Commit f6a9a8f87704d969ad3151952ec3d679e258cbac

Authored by 娄高锋
2 parents 1b49b3fa b79f715f

Merge branch 'minhang' of 192.168.168.201:panzhaov5/bsth_control into minhang

Too many changes to show.

To preserve performance only 8 of 37 files are displayed.

src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -36,35 +36,13 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo,
36 36  
37 37 /**
38 38 *
39   - * 改由通过 websocket 注册监听!!!
40   - *
41   - * @Title: registerLine @Description: TODO(注册线路,后续才能收到数据推送) @param @param
42   - * lineCodes @throws
43   - * 用GET 防止监控模式下被拦截
44   -
45   - @RequestMapping(value = "/registerLine", method = RequestMethod.GET)
46   - public int registerLine(@RequestParam String lineCodes) {
47   - List<String> list = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(lineCodes);
48   - String userName = SecurityUtils.getCurrentUser().getUserName();
49   - // 注销之前的绑定
50   - for (String line : list)
51   - BasicData.lineCode2SocketUserMap.get(line).remove(userName);
52   - // 重新绑定
53   - for (String line : list)
54   - BasicData.lineCode2SocketUserMap.put(line, userName);
55   -
56   - return 0;
57   - }*/
58   -
59   - /**
60   - *
61 39 * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id
62 40 * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws
63 41 */
64 42 @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)
65 43 public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,
66   - @RequestParam String dfsj/*, String clZbh, String jsy, String spy*/) {
67   - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj/*, clZbh, jsy, spy*/);
  44 + @RequestParam String dfsj,@RequestParam String bcType) {
  45 + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType);
68 46 }
69 47  
70 48 /**
... ... @@ -125,19 +103,6 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
125 103 public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) {
126 104 return scheduleRealInfoService.sreachVehic(nbbm);
127 105 }
128   -
129   - /**
130   - *
131   - * @Title: adjust @Description: TODO(调整人车) @param @param id
132   - * 班次ID @param @param nbbm 内部编码 @param @param jsy 驾驶员 @param @param spy
133   - * 售票员 @throws
134   -
135   - @RequestMapping(value = "/adjust", method = RequestMethod.POST)
136   - public Map<String, Object> adjust(@RequestParam Long id, String nbbm, String jsy,
137   - String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) {
138   - return scheduleRealInfoService.adjust(id, nbbm, jsy, spy, revertLine, borrowLine, borrowTimeStr, revertTimeStr);
139   - }
140   - */
141 106 /**
142 107 *
143 108 * @Title: realOutAdjust
... ... @@ -299,10 +264,17 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
299 264  
300 265 @RequestMapping(value = "/exportWaybill")
301 266 public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName, @RequestParam String clZbh,
302   - @RequestParam String lpName,@RequestParam String date) {
303   - return scheduleRealInfoService.exportWaybill(jName, clZbh, lpName,date);
  267 + @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {
  268 + return scheduleRealInfoService.exportWaybill(jName, clZbh, lpName,date,line);
  269 + }
  270 +
  271 + @RequestMapping(value = "/exportWaybillQp")
  272 + public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh
  273 + ,@RequestParam String date,@RequestParam String line) {
  274 + return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);
304 275 }
305 276  
  277 +
306 278 @RequestMapping(value = "/dailyInfo")
307 279 public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {
308 280 return scheduleRealInfoService.dailyInfo(line, date, type);
... ... @@ -321,8 +293,14 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
321 293  
322 294 @RequestMapping(value="/findKMBC")
323 295 public Map<String,Object> findKMBC(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
324   - ,@RequestParam String date){
325   - return scheduleRealInfoService.findKMBC(jName, clZbh,lpName,date);
  296 + ,@RequestParam String date,@RequestParam String line){
  297 + return scheduleRealInfoService.findKMBC(jName, clZbh,lpName,date,line);
  298 + }
  299 +
  300 + @RequestMapping(value="/findKMBCQp")
  301 + public Map<String,Object> findKMBCQp(@RequestParam String clZbh
  302 + ,@RequestParam String date,@RequestParam String line){
  303 + return scheduleRealInfoService.findKMBCQp(clZbh,date,line);
326 304 }
327 305  
328 306 @RequestMapping(value="/findLpName")
... ... @@ -351,16 +329,14 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
351 329 */
352 330 @RequestMapping(value="/queryListWaybill")
353 331 public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
354   - ,@RequestParam String date){
355   - String type="fqp";
356   - return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,type);
  332 + ,@RequestParam String date,@RequestParam String line){
  333 + return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,line);
357 334 }
358 335  
359 336 @RequestMapping(value="/queryListWaybillQp")
360   - public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
361   - ,@RequestParam String date){
362   - String type="qp";
363   - return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,type);
  337 + public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,
  338 + @RequestParam String date,@RequestParam String line){
  339 + return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);
364 340 }
365 341  
366 342 @RequestMapping(value="/statisticsDaily")
... ... @@ -368,6 +344,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
368 344 return scheduleRealInfoService.statisticsDaily(line, date,xlName);
369 345 }
370 346  
  347 + @RequestMapping(value="/MapById",method = RequestMethod.GET)
  348 + public Map<String, Object> MapById(@RequestParam("id") Long id){
  349 + return scheduleRealInfoService.MapById(id);
  350 + }
  351 +
371 352 /**
372 353 * @Title: scheduleDaily
373 354 * @Description: TODO(调度日报表)
... ... @@ -427,4 +408,14 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
427 408 }
428 409 return rs;
429 410 }
  411 +
  412 + @RequestMapping(value = "svgAttr", method = RequestMethod.POST)
  413 + public Map<String, Object> svgAttr(@RequestParam String jsonStr){
  414 + return scheduleRealInfoService.svgAttr(jsonStr);
  415 + }
  416 +
  417 + @RequestMapping(value = "svgAttr", method = RequestMethod.GET)
  418 + public Map<String, Object> findSvgAttr(@RequestParam String idx){
  419 + return scheduleRealInfoService.findSvgAttr(idx);
  420 + }
430 421 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
... ... @@ -169,6 +169,10 @@ public class InOutStationSignalHandle extends SignalHandle{
169 169  
170 170 if(gps.getStopNo().equals(sch.getZdzCode())){
171 171  
  172 + //进场最多提前1.2小时
  173 + if(sch.getBcType().equals("in") && sch.getZdsjT() - gps.getTimestamp() > MAX_BEFORE_TIME)
  174 + return;
  175 +
172 176 //实达时间不覆盖
173 177 if(StringUtils.isNotEmpty(sch.getZdsjActual()))
174 178 return;
... ...
src/main/java/com/bsth/entity/realcontrol/SvgAttribute.java 0 → 100644
  1 +package com.bsth.entity.realcontrol;
  2 +
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.Id;
  5 +import javax.persistence.Table;
  6 +
  7 +/**
  8 + * 主页SVG模拟图属性设置
  9 + * Created by panzhao on 2017/1/6.
  10 + */
  11 +@Entity
  12 +@Table(name = "bsth_c_svg_attr")
  13 +public class SvgAttribute {
  14 +
  15 + @Id
  16 + private String lineCode;
  17 +
  18 + /**
  19 + * 要隐藏的站点编码 , 号分割多个
  20 + */
  21 + private String hideStations;
  22 +
  23 + /**
  24 + * 站点别名 json对象字符串
  25 + */
  26 + private String nicknames;
  27 +
  28 + public String getLineCode() {
  29 + return lineCode;
  30 + }
  31 +
  32 + public void setLineCode(String lineCode) {
  33 + this.lineCode = lineCode;
  34 + }
  35 +
  36 + public String getHideStations() {
  37 + return hideStations;
  38 + }
  39 +
  40 + public void setHideStations(String hideStations) {
  41 + this.hideStations = hideStations;
  42 + }
  43 +
  44 + public String getNicknames() {
  45 + return nicknames;
  46 + }
  47 +
  48 + public void setNicknames(String nicknames) {
  49 + this.nicknames = nicknames;
  50 + }
  51 +}
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -24,7 +24,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
24 24 @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName order by (lpName+1)")
25 25 List<ScheduleRealInfo> queryUserInfo2(String line,String date);
26 26  
27   - @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName order by (lpName+1)")
  27 + @Query(value="select min(s.id), s.clZbh from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.clZbh order by (lpName+1)")
28 28 List<ScheduleRealInfo> queryUserInfo3(String line,String date);
29 29  
30 30 @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs")
... ... @@ -79,13 +79,13 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
79 79 + " and clZbh like %?5% order by s.fcsj")
80 80 List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code);
81 81  
82   - @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') order by bcs")
83   - List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date);
  82 + @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,fcsjActual")
  83 + List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line);
84 84  
85   - @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and bcType='normal' order by bcs")
86   - List<ScheduleRealInfo> queryListWaybill2(String jName,String clZbh,String lpName,String date);
  85 + @Query(value="select s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDate = str_to_date(?2,'%Y-%m-%d') and xlBm =?3 order by realExecDate,fcsjActual")
  86 + List<ScheduleRealInfo> queryListWaybill2(String clZbh,String date,String line);
87 87  
88   - @Query(value="select s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') order by bcs")
  88 + @Query(value="select s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') order by realExecDate,fcsjActual")
89 89 List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date);
90 90  
91 91 @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') between str_to_date(?3,'%Y-%m-%d') and str_to_date(?4,'%Y-%m-%d') order by bcs")
... ...
src/main/java/com/bsth/repository/realcontrol/SvgAttributeRepository.java 0 → 100644
  1 +package com.bsth.repository.realcontrol;
  2 +
  3 +import com.bsth.entity.realcontrol.SvgAttribute;
  4 +import com.bsth.repository.BaseRepository;
  5 +import org.springframework.data.jpa.repository.Query;
  6 +import org.springframework.stereotype.Repository;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * Created by panzhao on 2017/1/8.
  12 + */
  13 +@Repository
  14 +public interface SvgAttributeRepository extends BaseRepository<SvgAttribute, String> {
  15 + @Query("select s from SvgAttribute s where s.lineCode in ?1")
  16 + List<SvgAttribute> findSvgAttr(List<String> lineCodes);
  17 +}
... ...
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
1 1 package com.bsth.service.impl;
2 2  
3   -import java.io.ByteArrayInputStream;
4   -import java.io.File;
5   -import java.io.InputStream;
6   -import java.text.DecimalFormat;
7   -import java.util.ArrayList;
8   -import java.util.HashMap;
9   -import java.util.List;
10   -import java.util.Map;
11   -import java.util.Properties;
12   -
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.data.jpa.repository.EntityGraph;
15   -import org.springframework.stereotype.Service;
16   -
17   -import com.alibaba.fastjson.JSON;
18   -import com.alibaba.fastjson.JSONArray;
19   -import com.alibaba.fastjson.serializer.PropertyFilter;
20 3 import com.bsth.common.ResponseCode;
21 4 import com.bsth.entity.Line;
22 5 import com.bsth.entity.Station;
... ... @@ -30,7 +13,14 @@ import com.bsth.util.FTPClientUtils;
30 13 import com.bsth.util.PackTarGZUtils;
31 14 import com.bsth.util.db.DBUtils_MS;
32 15 import com.google.common.base.Splitter;
33   -import com.google.common.collect.Lists;
  16 +import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.stereotype.Service;
  18 +
  19 +import java.io.ByteArrayInputStream;
  20 +import java.io.File;
  21 +import java.io.InputStream;
  22 +import java.text.DecimalFormat;
  23 +import java.util.*;
34 24  
35 25 /**
36 26 *
... ... @@ -985,6 +975,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
985 975 List<String> idx = Splitter.on(',').splitToList(lineIds);
986 976 //路由
987 977 List<StationRoute> list = new ArrayList<>();
  978 +
  979 +
988 980 /**
989 981 * in 查询符 无法和 @EntityGraph 同时配合使用,这可能是一个bug
990 982 * 暂时只能循环单线路查询
... ... @@ -993,9 +985,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
993 985 for(String id : idx){
994 986 list.addAll(repository.findByLineCode(id));
995 987 }
996   -
  988 +
  989 + for(StationRoute sr : list){
  990 + sr.setLine(null);
  991 + }
997 992 //过滤部分字段
998   - String jsonStr = JSON.toJSONString(list, new PropertyFilter() {
  993 + /*String jsonStr = JSON.toJSONString(list, new PropertyFilter() {
999 994  
1000 995 @Override
1001 996 public boolean apply(Object object, String name, Object value) {
... ... @@ -1003,10 +998,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
1003 998 return false;
1004 999 return true;
1005 1000 }
1006   - });
  1001 + });*/
1007 1002  
1008 1003 rs.put("status", ResponseCode.SUCCESS);
1009   - rs.put("list", jsonStr);
  1004 + rs.put("list", list);
1010 1005 }catch(Exception e){
1011 1006 logger.error("", e);
1012 1007 rs.put("status", ResponseCode.ERROR);
... ...
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
... ... @@ -15,7 +15,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
15 15  
16 16 Map<String, Collection<ScheduleRealInfo>> findByLines(String lines);
17 17  
18   - Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj/*,String nbbm,String jsy,String spy*/);
  18 + Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType);
19 19  
20 20 Map<String, Object> destroy(String idsStr/*, int spaceAdjust*/, String remarks, String reason/*, int spaceNum*/);
21 21  
... ... @@ -61,7 +61,9 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
61 61  
62 62 List<ScheduleRealInfo> queryUserInfo(String line,String date,String state);
63 63  
64   - List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName,String date);
  64 + List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName,String date,String line);
  65 +
  66 + List<ScheduleRealInfo> exportWaybillQp(String clZbh,String date,String line);
65 67  
66 68 List<Map<String,Object>> dailyInfo(String line,String date,String type);
67 69  
... ... @@ -87,7 +89,9 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
87 89  
88 90 Map<String,Object> findKMBC1(String jName,String clZbh, String date,String enddate);
89 91  
90   - Map<String,Object> findKMBC(String jName,String clZbh,String lpName,String date);
  92 + Map<String,Object> findKMBC(String jName,String clZbh,String lpName,String date,String line);
  93 +
  94 + Map<String,Object> findKMBCQp(String clZbh,String date,String line);
91 95  
92 96 Map<String,Object> findKMBC2(String jName,String clZbh,String date);
93 97  
... ... @@ -97,8 +101,10 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
97 101  
98 102 List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code, String type);
99 103  
100   - List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String type);
  104 + List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line);
101 105  
  106 + List<ScheduleRealInfo> queryListWaybillQp(String clZbh,String date,String line);
  107 +
102 108 Map<String, Object> removeChildTask(Long taskId);
103 109  
104 110 List<Map<String,Object>> statisticsDaily(String line,String date,String xlName);
... ... @@ -128,4 +134,10 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
128 134 Map<String,Object> changeBcType(Long id, String bcType, String remarks);
129 135  
130 136 Map<String,Object> historySave(ScheduleRealInfo sch);
  137 +
  138 + Map<String, Object> MapById(Long id) ;
  139 +
  140 + Map<String,Object> svgAttr(String jsonStr);
  141 +
  142 + Map<String,Object> findSvgAttr(String idx);
131 143 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -18,13 +18,16 @@ import com.bsth.entity.Personnel;
18 18 import com.bsth.entity.realcontrol.ChildTaskPlan;
19 19 import com.bsth.entity.realcontrol.LineConfig;
20 20 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  21 +import com.bsth.entity.realcontrol.SvgAttribute;
21 22 import com.bsth.entity.schedule.CarConfigInfo;
22 23 import com.bsth.entity.schedule.EmployeeConfigInfo;
23 24 import com.bsth.entity.schedule.GuideboardInfo;
  25 +import com.bsth.entity.sys.DutyEmployee;
24 26 import com.bsth.entity.sys.SysUser;
25 27 import com.bsth.repository.LineRepository;
26 28 import com.bsth.repository.realcontrol.ChildTaskPlanRepository;
27 29 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  30 +import com.bsth.repository.realcontrol.SvgAttributeRepository;
28 31 import com.bsth.repository.schedule.CarConfigInfoRepository;
29 32 import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
30 33 import com.bsth.repository.schedule.GuideboardInfoRepository;
... ... @@ -32,12 +35,15 @@ import com.bsth.security.util.SecurityUtils;
32 35 import com.bsth.service.SectionRouteService;
33 36 import com.bsth.service.impl.BaseServiceImpl;
34 37 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  38 +import com.bsth.service.sys.DutyEmployeeService;
35 39 import com.bsth.util.*;
36 40 import com.bsth.websocket.handler.SendUtils;
37 41 import com.google.common.base.Splitter;
38 42 import com.google.common.collect.ArrayListMultimap;
  43 +import com.google.common.collect.BiMap;
39 44 import com.google.common.collect.Lists;
40 45 import com.google.common.collect.Multimap;
  46 +import org.apache.commons.lang3.StringEscapeUtils;
41 47 import org.apache.commons.lang3.StringUtils;
42 48 import org.joda.time.format.DateTimeFormat;
43 49 import org.joda.time.format.DateTimeFormatter;
... ... @@ -46,7 +52,6 @@ import org.slf4j.LoggerFactory;
46 52 import org.springframework.beans.factory.annotation.Autowired;
47 53 import org.springframework.stereotype.Service;
48 54  
49   -import java.net.URLEncoder;
50 55 import java.text.DecimalFormat;
51 56 import java.text.ParseException;
52 57 import java.text.SimpleDateFormat;
... ... @@ -54,431 +59,390 @@ import java.util.*;
54 59  
55 60 @Service
56 61 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long>
57   - implements ScheduleRealInfoService {
  62 + implements ScheduleRealInfoService {
58 63  
59   - @Autowired
60   - ScheduleRealInfoRepository scheduleRealInfoRepository;
  64 + @Autowired
  65 + ScheduleRealInfoRepository scheduleRealInfoRepository;
61 66  
62   - @Autowired
63   - EmployeeConfigInfoRepository employeeConfigInfoRepository;
  67 + @Autowired
  68 + EmployeeConfigInfoRepository employeeConfigInfoRepository;
64 69  
65   - @Autowired
66   - CarConfigInfoRepository carConfigInfoRepository;
67   -
68   - @Autowired
69   - SectionRouteService sectionRouteService;
70   -
71   - /*@Autowired
72   - BorrowCenter borrowCenter;*/
73   -
74   - @Autowired
75   - LineRepository lineRepository;
76   -
77   - @Autowired
78   - GuideboardInfoRepository guideboardInfoRepository;
79   -
80   - @Autowired
81   - ChildTaskPlanRepository cTaskPlanRepository;
82   -
83   - @Autowired
84   - SendUtils sendUtils;
85   -
86   - @Autowired
87   - DayOfSchedule dayOfSchedule;
88   -
89   - @Autowired
90   - SchAttrCalculator schAttrCalculator;
91   -
92   - @Autowired
93   - LineConfigData lineConfigData;
94   -
95   - Logger logger = LoggerFactory.getLogger(this.getClass());
96   -
97   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
98   - sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"),
99   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
100   -
101   - @Override
102   - public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {
103   - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));
104   -
105   - Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();
106   -
107   - for (String lineCode : lineList) {
108   - mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode));
109   - }
110   - return mMap.asMap();
111   - }
112   -
113   - private final static long DAY_TIME = 1000 * 60 * 60 * 24L;
114   - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
115   - @Override
116   - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj/*, String nbbm,String jsy,String spy*/) {
117   - Map<String, Object> map = new HashMap<>();
118   - try {
119   -
120   - ScheduleRealInfo schedule = dayOfSchedule.get(id);
121   -
122   -
123   - LineConfig config = lineConfigData.get(schedule.getXlBm());
124   - //小于线路开始运营时间,则默认跨过24点
125   - if(dfsj.compareTo(config.getStartOpt()) < 0){
126   - schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME));
127   - }
128   - else {
129   - schedule.setRealExecDate(schedule.getScheduleDateStr());
130   - }
131   -
132   - schedule.setDfsjAll(dfsj);
133   - schedule.addRemarks(remarks);
134   -
135   - List<ScheduleRealInfo> ts = new ArrayList<>();
136   - ts.add(schedule);
137   - //调整终点时间和下一个班次的应到时间
138   - schedule.calcEndTime();
139   - ScheduleRealInfo nextSch = dayOfSchedule.next(schedule);
140   - if(null != nextSch){
141   - nextSch.setQdzArrDateJH(schedule.getZdsj());
142   - ts.add(nextSch);
143   - }
144   -
145   - // 持久化到数据库
146   - dayOfSchedule.save(schedule);
147   -
148   - map.put("status", ResponseCode.SUCCESS);
149   - map.put("ts", ts);
150   - } catch (Exception e) {
151   - logger.error("", e);
152   - map.put("status", ResponseCode.ERROR);
153   - }
154   - return map;
155   - }
156   -
157   - @Override
158   - public Map<String, Object> destroy(String idsStr, /*int spaceAdjust, */String remarks, String reason/*, int spaceNum*/) {
159   -
160   - Map<String, Object> map = new HashMap<>();
161   - List<ScheduleRealInfo> rsList = new ArrayList<>();
162   - map.put("ts", rsList);
163   - try {
164   - List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));
165   -
166   - ScheduleRealInfo schedule = null;
167   - for (String id : idList) {
168   - schedule = dayOfSchedule.get(Long.parseLong(id));
169   - if(schedule.isDestroy()){
170   - map.put("status", ResponseCode.ERROR);
171   - map.put("msg", "不必要的重复烂班!");
172   - return map;
173   - }
174   -
175   - schedule.setAdjustExps(reason);
176   - schedule.destroy();
177   - schedule.addRemarks(remarks);
178   -
179   - dayOfSchedule.save(schedule);
180   - rsList.add(schedule);
181   - }
182   -
183   - map.put("status", ResponseCode.SUCCESS);
184   - } catch (Exception e) {
185   - logger.error("", e);
186   - map.put("status", ResponseCode.ERROR);
187   - }
188   - return map;
189   - }
190   -
191   - // 线路id获取驾驶员
192   - @Override
193   - public List<Map<String, String>> findDriverByLine(String lineCode) {
194   - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
195   -
196   - List<Map<String, String>> rsList = new ArrayList<>();
197   - Map<String, String> map = null;
198   - Personnel driver = null;
199   - String code = null;
200   -
201   - for (EmployeeConfigInfo employee : list) {
202   - driver = employee.getJsy();
203   - if (driver != null) {
204   - map = new HashMap<>();
205   - code = driver.getJobCode();
206   - map.put("id", code + "/" + driver.getPersonnelName());
207   - map.put("text", code + "/" + driver.getPersonnelName());
208   - rsList.add(map);
209   - }
210   - }
211   - return rsList;
212   - }
213   -
214   - // 线路id获取售票员
215   - @Override
216   - public List<Map<String, String>> findConductorByLine(String lineCode) {
217   - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
218   -
219   - List<Map<String, String>> rsList = new ArrayList<>();
220   - Map<String, String> map = null;
221   - Personnel conductor = null;
222   - String code = null;
223   -
224   - for (EmployeeConfigInfo employee : list) {
225   - conductor = employee.getSpy();
226   - if (conductor != null) {
227   - code = conductor.getJobCode();
228   - map = new HashMap<>();
229   - map.put("id", code + "/" + conductor.getPersonnelName());
230   - map.put("text", code + "/" + conductor.getPersonnelName());
231   - rsList.add(map);
232   - }
233   - }
234   - return rsList;
235   - }
236   -
237   - @Override
238   - public List<Map<String, String>> findCarByLine(String lineCode) {
239   -
240   - List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode);
241   -
242   - List<Map<String, String>> rsList = new ArrayList<>();
243   - Map<String, String> map = null;
244   - Cars car = null;
245   - String code = null;
246   -
247   - for (CarConfigInfo cci : list) {
248   - car = cci.getCl();
249   - if (car != null) {
250   - code = car.getInsideCode();
251   - map = new HashMap<>();
252   - map.put("id", code);
253   - map.put("text", code);
254   - rsList.add(map);
255   - }
256   - }
257   - return rsList;
258   - }
259   -
260   -
261   - /**
262   - * 临加班次
263   - */
264   - @Override
265   - public Map<String, Object> save(ScheduleRealInfo t) {
266   - Map<String, Object> rs = new HashMap<>();
267   - try{
268   - SysUser user = SecurityUtils.getCurrentUser();
269   - String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());
270   -
271   - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd")
272   - ,sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");
273   -
274   - if(StringUtils.isEmpty(t.getjGh())){
275   - rs.put("status", ResponseCode.ERROR);
276   - rs.put("msg", "驾驶员工号不能为空!");
277   - return rs;
278   - }
279   - //截取工号
280   - if(t.getjGh().indexOf("-") != -1){
281   - t.setjGh(t.getjGh().split("-")[1]);
282   - }
283   -
284   - t.setScheduleDateStr(schDate);
285   - t.setScheduleDate(sdfyyyyMMdd.parse(schDate));
286   - t.setRealExecDate(schDate);
287   - t.setCreateBy(user);
288   - t.setSflj(true);
289   - t.setLate(false);
290   - t.setDfsj(t.getFcsj());
291   - t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime());
292   -
293   -
294   - //班次历时
295   - t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);
296   -
297   - //起终点名称
298   - String prefix = t.getXlBm() + "_" + t.getXlDir() + "_";
299   - t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));
300   - t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));
301   -
302   - //计算班次实际时间
303   - schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);
304   - if(t.getZdsjT() < t.getFcsjT()){
305   - rs.put("status", ResponseCode.ERROR);
306   - rs.put("msg", "起终点时间异常!");
307   - return rs;
308   - }
309   -
310   - //实时入库
311   - super.save(t);
312   -
313   - // 加入缓存
314   - dayOfSchedule.put(t);
315   -
316   - //更新起点应到时间
317   - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t.getClZbh());
318   -
319   -
320   - rs.put("ts", ts);
321   - rs.put("t", t);
322   - }catch(Exception e){
323   - logger.error("", e);
324   - rs.put("status", ResponseCode.ERROR);
325   - }
326   - return rs;
327   - }
328   -
329   - @Override
330   - public Map<String, Object> delete(Long id) {
331   - Map<String, Object> rs = new HashMap<>();
332   - rs.put("status", ResponseCode.ERROR);
333   -
334   - ScheduleRealInfo sch = dayOfSchedule.get(id);
335   - if(sch == null){
336   - rs.put("msg", "无效的id号");
337   - return rs;
338   - }
339   -
340   - if(!sch.isSflj()){
341   - rs.put("msg", "你只能删除临加班次");
342   - return rs;
343   - }
344   -
345   - dayOfSchedule.delete(sch);
346   - //ScheduleRealInfo sch = dayOfSchedule.delete(id);
347   - //数据库删除
348   - rs = super.delete(id);
349   - //更新起点应到时间
350   - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch.getClZbh());
351   - rs.put("ts", ts);
352   - rs.put("delete", sch);
353   -
354   - return rs;
355   - }
356   -
357   - @Override
358   - public List<Map<String, String>> sreachVehic(String nbbm) {
359   - // 转大写
360   - nbbm = nbbm.toUpperCase();
361   -
362   - List<Map<String, String>> list = new ArrayList<>();
363   - Map<String, String> map;
364   - Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
365   -
366   - Line line;
367   - for (String k : allSet) {
368   - if (k.indexOf(nbbm) != -1) {
369   - // 所属线路
370   - map = new HashMap<>();
371   - line = BasicData.nbbm2LineMap.get(k);
372   - map.put("id", k);
373   - map.put("text", k);
374   - if (null != line) {
375   - map.put("lineName", line.getName());
376   - map.put("lineCode", line.getLineCode());
377   - }
378   -
379   - list.add(map);
380   - }
381   -
382   - if (list.size() > 20)
383   - break;
384   - }
385   - return list;
386   - }
387   -
388   -/* @Override
389   - public Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) {
390   - // 班次
391   - ScheduleRealInfo schedule = dayOfSchedule.get(id);
392   - int upDown = Integer.parseInt(schedule.getXlDir());
  70 + @Autowired
  71 + CarConfigInfoRepository carConfigInfoRepository;
393 72  
394   - String rq = sdfMonth.format(new Date());
395   - // 换车
396   - if (!StringUtils.isBlank(nbbm)) {
397   - adjustCar(schedule, nbbm);
398   - }
399   -
400   - List<String> tempArray;
401   - // 换驾驶员
402   - if (!StringUtils.isBlank(jsy)) {
403   - tempArray = Splitter.on("/").splitToList(jsy);
404   - adjustDriver(schedule, tempArray.get(0), tempArray.get(1));
405   - }
406   -
407   - // 换售票员
408   - if (!StringUtils.isBlank(spy)) {
409   - tempArray = Splitter.on("/").splitToList(spy);
410   - adjustConductor(schedule, tempArray.get(0), tempArray.get(1));
411   - }
412   -
413   - if(borrowLine != null && borrowTimeStr != null){
414   - try {
415   - //跨线路借车
416   - Long t = sdfMinute.parse(rq + " " + borrowTimeStr).getTime();
417   - //borrowCenter.put(nbbm, borrowLine, 0, t, upDown);
418   - } catch (ParseException e) {
419   - e.printStackTrace();
420   - }
421   - }
422   -
423   - if(revertLine != null && revertTimeStr != null){
424   - //定时还车
425   - try {
426   - Long t = sdfMinute.parse(rq + " " + revertTimeStr).getTime();
427   - //还车的时候不用切走向
428   - //borrowCenter.put(nbbm, revertLine, 1, t, -1);
429   - } catch (ParseException e) {
430   - e.printStackTrace();
431   - }
432   - }
433   -
434   - scheduleRealInfoRepository.save(schedule);
435   - //ScheduleBuffer.persistentList.add(schedule);
436   -
437   - Map<String, Object> map = new HashMap<>();
438   - map.put("status", 200);
439   - map.put("t", schedule);
440   - return map;
441   - }*/
442   -
443   - @Override
444   - public void adjustCar(ScheduleRealInfo schedule, String car) {
445   - schedule.setClZbh(car);
446   - }
447   -
448   - @Override
449   - public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) {
450   - if(driver.indexOf("-") != -1)
451   - driver = driver.split("-")[1];
452   - schedule.setjGh(driver);
453   - schedule.setjName(driverName);
454   - }
  73 + @Autowired
  74 + SectionRouteService sectionRouteService;
455 75  
456   - @Override
457   - public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) {
458   - if(conductor.indexOf("-") != -1)
459   - conductor = conductor.split("-")[1];
460   - schedule.setsGh(conductor);
461   - schedule.setsName(conductorName);
462   - }
  76 + /*@Autowired
  77 + BorrowCenter borrowCenter;*/
463 78  
464   - @Override
465   - public List<ScheduleRealInfo> queryUserInfo(String line, String date,String state) {
466   - if(state.equals("2")){
467   - return scheduleRealInfoRepository.queryUserInfo2(line, date);
468   - }else{
469   - return scheduleRealInfoRepository.queryUserInfo3(line, date);
470   - }
471   -
472   - }
473   - /**
474   - *
475   - */
476   - @Override
477   - public List<ScheduleRealInfo> exportWaybill(String jName, String clZbh, String lpName,String date) {
  79 + @Autowired
  80 + LineRepository lineRepository;
  81 +
  82 + @Autowired
  83 + GuideboardInfoRepository guideboardInfoRepository;
  84 +
  85 + @Autowired
  86 + ChildTaskPlanRepository cTaskPlanRepository;
  87 +
  88 + @Autowired
  89 + SendUtils sendUtils;
  90 +
  91 + @Autowired
  92 + DayOfSchedule dayOfSchedule;
  93 +
  94 + @Autowired
  95 + SchAttrCalculator schAttrCalculator;
  96 +
  97 + @Autowired
  98 + LineConfigData lineConfigData;
  99 +
  100 + @Autowired
  101 + DutyEmployeeService dutyEmployeeService;
  102 +
  103 + Logger logger = LoggerFactory.getLogger(this.getClass());
  104 +
  105 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  106 + sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"),
  107 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  108 +
  109 + @Override
  110 + public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {
  111 + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));
  112 +
  113 + Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();
  114 +
  115 + for (String lineCode : lineList) {
  116 + mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode));
  117 + }
  118 + return mMap.asMap();
  119 + }
  120 +
  121 + private final static long DAY_TIME = 1000 * 60 * 60 * 24L;
  122 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  123 +
  124 + @Override
  125 + public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType) {
  126 + Map<String, Object> map = new HashMap<>();
  127 + try {
  128 +
  129 + ScheduleRealInfo schedule = dayOfSchedule.get(id);
  130 +
  131 +
  132 + LineConfig config = lineConfigData.get(schedule.getXlBm());
  133 + //小于线路开始运营时间,则默认跨过24点
  134 + if (dfsj.compareTo(config.getStartOpt()) < 0) {
  135 + schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME));
  136 + } else {
  137 + schedule.setRealExecDate(schedule.getScheduleDateStr());
  138 + }
  139 +
  140 + schedule.setDfsjAll(dfsj);
  141 + schedule.addRemarks(remarks);
  142 +
  143 + List<ScheduleRealInfo> ts = new ArrayList<>();
  144 + ts.add(schedule);
  145 + //调整终点时间和下一个班次的应到时间
  146 + schedule.calcEndTime();
  147 + ScheduleRealInfo nextSch = dayOfSchedule.next(schedule);
  148 + if (null != nextSch) {
  149 + nextSch.setQdzArrDateJH(schedule.getZdsj());
  150 + ts.add(nextSch);
  151 + }
  152 +
  153 + //调整班次类型
  154 + if(StringUtils.isNotEmpty(bcType)){
  155 + schedule.setBcType(bcType);
  156 + }
  157 +
  158 + // 持久化到数据库
  159 + dayOfSchedule.save(schedule);
  160 +
  161 + map.put("status", ResponseCode.SUCCESS);
  162 + map.put("ts", ts);
  163 + } catch (Exception e) {
  164 + logger.error("", e);
  165 + map.put("status", ResponseCode.ERROR);
  166 + }
  167 + return map;
  168 + }
  169 +
  170 + @Override
  171 + public Map<String, Object> destroy(String idsStr, /*int spaceAdjust, */String remarks, String reason/*, int spaceNum*/) {
  172 +
  173 + Map<String, Object> map = new HashMap<>();
  174 + List<ScheduleRealInfo> rsList = new ArrayList<>();
  175 + map.put("ts", rsList);
  176 + try {
  177 + List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));
  178 +
  179 + ScheduleRealInfo schedule = null;
  180 + for (String id : idList) {
  181 + schedule = dayOfSchedule.get(Long.parseLong(id));
  182 + if (schedule.isDestroy()) {
  183 + map.put("status", ResponseCode.ERROR);
  184 + map.put("msg", "不必要的重复烂班!");
  185 + return map;
  186 + }
  187 +
  188 + schedule.setAdjustExps(reason);
  189 + schedule.destroy();
  190 + schedule.addRemarks(remarks);
  191 +
  192 + dayOfSchedule.save(schedule);
  193 + rsList.add(schedule);
  194 + }
  195 +
  196 + map.put("status", ResponseCode.SUCCESS);
  197 + } catch (Exception e) {
  198 + logger.error("", e);
  199 + map.put("status", ResponseCode.ERROR);
  200 + }
  201 + return map;
  202 + }
  203 +
  204 + // 线路id获取驾驶员
  205 + @Override
  206 + public List<Map<String, String>> findDriverByLine(String lineCode) {
  207 + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
  208 +
  209 + List<Map<String, String>> rsList = new ArrayList<>();
  210 + Map<String, String> map = null;
  211 + Personnel driver = null;
  212 + String code = null;
  213 +
  214 + for (EmployeeConfigInfo employee : list) {
  215 + driver = employee.getJsy();
  216 + if (driver != null) {
  217 + map = new HashMap<>();
  218 + code = driver.getJobCode();
  219 + map.put("id", code + "/" + driver.getPersonnelName());
  220 + map.put("text", code + "/" + driver.getPersonnelName());
  221 + rsList.add(map);
  222 + }
  223 + }
  224 + return rsList;
  225 + }
  226 +
  227 + // 线路id获取售票员
  228 + @Override
  229 + public List<Map<String, String>> findConductorByLine(String lineCode) {
  230 + List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
  231 +
  232 + List<Map<String, String>> rsList = new ArrayList<>();
  233 + Map<String, String> map = null;
  234 + Personnel conductor = null;
  235 + String code = null;
  236 +
  237 + for (EmployeeConfigInfo employee : list) {
  238 + conductor = employee.getSpy();
  239 + if (conductor != null) {
  240 + code = conductor.getJobCode();
  241 + map = new HashMap<>();
  242 + map.put("id", code + "/" + conductor.getPersonnelName());
  243 + map.put("text", code + "/" + conductor.getPersonnelName());
  244 + rsList.add(map);
  245 + }
  246 + }
  247 + return rsList;
  248 + }
  249 +
  250 + @Override
  251 + public List<Map<String, String>> findCarByLine(String lineCode) {
  252 +
  253 + List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode);
  254 +
  255 + List<Map<String, String>> rsList = new ArrayList<>();
  256 + Map<String, String> map = null;
  257 + Cars car = null;
  258 + String code = null;
  259 +
  260 + for (CarConfigInfo cci : list) {
  261 + car = cci.getCl();
  262 + if (car != null) {
  263 + code = car.getInsideCode();
  264 + map = new HashMap<>();
  265 + map.put("id", code);
  266 + map.put("text", code);
  267 + rsList.add(map);
  268 + }
  269 + }
  270 + return rsList;
  271 + }
  272 +
  273 +
  274 + /**
  275 + * 临加班次
  276 + */
  277 + @Override
  278 + public Map<String, Object> save(ScheduleRealInfo t) {
  279 + Map<String, Object> rs = new HashMap<>();
  280 + try {
  281 + if (BasicData.deviceId2NbbmMap.inverse().get(t.getClZbh()) == null) {
  282 + rs.put("msg", "车辆 " + t.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
  283 + rs.put("status", ResponseCode.ERROR);
  284 + return rs;
  285 + }
  286 +
  287 + SysUser user = SecurityUtils.getCurrentUser();
  288 + String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());
  289 +
  290 + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");
  291 +
  292 + if (StringUtils.isEmpty(t.getjGh())) {
  293 + rs.put("status", ResponseCode.ERROR);
  294 + rs.put("msg", "驾驶员工号不能为空!");
  295 + return rs;
  296 + }
  297 + //截取工号
  298 + if (t.getjGh().indexOf("-") != -1) {
  299 + t.setjGh(t.getjGh().split("-")[1]);
  300 + }
  301 +
  302 + t.setScheduleDateStr(schDate);
  303 + t.setScheduleDate(sdfyyyyMMdd.parse(schDate));
  304 + t.setRealExecDate(schDate);
  305 + t.setCreateBy(user);
  306 + t.setSflj(true);
  307 + t.setLate(false);
  308 + t.setDfsj(t.getFcsj());
  309 + t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime());
  310 +
  311 +
  312 + //班次历时
  313 + t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);
  314 +
  315 + //起终点名称
  316 + String prefix = t.getXlBm() + "_" + t.getXlDir() + "_";
  317 + t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));
  318 + t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));
  319 +
  320 + //计算班次实际时间
  321 + schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);
  322 + if (t.getZdsjT() < t.getFcsjT()) {
  323 + rs.put("status", ResponseCode.ERROR);
  324 + rs.put("msg", "起终点时间异常!");
  325 + return rs;
  326 + }
  327 +
  328 + //实时入库
  329 + super.save(t);
  330 +
  331 + // 加入缓存
  332 + dayOfSchedule.put(t);
  333 +
  334 + //更新起点应到时间
  335 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t.getClZbh());
  336 +
  337 +
  338 + rs.put("ts", ts);
  339 + rs.put("t", t);
  340 + } catch (Exception e) {
  341 + logger.error("", e);
  342 + rs.put("status", ResponseCode.ERROR);
  343 + }
  344 + return rs;
  345 + }
  346 +
  347 + @Override
  348 + public Map<String, Object> delete(Long id) {
  349 + Map<String, Object> rs = new HashMap<>();
  350 + rs.put("status", ResponseCode.ERROR);
  351 +
  352 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  353 + if (sch == null) {
  354 + rs.put("msg", "无效的id号");
  355 + return rs;
  356 + }
  357 +
  358 + if (!sch.isSflj()) {
  359 + rs.put("msg", "你只能删除临加班次");
  360 + return rs;
  361 + }
  362 +
  363 + dayOfSchedule.delete(sch);
  364 + //ScheduleRealInfo sch = dayOfSchedule.delete(id);
  365 + //数据库删除
  366 + rs = super.delete(id);
  367 + //更新起点应到时间
  368 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch.getClZbh());
  369 + rs.put("ts", ts);
  370 + rs.put("delete", sch);
  371 +
  372 + return rs;
  373 + }
  374 +
  375 + @Override
  376 + public List<Map<String, String>> sreachVehic(String nbbm) {
  377 + // 转大写
  378 + nbbm = nbbm.toUpperCase();
  379 +
  380 + List<Map<String, String>> list = new ArrayList<>();
  381 + Map<String, String> map;
  382 + Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
  383 +
  384 + Line line;
  385 + for (String k : allSet) {
  386 + if (k.indexOf(nbbm) != -1) {
  387 + // 所属线路
  388 + map = new HashMap<>();
  389 + line = BasicData.nbbm2LineMap.get(k);
  390 + map.put("id", k);
  391 + map.put("text", k);
  392 + if (null != line) {
  393 + map.put("lineName", line.getName());
  394 + map.put("lineCode", line.getLineCode());
  395 + }
  396 +
  397 + list.add(map);
  398 + }
  399 +
  400 + if (list.size() > 20)
  401 + break;
  402 + }
  403 + return list;
  404 + }
  405 +
  406 + @Override
  407 + public void adjustCar(ScheduleRealInfo schedule, String car) {
  408 + schedule.setClZbh(car);
  409 + }
  410 +
  411 + @Override
  412 + public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) {
  413 + if (driver.indexOf("-") != -1)
  414 + driver = driver.split("-")[1];
  415 + schedule.setjGh(driver);
  416 + schedule.setjName(driverName);
  417 + }
  418 +
  419 + @Override
  420 + public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) {
  421 + if (conductor.indexOf("-") != -1)
  422 + conductor = conductor.split("-")[1];
  423 + schedule.setsGh(conductor);
  424 + schedule.setsName(conductorName);
  425 + }
  426 +
  427 + @Override
  428 + public List<ScheduleRealInfo> queryUserInfo(String line, String date, String state) {
  429 + if (state.equals("2")) {
  430 + return scheduleRealInfoRepository.queryUserInfo2(line, date);
  431 + } else {
  432 + return scheduleRealInfoRepository.queryUserInfo3(line, date);
  433 + }
  434 +
  435 + }
  436 +
  437 + /**
  438 + *
  439 + */
  440 + @Override
  441 + public List<ScheduleRealInfo> exportWaybill(String jName, String clZbh, String lpName,String date,String line) {
478 442 ReportUtils ee = new ReportUtils();
479 443 ReportRelatedUtils rru = new ReportRelatedUtils();
480 444 List<Iterator<?>> list = new ArrayList<Iterator<?>>();
481   - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName,date);
  445 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName,date,line);
482 446 List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
483 447  
484 448 DecimalFormat format = new DecimalFormat("0.00");
... ... @@ -499,7 +463,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
499 463 //计划班次,烂班班次,增加班次
500 464 tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
501 465 if(scheduleRealInfo.isSflj()){
502   - addMileage += tempJhlc;
503 466 ljbc++;
504 467 }else{
505 468 jhlc += tempJhlc;
... ... @@ -513,7 +476,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
513 476 //计算营运里程,空驶里程
514 477 if(childTaskPlans.isEmpty()){
515 478 if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
516   - || scheduleRealInfo.getBcType().equals("venting")){
  479 + ){
517 480 ksgl += tempJhlc;
518 481 }else{
519 482 yygl += tempJhlc;
... ... @@ -523,8 +486,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
523 486 while(it.hasNext()){
524 487 ChildTaskPlan childTaskPlan = it.next();
525 488 if(childTaskPlan.getMileageType().equals("empty")){
  489 + if(scheduleRealInfo.isSflj()){
  490 + addMileage += tempJhlc;
  491 + }
526 492 ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
527 493 }else{
  494 + if(scheduleRealInfo.isSflj()){
  495 + addMileage += tempJhlc;
  496 + }
528 497 yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
529 498 }
530 499 }
... ... @@ -573,141 +542,141 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
573 542  
574 543 list.add(listMap.iterator());
575 544 ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould\\waybill_minhang.xls",
576   - path+"export\\" + jName + ".xls");
  545 + path+"export\\" + date+"-"+jName+"-"+clZbh+"-"+lpName+"-行车路单.xls");
577 546 return scheduleRealInfos;
578 547 }
579 548  
580   - @Override
581   - public List<Map<String, Object>> dailyInfo(String line, String date,String type) {
582   - DecimalFormat format = new DecimalFormat("0.00");
583   - ReportUtils ee = new ReportUtils();
584   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
585   - List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);
586   -
587   - double totalZGL = 0,totalKSGL=0,totalYH=0;
588   - int totalBCS=0;
589   - for(int i = 0;i < list.size();i++){
590   - String zgl = format.format(Double.parseDouble(list.get(i).get("zgl")==null?"0":list.get(i).get("zgl").toString()));
591   - String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl")==null?"0":list.get(i).get("ksgl").toString()));
592   - if(type.equals("export")){
593   - totalZGL += Double.parseDouble(zgl);
594   - totalKSGL += Double.parseDouble(ksgl);
595   - totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());
596   - }
597   - list.get(i).put("zgl", zgl);
598   - list.get(i).put("ksgl", ksgl);
599   - }
600   - if(type.equals("export")){
601   - Map<String,Object> map = new HashMap<String, Object>();
602   - map.put("line", line);
603   - map.put("date", date);
604   - map.put("totalZGL", totalZGL);
605   - map.put("totalKSGL", totalKSGL);
606   - map.put("totalYH", totalYH);
607   - map.put("totalBCS", totalBCS);
608   -
609   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
610   -
611   - listI.add(list.iterator());
612   - try {
613   - ee.excelReplace(listI, new Object[] { map }, path+"mould\\daily.xls",
614   - path+"export\\班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
615   - } catch (ParseException e) {
616   - e.printStackTrace();
617   - }
618   - }
619   - return list;
620   - }
621   -
622   - @Override
623   - public List<Object[]> historyMessage(String line, String date, String code, String type) {
624   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
625   - long d= 0;
626   - long t=0;
627   - if(date.length()>0){
628   - try {
629   - d=sdf.parse(date+" 00:00:00").getTime();
630   - t=sdf.parse(date+" 23:59:59").getTime();
631   - } catch (ParseException e) {
632   - // TODO Auto-generated catch block
633   - e.printStackTrace();
634   - }
635   -
636   - }
637   -
638   - List<Object[]> list = scheduleRealInfoRepository.historyMessage(line, d, t, code);
639   - for(Object[] obj:list){
640   - if(obj != null){
641   - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
642   - obj[4] = BasicData.lineCode2NameMap.get(line);
643   - }
644   - }
645   -
646   - if(type != null && type.length() != 0 && type.equals("export")){
647   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
648   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
649   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
650   - Map<String,Object> m = new HashMap<String, Object>();
651   - ReportUtils ee = new ReportUtils();
652   - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
653   - for(int i = 0; i < list.size(); i++){
654   - Map<String, Object> map = new HashMap<String, Object>();
655   - Object[] obj = list.get(i);
656   - map.put("num", i + 1);
657   - map.put("line", obj[4]);
658   - map.put("clZbh", obj[0]);
659   - map.put("sender", obj[1]);
660   - map.put("date", obj[3]);
661   - map.put("text", obj[2]);
662   - newList.add(map);
663   - }
664   - try {
665   - listI.add(newList.iterator());
666   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
667   - ee.excelReplace(listI, new Object[] { m }, path+"mould\\historyMessage.xls",
668   - path+"export\\调度历史消息" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
669   - } catch (Exception e) {
670   - // TODO: handle exception
671   - e.printStackTrace();
672   - }
673   - }
674   -
675   - if(type != null && type.length() != 0 && type.equals("export_msg")){
676   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
677   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
678   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
679   - Map<String,Object> m = new HashMap<String, Object>();
680   - ReportUtils ee = new ReportUtils();
681   - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
682   - for(int i = 0; i < list.size(); i++){
683   - Map<String, Object> map = new HashMap<String, Object>();
684   - Object[] obj = list.get(i);
685   - map.put("num", i + 1);
686   - map.put("line", obj[4]);
687   - map.put("clZbh", obj[0]);
688   - map.put("sender", obj[1]);
689   - map.put("date", obj[3]);
690   - map.put("text", obj[2]);
691   - newList.add(map);
692   - }
693   - try {
694   - listI.add(newList.iterator());
695   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
696   - ee.excelReplace(listI, new Object[] { m }, path+"mould\\message.xls",
697   - path+"export\\调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
698   - } catch (Exception e) {
699   - // TODO: handle exception
700   - e.printStackTrace();
701   - }
702   - }
703   - return list;
704   - }
705   -
706   - @Override
707   - public Map<Integer, Integer> trustStatus(String lineStr) {
708   - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));
709   -
710   - Map<Integer, Integer> map = new HashMap<>();
  549 + @Override
  550 + public List<Map<String, Object>> dailyInfo(String line, String date, String type) {
  551 + DecimalFormat format = new DecimalFormat("0.00");
  552 + ReportUtils ee = new ReportUtils();
  553 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  554 + List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);
  555 +
  556 + double totalZGL = 0, totalKSGL = 0, totalYH = 0;
  557 + int totalBCS = 0;
  558 + for (int i = 0; i < list.size(); i++) {
  559 + String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString()));
  560 + String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString()));
  561 + if (type.equals("export")) {
  562 + totalZGL += Double.parseDouble(zgl);
  563 + totalKSGL += Double.parseDouble(ksgl);
  564 + totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());
  565 + }
  566 + list.get(i).put("zgl", zgl);
  567 + list.get(i).put("ksgl", ksgl);
  568 + }
  569 + if (type.equals("export")) {
  570 + Map<String, Object> map = new HashMap<String, Object>();
  571 + map.put("line", line);
  572 + map.put("date", date);
  573 + map.put("totalZGL", totalZGL);
  574 + map.put("totalKSGL", totalKSGL);
  575 + map.put("totalYH", totalYH);
  576 + map.put("totalBCS", totalBCS);
  577 +
  578 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  579 +
  580 + listI.add(list.iterator());
  581 + try {
  582 + ee.excelReplace(listI, new Object[]{map}, path + "mould\\daily.xls",
  583 + path + "export\\班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  584 + } catch (ParseException e) {
  585 + e.printStackTrace();
  586 + }
  587 + }
  588 + return list;
  589 + }
  590 +
  591 + @Override
  592 + public List<Object[]> historyMessage(String line, String date, String code, String type) {
  593 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  594 + long d = 0;
  595 + long t = 0;
  596 + if (date.length() > 0) {
  597 + try {
  598 + d = sdf.parse(date + " 00:00:00").getTime();
  599 + t = sdf.parse(date + " 23:59:59").getTime();
  600 + } catch (ParseException e) {
  601 + // TODO Auto-generated catch block
  602 + e.printStackTrace();
  603 + }
  604 +
  605 + }
  606 +
  607 + List<Object[]> list = scheduleRealInfoRepository.historyMessage(line, d, t, code);
  608 + for (Object[] obj : list) {
  609 + if (obj != null) {
  610 + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
  611 + obj[4] = BasicData.lineCode2NameMap.get(line);
  612 + }
  613 + }
  614 +
  615 + if (type != null && type.length() != 0 && type.equals("export")) {
  616 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  617 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  618 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  619 + Map<String, Object> m = new HashMap<String, Object>();
  620 + ReportUtils ee = new ReportUtils();
  621 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  622 + for (int i = 0; i < list.size(); i++) {
  623 + Map<String, Object> map = new HashMap<String, Object>();
  624 + Object[] obj = list.get(i);
  625 + map.put("num", i + 1);
  626 + map.put("line", obj[4]);
  627 + map.put("clZbh", obj[0]);
  628 + map.put("sender", obj[1]);
  629 + map.put("date", obj[3]);
  630 + map.put("text", obj[2]);
  631 + newList.add(map);
  632 + }
  633 + try {
  634 + listI.add(newList.iterator());
  635 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  636 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\historyMessage.xls",
  637 + path + "export\\调度历史消息" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  638 + } catch (Exception e) {
  639 + // TODO: handle exception
  640 + e.printStackTrace();
  641 + }
  642 + }
  643 +
  644 + if (type != null && type.length() != 0 && type.equals("export_msg")) {
  645 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  646 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  647 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  648 + Map<String, Object> m = new HashMap<String, Object>();
  649 + ReportUtils ee = new ReportUtils();
  650 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  651 + for (int i = 0; i < list.size(); i++) {
  652 + Map<String, Object> map = new HashMap<String, Object>();
  653 + Object[] obj = list.get(i);
  654 + map.put("num", i + 1);
  655 + map.put("line", obj[4]);
  656 + map.put("clZbh", obj[0]);
  657 + map.put("sender", obj[1]);
  658 + map.put("date", obj[3]);
  659 + map.put("text", obj[2]);
  660 + newList.add(map);
  661 + }
  662 + try {
  663 + listI.add(newList.iterator());
  664 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  665 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\message.xls",
  666 + path + "export\\调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  667 + } catch (Exception e) {
  668 + // TODO: handle exception
  669 + e.printStackTrace();
  670 + }
  671 + }
  672 + return list;
  673 + }
  674 +
  675 + @Override
  676 + public Map<Integer, Integer> trustStatus(String lineStr) {
  677 + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));
  678 +
  679 + Map<Integer, Integer> map = new HashMap<>();
711 680 /*Integer code;
712 681 for (String lineCode : lineList) {
713 682 code = Integer.parseInt(lineCode);
... ... @@ -716,485 +685,1519 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
716 685  
717 686 map.put(code, ScheduleBuffer.trustMap.get(code));
718 687 }*/
719   - return map;
720   - }
721   -
722   - @Override
723   - public Map<String, Object> realOutAdjust(Long id, String fcsjActual, String remarks) {
724   - Map<String, Object> rs = new HashMap<>();
725   - List<ScheduleRealInfo> ts = new ArrayList<>();
726   - try {
727   - ScheduleRealInfo sch = dayOfSchedule.get(id);
728   -
729   - LineConfig config = lineConfigData.get(sch.getXlBm());
730   - //小于线路开始运营时间,则默认跨过24点
731   - if(fcsjActual.compareTo(config.getStartOpt()) < 0){
732   - sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME));
733   - }
734   - else {
735   - sch.setRealExecDate(sch.getScheduleDateStr());
  688 + return map;
  689 + }
  690 +
  691 + @Override
  692 + public Map<String, Object> realOutAdjust(Long id, String fcsjActual, String remarks) {
  693 + Map<String, Object> rs = new HashMap<>();
  694 + List<ScheduleRealInfo> ts = new ArrayList<>();
  695 + try {
  696 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  697 +
  698 + LineConfig config = lineConfigData.get(sch.getXlBm());
  699 + //小于线路开始运营时间,则默认跨过24点
  700 + if (fcsjActual.compareTo(config.getStartOpt()) < 0) {
  701 + sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME));
  702 + } else {
  703 + sch.setRealExecDate(sch.getScheduleDateStr());
  704 + }
  705 +
  706 + sch.setFcsjActualAll(fcsjActual);
  707 + sch.addRemarks(remarks);
  708 + sch.calcStatus();
  709 +
  710 + dayOfSchedule.save(sch);
  711 + //scheduleRealInfoRepository.save(sch);
  712 +
  713 + ts.add(sch);
  714 +
  715 + rs.put("status", ResponseCode.SUCCESS);
  716 + rs.put("ts", ts);
  717 +
  718 + //通知页面刷新
  719 + sendUtils.refreshSch(ts);
  720 + } catch (Exception e) {
  721 + logger.error("", e);
  722 + rs.put("status", ResponseCode.ERROR);
  723 + }
  724 +
  725 + return rs;
  726 + }
  727 +
  728 + @Override
  729 + public Map<String, Object> revokeDestroy(Long id) {
  730 + Map<String, Object> rs = new HashMap<>();
  731 + try {
  732 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  733 + if (sch.getStatus() != -1) {
  734 + rs.put("status", ResponseCode.ERROR);
  735 + rs.put("msg", "未烂班,无法撤销!");
  736 + } else {
  737 + sch.setStatus(0);
  738 + rs.put("status", ResponseCode.SUCCESS);
  739 + rs.put("t", sch);
  740 +
  741 + }
  742 + } catch (Exception e) {
  743 + logger.error("", e);
  744 + rs.put("status", ResponseCode.ERROR);
  745 + }
  746 + return rs;
  747 + }
  748 +
  749 + @Override
  750 + public Map<String, Object> revokeRealOutgo(Long id) {
  751 + Map<String, Object> rs = new HashMap<>();
  752 + List<ScheduleRealInfo> ts = new ArrayList<>();
  753 +
  754 + try {
  755 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  756 + if (sch.getFcsjActual() == null) {
  757 + rs.put("status", ResponseCode.ERROR);
  758 + rs.put("msg", "无实发时间,无法撤销!");
  759 + } else {
  760 + //将对应的到离站数据标记为不可信
  761 + List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());
  762 + for (ArrivalEntity arr : list) {
  763 + if (arr.getInOut() == 1
  764 + && arr.getUpDown() == Integer.parseInt(sch.getXlDir())
  765 + && arr.getStopNo().equals(sch.getQdzCode())
  766 + && Math.abs(arr.getTs() - sch.getFcsjActualTime()) < 1000 * 60) {
  767 + arr.setEnable(false);
  768 + break;
  769 + }
  770 + }
  771 +
  772 + sch.clearFcsjActual();
  773 + rs.put("status", ResponseCode.SUCCESS);
  774 +
  775 + ts.add(sch);
  776 + rs.put("ts", ts);
  777 +
  778 + }
  779 + } catch (Exception e) {
  780 + logger.error("", e);
  781 + rs.put("status", ResponseCode.ERROR);
  782 + }
  783 + return rs;
  784 + }
  785 +
  786 + @Override
  787 + public Map<String, Object> spaceAdjust(Long[] ids, Integer space) {
  788 +
  789 + List<ScheduleRealInfo> list = new ArrayList<>(), updateList = new ArrayList<>();
  790 + Map<String, Object> rs = new HashMap<>();
  791 + try {
  792 + ScheduleRealInfo sch, next;
  793 + for (Long id : ids) {
  794 + sch = dayOfSchedule.get(id);
  795 + if (null != sch)
  796 + list.add(sch);
  797 + }
  798 +
  799 + int size = list.size();
  800 + if (size == 0) {
  801 + rs.put("status", ResponseCode.ERROR);
  802 + } else {
  803 + // 按发车时间排序
  804 + Collections.sort(list, new ScheduleComparator.FCSJ());
  805 +
  806 + // 以第一个实际发车/待发时间为起点,调整间隔
  807 + sch = list.get(0);
  808 + Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L;
  809 +
  810 + for (int i = 1; i < size; i++) {
  811 + st += plus;
  812 + sch = list.get(i);
  813 + sch.setDfsjAll(st);
  814 + //重新计算终点时间
  815 + sch.calcEndTime();
  816 +
  817 + dayOfSchedule.save(sch);
  818 +
  819 + updateList.add(sch);
  820 + next = dayOfSchedule.next(sch);
  821 + if (next.getQdzName().equals(sch.getZdzName())) {
  822 + next.setQdzArrDateJH(sch.getZdsj());
  823 + updateList.add(next);
  824 + }
  825 + }
  826 +
  827 +
  828 + rs.put("status", ResponseCode.SUCCESS);
  829 + rs.put("ts", updateList);
  830 + }
  831 +
  832 + } catch (Exception e) {
  833 + logger.error("", e);
  834 + rs.put("status", ResponseCode.ERROR);
  835 + }
  836 + return rs;
  837 + }
  838 +
  839 + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  840 +
  841 + @Override
  842 + public Map<String, Object> schInfoFineTune(Map<String, String> map) {
  843 + Map<String, Object> rs = new HashMap<>();
  844 + List<ScheduleRealInfo> ts = new ArrayList<>();
  845 + try {
  846 + Long id = Long.parseLong(map.get("id"));
  847 + //班次类型
  848 + //String bcType = map.get("bcType");
  849 + //车辆自编号
  850 + //String clZbh = map.get("clZbh");
  851 + //计划发车时间
  852 + //String fcsj = map.get("fcsj");
  853 + //实际发车时间
  854 + String fcsjActual = map.get("fcsjActual");
  855 + //实际终点时间
  856 + String zdsjActual = map.get("zdsjActual");
  857 + //备注
  858 + String remarks = map.get("remarks");
  859 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  860 + if (null != sch) {
  861 + if (StringUtils.isNotBlank(fcsjActual)) {
  862 + LineConfig config = lineConfigData.get(sch.getXlBm());
  863 + long t = 0L;
  864 + //小于线路开始运营时间,则默认跨过24点
  865 + if (fcsjActual.compareTo(config.getStartOpt()) < 0)
  866 + t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual);
  867 + else
  868 + t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);
  869 +
  870 + //调整实发
  871 + if (!fcsjActual.equals(sch.getFcsjActual()))
  872 + sch.setFcsjActualAll(t);
  873 + } else {
  874 + //撤销实发
  875 + if (sch.getFcsjActual() != null)
  876 + revokeRealOutgo(sch.getId());
  877 + }
  878 + //实达时间
  879 + if (StringUtils.isNotBlank(zdsjActual)) {
  880 + if (!zdsjActual.equals(sch.getZdsjActual())) {
  881 + //调整实达
  882 + sch.setZdsjActualAll(zdsjActual);
  883 + //下一班次起点到达时间
  884 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  885 + if (null != next) {
  886 + next.setQdzArrDateSJ(zdsjActual);
  887 + ts.add(next);
  888 + }
  889 +
  890 + //重新计算车辆执行班次
  891 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
  892 + }
  893 + } else {
  894 + //清除实达时间
  895 + sch.clearZdsjActual();
  896 + //清除下一班次起点到达时间
  897 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  898 + if (null != next) {
  899 + next.setQdzArrDateSJ(null);
  900 + ts.add(next);
  901 + }
  902 + }
  903 + sch.setRemarks(remarks);
  904 +
  905 + try {
  906 + //烂班
  907 + if(map.get("status") != null
  908 + && Integer.parseInt(map.get("status").toString()) == -1){
  909 + destroy(sch.getId() + "", "", map.get("adjustExps").toString());
  910 + }
  911 + } catch (NumberFormatException e) {
  912 + logger.error("", e);
  913 + }
  914 + }
  915 +
  916 + String bcType = map.get("bcType");
  917 + if(StringUtils.isNotEmpty(bcType)){
  918 + sch.setBcType(bcType);
  919 + }
  920 + //班次状态
  921 + sch.calcStatus();
  922 + dayOfSchedule.save(sch);
  923 + //页面需要更新的班次信息
  924 + ts.add(sch);
  925 +
  926 + rs.put("status", ResponseCode.SUCCESS);
  927 + rs.put("ts", ts);
  928 + } catch (Exception e) {
  929 + logger.error("", e);
  930 + rs.put("status", ResponseCode.ERROR);
  931 + }
  932 + return rs;
  933 + }
  934 +
  935 + @Override
  936 + public Map<String, Object> outgoAdjustAll(String params) {
  937 + Map<String, Object> rs = new HashMap<>();
  938 + try {
  939 + JSONArray jsonArray = JSONArray.parseArray(params);
  940 +
  941 + ScheduleRealInfo schedule = null;
  942 + JSONObject jsonObj;
  943 + String dfsj;
  944 + for (int i = 0; i < jsonArray.size(); i++) {
  945 + jsonObj = jsonArray.getJSONObject(i);
  946 + dfsj = jsonObj.getString("t");
  947 + schedule = dayOfSchedule.get(jsonObj.getLong("id"));
  948 + //设置待发时间
  949 + schedule.setDfsjAll(dfsj);
  950 +
  951 + dayOfSchedule.save(schedule);
  952 + }
  953 +
  954 + rs.put("status", ResponseCode.SUCCESS);
  955 + //将更新的最后一个班次返回
  956 + rs.put("t", schedule);
  957 + } catch (Exception e) {
  958 + logger.error("", e);
  959 + rs.put("status", ResponseCode.ERROR);
  960 + }
  961 + return rs;
  962 + }
  963 +
  964 + @Override
  965 + public Map<String, Object> findRouteByLine(String lineCode) {
  966 + Map<String, Object> map = new HashMap<>();
  967 + //上行
  968 + Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);
  969 + map.put("line.id_eq", lineId);
  970 + map.put("directions_eq", 0);
  971 + List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);
  972 +
  973 + //下行
  974 + map.put("directions_eq", 1);
  975 + List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);
  976 +
  977 + Map<String, Object> rs = new HashMap<>();
  978 +
  979 + String upVectors = "", vec;
  980 + //拼接上行路段
  981 + for (Map<String, Object> temp : upList) {
  982 + vec = temp.get("sectionBsectionVector").toString();
  983 + upVectors += vec.subSequence(11, vec.length() - 2) + " ";
  984 + }
  985 +
  986 + //拼接下行路段
  987 + String downVectors = "";
  988 + for (Map<String, Object> temp : downList) {//LINESTRING(
  989 + vec = temp.get("sectionBsectionVector").toString();
  990 + downVectors += vec.subSequence(11, vec.length() - 2) + " ";
  991 + }
  992 +
  993 +
  994 + rs.put("up", upVectors);
  995 + //上行gcj
  996 + rs.put("up_gcj", BdToGcjString(upVectors));
  997 + rs.put("down", downVectors);
  998 + //下行gcj
  999 + rs.put("down_gcj", BdToGcjString(downVectors));
  1000 + rs.put("lineId", lineId);
  1001 +
  1002 + return rs;
  1003 + }
  1004 +
  1005 + /**
  1006 + * @param @param bdStr
  1007 + * @throws
  1008 + * @Title: BdToGcjString
  1009 + * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)
  1010 + */
  1011 + public String BdToGcjString(String bdStr) {
  1012 + String[] array = bdStr.split(","), subArray;
  1013 + if (array.length == 0 || bdStr.length() < 2)
  1014 + return "";
  1015 +
  1016 + String gcjStr = "";
  1017 + TransGPS.Location location;
  1018 + for (String crd : array) {
  1019 + subArray = crd.split(" ");
  1020 + if (subArray.length != 2)
  1021 + continue;
  1022 + location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));
  1023 +
  1024 + gcjStr += location.getLng() + " " + location.getLat() + ",";
  1025 + }
  1026 +
  1027 + return gcjStr.substring(0, gcjStr.length() - 1);
  1028 + }
  1029 +
  1030 + public List<Map<String, String>> findLine(String line) {
  1031 + List<Line> listLine = lineRepository.findLine("%" + line + "%");
  1032 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  1033 + Map<String, String> map;
  1034 + for (Line temp : listLine) {
  1035 + if (temp != null) {
  1036 + String xlName = temp.getName();
  1037 + if (xlName.indexOf(line) != -1) {
  1038 + map = new HashMap<String, String>();
  1039 + map.put("id", temp.getLineCode());
  1040 + map.put("text", xlName);
  1041 + list.add(map);
  1042 + }
  1043 + }
  1044 + }
  1045 + return list;
  1046 + }
  1047 +
  1048 + public List<Map<String, String>> findLpName(String lpName) {
  1049 + List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%");
  1050 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  1051 + Map<String, String> map;
  1052 + for (GuideboardInfo temp : listLpName) {
  1053 + if (temp != null) {
  1054 + String lp = temp.getLpName();
  1055 + if (lp.indexOf(lpName) != -1) {
  1056 + map = new HashMap<String, String>();
  1057 + map.put("id", lp);
  1058 + map.put("text", lp);
  1059 + list.add(map);
  1060 + }
  1061 + }
  1062 + }
  1063 + return list;
  1064 + }
  1065 +
  1066 + @Override
  1067 + public Map<String, Object> findKMBC2(String jName, String clZbh, String date) {
  1068 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date);
  1069 +
  1070 + DecimalFormat format = new DecimalFormat("0.00");
  1071 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1072 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1073 + int jhbc = 0, cjbc = 0, ljbc = 0;
  1074 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;
  1075 + float addMileage = 0l, remMileage = 0l;
  1076 + String j_Name = "";
  1077 + Map<String, Object> map = new HashMap<String, Object>();
  1078 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1079 + if (scheduleRealInfo != null) {
  1080 + j_Name = scheduleRealInfo.getjName();
  1081 + //计划里程(主任务过滤掉临加班次),
  1082 + //烂班里程(主任务烂班),
  1083 + //临加里程(主任务临加),
  1084 + //计划班次,烂班班次,增加班次
  1085 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1086 + if (scheduleRealInfo.isSflj()) {
  1087 + addMileage += tempJhlc;
  1088 + ljbc++;
  1089 + } else {
  1090 + jhlc += tempJhlc;
  1091 + jhbc++;
  1092 + if (scheduleRealInfo.getStatus() == -1) {
  1093 + remMileage += tempJhlc;
  1094 + cjbc++;
  1095 + }
  1096 + }
  1097 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1098 + //计算营运里程,空驶里程
  1099 + if (childTaskPlans.isEmpty()) {
  1100 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  1101 + || scheduleRealInfo.getBcType().equals("venting")) {
  1102 + ksgl += tempJhlc;
  1103 + } else {
  1104 + yygl += tempJhlc;
  1105 + }
  1106 + } else {
  1107 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1108 + while (it.hasNext()) {
  1109 + ChildTaskPlan childTaskPlan = it.next();
  1110 + if (childTaskPlan.getMileageType().equals("empty")) {
  1111 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1112 + } else {
  1113 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1114 + }
  1115 + }
  1116 + }
  1117 + }
  1118 + }
  1119 + map.put("j_name", j_Name);
  1120 + map.put("jhlc", format.format(jhlc));
  1121 + map.put("remMileage", format.format(remMileage));
  1122 + map.put("addMileage", format.format(addMileage));
  1123 + map.put("yygl", format.format(yygl));
  1124 + map.put("ksgl", format.format(ksgl));
  1125 + map.put("realMileage", format.format(yygl + ksgl));
  1126 + map.put("jhbc", jhbc);
  1127 + map.put("cjbc", cjbc);
  1128 + map.put("ljbc", ljbc);
  1129 + map.put("sjbc", jhbc - cjbc + ljbc);
  1130 + return map;
  1131 + }
  1132 +
  1133 +
  1134 +
  1135 + @Override
  1136 + public Map<String, Object> findKMBC(String jName, String clZbh,
  1137 + String lpName, String date,String line) {
  1138 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date,line);
  1139 + DecimalFormat format = new DecimalFormat("0.00");
  1140 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1141 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1142 + int jhbc = 0, cjbc = 0, ljbc = 0;
  1143 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;
  1144 + float addMileage = 0l, remMileage = 0l;
  1145 + Map<String, Object> map = new HashMap<String, Object>();
  1146 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1147 + if (scheduleRealInfo != null) {
  1148 + //计划里程(主任务过滤掉临加班次),
  1149 + //烂班里程(主任务烂班),
  1150 + //临加里程(主任务临加),
  1151 + //计划班次,烂班班次,增加班次
  1152 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1153 + if (scheduleRealInfo.isSflj()) {
  1154 + addMileage += tempJhlc;
  1155 + ljbc++;
  1156 + } else {
  1157 + if (!(scheduleRealInfo.getBcType().equals("in")
  1158 + || scheduleRealInfo.getBcType().equals("out"))) {
  1159 + jhbc++;
  1160 + jhlc += tempJhlc;
  1161 + }
  1162 +
  1163 + if (scheduleRealInfo.getStatus() == -1) {
  1164 + remMileage += tempJhlc;
  1165 + cjbc++;
  1166 + }
  1167 + }
  1168 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1169 + //计算营运里程,空驶里程
  1170 + if (childTaskPlans.isEmpty()) {
  1171 + if (scheduleRealInfo.getBcType().equals("in") ||
  1172 + scheduleRealInfo.getBcType().equals("out")) {
  1173 + jcclc += tempJhlc;
  1174 + }
  1175 + //主任务 放空班次属于营运
  1176 +// else if(scheduleRealInfo.getBcType().equals("venting")){
  1177 +// ksgl += tempJhlc;
  1178 +// }
  1179 + else {
  1180 + if (scheduleRealInfo.getStatus() != -1) {
  1181 + yygl += tempJhlc;
  1182 + }
  1183 + }
  1184 + } else {
  1185 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1186 + while (it.hasNext()) {
  1187 + ChildTaskPlan childTaskPlan = it.next();
  1188 + if (childTaskPlan.getMileageType().equals("empty")) {
  1189 + if (childTaskPlan.isDestroy()) {
  1190 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1191 + } else {
  1192 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1193 + }
  1194 + } else {
  1195 + if (childTaskPlan.isDestroy()) {
  1196 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1197 +// cjbc++;
  1198 + } else {
  1199 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1200 + }
  1201 + }
  1202 + }
  1203 + }
  1204 + }
  1205 + }
  1206 + map.put("jhlc", format.format(jhlc));
  1207 + map.put("remMileage", format.format(remMileage));
  1208 + map.put("addMileage", format.format(addMileage));
  1209 + map.put("yygl", format.format(yygl));
  1210 + map.put("ksgl", format.format(ksgl));
  1211 + map.put("realMileage", format.format(yygl + ksgl + jcclc));
  1212 + map.put("jhbc", jhbc);
  1213 + map.put("cjbc", cjbc);
  1214 + map.put("ljbc", ljbc);
  1215 + map.put("sjbc", jhbc - cjbc + ljbc);
  1216 + map.put("jcclc", jcclc);
  1217 + map.put("zkslc", format.format(ksgl + jcclc));
  1218 + return map;
  1219 + }
  1220 +
  1221 +
  1222 + @Override
  1223 + public List<Map<String, Object>> account(String line, String date,
  1224 + String code, String xlName, String type) {
  1225 + List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code);
  1226 + List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
  1227 + Map<String, Object> map;
  1228 + int i = 1;
  1229 + for (Object[] obj : lsitObj) {
  1230 + if (obj != null) {
  1231 + map = new HashMap<String, Object>();
  1232 + map.put("num", i++);
  1233 + map.put("xlName", xlName);
  1234 + map.put("clZbh", obj[3]);
  1235 + map.put("company", obj[0]);
  1236 + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1] + "")).toUpperCase());
  1237 + map.put("requestTime", obj[2]);
  1238 + listMap.add(map);
  1239 + }
  1240 + }
  1241 +
  1242 + if (type != null && type.length() != 0 && type.equals("export")) {
  1243 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1244 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1245 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1246 + Map<String, Object> m = new HashMap<String, Object>();
  1247 + ReportUtils ee = new ReportUtils();
  1248 + Map<String, Object> typeMap = new HashMap<String, Object>();
  1249 + typeMap.put("0xA1", "请求恢复运营");
  1250 + typeMap.put("0xA2", "申请调档");
  1251 + typeMap.put("0xA3", "出场请求");
  1252 + typeMap.put("0xA5", "进场请求");
  1253 + typeMap.put("0xA7", "加油请求");
  1254 + typeMap.put("0x50", "车辆故障");
  1255 + typeMap.put("0x70", "路阻报告");
  1256 + typeMap.put("0x60", "事故报告");
  1257 + typeMap.put("0x11", "扣证纠纷");
  1258 + typeMap.put("0x12", "报警");
  1259 + for (Map<String, Object> map1 : listMap) {
  1260 + map1.put("requestText", typeMap.get(map1.get("requestType")));
  1261 + }
  1262 + try {
  1263 + listI.add(listMap.iterator());
  1264 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  1265 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\account.xls",
  1266 + path + "export\\驾驶员请求台账" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  1267 + } catch (Exception e) {
  1268 + // TODO: handle exception
  1269 + e.printStackTrace();
  1270 + }
  1271 + }
  1272 +
  1273 + return listMap;
  1274 + }
  1275 +
  1276 + @Override
  1277 + public List<ScheduleRealInfo> correctForm(String line, String startDate,
  1278 + String endDate, String lpName, String code, String type) {
  1279 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.correctForm(line, startDate, endDate, lpName, code);
  1280 +
  1281 + if (type != null && type.length() != 0 && type.equals("export")) {
  1282 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1283 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1284 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1285 + Map<String, Object> m = new HashMap<String, Object>();
  1286 + ReportUtils ee = new ReportUtils();
  1287 + m.put("dates", startDate + " 至 " + endDate);
  1288 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  1289 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1290 + for (ScheduleRealInfo schedule : list) {
  1291 + Map<String, Object> tempMap = new HashMap<String, Object>();
  1292 + tempMap.put("xlName", schedule.getXlName() != null ? schedule.getXlName() : "");
  1293 + tempMap.put("lpName", schedule.getLpName() != null ? schedule.getLpName() : "");
  1294 + tempMap.put("clZbh", schedule.getClZbh() != null ? schedule.getClZbh() : "");
  1295 + tempMap.put("jName", schedule.getjName() != null ? schedule.getjName() : "");
  1296 + tempMap.put("sName", schedule.getsName() != null ? schedule.getsName() : "");
  1297 + tempMap.put("fcsj", schedule.getFcsj() != null ? schedule.getFcsj() : "");
  1298 + tempMap.put("fcsjActual", schedule.getFcsjActual() != null ? schedule.getFcsjActual() : "");
  1299 + tempMap.put("zdsj", schedule.getZdsj() != null ? schedule.getZdsj() : "");
  1300 + tempMap.put("zdsjActual", schedule.getZdsjActual() != null ? schedule.getZdsjActual() : "");
  1301 + if (schedule.getUpdateBy() != null) {
  1302 + if (schedule.getUpdateBy().getName() != null)
  1303 + tempMap.put("userName", schedule.getUpdateBy().getName());
  1304 + else
  1305 + tempMap.put("userName", "");
  1306 + } else {
  1307 + tempMap.put("userName", "");
  1308 + }
  1309 + if (schedule.getUpdateDate() != null) {
  1310 + tempMap.put("updateDate", sdf.format(schedule.getUpdateDate()));
  1311 + } else {
  1312 + tempMap.put("updateDate", "");
  1313 + }
  1314 + tempMap.put("remarks", schedule.getRemarks() != null ? schedule.getRemarks() : "");
  1315 + tempList.add(tempMap);
  1316 + }
  1317 + try {
  1318 + listI.add(tempList.iterator());
  1319 + String path = this.getClass().getResource("/").getPath() + "static\\pages\\forms\\";
  1320 + ee.excelReplace(listI, new Object[]{m}, path + "mould\\correctForm.xls",
  1321 + path + "export\\修正报表" + sdfSimple.format(sdfMonth.parse(startDate)) + "-" + sdfSimple.format(sdfMonth.parse(endDate)) + ".xls");
  1322 + } catch (Exception e) {
  1323 + // TODO: handle exception
  1324 + e.printStackTrace();
  1325 + }
  1326 + Map<String, Object> map = tempList.get(tempList.size() - 1);
  1327 + System.out.println("tempMap:" + map);
  1328 + }
  1329 +
  1330 + return list;
  1331 + }
  1332 +
  1333 + @Override
  1334 + public List<ScheduleRealInfo> queryListWaybill(String jName, String clZbh,
  1335 + String lpName, String date,String line) {
  1336 + List<ScheduleRealInfo> list = null;
  1337 + list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date,line);
  1338 + for (int i = 0; i < list.size(); i++) {
  1339 + ScheduleRealInfo s = list.get(i);
  1340 + String remarks = "";
  1341 + if (s.getRemarks() != null) {
  1342 + remarks += s.getRemarks();
  1343 + }
  1344 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  1345 + if (!childTaskPlans.isEmpty()) {
  1346 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1347 + while (it.hasNext()) {
  1348 + ChildTaskPlan c = it.next();
  1349 + if (c.getRemarks() != null && c.getRemarks().length() > 0) {
  1350 + remarks += c.getRemarks();
  1351 + }
  1352 +
  1353 + }
  1354 + }
  1355 + s.setRemarks(remarks);
  1356 + }
  1357 +
  1358 + return list;
  1359 + }
  1360 +
  1361 + @Override
  1362 + public Map<String, Object> removeChildTask(Long taskId) {
  1363 + Map<String, Object> rs = new HashMap<>();
  1364 + ChildTaskPlan chTask = cTaskPlanRepository.findOne(taskId);
  1365 +
  1366 + ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());
  1367 + try {
  1368 +
  1369 + sch.getcTasks().remove(chTask);
  1370 + scheduleRealInfoRepository.save(sch);
  1371 + rs.put("status", ResponseCode.SUCCESS);
  1372 + } catch (Exception e) {
  1373 + logger.error("", e);
  1374 + rs.put("status", ResponseCode.ERROR);
  1375 + }
  1376 + return rs;
  1377 + }
  1378 +
  1379 + @Override
  1380 + public List<Map<String, Object>> statisticsDaily(String line, String date,
  1381 + String xlName) {
  1382 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1383 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  1384 + DecimalFormat format = new DecimalFormat("0.00");
  1385 + double jhlc = 0, tempJhlc = 0, childMileage = 0;
  1386 + float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f, ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_other = 0f, ljgl = 0f;
  1387 + //班次
  1388 + int sj_0 = 6 * 60 + 31, sj_1 = 8 * 60 + 30, sj_2 = 16 * 60 + 1, sj_3 = 18 * 60;
  1389 + int jhbc = 0, jhbc_m = 0, jhbc_a = 0;
  1390 + int sjbc = 0, sjbc_m = 0, sjbc_a = 0;
  1391 + int ljbc = 0, ljbc_m = 0, ljbc_a = 0;
  1392 + int fzbc = 0, fzbc_m = 0, fzbc_a = 0;
  1393 + int dtbc = 0, dtbc_m = 0, dtbc_a = 0;
  1394 + int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0;
  1395 + Map<String, Object> map = new HashMap<String, Object>();
  1396 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1397 + if (scheduleRealInfo != null) {
  1398 +
  1399 + if (!(scheduleRealInfo.getBcType().equals("in")
  1400 + || scheduleRealInfo.getBcType().equals("out"))) {
  1401 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1402 + //计算实际里程,少驶里程,计划里程=实际里程+少驶里程
  1403 + if (childTaskPlans.isEmpty()) {
  1404 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1405 + //临加公里
  1406 + if (scheduleRealInfo.isSflj()) {
  1407 + ljgl += tempJhlc;
  1408 + } else {
  1409 + jhlc += tempJhlc;
  1410 + }
  1411 + if (scheduleRealInfo.getStatus() == 2) {
  1412 + sjgl += tempJhlc;
  1413 + } else if (scheduleRealInfo.getStatus() == -1) {
  1414 + ssgl += tempJhlc;
  1415 + if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("路阻") != -1) {
  1416 + ssgl_lz += tempJhlc;
  1417 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("吊慢") != -1) {
  1418 + ssgl_dm += tempJhlc;
  1419 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("故障") != -1) {
  1420 + ssgl_gz += tempJhlc;
  1421 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("纠纷") != -1) {
  1422 + ssgl_jf += tempJhlc;
  1423 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("肇事") != -1) {
  1424 + ssgl_zs += tempJhlc;
  1425 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("缺人") != -1) {
  1426 + ssgl_qr += tempJhlc;
  1427 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("缺车") != -1) {
  1428 + ssgl_qc += tempJhlc;
  1429 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("客稀") != -1) {
  1430 + ssgl_kx += tempJhlc;
  1431 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("气候") != -1) {
  1432 + ssgl_qh += tempJhlc;
  1433 + } else if ((scheduleRealInfo.getRemarks() == null ? "" : scheduleRealInfo.getRemarks()).indexOf("援外") != -1) {
  1434 + ssgl_yw += tempJhlc;
  1435 + } else {
  1436 + ssgl_other += tempJhlc;
  1437 + }
  1438 + }
  1439 + } else {
  1440 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1441 + while (it.hasNext()) {
  1442 + ChildTaskPlan childTaskPlan = it.next();
  1443 + childMileage = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1444 + jhlc += childMileage;
  1445 + if (childTaskPlan.isDestroy()) {
  1446 + ssgl += childMileage;
  1447 + if (childTaskPlan.getDestroyReason().equals("路阻")) {
  1448 + ssgl_lz += childTaskPlan.getMileage();
  1449 + } else if (childTaskPlan.getDestroyReason().equals("吊慢")) {
  1450 + ssgl_dm += childTaskPlan.getMileage();
  1451 + } else if (childTaskPlan.getDestroyReason().equals("故障")) {
  1452 + ssgl_gz += childTaskPlan.getMileage();
  1453 + } else if (childTaskPlan.getDestroyReason().equals("纠纷")) {
  1454 + ssgl_jf += childTaskPlan.getMileage();
  1455 + } else if (childTaskPlan.getDestroyReason().equals("肇事")) {
  1456 + ssgl_zs += childTaskPlan.getMileage();
  1457 + } else if (childTaskPlan.getDestroyReason().equals("缺人")) {
  1458 + ssgl_qr += childTaskPlan.getMileage();
  1459 + } else if (childTaskPlan.getDestroyReason().equals("缺车")) {
  1460 + ssgl_qc += childTaskPlan.getMileage();
  1461 + } else if (childTaskPlan.getDestroyReason().equals("客稀")) {
  1462 + ssgl_kx += childTaskPlan.getMileage();
  1463 + } else if (childTaskPlan.getDestroyReason().equals("气候")) {
  1464 + ssgl_qh += childTaskPlan.getMileage();
  1465 + } else if (childTaskPlan.getDestroyReason().equals("援外")) {
  1466 + ssgl_yw += childTaskPlan.getMileage();
  1467 + } else {
  1468 + ssgl_other += childTaskPlan.getMileage();
  1469 + }
  1470 + } else {
  1471 + sjgl += childMileage;
  1472 + }
  1473 + }
  1474 + }
  1475 +
  1476 + //班次
  1477 + jhbc++;
  1478 + String[] fcsj = scheduleRealInfo.getFcsj().split(":");
  1479 + String[] fcsjActual = (scheduleRealInfo.getFcsjActual() == null ? "0:00" : scheduleRealInfo.getFcsjActual()).split(":");
  1480 + if ((Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) > sj_0 && (Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) < sj_1) {
  1481 + jhbc_m++;
  1482 + } else if ((Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) > sj_2 && (Integer.parseInt(fcsj[0]) * 60 + Integer.parseInt(fcsj[1])) < sj_3) {
  1483 + jhbc_a++;
  1484 + }
  1485 + if (scheduleRealInfo.getStatus() == 2) {
  1486 + sjbc++;
  1487 + if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_1) {
  1488 + sjbc_m++;
  1489 + } else if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_3) {
  1490 + sjbc_a++;
  1491 + }
  1492 + }
  1493 + if (scheduleRealInfo.isSflj()) {
  1494 + ljbc++;
  1495 + if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_1) {
  1496 + ljbc_m++;
  1497 + } else if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_3) {
  1498 + ljbc_a++;
  1499 + }
  1500 + }
  1501 + if (scheduleRealInfo.getBcType().equals("venting")) {
  1502 + fzbc++;
  1503 + if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_1) {
  1504 + fzbc_m++;
  1505 + } else if ((Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0]) * 60 + Integer.parseInt(fcsjActual[1])) < sj_3) {
  1506 + fzbc_a++;
  1507 + }
  1508 + }
  1509 + }
  1510 + }
  1511 + }
  1512 + map.put("xlName", xlName);
  1513 + map.put("jhlc", format.format(jhlc));
  1514 + map.put("sjgl", format.format(sjgl));
  1515 + map.put("ssgl", format.format(ssgl));
  1516 + map.put("ssgl_lz", ssgl_lz == 0 ? 0 : format.format(ssgl_lz));
  1517 + map.put("ssgl_dm", ssgl_dm == 0 ? 0 : format.format(ssgl_dm));
  1518 + map.put("ssgl_gz", ssgl_gz == 0 ? 0 : format.format(ssgl_gz));
  1519 + map.put("ssgl_jf", ssgl_jf == 0 ? 0 : format.format(ssgl_jf));
  1520 + map.put("ssgl_zs", ssgl_zs == 0 ? 0 : format.format(ssgl_zs));
  1521 + map.put("ssgl_qr", ssgl_qr == 0 ? 0 : format.format(ssgl_qr));
  1522 + map.put("ssgl_qc", ssgl_qc == 0 ? 0 : format.format(ssgl_qc));
  1523 + map.put("ssgl_kx", ssgl_kx == 0 ? 0 : format.format(ssgl_kx));
  1524 + map.put("ssgl_qh", ssgl_qh == 0 ? 0 : format.format(ssgl_qh));
  1525 + map.put("ssgl_yw", ssgl_yw == 0 ? 0 : format.format(ssgl_yw));
  1526 + map.put("ssgl_other", ssgl_other == 0 ? 0 : format.format(ssgl_other));
  1527 + map.put("ljgl", ljgl == 0 ? 0 : format.format(ljgl));
  1528 + map.put("jhbc", jhbc);
  1529 + map.put("jhbc_m", jhbc_m);
  1530 + map.put("jhbc_a", jhbc_a);
  1531 + map.put("sjbc", sjbc);
  1532 + map.put("sjbc_m", sjbc_m);
  1533 + map.put("sjbc_a", sjbc_a);
  1534 + map.put("ljbc", ljbc);
  1535 + map.put("ljbc_m", ljbc_m);
  1536 + map.put("ljbc_a", ljbc_a);
  1537 + map.put("fzbc", fzbc);
  1538 + map.put("fzbc_m", fzbc_m);
  1539 + map.put("fzbc_a", fzbc_a);
  1540 + map.put("dtbc", dtbc);
  1541 + map.put("dtbc_m", dtbc_m);
  1542 + map.put("dtbc_a", dtbc_a);
  1543 + map.put("djg", djg);
  1544 + map.put("djg_m", djg_m);
  1545 + map.put("djg_a", djg_a);
  1546 + map.put("djg_time", djg_time);
  1547 + lMap.add(map);
  1548 + return lMap;
  1549 + }
  1550 +
  1551 + @Override
  1552 + public Map<String, Object> scheduleDaily(String line, String date) {
  1553 + Map<String, String> tempMap = null;
  1554 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1555 + Map<String, Object> map = new HashMap<String, Object>();
  1556 + Double jhlc = 0.00;
  1557 + Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f, ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_other = 0f, ljgl = 0f;
  1558 + int jhbc = 0;
  1559 + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {
  1560 + if (scheduleRealInfo != null) {
  1561 + //计算里程(包括子任务)
  1562 + jhlc += scheduleRealInfo.getJhlc();
  1563 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1564 + if (!childTaskPlans.isEmpty()) {
  1565 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1566 + while (it.hasNext()) {
  1567 + ChildTaskPlan childTaskPlan = it.next();
  1568 + //是否烂班,烂班就是少驶
  1569 + if (!childTaskPlan.isDestroy()) {
  1570 + sjgl += childTaskPlan.getMileage();
  1571 + } else {
  1572 + ssgl += childTaskPlan.getMileage();
  1573 + if (childTaskPlan.getDestroyReason().equals("路阻")) {
  1574 + ssgl_lz += childTaskPlan.getMileage();
  1575 + } else if (childTaskPlan.getDestroyReason().equals("吊慢")) {
  1576 + ssgl_dm += childTaskPlan.getMileage();
  1577 + } else if (childTaskPlan.getDestroyReason().equals("故障")) {
  1578 + ssgl_gz += childTaskPlan.getMileage();
  1579 + } else if (childTaskPlan.getDestroyReason().equals("纠纷")) {
  1580 + ssgl_jf += childTaskPlan.getMileage();
  1581 + } else if (childTaskPlan.getDestroyReason().equals("肇事")) {
  1582 + ssgl_zs += childTaskPlan.getMileage();
  1583 + } else if (childTaskPlan.getDestroyReason().equals("缺人")) {
  1584 + ssgl_qr += childTaskPlan.getMileage();
  1585 + } else if (childTaskPlan.getDestroyReason().equals("缺车")) {
  1586 + ssgl_qc += childTaskPlan.getMileage();
  1587 + } else if (childTaskPlan.getDestroyReason().equals("客稀")) {
  1588 + ssgl_kx += childTaskPlan.getMileage();
  1589 + } else if (childTaskPlan.getDestroyReason().equals("气候")) {
  1590 + ssgl_qh += childTaskPlan.getMileage();
  1591 + } else if (childTaskPlan.getDestroyReason().equals("援外")) {
  1592 + ssgl_yw += childTaskPlan.getMileage();
  1593 + } else {
  1594 + ssgl_other += childTaskPlan.getMileage();
  1595 + }
  1596 + }
  1597 + //临加公里
  1598 + if (childTaskPlan.getType1().equals("临加")) {
  1599 + ljgl += childTaskPlan.getMileage();
  1600 + }
  1601 + }
  1602 + }
  1603 + //班次
  1604 + scheduleRealInfo.getFcsjT();
  1605 + scheduleRealInfo.getFcsjActualTime();
  1606 + }
  1607 + }
  1608 + map.put("jhlc", jhlc);
  1609 + map.put("sjgl", sjgl);
  1610 + map.put("ssgl", ssgl);
  1611 + map.put("ssgl_lz", ssgl_lz);
  1612 + map.put("ssgl_dm", ssgl_dm);
  1613 + map.put("ssgl_gz", ssgl_gz);
  1614 + map.put("ssgl_jf", ssgl_jf);
  1615 + map.put("ssgl_zs", ssgl_zs);
  1616 + map.put("ssgl_qr", ssgl_qr);
  1617 + map.put("ssgl_qc", ssgl_qc);
  1618 + map.put("ssgl_kx", ssgl_kx);
  1619 + map.put("ssgl_qh", ssgl_qh);
  1620 + map.put("ssgl_yw", ssgl_yw);
  1621 + map.put("ssgl_other", ssgl_other);
  1622 + map.put("ljgl", ljgl);
  1623 +
  1624 + map.put("jhbc", scheduleRealInfos.size());
  1625 + return null;
  1626 + }
  1627 +
  1628 + @Override
  1629 + public int countByLineCodeAndDate(String xlBm, String schDate) {
  1630 + return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);
  1631 + }
  1632 +
  1633 + @Override
  1634 + public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {
  1635 + return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);
  1636 + }
  1637 +
  1638 + @Override
  1639 + public void deleteByLineCodeAndDate(String xlBm, String schDate) {
  1640 + scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);
  1641 + }
  1642 +
  1643 + @Override
  1644 + public Long getMaxId() {
  1645 + return scheduleRealInfoRepository.getMaxId();
  1646 + }
  1647 +
  1648 + @Override
  1649 + public List<ScheduleRealInfo> realScheduleList(String line, String date) {
  1650 + /*List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.queryUserInfo(line, date);
  1651 + List<ScheduleRealInfo> listTotal = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1652 + for(ScheduleRealInfo info:listInfo){
  1653 + for(ScheduleRealInfo total:listTotal){
  1654 + if(info.getjGh().equals(total.getjGh()) && info.getLpName().equals(total.getLpName()) && info.getClZbh().equals(total.getClZbh())){
  1655 +
  1656 + }
736 1657 }
  1658 + }*/
  1659 + return scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1660 + }
737 1661  
738   - sch.setFcsjActualAll(fcsjActual);
739   - sch.addRemarks(remarks);
740   - sch.calcStatus();
741   -
742   - dayOfSchedule.save(sch);
743   - //scheduleRealInfoRepository.save(sch);
744   -
745   - ts.add(sch);
746   -
747   - rs.put("status", ResponseCode.SUCCESS);
748   - rs.put("ts", ts);
749   -
750   - //通知页面刷新
751   - sendUtils.refreshSch(ts);
752   - } catch (Exception e) {
753   - logger.error("", e);
754   - rs.put("status", ResponseCode.ERROR);
755   - }
756   -
757   - return rs;
758   - }
759   -
760   - @Override
761   - public Map<String, Object> revokeDestroy(Long id) {
762   - Map<String, Object> rs = new HashMap<>();
763   - try {
764   - ScheduleRealInfo sch = dayOfSchedule.get(id);
765   - if (sch.getStatus() != -1) {
766   - rs.put("status", ResponseCode.ERROR);
767   - rs.put("msg", "未烂班,无法撤销!");
768   - } else {
769   - sch.setStatus(0);
770   - rs.put("status", ResponseCode.SUCCESS);
771   - rs.put("t", sch);
772   -
773   - }
774   - } catch (Exception e) {
775   - logger.error("", e);
776   - rs.put("status", ResponseCode.ERROR);
777   - }
778   - return rs;
779   - }
780 1662  
781   - @Override
782   - public Map<String, Object> revokeRealOutgo(Long id) {
783   - Map<String, Object> rs = new HashMap<>();
784   - List<ScheduleRealInfo> ts = new ArrayList<>();
  1663 + public List<Map<String, Object>> yesterdayDataList(String line, String date) {
  1664 + //前一天日期
  1665 +// String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
  1666 +// String date = "2016-09-20";
  1667 + List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date);
  1668 +// List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1669 + for (int x = 0; x < yesterdayDataList.size(); x++) {
  1670 + String jName = yesterdayDataList.get(x).get("jGh").toString();
  1671 + String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
  1672 + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date);
  1673 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;
  1674 + float addMileage = 0l, remMileage = 0l;
  1675 + Map<String, Object> map = new HashMap<String, Object>();
  1676 + boolean fage = true;
  1677 + for (ScheduleRealInfo scheduleRealInfo : lists) {
  1678 + if (fage) {
  1679 + //根据线路代码获取公司
  1680 + Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
  1681 + yesterdayDataList.get(x).put("company", li.getCompany());
  1682 + yesterdayDataList.get(x).put("bCompany", li.getBrancheCompany());
  1683 + fage = false;
  1684 + }
  1685 + if (scheduleRealInfo != null) {
  1686 + //计划里程(主任务过滤掉临加班次),
  1687 + //烂班里程(主任务烂班),
  1688 + //临加里程(主任务临加),
  1689 + //计划班次,烂班班次,增加班次
  1690 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1691 + if (scheduleRealInfo.isSflj()) {
  1692 + addMileage += tempJhlc;
  1693 + } else {
  1694 + if (!(scheduleRealInfo.getBcType().equals("in")
  1695 + || scheduleRealInfo.getBcType().equals("out"))) {
  1696 + jhlc += tempJhlc;
  1697 + }
  1698 +
  1699 + if (scheduleRealInfo.getStatus() == -1) {
  1700 + remMileage += tempJhlc;
  1701 + }
  1702 + }
  1703 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1704 + //计算营运里程,空驶里程
  1705 + if (childTaskPlans.isEmpty()) {
  1706 + if (scheduleRealInfo.getBcType().equals("in") ||
  1707 + scheduleRealInfo.getBcType().equals("out")) {
  1708 + jcclc += tempJhlc;
  1709 + }
  1710 + //主任务 放空班次属于营运
  1711 +// else if(scheduleRealInfo.getBcType().equals("venting")){
  1712 +// ksgl += tempJhlc;
  1713 +// }
  1714 + else {
  1715 + if (scheduleRealInfo.getStatus() != -1) {
  1716 + yygl += tempJhlc;
  1717 + }
  1718 + }
  1719 + } else {
  1720 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1721 + while (it.hasNext()) {
  1722 + ChildTaskPlan childTaskPlan = it.next();
  1723 + if (childTaskPlan.getMileageType().equals("empty")) {
  1724 + if (childTaskPlan.isDestroy()) {
  1725 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1726 + } else {
  1727 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1728 + }
  1729 + } else {
  1730 + if (childTaskPlan.isDestroy()) {
  1731 + remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1732 + } else {
  1733 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1734 + }
  1735 + }
  1736 + }
  1737 + }
  1738 + }
  1739 + }
  1740 +
  1741 + yesterdayDataList.get(x).put("totalKilometers", yygl + ksgl + jcclc);
  1742 +
  1743 + }
785 1744  
786   - try {
787   - ScheduleRealInfo sch = dayOfSchedule.get(id);
788   - if (sch.getFcsjActual() == null) {
789   - rs.put("status", ResponseCode.ERROR);
790   - rs.put("msg", "无实发时间,无法撤销!");
791   - } else {
792   - //将对应的到离站数据标记为不可信
793   - List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());
794   - for(ArrivalEntity arr : list){
795   - if(arr.getInOut() == 1
796   - && arr.getUpDown() == Integer.parseInt(sch.getXlDir())
797   - && arr.getStopNo().equals(sch.getQdzCode())
798   - && Math.abs(arr.getTs() - sch.getFcsjActualTime()) < 1000 * 60){
799   - arr.setEnable(false);
800   - break;
801   - }
  1745 + /* for(ScheduleRealInfo scheduleRealInfo:list){
  1746 + if(scheduleRealInfo != null){
  1747 + for(int i=0;i<yesterdayDataList.size();i++){
  1748 + if(scheduleRealInfo.getXlBm().equals(yesterdayDataList.get(i).get("xlBm")) && scheduleRealInfo.getClZbh().equals(yesterdayDataList.get(i).get("clZbh"))
  1749 + && scheduleRealInfo.getjGh().equals(yesterdayDataList.get(i).get("jGh"))){
  1750 + //根据线路代码获取公司
  1751 + Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
  1752 + yesterdayDataList.get(i).put("company", li.getCompany());
  1753 + yesterdayDataList.get(i).put("bCompany", li.getBrancheCompany());
  1754 + //计算总公里
  1755 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1756 + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
  1757 + if(childTaskPlans.isEmpty()){
  1758 + if(scheduleRealInfo.getStatus() == 2){
  1759 + yesterdayDataList.get(i).put("totalKilometers", scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers")));
  1760 + }
  1761 + }else{
  1762 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1763 + while(it.hasNext()){
  1764 + ChildTaskPlan childTaskPlan = it.next();
  1765 + if(!childTaskPlan.isDestroy()){
  1766 + yesterdayDataList.get(i).put("totalKilometers", childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers")));
  1767 + }
  1768 + }
  1769 + }
  1770 + }
802 1771 }
803   -
804   - sch.clearFcsjActual();
805   - rs.put("status", ResponseCode.SUCCESS);
806   -
807   - ts.add(sch);
808   - rs.put("ts", ts);
809   -
810   - }
811   - } catch (Exception e) {
812   - logger.error("", e);
813   - rs.put("status", ResponseCode.ERROR);
814   - }
815   - return rs;
816   - }
817   -
818   - @Override
819   - public Map<String, Object> spaceAdjust(Long[] ids, Integer space) {
820   -
821   - List<ScheduleRealInfo> list = new ArrayList<>()
822   - ,updateList = new ArrayList<>();
823   - Map<String, Object> rs = new HashMap<>();
824   - try {
825   - ScheduleRealInfo sch, next;
826   - for (Long id : ids) {
827   - sch = dayOfSchedule.get(id);
828   - if (null != sch)
829   - list.add(sch);
830 1772 }
  1773 + }*/
  1774 + //增加顺序号
  1775 + for (int i = 0; i < yesterdayDataList.size(); i++) {
  1776 + if (i == 0) {
  1777 + yesterdayDataList.get(i).put("seqNumber", 1);
  1778 + } else {
  1779 + if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) {
  1780 + yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber"));
  1781 + } else {
  1782 + yesterdayDataList.get(i).put("seqNumber", 1);
  1783 + }
  1784 + }
  1785 + }
  1786 + return yesterdayDataList;
  1787 + }
  1788 +
  1789 + /**
  1790 + * 批量调整人车
  1791 + */
  1792 + @Override
  1793 + public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs) {
  1794 + Map<String, Object> rs = new HashMap<>();
  1795 + Set<ScheduleRealInfo> set = new HashSet<>();
  1796 +
  1797 + ScheduleRealInfo sch;
  1798 + BiMap<String, String> map = BasicData.deviceId2NbbmMap.inverse();
  1799 +
  1800 + for (ChangePersonCar cpc : cpcs) {
  1801 +
  1802 + if (map.get(cpc.getClZbh()) == null) {
  1803 + rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
  1804 + rs.put("status", ResponseCode.ERROR);
  1805 + return rs;
  1806 + }
  1807 +
  1808 + sch = dayOfSchedule.get(cpc.getSchId());
  1809 + if (sch == null)
  1810 + continue;
  1811 +
  1812 + if (StringUtils.isNotEmpty(cpc.getJsy())) {
  1813 + //换驾驶员
  1814 + persoChange(sch, cpc.getJsy().split("/")[0]);
  1815 + }
  1816 +
  1817 + //换售票员
  1818 + if (StringUtils.isNotEmpty(cpc.getSpy())) {
  1819 + persoChangeSPY(sch, cpc.getSpy().split("/")[0]);
  1820 + }
  1821 +
  1822 + //换车
  1823 + if (StringUtils.isNotEmpty(cpc.getClZbh())) {
  1824 + set.add(sch);
  1825 + set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));
  1826 + }
  1827 +
  1828 + }
  1829 + rs.put("ts", set);
  1830 + rs.put("status", ResponseCode.SUCCESS);
  1831 + return rs;
  1832 + }
  1833 +
  1834 + /**
  1835 + * @Title: persoChange
  1836 + * @Description: TODO(班次换驾驶员)
  1837 + */
  1838 + public void persoChange(ScheduleRealInfo sch, String jGh) {
  1839 + if (sch.getjGh().equals(jGh))
  1840 + return;
  1841 + String jName = BasicData.allPerson.get(jGh);
  1842 + if (StringUtils.isNotEmpty(jName)) {
  1843 + sch.setjGh(jGh);
  1844 + sch.setjName(jName);
  1845 + }
  1846 + }
  1847 +
  1848 + /**
  1849 + * @Title: persoChange
  1850 + * @Description: TODO(班次换售票员)
  1851 + */
  1852 + public void persoChangeSPY(ScheduleRealInfo sch, String sGh) {
  1853 + if (sch.getsGh().equals(sGh))
  1854 + return;
  1855 + String sName = BasicData.allPerson.get(sGh);
  1856 + if (StringUtils.isNotEmpty(sName)) {
  1857 + sch.setsGh(sGh);
  1858 + sch.setsName(sName);
  1859 + }
  1860 + }
  1861 +
  1862 + /**
  1863 + * 批量待发调整
  1864 + */
  1865 + @Override
  1866 + public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {
  1867 + Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>();
  1868 + List<ScheduleRealInfo> list = new ArrayList<>();
  1869 +
  1870 + ScheduleRealInfo sch, next;
  1871 + for (DfsjChange dc : dfsjcs) {
  1872 + if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))
  1873 + continue;
  1874 +
  1875 + /*sch = dayOfSchedule.get(dc.getSchId());
  1876 + if(sch==null)
  1877 + continue;
  1878 +
  1879 + sch.setDfsjAll(dc.getNew_dfsj());
  1880 + //重新计算终点时间
  1881 + sch.calcEndTime();
  1882 + list.add(sch);*/
  1883 + tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null);
831 1884  
832   - int size = list.size();
833   - if(size == 0){
834   - rs.put("status", ResponseCode.ERROR);
835   - }
836   - else{
837   - // 按发车时间排序
838   - Collections.sort(list, new ScheduleComparator.FCSJ());
839   -
840   - // 以第一个实际发车/待发时间为起点,调整间隔
841   - sch = list.get(0);
842   - Long st = sch.getFcsjActualTime()==null?sch.getDfsjT():sch.getFcsjActualTime()
843   - ,plus = space * 60 * 1000L;
844   -
845   - for(int i = 1; i < size; i ++){
846   - st += plus;
847   - sch = list.get(i);
848   - sch.setDfsjAll(st);
849   - //重新计算终点时间
850   - sch.calcEndTime();
851   -
852   - dayOfSchedule.save(sch);
853   -
854   - updateList.add(sch);
855   - next=dayOfSchedule.next(sch);
856   - if(next.getQdzName().equals(sch.getZdzName())){
857   - next.setQdzArrDateJH(sch.getZdsj());
858   - updateList.add(next);
859   - }
860   - }
  1885 + if (tempMap.get("status").equals(ResponseCode.SUCCESS)) {
  1886 + list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));
  1887 + }
  1888 + //next=dayOfSchedule.next(sch);
  1889 + /*if(next.getQdzName().equals(sch.getZdzName())){
  1890 + next.setQdzArrDateJH(sch.getZdsj());
  1891 + list.add(next);
  1892 + }*/
  1893 + }
861 1894  
  1895 + rs.put("status", ResponseCode.SUCCESS);
  1896 + rs.put("ts", list);
  1897 + return rs;
  1898 + }
862 1899  
863   - rs.put("status", ResponseCode.SUCCESS);
864   - rs.put("ts", updateList);
865   - }
866   -
867   - } catch (Exception e) {
868   - logger.error("", e);
869   - rs.put("status", ResponseCode.ERROR);
870   - }
871   - return rs;
872   - }
873 1900  
874   - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
875   -
876   - @Override
877   - public Map<String, Object> schInfoFineTune(Map<String, String> map) {
878   - Map<String, Object> rs = new HashMap<>();
879   - List<ScheduleRealInfo> ts = new ArrayList<>();
880   - try {
881   - Long id = Long.parseLong(map.get("id"));
882   - //班次类型
883   - //String bcType = map.get("bcType");
884   - //车辆自编号
885   - //String clZbh = map.get("clZbh");
886   - //计划发车时间
887   - //String fcsj = map.get("fcsj");
888   - //实际发车时间
889   - String fcsjActual = map.get("fcsjActual");
890   -
891   - //实际终点时间
892   - String zdsjActual = map.get("zdsjActual");
893   - //备注
894   - String remarks = map.get("remarks");
895   -
896   - ScheduleRealInfo sch = dayOfSchedule.get(id);
897   - if(null != sch){
898   -// //驾驶员
899   -// if(StringUtils.isNotBlank(map.get("jsy"))){
900   -// String[] jsy = map.get("jsy").split("/");
901   -// sch.setjGh(jsy[0]);
902   -// sch.setjName(jsy[1]);
903   -// }
904   -
905   - //售票员
906   -// if(StringUtils.isNotBlank(map.get("spy"))){
907   -// String[] spy = map.get("spy").split("/");
908   -// sch.setsGh(spy[0]);
909   -// sch.setsName(spy[1]);
910   -// }
911   -
912   - //sch.setBcType(bcType);
913   - //sch.setClZbh(clZbh);
914   - //sch.setFcsjAll(fcsj);
915   -
916   - if(StringUtils.isNotBlank(fcsjActual)){
917   - LineConfig config = lineConfigData.get(sch.getXlBm());
918   - long t=0L;
919   - //小于线路开始运营时间,则默认跨过24点
920   - if(fcsjActual.compareTo(config.getStartOpt()) < 0)
921   - t=fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)+fcsjActual);
922   - else
923   - t=fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+fcsjActual);
924   -
925   - //调整实发
926   - if(!fcsjActual.equals(sch.getFcsjActual()))
927   - sch.setFcsjActualAll(t);
928   - }
929   - else{
930   - //撤销实发
931   - if(sch.getFcsjActual() != null)
932   - revokeRealOutgo(sch.getId());
933   - }
934   -
935   - //实达时间
936   - if(StringUtils.isNotBlank(zdsjActual)){
937   - if(!zdsjActual.equals(sch.getZdsjActual())){
938   - //调整实达
939   - sch.setZdsjActualAll(zdsjActual);
940   - //下一班次起点到达时间
941   - ScheduleRealInfo next = dayOfSchedule.next(sch);
942   - if(null != next){
943   - next.setQdzArrDateSJ(zdsjActual);
944   - ts.add(next);
945   - }
946   -
947   - //重新计算车辆执行班次
948   - dayOfSchedule.reCalcExecPlan(sch.getClZbh());
949   - }
950   - }
951   - else {
952   - /*if(sch.getZdsjActual() != null){
953   - //将对应的到离站数据标记为不可信
954   - List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());
955   - for(ArrivalEntity arr : list){
956   - if(arr.getInOut() == 0
957   - && arr.getUpDown() == Integer.parseInt(sch.getXlDir())
958   - && arr.getStopNo().equals(sch.getZdzCode())
959   - && Math.abs(arr.getTs() - sch.getZdsjActualTime()) < 1000 * 60){
960   - arr.setEnable(false);
961   - break;
962   - }
963   - }
964   - }*/
965   -
966   - //清除实达时间
967   - sch.clearZdsjActual();
968   - //清除下一班次起点到达时间
969   - ScheduleRealInfo next = dayOfSchedule.next(sch);
970   - if(null != next){
971   - next.setQdzArrDateSJ(null);
972   - ts.add(next);
973   - }
974   - }
975   -
976   - sch.setRemarks(remarks);
977   - }
978   -
979   - //班次状态
980   - sch.calcStatus();
981   - dayOfSchedule.save(sch);
982   - //页面需要更新的班次信息
983   - ts.add(sch);
984   -
985   - rs.put("status", ResponseCode.SUCCESS);
986   - rs.put("ts", ts);
987   - } catch (Exception e) {
988   - logger.error("", e);
989   - rs.put("status", ResponseCode.ERROR);
990   - }
991   - return rs;
992   - }
993   -
994   - @Override
995   - public Map<String, Object> outgoAdjustAll(String params) {
996   - Map<String, Object> rs = new HashMap<>();
997   - try{
998   - JSONArray jsonArray = JSONArray.parseArray(params);
999   -
1000   - ScheduleRealInfo schedule = null;
1001   - JSONObject jsonObj;
1002   - String dfsj;
1003   - for(int i = 0; i < jsonArray.size(); i ++){
1004   - jsonObj = jsonArray.getJSONObject(i);
1005   - dfsj = jsonObj.getString("t");
1006   - schedule = dayOfSchedule.get(jsonObj.getLong("id"));
1007   - //设置待发时间
1008   - schedule.setDfsjAll(dfsj);
1009   -
1010   - dayOfSchedule.save(schedule);
1011   - }
1012   -
1013   - rs.put("status", ResponseCode.SUCCESS);
1014   - //将更新的最后一个班次返回
1015   - rs.put("t", schedule);
1016   - }catch(Exception e){
1017   - logger.error("", e);
1018   - rs.put("status", ResponseCode.ERROR);
1019   - }
1020   - return rs;
1021   - }
  1901 + @Override
  1902 + public Map<String, Object> findKMBC1(String jName, String clZbh,
  1903 + String date, String enddate) {
  1904 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);
  1905 + DecimalFormat format = new DecimalFormat("0.00");
  1906 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1907 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1908 + int jhbc = 0, cjbc = 0, ljbc = 0;
  1909 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0;
  1910 + float addMileage = 0l, remMileage = 0l;
  1911 + Map<String, Object> map = new HashMap<String, Object>();
  1912 + for (ScheduleRealInfo scheduleRealInfo : list) {
  1913 + if (scheduleRealInfo != null) {
  1914 + //计划里程(主任务过滤掉临加班次),
  1915 + //烂班里程(主任务烂班),
  1916 + //临加里程(主任务临加),
  1917 + //计划班次,烂班班次,增加班次
  1918 + tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1919 + if (scheduleRealInfo.isSflj()) {
  1920 + addMileage += tempJhlc;
  1921 + ljbc++;
  1922 + } else {
  1923 + jhlc += tempJhlc;
  1924 + jhbc++;
  1925 + if (scheduleRealInfo.getStatus() == -1) {
  1926 + remMileage += tempJhlc;
  1927 + cjbc++;
  1928 + }
  1929 + }
  1930 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1931 + //计算营运里程,空驶里程
  1932 + if (childTaskPlans.isEmpty()) {
  1933 + if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  1934 + || scheduleRealInfo.getBcType().equals("venting")) {
  1935 + ksgl += tempJhlc;
  1936 + } else {
  1937 + yygl += tempJhlc;
  1938 + }
  1939 + } else {
  1940 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1941 + while (it.hasNext()) {
  1942 + ChildTaskPlan childTaskPlan = it.next();
  1943 + if (childTaskPlan.getMileageType().equals("empty")) {
  1944 + ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1945 + } else {
  1946 + yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
  1947 + }
  1948 + }
  1949 + }
  1950 + }
  1951 + }
  1952 + map.put("jhlc", format.format(jhlc));
  1953 + map.put("remMileage", format.format(remMileage));
  1954 + map.put("addMileage", format.format(addMileage));
  1955 + map.put("yygl", format.format(yygl));
  1956 + map.put("ksgl", format.format(ksgl));
  1957 + map.put("realMileage", format.format(yygl + ksgl));
  1958 + map.put("jhbc", jhbc);
  1959 + map.put("cjbc", cjbc);
  1960 + map.put("ljbc", ljbc);
  1961 + map.put("sjbc", jhbc - cjbc + ljbc);
  1962 + return map;
  1963 + }
  1964 +
  1965 + /**
  1966 + * 调整班次类型
  1967 + *
  1968 + * @param id
  1969 + * @param bcType
  1970 + * @param remarks
  1971 + * @return
  1972 + */
  1973 + @Override
  1974 + public Map<String, Object> changeBcType(Long id, String bcType, String remarks) {
  1975 + Map<String, Object> rs = new HashMap<>();
  1976 +
  1977 + try {
  1978 + ScheduleRealInfo sch = dayOfSchedule.get(id);
  1979 + if (sch != null) {
  1980 + sch.setBcType(bcType);
  1981 + sch.addRemarks(remarks);
  1982 + //有时间记录一下相关变更数据
  1983 + rs.put("status", ResponseCode.SUCCESS);
  1984 + rs.put("t", sch);
  1985 + }
  1986 + } catch (Exception e) {
  1987 + logger.error("", e);
  1988 + rs.put("status", ResponseCode.ERROR);
  1989 + }
  1990 +
  1991 + return rs;
  1992 + }
  1993 +
  1994 + @Override
  1995 + public Map<String, Object> historySave(ScheduleRealInfo sch) {
  1996 + Map<String, Object> rs = new HashMap<>();
  1997 + rs.put("status", ResponseCode.ERROR);
  1998 +
  1999 + ScheduleRealInfo oldSch = super.findById(sch.getId());
  2000 + //修改车辆
  2001 + if (!oldSch.getClZbh().equals(sch.getClZbh())) {
  2002 + Set<String> allCar = BasicData.deviceId2NbbmMap.values();
  2003 + if (!allCar.contains(sch.getClZbh())) {
  2004 + rs.put("msg", "无效的车辆自编号");
  2005 + return rs;
  2006 + } else
  2007 + oldSch.setClZbh(sch.getClZbh());
  2008 + }
  2009 +
  2010 + //修改驾驶员
  2011 + if (!oldSch.getjGh().equals(sch.getjGh())) {
  2012 + Map<String, String> allPer = BasicData.allPerson;
  2013 + if (!allPer.containsKey(sch.getjGh())) {
  2014 + rs.put("msg", "无效的驾驶员");
  2015 + return rs;
  2016 + } else {
  2017 + oldSch.setjGh(sch.getjGh());
  2018 + oldSch.setjName(allPer.get(oldSch.getjGh()));
  2019 + }
  2020 + }
  2021 +
  2022 + //待发时间
  2023 + oldSch.setDfsj(sch.getDfsj());
  2024 + //实发时间
  2025 + oldSch.setFcsjActual(sch.getFcsjActual());
  2026 + //实际终点
  2027 + oldSch.setZdsjActual(sch.getZdsjActual());
  2028 + //备注
  2029 + oldSch.setRemarks(sch.getRemarks());
  2030 +
  2031 + scheduleRealInfoRepository.save(oldSch);
  2032 + rs.put("status", ResponseCode.SUCCESS);
  2033 + return rs;
  2034 + }
  2035 +
  2036 + @Autowired
  2037 + SvgAttributeRepository svgAttributeRepository;
  2038 +
  2039 + @Override
  2040 + public Map<String, Object> svgAttr(String jsonStr) {
  2041 + Map<String, Object> rs = new HashMap<>();
  2042 +
  2043 + try {
  2044 + JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr));
  2045 +
  2046 + SvgAttribute svgAttribute = new SvgAttribute();
  2047 + svgAttribute.setLineCode(jObj.getString("lineCode"));
  2048 + svgAttribute.setHideStations(jObj.getString("hideStations"));
  2049 + svgAttribute.setNicknames(jObj.getString("nicknames"));
  2050 + svgAttributeRepository.save(svgAttribute);
  2051 +
  2052 + rs.put("t", svgAttribute);
  2053 + rs.put("status", ResponseCode.SUCCESS);
  2054 + } catch (Exception e) {
  2055 + logger.error("", e);
  2056 + rs.put("status", ResponseCode.ERROR);
  2057 + }
  2058 + return rs;
  2059 + }
  2060 +
  2061 + @Override
  2062 + public Map<String, Object> findSvgAttr(String idx) {
  2063 + Map<String, Object> rs = new HashMap<>();
  2064 + try {
  2065 + List<String> lineCodes = Splitter.on(",").splitToList(idx);
  2066 + List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes);
  2067 +
  2068 + rs.put("status", ResponseCode.SUCCESS);
  2069 + rs.put("list", list);
  2070 + } catch (Exception e) {
  2071 + logger.error("", e);
  2072 + rs.put("status", ResponseCode.ERROR);
  2073 + }
  2074 + return rs;
  2075 + }
  2076 +
  2077 + @Override
  2078 + public List<Map<String, Object>> yesterdayDataList(String line) {
  2079 + // TODO Auto-generated method stub
  2080 + return null;
  2081 + }
1022 2082  
1023 2083 @Override
1024   - public Map<String, Object> findRouteByLine(String lineCode) {
1025   - Map<String, Object> map = new HashMap<>();
1026   - //上行
1027   - Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);
1028   - map.put("line.id_eq", lineId);
1029   - map.put("directions_eq", 0);
1030   - List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);
1031   -
1032   - //下行
1033   - map.put("directions_eq", 1);
1034   - List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);
1035   -
1036   - Map<String, Object> rs = new HashMap<>();
1037   -
1038   - String upVectors = "", vec;
1039   - //拼接上行路段
1040   - for(Map<String, Object> temp : upList){
1041   - vec = temp.get("sectionBsectionVector").toString();
1042   - upVectors += vec.subSequence(11, vec.length() - 2) + " ";
1043   - }
1044   -
1045   - //拼接下行路段
1046   - String downVectors = "";
1047   - for(Map<String, Object> temp : downList){//LINESTRING(
1048   - vec = temp.get("sectionBsectionVector").toString();
1049   - downVectors += vec.subSequence(11, vec.length() - 2) + " ";
1050   - }
1051   -
1052   -
1053   - rs.put("up", upVectors);
1054   - //上行gcj
1055   - rs.put("up_gcj", BdToGcjString(upVectors));
1056   - rs.put("down", downVectors);
1057   - //下行gcj
1058   - rs.put("down_gcj", BdToGcjString(downVectors));
1059   - rs.put("lineId", lineId);
1060   -
1061   - return rs;
1062   - }
1063   -
1064   - /**
1065   - *
1066   - * @Title: BdToGcjString
1067   - * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)
1068   - * @param @param bdStr
1069   - * @throws
1070   - */
1071   - public String BdToGcjString(String bdStr){
1072   - String[] array = bdStr.split(",")
1073   - ,subArray;
1074   - if(array.length == 0 || bdStr.length() < 2)
1075   - return "";
1076   -
1077   - String gcjStr = "";
1078   - TransGPS.Location location;
1079   - for(String crd : array){
1080   - subArray = crd.split(" ");
1081   - if(subArray.length != 2)
1082   - continue;
1083   - location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));
1084   -
1085   - gcjStr += location.getLng() + " " + location.getLat() + ",";
1086   - }
  2084 + public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) {
  2085 + // TODO Auto-generated method stub
  2086 + ReportUtils ee = new ReportUtils();
  2087 + ReportRelatedUtils rru = new ReportRelatedUtils();
  2088 + List<Iterator<?>> list = new ArrayList<Iterator<?>>();
  2089 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2( clZbh,date,line);
  2090 + List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
1087 2091  
1088   - return gcjStr.substring(0, gcjStr.length() - 1);
1089   - }
1090   - public List<Map<String, String>> findLine(String line) {
1091   - List<Line> listLine = lineRepository.findLine("%"+line+"%");
1092   - List<Map<String,String>> list = new ArrayList<Map<String,String>>();
1093   - Map<String,String> map;
1094   - for(Line temp:listLine){
1095   - if(temp != null){
1096   - String xlName = temp.getName();
1097   - if(xlName.indexOf(line) != -1){
1098   - map = new HashMap<String, String>();
1099   - map.put("id", temp.getLineCode());
1100   - map.put("text", xlName);
1101   - list.add(map);
1102   - }
1103   - }
1104   - }
1105   - return list;
1106   - }
1107   -
1108   - public List<Map<String, String>> findLpName(String lpName) {
1109   - List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%"+lpName+"%");
1110   - List<Map<String,String>> list = new ArrayList<Map<String,String>>();
1111   - Map<String,String> map;
1112   - for(GuideboardInfo temp:listLpName){
1113   - if(temp != null){
1114   - String lp = temp.getLpName();
1115   - if(lp.indexOf(lpName) != -1){
1116   - map = new HashMap<String, String>();
1117   - map.put("id", lp);
1118   - map.put("text", lp);
1119   - list.add(map);
1120   - }
1121   - }
1122   - }
1123   - return list;
1124   - }
1125   -
1126   - @Override
1127   - public Map<String, Object> findKMBC2(String jName, String clZbh,String date) {
1128   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh , date);
1129   -
1130 2092 DecimalFormat format = new DecimalFormat("0.00");
1131 2093 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1132 2094 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
1133 2095 int jhbc = 0,cjbc = 0,ljbc = 0;
1134   - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;
  2096 + double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0,jcclc=0;
1135 2097 float addMileage = 0l,remMileage = 0l;
1136   - String j_Name="";
1137   - Map<String,Object> map = new HashMap<String, Object>();
1138   - for(ScheduleRealInfo scheduleRealInfo : list){
  2098 +
  2099 + Map<String,Object> map;
  2100 + for(ScheduleRealInfo scheduleRealInfo : scheduleRealInfos){
1139 2101 if(scheduleRealInfo != null){
1140   - j_Name=scheduleRealInfo.getjName();
1141   - //计划里程(主任务过滤掉临加班次),
1142   - //烂班里程(主任务烂班),
1143   - //临加里程(主任务临加),
1144   - //计划班次,烂班班次,增加班次
1145   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1146   - if(scheduleRealInfo.isSflj()){
1147   - addMileage += tempJhlc;
1148   - ljbc++;
1149   - }else{
1150   - jhlc += tempJhlc;
1151   - jhbc++;
1152   - if(scheduleRealInfo.getStatus() == -1){
1153   - remMileage += tempJhlc;
1154   - cjbc++;
1155   - }
1156   - }
1157   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1158   - //计算营运里程,空驶里程
1159   - if(childTaskPlans.isEmpty()){
1160   - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
1161   - || scheduleRealInfo.getBcType().equals("venting")){
1162   - ksgl += tempJhlc;
  2102 + //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次
  2103 + //计划里程(主任务过滤掉临加班次),
  2104 + //烂班里程(主任务烂班),
  2105 + //临加里程(主任务临加),
  2106 + //计划班次,烂班班次,增加班次
  2107 + tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  2108 + if(scheduleRealInfo.isSflj()){
  2109 + ljbc++;
1163 2110 }else{
1164   - yygl += tempJhlc;
1165   - }
1166   - }else{
1167   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1168   - while(it.hasNext()){
1169   - ChildTaskPlan childTaskPlan = it.next();
1170   - if(childTaskPlan.getMileageType().equals("empty")){
1171   - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  2111 + jhlc += tempJhlc;
  2112 + jhbc++;
  2113 + if(scheduleRealInfo.getStatus() == -1){
  2114 + remMileage += tempJhlc;
  2115 + cjbc++;
  2116 + }
  2117 + }
  2118 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  2119 + //计算营运里程,空驶里程
  2120 + if(childTaskPlans.isEmpty()){
  2121 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  2122 + || scheduleRealInfo.getBcType().equals("venting")){
  2123 + ksgl += tempJhlc;
1172 2124 }else{
1173   - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  2125 + yygl += tempJhlc;
  2126 + }
  2127 + }else{
  2128 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  2129 + while(it.hasNext()){
  2130 + ChildTaskPlan childTaskPlan = it.next();
  2131 + if(childTaskPlan.getMileageType().equals("empty")){
  2132 + if(scheduleRealInfo.isSflj()){
  2133 + addMileage += tempJhlc;
  2134 + }
  2135 + ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  2136 + }else{
  2137 + if(scheduleRealInfo.isSflj()){
  2138 + addMileage += tempJhlc;
  2139 + }
  2140 + yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  2141 + }
1174 2142 }
1175 2143 }
1176   - }
  2144 +
  2145 + if(!(scheduleRealInfo.getBcType().equals("in")||scheduleRealInfo.getBcType().equals("out"))){
  2146 + map = new HashMap<String, Object>();
  2147 + try {
  2148 + map = rru.getMapValue(scheduleRealInfo);
  2149 + String zdsj = scheduleRealInfo.getZdsj();
  2150 + String zdsjActual = scheduleRealInfo.getZdsjActual();
  2151 + if(zdsj != null && zdsjActual != null &&
  2152 + !zdsj.equals(zdsjActual)){
  2153 + if(zdsj.compareTo(zdsjActual) > 0){
  2154 + map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  2155 + map.put("slow", "");
  2156 + } else {
  2157 + map.put("fast", "");
  2158 + map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  2159 + }
  2160 + } else {
  2161 + map.put("fast", "");
  2162 + map.put("slow", "");
  2163 + }
  2164 + listMap.add(map);
  2165 + } catch (Exception e) {
  2166 + e.printStackTrace();
  2167 + }
  2168 + }
1177 2169 }
1178 2170 }
1179   - map.put("j_name", j_Name);
1180   - map.put("jhlc", format.format(jhlc));
1181   - map.put("remMileage", format.format(remMileage));
1182   - map.put("addMileage", format.format(addMileage));
1183   - map.put("yygl", format.format(yygl));
  2171 +
  2172 + //计算里程和班次数,并放入Map里
  2173 + map = new HashMap<String, Object>();
  2174 + map.put("jhlc", format.format(jhlc+jcclc));
  2175 + map.put("yygljh", format.format(jhlc));
  2176 + map.put("ssgl", format.format(remMileage));
1184 2177 map.put("ksgl", format.format(ksgl));
1185   - map.put("realMileage", format.format(yygl+ksgl));
  2178 + map.put("yyglsj", format.format(yygl+remMileage));
1186 2179 map.put("jhbc", jhbc);
1187   - map.put("cjbc", cjbc);
1188   - map.put("ljbc", ljbc);
  2180 + map.put("jcclc", jcclc);
  2181 +
  2182 + map.put("ljgl", format.format(addMileage));
  2183 + map.put("ssbc", cjbc);
  2184 + map.put("ysgl", format.format(yygl));
1189 2185 map.put("sjbc", jhbc-cjbc+ljbc);
1190   - return map;
  2186 + map.put("zgl", format.format(yygl+remMileage+ksgl+jcclc));
  2187 + map.put("ljbc", ljbc);
  2188 +
  2189 + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
  2190 +
  2191 + list.add(listMap.iterator());
  2192 + ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould\\waybill_qingpu.xls",
  2193 + path+"export\\" + date+"-"+clZbh+"-行车路单.xls");
  2194 + return scheduleRealInfos;
1191 2195 }
1192   -
1193   -
  2196 +
1194 2197 @Override
1195   - public Map<String, Object> findKMBC(String jName, String clZbh,
1196   - String lpName,String date) {
1197   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date);
  2198 + public Map<String, Object> findKMBCQp(String clZbh, String date, String line) {
  2199 + // TODO Auto-generated method stub
  2200 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill2( clZbh,date,line);
1198 2201 DecimalFormat format = new DecimalFormat("0.00");
1199 2202 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1200 2203 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
... ... @@ -1210,7 +2213,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1210 2213 //计划班次,烂班班次,增加班次
1211 2214 tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1212 2215 if(scheduleRealInfo.isSflj()){
1213   - addMileage += tempJhlc;
1214 2216 ljbc++;
1215 2217 }else{
1216 2218 if( !(scheduleRealInfo.getBcType().equals("in")
... ... @@ -1231,12 +2233,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1231 2233 scheduleRealInfo.getBcType().equals("out")){
1232 2234 jcclc +=tempJhlc;
1233 2235 }
  2236 +
1234 2237 //主任务 放空班次属于营运
1235 2238 // else if(scheduleRealInfo.getBcType().equals("venting")){
1236 2239 // ksgl += tempJhlc;
1237 2240 // }
1238 2241 else{
1239 2242 if(scheduleRealInfo.getStatus() != -1){
  2243 + if(scheduleRealInfo.isSflj()){
  2244 + addMileage += tempJhlc;
  2245 + }
1240 2246 yygl += tempJhlc;
1241 2247 }
1242 2248 }
... ... @@ -1248,6 +2254,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1248 2254 if(childTaskPlan.isDestroy()){
1249 2255 remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1250 2256 }else{
  2257 + if(scheduleRealInfo.isSflj()){
  2258 + addMileage += tempJhlc;
  2259 + }
1251 2260 ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1252 2261 }
1253 2262 }else{
... ... @@ -1255,6 +2264,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1255 2264 remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1256 2265 // cjbc++;
1257 2266 }else{
  2267 + if(scheduleRealInfo.isSflj()){
  2268 + addMileage += tempJhlc;
  2269 + }
1258 2270 yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1259 2271 }
1260 2272 }
... ... @@ -1262,143 +2274,32 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1262 2274 }
1263 2275 }
1264 2276 }
1265   - map.put("jhlc", format.format(jhlc));
1266   - map.put("remMileage", format.format(remMileage));
1267   - map.put("addMileage", format.format(addMileage));
1268   - map.put("yygl", format.format(yygl));
  2277 + map.put("jhlc", format.format(jhlc+jcclc));
  2278 + map.put("yygljh", format.format(jhlc));
  2279 + map.put("ssgl", format.format(remMileage));
1269 2280 map.put("ksgl", format.format(ksgl));
1270   - map.put("realMileage", format.format(yygl+ksgl+jcclc));
  2281 + map.put("yyglsj", format.format(yygl+remMileage));
1271 2282 map.put("jhbc", jhbc);
1272   - map.put("cjbc", cjbc);
1273   - map.put("ljbc", ljbc);
1274   - map.put("sjbc", jhbc-cjbc+ljbc);
1275 2283 map.put("jcclc", jcclc);
1276   - map.put("zkslc", format.format(ksgl+jcclc));
1277   - return map;
1278   - }
1279   -
1280   - @Override
1281   - public List<Map<String, Object>> account(String line, String date,
1282   - String code,String xlName, String type) {
1283   - List<Object[]> lsitObj = scheduleRealInfoRepository.account(line,date,code);
1284   - List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
1285   - Map<String,Object> map;
1286   - int i = 1;
1287   - for(Object[] obj : lsitObj){
1288   - if(obj != null){
1289   - map = new HashMap<String,Object>();
1290   - map.put("num", i++);
1291   - map.put("xlName", xlName);
1292   - map.put("clZbh", obj[3]);
1293   - map.put("company", obj[0]);
1294   - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1]+"")).toUpperCase());
1295   - map.put("requestTime", obj[2]);
1296   - listMap.add(map);
1297   - }
1298   - }
1299   -
1300   - if(type != null && type.length() != 0 && type.equals("export")){
1301   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
1302   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
1303   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
1304   - Map<String,Object> m = new HashMap<String, Object>();
1305   - ReportUtils ee = new ReportUtils();
1306   - Map<String, Object> typeMap = new HashMap<String, Object>();
1307   - typeMap.put("0xA1", "请求恢复运营");
1308   - typeMap.put("0xA2", "申请调档");
1309   - typeMap.put("0xA3", "出场请求");
1310   - typeMap.put("0xA5", "进场请求");
1311   - typeMap.put("0xA7", "加油请求");
1312   - typeMap.put("0x50", "车辆故障");
1313   - typeMap.put("0x70", "路阻报告");
1314   - typeMap.put("0x60", "事故报告");
1315   - typeMap.put("0x11", "扣证纠纷");
1316   - typeMap.put("0x12", "报警");
1317   - for(Map<String, Object> map1 : listMap){
1318   - map1.put("requestText", typeMap.get(map1.get("requestType")));
1319   - }
1320   - try {
1321   - listI.add(listMap.iterator());
1322   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
1323   - ee.excelReplace(listI, new Object[] { m }, path+"mould\\account.xls",
1324   - path+"export\\驾驶员请求台账" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
1325   - } catch (Exception e) {
1326   - // TODO: handle exception
1327   - e.printStackTrace();
1328   - }
1329   - }
1330   -
1331   - return listMap;
1332   - }
1333   -
1334   - @Override
1335   - public List<ScheduleRealInfo> correctForm(String line, String startDate,
1336   - String endDate, String lpName, String code, String type) {
1337   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.correctForm(line,startDate,endDate,lpName,code);
1338 2284  
1339   - if(type != null && type.length() != 0 && type.equals("export")){
1340   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
1341   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
1342   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
1343   - Map<String,Object> m = new HashMap<String, Object>();
1344   - ReportUtils ee = new ReportUtils();
1345   - m.put("dates", startDate + " 至 " + endDate);
1346   - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
1347   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
1348   - for(ScheduleRealInfo schedule : list){
1349   - Map<String, Object> tempMap = new HashMap<String, Object>();
1350   - tempMap.put("xlName", schedule.getXlName()!=null?schedule.getXlName():"");
1351   - tempMap.put("lpName", schedule.getLpName()!=null?schedule.getLpName():"");
1352   - tempMap.put("clZbh", schedule.getClZbh()!=null?schedule.getClZbh():"");
1353   - tempMap.put("jName", schedule.getjName()!=null?schedule.getjName():"");
1354   - tempMap.put("sName", schedule.getsName()!=null?schedule.getsName():"");
1355   - tempMap.put("fcsj", schedule.getFcsj()!=null?schedule.getFcsj():"");
1356   - tempMap.put("fcsjActual", schedule.getFcsjActual()!=null?schedule.getFcsjActual():"");
1357   - tempMap.put("zdsj", schedule.getZdsj()!=null?schedule.getZdsj():"");
1358   - tempMap.put("zdsjActual", schedule.getZdsjActual()!=null?schedule.getZdsjActual():"");
1359   - if(schedule.getUpdateBy() != null){
1360   - if(schedule.getUpdateBy().getName() != null)
1361   - tempMap.put("userName", schedule.getUpdateBy().getName());
1362   - else
1363   - tempMap.put("userName", "");
1364   - } else {
1365   - tempMap.put("userName", "");
1366   - }
1367   - if(schedule.getUpdateDate() != null){
1368   - tempMap.put("updateDate", sdf.format(schedule.getUpdateDate()));
1369   - } else {
1370   - tempMap.put("updateDate", "");
1371   - }
1372   - tempMap.put("remarks", schedule.getRemarks()!=null?schedule.getRemarks():"");
1373   - tempList.add(tempMap);
1374   - }
1375   - try {
1376   - listI.add(tempList.iterator());
1377   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
1378   - ee.excelReplace(listI, new Object[] { m }, path+"mould\\correctForm.xls",
1379   - path+"export\\修正报表" + sdfSimple.format(sdfMonth.parse(startDate)) + "-" + sdfSimple.format(sdfMonth.parse(endDate)) + ".xls");
1380   - } catch (Exception e) {
1381   - // TODO: handle exception
1382   - e.printStackTrace();
1383   - }
1384   - Map<String, Object> map = tempList.get(tempList.size() - 1);
1385   - System.out.println("tempMap:" + map);
1386   - }
1387   -
1388   - return list;
  2285 + map.put("ljgl", format.format(addMileage));
  2286 + map.put("ssbc", cjbc);
  2287 + map.put("ysgl", format.format(yygl));
  2288 + map.put("sjbc", jhbc-cjbc+ljbc);
  2289 + map.put("zgl", format.format(yygl+remMileage+ksgl+jcclc));
  2290 + map.put("ljbc", ljbc);
  2291 + return map;
1389 2292 }
1390 2293  
1391 2294 @Override
1392   - public List<ScheduleRealInfo> queryListWaybill(String jName, String clZbh,
1393   - String lpName,String date,String type) {
  2295 + public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) {
  2296 + // TODO Auto-generated method stub
1394 2297 List <ScheduleRealInfo> list=null;
1395   - if(type.equals("qp")){
1396   - list= scheduleRealInfoRepository.queryListWaybill2(jName,clZbh,lpName,date);
1397   - }else{
1398   - list= scheduleRealInfoRepository.queryListWaybill(jName,clZbh,lpName,date);
1399   - }
1400   - for (int i = 0; i < list.size(); i++) {
1401   - ScheduleRealInfo s=list.get(i);
  2298 + list= scheduleRealInfoRepository.queryListWaybill2(clZbh,date,line);
  2299 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  2300 + for (int i = 0; i < list.size(); i++) {
  2301 + ScheduleRealInfo s=list.get(i);
  2302 + if(!(s.getBcType().equals("in")||s.getBcType().equals("out"))){
1402 2303 String remarks="";
1403 2304 if(s.getRemarks()!=null){
1404 2305 remarks +=s.getRemarks();
... ... @@ -1415,703 +2316,61 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1415 2316 }
1416 2317 }
1417 2318 s.setRemarks(remarks);
  2319 + newList.add(s);
1418 2320 }
1419 2321  
1420   - return list;
1421   - }
1422   -
1423   - @Override
1424   - public Map<String, Object> removeChildTask(Long taskId) {
1425   - Map<String, Object> rs = new HashMap<>();
1426   - ChildTaskPlan chTask = cTaskPlanRepository.findOne(taskId);
1427   -
1428   - ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());
1429   - try {
1430   -
1431   - sch.getcTasks().remove(chTask);
1432   - scheduleRealInfoRepository.save(sch);
1433   - rs.put("status", ResponseCode.SUCCESS);
1434   - } catch (Exception e) {
1435   - logger.error("", e);
1436   - rs.put("status", ResponseCode.ERROR);
1437   - }
1438   - return rs;
1439   - }
1440   -
1441   - @Override
1442   - public List<Map<String, Object>> statisticsDaily(String line, String date,
1443   - String xlName) {
1444   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1445   - List<Map<String,Object>> lMap = new ArrayList<Map<String,Object>>();
1446   - DecimalFormat format = new DecimalFormat("0.00");
1447   - double jhlc = 0, tempJhlc = 0,childMileage = 0;
1448   - float sjgl = 0f,ssgl = 0f,ssgl_lz = 0f,ssgl_dm = 0f,ssgl_gz = 0f,ssgl_jf = 0f,ssgl_zs = 0f,ssgl_qr = 0f
1449   - ,ssgl_qc = 0f,ssgl_kx = 0f,ssgl_qh = 0f,ssgl_yw = 0f,ssgl_other = 0f,ljgl = 0f;
1450   - //班次
1451   - int sj_0 = 6*60+31,sj_1 = 8*60+30,sj_2 = 16*60+1,sj_3 = 18*60;
1452   - int jhbc = 0,jhbc_m = 0,jhbc_a = 0;
1453   - int sjbc = 0,sjbc_m = 0,sjbc_a = 0;
1454   - int ljbc = 0,ljbc_m = 0,ljbc_a = 0;
1455   - int fzbc = 0,fzbc_m = 0,fzbc_a = 0;
1456   - int dtbc = 0,dtbc_m = 0,dtbc_a = 0;
1457   - int djg = 0,djg_m = 0,djg_a = 0,djg_time = 0;
1458   - Map<String,Object> map = new HashMap<String, Object>();
1459   - for(ScheduleRealInfo scheduleRealInfo: list){
1460   - if(scheduleRealInfo != null){
1461   -
1462   - if(!(scheduleRealInfo.getBcType().equals("in")
1463   - ||scheduleRealInfo.getBcType().equals("out")) ){
1464   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1465   - //计算实际里程,少驶里程,计划里程=实际里程+少驶里程
1466   - if(childTaskPlans.isEmpty()){
1467   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1468   - //临加公里
1469   - if(scheduleRealInfo.isSflj()){
1470   - ljgl += tempJhlc;
1471   - }else{
1472   - jhlc += tempJhlc;
1473   - }
1474   - if(scheduleRealInfo.getStatus() == 2){
1475   - sjgl += tempJhlc;
1476   - }else if(scheduleRealInfo.getStatus() == -1){
1477   - ssgl += tempJhlc;
1478   - if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("路阻") != -1){
1479   - ssgl_lz += tempJhlc;
1480   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("吊慢") != -1){
1481   - ssgl_dm += tempJhlc;
1482   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("故障") != -1){
1483   - ssgl_gz += tempJhlc;
1484   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("纠纷") != -1){
1485   - ssgl_jf += tempJhlc;
1486   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("肇事") != -1){
1487   - ssgl_zs += tempJhlc;
1488   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺人") != -1){
1489   - ssgl_qr += tempJhlc;
1490   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺车") != -1){
1491   - ssgl_qc += tempJhlc;
1492   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("客稀") != -1){
1493   - ssgl_kx += tempJhlc;
1494   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("气候") != -1){
1495   - ssgl_qh += tempJhlc;
1496   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("援外") != -1){
1497   - ssgl_yw += tempJhlc;
1498   - }else{
1499   - ssgl_other += tempJhlc;
1500   - }
1501   - }
1502   - }else{
1503   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1504   - while(it.hasNext()){
1505   - ChildTaskPlan childTaskPlan = it.next();
1506   - childMileage = childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1507   - jhlc += childMileage;
1508   - if(childTaskPlan.isDestroy()){
1509   - ssgl += childMileage;
1510   - if(childTaskPlan.getDestroyReason().equals("路阻")){
1511   - ssgl_lz += childTaskPlan.getMileage();
1512   - }else if(childTaskPlan.getDestroyReason().equals("吊慢")){
1513   - ssgl_dm += childTaskPlan.getMileage();
1514   - }else if(childTaskPlan.getDestroyReason().equals("故障")){
1515   - ssgl_gz += childTaskPlan.getMileage();
1516   - }else if(childTaskPlan.getDestroyReason().equals("纠纷")){
1517   - ssgl_jf += childTaskPlan.getMileage();
1518   - }else if(childTaskPlan.getDestroyReason().equals("肇事")){
1519   - ssgl_zs += childTaskPlan.getMileage();
1520   - }else if(childTaskPlan.getDestroyReason().equals("缺人")){
1521   - ssgl_qr += childTaskPlan.getMileage();
1522   - }else if(childTaskPlan.getDestroyReason().equals("缺车")){
1523   - ssgl_qc += childTaskPlan.getMileage();
1524   - }else if(childTaskPlan.getDestroyReason().equals("客稀")){
1525   - ssgl_kx += childTaskPlan.getMileage();
1526   - }else if(childTaskPlan.getDestroyReason().equals("气候")){
1527   - ssgl_qh += childTaskPlan.getMileage();
1528   - }else if(childTaskPlan.getDestroyReason().equals("援外")){
1529   - ssgl_yw += childTaskPlan.getMileage();
1530   - }else{
1531   - ssgl_other += childTaskPlan.getMileage();
1532   - }
1533   - }else{
1534   - sjgl += childMileage;
1535   - }
1536   - }
1537   - }
1538   -
1539   - //班次
1540   - jhbc++;
1541   - String[] fcsj = scheduleRealInfo.getFcsj().split(":");
1542   - String[] fcsjActual = (scheduleRealInfo.getFcsjActual()==null?"0:00":scheduleRealInfo.getFcsjActual()).split(":");
1543   - if((Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) > sj_0 && (Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) < sj_1){
1544   - jhbc_m++;
1545   - }else if((Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) > sj_2 && (Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) < sj_3){
1546   - jhbc_a++;
1547   - }
1548   - if(scheduleRealInfo.getStatus() == 2){
1549   - sjbc++;
1550   - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){
1551   - sjbc_m++;
1552   - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){
1553   - sjbc_a++;
1554   - }
1555   - }
1556   - if(scheduleRealInfo.isSflj()){
1557   - ljbc++;
1558   - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){
1559   - ljbc_m++;
1560   - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){
1561   - ljbc_a++;
1562   - }
1563   - }
1564   - if(scheduleRealInfo.getBcType().equals("venting")){
1565   - fzbc++;
1566   - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){
1567   - fzbc_m++;
1568   - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){
1569   - fzbc_a++;
1570   - }
1571   - }
1572   - }
1573   - }
1574   - }
1575   - map.put("xlName", xlName);
1576   - map.put("jhlc", format.format(jhlc));
1577   - map.put("sjgl", format.format(sjgl));
1578   - map.put("ssgl", format.format(ssgl));
1579   - map.put("ssgl_lz", ssgl_lz==0?0:format.format(ssgl_lz));
1580   - map.put("ssgl_dm", ssgl_dm==0?0:format.format(ssgl_dm));
1581   - map.put("ssgl_gz", ssgl_gz==0?0:format.format(ssgl_gz));
1582   - map.put("ssgl_jf", ssgl_jf==0?0:format.format(ssgl_jf));
1583   - map.put("ssgl_zs", ssgl_zs==0?0:format.format(ssgl_zs));
1584   - map.put("ssgl_qr", ssgl_qr==0?0:format.format(ssgl_qr));
1585   - map.put("ssgl_qc", ssgl_qc==0?0:format.format(ssgl_qc));
1586   - map.put("ssgl_kx", ssgl_kx==0?0:format.format(ssgl_kx));
1587   - map.put("ssgl_qh", ssgl_qh==0?0:format.format(ssgl_qh));
1588   - map.put("ssgl_yw", ssgl_yw==0?0:format.format(ssgl_yw));
1589   - map.put("ssgl_other", ssgl_other==0?0:format.format(ssgl_other));
1590   - map.put("ljgl", ljgl==0?0:format.format(ljgl));
1591   - map.put("jhbc", jhbc);
1592   - map.put("jhbc_m", jhbc_m);
1593   - map.put("jhbc_a", jhbc_a);
1594   - map.put("sjbc", sjbc);
1595   - map.put("sjbc_m", sjbc_m);
1596   - map.put("sjbc_a", sjbc_a);
1597   - map.put("ljbc", ljbc);
1598   - map.put("ljbc_m", ljbc_m);
1599   - map.put("ljbc_a", ljbc_a);
1600   - map.put("fzbc", fzbc);
1601   - map.put("fzbc_m", fzbc_m);
1602   - map.put("fzbc_a", fzbc_a);
1603   - map.put("dtbc", dtbc);
1604   - map.put("dtbc_m", dtbc_m);
1605   - map.put("dtbc_a", dtbc_a);
1606   - map.put("djg", djg);
1607   - map.put("djg_m", djg_m);
1608   - map.put("djg_a", djg_a);
1609   - map.put("djg_time", djg_time);
1610   - lMap.add(map);
1611   - return lMap;
1612 2322 }
1613 2323  
1614   - @Override
1615   - public Map<String,Object> scheduleDaily(String line, String date) {
1616   - Map<String,String> tempMap = null;
1617   - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1618   - Map<String, Object> map = new HashMap<String, Object>();
1619   - Double jhlc = 0.00;
1620   - Float sjgl = 0f,ssgl = 0f,ssgl_lz = 0f,ssgl_dm = 0f,ssgl_gz = 0f,ssgl_jf = 0f,ssgl_zs = 0f,ssgl_qr = 0f
1621   - ,ssgl_qc = 0f,ssgl_kx = 0f,ssgl_qh = 0f,ssgl_yw = 0f,ssgl_other = 0f,ljgl = 0f;
1622   - int jhbc = 0;
1623   - for(ScheduleRealInfo scheduleRealInfo:scheduleRealInfos){
1624   - if(scheduleRealInfo != null){
1625   - //计算里程(包括子任务)
1626   - jhlc += scheduleRealInfo.getJhlc();
1627   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1628   - if(!childTaskPlans.isEmpty()){
1629   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1630   - while(it.hasNext()){
1631   - ChildTaskPlan childTaskPlan = it.next();
1632   - //是否烂班,烂班就是少驶
1633   - if(!childTaskPlan.isDestroy()){
1634   - sjgl += childTaskPlan.getMileage();
1635   - }else{
1636   - ssgl += childTaskPlan.getMileage();
1637   - if(childTaskPlan.getDestroyReason().equals("路阻")){
1638   - ssgl_lz += childTaskPlan.getMileage();
1639   - }else if(childTaskPlan.getDestroyReason().equals("吊慢")){
1640   - ssgl_dm += childTaskPlan.getMileage();
1641   - }else if(childTaskPlan.getDestroyReason().equals("故障")){
1642   - ssgl_gz += childTaskPlan.getMileage();
1643   - }else if(childTaskPlan.getDestroyReason().equals("纠纷")){
1644   - ssgl_jf += childTaskPlan.getMileage();
1645   - }else if(childTaskPlan.getDestroyReason().equals("肇事")){
1646   - ssgl_zs += childTaskPlan.getMileage();
1647   - }else if(childTaskPlan.getDestroyReason().equals("缺人")){
1648   - ssgl_qr += childTaskPlan.getMileage();
1649   - }else if(childTaskPlan.getDestroyReason().equals("缺车")){
1650   - ssgl_qc += childTaskPlan.getMileage();
1651   - }else if(childTaskPlan.getDestroyReason().equals("客稀")){
1652   - ssgl_kx += childTaskPlan.getMileage();
1653   - }else if(childTaskPlan.getDestroyReason().equals("气候")){
1654   - ssgl_qh += childTaskPlan.getMileage();
1655   - }else if(childTaskPlan.getDestroyReason().equals("援外")){
1656   - ssgl_yw += childTaskPlan.getMileage();
1657   - }else{
1658   - ssgl_other += childTaskPlan.getMileage();
1659   - }
1660   - }
1661   - //临加公里
1662   - if(childTaskPlan.getType1().equals("临加")){
1663   - ljgl += childTaskPlan.getMileage();
1664   - }
1665   - }
1666   - }
1667   - //班次
1668   - scheduleRealInfo.getFcsjT();
1669   - scheduleRealInfo.getFcsjActualTime();
1670   - }
1671   - }
1672   - map.put("jhlc", jhlc);
1673   - map.put("sjgl", sjgl);
1674   - map.put("ssgl", ssgl);
1675   - map.put("ssgl_lz", ssgl_lz);
1676   - map.put("ssgl_dm", ssgl_dm);
1677   - map.put("ssgl_gz", ssgl_gz);
1678   - map.put("ssgl_jf", ssgl_jf);
1679   - map.put("ssgl_zs", ssgl_zs);
1680   - map.put("ssgl_qr", ssgl_qr);
1681   - map.put("ssgl_qc", ssgl_qc);
1682   - map.put("ssgl_kx", ssgl_kx);
1683   - map.put("ssgl_qh", ssgl_qh);
1684   - map.put("ssgl_yw", ssgl_yw);
1685   - map.put("ssgl_other", ssgl_other);
1686   - map.put("ljgl", ljgl);
1687   -
1688   - map.put("jhbc", scheduleRealInfos.size());
1689   - return null;
1690   - }
1691   -
1692   - @Override
1693   - public int countByLineCodeAndDate(String xlBm, String schDate) {
1694   - return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);
1695   - }
1696   -
1697   - @Override
1698   - public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {
1699   - return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);
1700   - }
1701   -
1702   - @Override
1703   - public void deleteByLineCodeAndDate(String xlBm, String schDate) {
1704   - scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);
1705   - }
1706   -
1707   - @Override
1708   - public Long getMaxId() {
1709   - return scheduleRealInfoRepository.getMaxId();
  2324 + return newList;
1710 2325 }
1711 2326  
1712 2327 @Override
1713   - public List<ScheduleRealInfo> realScheduleList(String line, String date) {
1714   - /*List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.queryUserInfo(line, date);
1715   - List<ScheduleRealInfo> listTotal = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1716   - for(ScheduleRealInfo info:listInfo){
1717   - for(ScheduleRealInfo total:listTotal){
1718   - if(info.getjGh().equals(total.getjGh()) && info.getLpName().equals(total.getLpName()) && info.getClZbh().equals(total.getClZbh())){
1719   -
1720   - }
1721   - }
1722   - }*/
1723   - return scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1724   - }
1725   -
1726   -
1727   - public List<Map<String,Object>> yesterdayDataList(String line,String date) {
1728   - //前一天日期
1729   -// String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
1730   -// String date = "2016-09-20";
1731   - List<Map<String,Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date);
1732   -// List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1733   - for(int x=0;x<yesterdayDataList.size();x++){
1734   - String jName=yesterdayDataList.get(x).get("jGh").toString();
1735   - String clZbh=yesterdayDataList.get(x).get("clZbh").toString();
1736   - List<ScheduleRealInfo> lists=scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date);
1737   - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0,jcclc=0;
1738   - float addMileage = 0l,remMileage = 0l;
1739   - Map<String,Object> map = new HashMap<String, Object>();
1740   - boolean fage=true;
1741   - for(ScheduleRealInfo scheduleRealInfo : lists){
1742   - if(fage){
1743   - //根据线路代码获取公司
1744   - Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
1745   - yesterdayDataList.get(x).put("company", li.getCompany());
1746   - yesterdayDataList.get(x).put("bCompany", li.getBrancheCompany());
1747   - fage=false;
1748   - }
1749   - if(scheduleRealInfo != null){
1750   - //计划里程(主任务过滤掉临加班次),
1751   - //烂班里程(主任务烂班),
1752   - //临加里程(主任务临加),
1753   - //计划班次,烂班班次,增加班次
1754   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1755   - if(scheduleRealInfo.isSflj()){
1756   - addMileage += tempJhlc;
1757   - }else{
1758   - if( !(scheduleRealInfo.getBcType().equals("in")
1759   - ||scheduleRealInfo.getBcType().equals("out")) ){
1760   - jhlc += tempJhlc;
1761   - }
1762   -
1763   - if(scheduleRealInfo.getStatus() == -1){
1764   - remMileage += tempJhlc;
1765   - }
1766   - }
1767   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1768   - //计算营运里程,空驶里程
1769   - if(childTaskPlans.isEmpty()){
1770   - if(scheduleRealInfo.getBcType().equals("in") ||
1771   - scheduleRealInfo.getBcType().equals("out")){
1772   - jcclc +=tempJhlc;
1773   - }
1774   - //主任务 放空班次属于营运
1775   -// else if(scheduleRealInfo.getBcType().equals("venting")){
1776   -// ksgl += tempJhlc;
1777   -// }
1778   - else{
1779   - if(scheduleRealInfo.getStatus() != -1){
1780   - yygl += tempJhlc;
1781   - }
1782   - }
1783   - }else{
1784   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1785   - while(it.hasNext()){
1786   - ChildTaskPlan childTaskPlan = it.next();
1787   - if(childTaskPlan.getMileageType().equals("empty")){
1788   - if(childTaskPlan.isDestroy()){
1789   - remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1790   - }else{
1791   - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1792   - }
1793   - }else{
1794   - if(childTaskPlan.isDestroy()){
1795   - remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1796   - }else{
1797   - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1798   - }
  2328 + public Map<String, Object> MapById(Long id) {
  2329 + // TODO Auto-generated method stub
  2330 + Map<String, Object> map=new HashMap<String, Object>();
  2331 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
  2332 + ScheduleRealInfo s=scheduleRealInfoRepository.findOne(id);
  2333 + String xlbm=s.getXlBm();
  2334 + String fcrq=s.getScheduleDateStr();
  2335 +
  2336 +
  2337 + map.put("xlName", s.getXlName());
  2338 + map.put("clZbh", s.getClZbh());
  2339 + map.put("fcsjActual", s.getFcsjActual());
  2340 + map.put("zdzName", s.getZdzName());
  2341 + map.put("scheduleDate", s.getScheduleDateStr());
  2342 + String zdp="",zwdp="",wdp="";
  2343 +
  2344 + List<DutyEmployee> list= dutyEmployeeService.getDutyEmployee(xlbm, fcrq+"00:00", fcrq+"23:59");
  2345 + try {
  2346 + Long fcsj1=sdf.parse(fcrq+" 03:00").getTime();
  2347 + Long fcsj2=sdf.parse(fcrq+" 11:00").getTime();
  2348 + Long fcsj3=sdf.parse(fcrq+" 22:00").getTime();
  2349 + for(int i=0;i<list.size();i++){
  2350 + DutyEmployee t=list.get(i);
  2351 + Long ts=t.getTs();
  2352 + if(ts>fcsj1&&ts<fcsj2){
  2353 + if(zdp.indexOf(t.getuName())==-1){
  2354 + zdp +=t.getuName()+",";
1799 2355 }
1800   - }
1801   - }
1802   - }
1803   - }
1804   -
1805   - yesterdayDataList.get(x).put("totalKilometers", yygl+ksgl+jcclc);
1806   -
1807   - }
1808   -
1809   - /* for(ScheduleRealInfo scheduleRealInfo:list){
1810   - if(scheduleRealInfo != null){
1811   - for(int i=0;i<yesterdayDataList.size();i++){
1812   - if(scheduleRealInfo.getXlBm().equals(yesterdayDataList.get(i).get("xlBm")) && scheduleRealInfo.getClZbh().equals(yesterdayDataList.get(i).get("clZbh"))
1813   - && scheduleRealInfo.getjGh().equals(yesterdayDataList.get(i).get("jGh"))){
1814   - //根据线路代码获取公司
1815   - Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
1816   - yesterdayDataList.get(i).put("company", li.getCompany());
1817   - yesterdayDataList.get(i).put("bCompany", li.getBrancheCompany());
1818   - //计算总公里
1819   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1820   - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
1821   - if(childTaskPlans.isEmpty()){
1822   - if(scheduleRealInfo.getStatus() == 2){
1823   - yesterdayDataList.get(i).put("totalKilometers", scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers")));
  2356 + }else if(ts>fcsj2 && ts<fcsj3){
  2357 + if(zwdp.indexOf(t.getuName())==-1){
  2358 + zwdp +=t.getuName()+",";
1824 2359 }
1825 2360 }else{
1826   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1827   - while(it.hasNext()){
1828   - ChildTaskPlan childTaskPlan = it.next();
1829   - if(!childTaskPlan.isDestroy()){
1830   - yesterdayDataList.get(i).put("totalKilometers", childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage()+(double)(yesterdayDataList.get(i).get("totalKilometers")==null?0.0:yesterdayDataList.get(i).get("totalKilometers")));
1831   - }
  2361 + if(wdp.indexOf(t.getuName())==-1){
  2362 + wdp +=t.getuName()+",";
1832 2363 }
1833 2364 }
1834   - }
1835   - }
1836   - }
1837   - }*/
1838   - //增加顺序号
1839   - for(int i=0;i<yesterdayDataList.size();i++){
1840   - if(i == 0){
1841   - yesterdayDataList.get(i).put("seqNumber", 1);
1842   - }else{
1843   - if(yesterdayDataList.get(i-1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))){
1844   - yesterdayDataList.get(i).put("seqNumber", 1+(int)yesterdayDataList.get(i-1).get("seqNumber"));
1845   - }else{
1846   - yesterdayDataList.get(i).put("seqNumber", 1);
1847   - }
1848   - }
1849   - }
1850   - return yesterdayDataList;
1851   - }
1852   -
1853   - /**
1854   - * 批量调整人车
1855   - */
1856   - @Override
1857   - public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs) {
1858   - Map<String, Object> rs = new HashMap<>();
1859   - Set<ScheduleRealInfo> set = new HashSet<>();
1860   -
1861   - ScheduleRealInfo sch;
1862   -
1863   - for(ChangePersonCar cpc : cpcs){
1864   -
1865   - sch = dayOfSchedule.get(cpc.getSchId());
1866   - if(sch==null)
1867   - continue;
1868   -
1869   - if(StringUtils.isNotEmpty(cpc.getJsy())){
1870   - //换驾驶员
1871   - persoChange(sch, cpc.getJsy().split("/")[0]);
1872   - }
1873   -
1874   - //换售票员
1875   - if(StringUtils.isNotEmpty(cpc.getSpy())){
1876   - persoChangeSPY(sch, cpc.getSpy().split("/")[0]);
1877   - }
1878   -
1879   - //换车
1880   - if(StringUtils.isNotEmpty(cpc.getClZbh())){
1881   - set.add(sch);
1882   - set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));
1883   - }
1884   -
1885   - }
1886   - rs.put("ts", set);
1887   - rs.put("status", ResponseCode.SUCCESS);
1888   - return rs;
1889   - }
1890   -
1891   - /**
1892   - *
1893   - * @Title: persoChange
1894   - * @Description: TODO(班次换驾驶员)
1895   - */
1896   - public void persoChange(ScheduleRealInfo sch, String jGh){
1897   - if(sch.getjGh().equals(jGh))
1898   - return;
1899   - String jName = BasicData.allPerson.get(jGh);
1900   - if(StringUtils.isNotEmpty(jName)){
1901   - sch.setjGh(jGh);
1902   - sch.setjName(jName);
1903   - }
1904   - }
1905   -
1906   - /**
1907   - *
1908   - * @Title: persoChange
1909   - * @Description: TODO(班次换售票员)
1910   - */
1911   - public void persoChangeSPY(ScheduleRealInfo sch, String sGh){
1912   - if(sch.getsGh().equals(sGh))
1913   - return;
1914   - String sName = BasicData.allPerson.get(sGh);
1915   - if(StringUtils.isNotEmpty(sName)){
1916   - sch.setsGh(sGh);
1917   - sch.setsName(sName);
1918   - }
1919   - }
1920   -
1921   - /**
1922   - * 批量待发调整
1923   - */
1924   - @Override
1925   - public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {
1926   - Map<String, Object> rs = new HashMap<>()
1927   - ,tempMap = new HashMap<>();
1928   - List<ScheduleRealInfo> list = new ArrayList<>();
1929   -
1930   - ScheduleRealInfo sch,next;
1931   - for(DfsjChange dc : dfsjcs){
1932   - if(StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))
1933   - continue;
1934   -
1935   - /*sch = dayOfSchedule.get(dc.getSchId());
1936   - if(sch==null)
1937   - continue;
1938   -
1939   - sch.setDfsjAll(dc.getNew_dfsj());
1940   - //重新计算终点时间
1941   - sch.calcEndTime();
1942   - list.add(sch);*/
1943   - tempMap = outgoAdjust(dc.getSchId(),"", dc.getNew_dfsj());
1944   -
1945   - if(tempMap.get("status").equals(ResponseCode.SUCCESS)){
1946   - list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));
1947   - }
1948   - //next=dayOfSchedule.next(sch);
1949   - /*if(next.getQdzName().equals(sch.getZdzName())){
1950   - next.setQdzArrDateJH(sch.getZdsj());
1951   - list.add(next);
1952   - }*/
1953   - }
1954   -
1955   - rs.put("status", ResponseCode.SUCCESS);
1956   - rs.put("ts", list);
1957   - return rs;
1958   - }
1959   -
1960   -
1961   - @Override
1962   - public Map<String, Object> findKMBC1(String jName, String clZbh,
1963   - String date, String enddate) {
1964   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);
1965   - DecimalFormat format = new DecimalFormat("0.00");
1966   -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1967   -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
1968   - int jhbc = 0,cjbc = 0,ljbc = 0;
1969   - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;
1970   - float addMileage = 0l,remMileage = 0l;
1971   - Map<String,Object> map = new HashMap<String, Object>();
1972   - for(ScheduleRealInfo scheduleRealInfo : list){
1973   - if(scheduleRealInfo != null){
1974   - //计划里程(主任务过滤掉临加班次),
1975   - //烂班里程(主任务烂班),
1976   - //临加里程(主任务临加),
1977   - //计划班次,烂班班次,增加班次
1978   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1979   - if(scheduleRealInfo.isSflj()){
1980   - addMileage += tempJhlc;
1981   - ljbc++;
1982   - }else{
1983   - jhlc += tempJhlc;
1984   - jhbc++;
1985   - if(scheduleRealInfo.getStatus() == -1){
1986   - remMileage += tempJhlc;
1987   - cjbc++;
1988   - }
1989   - }
1990   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1991   - //计算营运里程,空驶里程
1992   - if(childTaskPlans.isEmpty()){
1993   - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
1994   - || scheduleRealInfo.getBcType().equals("venting")){
1995   - ksgl += tempJhlc;
1996   - }else{
1997   - yygl += tempJhlc;
1998   - }
1999   - }else{
2000   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
2001   - while(it.hasNext()){
2002   - ChildTaskPlan childTaskPlan = it.next();
2003   - if(childTaskPlan.getMileageType().equals("empty")){
2004   - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
2005   - }else{
2006   - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
2007   - }
2008 2365 }
  2366 + } catch (ParseException e) {
  2367 + // TODO Auto-generated catch block
  2368 + e.printStackTrace();
2009 2369 }
2010   - }
2011   - }
2012   - map.put("jhlc", format.format(jhlc));
2013   - map.put("remMileage", format.format(remMileage));
2014   - map.put("addMileage", format.format(addMileage));
2015   - map.put("yygl", format.format(yygl));
2016   - map.put("ksgl", format.format(ksgl));
2017   - map.put("realMileage", format.format(yygl+ksgl));
2018   - map.put("jhbc", jhbc);
2019   - map.put("cjbc", cjbc);
2020   - map.put("ljbc", ljbc);
2021   - map.put("sjbc", jhbc-cjbc+ljbc);
2022   - return map;
2023   - }
2024   -
2025   - /**
2026   - * 调整班次类型
2027   - * @param id
2028   - * @param bcType
2029   - * @param remarks
2030   - * @return
2031   - */
2032   - @Override
2033   - public Map<String, Object> changeBcType(Long id, String bcType, String remarks) {
2034   - Map<String, Object> rs = new HashMap<>();
2035   -
2036   - try {
2037   - ScheduleRealInfo sch = dayOfSchedule.get(id);
2038   - if(sch != null){
2039   - sch.setBcType(bcType);
2040   - sch.addRemarks(remarks);
2041   - //有时间记录一下相关变更数据
2042   - rs.put("status", ResponseCode.SUCCESS);
2043   - rs.put("t", sch);
2044   - }
2045   - } catch (Exception e) {
2046   - logger.error("", e);
2047   - rs.put("status", ResponseCode.ERROR);
2048   - }
2049   -
2050   - return rs;
2051   - }
2052   -
2053   - @Override
2054   - public Map<String, Object> historySave(ScheduleRealInfo sch) {
2055   - Map<String, Object> rs = new HashMap<>();
2056   - rs.put("status", ResponseCode.ERROR);
2057   -
2058   - ScheduleRealInfo oldSch = super.findById(sch.getId());
2059   - //修改车辆
2060   - if(!oldSch.getClZbh().equals(sch.getClZbh())){
2061   - Set<String> allCar=BasicData.deviceId2NbbmMap.values();
2062   - if(!allCar.contains(sch.getClZbh())){
2063   - rs.put("msg", "无效的车辆自编号");
2064   - return rs;
2065   - }
2066   - else
2067   - oldSch.setClZbh(sch.getClZbh());
2068   - }
2069   -
2070   - //修改驾驶员
2071   - if(!oldSch.getjGh().equals(sch.getjGh())){
2072   - Map<String, String> allPer = BasicData.allPerson;
2073   - if(!allPer.containsKey(sch.getjGh())){
2074   - rs.put("msg", "无效的驾驶员");
2075   - return rs;
2076   - }
2077   - else{
2078   - oldSch.setjGh(sch.getjGh());
2079   - oldSch.setjName(allPer.get(oldSch.getjGh()));
2080   - }
2081   - }
2082   -
2083   - //修改售票员
2084   -/* if(!oldSch.getsGh().equals(sch.getsGh())){
2085   - Map<String, String> allPer = BasicData.allPerson;
2086   -
2087   - if(StringUtils.isNotEmpty(sch.getsGh())){
2088   - if(!allPer.containsKey(sch.getsGh())){
2089   - rs.put("msg", "无效的售票员");
2090   - return rs;
2091   - }
2092   - }
2093   - oldSch.setsGh(sch.getsGh());
2094   - oldSch.setsName(allPer.get(oldSch.getsGh()));
2095   - }*/
2096   -
2097   - //待发时间
2098   - oldSch.setDfsj(sch.getDfsj());
2099   - //实发时间
2100   - oldSch.setFcsjActual(sch.getFcsjActual());
2101   - //实际终点
2102   - oldSch.setZdsjActual(sch.getZdsjActual());
2103   - //备注
2104   - oldSch.setRemarks(sch.getRemarks());
2105   -
2106   - scheduleRealInfoRepository.save(oldSch);
2107   - rs.put("status", ResponseCode.SUCCESS);
2108   - return rs;
2109   - }
2110   -
2111   - @Override
2112   - public List<Map<String, Object>> yesterdayDataList(String line) {
2113   - // TODO Auto-generated method stub
2114   - return null;
  2370 + map.put("zdp", zdp);
  2371 + map.put("zwdp", zwdp);
  2372 + map.put("wdp", wdp);
  2373 + return map;
2115 2374 }
2116 2375  
2117   -}
  2376 +}
2118 2377 \ No newline at end of file
... ...