Commit e237b1794af991c50f158baac7da0ad6859547c5

Authored by yiming
1 parent e77a52f9

临港路单推送

src/main/java/com/example/demo/SaticScheduleTask.java
@@ -2,10 +2,13 @@ package com.example.demo; @@ -2,10 +2,13 @@ package com.example.demo;
2 2
3 3
4 4
5 -import com.example.demo.model.Scheduling;  
6 -import com.example.demo.model.SchedulingData;  
7 -import com.example.demo.model.StationRouteData; 5 +
  6 +import cn.hutool.http.HttpUtil;
  7 +import com.alibaba.fastjson.JSON;
  8 +import com.alibaba.fastjson.JSONArray;
  9 +import com.example.demo.model.Waybill;
8 import com.example.demo.service.Contrast; 10 import com.example.demo.service.Contrast;
  11 +import com.example.demo.service.DriverCardService;
9 import org.slf4j.Logger; 12 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory; 13 import org.slf4j.LoggerFactory;
11 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,42 +36,27 @@ public class SaticScheduleTask { @@ -33,42 +36,27 @@ public class SaticScheduleTask {
33 @Autowired 36 @Autowired
34 private Contrast contrast; 37 private Contrast contrast;
35 38
36 - public static Map<String,List<SchedulingData>> SchedulingDataMap=new HashMap<>(); 39 + @Autowired
  40 + private DriverCardService driverCardService;
37 41
38 - public static List<List<StationRouteData>> StationRouteData=new ArrayList<>();  
39 42
40 @Scheduled(cron = "0 0 12 * * ?") 43 @Scheduled(cron = "0 0 12 * * ?")
41 @PostConstruct 44 @PostConstruct
42 void getArrivalInfos(){ 45 void getArrivalInfos(){
43 try { 46 try {
44 LocalDateTime now=LocalDate.now().atStartOfDay(); 47 LocalDateTime now=LocalDate.now().atStartOfDay();
45 - DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");  
46 -/* DateTimeFormatter tdf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");  
47 - now=LocalDateTime.parse("2024-08-26 00:00",tdf);*/  
48 - if(SchedulingDataMap.size()==0){  
49 - List<SchedulingData> dataList1=contrast.getSchedulingS(now,1);  
50 - SchedulingDataMap.put(now.minusDays(1).format(dtf),dataList1);  
51 - logger.info(">>>>>>>>>>>>>>"+now.minusDays(1)+"路单信息加载完毕");  
52 -  
53 - List<SchedulingData> dataList2=contrast.getSchedulingS(now,2);  
54 - SchedulingDataMap.put(now.minusDays(2).format(dtf),dataList2);  
55 - logger.info(">>>>>>>>>>>>>>"+now.minusDays(2)+"路单信息加载完毕");  
56 -  
57 - List<SchedulingData> dataList3=contrast.getSchedulingS(now,3);  
58 - SchedulingDataMap.put(now.minusDays(3).format(dtf),dataList3);  
59 - logger.info(">>>>>>>>>>>>>>"+now.minusDays(3)+"路单信息加载完毕");  
60 - }else {  
61 - List<SchedulingData> dataList1=contrast.getSchedulingS(now,1);  
62 - SchedulingDataMap.put(now.minusDays(1).format(dtf),dataList1);  
63 - logger.info(">>>>>>>>>>>>>>"+now.minusDays(1)+"路单信息加载完毕");  
64 - SchedulingDataMap.remove(now.minusDays(4));  
65 - logger.info(">>>>>>>>>>>>>>"+now.minusDays(4)+"路单信息删除完毕");  
66 - }  
67 -  
68 - StationRouteData=contrast.getStationRoutes();  
69 - logger.info(">>>>>>>>>>>>>>站点路由信息加载完毕"); 48 + List<Waybill> dataList=contrast.getSchedulingS(now,1);
  49 + JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(dataList));
  50 + HttpUtil.post("https://160.10.6.50:12602/api/waybillUpload",jsonArray.toString());
  51 + logger.info(">>>>>>>>>>>>>>"+now.minusDays(1)+"路单信息发送完毕");
70 } catch (Exception e) { 52 } catch (Exception e) {
71 e.printStackTrace(); 53 e.printStackTrace();
72 } 54 }
73 } 55 }
  56 +
  57 + @Scheduled(cron = "0 0 1 * * ?")
  58 + @PostConstruct
  59 + void loadDriverCar(){
  60 + driverCardService.loadDriverCar();
  61 + }
74 } 62 }
75 \ No newline at end of file 63 \ No newline at end of file
src/main/java/com/example/demo/control/ScheduleController.java
1 package com.example.demo.control; 1 package com.example.demo.control;
2 2
3 3
4 -import cn.hutool.json.JSONArray;  
5 -import cn.hutool.json.JSONUtil;  
6 -import com.example.demo.SaticScheduleTask;  
7 -import com.example.demo.model.Scheduling;  
8 -import com.example.demo.model.SchedulingData;  
9 -import com.example.demo.model.StationRoute;  
10 -import com.example.demo.model.StationRouteData; 4 +import cn.hutool.http.HttpUtil;
  5 +import com.alibaba.fastjson.JSON;
  6 +import com.alibaba.fastjson.JSONArray;
  7 +import com.example.demo.model.Waybill;
11 import com.example.demo.service.Contrast; 8 import com.example.demo.service.Contrast;
12 -import com.example.demo.util.IPWhiteUtil;  
13 -import com.example.demo.util.IpUtils;  
14 import org.slf4j.Logger; 9 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory; 10 import org.slf4j.LoggerFactory;
16 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -18,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
18 import org.springframework.web.bind.annotation.RequestParam; 13 import org.springframework.web.bind.annotation.RequestParam;
19 import org.springframework.web.bind.annotation.RestController; 14 import org.springframework.web.bind.annotation.RestController;
20 import javax.servlet.http.HttpServletRequest; 15 import javax.servlet.http.HttpServletRequest;
  16 +import java.time.LocalDate;
21 import java.time.LocalDateTime; 17 import java.time.LocalDateTime;
22 import java.time.format.DateTimeFormatter; 18 import java.time.format.DateTimeFormatter;
23 import java.util.List; 19 import java.util.List;
@@ -31,21 +27,17 @@ public class ScheduleController { @@ -31,21 +27,17 @@ public class ScheduleController {
31 private Contrast contrast; 27 private Contrast contrast;
32 28
33 29
34 - private String ipWhite = "58.40.5.18;61.169.120.202;127.0.0.1;localhost;192.168.20.150";  
35 30
36 Logger logger = LoggerFactory.getLogger(this.getClass()); 31 Logger logger = LoggerFactory.getLogger(this.getClass());
37 32
38 @RequestMapping("getSchedules") 33 @RequestMapping("getSchedules")
39 - public JSONArray getSchedules(@RequestParam String date, HttpServletRequest request){ 34 + public JSONArray getSchedules(@RequestParam String date){
40 JSONArray jsonArray= new JSONArray(); 35 JSONArray jsonArray= new JSONArray();
41 try { 36 try {
42 - String ip=IpUtils.getIpAddr(request);  
43 - if (!IPWhiteUtil.checkRequestIP(ip, ipWhite)) {  
44 - logger.info("拦截的IP为:" + ip);  
45 - return null;  
46 - }  
47 - List<SchedulingData> list= SaticScheduleTask.SchedulingDataMap.get(date);  
48 - jsonArray = JSONUtil.parseArray(list); 37 + DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
  38 + LocalDate localDate= LocalDate.parse(date,dtf);
  39 + List<Waybill> dataList=contrast.getSchedulingS(localDate.atStartOfDay(),0);
  40 + jsonArray= JSON.parseArray(JSON.toJSONString(dataList));
49 } catch (Exception e) { 41 } catch (Exception e) {
50 e.printStackTrace(); 42 e.printStackTrace();
51 } 43 }
@@ -53,23 +45,20 @@ public class ScheduleController { @@ -53,23 +45,20 @@ public class ScheduleController {
53 return jsonArray; 45 return jsonArray;
54 } 46 }
55 47
56 - @RequestMapping("getStationRoutes")  
57 - public JSONArray getStationRoutes(HttpServletRequest request){ 48 + @RequestMapping("sendSchedules")
  49 + public JSONArray sendSchedules(@RequestParam String date){
58 JSONArray jsonArray= new JSONArray(); 50 JSONArray jsonArray= new JSONArray();
59 try { 51 try {
60 - String ip=IpUtils.getIpAddr(request);  
61 - if (!IPWhiteUtil.checkRequestIP(ip, ipWhite)) {  
62 - logger.info("拦截的IP为:" + ip);  
63 - return null;  
64 - }  
65 - List<List<StationRouteData>> list= SaticScheduleTask.StationRouteData;  
66 - jsonArray = JSONUtil.parseArray(list); 52 + DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
  53 + LocalDate localDate= LocalDate.parse(date,dtf);
  54 + List<Waybill> dataList=contrast.getSchedulingS(localDate.atStartOfDay(),0);
  55 + jsonArray= JSON.parseArray(JSON.toJSONString(dataList));
  56 + HttpUtil.post("https://160.10.6.50:12602/api/waybillUpload",jsonArray.toString());
67 } catch (Exception e) { 57 } catch (Exception e) {
68 e.printStackTrace(); 58 e.printStackTrace();
69 } 59 }
70 - logger.info(">>>>>>>>>>>>>>>>站点路由信息返回:"+jsonArray.size()); 60 + logger.info(">>>>>>>>>>>>>>>>路单信息手动推送:"+jsonArray.size());
71 return jsonArray; 61 return jsonArray;
72 } 62 }
73 63
74 -  
75 } 64 }
src/main/java/com/example/demo/mapper/db1/SiteMapper1.java
@@ -24,4 +24,16 @@ public interface SiteMapper1 { @@ -24,4 +24,16 @@ public interface SiteMapper1 {
24 24
25 @DS("db1") 25 @DS("db1")
26 String getMaxTime(String date); 26 String getMaxTime(String date);
  27 +
  28 + @DS("db1")
  29 + List<LinePW> getLinePW();
  30 +
  31 + @DS("db1")
  32 + List<CardDriver> getCardDriver();
  33 +
  34 + @DS("db1")
  35 + void insertCardDriver(List<CardDriver> cardDrivers);
  36 +
  37 + @DS("db1")
  38 + void deleteCardDriver();
27 } 39 }
28 \ No newline at end of file 40 \ No newline at end of file
src/main/java/com/example/demo/model/CardDriver.java 0 → 100644
  1 +package com.example.demo.model;
  2 +
  3 +import java.util.Map;
  4 +
  5 +public class CardDriver {
  6 + private String card_no;
  7 + private String inside_no;
  8 + private String driver_no;
  9 + private String name;
  10 +
  11 + public static CardDriver getInstance(Map m){
  12 + CardDriver cardDriver = new CardDriver();
  13 + cardDriver.setCard_no(m.get("faceNo")!=null?m.get("faceNo").toString():null);
  14 + cardDriver.setInside_no(m.get("inlineNo")!=null?m.get("inlineNo").toString():null);
  15 + cardDriver.setDriver_no(m.get("bandUId")!=null?m.get("bandUId").toString():null);
  16 + cardDriver.setName(m.get("bandUName")!=null?m.get("bandUName").toString():null);
  17 + return cardDriver;
  18 + }
  19 +
  20 + public String getCard_no() {
  21 + return card_no;
  22 + }
  23 +
  24 + public void setCard_no(String card_no) {
  25 + this.card_no = card_no;
  26 + }
  27 +
  28 + public String getInside_no() {
  29 + return inside_no;
  30 + }
  31 +
  32 + public void setInside_no(String inside_no) {
  33 + this.inside_no = inside_no;
  34 + }
  35 +
  36 + public String getDriver_no() {
  37 + return driver_no;
  38 + }
  39 +
  40 + public void setDriver_no(String driver_no) {
  41 + this.driver_no = driver_no;
  42 + }
  43 +
  44 + public String getName() {
  45 + return name;
  46 + }
  47 +
  48 + public void setName(String name) {
  49 + this.name = name;
  50 + }
  51 +}
src/main/java/com/example/demo/model/LinePW.java 0 → 100644
  1 +package com.example.demo.model;
  2 +
  3 +public class LinePW {
  4 + private String line_code;
  5 + private String line_name;
  6 + private String line_id;
  7 +
  8 + public String getLine_code() {
  9 + return line_code;
  10 + }
  11 +
  12 + public void setLine_code(String line_code) {
  13 + this.line_code = line_code;
  14 + }
  15 +
  16 + public String getLine_name() {
  17 + return line_name;
  18 + }
  19 +
  20 + public void setLine_name(String line_name) {
  21 + this.line_name = line_name;
  22 + }
  23 +
  24 + public String getLine_id() {
  25 + return line_id;
  26 + }
  27 +
  28 + public void setLine_id(String line_id) {
  29 + this.line_id = line_id;
  30 + }
  31 +}
src/main/java/com/example/demo/model/Scheduling.java
@@ -21,6 +21,16 @@ public class Scheduling implements Comparable&lt;Scheduling&gt; ,Cloneable{ @@ -21,6 +21,16 @@ public class Scheduling implements Comparable&lt;Scheduling&gt; ,Cloneable{
21 private String zdsj_actual;//实际到达时间 21 private String zdsj_actual;//实际到达时间
22 private String shanghai_linecode; 22 private String shanghai_linecode;
23 23
  24 + public String getS_gh() {
  25 + return s_gh;
  26 + }
  27 +
  28 + public void setS_gh(String s_gh) {
  29 + this.s_gh = s_gh;
  30 + }
  31 +
  32 + private String s_gh;//驾驶员工号
  33 +
24 private List<InOutStation> inOutStations; 34 private List<InOutStation> inOutStations;
25 35
26 36
src/main/java/com/example/demo/model/SchedulingData.java deleted 100644 → 0
1 -package com.example.demo.model;  
2 -  
3 -import java.util.List;  
4 -  
5 -public class SchedulingData {  
6 - private String date;//日期YYYYMMDD  
7 - private String nbbm;//车辆内部编码  
8 - private String deviceID;//车辆内部编码  
9 - private String company;//公司号  
10 - private String driver;//驾驶员工号  
11 - private String lineCode;//上海市线路编码  
12 - private String carPlate;//车牌 例如D12345不带中文  
13 - private String upDown;//上下行 0上行,1下行  
14 - private String qdzName;//起点站名称  
15 - private String qdzCode;//起点站编码  
16 - private String zdzName;//终点站名称  
17 - private String zdzCode;//终点站编码  
18 - private String fcsj;//实际发车时间hhmmss  
19 - private String zdsj;//实际到达时间hhmmss  
20 -  
21 - private List<InOutStation> inOutStations;//进出站信息  
22 -  
23 -  
24 - public static SchedulingData getInstance(Scheduling scheduling){  
25 - SchedulingData schedulingKFK=new SchedulingData();  
26 - schedulingKFK.setDate(scheduling.getSchedule_date_str()!=null?scheduling.getSchedule_date_str().replace("-",""):null);  
27 - schedulingKFK.setNbbm(scheduling.getCl_zbh());  
28 - schedulingKFK.setDeviceID(scheduling.getEquipment_code());  
29 - schedulingKFK.setCompany(scheduling.getGs_bm());  
30 - schedulingKFK.setDriver(scheduling.getJ_gh());  
31 - schedulingKFK.setLineCode(scheduling.getShanghai_linecode());  
32 - schedulingKFK.setCarPlate(scheduling.getCar_plate()!=null?scheduling.getCar_plate().replace("沪",""):null);  
33 - schedulingKFK.setUpDown(scheduling.getXl_dir());  
34 - schedulingKFK.setQdzName(scheduling.getQdz_name());  
35 - schedulingKFK.setQdzCode(scheduling.getQdz_code());  
36 - schedulingKFK.setZdzName(scheduling.getZdz_name());  
37 - schedulingKFK.setZdzCode(scheduling.getZdz_code());  
38 - schedulingKFK.setFcsj(scheduling.getFcsj_actual()!=null?scheduling.getFcsj_actual().replace(":","")+"00":null);  
39 - schedulingKFK.setZdsj(scheduling.getZdsj_actual()!=null?scheduling.getZdsj_actual().replace(":","")+"00":null);  
40 - schedulingKFK.setInOutStations(scheduling.getInOutStations());  
41 - return schedulingKFK;  
42 - }  
43 -  
44 - public String getDeviceID() {  
45 - return deviceID;  
46 - }  
47 -  
48 - public void setDeviceID(String deviceID) {  
49 - this.deviceID = deviceID;  
50 - }  
51 -  
52 - public String getDate() {  
53 - return date;  
54 - }  
55 -  
56 - public void setDate(String date) {  
57 - this.date = date;  
58 - }  
59 -  
60 - public String getNbbm() {  
61 - return nbbm;  
62 - }  
63 -  
64 - public void setNbbm(String nbbm) {  
65 - this.nbbm = nbbm;  
66 - }  
67 -  
68 - public String getCompany() {  
69 - return company;  
70 - }  
71 -  
72 - public void setCompany(String company) {  
73 - this.company = company;  
74 - }  
75 -  
76 - public String getDriver() {  
77 - return driver;  
78 - }  
79 -  
80 - public void setDriver(String driver) {  
81 - this.driver = driver;  
82 - }  
83 -  
84 - public String getLineCode() {  
85 - return lineCode;  
86 - }  
87 -  
88 - public void setLineCode(String lineCode) {  
89 - this.lineCode = lineCode;  
90 - }  
91 -  
92 - public String getCarPlate() {  
93 - return carPlate;  
94 - }  
95 -  
96 - public void setCarPlate(String carPlate) {  
97 - this.carPlate = carPlate;  
98 - }  
99 -  
100 - public String getUpDown() {  
101 - return upDown;  
102 - }  
103 -  
104 - public void setUpDown(String upDown) {  
105 - this.upDown = upDown;  
106 - }  
107 -  
108 - public String getQdzName() {  
109 - return qdzName;  
110 - }  
111 -  
112 - public void setQdzName(String qdzName) {  
113 - this.qdzName = qdzName;  
114 - }  
115 -  
116 - public String getQdzCode() {  
117 - return qdzCode;  
118 - }  
119 -  
120 - public void setQdzCode(String qdzCode) {  
121 - this.qdzCode = qdzCode;  
122 - }  
123 -  
124 - public String getZdzName() {  
125 - return zdzName;  
126 - }  
127 -  
128 - public void setZdzName(String zdzName) {  
129 - this.zdzName = zdzName;  
130 - }  
131 -  
132 - public String getZdzCode() {  
133 - return zdzCode;  
134 - }  
135 -  
136 - public void setZdzCode(String zdzCode) {  
137 - this.zdzCode = zdzCode;  
138 - }  
139 -  
140 - public String getFcsj() {  
141 - return fcsj;  
142 - }  
143 -  
144 - public void setFcsj(String fcsj) {  
145 - this.fcsj = fcsj;  
146 - }  
147 -  
148 - public String getZdsj() {  
149 - return zdsj;  
150 - }  
151 -  
152 - public void setZdsj(String zdsj) {  
153 - this.zdsj = zdsj;  
154 - }  
155 -  
156 - public List<InOutStation> getInOutStations() {  
157 - return inOutStations;  
158 - }  
159 -  
160 - public void setInOutStations(List<InOutStation> inOutStations) {  
161 - this.inOutStations = inOutStations;  
162 - }  
163 -  
164 -}  
src/main/java/com/example/demo/model/StationRouteData.java deleted 100644 → 0
1 -package com.example.demo.model;  
2 -  
3 -public class StationRouteData {  
4 - private String stationRouteCode;  
5 - private String directions;  
6 - private String lineCode;  
7 - private String stationName;  
8 - private String stationCode;  
9 -  
10 -  
11 -  
12 - public static StationRouteData getInstance(StationRoute stationRoute){  
13 - StationRouteData stationRouteKFK=new StationRouteData();  
14 - stationRouteKFK.setStationRouteCode(stationRoute.getStation_route_code());  
15 - stationRouteKFK.setDirections(stationRoute.getDirections());  
16 - stationRouteKFK.setLineCode(stationRoute.getShanghai_linecode());  
17 - stationRouteKFK.setStationName(stationRoute.getStation_name());  
18 - stationRouteKFK.setStationCode(stationRoute.getStation_code());  
19 - return stationRouteKFK;  
20 - }  
21 -  
22 - public String getStationRouteCode() {  
23 - return stationRouteCode;  
24 - }  
25 -  
26 - public void setStationRouteCode(String stationRouteCode) {  
27 - this.stationRouteCode = stationRouteCode;  
28 - }  
29 -  
30 - public String getDirections() {  
31 - return directions;  
32 - }  
33 -  
34 - public void setDirections(String directions) {  
35 - this.directions = directions;  
36 - }  
37 -  
38 - public String getLineCode() {  
39 - return lineCode;  
40 - }  
41 -  
42 - public void setLineCode(String lineCode) {  
43 - this.lineCode = lineCode;  
44 - }  
45 -  
46 - public String getStationName() {  
47 - return stationName;  
48 - }  
49 -  
50 - public void setStationName(String stationName) {  
51 - this.stationName = stationName;  
52 - }  
53 -  
54 - public String getStationCode() {  
55 - return stationCode;  
56 - }  
57 -  
58 - public void setStationCode(String stationCode) {  
59 - this.stationCode = stationCode;  
60 - }  
61 -}  
src/main/java/com/example/demo/model/StopInfo.java 0 → 100644
  1 +package com.example.demo.model;
  2 +
  3 +public class StopInfo {
  4 +
  5 + private String stopInfoID;//内部编码
  6 + private String stopSeq;//站点序号
  7 + private String stopTime;//时间
  8 + private String inOutStation;//进出站
  9 +
  10 +
  11 + public String getStopInfoID() {
  12 + return stopInfoID;
  13 + }
  14 +
  15 + public void setStopInfoID(String stopInfoID) {
  16 + this.stopInfoID = stopInfoID;
  17 + }
  18 +
  19 + public String getStopSeq() {
  20 + return stopSeq;
  21 + }
  22 +
  23 + public void setStopSeq(String stopSeq) {
  24 + this.stopSeq = stopSeq;
  25 + }
  26 +
  27 + public String getStopTime() {
  28 + return stopTime;
  29 + }
  30 +
  31 + public void setStopTime(String stopTime) {
  32 + this.stopTime = stopTime;
  33 + }
  34 +
  35 + public String getInOutStation() {
  36 + return inOutStation;
  37 + }
  38 +
  39 + public void setInOutStation(String inOutStation) {
  40 + this.inOutStation = inOutStation;
  41 + }
  42 +}
src/main/java/com/example/demo/model/Waybill.java 0 → 100644
  1 +package com.example.demo.model;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +public class Waybill {
  7 + private String routeDate;//日期YYYYMMDD
  8 + private String tripID;//上海市线路编码
  9 + private String companyNO;//公司号
  10 + private String driver;//司售卡卡内号
  11 + private String routeCode;//票务线路编码
  12 + private String carPlate;//车牌
  13 + private String upDownTrip;//上下行
  14 + private String startStation;//起点站
  15 + private String startStationCode;//起点站编码
  16 + private String endStation;//终点站
  17 + private String endStationCode;//终点站编码
  18 + private String departureTime;//发车时间
  19 + private String arrivalTime;//到达时间
  20 +
  21 + private List<StopInfo> stopInfosList;//进出站信息
  22 +
  23 + public static Waybill getInstance(Scheduling scheduling){
  24 + Waybill waybill=new Waybill();
  25 + waybill.setRouteDate(scheduling.getSchedule_date_str()!=null?scheduling.getSchedule_date_str().replace("-",""):null);
  26 + waybill.setTripID(scheduling.getShanghai_linecode());
  27 + waybill.setCompanyNO("");
  28 + waybill.setCarPlate(scheduling.getCar_plate()!=null?scheduling.getCar_plate().replace("沪",""):null);
  29 + waybill.setUpDownTrip(scheduling.getXl_dir());
  30 + waybill.setStartStation(scheduling.getQdz_name());
  31 + waybill.setStartStationCode(scheduling.getQdz_code());
  32 + waybill.setEndStation(scheduling.getZdz_name());
  33 + waybill.setEndStationCode(scheduling.getZdz_code());
  34 + waybill.setDepartureTime(scheduling.getFcsj_actual()!=null?scheduling.getFcsj_actual().replace(":","")+"00":null);
  35 + waybill.setArrivalTime(scheduling.getZdsj_actual()!=null?scheduling.getZdsj_actual().replace(":","")+"00":null);
  36 +
  37 + List<StopInfo> stopInfos=new ArrayList<>();
  38 + List<InOutStation> inOutStations=scheduling.getInOutStations();
  39 + if(inOutStations!=null){
  40 + inOutStations.forEach(station -> {
  41 + StopInfo stopInfoIn=new StopInfo();
  42 + stopInfoIn.setStopInfoID(station.getStop_no());
  43 + stopInfoIn.setStopSeq(station.getStationRouteCode());
  44 + stopInfoIn.setInOutStation("0");
  45 + stopInfoIn.setStopTime(station.getInTimeStr());
  46 +
  47 + StopInfo stopInfoOut=new StopInfo();
  48 + stopInfoOut.setStopInfoID(station.getStop_no());
  49 + stopInfoOut.setStopSeq(station.getStationRouteCode());
  50 + stopInfoOut.setInOutStation("1");
  51 + stopInfoOut.setStopTime(station.getOutTimeStr());
  52 + stopInfos.add(stopInfoIn);
  53 + stopInfos.add(stopInfoOut);
  54 + });
  55 + }
  56 + waybill.setStopInfosList(stopInfos);
  57 + return waybill;
  58 + }
  59 +
  60 + public String getCompanyNO() {
  61 + return companyNO;
  62 + }
  63 +
  64 + public void setCompanyNO(String companyNO) {
  65 + this.companyNO = companyNO;
  66 + }
  67 +
  68 + public String getRouteDate() {
  69 + return routeDate;
  70 + }
  71 +
  72 + public void setRouteDate(String routeDate) {
  73 + this.routeDate = routeDate;
  74 + }
  75 +
  76 + public String getTripID() {
  77 + return tripID;
  78 + }
  79 +
  80 + public void setTripID(String tripID) {
  81 + this.tripID = tripID;
  82 + }
  83 +
  84 + public String getDriver() {
  85 + return driver;
  86 + }
  87 +
  88 + public void setDriver(String driver) {
  89 + this.driver = driver;
  90 + }
  91 +
  92 + public String getRouteCode() {
  93 + return routeCode;
  94 + }
  95 +
  96 + public void setRouteCode(String routeCode) {
  97 + this.routeCode = routeCode;
  98 + }
  99 +
  100 + public String getCarPlate() {
  101 + return carPlate;
  102 + }
  103 +
  104 + public void setCarPlate(String carPlate) {
  105 + this.carPlate = carPlate;
  106 + }
  107 +
  108 + public String getUpDownTrip() {
  109 + return upDownTrip;
  110 + }
  111 +
  112 + public void setUpDownTrip(String upDownTrip) {
  113 + this.upDownTrip = upDownTrip;
  114 + }
  115 +
  116 + public String getStartStation() {
  117 + return startStation;
  118 + }
  119 +
  120 + public void setStartStation(String startStation) {
  121 + this.startStation = startStation;
  122 + }
  123 +
  124 + public String getStartStationCode() {
  125 + return startStationCode;
  126 + }
  127 +
  128 + public void setStartStationCode(String startStationCode) {
  129 + this.startStationCode = startStationCode;
  130 + }
  131 +
  132 + public String getEndStation() {
  133 + return endStation;
  134 + }
  135 +
  136 + public void setEndStation(String endStation) {
  137 + this.endStation = endStation;
  138 + }
  139 +
  140 + public String getEndStationCode() {
  141 + return endStationCode;
  142 + }
  143 +
  144 + public void setEndStationCode(String endStationCode) {
  145 + this.endStationCode = endStationCode;
  146 + }
  147 +
  148 + public String getDepartureTime() {
  149 + return departureTime;
  150 + }
  151 +
  152 + public void setDepartureTime(String departureTime) {
  153 + this.departureTime = departureTime;
  154 + }
  155 +
  156 + public String getArrivalTime() {
  157 + return arrivalTime;
  158 + }
  159 +
  160 + public void setArrivalTime(String arrivalTime) {
  161 + this.arrivalTime = arrivalTime;
  162 + }
  163 +
  164 + public List<StopInfo> getStopInfosList() {
  165 + return stopInfosList;
  166 + }
  167 +
  168 + public void setStopInfosList(List<StopInfo> stopInfosList) {
  169 + this.stopInfosList = stopInfosList;
  170 + }
  171 +}
src/main/java/com/example/demo/service/Contrast.java
@@ -27,29 +27,38 @@ public class Contrast { @@ -27,29 +27,38 @@ public class Contrast {
27 @Autowired 27 @Autowired
28 private SiteMapper2 siteMapper2; 28 private SiteMapper2 siteMapper2;
29 29
30 - @Autowired  
31 - private KafkaTemplate kafkaTemplate;  
32 -  
33 30
34 31
35 /** 32 /**
36 * @Description:车辆、排班、进出站、路由的关联及预加载 33 * @Description:车辆、排班、进出站、路由的关联及预加载
37 * @Param: now加载的最终时间 day加载几天 34 * @Param: now加载的最终时间 day加载几天
38 * @Author: YM 35 * @Author: YM
39 - * @Date: 2021/10/12 36 + * @Date: 2024/09/19
40 */ 37 */
41 - public List<SchedulingData> getSchedulingS(LocalDateTime now,int day) throws Exception{  
42 - List<SchedulingData> schedulingDataList=new ArrayList<>(); 38 + public List<Waybill> getSchedulingS(LocalDateTime now, int day) throws Exception{
  39 + List<Waybill> waybillList=new ArrayList<>();
43 List<Scheduling> schedulingS=new ArrayList<>(); 40 List<Scheduling> schedulingS=new ArrayList<>();
44 Map map = new HashMap(); 41 Map map = new HashMap();
45 - 42 + Set<String> drivers=new HashSet<>();
  43 + List<LinePW> linePWS = siteMapper1.getLinePW();
  44 + Map<String,String> linePWMap=new HashMap<>();
  45 + linePWS.forEach(linePW -> {
  46 + linePWMap.put(linePW.getLine_code(), linePW.getLine_id());
  47 + });
  48 + List<CardDriver> cardDrivers = siteMapper1.getCardDriver();
  49 + Map<String,String> cardDriverMap=new HashMap<>();
  50 + cardDrivers.forEach(cardDriver -> {
  51 + if(cardDriver.getDriver_no()!=null && cardDriver.getDriver_no().split("-").length==2){
  52 + cardDriverMap.put(cardDriver.getDriver_no().split("-")[1], cardDriver.getCard_no());
  53 + }
  54 + });
46 //计算开始结束时间 55 //计算开始结束时间
47 LocalDateTime localDateTimeStart=now.minusDays(day); 56 LocalDateTime localDateTimeStart=now.minusDays(day);
48 DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd"); 57 DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
49 DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); 58 DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
50 String dateTime = siteMapper1.getMaxTime(localDateTimeStart.format(df)); 59 String dateTime = siteMapper1.getMaxTime(localDateTimeStart.format(df));
51 if(dateTime==null){ 60 if(dateTime==null){
52 - return schedulingDataList; 61 + return waybillList;
53 } 62 }
54 LocalDateTime localDateTimeEnd=LocalDateTime.parse(dateTime,dtf).plusMinutes(5); 63 LocalDateTime localDateTimeEnd=LocalDateTime.parse(dateTime,dtf).plusMinutes(5);
55 64
@@ -165,92 +174,24 @@ public class Contrast { @@ -165,92 +174,24 @@ public class Contrast {
165 } 174 }
166 175
167 for (Scheduling scheduling : schedulings) { 176 for (Scheduling scheduling : schedulings) {
168 - SchedulingData schedulingData= SchedulingData.getInstance(scheduling);  
169 - schedulingDataList.add(schedulingData);  
170 - }  
171 - logger.info("共"+schedulingDataList.size()+"个班次,未匹配进出站班次"+schedulings2.size());  
172 -  
173 - /*  
174 -  
175 - List<List<SchedulingKFK>> subList = getSubList(100, schedulingKFKS);  
176 - if(!subList.isEmpty()){  
177 - subList.forEach(data->{  
178 - if (!data.isEmpty()) {  
179 - Map<String, Object> map2 = new HashMap<>();  
180 - map2.put("datatype", "scheduling");  
181 - map2.put("datas", data);  
182 - JSON j=new JSONObject(map2);  
183 - String json =j.toString();  
184 - ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("QPGJ", json);  
185 - future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {  
186 - @Override  
187 - public void onSuccess(SendResult<String, String> result) {  
188 - logger.info("kafka发送路单数据成功");  
189 - }  
190 - @Override  
191 - public void onFailure(Throwable ex) {  
192 - logger.error("kafka发送单数数据异常", ex);  
193 - }  
194 - });  
195 - }  
196 - });  
197 - }*/  
198 - return schedulingDataList;  
199 - }  
200 -  
201 - public List<List<StationRouteData>> getStationRoutes(){  
202 - List<List<StationRouteData>> list = new ArrayList<>();  
203 - List<StationRoute> StationRouteList=siteMapper1.getStationRoute();  
204 -  
205 - List<StationRouteData> routeData=new ArrayList<>();  
206 - for (StationRoute stationRoute : StationRouteList) {  
207 - StationRouteData stationRouteData= StationRouteData.getInstance(stationRoute);  
208 - routeData.add(stationRouteData);  
209 - }  
210 -  
211 - Map<String, List<StationRouteData>> StationRoutes = routeData.stream().collect(Collectors.groupingBy(s->s.getLineCode()+"_"+s.getDirections()));  
212 - StationRoutes.forEach((k,v)->{  
213 - list.add(v);  
214 - });  
215 -  
216 -  
217 - /*if(!list.isEmpty()){  
218 - Map<String, Object> map = new HashMap<>();  
219 - map.put("datatype", "stationRoute");  
220 - map.put("datas", list);  
221 - JSON j=new JSONObject(map);  
222 - String json =j.toString();  
223 - ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("QPGJ", json);  
224 - future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {  
225 - @Override  
226 - public void onSuccess(SendResult<String, String> result) {  
227 - logger.info("kafka站点路由数据成功");  
228 - }  
229 - @Override  
230 - public void onFailure(Throwable ex) {  
231 - logger.error("kafka发送站点路由数据异常", ex);  
232 - }  
233 - });  
234 - }*/  
235 - return list;  
236 - }  
237 -  
238 - public List<List<SchedulingData>> getSubList(int length, List<SchedulingData> list){  
239 - int size = list.size();  
240 - int temp = size / length + 1;  
241 - boolean result = size % length == 0;  
242 - List<List<SchedulingData>> subList = new ArrayList<>();  
243 - for (int i = 0; i < temp; i++) {  
244 - if (i == temp - 1) {  
245 - if (result) {  
246 - break;  
247 - }  
248 - subList.add(list.subList(length * i, size)) ;  
249 - } else {  
250 - subList.add(list.subList(length * i, length * (i + 1))) ; 177 + Waybill waybill= Waybill.getInstance(scheduling);
  178 + if(cardDriverMap.get(scheduling.getJ_gh())!=null){
  179 + waybill.setDriver(cardDriverMap.get(scheduling.getJ_gh()));
  180 + }else{
  181 + waybill.setDriver(cardDriverMap.get(scheduling.getS_gh()));
  182 + }
  183 + if(waybill.getDriver()==null){
  184 + drivers.add(scheduling.getJ_gh());
251 } 185 }
  186 + waybill.setRouteCode(linePWMap.get(scheduling.getXl_bm()));
  187 + waybillList.add(waybill);
252 } 188 }
253 - return subList; 189 + drivers.forEach(s -> {
  190 + logger.info(s);
  191 + });
  192 + logger.info("共"+waybillList.size()+"个班次,未匹配进出站班次"+schedulings2.size());
  193 + logger.info("未匹配司售卡"+drivers.size());
  194 + return waybillList;
254 } 195 }
255 196
256 197
src/main/java/com/example/demo/service/DriverCardService.java 0 → 100644
  1 +package com.example.demo.service;
  2 +
  3 +import cn.hutool.http.HttpUtil;
  4 +import com.alibaba.fastjson.JSON;
  5 +import com.example.demo.mapper.db1.SiteMapper1;
  6 +import com.example.demo.model.CardDriver;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +import java.util.ArrayList;
  10 +import java.util.HashMap;
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
  14 +@Service
  15 +public class DriverCardService {
  16 +
  17 + @Autowired
  18 + private SiteMapper1 siteMapper1;
  19 +
  20 + public void loadDriverCar(){
  21 + try {
  22 + String sb = HttpUtil.post("http://10.10.150.53:18080/demoserver/business/findDriverSaleCardList",new HashMap<>());
  23 + List<Map> result= JSON.parseArray(sb,Map.class);
  24 + List<CardDriver> cardDrivers = new ArrayList<>();
  25 + if(result!=null && result.size()>0){
  26 + for (Map map : result) {
  27 + cardDrivers.add(CardDriver.getInstance(map));
  28 + }
  29 + siteMapper1.deleteCardDriver();
  30 + siteMapper1.insertCardDriver(cardDrivers);
  31 + }
  32 + } catch (Exception e) {
  33 + e.printStackTrace();
  34 + }
  35 + }
  36 +}
src/main/resources/application.properties
1 server.port=19092 1 server.port=19092
2 2
3 -spring.datasource.db1.jdbc-url=jdbc:mysql://192.168.50.213:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false 3 +spring.datasource.db1.jdbc-url=jdbc:mysql://10.10.150.103:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
4 spring.datasource.db1.username=root 4 spring.datasource.db1.username=root
5 -spring.datasource.db1.password=root2jsp 5 +spring.datasource.db1.password=fsodlgjiuigAQF2$9fs9
6 spring.datasource.db1.driver-class-name=com.mysql.cj.jdbc.Driver 6 spring.datasource.db1.driver-class-name=com.mysql.cj.jdbc.Driver
7 spring.datasource.db1.druid.test-on-borrow=true 7 spring.datasource.db1.druid.test-on-borrow=true
8 spring.datasource.db1.druid.test-while-idle=true 8 spring.datasource.db1.druid.test-while-idle=true
9 9
10 -spring.datasource.db2.jdbc-url=jdbc:mysql://192.168.50.213:3306/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false 10 +spring.datasource.db2.jdbc-url=jdbc:mysql://10.10.150.103:3306/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false
11 spring.datasource.db2.username=root 11 spring.datasource.db2.username=root
12 -spring.datasource.db2.password=root2jsp 12 +spring.datasource.db2.password=fsodlgjiuigAQF2$9fs9
13 spring.datasource.db2.driver-class-name=com.mysql.cj.jdbc.Driver 13 spring.datasource.db2.driver-class-name=com.mysql.cj.jdbc.Driver
14 spring.datasource.db2.druid.test-on-borrow=true 14 spring.datasource.db2.druid.test-on-borrow=true
15 spring.datasource.db2.druid.test-while-idle=true 15 spring.datasource.db2.druid.test-while-idle=true
@@ -20,12 +20,6 @@ mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl @@ -20,12 +20,6 @@ mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
20 logging.level.com.example.demo.mapper=info 20 logging.level.com.example.demo.mapper=info
21 #logging.level.org.mybatis = debug 21 #logging.level.org.mybatis = debug
22 22
23 -spring.kafka.bootstrap-servers=192.168.40.82:9092  
24 -spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer  
25 -spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer  
26 -spring.kafka.producer.buffer-memory=33554432  
27 -spring.kafka.producer.acks=all  
28 -spring.kafka.producer.properties.max.request.size=20971520  
29 23
30 24
31 25
src/main/resources/mapping/db1/Site-mapper1.xml
@@ -50,5 +50,27 @@ @@ -50,5 +50,27 @@
50 where (bc_type ='normal' or bc_type ='venting') and schedule_date_str='${date}' 50 where (bc_type ='normal' or bc_type ='venting') and schedule_date_str='${date}'
51 </select> 51 </select>
52 52
  53 + <select id="getLinePW" resultType="com.example.demo.model.LinePW">
  54 + SELECT * FROM `bsth_c_line_pw`
  55 + </select>
  56 +
  57 + <select id="getCardDriver" resultType="com.example.demo.model.CardDriver">
  58 + SELECT * FROM `card_driver`
  59 + </select>
  60 +
  61 + <insert id="insertCardDriver" parameterType="com.example.demo.model.CardDriver">
  62 + INSERT INTO `card_driver` (
  63 + `card_no`, `inside_no`, `driver_no`, `name`
  64 + )
  65 + VALUES
  66 + <foreach collection="list" item="card" index="index" separator=",">
  67 + ( #{card.card_no}, #{card.inside_no}, #{card.driver_no}, #{card.name})
  68 + </foreach>
  69 + </insert>
  70 +
  71 + <delete id="deleteCardDriver">
  72 + delete from `card_driver`
  73 + </delete>
  74 +
53 75
54 </mapper> 76 </mapper>
55 \ No newline at end of file 77 \ No newline at end of file