Commit aac8cf5fb9ccb197bb401f8f9c1f71476e4f3758

Authored by 潘钊
1 parent 3b394d44

update...

src/main/java/com/bsth/CXFConfig.java
... ... @@ -4,9 +4,11 @@ import com.bsth.server_rs.AuthorizeInterceptor_IN;
4 4 import com.bsth.server_rs.base_info.car.CarRestService;
5 5 import com.bsth.server_rs.base_info.line.LineRestService;
6 6 import com.bsth.server_rs.base_info.person.PersonRestService;
  7 +import com.bsth.server_rs.base_info.section.LD_SectionRestService;
7 8 import com.bsth.server_rs.base_info.station.StationRestService;
8 9 import com.bsth.server_rs.exception.AesExceptionMapper;
9 10 import com.bsth.server_rs.gps.GpsRestService;
  11 +import com.bsth.server_rs.schedule.plan.SchedulePlanService;
10 12 import com.bsth.server_rs.schedule.real.ScheduleRealService;
11 13 import com.bsth.server_ws.attendance.AttendanceServiceSoap;
12 14 import com.bsth.server_ws.park_station.CompanyServiceSoap;
... ... @@ -73,9 +75,12 @@ public class CXFConfig {
73 75  
74 76 @Autowired
75 77 ScheduleRealService scheduleRealService;
76   -
77 78 @Autowired
78 79 StationRestService stationRestService;
  80 + @Autowired
  81 + LD_SectionRestService ldSectionRestService;
  82 + @Autowired
  83 + SchedulePlanService schedulePlanService;
79 84  
80 85 @Bean
81 86 public Server rsServer() {
... ... @@ -88,7 +93,9 @@ public class CXFConfig {
88 93 new PersonRestService(),
89 94 new GpsRestService(),
90 95 scheduleRealService,
91   - stationRestService));
  96 + stationRestService,
  97 + ldSectionRestService,
  98 + schedulePlanService));
92 99 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
93 100 //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
94 101 endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
... ...
src/main/java/com/bsth/common/BasicData.java
... ... @@ -69,7 +69,7 @@ public class BasicData implements CommandLineRunner {
69 69 }
70 70  
71 71 private String calcScheduleDate(String startDate){
72   - return "20170828";
  72 + return "20170831";
73 73 }
74 74 }
75 75 }
... ...
src/main/java/com/bsth/server_rs/base_info/section/LD_SectionRestService.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.section;
  2 +
  3 +import com.bsth.server_rs.base_info.section.buffer.LD_SectionBufferData;
  4 +import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute;
  5 +import org.springframework.stereotype.Component;
  6 +
  7 +import javax.ws.rs.GET;
  8 +import javax.ws.rs.Path;
  9 +import javax.ws.rs.PathParam;
  10 +import javax.ws.rs.Produces;
  11 +import javax.ws.rs.core.MediaType;
  12 +import java.util.Collection;
  13 +import java.util.Map;
  14 +
  15 +/**
  16 + * Created by panzhao on 2017/9/1.
  17 + */
  18 +
  19 +@Component
  20 +@Path("/ld_section")
  21 +@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  22 +public class LD_SectionRestService {
  23 +
  24 + @GET
  25 + @Path("/{company}")
  26 + public Map<String, Collection<LD_SectionRoute>> findByCompany(@PathParam("company") String company){
  27 + return LD_SectionBufferData.findRouteByCompany(company);
  28 + }
  29 +}
... ...
src/main/java/com/bsth/server_rs/base_info/section/buffer/LD_SectionBufferData.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.section.buffer;
  2 +
  3 +import com.bsth.Application;
  4 +import com.bsth.server_rs.base_info.line.Line;
  5 +import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
  6 +import com.bsth.server_rs.base_info.section.entity.LD_Section;
  7 +import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute;
  8 +import com.google.common.collect.ArrayListMultimap;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.boot.CommandLineRunner;
  11 +import org.springframework.core.annotation.Order;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +import java.util.*;
  15 +import java.util.concurrent.TimeUnit;
  16 +
  17 +/**
  18 + * 站点数据缓存(自更新)
  19 + * Created by panzhao on 2017/3/27.
  20 + */
  21 +@Component
  22 +@Order(6)
  23 +public class LD_SectionBufferData implements CommandLineRunner {
  24 +
  25 +
  26 + private static List<LD_Section> data;
  27 + private static Map<String, LD_Section> codeMap;
  28 +
  29 + @Autowired
  30 + LD_SectionRefreshThread ld_sectionRefreshThread;
  31 +
  32 + /**
  33 + 路由缓存
  34 + 线路编码_上下行 ——> 路由集合
  35 + */
  36 + private static ArrayListMultimap<String, LD_SectionRoute> routeListMap;
  37 +
  38 +
  39 + public static List<LD_Section> findAll(){
  40 + return data;
  41 + }
  42 +
  43 + public static Map<String, Collection<LD_SectionRoute>> findAllRoute(){
  44 + return routeListMap.asMap();
  45 + }
  46 +
  47 + public static LD_Section findOne(String code){
  48 + return codeMap.get(code);
  49 + }
  50 +
  51 + public static void replaceAll(List<LD_Section> newData){
  52 + data = newData;
  53 + Map<String, LD_Section> codeMapCopy = new HashMap<>();
  54 + for(LD_Section section : data){
  55 + codeMapCopy.put(section.getSectionCode(), section);
  56 + }
  57 +
  58 + codeMap = codeMapCopy;
  59 + }
  60 +
  61 + public static void replaceRoutes(List<LD_SectionRoute> list){
  62 + Collections.sort(list, new Comparator<LD_SectionRoute>() {
  63 + @Override
  64 + public int compare(LD_SectionRoute o1, LD_SectionRoute o2) {
  65 + return o1.getSectionrouteCode().compareTo(o2.getSectionrouteCode());
  66 + }
  67 + });
  68 +
  69 + ArrayListMultimap<String, LD_SectionRoute> routeListMapCopy = ArrayListMultimap.create();
  70 + for(LD_SectionRoute sr : list){
  71 + routeListMapCopy.put(sr.getLineCode()+"_" + sr.getDirections(), sr);
  72 + }
  73 +
  74 + routeListMap = routeListMapCopy;
  75 + }
  76 +
  77 + @Override
  78 + public void run(String... strings) throws Exception {
  79 + Application.mainServices.scheduleWithFixedDelay(ld_sectionRefreshThread, 10, 60 * 60, TimeUnit.SECONDS);
  80 + }
  81 +
  82 + public static Map<String, Collection<LD_SectionRoute>> findRouteByCompany(String company) {
  83 + List<Line> lines = LineBufferData.findByCompany(company);
  84 +
  85 + ArrayListMultimap<String, LD_SectionRoute> listMap = ArrayListMultimap.create();
  86 +
  87 +
  88 + Set<String> ks = routeListMap.keySet();
  89 +
  90 + for(String k : ks){
  91 + if(include(lines, k)){
  92 + listMap.putAll(k, routeListMap.get(k));
  93 + }
  94 + }
  95 + return listMap.asMap();
  96 + }
  97 +
  98 + private static boolean include(List<Line> lines, String k){
  99 +
  100 + for(Line line : lines){
  101 + if(k.startsWith(line.getLineCode() + "_"))
  102 + return true;
  103 + }
  104 + return false;
  105 + }
  106 +}
... ...
src/main/java/com/bsth/server_rs/base_info/section/buffer/LD_SectionRefreshThread.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.section.buffer;
  2 +
  3 +import com.bsth.server_rs.base_info.section.entity.LD_Section;
  4 +import com.bsth.server_rs.base_info.section.entity.LD_SectionRoute;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  9 +import org.springframework.jdbc.core.JdbcTemplate;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * Created by panzhao on 2017/3/27.
  16 + */
  17 +@Component
  18 +public class LD_SectionRefreshThread extends Thread{
  19 +
  20 + @Autowired
  21 + JdbcTemplate jdbcTemplate;
  22 +
  23 + Logger logger = LoggerFactory.getLogger(this.getClass());
  24 +
  25 + @Override
  26 + public void run() {
  27 +
  28 + try {
  29 +
  30 + //路段信息
  31 + List<LD_Section> sectionList = jdbcTemplate.query("select section_code,section_name,section_type,ST_AsText(gsection_vector) as gsection_vector,croses_road,versions from bsth_c_section where section_name not like '%行路段' ",
  32 + BeanPropertyRowMapper.newInstance(LD_Section.class));
  33 +
  34 + if(sectionList == null || sectionList.size() == 0)
  35 + return;
  36 +
  37 + LD_SectionBufferData.replaceAll(sectionList);
  38 +
  39 + //路段路由信息
  40 + List<LD_SectionRoute> routeList = jdbcTemplate.query("select line_code,section_code,directions,sectionroute_code,versions from bsth_c_sectionroute where destroy=0",
  41 + BeanPropertyRowMapper.newInstance(LD_SectionRoute.class));
  42 +
  43 + for(LD_SectionRoute sr : routeList){
  44 + sr.setSection(LD_SectionBufferData.findOne(sr.getSectionCode()));
  45 + }
  46 +
  47 + LD_SectionBufferData.replaceRoutes(routeList);
  48 + }catch (Exception e){
  49 + logger.error("", e);
  50 + }
  51 + }
  52 +}
... ...
src/main/java/com/bsth/server_rs/base_info/section/entity/LD_Section.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.section.entity;
  2 +
  3 +/**
  4 + * 路段
  5 + * Created by panzhao on 2017/9/1.
  6 + */
  7 +public class LD_Section {
  8 +
  9 + /** 路段编码 */
  10 + private String sectionCode;
  11 +
  12 + /** 路段名称 */
  13 + private String sectionName;
  14 +
  15 + /** 路段类型 */
  16 + private String sectionType;
  17 +
  18 + /** 路段矢量(空间坐标点集合)--GPS坐标点 */
  19 + private String gsectionVector;
  20 +
  21 + /** 交叉路 */
  22 + private String crosesRoad;
  23 +
  24 + /** 版本号 */
  25 + private Integer versions;
  26 +
  27 + public String getSectionCode() {
  28 + return sectionCode;
  29 + }
  30 +
  31 + public void setSectionCode(String sectionCode) {
  32 + this.sectionCode = sectionCode;
  33 + }
  34 +
  35 + public String getSectionName() {
  36 + return sectionName;
  37 + }
  38 +
  39 + public void setSectionName(String sectionName) {
  40 + this.sectionName = sectionName;
  41 + }
  42 +
  43 + public String getSectionType() {
  44 + return sectionType;
  45 + }
  46 +
  47 + public void setSectionType(String sectionType) {
  48 + this.sectionType = sectionType;
  49 + }
  50 +
  51 + public String getGsectionVector() {
  52 + return gsectionVector;
  53 + }
  54 +
  55 + public void setGsectionVector(String gsectionVector) {
  56 + this.gsectionVector = gsectionVector;
  57 + }
  58 +
  59 + public String getCrosesRoad() {
  60 + return crosesRoad;
  61 + }
  62 +
  63 + public void setCrosesRoad(String crosesRoad) {
  64 + this.crosesRoad = crosesRoad;
  65 + }
  66 +
  67 + public Integer getVersions() {
  68 + return versions;
  69 + }
  70 +
  71 + public void setVersions(Integer versions) {
  72 + this.versions = versions;
  73 + }
  74 +}
... ...
src/main/java/com/bsth/server_rs/base_info/section/entity/LD_SectionRoute.java 0 → 100644
  1 +package com.bsth.server_rs.base_info.section.entity;
  2 +
  3 +/**
  4 + * 路段路由
  5 + * Created by panzhao on 2017/9/1.
  6 + */
  7 +public class LD_SectionRoute {
  8 +
  9 + /** 线路编号 */
  10 + private String lineCode;
  11 +
  12 + /** 路段编号 */
  13 + private String sectionCode;
  14 +
  15 + /** 路段路由方向 */
  16 + private Integer directions;
  17 +
  18 + /** 路段路由序号 */
  19 + private Integer sectionrouteCode;
  20 +
  21 + /** 版本号 */
  22 + private Integer versions;
  23 +
  24 + /** 路段详细 */
  25 + private LD_Section section;
  26 +
  27 + public String getLineCode() {
  28 + return lineCode;
  29 + }
  30 +
  31 + public void setLineCode(String lineCode) {
  32 + this.lineCode = lineCode;
  33 + }
  34 +
  35 + public String getSectionCode() {
  36 + return sectionCode;
  37 + }
  38 +
  39 + public void setSectionCode(String sectionCode) {
  40 + this.sectionCode = sectionCode;
  41 + }
  42 +
  43 + public Integer getDirections() {
  44 + return directions;
  45 + }
  46 +
  47 + public void setDirections(Integer directions) {
  48 + this.directions = directions;
  49 + }
  50 +
  51 + public Integer getSectionrouteCode() {
  52 + return sectionrouteCode;
  53 + }
  54 +
  55 + public void setSectionrouteCode(Integer sectionrouteCode) {
  56 + this.sectionrouteCode = sectionrouteCode;
  57 + }
  58 +
  59 + public Integer getVersions() {
  60 + return versions;
  61 + }
  62 +
  63 + public void setVersions(Integer versions) {
  64 + this.versions = versions;
  65 + }
  66 +
  67 + public LD_Section getSection() {
  68 + return section;
  69 + }
  70 +
  71 + public void setSection(LD_Section section) {
  72 + this.section = section;
  73 + }
  74 +}
... ...
src/main/java/com/bsth/server_rs/base_info/station/buffer/StationRefreshThread.java
... ... @@ -35,7 +35,7 @@ public class StationRefreshThread extends Thread{
35 35 StationBufferData.replaceAll(stationList);
36 36  
37 37 //站点路由信息
38   - List<StationRotue> routeList = jdbcTemplate.query("select id, line, station_route_code, line_code,station_code,station_mark,distances, to_time,directions from bsth_c_stationroute",
  38 + List<StationRotue> routeList = jdbcTemplate.query("select id, line, station_route_code, line_code,station_code,station_mark,distances, to_time,directions from bsth_c_stationroute where destroy=0",
39 39 BeanPropertyRowMapper.newInstance(StationRotue.class));
40 40  
41 41 for(StationRotue sr : routeList){
... ...
src/main/java/com/bsth/server_rs/schedule/dto/AttendancePlanDay.java 0 → 100644
  1 +package com.bsth.server_rs.schedule.dto;
  2 +
  3 +/**
  4 + * Created by panzhao on 2017/9/1.
  5 + */
  6 +public class AttendancePlanDay {
  7 +
  8 + private String jGh;
  9 +
  10 + private String jName;
  11 +
  12 + private String scheduleDate;
  13 +
  14 + public String getjGh() {
  15 + return jGh;
  16 + }
  17 +
  18 + public void setjGh(String jGh) {
  19 + this.jGh = jGh;
  20 + }
  21 +
  22 + public String getjName() {
  23 + return jName;
  24 + }
  25 +
  26 + public void setjName(String jName) {
  27 + this.jName = jName;
  28 + }
  29 +
  30 + public String getScheduleDate() {
  31 + return scheduleDate;
  32 + }
  33 +
  34 + public void setScheduleDate(String scheduleDate) {
  35 + this.scheduleDate = scheduleDate;
  36 + }
  37 +}
... ...
src/main/java/com/bsth/server_rs/schedule/dto/AttendancePlanMonth.java 0 → 100644
  1 +package com.bsth.server_rs.schedule.dto;
  2 +
  3 +import com.bsth.util.ConvertUtil;
  4 +import com.google.common.collect.ArrayListMultimap;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +
  8 +import java.util.ArrayList;
  9 +import java.util.List;
  10 +import java.util.Set;
  11 +
  12 +/**
  13 + * 计划出勤
  14 + * Created by panzhao on 2017/9/1.
  15 + */
  16 +public class AttendancePlanMonth {
  17 +
  18 + static Logger logger = LoggerFactory.getLogger(AttendancePlanMonth.class);
  19 +
  20 + public static List<AttendancePlanMonth> getMultiInstance(String month, List<AttendancePlanDay> list){
  21 + List<AttendancePlanMonth> rs = new ArrayList<>();
  22 +
  23 + if(list == null || list.size() == 0)
  24 + return rs;
  25 +
  26 + //分组
  27 + Class clazz = AttendancePlanDay.class;
  28 + try {
  29 + ArrayListMultimap<String, AttendancePlanDay> listMultimap = new ConvertUtil<AttendancePlanDay>()
  30 + .groupMultiList(list, "/", clazz.getDeclaredField("jGh"), clazz.getDeclaredField("jName"));
  31 +
  32 + Set<String> ks = listMultimap.keySet();
  33 +
  34 + for(String k : ks){
  35 + rs.add(new AttendancePlanMonth(month, k, listMultimap.get(k)));
  36 + }
  37 + } catch (NoSuchFieldException e) {
  38 + logger.error("", e);
  39 + }
  40 + return rs;
  41 + }
  42 +
  43 + AttendancePlanMonth(){}
  44 +
  45 + AttendancePlanMonth(String month, String jsy, List<AttendancePlanDay> list){
  46 + this.month = month;
  47 + this.jsy = jsy;
  48 + this.ycqts = list.size();
  49 +
  50 + StringBuilder sb = new StringBuilder();
  51 + try {
  52 + for(AttendancePlanDay p : list){
  53 + sb.append(p.getScheduleDate().split("-")[2] + ",");
  54 + }
  55 + sb.deleteCharAt(sb.length() - 1);
  56 + }catch (Exception e){
  57 + logger.error("", e);
  58 + }
  59 + this.details = sb.toString();
  60 + }
  61 +
  62 + /** 月份 yyyy-MM */
  63 + private String month;
  64 +
  65 + /** 驾驶员 */
  66 + private String jsy;
  67 +
  68 + /** 出勤天数 */
  69 + private int ycqts;
  70 +
  71 + /** 详细 */
  72 + private String details;
  73 +
  74 + public String getMonth() {
  75 + return month;
  76 + }
  77 +
  78 + public void setMonth(String month) {
  79 + this.month = month;
  80 + }
  81 +
  82 + public String getJsy() {
  83 + return jsy;
  84 + }
  85 +
  86 + public void setJsy(String jsy) {
  87 + this.jsy = jsy;
  88 + }
  89 +
  90 + public int getYcqts() {
  91 + return ycqts;
  92 + }
  93 +
  94 + public void setYcqts(int ycqts) {
  95 + this.ycqts = ycqts;
  96 + }
  97 +
  98 + public String getDetails() {
  99 + return details;
  100 + }
  101 +
  102 + public void setDetails(String details) {
  103 + this.details = details;
  104 + }
  105 +}
... ...
src/main/java/com/bsth/server_rs/schedule/dto/PlanScheduleDTO_JK.java 0 → 100644
  1 +package com.bsth.server_rs.schedule.dto;
  2 +
  3 +import com.bsth.entity.SchedulePlanInfo;
  4 +import org.joda.time.format.DateTimeFormat;
  5 +import org.joda.time.format.DateTimeFormatter;
  6 +
  7 +import javax.xml.bind.annotation.XmlRootElement;
  8 +import java.util.ArrayList;
  9 +import java.util.Collections;
  10 +import java.util.Comparator;
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 输出给监控平台的计划排班
  15 + * Created by panzhao on 2017/9/1.
  16 + */
  17 +@XmlRootElement
  18 +public class PlanScheduleDTO_JK {
  19 +
  20 + public static List<PlanScheduleDTO_JK> getMultiInstance(List<SchedulePlanInfo> list){
  21 + List<PlanScheduleDTO_JK> rs = new ArrayList<>();
  22 + if(list == null || list.size()==0)
  23 + return rs;
  24 +
  25 + Collections.sort(list, new Comparator<SchedulePlanInfo>() {
  26 + @Override
  27 + public int compare(SchedulePlanInfo o1, SchedulePlanInfo o2) {
  28 + return o1.getFcno().compareTo(o2.getFcno());
  29 + }
  30 + });
  31 +
  32 + for(SchedulePlanInfo plan : list){
  33 + rs.add(new PlanScheduleDTO_JK(plan));
  34 + }
  35 +
  36 + return rs;
  37 + }
  38 +
  39 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
  40 +
  41 + PlanScheduleDTO_JK(){}
  42 +
  43 + PlanScheduleDTO_JK(SchedulePlanInfo sch){
  44 + this.id = sch.getId();
  45 + this.scheduleDateStr = fmtyyyyMMdd.print(sch.getScheduleDate().getTime());
  46 + this.lineCode = sch.getXlBm();
  47 + this.lineName = sch.getXlName();
  48 + this.lpName = sch.getLpName();
  49 + this.nbbm = sch.getClZbh();
  50 + this.jsy = sch.getjGh() + "/" + sch.getjName();
  51 + this.spy = sch.getsGh() + "/" + sch.getsName();
  52 + this.upDowm = Integer.parseInt(sch.getXlDir());
  53 + this.qdzCode = sch.getQdzCode();
  54 + this.qdzName = sch.getQdzName();
  55 + this.zdzCode = sch.getZdzCode();
  56 + this.zdzName = sch.getZdzName();
  57 + this.fcsj = sch.getFcsj();
  58 + this.fcno = sch.getFcno();
  59 + this.jhlc = sch.getJhlc();
  60 + this.bcsj = sch.getBcsj();
  61 + this.bcType = sch.getBcType();
  62 + }
  63 +
  64 + /** 主键Id */
  65 + private Long id;
  66 +
  67 + /** 排班计划日期 */
  68 + private String scheduleDateStr;
  69 +
  70 + /** 线路编码 */
  71 + private String lineCode;
  72 +
  73 + /** 线路名称 */
  74 + private String lineName;
  75 +
  76 + /** 路牌名称 */
  77 + private String lpName;
  78 +
  79 + /** 车辆自编号 */
  80 + private String nbbm;
  81 +
  82 + /** 驾驶员工号/姓名 */
  83 + private String jsy;
  84 + /** 售票员工号/姓名 */
  85 + private String spy;
  86 +
  87 + /** 上下行 */
  88 + private Integer upDowm;
  89 + /** 起点站code */
  90 + private String qdzCode;
  91 + /** 起点站名字 */
  92 + private String qdzName;
  93 + /** 终点站code */
  94 + private String zdzCode;
  95 + /** 终点站名字 */
  96 + private String zdzName;
  97 +
  98 + /** 发车时间(格式 HH:mm) */
  99 + private String fcsj;
  100 + /** 发车顺序号 */
  101 + private Integer fcno;
  102 + /** 计划里程 */
  103 + private Double jhlc;
  104 + /** 班次历时 */
  105 + private Integer bcsj;
  106 +
  107 + /** 班次类型 */
  108 + private String bcType;
  109 +
  110 + public Long getId() {
  111 + return id;
  112 + }
  113 +
  114 + public void setId(Long id) {
  115 + this.id = id;
  116 + }
  117 +
  118 + public String getScheduleDateStr() {
  119 + return scheduleDateStr;
  120 + }
  121 +
  122 + public void setScheduleDateStr(String scheduleDateStr) {
  123 + this.scheduleDateStr = scheduleDateStr;
  124 + }
  125 +
  126 + public String getLpName() {
  127 + return lpName;
  128 + }
  129 +
  130 + public void setLpName(String lpName) {
  131 + this.lpName = lpName;
  132 + }
  133 +
  134 + public String getNbbm() {
  135 + return nbbm;
  136 + }
  137 +
  138 + public void setNbbm(String nbbm) {
  139 + this.nbbm = nbbm;
  140 + }
  141 +
  142 + public String getJsy() {
  143 + return jsy;
  144 + }
  145 +
  146 + public void setJsy(String jsy) {
  147 + this.jsy = jsy;
  148 + }
  149 +
  150 + public String getSpy() {
  151 + return spy;
  152 + }
  153 +
  154 + public void setSpy(String spy) {
  155 + this.spy = spy;
  156 + }
  157 +
  158 + public String getQdzCode() {
  159 + return qdzCode;
  160 + }
  161 +
  162 + public void setQdzCode(String qdzCode) {
  163 + this.qdzCode = qdzCode;
  164 + }
  165 +
  166 + public String getQdzName() {
  167 + return qdzName;
  168 + }
  169 +
  170 + public void setQdzName(String qdzName) {
  171 + this.qdzName = qdzName;
  172 + }
  173 +
  174 + public String getZdzCode() {
  175 + return zdzCode;
  176 + }
  177 +
  178 + public void setZdzCode(String zdzCode) {
  179 + this.zdzCode = zdzCode;
  180 + }
  181 +
  182 + public String getZdzName() {
  183 + return zdzName;
  184 + }
  185 +
  186 + public void setZdzName(String zdzName) {
  187 + this.zdzName = zdzName;
  188 + }
  189 +
  190 + public String getFcsj() {
  191 + return fcsj;
  192 + }
  193 +
  194 + public void setFcsj(String fcsj) {
  195 + this.fcsj = fcsj;
  196 + }
  197 +
  198 + public Integer getFcno() {
  199 + return fcno;
  200 + }
  201 +
  202 + public void setFcno(Integer fcno) {
  203 + this.fcno = fcno;
  204 + }
  205 +
  206 + public Double getJhlc() {
  207 + return jhlc;
  208 + }
  209 +
  210 + public void setJhlc(Double jhlc) {
  211 + this.jhlc = jhlc;
  212 + }
  213 +
  214 + public Integer getBcsj() {
  215 + return bcsj;
  216 + }
  217 +
  218 + public void setBcsj(Integer bcsj) {
  219 + this.bcsj = bcsj;
  220 + }
  221 +
  222 + public String getBcType() {
  223 + return bcType;
  224 + }
  225 +
  226 + public void setBcType(String bcType) {
  227 + this.bcType = bcType;
  228 + }
  229 +
  230 + public String getLineCode() {
  231 + return lineCode;
  232 + }
  233 +
  234 + public void setLineCode(String lineCode) {
  235 + this.lineCode = lineCode;
  236 + }
  237 +
  238 + public String getLineName() {
  239 + return lineName;
  240 + }
  241 +
  242 + public void setLineName(String lineName) {
  243 + this.lineName = lineName;
  244 + }
  245 +
  246 + public Integer getUpDowm() {
  247 + return upDowm;
  248 + }
  249 +
  250 + public void setUpDowm(Integer upDowm) {
  251 + this.upDowm = upDowm;
  252 + }
  253 +}
... ...
src/main/java/com/bsth/server_rs/schedule/dto/ScheduleInOut.java
1 1 package com.bsth.server_rs.schedule.dto;
2 2  
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONObject;
5 3 import com.bsth.entity.ScheduleRealInfo;
6 4  
7 5 import javax.xml.bind.annotation.XmlRootElement;
... ... @@ -26,43 +24,40 @@ public class ScheduleInOut implements Serializable {
26 24 if(!sch.getQdzCode().equals(tccCode) && !sch.getZdzCode().equals(tccCode))
27 25 continue;
28 26  
29   - rs.add(getInstance(sch));
  27 + rs.add(new ScheduleInOut(sch));
30 28 }
31 29 return rs;
32 30 }
33 31  
34   - public static ScheduleInOut getInstance(ScheduleRealInfo sch){
35   - return JSONObject.parseObject(JSON.toJSONString(sch), ScheduleInOut.class);
  32 + /* public static ScheduleInOut getInstance(ScheduleRealInfo sch){
  33 + //return JSONObject.parseObject(JSON.toJSONString(sch), ScheduleInOut.class);
  34 + }*/
  35 +
  36 + ScheduleInOut(){}
  37 +
  38 + ScheduleInOut(ScheduleRealInfo sch){
  39 + this.id = sch.getId();
36 40 }
37 41  
38 42 private Long id;
39 43 private String scheduleDateStr;
40   - private String realExecDate;
41   - private String xlName;
42   - private String xlBm;
  44 + private String lineCode;
  45 + private String lineName;
43 46 private String lpName;
44   - private String clZbh;
45   - private String jGh;
46   - private String jName;
47   - private String sGh;
48   - private String sName;
49   - private String xlDir;
  47 + private String nbbm;
  48 + private String jsy;
  49 + private String spy;
  50 + private Integer upDown;
50 51 private String qdzCode;
51 52 private String qdzName;
52 53 private String zdzCode;
53 54 private String zdzName;
54   - private String dfsj;
55 55 private Long dfsjT;
56   - private String zdsj;
57 56 private Long zdsjT;
58   - private String fcsjActual;
59   - private String zdsjActual;
  57 + private Long fcsjActualTime;
  58 + private Long zdsjActualTime;
60 59 private boolean sflj;
61 60 private String remarks;
62   - private String gsName;
63   - private String gsBm;
64   - private String fgsName;
65   - private String fgsBm;
66 61  
67 62 public Long getId() {
68 63 return id;
... ... @@ -80,28 +75,20 @@ public class ScheduleInOut implements Serializable {
80 75 this.scheduleDateStr = scheduleDateStr;
81 76 }
82 77  
83   - public String getRealExecDate() {
84   - return realExecDate;
85   - }
86   -
87   - public void setRealExecDate(String realExecDate) {
88   - this.realExecDate = realExecDate;
89   - }
90   -
91   - public String getXlName() {
92   - return xlName;
  78 + public String getLineCode() {
  79 + return lineCode;
93 80 }
94 81  
95   - public void setXlName(String xlName) {
96   - this.xlName = xlName;
  82 + public void setLineCode(String lineCode) {
  83 + this.lineCode = lineCode;
97 84 }
98 85  
99   - public String getXlBm() {
100   - return xlBm;
  86 + public String getLineName() {
  87 + return lineName;
101 88 }
102 89  
103   - public void setXlBm(String xlBm) {
104   - this.xlBm = xlBm;
  90 + public void setLineName(String lineName) {
  91 + this.lineName = lineName;
105 92 }
106 93  
107 94 public String getLpName() {
... ... @@ -112,52 +99,36 @@ public class ScheduleInOut implements Serializable {
112 99 this.lpName = lpName;
113 100 }
114 101  
115   - public String getClZbh() {
116   - return clZbh;
117   - }
118   -
119   - public void setClZbh(String clZbh) {
120   - this.clZbh = clZbh;
121   - }
122   -
123   - public String getjGh() {
124   - return jGh;
  102 + public String getNbbm() {
  103 + return nbbm;
125 104 }
126 105  
127   - public void setjGh(String jGh) {
128   - this.jGh = jGh;
  106 + public void setNbbm(String nbbm) {
  107 + this.nbbm = nbbm;
129 108 }
130 109  
131   - public String getjName() {
132   - return jName;
  110 + public String getJsy() {
  111 + return jsy;
133 112 }
134 113  
135   - public void setjName(String jName) {
136   - this.jName = jName;
  114 + public void setJsy(String jsy) {
  115 + this.jsy = jsy;
137 116 }
138 117  
139   - public String getsGh() {
140   - return sGh;
  118 + public String getSpy() {
  119 + return spy;
141 120 }
142 121  
143   - public void setsGh(String sGh) {
144   - this.sGh = sGh;
  122 + public void setSpy(String spy) {
  123 + this.spy = spy;
145 124 }
146 125  
147   - public String getsName() {
148   - return sName;
  126 + public Integer getUpDown() {
  127 + return upDown;
149 128 }
150 129  
151   - public void setsName(String sName) {
152   - this.sName = sName;
153   - }
154   -
155   - public String getXlDir() {
156   - return xlDir;
157   - }
158   -
159   - public void setXlDir(String xlDir) {
160   - this.xlDir = xlDir;
  130 + public void setUpDown(Integer upDown) {
  131 + this.upDown = upDown;
161 132 }
162 133  
163 134 public String getQdzCode() {
... ... @@ -192,14 +163,6 @@ public class ScheduleInOut implements Serializable {
192 163 this.zdzName = zdzName;
193 164 }
194 165  
195   - public String getDfsj() {
196   - return dfsj;
197   - }
198   -
199   - public void setDfsj(String dfsj) {
200   - this.dfsj = dfsj;
201   - }
202   -
203 166 public Long getDfsjT() {
204 167 return dfsjT;
205 168 }
... ... @@ -208,14 +171,6 @@ public class ScheduleInOut implements Serializable {
208 171 this.dfsjT = dfsjT;
209 172 }
210 173  
211   - public String getZdsj() {
212   - return zdsj;
213   - }
214   -
215   - public void setZdsj(String zdsj) {
216   - this.zdsj = zdsj;
217   - }
218   -
219 174 public Long getZdsjT() {
220 175 return zdsjT;
221 176 }
... ... @@ -224,20 +179,20 @@ public class ScheduleInOut implements Serializable {
224 179 this.zdsjT = zdsjT;
225 180 }
226 181  
227   - public String getFcsjActual() {
228   - return fcsjActual;
  182 + public Long getFcsjActualTime() {
  183 + return fcsjActualTime;
229 184 }
230 185  
231   - public void setFcsjActual(String fcsjActual) {
232   - this.fcsjActual = fcsjActual;
  186 + public void setFcsjActualTime(Long fcsjActualTime) {
  187 + this.fcsjActualTime = fcsjActualTime;
233 188 }
234 189  
235   - public String getZdsjActual() {
236   - return zdsjActual;
  190 + public Long getZdsjActualTime() {
  191 + return zdsjActualTime;
237 192 }
238 193  
239   - public void setZdsjActual(String zdsjActual) {
240   - this.zdsjActual = zdsjActual;
  194 + public void setZdsjActualTime(Long zdsjActualTime) {
  195 + this.zdsjActualTime = zdsjActualTime;
241 196 }
242 197  
243 198 public boolean isSflj() {
... ... @@ -255,36 +210,4 @@ public class ScheduleInOut implements Serializable {
255 210 public void setRemarks(String remarks) {
256 211 this.remarks = remarks;
257 212 }
258   -
259   - public String getGsName() {
260   - return gsName;
261   - }
262   -
263   - public void setGsName(String gsName) {
264   - this.gsName = gsName;
265   - }
266   -
267   - public String getGsBm() {
268   - return gsBm;
269   - }
270   -
271   - public void setGsBm(String gsBm) {
272   - this.gsBm = gsBm;
273   - }
274   -
275   - public String getFgsName() {
276   - return fgsName;
277   - }
278   -
279   - public void setFgsName(String fgsName) {
280   - this.fgsName = fgsName;
281   - }
282   -
283   - public String getFgsBm() {
284   - return fgsBm;
285   - }
286   -
287   - public void setFgsBm(String fgsBm) {
288   - this.fgsBm = fgsBm;
289   - }
290 213 }
... ...
src/main/java/com/bsth/server_rs/schedule/dto/ScheduleRealInfoDTO_JK.java
... ... @@ -14,7 +14,12 @@ import java.util.*;
14 14 @XmlRootElement
15 15 public class ScheduleRealInfoDTO_JK implements Serializable {
16 16  
17   - public static List<ScheduleRealInfoDTO_JK> getMultiInstance(List<ScheduleRealInfo> list){
  17 + public static List<ScheduleRealInfoDTO_JK> getMultiInstance(List<ScheduleRealInfo> list) {
  18 +
  19 + List<ScheduleRealInfoDTO_JK> rs = new ArrayList<>();
  20 +
  21 + if(list == null || list.size()==0)
  22 + return rs;
18 23 Collections.sort(list, new Comparator<ScheduleRealInfo>() {
19 24 @Override
20 25 public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
... ... @@ -22,20 +27,16 @@ public class ScheduleRealInfoDTO_JK implements Serializable {
22 27 }
23 28 });
24 29  
25   - List<ScheduleRealInfoDTO_JK> rs = new ArrayList<>();
26   - ScheduleRealInfoDTO_JK s;
27   - for(ScheduleRealInfo sch : list){
28   - s = new ScheduleRealInfoDTO_JK(sch);
29   - if(!s.getId().toString().equals("2740904"))
30   - continue;
31   - rs.add(s);
  30 + for (ScheduleRealInfo sch : list) {
  31 + rs.add(new ScheduleRealInfoDTO_JK(sch));
32 32 }
33 33 return rs;
34 34 }
35 35  
36   - ScheduleRealInfoDTO_JK(){}
  36 + ScheduleRealInfoDTO_JK() {
  37 + }
37 38  
38   - ScheduleRealInfoDTO_JK(ScheduleRealInfo sch){
  39 + ScheduleRealInfoDTO_JK(ScheduleRealInfo sch) {
39 40 this.id = sch.getId();
40 41 this.scheduleDate = sch.getScheduleDateStr();
41 42 this.lineName = sch.getXlName();
... ... @@ -69,53 +70,91 @@ public class ScheduleRealInfoDTO_JK implements Serializable {
69 70  
70 71 private String scheduleDate;
71 72  
72   - /** 线路名称 */
  73 + /**
  74 + * 线路名称
  75 + */
73 76 private String lineName;
74   - /** 线路编码 */
  77 + /**
  78 + * 线路编码
  79 + */
75 80 private String lineCode;
76 81  
77   - /** 路牌名称 */
  82 + /**
  83 + * 路牌名称
  84 + */
78 85 private String lpName;
79 86  
80   - /** 车辆自编号 */
  87 + /**
  88 + * 车辆自编号
  89 + */
81 90 private String nbbm;
82 91  
83   - /** 驾驶员工号/名称 */
  92 + /**
  93 + * 驾驶员工号/名称
  94 + */
84 95 private String jsy;
85   - /** 售票员工号/名称 */
  96 + /**
  97 + * 售票员工号/名称
  98 + */
86 99 private String spy;
87 100  
88   - /** 线路方向 */
  101 + /**
  102 + * 线路方向
  103 + */
89 104 private Integer upDown;
90   - /** 起点站code*/
  105 + /**
  106 + * 起点站code
  107 + */
91 108 private String qdzCode;
92   - /** 起点站名字 */
  109 + /**
  110 + * 起点站名字
  111 + */
93 112 private String qdzName;
94 113  
95   - /** 终点站code*/
  114 + /**
  115 + * 终点站code
  116 + */
96 117 private String zdzCode;
97   - /** 终点站名字 */
  118 + /**
  119 + * 终点站名字
  120 + */
98 121 private String zdzName;
99 122  
100   - /** 计划发车时间戳*/
  123 + /**
  124 + * 计划发车时间戳
  125 + */
101 126 private Long fcsjT;
102   - /**待发时间戳 */
  127 + /**
  128 + * 待发时间戳
  129 + */
103 130 private Long dfsjT;
104   - /** 计划终点时间戳*/
  131 + /**
  132 + * 计划终点时间戳
  133 + */
105 134 private Long zdsjT;
106 135  
107   - /** 实际发车时间戳*/
  136 + /**
  137 + * 实际发车时间戳
  138 + */
108 139 private Long fcsjActualTime;
109   - /** 实际终点时间戳*/
  140 + /**
  141 + * 实际终点时间戳
  142 + */
110 143 private Long zdsjActualTime;
111 144  
112   - /** 实际计划里程 */
  145 + /**
  146 + * 实际计划里程
  147 + */
113 148 private Double jhlc;
114 149  
115   - /** 计划里程 */
  150 + /**
  151 + * 计划里程
  152 + */
116 153 private Double jhlcOrig;
117 154  
118   - /** 班次历时 */
  155 + /**
  156 + * 班次历时
  157 + */
119 158 private Integer bcsj;
120 159  
121 160 /**
... ... @@ -124,18 +163,26 @@ public class ScheduleRealInfoDTO_JK implements Serializable {
124 163 private String bcType;
125 164  
126 165  
127   - /**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */
  166 + /**
  167 + * 班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班
  168 + */
128 169 private int status;
129 170  
130 171 private String adjustExps;
131 172  
132   - /** 是否是临加班次 */
  173 + /**
  174 + * 是否是临加班次
  175 + */
133 176 private boolean sflj;
134 177  
135   - /** 备注*/
  178 + /**
  179 + * 备注
  180 + */
136 181 private String remarks;
137 182  
138   - /** 子任务 */
  183 + /**
  184 + * 子任务
  185 + */
139 186 private Set<ChildTaskPlan> cTasks;
140 187  
141 188 public Long getId() {
... ...
src/main/java/com/bsth/server_rs/schedule/plan/SchedulePlanService.java 0 → 100644
  1 +package com.bsth.server_rs.schedule.plan;
  2 +
  3 +import com.bsth.redis.PlanScheduleRedisService;
  4 +import com.bsth.server_rs.base_info.line.Line;
  5 +import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
  6 +import com.bsth.server_rs.schedule.dto.AttendancePlanDay;
  7 +import com.bsth.server_rs.schedule.dto.AttendancePlanMonth;
  8 +import com.bsth.server_rs.schedule.dto.PlanScheduleDTO_JK;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  13 +import org.springframework.jdbc.core.JdbcTemplate;
  14 +import org.springframework.stereotype.Component;
  15 +
  16 +import javax.ws.rs.GET;
  17 +import javax.ws.rs.Path;
  18 +import javax.ws.rs.PathParam;
  19 +import javax.ws.rs.Produces;
  20 +import javax.ws.rs.core.MediaType;
  21 +import java.text.DateFormat;
  22 +import java.text.SimpleDateFormat;
  23 +import java.util.ArrayList;
  24 +import java.util.List;
  25 +
  26 +/**
  27 + * Created by panzhao on 2017/8/24.
  28 + */
  29 +@Component
  30 +@Path("/schedule")
  31 +@Produces({MediaType.APPLICATION_JSON})
  32 +public class SchedulePlanService {
  33 +
  34 + @Autowired
  35 + PlanScheduleRedisService redisService;
  36 +
  37 + @Autowired
  38 + JdbcTemplate jdbcTemplate;
  39 +
  40 + Logger logger = LoggerFactory.getLogger(this.getClass());
  41 +
  42 + @GET
  43 + @Path("/sch_jk/{company}/{rq}")
  44 + public List<PlanScheduleDTO_JK> find_JK(@PathParam("company") String company, @PathParam("rq") String rq){
  45 + List<PlanScheduleDTO_JK> all = new ArrayList<>();
  46 +
  47 + List<Line> lines = LineBufferData.findByCompany(company);
  48 + for(Line line : lines){
  49 + all.addAll(PlanScheduleDTO_JK.getMultiInstance(redisService.read(rq, line.getLineCode())));
  50 + }
  51 + return all;
  52 + }
  53 +
  54 + @GET
  55 + @Path("/ycqts/{company}/{month}")
  56 + public List<AttendancePlanMonth> count_ycqts(@PathParam("company") String company,@PathParam("month") String month){
  57 + try {
  58 + DateFormat formatter = new SimpleDateFormat("yyyy-MM");
  59 + formatter.parse(month);
  60 + }catch (Exception e){
  61 + logger.error("", e);
  62 + return null;
  63 + }
  64 +
  65 + List<AttendancePlanDay> list = jdbcTemplate.query("SELECT j_gh,j_name,DATE_FORMAT(schedule_date,'%Y-%m-%d') as schedule_date FROM bsth_c_s_sp_info WHERE gs_bm='"+company+"' and schedule_date LIKE '"+month+"-%' GROUP BY j_gh,j_name,DATE_FORMAT(schedule_date,'%Y-%m-%d')", BeanPropertyRowMapper.newInstance(AttendancePlanDay.class));
  66 + return AttendancePlanMonth.getMultiInstance(month, list);
  67 + }
  68 +}
... ...