Commit d2dcc317b4e6386b9726686128d62ab33b9b3acc
Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
Showing
16 changed files
with
657 additions
and
363 deletions
Too many changes to show.
To preserve performance only 16 of 28 files are displayed.
pom.xml
| @@ -259,11 +259,11 @@ | @@ -259,11 +259,11 @@ | ||
| 259 | </dependency> | 259 | </dependency> |
| 260 | 260 | ||
| 261 | 261 | ||
| 262 | - <!--<dependency>--> | ||
| 263 | - <!--<groupId>ojdbc</groupId>--> | ||
| 264 | - <!--<artifactId>ojdbc</artifactId>--> | ||
| 265 | - <!--<version>14</version>--> | ||
| 266 | - <!--</dependency>--> | 262 | + <dependency> |
| 263 | + <groupId>ojdbc</groupId> | ||
| 264 | + <artifactId>ojdbc</artifactId> | ||
| 265 | + <version>14</version> | ||
| 266 | + </dependency> | ||
| 267 | </dependencies> | 267 | </dependencies> |
| 268 | 268 | ||
| 269 | <dependencyManagement> | 269 | <dependencyManagement> |
src/main/java/com/bsth/controller/report/ReportController.java
| @@ -51,6 +51,7 @@ public class ReportController { | @@ -51,6 +51,7 @@ public class ReportController { | ||
| 51 | m.put("jzsj", a.getJzsj()); | 51 | m.put("jzsj", a.getJzsj()); |
| 52 | m.put("czsj", a.getCzsj()); | 52 | m.put("czsj", a.getCzsj()); |
| 53 | m.put("upDown", a.getUpDown()==0?"上行":"下行"); | 53 | m.put("upDown", a.getUpDown()==0?"上行":"下行"); |
| 54 | + resList.add(m); | ||
| 54 | i++; | 55 | i++; |
| 55 | } | 56 | } |
| 56 | 57 | ||
| @@ -66,41 +67,61 @@ public class ReportController { | @@ -66,41 +67,61 @@ public class ReportController { | ||
| 66 | return resList; | 67 | return resList; |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 70 | + | ||
| 69 | @RequestMapping(value="/queryListClzd" ,method = RequestMethod.GET) | 71 | @RequestMapping(value="/queryListClzd" ,method = RequestMethod.GET) |
| 70 | public List<ArrivalInfo> queryListClzd(@RequestParam String zd,@RequestParam String line, | 72 | public List<ArrivalInfo> queryListClzd(@RequestParam String zd,@RequestParam String line, |
| 71 | @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){ | 73 | @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){ |
| 72 | return service.queryListClzd(line,zd,zdlx,fcsj,ddsj); | 74 | return service.queryListClzd(line,zd,zdlx,fcsj,ddsj); |
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | - @RequestMapping(value="/exportQueryListClzd" ,method = RequestMethod.GET) | ||
| 76 | - public List<Map<String, Object>> exportQueryListClzd(@RequestParam String zd,@RequestParam String line, | ||
| 77 | - @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){ | 77 | + |
| 78 | + | ||
| 79 | + | ||
| 80 | + @RequestMapping(value="/jobSummaryExport" ,method = RequestMethod.GET) | ||
| 81 | + public List<Map<String, Object>> jobSummaryExport(@RequestParam Map<String, Object> map){ | ||
| 78 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | 82 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); |
| 83 | + String lineName=map.get("lineName").toString(); | ||
| 84 | + String date=map.get("date").toString(); | ||
| 79 | ReportUtils ee = new ReportUtils(); | 85 | ReportUtils ee = new ReportUtils(); |
| 80 | - List<ArrivalInfo> list=service.queryListClzd(line, zd, zdlx, fcsj, ddsj); | ||
| 81 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 82 | - int i=1; | ||
| 83 | - for (ArrivalInfo a:list ) { | ||
| 84 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 85 | - m.put("i", i); | ||
| 86 | - m.put("nbbm", a.getNbbm()); | ||
| 87 | - m.put("stopName", a.getStopName()); | ||
| 88 | - m.put("jzsj", a.getJzsj()); | ||
| 89 | - m.put("czsj", a.getCzsj()); | ||
| 90 | - m.put("upDown", a.getUpDown()==0?"上行":"下行"); | ||
| 91 | - i++; | 86 | + List<Map<String,Object>> fwqlList= service.jobFwqk(map); |
| 87 | + List<Map<String, Object>> lgqlList=service.jobLjqk(map); | ||
| 88 | + map=service.jobHzxx(map); | ||
| 89 | + map.put("lineName", lineName); | ||
| 90 | + map.put("date",date); | ||
| 91 | + if(fwqlList.size()<=0){ | ||
| 92 | + Map<String, Object> newMap=new HashMap<String,Object>(); | ||
| 93 | + newMap.put("nr", " "); | ||
| 94 | + newMap.put("lp", " "); | ||
| 95 | + newMap.put("nbbm", " "); | ||
| 96 | + newMap.put("jgh", " "); | ||
| 97 | + newMap.put("dz", " "); | ||
| 98 | + newMap.put("sj", " "); | ||
| 99 | + newMap.put("lbbc", " "); | ||
| 100 | + newMap.put("lblc", " "); | ||
| 101 | + newMap.put("jyqp", " "); | ||
| 102 | + fwqlList.add(newMap); | ||
| 103 | + } | ||
| 104 | + if(lgqlList.size()<=0){ | ||
| 105 | + Map<String, Object> newMap=new HashMap<String,Object>(); | ||
| 106 | + newMap.put("lp", " "); | ||
| 107 | + newMap.put("nbbm", " "); | ||
| 108 | + newMap.put("jgh", " "); | ||
| 109 | + newMap.put("dz", " "); | ||
| 110 | + newMap.put("sj", " "); | ||
| 111 | + newMap.put("ljlc"," "); | ||
| 112 | + newMap.put("jyqp", " "); | ||
| 113 | + lgqlList.add(newMap); | ||
| 92 | } | 114 | } |
| 93 | - | ||
| 94 | try { | 115 | try { |
| 95 | - Map<String, Object> map=new HashMap<String, Object>(); | ||
| 96 | - listI.add(resList.iterator()); | 116 | + listI.add(fwqlList.iterator()); |
| 117 | + listI.add(lgqlList.iterator()); | ||
| 97 | String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | 118 | String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; |
| 98 | - ee.excelReplace(listI, new Object[] { map }, path + "mould/inoutstation.xls", | ||
| 99 | - path + "export/班次到离站.xls"); | 119 | + ee.excelReplace(listI, new Object[] { map }, path + "mould/jobSummary.xls", |
| 120 | + path + "export/调度员工作汇总日报.xls"); | ||
| 100 | } catch (Exception e) { | 121 | } catch (Exception e) { |
| 101 | e.printStackTrace(); | 122 | e.printStackTrace(); |
| 102 | } | 123 | } |
| 103 | - return resList; | 124 | + return new ArrayList<Map<String, Object>>(); |
| 104 | } | 125 | } |
| 105 | @RequestMapping(value = "/sreachZd", method = RequestMethod.GET) | 126 | @RequestMapping(value = "/sreachZd", method = RequestMethod.GET) |
| 106 | public List<Map<String, String>> sreachPersonnel(@RequestParam String line,@RequestParam int zdlx,@RequestParam String zd) { | 127 | public List<Map<String, String>> sreachPersonnel(@RequestParam String line,@RequestParam int zdlx,@RequestParam String zd) { |
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
| 1 | - | ||
| 2 | -package com.bsth.data.schedule.late_adjust; | ||
| 3 | - | ||
| 4 | -import com.bsth.data.BasicData; | ||
| 5 | -import com.bsth.data.LineConfigData; | ||
| 6 | -import com.bsth.data.gpsdata.GpsEntity; | ||
| 7 | -import com.bsth.entity.realcontrol.LineConfig; | ||
| 8 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 9 | -import com.bsth.util.Arith; | ||
| 10 | -import com.bsth.websocket.handler.SendUtils; | ||
| 11 | -import org.slf4j.Logger; | ||
| 12 | -import org.slf4j.LoggerFactory; | ||
| 13 | -import org.springframework.beans.BeansException; | ||
| 14 | -import org.springframework.context.ApplicationContext; | ||
| 15 | -import org.springframework.context.ApplicationContextAware; | ||
| 16 | -import org.springframework.stereotype.Component; | ||
| 17 | - | ||
| 18 | -import java.util.Collection; | ||
| 19 | -import java.util.HashMap; | ||
| 20 | -import java.util.Map; | ||
| 21 | - | ||
| 22 | -/** | ||
| 23 | - * 误点自动调整待发 处理程序 | ||
| 24 | - * | ||
| 25 | - * 注意 :这里的误点是指应发未到 | ||
| 26 | - * Created by panzhao on 2017/4/16. | ||
| 27 | - */ | ||
| 28 | -@Component | ||
| 29 | -public class LateAdjustHandle implements ApplicationContextAware{ | ||
| 30 | - | ||
| 31 | - static LineConfigData lineConfigData; | ||
| 32 | - static SendUtils sendUtils; | ||
| 33 | - | ||
| 34 | - static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class); | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * 应发未到车辆 和 班次 | ||
| 38 | - */ | ||
| 39 | - private static Map<String, ScheduleRealInfo> lateSchMap; | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - static { | ||
| 43 | - lateSchMap = new HashMap<>(); | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 新增一个误点班次 | ||
| 48 | - * @param sch | ||
| 49 | - */ | ||
| 50 | - public static void putLate(ScheduleRealInfo sch){ | ||
| 51 | - try { | ||
| 52 | - //进出场班次不需要 | ||
| 53 | - if(sch.getBcType().equals("in") || sch.getBcType().equals("out")) | ||
| 54 | - return; | ||
| 55 | - //线路配置 | ||
| 56 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 57 | - if(sch.getLateMinute() == 0){ | ||
| 58 | - if(config.isEnableYjtk()){ | ||
| 59 | - sch.setLateMinute(sch.getXlDir().equals("0")?config.getUpStopMinute():config.getDownStopMinute()); | ||
| 60 | - } | ||
| 61 | - else | ||
| 62 | - return; | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - if(sch.getDfsj().compareTo(config.getYjtkStart()) > 0 | ||
| 66 | - && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0){ | ||
| 67 | - | ||
| 68 | - ScheduleRealInfo cancel = null; | ||
| 69 | - //之前存在误点班次没有发出 | ||
| 70 | - ScheduleRealInfo old = lateSchMap.get(sch.getClZbh()); | ||
| 71 | - if(old != null && old.getDfsjT() < sch.getDfsjT()){ | ||
| 72 | - remove(old); | ||
| 73 | - cancel = old; | ||
| 74 | - logger.info("【应发未到】old 班次 " + old.getId() + " -被覆盖!"); | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - lateSchMap.put(sch.getClZbh(), sch); | ||
| 78 | - //通知客户端 | ||
| 79 | - sch.setLate2(true); | ||
| 80 | - sendUtils.sendAutoWdtz(sch, cancel); | ||
| 81 | - | ||
| 82 | - logger.info("【应发未到】班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | ||
| 83 | - } | ||
| 84 | - }catch (Exception e){ | ||
| 85 | - logger.error("", e); | ||
| 86 | - } | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - | ||
| 90 | - /** | ||
| 91 | - * 获取所有应发未到的班次 | ||
| 92 | - * @return | ||
| 93 | - */ | ||
| 94 | - public static Collection<ScheduleRealInfo> allLateSch(){ | ||
| 95 | - return lateSchMap.values(); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - public static void remove(ScheduleRealInfo sch){ | ||
| 99 | - try { | ||
| 100 | - if(lateSchMap.get(sch.getClZbh()) == sch){ | ||
| 101 | - lateSchMap.remove(sch.getClZbh()); | ||
| 102 | - sch.setLate2(false); | ||
| 103 | - sch.setLateMinute(0); | ||
| 104 | - } | ||
| 105 | - }catch (Exception e){ | ||
| 106 | - logger.error("", e); | ||
| 107 | - } | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - /** | ||
| 111 | - * 车辆到站 | ||
| 112 | - * @param gps | ||
| 113 | - */ | ||
| 114 | - public static void carArrive(GpsEntity gps){ | ||
| 115 | - try{ | ||
| 116 | - if(gps.getInstation() != 1) | ||
| 117 | - return; | ||
| 118 | - | ||
| 119 | - ScheduleRealInfo sch = lateSchMap.get(gps.getNbbm()); | ||
| 120 | - if(sch == null) | ||
| 121 | - return; | ||
| 122 | - | ||
| 123 | - //进的是班次起点(名称一样即可) | ||
| 124 | - gps.setStationName(BasicData.stationCode2NameMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo())); | ||
| 125 | - if(gps.getStationName().equals(sch.getQdzName()) | ||
| 126 | - && sch.getLateMinute() > 0){ | ||
| 127 | - //自动调整待发 到达时间 + 停靠时间 | ||
| 128 | - long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); | ||
| 129 | - sch.setDfsjAll(dt); | ||
| 130 | - sch.setDfAuto(true); | ||
| 131 | - //取消应发未到标记 | ||
| 132 | - sch.setLate2(false); | ||
| 133 | - | ||
| 134 | - lateSchMap.remove(sch.getClZbh()); | ||
| 135 | - logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt); | ||
| 136 | - } | ||
| 137 | - }catch (Exception e){ | ||
| 138 | - e.printStackTrace(); | ||
| 139 | - logger.error("", e); | ||
| 140 | - } | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - @Override | ||
| 144 | - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
| 145 | - lineConfigData = applicationContext.getBean(LineConfigData.class); | ||
| 146 | - sendUtils = applicationContext.getBean(SendUtils.class); | ||
| 147 | - } | 1 | + |
| 2 | +package com.bsth.data.schedule.late_adjust; | ||
| 3 | + | ||
| 4 | +import com.bsth.data.BasicData; | ||
| 5 | +import com.bsth.data.LineConfigData; | ||
| 6 | +import com.bsth.data.gpsdata.GpsEntity; | ||
| 7 | +import com.bsth.entity.realcontrol.LineConfig; | ||
| 8 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 9 | +import com.bsth.util.Arith; | ||
| 10 | +import com.bsth.websocket.handler.SendUtils; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | +import org.springframework.beans.BeansException; | ||
| 14 | +import org.springframework.context.ApplicationContext; | ||
| 15 | +import org.springframework.context.ApplicationContextAware; | ||
| 16 | +import org.springframework.stereotype.Component; | ||
| 17 | + | ||
| 18 | +import java.util.Collection; | ||
| 19 | +import java.util.HashMap; | ||
| 20 | +import java.util.Map; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * 误点自动调整待发 处理程序 | ||
| 24 | + * | ||
| 25 | + * 注意 :这里的误点是指应发未到 | ||
| 26 | + * Created by panzhao on 2017/4/16. | ||
| 27 | + */ | ||
| 28 | +@Component | ||
| 29 | +public class LateAdjustHandle implements ApplicationContextAware{ | ||
| 30 | + | ||
| 31 | + static LineConfigData lineConfigData; | ||
| 32 | + static SendUtils sendUtils; | ||
| 33 | + | ||
| 34 | + static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class); | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 应发未到车辆 和 班次 | ||
| 38 | + */ | ||
| 39 | + private static Map<String, ScheduleRealInfo> lateSchMap; | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + static { | ||
| 43 | + lateSchMap = new HashMap<>(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 新增一个误点班次 | ||
| 48 | + * @param sch | ||
| 49 | + */ | ||
| 50 | + public static void putLate(ScheduleRealInfo sch){ | ||
| 51 | + try { | ||
| 52 | + //进出场班次不需要 | ||
| 53 | + if(sch.getBcType().equals("in") || sch.getBcType().equals("out")) | ||
| 54 | + return; | ||
| 55 | + //线路配置 | ||
| 56 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 57 | + if(sch.getLateMinute() == 0){ | ||
| 58 | + if(config.isEnableYjtk()){ | ||
| 59 | + sch.setLateMinute(sch.getXlDir().equals("0")?config.getUpStopMinute():config.getDownStopMinute()); | ||
| 60 | + } | ||
| 61 | + else | ||
| 62 | + return; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + if(sch.getDfsj().compareTo(config.getYjtkStart()) > 0 | ||
| 66 | + && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0){ | ||
| 67 | + | ||
| 68 | + ScheduleRealInfo cancel = null; | ||
| 69 | + //之前存在误点班次没有发出 | ||
| 70 | + ScheduleRealInfo old = lateSchMap.get(sch.getClZbh()); | ||
| 71 | + if(old != null && old.getDfsjT() < sch.getDfsjT()){ | ||
| 72 | + remove(old); | ||
| 73 | + cancel = old; | ||
| 74 | + logger.info("【应发未到】old 班次 " + old.getId() + " -被覆盖!"); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + lateSchMap.put(sch.getClZbh(), sch); | ||
| 78 | + //通知客户端 | ||
| 79 | + sch.setLate2(true); | ||
| 80 | + sendUtils.sendAutoWdtz(sch, cancel); | ||
| 81 | + | ||
| 82 | + logger.info("【应发未到】班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | ||
| 83 | + } | ||
| 84 | + }catch (Exception e){ | ||
| 85 | + logger.error("", e); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * 获取所有应发未到的班次 | ||
| 92 | + * @return | ||
| 93 | + */ | ||
| 94 | + public static Collection<ScheduleRealInfo> allLateSch(){ | ||
| 95 | + return lateSchMap.values(); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public static void remove(ScheduleRealInfo sch){ | ||
| 99 | + try { | ||
| 100 | + if(lateSchMap.get(sch.getClZbh()) == sch){ | ||
| 101 | + lateSchMap.remove(sch.getClZbh()); | ||
| 102 | + sch.setLate2(false); | ||
| 103 | + sch.setLateMinute(0); | ||
| 104 | + } | ||
| 105 | + }catch (Exception e){ | ||
| 106 | + logger.error("", e); | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * 车辆到站 | ||
| 112 | + * @param gps | ||
| 113 | + */ | ||
| 114 | + public static void carArrive(GpsEntity gps){ | ||
| 115 | + try{ | ||
| 116 | + if(gps.getInstation() != 1) | ||
| 117 | + return; | ||
| 118 | + | ||
| 119 | + ScheduleRealInfo sch = lateSchMap.get(gps.getNbbm()); | ||
| 120 | + if(sch == null) | ||
| 121 | + return; | ||
| 122 | + | ||
| 123 | + //进的是班次起点(名称一样即可) | ||
| 124 | + gps.setStationName(BasicData.stationCode2NameMap.get(gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo())); | ||
| 125 | + if(gps.getStationName().equals(sch.getQdzName()) | ||
| 126 | + && sch.getLateMinute() > 0){ | ||
| 127 | + //自动调整待发 到达时间 + 停靠时间 | ||
| 128 | + long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); | ||
| 129 | + sch.setDfsjAll(dt); | ||
| 130 | + sch.setDfAuto(true); | ||
| 131 | + //取消应发未到标记 | ||
| 132 | + sch.setLate2(false); | ||
| 133 | + | ||
| 134 | + lateSchMap.remove(sch.getClZbh()); | ||
| 135 | + logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt); | ||
| 136 | + } | ||
| 137 | + }catch (Exception e){ | ||
| 138 | + e.printStackTrace(); | ||
| 139 | + logger.error("", e); | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + @Override | ||
| 144 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
| 145 | + lineConfigData = applicationContext.getBean(LineConfigData.class); | ||
| 146 | + sendUtils = applicationContext.getBean(SendUtils.class); | ||
| 147 | + } | ||
| 148 | } | 148 | } |
| 149 | \ No newline at end of file | 149 | \ No newline at end of file |
src/main/java/com/bsth/data/schedule/late_adjust/ScheduleLateThread.java
| 1 | -package com.bsth.data.schedule.late_adjust; | ||
| 2 | - | ||
| 3 | - | ||
| 4 | -import com.bsth.data.schedule.DayOfSchedule; | ||
| 5 | -import com.bsth.data.schedule.ScheduleComparator; | ||
| 6 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 7 | -import com.bsth.websocket.handler.SendUtils; | ||
| 8 | -import org.apache.commons.lang3.StringUtils; | ||
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | -import org.springframework.stereotype.Component; | ||
| 11 | - | ||
| 12 | -import java.util.ArrayList; | ||
| 13 | -import java.util.Collections; | ||
| 14 | -import java.util.Comparator; | ||
| 15 | -import java.util.List; | ||
| 16 | - | ||
| 17 | -/** | ||
| 18 | - * | ||
| 19 | - * @ClassName: ScheduleLateThread | ||
| 20 | - * @Description: TODO(班次误点扫描线程) | ||
| 21 | - * @author PanZhao | ||
| 22 | - * @date 2016年8月31日 下午3:09:02 | ||
| 23 | - * | ||
| 24 | - */ | ||
| 25 | -@Component | ||
| 26 | -public class ScheduleLateThread extends Thread{ | ||
| 27 | - | ||
| 28 | - @Autowired | ||
| 29 | - DayOfSchedule dayOfSchedule; | ||
| 30 | - | ||
| 31 | - @Autowired | ||
| 32 | - SendUtils sendUtils; | ||
| 33 | - | ||
| 34 | - private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.FCSJ(); | ||
| 35 | - | ||
| 36 | - @Override | ||
| 37 | - public void run() { | ||
| 38 | - List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); | ||
| 39 | - Collections.sort(all, cpm); | ||
| 40 | - | ||
| 41 | - long t = System.currentTimeMillis(); | ||
| 42 | - int size = all.size(); | ||
| 43 | - | ||
| 44 | - ScheduleRealInfo sch; | ||
| 45 | - for(int i = 0; i < size; i ++){ | ||
| 46 | - sch = all.get(i); | ||
| 47 | - if(sch.getDfsjT() > t) | ||
| 48 | - break; | ||
| 49 | - | ||
| 50 | - if(sch.isLate()) | ||
| 51 | - continue; | ||
| 52 | - | ||
| 53 | - if(sch.getStatus() == 0 | ||
| 54 | - && StringUtils.isEmpty(sch.getFcsjActual())){ | ||
| 55 | - | ||
| 56 | - //检查应发未到 当前班次无起点到达时间 | ||
| 57 | - if(StringUtils.isEmpty(sch.getQdzArrDateSJ())){ | ||
| 58 | - ScheduleRealInfo prev = dayOfSchedule.prev(sch); | ||
| 59 | - //上一个班次也没有实际终点到达时间 | ||
| 60 | - if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){ | ||
| 61 | - //进入误点调整程序 | ||
| 62 | - LateAdjustHandle.putLate(sch); | ||
| 63 | - } | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - //应发未发 | ||
| 67 | - sch.setLate(true); | ||
| 68 | - //通知客户端 | ||
| 69 | - sendUtils.refreshSch(sch); | ||
| 70 | - } | ||
| 71 | - } | ||
| 72 | - } | 1 | +package com.bsth.data.schedule.late_adjust; |
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.bsth.data.schedule.DayOfSchedule; | ||
| 5 | +import com.bsth.data.schedule.ScheduleComparator; | ||
| 6 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 7 | +import com.bsth.websocket.handler.SendUtils; | ||
| 8 | +import org.apache.commons.lang3.StringUtils; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.stereotype.Component; | ||
| 11 | + | ||
| 12 | +import java.util.ArrayList; | ||
| 13 | +import java.util.Collections; | ||
| 14 | +import java.util.Comparator; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * | ||
| 19 | + * @ClassName: ScheduleLateThread | ||
| 20 | + * @Description: TODO(班次误点扫描线程) | ||
| 21 | + * @author PanZhao | ||
| 22 | + * @date 2016年8月31日 下午3:09:02 | ||
| 23 | + * | ||
| 24 | + */ | ||
| 25 | +@Component | ||
| 26 | +public class ScheduleLateThread extends Thread{ | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + DayOfSchedule dayOfSchedule; | ||
| 30 | + | ||
| 31 | + @Autowired | ||
| 32 | + SendUtils sendUtils; | ||
| 33 | + | ||
| 34 | + private static Comparator<ScheduleRealInfo> cpm = new ScheduleComparator.FCSJ(); | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public void run() { | ||
| 38 | + List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); | ||
| 39 | + Collections.sort(all, cpm); | ||
| 40 | + | ||
| 41 | + long t = System.currentTimeMillis(); | ||
| 42 | + int size = all.size(); | ||
| 43 | + | ||
| 44 | + ScheduleRealInfo sch; | ||
| 45 | + for(int i = 0; i < size; i ++){ | ||
| 46 | + sch = all.get(i); | ||
| 47 | + if(sch.getDfsjT() > t) | ||
| 48 | + break; | ||
| 49 | + | ||
| 50 | + if(sch.isLate()) | ||
| 51 | + continue; | ||
| 52 | + | ||
| 53 | + if(sch.getStatus() == 0 | ||
| 54 | + && StringUtils.isEmpty(sch.getFcsjActual())){ | ||
| 55 | + | ||
| 56 | + //检查应发未到 当前班次无起点到达时间 | ||
| 57 | + if(StringUtils.isEmpty(sch.getQdzArrDateSJ())){ | ||
| 58 | + ScheduleRealInfo prev = dayOfSchedule.prev(sch); | ||
| 59 | + //上一个班次也没有实际终点到达时间 | ||
| 60 | + if(prev != null && StringUtils.isEmpty(prev.getZdsjActual())){ | ||
| 61 | + //进入误点调整程序 | ||
| 62 | + LateAdjustHandle.putLate(sch); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + //应发未发 | ||
| 67 | + sch.setLate(true); | ||
| 68 | + //通知客户端 | ||
| 69 | + sendUtils.refreshSch(sch); | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | } | 73 | } |
| 74 | \ No newline at end of file | 74 | \ No newline at end of file |
src/main/java/com/bsth/entity/mcy_forms/Waybillday.java
| @@ -20,6 +20,8 @@ public class Waybillday { | @@ -20,6 +20,8 @@ public class Waybillday { | ||
| 20 | 20 | ||
| 21 | private String zlc;//里程 | 21 | private String zlc;//里程 |
| 22 | 22 | ||
| 23 | + private String sh;//损耗 | ||
| 24 | + | ||
| 23 | public String getJgh() { | 25 | public String getJgh() { |
| 24 | return jgh; | 26 | return jgh; |
| 25 | } | 27 | } |
| @@ -110,6 +112,15 @@ public class Waybillday { | @@ -110,6 +112,15 @@ public class Waybillday { | ||
| 110 | public void setYl(String yl) { | 112 | public void setYl(String yl) { |
| 111 | this.yl = yl; | 113 | this.yl = yl; |
| 112 | } | 114 | } |
| 115 | + | ||
| 116 | + public String getSh() { | ||
| 117 | + return sh; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public void setSh(String sh) { | ||
| 121 | + this.sh = sh; | ||
| 122 | + } | ||
| 123 | + | ||
| 113 | 124 | ||
| 114 | 125 | ||
| 115 | } | 126 | } |
src/main/java/com/bsth/entity/schedule/SchedulePlan.java
| @@ -2,8 +2,11 @@ package com.bsth.entity.schedule; | @@ -2,8 +2,11 @@ package com.bsth.entity.schedule; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.Line; | 3 | import com.bsth.entity.Line; |
| 4 | import com.fasterxml.jackson.annotation.JsonIgnore; | 4 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 5 | +import org.apache.commons.lang3.BooleanUtils; | ||
| 5 | 6 | ||
| 6 | import javax.persistence.*; | 7 | import javax.persistence.*; |
| 8 | +import java.sql.PreparedStatement; | ||
| 9 | +import java.sql.SQLException; | ||
| 7 | import java.util.ArrayList; | 10 | import java.util.ArrayList; |
| 8 | import java.util.Date; | 11 | import java.util.Date; |
| 9 | import java.util.List; | 12 | import java.util.List; |
| @@ -53,6 +56,30 @@ public class SchedulePlan extends BEntity { | @@ -53,6 +56,30 @@ public class SchedulePlan extends BEntity { | ||
| 53 | @OneToMany(mappedBy = "schedulePlan", cascade = CascadeType.ALL, fetch = FetchType.LAZY) | 56 | @OneToMany(mappedBy = "schedulePlan", cascade = CascadeType.ALL, fetch = FetchType.LAZY) |
| 54 | private List<SchedulePlanInfo> schedulePlanInfoList = new ArrayList<>(); | 57 | private List<SchedulePlanInfo> schedulePlanInfoList = new ArrayList<>(); |
| 55 | 58 | ||
| 59 | + | ||
| 60 | + public static String generateInsertSql() { | ||
| 61 | + String sql = "insert into bsth_c_s_sp " + | ||
| 62 | + " (xl, schedule_from_time, schedule_to_time, " + | ||
| 63 | + "tt_info_names, tt_info_ids, is_history_plan_first, plan_result, " + | ||
| 64 | + "create_by, update_by, create_date, update_date) " + | ||
| 65 | + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; | ||
| 66 | + return sql; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public void preparedStatementSet(PreparedStatement ps) throws SQLException { | ||
| 70 | + ps.setInt(1, this.xl.getId()); | ||
| 71 | + ps.setDate(2, new java.sql.Date(this.scheduleFromTime.getTime())); | ||
| 72 | + ps.setDate(3, new java.sql.Date(this.scheduleToTime.getTime())); | ||
| 73 | + ps.setString(4, this.ttInfoNames); | ||
| 74 | + ps.setString(5, this.ttInfoIds); | ||
| 75 | + ps.setInt(6, BooleanUtils.isTrue(this.isHistoryPlanFirst) ? 1 : 0); | ||
| 76 | + ps.setString(7, this.planResult); | ||
| 77 | + ps.setInt(8, this.getCreateBy().getId()); | ||
| 78 | + ps.setInt(9, this.getUpdateBy().getId()); | ||
| 79 | + ps.setTimestamp(10, new java.sql.Timestamp(this.getCreateDate().getTime())); | ||
| 80 | + ps.setTimestamp(11, new java.sql.Timestamp(this.getUpdateDate().getTime())); | ||
| 81 | + } | ||
| 82 | + | ||
| 56 | public Long getId() { | 83 | public Long getId() { |
| 57 | return id; | 84 | return id; |
| 58 | } | 85 | } |
src/main/java/com/bsth/entity/schedule/SchedulePlanInfo.java
| @@ -6,6 +6,9 @@ import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output; | @@ -6,6 +6,9 @@ import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output; | ||
| 6 | import org.apache.commons.lang3.StringUtils; | 6 | import org.apache.commons.lang3.StringUtils; |
| 7 | 7 | ||
| 8 | import javax.persistence.*; | 8 | import javax.persistence.*; |
| 9 | +import java.sql.PreparedStatement; | ||
| 10 | +import java.sql.SQLException; | ||
| 11 | +import java.sql.Types; | ||
| 9 | import java.util.Date; | 12 | import java.util.Date; |
| 10 | import java.util.List; | 13 | import java.util.List; |
| 11 | 14 | ||
| @@ -148,12 +151,15 @@ public class SchedulePlanInfo { | @@ -148,12 +151,15 @@ public class SchedulePlanInfo { | ||
| 148 | private Date updateDate; | 151 | private Date updateDate; |
| 149 | 152 | ||
| 150 | 153 | ||
| 154 | +// @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | ||
| 155 | +// @JoinTable( | ||
| 156 | +// name = "bsth_c_s_sp_r_info", | ||
| 157 | +// joinColumns = @JoinColumn(name = "sp_info_id"), | ||
| 158 | +// inverseJoinColumns = @JoinColumn(name = "sp_id") | ||
| 159 | +// ) | ||
| 160 | +// private SchedulePlan schedulePlan; | ||
| 161 | + | ||
| 151 | @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | 162 | @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) |
| 152 | - @JoinTable( | ||
| 153 | - name = "bsth_c_s_sp_r_info", | ||
| 154 | - joinColumns = @JoinColumn(name = "sp_info_id"), | ||
| 155 | - inverseJoinColumns = @JoinColumn(name = "sp_id") | ||
| 156 | - ) | ||
| 157 | private SchedulePlan schedulePlan; | 163 | private SchedulePlan schedulePlan; |
| 158 | 164 | ||
| 159 | public SchedulePlanInfo() {} | 165 | public SchedulePlanInfo() {} |
| @@ -302,6 +308,62 @@ public class SchedulePlanInfo { | @@ -302,6 +308,62 @@ public class SchedulePlanInfo { | ||
| 302 | 308 | ||
| 303 | } | 309 | } |
| 304 | 310 | ||
| 311 | + public static String generateInsertSql() { | ||
| 312 | + String sql = "insert into bsth_c_s_sp_info " + | ||
| 313 | + " (schedule_date, gs_name, gs_bm, fgs_name, fgs_bm, ccno, " + | ||
| 314 | + "xl, xl_name, xl_bm, lp, lp_name, cl, cl_zbh, bd_time, cc_time, " + | ||
| 315 | + "j, j_gh, j_name, s, s_gh, s_name, " + | ||
| 316 | + "xl_dir, qdz_code, qdz_name, zdz_code, zdz_name, " + | ||
| 317 | + "fcsj, fcno, bcs, jhlc, bcsj, bc_type, " + | ||
| 318 | + "tt_info, tt_info_name, remark, schedule_plan, " + | ||
| 319 | + "create_by, update_by, create_date, update_date) " + | ||
| 320 | + "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," + | ||
| 321 | + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; | ||
| 322 | + return sql; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + public void preparedStatementSet(PreparedStatement ps) throws SQLException { | ||
| 326 | + if (this.scheduleDate != null) ps.setDate(1, new java.sql.Date(this.scheduleDate.getTime())); else ps.setNull(1, Types.DATE); | ||
| 327 | + if (this.gsName != null) ps.setString(2, this.gsName); else ps.setNull(2, Types.VARCHAR); | ||
| 328 | + if (this.gsBm != null) ps.setString(3, this.gsBm); else ps.setNull(3, Types.VARCHAR); | ||
| 329 | + if (this.fgsName != null) ps.setString(4, this.fgsName); else ps.setNull(4, Types.VARCHAR); | ||
| 330 | + if (this.fgsBm != null) ps.setString(5, this.fgsBm); else ps.setNull(5, Types.VARCHAR); | ||
| 331 | + if (this.ccno != null) ps.setInt(6, this.ccno); else ps.setNull(6, Types.INTEGER); | ||
| 332 | + if (this.xl != null) ps.setInt(7, this.xl); else ps.setNull(7, Types.INTEGER); | ||
| 333 | + if (this.xlName != null) ps.setString(8, this.xlName); else ps.setNull(8, Types.VARCHAR); | ||
| 334 | + if (this.xlBm != null) ps.setString(9, this.xlBm); else ps.setNull(9, Types.VARCHAR); | ||
| 335 | + if (this.lp != null) ps.setLong(10, this.lp); else ps.setNull(10, Types.BIGINT); | ||
| 336 | + if (this.lpName != null) ps.setString(11, this.lpName); else ps.setNull(11, Types.VARCHAR); | ||
| 337 | + if (this.cl != null) ps.setInt(12, this.cl); else ps.setNull(12, Types.INTEGER); | ||
| 338 | + if (this.clZbh != null) ps.setString(13, this.clZbh); else ps.setNull(13, Types.VARCHAR); | ||
| 339 | + if (this.bdTime != null) ps.setString(14, this.bdTime); else ps.setNull(14, Types.VARCHAR); | ||
| 340 | + if (this.ccTime != null) ps.setString(15, this.ccTime); else ps.setNull(15, Types.VARCHAR); | ||
| 341 | + if (this.j != null) ps.setInt(16, this.j); else ps.setNull(16, Types.INTEGER); | ||
| 342 | + if (this.jGh != null) ps.setString(17, this.jGh); else ps.setNull(17, Types.VARCHAR); | ||
| 343 | + if (this.jName != null) ps.setString(18, this.jName); else ps.setNull(18, Types.VARCHAR); | ||
| 344 | + if (this.s != null) ps.setInt(19, this.s); else ps.setNull(19, Types.INTEGER); | ||
| 345 | + if (this.sGh != null) ps.setString(20, this.sGh); else ps.setNull(20, Types.VARCHAR); | ||
| 346 | + if (this.sName != null) ps.setString(21, this.sName); else ps.setNull(21, Types.VARCHAR); | ||
| 347 | + if (this.xlDir != null) ps.setString(22, this.xlDir); else ps.setNull(22, Types.VARCHAR); | ||
| 348 | + if (this.qdzCode != null) ps.setString(23, this.qdzCode); else ps.setNull(23, Types.VARCHAR); | ||
| 349 | + if (this.qdzName != null) ps.setString(24, this.qdzName); else ps.setNull(24, Types.VARCHAR); | ||
| 350 | + if (this.zdzCode != null) ps.setString(25, this.zdzCode); else ps.setNull(25, Types.VARCHAR); | ||
| 351 | + if (this.zdzName != null) ps.setString(26, this.zdzName); else ps.setNull(26, Types.VARCHAR); | ||
| 352 | + if (this.fcsj != null) ps.setString(27, this.fcsj); else ps.setNull(27, Types.VARCHAR); | ||
| 353 | + if (this.fcno != null) ps.setInt(28, this.fcno); else ps.setNull(28, Types.INTEGER); | ||
| 354 | + if (this.bcs != null) ps.setInt(29, this.bcs); else ps.setNull(29, Types.INTEGER); | ||
| 355 | + if (this.jhlc != null) ps.setDouble(30, this.jhlc); else ps.setNull(30, Types.DOUBLE); | ||
| 356 | + if (this.bcsj != null) ps.setInt(31, this.bcsj); else ps.setNull(31, Types.INTEGER); | ||
| 357 | + if (this.bcType != null) ps.setString(32, this.bcType); else ps.setNull(32, Types.VARCHAR); | ||
| 358 | + if (this.ttInfo != null) ps.setLong(33, this.ttInfo); else ps.setNull(33, Types.BIGINT); | ||
| 359 | + if (this.ttInfoName != null) ps.setString(34, this.ttInfoName); else ps.setNull(34, Types.VARCHAR); | ||
| 360 | + if (this.remark != null) ps.setString(35, this.remark); else ps.setNull(35, Types.VARCHAR); | ||
| 361 | + if (this.schedulePlan != null) ps.setLong(36, this.schedulePlan.getId()); else ps.setNull(36, Types.BIGINT); | ||
| 362 | + if (this.createBy != null) ps.setInt(37, this.createBy.getId()); else ps.setNull(37, Types.INTEGER); | ||
| 363 | + if (this.updateBy != null) ps.setInt(38, this.updateBy.getId()); else ps.setNull(38, Types.INTEGER); | ||
| 364 | + if (this.createDate != null) ps.setTimestamp(39, new java.sql.Timestamp(this.createDate.getTime())); else ps.setNull(39, Types.TIMESTAMP); | ||
| 365 | + if (this.updateDate != null) ps.setTimestamp(40, new java.sql.Timestamp(this.updateDate.getTime())); else ps.setNull(40, Types.TIMESTAMP); | ||
| 366 | + } | ||
| 305 | 367 | ||
| 306 | public Long getId() { | 368 | public Long getId() { |
| 307 | return id; | 369 | return id; |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| @@ -22,7 +22,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -22,7 +22,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 22 | List<ScheduleRealInfo> findByLines(List<String> lines); | 22 | List<ScheduleRealInfo> findByLines(List<String> lines); |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and bc_type not in ('in','out') order by (lpName+1),clZbh,realExecDate,fcsj") | 25 | + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and bc_type not in ('in','out') order by (lpName+1),clZbh,realExecDate,dfsj") |
| 26 | List<ScheduleRealInfo> scheduleDailyQp(String line,String date); | 26 | List<ScheduleRealInfo> scheduleDailyQp(String line,String date); |
| 27 | 27 | ||
| 28 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") | 28 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") |
| @@ -87,11 +87,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -87,11 +87,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 87 | List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); | 87 | List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); |
| 88 | 88 | ||
| 89 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 89 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 90 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,fcsj") | 90 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,dfsj") |
| 91 | List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line); | 91 | List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line); |
| 92 | 92 | ||
| 93 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 93 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 94 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,fcsj") | 94 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,dfsj") |
| 95 | List<ScheduleRealInfo> queryListWaybillXcld(String jGh,String clZbh,String lpName,String date,String line); | 95 | List<ScheduleRealInfo> queryListWaybillXcld(String jGh,String clZbh,String lpName,String date,String line); |
| 96 | 96 | ||
| 97 | // @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 97 | // @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| @@ -104,11 +104,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -104,11 +104,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 104 | 104 | ||
| 105 | 105 | ||
| 106 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 106 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 107 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDate = str_to_date(?2,'%Y-%m-%d') and xlBm =?3 order by realExecDate,fcsj") | 107 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDate = str_to_date(?2,'%Y-%m-%d') and xlBm =?3 order by realExecDate,dfsj") |
| 108 | List<ScheduleRealInfo> queryListWaybill2(String clZbh,String date,String line); | 108 | List<ScheduleRealInfo> queryListWaybill2(String clZbh,String date,String line); |
| 109 | 109 | ||
| 110 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 110 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 111 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh like %?1% and s.clZbh like %?2% and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') and s.gsBm like %?4% and s.fgsBm like %?5% order by realExecDate,fcsj") | 111 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh like %?1% and s.clZbh like %?2% and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') and s.gsBm like %?4% and s.fgsBm like %?5% order by realExecDate,dfsj") |
| 112 | List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm); | 112 | List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm); |
| 113 | 113 | ||
| 114 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 114 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| @@ -133,11 +133,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -133,11 +133,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 133 | 133 | ||
| 134 | //去掉了 xlBm is not null | 134 | //去掉了 xlBm is not null |
| 135 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 135 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 136 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.realExecDate,s.fcsj, (s.lpName+1)") | 136 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.realExecDate,s.dfsj, (s.lpName+1)") |
| 137 | List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); | 137 | List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); |
| 138 | 138 | ||
| 139 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 139 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 140 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by (s.lpName+1), s.realExecDate,s.fcsj") | 140 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by (s.lpName+1), s.realExecDate,s.dfsj") |
| 141 | List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date); | 141 | List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date); |
| 142 | 142 | ||
| 143 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 143 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
src/main/java/com/bsth/repository/schedule/SchedulePlanInfoRepository.java
| @@ -24,8 +24,6 @@ public interface SchedulePlanInfoRepository extends BaseRepository<SchedulePlanI | @@ -24,8 +24,6 @@ public interface SchedulePlanInfoRepository extends BaseRepository<SchedulePlanI | ||
| 24 | @Query(value = "select s from SchedulePlanInfo s where scheduleDate=?1") | 24 | @Query(value = "select s from SchedulePlanInfo s where scheduleDate=?1") |
| 25 | List<SchedulePlanInfo> findByDate(Date date); | 25 | List<SchedulePlanInfo> findByDate(Date date); |
| 26 | 26 | ||
| 27 | - Long deleteByXlAndScheduleDateGreaterThanEqualAndScheduleDateLessThanEqual(Integer xlid, Date startDate, Date endDate); | ||
| 28 | - | ||
| 29 | @Query(value = " select " + | 27 | @Query(value = " select " + |
| 30 | "info.xl as xlId, " + | 28 | "info.xl as xlId, " + |
| 31 | "info.xl_name as xlName, " + | 29 | "info.xl_name as xlName, " + |
src/main/java/com/bsth/service/forms/impl/ExportServiceImpl.java
| @@ -35,12 +35,14 @@ public class ExportServiceImpl implements ExportService{ | @@ -35,12 +35,14 @@ public class ExportServiceImpl implements ExportService{ | ||
| 35 | 35 | ||
| 36 | for(Waybillday w : list){ | 36 | for(Waybillday w : list){ |
| 37 | Map<String, Object> m = new HashMap<String, Object>(); | 37 | Map<String, Object> m = new HashMap<String, Object>(); |
| 38 | - m.put("carPlate", w.getCarPlate()); | 38 | + m.put("carPlate", w.getNbbm()); |
| 39 | m.put("jzl1", w.getJzl1()); | 39 | m.put("jzl1", w.getJzl1()); |
| 40 | m.put("jzl", w.getJzl()); | 40 | m.put("jzl", w.getJzl()); |
| 41 | m.put("yh", w.getYh()); | 41 | m.put("yh", w.getYh()); |
| 42 | + m.put("sh", w.getSh()); | ||
| 42 | m.put("jName", w.getjName()); | 43 | m.put("jName", w.getjName()); |
| 43 | m.put("zlc", w.getZlc()); | 44 | m.put("zlc", w.getZlc()); |
| 45 | + m.put("jy", ""); | ||
| 44 | resList.add(m); | 46 | resList.add(m); |
| 45 | } | 47 | } |
| 46 | 48 | ||
| @@ -48,7 +50,7 @@ public class ExportServiceImpl implements ExportService{ | @@ -48,7 +50,7 @@ public class ExportServiceImpl implements ExportService{ | ||
| 48 | listI.add(resList.iterator()); | 50 | listI.add(resList.iterator()); |
| 49 | String path = this.getClass().getResource("/").getPath()+"static/pages/forms/"; | 51 | String path = this.getClass().getResource("/").getPath()+"static/pages/forms/"; |
| 50 | ee.excelReplace(listI, new Object[] { map }, path+"mould/waybillday.xls", | 52 | ee.excelReplace(listI, new Object[] { map }, path+"mould/waybillday.xls", |
| 51 | - path+"export/行车路单日报表" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | 53 | + path+"export/行车路单日报表.xls"); |
| 52 | } catch (Exception e) { | 54 | } catch (Exception e) { |
| 53 | e.printStackTrace(); | 55 | e.printStackTrace(); |
| 54 | } | 56 | } |
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| @@ -64,48 +64,69 @@ public class FormsServiceImpl implements FormsService { | @@ -64,48 +64,69 @@ public class FormsServiceImpl implements FormsService { | ||
| 64 | // 行车路单日报表 | 64 | // 行车路单日报表 |
| 65 | @Override | 65 | @Override |
| 66 | public List<Waybillday> waybillday(Map<String, Object> map) { | 66 | public List<Waybillday> waybillday(Map<String, Object> map) { |
| 67 | - | ||
| 68 | - | ||
| 69 | - | ||
| 70 | - String sql=" select t.*,z.jzl,z.yh from (" | ||
| 71 | - + " select x.j_gh,x.cl_zbh,x.j_name,x.schedule_date," | ||
| 72 | - + " x.gs_bm,x.gs_name,x.fgs_bm,x.fgs_name from bsth_c_s_sp_info_real x " | ||
| 73 | - + " where to_days( x.schedule_date)=to_days('"+map.get("date").toString() + "') " | ||
| 74 | - + " and x.gs_bm='"+map.get("gsdmWaybillday").toString()+"' " | ||
| 75 | - + " and x.fgs_bm='"+map.get("fgsdmWaybillday").toString()+"' " | ||
| 76 | - + " and xl_bm like '%"+ map.get("line").toString().trim()+"%'" | ||
| 77 | - + " GROUP BY x.j_gh,x.cl_zbh,x.j_name," | ||
| 78 | - + " x.schedule_date,x.gs_bm,x.gs_name,x.fgs_bm,x.fgs_name ) t" | ||
| 79 | - + " LEFT join (select y.rq,y.xlbm,y.nbbm,y.jsy,y.jzl,y.yh from" | ||
| 80 | - + " bsth_c_ylb y where 1=1 " | ||
| 81 | - + " and to_days(y.RQ)=to_days('"+map.get("date").toString() + "') " | ||
| 82 | - + " and y.XLBM like '%"+ map.get("line").toString().trim()+"%'" | ||
| 83 | - + " and y.ssgsdm='"+map.get("gsdmWaybillday").toString()+"'" | ||
| 84 | - + " and y.fgsdm='"+map.get("gsdmWaybillday").toString()+"') z " | ||
| 85 | - + " on t.cl_zbh=z.nbbm "; | 67 | + String line=map.get("line").toString(); |
| 68 | + String date=map.get("date").toString(); | ||
| 69 | + | ||
| 70 | + String sql="select " | ||
| 71 | + + " r.cl_zbh,r.j_gh,r.j_name" | ||
| 72 | + + " from bsth_c_s_sp_info_real r where " | ||
| 73 | + + " r.schedule_date_str = '"+date+"'" | ||
| 74 | + + " and r.xl_bm = '"+line+"' " | ||
| 75 | + + " group by " | ||
| 76 | + + " r.cl_zbh,r.j_gh,r.j_name"; | ||
| 86 | 77 | ||
| 87 | List<Waybillday> list = jdbcTemplate.query(sql, new RowMapper<Waybillday>() { | 78 | List<Waybillday> list = jdbcTemplate.query(sql, new RowMapper<Waybillday>() { |
| 79 | + | ||
| 88 | @Override | 80 | @Override |
| 89 | public Waybillday mapRow(ResultSet arg0, int arg1) throws SQLException { | 81 | public Waybillday mapRow(ResultSet arg0, int arg1) throws SQLException { |
| 90 | - Waybillday wbd = new Waybillday(); | ||
| 91 | - wbd.setCarPlate(arg0.getString("cl_zbh")); | ||
| 92 | - wbd.setJzl(arg0.getString("jzl")); | ||
| 93 | - wbd.setYh(arg0.getString("yh")); | ||
| 94 | - wbd.setjName(arg0.getString("j_name")); | ||
| 95 | - wbd.setRq(arg0.getString("schedule_date")); | ||
| 96 | - wbd.setJgh(arg0.getString("j_gh")); | ||
| 97 | - return wbd; | ||
| 98 | - } | 82 | + Waybillday w=new Waybillday(); |
| 83 | + w.setJgh(arg0.getString("j_gh")); | ||
| 84 | + w.setjName(arg0.getString("j_name")); | ||
| 85 | + w.setNbbm(arg0.getString("cl_zbh")); | ||
| 86 | + return w; | ||
| 87 | + | ||
| 88 | + }; | ||
| 99 | }); | 89 | }); |
| 100 | - | ||
| 101 | - for(int i=0;i<list.size();i++){ | 90 | + List<ScheduleRealInfo> realList= scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date); |
| 91 | + List<Ylb> listYlb= ylbRepository.obtainYl(date, "", "", line, "", "xlbm"); | ||
| 92 | + double jzl=0.0,sh=0.0,yh=0.0; | ||
| 93 | + for (int i = 0; i < list.size(); i++) { | ||
| 102 | Waybillday w=list.get(i); | 94 | Waybillday w=list.get(i); |
| 103 | - Map<String, Object> maps = new HashMap<>(); | ||
| 104 | - maps = commonService.findKMBC2(w.getJgh(), w.getCarPlate(), | ||
| 105 | - w.getRq()); | ||
| 106 | - w.setJzl1(maps.get("ksgl").toString()); | ||
| 107 | - w.setZlc(maps.get("realMileage").toString()); | ||
| 108 | - | 95 | + List<ScheduleRealInfo> listInfo=new ArrayList<ScheduleRealInfo>(); |
| 96 | + for (int j = 0; j < realList.size(); j++) { | ||
| 97 | + ScheduleRealInfo s=realList.get(j); | ||
| 98 | + if(w.getNbbm().equals(s.getClZbh()) && w.getJgh().equals(w.getJgh())){ | ||
| 99 | + listInfo.add(s); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + double sjgl=culateMileageService.culateSjgl(listInfo); | ||
| 104 | + double ljgl=culateMileageService.culateLjgl(listInfo); | ||
| 105 | + double zyygl=Arith.add(sjgl, ljgl); | ||
| 106 | + double jccg=culateMileageService.culateJccgl(listInfo); | ||
| 107 | + double ksgl=culateMileageService.culateKsgl(listInfo); | ||
| 108 | + double zksgl=Arith.add(jccg, ksgl); | ||
| 109 | + | ||
| 110 | + w.setJzl1(String.valueOf(zksgl)); | ||
| 111 | + w.setZlc(String.valueOf(Arith.add(zyygl, zksgl))); | ||
| 112 | + | ||
| 113 | + | ||
| 114 | + jzl=0.0; | ||
| 115 | + sh=0.0; | ||
| 116 | + yh=0.0; | ||
| 117 | + for (int j = 0; j < listYlb.size(); j++) { | ||
| 118 | + Ylb y=listYlb.get(j); | ||
| 119 | + if(w.getNbbm().equals(y.getNbbm()) && w.getJgh().equals(y.getJsy())){ | ||
| 120 | + jzl=Arith.add(jzl, y.getJzl()); | ||
| 121 | + sh=Arith.add(sh, y.getSh()); | ||
| 122 | + yh=Arith.add(yh, y.getYh()); | ||
| 123 | + } | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + w.setJzl(String.valueOf(jzl)); | ||
| 127 | + w.setYh(String.valueOf(yh)); | ||
| 128 | + w.setSh(String.valueOf(sh)); | ||
| 129 | + | ||
| 109 | } | 130 | } |
| 110 | return list; | 131 | return list; |
| 111 | } | 132 | } |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -1668,35 +1668,42 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1668,35 +1668,42 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1668 | public List<Map<String, Object>> statisticsDaily(String line, String date, | 1668 | public List<Map<String, Object>> statisticsDaily(String line, String date, |
| 1669 | String xlName, String type) { | 1669 | String xlName, String type) { |
| 1670 | List<Map<String, Object>> lMap= new ArrayList<Map<String, Object>>(); | 1670 | List<Map<String, Object>> lMap= new ArrayList<Map<String, Object>>(); |
| 1671 | - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); | 1671 | + List<ScheduleRealInfo>list_s=scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); |
| 1672 | + List<ScheduleRealInfo> lists =new ArrayList<ScheduleRealInfo>(); | ||
| 1673 | + for (int i = 0; i < list_s.size(); i++) { | ||
| 1674 | + ScheduleRealInfo s=list_s.get(i); | ||
| 1675 | + if(s.getZdsjActual()!=null){ | ||
| 1676 | + lists.add(s); | ||
| 1677 | + } | ||
| 1678 | + } | ||
| 1672 | Map<String, Object> map = new HashMap<String, Object>(); | 1679 | Map<String, Object> map = new HashMap<String, Object>(); |
| 1673 | map.put("xlName", xlName); | 1680 | map.put("xlName", xlName); |
| 1674 | - double jhlc=culateService.culateJhgl(lists); | 1681 | + double jhlc=culateService.culateJhgl(list_s); |
| 1675 | map.put("jhlc",jhlc); | 1682 | map.put("jhlc",jhlc); |
| 1676 | map.put("sjgl", Arith.add(culateService.culateSjgl(lists),culateService.culateLjgl(lists))); | 1683 | map.put("sjgl", Arith.add(culateService.culateSjgl(lists),culateService.culateLjgl(lists))); |
| 1677 | - double lbgl=culateService.culateLbgl(lists); | 1684 | + double lbgl=culateService.culateLbgl(list_s); |
| 1678 | map.put("ssgl", lbgl); | 1685 | map.put("ssgl", lbgl); |
| 1679 | - map.put("ssgl_lz", culateService.culateCJLC(lists, "路阻")); | ||
| 1680 | - map.put("ssgl_dm", culateService.culateCJLC(lists, "吊慢")); | ||
| 1681 | - map.put("ssgl_gz", culateService.culateCJLC(lists, "故障")); | ||
| 1682 | - map.put("ssgl_jf", culateService.culateCJLC(lists, "纠纷")); | ||
| 1683 | - map.put("ssgl_zs", culateService.culateCJLC(lists, "肇事")); | ||
| 1684 | - map.put("ssgl_qr", culateService.culateCJLC(lists, "缺人")); | ||
| 1685 | - map.put("ssgl_qc", culateService.culateCJLC(lists, "缺车")); | ||
| 1686 | - map.put("ssgl_kx", culateService.culateCJLC(lists, "客稀")); | ||
| 1687 | - map.put("ssgl_qh", culateService.culateCJLC(lists, "气候")); | ||
| 1688 | - map.put("ssgl_yw", culateService.culateCJLC(lists, "援外")); | ||
| 1689 | - double ssgl_pc=culateService.culateCJLC(lists, "配车"); | ||
| 1690 | - double ssgl_by=culateService.culateCJLC(lists, "保养"); | ||
| 1691 | - double ssgl_cj=culateService.culateCJLC(lists, "抽减"); | ||
| 1692 | - double ssgl_qt=culateService.culateCJLC(lists, "其他"); | 1686 | + map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻")); |
| 1687 | + map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢")); | ||
| 1688 | + map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障")); | ||
| 1689 | + map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷")); | ||
| 1690 | + map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事")); | ||
| 1691 | + map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人")); | ||
| 1692 | + map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车")); | ||
| 1693 | + map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀")); | ||
| 1694 | + map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候")); | ||
| 1695 | + map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外")); | ||
| 1696 | + double ssgl_pc=culateService.culateCJLC(list_s, "配车"); | ||
| 1697 | + double ssgl_by=culateService.culateCJLC(list_s, "保养"); | ||
| 1698 | + double ssgl_cj=culateService.culateCJLC(list_s, "抽减"); | ||
| 1699 | + double ssgl_qt=culateService.culateCJLC(list_s, "其他"); | ||
| 1693 | map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by),Arith.add(ssgl_cj, ssgl_qt))); | 1700 | map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by),Arith.add(ssgl_cj, ssgl_qt))); |
| 1694 | - map.put("ssbc", culateService.culateLbbc(lists)); | 1701 | + map.put("ssbc", culateService.culateLbbc(list_s)); |
| 1695 | double ljgl=culateService.culateLjgl(lists); | 1702 | double ljgl=culateService.culateLjgl(lists); |
| 1696 | map.put("ljgl", ljgl); | 1703 | map.put("ljgl", ljgl); |
| 1697 | - map.put("jhbc", culateService.culateJhbc(lists,"")); | ||
| 1698 | - map.put("jhbc_m", culateService.culateJhbc(lists, "zgf")); | ||
| 1699 | - map.put("jhbc_a", culateService.culateJhbc(lists, "wgf")); | 1704 | + map.put("jhbc", culateService.culateJhbc(list_s,"")); |
| 1705 | + map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf")); | ||
| 1706 | + map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf")); | ||
| 1700 | map.put("sjbc", culateService.culateSjbc(lists,"")); | 1707 | map.put("sjbc", culateService.culateSjbc(lists,"")); |
| 1701 | map.put("sjbc_m", culateService.culateSjbc(lists,"zgf")); | 1708 | map.put("sjbc_m", culateService.culateSjbc(lists,"zgf")); |
| 1702 | map.put("sjbc_a", culateService.culateSjbc(lists,"wgf")); | 1709 | map.put("sjbc_a", culateService.culateSjbc(lists,"wgf")); |
| @@ -2264,11 +2271,18 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -2264,11 +2271,18 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 2264 | return lMap; | 2271 | return lMap; |
| 2265 | }*/ | 2272 | }*/ |
| 2266 | 2273 | ||
| 2267 | - public final Map<String, Object> staticTj(List<ScheduleRealInfo> lists){ | 2274 | + public final Map<String, Object> staticTj(List<ScheduleRealInfo> list){ |
| 2275 | + List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>(); | ||
| 2276 | + for(int i=0;i<list.size();i++){ | ||
| 2277 | + ScheduleRealInfo s=list.get(i); | ||
| 2278 | + if(s.getZdsjActual()!=null){ | ||
| 2279 | + lists.add(s); | ||
| 2280 | + } | ||
| 2281 | + } | ||
| 2268 | Map<String, Object> map = new HashMap<String, Object>(); | 2282 | Map<String, Object> map = new HashMap<String, Object>(); |
| 2269 | map.put("xlName", lists.get(0).getXlName()); | 2283 | map.put("xlName", lists.get(0).getXlName()); |
| 2270 | - double jhyygl=culateService.culateJhgl(lists);//计划营运公里 | ||
| 2271 | - double jhjcclc= culateService.culateJhJccgl(lists);//计划进出场公里(计划空驶公里) | 2284 | + double jhyygl=culateService.culateJhgl(list);//计划营运公里 |
| 2285 | + double jhjcclc= culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 2272 | map.put("jhlc", jhyygl); | 2286 | map.put("jhlc", jhyygl); |
| 2273 | map.put("jcclc", jhjcclc); | 2287 | map.put("jcclc", jhjcclc); |
| 2274 | map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | 2288 | map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); |
| @@ -2284,23 +2298,23 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -2284,23 +2298,23 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 2284 | map.put("sjgl",zyygl); | 2298 | map.put("sjgl",zyygl); |
| 2285 | map.put("sjksgl", zksgl); | 2299 | map.put("sjksgl", zksgl); |
| 2286 | 2300 | ||
| 2287 | - map.put("ssgl", culateService.culateLbgl(lists)); | ||
| 2288 | - map.put("ssgl_lz", culateService.culateCJLC(lists, "路阻")); | ||
| 2289 | - map.put("ssgl_dm", culateService.culateCJLC(lists, "吊慢")); | ||
| 2290 | - map.put("ssgl_gz", culateService.culateCJLC(lists, "故障")); | ||
| 2291 | - map.put("ssgl_jf", culateService.culateCJLC(lists, "纠纷")); | ||
| 2292 | - map.put("ssgl_zs", culateService.culateCJLC(lists, "肇事")); | ||
| 2293 | - map.put("ssgl_qr", culateService.culateCJLC(lists, "缺人")); | ||
| 2294 | - map.put("ssgl_qc", culateService.culateCJLC(lists, "缺车")); | ||
| 2295 | - map.put("ssgl_kx", culateService.culateCJLC(lists, "客稀")); | ||
| 2296 | - map.put("ssgl_qh", culateService.culateCJLC(lists, "气候")); | ||
| 2297 | - map.put("ssgl_yw", culateService.culateCJLC(lists, "援外")); | ||
| 2298 | - map.put("ssgl_other", culateService.culateCJLC(lists, "其他")); | ||
| 2299 | - map.put("ssbc", culateService.culateLbbc(lists)); | 2301 | + map.put("ssgl", culateService.culateLbgl(list)); |
| 2302 | + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | ||
| 2303 | + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | ||
| 2304 | + map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | ||
| 2305 | + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | ||
| 2306 | + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | ||
| 2307 | + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | ||
| 2308 | + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | ||
| 2309 | + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | ||
| 2310 | + map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | ||
| 2311 | + map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | ||
| 2312 | + map.put("ssgl_other", culateService.culateCJLC(list, "其他")); | ||
| 2313 | + map.put("ssbc", culateService.culateLbbc(list)); | ||
| 2300 | map.put("ljgl", ljgl); | 2314 | map.put("ljgl", ljgl); |
| 2301 | - map.put("jhbc", culateService.culateJhbc(lists,"")); | ||
| 2302 | - map.put("jhbc_m", culateService.culateJhbc(lists, "zgf")); | ||
| 2303 | - map.put("jhbc_a", culateService.culateJhbc(lists, "wgf")); | 2315 | + map.put("jhbc", culateService.culateJhbc(list,"")); |
| 2316 | + map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | ||
| 2317 | + map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | ||
| 2304 | map.put("sjbc", culateService.culateSjbc(lists,"")); | 2318 | map.put("sjbc", culateService.culateSjbc(lists,"")); |
| 2305 | map.put("sjbc_m", culateService.culateSjbc(lists,"zgf")); | 2319 | map.put("sjbc_m", culateService.culateSjbc(lists,"zgf")); |
| 2306 | map.put("sjbc_a", culateService.culateSjbc(lists,"wgf")); | 2320 | map.put("sjbc_a", culateService.culateSjbc(lists,"wgf")); |
| @@ -2324,6 +2338,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -2324,6 +2338,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 2324 | public List<Map<String, Object>> statisticsDailyTj(String gsdm,String fgsdm,String line, String date,String date2, | 2338 | public List<Map<String, Object>> statisticsDailyTj(String gsdm,String fgsdm,String line, String date,String date2, |
| 2325 | String xlName, String type) { | 2339 | String xlName, String type) { |
| 2326 | List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | 2340 | List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); |
| 2341 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 2327 | List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | 2342 | List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); |
| 2328 | line =line.trim(); | 2343 | line =line.trim(); |
| 2329 | if(line.equals("")){ | 2344 | if(line.equals("")){ |
| @@ -2333,6 +2348,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -2333,6 +2348,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 2333 | //查询单条线路 | 2348 | //查询单条线路 |
| 2334 | list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2); | 2349 | list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2); |
| 2335 | } | 2350 | } |
| 2351 | + for (int i = 0; i < list.size(); i++) { | ||
| 2352 | + ScheduleRealInfo s=list.get(i); | ||
| 2353 | + if(s.getZdsjActual()!=null){ | ||
| 2354 | + list_s.add(s); | ||
| 2355 | + } | ||
| 2356 | + } | ||
| 2336 | List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | 2357 | List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); |
| 2337 | for (int i = 0; i < list.size(); i++) { | 2358 | for (int i = 0; i < list.size(); i++) { |
| 2338 | if(i<list.size()-1){ | 2359 | if(i<list.size()-1){ |
| @@ -2366,12 +2387,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -2366,12 +2387,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 2366 | map.put("jcclc", jhjcclc); | 2387 | map.put("jcclc", jhjcclc); |
| 2367 | map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | 2388 | map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); |
| 2368 | 2389 | ||
| 2369 | - double ljgl= culateService.culateLjgl(list); | ||
| 2370 | - double sjyygl= culateService.culateSjgl(list); | 2390 | + double ljgl= culateService.culateLjgl(list_s); |
| 2391 | + double sjyygl= culateService.culateSjgl(list_s); | ||
| 2371 | double zyygl= Arith.add(sjyygl,ljgl); | 2392 | double zyygl= Arith.add(sjyygl,ljgl); |
| 2372 | 2393 | ||
| 2373 | - double sjjccgl=culateService.culateJccgl(list); | ||
| 2374 | - double sjksgl=culateService.culateKsgl(list); | 2394 | + double sjjccgl=culateService.culateJccgl(list_s); |
| 2395 | + double sjksgl=culateService.culateKsgl(list_s); | ||
| 2375 | double zksgl=Arith.add(sjjccgl, sjksgl); | 2396 | double zksgl=Arith.add(sjjccgl, sjksgl); |
| 2376 | map.put("sjzgl", Arith.add(zyygl, zksgl)); | 2397 | map.put("sjzgl", Arith.add(zyygl, zksgl)); |
| 2377 | map.put("sjgl",zyygl); | 2398 | map.put("sjgl",zyygl); |
| @@ -2393,15 +2414,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -2393,15 +2414,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 2393 | map.put("jhbc", culateService.culateJhbc(list,"")); | 2414 | map.put("jhbc", culateService.culateJhbc(list,"")); |
| 2394 | map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | 2415 | map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); |
| 2395 | map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | 2416 | map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); |
| 2396 | - map.put("sjbc", culateService.culateSjbc(list,"")); | ||
| 2397 | - map.put("sjbc_m", culateService.culateSjbc(list,"zgf")); | ||
| 2398 | - map.put("sjbc_a", culateService.culateSjbc(list,"wgf")); | ||
| 2399 | - map.put("ljbc", culateService.culateLjbc(list,"")); | ||
| 2400 | - map.put("ljbc_m", culateService.culateLjbc(list,"zgf")); | ||
| 2401 | - map.put("ljbc_a", culateService.culateLjbc(list,"wgf")); | ||
| 2402 | - map.put("fzbc", culateService.culateFzbc(list, "")); | ||
| 2403 | - map.put("fzbc_m", culateService.culateFzbc(list, "zgf")); | ||
| 2404 | - map.put("fzbc_a", culateService.culateFzbc(list, "wgf")); | 2417 | + map.put("sjbc", culateService.culateSjbc(list_s,"")); |
| 2418 | + map.put("sjbc_m", culateService.culateSjbc(list_s,"zgf")); | ||
| 2419 | + map.put("sjbc_a", culateService.culateSjbc(list_s,"wgf")); | ||
| 2420 | + map.put("ljbc", culateService.culateLjbc(list_s,"")); | ||
| 2421 | + map.put("ljbc_m", culateService.culateLjbc(list_s,"zgf")); | ||
| 2422 | + map.put("ljbc_a", culateService.culateLjbc(list_s,"wgf")); | ||
| 2423 | + map.put("fzbc", culateService.culateFzbc(list_s, "")); | ||
| 2424 | + map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | ||
| 2425 | + map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | ||
| 2405 | map.put("dtbc", 0); | 2426 | map.put("dtbc", 0); |
| 2406 | map.put("dtbc_m", 0); | 2427 | map.put("dtbc_m", 0); |
| 2407 | map.put("dtbc_a", 0); | 2428 | map.put("dtbc_a", 0); |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| @@ -1181,6 +1181,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -1181,6 +1181,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1181 | newMap.put("dz", scheduleRealInfo.getQdzName()); | 1181 | newMap.put("dz", scheduleRealInfo.getQdzName()); |
| 1182 | newMap.put("sj", scheduleRealInfo.getFcsj()); | 1182 | newMap.put("sj", scheduleRealInfo.getFcsj()); |
| 1183 | newMap.put("lbbc", 1); | 1183 | newMap.put("lbbc", 1); |
| 1184 | + newMap.put("gzf", " "); | ||
| 1184 | newMap.put("lblc", scheduleRealInfo.getJhlcOrig()); | 1185 | newMap.put("lblc", scheduleRealInfo.getJhlcOrig()); |
| 1185 | newMap.put("jyqp", scheduleRealInfo.getRemarks()); | 1186 | newMap.put("jyqp", scheduleRealInfo.getRemarks()); |
| 1186 | list.add(newMap); | 1187 | list.add(newMap); |
| @@ -1206,6 +1207,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -1206,6 +1207,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1206 | newMap.put("jgh", scheduleRealInfo.getjGh()); | 1207 | newMap.put("jgh", scheduleRealInfo.getjGh()); |
| 1207 | newMap.put("dz", childTaskPlan.getStartStationName()); | 1208 | newMap.put("dz", childTaskPlan.getStartStationName()); |
| 1208 | newMap.put("sj", childTaskPlan.getStartDate()); | 1209 | newMap.put("sj", childTaskPlan.getStartDate()); |
| 1210 | + newMap.put("gzf", " "); | ||
| 1209 | newMap.put("lbbc", 0); | 1211 | newMap.put("lbbc", 0); |
| 1210 | newMap.put("lblc", childTaskPlan.getMileage()); | 1212 | newMap.put("lblc", childTaskPlan.getMileage()); |
| 1211 | newMap.put("jyqp", childTaskPlan.getRemarks()); | 1213 | newMap.put("jyqp", childTaskPlan.getRemarks()); |
| @@ -1237,8 +1239,12 @@ public class ReportServiceImpl implements ReportService{ | @@ -1237,8 +1239,12 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1237 | newMap.put("lp", "小计"); | 1239 | newMap.put("lp", "小计"); |
| 1238 | newMap.put("nbbm", "少驶班次"); | 1240 | newMap.put("nbbm", "少驶班次"); |
| 1239 | newMap.put("jgh", lbbc); | 1241 | newMap.put("jgh", lbbc); |
| 1240 | - newMap.put("sj", "少驶公里"); | 1242 | + newMap.put("lbbc", "少驶公里"); |
| 1241 | newMap.put("lblc", lblc); | 1243 | newMap.put("lblc", lblc); |
| 1244 | + newMap.put("dz", " "); | ||
| 1245 | + newMap.put("sj", " "); | ||
| 1246 | + newMap.put("gzf", " "); | ||
| 1247 | + newMap.put("jyqp"," "); | ||
| 1242 | listNew.add(newMap); | 1248 | listNew.add(newMap); |
| 1243 | } | 1249 | } |
| 1244 | 1250 | ||
| @@ -1271,7 +1277,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -1271,7 +1277,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1271 | newMap.put("dz", scheduleRealInfo.getQdzName()); | 1277 | newMap.put("dz", scheduleRealInfo.getQdzName()); |
| 1272 | newMap.put("sj", scheduleRealInfo.getFcsj()); | 1278 | newMap.put("sj", scheduleRealInfo.getFcsj()); |
| 1273 | newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); | 1279 | newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc()); |
| 1274 | - newMap.put("jyqp", scheduleRealInfo.getRealMileage()); | 1280 | + newMap.put("jyqp", scheduleRealInfo.getRealMileage()==null?"":scheduleRealInfo.getRealMileage()); |
| 1275 | list.add(newMap); | 1281 | list.add(newMap); |
| 1276 | } | 1282 | } |
| 1277 | // }else{ | 1283 | // }else{ |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| @@ -8,6 +8,7 @@ import com.bsth.repository.LineRepository; | @@ -8,6 +8,7 @@ import com.bsth.repository.LineRepository; | ||
| 8 | import com.bsth.repository.schedule.*; | 8 | import com.bsth.repository.schedule.*; |
| 9 | import com.bsth.service.schedule.SchedulePlanRuleResultService; | 9 | import com.bsth.service.schedule.SchedulePlanRuleResultService; |
| 10 | import com.bsth.service.schedule.SchedulePlanService; | 10 | import com.bsth.service.schedule.SchedulePlanService; |
| 11 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 11 | import com.bsth.service.schedule.rules.ScheduleRuleService; | 12 | import com.bsth.service.schedule.rules.ScheduleRuleService; |
| 12 | import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input; | 13 | import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input; |
| 13 | import com.bsth.service.schedule.rules.plan.PlanResult; | 14 | import com.bsth.service.schedule.rules.plan.PlanResult; |
| @@ -24,9 +25,6 @@ import org.slf4j.Logger; | @@ -24,9 +25,6 @@ import org.slf4j.Logger; | ||
| 24 | import org.slf4j.LoggerFactory; | 25 | import org.slf4j.LoggerFactory; |
| 25 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
| 27 | -import org.springframework.transaction.annotation.Isolation; | ||
| 28 | -import org.springframework.transaction.annotation.Propagation; | ||
| 29 | -import org.springframework.transaction.annotation.Transactional; | ||
| 30 | 28 | ||
| 31 | import java.util.*; | 29 | import java.util.*; |
| 32 | 30 | ||
| @@ -216,32 +214,53 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -216,32 +214,53 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 216 | 214 | ||
| 217 | } | 215 | } |
| 218 | 216 | ||
| 219 | - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 220 | public SchedulePlan save(SchedulePlan schedulePlan) { | 217 | public SchedulePlan save(SchedulePlan schedulePlan) { |
| 221 | // pre、如果排班的数据之前已经有了,删除之前的数据 | 218 | // pre、如果排班的数据之前已经有了,删除之前的数据 |
| 222 | - schedulePlanInfoRepository.deleteByXlAndScheduleDateGreaterThanEqualAndScheduleDateLessThanEqual( | ||
| 223 | - schedulePlan.getXl().getId(), schedulePlan.getScheduleFromTime(), schedulePlan.getScheduleToTime() | ||
| 224 | - ); | 219 | + Date startpre = new Date(); |
| 220 | + scheduleRuleService.deelteSchedulePlanInfo( | ||
| 221 | + schedulePlan.getXl().getId(), | ||
| 222 | + schedulePlan.getScheduleFromTime(), | ||
| 223 | + schedulePlan.getScheduleToTime()); | ||
| 224 | + Date endpre = new Date(); | ||
| 225 | 225 | ||
| 226 | // 1、时刻表数据及每日路牌数据计算 | 226 | // 1、时刻表数据及每日路牌数据计算 |
| 227 | + Date start1 = new Date(); | ||
| 227 | Object[] ttInfoRets = ttInfoOutput(schedulePlan); | 228 | Object[] ttInfoRets = ttInfoOutput(schedulePlan); |
| 228 | TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0]; | 229 | TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0]; |
| 229 | LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; | 230 | LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; |
| 231 | + Date end1 = new Date(); | ||
| 230 | // 2、循环规则计算输出 | 232 | // 2、循环规则计算输出 |
| 233 | + Date start2 = new Date(); | ||
| 231 | ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output); | 234 | ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output); |
| 235 | + Date end2 = new Date(); | ||
| 232 | // 3、计划输出 | 236 | // 3、计划输出 |
| 237 | + Date start3 = new Date(); | ||
| 233 | PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); | 238 | PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); |
| 239 | + Date end3 = new Date(); | ||
| 240 | + | ||
| 241 | + // 4、保存数据(jdbcTemplate 批量插入) | ||
| 242 | + Date start4 = new Date(); | ||
| 243 | + scheduleRuleService.generateSchedulePlan(schedulePlan, planResult.getSchedulePlanInfos()); | ||
| 244 | + Date end4 = new Date(); | ||
| 245 | + | ||
| 234 | 246 | ||
| 235 | - // 4、保存数据(TODO:之后改成批量保存) | ||
| 236 | - schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos()); | ||
| 237 | - super.save(schedulePlan); | 247 | + logger.info("删除数据 {} ms,drool时刻表每日路牌计算 {} ms,drool循环规则计算 {} ms,drool计划数据 {} ms,插入数据 {} ms", |
| 248 | + endpre.getTime() - startpre.getTime(), | ||
| 249 | + end1.getTime() - start1.getTime(), | ||
| 250 | + end2.getTime() - start2.getTime(), | ||
| 251 | + end3.getTime() - start3.getTime(), | ||
| 252 | + end4.getTime() - start4.getTime()); | ||
| 238 | 253 | ||
| 239 | - schedulePlanRuleResultService.bulkSave(scheduleResults_output.getSchedulePlanRuleResults()); | ||
| 240 | 254 | ||
| 241 | return new SchedulePlan(); | 255 | return new SchedulePlan(); |
| 242 | } | 256 | } |
| 243 | 257 | ||
| 244 | @Override | 258 | @Override |
| 259 | + public void delete(Long aLong) throws ScheduleException { | ||
| 260 | + scheduleRuleService.deleteSchedulePlanAll(aLong); | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + @Override | ||
| 245 | public SchedulePlan findSchedulePlanTommorw() { | 264 | public SchedulePlan findSchedulePlanTommorw() { |
| 246 | DateTime today = new DateTime(new Date()); | 265 | DateTime today = new DateTime(new Date()); |
| 247 | DateTime tommorw = new DateTime(today.getYear(), today.getMonthOfYear(), today.getDayOfMonth(), 0, 0).plusDays(1); | 266 | DateTime tommorw = new DateTime(today.getYear(), today.getMonthOfYear(), today.getDayOfMonth(), 0, 0).plusDays(1); |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleService.java
| 1 | package com.bsth.service.schedule.rules; | 1 | package com.bsth.service.schedule.rules; |
| 2 | 2 | ||
| 3 | +import com.bsth.entity.schedule.SchedulePlan; | ||
| 4 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 3 | import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; | 5 | import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; |
| 4 | 6 | ||
| 5 | import java.util.Date; | 7 | import java.util.Date; |
| @@ -19,4 +21,26 @@ public interface ScheduleRuleService { | @@ -19,4 +21,26 @@ public interface ScheduleRuleService { | ||
| 19 | * @return | 21 | * @return |
| 20 | */ | 22 | */ |
| 21 | List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from); | 23 | List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from); |
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 生成排班计划。 | ||
| 27 | + * @param schedulePlan 计划主表 | ||
| 28 | + * @param schedulePlanInfos 计划明细表 | ||
| 29 | + */ | ||
| 30 | + void generateSchedulePlan(SchedulePlan schedulePlan, List<SchedulePlanInfo> schedulePlanInfos); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除排班计划。 | ||
| 34 | + * @param id 排班计划id | ||
| 35 | + */ | ||
| 36 | + void deleteSchedulePlanAll(Long id); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 删除指定时间范围的排班明细。 | ||
| 40 | + * @param xlid 线路id | ||
| 41 | + * @param datefrom 开始日期 | ||
| 42 | + * @param dateto 结束日期 | ||
| 43 | + */ | ||
| 44 | + void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto); | ||
| 22 | } | 45 | } |
| 46 | + |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleServiceImpl.java
| 1 | package com.bsth.service.schedule.rules; | 1 | package com.bsth.service.schedule.rules; |
| 2 | 2 | ||
| 3 | +import com.bsth.entity.schedule.SchedulePlan; | ||
| 4 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 3 | import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; | 5 | import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; |
| 6 | +import org.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 4 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 5 | import org.springframework.jdbc.core.JdbcTemplate; | 10 | import org.springframework.jdbc.core.JdbcTemplate; |
| 11 | +import org.springframework.jdbc.core.PreparedStatementCreator; | ||
| 6 | import org.springframework.jdbc.core.RowMapper; | 12 | import org.springframework.jdbc.core.RowMapper; |
| 13 | +import org.springframework.jdbc.support.GeneratedKeyHolder; | ||
| 14 | +import org.springframework.jdbc.support.KeyHolder; | ||
| 7 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 16 | +import org.springframework.transaction.annotation.Isolation; | ||
| 17 | +import org.springframework.transaction.annotation.Propagation; | ||
| 18 | +import org.springframework.transaction.annotation.Transactional; | ||
| 8 | 19 | ||
| 20 | +import java.sql.Connection; | ||
| 21 | +import java.sql.PreparedStatement; | ||
| 9 | import java.sql.ResultSet; | 22 | import java.sql.ResultSet; |
| 10 | import java.sql.SQLException; | 23 | import java.sql.SQLException; |
| 24 | +import java.util.ArrayList; | ||
| 11 | import java.util.Date; | 25 | import java.util.Date; |
| 12 | import java.util.List; | 26 | import java.util.List; |
| 13 | 27 | ||
| @@ -16,6 +30,8 @@ import java.util.List; | @@ -16,6 +30,8 @@ import java.util.List; | ||
| 16 | */ | 30 | */ |
| 17 | @Service | 31 | @Service |
| 18 | public class ScheduleRuleServiceImpl implements ScheduleRuleService { | 32 | public class ScheduleRuleServiceImpl implements ScheduleRuleService { |
| 33 | + /** 日志记录器 */ | ||
| 34 | + private static final Logger logger = LoggerFactory.getLogger(ScheduleRuleServiceImpl.class); | ||
| 19 | 35 | ||
| 20 | @Autowired | 36 | @Autowired |
| 21 | private JdbcTemplate jdbcTemplate; | 37 | private JdbcTemplate jdbcTemplate; |
| @@ -43,4 +59,70 @@ public class ScheduleRuleServiceImpl implements ScheduleRuleService { | @@ -43,4 +59,70 @@ public class ScheduleRuleServiceImpl implements ScheduleRuleService { | ||
| 43 | } | 59 | } |
| 44 | }); | 60 | }); |
| 45 | } | 61 | } |
| 62 | + | ||
| 63 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 64 | + public void deleteSchedulePlanAll(Long id) { | ||
| 65 | + String sql1 = "delete from bsth_c_s_sp where id = ?"; | ||
| 66 | + String sql2 = "delete from bsth_c_s_sp_info where schedule_plan = ?"; | ||
| 67 | + | ||
| 68 | + jdbcTemplate.update(sql2, id); | ||
| 69 | + jdbcTemplate.update(sql1, id); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 73 | + public void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto) { | ||
| 74 | + String sql = "delete from bsth_c_s_sp_info where xl = ? and schedule_date >= ? and schedule_date <= ?"; | ||
| 75 | + jdbcTemplate.update(sql, xlid, datefrom, dateto); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 79 | + @Override | ||
| 80 | + public void generateSchedulePlan(final SchedulePlan schedulePlan, final List<SchedulePlanInfo> schedulePlanInfos) { | ||
| 81 | + // 1、插入排班计划主表,并获取主键id | ||
| 82 | + KeyHolder keyHolder = new GeneratedKeyHolder(); | ||
| 83 | + jdbcTemplate.update(new PreparedStatementCreator() { | ||
| 84 | + @Override | ||
| 85 | + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { | ||
| 86 | + PreparedStatement ps = connection.prepareStatement( | ||
| 87 | + SchedulePlan.generateInsertSql(), new String[] {"id"}); | ||
| 88 | + schedulePlan.preparedStatementSet(ps); | ||
| 89 | + | ||
| 90 | + return ps; | ||
| 91 | + } | ||
| 92 | + }, keyHolder); | ||
| 93 | + | ||
| 94 | + SchedulePlan master = new SchedulePlan(); | ||
| 95 | + master.setId(keyHolder.getKey().longValue()); | ||
| 96 | + for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | ||
| 97 | + schedulePlanInfo.setSchedulePlan(master); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + // 2、批量插入排班计划从表 | ||
| 101 | + List<List<SchedulePlanInfo>> lists = new ArrayList<>(); | ||
| 102 | + int batchSize = 2000; | ||
| 103 | + int loopCount = schedulePlanInfos.size() / batchSize; | ||
| 104 | + int otherCount = schedulePlanInfos.size() % batchSize; | ||
| 105 | + for (int i = 0; i < loopCount; i++) { | ||
| 106 | + lists.add(schedulePlanInfos.subList(i * batchSize, i * batchSize + batchSize)); | ||
| 107 | + } | ||
| 108 | + if (otherCount > 0) { | ||
| 109 | + lists.add(schedulePlanInfos.subList(loopCount * batchSize, loopCount * batchSize + otherCount)); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + for (final List<SchedulePlanInfo> list : lists) { | ||
| 113 | + jdbcTemplate.batchUpdate(SchedulePlanInfo.generateInsertSql(), new BatchPreparedStatementSetter() { | ||
| 114 | + @Override | ||
| 115 | + public void setValues(PreparedStatement preparedStatement, int i) throws SQLException { | ||
| 116 | + SchedulePlanInfo schedulePlanInfo = list.get(i); | ||
| 117 | + schedulePlanInfo.preparedStatementSet(preparedStatement); | ||
| 118 | + } | ||
| 119 | + @Override | ||
| 120 | + public int getBatchSize() { | ||
| 121 | + return list.size(); | ||
| 122 | + } | ||
| 123 | + }); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + } | ||
| 46 | } | 127 | } |
| 128 | + |