Commit c2d036f441362c65cb6cbd89c6414dcabdd3febe
1 parent
e37c6917
南汇路单接口 新开接口加入电量数据
Showing
10 changed files
with
965 additions
and
431 deletions
src/main/java/com/bsth/entity/ElecInfo.java
0 → 100644
| 1 | +package com.bsth.entity; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 5 | + | ||
| 6 | +import javax.persistence.Entity; | ||
| 7 | +import javax.persistence.Id; | ||
| 8 | +import javax.persistence.Table; | ||
| 9 | +import java.io.Serializable; | ||
| 10 | +import java.util.Date; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 电量信息表 | ||
| 14 | + */ | ||
| 15 | +@Entity | ||
| 16 | +@Table(name = "bsth_c_dlb") | ||
| 17 | +public class ElecInfo implements Serializable { | ||
| 18 | + @Id | ||
| 19 | + private Integer id; | ||
| 20 | + /** | ||
| 21 | + * 日期 | ||
| 22 | + */ | ||
| 23 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | ||
| 24 | + private Date rq; | ||
| 25 | + /** | ||
| 26 | + * 内部编码 | ||
| 27 | + */ | ||
| 28 | + private String nbbm; | ||
| 29 | + /** | ||
| 30 | + * 驾驶员 | ||
| 31 | + */ | ||
| 32 | + private String jsy; | ||
| 33 | + /** | ||
| 34 | + * 充电量 | ||
| 35 | + */ | ||
| 36 | + private Double cdl; | ||
| 37 | + /** | ||
| 38 | + * 耗电 | ||
| 39 | + */ | ||
| 40 | + private Double hd; | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public int hashCode() { | ||
| 44 | + return this.toString().hashCode(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public boolean equals(Object obj) { | ||
| 49 | + return this.toString().equals(((ElecInfo)obj).toString()); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Override | ||
| 53 | + public String toString() { | ||
| 54 | + return "oil_" + this.id; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public Integer getId() { | ||
| 58 | + return id; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public void setId(Integer id) { | ||
| 62 | + this.id = id; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public Date getRq() { | ||
| 66 | + return rq; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public void setRq(Date rq) { | ||
| 70 | + this.rq = rq; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public String getNbbm() { | ||
| 74 | + return nbbm; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public void setNbbm(String nbbm) { | ||
| 78 | + this.nbbm = nbbm; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public String getJsy() { | ||
| 82 | + return jsy; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void setJsy(String jsy) { | ||
| 86 | + this.jsy = jsy; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public Double getCdl() { | ||
| 90 | + return cdl; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void setCdl(Double cdl) { | ||
| 94 | + this.cdl = cdl; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public Double getHd() { | ||
| 98 | + return hd; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void setHd(Double hd) { | ||
| 102 | + this.hd = hd; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | +} |
src/main/java/com/bsth/redis/ElecRedisService.java
0 → 100644
| 1 | +package com.bsth.redis; | ||
| 2 | + | ||
| 3 | +import com.bsth.Application; | ||
| 4 | +import com.bsth.entity.ElecInfo; | ||
| 5 | +import com.bsth.redis.util.RedisUtils; | ||
| 6 | +import com.bsth.repository.ElecInfoRepository; | ||
| 7 | +import com.bsth.util.ConfigUtil; | ||
| 8 | +import com.bsth.util.ConvertUtil; | ||
| 9 | +import com.google.common.collect.ArrayListMultimap; | ||
| 10 | +import org.joda.time.DateTime; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.boot.CommandLineRunner; | ||
| 15 | +import org.springframework.core.annotation.Order; | ||
| 16 | +import org.springframework.data.redis.core.RedisTemplate; | ||
| 17 | +import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
| 18 | +import org.springframework.stereotype.Component; | ||
| 19 | +import org.springframework.stereotype.Service; | ||
| 20 | + | ||
| 21 | +import java.util.*; | ||
| 22 | +import java.util.concurrent.TimeUnit; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * 油量数据Redis缓存 | ||
| 26 | + * Created by panzhao on 2017/3/19. | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Order(3) | ||
| 30 | +public class ElecRedisService implements CommandLineRunner { | ||
| 31 | + | ||
| 32 | + @Autowired | ||
| 33 | + private RedisTemplate redisTemplate; | ||
| 34 | + | ||
| 35 | + @Autowired | ||
| 36 | + ElecInfoRepository elecInfoRepository; | ||
| 37 | + | ||
| 38 | + @Autowired | ||
| 39 | + RedisUtils redisUtils; | ||
| 40 | + | ||
| 41 | + static Logger logger = LoggerFactory.getLogger(ElecRedisService.class); | ||
| 42 | + | ||
| 43 | + private final static String REDIS_KEY_PREFIX = "elec:"; | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 将油量数据写入redis | ||
| 47 | + * | ||
| 48 | + * @param list | ||
| 49 | + */ | ||
| 50 | + public void wirte(List<ElecInfo> list) { | ||
| 51 | + ArrayListMultimap<String, ElecInfo> multimap; | ||
| 52 | + try { | ||
| 53 | + if (list.size() == 0) | ||
| 54 | + return; | ||
| 55 | + //按日期和线路分组数据 | ||
| 56 | + Class clazz = ElecInfo.class; | ||
| 57 | + multimap = new ConvertUtil().groupMultiList(list, ":", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("rq")); | ||
| 58 | + | ||
| 59 | + //写入redis | ||
| 60 | + Iterator<String> iterator = multimap.keySet().iterator(); | ||
| 61 | + String key; | ||
| 62 | + while (iterator.hasNext()) { | ||
| 63 | + key = iterator.next(); | ||
| 64 | + mergeData(key, multimap.get(key)); | ||
| 65 | + } | ||
| 66 | + } catch (Exception e) { | ||
| 67 | + logger.error("", e); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * 根据车辆和日期获取油耗数据,以 车辆_驾驶员 为key | ||
| 73 | + * | ||
| 74 | + * @param nbbmArray | ||
| 75 | + * @param rq | ||
| 76 | + * @return | ||
| 77 | + */ | ||
| 78 | + public Map<String, ElecInfo> findByNbbmGroup(Iterable<String> nbbmArray, String rq) { | ||
| 79 | + Map<String, ElecInfo> rs = new HashMap<>(); | ||
| 80 | + | ||
| 81 | + rq = rq.replaceAll("-", ""); | ||
| 82 | + try { | ||
| 83 | + List<ElecInfo> list = new ArrayList<>(); | ||
| 84 | + for (String nbbm : nbbmArray) { | ||
| 85 | + nbbm = nbbm.split("_")[1]; | ||
| 86 | + list.addAll(read(nbbm, rq)); | ||
| 87 | + } | ||
| 88 | + Class clazz = ElecInfo.class; | ||
| 89 | + rs = new ConvertUtil().groupList(list, "_", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("jsy")); | ||
| 90 | + } catch (Exception e) { | ||
| 91 | + logger.error("", e); | ||
| 92 | + } | ||
| 93 | + return rs; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public List<ElecInfo> read(String nbbm, String rq) { | ||
| 97 | + return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + nbbm + ":" + rq, 0, -1); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * 将 list 与redis里的数据合并 | ||
| 102 | + * | ||
| 103 | + * @param key | ||
| 104 | + * @param list | ||
| 105 | + */ | ||
| 106 | + public void mergeData(String key, List<ElecInfo> list) { | ||
| 107 | + key = REDIS_KEY_PREFIX + key; | ||
| 108 | + | ||
| 109 | + //更新 直接覆盖更新 | ||
| 110 | + redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @Autowired | ||
| 114 | + ElecRefreshThread elecRefreshThread; | ||
| 115 | + | ||
| 116 | + @Override | ||
| 117 | + public void run(String... strings) throws Exception { | ||
| 118 | + Application.mainServices.schedule(new Runnable() { | ||
| 119 | + @Override | ||
| 120 | + public void run() { | ||
| 121 | + //启动加载油耗缓存 | ||
| 122 | + synchData(null); | ||
| 123 | + } | ||
| 124 | + }, 30, TimeUnit.SECONDS); | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + //定时刷新油耗信息 | ||
| 128 | + Application.mainServices.scheduleWithFixedDelay(elecRefreshThread, 60 * 40, 60 * 40, TimeUnit.SECONDS); | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + /** | ||
| 132 | + * 和数据库同步数据 | ||
| 133 | + */ | ||
| 134 | + public void synchData(Integer days) { | ||
| 135 | + int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | ||
| 136 | + if (null != days && days < cacheDays) | ||
| 137 | + cacheDays = days; | ||
| 138 | + //设置key 序列化器 | ||
| 139 | + redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
| 140 | + | ||
| 141 | + DateTime dt = new DateTime(); | ||
| 142 | + dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays); | ||
| 143 | + List<ElecInfo> list = elecInfoRepository.findByDateLT(dt.toDate()); | ||
| 144 | + //写入redis | ||
| 145 | + wirte(list); | ||
| 146 | + logger.info("刷新电耗数据, days: " + cacheDays + " -size: " + list.size() + " -LT: " + dt.toString("yyyy-MM-dd")); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + @Component | ||
| 150 | + public static class ElecRefreshThread extends Thread { | ||
| 151 | + | ||
| 152 | + @Autowired | ||
| 153 | + ElecRedisService elecRedisService; | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public void run() { | ||
| 157 | + try { | ||
| 158 | + elecRedisService.synchData(5); | ||
| 159 | + } catch (Exception e) { | ||
| 160 | + logger.error("", e); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | +} |
src/main/java/com/bsth/repository/ElecInfoRepository.java
0 → 100644
| 1 | +package com.bsth.repository; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.ElecInfo; | ||
| 4 | +import org.springframework.data.jpa.repository.Query; | ||
| 5 | +import org.springframework.data.repository.PagingAndSortingRepository; | ||
| 6 | +import org.springframework.stereotype.Repository; | ||
| 7 | + | ||
| 8 | +import java.util.Date; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Created by panzhao on 2017/3/19. | ||
| 13 | + */ | ||
| 14 | +@Repository | ||
| 15 | +public interface ElecInfoRepository extends PagingAndSortingRepository<ElecInfo, Long> { | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + @Query("select elec from ElecInfo elec where elec.rq>?1") | ||
| 19 | + List<ElecInfo> findByDateLT(Date rq); | ||
| 20 | +} |
src/main/java/com/bsth/server_rs/schedule/real/thread/ExecSchDataRefreshThread.java
| 1 | -package com.bsth.server_rs.schedule.real.thread; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | -import com.alibaba.fastjson.JSONObject; | ||
| 5 | -import com.bsth.server_rs.schedule.real.SchRealDataBuffer; | ||
| 6 | -import com.bsth.util.ConfigUtil; | ||
| 7 | -import com.bsth.util.HttpClientUtils; | ||
| 8 | -import org.slf4j.Logger; | ||
| 9 | -import org.slf4j.LoggerFactory; | ||
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | -import org.springframework.stereotype.Component; | ||
| 12 | - | ||
| 13 | -import java.util.HashMap; | ||
| 14 | -import java.util.List; | ||
| 15 | -import java.util.Map; | ||
| 16 | - | ||
| 17 | -/** | ||
| 18 | - * 车辆当前执行班次数据刷新线程 | ||
| 19 | - * Created by panzhao on 2017/11/9. | ||
| 20 | - */ | ||
| 21 | -@Component | ||
| 22 | -public class ExecSchDataRefreshThread extends Thread{ | ||
| 23 | - | ||
| 24 | - static String url; | ||
| 25 | - static String secretKey; | ||
| 26 | - | ||
| 27 | - @Autowired | ||
| 28 | - SchRealDataBuffer schRealDataBuffer; | ||
| 29 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 30 | - | ||
| 31 | - static { | ||
| 32 | - secretKey = ConfigUtil.get("http.control.secret.key"); | ||
| 33 | - url = ConfigUtil.get("http.control.service_data_url") + "/execSchList?secretKey=" + secretKey; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - @Override | ||
| 37 | - public void run() { | ||
| 38 | - try { | ||
| 39 | - StringBuilder sb = HttpClientUtils.get(url); | ||
| 40 | - List<JSONObject> list = JSON.parseArray(sb.toString(), JSONObject.class); | ||
| 41 | - | ||
| 42 | - Map<String, JSONObject> map = new HashMap<>(); | ||
| 43 | - for(JSONObject obj : list){ | ||
| 44 | - map.put(obj.getString("clZbh"), obj); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - if(map.size() > 0) | ||
| 48 | - schRealDataBuffer.setExecMap(map); | ||
| 49 | - } catch (Exception e) { | ||
| 50 | - logger.error("", e); | ||
| 51 | - } | ||
| 52 | - } | ||
| 53 | -} | 1 | +package com.bsth.server_rs.schedule.real.thread; |
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | +import com.bsth.server_rs.schedule.real.SchRealDataBuffer; | ||
| 6 | +import com.bsth.util.ConfigUtil; | ||
| 7 | +import com.bsth.util.HttpClientUtils; | ||
| 8 | +import org.slf4j.Logger; | ||
| 9 | +import org.slf4j.LoggerFactory; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.stereotype.Component; | ||
| 12 | + | ||
| 13 | +import java.util.HashMap; | ||
| 14 | +import java.util.List; | ||
| 15 | +import java.util.Map; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 车辆当前执行班次数据刷新线程 | ||
| 19 | + * Created by panzhao on 2017/11/9. | ||
| 20 | + */ | ||
| 21 | +@Component | ||
| 22 | +public class ExecSchDataRefreshThread extends Thread{ | ||
| 23 | + | ||
| 24 | + static String url; | ||
| 25 | + static String secretKey; | ||
| 26 | + | ||
| 27 | + @Autowired | ||
| 28 | + SchRealDataBuffer schRealDataBuffer; | ||
| 29 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 30 | + | ||
| 31 | + static { | ||
| 32 | + secretKey = ConfigUtil.get("http.control.secret.key"); | ||
| 33 | + url = ConfigUtil.get("http.control.service_data_url") + "/execSchList?secretKey=" + secretKey; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public void run() { | ||
| 38 | + try { | ||
| 39 | + StringBuilder sb = HttpClientUtils.get(url); | ||
| 40 | + List<JSONObject> list = JSON.parseArray(sb.toString(), JSONObject.class); | ||
| 41 | + | ||
| 42 | + Map<String, JSONObject> map = new HashMap<>(); | ||
| 43 | + for(JSONObject obj : list){ | ||
| 44 | + map.put(obj.getString("clZbh"), obj); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + if(map.size() > 0) | ||
| 48 | + schRealDataBuffer.setExecMap(map); | ||
| 49 | + } catch (Exception e) { | ||
| 50 | + logger.error("", e); | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | +} |
src/main/java/com/bsth/server_ws/util/WSDataConver.java
| 1 | package com.bsth.server_ws.util; | 1 | package com.bsth.server_ws.util; |
| 2 | 2 | ||
| 3 | +import java.lang.reflect.Field; | ||
| 4 | +import java.text.ParseException; | ||
| 5 | +import java.text.SimpleDateFormat; | ||
| 6 | +import java.util.ArrayList; | ||
| 7 | +import java.util.Calendar; | ||
| 8 | +import java.util.Collections; | ||
| 9 | +import java.util.Comparator; | ||
| 10 | +import java.util.Date; | ||
| 11 | +import java.util.HashMap; | ||
| 12 | +import java.util.List; | ||
| 13 | +import java.util.Map; | ||
| 14 | +import java.util.Set; | ||
| 15 | + | ||
| 16 | +import org.apache.commons.lang3.StringUtils; | ||
| 17 | +import org.slf4j.Logger; | ||
| 18 | +import org.slf4j.LoggerFactory; | ||
| 19 | + | ||
| 3 | import com.bsth.entity.DutyEmployee; | 20 | import com.bsth.entity.DutyEmployee; |
| 21 | +import com.bsth.entity.ElecInfo; | ||
| 4 | import com.bsth.entity.OilInfo; | 22 | import com.bsth.entity.OilInfo; |
| 5 | import com.bsth.entity.SchedulePlanInfo; | 23 | import com.bsth.entity.SchedulePlanInfo; |
| 6 | import com.bsth.entity.ScheduleRealInfo; | 24 | import com.bsth.entity.ScheduleRealInfo; |
| 7 | import com.bsth.server_ws.attendance.entity.Jsy_attendance; | 25 | import com.bsth.server_ws.attendance.entity.Jsy_attendance; |
| 8 | import com.bsth.server_ws.park_station.dto.LsLcPb; | 26 | import com.bsth.server_ws.park_station.dto.LsLcPb; |
| 9 | -import com.bsth.server_ws.waybill.entity.*; | 27 | +import com.bsth.server_ws.waybill.entity.NH_waybill; |
| 28 | +import com.bsth.server_ws.waybill.entity.NH_waybillItem; | ||
| 29 | +import com.bsth.server_ws.waybill.entity.SN_lossMileage; | ||
| 30 | +import com.bsth.server_ws.waybill.entity.SN_waybill; | ||
| 31 | +import com.bsth.server_ws.waybill.entity.SN_waybillItem; | ||
| 10 | import com.bsth.util.Arith; | 32 | import com.bsth.util.Arith; |
| 11 | import com.bsth.util.ConvertUtil; | 33 | import com.bsth.util.ConvertUtil; |
| 12 | import com.google.common.collect.ArrayListMultimap; | 34 | import com.google.common.collect.ArrayListMultimap; |
| 13 | -import org.apache.commons.lang3.StringUtils; | ||
| 14 | -import org.slf4j.Logger; | ||
| 15 | -import org.slf4j.LoggerFactory; | ||
| 16 | - | ||
| 17 | -import java.lang.reflect.Field; | ||
| 18 | -import java.text.ParseException; | ||
| 19 | -import java.text.SimpleDateFormat; | ||
| 20 | -import java.util.*; | ||
| 21 | 35 | ||
| 22 | /** | 36 | /** |
| 23 | * Created by panzhao on 2017/3/15. | 37 | * Created by panzhao on 2017/3/15. |
| @@ -226,7 +240,13 @@ public class WSDataConver { | @@ -226,7 +240,13 @@ public class WSDataConver { | ||
| 226 | //驾驶员工号 | 240 | //驾驶员工号 |
| 227 | nh_waybillItem.setM_strJSY(list.get(0).getjGh()); | 241 | nh_waybillItem.setM_strJSY(list.get(0).getjGh()); |
| 228 | //售票员工号 | 242 | //售票员工号 |
| 229 | - nh_waybillItem.setM_strSPY(nvlGetVal(list.get(0).getsGh())); | 243 | + nh_waybillItem.setM_strSPY(""); |
| 244 | + for (ScheduleRealInfo sri : list) { | ||
| 245 | + if (StringUtils.isNotEmpty(sri.getsGh())) { | ||
| 246 | + nh_waybillItem.setM_strSPY(sri.getsGh()); | ||
| 247 | + break; | ||
| 248 | + } | ||
| 249 | + } | ||
| 230 | //驾驶员考勤 | 250 | //驾驶员考勤 |
| 231 | nh_waybillItem.setM_strJSYKQ(""); | 251 | nh_waybillItem.setM_strJSYKQ(""); |
| 232 | //售票员考勤 | 252 | //售票员考勤 |
| @@ -273,6 +293,170 @@ public class WSDataConver { | @@ -273,6 +293,170 @@ public class WSDataConver { | ||
| 273 | } | 293 | } |
| 274 | return rs; | 294 | return rs; |
| 275 | } | 295 | } |
| 296 | + | ||
| 297 | + /** | ||
| 298 | + * 将实际排班、油耗数据、电量数据 转换成南汇路单需要的数据格式 | ||
| 299 | + * | ||
| 300 | + * @param listMap | ||
| 301 | + * @param oilInfoMap | ||
| 302 | + * @return | ||
| 303 | + */ | ||
| 304 | + public static NH_waybill[] to_waybill_NH4TH(ArrayListMultimap<String, ScheduleRealInfo> listMap, Map<String, OilInfo> oilInfoMap, Map<String, ElecInfo> elecInfoMap, List<DutyEmployee> des) throws NoSuchFieldException { | ||
| 305 | + List<String> nbbmArray = new ArrayList<>(listMap.keySet()); | ||
| 306 | + | ||
| 307 | + NH_waybill[] rs = new NH_waybill[nbbmArray.size()]; | ||
| 308 | + Field jGhField = ScheduleRealInfo.class.getDeclaredField("jGh"); | ||
| 309 | + //Field lpField = ScheduleRealInfo.class.getDeclaredField("lpName"); | ||
| 310 | + | ||
| 311 | + List<ScheduleRealInfo> list; | ||
| 312 | + ArrayListMultimap<String, ScheduleRealInfo> jGhListMap; | ||
| 313 | + ScheduleRealInfo sch; | ||
| 314 | + NH_waybill nh_waybill; | ||
| 315 | + NH_waybillItem nh_waybillItem; | ||
| 316 | + OilInfo oilInfo; | ||
| 317 | + ElecInfo elecInfo; | ||
| 318 | + for (int i = 0; i < nbbmArray.size(); i++) { | ||
| 319 | + list = listMap.get(nbbmArray.get(i)); | ||
| 320 | + if (list.size() == 0) | ||
| 321 | + continue; | ||
| 322 | + //班次信息 | ||
| 323 | + nh_waybill = new NH_waybill(); | ||
| 324 | + sch = list.get(0); | ||
| 325 | + //日期 | ||
| 326 | + nh_waybill.setM_strYYRQ(sch.getScheduleDateStr()); | ||
| 327 | + //车辆自编号 | ||
| 328 | + nh_waybill.setM_strNBBM(sch.getClZbh()); | ||
| 329 | + //线路编码 | ||
| 330 | + nh_waybill.setM_strXLBM(sch.getXlBm()); | ||
| 331 | + nh_waybill.setM_SubInfos(new ArrayList<NH_waybillItem>()); | ||
| 332 | + | ||
| 333 | + //按 驾驶员 分组班次,构造路单子项 | ||
| 334 | + jGhListMap = new ConvertUtil<ScheduleRealInfo>().groupMultiList(list, "_", jGhField); | ||
| 335 | + for (String jGh : jGhListMap.keySet()) { | ||
| 336 | + list = jGhListMap.get(jGh); | ||
| 337 | + nh_waybillItem = new NH_waybillItem(); | ||
| 338 | + //计划里程 | ||
| 339 | + nh_waybillItem.setM_dblJHLC(ScheduleCalculator.calcJHLC(list)); | ||
| 340 | + //实际计划公里 | ||
| 341 | + nh_waybillItem.setM_dblSJJHLC(ScheduleCalculator.calcSJLC(list)); | ||
| 342 | + //实际出场里程 | ||
| 343 | + nh_waybillItem.setM_dblCCLC(ScheduleCalculator.calcCCLC(list)); | ||
| 344 | + //实际进场里程 | ||
| 345 | + nh_waybillItem.setM_dblJCLC(ScheduleCalculator.calcJCLC(list)); | ||
| 346 | + //营业公里 | ||
| 347 | + nh_waybillItem.setM_dblYYLC(ScheduleCalculator.calcYYLC(list)); | ||
| 348 | + //空驶公里 | ||
| 349 | + nh_waybillItem.setM_dblKSLC(ScheduleCalculator.calcKSLC(list)); | ||
| 350 | + //抽减公里 | ||
| 351 | + nh_waybillItem.setM_dblCJLC(ScheduleCalculator.calcCJLC(list)); | ||
| 352 | + //烂班公里 | ||
| 353 | + nh_waybillItem.setM_dblLBLC(ScheduleCalculator.calcLBLC(list)); | ||
| 354 | + //增加公里 | ||
| 355 | + nh_waybillItem.setM_dblZJLC(ScheduleCalculator.calcZJLC(list)); | ||
| 356 | + //总公里 | ||
| 357 | + nh_waybillItem.setM_dblZLC(ScheduleCalculator.calcZLC(list)); | ||
| 358 | + //烂班公里原因 | ||
| 359 | + nh_waybillItem.setM_strLBYY(ScheduleCalculator.joinLBYY(list)); | ||
| 360 | + //抽减公里原因 | ||
| 361 | + nh_waybillItem.setM_strCJYY(ScheduleCalculator.joinCJYY(list)); | ||
| 362 | + //计划班次 | ||
| 363 | + nh_waybillItem.setM_intJHBC(ScheduleCalculator.countJHBC(list)); | ||
| 364 | + //实际计划班次 | ||
| 365 | + nh_waybillItem.setM_intSJJHBC(ScheduleCalculator.countSJJHBC(list)); | ||
| 366 | + //实际班次 ————> 暂时和实际计划班次相同 | ||
| 367 | + nh_waybillItem.setM_intSJBC(ScheduleCalculator.countSJJHBC(list)); | ||
| 368 | + //增加班次 | ||
| 369 | + nh_waybillItem.setM_intZJBC(ScheduleCalculator.countZJBC(list)); | ||
| 370 | + //抽减班次 | ||
| 371 | + nh_waybillItem.setM_intCJBC(ScheduleCalculator.countCJBC(list)); | ||
| 372 | + //烂班工时 | ||
| 373 | + nh_waybillItem.setM_dblLBGS(ScheduleCalculator.calcLBGS(list)); | ||
| 374 | + //路牌 | ||
| 375 | + nh_waybillItem.setM_strLP(list.get(0).getLpName()); | ||
| 376 | + //驾驶员工号 | ||
| 377 | + nh_waybillItem.setM_strJSY(list.get(0).getjGh()); | ||
| 378 | + //售票员工号 | ||
| 379 | + nh_waybillItem.setM_strSPY(""); | ||
| 380 | + for (ScheduleRealInfo sri : list) { | ||
| 381 | + if (StringUtils.isNotEmpty(sri.getsGh())) { | ||
| 382 | + nh_waybillItem.setM_strSPY(sri.getsGh()); | ||
| 383 | + break; | ||
| 384 | + } | ||
| 385 | + } | ||
| 386 | + //驾驶员考勤 | ||
| 387 | + nh_waybillItem.setM_strJSYKQ(""); | ||
| 388 | + //售票员考勤 | ||
| 389 | + nh_waybillItem.setM_strSPYKQ(""); | ||
| 390 | + //当班调度员 | ||
| 391 | + nh_waybillItem.setM_strDDY(ScheduleCalculator.calcDDY(list, des)); | ||
| 392 | + //营运状态 | ||
| 393 | + nh_waybillItem.setM_strYYZT(""); | ||
| 394 | + //备注 | ||
| 395 | + nh_waybillItem.setM_strBZ(""); | ||
| 396 | + | ||
| 397 | + oilInfo = oilInfoMap.get(list.get(0).getClZbh() + "_" + list.get(0).getjGh()); | ||
| 398 | + if (oilInfo != null) { | ||
| 399 | + //出场存油 | ||
| 400 | + nh_waybillItem.setM_dblCCCY(oilInfo.getCzyl()); | ||
| 401 | + //进场存油 | ||
| 402 | + nh_waybillItem.setM_dblJCCY(oilInfo.getJzyl()); | ||
| 403 | + //加注量1 | ||
| 404 | + nh_waybillItem.setM_dblJZL1(oilInfo.getJzl()); | ||
| 405 | + //加注量2 | ||
| 406 | + nh_waybillItem.setM_dblJZL2(0.0); | ||
| 407 | + //尿素 | ||
| 408 | + nh_waybillItem.setM_dblNS(oilInfo.getNs()); | ||
| 409 | + //消耗量 | ||
| 410 | + nh_waybillItem.setM_dblYH(oilInfo.getYh()); | ||
| 411 | + //加油地点1 | ||
| 412 | + nh_waybillItem.setM_strJYD1(""); | ||
| 413 | + //加油地点2 | ||
| 414 | + nh_waybillItem.setM_strJYD2(""); | ||
| 415 | + //加油工工号1 | ||
| 416 | + nh_waybillItem.setM_strJYG1(""); | ||
| 417 | + //加油工工号1 | ||
| 418 | + nh_waybillItem.setM_strJYG2(""); | ||
| 419 | + //油耗类型1 | ||
| 420 | + nh_waybillItem.setM_strYHLX1(oilInfo.getRylx()); | ||
| 421 | + //油耗类型2 | ||
| 422 | + nh_waybillItem.setM_strYHLX1(""); | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + elecInfo = elecInfoMap.get(list.get(0).getClZbh() + "_" + list.get(0).getjGh()); | ||
| 426 | + if (elecInfo != null) { | ||
| 427 | + //出场存油 | ||
| 428 | + nh_waybillItem.setM_dblCCCY(100.0); | ||
| 429 | + //进场存油 | ||
| 430 | + nh_waybillItem.setM_dblJCCY(100.0); | ||
| 431 | + //加注量1 | ||
| 432 | + nh_waybillItem.setM_dblJZL1(elecInfo.getCdl()); | ||
| 433 | + //加注量2 | ||
| 434 | + nh_waybillItem.setM_dblJZL2(0.0); | ||
| 435 | + //尿素 | ||
| 436 | + nh_waybillItem.setM_dblNS(0.0); | ||
| 437 | + //消耗量 | ||
| 438 | + nh_waybillItem.setM_dblYH(elecInfo.getHd()); | ||
| 439 | + //加油地点1 | ||
| 440 | + nh_waybillItem.setM_strJYD1(""); | ||
| 441 | + //加油地点2 | ||
| 442 | + nh_waybillItem.setM_strJYD2(""); | ||
| 443 | + //加油工工号1 | ||
| 444 | + nh_waybillItem.setM_strJYG1(""); | ||
| 445 | + //加油工工号1 | ||
| 446 | + nh_waybillItem.setM_strJYG2(""); | ||
| 447 | + //油耗类型1 | ||
| 448 | + nh_waybillItem.setM_strYHLX1(""); | ||
| 449 | + //油耗类型2 | ||
| 450 | + nh_waybillItem.setM_strYHLX1(""); | ||
| 451 | + } | ||
| 452 | + | ||
| 453 | + nh_waybill.getM_SubInfos().add(nh_waybillItem); | ||
| 454 | + } | ||
| 455 | + | ||
| 456 | + rs[i] = nh_waybill; | ||
| 457 | + } | ||
| 458 | + return rs; | ||
| 459 | + } | ||
| 276 | 460 | ||
| 277 | 461 | ||
| 278 | /** | 462 | /** |
src/main/java/com/bsth/server_ws/waybill/LD_Service.java
| 1 | -package com.bsth.server_ws.waybill; | ||
| 2 | - | ||
| 3 | -import com.bsth.server_ws.waybill.entity.NH_waybill; | ||
| 4 | -import com.bsth.server_ws.waybill.entity.SN_lossMileage; | ||
| 5 | -import com.bsth.server_ws.waybill.entity.SN_waybill; | ||
| 6 | - | ||
| 7 | -import javax.jws.WebMethod; | ||
| 8 | -import javax.jws.WebParam; | ||
| 9 | -import javax.jws.WebService; | ||
| 10 | -import javax.xml.ws.Holder; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 路单接口 | ||
| 14 | - * Created by panzhao on 2017/3/17. | ||
| 15 | - */ | ||
| 16 | -@WebService( | ||
| 17 | - name = "LD_ServiceSoap", | ||
| 18 | - targetNamespace = "http://control.bsth.com/") | ||
| 19 | -public interface LD_Service { | ||
| 20 | - | ||
| 21 | - /*** | ||
| 22 | - * 路单接口(原南汇格式) | ||
| 23 | - * @param password 密码 | ||
| 24 | - * @param rq 日期 | ||
| 25 | - * @param companyId 公司编码 | ||
| 26 | - * @param result | ||
| 27 | - * @param fError | ||
| 28 | - * @return | ||
| 29 | - */ | ||
| 30 | - @WebMethod | ||
| 31 | - boolean waybill_NH( | ||
| 32 | - @WebParam(name = "password") String password, | ||
| 33 | - @WebParam(name = "rq") String rq, | ||
| 34 | - @WebParam(name = "companyId") String companyId, | ||
| 35 | - @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<NH_waybill[]> result, | ||
| 36 | - @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError); | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * 路单接口(上南格式) | ||
| 40 | - * | ||
| 41 | - * @param password 密码 | ||
| 42 | - * @param rq 日期 | ||
| 43 | - * @param companyId 公司编码 | ||
| 44 | - * @return | ||
| 45 | - */ | ||
| 46 | - boolean waybill_SN( | ||
| 47 | - @WebParam(name = "password") String password, | ||
| 48 | - @WebParam(name = "rq") String rq, | ||
| 49 | - @WebParam(name = "companyId") String companyId, | ||
| 50 | - @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<SN_waybill[]> result, | ||
| 51 | - @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError); | ||
| 52 | - | ||
| 53 | - /** | ||
| 54 | - * 损失公里(上南格式) | ||
| 55 | - * @param password | ||
| 56 | - * @param rq | ||
| 57 | - * @param companyId | ||
| 58 | - * @param result | ||
| 59 | - * @param fError | ||
| 60 | - * @return | ||
| 61 | - */ | ||
| 62 | - boolean lossMileage( | ||
| 63 | - @WebParam(name = "password") String password, | ||
| 64 | - @WebParam(name = "rq") String rq, | ||
| 65 | - @WebParam(name = "companyId") String companyId, | ||
| 66 | - @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<SN_lossMileage[]> result, | ||
| 67 | - @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError); | ||
| 68 | -} | 1 | +package com.bsth.server_ws.waybill; |
| 2 | + | ||
| 3 | +import com.bsth.server_ws.waybill.entity.NH_waybill; | ||
| 4 | +import com.bsth.server_ws.waybill.entity.SN_lossMileage; | ||
| 5 | +import com.bsth.server_ws.waybill.entity.SN_waybill; | ||
| 6 | + | ||
| 7 | +import javax.jws.WebMethod; | ||
| 8 | +import javax.jws.WebParam; | ||
| 9 | +import javax.jws.WebService; | ||
| 10 | +import javax.xml.ws.Holder; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 路单接口 | ||
| 14 | + * Created by panzhao on 2017/3/17. | ||
| 15 | + */ | ||
| 16 | +@WebService( | ||
| 17 | + name = "LD_ServiceSoap", | ||
| 18 | + targetNamespace = "http://control.bsth.com/") | ||
| 19 | +public interface LD_Service { | ||
| 20 | + | ||
| 21 | + /*** | ||
| 22 | + * 路单接口(原南汇格式) | ||
| 23 | + * @param password 密码 | ||
| 24 | + * @param rq 日期 | ||
| 25 | + * @param companyId 公司编码 | ||
| 26 | + * @param result | ||
| 27 | + * @param fError | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + @WebMethod | ||
| 31 | + boolean waybill_NH( | ||
| 32 | + @WebParam(name = "password") String password, | ||
| 33 | + @WebParam(name = "rq") String rq, | ||
| 34 | + @WebParam(name = "companyId") String companyId, | ||
| 35 | + @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<NH_waybill[]> result, | ||
| 36 | + @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError); | ||
| 37 | + | ||
| 38 | + /*** | ||
| 39 | + * 路单接口(原南汇格式 公司内部用) | ||
| 40 | + * @param password 密码 | ||
| 41 | + * @param rq 日期 | ||
| 42 | + * @param companyId 公司编码 | ||
| 43 | + * @param result | ||
| 44 | + * @param fError | ||
| 45 | + * @return | ||
| 46 | + */ | ||
| 47 | + @WebMethod | ||
| 48 | + boolean waybill_NH4TH( | ||
| 49 | + @WebParam(name = "password") String password, | ||
| 50 | + @WebParam(name = "rq") String rq, | ||
| 51 | + @WebParam(name = "companyId") String companyId, | ||
| 52 | + @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<NH_waybill[]> result, | ||
| 53 | + @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError); | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 路单接口(上南格式) | ||
| 57 | + * | ||
| 58 | + * @param password 密码 | ||
| 59 | + * @param rq 日期 | ||
| 60 | + * @param companyId 公司编码 | ||
| 61 | + * @return | ||
| 62 | + */ | ||
| 63 | + boolean waybill_SN( | ||
| 64 | + @WebParam(name = "password") String password, | ||
| 65 | + @WebParam(name = "rq") String rq, | ||
| 66 | + @WebParam(name = "companyId") String companyId, | ||
| 67 | + @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<SN_waybill[]> result, | ||
| 68 | + @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError); | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 损失公里(上南格式) | ||
| 72 | + * @param password | ||
| 73 | + * @param rq | ||
| 74 | + * @param companyId | ||
| 75 | + * @param result | ||
| 76 | + * @param fError | ||
| 77 | + * @return | ||
| 78 | + */ | ||
| 79 | + boolean lossMileage( | ||
| 80 | + @WebParam(name = "password") String password, | ||
| 81 | + @WebParam(name = "rq") String rq, | ||
| 82 | + @WebParam(name = "companyId") String companyId, | ||
| 83 | + @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<SN_lossMileage[]> result, | ||
| 84 | + @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError); | ||
| 85 | +} |
src/main/java/com/bsth/server_ws/waybill/LD_ServiceSoap.java
| 1 | -package com.bsth.server_ws.waybill; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.DutyEmployee; | ||
| 4 | -import com.bsth.entity.OilInfo; | ||
| 5 | -import com.bsth.entity.ScheduleRealInfo; | ||
| 6 | -import com.bsth.redis.OilRedisService; | ||
| 7 | -import com.bsth.redis.ScheduleRedisService; | ||
| 8 | -import com.bsth.repository.DutyEmployeeRepository; | ||
| 9 | -import com.bsth.server_ws.util.WSDataConver; | ||
| 10 | -import com.bsth.server_ws.waybill.entity.NH_waybill; | ||
| 11 | -import com.bsth.server_ws.waybill.entity.SN_lossMileage; | ||
| 12 | -import com.bsth.server_ws.waybill.entity.SN_waybill; | ||
| 13 | -import com.bsth.service.UserService; | ||
| 14 | -import com.google.common.collect.ArrayListMultimap; | ||
| 15 | -import org.joda.time.format.DateTimeFormat; | ||
| 16 | -import org.joda.time.format.DateTimeFormatter; | ||
| 17 | -import org.slf4j.Logger; | ||
| 18 | -import org.slf4j.LoggerFactory; | ||
| 19 | -import org.springframework.beans.BeansException; | ||
| 20 | -import org.springframework.context.ApplicationContext; | ||
| 21 | -import org.springframework.context.ApplicationContextAware; | ||
| 22 | -import org.springframework.stereotype.Component; | ||
| 23 | - | ||
| 24 | -import javax.jws.WebService; | ||
| 25 | -import javax.xml.ws.Holder; | ||
| 26 | -import java.util.List; | ||
| 27 | -import java.util.Map; | ||
| 28 | - | ||
| 29 | -/** | ||
| 30 | - * Created by panzhao on 2017/3/17. | ||
| 31 | - */ | ||
| 32 | -@Component | ||
| 33 | -@WebService( | ||
| 34 | - name = "LD_ServiceSoap", | ||
| 35 | - portName = "LD_ServiceSoap", | ||
| 36 | - serviceName = "LD_Service", | ||
| 37 | - targetNamespace = "http://control.bsth.com/", | ||
| 38 | - endpointInterface = "com.bsth.server_ws.waybill.LD_Service") | ||
| 39 | -public class LD_ServiceSoap implements LD_Service, ApplicationContextAware { | ||
| 40 | - | ||
| 41 | - static OilRedisService oilRedisService; | ||
| 42 | - static ScheduleRedisService scheduleRedisService; | ||
| 43 | - static DutyEmployeeRepository dutyEmployeeRepository; | ||
| 44 | - | ||
| 45 | - static UserService userService; | ||
| 46 | - | ||
| 47 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 48 | - | ||
| 49 | - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"), | ||
| 50 | - fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 51 | - | ||
| 52 | - @Override | ||
| 53 | - public boolean waybill_NH(String password, String rq, String companyId, Holder<NH_waybill[]> result, Holder<String> fError) { | ||
| 54 | - try { | ||
| 55 | - if(userService.get(password) == null){ | ||
| 56 | - fError.value = "无效的密码!"; | ||
| 57 | - return false; | ||
| 58 | - } | ||
| 59 | - //日期减一天,老接口是这样的 | ||
| 60 | - //rq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | ||
| 61 | - String prveRq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | ||
| 62 | - | ||
| 63 | - //实际排班 | ||
| 64 | - ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(prveRq, companyId); | ||
| 65 | - //油耗信息 | ||
| 66 | - Map<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | ||
| 67 | - //当班调派 | ||
| 68 | - long st = fmtyyyyMMddHHmm.parseMillis(prveRq + "00:00"), et = fmtyyyyMMddHHmm.parseMillis(prveRq + "23:59"); | ||
| 69 | - List<DutyEmployee> des = dutyEmployeeRepository.findByTime(st, et); | ||
| 70 | - //转换成南汇路单需要的格式 | ||
| 71 | - NH_waybill[] array = WSDataConver.to_waybill_NH(listMap, oilInfoMap, des); | ||
| 72 | - result.value = array; | ||
| 73 | - | ||
| 74 | - //不再代理老接口数据 | ||
| 75 | - /*if(companyId.equals("26") && !WebServiceProxy.isAllNew(companyId)){ | ||
| 76 | - ClsLDInfo[] oldArray = OldWSClient.getNH_LD(companyId, rq); | ||
| 77 | - //合并新老系统的数据 | ||
| 78 | - result.value = WebServiceProxy.mergerData(result.value, oldArray, companyId); | ||
| 79 | - }*/ | ||
| 80 | - } catch (Exception e) { | ||
| 81 | - logger.error("", e); | ||
| 82 | - fError.value = "服务器出现异常!"; | ||
| 83 | - return false; | ||
| 84 | - } | ||
| 85 | - return true; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - @Override | ||
| 89 | - public boolean waybill_SN(String password, String rq, String companyId, Holder<SN_waybill[]> result, Holder<String> fError) { | ||
| 90 | - try { | ||
| 91 | - if(userService.get(password) == null){ | ||
| 92 | - fError.value = "无效的密码!"; | ||
| 93 | - return false; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - //实际排班 | ||
| 97 | - ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(rq, companyId); | ||
| 98 | - //油耗信息 | ||
| 99 | - Map<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), rq); | ||
| 100 | - //转换成上南路单需要的格式 | ||
| 101 | - SN_waybill[] array = WSDataConver.to_waybill_SN(listMap, oilInfoMap); | ||
| 102 | - result.value = array; | ||
| 103 | - } catch (Exception e) { | ||
| 104 | - logger.error("", e); | ||
| 105 | - fError.value = "服务器出现异常!"; | ||
| 106 | - return false; | ||
| 107 | - } | ||
| 108 | - return true; | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - @Override | ||
| 112 | - public boolean lossMileage(String password, String rq, String companyId, Holder<SN_lossMileage[]> result, Holder<String> fError) { | ||
| 113 | - try { | ||
| 114 | - if(userService.get(password) == null){ | ||
| 115 | - fError.value = "无效的密码!"; | ||
| 116 | - return false; | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - //按线路分组的实际排班 | ||
| 120 | - ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByLine(rq, companyId); | ||
| 121 | - //转换成上南需要的损失公里数据 | ||
| 122 | - SN_lossMileage[] array = WSDataConver.to_lossMileage_SN(listMap); | ||
| 123 | - result.value = array; | ||
| 124 | - } catch (Exception e) { | ||
| 125 | - logger.error("", e); | ||
| 126 | - fError.value = "服务器出现异常!"; | ||
| 127 | - return false; | ||
| 128 | - } | ||
| 129 | - return false; | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - | ||
| 133 | - @Override | ||
| 134 | - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
| 135 | - oilRedisService = applicationContext.getBean(OilRedisService.class); | ||
| 136 | - scheduleRedisService = applicationContext.getBean(ScheduleRedisService.class); | ||
| 137 | - dutyEmployeeRepository = applicationContext.getBean(DutyEmployeeRepository.class); | ||
| 138 | - userService = applicationContext.getBean(UserService.class); | ||
| 139 | - } | ||
| 140 | -} | 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 org.joda.time.format.DateTimeFormat; | ||
| 10 | +import org.joda.time.format.DateTimeFormatter; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | +import org.springframework.beans.BeansException; | ||
| 14 | +import org.springframework.context.ApplicationContext; | ||
| 15 | +import org.springframework.context.ApplicationContextAware; | ||
| 16 | +import org.springframework.stereotype.Component; | ||
| 17 | + | ||
| 18 | +import com.bsth.entity.DutyEmployee; | ||
| 19 | +import com.bsth.entity.ElecInfo; | ||
| 20 | +import com.bsth.entity.OilInfo; | ||
| 21 | +import com.bsth.entity.ScheduleRealInfo; | ||
| 22 | +import com.bsth.redis.ElecRedisService; | ||
| 23 | +import com.bsth.redis.OilRedisService; | ||
| 24 | +import com.bsth.redis.ScheduleRedisService; | ||
| 25 | +import com.bsth.repository.DutyEmployeeRepository; | ||
| 26 | +import com.bsth.server_ws.util.WSDataConver; | ||
| 27 | +import com.bsth.server_ws.waybill.entity.NH_waybill; | ||
| 28 | +import com.bsth.server_ws.waybill.entity.SN_lossMileage; | ||
| 29 | +import com.bsth.server_ws.waybill.entity.SN_waybill; | ||
| 30 | +import com.bsth.service.UserService; | ||
| 31 | +import com.google.common.collect.ArrayListMultimap; | ||
| 32 | + | ||
| 33 | +/** | ||
| 34 | + * Created by panzhao on 2017/3/17. | ||
| 35 | + */ | ||
| 36 | +@Component | ||
| 37 | +@WebService( | ||
| 38 | + name = "LD_ServiceSoap", | ||
| 39 | + portName = "LD_ServiceSoap", | ||
| 40 | + serviceName = "LD_Service", | ||
| 41 | + targetNamespace = "http://control.bsth.com/", | ||
| 42 | + endpointInterface = "com.bsth.server_ws.waybill.LD_Service") | ||
| 43 | +public class LD_ServiceSoap implements LD_Service, ApplicationContextAware { | ||
| 44 | + | ||
| 45 | + static OilRedisService oilRedisService; | ||
| 46 | + static ElecRedisService elecRedisService; | ||
| 47 | + static ScheduleRedisService scheduleRedisService; | ||
| 48 | + static DutyEmployeeRepository dutyEmployeeRepository; | ||
| 49 | + | ||
| 50 | + static UserService userService; | ||
| 51 | + | ||
| 52 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 53 | + | ||
| 54 | + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"), | ||
| 55 | + fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public boolean waybill_NH(String password, String rq, String companyId, Holder<NH_waybill[]> result, Holder<String> fError) { | ||
| 59 | + try { | ||
| 60 | + if(userService.get(password) == null){ | ||
| 61 | + fError.value = "无效的密码!"; | ||
| 62 | + return false; | ||
| 63 | + } | ||
| 64 | + //日期减一天,老接口是这样的 | ||
| 65 | + //rq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | ||
| 66 | + String prveRq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | ||
| 67 | + | ||
| 68 | + //实际排班 | ||
| 69 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(prveRq, companyId); | ||
| 70 | + //油耗信息 | ||
| 71 | + Map<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | ||
| 72 | + //当班调派 | ||
| 73 | + long st = fmtyyyyMMddHHmm.parseMillis(prveRq + "00:00"), et = fmtyyyyMMddHHmm.parseMillis(prveRq + "23:59"); | ||
| 74 | + List<DutyEmployee> des = dutyEmployeeRepository.findByTime(st, et); | ||
| 75 | + //转换成南汇路单需要的格式 | ||
| 76 | + NH_waybill[] array = WSDataConver.to_waybill_NH(listMap, oilInfoMap, des); | ||
| 77 | + result.value = array; | ||
| 78 | + | ||
| 79 | + //不再代理老接口数据 | ||
| 80 | + /*if(companyId.equals("26") && !WebServiceProxy.isAllNew(companyId)){ | ||
| 81 | + ClsLDInfo[] oldArray = OldWSClient.getNH_LD(companyId, rq); | ||
| 82 | + //合并新老系统的数据 | ||
| 83 | + result.value = WebServiceProxy.mergerData(result.value, oldArray, companyId); | ||
| 84 | + }*/ | ||
| 85 | + } catch (Exception e) { | ||
| 86 | + logger.error("", e); | ||
| 87 | + fError.value = "服务器出现异常!"; | ||
| 88 | + return false; | ||
| 89 | + } | ||
| 90 | + return true; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + @Override | ||
| 94 | + public boolean waybill_NH4TH(String password, String rq, String companyId, Holder<NH_waybill[]> result, Holder<String> fError) { | ||
| 95 | + try { | ||
| 96 | + if(userService.get(password) == null){ | ||
| 97 | + fError.value = "无效的密码!"; | ||
| 98 | + return false; | ||
| 99 | + } | ||
| 100 | + //日期减一天,老接口是这样的 | ||
| 101 | + //rq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | ||
| 102 | + String prveRq = fmtyyyyMMdd.print(fmtyyyyMMdd.parseDateTime(rq).minusDays(1)); | ||
| 103 | + | ||
| 104 | + //实际排班 | ||
| 105 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(prveRq, companyId); | ||
| 106 | + //油耗信息 | ||
| 107 | + Map<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | ||
| 108 | + //电耗信息 | ||
| 109 | + Map<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup(listMap.keySet(), prveRq); | ||
| 110 | + //当班调派 | ||
| 111 | + long st = fmtyyyyMMddHHmm.parseMillis(prveRq + "00:00"), et = fmtyyyyMMddHHmm.parseMillis(prveRq + "23:59"); | ||
| 112 | + List<DutyEmployee> des = dutyEmployeeRepository.findByTime(st, et); | ||
| 113 | + //转换成南汇路单需要的格式 | ||
| 114 | + NH_waybill[] array = WSDataConver.to_waybill_NH4TH(listMap, oilInfoMap, elecInfoMap, des); | ||
| 115 | + result.value = array; | ||
| 116 | + | ||
| 117 | + //不再代理老接口数据 | ||
| 118 | + /*if(companyId.equals("26") && !WebServiceProxy.isAllNew(companyId)){ | ||
| 119 | + ClsLDInfo[] oldArray = OldWSClient.getNH_LD(companyId, rq); | ||
| 120 | + //合并新老系统的数据 | ||
| 121 | + result.value = WebServiceProxy.mergerData(result.value, oldArray, companyId); | ||
| 122 | + }*/ | ||
| 123 | + } catch (Exception e) { | ||
| 124 | + logger.error("", e); | ||
| 125 | + fError.value = "服务器出现异常!"; | ||
| 126 | + return false; | ||
| 127 | + } | ||
| 128 | + return true; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + @Override | ||
| 132 | + public boolean waybill_SN(String password, String rq, String companyId, Holder<SN_waybill[]> result, Holder<String> fError) { | ||
| 133 | + try { | ||
| 134 | + if(userService.get(password) == null){ | ||
| 135 | + fError.value = "无效的密码!"; | ||
| 136 | + return false; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + //实际排班 | ||
| 140 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByNbbm(rq, companyId); | ||
| 141 | + //油耗信息 | ||
| 142 | + Map<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup(listMap.keySet(), rq); | ||
| 143 | + //转换成上南路单需要的格式 | ||
| 144 | + SN_waybill[] array = WSDataConver.to_waybill_SN(listMap, oilInfoMap); | ||
| 145 | + result.value = array; | ||
| 146 | + } catch (Exception e) { | ||
| 147 | + logger.error("", e); | ||
| 148 | + fError.value = "服务器出现异常!"; | ||
| 149 | + return false; | ||
| 150 | + } | ||
| 151 | + return true; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + @Override | ||
| 155 | + public boolean lossMileage(String password, String rq, String companyId, Holder<SN_lossMileage[]> result, Holder<String> fError) { | ||
| 156 | + try { | ||
| 157 | + if(userService.get(password) == null){ | ||
| 158 | + fError.value = "无效的密码!"; | ||
| 159 | + return false; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + //按线路分组的实际排班 | ||
| 163 | + ArrayListMultimap<String, ScheduleRealInfo> listMap = scheduleRedisService.findByDateAndGroupByLine(rq, companyId); | ||
| 164 | + //转换成上南需要的损失公里数据 | ||
| 165 | + SN_lossMileage[] array = WSDataConver.to_lossMileage_SN(listMap); | ||
| 166 | + result.value = array; | ||
| 167 | + } catch (Exception e) { | ||
| 168 | + logger.error("", e); | ||
| 169 | + fError.value = "服务器出现异常!"; | ||
| 170 | + return false; | ||
| 171 | + } | ||
| 172 | + return false; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + | ||
| 176 | + @Override | ||
| 177 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
| 178 | + oilRedisService = applicationContext.getBean(OilRedisService.class); | ||
| 179 | + elecRedisService = applicationContext.getBean(ElecRedisService.class); | ||
| 180 | + scheduleRedisService = applicationContext.getBean(ScheduleRedisService.class); | ||
| 181 | + dutyEmployeeRepository = applicationContext.getBean(DutyEmployeeRepository.class); | ||
| 182 | + userService = applicationContext.getBean(UserService.class); | ||
| 183 | + } | ||
| 184 | +} |
src/main/java/com/bsth/util/HttpClientUtils.java
| 1 | -package com.bsth.util; | ||
| 2 | - | ||
| 3 | -import org.apache.http.HttpEntity; | ||
| 4 | -import org.apache.http.client.config.RequestConfig; | ||
| 5 | -import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 6 | -import org.apache.http.client.methods.HttpGet; | ||
| 7 | -import org.apache.http.client.methods.HttpPost; | ||
| 8 | -import org.apache.http.entity.StringEntity; | ||
| 9 | -import org.apache.http.impl.client.CloseableHttpClient; | ||
| 10 | -import org.apache.http.impl.client.HttpClients; | ||
| 11 | -import org.slf4j.Logger; | ||
| 12 | -import org.slf4j.LoggerFactory; | ||
| 13 | - | ||
| 14 | -import java.io.BufferedReader; | ||
| 15 | -import java.io.IOException; | ||
| 16 | -import java.io.InputStreamReader; | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * Created by panzhao on 2017/8/2. | ||
| 20 | - */ | ||
| 21 | -public class HttpClientUtils { | ||
| 22 | - | ||
| 23 | - static Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); | ||
| 24 | - | ||
| 25 | - public static StringBuilder get(String url) throws Exception { | ||
| 26 | - CloseableHttpClient httpClient = null; | ||
| 27 | - CloseableHttpResponse response = null; | ||
| 28 | - StringBuilder stringBuffer = null; | ||
| 29 | - try { | ||
| 30 | - httpClient = HttpClients.createDefault(); | ||
| 31 | - HttpGet get = new HttpGet(url); | ||
| 32 | - //超时时间 | ||
| 33 | - RequestConfig requestConfig = RequestConfig.custom() | ||
| 34 | - .setConnectTimeout(6500).setConnectionRequestTimeout(6000) | ||
| 35 | - .setSocketTimeout(6500).build(); | ||
| 36 | - get.setConfig(requestConfig); | ||
| 37 | - get.addHeader("Content-Encoding", "gzip"); | ||
| 38 | - | ||
| 39 | - response = httpClient.execute(get); | ||
| 40 | - | ||
| 41 | - int statusCode = response.getStatusLine().getStatusCode(); | ||
| 42 | - if(statusCode != 200){ | ||
| 43 | - get.abort(); | ||
| 44 | - System.out.println("http client status code: " + statusCode); | ||
| 45 | - return null; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - stringBuffer = getResult(response.getEntity()); | ||
| 49 | - } catch (Exception e) { | ||
| 50 | - logger.error("", e); | ||
| 51 | - } finally { | ||
| 52 | - if (null != httpClient) | ||
| 53 | - httpClient.close(); | ||
| 54 | - if (null != response) | ||
| 55 | - response.close(); | ||
| 56 | - } | ||
| 57 | - return stringBuffer; | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * raw post data | ||
| 62 | - * @param url | ||
| 63 | - * @param data | ||
| 64 | - * @return | ||
| 65 | - */ | ||
| 66 | - public static StringBuilder post(String url, String data) throws Exception { | ||
| 67 | - CloseableHttpClient httpClient = null; | ||
| 68 | - CloseableHttpResponse response = null; | ||
| 69 | - StringBuilder stringBuffer = null; | ||
| 70 | - try { | ||
| 71 | - httpClient = HttpClients.createDefault(); | ||
| 72 | - HttpPost post = new HttpPost(url); | ||
| 73 | - | ||
| 74 | - post.setHeader("Accept", "application/json"); | ||
| 75 | - post.setHeader("Content-Type", "application/json"); | ||
| 76 | - //超时时间 | ||
| 77 | - RequestConfig requestConfig = RequestConfig.custom() | ||
| 78 | - .setConnectTimeout(3500).setConnectionRequestTimeout(2000) | ||
| 79 | - .setSocketTimeout(3500).build(); | ||
| 80 | - post.setConfig(requestConfig); | ||
| 81 | - post.setEntity((new StringEntity(data, "UTF-8"))); | ||
| 82 | - | ||
| 83 | - response = httpClient.execute(post); | ||
| 84 | - | ||
| 85 | - int statusCode = response.getStatusLine().getStatusCode(); | ||
| 86 | - if(statusCode != 200){ | ||
| 87 | - post.abort(); | ||
| 88 | - System.out.println("http client status code: " + statusCode); | ||
| 89 | - return null; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - stringBuffer = getResult(response.getEntity()); | ||
| 93 | - } catch (Exception e) { | ||
| 94 | - logger.error("", e); | ||
| 95 | - } finally { | ||
| 96 | - if (null != httpClient) | ||
| 97 | - httpClient.close(); | ||
| 98 | - if (null != response) | ||
| 99 | - response.close(); | ||
| 100 | - } | ||
| 101 | - return stringBuffer; | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - private static StringBuilder getResult(HttpEntity entity) throws IOException { | ||
| 105 | - StringBuilder stringBuffer = null; | ||
| 106 | - if (null != entity) { | ||
| 107 | - BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); | ||
| 108 | - stringBuffer = new StringBuilder(); | ||
| 109 | - String str = ""; | ||
| 110 | - while ((str = br.readLine()) != null) | ||
| 111 | - stringBuffer.append(str); | ||
| 112 | - } | ||
| 113 | - return stringBuffer; | ||
| 114 | - } | ||
| 115 | -} | 1 | +package com.bsth.util; |
| 2 | + | ||
| 3 | +import org.apache.http.HttpEntity; | ||
| 4 | +import org.apache.http.client.config.RequestConfig; | ||
| 5 | +import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 6 | +import org.apache.http.client.methods.HttpGet; | ||
| 7 | +import org.apache.http.client.methods.HttpPost; | ||
| 8 | +import org.apache.http.entity.StringEntity; | ||
| 9 | +import org.apache.http.impl.client.CloseableHttpClient; | ||
| 10 | +import org.apache.http.impl.client.HttpClients; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | + | ||
| 14 | +import java.io.BufferedReader; | ||
| 15 | +import java.io.IOException; | ||
| 16 | +import java.io.InputStreamReader; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Created by panzhao on 2017/8/2. | ||
| 20 | + */ | ||
| 21 | +public class HttpClientUtils { | ||
| 22 | + | ||
| 23 | + static Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); | ||
| 24 | + | ||
| 25 | + public static StringBuilder get(String url) throws Exception { | ||
| 26 | + CloseableHttpClient httpClient = null; | ||
| 27 | + CloseableHttpResponse response = null; | ||
| 28 | + StringBuilder stringBuffer = null; | ||
| 29 | + try { | ||
| 30 | + httpClient = HttpClients.createDefault(); | ||
| 31 | + HttpGet get = new HttpGet(url); | ||
| 32 | + //超时时间 | ||
| 33 | + RequestConfig requestConfig = RequestConfig.custom() | ||
| 34 | + .setConnectTimeout(6500).setConnectionRequestTimeout(6000) | ||
| 35 | + .setSocketTimeout(6500).build(); | ||
| 36 | + get.setConfig(requestConfig); | ||
| 37 | + get.addHeader("Content-Encoding", "gzip"); | ||
| 38 | + | ||
| 39 | + response = httpClient.execute(get); | ||
| 40 | + | ||
| 41 | + int statusCode = response.getStatusLine().getStatusCode(); | ||
| 42 | + if(statusCode != 200){ | ||
| 43 | + get.abort(); | ||
| 44 | + System.out.println("http client status code: " + statusCode); | ||
| 45 | + return null; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + stringBuffer = getResult(response.getEntity()); | ||
| 49 | + } catch (Exception e) { | ||
| 50 | + logger.error("", e); | ||
| 51 | + } finally { | ||
| 52 | + if (null != httpClient) | ||
| 53 | + httpClient.close(); | ||
| 54 | + if (null != response) | ||
| 55 | + response.close(); | ||
| 56 | + } | ||
| 57 | + return stringBuffer; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * raw post data | ||
| 62 | + * @param url | ||
| 63 | + * @param data | ||
| 64 | + * @return | ||
| 65 | + */ | ||
| 66 | + public static StringBuilder post(String url, String data) throws Exception { | ||
| 67 | + CloseableHttpClient httpClient = null; | ||
| 68 | + CloseableHttpResponse response = null; | ||
| 69 | + StringBuilder stringBuffer = null; | ||
| 70 | + try { | ||
| 71 | + httpClient = HttpClients.createDefault(); | ||
| 72 | + HttpPost post = new HttpPost(url); | ||
| 73 | + | ||
| 74 | + post.setHeader("Accept", "application/json"); | ||
| 75 | + post.setHeader("Content-Type", "application/json"); | ||
| 76 | + //超时时间 | ||
| 77 | + RequestConfig requestConfig = RequestConfig.custom() | ||
| 78 | + .setConnectTimeout(3500).setConnectionRequestTimeout(2000) | ||
| 79 | + .setSocketTimeout(3500).build(); | ||
| 80 | + post.setConfig(requestConfig); | ||
| 81 | + post.setEntity((new StringEntity(data, "UTF-8"))); | ||
| 82 | + | ||
| 83 | + response = httpClient.execute(post); | ||
| 84 | + | ||
| 85 | + int statusCode = response.getStatusLine().getStatusCode(); | ||
| 86 | + if(statusCode != 200){ | ||
| 87 | + post.abort(); | ||
| 88 | + System.out.println("http client status code: " + statusCode); | ||
| 89 | + return null; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + stringBuffer = getResult(response.getEntity()); | ||
| 93 | + } catch (Exception e) { | ||
| 94 | + logger.error("", e); | ||
| 95 | + } finally { | ||
| 96 | + if (null != httpClient) | ||
| 97 | + httpClient.close(); | ||
| 98 | + if (null != response) | ||
| 99 | + response.close(); | ||
| 100 | + } | ||
| 101 | + return stringBuffer; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + private static StringBuilder getResult(HttpEntity entity) throws IOException { | ||
| 105 | + StringBuilder stringBuffer = null; | ||
| 106 | + if (null != entity) { | ||
| 107 | + BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); | ||
| 108 | + stringBuffer = new StringBuilder(); | ||
| 109 | + String str = ""; | ||
| 110 | + while ((str = br.readLine()) != null) | ||
| 111 | + stringBuffer.append(str); | ||
| 112 | + } | ||
| 113 | + return stringBuffer; | ||
| 114 | + } | ||
| 115 | +} |
src/main/resources/application.properties
| @@ -15,4 +15,4 @@ server.compression.enabled=true | @@ -15,4 +15,4 @@ server.compression.enabled=true | ||
| 15 | server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript | 15 | server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript |
| 16 | 16 | ||
| 17 | #redis | 17 | #redis |
| 18 | -cache.days=30 | 18 | +cache.days=15 |
src/main/resources/logback.xml
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | -<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd"> --> | ||
| 3 | -<configuration> | ||
| 4 | - | ||
| 5 | - <!-- <property resource="application.properties" /> --> | ||
| 6 | - <property name="LOG_BASE" value="E:/control_interface_logs" /> | ||
| 7 | - <!-- 控制台输出 --> | ||
| 8 | - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
| 9 | - | ||
| 10 | - <layout class="ch.qos.logback.classic.PatternLayout"> | ||
| 11 | - <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | ||
| 12 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n | ||
| 13 | - </pattern> | ||
| 14 | - </layout> | ||
| 15 | - </appender> | ||
| 16 | - | ||
| 17 | - <!-- 主日志文件 --> | ||
| 18 | - <appender name="FILE" | ||
| 19 | - class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
| 20 | - <file>${LOG_BASE}/main/main.log</file> | ||
| 21 | - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
| 22 | - <fileNamePattern>${LOG_BASE}/main/main-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
| 23 | - <timeBasedFileNamingAndTriggeringPolicy | ||
| 24 | - class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
| 25 | - <maxFileSize>100MB</maxFileSize> | ||
| 26 | - </timeBasedFileNamingAndTriggeringPolicy> | ||
| 27 | - </rollingPolicy> | ||
| 28 | - <encoder> | ||
| 29 | - <pattern>%msg%n</pattern> | ||
| 30 | - </encoder> | ||
| 31 | - | ||
| 32 | - <layout class="ch.qos.logback.classic.PatternLayout"> | ||
| 33 | - <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | ||
| 34 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n | ||
| 35 | - </pattern> | ||
| 36 | - </layout> | ||
| 37 | - </appender> | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - <!-- 日志输出级别 --> | ||
| 41 | - <root level="info"> | ||
| 42 | - <appender-ref ref="STDOUT" /> | ||
| 43 | - <appender-ref ref="FILE" /> | ||
| 44 | - </root> | 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd"> --> | ||
| 3 | +<configuration> | ||
| 4 | + | ||
| 5 | + <!-- <property resource="application.properties" /> --> | ||
| 6 | + <property name="LOG_BASE" value="E:/control_interface_logs" /> | ||
| 7 | + <!-- 控制台输出 --> | ||
| 8 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
| 9 | + | ||
| 10 | + <layout class="ch.qos.logback.classic.PatternLayout"> | ||
| 11 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | ||
| 12 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n | ||
| 13 | + </pattern> | ||
| 14 | + </layout> | ||
| 15 | + </appender> | ||
| 16 | + | ||
| 17 | + <!-- 主日志文件 --> | ||
| 18 | + <appender name="FILE" | ||
| 19 | + class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
| 20 | + <file>${LOG_BASE}/main/main.log</file> | ||
| 21 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
| 22 | + <fileNamePattern>${LOG_BASE}/main/main-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
| 23 | + <timeBasedFileNamingAndTriggeringPolicy | ||
| 24 | + class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
| 25 | + <maxFileSize>100MB</maxFileSize> | ||
| 26 | + </timeBasedFileNamingAndTriggeringPolicy> | ||
| 27 | + </rollingPolicy> | ||
| 28 | + <encoder> | ||
| 29 | + <pattern>%msg%n</pattern> | ||
| 30 | + </encoder> | ||
| 31 | + | ||
| 32 | + <layout class="ch.qos.logback.classic.PatternLayout"> | ||
| 33 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | ||
| 34 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] %-5level-%msg%n | ||
| 35 | + </pattern> | ||
| 36 | + </layout> | ||
| 37 | + </appender> | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + <!-- 日志输出级别 --> | ||
| 41 | + <root level="info"> | ||
| 42 | + <appender-ref ref="STDOUT" /> | ||
| 43 | + <appender-ref ref="FILE" /> | ||
| 44 | + </root> | ||
| 45 | </configuration> | 45 | </configuration> |
| 46 | \ No newline at end of file | 46 | \ No newline at end of file |