Commit 4482eaed13aa412bbaf76894f93bfbc1d8db889a
1 parent
e809637a
路单数据接口添加氢能源
Showing
1 changed file
with
193 additions
and
187 deletions
src/main/java/com/bsth/server_ws/waybill/LD_ServiceSoap.java
| 1 | -package com.bsth.server_ws.waybill; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | -import java.util.Map; | |
| 5 | - | |
| 6 | -import javax.jws.WebService; | |
| 7 | -import javax.xml.ws.Holder; | |
| 8 | - | |
| 9 | -import com.fasterxml.jackson.databind.ObjectMapper; | |
| 10 | -import org.joda.time.format.DateTimeFormat; | |
| 11 | -import org.joda.time.format.DateTimeFormatter; | |
| 12 | -import org.slf4j.Logger; | |
| 13 | -import org.slf4j.LoggerFactory; | |
| 14 | -import org.springframework.beans.BeansException; | |
| 15 | -import org.springframework.context.ApplicationContext; | |
| 16 | -import org.springframework.context.ApplicationContextAware; | |
| 17 | -import org.springframework.stereotype.Component; | |
| 18 | - | |
| 19 | -import com.bsth.entity.DutyEmployee; | |
| 20 | -import com.bsth.entity.ElecInfo; | |
| 21 | -import com.bsth.entity.OilInfo; | |
| 22 | -import com.bsth.entity.ScheduleRealInfo; | |
| 23 | -import com.bsth.redis.ElecRedisService; | |
| 24 | -import com.bsth.redis.OilRedisService; | |
| 25 | -import com.bsth.redis.ScheduleRedisService; | |
| 26 | -import com.bsth.repository.DutyEmployeeRepository; | |
| 27 | -import com.bsth.server_ws.util.WSDataConver; | |
| 28 | -import com.bsth.server_ws.waybill.entity.NH_waybill; | |
| 29 | -import com.bsth.server_ws.waybill.entity.SN_lossMileage; | |
| 30 | -import com.bsth.server_ws.waybill.entity.SN_waybill; | |
| 31 | -import com.bsth.service.UserService; | |
| 32 | -import com.google.common.collect.ArrayListMultimap; | |
| 33 | - | |
| 34 | -/** | |
| 35 | - * Created by panzhao on 2017/3/17. | |
| 36 | - */ | |
| 37 | -@Component | |
| 38 | -@WebService( | |
| 39 | - name = "LD_ServiceSoap", | |
| 40 | - portName = "LD_ServiceSoap", | |
| 41 | - serviceName = "LD_Service", | |
| 42 | - targetNamespace = "http://control.bsth.com/", | |
| 43 | - endpointInterface = "com.bsth.server_ws.waybill.LD_Service") | |
| 44 | -public class LD_ServiceSoap implements LD_Service, ApplicationContextAware { | |
| 45 | - | |
| 46 | - static OilRedisService oilRedisService; | |
| 47 | - static ElecRedisService elecRedisService; | |
| 48 | - static ScheduleRedisService scheduleRedisService; | |
| 49 | - static DutyEmployeeRepository dutyEmployeeRepository; | |
| 50 | - | |
| 51 | - static UserService userService; | |
| 52 | - | |
| 53 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 54 | - | |
| 55 | - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"), | |
| 56 | - fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 57 | - | |
| 58 | - @Override | |
| 59 | - public boolean waybill_NH(String password, String rq, String companyId, Holder<NH_waybill[]> result, Holder<String> fError) { | |
| 60 | - try { | |
| 61 | - if(userService.get(password) == null){ | |
| 62 | - fError.value = "无效的密码!"; | |
| 63 | - return false; | |
| 64 | - } | |
| 65 | - //日期减一天,老接口是这样的 | |
| 66 | - //rq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 67 | - String prveRq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 68 | - | |
| 69 | - //实际排班 | |
| 70 | - ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(prveRq, companyId); | |
| 71 | - //油耗信息 | |
| 72 | - ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 73 | - //电耗信息 | |
| 74 | - ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 75 | - //当班调派 | |
| 76 | - long st = fmtyyyyMMddHHmm.parseMillis(prveRq + "00:00"), et = fmtyyyyMMddHHmm.parseMillis(prveRq + "23:59"); | |
| 77 | - List<DutyEmployee> des = dutyEmployeeRepository.findByTime(st, et); | |
| 78 | - //转换成南汇路单需要的格式 | |
| 79 | - NH_waybill[] array = WSDataConver.to_waybill_NH(listMap, oilInfoMap, elecInfoMap, des); | |
| 80 | - result.value = array; | |
| 81 | - | |
| 82 | - //不再代理老接口数据 | |
| 83 | - /*if(companyId.equals("26") && !WebServiceProxy.isAllNew(companyId)){ | |
| 84 | - ClsLDInfo[] oldArray = OldWSClient.getNH_LD(companyId, rq); | |
| 85 | - //合并新老系统的数据 | |
| 86 | - result.value = WebServiceProxy.mergerData(result.value, oldArray, companyId); | |
| 87 | - }*/ | |
| 88 | - } catch (Exception e) { | |
| 89 | - logger.error("", e); | |
| 90 | - fError.value = "服务器出现异常!"; | |
| 91 | - return false; | |
| 92 | - } | |
| 93 | - return true; | |
| 94 | - } | |
| 95 | - | |
| 96 | - @Override | |
| 97 | - public boolean waybill_NH4TH(String password, String rq, String companyId, Holder<NH_waybill[]> result, Holder<String> fError) { | |
| 98 | - try { | |
| 99 | - if(userService.get(password) == null){ | |
| 100 | - fError.value = "无效的密码!"; | |
| 101 | - return false; | |
| 102 | - } | |
| 103 | - //日期减一天,老接口是这样的 | |
| 104 | - //rq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 105 | - String prveRq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 106 | - | |
| 107 | - //实际排班 | |
| 108 | - ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(prveRq, companyId); | |
| 109 | - //油耗信息 | |
| 110 | - ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 111 | - //电耗信息 | |
| 112 | - ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 113 | - //当班调派 | |
| 114 | - long st = fmtyyyyMMddHHmm.parseMillis(prveRq + "00:00"), et = fmtyyyyMMddHHmm.parseMillis(prveRq + "23:59"); | |
| 115 | - List<DutyEmployee> des = dutyEmployeeRepository.findByTime(st, et); | |
| 116 | - //转换成南汇路单需要的格式 | |
| 117 | - NH_waybill[] array = WSDataConver.to_waybill_NH4TH(listMap, oilInfoMap, elecInfoMap, des); | |
| 118 | - result.value = array; | |
| 119 | - | |
| 120 | - //不再代理老接口数据 | |
| 121 | - /*if(companyId.equals("26") && !WebServiceProxy.isAllNew(companyId)){ | |
| 122 | - ClsLDInfo[] oldArray = OldWSClient.getNH_LD(companyId, rq); | |
| 123 | - //合并新老系统的数据 | |
| 124 | - result.value = WebServiceProxy.mergerData(result.value, oldArray, companyId); | |
| 125 | - }*/ | |
| 126 | - } catch (Exception e) { | |
| 127 | - logger.error("", e); | |
| 128 | - fError.value = "服务器出现异常!"; | |
| 129 | - return false; | |
| 130 | - } | |
| 131 | - return true; | |
| 132 | - } | |
| 133 | - | |
| 134 | - @Override | |
| 135 | - public boolean waybill_SN(String password, String rq, String companyId, Holder<SN_waybill[]> result, Holder<String> fError) { | |
| 136 | - try { | |
| 137 | - if(userService.get(password) == null){ | |
| 138 | - fError.value = "无效的密码!"; | |
| 139 | - return false; | |
| 140 | - } | |
| 141 | - | |
| 142 | - //实际排班 | |
| 143 | - ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(rq, companyId); | |
| 144 | - //油耗信息 | |
| 145 | - Map<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroupRaw(listMap.keySet(), rq); | |
| 146 | - //转换成上南路单需要的格式 | |
| 147 | - SN_waybill[] array = WSDataConver.to_waybill_SN(listMap, oilInfoMap); | |
| 148 | - result.value = array; | |
| 149 | - } catch (Exception e) { | |
| 150 | - logger.error("", e); | |
| 151 | - fError.value = "服务器出现异常!"; | |
| 152 | - return false; | |
| 153 | - } | |
| 154 | - return true; | |
| 155 | - } | |
| 156 | - | |
| 157 | - @Override | |
| 158 | - public boolean lossMileage(String password, String rq, String companyId, Holder<SN_lossMileage[]> result, Holder<String> fError) { | |
| 159 | - try { | |
| 160 | - if(userService.get(password) == null){ | |
| 161 | - fError.value = "无效的密码!"; | |
| 162 | - return false; | |
| 163 | - } | |
| 164 | - | |
| 165 | - //按线路分组的实际排班 | |
| 166 | - ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByLine(rq, companyId); | |
| 167 | - //转换成上南需要的损失公里数据 | |
| 168 | - SN_lossMileage[] array = WSDataConver.to_lossMileage_SN(listMap); | |
| 169 | - result.value = array; | |
| 170 | - } catch (Exception e) { | |
| 171 | - logger.error("", e); | |
| 172 | - fError.value = "服务器出现异常!"; | |
| 173 | - return false; | |
| 174 | - } | |
| 175 | - return false; | |
| 176 | - } | |
| 177 | - | |
| 178 | - | |
| 179 | - @Override | |
| 180 | - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 181 | - oilRedisService = applicationContext.getBean(OilRedisService.class); | |
| 182 | - elecRedisService = applicationContext.getBean(ElecRedisService.class); | |
| 183 | - scheduleRedisService = applicationContext.getBean(ScheduleRedisService.class); | |
| 184 | - dutyEmployeeRepository = applicationContext.getBean(DutyEmployeeRepository.class); | |
| 185 | - userService = applicationContext.getBean(UserService.class); | |
| 186 | - } | |
| 187 | -} | |
| 1 | +package com.bsth.server_ws.waybill; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | +import java.util.Map; | |
| 5 | + | |
| 6 | +import javax.jws.WebService; | |
| 7 | +import javax.xml.ws.Holder; | |
| 8 | + | |
| 9 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
| 10 | +import org.joda.time.format.DateTimeFormat; | |
| 11 | +import org.joda.time.format.DateTimeFormatter; | |
| 12 | +import org.slf4j.Logger; | |
| 13 | +import org.slf4j.LoggerFactory; | |
| 14 | +import org.springframework.beans.BeansException; | |
| 15 | +import org.springframework.context.ApplicationContext; | |
| 16 | +import org.springframework.context.ApplicationContextAware; | |
| 17 | +import org.springframework.stereotype.Component; | |
| 18 | + | |
| 19 | +import com.bsth.entity.DutyEmployee; | |
| 20 | +import com.bsth.entity.ElecInfo; | |
| 21 | +import com.bsth.entity.HInfo; | |
| 22 | +import com.bsth.entity.OilInfo; | |
| 23 | +import com.bsth.entity.ScheduleRealInfo; | |
| 24 | +import com.bsth.redis.ElecRedisService; | |
| 25 | +import com.bsth.redis.HRedisService; | |
| 26 | +import com.bsth.redis.OilRedisService; | |
| 27 | +import com.bsth.redis.ScheduleRedisService; | |
| 28 | +import com.bsth.repository.DutyEmployeeRepository; | |
| 29 | +import com.bsth.server_ws.util.WSDataConver; | |
| 30 | +import com.bsth.server_ws.waybill.entity.NH_waybill; | |
| 31 | +import com.bsth.server_ws.waybill.entity.SN_lossMileage; | |
| 32 | +import com.bsth.server_ws.waybill.entity.SN_waybill; | |
| 33 | +import com.bsth.service.UserService; | |
| 34 | +import com.google.common.collect.ArrayListMultimap; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * Created by panzhao on 2017/3/17. | |
| 38 | + */ | |
| 39 | +@Component | |
| 40 | +@WebService( | |
| 41 | + name = "LD_ServiceSoap", | |
| 42 | + portName = "LD_ServiceSoap", | |
| 43 | + serviceName = "LD_Service", | |
| 44 | + targetNamespace = "http://control.bsth.com/", | |
| 45 | + endpointInterface = "com.bsth.server_ws.waybill.LD_Service") | |
| 46 | +public class LD_ServiceSoap implements LD_Service, ApplicationContextAware { | |
| 47 | + | |
| 48 | + static OilRedisService oilRedisService; | |
| 49 | + static ElecRedisService elecRedisService; | |
| 50 | + static HRedisService hRedisService; | |
| 51 | + static ScheduleRedisService scheduleRedisService; | |
| 52 | + static DutyEmployeeRepository dutyEmployeeRepository; | |
| 53 | + | |
| 54 | + static UserService userService; | |
| 55 | + | |
| 56 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 57 | + | |
| 58 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"), | |
| 59 | + fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 60 | + | |
| 61 | + @Override | |
| 62 | + public boolean waybill_NH(String password, String rq, String companyId, Holder<NH_waybill[]> result, Holder<String> fError) { | |
| 63 | + try { | |
| 64 | + if(userService.get(password) == null){ | |
| 65 | + fError.value = "无效的密码!"; | |
| 66 | + return false; | |
| 67 | + } | |
| 68 | + //日期减一天,老接口是这样的 | |
| 69 | + //rq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 70 | + String prveRq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 71 | + | |
| 72 | + //实际排班 | |
| 73 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(prveRq, companyId); | |
| 74 | + //油耗信息 | |
| 75 | + ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 76 | + //电耗信息 | |
| 77 | + ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 78 | + //氢耗信息 | |
| 79 | + ArrayListMultimap<String, HInfo> hInfoMap = hRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 80 | + //当班调派 | |
| 81 | + long st = fmtyyyyMMddHHmm.parseMillis(prveRq + "00:00"), et = fmtyyyyMMddHHmm.parseMillis(prveRq + "23:59"); | |
| 82 | + List<DutyEmployee> des = dutyEmployeeRepository.findByTime(st, et); | |
| 83 | + //转换成南汇路单需要的格式 | |
| 84 | + NH_waybill[] array = WSDataConver.to_waybill_NH(listMap, oilInfoMap, elecInfoMap, hInfoMap, des); | |
| 85 | + result.value = array; | |
| 86 | + | |
| 87 | + //不再代理老接口数据 | |
| 88 | + /*if(companyId.equals("26") && !WebServiceProxy.isAllNew(companyId)){ | |
| 89 | + ClsLDInfo[] oldArray = OldWSClient.getNH_LD(companyId, rq); | |
| 90 | + //合并新老系统的数据 | |
| 91 | + result.value = WebServiceProxy.mergerData(result.value, oldArray, companyId); | |
| 92 | + }*/ | |
| 93 | + } catch (Exception e) { | |
| 94 | + logger.error("", e); | |
| 95 | + fError.value = "服务器出现异常!"; | |
| 96 | + return false; | |
| 97 | + } | |
| 98 | + return true; | |
| 99 | + } | |
| 100 | + | |
| 101 | + @Override | |
| 102 | + public boolean waybill_NH4TH(String password, String rq, String companyId, Holder<NH_waybill[]> result, Holder<String> fError) { | |
| 103 | + try { | |
| 104 | + if(userService.get(password) == null){ | |
| 105 | + fError.value = "无效的密码!"; | |
| 106 | + return false; | |
| 107 | + } | |
| 108 | + //日期减一天,老接口是这样的 | |
| 109 | + //rq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 110 | + String prveRq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | |
| 111 | + | |
| 112 | + //实际排班 | |
| 113 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(prveRq, companyId); | |
| 114 | + //油耗信息 | |
| 115 | + ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 116 | + //电耗信息 | |
| 117 | + ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | |
| 118 | + //当班调派 | |
| 119 | + long st = fmtyyyyMMddHHmm.parseMillis(prveRq + "00:00"), et = fmtyyyyMMddHHmm.parseMillis(prveRq + "23:59"); | |
| 120 | + List<DutyEmployee> des = dutyEmployeeRepository.findByTime(st, et); | |
| 121 | + //转换成南汇路单需要的格式 | |
| 122 | + NH_waybill[] array = WSDataConver.to_waybill_NH4TH(listMap, oilInfoMap, elecInfoMap, des); | |
| 123 | + result.value = array; | |
| 124 | + | |
| 125 | + //不再代理老接口数据 | |
| 126 | + /*if(companyId.equals("26") && !WebServiceProxy.isAllNew(companyId)){ | |
| 127 | + ClsLDInfo[] oldArray = OldWSClient.getNH_LD(companyId, rq); | |
| 128 | + //合并新老系统的数据 | |
| 129 | + result.value = WebServiceProxy.mergerData(result.value, oldArray, companyId); | |
| 130 | + }*/ | |
| 131 | + } catch (Exception e) { | |
| 132 | + logger.error("", e); | |
| 133 | + fError.value = "服务器出现异常!"; | |
| 134 | + return false; | |
| 135 | + } | |
| 136 | + return true; | |
| 137 | + } | |
| 138 | + | |
| 139 | + @Override | |
| 140 | + public boolean waybill_SN(String password, String rq, String companyId, Holder<SN_waybill[]> result, Holder<String> fError) { | |
| 141 | + try { | |
| 142 | + if(userService.get(password) == null){ | |
| 143 | + fError.value = "无效的密码!"; | |
| 144 | + return false; | |
| 145 | + } | |
| 146 | + | |
| 147 | + //实际排班 | |
| 148 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(rq, companyId); | |
| 149 | + //油耗信息 | |
| 150 | + Map<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroupRaw(listMap.keySet(), rq); | |
| 151 | + //转换成上南路单需要的格式 | |
| 152 | + SN_waybill[] array = WSDataConver.to_waybill_SN(listMap, oilInfoMap); | |
| 153 | + result.value = array; | |
| 154 | + } catch (Exception e) { | |
| 155 | + logger.error("", e); | |
| 156 | + fError.value = "服务器出现异常!"; | |
| 157 | + return false; | |
| 158 | + } | |
| 159 | + return true; | |
| 160 | + } | |
| 161 | + | |
| 162 | + @Override | |
| 163 | + public boolean lossMileage(String password, String rq, String companyId, Holder<SN_lossMileage[]> result, Holder<String> fError) { | |
| 164 | + try { | |
| 165 | + if(userService.get(password) == null){ | |
| 166 | + fError.value = "无效的密码!"; | |
| 167 | + return false; | |
| 168 | + } | |
| 169 | + | |
| 170 | + //按线路分组的实际排班 | |
| 171 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByLine(rq, companyId); | |
| 172 | + //转换成上南需要的损失公里数据 | |
| 173 | + SN_lossMileage[] array = WSDataConver.to_lossMileage_SN(listMap); | |
| 174 | + result.value = array; | |
| 175 | + } catch (Exception e) { | |
| 176 | + logger.error("", e); | |
| 177 | + fError.value = "服务器出现异常!"; | |
| 178 | + return false; | |
| 179 | + } | |
| 180 | + return false; | |
| 181 | + } | |
| 182 | + | |
| 183 | + | |
| 184 | + @Override | |
| 185 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
| 186 | + oilRedisService = applicationContext.getBean(OilRedisService.class); | |
| 187 | + elecRedisService = applicationContext.getBean(ElecRedisService.class); | |
| 188 | + hRedisService = applicationContext.getBean(HRedisService.class); | |
| 189 | + scheduleRedisService = applicationContext.getBean(ScheduleRedisService.class); | |
| 190 | + dutyEmployeeRepository = applicationContext.getBean(DutyEmployeeRepository.class); | |
| 191 | + userService = applicationContext.getBean(UserService.class); | |
| 192 | + } | |
| 193 | +} | ... | ... |