ScheduleRealInfoServiceImpl.java
3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.bsth.service.impl;
import com.bsth.entity.ScheduleRealInfo;
import com.bsth.entity.result.CalcWaybill;
import com.bsth.repository.ScheduleRealInfoRepository;
import com.bsth.service.*;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.bsth.entity.*;
/**
* Created by panzhao on 2017/7/27.
*/
@Service
public class ScheduleRealInfoServiceImpl implements ScheduleRealInfoService {
@Autowired
ScheduleRealInfoRepository scheduleRealInfoRepository;
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
LineConfigService lineConfigService;
Logger logger = LoggerFactory.getLogger(this.getClass());
private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"),
fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"),
fmtHHmm = DateTimeFormat.forPattern("HH:mm");
private final static long DAY_TIME = 1000 * 60 * 60 * 24L;
@Override
public List<CalcWaybill> findAll(String rq,String lineCode) {
List<ScheduleRealInfo> list = scheduleRealInfoRepository.findAll(rq,lineCode);
String sql ="select r.j_gh ,r.s_gh,r.cl_zbh,r.xl_bm, r.lp_name FROM"
+ " bsth_c_s_sp_info_real r where "
+ " r.schedule_date_str='"+rq+"' and r.xl_bm = '"+lineCode+"'"
+ " GROUP BY r.j_gh,r.xl_bm,r.lp_name ";
List<Map<String, String>> listMap = jdbcTemplate.query(sql, new RowMapper<Map<String, String>>() {
@Override
public Map<String, String> mapRow(ResultSet arg0, int arg1) throws SQLException {
Map<String, String> c = new HashMap<String,String>();
c.put("jGh", arg0.getString("j_gh"));
c.put("sGh", arg0.getString("s_gh")==null?"":arg0.getString("s_gh"));
c.put("clZbh", arg0.getString("cl_zbh"));
c.put("xlBm", arg0.getString("xl_bm"));
c.put("lpName", arg0.getString("lp_name"));
return c;
}
});
for (int i = 0; i < listMap.size(); i++) {
Map<String, String> m=listMap.get(i);
String jGh=m.get("jGh");
String sGh=m.get("sGh");
String clZbh=m.get("clZbh");
String xlBm=m.get("xlBm");
String lpName=m.get("lpName");
//所有数据排班数据
List<ScheduleRealInfo> list_=new ArrayList<ScheduleRealInfo>();
//执行了的班次的排班数据
List<ScheduleRealInfo> lists_=new ArrayList<ScheduleRealInfo>();
for (int j = 0; j < list.size(); j++) {
ScheduleRealInfo s=list.get(j);
if(jGh.equals(s.getjGh())
&& sGh.equals(s.getsGh()==null?"":s.getsGh())
&& clZbh.equals(s.getClZbh())
&& xlBm.equals(s.getXlBm())
&& lpName.equals(s.getLpName())){
list_.add(s);
Set<ChildTaskPlan> cts = s.getcTasks();
if(cts != null && cts.size() > 0){
lists_.add(s);
}else{
if(s.getZdsjActual()!=null
&& s.getFcsjActual() !=null){
lists_.add(s);
}
}
}
}
}
return null;
}
}