Commit 96f554aacd1e07bb563e0038dfcc38c9c18962e5

Authored by 王通
1 parent 9c2c41d2

1.考勤接口

src/main/java/com/bsth/server_ws/attendance/AttendanceService.java
1   -package com.bsth.server_ws.attendance;
2   -
3   -import com.bsth.server_ws.attendance.entity.Jsy_attendance;
4   -
5   -import javax.jws.WebParam;
6   -import javax.jws.WebService;
7   -import javax.xml.ws.Holder;
8   -
9   -/**
10   - * 考勤相关数据接口
11   - * Created by panzhao on 2017/3/27.
12   - */
13   -@WebService(
14   - name = "AttendanceServiceSoap",
15   - targetNamespace = "http://control.bsth.com/")
16   -public interface AttendanceService {
17   -
18   - /**
19   - * 驾驶员考勤信息
20   - * @param password
21   - * @param rq
22   - * @param company 公司编码
23   - * @param result
24   - * @param fError
25   - * @return
26   - */
27   - boolean jsy_attendance(
28   - @WebParam(name = "password") String password,
29   - @WebParam(name = "rq") String rq,
30   - @WebParam(name = "company") String company,
31   - @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<Jsy_attendance[]> result,
32   - @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError);
33   -}
  1 +package com.bsth.server_ws.attendance;
  2 +
  3 +import javax.jws.WebMethod;
  4 +import javax.jws.WebParam;
  5 +import javax.jws.WebService;
  6 +import javax.xml.ws.Holder;
  7 +
  8 +import com.bsth.server_ws.attendance.entity.Ssry_attendance;
  9 +import com.bsth.server_ws.attendance.entity.Jsy_attendance;
  10 +
  11 +/**
  12 + * 考勤相关数据接口
  13 + * Created by panzhao on 2017/3/27.
  14 + */
  15 +@WebService(
  16 + name = "AttendanceServiceSoap",
  17 + targetNamespace = "http://control.bsth.com/")
  18 +public interface AttendanceService {
  19 +
  20 + /**
  21 + * 驾驶员考勤信息
  22 + * @param password
  23 + * @param rq
  24 + * @param company 公司编码
  25 + * @param result
  26 + * @param fError
  27 + * @return
  28 + */
  29 + @WebMethod
  30 + boolean jsy_attendance(
  31 + @WebParam(name = "password") String password,
  32 + @WebParam(name = "rq") String rq,
  33 + @WebParam(name = "company") String company,
  34 + @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<Jsy_attendance[]> result,
  35 + @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError);
  36 +
  37 + /**
  38 + * 考勤信息
  39 + * @param password
  40 + * @param rq
  41 + * @param company 公司编码
  42 + * @param result
  43 + * @param fError
  44 + * @return
  45 + */
  46 + @WebMethod
  47 + boolean ssry_attendance(
  48 + @WebParam(name = "password") String password,
  49 + @WebParam(name = "rq") String rq,
  50 + @WebParam(name = "company") String company,
  51 + @WebParam(name = "resultArray", mode = WebParam.Mode.INOUT) Holder<Ssry_attendance[]> result,
  52 + @WebParam(name = "fError", mode = WebParam.Mode.INOUT) Holder<String> fError);
  53 +}
... ...
src/main/java/com/bsth/server_ws/attendance/AttendanceServiceSoap.java
1   -package com.bsth.server_ws.attendance;
2   -
3   -import com.bsth.entity.SchedulePlanInfo;
4   -import com.bsth.entity.ScheduleRealInfo;
5   -import com.bsth.redis.PlanScheduleRedisService;
6   -import com.bsth.redis.ScheduleRedisService;
7   -import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
8   -import com.bsth.server_ws.attendance.entity.Jsy_attendance;
9   -import com.bsth.server_ws.util.WSDataConver;
10   -import com.bsth.service.DDYAuthorityService;
11   -import com.bsth.service.UserService;
12   -import org.slf4j.Logger;
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 javax.jws.WebService;
19   -import javax.xml.ws.Holder;
20   -import java.util.HashSet;
21   -import java.util.List;
22   -import java.util.Map;
23   -import java.util.Set;
24   -
25   -/**
26   - * Created by panzhao on 2017/3/27.
27   - */
28   -@Component
29   -@WebService(
30   - name = "AttendanceServiceSoap",
31   - portName = "AttendanceServiceSoap",
32   - serviceName = "AttendanceService",
33   - targetNamespace = "http://control.bsth.com/",
34   - endpointInterface = "com.bsth.server_ws.attendance.AttendanceService")
35   -public class AttendanceServiceSoap implements AttendanceService, ApplicationContextAware {
36   -
37   - Logger logger = org.slf4j.LoggerFactory.getLogger(this.getClass());
38   -
39   - static DDYAuthorityService ddyAuthorityService;
40   - static PlanScheduleRedisService planScheduleRedisService;
41   - static ScheduleRedisService scheduleRedisService;
42   -
43   - static UserService userService;
44   -
45   - @Override
46   - public boolean jsy_attendance(String password, String rq, String company, Holder<Jsy_attendance[]> result, Holder<String> fError) {
47   - try {
48   - if(userService.get(password) == null){
49   - fError.value = "无效的密码!";
50   - return false;
51   - }
52   -
53   - //按公司编码获取线路
54   - List<String> lineArray = LineBufferData.findCodesByCompany(company);
55   - //计划排班
56   - List<SchedulePlanInfo> plans = planScheduleRedisService.findByMultiLine(lineArray, rq);
57   - //实际排班
58   - List<ScheduleRealInfo> reals = scheduleRedisService.findByMultiLine(lineArray, rq);
59   - //从计划和实际里提取出驾驶员
60   - Set<String> jsySet = extractJsy(plans, reals);
61   - //驾驶员班型对照
62   - Map<String, String> types = ddyAuthorityService.findMultiType(jsySet);
63   -
64   - //转换成工资系统想要的数据
65   - result.value = WSDataConver.to_jsyAttendanceNH(plans, reals, jsySet, types, rq);
66   - }catch (Exception e){
67   - logger.error("", e);
68   - fError.value = "服务器出现异常!";
69   - return false;
70   - }
71   - return true;
72   - }
73   -
74   -
75   - private Set<String> extractJsy(List<SchedulePlanInfo> plans, List<ScheduleRealInfo> reals) {
76   - Set<String> rs = new HashSet<>();
77   - for (SchedulePlanInfo plan : plans) {
78   - rs.add(plan.getjGh());
79   - }
80   -
81   - for (ScheduleRealInfo sch : reals) {
82   - rs.add(sch.getjGh());
83   - }
84   - return rs;
85   - }
86   -
87   - @Override
88   - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
89   - ddyAuthorityService = applicationContext.getBean(DDYAuthorityService.class);
90   - planScheduleRedisService = applicationContext.getBean(PlanScheduleRedisService.class);
91   - scheduleRedisService = applicationContext.getBean(ScheduleRedisService.class);
92   - userService = applicationContext.getBean(UserService.class);
93   - }
94   -}
  1 +package com.bsth.server_ws.attendance;
  2 +
  3 +import com.bsth.entity.SchedulePlanInfo;
  4 +import com.bsth.entity.ScheduleRealInfo;
  5 +import com.bsth.redis.PlanScheduleRedisService;
  6 +import com.bsth.redis.ScheduleRedisService;
  7 +import com.bsth.server_rs.base_info.line.buffer.LineBufferData;
  8 +import com.bsth.server_ws.attendance.entity.Ssry_attendance;
  9 +import com.bsth.server_ws.attendance.entity.Jsy_attendance;
  10 +import com.bsth.server_ws.util.WSDataConver;
  11 +import com.bsth.service.DDYAuthorityService;
  12 +import com.bsth.service.UserService;
  13 +
  14 +import org.apache.commons.lang3.StringUtils;
  15 +import org.slf4j.Logger;
  16 +import org.springframework.beans.BeansException;
  17 +import org.springframework.context.ApplicationContext;
  18 +import org.springframework.context.ApplicationContextAware;
  19 +import org.springframework.stereotype.Component;
  20 +
  21 +import javax.jws.WebService;
  22 +import javax.xml.ws.Holder;
  23 +import java.util.HashSet;
  24 +import java.util.List;
  25 +import java.util.Map;
  26 +import java.util.Set;
  27 +
  28 +/**
  29 + * Created by panzhao on 2017/3/27.
  30 + */
  31 +@Component
  32 +@WebService(
  33 + name = "AttendanceServiceSoap",
  34 + portName = "AttendanceServiceSoap",
  35 + serviceName = "AttendanceService",
  36 + targetNamespace = "http://control.bsth.com/",
  37 + endpointInterface = "com.bsth.server_ws.attendance.AttendanceService")
  38 +public class AttendanceServiceSoap implements AttendanceService, ApplicationContextAware {
  39 +
  40 + Logger logger = org.slf4j.LoggerFactory.getLogger(this.getClass());
  41 +
  42 + static DDYAuthorityService ddyAuthorityService;
  43 + static PlanScheduleRedisService planScheduleRedisService;
  44 + static ScheduleRedisService scheduleRedisService;
  45 +
  46 + static UserService userService;
  47 +
  48 + @Override
  49 + public boolean jsy_attendance(String password, String rq, String company, Holder<Jsy_attendance[]> result, Holder<String> fError) {
  50 + try {
  51 + if(userService.get(password) == null){
  52 + fError.value = "无效的密码!";
  53 + return false;
  54 + }
  55 +
  56 + //按公司编码获取线路
  57 + List<String> lineArray = LineBufferData.findCodesByCompany(company);
  58 + //计划排班
  59 + List<SchedulePlanInfo> plans = planScheduleRedisService.findByMultiLine(lineArray, rq);
  60 + //实际排班
  61 + List<ScheduleRealInfo> reals = scheduleRedisService.findByMultiLine(lineArray, rq);
  62 + //从计划和实际里提取出驾驶员
  63 + Set<String> jsySet = extractJsy(plans, reals);
  64 + //驾驶员班型对照
  65 + Map<String, String> types = ddyAuthorityService.findMultiType(jsySet);
  66 +
  67 + //转换成工资系统想要的数据
  68 + result.value = WSDataConver.to_jsyAttendanceNH(plans, reals, jsySet, types, rq);
  69 + }catch (Exception e){
  70 + logger.error("", e);
  71 + fError.value = "服务器出现异常!";
  72 + return false;
  73 + }
  74 + return true;
  75 + }
  76 +
  77 + @Override
  78 + public boolean ssry_attendance(String password, String rq, String company, Holder<Ssry_attendance[]> result,
  79 + Holder<String> fError) {
  80 + // TODO Auto-generated method stub
  81 + try {
  82 + if(userService.get(password) == null){
  83 + fError.value = "无效的密码!";
  84 + return false;
  85 + }
  86 +
  87 + //按公司编码获取线路
  88 + List<String> lineArray = LineBufferData.findCodesByCompany(company);
  89 + //计划排班
  90 + List<SchedulePlanInfo> plans = planScheduleRedisService.findByMultiLine(lineArray, rq);
  91 + //实际排班
  92 + List<ScheduleRealInfo> reals = scheduleRedisService.findByMultiLine(lineArray, rq);
  93 + //从计划和实际里提取出驾驶员
  94 + Set<String> jsys = new HashSet<String>(), spys = new HashSet<String>();
  95 + extractSsry(plans, reals, jsys, spys);
  96 +
  97 + //转换成工资系统想要的数据
  98 + result.value = WSDataConver.toAttendanceNH(plans, reals, jsys, spys, rq);
  99 + }catch (Exception e){
  100 + logger.error("", e);
  101 + fError.value = "服务器出现异常!";
  102 + return false;
  103 + }
  104 + return true;
  105 + }
  106 +
  107 + private Set<String> extractJsy(List<SchedulePlanInfo> plans, List<ScheduleRealInfo> reals) {
  108 + Set<String> rs = new HashSet<>();
  109 + for (SchedulePlanInfo plan : plans) {
  110 + rs.add(plan.getjGh());
  111 + }
  112 +
  113 + for (ScheduleRealInfo sch : reals) {
  114 + rs.add(sch.getjGh());
  115 + }
  116 + return rs;
  117 + }
  118 +
  119 + /**
  120 + * 提取司售人员
  121 + * @param plans
  122 + * @param reals
  123 + * @return
  124 + */
  125 + private void extractSsry(List<SchedulePlanInfo> plans, List<ScheduleRealInfo> reals, Set<String> jsys, Set<String> spys) {
  126 + for (SchedulePlanInfo plan : plans) {
  127 + jsys.add(plan.getjGh());
  128 + if (StringUtils.isNotEmpty(plan.getsGh())) {
  129 + spys.add(plan.getsGh());
  130 + }
  131 + }
  132 +
  133 + for (ScheduleRealInfo sch : reals) {
  134 + jsys.add(sch.getjGh());
  135 + if (StringUtils.isNotEmpty(sch.getsGh())) {
  136 + spys.add(sch.getsGh());
  137 + }
  138 + }
  139 + }
  140 +
  141 + @Override
  142 + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
  143 + ddyAuthorityService = applicationContext.getBean(DDYAuthorityService.class);
  144 + planScheduleRedisService = applicationContext.getBean(PlanScheduleRedisService.class);
  145 + scheduleRedisService = applicationContext.getBean(ScheduleRedisService.class);
  146 + userService = applicationContext.getBean(UserService.class);
  147 + }
  148 +
  149 +}
... ...
src/main/java/com/bsth/server_ws/util/WSDataConver.java
... ... @@ -23,6 +23,7 @@ import com.bsth.entity.ElecInfo;
23 23 import com.bsth.entity.OilInfo;
24 24 import com.bsth.entity.SchedulePlanInfo;
25 25 import com.bsth.entity.ScheduleRealInfo;
  26 +import com.bsth.server_ws.attendance.entity.Ssry_attendance;
26 27 import com.bsth.server_ws.attendance.entity.Jsy_attendance;
27 28 import com.bsth.server_ws.park_station.dto.LsLcPb;
28 29 import com.bsth.server_ws.waybill.entity.NH_waybill;
... ... @@ -731,23 +732,23 @@ public class WSDataConver {
731 732 List<ScheduleRealInfo> treals = searchRealByJsy(reals, jGh);
732 733 Set<String> lines = new HashSet<String>();
733 734 for (SchedulePlanInfo p : tplans) {
734   - lines.add(p.getXlBm() + "_" + p.getLpName());
  735 + lines.add(p.getXlBm());
735 736 }
736 737 for (ScheduleRealInfo r : treals) {
737   - lines.add(r.getXlBm() + "_" + r.getLpName());
  738 + lines.add(r.getXlBm());
738 739 }
739 740 for (String line : lines) {
740 741 Jsy_attendance attendance = new Jsy_attendance();
741 742 SchedulePlanInfo plan = null;
742 743 ScheduleRealInfo real = null;
743 744 for (SchedulePlanInfo p : tplans) {
744   - if (line.equals(p.getXlBm() + "_" + p.getLpName())) {
  745 + if (line.equals(p.getXlBm())) {
745 746 plan = p;
746 747 break;
747 748 }
748 749 }
749 750 for (ScheduleRealInfo r : treals) {
750   - if (line.equals(r.getXlBm() + "_" + r.getLpName())) {
  751 + if (line.equals(r.getXlBm())) {
751 752 real = r;
752 753 break;
753 754 }
... ... @@ -793,13 +794,107 @@ public class WSDataConver {
793 794  
794 795 return rs.toArray(new Jsy_attendance[rs.size()]);
795 796 }
  797 +
  798 + /**
  799 + * 将数据转换成南汇工资系统需要的考勤数据(司/售) 版本2
  800 + *
  801 + * @param plans
  802 + * @param reals
  803 + * @param types
  804 + * @return
  805 + */
  806 + public static Ssry_attendance[] toAttendanceNH(List<SchedulePlanInfo> plans, List<ScheduleRealInfo> reals, Set<String> jsys, Set<String> spys, String rq) {
  807 + //List<String> ghArray = new ArrayList<>(types.keySet());
  808 + List<Ssry_attendance> rs = new ArrayList<Ssry_attendance>();
  809 + for (String jGh : jsys) {
  810 + List<SchedulePlanInfo> tplans = searchByGh(plans, jGh, 1);
  811 + List<ScheduleRealInfo> treals = searchRealByGh(reals, jGh, 1);
  812 + padding(reals, tplans, treals, jGh, rq, 1, rs);
  813 + }
  814 +
  815 + for (String sGh : spys) {
  816 + List<SchedulePlanInfo> tplans = searchByGh(plans, sGh, 2);
  817 + List<ScheduleRealInfo> treals = searchRealByGh(reals, sGh, 2);
  818 + padding(reals, tplans, treals, sGh, rq, 2, rs);
  819 + }
  820 +
  821 + return rs.toArray(new Ssry_attendance[rs.size()]);
  822 + }
  823 +
  824 + private static void padding(List<ScheduleRealInfo> reals, List<SchedulePlanInfo> tplans, List<ScheduleRealInfo> treals, String gh, String rq, int yglx, List<Ssry_attendance> rs) {
  825 + Set<String> lines = new HashSet<String>();
  826 + for (SchedulePlanInfo p : tplans) {
  827 + lines.add(p.getXlBm());
  828 + }
  829 + for (ScheduleRealInfo r : treals) {
  830 + lines.add(r.getXlBm());
  831 + }
  832 + for (String line : lines) {
  833 + Ssry_attendance attendance = new Ssry_attendance();
  834 + SchedulePlanInfo plan = null;
  835 + ScheduleRealInfo real = null;
  836 + Set<String> cls = new HashSet<String>(), lps = new HashSet<String>();
  837 + for (SchedulePlanInfo p : tplans) {
  838 + if (line.equals(p.getXlBm())) {
  839 + plan = p;
  840 + cls.add(p.getClZbh());
  841 + lps.add(p.getLpName());
  842 + }
  843 + }
  844 + for (ScheduleRealInfo r : treals) {
  845 + if (line.equals(r.getXlBm())) {
  846 + real = r;
  847 + cls.add(r.getClZbh());
  848 + lps.add(r.getLpName());
  849 + }
  850 + }
  851 + for (String cl : cls) {
  852 + attendance.addCl(cl);
  853 + }
  854 + for (String lp : lps) {
  855 + attendance.addLpName(lp);
  856 + }
  857 + attendance.setYglx(yglx);
  858 + attendance.setRq(rq);
  859 + //考勤
  860 + attendance.setStatus((plan==null?"0":"1") + "," + (real==null?"0":"1"));
  861 + //驾驶员工号
  862 + attendance.setGh(gh);
  863 + //早晚班类型
  864 + attendance.calcZybType(reals);
  865 +
  866 + String name = null;
  867 + //实际计划
  868 + if(real != null){
  869 + attendance.setXlBm(real.getXlBm());
  870 + attendance.setXlName(real.getXlName());
  871 + if (yglx == 1) {
  872 + name = real.getjName();
  873 + } else if (yglx == 2) {
  874 + name = real.getsName();
  875 + }
  876 + }
  877 + //计划
  878 + else if(plan != null){
  879 + attendance.setXlBm(plan.getXlBm());
  880 + attendance.setXlName(plan.getXlName());
  881 + if (yglx == 1) {
  882 + name = plan.getjName();
  883 + } else if (yglx == 2) {
  884 + name = plan.getsName();
  885 + }
  886 + }
  887 + attendance.setName(name);
  888 +
  889 + rs.add(attendance);
  890 + }
  891 + }
796 892  
797 893 public static List<SchedulePlanInfo> searchByJsy(List<SchedulePlanInfo> plans, String jGh){
798 894 List<SchedulePlanInfo> rs = new ArrayList<SchedulePlanInfo>();
799 895 String oldLineId = "0";
800   - String oldLp = "0";
801 896 for(SchedulePlanInfo plan : plans){
802   - if (plan.getjGh().equals(jGh) && (!oldLineId.equals(plan.getXlBm()) || !oldLp.equals(plan.getLpName()))) {
  897 + if (plan.getjGh().equals(jGh) && !oldLineId.equals(plan.getXlBm())) {
803 898 rs.add(plan);
804 899 oldLineId = plan.getXlBm();
805 900 }
... ... @@ -807,13 +902,29 @@ public class WSDataConver {
807 902  
808 903 return rs;
809 904 }
  905 +
  906 + public static List<SchedulePlanInfo> searchByGh(List<SchedulePlanInfo> plans, String gh, int yglx){
  907 + List<SchedulePlanInfo> rs = new ArrayList<SchedulePlanInfo>();
  908 + for(SchedulePlanInfo plan : plans){
  909 + String tgh = null;
  910 + if (yglx == 1) {
  911 + tgh = plan.getjGh();
  912 + } else if (yglx == 2) {
  913 + tgh = plan.getsGh();
  914 + }
  915 + if (gh.equals(tgh)) {
  916 + rs.add(plan);
  917 + }
  918 + }
  919 +
  920 + return rs;
  921 + }
810 922  
811 923 public static List<ScheduleRealInfo> searchRealByJsy(List<ScheduleRealInfo> reals, String jGh){
812 924 List<ScheduleRealInfo> rs = new ArrayList<ScheduleRealInfo>();
813 925 String oldLineId = "0";
814   - String oldLp = "0";
815 926 for(ScheduleRealInfo sch : reals){
816   - if (sch.getjGh().equals(jGh) && (!oldLineId.equals(sch.getXlBm()) || !oldLp.equals(sch.getLpName()))) {
  927 + if (sch.getjGh().equals(jGh) && !oldLineId.equals(sch.getXlBm())) {
817 928 rs.add(sch);
818 929 oldLineId = sch.getXlBm();
819 930 }
... ... @@ -821,6 +932,23 @@ public class WSDataConver {
821 932  
822 933 return rs;
823 934 }
  935 +
  936 + public static List<ScheduleRealInfo> searchRealByGh(List<ScheduleRealInfo> reals, String gh, int yglx){
  937 + List<ScheduleRealInfo> rs = new ArrayList<ScheduleRealInfo>();
  938 + for(ScheduleRealInfo sch : reals){
  939 + String tgh = null;
  940 + if (yglx == 1) {
  941 + tgh = sch.getjGh();
  942 + } else if (yglx == 2) {
  943 + tgh = sch.getsGh();
  944 + }
  945 + if (gh.equals(tgh)) {
  946 + rs.add(sch);
  947 + }
  948 + }
  949 +
  950 + return rs;
  951 + }
824 952  
825 953 /**
826 954 * 将排班和油耗转换成综合查询需要的数据
... ...