Commit 1b85033d107cb4b93fe217af24869faba449d41a

Authored by 王通
1 parent c362c2a5

1.minhang

src/main/java/com/bsth/CXFConfig.java
@@ -4,7 +4,6 @@ package com.bsth; @@ -4,7 +4,6 @@ package com.bsth;
4 import com.bsth.server_rs.AuthorizeInterceptor_IN; 4 import com.bsth.server_rs.AuthorizeInterceptor_IN;
5 import com.bsth.server_rs.base_info.car.CarRestService; 5 import com.bsth.server_rs.base_info.car.CarRestService;
6 import com.bsth.server_rs.base_info.carpark.CarparkRestService; 6 import com.bsth.server_rs.base_info.carpark.CarparkRestService;
7 -import com.bsth.server_rs.base_info.iocarpark.IoCarparkRestService;  
8 import com.bsth.server_rs.base_info.line.LineRestService; 7 import com.bsth.server_rs.base_info.line.LineRestService;
9 import com.bsth.server_rs.base_info.person.PersonRestService; 8 import com.bsth.server_rs.base_info.person.PersonRestService;
10 import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService; 9 import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
@@ -15,18 +14,16 @@ import com.bsth.server_rs.bigdata.BigscreenService; @@ -15,18 +14,16 @@ import com.bsth.server_rs.bigdata.BigscreenService;
15 import com.bsth.server_rs.departure.DepartureRestService; 14 import com.bsth.server_rs.departure.DepartureRestService;
16 import com.bsth.server_rs.destroy.DestroyDetailRestService; 15 import com.bsth.server_rs.destroy.DestroyDetailRestService;
17 import com.bsth.server_rs.directive.DirectiveRestService; 16 import com.bsth.server_rs.directive.DirectiveRestService;
18 -import com.bsth.server_rs.dks.DksRestService; 17 +import com.bsth.server_rs.dispatch.DispatchService;
19 import com.bsth.server_rs.electric.ElectricService; 18 import com.bsth.server_rs.electric.ElectricService;
20 import com.bsth.server_rs.exception.AesExceptionMapper; 19 import com.bsth.server_rs.exception.AesExceptionMapper;
21 import com.bsth.server_rs.gps.GpsRestService; 20 import com.bsth.server_rs.gps.GpsRestService;
22 import com.bsth.server_rs.logs.RealLogRestService; 21 import com.bsth.server_rs.logs.RealLogRestService;
23 -import com.bsth.server_rs.man_hours.ManHoursRestService;  
24 import com.bsth.server_rs.rate.RateService; 22 import com.bsth.server_rs.rate.RateService;
25 import com.bsth.server_rs.schedule.plan.SchedulePlanService; 23 import com.bsth.server_rs.schedule.plan.SchedulePlanService;
26 import com.bsth.server_rs.schedule.real.ScheduleRealService; 24 import com.bsth.server_rs.schedule.real.ScheduleRealService;
27 import com.bsth.server_rs.schedule.real.StaffViewRealService; 25 import com.bsth.server_rs.schedule.real.StaffViewRealService;
28 import com.bsth.server_rs.waybill.WaybillRestService; 26 import com.bsth.server_rs.waybill.WaybillRestService;
29 -import com.bsth.server_rs.white_ip.WhiteIpRestService;  
30 import com.bsth.server_ws.attendance.AttendanceServiceSoap; 27 import com.bsth.server_ws.attendance.AttendanceServiceSoap;
31 import com.bsth.server_ws.electric_oil.OilServiceSoap; 28 import com.bsth.server_ws.electric_oil.OilServiceSoap;
32 import com.bsth.server_ws.park_station.CompanyServiceSoap; 29 import com.bsth.server_ws.park_station.CompanyServiceSoap;
@@ -134,13 +131,7 @@ public class CXFConfig { @@ -134,13 +131,7 @@ public class CXFConfig {
134 @Autowired 131 @Autowired
135 private DepartureRestService departureRestService; 132 private DepartureRestService departureRestService;
136 @Autowired 133 @Autowired
137 - private DksRestService dksRestService;  
138 - @Autowired  
139 - private WhiteIpRestService whiteIpRestService;  
140 - @Autowired  
141 - private ManHoursRestService manHoursRestService;  
142 - @Autowired  
143 - private IoCarparkRestService ioCarparkRestService; 134 + private DispatchService dispatchService;
144 135
145 @Bean 136 @Bean
146 public Server rsServer() { 137 public Server rsServer() {
@@ -168,10 +159,7 @@ public class CXFConfig { @@ -168,10 +159,7 @@ public class CXFConfig {
168 destroyDetailRestService, 159 destroyDetailRestService,
169 carparkRestService, 160 carparkRestService,
170 departureRestService, 161 departureRestService,
171 - dksRestService,  
172 - whiteIpRestService,  
173 - manHoursRestService,  
174 - ioCarparkRestService)); 162 + dispatchService));
175 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); 163 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
176 //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); 164 //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
177 endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); 165 endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
src/main/java/com/bsth/StartCommand.java
@@ -3,7 +3,6 @@ package com.bsth; @@ -3,7 +3,6 @@ package com.bsth;
3 3
4 import com.bsth.server_rs.gps.buffer.BasicDataRefreshThread; 4 import com.bsth.server_rs.gps.buffer.BasicDataRefreshThread;
5 import com.bsth.server_rs.gps.buffer.GpsRefreshThread; 5 import com.bsth.server_rs.gps.buffer.GpsRefreshThread;
6 -import com.bsth.server_rs.man_hours.ManHoursRefreshScheduler;  
7 import com.bsth.server_rs.schedule.real.thread.ExecSchDataRefreshThread; 6 import com.bsth.server_rs.schedule.real.thread.ExecSchDataRefreshThread;
8 import com.bsth.server_rs.schedule.real.thread.SchInOutDataRefreshThread; 7 import com.bsth.server_rs.schedule.real.thread.SchInOutDataRefreshThread;
9 import com.bsth.server_rs.thread.RfidCardInfoPersistenceThread; 8 import com.bsth.server_rs.thread.RfidCardInfoPersistenceThread;
@@ -34,8 +33,6 @@ public class StartCommand implements CommandLineRunner{ @@ -34,8 +33,6 @@ public class StartCommand implements CommandLineRunner{
34 GpsRefreshThread gpsRefreshThread; 33 GpsRefreshThread gpsRefreshThread;
35 @Autowired 34 @Autowired
36 BasicDataRefreshThread basicDataRefreshThread; 35 BasicDataRefreshThread basicDataRefreshThread;
37 - @Autowired  
38 - ManHoursRefreshScheduler manHoursRefreshScheduler;  
39 36
40 @Override 37 @Override
41 public void run(String... arg0){ 38 public void run(String... arg0){
@@ -52,7 +49,6 @@ public class StartCommand implements CommandLineRunner{ @@ -52,7 +49,6 @@ public class StartCommand implements CommandLineRunner{
52 Application.mainServices.scheduleWithFixedDelay(gpsRefreshThread, 10, 7, TimeUnit.SECONDS); 49 Application.mainServices.scheduleWithFixedDelay(gpsRefreshThread, 10, 7, TimeUnit.SECONDS);
53 //定时刷新基础信息 50 //定时刷新基础信息
54 Application.mainServices.scheduleWithFixedDelay(basicDataRefreshThread, 30, 30, TimeUnit.MINUTES); 51 Application.mainServices.scheduleWithFixedDelay(basicDataRefreshThread, 30, 30, TimeUnit.MINUTES);
55 - manHoursRefreshScheduler.refresh();  
56 } catch (Exception e) { 52 } catch (Exception e) {
57 e.printStackTrace(); 53 e.printStackTrace();
58 } 54 }
src/main/java/com/bsth/server_rs/base_info/iocarpark/IoCarparkRestService.java deleted 100644 → 0
1 -package com.bsth.server_rs.base_info.iocarpark;  
2 -  
3 -import com.bsth.server_rs.base_info.iocarpark.buffer.IoCarparkBufferData;  
4 -import com.bsth.server_rs.base_info.iocarpark.entity.IoCarparkSectionRoute;  
5 -import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute;  
6 -import org.slf4j.Logger;  
7 -import org.slf4j.LoggerFactory;  
8 -import org.springframework.beans.factory.annotation.Autowired;  
9 -import org.springframework.stereotype.Component;  
10 -  
11 -import javax.ws.rs.*;  
12 -import javax.ws.rs.core.MediaType;  
13 -import java.util.Collection;  
14 -import java.util.List;  
15 -import java.util.Map;  
16 -  
17 -/**  
18 - * @author Hill  
19 - */  
20 -  
21 -@Component  
22 -@Path("/iocarpark")  
23 -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})  
24 -public class IoCarparkRestService {  
25 -  
26 - private final static Logger log = LoggerFactory.getLogger(IoCarparkRestService.class);  
27 -  
28 - @Autowired  
29 - IoCarparkBufferData ioCarparkBufferData;  
30 -  
31 - @GET  
32 - @Path("/all")  
33 - public Map<String, Collection<IoCarparkSectionRoute>> findAll(){  
34 - return IoCarparkBufferData.findAllRoute();  
35 - }  
36 -  
37 - @GET  
38 - @Path("/{company}")  
39 - public Map<String, Collection<IoCarparkSectionRoute>> findByCompany(@PathParam("company") String company){  
40 - return ioCarparkBufferData.findRouteByCompany(company);  
41 - }  
42 -  
43 - @GET  
44 - @Path("/line/{lineCode}")  
45 - public Map<String, Collection<IoCarparkSectionRoute>> findByLineCode(@PathParam("lineCode") String lineCode){  
46 - return ioCarparkBufferData.findByLineCode(lineCode);  
47 - }  
48 -}  
src/main/java/com/bsth/server_rs/base_info/iocarpark/buffer/IoCarparkBufferData.java deleted 100644 → 0
1 -package com.bsth.server_rs.base_info.iocarpark.buffer;  
2 -  
3 -import com.bsth.Application;  
4 -import com.bsth.server_rs.base_info.iocarpark.entity.IoCarparkSectionRoute;  
5 -import com.bsth.server_rs.base_info.line.Line;  
6 -import com.bsth.server_rs.base_info.line.buffer.LineBufferData;  
7 -import com.bsth.server_rs.base_info.section.entity.LD_Section;  
8 -import com.google.common.collect.ArrayListMultimap;  
9 -import org.slf4j.Logger;  
10 -import org.slf4j.LoggerFactory;  
11 -import org.springframework.beans.factory.annotation.Autowired;  
12 -import org.springframework.boot.CommandLineRunner;  
13 -import org.springframework.core.annotation.Order;  
14 -import org.springframework.jdbc.core.JdbcTemplate;  
15 -import org.springframework.stereotype.Component;  
16 -  
17 -import java.util.*;  
18 -import java.util.concurrent.ConcurrentHashMap;  
19 -  
20 -/**  
21 - * @author Hill  
22 - */  
23 -@Component  
24 -@Order(6)  
25 -public class IoCarparkBufferData {  
26 -  
27 - @Autowired  
28 - JdbcTemplate jdbcTemplate;  
29 -  
30 - Logger logger = LoggerFactory.getLogger(this.getClass());  
31 -  
32 - /**  
33 - 路由缓存  
34 - 线路编码_上下行 ——> 路由集合  
35 - */  
36 - private static ArrayListMultimap<String, IoCarparkSectionRoute> routeListMap;  
37 -  
38 - public static Map<String, Collection<IoCarparkSectionRoute>> findAllRoute(){  
39 - return routeListMap.asMap();  
40 - }  
41 -  
42 - public static void replaceRoutes(List<IoCarparkSectionRoute> list){  
43 - Collections.sort(list, new Comparator<IoCarparkSectionRoute>() {  
44 - @Override  
45 - public int compare(IoCarparkSectionRoute o1, IoCarparkSectionRoute o2) {  
46 - return o1.getSectionrouteCode().compareTo(o2.getSectionrouteCode());  
47 - }  
48 - });  
49 -  
50 - ArrayListMultimap<String, IoCarparkSectionRoute> routeListMapCopy = ArrayListMultimap.create();  
51 - for(IoCarparkSectionRoute sr : list){  
52 - routeListMapCopy.put(sr.getLineCode()+"_" + sr.getStart() + "_" + sr.getEnd(), sr);  
53 - }  
54 -  
55 - routeListMap = routeListMapCopy;  
56 - }  
57 -  
58 - public Map<String, Collection<IoCarparkSectionRoute>> findRouteByCompany(String company) {  
59 - List<Line> lines = LineBufferData.findByCompany(company);  
60 -  
61 - ArrayListMultimap<String, IoCarparkSectionRoute> listMap = ArrayListMultimap.create();  
62 -  
63 -  
64 - Set<String> ks = routeListMap.keySet();  
65 -  
66 - for(String k : ks){  
67 - if(include(lines, k)){  
68 - listMap.putAll(k, routeListMap.get(k));  
69 - }  
70 - }  
71 - return listMap.asMap();  
72 - }  
73 -  
74 - private static boolean include(List<Line> lines, String k){  
75 -  
76 - for(Line line : lines){  
77 - if(k.startsWith(line.getLineCode() + "_"))  
78 - return true;  
79 - }  
80 - return false;  
81 - }  
82 -  
83 - public Map<String, Collection<IoCarparkSectionRoute>> findByLineCode(String lineCode) {  
84 -  
85 - ArrayListMultimap<String, IoCarparkSectionRoute> listMap = ArrayListMultimap.create();  
86 -  
87 - Set<String> ks = routeListMap.keySet();  
88 -  
89 - for(String k : ks){  
90 - if(k.startsWith(lineCode + "_")){  
91 - listMap.putAll(k, routeListMap.get(k));  
92 - }  
93 - }  
94 - return listMap.asMap();  
95 - }  
96 -}  
src/main/java/com/bsth/server_rs/base_info/iocarpark/entity/IoCarparkSectionRoute.java deleted 100644 → 0
1 -package com.bsth.server_rs.base_info.iocarpark.entity;  
2 -  
3 -import com.bsth.server_rs.base_info.section.entity.LD_Section;  
4 -  
5 -/**  
6 - * @author Hill  
7 - * 进出场路段路由  
8 - */  
9 -public class IoCarparkSectionRoute {  
10 -  
11 - /** 线路编号 */  
12 - private String lineCode;  
13 -  
14 - /**  
15 - * 起点场站编号  
16 - */  
17 - private String start;  
18 -  
19 - /**  
20 - * 终点场站编号  
21 - */  
22 - private String end;  
23 -  
24 - /** 路段编号 */  
25 - private String sectionCode;  
26 -  
27 - /** 路段路由方向 */  
28 - private Integer directions;  
29 -  
30 - /** 路段路由序号 */  
31 - private Integer sectionrouteCode;  
32 -  
33 - /** 版本号 */  
34 - private Integer versions;  
35 -  
36 - /** 路段详细 */  
37 - private LD_Section section;  
38 -  
39 - public String getLineCode() {  
40 - return lineCode;  
41 - }  
42 -  
43 - public void setLineCode(String lineCode) {  
44 - this.lineCode = lineCode;  
45 - }  
46 -  
47 - public String getStart() {  
48 - return start;  
49 - }  
50 -  
51 - public void setStart(String start) {  
52 - this.start = start;  
53 - }  
54 -  
55 - public String getEnd() {  
56 - return end;  
57 - }  
58 -  
59 - public void setEnd(String end) {  
60 - this.end = end;  
61 - }  
62 -  
63 - public String getSectionCode() {  
64 - return sectionCode;  
65 - }  
66 -  
67 - public void setSectionCode(String sectionCode) {  
68 - this.sectionCode = sectionCode;  
69 - }  
70 -  
71 - public Integer getDirections() {  
72 - return directions;  
73 - }  
74 -  
75 - public void setDirections(Integer directions) {  
76 - this.directions = directions;  
77 - }  
78 -  
79 - public Integer getSectionrouteCode() {  
80 - return sectionrouteCode;  
81 - }  
82 -  
83 - public void setSectionrouteCode(Integer sectionrouteCode) {  
84 - this.sectionrouteCode = sectionrouteCode;  
85 - }  
86 -  
87 - public Integer getVersions() {  
88 - return versions;  
89 - }  
90 -  
91 - public void setVersions(Integer versions) {  
92 - this.versions = versions;  
93 - }  
94 -  
95 - public LD_Section getSection() {  
96 - return section;  
97 - }  
98 -  
99 - public void setSection(LD_Section section) {  
100 - this.section = section;  
101 - }  
102 -}  
src/main/java/com/bsth/server_rs/base_info/section/buffer/LD_SectionRefreshThread.java
1 package com.bsth.server_rs.base_info.section.buffer; 1 package com.bsth.server_rs.base_info.section.buffer;
2 2
3 -import com.bsth.server_rs.base_info.iocarpark.buffer.IoCarparkBufferData;  
4 -import com.bsth.server_rs.base_info.iocarpark.entity.IoCarparkSectionRoute;  
5 import com.bsth.server_rs.base_info.section.entity.LD_Section; 3 import com.bsth.server_rs.base_info.section.entity.LD_Section;
6 import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute; 4 import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute;
7 import com.bsth.server_rs.base_info.section.entity.RoadSpeed; 5 import com.bsth.server_rs.base_info.section.entity.RoadSpeed;
@@ -52,16 +50,6 @@ public class LD_SectionRefreshThread extends Thread{ @@ -52,16 +50,6 @@ public class LD_SectionRefreshThread extends Thread{
52 50
53 LD_SectionBufferData.replaceRoutes(routeList); 51 LD_SectionBufferData.replaceRoutes(routeList);
54 52
55 - //进出场路段路由信息  
56 - List<IoCarparkSectionRoute> routeList1 = jdbcTemplate.query("select a.line_code,a.`start`,a.`end`,a.section_code,a.directions,a.sectionroute_code,a.versions from bsth_c_ls_inout_sectionroute a join bsth_c_line_versions b on a.line = b.line and a.versions = b.versions where a.destroy=0 and b.status = 1 ORDER BY a.line_code, versions, `start`, `end`, sectionroute_code",  
57 - BeanPropertyRowMapper.newInstance(IoCarparkSectionRoute.class));  
58 -  
59 - for(IoCarparkSectionRoute sr : routeList1){  
60 - sr.setSection(LD_SectionBufferData.findOne(sr.getSectionCode()));  
61 - }  
62 -  
63 - IoCarparkBufferData.replaceRoutes(routeList1);  
64 -  
65 //查询路段限速信息 53 //查询路段限速信息
66 List<RoadSpeed> roadSpeedList = jdbcTemplate.query("select id,name,ST_AsText(g_road_vector) as g_road_vector,speed,speed_start_date,speed_end_date,line,is_start,create_date,update_date from bsth_c_road_speed where is_start=0", BeanPropertyRowMapper.newInstance(RoadSpeed.class)); 54 List<RoadSpeed> roadSpeedList = jdbcTemplate.query("select id,name,ST_AsText(g_road_vector) as g_road_vector,speed,speed_start_date,speed_end_date,line,is_start,create_date,update_date from bsth_c_road_speed where is_start=0", BeanPropertyRowMapper.newInstance(RoadSpeed.class));
67 if(roadSpeedList.size() > 0) 55 if(roadSpeedList.size() > 0)
src/main/java/com/bsth/server_rs/dispatch/DispatchService.java 0 → 100644
  1 +package com.bsth.server_rs.dispatch;
  2 +
  3 +import com.fasterxml.jackson.databind.ObjectMapper;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  6 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  7 +import org.springframework.jdbc.core.JdbcTemplate;
  8 +import org.springframework.stereotype.Component;
  9 +import org.springframework.web.bind.annotation.PathVariable;
  10 +
  11 +import javax.ws.rs.GET;
  12 +import javax.ws.rs.Path;
  13 +import javax.ws.rs.Produces;
  14 +import javax.ws.rs.core.MediaType;
  15 +import java.io.IOException;
  16 +import java.util.List;
  17 +import java.util.Map;
  18 +
  19 +/**
  20 + * @author Hill
  21 + */
  22 +@Component
  23 +@Path("/dispatch")
  24 +@Produces({MediaType.APPLICATION_JSON})
  25 +public class DispatchService {
  26 +
  27 + @Autowired
  28 + private JdbcTemplate jdbcTemplate;
  29 +
  30 + private ObjectMapper mapper = new ObjectMapper();
  31 +
  32 + @GET
  33 + @Path("/{rq}")
  34 + public List<SchEditInfo> findByRq(@PathVariable String rq) throws IOException {
  35 + List<SchEditInfo> editInfos = jdbcTemplate.query("SELECT a.*,b.xl_name line_name,b.gs_name gsmc,b.fgs_name fgsmc,b.schedule_date_str,b.fcsj FROM logger_sch_modify a JOIN bsth_c_s_sp_info_real b ON a.sch_id = b.id WHERE a.rq = ? AND a.type = 'TZRC'", new Object[]{ rq }, BeanPropertyRowMapper.newInstance(SchEditInfo.class));
  36 + for (SchEditInfo editInfo : editInfos) {
  37 + editInfo.setDetail(mapper.readValue(editInfo.getJsonArray(), Map.class));
  38 + }
  39 +
  40 + return editInfos;
  41 + }
  42 +}
src/main/java/com/bsth/server_rs/dispatch/SchEditInfo.java 0 → 100644
  1 +package com.bsth.server_rs.dispatch;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnore;
  4 +
  5 +import java.util.Map;
  6 +
  7 +/**
  8 + *
  9 + * @author panzhao
  10 + * @date 2017/5/18
  11 + */
  12 +public class SchEditInfo {
  13 +
  14 + private long id;
  15 + /**
  16 + * 日期 yyyy-MM-dd
  17 + */
  18 + private String rq;
  19 +
  20 + /**
  21 + * 时间 HH:mm
  22 + */
  23 + private String timeStr;
  24 +
  25 + /**
  26 + * 时间戳
  27 + */
  28 + private long ts;
  29 +
  30 + @JsonIgnore
  31 + private String lineCode;
  32 +
  33 + @JsonIgnore
  34 + private String gsbm;
  35 +
  36 + @JsonIgnore
  37 + private String fgsbm;
  38 +
  39 + /**
  40 + * 班次ID
  41 + */
  42 + @JsonIgnore
  43 + private long schId;
  44 +
  45 + /**
  46 + * 类型
  47 + */
  48 + private String type;
  49 +
  50 + private String type2;
  51 + /**
  52 + * 操作人 @system 系统/用户名
  53 + */
  54 + private String user;
  55 +
  56 + /**
  57 + * 操作明细
  58 + */
  59 + @JsonIgnore
  60 + private String jsonArray;
  61 +
  62 + private String remarks;
  63 +
  64 + private String lineName;
  65 +
  66 + private String gsmc;
  67 +
  68 + private String fgsmc;
  69 +
  70 + private String scheduleDataStr;
  71 +
  72 + private String fcsj;
  73 +
  74 + private Map<String, Object> detail;
  75 +
  76 + public long getId() {
  77 + return id;
  78 + }
  79 +
  80 + public void setId(long id) {
  81 + this.id = id;
  82 + }
  83 +
  84 + public String getRq() {
  85 + return rq;
  86 + }
  87 +
  88 + public void setRq(String rq) {
  89 + this.rq = rq;
  90 + }
  91 +
  92 + public String getTimeStr() {
  93 + return timeStr;
  94 + }
  95 +
  96 + public void setTimeStr(String timeStr) {
  97 + this.timeStr = timeStr;
  98 + }
  99 +
  100 + public long getTs() {
  101 + return ts;
  102 + }
  103 +
  104 + public void setTs(long ts) {
  105 + this.ts = ts;
  106 + }
  107 +
  108 + public String getLineCode() {
  109 + return lineCode;
  110 + }
  111 +
  112 + public void setLineCode(String lineCode) {
  113 + this.lineCode = lineCode;
  114 + }
  115 +
  116 + public String getGsbm() {
  117 + return gsbm;
  118 + }
  119 +
  120 + public void setGsbm(String gsbm) {
  121 + this.gsbm = gsbm;
  122 + }
  123 +
  124 + public String getFgsbm() {
  125 + return fgsbm;
  126 + }
  127 +
  128 + public void setFgsbm(String fgsbm) {
  129 + this.fgsbm = fgsbm;
  130 + }
  131 +
  132 + public long getSchId() {
  133 + return schId;
  134 + }
  135 +
  136 + public void setSchId(long schId) {
  137 + this.schId = schId;
  138 + }
  139 +
  140 + public String getType() {
  141 + return type;
  142 + }
  143 +
  144 + public void setType(String type) {
  145 + this.type = type;
  146 + }
  147 +
  148 + public String getType2() {
  149 + return type2;
  150 + }
  151 +
  152 + public void setType2(String type2) {
  153 + this.type2 = type2;
  154 + }
  155 +
  156 + public String getUser() {
  157 + return user;
  158 + }
  159 +
  160 + public void setUser(String user) {
  161 + this.user = user;
  162 + }
  163 +
  164 + public String getJsonArray() {
  165 + return jsonArray;
  166 + }
  167 +
  168 + public void setJsonArray(String jsonArray) {
  169 + this.jsonArray = jsonArray;
  170 + }
  171 +
  172 + public String getRemarks() {
  173 + return remarks;
  174 + }
  175 +
  176 + public void setRemarks(String remarks) {
  177 + this.remarks = remarks;
  178 + }
  179 +
  180 + public String getLineName() {
  181 + return lineName;
  182 + }
  183 +
  184 + public void setLineName(String lineName) {
  185 + this.lineName = lineName;
  186 + }
  187 +
  188 + public String getGsmc() {
  189 + return gsmc;
  190 + }
  191 +
  192 + public void setGsmc(String gsmc) {
  193 + this.gsmc = gsmc;
  194 + }
  195 +
  196 + public String getFgsmc() {
  197 + return fgsmc;
  198 + }
  199 +
  200 + public void setFgsmc(String fgsmc) {
  201 + this.fgsmc = fgsmc;
  202 + }
  203 +
  204 + public String getScheduleDataStr() {
  205 + return scheduleDataStr;
  206 + }
  207 +
  208 + public void setScheduleDataStr(String scheduleDataStr) {
  209 + this.scheduleDataStr = scheduleDataStr;
  210 + }
  211 +
  212 + public String getFcsj() {
  213 + return fcsj;
  214 + }
  215 +
  216 + public void setFcsj(String fcsj) {
  217 + this.fcsj = fcsj;
  218 + }
  219 +
  220 + public Map<String, Object> getDetail() {
  221 + return detail;
  222 + }
  223 +
  224 + public void setDetail(Map<String, Object> detail) {
  225 + this.detail = detail;
  226 + }
  227 +}
0 \ No newline at end of file 228 \ No newline at end of file
src/main/java/com/bsth/server_rs/dks/BusMileage.java deleted 100644 → 0
1 -package com.bsth.server_rs.dks;  
2 -  
3 -public class BusMileage {  
4 -  
5 - /**  
6 - *  
7 - */  
8 - private String scheduleDate;  
9 -  
10 - /**  
11 - * 内部编码  
12 - */  
13 - private String nbbm;  
14 -  
15 - /**  
16 - * 计划里程  
17 - */  
18 - private Double jhlc;  
19 -  
20 - /**  
21 - * 实际计划里程  
22 - */  
23 - private Double sjjhlc;  
24 -  
25 - /**  
26 - * 实际出场里程  
27 - */  
28 - private Double sjcclc;  
29 -  
30 - /**  
31 - * 实际进场里程  
32 - */  
33 - private Double sjjclc;  
34 -  
35 - /**  
36 - * 营运里程  
37 - */  
38 - private Double yylc;  
39 -  
40 - /**  
41 - * 空驶里程  
42 - */  
43 - private Double kslc;  
44 -  
45 - /**  
46 - * 抽减里程  
47 - */  
48 - private Double cjlc;  
49 -  
50 - /**  
51 - * 烂班里程  
52 - */  
53 - private Double lblc;  
54 -  
55 - /**  
56 - * 增加里程  
57 - */  
58 - private Double zjlc;  
59 -  
60 - /**  
61 - * 总里程  
62 - */  
63 - private Double zlc;  
64 -  
65 - /**  
66 - * 油耗  
67 - */  
68 - private Double yh;  
69 -  
70 - /**  
71 - * 电耗  
72 - */  
73 - private Double dh;  
74 -  
75 - private String company;  
76 -  
77 - private String companyCode;  
78 -  
79 - public String getScheduleDate() {  
80 - return scheduleDate;  
81 - }  
82 -  
83 - public void setScheduleDate(String scheduleDate) {  
84 - this.scheduleDate = scheduleDate;  
85 - }  
86 -  
87 - public String getNbbm() {  
88 - return nbbm;  
89 - }  
90 -  
91 - public void setNbbm(String nbbm) {  
92 - this.nbbm = nbbm;  
93 - }  
94 -  
95 - public Double getJhlc() {  
96 - return jhlc;  
97 - }  
98 -  
99 - public void setJhlc(Double jhlc) {  
100 - this.jhlc = jhlc;  
101 - }  
102 -  
103 - public Double getSjjhlc() {  
104 - return sjjhlc;  
105 - }  
106 -  
107 - public void setSjjhlc(Double sjjhlc) {  
108 - this.sjjhlc = sjjhlc;  
109 - }  
110 -  
111 - public Double getSjcclc() {  
112 - return sjcclc;  
113 - }  
114 -  
115 - public void setSjcclc(Double sjcclc) {  
116 - this.sjcclc = sjcclc;  
117 - }  
118 -  
119 - public Double getSjjclc() {  
120 - return sjjclc;  
121 - }  
122 -  
123 - public void setSjjclc(Double sjjclc) {  
124 - this.sjjclc = sjjclc;  
125 - }  
126 -  
127 - public Double getYylc() {  
128 - return yylc;  
129 - }  
130 -  
131 - public void setYylc(Double yylc) {  
132 - this.yylc = yylc;  
133 - }  
134 -  
135 - public Double getKslc() {  
136 - return kslc;  
137 - }  
138 -  
139 - public void setKslc(Double kslc) {  
140 - this.kslc = kslc;  
141 - }  
142 -  
143 - public Double getCjlc() {  
144 - return cjlc;  
145 - }  
146 -  
147 - public void setCjlc(Double cjlc) {  
148 - this.cjlc = cjlc;  
149 - }  
150 -  
151 - public Double getLblc() {  
152 - return lblc;  
153 - }  
154 -  
155 - public void setLblc(Double lblc) {  
156 - this.lblc = lblc;  
157 - }  
158 -  
159 - public Double getZjlc() {  
160 - return zjlc;  
161 - }  
162 -  
163 - public void setZjlc(Double zjlc) {  
164 - this.zjlc = zjlc;  
165 - }  
166 -  
167 - public Double getZlc() {  
168 - return zlc;  
169 - }  
170 -  
171 - public void setZlc(Double zlc) {  
172 - this.zlc = zlc;  
173 - }  
174 -  
175 - public Double getYh() {  
176 - return yh;  
177 - }  
178 -  
179 - public void setYh(Double yh) {  
180 - this.yh = yh;  
181 - }  
182 -  
183 - public Double getDh() {  
184 - return dh;  
185 - }  
186 -  
187 - public void setDh(Double dh) {  
188 - this.dh = dh;  
189 - }  
190 -  
191 - public String getCompany() {  
192 - return company;  
193 - }  
194 -  
195 - public void setCompany(String company) {  
196 - this.company = company;  
197 - }  
198 -  
199 - public String getCompanyCode() {  
200 - return companyCode;  
201 - }  
202 -  
203 - public void setCompanyCode(String companyCode) {  
204 - this.companyCode = companyCode;  
205 - }  
206 -}  
src/main/java/com/bsth/server_rs/dks/DksRestService.java deleted 100644 → 0
1 -package com.bsth.server_rs.dks;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.bsth.common.BusinessCodeData;  
5 -import com.bsth.entity.ElecInfo;  
6 -import com.bsth.entity.OilInfo;  
7 -import com.bsth.entity.SchedulePlanInfo;  
8 -import com.bsth.entity.ScheduleRealInfo;  
9 -import com.bsth.redis.ElecRedisService;  
10 -import com.bsth.redis.OilRedisService;  
11 -import com.bsth.redis.ScheduleRedisService;  
12 -import com.bsth.repository.SchedulePlanInfoRepository;  
13 -import com.bsth.repository.ScheduleRealInfoRepository;  
14 -import com.bsth.server_rs.base_info.line.Line;  
15 -import com.bsth.server_rs.base_info.line.buffer.LineBufferData;  
16 -import com.bsth.server_ws.util.ScheduleCalculator;  
17 -import com.bsth.util.Arith;  
18 -import com.google.common.collect.ArrayListMultimap;  
19 -import org.joda.time.DateTime;  
20 -import org.joda.time.format.DateTimeFormat;  
21 -import org.slf4j.Logger;  
22 -import org.slf4j.LoggerFactory;  
23 -import org.springframework.beans.factory.annotation.Autowired;  
24 -import org.springframework.jdbc.core.BatchPreparedStatementSetter;  
25 -import org.springframework.jdbc.core.BeanPropertyRowMapper;  
26 -import org.springframework.jdbc.core.JdbcTemplate;  
27 -import org.springframework.jdbc.datasource.DataSourceTransactionManager;  
28 -import org.springframework.scheduling.annotation.EnableScheduling;  
29 -import org.springframework.scheduling.annotation.Scheduled;  
30 -import org.springframework.stereotype.Component;  
31 -import org.springframework.transaction.TransactionDefinition;  
32 -import org.springframework.transaction.TransactionStatus;  
33 -import org.springframework.transaction.support.DefaultTransactionDefinition;  
34 -import org.springframework.util.StringUtils;  
35 -  
36 -import javax.ws.rs.*;  
37 -import javax.ws.rs.core.MediaType;  
38 -import java.sql.PreparedStatement;  
39 -import java.sql.SQLException;  
40 -import java.util.*;  
41 -  
42 -/**  
43 - * @author Hill  
44 - * @date 2021-09  
45 - */  
46 -@Component  
47 -@EnableScheduling  
48 -@Path("/dks")  
49 -@Produces({MediaType.APPLICATION_JSON})  
50 -public class DksRestService {  
51 -  
52 - private final static Logger log = LoggerFactory.getLogger(DksRestService.class);  
53 -  
54 - @Autowired  
55 - private JdbcTemplate jdbcTemplate;  
56 -  
57 - @Autowired  
58 - private ScheduleRealInfoRepository scheduleRealInfoRepository;  
59 -  
60 - @Autowired  
61 - private SchedulePlanInfoRepository schedulePlanInfoRepository;  
62 -  
63 - @Autowired  
64 - private ScheduleRedisService scheduleRedisService;  
65 -  
66 - @Autowired  
67 - private OilRedisService oilRedisService;  
68 -  
69 - @Autowired  
70 - private ElecRedisService elecRedisService;  
71 -  
72 - /**  
73 - * 根据日期统计数据重新计算  
74 - * @param rq  
75 - */  
76 - @GET  
77 - @Path("/reCompute/{rq}")  
78 - public void reStatisticalComputation(@PathParam("rq") String rq) {  
79 - DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq);  
80 - planComputation(dateTime);  
81 - realComputation(dateTime);  
82 - carMileageComputation(dateTime);  
83 - }  
84 -  
85 - /**  
86 - *  
87 - */  
88 - private List<LineServiceConfigVo> reGroup(List<LineServiceConfig> configs, String month) {  
89 - List<LineServiceConfigVo> result = new ArrayList<>();  
90 - String oldLineCode = "";  
91 - LineServiceConfigVo vo = null;  
92 - for (int i = 0, len = configs.size();i < len;i++) {  
93 - LineServiceConfig config = configs.get(i);  
94 - if (i == 0) {  
95 - oldLineCode = config.getLineCode();  
96 - vo = new LineServiceConfigVo();  
97 - vo.setLineName(config.getLineName());  
98 - vo.setMonth(month);  
99 - vo.setConductorFirstCount(config.getConductorCount());  
100 - vo.setDriverFirstCount(config.getDriverCount());  
101 - } else if (i == len - 1) {  
102 - result.add(vo);  
103 - } else {  
104 - if (!oldLineCode.equals(config.getLineCode())) {  
105 - oldLineCode = config.getLineCode();  
106 - result.add(vo);  
107 - vo = new LineServiceConfigVo();  
108 - vo.setLineName(config.getLineName());  
109 - vo.setMonth(month);  
110 - vo.setConductorFirstCount(config.getConductorCount());  
111 - vo.setDriverFirstCount(config.getDriverCount());  
112 - }  
113 - }  
114 - vo.setConductorLastCount(config.getConductorCount());  
115 - vo.setDriverLastCount(config.getDriverCount());  
116 - }  
117 -  
118 - return result;  
119 - }  
120 -  
121 - /**  
122 - * 计划司售配档数  
123 - * @param month  
124 - */  
125 - @GET  
126 - @Path("/plan/{month}")  
127 - public List<LineServiceConfigVo> plan(@PathParam("month") String month) {  
128 - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class));  
129 - return reGroup(configs, month);  
130 - }  
131 -  
132 - /**  
133 - * 实际司售配档数  
134 - * @param month  
135 - */  
136 - @GET  
137 - @Path("/actual/{month}")  
138 - public List<LineServiceConfigVo> actual(@PathParam("month") String month) {  
139 - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class));  
140 - return reGroup(configs, month);  
141 - }  
142 -  
143 - /**  
144 - * 计划配车数  
145 - * @param month  
146 - */  
147 - @GET  
148 - @Path("/bus/plan/{month}")  
149 - public List<BusVo> busPlan(@PathParam("month") String month) {  
150 - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class));  
151 - List<BusVo> result = new ArrayList<>();  
152 - String oldLineCode = "";  
153 - BusVo vo = null;  
154 - int max = 0;  
155 - for (int i = 0, len = configs.size();i < len;i++) {  
156 - LineServiceConfig config = configs.get(i);  
157 - if (i == 0) {  
158 - oldLineCode = config.getLineCode();  
159 - vo = new BusVo();  
160 - vo.setLineName(config.getLineName());  
161 - vo.setMonth(month);  
162 - vo.setBusFirstCount(config.getCarCount());  
163 - } else if (!oldLineCode.equals(config.getLineCode())) {  
164 - oldLineCode = config.getLineCode();  
165 - vo.setBusMaxCount(max);  
166 - result.add(vo);  
167 - max = 0;  
168 - vo = new BusVo();  
169 - vo.setLineName(config.getLineName());  
170 - vo.setMonth(month);  
171 - vo.setBusFirstCount(config.getCarCount());  
172 - }  
173 - max = Math.max(max, config.getCarCount());  
174 - if (i == len - 1) {  
175 - vo.setBusMaxCount(max);  
176 - result.add(vo);  
177 - }  
178 - vo.setBusLastCount(config.getCarCount());  
179 - }  
180 -  
181 - return result;  
182 - }  
183 -  
184 - /**  
185 - * 实际配车数  
186 - * @param month  
187 - */  
188 - @GET  
189 - @Path("/bus/{month}")  
190 - public List<BusVo> bus(@PathParam("month") String month) {  
191 - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class));  
192 - List<BusVo> result = new ArrayList<>();  
193 - String oldLineCode = "";  
194 - BusVo vo = null;  
195 - int max = 0;  
196 - for (int i = 0, len = configs.size();i < len;i++) {  
197 - LineServiceConfig config = configs.get(i);  
198 - if (i == 0) {  
199 - oldLineCode = config.getLineCode();  
200 - vo = new BusVo();  
201 - vo.setLineName(config.getLineName());  
202 - vo.setMonth(month);  
203 - vo.setBusFirstCount(config.getCarCount());  
204 - } else if (!oldLineCode.equals(config.getLineCode())) {  
205 - oldLineCode = config.getLineCode();  
206 - vo.setBusMaxCount(max);  
207 - result.add(vo);  
208 - max = 0;  
209 - vo = new BusVo();  
210 - vo.setLineName(config.getLineName());  
211 - vo.setMonth(month);  
212 - vo.setBusFirstCount(config.getCarCount());  
213 - }  
214 - max = Math.max(max, config.getCarCount());  
215 - if (i == len - 1) {  
216 - vo.setBusMaxCount(max);  
217 - result.add(vo);  
218 - }  
219 - vo.setBusLastCount(config.getCarCount());  
220 - }  
221 -  
222 - return result;  
223 - }  
224 -  
225 - /**  
226 - * 车辆公里、油耗数据  
227 - * @param month  
228 - */  
229 - @GET  
230 - @Path("/mileage/{month}")  
231 - public List<BusMileageVo> mileage(@PathParam("month") String month) {  
232 - List<BusMileage> mileages = jdbcTemplate.query("select company, company_code, nbbm, schedule_month schedule_date, sum(zlc) zlc, sum(yh) yh, sum(dh) dh from control_interface.bsth_t_mileage where schedule_month = ? group by company, company_code, nbbm, schedule_month", new Object[]{ month }, BeanPropertyRowMapper.newInstance(BusMileage.class));  
233 - List<BusMileageVo> result = new ArrayList<>();  
234 - for (BusMileage mileage : mileages) {  
235 - BusMileageVo vo = new BusMileageVo();  
236 - vo.setMonth(mileage.getScheduleDate());  
237 - vo.setInsideCode(mileage.getNbbm());  
238 - vo.setTotalMileage(mileage.getZlc());  
239 - vo.setOilConsume(mileage.getYh());  
240 - vo.setElectricConsume(mileage.getDh());  
241 - vo.setCompany(mileage.getCompany());  
242 - vo.setCompanyCode(mileage.getCompanyCode());  
243 -  
244 - result.add(vo);  
245 - }  
246 -  
247 - return result;  
248 - }  
249 -  
250 - @Scheduled(cron = "0 0/25 23 * * ?")  
251 - public void statisticalComputation() {  
252 - log.info("执行电科所接口数据统计计算");  
253 - DateTime dateTime = DateTime.now().plusDays(1);  
254 - try {  
255 - for (int i = 0;i < 3;i++) {  
256 - dateTime = dateTime.minusDays(1);  
257 - planComputation(dateTime);  
258 - realComputation(dateTime);  
259 - carMileageComputation(dateTime);  
260 - }  
261 - } catch (Exception e) {  
262 - e.printStackTrace();  
263 - }  
264 - }  
265 -  
266 - /**  
267 - * 计划排班中的线路司售配档数  
268 - */  
269 - private void planComputation(DateTime dateTime) {  
270 - // 记录实际线路司售配档情况  
271 - List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate());  
272 - Set<String> lineCodes = new HashSet<>();  
273 - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>();  
274 - final List<LineServiceConfig> objects = new ArrayList<>();  
275 - for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) {  
276 - String lineCode = schedulePlanInfo.getXlBm();  
277 - lineCodes.add(lineCode);  
278 - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode);  
279 - if (conductors == null) {  
280 - conductors = new HashSet<>();  
281 - line2conductors.put(lineCode, conductors);  
282 - }  
283 - if (drivers == null) {  
284 - drivers = new HashSet<>();  
285 - line2drivers.put(lineCode, drivers);  
286 - }  
287 - if (cars == null) {  
288 - cars = new HashSet<>();  
289 - line2cars.put(lineCode, cars);  
290 - }  
291 - if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) {  
292 - conductors.add(schedulePlanInfo.getsGh());  
293 - }  
294 - drivers.add(schedulePlanInfo.getjGh());  
295 - cars.add(schedulePlanInfo.getClZbh());  
296 - }  
297 - for (String lineCode : lineCodes) {  
298 - LineServiceConfig object = new LineServiceConfig();  
299 - Line line = LineBufferData.findOne(lineCode);  
300 - object.setLineCode(lineCode);  
301 - object.setLineName(line == null ? "" : line.getName());  
302 - object.setScheduleDate(dateTime.toString("yyyy-MM-dd"));  
303 - object.setConductorCount(line2conductors.get(lineCode).size());  
304 - object.setDriverCount(line2drivers.get(lineCode).size());  
305 - object.setCarCount(line2cars.get(lineCode).size());  
306 -  
307 - objects.add(object);  
308 - }  
309 -  
310 - //编程式事务  
311 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
312 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
313 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
314 - TransactionStatus status = tran.getTransaction(def);  
315 -  
316 - try {  
317 - jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") });  
318 - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() {  
319 - @Override  
320 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
321 - LineServiceConfig object = objects.get(i);  
322 - ps.setString(1, object.getLineCode());  
323 - ps.setString(2, object.getLineName());  
324 - ps.setString(3, object.getScheduleDate());  
325 - ps.setInt(4, object.getConductorCount());  
326 - ps.setInt(5, object.getDriverCount());  
327 - ps.setInt(6, object.getCarCount());  
328 - }  
329 -  
330 - @Override  
331 - public int getBatchSize() {  
332 - return objects.size();  
333 - }  
334 - });  
335 - tran.commit(status);  
336 - } catch (Exception e) {  
337 - tran.rollback(status);  
338 - }  
339 - }  
340 -  
341 - /**  
342 - * 实际排班中的线路司售配档数  
343 - */  
344 - private void realComputation(DateTime dateTime) {  
345 - // 记录实际线路司售配档情况  
346 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findAll(dateTime.toString("yyyy-MM-dd"));  
347 - Set<String> lineCodes = new HashSet<>();  
348 - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>();  
349 - final List<LineServiceConfig> objects = new ArrayList<>();  
350 - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) {  
351 - // 烂班班次不计入配档数  
352 - if (scheduleRealInfo.getStatus() == -1) { continue; }  
353 - String lineCode = scheduleRealInfo.getXlBm();  
354 - lineCodes.add(lineCode);  
355 - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode);  
356 - if (conductors == null) {  
357 - conductors = new HashSet<>();  
358 - line2conductors.put(lineCode, conductors);  
359 - }  
360 - if (drivers == null) {  
361 - drivers = new HashSet<>();  
362 - line2drivers.put(lineCode, drivers);  
363 - }  
364 - if (cars == null) {  
365 - cars = new HashSet<>();  
366 - line2cars.put(lineCode, cars);  
367 - }  
368 - if (!StringUtils.isEmpty(scheduleRealInfo.getsGh())) {  
369 - conductors.add(scheduleRealInfo.getsGh());  
370 - }  
371 - drivers.add(scheduleRealInfo.getjGh());  
372 - cars.add(scheduleRealInfo.getClZbh());  
373 - }  
374 - for (String lineCode : lineCodes) {  
375 - LineServiceConfig object = new LineServiceConfig();  
376 - Line line = LineBufferData.findOne(lineCode);  
377 - object.setLineCode(lineCode);  
378 - object.setLineName(line == null ? "" : line.getName());  
379 - object.setScheduleDate(dateTime.toString("yyyy-MM-dd"));  
380 - object.setConductorCount(line2conductors.get(lineCode).size());  
381 - object.setDriverCount(line2drivers.get(lineCode).size());  
382 - object.setCarCount(line2cars.get(lineCode).size());  
383 -  
384 - objects.add(object);  
385 - }  
386 -  
387 - //编程式事务  
388 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
389 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
390 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
391 - TransactionStatus status = tran.getTransaction(def);  
392 - try {  
393 - jdbcTemplate.update("delete from control_interface.bsth_t_real where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") });  
394 - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_real (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() {  
395 - @Override  
396 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
397 - LineServiceConfig object = objects.get(i);  
398 - ps.setString(1, object.getLineCode());  
399 - ps.setString(2, object.getLineName());  
400 - ps.setString(3, object.getScheduleDate());  
401 - ps.setInt(4, object.getConductorCount());  
402 - ps.setInt(5, object.getDriverCount());  
403 - ps.setInt(6, object.getCarCount());  
404 - }  
405 -  
406 - @Override  
407 - public int getBatchSize() {  
408 - return objects.size();  
409 - }  
410 - });  
411 - tran.commit(status);  
412 - } catch (Exception e) {  
413 - tran.rollback(status);  
414 - }  
415 - }  
416 -  
417 - private void carMileageComputation(final DateTime dateTime) {  
418 - String rq = dateTime.toString("yyyy-MM-dd");  
419 - // 实际排班信息  
420 - ArrayListMultimap<String, ScheduleRealInfo> nbbm2schedules = scheduleRedisService.findByDate(rq);  
421 - // 油耗信息  
422 - ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq);  
423 - //电耗信息  
424 - ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq);  
425 - Set<String> nbbms = nbbm2schedules.keySet();  
426 - final List<BusMileage> busMileages = new ArrayList<>();  
427 - Set<String> keys = new HashSet<String>(); //保存已添加的车号  
428 - for (String nbbm : nbbms) {  
429 - List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm);  
430 - if (scheduleRealInfos.size() == 0) {  
431 - continue;  
432 - }  
433 - ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(0);  
434 - BusMileage busMileage = new BusMileage();  
435 - busMileage.setScheduleDate(rq);  
436 - busMileage.setNbbm(nbbm);  
437 - busMileage.setJhlc(ScheduleCalculator.calcJHLC(scheduleRealInfos));  
438 - busMileage.setSjjhlc(ScheduleCalculator.calcSJLC(scheduleRealInfos));  
439 - busMileage.setSjcclc(ScheduleCalculator.calcCCLC(scheduleRealInfos));  
440 - busMileage.setSjjclc(ScheduleCalculator.calcJCLC(scheduleRealInfos));  
441 - busMileage.setYylc(ScheduleCalculator.calcYYLC(scheduleRealInfos));  
442 - busMileage.setKslc(ScheduleCalculator.calcKSLC(scheduleRealInfos));  
443 - busMileage.setCjlc(ScheduleCalculator.calcCJLC(scheduleRealInfos));  
444 - busMileage.setLblc(ScheduleCalculator.calcLBLC(scheduleRealInfos));  
445 - busMileage.setZjlc(ScheduleCalculator.calcZJLC(scheduleRealInfos));  
446 - busMileage.setZlc(ScheduleCalculator.calcZLC(scheduleRealInfos));  
447 - List<OilInfo> oilInfos = oilInfoMap.get(nbbm);  
448 - List<ElecInfo> elecInfos = elecInfoMap.get(nbbm);  
449 - Double yh = 0.0, dh = 0.0;  
450 - for (OilInfo oilInfo : oilInfos) {  
451 - if(scheduleRealInfo.getGsBm().equals(oilInfo.getSsgsdm())){  
452 - yh = Arith.add(yh, oilInfo.getYh());  
453 - }  
454 - }  
455 - for (ElecInfo elecInfo : elecInfos) {  
456 - if(scheduleRealInfo.getGsBm().equals(elecInfo.getSsgsdm())){  
457 - dh = Arith.add(dh, elecInfo.getHd());  
458 - }  
459 - }  
460 - busMileage.setYh(yh);  
461 - busMileage.setDh(dh);  
462 - busMileage.setCompany(scheduleRealInfo.getGsName());  
463 - busMileage.setCompanyCode(scheduleRealInfo.getGsBm());  
464 -  
465 - busMileages.add(busMileage);  
466 - keys.add(busMileage.getCompanyCode() + "_" + nbbm);  
467 - }  
468 -  
469 - for(String nbbm : oilInfoMap.keys()){ //有加油没路单的车。  
470 - Set<String> gs_Set = new HashSet<String>();  
471 - for (OilInfo oilInfo : oilInfoMap.get(nbbm)) {  
472 - gs_Set.add(oilInfo.getSsgsdm());  
473 - }  
474 - for(String gs : gs_Set){  
475 - if(keys.contains(gs + "_" + nbbm)){  
476 - continue;  
477 - }  
478 - BusMileage busMileage = new BusMileage();  
479 - busMileage.setScheduleDate(rq);  
480 - busMileage.setNbbm(nbbm);  
481 - busMileage.setJhlc(0d);  
482 - busMileage.setSjjhlc(0d);  
483 - busMileage.setSjcclc(0d);  
484 - busMileage.setSjjclc(0d);  
485 - busMileage.setYylc(0d);  
486 - busMileage.setKslc(0d);  
487 - busMileage.setCjlc(0d);  
488 - busMileage.setLblc(0d);  
489 - busMileage.setZjlc(0d);  
490 - busMileage.setZlc(0d);  
491 - List<OilInfo> oilInfos = oilInfoMap.get(nbbm);  
492 - List<ElecInfo> elecInfos = elecInfoMap.containsKey(nbbm)?elecInfoMap.get(nbbm):new ArrayList<ElecInfo>();  
493 - Double yh = 0.0, dh = 0.0;  
494 - for (OilInfo oilInfo : oilInfos) {  
495 - if(gs.equals(oilInfo.getSsgsdm())){  
496 - yh = Arith.add(yh, oilInfo.getYh());  
497 - }  
498 - }  
499 - for (ElecInfo elecInfo : elecInfos) {  
500 - if(gs.equals(elecInfo.getSsgsdm())){  
501 - dh = Arith.add(dh, elecInfo.getHd());  
502 - }  
503 - }  
504 - busMileage.setYh(yh);  
505 - busMileage.setDh(dh);  
506 - busMileage.setCompany(BusinessCodeData.code2Name.get(gs));  
507 - busMileage.setCompanyCode(gs);  
508 -  
509 - busMileages.add(busMileage);  
510 - keys.add(busMileage.getCompanyCode() + "_" + nbbm);  
511 - }  
512 - }  
513 -  
514 - for(String nbbm : elecInfoMap.keys()){ //有加电没路单的车。  
515 - Set<String> gs_Set = new HashSet<String>();  
516 - for (ElecInfo elecInfo : elecInfoMap.get(nbbm)) {  
517 - gs_Set.add(elecInfo.getSsgsdm());  
518 - }  
519 - for(String gs : gs_Set){  
520 - if(keys.contains(gs + "_" + nbbm)){  
521 - continue;  
522 - }  
523 - BusMileage busMileage = new BusMileage();  
524 - busMileage.setScheduleDate(rq);  
525 - busMileage.setNbbm(nbbm);  
526 - busMileage.setJhlc(0d);  
527 - busMileage.setSjjhlc(0d);  
528 - busMileage.setSjcclc(0d);  
529 - busMileage.setSjjclc(0d);  
530 - busMileage.setYylc(0d);  
531 - busMileage.setKslc(0d);  
532 - busMileage.setCjlc(0d);  
533 - busMileage.setLblc(0d);  
534 - busMileage.setZjlc(0d);  
535 - busMileage.setZlc(0d);  
536 - List<ElecInfo> elecInfos = elecInfoMap.get(nbbm);  
537 - Double yh = 0.0, dh = 0.0;  
538 - for (ElecInfo elecInfo : elecInfos) {  
539 - if(gs.equals(elecInfo.getSsgsdm())){  
540 - dh = Arith.add(dh, elecInfo.getHd());  
541 - }  
542 - }  
543 - busMileage.setYh(yh);  
544 - busMileage.setDh(dh);  
545 - busMileage.setCompany(BusinessCodeData.code2Name.get(gs));  
546 - busMileage.setCompanyCode(gs);  
547 -  
548 - busMileages.add(busMileage);  
549 - keys.add(busMileage.getCompanyCode() + "_" + nbbm);  
550 - }  
551 - }  
552 -  
553 - //编程式事务  
554 - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());  
555 - DefaultTransactionDefinition def = new DefaultTransactionDefinition();  
556 - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);  
557 - TransactionStatus status = tran.getTransaction(def);  
558 - try {  
559 - jdbcTemplate.update("delete from control_interface.bsth_t_mileage where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") });  
560 - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_mileage (schedule_date,nbbm,jhlc,sjjhlc,sjcclc,sjjclc,yylc,kslc,cjlc,lblc,zjlc,zlc,yh,dh,schedule_month,company,company_code) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {  
561 - @Override  
562 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
563 - BusMileage busMileage = busMileages.get(i);  
564 - ps.setString(1, busMileage.getScheduleDate());  
565 - ps.setString(2, busMileage.getNbbm());  
566 - ps.setDouble(3, busMileage.getJhlc());  
567 - ps.setDouble(4, busMileage.getSjjhlc());  
568 - ps.setDouble(5, busMileage.getSjcclc());  
569 - ps.setDouble(6, busMileage.getSjjclc());  
570 - ps.setDouble(7, busMileage.getYylc());  
571 - ps.setDouble(8, busMileage.getKslc());  
572 - ps.setDouble(9, busMileage.getCjlc());  
573 - ps.setDouble(10, busMileage.getLblc());  
574 - ps.setDouble(11, busMileage.getZjlc());  
575 - ps.setDouble(12, busMileage.getZlc());  
576 - ps.setDouble(13, busMileage.getYh());  
577 - ps.setDouble(14, busMileage.getDh());  
578 - ps.setString(15, dateTime.toString("yyyy-MM"));  
579 - ps.setString(16, busMileage.getCompany());  
580 - ps.setString(17, busMileage.getCompanyCode());  
581 - }  
582 -  
583 - @Override  
584 - public int getBatchSize() {  
585 - return busMileages.size();  
586 - }  
587 - });  
588 - tran.commit(status);  
589 - } catch (Exception e) {  
590 - tran.rollback(status);  
591 - }  
592 - }  
593 -  
594 - /**  
595 - * 线路司售配档对象  
596 - */  
597 - private final static class LineServiceConfigVo {  
598 -  
599 - private String lineName;  
600 -  
601 - private String month;  
602 -  
603 - private Integer driverFirstCount;  
604 -  
605 - private Integer driverLastCount;  
606 -  
607 - private Integer conductorFirstCount;  
608 -  
609 - private Integer conductorLastCount;  
610 -  
611 - public String getLineName() {  
612 - return lineName;  
613 - }  
614 -  
615 - public void setLineName(String lineName) {  
616 - this.lineName = lineName;  
617 - }  
618 -  
619 - public String getMonth() {  
620 - return month;  
621 - }  
622 -  
623 - public void setMonth(String month) {  
624 - this.month = month;  
625 - }  
626 -  
627 - public Integer getDriverFirstCount() {  
628 - return driverFirstCount;  
629 - }  
630 -  
631 - public void setDriverFirstCount(Integer driverFirstCount) {  
632 - this.driverFirstCount = driverFirstCount;  
633 - }  
634 -  
635 - public Integer getDriverLastCount() {  
636 - return driverLastCount;  
637 - }  
638 -  
639 - public void setDriverLastCount(Integer driverLastCount) {  
640 - this.driverLastCount = driverLastCount;  
641 - }  
642 -  
643 - public Integer getConductorFirstCount() {  
644 - return conductorFirstCount;  
645 - }  
646 -  
647 - public void setConductorFirstCount(Integer conductorFirstCount) {  
648 - this.conductorFirstCount = conductorFirstCount;  
649 - }  
650 -  
651 - public Integer getConductorLastCount() {  
652 - return conductorLastCount;  
653 - }  
654 -  
655 - public void setConductorLastCount(Integer conductorLastCount) {  
656 - this.conductorLastCount = conductorLastCount;  
657 - }  
658 - }  
659 -  
660 - /**  
661 - * 车辆配档对象  
662 - */  
663 - private final static class BusVo {  
664 -  
665 - private String lineName;  
666 -  
667 - private String month;  
668 -  
669 - private Integer busFirstCount;  
670 -  
671 - private Integer busLastCount;  
672 -  
673 - private Integer busMaxCount;  
674 -  
675 - public String getLineName() {  
676 - return lineName;  
677 - }  
678 -  
679 - public void setLineName(String lineName) {  
680 - this.lineName = lineName;  
681 - }  
682 -  
683 - public String getMonth() {  
684 - return month;  
685 - }  
686 -  
687 - public void setMonth(String month) {  
688 - this.month = month;  
689 - }  
690 -  
691 - public Integer getBusFirstCount() {  
692 - return busFirstCount;  
693 - }  
694 -  
695 - public void setBusFirstCount(Integer busFirstCount) {  
696 - this.busFirstCount = busFirstCount;  
697 - }  
698 -  
699 - public Integer getBusLastCount() {  
700 - return busLastCount;  
701 - }  
702 -  
703 - public void setBusLastCount(Integer busLastCount) {  
704 - this.busLastCount = busLastCount;  
705 - }  
706 -  
707 - public Integer getBusMaxCount() {  
708 - return busMaxCount;  
709 - }  
710 -  
711 - public void setBusMaxCount(Integer busMaxCount) {  
712 - this.busMaxCount = busMaxCount;  
713 - }  
714 - }  
715 -  
716 - /**  
717 - * 车辆公里、油耗对象  
718 - */  
719 - private final static class BusMileageVo {  
720 -  
721 - private String insideCode;  
722 -  
723 - private String month;  
724 -  
725 - private Double totalMileage;  
726 -  
727 - private Double oilConsume;  
728 -  
729 - private Double electricConsume;  
730 -  
731 - private String company;  
732 -  
733 - private String companyCode;  
734 -  
735 - public String getInsideCode() {  
736 - return insideCode;  
737 - }  
738 -  
739 - public void setInsideCode(String insideCode) {  
740 - this.insideCode = insideCode;  
741 - }  
742 -  
743 - public String getMonth() {  
744 - return month;  
745 - }  
746 -  
747 - public void setMonth(String month) {  
748 - this.month = month;  
749 - }  
750 -  
751 - public Double getTotalMileage() {  
752 - return totalMileage;  
753 - }  
754 -  
755 - public void setTotalMileage(Double totalMileage) {  
756 - this.totalMileage = totalMileage;  
757 - }  
758 -  
759 - public Double getOilConsume() {  
760 - return oilConsume;  
761 - }  
762 -  
763 - public void setOilConsume(Double oilConsume) {  
764 - this.oilConsume = oilConsume;  
765 - }  
766 -  
767 - public Double getElectricConsume() {  
768 - return electricConsume;  
769 - }  
770 -  
771 - public void setElectricConsume(Double electricConsume) {  
772 - this.electricConsume = electricConsume;  
773 - }  
774 -  
775 - public String getCompany() {  
776 - return company;  
777 - }  
778 -  
779 - public void setCompany(String company) {  
780 - this.company = company;  
781 - }  
782 -  
783 - public String getCompanyCode() {  
784 - return companyCode;  
785 - }  
786 -  
787 - public void setCompanyCode(String companyCode) {  
788 - this.companyCode = companyCode;  
789 - }  
790 - }  
791 -}  
src/main/java/com/bsth/server_rs/dks/LineServiceConfig.java deleted 100644 → 0
1 -package com.bsth.server_rs.dks;  
2 -  
3 -/**  
4 - * 线路运营司、售、车辆配档信息  
5 - * @author Hill  
6 - */  
7 -public class LineServiceConfig {  
8 -  
9 - private String lineCode;  
10 -  
11 - private String lineName;  
12 -  
13 - private String month;  
14 -  
15 - private String scheduleDate;  
16 -  
17 - private int driverCount;  
18 -  
19 - private int conductorCount;  
20 -  
21 - private int carCount;  
22 -  
23 - public String getLineCode() {  
24 - return lineCode;  
25 - }  
26 -  
27 - public void setLineCode(String lineCode) {  
28 - this.lineCode = lineCode;  
29 - }  
30 -  
31 - public String getLineName() {  
32 - return lineName;  
33 - }  
34 -  
35 - public void setLineName(String lineName) {  
36 - this.lineName = lineName;  
37 - }  
38 -  
39 - public String getMonth() {  
40 - return month;  
41 - }  
42 -  
43 - public void setMonth(String month) {  
44 - this.month = month;  
45 - }  
46 -  
47 - public String getScheduleDate() {  
48 - return scheduleDate;  
49 - }  
50 -  
51 - public void setScheduleDate(String scheduleDate) {  
52 - this.scheduleDate = scheduleDate;  
53 - }  
54 -  
55 - public int getDriverCount() {  
56 - return driverCount;  
57 - }  
58 -  
59 - public void setDriverCount(int driverCount) {  
60 - this.driverCount = driverCount;  
61 - }  
62 -  
63 - public int getConductorCount() {  
64 - return conductorCount;  
65 - }  
66 -  
67 - public void setConductorCount(int conductorCount) {  
68 - this.conductorCount = conductorCount;  
69 - }  
70 -  
71 - public int getCarCount() {  
72 - return carCount;  
73 - }  
74 -  
75 - public void setCarCount(int carCount) {  
76 - this.carCount = carCount;  
77 - }  
78 -}  
src/main/java/com/bsth/server_rs/man_hours/ManHoursRefreshScheduler.java deleted 100644 → 0
1 -package com.bsth.server_rs.man_hours;  
2 -  
3 -import com.bsth.entity.ManHours;  
4 -import org.joda.time.DateTime;  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.jdbc.core.BeanPropertyRowMapper;  
7 -import org.springframework.jdbc.core.JdbcTemplate;  
8 -import org.springframework.scheduling.annotation.EnableScheduling;  
9 -import org.springframework.scheduling.annotation.Scheduled;  
10 -import org.springframework.stereotype.Component;  
11 -  
12 -import java.util.HashMap;  
13 -import java.util.List;  
14 -import java.util.Map;  
15 -  
16 -/**  
17 - * @author Hill  
18 - */  
19 -@Component  
20 -@EnableScheduling  
21 -public class ManHoursRefreshScheduler {  
22 -  
23 - @Autowired  
24 - private JdbcTemplate jdbcTemplate;  
25 -  
26 - @Autowired  
27 - private ManHoursRestService manHoursRestService;  
28 -  
29 - @Scheduled(cron = "0 0/30 * * * ?")  
30 - public void refresh() {  
31 - Map<String, Float> linelp2mh = new HashMap<>();  
32 - DateTime dateTime = DateTime.now().withTime(0,0,0,0);  
33 - List<ManHours> manHoursList = jdbcTemplate.query("select d.xl xl_bm,d.lp,d.gs man_hours,e.lp_name from (SELECT DISTINCT c.xl,c.lp,c.gs FROM `bsth_c_s_sp_info` a join bsth_c_s_ttinfo b on a.tt_info = b.id join bsth_c_s_ttinfo_bx_detail c on b.id = c.ttinfo where a.schedule_date = FROM_UNIXTIME(?)) d join bsth_c_s_gbi e on d.lp = e.id",new Object[]{ dateTime.getMillis() / 1000 }, BeanPropertyRowMapper.newInstance(ManHours.class));  
34 - for (ManHours manHours : manHoursList) {  
35 - linelp2mh.put(String.format("%s_%s", manHours.getXlBm(), manHours.getLpName()), manHours.getManHours());  
36 - }  
37 - manHoursRestService.setLinelp2mh(linelp2mh);  
38 - }  
39 -}  
src/main/java/com/bsth/server_rs/man_hours/ManHoursRestService.java deleted 100644 → 0
1 -package com.bsth.server_rs.man_hours;  
2 -  
3 -import com.bsth.entity.WhiteIp;  
4 -import org.springframework.beans.factory.annotation.Autowired;  
5 -import org.springframework.jdbc.core.BeanPropertyRowMapper;  
6 -import org.springframework.jdbc.core.JdbcTemplate;  
7 -import org.springframework.stereotype.Component;  
8 -import org.springframework.web.bind.annotation.PathVariable;  
9 -  
10 -import javax.ws.rs.GET;  
11 -import javax.ws.rs.Path;  
12 -import javax.ws.rs.PathParam;  
13 -import javax.ws.rs.Produces;  
14 -import javax.ws.rs.core.MediaType;  
15 -import java.util.HashMap;  
16 -import java.util.List;  
17 -import java.util.Map;  
18 -  
19 -/**  
20 - * @author hill  
21 - * @date  
22 - */  
23 -@Component  
24 -@Path("/manHours")  
25 -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})  
26 -public class ManHoursRestService {  
27 -  
28 - private Map<String, Float> linelp2mh = new HashMap<>();  
29 -  
30 - @GET  
31 - @Path("")  
32 - public Map<String, Float> manHours() {  
33 - return linelp2mh;  
34 - }  
35 -  
36 - @GET  
37 - @Path("/{xlBm}/{lpName}")  
38 - public Float manHours(@PathParam("xlBm") String xlBm, @PathParam("lpName") String lpName) {  
39 - return linelp2mh.get(String.format("%s_%s", xlBm, lpName));  
40 - }  
41 -  
42 - public void setLinelp2mh(Map<String, Float> linelp2mh) {  
43 - this.linelp2mh = linelp2mh;  
44 - }  
45 -}  
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
@@ -3,15 +3,11 @@ package com.bsth.server_rs.schedule.real; @@ -3,15 +3,11 @@ package com.bsth.server_rs.schedule.real;
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
6 -import com.bsth.Application;  
7 import com.bsth.common.BasicData; 6 import com.bsth.common.BasicData;
8 import com.bsth.common.ResponseCode; 7 import com.bsth.common.ResponseCode;
9 import com.bsth.entity.ScheduleRealInfo; 8 import com.bsth.entity.ScheduleRealInfo;
10 -import com.bsth.entity.ScheduleRealInfoVo;  
11 import com.bsth.redis.ScheduleRedisService; 9 import com.bsth.redis.ScheduleRedisService;
12 import com.bsth.repository.ScheduleRealInfoRepository; 10 import com.bsth.repository.ScheduleRealInfoRepository;
13 -import com.bsth.server_rs.base_info.car.Car;  
14 -import com.bsth.server_rs.base_info.car.buffer.CarBufferData;  
15 import com.bsth.server_rs.base_info.line.Line; 11 import com.bsth.server_rs.base_info.line.Line;
16 import com.bsth.server_rs.base_info.line.buffer.LineBufferData; 12 import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
17 import com.bsth.server_rs.schedule.dto.ScheduleCcInfoConfig; 13 import com.bsth.server_rs.schedule.dto.ScheduleCcInfoConfig;
@@ -19,32 +15,22 @@ import com.bsth.server_rs.schedule.dto.ScheduleInOut; @@ -19,32 +15,22 @@ import com.bsth.server_rs.schedule.dto.ScheduleInOut;
19 import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK; 15 import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK;
20 import com.bsth.util.ConfigUtil; 16 import com.bsth.util.ConfigUtil;
21 import com.bsth.util.HttpClientUtils; 17 import com.bsth.util.HttpClientUtils;
22 -import com.fasterxml.jackson.core.JsonProcessingException;  
23 -import com.fasterxml.jackson.databind.ObjectMapper;  
24 import com.google.common.base.Splitter; 18 import com.google.common.base.Splitter;
25 import org.apache.commons.lang3.StringUtils; 19 import org.apache.commons.lang3.StringUtils;
26 -import org.apache.kafka.clients.producer.ProducerRecord;  
27 import org.joda.time.DateTime; 20 import org.joda.time.DateTime;
28 import org.joda.time.format.DateTimeFormat; 21 import org.joda.time.format.DateTimeFormat;
29 import org.joda.time.format.DateTimeFormatter; 22 import org.joda.time.format.DateTimeFormatter;
30 import org.slf4j.Logger; 23 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory; 24 import org.slf4j.LoggerFactory;
32 -import org.springframework.beans.BeanUtils;  
33 -import org.springframework.beans.factory.InitializingBean;  
34 import org.springframework.beans.factory.annotation.Autowired; 25 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.jdbc.core.JdbcTemplate; 26 import org.springframework.jdbc.core.JdbcTemplate;
36 import org.springframework.kafka.core.KafkaTemplate; 27 import org.springframework.kafka.core.KafkaTemplate;
37 -import org.springframework.kafka.support.SendResult;  
38 -import org.springframework.messaging.Message;  
39 import org.springframework.stereotype.Component; 28 import org.springframework.stereotype.Component;
40 -import org.springframework.util.concurrent.ListenableFuture;  
41 -import org.springframework.util.concurrent.ListenableFutureCallback;  
42 29
43 import javax.ws.rs.*; 30 import javax.ws.rs.*;
44 import javax.ws.rs.core.MediaType; 31 import javax.ws.rs.core.MediaType;
45 import java.net.URLEncoder; 32 import java.net.URLEncoder;
46 import java.util.*; 33 import java.util.*;
47 -import java.util.concurrent.*;  
48 34
49 /** 35 /**
50 * Created by panzhao on 2017/8/24. 36 * Created by panzhao on 2017/8/24.
@@ -52,7 +38,7 @@ import java.util.concurrent.*; @@ -52,7 +38,7 @@ import java.util.concurrent.*;
52 @Component 38 @Component
53 @Path("/schedule_real") 39 @Path("/schedule_real")
54 @Produces({MediaType.APPLICATION_JSON}) 40 @Produces({MediaType.APPLICATION_JSON})
55 -public class ScheduleRealService implements InitializingBean { 41 +public class ScheduleRealService {
56 42
57 @Autowired 43 @Autowired
58 ScheduleRedisService redisService; 44 ScheduleRedisService redisService;
@@ -330,68 +316,4 @@ public class ScheduleRealService implements InitializingBean { @@ -330,68 +316,4 @@ public class ScheduleRealService implements InitializingBean {
330 316
331 return codes; 317 return codes;
332 } 318 }
333 -  
334 - @Override  
335 - public void afterPropertiesSet() throws Exception {  
336 - Application.mainServices.scheduleWithFixedDelay(new Runnable() {  
337 - @Override  
338 - public void run() {  
339 - try {  
340 - DateTime dateTime = DateTime.now(), preDate = dateTime.minusDays(1);  
341 - List<String> dates = new ArrayList<>();  
342 - dates.add(dateTime.toString("yyyy-MM-dd"));  
343 - dates.add(preDate.toString("yyyy-MM-dd"));  
344 - if (timestamp == 0) {  
345 - timestamp = dateTime.minusHours(1).getMillis();  
346 - }  
347 - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findByDates(dates, new Date(timestamp));  
348 - timestamp = dateTime.getMillis();  
349 -  
350 - Queue<ScheduleRealInfoVo> queue = new ConcurrentLinkedDeque<>();  
351 - for (ScheduleRealInfo sch : scheduleRealInfos) {  
352 - ScheduleRealInfoVo scheduleRealInfoVo = new ScheduleRealInfoVo();  
353 - BeanUtils.copyProperties(sch, scheduleRealInfoVo);  
354 - Car car = CarBufferData.findOne(scheduleRealInfoVo.getClZbh());  
355 - scheduleRealInfoVo.setCarPlate(car == null ? "" : car.getCarPlate());  
356 - queue.add(scheduleRealInfoVo);  
357 - }  
358 -  
359 - int size = scheduleRealInfos.size();  
360 - for (int i = 0, len = size % KAFKA_BATCH_SIZE == 0 ? size / KAFKA_BATCH_SIZE : size / KAFKA_BATCH_SIZE + 1;i < len;i++) {  
361 - List<ScheduleRealInfoVo> scheduleRealInfoVos = new ArrayList<>();  
362 - for (int j = 0; j < KAFKA_BATCH_SIZE;j++) {  
363 - ScheduleRealInfoVo scheduleRealInfoVo = queue.poll();  
364 - if (scheduleRealInfoVo == null) {  
365 - break;  
366 - }  
367 - scheduleRealInfoVos.add(scheduleRealInfoVo);  
368 - }  
369 -  
370 - Map<String, Object> data = new HashMap<>();  
371 - data.put("datatype", "waybill");  
372 - data.put("datas", scheduleRealInfoVos);  
373 -  
374 - ObjectMapper mapper = new ObjectMapper();  
375 - String json = mapper.writeValueAsString(data);  
376 - logger.info(json);  
377 - ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("PDGJ_JQDD", json);  
378 - future.addCallback(new ListenableFutureCallback<SendResult<String, String>>() {  
379 -  
380 - @Override  
381 - public void onSuccess(SendResult<String, String> result) {  
382 -  
383 - }  
384 -  
385 - @Override  
386 - public void onFailure(Throwable ex) {  
387 - logger.error("kafka发送电子路单异常", ex);  
388 - }  
389 - });  
390 - }  
391 - } catch (Exception e) {  
392 - logger.error("kafka发电子路单调度异常", e);  
393 - }  
394 - }  
395 - }, 30, 240, TimeUnit.SECONDS);  
396 - }  
397 } 319 }
src/main/java/com/bsth/server_rs/white_ip/WhiteIpRestService.java deleted 100644 → 0
1 -package com.bsth.server_rs.white_ip;  
2 -  
3 -import com.bsth.entity.DestroySituation;  
4 -import com.bsth.entity.ScheduleRealInfo;  
5 -import com.bsth.entity.WhiteIp;  
6 -import com.bsth.repository.DestroySituationRepository;  
7 -import com.bsth.repository.ScheduleRealInfoRepository;  
8 -import com.bsth.server_rs.base_info.car.Car;  
9 -import com.bsth.server_rs.base_info.car.buffer.CarBufferData;  
10 -import org.springframework.beans.factory.annotation.Autowired;  
11 -import org.springframework.jdbc.core.BeanPropertyRowMapper;  
12 -import org.springframework.jdbc.core.JdbcTemplate;  
13 -import org.springframework.stereotype.Component;  
14 -  
15 -import javax.ws.rs.GET;  
16 -import javax.ws.rs.Path;  
17 -import javax.ws.rs.PathParam;  
18 -import javax.ws.rs.Produces;  
19 -import javax.ws.rs.core.MediaType;  
20 -import java.util.ArrayList;  
21 -import java.util.HashMap;  
22 -import java.util.List;  
23 -import java.util.Map;  
24 -  
25 -/**  
26 - * @author hill  
27 - * @date  
28 - */  
29 -@Component  
30 -@Path("/whiteIp")  
31 -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})  
32 -public class WhiteIpRestService {  
33 -  
34 - @Autowired  
35 - private JdbcTemplate jdbcTemplate;  
36 -  
37 - @GET  
38 - @Path("")  
39 - public List<WhiteIp> validIp() {  
40 - List<WhiteIp> result = jdbcTemplate.query("select * from control_interface.bsth_c_white_ip where valid_date > now()", BeanPropertyRowMapper.newInstance(WhiteIp.class));  
41 -  
42 - return result;  
43 - }  
44 -}  
src/main/resources/application-cloud.properties
@@ -8,7 +8,7 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy @@ -8,7 +8,7 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
8 spring.jpa.database= MYSQL 8 spring.jpa.database= MYSQL
9 spring.jpa.show-sql= false 9 spring.jpa.show-sql= false
10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver 10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11 -spring.datasource.url= jdbc:mysql://192.170.100.132/control?useUnicode=true&characterEncoding=utf-8&useSSL=false 11 +spring.datasource.url= jdbc:mysql://192.168.168.171/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 spring.datasource.username= root 12 spring.datasource.username= root
13 spring.datasource.password= root2jsp 13 spring.datasource.password= root2jsp
14 #DATASOURCE 14 #DATASOURCE
@@ -25,18 +25,11 @@ spring.datasource.validation-query=select 1 @@ -25,18 +25,11 @@ spring.datasource.validation-query=select 1
25 25
26 #REDIS 26 #REDIS
27 spring.redis.database=0 27 spring.redis.database=0
28 -spring.redis.host=192.170.100.250 28 +spring.redis.host=192.168.168.200
29 spring.redis.password=bsth_control_001 29 spring.redis.password=bsth_control_001
30 spring.redis.port=28008 30 spring.redis.port=28008
31 31
32 -#kafka  
33 -spring.kafka.bootstrap-servers=112.64.45.145:19093,112.64.45.145:19094,112.64.45.145:19095,112.64.45.145:19096  
34 -spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer  
35 -spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer  
36 -spring.kafka.producer.buffer-memory=33554432  
37 -spring.kafka.producer.acks=all  
38 -  
39 -http.control.service_data_url= https://192.170.100.54:9088/companyService 32 +http.control.service_data_url= http://192.168.168.171:9088/companyService
40 http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki 33 http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki
41 34
42 -http.gps.real.url= http://192.170.100.252:8080/transport_server/rtgps/  
43 \ No newline at end of file 35 \ No newline at end of file
  36 +http.gps.real.url= http://192.168.168.171:8080/transport_server/rtgps/
44 \ No newline at end of file 37 \ No newline at end of file
src/main/resources/application.properties
1 -spring.profiles: dev,prod  
2 -spring.profiles.active: cloud 1 +spring.profiles.active= cloud
3 2
4 spring.view.suffix=.html 3 spring.view.suffix=.html
5 server.session-timeout=-1 4 server.session-timeout=-1
src/main/resources/ms-jdbc.properties
1 -#ms.mysql.driver= com.mysql.jdbc.Driver  
2 -#ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8  
3 -#ms.mysql.username= root  
4 -#ms.mysql.password= panzhao  
5 -  
6 -ms.mysql.driver= com.mysql.jdbc.Driver  
7 -ms.mysql.url= jdbc:mysql://10.10.200.226:3306/ms?useUnicode=true&characterEncoding=utf-8  
8 -ms.mysql.username= root 1 +#ms.mysql.driver= com.mysql.jdbc.Driver
  2 +#ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8
  3 +#ms.mysql.username= root
  4 +#ms.mysql.password= panzhao
  5 +
  6 +ms.mysql.driver= com.mysql.jdbc.Driver
  7 +ms.mysql.url= jdbc:mysql://192.168.168.171/ms?useUnicode=true&characterEncoding=utf-8
  8 +ms.mysql.username= root
9 ms.mysql.password= root2jsp 9 ms.mysql.password= root2jsp
10 \ No newline at end of file 10 \ No newline at end of file