Commit 4308447bfe8376c140863cc44adb1ceb3d7cea7b
1 parent
e5c57de6
update...
Showing
4 changed files
with
307 additions
and
0 deletions
src/main/java/com/bsth/server_ws/park_station/CompanyService.java
| ... | ... | @@ -71,4 +71,14 @@ public interface CompanyService { |
| 71 | 71 | @WebParam(name = "company") String company, |
| 72 | 72 | @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) javax.xml.ws.Holder<String[]> result, |
| 73 | 73 | @WebParam(name = "fError", mode = WebParam.Mode.INOUT) javax.xml.ws.Holder<String> fError); |
| 74 | + | |
| 75 | + boolean getLSLC_PB( | |
| 76 | + @WebParam(name = "ip") String ip, | |
| 77 | + @WebParam(name = "userName") String userName, | |
| 78 | + @WebParam(name = "password") String password, | |
| 79 | + @WebParam(name = "month") String month, | |
| 80 | + @WebParam(name = "workId") String workId, | |
| 81 | + @WebParam(name = "company") String company, | |
| 82 | + @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) javax.xml.ws.Holder<String[]> result, | |
| 83 | + @WebParam(name = "fError", mode = WebParam.Mode.INOUT) javax.xml.ws.Holder<String> fError); | |
| 74 | 84 | } | ... | ... |
src/main/java/com/bsth/server_ws/park_station/CompanyServiceSoap.java
| 1 | 1 | package com.bsth.server_ws.park_station; |
| 2 | 2 | |
| 3 | +import com.bsth.entity.OilInfo; | |
| 3 | 4 | import com.bsth.entity.ScheduleRealInfo; |
| 4 | 5 | import com.bsth.server_ws.util.Constants; |
| 5 | 6 | import com.bsth.server_ws.util.ControlHttpUtils; |
| 6 | 7 | import com.bsth.server_ws.util.WSDataConver; |
| 7 | 8 | import org.slf4j.Logger; |
| 8 | 9 | import org.slf4j.LoggerFactory; |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 12 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 9 | 13 | import org.springframework.stereotype.Component; |
| 10 | 14 | |
| 11 | 15 | import javax.jws.WebMethod; |
| ... | ... | @@ -30,6 +34,9 @@ public class CompanyServiceSoap implements CompanyService { |
| 30 | 34 | |
| 31 | 35 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 32 | 36 | |
| 37 | + @Autowired | |
| 38 | + JdbcTemplate jdbcTemplate; | |
| 39 | + | |
| 33 | 40 | @Override |
| 34 | 41 | @WebMethod |
| 35 | 42 | public boolean returnCCInfo(String password, String companyId, String rq, javax.xml.ws.Holder<String[]> result, javax.xml.ws.Holder<String> fError) { |
| ... | ... | @@ -106,4 +113,25 @@ public class CompanyServiceSoap implements CompanyService { |
| 106 | 113 | } |
| 107 | 114 | return false; |
| 108 | 115 | } |
| 116 | + | |
| 117 | + @Override | |
| 118 | + public boolean getLSLC_PB(String ip, String userName, String password, String month, String workId, String company, Holder<String[]> result, Holder<String> fError) { | |
| 119 | + try{ | |
| 120 | + //实际排班 | |
| 121 | + List<ScheduleRealInfo> schList = | |
| 122 | + jdbcTemplate.query("select * from bsth_c_s_sp_info_real where gs_bm='"+company+"' and j_gh='"+workId+"' and schedule_date_str like '"+month+"-%'", | |
| 123 | + BeanPropertyRowMapper.newInstance(ScheduleRealInfo.class)); | |
| 124 | + | |
| 125 | + //油耗 | |
| 126 | + List<OilInfo> oilList = | |
| 127 | + jdbcTemplate.query("select * from bsth_c_ylb where jsy='"+workId+"' and rq like '"+month+"-%'", | |
| 128 | + BeanPropertyRowMapper.newInstance(OilInfo.class)); | |
| 129 | + | |
| 130 | + result.value = WSDataConver.to_getLSLC_PB(month, schList, oilList); | |
| 131 | + }catch(Exception e){ | |
| 132 | + fError.value = e.getMessage(); | |
| 133 | + logger.error("", e); | |
| 134 | + } | |
| 135 | + return false; | |
| 136 | + } | |
| 109 | 137 | } | ... | ... |
src/main/java/com/bsth/server_ws/park_station/dto/LsLcPb.java
0 → 100644
| 1 | +package com.bsth.server_ws.park_station.dto; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 综合查询结果集(历时、路程、排班) | |
| 5 | + * Created by panzhao on 2018/1/17. | |
| 6 | + */ | |
| 7 | +public class LsLcPb { | |
| 8 | + | |
| 9 | + /** | |
| 10 | + * 第几天 | |
| 11 | + */ | |
| 12 | + private int day; | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 1:路程、2:排班、3:当天、4:休息 | |
| 16 | + */ | |
| 17 | + private int type; | |
| 18 | + | |
| 19 | + //##### type 为 1 时 #### | |
| 20 | + /** | |
| 21 | + * 考勤 (出勤、病假) | |
| 22 | + */ | |
| 23 | + private String lckq; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 用油 | |
| 27 | + */ | |
| 28 | + private Double lcyh; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 营运里程 | |
| 32 | + */ | |
| 33 | + private Double lcyylc; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 非营运里程 | |
| 37 | + */ | |
| 38 | + private Double lcfyylc; | |
| 39 | + | |
| 40 | + | |
| 41 | + //##### type 为 2 时 #### | |
| 42 | + /** | |
| 43 | + * 线路 | |
| 44 | + */ | |
| 45 | + private String pbxl; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 路牌 | |
| 49 | + */ | |
| 50 | + private String pblp; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 报到时间 | |
| 54 | + */ | |
| 55 | + private String pbbd; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 用车 | |
| 59 | + */ | |
| 60 | + private String pbyc; | |
| 61 | + | |
| 62 | + | |
| 63 | + public int getDay() { | |
| 64 | + return day; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void setDay(int day) { | |
| 68 | + this.day = day; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public int getType() { | |
| 72 | + return type; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void setType(int type) { | |
| 76 | + this.type = type; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public String getLckq() { | |
| 80 | + return lckq; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void setLckq(String lckq) { | |
| 84 | + this.lckq = lckq; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public Double getLcyh() { | |
| 88 | + return lcyh; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public void setLcyh(Double lcyh) { | |
| 92 | + this.lcyh = lcyh; | |
| 93 | + } | |
| 94 | + | |
| 95 | + public Double getLcyylc() { | |
| 96 | + return lcyylc; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public void setLcyylc(Double lcyylc) { | |
| 100 | + this.lcyylc = lcyylc; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public Double getLcfyylc() { | |
| 104 | + return lcfyylc; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public void setLcfyylc(Double lcfyylc) { | |
| 108 | + this.lcfyylc = lcfyylc; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public String getPbxl() { | |
| 112 | + return pbxl; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public void setPbxl(String pbxl) { | |
| 116 | + this.pbxl = pbxl; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public String getPblp() { | |
| 120 | + return pblp; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void setPblp(String pblp) { | |
| 124 | + this.pblp = pblp; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public String getPbbd() { | |
| 128 | + return pbbd; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public void setPbbd(String pbbd) { | |
| 132 | + this.pbbd = pbbd; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public String getPbyc() { | |
| 136 | + return pbyc; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public void setPbyc(String pbyc) { | |
| 140 | + this.pbyc = pbyc; | |
| 141 | + } | |
| 142 | +} | ... | ... |
src/main/java/com/bsth/server_ws/util/WSDataConver.java
| ... | ... | @@ -5,6 +5,7 @@ import com.bsth.entity.OilInfo; |
| 5 | 5 | import com.bsth.entity.SchedulePlanInfo; |
| 6 | 6 | import com.bsth.entity.ScheduleRealInfo; |
| 7 | 7 | import com.bsth.server_ws.attendance.entity.Jsy_attendance; |
| 8 | +import com.bsth.server_ws.park_station.dto.LsLcPb; | |
| 8 | 9 | import com.bsth.server_ws.waybill.entity.*; |
| 9 | 10 | import com.bsth.util.Arith; |
| 10 | 11 | import com.bsth.util.ConvertUtil; |
| ... | ... | @@ -14,6 +15,8 @@ import org.slf4j.Logger; |
| 14 | 15 | import org.slf4j.LoggerFactory; |
| 15 | 16 | |
| 16 | 17 | import java.lang.reflect.Field; |
| 18 | +import java.text.ParseException; | |
| 19 | +import java.text.SimpleDateFormat; | |
| 17 | 20 | import java.util.*; |
| 18 | 21 | |
| 19 | 22 | /** |
| ... | ... | @@ -610,6 +613,130 @@ public class WSDataConver { |
| 610 | 613 | return null; |
| 611 | 614 | } |
| 612 | 615 | |
| 616 | + /** | |
| 617 | + * 将排班和油耗转换成综合查询需要的数据 | |
| 618 | + * @param schList | |
| 619 | + * @param oilList | |
| 620 | + * @return | |
| 621 | + */ | |
| 622 | + public static String[] to_getLSLC_PB(String fdate, List<ScheduleRealInfo> schList, List<OilInfo> oilList) { | |
| 623 | + String[] array = new String[0]; | |
| 624 | + try { | |
| 625 | + //按日期分组数据 | |
| 626 | + ArrayListMultimap<String, ScheduleRealInfo> schMultimap = | |
| 627 | + new ConvertUtil().groupMultiList(schList, "_", ScheduleRealInfo.class.getDeclaredField("scheduleDateStr")); | |
| 628 | + | |
| 629 | + ArrayListMultimap<String, OilInfo> oilMultimap = | |
| 630 | + new ConvertUtil().groupMultiList(oilList, "_", OilInfo.class.getDeclaredField("rq")); | |
| 631 | + | |
| 632 | + //月份有多少天 | |
| 633 | + int year = Integer.parseInt(fdate.substring(0, 4)); | |
| 634 | + int month = Integer.parseInt(fdate.substring(5, 7)); | |
| 635 | + Calendar cal = Calendar.getInstance(); | |
| 636 | + cal.set(Calendar.YEAR,year); | |
| 637 | + cal.set(Calendar.MONTH,month - 1);//从0开始 | |
| 638 | + int maxDate = cal.getActualMaximum(Calendar.DATE); | |
| 639 | + | |
| 640 | + List<LsLcPb> rs = new ArrayList<>(); | |
| 641 | + LsLcPb lcPb; | |
| 642 | + List<ScheduleRealInfo> pbList; | |
| 643 | + List<OilInfo> yhList; | |
| 644 | + String rq,rq2; | |
| 645 | + ScheduleRealInfo outSch; | |
| 646 | + int currentDay = cal.get(Calendar.DAY_OF_MONTH); | |
| 647 | + for(int i = 1; i <= maxDate; i++){ | |
| 648 | + lcPb = new LsLcPb(); | |
| 649 | + rq = fdate + "-" + (i < 10?"0":"") + i; | |
| 650 | + rq2 = rq.replaceAll("-", ""); | |
| 651 | + | |
| 652 | + pbList = schMultimap.get(rq); | |
| 653 | + yhList = oilMultimap.get(rq2); | |
| 654 | + | |
| 655 | + if(pbList == null || pbList.size() == 0) | |
| 656 | + lcPb.setType(4);//休息 | |
| 657 | + else if(i < currentDay){ | |
| 658 | + lcPb.setType(1); | |
| 659 | + lcPb.setLckq(""); | |
| 660 | + if(yhList != null && yhList.size() > 0){ | |
| 661 | + lcPb.setLcyh(yhList.get(0).getYh()); | |
| 662 | + } | |
| 663 | + lcPb.setLcyylc(ScheduleCalculator.calcYYLC(pbList)); | |
| 664 | + lcPb.setLcfyylc(ScheduleCalculator.calcKSLC(pbList)); | |
| 665 | + } | |
| 666 | + else if (i == currentDay) | |
| 667 | + lcPb.setType(3);//今天 | |
| 668 | + else { | |
| 669 | + lcPb.setType(2); | |
| 670 | + outSch = getOutSch(pbList); | |
| 671 | + if(null != outSch){ | |
| 672 | + lcPb.setPbxl(outSch.getXlName()); | |
| 673 | + lcPb.setPblp(outSch.getLpName()); | |
| 674 | + lcPb.setPbbd(minusMinute(outSch.getDfsj(), 15)); | |
| 675 | + lcPb.setPbyc(outSch.getClZbh()); | |
| 676 | + } | |
| 677 | + } | |
| 678 | + | |
| 679 | + rs.add(lcPb); | |
| 680 | + } | |
| 681 | + | |
| 682 | + //拼接成字符串数组 | |
| 683 | + array = new String[rs.size()]; | |
| 684 | + StringBuilder sb; | |
| 685 | + for(int i = 0,len=rs.size(); i < len; i++){ | |
| 686 | + lcPb = rs.get(i); | |
| 687 | + sb = new StringBuilder(); | |
| 688 | + | |
| 689 | + sb.append(lcPb.getType()); | |
| 690 | + | |
| 691 | + switch (lcPb.getType()){ | |
| 692 | + case 1: | |
| 693 | + sb.append("," + lcPb.getLckq()); | |
| 694 | + sb.append("," + lcPb.getLcyh()); | |
| 695 | + sb.append("," + lcPb.getLcyylc()); | |
| 696 | + sb.append("," + lcPb.getLcfyylc()); | |
| 697 | + break; | |
| 698 | + case 2: | |
| 699 | + sb.append("," + lcPb.getPbxl()); | |
| 700 | + sb.append("," + lcPb.getPblp()); | |
| 701 | + sb.append("," + lcPb.getPbbd()); | |
| 702 | + sb.append("," + lcPb.getPbyc()); | |
| 703 | + break; | |
| 704 | + } | |
| 705 | + array[i] = sb.toString(); | |
| 706 | + } | |
| 707 | + } catch (NoSuchFieldException e) { | |
| 708 | + logger.error("", e); | |
| 709 | + } | |
| 710 | + return array; | |
| 711 | + } | |
| 712 | + | |
| 713 | + /** | |
| 714 | + * HH:mm 格式时间减分钟 | |
| 715 | + * @param dfsj | |
| 716 | + * @param i | |
| 717 | + * @return | |
| 718 | + */ | |
| 719 | + private static String minusMinute(String hhmm, int i) { | |
| 720 | + try { | |
| 721 | + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); | |
| 722 | + long t = sdf.parse(hhmm).getTime(); | |
| 723 | + | |
| 724 | + return sdf.format(new Date(t - (i * 60 * 1000))); | |
| 725 | + } catch (ParseException e) { | |
| 726 | + logger.error("", e); | |
| 727 | + } | |
| 728 | + return null; | |
| 729 | + } | |
| 730 | + | |
| 731 | + private static ScheduleRealInfo getOutSch(List<ScheduleRealInfo> pbList) { | |
| 732 | + | |
| 733 | + for(ScheduleRealInfo sch : pbList){ | |
| 734 | + if(sch.getBcType().equals("out")) | |
| 735 | + return sch; | |
| 736 | + } | |
| 737 | + return null; | |
| 738 | + } | |
| 739 | + | |
| 613 | 740 | public static class OilComp implements Comparator<OilInfo> { |
| 614 | 741 | |
| 615 | 742 | @Override | ... | ... |