Commit 042ef81820972192ffdd61ab3bacdefd7b01e6b0

Authored by zhouqin
2 parents 876dffcf f0622517

Merge remote-tracking branch 'origin/qingpu_20180808' into qingpu_20180808

Showing 93 changed files with 2658 additions and 417 deletions

Too many changes to show.

To preserve performance only 93 of 597 files are displayed.

src/main/java/com/bsth/XDApplication.java
... ... @@ -169,7 +169,7 @@ public class XDApplication implements CommandLineRunner {
169 169 sexec.scheduleWithFixedDelay(schedulePstThread, 180, 10, TimeUnit.SECONDS);//班次延迟入库线程
170 170 sexec.scheduleWithFixedDelay(seiPstThread, 180, 60, TimeUnit.SECONDS);//班次修正日志入库
171 171 sexec.scheduleWithFixedDelay(directivesPstThread, 120, 60, TimeUnit.SECONDS);//调度指令延迟入库
172   - sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
  172 + //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
173 173 sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据
174 174 sexec.scheduleWithFixedDelay(basicDataLoader, 1, 1, TimeUnit.HOURS);//基础数据更新
175 175 sexec.scheduleWithFixedDelay(autoExecScanThread, 180, 50, TimeUnit.SECONDS);//班次自动执行
... ...
src/main/java/com/bsth/common/Constants.java
... ... @@ -20,6 +20,8 @@ public class Constants {
20 20 public static final String METRONIC_URL = "/metronic_v4.5.4/**";
21 21 public static final String LOGIN_FAILURE = "/user/loginFailure";
22 22 public static final String CAPTCHA = "/captcha.jpg";
  23 + public static final String XIANDIAO_LOGIN = "/xdlogin.html";
  24 + public static final String IPAD_IMG_URL = "/apple-touch-icon-72x72.png";
23 25  
24 26 //对外的营运数据接口
25 27 public static final String SERVICE_INTERFACE = "/companyService/**";
... ...
src/main/java/com/bsth/controller/StationController.java
1 1 package com.bsth.controller;
2 2  
3   -import java.util.Map;
4   -
  3 +import com.bsth.entity.Station;
  4 +import com.bsth.service.StationService;
  5 +import com.bsth.util.GetUIDAndCode;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
5 8 import org.springframework.beans.factory.annotation.Autowired;
6 9 import org.springframework.web.bind.annotation.RequestMapping;
7 10 import org.springframework.web.bind.annotation.RequestMethod;
8 11 import org.springframework.web.bind.annotation.RequestParam;
9 12 import org.springframework.web.bind.annotation.RestController;
10 13  
11   -import com.bsth.entity.Station;
12   -import com.bsth.service.StationService;
13   -import com.bsth.util.GetUIDAndCode;
  14 +import java.util.Map;
14 15  
15 16 /**
16 17 *
... ... @@ -34,6 +35,9 @@ public class StationController extends BaseController<Station, Integer> {
34 35  
35 36 @Autowired
36 37 private StationService service;
  38 +
  39 + /** 日志记录器 */
  40 + private static final Logger LOGGER = LoggerFactory.getLogger(StationController.class);
37 41  
38 42 /**
39 43 * @Description :TODO(根据坐标点匹配数据库中的站点)
... ... @@ -153,10 +157,13 @@ public class StationController extends BaseController<Station, Integer> {
153 157 */
154 158 @RequestMapping(value="updateStationAndSectionCode" , method = RequestMethod.GET)
155 159 public int updateStationAndSectionCode(@RequestParam Integer stationCount, Integer sectionCount) {
  160 + System.out.println(stationCount+" _ "+ sectionCount );
156 161 for(int i = 0; i < stationCount; i++) {
  162 + System.out.println(i);
157 163 GetUIDAndCode.getStationId();
158 164 }
159   - for(int i = 0; i < sectionCount; i++) {
  165 + for(int j = 0; j < sectionCount; j++) {
  166 + System.out.println(j);
160 167 GetUIDAndCode.getSectionId();
161 168 }
162 169 return 1;
... ...
src/main/java/com/bsth/controller/StationRouteController.java
1 1 package com.bsth.controller;
2 2  
3   -import com.bsth.entity.Station;
4 3 import com.bsth.entity.StationRoute;
5 4 import com.bsth.entity.StationRouteCache;
6 5 import com.bsth.repository.StationRouteCacheRepository;
... ... @@ -12,11 +11,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
12 11 import org.springframework.web.bind.annotation.RequestParam;
13 12 import org.springframework.web.bind.annotation.RestController;
14 13  
  14 +import javax.servlet.http.HttpServletResponse;
15 15 import java.util.List;
16 16 import java.util.Map;
17 17  
18   -import javax.servlet.http.HttpServletResponse;
19   -
20 18 /**
21 19 *
22 20 * @ClassName: StationRouteController(站点路由控制器)
... ...
src/main/java/com/bsth/controller/realcontrol/PageForwardingController.java
... ... @@ -6,10 +6,12 @@ import com.bsth.security.util.SecurityUtils;
6 6 import org.slf4j.Logger;
7 7 import org.slf4j.LoggerFactory;
8 8 import org.springframework.stereotype.Controller;
  9 +import org.springframework.web.bind.annotation.PathVariable;
9 10 import org.springframework.web.bind.annotation.RequestMapping;
10 11 import org.springframework.web.servlet.ModelAndView;
11 12  
12 13 import javax.servlet.http.HttpServletResponse;
  14 +import javax.ws.rs.Path;
13 15  
14 16 /**
15 17 * 线调登入页面转发
... ... @@ -21,7 +23,7 @@ public class PageForwardingController {
21 23  
22 24 Logger logger = LoggerFactory.getLogger(this.getClass());
23 25  
24   - @RequestMapping("/v2")
  26 + /*@RequestMapping("/v2")
25 27 public ModelAndView v2(HttpServletResponse response){
26 28 ModelAndView mv = new ModelAndView();
27 29 SysUser user = SecurityUtils.getCurrentUser();
... ... @@ -50,5 +52,42 @@ public class PageForwardingController {
50 52 //正常线调主页
51 53 mv.setViewName("/real_control_v2/main.html");
52 54 return mv;
  55 + }*/
  56 +
  57 + @RequestMapping("/{type}")
  58 + public ModelAndView v2(@PathVariable("type") String type, HttpServletResponse response){
  59 + ModelAndView mv = new ModelAndView();
  60 + SysUser user = SecurityUtils.getCurrentUser();
  61 +
  62 + //班次管理员
  63 + if(user.getUserName().equals("bcgly")){
  64 + mv.setViewName("/real_control_v2/sch_manage/sch_imitate.html");
  65 + return mv;
  66 + }
  67 +
  68 + try{
  69 + //闵行运管所,直接打开地图页面
  70 + if(user.getRoles().size() == 1){
  71 + for(Role role : user.getRoles()){
  72 + if(role.getCodeName().equals("MH_YGS")){
  73 + // 直接重定向
  74 + response.sendRedirect("/pages/mapmonitor/alone/wrap.html");
  75 + return null;
  76 + }
  77 + }
  78 + }
  79 + }catch (Exception e){
  80 + logger.error("", e);
  81 + }
  82 +
  83 +
  84 + if(type.equals("v2_mobile")){
  85 + mv.setViewName("/real_control_v2_mobile/main.html");
  86 + }else{
  87 + //正常线调主页
  88 + mv.setViewName("/real_control_v2/main.html");
  89 + }
  90 +
  91 + return mv;
53 92 }
54 93 }
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
  3 +import java.io.ByteArrayOutputStream;
  4 +import java.io.IOException;
  5 +import java.io.InputStream;
  6 +import java.io.OutputStream;
  7 +import java.net.HttpURLConnection;
  8 +import java.net.URL;
  9 +import java.util.ArrayList;
  10 +import java.util.Collection;
  11 +import java.util.HashMap;
  12 +import java.util.List;
  13 +import java.util.Map;
  14 +
  15 +import org.apache.commons.io.IOUtils;
  16 +import org.apache.commons.lang3.StringEscapeUtils;
  17 +import org.joda.time.format.DateTimeFormat;
  18 +import org.joda.time.format.DateTimeFormatter;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.web.bind.annotation.PathVariable;
  21 +import org.springframework.web.bind.annotation.RequestMapping;
  22 +import org.springframework.web.bind.annotation.RequestMethod;
  23 +import org.springframework.web.bind.annotation.RequestParam;
  24 +import org.springframework.web.bind.annotation.RestController;
  25 +
3 26 import com.alibaba.fastjson.JSONArray;
4 27 import com.bsth.common.ResponseCode;
5 28 import com.bsth.controller.BaseController;
... ... @@ -10,14 +33,11 @@ import com.bsth.data.schedule.DayOfSchedule;
10 33 import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
11 34 import com.bsth.entity.realcontrol.ScheduleRealInfo;
12 35 import com.bsth.entity.schedule.SchedulePlanInfo;
  36 +import com.bsth.entity.sys.SysUser;
  37 +import com.bsth.security.util.SecurityUtils;
13 38 import com.bsth.service.realcontrol.ScheduleRealInfoService;
14   -import org.apache.commons.lang3.StringEscapeUtils;
15   -import org.joda.time.format.DateTimeFormat;
16   -import org.joda.time.format.DateTimeFormatter;
17   -import org.springframework.beans.factory.annotation.Autowired;
18   -import org.springframework.web.bind.annotation.*;
19   -
20   -import java.util.*;
  39 +import com.bsth.util.ConfigUtil;
  40 +import com.fasterxml.jackson.databind.ObjectMapper;
21 41  
22 42 @RestController
23 43 @RequestMapping("/realSchedule")
... ... @@ -515,6 +535,11 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
515 535 return scheduleRealInfoService.realScheduleList(line,date);
516 536 }
517 537  
  538 + @RequestMapping(value="/realScheduleList_zrw")
  539 + public List<ScheduleRealInfo> realScheduleList_zrw(@RequestParam String line,@RequestParam String date){
  540 + return scheduleRealInfoService.realScheduleList_zrw(line,date);
  541 + }
  542 +
518 543 @RequestMapping(value="/realScheduleList_mh_2")
519 544 public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){
520 545 return scheduleRealInfoService.realScheduleList_mh_2(line,date);
... ... @@ -686,4 +711,74 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
686 711 public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){
687 712 return scheduleRealInfoService.deleteToHistory(id);
688 713 }
  714 +
  715 + /**
  716 + * 从历史库里删除临加班次
  717 + * @param sch
  718 + * @return
  719 + */
  720 + @RequestMapping(value = "wxsb", method = RequestMethod.POST)
  721 + public Map<String, Object> deleteToHistory(@RequestParam Map<String, Object> param){
  722 + SysUser user = SecurityUtils.getCurrentUser();
  723 + String uname = user.getUserName();
  724 + StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url"));
  725 + url.append("?nbbm=").append(param.get("nbbm")).append("&bxy=").append(uname).append("&bxbm=").append(param.get("bxType"));
  726 + // 分公司保存格式 分公司编码_公司编码
  727 + String val = BasicData.nbbm2FgsCompanyCodeMap.get(param.get("nbbm"));
  728 + String[] arr = val.split("_");
  729 + if (!"22".equals(arr[1])) {
  730 + Map<String, Object> res = new HashMap<String, Object>();
  731 + res.put("status", ResponseCode.ERROR);
  732 + res.put("msg", "除金高公司外暂未开通此功能");
  733 +
  734 + return res;
  735 + }
  736 + url.append("&fgs=").append(arr[0]);
  737 +
  738 + return request(url.toString());
  739 + }
  740 +
  741 + @SuppressWarnings("unchecked")
  742 + private static Map<String, Object> request(String url) {
  743 + Map<String, Object> res = new HashMap<String, Object>();
  744 + res.put("status", ResponseCode.SUCCESS);
  745 + InputStream in = null;
  746 + HttpURLConnection con = null;
  747 + try {
  748 + con = (HttpURLConnection)new URL(url).openConnection();
  749 + con.setRequestMethod("POST");
  750 + con.setRequestProperty("keep-alive", "true");
  751 + con.setRequestProperty("accept", "application/json");
  752 + con.setRequestProperty("content-type", "application/json");
  753 + con.setDoInput(true);
  754 + con.setReadTimeout(2500);
  755 + con.setConnectTimeout(2500);
  756 +
  757 + con.connect();
  758 + if (con.getResponseCode() == 200) {
  759 + in = con.getInputStream();
  760 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  761 + IOUtils.copy(in, bout); bout.close();
  762 + Map<String, Object> response = new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  763 + if (!"报修成功".equals(response.get("msg"))) {
  764 + res.put("status", ResponseCode.ERROR);
  765 + res.putAll(response);
  766 + }
  767 + }
  768 + } catch (IOException e) {
  769 + // TODO Auto-generated catch block
  770 + res.put("status", ResponseCode.ERROR);
  771 + res.put("msg", "调用上报接口异常");
  772 + } finally {
  773 + try {
  774 + if (in != null) in.close();
  775 + if (con != null) con.disconnect();
  776 + } catch (IOException e) {
  777 + // TODO Auto-generated catch block
  778 + e.printStackTrace();
  779 + }
  780 + }
  781 +
  782 + return res;
  783 + }
689 784 }
... ...
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
... ... @@ -73,7 +73,7 @@ public class ServiceDataInterface {
73 73 map = new HashMap<>();
74 74 map.put("clZbh", sch.getClZbh());
75 75 map.put("jGh", sch.getjGh());
76   - map.put("jName", sch.getjGh());
  76 + map.put("jName", sch.getjName());
77 77 map.put("sGh", sch.getsGh());
78 78 map.put("sName", sch.getsGh());
79 79 map.put("lpName", sch.getLpName());
... ...
src/main/java/com/bsth/controller/schedule/core/CarConfigInfoController.java
1 1 package com.bsth.controller.schedule.core;
2 2  
  3 +import com.bsth.common.Constants;
3 4 import com.bsth.common.ResponseCode;
4 5 import com.bsth.controller.schedule.BController;
5 6 import com.bsth.entity.schedule.CarConfigInfo;
  7 +import com.bsth.entity.sys.CompanyAuthority;
6 8 import com.bsth.repository.schedule.CarConfigInfoRepository;
7 9 import com.bsth.service.schedule.CarConfigInfoService;
8 10 import com.bsth.service.schedule.exception.ScheduleException;
... ... @@ -12,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
12 14 import org.springframework.web.bind.annotation.RequestParam;
13 15 import org.springframework.web.bind.annotation.RestController;
14 16  
  17 +import javax.servlet.http.HttpServletRequest;
  18 +import javax.servlet.http.HttpSession;
15 19 import java.util.HashMap;
16 20 import java.util.List;
17 21 import java.util.Map;
... ... @@ -58,4 +62,84 @@ public class CarConfigInfoController extends BController&lt;CarConfigInfo, Long&gt; {
58 62  
59 63 return rtn;
60 64 }
  65 +
  66 + @RequestMapping(value = "/validate_cars_2", method = RequestMethod.GET)
  67 + public Map<String, Object> validate_cars(@RequestParam Integer xlId, @RequestParam Integer clId) {
  68 + Map<String, Object> rtn = new HashMap<>();
  69 + try {
  70 + carConfigInfoService.validate_cars(xlId, clId);
  71 + rtn.put("status", ResponseCode.SUCCESS);
  72 + } catch (ScheduleException exp) {
  73 + rtn.put("status", ResponseCode.ERROR);
  74 + rtn.put("msg", exp.getMessage());
  75 + }
  76 +
  77 + return rtn;
  78 + }
  79 +
  80 + @RequestMapping(value = "/validate_cars_gs", method = RequestMethod.GET)
  81 + public Map<String, Object> validate_cars_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) {
  82 + HttpSession session = request.getSession();
  83 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS);
  84 +
  85 + Map<String, Object> rtn = new HashMap<>();
  86 + try {
  87 + CarConfigInfo carConfigInfo = new CarConfigInfo(
  88 + null,
  89 + param.get("xl.id_eq"),
  90 + param.get("xl.name_eq"),
  91 + param.get("cl.id_eq")
  92 + );
  93 + carConfigInfoService.validate_cars_gs(carConfigInfo, cmyAuths);
  94 + rtn.put("status", ResponseCode.SUCCESS);
  95 + } catch (ScheduleException exp) {
  96 + rtn.put("status", ResponseCode.ERROR);
  97 + rtn.put("msg", exp.getMessage());
  98 + }
  99 +
  100 + return rtn;
  101 + }
  102 +
  103 + @RequestMapping(value = "/validate_cars_fgs", method = RequestMethod.GET)
  104 + public Map<String, Object> validate_cars_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) {
  105 + HttpSession session = request.getSession();
  106 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS);
  107 +
  108 + Map<String, Object> rtn = new HashMap<>();
  109 + try {
  110 + CarConfigInfo carConfigInfo = new CarConfigInfo(
  111 + null,
  112 + param.get("xl.id_eq"),
  113 + param.get("xl.name_eq"),
  114 + param.get("cl.id_eq")
  115 + );
  116 + carConfigInfoService.validate_cars_fgs(carConfigInfo, cmyAuths);
  117 + rtn.put("status", ResponseCode.SUCCESS);
  118 + } catch (ScheduleException exp) {
  119 + rtn.put("status", ResponseCode.ERROR);
  120 + rtn.put("msg", exp.getMessage());
  121 + }
  122 +
  123 + return rtn;
  124 + }
  125 +
  126 + @RequestMapping(value = "/validate_cars_config", method = RequestMethod.GET)
  127 + public Map<String, Object> validate_cars_config(@RequestParam Map<String, Object> param) {
  128 + Map<String, Object> rtn = new HashMap<>();
  129 + try {
  130 + CarConfigInfo carConfigInfo = new CarConfigInfo(
  131 + null,
  132 + param.get("xl.id_eq"),
  133 + param.get("xl.name_eq"),
  134 + param.get("cl.id_eq")
  135 + );
  136 + carConfigInfoService.validate_cars_config(carConfigInfo);
  137 + rtn.put("status", ResponseCode.SUCCESS);
  138 + } catch (ScheduleException exp) {
  139 + rtn.put("status", ResponseCode.ERROR);
  140 + rtn.put("msg", exp.getMessage());
  141 + }
  142 +
  143 + return rtn;
  144 + }
61 145 }
... ...
src/main/java/com/bsth/controller/schedule/core/EmployeeConfigInfoController.java
1 1 package com.bsth.controller.schedule.core;
2 2  
  3 +import com.bsth.common.Constants;
3 4 import com.bsth.common.ResponseCode;
4 5 import com.bsth.controller.schedule.BController;
5 6 import com.bsth.entity.schedule.EmployeeConfigInfo;
  7 +import com.bsth.entity.sys.CompanyAuthority;
6 8 import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
7 9 import com.bsth.service.schedule.EmployeeConfigInfoService;
8 10 import com.bsth.service.schedule.exception.ScheduleException;
9 11 import org.springframework.beans.factory.annotation.Autowired;
10 12 import org.springframework.web.bind.annotation.*;
11 13  
  14 +import javax.servlet.http.HttpServletRequest;
  15 +import javax.servlet.http.HttpSession;
12 16 import java.util.HashMap;
13 17 import java.util.List;
14 18 import java.util.Map;
... ... @@ -91,6 +95,54 @@ public class EmployeeConfigInfoController extends BController&lt;EmployeeConfigInfo
91 95 return rtn;
92 96 }
93 97  
  98 + @RequestMapping(value = "/validate_jsy_gs", method = RequestMethod.GET)
  99 + public Map<String, Object> validate_jsy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) {
  100 + HttpSession session = request.getSession();
  101 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS);
  102 +
  103 + Map<String, Object> rtn = new HashMap<>();
  104 + try {
  105 + EmployeeConfigInfo employeeConfigInfo = new EmployeeConfigInfo(
  106 + null,
  107 + param.get("xl.id_eq"),
  108 + param.get("xl.name_eq"),
  109 + param.get("jsy.id_eq"),
  110 + null
  111 + );
  112 + employeeConfigInfoService.validate_jsy_gs(employeeConfigInfo, cmyAuths);
  113 + rtn.put("status", ResponseCode.SUCCESS);
  114 + } catch (ScheduleException exp) {
  115 + rtn.put("status", ResponseCode.ERROR);
  116 + rtn.put("msg", exp.getMessage());
  117 + }
  118 +
  119 + return rtn;
  120 + }
  121 +
  122 + @RequestMapping(value = "/validate_jsy_fgs", method = RequestMethod.GET)
  123 + public Map<String, Object> validate_jsy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) {
  124 + HttpSession session = request.getSession();
  125 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS);
  126 +
  127 + Map<String, Object> rtn = new HashMap<>();
  128 + try {
  129 + EmployeeConfigInfo employeeConfigInfo = new EmployeeConfigInfo(
  130 + null,
  131 + param.get("xl.id_eq"),
  132 + param.get("xl.name_eq"),
  133 + param.get("jsy.id_eq"),
  134 + null
  135 + );
  136 + employeeConfigInfoService.validate_jsy_fgs(employeeConfigInfo, cmyAuths);
  137 + rtn.put("status", ResponseCode.SUCCESS);
  138 + } catch (ScheduleException exp) {
  139 + rtn.put("status", ResponseCode.ERROR);
  140 + rtn.put("msg", exp.getMessage());
  141 + }
  142 +
  143 + return rtn;
  144 + }
  145 +
94 146 @RequestMapping(value = "/validate_spy", method = RequestMethod.GET)
95 147 public Map<String, Object> validate_spy(@RequestParam Map<String, Object> param) {
96 148 Map<String, Object> rtn = new HashMap<>();
... ... @@ -130,4 +182,50 @@ public class EmployeeConfigInfoController extends BController&lt;EmployeeConfigInfo
130 182 }
131 183 return rtn;
132 184 }
  185 +
  186 + @RequestMapping(value = "/validate_spy_gs", method = RequestMethod.GET)
  187 + public Map<String, Object> validate_spy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) {
  188 + HttpSession session = request.getSession();
  189 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS);
  190 +
  191 + Map<String, Object> rtn = new HashMap<>();
  192 + try {
  193 + EmployeeConfigInfo employeeConfigInfo = new EmployeeConfigInfo(
  194 + null,
  195 + param.get("xl.id_eq"),
  196 + param.get("xl.name_eq"),
  197 + null,
  198 + param.get("spy.id_eq")
  199 + );
  200 + employeeConfigInfoService.validate_spy_gs(employeeConfigInfo, cmyAuths);
  201 + rtn.put("status", ResponseCode.SUCCESS);
  202 + } catch (ScheduleException exp) {
  203 + rtn.put("status", ResponseCode.ERROR);
  204 + rtn.put("msg", exp.getMessage());
  205 + }
  206 + return rtn;
  207 + }
  208 +
  209 + @RequestMapping(value = "/validate_spy_fgs", method = RequestMethod.GET)
  210 + public Map<String, Object> validate_spy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) {
  211 + HttpSession session = request.getSession();
  212 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS);
  213 +
  214 + Map<String, Object> rtn = new HashMap<>();
  215 + try {
  216 + EmployeeConfigInfo employeeConfigInfo = new EmployeeConfigInfo(
  217 + null,
  218 + param.get("xl.id_eq"),
  219 + param.get("xl.name_eq"),
  220 + null,
  221 + param.get("spy.id_eq")
  222 + );
  223 + employeeConfigInfoService.validate_spy_fgs(employeeConfigInfo, cmyAuths);
  224 + rtn.put("status", ResponseCode.SUCCESS);
  225 + } catch (ScheduleException exp) {
  226 + rtn.put("status", ResponseCode.ERROR);
  227 + rtn.put("msg", exp.getMessage());
  228 + }
  229 + return rtn;
  230 + }
133 231 }
... ...
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController.java
... ... @@ -57,4 +57,21 @@ public class SchedulePlanController extends BController&lt;SchedulePlan, Long&gt; {
57 57 return rtn;
58 58 }
59 59  
  60 + /**
  61 + * 验证排班计划时间范围内规则的正确性。
  62 + * @return
  63 + * @throws Exception
  64 + */
  65 + @RequestMapping(value = "/valttrule/{xlid}/{from}/{to}", method = RequestMethod.GET)
  66 + public Map<String, Object> validateRule(
  67 + @PathVariable(value = "xlid") Integer xlid,
  68 + @PathVariable(value = "from") Date from,
  69 + @PathVariable(value = "to") Date to
  70 + ) throws Exception {
  71 + Map<String, Object> rtn = new HashMap<>();
  72 + rtn.put("status", ResponseCode.SUCCESS);
  73 + rtn.put("data", schedulePlanService.validateRule(xlid, from, to));
  74 + return rtn;
  75 + }
  76 +
60 77 }
... ...
src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController.java
... ... @@ -128,6 +128,32 @@ public class TTInfoDetailController extends BController&lt;TTInfoDetail, Long&gt; {
128 128 return ttInfoDetailService.skbDetailMxSave(entities);
129 129 }
130 130  
  131 + @RequestMapping(value = "/exportDTDFile2", method = RequestMethod.POST)
  132 + public void exportFile2(@RequestBody TTinfoDetailDynamicData.LineHeadWayInfo lineHeadWayInfo,
  133 + HttpServletResponse response) throws Exception {
  134 + DataToolsFile dataToolsFile = ttInfoDetailService.exportHeadwayTTinfo(lineHeadWayInfo);
  135 +
  136 + // 流输出导出文件
  137 + response.setHeader("content-type", "application/octet-stream");
  138 + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName());
  139 + response.setContentType("application/octet-stream");
  140 +
  141 + OutputStream os = response.getOutputStream();
  142 + BufferedOutputStream bos = new BufferedOutputStream(os);
  143 +
  144 + InputStream is = new FileInputStream(dataToolsFile.getFile());
  145 + BufferedInputStream bis = new BufferedInputStream(is);
  146 +
  147 + int length = 0;
  148 + byte[] temp = new byte[1 * 1024 * 10];
  149 + while ((length = bis.read(temp)) != -1) {
  150 + bos.write(temp, 0, length);
  151 + }
  152 + bos.flush();
  153 + bis.close();
  154 + bos.close();
  155 + is.close();
  156 + }
131 157  
132 158 @RequestMapping(value = "/exportDTDFile/{type}", method = RequestMethod.POST)
133 159 public void exportFile(
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
... ... @@ -81,6 +81,7 @@ public class InStationProcess {
81 81 * @param prev
82 82 */
83 83 private void inStation(GpsEntity gps, GpsEntity prev) {
  84 + logger.info("进站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")");
84 85 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
85 86 boolean flow = true;
86 87 //要经过2个中途站才能进
... ... @@ -120,7 +121,7 @@ public class InStationProcess {
120 121 private void inEndStation(ScheduleRealInfo sch, GpsEntity gps) {
121 122 String nbbm = sch.getClZbh();
122 123 //校验进站前置约束
123   - if (!validInPremise(gps))
  124 + if (!validInPremise(gps) && isNormalSch(sch))
124 125 return;
125 126  
126 127 //实达时间不覆盖
... ...
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java
... ... @@ -74,6 +74,7 @@ public class OutStationProcess {
74 74 * @param gps
75 75 */
76 76 private void outStation(GpsEntity gps, GpsEntity prev) {
  77 + logger.info("出站记录(到达时间:" + gps.getArrTime() + " 进出站状态:" + gps.getInstation() + " 站点编号:" + gps.getStopNo() + " deviceId:" + gps.getDeviceId() + " nbbm:" + gps.getNbbm() + ")");
77 78 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
78 79  
79 80 //起点发车
... ...
src/main/java/com/bsth/data/gpsdata_v2/utils/GeoUtils.java
... ... @@ -397,5 +397,9 @@ public class GeoUtils {
397 397 return true;
398 398 }
399 399 }
  400 +
  401 + public static void main(String args[]) {
  402 + System.out.println(getDistance(new Point(121.52079, 31.189495), new Point(121.519981, 31.189695)));
  403 + }
400 404  
401 405 }
... ...
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataRecovery.java
... ... @@ -84,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware {
84 84 Calendar calendar = Calendar.getInstance();
85 85 int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
86 86  
87   - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE,SERVER_TS from bsth_c_gps_info where days_year=39"; //+ dayOfYear;
  87 + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE,SERVER_TS from bsth_c_gps_info"; //+ dayOfYear;
88 88 JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource());
89 89  
90 90 List<GpsEntity> list =
... ...
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
... ... @@ -108,6 +108,7 @@ public class LateAdjustHandle implements ApplicationContextAware {
108 108 try {
109 109 if (gps.getInstation() <= 0 || null == sch)
110 110 return;
  111 + logger.info("carArrive id: " + sch.getId());
111 112  
112 113 if (!lateSchMap.containsKey(sch.getId())) {
113 114 //班次是否误点(可能处于误点线程扫描的空隙,所以再判定一次)
... ...
src/main/java/com/bsth/data/schedule/thread/CalcOilThread.java
... ... @@ -2,13 +2,10 @@ package com.bsth.data.schedule.thread;
2 2  
3 3 import com.bsth.data.directive.DayOfDirectives;
4 4 import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
5   -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
6 5 import com.bsth.service.calc.CalcWaybillService;
7 6 import com.bsth.service.oil.DlbService;
8   -import com.bsth.data.safe_driv.SafeDrivCenter;
9 7 import com.bsth.service.oil.YlbService;
10 8 import com.bsth.service.report.SheetService;
11   -
12 9 import org.slf4j.Logger;
13 10 import org.slf4j.LoggerFactory;
14 11 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -60,7 +57,7 @@ public class CalcOilThread extends Thread{
60 57 //清除指令数据
61 58 dayOfDirectives.clearAll();
62 59 //清除安全驾驶数据
63   - SafeDrivCenter.clear();
  60 + //SafeDrivCenter.clear();
64 61 //清除超速缓存数据
65 62 OverspeedProcess.clear();
66 63  
... ...
src/main/java/com/bsth/entity/Cars.java
... ... @@ -126,6 +126,8 @@ public class Cars extends BEntity implements Serializable {
126 126 private String serviceNo;
127 127 /** 是否电车(TODO:在原系统里没有,这里暂时留着) */
128 128 private Boolean sfdc;
  129 + /** 是否混合动力(TODO:在原系统里没有,这里暂时留着) */
  130 + private Boolean sfmix;
129 131 /** 备注/描述 */
130 132 private String descriptions;
131 133  
... ... @@ -512,4 +514,12 @@ public class Cars extends BEntity implements Serializable {
512 514 public void setCgsbm(String cgsbm) {
513 515 this.cgsbm = cgsbm;
514 516 }
  517 +
  518 + public Boolean getSfmix() {
  519 + return sfmix;
  520 + }
  521 +
  522 + public void setSfmix(Boolean sfmix) {
  523 + this.sfmix = sfmix;
  524 + }
515 525 }
... ...
src/main/java/com/bsth/entity/mcy_forms/Shifday.java
... ... @@ -35,6 +35,8 @@ public class Shifday {
35 35 private String sjbc;//实际班次
36 36  
37 37 private String jgh;
  38 +
  39 + private String sgh;
38 40  
39 41 private String zbh;
40 42  
... ... @@ -56,6 +58,14 @@ public class Shifday {
56 58 this.jgh = jgh;
57 59 }
58 60  
  61 + public String getSgh() {
  62 + return sgh;
  63 + }
  64 +
  65 + public void setSgh(String sgh) {
  66 + this.sgh = sgh;
  67 + }
  68 +
59 69 public String getZbh() {
60 70 return zbh;
61 71 }
... ...
src/main/java/com/bsth/entity/schedule/BEntity.java
... ... @@ -12,10 +12,10 @@ import java.util.Date;
12 12 public class BEntity {
13 13  
14 14 /** 创建人 */
15   - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
  15 + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
16 16 private SysUser createBy;
17 17 /** 修改人 */
18   - @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
  18 + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
19 19 private SysUser updateBy;
20 20  
21 21 /** 创建日期 */
... ...
src/main/java/com/bsth/entity/schedule/SchedulePlanInfo.java
1 1 package com.bsth.entity.schedule;
2 2  
3 3 import com.bsth.entity.Line;
4   -import com.bsth.service.schedule.rules.rerun.RerunRule_input;
5   -import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
6   -import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_Type;
  4 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;
  5 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResult_output;
  6 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;
7 7  
8 8 import javax.persistence.*;
9 9 import java.sql.PreparedStatement;
... ...
src/main/java/com/bsth/filter/AccessLogFilter.java
... ... @@ -58,9 +58,11 @@ public class AccessLogFilter extends BaseFilter {
58 58 s.append(getBlock(params));
59 59 s.append(getBlock(headers));
60 60 s.append(getBlock(request.getHeader("Referer")));
61   -
62   - logger.info(s.toString());
  61 +
  62 + long now = System.currentTimeMillis();
63 63 chain.doFilter(request, response);
  64 + s.append("<cost time:").append(System.currentTimeMillis() - now).append(">");
  65 + logger.info(s.toString());
64 66 }
65 67  
66 68 private static String getParams(HttpServletRequest request) {
... ...
src/main/java/com/bsth/filter/BaseFilter.java
... ... @@ -17,7 +17,7 @@ public abstract class BaseFilter implements Filter {
17 17 * 白名单
18 18 */
19 19 private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
20   - Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT };
  20 + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT,Constants.XIANDIAO_LOGIN ,Constants.IPAD_IMG_URL};
21 21  
22 22 @Override
23 23 public void destroy() {
... ...
src/main/java/com/bsth/repository/CarDeviceRepository.java
... ... @@ -15,4 +15,10 @@ import org.springframework.stereotype.Repository;
15 15 public interface CarDeviceRepository extends BaseRepository<CarDevice, Long> {
16 16 @Query(value="select s from CarDevice s where s.newDeviceNo=?1 and s.qyrq<=?2 ")
17 17 List<CarDevice> findCarDevice(String device,Date date );
  18 +
  19 + @Query(value="select s from CarDevice s where s.oldDeviceNo=?1 and s.qyrq>=?2 ")
  20 + List<CarDevice> findCarOldDevice(String device,Date date );
  21 +
  22 + @Query(value="select s from CarDevice s where s.clZbh=?1 and s.qyrq>=?2 ")
  23 + List<CarDevice> findCarCode(String code,Date date );
18 24 }
... ...
src/main/java/com/bsth/repository/schedule/CarConfigInfoRepository.java
... ... @@ -50,4 +50,7 @@ public interface CarConfigInfoRepository extends BaseRepository&lt;CarConfigInfo, L
50 50  
51 51 @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH)
52 52 List<CarConfigInfo> findByXlId(Integer xlid);
  53 +
  54 + @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH)
  55 + List<CarConfigInfo> findByClId(Integer clid);
53 56 }
54 57 \ No newline at end of file
... ...
src/main/java/com/bsth/repository/schedule/GuideboardInfoRepository.java
... ... @@ -43,5 +43,7 @@ public interface GuideboardInfoRepository extends BaseRepository&lt;GuideboardInfo,
43 43  
44 44 @Query(value = "SELECT g FROM GuideboardInfo g where g.xl =?1 and g.lpName = ?2 and g.lpNo = ?3 and lpType =?4 and isCancel = 0")
45 45 List<GuideboardInfo> validateLp(Line xl,String lpName , int lpNo,String lpType);
  46 +
  47 + List<GuideboardInfo> findByXlId(Integer id);
46 48  
47 49 }
... ...
src/main/java/com/bsth/repository/schedule/TTInfoRepository.java
... ... @@ -48,4 +48,6 @@ public interface TTInfoRepository extends BaseRepository&lt;TTInfo, Long&gt; {
48 48 "from LineVersions lv where lv.line.id = ?1 and lv.status = ?2 ")
49 49 List<Map<String, Object>> findLineVersionDescs3(Integer lineId, Integer status);
50 50  
  51 + List<TTInfo> findByXlId(Integer xlId);
  52 +
51 53 }
... ...
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/security/filter/LoginInterceptor.java
... ... @@ -33,7 +33,7 @@ public class LoginInterceptor implements Filter {
33 33 * 相比于 BaseFilter,此处对线调GPS请求进行了拦截验证
34 34 */
35 35 private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
36   - Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT };
  36 + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT,Constants.XIANDIAO_LOGIN,Constants.IPAD_IMG_URL };
37 37  
38 38  
39 39 @Override
... ...
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
... ... @@ -115,7 +115,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
115 115 //待发应到时间
116 116 String dfsj = fmtHHmm.print(sch.getDfsjT() + (sch.getBcsj() * 60 * 1000));
117 117 String text = "您已完成" + finish + "个班次,下一发车时间" + fmtHHmm_CN.print(sch.getDfsjT()) + ",由"
118   - + sch.getQdzName() + "发往" + sch.getZdzName() + ";应到 " + dfsj;
  118 + + sch.getQdzName() + "发往" + sch.getZdzName() + ";应到 " + dfsj+";停车之后,请拉手刹!";
119 119  
120 120 if(sch.getBcType().equals("venting")){
121 121 text += " (直放)";
... ...
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
... ... @@ -596,7 +596,7 @@ public class FormsServiceImpl implements FormsService {
596 596 @Override
597 597 public List<Shifday> shifday(Map<String, Object> map) {
598 598  
599   - String line="";
  599 + String line="";
600 600 String date="";
601 601 String gsdmShif="";
602 602 String fgsdmShif="";
... ... @@ -624,18 +624,17 @@ public class FormsServiceImpl implements FormsService {
624 624 if(!type.equals("") && !statue.equals("")){
625 625 sql_ +=" order by "+statue+" "+type;
626 626 }
627   - String sql ="select t.* from (select r.schedule_date,r.j_name,"
628   - + "IFNULL(r.s_name,'')as s_name,"
629   - + " r.cl_zbh,r.xl_bm, r.j_gh,r.gs_bm,r.fgs_bm,r.lp_name "
630   - + "FROM bsth_c_s_sp_info_real r where 1=1 "
631   - + " and r.schedule_date_str='"+date + "' "
  627 + String sql ="select t.* from (select r.schedule_date,"
  628 + + " IFNULL(r.s_gh,'')as s_gh,r.cl_zbh,"
  629 + + " r.xl_bm,r.j_gh,r.gs_bm,r.fgs_bm,r.lp_name"
  630 + + " FROM bsth_c_s_sp_info_real r where 1=1 "
  631 + + " and r.schedule_date_str='"+date + "' "
632 632 + " and r.xl_bm = '"+line+"' "
633 633 + " and r.gs_bm like '%"+gsdmShif+"%' "
634   - + " and r.fgs_bm like '%"+fgsdmShif+"%' ) t"
635   - + " GROUP BY t.schedule_date,t.j_name,t.s_name, "
636   - + "t.cl_zbh,t.xl_bm,t.j_gh,t.gs_bm,t.fgs_bm,t.lp_name "
637   - + sql_;
638   -
  634 + + " and r.fgs_bm like '%"+fgsdmShif+"%' "+sql_+") t"
  635 + + " GROUP BY t.schedule_date,t.xl_bm,t.cl_zbh,t.lp_name,"
  636 + + " t.j_gh,t.s_gh,t.gs_bm,t.fgs_bm ";
  637 +
639 638  
640 639 List<Shifday> list = jdbcTemplate.query(sql, new RowMapper<Shifday>() {
641 640  
... ... @@ -643,15 +642,16 @@ public class FormsServiceImpl implements FormsService {
643 642 public Shifday mapRow(ResultSet arg0, int arg1) throws SQLException {
644 643 Shifday shifday = new Shifday();
645 644 shifday.setRq(arg0.getString("schedule_date"));
646   - shifday.setjName(arg0.getString("j_name").toString());
647   - shifday.setsName(arg0.getString("s_name") == null ? "" : arg0.getString("s_name").toString());
  645 +// shifday.setjName(arg0.getString("j_name").toString());
  646 +// shifday.setsName(arg0.getString("s_name") == null ? "" : arg0.getString("s_name").toString());
648 647 shifday.setCarPlate(arg0.getString("cl_zbh").toString());
649 648 shifday.setJgh(arg0.getString("j_gh"));
  649 + shifday.setSgh(arg0.getString("s_gh") == null ? "" : arg0.getString("s_gh").toString());
650 650 shifday.setLpName(arg0.getString("lp_name")== null ? "" : arg0.getString("lp_name").toString());
651 651 return shifday;
652 652 }
653   -
654 653 });
  654 +
655 655 List<ScheduleRealInfo> sList;
656 656 List<ScheduleRealInfo> list_s;
657 657 List<ScheduleRealInfo> lists=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(map.get("line").toString(), map.get("date").toString());
... ... @@ -661,8 +661,9 @@ public class FormsServiceImpl implements FormsService {
661 661 Shifday d=list.get(i);
662 662 for (int j = 0; j < lists.size(); j++) {
663 663 ScheduleRealInfo s=lists.get(j);
664   - if(d.getJgh().equals(s.getjGh()) && d.getCarPlate().equals(s.getClZbh())
665   - &&d.getLpName().equals(s.getLpName())){
  664 + if(d.getJgh().equals(s.getjGh()) && d.getSgh().equals(s.getsGh())
  665 + && d.getCarPlate().equals(s.getClZbh())
  666 + && d.getLpName().equals(s.getLpName())){
666 667 sList.add(s);
667 668 Set<ChildTaskPlan> cts = s.getcTasks();
668 669 if(cts != null && cts.size() > 0){
... ... @@ -674,7 +675,10 @@ public class FormsServiceImpl implements FormsService {
674 675 }
675 676 }
676 677 }
677   -
  678 + if(sList.size()>0){
  679 + d.setjName(sList.get(0).getjName());
  680 + d.setsName(sList.get(0).getsName() == null ? "":sList.get(0).getsName());
  681 + }
678 682 double ksgl=culateMileageService.culateKsgl(list_s);
679 683 double jccgl=culateMileageService.culateJccgl(list_s);
680 684 double zksgl=Arith.add(ksgl, jccgl);
... ... @@ -893,7 +897,8 @@ public class FormsServiceImpl implements FormsService {
893 897 if(fgsdm.length() != 0){
894 898 sql += " and r.fgs_bm ='"+fgsdm+"'";
895 899 }
896   - sql += " group by r.j_gh,r.xl_bm,r.cl_zbh,r.j_name order by r.xl_bm,r.cl_zbh";
  900 + sql += " group by r.fgs_bm,r.j_gh,r.xl_bm,r.cl_zbh,r.j_name " +
  901 + "order by r.xl_bm,r.cl_zbh";
897 902  
898 903 list = jdbcTemplate.query(sql, new RowMapper<Singledata>() {
899 904 @Override
... ... @@ -924,7 +929,7 @@ public class FormsServiceImpl implements FormsService {
924 929 + " WHERE rq = '"+startDate+"'"
925 930 + linesql
926 931 + " union"
927   - + " SELECT id,xlbm,nbbm,jsy,cdl as jzl,hd as yh,sh as sh,fgsdm FROM bsth_c_dlb"
  932 + + " SELECT id,xlbm,nbbm,jsy,cdl as jzl,hd as yh,sh as sh,fgsdm FROM bsth_c_dlb"
928 933 + " WHERE rq = '"+startDate+"'"
929 934 + linesql;
930 935 List<Singledata> listNy = jdbcTemplate.query(nysql, new RowMapper<Singledata>() {
... ...
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
... ... @@ -400,7 +400,7 @@ public class BusIntervalServiceImpl implements BusIntervalService {
400 400 sql += " and cl.line_code = '"+line+"'";
401 401 if(ttId.length() != 0)
402 402 sql += " and td.ttinfo = '"+ttId+"'";
403   - sql += " group by td.lp";
  403 + sql += " group by td.lp, lp.lp_name";
404 404  
405 405 list = jdbcTemplate.query(sql,
406 406 new RowMapper<Map<String, Object>>(){
... ...
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
... ... @@ -24,6 +24,7 @@ import com.bsth.util.db.DBUtils_MS;
24 24 import com.bsth.webService.trafficManage.org.tempuri.Results;
25 25 import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator;
26 26 import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap;
  27 +import com.bsth.webService.trafficManage.qp.WebServiceSoap_PortType;
27 28 import org.apache.commons.lang.StringEscapeUtils;
28 29 import org.apache.commons.lang.StringUtils;
29 30 import org.apache.commons.lang.time.DateUtils;
... ... @@ -130,6 +131,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{
130 131 e.printStackTrace();
131 132 }
132 133 }
  134 + // 青浦接口
  135 + private WebServiceSoap_PortType qp_ssop;
  136 + {
  137 + try {
  138 + qp_ssop = new com.bsth.webService.trafficManage.qp.WebServiceLocator().getWebServiceSoap();
  139 + } catch (Exception e) {
  140 + e.printStackTrace();
  141 + }
  142 + }
133 143 // 格式化 年月日时分秒 nyrsfm是年月日时分秒的拼音首字母
134 144 private SimpleDateFormat sdfnyrsfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
135 145  
... ... @@ -144,6 +154,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{
144 154 // 密码
145 155 private final String passwordOther = "user";
146 156  
  157 + private final String userNameOther_qp = "china317";
  158 +
  159 + private final String passwordOther_qp = "china317";
  160 +
147 161 // 用户名
148 162 private final String userNameUp = "user";
149 163 // 密码
... ... @@ -514,6 +528,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{
514 528 results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str));
515 529 // 记录日志
516 530 result = logRecord(results,logXlbmMap,logXlbmSuccessMap,logXlbmFailureMap,logSuccess,logFailure,str);
  531 + // 发送到青浦运管处
  532 + try {
  533 + com.bsth.webService.trafficManage.qp.Results res
  534 + = qp_ssop.setLD(userNameOther_qp,passwordOther_qp,StringEscapeUtils.unescapeHtml(str));
  535 + logger.info("青浦路单是否上传成功:"+res.isSuccess());
  536 + }catch (Exception e){
  537 + e.printStackTrace();
  538 + continue;
  539 + }
517 540 }
518 541 }
519 542 // 每per条线路上传后剩下的数据再上传
... ... @@ -521,6 +544,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{
521 544 sf.append("</DLDS>");
522 545 str = sf.toString().replace("'","");// 去掉'号
523 546 results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(str));
  547 + // 发送到青浦运管处
  548 + try {
  549 + com.bsth.webService.trafficManage.qp.Results res
  550 + = qp_ssop.setLD(userNameOther_qp,passwordOther_qp,StringEscapeUtils.unescapeHtml(str));
  551 + logger.info("青浦路单是否上传成功:"+res.isSuccess());
  552 + }catch (Exception e){
  553 + e.printStackTrace();
  554 + }
524 555 }
525 556 // 记录日志
526 557 result = logRecord(results,logXlbmMap,logXlbmSuccessMap,logXlbmFailureMap,logSuccess,logFailure,str);
... ... @@ -945,11 +976,11 @@ public class TrafficManageServiceImpl implements TrafficManageService{
945 976 */
946 977 @Override
947 978 public String setSKB(String ids) {
948   - String result = "failure";
  979 + String result = "上传失败,";
949 980 StringBuffer sBuffer = new StringBuffer();
950 981 DecimalFormat df = new DecimalFormat("######0.000");
951   - Map<String,String> lsStationCode2NameMap;
952   - Map<String, Integer> lsStationName2YgcNumber;
  982 + Map<String,String> lsStationCode2NameMap = null;
  983 + Map<String, Integer> lsStationName2YgcNumber = null;
953 984 try {
954 985 String[] idArray = ids.split(",");
955 986 StringBuffer sBufferA ,sBufferB ,sBufferC ;
... ... @@ -965,14 +996,21 @@ public class TrafficManageServiceImpl implements TrafficManageService{
965 996 sBuffer.append("<SKBs>");
966 997 HashMap<String,String> paramMap;
967 998 HashMap<String,String> otherMap = new HashMap<>();
  999 + // 线路编码、周几执行、发车站点名称、发车站点序号、到达站点名称、到达站点序号
  1000 + String xlbm,zjzx,fczdmc,zdxh,ddzdmc,ddxh;
  1001 + // 得到时刻表版本号
  1002 + int lineVersion;
  1003 + long ttinfoId;
  1004 + // 是否输出站点信息
  1005 + boolean isLogStation;
968 1006 for (int i = 0; i < idArray.length; i++) {
969   - long ttinfoId = Long.valueOf(idArray[i]);
  1007 + ttinfoId = Long.valueOf(idArray[i]);
970 1008 ttInfo = ttInfoRepository.findOne(ttinfoId);
971 1009 if(ttInfo == null)
972 1010 continue;
973 1011 ttinfoList.add(ttInfo); // 保存时刻表
974 1012 // 得到时刻表版本号
975   - int lineVersion = ttInfo.getLineVersion();
  1013 + lineVersion = ttInfo.getLineVersion();
976 1014 // 查询历史站点路由
977 1015 lsStationCode2NameMap = getLsStationCode(ttInfo.getXl().getLineCode(),lineVersion);
978 1016 // 查询历史站点路由
... ... @@ -988,16 +1026,35 @@ public class TrafficManageServiceImpl implements TrafficManageService{
988 1026 param = new HashMap();
989 1027 param.put("line.id_eq", ttInfo.getXl().getId());
990 1028 lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param));
  1029 + // 初始化
  1030 + isLogStation = true;
991 1031 if(ttInfoDetailIterator.hasNext()){
  1032 + // 得到线路信息
  1033 + Line line = lineRepository.findOne(ttInfo.getXl().getId());
  1034 + if(line == null){
  1035 + result += "未找到相应的线路信息,请设置线路信息后再上传";
  1036 + return result;
  1037 + }
  1038 + // 得到上海市线路编码
  1039 + xlbm = line.getShanghaiLinecode();
  1040 + if("".equals(xlbm) || "null".equals(xlbm)){
  1041 + result += "线路编码为空,请设置线路编码后再上传";
  1042 + return result;
  1043 + }
  1044 + // 拿到周几执行
  1045 + zjzx = changeRuleDay(ttInfo.getRule_days());
  1046 + if("".equals(zjzx) || "null".equals(zjzx)){
  1047 + result += "时刻表执行时间为空,请设置执行时间后再上传";
  1048 + return result;
  1049 + }
992 1050 sBuffer.append("<SKB>");
993   - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl().getId()))
994   - .append("</XLBM>");
  1051 + sBuffer.append("<XLBM>").append(xlbm).append("</XLBM>");
995 1052 sBufferB = new StringBuffer();
996 1053 sBufferC = new StringBuffer();
997 1054 sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>");
998 1055 // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表
999 1056 sBufferB.append("<JSRQ>").append("").append("</JSRQ>");
1000   - sBufferB.append("<ZJZX>").append(changeRuleDay(ttInfo.getRule_days())).append("</ZJZX>");
  1057 + sBufferB.append("<ZJZX>").append(zjzx).append("</ZJZX>");
1001 1058 sBufferB.append("<TBYY>").append("").append("</TBYY>");
1002 1059 sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>");
1003 1060 sBufferB.append("<BCList>");
... ... @@ -1021,22 +1078,51 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1021 1078 if(changeTimeFormat(ttInfoDetail) == null){
1022 1079 continue;
1023 1080 }
  1081 + // 发生站点名称
  1082 + fczdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getQdzCode());
  1083 + if("".equals(fczdmc) || "null".equals(fczdmc)){
  1084 + result += "发车站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传";
  1085 + return result;
  1086 + }
1024 1087 sBufferC.append("<BC>");
1025 1088 sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>");
1026 1089 sBufferC.append("<SXX>").append(sxx).append("</SXX>");
1027   - sBufferC.append("<FCZDMC>").append(lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
1028   - +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>");
  1090 + sBufferC.append("<FCZDMC>").append(fczdmc).append("</FCZDMC>");
1029 1091 // 起点站的参数
1030 1092 otherMap.put("stationMark","B");
1031 1093 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap);
1032   - sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)).append("</ZDXH>");
  1094 + if(isLogStation){// 输出起点站信息
  1095 + logger.info("setSKB:"+"起点站信息:"+paramMap);
  1096 + }
  1097 + // 发车站点序号
  1098 + zdxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber));
  1099 + if("".equals(zdxh) || "null".equals(zdxh) || "0".equals(zdxh)){
  1100 + result += "发车站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传";
  1101 + return result;
  1102 + }
  1103 + // 到达站点名称
  1104 + ddzdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getZdzCode());
  1105 + if("".equals(ddzdmc) || "null".equals(ddzdmc)){
  1106 + result += "到达站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传";
  1107 + return result;
  1108 + }
  1109 + sBufferC.append("<ZDXH>").append(zdxh).append("</ZDXH>");
1033 1110 sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>");
1034   - sBufferC.append("<DDZDMC>").append(lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()
1035   - +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>");
1036   - // 起点站的参数
  1111 + sBufferC.append("<DDZDMC>").append(ddzdmc).append("</DDZDMC>");
  1112 + // 终点站的参数
1037 1113 otherMap.put("stationMark","E");
1038 1114 paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap);
1039   - sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)).append("</DDXH>");
  1115 + if(isLogStation){// 输出终点站信息
  1116 + logger.info("setSKB:"+"终点站信息:"+paramMap);
  1117 + }
  1118 + // 到达站点序号
  1119 + ddxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber));
  1120 + if("".equals(ddxh) || "null".equals(ddxh) || "0".equals(ddxh)){
  1121 + result += "到达站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传";
  1122 + return result;
  1123 + }
  1124 + isLogStation = false; // 一条线路只输出一次,后面的不输出了
  1125 + sBufferC.append("<DDXH>").append(ddxh).append("</DDXH>");
1040 1126 sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>");
1041 1127 sBufferC.append("</BC>");
1042 1128 // 0:上行;1:下行
... ... @@ -1055,10 +1141,11 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1055 1141 sBufferA.append("<JHYYLC>").append(df.format(yylc)).append("</JHYYLC>");
1056 1142 sBuffer.append(sBufferA).append(sBufferB).append(sBufferC);
1057 1143 }
  1144 + logger.info("setSKB:"+"ttinfoId:"+ttinfoId+";当前站点版本号:"+lineVersion+";查询历史站点路由:"+lsStationCode2NameMap+";查询历史站点编号:"+lsStationName2YgcNumber);
1058 1145 }
1059 1146 sBuffer.append("</SKBs>");
1060 1147 if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){
1061   - result = "success";
  1148 + result = "上传成功";
1062 1149 SKBUploadLogger skbUploadLogger ;
1063 1150 SysUser user = SecurityUtils.getCurrentUser();
1064 1151 // 保存时刻表上传记录
... ... @@ -1069,6 +1156,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1069 1156 skbUploadLoggerRepository.save(skbUploadLogger);
1070 1157 }
1071 1158 }
  1159 +
  1160 + // 发送到青浦运管处
  1161 + try {
  1162 + com.bsth.webService.trafficManage.qp.Results res =
  1163 + qp_ssop.setSKB(userNameOther_qp,passwordOther_qp,sBuffer.toString());
  1164 + logger.info("青浦时刻表上传结果:"+ res.isSuccess());
  1165 + }catch (Exception e){
  1166 + e.printStackTrace();
  1167 + }
1072 1168 } catch (Exception e) {
1073 1169 logger.error("setSKB:", e);
1074 1170 e.printStackTrace();
... ...
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
... ... @@ -132,8 +132,8 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
132 132  
133 133 Long getMaxId();
134 134 Map<String,Object> scheduleDaily(String line,String date);
135   -
136 135 List<ScheduleRealInfo> realScheduleList(String line,String date);
  136 + List<ScheduleRealInfo> realScheduleList_zrw(String line,String date);
137 137 List<ScheduleRealInfo> realScheduleListQp(String line,String date);
138 138  
139 139 List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm,String jGh,String nbbm);
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -611,111 +611,119 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
611 611 * 临加班次
612 612 */
613 613 @Override
614   - public Map<String, Object> save(ScheduleRealInfo t) {
  614 + public Map<String, Object> save(ScheduleRealInfo sch) {
615 615 Map<String, Object> rs = new HashMap<>();
616 616 try {
617   - if (!carExist(t.getGsBm(), t.getClZbh())) {
618   - rs.put("msg", "车辆 " + t.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
619   - rs.put("status", ResponseCode.ERROR);
620   - return rs;
  617 + String clZbh = sch.getClZbh();
  618 + if (StringUtils.isNotEmpty(clZbh)) {
  619 + //检测
  620 + if (!carExist(sch.getGsBm(), clZbh)) {
  621 + rs.put("status", ResponseCode.ERROR);
  622 + rs.put("msg", "车辆 " + clZbh + " 不存在!");
  623 + return rs;
  624 + } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) {
  625 + rs.put("status", ResponseCode.ERROR);
  626 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆");
  627 + return rs;
  628 + }
621 629 }
622 630  
623 631 SysUser user = SecurityUtils.getCurrentUser();
624   - String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm());
  632 + String schDate = DayOfSchedule.currSchDateMap.get(sch.getXlBm());
625 633  
626 634 SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm");
627 635  
628   - if (StringUtils.isEmpty(t.getjGh())) {
  636 + if (StringUtils.isEmpty(sch.getjGh())) {
629 637 rs.put("status", ResponseCode.ERROR);
630 638 rs.put("msg", "驾驶员工号不能为空!");
631 639 return rs;
632 640 }
633 641 //截取驾驶员工号
634   - if (t.getjGh().indexOf("-") != -1) {
635   - t.setjGh(t.getjGh().split("-")[1]);
  642 + if (sch.getjGh().indexOf("-") != -1) {
  643 + sch.setjGh(sch.getjGh().split("-")[1]);
636 644 }
637 645 //检查驾驶员工号
638   - String jName = getPersonName(t.getGsBm(), t.getjGh());
  646 + String jName = getPersonName(sch.getGsBm(), sch.getjGh());
639 647 if (StringUtils.isEmpty(jName)) {
640   - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员");
  648 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员");
641 649 rs.put("status", ResponseCode.ERROR);
642 650 return rs;
643   - } else if (StringUtils.isEmpty(t.getjName())) {
644   - t.setjName(jName);//补上驾驶员名称
  651 + } else if (StringUtils.isEmpty(sch.getjName())) {
  652 + sch.setjName(jName);//补上驾驶员名称
645 653 }
646 654  
647 655 //有售票员
648   - if (StringUtils.isNotEmpty(t.getsGh())) {
649   - String sName = getPersonName(t.getGsBm(), t.getsGh());
  656 + if (StringUtils.isNotEmpty(sch.getsGh())) {
  657 + String sName = getPersonName(sch.getGsBm(), sch.getsGh());
650 658 if (StringUtils.isEmpty(sName)) {
651   - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员");
  659 + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的售票员");
652 660 rs.put("status", ResponseCode.ERROR);
653 661 return rs;
654   - } else if (StringUtils.isEmpty(t.getsName())) {
655   - t.setsName(sName);//补上售票员名称
  662 + } else if (StringUtils.isEmpty(sch.getsName())) {
  663 + sch.setsName(sName);//补上售票员名称
656 664 }
657 665 } else {
658   - t.setsGh("");
659   - t.setsName("");
  666 + sch.setsGh("");
  667 + sch.setsName("");
660 668 }
661 669  
662 670 //公司 和 分公司名称
663   - t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm()));
664   - t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getFgsBm() + "_" + t.getGsBm()));
665   - t.setCreateDate(new Date());
666   - t.setScheduleDateStr(schDate);
667   - t.setScheduleDate(sdfyyyyMMdd.parse(schDate));
668   - t.setRealExecDate(schDate);
669   -
670   - t.setCreateBy(user);
671   - t.setSflj(true);
672   - t.setLate(false);
673   - t.setDfsj(t.getFcsj());
674   - t.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + t.getZdsj()).getTime());
675   - t.setJhlcOrig(t.getJhlc());
676   - t.setCreateDate(new Date());
677   - t.setUpdateDate(new Date());
678   - t.setSpId(-1L);
  671 + sch.setGsName(BasicData.businessCodeNameMap.get(sch.getGsBm()));
  672 + sch.setFgsName(BasicData.businessFgsCodeNameMap.get(sch.getFgsBm() + "_" + sch.getGsBm()));
  673 + sch.setCreateDate(new Date());
  674 + sch.setScheduleDateStr(schDate);
  675 + sch.setScheduleDate(sdfyyyyMMdd.parse(schDate));
  676 + sch.setRealExecDate(schDate);
  677 +
  678 + sch.setCreateBy(user);
  679 + sch.setSflj(true);
  680 + sch.setLate(false);
  681 + sch.setDfsj(sch.getFcsj());
  682 + sch.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + sch.getZdsj()).getTime());
  683 + sch.setJhlcOrig(sch.getJhlc());
  684 + sch.setCreateDate(new Date());
  685 + sch.setUpdateDate(new Date());
  686 + sch.setSpId(-1L);
679 687 //起终点名称
680   - String prefix = t.getXlBm() + "_" + t.getXlDir() + "_";
681   - t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix));
682   - t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix));
  688 + String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_";
  689 + sch.setQdzName(BasicData.getStationNameByCode(sch.getQdzCode(), prefix));
  690 + sch.setZdzName(BasicData.getStationNameByCode(sch.getZdzCode(), prefix));
683 691  
684 692 //计算班次实际执行时间
685   - schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t);
  693 + schAttrCalculator.calcRealDate(sch).calcAllTimeByFcsj(sch);
686 694  
687 695 //处理计达跨24点
688   - LineConfig conf = lineConfigData.get(t.getXlBm());
689   - if (t.getZdsj().compareTo(conf.getStartOpt()) < 0) {
690   - t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime() + (1000 * 60 * 60 * 24));
  696 + LineConfig conf = lineConfigData.get(sch.getXlBm());
  697 + if (sch.getZdsj().compareTo(conf.getStartOpt()) < 0) {
  698 + sch.setZdsjT(sdfyyyyMMddHHmm.parse(sch.getScheduleDateStr() + sch.getZdsj()).getTime() + (1000 * 60 * 60 * 24));
691 699 }
692 700  
693 701 //班次历时
694   - t.setBcsj((int) ((t.getZdsjT() - t.getDfsjT()) / 1000 / 60));
695   - if (t.getZdsjT() < t.getFcsjT()) {
  702 + sch.setBcsj((int) ((sch.getZdsjT() - sch.getDfsjT()) / 1000 / 60));
  703 + if (sch.getZdsjT() < sch.getFcsjT()) {
696 704 rs.put("status", ResponseCode.ERROR);
697 705 rs.put("msg", "起终点时间异常!");
698 706 return rs;
699 707 }
700 708  
701   - t.setId(dayOfSchedule.getId());
  709 + sch.setId(dayOfSchedule.getId());
702 710 //实时入库
703   - super.save(t);
  711 + super.save(sch);
704 712  
705 713 // 加入缓存
706   - dayOfSchedule.put(t);
  714 + dayOfSchedule.put(sch);
707 715  
708 716 //更新起点应到时间
709   - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(t);
  717 + List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch);
710 718  
711 719 //重新计算车辆当前执行班次
712   - dayOfSchedule.reCalcExecPlan(t.getClZbh());
  720 + dayOfSchedule.reCalcExecPlan(sch.getClZbh());
713 721  
714 722 //记录站到场历时数据
715   - Station2ParkBuffer.put(t);
  723 + Station2ParkBuffer.put(sch);
716 724  
717 725 rs.put("ts", ts);
718   - rs.put("t", t);
  726 + rs.put("t", sch);
719 727 } catch (Exception e) {
720 728 logger.error("", e);
721 729 rs.put("status", ResponseCode.ERROR);
... ... @@ -1210,34 +1218,73 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1210 1218  
1211 1219 }
1212 1220 String device = "";
  1221 + String device2 ="";
  1222 + long qyrqTime=0l;
1213 1223 if (!code.equals("")) {
1214   - device = BasicData.deviceId2NbbmMap.inverse().get(code);
  1224 + try {
  1225 + List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00"));
  1226 + if(deviceList.size()>0){
  1227 + device=deviceList.get(0).getOldDeviceNo();
  1228 + Date qyrq=deviceList.get(0).getQyrq();
  1229 + qyrqTime=qyrq.getTime();
  1230 + if(qyrqTime<t){
  1231 + device2=deviceList.get(0).getNewDeviceNo();
  1232 + }
  1233 + }else{
  1234 + device = BasicData.deviceId2NbbmMap.inverse().get(code);
  1235 + }
  1236 + } catch (ParseException e) {
  1237 + // TODO Auto-generated catch block
  1238 + e.printStackTrace();
  1239 + }
1215 1240 }
1216   - List<Object[]> list = scheduleRealInfoRepository.historyMessage(line, d, t, device);
1217   - for (Object[] obj : list) {
  1241 + List<Object[]> list=new ArrayList<Object[]>();
  1242 +
  1243 + List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, d, t, device);
  1244 + for (Object[] obj : list0) {
1218 1245 if (obj != null) {
1219   -
1220   - if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) {
1221   - List<CarDevice> carDeviceList = new ArrayList<CarDevice>();
1222   - try {
1223   - carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));
1224   - } catch (Exception e) {
1225   - // TODO Auto-generated catch block
1226   - e.printStackTrace();
1227   - }
1228   - if (carDeviceList.size() > 0) {
1229   - obj[0] = carDeviceList.get(0).getClZbh();
  1246 + if(code.equals("")){
  1247 + if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) {
  1248 + List<CarDevice> carDeviceList = new ArrayList<CarDevice>();
  1249 + try {
  1250 + carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));
  1251 + //启用日期大于营运日期 还是根据旧设备号查询
  1252 + if(carDeviceList.size()==0){
  1253 + carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString())));
  1254 + }
  1255 + } catch (Exception e) {
  1256 + // TODO Auto-generated catch block
  1257 + e.printStackTrace();
  1258 + }
  1259 + if (carDeviceList.size() > 0) {
  1260 + obj[0] = carDeviceList.get(0).getClZbh();
  1261 + } else {
  1262 + obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());
  1263 + }
1230 1264 } else {
1231 1265 obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());
1232 1266 }
1233   - } else {
1234   - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString());
1235   - }
  1267 + }else{
  1268 + obj[0]=code;
  1269 + }
  1270 +
1236 1271 obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
1237 1272 obj[4] = BasicData.lineCode2NameMap.get(line);
1238 1273 }
1239 1274 }
1240   -
  1275 + list.addAll(list0);
  1276 + if(!device2.equals("")){
  1277 + List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, d, t, device2);
  1278 + for (Object[] obj : list1) {
  1279 + if (obj != null) {
  1280 + obj[0] =code;
  1281 + obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString())));
  1282 + obj[4] = BasicData.lineCode2NameMap.get(line);
  1283 + }
  1284 + }
  1285 + list.addAll(list1);
  1286 + }
  1287 +
1241 1288 if (type != null && type.length() != 0 && type.equals("export")) {
1242 1289 String lineName = BasicData.lineCode2NameMap.get(line);
1243 1290 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
... ... @@ -3213,6 +3260,63 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3213 3260 String zdsj1 = "";
3214 3261 String zdsjActual1 = "";
3215 3262 List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);
  3263 +
  3264 + /*
  3265 + * 对计划发车时间相同的班次进行排序 out最前 in最后
  3266 + */
  3267 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  3268 + String minfcsj = "02:00";
  3269 + List<Line> lineList = lineRepository.findLineByCode(line);
  3270 + if (lineList.size() > 0) {
  3271 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  3272 + + " id = ("
  3273 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  3274 + + ")";
  3275 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  3276 + }
  3277 + String[] minSjs = minfcsj.split(":");
  3278 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  3279 + for (int i = 0; i < listInfo.size(); i++) {
  3280 + ScheduleRealInfo s = listInfo.get(i);
  3281 + if (s.getBcType().equals("out")) {
  3282 + s.setRemark("1");
  3283 + } else if (s.getBcType().equals("in")) {
  3284 + s.setRemark("3");
  3285 + } else {
  3286 + s.setRemark("2");
  3287 + }
  3288 + String[] fcsj = s.getFcsj().split(":");
  3289 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  3290 +
  3291 + Long fscjT = 0L;
  3292 + if (fcsjL < minSj) {
  3293 + Calendar calendar = new GregorianCalendar();
  3294 + calendar.setTime(s.getScheduleDate());
  3295 + calendar.add(calendar.DATE, 1);
  3296 + s.setScheduleDate(calendar.getTime());
  3297 + try {
  3298 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  3299 + } catch (ParseException e) {
  3300 + // TODO Auto-generated catch block
  3301 + e.printStackTrace();
  3302 + }
  3303 +
  3304 + } else {
  3305 + try {
  3306 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  3307 + } catch (ParseException e) {
  3308 + // TODO Auto-generated catch block
  3309 + e.printStackTrace();
  3310 + }
  3311 + ;
  3312 + }
  3313 + s.setFcsjT(fscjT);
  3314 + }
  3315 + List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();
  3316 + listInfo2.addAll(listInfo);
  3317 + Collections.sort(listInfo, new compareLpFcsjType());
  3318 + System.out.println(listInfo);
  3319 + Collections.sort(listInfo2,new compareDirLpFcsjType());
3216 3320 for (int i = 0; i < listInfo.size(); i++) {
3217 3321 ScheduleRealInfo t = listInfo.get(i);
3218 3322 if (!lpName.equals(t.getLpName())) {
... ... @@ -3231,8 +3335,44 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3231 3335 lpName = t.getLpName();
3232 3336 list.add(t);
3233 3337 }
3234   -
  3338 +/*
3235 3339 List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleDdrb2(line, date);
  3340 + for (int i = 0; i < listInfo2.size(); i++) {
  3341 + ScheduleRealInfo s = listInfo2.get(i);
  3342 + if (s.getBcType().equals("out")) {
  3343 + s.setRemark("1");
  3344 + } else if (s.getBcType().equals("in")) {
  3345 + s.setRemark("3");
  3346 + } else {
  3347 + s.setRemark("2");
  3348 + }
  3349 + String[] fcsj = s.getFcsj().split(":");
  3350 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  3351 +
  3352 + Long fscjT = 0L;
  3353 + if (fcsjL < minSj) {
  3354 + Calendar calendar = new GregorianCalendar();
  3355 + calendar.setTime(s.getScheduleDate());
  3356 + calendar.add(calendar.DATE, 1);
  3357 + s.setScheduleDate(calendar.getTime());
  3358 + try {
  3359 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  3360 + } catch (ParseException e) {
  3361 + // TODO Auto-generated catch block
  3362 + e.printStackTrace();
  3363 + }
  3364 +
  3365 + } else {
  3366 + try {
  3367 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  3368 + } catch (ParseException e) {
  3369 + // TODO Auto-generated catch block
  3370 + e.printStackTrace();
  3371 + }
  3372 + ;
  3373 + }
  3374 + s.setFcsjT(fscjT);
  3375 + }*/
3236 3376 List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();
3237 3377 List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();
3238 3378 List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();
... ... @@ -3301,6 +3441,195 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3301 3441 }
3302 3442  
3303 3443 @Override
  3444 + public List<ScheduleRealInfo> realScheduleList_zrw(String line, String date) {
  3445 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  3446 + String lpName = "lpName";
  3447 + String zdsj = "";
  3448 + String zdsjActual = "";
  3449 + String zdsj1 = "";
  3450 + String zdsjActual1 = "";
  3451 + List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date);
  3452 +
  3453 + /*
  3454 + * 对计划发车时间相同的班次进行排序 out最前 in最后
  3455 + */
  3456 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  3457 + String minfcsj = "02:00";
  3458 + List<Line> lineList = lineRepository.findLineByCode(line);
  3459 + if (lineList.size() > 0) {
  3460 + String sqlMinYysj = "select start_opt from bsth_c_line_config where "
  3461 + + " id = ("
  3462 + + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'"
  3463 + + ")";
  3464 + minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class);
  3465 + }
  3466 + String[] minSjs = minfcsj.split(":");
  3467 + Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]);
  3468 + for (int i = 0; i < listInfo.size(); i++) {
  3469 + ScheduleRealInfo s = listInfo.get(i);
  3470 + if (s.getBcType().equals("out")) {
  3471 + s.setRemark("1");
  3472 + } else if (s.getBcType().equals("in")) {
  3473 + s.setRemark("3");
  3474 + } else {
  3475 + s.setRemark("2");
  3476 + }
  3477 + String[] fcsj = s.getFcsj().split(":");
  3478 + Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]);
  3479 +
  3480 + Long fscjT = 0L;
  3481 + if (fcsjL < minSj) {
  3482 + Calendar calendar = new GregorianCalendar();
  3483 + calendar.setTime(s.getScheduleDate());
  3484 + calendar.add(calendar.DATE, 1);
  3485 + s.setScheduleDate(calendar.getTime());
  3486 + try {
  3487 + fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime();
  3488 + } catch (ParseException e) {
  3489 + // TODO Auto-generated catch block
  3490 + e.printStackTrace();
  3491 + }
  3492 +
  3493 + } else {
  3494 + try {
  3495 + fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime();
  3496 + } catch (ParseException e) {
  3497 + // TODO Auto-generated catch block
  3498 + e.printStackTrace();
  3499 + }
  3500 + ;
  3501 + }
  3502 + s.setFcsjT(fscjT);
  3503 + }
  3504 +
  3505 +// Collections.sort(listInfo, new compareLpFcsjType());
  3506 + List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>();
  3507 +
  3508 + Collections.sort(listInfo, new compareLpFcsjType());
  3509 + for (int i = 0; i < listInfo.size(); i++) {
  3510 + ScheduleRealInfo t = listInfo.get(i);
  3511 + if (!lpName.equals(t.getLpName())) {
  3512 + zdsjActual = t.getZdsjActual();
  3513 + zdsj = t.getZdsj();
  3514 + t.setZdsjActual("");
  3515 + t.setZdsj("");
  3516 + } else {
  3517 + zdsj1 = t.getZdsj();
  3518 + zdsjActual1 = t.getZdsjActual();
  3519 + t.setZdsjActual(zdsjActual);
  3520 + t.setZdsj(zdsj);
  3521 + zdsj = zdsj1;
  3522 + zdsjActual = zdsjActual1;
  3523 + }
  3524 +
  3525 +
  3526 +
  3527 + lpName = t.getLpName();
  3528 + listInfo2.add(t);
  3529 +
  3530 + }
  3531 +
  3532 + Collections.sort(listInfo2,new compareDirLpFcsjType());
  3533 + for (int i = 0; i < listInfo2.size(); i++) {
  3534 + ScheduleRealInfo t=listInfo2.get(i);
  3535 + list.add(t);
  3536 + Set<ChildTaskPlan> childTaskPlans = t.getcTasks();
  3537 + //计算营运里程,空驶里程
  3538 + if (!childTaskPlans.isEmpty()) {
  3539 + List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans);
  3540 + Collections.sort(listit, new ComparableChild());
  3541 + for (int j = 0; j < listit.size(); j++) {
  3542 + ScheduleRealInfo s = new ScheduleRealInfo();
  3543 + ChildTaskPlan childTaskPlan = listit.get(j);
  3544 + if (childTaskPlan.getCcId() == null) {
  3545 + if (childTaskPlan.isDestroy()) {
  3546 + s.setFcsjActual("");
  3547 + s.setZdsjActual("");
  3548 + } else {
  3549 + s.setFcsjActual(childTaskPlan.getStartDate());
  3550 + s.setZdsjActual("");
  3551 + s.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage())));
  3552 + }
  3553 + s.setFcsj(childTaskPlan.getStartDate());
  3554 + s.setZdsj("");
  3555 + s.setQdzName(childTaskPlan.getStartStationName());
  3556 + s.setZdzName(childTaskPlan.getEndStationName());
  3557 + s.setRemarks(childTaskPlan.getRemarks());
  3558 + s.setAdjustExps("子");
  3559 + s.setLpName("");
  3560 + list.add(s);
  3561 + }
  3562 + }
  3563 + }
  3564 + }
  3565 + List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>();
  3566 + List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>();
  3567 + List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>();
  3568 + List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>();
  3569 + if (list.size() > 0) {
  3570 + int a = list.size() % 3;
  3571 + int b = list.size() / 3;
  3572 + int x = 0, y = 0;
  3573 + if (a == 2) {
  3574 + x = b + 1;
  3575 + y = x * 2;
  3576 + } else if (a == 1) {
  3577 + x = b + 1;
  3578 + y = x * 2 - 1;
  3579 + } else {
  3580 + x = b;
  3581 + y = 2 * x;
  3582 +
  3583 + }
  3584 + for (int i = 0; i < list.size(); i++) {
  3585 + ScheduleRealInfo s = list.get(i);
  3586 + if (i + 1 <= x) {
  3587 + xList.add(s);
  3588 + } else if ((i + 1) > x && (i + 1) <= y) {
  3589 + yList.add(s);
  3590 + } else {
  3591 + zList.add(s);
  3592 + }
  3593 + }
  3594 + for (int i = 0; i < x; i++) {
  3595 + newList.add(xList.get(i));
  3596 + if (yList.size() > i) {
  3597 + newList.add(yList.get(i));
  3598 + } else {
  3599 + newList.add(new ScheduleRealInfo());
  3600 + }
  3601 + if (zList.size() > i) {
  3602 + newList.add(zList.get(i));
  3603 + } else {
  3604 + newList.add(new ScheduleRealInfo());
  3605 + }
  3606 +
  3607 + }
  3608 + }
  3609 + /* for (int i = 0; i < newList.size(); i++) {
  3610 + ScheduleRealInfo t1 = newList.get(i);
  3611 + for (int j = 0; j < list.size(); j++) {
  3612 + ScheduleRealInfo t2 = list.get(j);
  3613 + if (t1.getId() == t2.getId()) {
  3614 + t1 = t2;
  3615 + }
  3616 + }
  3617 + }*/
  3618 +
  3619 + for (int i = 0; i < newList.size(); i++) {
  3620 + ScheduleRealInfo t1 = newList.get(i);
  3621 + String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks();
  3622 + if (reamrks1.length() > 4) {
  3623 + t1.setRemarks(reamrks1.substring(0, 4));
  3624 + t1.setRemark(reamrks1);
  3625 + } else {
  3626 + t1.setRemark(reamrks1);
  3627 + }
  3628 + }
  3629 + return newList;
  3630 + }
  3631 +
  3632 + @Override
3304 3633 public List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date) {
3305 3634 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
3306 3635 String lpName = "lpName";
... ... @@ -4658,13 +4987,18 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4658 4987 String xlName = map.get("xlName").toString();
4659 4988 String state = map.get("state").toString();
4660 4989 String type = map.get("type").toString();
4661   -
  4990 + String genre =map.get("genre").toString();
4662 4991 List<Map<String, Object>> dataList2 = new ArrayList<Map<String, Object>>();
4663 4992 List<Map<String, Object>> dataList3 = new ArrayList<Map<String, Object>>();
4664 4993 List<Map<String, Object>> list1 = this.statisticsDaily(line, date, xlName, null);
4665 4994 List<ScheduleRealInfo> list2 = this.queryUserInfo(line, date, state);
4666   - List<ScheduleRealInfo> list3 = this.realScheduleList(line, date);
4667   -
  4995 + List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>();
  4996 + if(genre.equals("qp"))
  4997 + list3=this.realScheduleListQp(line, date);
  4998 + else if(genre.equals("zrw"))
  4999 + list3=this.realScheduleList_zrw(line, date);
  5000 + else
  5001 + list3=this.realScheduleList(line, date);
4668 5002 Map<String, Object> nMap = new HashMap<String, Object>();
4669 5003 nMap.put("date", xlName + date);
4670 5004 nMap.put("jls", list1.get(0).get("jls"));
... ... @@ -4792,7 +5126,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4792 5126 }
4793 5127 }
4794 5128 tempMap.put("zdsjk" + x, zdsjk);
4795   - tempMap.put("zdsjm" + x, zdsjm);
  5129 + tempMap.put("zdsjm" + x, zdsjm.equals("0")?"":zdsjm);
4796 5130 tempMap.put("fcsj" + x, schedule.getFcsj());
4797 5131 String fcsjActural = schedule.getFcsjActual() != null ? schedule.getFcsjActual() : "";
4798 5132 String bcType = schedule.getBcType() != null ? schedule.getBcType() : "";
... ... @@ -4819,7 +5153,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4819 5153 }
4820 5154 }
4821 5155 tempMap.put("fcsjk" + x, fcsjk);
4822   - tempMap.put("fcsjm" + x, fcsjm);
  5156 + tempMap.put("fcsjm" + x, fcsjm.equals("0")?"":fcsjm);
4823 5157 tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : "");
4824 5158  
4825 5159 size++;
... ... @@ -5631,6 +5965,23 @@ class AccountXlbm implements Comparator&lt;Map&lt;String, Object&gt;&gt; {
5631 5965 }
5632 5966 }
5633 5967  
  5968 +class compareLpFcsjType implements Comparator<ScheduleRealInfo> {
  5969 + @Override
  5970 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  5971 + // TODO Auto-generated method stub
  5972 + return (o1.getLpName()+o1.getFcsjT() + o1.getRemark()).compareTo(o2.getLpName()+o2.getFcsjT() + o2.getRemark());
  5973 + }
  5974 +
  5975 +}
  5976 +
  5977 +class compareDirLpFcsjType implements Comparator<ScheduleRealInfo> {
  5978 + @Override
  5979 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  5980 + // TODO Auto-generated method stub
  5981 + return (o1.getXlDir()+o1.getFcsjT() + o1.getRemark()+o1.getLpName()).compareTo(o2.getXlDir()+o2.getFcsjT() + o2.getRemark()+o2.getLpName());
  5982 + }
  5983 +
  5984 +}
5634 5985 class compareFcsjType implements Comparator<ScheduleRealInfo> {
5635 5986 @Override
5636 5987 public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
... ...
src/main/java/com/bsth/service/report/impl/CulateMileageServiceImpl.java
... ... @@ -863,6 +863,8 @@ public class CulateMileageServiceImpl implements CulateMileageService{
863 863 if (sch.isSflj())
864 864 continue;
865 865 cts = sch.getcTasks();
  866 + if(isInOut(sch))
  867 + continue;
866 868 //有子任务
867 869 if (cts != null && cts.size() > 0) {
868 870 for(ChildTaskPlan c : cts){
... ... @@ -881,8 +883,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{
881 883 }
882 884 }
883 885 }
884   - else if(isInOut(sch))
885   - continue;
  886 +
886 887 //主任务烂班
887 888 else if(sch.getStatus() == -1 && !sch.isCcService()){
888 889 if(sch.getAdjustExps().equals(item) ||
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -1825,7 +1825,7 @@ public class ReportServiceImpl implements ReportService{
1825 1825 newMap.put("dz", scheduleRealInfo.getQdzName());
1826 1826 newMap.put("sj", scheduleRealInfo.getFcsj());
1827 1827 newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
1828   - newMap.put("jyqp", scheduleRealInfo.getRealMileage()==null?"":scheduleRealInfo.getRealMileage());
  1828 + newMap.put("jyqp", scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks());
1829 1829 list.add(newMap);
1830 1830 }
1831 1831 // }else{
... ...
src/main/java/com/bsth/service/schedule/CarConfigInfoService.java
1 1 package com.bsth.service.schedule;
2 2  
3 3 import com.bsth.entity.schedule.CarConfigInfo;
  4 +import com.bsth.entity.sys.CompanyAuthority;
4 5 import com.bsth.service.schedule.exception.ScheduleException;
5 6  
  7 +import java.util.List;
  8 +
6 9 /**
7 10 * Created by xu on 16/5/9.
8 11 */
9 12 public interface CarConfigInfoService extends BService<CarConfigInfo, Long> {
  13 + // 判定车辆是否配置在其他线路上
10 14 void validate_cars(CarConfigInfo carConfigInfo) throws ScheduleException;
  15 + // 判定车辆是否配置在其他线路上2
  16 + void validate_cars(Integer xlId, Integer clId) throws ScheduleException;
  17 + // 判定车辆是否配置在当前线路中
  18 + void validate_cars_config(CarConfigInfo carConfigInfo) throws ScheduleException;
  19 + // 判定车辆所属公司和当前用户的所属公司
  20 + void validate_cars_gs(CarConfigInfo carConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException;
  21 + // 判定车辆所属分公司和当前用户的所属分公司
  22 + void validate_cars_fgs(CarConfigInfo carConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException;
11 23 void toggleCancel(Long id) throws ScheduleException;
  24 +
  25 +
12 26 }
... ...
src/main/java/com/bsth/service/schedule/EmployeeConfigInfoService.java
1 1 package com.bsth.service.schedule;
2 2  
3 3 import com.bsth.entity.schedule.EmployeeConfigInfo;
  4 +import com.bsth.entity.sys.CompanyAuthority;
4 5 import com.bsth.service.schedule.exception.ScheduleException;
5 6  
  7 +import java.util.List;
  8 +
6 9 /**
7 10 * Created by xu on 16/5/10.
8 11 */
... ... @@ -13,8 +16,17 @@ public interface EmployeeConfigInfoService extends BService&lt;EmployeeConfigInfo,
13 16 void validate_spy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException;
14 17 // 验证驾驶员是否配置在指定线路
15 18 void validate_jsy_config(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException;
  19 + // 判定驾驶员所属公司和当前用户的所属公司
  20 + void validate_jsy_gs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException;
  21 + // 判定驾驶员所属分公司和当前用户的所属分公司
  22 + void validate_jsy_fgs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException;
16 23 // 验证售票员是否配置在指定线路
17 24 void validate_spy_config(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException;
  25 + // 判定驾驶员所属公司和当前用户的所属公司
  26 + void validate_spy_gs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException;
  27 + // 判定驾驶员所属分公司和当前用户的所属分公司
  28 + void validate_spy_fgs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException;
  29 +
18 30 void toggleCancel(Long id) throws ScheduleException;
19 31 Long getMaxDbbm(Integer xlId);
20 32 }
... ...
src/main/java/com/bsth/service/schedule/SchedulePlanService.java
1 1 package com.bsth.service.schedule;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlan;
4   -import com.bsth.service.schedule.rules.ttinfo2.Result;
  4 +import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult;
  5 +import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result;
5 6  
6 7 import java.util.Date;
7 8  
... ... @@ -26,4 +27,13 @@ public interface SchedulePlanService extends BService&lt;SchedulePlan, Long&gt; {
26 27 * @return
27 28 */
28 29 Result validateTTInfo(Integer xlid, Date from, Date to);
  30 +
  31 + /**
  32 + * 验证规则。
  33 + * @param xlId 线路id
  34 + * @param from 排班计划开始时间
  35 + * @param to 排班计划结束时间
  36 + * @return
  37 + */
  38 + ValidateRuleResult validateRule(Integer xlId, Date from, Date to);
29 39 }
30 40 \ No newline at end of file
... ...
src/main/java/com/bsth/service/schedule/TTInfoDetailService.java
... ... @@ -34,6 +34,14 @@ public interface TTInfoDetailService extends BService&lt;TTInfoDetail, Long&gt; {
34 34 DataToolsFile exportDynamicTTinfo(TTinfoDetailDynamicData.DTInfos dtInfos, DataToolsFileType type) throws ScheduleException;
35 35  
36 36 /**
  37 + * 导出班次发车间隔信息。
  38 + * @param lineHeadWayInfo
  39 + * @return
  40 + * @throws ScheduleException
  41 + */
  42 + DataToolsFile exportHeadwayTTinfo(TTinfoDetailDynamicData.LineHeadWayInfo lineHeadWayInfo) throws ScheduleException;
  43 +
  44 + /**
37 45 * 获取时刻表最大发车顺序号
38 46 * @param xlid 线路id
39 47 * @param ttinfoid 时刻表id
... ...
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
... ... @@ -454,6 +454,19 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
454 454  
455 455 StationRoute station1 = stationRouteService.findById(lpObjList.get(0).getStationRouteId1());
456 456 StationRoute station2 = stationRouteService.findById(lpObjList.get(1).getStationRouteId2());
  457 +
  458 + // TODO
  459 + Map<String, Object> param = new HashMap<>();
  460 + param.put("station.id_eq", null);
  461 + if (station1 == null) {
  462 + param.put("station.id_eq", lpObjList.get(0).getStationRouteId1());
  463 + station1 = ((List<StationRoute>) stationRouteService.list(param)).get(0);
  464 + }
  465 + if (station2 == null) {
  466 + param.put("station.id_eq", lpObjList.get(0).getStationRouteId2());
  467 + station2 = ((List<StationRoute>) stationRouteService.list(param)).get(0);
  468 + }
  469 +
457 470 for (int i = 0; i < groupCount; i++) {
458 471 excelPoiOperator.createStringCell(wb, lpHeadRow, (short) (i * 2 + 1), station1.getStationName(), new Color(0x96b9d7));
459 472 excelPoiOperator.createStringCell(wb, lpHeadRow, (short) (i * 2 + 2), station2.getStationName(), new Color(0x96b9d7));
... ... @@ -566,6 +579,19 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
566 579  
567 580 StationRoute station1 = stationRouteService.findById(lpObjList.get(0).getStationRouteId1());
568 581 StationRoute station2 = stationRouteService.findById(lpObjList.get(1).getStationRouteId2());
  582 +
  583 + // TODO
  584 + Map<String, Object> param = new HashMap<>();
  585 + param.put("station.id_eq", null);
  586 + if (station1 == null) {
  587 + param.put("station.id_eq", lpObjList.get(0).getStationRouteId1());
  588 + station1 = ((List<StationRoute>) stationRouteService.list(param)).get(0);
  589 + }
  590 + if (station2 == null) {
  591 + param.put("station.id_eq", lpObjList.get(0).getStationRouteId2());
  592 + station2 = ((List<StationRoute>) stationRouteService.list(param)).get(0);
  593 + }
  594 +
569 595 for (int i = 1; i <= groupCount; i++) {
570 596 excelPoiOperator.createStringCell(wb, lpHeadRow, (short) (i * 2 + 1), station1.getStationName(), new Color(0x96b9d7));
571 597 excelPoiOperator.createStringCell(wb, lpHeadRow, (short) (i * 2 + 2), station2.getStationName(), new Color(0x96b9d7));
... ... @@ -644,7 +670,9 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
644 670 cell.setCellValue(bcObj.getFcsj() + "X");
645 671 } else { // 一个车次链
646 672 cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3));
647   - cell.setCellValue(bcObj.getFcsj() + "X");
  673 + if (cell != null) {
  674 + cell.setCellValue(bcObj.getFcsj() + "X");
  675 + }
648 676 }
649 677 break;
650 678 case LC:
... ... @@ -772,4 +800,82 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
772 800 }
773 801  
774 802 }
  803 +
  804 + @Override
  805 + public DataToolsFile exportHeadwayTTinfo(LineHeadWayInfo lineHeadWayInfo) throws ScheduleException {
  806 + try {
  807 + // 输出2007版本
  808 + ExcelPoiOperator excelPoiOperator = new Excel2007PoiOperator();
  809 +
  810 + // 使用POI,创建xlsx文件
  811 + org.apache.poi.ss.usermodel.Workbook wb = excelPoiOperator.createWorkBook();
  812 + // 一个sheet写上下行间隔信息
  813 + org.apache.poi.ss.usermodel.Sheet sheet = excelPoiOperator.createWorkBookSheet(wb, "时刻表发车间隔信息_统计");
  814 +
  815 + // 构建第一行数据
  816 + Row lpHeadRow = excelPoiOperator.createSheetRow(sheet, 0);
  817 + // 构建上行发车间隔表头
  818 + excelPoiOperator.createStringCell(wb, lpHeadRow, (short) 0, "路牌", new Color(0x96b9d7));
  819 + excelPoiOperator.createStringCell(wb, lpHeadRow, (short) 1, "发车时间", new Color(0x96b9d7));
  820 + excelPoiOperator.createStringCell(wb, lpHeadRow, (short) 2, "发车间隔", new Color(0x96b9d7));
  821 + // 构造下行发车间隔表头
  822 + excelPoiOperator.createStringCell(wb, lpHeadRow, (short) 6, "路牌", new Color(0x96b9d7));
  823 + excelPoiOperator.createStringCell(wb, lpHeadRow, (short) 7, "发车时间", new Color(0x96b9d7));
  824 + excelPoiOperator.createStringCell(wb, lpHeadRow, (short) 8, "发车间隔", new Color(0x96b9d7));
  825 +
  826 + // 构造行
  827 + int maxRow = Math.max(lineHeadWayInfo.getUpBcList().size(), lineHeadWayInfo.getDownBcList().size());
  828 + List<Row> rowList = new ArrayList<>();
  829 + for (int i = 1; i <= maxRow; i++) {
  830 + Row row = excelPoiOperator.createSheetRow(sheet, i);
  831 + rowList.add(row);
  832 + }
  833 +
  834 + // 构造上行发车间隔信息
  835 + for (int i = 0; i < lineHeadWayInfo.getUpBcList().size(); i++) {
  836 + BcHeadWayInfo bcHeadWayInfo = lineHeadWayInfo.getUpBcList().get(i);
  837 + excelPoiOperator.createStringCell(wb, rowList.get(i), (short) 0, bcHeadWayInfo.getLpName());
  838 + excelPoiOperator.createStringCell(wb, rowList.get(i), (short) 1, bcHeadWayInfo.getFcsj());
  839 + excelPoiOperator.createStringCell(wb, rowList.get(i), (short) 2, bcHeadWayInfo.getHeadway());
  840 + }
  841 + // 构造下行发车间隔信息
  842 + for (int i = 0; i < lineHeadWayInfo.getDownBcList().size(); i++) {
  843 + BcHeadWayInfo bcHeadWayInfo = lineHeadWayInfo.getDownBcList().get(i);
  844 + excelPoiOperator.createStringCell(wb, rowList.get(i), (short) 6, bcHeadWayInfo.getLpName());
  845 + excelPoiOperator.createStringCell(wb, rowList.get(i), (short) 7, bcHeadWayInfo.getFcsj());
  846 + excelPoiOperator.createStringCell(wb, rowList.get(i), (short) 8, bcHeadWayInfo.getHeadway());
  847 + }
  848 +
  849 + // 自适应单元格长宽
  850 + sheet.autoSizeColumn(0);
  851 + sheet.autoSizeColumn(1);
  852 + sheet.autoSizeColumn(2);
  853 + sheet.autoSizeColumn(6);
  854 + sheet.autoSizeColumn(7);
  855 + sheet.autoSizeColumn(8);
  856 +
  857 + // wb内存写入文件
  858 + String filepath = dataToolsProperties.getFileoutputDir() +
  859 + File.separator +
  860 + "动态时刻表发车间隔信息-" +
  861 + new DateTime().toString("yyyyMMddHHmmss") + ".xlsx";
  862 + File file = new File(filepath);
  863 + excelPoiOperator.writeExcel(file, wb);
  864 +
  865 + DataToolsFile dataToolsFile = new DataToolsFile();
  866 + dataToolsFile.setFileType(DataToolsFileType.XLSX);
  867 + dataToolsFile.setFile(file);
  868 +
  869 + return dataToolsFile;
  870 +
  871 + } catch (Exception exp) {
  872 + LOGGER.info("//---------------- 动态时刻表发车间隔信息输出 failed... ----------------//");
  873 +
  874 + StringWriter sw = new StringWriter();
  875 + exp.printStackTrace(new PrintWriter(sw));
  876 + LOGGER.info(sw.toString());
  877 +
  878 + throw new ScheduleException(exp);
  879 + }
  880 + }
775 881 }
... ...
src/main/java/com/bsth/service/schedule/datatools/TTinfoDetailDynamicData.java
... ... @@ -400,6 +400,62 @@ public interface TTinfoDetailDynamicData {
400 400 }
401 401 }
402 402  
  403 + class BcHeadWayInfo { // 班次发车间隔信息
  404 + /** 路牌名字 */
  405 + private String lpName;
  406 + /** 发车时间 */
  407 + private String fcsj;
  408 + /** 发车间隔 */
  409 + private String headway;
  410 +
  411 + public String getLpName() {
  412 + return lpName;
  413 + }
  414 +
  415 + public void setLpName(String lpName) {
  416 + this.lpName = lpName;
  417 + }
  418 +
  419 + public String getFcsj() {
  420 + return fcsj;
  421 + }
  422 +
  423 + public void setFcsj(String fcsj) {
  424 + this.fcsj = fcsj;
  425 + }
  426 +
  427 + public String getHeadway() {
  428 + return headway;
  429 + }
  430 +
  431 + public void setHeadway(String headway) {
  432 + this.headway = headway;
  433 + }
  434 + }
  435 +
  436 + class LineHeadWayInfo { // 线路发车间隔信息
  437 + /** 上行班次发车间隔信息 */
  438 + private List<BcHeadWayInfo> upBcList;
  439 + /** 下行班次发车间隔信息 */
  440 + private List<BcHeadWayInfo> downBcList;
  441 +
  442 + public List<BcHeadWayInfo> getUpBcList() {
  443 + return upBcList;
  444 + }
  445 +
  446 + public void setUpBcList(List<BcHeadWayInfo> upBcList) {
  447 + this.upBcList = upBcList;
  448 + }
  449 +
  450 + public List<BcHeadWayInfo> getDownBcList() {
  451 + return downBcList;
  452 + }
  453 +
  454 + public void setDownBcList(List<BcHeadWayInfo> downBcList) {
  455 + this.downBcList = downBcList;
  456 + }
  457 + }
  458 +
403 459 //---------------------- 生成时刻表用对象(以上) ---------------------//
404 460  
405 461 /**
... ... @@ -409,4 +465,12 @@ public interface TTinfoDetailDynamicData {
409 465 * @throws ScheduleException
410 466 */
411 467 DataToolsFile exportDynamicTTinfo(DTInfos dtInfos, DataToolsFileType type) throws ScheduleException;
  468 +
  469 + /**
  470 + * 导出班次发车间隔信息。
  471 + * @param lineHeadWayInfo
  472 + * @return
  473 + * @throws ScheduleException
  474 + */
  475 + DataToolsFile exportHeadwayTTinfo(LineHeadWayInfo lineHeadWayInfo) throws ScheduleException;
412 476 }
... ...
src/main/java/com/bsth/service/schedule/impl/CarConfigInfoServiceImpl.java
1 1 package com.bsth.service.schedule.impl;
2 2  
  3 +import com.bsth.entity.Cars;
3 4 import com.bsth.entity.schedule.CarConfigInfo;
4 5 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  6 +import com.bsth.entity.sys.CompanyAuthority;
5 7 import com.bsth.service.schedule.CarConfigInfoService;
  8 +import com.bsth.service.schedule.CarsService;
6 9 import com.bsth.service.schedule.ScheduleRule1FlatService;
7 10 import com.bsth.service.schedule.exception.ScheduleException;
8 11 import com.bsth.service.schedule.utils.DataToolsFile;
... ... @@ -25,6 +28,8 @@ import java.util.Map;
25 28 public class CarConfigInfoServiceImpl extends BServiceImpl<CarConfigInfo, Long> implements CarConfigInfoService {
26 29 @Autowired
27 30 private ScheduleRule1FlatService scheduleRule1FlatService;
  31 + @Autowired
  32 + private CarsService carsService;
28 33  
29 34 @Autowired
30 35 @Qualifier(value = "carConfig_dataTool")
... ... @@ -45,6 +50,57 @@ public class CarConfigInfoServiceImpl extends BServiceImpl&lt;CarConfigInfo, Long&gt;
45 50 return dataToolsService.exportData(params);
46 51 }
47 52  
  53 + @Override
  54 + public void validate_cars_gs(CarConfigInfo carConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException {
  55 + if (CollectionUtils.isEmpty(companyAuthorityList)) {
  56 + throw new ScheduleException("当前用户没有公司权限!");
  57 + }
  58 +
  59 + boolean isFind = false;
  60 + Cars cars = carsService.findById(carConfigInfo.getCl().getId());
  61 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  62 + if (companyAuthority.getCompanyCode().equals(cars.getBusinessCode())) {
  63 + isFind = true;
  64 + break;
  65 + }
  66 + }
  67 + if (!isFind) {
  68 + throw new ScheduleException("当前车辆不在用户所属公司中!");
  69 + }
  70 + }
  71 +
  72 + @Override
  73 + public void validate_cars_fgs(CarConfigInfo carConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException {
  74 + if (CollectionUtils.isEmpty(companyAuthorityList)) {
  75 + throw new ScheduleException("当前用户没有分公司权限!");
  76 + }
  77 +
  78 + boolean isFind = false;
  79 + Cars cars = carsService.findById(carConfigInfo.getCl().getId());
  80 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  81 + if (companyAuthority.getCompanyCode().equals(cars.getBusinessCode())) {
  82 + isFind = true;
  83 + break;
  84 + }
  85 + }
  86 + if (!isFind) {
  87 + // 如果没有公司权限,验证通过
  88 + return;
  89 + }
  90 +
  91 + isFind = false;
  92 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  93 + if (companyAuthority.getCompanyCode().equals(cars.getBusinessCode()) &&
  94 + companyAuthority.getSubCompanyCode().equals(cars.getBrancheCompanyCode())) {
  95 + isFind = true;
  96 + break;
  97 + }
  98 + }
  99 + if (!isFind) {
  100 + throw new ScheduleException("当前车辆不在用户所属分公司中!");
  101 + }
  102 + }
  103 +
48 104 @Transactional
49 105 public void validate_cars(CarConfigInfo carConfigInfo) throws ScheduleException {
50 106 // 相同车辆不能同时配置
... ... @@ -73,6 +129,29 @@ public class CarConfigInfoServiceImpl extends BServiceImpl&lt;CarConfigInfo, Long&gt;
73 129  
74 130 }
75 131  
  132 + @Override
  133 + public void validate_cars(Integer xlId, Integer clId) throws ScheduleException {
  134 + Map<String, Object> param = new HashMap<>();
  135 + param.put("cl.id_eq", clId);
  136 + List<CarConfigInfo> carConfigInfos = list(param);
  137 + for (CarConfigInfo carConfigInfo : carConfigInfos) {
  138 + if (!carConfigInfo.getXl().getId().equals(xlId)) {
  139 + throw new ScheduleException("车辆不配置在当前线路下,配置在" + carConfigInfo.getXl().getName() + "线路中!");
  140 + }
  141 + }
  142 + }
  143 +
  144 + @Override
  145 + public void validate_cars_config(CarConfigInfo carConfigInfo) throws ScheduleException {
  146 + Map<String, Object> param = new HashMap<>();
  147 + param.put("xl.id_eq", carConfigInfo.getXl().getId());
  148 + param.put("cl.id_eq", carConfigInfo.getCl().getId());
  149 + List<CarConfigInfo> carConfigInfos = list(param);
  150 + if (CollectionUtils.isEmpty(carConfigInfos)) {
  151 + throw new ScheduleException("当前车辆没有配置在当前线路中,不属于当前线路!");
  152 + }
  153 + }
  154 +
76 155 @Transactional
77 156 @Override
78 157 public void delete(Long aLong) throws ScheduleException {
... ...
src/main/java/com/bsth/service/schedule/impl/CarDeviceServiceImpl.java
... ... @@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Propagation;
12 12 import org.springframework.transaction.annotation.Transactional;
13 13 import org.springframework.util.CollectionUtils;
14 14  
  15 +import java.util.Date;
15 16 import java.util.HashMap;
16 17 import java.util.Map;
17 18  
... ... @@ -29,6 +30,8 @@ public class CarDeviceServiceImpl extends BServiceImpl&lt;CarDevice, Long&gt; implemen
29 30 // 查找对应的车辆基础信息,更新设备编号数据
30 31 Cars cars = carsService.findById(carDevice.getCl());
31 32 cars.setEquipmentCode(carDevice.getNewDeviceNo());
  33 + // 设备启用日期使用后台日期
  34 + carDevice.setQyrq(new Date());
32 35 return super.save(carDevice);
33 36 }
34 37  
... ...
src/main/java/com/bsth/service/schedule/impl/CarsServiceImpl.java
1 1 package com.bsth.service.schedule.impl;
2 2  
  3 +import com.bsth.entity.CarDevice;
3 4 import com.bsth.entity.Cars;
  5 +import com.bsth.entity.schedule.CarConfigInfo;
  6 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  7 +import com.bsth.service.schedule.CarDeviceService;
4 8 import com.bsth.service.schedule.CarsService;
5 9 import com.bsth.service.schedule.exception.ScheduleException;
6 10 import com.bsth.service.schedule.utils.DataToolsFile;
... ... @@ -12,7 +16,9 @@ import org.springframework.transaction.annotation.Transactional;
12 16 import org.springframework.util.CollectionUtils;
13 17  
14 18 import java.io.File;
  19 +import java.util.Date;
15 20 import java.util.HashMap;
  21 +import java.util.List;
16 22 import java.util.Map;
17 23  
18 24 /**
... ... @@ -24,6 +30,48 @@ public class CarsServiceImpl extends BServiceImpl&lt;Cars, Integer&gt; implements Cars
24 30 @Qualifier(value = "cars_dataTool")
25 31 private DataToolsService dataToolsService;
26 32  
  33 + @Autowired
  34 + @Qualifier(value = "carDeviceServiceImpl_sc")
  35 + private CarDeviceService carDeviceService;
  36 +
  37 + @Autowired
  38 + private CarConfigInfoRepository carConfigInfoRepository;
  39 +
  40 + @Override
  41 + public Cars save(Cars cars) {
  42 + if (cars.getId() != null && cars.getScrapState()) { // 更新车辆信息,报废车辆
  43 + // 1、作废的车辆,修改报废号
  44 + String eCode = cars.getEquipmentCode();
  45 + cars.setEquipmentCode("BF-" + eCode);
  46 + cars.setScrapCode("BF-" + cars.getEquipmentCode());
  47 + // 2、添加一条相关的设备替换记录
  48 + // 查找在哪条线路上
  49 + List<CarConfigInfo> carConfigInfoList = carConfigInfoRepository.findByClId(cars.getId());
  50 + for (CarConfigInfo carConfigInfo : carConfigInfoList) {
  51 + CarDevice carDevice = new CarDevice();
  52 + carDevice.setGsName(cars.getCompany());
  53 + carDevice.setCompany(cars.getBusinessCode());
  54 + carDevice.setBrancheCompany(cars.getBrancheCompanyCode());
  55 + carDevice.setCl(cars.getId());
  56 + carDevice.setClZbh(cars.getInsideCode());
  57 + carDevice.setXl(carConfigInfo.getXl().getId());
  58 + carDevice.setXlName(carConfigInfo.getXl().getName());
  59 + carDevice.setXlBm(carConfigInfo.getXl().getLineCode());
  60 + carDevice.setOldDeviceNo(eCode);
  61 + carDevice.setNewDeviceNo("BF-" + eCode);
  62 + carDevice.setIsCancel(false);
  63 +
  64 + carDevice.setCreateBy(cars.getCreateBy());
  65 + carDevice.setUpdateBy(cars.getUpdateBy());
  66 + carDevice.setCreateDate(new Date());
  67 + carDevice.setUpdateDate(new Date());
  68 + carDeviceService.save(carDevice);
  69 + }
  70 + }
  71 +
  72 + return super.save(cars);
  73 + }
  74 +
27 75 @Override
28 76 public void importData(File file, Map<String, Object> params) throws ScheduleException {
29 77 dataToolsService.importData(file, params);
... ...
src/main/java/com/bsth/service/schedule/impl/EmployeeConfigInfoServiceImpl.java
1 1 package com.bsth.service.schedule.impl;
2 2  
  3 +import com.bsth.entity.Personnel;
3 4 import com.bsth.entity.schedule.EmployeeConfigInfo;
4 5 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  6 +import com.bsth.entity.sys.CompanyAuthority;
5 7 import com.bsth.service.schedule.EmployeeConfigInfoService;
  8 +import com.bsth.service.schedule.EmployeeService;
6 9 import com.bsth.service.schedule.ScheduleRule1FlatService;
7 10 import com.bsth.service.schedule.exception.ScheduleException;
8 11 import com.bsth.service.schedule.utils.DataToolsFile;
... ... @@ -28,6 +31,8 @@ import java.util.*;
28 31 public class EmployeeConfigInfoServiceImpl extends BServiceImpl<EmployeeConfigInfo, Long> implements EmployeeConfigInfoService {
29 32 @Autowired
30 33 private ScheduleRule1FlatService scheduleRule1FlatService;
  34 + @Autowired
  35 + private EmployeeService employeeService;
31 36  
32 37 @Autowired
33 38 @Qualifier(value = "employeeConfig_dataTool")
... ... @@ -110,6 +115,57 @@ public class EmployeeConfigInfoServiceImpl extends BServiceImpl&lt;EmployeeConfigIn
110 115 }
111 116 }
112 117  
  118 + @Override
  119 + public void validate_jsy_gs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException {
  120 + if (CollectionUtils.isEmpty(companyAuthorityList)) {
  121 + throw new ScheduleException("当前用户没有公司权限!");
  122 + }
  123 +
  124 + boolean isFind = false;
  125 + Personnel personnel = employeeService.findById(employeeConfigInfo.getJsy().getId());
  126 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  127 + if (companyAuthority.getCompanyCode().equals(personnel.getCompanyCode())) {
  128 + isFind = true;
  129 + break;
  130 + }
  131 + }
  132 + if (!isFind) {
  133 + throw new ScheduleException("当前驾驶员不在用户所属公司中!");
  134 + }
  135 + }
  136 +
  137 + @Override
  138 + public void validate_jsy_fgs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException {
  139 + if (CollectionUtils.isEmpty(companyAuthorityList)) {
  140 + throw new ScheduleException("当前用户没有分公司权限!");
  141 + }
  142 +
  143 + boolean isFind = false;
  144 + Personnel personnel = employeeService.findById(employeeConfigInfo.getJsy().getId());
  145 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  146 + if (companyAuthority.getCompanyCode().equals(personnel.getCompanyCode())) {
  147 + isFind = true;
  148 + break;
  149 + }
  150 + }
  151 + if (!isFind) {
  152 + // 如果没有公司权限,验证通过
  153 + return;
  154 + }
  155 +
  156 + isFind = false;
  157 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  158 + if (companyAuthority.getCompanyCode().equals(personnel.getCompanyCode()) &&
  159 + companyAuthority.getSubCompanyCode().equals(personnel.getBrancheCompanyCode())) {
  160 + isFind = true;
  161 + break;
  162 + }
  163 + }
  164 + if (!isFind) {
  165 + throw new ScheduleException("当前驾驶员不在用户所属分公司中!");
  166 + }
  167 + }
  168 +
113 169 @Transactional
114 170 @Override
115 171 public void validate_spy(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException {
... ... @@ -137,6 +193,57 @@ public class EmployeeConfigInfoServiceImpl extends BServiceImpl&lt;EmployeeConfigIn
137 193 }
138 194 }
139 195  
  196 + @Override
  197 + public void validate_spy_gs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException {
  198 + if (CollectionUtils.isEmpty(companyAuthorityList)) {
  199 + throw new ScheduleException("当前用户没有公司权限!");
  200 + }
  201 +
  202 + boolean isFind = false;
  203 + Personnel personnel = employeeService.findById(employeeConfigInfo.getSpy().getId());
  204 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  205 + if (companyAuthority.getCompanyCode().equals(personnel.getCompanyCode())) {
  206 + isFind = true;
  207 + break;
  208 + }
  209 + }
  210 + if (!isFind) {
  211 + throw new ScheduleException("当前售票员不在用户所属公司中!");
  212 + }
  213 + }
  214 +
  215 + @Override
  216 + public void validate_spy_fgs(EmployeeConfigInfo employeeConfigInfo, List<CompanyAuthority> companyAuthorityList) throws ScheduleException {
  217 + if (CollectionUtils.isEmpty(companyAuthorityList)) {
  218 + throw new ScheduleException("当前用户没有分公司权限!");
  219 + }
  220 +
  221 + boolean isFind = false;
  222 + Personnel personnel = employeeService.findById(employeeConfigInfo.getSpy().getId());
  223 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  224 + if (companyAuthority.getCompanyCode().equals(personnel.getCompanyCode())) {
  225 + isFind = true;
  226 + break;
  227 + }
  228 + }
  229 + if (!isFind) {
  230 + // 如果没有公司权限,验证通过
  231 + return;
  232 + }
  233 +
  234 + isFind = false;
  235 + for (CompanyAuthority companyAuthority : companyAuthorityList) {
  236 + if (companyAuthority.getCompanyCode().equals(personnel.getCompanyCode()) &&
  237 + companyAuthority.getSubCompanyCode().equals(personnel.getBrancheCompanyCode())) {
  238 + isFind = true;
  239 + break;
  240 + }
  241 + }
  242 + if (!isFind) {
  243 + throw new ScheduleException("当前售票员不在用户所属分公司中!");
  244 + }
  245 + }
  246 +
140 247 @Transactional
141 248 @Override
142 249 public void validate_spy_config(EmployeeConfigInfo employeeConfigInfo) throws ScheduleException {
... ...
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
1 1 package com.bsth.service.schedule.impl;
2 2  
  3 +import com.bsth.entity.Line;
3 4 import com.bsth.entity.schedule.SchedulePlan;
4 5 import com.bsth.entity.schedule.TTInfo;
5 6 import com.bsth.repository.BusinessRepository;
... ... @@ -7,10 +8,11 @@ import com.bsth.repository.LineRepository;
7 8 import com.bsth.repository.schedule.*;
8 9 import com.bsth.service.schedule.SchedulePlanService;
9 10 import com.bsth.service.schedule.exception.ScheduleException;
10   -import com.bsth.service.schedule.plan.DroolsSchedulePlan;
11   -import com.bsth.service.schedule.rules.ScheduleRuleService;
12   -import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
13   -import com.bsth.service.schedule.rules.ttinfo2.Result;
  11 +import com.bsth.service.schedule.impl.plan.DroolsSchedulePlan;
  12 +import com.bsth.service.schedule.impl.plan.ScheduleRuleService;
  13 +import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult;
  14 +import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.CalcuParam;
  15 +import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result;
14 16 import org.joda.time.DateTime;
15 17 import org.kie.api.KieBase;
16 18 import org.kie.api.runtime.KieSession;
... ... @@ -42,6 +44,10 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
42 44 private KieBase preKBase;
43 45  
44 46 @Autowired
  47 + @Qualifier("KBase3")
  48 + private KieBase validateKBase;
  49 +
  50 + @Autowired
45 51 private ScheduleRule1FlatRepository scheduleRule1FlatRepository;
46 52 @Autowired
47 53 private TTInfoRepository ttInfoRepository;
... ... @@ -52,6 +58,8 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
52 58 @Autowired
53 59 private CarConfigInfoRepository carConfigInfoRepository;
54 60 @Autowired
  61 + private GuideboardInfoRepository guideboardInfoRepository;
  62 + @Autowired
55 63 private EmployeeConfigInfoRepository employeeConfigInfoRepository;
56 64 @Autowired
57 65 private BusinessRepository businessRepository;
... ... @@ -146,22 +154,25 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
146 154 public Result validateTTInfo(Integer xlid, Date from, Date to) {
147 155 // 构造drools session->载入数据->启动规则->计算->销毁session
148 156 // 创建session,内部配置的是stateful
149   - KieSession session = coreKBase.newKieSession();
  157 + KieSession session = validateKBase.newKieSession();
150 158 // 设置gloable对象,在drl中通过别名使用
151 159 session.setGlobal("log", logger);
152   - session.setGlobal("lineRepository", lineRepository);
153 160 session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
154 161  
155 162 Result rs = new Result(); // 输出gloable对象
156 163 session.setGlobal("rs", rs);
157 164  
158 165 // 载入数据
  166 + Line line = lineRepository.findOne(xlid);
  167 + session.insert(line);
  168 +
159 169 CalcuParam calcuParam = new CalcuParam(
160 170 new DateTime(from), new DateTime(to), xlid);
161 171 session.insert(calcuParam);
162   - List<TTInfo> ttInfos = (List<TTInfo>) ttInfoRepository.findAll();
163   - for (TTInfo ttInfo: ttInfos)
164   - session.insert(ttInfo);
  172 + List<TTInfo> ttInfos = ttInfoRepository.findByXlId(xlid);
  173 + for (TTInfo ttInfo: ttInfos) {
  174 + session.insert(ttInfo);
  175 + }
165 176  
166 177 // 执行rule
167 178 session.fireAllRules();
... ... @@ -171,4 +182,30 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
171 182  
172 183 return rs;
173 184 }
  185 +
  186 + @Override
  187 + public ValidateRuleResult validateRule(Integer xlId, Date from, Date to) {
  188 + KieSession session = validateKBase.newKieSession();
  189 + session.setGlobal("LOG", logger);
  190 + session.setGlobal("ccRepo", carConfigInfoRepository);
  191 + session.setGlobal("lpRepo", guideboardInfoRepository);
  192 + session.setGlobal("ecRepo", employeeConfigInfoRepository);
  193 + session.setGlobal("ruleRepo", scheduleRule1FlatRepository);
  194 +
  195 + ValidateRuleResult result = new ValidateRuleResult();
  196 + session.setGlobal("result", result);
  197 +
  198 + com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam calcuParam =
  199 + new com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam();
  200 + calcuParam.setXlId(xlId);
  201 + calcuParam.setFromDate(new DateTime(from));
  202 + calcuParam.setToDate(new DateTime(to));
  203 + session.insert(calcuParam);
  204 +
  205 + session.fireAllRules();
  206 +
  207 + session.dispose();;
  208 +
  209 + return result;
  210 + }
174 211 }
... ...
src/main/java/com/bsth/service/schedule/impl/TTInfoDetailServiceImpl.java
... ... @@ -145,6 +145,11 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
145 145 }
146 146  
147 147 @Override
  148 + public DataToolsFile exportHeadwayTTinfo(TTinfoDetailDynamicData.LineHeadWayInfo lineHeadWayInfo) throws ScheduleException {
  149 + return tTinfoDetailDynamicData.exportHeadwayTTinfo(lineHeadWayInfo);
  150 + }
  151 +
  152 + @Override
148 153 public DataToolsFile exportDynamicTTinfo(TTinfoDetailDynamicData.DTInfos dtInfos, DataToolsFileType type) throws ScheduleException {
149 154 return tTinfoDetailDynamicData.exportDynamicTTinfo(dtInfos, type);
150 155 }
... ...
src/main/java/com/bsth/service/schedule/plan/DroolsSchedulePlan.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/DroolsSchedulePlan.java
1   -package com.bsth.service.schedule.plan;
  1 +package com.bsth.service.schedule.impl.plan;
2 2  
3 3 import com.bsth.entity.Line;
4 4 import com.bsth.entity.schedule.SchedulePlan;
... ... @@ -8,17 +8,16 @@ import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
8 8 import com.bsth.repository.BusinessRepository;
9 9 import com.bsth.repository.LineRepository;
10 10 import com.bsth.repository.schedule.*;
11   -import com.bsth.service.schedule.rules.ScheduleRuleService;
12   -import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input;
13   -import com.bsth.service.schedule.rules.plan.PlanResult;
14   -import com.bsth.service.schedule.rules.rerun.RerunRule_input;
15   -import com.bsth.service.schedule.rules.rerun.RerunRule_param;
16   -import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
17   -import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
18   -import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
19   -import com.bsth.service.schedule.rules.ttinfo.*;
20   -import com.bsth.service.schedule.rules.validate.ValidateParam;
21   -import com.bsth.service.schedule.rules.validate.ValidateResults_output;
  11 +import com.bsth.service.schedule.impl.plan.kBase1.core.plan.PlanCalcuParam_input;
  12 +import com.bsth.service.schedule.impl.plan.kBase1.core.plan.PlanResult;
  13 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;
  14 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_param;
  15 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleCalcuParam_input;
  16 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;
  17 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;
  18 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.*;
  19 +import com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidateParam;
  20 +import com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidateResults_output;
22 21 import org.apache.commons.lang3.StringUtils;
23 22 import org.joda.time.DateTime;
24 23 import org.kie.api.KieBase;
... ...
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/MyDroolsConfiguration.java
1   -package com.bsth.service.schedule.rules;
  1 +package com.bsth.service.schedule.impl.plan;
2 2  
3 3 import org.kie.api.KieBase;
4 4 import org.kie.api.KieBaseConfiguration;
... ... @@ -56,27 +56,24 @@ public class MyDroolsConfiguration {
56 56 // 3.2、写入drl(写法超多,有点混乱)
57 57 // 这里使用文件的形式写入,TODO:以后考虑从数据库中读drl写入
58 58 // 注意kfs写的时候如果指定path,强制为src/main/resources/加上文件名,还有就是文件名不要重复否则会覆盖的
59   - kfs.write("src/main/resources/functions.drl", kieServices.getResources()
  59 + kfs.write("src/main/resources/kBase1_core_shiftloop.drl", kieServices.getResources()
60 60 .newInputStreamResource(this.getClass().getResourceAsStream(
61   - "/rules/functions.drl"), "UTF-8"));
62   - kfs.write("src/main/resources/shiftloop_fb_2.drl", kieServices.getResources()
  61 + "/rules/kBase1_core_shiftloop.drl"), "UTF-8"));
  62 + kfs.write("src/main/resources/kBase1_core_ttinfo.drl", kieServices.getResources()
63 63 .newInputStreamResource(this.getClass().getResourceAsStream(
64   - "/rules/shiftloop_fb_2.drl"), "UTF-8"));
65   - kfs.write("src/main/resources/ttinfo.drl", kieServices.getResources()
  64 + "/rules/kBase1_core_ttinfo.drl"), "UTF-8"));
  65 + kfs.write("src/main/resources/kBase1_core_plan.drl", kieServices.getResources()
66 66 .newInputStreamResource(this.getClass().getResourceAsStream(
67   - "/rules/ttinfo.drl"), "UTF-8"));
68   - kfs.write("src/main/resources/ttinfo2.drl", kieServices.getResources()
  67 + "/rules/kBase1_core_plan.drl"), "UTF-8"));
  68 + kfs.write("src/main/resources/kBase1_core_rerun.drl", kieServices.getResources()
69 69 .newInputStreamResource(this.getClass().getResourceAsStream(
70   - "/rules/ttinfo2.drl"), "UTF-8"));
71   - kfs.write("src/main/resources/plan.drl", kieServices.getResources()
  70 + "/rules/kBase1_core_rerun.drl"), "UTF-8"));
  71 + kfs.write("src/main/resources/kBase1_core_validate.drl", kieServices.getResources()
72 72 .newInputStreamResource(this.getClass().getResourceAsStream(
73   - "/rules/plan.drl"), "UTF-8"));
74   - kfs.write("src/main/resources/rerun.drl", kieServices.getResources()
  73 + "/rules/kBase1_core_validate.drl"), "UTF-8"));
  74 + kfs.write("src/main/resources/kBase1_core_functions.drl", kieServices.getResources()
75 75 .newInputStreamResource(this.getClass().getResourceAsStream(
76   - "/rules/rerun.drl"), "UTF-8"));
77   - kfs.write("src/main/resources/validplan.drl", kieServices.getResources()
78   - .newInputStreamResource(this.getClass().getResourceAsStream(
79   - "/rules/validplan.drl"), "UTF-8"));
  76 + "/rules/kBase1_core_functions.drl"), "UTF-8"));
80 77 // TODO:还有其他drl....
81 78  
82 79 // 4、创建KieBuilder,使用KieFileSystem构建
... ... @@ -134,9 +131,9 @@ public class MyDroolsConfiguration {
134 131 // 这里使用文件的形式写入,TODO:以后考虑从数据库中读drl写入
135 132 // 注意kfs写的时候如果指定path,强制为src/main/resources/加上文件名,还有就是文件名不要重复否则会覆盖的
136 133  
137   - kfs.write("src/main/resources/ruleWrap.drl", kieServices.getResources()
  134 + kfs.write("src/main/resources/kBase2_wrap_rule.drl", kieServices.getResources()
138 135 .newInputStreamResource(this.getClass().getResourceAsStream(
139   - "/rules/ruleWrap.drl"), "UTF-8"));
  136 + "/rules/kBase2_wrap_rule.drl"), "UTF-8"));
140 137  
141 138 // TODO:还有其他drl....
142 139  
... ... @@ -161,4 +158,52 @@ public class MyDroolsConfiguration {
161 158  
162 159 return kieBase;
163 160 }
  161 +
  162 + /**
  163 + * 验证相关的drl知识库。
  164 + * @return
  165 + */
  166 + @Bean(name = "KBase3")
  167 + public KieBase myKieBase3() {
  168 + KieServices kieServices = KieServices.Factory.get();
  169 + KieModuleModel kieModuleModel = kieServices.newKieModuleModel();
  170 + KieBaseModel kieBaseModel = kieModuleModel.newKieBaseModel("KBase3")
  171 + .setDefault(true)
  172 + .setEqualsBehavior(EqualityBehaviorOption.EQUALITY)
  173 + .setEventProcessingMode(EventProcessingOption.STREAM);
  174 + kieBaseModel.newKieSessionModel("KSession1")
  175 + .setDefault(true)
  176 + .setType(KieSessionModel.KieSessionType.STATEFUL)
  177 + .setClockType(ClockTypeOption.get("realtime"));
  178 +
  179 + KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
  180 + kieFileSystem.writeKModuleXML(kieModuleModel.toXML());
  181 +
  182 + kieFileSystem.write(
  183 + "src/main/resources/kBase3_validate_timetable.drl",
  184 + kieServices.getResources().newInputStreamResource(
  185 + this.getClass().getResourceAsStream("/rules/kBase3_validate_timetable.drl"),
  186 + "UTF-8"));
  187 + kieFileSystem.write(
  188 + "src/main/resources/kbase3_validate_rule.drl",
  189 + kieServices.getResources().newInputStreamResource(
  190 + this.getClass().getResourceAsStream("/rules/kBase3_validate_rule.drl"),
  191 + "UTF-8"));
  192 +
  193 + KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem).buildAll();
  194 + Results results = kieBuilder.getResults();
  195 + if (results.hasMessages(Message.Level.ERROR)) {
  196 + throw new IllegalStateException("构建drools6错误:" + results.getMessages());
  197 + }
  198 +
  199 + ReleaseId releaseId = kieServices.getRepository().getDefaultReleaseId();
  200 + KieContainer kieContainer = kieServices.newKieContainer(releaseId);
  201 +
  202 + KieBaseConfiguration kieBaseConfiguration = kieServices.newKieBaseConfiguration();
  203 + KieBase kieBase = kieContainer.newKieBase("KBase3", kieBaseConfiguration);
  204 +
  205 + return kieBase;
  206 +
  207 + }
  208 +
164 209 }
... ...
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleService.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/ScheduleRuleService.java
1   -package com.bsth.service.schedule.rules;
  1 +package com.bsth.service.schedule.impl.plan;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlan;
4 4 import com.bsth.entity.schedule.SchedulePlanInfo;
5 5 import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
6   -import com.bsth.service.schedule.rules.rerun.RerunRule_input;
  6 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;
7 7  
8 8 import java.util.Date;
9 9 import java.util.List;
... ...
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleServiceImpl.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/ScheduleRuleServiceImpl.java
1   -package com.bsth.service.schedule.rules;
  1 +package com.bsth.service.schedule.impl.plan;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlan;
4 4 import com.bsth.entity.schedule.SchedulePlanInfo;
5 5 import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
6   -import com.bsth.service.schedule.rules.rerun.RerunRule_input;
  6 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;
7 7 import org.slf4j.Logger;
8 8 import org.slf4j.LoggerFactory;
9 9 import org.springframework.beans.factory.annotation.Autowired;
... ...
src/main/java/com/bsth/service/schedule/rules/plan/PlanCalcuParam_input.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/plan/PlanCalcuParam_input.java
1   -package com.bsth.service.schedule.rules.plan;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.plan;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlan;
4   -import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
5   -import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output;
  4 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;
  5 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResults_output;
6 6  
7 7 /**
8 8 * 排班规则-规则输入参数。
... ...
src/main/java/com/bsth/service/schedule/rules/plan/PlanResult.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/plan/PlanResult.java
1   -package com.bsth.service.schedule.rules.plan;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.plan;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlanInfo;
4 4  
... ...
src/main/java/com/bsth/service/schedule/rules/plan/readme.txt renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/plan/readme.txt
src/main/java/com/bsth/service/schedule/rules/rerun/RerunRule_input.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/rerun/RerunRule_input.java
1   -package com.bsth.service.schedule.rules.rerun;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.rerun;
2 2  
3 3 /**
4 4 * Created by xu on 17/4/26.
... ...
src/main/java/com/bsth/service/schedule/rules/rerun/RerunRule_param.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/rerun/RerunRule_param.java
1   -package com.bsth.service.schedule.rules.rerun;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.rerun;
2 2  
3 3 import java.util.Set;
4 4  
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/GidFbFcnoFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/GidFbFcnoFunction.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 import com.bsth.entity.schedule.TTInfoDetail;
4 4 import org.kie.api.runtime.rule.AccumulateFunction;
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/GidFbTimeFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/GidFbTimeFunction.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 import com.bsth.entity.schedule.TTInfoDetail;
4 4 import org.joda.time.LocalTime;
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/GidsCountFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/GidsCountFunction.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 import com.bsth.entity.schedule.TTInfoDetail;
4 4 import org.kie.api.runtime.rule.AccumulateFunction;
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleCalcuParam_input.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/ScheduleCalcuParam_input.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlan;
4 4 import org.joda.time.DateTime;
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleResult_output.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/ScheduleResult_output.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 import org.joda.time.DateTime;
4 4  
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleResults_output.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/ScheduleResults_output.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
4 4 import org.apache.commons.lang3.StringUtils;
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleRule_Type.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/ScheduleRule_Type.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 /**
4 4 * 排班规则_输入_输出_类型。
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleRule_input.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/shiftloop/ScheduleRule_input.java
1   -package com.bsth.service.schedule.rules.shiftloop;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
2 2  
3 3 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
4 4 import com.google.common.base.Splitter;
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResult_output.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/LpInfoResult_output.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3 3 import org.joda.time.DateTime;
4 4  
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResultsFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/LpInfoResultsFunction.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3 3 import com.bsth.entity.schedule.TTInfoDetail;
4 4 import org.kie.api.runtime.rule.AccumulateFunction;
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResults_output.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/LpInfoResults_output.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3 3 import java.util.ArrayList;
4 4 import java.util.List;
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/MinRuleQyrqFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/MinRuleQyrqFunction.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3   -import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
  3 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;
4 4 import org.joda.time.DateTime;
5 5 import org.kie.api.runtime.rule.AccumulateFunction;
6 6  
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/TTInfoCalcuParam_input.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/TTInfoCalcuParam_input.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3 3 import org.joda.time.DateTime;
4 4  
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/TTInfoResult_output.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/TTInfoResult_output.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3 3 import org.joda.time.DateTime;
4 4  
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/TTInfoResults_output.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/TTInfoResults_output.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3 3 import com.google.common.collect.ArrayListMultimap;
4 4 import com.google.common.collect.Multimap;
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/TTInfo_input.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/TTInfo_input.java
1   -package com.bsth.service.schedule.rules.ttinfo;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
2 2  
3 3 import com.bsth.entity.schedule.TTInfo;
4 4 import org.apache.commons.lang3.StringUtils;
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/readme.txt renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/ttinfo/readme.txt
src/main/java/com/bsth/service/schedule/rules/validate/ValidRepeatBcFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/validate/ValidRepeatBcFunction.java
1   -package com.bsth.service.schedule.rules.validate;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.validate;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlanInfo;
4 4 import org.kie.api.runtime.rule.AccumulateFunction;
... ...
src/main/java/com/bsth/service/schedule/rules/validate/ValidWantLpFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/validate/ValidWantLpFunction.java
1   -package com.bsth.service.schedule.rules.validate;
2   -
3   -import com.bsth.entity.schedule.SchedulePlanInfo;
4   -import com.bsth.service.schedule.rules.ttinfo.LpInfoResult_output;
5   -import org.kie.api.runtime.rule.AccumulateFunction;
6   -
7   -import java.io.*;
8   -import java.text.SimpleDateFormat;
9   -import java.util.*;
10   -
11   -/**
12   - * 计算缺少路牌错误。
13   - * 同一天,如果有时刻表路牌没有执行到,统计。
14   - * 注意:使用这个函数时,要一天计算一次,多天计算无意义。
15   - */
16   -public class ValidWantLpFunction implements AccumulateFunction {
17   - @Override
18   - public void writeExternal(ObjectOutput out) throws IOException {
19   - }
20   -
21   - @Override
22   - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
23   -
24   - }
25   -
26   - protected static class WantLpInfo implements Externalizable {
27   - /** 错误描述 */
28   - public List<ValidateResults_output.ValidInfo> validInfoList = new ArrayList<>();
29   - /** 每天的路牌班次数量 */
30   - public Map<String, Integer> lpBcCount = new HashMap<>();
31   - /** 每天的路牌名字对应 */
32   - public Map<String, String> lpNamesMap = new HashMap<>();
33   - /** 排班日期 */
34   - public Date scheduleDate;
35   -
36   - public WantLpInfo() {
37   -
38   - }
39   -
40   - @Override
41   - public void writeExternal(ObjectOutput out) throws IOException {
42   - out.writeObject(validInfoList);
43   - }
44   -
45   - @Override
46   - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
47   - validInfoList = (List<ValidateResults_output.ValidInfo>) in.readObject();
48   - }
49   - }
50   -
51   - @Override
52   - public Serializable createContext() {
53   - return new WantLpInfo();
54   - }
55   -
56   - @Override
57   - public void init(Serializable serializable) throws Exception {
58   - // TODO:
59   -// System.out.println("init");
60   - }
61   -
62   - @Override
63   - public void accumulate(Serializable context, Object o) {
64   - WantLpInfo wantLpInfo = (WantLpInfo) context;
65   - ValidateResource validateResource = (ValidateResource) o;
66   -
67   - SchedulePlanInfo spi = validateResource.getSpi();
68   - List<LpInfoResult_output> lpiList = validateResource.getLpiList();
69   -
70   - // 获取当天所有路牌信息,每个验证对象都带当天所有路牌信息,只需判定一次
71   - if (wantLpInfo.lpNamesMap.isEmpty()) {
72   - for (LpInfoResult_output lpInfoResult_output: lpiList) {
73   - wantLpInfo.lpNamesMap.put(lpInfoResult_output.getLpId(), lpInfoResult_output.getLpName());
74   - wantLpInfo.lpBcCount.put(lpInfoResult_output.getLpId(), 0);
75   - }
76   - }
77   - if (wantLpInfo.scheduleDate == null) {
78   - wantLpInfo.scheduleDate = spi.getScheduleDate();
79   - }
80   -
81   - // 累计记录每个排班班次出现次数
82   - String lpId_spi = spi.getLp().toString();
83   - wantLpInfo.lpBcCount.put(lpId_spi, wantLpInfo.lpBcCount.get(lpId_spi) + 1);
84   -
85   - }
86   -
87   - @Override
88   - public boolean supportsReverse() {
89   - return true;
90   - }
91   -
92   - @Override
93   - public void reverse(Serializable context, Object o) throws Exception {
94   - WantLpInfo wantLpInfo = (WantLpInfo) context;
95   -
96   - // 清空数据,下一天继续迭代
97   - wantLpInfo.lpBcCount.clear();
98   - wantLpInfo.lpNamesMap.clear();
99   - wantLpInfo.scheduleDate = null;
100   - wantLpInfo.validInfoList.clear();
101   -
102   -// System.out.println("reverse");
103   -
104   - }
105   -
106   - @Override
107   - public Class<?> getResultType() {
108   - return List.class;
109   - }
110   -
111   - @Override
112   - public Object getResult(Serializable context) throws Exception {
113   - WantLpInfo wantLpInfo = (WantLpInfo) context;
114   -
115   - SimpleDateFormat sf = new SimpleDateFormat("yyyy年MM月dd日");
116   - String infoFormat = "日期(%s),路牌(%s),没有排班班次";
117   -
118   - for (String lpId : wantLpInfo.lpBcCount.keySet()) {
119   - if (wantLpInfo.lpBcCount.get(lpId) == 0) {
120   - // 排班没有班次
121   - ValidateResults_output.ValidInfo validInfo = new ValidateResults_output.ValidInfo();
122   - validInfo.setSd(wantLpInfo.scheduleDate);
123   - validInfo.setDesc(String.format(
124   - infoFormat,
125   - sf.format(wantLpInfo.scheduleDate),
126   - wantLpInfo.lpNamesMap.get(lpId))
127   - );
128   - wantLpInfo.validInfoList.add(validInfo);
129   - }
130   - }
131   -
132   - System.out.println("ValidWantLpFunction==>" + wantLpInfo.lpBcCount);
133   -
134   - return wantLpInfo.validInfoList;
135   - }
136   -
137   -}
138   -
139   -
140   -
141   -
142   -
143   -
144   -
145   -
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.validate;
  2 +
  3 +import com.bsth.entity.schedule.SchedulePlanInfo;
  4 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;
  5 +import org.kie.api.runtime.rule.AccumulateFunction;
  6 +
  7 +import java.io.*;
  8 +import java.text.SimpleDateFormat;
  9 +import java.util.*;
  10 +
  11 +/**
  12 + * 计算缺少路牌错误。
  13 + * 同一天,如果有时刻表路牌没有执行到,统计。
  14 + * 注意:使用这个函数时,要一天计算一次,多天计算无意义。
  15 + */
  16 +public class ValidWantLpFunction implements AccumulateFunction {
  17 + @Override
  18 + public void writeExternal(ObjectOutput out) throws IOException {
  19 + }
  20 +
  21 + @Override
  22 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  23 +
  24 + }
  25 +
  26 + protected static class WantLpInfo implements Externalizable {
  27 + /** 错误描述 */
  28 + public List<ValidateResults_output.ValidInfo> validInfoList = new ArrayList<>();
  29 + /** 每天的路牌班次数量 */
  30 + public Map<String, Integer> lpBcCount = new HashMap<>();
  31 + /** 每天的路牌名字对应 */
  32 + public Map<String, String> lpNamesMap = new HashMap<>();
  33 + /** 排班日期 */
  34 + public Date scheduleDate;
  35 +
  36 + public WantLpInfo() {
  37 +
  38 + }
  39 +
  40 + @Override
  41 + public void writeExternal(ObjectOutput out) throws IOException {
  42 + out.writeObject(validInfoList);
  43 + }
  44 +
  45 + @Override
  46 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  47 + validInfoList = (List<ValidateResults_output.ValidInfo>) in.readObject();
  48 + }
  49 + }
  50 +
  51 + @Override
  52 + public Serializable createContext() {
  53 + return new WantLpInfo();
  54 + }
  55 +
  56 + @Override
  57 + public void init(Serializable serializable) throws Exception {
  58 + // TODO:
  59 +// System.out.println("init");
  60 + }
  61 +
  62 + @Override
  63 + public void accumulate(Serializable context, Object o) {
  64 + WantLpInfo wantLpInfo = (WantLpInfo) context;
  65 + ValidateResource validateResource = (ValidateResource) o;
  66 +
  67 + SchedulePlanInfo spi = validateResource.getSpi();
  68 + List<LpInfoResult_output> lpiList = validateResource.getLpiList();
  69 +
  70 + // 获取当天所有路牌信息,每个验证对象都带当天所有路牌信息,只需判定一次
  71 + if (wantLpInfo.lpNamesMap.isEmpty()) {
  72 + for (LpInfoResult_output lpInfoResult_output: lpiList) {
  73 + wantLpInfo.lpNamesMap.put(lpInfoResult_output.getLpId(), lpInfoResult_output.getLpName());
  74 + wantLpInfo.lpBcCount.put(lpInfoResult_output.getLpId(), 0);
  75 + }
  76 + }
  77 + if (wantLpInfo.scheduleDate == null) {
  78 + wantLpInfo.scheduleDate = spi.getScheduleDate();
  79 + }
  80 +
  81 + // 累计记录每个排班班次出现次数
  82 + String lpId_spi = spi.getLp().toString();
  83 + wantLpInfo.lpBcCount.put(lpId_spi, wantLpInfo.lpBcCount.get(lpId_spi) + 1);
  84 +
  85 + }
  86 +
  87 + @Override
  88 + public boolean supportsReverse() {
  89 + return true;
  90 + }
  91 +
  92 + @Override
  93 + public void reverse(Serializable context, Object o) throws Exception {
  94 + WantLpInfo wantLpInfo = (WantLpInfo) context;
  95 +
  96 + // 清空数据,下一天继续迭代
  97 + wantLpInfo.lpBcCount.clear();
  98 + wantLpInfo.lpNamesMap.clear();
  99 + wantLpInfo.scheduleDate = null;
  100 + wantLpInfo.validInfoList.clear();
  101 +
  102 +// System.out.println("reverse");
  103 +
  104 + }
  105 +
  106 + @Override
  107 + public Class<?> getResultType() {
  108 + return List.class;
  109 + }
  110 +
  111 + @Override
  112 + public Object getResult(Serializable context) throws Exception {
  113 + WantLpInfo wantLpInfo = (WantLpInfo) context;
  114 +
  115 + SimpleDateFormat sf = new SimpleDateFormat("yyyy年MM月dd日");
  116 + String infoFormat = "日期(%s),路牌(%s),没有排班班次";
  117 +
  118 + for (String lpId : wantLpInfo.lpBcCount.keySet()) {
  119 + if (wantLpInfo.lpBcCount.get(lpId) == 0) {
  120 + // 排班没有班次
  121 + ValidateResults_output.ValidInfo validInfo = new ValidateResults_output.ValidInfo();
  122 + validInfo.setSd(wantLpInfo.scheduleDate);
  123 + validInfo.setDesc(String.format(
  124 + infoFormat,
  125 + sf.format(wantLpInfo.scheduleDate),
  126 + wantLpInfo.lpNamesMap.get(lpId))
  127 + );
  128 + wantLpInfo.validInfoList.add(validInfo);
  129 + }
  130 + }
  131 +
  132 + System.out.println("ValidWantLpFunction==>" + wantLpInfo.lpBcCount);
  133 +
  134 + return wantLpInfo.validInfoList;
  135 + }
  136 +
  137 +}
  138 +
  139 +
  140 +
  141 +
  142 +
  143 +
  144 +
  145 +
... ...
src/main/java/com/bsth/service/schedule/rules/validate/ValidWholeRerunBcFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/validate/ValidWholeRerunBcFunction.java
1   -package com.bsth.service.schedule.rules.validate;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.validate;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlanInfo;
4 4 import org.kie.api.runtime.rule.AccumulateFunction;
... ...
src/main/java/com/bsth/service/schedule/rules/validate/ValidateParam.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/validate/ValidateParam.java
1   -package com.bsth.service.schedule.rules.validate;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.validate;
2 2  
3 3 import org.joda.time.DateTime;
4 4 import org.joda.time.Period;
... ...
src/main/java/com/bsth/service/schedule/rules/validate/ValidateResource.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/validate/ValidateResource.java
1   -package com.bsth.service.schedule.rules.validate;
2   -
3   -import com.bsth.entity.schedule.SchedulePlanInfo;
4   -import com.bsth.service.schedule.rules.ttinfo.LpInfoResult_output;
5   -
6   -import java.util.Date;
7   -import java.util.List;
8   -
9   -/**
10   - * 验证操作dsl类。
11   - */
12   -public class ValidateResource {
13   - /** 具体日期 */
14   - private Date sd;
15   - /** 当天排班计划 */
16   - private SchedulePlanInfo spi;
17   - /** 当天所有路牌信息 */
18   - private List<LpInfoResult_output> lpiList;
19   -
20   - public Date getSd() {
21   - return sd;
22   - }
23   -
24   - public void setSd(Date sd) {
25   - this.sd = sd;
26   - }
27   -
28   - public SchedulePlanInfo getSpi() {
29   - return spi;
30   - }
31   -
32   - public void setSpi(SchedulePlanInfo spi) {
33   - this.spi = spi;
34   - }
35   -
36   - public List<LpInfoResult_output> getLpiList() {
37   - return lpiList;
38   - }
39   -
40   - public void setLpiList(List<LpInfoResult_output> lpiList) {
41   - this.lpiList = lpiList;
42   - }
43   -}
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.validate;
  2 +
  3 +import com.bsth.entity.schedule.SchedulePlanInfo;
  4 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;
  5 +
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * 验证操作dsl类。
  11 + */
  12 +public class ValidateResource {
  13 + /** 具体日期 */
  14 + private Date sd;
  15 + /** 当天排班计划 */
  16 + private SchedulePlanInfo spi;
  17 + /** 当天所有路牌信息 */
  18 + private List<LpInfoResult_output> lpiList;
  19 +
  20 + public Date getSd() {
  21 + return sd;
  22 + }
  23 +
  24 + public void setSd(Date sd) {
  25 + this.sd = sd;
  26 + }
  27 +
  28 + public SchedulePlanInfo getSpi() {
  29 + return spi;
  30 + }
  31 +
  32 + public void setSpi(SchedulePlanInfo spi) {
  33 + this.spi = spi;
  34 + }
  35 +
  36 + public List<LpInfoResult_output> getLpiList() {
  37 + return lpiList;
  38 + }
  39 +
  40 + public void setLpiList(List<LpInfoResult_output> lpiList) {
  41 + this.lpiList = lpiList;
  42 + }
  43 +}
... ...
src/main/java/com/bsth/service/schedule/rules/validate/ValidateResults_output.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase1/core/validate/ValidateResults_output.java
1   -package com.bsth.service.schedule.rules.validate;
  1 +package com.bsth.service.schedule.impl.plan.kBase1.core.validate;
2 2  
3 3 import java.util.ArrayList;
4 4 import java.util.Date;
... ...
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/CalcuParam.java 0 → 100644
  1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +import org.joda.time.DateTime;
  4 +
  5 +/**
  6 + * 计算用参数。
  7 + */
  8 +public class CalcuParam {
  9 + /** 线路Id */
  10 + private Integer xlId;
  11 +
  12 + /** 计划开始计算日期 */
  13 + private DateTime fromDate;
  14 + /** 计划结束计算日期 */
  15 + private DateTime toDate;
  16 +
  17 + public Integer getXlId() {
  18 + return xlId;
  19 + }
  20 +
  21 + public void setXlId(Integer xlId) {
  22 + this.xlId = xlId;
  23 + }
  24 +
  25 + public DateTime getFromDate() {
  26 + return fromDate;
  27 + }
  28 +
  29 + public void setFromDate(DateTime fromDate) {
  30 + this.fromDate = fromDate;
  31 + }
  32 +
  33 + public DateTime getToDate() {
  34 + return toDate;
  35 + }
  36 +
  37 + public void setToDate(DateTime toDate) {
  38 + this.toDate = toDate;
  39 + }
  40 +}
... ...
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/ErrorInfoFunction.java 0 → 100644
  1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +
  4 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  5 +import com.bsth.entity.schedule.GuideboardInfo;
  6 +import org.apache.commons.lang3.StringUtils;
  7 +import org.apache.commons.lang3.math.NumberUtils;
  8 +import org.kie.api.runtime.rule.AccumulateFunction;
  9 +
  10 +import java.io.*;
  11 +import java.util.HashMap;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * 查找错误函数。
  16 + */
  17 +public class ErrorInfoFunction implements AccumulateFunction {
  18 + @Override
  19 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  20 +
  21 + }
  22 +
  23 + @Override
  24 + public void writeExternal(ObjectOutput out) throws IOException {
  25 +
  26 + }
  27 +
  28 + protected static class ErrorInfoContext implements Externalizable {
  29 + /** 错误数量 */
  30 + public Integer errorCount = 0;
  31 + /** 错误Map,Map<规则id,errorInfo> */
  32 + public Map<Long, ValidateRuleResult.ErrorInfo> errorInfoMap = new HashMap<>();
  33 +
  34 + public ErrorInfoContext() {
  35 +
  36 + }
  37 +
  38 + @Override
  39 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  40 + errorCount = in.readInt();
  41 + errorInfoMap = (Map<Long, ValidateRuleResult.ErrorInfo>) in.readObject();
  42 +
  43 + }
  44 +
  45 + @Override
  46 + public void writeExternal(ObjectOutput out) throws IOException {
  47 + out.writeInt(errorCount);
  48 + out.writeObject(errorInfoMap);
  49 + }
  50 +
  51 + }
  52 +
  53 + @Override
  54 + public Serializable createContext() {
  55 + return new ErrorInfoContext();
  56 + }
  57 +
  58 + @Override
  59 + public void init(Serializable serializable) throws Exception {
  60 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  61 + errorInfoContext.errorCount = 0;
  62 + errorInfoContext.errorInfoMap = new HashMap<>();
  63 + }
  64 +
  65 + @Override
  66 + public void accumulate(Serializable serializable, Object o) {
  67 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  68 + WrapInput wrapInput = (WrapInput) o;
  69 +
  70 + ValidateRuleResult.ErrorInfo errorInfo = new ValidateRuleResult.ErrorInfo();
  71 + errorInfo.setRuleId(wrapInput.getRuleId());
  72 + errorInfo.setClZbh(wrapInput.getClZbh());
  73 + errorInfo.setQyrq(wrapInput.getQyrq());
  74 +
  75 + // 1、车辆配置验证
  76 + if (StringUtils.isNotEmpty(wrapInput.getClZbh())) { // 自编号不能为空
  77 + if (wrapInput.getCcInfos().get(wrapInput.getClZbh()) == null) { // 车辆配置不在当前线路上
  78 + errorInfo.getErrorDescList().add("车辆配置不在当前线路,请重新编辑保存!");
  79 + }
  80 + } else {
  81 + errorInfo.getErrorDescList().add("自编号不能为空,请重新编辑保存!");
  82 + }
  83 +
  84 + // 2、路牌id,路牌名字,路牌起始索引验证
  85 + if (StringUtils.isNotEmpty(wrapInput.getLpIds()) &&
  86 + StringUtils.isNotEmpty(wrapInput.getLpNames())) { // 冗余的路牌id和路牌名字都不能为空
  87 + String[] lpIds = wrapInput.getLpIds().split(",");
  88 + String[] lpNames = wrapInput.getLpNames().split(",");
  89 + if (lpIds.length == lpNames.length) { // 路牌id和路牌名字个数一致
  90 + for (int i = 0; i < lpIds.length; i++) {
  91 + if (!NumberUtils.isDigits(lpIds[i])) { // 冗余路牌id必须是数字
  92 + errorInfo.getErrorDescList().add("冗余路牌id必须是数字,请重新编辑保存!");
  93 + break;
  94 + }
  95 +
  96 + GuideboardInfo lpInfo = wrapInput.getLpInfos().get(NumberUtils.toLong(lpIds[i]));
  97 + if (lpInfo == null) { // 路牌不在当前线路上
  98 + errorInfo.getErrorDescList().add("路牌不在当前线路上,请重新编辑保存!");
  99 + } else {
  100 + if (StringUtils.isEmpty(lpNames[i]) ||
  101 + !(lpNames[i].equals(lpInfo.getLpName()))) { // 路牌id和路牌名字不对应
  102 + errorInfo.getErrorDescList().add("路牌id和路牌名字不对应,请重新编辑保存!");
  103 + break;
  104 + }
  105 + }
  106 + }
  107 +
  108 + if (wrapInput.getLpStartIndex() < 1 ||
  109 + wrapInput.getLpStartIndex() > lpIds.length) { // 路牌起始索引溢出
  110 + errorInfo.getErrorDescList().add("路牌起始索引溢出,请重新编辑保存!");
  111 + }
  112 + } else {
  113 + errorInfo.getErrorDescList().add("路牌id和路牌名字个数不一致,请重新编辑保存!");
  114 + }
  115 + } else {
  116 + errorInfo.getErrorDescList().add("冗余的路牌id和路牌名字都不能为空,请重新编辑保存!");
  117 + }
  118 +
  119 + // 3、人员配置,搭班编码,人员起始索引验证
  120 + if (StringUtils.isNotEmpty(wrapInput.getEcIds()) &&
  121 + StringUtils.isNotEmpty(wrapInput.getEcDbbms())) { // 冗余的人员配置id和人员搭班编码都不能为空
  122 + String[] ecIds = wrapInput.getEcIds().split(",");
  123 + String[] ecDbbms = wrapInput.getEcDbbms().split(",");
  124 + if (ecIds.length == ecDbbms.length) { // 人员配置id和搭班编码个数一致
  125 + for (int i = 0; i < ecIds.length; i++) {
  126 + if (ecIds[i].contains("-")) { // 分班标识
  127 + String[] fb_ecIds = ecIds[i].split("-");
  128 + String[] fb_ecDbbms = ecDbbms[i].split("-");
  129 + if (fb_ecIds.length != 2 || fb_ecDbbms.length != 2) { // 只能早晚分班
  130 + errorInfo.getErrorDescList().add("只能早晚分班,请重新编辑保存!");
  131 + break;
  132 + } else {
  133 + EmployeeConfigInfo fb_ecInfo1 = wrapInput.getEcInfos().get(NumberUtils.toLong(fb_ecIds[0]));
  134 + EmployeeConfigInfo fb_ecInfo2 = wrapInput.getEcInfos().get(NumberUtils.toLong(fb_ecIds[1]));
  135 + if (fb_ecInfo1 == null || fb_ecInfo2 == null) { // 分班的人员配置不在当前线路
  136 + errorInfo.getErrorDescList().add("分班的人员配置不在当前线路,请重新编辑保存!");
  137 + break;
  138 + } else {
  139 + if (StringUtils.isEmpty(fb_ecDbbms[0]) ||
  140 + StringUtils.isEmpty(fb_ecDbbms[1]) ||
  141 + !(fb_ecDbbms[0].equals(fb_ecInfo1.getDbbm())) ||
  142 + !(fb_ecDbbms[1].equals(fb_ecInfo2.getDbbm()))) { // 分班人员配置id和搭班编码不对应
  143 + errorInfo.getErrorDescList().add("分班人员配置id和搭班编码不对应,请重新编辑保存!");
  144 + break;
  145 + }
  146 + }
  147 + }
  148 +
  149 + } else {
  150 + if (!NumberUtils.isDigits(ecIds[i])) { // 冗余的人员配置id必须是数字
  151 + errorInfo.getErrorDescList().add("冗余的人员配置id必须是数字,请重新编辑保存!");
  152 + break;
  153 + }
  154 +
  155 + EmployeeConfigInfo ecInfo = wrapInput.getEcInfos().get(NumberUtils.toLong(ecIds[i]));
  156 + if (ecInfo == null) { // 人员配置不在当前线路
  157 + errorInfo.getErrorDescList().add("人员配置不在当前线路,请重新编辑保存!");
  158 + break;
  159 + } else {
  160 + if (StringUtils.isEmpty(ecDbbms[i]) ||
  161 + !(ecDbbms[i].equals(ecInfo.getDbbm()))) { // 人员配置id和搭班编码不对应
  162 + errorInfo.getErrorDescList().add("人员配置id和搭班编码不对应,请重新编辑保存!");
  163 + break;
  164 + }
  165 + }
  166 + }
  167 + }
  168 +
  169 + if (wrapInput.getEcStartIndex() < 1 ||
  170 + wrapInput.getEcStartIndex() > ecIds.length) { // 人员起始索引溢出
  171 + errorInfo.getErrorDescList().add("人员起始索引溢出,请重新编辑保存!");
  172 + }
  173 + } else {
  174 + errorInfo.getErrorDescList().add("人员配置id和搭班编码个数不一致,请重新编辑保存!");
  175 + }
  176 + }
  177 +
  178 + if (errorInfo.getErrorDescList().size() > 0) {
  179 + errorInfoContext.errorCount ++;
  180 + errorInfoContext.errorInfoMap.put(wrapInput.getRuleId(), errorInfo);
  181 + }
  182 +
  183 + }
  184 +
  185 + @Override
  186 + public void reverse(Serializable serializable, Object o) throws Exception {
  187 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  188 + WrapInput wrapInput = (WrapInput) o;
  189 +
  190 + if (errorInfoContext.errorInfoMap.get(wrapInput.getRuleId()) != null) {
  191 + errorInfoContext.errorInfoMap.remove(wrapInput.getRuleId());
  192 + errorInfoContext.errorCount --;
  193 + }
  194 + }
  195 +
  196 + @Override
  197 + public Object getResult(Serializable serializable) throws Exception {
  198 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  199 + return errorInfoContext.errorInfoMap;
  200 + }
  201 +
  202 + @Override
  203 + public boolean supportsReverse() {
  204 + return true;
  205 + }
  206 +
  207 + @Override
  208 + public Class<?> getResultType() {
  209 + return Map.class;
  210 + }
  211 +
  212 +}
... ...
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/ValidateRuleResult.java 0 → 100644
  1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.Date;
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 输出结果值。
  9 + */
  10 +public class ValidateRuleResult {
  11 + /** 线路id */
  12 + private Integer xlId;
  13 + /** 规则总数量 */
  14 + private Integer count;
  15 + /** 启用的规则数量 */
  16 + private Integer qyCount;
  17 + /** 启用规则中的错误数量 */
  18 + private Integer qyErrorCount;
  19 + /** 错误列表 */
  20 + private List<ErrorInfo> errorInfos = new ArrayList<>();
  21 +
  22 + public Integer getXlId() {
  23 + return xlId;
  24 + }
  25 +
  26 + public void setXlId(Integer xlId) {
  27 + this.xlId = xlId;
  28 + }
  29 +
  30 + public Integer getCount() {
  31 + return count;
  32 + }
  33 +
  34 + public void setCount(Integer count) {
  35 + this.count = count;
  36 + }
  37 +
  38 + public Integer getQyCount() {
  39 + return qyCount;
  40 + }
  41 +
  42 + public void setQyCount(Integer qyCount) {
  43 + this.qyCount = qyCount;
  44 + }
  45 +
  46 + public Integer getQyErrorCount() {
  47 + return qyErrorCount;
  48 + }
  49 +
  50 + public void setQyErrorCount(Integer qyErrorCount) {
  51 + this.qyErrorCount = qyErrorCount;
  52 + }
  53 +
  54 + public List<ErrorInfo> getErrorInfos() {
  55 + return errorInfos;
  56 + }
  57 +
  58 + public void setErrorInfos(List<ErrorInfo> errorInfos) {
  59 + this.errorInfos = errorInfos;
  60 + }
  61 +
  62 + public static class ErrorInfo {
  63 + /** 规则id */
  64 + private Long ruleId;
  65 + /** 车辆自编号 */
  66 + private String clZbh;
  67 + /** 启用日期 */
  68 + private Date qyrq;
  69 + /** 错误描述 */
  70 + private List<String> errorDescList = new ArrayList<>();
  71 +
  72 + public Long getRuleId() {
  73 + return ruleId;
  74 + }
  75 +
  76 + public void setRuleId(Long ruleId) {
  77 + this.ruleId = ruleId;
  78 + }
  79 +
  80 + public String getClZbh() {
  81 + return clZbh;
  82 + }
  83 +
  84 + public void setClZbh(String clZbh) {
  85 + this.clZbh = clZbh;
  86 + }
  87 +
  88 + public Date getQyrq() {
  89 + return qyrq;
  90 + }
  91 +
  92 + public void setQyrq(Date qyrq) {
  93 + this.qyrq = qyrq;
  94 + }
  95 +
  96 + public List<String> getErrorDescList() {
  97 + return errorDescList;
  98 + }
  99 +
  100 + public void setErrorDescList(List<String> errorDescList) {
  101 + this.errorDescList = errorDescList;
  102 + }
  103 + }
  104 +}
... ...
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/WrapInput.java 0 → 100644
  1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +import com.bsth.entity.schedule.CarConfigInfo;
  4 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  5 +import com.bsth.entity.schedule.GuideboardInfo;
  6 +import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  7 +import org.springframework.util.CollectionUtils;
  8 +
  9 +import java.util.*;
  10 +
  11 +/**
  12 + * 聚合输入的待判定数据。
  13 + */
  14 +public class WrapInput {
  15 + /** 线路Id */
  16 + private Integer xlId;
  17 + /** 车辆自编号 */
  18 + private String clZbh;
  19 + /** 路牌id列表 */
  20 + private String lpIds;
  21 + /** 路牌名字列表 */
  22 + private String lpNames;
  23 + /** 人员配置列表 */
  24 + private String ecIds;
  25 + /** 人员搭班编码列表 */
  26 + private String ecDbbms;
  27 + /** 路牌循环起始索引 */
  28 + private Integer lpStartIndex;
  29 + /** 人员循环起始索引 */
  30 + private Integer ecStartIndex;
  31 + /** 规则id */
  32 + private Long ruleId;
  33 + /** 启用日期 */
  34 + private Date qyrq;
  35 +
  36 + private Map<String, CarConfigInfo> ccInfos = new HashMap<>();
  37 + private Map<Long, GuideboardInfo> lpInfos = new HashMap<>();
  38 + private Map<Long, EmployeeConfigInfo> ecInfos = new HashMap<>();
  39 +
  40 + public WrapInput(ScheduleRule1Flat r,
  41 + Map<String, CarConfigInfo> cc,
  42 + Map<Long, GuideboardInfo> lp,
  43 + Map<Long, EmployeeConfigInfo> ec) {
  44 + this.xlId = r.getXl().getId();
  45 + this.clZbh = r.getCarConfigInfo().getCl().getInsideCode();
  46 + this.lpIds = r.getLpIds();
  47 + this.lpNames = r.getLpNames();
  48 + this.ecIds = r.getRyConfigIds();
  49 + this.ecDbbms = r.getRyDbbms();
  50 + this.lpStartIndex = r.getLpStart();
  51 + this.ecStartIndex = r.getRyStart();
  52 + this.ruleId = r.getId();
  53 + this.qyrq = r.getQyrq();
  54 +
  55 + if (!CollectionUtils.isEmpty(cc)) {
  56 + this.ccInfos.putAll(cc);
  57 + }
  58 + if (!CollectionUtils.isEmpty(lp)) {
  59 + this.lpInfos.putAll(lp);
  60 + }
  61 + if (!CollectionUtils.isEmpty(ec)) {
  62 + this.ecInfos.putAll(ec);
  63 + }
  64 +
  65 + }
  66 +
  67 + public Integer getXlId() {
  68 + return xlId;
  69 + }
  70 +
  71 + public void setXlId(Integer xlId) {
  72 + this.xlId = xlId;
  73 + }
  74 +
  75 + public String getClZbh() {
  76 + return clZbh;
  77 + }
  78 +
  79 + public void setClZbh(String clZbh) {
  80 + this.clZbh = clZbh;
  81 + }
  82 +
  83 + public String getLpIds() {
  84 + return lpIds;
  85 + }
  86 +
  87 + public void setLpIds(String lpIds) {
  88 + this.lpIds = lpIds;
  89 + }
  90 +
  91 + public String getLpNames() {
  92 + return lpNames;
  93 + }
  94 +
  95 + public void setLpNames(String lpNames) {
  96 + this.lpNames = lpNames;
  97 + }
  98 +
  99 + public String getEcIds() {
  100 + return ecIds;
  101 + }
  102 +
  103 + public void setEcIds(String ecIds) {
  104 + this.ecIds = ecIds;
  105 + }
  106 +
  107 + public String getEcDbbms() {
  108 + return ecDbbms;
  109 + }
  110 +
  111 + public void setEcDbbms(String ecDbbms) {
  112 + this.ecDbbms = ecDbbms;
  113 + }
  114 +
  115 + public Integer getLpStartIndex() {
  116 + return lpStartIndex;
  117 + }
  118 +
  119 + public void setLpStartIndex(Integer lpStartIndex) {
  120 + this.lpStartIndex = lpStartIndex;
  121 + }
  122 +
  123 + public Integer getEcStartIndex() {
  124 + return ecStartIndex;
  125 + }
  126 +
  127 + public void setEcStartIndex(Integer ecStartIndex) {
  128 + this.ecStartIndex = ecStartIndex;
  129 + }
  130 +
  131 + public Long getRuleId() {
  132 + return ruleId;
  133 + }
  134 +
  135 + public void setRuleId(Long ruleId) {
  136 + this.ruleId = ruleId;
  137 + }
  138 +
  139 + public Date getQyrq() {
  140 + return qyrq;
  141 + }
  142 +
  143 + public void setQyrq(Date qyrq) {
  144 + this.qyrq = qyrq;
  145 + }
  146 +
  147 + public Map<String, CarConfigInfo> getCcInfos() {
  148 + return ccInfos;
  149 + }
  150 +
  151 + public void setCcInfos(Map<String, CarConfigInfo> ccInfos) {
  152 + this.ccInfos = ccInfos;
  153 + }
  154 +
  155 + public Map<Long, GuideboardInfo> getLpInfos() {
  156 + return lpInfos;
  157 + }
  158 +
  159 + public void setLpInfos(Map<Long, GuideboardInfo> lpInfos) {
  160 + this.lpInfos = lpInfos;
  161 + }
  162 +
  163 + public Map<Long, EmployeeConfigInfo> getEcInfos() {
  164 + return ecInfos;
  165 + }
  166 +
  167 + public void setEcInfos(Map<Long, EmployeeConfigInfo> ecInfos) {
  168 + this.ecInfos = ecInfos;
  169 + }
  170 +}
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo2/CalcuParam.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/timetable/CalcuParam.java
1   -package com.bsth.service.schedule.rules.ttinfo2;
  1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.timetable;
2 2  
3 3 import org.joda.time.DateTime;
4 4  
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo2/ErrorBcCountFunction.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/timetable/ErrorBcCountFunction.java
1   -package com.bsth.service.schedule.rules.ttinfo2;
  1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.timetable;
2 2  
3 3 import com.bsth.entity.schedule.TTInfoDetail;
4 4 import org.apache.commons.lang3.StringUtils;
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo2/Result.java renamed to src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/timetable/Result.java
1   -package com.bsth.service.schedule.rules.ttinfo2;
  1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.timetable;
2 2  
3 3 import java.util.ArrayList;
4 4 import java.util.List;
... ... @@ -22,6 +22,8 @@ public class Result {
22 22 private Long ttid;
23 23 /** 时刻表名字 */
24 24 private String ttname;
  25 + /** 线路版本 */
  26 + private Integer lineVersion;
25 27  
26 28 /** 所有班次数 */
27 29 private Long allbc;
... ... @@ -90,5 +92,13 @@ public class Result {
90 92 public void setErrorbc(Long errorbc) {
91 93 this.errorbc = errorbc;
92 94 }
  95 +
  96 + public Integer getLineVersion() {
  97 + return lineVersion;
  98 + }
  99 +
  100 + public void setLineVersion(Integer lineVersion) {
  101 + this.lineVersion = lineVersion;
  102 + }
93 103 }
94 104 }
... ...
src/main/java/com/bsth/service/sys/RoleService.java
... ... @@ -8,6 +8,6 @@ import com.bsth.service.BaseService;
8 8 public interface RoleService extends BaseService<Role, Integer>{
9 9  
10 10 Map<String, Object> settRoleModules(Integer roleId, String mIds);
11   -
  11 +
12 12 Map<String, Object> roleInfo(Integer id);
13 13 }
... ...
src/main/java/com/bsth/service/sys/impl/RoleServiceImpl.java
... ... @@ -33,7 +33,7 @@ public class RoleServiceImpl extends BaseServiceImpl&lt;Role, Integer&gt; implements
33 33  
34 34 @Autowired
35 35 ModuleRepository moduleRepository;
36   -
  36 +
37 37 SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
38 38  
39 39 @Override
... ...
src/main/java/com/bsth/webService/trafficManage/qp/Results.java 0 → 100644
  1 +/**
  2 + * Results.java
  3 + *
  4 + * This file was auto-generated from WSDL
  5 + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
  6 + */
  7 +
  8 +package com.bsth.webService.trafficManage.qp;
  9 +
  10 +public class Results implements java.io.Serializable {
  11 + private boolean success;
  12 +
  13 + private String message;
  14 +
  15 + public Results() {
  16 + }
  17 +
  18 + public Results(
  19 + boolean success,
  20 + String message) {
  21 + this.success = success;
  22 + this.message = message;
  23 + }
  24 +
  25 +
  26 + /**
  27 + * Gets the success value for this Results.
  28 + *
  29 + * @return success
  30 + */
  31 + public boolean isSuccess() {
  32 + return success;
  33 + }
  34 +
  35 +
  36 + /**
  37 + * Sets the success value for this Results.
  38 + *
  39 + * @param success
  40 + */
  41 + public void setSuccess(boolean success) {
  42 + this.success = success;
  43 + }
  44 +
  45 +
  46 + /**
  47 + * Gets the message value for this Results.
  48 + *
  49 + * @return message
  50 + */
  51 + public String getMessage() {
  52 + return message;
  53 + }
  54 +
  55 +
  56 + /**
  57 + * Sets the message value for this Results.
  58 + *
  59 + * @param message
  60 + */
  61 + public void setMessage(String message) {
  62 + this.message = message;
  63 + }
  64 +
  65 + private Object __equalsCalc = null;
  66 + public synchronized boolean equals(Object obj) {
  67 + if (!(obj instanceof Results)) return false;
  68 + Results other = (Results) obj;
  69 + if (obj == null) return false;
  70 + if (this == obj) return true;
  71 + if (__equalsCalc != null) {
  72 + return (__equalsCalc == obj);
  73 + }
  74 + __equalsCalc = obj;
  75 + boolean _equals;
  76 + _equals = true &&
  77 + this.success == other.isSuccess() &&
  78 + ((this.message==null && other.getMessage()==null) ||
  79 + (this.message!=null &&
  80 + this.message.equals(other.getMessage())));
  81 + __equalsCalc = null;
  82 + return _equals;
  83 + }
  84 +
  85 + private boolean __hashCodeCalc = false;
  86 + public synchronized int hashCode() {
  87 + if (__hashCodeCalc) {
  88 + return 0;
  89 + }
  90 + __hashCodeCalc = true;
  91 + int _hashCode = 1;
  92 + _hashCode += (isSuccess() ? Boolean.TRUE : Boolean.FALSE).hashCode();
  93 + if (getMessage() != null) {
  94 + _hashCode += getMessage().hashCode();
  95 + }
  96 + __hashCodeCalc = false;
  97 + return _hashCode;
  98 + }
  99 +
  100 + // Type metadata
  101 + private static org.apache.axis.description.TypeDesc typeDesc =
  102 + new org.apache.axis.description.TypeDesc(Results.class, true);
  103 +
  104 + static {
  105 + typeDesc.setXmlType(new javax.xml.namespace.QName("http://tempuri.org/", "Results"));
  106 + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
  107 + elemField.setFieldName("success");
  108 + elemField.setXmlName(new javax.xml.namespace.QName("http://tempuri.org/", "success"));
  109 + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"));
  110 + elemField.setNillable(false);
  111 + typeDesc.addFieldDesc(elemField);
  112 + elemField = new org.apache.axis.description.ElementDesc();
  113 + elemField.setFieldName("message");
  114 + elemField.setXmlName(new javax.xml.namespace.QName("http://tempuri.org/", "message"));
  115 + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
  116 + elemField.setMinOccurs(0);
  117 + elemField.setNillable(false);
  118 + typeDesc.addFieldDesc(elemField);
  119 + }
  120 +
  121 + /**
  122 + * Return type metadata object
  123 + */
  124 + public static org.apache.axis.description.TypeDesc getTypeDesc() {
  125 + return typeDesc;
  126 + }
  127 +
  128 + /**
  129 + * Get Custom Serializer
  130 + */
  131 + public static org.apache.axis.encoding.Serializer getSerializer(
  132 + String mechType,
  133 + Class _javaType,
  134 + javax.xml.namespace.QName _xmlType) {
  135 + return
  136 + new org.apache.axis.encoding.ser.BeanSerializer(
  137 + _javaType, _xmlType, typeDesc);
  138 + }
  139 +
  140 + /**
  141 + * Get Custom Deserializer
  142 + */
  143 + public static org.apache.axis.encoding.Deserializer getDeserializer(
  144 + String mechType,
  145 + Class _javaType,
  146 + javax.xml.namespace.QName _xmlType) {
  147 + return
  148 + new org.apache.axis.encoding.ser.BeanDeserializer(
  149 + _javaType, _xmlType, typeDesc);
  150 + }
  151 +
  152 +}
... ...
src/main/java/com/bsth/webService/trafficManage/qp/WebService.java 0 → 100644
  1 +/**
  2 + * WebService.java
  3 + *
  4 + * This file was auto-generated from WSDL
  5 + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
  6 + */
  7 +
  8 +package com.bsth.webService.trafficManage.qp;
  9 +
  10 +public interface WebService extends javax.xml.rpc.Service {
  11 + public String getWebServiceSoapAddress();
  12 +
  13 + public com.bsth.webService.trafficManage.qp.WebServiceSoap_PortType getWebServiceSoap() throws javax.xml.rpc.ServiceException;
  14 +
  15 + public com.bsth.webService.trafficManage.qp.WebServiceSoap_PortType getWebServiceSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
  16 +}
... ...
src/main/java/com/bsth/webService/trafficManage/qp/WebServiceLocator.java 0 → 100644
  1 +/**
  2 + * WebServiceLocator.java
  3 + *
  4 + * This file was auto-generated from WSDL
  5 + * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
  6 + */
  7 +
  8 +package com.bsth.webService.trafficManage.qp;
  9 +
  10 +public class WebServiceLocator extends org.apache.axis.client.Service implements WebService {
  11 +
  12 + public WebServiceLocator() {
  13 + }
  14 +
  15 +
  16 + public WebServiceLocator(org.apache.axis.EngineConfiguration config) {
  17 + super(config);
  18 + }
  19 +
  20 + public WebServiceLocator(String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException {
  21 + super(wsdlLoc, sName);
  22 + }
  23 +
  24 + // Use to get a proxy class for WebServiceSoap
  25 + private String WebServiceSoap_address = "http://www.tanway.cn:7280/yyws/services/WebServiceSoap";
  26 +
  27 + public String getWebServiceSoapAddress() {
  28 + return WebServiceSoap_address;
  29 + }
  30 +
  31 + // The WSDD service name defaults to the port name.
  32 + private String WebServiceSoapWSDDServiceName = "WebServiceSoap";
  33 +
  34 + public String getWebServiceSoapWSDDServiceName() {
  35 + return WebServiceSoapWSDDServiceName;
  36 + }
  37 +
  38 + public void setWebServiceSoapWSDDServiceName(String name) {
  39 + WebServiceSoapWSDDServiceName = name;
  40 + }
  41 +
  42 + public com.bsth.webService.trafficManage.qp.WebServiceSoap_PortType getWebServiceSoap() throws javax.xml.rpc.ServiceException {
  43 + java.net.URL endpoint;
  44 + try {
  45 + endpoint = new java.net.URL(WebServiceSoap_address);
  46 + }
  47 + catch (java.net.MalformedURLException e) {
  48 + throw new javax.xml.rpc.ServiceException(e);
  49 + }
  50 + return getWebServiceSoap(endpoint);
  51 + }
  52 +
  53 + public com.bsth.webService.trafficManage.qp.WebServiceSoap_PortType getWebServiceSoap(java.net.URL portAddress) throws javax.xml.rpc.ServiceException {
  54 + try {
  55 + com.bsth.webService.trafficManage.qp.WebServiceSoapSoapBindingStub _stub = new com.bsth.webService.trafficManage.qp.WebServiceSoapSoapBindingStub(portAddress, this);
  56 + _stub.setPortName(getWebServiceSoapWSDDServiceName());
  57 + return _stub;
  58 + }
  59 + catch (org.apache.axis.AxisFault e) {
  60 + return null;
  61 + }
  62 + }
  63 +
  64 + public void setWebServiceSoapEndpointAddress(String address) {
  65 + WebServiceSoap_address = address;
  66 + }
  67 +
  68 + /**
  69 + * For the given interface, get the stub implementation.
  70 + * If this service has no port for the given interface,
  71 + * then ServiceException is thrown.
  72 + */
  73 + public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
  74 + try {
  75 + if (com.bsth.webService.trafficManage.qp.WebServiceSoap_PortType.class.isAssignableFrom(serviceEndpointInterface)) {
  76 + com.bsth.webService.trafficManage.qp.WebServiceSoapSoapBindingStub _stub = new com.bsth.webService.trafficManage.qp.WebServiceSoapSoapBindingStub(new java.net.URL(WebServiceSoap_address), this);
  77 + _stub.setPortName(getWebServiceSoapWSDDServiceName());
  78 + return _stub;
  79 + }
  80 + }
  81 + catch (Throwable t) {
  82 + throw new javax.xml.rpc.ServiceException(t);
  83 + }
  84 + throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName()));
  85 + }
  86 +
  87 + /**
  88 + * For the given interface, get the stub implementation.
  89 + * If this service has no port for the given interface,
  90 + * then ServiceException is thrown.
  91 + */
  92 + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException {
  93 + if (portName == null) {
  94 + return getPort(serviceEndpointInterface);
  95 + }
  96 + String inputPortName = portName.getLocalPart();
  97 + if ("WebServiceSoap".equals(inputPortName)) {
  98 + return getWebServiceSoap();
  99 + }
  100 + else {
  101 + java.rmi.Remote _stub = getPort(serviceEndpointInterface);
  102 + ((org.apache.axis.client.Stub) _stub).setPortName(portName);
  103 + return _stub;
  104 + }
  105 + }
  106 +
  107 + public javax.xml.namespace.QName getServiceName() {
  108 + return new javax.xml.namespace.QName("http://tempuri.org/", "WebService");
  109 + }
  110 +
  111 + private java.util.HashSet ports = null;
  112 +
  113 + public java.util.Iterator getPorts() {
  114 + if (ports == null) {
  115 + ports = new java.util.HashSet();
  116 + ports.add(new javax.xml.namespace.QName("http://tempuri.org/", "WebServiceSoap"));
  117 + }
  118 + return ports.iterator();
  119 + }
  120 +
  121 + /**
  122 + * Set the endpoint address for the specified port name.
  123 + */
  124 + public void setEndpointAddress(String portName, String address) throws javax.xml.rpc.ServiceException {
  125 +
  126 +if ("WebServiceSoap".equals(portName)) {
  127 + setWebServiceSoapEndpointAddress(address);
  128 + }
  129 + else
  130 +{ // Unknown Port Name
  131 + throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName);
  132 + }
  133 + }
  134 +
  135 + /**
  136 + * Set the endpoint address for the specified port name.
  137 + */
  138 + public void setEndpointAddress(javax.xml.namespace.QName portName, String address) throws javax.xml.rpc.ServiceException {
  139 + setEndpointAddress(portName.getLocalPart(), address);
  140 + }
  141 +
  142 +}
... ...