Commit daa64c1cd964d2357a99b524c240a197915252f0

Authored by 王通
2 parents 95438552 00c4de1b

Merge branch 'pudong' into pudong_test

# Conflicts:
#	src/main/java/com/bsth/XDApplication.java
#	src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController_facade.java
#	src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
#	src/main/resources/datatools/ktrs/ttinfodetailoutputforedit.ktr
#	src/main/resources/dubbo/config-dev.properties
#	src/main/resources/dubbo/config-prod.properties

Too many changes to show.

To preserve performance only 15 of 92 files are displayed.

src/main/java/com/bsth/XDApplication.java
1   -package com.bsth;
2   -
3   -import com.bsth.data.BasicData;
4   -import com.bsth.data.LineVersionsData;
5   -import com.bsth.data.ThreadMonotor;
6   -import com.bsth.data.car_out_info.UpdateDBThread;
7   -import com.bsth.data.directive.DirectivesPstThread;
8   -import com.bsth.data.forecast.SampleTimeDataLoader;
9   -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
10   -import com.bsth.data.gpsdata_v2.thread.OfflineMonitorThread;
11   -import com.bsth.data.msg_queue.DirectivePushQueue;
12   -import com.bsth.data.msg_queue.WebSocketPushQueue;
13   -import com.bsth.data.safe_driv.SafeDrivDataLoadThread;
14   -import com.bsth.data.schedule.DayOfSchedule;
15   -import com.bsth.data.schedule.auto_exec.AutoExecScanThread;
16   -import com.bsth.data.schedule.e_state_check.thread.FixedCheckStationCodeThread;
17   -import com.bsth.data.schedule.edit_logs.SeiPstThread;
18   -import com.bsth.data.schedule.late_adjust.ScheduleLateThread;
19   -import com.bsth.data.schedule.signal.SchSiginUpdateDBThread;
20   -import com.bsth.data.schedule.thread.CalcOilThread;
21   -import com.bsth.data.schedule.thread.SchedulePstThread;
22   -import com.bsth.data.schedule.thread.ScheduleRefreshThread;
23   -import com.bsth.data.schedule.thread.SubmitToTrafficManage;
24   -import com.bsth.util.DateUtils;
25   -import com.bsth.util.Tools;
26   -import org.slf4j.Logger;
27   -import org.slf4j.LoggerFactory;
28   -import org.springframework.beans.factory.annotation.Autowired;
29   -import org.springframework.boot.CommandLineRunner;
30   -import org.springframework.stereotype.Component;
31   -
32   -import java.util.concurrent.ScheduledExecutorService;
33   -import java.util.concurrent.TimeUnit;
34   -
35   -/**
36   - * 线调大部分服务都在这里启动
37   - * Created by panzhao on 2017/5/14.
38   - */
39   -@Component
40   -public class XDApplication implements CommandLineRunner {
41   -
42   - Logger log = LoggerFactory.getLogger(this.getClass());
43   -
44   - @Autowired
45   - BasicData.BasicDataLoader basicDataLoader;
46   - @Autowired
47   - UpdateDBThread fcxxUpdateThread;
48   - @Autowired
49   - ScheduleRefreshThread scheduleRefreshThread;
50   - @Autowired
51   - SchedulePstThread schedulePstThread;
52   - @Autowired
53   - ScheduleLateThread scheduleLateThread;
54   - @Autowired
55   - SubmitToTrafficManage submitToTrafficManage;
56   - @Autowired
57   - CalcOilThread calcOilThread;
58   - @Autowired
59   - DirectivesPstThread directivesPstThread;
60   - @Autowired
61   - ThreadMonotor threadMonotor;
62   - @Autowired
63   - SeiPstThread seiPstThread;
64   - @Autowired
65   - SampleTimeDataLoader sampleTimeDataLoader;
66   - @Autowired
67   - SchSiginUpdateDBThread schSiginUpdateDBThread;
68   - @Autowired
69   - AutoExecScanThread autoExecScanThread;
70   -
71   - @Autowired
72   - GpsDataLoaderThread gpsDataLoader;
73   -
74   - @Autowired
75   - OfflineMonitorThread offlineMonitorThread;
76   -
77   - @Autowired
78   - LineVersionsData lineVersionsData;
79   -
80   - /*@Autowired
81   - FixedEnableVerionsThread fixedEnableVerionsThread;*/
82   -
83   - @Autowired
84   - SafeDrivDataLoadThread safeDrivDataLoadThread;
85   -
86   - @Autowired
87   - FixedCheckStationCodeThread fixedCheckStationCodeThread;
88   -
89   - private static long timeDiff;
90   - private static long timeDiffTraffic;
91   -
92   - static {
93   - // 早上2:20
94   - timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis();
95   - if (timeDiff < 0)
96   - timeDiff += (1000 * 60 * 60 * 24);
97   - // 早上07:00
98   - timeDiffTraffic = (DateUtils.getTimestamp() + 1000 * 60 * 60 * 7) - System.currentTimeMillis();
99   - if (timeDiffTraffic < 0)
100   - timeDiffTraffic += (1000 * 60 * 60 * 24);
101   - }
102   -
103   - @Override
104   - public void run(String... strings) throws Exception {
105   - try {
106   - Tools tools = new Tools("application.properties");
107   - String environment = tools.getValue("spring.profiles.active");
108   - //预先加载基础的对照数据
109   - basicDataLoader.loadAllData();
110   - switch (environment){
111   - case "dev":
112   - devInit();
113   - break;
114   - case "prod":
115   - prodInit();
116   - break;
117   - }
118   - }catch (Exception e){
119   - log.error("线调后台启动出现异常!!", e);
120   - System.exit(1);
121   - }
122   - }
123   -
124   - @Autowired
125   - DayOfSchedule dayOfSchedule;
126   - public void devInit(){
127   - log.info("devInit...");
128   - ScheduledExecutorService sexec = Application.mainServices;
129   - //抓取GPS数据
130   - gpsDataLoader.setFlag(-1);
131   - //dayOfSchedule.dataRecovery();
132   - //sexec.scheduleWithFixedDelay(gpsDataLoader, 60, 4, TimeUnit.SECONDS);
133   - //实际排班更新线程
134   - //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
135   - //sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 30, TimeUnit.SECONDS);//检查班次误点
136   - //sexec.scheduleWithFixedDelay(autoExecScanThread, 100, 50, TimeUnit.SECONDS);//班次自动执行
137   - //WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的
138   -
139   - //sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 50, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码
140   - //实际排班延迟入库线程
141   - //sexec.scheduleWithFixedDelay(schedulePstThread, 60, 15, TimeUnit.SECONDS);
142   - //班次修正日志延迟入库
143   - //sexec.scheduleWithFixedDelay(seiPstThread, 60, 30, TimeUnit.SECONDS);
144   - //调度指令延迟入库
145   - //sexec.scheduleWithFixedDelay(directivesPstThread, 180, 180, TimeUnit.SECONDS);
146   - //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
147   - //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);
148   -
149   - //安全驾驶
150   - //sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 40, 30, TimeUnit.SECONDS);
151   -
152   - //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 20, 60 * 2 , TimeUnit.SECONDS);
153   - }
154   -
155   - public void prodInit(){
156   - log.info("prodInit...");
157   - ScheduledExecutorService sexec = Application.mainServices;
158   - //安全驾驶
159   - sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS);
160   -
161   - /** 线调业务 */
162   - sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程
163   - sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 20, TimeUnit.SECONDS);//检查班次误点
164   - sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据
165   - sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 60, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码
166   -
167   - sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线
168   - sexec.scheduleWithFixedDelay(schedulePstThread, 180, 10, TimeUnit.SECONDS);//班次延迟入库线程
169   - sexec.scheduleWithFixedDelay(seiPstThread, 180, 60, TimeUnit.SECONDS);//班次修正日志入库
170   - sexec.scheduleWithFixedDelay(directivesPstThread, 120, 60, TimeUnit.SECONDS);//调度指令延迟入库
171   - sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
172   - sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据
173   - sexec.scheduleWithFixedDelay(basicDataLoader, 1, 1, TimeUnit.HOURS);//基础数据更新
174   - sexec.scheduleWithFixedDelay(autoExecScanThread, 180, 50, TimeUnit.SECONDS);//班次自动执行
175   - //DirectivePushQueue.start();//消息队列 -指令,系统下发的
176   - WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的
177   -
178   - /** 线调为其他程序提供的数据 --写入数据库 */
179   - //sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布)
180   - //线路首末班数据(网关用,班次更新时写入)
181   - //com.bsth.data.schedule.f_a_l.FirstAndLastHandler
182   - //sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号)
183   -
184   - //运管处静态数据提交
185   - //log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处");
186   - //sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
187   - //计算油、公里加注
188   - sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
189   -
190   - //线路版本更新
191   - sexec.scheduleWithFixedDelay(lineVersionsData, 60 * 5, 60 * 15, TimeUnit.SECONDS);
192   -
193   - //线路版本更新
194   - //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 60 * 4, 60 * 2 , TimeUnit.SECONDS);
195   - }
196   -}
  1 +package com.bsth;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.data.LineVersionsData;
  5 +import com.bsth.data.ThreadMonotor;
  6 +import com.bsth.data.car_out_info.UpdateDBThread;
  7 +import com.bsth.data.directive.DirectivesPstThread;
  8 +import com.bsth.data.forecast.SampleTimeDataLoader;
  9 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
  10 +import com.bsth.data.gpsdata_v2.thread.OfflineMonitorThread;
  11 +import com.bsth.data.msg_queue.DirectivePushQueue;
  12 +import com.bsth.data.msg_queue.WebSocketPushQueue;
  13 +import com.bsth.data.safe_driv.SafeDrivDataLoadThread;
  14 +import com.bsth.data.schedule.DayOfSchedule;
  15 +import com.bsth.data.schedule.auto_exec.AutoExecScanThread;
  16 +import com.bsth.data.schedule.e_state_check.thread.FixedCheckStationCodeThread;
  17 +import com.bsth.data.schedule.edit_logs.SeiPstThread;
  18 +import com.bsth.data.schedule.late_adjust.ScheduleLateThread;
  19 +import com.bsth.data.schedule.signal.SchSiginUpdateDBThread;
  20 +import com.bsth.data.schedule.thread.CalcOilThread;
  21 +import com.bsth.data.schedule.thread.SchedulePstThread;
  22 +import com.bsth.data.schedule.thread.ScheduleRefreshThread;
  23 +import com.bsth.data.schedule.thread.SubmitToTrafficManage;
  24 +import com.bsth.util.DateUtils;
  25 +import com.bsth.util.Tools;
  26 +import org.slf4j.Logger;
  27 +import org.slf4j.LoggerFactory;
  28 +import org.springframework.beans.factory.annotation.Autowired;
  29 +import org.springframework.boot.CommandLineRunner;
  30 +import org.springframework.stereotype.Component;
  31 +
  32 +import java.util.concurrent.ScheduledExecutorService;
  33 +import java.util.concurrent.TimeUnit;
  34 +
  35 +/**
  36 + * 线调大部分服务都在这里启动
  37 + * Created by panzhao on 2017/5/14.
  38 + */
  39 +@Component
  40 +public class XDApplication implements CommandLineRunner {
  41 +
  42 + Logger log = LoggerFactory.getLogger(this.getClass());
  43 +
  44 + @Autowired
  45 + BasicData.BasicDataLoader basicDataLoader;
  46 + @Autowired
  47 + UpdateDBThread fcxxUpdateThread;
  48 + @Autowired
  49 + ScheduleRefreshThread scheduleRefreshThread;
  50 + @Autowired
  51 + SchedulePstThread schedulePstThread;
  52 + @Autowired
  53 + ScheduleLateThread scheduleLateThread;
  54 + @Autowired
  55 + SubmitToTrafficManage submitToTrafficManage;
  56 + @Autowired
  57 + CalcOilThread calcOilThread;
  58 + @Autowired
  59 + DirectivesPstThread directivesPstThread;
  60 + @Autowired
  61 + ThreadMonotor threadMonotor;
  62 + @Autowired
  63 + SeiPstThread seiPstThread;
  64 + @Autowired
  65 + SampleTimeDataLoader sampleTimeDataLoader;
  66 + @Autowired
  67 + SchSiginUpdateDBThread schSiginUpdateDBThread;
  68 + @Autowired
  69 + AutoExecScanThread autoExecScanThread;
  70 +
  71 + @Autowired
  72 + GpsDataLoaderThread gpsDataLoader;
  73 +
  74 + @Autowired
  75 + OfflineMonitorThread offlineMonitorThread;
  76 +
  77 + @Autowired
  78 + LineVersionsData lineVersionsData;
  79 +
  80 + /*@Autowired
  81 + FixedEnableVerionsThread fixedEnableVerionsThread;*/
  82 +
  83 + @Autowired
  84 + SafeDrivDataLoadThread safeDrivDataLoadThread;
  85 +
  86 + @Autowired
  87 + FixedCheckStationCodeThread fixedCheckStationCodeThread;
  88 +
  89 + private static long timeDiff;
  90 + private static long timeDiffTraffic;
  91 +
  92 + static {
  93 + // 早上2:20
  94 + timeDiff = (DateUtils.getTimestamp() + 1000 * 60 * 140) - System.currentTimeMillis();
  95 + if (timeDiff < 0)
  96 + timeDiff += (1000 * 60 * 60 * 24);
  97 + // 早上07:00
  98 + timeDiffTraffic = (DateUtils.getTimestamp() + 1000 * 60 * 60 * 7) - System.currentTimeMillis();
  99 + if (timeDiffTraffic < 0)
  100 + timeDiffTraffic += (1000 * 60 * 60 * 24);
  101 + }
  102 +
  103 + @Override
  104 + public void run(String... strings) throws Exception {
  105 + try {
  106 + Tools tools = new Tools("application.properties");
  107 + String environment = tools.getValue("spring.profiles.active");
  108 + //预先加载基础的对照数据
  109 + basicDataLoader.loadAllData();
  110 + switch (environment){
  111 + case "dev":
  112 + devInit();
  113 + break;
  114 + case "prod":
  115 + prodInit();
  116 + break;
  117 + }
  118 + }catch (Exception e){
  119 + log.error("线调后台启动出现异常!!", e);
  120 + System.exit(1);
  121 + }
  122 + }
  123 +
  124 + @Autowired
  125 + DayOfSchedule dayOfSchedule;
  126 + public void devInit(){
  127 + log.info("devInit...");
  128 + ScheduledExecutorService sexec = Application.mainServices;
  129 + //抓取GPS数据
  130 + gpsDataLoader.setFlag(-1);
  131 + //dayOfSchedule.dataRecovery();
  132 + //sexec.scheduleWithFixedDelay(gpsDataLoader, 60, 4, TimeUnit.SECONDS);
  133 + //实际排班更新线程
  134 + //sexec.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS);
  135 + //sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 30, TimeUnit.SECONDS);//检查班次误点
  136 + //sexec.scheduleWithFixedDelay(autoExecScanThread, 100, 50, TimeUnit.SECONDS);//班次自动执行
  137 + //WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的
  138 +
  139 + //sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 50, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码
  140 + //实际排班延迟入库线程
  141 + //sexec.scheduleWithFixedDelay(schedulePstThread, 60, 15, TimeUnit.SECONDS);
  142 + //班次修正日志延迟入库
  143 + //sexec.scheduleWithFixedDelay(seiPstThread, 60, 30, TimeUnit.SECONDS);
  144 + //调度指令延迟入库
  145 + //sexec.scheduleWithFixedDelay(directivesPstThread, 180, 180, TimeUnit.SECONDS);
  146 + //线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
  147 + //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);
  148 +
  149 + //安全驾驶
  150 + //sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 40, 30, TimeUnit.SECONDS);
  151 +
  152 + //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 20, 60 * 2 , TimeUnit.SECONDS);
  153 + }
  154 +
  155 + public void prodInit(){
  156 + log.info("prodInit...");
  157 + ScheduledExecutorService sexec = Application.mainServices;
  158 + //安全驾驶
  159 + sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS);
  160 +
  161 + /** 线调业务 */
  162 + sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程
  163 + sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 20, TimeUnit.SECONDS);//检查班次误点
  164 + sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据
  165 + sexec.scheduleWithFixedDelay(fixedCheckStationCodeThread, 60, 60 * 5, TimeUnit.SECONDS);//检查班次站点编码
  166 +
  167 + sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线
  168 + sexec.scheduleWithFixedDelay(schedulePstThread, 180, 10, TimeUnit.SECONDS);//班次延迟入库线程
  169 + sexec.scheduleWithFixedDelay(seiPstThread, 180, 60, TimeUnit.SECONDS);//班次修正日志入库
  170 + sexec.scheduleWithFixedDelay(directivesPstThread, 120, 60, TimeUnit.SECONDS);//调度指令延迟入库
  171 + sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
  172 + sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据
  173 + sexec.scheduleWithFixedDelay(basicDataLoader, 1, 1, TimeUnit.HOURS);//基础数据更新
  174 + sexec.scheduleWithFixedDelay(autoExecScanThread, 180, 50, TimeUnit.SECONDS);//班次自动执行
  175 + //DirectivePushQueue.start();//消息队列 -指令,系统下发的
  176 + WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的
  177 +
  178 + /** 线调为其他程序提供的数据 --写入数据库 */
  179 + //sexec.scheduleWithFixedDelay(fcxxUpdateThread, 160, 30, TimeUnit.SECONDS);//发车信息(发车屏、信息发布)
  180 + //线路首末班数据(网关用,班次更新时写入)
  181 + //com.bsth.data.schedule.f_a_l.FirstAndLastHandler
  182 + //sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 160, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号)
  183 +
  184 + //运管处静态数据提交
  185 + //log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处");
  186 + //sexec.scheduleAtFixedRate(submitToTrafficManage, timeDiffTraffic / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
  187 + //计算油、公里加注
  188 + sexec.scheduleAtFixedRate(calcOilThread, timeDiff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);
  189 +
  190 + //线路版本更新
  191 + sexec.scheduleWithFixedDelay(lineVersionsData, 60 * 5, 60 * 15, TimeUnit.SECONDS);
  192 +
  193 + //线路版本更新
  194 + //sexec.scheduleWithFixedDelay(fixedEnableVerionsThread, 60 * 4, 60 * 2 , TimeUnit.SECONDS);
  195 + }
  196 +}
... ...
src/main/java/com/bsth/controller/oil/CwjyController.java
1 1 package com.bsth.controller.oil;
2 2  
3 3  
  4 +import java.io.File;
4 5 import java.util.Date;
5 6 import java.util.HashMap;
6 7 import java.util.List;
... ... @@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
11 12 import org.springframework.web.bind.annotation.RequestMethod;
12 13 import org.springframework.web.bind.annotation.RequestParam;
13 14 import org.springframework.web.bind.annotation.RestController;
  15 +import org.springframework.web.multipart.MultipartFile;
14 16  
15 17 import com.bsth.common.ResponseCode;
16 18 import com.bsth.controller.BaseController;
... ... @@ -22,6 +24,7 @@ import com.bsth.entity.sys.SysUser;
22 24 import com.bsth.security.util.SecurityUtils;
23 25 import com.bsth.service.oil.CwjyService;
24 26 import com.bsth.util.PageObject;
  27 +import com.google.common.io.Files;
25 28  
26 29 @RestController
27 30 @RequestMapping("cwjy")
... ... @@ -95,4 +98,23 @@ public class CwjyController extends BaseController&lt;Cwjy, Integer&gt;{
95 98 return maps;
96 99 }
97 100  
  101 + /*
  102 + * 场外加油导入
  103 + */
  104 + @RequestMapping(value = "/uploadFile",method = RequestMethod.POST)
  105 + public String uploadFile(MultipartFile file, String gsbm_, String gsName,
  106 + String fgsbm_, String fgsName) throws Exception{
  107 + Map<String, Object> map = new HashMap<String, Object>();
  108 + File newFile = new File(
  109 + getDataImportClasspath() + File.separator +
  110 + file.getOriginalFilename());
  111 + Files.write(file.getBytes(), newFile);
  112 + String result = service.importExcel(newFile, gsbm_, gsName);
  113 + return "{\"result\":" + "\""+result+"\"}";
  114 + }
  115 +
  116 + public String getDataImportClasspath(){
  117 + return this.getClass().getResource("/").getPath() + "/static/pages/oil";
  118 + }
  119 +
98 120 }
... ...
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
1   -package com.bsth.controller.realcontrol;
2   -
3   -import java.text.SimpleDateFormat;
4   -import java.util.Date;
5   -import java.util.HashMap;
6   -import java.util.List;
7   -import java.util.Map;
8   -
9   -import org.slf4j.Logger;
10   -import org.slf4j.LoggerFactory;
11   -import org.springframework.beans.factory.annotation.Autowired;
12   -import org.springframework.web.bind.annotation.RequestMapping;
13   -import org.springframework.web.bind.annotation.RequestParam;
14   -import org.springframework.web.bind.annotation.RestController;
15   -
16   -import com.bsth.common.ResponseCode;
17   -import com.bsth.data.directive.DayOfDirectives;
18   -import com.bsth.data.directive.DirectivesPstThread;
19   -import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
20   -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
21   -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
22   -import com.bsth.data.msg_queue.DirectivePushQueue;
23   -import com.bsth.data.msg_queue.WebSocketPushQueue;
24   -import com.bsth.data.pilot80.PilotReport;
25   -import com.bsth.data.schedule.DayOfSchedule;
26   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
27   -import com.bsth.websocket.handler.SendUtils;
28   -
29   -import ch.qos.logback.classic.Level;
30   -import ch.qos.logback.classic.LoggerContext;
31   -
32   -/**
33   - * Created by panzhao on 2017/4/14.
34   - */
35   -@RestController
36   -@RequestMapping("adminUtils")
37   -public class AdminUtilsController {
38   -
39   -
40   - Logger logger = LoggerFactory.getLogger(this.getClass());
41   -
42   - @Autowired
43   - DayOfSchedule dayOfSchedule;
44   -
45   - @Autowired
46   - GeoCacheData geoCacheData;
47   -
48   - @Autowired
49   - DayOfDirectives dayOfDirectives;
50   -
51   - @Autowired
52   - SendUtils sendUtils;
53   -
54   - @Autowired
55   - PilotReport pilotReport;
56   -
57   - /**
58   - * 出现重复班次的车辆
59   - *
60   - * @param
61   - * @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)
62   - * public void schRepeat(@RequestParam String nbbm){
63   - * logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
64   - * List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);
65   - * logger.info("检测前,车辆班次数量:" + list.size());
66   - * <p>
67   - * Map<Long, ScheduleRealInfo> map = new HashMap<>();
68   - * for(ScheduleRealInfo sch : list){
69   - * if(map.containsKey(sch.getId())){
70   - * logger.info("检测到重复ID: " + sch.getId());
71   - * }
72   - * map.put(sch.getId(), sch);
73   - * }
74   - * <p>
75   - * logger.info("检测后,车辆班次数量:" + list.size());
76   - * if(map.values().size() > 0){
77   - * dayOfSchedule.replaceByNbbm(nbbm, map.values());
78   - * }
79   - * }
80   - */
81   -
82   -/* @RequestMapping(value = "/directivePushQueue")
83   - public void directivePushQueue(){
84   - DirectivePushQueue.start();
85   - }*/
86   - @RequestMapping(value = "/directiveQueueSize")
87   - public void directiveQueueSize() {
88   - DirectivePushQueue.size();
89   - }
90   -
91   - /*@RequestMapping(value = "/webSocketPushQueue")
92   - public void webSocketPushQueue(){
93   - WebSocketPushQueue.start();
94   - }*/
95   -
96   - @RequestMapping(value = "/webSocketQueueSize")
97   - public void webSocketQueueSize() {
98   - WebSocketPushQueue.size();
99   - }
100   -
101   - @RequestMapping(value = "/setHttpFlag")
102   - public void setHttpFlag(@RequestParam int flag) {
103   - if (flag != 0 && flag != -1)
104   - return;
105   - GpsDataLoaderThread.setFlag(flag);
106   - }
107   -
108   - @RequestMapping(value = "/updateCacheBuff")
109   - public void updateCacheBuff() {
110   - geoCacheData.loadData();
111   - }
112   -
113   - @RequestMapping(value = "/reCalcLpSch")
114   - public void reCalcLpSch() {
115   - dayOfSchedule._test_reCalcLpSch();
116   - }
117   -
118   - @RequestMapping(value = "/findSchByLpName")
119   - public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) {
120   - return dayOfSchedule.getLpScheduleMap().get(lpName);
121   - }
122   -
123   - @RequestMapping(value = "/findSchByNbbm")
124   - public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) {
125   - return dayOfSchedule.findByNbbm(nbbm);
126   - }
127   -
128   - @RequestMapping(value = "/removeExecPlan")
129   - public int removeExecPlan(@RequestParam String nbbm) {
130   - dayOfSchedule.removeExecPlan(nbbm);
131   - return 1;
132   - }
133   -
134   - @RequestMapping(value = "/sch_re_calc_id_maps")
135   - public int reCalcIdMaps() {
136   - return dayOfSchedule.reCalcIdMaps();
137   - }
138   -
139   - @RequestMapping(value = "/sch_size_string")
140   - public String schSizeString() {
141   - return dayOfSchedule.sizeString();
142   - }
143   -
144   - @RequestMapping(value = "/containerSize")
145   - public Map<String, Integer> containerSize() {
146   - Map<String, Integer> rs = new HashMap<>();
147   - rs.put("60_size", dayOfDirectives.all60().size());
148   - rs.put("80_size", pilotReport.findAll().size());
149   - rs.put("nbbm_sch_size", dayOfSchedule.findAll().size());
150   - rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size());
151   - rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size());
152   - rs.put("pst_sch_size", dayOfSchedule.getPstSize());
153   - rs.put("speeds_size", OverspeedProcess.size());
154   - return rs;
155   - }
156   -
157   - @RequestMapping(value = "/websocketRadioText")
158   - public int radioText(String t, String lineCode) {
159   - sendUtils.sendRadioText(t, lineCode);
160   - return 0;
161   - }
162   -
163   - @Autowired
164   - DirectivesPstThread directivesPstThread;
165   -
166   - @RequestMapping(value = "/_sd_60_pst")
167   - public void sd_60_pst() {
168   - logger.info("手动入库指令....");
169   - directivesPstThread.run();
170   - }
171   -
172   - /**
173   - * 删除班次,删除内存中未清理掉的非当天的班次
174   - * @createDate 2019.05.13
175   - * @author zhangxianzhou
176   - * @param id 线路id
177   - * @return 被删除的班次信息
178   - */
179   - @RequestMapping("/deleteSchduleBC")
180   - public Map<String, Object> deleteSchduleBC(Long id) {
181   - Map<String, Object> rs = new HashMap<>();
182   - rs.put("status", ResponseCode.ERROR);
183   - ScheduleRealInfo sch = null;
184   - try {
185   - sch = dayOfSchedule.get(id);
186   - if (sch == null) {
187   - rs.put("msg", "无效的id号");
188   - return rs;
189   - }
190   -
191   - //内存中删除
192   - dayOfSchedule.deleteBC(sch);
193   - rs.put("delete", sch);
194   - rs.put("status", ResponseCode.SUCCESS);
195   -
196   - } catch (Exception e) {
197   - logger.error("", e);
198   - rs.put("msg", e.getMessage());
199   - sch.setDeleted(false);
200   - }
201   -
202   - return rs;
203   - }
204   -
205   - @RequestMapping("/changeLogLevel")
206   - public Map<String, Object> changeLogLevel(@RequestParam String level) {
207   - Map<String, Object> rs = new HashMap<>();
208   - rs.put("errCode", 1);
209   - LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
210   - context.getLogger("root").setLevel(Level.toLevel(level));
211   - rs.put("errCode", 0);
212   - rs.put("errMsg", "成功");
213   -
214   - return rs;
215   - }
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.*;
  5 +
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import com.bsth.common.ResponseCode;
  14 +import com.bsth.data.directive.DayOfDirectives;
  15 +import com.bsth.data.directive.DirectivesPstThread;
  16 +import com.bsth.data.gpsdata_v2.cache.GeoCacheData;
  17 +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess;
  18 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
  19 +import com.bsth.data.msg_queue.DirectivePushQueue;
  20 +import com.bsth.data.msg_queue.WebSocketPushQueue;
  21 +import com.bsth.data.pilot80.PilotReport;
  22 +import com.bsth.data.schedule.DayOfSchedule;
  23 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  24 +import com.bsth.websocket.handler.SendUtils;
  25 +
  26 +import ch.qos.logback.classic.Level;
  27 +import ch.qos.logback.classic.LoggerContext;
  28 +
  29 +/**
  30 + * Created by panzhao on 2017/4/14.
  31 + */
  32 +@RestController
  33 +@RequestMapping("adminUtils")
  34 +public class AdminUtilsController {
  35 +
  36 +
  37 + Logger logger = LoggerFactory.getLogger(this.getClass());
  38 +
  39 + @Autowired
  40 + DayOfSchedule dayOfSchedule;
  41 +
  42 + @Autowired
  43 + GeoCacheData geoCacheData;
  44 +
  45 + @Autowired
  46 + DayOfDirectives dayOfDirectives;
  47 +
  48 + @Autowired
  49 + SendUtils sendUtils;
  50 +
  51 + @Autowired
  52 + PilotReport pilotReport;
  53 +
  54 + /**
  55 + * 出现重复班次的车辆
  56 + *
  57 + * @param
  58 + * @RequestMapping(value = "/schRepeat", method = RequestMethod.POST)
  59 + * public void schRepeat(@RequestParam String nbbm){
  60 + * logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测...");
  61 + * List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm);
  62 + * logger.info("检测前,车辆班次数量:" + list.size());
  63 + * <p>
  64 + * Map<Long, ScheduleRealInfo> map = new HashMap<>();
  65 + * for(ScheduleRealInfo sch : list){
  66 + * if(map.containsKey(sch.getId())){
  67 + * logger.info("检测到重复ID: " + sch.getId());
  68 + * }
  69 + * map.put(sch.getId(), sch);
  70 + * }
  71 + * <p>
  72 + * logger.info("检测后,车辆班次数量:" + list.size());
  73 + * if(map.values().size() > 0){
  74 + * dayOfSchedule.replaceByNbbm(nbbm, map.values());
  75 + * }
  76 + * }
  77 + */
  78 +
  79 +/* @RequestMapping(value = "/directivePushQueue")
  80 + public void directivePushQueue(){
  81 + DirectivePushQueue.start();
  82 + }*/
  83 + @RequestMapping(value = "/directiveQueueSize")
  84 + public void directiveQueueSize() {
  85 + DirectivePushQueue.size();
  86 + }
  87 +
  88 + /*@RequestMapping(value = "/webSocketPushQueue")
  89 + public void webSocketPushQueue(){
  90 + WebSocketPushQueue.start();
  91 + }*/
  92 +
  93 + @RequestMapping(value = "/webSocketQueueSize")
  94 + public void webSocketQueueSize() {
  95 + WebSocketPushQueue.size();
  96 + }
  97 +
  98 + @RequestMapping(value = "/setHttpFlag")
  99 + public void setHttpFlag(@RequestParam int flag) {
  100 + if (flag != 0 && flag != -1)
  101 + return;
  102 + GpsDataLoaderThread.setFlag(flag);
  103 + }
  104 +
  105 + @RequestMapping(value = "/updateCacheBuff")
  106 + public void updateCacheBuff() {
  107 + geoCacheData.loadData();
  108 + }
  109 +
  110 + @RequestMapping(value = "/reCalcLpSch")
  111 + public void reCalcLpSch() {
  112 + dayOfSchedule._test_reCalcLpSch();
  113 + }
  114 +
  115 + @RequestMapping(value = "/findSchByLpName")
  116 + public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName) {
  117 + return dayOfSchedule.getLpScheduleMap().get(lpName);
  118 + }
  119 +
  120 + @RequestMapping(value = "/findSchByNbbm")
  121 + public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm) {
  122 + return dayOfSchedule.findByNbbm(nbbm);
  123 + }
  124 +
  125 + @RequestMapping(value = "/executeCurr")
  126 + public ScheduleRealInfo executeCurr(@RequestParam String nbbm) {
  127 + return dayOfSchedule.executeCurr(nbbm);
  128 + };
  129 +
  130 + @RequestMapping(value = "/reCalcExecPlan4Nbbm")
  131 + public void reCalcExecPlan4Nbbm(@RequestParam String nbbm) {
  132 + dayOfSchedule.reCalcExecPlan(nbbm);
  133 + };
  134 +
  135 + @RequestMapping(value = "/reCalcExecPlan4Line")
  136 + public void reCalcExecPlan4Line(@RequestParam String lineCode) {
  137 + Set<String> nbbms = dayOfSchedule.findCarByLineCode(lineCode);
  138 + for (String nbbm : nbbms) {
  139 + dayOfSchedule.reCalcExecPlan(nbbm);
  140 + }
  141 + };
  142 +
  143 + @RequestMapping(value = "/removeExecPlan")
  144 + public int removeExecPlan(@RequestParam String nbbm) {
  145 + dayOfSchedule.removeExecPlan(nbbm);
  146 + return 1;
  147 + }
  148 +
  149 + @RequestMapping(value = "/sch_re_calc_id_maps")
  150 + public int reCalcIdMaps() {
  151 + return dayOfSchedule.reCalcIdMaps();
  152 + }
  153 +
  154 + @RequestMapping(value = "/sch_size_string")
  155 + public String schSizeString() {
  156 + return dayOfSchedule.sizeString();
  157 + }
  158 +
  159 + @RequestMapping(value = "/containerSize")
  160 + public Map<String, Integer> containerSize() {
  161 + Map<String, Integer> rs = new HashMap<>();
  162 + rs.put("60_size", dayOfDirectives.all60().size());
  163 + rs.put("80_size", pilotReport.findAll().size());
  164 + rs.put("nbbm_sch_size", dayOfSchedule.findAll().size());
  165 + rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size());
  166 + rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size());
  167 + rs.put("pst_sch_size", dayOfSchedule.getPstSize());
  168 + rs.put("speeds_size", OverspeedProcess.size());
  169 + return rs;
  170 + }
  171 +
  172 + @RequestMapping(value = "/websocketRadioText")
  173 + public int radioText(String t, String lineCode) {
  174 + sendUtils.sendRadioText(t, lineCode);
  175 + return 0;
  176 + }
  177 +
  178 + @Autowired
  179 + DirectivesPstThread directivesPstThread;
  180 +
  181 + @RequestMapping(value = "/_sd_60_pst")
  182 + public void sd_60_pst() {
  183 + logger.info("手动入库指令....");
  184 + directivesPstThread.run();
  185 + }
  186 +
  187 + /**
  188 + * 删除班次,删除内存中未清理掉的非当天的班次
  189 + * @createDate 2019.05.13
  190 + * @author zhangxianzhou
  191 + * @param id 线路id
  192 + * @return 被删除的班次信息
  193 + */
  194 + @RequestMapping("/deleteSchduleBC")
  195 + public Map<String, Object> deleteSchduleBC(Long id) {
  196 + Map<String, Object> rs = new HashMap<>();
  197 + rs.put("status", ResponseCode.ERROR);
  198 + ScheduleRealInfo sch = null;
  199 + try {
  200 + sch = dayOfSchedule.get(id);
  201 + if (sch == null) {
  202 + rs.put("msg", "无效的id号");
  203 + return rs;
  204 + }
  205 +
  206 + //内存中删除
  207 + dayOfSchedule.deleteBC(sch);
  208 + rs.put("delete", sch);
  209 + rs.put("status", ResponseCode.SUCCESS);
  210 +
  211 + } catch (Exception e) {
  212 + logger.error("", e);
  213 + rs.put("msg", e.getMessage());
  214 + sch.setDeleted(false);
  215 + }
  216 +
  217 + return rs;
  218 + }
  219 +
  220 + @RequestMapping("/changeLogLevel")
  221 + public Map<String, Object> changeLogLevel(@RequestParam String level) {
  222 + Map<String, Object> rs = new HashMap<>();
  223 + rs.put("errCode", 1);
  224 + LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
  225 + context.getLogger("root").setLevel(Level.toLevel(level));
  226 + rs.put("errCode", 0);
  227 + rs.put("errMsg", "成功");
  228 +
  229 + return rs;
  230 + }
216 231 }
217 232 \ No newline at end of file
... ...
src/main/java/com/bsth/controller/realcontrol/ReportRegisterController.java
1   -package com.bsth.controller.realcontrol;
2   -
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONObject;
5   -import com.bsth.common.ResponseCode;
6   -import com.bsth.controller.BaseController;
7   -import com.bsth.data.report_register.ReportRegisterService;
8   -import com.bsth.data.report_register.entity.ReportRegister;
9   -import com.bsth.util.HttpClientUtils;
10   -import org.slf4j.Logger;
11   -import org.slf4j.LoggerFactory;
12   -import org.springframework.beans.factory.annotation.Autowired;
13   -import org.springframework.beans.propertyeditors.CustomDateEditor;
14   -import org.springframework.web.bind.WebDataBinder;
15   -import org.springframework.web.bind.annotation.InitBinder;
16   -import org.springframework.web.bind.annotation.PathVariable;
17   -import org.springframework.web.bind.annotation.RequestMapping;
18   -import org.springframework.web.bind.annotation.RequestMethod;
19   -import org.springframework.web.bind.annotation.RequestParam;
20   -import org.springframework.web.bind.annotation.RestController;
21   -import org.springframework.web.context.request.WebRequest;
22   -
23   -import java.text.DateFormat;
24   -import java.text.SimpleDateFormat;
25   -import java.util.Date;
26   -import java.util.HashMap;
27   -import java.util.Map;
28   -
29   -/**
30   - * 报备登记
31   - * Created by yrf on 2019/12/04.
32   - */
33   -@RestController
34   -@RequestMapping("reportRegister")
35   -public class ReportRegisterController extends BaseController<ReportRegister, Long>{
36   -
37   - Logger log = LoggerFactory.getLogger(this.getClass());
38   -
39   - final static String url = "http://114.80.178.13/complaint/TsReport/input.do";
40   -// final static String url = "http://192.168.168.228:8080/complaint/TsReport/input.do";
41   -
42   - @Autowired
43   - ReportRegisterService reportRegisterService;
44   -
45   - @InitBinder
46   - public void initBinder(WebDataBinder binder, WebRequest request) {
47   - //转换日期 注意这里的转化要和传进来的字符串的格式一直 如2015-9-9 就应该为yyyy-MM-dd
48   - DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
49   - binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));// CustomDateEditor为自定义日期编辑器
50   - }
51   -
52   -
53   - @RequestMapping(value = "/findList", method = RequestMethod.GET)
54   - public Map<String, Object> findList(@RequestParam Map<String, String> map) {
55   - return reportRegisterService.findList(map);
56   - }
57   -
58   - @RequestMapping(value = "/{id}", method = RequestMethod.GET)
59   - public ReportRegister findById(@PathVariable("id") Long id) {
60   - ReportRegister reportRegister = reportRegisterService.findById(id);
61   - return reportRegister;
62   - }
63   -
64   - @RequestMapping(value = "/delete", method = RequestMethod.POST)
65   - public Map<String, Object> deleteInfo(ReportRegister t) {
66   - Map<String, Object> map = new HashMap<>();
67   - try{
68   -// map = baseService.delete(id);
69   - reportRegisterService.deleteInfo(t);
70   - String data = "{ID:'"+t.getID()+"', STATUS:'2'}";
71   - StringBuilder sb = HttpClientUtils.post(url,data);
72   - JSONObject obj = JSON.parseObject(sb.toString());
73   - map.put("status2", obj);
74   - } catch (Exception e) {
75   - log.error(e.toString(), e);
76   - }
77   - return map;
78   - }
79   -
80   -
81   - @RequestMapping(method = RequestMethod.POST)
82   - public Map<String, Object> save(ReportRegister t) {
83   - Map<String, Object> map = new HashMap<>();
84   - try{
85   - reportRegisterService.save(t);
86   - map.put("status", ResponseCode.SUCCESS);
87   - map.put("t", t);
88   - StringBuilder sb = HttpClientUtils.post(url,t.toString());
89   - JSONObject obj = JSON.parseObject(sb.toString());
90   - map.put("status2", obj);
91   - } catch (Exception e) {
92   - log.error(e.toString(), e);
93   - }
94   - return map;
95   - }
96   -}
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.bsth.common.ResponseCode;
  6 +import com.bsth.controller.BaseController;
  7 +import com.bsth.data.report_register.ReportRegisterService;
  8 +import com.bsth.data.report_register.entity.ReportRegister;
  9 +import com.bsth.util.HttpClientUtils;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.beans.propertyeditors.CustomDateEditor;
  14 +import org.springframework.web.bind.WebDataBinder;
  15 +import org.springframework.web.bind.annotation.InitBinder;
  16 +import org.springframework.web.bind.annotation.PathVariable;
  17 +import org.springframework.web.bind.annotation.RequestMapping;
  18 +import org.springframework.web.bind.annotation.RequestMethod;
  19 +import org.springframework.web.bind.annotation.RequestParam;
  20 +import org.springframework.web.bind.annotation.RestController;
  21 +import org.springframework.web.context.request.WebRequest;
  22 +
  23 +import java.text.DateFormat;
  24 +import java.text.SimpleDateFormat;
  25 +import java.util.Date;
  26 +import java.util.HashMap;
  27 +import java.util.Map;
  28 +
  29 +/**
  30 + * 报备登记
  31 + * Created by yrf on 2019/12/04.
  32 + */
  33 +@RestController
  34 +@RequestMapping("reportRegister")
  35 +public class ReportRegisterController extends BaseController<ReportRegister, Long>{
  36 +
  37 + Logger log = LoggerFactory.getLogger(this.getClass());
  38 +
  39 + final static String url = "http://114.80.178.13/complaint/TsReport/input.do";
  40 +// final static String url = "http://192.168.168.228:8080/complaint/TsReport/input.do";
  41 +
  42 + @Autowired
  43 + ReportRegisterService reportRegisterService;
  44 +
  45 + @InitBinder
  46 + public void initBinder(WebDataBinder binder, WebRequest request) {
  47 + //转换日期 注意这里的转化要和传进来的字符串的格式一直 如2015-9-9 就应该为yyyy-MM-dd
  48 + DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  49 + binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));// CustomDateEditor为自定义日期编辑器
  50 + }
  51 +
  52 +
  53 + @RequestMapping(value = "/findList", method = RequestMethod.GET)
  54 + public Map<String, Object> findList(@RequestParam Map<String, String> map) {
  55 + return reportRegisterService.findList(map);
  56 + }
  57 +
  58 + @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  59 + public ReportRegister findById(@PathVariable("id") Long id) {
  60 + ReportRegister reportRegister = reportRegisterService.findById(id);
  61 + return reportRegister;
  62 + }
  63 +
  64 + @RequestMapping(value = "/delete", method = RequestMethod.POST)
  65 + public Map<String, Object> deleteInfo(ReportRegister t) {
  66 + Map<String, Object> map = new HashMap<>();
  67 + try{
  68 +// map = baseService.delete(id);
  69 + reportRegisterService.deleteInfo(t);
  70 + String data = "{ID:'"+t.getID()+"', STATUS:'2'}";
  71 + StringBuilder sb = HttpClientUtils.post(url,data);
  72 + JSONObject obj = JSON.parseObject(sb.toString());
  73 + map.put("status2", obj);
  74 + } catch (Exception e) {
  75 + log.error(e.toString(), e);
  76 + }
  77 + return map;
  78 + }
  79 +
  80 +
  81 + @RequestMapping(method = RequestMethod.POST)
  82 + public Map<String, Object> save(ReportRegister t) {
  83 + Map<String, Object> map = new HashMap<>();
  84 + try{
  85 + reportRegisterService.save(t);
  86 + map.put("status", ResponseCode.SUCCESS);
  87 + map.put("t", t);
  88 + StringBuilder sb = HttpClientUtils.post(url,t.toString());
  89 + JSONObject obj = JSON.parseObject(sb.toString());
  90 + map.put("status2", obj);
  91 + } catch (Exception e) {
  92 + log.error(e.toString(), e);
  93 + }
  94 + return map;
  95 + }
  96 +}
... ...
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
1   -package com.bsth.controller.realcontrol;
2   -
3   -import java.util.ArrayList;
4   -import java.util.Arrays;
5   -import java.util.Collection;
6   -import java.util.HashMap;
7   -import java.util.List;
8   -import java.util.Map;
9   -
10   -import org.apache.commons.lang3.StringEscapeUtils;
11   -import org.joda.time.format.DateTimeFormat;
12   -import org.joda.time.format.DateTimeFormatter;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.web.bind.annotation.PathVariable;
15   -import org.springframework.web.bind.annotation.RequestMapping;
16   -import org.springframework.web.bind.annotation.RequestMethod;
17   -import org.springframework.web.bind.annotation.RequestParam;
18   -import org.springframework.web.bind.annotation.RestController;
19   -
20   -import com.alibaba.fastjson.JSONArray;
21   -import com.bsth.common.ResponseCode;
22   -import com.bsth.controller.BaseController;
23   -import com.bsth.controller.realcontrol.dto.ChangePersonCar;
24   -import com.bsth.controller.realcontrol.dto.DfsjChange;
25   -import com.bsth.data.BasicData;
26   -import com.bsth.data.schedule.DayOfSchedule;
27   -import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
28   -import com.bsth.entity.realcontrol.ScheduleRealInfo;
29   -import com.bsth.entity.report.RepairReport;
30   -import com.bsth.entity.schedule.SchedulePlanInfo;
31   -import com.bsth.service.realcontrol.ScheduleRealInfoService;
32   -
33   -@RestController
34   -@RequestMapping("/realSchedule")
35   -public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {
36   -
37   - @Autowired
38   - ScheduleRealInfoService scheduleRealInfoService;
39   -
40   - @Autowired
41   - DayOfSchedule dayOfSchedule;
42   -
43   - @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST)
44   - public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){
45   - return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm);
46   - }
47   -
48   - @RequestMapping(value = "/lines")
49   - public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) {
50   - return scheduleRealInfoService.findByLines(lines);
51   - }
52   -
53   - @RequestMapping(value = "/car")
54   - public List<ScheduleRealInfo> findByCar(String nbbm){
55   - return dayOfSchedule.findByNbbm(nbbm);
56   - }
57   -
58   - /**
59   - *
60   - * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id
61   - * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws
62   - */
63   - @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)
64   - public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,
65   - @RequestParam String dfsj,String bcType,
66   - @RequestParam(defaultValue = "") String opType) {
67   - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType, opType, null);
68   - }
69   -
70   - /**
71   - *
72   - * @Title: destroy @Description: TODO(销毁,烂班) @param @param idsStr 要烂掉的班次ID ,分隔
73   - */
74   - @RequestMapping(value = "/destroy", method = RequestMethod.POST)
75   - public Map<String, Object> destroy(@RequestParam String idsStr
76   - /*, @RequestParam(defaultValue = "-1") int spaceAdjust*/,
77   - @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {
78   - return scheduleRealInfoService.destroy(idsStr, remarks, adjustExps, null);
79   - }
80   -
81   - /**
82   - *
83   - * @Title: carDeviceMapp @Description: TODO(获取车辆自编号和设备号对照,从缓存取) @throws
84   - */
85   - @RequestMapping(value = "/carDeviceMapp", method = RequestMethod.GET)
86   - public Map<String, String> carDeviceMapp() {
87   - return BasicData.deviceId2NbbmMap.inverse();
88   - }
89   -
90   - /**
91   - *
92   - * @Title: findPersionByLine @Description: TODO(根据线路主键获取驾驶员) @param @param
93   - * lineId @throws
94   - */
95   - @RequestMapping(value = "/driver", method = RequestMethod.GET)
96   - public List<Map<String, String>> findDriverByLine(@RequestParam String lineCode) {
97   - return scheduleRealInfoService.findDriverByLine(lineCode);
98   - }
99   -
100   - /**
101   - *
102   - * @Title: findPersionByLine @Description: TODO(根据线路主键获取售票员) @param @param
103   - * lineId @throws
104   - */
105   - @RequestMapping(value = "/conductor", method = RequestMethod.GET)
106   - public List<Map<String, String>> findConductorByLine(@RequestParam String lineCode) {
107   - return scheduleRealInfoService.findConductorByLine(lineCode);
108   - }
109   -
110   - /**
111   - *
112   - * @Title: findPersionByLine @Description: TODO(根据线路主键获取车辆) @param @param
113   - * lineId @throws
114   - */
115   - @RequestMapping(value = "/cars", method = RequestMethod.GET)
116   - public List<Map<String, String>> findCarByLine(@RequestParam String lineCode) {
117   - return scheduleRealInfoService.findCarByLine(lineCode);
118   - }
119   -
120   - /**
121   - *
122   - * @Title: sreachNbbm @Description: TODO(搜索车辆内部编码) @throws
123   - */
124   - @RequestMapping(value = "/sreachVehic", method = RequestMethod.GET)
125   - public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) {
126   - return scheduleRealInfoService.sreachVehic(nbbm);
127   - }
128   - /**
129   - *
130   - * @Title: realOutAdjust
131   - * @Description: TODO(实发调整)
132   - * @param @param id 班次ID
133   - * @param @param fcsjActual 实际发车时间 HH:mm
134   - * @param @param remarks 备注
135   - * @throws
136   - */
137   - @RequestMapping(value = "/realOutAdjust", method = RequestMethod.POST)
138   - public Map<String, Object> realOutAdjust(@RequestParam Map<String, String> map) {
139   - return scheduleRealInfoService.realOutAdjust(map);
140   - }
141   -
142   - /**
143   - *
144   - * @Title: revokeDestroy
145   - * @Description: TODO(撤销烂班)
146   - * @param @param id
147   - * @throws
148   - */
149   - @RequestMapping(value = "/revokeDestroy", method = RequestMethod.POST)
150   - public Map<String, Object> revokeDestroy(@RequestParam Long id){
151   - return scheduleRealInfoService.revokeDestroy(id);
152   - }
153   -
154   - /**
155   - *
156   - * @Title: revokeRealOutgo
157   - * @Description: TODO(撤销实发)
158   - * @param @param id
159   - * @throws
160   - */
161   - @RequestMapping(value = "/revokeRealOutgo", method = RequestMethod.POST)
162   - public Map<String, Object> revokeRealOutgo(@RequestParam Long id){
163   - return scheduleRealInfoService.revokeRealOutgo(id);
164   - }
165   -
166   - /**
167   - * 撤销执行
168   - * @param id
169   - * @return
170   - */
171   - @RequestMapping(value = "/revokeRealArrive", method = RequestMethod.POST)
172   - public Map<String, Object> revokeRealArrive(@RequestParam Long id){
173   - return scheduleRealInfoService.revokeRealArrive(id);
174   - }
175   -
176   - /**
177   - *
178   - * @Title: spaceAdjust
179   - * @Description: TODO(间隔调整)
180   - * @param @param ids 要调整的班次数组ID
181   - * @param @param space 间隔
182   - * @throws
183   - */
184   - @RequestMapping(value = "/spaceAdjust", method = RequestMethod.POST)
185   - public Map<String, Object> spaceAdjust(Long[] ids, Integer space){
186   - return scheduleRealInfoService.spaceAdjust(ids, space);
187   - }
188   -
189   - /**
190   - *
191   - * @Title: schInfoFineTune
192   - * @Description: TODO(发车信息微调)
193   - * @param @param map
194   - * @throws
195   - */
196   - @RequestMapping(value = "/schInfoFineTune", method = RequestMethod.POST)
197   - public Map<String, Object> schInfoFineTune(@RequestParam Map<String, String> map){
198   - return scheduleRealInfoService.schInfoFineTune(map);
199   - }
200   -
201   - /**
202   - *
203   - * @Title: outgoAdjustAll
204   - * @Description: TODO(批量待发调整)
205   - * @param @param list
206   - * @throws
207   - */
208   - @RequestMapping(value = "/outgoAdjustAll", method = RequestMethod.POST)
209   - public Map<String, Object> outgoAdjustAll(@RequestParam String params){
210   - //反转义
211   - params = StringEscapeUtils.unescapeHtml4(params);
212   - return scheduleRealInfoService.outgoAdjustAll(params);
213   - }
214   -
215   - /**
216   - *
217   - * @Title: findByLineAndUpDown
218   - * @Description: TODO(根据线路和走向获取班次)
219   - * @param @param line
220   - * @param @param upDown
221   - */
222   - @RequestMapping(value = "/findByLineAndUpDown")
223   - public List<ScheduleRealInfo> findByLineAndUpDown(@RequestParam String line,@RequestParam Integer upDown){
224   - return dayOfSchedule.findByLineAndUpDown(line, upDown);
225   - }
226   -
227   - /**
228   - *
229   - * @Title: findRouteByLine
230   - * @Description: TODO(获取线路的站点,路段路由)
231   - * @param @param lineCode
232   - * @throws
233   - */
234   - @RequestMapping(value = "/findRouteByLine")
235   - public Map<String, Object> findRouteByLine(@RequestParam String lineCode){
236   - return scheduleRealInfoService.findRouteByLine(lineCode);
237   - }
238   -
239   - /**
240   - *
241   - * @Title: removeChildTask
242   - * @Description: TODO(删除子任务)
243   - * @param @param taskId 子任务ID
244   - * @throws
245   - */
246   - @RequestMapping(value = "/childTask/{taskId}", method = RequestMethod.DELETE)
247   - public Map<String, Object> removeChildTask(@PathVariable("taskId") Long taskId){
248   - return scheduleRealInfoService.removeChildTask(taskId);
249   - }
250   -
251   - /**
252   - *
253   - * @Title: findByLineCode
254   - * @Description: TODO(根据线路获取班次信息)
255   - * @param @param lineCode
256   - */
257   - @RequestMapping(value = "/lineCode/{lineCode}")
258   - public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){
259   - return dayOfSchedule.findByLineCode(lineCode);
260   - }
261   -
262   - @RequestMapping(value = "/queryUserInfo")
263   - public List<ScheduleRealInfo> queryUserInfo(@RequestParam String line,
264   - @RequestParam String date,@RequestParam String state) {
265   - return scheduleRealInfoService.queryUserInfo(line, date,state);
266   - }
267   -
268   - @RequestMapping(value = "/queryUserInfoPx")
269   - public List<ScheduleRealInfo> queryUserInfoPx(@RequestParam String line,
270   - @RequestParam String date,@RequestParam String state,@RequestParam String type) {
271   - return scheduleRealInfoService.queryUserInfoPx(line, date,state,type);
272   - }
273   -
274   - @RequestMapping(value = "/exportWaybill",method = RequestMethod.GET)
275   - public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName,@RequestParam String jGh, @RequestParam String clZbh,
276   - @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {
277   - return scheduleRealInfoService.exportWaybill(jName,jGh, clZbh, lpName,date,line);
278   - }
279   -
280   - @RequestMapping(value = "/exportWaybillQp",method = RequestMethod.GET)
281   - public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh
282   - ,@RequestParam String date,@RequestParam String line) {
283   - return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);
284   - }
285   -
286   -
287   - @RequestMapping(value = "/dailyInfo")
288   - public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {
289   - return scheduleRealInfoService.dailyInfo(line, date, type);
290   - }
291   -
292   - @RequestMapping(value = "/historyMessage")
293   - public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date,
294   - @RequestParam String code, @RequestParam String type) {
295   - return scheduleRealInfoService.historyMessage(line, date, code, type);
296   - }
297   -
298   - @RequestMapping(value="/findLine")
299   - public List<Map<String,String>> findLine(@RequestParam String line){
300   - return scheduleRealInfoService.findLine(line);
301   - }
302   -
303   - @RequestMapping(value="/findKMBC",method = RequestMethod.GET)
304   - public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
305   - ,@RequestParam String date,@RequestParam String line){
306   - return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);
307   - }
308   -
309   - /**
310   - * 路单公里统计 (闵行审计专用)
311   - * @param jGh
312   - * @param clZbh
313   - * @param lpName
314   - * @param date
315   - * @param line
316   - * @return
317   - */
318   - @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)
319   - public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
320   - ,@RequestParam String date,@RequestParam String line){
321   - return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);
322   - }
323   -
324   - @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
325   - public Map<String,Object> findKMBCQp(@RequestParam String clZbh
326   - ,@RequestParam String date,@RequestParam String line){
327   - return scheduleRealInfoService.findKMBCQp(clZbh,date,line);
328   - }
329   -
330   - @RequestMapping(value="/findLpName")
331   - public List<Map<String,String>> findLpName(@RequestParam String lpName){
332   - return scheduleRealInfoService.findLpName(lpName);
333   - }
334   -
335   - @RequestMapping(value = "/account")
336   - public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date,
337   - @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {
338   - return scheduleRealInfoService.account(line, date, code, xlName, type);
339   - }
340   -
341   - @RequestMapping(value = "/accountPx")
342   - public List<Map<String,Object>> accountPx(@RequestParam String line, @RequestParam String date,
343   - @RequestParam String code,@RequestParam String xlName, @RequestParam String px) {
344   - return scheduleRealInfoService.accountPx(line, date, code, xlName, px);
345   - }
346   -
347   - @RequestMapping(value = "/correctForm")
348   - public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,
349   - @RequestParam String endDate,
350   - @RequestParam String lpName, @RequestParam String code,
351   - @RequestParam String type,@RequestParam String changType) {
352   - return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);
353   - }
354   - /**
355   - * @Title queryListWaybill
356   - * @Description 查询行车路单列表
357   - * @param jName 驾驶员名字
358   - * @param clZbh 车辆自编号(内部编号)
359   - * @param lpName 路牌
360   - * @return
361   - */
362   - @RequestMapping(value="/queryListWaybill",method = RequestMethod.GET)
363   - public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
364   - ,@RequestParam String date,@RequestParam String line){
365   - return scheduleRealInfoService.queryListWaybill(jGh, clZbh,lpName,date,line);
366   - }
367   -
368   - /**
369   - * @Title queryListWaybill
370   - * @Description 查询行车路单列表(闵行审计专用路单)
371   - * @param jName 驾驶员名字
372   - * @param clZbh 车辆自编号(内部编号)
373   - * @param lpName 路牌
374   - * @return
375   - */
376   - @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)
377   - public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
378   - ,@RequestParam String date,@RequestParam String line){
379   - return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);
380   - }
381   -
382   - @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)
383   - public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,
384   - @RequestParam String date,@RequestParam String line){
385   - return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);
386   - }
387   -
388   - @RequestMapping(value="/statisticsDaily")
389   - public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date,
390   - @RequestParam String xlName, @RequestParam String type){
391   - return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);
392   - }
393   -
394   - @RequestMapping(value="/statisticsDaily_mh_2")
395   - public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,
396   - @RequestParam String xlName, @RequestParam String type){
397   - return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);
398   - }
399   -
400   - @RequestMapping(value="/statisticsDailyTj")
401   - public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
402   - String gsdm="";
403   - if(map.get("gsdm")!=null){
404   - gsdm=map.get("gsdm").toString();
405   - }
406   - String fgsdm="";
407   - if(map.get("fgsdm")!=null){
408   - fgsdm=map.get("fgsdm").toString();
409   - }
410   - String line="";
411   - if(map.get("line")!=null){
412   - line=map.get("line").toString();
413   - }
414   - String date="";
415   - if(map.get("date")!=null){
416   - date=map.get("date").toString();
417   - }
418   - String date2="";
419   - if(map.get("date2")!=null){
420   - date2=map.get("date2").toString();
421   - }
422   - String xlName="";
423   - if(map.get("xlName")!=null){
424   - xlName=map.get("xlName").toString();
425   - }
426   - String type="";
427   - if(map.get("type")!=null){
428   - type=map.get("type").toString();
429   - }
430   - String nature="0";
431   - if(map.get("nature")!=null){
432   - nature=map.get("nature").toString();
433   - }
434   - return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type,nature);
435   - }
436   -
437   - /*
438   - * 公里修正报表
439   - */
440   - @RequestMapping(value="/mileageReportTj")
441   - public List<Map<String,Object>> mileageReport(@RequestParam Map<String, Object> map){
442   - String gsdm="";
443   - if(map.get("gsdm")!=null){
444   - gsdm=map.get("gsdm").toString();
445   - }
446   - String fgsdm="";
447   - if(map.get("fgsdm")!=null){
448   - fgsdm=map.get("fgsdm").toString();
449   - }
450   - String line="";
451   - if(map.get("line")!=null){
452   - line=map.get("line").toString();
453   - }
454   - String date="";
455   - if(map.get("date")!=null){
456   - date=map.get("date").toString();
457   - }
458   - String date2="";
459   - if(map.get("date2")!=null){
460   - date2=map.get("date2").toString();
461   - }
462   - String xlName="";
463   - if(map.get("xlName")!=null){
464   - xlName=map.get("xlName").toString();
465   - }
466   - return scheduleRealInfoService.mileageReport(gsdm,fgsdm,line, date,date2);
467   - }
468   -
469   - /*
470   - * 班次修正报表
471   - */
472   - @RequestMapping(value="/scheduleCorrectionReport")
473   - public List<Map<String,Object>> scheduleCorrectionReport(@RequestParam Map<String, Object> map){
474   - String gsdm="";
475   - if(map.get("gsdm")!=null){
476   - gsdm=map.get("gsdm").toString();
477   - }
478   - String fgsdm="";
479   - if(map.get("fgsdm")!=null){
480   - fgsdm=map.get("fgsdm").toString();
481   - }
482   - String line="";
483   - if(map.get("line")!=null){
484   - line=map.get("line").toString();
485   - }
486   - String date="";
487   - if(map.get("date")!=null){
488   - date=map.get("date").toString();
489   - }
490   - String date2="";
491   - if(map.get("date2")!=null){
492   - date2=map.get("date2").toString();
493   - }
494   - String xlName="";
495   - if(map.get("xlName")!=null){
496   - xlName=map.get("xlName").toString();
497   - }
498   - return scheduleRealInfoService.scheduleCorrectionReport(gsdm,fgsdm,line, date,date2);
499   - }
500   -
501   - @RequestMapping(value="/MapById",method = RequestMethod.GET)
502   - public Map<String, Object> MapById(@RequestParam("id") Long id){
503   - return scheduleRealInfoService.MapById(id);
504   - }
505   -
506   - @RequestMapping(value="/MapByIdQp",method = RequestMethod.GET)
507   - public Map<String, Object> MapByIdQp(@RequestParam("id") Long id){
508   - return scheduleRealInfoService.MapByIdQp(id);
509   - }
510   -
511   - /**
512   - * @Title: scheduleDaily
513   - * @Description: TODO(调度日报表)
514   - * @param line 线路
515   - * @param date 时间
516   - * @return
517   - */
518   - @RequestMapping(value="/scheduleDaily")
519   - public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
520   - return scheduleRealInfoService.scheduleDaily(line,date);
521   - }
522   -
523   - @RequestMapping(value="/realScheduleList")
524   - public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){
525   - return scheduleRealInfoService.realScheduleList(line,date);
526   - }
527   -
528   - @RequestMapping(value="/realScheduleList_zrw")
529   - public List<ScheduleRealInfo> realScheduleList_zrw(@RequestParam String line,@RequestParam String date){
530   - return scheduleRealInfoService.realScheduleList_zrw(line,date);
531   - }
532   -
533   - @RequestMapping(value="/realScheduleList_mh_2")
534   - public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){
535   - return scheduleRealInfoService.realScheduleList_mh_2(line,date);
536   - }
537   -
538   - @RequestMapping(value="/realScheduleListQp")
539   - public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){
540   - return scheduleRealInfoService.realScheduleListQp(line,date);
541   - }
542   -
543   - @RequestMapping(value="/multi_tzrc", method=RequestMethod.POST)
544   - public Map<String, Object> multi_tzrc(@RequestParam String cpcsJson){
545   - cpcsJson = StringEscapeUtils.unescapeHtml4(cpcsJson);
546   - List<ChangePersonCar> cpcs = JSONArray.parseArray(cpcsJson, ChangePersonCar.class);
547   - return scheduleRealInfoService.multi_tzrc(cpcs, null);
548   - }
549   -
550   - @RequestMapping(value="/multi_dftz", method=RequestMethod.POST)
551   - public Map<String, Object> multi_dftz(@RequestParam String dcsJson){
552   - dcsJson = StringEscapeUtils.unescapeHtml4(dcsJson);
553   - List<DfsjChange> dfsjcs = JSONArray.parseArray(dcsJson, DfsjChange.class);
554   - return scheduleRealInfoService.multi_dftz(dfsjcs);
555   - }
556   -
557   - @RequestMapping(value="/changeBcType/{id}", method=RequestMethod.POST)
558   - public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks, String majorStationName){
559   - return scheduleRealInfoService.changeBcType(id, bcType, remarks, majorStationName);
560   - }
561   -
562   - @RequestMapping(value="/history", method=RequestMethod.POST)
563   - public Map<String,Object> historySave(ScheduleRealInfo sch){
564   - return scheduleRealInfoService.historySave(sch);
565   - }
566   -
567   -
568   - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
569   - private final static long ONE_DAY = 1000 * 60 * 60 * 24;
570   - /**
571   - * 获取可编辑的历史班次日期
572   - * @return
573   - */
574   - @RequestMapping("dateArray")
575   - public List<String> dateArray(@RequestParam(defaultValue = "0") int c){
576   - List<String> rs = new ArrayList<>();
577   -
578   - long t = System.currentTimeMillis();
579   - if(c != 1)
580   - t -= (ONE_DAY + (1000 * 60 * 60 * 6));
581   - for(int i = 0; i < 3; i ++){
582   - rs.add(fmtyyyyMMdd.print(t));
583   - t -= ONE_DAY;
584   - }
585   - return rs;
586   - }
587   -
588   - @RequestMapping(value = "svgAttr", method = RequestMethod.POST)
589   - public Map<String, Object> svgAttr(@RequestParam String jsonStr){
590   - return scheduleRealInfoService.svgAttr(jsonStr);
591   - }
592   -
593   - @RequestMapping(value = "svgAttr", method = RequestMethod.GET)
594   - public Map<String, Object> findSvgAttr(@RequestParam String idx){
595   - return scheduleRealInfoService.findSvgAttr(idx);
596   - }
597   -
598   - @RequestMapping(value = "addRemarks", method = RequestMethod.POST)
599   - public Map<String, Object> addRemarks(@RequestParam Long id, @RequestParam String remarks){
600   - return scheduleRealInfoService.addRemarks(id, remarks);
601   - }
602   -
603   - @RequestMapping(value = "scheduleDailyQp", method = RequestMethod.GET)
604   - public List<Map<String, Object>> scheduleDailyQp(@RequestParam String line,@RequestParam String date){
605   - return scheduleRealInfoService.scheduleDailyQp(line,date);
606   - }
607   -
608   - @RequestMapping(value = "scheduleDailyExport", method = RequestMethod.GET)
609   - public List<Map<String, Object>> scheduleDailyExport(@RequestParam Map<String, Object> map){
610   - return scheduleRealInfoService.scheduleDailyExport(map);
611   - }
612   -
613   - @RequestMapping(value = "exportWaybillMore", method = RequestMethod.GET)
614   - public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){
615   - return scheduleRealInfoService.exportWaybillMore(map);
616   - }
617   -
618   - /**
619   - * 获取当日计划排班 , 从计划表抓取数据
620   - * @return
621   - */
622   - @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)
623   - public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){
624   - return scheduleRealInfoService.currentSchedulePlan(lineCode);
625   - }
626   -
627   - @RequestMapping(value = "lpChangeMulti", method = RequestMethod.POST)
628   - public Map<String, Object> lpChangeMulti(@RequestParam String leftIdx, @RequestParam String rightIdx,@RequestParam int type){
629   - return scheduleRealInfoService.lpChangeMulti(leftIdx, rightIdx, type);
630   - }
631   -
632   - /**
633   - * 删除当日实际排班
634   - * @return
635   - */
636   - @RequestMapping(value = "deleteRealSchedule", method = RequestMethod.POST)
637   - public Map<String, Object> deleteRealSchedule(@RequestParam String lineCode){
638   - return dayOfSchedule.deleteRealSchedule(lineCode);
639   - }
640   -
641   - /**
642   - * 从计划表重新加载当日排班
643   - * @param lineCode
644   - * @return
645   - */
646   - @RequestMapping(value = "reLoadRealSchedule", method = RequestMethod.POST)
647   - public Map<String, Object> reLoadRealSchedule(@RequestParam String lineCode){
648   - Map<String, Object> rs = new HashMap<>();
649   - List<ScheduleRealInfo> list = dayOfSchedule.findByLineCode(lineCode);
650   - if(list != null && list.size() > 0){
651   - rs.put("status", ResponseCode.ERROR);
652   - rs.put("msg", "失败," + list.get(0).getXlName() + "当日存在实际排班,无法重新加载。");
653   - return rs;
654   - }
655   -
656   - int code = dayOfSchedule.reloadSch(lineCode);
657   -
658   - //重新按公司编码索引数据
659   - dayOfSchedule.groupByGsbm();
660   - rs.put("status", code==0? ResponseCode.SUCCESS: ResponseCode.ERROR);
661   - return rs;
662   - }
663   -
664   - /**
665   - * 误点调整
666   - * @param idx
667   - * @param minute
668   - * @return
669   - */
670   - @RequestMapping(value = "lateAdjust", method = RequestMethod.POST)
671   - public Map<String, Object> lateAdjust(@RequestParam String idx,@RequestParam float minute ){
672   - return scheduleRealInfoService.lateAdjust(idx, minute);
673   - }
674   -
675   - /**
676   - * 获取所有应发未到的班次
677   - * @param idx
678   - * @return
679   - */
680   - @RequestMapping(value = "allLate2")
681   - public List<ScheduleRealInfo> allLate2(@RequestParam String idx){
682   - return scheduleRealInfoService.allLate2(idx);
683   - }
684   -
685   - /**
686   - * 添加一个临加到历史库
687   - * @param sch
688   - * @return
689   - */
690   - @RequestMapping(value = "history/add", method = RequestMethod.POST)
691   - public Map<String, Object> addToHistory(ScheduleRealInfo sch){
692   - return scheduleRealInfoService.addToHistory(sch);
693   - }
694   -
695   - /**
696   - * 从历史库里删除临加班次
697   - * @param sch
698   - * @return
699   - */
700   - @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)
701   - public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){
702   - return scheduleRealInfoService.deleteToHistory(id);
703   - }
704   -
705   - @RequestMapping(value = "isCircleQdz", method = RequestMethod.POST)
706   - public Map<String, Object> isCircleQdz(@RequestParam String line, String nbbm, String ts, String qdzCode){
707   - Map<String, Object> map =new HashMap<>();
708   - map.put("isExist",scheduleRealInfoService.isCircleQdz(nbbm, ts, line, qdzCode));
709   - return map;
710   - }
711   -
712   - /**
713   - * 从历史库里删除临加班次
714   - * @param sch
715   - * @return
716   - */
717   - @RequestMapping(value = "wxsb", method = RequestMethod.POST)
718   - public Map<String, Object> repairReport(@RequestParam Map<String, Object> param){
719   - return scheduleRealInfoService.repairReport(param, true);
720   - }
721   -
722   - @RequestMapping(value = "wxsb", method = RequestMethod.GET)
723   - public List<RepairReport> repairReportList(@RequestParam String line, @RequestParam String date, @RequestParam String code, @RequestParam String type){
724   - return scheduleRealInfoService.repairReportList(line, date, code, type);
725   - }
726   -
727   - @RequestMapping(value = "lineLevel", method = RequestMethod.GET)
728   - public Map<String, String> lineLevel(@RequestParam String idx){
729   - return scheduleRealInfoService.getLevelsByLines(Arrays.asList(idx.split(",")));
730   - }
731   -}
  1 +package com.bsth.controller.realcontrol;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.Arrays;
  5 +import java.util.Collection;
  6 +import java.util.HashMap;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +import org.apache.commons.lang3.StringEscapeUtils;
  11 +import org.joda.time.format.DateTimeFormat;
  12 +import org.joda.time.format.DateTimeFormatter;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.web.bind.annotation.PathVariable;
  15 +import org.springframework.web.bind.annotation.RequestMapping;
  16 +import org.springframework.web.bind.annotation.RequestMethod;
  17 +import org.springframework.web.bind.annotation.RequestParam;
  18 +import org.springframework.web.bind.annotation.RestController;
  19 +
  20 +import com.alibaba.fastjson.JSONArray;
  21 +import com.bsth.common.ResponseCode;
  22 +import com.bsth.controller.BaseController;
  23 +import com.bsth.controller.realcontrol.dto.ChangePersonCar;
  24 +import com.bsth.controller.realcontrol.dto.DfsjChange;
  25 +import com.bsth.data.BasicData;
  26 +import com.bsth.data.schedule.DayOfSchedule;
  27 +import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
  28 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  29 +import com.bsth.entity.report.RepairReport;
  30 +import com.bsth.entity.schedule.SchedulePlanInfo;
  31 +import com.bsth.service.realcontrol.ScheduleRealInfoService;
  32 +
  33 +@RestController
  34 +@RequestMapping("/realSchedule")
  35 +public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {
  36 +
  37 + @Autowired
  38 + ScheduleRealInfoService scheduleRealInfoService;
  39 +
  40 + @Autowired
  41 + DayOfSchedule dayOfSchedule;
  42 +
  43 + @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST)
  44 + public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){
  45 + return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm);
  46 + }
  47 +
  48 + @RequestMapping(value = "/lines")
  49 + public Map<String, Collection<ScheduleRealInfo>> findByLines(@RequestParam String lines) {
  50 + return scheduleRealInfoService.findByLines(lines);
  51 + }
  52 +
  53 + @RequestMapping(value = "/car")
  54 + public List<ScheduleRealInfo> findByCar(String nbbm){
  55 + return dayOfSchedule.findByNbbm(nbbm);
  56 + }
  57 +
  58 + /**
  59 + *
  60 + * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id
  61 + * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws
  62 + */
  63 + @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)
  64 + public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,
  65 + @RequestParam String dfsj,String bcType,
  66 + @RequestParam(defaultValue = "") String opType) {
  67 + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType, opType, null);
  68 + }
  69 +
  70 + /**
  71 + *
  72 + * @Title: destroy @Description: TODO(销毁,烂班) @param @param idsStr 要烂掉的班次ID ,分隔
  73 + */
  74 + @RequestMapping(value = "/destroy", method = RequestMethod.POST)
  75 + public Map<String, Object> destroy(@RequestParam String idsStr
  76 + /*, @RequestParam(defaultValue = "-1") int spaceAdjust*/,
  77 + @RequestParam String remarks, @RequestParam String adjustExps/*, @RequestParam(defaultValue = "0") int spaceNum*/) {
  78 + return scheduleRealInfoService.destroy(idsStr, remarks, adjustExps, null);
  79 + }
  80 +
  81 + /**
  82 + *
  83 + * @Title: carDeviceMapp @Description: TODO(获取车辆自编号和设备号对照,从缓存取) @throws
  84 + */
  85 + @RequestMapping(value = "/carDeviceMapp", method = RequestMethod.GET)
  86 + public Map<String, String> carDeviceMapp() {
  87 + return BasicData.deviceId2NbbmMap.inverse();
  88 + }
  89 +
  90 + /**
  91 + *
  92 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取驾驶员) @param @param
  93 + * lineId @throws
  94 + */
  95 + @RequestMapping(value = "/driver", method = RequestMethod.GET)
  96 + public List<Map<String, String>> findDriverByLine(@RequestParam String lineCode) {
  97 + return scheduleRealInfoService.findDriverByLine(lineCode);
  98 + }
  99 +
  100 + /**
  101 + *
  102 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取售票员) @param @param
  103 + * lineId @throws
  104 + */
  105 + @RequestMapping(value = "/conductor", method = RequestMethod.GET)
  106 + public List<Map<String, String>> findConductorByLine(@RequestParam String lineCode) {
  107 + return scheduleRealInfoService.findConductorByLine(lineCode);
  108 + }
  109 +
  110 + /**
  111 + *
  112 + * @Title: findPersionByLine @Description: TODO(根据线路主键获取车辆) @param @param
  113 + * lineId @throws
  114 + */
  115 + @RequestMapping(value = "/cars", method = RequestMethod.GET)
  116 + public List<Map<String, String>> findCarByLine(@RequestParam String lineCode) {
  117 + return scheduleRealInfoService.findCarByLine(lineCode);
  118 + }
  119 +
  120 + /**
  121 + *
  122 + * @Title: sreachNbbm @Description: TODO(搜索车辆内部编码) @throws
  123 + */
  124 + @RequestMapping(value = "/sreachVehic", method = RequestMethod.GET)
  125 + public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) {
  126 + return scheduleRealInfoService.sreachVehic(nbbm);
  127 + }
  128 + /**
  129 + *
  130 + * @Title: realOutAdjust
  131 + * @Description: TODO(实发调整)
  132 + * @param @param id 班次ID
  133 + * @param @param fcsjActual 实际发车时间 HH:mm
  134 + * @param @param remarks 备注
  135 + * @throws
  136 + */
  137 + @RequestMapping(value = "/realOutAdjust", method = RequestMethod.POST)
  138 + public Map<String, Object> realOutAdjust(@RequestParam Map<String, String> map) {
  139 + return scheduleRealInfoService.realOutAdjust(map);
  140 + }
  141 +
  142 + /**
  143 + *
  144 + * @Title: revokeDestroy
  145 + * @Description: TODO(撤销烂班)
  146 + * @param @param id
  147 + * @throws
  148 + */
  149 + @RequestMapping(value = "/revokeDestroy", method = RequestMethod.POST)
  150 + public Map<String, Object> revokeDestroy(@RequestParam Long id){
  151 + return scheduleRealInfoService.revokeDestroy(id);
  152 + }
  153 +
  154 + /**
  155 + *
  156 + * @Title: revokeRealOutgo
  157 + * @Description: TODO(撤销实发)
  158 + * @param @param id
  159 + * @throws
  160 + */
  161 + @RequestMapping(value = "/revokeRealOutgo", method = RequestMethod.POST)
  162 + public Map<String, Object> revokeRealOutgo(@RequestParam Long id){
  163 + return scheduleRealInfoService.revokeRealOutgo(id);
  164 + }
  165 +
  166 + /**
  167 + * 撤销执行
  168 + * @param id
  169 + * @return
  170 + */
  171 + @RequestMapping(value = "/revokeRealArrive", method = RequestMethod.POST)
  172 + public Map<String, Object> revokeRealArrive(@RequestParam Long id){
  173 + return scheduleRealInfoService.revokeRealArrive(id);
  174 + }
  175 +
  176 + /**
  177 + *
  178 + * @Title: spaceAdjust
  179 + * @Description: TODO(间隔调整)
  180 + * @param @param ids 要调整的班次数组ID
  181 + * @param @param space 间隔
  182 + * @throws
  183 + */
  184 + @RequestMapping(value = "/spaceAdjust", method = RequestMethod.POST)
  185 + public Map<String, Object> spaceAdjust(Long[] ids, Integer space){
  186 + return scheduleRealInfoService.spaceAdjust(ids, space);
  187 + }
  188 +
  189 + /**
  190 + *
  191 + * @Title: schInfoFineTune
  192 + * @Description: TODO(发车信息微调)
  193 + * @param @param map
  194 + * @throws
  195 + */
  196 + @RequestMapping(value = "/schInfoFineTune", method = RequestMethod.POST)
  197 + public Map<String, Object> schInfoFineTune(@RequestParam Map<String, String> map){
  198 + return scheduleRealInfoService.schInfoFineTune(map);
  199 + }
  200 +
  201 + /**
  202 + *
  203 + * @Title: outgoAdjustAll
  204 + * @Description: TODO(批量待发调整)
  205 + * @param @param list
  206 + * @throws
  207 + */
  208 + @RequestMapping(value = "/outgoAdjustAll", method = RequestMethod.POST)
  209 + public Map<String, Object> outgoAdjustAll(@RequestParam String params){
  210 + //反转义
  211 + params = StringEscapeUtils.unescapeHtml4(params);
  212 + return scheduleRealInfoService.outgoAdjustAll(params);
  213 + }
  214 +
  215 + /**
  216 + *
  217 + * @Title: findByLineAndUpDown
  218 + * @Description: TODO(根据线路和走向获取班次)
  219 + * @param @param line
  220 + * @param @param upDown
  221 + */
  222 + @RequestMapping(value = "/findByLineAndUpDown")
  223 + public List<ScheduleRealInfo> findByLineAndUpDown(@RequestParam String line,@RequestParam Integer upDown){
  224 + return dayOfSchedule.findByLineAndUpDown(line, upDown);
  225 + }
  226 +
  227 + /**
  228 + *
  229 + * @Title: findRouteByLine
  230 + * @Description: TODO(获取线路的站点,路段路由)
  231 + * @param @param lineCode
  232 + * @throws
  233 + */
  234 + @RequestMapping(value = "/findRouteByLine")
  235 + public Map<String, Object> findRouteByLine(@RequestParam String lineCode){
  236 + return scheduleRealInfoService.findRouteByLine(lineCode);
  237 + }
  238 +
  239 + /**
  240 + *
  241 + * @Title: removeChildTask
  242 + * @Description: TODO(删除子任务)
  243 + * @param @param taskId 子任务ID
  244 + * @throws
  245 + */
  246 + @RequestMapping(value = "/childTask/{taskId}", method = RequestMethod.DELETE)
  247 + public Map<String, Object> removeChildTask(@PathVariable("taskId") Long taskId){
  248 + return scheduleRealInfoService.removeChildTask(taskId);
  249 + }
  250 +
  251 + /**
  252 + *
  253 + * @Title: findByLineCode
  254 + * @Description: TODO(根据线路获取班次信息)
  255 + * @param @param lineCode
  256 + */
  257 + @RequestMapping(value = "/lineCode/{lineCode}")
  258 + public List<ScheduleRealInfo> findByLineCode(@PathVariable("lineCode") String lineCode){
  259 + return dayOfSchedule.findByLineCode(lineCode);
  260 + }
  261 +
  262 + @RequestMapping(value = "/queryUserInfo")
  263 + public List<ScheduleRealInfo> queryUserInfo(@RequestParam String line,
  264 + @RequestParam String date,@RequestParam String state) {
  265 + return scheduleRealInfoService.queryUserInfo(line, date,state);
  266 + }
  267 +
  268 + @RequestMapping(value = "/queryUserInfoPx")
  269 + public List<ScheduleRealInfo> queryUserInfoPx(@RequestParam String line,
  270 + @RequestParam String date,@RequestParam String state,@RequestParam String type) {
  271 + return scheduleRealInfoService.queryUserInfoPx(line, date,state,type);
  272 + }
  273 +
  274 + @RequestMapping(value = "/exportWaybill",method = RequestMethod.GET)
  275 + public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName,@RequestParam String jGh, @RequestParam String clZbh,
  276 + @RequestParam String lpName,@RequestParam String date,@RequestParam String line) {
  277 + return scheduleRealInfoService.exportWaybill(jName,jGh, clZbh, lpName,date,line);
  278 + }
  279 +
  280 + @RequestMapping(value = "/exportWaybillQp",method = RequestMethod.GET)
  281 + public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh
  282 + ,@RequestParam String date,@RequestParam String line) {
  283 + return scheduleRealInfoService.exportWaybillQp( clZbh, date,line);
  284 + }
  285 +
  286 +
  287 + @RequestMapping(value = "/dailyInfo")
  288 + public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {
  289 + return scheduleRealInfoService.dailyInfo(line, date, type);
  290 + }
  291 +
  292 + @RequestMapping(value = "/historyMessage")
  293 + public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date,
  294 + @RequestParam String code, @RequestParam String type) {
  295 + return scheduleRealInfoService.historyMessage(line, date, code, type);
  296 + }
  297 +
  298 + @RequestMapping(value="/findLine")
  299 + public List<Map<String,String>> findLine(@RequestParam String line){
  300 + return scheduleRealInfoService.findLine(line);
  301 + }
  302 +
  303 + @RequestMapping(value="/findKMBC",method = RequestMethod.GET)
  304 + public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  305 + ,@RequestParam String date,@RequestParam String line){
  306 + return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);
  307 + }
  308 +
  309 + /**
  310 + * 路单公里统计 (闵行审计专用)
  311 + * @param jGh
  312 + * @param clZbh
  313 + * @param lpName
  314 + * @param date
  315 + * @param line
  316 + * @return
  317 + */
  318 + @RequestMapping(value="/findKMBC_mh_2",method = RequestMethod.GET)
  319 + public Map<String,Object> findKMBC_mh_2(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  320 + ,@RequestParam String date,@RequestParam String line){
  321 + return scheduleRealInfoService.findKMBC_mh_2(jGh, clZbh,lpName,date,line);
  322 + }
  323 +
  324 + @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
  325 + public Map<String,Object> findKMBCQp(@RequestParam String clZbh
  326 + ,@RequestParam String date,@RequestParam String line){
  327 + return scheduleRealInfoService.findKMBCQp(clZbh,date,line);
  328 + }
  329 +
  330 + @RequestMapping(value="/findLpName")
  331 + public List<Map<String,String>> findLpName(@RequestParam String lpName){
  332 + return scheduleRealInfoService.findLpName(lpName);
  333 + }
  334 +
  335 + @RequestMapping(value = "/account")
  336 + public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date,
  337 + @RequestParam String code,@RequestParam String xlName, @RequestParam String type) {
  338 + return scheduleRealInfoService.account(line, date, code, xlName, type);
  339 + }
  340 +
  341 + @RequestMapping(value = "/accountPx")
  342 + public List<Map<String,Object>> accountPx(@RequestParam String line, @RequestParam String date,
  343 + @RequestParam String code,@RequestParam String xlName, @RequestParam String px) {
  344 + return scheduleRealInfoService.accountPx(line, date, code, xlName, px);
  345 + }
  346 +
  347 + @RequestMapping(value = "/correctForm")
  348 + public List<SchEditInfoDto> correctForm(@RequestParam String line, @RequestParam String date,
  349 + @RequestParam String endDate,
  350 + @RequestParam String lpName, @RequestParam String code,
  351 + @RequestParam String type,@RequestParam String changType) {
  352 + return scheduleRealInfoService.correctForm(line, date, endDate, lpName, code, type,changType);
  353 + }
  354 + /**
  355 + * @Title queryListWaybill
  356 + * @Description 查询行车路单列表
  357 + * @param jName 驾驶员名字
  358 + * @param clZbh 车辆自编号(内部编号)
  359 + * @param lpName 路牌
  360 + * @return
  361 + */
  362 + @RequestMapping(value="/queryListWaybill",method = RequestMethod.GET)
  363 + public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
  364 + ,@RequestParam String date,@RequestParam String line){
  365 + return scheduleRealInfoService.queryListWaybill(jGh, clZbh,lpName,date,line);
  366 + }
  367 +
  368 + /**
  369 + * @Title queryListWaybill
  370 + * @Description 查询行车路单列表(闵行审计专用路单)
  371 + * @param jName 驾驶员名字
  372 + * @param clZbh 车辆自编号(内部编号)
  373 + * @param lpName 路牌
  374 + * @return
  375 + */
  376 + @RequestMapping(value="/queryListWaybill_mh_2",method = RequestMethod.GET)
  377 + public List<ScheduleRealInfo> queryListWaybill_mh_2(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName
  378 + ,@RequestParam String date,@RequestParam String line){
  379 + return scheduleRealInfoService.queryListWaybill2(jName, clZbh,lpName,date,line);
  380 + }
  381 +
  382 + @RequestMapping(value="/queryListWaybillQp",method = RequestMethod.GET)
  383 + public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh,
  384 + @RequestParam String date,@RequestParam String line){
  385 + return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line);
  386 + }
  387 +
  388 + @RequestMapping(value="/statisticsDaily")
  389 + public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date,
  390 + @RequestParam String xlName, @RequestParam String type){
  391 + return scheduleRealInfoService.statisticsDaily(line, date, xlName, type);
  392 + }
  393 +
  394 + @RequestMapping(value="/statisticsDaily_mh_2")
  395 + public List<Map<String,Object>> statisticsDaily_mh_2(@RequestParam String line, @RequestParam String date,
  396 + @RequestParam String xlName, @RequestParam String type){
  397 + return scheduleRealInfoService.statisticsDaily_mh_2(line, date, xlName, type);
  398 + }
  399 +
  400 + @RequestMapping(value="/statisticsDailyTj")
  401 + public List<Map<String,Object>> statisticsDailyTj(@RequestParam Map<String, Object> map){
  402 + String gsdm="";
  403 + if(map.get("gsdm")!=null){
  404 + gsdm=map.get("gsdm").toString();
  405 + }
  406 + String fgsdm="";
  407 + if(map.get("fgsdm")!=null){
  408 + fgsdm=map.get("fgsdm").toString();
  409 + }
  410 + String line="";
  411 + if(map.get("line")!=null){
  412 + line=map.get("line").toString();
  413 + }
  414 + String date="";
  415 + if(map.get("date")!=null){
  416 + date=map.get("date").toString();
  417 + }
  418 + String date2="";
  419 + if(map.get("date2")!=null){
  420 + date2=map.get("date2").toString();
  421 + }
  422 + String xlName="";
  423 + if(map.get("xlName")!=null){
  424 + xlName=map.get("xlName").toString();
  425 + }
  426 + String type="";
  427 + if(map.get("type")!=null){
  428 + type=map.get("type").toString();
  429 + }
  430 + String nature="0";
  431 + if(map.get("nature")!=null){
  432 + nature=map.get("nature").toString();
  433 + }
  434 + return scheduleRealInfoService.statisticsDailyTj(gsdm,fgsdm,line, date,date2, xlName, type,nature);
  435 + }
  436 +
  437 + /*
  438 + * 公里修正报表
  439 + */
  440 + @RequestMapping(value="/mileageReportTj")
  441 + public List<Map<String,Object>> mileageReport(@RequestParam Map<String, Object> map){
  442 + String gsdm="";
  443 + if(map.get("gsdm")!=null){
  444 + gsdm=map.get("gsdm").toString();
  445 + }
  446 + String fgsdm="";
  447 + if(map.get("fgsdm")!=null){
  448 + fgsdm=map.get("fgsdm").toString();
  449 + }
  450 + String line="";
  451 + if(map.get("line")!=null){
  452 + line=map.get("line").toString();
  453 + }
  454 + String date="";
  455 + if(map.get("date")!=null){
  456 + date=map.get("date").toString();
  457 + }
  458 + String date2="";
  459 + if(map.get("date2")!=null){
  460 + date2=map.get("date2").toString();
  461 + }
  462 + String xlName="";
  463 + if(map.get("xlName")!=null){
  464 + xlName=map.get("xlName").toString();
  465 + }
  466 + return scheduleRealInfoService.mileageReport(gsdm,fgsdm,line, date,date2);
  467 + }
  468 +
  469 + /*
  470 + * 班次修正报表
  471 + */
  472 + @RequestMapping(value="/scheduleCorrectionReport")
  473 + public List<Map<String,Object>> scheduleCorrectionReport(@RequestParam Map<String, Object> map){
  474 + String gsdm="";
  475 + if(map.get("gsdm")!=null){
  476 + gsdm=map.get("gsdm").toString();
  477 + }
  478 + String fgsdm="";
  479 + if(map.get("fgsdm")!=null){
  480 + fgsdm=map.get("fgsdm").toString();
  481 + }
  482 + String line="";
  483 + if(map.get("line")!=null){
  484 + line=map.get("line").toString();
  485 + }
  486 + String date="";
  487 + if(map.get("date")!=null){
  488 + date=map.get("date").toString();
  489 + }
  490 + String date2="";
  491 + if(map.get("date2")!=null){
  492 + date2=map.get("date2").toString();
  493 + }
  494 + String xlName="";
  495 + if(map.get("xlName")!=null){
  496 + xlName=map.get("xlName").toString();
  497 + }
  498 + return scheduleRealInfoService.scheduleCorrectionReport(gsdm,fgsdm,line, date,date2);
  499 + }
  500 +
  501 + @RequestMapping(value="/MapById",method = RequestMethod.GET)
  502 + public Map<String, Object> MapById(@RequestParam("id") Long id){
  503 + return scheduleRealInfoService.MapById(id);
  504 + }
  505 +
  506 + @RequestMapping(value="/MapByIdQp",method = RequestMethod.GET)
  507 + public Map<String, Object> MapByIdQp(@RequestParam("id") Long id){
  508 + return scheduleRealInfoService.MapByIdQp(id);
  509 + }
  510 +
  511 + /**
  512 + * @Title: scheduleDaily
  513 + * @Description: TODO(调度日报表)
  514 + * @param line 线路
  515 + * @param date 时间
  516 + * @return
  517 + */
  518 + @RequestMapping(value="/scheduleDaily")
  519 + public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
  520 + return scheduleRealInfoService.scheduleDaily(line,date);
  521 + }
  522 +
  523 + @RequestMapping(value="/realScheduleList")
  524 + public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){
  525 + return scheduleRealInfoService.realScheduleList(line,date);
  526 + }
  527 +
  528 + @RequestMapping(value="/realScheduleList_zrw")
  529 + public List<ScheduleRealInfo> realScheduleList_zrw(@RequestParam String line,@RequestParam String date){
  530 + return scheduleRealInfoService.realScheduleList_zrw(line,date);
  531 + }
  532 +
  533 + @RequestMapping(value="/realScheduleList_mh_2")
  534 + public List<ScheduleRealInfo> realScheduleList_mh_2(@RequestParam String line,@RequestParam String date){
  535 + return scheduleRealInfoService.realScheduleList_mh_2(line,date);
  536 + }
  537 +
  538 + @RequestMapping(value="/realScheduleListQp")
  539 + public List<ScheduleRealInfo> realScheduleListQp(@RequestParam String line,@RequestParam String date){
  540 + return scheduleRealInfoService.realScheduleListQp(line,date);
  541 + }
  542 +
  543 + @RequestMapping(value="/multi_tzrc", method=RequestMethod.POST)
  544 + public synchronized Map<String, Object> multi_tzrc(@RequestParam String cpcsJson){
  545 + cpcsJson = StringEscapeUtils.unescapeHtml4(cpcsJson);
  546 + List<ChangePersonCar> cpcs = JSONArray.parseArray(cpcsJson, ChangePersonCar.class);
  547 + return scheduleRealInfoService.multi_tzrc(cpcs, null);
  548 + }
  549 +
  550 + @RequestMapping(value="/multi_dftz", method=RequestMethod.POST)
  551 + public Map<String, Object> multi_dftz(@RequestParam String dcsJson){
  552 + dcsJson = StringEscapeUtils.unescapeHtml4(dcsJson);
  553 + List<DfsjChange> dfsjcs = JSONArray.parseArray(dcsJson, DfsjChange.class);
  554 + return scheduleRealInfoService.multi_dftz(dfsjcs);
  555 + }
  556 +
  557 + @RequestMapping(value="/changeBcType/{id}", method=RequestMethod.POST)
  558 + public Map<String, Object> changeBcType(@PathVariable("id") Long id, String bcType, String remarks, String majorStationName){
  559 + return scheduleRealInfoService.changeBcType(id, bcType, remarks, majorStationName);
  560 + }
  561 +
  562 + @RequestMapping(value="/history", method=RequestMethod.POST)
  563 + public Map<String,Object> historySave(ScheduleRealInfo sch){
  564 + return scheduleRealInfoService.historySave(sch);
  565 + }
  566 +
  567 +
  568 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  569 + private final static long ONE_DAY = 1000 * 60 * 60 * 24;
  570 + /**
  571 + * 获取可编辑的历史班次日期
  572 + * @return
  573 + */
  574 + @RequestMapping("dateArray")
  575 + public List<String> dateArray(@RequestParam(defaultValue = "0") int c){
  576 + List<String> rs = new ArrayList<>();
  577 +
  578 + long t = System.currentTimeMillis();
  579 + if(c != 1)
  580 + t -= (ONE_DAY + (1000 * 60 * 60 * 6));
  581 + for(int i = 0; i < 3; i ++){
  582 + rs.add(fmtyyyyMMdd.print(t));
  583 + t -= ONE_DAY;
  584 + }
  585 + return rs;
  586 + }
  587 +
  588 + @RequestMapping(value = "svgAttr", method = RequestMethod.POST)
  589 + public Map<String, Object> svgAttr(@RequestParam String jsonStr){
  590 + return scheduleRealInfoService.svgAttr(jsonStr);
  591 + }
  592 +
  593 + @RequestMapping(value = "svgAttr", method = RequestMethod.GET)
  594 + public Map<String, Object> findSvgAttr(@RequestParam String idx){
  595 + return scheduleRealInfoService.findSvgAttr(idx);
  596 + }
  597 +
  598 + @RequestMapping(value = "addRemarks", method = RequestMethod.POST)
  599 + public Map<String, Object> addRemarks(@RequestParam Long id, @RequestParam String remarks){
  600 + return scheduleRealInfoService.addRemarks(id, remarks);
  601 + }
  602 +
  603 + @RequestMapping(value = "scheduleDailyQp", method = RequestMethod.GET)
  604 + public List<Map<String, Object>> scheduleDailyQp(@RequestParam String line,@RequestParam String date){
  605 + return scheduleRealInfoService.scheduleDailyQp(line,date);
  606 + }
  607 +
  608 + @RequestMapping(value = "scheduleDailyExport", method = RequestMethod.GET)
  609 + public List<Map<String, Object>> scheduleDailyExport(@RequestParam Map<String, Object> map){
  610 + return scheduleRealInfoService.scheduleDailyExport(map);
  611 + }
  612 +
  613 + @RequestMapping(value = "exportWaybillMore", method = RequestMethod.GET)
  614 + public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){
  615 + return scheduleRealInfoService.exportWaybillMore(map);
  616 + }
  617 +
  618 + /**
  619 + * 获取当日计划排班 , 从计划表抓取数据
  620 + * @return
  621 + */
  622 + @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)
  623 + public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){
  624 + return scheduleRealInfoService.currentSchedulePlan(lineCode);
  625 + }
  626 +
  627 + @RequestMapping(value = "lpChangeMulti", method = RequestMethod.POST)
  628 + public Map<String, Object> lpChangeMulti(@RequestParam String leftIdx, @RequestParam String rightIdx,@RequestParam int type){
  629 + return scheduleRealInfoService.lpChangeMulti(leftIdx, rightIdx, type);
  630 + }
  631 +
  632 + /**
  633 + * 删除当日实际排班
  634 + * @return
  635 + */
  636 + @RequestMapping(value = "deleteRealSchedule", method = RequestMethod.POST)
  637 + public Map<String, Object> deleteRealSchedule(@RequestParam String lineCode){
  638 + return dayOfSchedule.deleteRealSchedule(lineCode);
  639 + }
  640 +
  641 + /**
  642 + * 从计划表重新加载当日排班
  643 + * @param lineCode
  644 + * @return
  645 + */
  646 + @RequestMapping(value = "reLoadRealSchedule", method = RequestMethod.POST)
  647 + public Map<String, Object> reLoadRealSchedule(@RequestParam String lineCode){
  648 + Map<String, Object> rs = new HashMap<>();
  649 + List<ScheduleRealInfo> list = dayOfSchedule.findByLineCode(lineCode);
  650 + if(list != null && list.size() > 0){
  651 + rs.put("status", ResponseCode.ERROR);
  652 + rs.put("msg", "失败," + list.get(0).getXlName() + "当日存在实际排班,无法重新加载。");
  653 + return rs;
  654 + }
  655 +
  656 + int code = dayOfSchedule.reloadSch(lineCode);
  657 +
  658 + //重新按公司编码索引数据
  659 + dayOfSchedule.groupByGsbm();
  660 + rs.put("status", code==0? ResponseCode.SUCCESS: ResponseCode.ERROR);
  661 + return rs;
  662 + }
  663 +
  664 + /**
  665 + * 误点调整
  666 + * @param idx
  667 + * @param minute
  668 + * @return
  669 + */
  670 + @RequestMapping(value = "lateAdjust", method = RequestMethod.POST)
  671 + public Map<String, Object> lateAdjust(@RequestParam String idx,@RequestParam float minute ){
  672 + return scheduleRealInfoService.lateAdjust(idx, minute);
  673 + }
  674 +
  675 + /**
  676 + * 获取所有应发未到的班次
  677 + * @param idx
  678 + * @return
  679 + */
  680 + @RequestMapping(value = "allLate2")
  681 + public List<ScheduleRealInfo> allLate2(@RequestParam String idx){
  682 + return scheduleRealInfoService.allLate2(idx);
  683 + }
  684 +
  685 + /**
  686 + * 添加一个临加到历史库
  687 + * @param sch
  688 + * @return
  689 + */
  690 + @RequestMapping(value = "history/add", method = RequestMethod.POST)
  691 + public Map<String, Object> addToHistory(ScheduleRealInfo sch){
  692 + return scheduleRealInfoService.addToHistory(sch);
  693 + }
  694 +
  695 + /**
  696 + * 从历史库里删除临加班次
  697 + * @param sch
  698 + * @return
  699 + */
  700 + @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE)
  701 + public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){
  702 + return scheduleRealInfoService.deleteToHistory(id);
  703 + }
  704 +
  705 + @RequestMapping(value = "isCircleQdz", method = RequestMethod.POST)
  706 + public Map<String, Object> isCircleQdz(@RequestParam String line, String nbbm, String ts, String qdzCode){
  707 + Map<String, Object> map =new HashMap<>();
  708 + map.put("isExist",scheduleRealInfoService.isCircleQdz(nbbm, ts, line, qdzCode));
  709 + return map;
  710 + }
  711 +
  712 + /**
  713 + * 从历史库里删除临加班次
  714 + * @param sch
  715 + * @return
  716 + */
  717 + @RequestMapping(value = "wxsb", method = RequestMethod.POST)
  718 + public Map<String, Object> repairReport(@RequestParam Map<String, Object> param){
  719 + return scheduleRealInfoService.repairReport(param, true);
  720 + }
  721 +
  722 + @RequestMapping(value = "wxsb", method = RequestMethod.GET)
  723 + public List<RepairReport> repairReportList(@RequestParam String line, @RequestParam String date, @RequestParam String code, @RequestParam String type){
  724 + return scheduleRealInfoService.repairReportList(line, date, code, type);
  725 + }
  726 +
  727 + @RequestMapping(value = "lineLevel", method = RequestMethod.GET)
  728 + public Map<String, String> lineLevel(@RequestParam String idx){
  729 + return scheduleRealInfoService.getLevelsByLines(Arrays.asList(idx.split(",")));
  730 + }
  731 +}
... ...
src/main/java/com/bsth/controller/schedule/basicinfo/CarController_facade.java
1   -package com.bsth.controller.schedule.basicinfo;
2   -
3   -import com.alibaba.dubbo.config.annotation.Reference;
4   -import com.bsth.common.ResponseCode;
5   -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
6   -import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDto;
7   -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
8   -import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
9   -import com.bsth.control_v2.plan_module.common.service.baseinfo.CarServiceFacade;
10   -import com.bsth.controller.schedule.BController_facade;
11   -import com.bsth.service.schedule.CarsService;
12   -import com.bsth.service.schedule.utils.DataToolsFile;
13   -import org.apache.commons.lang3.StringUtils;
14   -import org.apache.poi.ss.usermodel.Workbook;
15   -import org.springframework.beans.factory.annotation.Autowired;
16   -import org.springframework.context.annotation.Conditional;
17   -import org.springframework.web.bind.annotation.RequestMapping;
18   -import org.springframework.web.bind.annotation.RequestMethod;
19   -import org.springframework.web.bind.annotation.RequestParam;
20   -import org.springframework.web.bind.annotation.RestController;
21   -import org.springframework.web.multipart.MultipartFile;
22   -
23   -import javax.servlet.http.HttpServletResponse;
24   -import java.io.*;
25   -import java.util.*;
26   -
27   -/**
28   - * 车辆基础信息controller_facade
29   - */
30   -@RestController
31   -@Conditional(DubboConfigCondition.class)
32   -@RequestMapping("cars_sc")
33   -public class CarController_facade extends BController_facade<Integer, CarDto> {
34   -
35   - @Override
36   - public void setCreateUserInfo(CarDto carDto, Integer userId, Date createDate) {
37   - UserDto userDto = UserDto.getBuilder()
38   - .setId(userId)
39   - .build();
40   - carDto.setCreateBy(userDto);
41   - carDto.setCreateDate(createDate);
42   - }
43   - @Override
44   - public void setUpdateUserInfo(CarDto carDto, Integer userId, Date updateDate) {
45   - UserDto userDto = UserDto.getBuilder()
46   - .setId(userId)
47   - .build();
48   - carDto.setUpdateBy(userDto);
49   - carDto.setUpdateDate(updateDate);
50   - }
51   -
52   - @Reference
53   - private CarServiceFacade carServiceFacade;
54   - @Override
55   - protected BServiceFacade<Integer, CarDto> getBServiceFacade() {
56   - return carServiceFacade;
57   - }
58   -
59   - @RequestMapping(value = "/validate_zbh", method = RequestMethod.GET)
60   - public Map<String, Object> validate_zbh(@RequestParam Map<String, Object> param) {
61   - Map<String, Object> rtn = new HashMap<>();
62   - try {
63   - // 自编号验证
64   - CarDto carDto = CarDto.getBuilder()
65   - .setId(param.get("id_eq") == null ?
66   - null : Integer.valueOf(param.get("id_eq").toString()))
67   - .setInsideCode(param.get("insideCode_eq") == null ?
68   - null : param.get("insideCode_eq").toString())
69   - .build();
70   - this.carServiceFacade.validate_repeat_nbbh(carDto);
71   - rtn.put("status", ResponseCode.SUCCESS);
72   - } catch (Exception exp) {
73   - rtn.put("status", ResponseCode.ERROR);
74   - rtn.put("msg", exp.getMessage());
75   - }
76   - return rtn;
77   - }
78   -
79   - @RequestMapping(value = "/validate_clbh", method = RequestMethod.GET)
80   - public Map<String, Object> validate_clbh(@RequestParam Map<String, Object> param) {
81   - Map<String, Object> rtn = new HashMap<>();
82   - try {
83   - // 车辆编号验证
84   - CarDto carDto = CarDto.getBuilder()
85   - .setId(param.get("id_eq") == null ?
86   - null : Integer.valueOf(param.get("id_eq").toString()))
87   - .setCarCode(param.get("carCode_eq") == null ?
88   - null : param.get("carCode_eq").toString())
89   - .build();
90   - this.carServiceFacade.validate_repeat_clbh(carDto);
91   - rtn.put("status", ResponseCode.SUCCESS);
92   - } catch (Exception exp) {
93   - rtn.put("status", ResponseCode.ERROR);
94   - rtn.put("msg", exp.getMessage());
95   - }
96   - return rtn;
97   - }
98   -
99   - @RequestMapping(value = "/validate_cph", method = RequestMethod.GET)
100   - public Map<String, Object> validate_cph(@RequestParam Map<String, Object> param) {
101   - Map<String, Object> rtn = new HashMap<>();
102   - try {
103   - // 车牌号验证
104   - CarDto carDto = CarDto.getBuilder()
105   - .setId(param.get("id_eq") == null ?
106   - null : Integer.valueOf(param.get("id_eq").toString()))
107   - .setCarPlate(param.get("carPlate_eq") == null ?
108   - null : param.get("carPlate_eq").toString())
109   - .build();
110   - this.carServiceFacade.validate_repeat_cph(carDto);
111   - rtn.put("status", ResponseCode.SUCCESS);
112   - } catch (Exception exp) {
113   - rtn.put("status", ResponseCode.ERROR);
114   - rtn.put("msg", exp.getMessage());
115   - }
116   - return rtn;
117   - }
118   -
119   - @RequestMapping(value = "/validate_sbbh", method = RequestMethod.GET)
120   - public Map<String, Object> validate_sbbh(@RequestParam Map<String, Object> param) {
121   - Map<String, Object> rtn = new HashMap<>();
122   - try {
123   - // 设备编号验证
124   - CarDto carDto = CarDto.getBuilder()
125   - .setId(param.get("id_eq") == null ?
126   - null : Integer.valueOf(param.get("id_eq").toString()))
127   - .setEquipmentCode(param.get("equipmentCode_eq") == null ?
128   - null : param.get("equipmentCode_eq").toString())
129   - .build();
130   - this.carServiceFacade.validate_repeat_sbbh(carDto);
131   - rtn.put("status", ResponseCode.SUCCESS);
132   - } catch (Exception exp) {
133   - rtn.put("status", ResponseCode.ERROR);
134   - rtn.put("msg", exp.getMessage());
135   - }
136   - return rtn;
137   - }
138   -
139   - //------------------ TODO:导入导出逻辑,之后会服务化 -----------------//
140   - @Autowired
141   - private CarsService carsService;
142   - // 上传excel文件
143   - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
144   - public Map<String, Object> uploadFile(MultipartFile file) {
145   - Map<String, Object> rtn = new HashMap<>();
146   - try {
147   - DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes());
148   - // excel文件名
149   - String fileName = dataToolsFile.getFile().getAbsolutePath();
150   - Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile());
151   -
152   - // excel文件sheet
153   - List<String> sheetnames = new ArrayList<>();
154   - for (int i = 0; i < wb.getNumberOfSheets(); i ++) {
155   - sheetnames.add(wb.getSheetAt(i).getSheetName());
156   - }
157   -
158   - wb.close();
159   -
160   - rtn.put("status", ResponseCode.SUCCESS);
161   - rtn.put("filename", fileName);
162   - rtn.put("sheetnames", StringUtils.join(sheetnames, ","));
163   - } catch (Exception exp) {
164   - exp.printStackTrace();
165   - rtn.put("status", ResponseCode.ERROR);
166   - rtn.put("msg", exp.getMessage());
167   - }
168   - return rtn;
169   - }
170   - // 导入excel文件
171   - @RequestMapping(value = "/importFile", method = RequestMethod.POST)
172   - public Map<String, Object> importFile(@RequestParam Map<String, Object> params) {
173   - Map<String, Object> rtn = new HashMap<>();
174   -
175   - try {
176   - File file = new File(String.valueOf(params.get("filename")));
177   - if (!file.exists()) {
178   - throw new Exception("导入文件不存在!");
179   - }
180   - carsService.importData(file, params);
181   -
182   - rtn.put("status", ResponseCode.SUCCESS);
183   - rtn.put("msg", "导入文件成功");
184   - } catch (Exception exp) {
185   - rtn.put("status", ResponseCode.ERROR);
186   - rtn.put("msg", exp.getMessage());
187   - }
188   -
189   - return rtn;
190   - }
191   - // 上传并导入excel文件
192   - @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST)
193   - public Map<String, Object> uploadAndImportFile(MultipartFile file) {
194   - Map<String, Object> rtn = new HashMap<>();
195   -
196   - try {
197   - DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes());
198   - Map<String, Object> params = new HashMap<>();
199   - carsService.importData(dataToolsFile.getFile(), params);
200   -
201   - rtn.put("status", ResponseCode.SUCCESS);
202   - rtn.put("msg", "上传&导入文件成功");
203   - } catch (Exception exp) {
204   - exp.printStackTrace();
205   - rtn.put("status", ResponseCode.ERROR);
206   - rtn.put("msg", exp.getMessage());
207   - }
208   -
209   - return rtn;
210   - }
211   -
212   - // 导出数据到xls文件
213   - @RequestMapping(value = "/exportFile", method = RequestMethod.GET)
214   - public void exportFile(HttpServletResponse response,
215   - @RequestParam Map<String, Object> params) throws Exception {
216   - DataToolsFile dataToolsFile = carsService.exportData(params);
217   - // 流输出导出文件
218   - response.setHeader("content-type", "application/octet-stream");
219   - response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName());
220   - response.setContentType("application/octet-stream");
221   -
222   - OutputStream os = response.getOutputStream();
223   - BufferedOutputStream bos = new BufferedOutputStream(os);
224   -
225   - InputStream is = new FileInputStream(dataToolsFile.getFile());
226   - BufferedInputStream bis = new BufferedInputStream(is);
227   -
228   - int length = 0;
229   - byte[] temp = new byte[1 * 1024 * 10];
230   - while ((length = bis.read(temp)) != -1) {
231   - bos.write(temp, 0, length);
232   - }
233   - bos.flush();
234   - bis.close();
235   - bos.close();
236   - is.close();
237   - }
238   -
239   -
240   -
241   -
242   -}
  1 +package com.bsth.controller.schedule.basicinfo;
  2 +
  3 +import com.alibaba.dubbo.config.annotation.Reference;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
  6 +import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDto;
  7 +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
  8 +import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
  9 +import com.bsth.control_v2.plan_module.common.service.baseinfo.CarServiceFacade;
  10 +import com.bsth.controller.schedule.BController_facade;
  11 +import com.bsth.service.schedule.CarsService;
  12 +import com.bsth.service.schedule.utils.DataToolsFile;
  13 +import org.apache.commons.lang3.StringUtils;
  14 +import org.apache.poi.ss.usermodel.Workbook;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.context.annotation.Conditional;
  17 +import org.springframework.web.bind.annotation.RequestMapping;
  18 +import org.springframework.web.bind.annotation.RequestMethod;
  19 +import org.springframework.web.bind.annotation.RequestParam;
  20 +import org.springframework.web.bind.annotation.RestController;
  21 +import org.springframework.web.multipart.MultipartFile;
  22 +
  23 +import javax.servlet.http.HttpServletResponse;
  24 +import java.io.*;
  25 +import java.util.*;
  26 +
  27 +/**
  28 + * 车辆基础信息controller_facade
  29 + */
  30 +@RestController
  31 +@Conditional(DubboConfigCondition.class)
  32 +@RequestMapping("cars_sc")
  33 +public class CarController_facade extends BController_facade<Integer, CarDto> {
  34 +
  35 + @Override
  36 + public void setCreateUserInfo(CarDto carDto, Integer userId, Date createDate) {
  37 + UserDto userDto = UserDto.getBuilder()
  38 + .setId(userId)
  39 + .build();
  40 + carDto.setCreateBy(userDto);
  41 + carDto.setCreateDate(createDate);
  42 + }
  43 + @Override
  44 + public void setUpdateUserInfo(CarDto carDto, Integer userId, Date updateDate) {
  45 + UserDto userDto = UserDto.getBuilder()
  46 + .setId(userId)
  47 + .build();
  48 + carDto.setUpdateBy(userDto);
  49 + carDto.setUpdateDate(updateDate);
  50 + }
  51 +
  52 + @Reference
  53 + private CarServiceFacade carServiceFacade;
  54 + @Override
  55 + protected BServiceFacade<Integer, CarDto> getBServiceFacade() {
  56 + return carServiceFacade;
  57 + }
  58 +
  59 + @RequestMapping(value = "/validate_zbh", method = RequestMethod.GET)
  60 + public Map<String, Object> validate_zbh(@RequestParam Map<String, Object> param) {
  61 + Map<String, Object> rtn = new HashMap<>();
  62 + try {
  63 + // 自编号验证
  64 + CarDto carDto = CarDto.getBuilder()
  65 + .setId(param.get("id_eq") == null ?
  66 + null : Integer.valueOf(param.get("id_eq").toString()))
  67 + .setInsideCode(param.get("insideCode_eq") == null ?
  68 + null : param.get("insideCode_eq").toString())
  69 + .build();
  70 + this.carServiceFacade.validate_repeat_nbbh(carDto);
  71 + rtn.put("status", ResponseCode.SUCCESS);
  72 + } catch (Exception exp) {
  73 + rtn.put("status", ResponseCode.ERROR);
  74 + rtn.put("msg", exp.getMessage());
  75 + }
  76 + return rtn;
  77 + }
  78 +
  79 + @RequestMapping(value = "/validate_clbh", method = RequestMethod.GET)
  80 + public Map<String, Object> validate_clbh(@RequestParam Map<String, Object> param) {
  81 + Map<String, Object> rtn = new HashMap<>();
  82 + try {
  83 + // 车辆编号验证
  84 + CarDto carDto = CarDto.getBuilder()
  85 + .setId(param.get("id_eq") == null ?
  86 + null : Integer.valueOf(param.get("id_eq").toString()))
  87 + .setCarCode(param.get("carCode_eq") == null ?
  88 + null : param.get("carCode_eq").toString())
  89 + .build();
  90 + this.carServiceFacade.validate_repeat_clbh(carDto);
  91 + rtn.put("status", ResponseCode.SUCCESS);
  92 + } catch (Exception exp) {
  93 + rtn.put("status", ResponseCode.ERROR);
  94 + rtn.put("msg", exp.getMessage());
  95 + }
  96 + return rtn;
  97 + }
  98 +
  99 + @RequestMapping(value = "/validate_cph", method = RequestMethod.GET)
  100 + public Map<String, Object> validate_cph(@RequestParam Map<String, Object> param) {
  101 + Map<String, Object> rtn = new HashMap<>();
  102 + try {
  103 + // 车牌号验证
  104 + CarDto carDto = CarDto.getBuilder()
  105 + .setId(param.get("id_eq") == null ?
  106 + null : Integer.valueOf(param.get("id_eq").toString()))
  107 + .setCarPlate(param.get("carPlate_eq") == null ?
  108 + null : param.get("carPlate_eq").toString())
  109 + .build();
  110 + this.carServiceFacade.validate_repeat_cph(carDto);
  111 + rtn.put("status", ResponseCode.SUCCESS);
  112 + } catch (Exception exp) {
  113 + rtn.put("status", ResponseCode.ERROR);
  114 + rtn.put("msg", exp.getMessage());
  115 + }
  116 + return rtn;
  117 + }
  118 +
  119 + @RequestMapping(value = "/validate_sbbh", method = RequestMethod.GET)
  120 + public Map<String, Object> validate_sbbh(@RequestParam Map<String, Object> param) {
  121 + Map<String, Object> rtn = new HashMap<>();
  122 + try {
  123 + // 设备编号验证
  124 + CarDto carDto = CarDto.getBuilder()
  125 + .setId(param.get("id_eq") == null ?
  126 + null : Integer.valueOf(param.get("id_eq").toString()))
  127 + .setEquipmentCode(param.get("equipmentCode_eq") == null ?
  128 + null : param.get("equipmentCode_eq").toString())
  129 + .build();
  130 + this.carServiceFacade.validate_repeat_sbbh(carDto);
  131 + rtn.put("status", ResponseCode.SUCCESS);
  132 + } catch (Exception exp) {
  133 + rtn.put("status", ResponseCode.ERROR);
  134 + rtn.put("msg", exp.getMessage());
  135 + }
  136 + return rtn;
  137 + }
  138 +
  139 + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------//
  140 + @Autowired
  141 + private CarsService carsService;
  142 + // 上传excel文件
  143 + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
  144 + public Map<String, Object> uploadFile(MultipartFile file) {
  145 + Map<String, Object> rtn = new HashMap<>();
  146 + try {
  147 + DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes());
  148 + // excel文件名
  149 + String fileName = dataToolsFile.getFile().getAbsolutePath();
  150 + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile());
  151 +
  152 + // excel文件sheet
  153 + List<String> sheetnames = new ArrayList<>();
  154 + for (int i = 0; i < wb.getNumberOfSheets(); i ++) {
  155 + sheetnames.add(wb.getSheetAt(i).getSheetName());
  156 + }
  157 +
  158 + wb.close();
  159 +
  160 + rtn.put("status", ResponseCode.SUCCESS);
  161 + rtn.put("filename", fileName);
  162 + rtn.put("sheetnames", StringUtils.join(sheetnames, ","));
  163 + } catch (Exception exp) {
  164 + exp.printStackTrace();
  165 + rtn.put("status", ResponseCode.ERROR);
  166 + rtn.put("msg", exp.getMessage());
  167 + }
  168 + return rtn;
  169 + }
  170 + // 导入excel文件
  171 + @RequestMapping(value = "/importFile", method = RequestMethod.POST)
  172 + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) {
  173 + Map<String, Object> rtn = new HashMap<>();
  174 +
  175 + try {
  176 + File file = new File(String.valueOf(params.get("filename")));
  177 + if (!file.exists()) {
  178 + throw new Exception("导入文件不存在!");
  179 + }
  180 + carsService.importData(file, params);
  181 +
  182 + rtn.put("status", ResponseCode.SUCCESS);
  183 + rtn.put("msg", "导入文件成功");
  184 + } catch (Exception exp) {
  185 + rtn.put("status", ResponseCode.ERROR);
  186 + rtn.put("msg", exp.getMessage());
  187 + }
  188 +
  189 + return rtn;
  190 + }
  191 + // 上传并导入excel文件
  192 + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST)
  193 + public Map<String, Object> uploadAndImportFile(MultipartFile file) {
  194 + Map<String, Object> rtn = new HashMap<>();
  195 +
  196 + try {
  197 + DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes());
  198 + Map<String, Object> params = new HashMap<>();
  199 + carsService.importData(dataToolsFile.getFile(), params);
  200 +
  201 + rtn.put("status", ResponseCode.SUCCESS);
  202 + rtn.put("msg", "上传&导入文件成功");
  203 + } catch (Exception exp) {
  204 + exp.printStackTrace();
  205 + rtn.put("status", ResponseCode.ERROR);
  206 + rtn.put("msg", exp.getMessage());
  207 + }
  208 +
  209 + return rtn;
  210 + }
  211 +
  212 + // 导出数据到xls文件
  213 + @RequestMapping(value = "/exportFile", method = RequestMethod.GET)
  214 + public void exportFile(HttpServletResponse response,
  215 + @RequestParam Map<String, Object> params) throws Exception {
  216 + DataToolsFile dataToolsFile = carsService.exportData(params);
  217 + // 流输出导出文件
  218 + response.setHeader("content-type", "application/octet-stream");
  219 + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName());
  220 + response.setContentType("application/octet-stream");
  221 +
  222 + OutputStream os = response.getOutputStream();
  223 + BufferedOutputStream bos = new BufferedOutputStream(os);
  224 +
  225 + InputStream is = new FileInputStream(dataToolsFile.getFile());
  226 + BufferedInputStream bis = new BufferedInputStream(is);
  227 +
  228 + int length = 0;
  229 + byte[] temp = new byte[1 * 1024 * 10];
  230 + while ((length = bis.read(temp)) != -1) {
  231 + bos.write(temp, 0, length);
  232 + }
  233 + bos.flush();
  234 + bis.close();
  235 + bos.close();
  236 + is.close();
  237 + }
  238 +
  239 +
  240 +
  241 +
  242 +}
... ...
src/main/java/com/bsth/controller/schedule/basicinfo/CarDeviceController_facade.java
1   -package com.bsth.controller.schedule.basicinfo;
2   -
3   -import com.alibaba.dubbo.config.annotation.Reference;
4   -import com.bsth.common.ResponseCode;
5   -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
6   -import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDeviceDto;
7   -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
8   -import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
9   -import com.bsth.control_v2.plan_module.common.service.baseinfo.CarDeviceServiceFacade;
10   -import com.bsth.controller.schedule.BController_facade;
11   -import org.joda.time.DateTime;
12   -import org.springframework.context.annotation.Conditional;
13   -import org.springframework.web.bind.annotation.RequestMapping;
14   -import org.springframework.web.bind.annotation.RequestMethod;
15   -import org.springframework.web.bind.annotation.RequestParam;
16   -import org.springframework.web.bind.annotation.RestController;
17   -
18   -import java.util.Date;
19   -import java.util.HashMap;
20   -import java.util.Map;
21   -
22   -@RestController
23   -@Conditional(DubboConfigCondition.class)
24   -@RequestMapping("cde_sc")
25   -public class CarDeviceController_facade extends BController_facade<Long, CarDeviceDto> {
26   - @Override
27   - public void setCreateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date createDate) {
28   - UserDto userDto = UserDto.getBuilder()
29   - .setId(userId)
30   - .build();
31   - carDeviceDto.setCreateBy(userDto);
32   - carDeviceDto.setCreateDate(createDate);
33   - }
34   -
35   - @Override
36   - public void setUpdateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date updateDate) {
37   - UserDto userDto = UserDto.getBuilder()
38   - .setId(userId)
39   - .build();
40   - carDeviceDto.setUpdateBy(userDto);
41   - carDeviceDto.setUpdateDate(updateDate);
42   - }
43   -
44   - @Reference
45   - private CarDeviceServiceFacade carDeviceServiceFacade;
46   -
47   - @Override
48   - protected BServiceFacade<Long, CarDeviceDto> getBServiceFacade() {
49   - return carDeviceServiceFacade;
50   - }
51   - @RequestMapping(value = "/validate_qyrq", method = RequestMethod.GET)
52   - public Map<String, Object> validate_qyrq(@RequestParam Map<String, Object> param) {
53   - Map<String, Object> rtn = new HashMap<>();
54   -
55   - try {
56   - // 启用日期验证
57   - // 计算日期
58   - Date qyrq_c = null;
59   - if (param.get("qyrq_eq") != null) {
60   - try {
61   - qyrq_c = new Date();
62   - qyrq_c.setTime(Long.parseLong(param.get("qyrq_eq").toString()));
63   - } catch (Exception exp) {
64   - qyrq_c = new DateTime(param.get("qyrq_eq").toString()).toDate();
65   - }
66   - }
67   -
68   - CarDeviceDto carDeviceDto = CarDeviceDto.getBuilder()
69   - .setId(param.get("id_eq") == null ?
70   - null : Long.valueOf(param.get("id_eq").toString()))
71   - .setXl(param.get("xl_eq") == null ?
72   - null : Integer.valueOf(param.get("xl_eq").toString()))
73   - .setCl(param.get("cl_eq") == null ?
74   - null : Integer.valueOf(param.get("cl_eq").toString()))
75   - .setQyrq(qyrq_c)
76   - .build();
77   -
78   - this.carDeviceServiceFacade.validate_qyrq(carDeviceDto);
79   - rtn.put("status", ResponseCode.SUCCESS);
80   - } catch (Exception exp) {
81   - rtn.put("status", ResponseCode.ERROR);
82   - rtn.put("msg", exp.getMessage());
83   - }
84   -
85   - return rtn;
86   - }
87   -}
  1 +package com.bsth.controller.schedule.basicinfo;
  2 +
  3 +import com.alibaba.dubbo.config.annotation.Reference;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
  6 +import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDeviceDto;
  7 +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
  8 +import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
  9 +import com.bsth.control_v2.plan_module.common.service.baseinfo.CarDeviceServiceFacade;
  10 +import com.bsth.controller.schedule.BController_facade;
  11 +import org.joda.time.DateTime;
  12 +import org.springframework.context.annotation.Conditional;
  13 +import org.springframework.web.bind.annotation.RequestMapping;
  14 +import org.springframework.web.bind.annotation.RequestMethod;
  15 +import org.springframework.web.bind.annotation.RequestParam;
  16 +import org.springframework.web.bind.annotation.RestController;
  17 +
  18 +import java.util.Date;
  19 +import java.util.HashMap;
  20 +import java.util.Map;
  21 +
  22 +@RestController
  23 +@Conditional(DubboConfigCondition.class)
  24 +@RequestMapping("cde_sc")
  25 +public class CarDeviceController_facade extends BController_facade<Long, CarDeviceDto> {
  26 + @Override
  27 + public void setCreateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date createDate) {
  28 + UserDto userDto = UserDto.getBuilder()
  29 + .setId(userId)
  30 + .build();
  31 + carDeviceDto.setCreateBy(userDto);
  32 + carDeviceDto.setCreateDate(createDate);
  33 + }
  34 +
  35 + @Override
  36 + public void setUpdateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date updateDate) {
  37 + UserDto userDto = UserDto.getBuilder()
  38 + .setId(userId)
  39 + .build();
  40 + carDeviceDto.setUpdateBy(userDto);
  41 + carDeviceDto.setUpdateDate(updateDate);
  42 + }
  43 +
  44 + @Reference
  45 + private CarDeviceServiceFacade carDeviceServiceFacade;
  46 +
  47 + @Override
  48 + protected BServiceFacade<Long, CarDeviceDto> getBServiceFacade() {
  49 + return carDeviceServiceFacade;
  50 + }
  51 + @RequestMapping(value = "/validate_qyrq", method = RequestMethod.GET)
  52 + public Map<String, Object> validate_qyrq(@RequestParam Map<String, Object> param) {
  53 + Map<String, Object> rtn = new HashMap<>();
  54 +
  55 + try {
  56 + // 启用日期验证
  57 + // 计算日期
  58 + Date qyrq_c = null;
  59 + if (param.get("qyrq_eq") != null) {
  60 + try {
  61 + qyrq_c = new Date();
  62 + qyrq_c.setTime(Long.parseLong(param.get("qyrq_eq").toString()));
  63 + } catch (Exception exp) {
  64 + qyrq_c = new DateTime(param.get("qyrq_eq").toString()).toDate();
  65 + }
  66 + }
  67 +
  68 + CarDeviceDto carDeviceDto = CarDeviceDto.getBuilder()
  69 + .setId(param.get("id_eq") == null ?
  70 + null : Long.valueOf(param.get("id_eq").toString()))
  71 + .setXl(param.get("xl_eq") == null ?
  72 + null : Integer.valueOf(param.get("xl_eq").toString()))
  73 + .setCl(param.get("cl_eq") == null ?
  74 + null : Integer.valueOf(param.get("cl_eq").toString()))
  75 + .setQyrq(qyrq_c)
  76 + .build();
  77 +
  78 + this.carDeviceServiceFacade.validate_qyrq(carDeviceDto);
  79 + rtn.put("status", ResponseCode.SUCCESS);
  80 + } catch (Exception exp) {
  81 + rtn.put("status", ResponseCode.ERROR);
  82 + rtn.put("msg", exp.getMessage());
  83 + }
  84 +
  85 + return rtn;
  86 + }
  87 +}
... ...
src/main/java/com/bsth/controller/schedule/basicinfo/EmployeeController_facade.java
1   -package com.bsth.controller.schedule.basicinfo;
2   -
3   -import com.alibaba.dubbo.config.annotation.Reference;
4   -import com.bsth.common.ResponseCode;
5   -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
6   -import com.bsth.control_v2.plan_module.common.dto.baseinfo.PersonnelDto;
7   -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
8   -import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
9   -import com.bsth.control_v2.plan_module.common.service.baseinfo.PersonnelServiceFacade;
10   -import com.bsth.controller.schedule.BController_facade;
11   -import com.bsth.service.schedule.EmployeeService;
12   -import com.bsth.service.schedule.utils.DataToolsFile;
13   -import org.apache.commons.lang3.StringUtils;
14   -import org.apache.poi.ss.usermodel.Workbook;
15   -import org.springframework.beans.factory.annotation.Autowired;
16   -import org.springframework.context.annotation.Conditional;
17   -import org.springframework.web.bind.annotation.RequestMapping;
18   -import org.springframework.web.bind.annotation.RequestMethod;
19   -import org.springframework.web.bind.annotation.RequestParam;
20   -import org.springframework.web.bind.annotation.RestController;
21   -import org.springframework.web.multipart.MultipartFile;
22   -
23   -import javax.servlet.http.HttpServletResponse;
24   -import java.io.*;
25   -import java.util.*;
26   -
27   -/**
28   - * 人员基础信息Controller_facade
29   - */
30   -@RestController
31   -@Conditional(DubboConfigCondition.class)
32   -@RequestMapping("ee")
33   -public class EmployeeController_facade extends BController_facade<Integer, PersonnelDto> {
34   - @Override
35   - public void setCreateUserInfo(PersonnelDto personnelDto, Integer userId, Date createDate) {
36   - UserDto userDto = UserDto.getBuilder()
37   - .setId(userId)
38   - .build();
39   - personnelDto.setCreateBy(userDto);
40   - personnelDto.setCreateDate(createDate);
41   - }
42   -
43   - @Override
44   - public void setUpdateUserInfo(PersonnelDto personnelDto, Integer userId, Date updateDate) {
45   - UserDto userDto = UserDto.getBuilder()
46   - .setId(userId)
47   - .build();
48   - personnelDto.setUpdateBy(userDto);
49   - personnelDto.setUpdateDate(updateDate);
50   - }
51   -
52   - @Reference
53   - private PersonnelServiceFacade personnelServiceFacade;
54   - @Override
55   - protected BServiceFacade<Integer, PersonnelDto> getBServiceFacade() {
56   - return personnelServiceFacade;
57   - }
58   - @RequestMapping(value = "/validate_gh", method = RequestMethod.GET)
59   - public Map<String, Object> validate_gh(@RequestParam Map<String, Object> param) {
60   - Map<String, Object> rtn = new HashMap<>();
61   - try {
62   - // 工号验证
63   - PersonnelDto personnelDto = PersonnelDto.getBuilder()
64   - .setId(param.get("id_eq") == null ?
65   - null : Integer.valueOf(param.get("id_eq").toString()))
66   - .setCompanyCode(param.get("companyCode_eq") == null ?
67   - null : param.get("companyCode_eq").toString())
68   - .setJobCode(param.get("jobCode_eq") == null ?
69   - null : param.get("jobCode_eq").toString())
70   - .build();
71   - this.personnelServiceFacade.validate_gh(personnelDto);
72   - rtn.put("status", ResponseCode.SUCCESS);
73   - } catch (Exception exp) {
74   - rtn.put("status", ResponseCode.ERROR);
75   - rtn.put("msg", exp.getMessage());
76   - }
77   -
78   - return rtn;
79   - }
80   -
81   - //------------------ TODO:导入导出逻辑,之后会服务化 -----------------//
82   - @Autowired
83   - private EmployeeService employeeService;
84   - // 上传excel文件
85   - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
86   - public Map<String, Object> uploadFile(MultipartFile file) {
87   - Map<String, Object> rtn = new HashMap<>();
88   - try {
89   - DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes());
90   - // excel文件名
91   - String fileName = dataToolsFile.getFile().getAbsolutePath();
92   - Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile());
93   -
94   - // excel文件sheet
95   - List<String> sheetnames = new ArrayList<>();
96   - for (int i = 0; i < wb.getNumberOfSheets(); i ++) {
97   - sheetnames.add(wb.getSheetAt(i).getSheetName());
98   - }
99   -
100   - wb.close();
101   -
102   - rtn.put("status", ResponseCode.SUCCESS);
103   - rtn.put("filename", fileName);
104   - rtn.put("sheetnames", StringUtils.join(sheetnames, ","));
105   - } catch (Exception exp) {
106   - exp.printStackTrace();
107   - rtn.put("status", ResponseCode.ERROR);
108   - rtn.put("msg", exp.getMessage());
109   - }
110   - return rtn;
111   - }
112   - // 导入excel文件
113   - @RequestMapping(value = "/importFile", method = RequestMethod.POST)
114   - public Map<String, Object> importFile(@RequestParam Map<String, Object> params) {
115   - Map<String, Object> rtn = new HashMap<>();
116   -
117   - try {
118   - File file = new File(String.valueOf(params.get("filename")));
119   - if (!file.exists()) {
120   - throw new Exception("导入文件不存在!");
121   - }
122   - employeeService.importData(file, params);
123   -
124   - rtn.put("status", ResponseCode.SUCCESS);
125   - rtn.put("msg", "导入文件成功");
126   - } catch (Exception exp) {
127   - rtn.put("status", ResponseCode.ERROR);
128   - rtn.put("msg", exp.getMessage());
129   - }
130   -
131   - return rtn;
132   - }
133   - // 上传并导入excel文件
134   - @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST)
135   - public Map<String, Object> uploadAndImportFile(MultipartFile file) {
136   - Map<String, Object> rtn = new HashMap<>();
137   -
138   - try {
139   - DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes());
140   - Map<String, Object> params = new HashMap<>();
141   - employeeService.importData(dataToolsFile.getFile(), params);
142   -
143   - rtn.put("status", ResponseCode.SUCCESS);
144   - rtn.put("msg", "上传&导入文件成功");
145   - } catch (Exception exp) {
146   - exp.printStackTrace();
147   - rtn.put("status", ResponseCode.ERROR);
148   - rtn.put("msg", exp.getMessage());
149   - }
150   -
151   - return rtn;
152   - }
153   -
154   - // 导出数据到xls文件
155   - @RequestMapping(value = "/exportFile", method = RequestMethod.GET)
156   - public void exportFile(HttpServletResponse response,
157   - @RequestParam Map<String, Object> params) throws Exception {
158   - DataToolsFile dataToolsFile = employeeService.exportData(params);
159   - // 流输出导出文件
160   - response.setHeader("content-type", "application/octet-stream");
161   - response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName());
162   - response.setContentType("application/octet-stream");
163   -
164   - OutputStream os = response.getOutputStream();
165   - BufferedOutputStream bos = new BufferedOutputStream(os);
166   -
167   - InputStream is = new FileInputStream(dataToolsFile.getFile());
168   - BufferedInputStream bis = new BufferedInputStream(is);
169   -
170   - int length = 0;
171   - byte[] temp = new byte[1 * 1024 * 10];
172   - while ((length = bis.read(temp)) != -1) {
173   - bos.write(temp, 0, length);
174   - }
175   - bos.flush();
176   - bis.close();
177   - bos.close();
178   - is.close();
179   - }
180   -
181   -}
  1 +package com.bsth.controller.schedule.basicinfo;
  2 +
  3 +import com.alibaba.dubbo.config.annotation.Reference;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
  6 +import com.bsth.control_v2.plan_module.common.dto.baseinfo.PersonnelDto;
  7 +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
  8 +import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
  9 +import com.bsth.control_v2.plan_module.common.service.baseinfo.PersonnelServiceFacade;
  10 +import com.bsth.controller.schedule.BController_facade;
  11 +import com.bsth.service.schedule.EmployeeService;
  12 +import com.bsth.service.schedule.utils.DataToolsFile;
  13 +import org.apache.commons.lang3.StringUtils;
  14 +import org.apache.poi.ss.usermodel.Workbook;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.context.annotation.Conditional;
  17 +import org.springframework.web.bind.annotation.RequestMapping;
  18 +import org.springframework.web.bind.annotation.RequestMethod;
  19 +import org.springframework.web.bind.annotation.RequestParam;
  20 +import org.springframework.web.bind.annotation.RestController;
  21 +import org.springframework.web.multipart.MultipartFile;
  22 +
  23 +import javax.servlet.http.HttpServletResponse;
  24 +import java.io.*;
  25 +import java.util.*;
  26 +
  27 +/**
  28 + * 人员基础信息Controller_facade
  29 + */
  30 +@RestController
  31 +@Conditional(DubboConfigCondition.class)
  32 +@RequestMapping("ee")
  33 +public class EmployeeController_facade extends BController_facade<Integer, PersonnelDto> {
  34 + @Override
  35 + public void setCreateUserInfo(PersonnelDto personnelDto, Integer userId, Date createDate) {
  36 + UserDto userDto = UserDto.getBuilder()
  37 + .setId(userId)
  38 + .build();
  39 + personnelDto.setCreateBy(userDto);
  40 + personnelDto.setCreateDate(createDate);
  41 + }
  42 +
  43 + @Override
  44 + public void setUpdateUserInfo(PersonnelDto personnelDto, Integer userId, Date updateDate) {
  45 + UserDto userDto = UserDto.getBuilder()
  46 + .setId(userId)
  47 + .build();
  48 + personnelDto.setUpdateBy(userDto);
  49 + personnelDto.setUpdateDate(updateDate);
  50 + }
  51 +
  52 + @Reference
  53 + private PersonnelServiceFacade personnelServiceFacade;
  54 + @Override
  55 + protected BServiceFacade<Integer, PersonnelDto> getBServiceFacade() {
  56 + return personnelServiceFacade;
  57 + }
  58 + @RequestMapping(value = "/validate_gh", method = RequestMethod.GET)
  59 + public Map<String, Object> validate_gh(@RequestParam Map<String, Object> param) {
  60 + Map<String, Object> rtn = new HashMap<>();
  61 + try {
  62 + // 工号验证
  63 + PersonnelDto personnelDto = PersonnelDto.getBuilder()
  64 + .setId(param.get("id_eq") == null ?
  65 + null : Integer.valueOf(param.get("id_eq").toString()))
  66 + .setCompanyCode(param.get("companyCode_eq") == null ?
  67 + null : param.get("companyCode_eq").toString())
  68 + .setJobCode(param.get("jobCode_eq") == null ?
  69 + null : param.get("jobCode_eq").toString())
  70 + .build();
  71 + this.personnelServiceFacade.validate_gh(personnelDto);
  72 + rtn.put("status", ResponseCode.SUCCESS);
  73 + } catch (Exception exp) {
  74 + rtn.put("status", ResponseCode.ERROR);
  75 + rtn.put("msg", exp.getMessage());
  76 + }
  77 +
  78 + return rtn;
  79 + }
  80 +
  81 + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------//
  82 + @Autowired
  83 + private EmployeeService employeeService;
  84 + // 上传excel文件
  85 + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
  86 + public Map<String, Object> uploadFile(MultipartFile file) {
  87 + Map<String, Object> rtn = new HashMap<>();
  88 + try {
  89 + DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes());
  90 + // excel文件名
  91 + String fileName = dataToolsFile.getFile().getAbsolutePath();
  92 + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile());
  93 +
  94 + // excel文件sheet
  95 + List<String> sheetnames = new ArrayList<>();
  96 + for (int i = 0; i < wb.getNumberOfSheets(); i ++) {
  97 + sheetnames.add(wb.getSheetAt(i).getSheetName());
  98 + }
  99 +
  100 + wb.close();
  101 +
  102 + rtn.put("status", ResponseCode.SUCCESS);
  103 + rtn.put("filename", fileName);
  104 + rtn.put("sheetnames", StringUtils.join(sheetnames, ","));
  105 + } catch (Exception exp) {
  106 + exp.printStackTrace();
  107 + rtn.put("status", ResponseCode.ERROR);
  108 + rtn.put("msg", exp.getMessage());
  109 + }
  110 + return rtn;
  111 + }
  112 + // 导入excel文件
  113 + @RequestMapping(value = "/importFile", method = RequestMethod.POST)
  114 + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) {
  115 + Map<String, Object> rtn = new HashMap<>();
  116 +
  117 + try {
  118 + File file = new File(String.valueOf(params.get("filename")));
  119 + if (!file.exists()) {
  120 + throw new Exception("导入文件不存在!");
  121 + }
  122 + employeeService.importData(file, params);
  123 +
  124 + rtn.put("status", ResponseCode.SUCCESS);
  125 + rtn.put("msg", "导入文件成功");
  126 + } catch (Exception exp) {
  127 + rtn.put("status", ResponseCode.ERROR);
  128 + rtn.put("msg", exp.getMessage());
  129 + }
  130 +
  131 + return rtn;
  132 + }
  133 + // 上传并导入excel文件
  134 + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST)
  135 + public Map<String, Object> uploadAndImportFile(MultipartFile file) {
  136 + Map<String, Object> rtn = new HashMap<>();
  137 +
  138 + try {
  139 + DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes());
  140 + Map<String, Object> params = new HashMap<>();
  141 + employeeService.importData(dataToolsFile.getFile(), params);
  142 +
  143 + rtn.put("status", ResponseCode.SUCCESS);
  144 + rtn.put("msg", "上传&导入文件成功");
  145 + } catch (Exception exp) {
  146 + exp.printStackTrace();
  147 + rtn.put("status", ResponseCode.ERROR);
  148 + rtn.put("msg", exp.getMessage());
  149 + }
  150 +
  151 + return rtn;
  152 + }
  153 +
  154 + // 导出数据到xls文件
  155 + @RequestMapping(value = "/exportFile", method = RequestMethod.GET)
  156 + public void exportFile(HttpServletResponse response,
  157 + @RequestParam Map<String, Object> params) throws Exception {
  158 + DataToolsFile dataToolsFile = employeeService.exportData(params);
  159 + // 流输出导出文件
  160 + response.setHeader("content-type", "application/octet-stream");
  161 + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName());
  162 + response.setContentType("application/octet-stream");
  163 +
  164 + OutputStream os = response.getOutputStream();
  165 + BufferedOutputStream bos = new BufferedOutputStream(os);
  166 +
  167 + InputStream is = new FileInputStream(dataToolsFile.getFile());
  168 + BufferedInputStream bis = new BufferedInputStream(is);
  169 +
  170 + int length = 0;
  171 + byte[] temp = new byte[1 * 1024 * 10];
  172 + while ((length = bis.read(temp)) != -1) {
  173 + bos.write(temp, 0, length);
  174 + }
  175 + bos.flush();
  176 + bis.close();
  177 + bos.close();
  178 + is.close();
  179 + }
  180 +
  181 +}
... ...
src/main/java/com/bsth/controller/schedule/core/LogController_facade.java
1   -package com.bsth.controller.schedule.core;
2   -
3   -import com.alibaba.dubbo.config.annotation.Reference;
4   -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
5   -import com.bsth.control_v2.plan_module.common.dto.schedule.log.ModuleOperatorLogDto;
6   -import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
7   -import com.bsth.control_v2.plan_module.common.service.log.LogServiceFacade;
8   -import com.bsth.controller.schedule.BController_facade;
9   -import org.springframework.context.annotation.Conditional;
10   -import org.springframework.web.bind.annotation.RequestMapping;
11   -import org.springframework.web.bind.annotation.RestController;
12   -
13   -@RestController
14   -@Conditional(DubboConfigCondition.class)
15   -@RequestMapping("s_log")
16   -public class LogController_facade extends BController_facade<Long, ModuleOperatorLogDto> {
17   - @Reference
18   - private LogServiceFacade logServiceFacade;
19   -
20   - @Override
21   - protected BServiceFacade<Long, ModuleOperatorLogDto> getBServiceFacade() {
22   - return logServiceFacade;
23   - }
24   -}
  1 +package com.bsth.controller.schedule.core;
  2 +
  3 +import com.alibaba.dubbo.config.annotation.Reference;
  4 +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
  5 +import com.bsth.control_v2.plan_module.common.dto.schedule.log.ModuleOperatorLogDto;
  6 +import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
  7 +import com.bsth.control_v2.plan_module.common.service.log.LogServiceFacade;
  8 +import com.bsth.controller.schedule.BController_facade;
  9 +import org.springframework.context.annotation.Conditional;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +@RestController
  14 +@Conditional(DubboConfigCondition.class)
  15 +@RequestMapping("s_log")
  16 +public class LogController_facade extends BController_facade<Long, ModuleOperatorLogDto> {
  17 + @Reference
  18 + private LogServiceFacade logServiceFacade;
  19 +
  20 + @Override
  21 + protected BServiceFacade<Long, ModuleOperatorLogDto> getBServiceFacade() {
  22 + return logServiceFacade;
  23 + }
  24 +}
... ...
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController_facade.java
1   -package com.bsth.controller.schedule.core;
2   -
3   -import com.alibaba.dubbo.config.annotation.Reference;
4   -import com.bsth.common.ResponseCode;
5   -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
6   -import com.bsth.control_v2.plan_module.common.dto.schedule.PlanDto;
7   -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
8   -import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
9   -import com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade;
10   -import com.bsth.control_v2.plan_module.common.service.schedule.validate.PlanPreValidateFacade;
11   -import com.bsth.controller.schedule.BController_facade;
12   -import com.bsth.entity.schedule.SchedulePlan;
13   -import com.bsth.service.schedule.SchedulePlanService;
14   -import org.springframework.beans.factory.annotation.Autowired;
15   -import org.springframework.context.annotation.Conditional;
16   -import org.springframework.web.bind.annotation.PathVariable;
17   -import org.springframework.web.bind.annotation.RequestMapping;
18   -import org.springframework.web.bind.annotation.RequestMethod;
19   -import org.springframework.web.bind.annotation.RestController;
20   -
21   -import java.util.Date;
22   -import java.util.HashMap;
23   -import java.util.Map;
24   -
25   -@RestController
26   -@Conditional(DubboConfigCondition.class)
27   -@RequestMapping("spc")
28   -public class SchedulePlanController_facade extends BController_facade<Long, PlanDto> {
29   - @Reference
30   - private PlanServiceFacade planServiceFacade;
31   - @Reference
32   - private PlanPreValidateFacade planPreValidateFacade;
33   -
34   - @Override
35   - protected BServiceFacade<Long, PlanDto> getBServiceFacade() {
36   - return planServiceFacade;
37   - }
38   -
39   - /**
40   - * 创建指定线路,指定时间范围内的排班计划,使用的时刻表情况
41   - * @param xlid 线路id
42   - * @param from 开始时间
43   - * @param to 结束时间
44   - * @return
45   - * @throws Exception
46   - */
47   - @RequestMapping(value = "/valttinfo/{xlid}/{from}/{to}", method = RequestMethod.GET)
48   - public Map<String, Object> validateTTInfo(
49   - @PathVariable(value = "xlid") Integer xlid,
50   - @PathVariable(value = "from") Date from,
51   - @PathVariable(value = "to") Date to
52   - ) throws Exception {
53   - Map<String, Object> rtn = new HashMap<>();
54   - rtn.put("status", ResponseCode.SUCCESS);
55   - rtn.put("data", planPreValidateFacade.validateTTInfo(xlid, from, to));
56   - return rtn;
57   - }
58   -
59   - /**
60   - * 验证排班计划时间范围内规则的正确性。
61   - * @return
62   - * @throws Exception
63   - */
64   - @RequestMapping(value = "/valttrule/{xlid}/{from}/{to}", method = RequestMethod.GET)
65   - public Map<String, Object> validateRule(
66   - @PathVariable(value = "xlid") Integer xlid,
67   - @PathVariable(value = "from") Date from,
68   - @PathVariable(value = "to") Date to
69   - ) throws Exception {
70   - Map<String, Object> rtn = new HashMap<>();
71   - rtn.put("status", ResponseCode.SUCCESS);
72   - rtn.put("data", planPreValidateFacade.validateRule(xlid, from, to));
73   - return rtn;
74   - }
75   -
76   - @Override
77   - public void setCreateUserInfo(PlanDto planDto, Integer userId, Date createDate) {
78   - UserDto userDto = UserDto.getBuilder()
79   - .setId(userId)
80   - .build();
81   - planDto.setCreateBy(userDto);
82   - planDto.setCreateDate(createDate);
83   - }
84   -
85   - @Override
86   - public void setUpdateUserInfo(PlanDto planDto, Integer userId, Date updateDate) {
87   - UserDto userDto = UserDto.getBuilder()
88   - .setId(userId)
89   - .build();
90   - planDto.setUpdateBy(userDto);
91   - planDto.setUpdateDate(updateDate);
92   - }
93   -
94   - //------------------------- 以下是还未服务话的功能 --------------------------//
95   - @Autowired
96   - private SchedulePlanService schedulePlanService;
97   -
98   - /**
99   - * 获取明天的一歌排班计划。
100   - * @return
101   - * @throws Exception
102   - */
103   - @RequestMapping(value = "/tommorw", method = RequestMethod.GET)
104   - public SchedulePlan getTommorwPlan() throws Exception {
105   - try {
106   - return schedulePlanService.findSchedulePlanTommorw();
107   - } catch (Exception exp) {
108   - throw new Exception(exp.getCause());
109   - }
110   - }
111   -}
  1 +package com.bsth.controller.schedule.core;
  2 +
  3 +import com.alibaba.dubbo.config.annotation.Reference;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
  6 +import com.bsth.control_v2.plan_module.common.dto.schedule.PlanDto;
  7 +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
  8 +import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
  9 +import com.bsth.control_v2.plan_module.common.service.schedule.PlanServiceFacade;
  10 +import com.bsth.control_v2.plan_module.common.service.schedule.validate.PlanPreValidateFacade;
  11 +import com.bsth.controller.schedule.BController_facade;
  12 +import com.bsth.entity.schedule.SchedulePlan;
  13 +import com.bsth.service.schedule.SchedulePlanService;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.context.annotation.Conditional;
  16 +import org.springframework.web.bind.annotation.PathVariable;
  17 +import org.springframework.web.bind.annotation.RequestMapping;
  18 +import org.springframework.web.bind.annotation.RequestMethod;
  19 +import org.springframework.web.bind.annotation.RestController;
  20 +
  21 +import java.util.Date;
  22 +import java.util.HashMap;
  23 +import java.util.Map;
  24 +
  25 +@RestController
  26 +@Conditional(DubboConfigCondition.class)
  27 +@RequestMapping("spc")
  28 +public class SchedulePlanController_facade extends BController_facade<Long, PlanDto> {
  29 + @Reference
  30 + private PlanServiceFacade planServiceFacade;
  31 + @Reference
  32 + private PlanPreValidateFacade planPreValidateFacade;
  33 +
  34 + @Override
  35 + protected BServiceFacade<Long, PlanDto> getBServiceFacade() {
  36 + return planServiceFacade;
  37 + }
  38 +
  39 + /**
  40 + * 创建指定线路,指定时间范围内的排班计划,使用的时刻表情况
  41 + * @param xlid 线路id
  42 + * @param from 开始时间
  43 + * @param to 结束时间
  44 + * @return
  45 + * @throws Exception
  46 + */
  47 + @RequestMapping(value = "/valttinfo/{xlid}/{from}/{to}", method = RequestMethod.GET)
  48 + public Map<String, Object> validateTTInfo(
  49 + @PathVariable(value = "xlid") Integer xlid,
  50 + @PathVariable(value = "from") Date from,
  51 + @PathVariable(value = "to") Date to
  52 + ) throws Exception {
  53 + Map<String, Object> rtn = new HashMap<>();
  54 + rtn.put("status", ResponseCode.SUCCESS);
  55 + rtn.put("data", planPreValidateFacade.validateTTInfo(xlid, from, to));
  56 + return rtn;
  57 + }
  58 +
  59 + /**
  60 + * 验证排班计划时间范围内规则的正确性。
  61 + * @return
  62 + * @throws Exception
  63 + */
  64 + @RequestMapping(value = "/valttrule/{xlid}/{from}/{to}", method = RequestMethod.GET)
  65 + public Map<String, Object> validateRule(
  66 + @PathVariable(value = "xlid") Integer xlid,
  67 + @PathVariable(value = "from") Date from,
  68 + @PathVariable(value = "to") Date to
  69 + ) throws Exception {
  70 + Map<String, Object> rtn = new HashMap<>();
  71 + rtn.put("status", ResponseCode.SUCCESS);
  72 + rtn.put("data", planPreValidateFacade.validateRule(xlid, from, to));
  73 + return rtn;
  74 + }
  75 +
  76 + @Override
  77 + public void setCreateUserInfo(PlanDto planDto, Integer userId, Date createDate) {
  78 + UserDto userDto = UserDto.getBuilder()
  79 + .setId(userId)
  80 + .build();
  81 + planDto.setCreateBy(userDto);
  82 + planDto.setCreateDate(createDate);
  83 + }
  84 +
  85 + @Override
  86 + public void setUpdateUserInfo(PlanDto planDto, Integer userId, Date updateDate) {
  87 + UserDto userDto = UserDto.getBuilder()
  88 + .setId(userId)
  89 + .build();
  90 + planDto.setUpdateBy(userDto);
  91 + planDto.setUpdateDate(updateDate);
  92 + }
  93 +
  94 + //------------------------- 以下是还未服务话的功能 --------------------------//
  95 + @Autowired
  96 + private SchedulePlanService schedulePlanService;
  97 +
  98 + /**
  99 + * 获取明天的一歌排班计划。
  100 + * @return
  101 + * @throws Exception
  102 + */
  103 + @RequestMapping(value = "/tommorw", method = RequestMethod.GET)
  104 + public SchedulePlan getTommorwPlan() throws Exception {
  105 + try {
  106 + return schedulePlanService.findSchedulePlanTommorw();
  107 + } catch (Exception exp) {
  108 + throw new Exception(exp.getCause());
  109 + }
  110 + }
  111 +}
... ...
src/main/java/com/bsth/controller/schedule/core/SchedulePlanInfoController_facade.java
1   -package com.bsth.controller.schedule.core;
2   -
3   -import com.alibaba.dubbo.config.annotation.Reference;
4   -import com.bsth.common.ResponseCode;
5   -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
6   -import com.bsth.control_v2.plan_module.common.dto.schedule.PlanInfoDto;
7   -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
8   -import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
9   -import com.bsth.control_v2.plan_module.common.service.schedule.PlanInfoServiceFacade;
10   -import com.bsth.control_v2.plan_module.common.utils.SystemInfoUtils;
11   -import com.bsth.controller.schedule.BController_facade;
12   -import org.springframework.context.annotation.Conditional;
13   -import org.springframework.web.bind.annotation.PathVariable;
14   -import org.springframework.web.bind.annotation.RequestMapping;
15   -import org.springframework.web.bind.annotation.RequestMethod;
16   -import org.springframework.web.bind.annotation.RestController;
17   -
18   -import java.util.Date;
19   -import java.util.HashMap;
20   -import java.util.Map;
21   -
22   -@RestController
23   -@Conditional(DubboConfigCondition.class)
24   -@RequestMapping("spic")
25   -public class SchedulePlanInfoController_facade extends BController_facade<Long, PlanInfoDto> {
26   - @Reference
27   - private PlanInfoServiceFacade planInfoServiceFacade;
28   -
29   - @Override
30   - protected BServiceFacade<Long, PlanInfoDto> getBServiceFacade() {
31   - return planInfoServiceFacade;
32   - }
33   -
34   - @Override
35   - public void setCreateUserInfo(PlanInfoDto planInfoDto, Integer userId, Date createDate) {
36   - UserDto userDto = UserDto.getBuilder()
37   - .setId(userId)
38   - .build();
39   - planInfoDto.setCreateBy(userDto);
40   - planInfoDto.setCreateDate(createDate);
41   - }
42   -
43   - @Override
44   - public void setUpdateUserInfo(PlanInfoDto planInfoDto, Integer userId, Date updateDate) {
45   - UserDto userDto = UserDto.getBuilder()
46   - .setId(userId)
47   - .build();
48   - planInfoDto.setUpdateBy(userDto);
49   - planInfoDto.setUpdateDate(updateDate);
50   - }
51   -
52   - @Override
53   - protected boolean isUpdateExtend() {
54   - return true;
55   - }
56   -
57   - @Override
58   - protected PlanInfoDto updateExtend(PlanInfoDto planInfoDto) {
59   - return this.planInfoServiceFacade.updateInfo(planInfoDto, SystemInfoUtils.createClientSystemInfo());
60   - }
61   -
62   - @RequestMapping(value = "/groupextinfos/{xlid}/{date}", method = RequestMethod.GET)
63   - public Map<String, Object> findGroupInfoExt(
64   - @PathVariable(value = "xlid") Integer xlid,
65   - @PathVariable(value = "date") Date scheduleDate) {
66   - Map<String, Object> resultMap = new HashMap<>();
67   - try {
68   - resultMap.put("status", ResponseCode.SUCCESS);
69   - resultMap.put("data", this.planInfoServiceFacade.findPlanGroupInfo(xlid, scheduleDate));
70   -
71   - } catch (Exception exp) {
72   - exp.printStackTrace();
73   - resultMap.put("status", ResponseCode.ERROR);
74   - resultMap.put("msg", exp.getLocalizedMessage());
75   - }
76   -
77   - return resultMap;
78   - }
79   -
80   - @RequestMapping(value = "/lastestsd/{xlid}", method = RequestMethod.GET)
81   - public Map<String, Object> findLastestPlanDate(
82   - @PathVariable(value = "xlid") Integer xlid) {
83   - Map<String, Object> resultMap = new HashMap<>();
84   - try {
85   - resultMap.put("status", ResponseCode.SUCCESS);
86   - resultMap.put("data", this.planInfoServiceFacade.findLastestPlanInfoDate(xlid));
87   -
88   - } catch (Exception exp) {
89   - exp.printStackTrace();
90   - resultMap.put("status", ResponseCode.ERROR);
91   - resultMap.put("msg", exp.getLocalizedMessage());
92   - }
93   -
94   - return resultMap;
95   - }
96   -
97   -
98   -}
  1 +package com.bsth.controller.schedule.core;
  2 +
  3 +import com.alibaba.dubbo.config.annotation.Reference;
  4 +import com.bsth.common.ResponseCode;
  5 +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
  6 +import com.bsth.control_v2.plan_module.common.dto.schedule.PlanInfoDto;
  7 +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
  8 +import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
  9 +import com.bsth.control_v2.plan_module.common.service.schedule.PlanInfoServiceFacade;
  10 +import com.bsth.control_v2.plan_module.common.utils.SystemInfoUtils;
  11 +import com.bsth.controller.schedule.BController_facade;
  12 +import org.springframework.context.annotation.Conditional;
  13 +import org.springframework.web.bind.annotation.PathVariable;
  14 +import org.springframework.web.bind.annotation.RequestMapping;
  15 +import org.springframework.web.bind.annotation.RequestMethod;
  16 +import org.springframework.web.bind.annotation.RestController;
  17 +
  18 +import java.util.Date;
  19 +import java.util.HashMap;
  20 +import java.util.Map;
  21 +
  22 +@RestController
  23 +@Conditional(DubboConfigCondition.class)
  24 +@RequestMapping("spic")
  25 +public class SchedulePlanInfoController_facade extends BController_facade<Long, PlanInfoDto> {
  26 + @Reference
  27 + private PlanInfoServiceFacade planInfoServiceFacade;
  28 +
  29 + @Override
  30 + protected BServiceFacade<Long, PlanInfoDto> getBServiceFacade() {
  31 + return planInfoServiceFacade;
  32 + }
  33 +
  34 + @Override
  35 + public void setCreateUserInfo(PlanInfoDto planInfoDto, Integer userId, Date createDate) {
  36 + UserDto userDto = UserDto.getBuilder()
  37 + .setId(userId)
  38 + .build();
  39 + planInfoDto.setCreateBy(userDto);
  40 + planInfoDto.setCreateDate(createDate);
  41 + }
  42 +
  43 + @Override
  44 + public void setUpdateUserInfo(PlanInfoDto planInfoDto, Integer userId, Date updateDate) {
  45 + UserDto userDto = UserDto.getBuilder()
  46 + .setId(userId)
  47 + .build();
  48 + planInfoDto.setUpdateBy(userDto);
  49 + planInfoDto.setUpdateDate(updateDate);
  50 + }
  51 +
  52 + @Override
  53 + protected boolean isUpdateExtend() {
  54 + return true;
  55 + }
  56 +
  57 + @Override
  58 + protected PlanInfoDto updateExtend(PlanInfoDto planInfoDto) {
  59 + return this.planInfoServiceFacade.updateInfo(planInfoDto, SystemInfoUtils.createClientSystemInfo());
  60 + }
  61 +
  62 + @RequestMapping(value = "/groupextinfos/{xlid}/{date}", method = RequestMethod.GET)
  63 + public Map<String, Object> findGroupInfoExt(
  64 + @PathVariable(value = "xlid") Integer xlid,
  65 + @PathVariable(value = "date") Date scheduleDate) {
  66 + Map<String, Object> resultMap = new HashMap<>();
  67 + try {
  68 + resultMap.put("status", ResponseCode.SUCCESS);
  69 + resultMap.put("data", this.planInfoServiceFacade.findPlanGroupInfo(xlid, scheduleDate));
  70 +
  71 + } catch (Exception exp) {
  72 + exp.printStackTrace();
  73 + resultMap.put("status", ResponseCode.ERROR);
  74 + resultMap.put("msg", exp.getLocalizedMessage());
  75 + }
  76 +
  77 + return resultMap;
  78 + }
  79 +
  80 + @RequestMapping(value = "/lastestsd/{xlid}", method = RequestMethod.GET)
  81 + public Map<String, Object> findLastestPlanDate(
  82 + @PathVariable(value = "xlid") Integer xlid) {
  83 + Map<String, Object> resultMap = new HashMap<>();
  84 + try {
  85 + resultMap.put("status", ResponseCode.SUCCESS);
  86 + resultMap.put("data", this.planInfoServiceFacade.findLastestPlanInfoDate(xlid));
  87 +
  88 + } catch (Exception exp) {
  89 + exp.printStackTrace();
  90 + resultMap.put("status", ResponseCode.ERROR);
  91 + resultMap.put("msg", exp.getLocalizedMessage());
  92 + }
  93 +
  94 + return resultMap;
  95 + }
  96 +
  97 +
  98 +}
... ...
src/main/java/com/bsth/controller/schedule/core/TTInfoBxDetailController_facade.java
1   -package com.bsth.controller.schedule.core;
2   -
3   -import com.alibaba.dubbo.config.annotation.Reference;
4   -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
5   -import com.bsth.control_v2.plan_module.common.dto.schedule.timetable.TTInfoBxDetailDto;
6   -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
7   -import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
8   -import com.bsth.control_v2.plan_module.common.service.schedule.timetable.TTInfoBxDetailServiceFacade;
9   -import com.bsth.controller.schedule.BController_facade;
10   -import org.springframework.context.annotation.Conditional;
11   -import org.springframework.web.bind.annotation.RequestMapping;
12   -import org.springframework.web.bind.annotation.RestController;
13   -
14   -import java.util.Date;
15   -
16   -@RestController
17   -@Conditional(DubboConfigCondition.class)
18   -@RequestMapping("tibxdc")
19   -public class TTInfoBxDetailController_facade extends BController_facade<Long, TTInfoBxDetailDto> {
20   - @Reference
21   - private TTInfoBxDetailServiceFacade ttInfoBxDetailServiceFacade;
22   -
23   - @Override
24   - protected BServiceFacade<Long, TTInfoBxDetailDto> getBServiceFacade() {
25   - return ttInfoBxDetailServiceFacade;
26   - }
27   -
28   - @Override
29   - public void setCreateUserInfo(TTInfoBxDetailDto ttInfoBxDetailDto, Integer userId, Date createDate) {
30   - UserDto userDto = UserDto.getBuilder()
31   - .setId(userId)
32   - .build();
33   - ttInfoBxDetailDto.setCreateBy(userDto);
34   - ttInfoBxDetailDto.setCreateDate(createDate);
35   - }
36   -
37   - @Override
38   - public void setUpdateUserInfo(TTInfoBxDetailDto ttInfoBxDetailDto, Integer userId, Date updateDate) {
39   - UserDto userDto = UserDto.getBuilder()
40   - .setId(userId)
41   - .build();
42   - ttInfoBxDetailDto.setUpdateBy(userDto);
43   - ttInfoBxDetailDto.setUpdateDate(updateDate);
44   - }
45   -}
  1 +package com.bsth.controller.schedule.core;
  2 +
  3 +import com.alibaba.dubbo.config.annotation.Reference;
  4 +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition;
  5 +import com.bsth.control_v2.plan_module.common.dto.schedule.timetable.TTInfoBxDetailDto;
  6 +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto;
  7 +import com.bsth.control_v2.plan_module.common.service.BServiceFacade;
  8 +import com.bsth.control_v2.plan_module.common.service.schedule.timetable.TTInfoBxDetailServiceFacade;
  9 +import com.bsth.controller.schedule.BController_facade;
  10 +import org.springframework.context.annotation.Conditional;
  11 +import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.RestController;
  13 +
  14 +import java.util.Date;
  15 +
  16 +@RestController
  17 +@Conditional(DubboConfigCondition.class)
  18 +@RequestMapping("tibxdc")
  19 +public class TTInfoBxDetailController_facade extends BController_facade<Long, TTInfoBxDetailDto> {
  20 + @Reference
  21 + private TTInfoBxDetailServiceFacade ttInfoBxDetailServiceFacade;
  22 +
  23 + @Override
  24 + protected BServiceFacade<Long, TTInfoBxDetailDto> getBServiceFacade() {
  25 + return ttInfoBxDetailServiceFacade;
  26 + }
  27 +
  28 + @Override
  29 + public void setCreateUserInfo(TTInfoBxDetailDto ttInfoBxDetailDto, Integer userId, Date createDate) {
  30 + UserDto userDto = UserDto.getBuilder()
  31 + .setId(userId)
  32 + .build();
  33 + ttInfoBxDetailDto.setCreateBy(userDto);
  34 + ttInfoBxDetailDto.setCreateDate(createDate);
  35 + }
  36 +
  37 + @Override
  38 + public void setUpdateUserInfo(TTInfoBxDetailDto ttInfoBxDetailDto, Integer userId, Date updateDate) {
  39 + UserDto userDto = UserDto.getBuilder()
  40 + .setId(userId)
  41 + .build();
  42 + ttInfoBxDetailDto.setUpdateBy(userDto);
  43 + ttInfoBxDetailDto.setUpdateDate(updateDate);
  44 + }
  45 +}
... ...
src/main/java/com/bsth/controller/schedule/core/legacy/TTInfoBxDetailController.java
1   -package com.bsth.controller.schedule.core.legacy;
2   -
3   -import com.bsth.controller.schedule.BController;
4   -import com.bsth.controller.schedule.core.TTInfoBxDetailController_facade;
5   -import com.bsth.entity.schedule.TTInfoBxDetail;
6   -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
7   -import org.springframework.web.bind.annotation.RequestMapping;
8   -import org.springframework.web.bind.annotation.RestController;
9   -
10   -@RestController
11   -@ConditionalOnMissingBean(TTInfoBxDetailController_facade.class)
12   -@RequestMapping("tibxdc")
13   -public class TTInfoBxDetailController extends BController<TTInfoBxDetail, Long> {
14   -}
  1 +package com.bsth.controller.schedule.core.legacy;
  2 +
  3 +import com.bsth.controller.schedule.BController;
  4 +import com.bsth.controller.schedule.core.TTInfoBxDetailController_facade;
  5 +import com.bsth.entity.schedule.TTInfoBxDetail;
  6 +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +@RestController
  11 +@ConditionalOnMissingBean(TTInfoBxDetailController_facade.class)
  12 +@RequestMapping("tibxdc")
  13 +public class TTInfoBxDetailController extends BController<TTInfoBxDetail, Long> {
  14 +}
... ...
src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
1   -package com.bsth.data.gpsdata_v2;
2   -
3   -import com.alibaba.fastjson.JSON;
4   -import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
5   -import com.bsth.data.gpsdata_v2.entity.GpsEntity;
6   -import com.bsth.data.gpsdata_v2.handlers.*;
7   -import com.bsth.email.SendEmailController;
8   -import com.bsth.email.entity.EmailBean;
9   -import com.google.common.collect.ArrayListMultimap;
10   -import org.apache.commons.lang3.StringUtils;
11   -import org.slf4j.Logger;
12   -import org.slf4j.LoggerFactory;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.stereotype.Component;
15   -
16   -import java.util.*;
17   -import java.util.concurrent.CountDownLatch;
18   -import java.util.concurrent.ExecutorService;
19   -import java.util.concurrent.Executors;
20   -import java.util.concurrent.ThreadFactory;
21   -import java.util.concurrent.TimeUnit;
22   -
23   -/**
24   - * 实时信号数据处理
25   - * Created by panzhao on 2017/11/15.
26   - */
27   -@Component
28   -public class DataHandleProcess {
29   -
30   - @Autowired
31   - GpsStateProcess gpsStateProcess;
32   - @Autowired
33   - StationInsideProcess stationInsideProcess;
34   - @Autowired
35   - AbnormalStateProcess abnormalStateProcess;
36   - @Autowired
37   - InStationProcess inStationProcess;
38   - @Autowired
39   - OutStationProcess outStationProcess;
40   - @Autowired
41   - ReverseRouteProcess reverseRouteProcess;
42   - @Autowired
43   - GpsRealData gpsRealData;
44   - // 发送邮件
45   - @Autowired
46   - private SendEmailController sendEmailController;
47   -
48   -
49   - static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class);
50   -
51   - final static int POOL_SIZE = 20;
52   -
53   - static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1, new ThreadFactory() {
54   -
55   - @Override
56   - public Thread newThread(Runnable r) {
57   - // TODO Auto-generated method stub
58   - Thread t = new Thread(r);
59   - t.setName("GPSProcessor");
60   -
61   - return t;
62   - }
63   -
64   - });
65   - public static CountDownLatch count;
66   -
67   - static long lastTime;
68   -
69   - public static boolean isBlock() {
70   - return System.currentTimeMillis() - lastTime > 1000 * 30;
71   - }
72   -
73   - private void shutdownAndAwaitTermination(ExecutorService pool) {
74   - pool.shutdown();
75   - try {
76   - if (!pool.awaitTermination(500, TimeUnit.MILLISECONDS)) {
77   - pool.shutdownNow();
78   - }
79   - if (!pool.awaitTermination(500, TimeUnit.MILLISECONDS)) {
80   - logger.error("线程池无法正常终止");
81   - }
82   - } catch (InterruptedException e) {
83   - pool.shutdown();
84   - Thread.currentThread().interrupt();
85   - }
86   - }
87   -
88   - public void handle(List<GpsEntity> list) {
89   - try {
90   - if (list.size() == 0)
91   - return;
92   - lastTime = System.currentTimeMillis();
93   - //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑)
94   - ArrayListMultimap multimap = ArrayListMultimap.create();
95   - for (GpsEntity gps : list) {
96   - multimap.put(gps.getDeviceId(), gps);
97   - }
98   - List<String> deviceList = new ArrayList<>(multimap.keySet());
99   -
100   - //数据均分给线程
101   - ArrayListMultimap dataListMap = ArrayListMultimap.create();
102   - int size = deviceList.size(), threadIndex = 0, threadSize = size / POOL_SIZE;
103   - if(threadSize==0)
104   - threadSize = size;
105   - for (int i = 0; i < size; i++) {
106   - if (i % threadSize == 0)
107   - threadIndex++;
108   - dataListMap.putAll(threadIndex, multimap.get(deviceList.get(i)));
109   - }
110   - Set<Integer> ks = dataListMap.keySet();
111   - logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size());
112   - count = new CountDownLatch(ks.size());
113   -
114   - //logger.info(JSON.toJSONString(ks));
115   - for (Integer index : ks) {
116   - threadPool.execute(new SignalHandleThread(dataListMap.get(index), count));
117   - }
118   -
119   -
120   - //等待子线程结束
121   - boolean isNormal = count.await(5, TimeUnit.SECONDS);
122   - if (!isNormal) {
123   - try {
124   - shutdownAndAwaitTermination(threadPool);
125   - threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1, new ThreadFactory() {
126   -
127   - @Override
128   - public Thread newThread(Runnable r) {
129   - // TODO Auto-generated method stub
130   - Thread t = new Thread(r);
131   - t.setName("GPSProcessor");
132   -
133   - return t;
134   - }
135   -
136   - });
137   - //发送邮件
138   - EmailBean mail = new EmailBean();
139   - mail.setSubject("线调GPS处理");
140   - mail.setContent("GPS处理超时,检查线程栈文件信息<br/>");
141   - sendEmailController.sendMail("113252620@qq.com", mail);
142   - logger.info("DataHandlerProcess:邮件发送成功!");
143   - } catch (Exception e){
144   - logger.error("DataHandlerProcess:邮件发送失败!",e);
145   - }
146   - }
147   -
148   - //加入实时gps对照
149   - for (GpsEntity gps : list)
150   - gpsRealData.put(gps);
151   -
152   - logger.info("time , " + (System.currentTimeMillis() - lastTime));
153   - } catch (Exception e) {
154   - logger.error("", e);
155   - }
156   - }
157   -
158   - static GpsComp comp = new GpsComp();
159   -
160   - public class SignalHandleThread implements Runnable {
161   -
162   - List<GpsEntity> list;
163   - CountDownLatch count;
164   -
165   - SignalHandleThread(List<GpsEntity> gpsList, CountDownLatch count) {
166   - this.list = gpsList;
167   - this.count = count;
168   - }
169   -
170   - @Override
171   - public void run() {
172   - try {
173   - Collections.sort(list, comp);
174   - GpsEntity gps;
175   - for(int i = 0,len = list.size(); i< len ;i ++){
176   - if (Thread.currentThread().isInterrupted()) break;
177   - gps = list.get(i);
178   -
179   - try {
180   - if (StringUtils.isEmpty(gps.getNbbm()))
181   - continue;
182   - if (Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20)
183   - continue;
184   -
185   - gpsStateProcess.process(gps);//状态处理
186   - stationInsideProcess.process(gps);//场站内外判定
187   - reverseRouteProcess.process(gps);//反向路由处理
188   - abnormalStateProcess.process(gps);//超速越界
189   -
190   - inStationProcess.process(gps);//进站
191   - outStationProcess.process(gps);//出站
192   -
193   -
194   - GpsCacheData.putGps(gps);//历史gps缓存
195   - } catch (Throwable e) {
196   - logger.error("", e);
197   - }
198   - }
199   - } finally {
200   - if (count != null)
201   - count.countDown();
202   - }
203   - }
204   - }
205   -
206   - public static class GpsComp implements Comparator<GpsEntity> {
207   -
208   - @Override
209   - public int compare(GpsEntity g1, GpsEntity g2) {
210   - return g1.getTimestamp().compareTo(g2.getTimestamp());
211   - }
212   - }
  1 +package com.bsth.data.gpsdata_v2;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.bsth.data.gpsdata_v2.cache.GpsCacheData;
  5 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  6 +import com.bsth.data.gpsdata_v2.handlers.*;
  7 +import com.bsth.email.SendEmailController;
  8 +import com.bsth.email.entity.EmailBean;
  9 +import com.google.common.collect.ArrayListMultimap;
  10 +import org.apache.commons.lang3.StringUtils;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +import java.util.*;
  17 +import java.util.concurrent.CountDownLatch;
  18 +import java.util.concurrent.ExecutorService;
  19 +import java.util.concurrent.Executors;
  20 +import java.util.concurrent.ThreadFactory;
  21 +import java.util.concurrent.TimeUnit;
  22 +
  23 +/**
  24 + * 实时信号数据处理
  25 + * Created by panzhao on 2017/11/15.
  26 + */
  27 +@Component
  28 +public class DataHandleProcess {
  29 +
  30 + @Autowired
  31 + GpsStateProcess gpsStateProcess;
  32 + @Autowired
  33 + StationInsideProcess stationInsideProcess;
  34 + @Autowired
  35 + AbnormalStateProcess abnormalStateProcess;
  36 + @Autowired
  37 + InStationProcess inStationProcess;
  38 + @Autowired
  39 + OutStationProcess outStationProcess;
  40 + @Autowired
  41 + ReverseRouteProcess reverseRouteProcess;
  42 + @Autowired
  43 + GpsRealData gpsRealData;
  44 + // 发送邮件
  45 + @Autowired
  46 + private SendEmailController sendEmailController;
  47 +
  48 +
  49 + static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class);
  50 +
  51 + final static int POOL_SIZE = 20;
  52 +
  53 + static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1, new ThreadFactory() {
  54 +
  55 + @Override
  56 + public Thread newThread(Runnable r) {
  57 + // TODO Auto-generated method stub
  58 + Thread t = new Thread(r);
  59 + t.setName("GPSProcessor");
  60 +
  61 + return t;
  62 + }
  63 +
  64 + });
  65 + public static CountDownLatch count;
  66 +
  67 + static long lastTime;
  68 +
  69 + public static boolean isBlock() {
  70 + return System.currentTimeMillis() - lastTime > 1000 * 30;
  71 + }
  72 +
  73 + private void shutdownAndAwaitTermination(ExecutorService pool) {
  74 + pool.shutdown();
  75 + try {
  76 + if (!pool.awaitTermination(500, TimeUnit.MILLISECONDS)) {
  77 + pool.shutdownNow();
  78 + }
  79 + if (!pool.awaitTermination(500, TimeUnit.MILLISECONDS)) {
  80 + logger.error("线程池无法正常终止");
  81 + }
  82 + } catch (InterruptedException e) {
  83 + pool.shutdown();
  84 + Thread.currentThread().interrupt();
  85 + }
  86 + }
  87 +
  88 + public void handle(List<GpsEntity> list) {
  89 + try {
  90 + if (list.size() == 0)
  91 + return;
  92 + lastTime = System.currentTimeMillis();
  93 + //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑)
  94 + ArrayListMultimap multimap = ArrayListMultimap.create();
  95 + for (GpsEntity gps : list) {
  96 + multimap.put(gps.getDeviceId(), gps);
  97 + }
  98 + List<String> deviceList = new ArrayList<>(multimap.keySet());
  99 +
  100 + //数据均分给线程
  101 + ArrayListMultimap dataListMap = ArrayListMultimap.create();
  102 + int size = deviceList.size(), threadIndex = 0, threadSize = size / POOL_SIZE;
  103 + if(threadSize==0)
  104 + threadSize = size;
  105 + for (int i = 0; i < size; i++) {
  106 + if (i % threadSize == 0)
  107 + threadIndex++;
  108 + dataListMap.putAll(threadIndex, multimap.get(deviceList.get(i)));
  109 + }
  110 + Set<Integer> ks = dataListMap.keySet();
  111 + logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size());
  112 + count = new CountDownLatch(ks.size());
  113 +
  114 + //logger.info(JSON.toJSONString(ks));
  115 + for (Integer index : ks) {
  116 + threadPool.execute(new SignalHandleThread(dataListMap.get(index), count));
  117 + }
  118 +
  119 +
  120 + //等待子线程结束
  121 + boolean isNormal = count.await(5, TimeUnit.SECONDS);
  122 + if (!isNormal) {
  123 + try {
  124 + shutdownAndAwaitTermination(threadPool);
  125 + threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1, new ThreadFactory() {
  126 +
  127 + @Override
  128 + public Thread newThread(Runnable r) {
  129 + // TODO Auto-generated method stub
  130 + Thread t = new Thread(r);
  131 + t.setName("GPSProcessor");
  132 +
  133 + return t;
  134 + }
  135 +
  136 + });
  137 + //发送邮件
  138 + EmailBean mail = new EmailBean();
  139 + mail.setSubject("线调GPS处理");
  140 + mail.setContent("GPS处理超时,检查线程栈文件信息<br/>");
  141 + sendEmailController.sendMail("113252620@qq.com", mail);
  142 + logger.info("DataHandlerProcess:邮件发送成功!");
  143 + } catch (Exception e){
  144 + logger.error("DataHandlerProcess:邮件发送失败!",e);
  145 + }
  146 + }
  147 +
  148 + //加入实时gps对照
  149 + for (GpsEntity gps : list)
  150 + gpsRealData.put(gps);
  151 +
  152 + logger.info("time , " + (System.currentTimeMillis() - lastTime));
  153 + } catch (Exception e) {
  154 + logger.error("", e);
  155 + }
  156 + }
  157 +
  158 + static GpsComp comp = new GpsComp();
  159 +
  160 + public class SignalHandleThread implements Runnable {
  161 +
  162 + List<GpsEntity> list;
  163 + CountDownLatch count;
  164 +
  165 + SignalHandleThread(List<GpsEntity> gpsList, CountDownLatch count) {
  166 + this.list = gpsList;
  167 + this.count = count;
  168 + }
  169 +
  170 + @Override
  171 + public void run() {
  172 + try {
  173 + Collections.sort(list, comp);
  174 + GpsEntity gps;
  175 + for(int i = 0,len = list.size(); i< len ;i ++){
  176 + if (Thread.currentThread().isInterrupted()) break;
  177 + gps = list.get(i);
  178 +
  179 + try {
  180 + if (StringUtils.isEmpty(gps.getNbbm()))
  181 + continue;
  182 + if (Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20)
  183 + continue;
  184 +
  185 + gpsStateProcess.process(gps);//状态处理
  186 + stationInsideProcess.process(gps);//场站内外判定
  187 + reverseRouteProcess.process(gps);//反向路由处理
  188 + abnormalStateProcess.process(gps);//超速越界
  189 +
  190 + inStationProcess.process(gps);//进站
  191 + outStationProcess.process(gps);//出站
  192 +
  193 +
  194 + GpsCacheData.putGps(gps);//历史gps缓存
  195 + } catch (Throwable e) {
  196 + logger.error("", e);
  197 + }
  198 + }
  199 + } finally {
  200 + if (count != null)
  201 + count.countDown();
  202 + }
  203 + }
  204 + }
  205 +
  206 + public static class GpsComp implements Comparator<GpsEntity> {
  207 +
  208 + @Override
  209 + public int compare(GpsEntity g1, GpsEntity g2) {
  210 + return g1.getTimestamp().compareTo(g2.getTimestamp());
  211 + }
  212 + }
213 213 }
214 214 \ No newline at end of file
... ...
src/main/java/com/bsth/data/gpsdata_v2/cache/GpsCacheData.java
1   -package com.bsth.data.gpsdata_v2.cache;
2   -
3   -import com.bsth.data.gpsdata_v2.entity.GpsEntity;
4   -import com.bsth.data.gpsdata_v2.entity.StationRoute;
5   -import com.bsth.data.gpsdata_v2.entity.trail.GpsExecTrail;
6   -import com.bsth.data.gpsdata_v2.utils.CircleQueue;
7   -import com.google.common.collect.ArrayListMultimap;
8   -import org.slf4j.Logger;
9   -import org.slf4j.LoggerFactory;
10   -
11   -import java.util.*;
12   -import java.util.concurrent.ConcurrentHashMap;
13   -import java.util.concurrent.ConcurrentMap;
14   -
15   -/**
16   - * gps 数据缓存
17   - * Created by panzhao on 2017/11/15.
18   - */
19   -public class GpsCacheData {
20   -
21   - /**
22   - * 每辆车缓存最后200条gps
23   - */
24   - private static final int CACHE_SIZE = 200;
25   - private static ConcurrentMap<String, CircleQueue<GpsEntity>> gpsCacheMap = new ConcurrentHashMap<>();
26   -
27   - /**
28   - * 车辆执行班次的详细 进出站数据
29   - */
30   - private static ArrayListMultimap<String, GpsExecTrail> trailListMultimap = ArrayListMultimap.create();
31   -
32   - static Logger logger = LoggerFactory.getLogger(GpsCacheData.class);
33   -
34   - public static CircleQueue<GpsEntity> getGps(String device) {
35   - return gpsCacheMap.get(device);
36   - }
37   -
38   - /**
39   - * 清除车辆的轨迹数据
40   - * @param nbbm
41   - */
42   - public static void remove(String nbbm){
43   - //logger.info("清除车辆到离站轨迹, " + nbbm);
44   - trailListMultimap.removeAll(nbbm);
45   - }
46   -
47   - public static GpsExecTrail gpsExecTrail(String nbbm){
48   - List<GpsExecTrail> list = trailListMultimap.get(nbbm);
49   -
50   - GpsExecTrail trail;
51   - if(null == list || list.size() == 0
52   - || list.get(list.size() - 1).isEnd()){
53   - trail = new GpsExecTrail();
54   -
55   - trailListMultimap.put(nbbm, trail);
56   - }
57   - else{
58   - trail = list.get(list.size() - 1);
59   - }
60   -
61   - return trail;
62   - }
63   -
64   - public static void out(GpsEntity gps){
65   - GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
66   - trail.getSrs().add(gps);
67   -
68   - }
69   -
70   - public static void in(GpsEntity gps, boolean end){
71   - GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
72   - trail.getSrs().add(gps);
73   - trail.setEnd(end);
74   - }
75   -
76   - public static GpsEntity getPrev(GpsEntity gps){
77   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
78   - if(queue != null)
79   - return queue.getTail();
80   - return null;
81   - }
82   -
83   - public static void putGps(GpsEntity gps) {
84   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
85   - if (queue == null) {
86   - queue = new CircleQueue<>(CACHE_SIZE);
87   - gpsCacheMap.put(gps.getDeviceId(), queue);
88   - }
89   - queue.add(gps);
90   - }
91   -
92   - public static void clear(String deviceId) {
93   - try {
94   - CircleQueue<GpsEntity> queue = gpsCacheMap.get(deviceId);
95   - if (queue != null)
96   - queue.clear();
97   - } catch (Exception e) {
98   - logger.error("", e);
99   - }
100   - }
101   -
102   - public static StationRoute prevStation(GpsEntity gps) {
103   - List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
104   - if(null == trails || trails.size() == 0)
105   - return null;
106   -
107   - GpsEntity prev;
108   - for(int i = trails.size() - 1; i > 0; i--){
109   - prev = trails.get(i).getSrs().peekLast();
110   -
111   - if(prev != null){
112   - return GeoCacheData.getRouteCode(prev);
113   - }
114   - }
115   - return null;
116   - }
117   -
118   - /**
119   - * 最后一段轨迹
120   - * @param gps
121   - * @return
122   - */
123   - public static int lastInTrailsSize(GpsEntity gps) {
124   - //int size = 0;
125   - List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
126   - if(null == trails || trails.size() == 0)
127   - return 0;
128   -
129   - GpsExecTrail gs = trails.get(trails.size() - 1);
130   - if(gs.isEnd())
131   - return 0;
132   -
133   - Set<String> set = new HashSet<>();
134   - for(GpsEntity g : gs.getSrs()){
135   - if(g.getInstation() == 1)
136   - set.add(g.getStation().getName());
137   - }
138   - return set.size();
139   - }
140   -
141   - public static List<StationRoute> prevMultiStation(GpsEntity gps) {
142   - List<StationRoute> rs = new ArrayList<>();
143   - List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
144   - if(null == trails || trails.size() == 0)
145   - return null;
146   -
147   - for(int i = trails.size() - 1; i > 0; i--){
148   - rs.addAll(searchLinked(trails.get(i).getSrs(), gps.getUpDown()));
149   - if(rs.size() > 3)
150   - break;
151   - }
152   - return rs;
153   - }
154   -
155   - private static List<StationRoute> searchLinked(LinkedList<GpsEntity> list, int upDown){
156   - List<StationRoute> rs = new ArrayList<>();
157   -
158   - GpsEntity gps;
159   - int prevCode=0;
160   - for(int i = list.size() - 1; i > 0; i --){
161   - gps = list.get(i);
162   - if(gps.getInstation()!=1)
163   - continue;
164   -
165   - if(gps.getUpDown() != upDown)
166   - break;
167   -
168   - if(gps.getStation().getRouteSort() != prevCode)
169   - rs.add(gps.getStation());
170   -
171   - prevCode = gps.getStation().getRouteSort();
172   -
173   - if(rs.size() >= 3)
174   - break;
175   - }
176   - return rs;
177   - }
178   -}
  1 +package com.bsth.data.gpsdata_v2.cache;
  2 +
  3 +import com.bsth.data.gpsdata_v2.entity.GpsEntity;
  4 +import com.bsth.data.gpsdata_v2.entity.StationRoute;
  5 +import com.bsth.data.gpsdata_v2.entity.trail.GpsExecTrail;
  6 +import com.bsth.data.gpsdata_v2.utils.CircleQueue;
  7 +import com.google.common.collect.ArrayListMultimap;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +
  11 +import java.util.*;
  12 +import java.util.concurrent.ConcurrentHashMap;
  13 +import java.util.concurrent.ConcurrentMap;
  14 +import java.util.concurrent.CopyOnWriteArrayList;
  15 +
  16 +/**
  17 + * gps 数据缓存
  18 + * Created by panzhao on 2017/11/15.
  19 + */
  20 +public class GpsCacheData {
  21 +
  22 + /**
  23 + * 每辆车缓存最后200条gps
  24 + */
  25 + private static final int CACHE_SIZE = 200;
  26 + private static ConcurrentMap<String, CircleQueue<GpsEntity>> gpsCacheMap = new ConcurrentHashMap<>();
  27 +
  28 + /**
  29 + * 车辆执行班次的详细 进出站数据
  30 + */
  31 + //private static ArrayListMultimap<String, GpsExecTrail> trailListMultimap = ArrayListMultimap.create();
  32 + private static Map<String, List<GpsExecTrail>> trailListMultimap = new ConcurrentHashMap<>();
  33 +
  34 + static Logger logger = LoggerFactory.getLogger(GpsCacheData.class);
  35 +
  36 + public static CircleQueue<GpsEntity> getGps(String device) {
  37 + return gpsCacheMap.get(device);
  38 + }
  39 +
  40 + /**
  41 + * 清除车辆的轨迹数据
  42 + * @param nbbm
  43 + */
  44 + public static void remove(String nbbm){
  45 + //logger.info("清除车辆到离站轨迹, " + nbbm);
  46 + trailListMultimap.remove(nbbm);
  47 + }
  48 +
  49 + public static GpsExecTrail gpsExecTrail(String nbbm){
  50 + List<GpsExecTrail> list = trailListMultimap.get(nbbm);
  51 +
  52 + GpsExecTrail trail;
  53 + if (null == list || list.size() == 0 || list.get(list.size() - 1).isEnd()) {
  54 + if (null == list) {
  55 + list = new CopyOnWriteArrayList<>();
  56 + trailListMultimap.put(nbbm, list);
  57 + }
  58 + trail = new GpsExecTrail();
  59 + list.add(trail);
  60 + } else{
  61 + trail = list.get(list.size() - 1);
  62 + }
  63 +
  64 + return trail;
  65 + }
  66 +
  67 + public static void out(GpsEntity gps){
  68 + GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
  69 + trail.getSrs().add(gps);
  70 +
  71 + }
  72 +
  73 + public static void in(GpsEntity gps, boolean end){
  74 + GpsExecTrail trail = gpsExecTrail(gps.getNbbm());
  75 + trail.getSrs().add(gps);
  76 + trail.setEnd(end);
  77 + }
  78 +
  79 + public static GpsEntity getPrev(GpsEntity gps){
  80 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
  81 + if(queue != null)
  82 + return queue.getTail();
  83 + return null;
  84 + }
  85 +
  86 + public static void putGps(GpsEntity gps) {
  87 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(gps.getDeviceId());
  88 + if (queue == null) {
  89 + queue = new CircleQueue<>(CACHE_SIZE);
  90 + gpsCacheMap.put(gps.getDeviceId(), queue);
  91 + }
  92 + queue.add(gps);
  93 + }
  94 +
  95 + public static void clear(String deviceId) {
  96 + try {
  97 + CircleQueue<GpsEntity> queue = gpsCacheMap.get(deviceId);
  98 + if (queue != null)
  99 + queue.clear();
  100 + } catch (Exception e) {
  101 + logger.error("", e);
  102 + }
  103 + }
  104 +
  105 + public static StationRoute prevStation(GpsEntity gps) {
  106 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  107 + if(null == trails || trails.size() == 0)
  108 + return null;
  109 +
  110 + GpsEntity prev;
  111 + for(int i = trails.size() - 1; i > 0; i--){
  112 + prev = trails.get(i).getSrs().peekLast();
  113 +
  114 + if(prev != null){
  115 + return GeoCacheData.getRouteCode(prev);
  116 + }
  117 + }
  118 + return null;
  119 + }
  120 +
  121 + /**
  122 + * 最后一段轨迹
  123 + * @param gps
  124 + * @return
  125 + */
  126 + public static int lastInTrailsSize(GpsEntity gps) {
  127 + //int size = 0;
  128 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  129 + if(null == trails || trails.size() == 0)
  130 + return 0;
  131 +
  132 + GpsExecTrail gs = trails.get(trails.size() - 1);
  133 + if(gs.isEnd())
  134 + return 0;
  135 +
  136 + Set<String> set = new HashSet<>();
  137 + for(GpsEntity g : gs.getSrs()){
  138 + if(g.getInstation() == 1)
  139 + set.add(g.getStation().getName());
  140 + }
  141 + return set.size();
  142 + }
  143 +
  144 + public static List<StationRoute> prevMultiStation(GpsEntity gps) {
  145 + List<StationRoute> rs = new ArrayList<>();
  146 + List<GpsExecTrail> trails = trailListMultimap.get(gps.getNbbm());
  147 + if(null == trails || trails.size() == 0)
  148 + return null;
  149 +
  150 + for(int i = trails.size() - 1; i > 0; i--){
  151 + rs.addAll(searchLinked(trails.get(i).getSrs(), gps.getUpDown()));
  152 + if(rs.size() > 3)
  153 + break;
  154 + }
  155 + return rs;
  156 + }
  157 +
  158 + private static List<StationRoute> searchLinked(LinkedList<GpsEntity> list, int upDown){
  159 + List<StationRoute> rs = new ArrayList<>();
  160 +
  161 + GpsEntity gps;
  162 + int prevCode=0;
  163 + for(int i = list.size() - 1; i > 0; i --){
  164 + gps = list.get(i);
  165 + if(gps.getInstation()!=1)
  166 + continue;
  167 +
  168 + if(gps.getUpDown() != upDown)
  169 + break;
  170 +
  171 + if(gps.getStation().getRouteSort() != prevCode)
  172 + rs.add(gps.getStation());
  173 +
  174 + prevCode = gps.getStation().getRouteSort();
  175 +
  176 + if(rs.size() >= 3)
  177 + break;
  178 + }
  179 + return rs;
  180 + }
  181 +}
... ...