Commit 5806aff73ff624ab8dbb189d7d4a58683c45ffa3

Authored by 徐烜
2 parents ffca2013 1219bdf8

Merge branch 'minhang' of http://222.66.0.204:8090//panzhaov5/bsth_control into minhang

Too many changes to show.

To preserve performance only 15 of 33 files are displayed.

src/main/java/com/bsth/controller/gps/GpsController.java
... ... @@ -195,12 +195,10 @@ public class GpsController {
195 195 }
196 196  
197 197 @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
198   - public PageObject<GpsSpeed> pagequery(@RequestParam Map<String, Object> map){
199   - PageObject<GpsSpeed> pageObject = null;
  198 + public Map<String, Object> pagequery(@RequestParam Map<String, Object> map){
200 199 map.put("curPage", map.get("page").toString());
201 200 map.put("pageData","10");
202   - pageObject=gpsService.Pagequery(map);
203   - return pageObject;
  201 + return gpsService.Pagequery(map);
204 202 }
205 203  
206 204 }
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -335,8 +335,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
335 335 @RequestMapping(value = "/correctForm")
336 336 public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,
337 337 @RequestParam String endDate,
338   - @RequestParam String lpName, @RequestParam String code, @RequestParam String type) {
339   - return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type);
  338 + @RequestParam String lpName, @RequestParam String code,
  339 + @RequestParam String type,@RequestParam String changType) {
  340 + return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);
340 341 }
341 342 /**
342 343 * @Title queryListWaybill
... ...
src/main/java/com/bsth/controller/report/ReportController.java
... ... @@ -6,12 +6,15 @@ import java.util.Iterator;
6 6 import java.util.List;
7 7 import java.util.Map;
8 8  
  9 +import org.apache.commons.lang3.StringEscapeUtils;
9 10 import org.springframework.beans.factory.annotation.Autowired;
10 11 import org.springframework.web.bind.annotation.RequestMapping;
11 12 import org.springframework.web.bind.annotation.RequestMethod;
12 13 import org.springframework.web.bind.annotation.RequestParam;
13 14 import org.springframework.web.bind.annotation.RestController;
14 15  
  16 +import com.alibaba.fastjson.JSONArray;
  17 +import com.alibaba.fastjson.JSONObject;
15 18 import com.bsth.entity.StationRoute;
16 19 import com.bsth.entity.excep.ArrivalInfo;
17 20 import com.bsth.entity.realcontrol.ScheduleRealInfo;
... ... @@ -276,4 +279,40 @@ public class ReportController {
276 279 public List<Map<String, Object>> countDjg(@RequestParam Map<String, Object> map){
277 280 return service.countDjg(map);
278 281 }
  282 +
  283 +
  284 + @RequestMapping(value="/countDjgXx")
  285 + public List<Map<String, Object>> countDjgXx(@RequestParam Map<String, Object> map){
  286 + List<Map<String, Object>> lMap=new ArrayList<Map<String, Object>>();
  287 + String json =StringEscapeUtils.unescapeHtml4(map.get("listXx").toString());
  288 + JSONArray jsonArray=JSONArray.parseArray(json);
  289 + JSONObject jsonObject;
  290 + for (int x = 0; x < jsonArray.size(); x++) {
  291 + jsonObject=jsonArray.getJSONObject(x);
  292 + Map<String, Object> m_=new HashMap<String,Object>();
  293 + m_.put("fgsname", jsonObject.getString("fgsname"));
  294 + m_.put("xlName", jsonObject.getString("xlName"));
  295 + m_.put("djgde", jsonObject.getString("djgde"));
  296 + m_.put("qJh", jsonObject.getString("qJh"));
  297 + m_.put("qSj", jsonObject.getString("qSj"));
  298 + m_.put("hJh", jsonObject.getString("hJh"));
  299 + m_.put("hSj", jsonObject.getString("hSj"));
  300 + lMap.add(m_);
  301 + }
  302 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  303 + Map<String, Object> m = new HashMap<String, Object>();
  304 + m.put("date", map.get("date").toString());
  305 + ReportUtils ee = new ReportUtils();
  306 + try {
  307 + listI.add(lMap.iterator());
  308 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  309 + ee.excelReplace(listI, new Object[]{m}, path + "mould/countIntervalXx.xls",
  310 + path + "export/大间隔统计表详细.xls");
  311 + } catch (Exception e) {
  312 + // TODO: handle exception
  313 + e.printStackTrace();
  314 + }
  315 +
  316 + return lMap;
  317 + }
279 318 }
... ...
src/main/java/com/bsth/data/pinyin/PersionPinYin.java
1   -package com.bsth.data.pinyin;
2   -
3   -import com.fasterxml.jackson.annotation.JsonIgnore;
4   -
5   -/**
6   - * 人员拼音映射
7   - * Created by panzhao on 2017/7/19.
8   - */
9   -public class PersionPinYin {
10   -
11   - /**
12   - * Id
13   - */
14   - private Integer id;
15   -
16   - /**
17   - * 工号
18   - */
19   - private String workId;
20   -
21   - /**
22   - * 姓名
23   - */
24   - private String name;
25   -
26   - /**
27   - * 全拼
28   - */
29   - private String fullChars;
30   -
31   - /**
32   - * 简便
33   - */
34   - private String camelChars;
35   -
36   - /**
37   - * 所属公司编码
38   - */
39   - @JsonIgnore
40   - private String companyId;
41   -
42   - /**
43   - * 所属分公司编码
44   - */
45   - @JsonIgnore
46   - private String fgsCompanyId;
47   -
48   - public String getWorkId() {
49   - return workId;
50   - }
51   -
52   - public void setWorkId(String workId) {
53   - this.workId = workId;
54   - }
55   -
56   - public String getName() {
57   - return name;
58   - }
59   -
60   - public void setName(String name) {
61   - this.name = name;
62   - }
63   -
64   - public String getFullChars() {
65   - return fullChars;
66   - }
67   -
68   - public void setFullChars(String fullChars) {
69   - this.fullChars = fullChars;
70   - }
71   -
72   - public String getCamelChars() {
73   - return camelChars;
74   - }
75   -
76   - public void setCamelChars(String camelChars) {
77   - this.camelChars = camelChars;
78   - }
79   -
80   - public String getCompanyId() {
81   - return companyId;
82   - }
83   -
84   - public void setCompanyId(String companyId) {
85   - this.companyId = companyId;
86   - }
87   -
88   - public String getFgsCompanyId() {
89   - return fgsCompanyId;
90   - }
91   -
92   - public void setFgsCompanyId(String fgsCompanyId) {
93   - this.fgsCompanyId = fgsCompanyId;
94   - }
95   -
96   - public Integer getId() {
97   - return id;
98   - }
99   -
100   - public void setId(Integer id) {
101   - this.id = id;
102   - }
103   -}
  1 +package com.bsth.data.pinyin;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnore;
  4 +
  5 +/**
  6 + * 人员拼音映射
  7 + * Created by panzhao on 2017/7/19.
  8 + */
  9 +public class PersionPinYin {
  10 +
  11 + /**
  12 + * Id
  13 + */
  14 + private Integer id;
  15 +
  16 + /**
  17 + * 工号
  18 + */
  19 + private String workId;
  20 +
  21 + /**
  22 + * 姓名
  23 + */
  24 + private String name;
  25 +
  26 + /**
  27 + * 全拼
  28 + */
  29 + private String fullChars;
  30 +
  31 + /**
  32 + * 简便
  33 + */
  34 + private String camelChars;
  35 +
  36 + /**
  37 + * 所属公司编码
  38 + */
  39 + @JsonIgnore
  40 + private String companyId;
  41 +
  42 + /**
  43 + * 所属分公司编码
  44 + */
  45 + @JsonIgnore
  46 + private String fgsCompanyId;
  47 +
  48 + public String getWorkId() {
  49 + return workId;
  50 + }
  51 +
  52 + public void setWorkId(String workId) {
  53 + this.workId = workId;
  54 + }
  55 +
  56 + public String getName() {
  57 + return name;
  58 + }
  59 +
  60 + public void setName(String name) {
  61 + this.name = name;
  62 + }
  63 +
  64 + public String getFullChars() {
  65 + return fullChars;
  66 + }
  67 +
  68 + public void setFullChars(String fullChars) {
  69 + this.fullChars = fullChars;
  70 + }
  71 +
  72 + public String getCamelChars() {
  73 + return camelChars;
  74 + }
  75 +
  76 + public void setCamelChars(String camelChars) {
  77 + this.camelChars = camelChars;
  78 + }
  79 +
  80 + public String getCompanyId() {
  81 + return companyId;
  82 + }
  83 +
  84 + public void setCompanyId(String companyId) {
  85 + this.companyId = companyId;
  86 + }
  87 +
  88 + public String getFgsCompanyId() {
  89 + return fgsCompanyId;
  90 + }
  91 +
  92 + public void setFgsCompanyId(String fgsCompanyId) {
  93 + this.fgsCompanyId = fgsCompanyId;
  94 + }
  95 +
  96 + public Integer getId() {
  97 + return id;
  98 + }
  99 +
  100 + public void setId(Integer id) {
  101 + this.id = id;
  102 + }
  103 +}
... ...
src/main/java/com/bsth/data/pinyin/PersionPinYinBuffer.java
1   -package com.bsth.data.pinyin;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.entity.Personnel;
5   -import com.bsth.entity.sys.CompanyAuthority;
6   -import com.github.stuxuhai.jpinyin.PinyinException;
7   -import com.github.stuxuhai.jpinyin.PinyinFormat;
8   -import com.github.stuxuhai.jpinyin.PinyinHelper;
9   -import com.google.common.collect.ArrayListMultimap;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -import org.springframework.stereotype.Component;
13   -
14   -import java.util.ArrayList;
15   -import java.util.Collection;
16   -import java.util.List;
17   -
18   -/**
19   - * 人员拼音数据映射缓存
20   - * Created by panzhao on 2017/7/19.
21   - */
22   -@Component
23   -public class PersionPinYinBuffer {
24   -
25   - static ArrayListMultimap<String, PersionPinYin> listMultimap = ArrayListMultimap.create();
26   - static List<PersionPinYin> all = new ArrayList<>();
27   -
28   - Logger log = LoggerFactory.getLogger(this.getClass());
29   -
30   -
31   - public void refresh(){
32   - ArrayListMultimap<String, PersionPinYin> listMultimapCopy = ArrayListMultimap.create();
33   - List<PersionPinYin> allCopy = new ArrayList<>();
34   - PersionPinYin ppy;
35   -
36   - Collection<Personnel> list = BasicData.perMap.values();
37   - for(Personnel p : list){
38   - ppy = new PersionPinYin();
39   - ppy.setId(p.getId());
40   - ppy.setCompanyId(p.getCompanyCode());
41   - ppy.setFgsCompanyId(p.getBrancheCompanyCode());
42   - ppy.setName(p.getPersonnelName());
43   - ppy.setWorkId(p.getJobCode());
44   - try {
45   - ppy.setFullChars(PinyinHelper.convertToPinyinString(ppy.getName(), "" , PinyinFormat.WITHOUT_TONE));
46   - ppy.setCamelChars(PinyinHelper.getShortPinyin(ppy.getName()));
47   - }catch (PinyinException pye){
48   - log.error("拼音转换出现异常," + ppy.getName(), pye);
49   - continue;
50   - }
51   -
52   - listMultimapCopy.put(ppy.getCompanyId() + "_" + ppy.getFgsCompanyId(), ppy);
53   - allCopy.add(ppy);
54   - }
55   -
56   - if(allCopy.size() > 0){
57   - all = allCopy;
58   - listMultimap = listMultimapCopy;
59   - }
60   - }
61   -
62   - public List<PersionPinYin> getAll(){
63   - return all;
64   - }
65   -
66   - public List<PersionPinYin> getAll(List<CompanyAuthority> auths){
67   - List<PersionPinYin> rs = new ArrayList<>();
68   - for(CompanyAuthority ca : auths){
69   - rs.addAll(listMultimap.get(ca.getCompanyCode() + "_" + ca.getSubCompanyCode()));
70   - }
71   - return rs;
72   - }
73   -}
  1 +package com.bsth.data.pinyin;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.entity.Personnel;
  5 +import com.bsth.entity.sys.CompanyAuthority;
  6 +import com.github.stuxuhai.jpinyin.PinyinException;
  7 +import com.github.stuxuhai.jpinyin.PinyinFormat;
  8 +import com.github.stuxuhai.jpinyin.PinyinHelper;
  9 +import com.google.common.collect.ArrayListMultimap;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.ArrayList;
  15 +import java.util.Collection;
  16 +import java.util.List;
  17 +
  18 +/**
  19 + * 人员拼音数据映射缓存
  20 + * Created by panzhao on 2017/7/19.
  21 + */
  22 +@Component
  23 +public class PersionPinYinBuffer {
  24 +
  25 + static ArrayListMultimap<String, PersionPinYin> listMultimap = ArrayListMultimap.create();
  26 + static List<PersionPinYin> all = new ArrayList<>();
  27 +
  28 + Logger log = LoggerFactory.getLogger(this.getClass());
  29 +
  30 +
  31 + public void refresh(){
  32 + ArrayListMultimap<String, PersionPinYin> listMultimapCopy = ArrayListMultimap.create();
  33 + List<PersionPinYin> allCopy = new ArrayList<>();
  34 + PersionPinYin ppy;
  35 +
  36 + Collection<Personnel> list = BasicData.perMap.values();
  37 + for(Personnel p : list){
  38 + ppy = new PersionPinYin();
  39 + ppy.setId(p.getId());
  40 + ppy.setCompanyId(p.getCompanyCode());
  41 + ppy.setFgsCompanyId(p.getBrancheCompanyCode());
  42 + ppy.setName(p.getPersonnelName());
  43 + ppy.setWorkId(p.getJobCode());
  44 + try {
  45 + ppy.setFullChars(PinyinHelper.convertToPinyinString(ppy.getName(), "" , PinyinFormat.WITHOUT_TONE));
  46 + ppy.setCamelChars(PinyinHelper.getShortPinyin(ppy.getName()));
  47 + }catch (PinyinException pye){
  48 + log.error("拼音转换出现异常," + ppy.getName(), pye);
  49 + continue;
  50 + }
  51 +
  52 + listMultimapCopy.put(ppy.getCompanyId() + "_" + ppy.getFgsCompanyId(), ppy);
  53 + allCopy.add(ppy);
  54 + }
  55 +
  56 + if(allCopy.size() > 0){
  57 + all = allCopy;
  58 + listMultimap = listMultimapCopy;
  59 + }
  60 + }
  61 +
  62 + public List<PersionPinYin> getAll(){
  63 + return all;
  64 + }
  65 +
  66 + public List<PersionPinYin> getAll(List<CompanyAuthority> auths){
  67 + List<PersionPinYin> rs = new ArrayList<>();
  68 + for(CompanyAuthority ca : auths){
  69 + rs.addAll(listMultimap.get(ca.getCompanyCode() + "_" + ca.getSubCompanyCode()));
  70 + }
  71 + return rs;
  72 + }
  73 +}
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -797,6 +797,7 @@ public class DayOfSchedule {
797 797  
798 798 public void save(ScheduleRealInfo sch) {
799 799 //schRepository.save(sch);
  800 + sch.setUpdateDate(new Date());
800 801 pstBuffer.add(sch);
801 802 }
802 803  
... ...
src/main/java/com/bsth/data/schedule/f_a_l/FirstAndLastHandler.java
1   -package com.bsth.data.schedule.f_a_l;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.data.schedule.DayOfSchedule;
5   -import com.bsth.data.schedule.ScheduleComparator;
6   -import com.bsth.data.schedule.f_a_l.entity.ToGateway;
7   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
8   -import com.bsth.util.db.DBUtils_MS;
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.factory.annotation.Autowired;
12   -import org.springframework.jdbc.core.BatchPreparedStatementSetter;
13   -import org.springframework.jdbc.core.JdbcTemplate;
14   -import org.springframework.jdbc.datasource.DataSourceTransactionManager;
15   -import org.springframework.stereotype.Component;
16   -import org.springframework.transaction.TransactionDefinition;
17   -import org.springframework.transaction.TransactionStatus;
18   -import org.springframework.transaction.support.DefaultTransactionDefinition;
19   -
20   -import java.sql.PreparedStatement;
21   -import java.sql.SQLException;
22   -import java.util.ArrayList;
23   -import java.util.Collections;
24   -import java.util.List;
25   -import java.util.concurrent.ConcurrentHashMap;
26   -
27   -/**
28   - * 首末班处理程序
29   - * Created by panzhao on 2017/7/19.
30   - */
31   -@Component
32   -public class FirstAndLastHandler {
33   -
34   - static ConcurrentHashMap<String, ToGateway> maps = new ConcurrentHashMap<>();
35   -
36   - static Logger log = LoggerFactory.getLogger(FirstAndLastHandler.class);
37   -
38   - static boolean flag;
39   -
40   - @Autowired
41   - DayOfSchedule dayOfSchedule;
42   -
43   - public void marks(String lineCode){
44   - marks(dayOfSchedule.findByLineCode(lineCode));
45   - }
46   -
47   - /**
48   - * 标记首末班
49   - * @param list
50   - */
51   - public static void marks(List<ScheduleRealInfo> list){
52   - try{
53   - Collections.sort(list, new ScheduleComparator.FCSJ());
54   - //按上下行分组
55   - List<ScheduleRealInfo> ups = new ArrayList<>(),
56   - downs = new ArrayList<>();
57   -
58   - for(ScheduleRealInfo sch : list){
59   - if(sch.getXlDir().equals("0"))
60   - ups.add(sch);
61   - else
62   - downs.add(sch);
63   - }
64   -
65   - markOneWay(ups);
66   - markOneWay(downs);
67   - }catch (Exception e){
68   - log.error("", e);
69   - }
70   - }
71   -
72   - /**
73   - * 标记单程,上行或下行
74   - * @param list
75   - */
76   - private static void markOneWay(List<ScheduleRealInfo> list){
77   - ScheduleRealInfo first = null, last = null;
78   -
79   - for(ScheduleRealInfo sch: list){
80   - if(sch._isInout() || sch.getBcType().equals("region")
81   - || sch.getBcType().equals("venting"))
82   - continue;
83   -
84   - if(first == null)
85   - first = sch;
86   -
87   - last = sch;
88   - }
89   -
90   - put(first, last);
91   - }
92   -
93   - private static void put(ScheduleRealInfo first, ScheduleRealInfo last){
94   - if(first == null || last == null)
95   - return;
96   -
97   - ToGateway tg = new ToGateway();
98   - tg.setLineCode(first.getXlBm());
99   - tg.setUpDown(Integer.parseInt(first.getXlDir()));
100   - tg.setsDeviceId(BasicData.deviceId2NbbmMap.inverse().get(first.getClZbh()));
101   - tg.setSt(first.getDfsjT());
102   -
103   - tg.setRq(first.getScheduleDateStr());
104   -
105   - tg.seteDeviceId(BasicData.deviceId2NbbmMap.inverse().get(last.getClZbh()));
106   - tg.setEt(last.getDfsjT());
107   -
108   - maps.put(tg.getLineCode() + "_" + tg.getUpDown(), tg);
109   - flag = true;
110   - }
111   -
112   - public static void saveAll(){
113   - if(!flag)
114   - return;
115   -
116   - final List<ToGateway> pstList = new ArrayList<>(maps.values());
117   - if(pstList == null || pstList.size() == 0)
118   - return;
119   -
120   - flag = false;
121   - JdbcTemplate jdbcTemp = new JdbcTemplate(DBUtils_MS.getDataSource());
122   - //编程式事务
123   - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemp.getDataSource());
124   - DefaultTransactionDefinition def = new DefaultTransactionDefinition();
125   - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
126   - TransactionStatus status = tran.getTransaction(def);
127   -
128   - try{
129   - //删除
130   - jdbcTemp.update("delete from bsth_t_first_last");
131   - //重新写入
132   - jdbcTemp.batchUpdate("insert into bsth_t_first_last(line_code, s_device_id, st, e_device_id, et, up_down, rq) VALUES(?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
133   - @Override
134   - public void setValues(PreparedStatement ps, int i) throws SQLException {
135   - ToGateway tg = pstList.get(i);
136   - ps.setString(1, tg.getLineCode());
137   - ps.setString(2, tg.getsDeviceId());
138   - ps.setLong(3, tg.getSt());
139   - ps.setString(4, tg.geteDeviceId());
140   - ps.setLong(5, tg.getEt());
141   - ps.setInt(6, tg.getUpDown());
142   - ps.setString(7, tg.getRq());
143   - }
144   -
145   - @Override
146   - public int getBatchSize() {
147   - return pstList.size();
148   - }
149   - });
150   -
151   - log.info("首末班数据入库," + pstList.size());
152   - tran.commit(status);
153   - }catch (Exception e){
154   - log.error("", e);
155   - tran.rollback(status);
156   - }
157   - }
158   -}
  1 +package com.bsth.data.schedule.f_a_l;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.schedule.DayOfSchedule;
  5 +import com.bsth.data.schedule.ScheduleComparator;
  6 +import com.bsth.data.schedule.f_a_l.entity.ToGateway;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import com.bsth.util.db.DBUtils_MS;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  13 +import org.springframework.jdbc.core.JdbcTemplate;
  14 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  15 +import org.springframework.stereotype.Component;
  16 +import org.springframework.transaction.TransactionDefinition;
  17 +import org.springframework.transaction.TransactionStatus;
  18 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  19 +
  20 +import java.sql.PreparedStatement;
  21 +import java.sql.SQLException;
  22 +import java.util.ArrayList;
  23 +import java.util.Collections;
  24 +import java.util.List;
  25 +import java.util.concurrent.ConcurrentHashMap;
  26 +
  27 +/**
  28 + * 首末班处理程序
  29 + * Created by panzhao on 2017/7/19.
  30 + */
  31 +@Component
  32 +public class FirstAndLastHandler {
  33 +
  34 + static ConcurrentHashMap<String, ToGateway> maps = new ConcurrentHashMap<>();
  35 +
  36 + static Logger log = LoggerFactory.getLogger(FirstAndLastHandler.class);
  37 +
  38 + static boolean flag;
  39 +
  40 + @Autowired
  41 + DayOfSchedule dayOfSchedule;
  42 +
  43 + public void marks(String lineCode){
  44 + marks(dayOfSchedule.findByLineCode(lineCode));
  45 + }
  46 +
  47 + /**
  48 + * 标记首末班
  49 + * @param list
  50 + */
  51 + public static void marks(List<ScheduleRealInfo> list){
  52 + try{
  53 + Collections.sort(list, new ScheduleComparator.FCSJ());
  54 + //按上下行分组
  55 + List<ScheduleRealInfo> ups = new ArrayList<>(),
  56 + downs = new ArrayList<>();
  57 +
  58 + for(ScheduleRealInfo sch : list){
  59 + if(sch.getXlDir().equals("0"))
  60 + ups.add(sch);
  61 + else
  62 + downs.add(sch);
  63 + }
  64 +
  65 + markOneWay(ups);
  66 + markOneWay(downs);
  67 + }catch (Exception e){
  68 + log.error("", e);
  69 + }
  70 + }
  71 +
  72 + /**
  73 + * 标记单程,上行或下行
  74 + * @param list
  75 + */
  76 + private static void markOneWay(List<ScheduleRealInfo> list){
  77 + ScheduleRealInfo first = null, last = null;
  78 +
  79 + for(ScheduleRealInfo sch: list){
  80 + if(sch._isInout() || sch.getBcType().equals("region")
  81 + || sch.getBcType().equals("venting"))
  82 + continue;
  83 +
  84 + if(first == null)
  85 + first = sch;
  86 +
  87 + last = sch;
  88 + }
  89 +
  90 + put(first, last);
  91 + }
  92 +
  93 + private static void put(ScheduleRealInfo first, ScheduleRealInfo last){
  94 + if(first == null || last == null)
  95 + return;
  96 +
  97 + ToGateway tg = new ToGateway();
  98 + tg.setLineCode(first.getXlBm());
  99 + tg.setUpDown(Integer.parseInt(first.getXlDir()));
  100 + tg.setsDeviceId(BasicData.deviceId2NbbmMap.inverse().get(first.getClZbh()));
  101 + tg.setSt(first.getDfsjT());
  102 +
  103 + tg.setRq(first.getScheduleDateStr());
  104 +
  105 + tg.seteDeviceId(BasicData.deviceId2NbbmMap.inverse().get(last.getClZbh()));
  106 + tg.setEt(last.getDfsjT());
  107 +
  108 + maps.put(tg.getLineCode() + "_" + tg.getUpDown(), tg);
  109 + flag = true;
  110 + }
  111 +
  112 + public static void saveAll(){
  113 + if(!flag)
  114 + return;
  115 +
  116 + final List<ToGateway> pstList = new ArrayList<>(maps.values());
  117 + if(pstList == null || pstList.size() == 0)
  118 + return;
  119 +
  120 + flag = false;
  121 + JdbcTemplate jdbcTemp = new JdbcTemplate(DBUtils_MS.getDataSource());
  122 + //编程式事务
  123 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemp.getDataSource());
  124 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  125 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  126 + TransactionStatus status = tran.getTransaction(def);
  127 +
  128 + try{
  129 + //删除
  130 + jdbcTemp.update("delete from bsth_t_first_last");
  131 + //重新写入
  132 + jdbcTemp.batchUpdate("insert into bsth_t_first_last(line_code, s_device_id, st, e_device_id, et, up_down, rq) VALUES(?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
  133 + @Override
  134 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  135 + ToGateway tg = pstList.get(i);
  136 + ps.setString(1, tg.getLineCode());
  137 + ps.setString(2, tg.getsDeviceId());
  138 + ps.setLong(3, tg.getSt());
  139 + ps.setString(4, tg.geteDeviceId());
  140 + ps.setLong(5, tg.getEt());
  141 + ps.setInt(6, tg.getUpDown());
  142 + ps.setString(7, tg.getRq());
  143 + }
  144 +
  145 + @Override
  146 + public int getBatchSize() {
  147 + return pstList.size();
  148 + }
  149 + });
  150 +
  151 + log.info("首末班数据入库," + pstList.size());
  152 + tran.commit(status);
  153 + }catch (Exception e){
  154 + log.error("", e);
  155 + tran.rollback(status);
  156 + }
  157 + }
  158 +}
... ...
src/main/java/com/bsth/data/schedule/f_a_l/entity/ToGateway.java
1   -package com.bsth.data.schedule.f_a_l.entity;
2   -
3   -/**
4   - * 发送给网关的首末班数据格式
5   - * Created by panzhao on 2017/7/19.
6   - */
7   -public class ToGateway {
8   -
9   - /** 线路 */
10   - private String lineCode;
11   -
12   - /** 上下行 */
13   - private int upDown;
14   -
15   - /** 首班设备号 */
16   - private String sDeviceId;
17   -
18   - /** 首班时间 */
19   - private Long st;
20   -
21   - /** 末班设备号 */
22   - private String eDeviceId;
23   -
24   - /** 末班时间 */
25   - private Long et;
26   -
27   - /** 班次日期 */
28   - private String rq;
29   -
30   -
31   - public String getLineCode() {
32   - return lineCode;
33   - }
34   -
35   - public void setLineCode(String lineCode) {
36   - this.lineCode = lineCode;
37   - }
38   -
39   - public Long getSt() {
40   - return st;
41   - }
42   -
43   - public void setSt(Long st) {
44   - this.st = st;
45   - }
46   -
47   - public Long getEt() {
48   - return et;
49   - }
50   -
51   - public void setEt(Long et) {
52   - this.et = et;
53   - }
54   -
55   - public String getRq() {
56   - return rq;
57   - }
58   -
59   - public void setRq(String rq) {
60   - this.rq = rq;
61   - }
62   -
63   - public int getUpDown() {
64   - return upDown;
65   - }
66   -
67   - public void setUpDown(int upDown) {
68   - this.upDown = upDown;
69   - }
70   -
71   - public String getsDeviceId() {
72   - return sDeviceId;
73   - }
74   -
75   - public void setsDeviceId(String sDeviceId) {
76   - this.sDeviceId = sDeviceId;
77   - }
78   -
79   - public String geteDeviceId() {
80   - return eDeviceId;
81   - }
82   -
83   - public void seteDeviceId(String eDeviceId) {
84   - this.eDeviceId = eDeviceId;
85   - }
86   -}
  1 +package com.bsth.data.schedule.f_a_l.entity;
  2 +
  3 +/**
  4 + * 发送给网关的首末班数据格式
  5 + * Created by panzhao on 2017/7/19.
  6 + */
  7 +public class ToGateway {
  8 +
  9 + /** 线路 */
  10 + private String lineCode;
  11 +
  12 + /** 上下行 */
  13 + private int upDown;
  14 +
  15 + /** 首班设备号 */
  16 + private String sDeviceId;
  17 +
  18 + /** 首班时间 */
  19 + private Long st;
  20 +
  21 + /** 末班设备号 */
  22 + private String eDeviceId;
  23 +
  24 + /** 末班时间 */
  25 + private Long et;
  26 +
  27 + /** 班次日期 */
  28 + private String rq;
  29 +
  30 +
  31 + public String getLineCode() {
  32 + return lineCode;
  33 + }
  34 +
  35 + public void setLineCode(String lineCode) {
  36 + this.lineCode = lineCode;
  37 + }
  38 +
  39 + public Long getSt() {
  40 + return st;
  41 + }
  42 +
  43 + public void setSt(Long st) {
  44 + this.st = st;
  45 + }
  46 +
  47 + public Long getEt() {
  48 + return et;
  49 + }
  50 +
  51 + public void setEt(Long et) {
  52 + this.et = et;
  53 + }
  54 +
  55 + public String getRq() {
  56 + return rq;
  57 + }
  58 +
  59 + public void setRq(String rq) {
  60 + this.rq = rq;
  61 + }
  62 +
  63 + public int getUpDown() {
  64 + return upDown;
  65 + }
  66 +
  67 + public void setUpDown(int upDown) {
  68 + this.upDown = upDown;
  69 + }
  70 +
  71 + public String getsDeviceId() {
  72 + return sDeviceId;
  73 + }
  74 +
  75 + public void setsDeviceId(String sDeviceId) {
  76 + this.sDeviceId = sDeviceId;
  77 + }
  78 +
  79 + public String geteDeviceId() {
  80 + return eDeviceId;
  81 + }
  82 +
  83 + public void seteDeviceId(String eDeviceId) {
  84 + this.eDeviceId = eDeviceId;
  85 + }
  86 +}
... ...
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
1 1 package com.bsth.data.schedule.thread;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.schedule.DayOfSchedule;
4 5 import com.bsth.entity.realcontrol.ScheduleRealInfo;
5 6 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
6 7 import org.slf4j.Logger;
7 8 import org.slf4j.LoggerFactory;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9   -import org.springframework.orm.jpa.JpaObjectRetrievalFailureException;
  10 +import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
  11 +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
10 12 import org.springframework.stereotype.Component;
11 13  
12   -import javax.persistence.EntityNotFoundException;
13   -
14 14 /**
15 15 * @author PanZhao
16 16 * @ClassName: SchedulePstThread
... ... @@ -23,36 +23,68 @@ public class SchedulePstThread extends Thread {
23 23 @Autowired
24 24 ScheduleRealInfoRepository scheduleRepository;
25 25  
  26 + @Autowired
  27 + NamedParameterJdbcTemplate jdbcTemplate;
  28 +
  29 + @Autowired
  30 + DayOfSchedule dayOfSchedule;
  31 +
26 32 Logger logger = LoggerFactory.getLogger(this.getClass());
27 33  
28 34 @Override
29 35 public void run() {
30 36  
31   - //LinkedList<ScheduleRealInfo> list = DayOfSchedule.pstBuffer;
32   -
33 37 ScheduleRealInfo schedule;
34 38 for (int i = 0; i < 1000; i++) {
35 39 schedule = DayOfSchedule.pstBuffer.poll();
36 40 if (null == schedule)
37 41 break;
38 42  
39   - if(schedule.isDeleted()){
  43 + if (schedule.isDeleted()) {
40 44 logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId());
41 45 continue;
42 46 }
43 47  
44   - try {
45   - scheduleRepository.save(schedule);
46   - }
47   - catch (JpaObjectRetrievalFailureException e1){
48   - logger.error("JpaObjectRetrievalFailureException error.... 可忽略");
49   - }
50   - catch(EntityNotFoundException e2){
51   - logger.error("EntityNotFoundException error.... 可忽略");
52   - }
53   - catch (Exception e) {
54   - logger.error("班次入库的时候出现未知异常!!", e);
55   - }
  48 + save(schedule);
  49 + }
  50 + }
  51 +
  52 + /**
  53 + * 班次更新到数据库,不走jpa
  54 + *
  55 + * @param sch
  56 + */
  57 + public void save(ScheduleRealInfo sch) {
  58 + if (sch.getId() == null) {
  59 + logger.error("入库的班次没有ID, " + JSON.toJSONString(sch));
  60 + return;
  61 + }
  62 +
  63 + if(sch.getSaveFailCount() > 5){
  64 + logger.error("入库失败上限, " + JSON.toJSONString(sch));
  65 + return;
  66 + }
  67 +
  68 + try {
  69 + String sql = "UPDATE bsth_c_s_sp_info_real" +
  70 + " SET adjust_exps=:adjustExps, bc_type=:bcType, bcs=:bcs, bcsj=:bcsj, ccno=:ccno, cl_zbh=:clZbh, df_auto=:dfAuto," +
  71 + " dfsj=:dfsj, directive_state=:directiveState, fcno=:fcno, fcsj=:fcsj, fcsj_actual=:fcsjActual, fgs_bm=:fgsBm, fgs_name=:fgsName, gs_bm=:gsBm, gs_name=:gsName," +
  72 + " j_gh=:jGh, j_name=:jName, jhlc=:jhlc, jhlc_orig=:jhlcOrig, lp_name=:lpName, ONLINE=:online, qdz_code=:qdzCode, qdz_name=:qdzName," +
  73 + " real_exec_date=:realExecDate, reissue=:reissue, remarks=:remarks, s_gh=:sGh, s_name=:sName, schedule_date=:scheduleDate," +
  74 + " schedule_date_str=:scheduleDateStr, sflj=:sflj, sp_id=:spId, STATUS=:status, update_date=:updateDate, xl_bm=:xlBm, xl_dir=:xlDir, xl_name=:xlName," +
  75 + " zdsj=:zdsj, zdsj_actual=:zdsjActual, zdz_code=:zdzCode, zdz_name=:zdzName" +
  76 + " WHERE " +
  77 + " id=:id";
  78 +
  79 + jdbcTemplate.update(sql, new BeanPropertySqlParameterSource(sch));
  80 + sch.setSaveFailCount(0);
  81 + } catch (Exception e) {
  82 + //下次入库再试
  83 + sch.setSaveFailCount(sch.getSaveFailCount()+1);
  84 + dayOfSchedule.save(sch);
  85 +
  86 + logger.error("班次 " + sch.getId() + "入库失败," + JSON.toJSONString(sch));
  87 + logger.error("", e);
56 88 }
57 89 }
58 90 }
... ...
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
... ... @@ -30,8 +30,9 @@ public class ScheduleRealInfo {
30 30 /** 计划ID */
31 31 private Long spId;
32 32  
33   - /** 排班计划日期 */
  33 + /** 排班计划日期 --no webSocket */
34 34 private Date scheduleDate;
  35 + /** 排班日期字符串 YYYY-MM-DD */
35 36 private String scheduleDateStr;
36 37  
37 38 /** 真实执行时间 yyyy-MM-dd */
... ... @@ -81,9 +82,9 @@ public class ScheduleRealInfo {
81 82 @Transient
82 83 private Long zdsjT;
83 84  
84   - /** 发车顺序号 */
  85 + /** 发车顺序号 --no webSocket*/
85 86 private Integer fcno;
86   - /** 对应班次数 */
  87 + /** 对应班次数 --no webSocket*/
87 88 private Integer bcs;
88 89 /** 计划里程 */
89 90 private Double jhlc;
... ... @@ -91,10 +92,12 @@ public class ScheduleRealInfo {
91 92 /** 原始计划里程 (原计调的数据) */
92 93 private Double jhlcOrig;
93 94  
94   - /** 实际里程 这个字段被废弃*/
  95 + /** 实际里程 --no webSocket*/
  96 + @Transient
  97 + @JsonIgnore
95 98 private Double realMileage;
96 99  
97   - /** 实际里程 */
  100 + /** 实际里程 --no webSocket */
98 101 @Transient
99 102 private String sjlc;
100 103 /** 班次历时 */
... ... @@ -153,7 +156,8 @@ public class ScheduleRealInfo {
153 156 /** 备注*/
154 157 private String remarks;
155 158  
156   - /** 原计划排班备注 */
  159 + /** 原计划排班备注 --no webSocket */
  160 + @Transient
157 161 private String remark;
158 162  
159 163 /**待发时间(格式 HH:mm) */
... ... @@ -166,9 +170,6 @@ public class ScheduleRealInfo {
166 170 /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */
167 171 private Integer directiveState = -1;
168 172  
169   - /** “运营状态” 指令下发状态 60: 已发送, 100: 设备确认收到 0:失败*/
170   - private Integer opDirectiveState;
171   -
172 173 /** 起点站计划到达时间 */
173 174 @Transient
174 175 private String qdzArrDatejh;
... ... @@ -200,7 +201,7 @@ public class ScheduleRealInfo {
200 201 /** 是否有补发GPS信号 */
201 202 private boolean reissue;
202 203  
203   - /** 发车屏 发车顺序号,不持久化,会动态变化 */
  204 + /** 发车屏 发车顺序号,不持久化,会动态变化 --no webSocket*/
204 205 @Transient
205 206 private int fcpSn;
206 207  
... ... @@ -209,6 +210,10 @@ public class ScheduleRealInfo {
209 210 @JsonIgnore
210 211 private boolean deleted;
211 212  
  213 + @Transient
  214 + @JsonIgnore
  215 + private int saveFailCount=0;
  216 +
212 217 public boolean isDfAuto() {
213 218 return dfAuto;
214 219 }
... ... @@ -486,7 +491,7 @@ public class ScheduleRealInfo {
486 491 if(this.isSflj())
487 492 this.setJhlcOrig(this.getJhlc());
488 493 }
489   -
  494 +
490 495 public String getSjlc() {
491 496 return sjlc;
492 497 }
... ... @@ -816,22 +821,6 @@ public class ScheduleRealInfo {
816 821 calcStatus();
817 822 }
818 823  
819   - public Integer getOpDirectiveState() {
820   - return opDirectiveState;
821   - }
822   -
823   - public void setOpDirectiveState(Integer opDirectiveState) {
824   - this.opDirectiveState = opDirectiveState;
825   - }
826   -
827   -/* public ScheduleRealInfo getTwinsSch() {
828   - return twinsSch;
829   - }
830   -
831   - public void setTwinsSch(ScheduleRealInfo twinsSch) {
832   - this.twinsSch = twinsSch;
833   - }*/
834   -
835 824 public boolean isLate() {
836 825 return late;
837 826 }
... ... @@ -925,4 +914,12 @@ public class ScheduleRealInfo {
925 914 public void setDeleted(boolean deleted) {
926 915 this.deleted = deleted;
927 916 }
  917 +
  918 + public int getSaveFailCount() {
  919 + return saveFailCount;
  920 + }
  921 +
  922 + public void setSaveFailCount(int saveFailCount) {
  923 + this.saveFailCount = saveFailCount;
  924 + }
928 925 }
... ...
src/main/java/com/bsth/service/gps/GpsService.java
... ... @@ -47,5 +47,5 @@ public interface GpsService {
47 47 List<GpsSpeed> findPosition(String deviceid, String startdate,
48 48 String enddate) throws ParseException;
49 49  
50   - PageObject<GpsSpeed> Pagequery(Map<String, Object> map);
  50 + Map<String, Object> Pagequery(Map<String, Object> map);
51 51 }
... ...
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
... ... @@ -1053,16 +1053,19 @@ public class GpsServiceImpl implements GpsService {
1053 1053 }
1054 1054  
1055 1055 @Override
1056   - public PageObject<GpsSpeed> Pagequery(Map<String, Object> map) {
1057   -
  1056 + public Map<String, Object> Pagequery(Map<String, Object> map) {
1058 1057 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1058 + Integer totalDays = 0;//数据跨越天数
  1059 + try {
  1060 + totalDays = (int) ((sdf.parse(map.get("endDate").toString()+" 23:59:59").getTime()-sdf.parse(map.get("startDate").toString()+" 00:00:00").getTime()+1)/(3600*24*1000))+1;
  1061 + } catch (ParseException e) {
  1062 + e.printStackTrace();
  1063 + }//总页数
  1064 + map.put("totalDays",totalDays);
1059 1065 List<GpsSpeed> list=findAll(map);
1060 1066 List<GpsSpeed> listResult = new ArrayList<GpsSpeed>();
1061   - int curPage;//页码
1062   - int pageData;//每页的记录条数
1063   - int start;//起始数据下标
1064   - int totalPage;//总页数
1065   - int totalData = 0;
  1067 + int curPage = 0;//页码
  1068 + int pageData = 0;//每页的记录条数
1066 1069 if(list.size()>1){
1067 1070 GpsSpeed GpsSpeedNow;//下标为i的车辆行驶记录
1068 1071 GpsSpeed GpsSpeedLast;//下标为i-1的车辆行驶记录
... ... @@ -1099,49 +1102,35 @@ public class GpsServiceImpl implements GpsService {
1099 1102 }
1100 1103 }
1101 1104 }
1102   - Iterator<GpsSpeed> speedIt = listResult.iterator();
1103   - while(speedIt.hasNext()){
1104   - GpsSpeed GpsSpeed = speedIt.next();
1105   - if(GpsSpeed.getEndtimestamp()-GpsSpeed.getTimestamp()<=1000){
1106   - speedIt.remove();
1107   - }
1108   - }
1109   -
1110   - totalData = listResult.size();//总记录条数。
1111   - if(map.get("curPage") == null || map.get("curPage").equals("0")){
1112   - curPage = 0;
1113   - }else{
1114   - curPage = Integer.parseInt((String) map.get("curPage"));
1115   - }
1116   - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
1117   - start = (curPage - 0) * pageData; //起始记录下标。
1118   - totalPage = totalData % pageData == 0 ? totalData / pageData : totalData / pageData +1;//总页数
1119   - if(curPage == totalPage-1){//如果当前页等于总页数。
1120   - listResult = listResult.subList(start, totalData);
1121   - }else{
1122   - listResult = listResult.subList(start, start+pageData);
  1105 + if(listResult.size()>0){
  1106 + Iterator<GpsSpeed> speedIt = listResult.iterator();
  1107 + while(speedIt.hasNext()){
  1108 + GpsSpeed GpsSpeed = speedIt.next();
  1109 + if(GpsSpeed.getEndtimestamp()-GpsSpeed.getTimestamp()<=1000){
  1110 + speedIt.remove();
  1111 + }
  1112 + }
1123 1113 }
1124   - }else{
1125   - curPage = 1;
1126   - pageData = Integer.parseInt((String) map.get("pageData"));//每页的记录条数
1127   - totalPage =1;
1128 1114 }
  1115 + if(map.get("curPage") == null || map.get("curPage").equals("0")){
  1116 + curPage = 0;
  1117 + }else{
  1118 + curPage = Integer.parseInt((String) map.get("curPage"));
  1119 + }
  1120 + Integer totalPage = totalDays;
  1121 + pageData = listResult.size();//每页的记录条数就是当前页查出的全部数据。
1129 1122 Map<String,Object> paramMap = new HashMap<String,Object>();
1130 1123 paramMap.put("totalPage", totalPage);
1131   - paramMap.put("curPage", curPage);
  1124 + paramMap.put("page", curPage);
1132 1125 paramMap.put("pageData", pageData);
1133   - PageHelper pageHelper = new PageHelper(totalData, paramMap);
1134   - pageHelper.getMap();
1135   - PageObject<GpsSpeed> pageObject = pageHelper.getPageObject();
1136   - pageObject.setDataList(listResult);
1137   - return pageObject;
  1126 + paramMap.put("list", listResult);
  1127 + return paramMap;
1138 1128 }
1139 1129  
1140 1130 static List<GpsSpeed> findAll(Map<String, Object> map) {
1141 1131 Connection conn = null;
1142 1132 PreparedStatement ps = null;
1143 1133 ResultSet rs = null;
1144   - int page=Integer.parseInt(map.get("page").toString());
1145 1134 List<GpsSpeed> list=new ArrayList<GpsSpeed>();
1146 1135 String sql="select * from bsth_c_gps_info where 1=1 ";
1147 1136 Object line=map.get("line");
... ... @@ -1149,6 +1138,13 @@ public class GpsServiceImpl implements GpsService {
1149 1138 Object updown=map.get("updown");
1150 1139 Object startDate=map.get("startDate");
1151 1140 Object endDate=map.get("endDate");
  1141 + Integer totalDays = Integer.valueOf(map.get("totalDays").toString());
  1142 + Integer curPage = 0;//页码
  1143 + if(map.get("curPage") == null || map.get("curPage").equals("0")){
  1144 + curPage = 0;
  1145 + }else{
  1146 + curPage = Integer.parseInt((String) map.get("curPage"));
  1147 + }
1152 1148  
1153 1149 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
1154 1150 if(line!=null){
... ... @@ -1167,7 +1163,7 @@ public class GpsServiceImpl implements GpsService {
1167 1163 if(startDate!=null){
1168 1164 if (startDate.toString().length()>0) {
1169 1165 try {
1170   - Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime();
  1166 + Long t1=sdf.parse(startDate.toString()+" 00:00:00").getTime()+curPage*3600*24*1000;
1171 1167 sql += " and ts >="+t1;
1172 1168 } catch (ParseException e) {
1173 1169 e.printStackTrace();
... ... @@ -1178,7 +1174,7 @@ public class GpsServiceImpl implements GpsService {
1178 1174 if(endDate!=null){
1179 1175 if (endDate.toString().length()>0) {
1180 1176 try {
1181   - Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime();
  1177 + Long t2=sdf.parse(endDate.toString()+" 23:59:59").getTime()-(totalDays-1-curPage)*3600*24*1000;
1182 1178 sql += " and ts <="+t2;
1183 1179 } catch (ParseException e) {
1184 1180 e.printStackTrace();
... ...
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
... ... @@ -105,7 +105,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
105 105 List<Map<String,Object>> accountPx(String line,String date,String code,String xlName, String px);
106 106  
107 107  
108   - List<SchEditInfoDto> correctForm(String line,String date,String endDate,String lpName,String code, String type);
  108 + List<SchEditInfoDto> correctForm(String line,String date,String endDate,String lpName,String code, String type,String changType);
109 109  
110 110 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line);
111 111  
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -1810,7 +1810,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1810 1810  
1811 1811 @Override
1812 1812 public List<SchEditInfoDto> correctForm(String line,String date,String endDate,
1813   - String lpName,String code, String type) {
  1813 + String lpName,String code, String type,String changType) {
1814 1814  
1815 1815 // var types = {'DFTZ': '待发调整', 'FCXXWT':'发车信息微调', 'JHLB': '计划烂班', 'CXLB': '撤销烂班',
1816 1816 // 'CXZX': '撤销执行', 'CXSF': '撤销实发', 'SFTZ': '实发调整', 'TZRC': '调整人车'};
... ... @@ -1824,6 +1824,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1824 1824 map.put("SFTZ", "实发调整");
1825 1825 map.put("TZRC", "调整人车");
1826 1826  
  1827 + SimpleDateFormat sdf1=new SimpleDateFormat("HH:mm");
  1828 + SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm");
1827 1829 String cont = "";
1828 1830 cont = " and xl_bm ='"+line +"'";
1829 1831 if(!lpName.equals("")){
... ... @@ -1832,7 +1834,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1832 1834 if(!code.equals("")){
1833 1835 cont +=" and cl_zbh ='"+code+"'";
1834 1836 }
1835   - String sql = "select t1.*, "
  1837 + String sql = "select t1.*, t2.real_exec_date,"
1836 1838 + "t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name,"
1837 1839 + "t2.xl_dir,t2.real_exec_date from (select * from "
1838 1840 + "logger_sch_modify where rq BETWEEN ? and ? and line_code=? )"
... ... @@ -1843,9 +1845,39 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1843 1845 new BeanPropertyRowMapper(SchEditInfoDto.class),date,endDate, line);
1844 1846 List<SchEditInfoDto> lists=new ArrayList<SchEditInfoDto>();
1845 1847 for (int i = 0; i < list.size(); i++) {
  1848 + Long fcsjs=0l;
  1849 + Long updsj=0l;
1846 1850 SchEditInfoDto t=list.get(i);
1847 1851 if(map.get(t.getType())!=null){
1848   - t.setType2(t.getUser()+"于"+t.getTimeStr()+"进行"+map.get(t.getType()).toString()+";");
  1852 +
  1853 + if(changType.equals("")){
  1854 + t.setType2(t.getUser()+"于"+t.getTimeStr()+"进行"+map.get(t.getType()).toString()+";");
  1855 + }else{
  1856 + String fcsj="";
  1857 + String updtime="";
  1858 + try {
  1859 + fcsj= sdf1.format(sdf1.parse(t.getFcsj()));
  1860 + updtime=sdf1.format(sdf1.parse(t.getTimeStr()));
  1861 + fcsjs=sdf2.parse(t.getRealExecDate()+" "+fcsj).getTime();
  1862 + updsj=sdf2.parse(t.getRq()+" "+updtime).getTime();
  1863 + } catch (ParseException e) {
  1864 + // TODO Auto-generated catch block
  1865 + e.printStackTrace();
  1866 + }
  1867 + if(changType.equals("1")){
  1868 + if(fcsjs>updsj){
  1869 + t.setType2(t.getUser()+"于"+t.getTimeStr()+"进行"+map.get(t.getType()).toString()+";");
  1870 + }else{
  1871 + t.setType2("");
  1872 + }
  1873 + }else if(changType.equals("2")){
  1874 + if(fcsjs<updsj){
  1875 + t.setType2(t.getUser()+"于"+t.getTimeStr()+"进行"+map.get(t.getType()).toString()+";");
  1876 + }else{
  1877 + t.setType2("");
  1878 + }
  1879 + }
  1880 + }
1849 1881 }else{
1850 1882 t.setType2("");
1851 1883 }
... ... @@ -1859,7 +1891,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1859 1891 }
1860 1892  
1861 1893 if(fage){
1862   - lists.add(t);
  1894 + if(changType.equals("")){
  1895 + lists.add(t);
  1896 + } else {
  1897 + if (changType.equals("1")) {
  1898 + if (fcsjs > updsj) {
  1899 + lists.add(t);
  1900 + }
  1901 + } else if (changType.equals("2")) {
  1902 + if (fcsjs < updsj) {
  1903 + lists.add(t);
  1904 + }
  1905 + }
  1906 + }
1863 1907 }
1864 1908 }
1865 1909  
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -4,6 +4,7 @@ import com.bsth.entity.Line;
4 4 import com.bsth.entity.Personnel;
5 5 import com.bsth.entity.StationRoute;
6 6 import com.bsth.entity.excep.ArrivalInfo;
  7 +import com.bsth.entity.mcy_forms.Daily;
7 8 import com.bsth.entity.oil.Dlb;
8 9 import com.bsth.entity.oil.Ylb;
9 10 import com.bsth.entity.realcontrol.ChildTaskPlan;
... ... @@ -2234,6 +2235,7 @@ public class ReportServiceImpl implements ReportService{
2234 2235 String date=map.get("date").toString();
2235 2236 String gsbm=map.get("gsbm").toString();
2236 2237 String fgsbm=map.get("fgsbm").toString();
  2238 + String type=map.get("type").toString();
2237 2239 List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
2238 2240 if(line.equals("")){
2239 2241 list=scheduleRealInfoRepository.scheduleByDateAndLineByGs(gsbm, fgsbm, date);
... ... @@ -2273,7 +2275,6 @@ public class ReportServiceImpl implements ReportService{
2273 2275 }
2274 2276 });
2275 2277  
2276   -
2277 2278 for (int i = 0; i < xlList.size(); i++) {
2278 2279 String lineCode=xlList.get(i).get("line").toString();
2279 2280 String grade =xlList.get(i).get("grade").toString();
... ... @@ -2309,6 +2310,7 @@ public class ReportServiceImpl implements ReportService{
2309 2310 e.printStackTrace();
2310 2311 }
2311 2312 }
  2313 +
2312 2314 if(listInfo.size()>0){
2313 2315 int sjbcs=culateService.culateSjbc(list_, "")+culateService.culateLjbc(list_, "");
2314 2316 Map<String, Object> m=listDjg(gsbm,fgsbm,lineCode,sjbcs,peak,trough,listInfo,grade);
... ... @@ -2316,6 +2318,21 @@ public class ReportServiceImpl implements ReportService{
2316 2318 }
2317 2319  
2318 2320 }
  2321 + if(type.equals("export")){
  2322 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  2323 + Map<String, Object> m = new HashMap<String, Object>();
  2324 + m.put("date", date);
  2325 + ReportUtils ee = new ReportUtils();
  2326 + try {
  2327 + listI.add(lMap.iterator());
  2328 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  2329 + ee.excelReplace(listI, new Object[]{m}, path + "mould/countInterval.xls",
  2330 + path + "export/大间隔统计表.xls");
  2331 + } catch (Exception e) {
  2332 + // TODO: handle exception
  2333 + e.printStackTrace();
  2334 + }
  2335 + }
2319 2336 return lMap;
2320 2337 }
2321 2338  
... ...