Commit d143649f69ba1f9a3e1fb09460bfea1c8090772a

Authored by youxiw2000
2 parents 02362ca0 8c415bd1

12312

Showing 25 changed files with 1834 additions and 851 deletions

Too many changes to show.

To preserve performance only 25 of 71 files are displayed.

... ... @@ -400,6 +400,12 @@
400 400 <version>1.0.0</version>
401 401 </dependency>
402 402  
  403 + <!-- geotool -->
  404 + <dependency>
  405 + <groupId>org.locationtech.jts</groupId>
  406 + <artifactId>jts-core</artifactId>
  407 + <version>1.16.1</version>
  408 + </dependency>
403 409 </dependencies>
404 410  
405 411 <dependencyManagement>
... ...
src/main/java/com/bsth/common/Constants.java
... ... @@ -54,4 +54,9 @@ public class Constants {
54 54 * 批量解除调度指令和班次的外键约束
55 55 */
56 56 public static final String MULTI_REMOVE_DIRECTIVE_SCH_FK = "update bsth_v_directive_60 set sch=NULL where sch in ";
  57 +
  58 + /**
  59 + * 批量解除子任务和班次的外键约束
  60 + */
  61 + public static final String MULTI_REMOVE_CHILDTASK_SCH_FK = "update bsth_c_s_child_task set schedule=NULL where schedule in ";
57 62 }
... ...
src/main/java/com/bsth/controller/InoutCarparkController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.LsInoutSectionRoute;
  5 +import com.bsth.repository.StationRouteCacheRepository;
  6 +import com.bsth.repository.StationRouteRepository;
  7 +import com.bsth.service.InoutCarparkService;
  8 +import com.bsth.service.StationRouteService;
  9 +import com.fasterxml.jackson.core.JsonProcessingException;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.util.StringUtils;
  14 +import org.springframework.web.bind.annotation.*;
  15 +
  16 +import java.util.HashMap;
  17 +import java.util.Map;
  18 +
  19 +@RestController
  20 +@RequestMapping("inout")
  21 +public class InoutCarparkController extends BaseController<LsInoutSectionRoute, Long>{
  22 +
  23 + private final static Logger logger = LoggerFactory.getLogger(InoutCarparkController.class);
  24 +
  25 + @Autowired
  26 + InoutCarparkService inoutCarparkService;
  27 +
  28 + @RequestMapping(value = "/getStartEndByLine", method = RequestMethod.GET)
  29 + public Map<String, Object> getStartEndByLine(@RequestParam("lineId")int lineId, @RequestParam("version")int version) {
  30 + return inoutCarparkService.getStartEndByLine(lineId, version);
  31 + }
  32 +
  33 + @RequestMapping(value = "/getRouteByStartEnd", method = RequestMethod.GET)
  34 + public Map<String, Object> getRouteByStartEnd(@RequestParam("lineId")int lineId, @RequestParam("version")int version, @RequestParam("start")String start, @RequestParam("end")String end) {
  35 + return inoutCarparkService.getRouteByStartEnd(lineId, version, start, end);
  36 + }
  37 +
  38 + /**
  39 + * 新增路段信息
  40 + *
  41 + * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID
  42 + *
  43 + * lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;
  44 + *
  45 + * sectionrouteCode:路段序号;speedLimit:路段限速>
  46 + *
  47 + * @return map<SUCCESS:成功;ERROR:异常>
  48 + */
  49 + @RequestMapping(value="sectionSave" , method = RequestMethod.POST)
  50 + public Map<String, Object> sectionSave(@RequestParam Map<String, Object> map) {
  51 + map.put("createBy", "");
  52 + map.put("updateBy", "");
  53 + return inoutCarparkService.sectionSave(map);
  54 + }
  55 +
  56 + /**
  57 + * @Description :TODO(编辑线路走向)
  58 + *
  59 + * @param map <sectionId:路段ID; sectionJSON:路段信息>
  60 + *
  61 + * @return Map<String, Object> <SUCCESS ; ERROR>
  62 + */
  63 + @RequestMapping(value="sectionUpdate" , method = RequestMethod.POST)
  64 + public Map<String, Object> sectionUpdate(@RequestParam Map<String, Object> map) {
  65 +
  66 + map.put("updateBy", "");
  67 +
  68 + map.put("createBy", "");
  69 +
  70 + map.put("createDate", "");
  71 +
  72 + return inoutCarparkService.sectionUpdate(map);
  73 +
  74 + }
  75 +
  76 + /**
  77 + * @param id //路段路由id
  78 + * @Description: TODO(撤销路段)
  79 + */
  80 + @RequestMapping(value = "/destroy", method = RequestMethod.POST)
  81 + public Map<String, Object> destroy(@RequestParam Map<String, Object> map) {
  82 + return inoutCarparkService.destroy(map);
  83 + }
  84 +
  85 + /**
  86 + * 从历史轨迹做进场路径规划
  87 + * @Description: TODO(撤销路段)
  88 + */
  89 + @RequestMapping(value = "/pathPlaningByHistory", method = RequestMethod.POST)
  90 + public Map<String, Object> pathPlaningByHistory(@RequestParam Map<String, Object> map){
  91 + Map<String, Object> result = new HashMap<>();
  92 + result.put("status", ResponseCode.SUCCESS);
  93 + try {
  94 + String schId = (String)map.get("schId"), version = (String)map.get("version");
  95 + if (StringUtils.isEmpty(schId) || StringUtils.isEmpty(version)) {
  96 + throw new RuntimeException("无效的参数");
  97 + }
  98 + inoutCarparkService.pathPlaningByHistory(Long.parseLong(schId), Integer.parseInt(version));
  99 + } catch (Exception e) {
  100 + result.put("status", ResponseCode.ERROR);
  101 + logger.error("路径规划异常", e);
  102 + }
  103 +
  104 + return result;
  105 + }
  106 +}
... ...
src/main/java/com/bsth/controller/oil/YlbController.java
... ... @@ -234,8 +234,24 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
234 234  
235 235 @RequestMapping(value = "/checkDate",method = RequestMethod.GET)
236 236 public String checkDate(@RequestParam Map<String, Object> map){
237   - String list=ylbService.checkDate(map);
238   - return list;
  237 + String result=ylbService.checkDate(map);
  238 + return result;
  239 + }
  240 +
  241 + @RequestMapping(value = "/getModifyRights",method = RequestMethod.GET)
  242 + public Map<String, Object> getModifyRights(@RequestParam Map<String, Object> map){
  243 + String result=ylbService.getModifyRights();
  244 + Map<String, Object> resMap = new HashMap<String, Object>();
  245 + resMap.put("text", result);
  246 + return resMap;
  247 + }
  248 +
  249 + @RequestMapping(value = "/modifyRightsChange",method = RequestMethod.GET)
  250 + public Map<String, Object> modifyRightsChange(@RequestParam Map<String, Object> map){
  251 + String result=ylbService.modifyRightsChange();
  252 + Map<String, Object> resMap = new HashMap<String, Object>();
  253 + resMap.put("text", result);
  254 + return resMap;
239 255 }
240 256  
241 257 @RequestMapping(value = "/sumYlb",method = RequestMethod.GET)
... ...
src/main/java/com/bsth/controller/realcontrol/ServiceDataInterface.java
... ... @@ -13,9 +13,12 @@ import com.bsth.data.gpsdata_v2.GpsRealData;
13 13 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
14 14 import com.bsth.data.schedule.DayOfSchedule;
15 15 import com.bsth.data.schedule.external.TccExternalService;
  16 +import com.bsth.entity.Line;
16 17 import com.bsth.entity.directive.D60;
17 18 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  19 +import com.bsth.repository.LineRepository;
18 20 import com.bsth.repository.directive.D60Repository;
  21 +import com.bsth.service.LineService;
19 22 import com.bsth.websocket.handler.SendUtils;
20 23 import com.fasterxml.jackson.databind.ObjectMapper;
21 24 import com.google.common.base.Splitter;
... ... @@ -59,6 +62,13 @@ public class ServiceDataInterface {
59 62 @Autowired
60 63 private SendUtils sendUtils;
61 64  
  65 +
  66 + @Autowired
  67 + LineRepository lineRepository;
  68 +
  69 + @Autowired
  70 + private LineService service;
  71 +
62 72 /**
63 73 * 获取车辆 和 当前执行班次对照信息
64 74 *
... ... @@ -324,9 +334,26 @@ public class ServiceDataInterface {
324 334  
325 335 ObjectMapper mapper = new ObjectMapper();
326 336 try {
  337 + List<Map<String,String>> emergencyList = new ArrayList();
  338 + List<Map<String,String>> emergencyListAll = new ArrayList();
327 339 List<Map> maps = mapper.readValue(jsonStr,mapper.getTypeFactory().constructParametricType(List.class, Map.class));
328 340 for (Map map : maps) {
329 341 sendUtils.sendContingencyPlan(map);
  342 + emergencyList.add((Map<String, String>) map.get("emergencyLine"));
  343 + }
  344 +
  345 + for (Map.Entry<String, String> m : BasicData.lineCode2NameMap.entrySet()){
  346 + for (Map<String,String> emer : emergencyList){
  347 + for (Map.Entry<String,String> t : emer.entrySet()){
  348 + if(m.getKey().equals(t.getKey())){
  349 + emergencyListAll.add(emer); //
  350 + Line line = lineRepository.findById(Integer.parseInt(t.getKey())).get();
  351 + line.setName(t.getValue());
  352 + Map<String, Object> status = service.update(line);
  353 + logger.info("应急接口修改线路名称-----------------------"+status.get("status"));
  354 + }
  355 + }
  356 + }
330 357 }
331 358 } catch (IOException e) {
332 359 result.put("errCode", 502);
... ...
src/main/java/com/bsth/controller/report/ReportController.java
... ... @@ -218,8 +218,9 @@ public class ReportController {
218 218 return new ArrayList<Map<String, Object>>();
219 219 }
220 220 @RequestMapping(value = "/sreachZd", method = RequestMethod.GET)
221   - public List<Map<String, String>> sreachPersonnel(@RequestParam String line,@RequestParam int zdlx) {
222   - return service.sreachZd(line,zdlx);
  221 + public List<Map<String, String>> sreachPersonnel(@RequestParam String line,@RequestParam int zdlx,
  222 + @RequestParam String date1,@RequestParam String date2) {
  223 + return service.sreachZd(line,zdlx,date1,date2);
223 224 }
224 225  
225 226  
... ...
src/main/java/com/bsth/controller/schedule/TrafficManageController.java
1   -package com.bsth.controller.schedule;
2   -
3   -import com.bsth.service.TrafficManageService;
4   -
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.RequestMapping;
7   -import org.springframework.web.bind.annotation.RequestMethod;
8   -import org.springframework.web.bind.annotation.RequestParam;
9   -import org.springframework.web.bind.annotation.RestController;
10   -
11   -/**
12   - *
13   - * @author BSTH
14   - *
15   - */
16   -@RestController
17   -@RequestMapping("trmg")
18   -public class TrafficManageController {
19   -
20   - @Autowired
21   - private TrafficManageService trManageService;
22   -
23   -
24   - @RequestMapping(value = "/setXL", method = RequestMethod.GET)
25   - public String setXL(@RequestParam("ids") String ids) throws Exception {
26   - try {
27   - return trManageService.setXL(ids);
28   - } catch (Exception exp) {
29   - throw new Exception(exp.getCause());
30   - }
31   - }
32   -
33   - @RequestMapping(value = "/setXLByInUse", method = RequestMethod.GET)
34   - public String setXLByInUse(@RequestParam("inUse") String inUse) throws Exception {
35   - try {
36   - return trManageService.setXLByInUse(inUse);
37   - } catch (Exception exp) {
38   - throw new Exception(exp.getCause());
39   - }
40   - }
41   -
42   - @RequestMapping(value = "/setCL", method = RequestMethod.GET)
43   - public String setCL() throws Exception {
44   - try {
45   - return trManageService.setCL();
46   - } catch (Exception exp) {
47   - throw new Exception(exp.getCause());
48   - }
49   - }
50   -
51   - @RequestMapping(value = "/setSJ", method = RequestMethod.GET)
52   - public String setSJ() throws Exception {
53   - try {
54   - return trManageService.setSJ();
55   - } catch (Exception exp) {
56   - throw new Exception(exp.getCause());
57   - }
58   - }
59   -
60   - @RequestMapping(value = "/setLD", method = RequestMethod.GET)
61   - public String setLD() throws Exception {
62   - try {
63   - return trManageService.setLD();
64   - } catch (Exception exp) {
65   - throw new Exception(exp.getCause());
66   - }
67   - }
68   -
69   - @RequestMapping(value = "/setLDByDate", method = RequestMethod.GET)
70   - public String setLDByDate(@RequestParam("theDate") String theDate) throws Exception {
71   - try {
72   - return trManageService.setLD(theDate);
73   - } catch (Exception exp) {
74   - throw new Exception(exp.getCause());
75   - }
76   - }
77   -
78   - @RequestMapping(value = "/setLDFile", method = RequestMethod.GET)
79   - public String setLDFile() throws Exception {
80   - try {
81   - return trManageService.setLDFile();
82   - } catch (Exception exp) {
83   - throw new Exception(exp.getCause());
84   - }
85   - }
86   -
87   - @RequestMapping(value = "/setLCYH", method = RequestMethod.GET)
88   - public String setLCYH() throws Exception {
89   - try {
90   - return trManageService.setLCYH();
91   - } catch (Exception exp) {
92   - throw new Exception(exp.getCause());
93   - }
94   - }
95   -
96   - @RequestMapping(value = "/setDDRB", method = RequestMethod.GET)
97   - public String setDDRB() throws Exception {
98   - try {
99   - return trManageService.setDDRB();
100   - } catch (Exception exp) {
101   - throw new Exception(exp.getCause());
102   - }
103   - }
104   -
105   - @RequestMapping(value = "/setJHBC", method = RequestMethod.GET)
106   - public String setJHBC() throws Exception {
107   - try {
108   - return trManageService.setJHBC();
109   - } catch (Exception exp) {
110   - throw new Exception(exp.getCause());
111   - }
112   - }
113   -
114   - @RequestMapping(value = "/setJHBCByDate", method = RequestMethod.GET)
115   - public String setJHBCByDate(@RequestParam("theDate") String theDate) throws Exception {
116   - try {
117   - return trManageService.setJHBC(theDate);
118   - } catch (Exception exp) {
119   - throw new Exception(exp.getCause());
120   - }
121   - }
122   -
123   - @RequestMapping(value = "/setSKB", method = RequestMethod.GET)
124   - public String setSKB(@RequestParam("ids") String ids) throws Exception {
125   - try {
126   - return trManageService.setSKB(ids);
127   - } catch (Exception exp) {
128   - throw new Exception(exp.getCause());
129   - }
130   - }
131   -
132   - @RequestMapping(value = "/setXLPC", method = RequestMethod.GET)
133   - public String setXLPC() throws Exception {
134   - try {
135   - return trManageService.setXLPC();
136   - } catch (Exception exp) {
137   - throw new Exception(exp.getCause());
138   - }
139   - }
140   -
141   - @RequestMapping(value = "/setCS", method = RequestMethod.GET)
142   - public String setCS() throws Exception {
143   - try {
144   - return trManageService.setCS();
145   - } catch (Exception exp) {
146   - throw new Exception(exp.getCause());
147   - }
148   - }
149   -
150   - @RequestMapping(value = "/getDownLoadAllDataFile", method = RequestMethod.GET)
151   - public String getDownLoadAllDataFile() throws Exception {
152   - try {
153   - return trManageService.getDownLoadAllDataFile();
154   - } catch (Exception exp) {
155   - throw new Exception(exp.getCause());
156   - }
157   - }
158   -
159   -}
  1 +package com.bsth.controller.schedule;
  2 +
  3 +import com.bsth.service.TrafficManageService;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestMapping;
  7 +import org.springframework.web.bind.annotation.RequestMethod;
  8 +import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
  10 +
  11 +/**
  12 + *
  13 + * @author BSTH
  14 + *
  15 + */
  16 +@RestController
  17 +@RequestMapping("trmg")
  18 +public class TrafficManageController {
  19 +
  20 + @Autowired
  21 + private TrafficManageService trManageService;
  22 +
  23 +
  24 + @RequestMapping(value = "/setXL", method = RequestMethod.GET)
  25 + public String setXL(@RequestParam("ids") String ids) throws Exception {
  26 + try {
  27 + return trManageService.setXL(ids);
  28 + } catch (Exception exp) {
  29 + throw new Exception(exp.getCause());
  30 + }
  31 + }
  32 +
  33 + @RequestMapping(value = "/setXLByInUse", method = RequestMethod.GET)
  34 + public String setXLByInUse(@RequestParam("inUse") String inUse) throws Exception {
  35 + try {
  36 + return trManageService.setXLByInUse(inUse);
  37 + } catch (Exception exp) {
  38 + throw new Exception(exp.getCause());
  39 + }
  40 + }
  41 +
  42 + @RequestMapping(value = "/setCL", method = RequestMethod.GET)
  43 + public String setCL() throws Exception {
  44 + try {
  45 + return trManageService.setCL();
  46 + } catch (Exception exp) {
  47 + throw new Exception(exp.getCause());
  48 + }
  49 + }
  50 +
  51 + @RequestMapping(value = "/setSJ", method = RequestMethod.GET)
  52 + public String setSJ() throws Exception {
  53 + try {
  54 + return trManageService.setSJ();
  55 + } catch (Exception exp) {
  56 + throw new Exception(exp.getCause());
  57 + }
  58 + }
  59 +
  60 + @RequestMapping(value = "/setLD", method = RequestMethod.GET)
  61 + public String setLD() throws Exception {
  62 + try {
  63 + return trManageService.setLD();
  64 + } catch (Exception exp) {
  65 + throw new Exception(exp.getCause());
  66 + }
  67 + }
  68 +
  69 + @RequestMapping(value = "/setLDByDate", method = RequestMethod.GET)
  70 + public String setLDByDate(@RequestParam("theDate") String theDate) throws Exception {
  71 + try {
  72 + return trManageService.setLD(theDate);
  73 + } catch (Exception exp) {
  74 + throw new Exception(exp.getCause());
  75 + }
  76 + }
  77 +
  78 + @RequestMapping(value = "/setLDFile", method = RequestMethod.GET)
  79 + public String setLDFile() throws Exception {
  80 + try {
  81 + return trManageService.setLDFile();
  82 + } catch (Exception exp) {
  83 + throw new Exception(exp.getCause());
  84 + }
  85 + }
  86 +
  87 + @RequestMapping(value = "/setLCYH", method = RequestMethod.GET)
  88 + public String setLCYH() throws Exception {
  89 + try {
  90 + return trManageService.setLCYH();
  91 + } catch (Exception exp) {
  92 + throw new Exception(exp.getCause());
  93 + }
  94 + }
  95 +
  96 + @RequestMapping(value = "/setDDRB", method = RequestMethod.GET)
  97 + public String setDDRB() throws Exception {
  98 + try {
  99 + return trManageService.setDDRB();
  100 + } catch (Exception exp) {
  101 + throw new Exception(exp.getCause());
  102 + }
  103 + }
  104 +
  105 + @RequestMapping(value = "/setJHBC", method = RequestMethod.GET)
  106 + public String setJHBC() throws Exception {
  107 + try {
  108 + return trManageService.setJHBC();
  109 + } catch (Exception exp) {
  110 + throw new Exception(exp.getCause());
  111 + }
  112 + }
  113 +
  114 + @RequestMapping(value = "/setJHBCByDate", method = RequestMethod.GET)
  115 + public String setJHBCByDate(@RequestParam("theDate") String theDate) throws Exception {
  116 + try {
  117 + return trManageService.setJHBC(theDate);
  118 + } catch (Exception exp) {
  119 + throw new Exception(exp.getCause());
  120 + }
  121 + }
  122 +
  123 + @RequestMapping(value = "/setSKB", method = RequestMethod.GET)
  124 + public String setSKB(@RequestParam("ids") String ids, @RequestParam("qyrqs") String qyrqs) throws Exception {
  125 + try {
  126 + return trManageService.setSKB(ids, qyrqs);
  127 + } catch (Exception exp) {
  128 + throw new Exception(exp.getCause());
  129 + }
  130 + }
  131 +
  132 + @RequestMapping(value = "/setXLPC", method = RequestMethod.GET)
  133 + public String setXLPC() throws Exception {
  134 + try {
  135 + return trManageService.setXLPC();
  136 + } catch (Exception exp) {
  137 + throw new Exception(exp.getCause());
  138 + }
  139 + }
  140 +
  141 + @RequestMapping(value = "/setCS", method = RequestMethod.GET)
  142 + public String setCS() throws Exception {
  143 + try {
  144 + return trManageService.setCS();
  145 + } catch (Exception exp) {
  146 + throw new Exception(exp.getCause());
  147 + }
  148 + }
  149 +
  150 + @RequestMapping(value = "/getDownLoadAllDataFile", method = RequestMethod.GET)
  151 + public String getDownLoadAllDataFile() throws Exception {
  152 + try {
  153 + return trManageService.getDownLoadAllDataFile();
  154 + } catch (Exception exp) {
  155 + throw new Exception(exp.getCause());
  156 + }
  157 + }
  158 +
  159 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
... ... @@ -6,6 +6,7 @@ import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6 6 import com.bsth.data.gpsdata_v2.handlers.*;
7 7 import com.bsth.email.SendEmailController;
8 8 import com.bsth.email.entity.EmailBean;
  9 +import com.bsth.util.IpUtils;
9 10 import com.fasterxml.jackson.databind.ObjectMapper;
10 11 import com.google.common.collect.ArrayListMultimap;
11 12 import org.apache.commons.lang3.StringUtils;
... ... @@ -109,7 +110,7 @@ public class DataHandleProcess {
109 110 //发送邮件
110 111 EmailBean mail = new EmailBean();
111 112 mail.setSubject("线调GPS处理");
112   - mail.setContent("GPS处理超时,检查日志信息<br/>");
  113 + mail.setContent(IpUtils.getLocalIpAddress() + "GPS处理超时,检查日志信息<br/>");
113 114 sendEmailController.sendMail("113252620@qq.com", mail);
114 115 logger.info(new ObjectMapper().writeValueAsString(list));
115 116 logger.info("DataHandlerProcess:邮件发送成功!");
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -1020,6 +1020,7 @@ public class DayOfSchedule {
1020 1020 }
1021 1021 inStr.deleteCharAt(inStr.length() - 1).append(")");
1022 1022 jdbcTemplate.update(Constants.MULTI_REMOVE_DIRECTIVE_SCH_FK + " " + inStr.toString());
  1023 + jdbcTemplate.update(Constants.MULTI_REMOVE_CHILDTASK_SCH_FK + " " + inStr.toString());
1023 1024 }
1024 1025  
1025 1026 //删除班次数据
... ...
src/main/java/com/bsth/entity/CarPark.java
... ... @@ -40,7 +40,7 @@ public class CarPark {
40 40  
41 41 // 地理位置(百度坐标)
42 42 private String bParkPoint;
43   -
  43 +
44 44 // 地理位置中心点(百度坐标)
45 45 private String bCenterPoint;
46 46  
... ... @@ -81,7 +81,7 @@ public class CarPark {
81 81 private String brancheCompany;
82 82  
83 83 /** 组合公司分公司编码 */
84   - @Formula(" concat(company, '_', branche_company) ")
  84 + @Transient
85 85 private String cgsbm;
86 86  
87 87 // 是否撤销
... ... @@ -106,14 +106,6 @@ public class CarPark {
106 106 // 修改日期
107 107 @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
108 108 private Date updateDate;
109   -
110   - public String getCgsbm() {
111   - return cgsbm;
112   - }
113   -
114   - public void setCgsbm(String cgsbm) {
115   - this.cgsbm = cgsbm;
116   - }
117 109  
118 110 public Integer getId() {
119 111 return id;
... ... @@ -219,6 +211,14 @@ public class CarPark {
219 211 this.company = company;
220 212 }
221 213  
  214 + public String getCgsbm() {
  215 + return this.company + "_" + this.brancheCompany;
  216 + }
  217 +
  218 + public void setCgsbm(String cgsbm) {
  219 + this.cgsbm = cgsbm;
  220 + }
  221 +
222 222 public Integer getDestroy() {
223 223 return destroy;
224 224 }
... ...
src/main/java/com/bsth/entity/LsInoutSectionRoute.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +
  7 +/**
  8 + *
  9 + * @ClassName : LsInoutSectionRoute(历史进出场路段路由实体类)
  10 + *
  11 + * @Author : bsth@lq
  12 + *
  13 + * @Description : TODO(历史路段路由)
  14 + *
  15 + * @Version 公交调度系统BS版 0.1
  16 + *
  17 + */
  18 +
  19 +@Entity
  20 +@Table(name = "bsth_c_ls_inout_sectionroute")
  21 +public class LsInoutSectionRoute {
  22 +
  23 + @Id
  24 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  25 + private Long id;
  26 +
  27 + // 路段路由序号
  28 + private Integer sectionrouteCode;
  29 +
  30 + // 线路编号
  31 + private String lineCode;
  32 +
  33 + /**
  34 + * 进出场起点编码
  35 + */
  36 + private String start;
  37 +
  38 + /**
  39 + * 进出场终点编码
  40 + */
  41 + private String end;
  42 +
  43 + // 路段编号
  44 + private String sectionCode;
  45 +
  46 + // 路段路由方向
  47 + private Integer directions;
  48 +
  49 + // 版本号
  50 + private Integer versions;
  51 +
  52 + // 是否撤销
  53 + private Integer destroy;
  54 +
  55 + // 描述
  56 + private String descriptions;
  57 +
  58 + // 创建人
  59 + private Integer createBy;
  60 +
  61 + // 修改人
  62 + private Integer updateBy;
  63 +
  64 + // 创建日期
  65 + @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  66 + private Date createDate;
  67 +
  68 + // 修改日期
  69 + @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  70 + private Date updateDate;
  71 +
  72 + // 路段信息
  73 + @OneToOne
  74 + private Section section;
  75 +
  76 + // 线路信息
  77 + @ManyToOne
  78 + private Line line;
  79 +
  80 + public Long getId() {
  81 + return id;
  82 + }
  83 +
  84 + public void setId(Long id) {
  85 + this.id = id;
  86 + }
  87 +
  88 + public Integer getSectionrouteCode() {
  89 + return sectionrouteCode;
  90 + }
  91 +
  92 + public void setSectionrouteCode(Integer sectionrouteCode) {
  93 + this.sectionrouteCode = sectionrouteCode;
  94 + }
  95 +
  96 + public String getLineCode() {
  97 + return lineCode;
  98 + }
  99 +
  100 + public void setLineCode(String lineCode) {
  101 + this.lineCode = lineCode;
  102 + }
  103 +
  104 + public String getStart() {
  105 + return start;
  106 + }
  107 +
  108 + public void setStart(String start) {
  109 + this.start = start;
  110 + }
  111 +
  112 + public String getEnd() {
  113 + return end;
  114 + }
  115 +
  116 + public void setEnd(String end) {
  117 + this.end = end;
  118 + }
  119 +
  120 + public String getSectionCode() {
  121 + return sectionCode;
  122 + }
  123 +
  124 + public void setSectionCode(String sectionCode) {
  125 + this.sectionCode = sectionCode;
  126 + }
  127 +
  128 + public Integer getDirections() {
  129 + return directions;
  130 + }
  131 +
  132 + public void setDirections(Integer directions) {
  133 + this.directions = directions;
  134 + }
  135 +
  136 + public Integer getVersions() {
  137 + return versions;
  138 + }
  139 +
  140 + public void setVersions(Integer versions) {
  141 + this.versions = versions;
  142 + }
  143 +
  144 + public Integer getDestroy() {
  145 + return destroy;
  146 + }
  147 +
  148 + public void setDestroy(Integer destroy) {
  149 + this.destroy = destroy;
  150 + }
  151 +
  152 + public String getDescriptions() {
  153 + return descriptions;
  154 + }
  155 +
  156 + public void setDescriptions(String descriptions) {
  157 + this.descriptions = descriptions;
  158 + }
  159 +
  160 + public Integer getCreateBy() {
  161 + return createBy;
  162 + }
  163 +
  164 + public void setCreateBy(Integer createBy) {
  165 + this.createBy = createBy;
  166 + }
  167 +
  168 + public Integer getUpdateBy() {
  169 + return updateBy;
  170 + }
  171 +
  172 + public void setUpdateBy(Integer updateBy) {
  173 + this.updateBy = updateBy;
  174 + }
  175 +
  176 + public Date getCreateDate() {
  177 + return createDate;
  178 + }
  179 +
  180 + public void setCreateDate(Date createDate) {
  181 + this.createDate = createDate;
  182 + }
  183 +
  184 + public Date getUpdateDate() {
  185 + return updateDate;
  186 + }
  187 +
  188 + public void setUpdateDate(Date updateDate) {
  189 + this.updateDate = updateDate;
  190 + }
  191 +
  192 + public Section getSection() {
  193 + return section;
  194 + }
  195 +
  196 + public void setSection(Section section) {
  197 + this.section = section;
  198 + }
  199 +
  200 + public Line getLine() {
  201 + return line;
  202 + }
  203 +
  204 + public void setLine(Line line) {
  205 + this.line = line;
  206 + }
  207 +}
... ...
src/main/java/com/bsth/entity/Section.java
1 1 package com.bsth.entity;
2 2  
  3 +import org.hibernate.annotations.Formula;
  4 +
3 5 import java.util.Date;
4 6  
5 7 import javax.persistence.Column;
... ... @@ -53,12 +55,15 @@ public class Section{
53 55 private String sectionType;
54 56  
55 57 // 路段矢量(空间坐标点集合)--GPS坐标点
  58 + @Formula("ST_AsText(gsection_vector)")
56 59 private String gsectionVector;
57 60  
58 61 // 路段矢量(空间坐标点集合)--百度原始坐标坐标点
  62 + @Formula("ST_AsText(bsection_vector)")
59 63 private String bsectionVector;
60 64  
61 65 // 路段矢量(空间坐标点集合)--城建坐标点
  66 + @Formula("ST_AsText(csection_vector)")
62 67 private String csectionVector;
63 68  
64 69 // 交叉路
... ...
src/main/java/com/bsth/entity/Station.java
1 1 package com.bsth.entity;
2 2  
  3 +import com.bsth.util.Geo.Point;
3 4 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import org.hibernate.annotations.Formula;
  6 +import org.locationtech.jts.geom.Geometry;
  7 +import org.locationtech.jts.io.WKBReader;
4 8  
5   -import javax.persistence.Column;
6   -import javax.persistence.Entity;
7   -import javax.persistence.GeneratedValue;
8   -import javax.persistence.GenerationType;
9   -import javax.persistence.Id;
10   -import javax.persistence.Table;
  9 +import javax.persistence.*;
11 10  
12 11 import java.util.Arrays;
13 12 import java.util.Date;
  13 +import java.util.List;
14 14  
15 15  
16 16 /**
... ... @@ -89,6 +89,9 @@ public class Station {
89 89  
90 90 // 多边形空间原坐标坐标点集合
91 91 private byte[] bPolygonGrid;
  92 +
  93 + @Transient
  94 + private String bdPolygon;
92 95  
93 96 /**
94 97 * 是否撤销
... ... @@ -272,6 +275,17 @@ public class Station {
272 275 this.bPolygonGrid = bPolygonGrid;
273 276 }
274 277  
  278 + public String getBdPolygon() {
  279 + if (bPolygonGrid == null) {
  280 + return null;
  281 + }
  282 + Geometry geometry = getGeometryFromBytes(getbPolygonGrid());
  283 + if (geometry == null) {
  284 + return null;
  285 + }
  286 + return geometry.toString();
  287 + }
  288 +
275 289 public Integer getDestroy() {
276 290 return destroy;
277 291 }
... ... @@ -328,6 +342,48 @@ public class Station {
328 342 this.updateDate = updateDate;
329 343 }
330 344  
  345 + private static Geometry getGeometryFromBytes(byte[] geometryAsBytes) {
  346 + Geometry geometry = null;
  347 + try {
  348 + // 字节数组小于5,说明geometry有问题
  349 + if (geometryAsBytes.length < 5) {
  350 + throw new Exception("Invalid geometry inputStream - less than five bytes");
  351 + }
  352 +
  353 + //first four bytes of the geometry are the SRID,
  354 + //followed by the actual WKB. Determine the SRID
  355 + //这里是取字节数组的前4个来解析srid
  356 + byte[] sridBytes = new byte[4];
  357 + System.arraycopy(geometryAsBytes, 0, sridBytes, 0, 4);
  358 + boolean bigEndian = (geometryAsBytes[4] == 0x00);
  359 + // 解析srid
  360 + int srid = 0;
  361 + if (bigEndian) {
  362 + for (int i = 0; i < sridBytes.length; i++) {
  363 + srid = (srid << 8) + (sridBytes[i] & 0xff);
  364 + }
  365 + } else {
  366 + for (int i = 0; i < sridBytes.length; i++) {
  367 + srid += (sridBytes[i] & 0xff) << (8 * i);
  368 + }
  369 + }
  370 +
  371 + //use the JTS WKBReader for WKB parsing
  372 + WKBReader wkbReader = new WKBReader();
  373 + // 使用geotool的WKBReader 把字节数组转成geometry对象。
  374 + //copy the byte array, removing the first four
  375 + //SRID bytes
  376 + byte[] wkb = new byte[geometryAsBytes.length - 4];
  377 + System.arraycopy(geometryAsBytes, 4, wkb, 0, wkb.length);
  378 + geometry = wkbReader.read(wkb);
  379 + geometry.setSRID(srid);
  380 + } catch (Exception e) {
  381 + e.printStackTrace();
  382 + }
  383 +
  384 + return geometry;
  385 + }
  386 +
331 387 @Override
332 388 public String toString() {
333 389 return "Station [id=" + id + ", stationCod=" + stationCod + ", stationName=" + stationName + ", roadCoding="
... ...
src/main/java/com/bsth/entity/schedule/datasync/VehicleDataSyncTask.java
... ... @@ -9,7 +9,7 @@ import java.io.Serializable;
9 9 import java.util.Date;
10 10  
11 11 /**
12   - * 车辆数据同步日志
  12 + * 车辆数据同步任务
13 13 */
14 14 @Data
15 15 @Builder
... ...
src/main/java/com/bsth/repository/CarParkRepository.java
1   -package com.bsth.repository;
2   -
3   -import java.util.List;
4   -
5   -import org.springframework.data.jpa.repository.Modifying;
6   -import org.springframework.data.jpa.repository.Query;
7   -import org.springframework.stereotype.Repository;
8   -import org.springframework.transaction.annotation.Transactional;
9   -
10   -import com.bsth.entity.CarPark;
11   -
12   -@Repository
13   -public interface CarParkRepository extends BaseRepository<CarPark, Integer>{
14   -
15   - // 查询最大ID
16   - @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_car_park) k"
17   - , nativeQuery=true)
18   - public long carParkMaxId();
19   -
20   - @Transactional
21   - @Modifying
22   - @Query(value="INSERT INTO bsth_c_car_park (" +
23   - " area , company , park_code , park_name , branche_company , " +
24   -
25   - "create_by , create_date , descriptions , destroy, update_by, " +
26   -
27   - "update_date , versions , b_center_point , b_park_point ,db_type, " +
28   -
29   - "g_center_point, g_park_point, radius, shapes_type) " +
30   -
31   - " VALUES(" +
32   - "?1 , ?2 , ?3 , ?4 , ?5," +
33   -
34   - "?6 , str_to_date(?7,'%Y-%m-%d %H:%i:%s') , ?8 , ?9 , ?10," +
35   -
36   - "str_to_date(?11,'%Y-%m-%d %H:%i:%s'), ?12 ,?13,ST_GeomFromText(?14), ?15, " +
37   -
38   - "?16, ST_GeomFromText(?17), ?18,?19)", nativeQuery=true)
39   - public void carParkSave(Double area,String company,String parkCode,String parkName,
40   -
41   - String brancheCompany,Integer createBy,String createDate,String descriptions,Integer destroy,
42   -
43   - Integer updateBy,String updateDate,Integer versions,String bCenterPoint,String bParkPoint,
44   -
45   - String dbType,String gCenterPoint,String gParkPoint,Integer radius,String shapesType);
46   -
47   -
48   - /**
49   - * @Description :TODO(查询路段信息)
50   - *
51   - * @param map <id:路段路由ID>
52   - *
53   - * @return List<Object[]>
54   - */
55   - @Query(value ="SELECT k.id AS carParkId," +
56   - "k.area AS carParkArea," +
57   - "k.company AS carParkCompany," +
58   - "k.park_code AS carParkCode," +
59   - "k.park_name AS carParkName," +
60   - "k.branche_company AS carParkBrancheCompany," +
61   - "k.create_by AS carParkCreateBy," +
62   - "k.create_date AS carParkCreateDate," +
63   - "k.descriptions AS carParkDescriptions," +
64   - "k.destroy AS carParkDestroy," +
65   - "k.update_by AS carParkUpdate," +
66   - "k.update_date AS carParkUpdateDate," +
67   - "k.versions AS carParkVersions," +
68   - "k.b_center_point AS carParkBcenterPoint," +
69   - "ST_AsText(k.b_park_point) AS carParkBparkPoint," +
70   - "k.g_center_point AS carParkGcenterPoint," +
71   - "ST_AsText(k.g_park_point) AS carParkGparkPoint, " +
72   - "k.db_type AS carParkDBtype," +
73   - "k.radius AS carParkRadius," +
74   - "k.shapes_type AS carParkShapesType FROM bsth_c_car_park k where k.id = ?1", nativeQuery=true)
75   - List<Object[]> findCarParkInfoFormId(int id);
76   -
77   - @Transactional
78   - @Modifying
79   - @Query(value="UPDATE bsth_c_car_park SET " +
80   - "area = ?1 , " +
81   - "company = ?2 , " +
82   - "park_code = ?3 , " +
83   - "park_name = ?4 , " +
84   - "branche_company = ?5 , " +
85   - "create_by = ?6 , " +
86   - "create_date = str_to_date(?7,'%Y-%m-%d %H:%i:%s') , " +
87   - "descriptions = ?8 , " +
88   - "destroy = ?9 , " +
89   - "update_by = ?10 , " +
90   - "update_date =str_to_date(?11,'%Y-%m-%d %H:%i:%s') , " +
91   - "versions = ?12 , " +
92   - "b_center_point = ?13 , " +
93   - "g_center_point = ?14 , " +
94   - "b_park_point = ST_GeomFromText(?15) , " +
95   - "g_park_point = ST_GeomFromText(?16) , " +
96   - "db_type = ?17 , " +
97   - "radius = ?18 , " +
98   - "shapes_type = ?19 " +
99   - " WHERE id = ?20 ", nativeQuery=true)
100   - public void carParkUpdate(double area,String company,String parkCode,String parkName,String brancheCompany,
101   -
102   - Integer createBy ,String createDate,String descriptions,Integer destroy,Integer updateBy,
103   -
104   - String updateDate,Integer versions,String bCenterPoint,String gCenterPoint,String bParkPoint,
105   -
106   - String gParkPoint,String dbType,Integer radius,String shapesType,Integer id );
107   -
108   - @Query(value = "select st_astext(g_park_point), shapes_type, g_center_point, radius,park_code,park_name from bsth_c_car_park where park_code=?1", nativeQuery = true)
109   - public Object[][] bufferAera(String parkCode);
110   -
111   - @Query(value ="SELECT p.park_name,p.park_code from bsth_c_car_park p where p.park_code = ?1", nativeQuery=true)
112   - List<Object[]> selectTccInfoByCode(String parkCode);
113   -}
  1 +package com.bsth.repository;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.springframework.data.jpa.repository.Modifying;
  6 +import org.springframework.data.jpa.repository.Query;
  7 +import org.springframework.stereotype.Repository;
  8 +import org.springframework.transaction.annotation.Transactional;
  9 +
  10 +import com.bsth.entity.CarPark;
  11 +
  12 +@Repository
  13 +public interface CarParkRepository extends BaseRepository<CarPark, Integer>{
  14 +
  15 + // 查询最大ID
  16 + @Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_car_park) k"
  17 + , nativeQuery=true)
  18 + public long carParkMaxId();
  19 +
  20 + @Transactional
  21 + @Modifying
  22 + @Query(value="INSERT INTO bsth_c_car_park (" +
  23 + " area , company , park_code , park_name , branche_company , " +
  24 +
  25 + "create_by , create_date , descriptions , destroy, update_by, " +
  26 +
  27 + "update_date , versions , b_center_point , b_park_point ,db_type, " +
  28 +
  29 + "g_center_point, g_park_point, radius, shapes_type) " +
  30 +
  31 + " VALUES(" +
  32 + "?1 , ?2 , ?3 , ?4 , ?5," +
  33 +
  34 + "?6 , str_to_date(?7,'%Y-%m-%d %H:%i:%s') , ?8 , ?9 , ?10," +
  35 +
  36 + "str_to_date(?11,'%Y-%m-%d %H:%i:%s'), ?12 ,?13,ST_GeomFromText(?14), ?15, " +
  37 +
  38 + "?16, ST_GeomFromText(?17), ?18,?19)", nativeQuery=true)
  39 + public void carParkSave(Double area,String company,String parkCode,String parkName,
  40 +
  41 + String brancheCompany,Integer createBy,String createDate,String descriptions,Integer destroy,
  42 +
  43 + Integer updateBy,String updateDate,Integer versions,String bCenterPoint,String bParkPoint,
  44 +
  45 + String dbType,String gCenterPoint,String gParkPoint,Integer radius,String shapesType);
  46 +
  47 +
  48 + /**
  49 + * @Description :TODO(查询路段信息)
  50 + *
  51 + * @param map <id:路段路由ID>
  52 + *
  53 + * @return List<Object[]>
  54 + */
  55 + @Query(value ="SELECT k.id AS carParkId," +
  56 + "k.area AS carParkArea," +
  57 + "k.company AS carParkCompany," +
  58 + "k.park_code AS carParkCode," +
  59 + "k.park_name AS carParkName," +
  60 + "k.branche_company AS carParkBrancheCompany," +
  61 + "k.create_by AS carParkCreateBy," +
  62 + "k.create_date AS carParkCreateDate," +
  63 + "k.descriptions AS carParkDescriptions," +
  64 + "k.destroy AS carParkDestroy," +
  65 + "k.update_by AS carParkUpdate," +
  66 + "k.update_date AS carParkUpdateDate," +
  67 + "k.versions AS carParkVersions," +
  68 + "k.b_center_point AS carParkBcenterPoint," +
  69 + "ST_AsText(k.b_park_point) AS carParkBparkPoint," +
  70 + "k.g_center_point AS carParkGcenterPoint," +
  71 + "ST_AsText(k.g_park_point) AS carParkGparkPoint, " +
  72 + "k.db_type AS carParkDBtype," +
  73 + "k.radius AS carParkRadius," +
  74 + "k.shapes_type AS carParkShapesType FROM bsth_c_car_park k where k.id = ?1", nativeQuery=true)
  75 + List<Object[]> findCarParkInfoFormId(int id);
  76 +
  77 + @Transactional
  78 + @Modifying
  79 + @Query(value="UPDATE bsth_c_car_park SET " +
  80 + "area = ?1 , " +
  81 + "company = ?2 , " +
  82 + "park_code = ?3 , " +
  83 + "park_name = ?4 , " +
  84 + "branche_company = ?5 , " +
  85 + "create_by = ?6 , " +
  86 + "create_date = str_to_date(?7,'%Y-%m-%d %H:%i:%s') , " +
  87 + "descriptions = ?8 , " +
  88 + "destroy = ?9 , " +
  89 + "update_by = ?10 , " +
  90 + "update_date =str_to_date(?11,'%Y-%m-%d %H:%i:%s') , " +
  91 + "versions = ?12 , " +
  92 + "b_center_point = ?13 , " +
  93 + "g_center_point = ?14 , " +
  94 + "b_park_point = ST_GeomFromText(?15) , " +
  95 + "g_park_point = ST_GeomFromText(?16) , " +
  96 + "db_type = ?17 , " +
  97 + "radius = ?18 , " +
  98 + "shapes_type = ?19 " +
  99 + " WHERE id = ?20 ", nativeQuery=true)
  100 + public void carParkUpdate(double area,String company,String parkCode,String parkName,String brancheCompany,
  101 +
  102 + Integer createBy ,String createDate,String descriptions,Integer destroy,Integer updateBy,
  103 +
  104 + String updateDate,Integer versions,String bCenterPoint,String gCenterPoint,String bParkPoint,
  105 +
  106 + String gParkPoint,String dbType,Integer radius,String shapesType,Integer id );
  107 +
  108 + @Query(value = "select st_astext(g_park_point), shapes_type, g_center_point, radius,park_code,park_name from bsth_c_car_park where park_code=?1", nativeQuery = true)
  109 + public Object[][] bufferAera(String parkCode);
  110 +
  111 + @Query(value ="SELECT p.park_name,p.park_code from bsth_c_car_park p where p.park_code = ?1", nativeQuery=true)
  112 + List<Object[]> selectTccInfoByCode(String parkCode);
  113 +
  114 + @Query(value ="select c.id, c.area,c.company,c.park_code,c.park_name,c.branche_company,c.create_by,c.create_date,c.descriptions,c.destroy,c.update_by,c.update_date,c.versions,c.b_center_point,ST_AsText(c.b_park_point) b_park_point,c.g_center_point,ST_AsText(c.g_park_point) g_park_point,c.db_type,c.radius,c.shapes_type from bsth_c_line_information l left join bsth_c_car_park c on l.car_park = c.park_code where l.line = ?1", nativeQuery=true)
  115 + CarPark findByLineId(int lineId);
  116 +}
... ...
src/main/java/com/bsth/repository/LsInoutSectionRouteRepository.java 0 → 100644
  1 +package com.bsth.repository;
  2 +
  3 +import com.bsth.entity.LsInoutSectionRoute;
  4 +import com.bsth.entity.LsSectionRoute;
  5 +import org.springframework.data.jpa.repository.Modifying;
  6 +import org.springframework.data.jpa.repository.Query;
  7 +import org.springframework.stereotype.Repository;
  8 +import org.springframework.transaction.annotation.Transactional;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + *
  14 + * @Interface: SectionRouteRepository(路段路由Repository数据持久层接口)
  15 + *
  16 + * @Extends : BaseRepository
  17 + *
  18 + * @Description: TODO(路段路由Repository数据持久层接口)
  19 + *
  20 + * @Author bsth@lq
  21 + *
  22 + * @Version 公交调度系统BS版 0.1
  23 + *
  24 + */
  25 +
  26 +@Repository
  27 +public interface LsInoutSectionRouteRepository extends BaseRepository<LsInoutSectionRoute, Long> {
  28 +
  29 + /**
  30 + * 查询待更新线路的路段路由
  31 + */
  32 + @Query(value = "SELECT sr FROM LsInoutSectionRoute sr where sr.line.id =?1 and sr.versions=?2 and sr.start=?3 and sr.end=?4 and sr.destroy=0")
  33 + List<LsInoutSectionRoute> getRouteByStartEnd(int lineId, int version, String start, String end);
  34 +
  35 + /**
  36 + *
  37 + * @param lineCode
  38 + * @param version
  39 + * @param start
  40 + * @param end
  41 + * @param sectionrouteCode
  42 + */
  43 + @Modifying
  44 + @Query(value="UPDATE bsth_c_ls_inout_sectionroute set sectionroute_code = (sectionroute_code+1) where line_code = ?1 and versions = ?2 and start = ?3 and end = ?4 and sectionroute_code >=?5 and destroy = 0", nativeQuery=true)
  45 + public void sectionUpdSectionRouteCode(String lineCode, int version, String start, String end, Integer sectionrouteCode);
  46 +
  47 + /**
  48 + * 撤销线路某版本进出场
  49 + * @param lineCode
  50 + * @param version
  51 + * @param start
  52 + * @param end
  53 + */
  54 + @Modifying
  55 + @Query(value="UPDATE bsth_c_ls_inout_sectionroute set destroy = 1 where line_code = ?1 and versions = ?2 and start = ?3 and end = ?4", nativeQuery=true)
  56 + public void destroy(String lineCode, int version, String start, String end);
  57 +}
... ...
src/main/java/com/bsth/repository/LsStationRouteRepository.java
1   -package com.bsth.repository;
2   -
3   -import java.util.List;
4   -import java.util.Map;
5   -
6   -import org.springframework.data.domain.Sort;
7   -import org.springframework.data.jpa.repository.EntityGraph;
8   -import org.springframework.data.jpa.repository.Modifying;
9   -import org.springframework.data.jpa.repository.Query;
10   -import org.springframework.stereotype.Repository;
11   -import org.springframework.transaction.annotation.Transactional;
12   -
13   -import com.bsth.entity.LsStationRoute;
14   -import com.bsth.entity.StationRoute;
15   -
16   -/**
17   - *
18   - * @Interface: StationRouteRepository(站点路由Repository数据持久层接口)
19   - *
20   - * @Extends : BaseRepository
21   - *
22   - * @Description: TODO(站点路由Repository数据持久层接口)
23   - *
24   - * @Author bsth@lq
25   - *
26   - * @Version 公交调度系统BS版 0.1
27   - *
28   - */
29   -
30   -@Repository
31   -public interface LsStationRouteRepository extends BaseRepository<LsStationRoute, Integer> {
32   -
33   - /**
34   - * 查询待更新线路的站点路由
35   - */
36   - @EntityGraph(value = "ls_stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
37   - @Query(value = "SELECT DISTINCT sr FROM LsStationRoute sr where sr.line.id =?1 and sr.lineCode=?2 and sr.versions=?3 and sr.destroy=0")
38   - List<LsStationRoute> findupdated(Integer lineId, String lineCode, Integer versions);
39   -
40   - @Query(value = "SELECT a.`stationRoute.id`," +
41   - "a.`stationRoute.line`," +
42   - "a.`stationRoute.station`," +
43   - "a.`stationRoute.stationName`," +
44   - "a.`stationRoute.stationRouteCode`," +
45   - "a.`stationRoute.lineCode`," +
46   - "a.`stationRoute.stationMark`," +
47   - "a.`stationRoute.outStationNmber`," +
48   - "a.`stationRoute.directions`," +
49   - "a.`stationRoute.distances`," +
50   - "a.`stationRoute.toTime`," +
51   - "a.`stationRoute.firstTime`," +
52   - "a.`stationRoute.endTime`," +
53   - "a.`stationRoute.descriptions`," +
54   - "a.`stationRoute.versions`," +
55   - "b.id AS 'station.id'," +
56   - "b.station_cod AS 'station.stationCod'," +
57   - "b.station_name AS 'station.stationName'," +
58   - "b.road_coding AS 'station.roadCoding'," +
59   - "b.db_type AS 'station.dbType'," +
60   - "b.b_jwpoints AS 'station.bJwpoints'," +
61   - "b.g_lonx AS 'station.gLonx'," +
62   - "b.g_lonx AS 'station.gLaty'," +
63   - "b.x AS 'station.x'," +
64   - "b.y AS 'station.y'," +
65   - "b.shapes_type AS 'station.shapesType'," +
66   - "b.radius AS 'station.radius'," +
67   - "ST_AsText(b.g_polygon_grid) AS 'station.gPolygonGrid'," +
68   - "ST_AsText(b.b_polygon_grid) AS 'station.bPolygonGrid'," +
69   - "b.destroy AS 'station.destroy'," +
70   - "b.versions AS 'station.versions'," +
71   - "b.descriptions AS 'station.descriptions', " +
72   - "a.`stationRoute.industryCode` " +
73   - " FROM (" +
74   - "SELECT r.id AS 'stationRoute.id'," +
75   - " r.line AS 'stationRoute.line'," +
76   - "r.station AS 'stationRoute.station'," +
77   - "r.station_name AS 'stationRoute.stationName'," +
78   - "r.station_route_code as 'stationRoute.stationRouteCode'," +
79   - "r.line_code AS 'stationRoute.lineCode'," +
80   - "r.station_mark AS 'stationRoute.stationMark'," +
81   - "r.out_station_nmber AS 'stationRoute.outStationNmber'," +
82   - "r.directions AS 'stationRoute.directions'," +
83   - "r.distances AS 'stationRoute.distances'," +
84   - "r.to_time AS 'stationRoute.toTime'," +
85   - "r.first_time AS 'stationRoute.firstTime'," +
86   - "r.end_time AS 'stationRoute.endTime'," +
87   - "r.descriptions AS 'stationRoute.descriptions'," +
88   - "r.versions AS 'stationRoute.versions', " +
89   - "r.industry_code AS 'stationRoute.industryCode' " +
90   - " FROM bsth_c_ls_stationroute r WHERE r.line = ?1 and r.directions = ?2 and r.versions=?3 and r.destroy=0) a " +
91   - "LEFT JOIN bsth_c_station b " +
92   - "ON a.`stationRoute.station` = b.id ORDER BY a.`stationRoute.stationRouteCode` ASC", nativeQuery=true)
93   - List<Object[]> findPoints(Integer lineId, Integer direction, Integer versions);
94   -
95   -
96   - @Query(value = "SELECT a.stationRouteLine," +
97   - " a.stationRouteStation," +
98   - " a.stationRouteCode," +
99   - " a.stationRouteLIneCode," +
100   - " a.stationRouteStationMark," +
101   - " a.stationOutStationNmber," +
102   - " a.stationRoutedirections," +
103   - " a.stationRouteDistances," +
104   - " a.stationRouteToTime," +
105   - " a.staitonRouteFirstTime," +
106   - " a.stationRouteEndTime," +
107   - " a.stationRouteDescriptions," +
108   - " a.stationRouteDestroy," +
109   - " a.stationRouteVersions," +
110   - " a.stationRouteCreateBy," +
111   - " a.stationRouteCreateDate," +
112   - " a.stationRouteUpdateBy," +
113   - " a.stationRouteUpdateDate," +
114   - " b.id AS stationId," +
115   - " b.station_cod AS stationCode," +
116   - " a.stationRouteName," +
117   - " b.road_coding AS stationRoadCoding," +
118   - " b.db_type AS stationDbType," +
119   - " b.b_jwpoints AS stationJwpoints," +
120   - " b.g_lonx AS stationGlonx," +
121   - " b.g_laty AS stationGlaty," +
122   - " b.x AS stationX," +
123   - " b.y AS stationY," +
124   - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +
125   - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +
126   - " b.destroy AS stationDestroy," +
127   - " b.radius AS stationRadius," +
128   - " b.shapes_type AS stationShapesType," +
129   - " b.versions AS stationVersions," +
130   - " b.descriptions AS sttationDescriptions," +
131   - " b.create_by AS stationCreateBy," +
132   - " b.create_date AS stationCreateDate," +
133   - " b.update_by AS stationUpdateBy," +
134   - " b.update_date AS stationUpdateDate," +
135   - " a.stationRouteId," +
136   - "b.station_name as zdmc, "+
137   - "a.industryCode "+
138   - " FROM ( SELECT s.id AS stationRouteId," +
139   - " s.line AS stationRouteLine," +
140   - " s.station as stationRouteStation," +
141   - " s.station_name AS stationRouteName," +
142   - " s.station_route_code as stationRouteCode," +
143   - " s.industry_code as industryCode," +
144   - " s.line_code AS stationRouteLIneCode," +
145   - " s.station_mark AS stationRouteStationMark," +
146   - " s.out_station_nmber AS stationOutStationNmber," +
147   - " s.directions AS stationRoutedirections," +
148   - " s.distances AS stationRouteDistances," +
149   - " s.to_time AS stationRouteToTime," +
150   - " s.first_time AS staitonRouteFirstTime," +
151   - " s.end_time AS stationRouteEndTime," +
152   - " s.descriptions AS stationRouteDescriptions," +
153   - " s.destroy AS stationRouteDestroy," +
154   - " s.versions AS stationRouteVersions," +
155   - " s.create_by AS stationRouteCreateBy," +
156   - " s.create_date AS stationRouteCreateDate," +
157   - " s.update_by AS stationRouteUpdateBy," +
158   - " s.update_date AS stationRouteUpdateDate FROM bsth_c_ls_stationroute s WHERE s.line = ?1 and s.directions = ?2 and s.versions=?3 and s.destroy = 0) a " +
159   - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id order by a.stationRouteCode", nativeQuery=true)
160   - List<Object[]> getStationRouteList(Integer lineId, Integer dir ,Integer version);
161   - /**
162   - * 更新路线前删除线路版本号历史原有站点路由
163   - *
164   - * @param line
165   - * @param dir
166   - */
167   - @Modifying
168   - @Transactional
169   - @Query(value="DELETE from bsth_c_ls_stationroute where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true)
170   - public void batchDelete(Integer line,Integer dir, Integer versions);
171   -
172   - /**
173   - * 更新路线前撤销线路版本号历史原有站点路由
174   - *
175   - * @param line
176   - * @param dir
177   - */
178   - @Modifying
179   - @Query(value="UPDATE bsth_c_ls_stationroute set destroy = 1 where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true)
180   - public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions);
181   -
182   - /**
183   - * 按线路编码查询各站点的顺序号
184   - * @param lineCode 线路编码
185   - * @param lineVersion 版本号
186   - * @return
187   - */
188   - @Query("SELECT new map(" +
189   - "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +
190   - "line.linePlayType as linePlayType,s.stationMark as stationMark) " +
191   - "FROM " +
192   - "LsStationRoute s " +
193   - "WHERE " +
194   - "s.destroy = 0 AND s.lineCode = ?1 AND s.versions = ?2 " +
195   - "ORDER BY " +
196   - "lineCode,directions,stationRouteCode")
197   - List<Map<String, String>> findLineWithLineCode4Ygc(String lineCode,Integer lineVersion);
198   - /**
199   - * @Description : TODO(根据站点路由Id查询详情)
200   - *
201   - * @param id:站点路由ID
202   - *
203   - * @return List<Object[]>
204   - */
205   - @Query(value = "SELECT a.stationRouteLine," +
206   - " a.stationRouteStation," +
207   - " a.stationRouteCode," +
208   - " a.stationRouteLIneCode," +
209   - " a.stationRouteStationMark," +
210   - " a.stationOutStationNmber," +
211   - " a.stationRoutedirections," +
212   - " a.stationRouteDistances," +
213   - " a.stationRouteToTime," +
214   - " a.staitonRouteFirstTime," +
215   - " a.stationRouteEndTime," +
216   - " a.stationRouteDescriptions," +
217   - " a.stationRouteDestroy," +
218   - " a.stationRouteVersions," +
219   - " a.stationRouteCreateBy," +
220   - " a.stationRouteCreateDate," +
221   - " a.stationRouteUpdateBy," +
222   - " a.stationRouteUpdateDate," +
223   - " b.id AS stationId," +
224   - " b.station_cod AS stationCode," +
225   - " a.stationRouteName," +
226   - " b.road_coding AS stationRoadCoding," +
227   - " b.db_type AS stationDbType," +
228   - " b.b_jwpoints AS stationJwpoints," +
229   - " b.g_lonx AS stationGlonx," +
230   - " b.g_laty AS stationGlaty," +
231   - " b.x AS stationX," +
232   - " b.y AS stationY," +
233   - " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +
234   - " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +
235   - " b.destroy AS stationDestroy," +
236   - " b.radius AS stationRadius," +
237   - " b.shapes_type AS stationShapesType," +
238   - " b.versions AS stationVersions," +
239   - " b.descriptions AS sttationDescriptions," +
240   - " b.create_by AS stationCreateBy," +
241   - " b.create_date AS stationCreateDate," +
242   - " b.update_by AS stationUpdateBy," +
243   - " b.update_date AS stationUpdateDate," +
244   - " a.stationRouteId,b.station_name as zdmc, " +
245   - " a.industryCode "+
246   - " FROM " +
247   - "( SELECT s.id AS stationRouteId," +
248   - " s.line AS stationRouteLine," +
249   - " s.station as stationRouteStation," +
250   - " s.station_name AS stationRouteName," +
251   - " s.station_route_code as stationRouteCode," +
252   - " s.industry_code as industryCode," +
253   - " s.line_code AS stationRouteLIneCode," +
254   - " s.station_mark AS stationRouteStationMark," +
255   - " s.out_station_nmber AS stationOutStationNmber," +
256   - " s.directions AS stationRoutedirections," +
257   - " s.distances AS stationRouteDistances," +
258   - " s.to_time AS stationRouteToTime," +
259   - " s.first_time AS staitonRouteFirstTime," +
260   - " s.end_time AS stationRouteEndTime," +
261   - " s.descriptions AS stationRouteDescriptions," +
262   - " s.destroy AS stationRouteDestroy," +
263   - " s.versions AS stationRouteVersions," +
264   - " s.create_by AS stationRouteCreateBy," +
265   - " s.create_date AS stationRouteCreateDate," +
266   - " s.update_by AS stationRouteUpdateBy," +
267   - " s.update_date AS stationRouteUpdateDate FROM bsth_c_ls_stationroute s WHERE s.id = ?1 ) a " +
268   - " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)
269   - List<Object[]> findStationRouteInfo(Integer id);
270   -
271   - // 批量修改站点行业编码
272   - @Modifying
273   - @Query(value="update bsth_c_ls_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true)
274   - void updIndustryCode(Integer id, String industryCode);
275   -
276   - @Modifying
277   - @Query(value="UPDATE bsth_c_ls_stationroute set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true)
278   - void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod);
279   -
280   - @Modifying
281   - @Query(value="update bsth_c_ls_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true)
282   - void stationRouteDir(Integer line);
283   -
284   - @Query("select r from LsStationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
285   - List<LsStationRoute> findByLine(int lineId, int dir);
286   -
287   - @Modifying
288   - @Query(value="update bsth_c_ls_stationroute set distances =?2 where id = ?1 ", nativeQuery=true)
289   - void upddis(Integer id,Double dis);
290   -
291   - @Query(value="select * from bsth_c_ls_stationroute where line_code = ?3 and directions = ?4 and destroy = 0 and versions = ?5 limit ?1,?2", nativeQuery=true)
292   - Iterable<LsStationRoute> page(int start , int end , int line ,int dir, int version);
293   -
294   - @Query(value="select count(*) from bsth_c_ls_stationroute where line_code = ?1 and directions = ?2 and destroy = 0 and versions = ?3 ", nativeQuery=true)
295   - int count(int line, int dir, int version);
296   -}
  1 +package com.bsth.repository;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.data.jpa.repository.EntityGraph;
  7 +import org.springframework.data.jpa.repository.Modifying;
  8 +import org.springframework.data.jpa.repository.Query;
  9 +import org.springframework.stereotype.Repository;
  10 +import org.springframework.transaction.annotation.Transactional;
  11 +
  12 +import com.bsth.entity.LsStationRoute;
  13 +
  14 +/**
  15 + *
  16 + * @Interface: StationRouteRepository(站点路由Repository数据持久层接口)
  17 + *
  18 + * @Extends : BaseRepository
  19 + *
  20 + * @Description: TODO(站点路由Repository数据持久层接口)
  21 + *
  22 + * @Author bsth@lq
  23 + *
  24 + * @Version 公交调度系统BS版 0.1
  25 + *
  26 + */
  27 +
  28 +@Repository
  29 +public interface LsStationRouteRepository extends BaseRepository<LsStationRoute, Integer> {
  30 +
  31 + /**
  32 + * 查询待更新线路的站点路由
  33 + */
  34 + @EntityGraph(value = "ls_stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  35 + @Query(value = "SELECT DISTINCT sr FROM LsStationRoute sr where sr.line.id =?1 and sr.lineCode=?2 and sr.versions=?3 and sr.destroy=0")
  36 + List<LsStationRoute> findupdated(Integer lineId, String lineCode, Integer versions);
  37 +
  38 + @Query(value = "SELECT a.`stationRoute.id`," +
  39 + "a.`stationRoute.line`," +
  40 + "a.`stationRoute.station`," +
  41 + "a.`stationRoute.stationName`," +
  42 + "a.`stationRoute.stationRouteCode`," +
  43 + "a.`stationRoute.lineCode`," +
  44 + "a.`stationRoute.stationMark`," +
  45 + "a.`stationRoute.outStationNmber`," +
  46 + "a.`stationRoute.directions`," +
  47 + "a.`stationRoute.distances`," +
  48 + "a.`stationRoute.toTime`," +
  49 + "a.`stationRoute.firstTime`," +
  50 + "a.`stationRoute.endTime`," +
  51 + "a.`stationRoute.descriptions`," +
  52 + "a.`stationRoute.versions`," +
  53 + "b.id AS 'station.id'," +
  54 + "b.station_cod AS 'station.stationCod'," +
  55 + "b.station_name AS 'station.stationName'," +
  56 + "b.road_coding AS 'station.roadCoding'," +
  57 + "b.db_type AS 'station.dbType'," +
  58 + "b.b_jwpoints AS 'station.bJwpoints'," +
  59 + "b.g_lonx AS 'station.gLonx'," +
  60 + "b.g_lonx AS 'station.gLaty'," +
  61 + "b.x AS 'station.x'," +
  62 + "b.y AS 'station.y'," +
  63 + "b.shapes_type AS 'station.shapesType'," +
  64 + "b.radius AS 'station.radius'," +
  65 + "ST_AsText(b.g_polygon_grid) AS 'station.gPolygonGrid'," +
  66 + "ST_AsText(b.b_polygon_grid) AS 'station.bPolygonGrid'," +
  67 + "b.destroy AS 'station.destroy'," +
  68 + "b.versions AS 'station.versions'," +
  69 + "b.descriptions AS 'station.descriptions', " +
  70 + "a.`stationRoute.industryCode` " +
  71 + " FROM (" +
  72 + "SELECT r.id AS 'stationRoute.id'," +
  73 + " r.line AS 'stationRoute.line'," +
  74 + "r.station AS 'stationRoute.station'," +
  75 + "r.station_name AS 'stationRoute.stationName'," +
  76 + "r.station_route_code as 'stationRoute.stationRouteCode'," +
  77 + "r.line_code AS 'stationRoute.lineCode'," +
  78 + "r.station_mark AS 'stationRoute.stationMark'," +
  79 + "r.out_station_nmber AS 'stationRoute.outStationNmber'," +
  80 + "r.directions AS 'stationRoute.directions'," +
  81 + "r.distances AS 'stationRoute.distances'," +
  82 + "r.to_time AS 'stationRoute.toTime'," +
  83 + "r.first_time AS 'stationRoute.firstTime'," +
  84 + "r.end_time AS 'stationRoute.endTime'," +
  85 + "r.descriptions AS 'stationRoute.descriptions'," +
  86 + "r.versions AS 'stationRoute.versions', " +
  87 + "r.industry_code AS 'stationRoute.industryCode' " +
  88 + " FROM bsth_c_ls_stationroute r WHERE r.line = ?1 and r.directions = ?2 and r.versions=?3 and r.destroy=0) a " +
  89 + "LEFT JOIN bsth_c_station b " +
  90 + "ON a.`stationRoute.station` = b.id ORDER BY a.`stationRoute.stationRouteCode` ASC", nativeQuery=true)
  91 + List<Object[]> findPoints(Integer lineId, Integer direction, Integer versions);
  92 +
  93 +
  94 + @Query(value = "SELECT a.stationRouteLine," +
  95 + " a.stationRouteStation," +
  96 + " a.stationRouteCode," +
  97 + " a.stationRouteLIneCode," +
  98 + " a.stationRouteStationMark," +
  99 + " a.stationOutStationNmber," +
  100 + " a.stationRoutedirections," +
  101 + " a.stationRouteDistances," +
  102 + " a.stationRouteToTime," +
  103 + " a.staitonRouteFirstTime," +
  104 + " a.stationRouteEndTime," +
  105 + " a.stationRouteDescriptions," +
  106 + " a.stationRouteDestroy," +
  107 + " a.stationRouteVersions," +
  108 + " a.stationRouteCreateBy," +
  109 + " a.stationRouteCreateDate," +
  110 + " a.stationRouteUpdateBy," +
  111 + " a.stationRouteUpdateDate," +
  112 + " b.id AS stationId," +
  113 + " b.station_cod AS stationCode," +
  114 + " a.stationRouteName," +
  115 + " b.road_coding AS stationRoadCoding," +
  116 + " b.db_type AS stationDbType," +
  117 + " b.b_jwpoints AS stationJwpoints," +
  118 + " b.g_lonx AS stationGlonx," +
  119 + " b.g_laty AS stationGlaty," +
  120 + " b.x AS stationX," +
  121 + " b.y AS stationY," +
  122 + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +
  123 + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +
  124 + " b.destroy AS stationDestroy," +
  125 + " b.radius AS stationRadius," +
  126 + " b.shapes_type AS stationShapesType," +
  127 + " b.versions AS stationVersions," +
  128 + " b.descriptions AS sttationDescriptions," +
  129 + " b.create_by AS stationCreateBy," +
  130 + " b.create_date AS stationCreateDate," +
  131 + " b.update_by AS stationUpdateBy," +
  132 + " b.update_date AS stationUpdateDate," +
  133 + " a.stationRouteId," +
  134 + "b.station_name as zdmc, "+
  135 + "a.industryCode "+
  136 + " FROM ( SELECT s.id AS stationRouteId," +
  137 + " s.line AS stationRouteLine," +
  138 + " s.station as stationRouteStation," +
  139 + " s.station_name AS stationRouteName," +
  140 + " s.station_route_code as stationRouteCode," +
  141 + " s.industry_code as industryCode," +
  142 + " s.line_code AS stationRouteLIneCode," +
  143 + " s.station_mark AS stationRouteStationMark," +
  144 + " s.out_station_nmber AS stationOutStationNmber," +
  145 + " s.directions AS stationRoutedirections," +
  146 + " s.distances AS stationRouteDistances," +
  147 + " s.to_time AS stationRouteToTime," +
  148 + " s.first_time AS staitonRouteFirstTime," +
  149 + " s.end_time AS stationRouteEndTime," +
  150 + " s.descriptions AS stationRouteDescriptions," +
  151 + " s.destroy AS stationRouteDestroy," +
  152 + " s.versions AS stationRouteVersions," +
  153 + " s.create_by AS stationRouteCreateBy," +
  154 + " s.create_date AS stationRouteCreateDate," +
  155 + " s.update_by AS stationRouteUpdateBy," +
  156 + " s.update_date AS stationRouteUpdateDate FROM bsth_c_ls_stationroute s WHERE s.line = ?1 and s.directions = ?2 and s.versions=?3 and s.destroy = 0) a " +
  157 + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id order by a.stationRouteCode", nativeQuery=true)
  158 + List<Object[]> getStationRouteList(Integer lineId, Integer dir ,Integer version);
  159 + /**
  160 + * 更新路线前删除线路版本号历史原有站点路由
  161 + *
  162 + * @param line
  163 + * @param dir
  164 + */
  165 + @Modifying
  166 + @Transactional
  167 + @Query(value="DELETE from bsth_c_ls_stationroute where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true)
  168 + public void batchDelete(Integer line,Integer dir, Integer versions);
  169 +
  170 + /**
  171 + * 更新路线前撤销线路版本号历史原有站点路由
  172 + *
  173 + * @param line
  174 + * @param dir
  175 + */
  176 + @Modifying
  177 + @Query(value="UPDATE bsth_c_ls_stationroute set destroy = 1 where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true)
  178 + public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions);
  179 +
  180 + /**
  181 + * 按线路编码查询各站点的顺序号
  182 + * @param lineCode 线路编码
  183 + * @param lineVersion 版本号
  184 + * @return
  185 + */
  186 + @Query("SELECT new map(" +
  187 + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," +
  188 + "line.linePlayType as linePlayType,s.stationMark as stationMark) " +
  189 + "FROM " +
  190 + "LsStationRoute s " +
  191 + "WHERE " +
  192 + "s.destroy = 0 AND s.lineCode = ?1 AND s.versions = ?2 " +
  193 + "ORDER BY " +
  194 + "lineCode,directions,stationRouteCode")
  195 + List<Map<String, String>> findLineWithLineCode4Ygc(String lineCode,Integer lineVersion);
  196 + /**
  197 + * @Description : TODO(根据站点路由Id查询详情)
  198 + *
  199 + * @param id:站点路由ID
  200 + *
  201 + * @return List<Object[]>
  202 + */
  203 + @Query(value = "SELECT a.stationRouteLine," +
  204 + " a.stationRouteStation," +
  205 + " a.stationRouteCode," +
  206 + " a.stationRouteLIneCode," +
  207 + " a.stationRouteStationMark," +
  208 + " a.stationOutStationNmber," +
  209 + " a.stationRoutedirections," +
  210 + " a.stationRouteDistances," +
  211 + " a.stationRouteToTime," +
  212 + " a.staitonRouteFirstTime," +
  213 + " a.stationRouteEndTime," +
  214 + " a.stationRouteDescriptions," +
  215 + " a.stationRouteDestroy," +
  216 + " a.stationRouteVersions," +
  217 + " a.stationRouteCreateBy," +
  218 + " a.stationRouteCreateDate," +
  219 + " a.stationRouteUpdateBy," +
  220 + " a.stationRouteUpdateDate," +
  221 + " b.id AS stationId," +
  222 + " b.station_cod AS stationCode," +
  223 + " a.stationRouteName," +
  224 + " b.road_coding AS stationRoadCoding," +
  225 + " b.db_type AS stationDbType," +
  226 + " b.b_jwpoints AS stationJwpoints," +
  227 + " b.g_lonx AS stationGlonx," +
  228 + " b.g_laty AS stationGlaty," +
  229 + " b.x AS stationX," +
  230 + " b.y AS stationY," +
  231 + " ST_AsText(b.b_polygon_grid) as stationBPolyonGrid," +
  232 + " ST_AsText(b.g_polygon_grid) AS stationGPloyonGrid, " +
  233 + " b.destroy AS stationDestroy," +
  234 + " b.radius AS stationRadius," +
  235 + " b.shapes_type AS stationShapesType," +
  236 + " b.versions AS stationVersions," +
  237 + " b.descriptions AS sttationDescriptions," +
  238 + " b.create_by AS stationCreateBy," +
  239 + " b.create_date AS stationCreateDate," +
  240 + " b.update_by AS stationUpdateBy," +
  241 + " b.update_date AS stationUpdateDate," +
  242 + " a.stationRouteId,b.station_name as zdmc, " +
  243 + " a.industryCode "+
  244 + " FROM " +
  245 + "( SELECT s.id AS stationRouteId," +
  246 + " s.line AS stationRouteLine," +
  247 + " s.station as stationRouteStation," +
  248 + " s.station_name AS stationRouteName," +
  249 + " s.station_route_code as stationRouteCode," +
  250 + " s.industry_code as industryCode," +
  251 + " s.line_code AS stationRouteLIneCode," +
  252 + " s.station_mark AS stationRouteStationMark," +
  253 + " s.out_station_nmber AS stationOutStationNmber," +
  254 + " s.directions AS stationRoutedirections," +
  255 + " s.distances AS stationRouteDistances," +
  256 + " s.to_time AS stationRouteToTime," +
  257 + " s.first_time AS staitonRouteFirstTime," +
  258 + " s.end_time AS stationRouteEndTime," +
  259 + " s.descriptions AS stationRouteDescriptions," +
  260 + " s.destroy AS stationRouteDestroy," +
  261 + " s.versions AS stationRouteVersions," +
  262 + " s.create_by AS stationRouteCreateBy," +
  263 + " s.create_date AS stationRouteCreateDate," +
  264 + " s.update_by AS stationRouteUpdateBy," +
  265 + " s.update_date AS stationRouteUpdateDate FROM bsth_c_ls_stationroute s WHERE s.id = ?1 ) a " +
  266 + " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)
  267 + List<Object[]> findStationRouteInfo(Integer id);
  268 +
  269 + // 批量修改站点行业编码
  270 + @Modifying
  271 + @Query(value="update bsth_c_ls_stationroute set industry_code =?2 where id = ?1 ", nativeQuery=true)
  272 + void updIndustryCode(Integer id, String industryCode);
  273 +
  274 + @Modifying
  275 + @Query(value="UPDATE bsth_c_ls_stationroute set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true)
  276 + void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod);
  277 +
  278 + @Modifying
  279 + @Query(value="update bsth_c_ls_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true)
  280 + void stationRouteDir(Integer line);
  281 +
  282 + @Query("select r from LsStationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
  283 + List<LsStationRoute> findByLine(int lineId, int dir);
  284 +
  285 + @Modifying
  286 + @Query(value="update bsth_c_ls_stationroute set distances =?2 where id = ?1 ", nativeQuery=true)
  287 + void upddis(Integer id,Double dis);
  288 +
  289 + @Query(value="select * from bsth_c_ls_stationroute where line_code = ?3 and directions = ?4 and destroy = 0 and versions = ?5 limit ?1,?2", nativeQuery=true)
  290 + Iterable<LsStationRoute> page(int start , int end , int line ,int dir, int version);
  291 +
  292 + @Query(value="select count(*) from bsth_c_ls_stationroute where line_code = ?1 and directions = ?2 and destroy = 0 and versions = ?3 ", nativeQuery=true)
  293 + int count(int line, int dir, int version);
  294 +
  295 + @Query(value = " select r.station_code, r.station_name, r.versions " +
  296 + "from bsth_c_ls_stationroute r where r.line_code = ?1 " +
  297 + "and r.directions=?2 and r.destroy = 0 and r.versions in(" +
  298 + "select v.versions from bsth_c_line_versions v where v.line_code=?1 " +
  299 + "and ((date_format(v.start_date, '%Y-%m-%d') >= ?3 and date_format(v.start_date, '%Y-%m-%d') <= ?4) " +
  300 + " or (date_format(v.start_date, '%Y-%m-%d') <= ?4 and date_format(v.end_date, '%Y-%m-%d') >= ?4) " +
  301 + " or (date_format(v.start_date, '%Y-%m-%d') >= ?3 and date_format(v.end_date, '%Y-%m-%d') <= ?4))" +
  302 + ") order by r.versions desc, r.station_route_code asc ", nativeQuery = true)
  303 + List<Object[]> findHistory(String lineCode, Integer updown, String date1, String date2);
  304 +
  305 + @Query("select r from LsStationRoute r where r.line.id=?1 and r.versions=?2 and r.directions=?3 and r.destroy=0 order by r.stationRouteCode")
  306 + List<LsStationRoute> findByLineVersion(int lineId, int version, int dir);
  307 +}
... ...
src/main/java/com/bsth/repository/StationRouteRepository.java
... ... @@ -422,7 +422,7 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int
422 422 @Query("select r from StationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
423 423 List<StationRoute> findByLine(Integer lineId, Integer dir);
424 424  
425   - @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and versions is not null order by r.destroy, r.stationRouteCode")
  425 + @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
426 426 List<StationRoute> findAllByLine(String lineCode, int updown);
427 427  
428 428 @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
... ...
src/main/java/com/bsth/repository/oil/YlbRepository.java
... ... @@ -47,8 +47,8 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
47 47 List<Ylb> listMaxRqJcsx(String rq,String gsbm,String fgsbm,String xlbm,String nbbm);
48 48  
49 49 @Query(value="select * from bsth_c_ylb where "
50   - + " DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= rq "
51   - + " and rq< ?1 and ssgsdm like %?2%"
  50 + + " rq >= str_to_date(?1, '%Y-%m-%d') - INTERVAL 90 DAY "
  51 + + " and rq< ?1 and ssgsdm like %?2% "
52 52 + " and fgsdm like %?3% and xlbm like %?4% and nbbm like %?5% "
53 53 + " order by nbbm , rq desc,jcsx desc,lp desc",nativeQuery=true)
54 54 List<Ylb> listByRqJcsx(String rq,String gsbm,String fgsbm,String xlbm,String nbbm);
... ...
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
... ... @@ -47,6 +47,7 @@ public interface TTInfoDetailRepository extends BaseRepository&lt;TTInfoDetail, Lon
47 47 @Query(value = "select tt from TTInfoDetail tt where tt.ttinfo.id = ?1 and tt.lp.id = ?2 order by tt.fcno asc")
48 48 List<TTInfoDetail> findBcdetails(Long ttinfoId, Long lpId);
49 49  
  50 + @Query(value = "select tt from TTInfoDetail tt left join fetch tt.lp where tt.ttinfo.id = ?1 ")
50 51 List<TTInfoDetail> findByTtinfoId(Long id);
51 52  
52 53 @Modifying
... ...
src/main/java/com/bsth/service/InoutCarparkService.java 0 → 100644
  1 +package com.bsth.service;
  2 +
  3 +import com.bsth.entity.LsStationRoute;
  4 +import com.bsth.entity.StationRoute;
  5 +import com.bsth.entity.StationRouteCache;
  6 +import com.fasterxml.jackson.core.JsonProcessingException;
  7 +
  8 +import javax.servlet.http.HttpServletResponse;
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +
  12 +public interface InoutCarparkService {
  13 +
  14 + Map<String, Object> getStartEndByLine(int lineId, int version);
  15 +
  16 + Map<String, Object> getRouteByStartEnd(int lineId, int version, String start, String end);
  17 +
  18 + Map<String, Object> sectionSave(Map<String, Object> map);
  19 +
  20 + Map<String, Object> sectionUpdate(Map<String, Object> map);
  21 +
  22 + Map<String, Object> destroy(Map<String, Object> map);
  23 +
  24 + void pathPlaningByHistory(long schId, int versions) throws JsonProcessingException;
  25 +}
... ...
src/main/java/com/bsth/service/TrafficManageService.java
1   -package com.bsth.service;
2   -
3   -/**
4   - *
5   - * @Interface: LineService(线路service业务层实现接口)
6   - *
7   - * @extends : BaseService
8   - *
9   - * @Description: TODO(线路service业务层实现接口)
10   - *
11   - * @Author bsth@lq
12   - *
13   - * @Date 2016年4月28日 上午9:21:17
14   - *
15   - * @Version 公交调度系统BS版 0.1
16   - *
17   - */
18   -public interface TrafficManageService {
19   -
20   - /**
21   - * 上传线路信息
22   - *
23   - * @return 调用接口返回信息
24   - */
25   - String setXL(String ids);
26   -
27   - /**
28   - * 上传线路信息
29   - *
30   - * @return 调用接口返回信息
31   - */
32   - String setXLByInUse(String ids);
33   -
34   - /**
35   - * 上传车辆信息
36   - *
37   - * @return 调用接口返回信息
38   - */
39   - String setCL();
40   -
41   - /**
42   - * 上传司机信息
43   - * @return 调用接口返回信息
44   - */
45   - String setSJ();
46   -
47   - /**
48   - * 上传超速数据
49   - *
50   - * @return 调用接口返回信息
51   - */
52   - String setCS();
53   -
54   - /**
55   - * 上传线路班次时刻表数据
56   - *
57   - * @return 调用接口返回信息
58   - */
59   - String setSKB(String ids);
60   -
61   - /**
62   - * 线路人员车辆配置信息
63   - * @return 调用接口返回信息
64   - */
65   - String setXLPC();
66   -
67   - /**
68   - * 线路计划班次表
69   - * @return 调用接口返回信息
70   - */
71   - String setJHBC();
72   -
73   - String setJHBC(String theDate);
74   -
75   - String setLD(String theDate);
76   -
77   - String setLD();
78   -
79   - String setLDFile();
80   -
81   - String setLCYH();
82   -
83   - String setDDRB();
84   -
85   - /**
86   - * 下载全量的公交基础数据
87   - * @return
88   - */
89   - String getDownLoadAllDataFile();
90   -
91   - /**
92   - * 下载增量的公交基础数据
93   - * @return
94   - */
95   - String getDownLoadIncreaseDataFile();
96   -
97   - /**
98   - * 指定线路查询方式公交基础数据下载
99   - * @return
100   - */
101   - String getDownLoadWarrantsBusLineStation();
102   -}
  1 +package com.bsth.service;
  2 +
  3 +/**
  4 + *
  5 + * @Interface: LineService(线路service业务层实现接口)
  6 + *
  7 + * @extends : BaseService
  8 + *
  9 + * @Description: TODO(线路service业务层实现接口)
  10 + *
  11 + * @Author bsth@lq
  12 + *
  13 + * @Date 2016年4月28日 上午9:21:17
  14 + *
  15 + * @Version 公交调度系统BS版 0.1
  16 + *
  17 + */
  18 +public interface TrafficManageService {
  19 +
  20 + /**
  21 + * 上传线路信息
  22 + *
  23 + * @return 调用接口返回信息
  24 + */
  25 + String setXL(String ids);
  26 +
  27 + /**
  28 + * 上传线路信息
  29 + *
  30 + * @return 调用接口返回信息
  31 + */
  32 + String setXLByInUse(String ids);
  33 +
  34 + /**
  35 + * 上传车辆信息
  36 + *
  37 + * @return 调用接口返回信息
  38 + */
  39 + String setCL();
  40 +
  41 + /**
  42 + * 上传司机信息
  43 + * @return 调用接口返回信息
  44 + */
  45 + String setSJ();
  46 +
  47 + /**
  48 + * 上传超速数据
  49 + *
  50 + * @return 调用接口返回信息
  51 + */
  52 + String setCS();
  53 +
  54 + /**
  55 + * 上传线路班次时刻表数据
  56 + *
  57 + * @return 调用接口返回信息
  58 + */
  59 + String setSKB(String ids, String qyrqs);
  60 +
  61 + /**
  62 + * 线路人员车辆配置信息
  63 + * @return 调用接口返回信息
  64 + */
  65 + String setXLPC();
  66 +
  67 + /**
  68 + * 线路计划班次表
  69 + * @return 调用接口返回信息
  70 + */
  71 + String setJHBC();
  72 +
  73 + String setJHBC(String theDate);
  74 +
  75 + String setLD(String theDate);
  76 +
  77 + String setLD();
  78 +
  79 + String setLDFile();
  80 +
  81 + String setLCYH();
  82 +
  83 + String setDDRB();
  84 +
  85 + /**
  86 + * 下载全量的公交基础数据
  87 + * @return
  88 + */
  89 + String getDownLoadAllDataFile();
  90 +
  91 + /**
  92 + * 下载增量的公交基础数据
  93 + * @return
  94 + */
  95 + String getDownLoadIncreaseDataFile();
  96 +
  97 + /**
  98 + * 指定线路查询方式公交基础数据下载
  99 + * @return
  100 + */
  101 + String getDownLoadWarrantsBusLineStation();
  102 +}
... ...
src/main/java/com/bsth/service/forms/impl/BudgetServiceImpl.java
... ... @@ -150,7 +150,6 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
150 150  
151 151 for(int i = 0; i < textList.size(); i++){
152 152 String text = textList.get(i);
153   -// System.out.println(text);
154 153 String[] split = text.split(",");
155 154 int rowNo = Integer.valueOf(split[0].trim());
156 155 String year = split[1].trim();
... ... @@ -229,11 +228,11 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
229 228 Budget bud = budgets.get(0);
230 229 if(b.getFormalPerson() != null){
231 230 if(bud.getBudgetMileage() != null){
232   - bud.setChangeMileage(b.getFormalPerson());
  231 + bud.setChangeMileage(b.getFormalMileage());
233 232 } else {
234   - bud.setBudgetMileage(b.getFormalPerson());
  233 + bud.setBudgetMileage(b.getFormalMileage());
235 234 }
236   - bud.setFormalMileage(b.getFormalPerson());
  235 + bud.setFormalMileage(b.getFormalMileage());
237 236 }
238 237 if(b.getFormalPerson() != null){
239 238 if(bud.getBudgetPerson() != null){
... ... @@ -251,11 +250,11 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
251 250 }
252 251 bud.setFormalAmounts(b.getFormalAmounts());
253 252 }
254   - repository.update(bud.getBudgetMileage(), bud.getChangeMileage(), bud.getFormalPerson(),
  253 + repository.update(bud.getBudgetMileage(), bud.getChangeMileage(), bud.getFormalMileage(),
255 254 bud.getBudgetPerson(), bud.getChangePerson(), bud.getFormalPerson(),
256 255 bud.getBudgetAmounts(), bud.getChangeAmounts(), bud.getFormalAmounts(), bud.getId());
257 256 } else {
258   - b.setBudgetMileage(b.getFormalPerson());
  257 + b.setBudgetMileage(b.getFormalMileage());
259 258 b.setBudgetPerson(b.getFormalPerson());
260 259 b.setBudgetAmounts(b.getFormalAmounts());
261 260 insertList.add(b);
... ... @@ -380,7 +379,6 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
380 379 r.setXlName(lineAllMap.get(name).getName());
381 380 }
382 381 } else {
383   - boolean flag = true;
384 382 for(String key : lineAllMap.keySet()){
385 383 Line l = lineAllMap.get(key);
386 384 String name = l.getName();
... ... @@ -388,15 +386,11 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
388 386 name = name.replaceAll("区间", "") + l.getStartStationName().substring(0, 1);
389 387 }
390 388 if(l.getName().equals(lineName) || name.equals(lineName)){
391   - flag = false;
392 389 r.setXlBm(l.getLineCode());
393 390 r.setXlName(l.getName());
394 391 break;
395 392 }
396 393 }
397   -// if(flag){
398   -// System.out.println(m.get("lineName").toString() + " >> " + lineName);
399   -// }
400 394 }
401 395  
402 396 if(r.getXlBm() != null){
... ... @@ -432,6 +426,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
432 426 // TODO Auto-generated method stub
433 427 SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY");
434 428 SimpleDateFormat sdfMM = new SimpleDateFormat("MM");
  429 + DecimalFormat df = new DecimalFormat("0.###");
435 430 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
436 431 Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();
437 432 Map<String, Boolean> lineNature = lineService.lineNature();
... ... @@ -474,9 +469,9 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
474 469 m.put("xlName", xlName);
475 470 m.put("sfyy", sfyy);
476 471 m.put("sfjc", sfjc);
477   - m.put("budget", b.getBudgetMileage()!=null?b.getBudgetMileage():"");
478   - m.put("change", b.getChangeMileage()!=null?b.getChangeMileage():"");
479   - m.put("formal", b.getFormalMileage()!=null?b.getFormalMileage():"");
  472 + m.put("budget", b.getBudgetMileage()!=null?df.format(b.getBudgetMileage()):"");
  473 + m.put("change", b.getChangeMileage()!=null?df.format(b.getChangeMileage()):"");
  474 + m.put("formal", b.getFormalMileage()!=null?df.format(b.getFormalMileage()):"");
480 475 for(int i = 1; i <= 12; i++){
481 476 m.put("mon"+i, "");
482 477 m.put("bud"+i, "");
... ... @@ -494,28 +489,28 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
494 489 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
495 490 if(b.getBudgetMileage()!=null){
496 491 if(m.get("budget").toString().length() > 0){
497   - m.put("budget", new BigDecimal(m.get("budget").toString()).add(
498   - new BigDecimal(b.getBudgetMileage())).doubleValue());
  492 + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add(
  493 + new BigDecimal(b.getBudgetMileage())).doubleValue()));
499 494 } else {
500   - m.put("budget", b.getBudgetMileage());
  495 + m.put("budget", df.format(b.getBudgetMileage()));
501 496 }
502 497 }
503 498 if(b.getChangeMileage()!=null){
504 499 if(m.get("change").toString().length() > 0){
505   - m.put("change", new BigDecimal(m.get("change").toString()).add(
506   - new BigDecimal(b.getChangeMileage())).doubleValue());
  500 + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add(
  501 + new BigDecimal(b.getChangeMileage())).doubleValue()));
507 502 } else {
508   - m.put("change", b.getChangeMileage());
  503 + m.put("change", df.format(b.getChangeMileage()));
509 504 }
510 505 }
511 506 if(b.getFormalMileage()!=null){
512 507 if(m.get("formal").toString().length() > 0){
513   - m.put("formal", new BigDecimal(m.get("formal").toString()).add(
514   - new BigDecimal(b.getFormalMileage())).doubleValue());
  508 + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add(
  509 + new BigDecimal(b.getFormalMileage())).doubleValue()));
515 510 } else {
516   - m.put("formal", b.getFormalMileage());
  511 + m.put("formal", df.format(b.getFormalMileage()));
517 512 }
518   - m.put(bud, b.getFormalMileage());
  513 + m.put(bud, df.format(b.getFormalMileage()));
519 514 }
520 515 }
521 516 }
... ... @@ -611,6 +606,50 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
611 606 }
612 607 strList.add(gsBm + "_all");
613 608  
  609 + BigDecimal monAll = new BigDecimal("0");
  610 + BigDecimal preAll = new BigDecimal("0");
  611 + for(int i = 1; i <= 12; i++){
  612 + if(m.get("mon"+i).toString().length() > 0){
  613 + BigDecimal val = new BigDecimal(m.get("mon"+i).toString());
  614 + monAll = monAll.add(val);
  615 + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
  616 + m.put("mon"+i, val.doubleValue());
  617 + }
  618 + if(m.get("pre"+i).toString().length() > 0){
  619 + BigDecimal val = new BigDecimal(m.get("pre"+i).toString());
  620 + preAll = preAll.add(val);
  621 + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
  622 + m.put("pre"+i, val.doubleValue());
  623 + if(m.get("mon"+i).toString().length() > 0){
  624 + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString());
  625 + BigDecimal sub = monVal.subtract(val);
  626 + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue());
  627 + } else {
  628 + m.put("sub"+i, "-" + val.doubleValue());
  629 + }
  630 + }
  631 + }
  632 + monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
  633 + preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
  634 + Double subAll = monAll.subtract(preAll).doubleValue();
  635 + m.put("monAll", monAll.doubleValue());
  636 + m.put("preAll", preAll.doubleValue());
  637 + m.put("subAll", subAll > 0 ? "+" + subAll : subAll);
  638 +
  639 + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0
  640 + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){
  641 + BigDecimal formal = new BigDecimal(m.get("formal").toString());
  642 + m.put("complete", monAll.divide(
  643 + formal, 4, BigDecimal.ROUND_HALF_UP).multiply(
  644 + new BigDecimal(100)).divide(
  645 + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%");
  646 + BigDecimal diff = monAll.subtract(formal);
  647 + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue());
  648 + } else {
  649 + m.put("complete", "");
  650 + m.put("diff", "");
  651 + }
  652 +
614 653 for(String str : strList){
615 654 if(!keyMap.containsKey(str)){
616 655 continue;
... ... @@ -652,7 +691,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
652 691 }
653 692 if(m.get(bud).toString().length() > 0){
654 693 if(map.get(bud).toString().length() > 0){
655   - map.put(mon, new BigDecimal(m.get(bud).toString()).add(
  694 + map.put(bud, new BigDecimal(m.get(bud).toString()).add(
656 695 new BigDecimal(map.get(bud).toString())).doubleValue());
657 696 } else {
658 697 map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue());
... ... @@ -670,50 +709,6 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
670 709 List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList");
671 710 dataList.add(m);
672 711 }
673   -
674   - BigDecimal monAll = new BigDecimal("0");
675   - BigDecimal preAll = new BigDecimal("0");
676   - for(int i = 1; i <= 12; i++){
677   - if(m.get("mon"+i).toString().length() > 0){
678   - BigDecimal val = new BigDecimal(m.get("mon"+i).toString());
679   - monAll = monAll.add(val);
680   - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
681   - m.put("mon"+i, val.doubleValue());
682   - }
683   - if(m.get("pre"+i).toString().length() > 0){
684   - BigDecimal val = new BigDecimal(m.get("pre"+i).toString());
685   - preAll = preAll.add(val);
686   - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
687   - m.put("pre"+i, val.doubleValue());
688   - if(m.get("mon"+i).toString().length() > 0){
689   - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString());
690   - BigDecimal sub = monVal.subtract(val);
691   - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue());
692   - } else {
693   - m.put("sub"+i, "-" + val.doubleValue());
694   - }
695   - }
696   - }
697   - monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
698   - preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
699   - Double subAll = monAll.subtract(preAll).doubleValue();
700   - m.put("monAll", monAll.doubleValue());
701   - m.put("preAll", preAll.doubleValue());
702   - m.put("subAll", subAll > 0 ? "+" + subAll : subAll);
703   -
704   - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0
705   - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){
706   - BigDecimal formal = new BigDecimal(m.get("formal").toString());
707   - m.put("complete", monAll.divide(
708   - formal, 4, BigDecimal.ROUND_HALF_UP).multiply(
709   - new BigDecimal(100)).divide(
710   - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%");
711   - BigDecimal diff = monAll.subtract(formal);
712   - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue());
713   - } else {
714   - m.put("complete", "");
715   - m.put("diff", "");
716   - }
717 712 }
718 713  
719 714 for(String key : strs){
... ... @@ -764,14 +759,10 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
764 759 if(m.get("mon"+i).toString().length() > 0){
765 760 BigDecimal val = new BigDecimal(m.get("mon"+i).toString());
766 761 monAll = monAll.add(val);
767   - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
768   - m.put("mon"+i, val.doubleValue());
769 762 }
770 763 if(m.get("pre"+i).toString().length() > 0){
771 764 BigDecimal val = new BigDecimal(m.get("pre"+i).toString());
772 765 preAll = preAll.add(val);
773   - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
774   - m.put("pre"+i, val.doubleValue());
775 766 if(m.get("mon"+i).toString().length() > 0){
776 767 BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString());
777 768 BigDecimal sub = monVal.subtract(val);
... ... @@ -781,8 +772,6 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
781 772 }
782 773 }
783 774 }
784   - monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
785   - preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP);
786 775 Double subAll = monAll.subtract(preAll).doubleValue();
787 776 m.put("monAll", monAll.doubleValue());
788 777 m.put("preAll", preAll.doubleValue());
... ... @@ -869,6 +858,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
869 858 // TODO Auto-generated method stub
870 859 SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY");
871 860 SimpleDateFormat sdfMM = new SimpleDateFormat("MM");
  861 + DecimalFormat df = new DecimalFormat("0.###");
872 862 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
873 863 Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();
874 864 Map<String, Boolean> lineNature = lineService.lineNature();
... ... @@ -911,9 +901,9 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
911 901 m.put("xlName", xlName);
912 902 m.put("sfyy", sfyy);
913 903 m.put("sfjc", sfjc);
914   - m.put("budget", b.getBudgetPerson()!=null?b.getBudgetPerson():"");
915   - m.put("change", b.getChangePerson()!=null?b.getChangePerson():"");
916   - m.put("formal", b.getFormalPerson()!=null?b.getFormalPerson():"");
  904 + m.put("budget", b.getBudgetPerson()!=null?df.format(b.getBudgetPerson()):"");
  905 + m.put("change", b.getChangePerson()!=null?df.format(b.getChangePerson()):"");
  906 + m.put("formal", b.getFormalPerson()!=null?df.format(b.getFormalPerson()):"");
917 907 for(int i = 1; i <= 12; i++){
918 908 m.put("mon"+i, "");
919 909 m.put("bud"+i, "");
... ... @@ -931,28 +921,28 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
931 921 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
932 922 if(b.getBudgetPerson()!=null){
933 923 if(m.get("budget").toString().length() > 0){
934   - m.put("budget", new BigDecimal(m.get("budget").toString()).add(
935   - new BigDecimal(b.getBudgetPerson())).doubleValue());
  924 + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add(
  925 + new BigDecimal(b.getBudgetPerson())).doubleValue()));
936 926 } else {
937   - m.put("budget", b.getBudgetPerson());
  927 + m.put("budget", df.format(b.getBudgetPerson()));
938 928 }
939 929 }
940 930 if(b.getChangePerson()!=null){
941 931 if(m.get("change").toString().length() > 0){
942   - m.put("change", new BigDecimal(m.get("change").toString()).add(
943   - new BigDecimal(b.getChangePerson())).doubleValue());
  932 + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add(
  933 + new BigDecimal(b.getChangePerson())).doubleValue()));
944 934 } else {
945   - m.put("change", b.getChangePerson());
  935 + m.put("change", df.format(b.getChangePerson()));
946 936 }
947 937 }
948 938 if(b.getFormalPerson()!=null){
949 939 if(m.get("formal").toString().length() > 0){
950   - m.put("formal", new BigDecimal(m.get("formal").toString()).add(
951   - new BigDecimal(b.getFormalPerson())).doubleValue());
  940 + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add(
  941 + new BigDecimal(b.getFormalPerson())).doubleValue()));
952 942 } else {
953   - m.put("formal", b.getFormalPerson());
  943 + m.put("formal", df.format(b.getFormalPerson()));
954 944 }
955   - m.put(bud, b.getFormalPerson());
  945 + m.put(bud, df.format(b.getFormalPerson()));
956 946 }
957 947 }
958 948 }
... ... @@ -1091,7 +1081,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1091 1081 }
1092 1082 if(m.get(bud).toString().length() > 0){
1093 1083 if(map.get(bud).toString().length() > 0){
1094   - map.put(mon, new BigDecimal(m.get(bud).toString()).add(
  1084 + map.put(bud, new BigDecimal(m.get(bud).toString()).add(
1095 1085 new BigDecimal(map.get(bud).toString())).doubleValue());
1096 1086 } else {
1097 1087 map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue());
... ... @@ -1308,6 +1298,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1308 1298 // TODO Auto-generated method stub
1309 1299 SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY");
1310 1300 SimpleDateFormat sdfMM = new SimpleDateFormat("MM");
  1301 + DecimalFormat df = new DecimalFormat("0.###");
1311 1302 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
1312 1303 Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();
1313 1304 Map<String, Boolean> lineNature = lineService.lineNature();
... ... @@ -1351,9 +1342,9 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1351 1342 m.put("xlName", xlName);
1352 1343 m.put("sfyy", sfyy);
1353 1344 m.put("sfjc", sfjc);
1354   - m.put("budget", b.getBudgetAmounts()!=null?b.getBudgetAmounts():"");
1355   - m.put("change", b.getChangeAmounts()!=null?b.getChangeAmounts():"");
1356   - m.put("formal", b.getFormalAmounts()!=null?b.getFormalAmounts():"");
  1345 + m.put("budget", b.getBudgetAmounts()!=null?df.format(b.getBudgetAmounts()):"");
  1346 + m.put("change", b.getChangeAmounts()!=null?df.format(b.getChangeAmounts()):"");
  1347 + m.put("formal", b.getFormalAmounts()!=null?df.format(b.getFormalAmounts()):"");
1357 1348 for(int i = 1; i <= 12; i++){
1358 1349 m.put("mon"+i, "");
1359 1350 m.put("bud"+i, "");
... ... @@ -1372,28 +1363,28 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1372 1363 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
1373 1364 if(b.getBudgetAmounts()!=null){
1374 1365 if(m.get("budget").toString().length() > 0){
1375   - m.put("budget", new BigDecimal(m.get("budget").toString()).add(
1376   - new BigDecimal(b.getBudgetAmounts())).doubleValue());
  1366 + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add(
  1367 + new BigDecimal(b.getBudgetAmounts())).doubleValue()));
1377 1368 } else {
1378   - m.put("budget", b.getBudgetAmounts());
  1369 + m.put("budget", df.format(b.getBudgetAmounts()));
1379 1370 }
1380 1371 }
1381 1372 if(b.getChangeAmounts()!=null){
1382 1373 if(m.get("change").toString().length() > 0){
1383   - m.put("change", new BigDecimal(m.get("change").toString()).add(
1384   - new BigDecimal(b.getChangeAmounts())).doubleValue());
  1374 + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add(
  1375 + new BigDecimal(b.getChangeAmounts())).doubleValue()));
1385 1376 } else {
1386   - m.put("change", b.getChangeAmounts());
  1377 + m.put("change", df.format(b.getChangeAmounts()));
1387 1378 }
1388 1379 }
1389 1380 if(b.getFormalAmounts()!=null){
1390 1381 if(m.get("formal").toString().length() > 0){
1391   - m.put("formal", new BigDecimal(m.get("formal").toString()).add(
1392   - new BigDecimal(b.getFormalAmounts())).doubleValue());
  1382 + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add(
  1383 + new BigDecimal(b.getFormalAmounts())).doubleValue()));
1393 1384 } else {
1394   - m.put("formal", b.getFormalAmounts());
  1385 + m.put("formal", df.format(b.getFormalAmounts()));
1395 1386 }
1396   - m.put(bud, b.getFormalAmounts());
  1387 + m.put(bud, df.format(b.getFormalAmounts()));
1397 1388 }
1398 1389 }
1399 1390 }
... ... @@ -1529,7 +1520,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1529 1520 }
1530 1521 }
1531 1522 for(int i = 1; i <= 12; i++){
1532   - String mon = "mon"+i, bud = "bud"+i;
  1523 + String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i;
1533 1524 if(m.get(mon).toString().length() > 0){
1534 1525 if(map.get(mon).toString().length() > 0){
1535 1526 map.put(mon, new BigDecimal(m.get(mon).toString()).add(
... ... @@ -1540,12 +1531,20 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1540 1531 }
1541 1532 if(m.get(bud).toString().length() > 0){
1542 1533 if(map.get(bud).toString().length() > 0){
1543   - map.put(mon, new BigDecimal(m.get(bud).toString()).add(
  1534 + map.put(bud, new BigDecimal(m.get(bud).toString()).add(
1544 1535 new BigDecimal(map.get(bud).toString())).doubleValue());
1545 1536 } else {
1546 1537 map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue());
1547 1538 }
1548 1539 }
  1540 + if(m.get(pre).toString().length() > 0){
  1541 + if(map.get(pre).toString().length() > 0){
  1542 + map.put(pre, new BigDecimal(m.get(pre).toString()).add(
  1543 + new BigDecimal(map.get(pre).toString())).doubleValue());
  1544 + } else {
  1545 + map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue());
  1546 + }
  1547 + }
1549 1548 }
1550 1549 if(m.containsKey("num") && m.get("num").toString().length() > 0){
1551 1550 if(map.containsKey("num") && map.get("num").toString().length() > 0){
... ... @@ -1582,10 +1581,10 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1582 1581 }
1583 1582 }
1584 1583 }
1585   - BigDecimal monAll_ = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP);
  1584 + monAll = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP);
1586 1585 preAll = preAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP);
1587   - Double subAll = monAll_.subtract(preAll).doubleValue();
1588   - m.put("monAll", monAll_.doubleValue());
  1586 + Double subAll = monAll.subtract(preAll).doubleValue();
  1587 + m.put("monAll", monAll.doubleValue());
1589 1588 m.put("preAll", preAll.doubleValue());
1590 1589 m.put("subAll", subAll > 0 ? "+" + subAll : subAll);
1591 1590  
... ... @@ -1687,10 +1686,10 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1687 1686 }
1688 1687 }
1689 1688 }
1690   - BigDecimal monAll_ = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP);
  1689 + monAll = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP);
1691 1690 preAll = preAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP);
1692   - Double subAll = monAll_.subtract(preAll).doubleValue();
1693   - m.put("monAll", monAll_.doubleValue());
  1691 + Double subAll = monAll.subtract(preAll).doubleValue();
  1692 + m.put("monAll", monAll.doubleValue());
1694 1693 m.put("preAll", preAll.doubleValue());
1695 1694 m.put("subAll", subAll > 0 ? "+" + subAll : subAll);
1696 1695  
... ... @@ -1784,6 +1783,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1784 1783 // TODO Auto-generated method stub
1785 1784 SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY");
1786 1785 SimpleDateFormat sdfMM = new SimpleDateFormat("MM");
  1786 + DecimalFormat df = new DecimalFormat("0.###");
1787 1787 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
1788 1788 Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>();
1789 1789 List<Budget> findByYear = repository.findByYear(year);
... ... @@ -1834,9 +1834,9 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1834 1834 m.put("xlBm", xlBm);
1835 1835 m.put("xlName", xlName);
1836 1836 m.put("type", "公里");
1837   - m.put("budget", b.getBudgetMileage()!=null?b.getBudgetMileage():"");
1838   - m.put("change", b.getChangeMileage()!=null?b.getChangeMileage():"");
1839   - m.put("formal", b.getFormalMileage()!=null?b.getFormalMileage():"");
  1837 + m.put("budget", b.getBudgetMileage()!=null?df.format(b.getBudgetMileage()):"");
  1838 + m.put("change", b.getChangeMileage()!=null?df.format(b.getChangeMileage()):"");
  1839 + m.put("formal", b.getFormalMileage()!=null?df.format(b.getFormalMileage()):"");
1840 1840 for(int i = 1; i <= 12; i++){
1841 1841 m.put("mon"+i, "");
1842 1842 m.put("bud"+i, "");
... ... @@ -1844,7 +1844,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1844 1844 }
1845 1845 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
1846 1846 if(b.getFormalMileage()!=null){
1847   - m.put(bud, b.getFormalMileage());
  1847 + m.put(bud, df.format(b.getFormalMileage()));
1848 1848 }
1849 1849 m.put("monAll", "0");
1850 1850 xlMap.put(key1, m);
... ... @@ -1854,28 +1854,28 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1854 1854 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
1855 1855 if(b.getBudgetMileage()!=null){
1856 1856 if(m.get("budget").toString().length() > 0){
1857   - m.put("budget", new BigDecimal(m.get("budget").toString()).add(
1858   - new BigDecimal(b.getBudgetMileage())).doubleValue());
  1857 + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add(
  1858 + new BigDecimal(b.getBudgetMileage())).doubleValue()));
1859 1859 } else {
1860   - m.put("budget", b.getBudgetMileage());
  1860 + m.put("budget", df.format(b.getBudgetMileage()));
1861 1861 }
1862 1862 }
1863 1863 if(b.getChangeMileage()!=null){
1864 1864 if(m.get("change").toString().length() > 0){
1865   - m.put("change", new BigDecimal(m.get("change").toString()).add(
1866   - new BigDecimal(b.getChangeMileage())).doubleValue());
  1865 + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add(
  1866 + new BigDecimal(b.getChangeMileage())).doubleValue()));
1867 1867 } else {
1868   - m.put("change", b.getChangeMileage());
  1868 + m.put("change", df.format(b.getChangeMileage()));
1869 1869 }
1870 1870 }
1871 1871 if(b.getFormalMileage()!=null){
1872 1872 if(m.get("formal").toString().length() > 0){
1873   - m.put("formal", new BigDecimal(m.get("formal").toString()).add(
1874   - new BigDecimal(b.getFormalMileage())).doubleValue());
  1873 + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add(
  1874 + new BigDecimal(b.getFormalMileage())).doubleValue()));
1875 1875 } else {
1876   - m.put("formal", b.getFormalMileage());
  1876 + m.put("formal", df.format(b.getFormalMileage()));
1877 1877 }
1878   - m.put(bud, b.getFormalMileage());
  1878 + m.put(bud, df.format(b.getFormalMileage()));
1879 1879 }
1880 1880 }
1881 1881 }
... ... @@ -1888,9 +1888,9 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1888 1888 m.put("xlBm", xlBm);
1889 1889 m.put("xlName", xlName);
1890 1890 m.put("type", "人次");
1891   - m.put("budget", b.getBudgetPerson()!=null?b.getBudgetPerson():"");
1892   - m.put("change", b.getChangePerson()!=null?b.getChangePerson():"");
1893   - m.put("formal", b.getFormalPerson()!=null?b.getFormalPerson():"");
  1891 + m.put("budget", b.getBudgetPerson()!=null?df.format(b.getBudgetPerson()):"");
  1892 + m.put("change", b.getChangePerson()!=null?df.format(b.getChangePerson()):"");
  1893 + m.put("formal", b.getFormalPerson()!=null?df.format(b.getFormalPerson()):"");
1894 1894 for(int i = 1; i <= 12; i++){
1895 1895 m.put("mon"+i, "");
1896 1896 m.put("bud"+i, "");
... ... @@ -1898,7 +1898,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1898 1898 }
1899 1899 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
1900 1900 if(b.getFormalPerson()!=null){
1901   - m.put(bud, b.getFormalPerson());
  1901 + m.put(bud, df.format(b.getFormalPerson()));
1902 1902 }
1903 1903 m.put("monAll", "0");
1904 1904 xlMap.put(key2, m);
... ... @@ -1908,28 +1908,28 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1908 1908 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
1909 1909 if(b.getBudgetPerson()!=null){
1910 1910 if(m.get("budget").toString().length() > 0){
1911   - m.put("budget", new BigDecimal(m.get("budget").toString()).add(
1912   - new BigDecimal(b.getBudgetPerson())).doubleValue());
  1911 + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add(
  1912 + new BigDecimal(b.getBudgetPerson())).doubleValue()));
1913 1913 } else {
1914   - m.put("budget", b.getBudgetPerson());
  1914 + m.put("budget", df.format(b.getBudgetPerson()));
1915 1915 }
1916 1916 }
1917 1917 if(b.getChangePerson()!=null){
1918 1918 if(m.get("change").toString().length() > 0){
1919   - m.put("change", new BigDecimal(m.get("change").toString()).add(
1920   - new BigDecimal(b.getChangePerson())).doubleValue());
  1919 + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add(
  1920 + new BigDecimal(b.getChangePerson())).doubleValue()));
1921 1921 } else {
1922   - m.put("change", b.getChangePerson());
  1922 + m.put("change", df.format(b.getChangePerson()));
1923 1923 }
1924 1924 }
1925 1925 if(b.getFormalPerson()!=null){
1926 1926 if(m.get("formal").toString().length() > 0){
1927   - m.put("formal", new BigDecimal(m.get("formal").toString()).add(
1928   - new BigDecimal(b.getFormalPerson())).doubleValue());
  1927 + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add(
  1928 + new BigDecimal(b.getFormalPerson())).doubleValue()));
1929 1929 } else {
1930   - m.put("formal", b.getFormalPerson());
  1930 + m.put("formal", df.format(b.getFormalPerson()));
1931 1931 }
1932   - m.put(bud, b.getFormalPerson());
  1932 + m.put(bud, df.format(b.getFormalPerson()));
1933 1933 }
1934 1934 }
1935 1935 }
... ... @@ -1942,9 +1942,9 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1942 1942 m.put("xlBm", xlBm);
1943 1943 m.put("xlName", xlName);
1944 1944 m.put("type", "营收");
1945   - m.put("budget", b.getBudgetAmounts()!=null?b.getBudgetAmounts():"");
1946   - m.put("change", b.getChangeAmounts()!=null?b.getChangeAmounts():"");
1947   - m.put("formal", b.getFormalAmounts()!=null?b.getFormalAmounts():"");
  1945 + m.put("budget", b.getBudgetAmounts()!=null?df.format(b.getBudgetAmounts()):"");
  1946 + m.put("change", b.getChangeAmounts()!=null?df.format(b.getChangeAmounts()):"");
  1947 + m.put("formal", b.getFormalAmounts()!=null?df.format(b.getFormalAmounts()):"");
1948 1948 for(int i = 1; i <= 12; i++){
1949 1949 m.put("mon"+i, "");
1950 1950 m.put("bud"+i, "");
... ... @@ -1952,7 +1952,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1952 1952 }
1953 1953 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
1954 1954 if(b.getFormalAmounts()!=null){
1955   - m.put(bud, b.getFormalAmounts());
  1955 + m.put(bud, df.format(b.getFormalAmounts()));
1956 1956 }
1957 1957 m.put("monAll", "0");
1958 1958 xlMap.put(key3, m);
... ... @@ -1962,28 +1962,28 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
1962 1962 String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]);
1963 1963 if(b.getBudgetAmounts()!=null){
1964 1964 if(m.get("budget").toString().length() > 0){
1965   - m.put("budget", new BigDecimal(m.get("budget").toString()).add(
1966   - new BigDecimal(b.getBudgetAmounts())).doubleValue());
  1965 + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add(
  1966 + new BigDecimal(b.getBudgetAmounts())).doubleValue()));
1967 1967 } else {
1968   - m.put("budget", b.getBudgetAmounts());
  1968 + m.put("budget", df.format(b.getBudgetAmounts()));
1969 1969 }
1970 1970 }
1971 1971 if(b.getChangeAmounts()!=null){
1972 1972 if(m.get("change").toString().length() > 0){
1973   - m.put("change", new BigDecimal(m.get("change").toString()).add(
1974   - new BigDecimal(b.getChangeAmounts())).doubleValue());
  1973 + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add(
  1974 + new BigDecimal(b.getChangeAmounts())).doubleValue()));
1975 1975 } else {
1976   - m.put("change", b.getChangeAmounts());
  1976 + m.put("change", df.format(b.getChangeAmounts()));
1977 1977 }
1978 1978 }
1979 1979 if(b.getFormalAmounts()!=null){
1980 1980 if(m.get("formal").toString().length() > 0){
1981   - m.put("formal", new BigDecimal(m.get("formal").toString()).add(
1982   - new BigDecimal(b.getFormalAmounts())).doubleValue());
  1981 + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add(
  1982 + new BigDecimal(b.getFormalAmounts())).doubleValue()));
1983 1983 } else {
1984   - m.put("formal", b.getFormalAmounts());
  1984 + m.put("formal", df.format(b.getFormalAmounts()));
1985 1985 }
1986   - m.put(bud, b.getFormalAmounts());
  1986 + m.put(bud, df.format(b.getFormalAmounts()));
1987 1987 }
1988 1988 }
1989 1989 }
... ... @@ -2298,7 +2298,7 @@ public class BudgetServiceImpl extends BaseServiceImpl&lt;Budget, Integer&gt; implemen
2298 2298 }
2299 2299 if(m.get(bud).toString().length() > 0){
2300 2300 if(map.get(bud).toString().length() > 0){
2301   - map.put(mon, new BigDecimal(m.get(bud).toString()).add(
  2301 + map.put(bud, new BigDecimal(m.get(bud).toString()).add(
2302 2302 new BigDecimal(map.get(bud).toString())).doubleValue());
2303 2303 } else {
2304 2304 map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue());
... ...
src/main/java/com/bsth/service/forms/impl/RevenueLoader.java
... ... @@ -40,13 +40,13 @@ public class RevenueLoader {
40 40 */
41 41 public static List<Map<String, Object>> load(String date, String gsBm){
42 42 try {
43   - url = ConfigUtil.get("http.ticketing.interface") + "?txnType=getLineRevenue&busiDate="+date+"&companyCode="+gsBm;
  43 + url = ConfigUtil.get("http.ticketing.interface") + "?revenueFlag=1&txnType=getLineRevenue&busiDate="+date+"&companyCode="+gsBm;
44 44 list = new ArrayList<>();
45 45 httpClient = HttpClients.createDefault();
46 46 get = new HttpGet(url);
47 47 requestConfig = RequestConfig.custom()
48   - .setConnectTimeout(2500).setConnectionRequestTimeout(2000)
49   - .setSocketTimeout(2500).build();
  48 + .setConnectTimeout(10000).setConnectionRequestTimeout(10000)
  49 + .setSocketTimeout(60000).build();
50 50 get.setConfig(requestConfig);
51 51 if(list.size() > 0)
52 52 list.clear();
... ...
src/main/java/com/bsth/service/impl/InoutCarparkServiceImpl.java 0 → 100644
  1 +package com.bsth.service.impl;
  2 +
  3 +import com.alibaba.fastjson.JSONArray;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.data.BasicData;
  6 +import com.bsth.entity.*;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import com.bsth.repository.*;
  9 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  10 +import com.bsth.service.InoutCarparkService;
  11 +import com.bsth.service.gps.GpsService;
  12 +import com.bsth.util.TransGPS;
  13 +import com.fasterxml.jackson.core.JsonProcessingException;
  14 +import com.fasterxml.jackson.databind.ObjectMapper;
  15 +import org.joda.time.DateTime;
  16 +import org.joda.time.format.DateTimeFormat;
  17 +import org.joda.time.format.DateTimeFormatter;
  18 +import org.slf4j.Logger;
  19 +import org.slf4j.LoggerFactory;
  20 +import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.stereotype.Service;
  22 +import org.springframework.transaction.annotation.Transactional;
  23 +
  24 +import javax.persistence.EntityManager;
  25 +import java.text.SimpleDateFormat;
  26 +import java.util.*;
  27 +
  28 +/**
  29 + * @author Hill
  30 + */
  31 +@Service
  32 +public class InoutCarparkServiceImpl extends BaseServiceImpl<LsInoutSectionRoute, Long> implements InoutCarparkService {
  33 +
  34 + private final static Logger logger = LoggerFactory.getLogger(InoutCarparkServiceImpl.class);
  35 +
  36 + @Autowired
  37 + private LsStationRouteRepository lsStationRouteRepository;
  38 +
  39 + @Autowired
  40 + private CarParkRepository carParkRepository;
  41 +
  42 + @Autowired
  43 + private LsInoutSectionRouteRepository lsInoutSectionRouteRepository;
  44 +
  45 + @Autowired
  46 + private SectionRepository sectionRepository;
  47 +
  48 + @Autowired
  49 + LineRepository lineRepository;
  50 +
  51 + @Autowired
  52 + private ScheduleRealInfoRepository scheduleRealInfoRepository;
  53 +
  54 + @Autowired
  55 + private GpsService gpsService;
  56 +
  57 + @Override
  58 + public Map<String, Object> getStartEndByLine(int lineId, int version) {
  59 + Map<String, Object> result = new HashMap<>(), data = new HashMap<>();
  60 + result.put("code", 0);
  61 + result.put("msg", "");
  62 + result.put("data", data);
  63 +
  64 + List<LsStationRoute> upRoutes = lsStationRouteRepository.findByLineVersion(lineId, version, 0), downRoutes = lsStationRouteRepository.findByLineVersion(lineId, version, 1);
  65 + CarPark carPark = carParkRepository.findByLineId(lineId);
  66 + if (carPark == null) {
  67 + result.put("code", 500);
  68 + result.put("msg", "线路标准信息中无相应的停车场信息");
  69 +
  70 + return result;
  71 + }
  72 + if (upRoutes.size() < 2) {
  73 + result.put("code", 500);
  74 + result.put("msg", "线路上行站级少于2");
  75 +
  76 + return result;
  77 + }
  78 + LsStationRoute upFirst = upRoutes.get(0), upLast = upRoutes.get(upRoutes.size() - 1);
  79 + LsStationRoute downFirst = downRoutes.get(0), downLast = downRoutes.get(downRoutes.size() - 1);
  80 + // 环线或双环线只需提取一个起点站
  81 + if (upFirst.getStationCode().equals(upLast.getStationCode())) {
  82 + data.put("start", new LsStationRoute[]{ upFirst });
  83 + data.put("end", new LsStationRoute[]{ upFirst });
  84 + } else {
  85 + if (downRoutes.size() < 2) {
  86 + result.put("code", 500);
  87 + result.put("msg", "非环线线路下行站级少于2");
  88 +
  89 + return result;
  90 + }
  91 + data.put("start", new LsStationRoute[]{ upFirst, downFirst });
  92 + data.put("end", new LsStationRoute[]{ upLast, downLast });
  93 + }
  94 + data.put("carpark", carPark);
  95 +
  96 + return result;
  97 + }
  98 +
  99 + @Override
  100 + public Map<String, Object> getRouteByStartEnd(int lineId, int version, String start, String end) {
  101 + Map<String, Object> result = new HashMap<>(), data = new HashMap<>();
  102 + result.put("code", 0);
  103 + result.put("msg", "");
  104 + result.put("data", data);
  105 + data.put("routes", lsInoutSectionRouteRepository.getRouteByStartEnd(lineId, version, start, end));
  106 +
  107 + return result;
  108 + }
  109 +
  110 + /**
  111 + * 新增路段信息
  112 + *
  113 + * @param map:<bsectionVector:折线百度坐标集合;dbType:圆坐标类型;descriptions:描述与说明;destroy:是否撤销;directions:方向;lineId:线路ID
  114 + *
  115 + * lineCode :线路编码;roadCoding:道路编码;sectionCode:路段编码;sectionDistance:路段长度;sectionName:路段名称;sectionTime:路段时长;
  116 + *
  117 + * sectionrouteCode:路段序号;speedLimit:路段限速>
  118 + *
  119 + * @return map<SUCCESS:成功;ERROR:异常>
  120 + */
  121 + @Override
  122 + @Transactional
  123 + public Map<String, Object> sectionSave(Map<String, Object> map) {
  124 + Map<String, Object> resultMap = new HashMap<String, Object>();
  125 + try {
  126 + // 线路ID.
  127 + Integer lineId = map.get("lineId").equals("") ? null : Integer.valueOf(map.get("lineId").toString());
  128 + // 线路编码.
  129 + String lineCode = map.get("lineCode").equals("") ? "" : map.get("lineCode").toString();
  130 + // 路段名称.
  131 + String sectionName = map.get("sectionName").equals("") ? "" : map.get("sectionName").toString();
  132 + // 路段编码.
  133 + String sectionCode = map.get("sectionCode").equals("") ? "" : map.get("sectionCode").toString();
  134 + // 道路编码.
  135 + String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
  136 + // 原始坐标类型.
  137 + String dbType = map.get("dbType").equals("") ? "" :map.get("dbType").toString();
  138 + // 路段几何图形坐标.
  139 + String sectionJSON = map.get("bsectionVector").equals("") ? "" : map.get("bsectionVector").toString();
  140 + // 路段序号
  141 + String sectionrouteCode = map.get("sectionrouteCode").equals("") ? "" : map.get("sectionrouteCode").toString();
  142 + // 路段时长.
  143 + Double sectionTime = map.get("sectionTime").equals("") ? 0.0d : Double.valueOf(map.get("sectionTime").toString());
  144 + // 路段距离.
  145 + Double sectionDistance = map.get("sectionDistance").equals("") ? 0.0d : Double.valueOf(map.get("sectionDistance").toString());
  146 + // 路段限速.
  147 + Double speedLimit = map.get("speedLimit").equals("") ? 0.0d : Double.valueOf(map.get("speedLimit").toString());
  148 + // 版本.
  149 + Integer versions = map.get("versions").equals("") ? 1 : Integer.valueOf(map.get("versions").toString());
  150 + // 是否撤销.
  151 + Integer destroy = map.get("destroy").equals("") ? 0 : Integer.valueOf(map.get("destroy").toString());
  152 + // 路段方向.
  153 + Integer directions = map.get("directions").equals("") ? 0 : Integer.valueOf(map.get("directions").toString());
  154 + // 描述与说明.
  155 + String descriptions = map.get("descriptions").equals("")? "" : map.get("descriptions").toString();
  156 + // 起始
  157 + String start = map.get("start").equals("")? "" : map.get("start").toString();
  158 + // 结束
  159 + String end = map.get("end").equals("")? "" : map.get("end").toString();
  160 + // 原始线状图形坐标集合
  161 + String sectionsBpoints = "";
  162 + // WGS线状图形坐标集合
  163 + String sectionsWJPpoints = "";
  164 + if(!sectionJSON.equals("")) {
  165 + // 转换成JSON数组
  166 + JSONArray sectionsArray = JSONArray.parseArray(sectionJSON);
  167 + // 遍历
  168 + for(int s = 0 ;s<sectionsArray.size();s++) {
  169 + String pointsLngStr = sectionsArray.getJSONObject(s).get("lng").toString();
  170 + String pointsLatStr = sectionsArray.getJSONObject(s).get("lat").toString();
  171 + String WGSLngStr = "";
  172 + String WGSLatStr = "";
  173 + TransGPS.Location resultPoint = FromBDPointToWGSPoint(pointsLngStr,pointsLatStr);
  174 + WGSLngStr = String.valueOf(resultPoint.getLng());
  175 + WGSLatStr = String.valueOf(resultPoint.getLat());
  176 + if(s==0) {
  177 + sectionsBpoints = pointsLngStr + " " + pointsLatStr;
  178 + sectionsWJPpoints = WGSLngStr + " " + WGSLatStr;
  179 + }else {
  180 + sectionsBpoints = sectionsBpoints + "," + pointsLngStr + " " + pointsLatStr;
  181 + sectionsWJPpoints = sectionsWJPpoints + "," + WGSLngStr + " " + WGSLatStr;
  182 + }
  183 + }
  184 + }
  185 + // WGS坐标点集合
  186 + String gsectionVector = "LINESTRING(" + sectionsWJPpoints +")";
  187 + // 原坐标点集合
  188 + String bsectionVector = "LINESTRING(" + sectionsBpoints + ")";
  189 + String crosesRoad="";
  190 + String endNode ="";
  191 + String startNode="";
  192 + String middleNode="";
  193 + String sectionType="";
  194 + String csectionVector=null;
  195 + Integer id = Integer.valueOf(sectionCode);
  196 + sectionRepository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode, middleNode, gsectionVector, bsectionVector, sectionType, csectionVector, roadCoding, sectionDistance, sectionTime, dbType, speedLimit, descriptions, versions, id);
  197 + Section section = sectionRepository.findById(id).get();
  198 +
  199 + Line line = lineRepository.findById(lineId).get();
  200 +
  201 +
  202 + if (map.get("status") == null || Integer.parseInt(map.get("status").toString()) != 0) {
  203 +
  204 + LsInoutSectionRoute sectionRoute = new LsInoutSectionRoute();
  205 + Integer routeCode = null;
  206 + if(!sectionrouteCode.equals("")){
  207 + String sectionrouteCodeArray[] = sectionrouteCode.split("_");
  208 + routeCode = Integer.valueOf(sectionrouteCodeArray[0])+1;
  209 + }else {
  210 + routeCode = 1;
  211 + }
  212 + sectionRoute.setSectionrouteCode(routeCode);
  213 + sectionRoute.setLineCode(lineCode);
  214 + sectionRoute.setSection(section);
  215 + sectionRoute.setSectionCode(sectionCode);
  216 + sectionRoute.setDirections(directions);
  217 + sectionRoute.setDescriptions(descriptions);
  218 + sectionRoute.setDestroy(destroy);
  219 + sectionRoute.setVersions(versions);
  220 + sectionRoute.setLine(line);
  221 + sectionRoute.setStart(start);
  222 + sectionRoute.setEnd(end);
  223 + lsInoutSectionRouteRepository.save(sectionRoute);
  224 + }
  225 +
  226 +
  227 + resultMap.put("status", ResponseCode.SUCCESS);
  228 + } catch (Exception e) {
  229 + resultMap.put("status", ResponseCode.ERROR);
  230 + logger.error("save erro.", e);
  231 + }
  232 + return resultMap;
  233 + }
  234 +
  235 + /** 百度坐标转WGS坐标 */
  236 + public TransGPS.Location FromBDPointToWGSPoint(String bLonx, String bLatx) {
  237 +
  238 + double lng = Double.parseDouble(bLonx);
  239 +
  240 + double lat = Double.parseDouble(bLatx);
  241 +
  242 + TransGPS.Location bdLoc = TransGPS.LocationMake(lng, lat);
  243 +
  244 + TransGPS.Location location = TransGPS.bd_decrypt(bdLoc);
  245 +
  246 + TransGPS.Location WGSPoint = TransGPS.transformFromGCJToWGS(location);
  247 +
  248 + return WGSPoint;
  249 +
  250 + }
  251 +
  252 + /**
  253 + * @Description :TODO(编辑线路走向)
  254 + *
  255 + * @param map <sectionId:路段ID; sectionJSON:路段信息>
  256 + *
  257 + * @return Map<String, Object> <SUCCESS ; ERROR>
  258 + */
  259 + @Override
  260 + @Transactional
  261 + public Map<String, Object> sectionUpdate(Map<String, Object> map) {
  262 + Map<String, Object> resultMap = new HashMap<String, Object>();
  263 + try {
  264 + String bsectionVector = map.get("bsectionVector").equals("") ? "" :map.get("bsectionVector").toString();
  265 + // 原始线状图形坐标集合
  266 + String sectionsBpoints = "";
  267 + // WGS线状图形坐标集合
  268 + String sectionsWJPpoints = "";
  269 + if(!bsectionVector.equals("")) {
  270 + // 转换成JSON数组
  271 + JSONArray sectionsArray = JSONArray.parseArray(bsectionVector);
  272 + // 遍历
  273 + for(int s = 0 ;s<sectionsArray.size();s++) {
  274 + String pointsLngStr = sectionsArray.getJSONObject(s).get("lng").toString();
  275 + String pointsLatStr = sectionsArray.getJSONObject(s).get("lat").toString();
  276 + /** to WGS坐标 */
  277 + TransGPS.Location resultPoint = FromBDPointToWGSPoint(pointsLngStr,pointsLatStr);
  278 + String WGSLngStr = String.valueOf(resultPoint.getLng());
  279 + String WGSLatStr = String.valueOf(resultPoint.getLat());
  280 + if(s==0) {
  281 + sectionsBpoints = pointsLngStr + " " + pointsLatStr;
  282 + sectionsWJPpoints = WGSLngStr + " " + WGSLatStr;
  283 + }else {
  284 + sectionsBpoints = sectionsBpoints + "," + pointsLngStr + " " + pointsLatStr;
  285 + sectionsWJPpoints = sectionsWJPpoints + "," + WGSLngStr + " " + WGSLatStr;
  286 + }
  287 + }
  288 + }
  289 + // 原坐标类型
  290 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  291 + // 说明
  292 + String descriptions = "";
  293 + // 是否撤销
  294 + Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString());
  295 + // 方向
  296 + Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString());
  297 + // 线路ID
  298 + Integer sectionRouteLine = map.get("sectionRouteLine").equals("") ? null : Integer.parseInt(map.get("sectionRouteLine").toString());
  299 + // 道路编码
  300 + String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
  301 + // 路段编码
  302 + String sectionCode = map.get("sectionCode").equals("") ? "" : map.get("sectionCode").toString();
  303 + // 路段长度
  304 + Double sectionDistance = map.get("sectionDistance").equals("") ? null : Double.valueOf(map.get("sectionDistance").toString());
  305 + // 路段ID
  306 + Integer sectionId = map.get("sectionId").equals("") ? 0 : Integer.parseInt(map.get("sectionId").toString());
  307 + // 路段名称
  308 + String sectionName = map.get("sectionName").equals("") ? "" : map.get("sectionName").toString();
  309 + // 路段路由Id
  310 + Long sectionRouteId = map.get("sectionRouteId").equals("") ? null : Long.valueOf(map.get("sectionRouteId").toString());
  311 + // 线路编码
  312 + String lineCode =map.get("lineCode").equals("") ? "" : map.get("lineCode").toString();
  313 + // 路段时长
  314 + Double sectionTime = map.get("sectionTime").equals("") ? null : Double.valueOf(map.get("sectionTime").toString());
  315 + // 路段路由
  316 + Integer sectionrouteCode = "".equals(map.get("sectionrouteCode")) ? null : Integer.valueOf(map.get("sectionrouteCode").toString());
  317 + // 限速
  318 + Double speedLimit = map.get("speedLimit").equals("") ? null : Double.valueOf(map.get("speedLimit").toString());
  319 + // 版本
  320 + Integer version = map.get("versions").equals("") ? null : Integer.valueOf(map.get("versions").toString());
  321 + // 起始
  322 + String start = map.get("start").equals("")? "" : map.get("start").toString();
  323 + // 结束
  324 + String end = map.get("end").equals("")? "" : map.get("end").toString();
  325 + // WGS坐标点集合
  326 + String gsectionVector = null;
  327 + if(!sectionsWJPpoints.equals("")) {
  328 + gsectionVector = "LINESTRING(" + sectionsWJPpoints +")";
  329 + }
  330 + // 原坐标点集合
  331 + String bsectionVectorS = null;
  332 + if(!sectionsBpoints.equals("")) {
  333 + bsectionVectorS = "LINESTRING(" + sectionsBpoints + ")";
  334 + }
  335 + Integer createBy = map.get("createBy").equals("") ? null : Integer.valueOf(map.get("createBy").toString());
  336 + String createDate = map.get("createDate").equals("") ? null : map.get("createDate").toString();
  337 + Integer updateBy = map.get("updateBy").equals("") ?null : Integer.valueOf(map.get("updateBy").toString());
  338 + SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
  339 + Date date = new Date();
  340 + // 修改日期
  341 + String updateDate = formatter.format(date);
  342 + String crosesRoad="";
  343 + String endNode="";
  344 + String startNode="";
  345 + String middleNode="";
  346 + String sectionType="";
  347 + // 更新
  348 + sectionRepository.sectionUpdate(sectionId, gsectionVector, bsectionVectorS, sectionCode, sectionName, crosesRoad, endNode, startNode, middleNode, sectionType, roadCoding, sectionDistance, sectionTime, dbType, speedLimit, descriptions, version, createBy, createDate, updateBy, updateDate);
  349 +
  350 + Line line = lineRepository.findById(sectionRouteLine).get();
  351 + Section section = sectionRepository.findById(sectionId).get();
  352 +
  353 + if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) != 0) {
  354 +
  355 + LsInoutSectionRoute resultS = lsInoutSectionRouteRepository.findById(sectionRouteId).get();
  356 + int old_code = resultS.getSectionrouteCode();
  357 + // 是否修改路段序号标记
  358 + boolean type = false;
  359 + if(sectionrouteCode!=null) {
  360 + if(++sectionrouteCode == old_code) {
  361 + type = true;
  362 + }
  363 + // 默认是最前面路段
  364 + }else {
  365 + sectionrouteCode = 1;
  366 + }
  367 + if(!type)
  368 + lsInoutSectionRouteRepository.sectionUpdSectionRouteCode(lineCode, version, start, end,sectionrouteCode);
  369 + LsInoutSectionRoute route = new LsInoutSectionRoute();
  370 + route.setId(sectionRouteId);
  371 + route.setSectionrouteCode(sectionrouteCode);
  372 + route.setLineCode(lineCode);
  373 + route.setSectionCode(sectionCode);
  374 + route.setDirections(directions);
  375 + route.setVersions(version);
  376 + route.setDestroy(destroy);
  377 + route.setCreateBy(createBy);
  378 + route.setUpdateBy(updateBy);
  379 + route.setSection(section);
  380 + route.setLine(line);
  381 + route.setStart(start);
  382 + route.setEnd(end);
  383 + lsInoutSectionRouteRepository.save(route);
  384 + }
  385 + resultMap.put("status", ResponseCode.SUCCESS);
  386 + } catch (Exception e) {
  387 + resultMap.put("status", ResponseCode.ERROR);
  388 + logger.error("save erro.", e);
  389 + }
  390 + return resultMap;
  391 + }
  392 +
  393 + @Override
  394 + public Map<String, Object> destroy(Map<String, Object> map) {
  395 + Map<String, Object> resultMap = new HashMap<String, Object>();
  396 + try {
  397 + long id = Long.parseLong(map.get("id").toString());
  398 +
  399 + if(map.get("status") == null || Integer.parseInt(map.get("status").toString()) != 0) {
  400 + lsInoutSectionRouteRepository.deleteById(id);
  401 + }
  402 + resultMap.put("status", ResponseCode.SUCCESS);
  403 + } catch (Exception e) {
  404 + resultMap.put("status", ResponseCode.ERROR);
  405 + logger.error("destroy erro.", e);
  406 + }
  407 + return resultMap;
  408 + }
  409 +
  410 + @Override
  411 + @Transactional
  412 + public void pathPlaningByHistory(long schId, int versions) throws JsonProcessingException {
  413 + ScheduleRealInfo scheduleRealInfo = scheduleRealInfoRepository.findById(schId).get();
  414 + DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  415 + DateTime start = formatter.parseDateTime(scheduleRealInfo.getRealExecDate() + scheduleRealInfo.getFcsjActual());
  416 + DateTime end = formatter.parseDateTime(scheduleRealInfo.getRealExecDate() + scheduleRealInfo.getZdsjActual());
  417 + if (start.isAfter(end)) {
  418 + end = end.plusDays(1);
  419 + }
  420 + Map<String, Object> map = gpsService.history(new String[]{ scheduleRealInfo.getClZbh() }, start.getMillis() / 1000 - 20, end.getMillis() / 1000 + 20);
  421 + List<Map<String, Object>> list = (List<Map<String, Object>>)map.get("list");
  422 + List<Map<String, Object>> bsectionVector = new ArrayList<>();
  423 + for (Map<String, Object> m : list) {
  424 + Map<String, Object> m1 = new HashMap<>();
  425 + Float lng = (Float)m.get("lon"), lat = (Float)m.get("lat");
  426 + if (lng == 0 || lat == 0) {
  427 + continue;
  428 + }
  429 + m1.put("lng", m.get("bd_lon"));
  430 + m1.put("lat", m.get("bd_lat"));
  431 + bsectionVector.add(m1);
  432 + }
  433 + map.clear();
  434 + map.put("lineId", scheduleRealInfo.getXlBm());
  435 + map.put("lineCode", scheduleRealInfo.getXlBm());
  436 + map.put("sectionName", scheduleRealInfo.getQdzName() + "-" + scheduleRealInfo.getZdzName());
  437 + map.put("sectionCode", sectionRepository.sectionMaxId() + 1);
  438 + map.put("roadCoding", "");
  439 + map.put("dbType", "b");
  440 + map.put("sectionrouteCode", "1");
  441 + map.put("sectionTime", "");
  442 + map.put("sectionDistance", "");
  443 + map.put("speedLimit", "60");
  444 + map.put("versions", versions);
  445 + map.put("destroy", 0);
  446 + map.put("directions", 3);
  447 + map.put("descriptions", "");
  448 + map.put("start", scheduleRealInfo.getQdzCode());
  449 + map.put("end", scheduleRealInfo.getZdzCode());
  450 + map.put("bsectionVector", new ObjectMapper().writeValueAsString(bsectionVector));
  451 +
  452 + lsInoutSectionRouteRepository.destroy(scheduleRealInfo.getXlBm(), versions, scheduleRealInfo.getQdzCode(), scheduleRealInfo.getZdzCode());
  453 + sectionSave(map);
  454 + }
  455 +}
... ...