Commit 0136e0cd939252315f10699be8ea27a73c3b79d0

Authored by 王通
2 parents 3f77315e 6ce47cf6

Merge remote-tracking branch 'origin/master'

src/main/java/com/bsth/CXFConfig.java
1   -package com.bsth;
2   -
3   -
4   -import com.bsth.server_rs.AuthorizeInterceptor_IN;
5   -import com.bsth.server_rs.base_info.car.CarRestService;
6   -import com.bsth.server_rs.base_info.line.LineRestService;
7   -import com.bsth.server_rs.base_info.person.PersonRestService;
8   -import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
9   -import com.bsth.server_rs.base_info.section.LD_SectionRestService;
10   -import com.bsth.server_rs.base_info.station.StationRestService;
11   -import com.bsth.server_rs.bigdata.BigdataService;
12   -import com.bsth.server_rs.directive.DirectiveRestService;
13   -import com.bsth.server_rs.electric.ElectricService;
14   -import com.bsth.server_rs.exception.AesExceptionMapper;
15   -import com.bsth.server_rs.gps.GpsRestService;
16   -import com.bsth.server_rs.logs.RealLogRestService;
17   -import com.bsth.server_rs.rate.RateService;
18   -import com.bsth.server_rs.schedule.plan.SchedulePlanService;
19   -import com.bsth.server_rs.schedule.real.ScheduleRealService;
20   -import com.bsth.server_rs.schedule.real.StaffViewRealService;
21   -import com.bsth.server_rs.waybill.WaybillRestService;
22   -import com.bsth.server_ws.attendance.AttendanceServiceSoap;
23   -import com.bsth.server_ws.electric_oil.OilServiceSoap;
24   -import com.bsth.server_ws.park_station.CompanyServiceSoap;
25   -import com.bsth.server_ws.waybill.LD_ServiceSoap;
26   -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
27   -import org.apache.cxf.Bus;
28   -import org.apache.cxf.bus.spring.SpringBus;
29   -import org.apache.cxf.endpoint.Server;
30   -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
31   -import org.apache.cxf.jaxws.EndpointImpl;
32   -import org.apache.cxf.transport.servlet.CXFServlet;
33   -import org.springframework.beans.factory.annotation.Autowired;
34   -import org.springframework.boot.web.servlet.ServletRegistrationBean;
35   -import org.springframework.context.annotation.Bean;
36   -import org.springframework.context.annotation.Configuration;
37   -import org.springframework.core.Ordered;
38   -
39   -import javax.xml.ws.Endpoint;
40   -import java.util.Arrays;
41   -
42   -/**
43   - * Created by panzhao on 2017/3/9.
44   - */
45   -@Configuration
46   -public class CXFConfig {
47   -
48   - @Bean(name = Bus.DEFAULT_BUS_ID)
49   - public SpringBus springBus() {
50   - return new SpringBus();
51   - }
52   -
53   - @Autowired
54   - CompanyServiceSoap companyServiceSoap;
55   - @Autowired
56   - LD_ServiceSoap ld_serviceSoap;
57   - @Autowired
58   - AttendanceServiceSoap attendanceServiceSoap;
59   - @Autowired
60   - OilServiceSoap oilServiceSoap;
61   -
62   - @Bean
63   - public Endpoint companyEndpoint() {
64   - EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
65   - endpoint.publish("/CompanyService");
66   - //endpoint.getInInterceptors().add(new AuthInterceptor());
67   - return endpoint;
68   - }
69   -
70   - @Bean
71   - public Endpoint ldServiceEndpoint() {
72   - EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
73   - endpoint.publish("/LD_Service");
74   - //endpoint.getInInterceptors().add(new AuthInterceptor());
75   - return endpoint;
76   - }
77   -
78   - @Bean
79   - public Endpoint attendanceServiceEndpoint() {
80   - EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
81   - endpoint.publish("/attendanceService");
82   - //endpoint.getInInterceptors().add(new AuthInterceptor());
83   - return endpoint;
84   - }
85   -
86   - @Bean
87   - public Endpoint electricServiceEndpoint() {
88   - EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
89   - endpoint.publish("/oilServiceSoap");
90   - //endpoint.getInInterceptors().add(new AuthInterceptor());
91   - return endpoint;
92   - }
93   -
94   - @Autowired
95   - ScheduleRealService scheduleRealService;
96   - @Autowired
97   - StationRestService stationRestService;
98   - @Autowired
99   - LD_SectionRestService ldSectionRestService;
100   - @Autowired
101   - SchedulePlanService schedulePlanService;
102   - @Autowired
103   - RealLogRestService realLogRestService;
104   - @Autowired
105   - GpsRestService gpsRestService;
106   - @Autowired
107   - WaybillRestService waybillRestService;
108   - @Autowired
109   - DirectiveRestService directiveRestService;
110   - @Autowired
111   - LD_RoadSpeedRestService ld_roadSpeedRestService;
112   - @Autowired
113   - ElectricService electricService;
114   - @Autowired
115   - BigdataService bigdataService;
116   - @Autowired
117   - StaffViewRealService staffViewRealService;
118   - @Autowired
119   - RateService rateService;
120   -
121   - @Bean
122   - public Server rsServer() {
123   - JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
124   - endpoint.setBus(springBus());
125   - endpoint.setAddress("/rest");
126   - endpoint.setServiceBeans(Arrays.<Object>asList(
127   - new LineRestService(),
128   - new CarRestService(),
129   - new PersonRestService(),
130   - gpsRestService,
131   - waybillRestService,
132   - scheduleRealService,
133   - stationRestService,
134   - ldSectionRestService,
135   - schedulePlanService,
136   - realLogRestService,
137   - directiveRestService,
138   - ld_roadSpeedRestService,
139   - electricService,
140   - staffViewRealService,
141   - bigdataService,
142   - rateService));
143   - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
144   - //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
145   - endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
146   - return endpoint.create();
147   - }
148   -
149   - @Bean
150   - public ServletRegistrationBean servletRegistrationBean() {
151   - ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
152   - bean.setLoadOnStartup(0);
153   - bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
154   - return bean;
155   - }
156   -}
  1 +package com.bsth;
  2 +
  3 +
  4 +import com.bsth.server_rs.AuthorizeInterceptor_IN;
  5 +import com.bsth.server_rs.base_info.car.CarRestService;
  6 +import com.bsth.server_rs.base_info.line.LineRestService;
  7 +import com.bsth.server_rs.base_info.person.PersonRestService;
  8 +import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
  9 +import com.bsth.server_rs.base_info.section.LD_SectionRestService;
  10 +import com.bsth.server_rs.base_info.station.StationRestService;
  11 +import com.bsth.server_rs.bigdata.BigdataService;
  12 +import com.bsth.server_rs.bigdata.BigscreenService;
  13 +import com.bsth.server_rs.directive.DirectiveRestService;
  14 +import com.bsth.server_rs.electric.ElectricService;
  15 +import com.bsth.server_rs.exception.AesExceptionMapper;
  16 +import com.bsth.server_rs.gps.GpsRestService;
  17 +import com.bsth.server_rs.logs.RealLogRestService;
  18 +import com.bsth.server_rs.rate.RateService;
  19 +import com.bsth.server_rs.schedule.plan.SchedulePlanService;
  20 +import com.bsth.server_rs.schedule.real.ScheduleRealService;
  21 +import com.bsth.server_rs.schedule.real.StaffViewRealService;
  22 +import com.bsth.server_rs.waybill.WaybillRestService;
  23 +import com.bsth.server_ws.attendance.AttendanceServiceSoap;
  24 +import com.bsth.server_ws.electric_oil.OilServiceSoap;
  25 +import com.bsth.server_ws.park_station.CompanyServiceSoap;
  26 +import com.bsth.server_ws.waybill.LD_ServiceSoap;
  27 +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
  28 +import org.apache.cxf.Bus;
  29 +import org.apache.cxf.bus.spring.SpringBus;
  30 +import org.apache.cxf.endpoint.Server;
  31 +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
  32 +import org.apache.cxf.jaxws.EndpointImpl;
  33 +import org.apache.cxf.transport.servlet.CXFServlet;
  34 +import org.springframework.beans.factory.annotation.Autowired;
  35 +import org.springframework.boot.web.servlet.ServletRegistrationBean;
  36 +import org.springframework.context.annotation.Bean;
  37 +import org.springframework.context.annotation.Configuration;
  38 +import org.springframework.core.Ordered;
  39 +
  40 +import javax.xml.ws.Endpoint;
  41 +import java.util.Arrays;
  42 +
  43 +/**
  44 + * Created by panzhao on 2017/3/9.
  45 + */
  46 +@Configuration
  47 +public class CXFConfig {
  48 +
  49 + @Bean(name = Bus.DEFAULT_BUS_ID)
  50 + public SpringBus springBus() {
  51 + return new SpringBus();
  52 + }
  53 +
  54 + @Autowired
  55 + CompanyServiceSoap companyServiceSoap;
  56 + @Autowired
  57 + LD_ServiceSoap ld_serviceSoap;
  58 + @Autowired
  59 + AttendanceServiceSoap attendanceServiceSoap;
  60 + @Autowired
  61 + OilServiceSoap oilServiceSoap;
  62 +
  63 + @Bean
  64 + public Endpoint companyEndpoint() {
  65 + EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
  66 + endpoint.publish("/CompanyService");
  67 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  68 + return endpoint;
  69 + }
  70 +
  71 + @Bean
  72 + public Endpoint ldServiceEndpoint() {
  73 + EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
  74 + endpoint.publish("/LD_Service");
  75 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  76 + return endpoint;
  77 + }
  78 +
  79 + @Bean
  80 + public Endpoint attendanceServiceEndpoint() {
  81 + EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
  82 + endpoint.publish("/attendanceService");
  83 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  84 + return endpoint;
  85 + }
  86 +
  87 + @Bean
  88 + public Endpoint electricServiceEndpoint() {
  89 + EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
  90 + endpoint.publish("/oilServiceSoap");
  91 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  92 + return endpoint;
  93 + }
  94 +
  95 + @Autowired
  96 + ScheduleRealService scheduleRealService;
  97 + @Autowired
  98 + StationRestService stationRestService;
  99 + @Autowired
  100 + LD_SectionRestService ldSectionRestService;
  101 + @Autowired
  102 + SchedulePlanService schedulePlanService;
  103 + @Autowired
  104 + RealLogRestService realLogRestService;
  105 + @Autowired
  106 + GpsRestService gpsRestService;
  107 + @Autowired
  108 + WaybillRestService waybillRestService;
  109 + @Autowired
  110 + DirectiveRestService directiveRestService;
  111 + @Autowired
  112 + LD_RoadSpeedRestService ld_roadSpeedRestService;
  113 + @Autowired
  114 + ElectricService electricService;
  115 + @Autowired
  116 + BigdataService bigdataService;
  117 + @Autowired
  118 + BigscreenService bigscreenService;
  119 + @Autowired
  120 + StaffViewRealService staffViewRealService;
  121 + @Autowired
  122 + RateService rateService;
  123 +
  124 + @Bean
  125 + public Server rsServer() {
  126 + JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
  127 + endpoint.setBus(springBus());
  128 + endpoint.setAddress("/rest");
  129 + endpoint.setServiceBeans(Arrays.<Object>asList(
  130 + new LineRestService(),
  131 + new CarRestService(),
  132 + new PersonRestService(),
  133 + gpsRestService,
  134 + waybillRestService,
  135 + scheduleRealService,
  136 + stationRestService,
  137 + ldSectionRestService,
  138 + schedulePlanService,
  139 + realLogRestService,
  140 + directiveRestService,
  141 + ld_roadSpeedRestService,
  142 + electricService,
  143 + staffViewRealService,
  144 + bigdataService,
  145 + bigscreenService,
  146 + rateService));
  147 + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
  148 + //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
  149 + endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
  150 + return endpoint.create();
  151 + }
  152 +
  153 + @Bean
  154 + public ServletRegistrationBean servletRegistrationBean() {
  155 + ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
  156 + bean.setLoadOnStartup(0);
  157 + bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  158 + return bean;
  159 + }
  160 +}
... ...
src/main/java/com/bsth/entity/ChildTaskPlan.java
... ... @@ -96,6 +96,21 @@ public class ChildTaskPlan implements Serializable {
96 96 */
97 97 private String destroyReason;
98 98  
  99 + /**
  100 + * 车辆 如果为空,继承主任务
  101 + */
  102 + private String nbbm;
  103 +
  104 + /**
  105 + * 中途换车营运, 新车关联的主任务ID,子任务删除时,主任务ID将级联
  106 + */
  107 + private Long ccId;
  108 +
  109 + /**
  110 + * 为true 则无售票员, 否则继承主任务
  111 + */
  112 + private boolean noClerk;
  113 +
99 114 /** 创建日期 */
100 115 private Date createDate;
101 116  
... ... @@ -247,4 +262,29 @@ public class ChildTaskPlan implements Serializable {
247 262 public void setCreateDate(Date createDate) {
248 263 this.createDate = createDate;
249 264 }
  265 +
  266 + public String getNbbm() {
  267 + return nbbm;
  268 + }
  269 +
  270 + public void setNbbm(String nbbm) {
  271 + this.nbbm = nbbm;
  272 + }
  273 +
  274 + public Long getCcId() {
  275 + return ccId;
  276 + }
  277 +
  278 + public void setCcId(Long ccId) {
  279 + this.ccId = ccId;
  280 + }
  281 +
  282 + public boolean isNoClerk() {
  283 + return noClerk;
  284 + }
  285 +
  286 + public void setNoClerk(boolean noClerk) {
  287 + this.noClerk = noClerk;
  288 + }
  289 +
250 290 }
... ...
src/main/java/com/bsth/entity/ScheduleRealInfo.java
... ... @@ -173,6 +173,14 @@ public class ScheduleRealInfo implements Serializable{
173 173 /** 是否有补发GPS信号 */
174 174 private boolean reissue;
175 175  
  176 +
  177 +
  178 + /**
  179 + * 换车营运标记 true 表示该主任务由 【中途换车子任务】 级联生成
  180 + */
  181 + private boolean ccService;
  182 + private Integer lpChange;
  183 +
176 184 @Override
177 185 public int hashCode() {
178 186 return (this.id + this.scheduleDateStr + this.xlBm + this.fcsj).hashCode();
... ... @@ -599,6 +607,22 @@ public class ScheduleRealInfo implements Serializable{
599 607 this.reissue = reissue;
600 608 }
601 609  
  610 + public boolean isCcService() {
  611 + return ccService;
  612 + }
  613 +
  614 + public void setCcService(boolean ccService) {
  615 + this.ccService = ccService;
  616 + }
  617 +
  618 + public Integer getLpChange() {
  619 + return lpChange;
  620 + }
  621 +
  622 + public void setLpChange(Integer lpChange) {
  623 + this.lpChange = lpChange;
  624 + }
  625 +
602 626 public Double getJhlcOrig() {
603 627 return jhlcOrig;
604 628 }
... ...
src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java 0 → 100644
  1 +package com.bsth.server_rs.bigdata;
  2 +
  3 +import java.math.BigDecimal;
  4 +import java.sql.ResultSet;
  5 +import java.sql.SQLException;
  6 +import java.text.DecimalFormat;
  7 +import java.text.SimpleDateFormat;
  8 +import java.util.ArrayList;
  9 +import java.util.Date;
  10 +import java.util.HashMap;
  11 +import java.util.HashSet;
  12 +import java.util.Iterator;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +import java.util.Set;
  16 +
  17 +import javax.ws.rs.GET;
  18 +import javax.ws.rs.Path;
  19 +import javax.ws.rs.Produces;
  20 +import javax.ws.rs.core.MediaType;
  21 +
  22 +import org.apache.commons.lang.StringUtils;
  23 +import org.slf4j.Logger;
  24 +import org.slf4j.LoggerFactory;
  25 +import org.springframework.beans.factory.annotation.Autowired;
  26 +import org.springframework.jdbc.core.JdbcTemplate;
  27 +import org.springframework.jdbc.core.RowMapper;
  28 +import org.springframework.stereotype.Component;
  29 +
  30 +import com.alibaba.fastjson.JSON;
  31 +import com.alibaba.fastjson.JSONObject;
  32 +import com.bsth.entity.ChildTaskPlan;
  33 +import com.bsth.entity.ScheduleRealInfo;
  34 +import com.bsth.repository.ScheduleRealInfoRepository;
  35 +import com.bsth.util.Arith;
  36 +
  37 +@Component
  38 +@Path("/bigscreen")
  39 +@Produces({MediaType.APPLICATION_JSON})
  40 +public class BigscreenService {
  41 + Logger logger = LoggerFactory.getLogger(this.getClass());
  42 +
  43 + @Autowired
  44 + JdbcTemplate jdbcTemplate;
  45 +
  46 + @Autowired
  47 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  48 +
  49 + DecimalFormat df = new DecimalFormat("0.00");
  50 +
  51 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  52 +
  53 + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
  54 +
  55 + /*
  56 + * 线路接口开始
  57 + */
  58 + private static String getNature(String natureCode){
  59 + String natureName="";
  60 + if("lj".equals(natureCode)){
  61 + natureName="路救";
  62 + }else if("bc".equals(natureCode)){
  63 + natureName="备车";
  64 + }else if("dbc".equals(natureCode)){
  65 + natureName="定班车";
  66 + }else if("yxl".equals(natureCode)){
  67 + natureName="夜宵路";
  68 + }else if("cgxl".equals(natureCode)){
  69 + natureName="常规线路";
  70 + }else if("gjxl".equals(natureCode)){
  71 + natureName="过江线路";
  72 + }else if("csbs".equals(natureCode)){
  73 + natureName="穿梭巴士";
  74 + }else if("tyxl".equals(natureCode)){
  75 + natureName="特约线路";
  76 + }else if("cctxl".equals(natureCode)){
  77 + natureName="村村通线路";
  78 + }else if("qt".equals(natureCode)){
  79 + natureName="其他";
  80 + }else {
  81 + natureName="";
  82 + }
  83 + return natureName;
  84 + }
  85 +
  86 + private static String getGs(String gs){
  87 + String name="";
  88 + if("05".equals(gs)){
  89 + name="杨高公司";
  90 + }else if("22".equals(gs)){
  91 + name="金高公司";
  92 + }else if("26".equals(gs)){
  93 + name="南汇公司";
  94 + }else if("55".equals(gs)){
  95 + name="上南公司";
  96 + }else{
  97 + name="";
  98 + }
  99 + return name;
  100 + }
  101 +
  102 + private static String getState(String carState){
  103 + if(carState.equals("1")){
  104 + return "在册未在用";
  105 + }else if(carState.equals("2")){
  106 + return "在册在用";
  107 + }else if(carState.equals("3")){
  108 + return "报废审核中";
  109 + }else if(carState.equals("4")){
  110 + return "报废待更新";
  111 + }else if(carState.equals("5")){
  112 + return "报废已更新";
  113 + }else{
  114 + return "";
  115 + }
  116 + }
  117 +
  118 + public static boolean isInOut(ScheduleRealInfo s){
  119 + boolean fage=false;
  120 + if(s.getBcType().equals("in")){
  121 + fage=true;
  122 + }
  123 + if(s.getBcType().equals("out")){
  124 + fage=true;
  125 + }
  126 + if(s.getBcType().equals("ldks")){
  127 + fage=true;
  128 + }
  129 +
  130 + return fage;
  131 + }
  132 +
  133 + public Map<String, Long> getEndtime(String date){
  134 + Map<String, Long> map=new HashMap<String,Long>();
  135 + String sql="select xl,endtime from bsth_c_calc_count "
  136 + + " where date='"+date+"' ";
  137 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  138 + new RowMapper<Map<String, Object>>(){
  139 + @Override
  140 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  141 + Map<String, Object> m=new HashMap<String, Object>();
  142 + m.put("line", rs.getString("xl"));
  143 + m.put("endtime", rs.getString("endtime"));
  144 + return m;
  145 + }
  146 + });
  147 + for (int i = 0; i < list.size(); i++) {
  148 + map.put(list.get(i).get("line").toString(),
  149 + Long.parseLong(list.get(i).get("endtime").toString()));
  150 + }
  151 + return map;
  152 + }
  153 +
  154 + @GET
  155 + @Path("/selectData/getBigScreen")
  156 + public JSONObject getBigScreen(){
  157 + Map<String, Object> resMap = new HashMap<String, Object>();
  158 +
  159 + int day = 8;//天数
  160 +
  161 + Date dd = new Date();
  162 + String date = sd.format(dd); //yyyy-MM-dd 当天
  163 + Date dd2 = new Date();
  164 + dd2.setTime(dd.getTime() - ((long)(day-1))*1000*60*60*24);
  165 + String date2 = sd.format(dd2); //yyyy-MM-dd 7天前(加上当天就是取8天数据)
  166 +
  167 + String[] dates = new String[day];
  168 + Map<String, Integer> datesMap = new HashMap<String, Integer>();
  169 +
  170 + for(int i = 0; i < day; i++){
  171 + Date tempDate = new Date();
  172 + tempDate.setTime(dd2.getTime() + ((long)i)*1000*60*60*24);
  173 + String format = sd.format(tempDate);
  174 + dates[i] = format;
  175 + datesMap.put(format, i);
  176 + }
  177 +
  178 + String gpLineSql = "select * from bsth_c_line_plate";
  179 + List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql,
  180 + new RowMapper<Map<String, Object>>(){
  181 + @Override
  182 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  183 + Map<String, Object> m=new HashMap<String,Object>();
  184 + m.put("lineName", rs.getString("line_name"));
  185 + m.put("lineCode", rs.getString("line_code"));
  186 + return m;
  187 + }
  188 + });
  189 +
  190 + Set<String> gpSet = new HashSet<String>();
  191 + for(Map<String, Object> t : gpLineList){
  192 + if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){
  193 + gpSet.add(t.get("lineCode").toString().trim());
  194 + }
  195 + }
  196 +
  197 + String lineSql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"
  198 + + " a.shanghai_linecode, a.nature from "
  199 + + " bsth_c_line a left join bsth_c_line_config b "
  200 + + " on a.id=b.line where "
  201 + + " a.shanghai_linecode is not null and a.shanghai_linecode !='' and a.destroy=0 "
  202 + + " and a.remove=0 and a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')";
  203 + List<Map<String, Object>> lineList=jdbcTemplate.query(lineSql,
  204 + new RowMapper<Map<String, Object>>(){
  205 + @Override
  206 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  207 + Map<String, Object> m=new HashMap<String,Object>();
  208 + m.put("state", rs.getString("start_opt"));
  209 + m.put("company", rs.getString("company"));
  210 + m.put("companyName", getGs(rs.getString("company")));
  211 + m.put("lineCode",rs.getString("line_code"));
  212 + m.put("name", rs.getString("name"));
  213 + m.put("level", rs.getString("level"));
  214 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  215 + m.put("nature", getNature(rs.getString("nature")));
  216 + return m;
  217 + }
  218 + });
  219 +
  220 + Set<String> yyLine = new HashSet<String>();
  221 + int level1 = 0, level2 = 0;
  222 + for(Map<String, Object> t : lineList){
  223 + if(t.get("level") != null){
  224 + if("1".equals(t.get("level").toString())){
  225 + ++level1;
  226 + } else if("2".equals(t.get("level").toString())){
  227 + ++level2;
  228 + }
  229 + }
  230 +
  231 + if(t.get("lineCode") != null){
  232 + yyLine.add(t.get("lineCode").toString());
  233 + }
  234 + }
  235 +
  236 + String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz,"
  237 + + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz,"
  238 + + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz,"
  239 + + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz,"
  240 + + " jhszfcs,sjszfczds,szfczdl,create_date"
  241 + + " from bsth_c_calc_count "
  242 + + " where date >= '"+date2+"' and date <= '"+date+"'";
  243 +
  244 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  245 + new RowMapper<Map<String, Object>>(){
  246 + @Override
  247 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  248 + Map<String, Object> m=new HashMap<String,Object>();
  249 + m.put("lineCode",rs.getString("xl"));
  250 + m.put("lineName", rs.getString("xl_name"));
  251 + m.put("date", rs.getString("date"));
  252 +
  253 + m.put("jhbc", rs.getString("jhbc"));
  254 + m.put("sjbc", rs.getString("sjbc"));
  255 + m.put("bczxl", rs.getString("bczxl"));
  256 + m.put("jhbcz", rs.getString("jhbcz"));
  257 +
  258 + m.put("jhcc", rs.getString("jhcc"));
  259 + m.put("sjcc", rs.getString("sjcc"));
  260 + m.put("ccl", rs.getString("ccl"));
  261 + m.put("jhccz", rs.getString("jhccz"));
  262 +
  263 + m.put("jhyylc", rs.getString("jhyylc"));
  264 + m.put("sjyylc", rs.getString("sjyylc"));
  265 + m.put("jhyylcz", rs.getString("jhyylcz"));
  266 + m.put("jhkslc", rs.getString("jhkslc"));
  267 + m.put("sjkslc", rs.getString("sjkslc"));
  268 + m.put("jhkslcz", rs.getString("jhkslcz"));
  269 +
  270 + m.put("jhgfbcs", rs.getString("jhssgfbcs"));
  271 + m.put("sjgfbcs", rs.getString("sjgfbcs"));
  272 + m.put("jhgfbcsz", rs.getString("jhgfbcsz"));
  273 + m.put("jhdgbcs", rs.getString("jhssdgbcs"));
  274 + m.put("sjdgbcs", rs.getString("sjdgbcs"));
  275 + m.put("jhdgbcsz", rs.getString("jhdgbcsz"));
  276 +
  277 + m.put("jhsmbcs", rs.getString("jhsmbcs"));
  278 + m.put("sjsmbczds", rs.getString("sjsmbczds"));
  279 + m.put("smbczdl", rs.getString("smbczdl"));
  280 + m.put("jhsmbcsz", rs.getString("jhsmbcsz"));
  281 + m.put("sjsmbczdsz", rs.getString("sjsmbczdsz"));
  282 + m.put("smbczdlz", rs.getString("smbczdlz"));
  283 +
  284 + m.put("jhszfcs", rs.getString("jhszfcs"));
  285 + m.put("sjszfczds", rs.getString("sjszfczds"));
  286 + m.put("szfczdl", rs.getString("szfczdl"));
  287 +
  288 + Date date = new Date();
  289 + date.setTime(rs.getTimestamp("create_date").getTime());
  290 + m.put("createDate", sdf.format(date));
  291 + return m;
  292 + }
  293 + });
  294 +
  295 + List<Map<String, Object>> bcDetail = new ArrayList<Map<String,Object>>();
  296 + List<Map<String, Object>> smDetail = new ArrayList<Map<String,Object>>();
  297 + List<Map<String, Object>> qqDetail = new ArrayList<Map<String,Object>>();
  298 + List<Map<String, Object>> gpDetail = new ArrayList<Map<String,Object>>();
  299 +
  300 + List<Map<String, Object>> ccList = createMap("计划出车率", dates);
  301 + List<Map<String, Object>> bcList = createMap("计划班次执行率", dates);
  302 + List<Map<String, Object>> smList = createMap("首末班发车准点率", dates);
  303 + List<Map<String, Object>> qqList = createMap("起讫站发车准点率", dates);
  304 + List<Map<String, Object>> gpList = createMap("挂牌线路发车准点率", dates);
  305 +
  306 + long sjbcs_z = 0l;//实时总班次
  307 + BigDecimal yygl_z = new BigDecimal(0);//实时总营运里程
  308 + long jhcc = 0, sjcc = 0, jhbc = 0, sjbc = 0, jhsmbc = 0, sjsmbc = 0,
  309 + jhqqbc = 0, sjqqzd = 0, jhgpqqbc = 0, sjgpqqzd = 0;
  310 +
  311 + for(Map<String, Object> t : list){
  312 + if(yyLine.contains(t.get("lineCode").toString())){
  313 + String d = t.get("date").toString();
  314 + if(date.equals(d)){
  315 + sjbcs_z += Long.valueOf(t.get("sjbc").toString());
  316 + yygl_z = yygl_z.add(new BigDecimal(t.get("sjyylc").toString()));
  317 +
  318 + jhcc += Long.valueOf(t.get("jhccz").toString());
  319 + sjcc += Long.valueOf(t.get("sjcc").toString());
  320 + jhbc += Long.valueOf(t.get("jhbc").toString());
  321 + sjbc += Long.valueOf(t.get("sjbc").toString());
  322 + jhsmbc += Long.valueOf(t.get("jhsmbcs").toString());
  323 + sjsmbc += Long.valueOf(t.get("sjsmbczds").toString());
  324 + jhqqbc += Long.valueOf(t.get("jhszfcs").toString());
  325 + sjqqzd += Long.valueOf(t.get("sjszfczds").toString());
  326 + if(gpSet.contains(t.get("lineCode").toString())){
  327 + jhgpqqbc += Long.valueOf(t.get("jhszfcs").toString());
  328 + sjgpqqzd += Long.valueOf(t.get("sjszfczds").toString());
  329 + }
  330 +
  331 + Map<String, Object> bc = new HashMap<String, Object>();
  332 + bc.put("type", "班次执行详情");
  333 + bc.put("lineName", t.get("lineName").toString());
  334 + bc.put("jh", t.get("jhbc").toString());
  335 + bc.put("sj", t.get("sjbc").toString());
  336 + bcDetail.add(bc);
  337 +
  338 + Map<String, Object> sm = new HashMap<String, Object>();
  339 + sm.put("type", "首站发车详情");
  340 + sm.put("lineName", t.get("lineName").toString());
  341 + sm.put("jh", t.get("jhsmbcs").toString());
  342 + sm.put("sj", t.get("sjsmbczds").toString());
  343 + smDetail.add(sm);
  344 +
  345 + Map<String, Object> qq = new HashMap<String, Object>();
  346 + qq.put("type", "起讫站发车准点详情");
  347 + qq.put("lineName", t.get("lineName").toString());
  348 + qq.put("jh", t.get("jhszfcs").toString());
  349 + qq.put("sj", t.get("sjszfczds").toString());
  350 + qqDetail.add(qq);
  351 +
  352 + if(gpSet.contains(t.get("lineCode").toString())){
  353 + Map<String, Object> gp = new HashMap<String, Object>();
  354 + gp.put("type", "挂牌线路发车准点详情");
  355 + gp.put("lineName", t.get("lineName").toString());
  356 + gp.put("jh", t.get("jhszfcs").toString());
  357 + gp.put("sj", t.get("sjszfczds").toString());
  358 + gpDetail.add(gp);
  359 + }
  360 + }
  361 +
  362 + Map<String, Object> ccMap = ccList.get(datesMap.get(d));
  363 + Map<String, Object> bcMap = bcList.get(datesMap.get(d));
  364 + Map<String, Object> smMap = smList.get(datesMap.get(d));
  365 + Map<String, Object> qqMap = qqList.get(datesMap.get(d));
  366 + Map<String, Object> gpMap = gpList.get(datesMap.get(d));
  367 +
  368 + ccMap.put("jh", Long.valueOf(ccMap.get("jh").toString()) + Long.valueOf(t.get("jhccz").toString()));
  369 + ccMap.put("sj", Long.valueOf(ccMap.get("sj").toString()) + Long.valueOf(t.get("sjcc").toString()));
  370 + bcMap.put("jh", Long.valueOf(bcMap.get("jh").toString()) + Long.valueOf(t.get("jhbc").toString()));
  371 + bcMap.put("sj", Long.valueOf(bcMap.get("sj").toString()) + Long.valueOf(t.get("sjbc").toString()));
  372 + smMap.put("jh", Long.valueOf(smMap.get("jh").toString()) + Long.valueOf(t.get("jhsmbcs").toString()));
  373 + smMap.put("sj", Long.valueOf(smMap.get("sj").toString()) + Long.valueOf(t.get("sjsmbczds").toString()));
  374 + qqMap.put("jh", Long.valueOf(qqMap.get("jh").toString()) + Long.valueOf(t.get("jhszfcs").toString()));
  375 + qqMap.put("sj", Long.valueOf(qqMap.get("sj").toString()) + Long.valueOf(t.get("sjszfczds").toString()));
  376 + if(gpSet.contains(t.get("lineCode").toString())){
  377 + gpMap.put("jh", Long.valueOf(gpMap.get("jh").toString()) + Long.valueOf(t.get("jhszfcs").toString()));
  378 + gpMap.put("sj", Long.valueOf(gpMap.get("sj").toString()) + Long.valueOf(t.get("sjszfczds").toString()));
  379 + }
  380 +
  381 + }
  382 + }
  383 +
  384 + List<Map<String, Object>> zxlList = new ArrayList<Map<String, Object>>();
  385 + zxlList.addAll(ccList);
  386 + zxlList.addAll(bcList);
  387 + zxlList.addAll(smList);
  388 + zxlList.addAll(qqList);
  389 + zxlList.addAll(gpList);
  390 +
  391 + List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>();
  392 + detailsList.addAll(bcDetail);
  393 + detailsList.addAll(smDetail);
  394 + detailsList.addAll(qqDetail);
  395 + detailsList.addAll(gpDetail);
  396 +
  397 + for(Map<String, Object> t : zxlList){
  398 + if(t.get("jh") != null && Long.valueOf(t.get("jh").toString()).longValue() > 0l){
  399 + t.put("ratio", new BigDecimal(t.get("sj").toString()).divide(new BigDecimal(t.get("jh").toString()),
  400 + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue());
  401 + } else {
  402 + t.put("ratio", "0");
  403 + }
  404 + }
  405 +
  406 + List<Map<String, Object>> glList = new ArrayList<Map<String, Object>>();
  407 +
  408 + Date dd1 = new Date();
  409 + dd1.setTime(dd.getTime() - 1l*1000*60*60*24);
  410 + String date1 = sd.format(dd1); //前一天
  411 + List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date1);
  412 + List<ScheduleRealInfo> listSche = new ArrayList<ScheduleRealInfo>();
  413 + for(ScheduleRealInfo s : findAll){
  414 + if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路
  415 + listSche.add(s);
  416 + }
  417 + }
  418 + double jhyygl = culateJhgl(listSche);//计划营运公里
  419 + double sjgl = culateSjgl(listSche);//实际公里
  420 + double sjljgl = culateLjgl(listSche);//实际临加公里
  421 + double sjyygl = Arith.add(sjgl, sjljgl);//实际营运公里
  422 + double lz = culateCJLC(listSche, "路阻");
  423 + double dm = culateCJLC(listSche, "吊慢");
  424 + double gz = culateCJLC(listSche, "故障");
  425 + double jf = culateCJLC(listSche, "纠纷");
  426 + double zs = culateCJLC(listSche, "肇事");
  427 + double qr = culateCJLC(listSche, "缺人");
  428 + double qc = culateCJLC(listSche, "缺车");
  429 + double qrqc = Arith.add(qr, qc);//缺人缺车
  430 + double kx = culateCJLC(listSche, "客稀");
  431 + double qh = culateCJLC(listSche, "气候");
  432 + double yw = culateCJLC(listSche, "援外");
  433 + double lb_pc = culateCJLC(listSche, "配车");
  434 + double lb_by = culateCJLC(listSche, "保养");
  435 + double lb_cj = culateCJLC(listSche, "抽减");
  436 + double lb_qt = culateCJLC(listSche, "其他");
  437 + double qt = Arith.add(Arith.add(lb_pc, lb_by), Arith.add(lb_cj, lb_qt));//其他
  438 +
  439 + Map<String, Object> jhyyglMap = new HashMap<String, Object>();
  440 + jhyyglMap.put("name", "计划营运");
  441 + jhyyglMap.put("value", jhyygl);
  442 + glList.add(jhyyglMap);
  443 + Map<String, Object> sjyyglMap = new HashMap<String, Object>();
  444 + sjyyglMap.put("name", "实际营运");
  445 + sjyyglMap.put("value", sjyygl);
  446 + glList.add(sjyyglMap);
  447 + Map<String, Object> lzMap = new HashMap<String, Object>();
  448 + lzMap.put("name", "路阻");
  449 + lzMap.put("value", lz);
  450 + glList.add(lzMap);
  451 + Map<String, Object> dmMap = new HashMap<String, Object>();
  452 + dmMap.put("name", "吊慢");
  453 + dmMap.put("value", dm);
  454 + glList.add(dmMap);
  455 + Map<String, Object> gzMap = new HashMap<String, Object>();
  456 + gzMap.put("name", "故障");
  457 + gzMap.put("value", gz);
  458 + glList.add(gzMap);
  459 + Map<String, Object> jfMap = new HashMap<String, Object>();
  460 + jfMap.put("name", "纠纷");
  461 + jfMap.put("value", jf);
  462 + glList.add(jfMap);
  463 + Map<String, Object> zsMap = new HashMap<String, Object>();
  464 + zsMap.put("name", "肇事");
  465 + zsMap.put("value", zs);
  466 + glList.add(zsMap);
  467 + Map<String, Object> qrqcMap = new HashMap<String, Object>();
  468 + qrqcMap.put("name", "缺人缺车");
  469 + qrqcMap.put("value", qrqc);
  470 + glList.add(qrqcMap);
  471 + Map<String, Object> kxMap = new HashMap<String, Object>();
  472 + kxMap.put("name", "客稀");
  473 + kxMap.put("value", kx);
  474 + glList.add(kxMap);
  475 + Map<String, Object> qhMap = new HashMap<String, Object>();
  476 + qhMap.put("name", "气候");
  477 + qhMap.put("value", qh);
  478 + glList.add(qhMap);
  479 + Map<String, Object> ywMap = new HashMap<String, Object>();
  480 + ywMap.put("name", "援外");
  481 + ywMap.put("value", yw);
  482 + glList.add(ywMap);
  483 + Map<String, Object> qtMap = new HashMap<String, Object>();
  484 + qtMap.put("name", "其他");
  485 + qtMap.put("value", qt);
  486 + glList.add(qtMap);
  487 +
  488 +
  489 + resMap.put("lineCount", lineList.size());
  490 + resMap.put("level1Count", level1);
  491 + resMap.put("level2Count", level2);
  492 + resMap.put("sjbcs", sjbcs_z);
  493 + resMap.put("sjlcs", yygl_z.doubleValue());
  494 +
  495 + resMap.put("ccl", jhcc>0?new BigDecimal(sjcc).divide(new BigDecimal(jhcc),
  496 + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0");
  497 + resMap.put("bczxl", jhbc>0?new BigDecimal(sjbc).divide(new BigDecimal(jhbc),
  498 + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0");
  499 + resMap.put("smbzdl", jhbc>0?new BigDecimal(sjsmbc).divide(new BigDecimal(jhsmbc),
  500 + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0");
  501 + resMap.put("qqzzdl", jhbc>0?new BigDecimal(sjqqzd).divide(new BigDecimal(jhqqbc),
  502 + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0");
  503 + resMap.put("gpzdl", jhbc>0?new BigDecimal(sjgpqqzd).divide(new BigDecimal(jhgpqqbc),
  504 + 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).doubleValue():"0");
  505 +
  506 + resMap.put("ratioList", zxlList);
  507 +
  508 + resMap.put("detailsList", detailsList);
  509 +
  510 + resMap.put("mileageList", glList);
  511 +
  512 + return JSON.parseObject(JSON.toJSONString(resMap));
  513 + }
  514 +
  515 + @GET
  516 + @Path("/selectData/attendance")
  517 + public JSONObject attendance(){
  518 + Map<String, Object> resMap = new HashMap<String, Object>();
  519 +
  520 + int day = 7;//天数
  521 +
  522 + Date dd = new Date();
  523 + String date = sd.format(dd); //yyyy-MM-dd 当天
  524 + Date dd2 = new Date();
  525 + dd2.setTime(dd.getTime() - ((long)(day-1))*1000*60*60*24);
  526 + String date2 = sd.format(dd2); //yyyy-MM-dd 6天前(加上当天就是取7天数据)
  527 +
  528 + String[] dates = new String[day];
  529 + Map<String, Integer> datesMap = new HashMap<String, Integer>();
  530 +
  531 + for(int i = 0; i < day; i++){
  532 + Date tempDate = new Date();
  533 + tempDate.setTime(dd2.getTime() + ((long)i)*1000*60*60*24);
  534 + String format = sd.format(tempDate);
  535 + dates[i] = format;
  536 + datesMap.put(format, i);
  537 + }
  538 +
  539 + String lineSql="SELECT b.start_opt,a.company,a.line_code,a.name,a.level,"
  540 + + " a.shanghai_linecode, a.nature from "
  541 + + " bsth_c_line a left join bsth_c_line_config b "
  542 + + " on a.id=b.line where a.shanghai_linecode is not null"
  543 + + " and a.shanghai_linecode !='' and a.destroy=0 and a.remove=0"
  544 + + " and a.nature in ('yxl','cgxl','gjxl','csbs','cctxl')";
  545 + List<Map<String, Object>> lineList=jdbcTemplate.query(lineSql,
  546 + new RowMapper<Map<String, Object>>(){
  547 + @Override
  548 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  549 + Map<String, Object> m=new HashMap<String,Object>();
  550 + m.put("state", rs.getString("start_opt"));
  551 + m.put("company", rs.getString("company"));
  552 + m.put("companyName", getGs(rs.getString("company")));
  553 + m.put("lineCode",rs.getString("line_code"));
  554 + m.put("name", rs.getString("name"));
  555 + m.put("level", rs.getString("level"));
  556 + m.put("shanghaiLinecode", rs.getString("shanghai_linecode"));
  557 + m.put("nature", getNature(rs.getString("nature")));
  558 + return m;
  559 + }
  560 + });
  561 +
  562 + Set<String> yyLine = new HashSet<String>();
  563 + for(Map<String, Object> t : lineList){
  564 + if(t.get("lineCode") != null){
  565 + yyLine.add(t.get("lineCode").toString());
  566 + }
  567 + }
  568 +
  569 + List<Map<String, Object>> attList = new ArrayList<Map<String, Object>>();
  570 + List<Map<String, Object>> lackList = new ArrayList<Map<String, Object>>();
  571 +
  572 + for(int i = 0; i < dates.length; i++){
  573 + Set<String> jhSet = new HashSet<String>();
  574 + Set<String> sjSet = new HashSet<String>();
  575 + List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(dates[i]);
  576 + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();
  577 + for(ScheduleRealInfo s : findAll){
  578 + if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路
  579 + if(!isInOut(s)){
  580 + Set<ChildTaskPlan> cts = s.getcTasks();
  581 + if (cts != null && cts.size() > 0) {
  582 + list_s.add(s);
  583 + } else {
  584 + if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  585 + list_s.add(s);
  586 + }
  587 + }
  588 +
  589 + if(!s.isSflj() && !s.isCcService()){
  590 + jhSet.add(s.getjGh() + "/" + s.getjName());
  591 + }
  592 + }
  593 + }
  594 + }
  595 +
  596 + for(ScheduleRealInfo s : list_s){
  597 + if(!(s.getStatus() == -1)){
  598 + sjSet.add(s.getjGh() + "/" + s.getjName());
  599 + }
  600 +
  601 + if (s.isSflj()){
  602 + continue;
  603 + }
  604 + Set<ChildTaskPlan> cts;
  605 + cts = s.getcTasks();
  606 + //有子任务
  607 + if (cts != null && cts.size() > 0) {
  608 + for(ChildTaskPlan c : cts){
  609 + if(c.getCcId()==null){
  610 + if(c.getMileageType().equals("service")){
  611 + if(c.isDestroy() && (c.getDestroyReason()==null? "" : c.getDestroyReason()).equals("缺人")){
  612 + Map<String, Object> m = new HashMap<String, Object>();
  613 + m.put("gsName", s.getGsName());
  614 + m.put("lineName", s.getXlName());
  615 + m.put("driverName", s.getjName());
  616 + m.put("date", s.getRealExecDate());
  617 + m.put("time", c.getStartDate());
  618 + if(c.getRemarks() != null && c.getRemarks().trim().length() > 0){
  619 + m.put("explain", c.getRemarks());
  620 + } else {
  621 + m.put("explain", s.getRemarks()!=null?s.getRemarks():"");
  622 + }
  623 + lackList.add(m);
  624 + }
  625 + }
  626 + }
  627 + }
  628 + }
  629 + //主任务烂班
  630 + else if(s.getStatus() == -1 && !s.isCcService()){
  631 + if(s.getAdjustExps().equals("缺人")){
  632 + Map<String, Object> m = new HashMap<String, Object>();
  633 + m.put("gsName", s.getGsName());
  634 + m.put("lineName", s.getXlName());
  635 + m.put("driverName", s.getjName());
  636 + m.put("date", s.getRealExecDate());
  637 + m.put("time", s.getFcsj());
  638 + m.put("explain", s.getRemarks()!=null?s.getRemarks():"");
  639 + lackList.add(m);
  640 + }
  641 + }
  642 + }
  643 +
  644 + Map<String, Object> att = new HashMap<String, Object>();
  645 + att.put("date", dates[i]);
  646 + att.put("jh", jhSet.size());
  647 + att.put("sj", sjSet.size());
  648 + attList.add(att);
  649 + }
  650 +
  651 + String gpLineSql = "select p.company_code, count(1) jsy"
  652 + + " from (select e.jsy from bsth_c_s_ecinfo e"
  653 + + " where e.is_cancel = 0 group by e.jsy) a"
  654 + + " left join bsth_c_personnel p on a.jsy = p.id"
  655 + + " group by p.company_code";
  656 + List<Map<String, Object>> ecList=jdbcTemplate.query(gpLineSql,
  657 + new RowMapper<Map<String, Object>>(){
  658 + @Override
  659 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  660 + Map<String, Object> m=new HashMap<String,Object>();
  661 + m.put("company", rs.getString("company_code"));
  662 + m.put("jsy", rs.getString("jsy"));
  663 + return m;
  664 + }
  665 + });
  666 +
  667 + List<Map<String, Object>> jsyList = new ArrayList<Map<String, Object>>();
  668 + Map<String, Object> ygMap = new HashMap<String, Object>();
  669 + ygMap.put("company", "杨高");
  670 + ygMap.put("jsy", "0");
  671 + Map<String, Object> snMap = new HashMap<String, Object>();
  672 + snMap.put("company", "上南");
  673 + snMap.put("jsy", "0");
  674 + Map<String, Object> jgMap = new HashMap<String, Object>();
  675 + jgMap.put("company", "金高");
  676 + jgMap.put("jsy", "0");
  677 + Map<String, Object> nhMap = new HashMap<String, Object>();
  678 + nhMap.put("company", "南汇");
  679 + nhMap.put("jsy", "0");
  680 + for(Map<String, Object> m : ecList){ //顺序:杨高,上南,金高,南汇
  681 + if("05".equals(m.get("company").toString())){
  682 +// m.put("company", "杨高");
  683 + ygMap.put("jsy", m.get("jsy").toString());
  684 + }
  685 + if("55".equals(m.get("company").toString())){
  686 +// m.put("company", "上南");
  687 + snMap.put("jsy", m.get("jsy").toString());
  688 + }
  689 + if("22".equals(m.get("company").toString())){
  690 +// m.put("company", "金高");
  691 + jgMap.put("jsy", m.get("jsy").toString());
  692 + }
  693 + if("26".equals(m.get("company").toString())){
  694 +// m.put("company", "南汇");
  695 + nhMap.put("jsy", m.get("jsy").toString());
  696 + }
  697 + }
  698 + jsyList.add(ygMap);
  699 + jsyList.add(snMap);
  700 + jsyList.add(jgMap);
  701 + jsyList.add(nhMap);
  702 +
  703 + String xlSql = "select a.jsy, b.spy, c.cl from"
  704 + + " (select count(1) jsy from (select a.jsy from bsth_c_s_ecinfo a where a.is_cancel = 0 and a.spy is not null and a.jsy is not null group by jsy) a) a"
  705 + + " LEFT JOIN"
  706 + + " (select count(1) spy from (select b.spy from bsth_c_s_ecinfo b where b.is_cancel = 0 and b.spy is not null group by spy) b) b"
  707 + + " on 1=1"
  708 + + " LEFT JOIN"
  709 + + " (select count(1) cl from (select c.cl from bsth_c_s_ccinfo c where c.is_cancel = 0 and c.cl is not null and c.xl in(select e.xl from bsth_c_s_ecinfo e where e.is_cancel = 0 and e.spy is not null) group by c.cl) c) c"
  710 + + " on 1=1";
  711 + List<Map<String, Object>> xlConfigList=jdbcTemplate.query(xlSql,
  712 + new RowMapper<Map<String, Object>>(){
  713 + @Override
  714 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  715 + Map<String, Object> m=new HashMap<String,Object>();
  716 + m.put("jsy", rs.getString("jsy"));
  717 + m.put("spy", rs.getString("spy"));
  718 + m.put("cl", rs.getString("cl"));
  719 + return m;
  720 + }
  721 + });
  722 + long jsy = 0l, spy = 0l, cl = 0l;
  723 + for(Map<String, Object> t : xlConfigList){
  724 + if(t.get("jsy") != null){
  725 + jsy += Long.valueOf(t.get("jsy").toString());
  726 + }
  727 + if(t.get("spy") != null){
  728 + spy += Long.valueOf(t.get("spy").toString());
  729 + }
  730 + if(t.get("cl") != null){
  731 + cl += Long.valueOf(t.get("cl").toString());
  732 + }
  733 + }
  734 +
  735 + resMap.put("jsyList", jsyList);
  736 + resMap.put("attList", attList);
  737 + resMap.put("lackList", lackList);
  738 + resMap.put("salesmanJsy", jsy);
  739 + resMap.put("salesmanSpy", spy);
  740 + resMap.put("salesmanCl", cl);
  741 +
  742 + return JSON.parseObject(JSON.toJSONString(resMap));
  743 + }
  744 +
  745 + @GET
  746 + @Path("/selectData/getReport")
  747 + public List<Map<String, Object>> getReport(){
  748 + String sql="SELECT ID,REPORT_TYPE,REPORT_GS,REPORT_FGS,REPORT_GSNAME,REPORT_FGSNAME,"
  749 + + " REPORT_DATE,REPORT_BBR,REPORT_XL,REPORT_XLNAME,REPORT_STATION,REPORT_DWSBBM,"
  750 + + " REPORT_DWSBSJ,REPORT_YWSJ,REPORT_SMBWD,REPORT_DJGSJ,REPORT_DJGYY,REPORT_TFSJ,"
  751 + + " REPORT_YXSJ,REPORT_YXBC,REPORT_TZCS,REPORT_SGBH,REPORT_ZBH,REPORT_PZH,REPORT_JSY,"
  752 + + " REPORT_SGSJ,REPORT_SGDD,REPORT_XSFX,REPORT_SGDX,REPORT_DXPZH,REPORT_SGGK,"
  753 + + " REPORT_SSRS,REPORT_SWRS,REPORT_BGR,REPORT_BGRDH,REPORT_BZ,REPORT_ROAD,STATUS,"
  754 + + " CREATE_BY,CREATE_DATE,UPDATE_BY,UPDATE_DATE"
  755 + + " from bsth_t_report ";
  756 + List<Map<String, Object>> list=jdbcTemplate.query(sql,
  757 + new RowMapper<Map<String, Object>>(){
  758 + @Override
  759 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  760 + Map<String, Object> m=new HashMap<String,Object>();
  761 + m.put("ID", rs.getString("ID"));
  762 + m.put("REPORT_TYPE", rs.getString("REPORT_TYPE"));
  763 + m.put("REPORT_GS", rs.getString("REPORT_GS"));
  764 + m.put("REPORT_FGS",rs.getString("REPORT_FGS"));
  765 + m.put("REPORT_GSNAME",rs.getString("REPORT_GSNAME"));
  766 + m.put("REPORT_FGSNAME",rs.getString("REPORT_FGSNAME"));
  767 + m.put("REPORT_DATE",rs.getString("REPORT_DATE"));
  768 + m.put("REPORT_BBR",rs.getString("REPORT_BBR"));
  769 + m.put("REPORT_XL",rs.getString("REPORT_XL"));
  770 + m.put("REPORT_XLNAME",rs.getString("REPORT_XLNAME"));
  771 + m.put("REPORT_STATION",rs.getString("REPORT_STATION"));
  772 + m.put("REPORT_DWSBBM",rs.getString("REPORT_DWSBBM"));
  773 + m.put("REPORT_DWSBSJ",rs.getString("REPORT_DWSBSJ"));
  774 + m.put("REPORT_YWSJ",rs.getString("REPORT_YWSJ"));
  775 + m.put("REPORT_SMBWD",rs.getString("REPORT_SMBWD"));
  776 + m.put("REPORT_DJGSJ",rs.getString("REPORT_DJGSJ"));
  777 + m.put("REPORT_DJGYY",rs.getString("REPORT_DJGYY"));
  778 + m.put("REPORT_TFSJ",rs.getString("REPORT_TFSJ"));
  779 + m.put("REPORT_YXSJ",rs.getString("REPORT_YXSJ"));
  780 + m.put("REPORT_YXBC",rs.getString("REPORT_YXBC"));
  781 + m.put("REPORT_TZCS",rs.getString("REPORT_TZCS"));
  782 + m.put("REPORT_SGBH",rs.getString("REPORT_SGBH"));
  783 + m.put("REPORT_ZBH",rs.getString("REPORT_ZBH"));
  784 + m.put("REPORT_PZH",rs.getString("REPORT_PZH"));
  785 + m.put("REPORT_JSY",rs.getString("REPORT_JSY"));
  786 + m.put("REPORT_SGSJ",rs.getString("REPORT_SGSJ"));
  787 + m.put("REPORT_SGDD",rs.getString("REPORT_SGDD"));
  788 + m.put("REPORT_XSFX", rs.getString("REPORT_XSFX"));
  789 + m.put("REPORT_SGDX", rs.getString("REPORT_SGDX"));
  790 + m.put("REPORT_DXPZH", rs.getString("REPORT_DXPZH"));
  791 + m.put("REPORT_SGGK", rs.getString("REPORT_SGGK"));
  792 + m.put("REPORT_SSRS", rs.getString("REPORT_SSRS"));
  793 + m.put("REPORT_SWRS", rs.getString("REPORT_SWRS"));
  794 + m.put("REPORT_BGR", rs.getString("REPORT_BGR"));
  795 + m.put("REPORT_BGRDH", rs.getString("REPORT_BGRDH"));
  796 + m.put("REPORT_BZ", rs.getString("REPORT_BZ"));
  797 + m.put("REPORT_ROAD", rs.getString("REPORT_ROAD"));
  798 + m.put("STATUS", rs.getString("STATUS"));
  799 + m.put("CREATE_BY", rs.getString("CREATE_BY"));
  800 + m.put("CREATE_DATE", rs.getString("CREATE_DATE"));
  801 + m.put("UPDATE_BY", rs.getString("UPDATE_BY"));
  802 + m.put("UPDATE_DATE", rs.getString("UPDATE_DATE"));
  803 + return m;
  804 + }
  805 + });
  806 +
  807 + return list;
  808 + }
  809 +
  810 + public List<Map<String, Object>> createMap(String type, String[] dates){
  811 + List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
  812 +
  813 + for(int i = 0; i < dates.length; i++){
  814 + Map<String, Object> tempMap = new HashMap<String, Object>();
  815 + tempMap.put("type", type);
  816 + String[] split = dates[i].split("-");
  817 + tempMap.put("date", split[1] + "/" + split[2]);
  818 + tempMap.put("jh", "0");
  819 + tempMap.put("sj", "0");
  820 + mapList.add(tempMap);
  821 + }
  822 +
  823 + return mapList;
  824 + }
  825 +
  826 + public double culateJhgl(List<ScheduleRealInfo> lists) {
  827 + // TODO Auto-generated method stub
  828 + double jhgl=0;
  829 + for (int i = 0; i < lists.size(); i++) {
  830 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  831 + if (!isInOut(scheduleRealInfo)) {
  832 + if(!scheduleRealInfo.isSflj() && !scheduleRealInfo.isCcService()){
  833 + jhgl=Arith.add(jhgl,scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  834 + }
  835 + }
  836 + }
  837 + return jhgl;
  838 + }
  839 +
  840 + public double culateSjgl(List<ScheduleRealInfo> lists) {
  841 + // TODO Auto-generated method stub
  842 + double sjgl=0;
  843 + for (int i = 0; i < lists.size(); i++) {
  844 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  845 + if (!isInOut(scheduleRealInfo)) {
  846 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  847 + if(!scheduleRealInfo.isSflj()){
  848 + if(childTaskPlans.isEmpty()){
  849 + if(!(scheduleRealInfo.getStatus() == -1)){
  850 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  851 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  852 + if(jhlc-jhlcOrig>0){
  853 + sjgl=Arith.add(sjgl,jhlcOrig);
  854 + }else{
  855 + sjgl=Arith.add(sjgl,jhlc);
  856 + }
  857 +
  858 + }
  859 + }else{
  860 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  861 + while (it.hasNext()) {
  862 + ChildTaskPlan childTaskPlan = it.next();
  863 + if(childTaskPlan.getMileageType().equals("service")
  864 + &&"正常".equals(childTaskPlan.getType1())
  865 + && childTaskPlan.getCcId()==null){
  866 + if (!childTaskPlan.isDestroy()) {
  867 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  868 + sjgl=Arith.add(sjgl,jhgl);
  869 + }
  870 + }
  871 + }
  872 + }
  873 + }
  874 + }
  875 + }
  876 + return sjgl;
  877 + }
  878 +
  879 + public double culateLjgl(List<ScheduleRealInfo> lists) {
  880 + // TODO Auto-generated method stub
  881 + double ljgl=0;
  882 + for (int i = 0; i < lists.size(); i++) {
  883 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  884 + if (!isInOut(scheduleRealInfo)) {
  885 + if(!(scheduleRealInfo.getStatus() == -1)){
  886 + if(scheduleRealInfo.isSflj()){
  887 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  888 + if(childTaskPlans.isEmpty()){
  889 + ljgl=Arith.add(ljgl,scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  890 + }else{
  891 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  892 + while (it.hasNext()) {
  893 + ChildTaskPlan childTaskPlan = it.next();
  894 + if(childTaskPlan.getMileageType().equals("service") && childTaskPlan.getCcId()==null){
  895 + if (!childTaskPlan.isDestroy()) {
  896 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  897 + ljgl=Arith.add(ljgl,jhgl);
  898 + }
  899 + }
  900 + }
  901 + }
  902 + }else{
  903 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  904 + if(childTaskPlans.isEmpty()){
  905 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  906 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  907 + double zjlc=Arith.sub(jhlc, jhlcOrig);
  908 + if(zjlc>0){
  909 + ljgl=Arith.add(zjlc, ljgl);
  910 + }
  911 + }else{
  912 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  913 + while (it.hasNext()) {
  914 + ChildTaskPlan childTaskPlan = it.next();
  915 + if(childTaskPlan.getCcId()==null){
  916 + if("service".equals(childTaskPlan.getMileageType())&&"临加".equals(childTaskPlan.getType1())){
  917 + if (!childTaskPlan.isDestroy()) {
  918 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  919 + ljgl=Arith.add(ljgl,jhgl);
  920 + }
  921 + }
  922 + }
  923 + }
  924 + }
  925 + }
  926 + }
  927 +
  928 + }
  929 + }
  930 + return ljgl;
  931 + }
  932 +
  933 + public double culateCJLC(List<ScheduleRealInfo> list, String item) {
  934 + // TODO Auto-generated method stub
  935 + double sum = 0;
  936 + Set<ChildTaskPlan> cts;
  937 + for(ScheduleRealInfo sch : list){
  938 + if (sch.isSflj())
  939 + continue;
  940 + cts = sch.getcTasks();
  941 + if(isInOut(sch))
  942 + continue;
  943 + //有子任务
  944 + if (cts != null && cts.size() > 0) {
  945 + for(ChildTaskPlan c : cts){
  946 + if(c.getCcId()==null){
  947 + if(c.getMileageType().equals("service")){
  948 + if(item.equals("其他")){
  949 + if(c.isDestroy() &&
  950 + ((c.getDestroyReason()==null?"": c.getDestroyReason()).equals(item)||
  951 + (c.getDestroyReason()==null?"": c.getDestroyReason()).equals("")))
  952 + sum = Arith.add(sum, c.getMileage());
  953 + }else{
  954 + if(c.isDestroy() && (c.getDestroyReason()==null?"": c.getDestroyReason()).equals(item))
  955 + sum = Arith.add(sum, c.getMileage());
  956 + }
  957 + }
  958 + }
  959 + }
  960 + }
  961 +
  962 + //主任务烂班
  963 + else if(sch.getStatus() == -1 && !sch.isCcService()){
  964 + if(sch.getAdjustExps().equals(item) ||
  965 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){
  966 + sum = Arith.add(sum, sch.getJhlcOrig());
  967 + }
  968 + }
  969 + else if(item.equals("其他")){
  970 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  971 + if(diff > 0){
  972 + sum = Arith.add(sum, diff);
  973 + }
  974 + }
  975 + }
  976 + return sum;
  977 + }
  978 +}
... ...