Commit b79f715f009f9111b195b6fca7c90a111115107b

Authored by 廖磊
2 parents 4f3f73e8 90164ff0

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

minhang

# Conflicts:
#	src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
#	src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
Showing 23 changed files with 2414 additions and 2099 deletions

Too many changes to show.

To preserve performance only 23 of 49 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
... ... @@ -443,4 +408,14 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
443 408 }
444 409 return rs;
445 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 + }
446 421 }
... ...
src/main/java/com/bsth/data/BasicData.java
... ... @@ -261,26 +261,26 @@ public class BasicData implements CommandLineRunner {
261 261 /**
262 262 * 加载运管处的站点及序号
263 263 * 上行从1开始,下行顺序续编
264   -
265   - List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc();
266   - if(ygcLines != null && ygcLines.size() > 0){
267   - int size = ygcLines.size();
268   - Object[] tempArray ;
269   - int num = 1;
270   - String key;
271   - String lineCode = "";
272   - for (int i = 0; i < size; i ++){
273   - tempArray = ygcLines.get(i);
274   - if(lineCode.equals("")){
275   - lineCode = tempArray[0]+"";
276   - }else if(!lineCode.equals(tempArray[0]+"")){
277   - num = 1;
278   - lineCode = tempArray[0]+"";
279   - }
280   - key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2];
281   - tempStationName2YgcNumber.put(key,num++);
282   - }
283   - }*/
  264 + */
  265 + List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc();
  266 + if(ygcLines != null && ygcLines.size() > 0){
  267 + int size = ygcLines.size();
  268 + Object[] tempArray ;
  269 + int num = 1;
  270 + String key;
  271 + String lineCode = "";
  272 + for (int i = 0; i < size; i ++){
  273 + tempArray = ygcLines.get(i);
  274 + if(lineCode.equals("")){
  275 + lineCode = tempArray[0]+"";
  276 + }else if(!lineCode.equals(tempArray[0]+"")){
  277 + num = 1;
  278 + lineCode = tempArray[0]+"";
  279 + }
  280 + key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2];
  281 + tempStationName2YgcNumber.put(key,num++);
  282 + }
  283 + }
284 284 }
285 285  
286 286 lineId2CodeMap = biMap;
... ...
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/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/impl/TrafficManageServiceImpl.java
... ... @@ -390,36 +390,44 @@ public class TrafficManageServiceImpl implements TrafficManageService{
390 390 Map<String,Object> map = new HashMap<String,Object>();
391 391 for(Map<String,Object> schRealInfo:listGroup){
392 392 if(schRealInfo != null){
  393 + map.put("insideCode_eq", schRealInfo.get("clZbh")+"");
  394 + Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map));
  395 + /**
  396 + * 如果car==null,则说明该车辆是从线调中换车功能中加进去的,
  397 + * 在cars基础信息中查不到车辆的信息,所以忽略该车辆
  398 + */
  399 + if(car == null){
  400 + continue;
  401 + }
393 402 //计算总公里和空驶公里,营运公里=总公里-空驶公里
394 403 double totalKilometers = 0,emptyKilometers =0;
395 404 sf.append("<LCYH>");
396   - map.put("insideCode_eq", schRealInfo.get("clZbh")+"");
397   - Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map));
398   -// Cars car = carsRepository.findCarByClzbh(schRealInfo.getClZbh());
399 405 sf.append("<RQ>"+date+"</RQ>");
400 406 sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>");
401 407 sf.append("<CPH>"+car.getCarPlate()+"</CPH>");
402   - for(ScheduleRealInfo scheduleRealInfo:list){
403   - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"")
404   - .equals(scheduleRealInfo.getClZbh())){
405   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
406   - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
407   - if(childTaskPlans.isEmpty()){
408   - if(scheduleRealInfo.getStatus() == 2){
409   - totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
410   - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
411   - || scheduleRealInfo.getBcType().equals("venting")){
412   - emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
  408 + if(list != null && list.size() > 0){
  409 + for(ScheduleRealInfo scheduleRealInfo:list){
  410 + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"")
  411 + .equals(scheduleRealInfo.getClZbh())){
  412 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  413 + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
  414 + if(childTaskPlans.isEmpty()){
  415 + if(scheduleRealInfo.getStatus() == 2){
  416 + totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
  417 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  418 + || scheduleRealInfo.getBcType().equals("venting")){
  419 + emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();
  420 + }
413 421 }
414   - }
415   - }else{
416   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
417   - while(it.hasNext()){
418   - ChildTaskPlan childTaskPlan = it.next();
419   - if(!childTaskPlan.isDestroy()){
420   - totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();
421   - if(childTaskPlan.getMileageType().equals("empty")){
422   - emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();;
  422 + }else{
  423 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  424 + while(it.hasNext()){
  425 + ChildTaskPlan childTaskPlan = it.next();
  426 + if(!childTaskPlan.isDestroy()){
  427 + totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();
  428 + if(childTaskPlan.getMileageType().equals("empty")){
  429 + emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();;
  430 + }
423 431 }
424 432 }
425 433 }
... ... @@ -604,8 +612,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{
604 612 schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getQdzName())).append("</ZDXH>");
605 613 sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>");
606 614 sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>");
607   - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(
608   - schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getZdzName())).append("</ZDXH>");
  615 + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(
  616 + schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getZdzName())).append("</DDXH>");
609 617 sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj()))
610 618 .append("</JHDDSJ>");
611 619 sBuffer.append("</BC>");
... ...
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  
... ... @@ -134,9 +134,10 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
134 134 Map<String,Object> changeBcType(Long id, String bcType, String remarks);
135 135  
136 136 Map<String,Object> historySave(ScheduleRealInfo sch);
137   -
138 137  
139 138 Map<String, Object> MapById(Long id) ;
140 139  
141   -
  140 + Map<String,Object> svgAttr(String jsonStr);
  141 +
  142 + Map<String,Object> findSvgAttr(String idx);
142 143 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -18,6 +18,7 @@ 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;
... ... @@ -26,6 +27,7 @@ import com.bsth.entity.sys.SysUser;
26 27 import com.bsth.repository.LineRepository;
27 28 import com.bsth.repository.realcontrol.ChildTaskPlanRepository;
28 29 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  30 +import com.bsth.repository.realcontrol.SvgAttributeRepository;
29 31 import com.bsth.repository.schedule.CarConfigInfoRepository;
30 32 import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
31 33 import com.bsth.repository.schedule.GuideboardInfoRepository;
... ... @@ -38,18 +40,18 @@ import com.bsth.util.*;
38 40 import com.bsth.websocket.handler.SendUtils;
39 41 import com.google.common.base.Splitter;
40 42 import com.google.common.collect.ArrayListMultimap;
  43 +import com.google.common.collect.BiMap;
41 44 import com.google.common.collect.Lists;
42 45 import com.google.common.collect.Multimap;
  46 +import org.apache.commons.lang3.StringEscapeUtils;
43 47 import org.apache.commons.lang3.StringUtils;
44 48 import org.joda.time.format.DateTimeFormat;
45 49 import org.joda.time.format.DateTimeFormatter;
46   -import org.pentaho.di.core.logging.ChannelLogTable.ID;
47 50 import org.slf4j.Logger;
48 51 import org.slf4j.LoggerFactory;
49 52 import org.springframework.beans.factory.annotation.Autowired;
50 53 import org.springframework.stereotype.Service;
51 54  
52   -import java.net.URLEncoder;
53 55 import java.text.DecimalFormat;
54 56 import java.text.ParseException;
55 57 import java.text.SimpleDateFormat;
... ... @@ -57,429 +59,385 @@ import java.util.*;
57 59  
58 60 @Service
59 61 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long>
60   - implements ScheduleRealInfoService {
  62 + implements ScheduleRealInfoService {
61 63  
62   - @Autowired
63   - ScheduleRealInfoRepository scheduleRealInfoRepository;
  64 + @Autowired
  65 + ScheduleRealInfoRepository scheduleRealInfoRepository;
64 66  
65   - @Autowired
66   - EmployeeConfigInfoRepository employeeConfigInfoRepository;
  67 + @Autowired
  68 + EmployeeConfigInfoRepository employeeConfigInfoRepository;
67 69  
68   - @Autowired
69   - CarConfigInfoRepository carConfigInfoRepository;
70   -
71   - @Autowired
72   - SectionRouteService sectionRouteService;
73   -
74   - @Autowired
75   - DutyEmployeeService dutyEmployeeService;
76   -
77   - /*@Autowired
78   - BorrowCenter borrowCenter;*/
79   -
80   - @Autowired
81   - LineRepository lineRepository;
82   -
83   - @Autowired
84   - GuideboardInfoRepository guideboardInfoRepository;
85   -
86   - @Autowired
87   - ChildTaskPlanRepository cTaskPlanRepository;
88   -
89   - @Autowired
90   - SendUtils sendUtils;
91   -
92   - @Autowired
93   - DayOfSchedule dayOfSchedule;
94   -
95   - @Autowired
96   - SchAttrCalculator schAttrCalculator;
97   -
98   - @Autowired
99   - LineConfigData lineConfigData;
100   -
101   - Logger logger = LoggerFactory.getLogger(this.getClass());
102   -
103   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
104   - sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"),
105   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
106   -
107   - @Override
108   - public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {
109   - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));
110   -
111   - Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();
112   -
113   - for (String lineCode : lineList) {
114   - mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode));
115   - }
116   - return mMap.asMap();
117   - }
118   -
119   - private final static long DAY_TIME = 1000 * 60 * 60 * 24L;
120   - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
121   - @Override
122   - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj/*, String nbbm,String jsy,String spy*/) {
123   - Map<String, Object> map = new HashMap<>();
124   - try {
125   -
126   - ScheduleRealInfo schedule = dayOfSchedule.get(id);
127   -
128   -
129   - LineConfig config = lineConfigData.get(schedule.getXlBm());
130   - //小于线路开始运营时间,则默认跨过24点
131   - if(dfsj.compareTo(config.getStartOpt()) < 0){
132   - schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME));
133   - }
134   - else {
135   - schedule.setRealExecDate(schedule.getScheduleDateStr());
136   - }
137   -
138   - schedule.setDfsjAll(dfsj);
139   - schedule.addRemarks(remarks);
140   -
141   - List<ScheduleRealInfo> ts = new ArrayList<>();
142   - ts.add(schedule);
143   - //调整终点时间和下一个班次的应到时间
144   - schedule.calcEndTime();
145   - ScheduleRealInfo nextSch = dayOfSchedule.next(schedule);
146   - if(null != nextSch){
147   - nextSch.setQdzArrDateJH(schedule.getZdsj());
148   - ts.add(nextSch);
149   - }
150   -
151   - // 持久化到数据库
152   - dayOfSchedule.save(schedule);
153   -
154   - map.put("status", ResponseCode.SUCCESS);
155   - map.put("ts", ts);
156   - } catch (Exception e) {
157   - logger.error("", e);
158   - map.put("status", ResponseCode.ERROR);
159   - }
160   - return map;
161   - }
162   -
163   - @Override
164   - public Map<String, Object> destroy(String idsStr, /*int spaceAdjust, */String remarks, String reason/*, int spaceNum*/) {
165   -
166   - Map<String, Object> map = new HashMap<>();
167   - List<ScheduleRealInfo> rsList = new ArrayList<>();
168   - map.put("ts", rsList);
169   - try {
170   - List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr));
171   -
172   - ScheduleRealInfo schedule = null;
173   - for (String id : idList) {
174   - schedule = dayOfSchedule.get(Long.parseLong(id));
175   - if(schedule.isDestroy()){
176   - map.put("status", ResponseCode.ERROR);
177   - map.put("msg", "不必要的重复烂班!");
178   - return map;
179   - }
180   -
181   - schedule.setAdjustExps(reason);
182   - schedule.destroy();
183   - schedule.addRemarks(remarks);
184   -
185   - dayOfSchedule.save(schedule);
186   - rsList.add(schedule);
187   - }
188   -
189   - map.put("status", ResponseCode.SUCCESS);
190   - } catch (Exception e) {
191   - logger.error("", e);
192   - map.put("status", ResponseCode.ERROR);
193   - }
194   - return map;
195   - }
196   -
197   - // 线路id获取驾驶员
198   - @Override
199   - public List<Map<String, String>> findDriverByLine(String lineCode) {
200   - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
201   -
202   - List<Map<String, String>> rsList = new ArrayList<>();
203   - Map<String, String> map = null;
204   - Personnel driver = null;
205   - String code = null;
206   -
207   - for (EmployeeConfigInfo employee : list) {
208   - driver = employee.getJsy();
209   - if (driver != null) {
210   - map = new HashMap<>();
211   - code = driver.getJobCode();
212   - map.put("id", code + "/" + driver.getPersonnelName());
213   - map.put("text", code + "/" + driver.getPersonnelName());
214   - rsList.add(map);
215   - }
216   - }
217   - return rsList;
218   - }
219   -
220   - // 线路id获取售票员
221   - @Override
222   - public List<Map<String, String>> findConductorByLine(String lineCode) {
223   - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode);
224   -
225   - List<Map<String, String>> rsList = new ArrayList<>();
226   - Map<String, String> map = null;
227   - Personnel conductor = null;
228   - String code = null;
229   -
230   - for (EmployeeConfigInfo employee : list) {
231   - conductor = employee.getSpy();
232   - if (conductor != null) {
233   - code = conductor.getJobCode();
234   - map = new HashMap<>();
235   - map.put("id", code + "/" + conductor.getPersonnelName());
236   - map.put("text", code + "/" + conductor.getPersonnelName());
237   - rsList.add(map);
238   - }
239   - }
240   - return rsList;
241   - }
242   -
243   - @Override
244   - public List<Map<String, String>> findCarByLine(String lineCode) {
245   -
246   - List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode);
247   -
248   - List<Map<String, String>> rsList = new ArrayList<>();
249   - Map<String, String> map = null;
250   - Cars car = null;
251   - String code = null;
252   -
253   - for (CarConfigInfo cci : list) {
254   - car = cci.getCl();
255   - if (car != null) {
256   - code = car.getInsideCode();
257   - map = new HashMap<>();
258   - map.put("id", code);
259   - map.put("text", code);
260   - rsList.add(map);
261   - }
262   - }
263   - return rsList;
264   - }
265   -
266   -
267   - /**
268   - * 临加班次
269   - */
270   - @Override
271   - public Map<String, Object> save(ScheduleRealInfo t) {
272   - Map<String, Object> rs = new HashMap<>();
273   - try{
274   - SysUser user = SecurityUtils.getCurrentUser();
275   - String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());
276   -
277   - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd")
278   - ,sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");
279   -
280   - if(StringUtils.isEmpty(t.getjGh())){
281   - rs.put("status", ResponseCode.ERROR);
282   - rs.put("msg", "驾驶员工号不能为空!");
283   - return rs;
284   - }
285   - //截取工号
286   - if(t.getjGh().indexOf("-") != -1){
287   - t.setjGh(t.getjGh().split("-")[1]);
288   - }
289   -
290   - t.setScheduleDateStr(schDate);
291   - t.setScheduleDate(sdfyyyyMMdd.parse(schDate));
292   - t.setRealExecDate(schDate);
293   - t.setCreateBy(user);
294   - t.setSflj(true);
295   - t.setLate(false);
296   - t.setDfsj(t.getFcsj());
297   - t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime());
298   -
299   -
300   - //班次历时
301   - t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60);
302   -
303   - //起终点名称
304   - String prefix = t.getXlBm() + "_" + t.getXlDir() + "_";
305   - t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));
306   - t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));
307   -
308   - //计算班次实际时间
309   - schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);
310   - if(t.getZdsjT() < t.getFcsjT()){
311   - rs.put("status", ResponseCode.ERROR);
312   - rs.put("msg", "起终点时间异常!");
313   - return rs;
314   - }
315   -
316   - //实时入库
317   - super.save(t);
318   -
319   - // 加入缓存
320   - dayOfSchedule.put(t);
321   -
322   - //更新起点应到时间
323   - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t.getClZbh());
324   -
325   -
326   - rs.put("ts", ts);
327   - rs.put("t", t);
328   - }catch(Exception e){
329   - logger.error("", e);
330   - rs.put("status", ResponseCode.ERROR);
331   - }
332   - return rs;
333   - }
334   -
335   - @Override
336   - public Map<String, Object> delete(Long id) {
337   - Map<String, Object> rs = new HashMap<>();
338   - rs.put("status", ResponseCode.ERROR);
339   -
340   - ScheduleRealInfo sch = dayOfSchedule.get(id);
341   - if(sch == null){
342   - rs.put("msg", "无效的id号");
343   - return rs;
344   - }
345   -
346   - if(!sch.isSflj()){
347   - rs.put("msg", "你只能删除临加班次");
348   - return rs;
349   - }
350   -
351   - dayOfSchedule.delete(sch);
352   - //ScheduleRealInfo sch = dayOfSchedule.delete(id);
353   - //数据库删除
354   - rs = super.delete(id);
355   - //更新起点应到时间
356   - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch.getClZbh());
357   - rs.put("ts", ts);
358   - rs.put("delete", sch);
359   -
360   - return rs;
361   - }
362   -
363   - @Override
364   - public List<Map<String, String>> sreachVehic(String nbbm) {
365   - // 转大写
366   - nbbm = nbbm.toUpperCase();
367   -
368   - List<Map<String, String>> list = new ArrayList<>();
369   - Map<String, String> map;
370   - Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
371   -
372   - Line line;
373   - for (String k : allSet) {
374   - if (k.indexOf(nbbm) != -1) {
375   - // 所属线路
376   - map = new HashMap<>();
377   - line = BasicData.nbbm2LineMap.get(k);
378   - map.put("id", k);
379   - map.put("text", k);
380   - if (null != line) {
381   - map.put("lineName", line.getName());
382   - map.put("lineCode", line.getLineCode());
383   - }
384   -
385   - list.add(map);
386   - }
387   -
388   - if (list.size() > 20)
389   - break;
390   - }
391   - return list;
392   - }
  70 + @Autowired
  71 + CarConfigInfoRepository carConfigInfoRepository;
393 72  
394   -/* @Override
395   - public Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) {
396   - // 班次
397   - ScheduleRealInfo schedule = dayOfSchedule.get(id);
398   - int upDown = Integer.parseInt(schedule.getXlDir());
  73 + @Autowired
  74 + SectionRouteService sectionRouteService;
399 75  
400   - String rq = sdfMonth.format(new Date());
401   - // 换车
402   - if (!StringUtils.isBlank(nbbm)) {
403   - adjustCar(schedule, nbbm);
404   - }
405   -
406   - List<String> tempArray;
407   - // 换驾驶员
408   - if (!StringUtils.isBlank(jsy)) {
409   - tempArray = Splitter.on("/").splitToList(jsy);
410   - adjustDriver(schedule, tempArray.get(0), tempArray.get(1));
411   - }
412   -
413   - // 换售票员
414   - if (!StringUtils.isBlank(spy)) {
415   - tempArray = Splitter.on("/").splitToList(spy);
416   - adjustConductor(schedule, tempArray.get(0), tempArray.get(1));
417   - }
418   -
419   - if(borrowLine != null && borrowTimeStr != null){
420   - try {
421   - //跨线路借车
422   - Long t = sdfMinute.parse(rq + " " + borrowTimeStr).getTime();
423   - //borrowCenter.put(nbbm, borrowLine, 0, t, upDown);
424   - } catch (ParseException e) {
425   - e.printStackTrace();
426   - }
427   - }
428   -
429   - if(revertLine != null && revertTimeStr != null){
430   - //定时还车
431   - try {
432   - Long t = sdfMinute.parse(rq + " " + revertTimeStr).getTime();
433   - //还车的时候不用切走向
434   - //borrowCenter.put(nbbm, revertLine, 1, t, -1);
435   - } catch (ParseException e) {
436   - e.printStackTrace();
437   - }
438   - }
439   -
440   - scheduleRealInfoRepository.save(schedule);
441   - //ScheduleBuffer.persistentList.add(schedule);
442   -
443   - Map<String, Object> map = new HashMap<>();
444   - map.put("status", 200);
445   - map.put("t", schedule);
446   - return map;
447   - }*/
448   -
449   - @Override
450   - public void adjustCar(ScheduleRealInfo schedule, String car) {
451   - schedule.setClZbh(car);
452   - }
453   -
454   - @Override
455   - public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) {
456   - if(driver.indexOf("-") != -1)
457   - driver = driver.split("-")[1];
458   - schedule.setjGh(driver);
459   - schedule.setjName(driverName);
460   - }
461   -
462   - @Override
463   - public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) {
464   - if(conductor.indexOf("-") != -1)
465   - conductor = conductor.split("-")[1];
466   - schedule.setsGh(conductor);
467   - schedule.setsName(conductorName);
468   - }
  76 + /*@Autowired
  77 + BorrowCenter borrowCenter;*/
469 78  
470   - @Override
471   - public List<ScheduleRealInfo> queryUserInfo(String line, String date,String state) {
472   - if(state.equals("2")){
473   - return scheduleRealInfoRepository.queryUserInfo2(line, date);
474   - }else{
475   - return scheduleRealInfoRepository.queryUserInfo3(line, date);
476   - }
477   -
478   - }
479   - /**
480   - *
481   - */
482   - @Override
  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
483 441 public List<ScheduleRealInfo> exportWaybill(String jName, String clZbh, String lpName,String date,String line) {
484 442 ReportUtils ee = new ReportUtils();
485 443 ReportRelatedUtils rru = new ReportRelatedUtils();
... ... @@ -587,12 +545,1544 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
587 545 path+"export\\" + date+"-"+jName+"-"+clZbh+"-"+lpName+"-行车路单.xls");
588 546 return scheduleRealInfos;
589 547 }
590   -
591   - /**
592   - *
593   - */
  548 +
  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<>();
  680 + /*Integer code;
  681 + for (String lineCode : lineList) {
  682 + code = Integer.parseInt(lineCode);
  683 + if (!ScheduleBuffer.trustMap.containsKey(lineCode))
  684 + ScheduleBuffer.trustMap.put(code, 0);
  685 +
  686 + map.put(code, ScheduleBuffer.trustMap.get(code));
  687 + }*/
  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 + }
  1657 + }
  1658 + }*/
  1659 + return scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1660 + }
  1661 +
  1662 +
  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 + }
  1744 +
  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 + }
  1771 + }
  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);
  1884 +
  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 + }
  1894 +
  1895 + rs.put("status", ResponseCode.SUCCESS);
  1896 + rs.put("ts", list);
  1897 + return rs;
  1898 + }
  1899 +
  1900 +
  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 + }
  2082 +
594 2083 @Override
595   - public List<ScheduleRealInfo> exportWaybillQp( String clZbh,String date,String line) {
  2084 + public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) {
  2085 + // TODO Auto-generated method stub
596 2086 ReportUtils ee = new ReportUtils();
597 2087 ReportRelatedUtils rru = new ReportRelatedUtils();
598 2088 List<Iterator<?>> list = new ArrayList<Iterator<?>>();
... ... @@ -705,691 +2195,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
705 2195 }
706 2196  
707 2197 @Override
708   - public List<Map<String, Object>> dailyInfo(String line, String date,String type) {
709   - DecimalFormat format = new DecimalFormat("0.00");
710   - ReportUtils ee = new ReportUtils();
711   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
712   - List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);
713   -
714   - double totalZGL = 0,totalKSGL=0,totalYH=0;
715   - int totalBCS=0;
716   - for(int i = 0;i < list.size();i++){
717   - String zgl = format.format(Double.parseDouble(list.get(i).get("zgl")==null?"0":list.get(i).get("zgl").toString()));
718   - String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl")==null?"0":list.get(i).get("ksgl").toString()));
719   - if(type.equals("export")){
720   - totalZGL += Double.parseDouble(zgl);
721   - totalKSGL += Double.parseDouble(ksgl);
722   - totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());
723   - }
724   - list.get(i).put("zgl", zgl);
725   - list.get(i).put("ksgl", ksgl);
726   - }
727   - if(type.equals("export")){
728   - Map<String,Object> map = new HashMap<String, Object>();
729   - map.put("line", line);
730   - map.put("date", date);
731   - map.put("totalZGL", totalZGL);
732   - map.put("totalKSGL", totalKSGL);
733   - map.put("totalYH", totalYH);
734   - map.put("totalBCS", totalBCS);
735   -
736   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
737   -
738   - listI.add(list.iterator());
739   - try {
740   - ee.excelReplace(listI, new Object[] { map }, path+"mould\\daily.xls",
741   - path+"export\\班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
742   - } catch (ParseException e) {
743   - e.printStackTrace();
744   - }
745   - }
746   - return list;
747   - }
748   -
749   - @Override
750   - public List<Object[]> historyMessage(String line, String date, String code, String type) {
751   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
752   - long d= 0;
753   - long t=0;
754   - if(date.length()>0){
755   - try {
756   - d=sdf.parse(date+" 00:00:00").getTime();
757   - t=sdf.parse(date+" 23:59:59").getTime();
758   - } catch (ParseException e) {
759   - // TODO Auto-generated catch block
760   - e.printStackTrace();
761   - }
762   -
763   - }
764   -
765   - List<Object[]> list = scheduleRealInfoRepository.historyMessage(line,d,t, code);
766   - for(Object[] obj:list){
767   - if(obj != null){
768   - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
769   - obj[4] = BasicData.lineCode2NameMap.get(line);
770   - }
771   - }
772   -
773   - if(type != null && type.length() != 0 && type.equals("export")){
774   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
775   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
776   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
777   - Map<String,Object> m = new HashMap<String, Object>();
778   - ReportUtils ee = new ReportUtils();
779   - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
780   - for(int i = 0; i < list.size(); i++){
781   - Map<String, Object> map = new HashMap<String, Object>();
782   - Object[] obj = list.get(i);
783   - map.put("num", i + 1);
784   - map.put("line", obj[4]);
785   - map.put("clZbh", obj[0]);
786   - map.put("sender", obj[1]);
787   - map.put("date", obj[3]);
788   - map.put("text", obj[2]);
789   - newList.add(map);
790   - }
791   - try {
792   - listI.add(newList.iterator());
793   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
794   - ee.excelReplace(listI, new Object[] { m }, path+"mould\\historyMessage.xls",
795   - path+"export\\调度历史消息" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
796   - } catch (Exception e) {
797   - // TODO: handle exception
798   - e.printStackTrace();
799   - }
800   - }
801   -
802   - return list;
803   - }
804   -
805   - @Override
806   - public Map<Integer, Integer> trustStatus(String lineStr) {
807   - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr));
808   -
809   - Map<Integer, Integer> map = new HashMap<>();
810   - /*Integer code;
811   - for (String lineCode : lineList) {
812   - code = Integer.parseInt(lineCode);
813   - if (!ScheduleBuffer.trustMap.containsKey(lineCode))
814   - ScheduleBuffer.trustMap.put(code, 0);
815   -
816   - map.put(code, ScheduleBuffer.trustMap.get(code));
817   - }*/
818   - return map;
819   - }
820   -
821   - @Override
822   - public Map<String, Object> realOutAdjust(Long id, String fcsjActual, String remarks) {
823   - Map<String, Object> rs = new HashMap<>();
824   - List<ScheduleRealInfo> ts = new ArrayList<>();
825   - try {
826   - ScheduleRealInfo sch = dayOfSchedule.get(id);
827   -
828   - LineConfig config = lineConfigData.get(sch.getXlBm());
829   - //小于线路开始运营时间,则默认跨过24点
830   - if(fcsjActual.compareTo(config.getStartOpt()) < 0){
831   - sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME));
832   - }
833   - else {
834   - sch.setRealExecDate(sch.getScheduleDateStr());
835   - }
836   -
837   - sch.setFcsjActualAll(fcsjActual);
838   - sch.addRemarks(remarks);
839   - sch.calcStatus();
840   -
841   - dayOfSchedule.save(sch);
842   - //scheduleRealInfoRepository.save(sch);
843   -
844   - ts.add(sch);
845   -
846   - rs.put("status", ResponseCode.SUCCESS);
847   - rs.put("ts", ts);
848   -
849   - //通知页面刷新
850   - sendUtils.refreshSch(ts);
851   - } catch (Exception e) {
852   - logger.error("", e);
853   - rs.put("status", ResponseCode.ERROR);
854   - }
855   -
856   - return rs;
857   - }
858   -
859   - @Override
860   - public Map<String, Object> revokeDestroy(Long id) {
861   - Map<String, Object> rs = new HashMap<>();
862   - try {
863   - ScheduleRealInfo sch = dayOfSchedule.get(id);
864   - if (sch.getStatus() != -1) {
865   - rs.put("status", ResponseCode.ERROR);
866   - rs.put("msg", "未烂班,无法撤销!");
867   - } else {
868   - sch.setStatus(0);
869   - rs.put("status", ResponseCode.SUCCESS);
870   - rs.put("t", sch);
871   -
872   - }
873   - } catch (Exception e) {
874   - logger.error("", e);
875   - rs.put("status", ResponseCode.ERROR);
876   - }
877   - return rs;
878   - }
879   -
880   - @Override
881   - public Map<String, Object> revokeRealOutgo(Long id) {
882   - Map<String, Object> rs = new HashMap<>();
883   - List<ScheduleRealInfo> ts = new ArrayList<>();
884   -
885   - try {
886   - ScheduleRealInfo sch = dayOfSchedule.get(id);
887   - if (sch.getFcsjActual() == null) {
888   - rs.put("status", ResponseCode.ERROR);
889   - rs.put("msg", "无实发时间,无法撤销!");
890   - } else {
891   - //将对应的到离站数据标记为不可信
892   - List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());
893   - for(ArrivalEntity arr : list){
894   - if(arr.getInOut() == 1
895   - && arr.getUpDown() == Integer.parseInt(sch.getXlDir())
896   - && arr.getStopNo().equals(sch.getQdzCode())
897   - && Math.abs(arr.getTs() - sch.getFcsjActualTime()) < 1000 * 60){
898   - arr.setEnable(false);
899   - break;
900   - }
901   - }
902   -
903   - sch.clearFcsjActual();
904   - rs.put("status", ResponseCode.SUCCESS);
905   -
906   - ts.add(sch);
907   - rs.put("ts", ts);
908   -
909   - }
910   - } catch (Exception e) {
911   - logger.error("", e);
912   - rs.put("status", ResponseCode.ERROR);
913   - }
914   - return rs;
915   - }
916   -
917   - @Override
918   - public Map<String, Object> spaceAdjust(Long[] ids, Integer space) {
919   -
920   - List<ScheduleRealInfo> list = new ArrayList<>()
921   - ,updateList = new ArrayList<>();
922   - Map<String, Object> rs = new HashMap<>();
923   - try {
924   - ScheduleRealInfo sch, next;
925   - for (Long id : ids) {
926   - sch = dayOfSchedule.get(id);
927   - if (null != sch)
928   - list.add(sch);
929   - }
930   -
931   - int size = list.size();
932   - if(size == 0){
933   - rs.put("status", ResponseCode.ERROR);
934   - }
935   - else{
936   - // 按发车时间排序
937   - Collections.sort(list, new ScheduleComparator.FCSJ());
938   -
939   - // 以第一个实际发车/待发时间为起点,调整间隔
940   - sch = list.get(0);
941   - Long st = sch.getFcsjActualTime()==null?sch.getDfsjT():sch.getFcsjActualTime()
942   - ,plus = space * 60 * 1000L;
943   -
944   - for(int i = 1; i < size; i ++){
945   - st += plus;
946   - sch = list.get(i);
947   - sch.setDfsjAll(st);
948   - //重新计算终点时间
949   - sch.calcEndTime();
950   -
951   - dayOfSchedule.save(sch);
952   -
953   - updateList.add(sch);
954   - next=dayOfSchedule.next(sch);
955   - if(next.getQdzName().equals(sch.getZdzName())){
956   - next.setQdzArrDateJH(sch.getZdsj());
957   - updateList.add(next);
958   - }
959   - }
960   -
961   -
962   - rs.put("status", ResponseCode.SUCCESS);
963   - rs.put("ts", updateList);
964   - }
965   -
966   - } catch (Exception e) {
967   - logger.error("", e);
968   - rs.put("status", ResponseCode.ERROR);
969   - }
970   - return rs;
971   - }
972   -
973   - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
974   -
975   - @Override
976   - public Map<String, Object> schInfoFineTune(Map<String, String> map) {
977   - Map<String, Object> rs = new HashMap<>();
978   - List<ScheduleRealInfo> ts = new ArrayList<>();
979   - try {
980   - Long id = Long.parseLong(map.get("id"));
981   - //班次类型
982   - //String bcType = map.get("bcType");
983   - //车辆自编号
984   - //String clZbh = map.get("clZbh");
985   - //计划发车时间
986   - //String fcsj = map.get("fcsj");
987   - //实际发车时间
988   - String fcsjActual = map.get("fcsjActual");
989   -
990   - //实际终点时间
991   - String zdsjActual = map.get("zdsjActual");
992   - //备注
993   - String remarks = map.get("remarks");
994   -
995   - ScheduleRealInfo sch = dayOfSchedule.get(id);
996   - if(null != sch){
997   -// //驾驶员
998   -// if(StringUtils.isNotBlank(map.get("jsy"))){
999   -// String[] jsy = map.get("jsy").split("/");
1000   -// sch.setjGh(jsy[0]);
1001   -// sch.setjName(jsy[1]);
1002   -// }
1003   -
1004   - //售票员
1005   -// if(StringUtils.isNotBlank(map.get("spy"))){
1006   -// String[] spy = map.get("spy").split("/");
1007   -// sch.setsGh(spy[0]);
1008   -// sch.setsName(spy[1]);
1009   -// }
1010   -
1011   - //sch.setBcType(bcType);
1012   - //sch.setClZbh(clZbh);
1013   - //sch.setFcsjAll(fcsj);
1014   -
1015   - if(StringUtils.isNotBlank(fcsjActual)){
1016   - LineConfig config = lineConfigData.get(sch.getXlBm());
1017   - long t=0L;
1018   - //小于线路开始运营时间,则默认跨过24点
1019   - if(fcsjActual.compareTo(config.getStartOpt()) < 0)
1020   - t=fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)+fcsjActual);
1021   - else
1022   - t=fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr()+fcsjActual);
1023   -
1024   - //调整实发
1025   - if(!fcsjActual.equals(sch.getFcsjActual()))
1026   - sch.setFcsjActualAll(t);
1027   - }
1028   - else{
1029   - //撤销实发
1030   - if(sch.getFcsjActual() != null)
1031   - revokeRealOutgo(sch.getId());
1032   - }
1033   -
1034   - //实达时间
1035   - if(StringUtils.isNotBlank(zdsjActual)){
1036   - if(!zdsjActual.equals(sch.getZdsjActual())){
1037   - //调整实达
1038   - sch.setZdsjActualAll(zdsjActual);
1039   - //下一班次起点到达时间
1040   - ScheduleRealInfo next = dayOfSchedule.next(sch);
1041   - if(null != next){
1042   - next.setQdzArrDateSJ(zdsjActual);
1043   - ts.add(next);
1044   - }
1045   -
1046   - //重新计算车辆执行班次
1047   - dayOfSchedule.reCalcExecPlan(sch.getClZbh());
1048   - }
1049   - }
1050   - else {
1051   - /*if(sch.getZdsjActual() != null){
1052   - //将对应的到离站数据标记为不可信
1053   - List<ArrivalEntity> list = ArrivalData_GPS.findByNbbm(sch.getClZbh());
1054   - for(ArrivalEntity arr : list){
1055   - if(arr.getInOut() == 0
1056   - && arr.getUpDown() == Integer.parseInt(sch.getXlDir())
1057   - && arr.getStopNo().equals(sch.getZdzCode())
1058   - && Math.abs(arr.getTs() - sch.getZdsjActualTime()) < 1000 * 60){
1059   - arr.setEnable(false);
1060   - break;
1061   - }
1062   - }
1063   - }*/
1064   -
1065   - //清除实达时间
1066   - sch.clearZdsjActual();
1067   - //清除下一班次起点到达时间
1068   - ScheduleRealInfo next = dayOfSchedule.next(sch);
1069   - if(null != next){
1070   - next.setQdzArrDateSJ(null);
1071   - ts.add(next);
1072   - }
1073   - }
1074   -
1075   - sch.setRemarks(remarks);
1076   - }
1077   -
1078   - //班次状态
1079   - sch.calcStatus();
1080   - dayOfSchedule.save(sch);
1081   - //页面需要更新的班次信息
1082   - ts.add(sch);
1083   -
1084   - rs.put("status", ResponseCode.SUCCESS);
1085   - rs.put("ts", ts);
1086   - } catch (Exception e) {
1087   - logger.error("", e);
1088   - rs.put("status", ResponseCode.ERROR);
1089   - }
1090   - return rs;
1091   - }
1092   -
1093   - @Override
1094   - public Map<String, Object> outgoAdjustAll(String params) {
1095   - Map<String, Object> rs = new HashMap<>();
1096   - try{
1097   - JSONArray jsonArray = JSONArray.parseArray(params);
1098   -
1099   - ScheduleRealInfo schedule = null;
1100   - JSONObject jsonObj;
1101   - String dfsj;
1102   - for(int i = 0; i < jsonArray.size(); i ++){
1103   - jsonObj = jsonArray.getJSONObject(i);
1104   - dfsj = jsonObj.getString("t");
1105   - schedule = dayOfSchedule.get(jsonObj.getLong("id"));
1106   - //设置待发时间
1107   - schedule.setDfsjAll(dfsj);
1108   -
1109   - dayOfSchedule.save(schedule);
1110   - }
1111   -
1112   - rs.put("status", ResponseCode.SUCCESS);
1113   - //将更新的最后一个班次返回
1114   - rs.put("t", schedule);
1115   - }catch(Exception e){
1116   - logger.error("", e);
1117   - rs.put("status", ResponseCode.ERROR);
1118   - }
1119   - return rs;
1120   - }
1121   -
1122   - @Override
1123   - public Map<String, Object> findRouteByLine(String lineCode) {
1124   - Map<String, Object> map = new HashMap<>();
1125   - //上行
1126   - Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode);
1127   - map.put("line.id_eq", lineId);
1128   - map.put("directions_eq", 0);
1129   - List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map);
1130   -
1131   - //下行
1132   - map.put("directions_eq", 1);
1133   - List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map);
1134   -
1135   - Map<String, Object> rs = new HashMap<>();
1136   -
1137   - String upVectors = "", vec;
1138   - //拼接上行路段
1139   - for(Map<String, Object> temp : upList){
1140   - vec = temp.get("sectionBsectionVector").toString();
1141   - upVectors += vec.subSequence(11, vec.length() - 2) + " ";
1142   - }
1143   -
1144   - //拼接下行路段
1145   - String downVectors = "";
1146   - for(Map<String, Object> temp : downList){//LINESTRING(
1147   - vec = temp.get("sectionBsectionVector").toString();
1148   - downVectors += vec.subSequence(11, vec.length() - 2) + " ";
1149   - }
1150   -
1151   -
1152   - rs.put("up", upVectors);
1153   - //上行gcj
1154   - rs.put("up_gcj", BdToGcjString(upVectors));
1155   - rs.put("down", downVectors);
1156   - //下行gcj
1157   - rs.put("down_gcj", BdToGcjString(downVectors));
1158   - rs.put("lineId", lineId);
1159   -
1160   - return rs;
1161   - }
1162   -
1163   - /**
1164   - *
1165   - * @Title: BdToGcjString
1166   - * @Description: TODO(将百度路由字符串 转 成GCJ 字符串)
1167   - * @param @param bdStr
1168   - * @throws
1169   - */
1170   - public String BdToGcjString(String bdStr){
1171   - String[] array = bdStr.split(",")
1172   - ,subArray;
1173   - if(array.length == 0 || bdStr.length() < 2)
1174   - return "";
1175   -
1176   - String gcjStr = "";
1177   - TransGPS.Location location;
1178   - for(String crd : array){
1179   - subArray = crd.split(" ");
1180   - if(subArray.length != 2)
1181   - continue;
1182   - location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1])));
1183   -
1184   - gcjStr += location.getLng() + " " + location.getLat() + ",";
1185   - }
1186   -
1187   - return gcjStr.substring(0, gcjStr.length() - 1);
1188   - }
1189   - public List<Map<String, String>> findLine(String line) {
1190   - List<Line> listLine = lineRepository.findLine("%"+line+"%");
1191   - List<Map<String,String>> list = new ArrayList<Map<String,String>>();
1192   - Map<String,String> map;
1193   - for(Line temp:listLine){
1194   - if(temp != null){
1195   - String xlName = temp.getName();
1196   - if(xlName.indexOf(line) != -1){
1197   - map = new HashMap<String, String>();
1198   - map.put("id", temp.getLineCode());
1199   - map.put("text", xlName);
1200   - list.add(map);
1201   - }
1202   - }
1203   - }
1204   - return list;
1205   - }
1206   -
1207   - public List<Map<String, String>> findLpName(String lpName) {
1208   - List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%"+lpName+"%");
1209   - List<Map<String,String>> list = new ArrayList<Map<String,String>>();
1210   - Map<String,String> map;
1211   - for(GuideboardInfo temp:listLpName){
1212   - if(temp != null){
1213   - String lp = temp.getLpName();
1214   - if(lp.indexOf(lpName) != -1){
1215   - map = new HashMap<String, String>();
1216   - map.put("id", lp);
1217   - map.put("text", lp);
1218   - list.add(map);
1219   - }
1220   - }
1221   - }
1222   - return list;
1223   - }
1224   -
1225   - @Override
1226   - public Map<String, Object> findKMBC2(String jName, String clZbh,String date) {
1227   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh , date);
1228   -
1229   - DecimalFormat format = new DecimalFormat("0.00");
1230   -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1231   -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
1232   - int jhbc = 0,cjbc = 0,ljbc = 0;
1233   - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;
1234   - float addMileage = 0l,remMileage = 0l;
1235   - String j_Name="";
1236   - Map<String,Object> map = new HashMap<String, Object>();
1237   - for(ScheduleRealInfo scheduleRealInfo : list){
1238   - if(scheduleRealInfo != null){
1239   - j_Name=scheduleRealInfo.getjName();
1240   - //计划里程(主任务过滤掉临加班次),
1241   - //烂班里程(主任务烂班),
1242   - //临加里程(主任务临加),
1243   - //计划班次,烂班班次,增加班次
1244   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1245   - if(scheduleRealInfo.isSflj()){
1246   - addMileage += tempJhlc;
1247   - ljbc++;
1248   - }else{
1249   - jhlc += tempJhlc;
1250   - jhbc++;
1251   - if(scheduleRealInfo.getStatus() == -1){
1252   - remMileage += tempJhlc;
1253   - cjbc++;
1254   - }
1255   - }
1256   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1257   - //计算营运里程,空驶里程
1258   - if(childTaskPlans.isEmpty()){
1259   - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
1260   - || scheduleRealInfo.getBcType().equals("venting")){
1261   - ksgl += tempJhlc;
1262   - }else{
1263   - yygl += tempJhlc;
1264   - }
1265   - }else{
1266   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1267   - while(it.hasNext()){
1268   - ChildTaskPlan childTaskPlan = it.next();
1269   - if(childTaskPlan.getMileageType().equals("empty")){
1270   - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1271   - }else{
1272   - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1273   - }
1274   - }
1275   - }
1276   - }
1277   - }
1278   - map.put("j_name", j_Name);
1279   - map.put("jhlc", format.format(jhlc));
1280   - map.put("remMileage", format.format(remMileage));
1281   - map.put("addMileage", format.format(addMileage));
1282   - map.put("yygl", format.format(yygl));
1283   - map.put("ksgl", format.format(ksgl));
1284   - map.put("realMileage", format.format(yygl+ksgl));
1285   - map.put("jhbc", jhbc);
1286   - map.put("cjbc", cjbc);
1287   - map.put("ljbc", ljbc);
1288   - map.put("sjbc", jhbc-cjbc+ljbc);
1289   - return map;
1290   - }
1291   -
1292   -
1293   - @Override
1294   - public Map<String, Object> findKMBC(String jName, String clZbh,
1295   - String lpName,String date,String line) {
1296   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date,line);
1297   - DecimalFormat format = new DecimalFormat("0.00");
1298   -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1299   -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
1300   - int jhbc = 0,cjbc = 0,ljbc = 0;
1301   - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0,jcclc=0;
1302   - float addMileage = 0l,remMileage = 0l;
1303   - Map<String,Object> map = new HashMap<String, Object>();
1304   - for(ScheduleRealInfo scheduleRealInfo : list){
1305   - if(scheduleRealInfo != null){
1306   - //计划里程(主任务过滤掉临加班次),
1307   - //烂班里程(主任务烂班),
1308   - //临加里程(主任务临加),
1309   - //计划班次,烂班班次,增加班次
1310   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1311   - if(scheduleRealInfo.isSflj()){
1312   - ljbc++;
1313   - }else{
1314   - if( !(scheduleRealInfo.getBcType().equals("in")
1315   - ||scheduleRealInfo.getBcType().equals("out")) ){
1316   - jhbc++;
1317   - jhlc += tempJhlc;
1318   - }
1319   -
1320   - if(scheduleRealInfo.getStatus() == -1){
1321   - remMileage += tempJhlc;
1322   - cjbc++;
1323   - }
1324   - }
1325   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1326   - //计算营运里程,空驶里程
1327   - if(childTaskPlans.isEmpty()){
1328   - if(scheduleRealInfo.getBcType().equals("in") ||
1329   - scheduleRealInfo.getBcType().equals("out")){
1330   - jcclc +=tempJhlc;
1331   - }
1332   - //主任务 放空班次属于营运
1333   -// else if(scheduleRealInfo.getBcType().equals("venting")){
1334   -// ksgl += tempJhlc;
1335   -// }
1336   - else{
1337   - if(scheduleRealInfo.getStatus() != -1){
1338   - if(scheduleRealInfo.isSflj()){
1339   - addMileage += tempJhlc;
1340   - }
1341   - yygl += tempJhlc;
1342   - }
1343   - }
1344   - }else{
1345   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1346   - while(it.hasNext()){
1347   - ChildTaskPlan childTaskPlan = it.next();
1348   - if(childTaskPlan.getMileageType().equals("empty")){
1349   - if(childTaskPlan.isDestroy()){
1350   - remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1351   - }else{
1352   - if(scheduleRealInfo.isSflj()){
1353   - addMileage += tempJhlc;
1354   - }
1355   - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1356   - }
1357   - }else{
1358   - if(childTaskPlan.isDestroy()){
1359   - remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1360   -// cjbc++;
1361   - }else{
1362   - if(scheduleRealInfo.isSflj()){
1363   - addMileage += tempJhlc;
1364   - }
1365   - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1366   - }
1367   - }
1368   - }
1369   - }
1370   - }
1371   - }
1372   - map.put("jhlc", format.format(jhlc));
1373   - map.put("remMileage", format.format(remMileage));
1374   - map.put("addMileage", format.format(addMileage));
1375   - map.put("yygl", format.format(yygl));
1376   - map.put("ksgl", format.format(ksgl));
1377   - map.put("realMileage", format.format(yygl+ksgl+jcclc));
1378   - map.put("jhbc", jhbc);
1379   - map.put("cjbc", cjbc);
1380   - map.put("ljbc", ljbc);
1381   - map.put("sjbc", jhbc-cjbc+ljbc);
1382   - map.put("jcclc", jcclc);
1383   - map.put("zkslc", format.format(ksgl+jcclc));
1384   - return map;
1385   - }
1386   -
1387   -
1388   -
1389   - @Override
1390   - public Map<String, Object> findKMBCQp( String clZbh,
1391   - String date,String line) {
1392   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill2( clZbh,date,line);
  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);
1393 2201 DecimalFormat format = new DecimalFormat("0.00");
1394 2202 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1395 2203 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
... ... @@ -1483,97 +2291,18 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1483 2291 return map;
1484 2292 }
1485 2293  
1486   -
1487 2294 @Override
1488   - public List<Map<String, Object>> account(String line, String date,
1489   - String code,String xlName, String type) {
1490   - List<Object[]> lsitObj = scheduleRealInfoRepository.account(line,date,code);
1491   - List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
1492   - Map<String,Object> map;
1493   - int i = 1;
1494   - for(Object[] obj : lsitObj){
1495   - if(obj != null){
1496   - map = new HashMap<String,Object>();
1497   - map.put("num", i++);
1498   - map.put("xlName", xlName);
1499   - map.put("clZbh", obj[3]);
1500   - map.put("company", obj[0]);
1501   - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1]+"")).toUpperCase());
1502   - map.put("requestTime", obj[2]);
1503   - listMap.add(map);
1504   - }
1505   - }
1506   -
1507   - if(type != null && type.length() != 0 && type.equals("export")){
1508   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
1509   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
1510   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
1511   - Map<String,Object> m = new HashMap<String, Object>();
1512   - ReportUtils ee = new ReportUtils();
1513   - Map<String, Object> typeMap = new HashMap<String, Object>();
1514   - typeMap.put("0xA1", "请求恢复运营");
1515   - typeMap.put("0xA2", "申请调档");
1516   - typeMap.put("0xA3", "出场请求");
1517   - typeMap.put("0xA5", "进场请求");
1518   - typeMap.put("0xA7", "加油请求");
1519   - typeMap.put("0x50", "车辆故障");
1520   - typeMap.put("0x70", "路阻报告");
1521   - typeMap.put("0x60", "事故报告");
1522   - typeMap.put("0x11", "扣证纠纷");
1523   - typeMap.put("0x12", "报警");
1524   - for(Map<String, Object> map1 : listMap){
1525   - map1.put("requestText", typeMap.get(map1.get("requestType")));
1526   - }
1527   - try {
1528   - listI.add(listMap.iterator());
1529   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
1530   - ee.excelReplace(listI, new Object[] { m }, path+"mould\\account.xls",
1531   - path+"export\\驾驶员请求台账" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
1532   - } catch (Exception e) {
1533   - // TODO: handle exception
1534   - e.printStackTrace();
1535   - }
1536   - }
1537   -
1538   - return listMap;
1539   - }
1540   -
1541   - @Override
1542   - public List<ScheduleRealInfo> correctForm(String line, String startDate,
1543   - String endDate, String lpName, String code, String type) {
1544   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.correctForm(line,startDate,endDate,lpName,code);
1545   -
1546   - if(type != null && type.length() != 0 && type.equals("export")){
1547   - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
1548   - sdfSimple = new SimpleDateFormat("yyyyMMdd");
1549   - List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
1550   - Map<String,Object> m = new HashMap<String, Object>();
1551   - ReportUtils ee = new ReportUtils();
1552   - m.put("startDate", startDate);
1553   - m.put("endDate", endDate);
1554   - try {
1555   - listI.add(list.iterator());
1556   - String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
1557   - ee.excelReplace(listI, new Object[] { m }, path+"mould\\correctForm.xls",
1558   - path+"export\\" + URLEncoder.encode("修正报表", "UTF-8") + sdfSimple.format(sdfMonth.parse(startDate)) + "-" + sdfSimple.format(sdfMonth.parse(endDate)) + ".xls");
1559   - } catch (Exception e) {
1560   - // TODO: handle exception
1561   - e.printStackTrace();
1562   - }
1563   - }
1564   -
1565   - return list;
1566   - }
1567   -
1568   - @Override
1569   - public List<ScheduleRealInfo> queryListWaybill(String jName, String clZbh,
1570   - String lpName,String date,String line) {
1571   - List <ScheduleRealInfo> list= scheduleRealInfoRepository.queryListWaybill(jName,clZbh,lpName,date,line);
1572   - for (int i = 0; i < list.size(); i++) {
1573   - ScheduleRealInfo s=list.get(i);
1574   - String remarks="";
1575   - if(s.getRemarks()!=null){
1576   - remarks +=s.getRemarks();
  2295 + public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) {
  2296 + // TODO Auto-generated method stub
  2297 + List <ScheduleRealInfo> list=null;
  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"))){
  2303 + String remarks="";
  2304 + if(s.getRemarks()!=null){
  2305 + remarks +=s.getRemarks();
1577 2306 }
1578 2307 Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
1579 2308 if(!childTaskPlans.isEmpty()){
... ... @@ -1587,784 +2316,61 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1587 2316 }
1588 2317 }
1589 2318 s.setRemarks(remarks);
  2319 + newList.add(s);
1590 2320 }
1591 2321  
1592   - return list;
1593 2322 }
1594 2323  
1595   - @Override
1596   - public List<ScheduleRealInfo> queryListWaybillQp( String clZbh,String date,String line) {
1597   - List <ScheduleRealInfo> list=null;
1598   - list= scheduleRealInfoRepository.queryListWaybill2(clZbh,date,line);
1599   - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
1600   - for (int i = 0; i < list.size(); i++) {
1601   - ScheduleRealInfo s=list.get(i);
1602   - if(!(s.getBcType().equals("in")||s.getBcType().equals("out"))){
1603   - String remarks="";
1604   - if(s.getRemarks()!=null){
1605   - remarks +=s.getRemarks();
1606   - }
1607   - Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
1608   - if(!childTaskPlans.isEmpty()){
1609   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1610   - while(it.hasNext()){
1611   - ChildTaskPlan c = it.next();
1612   - if(c.getRemarks()!=null && c.getRemarks().length()>0){
1613   - remarks += c.getRemarks();
1614   - }
1615   -
1616   - }
1617   - }
1618   - s.setRemarks(remarks);
1619   - newList.add(s);
1620   - }
1621   -
1622   - }
1623   -
1624   - return newList;
  2324 + return newList;
1625 2325 }
1626 2326  
1627 2327 @Override
1628   - public Map<String, Object> removeChildTask(Long taskId) {
1629   - Map<String, Object> rs = new HashMap<>();
1630   - ChildTaskPlan chTask = cTaskPlanRepository.findOne(taskId);
1631   -
1632   - ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId());
1633   - try {
1634   -
1635   - sch.getcTasks().remove(chTask);
1636   - scheduleRealInfoRepository.save(sch);
1637   - rs.put("status", ResponseCode.SUCCESS);
1638   - } catch (Exception e) {
1639   - logger.error("", e);
1640   - rs.put("status", ResponseCode.ERROR);
1641   - }
1642   - return rs;
1643   - }
1644   -
1645   - @Override
1646   - public List<Map<String, Object>> statisticsDaily(String line, String date,
1647   - String xlName) {
1648   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1649   - List<Map<String,Object>> lMap = new ArrayList<Map<String,Object>>();
1650   - DecimalFormat format = new DecimalFormat("0.00");
1651   - double jhlc = 0, tempJhlc = 0,childMileage = 0;
1652   - float sjgl = 0f,ssgl = 0f,ssgl_lz = 0f,ssgl_dm = 0f,ssgl_gz = 0f,ssgl_jf = 0f,ssgl_zs = 0f,ssgl_qr = 0f
1653   - ,ssgl_qc = 0f,ssgl_kx = 0f,ssgl_qh = 0f,ssgl_yw = 0f,ssgl_other = 0f,ljgl = 0f;
1654   - //班次
1655   - int sj_0 = 6*60+31,sj_1 = 8*60+30,sj_2 = 16*60+1,sj_3 = 18*60;
1656   - int jhbc = 0,jhbc_m = 0,jhbc_a = 0;
1657   - int sjbc = 0,sjbc_m = 0,sjbc_a = 0;
1658   - int ljbc = 0,ljbc_m = 0,ljbc_a = 0;
1659   - int fzbc = 0,fzbc_m = 0,fzbc_a = 0;
1660   - int dtbc = 0,dtbc_m = 0,dtbc_a = 0;
1661   - int djg = 0,djg_m = 0,djg_a = 0,djg_time = 0;
1662   - Map<String,Object> map = new HashMap<String, Object>();
1663   - for(ScheduleRealInfo scheduleRealInfo: list){
1664   - if(scheduleRealInfo != null){
  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 +
1665 2336  
1666   - if(!(scheduleRealInfo.getBcType().equals("in")
1667   - ||scheduleRealInfo.getBcType().equals("out")) ){
1668   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1669   - //计算实际里程,少驶里程,计划里程=实际里程+少驶里程
1670   - if(childTaskPlans.isEmpty()){
1671   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1672   - //临加公里
1673   - if(scheduleRealInfo.isSflj()){
1674   - ljgl += tempJhlc;
1675   - }else{
1676   - jhlc += tempJhlc;
1677   - }
1678   - if(scheduleRealInfo.getStatus() == 2){
1679   - sjgl += tempJhlc;
1680   - }else if(scheduleRealInfo.getStatus() == -1){
1681   - ssgl += tempJhlc;
1682   - if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("路阻") != -1){
1683   - ssgl_lz += tempJhlc;
1684   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("吊慢") != -1){
1685   - ssgl_dm += tempJhlc;
1686   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("故障") != -1){
1687   - ssgl_gz += tempJhlc;
1688   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("纠纷") != -1){
1689   - ssgl_jf += tempJhlc;
1690   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("肇事") != -1){
1691   - ssgl_zs += tempJhlc;
1692   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺人") != -1){
1693   - ssgl_qr += tempJhlc;
1694   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺车") != -1){
1695   - ssgl_qc += tempJhlc;
1696   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("客稀") != -1){
1697   - ssgl_kx += tempJhlc;
1698   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("气候") != -1){
1699   - ssgl_qh += tempJhlc;
1700   - }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("援外") != -1){
1701   - ssgl_yw += tempJhlc;
1702   - }else{
1703   - ssgl_other += tempJhlc;
1704   - }
1705   - }
1706   - }else{
1707   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1708   - while(it.hasNext()){
1709   - ChildTaskPlan childTaskPlan = it.next();
1710   - childMileage = childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1711   - jhlc += childMileage;
1712   - if(childTaskPlan.isDestroy()){
1713   - ssgl += childMileage;
1714   - if(childTaskPlan.getDestroyReason().equals("路阻")){
1715   - ssgl_lz += childTaskPlan.getMileage();
1716   - }else if(childTaskPlan.getDestroyReason().equals("吊慢")){
1717   - ssgl_dm += childTaskPlan.getMileage();
1718   - }else if(childTaskPlan.getDestroyReason().equals("故障")){
1719   - ssgl_gz += childTaskPlan.getMileage();
1720   - }else if(childTaskPlan.getDestroyReason().equals("纠纷")){
1721   - ssgl_jf += childTaskPlan.getMileage();
1722   - }else if(childTaskPlan.getDestroyReason().equals("肇事")){
1723   - ssgl_zs += childTaskPlan.getMileage();
1724   - }else if(childTaskPlan.getDestroyReason().equals("缺人")){
1725   - ssgl_qr += childTaskPlan.getMileage();
1726   - }else if(childTaskPlan.getDestroyReason().equals("缺车")){
1727   - ssgl_qc += childTaskPlan.getMileage();
1728   - }else if(childTaskPlan.getDestroyReason().equals("客稀")){
1729   - ssgl_kx += childTaskPlan.getMileage();
1730   - }else if(childTaskPlan.getDestroyReason().equals("气候")){
1731   - ssgl_qh += childTaskPlan.getMileage();
1732   - }else if(childTaskPlan.getDestroyReason().equals("援外")){
1733   - ssgl_yw += childTaskPlan.getMileage();
1734   - }else{
1735   - ssgl_other += childTaskPlan.getMileage();
1736   - }
1737   - }else{
1738   - sjgl += childMileage;
1739   - }
1740   - }
1741   - }
1742   -
1743   - //班次
1744   - jhbc++;
1745   - String[] fcsj = scheduleRealInfo.getFcsj().split(":");
1746   - String[] fcsjActual = (scheduleRealInfo.getFcsjActual()==null?"0:00":scheduleRealInfo.getFcsjActual()).split(":");
1747   - if((Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) > sj_0 && (Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) < sj_1){
1748   - jhbc_m++;
1749   - }else if((Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) > sj_2 && (Integer.parseInt(fcsj[0])*60+Integer.parseInt(fcsj[1])) < sj_3){
1750   - jhbc_a++;
1751   - }
1752   - if(scheduleRealInfo.getStatus() == 2){
1753   - sjbc++;
1754   - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){
1755   - sjbc_m++;
1756   - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){
1757   - sjbc_a++;
1758   - }
1759   - }
1760   - if(scheduleRealInfo.isSflj()){
1761   - ljbc++;
1762   - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){
1763   - ljbc_m++;
1764   - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){
1765   - ljbc_a++;
1766   - }
1767   - }
1768   - if(scheduleRealInfo.getBcType().equals("venting")){
1769   - fzbc++;
1770   - if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_0 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_1){
1771   - fzbc_m++;
1772   - }else if((Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) > sj_2 && (Integer.parseInt(fcsjActual[0])*60+Integer.parseInt(fcsjActual[1])) < sj_3){
1773   - fzbc_a++;
1774   - }
1775   - }
1776   - }
1777   - }
1778   - }
1779   - map.put("xlName", xlName);
1780   - map.put("jhlc", format.format(jhlc));
1781   - map.put("sjgl", format.format(sjgl));
1782   - map.put("ssgl", format.format(ssgl));
1783   - map.put("ssgl_lz", ssgl_lz==0?0:format.format(ssgl_lz));
1784   - map.put("ssgl_dm", ssgl_dm==0?0:format.format(ssgl_dm));
1785   - map.put("ssgl_gz", ssgl_gz==0?0:format.format(ssgl_gz));
1786   - map.put("ssgl_jf", ssgl_jf==0?0:format.format(ssgl_jf));
1787   - map.put("ssgl_zs", ssgl_zs==0?0:format.format(ssgl_zs));
1788   - map.put("ssgl_qr", ssgl_qr==0?0:format.format(ssgl_qr));
1789   - map.put("ssgl_qc", ssgl_qc==0?0:format.format(ssgl_qc));
1790   - map.put("ssgl_kx", ssgl_kx==0?0:format.format(ssgl_kx));
1791   - map.put("ssgl_qh", ssgl_qh==0?0:format.format(ssgl_qh));
1792   - map.put("ssgl_yw", ssgl_yw==0?0:format.format(ssgl_yw));
1793   - map.put("ssgl_other", ssgl_other==0?0:format.format(ssgl_other));
1794   - map.put("ljgl", ljgl==0?0:format.format(ljgl));
1795   - map.put("jhbc", jhbc);
1796   - map.put("jhbc_m", jhbc_m);
1797   - map.put("jhbc_a", jhbc_a);
1798   - map.put("sjbc", sjbc);
1799   - map.put("sjbc_m", sjbc_m);
1800   - map.put("sjbc_a", sjbc_a);
1801   - map.put("ljbc", ljbc);
1802   - map.put("ljbc_m", ljbc_m);
1803   - map.put("ljbc_a", ljbc_a);
1804   - map.put("fzbc", fzbc);
1805   - map.put("fzbc_m", fzbc_m);
1806   - map.put("fzbc_a", fzbc_a);
1807   - map.put("dtbc", dtbc);
1808   - map.put("dtbc_m", dtbc_m);
1809   - map.put("dtbc_a", dtbc_a);
1810   - map.put("djg", djg);
1811   - map.put("djg_m", djg_m);
1812   - map.put("djg_a", djg_a);
1813   - map.put("djg_time", djg_time);
1814   - lMap.add(map);
1815   - return lMap;
1816   - }
1817   -
1818   - @Override
1819   - public Map<String,Object> scheduleDaily(String line, String date) {
1820   - Map<String,String> tempMap = null;
1821   - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1822   - Map<String, Object> map = new HashMap<String, Object>();
1823   - Double jhlc = 0.00;
1824   - Float sjgl = 0f,ssgl = 0f,ssgl_lz = 0f,ssgl_dm = 0f,ssgl_gz = 0f,ssgl_jf = 0f,ssgl_zs = 0f,ssgl_qr = 0f
1825   - ,ssgl_qc = 0f,ssgl_kx = 0f,ssgl_qh = 0f,ssgl_yw = 0f,ssgl_other = 0f,ljgl = 0f;
1826   - int jhbc = 0;
1827   - for(ScheduleRealInfo scheduleRealInfo:scheduleRealInfos){
1828   - if(scheduleRealInfo != null){
1829   - //计算里程(包括子任务)
1830   - jhlc += scheduleRealInfo.getJhlc();
1831   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1832   - if(!childTaskPlans.isEmpty()){
1833   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1834   - while(it.hasNext()){
1835   - ChildTaskPlan childTaskPlan = it.next();
1836   - //是否烂班,烂班就是少驶
1837   - if(!childTaskPlan.isDestroy()){
1838   - sjgl += childTaskPlan.getMileage();
1839   - }else{
1840   - ssgl += childTaskPlan.getMileage();
1841   - if(childTaskPlan.getDestroyReason().equals("路阻")){
1842   - ssgl_lz += childTaskPlan.getMileage();
1843   - }else if(childTaskPlan.getDestroyReason().equals("吊慢")){
1844   - ssgl_dm += childTaskPlan.getMileage();
1845   - }else if(childTaskPlan.getDestroyReason().equals("故障")){
1846   - ssgl_gz += childTaskPlan.getMileage();
1847   - }else if(childTaskPlan.getDestroyReason().equals("纠纷")){
1848   - ssgl_jf += childTaskPlan.getMileage();
1849   - }else if(childTaskPlan.getDestroyReason().equals("肇事")){
1850   - ssgl_zs += childTaskPlan.getMileage();
1851   - }else if(childTaskPlan.getDestroyReason().equals("缺人")){
1852   - ssgl_qr += childTaskPlan.getMileage();
1853   - }else if(childTaskPlan.getDestroyReason().equals("缺车")){
1854   - ssgl_qc += childTaskPlan.getMileage();
1855   - }else if(childTaskPlan.getDestroyReason().equals("客稀")){
1856   - ssgl_kx += childTaskPlan.getMileage();
1857   - }else if(childTaskPlan.getDestroyReason().equals("气候")){
1858   - ssgl_qh += childTaskPlan.getMileage();
1859   - }else if(childTaskPlan.getDestroyReason().equals("援外")){
1860   - ssgl_yw += childTaskPlan.getMileage();
1861   - }else{
1862   - ssgl_other += childTaskPlan.getMileage();
1863   - }
1864   - }
1865   - //临加公里
1866   - if(childTaskPlan.getType1().equals("临加")){
1867   - ljgl += childTaskPlan.getMileage();
1868   - }
1869   - }
1870   - }
1871   - //班次
1872   - scheduleRealInfo.getFcsjT();
1873   - scheduleRealInfo.getFcsjActualTime();
1874   - }
1875   - }
1876   - map.put("jhlc", jhlc);
1877   - map.put("sjgl", sjgl);
1878   - map.put("ssgl", ssgl);
1879   - map.put("ssgl_lz", ssgl_lz);
1880   - map.put("ssgl_dm", ssgl_dm);
1881   - map.put("ssgl_gz", ssgl_gz);
1882   - map.put("ssgl_jf", ssgl_jf);
1883   - map.put("ssgl_zs", ssgl_zs);
1884   - map.put("ssgl_qr", ssgl_qr);
1885   - map.put("ssgl_qc", ssgl_qc);
1886   - map.put("ssgl_kx", ssgl_kx);
1887   - map.put("ssgl_qh", ssgl_qh);
1888   - map.put("ssgl_yw", ssgl_yw);
1889   - map.put("ssgl_other", ssgl_other);
1890   - map.put("ljgl", ljgl);
1891   -
1892   - map.put("jhbc", scheduleRealInfos.size());
1893   - return null;
1894   - }
1895   -
1896   - @Override
1897   - public int countByLineCodeAndDate(String xlBm, String schDate) {
1898   - return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate);
1899   - }
1900   -
1901   - @Override
1902   - public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) {
1903   - return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate);
1904   - }
1905   -
1906   - @Override
1907   - public void deleteByLineCodeAndDate(String xlBm, String schDate) {
1908   - scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate);
1909   - }
1910   -
1911   - @Override
1912   - public Long getMaxId() {
1913   - return scheduleRealInfoRepository.getMaxId();
1914   - }
1915   -
1916   - @Override
1917   - public List<ScheduleRealInfo> realScheduleList(String line, String date) {
1918   - /*List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.queryUserInfo(line, date);
1919   - List<ScheduleRealInfo> listTotal = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1920   - for(ScheduleRealInfo info:listInfo){
1921   - for(ScheduleRealInfo total:listTotal){
1922   - if(info.getjGh().equals(total.getjGh()) && info.getLpName().equals(total.getLpName()) && info.getClZbh().equals(total.getClZbh())){
1923   -
1924   - }
1925   - }
1926   - }*/
1927   - return scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1928   - }
1929   -
1930   -
1931   - public List<Map<String,Object>> yesterdayDataList(String line,String date) {
1932   - //前一天日期
1933   -// String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
1934   -// String date = "2016-09-20";
1935   - List<Map<String,Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date);
1936   -// List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1937   - for(int x=0;x<yesterdayDataList.size();x++){
1938   - String jName=yesterdayDataList.get(x).get("jGh").toString();
1939   - String clZbh=yesterdayDataList.get(x).get("clZbh").toString();
1940   - List<ScheduleRealInfo> lists=scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date);
1941   - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0,jcclc=0;
1942   - float addMileage = 0l,remMileage = 0l;
1943   - Map<String,Object> map = new HashMap<String, Object>();
1944   - boolean fage=true;
1945   - for(ScheduleRealInfo scheduleRealInfo : lists){
1946   - if(fage){
1947   - //根据线路代码获取公司
1948   - Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
1949   - yesterdayDataList.get(x).put("company", li.getCompany());
1950   - yesterdayDataList.get(x).put("bCompany", li.getBrancheCompany());
1951   - fage=false;
1952   - }
1953   - if(scheduleRealInfo != null){
1954   - //计划里程(主任务过滤掉临加班次),
1955   - //烂班里程(主任务烂班),
1956   - //临加里程(主任务临加),
1957   - //计划班次,烂班班次,增加班次
1958   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
1959   - if(scheduleRealInfo.isSflj()){
1960   - addMileage += tempJhlc;
1961   - }else{
1962   - if( !(scheduleRealInfo.getBcType().equals("in")
1963   - ||scheduleRealInfo.getBcType().equals("out")) ){
1964   - jhlc += tempJhlc;
1965   - }
1966   -
1967   - if(scheduleRealInfo.getStatus() == -1){
1968   - remMileage += tempJhlc;
1969   - }
1970   - }
1971   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1972   - //计算营运里程,空驶里程
1973   - if(childTaskPlans.isEmpty()){
1974   - if(scheduleRealInfo.getBcType().equals("in") ||
1975   - scheduleRealInfo.getBcType().equals("out")){
1976   - jcclc +=tempJhlc;
1977   - }
1978   - //主任务 放空班次属于营运
1979   -// else if(scheduleRealInfo.getBcType().equals("venting")){
1980   -// ksgl += tempJhlc;
1981   -// }
1982   - else{
1983   - if(scheduleRealInfo.getStatus() != -1){
1984   - yygl += tempJhlc;
1985   - }
1986   - }
1987   - }else{
1988   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1989   - while(it.hasNext()){
1990   - ChildTaskPlan childTaskPlan = it.next();
1991   - if(childTaskPlan.getMileageType().equals("empty")){
1992   - if(childTaskPlan.isDestroy()){
1993   - remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1994   - }else{
1995   - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
1996   - }
1997   - }else{
1998   - if(childTaskPlan.isDestroy()){
1999   - remMileage += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
2000   - }else{
2001   - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
2002   - }
  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()+",";
2003 2355 }
2004   - }
2005   - }
2006   - }
2007   - }
2008   -
2009   - yesterdayDataList.get(x).put("totalKilometers", yygl+ksgl+jcclc);
2010   -
2011   - }
2012   -
2013   - /* for(ScheduleRealInfo scheduleRealInfo:list){
2014   - if(scheduleRealInfo != null){
2015   - for(int i=0;i<yesterdayDataList.size();i++){
2016   - if(scheduleRealInfo.getXlBm().equals(yesterdayDataList.get(i).get("xlBm")) && scheduleRealInfo.getClZbh().equals(yesterdayDataList.get(i).get("clZbh"))
2017   - && scheduleRealInfo.getjGh().equals(yesterdayDataList.get(i).get("jGh"))){
2018   - //根据线路代码获取公司
2019   - Line li = lineRepository.findByLineCode(scheduleRealInfo.getXlBm());
2020   - yesterdayDataList.get(i).put("company", li.getCompany());
2021   - yesterdayDataList.get(i).put("bCompany", li.getBrancheCompany());
2022   - //计算总公里
2023   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
2024   - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班
2025   - if(childTaskPlans.isEmpty()){
2026   - if(scheduleRealInfo.getStatus() == 2){
2027   - 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()+",";
2028 2359 }
2029 2360 }else{
2030   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
2031   - while(it.hasNext()){
2032   - ChildTaskPlan childTaskPlan = it.next();
2033   - if(!childTaskPlan.isDestroy()){
2034   - 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")));
2035   - }
  2361 + if(wdp.indexOf(t.getuName())==-1){
  2362 + wdp +=t.getuName()+",";
2036 2363 }
2037 2364 }
2038   - }
2039   - }
2040   - }
2041   - }*/
2042   - //增加顺序号
2043   - for(int i=0;i<yesterdayDataList.size();i++){
2044   - if(i == 0){
2045   - yesterdayDataList.get(i).put("seqNumber", 1);
2046   - }else{
2047   - if(yesterdayDataList.get(i-1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))){
2048   - yesterdayDataList.get(i).put("seqNumber", 1+(int)yesterdayDataList.get(i-1).get("seqNumber"));
2049   - }else{
2050   - yesterdayDataList.get(i).put("seqNumber", 1);
2051   - }
2052   - }
2053   - }
2054   - return yesterdayDataList;
2055   - }
2056   -
2057   - /**
2058   - * 批量调整人车
2059   - */
2060   - @Override
2061   - public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs) {
2062   - Map<String, Object> rs = new HashMap<>();
2063   - Set<ScheduleRealInfo> set = new HashSet<>();
2064   -
2065   - ScheduleRealInfo sch;
2066   -
2067   - for(ChangePersonCar cpc : cpcs){
2068   -
2069   - sch = dayOfSchedule.get(cpc.getSchId());
2070   - if(sch==null)
2071   - continue;
2072   -
2073   - if(StringUtils.isNotEmpty(cpc.getJsy())){
2074   - //换驾驶员
2075   - persoChange(sch, cpc.getJsy().split("/")[0]);
2076   - }
2077   -
2078   - //换售票员
2079   - if(StringUtils.isNotEmpty(cpc.getSpy())){
2080   - persoChangeSPY(sch, cpc.getSpy().split("/")[0]);
2081   - }
2082   -
2083   - //换车
2084   - if(StringUtils.isNotEmpty(cpc.getClZbh())){
2085   - set.add(sch);
2086   - set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh()));
2087   - }
2088   -
2089   - }
2090   - rs.put("ts", set);
2091   - rs.put("status", ResponseCode.SUCCESS);
2092   - return rs;
2093   - }
2094   -
2095   - /**
2096   - *
2097   - * @Title: persoChange
2098   - * @Description: TODO(班次换驾驶员)
2099   - */
2100   - public void persoChange(ScheduleRealInfo sch, String jGh){
2101   - if(sch.getjGh().equals(jGh))
2102   - return;
2103   - String jName = BasicData.allPerson.get(jGh);
2104   - if(StringUtils.isNotEmpty(jName)){
2105   - sch.setjGh(jGh);
2106   - sch.setjName(jName);
2107   - }
2108   - }
2109   -
2110   - /**
2111   - *
2112   - * @Title: persoChange
2113   - * @Description: TODO(班次换售票员)
2114   - */
2115   - public void persoChangeSPY(ScheduleRealInfo sch, String sGh){
2116   - if(sch.getsGh().equals(sGh))
2117   - return;
2118   - String sName = BasicData.allPerson.get(sGh);
2119   - if(StringUtils.isNotEmpty(sName)){
2120   - sch.setsGh(sGh);
2121   - sch.setsName(sName);
2122   - }
2123   - }
2124   -
2125   - /**
2126   - * 批量待发调整
2127   - */
2128   - @Override
2129   - public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) {
2130   - Map<String, Object> rs = new HashMap<>()
2131   - ,tempMap = new HashMap<>();
2132   - List<ScheduleRealInfo> list = new ArrayList<>();
2133   -
2134   - ScheduleRealInfo sch,next;
2135   - for(DfsjChange dc : dfsjcs){
2136   - if(StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj()))
2137   - continue;
2138   -
2139   - /*sch = dayOfSchedule.get(dc.getSchId());
2140   - if(sch==null)
2141   - continue;
2142   -
2143   - sch.setDfsjAll(dc.getNew_dfsj());
2144   - //重新计算终点时间
2145   - sch.calcEndTime();
2146   - list.add(sch);*/
2147   - tempMap = outgoAdjust(dc.getSchId(),"", dc.getNew_dfsj());
2148   -
2149   - if(tempMap.get("status").equals(ResponseCode.SUCCESS)){
2150   - list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts"));
2151   - }
2152   - //next=dayOfSchedule.next(sch);
2153   - /*if(next.getQdzName().equals(sch.getZdzName())){
2154   - next.setQdzArrDateJH(sch.getZdsj());
2155   - list.add(next);
2156   - }*/
2157   - }
2158   -
2159   - rs.put("status", ResponseCode.SUCCESS);
2160   - rs.put("ts", list);
2161   - return rs;
2162   - }
2163   -
2164   -
2165   - @Override
2166   - public Map<String, Object> findKMBC1(String jName, String clZbh,
2167   - String date, String enddate) {
2168   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate);
2169   - DecimalFormat format = new DecimalFormat("0.00");
2170   -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
2171   -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
2172   - int jhbc = 0,cjbc = 0,ljbc = 0;
2173   - double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;
2174   - float addMileage = 0l,remMileage = 0l;
2175   - Map<String,Object> map = new HashMap<String, Object>();
2176   - for(ScheduleRealInfo scheduleRealInfo : list){
2177   - if(scheduleRealInfo != null){
2178   - //计划里程(主任务过滤掉临加班次),
2179   - //烂班里程(主任务烂班),
2180   - //临加里程(主任务临加),
2181   - //计划班次,烂班班次,增加班次
2182   - tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
2183   - if(scheduleRealInfo.isSflj()){
2184   - addMileage += tempJhlc;
2185   - ljbc++;
2186   - }else{
2187   - jhlc += tempJhlc;
2188   - jhbc++;
2189   - if(scheduleRealInfo.getStatus() == -1){
2190   - remMileage += tempJhlc;
2191   - cjbc++;
2192   - }
2193   - }
2194   - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
2195   - //计算营运里程,空驶里程
2196   - if(childTaskPlans.isEmpty()){
2197   - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
2198   - || scheduleRealInfo.getBcType().equals("venting")){
2199   - ksgl += tempJhlc;
2200   - }else{
2201   - yygl += tempJhlc;
2202   - }
2203   - }else{
2204   - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
2205   - while(it.hasNext()){
2206   - ChildTaskPlan childTaskPlan = it.next();
2207   - if(childTaskPlan.getMileageType().equals("empty")){
2208   - ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
2209   - }else{
2210   - yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
2211   - }
2212   - }
2213   - }
2214   - }
2215   - }
2216   - map.put("jhlc", format.format(jhlc));
2217   - map.put("remMileage", format.format(remMileage));
2218   - map.put("addMileage", format.format(addMileage));
2219   - map.put("yygl", format.format(yygl));
2220   - map.put("ksgl", format.format(ksgl));
2221   - map.put("realMileage", format.format(yygl+ksgl));
2222   - map.put("jhbc", jhbc);
2223   - map.put("cjbc", cjbc);
2224   - map.put("ljbc", ljbc);
2225   - map.put("sjbc", jhbc-cjbc+ljbc);
2226   - return map;
2227   - }
2228   -
2229   - /**
2230   - * 调整班次类型
2231   - * @param id
2232   - * @param bcType
2233   - * @param remarks
2234   - * @return
2235   - */
2236   - @Override
2237   - public Map<String, Object> changeBcType(Long id, String bcType, String remarks) {
2238   - Map<String, Object> rs = new HashMap<>();
2239   -
2240   - try {
2241   - ScheduleRealInfo sch = dayOfSchedule.get(id);
2242   - if(sch != null){
2243   - sch.setBcType(bcType);
2244   - sch.addRemarks(remarks);
2245   - //有时间记录一下相关变更数据
2246   - rs.put("status", ResponseCode.SUCCESS);
2247   - rs.put("t", sch);
2248   - }
2249   - } catch (Exception e) {
2250   - logger.error("", e);
2251   - rs.put("status", ResponseCode.ERROR);
2252   - }
2253   -
2254   - return rs;
2255   - }
2256   -
2257   - @Override
2258   - public Map<String, Object> historySave(ScheduleRealInfo sch) {
2259   - Map<String, Object> rs = new HashMap<>();
2260   - rs.put("status", ResponseCode.ERROR);
2261   -
2262   - ScheduleRealInfo oldSch = super.findById(sch.getId());
2263   - //修改车辆
2264   - if(!oldSch.getClZbh().equals(sch.getClZbh())){
2265   - Set<String> allCar=BasicData.deviceId2NbbmMap.values();
2266   - if(!allCar.contains(sch.getClZbh())){
2267   - rs.put("msg", "无效的车辆自编号");
2268   - return rs;
2269   - }
2270   - else
2271   - oldSch.setClZbh(sch.getClZbh());
2272   - }
2273   -
2274   - //修改驾驶员
2275   - if(!oldSch.getjGh().equals(sch.getjGh())){
2276   - Map<String, String> allPer = BasicData.allPerson;
2277   - if(!allPer.containsKey(sch.getjGh())){
2278   - rs.put("msg", "无效的驾驶员");
2279   - return rs;
2280   - }
2281   - else{
2282   - oldSch.setjGh(sch.getjGh());
2283   - oldSch.setjName(allPer.get(oldSch.getjGh()));
2284   - }
2285   - }
2286   -
2287   - //修改售票员
2288   -/* if(!oldSch.getsGh().equals(sch.getsGh())){
2289   - Map<String, String> allPer = BasicData.allPerson;
2290   -
2291   - if(StringUtils.isNotEmpty(sch.getsGh())){
2292   - if(!allPer.containsKey(sch.getsGh())){
2293   - rs.put("msg", "无效的售票员");
2294   - return rs;
2295   - }
2296   - }
2297   - oldSch.setsGh(sch.getsGh());
2298   - oldSch.setsName(allPer.get(oldSch.getsGh()));
2299   - }*/
2300   -
2301   - //待发时间
2302   - oldSch.setDfsj(sch.getDfsj());
2303   - //实发时间
2304   - oldSch.setFcsjActual(sch.getFcsjActual());
2305   - //实际终点
2306   - oldSch.setZdsjActual(sch.getZdsjActual());
2307   - //备注
2308   - oldSch.setRemarks(sch.getRemarks());
2309   -
2310   - scheduleRealInfoRepository.save(oldSch);
2311   - rs.put("status", ResponseCode.SUCCESS);
2312   - return rs;
2313   - }
2314   -
2315   - @Override
2316   - public List<Map<String, Object>> yesterdayDataList(String line) {
2317   - // TODO Auto-generated method stub
2318   - return null;
2319   - }
2320   -
2321   - @Override
2322   - public Map<String, Object> MapById(Long id) {
2323   - // TODO Auto-generated method stub
2324   - Map<String, Object> map=new HashMap<String, Object>();
2325   - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
2326   - ScheduleRealInfo s=scheduleRealInfoRepository.findOne(id);
2327   - String xlbm=s.getXlBm();
2328   - String fcrq=s.getScheduleDateStr();
2329   -
2330   -
2331   - map.put("xlName", s.getXlName());
2332   - map.put("clZbh", s.getClZbh());
2333   - map.put("fcsjActual", s.getFcsjActual());
2334   - map.put("zdzName", s.getZdzName());
2335   - map.put("scheduleDate", s.getScheduleDateStr());
2336   - String zdp="",zwdp="",wdp="";
2337   -
2338   - List<DutyEmployee> list= dutyEmployeeService.getDutyEmployee(xlbm, fcrq+"00:00", fcrq+"23:59");
2339   - try {
2340   - Long fcsj1=sdf.parse(fcrq+" 03:00").getTime();
2341   - Long fcsj2=sdf.parse(fcrq+" 11:00").getTime();
2342   - Long fcsj3=sdf.parse(fcrq+" 22:00").getTime();
2343   - for(int i=0;i<list.size();i++){
2344   - DutyEmployee t=list.get(i);
2345   - Long ts=t.getTs();
2346   - if(ts>fcsj1&&ts<fcsj2){
2347   - if(zdp.indexOf(t.getuName())==-1){
2348   - zdp +=t.getuName()+",";
2349   - }
2350   - }else if(ts>fcsj2 && ts<fcsj3){
2351   - if(zwdp.indexOf(t.getuName())==-1){
2352   - zwdp +=t.getuName()+",";
2353   - }
2354   - }else{
2355   - if(wdp.indexOf(t.getuName())==-1){
2356   - wdp +=t.getuName()+",";
2357 2365 }
  2366 + } catch (ParseException e) {
  2367 + // TODO Auto-generated catch block
  2368 + e.printStackTrace();
2358 2369 }
2359   - }
2360   - } catch (ParseException e) {
2361   - // TODO Auto-generated catch block
2362   - e.printStackTrace();
2363   - }
2364   - map.put("zdp", zdp);
2365   - map.put("zwdp", zwdp);
2366   - map.put("wdp", wdp);
2367   - return map;
  2370 + map.put("zdp", zdp);
  2371 + map.put("zwdp", zwdp);
  2372 + map.put("wdp", wdp);
  2373 + return map;
2368 2374 }
2369 2375  
2370   -}
  2376 +}
2371 2377 \ No newline at end of file
... ...
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
... ... @@ -17,6 +17,7 @@ import java.util.List;
17 17 import java.util.Map;
18 18 import java.util.Set;
19 19  
  20 +import org.drools.compiler.lang.DRL5Expressions.type_return;
20 21 import org.springframework.beans.factory.annotation.Autowired;
21 22 import org.springframework.jdbc.core.JdbcTemplate;
22 23 import org.springframework.jdbc.core.RowMapper;
... ... @@ -1012,6 +1013,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1012 1013 String line = map.get("line").toString();
1013 1014 String date = map.get("date").toString();
1014 1015 String code = map.get("code").toString();
  1016 + String type = map.get("type").toString();
1015 1017  
1016 1018 if(date.length() == 0)
1017 1019 date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
... ... @@ -1042,8 +1044,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1042 1044 if(company.length() != 0){
1043 1045 sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
1044 1046 }
1045   - sql += " order by fcsj";
1046   -
  1047 + sql += " order by xl_name, fcsj";
  1048 +
1047 1049 list = jdbcTemplate.query(sql,
1048 1050 new RowMapper<Map<String, Object>>(){
1049 1051 @Override
... ... @@ -1072,8 +1074,13 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1072 1074 e.printStackTrace();
1073 1075 }
1074 1076  
  1077 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  1078 + List<String> keyList = new ArrayList<String>();
1075 1079 for(Map<String, Object> m : list){
1076 1080 String key = m.get("line") + "/" + m.get("clZbh") + "/" + m.get("jGh") + "/" + m.get("jName");
  1081 + if(!keyList.contains(m.get("line").toString())){
  1082 + keyList.add(m.get("line").toString());
  1083 + }
1077 1084 if(!keyMap.containsKey(key))
1078 1085 keyMap.put(key, new ArrayList<Map<String, Object>>());
1079 1086 keyMap.get(key).add(m);
... ... @@ -1120,7 +1127,58 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1120 1127 tempMap.put("sjf", sjf);
1121 1128 tempMap.put("wqr", wqr);
1122 1129 tempMap.put("workList", keyMap.get(key));
1123   - resList.add(tempMap);
  1130 + tempList.add(tempMap);
  1131 + }
  1132 +
  1133 + for(String key : keyList){
  1134 + for(Map<String, Object> m : tempList){
  1135 + if(key.equals(m.get("line").toString())){
  1136 + resList.add(m);
  1137 + }
  1138 + }
  1139 + }
  1140 +
  1141 + if(type.equals("export")){
  1142 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1143 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1144 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1145 + Map<String,Object> m = new HashMap<String, Object>();
  1146 + ReportUtils ee = new ReportUtils();
  1147 + try {
  1148 + listI.add(resList.iterator());
  1149 + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
  1150 + ee.excelReplace(listI, new Object[] { m }, path+"mould\\commandState.xls",
  1151 + path+"export\\指令状态分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  1152 + } catch (Exception e) {
  1153 + // TODO: handle exception
  1154 + e.printStackTrace();
  1155 + }
  1156 + }
  1157 +
  1158 + if(type.equals("export1")){
  1159 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  1160 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  1161 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  1162 + Map<String,Object> m = new HashMap<String, Object>();
  1163 + ReportUtils ee = new ReportUtils();
  1164 + String jsy = map.get("jsy").toString();
  1165 + try {
  1166 + for(Map<String, Object> map1 : resList){
  1167 + if(jsy.equals(map1.get("jsy").toString())){
  1168 + List<Map<String, Object>> temp = (List<Map<String, Object>>)map1.get("workList");
  1169 + listI.add(temp.iterator());
  1170 + m.put("detail", "日期:" + map1.get("date") + " 公司:" + map1.get("company")
  1171 + + " 分公司:" + map1.get("subCompany") + " 线路:" + map1.get("line")
  1172 + + " 车辆:" + map1.get("clZbh") + " 人员:" + map1.get("jsy"));
  1173 + }
  1174 + }
  1175 + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
  1176 + ee.excelReplace(listI, new Object[] { m }, path+"mould\\commandState1.xls",
  1177 + path+"export\\指令状态明细" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  1178 + } catch (Exception e) {
  1179 + // TODO: handle exception
  1180 + e.printStackTrace();
  1181 + }
1124 1182 }
1125 1183  
1126 1184 return resList;
... ...
src/main/resources/datatools/ktrs/ttinfodetailDataInput.ktr
... ... @@ -137,6 +137,48 @@
137 137 <bordercolorblue>100</bordercolorblue>
138 138 <drawshadow>Y</drawshadow>
139 139 </notepad>
  140 + <notepad>
  141 + <note>&#x51fa;&#x573a;&#x73ed;&#x6b21;&#xff0c;&#x65b9;&#x5411;&#x6709;&#x65f6;&#x786e;&#x5b9a;&#x4e0d;&#x51c6;&#xff0c;&#xa;&#x7a7a;&#x7684;&#x60c5;&#x51b5;&#x4e0b;&#x8bbe;&#x5b9a;&#x4e3a;0&#xff08;&#x4e0a;&#x884c;&#xff09;</note>
  142 + <xloc>120</xloc>
  143 + <yloc>1016</yloc>
  144 + <width>178</width>
  145 + <heigth>42</heigth>
  146 + <fontname>YaHei Consolas Hybrid</fontname>
  147 + <fontsize>12</fontsize>
  148 + <fontbold>N</fontbold>
  149 + <fontitalic>N</fontitalic>
  150 + <fontcolorred>0</fontcolorred>
  151 + <fontcolorgreen>0</fontcolorgreen>
  152 + <fontcolorblue>0</fontcolorblue>
  153 + <backgroundcolorred>255</backgroundcolorred>
  154 + <backgroundcolorgreen>205</backgroundcolorgreen>
  155 + <backgroundcolorblue>112</backgroundcolorblue>
  156 + <bordercolorred>100</bordercolorred>
  157 + <bordercolorgreen>100</bordercolorgreen>
  158 + <bordercolorblue>100</bordercolorblue>
  159 + <drawshadow>Y</drawshadow>
  160 + </notepad>
  161 + <notepad>
  162 + <note>&#x8fdb;&#x573a;&#x73ed;&#x6b21;&#xff0c;&#x65b9;&#x5411;&#x6709;&#x65f6;&#x786e;&#x5b9a;&#x4e0d;&#x51c6;&#xff0c;&#xa;&#x7a7a;&#x7684;&#x60c5;&#x51b5;&#x4e0b;&#x8bbe;&#x5b9a;&#x4e3a;0&#xff08;&#x4e0a;&#x884c;&#xff09;</note>
  163 + <xloc>578</xloc>
  164 + <yloc>1084</yloc>
  165 + <width>178</width>
  166 + <heigth>42</heigth>
  167 + <fontname>YaHei Consolas Hybrid</fontname>
  168 + <fontsize>12</fontsize>
  169 + <fontbold>N</fontbold>
  170 + <fontitalic>N</fontitalic>
  171 + <fontcolorred>0</fontcolorred>
  172 + <fontcolorgreen>0</fontcolorgreen>
  173 + <fontcolorblue>0</fontcolorblue>
  174 + <backgroundcolorred>255</backgroundcolorred>
  175 + <backgroundcolorgreen>205</backgroundcolorgreen>
  176 + <backgroundcolorblue>112</backgroundcolorblue>
  177 + <bordercolorred>100</bordercolorred>
  178 + <bordercolorgreen>100</bordercolorgreen>
  179 + <bordercolorblue>100</bordercolorblue>
  180 + <drawshadow>Y</drawshadow>
  181 + </notepad>
140 182 </notepads>
141 183 <connection>
142 184 <name>bus_control_variable</name>
... ... @@ -342,10 +384,12 @@
342 384 <hop> <from>&#x67e5;&#x627e;&#x8fdb;&#x573a;&#x73ed;&#x6b21;&#x4e0a;&#x4e00;&#x4e2a;&#x73ed;&#x6b21;&#x7684;&#x7ec8;&#x70b9;&#x7ad9;&#xff0c;&#x5e76;&#x4f5c;&#x4e3a;&#x8fdb;&#x573a;&#x73ed;&#x6b21;&#x7684;&#x8d77;&#x70b9;&#x7ad9;</from><to>&#x67e5;&#x627e;&#x8fdb;&#x573a;&#x8d77;&#x70b9;&#x7ad9;&#x5173;&#x8054;&#x786e;&#x5b9a;&#x4e0a;&#x4e0b;&#x884c;</to><enabled>Y</enabled> </hop>
343 385 <hop> <from>&#x67e5;&#x627e;&#x8fdb;&#x573a;&#x8d77;&#x70b9;&#x7ad9;&#x5173;&#x8054;&#x786e;&#x5b9a;&#x4e0a;&#x4e0b;&#x884c;</from><to>&#x4e0a;&#x4e0b;&#x884c;&#x5b57;&#x5178; 3</to><enabled>Y</enabled> </hop>
344 386 <hop> <from>&#x67e5;&#x627e;&#x7ebf;&#x8def;&#x51fa;&#x573a;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</from><to>&#x5339;&#x914d;&#x51fa;&#x573a;&#x73ed;&#x6b21;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</to><enabled>Y</enabled> </hop>
345   - <hop> <from>&#x5339;&#x914d;&#x51fa;&#x573a;&#x73ed;&#x6b21;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</from><to>&#x7c7b;&#x578b;&#x4fee;&#x6b63; 2</to><enabled>Y</enabled> </hop>
346   - <hop> <from>&#x7c7b;&#x578b;&#x4fee;&#x6b63; 2</from><to>&#x63d2;&#x5165;&#x2f;&#x66f4;&#x65b0;bsth_c_s_ttinfo_detail 2</to><enabled>Y</enabled> </hop>
347 387 <hop> <from>&#x67e5;&#x627e;&#x7ebf;&#x8def;&#x8fdb;&#x573a;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</from><to>&#x5339;&#x914d;&#x8fdb;&#x573a;&#x73ed;&#x6b21;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</to><enabled>Y</enabled> </hop>
348   - <hop> <from>&#x5339;&#x914d;&#x8fdb;&#x573a;&#x73ed;&#x6b21;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</from><to>&#x7c7b;&#x578b;&#x4fee;&#x6b63; 3</to><enabled>Y</enabled> </hop>
  388 + <hop> <from>&#x5339;&#x914d;&#x51fa;&#x573a;&#x73ed;&#x6b21;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</from><to>&#x4e0a;&#x4e0b;&#x884c;NULL&#x5224;&#x5b9a;</to><enabled>Y</enabled> </hop>
  389 + <hop> <from>&#x4e0a;&#x4e0b;&#x884c;NULL&#x5224;&#x5b9a;</from><to>&#x7c7b;&#x578b;&#x4fee;&#x6b63; 2</to><enabled>Y</enabled> </hop>
  390 + <hop> <from>&#x7c7b;&#x578b;&#x4fee;&#x6b63; 2</from><to>&#x63d2;&#x5165;&#x2f;&#x66f4;&#x65b0;bsth_c_s_ttinfo_detail 2</to><enabled>Y</enabled> </hop>
  391 + <hop> <from>&#x5339;&#x914d;&#x8fdb;&#x573a;&#x73ed;&#x6b21;&#x91cc;&#x7a0b;&#x65f6;&#x95f4;</from><to>&#x4e0a;&#x4e0b;&#x884c;&#x5224;&#x5b9a; 2</to><enabled>Y</enabled> </hop>
  392 + <hop> <from>&#x4e0a;&#x4e0b;&#x884c;&#x5224;&#x5b9a; 2</from><to>&#x7c7b;&#x578b;&#x4fee;&#x6b63; 3</to><enabled>Y</enabled> </hop>
349 393 <hop> <from>&#x7c7b;&#x578b;&#x4fee;&#x6b63; 3</from><to>&#x63d2;&#x5165;&#x2f;&#x66f4;&#x65b0;bsth_c_s_ttinfo_detail 3</to><enabled>Y</enabled> </hop>
350 394 </order>
351 395 <step>
... ... @@ -1051,8 +1095,8 @@
1051 1095 </lookup>
1052 1096 <cluster_schema/>
1053 1097 <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
1054   - <xloc>342</xloc>
1055   - <yloc>1031</yloc>
  1098 + <xloc>340</xloc>
  1099 + <yloc>1087</yloc>
1056 1100 <draw>Y</draw>
1057 1101 </GUI>
1058 1102 </step>
... ... @@ -1172,8 +1216,8 @@
1172 1216 </lookup>
1173 1217 <cluster_schema/>
1174 1218 <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
1175   - <xloc>875</xloc>
1176   - <yloc>887</yloc>
  1219 + <xloc>845</xloc>
  1220 + <yloc>899</yloc>
1177 1221 <draw>Y</draw>
1178 1222 </GUI>
1179 1223 </step>
... ... @@ -2450,10 +2494,25 @@
2450 2494 <grouping_symbol/>
2451 2495 <currency_symbol/>
2452 2496 <storage_type/>
  2497 + </meta> <meta> <name>sxx</name>
  2498 + <rename>sxx</rename>
  2499 + <type>Integer</type>
  2500 + <length>-2</length>
  2501 + <precision>-2</precision>
  2502 + <conversion_mask/>
  2503 + <date_format_lenient>false</date_format_lenient>
  2504 + <date_format_locale/>
  2505 + <date_format_timezone/>
  2506 + <lenient_string_to_number>false</lenient_string_to_number>
  2507 + <encoding/>
  2508 + <decimal_symbol/>
  2509 + <grouping_symbol/>
  2510 + <currency_symbol/>
  2511 + <storage_type/>
2453 2512 </meta> </fields> <cluster_schema/>
2454 2513 <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
2455 2514 <xloc>338</xloc>
2456   - <yloc>949</yloc>
  2515 + <yloc>1008</yloc>
2457 2516 <draw>Y</draw>
2458 2517 </GUI>
2459 2518 </step>
... ... @@ -2500,10 +2559,25 @@
2500 2559 <grouping_symbol/>
2501 2560 <currency_symbol/>
2502 2561 <storage_type/>
  2562 + </meta> <meta> <name>sxx2</name>
  2563 + <rename>sxx2</rename>
  2564 + <type>Integer</type>
  2565 + <length>-2</length>
  2566 + <precision>-2</precision>
  2567 + <conversion_mask/>
  2568 + <date_format_lenient>false</date_format_lenient>
  2569 + <date_format_locale/>
  2570 + <date_format_timezone/>
  2571 + <lenient_string_to_number>false</lenient_string_to_number>
  2572 + <encoding/>
  2573 + <decimal_symbol/>
  2574 + <grouping_symbol/>
  2575 + <currency_symbol/>
  2576 + <storage_type/>
2503 2577 </meta> </fields> <cluster_schema/>
2504 2578 <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
2505   - <xloc>875</xloc>
2506   - <yloc>1001</yloc>
  2579 + <xloc>847</xloc>
  2580 + <yloc>1003</yloc>
2507 2581 <draw>Y</draw>
2508 2582 </GUI>
2509 2583 </step>
... ... @@ -2667,10 +2741,78 @@
2667 2741 </GUI>
2668 2742 </step>
2669 2743  
  2744 + <step>
  2745 + <name>&#x4e0a;&#x4e0b;&#x884c;NULL&#x5224;&#x5b9a;</name>
  2746 + <type>IfNull</type>
  2747 + <description/>
  2748 + <distribute>Y</distribute>
  2749 + <custom_distribution/>
  2750 + <copies>1</copies>
  2751 + <partitioning>
  2752 + <method>none</method>
  2753 + <schema_name/>
  2754 + </partitioning>
  2755 + <replaceAllByValue/>
  2756 + <replaceAllMask/>
  2757 + <selectFields>Y</selectFields>
  2758 + <selectValuesType>N</selectValuesType>
  2759 + <setEmptyStringAll>N</setEmptyStringAll>
  2760 + <valuetypes>
  2761 + </valuetypes>
  2762 + <fields>
  2763 + <field>
  2764 + <name>sxx</name>
  2765 + <value>0</value>
  2766 + <mask/>
  2767 + <set_empty_string>N</set_empty_string>
  2768 + </field>
  2769 + </fields>
  2770 + <cluster_schema/>
  2771 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  2772 + <xloc>230</xloc>
  2773 + <yloc>946</yloc>
  2774 + <draw>Y</draw>
  2775 + </GUI>
  2776 + </step>
  2777 +
  2778 + <step>
  2779 + <name>&#x4e0a;&#x4e0b;&#x884c;&#x5224;&#x5b9a; 2</name>
  2780 + <type>IfNull</type>
  2781 + <description/>
  2782 + <distribute>Y</distribute>
  2783 + <custom_distribution/>
  2784 + <copies>1</copies>
  2785 + <partitioning>
  2786 + <method>none</method>
  2787 + <schema_name/>
  2788 + </partitioning>
  2789 + <replaceAllByValue/>
  2790 + <replaceAllMask/>
  2791 + <selectFields>Y</selectFields>
  2792 + <selectValuesType>N</selectValuesType>
  2793 + <setEmptyStringAll>N</setEmptyStringAll>
  2794 + <valuetypes>
  2795 + </valuetypes>
  2796 + <fields>
  2797 + <field>
  2798 + <name>sxx2</name>
  2799 + <value>0</value>
  2800 + <mask/>
  2801 + <set_empty_string>N</set_empty_string>
  2802 + </field>
  2803 + </fields>
  2804 + <cluster_schema/>
  2805 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  2806 + <xloc>804</xloc>
  2807 + <yloc>1081</yloc>
  2808 + <draw>Y</draw>
  2809 + </GUI>
  2810 + </step>
  2811 +
2670 2812 <step_error_handling>
2671 2813 <error>
2672 2814 <source_step>&#x63d2;&#x5165;&#x2f;&#x66f4;&#x65b0;bsth_c_s_ttinfo_detail</source_step>
2673   - <target_step>Excel&#x8f93;&#x51fa;</target_step>
  2815 + <target_step/>
2674 2816 <is_enabled>Y</is_enabled>
2675 2817 <nr_valuename>c1</nr_valuename>
2676 2818 <descriptions_valuename>c2</descriptions_valuename>
... ...
src/main/resources/static/pages/forms/mould/account.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/allline.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/commandState.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/mould/commandState1.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/mould/correctForm.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/mould/daily.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/historyMessage.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/message.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/statement/commandState.html
... ... @@ -50,7 +50,7 @@
50 50 </div>
51 51 <div class="form-group" style="margin-left: 9px">
52 52 <input class="btn btn-default" type="button" id="query" value="筛选"/>
53   -<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> -->
  53 + <input class="btn btn-default" type="button" id="export" value="导出"/>
54 54 </div>
55 55 </form>
56 56 </div>
... ... @@ -74,16 +74,23 @@
74 74  
75 75 </tbody>
76 76 </table>
  77 + <div id="box">&nbsp;</div>
77 78 <div id="works_hidden" class="hidden">
78 79 <span class="item-label" style="width: 80px;margin-left: 20px;">明细: </span>
79 80 <span class="item-label" style="width: 80px;margin-left: 60px;">日期 </span>
80 81 <span class="item-label" style="width: 80px;" id="date1"></span>
  82 + <span class="item-label" style="width: 80px;margin-left: 60px;">公司 </span>
  83 + <span class="item-label" style="width: 80px;" id="company2"></span>
  84 + <span class="item-label" style="width: 80px;margin-left: 60px;">分公司 </span>
  85 + <span class="item-label" style="width: 80px;" id="subCompany2"></span>
81 86 <span class="item-label" style="width: 80px;margin-left: 60px;">线路 </span>
82 87 <span class="item-label" style="width: 80px;" id="line1"></span>
83 88 <span class="item-label" style="width: 80px;margin-left: 60px;">车辆 </span>
84 89 <span class="item-label" style="width: 80px;" id="clZbh1"></span>
85 90 <span class="item-label" style="width: 80px;margin-left: 60px;">人员 </span>
86 91 <span class="item-label" style="width: 80px;" id="jsy1"></span>
  92 + <span class="item-label" style="width: 80px;margin-left: 60px;"></span>
  93 + <input class="btn btn-default" type="button" id="export1" value="导出当前明细"/>
87 94 </div>
88 95 <table class="table table-bordered table-hover table-checkable" id="works">
89 96 <thead>
... ... @@ -112,6 +119,7 @@
112 119  
113 120 <script>
114 121 $(function(){
  122 + $('#export').attr('disabled', "true");
115 123 var list;
116 124  
117 125 // 关闭左侧栏
... ... @@ -136,7 +144,7 @@
136 144 $.get('/basic/lineCode2Name',function(result){
137 145 var data=[];
138 146  
139   - data.push({id: "", text: "全部线路"});
  147 + data.push({id: " ", text: "全部线路"});
140 148 for(var code in result){
141 149 data.push({id: code, text: result[code]});
142 150 }
... ... @@ -217,16 +225,26 @@
217 225  
218 226 $("#query").on("click",jsDoQuery);
219 227  
  228 + var line = "";
  229 + var date = $("#date").val();
  230 + var code = $("#code").val();
  231 + var company = $("#company").val();
  232 + var subCompany = $("#subCompany").val();
220 233 function jsDoQuery(pagination){
221 234 var params = {};
222   - var line = $("#line").val();
223   - if(line = " ")
  235 + line = $("#line").val();
  236 + if(line == " ")
224 237 line = "";
  238 + date = $("#date").val();
  239 + code = $("#code").val();
  240 + company = $("#company").val();
  241 + subCompany = $("#subCompany").val();
225 242 params['line'] = line;
226   - params['date'] = $("#date").val();
227   - params['code'] = $("#code").val();
228   - params['company'] = $("#company").val();
229   - params['subCompany'] = $("#subCompany").val();
  243 + params['date'] = date;
  244 + params['code'] = code;
  245 + params['type'] = "query";
  246 + params['company'] = company;
  247 + params['subCompany'] = subCompany;
230 248 $("#forms .hidden").removeClass("hidden");
231 249 $get('/pcpc/commandState', params, function(result){
232 250 // 把数据填充到模版中
... ... @@ -235,29 +253,69 @@
235 253 // 把渲染好的模版html文本追加到表格中
236 254 $('#forms tbody').html(tbodyHtml);
237 255  
  256 + if(result.length == 0){
  257 + $('#export').attr('disabled', "true");
  258 + } else {
  259 + $("#export").removeAttr("disabled");
  260 + }
  261 +
  262 + $("#works_hidden").removeClass("hidden");
  263 + $("#works .hidden").removeClass("hidden");
  264 + $("#works_hidden").addClass("hidden");
  265 + $("#works").addClass("hidden");
  266 +
238 267 });
239 268 }
240 269  
241 270 $("#export").on("click",function(){
242   - $('#forms').tableExport({ type: 'excel', escape: 'false',filename:'(2016-02-29_2016-03-06)'});
  271 + var params = {};
  272 + params['line'] = line;
  273 + params['date'] = date;
  274 + params['code'] = code;
  275 + params['type'] = "export";
  276 + params['company'] = company;
  277 + params['subCompany'] = subCompany;
  278 + $get('/pcpc/commandState', params, function(result){
  279 + window.open("/downloadFile/download?fileName=指令状态分析"+moment(date).format("YYYYMMDD"));
  280 + });
243 281 });
244 282  
  283 + var jsy = "";
245 284 $("#forms tbody").on("click","a",function(){
246   - var jsy = $(this).html();
  285 + jsy = $(this).html();
247 286 $.each(list, function(i, g){
248 287 if(jsy == g.jsy){
249 288 $("#date1").html(g.date);
250 289 $("#line1").html(g.line);
251 290 $("#clZbh1").html(g.clZbh);
252 291 $("#jsy1").html(g.jsy);
  292 + $("#company2").html(g.company);
  293 + $("subCompany2").html(g.subCompany);
253 294 $("#works_hidden").removeClass("hidden");
254   - $("#works .hidden").removeClass("hidden");
  295 + $("#works").removeClass("hidden");
255 296 // 把数据填充到模版中
256 297 var tbodyHtml = template('list_workList',{list:g.workList});
257 298 // 把渲染好的模版html文本追加到表格中
258 299 $('#works tbody').html(tbodyHtml);
259 300 }
260 301 });
  302 +
  303 + $("html,body").animate({scrollTop:$("#box").offset().top},1000);
  304 +
  305 + });
  306 +
  307 + $("#export1").on("click",function(){
  308 + var params = {};
  309 + params['jsy'] = jsy;
  310 + params['line'] = line;
  311 + params['date'] = date;
  312 + params['code'] = code;
  313 + params['type'] = "export1";
  314 + params['company'] = company;
  315 + params['subCompany'] = subCompany;
  316 + $get('/pcpc/commandState', params, function(result){
  317 + window.open("/downloadFile/download?fileName=指令状态明细"+moment(date).format("YYYYMMDD"));
  318 + });
261 319 });
262 320  
263 321  
... ...
src/main/resources/static/pages/forms/statement/correctForm.html
... ... @@ -49,7 +49,7 @@
49 49 </div>
50 50 <div class="form-group">
51 51 <input class="btn btn-default" type="button" id="query" value="筛选"/>
52   -<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> -->
  52 + <input class="btn btn-default" type="button" id="export" value="导出"/>
53 53 </div>
54 54 </form>
55 55 </div>
... ...
src/main/resources/static/pages/forms/statement/historyMessage.html
... ... @@ -139,7 +139,7 @@
139 139 code = $("#code").val();
140 140 var type = "query";
141 141 $(".hidden").removeClass("hidden");
142   - $get('/realSchedule/historyMessage',{line:line,date:date,code:code},function(result){
  142 + $get('/realSchedule/historyMessage',{line:line,date:date,code:code,type:type},function(result){
143 143 // 把数据填充到模版中
144 144 var tbodyHtml = template('list_history',{list:result});
145 145 // 把渲染好的模版html文本追加到表格中
... ...
src/main/resources/static/pages/forms/statement/waybillQp.html
... ... @@ -342,7 +342,7 @@
342 342 <td>{{map.jhbc}}</td>
343 343 <td colspan="2">进出场公里</td>
344 344 <td>{{map.jcclc}}</td>
345   - <td >临加公里</td>
  345 + <td >加车公里</td>
346 346 <td>{{map.ljgl}}</td>
347 347 <td colspan="2">损失班次</td>
348 348 <td colspan="1">{{map.ssbc}}</td>
... ... @@ -355,7 +355,7 @@
355 355 <td>{{map.sjbc}}</td>
356 356 <td colspan="2">总公里</td>
357 357 <td>{{map.zgl}}</td>
358   - <td >临加班次</td>
  358 + <td >加车班次</td>
359 359 <td>{{map.ljbc}}</td>
360 360  
361 361 <td colspan="3"></td>
... ...