Commit 668bce7933c9e2f17dff8073b8dd78e8e4bb6101
Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control into pudong
Showing
32 changed files
with
2797 additions
and
846 deletions
Too many changes to show.
To preserve performance only 32 of 44 files are displayed.
src/main/java/com/bsth/controller/calc/CalcWaybillController.java
| @@ -6,6 +6,7 @@ import java.util.Map; | @@ -6,6 +6,7 @@ import java.util.Map; | ||
| 6 | 6 | ||
| 7 | import com.bsth.common.ResponseCode; | 7 | import com.bsth.common.ResponseCode; |
| 8 | import com.bsth.controller.BaseController; | 8 | import com.bsth.controller.BaseController; |
| 9 | +import com.bsth.entity.calc.CalcStatistics; | ||
| 9 | import com.bsth.entity.calc.CalcWaybill; | 10 | import com.bsth.entity.calc.CalcWaybill; |
| 10 | import com.bsth.service.calc.CalcWaybillService; | 11 | import com.bsth.service.calc.CalcWaybillService; |
| 11 | 12 | ||
| @@ -26,19 +27,26 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer> | @@ -26,19 +27,26 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer> | ||
| 26 | 27 | ||
| 27 | @RequestMapping(value="/generateNew") | 28 | @RequestMapping(value="/generateNew") |
| 28 | public Map<String, Object> generateNews(@RequestParam Map<String, Object> map) throws Exception{ | 29 | public Map<String, Object> generateNews(@RequestParam Map<String, Object> map) throws Exception{ |
| 29 | - String date = "", line = ""; | 30 | + String date = "", line = "", key=""; |
| 30 | if(map.get("date")!=null){ | 31 | if(map.get("date")!=null){ |
| 31 | date=map.get("date").toString().trim(); | 32 | date=map.get("date").toString().trim(); |
| 32 | } | 33 | } |
| 33 | if(map.get("line")!=null){ | 34 | if(map.get("line")!=null){ |
| 34 | line=map.get("line").toString().trim(); | 35 | line=map.get("line").toString().trim(); |
| 35 | } | 36 | } |
| 37 | + if(map.get("key")!=null){ | ||
| 38 | + key=map.get("key").toString().trim(); | ||
| 39 | + } | ||
| 36 | 40 | ||
| 37 | Map<String, Object> m = new HashMap<String, Object>(); | 41 | Map<String, Object> m = new HashMap<String, Object>(); |
| 38 | try { | 42 | try { |
| 39 | 43 | ||
| 40 | m = calcWaybillService.generateNew(date, line); | 44 | m = calcWaybillService.generateNew(date, line); |
| 41 | 45 | ||
| 46 | + if(key.length() == 0){ | ||
| 47 | + m.put("status", calcWaybillService.calcDaily(date, line)); | ||
| 48 | + } | ||
| 49 | + | ||
| 42 | } catch (Exception e) { | 50 | } catch (Exception e) { |
| 43 | // TODO: handle exception | 51 | // TODO: handle exception |
| 44 | e.printStackTrace(); | 52 | e.printStackTrace(); |
| @@ -82,4 +90,61 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer> | @@ -82,4 +90,61 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer> | ||
| 82 | return calcWaybillService.statisticsDailyTj(gsdm,fgsdm,line,date,date2,xlName,type); | 90 | return calcWaybillService.statisticsDailyTj(gsdm,fgsdm,line,date,date2,xlName,type); |
| 83 | } | 91 | } |
| 84 | 92 | ||
| 93 | + @RequestMapping(value="/generateDaliy") | ||
| 94 | + public Map<String, Object> generateDaliy(@RequestParam Map<String, Object> map) throws Exception{ | ||
| 95 | + String date = "", line = ""; | ||
| 96 | + if(map.containsKey("date") && map.get("date")!=null){ | ||
| 97 | + date=map.get("date").toString().trim(); | ||
| 98 | + } | ||
| 99 | + if(map.containsKey("line") && map.get("line")!=null){ | ||
| 100 | + line=map.get("line").toString().trim(); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 104 | + try { | ||
| 105 | + | ||
| 106 | + m.put("status", calcWaybillService.calcDaily(date, line)); | ||
| 107 | + | ||
| 108 | + } catch (Exception e) { | ||
| 109 | + // TODO: handle exception | ||
| 110 | + e.printStackTrace(); | ||
| 111 | + m.put("status", ResponseCode.ERROR); | ||
| 112 | + return m; | ||
| 113 | + } | ||
| 114 | + return m; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + @RequestMapping(value="/calcStatisticsDaily") | ||
| 118 | + public List<CalcStatistics> calcStatisticsDaily(@RequestParam Map<String, Object> map){ | ||
| 119 | + String gsdm=""; | ||
| 120 | + if(map.get("gsdm")!=null){ | ||
| 121 | + gsdm=map.get("gsdm").toString().trim(); | ||
| 122 | + } | ||
| 123 | + String fgsdm=""; | ||
| 124 | + if(map.get("fgsdm")!=null){ | ||
| 125 | + fgsdm=map.get("fgsdm").toString().trim(); | ||
| 126 | + } | ||
| 127 | + String line=""; | ||
| 128 | + if(map.get("line")!=null){ | ||
| 129 | + line=map.get("line").toString().trim(); | ||
| 130 | + } | ||
| 131 | + String date=""; | ||
| 132 | + if(map.get("date")!=null){ | ||
| 133 | + date=map.get("date").toString().trim(); | ||
| 134 | + } | ||
| 135 | + String date2=""; | ||
| 136 | + if(map.get("date2")!=null){ | ||
| 137 | + date2=map.get("date2").toString().trim(); | ||
| 138 | + } | ||
| 139 | + String xlName=""; | ||
| 140 | + if(map.get("xlName")!=null){ | ||
| 141 | + xlName=map.get("xlName").toString().trim(); | ||
| 142 | + } | ||
| 143 | + String type=""; | ||
| 144 | + if(map.get("type")!=null){ | ||
| 145 | + type=map.get("type").toString().trim(); | ||
| 146 | + } | ||
| 147 | + return calcWaybillService.calcStatisticsDaily(gsdm,fgsdm,line,date,date2,xlName,type); | ||
| 148 | + } | ||
| 149 | + | ||
| 85 | } | 150 | } |
src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController.java
| @@ -6,6 +6,7 @@ import com.bsth.entity.schedule.TTInfoDetail; | @@ -6,6 +6,7 @@ import com.bsth.entity.schedule.TTInfoDetail; | ||
| 6 | import com.bsth.service.schedule.TTInfoDetailService; | 6 | import com.bsth.service.schedule.TTInfoDetailService; |
| 7 | import com.bsth.service.schedule.datatools.TTInfoDetailForEdit; | 7 | import com.bsth.service.schedule.datatools.TTInfoDetailForEdit; |
| 8 | import com.bsth.service.schedule.datatools.TTinfoDetailDynamicData; | 8 | import com.bsth.service.schedule.datatools.TTinfoDetailDynamicData; |
| 9 | +import com.bsth.service.schedule.timetable.ExcelFormatType; | ||
| 9 | import com.bsth.service.schedule.utils.DataToolsFile; | 10 | import com.bsth.service.schedule.utils.DataToolsFile; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.web.bind.annotation.*; | 12 | import org.springframework.web.bind.annotation.*; |
| @@ -41,13 +42,14 @@ public class TTInfoDetailController extends BController<TTInfoDetail, Long> { | @@ -41,13 +42,14 @@ public class TTInfoDetailController extends BController<TTInfoDetail, Long> { | ||
| 41 | */ | 42 | */ |
| 42 | @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST) | 43 | @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST) |
| 43 | public Map<String, Object> validate_sheet( | 44 | public Map<String, Object> validate_sheet( |
| 44 | - String filename, String sheetname, Integer lineid, String linename, Integer lineversion) { | 45 | + String filename, String sheetname, Integer lineid, String linename, Integer lineversion, String excelFormatType) { |
| 45 | Map<String, Object> rtn = new HashMap<>(); | 46 | Map<String, Object> rtn = new HashMap<>(); |
| 46 | try { | 47 | try { |
| 47 | if (lineversion == null) { | 48 | if (lineversion == null) { |
| 48 | throw new Exception("线路版本未知"); | 49 | throw new Exception("线路版本未知"); |
| 49 | } | 50 | } |
| 50 | - ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename, lineversion); | 51 | + ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename, lineversion, |
| 52 | + ExcelFormatType.getEnum(excelFormatType)); | ||
| 51 | rtn.put("status", ResponseCode.SUCCESS); | 53 | rtn.put("status", ResponseCode.SUCCESS); |
| 52 | } catch (Exception exp) { | 54 | } catch (Exception exp) { |
| 53 | rtn.put("status", ResponseCode.ERROR); | 55 | rtn.put("status", ResponseCode.ERROR); |
src/main/java/com/bsth/data/schedule/thread/CalcOilThread.java
| @@ -3,6 +3,7 @@ package com.bsth.data.schedule.thread; | @@ -3,6 +3,7 @@ package com.bsth.data.schedule.thread; | ||
| 3 | import com.bsth.data.directive.DayOfDirectives; | 3 | import com.bsth.data.directive.DayOfDirectives; |
| 4 | import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | 4 | import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; |
| 5 | import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | 5 | import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; |
| 6 | +import com.bsth.service.calc.CalcWaybillService; | ||
| 6 | import com.bsth.service.oil.DlbService; | 7 | import com.bsth.service.oil.DlbService; |
| 7 | import com.bsth.data.safe_driv.SafeDrivCenter; | 8 | import com.bsth.data.safe_driv.SafeDrivCenter; |
| 8 | import com.bsth.service.oil.YlbService; | 9 | import com.bsth.service.oil.YlbService; |
| @@ -31,6 +32,9 @@ public class CalcOilThread extends Thread{ | @@ -31,6 +32,9 @@ public class CalcOilThread extends Thread{ | ||
| 31 | 32 | ||
| 32 | @Autowired | 33 | @Autowired |
| 33 | DayOfDirectives dayOfDirectives; | 34 | DayOfDirectives dayOfDirectives; |
| 35 | + | ||
| 36 | + @Autowired | ||
| 37 | + CalcWaybillService calcWaybillService; | ||
| 34 | 38 | ||
| 35 | @Override | 39 | @Override |
| 36 | public void run() { | 40 | public void run() { |
| @@ -42,6 +46,9 @@ public class CalcOilThread extends Thread{ | @@ -42,6 +46,9 @@ public class CalcOilThread extends Thread{ | ||
| 42 | logger.info("开始计算班次准点率...."); | 46 | logger.info("开始计算班次准点率...."); |
| 43 | sheetService.saveSheetList(""); | 47 | sheetService.saveSheetList(""); |
| 44 | logger.info("计算班次准点率结束!"); | 48 | logger.info("计算班次准点率结束!"); |
| 49 | + logger.info("开始保存统计日报...."); | ||
| 50 | + calcWaybillService.calcDaily("", ""); | ||
| 51 | + logger.info("统计日报保存完成!"); | ||
| 45 | } catch(Exception e){ | 52 | } catch(Exception e){ |
| 46 | logger.error("计算路单里程加注量失败",e); | 53 | logger.error("计算路单里程加注量失败",e); |
| 47 | } | 54 | } |
src/main/java/com/bsth/entity/calc/CalcInterval.java
0 → 100644
| 1 | +package com.bsth.entity.calc; | ||
| 2 | + | ||
| 3 | +import java.util.Date; | ||
| 4 | + | ||
| 5 | +import javax.persistence.Entity; | ||
| 6 | +import javax.persistence.GeneratedValue; | ||
| 7 | +import javax.persistence.Id; | ||
| 8 | +import javax.persistence.Table; | ||
| 9 | + | ||
| 10 | +@Entity | ||
| 11 | +@Table(name = "calc_interval") | ||
| 12 | +public class CalcInterval { | ||
| 13 | + /* 主键*/ | ||
| 14 | + @Id | ||
| 15 | + @GeneratedValue | ||
| 16 | + private Long id; | ||
| 17 | + /* 公司代码*/ | ||
| 18 | + private String gsdm; | ||
| 19 | + /* 公司名称*/ | ||
| 20 | + private String gsname; | ||
| 21 | + /* 分公司代码*/ | ||
| 22 | + private String fgsdm; | ||
| 23 | + /* 分公司名称*/ | ||
| 24 | + private String fgsname; | ||
| 25 | + /* 日期*/ | ||
| 26 | + private Date rq; | ||
| 27 | + /* 日期字符串*/ | ||
| 28 | + private String rqStr; | ||
| 29 | + /* 线路编码*/ | ||
| 30 | + private String xl; | ||
| 31 | + /* 线路名称*/ | ||
| 32 | + private String xlName; | ||
| 33 | + /* 大间隔次数*/ | ||
| 34 | + private int djg; | ||
| 35 | + /* 大间隔次数(早高峰)*/ | ||
| 36 | + private int djgM; | ||
| 37 | + /* 大间隔次数(晚高峰)*/ | ||
| 38 | + private int djgA; | ||
| 39 | + /* 最大大间隔时间*/ | ||
| 40 | + private int djgTime; | ||
| 41 | + /* 备注*/ | ||
| 42 | + private String remark; | ||
| 43 | + public Long getId() { | ||
| 44 | + return id; | ||
| 45 | + } | ||
| 46 | + public void setId(Long id) { | ||
| 47 | + this.id = id; | ||
| 48 | + } | ||
| 49 | + public String getGsdm() { | ||
| 50 | + return gsdm; | ||
| 51 | + } | ||
| 52 | + public void setGsdm(String gsdm) { | ||
| 53 | + this.gsdm = gsdm; | ||
| 54 | + } | ||
| 55 | + public String getGsname() { | ||
| 56 | + return gsname; | ||
| 57 | + } | ||
| 58 | + public void setGsname(String gsname) { | ||
| 59 | + this.gsname = gsname; | ||
| 60 | + } | ||
| 61 | + public String getFgsdm() { | ||
| 62 | + return fgsdm; | ||
| 63 | + } | ||
| 64 | + public void setFgsdm(String fgsdm) { | ||
| 65 | + this.fgsdm = fgsdm; | ||
| 66 | + } | ||
| 67 | + public String getFgsname() { | ||
| 68 | + return fgsname; | ||
| 69 | + } | ||
| 70 | + public void setFgsname(String fgsname) { | ||
| 71 | + this.fgsname = fgsname; | ||
| 72 | + } | ||
| 73 | + public Date getRq() { | ||
| 74 | + return rq; | ||
| 75 | + } | ||
| 76 | + public void setRq(Date rq) { | ||
| 77 | + this.rq = rq; | ||
| 78 | + } | ||
| 79 | + public String getRqStr() { | ||
| 80 | + return rqStr; | ||
| 81 | + } | ||
| 82 | + public void setRqStr(String rqStr) { | ||
| 83 | + this.rqStr = rqStr; | ||
| 84 | + } | ||
| 85 | + public String getXl() { | ||
| 86 | + return xl; | ||
| 87 | + } | ||
| 88 | + public void setXl(String xl) { | ||
| 89 | + this.xl = xl; | ||
| 90 | + } | ||
| 91 | + public String getXlName() { | ||
| 92 | + return xlName; | ||
| 93 | + } | ||
| 94 | + public void setXlName(String xlName) { | ||
| 95 | + this.xlName = xlName; | ||
| 96 | + } | ||
| 97 | + public int getDjg() { | ||
| 98 | + return djg; | ||
| 99 | + } | ||
| 100 | + public void setDjg(int djg) { | ||
| 101 | + this.djg = djg; | ||
| 102 | + } | ||
| 103 | + public int getDjgM() { | ||
| 104 | + return djgM; | ||
| 105 | + } | ||
| 106 | + public void setDjgM(int djgM) { | ||
| 107 | + this.djgM = djgM; | ||
| 108 | + } | ||
| 109 | + public int getDjgA() { | ||
| 110 | + return djgA; | ||
| 111 | + } | ||
| 112 | + public void setDjgA(int djgA) { | ||
| 113 | + this.djgA = djgA; | ||
| 114 | + } | ||
| 115 | + public int getDjgTime() { | ||
| 116 | + return djgTime; | ||
| 117 | + } | ||
| 118 | + public void setDjgTime(int djgTime) { | ||
| 119 | + this.djgTime = djgTime; | ||
| 120 | + } | ||
| 121 | + public String getRemark() { | ||
| 122 | + return remark; | ||
| 123 | + } | ||
| 124 | + public void setRemark(String remark) { | ||
| 125 | + this.remark = remark; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | +} |
src/main/java/com/bsth/entity/calc/CalcStatistics.java
0 → 100644
| 1 | +package com.bsth.entity.calc; | ||
| 2 | + | ||
| 3 | +import java.util.Date; | ||
| 4 | + | ||
| 5 | +import javax.persistence.Entity; | ||
| 6 | +import javax.persistence.GeneratedValue; | ||
| 7 | +import javax.persistence.Id; | ||
| 8 | +import javax.persistence.Table; | ||
| 9 | + | ||
| 10 | +@Entity | ||
| 11 | +@Table(name = "calc_statistics") | ||
| 12 | +public class CalcStatistics { | ||
| 13 | + /* 主键*/ | ||
| 14 | + @Id | ||
| 15 | + @GeneratedValue | ||
| 16 | + private Long id; | ||
| 17 | + /* 日期*/ | ||
| 18 | + private Date date; | ||
| 19 | + /* 日期字符串*/ | ||
| 20 | + private String dateStr; | ||
| 21 | + /* 线路编码*/ | ||
| 22 | + private String xl; | ||
| 23 | + /* 线路名称*/ | ||
| 24 | + private String xlName; | ||
| 25 | + /* 公司代码*/ | ||
| 26 | + private String gsdm; | ||
| 27 | + /* 分公司代码*/ | ||
| 28 | + private String fgsdm; | ||
| 29 | + /* 计划总公里*/ | ||
| 30 | + private Double jhzlc; | ||
| 31 | + /* 计划营运公里*/ | ||
| 32 | + private Double jhyylc; | ||
| 33 | + /* 计划空驶公里*/ | ||
| 34 | + private Double jhkslc; | ||
| 35 | + /* 实际总公里*/ | ||
| 36 | + private Double sjzlc; | ||
| 37 | + /* 实际营运公里*/ | ||
| 38 | + private Double sjyylc; | ||
| 39 | + /* 实际空驶公里*/ | ||
| 40 | + private Double sjkslc; | ||
| 41 | + /* 少驶公里*/ | ||
| 42 | + private Double sslc; | ||
| 43 | + /* 少驶班次*/ | ||
| 44 | + private int ssbc; | ||
| 45 | + /* 路阻公里*/ | ||
| 46 | + private Double lzlc; | ||
| 47 | + /* 吊慢公里*/ | ||
| 48 | + private Double dmlc; | ||
| 49 | + /* 故障公里*/ | ||
| 50 | + private Double gzlc; | ||
| 51 | + /* 纠纷公里*/ | ||
| 52 | + private Double jflc; | ||
| 53 | + /* 肇事公里*/ | ||
| 54 | + private Double zslc; | ||
| 55 | + /* 缺人公里*/ | ||
| 56 | + private Double qrlc; | ||
| 57 | + /* 缺车公里*/ | ||
| 58 | + private Double qclc; | ||
| 59 | + /* 客稀公里*/ | ||
| 60 | + private Double kxlc; | ||
| 61 | + /* 气候公里*/ | ||
| 62 | + private Double qhlc; | ||
| 63 | + /* 援外公里*/ | ||
| 64 | + private Double ywlc; | ||
| 65 | + /* 其他公里*/ | ||
| 66 | + private Double qtlc; | ||
| 67 | + /* 临加公里*/ | ||
| 68 | + private Double ljlc; | ||
| 69 | + /* 计划班次*/ | ||
| 70 | + private int jhbcq; | ||
| 71 | + /* 计划班次(早高峰)*/ | ||
| 72 | + private int jhbcz; | ||
| 73 | + /* 计划班次(晚高峰)*/ | ||
| 74 | + private int jhbcw; | ||
| 75 | + /* 实际班次*/ | ||
| 76 | + private int sjbcq; | ||
| 77 | + /* 实际班次(早高峰)*/ | ||
| 78 | + private int sjbcz; | ||
| 79 | + /* 实际班次(晚高峰)*/ | ||
| 80 | + private int sjbcw; | ||
| 81 | + /* 临加班次*/ | ||
| 82 | + private int ljbcq; | ||
| 83 | + /* 临加班次(早高峰)*/ | ||
| 84 | + private int ljbcz; | ||
| 85 | + /* 临加班次(晚高峰)*/ | ||
| 86 | + private int ljbcw; | ||
| 87 | + /* 放站班次*/ | ||
| 88 | + private int fzbcq; | ||
| 89 | + /* 放站班次(早高峰)*/ | ||
| 90 | + private int fzbcz; | ||
| 91 | + /* 放站班次(晚高峰)*/ | ||
| 92 | + private int fzbcw; | ||
| 93 | + /* 调头班次*/ | ||
| 94 | + private int dtbcq; | ||
| 95 | + /* 调头班次(早高峰)*/ | ||
| 96 | + private int dtbcz; | ||
| 97 | + /* 调头班次(晚高峰)*/ | ||
| 98 | + private int dtbcw; | ||
| 99 | + /* 大间隔次数*/ | ||
| 100 | + private int djgq; | ||
| 101 | + /* 大间隔次数(早高峰)*/ | ||
| 102 | + private int djgz; | ||
| 103 | + /* 大间隔次数(晚高峰)*/ | ||
| 104 | + private int djgw; | ||
| 105 | + /* 最大大间隔时间*/ | ||
| 106 | + private int djgsj; | ||
| 107 | + /* 备注*/ | ||
| 108 | + private String remark; | ||
| 109 | + | ||
| 110 | + | ||
| 111 | + public Long getId() { | ||
| 112 | + return id; | ||
| 113 | + } | ||
| 114 | + public void setId(Long id) { | ||
| 115 | + this.id = id; | ||
| 116 | + } | ||
| 117 | + public Date getDate() { | ||
| 118 | + return date; | ||
| 119 | + } | ||
| 120 | + public void setDate(Date date) { | ||
| 121 | + this.date = date; | ||
| 122 | + } | ||
| 123 | + public String getDateStr() { | ||
| 124 | + return dateStr; | ||
| 125 | + } | ||
| 126 | + public void setDateStr(String dateStr) { | ||
| 127 | + this.dateStr = dateStr; | ||
| 128 | + } | ||
| 129 | + public String getXl() { | ||
| 130 | + return xl; | ||
| 131 | + } | ||
| 132 | + public void setXl(String xl) { | ||
| 133 | + this.xl = xl; | ||
| 134 | + } | ||
| 135 | + public String getXlName() { | ||
| 136 | + return xlName; | ||
| 137 | + } | ||
| 138 | + public void setXlName(String xlName) { | ||
| 139 | + this.xlName = xlName; | ||
| 140 | + } | ||
| 141 | + public String getGsdm() { | ||
| 142 | + return gsdm; | ||
| 143 | + } | ||
| 144 | + public void setGsdm(String gsdm) { | ||
| 145 | + this.gsdm = gsdm; | ||
| 146 | + } | ||
| 147 | + public String getFgsdm() { | ||
| 148 | + return fgsdm; | ||
| 149 | + } | ||
| 150 | + public void setFgsdm(String fgsdm) { | ||
| 151 | + this.fgsdm = fgsdm; | ||
| 152 | + } | ||
| 153 | + public Double getJhzlc() { | ||
| 154 | + return jhzlc; | ||
| 155 | + } | ||
| 156 | + public void setJhzlc(Double jhzlc) { | ||
| 157 | + this.jhzlc = jhzlc; | ||
| 158 | + } | ||
| 159 | + public Double getJhyylc() { | ||
| 160 | + return jhyylc; | ||
| 161 | + } | ||
| 162 | + public void setJhyylc(Double jhyylc) { | ||
| 163 | + this.jhyylc = jhyylc; | ||
| 164 | + } | ||
| 165 | + public Double getJhkslc() { | ||
| 166 | + return jhkslc; | ||
| 167 | + } | ||
| 168 | + public void setJhkslc(Double jhkslc) { | ||
| 169 | + this.jhkslc = jhkslc; | ||
| 170 | + } | ||
| 171 | + public Double getSjzlc() { | ||
| 172 | + return sjzlc; | ||
| 173 | + } | ||
| 174 | + public void setSjzlc(Double sjzlc) { | ||
| 175 | + this.sjzlc = sjzlc; | ||
| 176 | + } | ||
| 177 | + public Double getSjyylc() { | ||
| 178 | + return sjyylc; | ||
| 179 | + } | ||
| 180 | + public void setSjyylc(Double sjyylc) { | ||
| 181 | + this.sjyylc = sjyylc; | ||
| 182 | + } | ||
| 183 | + public Double getSjkslc() { | ||
| 184 | + return sjkslc; | ||
| 185 | + } | ||
| 186 | + public void setSjkslc(Double sjkslc) { | ||
| 187 | + this.sjkslc = sjkslc; | ||
| 188 | + } | ||
| 189 | + public Double getSslc() { | ||
| 190 | + return sslc; | ||
| 191 | + } | ||
| 192 | + public void setSslc(Double sslc) { | ||
| 193 | + this.sslc = sslc; | ||
| 194 | + } | ||
| 195 | + public int getSsbc() { | ||
| 196 | + return ssbc; | ||
| 197 | + } | ||
| 198 | + public void setSsbc(int ssbc) { | ||
| 199 | + this.ssbc = ssbc; | ||
| 200 | + } | ||
| 201 | + public Double getLzlc() { | ||
| 202 | + return lzlc; | ||
| 203 | + } | ||
| 204 | + public void setLzlc(Double lzlc) { | ||
| 205 | + this.lzlc = lzlc; | ||
| 206 | + } | ||
| 207 | + public Double getDmlc() { | ||
| 208 | + return dmlc; | ||
| 209 | + } | ||
| 210 | + public void setDmlc(Double dmlc) { | ||
| 211 | + this.dmlc = dmlc; | ||
| 212 | + } | ||
| 213 | + public Double getGzlc() { | ||
| 214 | + return gzlc; | ||
| 215 | + } | ||
| 216 | + public void setGzlc(Double gzlc) { | ||
| 217 | + this.gzlc = gzlc; | ||
| 218 | + } | ||
| 219 | + public Double getJflc() { | ||
| 220 | + return jflc; | ||
| 221 | + } | ||
| 222 | + public void setJflc(Double jflc) { | ||
| 223 | + this.jflc = jflc; | ||
| 224 | + } | ||
| 225 | + public Double getZslc() { | ||
| 226 | + return zslc; | ||
| 227 | + } | ||
| 228 | + public void setZslc(Double zslc) { | ||
| 229 | + this.zslc = zslc; | ||
| 230 | + } | ||
| 231 | + public Double getQrlc() { | ||
| 232 | + return qrlc; | ||
| 233 | + } | ||
| 234 | + public void setQrlc(Double qrlc) { | ||
| 235 | + this.qrlc = qrlc; | ||
| 236 | + } | ||
| 237 | + public Double getQclc() { | ||
| 238 | + return qclc; | ||
| 239 | + } | ||
| 240 | + public void setQclc(Double qclc) { | ||
| 241 | + this.qclc = qclc; | ||
| 242 | + } | ||
| 243 | + public Double getKxlc() { | ||
| 244 | + return kxlc; | ||
| 245 | + } | ||
| 246 | + public void setKxlc(Double kxlc) { | ||
| 247 | + this.kxlc = kxlc; | ||
| 248 | + } | ||
| 249 | + public Double getQhlc() { | ||
| 250 | + return qhlc; | ||
| 251 | + } | ||
| 252 | + public void setQhlc(Double qhlc) { | ||
| 253 | + this.qhlc = qhlc; | ||
| 254 | + } | ||
| 255 | + public Double getYwlc() { | ||
| 256 | + return ywlc; | ||
| 257 | + } | ||
| 258 | + public void setYwlc(Double ywlc) { | ||
| 259 | + this.ywlc = ywlc; | ||
| 260 | + } | ||
| 261 | + public Double getQtlc() { | ||
| 262 | + return qtlc; | ||
| 263 | + } | ||
| 264 | + public void setQtlc(Double qtlc) { | ||
| 265 | + this.qtlc = qtlc; | ||
| 266 | + } | ||
| 267 | + public Double getLjlc() { | ||
| 268 | + return ljlc; | ||
| 269 | + } | ||
| 270 | + public void setLjlc(Double ljlc) { | ||
| 271 | + this.ljlc = ljlc; | ||
| 272 | + } | ||
| 273 | + public int getJhbcq() { | ||
| 274 | + return jhbcq; | ||
| 275 | + } | ||
| 276 | + public void setJhbcq(int jhbcq) { | ||
| 277 | + this.jhbcq = jhbcq; | ||
| 278 | + } | ||
| 279 | + public int getJhbcz() { | ||
| 280 | + return jhbcz; | ||
| 281 | + } | ||
| 282 | + public void setJhbcz(int jhbcz) { | ||
| 283 | + this.jhbcz = jhbcz; | ||
| 284 | + } | ||
| 285 | + public int getJhbcw() { | ||
| 286 | + return jhbcw; | ||
| 287 | + } | ||
| 288 | + public void setJhbcw(int jhbcw) { | ||
| 289 | + this.jhbcw = jhbcw; | ||
| 290 | + } | ||
| 291 | + public int getSjbcq() { | ||
| 292 | + return sjbcq; | ||
| 293 | + } | ||
| 294 | + public void setSjbcq(int sjbcq) { | ||
| 295 | + this.sjbcq = sjbcq; | ||
| 296 | + } | ||
| 297 | + public int getSjbcz() { | ||
| 298 | + return sjbcz; | ||
| 299 | + } | ||
| 300 | + public void setSjbcz(int sjbcz) { | ||
| 301 | + this.sjbcz = sjbcz; | ||
| 302 | + } | ||
| 303 | + public int getSjbcw() { | ||
| 304 | + return sjbcw; | ||
| 305 | + } | ||
| 306 | + public void setSjbcw(int sjbcw) { | ||
| 307 | + this.sjbcw = sjbcw; | ||
| 308 | + } | ||
| 309 | + public int getLjbcq() { | ||
| 310 | + return ljbcq; | ||
| 311 | + } | ||
| 312 | + public void setLjbcq(int ljbcq) { | ||
| 313 | + this.ljbcq = ljbcq; | ||
| 314 | + } | ||
| 315 | + public int getLjbcz() { | ||
| 316 | + return ljbcz; | ||
| 317 | + } | ||
| 318 | + public void setLjbcz(int ljbcz) { | ||
| 319 | + this.ljbcz = ljbcz; | ||
| 320 | + } | ||
| 321 | + public int getLjbcw() { | ||
| 322 | + return ljbcw; | ||
| 323 | + } | ||
| 324 | + public void setLjbcw(int ljbcw) { | ||
| 325 | + this.ljbcw = ljbcw; | ||
| 326 | + } | ||
| 327 | + public int getFzbcq() { | ||
| 328 | + return fzbcq; | ||
| 329 | + } | ||
| 330 | + public void setFzbcq(int fzbcq) { | ||
| 331 | + this.fzbcq = fzbcq; | ||
| 332 | + } | ||
| 333 | + public int getFzbcz() { | ||
| 334 | + return fzbcz; | ||
| 335 | + } | ||
| 336 | + public void setFzbcz(int fzbcz) { | ||
| 337 | + this.fzbcz = fzbcz; | ||
| 338 | + } | ||
| 339 | + public int getFzbcw() { | ||
| 340 | + return fzbcw; | ||
| 341 | + } | ||
| 342 | + public void setFzbcw(int fzbcw) { | ||
| 343 | + this.fzbcw = fzbcw; | ||
| 344 | + } | ||
| 345 | + public int getDtbcq() { | ||
| 346 | + return dtbcq; | ||
| 347 | + } | ||
| 348 | + public void setDtbcq(int dtbcq) { | ||
| 349 | + this.dtbcq = dtbcq; | ||
| 350 | + } | ||
| 351 | + public int getDtbcz() { | ||
| 352 | + return dtbcz; | ||
| 353 | + } | ||
| 354 | + public void setDtbcz(int dtbcz) { | ||
| 355 | + this.dtbcz = dtbcz; | ||
| 356 | + } | ||
| 357 | + public int getDtbcw() { | ||
| 358 | + return dtbcw; | ||
| 359 | + } | ||
| 360 | + public void setDtbcw(int dtbcw) { | ||
| 361 | + this.dtbcw = dtbcw; | ||
| 362 | + } | ||
| 363 | + public int getDjgq() { | ||
| 364 | + return djgq; | ||
| 365 | + } | ||
| 366 | + public void setDjgq(int djgq) { | ||
| 367 | + this.djgq = djgq; | ||
| 368 | + } | ||
| 369 | + public int getDjgz() { | ||
| 370 | + return djgz; | ||
| 371 | + } | ||
| 372 | + public void setDjgz(int djgz) { | ||
| 373 | + this.djgz = djgz; | ||
| 374 | + } | ||
| 375 | + public int getDjgw() { | ||
| 376 | + return djgw; | ||
| 377 | + } | ||
| 378 | + public void setDjgw(int djgw) { | ||
| 379 | + this.djgw = djgw; | ||
| 380 | + } | ||
| 381 | + public int getDjgsj() { | ||
| 382 | + return djgsj; | ||
| 383 | + } | ||
| 384 | + public void setDjgsj(int djgsj) { | ||
| 385 | + this.djgsj = djgsj; | ||
| 386 | + } | ||
| 387 | + public String getRemark() { | ||
| 388 | + return remark; | ||
| 389 | + } | ||
| 390 | + public void setRemark(String remark) { | ||
| 391 | + this.remark = remark; | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | +} |
src/main/java/com/bsth/repository/calc/CalcIntervalRepository.java
0 → 100644
| 1 | +package com.bsth.repository.calc; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +import javax.transaction.Transactional; | ||
| 6 | + | ||
| 7 | +import com.bsth.entity.calc.CalcInterval; | ||
| 8 | +import com.bsth.repository.BaseRepository; | ||
| 9 | + | ||
| 10 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 11 | +import org.springframework.data.jpa.repository.Query; | ||
| 12 | +import org.springframework.stereotype.Repository; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * | ||
| 16 | + */ | ||
| 17 | +@Repository | ||
| 18 | +public interface CalcIntervalRepository extends BaseRepository<CalcInterval, Integer>{ | ||
| 19 | + | ||
| 20 | + //按照时间段统计,公司下线路 | ||
| 21 | + @Query(value="select DISTINCT c from CalcInterval c where c.xl like %?1% and c.rqStr between ?2 and ?3 and c.gsdm like %?4% and c.fgsdm like %?5% order by c.xl") | ||
| 22 | + List<CalcInterval> selectByDateAndLine(String line,String date,String date2,String gsdm,String fgsdm); | ||
| 23 | + | ||
| 24 | + //按照时间段统计,单条线路 | ||
| 25 | + @Query(value="select DISTINCT c from CalcInterval c where c.xl = ?1 and c.rqStr between ?2 and ?3 order by c.xl") | ||
| 26 | + List<CalcInterval> selectByDateAndLine(String line,String date,String date2); | ||
| 27 | + | ||
| 28 | + //按照日期和线路删除数据 | ||
| 29 | + @Modifying | ||
| 30 | + @Transactional | ||
| 31 | + @Query(value = "delete CalcInterval c where c.rqStr=?1 and c.xl=?2") | ||
| 32 | + void deleteByDateAndLine(String date, String line); | ||
| 33 | + | ||
| 34 | + //按照日期删除数据 | ||
| 35 | + @Modifying | ||
| 36 | + @Transactional | ||
| 37 | + @Query(value = "delete CalcInterval c where c.rqStr=?1") | ||
| 38 | + void deleteByDate(String date); | ||
| 39 | + | ||
| 40 | +} |
src/main/java/com/bsth/repository/calc/CalcStatisticsRepository.java
0 → 100644
| 1 | +package com.bsth.repository.calc; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +import javax.transaction.Transactional; | ||
| 6 | + | ||
| 7 | +import com.bsth.entity.calc.CalcStatistics; | ||
| 8 | +import com.bsth.entity.calc.CalcWaybill; | ||
| 9 | +import com.bsth.repository.BaseRepository; | ||
| 10 | + | ||
| 11 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 12 | +import org.springframework.data.jpa.repository.Query; | ||
| 13 | +import org.springframework.stereotype.Repository; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * | ||
| 17 | + */ | ||
| 18 | +@Repository | ||
| 19 | +public interface CalcStatisticsRepository extends BaseRepository<CalcStatistics, Integer>{ | ||
| 20 | + | ||
| 21 | + //按照时间段统计,公司下线路 | ||
| 22 | + @Query(value="select DISTINCT c from CalcStatistics c where c.xl like %?1% and c.dateStr between ?2 and ?3 and c.gsdm like %?4% and c.fgsdm like %?5% order by c.xl") | ||
| 23 | + List<CalcStatistics> selectByDateAndLineTj(String line,String date,String date2,String gsdm,String fgsdm); | ||
| 24 | + | ||
| 25 | + //按照时间段统计,单条线路 | ||
| 26 | + @Query(value="select DISTINCT c from CalcStatistics c where c.xl = ?1 and c.dateStr between ?2 and ?3 order by c.xl") | ||
| 27 | + List<CalcStatistics> selectByDateAndLineTj2(String line,String date,String date2); | ||
| 28 | + | ||
| 29 | + //按照日期和线路删除数据 | ||
| 30 | + @Modifying | ||
| 31 | + @Transactional | ||
| 32 | + @Query(value = "delete CalcStatistics c where c.dateStr=?1 and c.xl=?2") | ||
| 33 | + void deleteByDateAndLine(String date, String line); | ||
| 34 | + | ||
| 35 | + //按照日期删除数据 | ||
| 36 | + @Modifying | ||
| 37 | + @Transactional | ||
| 38 | + @Query(value = "delete CalcStatistics c where c.dateStr=?1") | ||
| 39 | + void deleteByDate(String date); | ||
| 40 | + | ||
| 41 | +} |
src/main/java/com/bsth/service/calc/CalcCulateMileageService.java
| 1 | package com.bsth.service.calc; | 1 | package com.bsth.service.calc; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | +import java.util.Map; | ||
| 4 | 5 | ||
| 5 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 6 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 7 | +import com.bsth.entity.sys.Interval; | ||
| 6 | 8 | ||
| 7 | 9 | ||
| 8 | public interface CalcCulateMileageService { | 10 | public interface CalcCulateMileageService { |
| @@ -25,6 +27,7 @@ public interface CalcCulateMileageService { | @@ -25,6 +27,7 @@ public interface CalcCulateMileageService { | ||
| 25 | double culateLbgl(List<ScheduleRealInfo> lists);//烂班公里 | 27 | double culateLbgl(List<ScheduleRealInfo> lists);//烂班公里 |
| 26 | double culateCJLC(List<ScheduleRealInfo> lists,String item);//烂班公里详细 | 28 | double culateCJLC(List<ScheduleRealInfo> lists,String item);//烂班公里详细 |
| 27 | int culateDtfzbc(List<ScheduleRealInfo> lists,String type,String item);//掉头放站班次 | 29 | int culateDtfzbc(List<ScheduleRealInfo> lists,String type,String item);//掉头放站班次 |
| 30 | + Map<String, Object> culateDjg(List<ScheduleRealInfo> lists,String line, List<Map<String, Object>> xlList, List<Interval> djgList);//大间隔 | ||
| 28 | 31 | ||
| 29 | } | 32 | } |
| 30 | 33 |
src/main/java/com/bsth/service/calc/CalcToolService.java
| 1 | package com.bsth.service.calc; | 1 | package com.bsth.service.calc; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | +import java.util.Map; | ||
| 4 | 5 | ||
| 5 | import com.bsth.entity.calc.CalcWaybill; | 6 | import com.bsth.entity.calc.CalcWaybill; |
| 7 | +import com.bsth.entity.sys.Interval; | ||
| 6 | 8 | ||
| 7 | /** | 9 | /** |
| 8 | * Created by 17/11/16. | 10 | * Created by 17/11/16. |
| 9 | */ | 11 | */ |
| 10 | public interface CalcToolService { | 12 | public interface CalcToolService { |
| 11 | 13 | ||
| 12 | - List<CalcWaybill> findAll(String date, String line); | 14 | + List<CalcWaybill> findAll(String date, String line, List<Map<String, Object>> xlList, List<Interval> djgList); |
| 13 | 15 | ||
| 14 | } | 16 | } |
src/main/java/com/bsth/service/calc/CalcWaybillService.java
| @@ -3,6 +3,7 @@ package com.bsth.service.calc; | @@ -3,6 +3,7 @@ package com.bsth.service.calc; | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import java.util.Map; | 4 | import java.util.Map; |
| 5 | 5 | ||
| 6 | +import com.bsth.entity.calc.CalcStatistics; | ||
| 6 | import com.bsth.entity.calc.CalcWaybill; | 7 | import com.bsth.entity.calc.CalcWaybill; |
| 7 | import com.bsth.service.BaseService; | 8 | import com.bsth.service.BaseService; |
| 8 | 9 | ||
| @@ -14,5 +15,12 @@ public interface CalcWaybillService extends BaseService<CalcWaybill, Integer> { | @@ -14,5 +15,12 @@ public interface CalcWaybillService extends BaseService<CalcWaybill, Integer> { | ||
| 14 | Map<String, Object> generateNew(String date, String line) throws Exception; | 15 | Map<String, Object> generateNew(String date, String line) throws Exception; |
| 15 | 16 | ||
| 16 | List<Map<String, Object>> statisticsDailyTj(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type); | 17 | List<Map<String, Object>> statisticsDailyTj(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type); |
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @param rq 格式如:2018-03-22(留空""默认当前日期前一天) | ||
| 21 | + * @param line (留空""默认全部线路) | ||
| 22 | + */ | ||
| 23 | + String calcDaily(String rq, String line) throws Exception; | ||
| 17 | 24 | ||
| 25 | + List<CalcStatistics> calcStatisticsDaily(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type); | ||
| 18 | } | 26 | } |
src/main/java/com/bsth/service/calc/impl/CalcCulateMileageServiceImpl.java
| 1 | package com.bsth.service.calc.impl; | 1 | package com.bsth.service.calc.impl; |
| 2 | 2 | ||
| 3 | +import java.text.DecimalFormat; | ||
| 4 | +import java.text.ParseException; | ||
| 5 | +import java.text.SimpleDateFormat; | ||
| 6 | +import java.util.ArrayList; | ||
| 7 | +import java.util.Collections; | ||
| 8 | +import java.util.Comparator; | ||
| 9 | +import java.util.HashMap; | ||
| 3 | import java.util.Iterator; | 10 | import java.util.Iterator; |
| 4 | import java.util.List; | 11 | import java.util.List; |
| 12 | +import java.util.Map; | ||
| 5 | import java.util.Set; | 13 | import java.util.Set; |
| 6 | 14 | ||
| 7 | import org.apache.commons.lang.StringUtils; | 15 | import org.apache.commons.lang.StringUtils; |
| @@ -11,8 +19,10 @@ import org.springframework.stereotype.Service; | @@ -11,8 +19,10 @@ import org.springframework.stereotype.Service; | ||
| 11 | 19 | ||
| 12 | import com.bsth.entity.realcontrol.ChildTaskPlan; | 20 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 13 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 21 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 22 | +import com.bsth.entity.sys.Interval; | ||
| 14 | import com.bsth.service.calc.CalcCulateMileageService; | 23 | import com.bsth.service.calc.CalcCulateMileageService; |
| 15 | import com.bsth.util.Arith; | 24 | import com.bsth.util.Arith; |
| 25 | +import com.bsth.util.ComparableChild; | ||
| 16 | 26 | ||
| 17 | @Service | 27 | @Service |
| 18 | public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ | 28 | public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ |
| @@ -234,7 +244,7 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ | @@ -234,7 +244,7 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ | ||
| 234 | double sjgl =0; | 244 | double sjgl =0; |
| 235 | for (int i = 0; i < lists.size(); i++) { | 245 | for (int i = 0; i < lists.size(); i++) { |
| 236 | ScheduleRealInfo scheduleRealInfo=lists.get(i); | 246 | ScheduleRealInfo scheduleRealInfo=lists.get(i); |
| 237 | -// if(!scheduleRealInfo.isSflj()){ | 247 | + if(!scheduleRealInfo.isSflj()){ |
| 238 | Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | 248 | Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); |
| 239 | if(childTaskPlans.isEmpty()){ | 249 | if(childTaskPlans.isEmpty()){ |
| 240 | if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | 250 | if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") |
| @@ -264,7 +274,7 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ | @@ -264,7 +274,7 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ | ||
| 264 | } | 274 | } |
| 265 | } | 275 | } |
| 266 | } | 276 | } |
| 267 | -// } | 277 | + } |
| 268 | } | 278 | } |
| 269 | return sjgl; | 279 | return sjgl; |
| 270 | } | 280 | } |
| @@ -670,4 +680,196 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ | @@ -670,4 +680,196 @@ public class CalcCulateMileageServiceImpl implements CalcCulateMileageService{ | ||
| 670 | } | 680 | } |
| 671 | return bc; | 681 | return bc; |
| 672 | } | 682 | } |
| 683 | + | ||
| 684 | + public ScheduleRealInfo checkBc(ScheduleRealInfo s){ | ||
| 685 | + //如果班次有子任务 且 子任务中有属于营运的。把该子任务的发车时间设置成班次的发车时间 | ||
| 686 | + String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual(); | ||
| 687 | + if(fcsj.equals("")){ | ||
| 688 | + Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | ||
| 689 | + if(!childTaskPlans.isEmpty()){ | ||
| 690 | + List<ChildTaskPlan> listit=new ArrayList<ChildTaskPlan>(childTaskPlans); | ||
| 691 | + Collections.sort(listit, new ComparableChild()); | ||
| 692 | + for (int i = 0; i < listit.size(); i++) { | ||
| 693 | + ChildTaskPlan c=listit.get(i); | ||
| 694 | + if(!c.isDestroy()){ | ||
| 695 | + if(c.getMileageType().equals("service")){ | ||
| 696 | + s.setFcsjActual(c.getStartDate()); | ||
| 697 | + break; | ||
| 698 | + } | ||
| 699 | + | ||
| 700 | + } | ||
| 701 | + } | ||
| 702 | + } | ||
| 703 | + } | ||
| 704 | + return s; | ||
| 705 | + } | ||
| 706 | + | ||
| 707 | + public Map<String, Object> listDjg(int peak,int trough,List<ScheduleRealInfo> listInfo,String grade){ | ||
| 708 | + DecimalFormat df = new DecimalFormat("#0.00"); | ||
| 709 | + Collections.sort(listInfo, new ComparableAcuals()); | ||
| 710 | + List<ScheduleRealInfo> listInfo0=new ArrayList<ScheduleRealInfo>(); | ||
| 711 | + List<ScheduleRealInfo> listInfo1=new ArrayList<ScheduleRealInfo>(); | ||
| 712 | + for (int i = 0; i < listInfo.size(); i++) { | ||
| 713 | + ScheduleRealInfo s=listInfo.get(i); | ||
| 714 | + if(s.getXlDir().equals("0")){ | ||
| 715 | + listInfo0.add(s); | ||
| 716 | + }else{ | ||
| 717 | + listInfo0.add(s); | ||
| 718 | + } | ||
| 719 | + } | ||
| 720 | + Map<String, Object> map=new HashMap<String,Object>(); | ||
| 721 | + int djgcsz=0; | ||
| 722 | + int djgcsw=0; | ||
| 723 | + int djgcsq=0; | ||
| 724 | + long djcsj=0l; | ||
| 725 | + for (int i = 0; i < listInfo0.size(); i++) { | ||
| 726 | + ScheduleRealInfo s=listInfo.get(i); | ||
| 727 | + Long fcsjTime=s.getFcsjActualTime(); | ||
| 728 | + String time=s.getFcsjActual(); | ||
| 729 | + String[] fcsjStr = time.split(":"); | ||
| 730 | + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]); | ||
| 731 | + if(i<listInfo.size()-1){ | ||
| 732 | + Long djg=0l; | ||
| 733 | + Long fscjNext=listInfo.get(i+1).getFcsjActualTime(); | ||
| 734 | + if((fcsj>=zgf1&&fcsj<=zgf2)){ | ||
| 735 | + djg = (long) (peak*60*1000); | ||
| 736 | + if(fscjNext-fcsjTime>djg){ | ||
| 737 | + djgcsz ++; | ||
| 738 | + djgcsq ++; | ||
| 739 | + if(fscjNext-fcsjTime>djcsj){ | ||
| 740 | + djcsj=(fscjNext-fcsjTime)/60000; | ||
| 741 | + } | ||
| 742 | + } | ||
| 743 | + }else if((fcsj>=wgf1&&fcsj<=wgf2)){ | ||
| 744 | + djg = (long) (peak*60*1000); | ||
| 745 | + if(fscjNext-fcsjTime>djg){ | ||
| 746 | + djgcsw ++; | ||
| 747 | + djgcsq ++; | ||
| 748 | + if(fscjNext-fcsjTime>djcsj){ | ||
| 749 | + djcsj=(fscjNext-fcsjTime)/60000; | ||
| 750 | + } | ||
| 751 | + } | ||
| 752 | + }else{ | ||
| 753 | + djg = (long) (trough*60*1000); | ||
| 754 | + if(fscjNext-fcsjTime>djg){ | ||
| 755 | + djgcsq ++; | ||
| 756 | + if(fscjNext-fcsjTime>djcsj){ | ||
| 757 | + djcsj=(fscjNext-fcsjTime)/60000; | ||
| 758 | + } | ||
| 759 | + } | ||
| 760 | + } | ||
| 761 | + } | ||
| 762 | + } | ||
| 763 | + for (int i = 0; i < listInfo1.size(); i++) { | ||
| 764 | + ScheduleRealInfo s=listInfo.get(i); | ||
| 765 | + Long fcsjTime=s.getFcsjActualTime(); | ||
| 766 | + String time=s.getFcsjActual(); | ||
| 767 | + String[] fcsjStr = time.split(":"); | ||
| 768 | + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]); | ||
| 769 | + if(i<listInfo.size()-1){ | ||
| 770 | + Long djg=0l; | ||
| 771 | + Long fscjNext=listInfo.get(i+1).getFcsjActualTime(); | ||
| 772 | + if(fcsj>=zgf1&&fcsj<=zgf2){ | ||
| 773 | + djg = (long) (peak*60*1000); | ||
| 774 | + if(fscjNext-fcsjTime>djg){ | ||
| 775 | + djgcsz ++; | ||
| 776 | + djgcsq ++; | ||
| 777 | + if(fscjNext-fcsjTime>djcsj){ | ||
| 778 | + djcsj=(fscjNext-fcsjTime)/60000; | ||
| 779 | + } | ||
| 780 | + } | ||
| 781 | + }else if(fcsj>=wgf1&&fcsj<=wgf2){ | ||
| 782 | + djg = (long) (peak*60*1000); | ||
| 783 | + if(fscjNext-fcsjTime>djg){ | ||
| 784 | + djgcsw ++; | ||
| 785 | + djgcsq ++; | ||
| 786 | + if(fscjNext-fcsjTime>djcsj){ | ||
| 787 | + djcsj=(fscjNext-fcsjTime)/60000; | ||
| 788 | + } | ||
| 789 | + } | ||
| 790 | + }else{ | ||
| 791 | + djg = (long) (trough*60*1000); | ||
| 792 | + if(fscjNext-fcsjTime>djg){ | ||
| 793 | + djgcsq ++; | ||
| 794 | + if(fscjNext-fcsjTime>djcsj){ | ||
| 795 | + djcsj=(fscjNext-fcsjTime)/60000; | ||
| 796 | + } | ||
| 797 | + } | ||
| 798 | + } | ||
| 799 | + } | ||
| 800 | + } | ||
| 801 | + | ||
| 802 | + map.put("djgcsz", djgcsz); | ||
| 803 | + map.put("djgcsw", djgcsw); | ||
| 804 | + map.put("djgcsq", djgcsq); | ||
| 805 | + map.put("djgsj", djcsj); | ||
| 806 | + return map; | ||
| 807 | + } | ||
| 808 | + | ||
| 809 | + @Override | ||
| 810 | + public Map<String, Object> culateDjg(List<ScheduleRealInfo> lists, | ||
| 811 | + String line, List<Map<String, Object>> xlList, List<Interval> djgList) { | ||
| 812 | + // TODO Auto-generated method stub | ||
| 813 | + | ||
| 814 | + | ||
| 815 | + // TODO Auto-generated method stub | ||
| 816 | + List<ScheduleRealInfo> list=lists; | ||
| 817 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 818 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm"); | ||
| 819 | +// Collections.sort(listInfo,new ComparableAcuals()); | ||
| 820 | + | ||
| 821 | + for (int i = 0; i < xlList.size(); i++) { | ||
| 822 | + String lineCode=xlList.get(i).get("line").toString(); | ||
| 823 | + String grade =xlList.get(i).get("grade")==null?"1":xlList.get(i).get("grade").toString(); | ||
| 824 | + int peak=0; | ||
| 825 | + int trough=0; | ||
| 826 | + for (int j = 0; j < djgList.size(); j++) { | ||
| 827 | + Interval il=djgList.get(j); | ||
| 828 | + if(il.getLevel().equals(grade)){ | ||
| 829 | + peak=il.getPeak(); | ||
| 830 | + trough=il.getTrough(); | ||
| 831 | + continue; | ||
| 832 | + } | ||
| 833 | + } | ||
| 834 | + List<ScheduleRealInfo> listInfo=new ArrayList<ScheduleRealInfo>(); | ||
| 835 | + for (int j = 0; j < list.size(); j++) { | ||
| 836 | + ScheduleRealInfo sinfo=list.get(j); | ||
| 837 | + try { | ||
| 838 | + if(sinfo.getXlBm().equals(lineCode)){ | ||
| 839 | + ScheduleRealInfo s=checkBc(sinfo); | ||
| 840 | + String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual(); | ||
| 841 | + if(!fcsj.equals("")){ | ||
| 842 | + Long fcsjAcual = sdf.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime(); | ||
| 843 | + s.setFcsjActualTime(fcsjAcual); | ||
| 844 | + s.setFcsjActual(fcsj); | ||
| 845 | + listInfo.add(s); | ||
| 846 | + } | ||
| 847 | + } | ||
| 848 | + } catch (ParseException e) { | ||
| 849 | + // TODO Auto-generated catch block | ||
| 850 | + e.printStackTrace(); | ||
| 851 | + } | ||
| 852 | + } | ||
| 853 | + | ||
| 854 | + if(listInfo.size()>0){ | ||
| 855 | + m=listDjg(peak,trough,listInfo,grade); | ||
| 856 | + }else{ | ||
| 857 | + m.put("djgcsz", "0"); | ||
| 858 | + m.put("djgcsw", "0"); | ||
| 859 | + m.put("djgcsq", "0"); | ||
| 860 | + m.put("djgsj", "0"); | ||
| 861 | + } | ||
| 862 | + } | ||
| 863 | + return m; | ||
| 864 | + } | ||
| 673 | } | 865 | } |
| 866 | + | ||
| 867 | +class ComparableAcuals implements Comparator<ScheduleRealInfo>{ | ||
| 868 | + | ||
| 869 | + @Override | ||
| 870 | + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | ||
| 871 | + // TODO Auto-generated method stub | ||
| 872 | + return o1.getFcsjActualTime().compareTo(o2.getFcsjActualTime()); | ||
| 873 | + } | ||
| 874 | + | ||
| 875 | +} | ||
| 674 | \ No newline at end of file | 876 | \ No newline at end of file |
src/main/java/com/bsth/service/calc/impl/CalcToolServiceImpl.java
| @@ -9,9 +9,14 @@ import java.util.List; | @@ -9,9 +9,14 @@ import java.util.List; | ||
| 9 | import java.util.Map; | 9 | import java.util.Map; |
| 10 | import java.util.Set; | 10 | import java.util.Set; |
| 11 | 11 | ||
| 12 | +import javax.swing.text.Keymap; | ||
| 13 | + | ||
| 14 | +import com.bsth.entity.calc.CalcInterval; | ||
| 12 | import com.bsth.entity.calc.CalcWaybill; | 15 | import com.bsth.entity.calc.CalcWaybill; |
| 13 | import com.bsth.entity.realcontrol.ChildTaskPlan; | 16 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 14 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 17 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 18 | +import com.bsth.entity.sys.Interval; | ||
| 19 | +import com.bsth.repository.calc.CalcIntervalRepository; | ||
| 15 | import com.bsth.repository.calc.CalcWaybillRepository; | 20 | import com.bsth.repository.calc.CalcWaybillRepository; |
| 16 | import com.bsth.service.calc.CalcToolService; | 21 | import com.bsth.service.calc.CalcToolService; |
| 17 | import com.bsth.service.calc.CalcCulateMileageService; | 22 | import com.bsth.service.calc.CalcCulateMileageService; |
| @@ -35,11 +40,11 @@ public class CalcToolServiceImpl implements CalcToolService { | @@ -35,11 +40,11 @@ public class CalcToolServiceImpl implements CalcToolService { | ||
| 35 | private CalcWaybillRepository clacRepository; | 40 | private CalcWaybillRepository clacRepository; |
| 36 | 41 | ||
| 37 | @Autowired | 42 | @Autowired |
| 38 | - private CalcCulateMileageService culateMileageService; | 43 | + private CalcIntervalRepository culcIntervalRepository; |
| 39 | 44 | ||
| 40 | @Autowired | 45 | @Autowired |
| 41 | - private CulateMileageService culateMileageService2; | ||
| 42 | - | 46 | + private CalcCulateMileageService culateMileageService; |
| 47 | + | ||
| 43 | @Autowired | 48 | @Autowired |
| 44 | JdbcTemplate jdbcTemplate; | 49 | JdbcTemplate jdbcTemplate; |
| 45 | 50 | ||
| @@ -48,7 +53,7 @@ public class CalcToolServiceImpl implements CalcToolService { | @@ -48,7 +53,7 @@ public class CalcToolServiceImpl implements CalcToolService { | ||
| 48 | 53 | ||
| 49 | 54 | ||
| 50 | @Override | 55 | @Override |
| 51 | - public List<CalcWaybill> findAll(String rq, String lineCode) { | 56 | + public List<CalcWaybill> findAll(String rq, String lineCode, List<Map<String, Object>> xlList, List<Interval> djgList) { |
| 52 | List<CalcWaybill> listCal=new ArrayList<CalcWaybill>(); | 57 | List<CalcWaybill> listCal=new ArrayList<CalcWaybill>(); |
| 53 | List<ScheduleRealInfo> list = clacRepository.findAllSchedule(rq,lineCode); | 58 | List<ScheduleRealInfo> list = clacRepository.findAllSchedule(rq,lineCode); |
| 54 | String sql ="select r.j_gh ,r.s_gh,r.cl_zbh,r.xl_bm, r.lp_name FROM" | 59 | String sql ="select r.j_gh ,r.s_gh,r.cl_zbh,r.xl_bm, r.lp_name FROM" |
| @@ -104,9 +109,30 @@ public class CalcToolServiceImpl implements CalcToolService { | @@ -104,9 +109,30 @@ public class CalcToolServiceImpl implements CalcToolService { | ||
| 104 | 109 | ||
| 105 | //计算方法 | 110 | //计算方法 |
| 106 | if(list_.size()>0){ | 111 | if(list_.size()>0){ |
| 107 | - listCal.addAll(this.cul(list_, lists_)); | 112 | + listCal.addAll(this.cul(list_, lists_, xlList, djgList)); |
| 108 | } | 113 | } |
| 109 | } | 114 | } |
| 115 | + | ||
| 116 | + //按线路计算大间隔 | ||
| 117 | + if(list.size() > 0){ | ||
| 118 | + ScheduleRealInfo s = list.get(0); | ||
| 119 | + Map<String, Object> culateDjg = culateMileageService.culateDjg(list, lineCode, xlList, djgList); | ||
| 120 | + CalcInterval interval = new CalcInterval(); | ||
| 121 | + interval.setGsdm(s.getGsBm()); | ||
| 122 | + interval.setGsname(s.getGsName()); | ||
| 123 | + interval.setFgsdm(s.getFgsBm()); | ||
| 124 | + interval.setFgsname(s.getFgsName()); | ||
| 125 | + interval.setRq(s.getScheduleDate()); | ||
| 126 | + interval.setRqStr(s.getScheduleDateStr()); | ||
| 127 | + interval.setXl(s.getXlBm()); | ||
| 128 | + interval.setXlName(s.getXlName()); | ||
| 129 | + interval.setDjg(Integer.valueOf(culateDjg.get("djgcsq").toString())); | ||
| 130 | + interval.setDjgM(Integer.valueOf(culateDjg.get("djgcsz").toString())); | ||
| 131 | + interval.setDjgA(Integer.valueOf(culateDjg.get("djgcsw").toString())); | ||
| 132 | + interval.setDjgTime(Integer.valueOf(culateDjg.get("djgsj").toString())); | ||
| 133 | + culcIntervalRepository.save(interval); | ||
| 134 | + } | ||
| 135 | + | ||
| 110 | while(true){ | 136 | while(true){ |
| 111 | int i = 0, l = 0; | 137 | int i = 0, l = 0; |
| 112 | boolean flag = false; | 138 | boolean flag = false; |
| @@ -145,7 +171,7 @@ public class CalcToolServiceImpl implements CalcToolService { | @@ -145,7 +171,7 @@ public class CalcToolServiceImpl implements CalcToolService { | ||
| 145 | } | 171 | } |
| 146 | 172 | ||
| 147 | //list_ 全部班次 lists_执行了的班次(实到实发不为空) | 173 | //list_ 全部班次 lists_执行了的班次(实到实发不为空) |
| 148 | - private List<CalcWaybill> cul(List<ScheduleRealInfo> list_,List<ScheduleRealInfo> lists_){ | 174 | + private List<CalcWaybill> cul(List<ScheduleRealInfo> list_,List<ScheduleRealInfo> list_s, List<Map<String, Object>> xlList, List<Interval> djgList){ |
| 149 | List<CalcWaybill> list=new ArrayList<CalcWaybill>(); | 175 | List<CalcWaybill> list=new ArrayList<CalcWaybill>(); |
| 150 | if(list_.size()>0){ | 176 | if(list_.size()>0){ |
| 151 | Date date=list_.get(0).getScheduleDate(); | 177 | Date date=list_.get(0).getScheduleDate(); |
| @@ -167,20 +193,20 @@ public class CalcToolServiceImpl implements CalcToolService { | @@ -167,20 +193,20 @@ public class CalcToolServiceImpl implements CalcToolService { | ||
| 167 | int jhyybcWgf=culateMileageService.culateJhyybc(list_, "wgf"); | 193 | int jhyybcWgf=culateMileageService.culateJhyybc(list_, "wgf"); |
| 168 | double jhyylc=culateMileageService.culateJhyylc(list_); | 194 | double jhyylc=culateMileageService.culateJhyylc(list_); |
| 169 | double jhfyylc=culateMileageService.culateJhfyylc(list_); | 195 | double jhfyylc=culateMileageService.culateJhfyylc(list_); |
| 170 | - int sjyybc=culateMileageService.culateSjyybc(lists_, ""); | ||
| 171 | - int sjyybcZgf=culateMileageService.culateSjyybc(lists_, "zgf"); | ||
| 172 | - int sjyybcWgf=culateMileageService.culateSjyybc(lists_, "wgf"); | ||
| 173 | - double sjyylc=culateMileageService.culateSjyylc(lists_);//驾售共有 | ||
| 174 | - double sjyylc_j=culateMileageService.culateSjyylc_j(lists_);//无售 | ||
| 175 | - double sjfyylc=culateMileageService.culateSjfyylc(lists_);//驾售 | ||
| 176 | - double sjfyylc_j=culateMileageService.culateSjfyylc_j(lists_);//无售 | ||
| 177 | - int ljbc=culateMileageService.culateLjbc(lists_, ""); | ||
| 178 | - int ljbcZgf=culateMileageService.culateLjbc(lists_, "zgf"); | ||
| 179 | - int ljbcWgf=culateMileageService.culateLjbc(lists_, "wgf"); | ||
| 180 | - double ljyylc=culateMileageService.culateLjyylc(lists_);//驾售 | ||
| 181 | - double ljyylc_j=culateMileageService.culateLjyylc_j(lists_);//无售 | ||
| 182 | - double ljfyylc=culateMileageService.culateLjfyylc(lists_);//驾售 | ||
| 183 | - double ljfyylc_j=culateMileageService.culateLjfyylc_j(lists_);//无售 | 196 | + int sjyybc=culateMileageService.culateSjyybc(list_s, ""); |
| 197 | + int sjyybcZgf=culateMileageService.culateSjyybc(list_s, "zgf"); | ||
| 198 | + int sjyybcWgf=culateMileageService.culateSjyybc(list_s, "wgf"); | ||
| 199 | + double sjyylc=culateMileageService.culateSjyylc(list_s);//驾售共有 | ||
| 200 | + double sjyylc_j=culateMileageService.culateSjyylc_j(list_s);//无售 | ||
| 201 | + double sjfyylc=culateMileageService.culateSjfyylc(list_s);//驾售 | ||
| 202 | + double sjfyylc_j=culateMileageService.culateSjfyylc_j(list_s);//无售 | ||
| 203 | + int ljbc=culateMileageService.culateLjbc(list_s, ""); | ||
| 204 | + int ljbcZgf=culateMileageService.culateLjbc(list_s, "zgf"); | ||
| 205 | + int ljbcWgf=culateMileageService.culateLjbc(list_s, "wgf"); | ||
| 206 | + double ljyylc=culateMileageService.culateLjyylc(list_s);//驾售 | ||
| 207 | + double ljyylc_j=culateMileageService.culateLjyylc_j(list_s);//无售 | ||
| 208 | + double ljfyylc=culateMileageService.culateLjfyylc(list_s);//驾售 | ||
| 209 | + double ljfyylc_j=culateMileageService.culateLjfyylc_j(list_s);//无售 | ||
| 184 | int lbbc=culateMileageService.culateLbbc(list_); | 210 | int lbbc=culateMileageService.culateLbbc(list_); |
| 185 | double lblc=culateMileageService.culateLbgl(list_); | 211 | double lblc=culateMileageService.culateLbgl(list_); |
| 186 | double ssgl_lz= culateMileageService.culateCJLC(list_, "路阻"); | 212 | double ssgl_lz= culateMileageService.culateCJLC(list_, "路阻"); |
| @@ -199,12 +225,12 @@ public class CalcToolServiceImpl implements CalcToolService { | @@ -199,12 +225,12 @@ public class CalcToolServiceImpl implements CalcToolService { | ||
| 199 | double ssgl_cj=culateMileageService.culateCJLC(list_, "抽减"); | 225 | double ssgl_cj=culateMileageService.culateCJLC(list_, "抽减"); |
| 200 | double ssgl_qt=culateMileageService.culateCJLC(list_, "其他"); | 226 | double ssgl_qt=culateMileageService.culateCJLC(list_, "其他"); |
| 201 | double ssgl_qtz=Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj,ssgl_qt)); | 227 | double ssgl_qtz=Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj,ssgl_qt)); |
| 202 | - int fzbc=culateMileageService.culateDtfzbc(lists_, "major", "");//放站 | ||
| 203 | - int fzbcZgf=culateMileageService.culateDtfzbc(lists_, "major", "zgf"); | ||
| 204 | - int fzbcWgf=culateMileageService.culateDtfzbc(lists_, "major", "wgf"); | ||
| 205 | - int zfbc=culateMileageService.culateDtfzbc(lists_, "venting", "");//直放 | ||
| 206 | - int zfbcZgf=culateMileageService.culateDtfzbc(lists_, "venting", "zgf"); | ||
| 207 | - int zfbcWgf=culateMileageService.culateDtfzbc(lists_, "venting", "wgf"); | 228 | + int fzbc=culateMileageService.culateDtfzbc(list_s, "major", "");//放站 |
| 229 | + int fzbcZgf=culateMileageService.culateDtfzbc(list_s, "major", "zgf"); | ||
| 230 | + int fzbcWgf=culateMileageService.culateDtfzbc(list_s, "major", "wgf"); | ||
| 231 | + int zfbc=culateMileageService.culateDtfzbc(list_s, "venting", "");//直放 | ||
| 232 | + int zfbcZgf=culateMileageService.culateDtfzbc(list_s, "venting", "zgf"); | ||
| 233 | + int zfbcWgf=culateMileageService.culateDtfzbc(list_s, "venting", "wgf"); | ||
| 208 | CalcWaybill t=new CalcWaybill(); | 234 | CalcWaybill t=new CalcWaybill(); |
| 209 | t.setRq(date); | 235 | t.setRq(date); |
| 210 | t.setRqStr(dateStr); | 236 | t.setRqStr(dateStr); |
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
| @@ -2,9 +2,15 @@ package com.bsth.service.calc.impl; | @@ -2,9 +2,15 @@ package com.bsth.service.calc.impl; | ||
| 2 | 2 | ||
| 3 | import java.sql.ResultSet; | 3 | import java.sql.ResultSet; |
| 4 | import java.sql.SQLException; | 4 | import java.sql.SQLException; |
| 5 | +import java.text.SimpleDateFormat; | ||
| 5 | import java.util.ArrayList; | 6 | import java.util.ArrayList; |
| 7 | +import java.util.Calendar; | ||
| 8 | +import java.util.Collections; | ||
| 9 | +import java.util.Comparator; | ||
| 10 | +import java.util.Date; | ||
| 6 | import java.util.HashMap; | 11 | import java.util.HashMap; |
| 7 | import java.util.HashSet; | 12 | import java.util.HashSet; |
| 13 | +import java.util.Iterator; | ||
| 8 | import java.util.List; | 14 | import java.util.List; |
| 9 | import java.util.Map; | 15 | import java.util.Map; |
| 10 | import java.util.Set; | 16 | import java.util.Set; |
| @@ -12,13 +18,25 @@ import java.util.Set; | @@ -12,13 +18,25 @@ import java.util.Set; | ||
| 12 | import javax.transaction.Transactional; | 18 | import javax.transaction.Transactional; |
| 13 | 19 | ||
| 14 | import com.bsth.common.ResponseCode; | 20 | import com.bsth.common.ResponseCode; |
| 21 | +import com.bsth.entity.calc.CalcInterval; | ||
| 22 | +import com.bsth.entity.calc.CalcStatistics; | ||
| 15 | import com.bsth.entity.calc.CalcWaybill; | 23 | import com.bsth.entity.calc.CalcWaybill; |
| 24 | +import com.bsth.entity.realcontrol.ChildTaskPlan; | ||
| 25 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 26 | +import com.bsth.entity.sys.Interval; | ||
| 27 | +import com.bsth.repository.calc.CalcIntervalRepository; | ||
| 28 | +import com.bsth.repository.calc.CalcStatisticsRepository; | ||
| 16 | import com.bsth.repository.calc.CalcWaybillRepository; | 29 | import com.bsth.repository.calc.CalcWaybillRepository; |
| 30 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 17 | import com.bsth.service.calc.CalcToolService; | 31 | import com.bsth.service.calc.CalcToolService; |
| 18 | import com.bsth.service.calc.CalcWaybillService; | 32 | import com.bsth.service.calc.CalcWaybillService; |
| 19 | import com.bsth.service.impl.BaseServiceImpl; | 33 | import com.bsth.service.impl.BaseServiceImpl; |
| 34 | +import com.bsth.service.report.CulateMileageService; | ||
| 20 | import com.bsth.util.Arith; | 35 | import com.bsth.util.Arith; |
| 21 | -import com.bsth.util.BatchSaveUtils; | 36 | +import com.bsth.util.ReportUtils; |
| 37 | +import com.github.stuxuhai.jpinyin.PinyinException; | ||
| 38 | +import com.github.stuxuhai.jpinyin.PinyinFormat; | ||
| 39 | +import com.github.stuxuhai.jpinyin.PinyinHelper; | ||
| 22 | 40 | ||
| 23 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
| 24 | import org.slf4j.LoggerFactory; | 42 | import org.slf4j.LoggerFactory; |
| @@ -34,12 +52,24 @@ import org.springframework.stereotype.Service; | @@ -34,12 +52,24 @@ import org.springframework.stereotype.Service; | ||
| 34 | public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer> implements CalcWaybillService { | 52 | public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer> implements CalcWaybillService { |
| 35 | 53 | ||
| 36 | @Autowired | 54 | @Autowired |
| 37 | - private CalcWaybillRepository clacRepository; | 55 | + private CalcWaybillRepository calcRepository; |
| 38 | 56 | ||
| 39 | @Autowired | 57 | @Autowired |
| 40 | - private CalcToolService calcToolService; | 58 | + private CalcIntervalRepository calcIntervalRepository; |
| 41 | 59 | ||
| 42 | @Autowired | 60 | @Autowired |
| 61 | + private CalcStatisticsRepository calcStatisticsRepository; | ||
| 62 | + | ||
| 63 | + @Autowired | ||
| 64 | + private CalcToolService calcToolService; | ||
| 65 | + | ||
| 66 | + @Autowired | ||
| 67 | + private CulateMileageService culateService; | ||
| 68 | + | ||
| 69 | + @Autowired | ||
| 70 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 71 | + | ||
| 72 | + @Autowired | ||
| 43 | JdbcTemplate jdbcTemplate; | 73 | JdbcTemplate jdbcTemplate; |
| 44 | 74 | ||
| 45 | 75 | ||
| @@ -54,9 +84,11 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -54,9 +84,11 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 54 | try { | 84 | try { |
| 55 | 85 | ||
| 56 | if(date.length() != 0 && line.length() != 0){ | 86 | if(date.length() != 0 && line.length() != 0){ |
| 57 | - clacRepository.deleteByDateAndLine(date, line); | 87 | + calcRepository.deleteByDateAndLine(date, line); |
| 88 | + calcIntervalRepository.deleteByDateAndLine(date, line); | ||
| 58 | } else if(date.length() != 0){ | 89 | } else if(date.length() != 0){ |
| 59 | - clacRepository.deleteByDate(date); | 90 | + calcRepository.deleteByDate(date); |
| 91 | + calcIntervalRepository.deleteByDate(date); | ||
| 60 | } else { | 92 | } else { |
| 61 | newMap.put("status", ResponseCode.ERROR); | 93 | newMap.put("status", ResponseCode.ERROR); |
| 62 | logger.error("save erro.", "日期不能为空"); | 94 | logger.error("save erro.", "日期不能为空"); |
| @@ -84,21 +116,60 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -84,21 +116,60 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 84 | m.put("start_opt", rs.getString("start_opt")); | 116 | m.put("start_opt", rs.getString("start_opt")); |
| 85 | m.put("line_code", rs.getString("line_code")); | 117 | m.put("line_code", rs.getString("line_code")); |
| 86 | return m; | 118 | return m; |
| 87 | - }}); | ||
| 88 | - | 119 | + }}); |
| 120 | + | ||
| 121 | + String xlSql="select line_code,spac_grade from bsth_c_line"; | ||
| 122 | + if(line.length() != 0){ | ||
| 123 | + xlSql += " where line_code ='"+line+"'"; | ||
| 124 | + } | ||
| 125 | + List<Map<String, Object>> xlList=jdbcTemplate.query(xlSql, new RowMapper<Map<String, Object>>() { | ||
| 126 | + @Override | ||
| 127 | + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 128 | + Map<String, Object> map=new HashMap<String,Object>(); | ||
| 129 | + map.put("line",arg0.getString("line_code")); | ||
| 130 | + map.put("grade", arg0.getString("spac_grade")); | ||
| 131 | + return map; | ||
| 132 | + }}); | ||
| 133 | + Map<String, List<Map<String, Object>>> xlMap = new HashMap<String, List<Map<String, Object>>>(); | ||
| 134 | + for(Map<String, Object> m : xlList){ | ||
| 135 | + if(m.containsKey("line") && m.get("line").toString().trim().length() > 0){ | ||
| 136 | + String key = m.get("line").toString(); | ||
| 137 | + if(!xlMap.containsKey(key)) | ||
| 138 | + xlMap.put(key, new ArrayList<Map<String, Object>>()); | ||
| 139 | + xlMap.get(key).add(m); | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + //查询大间隔时间 | ||
| 143 | + String djgSql="select * from bsth_c_interval"; | ||
| 144 | + List<Interval> djgList=jdbcTemplate.query(djgSql, new RowMapper<Interval>() { | ||
| 145 | + @Override | ||
| 146 | + public Interval mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 147 | + Interval m=new Interval(); | ||
| 148 | + m.setLevel(arg0.getString("level")); | ||
| 149 | + m.setPeak(arg0.getInt("peak")); | ||
| 150 | + m.setTrough(arg0.getInt("trough")); | ||
| 151 | + return m; | ||
| 152 | + }}); | ||
| 153 | + | ||
| 89 | Set<String> lineSet = new HashSet<String>(); | 154 | Set<String> lineSet = new HashSet<String>(); |
| 90 | for (int i = 0; i < listLineConfig.size(); i++) { | 155 | for (int i = 0; i < listLineConfig.size(); i++) { |
| 91 | Map<String, Object> m =listLineConfig.get(i); | 156 | Map<String, Object> m =listLineConfig.get(i); |
| 92 | String lineCode=m.get("line_code").toString().trim(); | 157 | String lineCode=m.get("line_code").toString().trim(); |
| 93 | - String startOpt=m.get("start_opt").toString().trim(); | 158 | +// String startOpt=m.get("start_opt").toString().trim(); |
| 94 | if(!lineSet.add(lineCode)) | 159 | if(!lineSet.add(lineCode)) |
| 95 | continue; | 160 | continue; |
| 96 | 161 | ||
| 97 | - List<CalcWaybill> findAll = calcToolService.findAll(date, lineCode); | 162 | + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); |
| 163 | + if(xlMap.containsKey(lineCode) && xlMap.get(lineCode) != null){ | ||
| 164 | + tempList = xlMap.get(lineCode); | ||
| 165 | + } | ||
| 98 | 166 | ||
| 99 | -// new BatchSaveUtils<CalcWaybill>().saveList2(findAll, CalcWaybill.class); | 167 | + List<CalcWaybill> findAll = calcToolService.findAll(date, lineCode, tempList, djgList); |
| 100 | 168 | ||
| 101 | - clacRepository.save(findAll); | 169 | +// new BatchSaveUtils<CalcWaybill>().saveList2(findAll, CalcWaybill.class); |
| 170 | + | ||
| 171 | +// if(xlMap.get(lineCode).size() == 0) | ||
| 172 | + calcRepository.save(findAll); | ||
| 102 | } | 173 | } |
| 103 | 174 | ||
| 104 | newMap.put("status", ResponseCode.SUCCESS); | 175 | newMap.put("status", ResponseCode.SUCCESS); |
| @@ -116,28 +187,41 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -116,28 +187,41 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 116 | public List<Map<String, Object>> statisticsDailyTj(String gsdm, | 187 | public List<Map<String, Object>> statisticsDailyTj(String gsdm, |
| 117 | String fgsdm, String line, String date, String date2, | 188 | String fgsdm, String line, String date, String date2, |
| 118 | String xlName, String type) { | 189 | String xlName, String type) { |
| 119 | - | 190 | + |
| 191 | + List<String> keyList = new ArrayList<String>(); | ||
| 120 | List<CalcWaybill> list = new ArrayList<CalcWaybill>(); | 192 | List<CalcWaybill> list = new ArrayList<CalcWaybill>(); |
| 121 | List<CalcWaybill> lists = new ArrayList<CalcWaybill>(); | 193 | List<CalcWaybill> lists = new ArrayList<CalcWaybill>(); |
| 194 | + List<CalcInterval> list_ = new ArrayList<CalcInterval>(); | ||
| 122 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | 195 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 123 | Map<String, List<CalcWaybill>> keyMap = new HashMap<String, List<CalcWaybill>>(); | 196 | Map<String, List<CalcWaybill>> keyMap = new HashMap<String, List<CalcWaybill>>(); |
| 197 | + Map<String, List<CalcInterval>> keyMap_ = new HashMap<String, List<CalcInterval>>(); | ||
| 124 | 198 | ||
| 125 | if(line.equals("")){ | 199 | if(line.equals("")){ |
| 126 | //查询所有线路 | 200 | //查询所有线路 |
| 127 | - list = clacRepository.scheduleByDateAndLineTj(line,date,date2,gsdm,fgsdm); | 201 | + list = calcRepository.scheduleByDateAndLineTj(line,date,date2,gsdm,fgsdm); |
| 202 | + list_ = calcIntervalRepository.selectByDateAndLine(line, date, date2, gsdm, fgsdm); | ||
| 128 | }else{ | 203 | }else{ |
| 129 | //查询单条线路 | 204 | //查询单条线路 |
| 130 | - list = clacRepository.scheduleByDateAndLineTj2(line,date,date2); | 205 | + list = calcRepository.scheduleByDateAndLineTj2(line,date,date2); |
| 206 | + list_ = calcIntervalRepository.selectByDateAndLine(line, date, date2); | ||
| 131 | } | 207 | } |
| 132 | 208 | ||
| 133 | for(CalcWaybill c : list){ | 209 | for(CalcWaybill c : list){ |
| 134 | String key = c.getXlName(); | 210 | String key = c.getXlName(); |
| 135 | if(!keyMap.containsKey(key)){ | 211 | if(!keyMap.containsKey(key)){ |
| 136 | keyMap.put(key, new ArrayList<CalcWaybill>()); | 212 | keyMap.put(key, new ArrayList<CalcWaybill>()); |
| 213 | + keyList.add(key); | ||
| 137 | } | 214 | } |
| 138 | keyMap.get(key).add(c); | 215 | keyMap.get(key).add(c); |
| 139 | } | 216 | } |
| 140 | - for(String key : keyMap.keySet()){ | 217 | + for(CalcInterval c : list_){ |
| 218 | + String key = c.getXlName(); | ||
| 219 | + if(!keyMap_.containsKey(key)) | ||
| 220 | + keyMap_.put(key, new ArrayList<CalcInterval>()); | ||
| 221 | + keyMap_.get(key).add(c); | ||
| 222 | + } | ||
| 223 | + Collections.sort(keyList, new AccountXlbmStr()); | ||
| 224 | + for(String key : keyList){ | ||
| 141 | CalcWaybill calc = keyMap.get(key).get(0); | 225 | CalcWaybill calc = keyMap.get(key).get(0); |
| 142 | for(int i = 1; i < keyMap.get(key).size(); i++){ | 226 | for(int i = 1; i < keyMap.get(key).size(); i++){ |
| 143 | CalcWaybill c= keyMap.get(key).get(i); | 227 | CalcWaybill c= keyMap.get(key).get(i); |
| @@ -171,15 +255,32 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -171,15 +255,32 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 171 | calc.setFzbc(calc.getFzbc() + c.getFzbc()); | 255 | calc.setFzbc(calc.getFzbc() + c.getFzbc()); |
| 172 | calc.setFzbczgf(calc.getFzbczgf() + c.getFzbczgf()); | 256 | calc.setFzbczgf(calc.getFzbczgf() + c.getFzbczgf()); |
| 173 | calc.setFzbcwgf(calc.getFzbcwgf() + c.getFzbcwgf()); | 257 | calc.setFzbcwgf(calc.getFzbcwgf() + c.getFzbcwgf()); |
| 174 | - calc.setDtbc(calc.getDtbc() + c.getFzbc()); | 258 | + calc.setDtbc(calc.getDtbc() + c.getDtbc()); |
| 175 | calc.setDtbczgf(calc.getDtbczgf() + c.getDtbczgf()); | 259 | calc.setDtbczgf(calc.getDtbczgf() + c.getDtbczgf()); |
| 176 | calc.setDtbcwgf(calc.getDtbcwgf() + c.getDtbcwgf()); | 260 | calc.setDtbcwgf(calc.getDtbcwgf() + c.getDtbcwgf()); |
| 177 | - | ||
| 178 | } | 261 | } |
| 179 | calc.setSjyylc(Arith.add(calc.getSjyylc(), calc.getLjyylc())); | 262 | calc.setSjyylc(Arith.add(calc.getSjyylc(), calc.getLjyylc())); |
| 180 | - System.out.println(); | ||
| 181 | lists.add(calc); | 263 | lists.add(calc); |
| 182 | } | 264 | } |
| 265 | + CalcInterval sum_ = new CalcInterval(); | ||
| 266 | + sum_.setXlName("合计"); | ||
| 267 | + sum_.setDjgTime(0); | ||
| 268 | + for(String key : keyMap_.keySet()){ | ||
| 269 | + CalcInterval calc = keyMap_.get(key).get(0); | ||
| 270 | + for(int i = 1; i < keyMap_.get(key).size(); i++){ | ||
| 271 | + CalcInterval calc_ = keyMap_.get(key).get(i); | ||
| 272 | + calc.setDjg(calc.getDjg() + calc_.getDjg()); | ||
| 273 | + calc.setDjgM(calc.getDjgM() + calc_.getDjgM()); | ||
| 274 | + calc.setDjgA(calc.getDjgA() + calc_.getDjgA()); | ||
| 275 | + if(calc_.getDjgTime() > calc.getDjgTime()) | ||
| 276 | + calc.setDjgTime(calc_.getDjgTime()); | ||
| 277 | + } | ||
| 278 | + sum_.setDjg(sum_.getDjg() + calc.getDjg()); | ||
| 279 | + sum_.setDjgM(sum_.getDjgM() + calc.getDjgM()); | ||
| 280 | + sum_.setDjgA(sum_.getDjgA() + calc.getDjgA()); | ||
| 281 | + if(calc.getDjgTime() > sum_.getDjgTime()) | ||
| 282 | + sum_.setDjgTime(calc.getDjgTime()); | ||
| 283 | + } | ||
| 183 | 284 | ||
| 184 | CalcWaybill sum = new CalcWaybill(); | 285 | CalcWaybill sum = new CalcWaybill(); |
| 185 | sum.setXlName("合计"); | 286 | sum.setXlName("合计"); |
| @@ -187,7 +288,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -187,7 +288,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 187 | sum.setJhyylc(Arith.add(sum.getJhyylc()!=null?sum.getJhyylc():0, c.getJhyylc())); | 288 | sum.setJhyylc(Arith.add(sum.getJhyylc()!=null?sum.getJhyylc():0, c.getJhyylc())); |
| 188 | sum.setJhfyylc(Arith.add(sum.getJhfyylc()!=null?sum.getJhfyylc():0, c.getJhfyylc())); | 289 | sum.setJhfyylc(Arith.add(sum.getJhfyylc()!=null?sum.getJhfyylc():0, c.getJhfyylc())); |
| 189 | sum.setSjyylc(Arith.add(sum.getSjyylc()!=null?sum.getSjyylc():0, c.getSjyylc())); | 290 | sum.setSjyylc(Arith.add(sum.getSjyylc()!=null?sum.getSjyylc():0, c.getSjyylc())); |
| 291 | + sum.setLjyylc(Arith.add(sum.getLjyylc()!=null?sum.getLjyylc():0, c.getLjyylc())); | ||
| 190 | sum.setSjfyylc(Arith.add(sum.getSjfyylc()!=null?sum.getSjfyylc():0, c.getSjfyylc())); | 292 | sum.setSjfyylc(Arith.add(sum.getSjfyylc()!=null?sum.getSjfyylc():0, c.getSjfyylc())); |
| 293 | + sum.setLjfyylc(Arith.add(sum.getLjfyylc()!=null?sum.getLjfyylc():0, c.getLjfyylc())); | ||
| 191 | sum.setLblc(Arith.add(sum.getLblc()!=null?sum.getLblc():0, c.getLblc())); | 294 | sum.setLblc(Arith.add(sum.getLblc()!=null?sum.getLblc():0, c.getLblc())); |
| 192 | sum.setLbbc(sum.getLbbc() + c.getLbbc()); | 295 | sum.setLbbc(sum.getLbbc() + c.getLbbc()); |
| 193 | sum.setLblcLz(Arith.add(sum.getLblcLz()!=null?sum.getLblcLz():0, c.getLblcLz())); | 296 | sum.setLblcLz(Arith.add(sum.getLblcLz()!=null?sum.getLblcLz():0, c.getLblcLz())); |
| @@ -214,7 +317,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -214,7 +317,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 214 | sum.setFzbc(sum.getFzbc() + c.getFzbc()); | 317 | sum.setFzbc(sum.getFzbc() + c.getFzbc()); |
| 215 | sum.setFzbczgf(sum.getFzbczgf() + c.getFzbczgf()); | 318 | sum.setFzbczgf(sum.getFzbczgf() + c.getFzbczgf()); |
| 216 | sum.setFzbcwgf(sum.getFzbcwgf() + c.getFzbcwgf()); | 319 | sum.setFzbcwgf(sum.getFzbcwgf() + c.getFzbcwgf()); |
| 217 | - sum.setDtbc(sum.getDtbc() + c.getFzbc()); | 320 | + sum.setDtbc(sum.getDtbc() + c.getDtbc()); |
| 218 | sum.setDtbczgf(sum.getDtbczgf() + c.getDtbczgf()); | 321 | sum.setDtbczgf(sum.getDtbczgf() + c.getDtbczgf()); |
| 219 | sum.setDtbcwgf(sum.getDtbcwgf() + c.getDtbcwgf()); | 322 | sum.setDtbcwgf(sum.getDtbcwgf() + c.getDtbcwgf()); |
| 220 | } | 323 | } |
| @@ -228,9 +331,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -228,9 +331,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 228 | m.put("jhzlc", Arith.add(c.getJhyylc(), c.getJhfyylc())); | 331 | m.put("jhzlc", Arith.add(c.getJhyylc(), c.getJhfyylc())); |
| 229 | m.put("jhlc", c.getJhyylc()); | 332 | m.put("jhlc", c.getJhyylc()); |
| 230 | m.put("jcclc", c.getJhfyylc()); | 333 | m.put("jcclc", c.getJhfyylc()); |
| 231 | - m.put("sjzgl", Arith.add(c.getSjyylc(), c.getSjfyylc())); | ||
| 232 | - m.put("sjgl", c.getSjyylc()); | ||
| 233 | - m.put("sjksgl", c.getSjfyylc()); | 334 | + m.put("sjzgl", Arith.add(Arith.add(c.getSjyylc(), c.getLjyylc()), Arith.add(c.getSjfyylc(), c.getLjfyylc()))); |
| 335 | + m.put("sjgl", Arith.add(c.getSjyylc(), c.getLjyylc())); | ||
| 336 | + m.put("sjksgl", Arith.add(c.getSjfyylc(), c.getLjfyylc())); | ||
| 234 | m.put("ssgl", c.getLblc()); | 337 | m.put("ssgl", c.getLblc()); |
| 235 | m.put("ssbc", c.getLbbc()); | 338 | m.put("ssbc", c.getLbbc()); |
| 236 | m.put("ssgl_lz", c.getLblcLz()); | 339 | m.put("ssgl_lz", c.getLblcLz()); |
| @@ -260,14 +363,350 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | @@ -260,14 +363,350 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer | ||
| 260 | m.put("dtbc", c.getDtbc()); | 363 | m.put("dtbc", c.getDtbc()); |
| 261 | m.put("dtbc_m", c.getDtbczgf()); | 364 | m.put("dtbc_m", c.getDtbczgf()); |
| 262 | m.put("dtbc_a", c.getDtbcwgf()); | 365 | m.put("dtbc_a", c.getDtbcwgf()); |
| 263 | - m.put("djg", 0); | ||
| 264 | - m.put("djg_m", 0); | ||
| 265 | - m.put("djg_a", 0); | ||
| 266 | - m.put("djg_time", 0); | 366 | + if(keyMap_.containsKey(c.getXlName()) || c.getXlName().equals("合计")){ |
| 367 | + CalcInterval calc; | ||
| 368 | + if(c.getXlName().equals("合计")) | ||
| 369 | + calc = sum_; | ||
| 370 | + else | ||
| 371 | + calc = keyMap_.get(c.getXlName()).get(0); | ||
| 372 | + m.put("djg", calc.getDjg()); | ||
| 373 | + m.put("djg_m", calc.getDjgM()); | ||
| 374 | + m.put("djg_a", calc.getDjgA()); | ||
| 375 | + m.put("djg_time", calc.getDjgTime()); | ||
| 376 | + } else { | ||
| 377 | + m.put("djg", 0); | ||
| 378 | + m.put("djg_m", 0); | ||
| 379 | + m.put("djg_a", 0); | ||
| 380 | + m.put("djg_time", 0); | ||
| 381 | + } | ||
| 267 | resList.add(m); | 382 | resList.add(m); |
| 268 | } | 383 | } |
| 269 | 384 | ||
| 270 | return resList; | 385 | return resList; |
| 271 | } | 386 | } |
| 272 | 387 | ||
| 388 | + /** | ||
| 389 | + * @param rq 格式如:2018-03-22(留空""默认当前日期前一天) | ||
| 390 | + * @param line (留空""默认全部线路) | ||
| 391 | + */ | ||
| 392 | + @Transactional | ||
| 393 | + @Override | ||
| 394 | + public String calcDaily(String rq, String line) throws Exception{ | ||
| 395 | + String result = ""; | ||
| 396 | + try { | ||
| 397 | + if(rq == null || rq.trim().length() == 0){ | ||
| 398 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); | ||
| 399 | + Date dNow = new Date(); //当前时间 | ||
| 400 | + Date dBefore = new Date(); | ||
| 401 | + Calendar calendar = Calendar.getInstance(); //得到日历 | ||
| 402 | + calendar.setTime(dNow);//把当前时间赋给日历 | ||
| 403 | + calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天 | ||
| 404 | + dBefore = calendar.getTime(); //得到前一天的时间 | ||
| 405 | + rq = sdf.format(dBefore); | ||
| 406 | + } else { | ||
| 407 | + rq = rq.trim(); | ||
| 408 | + } | ||
| 409 | + if(line == null || line.trim().length() == 0){ | ||
| 410 | + line = ""; | ||
| 411 | + } else { | ||
| 412 | + line = line.trim(); | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | ||
| 416 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | ||
| 417 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | ||
| 418 | + | ||
| 419 | + String xlSql="select gs_bm, fgs_bm from bsth_c_s_sp_info_real where schedule_date_str = '"+rq+"'"; | ||
| 420 | + if(line.trim().length() > 0) | ||
| 421 | + xlSql += " and xl_bm = '"+line+"'"; | ||
| 422 | + xlSql += " group by gs_bm, fgs_bm"; | ||
| 423 | + List<Map<String, String>> gsList=jdbcTemplate.query(xlSql, new RowMapper<Map<String, String>>() { | ||
| 424 | + @Override | ||
| 425 | + public Map<String, String> mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 426 | + Map<String, String> m = new HashMap<String, String>(); | ||
| 427 | + m.put("gsdm", arg0.getString("gs_bm")); | ||
| 428 | + m.put("fgsdm", arg0.getString("fgs_bm")); | ||
| 429 | + return m; | ||
| 430 | + }}); | ||
| 431 | + | ||
| 432 | + //查询所有线路 | ||
| 433 | + for(Map<String, String> m : gsList){ | ||
| 434 | + list.addAll(scheduleRealInfoRepository.scheduleByDateAndLineTj(line, rq, rq, m.get("gsdm"), m.get("fgsdm"))); | ||
| 435 | + } | ||
| 436 | + | ||
| 437 | + for (int i = 0; i < list.size(); i++) { | ||
| 438 | + ScheduleRealInfo s=list.get(i); | ||
| 439 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 440 | + if(cts != null && cts.size() > 0){ | ||
| 441 | + list_s.add(s); | ||
| 442 | + }else{ | ||
| 443 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 444 | + list_s.add(s); | ||
| 445 | + } | ||
| 446 | + } | ||
| 447 | + } | ||
| 448 | + List<CalcStatistics> lMap = new ArrayList<CalcStatistics>(); | ||
| 449 | + for (int i = 0; i < list.size(); i++) { | ||
| 450 | + if(i<list.size()-1){ | ||
| 451 | + if(list.get(i+1).getXlBm().equals(list.get(i).getXlBm())){ | ||
| 452 | + lists.add(list.get(i)); | ||
| 453 | + }else{ | ||
| 454 | + lists.add(list.get(i)); | ||
| 455 | + CalcStatistics s=staticTj(lists); | ||
| 456 | + lMap.add(s); | ||
| 457 | + lists=new ArrayList<ScheduleRealInfo>(); | ||
| 458 | + } | ||
| 459 | + }else{ | ||
| 460 | + if(list.get(i).getXlBm().equals(list.get(i-1).getXlBm())){ | ||
| 461 | + lists.add(list.get(i)); | ||
| 462 | + CalcStatistics s=staticTj(lists); | ||
| 463 | + lMap.add(s); | ||
| 464 | + }else{ | ||
| 465 | + lists=new ArrayList<ScheduleRealInfo>(); | ||
| 466 | + lists.add(list.get(i)); | ||
| 467 | + CalcStatistics s=staticTj(lists); | ||
| 468 | + lMap.add(s); | ||
| 469 | + } | ||
| 470 | + } | ||
| 471 | + } | ||
| 472 | +// Collections.sort(lMap,new AccountXlbm()); | ||
| 473 | + | ||
| 474 | + if(line.trim().length() > 0){ | ||
| 475 | + calcStatisticsRepository.deleteByDateAndLine(rq, line); | ||
| 476 | + } else { | ||
| 477 | + calcStatisticsRepository.deleteByDate(rq); | ||
| 478 | + } | ||
| 479 | + calcStatisticsRepository.save(lMap); | ||
| 480 | + result = "success"; | ||
| 481 | + } catch (Exception e) { | ||
| 482 | + // TODO: handle exception | ||
| 483 | + throw e; | ||
| 484 | + }finally{ | ||
| 485 | + logger.info("result:"+result); | ||
| 486 | + } | ||
| 487 | + return result; | ||
| 488 | + } | ||
| 489 | + | ||
| 490 | + public final CalcStatistics staticTj(List<ScheduleRealInfo> list){ | ||
| 491 | + | ||
| 492 | + List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>(); | ||
| 493 | + for(int i=0;i<list.size();i++){ | ||
| 494 | + ScheduleRealInfo s=list.get(i); | ||
| 495 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 496 | + if(cts != null && cts.size() > 0){ | ||
| 497 | + lists.add(s); | ||
| 498 | + }else{ | ||
| 499 | + if(s.getZdsjActual()!=null&& s.getFcsjActual()!=null){ | ||
| 500 | + lists.add(s); | ||
| 501 | + } | ||
| 502 | + } | ||
| 503 | + } | ||
| 504 | +// Map<String, Object> map = new HashMap<String, Object>(); | ||
| 505 | + CalcStatistics s = new CalcStatistics(); | ||
| 506 | + if(list.size() > 0){ | ||
| 507 | + ScheduleRealInfo sche = list.get(0); | ||
| 508 | + s.setXl(sche.getXlBm()); | ||
| 509 | + s.setXlName(sche.getXlName()); | ||
| 510 | + s.setDate(sche.getScheduleDate()); | ||
| 511 | + s.setDateStr(sche.getScheduleDateStr()); | ||
| 512 | + s.setGsdm(sche.getGsBm()); | ||
| 513 | + s.setFgsdm(sche.getFgsBm()); | ||
| 514 | + | ||
| 515 | + double jhyygl=culateService.culateJhgl(list);//计划营运公里 | ||
| 516 | + double jhjcclc= culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | ||
| 517 | + s.setJhyylc(jhyygl); | ||
| 518 | + s.setJhkslc(jhjcclc); | ||
| 519 | + s.setJhzlc(Arith.add(jhyygl, jhjcclc)); | ||
| 520 | + | ||
| 521 | + double ljgl= culateService.culateLjgl(lists); | ||
| 522 | + double sjyygl= culateService.culateSjgl(lists); | ||
| 523 | + double zyygl= Arith.add(sjyygl,ljgl); | ||
| 524 | + | ||
| 525 | + double sjjccgl=culateService.culateJccgl(lists); | ||
| 526 | + double sjksgl=culateService.culateKsgl(lists); | ||
| 527 | + double zksgl=Arith.add(sjjccgl, sjksgl); | ||
| 528 | + s.setSjyylc(zyygl); | ||
| 529 | + s.setSjkslc(zksgl); | ||
| 530 | + s.setSjzlc(Arith.add(zyygl, zksgl)); | ||
| 531 | + | ||
| 532 | + s.setSslc(culateService.culateLbgl(list)); | ||
| 533 | + s.setSsbc(culateService.culateLbbc(list)); | ||
| 534 | + | ||
| 535 | + //计划+临加-少驶=实驶 | ||
| 536 | +// double jl=Arith.sub(Arith.add(jhyygl, ljgl),ssgl); | ||
| 537 | +// if(jl==zyygl){ | ||
| 538 | +// map.put("zt", 0); | ||
| 539 | +// }else{ | ||
| 540 | +// map.put("zt", 1); | ||
| 541 | +// } | ||
| 542 | + | ||
| 543 | + s.setLzlc(culateService.culateCJLC(list, "路阻")); | ||
| 544 | + s.setDmlc(culateService.culateCJLC(list, "吊慢")); | ||
| 545 | + s.setGzlc(culateService.culateCJLC(list, "故障")); | ||
| 546 | + s.setJflc(culateService.culateCJLC(list, "纠纷")); | ||
| 547 | + s.setZslc(culateService.culateCJLC(list, "肇事")); | ||
| 548 | + s.setQrlc(culateService.culateCJLC(list, "缺人")); | ||
| 549 | + s.setQclc(culateService.culateCJLC(list, "缺车")); | ||
| 550 | + s.setKxlc(culateService.culateCJLC(list, "客稀")); | ||
| 551 | + s.setQhlc(culateService.culateCJLC(list, "气候")); | ||
| 552 | + s.setYwlc(culateService.culateCJLC(list, "援外")); | ||
| 553 | + double ssgl_pc=culateService.culateCJLC(list, "配车"); | ||
| 554 | + double ssgl_by=culateService.culateCJLC(list, "保养"); | ||
| 555 | + double ssgl_cj=culateService.culateCJLC(list, "抽减"); | ||
| 556 | + double ssgl_qt=culateService.culateCJLC(list, "其他"); | ||
| 557 | + s.setQtlc(Arith.add(Arith.add(ssgl_pc, ssgl_by),Arith.add(ssgl_cj, ssgl_qt))); | ||
| 558 | + s.setLjlc(ljgl); | ||
| 559 | + | ||
| 560 | + s.setJhbcq(culateService.culateJhbc(list,"")); | ||
| 561 | + s.setJhbcz(culateService.culateJhbc(list, "zgf")); | ||
| 562 | + s.setJhbcw(culateService.culateJhbc(list, "wgf")); | ||
| 563 | + s.setSjbcq(culateService.culateSjbc(lists,"")); | ||
| 564 | + s.setSjbcz(culateService.culateSjbc(lists,"zgf")); | ||
| 565 | + s.setSjbcw(culateService.culateSjbc(lists,"wgf")); | ||
| 566 | + s.setLjbcq(culateService.culateLjbc(lists,"")); | ||
| 567 | + s.setLjbcz(culateService.culateLjbc(lists,"zgf")); | ||
| 568 | + s.setLjbcw(culateService.culateLjbc(lists,"wgf")); | ||
| 569 | + s.setFzbcq(culateService.culateFzbc(lists, "")); | ||
| 570 | + s.setFzbcz(culateService.culateFzbc(lists, "zgf")); | ||
| 571 | + s.setFzbcw(culateService.culateFzbc(lists, "wgf")); | ||
| 572 | + s.setDtbcq(0); | ||
| 573 | + s.setDtbcz(0); | ||
| 574 | + s.setDtbcw(0); | ||
| 575 | + Map<String, Object> m_=culateService.culateDjg(lists, list.get(0).getXlBm()); | ||
| 576 | + if(m_.containsKey("djgcsq") && m_.get("djgcsq")!=null) | ||
| 577 | + s.setDjgq(Integer.valueOf(m_.get("djgcsq").toString())); | ||
| 578 | + else | ||
| 579 | + s.setDjgq(0); | ||
| 580 | + if(m_.containsKey("djgcsz") && m_.get("djgcsz")!=null) | ||
| 581 | + s.setDjgz(Integer.valueOf(m_.get("djgcsz").toString())); | ||
| 582 | + else | ||
| 583 | + s.setDjgz(0); | ||
| 584 | + if(m_.containsKey("djgcsw") && m_.get("djgcsw")!=null) | ||
| 585 | + s.setDjgw(Integer.valueOf(m_.get("djgcsw").toString())); | ||
| 586 | + else | ||
| 587 | + s.setDjgw(0); | ||
| 588 | + if(m_.containsKey("djgsj") && m_.get("djgsj")!=null) | ||
| 589 | + s.setDjgsj(Integer.valueOf(m_.get("djgsj").toString())); | ||
| 590 | + else | ||
| 591 | + s.setDjgsj(0); | ||
| 592 | + } | ||
| 593 | + return s; | ||
| 594 | + } | ||
| 595 | + | ||
| 596 | + class AccountXlbm implements Comparator<Map<String, Object>>{ | ||
| 597 | + @Override | ||
| 598 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 599 | + // TODO Auto-generated method stub | ||
| 600 | +// PinyinHelper.convertToPinyinString(ppy.getName(), | ||
| 601 | +// "" , PinyinFormat.WITHOUT_TONE) | ||
| 602 | + return o1.get("xlNamePy").toString().compareTo( | ||
| 603 | + o2.get("xlNamePy").toString()); | ||
| 604 | + } | ||
| 605 | + } | ||
| 606 | + | ||
| 607 | + class AccountXlbmStr implements Comparator<String>{ | ||
| 608 | + @Override | ||
| 609 | + public int compare(String o1, String o2) { | ||
| 610 | + // TODO Auto-generated method stub | ||
| 611 | + return o1.compareTo(o2); | ||
| 612 | + } | ||
| 613 | + } | ||
| 614 | + | ||
| 615 | + @Override | ||
| 616 | + public List<CalcStatistics> calcStatisticsDaily(String gsdm, String fgsdm, | ||
| 617 | + String line, String date, String date2, String xlName, String type) { | ||
| 618 | + // TODO Auto-generated method stub | ||
| 619 | + List<CalcStatistics> list = new ArrayList<CalcStatistics>(); | ||
| 620 | + if(line.length() > 0){ | ||
| 621 | + list = calcStatisticsRepository.selectByDateAndLineTj2(line, date, date2); | ||
| 622 | + } else { | ||
| 623 | + list = calcStatisticsRepository.selectByDateAndLineTj(line, date, date2, gsdm, fgsdm); | ||
| 624 | + } | ||
| 625 | + | ||
| 626 | + List<CalcStatistics> resList = new ArrayList<CalcStatistics>(); | ||
| 627 | + Map<String, List<CalcStatistics>> keyMap = new HashMap<String, List<CalcStatistics>>(); | ||
| 628 | + List<String> keyList = new ArrayList<String>(); | ||
| 629 | + | ||
| 630 | + for(CalcStatistics s : list){ | ||
| 631 | + try { | ||
| 632 | + String key = PinyinHelper.convertToPinyinString(s.getXlName(), "" , PinyinFormat.WITHOUT_TONE); | ||
| 633 | + if(!keyMap.containsKey(key)){ | ||
| 634 | + keyMap.put(key, new ArrayList<CalcStatistics>()); | ||
| 635 | + keyList.add(key); | ||
| 636 | + } | ||
| 637 | + keyMap.get(key).add(s); | ||
| 638 | + } catch (PinyinException e) { | ||
| 639 | + // TODO Auto-generated catch block | ||
| 640 | + e.printStackTrace(); | ||
| 641 | + } | ||
| 642 | + } | ||
| 643 | + Collections.sort(keyList, new AccountXlbmStr()); | ||
| 644 | + | ||
| 645 | + for(String key : keyList){ | ||
| 646 | + if(keyMap.get(key).size() > 0){ | ||
| 647 | + CalcStatistics s = keyMap.get(key).get(0); | ||
| 648 | + if(keyMap.get(key).size() > 1) | ||
| 649 | + for(int i = 1; i < keyMap.get(key).size(); i++){ | ||
| 650 | + CalcStatistics s_ = keyMap.get(key).get(i); | ||
| 651 | + s = addStatistics(s, s_); | ||
| 652 | + } | ||
| 653 | + resList.add(s); | ||
| 654 | + } | ||
| 655 | + } | ||
| 656 | + | ||
| 657 | + if(resList.size() > 0){ | ||
| 658 | + CalcStatistics temp = new CalcStatistics(); | ||
| 659 | + temp.setXlName("合计"); | ||
| 660 | + for(CalcStatistics s : resList){ | ||
| 661 | + temp = addStatistics(temp, s); | ||
| 662 | + } | ||
| 663 | + resList.add(temp); | ||
| 664 | + } | ||
| 665 | + | ||
| 666 | + return resList; | ||
| 667 | + } | ||
| 668 | + | ||
| 669 | + public CalcStatistics addStatistics(CalcStatistics s, CalcStatistics s_){ | ||
| 670 | + s.setJhzlc(Arith.add(s.getJhzlc()!=null?s.getJhzlc():0, s_.getJhzlc())); | ||
| 671 | + s.setJhyylc(Arith.add(s.getJhyylc()!=null?s.getJhyylc():0, s_.getJhyylc())); | ||
| 672 | + s.setJhkslc(Arith.add(s.getJhkslc()!=null?s.getJhkslc():0, s_.getJhkslc())); | ||
| 673 | + s.setSjzlc(Arith.add(s.getSjzlc()!=null?s.getSjzlc():0, s_.getSjzlc())); | ||
| 674 | + s.setSjyylc(Arith.add(s.getSjyylc()!=null?s.getSjyylc():0, s_.getSjyylc())); | ||
| 675 | + s.setSjkslc(Arith.add(s.getSjkslc()!=null?s.getSjkslc():0, s_.getSjkslc())); | ||
| 676 | + s.setSslc(Arith.add(s.getSslc()!=null?s.getSslc():0, s_.getSslc())); | ||
| 677 | + s.setSsbc(s.getSsbc() + s_.getSsbc()); | ||
| 678 | + s.setLzlc(Arith.add(s.getLzlc()!=null?s.getLzlc():0, s_.getLzlc())); | ||
| 679 | + s.setDmlc(Arith.add(s.getDmlc()!=null?s.getDmlc():0, s_.getDmlc())); | ||
| 680 | + s.setGzlc(Arith.add(s.getGzlc()!=null?s.getGzlc():0, s_.getGzlc())); | ||
| 681 | + s.setJflc(Arith.add(s.getJflc()!=null?s.getJflc():0, s_.getJflc())); | ||
| 682 | + s.setZslc(Arith.add(s.getZslc()!=null?s.getZslc():0, s_.getZslc())); | ||
| 683 | + s.setQrlc(Arith.add(s.getQrlc()!=null?s.getQrlc():0, s_.getQrlc())); | ||
| 684 | + s.setQclc(Arith.add(s.getQclc()!=null?s.getQclc():0, s_.getQclc())); | ||
| 685 | + s.setKxlc(Arith.add(s.getKxlc()!=null?s.getKxlc():0, s_.getKxlc())); | ||
| 686 | + s.setQhlc(Arith.add(s.getQhlc()!=null?s.getQhlc():0, s_.getQhlc())); | ||
| 687 | + s.setYwlc(Arith.add(s.getYwlc()!=null?s.getYwlc():0, s_.getYwlc())); | ||
| 688 | + s.setQtlc(Arith.add(s.getQtlc()!=null?s.getQtlc():0, s_.getQtlc())); | ||
| 689 | + s.setLjlc(Arith.add(s.getLjlc()!=null?s.getLjlc():0, s_.getLjlc())); | ||
| 690 | + s.setJhbcq(s.getJhbcq() + s_.getJhbcq()); | ||
| 691 | + s.setJhbcz(s.getJhbcz() + s_.getJhbcz()); | ||
| 692 | + s.setJhbcw(s.getJhbcw() + s_.getJhbcw()); | ||
| 693 | + s.setSjbcq(s.getSjbcq() + s_.getSjbcq()); | ||
| 694 | + s.setSjbcz(s.getSjbcz() + s_.getSjbcz()); | ||
| 695 | + s.setSjbcw(s.getSjbcw() + s_.getSjbcw()); | ||
| 696 | + s.setLjbcq(s.getLjbcq() + s_.getLjbcq()); | ||
| 697 | + s.setLjbcz(s.getLjbcz() + s_.getLjbcz()); | ||
| 698 | + s.setLjbcw(s.getLjbcw() + s_.getLjbcw()); | ||
| 699 | + s.setFzbcq(s.getFzbcq() + s_.getFzbcq()); | ||
| 700 | + s.setFzbcz(s.getFzbcz() + s_.getFzbcz()); | ||
| 701 | + s.setFzbcw(s.getFzbcw() + s_.getFzbcw()); | ||
| 702 | + s.setDtbcq(s.getDtbcq() + s_.getDtbcq()); | ||
| 703 | + s.setDtbcz(s.getDtbcz() + s_.getDtbcz()); | ||
| 704 | + s.setDtbcw(s.getDtbcw() + s_.getDtbcw()); | ||
| 705 | + s.setDjgq(s.getDjgq() + s_.getDjgq()); | ||
| 706 | + s.setDjgz(s.getDjgz() + s_.getDjgz()); | ||
| 707 | + s.setDjgw(s.getDjgw() + s_.getDjgw()); | ||
| 708 | + s.setDjgsj(s.getDjgsj()>s_.getDjgsj()?s.getDjgsj():s_.getDjgsj()); | ||
| 709 | + return s; | ||
| 710 | + } | ||
| 711 | + | ||
| 273 | } | 712 | } |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| @@ -1005,8 +1005,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1005,8 +1005,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1005 | /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */ | 1005 | /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */ |
| 1006 | List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions); | 1006 | List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions); |
| 1007 | if(sobje.size()==1) { | 1007 | if(sobje.size()==1) { |
| 1008 | - int dsleepStr = sobje.get(0)[2] == null || sobje.get(0)[2].equals("") ? 60 : Integer.valueOf(sobje.get(0)[2].toString()); | ||
| 1009 | - sleepStr = "\t" + String.valueOf(dsleepStr); | 1008 | +// int dsleepStr = sobje.get(0)[2] == null || sobje.get(0)[2].equals("") ? 60 : Integer.valueOf(sobje.get(0)[2].toString()); |
| 1009 | +// sleepStr = "\t" + String.valueOf(dsleepStr); | ||
| 1010 | + double dsleepStrt = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(0)[2].toString()); | ||
| 1011 | + sleepStr = "\t" + new DecimalFormat("0").format(dsleepStrt); | ||
| 1010 | }else if(sobje.size()>1){ | 1012 | }else if(sobje.size()>1){ |
| 1011 | for(int j =0;j<sobje.size();j++) { | 1013 | for(int j =0;j<sobje.size();j++) { |
| 1012 | double dsleepStrt = sobje.get(j)[2] == null || sobje.get(j)[2].equals("") ? 60d : Double.valueOf(sobje.get(j)[2].toString()); | 1014 | double dsleepStrt = sobje.get(j)[2] == null || sobje.get(j)[2].equals("") ? 60d : Double.valueOf(sobje.get(j)[2].toString()); |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| @@ -324,37 +324,24 @@ public class ReportServiceImpl implements ReportService{ | @@ -324,37 +324,24 @@ public class ReportServiceImpl implements ReportService{ | ||
| 324 | } | 324 | } |
| 325 | return list; | 325 | return list; |
| 326 | } | 326 | } |
| 327 | + | ||
| 327 | @Override | 328 | @Override |
| 328 | public Map<String, Object> tbodyTime1(String line, String ttinfo) { | 329 | public Map<String, Object> tbodyTime1(String line, String ttinfo) { |
| 329 | DecimalFormat df = new DecimalFormat("#0.00"); | 330 | DecimalFormat df = new DecimalFormat("#0.00"); |
| 331 | + Map<String, Object> map=new HashMap<String,Object>(); | ||
| 330 | // TODO Auto-generated method stub | 332 | // TODO Auto-generated method stub |
| 333 | + | ||
| 331 | //查询配车 | 334 | //查询配车 |
| 332 | - String sqlPc=" select count(*) from bsth_c_cars where id in(" | ||
| 333 | - + " select cl from bsth_c_s_ccinfo where xl in ( " | ||
| 334 | - + " select id from bsth_c_line where line_code='"+line+"' )" | ||
| 335 | - + " group by equipment_code ) "; | ||
| 336 | - | ||
| 337 | - Map<String, Object> map=new HashMap<String,Object>(); | ||
| 338 | - | ||
| 339 | - /*List<Map<String, Object>> listPc= jdbcTemplate.query(sqlPc, | ||
| 340 | - new RowMapper<Map<String, Object>>(){ | ||
| 341 | - @Override | ||
| 342 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 343 | - Map<String, Object> m=new HashMap<String,Object>(); | ||
| 344 | - m.put("zbh", rs.getString("cl_zbh")); | ||
| 345 | - return m; | ||
| 346 | - } | ||
| 347 | - });*/ | 335 | + String sqlPc=" select count(*) from (select lp, count(*) from" |
| 336 | + + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"'" | ||
| 337 | + + " group by lp ) a"; | ||
| 348 | //配车 | 338 | //配车 |
| 349 | int pcs=jdbcTemplate.queryForObject(sqlPc, Integer.class); | 339 | int pcs=jdbcTemplate.queryForObject(sqlPc, Integer.class); |
| 350 | 340 | ||
| 341 | + | ||
| 351 | String sqlPlan=" SELECT jhlc,bc_type,fcsj FROM bsth_c_s_ttinfo_detail " | 342 | String sqlPlan=" SELECT jhlc,bc_type,fcsj FROM bsth_c_s_ttinfo_detail " |
| 352 | +" where ttinfo ='"+ttinfo+"' "; | 343 | +" where ttinfo ='"+ttinfo+"' "; |
| 353 | 344 | ||
| 354 | - //班次 | ||
| 355 | - int zgf_0 = 6*60+31,zgf_1 = 8*60+30,wgf_0 = 16*60+1,wgf_1 = 18*60; | ||
| 356 | - int qcBc=0,qjBc=0,zqcBc=0,zqjBc=0,wqcBc=0,wqjBc=0; | ||
| 357 | - double zlc = 0 , yylc = 0,kslc=0; | ||
| 358 | //查询班次 | 345 | //查询班次 |
| 359 | List<Map<String, Object>> listPlan= jdbcTemplate.query(sqlPlan, | 346 | List<Map<String, Object>> listPlan= jdbcTemplate.query(sqlPlan, |
| 360 | new RowMapper<Map<String, Object>>(){ | 347 | new RowMapper<Map<String, Object>>(){ |
| @@ -368,6 +355,11 @@ public class ReportServiceImpl implements ReportService{ | @@ -368,6 +355,11 @@ public class ReportServiceImpl implements ReportService{ | ||
| 368 | } | 355 | } |
| 369 | }); | 356 | }); |
| 370 | 357 | ||
| 358 | + //班次 | ||
| 359 | + int zgf_0 = 6*60+31,zgf_1 = 8*60+30,wgf_0 = 16*60+1,wgf_1 = 18*60; | ||
| 360 | + int qcBc=0,qjBc=0,zqcBc=0,zqjBc=0,wqcBc=0,wqjBc=0; | ||
| 361 | + double zlc = 0 , yylc = 0,kslc=0; | ||
| 362 | + | ||
| 371 | for (int i = 0; i < listPlan.size(); i++) { | 363 | for (int i = 0; i < listPlan.size(); i++) { |
| 372 | Map<String, Object> m=listPlan.get(i); | 364 | Map<String, Object> m=listPlan.get(i); |
| 373 | double jhlc=Double.parseDouble(m.get("jhlc").toString()); | 365 | double jhlc=Double.parseDouble(m.get("jhlc").toString()); |
| @@ -423,21 +415,23 @@ public class ReportServiceImpl implements ReportService{ | @@ -423,21 +415,23 @@ public class ReportServiceImpl implements ReportService{ | ||
| 423 | String minfcsj="02:00"; | 415 | String minfcsj="02:00"; |
| 424 | List<Line> lineList=lineRepository.findLineByCode(line); | 416 | List<Line> lineList=lineRepository.findLineByCode(line); |
| 425 | if(lineList.size()>0){ | 417 | if(lineList.size()>0){ |
| 426 | - String sqlMinYysj="select start_opt from bsth_c_line_config where " | ||
| 427 | - + " id = (" | ||
| 428 | - + "select max(id) from bsth_c_line_config where line ='"+lineList.get(0).getId() +"'" | ||
| 429 | - + ")"; | ||
| 430 | - minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class); | 418 | + String sql = "select count(*) from bsth_c_line_config where line = '"+lineList.get(0).getId()+"'"; |
| 419 | + if(jdbcTemplate.queryForObject(sql, Integer.class) > 0){ | ||
| 420 | + String sqlMinYysj="select start_opt from bsth_c_line_config where " | ||
| 421 | + + " id = (" | ||
| 422 | + + "select max(id) from bsth_c_line_config where line ='"+lineList.get(0).getId() +"'" | ||
| 423 | + + ")"; | ||
| 424 | + minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 425 | + } | ||
| 431 | } | 426 | } |
| 432 | String[] minSjs = minfcsj.split(":"); | 427 | String[] minSjs = minfcsj.split(":"); |
| 433 | int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]); | 428 | int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]); |
| 434 | //查询时间里程 | 429 | //查询时间里程 |
| 435 | - String sqlPc=" (SELECT jhlc,fcsj,bc_type,lp,2 as xh, ists FROM bsth_c_s_ttinfo_detail " | 430 | + String sqlPc=" (SELECT jhlc,fcsj,bc_type,bcsj,lp,2 as xh, ists FROM bsth_c_s_ttinfo_detail " |
| 436 | + " where ttinfo ='"+ttinfo+"' and fcsj <='"+minfcsj+"' ) " | 431 | + " where ttinfo ='"+ttinfo+"' and fcsj <='"+minfcsj+"' ) " |
| 437 | + " union " | 432 | + " union " |
| 438 | - + " (SELECT jhlc,fcsj,bc_type,lp,1 as xh, ists FROM bsth_c_s_ttinfo_detail " | ||
| 439 | - + " where ttinfo ='"+ttinfo+"' and fcsj > '"+minfcsj+"') order by lp,xh,fcsj"; | ||
| 440 | - | 433 | + + " (SELECT jhlc,fcsj,bc_type,bcsj,lp,1 as xh, ists FROM bsth_c_s_ttinfo_detail " |
| 434 | + + " where ttinfo ='"+ttinfo+"' and fcsj > '"+minfcsj+"' ) order by lp,xh,fcsj"; | ||
| 441 | Map<String, Object> map=new HashMap<String,Object>(); | 435 | Map<String, Object> map=new HashMap<String,Object>(); |
| 442 | List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, | 436 | List<Map<String, Object>> list= jdbcTemplate.query(sqlPc, |
| 443 | new RowMapper<Map<String, Object>>(){ | 437 | new RowMapper<Map<String, Object>>(){ |
| @@ -447,26 +441,31 @@ public class ReportServiceImpl implements ReportService{ | @@ -447,26 +441,31 @@ public class ReportServiceImpl implements ReportService{ | ||
| 447 | m.put("fcsj", rs.getString("fcsj")); | 441 | m.put("fcsj", rs.getString("fcsj")); |
| 448 | m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc")); | 442 | m.put("yygl", rs.getString("jhlc")==null?"0":rs.getString("jhlc")); |
| 449 | m.put("bcType", rs.getString("bc_type")); | 443 | m.put("bcType", rs.getString("bc_type")); |
| 444 | + m.put("bcsj", rs.getString("bcsj")); | ||
| 450 | m.put("lp", rs.getString("lp")); | 445 | m.put("lp", rs.getString("lp")); |
| 451 | m.put("ists", rs.getObject("ists")==null?"0":rs.getString("ists")); | 446 | m.put("ists", rs.getObject("ists")==null?"0":rs.getString("ists")); |
| 452 | return m; | 447 | return m; |
| 453 | } | 448 | } |
| 454 | }); | 449 | }); |
| 455 | - int yysj=0 ; | 450 | + |
| 451 | + int yysj=0; | ||
| 456 | double yycs=0 ,yygl=0; | 452 | double yycs=0 ,yygl=0; |
| 457 | String lp ="0"; | 453 | String lp ="0"; |
| 458 | - int sj=0; | ||
| 459 | - | 454 | + int sj=0, bcsj = 0; |
| 455 | + int temp = 0; | ||
| 460 | for(int i=0;i<list.size();i++){ | 456 | for(int i=0;i<list.size();i++){ |
| 461 | Map<String, Object> m=list.get(i); | 457 | Map<String, Object> m=list.get(i); |
| 462 | String time=m.get("fcsj").toString(); | 458 | String time=m.get("fcsj").toString(); |
| 463 | String[] times = time.split(":"); | 459 | String[] times = time.split(":"); |
| 460 | + int sjT = Integer.parseInt(times[0])*60+Integer.parseInt(times[1]); | ||
| 464 | if(lp.equals(m.get("lp").toString())){ | 461 | if(lp.equals(m.get("lp").toString())){ |
| 465 | - if(Integer.parseInt(times[0])*60+Integer.parseInt(times[1]) <=minSj){ | 462 | + if(sjT <= minSj){ |
| 466 | if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){ | 463 | if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){ |
| 467 | if(m.get("bcType").equals("in")){ | 464 | if(m.get("bcType").equals("in")){ |
| 468 | if(sj!=0){ | 465 | if(sj!=0){ |
| 469 | - yysj +=(Integer.parseInt(times[0])+24)*60+Integer.parseInt(times[1])-sj; | 466 | +// yysj += sjT + (24*60) - sj; |
| 467 | + yysj += bcsj; | ||
| 468 | + bcsj = 0; | ||
| 470 | } | 469 | } |
| 471 | sj=0; | 470 | sj=0; |
| 472 | } | 471 | } |
| @@ -474,45 +473,62 @@ public class ReportServiceImpl implements ReportService{ | @@ -474,45 +473,62 @@ public class ReportServiceImpl implements ReportService{ | ||
| 474 | yygl += Double.parseDouble(m.get("yygl").toString()); | 473 | yygl += Double.parseDouble(m.get("yygl").toString()); |
| 475 | 474 | ||
| 476 | if(sj==0){ | 475 | if(sj==0){ |
| 477 | - sj=(Integer.parseInt(times[0])+24)*60+Integer.parseInt(times[1]); | 476 | + sj = sjT + (24*60); |
| 478 | }else{ | 477 | }else{ |
| 479 | - yysj +=(Integer.parseInt(times[0])+24)*60+Integer.parseInt(times[1])-sj; | ||
| 480 | - sj=(Integer.parseInt(times[0])+24)*60+Integer.parseInt(times[1]); | 478 | + yysj += sjT + (24*60) - sj; |
| 479 | + if(m.containsKey("ists") && m.get("ists").equals("1")){ | ||
| 480 | + yysj += Integer.valueOf(m.get("bcsj").toString()); | ||
| 481 | + } else { | ||
| 482 | + sj = sjT + (24*60); | ||
| 483 | + } | ||
| 481 | } | 484 | } |
| 482 | } | 485 | } |
| 483 | }else{ | 486 | }else{ |
| 484 | if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){ | 487 | if(m.get("bcType").equals("in") || m.get("bcType").equals("out")){ |
| 485 | if(m.get("bcType").equals("in")){ | 488 | if(m.get("bcType").equals("in")){ |
| 486 | if(sj!=0){ | 489 | if(sj!=0){ |
| 487 | - yysj +=Integer.parseInt(times[0])*60+Integer.parseInt(times[1])-sj; | 490 | +// yysj += sjT - sj; |
| 491 | + yysj += bcsj; | ||
| 492 | + bcsj = 0; | ||
| 488 | } | 493 | } |
| 489 | sj=0; | 494 | sj=0; |
| 490 | } | 495 | } |
| 491 | - }else{ | 496 | + } else { |
| 492 | yygl += Double.parseDouble(m.get("yygl").toString()); | 497 | yygl += Double.parseDouble(m.get("yygl").toString()); |
| 493 | 498 | ||
| 494 | if(sj==0){ | 499 | if(sj==0){ |
| 495 | - sj=Integer.parseInt(times[0])*60+Integer.parseInt(times[1]); | 500 | + sj = sjT; |
| 496 | }else{ | 501 | }else{ |
| 497 | - yysj +=Integer.parseInt(times[0])*60+Integer.parseInt(times[1])-sj; | ||
| 498 | - sj=Integer.parseInt(times[0])*60+Integer.parseInt(times[1]); | 502 | + yysj += sjT - sj; |
| 503 | + if(m.containsKey("ists") && m.get("ists").equals("1")){ | ||
| 504 | + yysj += Integer.valueOf(m.get("bcsj").toString()); | ||
| 505 | + } else { | ||
| 506 | + sj = sjT; | ||
| 507 | + } | ||
| 499 | } | 508 | } |
| 500 | } | 509 | } |
| 501 | } | 510 | } |
| 502 | }else{ | 511 | }else{ |
| 512 | + if(sj == 0){ | ||
| 513 | + yysj += bcsj; | ||
| 514 | + bcsj = 0; | ||
| 515 | + } | ||
| 503 | if( !(m.get("bcType").equals("in") || m.get("bcType").equals("out"))){ | 516 | if( !(m.get("bcType").equals("in") || m.get("bcType").equals("out"))){ |
| 504 | yygl += Double.parseDouble(m.get("yygl").toString()); | 517 | yygl += Double.parseDouble(m.get("yygl").toString()); |
| 505 | - sj =Integer.parseInt(times[0])*60+Integer.parseInt(times[1]); | 518 | + sj = sjT; |
| 506 | }else{ | 519 | }else{ |
| 507 | sj=0; | 520 | sj=0; |
| 508 | } | 521 | } |
| 509 | lp=m.get("lp").toString(); | 522 | lp=m.get("lp").toString(); |
| 510 | - | ||
| 511 | } | 523 | } |
| 524 | + | ||
| 512 | if(m.containsKey("ists") && m.get("ists").equals("1")){ | 525 | if(m.containsKey("ists") && m.get("ists").equals("1")){ |
| 513 | sj = 0; | 526 | sj = 0; |
| 514 | } | 527 | } |
| 528 | + if( !(m.get("bcType").equals("in") || m.get("bcType").equals("out"))) | ||
| 529 | + bcsj = Integer.valueOf(m.get("bcsj").toString()); | ||
| 515 | } | 530 | } |
| 531 | + | ||
| 516 | if(yysj>0){ | 532 | if(yysj>0){ |
| 517 | yycs =yygl/(yysj*1.0/60); | 533 | yycs =yygl/(yysj*1.0/60); |
| 518 | } | 534 | } |
| @@ -522,6 +538,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -522,6 +538,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 522 | map.put("yysj", hh+":"+mm); | 538 | map.put("yysj", hh+":"+mm); |
| 523 | map.put("yycs", df.format(yycs)+"公里/小时"); | 539 | map.put("yycs", df.format(yycs)+"公里/小时"); |
| 524 | // map.put(key, value) | 540 | // map.put(key, value) |
| 541 | + | ||
| 525 | return map; | 542 | return map; |
| 526 | } | 543 | } |
| 527 | 544 | ||
| @@ -529,126 +546,15 @@ public class ReportServiceImpl implements ReportService{ | @@ -529,126 +546,15 @@ public class ReportServiceImpl implements ReportService{ | ||
| 529 | System.out.println(609360/60); | 546 | System.out.println(609360/60); |
| 530 | System.out.println(609360%60); | 547 | System.out.println(609360%60); |
| 531 | } | 548 | } |
| 532 | - /* @Override | ||
| 533 | - public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) { | ||
| 534 | - // TODO Auto-generated method stub | ||
| 535 | - List<Map<String, Object>> list=new ArrayList<Map<String,Object>>(); | ||
| 536 | - | ||
| 537 | - | ||
| 538 | - | ||
| 539 | - String sqlZd="select a.qdz_name,COUNT(a.cl_zbh) as cls,'zqc' AS lx from (" | ||
| 540 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"' " | ||
| 541 | - + " and bc_type ='normal'" | ||
| 542 | - + " and ((fcsj >'06:31' and fcsj<'08:30') or ( fcsj>'6:31' and fcsj<'8:30'))" | ||
| 543 | - + " group by cl_zbh,qdz_name) a group by a.qdz_name" | ||
| 544 | - + " union " | ||
| 545 | - + " select a.qdz_name,COUNT(a.cl_zbh) as cls,'wqc' AS lx from (" | ||
| 546 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"'" | ||
| 547 | - + " and bc_type ='normal' " | ||
| 548 | - + " and fcsj >'16:01' and fcsj<'18:00' group by cl_zbh,qdz_name " | ||
| 549 | - + " ) a group by a.qdz_name " | ||
| 550 | - + " union " | ||
| 551 | - + " select a.qdz_name,COUNT(a.cl_zbh) as cls,'zqj' AS lx from (" | ||
| 552 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"'" | ||
| 553 | - + " and bc_type ='region' " | ||
| 554 | - + " and ((fcsj >'06:31' and fcsj<'08:30') or ( fcsj>'6:31' and fcsj<'8:30'))" | ||
| 555 | - + " group by cl_zbh,qdz_name) a group by a.qdz_name" | ||
| 556 | - + " union " | ||
| 557 | - + " select a.qdz_name,COUNT(a.cl_zbh) as cls,'wqj' AS lx from (" | ||
| 558 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"'" | ||
| 559 | - + " and bc_type ='region' and fcsj >'16:01' and fcsj<'18:00'" | ||
| 560 | - + " group by cl_zbh,qdz_name) a group by a.qdz_name"; | ||
| 561 | - List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, | ||
| 562 | - new RowMapper<Map<String, Object>>(){ | ||
| 563 | - @Override | ||
| 564 | - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 565 | - Map<String, Object> m=new HashMap<String,Object>(); | ||
| 566 | - m.put("zdm", rs.getString("qdz_name")); | ||
| 567 | - m.put("cls", rs.getString("cls")); | ||
| 568 | - m.put("lx", rs.getString("lx")); | ||
| 569 | - return m; | ||
| 570 | - } | ||
| 571 | - }); | ||
| 572 | - int a=0; | ||
| 573 | - int b=0; | ||
| 574 | - int c=0; | ||
| 575 | - int d=0; | ||
| 576 | - for(int i=0;i<lists.size();i++){ | ||
| 577 | - boolean fage=true; | ||
| 578 | - Map<String, Object> newMap= new HashMap<String, Object>(); | ||
| 579 | - list.add(newMap); | ||
| 580 | - Map<String, Object> maps=lists.get(i); | ||
| 581 | - if(maps.get("lx").equals("zqc")){ | ||
| 582 | - list.get(a).put("zqcZm", maps.get("zdm")); | ||
| 583 | - list.get(a).put("zqcCls", maps.get("cls")); | ||
| 584 | - a++; | ||
| 585 | - fage=false; | ||
| 586 | - }else if(maps.get("lx").equals("wqc")){ | ||
| 587 | - list.get(b).put("wqcZm", maps.get("zdm")); | ||
| 588 | - list.get(b).put("wqcCls", maps.get("cls")); | ||
| 589 | - b++; | ||
| 590 | - fage=false; | ||
| 591 | - }else if(maps.get("lx").equals("zqj")){ | ||
| 592 | - list.get(c).put("zqjZm", maps.get("zdm")); | ||
| 593 | - list.get(c).put("zqjCls", maps.get("cls")); | ||
| 594 | - c++; | ||
| 595 | - fage=false; | ||
| 596 | - }else if(maps.get("lx").equals("wqj")){ | ||
| 597 | - list.get(d).put("wqjZm", maps.get("zdm")); | ||
| 598 | - list.get(d).put("wqjCls", maps.get("cls")); | ||
| 599 | - d++; | ||
| 600 | - fage=false; | ||
| 601 | - } | ||
| 602 | - if(fage){ | ||
| 603 | - break; | ||
| 604 | - } | ||
| 605 | - } | ||
| 606 | - boolean status=true; | ||
| 607 | - while (status) { | ||
| 608 | - for (int i = 0; i < list.size(); i++) { | ||
| 609 | - if(list.get(i).isEmpty()){ | ||
| 610 | - list.remove(i); | ||
| 611 | - status=true; | ||
| 612 | - }else{ | ||
| 613 | - status=false; | ||
| 614 | - } | ||
| 615 | - } | ||
| 616 | - | ||
| 617 | - } | ||
| 618 | - return list; | ||
| 619 | - }*/ | 549 | + |
| 620 | @Override | 550 | @Override |
| 621 | public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) { | 551 | public List<Map<String, Object>> tbodyTime3(String line, String ttinfo) { |
| 622 | // TODO Auto-generated method stub | 552 | // TODO Auto-generated method stub |
| 623 | List<Map<String, Object>> list=new ArrayList<Map<String,Object>>(); | 553 | List<Map<String, Object>> list=new ArrayList<Map<String,Object>>(); |
| 624 | List<Map<String, Object>> list_s=new ArrayList<Map<String,Object>>(); | 554 | List<Map<String, Object>> list_s=new ArrayList<Map<String,Object>>(); |
| 625 | 555 | ||
| 626 | - | ||
| 627 | - /*String sqlZd="select a.qdz_name,COUNT(a.cl_zbh) as cls,'zqc' AS lx from (" | ||
| 628 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"' " | ||
| 629 | - + " and bc_type ='normal'" | ||
| 630 | - + " and ((fcsj >'06:31' and fcsj<'08:30') or ( fcsj>'6:31' and fcsj<'8:30'))" | ||
| 631 | - + " group by cl_zbh,qdz_name) a group by a.qdz_name" | ||
| 632 | - + " union " | ||
| 633 | - + " select a.qdz_name,COUNT(a.cl_zbh) as cls,'wqc' AS lx from (" | ||
| 634 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"'" | ||
| 635 | - + " and bc_type ='normal' " | ||
| 636 | - + " and fcsj >'16:01' and fcsj<'18:00' group by cl_zbh,qdz_name " | ||
| 637 | - + " ) a group by a.qdz_name " | ||
| 638 | - + " union " | ||
| 639 | - + " select a.qdz_name,COUNT(a.cl_zbh) as cls,'zqj' AS lx from (" | ||
| 640 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"'" | ||
| 641 | - + " and bc_type ='region' " | ||
| 642 | - + " and ((fcsj >'06:31' and fcsj<'08:30') or ( fcsj>'6:31' and fcsj<'8:30'))" | ||
| 643 | - + " group by cl_zbh,qdz_name) a group by a.qdz_name" | ||
| 644 | - + " union " | ||
| 645 | - + " select a.qdz_name,COUNT(a.cl_zbh) as cls,'wqj' AS lx from (" | ||
| 646 | - + " select cl_zbh,qdz_name from bsth_c_s_sp_info where tt_info ='"+ttinfo+"'" | ||
| 647 | - + " and bc_type ='region' and fcsj >'16:01' and fcsj<'18:00'" | ||
| 648 | - + " group by cl_zbh,qdz_name) a group by a.qdz_name";*/ | ||
| 649 | - | ||
| 650 | - String sqlCl="SELECT cl_zbh,qdz_name,bc_type,fcsj,bcsj FROM" | ||
| 651 | - + " bsth_c_s_sp_info WHERE tt_info = '"+ttinfo+"' " | 556 | + String sqlCl="SELECT lp cl_zbh,qdz_name,bc_type,fcsj,bcsj FROM" |
| 557 | + + " bsth_c_s_ttinfo_detail WHERE ttinfo = '"+ttinfo+"' " | ||
| 652 | + " AND (bc_type = 'normal' or bc_type='region') order by qdz_name"; | 558 | + " AND (bc_type = 'normal' or bc_type='region') order by qdz_name"; |
| 653 | 559 | ||
| 654 | List<Map<String, Object>> listj= jdbcTemplate.query(sqlCl, | 560 | List<Map<String, Object>> listj= jdbcTemplate.query(sqlCl, |
| @@ -665,7 +571,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -665,7 +571,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 665 | } | 571 | } |
| 666 | }); | 572 | }); |
| 667 | 573 | ||
| 668 | - String sqlZd="select qdz_name ,bc_type from bsth_c_s_sp_info WHERE tt_info = '"+ttinfo+"' " | 574 | + String sqlZd="select qdz_name,bc_type from bsth_c_s_ttinfo_detail WHERE ttinfo = '"+ttinfo+"' " |
| 669 | + " AND (bc_type = 'normal' or bc_type='region') group by qdz_name ,bc_type " | 575 | + " AND (bc_type = 'normal' or bc_type='region') group by qdz_name ,bc_type " |
| 670 | + " order by qdz_name"; | 576 | + " order by qdz_name"; |
| 671 | List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, | 577 | List<Map<String, Object>> lists= jdbcTemplate.query(sqlZd, |
| @@ -807,6 +713,8 @@ public class ReportServiceImpl implements ReportService{ | @@ -807,6 +713,8 @@ public class ReportServiceImpl implements ReportService{ | ||
| 807 | } | 713 | } |
| 808 | boolean status=true; | 714 | boolean status=true; |
| 809 | while (status) { | 715 | while (status) { |
| 716 | + if(list.size() == 0) | ||
| 717 | + break; | ||
| 810 | for (int i = 0; i < list.size(); i++) { | 718 | for (int i = 0; i < list.size(); i++) { |
| 811 | if(list.get(i).isEmpty()){ | 719 | if(list.get(i).isEmpty()){ |
| 812 | list.remove(i); | 720 | list.remove(i); |
| @@ -815,8 +723,8 @@ public class ReportServiceImpl implements ReportService{ | @@ -815,8 +723,8 @@ public class ReportServiceImpl implements ReportService{ | ||
| 815 | status=false; | 723 | status=false; |
| 816 | } | 724 | } |
| 817 | } | 725 | } |
| 818 | - | ||
| 819 | } | 726 | } |
| 727 | + | ||
| 820 | return list; | 728 | return list; |
| 821 | } | 729 | } |
| 822 | 730 | ||
| @@ -828,11 +736,14 @@ public class ReportServiceImpl implements ReportService{ | @@ -828,11 +736,14 @@ public class ReportServiceImpl implements ReportService{ | ||
| 828 | String minfcsj="02:00"; | 736 | String minfcsj="02:00"; |
| 829 | List<Line> lineList=lineRepository.findLineByCode(line); | 737 | List<Line> lineList=lineRepository.findLineByCode(line); |
| 830 | if(lineList.size()>0){ | 738 | if(lineList.size()>0){ |
| 831 | - String sqlMinYysj="select start_opt from bsth_c_line_config where " | ||
| 832 | - + " id = (" | ||
| 833 | - + "select max(id) from bsth_c_line_config where line ='"+lineList.get(0).getId() +"'" | ||
| 834 | - + ")"; | ||
| 835 | - minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class); | 739 | + String sql = "select count(*) from bsth_c_line_config where line = '"+lineList.get(0).getId()+"'"; |
| 740 | + if(jdbcTemplate.queryForObject(sql, Integer.class) > 0){ | ||
| 741 | + String sqlMinYysj="select start_opt from bsth_c_line_config where " | ||
| 742 | + + " id = (" | ||
| 743 | + + "select max(id) from bsth_c_line_config where line ='"+lineList.get(0).getId() +"'" | ||
| 744 | + + ")"; | ||
| 745 | + minfcsj=jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 746 | + } | ||
| 836 | } | 747 | } |
| 837 | 748 | ||
| 838 | //查询全程 | 749 | //查询全程 |
| @@ -917,11 +828,14 @@ public class ReportServiceImpl implements ReportService{ | @@ -917,11 +828,14 @@ public class ReportServiceImpl implements ReportService{ | ||
| 917 | String minfcsj="02:00"; | 828 | String minfcsj="02:00"; |
| 918 | List<Line> lineList=lineRepository.findLineByCode(line); | 829 | List<Line> lineList=lineRepository.findLineByCode(line); |
| 919 | if(lineList.size()>0){ | 830 | if(lineList.size()>0){ |
| 920 | - String sqlMinYysj="select start_opt from bsth_c_line_config where " | ||
| 921 | - + " id = (" | ||
| 922 | - + "select max(id) from bsth_c_line_config where line ='"+lineList.get(0).getId() +"'" | ||
| 923 | - + ")"; | ||
| 924 | - minfcsj= jdbcTemplate.queryForObject(sqlMinYysj, String.class); | 831 | + String sql = "select count(*) from bsth_c_line_config where line = '"+lineList.get(0).getId()+"'"; |
| 832 | + if(jdbcTemplate.queryForObject(sql, Integer.class) > 0){ | ||
| 833 | + String sqlMinYysj="select start_opt from bsth_c_line_config where " | ||
| 834 | + + " id = (" | ||
| 835 | + + "select max(id) from bsth_c_line_config where line ='"+lineList.get(0).getId() +"'" | ||
| 836 | + + ")"; | ||
| 837 | + minfcsj= jdbcTemplate.queryForObject(sqlMinYysj, String.class); | ||
| 838 | + } | ||
| 925 | } | 839 | } |
| 926 | String[] minSjs = minfcsj.split(":"); | 840 | String[] minSjs = minfcsj.split(":"); |
| 927 | int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]); | 841 | int minSj=Integer.parseInt(minSjs[0])*60+Integer.parseInt(minSjs[1]); |
src/main/java/com/bsth/service/schedule/TTInfoDetailService.java
| @@ -4,6 +4,7 @@ import com.bsth.entity.schedule.TTInfoDetail; | @@ -4,6 +4,7 @@ import com.bsth.entity.schedule.TTInfoDetail; | ||
| 4 | import com.bsth.service.schedule.datatools.TTInfoDetailForEdit; | 4 | import com.bsth.service.schedule.datatools.TTInfoDetailForEdit; |
| 5 | import com.bsth.service.schedule.datatools.TTinfoDetailDynamicData; | 5 | import com.bsth.service.schedule.datatools.TTinfoDetailDynamicData; |
| 6 | import com.bsth.service.schedule.exception.ScheduleException; | 6 | import com.bsth.service.schedule.exception.ScheduleException; |
| 7 | +import com.bsth.service.schedule.timetable.ExcelFormatType; | ||
| 7 | import com.bsth.service.schedule.utils.DataToolsFile; | 8 | import com.bsth.service.schedule.utils.DataToolsFile; |
| 8 | 9 | ||
| 9 | import java.util.List; | 10 | import java.util.List; |
| @@ -45,13 +46,15 @@ public interface TTInfoDetailService extends BService<TTInfoDetail, Long> { | @@ -45,13 +46,15 @@ public interface TTInfoDetailService extends BService<TTInfoDetail, Long> { | ||
| 45 | * @param sheetname sheet名字 | 46 | * @param sheetname sheet名字 |
| 46 | * @param lineid 线路id | 47 | * @param lineid 线路id |
| 47 | * @param lineversion 线路版本 | 48 | * @param lineversion 线路版本 |
| 49 | + * @param excelFormatType 版本 | ||
| 48 | */ | 50 | */ |
| 49 | void validateExcelSheet( | 51 | void validateExcelSheet( |
| 50 | String filename, | 52 | String filename, |
| 51 | String sheetname, | 53 | String sheetname, |
| 52 | Integer lineid, | 54 | Integer lineid, |
| 53 | String linename, | 55 | String linename, |
| 54 | - Integer lineversion) throws ScheduleException; | 56 | + Integer lineversion, |
| 57 | + ExcelFormatType excelFormatType) throws ScheduleException; | ||
| 55 | 58 | ||
| 56 | /** | 59 | /** |
| 57 | * 验证关联的线路标准信息(以后放到规则引擎里去做)。 | 60 | * 验证关联的线路标准信息(以后放到规则引擎里去做)。 |
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
| 1 | package com.bsth.service.schedule.datatools; | 1 | package com.bsth.service.schedule.datatools; |
| 2 | 2 | ||
| 3 | -import com.bsth.entity.Station; | ||
| 4 | -import com.bsth.service.StationService; | 3 | +import com.bsth.entity.StationRoute; |
| 4 | +import com.bsth.service.StationRouteService; | ||
| 5 | import com.bsth.service.schedule.exception.ScheduleException; | 5 | import com.bsth.service.schedule.exception.ScheduleException; |
| 6 | +import com.bsth.service.schedule.timetable.ExcelFormatType; | ||
| 6 | import com.bsth.service.schedule.utils.*; | 7 | import com.bsth.service.schedule.utils.*; |
| 7 | import jxl.Sheet; | 8 | import jxl.Sheet; |
| 8 | import jxl.Workbook; | 9 | import jxl.Workbook; |
| @@ -14,10 +15,13 @@ import org.apache.poi.ss.usermodel.Cell; | @@ -14,10 +15,13 @@ import org.apache.poi.ss.usermodel.Cell; | ||
| 14 | import org.apache.poi.ss.usermodel.Row; | 15 | import org.apache.poi.ss.usermodel.Row; |
| 15 | import org.apache.poi.ss.util.CellRangeAddress; | 16 | import org.apache.poi.ss.util.CellRangeAddress; |
| 16 | import org.apache.poi.ss.util.WorkbookUtil; | 17 | import org.apache.poi.ss.util.WorkbookUtil; |
| 18 | +import org.apache.poi.xssf.usermodel.XSSFCell; | ||
| 17 | import org.apache.poi.xssf.usermodel.XSSFRow; | 19 | import org.apache.poi.xssf.usermodel.XSSFRow; |
| 18 | import org.apache.poi.xssf.usermodel.XSSFSheet; | 20 | import org.apache.poi.xssf.usermodel.XSSFSheet; |
| 19 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; | 21 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| 20 | import org.joda.time.DateTime; | 22 | import org.joda.time.DateTime; |
| 23 | +import org.joda.time.LocalTime; | ||
| 24 | +import org.joda.time.format.DateTimeFormat; | ||
| 21 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
| 22 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
| 23 | import org.springframework.beans.factory.annotation.Autowired; | 27 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -42,9 +46,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -42,9 +46,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 42 | /** 日志记录器 */ | 46 | /** 日志记录器 */ |
| 43 | private final static Logger LOGGER = LoggerFactory.getLogger(TTInfoDetailDataToolsImpl.class); | 47 | private final static Logger LOGGER = LoggerFactory.getLogger(TTInfoDetailDataToolsImpl.class); |
| 44 | 48 | ||
| 45 | - // TODO:之后改了 | ||
| 46 | @Autowired | 49 | @Autowired |
| 47 | - private StationService stationService; | 50 | + private StationRouteService stationRouteService; |
| 48 | 51 | ||
| 49 | @Autowired | 52 | @Autowired |
| 50 | @Qualifier(value = "dataToolsServiceImpl") | 53 | @Qualifier(value = "dataToolsServiceImpl") |
| @@ -98,7 +101,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -98,7 +101,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 98 | Integer lineid = Integer.valueOf(String.valueOf(params.get("lineinfo"))); // 线路标准id | 101 | Integer lineid = Integer.valueOf(String.valueOf(params.get("lineinfo"))); // 线路标准id |
| 99 | String xlname = String.valueOf(params.get("xlname")); // 线路名字 | 102 | String xlname = String.valueOf(params.get("xlname")); // 线路名字 |
| 100 | String ttname = String.valueOf(params.get("ttname")); // 时刻表名字 | 103 | String ttname = String.valueOf(params.get("ttname")); // 时刻表名字 |
| 101 | - Integer lineversion = Integer.valueOf(params.get("lineversion").toString()); | 104 | + Integer lineversion = Integer.valueOf(params.get("lineversion").toString()); // 线路路由版本 |
| 105 | + ExcelFormatType excelFormatType = ExcelFormatType.getEnum(String.valueOf(params.get("excelFormatType"))); // 格式 | ||
| 102 | 106 | ||
| 103 | LOGGER.info("参数1, xls文件名={},sheet名字={}", filename, sheetname); | 107 | LOGGER.info("参数1, xls文件名={},sheet名字={}", filename, sheetname); |
| 104 | LOGGER.info("参数2, 线路id={},线路名字={}", xlid, xlname); | 108 | LOGGER.info("参数2, 线路id={},线路名字={}", xlid, xlname); |
| @@ -175,6 +179,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -175,6 +179,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 175 | // 实际数据ktr | 179 | // 实际数据ktr |
| 176 | File ktrFile2_version = new File(this.getClass().getResource( | 180 | File ktrFile2_version = new File(this.getClass().getResource( |
| 177 | dataToolsProperties.getTtinfodetailDatainputktr2version()).toURI()); | 181 | dataToolsProperties.getTtinfodetailDatainputktr2version()).toURI()); |
| 182 | + // 实际数据ktr2 | ||
| 183 | + File ktrFile2_version2 = new File(this.getClass().getResource( | ||
| 184 | + dataToolsProperties.getTtinfodetailDatainputktr2version2()).toURI()); | ||
| 185 | + | ||
| 178 | 186 | ||
| 179 | // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | 187 | // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 |
| 180 | ktrParms.put("transpath", mktrFile.getAbsolutePath()); | 188 | ktrParms.put("transpath", mktrFile.getAbsolutePath()); |
| @@ -182,7 +190,14 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -182,7 +190,14 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 182 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 190 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| 183 | 191 | ||
| 184 | // 附加参数 | 192 | // 附加参数 |
| 185 | - ktrParms.put("injectktrfile", ktrFile2_version.getAbsolutePath()); // 注入元数据的ktr文件 | 193 | + if (excelFormatType == ExcelFormatType.Normal) { |
| 194 | + ktrParms.put("injectktrfile", ktrFile2_version.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 195 | + } else if (excelFormatType == ExcelFormatType.Dynamic) { | ||
| 196 | + ktrParms.put("injectktrfile", ktrFile2_version2.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 197 | + } else { | ||
| 198 | + throw new ScheduleException("未知ExcelFormatType"); | ||
| 199 | + } | ||
| 200 | + | ||
| 186 | ktrParms.put("sheetname", sheetname); // sheet工作区的名字 | 201 | ktrParms.put("sheetname", sheetname); // sheet工作区的名字 |
| 187 | ktrParms.put("lineinfoid", lineid); // 线路标准id | 202 | ktrParms.put("lineinfoid", lineid); // 线路标准id |
| 188 | ktrParms.put("xlname", xlname); // 线路名称 | 203 | ktrParms.put("xlname", xlname); // 线路名称 |
| @@ -441,8 +456,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -441,8 +456,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 441 | 456 | ||
| 442 | // 构造表头 | 457 | // 构造表头 |
| 443 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short)0, "路牌", new Color(0x96b9d7)); | 458 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short)0, "路牌", new Color(0x96b9d7)); |
| 444 | - Station station1 = stationService.findById(lpObjList.get(0).getStationRouteId1()); | ||
| 445 | - Station station2 = stationService.findById(lpObjList.get(1).getStationRouteId2()); | 459 | + StationRoute station1 = stationRouteService.findById(lpObjList.get(0).getStationRouteId1()); |
| 460 | + StationRoute station2 = stationRouteService.findById(lpObjList.get(1).getStationRouteId2()); | ||
| 446 | for (int i = 0; i < groupCount; i++) { | 461 | for (int i = 0; i < groupCount; i++) { |
| 447 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 1), | 462 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 1), |
| 448 | station1.getStationName(), new Color(0x96b9d7)); | 463 | station1.getStationName(), new Color(0x96b9d7)); |
| @@ -553,8 +568,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -553,8 +568,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 553 | 568 | ||
| 554 | // 构造表头,添加一个进场,添加一个出场 | 569 | // 构造表头,添加一个进场,添加一个出场 |
| 555 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short)0, "路牌", new Color(0x96b9d7)); | 570 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short)0, "路牌", new Color(0x96b9d7)); |
| 556 | - Station station1 = stationService.findById(lpObjList.get(0).getStationRouteId1()); | ||
| 557 | - Station station2 = stationService.findById(lpObjList.get(1).getStationRouteId2()); | 571 | + StationRoute station1 = stationRouteService.findById(lpObjList.get(0).getStationRouteId1()); |
| 572 | + StationRoute station2 = stationRouteService.findById(lpObjList.get(1).getStationRouteId2()); | ||
| 558 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (1), | 573 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (1), |
| 559 | "报到", new Color(0x96b9d7)); | 574 | "报到", new Color(0x96b9d7)); |
| 560 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (2), | 575 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (2), |
| @@ -565,8 +580,12 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -565,8 +580,12 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 565 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 2), | 580 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 2), |
| 566 | station2.getStationName(), new Color(0x96b9d7)); | 581 | station2.getStationName(), new Color(0x96b9d7)); |
| 567 | } | 582 | } |
| 583 | + | ||
| 584 | + // 最后一个进场需要变成三个班次 | ||
| 585 | + // 1个分班进场班次插入到前面的班次 | ||
| 586 | + // 后面添加两个班次,1个到场班次,1个离场班次 | ||
| 568 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 3), | 587 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 3), |
| 569 | - "进场", new Color(0x96b9d7)); | 588 | + "到场", new Color(0x96b9d7)); |
| 570 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 4), | 589 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 4), |
| 571 | "离场", new Color(0x96b9d7)); | 590 | "离场", new Color(0x96b9d7)); |
| 572 | 591 | ||
| @@ -589,56 +608,74 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -589,56 +608,74 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 589 | LpObj lpObj = lpObjList.get(i); | 608 | LpObj lpObj = lpObjList.get(i); |
| 590 | XSSFRow lpRow = sheet.createRow((short) (i + 1)); | 609 | XSSFRow lpRow = sheet.createRow((short) (i + 1)); |
| 591 | PoiUtils.createStringXSSFCell(wb, lpRow, (short) 0, lpObj.getLpname()); | 610 | PoiUtils.createStringXSSFCell(wb, lpRow, (short) 0, lpObj.getLpname()); |
| 592 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (1)); | ||
| 593 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (2)); | ||
| 594 | - for (int j = 1; j <= groupCount; j++) { | ||
| 595 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (j * 2 + 1)); | ||
| 596 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (j * 2 + 2)); | ||
| 597 | - } | ||
| 598 | 611 | ||
| 599 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 3)); | ||
| 600 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 4)); | 612 | + // 创建空白单元格,并设置字符串格式 |
| 613 | + XSSFCell xssfCell = null; | ||
| 601 | 614 | ||
| 602 | - for (BcObj bcObj : lpObj.getBcObjList()) { | ||
| 603 | - if (bcObj.getBcType() == BcType.NORMAL) { | ||
| 604 | - Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 605 | - cell.setCellValue(bcObj.getFcsj()); | 615 | + xssfCell = PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (1)); |
| 616 | + PoiUtils.setStringStyleXSSFCellStyle(wb, xssfCell); | ||
| 606 | 617 | ||
| 607 | - } else if (bcObj.getBcType() == BcType.BD) { | ||
| 608 | - if (bcObj.getGroupNo() == -1) { | ||
| 609 | - Cell cell = lpRow.getCell((short) 1); | ||
| 610 | - cell.setCellValue(bcObj.getFcsj()); | ||
| 611 | - } else if (bcObj.getGroupNo() > 0) { // 分班报到 | ||
| 612 | - Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 613 | - cell.setCellValue("报" + bcObj.getFcsj()); | 618 | + xssfCell = PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (2)); |
| 619 | + PoiUtils.setStringStyleXSSFCellStyle(wb, xssfCell); | ||
| 614 | 620 | ||
| 615 | - } | ||
| 616 | - | ||
| 617 | - } else if (bcObj.getBcType() == BcType.OUT) { | ||
| 618 | - if (bcObj.getGroupNo() == -1) { | ||
| 619 | - Cell cell = lpRow.getCell((short) (2)); | ||
| 620 | - cell.setCellValue(bcObj.getFcsj()); | ||
| 621 | - } else if (bcObj.getGroupNo() > 0) { // 分班出场 | ||
| 622 | - Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 623 | - cell.setCellValue("出" + bcObj.getFcsj()); | ||
| 624 | - } | 621 | + for (int j = 1; j <= groupCount; j++) { |
| 622 | + xssfCell = PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (j * 2 + 1)); | ||
| 623 | + PoiUtils.setStringStyleXSSFCellStyle(wb, xssfCell); | ||
| 624 | + xssfCell = PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (j * 2 + 2)); | ||
| 625 | + PoiUtils.setStringStyleXSSFCellStyle(wb, xssfCell); | ||
| 626 | + } | ||
| 625 | 627 | ||
| 626 | - } else if (bcObj.getBcType() == BcType.IN) { | ||
| 627 | - if (bcObj.getGroupNo() == -2) { | ||
| 628 | - Cell cell = lpRow.getCell((short) (groupCount * 2 + 3)); | 628 | + xssfCell = PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 3)); |
| 629 | + PoiUtils.setStringStyleXSSFCellStyle(wb, xssfCell); | ||
| 630 | + xssfCell = PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 4)); | ||
| 631 | + PoiUtils.setStringStyleXSSFCellStyle(wb, xssfCell); | ||
| 632 | + | ||
| 633 | + for (int j = 0; j < lpObj.getBcObjList().size(); j++) { | ||
| 634 | + BcObj bcObj = lpObj.getBcObjList().get(j); // 当前班次 | ||
| 635 | + Cell cell = null; // 待处理的单元格 | ||
| 636 | + | ||
| 637 | + switch (bcObj.getBcType()) { | ||
| 638 | + case BD: // 报到班次 | ||
| 639 | + if (bcObj.getIsFb()) { // 分班-两个车次链 | ||
| 640 | + cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 641 | + cell.setCellValue("报" + bcObj.getFcsj()); | ||
| 642 | + } else { // 一个车次链 | ||
| 643 | + cell = lpRow.getCell((short) 1); | ||
| 644 | + cell.setCellValue(bcObj.getFcsj()); | ||
| 645 | + } | ||
| 646 | + break; | ||
| 647 | + case OUT: // 出场班次 | ||
| 648 | + if (bcObj.getIsFb()) { // 分班-两个车次链 | ||
| 649 | + cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 650 | + cell.setCellValue("出" + bcObj.getFcsj()); | ||
| 651 | + } else { // 一个车次链 | ||
| 652 | + cell = lpRow.getCell((short) (2)); | ||
| 653 | + cell.setCellValue(bcObj.getFcsj()); | ||
| 654 | + } | ||
| 655 | + break; | ||
| 656 | + case NORMAL: // 正常班次 | ||
| 657 | + cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 629 | cell.setCellValue(bcObj.getFcsj()); | 658 | cell.setCellValue(bcObj.getFcsj()); |
| 630 | - } else if (bcObj.getGroupNo() > 0) { //分班进场 | ||
| 631 | - Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 632 | - // 停驶用 ※ | ||
| 633 | - cell.setCellValue(bcObj.getFcsj() + "X"); | ||
| 634 | - } | ||
| 635 | - | ||
| 636 | - } else if (bcObj.getBcType() == BcType.LC) { | ||
| 637 | - if (bcObj.getGroupNo() == -2) { | ||
| 638 | - Cell cell = lpRow.getCell((short) (groupCount * 2 + 4)); | 659 | + break; |
| 660 | + case IN: // 进场班次 | ||
| 661 | + if (bcObj.getIsFb()) { // 分班-两个车次链 | ||
| 662 | + cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 663 | + // TODO:停驶用 ※ | ||
| 664 | + cell.setCellValue(bcObj.getFcsj() + "X"); | ||
| 665 | + } else { // 一个车次链 | ||
| 666 | + cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | ||
| 667 | + cell.setCellValue(bcObj.getFcsj() + "X"); | ||
| 668 | + } | ||
| 669 | + break; | ||
| 670 | + case LC: | ||
| 671 | + // 这个是到场,准备离场班次 | ||
| 672 | + cell = lpRow.getCell((short) (groupCount * 2 + 3)); | ||
| 639 | cell.setCellValue(bcObj.getFcsj()); | 673 | cell.setCellValue(bcObj.getFcsj()); |
| 640 | - } | ||
| 641 | - | 674 | + // 加10分钟表示真正离场时间 |
| 675 | + cell = lpRow.getCell((short) (groupCount * 2 + 4)); | ||
| 676 | + LocalTime localTime = LocalTime.parse(bcObj.getFcsj(), DateTimeFormat.forPattern("HH:mm")); | ||
| 677 | + cell.setCellValue(localTime.plusMinutes(10).toString(DateTimeFormat.forPattern("HH:mm"))); | ||
| 678 | + break; | ||
| 642 | } | 679 | } |
| 643 | } | 680 | } |
| 644 | 681 | ||
| @@ -647,9 +684,9 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -647,9 +684,9 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 647 | PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 6), lpObj.getYylc()); | 684 | PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 6), lpObj.getYylc()); |
| 648 | PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 7), lpObj.getKslc()); | 685 | PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 7), lpObj.getKslc()); |
| 649 | PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 8), | 686 | PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 8), |
| 650 | - String.format("%d小时%d分钟", (int) (lpObj.getZgs() / 60), (int) (lpObj.getZgs() % 60))); | 687 | + String.format("%d%s%d", (int) (lpObj.getZgs() / 60), ":", (int) (lpObj.getZgs() % 60))); |
| 651 | PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 9), | 688 | PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 9), |
| 652 | - String.format("%d小时%d分钟", (int) (lpObj.getYygs() / 60), (int) (lpObj.getYygs() % 60))); | 689 | + String.format("%d%s%d", (int) (lpObj.getYygs() / 60), ":", (int) (lpObj.getYygs() % 60))); |
| 653 | PoiUtils.createIntegerXSSFCell(wb, lpRow, (short) (groupCount * 2 + 10), lpObj.getYybc()); | 690 | PoiUtils.createIntegerXSSFCell(wb, lpRow, (short) (groupCount * 2 + 10), lpObj.getYybc()); |
| 654 | 691 | ||
| 655 | } | 692 | } |
src/main/java/com/bsth/service/schedule/datatools/TTinfoDetailDynamicData.java
| @@ -54,6 +54,9 @@ public interface TTinfoDetailDynamicData { | @@ -54,6 +54,9 @@ public interface TTinfoDetailDynamicData { | ||
| 54 | /** 是否上行 */ | 54 | /** 是否上行 */ |
| 55 | private Boolean isUp; | 55 | private Boolean isUp; |
| 56 | 56 | ||
| 57 | + /** 是否分班 */ | ||
| 58 | + private Boolean isFb; | ||
| 59 | + | ||
| 57 | /** 班次类型 */ | 60 | /** 班次类型 */ |
| 58 | private BcType bcType; | 61 | private BcType bcType; |
| 59 | /** 发车时刻 */ | 62 | /** 发车时刻 */ |
| @@ -154,14 +157,6 @@ public interface TTinfoDetailDynamicData { | @@ -154,14 +157,6 @@ public interface TTinfoDetailDynamicData { | ||
| 154 | this.groupBcNo = groupBcNo; | 157 | this.groupBcNo = groupBcNo; |
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | - public Boolean getUp() { | ||
| 158 | - return isUp; | ||
| 159 | - } | ||
| 160 | - | ||
| 161 | - public void setUp(Boolean up) { | ||
| 162 | - isUp = up; | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | public String getFcsjDesc() { | 160 | public String getFcsjDesc() { |
| 166 | return fcsjDesc; | 161 | return fcsjDesc; |
| 167 | } | 162 | } |
| @@ -169,6 +164,14 @@ public interface TTinfoDetailDynamicData { | @@ -169,6 +164,14 @@ public interface TTinfoDetailDynamicData { | ||
| 169 | public void setFcsjDesc(String fcsjDesc) { | 164 | public void setFcsjDesc(String fcsjDesc) { |
| 170 | this.fcsjDesc = fcsjDesc; | 165 | this.fcsjDesc = fcsjDesc; |
| 171 | } | 166 | } |
| 167 | + | ||
| 168 | + public Boolean getIsFb() { | ||
| 169 | + return isFb; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + public void setIsFb(Boolean fb) { | ||
| 173 | + isFb = fb; | ||
| 174 | + } | ||
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | public static class LpObj { // 路牌对象 | 177 | public static class LpObj { // 路牌对象 |
| @@ -314,6 +317,7 @@ public interface TTinfoDetailDynamicData { | @@ -314,6 +317,7 @@ public interface TTinfoDetailDynamicData { | ||
| 314 | public void setYybc(Integer yybc) { | 317 | public void setYybc(Integer yybc) { |
| 315 | this.yybc = yybc; | 318 | this.yybc = yybc; |
| 316 | } | 319 | } |
| 320 | + | ||
| 317 | } | 321 | } |
| 318 | 322 | ||
| 319 | public static class StatInfo { // 统计数据对象 | 323 | public static class StatInfo { // 统计数据对象 |
src/main/java/com/bsth/service/schedule/impl/PeopleCarPlanServiceImpl.java
| @@ -565,7 +565,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -565,7 +565,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 565 | } | 565 | } |
| 566 | try { | 566 | try { |
| 567 | 567 | ||
| 568 | - String sql = "select * from bsth_c_s_sp_info_real where schedule_date_str >= '"+startDate+"' and schedule_date_str <= '"+endDate+"'"; | 568 | + String sql = "select schedule_date_str,xl_name,bc_type,gs_name,fgs_name,bcs,fcno," |
| 569 | + +"fcsj,fcsj_actual,zdsj,zdsj_actual,bcsj,qdz_name,sp_id,cc_service" | ||
| 570 | + +" from bsth_c_s_sp_info_real where schedule_date_str >= '"+startDate | ||
| 571 | + +"' and schedule_date_str <= '"+endDate+"'"; | ||
| 569 | if(line.length() != 0){ | 572 | if(line.length() != 0){ |
| 570 | sql += " and xl_bm = '"+line+"'"; | 573 | sql += " and xl_bm = '"+line+"'"; |
| 571 | } | 574 | } |
| @@ -636,8 +639,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -636,8 +639,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 636 | 639 | ||
| 637 | if(model.length() != 0){ | 640 | if(model.length() != 0){ |
| 638 | // sql = "select * from bsth_c_s_ttinfo_detail where ttinfo = '"+model+"' and bc_type != 'in' and bc_type != 'out'"; | 641 | // sql = "select * from bsth_c_s_ttinfo_detail where ttinfo = '"+model+"' and bc_type != 'in' and bc_type != 'out'"; |
| 639 | - sql = "select id from bsth_c_s_sp_info where tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out'" + | ||
| 640 | - " and bc_type != 'ldks' and schedule_date >= '"+startDate+"' and schedule_date <= '"+endDate+"'"; | 642 | + sql = "select id from bsth_c_s_sp_info where tt_info = '" + model + "' and bc_type != 'in' and bc_type != 'out'" |
| 643 | + + " and bc_type != 'ldks' and schedule_date >= '"+startDate+"' and schedule_date <= '"+endDate+"'"; | ||
| 641 | if(line.length() != 0){ | 644 | if(line.length() != 0){ |
| 642 | sql += " and xl_bm = '"+line+"'"; | 645 | sql += " and xl_bm = '"+line+"'"; |
| 643 | } | 646 | } |
| @@ -656,21 +659,21 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -656,21 +659,21 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 656 | e.printStackTrace(); | 659 | e.printStackTrace(); |
| 657 | } | 660 | } |
| 658 | 661 | ||
| 662 | + Set<Long> ttSet = new HashSet<Long>(); | ||
| 663 | + for(Long tt : ttList){ | ||
| 664 | + ttSet.add(tt); | ||
| 665 | + } | ||
| 659 | //分组计算 同时判断是否所选时刻信息 | 666 | //分组计算 同时判断是否所选时刻信息 |
| 660 | for(ScheduleRealInfo schedule : list){ | 667 | for(ScheduleRealInfo schedule : list){ |
| 661 | if(schedule.isCcService()){ | 668 | if(schedule.isCcService()){ |
| 662 | continue; | 669 | continue; |
| 663 | } | 670 | } |
| 664 | - DO:{ | ||
| 665 | if(model.length() != 0){ | 671 | if(model.length() != 0){ |
| 666 | - for(Long tt : ttList){ | ||
| 667 | - if((long)tt == (long)schedule.getSpId()){ | ||
| 668 | - String key = schedule.getXlName()+"/"+schedule.getQdzName()+"/"+schedule.getFcsj(); | ||
| 669 | - if(!keyMap.containsKey(key)) | ||
| 670 | - keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | ||
| 671 | - keyMap.get(key).add(schedule); | ||
| 672 | - break DO; | ||
| 673 | - } | 672 | + if(ttSet.contains(schedule.getSpId())){ |
| 673 | + String key = schedule.getXlName()+"/"+schedule.getQdzName()+"/"+schedule.getFcsj(); | ||
| 674 | + if(!keyMap.containsKey(key)) | ||
| 675 | + keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | ||
| 676 | + keyMap.get(key).add(schedule); | ||
| 674 | } | 677 | } |
| 675 | } else { | 678 | } else { |
| 676 | String key = schedule.getXlName()+"/"+schedule.getQdzName()+"/"+schedule.getFcsj(); | 679 | String key = schedule.getXlName()+"/"+schedule.getQdzName()+"/"+schedule.getFcsj(); |
| @@ -678,7 +681,6 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -678,7 +681,6 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 678 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | 681 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| 679 | keyMap.get(key).add(schedule); | 682 | keyMap.get(key).add(schedule); |
| 680 | } | 683 | } |
| 681 | - } | ||
| 682 | } | 684 | } |
| 683 | String companyName = "", subCompanyName = ""; | 685 | String companyName = "", subCompanyName = ""; |
| 684 | for(String key : keyMap.keySet()){ | 686 | for(String key : keyMap.keySet()){ |
| @@ -800,7 +802,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -800,7 +802,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 800 | if(page.length() != 0 && type.equals("query")){ | 802 | if(page.length() != 0 && type.equals("query")){ |
| 801 | int currPage = Integer.valueOf(page); | 803 | int currPage = Integer.valueOf(page); |
| 802 | modelMap.put("totalPage", resList.size()%10>0?(resList.size()/10 + 1):resList.size()/10); | 804 | modelMap.put("totalPage", resList.size()%10>0?(resList.size()/10 + 1):resList.size()/10); |
| 803 | - modelMap.put("dataList", resList.subList(currPage*10,((currPage+1)*10)>=resList.size()?resList.size():(currPage+1)*10)); | 805 | +// modelMap.put("dataList", resList.subList(currPage*10,((currPage+1)*10)>=resList.size()?resList.size():(currPage+1)*10)); |
| 806 | + modelMap.put("dataList", resList); | ||
| 804 | } else { | 807 | } else { |
| 805 | modelMap.put("dataList", resList); | 808 | modelMap.put("dataList", resList); |
| 806 | } | 809 | } |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| 1 | package com.bsth.service.schedule.impl; | 1 | package com.bsth.service.schedule.impl; |
| 2 | 2 | ||
| 3 | -import com.bsth.entity.Line; | ||
| 4 | import com.bsth.entity.schedule.SchedulePlan; | 3 | import com.bsth.entity.schedule.SchedulePlan; |
| 5 | -import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 6 | import com.bsth.entity.schedule.TTInfo; | 4 | import com.bsth.entity.schedule.TTInfo; |
| 7 | -import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | ||
| 8 | import com.bsth.repository.BusinessRepository; | 5 | import com.bsth.repository.BusinessRepository; |
| 9 | import com.bsth.repository.LineRepository; | 6 | import com.bsth.repository.LineRepository; |
| 10 | import com.bsth.repository.schedule.*; | 7 | import com.bsth.repository.schedule.*; |
| 11 | import com.bsth.service.schedule.SchedulePlanService; | 8 | import com.bsth.service.schedule.SchedulePlanService; |
| 12 | import com.bsth.service.schedule.exception.ScheduleException; | 9 | import com.bsth.service.schedule.exception.ScheduleException; |
| 10 | +import com.bsth.service.schedule.plan.DroolsSchedulePlan; | ||
| 13 | import com.bsth.service.schedule.rules.ScheduleRuleService; | 11 | import com.bsth.service.schedule.rules.ScheduleRuleService; |
| 14 | -import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input; | ||
| 15 | -import com.bsth.service.schedule.rules.plan.PlanResult; | ||
| 16 | -import com.bsth.service.schedule.rules.rerun.RerunRule_input; | ||
| 17 | -import com.bsth.service.schedule.rules.rerun.RerunRule_param; | ||
| 18 | -import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; | ||
| 19 | -import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; | ||
| 20 | -import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; | ||
| 21 | -import com.bsth.service.schedule.rules.ttinfo.*; | ||
| 22 | import com.bsth.service.schedule.rules.ttinfo2.CalcuParam; | 12 | import com.bsth.service.schedule.rules.ttinfo2.CalcuParam; |
| 23 | import com.bsth.service.schedule.rules.ttinfo2.Result; | 13 | import com.bsth.service.schedule.rules.ttinfo2.Result; |
| 24 | -import com.bsth.service.schedule.rules.validate.ValidateParam; | ||
| 25 | -import com.bsth.service.schedule.rules.validate.ValidateResults_output; | ||
| 26 | -import org.apache.commons.lang3.StringUtils; | ||
| 27 | import org.joda.time.DateTime; | 14 | import org.joda.time.DateTime; |
| 28 | import org.kie.api.KieBase; | 15 | import org.kie.api.KieBase; |
| 29 | import org.kie.api.runtime.KieSession; | 16 | import org.kie.api.runtime.KieSession; |
| @@ -37,6 +24,9 @@ import org.springframework.transaction.annotation.Propagation; | @@ -37,6 +24,9 @@ import org.springframework.transaction.annotation.Propagation; | ||
| 37 | import org.springframework.transaction.annotation.Transactional; | 24 | import org.springframework.transaction.annotation.Transactional; |
| 38 | 25 | ||
| 39 | import java.util.*; | 26 | import java.util.*; |
| 27 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 28 | +import java.util.concurrent.TimeUnit; | ||
| 29 | +import java.util.concurrent.locks.ReentrantLock; | ||
| 40 | 30 | ||
| 41 | /** | 31 | /** |
| 42 | * Created by xu on 16/6/16. | 32 | * Created by xu on 16/6/16. |
| @@ -44,12 +34,12 @@ import java.util.*; | @@ -44,12 +34,12 @@ import java.util.*; | ||
| 44 | @Service | 34 | @Service |
| 45 | public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> implements SchedulePlanService { | 35 | public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> implements SchedulePlanService { |
| 46 | @Autowired | 36 | @Autowired |
| 47 | - @Qualifier("kb1") | ||
| 48 | - private KieBase kieBase; | 37 | + @Qualifier("coreKBase") |
| 38 | + private KieBase coreKBase; | ||
| 49 | 39 | ||
| 50 | @Autowired | 40 | @Autowired |
| 51 | - @Qualifier("kb2") | ||
| 52 | - private KieBase kieBase2; | 41 | + @Qualifier("preKBase") |
| 42 | + private KieBase preKBase; | ||
| 53 | 43 | ||
| 54 | @Autowired | 44 | @Autowired |
| 55 | private ScheduleRule1FlatRepository scheduleRule1FlatRepository; | 45 | private ScheduleRule1FlatRepository scheduleRule1FlatRepository; |
| @@ -73,398 +63,62 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -73,398 +63,62 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 73 | /** 日志记录器 */ | 63 | /** 日志记录器 */ |
| 74 | private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class); | 64 | private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class); |
| 75 | 65 | ||
| 76 | - /** | ||
| 77 | - * 计算规则输入。 | ||
| 78 | - * @param schedulePlan | ||
| 79 | - * @return | ||
| 80 | - */ | ||
| 81 | - private List<ScheduleRule_input> calcuSrfList(SchedulePlan schedulePlan) { | ||
| 82 | - // 1-1、构造drools规则输入数据,输出数据 | ||
| 83 | - // 全局计算参数 | ||
| 84 | - ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan); | ||
| 85 | - | ||
| 86 | - // 规则输出数据 | ||
| 87 | - List<ScheduleRule_input> scheduleRule_inputs = new ArrayList<>(); | ||
| 88 | - | ||
| 89 | - // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 90 | - // 创建session,内部配置的是stateful | ||
| 91 | - KieSession session = kieBase2.newKieSession(); | ||
| 92 | - // 设置gloable对象,在drl中通过别名使用 | ||
| 93 | - session.setGlobal("sriList", scheduleRule_inputs); | ||
| 94 | - session.setGlobal("log", logger); // 设置日志 | ||
| 95 | - | ||
| 96 | - session.setGlobal("srf", scheduleRule1FlatRepository); | ||
| 97 | - session.setGlobal("rrr", rerunRuleRepository); | ||
| 98 | - session.setGlobal("srservice", scheduleRuleService); | ||
| 99 | - | ||
| 100 | - // 载入数据 | ||
| 101 | - session.insert(scheduleCalcuParam_input); | ||
| 102 | - | ||
| 103 | - // 执行rule | ||
| 104 | - session.fireAllRules(); | ||
| 105 | - | ||
| 106 | - // 执行完毕销毁,有日志的也要关闭 | ||
| 107 | - session.dispose(); | ||
| 108 | - | ||
| 109 | - return scheduleRule_inputs; | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - /** | ||
| 113 | - * 循环规则输出。 | ||
| 114 | - * @param schedulePlan 排班计划对象 | ||
| 115 | - * @param lpInfoResults_output 时刻表每日路牌的情况 | ||
| 116 | - */ | ||
| 117 | - private ScheduleResults_output loopRuleOutput( | ||
| 118 | - SchedulePlan schedulePlan, | ||
| 119 | - LpInfoResults_output lpInfoResults_output) { | ||
| 120 | - // 1-1、构造drools规则输入数据,输出数据 | ||
| 121 | - // 全局计算参数 | ||
| 122 | - ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan); | ||
| 123 | - // 每个规则对应的输入参数 | ||
| 124 | - List<ScheduleRule_input> scheduleRule_inputs = calcuSrfList(schedulePlan); | ||
| 125 | - | ||
| 126 | - // 规则输出数据 | ||
| 127 | - ScheduleResults_output scheduleResults_output = new ScheduleResults_output(); | ||
| 128 | - | ||
| 129 | - // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 130 | - // 创建session,内部配置的是stateful | ||
| 131 | - KieSession session = kieBase.newKieSession(); | ||
| 132 | - // 设置gloable对象,在drl中通过别名使用 | ||
| 133 | - session.setGlobal("scheduleResult", scheduleResults_output); | ||
| 134 | - session.setGlobal("log", logger); // 设置日志 | ||
| 135 | - session.setGlobal("scheduleRuleService", scheduleRuleService); | ||
| 136 | - | ||
| 137 | - // 载入数据 | ||
| 138 | - session.insert(scheduleCalcuParam_input); | ||
| 139 | - for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) { | ||
| 140 | - session.insert(scheduleRule_input); | ||
| 141 | - } | ||
| 142 | - // 每日时刻表路牌数据 | ||
| 143 | - for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) { | ||
| 144 | - session.insert(lpInfoResult_output); | ||
| 145 | - } | ||
| 146 | - // 执行rule | ||
| 147 | - session.fireAllRules(); | ||
| 148 | - | ||
| 149 | - // 执行完毕销毁,有日志的也要关闭 | ||
| 150 | - session.dispose(); | ||
| 151 | - | ||
| 152 | - // 保存循环规则结果数据 | ||
| 153 | - scheduleRuleService.generateRuleResult(scheduleResults_output.getSchedulePlanRuleResults()); | ||
| 154 | - | ||
| 155 | -// logger.info("循环规则输出={}", scheduleResults_output.showGuideboardDesc1()); | ||
| 156 | - | ||
| 157 | - return scheduleResults_output; | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - /** | ||
| 161 | - * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。 | ||
| 162 | - * @param schedulePlan 排班计划对象 | ||
| 163 | - * @return TTInfoResults_output, LpInfoResults_output | ||
| 164 | - */ | ||
| 165 | - private Object[] ttInfoOutput(SchedulePlan schedulePlan) { | ||
| 166 | - // 获取线路的所有未作废的时刻表 | ||
| 167 | - List<TTInfo> ttInfos = ttInfoRepository.findInCanceledByXl(schedulePlan.getXl()); | ||
| 168 | - | ||
| 169 | - // 1-1、构造drools规则输入数据,输出数据 | ||
| 170 | - // 全局计算参数 | ||
| 171 | - TTInfoCalcuParam_input ttInfoCalcuParam_input = | ||
| 172 | - new TTInfoCalcuParam_input( | ||
| 173 | - new DateTime(schedulePlan.getScheduleFromTime()), | ||
| 174 | - new DateTime(schedulePlan.getScheduleToTime()), | ||
| 175 | - String.valueOf(schedulePlan.getXl().getId()) | ||
| 176 | - ); | ||
| 177 | - // 规则输出数据 | ||
| 178 | - TTInfoResults_output ttInfoResults_output = new TTInfoResults_output(); | ||
| 179 | - LpInfoResults_output lpInfoResults_output = new LpInfoResults_output(); | ||
| 180 | - | ||
| 181 | - // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 182 | - // 创建session,内部配置的是stateful | ||
| 183 | - KieSession session = kieBase.newKieSession(); | ||
| 184 | - | ||
| 185 | - // 设置gloable对象,在drl中通过别名使用 | ||
| 186 | - session.setGlobal("results", ttInfoResults_output); | ||
| 187 | - session.setGlobal("lpInfoResults_output", lpInfoResults_output); | ||
| 188 | - session.setGlobal("log", logger); // 设置日志 | ||
| 189 | - session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository); | ||
| 190 | - | ||
| 191 | - // 载入数据 | ||
| 192 | - session.insert(ttInfoCalcuParam_input); | ||
| 193 | - for (TTInfo ttInfo : ttInfos) { | ||
| 194 | - TTInfo_input ttInfo_input = new TTInfo_input(ttInfo); | ||
| 195 | - session.insert(ttInfo_input); | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - // 载入数据2(计算规则最早启用时间) | ||
| 199 | - List<ScheduleRule1Flat> scheduleRule1Flats = scheduleRule1FlatRepository.findByXl(schedulePlan.getXl()); | ||
| 200 | - | ||
| 201 | - for (ScheduleRule1Flat scheduleRule1Flat: scheduleRule1Flats) { | ||
| 202 | - ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat); | ||
| 203 | - session.insert(scheduleRule_input); | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | - // 执行rule | ||
| 207 | - session.fireAllRules(); | ||
| 208 | - | ||
| 209 | - // 执行完毕销毁,有日志的也要关闭 | ||
| 210 | - session.dispose(); | ||
| 211 | - | ||
| 212 | - return new Object[] {ttInfoResults_output, lpInfoResults_output}; | ||
| 213 | - | ||
| 214 | - } | ||
| 215 | - | ||
| 216 | - /** | ||
| 217 | - * 排班生成。 | ||
| 218 | - * @param schedulePlan 排班计划对象 | ||
| 219 | - * @param scheduleResults_output loopRuleOutput方法规则输出 | ||
| 220 | - * @param ttInfoResults_output ttInfoOutput方法规则输出 | ||
| 221 | - * @return PlanResult | ||
| 222 | - */ | ||
| 223 | - private PlanResult planResultOutput( | ||
| 224 | - SchedulePlan schedulePlan, | ||
| 225 | - ScheduleResults_output scheduleResults_output, | ||
| 226 | - TTInfoResults_output ttInfoResults_output) { | ||
| 227 | - | ||
| 228 | - // 1-1、构造drools规则输入数据,输出数据 | ||
| 229 | - PlanCalcuParam_input planCalcuParam_input = new PlanCalcuParam_input( | ||
| 230 | - schedulePlan, | ||
| 231 | - scheduleResults_output, | ||
| 232 | - ttInfoResults_output | ||
| 233 | - ); | ||
| 234 | - // 规则输出数据 | ||
| 235 | - PlanResult planResult = new PlanResult(); | ||
| 236 | - planResult.setXlId(schedulePlan.getXl().getId().toString()); | ||
| 237 | - | ||
| 238 | - // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 239 | - // 创建session,内部配置的是stateful | ||
| 240 | - KieSession session = kieBase.newKieSession(); | ||
| 241 | - | ||
| 242 | - // 设置gloable对象,在drl中通过别名使用 | ||
| 243 | - session.setGlobal("planResult", planResult); | ||
| 244 | - session.setGlobal("log", logger); // 设置日志 | ||
| 245 | - | ||
| 246 | - session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository); | ||
| 247 | - session.setGlobal("carConfigInfoRepository", carConfigInfoRepository); | ||
| 248 | - session.setGlobal("employeeConfigInfoRepository", employeeConfigInfoRepository); | ||
| 249 | - session.setGlobal("lineRepository", lineRepository); | ||
| 250 | - session.setGlobal("businessRepository", businessRepository); | ||
| 251 | - | ||
| 252 | - // 载入数据 | ||
| 253 | - session.insert(planCalcuParam_input); | ||
| 254 | - | ||
| 255 | - // 执行rule | ||
| 256 | - session.fireAllRules(); | ||
| 257 | - | ||
| 258 | - // 执行完毕销毁,有日志的也要关闭 | ||
| 259 | - session.dispose(); | ||
| 260 | - | ||
| 261 | - return planResult; | ||
| 262 | - | ||
| 263 | - } | ||
| 264 | - | ||
| 265 | - /** | ||
| 266 | - * 生成线路排班(不含套跑规则)。 | ||
| 267 | - * @param schedulePlan | ||
| 268 | - * @return | ||
| 269 | - */ | ||
| 270 | - private PlanResult schedulePlanWithOutRerun(SchedulePlan schedulePlan) { | ||
| 271 | - // 1、时刻表数据及每日路牌数据计算 | ||
| 272 | - Date start1 = new Date(); | ||
| 273 | - Object[] ttInfoRets = ttInfoOutput(schedulePlan); | ||
| 274 | - TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0]; | ||
| 275 | - LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; | ||
| 276 | - Date end1 = new Date(); | ||
| 277 | - // 2、循环规则计算输出 | ||
| 278 | - Date start2 = new Date(); | ||
| 279 | - ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output); | ||
| 280 | - Date end2 = new Date(); | ||
| 281 | - | ||
| 282 | - logger.info("规则计算结果={}", scheduleResults_output.showGuideboardDesc1()); | ||
| 283 | - | ||
| 284 | - // 3、计划输出 | ||
| 285 | - Date start3 = new Date(); | ||
| 286 | - PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); | ||
| 287 | - Date end3 = new Date(); | ||
| 288 | - | ||
| 289 | - logger.info("drool时刻表每日路牌计算 {} ms,drool循环规则计算 {} ms,drool计划数据 {} ms", | ||
| 290 | - end1.getTime() - start1.getTime(), | ||
| 291 | - end2.getTime() - start2.getTime(), | ||
| 292 | - end3.getTime() - start3.getTime()); | ||
| 293 | - | ||
| 294 | - // TODO:将lpInfoResults_output 也要返回 | ||
| 295 | - | ||
| 296 | - return planResult; | ||
| 297 | - } | ||
| 298 | - | ||
| 299 | - /** | ||
| 300 | - * 套跑计划排班数据。 | ||
| 301 | - * @param planResult | ||
| 302 | - */ | ||
| 303 | - private void rerunPlanResult(PlanResult planResult, SchedulePlan schedulePlan) { | ||
| 304 | - List<RerunRule_input> rerunRule_inputs = scheduleRuleService.findRerunrule(Integer.parseInt(planResult.getXlId())); | ||
| 305 | - logger.info("套跑数量 {} 组", rerunRule_inputs.size()); | ||
| 306 | - | ||
| 307 | - // 主线路id | ||
| 308 | - Integer mainXlId = schedulePlan.getXl().getId(); | ||
| 309 | - | ||
| 310 | - if (rerunRule_inputs.size() > 0) { | ||
| 311 | - // 找出是对应路牌类型的线路,计算循环规则输出 | ||
| 312 | - Set<String> xlids = new HashSet<>(); | ||
| 313 | - for (RerunRule_input rerunRule_input: rerunRule_inputs) { | ||
| 314 | - if ("dylp".equals(rerunRule_input.getType())) { | ||
| 315 | - xlids.add(rerunRule_input.getS_xl()); // 参与套跑的线路 | ||
| 316 | - } | ||
| 317 | - } | ||
| 318 | - | ||
| 319 | - List<ScheduleResults_output> scheduleResults_outputs = new ArrayList<>(); | ||
| 320 | - Date start1 = new Date(); | ||
| 321 | - for (String xlid: xlids) { | ||
| 322 | - schedulePlan.getXl().setId(Integer.parseInt(xlid)); // 套跑的线路默认跟着主线路设定走 | ||
| 323 | - // 获取套跑线路的循环规则计算输出 | ||
| 324 | - Object[] ttInfoRets = ttInfoOutput(schedulePlan); | ||
| 325 | - LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; | ||
| 326 | - ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output); | ||
| 327 | - scheduleResults_outputs.add(scheduleResults_output); | ||
| 328 | - } | ||
| 329 | - | ||
| 330 | - // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 331 | - // 创建session,内部配置的是stateful | ||
| 332 | - KieSession session = kieBase.newKieSession(); | ||
| 333 | - | ||
| 334 | - // 设置gloable对象,在drl中通过别名使用 | ||
| 335 | - session.setGlobal("planResult", planResult); | ||
| 336 | - session.setGlobal("log", logger); // 设置日志 | ||
| 337 | - | ||
| 338 | - session.setGlobal("carConfigInfoRepository", carConfigInfoRepository); | ||
| 339 | - session.setGlobal("employeeConfigInfoRepository", employeeConfigInfoRepository); | ||
| 340 | - | ||
| 341 | - // 载入数据 | ||
| 342 | - RerunRule_param rerunRule_param = new RerunRule_param(); | ||
| 343 | - rerunRule_param.setMxlid(planResult.getXlId()); | ||
| 344 | - rerunRule_param.setXlIds_dylp(xlids); | ||
| 345 | - session.insert(rerunRule_param); | ||
| 346 | - for (RerunRule_input rri: rerunRule_inputs) { | ||
| 347 | - session.insert(rri); | ||
| 348 | - } | ||
| 349 | - for (SchedulePlanInfo spi: planResult.getSchedulePlanInfos()) { | ||
| 350 | - session.insert(spi); | 66 | + /** 线路独占锁 */ |
| 67 | + private ConcurrentHashMap<Integer, ReentrantLock> lineXLatchMaps = new ConcurrentHashMap<>(); | ||
| 68 | + private ReentrantLock getLineXLatch(Integer xlid) { | ||
| 69 | + ReentrantLock lineXLatch = lineXLatchMaps.get(xlid); | ||
| 70 | + if (lineXLatch == null) { | ||
| 71 | + lineXLatch = new ReentrantLock(); | ||
| 72 | + ReentrantLock pre = lineXLatchMaps.putIfAbsent(xlid, lineXLatch); | ||
| 73 | + if (pre != null) { | ||
| 74 | + lineXLatch = pre; | ||
| 351 | } | 75 | } |
| 352 | - for (ScheduleResults_output sro: scheduleResults_outputs) { | ||
| 353 | - session.insert(sro); | ||
| 354 | - } | ||
| 355 | - | ||
| 356 | - // 执行rule | ||
| 357 | - session.fireAllRules(); | ||
| 358 | - | ||
| 359 | - // 执行完毕销毁,有日志的也要关闭 | ||
| 360 | - session.dispose(); | ||
| 361 | - | ||
| 362 | - Date end1 = new Date(); | ||
| 363 | - logger.info("套跑规则计算,耗时 {} ms", end1.getTime() - start1.getTime()); | ||
| 364 | - | ||
| 365 | - schedulePlan.getXl().setId(mainXlId); | ||
| 366 | - | ||
| 367 | - } | ||
| 368 | - | ||
| 369 | - } | ||
| 370 | - | ||
| 371 | - /** | ||
| 372 | - * 验证排班结果。 | ||
| 373 | - * @param planResult | ||
| 374 | - * @param schedulePlan | ||
| 375 | - */ | ||
| 376 | - public void validPlanResult(PlanResult planResult, SchedulePlan schedulePlan) { | ||
| 377 | - // 1-1、构造drools规则输入数据,输出数据 | ||
| 378 | - ValidateParam validateParam = new ValidateParam( | ||
| 379 | - new DateTime(schedulePlan.getScheduleFromTime()), | ||
| 380 | - new DateTime(schedulePlan.getScheduleToTime()) | ||
| 381 | - ); | ||
| 382 | - // 规则输出数据 | ||
| 383 | - ValidateResults_output result = new ValidateResults_output(); | ||
| 384 | - | ||
| 385 | - // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 386 | - // 创建session,内部配置的是stateful | ||
| 387 | - KieSession session = kieBase.newKieSession(); | ||
| 388 | - | ||
| 389 | - // 设置gloable对象,在drl中通过别名使用 | ||
| 390 | - session.setGlobal("validResult", result); | ||
| 391 | - session.setGlobal("log", logger); // 设置日志 | ||
| 392 | - | ||
| 393 | - // 载入数据 | ||
| 394 | - session.insert(validateParam); | ||
| 395 | - for (SchedulePlanInfo schedulePlanInfo: planResult.getSchedulePlanInfos()) { | ||
| 396 | - session.insert(schedulePlanInfo); | ||
| 397 | - } | ||
| 398 | - | ||
| 399 | - // 执行rule | ||
| 400 | - session.fireAllRules(); | ||
| 401 | - | ||
| 402 | - // 执行完毕销毁,有日志的也要关闭 | ||
| 403 | - session.dispose(); | ||
| 404 | - | ||
| 405 | -// logger.info("错误总数={}", result.getInfos().size()); | ||
| 406 | -// for (ValidateResults_output.ValidInfo validInfo: result.getInfos()) { | ||
| 407 | -// logger.info(validInfo.getDesc()); | ||
| 408 | -// } | ||
| 409 | - | ||
| 410 | - // 取10条错误 | ||
| 411 | - int size = result.getInfos().size() > 10 ? 10: result.getInfos().size(); | ||
| 412 | - List<String> desclist = new ArrayList<>(); | ||
| 413 | - for (int i = 0; i < size; i++) { | ||
| 414 | - desclist.add(result.getInfos().get(i).getDesc()); | ||
| 415 | - } | ||
| 416 | - if (desclist.size() > 0) { | ||
| 417 | - schedulePlan.setPlanResult(StringUtils.join(desclist, "</br>")); | ||
| 418 | - } else { | ||
| 419 | - schedulePlan.setPlanResult("ok"); | ||
| 420 | } | 76 | } |
| 421 | - | ||
| 422 | - // TODO:设定错误信息 | 77 | + return lineXLatch; |
| 423 | } | 78 | } |
| 424 | 79 | ||
| 425 | @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | 80 | @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) |
| 426 | public SchedulePlan save(SchedulePlan schedulePlan) { | 81 | public SchedulePlan save(SchedulePlan schedulePlan) { |
| 427 | - // pre、如果排班的数据之前已经有了,删除之前的数据 | ||
| 428 | - Date startpre = new Date(); | ||
| 429 | - scheduleRuleService.deleteSchedulePlanInfo( | ||
| 430 | - schedulePlan.getXl().getLineCode(), | ||
| 431 | - schedulePlan.getScheduleFromTime(), | ||
| 432 | - schedulePlan.getScheduleToTime()); | ||
| 433 | - Date endpre = new Date(); | ||
| 434 | - | ||
| 435 | - // 1、查找线路,这是主线路 | ||
| 436 | - Line xl = lineRepository.findOne(schedulePlan.getXl().getId()); | ||
| 437 | - logger.info("<--- 排班master线路 id={}, name={}, 开始排班", xl.getId(), xl.getName()); | ||
| 438 | - | ||
| 439 | - // 2、确定主线路排班(包含完全套跑路牌规则,所谓完全套跑路牌规则指整个路牌的班次都是套跑规则指定的) | ||
| 440 | - PlanResult planResult = schedulePlanWithOutRerun(schedulePlan); | ||
| 441 | - | ||
| 442 | - // 3、确定套跑规则 | ||
| 443 | - rerunPlanResult(planResult, schedulePlan); | ||
| 444 | - | ||
| 445 | - // TODO:3-1、验证排班结果 | ||
| 446 | - validPlanResult(planResult, schedulePlan); | 82 | + ReentrantLock lineXLatch = getLineXLatch(schedulePlan.getXl().getId()); |
| 83 | + try { | ||
| 84 | + if (lineXLatch.tryLock(1, TimeUnit.SECONDS)) { | ||
| 85 | + // pre、如果排班的数据之前已经有了,删除之前的数据 | ||
| 86 | + Date startPre = new Date(); | ||
| 87 | + scheduleRuleService.deleteSchedulePlanInfo( | ||
| 88 | + schedulePlan.getXl().getLineCode(), | ||
| 89 | + schedulePlan.getScheduleFromTime(), | ||
| 90 | + schedulePlan.getScheduleToTime()); | ||
| 91 | + Date endPre = new Date(); | ||
| 92 | + logger.info("删除数据 {} ms --->", endPre.getTime() - startPre.getTime()); | ||
| 93 | + | ||
| 94 | + // core、生成排班计划 | ||
| 95 | + DroolsSchedulePlan droolsSchedulePlan = new DroolsSchedulePlan( | ||
| 96 | + schedulePlan, | ||
| 97 | + lineRepository, scheduleRule1FlatRepository, | ||
| 98 | + ttInfoRepository, ttInfoDetailRepository, | ||
| 99 | + carConfigInfoRepository, employeeConfigInfoRepository, | ||
| 100 | + rerunRuleRepository, businessRepository, | ||
| 101 | + scheduleRuleService, | ||
| 102 | + preKBase, coreKBase, | ||
| 103 | + logger | ||
| 104 | + ); | ||
| 105 | + droolsSchedulePlan.generatePlan(); | ||
| 447 | 106 | ||
| 448 | - // TODO:3-2、去除完全套跑遗漏班次(以后放到规则中执行) | ||
| 449 | - Iterator<SchedulePlanInfo> infoIterator = planResult.getSchedulePlanInfos().iterator(); | ||
| 450 | - while (infoIterator.hasNext()) { | ||
| 451 | - SchedulePlanInfo schedulePlanInfo = infoIterator.next(); | ||
| 452 | - if (schedulePlanInfo.getCl() == null) { | ||
| 453 | - infoIterator.remove(); | 107 | + return new SchedulePlan(); |
| 108 | + } else { | ||
| 109 | + throw new ScheduleException("当前线路正在排班,请稍后再操作..."); | ||
| 454 | } | 110 | } |
| 455 | - } | 111 | + } catch (Exception exp) { |
| 112 | + throw new RuntimeException(exp); | ||
| 113 | + } finally { | ||
| 114 | + try { | ||
| 115 | + lineXLatch.unlock(); | ||
| 116 | + } catch (Exception exp2) { | ||
| 456 | 117 | ||
| 457 | - // 4、保存数据(jdbcTemplate 批量插入) | ||
| 458 | - Date start4 = new Date(); | ||
| 459 | - scheduleRuleService.generateSchedulePlan(schedulePlan, planResult.getSchedulePlanInfos()); | ||
| 460 | - Date end4 = new Date(); | 118 | + } |
| 461 | 119 | ||
| 462 | - logger.info("删除数据 {} ms,保存主线路数据 {} 条 耗时 {} ms --->", | ||
| 463 | - endpre.getTime() - startpre.getTime(), | ||
| 464 | - planResult.getSchedulePlanInfos().size(), | ||
| 465 | - end4.getTime() - start4.getTime()); | 120 | + } |
| 466 | 121 | ||
| 467 | - return new SchedulePlan(); | ||
| 468 | } | 122 | } |
| 469 | 123 | ||
| 470 | @Override | 124 | @Override |
| @@ -475,10 +129,12 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -475,10 +129,12 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 475 | @Override | 129 | @Override |
| 476 | public SchedulePlan findSchedulePlanTommorw() { | 130 | public SchedulePlan findSchedulePlanTommorw() { |
| 477 | DateTime today = new DateTime(new Date()); | 131 | DateTime today = new DateTime(new Date()); |
| 478 | - DateTime tommorw = new DateTime(today.getYear(), today.getMonthOfYear(), today.getDayOfMonth(), 0, 0).plusDays(1); | 132 | + DateTime tommorw = new DateTime( |
| 133 | + today.getYear(), today.getMonthOfYear(), | ||
| 134 | + today.getDayOfMonth(), 0, 0).plusDays(1); | ||
| 479 | Map<String, Object> param = new HashMap<>(); | 135 | Map<String, Object> param = new HashMap<>(); |
| 480 | param.put("scheduleFromTime_le", tommorw.toDate()); | 136 | param.put("scheduleFromTime_le", tommorw.toDate()); |
| 481 | - param.put("scheduleToTime_ge", tommorw.toDate() ); | 137 | + param.put("scheduleToTime_ge", tommorw.toDate()); |
| 482 | Iterator<SchedulePlan> schedulePlanIterator = this.list(param).iterator(); | 138 | Iterator<SchedulePlan> schedulePlanIterator = this.list(param).iterator(); |
| 483 | if (schedulePlanIterator.hasNext()) { | 139 | if (schedulePlanIterator.hasNext()) { |
| 484 | return schedulePlanIterator.next(); | 140 | return schedulePlanIterator.next(); |
| @@ -490,7 +146,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -490,7 +146,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 490 | public Result validateTTInfo(Integer xlid, Date from, Date to) { | 146 | public Result validateTTInfo(Integer xlid, Date from, Date to) { |
| 491 | // 构造drools session->载入数据->启动规则->计算->销毁session | 147 | // 构造drools session->载入数据->启动规则->计算->销毁session |
| 492 | // 创建session,内部配置的是stateful | 148 | // 创建session,内部配置的是stateful |
| 493 | - KieSession session = kieBase.newKieSession(); | 149 | + KieSession session = coreKBase.newKieSession(); |
| 494 | // 设置gloable对象,在drl中通过别名使用 | 150 | // 设置gloable对象,在drl中通过别名使用 |
| 495 | session.setGlobal("log", logger); | 151 | session.setGlobal("log", logger); |
| 496 | session.setGlobal("lineRepository", lineRepository); | 152 | session.setGlobal("lineRepository", lineRepository); |
| @@ -513,7 +169,6 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -513,7 +169,6 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 513 | // 执行完毕销毁,有日志的也要关闭 | 169 | // 执行完毕销毁,有日志的也要关闭 |
| 514 | session.dispose(); | 170 | session.dispose(); |
| 515 | 171 | ||
| 516 | - | ||
| 517 | return rs; | 172 | return rs; |
| 518 | } | 173 | } |
| 519 | } | 174 | } |
src/main/java/com/bsth/service/schedule/impl/TTInfoDetailServiceImpl.java
| @@ -15,12 +15,15 @@ import com.bsth.repository.schedule.TTInfoRepository; | @@ -15,12 +15,15 @@ import com.bsth.repository.schedule.TTInfoRepository; | ||
| 15 | import com.bsth.repository.sys.SysUserRepository; | 15 | import com.bsth.repository.sys.SysUserRepository; |
| 16 | import com.bsth.service.CarParkService; | 16 | import com.bsth.service.CarParkService; |
| 17 | import com.bsth.service.LineInformationService; | 17 | import com.bsth.service.LineInformationService; |
| 18 | +import com.bsth.service.LineService; | ||
| 18 | import com.bsth.service.StationRouteService; | 19 | import com.bsth.service.StationRouteService; |
| 19 | import com.bsth.service.schedule.GuideboardInfoService; | 20 | import com.bsth.service.schedule.GuideboardInfoService; |
| 20 | import com.bsth.service.schedule.TTInfoDetailService; | 21 | import com.bsth.service.schedule.TTInfoDetailService; |
| 21 | import com.bsth.service.schedule.datatools.TTInfoDetailForEdit; | 22 | import com.bsth.service.schedule.datatools.TTInfoDetailForEdit; |
| 22 | import com.bsth.service.schedule.datatools.TTinfoDetailDynamicData; | 23 | import com.bsth.service.schedule.datatools.TTinfoDetailDynamicData; |
| 23 | import com.bsth.service.schedule.exception.ScheduleException; | 24 | import com.bsth.service.schedule.exception.ScheduleException; |
| 25 | +import com.bsth.service.schedule.timetable.ExcelData; | ||
| 26 | +import com.bsth.service.schedule.timetable.ExcelFormatType; | ||
| 24 | import com.bsth.service.schedule.utils.DataToolsFile; | 27 | import com.bsth.service.schedule.utils.DataToolsFile; |
| 25 | import com.bsth.service.schedule.utils.DataToolsFileType; | 28 | import com.bsth.service.schedule.utils.DataToolsFileType; |
| 26 | import com.bsth.service.schedule.utils.DataToolsService; | 29 | import com.bsth.service.schedule.utils.DataToolsService; |
| @@ -77,6 +80,8 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | @@ -77,6 +80,8 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | ||
| 77 | private SysUserRepository sysUserRepository; | 80 | private SysUserRepository sysUserRepository; |
| 78 | @Autowired | 81 | @Autowired |
| 79 | private GuideboardInfoRepository guideboardInfoRepository; | 82 | private GuideboardInfoRepository guideboardInfoRepository; |
| 83 | + @Autowired | ||
| 84 | + private LineService lineService; | ||
| 80 | 85 | ||
| 81 | @Autowired | 86 | @Autowired |
| 82 | @Qualifier(value = "ttInfoDetail_dataTool") | 87 | @Qualifier(value = "ttInfoDetail_dataTool") |
| @@ -155,130 +160,13 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | @@ -155,130 +160,13 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | ||
| 155 | } | 160 | } |
| 156 | 161 | ||
| 157 | @Override | 162 | @Override |
| 158 | - public void validateExcelSheet(String filename, String sheetname, Integer lineid, String linename, Integer lineversion) throws ScheduleException { | ||
| 159 | - try { | ||
| 160 | - File file = new File(filename); | ||
| 161 | - Workbook workbook; | ||
| 162 | - | ||
| 163 | - if (DataToolsFileType.XLS.isThisType(file)) { | ||
| 164 | - workbook = DataToolsFileType.XLS.getWorkBook(file); | ||
| 165 | - } else if (DataToolsFileType.XLSX.isThisType(file)) { | ||
| 166 | - workbook = DataToolsFileType.XLSX.getWorkBook(file); | ||
| 167 | - } else { | ||
| 168 | - throw new Exception("不是xls xlsx文件!"); | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - Sheet sheet = workbook.getSheet(sheetname); | ||
| 172 | - int rowNums = sheet.getLastRowNum() + 1; // 基于0 base的,长度加1 | ||
| 173 | - int colNums = sheet.getRow(0).getLastCellNum(); // 不需要加1,就是长度 | ||
| 174 | - | ||
| 175 | - if (rowNums == 0 || colNums == 0) { // 工作区是否为空 | ||
| 176 | - throw new Exception(String.format("%s 工作区没有数据!", sheetname)); | ||
| 177 | - } else { | ||
| 178 | - if (rowNums <= 1 || rowNums <= 1) { | ||
| 179 | - throw new Exception(String.format("工作区至少包含2行2列的数据")); | ||
| 180 | - } else { | ||
| 181 | - Row firstRow = sheet.getRow(0); // 获取第一行数据列 | ||
| 182 | - for (int i = 0; i < colNums; i++) { | ||
| 183 | - String cell_con = StringUtils.trimToEmpty(PoiUtils.getStringValueFromCell(firstRow.getCell(i))); // trimToEmpty | ||
| 184 | - | ||
| 185 | - if (StringUtils.isEmpty(cell_con)) { | ||
| 186 | - throw new Exception(String.format("第1行,第%d列数据不能为空", i + 1)); | ||
| 187 | - } else { | ||
| 188 | - // 正则表达式去除右侧数字 | ||
| 189 | -// cell_con = cell_con.replaceAll("[\\d+]", ""); | ||
| 190 | -// cell_con = cell_con.replaceAll("(\\d+)$", ""); | ||
| 191 | - | ||
| 192 | - // 如果站名中有类似->{数字},使用正则表达式过滤掉 | ||
| 193 | - cell_con = cell_con.replaceAll("(->\\d+)", ""); | ||
| 194 | - | ||
| 195 | - if (i == 0) { // 第一列必须是路牌2个字 | ||
| 196 | - if (!"路牌".equals(cell_con.trim())) { | ||
| 197 | - throw new Exception("第1行,第1列数据必须是路牌2个字"); | ||
| 198 | - } | ||
| 199 | - } else { // 排除出场,进场,其余内容到站点路由里查询,以各个方向的起点站为查询依据 | ||
| 200 | - if ((!"出场".equals(cell_con.trim())) && | ||
| 201 | - (!"进场".equals(cell_con.trim()))) { | ||
| 202 | - Map<String, Object> p1 = new HashMap<>(); | ||
| 203 | - p1.put("line.id_eq", lineid); | ||
| 204 | - p1.put("stationName_eq", cell_con.trim()); | ||
| 205 | - p1.put("stationMark_eq", "B"); // 起点站 | ||
| 206 | - p1.put("destroy_eq", 0); // 未撤销 | ||
| 207 | - p1.put("versions_eq", lineversion); // 带线路版本 | ||
| 208 | - | ||
| 209 | - List<LsStationRoute> lsStationRoutes = (List<LsStationRoute>) stationRouteService.list_ls(p1); | ||
| 210 | - if (CollectionUtils.isEmpty(lsStationRoutes)) { | ||
| 211 | - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中不是起点站", i + 1, cell_con.trim(), linename)); | ||
| 212 | - } else if (lsStationRoutes.size() > 1) { | ||
| 213 | - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中上下行都是起点站", i + 1, cell_con.trim(), linename)); | ||
| 214 | - } else if (StringUtils.isEmpty(lsStationRoutes.get(0).getStationCode())) { | ||
| 215 | - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中没有站点编码", i + 1, cell_con.trim(), linename)); | ||
| 216 | - } | ||
| 217 | - | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - } | ||
| 221 | - } | ||
| 222 | - } | ||
| 223 | - | ||
| 224 | - // 验证路牌内容 | ||
| 225 | - Map<String, Integer> gbindexmap = new HashMap<>(); // 记录每个路牌在第几行 | ||
| 226 | - for (int i = 1; i < rowNums; i++) { // 从第2行开始验证数据 | ||
| 227 | - Cell cell = sheet.getRow(i).getCell(0); // 获取第1列 | ||
| 228 | - String bcell_con = StringUtils.trimToEmpty(PoiUtils.getStringValueFromCell(cell)); // trimToEmpty | ||
| 229 | - if (StringUtils.isEmpty(bcell_con)) { | ||
| 230 | - throw new Exception(String.format("第%d行,第1列路牌无数据", i + 1)); | ||
| 231 | - } else if (gbindexmap.get(bcell_con.trim()) != null) { | ||
| 232 | - throw new Exception(String.format("第%d行,第1列的路牌数据与第%d行,第1列数据重复", | ||
| 233 | - i + 1, | ||
| 234 | - gbindexmap.get(bcell_con.trim()))); | ||
| 235 | - } else { | ||
| 236 | - Map<String, Object> p2 = new HashMap<>(); | ||
| 237 | - p2.put("xl.id_eq", lineid); | ||
| 238 | - p2.put("lpName_eq", bcell_con.trim()); | ||
| 239 | - p2.put("isCancel_eq", false); | ||
| 240 | - List<GuideboardInfo> guideboardInfoList = (List<GuideboardInfo>) guideboardInfoService.list(p2); | ||
| 241 | - if (CollectionUtils.isEmpty(guideboardInfoList)) { | ||
| 242 | - throw new Exception(String.format("第%d行,第1列的路牌在%s中不存在", i + 1, linename)); | ||
| 243 | - } else if (guideboardInfoList.size() > 1) { | ||
| 244 | - throw new Exception(String.format("第%d行,第1列的路牌在%s中重复", i + 1, linename)); | ||
| 245 | - } else { | ||
| 246 | - gbindexmap.put(bcell_con.trim(), i + 1); | ||
| 247 | - } | ||
| 248 | - } | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | - // 班次时间验证,正则表达式,格式hh:mm或者hhmm | ||
| 252 | - String rex1 = "^([01]?[0-9]|2[0-3]):[0-5][0-9]$"; // hh:mm格式 | ||
| 253 | - String rex2 = "^([01]?[0-9]|2[0-3]),[0-5][0-9]$"; // hh,mm格式 | ||
| 254 | - String rex3 = "^([01]?[0-9]|2[0-3])[0-5][0-9]$"; // hhmm格式 | ||
| 255 | - Pattern p1 = Pattern.compile(rex1); | ||
| 256 | - Pattern p2 = Pattern.compile(rex2); | ||
| 257 | - Pattern p3 = Pattern.compile(rex3); | ||
| 258 | - | ||
| 259 | - for (int i = 1; i < rowNums; i++) { // 从第2行开始验证数据 | ||
| 260 | - Row row = sheet.getRow(i); | ||
| 261 | - for (int j = 1; j < colNums; j++) { // 从第2列开始 | ||
| 262 | - String bcell_con = StringUtils.trimToEmpty(PoiUtils.getStringValueFromCell(row.getCell(j))).replaceAll("\\s*", ""); // trimToEmpty | ||
| 263 | - if (StringUtils.isNotEmpty(bcell_con)) { | ||
| 264 | - Matcher m1 = p1.matcher(bcell_con.trim()); | ||
| 265 | - Matcher m2 = p2.matcher(bcell_con.trim()); | ||
| 266 | - Matcher m3 = p3.matcher(bcell_con.trim()); | ||
| 267 | - if ((!m1.matches()) && (!m2.matches()) && (!m3.matches())) { | ||
| 268 | - throw new Exception(String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hh,mm或hhmm", i + 1, j + 1)); | ||
| 269 | - } | ||
| 270 | - } | ||
| 271 | - } | ||
| 272 | - } | ||
| 273 | - } | ||
| 274 | - | ||
| 275 | - } | ||
| 276 | - | ||
| 277 | - } catch (Exception exp) { | ||
| 278 | - exp.printStackTrace(); | ||
| 279 | - throw new ScheduleException(exp.getMessage()); | ||
| 280 | - } | ||
| 281 | - | 163 | + public void validateExcelSheet(String filename, String sheetname, Integer lineid, String linename, Integer lineversion, ExcelFormatType excelFormatType) throws ScheduleException { |
| 164 | + ExcelData excelData = new ExcelData( | ||
| 165 | + filename, sheetname, lineid, | ||
| 166 | + lineService, guideboardInfoService, | ||
| 167 | + lineversion, stationRouteService, | ||
| 168 | + excelFormatType); | ||
| 169 | + excelData.validateExcelSheet(); | ||
| 282 | } | 170 | } |
| 283 | 171 | ||
| 284 | @Override | 172 | @Override |
src/main/java/com/bsth/service/schedule/plan/DroolsSchedulePlan.java
0 → 100644
| 1 | +package com.bsth.service.schedule.plan; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.Line; | ||
| 4 | +import com.bsth.entity.schedule.SchedulePlan; | ||
| 5 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 6 | +import com.bsth.entity.schedule.TTInfo; | ||
| 7 | +import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | ||
| 8 | +import com.bsth.repository.BusinessRepository; | ||
| 9 | +import com.bsth.repository.LineRepository; | ||
| 10 | +import com.bsth.repository.schedule.*; | ||
| 11 | +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.PlanResult; | ||
| 14 | +import com.bsth.service.schedule.rules.rerun.RerunRule_input; | ||
| 15 | +import com.bsth.service.schedule.rules.rerun.RerunRule_param; | ||
| 16 | +import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; | ||
| 17 | +import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; | ||
| 18 | +import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; | ||
| 19 | +import com.bsth.service.schedule.rules.ttinfo.*; | ||
| 20 | +import com.bsth.service.schedule.rules.validate.ValidateParam; | ||
| 21 | +import com.bsth.service.schedule.rules.validate.ValidateResults_output; | ||
| 22 | +import org.apache.commons.lang3.StringUtils; | ||
| 23 | +import org.joda.time.DateTime; | ||
| 24 | +import org.kie.api.KieBase; | ||
| 25 | +import org.kie.api.runtime.KieSession; | ||
| 26 | +import org.slf4j.Logger; | ||
| 27 | + | ||
| 28 | +import java.util.*; | ||
| 29 | + | ||
| 30 | +/** | ||
| 31 | + * 排班计划(使用Drools)。 | ||
| 32 | + */ | ||
| 33 | +public class DroolsSchedulePlan { | ||
| 34 | + /** 主线路 */ | ||
| 35 | + private Line mainLine; | ||
| 36 | + /** 套跑辅线路规则 */ | ||
| 37 | + private List<RerunRule_input> rerunRule_inputs; | ||
| 38 | + | ||
| 39 | + /** 开始排班时间 */ | ||
| 40 | + private Date from; | ||
| 41 | + /** 结束排班时间 */ | ||
| 42 | + private Date to; | ||
| 43 | + /** 排班计划entity */ | ||
| 44 | + private SchedulePlan schedulePlan; | ||
| 45 | + | ||
| 46 | + //-------------------- 相关的Repo,service服务 --------------------// | ||
| 47 | + /** 线路Repo */ | ||
| 48 | + private LineRepository lineRepository; | ||
| 49 | + /** 排班规则Repo */ | ||
| 50 | + private ScheduleRule1FlatRepository scheduleRule1FlatRepository; | ||
| 51 | + /** 时刻表Repo */ | ||
| 52 | + private TTInfoRepository ttInfoRepository; | ||
| 53 | + /** 时刻表明细Repo */ | ||
| 54 | + private TTInfoDetailRepository ttInfoDetailRepository; | ||
| 55 | + /** 车辆配置Repo */ | ||
| 56 | + private CarConfigInfoRepository carConfigInfoRepository; | ||
| 57 | + /** 人员配置Repo */ | ||
| 58 | + private EmployeeConfigInfoRepository employeeConfigInfoRepository; | ||
| 59 | + /** 套跑规则Repo */ | ||
| 60 | + private RerunRuleRepository rerunRuleRepository; | ||
| 61 | + /** 营运状态Repo */ | ||
| 62 | + private BusinessRepository businessRepository; | ||
| 63 | + | ||
| 64 | + /** 排班规则service */ | ||
| 65 | + private ScheduleRuleService scheduleRuleService; | ||
| 66 | + | ||
| 67 | + //-------------------- Drools KBase实例 ------------------// | ||
| 68 | + /** 排班预处理KBase */ | ||
| 69 | + private KieBase preKBase; | ||
| 70 | + /** 排班核心KBase */ | ||
| 71 | + private KieBase coreKBase; | ||
| 72 | + | ||
| 73 | + //-------------------- 日志记录器 ---------------------// | ||
| 74 | + private Logger logger; | ||
| 75 | + | ||
| 76 | + public DroolsSchedulePlan( | ||
| 77 | + SchedulePlan schedulePlan, | ||
| 78 | + LineRepository lineRepository, ScheduleRule1FlatRepository scheduleRule1FlatRepository, | ||
| 79 | + TTInfoRepository ttInfoRepository, TTInfoDetailRepository ttInfoDetailRepository, | ||
| 80 | + CarConfigInfoRepository carConfigInfoRepository, | ||
| 81 | + EmployeeConfigInfoRepository employeeConfigInfoRepository, | ||
| 82 | + RerunRuleRepository rerunRuleRepository, | ||
| 83 | + BusinessRepository businessRepository, | ||
| 84 | + ScheduleRuleService scheduleRuleService, | ||
| 85 | + KieBase preKBase, KieBase coreKBase, | ||
| 86 | + Logger logger) { | ||
| 87 | + | ||
| 88 | + // 验证SchedulePlan实体 | ||
| 89 | + if (schedulePlan == null) { | ||
| 90 | + throw new RuntimeException("排班用SchedulePlan为空!"); | ||
| 91 | + } | ||
| 92 | + if (schedulePlan.getXl() == null) { | ||
| 93 | + throw new RuntimeException("排班线路为空!"); | ||
| 94 | + } else { | ||
| 95 | + // 获取主线路 | ||
| 96 | + this.mainLine = lineRepository.findOne(schedulePlan.getXl().getId()); | ||
| 97 | + if (this.mainLine == null) { | ||
| 98 | + throw new RuntimeException("线路id=" + schedulePlan.getXl().getId() + "不存在!"); | ||
| 99 | + } | ||
| 100 | + // 获取主线路套跑信息 | ||
| 101 | + this.rerunRule_inputs = scheduleRuleService.findRerunrule(this.mainLine.getId()); | ||
| 102 | + } | ||
| 103 | + if (schedulePlan.getScheduleFromTime() == null) { | ||
| 104 | + throw new RuntimeException("排班开始时间为空!"); | ||
| 105 | + } | ||
| 106 | + if (schedulePlan.getScheduleToTime() == null) { | ||
| 107 | + throw new RuntimeException("排班结束时间为空!"); | ||
| 108 | + } | ||
| 109 | + this.from = schedulePlan.getScheduleFromTime(); | ||
| 110 | + this.to = schedulePlan.getScheduleToTime(); | ||
| 111 | + if (schedulePlan.getTtInfoIds() == null) { | ||
| 112 | + throw new RuntimeException("排班关联的时刻表ids为空!"); | ||
| 113 | + } | ||
| 114 | + if (schedulePlan.getTtInfoNames() == null) { | ||
| 115 | + throw new RuntimeException("排班关联的时刻表名字s为空!"); | ||
| 116 | + } | ||
| 117 | + this.schedulePlan = schedulePlan; | ||
| 118 | + | ||
| 119 | + this.lineRepository = lineRepository; | ||
| 120 | + this.scheduleRule1FlatRepository = scheduleRule1FlatRepository; | ||
| 121 | + this.ttInfoRepository = ttInfoRepository; | ||
| 122 | + this.ttInfoDetailRepository = ttInfoDetailRepository; | ||
| 123 | + this.carConfigInfoRepository = carConfigInfoRepository; | ||
| 124 | + this.employeeConfigInfoRepository = employeeConfigInfoRepository; | ||
| 125 | + this.rerunRuleRepository = rerunRuleRepository; | ||
| 126 | + this.businessRepository = businessRepository; | ||
| 127 | + this.scheduleRuleService = scheduleRuleService; | ||
| 128 | + this.preKBase = preKBase; | ||
| 129 | + this.coreKBase = coreKBase; | ||
| 130 | + | ||
| 131 | + this.logger = logger; | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public void generatePlan() { | ||
| 136 | + logger.info("<--- 排班master线路 id={}, name={}, 开始排班", | ||
| 137 | + this.mainLine.getId(), this.mainLine.getName()); | ||
| 138 | + | ||
| 139 | + // 1、确定主线路排班(包含完全套跑路牌规则,所谓完全套跑路牌规则指整个路牌的班次都是套跑规则指定的) | ||
| 140 | + PlanResult planResult = this.schedulePlanWithOutRerun(); | ||
| 141 | + | ||
| 142 | + // 2、确定套跑规则 | ||
| 143 | + this.rerunPlanResult(planResult); | ||
| 144 | + | ||
| 145 | + // TODO:3-1、验证排班结果 | ||
| 146 | + this.validPlanResult(planResult); | ||
| 147 | + | ||
| 148 | + // TODO:3-2、去除完全套跑遗漏班次(以后放到规则中执行) | ||
| 149 | + Iterator<SchedulePlanInfo> infoIterator = planResult.getSchedulePlanInfos().iterator(); | ||
| 150 | + while (infoIterator.hasNext()) { | ||
| 151 | + SchedulePlanInfo schedulePlanInfo = infoIterator.next(); | ||
| 152 | + if (schedulePlanInfo.getCl() == null) { | ||
| 153 | + infoIterator.remove(); | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + // 4、保存数据(jdbcTemplate 批量插入) | ||
| 158 | + Date start4 = new Date(); | ||
| 159 | + this.scheduleRuleService.generateSchedulePlan( | ||
| 160 | + this.schedulePlan, planResult.getSchedulePlanInfos()); | ||
| 161 | + Date end4 = new Date(); | ||
| 162 | + | ||
| 163 | + this.logger.info("保存主线路数据 {} 条 耗时 {} ms --->", | ||
| 164 | + planResult.getSchedulePlanInfos().size(), | ||
| 165 | + end4.getTime() - start4.getTime()); | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + /** | ||
| 169 | + * 计算规则输入。 | ||
| 170 | + * @return | ||
| 171 | + */ | ||
| 172 | + private List<ScheduleRule_input> calcuSrfList(Line line) { | ||
| 173 | + // 1-1、构造drools规则输入数据,输出数据 | ||
| 174 | + // 全局计算参数 | ||
| 175 | + SchedulePlan schedulePlan = new SchedulePlan(); | ||
| 176 | + schedulePlan.setXl(line); | ||
| 177 | + schedulePlan.setScheduleFromTime(this.from); | ||
| 178 | + schedulePlan.setScheduleToTime(this.to); | ||
| 179 | + ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan); | ||
| 180 | + | ||
| 181 | + // 规则输出数据 | ||
| 182 | + List<ScheduleRule_input> scheduleRule_inputs = new ArrayList<>(); | ||
| 183 | + | ||
| 184 | + // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 185 | + // 创建session,内部配置的是stateful | ||
| 186 | + KieSession session = preKBase.newKieSession(); | ||
| 187 | + // 设置gloable对象,在drl中通过别名使用 | ||
| 188 | + session.setGlobal("sriList", scheduleRule_inputs); | ||
| 189 | + session.setGlobal("log", logger); // 设置日志 | ||
| 190 | + | ||
| 191 | + session.setGlobal("srf", scheduleRule1FlatRepository); | ||
| 192 | + session.setGlobal("rrr", rerunRuleRepository); | ||
| 193 | + session.setGlobal("srservice", scheduleRuleService); | ||
| 194 | + | ||
| 195 | + // 载入数据 | ||
| 196 | + session.insert(scheduleCalcuParam_input); | ||
| 197 | + | ||
| 198 | + // 执行rule | ||
| 199 | + session.fireAllRules(); | ||
| 200 | + | ||
| 201 | + // 执行完毕销毁,有日志的也要关闭 | ||
| 202 | + session.dispose(); | ||
| 203 | + | ||
| 204 | + return scheduleRule_inputs; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + /** | ||
| 208 | + * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。 | ||
| 209 | + * @return [TTInfoResults_output, LpInfoResults_output] | ||
| 210 | + */ | ||
| 211 | + private Object[] ttInfoOutput(Line line) { | ||
| 212 | + // 获取线路的所有未作废的时刻表 | ||
| 213 | + List<TTInfo> ttInfos = ttInfoRepository.findInCanceledByXl(line); | ||
| 214 | + | ||
| 215 | + // 1-1、构造drools规则输入数据,输出数据 | ||
| 216 | + // 全局计算参数 | ||
| 217 | + TTInfoCalcuParam_input ttInfoCalcuParam_input = | ||
| 218 | + new TTInfoCalcuParam_input( | ||
| 219 | + new DateTime(this.from), | ||
| 220 | + new DateTime(this.to), | ||
| 221 | + String.valueOf(line.getId()) | ||
| 222 | + ); | ||
| 223 | + // 规则输出数据 | ||
| 224 | + TTInfoResults_output ttInfoResults_output = new TTInfoResults_output(); | ||
| 225 | + LpInfoResults_output lpInfoResults_output = new LpInfoResults_output(); | ||
| 226 | + | ||
| 227 | + // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 228 | + // 创建session,内部配置的是stateful | ||
| 229 | + KieSession session = coreKBase.newKieSession(); | ||
| 230 | + | ||
| 231 | + // 设置gloable对象,在drl中通过别名使用 | ||
| 232 | + session.setGlobal("results", ttInfoResults_output); | ||
| 233 | + session.setGlobal("lpInfoResults_output", lpInfoResults_output); | ||
| 234 | + session.setGlobal("log", logger); // 设置日志 | ||
| 235 | + session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository); | ||
| 236 | + | ||
| 237 | + // 载入数据 | ||
| 238 | + session.insert(ttInfoCalcuParam_input); | ||
| 239 | + for (TTInfo ttInfo : ttInfos) { | ||
| 240 | + TTInfo_input ttInfo_input = new TTInfo_input(ttInfo); | ||
| 241 | + session.insert(ttInfo_input); | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + // 载入数据2(计算规则最早启用时间) | ||
| 245 | + List<ScheduleRule1Flat> scheduleRule1Flats = scheduleRule1FlatRepository.findByXl(line); | ||
| 246 | + | ||
| 247 | + for (ScheduleRule1Flat scheduleRule1Flat: scheduleRule1Flats) { | ||
| 248 | + ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat); | ||
| 249 | + session.insert(scheduleRule_input); | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + // 执行rule | ||
| 253 | + session.fireAllRules(); | ||
| 254 | + | ||
| 255 | + // 执行完毕销毁,有日志的也要关闭 | ||
| 256 | + session.dispose(); | ||
| 257 | + | ||
| 258 | + return new Object[] {ttInfoResults_output, lpInfoResults_output}; | ||
| 259 | + | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + /** | ||
| 263 | + * 循环规则输出。 | ||
| 264 | + * @param lpInfoResults_output 时刻表每日路牌的情况 | ||
| 265 | + */ | ||
| 266 | + private ScheduleResults_output loopRuleOutput(Line line, LpInfoResults_output lpInfoResults_output) { | ||
| 267 | + // 1-1、构造drools规则输入数据,输出数据 | ||
| 268 | + // 全局计算参数 | ||
| 269 | + SchedulePlan schedulePlan = new SchedulePlan(); | ||
| 270 | + schedulePlan.setXl(line); | ||
| 271 | + schedulePlan.setScheduleFromTime(this.from); | ||
| 272 | + schedulePlan.setScheduleToTime(this.to); | ||
| 273 | + schedulePlan.setIsHistoryPlanFirst(this.schedulePlan.getIsHistoryPlanFirst()); | ||
| 274 | + schedulePlan.setCreateBy(this.schedulePlan.getCreateBy()); | ||
| 275 | + ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan); | ||
| 276 | + // 每个规则对应的输入参数 | ||
| 277 | + List<ScheduleRule_input> scheduleRule_inputs = this.calcuSrfList(line); | ||
| 278 | + | ||
| 279 | + // 规则输出数据 | ||
| 280 | + ScheduleResults_output scheduleResults_output = new ScheduleResults_output(); | ||
| 281 | + | ||
| 282 | + // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 283 | + // 创建session,内部配置的是stateful | ||
| 284 | + KieSession session = coreKBase.newKieSession(); | ||
| 285 | + // 设置gloable对象,在drl中通过别名使用 | ||
| 286 | + session.setGlobal("scheduleResult", scheduleResults_output); | ||
| 287 | + session.setGlobal("log", logger); // 设置日志 | ||
| 288 | + session.setGlobal("scheduleRuleService", scheduleRuleService); | ||
| 289 | + | ||
| 290 | + // 载入数据 | ||
| 291 | + session.insert(scheduleCalcuParam_input); | ||
| 292 | + for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) { | ||
| 293 | + session.insert(scheduleRule_input); | ||
| 294 | + } | ||
| 295 | + // 每日时刻表路牌数据 | ||
| 296 | + for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) { | ||
| 297 | + session.insert(lpInfoResult_output); | ||
| 298 | + } | ||
| 299 | + // 执行rule | ||
| 300 | + session.fireAllRules(); | ||
| 301 | + | ||
| 302 | + // 执行完毕销毁,有日志的也要关闭 | ||
| 303 | + session.dispose(); | ||
| 304 | + | ||
| 305 | + // 保存循环规则结果数据 | ||
| 306 | + scheduleRuleService.generateRuleResult(scheduleResults_output.getSchedulePlanRuleResults()); | ||
| 307 | + | ||
| 308 | +// logger.info("循环规则输出={}", scheduleResults_output.showGuideboardDesc1()); | ||
| 309 | + | ||
| 310 | + return scheduleResults_output; | ||
| 311 | + } | ||
| 312 | + | ||
| 313 | + /** | ||
| 314 | + * 排班生成。 | ||
| 315 | + * @param scheduleResults_output loopRuleOutput方法规则输出 | ||
| 316 | + * @param ttInfoResults_output ttInfoOutput方法规则输出 | ||
| 317 | + * @return PlanResult | ||
| 318 | + */ | ||
| 319 | + private PlanResult planResultOutput( | ||
| 320 | + Line line, | ||
| 321 | + ScheduleResults_output scheduleResults_output, | ||
| 322 | + TTInfoResults_output ttInfoResults_output) { | ||
| 323 | + | ||
| 324 | + SchedulePlan schedulePlan = new SchedulePlan(); | ||
| 325 | + schedulePlan.setXl(line); | ||
| 326 | + schedulePlan.setScheduleFromTime(this.from); | ||
| 327 | + schedulePlan.setScheduleToTime(this.to); | ||
| 328 | + schedulePlan.setCreateBy(this.schedulePlan.getCreateBy()); | ||
| 329 | + schedulePlan.setUpdateBy(this.schedulePlan.getUpdateBy()); | ||
| 330 | + | ||
| 331 | + // 1-1、构造drools规则输入数据,输出数据 | ||
| 332 | + PlanCalcuParam_input planCalcuParam_input = new PlanCalcuParam_input( | ||
| 333 | + schedulePlan, | ||
| 334 | + scheduleResults_output, | ||
| 335 | + ttInfoResults_output | ||
| 336 | + ); | ||
| 337 | + // 规则输出数据 | ||
| 338 | + PlanResult planResult = new PlanResult(); | ||
| 339 | + planResult.setXlId(schedulePlan.getXl().getId().toString()); | ||
| 340 | + | ||
| 341 | + // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 342 | + // 创建session,内部配置的是stateful | ||
| 343 | + KieSession session = this.coreKBase.newKieSession(); | ||
| 344 | + | ||
| 345 | + // 设置gloable对象,在drl中通过别名使用 | ||
| 346 | + session.setGlobal("planResult", planResult); | ||
| 347 | + session.setGlobal("log", this.logger); // 设置日志 | ||
| 348 | + | ||
| 349 | + session.setGlobal("tTInfoDetailRepository", this.ttInfoDetailRepository); | ||
| 350 | + session.setGlobal("carConfigInfoRepository", this.carConfigInfoRepository); | ||
| 351 | + session.setGlobal("employeeConfigInfoRepository", this.employeeConfigInfoRepository); | ||
| 352 | + session.setGlobal("lineRepository", this.lineRepository); | ||
| 353 | + session.setGlobal("businessRepository", this.businessRepository); | ||
| 354 | + | ||
| 355 | + // 载入数据 | ||
| 356 | + session.insert(planCalcuParam_input); | ||
| 357 | + | ||
| 358 | + // 执行rule | ||
| 359 | + session.fireAllRules(); | ||
| 360 | + | ||
| 361 | + // 执行完毕销毁,有日志的也要关闭 | ||
| 362 | + session.dispose(); | ||
| 363 | + | ||
| 364 | + return planResult; | ||
| 365 | + | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + /** | ||
| 369 | + * 生成线路排班(不含套跑规则)。 | ||
| 370 | + * @param schedulePlan | ||
| 371 | + * @return | ||
| 372 | + */ | ||
| 373 | + private PlanResult schedulePlanWithOutRerun() { | ||
| 374 | + // 1、时刻表数据及每日路牌数据计算 | ||
| 375 | + Date start1 = new Date(); | ||
| 376 | + Object[] ttInfoRets = this.ttInfoOutput(this.mainLine); | ||
| 377 | + TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0]; | ||
| 378 | + LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; | ||
| 379 | + Date end1 = new Date(); | ||
| 380 | + // 2、循环规则计算输出 | ||
| 381 | + Date start2 = new Date(); | ||
| 382 | + ScheduleResults_output scheduleResults_output = this.loopRuleOutput( | ||
| 383 | + this.mainLine, lpInfoResults_output); | ||
| 384 | + Date end2 = new Date(); | ||
| 385 | + | ||
| 386 | + logger.info("规则计算结果={}", scheduleResults_output.showGuideboardDesc1()); | ||
| 387 | + | ||
| 388 | + // 3、计划输出 | ||
| 389 | + Date start3 = new Date(); | ||
| 390 | + PlanResult planResult = planResultOutput( | ||
| 391 | + this.mainLine, scheduleResults_output, ttInfoResults_output); | ||
| 392 | + Date end3 = new Date(); | ||
| 393 | + | ||
| 394 | + logger.info("drool时刻表每日路牌计算 {} ms,drool循环规则计算 {} ms,drool计划数据 {} ms", | ||
| 395 | + end1.getTime() - start1.getTime(), | ||
| 396 | + end2.getTime() - start2.getTime(), | ||
| 397 | + end3.getTime() - start3.getTime()); | ||
| 398 | + | ||
| 399 | + // TODO:将lpInfoResults_output 也要返回 | ||
| 400 | + | ||
| 401 | + return planResult; | ||
| 402 | + } | ||
| 403 | + | ||
| 404 | + /** | ||
| 405 | + * 套跑计划排班数据。 | ||
| 406 | + * @param planResult | ||
| 407 | + */ | ||
| 408 | + private void rerunPlanResult(PlanResult planResult) { | ||
| 409 | + logger.info("套跑数量 {} 组", this.rerunRule_inputs.size()); | ||
| 410 | + | ||
| 411 | + if (this.rerunRule_inputs.size() > 0) { | ||
| 412 | + // 找出是对应路牌类型的线路,计算循环规则输出 | ||
| 413 | + Set<String> dylpxlids = new HashSet<>(); | ||
| 414 | + for (RerunRule_input rerunRule_input: rerunRule_inputs) { | ||
| 415 | + if ("dylp".equals(rerunRule_input.getType())) { | ||
| 416 | + dylpxlids.add(rerunRule_input.getS_xl()); // 参与套跑的线路 | ||
| 417 | + } | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + List<ScheduleResults_output> scheduleResults_outputs = new ArrayList<>(); | ||
| 421 | + Date start1 = new Date(); | ||
| 422 | + for (String xlid: dylpxlids) { | ||
| 423 | + Line dylpline = new Line(); // 套跑的线路默认跟着主线路设定走 | ||
| 424 | + dylpline.setId(Integer.parseInt(xlid)); | ||
| 425 | + // 获取套跑线路的循环规则计算输出 | ||
| 426 | + Object[] ttInfoRets = this.ttInfoOutput(dylpline); | ||
| 427 | + LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; | ||
| 428 | + ScheduleResults_output scheduleResults_output = this.loopRuleOutput( | ||
| 429 | + dylpline, lpInfoResults_output); | ||
| 430 | + scheduleResults_outputs.add(scheduleResults_output); | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 434 | + // 创建session,内部配置的是stateful | ||
| 435 | + KieSession session = this.coreKBase.newKieSession(); | ||
| 436 | + | ||
| 437 | + // 设置gloable对象,在drl中通过别名使用 | ||
| 438 | + session.setGlobal("planResult", planResult); | ||
| 439 | + session.setGlobal("log", this.logger); // 设置日志 | ||
| 440 | + | ||
| 441 | + session.setGlobal("carConfigInfoRepository", this.carConfigInfoRepository); | ||
| 442 | + session.setGlobal("employeeConfigInfoRepository", this.employeeConfigInfoRepository); | ||
| 443 | + | ||
| 444 | + // 载入数据 | ||
| 445 | + RerunRule_param rerunRule_param = new RerunRule_param(); | ||
| 446 | + rerunRule_param.setMxlid(planResult.getXlId()); | ||
| 447 | + rerunRule_param.setXlIds_dylp(dylpxlids); | ||
| 448 | + session.insert(rerunRule_param); | ||
| 449 | + for (RerunRule_input rri: this.rerunRule_inputs) { | ||
| 450 | + session.insert(rri); | ||
| 451 | + } | ||
| 452 | + for (SchedulePlanInfo spi: planResult.getSchedulePlanInfos()) { | ||
| 453 | + session.insert(spi); | ||
| 454 | + } | ||
| 455 | + for (ScheduleResults_output sro: scheduleResults_outputs) { | ||
| 456 | + session.insert(sro); | ||
| 457 | + } | ||
| 458 | + | ||
| 459 | + // 执行rule | ||
| 460 | + session.fireAllRules(); | ||
| 461 | + | ||
| 462 | + // 执行完毕销毁,有日志的也要关闭 | ||
| 463 | + session.dispose(); | ||
| 464 | + | ||
| 465 | + Date end1 = new Date(); | ||
| 466 | + logger.info("套跑规则计算,耗时 {} ms", end1.getTime() - start1.getTime()); | ||
| 467 | + | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + } | ||
| 471 | + | ||
| 472 | + /** | ||
| 473 | + * 验证排班结果。 | ||
| 474 | + * @param planResult | ||
| 475 | + * @param schedulePlan | ||
| 476 | + */ | ||
| 477 | + public void validPlanResult(PlanResult planResult) { | ||
| 478 | + // 1-1、构造drools规则输入数据,输出数据 | ||
| 479 | + ValidateParam validateParam = new ValidateParam( | ||
| 480 | + new DateTime(this.from), new DateTime(this.to)); | ||
| 481 | + // 规则输出数据 | ||
| 482 | + ValidateResults_output result = new ValidateResults_output(); | ||
| 483 | + | ||
| 484 | + // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | ||
| 485 | + // 创建session,内部配置的是stateful | ||
| 486 | + KieSession session = this.coreKBase.newKieSession(); | ||
| 487 | + | ||
| 488 | + // 设置gloable对象,在drl中通过别名使用 | ||
| 489 | + session.setGlobal("validResult", result); | ||
| 490 | + session.setGlobal("log", this.logger); // 设置日志 | ||
| 491 | + | ||
| 492 | + // 载入数据 | ||
| 493 | + session.insert(validateParam); | ||
| 494 | + for (SchedulePlanInfo schedulePlanInfo: planResult.getSchedulePlanInfos()) { | ||
| 495 | + session.insert(schedulePlanInfo); | ||
| 496 | + } | ||
| 497 | + | ||
| 498 | + // 执行rule | ||
| 499 | + session.fireAllRules(); | ||
| 500 | + | ||
| 501 | + // 执行完毕销毁,有日志的也要关闭 | ||
| 502 | + session.dispose(); | ||
| 503 | + | ||
| 504 | +// logger.info("错误总数={}", result.getInfos().size()); | ||
| 505 | +// for (ValidateResults_output.ValidInfo validInfo: result.getInfos()) { | ||
| 506 | +// logger.info(validInfo.getDesc()); | ||
| 507 | +// } | ||
| 508 | + | ||
| 509 | + // 取10条错误 | ||
| 510 | + int size = result.getInfos().size() > 10 ? 10: result.getInfos().size(); | ||
| 511 | + List<String> desclist = new ArrayList<>(); | ||
| 512 | + for (int i = 0; i < size; i++) { | ||
| 513 | + desclist.add(result.getInfos().get(i).getDesc()); | ||
| 514 | + } | ||
| 515 | + if (desclist.size() > 0) { | ||
| 516 | + this.schedulePlan.setPlanResult(StringUtils.join(desclist, "</br>")); | ||
| 517 | + } else { | ||
| 518 | + this.schedulePlan.setPlanResult("ok"); | ||
| 519 | + } | ||
| 520 | + | ||
| 521 | + // TODO:设定错误信息 | ||
| 522 | + } | ||
| 523 | + | ||
| 524 | +} |
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
| @@ -28,7 +28,7 @@ public class MyDroolsConfiguration { | @@ -28,7 +28,7 @@ public class MyDroolsConfiguration { | ||
| 28 | * 返回一个kiebase知识库,直接冲文件系统读入drl规则文件, | 28 | * 返回一个kiebase知识库,直接冲文件系统读入drl规则文件, |
| 29 | * TODO:以后需要从数据库读入规则文件,并重新创建kbase知识库。 | 29 | * TODO:以后需要从数据库读入规则文件,并重新创建kbase知识库。 |
| 30 | */ | 30 | */ |
| 31 | - @Bean(name = "kb1") | 31 | + @Bean(name = "coreKBase") |
| 32 | public KieBase myKieBase() { | 32 | public KieBase myKieBase() { |
| 33 | // Drools 6开始引入kie统一接口(jboss的jbpm工作流也使用kie接口了),整个定义方式和5差别很大 | 33 | // Drools 6开始引入kie统一接口(jboss的jbpm工作流也使用kie接口了),整个定义方式和5差别很大 |
| 34 | // 这里使用全api方式创建知识库对象,不使用xml的方式,提供最大的灵活性 | 34 | // 这里使用全api方式创建知识库对象,不使用xml的方式,提供最大的灵活性 |
| @@ -105,7 +105,7 @@ public class MyDroolsConfiguration { | @@ -105,7 +105,7 @@ public class MyDroolsConfiguration { | ||
| 105 | * 返回一个kiebase知识库,直接冲文件系统读入drl规则文件, | 105 | * 返回一个kiebase知识库,直接冲文件系统读入drl规则文件, |
| 106 | * TODO:以后需要从数据库读入规则文件,并重新创建kbase知识库。 | 106 | * TODO:以后需要从数据库读入规则文件,并重新创建kbase知识库。 |
| 107 | */ | 107 | */ |
| 108 | - @Bean(name = "kb2") | 108 | + @Bean(name = "preKBase") |
| 109 | public KieBase myKieBase2() { | 109 | public KieBase myKieBase2() { |
| 110 | // Drools 6开始引入kie统一接口(jboss的jbpm工作流也使用kie接口了),整个定义方式和5差别很大 | 110 | // Drools 6开始引入kie统一接口(jboss的jbpm工作流也使用kie接口了),整个定义方式和5差别很大 |
| 111 | // 这里使用全api方式创建知识库对象,不使用xml的方式,提供最大的灵活性 | 111 | // 这里使用全api方式创建知识库对象,不使用xml的方式,提供最大的灵活性 |
src/main/java/com/bsth/service/schedule/timetable/ExcelData.java
0 → 100644
| 1 | +package com.bsth.service.schedule.timetable; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.Line; | ||
| 4 | +import com.bsth.entity.LsStationRoute; | ||
| 5 | +import com.bsth.entity.schedule.GuideboardInfo; | ||
| 6 | +import com.bsth.service.LineService; | ||
| 7 | +import com.bsth.service.StationRouteService; | ||
| 8 | +import com.bsth.service.schedule.GuideboardInfoService; | ||
| 9 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 10 | +import com.bsth.service.schedule.utils.DataToolsFile; | ||
| 11 | +import com.bsth.service.schedule.utils.DataToolsFileType; | ||
| 12 | +import com.bsth.service.schedule.utils.PoiUtils; | ||
| 13 | +import org.apache.commons.lang3.StringUtils; | ||
| 14 | +import org.apache.poi.ss.usermodel.Cell; | ||
| 15 | +import org.apache.poi.ss.usermodel.Row; | ||
| 16 | +import org.apache.poi.ss.usermodel.Sheet; | ||
| 17 | +import org.apache.poi.ss.usermodel.Workbook; | ||
| 18 | +import org.springframework.util.CollectionUtils; | ||
| 19 | + | ||
| 20 | +import java.io.File; | ||
| 21 | +import java.util.ArrayList; | ||
| 22 | +import java.util.HashMap; | ||
| 23 | +import java.util.List; | ||
| 24 | +import java.util.Map; | ||
| 25 | +import java.util.regex.Matcher; | ||
| 26 | +import java.util.regex.Pattern; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * 时刻表Excel数据类。 | ||
| 30 | + */ | ||
| 31 | +public class ExcelData { | ||
| 32 | + | ||
| 33 | + /** 导入后的Excel文件对象 */ | ||
| 34 | + private DataToolsFile dataToolsFile; | ||
| 35 | + /** 数据sheet名 */ | ||
| 36 | + private String sheetName; | ||
| 37 | + /** 线路 */ | ||
| 38 | + private Line line; | ||
| 39 | + /** 线路路由列表(包含上下行的起终点站) */ | ||
| 40 | + private List<LsStationRoute> lsStationRouteList; | ||
| 41 | + /** 路牌列表 */ | ||
| 42 | + private List<GuideboardInfo> guideboardInfoList; | ||
| 43 | + /** excel数据格式 */ | ||
| 44 | + private ExcelFormatType excelFormatType; | ||
| 45 | + | ||
| 46 | + public DataToolsFile getDataToolsFile() { | ||
| 47 | + return dataToolsFile; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public void setDataToolsFile(DataToolsFile dataToolsFile) { | ||
| 51 | + this.dataToolsFile = dataToolsFile; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public String getSheetName() { | ||
| 55 | + return sheetName; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void setSheetName(String sheetName) { | ||
| 59 | + this.sheetName = sheetName; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public Line getLine() { | ||
| 63 | + return line; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public void setLine(Line line) { | ||
| 67 | + this.line = line; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public List<LsStationRoute> getLsStationRouteList() { | ||
| 71 | + return lsStationRouteList; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + public void setLsStationRouteList(List<LsStationRoute> lsStationRouteList) { | ||
| 75 | + this.lsStationRouteList = lsStationRouteList; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public List<GuideboardInfo> getGuideboardInfoList() { | ||
| 79 | + return guideboardInfoList; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public void setGuideboardInfoList(List<GuideboardInfo> guideboardInfoList) { | ||
| 83 | + this.guideboardInfoList = guideboardInfoList; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public ExcelFormatType getExcelFormatType() { | ||
| 87 | + return excelFormatType; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public void setExcelFormatType(ExcelFormatType excelFormatType) { | ||
| 91 | + this.excelFormatType = excelFormatType; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 构造函数 | ||
| 96 | + * @param filePath 文件路径 | ||
| 97 | + * @param sheetName sheet名字 | ||
| 98 | + * @param lineId 线路Id | ||
| 99 | + * @param lineService LineServiceImpl | ||
| 100 | + * @param guideboardInfoService GuideboardInfoServiceImpl | ||
| 101 | + * @param lineRouteVersion 线路路由版本 | ||
| 102 | + * @param stationRouteService StationRouteServiceImpl | ||
| 103 | + * @param excelFormatType excel数据格式 | ||
| 104 | + * @throws ScheduleException | ||
| 105 | + * @see com.bsth.service.impl.LineServiceImpl | ||
| 106 | + * @see com.bsth.service.schedule.impl.GuideboardInfoServiceImpl | ||
| 107 | + * @see com.bsth.service.impl.StationRouteServiceImpl | ||
| 108 | + */ | ||
| 109 | + public ExcelData( | ||
| 110 | + String filePath, String sheetName, | ||
| 111 | + Integer lineId, LineService lineService, GuideboardInfoService guideboardInfoService, | ||
| 112 | + Integer lineRouteVersion, StationRouteService stationRouteService, | ||
| 113 | + ExcelFormatType excelFormatType) throws ScheduleException { | ||
| 114 | + // 获取Excel文件对象,类型 | ||
| 115 | + File file = new File(filePath); | ||
| 116 | + this.dataToolsFile = new DataToolsFile(); | ||
| 117 | + this.dataToolsFile.setFile(file); | ||
| 118 | + if (DataToolsFileType.XLS.isThisType(file)) { | ||
| 119 | + this.dataToolsFile.setFileType(DataToolsFileType.XLS); | ||
| 120 | + } else if (DataToolsFileType.XLSX.isThisType(file)) { | ||
| 121 | + this.dataToolsFile.setFileType(DataToolsFileType.XLSX); | ||
| 122 | + } else { | ||
| 123 | + throw new ScheduleException("不是xls xlsx文件!"); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + // sheet名字 | ||
| 127 | + this.sheetName = sheetName; | ||
| 128 | + // 线路 | ||
| 129 | + this.line = lineService.findById(lineId); | ||
| 130 | + // 线路路由列表 | ||
| 131 | + Map<String, Object> p1 = new HashMap<>(); | ||
| 132 | + p1.put("line.id_eq", lineId); | ||
| 133 | + p1.put("stationMark_in", "B,E"); // 起点站 | ||
| 134 | + p1.put("destroy_eq", 0); // 未撤销 | ||
| 135 | + p1.put("versions_eq", lineRouteVersion); // 带线路版本 | ||
| 136 | + lsStationRouteList = (List<LsStationRoute>) stationRouteService.list_ls(p1); | ||
| 137 | + // 路牌列表 | ||
| 138 | + p1.clear(); | ||
| 139 | + p1.put("xl.id_eq", lineId); | ||
| 140 | + p1.put("isCancel_eq", false); | ||
| 141 | + guideboardInfoList = guideboardInfoService.list(p1); | ||
| 142 | + | ||
| 143 | + // excel数据格式 | ||
| 144 | + this.excelFormatType = excelFormatType; | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + /** | ||
| 148 | + * 验证路由名字。 | ||
| 149 | + * @param colNum 列标号(从0开始) | ||
| 150 | + * @param routeName 路由名字 | ||
| 151 | + * @throws ScheduleException | ||
| 152 | + */ | ||
| 153 | + private void validateRouteName(int colNum, String routeName) throws ScheduleException { | ||
| 154 | + List<LsStationRoute> lsStationRoutes = new ArrayList<>(); | ||
| 155 | + for (LsStationRoute lsStationRoute : this.lsStationRouteList) { | ||
| 156 | + if ("B".equals(lsStationRoute.getStationMark()) && routeName.equals(lsStationRoute.getStationName())) { | ||
| 157 | + lsStationRoutes.add(lsStationRoute); | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + if (CollectionUtils.isEmpty(lsStationRoutes)) { | ||
| 162 | + throw new ScheduleException(String.format("第1行,第%d列数据%s在%s站点路由中不是起点站", | ||
| 163 | + colNum + 1, routeName, this.line.getName())); | ||
| 164 | + } else if (lsStationRoutes.size() > 1) { | ||
| 165 | + throw new ScheduleException(String.format("第1行,第%d列数据%s在%s站点路由中上下行都是起点站", | ||
| 166 | + colNum + 1, routeName, this.line.getName())); | ||
| 167 | + } else if (StringUtils.isEmpty(lsStationRoutes.get(0).getStationCode())) { | ||
| 168 | + throw new ScheduleException(String.format("第1行,第%d列数据%s在%s站点路由中没有站点编码", | ||
| 169 | + colNum + 1, routeName, this.line.getName())); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + /** | ||
| 175 | + * 验证路牌名字。 | ||
| 176 | + * @param colNum excelSheet 列index | ||
| 177 | + * @param guideboardName 路牌名字 | ||
| 178 | + * @throws ScheduleException | ||
| 179 | + */ | ||
| 180 | + private void validateGuideboardName(int colNum, String guideboardName) throws ScheduleException { | ||
| 181 | + List<GuideboardInfo> guideboardInfos = new ArrayList<>(); | ||
| 182 | + for (GuideboardInfo guideboardInfo : this.guideboardInfoList) { | ||
| 183 | + if (guideboardName.equals(guideboardInfo.getLpName())) { | ||
| 184 | + guideboardInfos.add(guideboardInfo); | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + if (CollectionUtils.isEmpty(guideboardInfos)) { | ||
| 189 | + throw new ScheduleException(String.format("第%d行,第1列的路牌在%s中不存在", | ||
| 190 | + colNum + 1, this.line.getName())); | ||
| 191 | + } else if (guideboardInfos.size() > 1) { | ||
| 192 | + throw new ScheduleException(String.format("第%d行,第1列的路牌在%s中重复", | ||
| 193 | + colNum + 1, this.line.getName())); | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + /** | ||
| 198 | + * 验证发车时间内容。 | ||
| 199 | + * @param rowNum excelSheet 行index | ||
| 200 | + * @param colNum excelSheet 列index | ||
| 201 | + * @param fcsjContent 发车时间内容 | ||
| 202 | + * @throws ScheduleException | ||
| 203 | + */ | ||
| 204 | + private void validateFcsjContent(int rowNum, int colNum, String fcsjContent) throws ScheduleException { | ||
| 205 | + if (this.excelFormatType == ExcelFormatType.Normal) { | ||
| 206 | + // 班次时间验证,正则表达式,格式hh:mm或者hhmm | ||
| 207 | + String rex1 = "^([01]?[0-9]|2[0-3]):[0-5][0-9]$"; // hh:mm格式 | ||
| 208 | + String rex2 = "^([01]?[0-9]|2[0-3]),[0-5][0-9]$"; // hh,mm格式 | ||
| 209 | + String rex3 = "^([01]?[0-9]|2[0-3])[0-5][0-9]$"; // hhmm格式 | ||
| 210 | + Pattern p1 = Pattern.compile(rex1); | ||
| 211 | + Pattern p2 = Pattern.compile(rex2); | ||
| 212 | + Pattern p3 = Pattern.compile(rex3); | ||
| 213 | + | ||
| 214 | + Matcher m1 = p1.matcher(fcsjContent.trim()); | ||
| 215 | + Matcher m2 = p2.matcher(fcsjContent.trim()); | ||
| 216 | + Matcher m3 = p3.matcher(fcsjContent.trim()); | ||
| 217 | + if ((!m1.matches()) && (!m2.matches()) && (!m3.matches())) { | ||
| 218 | + throw new ScheduleException(String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hh,mm或hhmm", | ||
| 219 | + rowNum + 1, colNum + 1)); | ||
| 220 | + } | ||
| 221 | + } else if (this.excelFormatType == ExcelFormatType.Dynamic) { | ||
| 222 | + String rex1 = "^(\u62a5|\u51fa)?([01]?[0-9]|2[0-3]):[0-5][0-9]$"; // (报|出)hh:mm格式 | ||
| 223 | + String rex2 = "^([01]?[0-9]|2[0-3]):[0-5][0-9](X|\u203b)?$"; // hh:mm(X|※)格式 | ||
| 224 | + Pattern p1 = Pattern.compile(rex1); | ||
| 225 | + Pattern p2 = Pattern.compile(rex2); | ||
| 226 | + Matcher m1 = p1.matcher(fcsjContent.trim()); | ||
| 227 | + Matcher m2 = p2.matcher(fcsjContent.trim()); | ||
| 228 | + if ((!m1.matches()) && (!m2.matches())) { | ||
| 229 | + throw new ScheduleException(String.format( | ||
| 230 | + "第%d行,第%d列的发车时间格式不正确,格式应为(报|出)hh:mm或hh:mm(X|※)", | ||
| 231 | + rowNum + 1, colNum + 1)); | ||
| 232 | + } | ||
| 233 | + } else { | ||
| 234 | + throw new ScheduleException("未知ExcelFormatType"); | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + private List<Integer> calcuExcelSheetColIndexList(Workbook workbook) throws ScheduleException { | ||
| 240 | + // 有些列不需要参与计算,找出参与计算的列 | ||
| 241 | + List<Integer> colIndexList = new ArrayList<>(); | ||
| 242 | + Sheet sheet = workbook.getSheet(this.sheetName); | ||
| 243 | + Row firstRow = sheet.getRow(0); // 获取第一行数据列 | ||
| 244 | + for (int i = 0; i < firstRow.getLastCellNum(); i++) { | ||
| 245 | + if (excelFormatType == ExcelFormatType.Normal) { | ||
| 246 | + colIndexList.add(i); | ||
| 247 | + } else if (excelFormatType == ExcelFormatType.Dynamic) { | ||
| 248 | + String cell_con = StringUtils.trimToEmpty( | ||
| 249 | + PoiUtils.getStringValueFromCell(firstRow.getCell(i))); // trimToEmpty | ||
| 250 | + if ("报到".equals(cell_con) || | ||
| 251 | + "到场".equals(cell_con) || | ||
| 252 | + "离场".equals(cell_con) || | ||
| 253 | + "总公里".equals(cell_con) || | ||
| 254 | + "营业公里".equals(cell_con) || | ||
| 255 | + "空驶公里".equals(cell_con) || | ||
| 256 | + "总工时".equals(cell_con) || | ||
| 257 | + "营业工时".equals(cell_con) || | ||
| 258 | + "营运班次".equals(cell_con)) { | ||
| 259 | + // 这些列全部祛除 | ||
| 260 | + continue; | ||
| 261 | + } else { | ||
| 262 | + colIndexList.add(i); | ||
| 263 | + } | ||
| 264 | + } else { | ||
| 265 | + throw new ScheduleException("未知excelFormatType"); | ||
| 266 | + } | ||
| 267 | + } | ||
| 268 | + return colIndexList; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + /** | ||
| 272 | + * 验证老系统ExcelSheet格式。 | ||
| 273 | + * @throws ScheduleException | ||
| 274 | + */ | ||
| 275 | + public void validateExcelSheet() throws ScheduleException { | ||
| 276 | + try { | ||
| 277 | + Workbook workbook = this.dataToolsFile.getFileType().getWorkBook( | ||
| 278 | + this.dataToolsFile.getFile() | ||
| 279 | + ); | ||
| 280 | + | ||
| 281 | + Sheet sheet = workbook.getSheet(this.sheetName); | ||
| 282 | + int rowNums = sheet.getLastRowNum() + 1; // 基于0 base的,长度加1 | ||
| 283 | + int colNums = sheet.getRow(0).getLastCellNum(); // 不需要加1,就是长度 | ||
| 284 | + | ||
| 285 | + if (rowNums == 0 || colNums == 0) { // 工作区是否为空 | ||
| 286 | + throw new Exception(String.format("%s 工作区没有数据!", this.sheetName)); | ||
| 287 | + } else { | ||
| 288 | + if (rowNums <= 1 || rowNums <= 1) { | ||
| 289 | + throw new Exception(String.format("工作区至少包含2行2列的数据")); | ||
| 290 | + } else { | ||
| 291 | + List<Integer> colIndexList = this.calcuExcelSheetColIndexList(workbook); | ||
| 292 | + Row firstRow = sheet.getRow(0); // 获取第一行数据列 | ||
| 293 | + for (int n = 0; n < colIndexList.size(); n++) { | ||
| 294 | + int i = colIndexList.get(n); | ||
| 295 | + String cell_con = StringUtils.trimToEmpty( | ||
| 296 | + PoiUtils.getStringValueFromCell(firstRow.getCell(i))); // trimToEmpty | ||
| 297 | + | ||
| 298 | + if (StringUtils.isEmpty(cell_con)) { | ||
| 299 | + throw new Exception(String.format("第1行,第%d列数据不能为空", i + 1)); | ||
| 300 | + } else { | ||
| 301 | + // 正则表达式去除右侧数字 | ||
| 302 | +// cell_con = cell_con.replaceAll("[\\d+]", ""); | ||
| 303 | +// cell_con = cell_con.replaceAll("(\\d+)$", ""); | ||
| 304 | + | ||
| 305 | + // 如果站名中有类似->{数字},使用正则表达式过滤掉 | ||
| 306 | + cell_con = cell_con.replaceAll("(->\\d+)", ""); | ||
| 307 | + | ||
| 308 | + if (i == 0) { // 第一列必须是路牌2个字 | ||
| 309 | + if (!"路牌".equals(cell_con.trim())) { | ||
| 310 | + throw new Exception("第1行,第1列数据必须是路牌2个字"); | ||
| 311 | + } | ||
| 312 | + } else { // 排除出场,进场,其余内容到站点路由里查询,以各个方向的起点站为查询依据 | ||
| 313 | + if ((!"出场".equals(cell_con.trim())) && | ||
| 314 | + (!"进场".equals(cell_con.trim()))) { | ||
| 315 | + validateRouteName(i, cell_con.trim()); // 验证路由名字 | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + } | ||
| 319 | + } | ||
| 320 | + } | ||
| 321 | + | ||
| 322 | + // 验证路牌内容 | ||
| 323 | + Map<String, Integer> gbindexmap = new HashMap<>(); // 记录每个路牌在第几行 | ||
| 324 | + for (int i = 1; i < rowNums; i++) { // 从第2行开始验证数据 | ||
| 325 | + Cell cell = sheet.getRow(i).getCell(0); // 获取第1列 | ||
| 326 | + String bcell_con = StringUtils.trimToEmpty( | ||
| 327 | + PoiUtils.getStringValueFromCell(cell)); // trimToEmpty | ||
| 328 | + if (StringUtils.isEmpty(bcell_con)) { | ||
| 329 | + throw new Exception(String.format("第%d行,第1列路牌无数据", i + 1)); | ||
| 330 | + } else if (gbindexmap.get(bcell_con.trim()) != null) { | ||
| 331 | + throw new Exception(String.format("第%d行,第1列的路牌数据与第%d行,第1列数据重复", | ||
| 332 | + i + 1, | ||
| 333 | + gbindexmap.get(bcell_con.trim()))); | ||
| 334 | + } else { | ||
| 335 | + validateGuideboardName(i, bcell_con.trim()); // 验证路牌名字 | ||
| 336 | + gbindexmap.put(bcell_con.trim(), i + 1); | ||
| 337 | + } | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + // 验证发车时间格式 | ||
| 341 | + for (int i = 1; i < rowNums; i++) { // 从第2行开始验证数据 | ||
| 342 | + Row row = sheet.getRow(i); | ||
| 343 | + for (int n = 1; n < colIndexList.size(); n++) { // 从第2列开始 | ||
| 344 | + int j = colIndexList.get(n); | ||
| 345 | + String bcell_con = StringUtils.trimToEmpty( | ||
| 346 | + PoiUtils.getStringValueFromCell( | ||
| 347 | + row.getCell(j))).replaceAll("\\s*", ""); // trimToEmpty | ||
| 348 | + if (StringUtils.isNotEmpty(bcell_con)) { | ||
| 349 | + validateFcsjContent(i, j, bcell_con); | ||
| 350 | + } | ||
| 351 | + } | ||
| 352 | + } | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + } catch (Exception exp) { | ||
| 358 | + exp.printStackTrace(); | ||
| 359 | + throw new ScheduleException(exp.getMessage()); | ||
| 360 | + } | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | +} |
src/main/java/com/bsth/service/schedule/timetable/ExcelFormatType.java
0 → 100644
| 1 | +package com.bsth.service.schedule.timetable; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonCreator; | ||
| 4 | +import com.fasterxml.jackson.annotation.JsonValue; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 导入时刻表时,excel的数据格式类型。 | ||
| 8 | + */ | ||
| 9 | +public enum ExcelFormatType { | ||
| 10 | + Normal("normal"), // 老系统格式 | ||
| 11 | + Dynamic("dynamic"); // 自动生成的导出格式 | ||
| 12 | + | ||
| 13 | + private String flag; | ||
| 14 | + | ||
| 15 | + @JsonCreator | ||
| 16 | + ExcelFormatType(String flag) { | ||
| 17 | + this.flag = flag; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + @JsonValue | ||
| 21 | + public String getFlag() { | ||
| 22 | + return flag; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void setFlag(String flag) { | ||
| 26 | + this.flag = flag; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public static ExcelFormatType getEnum(String str) { | ||
| 30 | + if ("normal".equals(str)) { | ||
| 31 | + return Normal; | ||
| 32 | + } else if ("dynamic".equals(str)) { | ||
| 33 | + return Dynamic; | ||
| 34 | + } else { | ||
| 35 | + throw new IllegalArgumentException("未知ExcelFormatType"); | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | +} |
src/main/java/com/bsth/service/schedule/utils/DataToolsFileType.java
| @@ -76,7 +76,8 @@ public enum DataToolsFileType { | @@ -76,7 +76,8 @@ public enum DataToolsFileType { | ||
| 76 | 76 | ||
| 77 | // application/x-tika-ooxml | 77 | // application/x-tika-ooxml |
| 78 | if ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(type) || | 78 | if ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(type) || |
| 79 | - "application/x-tika-ooxml".equals(type)) { | 79 | + "application/x-tika-ooxml".equals(type) || |
| 80 | + "application/zip".equals(type)) { | ||
| 80 | // .xlsx 2007之后的格式 | 81 | // .xlsx 2007之后的格式 |
| 81 | return true; | 82 | return true; |
| 82 | } else { | 83 | } else { |
src/main/java/com/bsth/service/schedule/utils/DataToolsProperties.java
| @@ -81,6 +81,9 @@ public class DataToolsProperties { | @@ -81,6 +81,9 @@ public class DataToolsProperties { | ||
| 81 | /** 时刻表明细信息导入2(带版本) */ | 81 | /** 时刻表明细信息导入2(带版本) */ |
| 82 | @NotNull | 82 | @NotNull |
| 83 | private String ttinfodetailDatainputktr2version; | 83 | private String ttinfodetailDatainputktr2version; |
| 84 | + /** 时刻表明细信息导入2(带版本),使用生成时刻表格式 */ | ||
| 85 | + @NotNull | ||
| 86 | + private String ttinfodetailDatainputktr2version2; | ||
| 84 | /** 排班规则信息导入 */ | 87 | /** 排班规则信息导入 */ |
| 85 | @NotNull | 88 | @NotNull |
| 86 | private String scheduleruleDatainputktr; | 89 | private String scheduleruleDatainputktr; |
| @@ -353,4 +356,12 @@ public class DataToolsProperties { | @@ -353,4 +356,12 @@ public class DataToolsProperties { | ||
| 353 | public void setTransTemplatedir(String transTemplatedir) { | 356 | public void setTransTemplatedir(String transTemplatedir) { |
| 354 | this.transTemplatedir = transTemplatedir; | 357 | this.transTemplatedir = transTemplatedir; |
| 355 | } | 358 | } |
| 359 | + | ||
| 360 | + public String getTtinfodetailDatainputktr2version2() { | ||
| 361 | + return ttinfodetailDatainputktr2version2; | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + public void setTtinfodetailDatainputktr2version2(String ttinfodetailDatainputktr2version2) { | ||
| 365 | + this.ttinfodetailDatainputktr2version2 = ttinfodetailDatainputktr2version2; | ||
| 366 | + } | ||
| 356 | } | 367 | } |
src/main/java/com/bsth/service/schedule/utils/PoiUtils.java
| @@ -2,7 +2,6 @@ package com.bsth.service.schedule.utils; | @@ -2,7 +2,6 @@ package com.bsth.service.schedule.utils; | ||
| 2 | 2 | ||
| 3 | import org.apache.poi.hssf.usermodel.HSSFDateUtil; | 3 | import org.apache.poi.hssf.usermodel.HSSFDateUtil; |
| 4 | import org.apache.poi.ss.usermodel.*; | 4 | import org.apache.poi.ss.usermodel.*; |
| 5 | -import org.apache.poi.ss.util.WorkbookUtil; | ||
| 6 | import org.apache.poi.xssf.usermodel.*; | 5 | import org.apache.poi.xssf.usermodel.*; |
| 7 | 6 | ||
| 8 | import java.awt.Color; | 7 | import java.awt.Color; |
| @@ -58,7 +57,7 @@ public class PoiUtils { | @@ -58,7 +57,7 @@ public class PoiUtils { | ||
| 58 | public static XSSFCell createStringXSSFCell( | 57 | public static XSSFCell createStringXSSFCell( |
| 59 | XSSFWorkbook xssfWorkbook, XSSFRow xssfRow, short column, String value, | 58 | XSSFWorkbook xssfWorkbook, XSSFRow xssfRow, short column, String value, |
| 60 | Color backgroundColor) { | 59 | Color backgroundColor) { |
| 61 | - return createXSSFCell( | 60 | + XSSFCell xssfCell = createXSSFCell( |
| 62 | xssfWorkbook, xssfRow, column, | 61 | xssfWorkbook, xssfRow, column, |
| 63 | value, XSSFCell.CELL_TYPE_STRING, | 62 | value, XSSFCell.CELL_TYPE_STRING, |
| 64 | HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | 63 | HorizontalAlignment.CENTER, VerticalAlignment.CENTER, |
| @@ -66,11 +65,14 @@ public class PoiUtils { | @@ -66,11 +65,14 @@ public class PoiUtils { | ||
| 66 | (short) 13, new Color(0x2765A7), "宋体", | 65 | (short) 13, new Color(0x2765A7), "宋体", |
| 67 | backgroundColor, FillPatternType.SOLID_FOREGROUND | 66 | backgroundColor, FillPatternType.SOLID_FOREGROUND |
| 68 | ); | 67 | ); |
| 68 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | ||
| 69 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | ||
| 70 | + return xssfCell; | ||
| 69 | } | 71 | } |
| 70 | 72 | ||
| 71 | public static XSSFCell createStringXSSFCell( | 73 | public static XSSFCell createStringXSSFCell( |
| 72 | XSSFWorkbook xssfWorkbook, XSSFRow xssfRow, short column, String value) { | 74 | XSSFWorkbook xssfWorkbook, XSSFRow xssfRow, short column, String value) { |
| 73 | - return createXSSFCell( | 75 | + XSSFCell xssfCell = createXSSFCell( |
| 74 | xssfWorkbook, xssfRow, column, | 76 | xssfWorkbook, xssfRow, column, |
| 75 | value, XSSFCell.CELL_TYPE_STRING, | 77 | value, XSSFCell.CELL_TYPE_STRING, |
| 76 | HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | 78 | HorizontalAlignment.CENTER, VerticalAlignment.CENTER, |
| @@ -78,6 +80,9 @@ public class PoiUtils { | @@ -78,6 +80,9 @@ public class PoiUtils { | ||
| 78 | (short) 13, new Color(0x2765A7), "宋体", | 80 | (short) 13, new Color(0x2765A7), "宋体", |
| 79 | new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | 81 | new Color(0xffffff), FillPatternType.SOLID_FOREGROUND |
| 80 | ); | 82 | ); |
| 83 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | ||
| 84 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | ||
| 85 | + return xssfCell; | ||
| 81 | } | 86 | } |
| 82 | 87 | ||
| 83 | public static XSSFCell createDoubleXSSFCell( | 88 | public static XSSFCell createDoubleXSSFCell( |
| @@ -120,6 +125,12 @@ public class PoiUtils { | @@ -120,6 +125,12 @@ public class PoiUtils { | ||
| 120 | ); | 125 | ); |
| 121 | } | 126 | } |
| 122 | 127 | ||
| 128 | + public static XSSFCell setStringStyleXSSFCellStyle(XSSFWorkbook xssfWorkbook, XSSFCell xssfCell) { | ||
| 129 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | ||
| 130 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | ||
| 131 | + return xssfCell; | ||
| 132 | + } | ||
| 133 | + | ||
| 123 | public static XSSFCell setIntegerStyleXSSFCellStyle(XSSFWorkbook xssfWorkbook, XSSFCell xssfCell) { | 134 | public static XSSFCell setIntegerStyleXSSFCellStyle(XSSFWorkbook xssfWorkbook, XSSFCell xssfCell) { |
| 124 | CreationHelper creationHelper = xssfWorkbook.getCreationHelper(); | 135 | CreationHelper creationHelper = xssfWorkbook.getCreationHelper(); |
| 125 | XSSFCellStyle xssfCellStyle = xssfCell.getCellStyle(); | 136 | XSSFCellStyle xssfCellStyle = xssfCell.getCellStyle(); |
| @@ -150,8 +161,9 @@ public class PoiUtils { | @@ -150,8 +161,9 @@ public class PoiUtils { | ||
| 150 | 161 | ||
| 151 | // 设定值 | 162 | // 设定值 |
| 152 | if (valueType == XSSFCell.CELL_TYPE_STRING) { | 163 | if (valueType == XSSFCell.CELL_TYPE_STRING) { |
| 153 | - cell.setCellValue(creationHelper.createRichTextString( | ||
| 154 | - WorkbookUtil.createSafeSheetName(String.valueOf(value)))); | 164 | +// cell.setCellValue(creationHelper.createRichTextString( |
| 165 | +// WorkbookUtil.createSafeSheetName(String.valueOf(value)))); | ||
| 166 | + cell.setCellValue(creationHelper.createRichTextString(String.valueOf(value))); | ||
| 155 | } else if (valueType == XSSFCell.CELL_TYPE_NUMERIC) { | 167 | } else if (valueType == XSSFCell.CELL_TYPE_NUMERIC) { |
| 156 | if (value instanceof Date) { // 日期 | 168 | if (value instanceof Date) { // 日期 |
| 157 | cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-mm-dd")); | 169 | cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-mm-dd")); |
src/main/java/com/bsth/service/traffic/impl/VehicleInoutStopServiceImpl.java
| @@ -8,7 +8,6 @@ import com.bsth.util.DateUtils; | @@ -8,7 +8,6 @@ import com.bsth.util.DateUtils; | ||
| 8 | import com.bsth.util.db.DBUtils_MS; | 8 | import com.bsth.util.db.DBUtils_MS; |
| 9 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
| 11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | import org.springframework.jdbc.core.JdbcTemplate; | 11 | import org.springframework.jdbc.core.JdbcTemplate; |
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 |
src/main/java/com/bsth/util/db/DBUtils_traffic.java
0 → 100644
| 1 | +package com.bsth.util.db; | ||
| 2 | + | ||
| 3 | +import com.mchange.v2.c3p0.DataSources; | ||
| 4 | +import org.apache.log4j.Logger; | ||
| 5 | + | ||
| 6 | +import javax.sql.DataSource; | ||
| 7 | +import java.io.FileNotFoundException; | ||
| 8 | +import java.io.IOException; | ||
| 9 | +import java.sql.Connection; | ||
| 10 | +import java.sql.ResultSet; | ||
| 11 | +import java.sql.SQLException; | ||
| 12 | +import java.sql.Statement; | ||
| 13 | +import java.util.HashMap; | ||
| 14 | +import java.util.Map; | ||
| 15 | +import java.util.Properties; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 网关ms库连接池 | ||
| 19 | + * @author PanZhao | ||
| 20 | + * | ||
| 21 | + */ | ||
| 22 | +//@Component | ||
| 23 | +public class DBUtils_traffic { | ||
| 24 | + | ||
| 25 | + private static String url = null; | ||
| 26 | + | ||
| 27 | + private static String username = null; | ||
| 28 | + | ||
| 29 | + private static String pwd = null; | ||
| 30 | + | ||
| 31 | + private static DataSource ds_pooled; | ||
| 32 | + | ||
| 33 | + static Logger logger = Logger.getLogger(DBUtils_traffic.class); | ||
| 34 | + | ||
| 35 | + static { | ||
| 36 | + Properties env = new Properties(); | ||
| 37 | + | ||
| 38 | + try { | ||
| 39 | + env.load(DBUtils_traffic.class.getClassLoader().getResourceAsStream("traffic-jdbc.properties")); | ||
| 40 | + // 1. 加载驱动类 | ||
| 41 | + Class.forName(env.getProperty("ms.mysql.driver")); | ||
| 42 | + | ||
| 43 | + url = env.getProperty("ms.mysql.url"); | ||
| 44 | + username = env.getProperty("ms.mysql.username"); | ||
| 45 | + pwd = env.getProperty("ms.mysql.password"); | ||
| 46 | + | ||
| 47 | + // 设置连接数据库的配置信息 | ||
| 48 | + DataSource ds_unpooled = DataSources.unpooledDataSource(url, | ||
| 49 | + username, pwd); | ||
| 50 | + | ||
| 51 | + Map<String, Object> pool_conf = new HashMap<String, Object>(); | ||
| 52 | + // 设置最大连接数 | ||
| 53 | + pool_conf.put("maxPoolSize", 10); | ||
| 54 | + | ||
| 55 | + pool_conf.put("testConnectionOnCheckout", false); | ||
| 56 | + //异步检测连接的有效性 | ||
| 57 | + pool_conf.put("testConnectionOnCheckin", true); | ||
| 58 | + //30秒检测一次 | ||
| 59 | + pool_conf.put("idleConnectionTestPeriod", 30); | ||
| 60 | + ds_pooled = DataSources.pooledDataSource(ds_unpooled, pool_conf); | ||
| 61 | + } catch (FileNotFoundException e) { | ||
| 62 | + logger.error(e.toString()); | ||
| 63 | + e.printStackTrace(); | ||
| 64 | + } catch (IOException e) { | ||
| 65 | + logger.error(e.toString()); | ||
| 66 | + e.printStackTrace(); | ||
| 67 | + } catch (ClassNotFoundException e) { | ||
| 68 | + logger.error(e.toString()); | ||
| 69 | + e.printStackTrace(); | ||
| 70 | + } catch (SQLException e) { | ||
| 71 | + logger.error(e.toString()); | ||
| 72 | + e.printStackTrace(); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 获取连接对象 | ||
| 78 | + */ | ||
| 79 | + public static Connection getConnection() throws SQLException { | ||
| 80 | + return ds_pooled.getConnection(); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 释放连接池资源 | ||
| 85 | + */ | ||
| 86 | + public static void clearup() { | ||
| 87 | + if (ds_pooled != null) { | ||
| 88 | + try { | ||
| 89 | + DataSources.destroy(ds_pooled); | ||
| 90 | + } catch (SQLException e) { | ||
| 91 | + logger.error(e.toString()); | ||
| 92 | + e.printStackTrace(); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * 资源关闭 | ||
| 99 | + * | ||
| 100 | + * @param rs | ||
| 101 | + * @param stmt | ||
| 102 | + * @param conn | ||
| 103 | + */ | ||
| 104 | + public static void close(ResultSet rs, Statement stmt, Connection conn) { | ||
| 105 | + if (rs != null) { | ||
| 106 | + try { | ||
| 107 | + rs.close(); | ||
| 108 | + } catch (SQLException e) { | ||
| 109 | + logger.error(e.toString()); | ||
| 110 | + e.printStackTrace(); | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + if (stmt != null) { | ||
| 115 | + try { | ||
| 116 | + stmt.close(); | ||
| 117 | + } catch (SQLException e) { | ||
| 118 | + logger.error(e.toString()); | ||
| 119 | + e.printStackTrace(); | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + if (conn != null) { | ||
| 124 | + try { | ||
| 125 | + conn.close(); | ||
| 126 | + } catch (SQLException e) { | ||
| 127 | + logger.error(e.toString()); | ||
| 128 | + e.printStackTrace(); | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public static DataSource getDataSource(){ | ||
| 134 | + return ds_pooled; | ||
| 135 | + } | ||
| 136 | +} |
src/main/resources/datatools/config-dev.properties
| @@ -10,7 +10,7 @@ datatools.kvars_dbuname=root | @@ -10,7 +10,7 @@ datatools.kvars_dbuname=root | ||
| 10 | #数据库密码 | 10 | #数据库密码 |
| 11 | datatools.kvars_dbpwd= | 11 | datatools.kvars_dbpwd= |
| 12 | #数据库库名 | 12 | #数据库库名 |
| 13 | -datatools.kvars_dbdname=control | 13 | +datatools.kvars_dbdname=test_control |
| 14 | 14 | ||
| 15 | # 3、上传数据配置信息 | 15 | # 3、上传数据配置信息 |
| 16 | # 上传文件目录配置(根据不同的环境需要修正) | 16 | # 上传文件目录配置(根据不同的环境需要修正) |
| @@ -41,6 +41,8 @@ datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr | @@ -41,6 +41,8 @@ datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr | ||
| 41 | datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr | 41 | datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr |
| 42 | # 时刻表明细信息导入2(版本化) | 42 | # 时刻表明细信息导入2(版本化) |
| 43 | datatools.ttinfodetail_datainputktr2version=/datatools/ktrs/ttinfodetailDataInput2_version.ktr | 43 | datatools.ttinfodetail_datainputktr2version=/datatools/ktrs/ttinfodetailDataInput2_version.ktr |
| 44 | +# 时刻表明细信息导入2(版本化),使用生成时刻表格式 | ||
| 45 | +datatools.ttinfodetail_datainputktr2version2=/datatools/ktrs/ttinfodetailDataInput2_version_2.ktr | ||
| 44 | 46 | ||
| 45 | # 车辆配置信息导入 | 47 | # 车辆配置信息导入 |
| 46 | datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr | 48 | datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr |
src/main/resources/datatools/config-prod.properties
| @@ -42,6 +42,8 @@ datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr | @@ -42,6 +42,8 @@ datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr | ||
| 42 | datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr | 42 | datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr |
| 43 | # 时刻表明细信息导入2(版本化) | 43 | # 时刻表明细信息导入2(版本化) |
| 44 | datatools.ttinfodetail_datainputktr2version=/datatools/ktrs/ttinfodetailDataInput2_version.ktr | 44 | datatools.ttinfodetail_datainputktr2version=/datatools/ktrs/ttinfodetailDataInput2_version.ktr |
| 45 | +# 时刻表明细信息导入2(版本化),使用生成时刻表格式 | ||
| 46 | +datatools.ttinfodetail_datainputktr2version2=/datatools/ktrs/ttinfodetailDataInput2_version_2.ktr | ||
| 45 | 47 | ||
| 46 | # 车辆配置信息导入 | 48 | # 车辆配置信息导入 |
| 47 | datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr | 49 | datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr |