Commit bafa0eaaa54304a7be0af984fcbeea6e6201167d

Authored by 游瑞烽
2 parents e14690ee 602002b9

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

Showing 36 changed files with 2627 additions and 406 deletions

Too many changes to show.

To preserve performance only 36 of 89 files are displayed.

src/main/java/com/bsth/controller/calc/CalcWaybillController.java
... ... @@ -147,7 +147,11 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer>
147 147 if(map.get("type")!=null){
148 148 type=map.get("type").toString().trim();
149 149 }
150   - return calcWaybillService.calcStatisticsDaily(gsdm,fgsdm,line,date,date2,xlName,type);
  150 + String nature="0";
  151 + if(map.get("nature")!=null){
  152 + nature=map.get("nature").toString();
  153 + }
  154 + return calcWaybillService.calcStatisticsDaily(gsdm,fgsdm,line,date,date2,xlName,type,nature);
151 155 }
152 156  
153 157 @RequestMapping(value="/calcStatisticsDaily2")
... ... @@ -180,7 +184,11 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer>
180 184 if(map.get("type")!=null){
181 185 type=map.get("type").toString().trim();
182 186 }
183   - return calcWaybillService.calcStatisticsDaily2(gsdm,fgsdm,line,date,date2,xlName,type);
  187 + String nature="0";
  188 + if(map.get("nature")!=null){
  189 + nature=map.get("nature").toString();
  190 + }
  191 + return calcWaybillService.calcStatisticsDaily2(gsdm,fgsdm,line,date,date2,xlName,type,nature);
184 192 }
185 193  
186 194 @RequestMapping(value="/generateLineMileage")
... ...
src/main/java/com/bsth/controller/forms/ExportController.java
... ... @@ -469,12 +469,13 @@ public class ExportController {
469 469 for (Operationservice l : operationservice) {
470 470 Map<String, Object> m = new HashMap<String, Object>();
471 471 m.put("i", i);
472   - m.put("xlName", l.getXlName());
473   - m.put("jzl", l.getJzl());
474   - m.put("xhl", l.getXhl());
475   - m.put("xsgl", l.getXsgl());
476   - m.put("emptMileage", l.getEmptMileage());
477   - m.put("sjbc", l.getSjbc());
  472 + m.put("fgs", l.getFgs()!=null?l.getFgs():"");
  473 + m.put("xlName", l.getXlName()!=null?l.getXlName():"");
  474 + m.put("jzl", l.getJzl()!=null?l.getJzl():"");
  475 + m.put("xhl", l.getXhl()!=null?l.getXhl():"");
  476 + m.put("xsgl", l.getXsgl()!=null?l.getXsgl():"");
  477 + m.put("emptMileage", l.getEmptMileage()!=null?l.getEmptMileage():"");
  478 + m.put("sjbc", l.getSjbc()!=null?l.getSjbc():"");
478 479 resList.add(m);
479 480 i++;
480 481 }
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -417,7 +417,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
417 417 if(map.get("type")!=null){
418 418 type=map.get("type").toString();
419 419 }
420   - return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type);
  420 + String nature="0";
  421 + if(map.get("nature")!=null){
  422 + nature=map.get("nature").toString();
  423 + }
  424 + return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type,nature);
421 425 }
422 426  
423 427 /*
... ...
src/main/java/com/bsth/controller/report/CalcSheetController.java 0 → 100644
  1 +package com.bsth.controller.report;
  2 +import java.util.List;
  3 +import java.util.Map;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestMethod;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +import com.bsth.controller.BaseController;
  11 +import com.bsth.entity.sheet.CalcSheet;
  12 +import com.bsth.entity.sheet.Sheet;
  13 +import com.bsth.service.report.CalcSheetService;
  14 +
  15 +@RestController
  16 +@RequestMapping("calcSheet")
  17 +public class CalcSheetController extends BaseController<CalcSheet, Integer>{
  18 + @Autowired
  19 + CalcSheetService calcSheetService;
  20 + //发车到站准点率统计
  21 + @RequestMapping(value = "/countList",method = RequestMethod.GET)
  22 + public List<CalcSheet> countList(@RequestParam Map<String, Object> map){
  23 + List<CalcSheet> list=calcSheetService.countListCalcSheet(map);
  24 + return list;
  25 + }
  26 + //发车到站准点率列表
  27 + @RequestMapping(value = "/calcListSheet",method = RequestMethod.GET)
  28 + public List<CalcSheet> calcListSheet(@RequestParam Map<String, Object> map){
  29 + List<CalcSheet> list=calcSheetService.calcListSheet(map);
  30 + return list;
  31 + }
  32 + //发车站点准点率详细
  33 + @RequestMapping(value = "/calcSheet",method = RequestMethod.GET)
  34 + public List<Sheet> calcSheet(@RequestParam Map<String, Object> map){
  35 + List<Sheet> list=calcSheetService.calcSheet(map);
  36 + return list;
  37 + }
  38 +
  39 + //营运线路出车率统计
  40 + @RequestMapping(value = "/calcTurnoutrate",method = RequestMethod.GET)
  41 + public List<Map<String, Object>> calcTurnoutrate(@RequestParam Map<String, Object> map){
  42 + List<Map<String, Object>> list=calcSheetService.calcTurnoutrate(map);
  43 + return list;
  44 + }
  45 +}
... ...
src/main/java/com/bsth/controller/schedule/core/EmployeeConfigInfoController.java
... ... @@ -70,6 +70,27 @@ public class EmployeeConfigInfoController extends BController&lt;EmployeeConfigInfo
70 70 return rtn;
71 71 }
72 72  
  73 + @RequestMapping(value = "/validate_jsy_config", method = RequestMethod.GET)
  74 + public Map<String, Object> validate_jsy_config(@RequestParam Map<String, Object> param) {
  75 + Map<String, Object> rtn = new HashMap<>();
  76 + try {
  77 + EmployeeConfigInfo employeeConfigInfo = new EmployeeConfigInfo(
  78 + null,
  79 + param.get("xl.id_eq"),
  80 + param.get("xl.name_eq"),
  81 + param.get("jsy.id_eq"),
  82 + null
  83 + );
  84 + employeeConfigInfoService.validate_jsy_config(employeeConfigInfo);
  85 + rtn.put("status", ResponseCode.SUCCESS);
  86 + } catch (ScheduleException exp) {
  87 + rtn.put("status", ResponseCode.ERROR);
  88 + rtn.put("msg", exp.getMessage());
  89 + }
  90 +
  91 + return rtn;
  92 + }
  93 +
73 94 @RequestMapping(value = "/validate_spy", method = RequestMethod.GET)
74 95 public Map<String, Object> validate_spy(@RequestParam Map<String, Object> param) {
75 96 Map<String, Object> rtn = new HashMap<>();
... ... @@ -89,4 +110,24 @@ public class EmployeeConfigInfoController extends BController&lt;EmployeeConfigInfo
89 110 }
90 111 return rtn;
91 112 }
  113 +
  114 + @RequestMapping(value = "/validate_spy_config", method = RequestMethod.GET)
  115 + public Map<String, Object> validate_spy_config(@RequestParam Map<String, Object> param) {
  116 + Map<String, Object> rtn = new HashMap<>();
  117 + try {
  118 + EmployeeConfigInfo employeeConfigInfo = new EmployeeConfigInfo(
  119 + null,
  120 + param.get("xl.id_eq"),
  121 + param.get("xl.name_eq"),
  122 + null,
  123 + param.get("spy.id_eq")
  124 + );
  125 + employeeConfigInfoService.validate_spy_config(employeeConfigInfo);
  126 + rtn.put("status", ResponseCode.SUCCESS);
  127 + } catch (ScheduleException exp) {
  128 + rtn.put("status", ResponseCode.ERROR);
  129 + rtn.put("msg", exp.getMessage());
  130 + }
  131 + return rtn;
  132 + }
92 133 }
... ...
src/main/java/com/bsth/data/safe_driv/SafeDrivDataLoadThread.java
... ... @@ -20,12 +20,12 @@ import java.util.List;
20 20 * Created by panzhao on 2017/4/6.
21 21 */
22 22 @Component
23   -public class SafeDrivDataLoadThread extends Thread{
  23 +public class SafeDrivDataLoadThread extends Thread {
24 24  
25 25 Logger logger = LoggerFactory.getLogger(this.getClass());
26 26  
27 27 static String url;
28   - static CloseableHttpClient httpClient = null;
  28 + static CloseableHttpClient httpClient;
29 29 static HttpGet get;
30 30 static RequestConfig requestConfig;
31 31 static CloseableHttpResponse response;
... ... @@ -51,9 +51,7 @@ public class SafeDrivDataLoadThread extends Thread{
51 51  
52 52 int statusCode = response.getStatusLine().getStatusCode();
53 53 if(statusCode != 200){
54   - get.abort();
55 54 logger.error("http client status code: " + statusCode);
56   - return;
57 55 }
58 56  
59 57 entity = response.getEntity();
... ... @@ -67,7 +65,7 @@ public class SafeDrivDataLoadThread extends Thread{
67 65  
68 66 list = JSON.parseArray(stringBuffer.toString(), SafeDriv.class);
69 67  
70   - for(SafeDriv sd : list){
  68 + for (SafeDriv sd : list) {
71 69 SafeDrivCenter.put(sd);
72 70 }
73 71 }
... ... @@ -75,7 +73,7 @@ public class SafeDrivDataLoadThread extends Thread{
75 73 if (null != response)
76 74 response.close();
77 75 } catch (Exception e) {
78   - logger.error("安全驾驶接口报错了" , e.getMessage());
  76 + logger.error("安全驾驶接口报错了", e.getMessage());
79 77 }
80 78 }
81 79 }
... ...
src/main/java/com/bsth/data/schedule/ScheduleComparator.java
... ... @@ -9,12 +9,10 @@ import java.util.HashMap;
9 9 import java.util.Map;
10 10  
11 11 /**
12   - *
13   - * @ClassName: ScheduleComparator
14   - * @Description: TODO(实际班次排序器)
15 12 * @author PanZhao
16   - * @date 2016年8月15日 下午1:53:28
17   - *
  13 + * @ClassName: ScheduleComparator
  14 + * @Description: TODO(实际班次排序器)
  15 + * @date 2016年8月15日 下午1:53:28
18 16 */
19 17 public class ScheduleComparator {
20 18  
... ... @@ -26,71 +24,62 @@ public class ScheduleComparator {
26 24 }*/
27 25  
28 26  
29   - static Map<String, Integer> bcTypeOrderMap = new HashMap<>();
  27 + static Map<String, Integer> bcTypeOrderMap = new HashMap<>();
30 28  
31   - static{
32   - bcTypeOrderMap.put("out", 0);
33   - bcTypeOrderMap.put("normal", 1);
34   - bcTypeOrderMap.put("region", 2);
35   - bcTypeOrderMap.put("major", 3);
36   - bcTypeOrderMap.put("venting", 4);
37   - bcTypeOrderMap.put("ldks", 5);
38   - bcTypeOrderMap.put("in", 6);
39   - }
40   -
41   - public static class FCSJ implements Comparator<ScheduleRealInfo>{
  29 + static {
  30 + bcTypeOrderMap.put("out", 0);
  31 + bcTypeOrderMap.put("normal", 1);
  32 + bcTypeOrderMap.put("region", 2);
  33 + bcTypeOrderMap.put("major", 3);
  34 + bcTypeOrderMap.put("venting", 4);
  35 + bcTypeOrderMap.put("ldks", 5);
  36 + bcTypeOrderMap.put("in", 6);
  37 + }
42 38  
43   - @Override
44   - public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
45   - int diff = (int) (s1.getFcsjT() - s2.getFcsjT());
46   - return diff!=0?diff:typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
47   - }
48   - }
  39 + public static class FCSJ implements Comparator<ScheduleRealInfo> {
49 40  
50   - private static int typeOrder(String bcType){
51   - return bcTypeOrderMap.get(bcType)!=null?bcTypeOrderMap.get(bcType):0;
52   - }
  41 + @Override
  42 + public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
  43 + int diff = (int) (s1.getFcsjT() - s2.getFcsjT());
  44 + return diff != 0 ? diff : typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
  45 + }
  46 + }
  47 +
  48 + private static int typeOrder(String bcType) {
  49 + return bcTypeOrderMap.get(bcType) != null ? bcTypeOrderMap.get(bcType) : 0;
  50 + }
53 51  
54   - public static class DFSJ implements Comparator<ScheduleRealInfo>{
  52 + public static class DFSJ implements Comparator<ScheduleRealInfo> {
55 53  
56 54 static Logger logger = LoggerFactory.getLogger(DFSJ.class);
57 55  
58   - @Override
59   - public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
60   - try{
  56 + @Override
  57 + public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
  58 + try {
  59 + int diff;
  60 + if (!s2.isSflj() && !s1.isSflj()) {
  61 + diff = (int) (s1.getFcsjT() - s2.getFcsjT());
61 62  
62   - if(!s1.getXlBm().equals(s2.getXlBm()) || !s1.getLpName().equals(s2.getLpName())){
63   - int diff = (int) (s1.getDfsjT() - s2.getDfsjT());
64   - return diff!=0?diff:typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
65   - }
66   - else{
67   - /**
68   - * 按时刻表发车顺序号
69   - */
70   - Integer fc1 = s1.getFcno();
71   - Integer fc2 = s2.getFcno();
72   - if(null != fc1 && null != fc2){
73   - return fc1.intValue()==fc2.intValue()?0:fc1.intValue()-fc2.intValue();
74   - }
75   - else{
76   - int diff = (int) (s1.getDfsjT() - s2.getDfsjT());
77   - return diff!=0?diff:typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
78   - }
  63 + } else {
  64 + diff = (int) (s1.getDfsjT() - s2.getDfsjT());
79 65 }
80   - }catch (Exception e){
  66 +
  67 + return diff != 0 ? diff : typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
  68 +
  69 + } catch (Exception e) {
81 70 logger.error("排序异常", e);
82   - return s1.getDfsjT() - s2.getDfsjT() > 0?1:-1;
  71 + return s1.getDfsjT() - s2.getDfsjT() > 0 ? 1 : -1;
83 72 }
84   - }
85   - }
  73 + }
  74 + }
86 75  
87   - public static class DFSJ2 implements Comparator<ScheduleRealInfo>{
  76 + public static class DFSJ2 implements Comparator<ScheduleRealInfo> {
88 77  
89 78  
90 79 @Override
91 80 public int compare(ScheduleRealInfo s1, ScheduleRealInfo s2) {
92 81 int diff = (int) (s1.getDfsjT() - s2.getDfsjT());
93   - return diff!=0?diff:typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
  82 + return diff != 0 ? diff : typeOrder(s1.getBcType()) - typeOrder(s2.getBcType());
94 83 }
95 84 }
96 85 }
... ...
src/main/java/com/bsth/entity/calc/CalcStatistics.java
... ... @@ -6,6 +6,7 @@ import javax.persistence.Entity;
6 6 import javax.persistence.GeneratedValue;
7 7 import javax.persistence.Id;
8 8 import javax.persistence.Table;
  9 +import javax.persistence.Transient;
9 10  
10 11 @Entity
11 12 @Table(name = "calc_statistics")
... ... @@ -66,6 +67,8 @@ public class CalcStatistics {
66 67 private Double qtlc;
67 68 /* 临加公里*/
68 69 private Double ljlc;
  70 + /* 临加空驶公里*/
  71 + private Double ljkslc;
69 72 /* 计划班次*/
70 73 private int jhbcq;
71 74 /* 计划班次(早高峰)*/
... ... @@ -106,8 +109,9 @@ public class CalcStatistics {
106 109 private int djgsj;
107 110 /* 备注*/
108 111 private String remark;
109   -
110   -
  112 + /*分公司名字*/
  113 + @Transient
  114 + private String fgsName;
111 115 public Long getId() {
112 116 return id;
113 117 }
... ... @@ -270,6 +274,12 @@ public class CalcStatistics {
270 274 public void setLjlc(Double ljlc) {
271 275 this.ljlc = ljlc;
272 276 }
  277 + public Double getLjkslc() {
  278 + return ljkslc;
  279 + }
  280 + public void setLjkslc(Double ljkslc) {
  281 + this.ljkslc = ljkslc;
  282 + }
273 283 public int getJhbcq() {
274 284 return jhbcq;
275 285 }
... ... @@ -390,5 +400,11 @@ public class CalcStatistics {
390 400 public void setRemark(String remark) {
391 401 this.remark = remark;
392 402 }
  403 + public String getFgsName() {
  404 + return fgsName;
  405 + }
  406 + public void setFgsName(String fgsName) {
  407 + this.fgsName = fgsName;
  408 + }
393 409  
394 410 }
... ...
src/main/java/com/bsth/entity/mcy_forms/Operationservice.java
... ... @@ -17,6 +17,10 @@ public class Operationservice {
17 17 private String jname;
18 18  
19 19 private String clzbh;
  20 +
  21 + private String gs;
  22 +
  23 + private String fgs;
20 24  
21 25 public String getJname() {
22 26 return jname;
... ... @@ -89,6 +93,22 @@ public class Operationservice {
89 93 public void setXlBm(String xlBm) {
90 94 this.xlBm = xlBm;
91 95 }
  96 +
  97 + public String getGs() {
  98 + return gs;
  99 + }
  100 +
  101 + public void setGs(String gs) {
  102 + this.gs = gs;
  103 + }
  104 +
  105 + public String getFgs() {
  106 + return fgs;
  107 + }
  108 +
  109 + public void setFgs(String fgs) {
  110 + this.fgs = fgs;
  111 + }
92 112  
93 113  
94 114 }
... ...
src/main/java/com/bsth/entity/sheet/CalcSheet.java 0 → 100644
  1 +package com.bsth.entity.sheet;
  2 +
  3 +import javax.persistence.Entity;
  4 +import javax.persistence.GeneratedValue;
  5 +import javax.persistence.Id;
  6 +import javax.persistence.Table;
  7 +import javax.persistence.Transient;
  8 +
  9 +import com.bsth.data.BasicData;
  10 +
  11 +@Entity
  12 +@Table(name = "bsth_c_calc_sheet")
  13 +public class CalcSheet {
  14 + /* 主键*/
  15 + @Id
  16 + @GeneratedValue
  17 + private Integer id;
  18 + /* 公司代码*/
  19 + private String gsdm;
  20 + /* 分公司代码*/
  21 + private String fgsdm;
  22 + /* 日期字符串*/
  23 + private String date;
  24 + /* 线路编码*/
  25 + private String xl;
  26 + /* 线路名称*/
  27 + private String xlName;
  28 + /*计划首站发车数*/
  29 + private String jhszfcs;
  30 + /*实际首站发车正点数*/
  31 + private String sjszfczds;
  32 + /*首站发车正点率*/
  33 + private String szfczdl;
  34 + /*首站发车到达正点数*/
  35 + private String sjszddzds;
  36 + /*首站发车到达正点率*/
  37 + private String szddzdl;
  38 + /*计划出车数*/
  39 + private String jhcc;
  40 + /*实际出车数*/
  41 + private String sjcc;
  42 + /*早高峰实际出车*/
  43 + private String sjcczgf;
  44 + /*晚高峰实际出车*/
  45 + private String sjccwgf;
  46 + /*计划班次数*/
  47 + private String jhbcs;
  48 + /*实际班次数*/
  49 + private String sjbcs;
  50 + /*临加班次数*/
  51 + private String ljbcs;
  52 + /*公司名字*/
  53 + @Transient
  54 + private String gsname;
  55 + /*分公司名字*/
  56 + @Transient
  57 + private String fgsname;
  58 + public Integer getId() {
  59 + return id;
  60 + }
  61 + public void setId(Integer id) {
  62 + this.id = id;
  63 + }
  64 + public String getGsdm() {
  65 + return gsdm;
  66 + }
  67 + public void setGsdm(String gsdm) {
  68 + this.gsdm = gsdm;
  69 + }
  70 + public String getFgsdm() {
  71 + return fgsdm;
  72 + }
  73 + public void setFgsdm(String fgsdm) {
  74 + this.fgsdm = fgsdm;
  75 + }
  76 + public String getDate() {
  77 + return date;
  78 + }
  79 + public void setDate(String date) {
  80 + this.date = date;
  81 + }
  82 + public String getXl() {
  83 + return xl;
  84 + }
  85 + public void setXl(String xl) {
  86 + this.xl = xl;
  87 + }
  88 + public String getXlName() {
  89 + return xlName;
  90 + }
  91 + public void setXlName(String xlName) {
  92 + this.xlName = xlName;
  93 + }
  94 + public String getJhszfcs() {
  95 + return jhszfcs;
  96 + }
  97 + public void setJhszfcs(String jhszfcs) {
  98 + this.jhszfcs = jhszfcs;
  99 + }
  100 + public String getSjszfczds() {
  101 + return sjszfczds;
  102 + }
  103 + public void setSjszfczds(String sjszfczds) {
  104 + this.sjszfczds = sjszfczds;
  105 + }
  106 + public String getSzfczdl() {
  107 + return szfczdl;
  108 + }
  109 + public void setSzfczdl(String szfczdl) {
  110 + this.szfczdl = szfczdl;
  111 + }
  112 + public String getSjszddzds() {
  113 + return sjszddzds;
  114 + }
  115 + public void setSjszddzds(String sjszddzds) {
  116 + this.sjszddzds = sjszddzds;
  117 + }
  118 + public String getSzddzdl() {
  119 + return szddzdl;
  120 + }
  121 + public void setSzddzdl(String szddzdl) {
  122 + this.szddzdl = szddzdl;
  123 + }
  124 + public String getJhcc() {
  125 + return jhcc;
  126 + }
  127 + public void setJhcc(String jhcc) {
  128 + this.jhcc = jhcc;
  129 + }
  130 + public String getSjcc() {
  131 + return sjcc;
  132 + }
  133 + public void setSjcc(String sjcc) {
  134 + this.sjcc = sjcc;
  135 + }
  136 + public String getSjcczgf() {
  137 + return sjcczgf;
  138 + }
  139 + public void setSjcczgf(String sjcczgf) {
  140 + this.sjcczgf = sjcczgf;
  141 + }
  142 + public String getSjccwgf() {
  143 + return sjccwgf;
  144 + }
  145 + public void setSjccwgf(String sjccwgf) {
  146 + this.sjccwgf = sjccwgf;
  147 + }
  148 + public String getJhbcs() {
  149 + return jhbcs;
  150 + }
  151 + public void setJhbcs(String jhbcs) {
  152 + this.jhbcs = jhbcs;
  153 + }
  154 + public String getSjbcs() {
  155 + return sjbcs;
  156 + }
  157 + public void setSjbcs(String sjbcs) {
  158 + this.sjbcs = sjbcs;
  159 + }
  160 + public String getLjbcs() {
  161 + return ljbcs;
  162 + }
  163 + public void setLjbcs(String ljbcs) {
  164 + this.ljbcs = ljbcs;
  165 + }
  166 +
  167 + public String getGsname() {
  168 + return BasicData.businessCodeNameMap.get(this.gsdm);
  169 + }
  170 +
  171 + public void setGsname(String gsname) {
  172 + this.gsname = gsname;
  173 + }
  174 +
  175 +
  176 + public String getFgsname() {
  177 + return BasicData.businessFgsCodeNameMap.get(this.fgsdm+"_"+this.gsdm);
  178 + }
  179 +
  180 + public void setFgsname(String fgsname) {
  181 + this.fgsname = fgsname;
  182 + }
  183 +}
... ...
src/main/java/com/bsth/repository/LsStationRouteRepository.java
1 1 package com.bsth.repository;
2 2  
3 3 import java.util.List;
  4 +import java.util.Map;
4 5  
5 6 import org.springframework.data.jpa.repository.EntityGraph;
6 7 import org.springframework.data.jpa.repository.Modifying;
... ... @@ -52,4 +53,21 @@ public interface LsStationRouteRepository extends BaseRepository&lt;LsStationRoute,
52 53 @Modifying
53 54 @Query(value="UPDATE bsth_c_ls_stationroute set destroy = 1 where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true)
54 55 public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions);
  56 +
  57 + /**
  58 + * 按线路编码查询各站点的顺序号
  59 + * @param lineCode 线路编码
  60 + * @param lineVersion 版本号
  61 + * @return
  62 + */
  63 + @Query("SELECT new map(" +
  64 + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +
  65 + "line.linePlayType as linePlayType,s.stationMark as stationMark) " +
  66 + "FROM " +
  67 + "LsStationRoute s " +
  68 + "WHERE " +
  69 + "s.destroy = 0 AND s.lineCode = ?1 AND s.versions = ?2 " +
  70 + "ORDER BY " +
  71 + "lineCode,directions,stationRouteCode")
  72 + List<Map<String, String>> findLineWithLineCode4Ygc(String lineCode,Integer lineVersion);
55 73 }
... ...
src/main/java/com/bsth/repository/calc/CalcStatisticsRepository.java
... ... @@ -6,8 +6,10 @@ import javax.transaction.Transactional;
6 6  
7 7 import com.bsth.entity.calc.CalcStatistics;
8 8 import com.bsth.entity.calc.CalcWaybill;
  9 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
9 10 import com.bsth.repository.BaseRepository;
10 11  
  12 +import org.springframework.data.jpa.repository.EntityGraph;
11 13 import org.springframework.data.jpa.repository.Modifying;
12 14 import org.springframework.data.jpa.repository.Query;
13 15 import org.springframework.stereotype.Repository;
... ... @@ -19,11 +21,11 @@ import org.springframework.stereotype.Repository;
19 21 public interface CalcStatisticsRepository extends BaseRepository<CalcStatistics, Integer>{
20 22  
21 23 //按照时间段统计,公司下线路
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")
  24 + @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.fgsdm,c.xl")
23 25 List<CalcStatistics> selectByDateAndLineTj(String line,String date,String date2,String gsdm,String fgsdm);
24 26  
25 27 //按照时间段统计,单条线路
26   - @Query(value="select DISTINCT c from CalcStatistics c where c.xl = ?1 and c.dateStr between ?2 and ?3 order by c.xl")
  28 + @Query(value="select DISTINCT c from CalcStatistics c where c.xl = ?1 and c.dateStr between ?2 and ?3 order by c.fgsdm,c.xl")
27 29 List<CalcStatistics> selectByDateAndLineTj2(String line,String date,String date2);
28 30  
29 31 //按照日期和线路删除数据
... ... @@ -38,4 +40,8 @@ public interface CalcStatisticsRepository extends BaseRepository&lt;CalcStatistics,
38 40 @Query(value = "delete CalcStatistics c where c.dateStr=?1")
39 41 void deleteByDate(String date);
40 42  
  43 + //按照时间段查询实际排班(分公司条件不可为空)
  44 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  45 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr between ?2 and ?3 and gsBm = ?4 and fgsBm = ?5 order by s.fgsBm, s.xlBm")
  46 + List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date,String date2,String gsdm,String fgsdm);
41 47 }
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -180,12 +180,12 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
180 180  
181 181 //按照时间段统计
182 182 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
183   - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr between ?2 and ?3 and gsBm = ?4 and fgsBm = ?5 order by s.xlBm")
  183 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and s.scheduleDateStr between ?2 and ?3 and gsBm = ?4 and fgsBm like %?5% order by s.fgsBm, s.xlBm")
184 184 List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2,String gsdm,String fgsdm);
185 185  
186 186 //按照时间段统计
187 187 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
188   - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 and s.scheduleDateStr<= ?3 order by s.xlBm")
  188 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDateStr >= ?2 and s.scheduleDateStr<= ?3 order by s.fgsBm,s.xlBm")
189 189 List<ScheduleRealInfo> scheduleByDateAndLineTj2(String line,String date,String date2);
190 190 //月报表
191 191 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
... ...
src/main/java/com/bsth/repository/sheet/CalcSheetRepository.java 0 → 100644
  1 +package com.bsth.repository.sheet;
  2 +
  3 +import com.bsth.entity.sheet.CalcSheet;
  4 +import com.bsth.repository.BaseRepository;
  5 +
  6 +import org.springframework.stereotype.Repository;
  7 +
  8 +/**
  9 + *
  10 + */
  11 +@Repository
  12 +public interface CalcSheetRepository extends BaseRepository<CalcSheet, Integer>{
  13 +
  14 +}
... ...
src/main/java/com/bsth/repository/sys/ResourceRepository.java
... ... @@ -10,5 +10,5 @@ import com.bsth.repository.BaseRepository;
10 10 @Repository
11 11 public interface ResourceRepository extends BaseRepository<Resource, Integer> {
12 12  
13   - List<Resource> findByRolesId(Integer roleId);
  13 + List<Resource> findByRolesId(Integer roleId);
14 14 }
... ...
src/main/java/com/bsth/service/LineService.java
... ... @@ -37,4 +37,6 @@ public interface LineService extends BaseService&lt;Line, Integer&gt; {
37 37 Map<String, Object> update(Line l);
38 38  
39 39 Map<String,Object> remove(Integer id);
  40 +
  41 + Map<String, Boolean> lineNature();
40 42 }
... ...
src/main/java/com/bsth/service/calc/CalcWaybillService.java
... ... @@ -30,9 +30,9 @@ public interface CalcWaybillService extends BaseService&lt;CalcWaybill, Integer&gt; {
30 30 */
31 31 String calcDaily(String rq, String line) throws Exception;
32 32  
33   - List<CalcStatistics> calcStatisticsDaily(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type);
  33 + List<CalcStatistics> calcStatisticsDaily(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type,String nature);
34 34  
35   - List<Map<String, Object>> calcStatisticsDaily2(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type);
  35 + List<Map<String, Object>> calcStatisticsDaily2(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type,String nature);
36 36  
37 37 Map<String, Object> calcLineMileage(String date, String line);
38 38  
... ...
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
... ... @@ -20,6 +20,7 @@ import java.util.Set;
20 20 import javax.transaction.Transactional;
21 21  
22 22 import com.bsth.common.ResponseCode;
  23 +import com.bsth.data.BasicData;
23 24 import com.bsth.entity.Line;
24 25 import com.bsth.entity.calc.CalcBusMileage;
25 26 import com.bsth.entity.calc.CalcInterval;
... ... @@ -36,6 +37,7 @@ import com.bsth.repository.calc.CalcLineMileageRepository;
36 37 import com.bsth.repository.calc.CalcStatisticsRepository;
37 38 import com.bsth.repository.calc.CalcWaybillRepository;
38 39 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  40 +import com.bsth.service.LineService;
39 41 import com.bsth.service.calc.CalcToolService;
40 42 import com.bsth.service.calc.CalcWaybillService;
41 43 import com.bsth.service.impl.BaseServiceImpl;
... ... @@ -91,7 +93,8 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
91 93  
92 94 @Autowired
93 95 private LineRepository lineRepository;
94   -
  96 + @Autowired
  97 + private LineService lineService;
95 98 @Autowired
96 99 private ReportService reportService;
97 100  
... ... @@ -550,7 +553,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
550 553  
551 554 //查询所有线路
552 555 for(Map<String, String> m : gsList){
553   - list.addAll(scheduleRealInfoRepository.scheduleByDateAndLineTj(line, rq, rq, m.get("gsdm"), m.get("fgsdm")));
  556 + list.addAll(calcStatisticsRepository.scheduleByDateAndLine(line, rq, rq, m.get("gsdm"), m.get("fgsdm")));
554 557 }
555 558  
556 559 for (int i = 0; i < list.size(); i++) {
... ... @@ -641,6 +644,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
641 644 double sjyygl= culateService.culateSjgl(lists);
642 645 double zyygl= Arith.add(sjyygl,ljgl);
643 646  
  647 + double ljksgl= culateService.culateLjksgl(lists);
644 648 double sjjccgl=culateService.culateJccgl(lists);
645 649 double sjksgl=culateService.culateKsgl(lists);
646 650 double zksgl=Arith.add(sjjccgl, sjksgl);
... ... @@ -648,6 +652,8 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
648 652 s.setSjkslc(zksgl);
649 653 s.setSjzlc(Arith.add(zyygl, zksgl));
650 654  
  655 + s.setLjkslc(ljksgl);
  656 +
651 657 s.setSslc(culateService.culateLbgl(list));
652 658 s.setSsbc(culateService.culateLbbc(list));
653 659  
... ... @@ -733,28 +739,51 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
733 739  
734 740 @Override
735 741 public List<CalcStatistics> calcStatisticsDaily(String gsdm, String fgsdm,
736   - String line, String date, String date2, String xlName, String type) {
  742 + String line, String date, String date2, String xlName, String type,String nature) {
737 743 // TODO Auto-generated method stub
738   - List<CalcStatistics> list = new ArrayList<CalcStatistics>();
  744 + List<CalcStatistics> listAll = new ArrayList<CalcStatistics>();
739 745 if(line.length() > 0){
740   - list = calcStatisticsRepository.selectByDateAndLineTj2(line, date, date2);
  746 + listAll = calcStatisticsRepository.selectByDateAndLineTj2(line, date, date2);
741 747 } else {
742   - list = calcStatisticsRepository.selectByDateAndLineTj(line, date, date2, gsdm, fgsdm);
  748 + listAll = calcStatisticsRepository.selectByDateAndLineTj(line, date, date2, gsdm, fgsdm);
  749 + }
  750 + Map<String, Boolean> lineMap=lineService.lineNature();
  751 + List<CalcStatistics> list = new ArrayList<CalcStatistics>();
  752 + if(nature.equals("0")){
  753 + list=listAll;
  754 + }else{
  755 + for (int i = 0; i < listAll.size(); i++) {
  756 + CalcStatistics c=listAll.get(i);
  757 + if(nature.equals("1")){
  758 + if(lineMap.get(c.getXl())){
  759 + list.add(c);
  760 + }
  761 + }else{
  762 + if(!lineMap.get(c.getXl())){
  763 + list.add(c);
  764 + }
  765 + }
  766 + }
743 767 }
744   -
745 768 List<CalcStatistics> resList = new ArrayList<CalcStatistics>();
746 769 Map<String, List<CalcStatistics>> keyMap = new HashMap<String, List<CalcStatistics>>();
747 770 List<String> keyList = new ArrayList<String>();
748 771  
749 772 for(CalcStatistics s : list){
750 773 try {
751   - String key = PinyinHelper.convertToPinyinString(s.getXlName(), "" , PinyinFormat.WITHOUT_TONE);
752   - if(!keyMap.containsKey(key)){
  774 +// String key = PinyinHelper.convertToPinyinString(s.getXl(), "" , PinyinFormat.WITHOUT_TONE);
  775 + String key =s.getFgsdm()+s.getXl();
  776 +// if(line.equals("")){
  777 +// key =s.getFgsdm()+s.getXl();
  778 +// }else{
  779 +// key =s.getXl();
  780 +// }
  781 + if(!keyMap.containsKey(key)){
753 782 keyMap.put(key, new ArrayList<CalcStatistics>());
754 783 keyList.add(key);
755 784 }
756 785 keyMap.get(key).add(s);
757   - } catch (PinyinException e) {
  786 + } catch (Exception e) {
758 787 // TODO Auto-generated catch block
759 788 e.printStackTrace();
760 789 }
... ... @@ -769,6 +798,13 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
769 798 CalcStatistics s_ = keyMap.get(key).get(i);
770 799 s = addStatistics(s, s_);
771 800 }
  801 +// if(line.equals("")){
  802 + s.setFgsName(BasicData.businessFgsCodeNameMap.get(s.getFgsdm()+"_"+s.getGsdm()));
  803 + /*}else{
  804 + List<Line> l=lineRepository.findLineByCode(line);
  805 + if(l.size()>0)
  806 + s.setFgsName(BasicData.businessFgsCodeNameMap.get(l.get(0).getBrancheCompany()+"_"+l.get(0).getCompany()));
  807 + }*/
772 808 resList.add(s);
773 809 }
774 810 }
... ... @@ -776,6 +812,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
776 812 if(resList.size() > 0){
777 813 CalcStatistics temp = new CalcStatistics();
778 814 temp.setXlName("合计");
  815 + temp.setFgsName("");
779 816 for(CalcStatistics s : resList){
780 817 temp = addStatistics(temp, s);
781 818 }
... ... @@ -785,6 +822,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
785 822 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
786 823 for(CalcStatistics c : resList){
787 824 Map<String, Object> m = new HashMap<String, Object>();
  825 + m.put("fgsName", c.getFgsName());
788 826 m.put("xlName", c.getXlName());
789 827 m.put("jhzlc", c.getJhzlc());
790 828 m.put("jhlc", c.getJhyylc());
... ... @@ -806,6 +844,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
806 844 m.put("ssgl_yw", c.getYwlc());
807 845 m.put("ssgl_other", c.getQtlc());
808 846 m.put("ljgl", c.getLjlc());
  847 + m.put("ljks", c.getLjkslc());
809 848 m.put("jhbc", c.getJhbcq());
810 849 m.put("jhbc_m", c.getJhbcz());
811 850 m.put("jhbc_a", c.getJhbcw());
... ... @@ -859,7 +898,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
859 898  
860 899 @Override
861 900 public List<Map<String, Object>> calcStatisticsDaily2(String gsdm, String fgsdm,
862   - String line, String date, String date2, String xlName, String type) {
  901 + String line, String date, String date2, String xlName, String type,String nature) {
863 902 // TODO Auto-generated method stub
864 903 SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
865 904 Date beginDate = new Date();
... ... @@ -899,26 +938,48 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
899 938 }
900 939  
901 940  
902   - List<CalcStatistics> list = new ArrayList<CalcStatistics>();
  941 + List<CalcStatistics> listAll = new ArrayList<CalcStatistics>();
903 942 if(line.length() > 0){
904   - list = calcStatisticsRepository.selectByDateAndLineTj2(line, d1, d2);
  943 + listAll = calcStatisticsRepository.selectByDateAndLineTj2(line, d1, d2);
905 944 } else {
906   - list = calcStatisticsRepository.selectByDateAndLineTj(line, d1, d2, gsdm, fgsdm);
  945 + listAll = calcStatisticsRepository.selectByDateAndLineTj(line, d1, d2, gsdm, fgsdm);
907 946 }
  947 + Map<String, Boolean> lineMap=lineService.lineNature();
  948 + List<CalcStatistics> list=new ArrayList<CalcStatistics>();
908 949  
  950 + for (int i = 0; i < listAll.size(); i++) {
  951 + CalcStatistics s=listAll.get(i);
  952 + if(nature.equals("0")){
  953 + list.add(s);
  954 + }else if(nature.equals("1")){
  955 + if(lineMap.containsKey(s.getXl()) && lineMap.get(s.getXl())){
  956 + list.add(s);
  957 + }
  958 + }else{
  959 + if(lineMap.containsKey(s.getXl()) && !lineMap.get(s.getXl())){
  960 + list.add(s);
  961 + }
  962 + }
  963 + }
909 964 List<CalcStatistics> resList = new ArrayList<CalcStatistics>();
910 965 Map<String, List<CalcStatistics>> keyMap = new HashMap<String, List<CalcStatistics>>();
911 966 List<String> keyList = new ArrayList<String>();
912 967  
913 968 for(CalcStatistics s : list){
914 969 try {
915   - String key = PinyinHelper.convertToPinyinString(s.getXlName(), "" , PinyinFormat.WITHOUT_TONE);
916   - if(!keyMap.containsKey(key)){
  970 +// String key = PinyinHelper.convertToPinyinString(s.getXlName(), "" , PinyinFormat.WITHOUT_TONE);
  971 + String key =s.getFgsdm()+s.getXl();
  972 +// if(line.equals("")){
  973 +// key =s.getFgsdm()+s.getXl();
  974 +// }else{
  975 +// key =s.getXl();
  976 +// }
  977 + if(!keyMap.containsKey(key)){
917 978 keyMap.put(key, new ArrayList<CalcStatistics>());
918 979 keyList.add(key);
919 980 }
920 981 keyMap.get(key).add(s);
921   - } catch (PinyinException e) {
  982 + } catch (Exception e) {
922 983 // TODO Auto-generated catch block
923 984 e.printStackTrace();
924 985 }
... ... @@ -950,6 +1011,13 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
950 1011 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
951 1012 for(CalcStatistics c : resList){
952 1013 Map<String, Object> m = new HashMap<String, Object>();
  1014 + if(c.getXl().equals("hj")){
  1015 + m.put("fgsName", "");
  1016 + m.put("fgsBm", "");
  1017 + }else{
  1018 + m.put("fgsName", BasicData.businessFgsCodeNameMap.get(c.getFgsdm()+"_"+c.getGsdm()));
  1019 + m.put("fgsBm", c.getFgsdm());
  1020 + }
953 1021 m.put("xlBm", c.getXl());
954 1022 m.put("xlName", c.getXlName());
955 1023 m.put("jhzlc", c.getJhzlc());
... ... @@ -972,6 +1040,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
972 1040 m.put("ssgl_yw", c.getYwlc());
973 1041 m.put("ssgl_other", c.getQtlc());
974 1042 m.put("ljgl", c.getLjlc());
  1043 + m.put("ljks", c.getLjkslc());
975 1044 m.put("jhbc", c.getJhbcq());
976 1045 m.put("jhbc_m", c.getJhbcz());
977 1046 m.put("jhbc_a", c.getJhbcw());
... ... @@ -1003,7 +1072,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1003 1072 //实时数据
1004 1073 List<Map<String, Object>> tjlist=new ArrayList<Map<String, Object>>();
1005 1074 if(!d4.equals("")){
1006   - tjlist= scheduleRealInfoService.statisticsDailyTjHb(gsdm, fgsdm, line, d3, d4, xlName, type);
  1075 + tjlist= scheduleRealInfoService.statisticsDailyTjHb(gsdm, fgsdm, line, d3, d4, xlName, type,nature);
1007 1076 }
1008 1077 List<Map<String, Object>> mapListHj = new ArrayList<Map<String, Object>>();
1009 1078 // List<String> lineList=new ArrayList<String>();
... ... @@ -1011,24 +1080,37 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1011 1080 mapList.addAll(tjlist);
1012 1081 for (int i = 0; i < mapList.size(); i++) {
1013 1082 Map<String, Object> m =mapList.get(i);
1014   - if(kMap.get(m.get("xlBm").toString())==null){
1015   - kMap.put(m.get("xlBm").toString(), m.get("xlBm").toString());
1016   - }
  1083 +// if(line.equals("")){
  1084 + if(kMap.get(m.get("fgsBm")+"_"+m.get("xlBm").toString())==null){
  1085 + kMap.put(m.get("fgsBm")+"_"+m.get("xlBm").toString(), m.get("fgsBm")+"_"+m.get("xlBm").toString());
  1086 + }
  1087 +// }else{
  1088 +// if(kMap.get(m.get("xlBm").toString())==null){
  1089 +// kMap.put(m.get("xlBm").toString(), m.get("xlBm").toString());
  1090 +// }
  1091 +// }
  1092 +
1017 1093 }
1018 1094 for (Object xlbm : kMap.keySet()) {
1019 1095 Map<String, Object> hjMap = new HashMap<String, Object>();
1020 1096 for (int i = 0; i < mapList.size(); i++) {
1021 1097 Map<String, Object> lsMap=mapList.get(i);
1022   - if (lsMap.get("xlBm").toString().equals(xlbm)) {
  1098 + String xlbm_="";
  1099 +// if(line.equals("")){
  1100 + xlbm_=lsMap.get("fgsBm").toString()+"_"+lsMap.get("xlBm").toString();
  1101 +// }else{
  1102 +// xlbm_=lsMap.get("xlBm").toString();
  1103 +// }
  1104 + if (xlbm_.equals(xlbm)) {
1023 1105 if(hjMap.get("xlBm")==null){
1024 1106 hjMap.put("xlBm", lsMap.get("xlBm"));
1025 1107 hjMap.put("xlName", lsMap.get("xlName"));
  1108 + hjMap.put("fgsName", lsMap.get("fgsName"));
1026 1109 try {
1027 1110 if(lsMap.get("xlBm").toString().equals("hj")){
1028 1111 hjMap.put("xlNamePy", "zzzzz");
1029   -
1030 1112 }else{
1031   - hjMap.put("xlNamePy", PinyinHelper.convertToPinyinString(lsMap.get("xlName").toString(), "", PinyinFormat.WITHOUT_TONE));
  1113 + hjMap.put("xlNamePy", PinyinHelper.convertToPinyinString(lsMap.get("fgsBm").toString()+lsMap.get("xlName").toString(), "", PinyinFormat.WITHOUT_TONE));
1032 1114 }
1033 1115 } catch (PinyinException e) {
1034 1116 // TODO Auto-generated catch block
... ... @@ -1055,6 +1137,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1055 1137 hjMap.put("ssgl_yw", Arith.add(lsMap.get("ssgl_yw"), hjMap.get("ssgl_yw")==null?"0":hjMap.get("ssgl_yw")));
1056 1138 hjMap.put("ssgl_other", Arith.add(lsMap.get("ssgl_other"), hjMap.get("ssgl_other")==null?"0":hjMap.get("ssgl_other")));
1057 1139 hjMap.put("ljgl", Arith.add(lsMap.get("ljgl"), hjMap.get("ljgl")==null?"0":hjMap.get("ljgl")));
  1140 + hjMap.put("ljks", Arith.add(lsMap.get("ljks"), hjMap.get("ljks")==null?"0":hjMap.get("ljks")));
1058 1141 hjMap.put("jhbc", Integer.parseInt(lsMap.get("jhbc").toString())+ Integer.parseInt(hjMap.get("jhbc")==null?"0":hjMap.get("jhbc").toString()));
1059 1142 hjMap.put("jhbc_m", Integer.parseInt(lsMap.get("jhbc_m").toString())+Integer.parseInt(hjMap.get("jhbc_m")==null?"0":hjMap.get("jhbc_m").toString()));
1060 1143 hjMap.put("jhbc_a", Integer.parseInt(lsMap.get("jhbc_a").toString())+ Integer.parseInt(hjMap.get("jhbc_a")==null?"0":hjMap.get("jhbc_a").toString()));
... ... @@ -1082,8 +1165,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1082 1165 hjMap.put("djg_time",hjMap.get("djg_time"));
1083 1166 }
1084 1167 }
1085   -
1086   -
1087 1168 double jl = Arith.sub(Arith.add(hjMap.get("jhlc"), hjMap.get("ljgl")), hjMap.get("ssgl"));
1088 1169 if (jl == Double.parseDouble(hjMap.get("sjgl").toString())) {
1089 1170 hjMap.put("zt", 0);
... ... @@ -1097,7 +1178,15 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1097 1178  
1098 1179 Collections.sort(mapListHj, new AccountXlbmByping());
1099 1180  
1100   -
  1181 + /*if(!line.equals("")){
  1182 + for (int i = 0; i < mapListHj.size(); i++) {
  1183 + if(mapListHj.get(i).get("xlBm").equals(line)){
  1184 + List<Line> l=lineRepository.findLineByCode(line);
  1185 + if(l.size()>0)
  1186 + mapListHj.get(i).put("fgsName", BasicData.businessFgsCodeNameMap.get(l.get(0).getBrancheCompany()+"_"+l.get(0).getCompany()));
  1187 + }
  1188 + }
  1189 + }*/
1101 1190 if (type != null && type.length() != 0 && type.equals("export")) {
1102 1191 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
1103 1192 sdfSimple = new SimpleDateFormat("yyyyMMdd");
... ... @@ -1115,7 +1204,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1115 1204 }
1116 1205 listI.add(mapListHj.iterator());
1117 1206 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
1118   - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_.xls",
  1207 + ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls",
1119 1208 path + "export/" + dateTime + "-" + xlName + "-统计日报.xls");
1120 1209 } catch (Exception e) {
1121 1210 // TODO: handle exception
... ... @@ -1148,6 +1237,10 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
1148 1237 s.setYwlc(Arith.add(s.getYwlc()!=null?s.getYwlc():0, s_.getYwlc()));
1149 1238 s.setQtlc(Arith.add(s.getQtlc()!=null?s.getQtlc():0, s_.getQtlc()));
1150 1239 s.setLjlc(Arith.add(s.getLjlc()!=null?s.getLjlc():0, s_.getLjlc()));
  1240 + if(s_.getLjkslc() == null){
  1241 + s_.setLjkslc(0d);
  1242 + }
  1243 + s.setLjkslc(Arith.add(s.getLjkslc()!=null?s.getLjkslc():0, s_.getLjkslc()));
1151 1244 s.setJhbcq(s.getJhbcq() + s_.getJhbcq());
1152 1245 s.setJhbcz(s.getJhbcz() + s_.getJhbcz());
1153 1246 s.setJhbcw(s.getJhbcw() + s_.getJhbcw());
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -28,7 +28,6 @@ import com.bsth.entity.mcy_forms.Operationservice;
28 28 import com.bsth.entity.mcy_forms.Shifday;
29 29 import com.bsth.entity.mcy_forms.Shiftuehiclemanth;
30 30 import com.bsth.entity.mcy_forms.Singledata;
31   -import com.bsth.entity.mcy_forms.Turnoutrate;
32 31 import com.bsth.entity.mcy_forms.Vehicleloading;
33 32 import com.bsth.entity.mcy_forms.Waybillday;
34 33 import com.bsth.entity.oil.Dlb;
... ... @@ -45,6 +44,7 @@ import com.bsth.entity.mcy_forms.Allline;
45 44 import com.bsth.entity.mcy_forms.Changetochange;
46 45 import com.bsth.entity.mcy_forms.Daily;
47 46 import com.bsth.entity.mcy_forms.Executionrate;
  47 +import com.bsth.service.LineService;
48 48 import com.bsth.service.forms.CommonService;
49 49 import com.bsth.service.forms.FormsService;
50 50 import com.bsth.service.realcontrol.ScheduleRealInfoService;
... ... @@ -61,6 +61,9 @@ public class FormsServiceImpl implements FormsService {
61 61 ScheduleRealInfoService scheduleRealInfoService;
62 62  
63 63 @Autowired
  64 + LineService lineService;
  65 +
  66 + @Autowired
64 67 CommonService commonService;
65 68  
66 69 @Autowired
... ... @@ -214,11 +217,11 @@ public class FormsServiceImpl implements FormsService {
214 217 sql+=" and l.line_code=" + map.get("line").toString();
215 218 }
216 219 sql+= " AND r.gs_bm is not null";
217   - if(map.get("gsdmLine").toString()!=""){
  220 + if(map.get("gsdmLine") != null && map.get("gsdmLine").toString()!=""){
218 221 sql+=" and r.gs_bm='"+map.get("gsdmLine").toString()+"' ";
219 222 }
220   - if(map.get("fgsdmLine").toString()!=""){
221   - sql+=" and r.fgs_bm='"+map.get("fgsdmLine").toString()+"'";
  223 + if(map.get("fgsdmLine") != null && map.get("fgsdmLine").toString()!=""){
  224 + sql+=" and r.fgs_bm='"+map.get("fgsdmLine").toString()+"' ";
222 225 }
223 226 sql += " GROUP BY s.station_name,l.name,r.gs_bm,r.gs_name,r.fgs_bm,r.fgs_name ";
224 227 List<Linepasswengerflow> list = jdbcTemplate.query(sql, new RowMapper<Linepasswengerflow>() {
... ... @@ -244,10 +247,10 @@ public class FormsServiceImpl implements FormsService {
244 247 final String empnames=map.get("empnames").toString();
245 248 String gsdmManth="";
246 249 String fgsdmManth="";
247   - if(map.containsKey("gsdmManth")){
  250 + if(map.get("gsdmManth") != null){
248 251 gsdmManth=map.get("gsdmManth").toString();
249 252 }
250   - if(map.containsKey("fgsdmManth")){
  253 + if(map.get("fgsdmManth") != null){
251 254 fgsdmManth=map.get("fgsdmManth").toString();
252 255 }
253 256 String sql ="select ";
... ... @@ -410,10 +413,10 @@ public class FormsServiceImpl implements FormsService {
410 413 final String empnames=map.get("empnames").toString();
411 414 String gsdmManth="";
412 415 String fgsdmManth="";
413   - if(map.containsKey("gsdmManth")){
  416 + if(map.get("gsdmManth")!=null){
414 417 gsdmManth=map.get("gsdmManth").toString();
415 418 }
416   - if(map.containsKey("fgsdmManth")){
  419 + if(map.get("fgsdmManth")!=null){
417 420 fgsdmManth=map.get("fgsdmManth").toString();
418 421 }
419 422 String sql ="select ";
... ... @@ -766,6 +769,10 @@ public class FormsServiceImpl implements FormsService {
766 769  
767 770 rq = rq2 + "-" + rq3;
768 771  
  772 + String sfyy="";
  773 + if(map.get("sfyy")!=null){
  774 + sfyy=map.get("sfyy").toString();
  775 + }
769 776 String line="";
770 777 if(map.get("line")!=null){
771 778 line=map.get("line").toString().trim();
... ... @@ -784,21 +791,23 @@ public class FormsServiceImpl implements FormsService {
784 791  
785 792 if(!line.equals("")){
786 793 sql +=" and xl= '"+line+"'";
787   - }else{
788   - sql += " and gs= '"+gs+"' and fgs= '"+fgs+"'";
  794 + }
  795 + if(!gs.equals("")){
  796 + sql += " and gs= '"+gs+"'";
  797 + }
  798 + if(!fgs.equals("")){
  799 + sql += " and fgs= '"+fgs+"'";
789 800 }
790 801  
791 802 sql +=" order by rq";
792 803 List<Changetochange> list = jdbcTemplate.query(sql, new RowMapper<Changetochange>() {
793   -
794   -
795 804 @Override
796 805 public Changetochange mapRow(ResultSet arg0, int arg1) throws SQLException {
797 806 Changetochange chan = new Changetochange();
798 807 chan.setRq(arg0.getString("rq"));
799 808 chan.setGs(BasicData.businessCodeNameMap.get(arg0.getString("gs")));
800 809 chan.setFgs(BasicData.businessFgsCodeNameMap.get(arg0.getString("fgs")+"_"+arg0.getString("gs")));
801   - chan.setXl(BasicData.lineCode2NameMap.get(arg0.getString("xl")));
  810 + chan.setXl(arg0.getString("xl"));
802 811 chan.setLp(arg0.getString("lp"));
803 812 chan.setFssj(arg0.getString("fssj"));
804 813 chan.setXgsj(arg0.getString("xgsj"));
... ... @@ -813,13 +822,42 @@ public class FormsServiceImpl implements FormsService {
813 822 return chan;
814 823 }
815 824 });
816   - return list;
  825 +
  826 + Map<String, Boolean> lineNature = lineService.lineNature();
  827 + List<Changetochange> resList = new ArrayList<Changetochange>();
  828 +
  829 + for(Changetochange c : list){
  830 + String xl = c.getXl();
  831 + if(sfyy.length() != 0){
  832 + if(sfyy.equals("0")){
  833 + resList.add(c);
  834 + } else if(sfyy.equals("1")){
  835 + if(lineNature.containsKey(xl) && lineNature.get(xl)){
  836 + resList.add(c);
  837 + }
  838 + } else {
  839 + if(lineNature.containsKey(xl) && !lineNature.get(xl)){
  840 + resList.add(c);
  841 + }
  842 + }
  843 + } else {
  844 + resList.add(c);
  845 + }
  846 +
  847 + c.setXl(BasicData.lineCode2NameMap.get(xl));
  848 + }
  849 +
  850 + return resList;
817 851 }
818 852  
819 853  
820 854 // 路单数据
821 855 @Override
822 856 public List<Singledata> singledatatj(Map<String, Object> map) {
  857 + String sfyy="";
  858 + if(map.get("sfyy")!=null){
  859 + sfyy=map.get("sfyy").toString();
  860 + }
823 861 String gsdm="";
824 862 if(map.get("gsdmSing")!=null){
825 863 gsdm=map.get("gsdmSing").toString();
... ... @@ -843,16 +881,20 @@ public class FormsServiceImpl implements FormsService {
843 881 List<Singledata> list_=new ArrayList<Singledata>();
844 882 if(tjtype.equals("jsy")){
845 883 //油统计
846   - String sql="select r.j_gh, r.xl_bm,r.cl_zbh,r.j_name"
  884 + String sql="select r.j_gh, r.xl_bm,r.cl_zbh,r.j_name,r.fgs_bm"
847 885 + " from bsth_c_s_sp_info_real r where "
848 886 + " r.schedule_date_str = '"+startDate+"'";
849   - if(xlbm.equals("")){
850   - sql +="and r.gs_bm='"+gsdm+"' "
851   - + " and r.fgs_bm='"+fgsdm+"'";
852   - }else{
  887 + if(xlbm.length() != 0){
853 888 sql += " and r.xl_bm = '"+xlbm+"'";
854 889 }
855   - sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.j_name order by r.xl_bm,r.cl_zbh";
  890 + if(gsdm.length() != 0){
  891 + sql += " and r.gs_bm ='"+gsdm+"'";
  892 + }
  893 + if(fgsdm.length() != 0){
  894 + sql += " and r.fgs_bm ='"+fgsdm+"'";
  895 + }
  896 + sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.j_name order by r.xl_bm,r.cl_zbh";
  897 +
856 898 list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
857 899 @Override
858 900 public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {
... ... @@ -861,20 +903,30 @@ public class FormsServiceImpl implements FormsService {
861 903 sin.setJsy(arg0.getString("j_gh"));
862 904 sin.setjName(arg0.getString("j_name"));
863 905 sin.setClzbh(arg0.getString("cl_zbh"));
  906 + sin.setgS(arg0.getString("fgs_bm"));
864 907 return sin;
865 908 }
866 909 });
  910 +
  911 + Collections.sort(list,new SingledataByXlbm());
  912 +
867 913 String linesql="";
868 914 if(!xlbm.equals("")){
869 915 linesql +=" and xlbm ='"+xlbm+"' ";
870 916 }
871   - String nysql="SELECT id,xlbm,nbbm, jsy,jzl as jzl,yh as yh,sh as sh FROM bsth_c_ylb "
  917 + if(!gsdm.equals("")){
  918 + linesql +=" and ssgsdm ='"+gsdm+"' ";
  919 + }
  920 + if(!fgsdm.equals("")){
  921 + linesql +=" and fgsdm ='"+fgsdm+"' ";
  922 + }
  923 + String nysql="SELECT id,xlbm,nbbm,jsy,jzl as jzl,yh as yh,sh as sh,fgsdm FROM bsth_c_ylb"
872 924 + " WHERE rq = '"+startDate+"'"
873   - + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'" +linesql
  925 + + linesql
874 926 + " union"
875   - + " SELECT id,xlbm,nbbm,jsy,cdl as jzl,hd as yh,sh as sh FROM bsth_c_dlb"
  927 + + " SELECT id,xlbm,nbbm,jsy,cdl as jzl,hd as yh,sh as sh,fgsdm FROM bsth_c_dlb"
876 928 + " WHERE rq = '"+startDate+"'"
877   - + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'"+linesql;
  929 + + linesql;
878 930 List<Singledata> listNy = jdbcTemplate.query(nysql, new RowMapper<Singledata>() {
879 931 @Override
880 932 public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {
... ... @@ -885,6 +937,7 @@ public class FormsServiceImpl implements FormsService {
885 937 sin.setJzl(arg0.getString("jzl"));
886 938 sin.setHyl(arg0.getString("yh"));
887 939 sin.setUnyyyl(arg0.getString("sh"));
  940 + sin.setgS(arg0.getString("fgsdm"));
888 941 return sin;
889 942 }
890 943 });
... ... @@ -913,7 +966,7 @@ public class FormsServiceImpl implements FormsService {
913 966 s.setClzbh(clzbh);
914 967 s.setSgh("");
915 968 s.setsName("");
916   - s.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  969 + s.setgS(BasicData.businessFgsCodeNameMap.get(sin_.getgS()+"_"+gsdm));
917 970 s.setxL(line);
918 971 s.setXlmc(BasicData.lineCode2NameMap.get(line));
919 972 s.setJzl(sin_.getJzl());
... ... @@ -983,27 +1036,29 @@ public class FormsServiceImpl implements FormsService {
983 1036 // sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
984 1037 sin.setSgh("");
985 1038 sin.setsName("");
986   - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  1039 + sin.setgS(BasicData.businessFgsCodeNameMap.get(sin.getgS()+"_"+gsdm));
987 1040 list_.add(sin);
988 1041  
989 1042 }
990   - Collections.sort(list_,new SingledataByXlbm());
991 1043 }else{
992 1044 String sql="select r.s_gh,r.s_name, "
993 1045 + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm"
994 1046 + " from bsth_c_s_sp_info_real r where "
995 1047 + " r.schedule_date_str = '"+startDate+"'"
996 1048 + " and r.s_gh !='' and r.s_gh is not null ";
997   - if(xlbm.equals("")){
998   - sql +="and r.gs_bm='"+gsdm+"' "
999   - + " and r.fgs_bm='"+fgsdm+"'";
1000   - }else{
  1049 + if(!xlbm.equals("")){
1001 1050 sql += " and r.xl_bm = '"+xlbm+"'";
1002 1051 }
1003   - sql += " group by r.s_gh,r.s_name,"
  1052 + if(!gsdm.equals("")){
  1053 + sql += " and r.gs_bm = '"+gsdm+"'";
  1054 + }
  1055 + if(!fgsdm.equals("")){
  1056 + sql += " and r.fgs_bm = '"+fgsdm+"'";
  1057 + }
  1058 + sql += " group by r.s_gh,r.s_name,"
1004 1059 + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
1005 1060  
1006   - list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
  1061 + list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
1007 1062 //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
1008 1063 @Override
1009 1064 public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {
... ... @@ -1013,10 +1068,13 @@ public class FormsServiceImpl implements FormsService {
1013 1068 sin.setClzbh(arg0.getString("cl_zbh"));
1014 1069 sin.setSgh(arg0.getString("s_gh"));
1015 1070 sin.setsName(arg0.getString("s_name"));
  1071 + sin.setgS(arg0.getString("fgs_bm"));
1016 1072 return sin;
1017 1073 }
1018 1074 });
1019 1075  
  1076 + Collections.sort(list,new SingledataByXlbm());
  1077 +
1020 1078 for (int i = 0; i < list.size(); i++) {
1021 1079 Singledata sin=list.get(i);
1022 1080 String jsy=sin.getSgh();
... ... @@ -1058,15 +1116,36 @@ public class FormsServiceImpl implements FormsService {
1058 1116 sin.setClzbh(clzbh);
1059 1117 sin.setJsy("");
1060 1118 sin.setjName("");
1061   - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  1119 + sin.setgS(BasicData.businessFgsCodeNameMap.get(sin.getgS()+"_"+gsdm));
1062 1120 sin.setHyl("");
1063 1121 sin.setJzl("");
1064 1122 sin.setUnyyyl("");
1065 1123 list_.add(sin);
1066 1124 }
1067   - Collections.sort(list_,new SingledataByXlbm());
1068 1125 }
1069   - return list_;
  1126 +
  1127 + Map<String, Boolean> lineNature = lineService.lineNature();
  1128 + List<Singledata> resList = new ArrayList<Singledata>();
  1129 + for(Singledata s : list_){
  1130 + String xlBm = s.getxL();
  1131 + if(sfyy.length() != 0){
  1132 + if(sfyy.equals("0")){
  1133 + resList.add(s);
  1134 + } else if(sfyy.equals("1")){
  1135 + if(lineNature.containsKey(xlBm) && lineNature.get(xlBm)){
  1136 + resList.add(s);
  1137 + }
  1138 + } else {
  1139 + if(lineNature.containsKey(xlBm) && !lineNature.get(xlBm)){
  1140 + resList.add(s);
  1141 + }
  1142 + }
  1143 + } else {
  1144 + resList.add(s);
  1145 + }
  1146 + }
  1147 +
  1148 + return resList;
1070 1149 }
1071 1150  
1072 1151  
... ... @@ -1098,12 +1177,15 @@ public class FormsServiceImpl implements FormsService {
1098 1177 String sql="select r.j_gh, r.xl_bm,r.cl_zbh,r.j_name"
1099 1178 + " from bsth_c_s_sp_info_real r where "
1100 1179 + " r.schedule_date_str = '"+startDate+"'";
1101   - if(xlbm.equals("")){
1102   - sql +="and r.gs_bm='"+gsdm+"' "
1103   - + " and r.fgs_bm='"+fgsdm+"'";
1104   - }else{
  1180 + if(!xlbm.equals("")){
1105 1181 sql += " and r.xl_bm = '"+xlbm+"'";
1106 1182 }
  1183 + if(!gsdm.equals("")){
  1184 + sql += " and r.gs_bm='"+gsdm+"'";
  1185 + }
  1186 + if(!fgsdm.equals("")){
  1187 + sql += " and r.fgs_bm='"+fgsdm+"'";
  1188 + }
1107 1189 sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.j_name order by r.xl_bm,r.cl_zbh";
1108 1190 list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
1109 1191 @Override
... ... @@ -1118,15 +1200,21 @@ public class FormsServiceImpl implements FormsService {
1118 1200 });
1119 1201 String linesql="";
1120 1202 if(!xlbm.equals("")){
1121   - linesql +=" and xlbm ='"+xlbm+"' ";
  1203 + linesql += " and xlbm ='"+xlbm+"' ";
1122 1204 }
  1205 + if(!gsdm.equals("")){
  1206 + linesql += " and ssgsdm ='"+gsdm+"'";
  1207 + }
  1208 + if(!fgsdm.equals("")){
  1209 + linesql += " and fgsdm ='"+fgsdm+"'";
  1210 + }
1123 1211 String nysql="SELECT id,xlbm,nbbm, jsy,jzl as jzl,yh as yh,sh as sh FROM bsth_c_ylb "
1124 1212 + " WHERE rq = '"+startDate+"'"
1125   - + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'" +linesql
  1213 + + linesql
1126 1214 + " union"
1127 1215 + " SELECT id,xlbm,nbbm,jsy,cdl as jzl,hd as yh,sh as sh FROM bsth_c_dlb"
1128 1216 + " WHERE rq = '"+startDate+"'"
1129   - + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'"+linesql;
  1217 + + linesql;
1130 1218 List<Singledata> listNy = jdbcTemplate.query(nysql, new RowMapper<Singledata>() {
1131 1219 @Override
1132 1220 public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException {
... ... @@ -1246,14 +1334,17 @@ public class FormsServiceImpl implements FormsService {
1246 1334 + " from bsth_c_s_sp_info_real r where "
1247 1335 + " r.schedule_date_str = '"+startDate+"'"
1248 1336 + " and r.s_gh !='' and r.s_gh is not null ";
1249   - if(xlbm.equals("")){
1250   - sql +="and r.gs_bm='"+gsdm+"' "
1251   - + " and r.fgs_bm='"+fgsdm+"'";
1252   - }else{
  1337 + if(!xlbm.equals("")){
1253 1338 sql += " and r.xl_bm = '"+xlbm+"'";
1254 1339 }
1255   - sql += " group by r.s_gh,r.s_name,"
1256   - + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
  1340 + if(!gsdm.equals("")){
  1341 + sql += " and r.gs_bm='"+gsdm+"'";
  1342 + }
  1343 + if(!fgsdm.equals("")){
  1344 + sql += " and r.fgs_bm='"+fgsdm+"'";
  1345 + }
  1346 + sql += " group by r.s_gh,r.s_name,"
  1347 + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
1257 1348  
1258 1349 list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
1259 1350 //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
... ... @@ -1635,14 +1726,17 @@ public class FormsServiceImpl implements FormsService {
1635 1726 String sql="select r.s_gh,r.s_name, "
1636 1727 + " r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.gs_bm,r.fgs_bm"
1637 1728 + " from bsth_c_s_sp_info_real r where r.schedule_date_str = '"+startDate+"'";
1638   - if(xlbm.equals("")){
1639   - sql +="and r.gs_bm='"+gsdm+"' "
1640   - + " and r.fgs_bm='"+fgsdm+"'";
1641   - }else{
  1729 + if(!xlbm.equals("")){
1642 1730 sql += " and r.xl_bm = '"+xlbm+"'";
1643 1731 }
1644   - sql += " group by r.s_gh,r.s_name,"
1645   - + " r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
  1732 + if(!gsdm.equals("")){
  1733 + sql += " and r.gs_bm='"+gsdm+"'";
  1734 + }
  1735 + if(!fgsdm.equals("")){
  1736 + sql += " and r.fgs_bm='"+fgsdm+"'";
  1737 + }
  1738 + sql += " group by r.s_gh,r.s_name,"
  1739 + + " r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
1646 1740  
1647 1741 List<Singledata> list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
1648 1742 //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
... ... @@ -1929,14 +2023,17 @@ public class FormsServiceImpl implements FormsService {
1929 2023 + " from bsth_c_s_sp_info_real r where "
1930 2024 + " r.schedule_date_str = '"+startDate+"'"
1931 2025 + " and r.s_gh !='' and r.s_gh is not null ";
1932   - if(xlbm.equals("")){
1933   - sql +="and r.gs_bm='"+gsdm+"' "
1934   - + " and r.fgs_bm='"+fgsdm+"'";
1935   - }else{
  2026 + if(!xlbm.equals("")){
1936 2027 sql += " and r.xl_bm = '"+xlbm+"'";
1937 2028 }
1938   - sql += " group by r.s_gh,r.s_name,"
1939   - + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
  2029 + if(!gsdm.equals("")){
  2030 + sql += " and r.gs_bm='"+gsdm+"'";
  2031 + }
  2032 + if(!fgsdm.equals("")){
  2033 + sql += " and r.fgs_bm='"+fgsdm+"'";
  2034 + }
  2035 + sql += " group by r.s_gh,r.s_name,"
  2036 + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
1940 2037  
1941 2038 list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
1942 2039 //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
... ... @@ -2205,13 +2302,16 @@ public class FormsServiceImpl implements FormsService {
2205 2302 + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm"
2206 2303 + " from bsth_c_s_sp_info_real r where "
2207 2304 + " r.schedule_date_str = '"+startDate+"'"
2208   - + " and r.s_gh !='' and r.s_gh is not null ";
2209   - if(xlbm.equals("")){
2210   - sql +="and r.gs_bm='"+gsdm+"' "
2211   - + " and r.fgs_bm='"+fgsdm+"'";
2212   - }else{
  2305 + + " and r.s_gh !='' and r.s_gh is not null ";
  2306 + if(!xlbm.equals("")){
2213 2307 sql += " and r.xl_bm = '"+xlbm+"'";
2214 2308 }
  2309 + if(!gsdm.equals("")){
  2310 + sql += " and r.gs_bm='"+gsdm+"'";
  2311 + }
  2312 + if(!fgsdm.equals("")){
  2313 + sql += " and r.fgs_bm='"+fgsdm+"'";
  2314 + }
2215 2315 sql += " group by r.s_gh,r.s_name,"
2216 2316 + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
2217 2317  
... ... @@ -2285,7 +2385,10 @@ public class FormsServiceImpl implements FormsService {
2285 2385 @Override
2286 2386 public List<Operationservice> operationservice(Map<String, Object> map) {
2287 2387  
2288   - String xlbm=map.get("line").toString().trim();
  2388 + String sfyy="";
  2389 + if(map.get("sfyy")!=null){
  2390 + sfyy=map.get("sfyy").toString();
  2391 + }
2289 2392 String gsdm="";
2290 2393 if(map.get("gsdmOperat")!=null){
2291 2394 gsdm=map.get("gsdmOperat").toString();
... ... @@ -2294,37 +2397,72 @@ public class FormsServiceImpl implements FormsService {
2294 2397 if(map.get("fgsdmOperat")!=null){
2295 2398 fgsdm=map.get("fgsdmOperat").toString();
2296 2399 }
2297   - startDate=map.get("startDate").toString();
2298   - endDate =map.get("endDate").toString();
2299   - String sql="select r.xl_bm"
  2400 + String xlbm=map.get("line").toString().trim();
  2401 + String startDate=map.get("startDate").toString();
  2402 + String endDate =map.get("endDate").toString();
  2403 +
  2404 + String sql="select r.xl_bm, r.gs_bm, r.fgs_bm"
2300 2405 + " from bsth_c_s_sp_info_real r where"
2301 2406 + " r.schedule_date_str BETWEEN '"+startDate+"' and '"+endDate+"'";
2302   - if(xlbm.equals("")){
2303   - sql +="and r.gs_bm='"+gsdm+"' "
2304   - + " and r.fgs_bm='"+fgsdm+"'";
2305   - }else{
  2407 + if(xlbm.length() != 0){
2306 2408 sql += " and r.xl_bm = '"+xlbm+"'";
2307 2409 }
2308   - sql += " group by r.xl_bm";
2309   -
  2410 + if(gsdm.length() != 0){
  2411 + sql += " and r.gs_bm='"+gsdm+"'";
  2412 + }
  2413 + if(fgsdm.length() != 0){
  2414 + sql += " and r.fgs_bm='"+fgsdm+"'";
  2415 + }
  2416 + sql += " group by r.gs_bm, r.fgs_bm, r.xl_bm " +
  2417 + "order by r.gs_bm, r.fgs_bm, r.xl_bm";
  2418 +
  2419 + System.out.println(sql);
2310 2420  
2311   - List<Operationservice> list= jdbcTemplate.query(sql, new RowMapper<Operationservice>() {
2312   - @Override
2313   - public Operationservice mapRow(ResultSet arg0, int arg1) throws SQLException {
2314   - Operationservice ve = new Operationservice();
2315   - ve.setXlBm(arg0.getString("xl_bm"));
2316   - return ve;
  2421 + List<Operationservice> query = jdbcTemplate.query(sql, new RowMapper<Operationservice>() {
  2422 + @Override
  2423 + public Operationservice mapRow(ResultSet arg0, int arg1) throws SQLException {
  2424 + Operationservice ve = new Operationservice();
  2425 + ve.setXlBm(arg0.getString("xl_bm"));
  2426 + ve.setGs(arg0.getString("gs_bm"));
  2427 + ve.setFgs(arg0.getString("fgs_bm"));
  2428 + return ve;
  2429 + }
  2430 + });
  2431 +
  2432 + List<Operationservice> list = new ArrayList<Operationservice>();
  2433 + Map<String, Boolean> lineNature = lineService.lineNature();
  2434 + for(Operationservice o : query){
  2435 + o.setFgs(BasicData.businessFgsCodeNameMap.get(o.getFgs()+"_"+o.getGs()));
  2436 +
  2437 + String xl = o.getXlBm();
  2438 + if(sfyy.length() != 0){
  2439 + if(sfyy.equals("0")){
  2440 + list.add(o);
  2441 + } else if(sfyy.equals("1")){
  2442 + if(lineNature.containsKey(xl) && lineNature.get(xl)){
  2443 + list.add(o);
  2444 + }
  2445 + } else {
  2446 + if(lineNature.containsKey(xl) && !lineNature.get(xl)){
  2447 + list.add(o);
  2448 + }
2317 2449 }
2318   - });
2319   -
2320   - String ylbSql=" select * from bsth_c_ylb where rq BETWEEN '"+startDate+"' and '"+endDate+"'";
2321   - if(xlbm.equals("")){
2322   - ylbSql +="and ssgsdm='"+gsdm+"' "
2323   - + " and fgsdm='"+fgsdm+"'";
2324   - }else{
  2450 + } else {
  2451 + list.add(o);
  2452 + }
  2453 + }
  2454 +
  2455 + String ylbSql=" select * from bsth_c_ylb where rq BETWEEN '"+startDate+"' and '"+endDate+"'";
  2456 + if(!xlbm.equals("")){
2325 2457 ylbSql += " and xlbm = '"+xlbm+"'";
2326 2458 }
2327   - List<Ylb> ylbList= jdbcTemplate.query(ylbSql, new RowMapper<Ylb>() {
  2459 + if(!gsdm.equals("")){
  2460 + ylbSql += " and ssgsdm='"+gsdm+"'";
  2461 + }
  2462 + if(!fgsdm.equals("")){
  2463 + ylbSql += " and fgsdm='"+fgsdm+"'";
  2464 + }
  2465 + List<Ylb> ylbList= jdbcTemplate.query(ylbSql, new RowMapper<Ylb>() {
2328 2466 @Override
2329 2467 public Ylb mapRow(ResultSet arg0, int arg1) throws SQLException {
2330 2468 Ylb y = new Ylb();
... ... @@ -2333,16 +2471,19 @@ public class FormsServiceImpl implements FormsService {
2333 2471 y.setYh(arg0.getDouble("yh"));
2334 2472 return y;
2335 2473 }
2336   - });
  2474 + });
2337 2475  
2338   - String dlbSql=" select * from bsth_c_dlb where rq BETWEEN '"+startDate+"' and '"+endDate+"'";
2339   - if(xlbm.equals("")){
2340   - ylbSql +="and ssgsdm='"+gsdm+"' "
2341   - + " and fgsdm='"+fgsdm+"'";
2342   - }else{
  2476 + String dlbSql=" select * from bsth_c_dlb where rq BETWEEN '"+startDate+"' and '"+endDate+"'";
  2477 + if(!xlbm.equals("")){
2343 2478 ylbSql += " and xlbm = '"+xlbm+"'";
2344 2479 }
2345   - List<Dlb> dlbList= jdbcTemplate.query(dlbSql, new RowMapper<Dlb>() {
  2480 + if(!gsdm.equals("")){
  2481 + ylbSql += " and ssgsdm='"+gsdm+"'";
  2482 + }
  2483 + if(!fgsdm.equals("")){
  2484 + ylbSql += " and fgsdm='"+fgsdm+"'";
  2485 + }
  2486 + List<Dlb> dlbList= jdbcTemplate.query(dlbSql, new RowMapper<Dlb>() {
2346 2487 @Override
2347 2488 public Dlb mapRow(ResultSet arg0, int arg1) throws SQLException {
2348 2489 Dlb d = new Dlb();
... ... @@ -2544,8 +2685,13 @@ public class FormsServiceImpl implements FormsService {
2544 2685 }
2545 2686 String rq2 = sdf1.format(d);
2546 2687 String rq3 = sdf1.format(d1);
2547   - String company = map.get("gsdmTurn").toString();
2548   - String subCompany = map.get("fgsdmTurn").toString();
  2688 + String company = "", subCompany = "";
  2689 + if(map.get("gsdmTurn") != null){
  2690 + company = map.get("gsdmTurn").toString();
  2691 + }
  2692 + if(map.get("fgsdmTurn") != null){
  2693 + subCompany = map.get("fgsdmTurn").toString();
  2694 + }
2549 2695 String line = map.get("line").toString();
2550 2696 String startDate = map.get("startDate").toString();
2551 2697 String endDate = map.get("endDate").toString();
... ... @@ -2559,12 +2705,17 @@ public class FormsServiceImpl implements FormsService {
2559 2705 List<Line> lineList = lineRepository.findLineBygsBm(company, subCompany, line.length()==0?"%"+line+"%":line);
2560 2706  
2561 2707 String sql = "select gs_name, fgs_name, cl_zbh, fcsj, bc_type, xl_bm, xl_name, schedule_date"
2562   - + " from bsth_c_s_sp_info where gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"' "
2563   - + "and schedule_date >= '"+startDate+"' "
2564   - + "and schedule_date <= '"+endDate+"' ";
  2708 + + " from bsth_c_s_sp_info where "
  2709 + + "schedule_date >= '"+startDate+"' and schedule_date <= '"+endDate+"' ";
2565 2710 if(line.trim().length() != 0){
2566 2711 sql += "and xl_bm = '"+line+"' ";
2567 2712 }
  2713 + if(company.trim().length() != 0){
  2714 + sql += "and gs_bm = '"+company+"' ";
  2715 + }
  2716 + if(subCompany.trim().length() != 0){
  2717 + sql += "and fgs_bm = '"+subCompany+"' ";
  2718 + }
2568 2719 List<SchedulePlanInfo> planList = jdbcTemplate.query(sql, new RowMapper<SchedulePlanInfo>() {
2569 2720  
2570 2721 @Override
... ... @@ -2711,18 +2862,34 @@ public class FormsServiceImpl implements FormsService {
2711 2862  
2712 2863 e.printStackTrace();
2713 2864 }
  2865 +
  2866 + String gsbm = "", fgsbm = "";
  2867 + if(map.get("gsdmEcecut")!=null){
  2868 + gsbm = map.get("gsdmEcecut").toString();
  2869 + }
  2870 + if(map.get("fgsdmEcecut")!=null){
  2871 + fgsbm = map.get("fgsdmEcecut").toString();
  2872 + }
  2873 +
2714 2874 String rq2 = sdf1.format(d);
2715 2875 String rq3 = sdf1.format(d1);
2716 2876  
2717 2877 rq = rq2 + "-" + rq3;
2718 2878  
  2879 + String where = "";
  2880 + if(gsbm.trim().length() != 0){
  2881 + where += " and gs_bm = '" + gsbm + "'";
  2882 + }
  2883 + if(fgsbm.trim().length() != 0){
  2884 + where += " and fgs_bm = '" + fgsbm + "'";
  2885 + }
  2886 +
2719 2887 String sql = " select b.xlgs, a.gs_bm,a.gs_name, a.fgs_bm,a.fgs_name , a.xl_bm,b.xl_name,b.sbc,b.sxl,b.scl,a.jbc ,a.jxl ,a.jcl,a.gslsbm,a.fgsbm,a.bc_type from "
2720 2888 + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type"
2721 2889 + " from bsth_c_s_sp_info" + " where schedule_date >= '"
2722 2890 + map.get("startDate").toString() + "' and schedule_date <= '" + map.get("endDate").toString() + "' and xl_bm='"
2723 2891 + map.get("line").toString() + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out')"
2724   - + " and gs_bm='"+ map.get("gsdmEcecut").toString() + "'"
2725   - + " and fgs_bm='"+ map.get("fgsdmEcecut").toString() + "'"
  2892 + + where
2726 2893 // + " GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type "
2727 2894 + " ) a left JOIN ("
2728 2895 + "SELECT COUNT(*) as xlgs,b.gs_bm,b.fgs_bm,b.xl_bm,b.xl_name,b.gs_name,b.fgs_name, b.sbc,b.sxl ,b.scl "
... ... @@ -2899,14 +3066,17 @@ public class FormsServiceImpl implements FormsService {
2899 3066 + " r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.gs_bm,r.fgs_bm"
2900 3067 + " from bsth_c_s_sp_info_real r where "
2901 3068 + "r.schedule_date_str = '"+map.get("date").toString()+"'";
2902   - if(xlbm.equals("")){
2903   - sql +="and r.gs_bm='"+gsbm+"' "
2904   - + " and r.fgs_bm='"+fgsbm+"'";
2905   - }else{
  3069 + if(!xlbm.equals("")){
2906 3070 sql += " and r.xl_bm = '"+xlbm+"'";
2907 3071 }
2908   - sql += " group by r.schedule_date_str,"
2909   - + " r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
  3072 + if(!gsbm.equals("")){
  3073 + sql += " and r.gs_bm='"+gsbm+"'";
  3074 + }
  3075 + if(!fgsbm.equals("")){
  3076 + sql += " and r.fgs_bm='"+fgsbm+"'";
  3077 + }
  3078 + sql += " group by r.schedule_date_str,"
  3079 + + " r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh";
2910 3080  
2911 3081 List<Daily> list = jdbcTemplate.query(sql, new RowMapper<Daily>() {
2912 3082 @Override
... ... @@ -2972,10 +3142,10 @@ public class FormsServiceImpl implements FormsService {
2972 3142 }
2973 3143  
2974 3144 class SingledataByXlbm implements Comparator<Singledata>{
2975   - @Override
2976   - public int compare(Singledata o1, Singledata o2) {
2977   - // TODO Auto-generated method stub
2978   - return (o2.getxL()+o2.getClzbh()).compareTo((o1.getxL()+o1.getClzbh()));
2979   - }
  3145 + @Override
  3146 + public int compare(Singledata o1, Singledata o2) {
  3147 + // TODO Auto-generated method stub
  3148 + return (o1.getgS()+o1.getxL()+o1.getClzbh()).compareTo((o2.getgS()+o2.getxL()+o2.getClzbh()));
  3149 + }
2980 3150 }
2981 3151 }
... ...
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
... ... @@ -359,6 +359,10 @@ public class GpsServiceImpl implements GpsService {
359 359 return (byte)(((serviceState & 0x80000000) == 0x80000000) ? 1 : 0);
360 360 }
361 361  
  362 + public static void main(String[] args){
  363 + System.out.println(getGpsValid(-2147483648));
  364 + }
  365 +
362 366 public Map<String, ArrivalEntity> findArrivalByTs(Long st, Long et, List<DeviceChange> dcs) {
363 367 Map<String, ArrivalEntity> map = new HashMap<>();
364 368  
... ...
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
... ... @@ -44,6 +44,7 @@ import com.bsth.repository.oil.DlbRepository;
44 44 import com.bsth.repository.oil.YlbRepository;
45 45 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
46 46 import com.bsth.service.BusIntervalService;
  47 +import com.bsth.service.LineService;
47 48 import com.bsth.service.report.CulateMileageService;
48 49 import com.bsth.service.schedule.PeopleCarPlanService;
49 50 import com.bsth.service.sys.DutyEmployeeService;
... ... @@ -60,8 +61,11 @@ import com.google.gson.Gson;
60 61 public class BusIntervalServiceImpl implements BusIntervalService {
61 62  
62 63 @Autowired
63   - CulateMileageService culateService;
  64 + LineService lineService;
64 65  
  66 + @Autowired
  67 + CulateMileageService culateService;
  68 +
65 69 @Autowired
66 70 private PeopleCarPlanService peopleCarPlanService;
67 71  
... ... @@ -113,7 +117,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
113 117 }
114 118 }
115 119 if(company.length() != 0){
116   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  120 + sql += " and gs_bm = '"+company+"'";
  121 + }
  122 + if(subCompany.length() != 0){
  123 + sql += " and fgs_bm = '"+subCompany+"'";
117 124 }
118 125 if(normal){
119 126 sql += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
... ... @@ -147,6 +154,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
147 154 schedule.setAdjustExps(rs.getString("adjust_exps"));
148 155 schedule.setJhlcOrig(rs.getDouble("jhlc_orig"));
149 156 schedule.setRemarks(rs.getString("remarks"));
  157 + schedule.setFgsBm(rs.getString("fgs_bm"));
150 158 schedule.setGsName(rs.getString("gs_name"));
151 159 schedule.setFgsName(rs.getString("fgs_name"));
152 160 schedule.setDfAuto(rs.getBoolean("df_auto"));
... ... @@ -419,8 +427,11 @@ public class BusIntervalServiceImpl implements BusIntervalService {
419 427 List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
420 428 Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>();
421 429  
422   - String company = map.get("company").toString();
423   - String subCompany = map.get("subCompany").toString();
  430 + String company = "", subCompany = "";
  431 + if(map.get("company")!=null)
  432 + company = map.get("company").toString();
  433 + if(map.get("subCompany")!=null)
  434 + subCompany = map.get("subCompany").toString();
424 435 String line = map.get("line").toString();
425 436 String startDate = map.get("startDate").toString();
426 437 String endDate = map.get("endDate").toString();
... ... @@ -429,6 +440,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
429 440 String times1 = map.get("times1").toString();
430 441 String times2 = map.get("times2").toString();
431 442 String type = map.get("type").toString();
  443 + String sfyy = map.get("sfyy").toString();
432 444 int sfqr = Integer.valueOf(map.get("sfqr").toString());
433 445  
434 446 if(startDate.length() == 0){
... ... @@ -467,6 +479,8 @@ public class BusIntervalServiceImpl implements BusIntervalService {
467 479 // int startTime = Integer.valueOf(split[0].split(":")[0])*60 + Integer.valueOf(split[0].split(":")[1]);
468 480 // int endTime = Integer.valueOf(split[1].split(":")[0])*60 + Integer.valueOf(split[1].split(":")[1]);
469 481  
  482 + Map<String, Boolean> lineNature = lineService.lineNature();
  483 +
470 484 for(ScheduleRealInfo schedule : list){
471 485 if(schedule.isCcService())
472 486 continue;
... ... @@ -479,7 +493,19 @@ public class BusIntervalServiceImpl implements BusIntervalService {
479 493 }
480 494 if(schedule.getXlName() == null || schedule.getXlName().trim().length() == 0)
481 495 continue;
482   - String key = schedule.getXlBm() + "/" + schedule.getXlName() + "/" + schedule.getQdzName();
  496 +
  497 + if(lineNature.containsKey(schedule.getXlBm()) && lineNature.get(schedule.getXlBm()) != null){
  498 + if(sfyy.equals("1") && !lineNature.get(schedule.getXlBm())){
  499 + continue;
  500 + } else if(sfyy.equals("2") && lineNature.get(schedule.getXlBm())){
  501 + continue;
  502 + }
  503 + } else if(sfyy.equals("2")){
  504 + continue;
  505 + }
  506 +
  507 + String key = schedule.getXlBm() + "/" + schedule.getXlName() + "/" + schedule.getQdzName()
  508 + + "/" + schedule.getFgsName() + "/" + schedule.getFgsBm();
483 509 if(!keyMap.containsKey(key))
484 510 keyMap.put(key, new ArrayList<ScheduleRealInfo>());
485 511 keyMap.get(key).add(schedule);
... ... @@ -592,7 +618,8 @@ public class BusIntervalServiceImpl implements BusIntervalService {
592 618 tempMap.put("line", split[1]);
593 619 tempMap.put("qdz", split[2]);
594 620 tempMap.put("company", companyName);
595   - tempMap.put("subCompany", subCompanyName);
  621 + tempMap.put("subCompany", split[3]);
  622 + tempMap.put("fgsbm", split[4]);
596 623 long jhInterval = 0l;
597 624 long sjInterval = 0l;
598 625 for(Long i : fcsjs)
... ... @@ -622,7 +649,8 @@ public class BusIntervalServiceImpl implements BusIntervalService {
622 649 Map<Long, List<Map<String, Object>>> sortMap = new HashMap<Long, List<Map<String, Object>>>();
623 650 for(Map<String, Object> m : tempList){
624 651 String times = m.get("times").toString();
625   - Long sort = Long.valueOf(times.substring(0, 2));
  652 + Long sort = Long.valueOf(times.substring(0, 2)) * 1000l
  653 + + Long.valueOf(m.get("fgsbm").toString());
626 654 if(!sortMap.containsKey(sort)){
627 655 sortMap.put(sort, new ArrayList<Map<String, Object>>());
628 656 sortList.add(sort);
... ... @@ -649,7 +677,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
649 677 }else if(statu.equals("0")){
650 678 List<Long> longList = new ArrayList<Long>();
651 679 for(String key : keyList){
652   - long xlBm = Long.valueOf(key.split("/")[0]);
  680 + long xlBm = Long.valueOf(key.split("/")[4]) * 1000000l + Long.valueOf(key.split("/")[0]);
653 681 if(!longList.contains(xlBm))
654 682 longList.add(xlBm);
655 683 Collections.sort(longList);
... ... @@ -657,7 +685,8 @@ public class BusIntervalServiceImpl implements BusIntervalService {
657 685 for(long xlBm : longList){
658 686 for(String key : keyList){
659 687 String[] split = key.split("/");
660   - if((long)Long.valueOf(split[0]) == xlBm){
  688 + long kl = Long.valueOf(split[4]) * 1000000l + Long.valueOf(split[0]);
  689 + if(kl == xlBm){
661 690 Map<String, Object> tempMap = new HashMap<String, Object>();
662 691 List<Long> fcsjs = new ArrayList<Long>();
663 692 List<Long> fcsjAs = new ArrayList<Long>();
... ... @@ -683,7 +712,8 @@ public class BusIntervalServiceImpl implements BusIntervalService {
683 712 tempMap.put("line", split[1]);
684 713 tempMap.put("qdz", split[2]);
685 714 tempMap.put("company", companyName);
686   - tempMap.put("subCompany", subCompanyName);
  715 + tempMap.put("subCompany", split[3]);
  716 + tempMap.put("fgsbm", split[4]);
687 717 tempMap.put("jhInterval", fcsjs.size()>0?df.format((double)fcsj/fcsjs.size()):"/");
688 718 tempMap.put("sjInterval", fcsjAs.size()>0?df.format((double)fcsjA/fcsjAs.size()):"/");
689 719 tempMap.put("MaxInterval", fcsjAs.size()>0?fcsjAs.get(fcsjAs.size() - 1):"/");
... ... @@ -745,9 +775,13 @@ public class BusIntervalServiceImpl implements BusIntervalService {
745 775 Set<Long> tsSet = new HashSet<Long>();
746 776 Set<Long> ttSet = new HashSet<Long>();
747 777  
748   - String company = map.get("company").toString();
749   - String subCompany = map.get("subCompany").toString();
  778 + String company = "", subCompany = "";
  779 + if(map.get("company")!=null)
  780 + company = map.get("company").toString();
  781 + if(map.get("subCompany")!=null)
  782 + subCompany = map.get("subCompany").toString();
750 783 String lp = map.get("lp").toString();
  784 + String sfyy = map.get("sfyy").toString();
751 785 String line = map.get("line").toString();
752 786 String statu = map.get("statu").toString();
753 787 String startDate = map.get("startDate").toString();
... ... @@ -775,7 +809,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
775 809 where += " and lp_name = '"+lp+"'";
776 810 }
777 811 if(company.length() != 0){
778   - where += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  812 + where += " and gs_bm = '"+company+"'";
  813 + }
  814 + if(subCompany.length() != 0){
  815 + where += " and fgs_bm = '"+subCompany+"'";
779 816 }
780 817 if(sfqr == 1){
781 818 where += " and zdsj >= '"+times1+"' and fcsj <= '"+times2+"'";
... ... @@ -783,7 +820,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
783 820 // where += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
784 821 where += " and bc_type != 'ldks'";
785 822  
786   - String sql = "select id, schedule_date_str, real_exec_date, xl_name, lp_name, bcs, bcsj, jhlc, bc_type,"
  823 + String sql = "select id, schedule_date_str, real_exec_date, xl_name, lp_name, bcs, bcsj, jhlc, bc_type, xl_bm, fgs_bm,"
787 824 + " fcsj, fcsj_actual, zdsj, zdsj_actual, qdz_name, zdz_name, xl_dir, status, remarks, gs_name, fgs_name, sp_id"
788 825 + " ,cc_service from bsth_c_s_sp_info_real where schedule_date_str >= '"+startDate+"'"
789 826 + " and schedule_date_str <= '"+endDate+"'"+where+"";
... ... @@ -796,6 +833,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
796 833 schedule.setId(rs.getLong("id"));
797 834 schedule.setScheduleDateStr(rs.getString("schedule_date_str"));
798 835 schedule.setRealExecDate(rs.getString("real_exec_date"));
  836 + schedule.setXlBm(rs.getString("xl_bm"));
799 837 schedule.setXlName(rs.getString("xl_name"));
800 838 schedule.setLpName(rs.getString("lp_name"));
801 839 schedule.setBcs(rs.getInt("bcs"));
... ... @@ -813,6 +851,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
813 851 schedule.setRemarks(rs.getString("remarks"));
814 852 schedule.setGsName(rs.getString("gs_name"));
815 853 schedule.setFgsName(rs.getString("fgs_name"));
  854 + schedule.setFgsBm(rs.getString("fgs_bm"));
816 855 schedule.setSpId(rs.getLong("sp_id"));
817 856 schedule.setCcService(rs.getBoolean("cc_service"));
818 857  
... ... @@ -877,7 +916,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
877 916 sql += " and xl_bm = '"+line+"'";
878 917 }
879 918 if(company.length() != 0){
880   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  919 + sql += " and gs_bm = '"+company+"'";
  920 + }
  921 + if(subCompany.length() != 0){
  922 + sql += " and fgs_bm = '"+subCompany+"'";
881 923 }
882 924 temp1 = jdbcTemplate.query(sql,
883 925 new RowMapper<Map<String, String>>(){
... ... @@ -1002,13 +1044,26 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1002 1044 cMap.get(key).add(cTask);
1003 1045 }
1004 1046  
  1047 + Map<String, Boolean> lineNature = lineService.lineNature();
  1048 +
1005 1049 for(ScheduleRealInfo schedule : list){
1006 1050 if(schedule.getXlName()==null || schedule.getXlName().trim().length()==0
1007 1051 || schedule.isCcService())
1008 1052 continue;
  1053 + String xlBm = schedule.getXlBm();
  1054 + if(lineNature.containsKey(xlBm) && lineNature.get(xlBm) != null){
  1055 + if(sfyy.equals("1") && !lineNature.get(xlBm)){
  1056 + continue;
  1057 + } else if(sfyy.equals("2") && lineNature.get(xlBm)){
  1058 + continue;
  1059 + }
  1060 + } else if(sfyy.equals("2")){
  1061 + continue;
  1062 + }
  1063 + String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/"
  1064 + + schedule.getLpName() + "/" + schedule.getFgsName();
1009 1065 if(model.length() != 0){
1010 1066 if(ttSet.contains(schedule.getSpId())){
1011   - String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName();
1012 1067 if(!keyMap.containsKey(key))
1013 1068 keyMap.put(key, new ArrayList<ScheduleRealInfo>());
1014 1069 keyMap.get(key).add(schedule);
... ... @@ -1023,7 +1078,6 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1023 1078 // }
1024 1079 // }
1025 1080 }else{
1026   - String key = schedule.getScheduleDateStr() + "/" + schedule.getXlName() + "/" + schedule.getLpName();
1027 1081 if(!keyMap.containsKey(key))
1028 1082 keyMap.put(key, new ArrayList<ScheduleRealInfo>());
1029 1083 keyMap.get(key).add(schedule);
... ... @@ -1081,9 +1135,6 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1081 1135 }else{
1082 1136 jhyysj += fcsj2 - fcsj1;
1083 1137 }
1084   - if(jhyysj < 0){
1085   - System.out.println(fcsj2 + " - " + fcsj1 + " = " + (fcsj2 - fcsj1));
1086   - }
1087 1138 jhyysj1 += fcsj2 - fcsj1;
1088 1139 }
1089 1140 if(i == 1 && schedule1.getBcType().toString().equals("normal")){
... ... @@ -1220,9 +1271,9 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1220 1271 sjlc += Double.valueOf(m.get("lc").toString());
1221 1272 }
1222 1273 }
1223   - tempMap.put("company", companyName);
1224   - tempMap.put("subCompany", subCompanyName);
1225 1274 String[] split = key.split("/");
  1275 + tempMap.put("company", companyName);
  1276 + tempMap.put("subCompany", split[3]);
1226 1277 tempMap.put("date", split[0]);
1227 1278 tempMap.put("line", split[1]);
1228 1279 tempMap.put("lp", split[2]);
... ... @@ -1272,7 +1323,8 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1272 1323 }
1273 1324 Map<String, List<Map<String, Object>>> keyMap2 = new HashMap<String, List<Map<String, Object>>>();
1274 1325 for(Map<String, Object> m : resList){
1275   - String key = m.get("line").toString() + "/" + m.get("lp").toString();
  1326 + String key = m.get("line").toString() + "/" + m.get("lp").toString()
  1327 + + "/" + m.get("subCompany").toString();
1276 1328 if(!keyMap2.containsKey(key))
1277 1329 keyMap2.put(key, new ArrayList<Map<String, Object>>());
1278 1330 keyMap2.get(key).add(m);
... ... @@ -1333,6 +1385,32 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1333 1385 return a.compareTo(b);
1334 1386 }
1335 1387 });
  1388 + Collections.sort(list3, new Comparator<String>() {
  1389 +
  1390 + public int compare(String o1, String o2) {
  1391 +
  1392 + Long a = 0l;
  1393 + Long b = 0l;
  1394 + String[] split1 = o1.split("/");
  1395 + String[] split2 = o2.split("/");
  1396 + char[] charArray1 = split1[2].toCharArray();
  1397 + char[] charArray2 = split2[2].toCharArray();
  1398 + for(int i = 0; i < charArray1.length; i++){
  1399 + long temp = 1l;
  1400 + for(int j = 0; j < i; j++)
  1401 + temp *= 10;
  1402 + a += (long)charArray1[charArray1.length - 1 - i] * temp;
  1403 + }
  1404 + for(int i = 0; i < charArray2.length; i++){
  1405 + long temp = 1l;
  1406 + for(int j = 0; j < i; j++)
  1407 + temp *= 10;
  1408 + b += (long)charArray2[charArray2.length - 1 - i] * temp;
  1409 + }
  1410 +
  1411 + return a.compareTo(b);
  1412 + }
  1413 + });
1336 1414 for(String key : list3){
1337 1415 Map<String, Object> tempMap = new HashMap<String, Object>();
1338 1416 BigDecimal jhyysj = new BigDecimal(0), jhyssj = new BigDecimal(0);
... ... @@ -1362,7 +1440,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1362 1440 tempMap.put("line", split[0]);
1363 1441 tempMap.put("lp", split[1]);
1364 1442 tempMap.put("company", companyName);
1365   - tempMap.put("subCompany", subCompanyName);
  1443 + tempMap.put("subCompany", split[2]);
1366 1444 tempMap.put("date", date);
1367 1445 list4.add(tempMap);
1368 1446 }
... ... @@ -1373,7 +1451,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1373 1451 List<Map<String, Object>> list5 = new ArrayList<Map<String, Object>>();
1374 1452 List<String> keyList = new ArrayList<String>();
1375 1453 for(Map<String, Object> m : list4){
1376   - String key = m.get("line").toString();
  1454 + String key = m.get("line").toString() + "/" + m.get("subCompany").toString();
1377 1455 if(!keyMap4.containsKey(key)){
1378 1456 keyList.add(key);
1379 1457 keyMap4.put(key, new ArrayList<Map<String, Object>>());
... ... @@ -1405,10 +1483,11 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1405 1483 tempMap.put("sjyssj", sjyssj.equals(0)?0:sjyssj.divide(size, 2, RoundingMode.HALF_UP));
1406 1484 tempMap.put("sjyycs", sjyycs.equals(0)?0:sjyycs.divide(size, 2, RoundingMode.HALF_UP));
1407 1485 tempMap.put("sjyscs", sjyscs.equals(0)?0:sjyscs.divide(size, 2, RoundingMode.HALF_UP));
1408   - tempMap.put("line", key);
  1486 + String[] split = key.split("/");
  1487 + tempMap.put("line", split[0]);
1409 1488 tempMap.put("lp", keyMap4.get(key).size());
1410 1489 tempMap.put("company", companyName);
1411   - tempMap.put("subCompany", subCompanyName);
  1490 + tempMap.put("subCompany", split[1]);
1412 1491 tempMap.put("date", date);
1413 1492 tempMap.put("work", keyMap4.get(key));
1414 1493 list5.add(tempMap);
... ... @@ -1491,8 +1570,13 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1491 1570 Map<String, List<Map<String, Object>>> keyMap0 = new HashMap<String, List<Map<String, Object>>>();
1492 1571 Map<String, List<Map<String, Object>>> keyMap1 = new HashMap<String, List<Map<String, Object>>>();
1493 1572  
1494   - String company = map.get("company").toString();
1495   - String subCompany = map.get("subCompany").toString();
  1573 + String sfqr = "", company = "", subCompany = "";
  1574 + if(map.get("sfqr")!=null)
  1575 + sfqr = map.get("sfqr").toString();
  1576 + if(map.get("company")!=null)
  1577 + company = map.get("company").toString();
  1578 + if(map.get("subCompany")!=null)
  1579 + subCompany = map.get("subCompany").toString();
1496 1580 String line = map.get("line").toString();
1497 1581 String startDate = map.get("startDate").toString();
1498 1582 String endDate = map.get("endDate").toString();
... ... @@ -1510,6 +1594,9 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1510 1594 if(times.length() == 0){
1511 1595 times = "05:00-23:00";
1512 1596 }
  1597 + if(sfqr.equals("0")){
  1598 + times = "";
  1599 + }
1513 1600  
1514 1601 list = getSchedule(company, subCompany, line, startDate, endDate, model, times, false);
1515 1602  
... ... @@ -1522,9 +1609,9 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1522 1609 date = startDate;
1523 1610 }
1524 1611  
1525   - String[] split = times.split("-");
1526   - int startTime = Integer.valueOf(split[0].split(":")[0])*60 + Integer.valueOf(split[0].split(":")[1]);
1527   - int endTime = Integer.valueOf(split[1].split(":")[0])*60 + Integer.valueOf(split[1].split(":")[1]);
  1612 +// String[] split = times.split("-");
  1613 +// int startTime = Integer.valueOf(split[0].split(":")[0])*60 + Integer.valueOf(split[0].split(":")[1]);
  1614 +// int endTime = Integer.valueOf(split[1].split(":")[0])*60 + Integer.valueOf(split[1].split(":")[1]);
1528 1615  
1529 1616 for(ScheduleRealInfo s : list){
1530 1617 if(s.isCcService()){
... ... @@ -1708,7 +1795,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1708 1795  
1709 1796 Map<String, Object> m = mapList.get(0);
1710 1797 tempMap.put("dates", date);
1711   - tempMap.put("times", times);
  1798 + tempMap.put("times", times.length()==0?"全日":times);
1712 1799 tempMap.put("line", m.get("line"));
1713 1800 tempMap.put("lp", m.get("lp"));
1714 1801 tempMap.put("station", m.get("station"));
... ... @@ -1730,10 +1817,14 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1730 1817 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
1731 1818 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
1732 1819 Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>();
1733   -
1734   - String company = map.get("company").toString();
1735   - String subCompany = map.get("subCompany").toString();
  1820 +
  1821 + String company = "", subCompany = "";
  1822 + String sfyy = map.get("sfyy").toString();
1736 1823 String line = map.get("line").toString();
  1824 + if(map.get("company")!=null)
  1825 + company = map.get("company").toString();
  1826 + if(map.get("subCompany")!=null)
  1827 + subCompany = map.get("subCompany").toString();
1737 1828 String startDate = map.get("startDate").toString();
1738 1829 String endDate = map.get("endDate").toString();
1739 1830 String model = map.get("model").toString();
... ... @@ -1777,17 +1868,86 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1777 1868 int startTime = Integer.valueOf(split[0].split(":")[0])*60 + Integer.valueOf(split[0].split(":")[1]);
1778 1869 int endTime = Integer.valueOf(split[1].split(":")[0])*60 + Integer.valueOf(split[1].split(":")[1]);
1779 1870  
  1871 + Map<String, Boolean> lineNature = lineService.lineNature();
  1872 +
1780 1873 for(ScheduleRealInfo schedule : list){
1781 1874 Long fcsj = schedule.getFcsjT();
1782 1875 if(sfqr == 1 && !(endTime!=0?fcsj>=startTime&&fcsj<endTime:fcsj>=startTime)){
1783 1876 continue;
1784 1877 }
1785   - String key = schedule.getXlName();
  1878 +
  1879 + String xlBm = schedule.getXlBm();
  1880 + if(lineNature.containsKey(xlBm) && lineNature.get(xlBm) != null){
  1881 + if(sfyy.equals("1") && !lineNature.get(xlBm)){
  1882 + continue;
  1883 + } else if(sfyy.equals("2") && lineNature.get(xlBm)){
  1884 + continue;
  1885 + }
  1886 + } else if(sfyy.equals("2")){
  1887 + continue;
  1888 + }
  1889 +
  1890 + String key = schedule.getXlName() + "/" + schedule.getFgsName();
1786 1891 if(!keyMap.containsKey(key))
1787 1892 keyMap.put(key, new ArrayList<ScheduleRealInfo>());
1788 1893 keyMap.get(key).add(schedule);
1789 1894 }
1790 1895  
  1896 + List<String> keyList = new ArrayList<String>();
  1897 + keyList.addAll(keyMap.keySet());
  1898 + Collections.sort(keyList, new Comparator<String>() {
  1899 +
  1900 + public int compare(String o1, String o2) {
  1901 +
  1902 + Long a = 0l;
  1903 + Long b = 0l;
  1904 + String[] split1 = o1.split("/");
  1905 + String[] split2 = o2.split("/");
  1906 + char[] charArray1 = split1[0].toCharArray();
  1907 + char[] charArray2 = split2[0].toCharArray();
  1908 + for(int i = 0; i < charArray1.length; i++){
  1909 + long temp = 1l;
  1910 + for(int j = 0; j < i; j++)
  1911 + temp *= 10;
  1912 + a += (long)charArray1[charArray1.length - 1 - i] * temp;
  1913 + }
  1914 + for(int i = 0; i < charArray2.length; i++){
  1915 + long temp = 1l;
  1916 + for(int j = 0; j < i; j++)
  1917 + temp *= 10;
  1918 + b += (long)charArray2[charArray2.length - 1 - i] * temp;
  1919 + }
  1920 +
  1921 + return a.compareTo(b);
  1922 + }
  1923 + });
  1924 + Collections.sort(keyList, new Comparator<String>() {
  1925 +
  1926 + public int compare(String o1, String o2) {
  1927 +
  1928 + Long a = 0l;
  1929 + Long b = 0l;
  1930 + String[] split1 = o1.split("/");
  1931 + String[] split2 = o2.split("/");
  1932 + char[] charArray1 = split1[1].toCharArray();
  1933 + char[] charArray2 = split2[1].toCharArray();
  1934 + for(int i = 0; i < charArray1.length; i++){
  1935 + long temp = 1l;
  1936 + for(int j = 0; j < i; j++)
  1937 + temp *= 10;
  1938 + a += (long)charArray1[charArray1.length - 1 - i] * temp;
  1939 + }
  1940 + for(int i = 0; i < charArray2.length; i++){
  1941 + long temp = 1l;
  1942 + for(int j = 0; j < i; j++)
  1943 + temp *= 10;
  1944 + b += (long)charArray2[charArray2.length - 1 - i] * temp;
  1945 + }
  1946 +
  1947 + return a.compareTo(b);
  1948 + }
  1949 + });
  1950 +
1791 1951 Map<String, Object> temp = new HashMap<String, Object>();
1792 1952 int jhbc_ = 0, sjbc_ = 0,
1793 1953 lzbc_ = 0, dmbc_ = 0,
... ... @@ -1801,7 +1961,8 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1801 1961 qclc_ = new BigDecimal("0"), kxlc_ = new BigDecimal("0"),
1802 1962 qhlc_ = new BigDecimal("0"), wylc_ = new BigDecimal("0"),
1803 1963 qtlc_ = new BigDecimal("0");
1804   - for(String key : keyMap.keySet()){
  1964 +// for(String key : keyMap.keySet()){
  1965 + for(String key : keyList){
1805 1966 Map<String, Object> tempMap = new HashMap<String, Object>();
1806 1967 int jhbc = 0, sjbc = 0,
1807 1968 lzbc = 0, dmbc = 0,
... ... @@ -1907,11 +2068,12 @@ public class BusIntervalServiceImpl implements BusIntervalService {
1907 2068 if(jhlc.doubleValue() == 0d){
1908 2069 flag = false;
1909 2070 }
  2071 + String[] keys = key.split("/");
1910 2072 tempMap.put("date", Date);
1911 2073 tempMap.put("company", companyName);
1912   - tempMap.put("subCompany", subCompanyName);
  2074 + tempMap.put("subCompany", keys[1]);
1913 2075 tempMap.put("times", sfqr == 1 ? times : "全日");
1914   - tempMap.put("line", key);
  2076 + tempMap.put("line", keys[0]);
1915 2077 tempMap.put("jhbc", jhbc);
1916 2078 tempMap.put("sjbc", sjbc);
1917 2079 tempMap.put("bcbfb", df.format(jhbc>0?(double)sjbc/jhbc*100:0)+"%");
... ... @@ -2055,10 +2217,14 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2055 2217 Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>();
2056 2218 Map<String, List<Map<String, Object>>> keyMap0 = new HashMap<String, List<Map<String, Object>>>();
2057 2219 Map<String, List<Map<String, Object>>> keyMap1 = new HashMap<String, List<Map<String, Object>>>();
2058   -
2059   - String company = map.get("company").toString();
2060   - String subCompany = map.get("subCompany").toString();
  2220 +
  2221 + String company = "", subCompany = "";
  2222 + String sfyy = map.get("sfyy").toString();
2061 2223 String line = map.get("line").toString();
  2224 + if(map.get("company")!=null)
  2225 + company = map.get("company").toString();
  2226 + if(map.get("subCompany")!=null)
  2227 + subCompany = map.get("subCompany").toString();
2062 2228 String startDate = map.get("startDate").toString();
2063 2229 String endDate = map.get("endDate").toString();
2064 2230 String times = map.get("times").toString();
... ... @@ -2091,7 +2257,10 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2091 2257 }
2092 2258 }
2093 2259 if(company.length() != 0){
2094   - sql += " and (gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"')";
  2260 + sql += " and gs_bm = '"+company+"'";
  2261 + }
  2262 + if(subCompany.length() != 0){
  2263 + sql += " and fgs_bm = '"+subCompany+"'";
2095 2264 }
2096 2265 sql += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
2097 2266  
... ... @@ -2152,10 +2321,23 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2152 2321 date = startDate;
2153 2322 else
2154 2323 date = startDate + "--" + endDate;
  2324 +
  2325 + Map<String, Boolean> lineNature = lineService.lineNature();
2155 2326  
2156 2327 for(ScheduleRealInfo schedule : list){
2157 2328 if(schedule.getXlName() == null || schedule.getXlName().trim().length() == 0)
2158 2329 continue;
  2330 + String xlBm = schedule.getXlBm();
  2331 + if(lineNature.containsKey(xlBm) && lineNature.get(xlBm) != null){
  2332 + if(sfyy.equals("1") && !lineNature.get(xlBm)){
  2333 + continue;
  2334 + } else if(sfyy.equals("2") && lineNature.get(xlBm)){
  2335 + continue;
  2336 + }
  2337 + } else if(sfyy.equals("2")){
  2338 + continue;
  2339 + }
  2340 +
2159 2341 String key = schedule.getGsName() + "/" + schedule.getFgsName() + "/" + schedule.getXlBm();
2160 2342 if(!keyMap.containsKey(key))
2161 2343 keyMap.put(key, new ArrayList<ScheduleRealInfo>());
... ... @@ -2339,13 +2521,14 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2339 2521 // tempMap.put("correctbl", df.format((double)(sddf + zddf + dxtz + lbtz)/sjbc*100) + "%");
2340 2522 resList.add(tempMap);
2341 2523 }
  2524 +
2342 2525 //计算掉线调整
2343 2526 String sqldot = "select * from "
2344   - + "logger_sch_modify where gsbm =? and fgsbm=? and rq BETWEEN ? and ? order by line_code,sch_id";
2345   -
2346   - ;
  2527 + + "logger_sch_modify where gsbm = ? and fgsbm like ? and rq BETWEEN ? and ? order by line_code,sch_id";
  2528 +
  2529 +
2347 2530 List<SchEditInfoDto> listDot = jdbcTemplate.query(sqldot,
2348   - new BeanPropertyRowMapper(SchEditInfoDto.class),company,subCompany,map.get("startDate").toString(),map.get("endDate").toString());
  2531 + new BeanPropertyRowMapper(SchEditInfoDto.class),company,"%"+subCompany+"%",map.get("startDate").toString(),map.get("endDate").toString());
2349 2532 int dxtzz=0;
2350 2533 Map<String, Object> mapSchId=new HashMap<String,Object>();
2351 2534 for (int i = 0; i < resList.size(); i++) {
... ... @@ -2860,21 +3043,28 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2860 3043 String startDate = map.get("startDate").toString().trim();
2861 3044 String endDate = map.get("endDate").toString().trim();
2862 3045 String line = map.get("line").toString().trim();
2863   - String company = map.get("gs").toString().trim();
2864   - String subCompany = map.get("fgs").toString().trim();
  3046 + String company = "", subCompany = "";
  3047 + if(map.get("gs")!=null)
  3048 + company = map.get("gs").toString().trim();
  3049 + if(map.get("fgs")!=null)
  3050 + subCompany = map.get("fgs").toString().trim();
  3051 + String sfyy = "";
  3052 + if(map.get("sfyy")!=null)
  3053 + sfyy = map.get("sfyy").toString().trim();
2865 3054  
2866 3055 String sql = "select id, cl_zbh, fcsj, fcsj_actual, j_gh, j_name, lp_name, qdz_name, " +
2867   - "schedule_date_str, xl_name, zdsj, zdsj_actual, fgs_name, gs_name, xl_dir, xl_bm " +
  3056 + "schedule_date_str, xl_name, zdsj, zdsj_actual, fgs_bm, fgs_name, gs_name, xl_dir, xl_bm " +
2868 3057 "from bsth_c_s_sp_info_real " +
2869 3058 "where schedule_date_str >= '"+startDate+"' and schedule_date_str <= '"+endDate+"' " +
2870 3059 "and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks' and cc_service = 0";
2871 3060  
2872 3061 if(company.length() != 0)
2873   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  3062 + sql += " and gs_bm = '"+company+"'";
  3063 + if(subCompany.length() != 0)
  3064 + sql += " and fgs_bm = '"+subCompany+"'";
2874 3065 if(line.length() != 0)
2875 3066 sql += " and xl_bm = '"+line+"'";
2876 3067  
2877   - System.out.println(sql);
2878 3068 List<ScheduleRealInfo> list = jdbcTemplate.query(sql,
2879 3069 new RowMapper<ScheduleRealInfo>(){
2880 3070 @Override
... ... @@ -2893,6 +3083,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2893 3083 schedule.setQdzName(rs.getString("qdz_name"));
2894 3084 schedule.setGsName(rs.getString("gs_name"));
2895 3085 schedule.setFgsName(rs.getString("fgs_name"));
  3086 + schedule.setFgsBm(rs.getString("fgs_bm"));
2896 3087 schedule.setClZbh(rs.getString("cl_zbh"));
2897 3088 schedule.setjGh(rs.getString("j_gh"));
2898 3089 schedule.setjName(rs.getString("j_name"));
... ... @@ -2903,8 +3094,21 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2903 3094 Map<String, Map<String, List<ScheduleRealInfo>>> sches = new HashMap<String, Map<String, List<ScheduleRealInfo>>>();
2904 3095 Map<String, List<List<Map<String, Object>>>> keyMap = new HashMap<String, List<List<Map<String, Object>>>>();
2905 3096  
  3097 + Map<String, Boolean> lineNature = lineService.lineNature();
  3098 +
2906 3099 for(ScheduleRealInfo s : list){
2907   - String xl = s.getXlName();
  3100 + String xlBm = s.getXlBm();
  3101 + if(lineNature.containsKey(xlBm) && lineNature.get(xlBm) != null){
  3102 + if(sfyy.equals("1") && !lineNature.get(xlBm)){
  3103 + continue;
  3104 + } else if(sfyy.equals("2") && lineNature.get(xlBm)){
  3105 + continue;
  3106 + }
  3107 + } else if(sfyy.equals("2")){
  3108 + continue;
  3109 + }
  3110 +
  3111 + String xl = s.getXlName() + "/" + s.getFgsName();
2908 3112 String dateStr = s.getScheduleDateStr();
2909 3113 if(!sches.containsKey(xl)){
2910 3114 sches.put(xl, new HashMap<String, List<ScheduleRealInfo>>());
... ... @@ -2956,6 +3160,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
2956 3160 Map<String, Object> temp = new HashMap<String, Object>();
2957 3161 temp.put("gs", s.getGsName());
2958 3162 temp.put("fgs", s.getFgsName());
  3163 + temp.put("fgsBm", s.getFgsBm());
2959 3164 temp.put("date", date);
2960 3165 temp.put("xlbm", s.getXlBm());
2961 3166 temp.put("line", s.getXlName());
... ... @@ -3020,6 +3225,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
3020 3225 }
3021 3226 tempMap.put("gs", list1.get(0).get(0).get("gs"));
3022 3227 tempMap.put("fgs", list1.get(0).get(0).get("fgs"));
  3228 + tempMap.put("fgsBm", list1.get(0).get(0).get("fgsBm"));
3023 3229 tempMap.put("line", list1.get(0).get(0).get("line"));
3024 3230 tempMap.put("date", list1.get(0).get(0).get("date"));
3025 3231 tempMap.put("xlbm", list1.get(0).get(0).get("xlbm"));
... ... @@ -3077,6 +3283,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
3077 3283 }
3078 3284 tempMap.put("gs", list2.get(0).get("gs"));
3079 3285 tempMap.put("fgs", list2.get(0).get("fgs"));
  3286 + tempMap.put("fgsBm", list2.get(0).get("fgsBm"));
3080 3287 tempMap.put("line", list2.get(0).get("line"));
3081 3288 tempMap.put("date", list2.get(0).get("date"));
3082 3289 tempMap.put("xl_date", list2.get(0).get("date") + "_" + list2.get(0).get("xlbm") + "_" + list2.get(0).get("line"));
... ...
src/main/java/com/bsth/service/impl/LineServiceImpl.java
... ... @@ -6,10 +6,14 @@ import com.bsth.repository.LineRepository;
6 6 import com.bsth.service.LineService;
7 7 import org.springframework.beans.factory.annotation.Autowired;
8 8 import org.springframework.jdbc.core.JdbcTemplate;
  9 +import org.springframework.jdbc.core.RowMapper;
9 10 import org.springframework.stereotype.Service;
10 11 import org.springframework.transaction.annotation.Transactional;
11 12  
  13 +import java.sql.ResultSet;
  14 +import java.sql.SQLException;
12 15 import java.util.HashMap;
  16 +import java.util.List;
13 17 import java.util.Map;
14 18  
15 19 /**
... ... @@ -117,4 +121,34 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L
117 121 }
118 122 return map;
119 123 }
  124 +
  125 + /*获取线路性质*/
  126 + @Override
  127 + public Map<String, Boolean> lineNature() {
  128 + // TODO Auto-generated method stub
  129 +// List<Line> lineList=repository.findLineBygsBm(gsBm, fgsBm, line);
  130 + String sql="select * from bsth_c_line ";
  131 + List<Line> lineList=jdbcTemplate.query(sql,
  132 + new RowMapper<Line>(){
  133 + @Override
  134 + public Line mapRow(ResultSet rs, int rowNum) throws SQLException {
  135 + Line l=new Line();
  136 + l.setLineCode(rs.getString("line_code"));
  137 + l.setNature(rs.getString("nature"));
  138 + return l;
  139 + }
  140 + });
  141 + Map<String, Boolean> map=new HashMap<String,Boolean>();
  142 + for (int i = 0; i < lineList.size(); i++) {
  143 + Line t=lineList.get(i);
  144 + String nature=t.getNature()==null?"":t.getNature();
  145 + if(nature.equals("yxl")||nature.equals("cgxl")||nature.equals("gjxl")
  146 + ||nature.equals("csbs")||nature.equals("cctxl")){
  147 + map.put(t.getLineCode(), true);
  148 + }else{
  149 + map.put(t.getLineCode(), false);
  150 + }
  151 + }
  152 + return map;
  153 + }
120 154 }
... ...
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
... ... @@ -77,6 +77,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{
77 77 @Autowired
78 78 private StationRouteRepository stationRouteRepository;
79 79  
  80 + // 历史站点路由repository
  81 + @Autowired
  82 + private LsStationRouteRepository lsStationRouteRepository;
  83 +
80 84 @Autowired
81 85 private SectionRepository sectionRepository;
82 86  
... ... @@ -532,7 +536,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{
532 536 //发送邮件
533 537 EmailBean mail = new EmailBean();
534 538 mail.setSubject(InetAddress.getLocalHost().getHostAddress()+":路单日志数据"+date);
535   - mail.setContent(logSuccess+"<br/>成功数:"+countSuccess+"<br/>" +logFailure+"<br/>失败数:"+countFailure);
  539 + mail.setContent("成功数:"+countSuccess+"<br/>失败数:"+countFailure+"<br/>" +logSuccess + "<br/>"+logFailure);
536 540 sendEmailController.sendMail(emailSendToAddress, mail);
537 541 logger.info("setLD-sendMail:邮件发送成功!");
538 542 }catch (Exception e){
... ... @@ -944,6 +948,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{
944 948 String result = "failure";
945 949 StringBuffer sBuffer = new StringBuffer();
946 950 DecimalFormat df = new DecimalFormat("######0.000");
  951 + Map<String,String> lsStationCode2NameMap;
  952 + Map<String, Integer> lsStationName2YgcNumber;
947 953 try {
948 954 String[] idArray = ids.split(",");
949 955 StringBuffer sBufferA ,sBufferB ,sBufferC ;
... ... @@ -960,10 +966,17 @@ public class TrafficManageServiceImpl implements TrafficManageService{
960 966 HashMap<String,String> paramMap;
961 967 HashMap<String,String> otherMap = new HashMap<>();
962 968 for (int i = 0; i < idArray.length; i++) {
963   - ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i]));
  969 + long ttinfoId = Long.valueOf(idArray[i]);
  970 + ttInfo = ttInfoRepository.findOne(ttinfoId);
964 971 if(ttInfo == null)
965 972 continue;
966 973 ttinfoList.add(ttInfo); // 保存时刻表
  974 + // 得到时刻表版本号
  975 + int lineVersion = ttInfo.getLineVersion();
  976 + // 查询历史站点路由
  977 + lsStationCode2NameMap = getLsStationCode(ttInfo.getXl().getLineCode(),lineVersion);
  978 + // 查询历史站点路由
  979 + lsStationName2YgcNumber = getLsStationRoute(ttInfo.getXl().getLineCode(),lineVersion);
967 980 zlc = 0.0f;
968 981 yylc = 0.0f;
969 982 // 获得时刻表
... ... @@ -992,7 +1005,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{
992 1005 ttInfoDetail = ttInfoDetailIterator.next();
993 1006 bcType = ttInfoDetail.getBcType();
994 1007 sxx = ttInfoDetail.getXlDir();
995   - // 进出场班次
  1008 + // 进出场班次的里程,加入总里程
996 1009 if(bcType.equals("in") || bcType.equals("out")){
997 1010 // 进出班次的计划里程,算空驶里程
998 1011 emptyLc = ttInfoDetail.getJhlc();
... ... @@ -1000,6 +1013,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1000 1013 zlc += emptyLc;
1001 1014 continue;
1002 1015 }
  1016 + // 不是正常班次,不传到运管处
  1017 + if(!bcType.equals("normal")){
  1018 + continue;
  1019 + }
1003 1020 // 如果发车时间格式错误,忽略此条
1004 1021 if(changeTimeFormat(ttInfoDetail) == null){
1005 1022 continue;
... ... @@ -1007,19 +1024,19 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1007 1024 sBufferC.append("<BC>");
1008 1025 sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>");
1009 1026 sBufferC.append("<SXX>").append(sxx).append("</SXX>");
1010   - sBufferC.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
  1027 + sBufferC.append("<FCZDMC>").append(lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
1011 1028 +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>");
1012 1029 // 起点站的参数
1013 1030 otherMap.put("stationMark","B");
1014 1031 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap);
1015   - sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>");
  1032 + sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)).append("</ZDXH>");
1016 1033 sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>");
1017   - sBufferC.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
  1034 + sBufferC.append("<DDZDMC>").append(lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
1018 1035 +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>");
1019 1036 // 起点站的参数
1020 1037 otherMap.put("stationMark","E");
1021 1038 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap);
1022   - sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>");
  1039 + sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)).append("</DDXH>");
1023 1040 sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>");
1024 1041 sBufferC.append("</BC>");
1025 1042 // 0:上行;1:下行
... ... @@ -1520,4 +1537,51 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1520 1537 map.put("stationMark",stationMark); // 站点类型
1521 1538 return map;
1522 1539 }
  1540 +
  1541 + /**
  1542 + * 取得历史站点编码和站点名称的对应关系
  1543 + * @return
  1544 + */
  1545 + private Map<String, String> getLsStationCode(String lineCode,int lineVersion){
  1546 + Map<String,Object> map = new HashMap<>();
  1547 + map.put("lineCode_eq", lineCode);
  1548 + map.put("versions_eq",lineVersion);
  1549 + LsStationRoute lsroute;
  1550 + Iterator<LsStationRoute> iterator = lsStationRouteRepository.findAll(new CustomerSpecs<LsStationRoute>(map)).iterator();
  1551 + Map<String, String> stationCode2Name = new HashMap<>();
  1552 + while (iterator.hasNext()) {
  1553 + lsroute = iterator.next();
  1554 + stationCode2Name.put(lsroute.getLineCode() + "_" + lsroute.getDirections() + "_" + lsroute.getStationCode(), lsroute.getStationName());
  1555 + }
  1556 + return stationCode2Name;
  1557 + }
  1558 +
  1559 + private Map<String, Integer> getLsStationRoute(String xlbm,int lineVersion){
  1560 + Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>();
  1561 + /**
  1562 + * 加载运管处的站点及序号
  1563 + * 上行从1开始,下行顺序续编
  1564 + */
  1565 + List<Map<String, String>> ygcLines = lsStationRouteRepository.findLineWithLineCode4Ygc(xlbm,lineVersion);
  1566 + if(ygcLines != null && ygcLines.size() > 0){
  1567 + int size = ygcLines.size();
  1568 + Map<String, String> tempMap ;
  1569 + int num = 1;
  1570 + String key;
  1571 + String lineCode = "";
  1572 + for (int i = 0; i < size; i ++){
  1573 + tempMap = ygcLines.get(i);
  1574 + if(lineCode.equals("")){
  1575 + lineCode = tempMap.get("lineCode");
  1576 + }else if(!lineCode.equals(tempMap.get("lineCode"))){
  1577 + num = 1;
  1578 + lineCode = tempMap.get("lineCode");
  1579 + }
  1580 + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions"))
  1581 + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark");
  1582 + tempStationName2YgcNumber.put(key,num++);
  1583 + }
  1584 + }
  1585 + return tempStationName2YgcNumber;
  1586 + }
1523 1587 }
... ...
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
... ... @@ -117,10 +117,10 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
117 117  
118 118 List<Map<String,Object>> statisticsDaily(String line, String date, String xlName, String type);
119 119  
120   - List<Map<String,Object>> statisticsDailyTj(String gsdm,String fgsdm,String line, String date,String date2, String xlName, String type);
  120 + List<Map<String,Object>> statisticsDailyTj(String gsdm,String fgsdm,String line, String date,String date2, String xlName, String type,String nature);
121 121  
122 122 //用于实时数据与统计数据合并查询
123   - List<Map<String,Object>> statisticsDailyTjHb(String gsdm,String fgsdm,String line, String date,String date2, String xlName, String type);
  123 + List<Map<String,Object>> statisticsDailyTjHb(String gsdm,String fgsdm,String line, String date,String date2, String xlName, String type,String nature);
124 124  
125 125 //List<Object> scheduleDaily(String line,String date);
126 126  
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -53,6 +53,7 @@ import com.bsth.repository.schedule.CarConfigInfoRepository;
53 53 import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
54 54 import com.bsth.repository.schedule.GuideboardInfoRepository;
55 55 import com.bsth.security.util.SecurityUtils;
  56 +import com.bsth.service.LineService;
56 57 import com.bsth.service.SectionRouteService;
57 58 import com.bsth.service.directive.DirectiveService;
58 59 import com.bsth.service.impl.BaseServiceImpl;
... ... @@ -114,7 +115,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
114 115  
115 116 @Autowired
116 117 LineRepository lineRepository;
117   -
  118 + @Autowired
  119 + LineService lineService;
118 120 @Autowired
119 121 GuideboardInfoRepository guideboardInfoRepository;
120 122  
... ... @@ -2232,6 +2234,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2232 2234 }
2233 2235 try {
2234 2236 String dateTime = sdfSimple.format(sdfMonth.parse(date));
  2237 + if(!endDate.equals(date)){
  2238 + dateTime += "-" + sdfSimple.format(sdfMonth.parse(endDate));
  2239 + }
2235 2240 String lineName = BasicData.lineCode2NameMap.get(line);
2236 2241 listI.add(tempList.iterator());
2237 2242 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
... ... @@ -2666,10 +2671,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2666 2671 }
2667 2672 Map<String, Object> map = new HashMap<String, Object>();
2668 2673 if (list.size() > 0) {
  2674 + map.put("fgsBm", list.get(0).getFgsBm());
2669 2675 map.put("xlBm", list.get(0).getXlBm());
2670 2676 map.put("xlName", list.get(0).getXlName());
  2677 + map.put("fgsName", list.get(0).getFgsName());
2671 2678 try {
2672   - map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE));
  2679 + map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getFgsBm()+list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE));
2673 2680 } catch (PinyinException e) {
2674 2681 // TODO Auto-generated catch block
2675 2682 e.printStackTrace();
... ... @@ -2679,7 +2686,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2679 2686 map.put("jhlc", jhyygl);
2680 2687 map.put("jcclc", jhjcclc);
2681 2688 map.put("jhzlc", Arith.add(jhyygl, jhjcclc));
2682   -
  2689 + double ljks=culateService.culateLjksgl(lists);
  2690 + map.put("ljks", ljks);
2683 2691 double ljgl = culateService.culateLjgl(lists);
2684 2692 double sjyygl = culateService.culateSjgl(lists);
2685 2693 double zyygl = Arith.add(sjyygl, ljgl);
... ... @@ -2744,18 +2752,34 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2744 2752  
2745 2753 @Override
2746 2754 public List<Map<String, Object>> statisticsDailyTj(String gsdm, String fgsdm, String line, String date, String date2,
2747   - String xlName, String type) {
2748   - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  2755 + String xlName, String type,String nature) {
  2756 + List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();
2749 2757 List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();
2750 2758 List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
2751 2759 line = line.trim();
2752 2760 if (line.equals("")) {
2753 2761 //查询所有线路
2754   - list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);
  2762 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);
2755 2763 } else {
2756 2764 //查询单条线路
2757   - list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);
2758   - }
  2765 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);
  2766 + }
  2767 + Map<String, Boolean> lineMap=lineService.lineNature();
  2768 + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
  2769 + for (int i = 0; i < listAll.size(); i++) {
  2770 + ScheduleRealInfo s=listAll.get(i);
  2771 + if (nature.equals("0")) {
  2772 + list.add(s);
  2773 + }else if(nature.equals("1")){
  2774 + if(lineMap.get(s.getXlBm())){
  2775 + list.add(s);
  2776 + }
  2777 + }else{
  2778 + if(!lineMap.get(s.getXlBm())){
  2779 + list.add(s);
  2780 + }
  2781 + }
  2782 + }
2759 2783 for (int i = 0; i < list.size(); i++) {
2760 2784 ScheduleRealInfo s = list.get(i);
2761 2785 Set<ChildTaskPlan> cts = s.getcTasks();
... ... @@ -2770,7 +2794,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2770 2794 List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
2771 2795 for (int i = 0; i < list.size(); i++) {
2772 2796 if (i < list.size() - 1) {
2773   - if (list.get(i + 1).getXlBm().equals(list.get(i).getXlBm())) {
  2797 + if ((list.get(i+1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) {
2774 2798 lists.add(list.get(i));
2775 2799 } else {
2776 2800 lists.add(list.get(i));
... ... @@ -2779,7 +2803,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2779 2803 lists = new ArrayList<ScheduleRealInfo>();
2780 2804 }
2781 2805 } else {
2782   - if (list.get(i).getXlBm().equals(list.get(i - 1).getXlBm())) {
  2806 + if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) {
2783 2807 lists.add(list.get(i));
2784 2808 Map<String, Object> map = staticTj(lists);
2785 2809 lMap.add(map);
... ... @@ -2791,10 +2815,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2791 2815 }
2792 2816 }
2793 2817 }
2794   -
  2818 + /*if(!line.equals("")){
  2819 + List<Line> l=lineRepository.findLineByCode(line);
  2820 + if(l.size()>0)
  2821 + lMap.get(0).put("fgsName", BasicData.businessFgsCodeNameMap.get(l.get(0).getBrancheCompany()+"_"+l.get(0).getCompany()));
  2822 + }*/
2795 2823 Collections.sort(lMap, new AccountXlbm());
2796 2824 Map<String, Object> map = new HashMap<String, Object>();
2797 2825 map.put("xlName", "合计");
  2826 + map.put("fgsName", "");
2798 2827 double jhyygl = culateService.culateJhgl(list);//计划营运公里
2799 2828 double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)
2800 2829 map.put("jhlc", jhyygl);
... ... @@ -2804,7 +2833,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2804 2833 double ljgl = culateService.culateLjgl(list_s);
2805 2834 double sjyygl = culateService.culateSjgl(list_s);
2806 2835 double zyygl = Arith.add(sjyygl, ljgl);
2807   -
  2836 + double ljks=culateService.culateLjksgl(list_s);
  2837 + map.put("ljks", ljks);
2808 2838 double sjjccgl = culateService.culateJccgl(list_s);
2809 2839 double sjksgl = culateService.culateKsgl(list_s);
2810 2840 double zksgl = Arith.add(sjjccgl, sjksgl);
... ... @@ -2902,7 +2932,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2902 2932 }
2903 2933 listI.add(lMap.iterator());
2904 2934 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
2905   - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_.xls",
  2935 + ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls",
2906 2936 path + "export/" + dateTime + "-" + xlName + "-统计日报.xls");
2907 2937 } catch (Exception e) {
2908 2938 // TODO: handle exception
... ... @@ -2916,18 +2946,35 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2916 2946  
2917 2947 @Override
2918 2948 public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2,
2919   - String xlName, String type) {
2920   - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  2949 + String xlName, String type,String nature) {
  2950 + List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>();
2921 2951 List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();
2922 2952 List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>();
2923 2953 line = line.trim();
2924 2954 if (line.equals("")) {
2925 2955 //查询所有线路
2926   - list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);
  2956 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm);
2927 2957 } else {
2928 2958 //查询单条线路
2929   - list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);
2930   - }
  2959 + listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2);
  2960 + }
  2961 +
  2962 + Map<String, Boolean> lineMap=lineService.lineNature();
  2963 + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
  2964 + for (int i = 0; i < listAll.size(); i++) {
  2965 + ScheduleRealInfo s=listAll.get(i);
  2966 + if (nature.equals("0")) {
  2967 + list.add(s);
  2968 + }else if(nature.equals("1")){
  2969 + if(lineMap.get(s.getXlBm())){
  2970 + list.add(s);
  2971 + }
  2972 + }else{
  2973 + if(!lineMap.get(s.getXlBm())){
  2974 + list.add(s);
  2975 + }
  2976 + }
  2977 + }
2931 2978 for (int i = 0; i < list.size(); i++) {
2932 2979 ScheduleRealInfo s = list.get(i);
2933 2980 Set<ChildTaskPlan> cts = s.getcTasks();
... ... @@ -2942,7 +2989,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2942 2989 List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
2943 2990 for (int i = 0; i < list.size(); i++) {
2944 2991 if (i < list.size() - 1) {
2945   - if (list.get(i + 1).getXlBm().equals(list.get(i).getXlBm())) {
  2992 + if ((list.get(i + 1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) {
2946 2993 lists.add(list.get(i));
2947 2994 } else {
2948 2995 lists.add(list.get(i));
... ... @@ -2951,7 +2998,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2951 2998 lists = new ArrayList<ScheduleRealInfo>();
2952 2999 }
2953 3000 } else {
2954   - if (list.get(i).getXlBm().equals(list.get(i - 1).getXlBm())) {
  3001 + if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) {
2955 3002 lists.add(list.get(i));
2956 3003 Map<String, Object> map = staticTj(lists);
2957 3004 lMap.add(map);
... ... @@ -2968,6 +3015,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2968 3015 Map<String, Object> map = new HashMap<String, Object>();
2969 3016 map.put("xlBm", "hj");
2970 3017 map.put("xlName", "合计");
  3018 + map.put("fgsBm", "");
  3019 + map.put("fgsName", "");
  3020 + map.put("gsBm", "");
2971 3021 double jhyygl = culateService.culateJhgl(list);//计划营运公里
2972 3022 double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里)
2973 3023 map.put("jhlc", jhyygl);
... ... @@ -2977,7 +3027,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2977 3027 double ljgl = culateService.culateLjgl(list_s);
2978 3028 double sjyygl = culateService.culateSjgl(list_s);
2979 3029 double zyygl = Arith.add(sjyygl, ljgl);
2980   -
  3030 + double ljks=culateService.culateLjksgl(list_s);
  3031 + map.put("ljks", ljks);
2981 3032 double sjjccgl = culateService.culateJccgl(list_s);
2982 3033 double sjksgl = culateService.culateKsgl(list_s);
2983 3034 double zksgl = Arith.add(sjjccgl, sjksgl);
... ...
src/main/java/com/bsth/service/report/CalcSheetService.java 0 → 100644
  1 +package com.bsth.service.report;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.bsth.entity.sheet.CalcSheet;
  7 +import com.bsth.entity.sheet.Sheet;
  8 +import com.bsth.service.BaseService;
  9 +
  10 +public interface CalcSheetService extends BaseService<CalcSheet, Integer>{
  11 + public List<CalcSheet> countListCalcSheet(Map<String, Object> map);
  12 + public List<CalcSheet> calcListSheet(Map<String, Object> map);
  13 + public List<Sheet> calcSheet(Map<String, Object> map);
  14 + public List<Map<String, Object>> calcTurnoutrate(Map<String, Object> map);
  15 +}
... ...
src/main/java/com/bsth/service/report/CulateMileageService.java
... ... @@ -4,6 +4,7 @@ import java.util.List;
4 4 import java.util.Map;
5 5  
6 6 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  7 +import com.google.common.util.concurrent.AbstractScheduledService.Scheduler;
7 8  
8 9 public interface CulateMileageService {
9 10  
... ... @@ -12,6 +13,7 @@ public interface CulateMileageService {
12 13 int culateLbbc(List<ScheduleRealInfo> lists);
13 14  
14 15 List<Map<String,Object>> jobLjqk(List<ScheduleRealInfo> lists);
  16 + double culateLjksgl(List<ScheduleRealInfo> lists);
15 17 double culateLjgl(List<ScheduleRealInfo> lists);
16 18 double culateLjgl_(List<ScheduleRealInfo> lists,String item);
17 19 double culateLjgl_spy(List<ScheduleRealInfo> lists);
... ... @@ -43,7 +45,7 @@ public interface CulateMileageService {
43 45  
44 46 int culateDtfzbc(List<ScheduleRealInfo> lists,String type,String status,String item);
45 47  
46   -
  48 +
47 49 //以下计算方法供新报表使用
48 50 Map<String, Double> culateSjlcMap(List<ScheduleRealInfo> lists);//计划内营运and计划外营运
49 51  
... ...
src/main/java/com/bsth/service/report/impl/CalcSheetServiceImpl.java 0 → 100644
  1 +package com.bsth.service.report.impl;
  2 +
  3 +
  4 +import java.lang.reflect.InvocationTargetException;
  5 +import java.sql.ResultSet;
  6 +import java.sql.SQLException;
  7 +import java.text.DecimalFormat;
  8 +import java.text.ParseException;
  9 +import java.text.SimpleDateFormat;
  10 +import java.util.ArrayList;
  11 +import java.util.Calendar;
  12 +import java.util.Collections;
  13 +import java.util.Comparator;
  14 +import java.util.Date;
  15 +import java.util.GregorianCalendar;
  16 +import java.util.HashMap;
  17 +import java.util.Iterator;
  18 +import java.util.List;
  19 +import java.util.Map;
  20 +
  21 +import org.apache.commons.lang3.StringUtils;
  22 +import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.jdbc.core.JdbcTemplate;
  24 +import org.springframework.jdbc.core.RowMapper;
  25 +import org.springframework.stereotype.Service;
  26 +
  27 +import com.bsth.data.BasicData;
  28 +import com.bsth.entity.Line;
  29 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  30 +import com.bsth.entity.sheet.CalcSheet;
  31 +import com.bsth.entity.sheet.Sheet;
  32 +import com.bsth.repository.LineRepository;
  33 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  34 +import com.bsth.service.LineService;
  35 +import com.bsth.service.impl.BaseServiceImpl;
  36 +import com.bsth.service.report.CalcSheetService;
  37 +import com.bsth.util.ComparableReal;
  38 +import com.bsth.util.ReportRelatedUtils;
  39 +import com.bsth.util.ReportUtils;
  40 +
  41 +
  42 +@Service
  43 +public class CalcSheetServiceImpl extends BaseServiceImpl<CalcSheet, Integer> implements CalcSheetService {
  44 + @Autowired
  45 + JdbcTemplate jdbcTemplate;
  46 + @Autowired
  47 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  48 + @Autowired
  49 + LineRepository lineRepository;
  50 + @Autowired
  51 + LineService lineService;
  52 + @Override
  53 + public List<CalcSheet> countListCalcSheet(Map<String, Object> map) {
  54 + // TODO Auto-generated method stub
  55 + final DecimalFormat df = new DecimalFormat("0.00");
  56 + String line="";
  57 + if(map.get("line")!=null){
  58 + line =map.get("line").toString().trim();
  59 + }
  60 + String gs="";
  61 + if(map.get("gs")!=null){
  62 + gs=map.get("gs").toString().trim();
  63 + }
  64 + String fgs="";
  65 + if(map.get("fgs")!=null){
  66 + fgs=map.get("fgs").toString().trim();
  67 + }
  68 + String nature="0";
  69 + if(map.get("nature")!=null){
  70 + nature=map.get("nature").toString();
  71 + }
  72 + Map<String, Boolean> lineMap=lineService.lineNature();
  73 +
  74 + String date=map.get("date").toString();
  75 + String endDate=map.get("endDate").toString();
  76 + String sql="select gsdm,fgsdm,xl,xl_name,max(id) as id,sum(jhszfcs) as jhszfcs ,"
  77 + + " sum(sjszfczds) as sjszfczds,sum(sjszddzds) as sjszddzds"
  78 + + " from bsth_c_calc_sheet where date >= '"+date+"' and date <= '"+endDate+"'";
  79 + if(line.trim().equals("")){
  80 + sql +=" and gsdm = '"+gs+"' and fgsdm like '%"+fgs+"%'";
  81 + }else{
  82 + sql +=" and xl ='"+line+"'";
  83 + }
  84 + sql +=" group by gsdm,fgsdm,xl,xl_name";
  85 + List<CalcSheet> lists=jdbcTemplate.query(sql,
  86 + new RowMapper<CalcSheet>(){
  87 + @Override
  88 + public CalcSheet mapRow(ResultSet rs, int rowNum) throws SQLException {
  89 + CalcSheet s=new CalcSheet();
  90 + s.setGsdm(rs.getString("gsdm"));
  91 + s.setFgsdm(rs.getString("fgsdm"));
  92 + s.setXl(rs.getString("xl"));
  93 + s.setXlName(rs.getString("xl_name"));
  94 + s.setId(rs.getInt("id"));
  95 + s.setJhszfcs(rs.getString("jhszfcs"));
  96 + s.setSjszfczds(rs.getString("sjszfczds"));
  97 + s.setSjszddzds(rs.getString("sjszddzds"));
  98 + int jhfc=Integer.parseInt(rs.getString("jhszfcs"));
  99 + int zdfc=Integer.parseInt(rs.getString("sjszfczds"));
  100 + int zddd=Integer.parseInt(rs.getString("sjszddzds"));
  101 + if(jhfc>0){
  102 + double zdl=(zdfc*1.0)/(jhfc*1.0)*100;
  103 + s.setSzfczdl(df.format(zdl)+"%");
  104 + zdl=(zddd*1.0)/(jhfc*1.0)*100;
  105 + s.setSzddzdl(df.format(zdl)+"%");
  106 + }else{
  107 + s.setSzfczdl("0.0%");
  108 + s.setSzddzdl("0.0%");
  109 + }
  110 + return s;
  111 + }
  112 + });
  113 + List<CalcSheet> list=new ArrayList<CalcSheet>();
  114 + for (int i = 0; i < lists.size(); i++) {
  115 + if (nature.equals("0")) {
  116 + list.add(lists.get(i));
  117 + }else if(nature.equals("1")){
  118 + if(lineMap.get(lists.get(i).getXl())){
  119 + list.add(lists.get(i));
  120 + }
  121 + }else{
  122 + if(!lineMap.get(lists.get(i).getXl())){
  123 + list.add(lists.get(i));
  124 + }
  125 + }
  126 + }
  127 + if(map.get("type").equals("export")){
  128 + String lineName="";
  129 + if(!line.equals("")){
  130 + lineName=list.get(0).getXlName();
  131 + }else if(!fgs.equals("")){
  132 + lineName=list.get(0).getFgsname();
  133 + }else{
  134 + lineName=list.get(0).getGsname();
  135 + }
  136 + List<Map<String, Object>> listmap=new ArrayList<Map<String, Object>>();
  137 + for (int i = 0; i < list.size(); i++) {
  138 + CalcSheet c=list.get(i);
  139 + Map<String, Object> m=new HashMap<String,Object>();
  140 + m.put("gs", c.getGsname());
  141 + m.put("fgs", c.getFgsname());
  142 + m.put("line", c.getXlName());
  143 + m.put("bcs", c.getJhszfcs());
  144 + m.put("zdbcs", c.getSjszfczds());
  145 + m.put("zdlv", c.getSzfczdl());
  146 + m.put("ddzdbcs", c.getSjszddzds());
  147 + m.put("ddzdlv", c.getSzddzdl());
  148 + listmap.add(m);
  149 + }
  150 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  151 + Map<String, Object> m = new HashMap<String, Object>();
  152 + m.put("date", date);
  153 + m.put("endDate", endDate);
  154 + ReportUtils ee = new ReportUtils();
  155 + try {
  156 + String dateTime = "";
  157 + if(date.equals(endDate)){
  158 + dateTime = date.replaceAll("-", "");
  159 + } else {
  160 + dateTime = date.replaceAll("-", "")+"-"+
  161 + endDate.replaceAll("-", "");
  162 + }
  163 + listI.add(listmap.iterator());
  164 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  165 + ee.excelReplace(listI, new Object[]{m}, path + "mould/" + "calcSheetList.xls",
  166 + path + "export/"+dateTime+"-"+lineName+"-发车到站准点率.xls");
  167 + } catch (Exception e) {
  168 + // TODO: handle exception
  169 + e.printStackTrace();
  170 + }
  171 + }
  172 + return list;
  173 + }
  174 + @Override
  175 + public List<CalcSheet> calcListSheet(Map<String, Object> map) {
  176 + // TODO Auto-generated method stub
  177 + String line=map.get("line").toString();
  178 + String date=map.get("date").toString();
  179 + String endDate=map.get("endDate").toString();
  180 + String sql="select * from bsth_c_calc_sheet where date >= '"+date+"' and "
  181 + + " date <= '"+endDate+"' and xl = '"+line+"' order by date";
  182 + List<CalcSheet> list=jdbcTemplate.query(sql,
  183 + new RowMapper<CalcSheet>(){
  184 + @Override
  185 + public CalcSheet mapRow(ResultSet rs, int rowNum) throws SQLException {
  186 + CalcSheet s=new CalcSheet();
  187 + s.setGsdm(rs.getString("gsdm"));
  188 + s.setFgsdm(rs.getString("fgsdm"));
  189 + s.setXl(rs.getString("xl"));
  190 + s.setXlName(rs.getString("xl_name"));
  191 + s.setId(rs.getInt("id"));
  192 + s.setDate(rs.getString("date"));
  193 + s.setJhszfcs(rs.getString("jhszfcs"));
  194 + s.setSjszfczds(rs.getString("sjszfczds"));
  195 + s.setSzfczdl(rs.getString("szfczdl"));
  196 + s.setSjszddzds(rs.getString("sjszddzds"));
  197 + s.setSzddzdl(rs.getString("szddzdl"));
  198 + return s;
  199 + }
  200 + });
  201 + if(map.get("type").equals("export")){
  202 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  203 + for (int i = 0; i < list.size(); i++) {
  204 + Map<String, Object> m = new HashMap<String, Object>();
  205 + CalcSheet c = list.get(i);
  206 + m.put("gs", c.getGsname());
  207 + m.put("fgs", c.getFgsname());
  208 + m.put("date", c.getDate());
  209 + m.put("line", c.getXlName());
  210 + m.put("bcs", c.getJhszfcs());
  211 + m.put("zdbcs", c.getSjszfczds());
  212 + m.put("zdlv", c.getSzfczdl()+"%");
  213 + m.put("ddzdbcs", c.getSjszddzds());
  214 + m.put("ddzdlv", c.getSzddzdl()+"%");
  215 + tempList.add(m);
  216 + }
  217 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  218 + Map<String, Object> m = new HashMap<String, Object>();
  219 + m.put("date", date);
  220 + m.put("endDate", endDate);
  221 + ReportUtils ee = new ReportUtils();
  222 + try {
  223 + listI.add(tempList.iterator());
  224 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  225 + ee.excelReplace(listI, new Object[]{m}, path + "mould/" + "calcSheetList1.xls",
  226 + path + "export/发车到站准点率"+date.replaceAll("-", "")+"-"+endDate.replaceAll("-", "")+".xls");
  227 + } catch (Exception e) {
  228 + // TODO: handle exception
  229 + e.printStackTrace();
  230 + }
  231 + }
  232 + return list;
  233 + }
  234 + @Override
  235 + public List<Sheet> calcSheet(Map<String, Object> map) {
  236 + // TODO Auto-generated method stub
  237 + System.out.println();
  238 + String line=map.get("line").toString();
  239 + String date=map.get("date").toString();
  240 + String dir =map.get("dir").toString();
  241 + List<ScheduleRealInfo> list=scheduleRealInfoRepository.scheduleDaily(line, date);
  242 + Line l =lineRepository.findByLineCode(line);
  243 + List<Sheet> listSheet=new ArrayList<Sheet>();
  244 + if(list.size()>0){
  245 + if(dir.equals("1")){
  246 + listSheet=calcSheetFcZdl(list, list.get(0).getXlBm(),l.getStartStationName(),l.getEndStationName());
  247 + }else{
  248 + listSheet=calcSheetDdZdl(list, list.get(0).getXlBm(),l.getStartStationName(),l.getEndStationName());
  249 + }
  250 + if(map.get("type").equals("export")){
  251 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  252 + Map<String, Object> m = new HashMap<String, Object>();
  253 + ReportUtils ee = new ReportUtils();
  254 + try {
  255 + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
  256 + for(int i = 0; i < listSheet.size(); i++){
  257 + Map<String, Object> temp = new HashMap<String, Object>();
  258 + Sheet s = listSheet.get(i);
  259 + temp.put("id", i+1);
  260 + temp.put("date", s.getDate());
  261 + temp.put("line", s.getLine());
  262 + temp.put("zdname", s.getZdname());
  263 + temp.put("jhsj", s.getJhsj());
  264 + temp.put("sjsj", s.getSjsj());
  265 + temp.put("sfzd", s.getSfzd());
  266 + tempList.add(temp);
  267 + }
  268 + listI.add(tempList.iterator());
  269 + m.put("date", date);
  270 + String fileName="";
  271 + if(dir.equals("1")){
  272 + fileName="发车准点率"+date;
  273 + }else{
  274 + fileName="到站准点率"+date;
  275 + }
  276 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  277 + ee.excelReplace(listI, new Object[]{m}, path + "mould/sheetList2.xls",
  278 + path + "export/"+fileName+".xls");
  279 + } catch (Exception e) {
  280 + // TODO: handle exception
  281 + e.printStackTrace();
  282 + }
  283 +
  284 + }
  285 + }
  286 + return listSheet;
  287 + }
  288 +
  289 + private List<Sheet> calcSheetFcZdl(List<ScheduleRealInfo> lists,String line,String qdz,String zdz) {
  290 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  291 + SimpleDateFormat sdf_ = new SimpleDateFormat("yyyy-MM-dd");
  292 + DecimalFormat df = new DecimalFormat("0.00");
  293 + List<Sheet> listSheet=new ArrayList<Sheet>();
  294 + List<ScheduleRealInfo> listjh0 = new ArrayList<ScheduleRealInfo>();
  295 + List<ScheduleRealInfo> listjh1 = new ArrayList<ScheduleRealInfo>();
  296 + List<ScheduleRealInfo> listsj0 = new ArrayList<ScheduleRealInfo>();
  297 + List<ScheduleRealInfo> listsj1 = new ArrayList<ScheduleRealInfo>();
  298 + long minFcsj = minFcsj(line);
  299 + for (int j = 0; j < lists.size(); j++) {
  300 + ScheduleRealInfo s = lists.get(j);
  301 + boolean fage=true;
  302 + if(s.getBcType().equals("region")){
  303 + if(s.getXlDir().equals("0")){
  304 + if(!s.getQdzName().equals(qdz))
  305 + fage=false;
  306 + }else{
  307 + if(!s.getQdzName().equals(zdz))
  308 + fage=false;
  309 + }
  310 + }
  311 + if (!isInOut(s) && fage) {
  312 + String[] fcsj = s.getFcsj().split(":");
  313 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  314 + Long fcsjT = 0L;
  315 + if (fcsjL < minFcsj) {
  316 + Calendar calendar = new GregorianCalendar();
  317 + calendar.setTime(s.getScheduleDate());
  318 + calendar.add(calendar.DATE, 1);
  319 + Date date = calendar.getTime();
  320 + try {
  321 + fcsjT = sdf.parse(sdf_.format(date) + " " + s.getFcsj()).getTime();
  322 + } catch (ParseException e) {
  323 + // TODO Auto-generated catch block
  324 + e.printStackTrace();
  325 + }
  326 + } else {
  327 + try {
  328 + fcsjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  329 + } catch (ParseException e) {
  330 + // TODO Auto-generated catch block
  331 + e.printStackTrace();
  332 + }
  333 + }
  334 + Long fcsjAcual = 0L;
  335 + if (StringUtils.isEmpty(s.getFcsjActual())) {
  336 + s.setFcsjActualTime(0L);
  337 + s.setFcsjT(fcsjT);
  338 + } else {
  339 + try {
  340 + fcsjAcual = sdf.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime();
  341 + s.setFcsjActualTime(fcsjAcual);
  342 + s.setFcsjT(fcsjT);
  343 + } catch (ParseException e) {
  344 + // TODO Auto-generated catch block
  345 + e.printStackTrace();
  346 + }
  347 + }
  348 + if (s.isSflj()) {
  349 + if (s.getXlDir().equals("0")) {
  350 + listsj0.add(s);
  351 + } else {
  352 + listsj1.add(s);
  353 + }
  354 + } else {
  355 + if (s.getXlDir().equals("0")) {
  356 + listsj0.add(s);
  357 + listjh0.add(s);
  358 + } else {
  359 + listsj1.add(s);
  360 + listjh1.add(s);
  361 + }
  362 + }
  363 + }
  364 + }
  365 + Collections.sort(listjh0, new ComparableReal());
  366 + Collections.sort(listjh1, new ComparableReal());
  367 + Collections.sort(listsj0, new ComparableAcual());
  368 + Collections.sort(listsj1, new ComparableAcual());
  369 + Map<String, Object> mjh = new HashMap<String, Object>();
  370 + Map<String, Object> msj = new HashMap<String, Object>();
  371 + Sheet sheet;
  372 + //获取上行所有准点班次
  373 + for (int k = 0; k < listjh0.size(); k++) {
  374 + ScheduleRealInfo sJh = listjh0.get(k);
  375 + for (int j = 0; j < listsj0.size(); j++) {
  376 + ScheduleRealInfo sSj = listsj0.get(j);
  377 + long sjc = sSj.getFcsjActualTime() - sJh.getFcsjT();
  378 + if (sjc >= -1 * 60 * 1000 && sjc <= 3 * 60 * 1000) {
  379 + if (mjh.get(String.valueOf(sJh.getId())) == null && msj.get(String.valueOf(sSj.getId())) == null) {
  380 + sheet = new Sheet();
  381 + sheet.setDate(sJh.getScheduleDateStr());
  382 + sheet.setRealDate(sSj.getRealExecDate());
  383 + sheet.setLine(sJh.getXlName());
  384 + sheet.setZdname(sJh.getQdzName());
  385 + sheet.setJhsj(sJh.getFcsj());
  386 + sheet.setSjsj(sSj.getFcsjActual());
  387 + sheet.setSfzd("准点");
  388 + sheet.setXlDir("0");
  389 + listSheet.add(sheet);
  390 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  391 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  392 + }
  393 + }
  394 + }
  395 + }
  396 + // 获取上行所有不准点班次
  397 +
  398 + for (int k = 0; k < listjh0.size(); k++) {
  399 + ScheduleRealInfo sJh = listjh0.get(k);
  400 + for (int j = 0; j < listsj0.size(); j++) {
  401 + ScheduleRealInfo sSj = listsj0.get(j);
  402 + if (mjh.get(String.valueOf(sJh.getId())) == null&&msj.get(String.valueOf(sSj.getId())) == null) {
  403 + sheet = new Sheet();
  404 + sheet.setDate(sJh.getScheduleDateStr());
  405 + sheet.setRealDate(sSj.getRealExecDate());
  406 + sheet.setLine(sJh.getXlName());
  407 + sheet.setZdname(sJh.getQdzName());
  408 + sheet.setJhsj(sJh.getFcsj());
  409 + sheet.setSjsj(sSj.getFcsjActual()==null?"烂班":sSj.getFcsjActual());
  410 + sheet.setSfzd("不准点");
  411 + sheet.setXlDir("0");
  412 + listSheet.add(sheet);
  413 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  414 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  415 + }
  416 +
  417 + }
  418 + }
  419 + // 获取下行所有准点班次
  420 + for (int k = 0; k < listjh1.size(); k++) {
  421 + ScheduleRealInfo sJh = listjh1.get(k);
  422 + for (int j = 0; j < listsj1.size(); j++) {
  423 + ScheduleRealInfo sSj = listsj1.get(j);
  424 + long sjc = sSj.getFcsjActualTime() - sJh.getFcsjT();
  425 + if (sjc >= -1 * 60 * 1000 && sjc <= 3 * 60 * 1000) {
  426 + if (mjh.get(String.valueOf(sJh.getId())) == null && msj.get(String.valueOf(sSj.getId())) == null) {
  427 + sheet = new Sheet();
  428 + sheet.setDate(sJh.getScheduleDateStr());
  429 + sheet.setRealDate(sSj.getRealExecDate());
  430 + sheet.setLine(sJh.getXlName());
  431 + sheet.setZdname(sJh.getQdzName());
  432 + sheet.setJhsj(sJh.getFcsj());
  433 + sheet.setSjsj(sSj.getFcsjActual());
  434 + sheet.setSfzd("准点");
  435 + sheet.setXlDir("1");
  436 + listSheet.add(sheet);
  437 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  438 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  439 + }
  440 + }
  441 + }
  442 + }
  443 +
  444 + // 获取下行所有不准点班次
  445 +
  446 + for (int k = 0; k < listjh1.size(); k++) {
  447 + ScheduleRealInfo sJh = listjh1.get(k);
  448 + for (int j = 0; j < listsj1.size(); j++) {
  449 + ScheduleRealInfo sSj = listsj1.get(j);
  450 + if (mjh.get(String.valueOf(sJh.getId())) == null&&msj.get(String.valueOf(sSj.getId())) == null) {
  451 + sheet = new Sheet();
  452 + sheet.setDate(sJh.getScheduleDateStr());
  453 + sheet.setRealDate(sSj.getRealExecDate());
  454 + sheet.setLine(sJh.getXlName());
  455 + sheet.setZdname(sJh.getQdzName());
  456 + sheet.setJhsj(sJh.getFcsj());
  457 + sheet.setSjsj(sSj.getFcsjActual()==null?"烂班":sSj.getFcsjActual());
  458 + sheet.setSfzd("不准点");
  459 + sheet.setXlDir("1");
  460 + listSheet.add(sheet);
  461 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  462 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  463 + }
  464 +
  465 + }
  466 + }
  467 +
  468 + Collections.sort(listSheet, new ComparableSheet());
  469 + return listSheet;
  470 + }
  471 +
  472 +
  473 + private List<Sheet> calcSheetDdZdl(List<ScheduleRealInfo> lists,String line,String qdz,String zdz) {
  474 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  475 + SimpleDateFormat sdf_ = new SimpleDateFormat("yyyy-MM-dd");
  476 + DecimalFormat df = new DecimalFormat("0.00");
  477 + List<Sheet> listSheet=new ArrayList<Sheet>();
  478 + List<ScheduleRealInfo> listjh0 = new ArrayList<ScheduleRealInfo>();
  479 + List<ScheduleRealInfo> listjh1 = new ArrayList<ScheduleRealInfo>();
  480 + List<ScheduleRealInfo> listsj0 = new ArrayList<ScheduleRealInfo>();
  481 + List<ScheduleRealInfo> listsj1 = new ArrayList<ScheduleRealInfo>();
  482 + long minFcsj = minFcsj(line);
  483 + for (int j = 0; j < lists.size(); j++) {
  484 + ScheduleRealInfo s = lists.get(j);
  485 + boolean fage=true;
  486 + if(s.getBcType().equals("region")){
  487 + if(s.getXlDir().equals("0")){
  488 + if(!s.getQdzName().equals(qdz))
  489 + fage=false;
  490 + }else{
  491 + if(!s.getQdzName().equals(zdz))
  492 + fage=false;
  493 + }
  494 + }
  495 + if (!isInOut(s) && fage) {
  496 + String[] fcsj = s.getFcsj().split(":");
  497 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  498 + Long fcsjT = 0L;
  499 + if (fcsjL < minFcsj) {
  500 + Calendar calendar = new GregorianCalendar();
  501 + calendar.setTime(s.getScheduleDate());
  502 + calendar.add(calendar.DATE, 1);
  503 + Date date = calendar.getTime();
  504 + try {
  505 + fcsjT = sdf.parse(sdf_.format(date) + " " + s.getFcsj()).getTime();
  506 + } catch (ParseException e) {
  507 + // TODO Auto-generated catch block
  508 + e.printStackTrace();
  509 + }
  510 + } else {
  511 + try {
  512 + fcsjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  513 + } catch (ParseException e) {
  514 + // TODO Auto-generated catch block
  515 + e.printStackTrace();
  516 + }
  517 + }
  518 + //计划达到时间
  519 + Long ddsjT=0L;
  520 + try {
  521 + ddsjT = sdf.parse(s.getRealExecDate()+" "+s.getZdsj()).getTime();
  522 + } catch (ParseException e1) {
  523 + // TODO Auto-generated catch block
  524 + e1.printStackTrace();
  525 + }
  526 +
  527 + Long fcsjAcual = 0L;
  528 + if (StringUtils.isEmpty(s.getFcsjActual())) {
  529 + s.setFcsjActualTime(0L);
  530 + s.setFcsjT(fcsjT);
  531 + } else {
  532 + try {
  533 + fcsjAcual = sdf.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime();
  534 + s.setFcsjActualTime(fcsjAcual);
  535 + s.setFcsjT(fcsjT);
  536 + } catch (ParseException e) {
  537 + // TODO Auto-generated catch block
  538 + e.printStackTrace();
  539 + }
  540 + }
  541 + if(fcsjT.longValue()>ddsjT.longValue()){
  542 + ddsjT=ddsjT+24*60*60*1000;
  543 + }
  544 + s.setZdsjT(ddsjT);
  545 + if(StringUtils.isEmpty(s.getZdsjActual())){
  546 + s.setZdsjActualTime(0L);
  547 + }else{
  548 + try {
  549 + Long ddsjActualT = sdf.parse(s.getRealExecDate()+" "+s.getZdsjActual()).getTime();
  550 + if(Math.abs(ddsjActualT-ddsjT)/60000>1000){
  551 + if(ddsjActualT.longValue()>ddsjT.longValue()){
  552 + ddsjActualT=ddsjActualT-24*60*60*1000;
  553 + }else{
  554 + ddsjActualT=ddsjActualT+24*60*60*1000;
  555 + }
  556 + }
  557 + s.setZdsjActualTime(ddsjActualT);
  558 + } catch (ParseException e) {
  559 + // TODO Auto-generated catch block
  560 + e.printStackTrace();
  561 + }
  562 + }
  563 + if (s.isSflj()) {
  564 + if (s.getXlDir().equals("0")) {
  565 + listsj0.add(s);
  566 + } else {
  567 + listsj1.add(s);
  568 + }
  569 + } else {
  570 + if (s.getXlDir().equals("0")) {
  571 + listsj0.add(s);
  572 + listjh0.add(s);
  573 + } else {
  574 + listsj1.add(s);
  575 + listjh1.add(s);
  576 + }
  577 + }
  578 + }
  579 + }
  580 + Collections.sort(listjh0, new ComparableJhZd());
  581 + Collections.sort(listjh1, new ComparableJhZd());
  582 + Collections.sort(listsj0, new ComparableZdAcual());
  583 + Collections.sort(listsj1, new ComparableZdAcual());
  584 + Map<String, Object> mjh = new HashMap<String, Object>();
  585 + Map<String, Object> msj = new HashMap<String, Object>();
  586 + Sheet sheet;
  587 + //获取上行所有准点班次
  588 + for (int k = 0; k < listjh0.size(); k++) {
  589 + ScheduleRealInfo sJh = listjh0.get(k);
  590 + for (int j = 0; j < listsj0.size(); j++) {
  591 + ScheduleRealInfo sSj = listsj0.get(j);
  592 + long sjc = sSj.getZdsjActualTime() - sJh.getZdsjT();
  593 + if (sjc >= -1 * 60 * 1000 && sjc <= 3 * 60 * 1000) {
  594 + if (mjh.get(String.valueOf(sJh.getId())) == null && msj.get(String.valueOf(sSj.getId())) == null) {
  595 + sheet = new Sheet();
  596 + sheet.setDate(sJh.getScheduleDateStr());
  597 + try {
  598 + long abs=Math.abs(sdf.parse(sJh.getRealExecDate()+" "+sJh.getFcsj()).getTime()-
  599 + sdf.parse(sJh.getRealExecDate()+" "+sJh.getZdsj()).getTime())/60000;
  600 + if(abs>1000){
  601 + Calendar calendar = new GregorianCalendar();
  602 + calendar.setTime(sdf_.parse(sJh.getRealExecDate()));
  603 + calendar.add(calendar.DATE, 1);
  604 + Date date = calendar.getTime();
  605 + sheet.setRealDate(sdf_.format(date));
  606 + }else{
  607 + sheet.setRealDate(sJh.getRealExecDate());
  608 + }
  609 + } catch (ParseException e) {
  610 + // TODO Auto-generated catch block
  611 + e.printStackTrace();
  612 + }
  613 + sheet.setLine(sJh.getXlName());
  614 + sheet.setZdname(sJh.getQdzName());
  615 + sheet.setJhsj(sJh.getZdsj());
  616 + sheet.setSjsj(sSj.getZdsjActual());
  617 + sheet.setSfzd("准点");
  618 + sheet.setXlDir("0");
  619 + listSheet.add(sheet);
  620 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  621 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  622 + }
  623 + }
  624 + }
  625 + }
  626 + // 获取上行所有不准点班次
  627 + for (int k = 0; k < listjh0.size(); k++) {
  628 + ScheduleRealInfo sJh = listjh0.get(k);
  629 + for (int j = 0; j < listsj0.size(); j++) {
  630 + ScheduleRealInfo sSj = listsj0.get(j);
  631 + if (mjh.get(String.valueOf(sJh.getId())) == null&&msj.get(String.valueOf(sSj.getId())) == null) {
  632 + sheet = new Sheet();
  633 + sheet.setDate(sJh.getScheduleDateStr());
  634 + try {
  635 + long abs=Math.abs(sdf.parse(sJh.getRealExecDate()+" "+sJh.getFcsj()).getTime()-
  636 + sdf.parse(sJh.getRealExecDate()+" "+sJh.getZdsj()).getTime())/60000;
  637 + if(abs>1000){
  638 + Calendar calendar = new GregorianCalendar();
  639 + calendar.setTime(sdf_.parse(sJh.getRealExecDate()));
  640 + calendar.add(calendar.DATE, 1);
  641 + Date date = calendar.getTime();
  642 + sheet.setRealDate(sdf_.format(date));
  643 + }else{
  644 + sheet.setRealDate(sJh.getRealExecDate());
  645 + }
  646 + } catch (ParseException e) {
  647 + // TODO Auto-generated catch block
  648 + e.printStackTrace();
  649 + }
  650 + sheet.setLine(sJh.getXlName());
  651 + sheet.setZdname(sJh.getQdzName());
  652 + sheet.setJhsj(sJh.getZdsj());
  653 + sheet.setSjsj(sSj.getZdsjActual()==null?"烂班":sSj.getZdsjActual());
  654 + sheet.setSfzd("不准点");
  655 + sheet.setXlDir("0");
  656 + listSheet.add(sheet);
  657 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  658 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  659 + }
  660 +
  661 + }
  662 + }
  663 + // 获取下行所有准点班次
  664 + for (int k = 0; k < listjh1.size(); k++) {
  665 + ScheduleRealInfo sJh = listjh1.get(k);
  666 + for (int j = 0; j < listsj1.size(); j++) {
  667 + ScheduleRealInfo sSj = listsj1.get(j);
  668 + long sjc = sSj.getZdsjActualTime() - sJh.getZdsjT();
  669 + if (sjc >= -1 * 60 * 1000 && sjc <= 3 * 60 * 1000) {
  670 + if (mjh.get(String.valueOf(sJh.getId())) == null && msj.get(String.valueOf(sSj.getId())) == null) {
  671 + sheet = new Sheet();
  672 + sheet.setDate(sJh.getScheduleDateStr());
  673 + try {
  674 + long abs=Math.abs(sdf.parse(sJh.getRealExecDate()+" "+sJh.getFcsj()).getTime()-
  675 + sdf.parse(sJh.getRealExecDate()+" "+sJh.getZdsj()).getTime())/60000;
  676 + if(abs>1000){
  677 + Calendar calendar = new GregorianCalendar();
  678 + calendar.setTime(sdf_.parse(sJh.getRealExecDate()));
  679 + calendar.add(calendar.DATE, 1);
  680 + Date date = calendar.getTime();
  681 + sheet.setRealDate(sdf_.format(date));
  682 + }else{
  683 + sheet.setRealDate(sJh.getRealExecDate());
  684 + }
  685 + } catch (ParseException e) {
  686 + // TODO Auto-generated catch block
  687 + e.printStackTrace();
  688 + }
  689 +
  690 + sheet.setLine(sJh.getXlName());
  691 + sheet.setZdname(sJh.getQdzName());
  692 + sheet.setJhsj(sJh.getZdsj());
  693 + sheet.setSjsj(sSj.getZdsjActual());
  694 + sheet.setSfzd("准点");
  695 + sheet.setXlDir("1");
  696 + listSheet.add(sheet);
  697 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  698 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  699 + }
  700 + }
  701 + }
  702 + }
  703 +
  704 + // 获取下行所有不准点班次
  705 + for (int k = 0; k < listjh1.size(); k++) {
  706 + ScheduleRealInfo sJh = listjh1.get(k);
  707 + for (int j = 0; j < listsj1.size(); j++) {
  708 + ScheduleRealInfo sSj = listsj1.get(j);
  709 + if (mjh.get(String.valueOf(sJh.getId())) == null&&msj.get(String.valueOf(sSj.getId())) == null) {
  710 + sheet = new Sheet();
  711 + sheet.setDate(sJh.getScheduleDateStr());
  712 + try {
  713 + long abs=Math.abs(sdf.parse(sJh.getRealExecDate()+" "+sJh.getFcsj()).getTime()-
  714 + sdf.parse(sJh.getRealExecDate()+" "+sJh.getZdsj()).getTime())/60000;
  715 + if(abs>1000){
  716 + Calendar calendar = new GregorianCalendar();
  717 + calendar.setTime(sdf_.parse(sJh.getRealExecDate()));
  718 + calendar.add(calendar.DATE, 1);
  719 + Date date = calendar.getTime();
  720 + sheet.setRealDate(sdf_.format(date));
  721 + }else{
  722 + sheet.setRealDate(sJh.getRealExecDate());
  723 + }
  724 + } catch (ParseException e) {
  725 + // TODO Auto-generated catch block
  726 + e.printStackTrace();
  727 + }
  728 + sheet.setLine(sJh.getXlName());
  729 + sheet.setZdname(sJh.getQdzName());
  730 + sheet.setJhsj(sJh.getZdsj());
  731 + sheet.setSjsj(sSj.getZdsjActual()==null?"烂班":sSj.getZdsjActual());
  732 + sheet.setSfzd("不准点");
  733 + sheet.setXlDir("1");
  734 + listSheet.add(sheet);
  735 + mjh.put(String.valueOf(sJh.getId()), sJh.getId());
  736 + msj.put(String.valueOf(sSj.getId()), sSj.getId());
  737 + }
  738 +
  739 + }
  740 + }
  741 +
  742 + Collections.sort(listSheet, new ComparableSheet());
  743 + return listSheet;
  744 + }
  745 + private Long minFcsj(String line){
  746 + String minfcsj="02:00";
  747 + List<Line> lineList=lineRepository.findLineByCode(line);
  748 + if(lineList.size()>0){
  749 + String sqlMinYysj="select start_opt from bsth_c_line_config where "
  750 + + " id = ("
  751 + + "select max(id) from bsth_c_line_config where line ='"+lineList.get(0).getId() +"'"
  752 + + ")";
  753 + minfcsj= jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  754 + }
  755 + String[] minSjs = minfcsj.split(":");
  756 + //车辆最早发车时间 用了过滤超第二天0点的数据
  757 + Long minSj=Long.parseLong(minSjs[0])*60+Long.parseLong(minSjs[1]);
  758 + return minSj;
  759 + }
  760 +
  761 + private static boolean isInOut(ScheduleRealInfo s){
  762 + boolean fage=false;
  763 + if(s.getBcType().equals("in")){
  764 + fage=true;
  765 + }
  766 + if(s.getBcType().equals("out")){
  767 + fage=true;
  768 + }
  769 + if(s.getBcType().equals("ldks")){
  770 + fage=true;
  771 + }
  772 + if(s.isCcService()){
  773 + fage=true;
  774 + }
  775 + return fage;
  776 + }
  777 + @Override
  778 + public List<Map<String, Object>> calcTurnoutrate(Map<String, Object> map) {
  779 + final DecimalFormat df = new DecimalFormat("0.00");
  780 + String line="";
  781 + if(map.get("line")!=null){
  782 + line =map.get("line").toString().trim();
  783 + }
  784 + String gs="";
  785 + if(map.get("gsdmTurn")!=null){
  786 + gs=map.get("gsdmTurn").toString().trim();
  787 + }
  788 + String fgs="";
  789 + if(map.get("fgsdmTurn")!=null){
  790 + fgs=map.get("fgsdmTurn").toString().trim();
  791 + }
  792 + String nature="0";
  793 + if(map.get("nature")!=null){
  794 + nature=map.get("nature").toString();
  795 + }
  796 + Map<String, Boolean> lineMap=lineService.lineNature();
  797 +
  798 + String startDate=map.get("startDate").toString();
  799 + String endDate=map.get("endDate").toString();
  800 + String date=startDate+"-"+endDate;
  801 + if(startDate.equals(endDate)){
  802 + date=startDate;
  803 + }else{
  804 + date=startDate+"-"+endDate;
  805 + }
  806 + String type=map.get("type").toString();
  807 + final String dates=date;
  808 + String sql_="";
  809 + if(line.equals("")){
  810 + sql_= " and gsdm ='"+gs+"' and fgsdm like '%"+fgs+"%'";
  811 + }else{
  812 + sql_=" and xl='"+line+"'";
  813 + }
  814 + String sql="select t.*,y.warrant_car as qzpcs from ("
  815 + + " select gsdm,fgsdm,xl,xl_name,sum(jhcc) as jhcc,sum(sjcc) as sjcc,"
  816 + + " sum(sjcczgf) as sjcczgf,sum(jhbcs) as jhbcs,sum(sjbcs) as sjbcs "
  817 + + " from bsth_c_calc_sheet where date >='"+startDate+"' and date <='"+endDate+"'"
  818 + + sql_
  819 + + " group by gsdm,fgsdm,xl,xl_name ) "
  820 + + " t LEFT JOIN bsth_c_line y "
  821 + + " on t.xl=y.line_code order by fgsdm,xl_name";
  822 + List<Map<String, Object>> lists=jdbcTemplate.query(sql,
  823 + new RowMapper<Map<String, Object>>(){
  824 + @Override
  825 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  826 + Map<String, Object> s=new HashMap<String,Object>();
  827 + s.put("rq",dates);
  828 + s.put("gsdm", rs.getString("gsdm"));
  829 + s.put("fgsdm", rs.getString("fgsdm"));
  830 + s.put("gsName", BasicData.businessCodeNameMap.get(rs.getString("gsdm")));
  831 + s.put("fgsName", BasicData.businessFgsCodeNameMap.get(rs.getString("fgsdm")+"_"+rs.getString("gsdm")));
  832 + s.put("xl", rs.getString("xl"));
  833 + s.put("xlName", rs.getString("xl_name"));
  834 + s.put("jhcc", rs.getInt("jhcc"));
  835 + s.put("sjcc", rs.getInt("sjcc"));
  836 + s.put("qzpcs",rs.getInt("qzpcs"));
  837 + s.put("sjcczgf", rs.getInt("sjcczgf"));
  838 + if(rs.getInt("jhcc")>0){
  839 + s.put("ccl",df.format((float)rs.getInt("sjcc")/rs.getInt("jhcc")*100)+"%");
  840 + s.put("cclzgf", df.format((float)rs.getInt("sjcczgf")/rs.getInt("jhcc")*100)+"%");
  841 + }else{
  842 + s.put("ccl", "0.00%");
  843 + s.put("cclzgf","0.00%");
  844 + }
  845 + s.put("jhbc", rs.getInt("jhbcs"));
  846 + s.put("sjbc", rs.getInt("sjbcs"));
  847 + if(rs.getInt("jhbcs")>0){
  848 + s.put("zxl", df.format((float)rs.getInt("sjbcs")/rs.getInt("jhbcs")*100)+"%");
  849 + }else{
  850 + s.put("zxl", "0.00%");
  851 + }
  852 + s.put("sm", "");
  853 + return s;
  854 + }
  855 + });
  856 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  857 +
  858 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  859 + int jhcc = 0, sjcc = 0,sjcczgf=0;;
  860 + int jhbc = 0, sjbc = 0;
  861 + int qz = 0;
  862 + int count=0;
  863 + Map<String, String> xlMap=new HashMap<String,String>();
  864 + for(Map<String, Object> m : lists){
  865 + if(nature.equals("0")){
  866 + list.add(m);
  867 + jhcc += Integer.valueOf(m.get("jhcc").toString());
  868 + sjcc += Integer.valueOf(m.get("sjcc").toString());
  869 + jhbc += Integer.valueOf(m.get("jhbc").toString());
  870 + sjbc += Integer.valueOf(m.get("sjbc").toString());
  871 + sjcczgf +=Integer.valueOf(m.get("sjcczgf").toString());
  872 + qz += Integer.valueOf(m.get("qzpcs").toString());
  873 + if(xlMap.get(m.get("xl").toString())==null){
  874 + count++;
  875 + xlMap.put(m.get("xl").toString(), m.get("xl").toString());
  876 + }
  877 + }else if(nature.equals("1")){
  878 + if(lineMap.get(m.get("xl").toString())){
  879 + list.add(m);
  880 + jhcc += Integer.valueOf(m.get("jhcc").toString());
  881 + sjcc += Integer.valueOf(m.get("sjcc").toString());
  882 + jhbc += Integer.valueOf(m.get("jhbc").toString());
  883 + sjbc += Integer.valueOf(m.get("sjbc").toString());
  884 + sjcczgf +=Integer.valueOf(m.get("sjcczgf").toString());
  885 + qz += Integer.valueOf(m.get("qzpcs").toString());
  886 + if(xlMap.get(m.get("xl").toString())==null){
  887 + count++;
  888 + xlMap.put(m.get("xl").toString(), m.get("xl").toString());
  889 + }
  890 + }
  891 + }else{
  892 + if(!lineMap.get(m.get("xl").toString())){
  893 + list.add(m);
  894 + jhcc += Integer.valueOf(m.get("jhcc").toString());
  895 + sjcc += Integer.valueOf(m.get("sjcc").toString());
  896 + jhbc += Integer.valueOf(m.get("jhbc").toString());
  897 + sjbc += Integer.valueOf(m.get("sjbc").toString());
  898 + sjcczgf +=Integer.valueOf(m.get("sjcczgf").toString());
  899 + qz += Integer.valueOf(m.get("qzpcs").toString());
  900 + if(xlMap.get(m.get("xl").toString())==null){
  901 + count++;
  902 + xlMap.put(m.get("xl").toString(), m.get("xl").toString());
  903 + }
  904 + }
  905 + }
  906 +
  907 + }
  908 +
  909 + Map<String, Object> tempMap=new HashMap<String,Object>();
  910 + tempMap.put("rq", "分类汇总");
  911 + tempMap.put("line_", "共" + list.size() + "条线路");
  912 + tempMap.put("xlName", "共" +count + "条线路");
  913 + tempMap.put("jhcc", jhcc);
  914 + tempMap.put("sjcc", sjcc);
  915 + tempMap.put("sjcczgf", sjcczgf);
  916 + tempMap.put("jhbc", jhbc);
  917 + tempMap.put("sjbc", sjbc);
  918 + tempMap.put("qzpcs", qz);
  919 + tempMap.put("sm", "");
  920 + if(jhcc != 0 && sjcc != 0){
  921 + tempMap.put("ccl", df.format(((float)sjcc / jhcc)*100)+"%");
  922 + tempMap.put("cclzgf", df.format(((float)sjcczgf / jhcc)*100)+"%");
  923 + }else{
  924 + tempMap.put("ccl", "0.00%");
  925 + tempMap.put("cclzgf", "0.00%");
  926 + }
  927 + if(jhbc != 0 && sjbc != 0){
  928 + tempMap.put("zxl", df.format(((float)sjbc / jhbc)*100)+"%");
  929 + }else{
  930 + tempMap.put("zxl", "0.00%");
  931 + }
  932 + if (type.equals("export")) {
  933 + String lineName=map.get("lineName").toString();
  934 + ReportUtils ee = new ReportUtils();
  935 + listI.add(list.iterator());
  936 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  937 + ee.excelReplace(listI, new Object[] { tempMap }, path + "mould/calcTurnoutrate.xls", path + "export/"
  938 + + dates + "-" + lineName + "-营运线路出车率统计表.xls");
  939 + }
  940 + list.add(tempMap);
  941 + return list;
  942 + }
  943 +}
  944 +
  945 +class ComparableSheet implements Comparator<Sheet>{
  946 + @Override
  947 + public int compare(Sheet o1, Sheet o2) {
  948 + // TODO Auto-generated method stub
  949 + return (o1.getXlDir()+o1.getRealDate()+o1.getJhsj()).compareTo((o2.getXlDir()+o2.getRealDate()+o2.getJhsj()));
  950 + }
  951 +}
  952 +
  953 +class ComparableZdAcual implements Comparator<ScheduleRealInfo>{
  954 + @Override
  955 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  956 + // TODO Auto-generated method stub
  957 + return o1.getZdsjActualTime().compareTo(o2.getZdsjActualTime());
  958 + }
  959 +}
  960 +
  961 +class ComparableJhZd implements Comparator<ScheduleRealInfo>{
  962 + @Override
  963 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  964 + // TODO Auto-generated method stub
  965 + return o1.getZdsjT().compareTo(o2.getZdsjT());
  966 + }
  967 +}
... ...
src/main/java/com/bsth/service/report/impl/CulateMileageServiceImpl.java
... ... @@ -1084,14 +1084,21 @@ public class CulateMileageServiceImpl implements CulateMileageService{
1084 1084 while (it.hasNext()) {
1085 1085 ChildTaskPlan childTaskPlan = it.next();
1086 1086 if(!childTaskPlan.isDestroy()){
1087   - if(childTaskPlan.getMileageType().equals("service")){
1088   - ljyy =Arith.add(ljyy,childTaskPlan.getMileage());
1089   - }
1090   - if(childTaskPlan.getMileageType().equals("empty")){
1091   - if(childTaskPlan.getType2().equals("2")||childTaskPlan.getType2().equals("3")){
1092   - ljjcc =Arith.add(ljjcc, childTaskPlan.getMileage());
1093   - }
1094   - }
  1087 + if(childTaskPlan.getCcId()==null){
  1088 + if(childTaskPlan.getMileageType().equals("service")){
  1089 + ljyy =Arith.add(ljyy,childTaskPlan.getMileage());
  1090 + }
  1091 + if(childTaskPlan.getMileageType().equals("empty")){
  1092 + if(childTaskPlan.getType2().equals("2")||childTaskPlan.getType2().equals("3")){
  1093 + ljjcc =Arith.add(ljjcc, childTaskPlan.getMileage());
  1094 + }
  1095 + }
  1096 + if(childTaskPlan.getMileageType().equals("empty")){
  1097 + if(childTaskPlan.getType2().equals("1")){
  1098 + ljkfks =Arith.add(ljkfks, childTaskPlan.getMileage());
  1099 + }
  1100 + }
  1101 + }
1095 1102 }
1096 1103 }
1097 1104 }
... ... @@ -1211,7 +1218,8 @@ public class CulateMileageServiceImpl implements CulateMileageService{
1211 1218 // }else{
1212 1219 if(childTaskPlan.getType2().equals("2")||childTaskPlan.getType2().equals("3")){
1213 1220 if (!childTaskPlan.isDestroy()) {
1214   - if(childTaskPlan.getReason().equals(item)){
  1221 + String reason=childTaskPlan.getReason()==null?"":childTaskPlan.getReason();
  1222 + if(reason.equals(item)){
1215 1223 zrwjcclc=Arith.add(zrwjcclc,childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage());
1216 1224 }
1217 1225 }
... ... @@ -1607,5 +1615,55 @@ public class CulateMileageServiceImpl implements CulateMileageService{
1607 1615 }
1608 1616 return ljgl;
1609 1617 }
  1618 +
  1619 + @Override
  1620 + public double culateLjksgl(List<ScheduleRealInfo> lists) {
  1621 + double ljks=0.0;
  1622 + for (int i = 0; i < lists.size(); i++) {
  1623 + ScheduleRealInfo t=lists.get(i);
  1624 + if(t.isSflj()){
  1625 + if(isInOut(t)){
  1626 + Set<ChildTaskPlan> childTaskPlans = t.getcTasks();
  1627 + if(childTaskPlans.isEmpty()){
  1628 + if(!t.isDestroy()){
  1629 + ljks =Arith.add(ljks, t.getJhlc());
  1630 + }
  1631 +
  1632 + }
  1633 + }else{
  1634 + Set<ChildTaskPlan> childTaskPlans = t.getcTasks();
  1635 + if(!childTaskPlans.isEmpty()){
  1636 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1637 + while (it.hasNext()) {
  1638 + ChildTaskPlan childTaskPlan = it.next();
  1639 + if(!childTaskPlan.isDestroy()){
  1640 + if(childTaskPlan.getMileageType().equals("empty") && childTaskPlan.getCcId()==null){
  1641 + ljks =Arith.add(ljks, childTaskPlan.getMileage());
  1642 + }
  1643 + }
  1644 + }
  1645 + }
  1646 + }
  1647 + }else{
  1648 + Set<ChildTaskPlan> childTaskPlans = t.getcTasks();
  1649 + if(!childTaskPlans.isEmpty()){
  1650 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1651 + while (it.hasNext()) {
  1652 + ChildTaskPlan childTaskPlan = it.next();
  1653 + if(childTaskPlan.getCcId()==null){
  1654 + if("empty".equals(childTaskPlan.getMileageType())&&"临加".equals(childTaskPlan.getType1())){
  1655 + if (!childTaskPlan.isDestroy()) {
  1656 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  1657 + ljks=Arith.add(ljks,jhgl);
  1658 + }
  1659 + }
  1660 + }
  1661 + }
  1662 + }
  1663 +
  1664 + }
  1665 + }
  1666 + return ljks;
  1667 + }
1610 1668  
1611 1669 }
... ...
src/main/java/com/bsth/service/schedule/EmployeeConfigInfoService.java
... ... @@ -7,8 +7,14 @@ import com.bsth.service.schedule.exception.ScheduleException;
7 7 * Created by xu on 16/5/10.
8 8 */
9 9 public interface EmployeeConfigInfoService extends BService<EmployeeConfigInfo, Long> {
  10 + // 验证驾驶员配置是否重复配置
10 11 void validate_jsy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException;
  12 + // 验证售票员配置是否重复配置
11 13 void validate_spy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException;
  14 + // 验证驾驶员是否配置在指定线路
  15 + void validate_jsy_config(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException;
  16 + // 验证售票员是否配置在指定线路
  17 + void validate_spy_config(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException;
12 18 void toggleCancel(Long id) throws ScheduleException;
13 19 Long getMaxDbbm(Integer xlId);
14 20 }
... ...
src/main/java/com/bsth/service/schedule/impl/CarDeviceServiceImpl.java
... ... @@ -47,6 +47,7 @@ public class CarDeviceServiceImpl extends BServiceImpl&lt;CarDevice, Long&gt; implemen
47 47 }
48 48 param.put("xl_eq", carDevice.getXl());
49 49 param.put("cl_eq", carDevice.getCl());
  50 + param.put("isCancel_eq", false); // 未标记作废删除的
50 51 param.put("qyrq_ge", carDevice.getQyrq());
51 52 if (!CollectionUtils.isEmpty(list(param))) {
52 53 throw new ScheduleException("启用日期必须比历史的启用日期大");
... ...
src/main/java/com/bsth/service/schedule/impl/EmployeeConfigInfoServiceImpl.java
... ... @@ -100,6 +100,18 @@ public class EmployeeConfigInfoServiceImpl extends BServiceImpl&lt;EmployeeConfigIn
100 100  
101 101 @Transactional
102 102 @Override
  103 + public void validate_jsy_config(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException {
  104 + Map<String, Object> param = new HashMap<>();
  105 + param.put("xl.id_eq", employeeConfigInfo.getXl().getId());
  106 + param.put("jsy.id_eq", employeeConfigInfo.getJsy().getId());
  107 + List<EmployeeConfigInfo> employeeConfigInfos = list(param);
  108 + if (CollectionUtils.isEmpty(employeeConfigInfos)) {
  109 + throw new ScheduleException("驾驶员没有配置在当前线路中,不属于当前线路!");
  110 + }
  111 + }
  112 +
  113 + @Transactional
  114 + @Override
103 115 public void validate_spy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException {
104 116 // 售票员不能重复配置
105 117 Map<String, Object> param = new HashMap<>();
... ... @@ -127,6 +139,18 @@ public class EmployeeConfigInfoServiceImpl extends BServiceImpl&lt;EmployeeConfigIn
127 139  
128 140 @Transactional
129 141 @Override
  142 + public void validate_spy_config(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException {
  143 + Map<String, Object> param = new HashMap<>();
  144 + param.put("xl.id_eq", employeeConfigInfo.getXl().getId());
  145 + param.put("spy.id_eq", employeeConfigInfo.getSpy().getId());
  146 + List<EmployeeConfigInfo> employeeConfigInfos = list(param);
  147 + if (CollectionUtils.isEmpty(employeeConfigInfos)) {
  148 + throw new ScheduleException("售票员没有配置在当前线路中,不属于当前线路!");
  149 + }
  150 + }
  151 +
  152 + @Transactional
  153 + @Override
130 154 public void delete(Long aLong) throws ScheduleException {
131 155 toggleCancel(aLong);
132 156 }
... ...
src/main/java/com/bsth/service/schedule/impl/PeopleCarPlanServiceImpl.java
... ... @@ -26,6 +26,7 @@ import com.bsth.data.BasicData;
26 26 import com.bsth.entity.realcontrol.ScheduleRealInfo;
27 27 import com.bsth.entity.schedule.SchedulePlanInfo;
28 28 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  29 +import com.bsth.service.LineService;
29 30 import com.bsth.service.schedule.PeopleCarPlanService;
30 31 import com.bsth.util.ReportUtils;
31 32  
... ... @@ -36,6 +37,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
36 37 private ScheduleRealInfoRepository scheduleRealInfoRepository;
37 38  
38 39 @Autowired
  40 + private LineService lineService;
  41 +
  42 + @Autowired
39 43 private JdbcTemplate jdbcTemplate;
40 44  
41 45 public List<ScheduleRealInfo> getSchedule(String company, String subCompany, String line, String date){
... ... @@ -47,7 +51,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
47 51 if(line.length() != 0)
48 52 sql += " and xl_bm = '"+line+"'";
49 53 if(company.length() != 0)
50   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  54 + sql += " and gs_bm = '"+company+"'";
  55 + if(subCompany.length() != 0)
  56 + sql += " and fgs_bm = '"+subCompany+"'";
  57 +
  58 + sql += " order by gs_bm, fgs_bm, xl_bm";
51 59  
52 60 list = jdbcTemplate.query(sql,
53 61 new RowMapper<ScheduleRealInfo>(){
... ... @@ -56,6 +64,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
56 64 ScheduleRealInfo schedule = new ScheduleRealInfo();
57 65 schedule.setScheduleDateStr(rs.getString("schedule_date_str"));
58 66 schedule.setRealExecDate(rs.getString("real_exec_date"));
  67 + schedule.setXlBm(rs.getString("xl_bm"));
59 68 schedule.setXlName(rs.getString("xl_name"));
60 69 schedule.setLpName(rs.getString("lp_name"));
61 70 schedule.setBcType(rs.getString("bc_type"));
... ... @@ -170,15 +179,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
170 179 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
171 180 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
172 181  
173   - String company = "";
174   - String subCompany ="";
175   - if(map.get("company")!=null){
176   - company = map.get("company").toString();
177   - }
178   -
179   - if(map.get("subCompany")!=null){
  182 + String company = "", subCompany ="";
  183 + if(map.get("company")!=null)
  184 + company = map.get("company").toString();
  185 + if(map.get("subCompany")!=null)
180 186 subCompany = map.get("subCompany").toString();
181   - }
182 187 String line = map.get("line").toString();
183 188 String date = map.get("date").toString();
184 189 String type = map.get("type").toString();
... ... @@ -193,9 +198,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
193 198 if(line.length() != 0){
194 199 sql += " and xl_bm = '"+line+"'";
195 200 }
196   - if(company.length() != 0){
197   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
198   - }
  201 + if(company.length() != 0)
  202 + sql += " and gs_bm = '"+company+"'";
  203 + if(subCompany.length() != 0)
  204 + sql += " and fgs_bm = '"+subCompany+"'";
199 205  
200 206 list = jdbcTemplate.query(sql,
201 207 new RowMapper<SchedulePlanInfo>(){
... ... @@ -322,8 +328,13 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
322 328 Set<String> lineSet = getNotOperation();
323 329 DecimalFormat df = new DecimalFormat("###0.##");
324 330  
325   - String company = map.get("company").toString();
326   - String subCompany = map.get("subCompany").toString();
  331 + String sfyy = "", company = "", subCompany = "";
  332 + if(map.get("sfyy")!=null)
  333 + sfyy = map.get("sfyy").toString();
  334 + if(map.get("company")!=null)
  335 + company = map.get("company").toString();
  336 + if(map.get("subCompany")!=null)
  337 + subCompany = map.get("subCompany").toString();
327 338 String line = map.get("line").toString();
328 339 String date = map.get("date").toString();
329 340 String type = map.get("type").toString();
... ... @@ -332,9 +343,27 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
332 343 date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
333 344 }
334 345  
335   - List<ScheduleRealInfo> list = this.getSchedule(company, subCompany, line, date);
  346 + List<ScheduleRealInfo> schedules = this.getSchedule(company, subCompany, line, date);
  347 + Map<String, Boolean> lineNature = lineService.lineNature();
336 348  
  349 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
337 350 Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>();
  351 +
  352 + //是否营运
  353 + for(ScheduleRealInfo schedule : schedules){
  354 + String xlbm = schedule.getXlBm();
  355 + if(sfyy.length() == 0 || sfyy.equals("0")){
  356 + list.add(schedule);
  357 + } else if(sfyy.equals("1")){
  358 + if(lineNature.containsKey(xlbm) && lineNature.get(xlbm)){
  359 + list.add(schedule);
  360 + }
  361 + } else {
  362 + if(lineNature.containsKey(xlbm) && !lineNature.get(xlbm)){
  363 + list.add(schedule);
  364 + }
  365 + }
  366 + }
338 367 for(ScheduleRealInfo schedule : list){
339 368 String key = schedule.getXlName();
340 369 if(key == null || key.trim().equals("") || lineSet.contains(key))
... ... @@ -573,16 +602,19 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
573 602 }
574 603 try {
575 604  
576   - String sql = "select schedule_date_str,xl_name,bc_type,gs_name,fgs_name,bcs,fcno,"
577   - +"fcsj,fcsj_actual,zdsj,zdsj_actual,bcsj,qdz_name,sp_id,cc_service"
  605 + String sql = "select schedule_date_str,xl_name,bc_type,gs_name,fgs_name,fgs_bm,bcs,"
  606 + +"fcno,fcsj,fcsj_actual,zdsj,zdsj_actual,bcsj,qdz_name,sp_id,cc_service"
578 607 +" from bsth_c_s_sp_info_real where schedule_date_str >= '"+startDate
579 608 +"' and schedule_date_str <= '"+endDate+"'";
580 609 if(line.length() != 0){
581 610 sql += " and xl_bm = '"+line+"'";
582 611 }
583   -// if(company.length() != 0){
584   - sql += " and gs_bm like '%"+company+"%' and fgs_bm like '%"+subCompany+"%'";
585   -// }
  612 + if(company.length() != 0){
  613 + sql += " and gs_bm = '"+company+"'";
  614 + }
  615 + if(subCompany.length() != 0){
  616 + sql += " and fgs_bm = '"+subCompany+"'";
  617 + }
586 618 sql += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
587 619 if(Integer.valueOf(bcType) == 1){
588 620 sql += " and bc_type != 'region'";
... ... @@ -599,6 +631,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
599 631 schedule.setBcType(rs.getString("bc_type"));
600 632 schedule.setGsName(rs.getString("gs_name"));
601 633 schedule.setFgsName(rs.getString("fgs_name"));
  634 + schedule.setFgsBm(rs.getString("fgs_bm"));
602 635 schedule.setBcs(rs.getInt("bcs"));
603 636 schedule.setFcno(rs.getInt("fcno"));
604 637 schedule.setFcsj(rs.getString("fcsj"));
... ... @@ -676,22 +709,23 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
676 709 if(schedule.isCcService()){
677 710 continue;
678 711 }
  712 +
  713 + String key = schedule.getXlName()+"/"+schedule.getQdzName()+"/"+schedule.getFcsj()+"/"+schedule.getFgsBm();
679 714 if(model.length() != 0){
680 715 if(ttSet.contains(schedule.getSpId())){
681   - String key = schedule.getXlName()+"/"+schedule.getQdzName()+"/"+schedule.getFcsj();
682 716 if(!keyMap.containsKey(key))
683 717 keyMap.put(key, new ArrayList<ScheduleRealInfo>());
684 718 keyMap.get(key).add(schedule);
685 719 }
686 720 } else {
687   - String key = schedule.getXlName()+"/"+schedule.getQdzName()+"/"+schedule.getFcsj();
688   - if(!keyMap.containsKey(key))
  721 + if(!keyMap.containsKey(key)){
689 722 keyMap.put(key, new ArrayList<ScheduleRealInfo>());
  723 + }
690 724 keyMap.get(key).add(schedule);
691 725 }
692 726 }
693   - String companyName = "", subCompanyName = "";
694 727 for(String key : keyMap.keySet()){
  728 + String companyName = "", subCompanyName = "";
695 729 Map<String, Object> tempMap = new HashMap<String, Object>();
696 730 List<Integer> fcsj = new ArrayList<Integer>();
697 731 List<Integer> yssj = new ArrayList<Integer>();
... ... @@ -777,7 +811,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
777 811 Map<String, List<Map<String, Object>>> listMap = new HashMap<String, List<Map<String, Object>>>();
778 812 Map<String, List<Map<String, Object>>> listMap2 = new HashMap<String, List<Map<String, Object>>>();
779 813 for(Map<String, Object> m : tempList){
780   - String key = m.get("line").toString() + m.get("qdz");
  814 + String key = m.get("line").toString() + m.get("qdz") + m.get("subCompany");
781 815 if(!listMap.containsKey(key))
782 816 listMap.put(key, new ArrayList<Map<String, Object>>());
783 817 listMap.get(key).add(m);
... ... @@ -889,9 +923,12 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
889 923 if(nbbm.length() != 0){
890 924 sql += " and cl_zbh like '%"+nbbm+"%'";
891 925 }
892   -// if(company.length() != 0){
893   - sql += " and gs_bm like '%"+company+"%' and fgs_bm like '%"+subCompany+"%'";
894   -// }
  926 + if(company.length() != 0){
  927 + sql += " and gs_bm like '"+company+"'";
  928 + }
  929 + if(subCompany.length() != 0){
  930 + sql += " and fgs_bm like '"+subCompany+"'";
  931 + }
895 932 sql += " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks'";
896 933 if(bcType.trim().equals("1")){
897 934 sql += " and bc_type != 'region'";
... ... @@ -1209,10 +1246,13 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1209 1246 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
1210 1247 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
1211 1248  
1212   - Set<String> lineSet = getNotOperation();
1213   -
1214   - String company = map.get("company").toString();
1215   - String subCompany = map.get("subCompany").toString();
  1249 + String sfyy = "", company = "", subCompany = "";
  1250 + if(map.get("sfyy")!=null)
  1251 + sfyy = map.get("sfyy").toString();
  1252 + if(map.get("company")!=null)
  1253 + company = map.get("company").toString();
  1254 + if(map.get("subCompany")!=null)
  1255 + subCompany = map.get("subCompany").toString();
1216 1256 String line = map.get("line").toString();
1217 1257 String date = map.get("date").toString();
1218 1258 String type = map.get("type").toString();
... ... @@ -1222,13 +1262,15 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1222 1262  
1223 1263 try {
1224 1264 String sql = "select a.schedule_date_str, a.real_exec_date, a.xl_name, a.fcsj, a.fcsj_actual, a.zdsj, a.zdsj_actual, a.qdz_name, a.zdz_name, a.xl_dir, a.status, a.gs_name, a.fgs_name,"
1225   - + " a.cc_service, b.start_opt from bsth_c_s_sp_info_real a left join (select line, start_opt from bsth_c_line_config order by id desc) b on a.xl_bm = b.line"
  1265 + + " a.xl_bm, a.fgs_bm, a.cc_service, b.start_opt from bsth_c_s_sp_info_real a left join (select line, start_opt from bsth_c_line_config order by id desc) b on a.xl_bm = b.line"
1226 1266 + " where schedule_date_str = '"+date+"'"
1227 1267 + " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks' and bc_type != 'region'";
1228 1268 if(line.trim().length() != 0)
1229 1269 sql += " and xl_bm = '"+line+"'";
1230   - else if(company.length() != 0)
1231   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  1270 + if(company.length() != 0)
  1271 + sql += " and gs_bm = '"+company+"'";
  1272 + if(subCompany.length() != 0)
  1273 + sql += " and fgs_bm = '"+subCompany+"'";
1232 1274  
1233 1275 list = jdbcTemplate.query(sql,
1234 1276 new RowMapper<ScheduleRealInfo>(){
... ... @@ -1238,6 +1280,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1238 1280 schedule.setScheduleDateStr(rs.getString("schedule_date_str"));
1239 1281 schedule.setRealExecDate(rs.getString("real_exec_date"));
1240 1282 schedule.setXlName(rs.getString("xl_name"));
  1283 + schedule.setXlBm(rs.getString("xl_Bm"));
1241 1284 schedule.setFcsj(rs.getString("fcsj"));
1242 1285 schedule.setFcsjActual(rs.getString("fcsj_actual"));
1243 1286 schedule.setZdsj(rs.getString("zdsj"));
... ... @@ -1248,6 +1291,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1248 1291 schedule.setStatus(rs.getInt("status"));
1249 1292 schedule.setGsName(rs.getString("gs_name"));
1250 1293 schedule.setFgsName(rs.getString("fgs_name"));
  1294 + schedule.setFgsBm(rs.getString("fgs_bm"));
1251 1295 schedule.setCcService(rs.getBoolean("cc_service"));
1252 1296  
1253 1297 int startOpt = 0;
... ... @@ -1287,26 +1331,54 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1287 1331 }
1288 1332  
1289 1333 Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>();
1290   - String companyName = "", subCompanyName = "";
  1334 + Map<String, Boolean> lineNature = lineService.lineNature();
1291 1335  
1292 1336 for(ScheduleRealInfo s : list){
1293   - if(lineSet.contains(s.getXlName()) || s.isCcService()){
  1337 + if(s.isCcService()){
1294 1338 continue;
1295 1339 }
1296   - String xlName = s.getXlName();
1297   - if(!keyMap.containsKey(xlName))
1298   - keyMap.put(xlName, new ArrayList<ScheduleRealInfo>());
1299   - keyMap.get(xlName).add(s);
1300   - if(companyName.length()==0&&s.getGsName()!=null&&s.getGsName().trim().length()!=0)
1301   - companyName = s.getGsName();
1302   - if(subCompanyName.length()==0&&s.getFgsName()!=null&&s.getFgsName().trim().length()!=0)
1303   - subCompanyName = s.getFgsName();
  1340 +
  1341 + String xlbm = s.getXlBm();
  1342 + boolean flag = false;
  1343 + if(sfyy.length() == 0 || sfyy.equals("0")){
  1344 + flag = true;
  1345 + } else if(sfyy.equals("1")){
  1346 + if(lineNature.containsKey(xlbm) && lineNature.get(xlbm)){
  1347 + flag = true;
  1348 + }
  1349 + } else {
  1350 + if(lineNature.containsKey(xlbm) && !lineNature.get(xlbm)){
  1351 + flag = true;
  1352 + }
  1353 + }
  1354 + if(!flag){
  1355 + continue;
  1356 + }
  1357 +
  1358 + String key = s.getXlName() + "/" + s.getXlBm() + "/" + s.getFgsBm();
  1359 + if(!keyMap.containsKey(key)){
  1360 + keyMap.put(key, new ArrayList<ScheduleRealInfo>());
  1361 + }
  1362 + keyMap.get(key).add(s);
1304 1363 }
1305 1364  
1306   - for(String xlName : keyMap.keySet()){
  1365 + //给key排序
  1366 + List<Long> longList = new ArrayList<Long>();
  1367 + Map<Long, String> longMap = new HashMap<Long, String>();
  1368 + for(String key : keyMap.keySet()){
  1369 + String[] keys = key.split("/");
  1370 + Long l = Long.valueOf(keys[2]) * 10000000000l + Long.valueOf(keys[1]);
  1371 + longMap.put(l, key);
  1372 + longList.add(l);
  1373 + }
  1374 + Collections.sort(longList);
  1375 +
  1376 + for(Long l : longList){
  1377 + String key = longMap.get(l);
1307 1378 Map<String, Object> tempMap = new HashMap<String, Object>();
  1379 + String[] keys = key.split("/");
1308 1380 tempMap.put("date", date.substring(5));
1309   - tempMap.put("line", xlName);
  1381 + tempMap.put("line", keys[0]);
1310 1382 List<Long> up1 = new ArrayList<Long>();
1311 1383 List<Long> up2 = new ArrayList<Long>();
1312 1384 List<Long> dn1 = new ArrayList<Long>();
... ... @@ -1315,7 +1387,12 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1315 1387 Map<Long, ScheduleRealInfo> up2Map = new HashMap<Long, ScheduleRealInfo>();
1316 1388 Map<Long, ScheduleRealInfo> dn1Map = new HashMap<Long, ScheduleRealInfo>();
1317 1389 Map<Long, ScheduleRealInfo> dn2Map = new HashMap<Long, ScheduleRealInfo>();
1318   - for(ScheduleRealInfo s : keyMap.get(xlName)){
  1390 + String companyName = "", subCompanyName = "";
  1391 + for(ScheduleRealInfo s : keyMap.get(key)){
  1392 + if(companyName.length()==0&&s.getGsName()!=null&&s.getGsName().trim().length()!=0)
  1393 + companyName = s.getGsName();
  1394 + if(subCompanyName.length()==0&&s.getFgsName()!=null&&s.getFgsName().trim().length()!=0)
  1395 + subCompanyName = s.getFgsName();
1319 1396 if(s.getXlDir().equals("0")){
1320 1397 up1.add(s.getFcsjT());
1321 1398 up1Map.put(s.getFcsjT(), s);
... ... @@ -1389,7 +1466,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1389 1466 tempMap.put("company", companyName);
1390 1467 tempMap.put("subCompany", subCompanyName);
1391 1468 tempMap.put("date", date);
1392   - tempMap.put("line", xlName);
  1469 + tempMap.put("line", keys[0]);
1393 1470 resList.add(tempMap);
1394 1471 }
1395 1472  
... ... @@ -1425,10 +1502,13 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1425 1502 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
1426 1503 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
1427 1504  
1428   - Set<String> lineSet = getNotOperation();
1429   -
1430   - String company = map.get("company").toString();
1431   - String subCompany = map.get("subCompany").toString();
  1505 + String sfyy = "", company = "", subCompany = "";
  1506 + if(map.get("sfyy")!=null)
  1507 + sfyy = map.get("sfyy").toString();
  1508 + if(map.get("company")!=null)
  1509 + company = map.get("company").toString();
  1510 + if(map.get("subCompany")!=null)
  1511 + subCompany = map.get("subCompany").toString();
1432 1512 String line = map.get("line").toString();
1433 1513 // String date = map.get("date").toString();
1434 1514 String startDate = map.get("startDate").toString();
... ... @@ -1453,13 +1533,16 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1453 1533  
1454 1534 try {
1455 1535 String sql = "select a.schedule_date_str, a.real_exec_date, a.xl_bm, a.xl_name, a.fcsj, a.fcsj_actual, a.zdsj, a.zdsj_actual, a.qdz_name, a.zdz_name, a.xl_dir, a.status, a.gs_name, a.fgs_name,"
1456   - + " a.cc_service, a.remarks, a.adjust_exps, b.start_opt from bsth_c_s_sp_info_real a left join (select line, start_opt from bsth_c_line_config order by id desc) b on a.xl_bm = b.line"
  1536 + + " a.fgs_bm, a.cc_service, a.remarks, a.adjust_exps, b.start_opt from bsth_c_s_sp_info_real a left join (select line, start_opt from bsth_c_line_config order by id desc) b "
  1537 + + " on a.xl_bm = b.line"
1457 1538 + " where schedule_date_str >= '"+startDate+"' and schedule_date_str <= '"+endDate+"'"
1458 1539 + " and bc_type != 'in' and bc_type != 'out' and bc_type != 'ldks' and bc_type != 'region'";
1459 1540 if(line.length() != 0)
1460 1541 sql += " and xl_bm = '"+line+"'";
1461 1542 if(company.length() != 0)
1462   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  1543 + sql += " and gs_bm = '"+company+"'";
  1544 + if(subCompany.length() != 0)
  1545 + sql += " and fgs_bm = '"+subCompany+"'";
1463 1546  
1464 1547 list = jdbcTemplate.query(sql,
1465 1548 new RowMapper<ScheduleRealInfo>(){
... ... @@ -1480,6 +1563,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1480 1563 schedule.setStatus(rs.getInt("status"));
1481 1564 schedule.setGsName(rs.getString("gs_name"));
1482 1565 schedule.setFgsName(rs.getString("fgs_name"));
  1566 + schedule.setFgsBm(rs.getString("fgs_bm"));
1483 1567 schedule.setCcService(rs.getBoolean("cc_service"));
1484 1568 schedule.setRemarks(rs.getString("remarks")!=null?rs.getString("remarks"):"");
1485 1569 schedule.setAdjustExps(rs.getString("adjust_exps")!=null?rs.getString("adjust_exps"):"");
... ... @@ -1520,36 +1604,67 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1520 1604 e.printStackTrace();
1521 1605 }
1522 1606  
  1607 + Map<String, Boolean> lineNature = lineService.lineNature();
1523 1608 Map<String, Map<String, List<ScheduleRealInfo>>> keyMap = new HashMap<String, Map<String,List<ScheduleRealInfo>>>();
1524 1609 Map<String, String> xlMap = new HashMap<String, String>();
1525   - String companyName = "", subCompanyName = "";
1526 1610  
1527 1611 for(ScheduleRealInfo s : list){
1528   - if(lineSet.contains(s.getXlName()) || s.isCcService()){
  1612 + if(s.isCcService()){
1529 1613 continue;
1530 1614 }
1531   - String xlName = s.getXlName();
  1615 +
  1616 + boolean flag = false;
  1617 + String xlbm = s.getXlBm();
  1618 + if(sfyy.length() == 0 || sfyy.equals("0")){
  1619 + flag = true;
  1620 + } else if(sfyy.equals("1")){
  1621 + if(lineNature.containsKey(xlbm) && lineNature.get(xlbm)){
  1622 + flag = true;
  1623 + }
  1624 + } else {
  1625 + if(lineNature.containsKey(xlbm) && !lineNature.get(xlbm)){
  1626 + flag = true;
  1627 + }
  1628 + }
  1629 + if(!flag){
  1630 + continue;
  1631 + }
  1632 +
  1633 + String key = s.getXlName() + "/" + s.getXlBm() + "/" + s.getFgsBm();
1532 1634 String date = s.getScheduleDateStr();
1533   - if(!keyMap.containsKey(xlName))
1534   - keyMap.put(xlName, new HashMap<String, List<ScheduleRealInfo>>());
1535   - if(!keyMap.get(xlName).containsKey(date))
1536   - keyMap.get(xlName).put(date, new ArrayList<ScheduleRealInfo>());
1537   - keyMap.get(xlName).get(date).add(s);
1538   - if(companyName.length()==0&&s.getGsName()!=null&&s.getGsName().trim().length()!=0)
1539   - companyName = s.getGsName();
1540   - if(subCompanyName.length()==0&&s.getFgsName()!=null&&s.getFgsName().trim().length()!=0)
1541   - subCompanyName = s.getFgsName();
1542   - xlMap.put(xlName, s.getXlBm());
  1635 + if(!keyMap.containsKey(key)){
  1636 + keyMap.put(key, new HashMap<String, List<ScheduleRealInfo>>());
  1637 + }
  1638 + if(!keyMap.get(key).containsKey(date)){
  1639 + keyMap.get(key).put(date, new ArrayList<ScheduleRealInfo>());
  1640 + }
  1641 + keyMap.get(key).get(date).add(s);
  1642 +
  1643 + xlMap.put(key, s.getXlBm());
1543 1644 }
1544 1645  
  1646 + //给key排序
  1647 + List<Long> longList = new ArrayList<Long>();
  1648 + Map<Long, String> longMap = new HashMap<Long, String>();
  1649 + for(String key : keyMap.keySet()){
  1650 + String[] keys = key.split("/");
  1651 + Long l = Long.valueOf(keys[2]) * 10000000000l + Long.valueOf(keys[1]);
  1652 + longMap.put(l, key);
  1653 + longList.add(l);
  1654 + }
  1655 + Collections.sort(longList);
  1656 +
  1657 +
1545 1658 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
1546   - for(String xlName : keyMap.keySet()){
  1659 + for(Long tempLong : longList){
  1660 + String key = longMap.get(tempLong);
  1661 + String companyName = "", subCompanyName = "";
1547 1662 List<Map<String, Object>> tempList = new ArrayList<Map<String,Object>>();
1548 1663 Map<String, Object> tempMap = new HashMap<String, Object>();
1549 1664 Map<Long, String> dateMap = new HashMap<Long, String>();
1550 1665 List<Long> Longs = new ArrayList<Long>();
1551 1666 int jhbc = 0, sjbc = 0;
1552   - for(String date : keyMap.get(xlName).keySet()){
  1667 + for(String date : keyMap.get(key).keySet()){
1553 1668 String[] split = date.split("-");
1554 1669 long l = Long.valueOf(split[0])*10000 + Long.valueOf(split[1])*100 + Long.valueOf(split[2]);
1555 1670 dateMap.put(l, date);
... ... @@ -1559,10 +1674,11 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1559 1674 for(long l : Longs){
1560 1675 String date = dateMap.get(l);
1561 1676 Map<String, Object> temp = new HashMap<String, Object>();
  1677 + String[] keys = key.split("/");
1562 1678 temp.put("date", date.substring(5));
1563 1679 temp.put("dates", date);
1564   - temp.put("line", xlName);
1565   - temp.put("xlbm", xlMap.get(xlName));
  1680 + temp.put("line", keys[0]);
  1681 + temp.put("xlbm", xlMap.get(key));
1566 1682 List<Long> up1 = new ArrayList<Long>();
1567 1683 List<Long> up2 = new ArrayList<Long>();
1568 1684 List<Long> dn1 = new ArrayList<Long>();
... ... @@ -1571,7 +1687,12 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1571 1687 Map<Long, ScheduleRealInfo> up2Map = new HashMap<Long, ScheduleRealInfo>();
1572 1688 Map<Long, ScheduleRealInfo> dn1Map = new HashMap<Long, ScheduleRealInfo>();
1573 1689 Map<Long, ScheduleRealInfo> dn2Map = new HashMap<Long, ScheduleRealInfo>();
1574   - for(ScheduleRealInfo s : keyMap.get(xlName).get(date)){
  1690 + for(ScheduleRealInfo s : keyMap.get(key).get(date)){
  1691 + if(companyName.length()==0&&s.getGsName()!=null&&s.getGsName().trim().length()!=0)
  1692 + companyName = s.getGsName();
  1693 + if(subCompanyName.length()==0&&s.getFgsName()!=null&&s.getFgsName().trim().length()!=0)
  1694 + subCompanyName = s.getFgsName();
  1695 +
1575 1696 if(s.getXlDir().equals("0")){
1576 1697 up1.add(s.getFcsjT());
1577 1698 up1Map.put(s.getFcsjT(), s);
... ... @@ -1612,7 +1733,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1612 1733 Map<String, Object> m = new HashMap<String, Object>();
1613 1734 m.put("date", date.substring(5));
1614 1735 m.put("dates", date);
1615   - m.put("line", xlName);
  1736 + m.put("line", keys[0]);
  1737 + m.put("company", companyName);
  1738 + m.put("subCompany", subCompanyName);
1616 1739 m.put("firstOrLast", "上行首发");
1617 1740 m.put("qdz", s1.getQdzName());
1618 1741 m.put("jhfc", s1.getFcsj());
... ... @@ -1629,7 +1752,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1629 1752 Map<String, Object> m = new HashMap<String, Object>();
1630 1753 m.put("date", date.substring(5));
1631 1754 m.put("dates", date);
1632   - m.put("line", xlName);
  1755 + m.put("line", keys[0]);
  1756 + m.put("company", companyName);
  1757 + m.put("subCompany", subCompanyName);
1633 1758 m.put("firstOrLast", "上行末发");
1634 1759 m.put("qdz", s3.getQdzName());
1635 1760 m.put("jhfc", s3.getFcsj());
... ... @@ -1674,7 +1799,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1674 1799 Map<String, Object> m = new HashMap<String, Object>();
1675 1800 m.put("date", date.substring(5));
1676 1801 m.put("dates", date);
1677   - m.put("line", xlName);
  1802 + m.put("line", keys[0]);
  1803 + m.put("company", companyName);
  1804 + m.put("subCompany", subCompanyName);
1678 1805 m.put("firstOrLast", "下行首发");
1679 1806 m.put("qdz", s1.getQdzName());
1680 1807 m.put("jhfc", s1.getFcsj());
... ... @@ -1692,7 +1819,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1692 1819 Map<String, Object> m = new HashMap<String, Object>();
1693 1820 m.put("date", date.substring(5));
1694 1821 m.put("dates", date);
1695   - m.put("line", xlName);
  1822 + m.put("line", keys[0]);
  1823 + m.put("company", companyName);
  1824 + m.put("subCompany", subCompanyName);
1696 1825 m.put("firstOrLast", "下行末发");
1697 1826 m.put("qdz", s3.getQdzName());
1698 1827 m.put("jhfc", s3.getFcsj());
... ... @@ -1718,11 +1847,12 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1718 1847 continue;
1719 1848 tempList.add(temp);
1720 1849 }
  1850 + String[] keys = key.split("/");
1721 1851 tempMap.put("map", tempList);
1722 1852 tempMap.put("company", companyName);
1723 1853 tempMap.put("subCompany", subCompanyName);
1724   - tempMap.put("xlbm", xlMap.get(xlName));
1725   - tempMap.put("line", xlName);
  1854 + tempMap.put("xlbm", xlMap.get(key));
  1855 + tempMap.put("line", keys[0]);
1726 1856 tempMap.put("date", dates);
1727 1857 tempMap.put("jhbc", jhbc);
1728 1858 tempMap.put("sjbc", sjbc);
... ... @@ -1744,8 +1874,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1744 1874 tempMap.put("zdl", (jhbc<1?"0":nf.format((float) sjbc / jhbc * 100)) + "%");
1745 1875 for(Map<String, Object> m : mapList){
1746 1876 m.put("no", ++i);
1747   - m.put("company", companyName);
1748   - m.put("subCompany", subCompanyName);
  1877 +// m.put("company", companyName);
  1878 +// m.put("subCompany", subCompanyName);
1749 1879 }
1750 1880 tempMap.put("map", mapList);
1751 1881 if(!type.equals("export"))
... ... @@ -1844,7 +1974,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1844 1974 sql += " and cl_zbh = '"+code+"'";
1845 1975 }
1846 1976 if(company.length() != 0){
1847   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  1977 + sql += " and gs_bm = '"+company+"'";
  1978 + }
  1979 + if(subCompany.length() != 0){
  1980 + sql += " and fgs_bm = '"+subCompany+"'";
1848 1981 }
1849 1982 sql += " union " +
1850 1983 "select r.id, r.schedule_date_str, r.xl_name, r.cl_zbh, r.j_gh, r.j_name, r.fcsj, d.timestamp, d.reply46, d.reply47, d.reply46time, d.reply47time, r.gs_name, r.fgs_name " +
... ... @@ -1856,7 +1989,10 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1856 1989 sql += " and cl_zbh = '"+code+"'";
1857 1990 }
1858 1991 if(company.length() != 0){
1859   - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'";
  1992 + sql += " and gs_bm = '"+company+"'";
  1993 + }
  1994 + if(subCompany.length() != 0){
  1995 + sql += " and fgs_bm = '"+subCompany+"'";
1860 1996 }
1861 1997 sql += " order by xl_name, fcsj";
1862 1998  
... ... @@ -1998,11 +2134,17 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
1998 2134 return resList;
1999 2135 }
2000 2136 */
  2137 +
2001 2138 @Override
2002 2139 public List<Map<String, Object>> commandState(Map<String, Object> map) {
2003 2140 // TODO Auto-generated method stub
2004   - String company = map.get("company").toString();
2005   - String subCompany = map.get("subCompany").toString();
  2141 + String sfyy = "", company = "", subCompany = "";
  2142 + if(map.get("sfyy")!=null)
  2143 + sfyy=map.get("sfyy").toString();
  2144 + if(map.get("company")!=null)
  2145 + company=map.get("company").toString();
  2146 + if(map.get("subCompany")!=null)
  2147 + subCompany=map.get("subCompany").toString();
2006 2148 String line = map.get("line").toString().trim();
2007 2149 String date = map.get("date").toString();
2008 2150 // String code = map.get("code").toString();
... ... @@ -2010,18 +2152,22 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
2010 2152  
2011 2153 String sql_="select * from bsth_c_s_sp_info_real "
2012 2154 + " WHERE schedule_date_str = '"+date+"' ";
2013   - if(line.equals("")){
2014   - sql_ += "and gs_bm='"+company+"'and fgs_bm='"+subCompany+"'";
2015   - }else{
  2155 + if(!line.equals("")){
2016 2156 sql_ += " and xl_bm = '"+line+"'";
2017 2157 }
  2158 + if(company.length() != 0){
  2159 + sql_ += " and gs_bm='"+company+"'";
  2160 + }
  2161 + if(subCompany.length() != 0){
  2162 + sql_ += " and fgs_bm='"+subCompany+"'";
  2163 + }
2018 2164  
2019 2165  
2020 2166 String sql="SELECT r.id,r.schedule_date_str,r.xl_name,r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,r.fcsj,"
2021 2167 + " r.gs_name,r.fgs_name,CONCAT(r.xl_bm,'_',r.id) as line_sch FROM ("+sql_+") AS r"
2022   - + " order by r.xl_name,r.id ";
  2168 + + " order by r.gs_bm,r.fgs_bm,r.xl_bm,r.id ";
2023 2169  
2024   - List<Map<String, Object>> list = jdbcTemplate.query(sql,
  2170 + List<Map<String, Object>> tempList = jdbcTemplate.query(sql,
2025 2171 new RowMapper<Map<String, Object>>(){
2026 2172 @Override
2027 2173 public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
... ... @@ -2050,6 +2196,23 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
2050 2196 e.printStackTrace();
2051 2197 }
2052 2198  
  2199 + Map<String, Boolean> lineNature = lineService.lineNature();
  2200 + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
  2201 + for(Map<String, Object> m : tempList){
  2202 + String xlbm = m.get("xlbm").toString();
  2203 + if(sfyy.length() == 0 || sfyy.equals("0")){
  2204 + list.add(m);
  2205 + } else if(sfyy.equals("1")){
  2206 + if(lineNature.containsKey(xlbm) && lineNature.get(xlbm)){
  2207 + list.add(m);
  2208 + }
  2209 + } else {
  2210 + if(lineNature.containsKey(xlbm) && !lineNature.get(xlbm)){
  2211 + list.add(m);
  2212 + }
  2213 + }
  2214 + }
  2215 +
2053 2216 long min = 0, max = 0;
2054 2217 for(Map<String, Object> m : list){
2055 2218 long l = Long.valueOf(m.get("id").toString());
... ... @@ -2411,7 +2574,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
2411 2574 String jgh = map.get("jgh").toString();
2412 2575 // String code = map.get("code").toString();
2413 2576 String type = "";
2414   - if(map.containsKey("type"))
  2577 + if(map.get("type")!=null)
2415 2578 type = map.get("type").toString().trim();
2416 2579  
2417 2580 String sql_="select * from bsth_c_s_sp_info_real "
... ... @@ -2420,7 +2583,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService {
2420 2583 if(!line.equals("")){
2421 2584 sql_ +=" and xl_bm = '"+line+"'";
2422 2585 }
2423   -
  2586 +
2424 2587  
2425 2588 String sql="SELECT r.id,r.schedule_date_str,r.fcsj,r.xl_name,r.xl_bm,r.cl_zbh,r.j_gh,r.j_name,"
2426 2589 + " r.fcsj,d. TIMESTAMP,d.reply46,d.reply47,d.reply46time,d.reply47time,"
... ...
src/main/java/com/bsth/service/schedule/plan/DroolsSchedulePlan.java
... ... @@ -475,6 +475,9 @@ public class DroolsSchedulePlan {
475 475 * @param schedulePlan
476 476 */
477 477 public void validPlanResult(PlanResult planResult) {
  478 + // 1-0、获取路牌信息
  479 + LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) this.ttInfoOutput(this.mainLine)[1];
  480 +
478 481 // 1-1、构造drools规则输入数据,输出数据
479 482 ValidateParam validateParam = new ValidateParam(
480 483 new DateTime(this.from), new DateTime(this.to));
... ... @@ -494,6 +497,9 @@ public class DroolsSchedulePlan {
494 497 for (SchedulePlanInfo schedulePlanInfo: planResult.getSchedulePlanInfos()) {
495 498 session.insert(schedulePlanInfo);
496 499 }
  500 + for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) {
  501 + session.insert(lpInfoResult_output);
  502 + }
497 503  
498 504 // 执行rule
499 505 session.fireAllRules();
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResult_output.java
... ... @@ -10,6 +10,8 @@ public class LpInfoResult_output {
10 10 private DateTime dateTime;
11 11 /** 路牌Id */
12 12 private String lpId;
  13 + /** 路牌名字 */
  14 + private String lpName;
13 15 /** 线路Id */
14 16 private String xlId;
15 17 /** 时刻表Id */
... ... @@ -56,4 +58,12 @@ public class LpInfoResult_output {
56 58 public void setTtInfoName(String ttInfoName) {
57 59 this.ttInfoName = ttInfoName;
58 60 }
  61 +
  62 + public String getLpName() {
  63 + return lpName;
  64 + }
  65 +
  66 + public void setLpName(String lpName) {
  67 + this.lpName = lpName;
  68 + }
59 69 }
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResultsFunction.java
... ... @@ -64,6 +64,7 @@ public class LpInfoResultsFunction implements AccumulateFunction {
64 64 if (lpInfoResultsData.lpInfoResult_outputMap.get(ttInfoDetail.getLp().getId()) == null) {
65 65 LpInfoResult_output lpInfoResult_output = new LpInfoResult_output();
66 66 lpInfoResult_output.setLpId(String.valueOf(ttInfoDetail.getLp().getId()));
  67 + lpInfoResult_output.setLpName(ttInfoDetail.getLp().getLpName());
67 68 lpInfoResult_output.setXlId(String.valueOf(ttInfoDetail.getXl().getId()));
68 69 lpInfoResult_output.setTtInfoId(String.valueOf(ttInfoDetail.getTtinfo().getId()));
69 70 lpInfoResult_output.setTtInfoName(ttInfoDetail.getTtinfo().getName());
... ...