Commit 344861b0f8af99102e94bdb50c0a82ef7034791c
1 parent
ab560d75
1.青浦和浦东有差异,修正
Showing
4 changed files
with
393 additions
and
382 deletions
src/main/java/com/bsth/server_ws/attendance/AttendanceServiceSoap.java
| 1 | 1 | package com.bsth.server_ws.attendance; |
| 2 | 2 | |
| 3 | +import java.util.HashMap; | |
| 4 | +import java.util.HashSet; | |
| 5 | +import java.util.List; | |
| 6 | +import java.util.Map; | |
| 7 | +import java.util.Set; | |
| 8 | + | |
| 9 | +import javax.jws.WebService; | |
| 10 | +import javax.xml.ws.Holder; | |
| 11 | + | |
| 12 | +import org.apache.commons.lang3.StringUtils; | |
| 13 | +import org.slf4j.Logger; | |
| 14 | +import org.springframework.beans.BeansException; | |
| 15 | +import org.springframework.context.ApplicationContext; | |
| 16 | +import org.springframework.context.ApplicationContextAware; | |
| 17 | +import org.springframework.stereotype.Component; | |
| 18 | + | |
| 3 | 19 | import com.bsth.entity.SchedulePlanInfo; |
| 4 | 20 | import com.bsth.entity.ScheduleRealInfo; |
| 5 | 21 | import com.bsth.redis.PlanScheduleRedisService; |
| 6 | 22 | import com.bsth.redis.ScheduleRedisService; |
| 7 | 23 | import com.bsth.server_rs.base_info.line.buffer.LineBufferData; |
| 8 | -import com.bsth.server_ws.attendance.entity.Ssry_attendance; | |
| 9 | 24 | import com.bsth.server_ws.attendance.entity.Jsy_attendance; |
| 25 | +import com.bsth.server_ws.attendance.entity.Ssry_attendance; | |
| 10 | 26 | import com.bsth.server_ws.util.WSDataConver; |
| 11 | 27 | import com.bsth.service.DDYAuthorityService; |
| 12 | 28 | import com.bsth.service.UserService; |
| 13 | 29 | |
| 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 | 30 | /** |
| 29 | 31 | * Created by panzhao on 2017/3/27. |
| 30 | 32 | */ |
| ... | ... | @@ -62,7 +64,8 @@ public class AttendanceServiceSoap implements AttendanceService, ApplicationCont |
| 62 | 64 | //从计划和实际里提取出驾驶员 |
| 63 | 65 | Set<String> jsySet = extractJsy(plans, reals); |
| 64 | 66 | //驾驶员班型对照 |
| 65 | - Map<String, String> types = ddyAuthorityService.findMultiType(jsySet); | |
| 67 | + //Map<String, String> types = ddyAuthorityService.findMultiType(jsySet); | |
| 68 | + Map<String, String> types = new HashMap<String, String>(); | |
| 66 | 69 | |
| 67 | 70 | //转换成工资系统想要的数据 |
| 68 | 71 | result.value = WSDataConver.to_jsyAttendanceNH(plans, reals, jsySet, types, rq); | ... | ... |
src/main/java/com/bsth/server_ws/attendance/entity/Jsy_attendance.java
| 1 | -package com.bsth.server_ws.attendance.entity; | |
| 2 | - | |
| 3 | -import com.bsth.entity.ScheduleRealInfo; | |
| 4 | - | |
| 5 | -import java.util.Collections; | |
| 6 | -import java.util.Comparator; | |
| 7 | -import java.util.List; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 南汇驾驶员考勤 | |
| 11 | - * Created by panzhao on 2017/3/27. | |
| 12 | - */ | |
| 13 | -public class Jsy_attendance { | |
| 14 | - | |
| 15 | - /** 日期 */ | |
| 16 | - private String rq; | |
| 17 | - | |
| 18 | - /** 公司编码 */ | |
| 19 | - private String company; | |
| 20 | - | |
| 21 | - /** 分公司编码 */ | |
| 22 | - private String fgsCompany; | |
| 23 | - | |
| 24 | - /** 线路编码 */ | |
| 25 | - private String xlBm; | |
| 26 | - | |
| 27 | - /** 线路名称 */ | |
| 28 | - private String xlName; | |
| 29 | - | |
| 30 | - /** 驾驶员工号 */ | |
| 31 | - private String jGh; | |
| 32 | - | |
| 33 | - /** 驾驶员名称 */ | |
| 34 | - private String jName; | |
| 35 | - | |
| 36 | - /** 售票员工号 */ | |
| 37 | - private String sGh; | |
| 38 | - | |
| 39 | - /** 售票员名称 */ | |
| 40 | - private String sName; | |
| 41 | - | |
| 42 | - /** 班型 */ | |
| 43 | - private String planType; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * 出勤状态 应出,实出 | |
| 47 | - * 1,0 应出未出 | |
| 48 | - * 1,1 应出实出 | |
| 49 | - * 0,1 无计划,临加出勤 | |
| 50 | - */ | |
| 51 | - private String status; | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * 路牌 | |
| 55 | - */ | |
| 56 | - private String lpNames; | |
| 57 | - | |
| 58 | - /** 车辆 */ | |
| 59 | - private String cls; | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * 早夜班类型 | |
| 63 | - * | |
| 64 | - * 早班:上班时间五点之前; | |
| 65 | - * 中班:下班时间为22点之后到24点之间; | |
| 66 | - * 晚班:下班时间24点之后为深夜班 | |
| 67 | - * | |
| 68 | - * 1、早班 | |
| 69 | - 2、中班 | |
| 70 | - 3、晚班 | |
| 71 | - 4、早中班 | |
| 72 | - 5、早晚班 | |
| 73 | - */ | |
| 74 | - private int zybType; | |
| 75 | - | |
| 76 | - | |
| 77 | - public void calcZybType(List<ScheduleRealInfo> list){ | |
| 78 | - ScheduleRealInfo s,e; | |
| 79 | - Collections.sort(list, new Comparator<ScheduleRealInfo>() { | |
| 80 | - @Override | |
| 81 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 82 | - return (int) (o1.getFcsjT() - o2.getFcsjT()); | |
| 83 | - } | |
| 84 | - }); | |
| 85 | - | |
| 86 | - s = list.get(0); | |
| 87 | - e = list.get(list.size() - 1); | |
| 88 | - | |
| 89 | - if(s.getFcsj().compareTo("05:00") <= 0) | |
| 90 | - this.zybType=1;//早班 | |
| 91 | - else if(e.getZdsj().compareTo("05:00") > 0) | |
| 92 | - this.zybType=2;//中班 | |
| 93 | - else if(e.getZdsj().compareTo("05:00") < 0) | |
| 94 | - this.zybType=3;//晚班 | |
| 95 | - | |
| 96 | - //早中班 | |
| 97 | - if(this.zybType==1 && e.getZdsj().compareTo("22:00") >=0 && e.getZdsj().compareTo("23:59") <= 0){ | |
| 98 | - this.zybType = 4; | |
| 99 | - } | |
| 100 | - | |
| 101 | - //早晚班 | |
| 102 | - if(this.zybType==1 && e.getZdsj().compareTo(s.getFcsj()) < 0){ | |
| 103 | - this.zybType = 5; | |
| 104 | - } | |
| 105 | - } | |
| 106 | - | |
| 107 | - public Jsy_attendance() { | |
| 108 | - } | |
| 109 | - | |
| 110 | - public String getRq() { | |
| 111 | - return rq; | |
| 112 | - } | |
| 113 | - | |
| 114 | - public void setRq(String rq) { | |
| 115 | - this.rq = rq; | |
| 116 | - } | |
| 117 | - | |
| 118 | - public String getXlBm() { | |
| 119 | - return xlBm; | |
| 120 | - } | |
| 121 | - | |
| 122 | - public void setXlBm(String xlBm) { | |
| 123 | - this.xlBm = xlBm; | |
| 124 | - } | |
| 125 | - | |
| 126 | - public String getXlName() { | |
| 127 | - return xlName; | |
| 128 | - } | |
| 129 | - | |
| 130 | - public void setXlName(String xlName) { | |
| 131 | - this.xlName = xlName; | |
| 132 | - } | |
| 133 | - | |
| 134 | - public String getjGh() { | |
| 135 | - return jGh; | |
| 136 | - } | |
| 137 | - | |
| 138 | - public void setjGh(String jGh) { | |
| 139 | - this.jGh = jGh; | |
| 140 | - } | |
| 141 | - | |
| 142 | - public String getjName() { | |
| 143 | - return jName; | |
| 144 | - } | |
| 145 | - | |
| 146 | - public void setjName(String jName) { | |
| 147 | - this.jName = jName; | |
| 148 | - } | |
| 149 | - | |
| 150 | - public String getsGh() { | |
| 151 | - return sGh; | |
| 152 | - } | |
| 153 | - | |
| 154 | - public void setsGh(String sGh) { | |
| 155 | - this.sGh = sGh; | |
| 156 | - } | |
| 157 | - | |
| 158 | - public String getsName() { | |
| 159 | - return sName; | |
| 160 | - } | |
| 161 | - | |
| 162 | - public void setsName(String sName) { | |
| 163 | - this.sName = sName; | |
| 164 | - } | |
| 165 | - | |
| 166 | - public String getPlanType() { | |
| 167 | - return planType; | |
| 168 | - } | |
| 169 | - | |
| 170 | - public void setPlanType(String planType) { | |
| 171 | - this.planType = planType; | |
| 172 | - } | |
| 173 | - | |
| 174 | - public String getStatus() { | |
| 175 | - return status; | |
| 176 | - } | |
| 177 | - | |
| 178 | - public void setStatus(String status) { | |
| 179 | - this.status = status; | |
| 180 | - } | |
| 181 | - | |
| 182 | - public String getCompany() { | |
| 183 | - return company; | |
| 184 | - } | |
| 185 | - | |
| 186 | - public void setCompany(String company) { | |
| 187 | - this.company = company; | |
| 188 | - } | |
| 189 | - | |
| 190 | - public String getFgsCompany() { | |
| 191 | - return fgsCompany; | |
| 192 | - } | |
| 193 | - | |
| 194 | - public void setFgsCompany(String fgsCompany) { | |
| 195 | - this.fgsCompany = fgsCompany; | |
| 196 | - } | |
| 197 | - | |
| 198 | - public String getLpNames() { | |
| 199 | - return lpNames; | |
| 200 | - } | |
| 201 | - | |
| 202 | - public void setLpNames(String lpNames) { | |
| 203 | - this.lpNames = lpNames; | |
| 204 | - } | |
| 205 | - | |
| 206 | - public String getCls() { | |
| 207 | - return cls; | |
| 208 | - } | |
| 209 | - | |
| 210 | - public void setCls(String cls) { | |
| 211 | - this.cls = cls; | |
| 212 | - } | |
| 213 | - | |
| 214 | - public void addLpName(String name){ | |
| 215 | - if(null==this.lpNames) | |
| 216 | - this.lpNames=""; | |
| 217 | - else | |
| 218 | - this.lpNames+=","; | |
| 219 | - this.lpNames+=name; | |
| 220 | - } | |
| 221 | - | |
| 222 | - public void addCl(String nbbm){ | |
| 223 | - if(null==this.cls) | |
| 224 | - this.cls=""; | |
| 225 | - else | |
| 226 | - this.cls+=","; | |
| 227 | - | |
| 228 | - this.cls+=nbbm; | |
| 229 | - } | |
| 230 | - | |
| 231 | - public int getZybType() { | |
| 232 | - return zybType; | |
| 233 | - } | |
| 234 | - | |
| 235 | - public void setZybType(int zybType) { | |
| 236 | - this.zybType = zybType; | |
| 237 | - } | |
| 238 | -} | |
| 1 | +package com.bsth.server_ws.attendance.entity; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.Collections; | |
| 5 | +import java.util.Comparator; | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +import com.bsth.entity.ScheduleRealInfo; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 南汇驾驶员考勤 | |
| 12 | + * Created by panzhao on 2017/3/27. | |
| 13 | + */ | |
| 14 | +public class Jsy_attendance { | |
| 15 | + | |
| 16 | + /** 日期 */ | |
| 17 | + private String rq; | |
| 18 | + | |
| 19 | + /** 公司编码 */ | |
| 20 | + private String company; | |
| 21 | + | |
| 22 | + /** 分公司编码 */ | |
| 23 | + private String fgsCompany; | |
| 24 | + | |
| 25 | + /** 线路编码 */ | |
| 26 | + private String xlBm; | |
| 27 | + | |
| 28 | + /** 线路名称 */ | |
| 29 | + private String xlName; | |
| 30 | + | |
| 31 | + /** 驾驶员工号 */ | |
| 32 | + private String jGh; | |
| 33 | + | |
| 34 | + /** 驾驶员名称 */ | |
| 35 | + private String jName; | |
| 36 | + | |
| 37 | + /** 售票员工号 */ | |
| 38 | + private String sGh; | |
| 39 | + | |
| 40 | + /** 售票员名称 */ | |
| 41 | + private String sName; | |
| 42 | + | |
| 43 | + /** 班型 */ | |
| 44 | + private String planType; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 出勤状态 应出,实出 | |
| 48 | + * 1,0 应出未出 | |
| 49 | + * 1,1 应出实出 | |
| 50 | + * 0,1 无计划,临加出勤 | |
| 51 | + */ | |
| 52 | + private String status; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 路牌 | |
| 56 | + */ | |
| 57 | + private String lpNames; | |
| 58 | + | |
| 59 | + /** 车辆 */ | |
| 60 | + private String cls; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 早夜班类型 | |
| 64 | + * | |
| 65 | + * 早班:上班时间五点之前; | |
| 66 | + * 中班:下班时间为22点之后到24点之间; | |
| 67 | + * 晚班:下班时间24点之后为深夜班 | |
| 68 | + * | |
| 69 | + * 1、早班 | |
| 70 | + 2、中班 | |
| 71 | + 3、晚班 | |
| 72 | + 4、早中班 | |
| 73 | + 5、早晚班 | |
| 74 | + */ | |
| 75 | + private int zybType; | |
| 76 | + | |
| 77 | + | |
| 78 | + public void calcZybType(List<ScheduleRealInfo> list){ | |
| 79 | + ScheduleRealInfo s,e; | |
| 80 | + List<ScheduleRealInfo> temp = new ArrayList<ScheduleRealInfo>(); | |
| 81 | + for (ScheduleRealInfo sri : list) { | |
| 82 | + if (sri.getFcsjT() != null) { | |
| 83 | + temp.add(sri); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + Collections.sort(temp, new Comparator<ScheduleRealInfo>() { | |
| 87 | + @Override | |
| 88 | + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 89 | + return (int) (o1.getFcsjT() - o2.getFcsjT()); | |
| 90 | + } | |
| 91 | + }); | |
| 92 | + | |
| 93 | + s = list.get(0); | |
| 94 | + e = list.get(list.size() - 1); | |
| 95 | + | |
| 96 | + if(s.getFcsj().compareTo("05:00") <= 0) | |
| 97 | + this.zybType=1;//早班 | |
| 98 | + else if(e.getZdsj().compareTo("05:00") > 0) | |
| 99 | + this.zybType=2;//中班 | |
| 100 | + else if(e.getZdsj().compareTo("05:00") < 0) | |
| 101 | + this.zybType=3;//晚班 | |
| 102 | + | |
| 103 | + //早中班 | |
| 104 | + if(this.zybType==1 && e.getZdsj().compareTo("22:00") >=0 && e.getZdsj().compareTo("23:59") <= 0){ | |
| 105 | + this.zybType = 4; | |
| 106 | + } | |
| 107 | + | |
| 108 | + //早晚班 | |
| 109 | + if(this.zybType==1 && e.getZdsj().compareTo(s.getFcsj()) < 0){ | |
| 110 | + this.zybType = 5; | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + public Jsy_attendance() { | |
| 115 | + } | |
| 116 | + | |
| 117 | + public String getRq() { | |
| 118 | + return rq; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public void setRq(String rq) { | |
| 122 | + this.rq = rq; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public String getXlBm() { | |
| 126 | + return xlBm; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void setXlBm(String xlBm) { | |
| 130 | + this.xlBm = xlBm; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public String getXlName() { | |
| 134 | + return xlName; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public void setXlName(String xlName) { | |
| 138 | + this.xlName = xlName; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public String getjGh() { | |
| 142 | + return jGh; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public void setjGh(String jGh) { | |
| 146 | + this.jGh = jGh; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public String getjName() { | |
| 150 | + return jName; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public void setjName(String jName) { | |
| 154 | + this.jName = jName; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public String getsGh() { | |
| 158 | + return sGh; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public void setsGh(String sGh) { | |
| 162 | + this.sGh = sGh; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public String getsName() { | |
| 166 | + return sName; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public void setsName(String sName) { | |
| 170 | + this.sName = sName; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public String getPlanType() { | |
| 174 | + return planType; | |
| 175 | + } | |
| 176 | + | |
| 177 | + public void setPlanType(String planType) { | |
| 178 | + this.planType = planType; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public String getStatus() { | |
| 182 | + return status; | |
| 183 | + } | |
| 184 | + | |
| 185 | + public void setStatus(String status) { | |
| 186 | + this.status = status; | |
| 187 | + } | |
| 188 | + | |
| 189 | + public String getCompany() { | |
| 190 | + return company; | |
| 191 | + } | |
| 192 | + | |
| 193 | + public void setCompany(String company) { | |
| 194 | + this.company = company; | |
| 195 | + } | |
| 196 | + | |
| 197 | + public String getFgsCompany() { | |
| 198 | + return fgsCompany; | |
| 199 | + } | |
| 200 | + | |
| 201 | + public void setFgsCompany(String fgsCompany) { | |
| 202 | + this.fgsCompany = fgsCompany; | |
| 203 | + } | |
| 204 | + | |
| 205 | + public String getLpNames() { | |
| 206 | + return lpNames; | |
| 207 | + } | |
| 208 | + | |
| 209 | + public void setLpNames(String lpNames) { | |
| 210 | + this.lpNames = lpNames; | |
| 211 | + } | |
| 212 | + | |
| 213 | + public String getCls() { | |
| 214 | + return cls; | |
| 215 | + } | |
| 216 | + | |
| 217 | + public void setCls(String cls) { | |
| 218 | + this.cls = cls; | |
| 219 | + } | |
| 220 | + | |
| 221 | + public void addLpName(String name){ | |
| 222 | + if(null==this.lpNames) | |
| 223 | + this.lpNames=""; | |
| 224 | + else | |
| 225 | + this.lpNames+=","; | |
| 226 | + this.lpNames+=name; | |
| 227 | + } | |
| 228 | + | |
| 229 | + public void addCl(String nbbm){ | |
| 230 | + if(null==this.cls) | |
| 231 | + this.cls=""; | |
| 232 | + else | |
| 233 | + this.cls+=","; | |
| 234 | + | |
| 235 | + this.cls+=nbbm; | |
| 236 | + } | |
| 237 | + | |
| 238 | + public int getZybType() { | |
| 239 | + return zybType; | |
| 240 | + } | |
| 241 | + | |
| 242 | + public void setZybType(int zybType) { | |
| 243 | + this.zybType = zybType; | |
| 244 | + } | |
| 245 | +} | ... | ... |
src/main/java/com/bsth/server_ws/util/WSDataConver.java
| ... | ... | @@ -757,7 +757,7 @@ public class WSDataConver { |
| 757 | 757 | //考勤 |
| 758 | 758 | attendance.setStatus((plan==null?"0":"1") + "," + (real==null?"0":"1")); |
| 759 | 759 | //班型 |
| 760 | - attendance.setPlanType(types.get(jGh)==null?"1":types.get(jGh)); | |
| 760 | + attendance.setPlanType("1"); | |
| 761 | 761 | //驾驶员工号 |
| 762 | 762 | attendance.setjGh(jGh); |
| 763 | 763 | //早晚班类型 | ... | ... |
src/main/java/com/bsth/service/impl/DDYAuthorityServiceImpl.java
| 1 | -package com.bsth.service.impl; | |
| 2 | - | |
| 3 | -import com.bsth.Application; | |
| 4 | -import com.bsth.service.DDYAuthorityService; | |
| 5 | -import com.google.common.base.Splitter; | |
| 6 | -import org.slf4j.Logger; | |
| 7 | -import org.slf4j.LoggerFactory; | |
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | -import org.springframework.boot.CommandLineRunner; | |
| 10 | -import org.springframework.core.annotation.Order; | |
| 11 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 12 | -import org.springframework.stereotype.Component; | |
| 13 | -import org.springframework.stereotype.Service; | |
| 14 | - | |
| 15 | -import java.util.*; | |
| 16 | -import java.util.concurrent.TimeUnit; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * Created by panzhao on 2017/3/27. | |
| 20 | - */ | |
| 21 | -@Service | |
| 22 | -@Order(5) | |
| 23 | -public class DDYAuthorityServiceImpl implements DDYAuthorityService, CommandLineRunner { | |
| 24 | - | |
| 25 | - @Autowired | |
| 26 | - JdbcTemplate jdbcTemplate; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * 驾驶员班型对照 | |
| 30 | - * 1: 做1休1 | |
| 31 | - * 1,1,1,1,1,0,0 : 做5休2 | |
| 32 | - */ | |
| 33 | - static Map<String, String> planTypesMap; | |
| 34 | - | |
| 35 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 36 | - | |
| 37 | - @Override | |
| 38 | - public List<String> findLinesByDDY(String ddy_id) { | |
| 39 | - List<String> rs; | |
| 40 | - try { | |
| 41 | - Map<String, Object> map = jdbcTemplate.queryForMap("select LINE_CODE_STR from bsth_c_real_control_authority a left join bsth_c_sys_user u on a.user_id=u.id where u.user_name=?", ddy_id); | |
| 42 | - String idx = map.get("LINE_CODE_STR").toString(); | |
| 43 | - | |
| 44 | - rs = Splitter.on(",").trimResults().splitToList(idx); | |
| 45 | - }catch (Exception e){ | |
| 46 | - logger.error("", e); | |
| 47 | - rs = new ArrayList<>(); | |
| 48 | - } | |
| 49 | - return rs; | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Override | |
| 53 | - public String findPlanType(String jGh) { | |
| 54 | - return planTypesMap.get(jGh); | |
| 55 | - } | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * 加载驾驶员班型数据 | |
| 59 | - */ | |
| 60 | - @Override | |
| 61 | - public void loadPlanTypes(){ | |
| 62 | - Map<String, String> rsMap = new HashMap<>(); | |
| 63 | - //线路_搭班编码 ——> 班型 | |
| 64 | - Map<String, String> ddbm2bxMap = new HashMap<>(); | |
| 65 | - List<Map<String, Object>> listMap = jdbcTemplate.queryForList("select IFNULL(FBGS, '1') as FBGS, RY_DBBMS, XL from bsth_c_s_sr1_flat where ry_dbbms is not null and xl is not null"); | |
| 66 | - List<String> fbList, dbList; | |
| 67 | - String xl, fbgs; | |
| 68 | - for(Map<String, Object> map : listMap){ | |
| 69 | - xl = map.get("XL").toString(); | |
| 70 | - fbgs = map.get("FBGS").toString(); | |
| 71 | - //拆分分班 | |
| 72 | - fbList = Splitter.on("-").trimResults().splitToList(map.get("RY_DBBMS").toString()); | |
| 73 | - for(String fb : fbList){ | |
| 74 | - //拆分搭班编码 | |
| 75 | - dbList = Splitter.on(",").trimResults().splitToList(fb); | |
| 76 | - | |
| 77 | - for(String db : dbList) | |
| 78 | - ddbm2bxMap.put(xl + "_" + db, fbgs); | |
| 79 | - } | |
| 80 | - } | |
| 81 | - | |
| 82 | - //线路_搭班编码 ——> 驾驶员 | |
| 83 | - Map<String, String> ddbm2jsyMap = new HashMap<>(); | |
| 84 | - listMap = jdbcTemplate.queryForList("select ec.DBBM,ec.XL,p.JOB_CODE from bsth_c_s_ecinfo ec LEFT JOIN bsth_c_personnel p on ec.jsy=p.id where ec.dbbm is not null and ec.xl is not null and p.job_code is not null"); | |
| 85 | - for(Map<String, Object> map : listMap){ | |
| 86 | - ddbm2jsyMap.put(map.get("XL") + "_" + map.get("DBBM"), map.get("JOB_CODE").toString()); | |
| 87 | - } | |
| 88 | - | |
| 89 | - Set<String> dbms = ddbm2jsyMap.keySet(); | |
| 90 | - for(String bm : dbms){ | |
| 91 | - if(ddbm2bxMap.containsKey(bm)) | |
| 92 | - rsMap.put(ddbm2jsyMap.get(bm), ddbm2bxMap.get(bm)); | |
| 93 | - } | |
| 94 | - planTypesMap = rsMap; | |
| 95 | - } | |
| 96 | - | |
| 97 | - @Override | |
| 98 | - public Map<String, String> findMultiType(Set<String> jsySet) { | |
| 99 | - Map<String, String> rs = new HashMap<>(); | |
| 100 | - for(String jGh: jsySet){ | |
| 101 | - rs.put(jGh, planTypesMap.get(jGh)); | |
| 102 | - } | |
| 103 | - return rs; | |
| 104 | - } | |
| 105 | - | |
| 106 | - | |
| 107 | - @Autowired | |
| 108 | - RefreshPlanTypesThread refreshPlanTypesThread; | |
| 109 | - | |
| 110 | - @Override | |
| 111 | - public void run(String... strings) throws Exception { | |
| 112 | - //加载驾驶员班型数据 | |
| 113 | - Application.mainServices.scheduleWithFixedDelay(refreshPlanTypesThread, 30, 60 * 120, TimeUnit.SECONDS); | |
| 114 | - } | |
| 115 | - | |
| 116 | - @Component | |
| 117 | - public static class RefreshPlanTypesThread extends Thread{ | |
| 118 | - | |
| 119 | - @Autowired | |
| 120 | - DDYAuthorityService ddyAuthorityService; | |
| 121 | - | |
| 122 | - @Override | |
| 123 | - public void run() { | |
| 124 | - ddyAuthorityService.loadPlanTypes(); | |
| 125 | - } | |
| 126 | - } | |
| 127 | -} | |
| 1 | +package com.bsth.service.impl; | |
| 2 | + | |
| 3 | +import com.bsth.Application; | |
| 4 | +import com.bsth.service.DDYAuthorityService; | |
| 5 | +import com.google.common.base.Splitter; | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.boot.CommandLineRunner; | |
| 10 | +import org.springframework.core.annotation.Order; | |
| 11 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 12 | +import org.springframework.stereotype.Component; | |
| 13 | +import org.springframework.stereotype.Service; | |
| 14 | + | |
| 15 | +import java.util.*; | |
| 16 | +import java.util.concurrent.TimeUnit; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * Created by panzhao on 2017/3/27. | |
| 20 | + */ | |
| 21 | +@Service | |
| 22 | +@Order(5) | |
| 23 | +public class DDYAuthorityServiceImpl implements DDYAuthorityService, CommandLineRunner { | |
| 24 | + | |
| 25 | + @Autowired | |
| 26 | + JdbcTemplate jdbcTemplate; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 驾驶员班型对照 | |
| 30 | + * 1: 做1休1 | |
| 31 | + * 1,1,1,1,1,0,0 : 做5休2 | |
| 32 | + */ | |
| 33 | + static Map<String, String> planTypesMap; | |
| 34 | + | |
| 35 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public List<String> findLinesByDDY(String ddy_id) { | |
| 39 | + List<String> rs; | |
| 40 | + try { | |
| 41 | + Map<String, Object> map = jdbcTemplate.queryForMap("select LINE_CODE_STR from bsth_c_real_control_authority a left join bsth_c_sys_user u on a.user_id=u.id where u.user_name=?", ddy_id); | |
| 42 | + String idx = map.get("LINE_CODE_STR").toString(); | |
| 43 | + | |
| 44 | + rs = Splitter.on(",").trimResults().splitToList(idx); | |
| 45 | + }catch (Exception e){ | |
| 46 | + logger.error("", e); | |
| 47 | + rs = new ArrayList<>(); | |
| 48 | + } | |
| 49 | + return rs; | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public String findPlanType(String jGh) { | |
| 54 | + return planTypesMap.get(jGh); | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 加载驾驶员班型数据 | |
| 59 | + */ | |
| 60 | + @Override | |
| 61 | + public void loadPlanTypes(){ | |
| 62 | + Map<String, String> rsMap = new HashMap<>(); | |
| 63 | + //线路_搭班编码 ——> 班型 | |
| 64 | + Map<String, String> ddbm2bxMap = new HashMap<>(); | |
| 65 | + List<Map<String, Object>> listMap = jdbcTemplate.queryForList("select IFNULL(FBGS, '1') as FBGS, RY_DBBMS, XL from bsth_c_s_sr1_flat where ry_dbbms is not null and xl is not null"); | |
| 66 | + List<String> fbList, dbList; | |
| 67 | + String xl, fbgs; | |
| 68 | + for(Map<String, Object> map : listMap){ | |
| 69 | + xl = map.get("XL").toString(); | |
| 70 | + fbgs = map.get("FBGS").toString(); | |
| 71 | + //拆分分班 | |
| 72 | + fbList = Splitter.on("-").trimResults().splitToList(map.get("RY_DBBMS").toString()); | |
| 73 | + for(String fb : fbList){ | |
| 74 | + //拆分搭班编码 | |
| 75 | + dbList = Splitter.on(",").trimResults().splitToList(fb); | |
| 76 | + | |
| 77 | + for(String db : dbList) | |
| 78 | + ddbm2bxMap.put(xl + "_" + db, fbgs); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | + //线路_搭班编码 ——> 驾驶员 | |
| 83 | + Map<String, String> ddbm2jsyMap = new HashMap<>(); | |
| 84 | + listMap = jdbcTemplate.queryForList("select ec.DBBM,ec.XL,p.JOB_CODE from bsth_c_s_ecinfo ec LEFT JOIN bsth_c_personnel p on ec.jsy=p.id where ec.dbbm is not null and ec.xl is not null and p.job_code is not null"); | |
| 85 | + for(Map<String, Object> map : listMap){ | |
| 86 | + ddbm2jsyMap.put(map.get("XL") + "_" + map.get("DBBM"), map.get("JOB_CODE").toString()); | |
| 87 | + } | |
| 88 | + | |
| 89 | + Set<String> dbms = ddbm2jsyMap.keySet(); | |
| 90 | + for(String bm : dbms){ | |
| 91 | + if(ddbm2bxMap.containsKey(bm)) | |
| 92 | + rsMap.put(ddbm2jsyMap.get(bm), ddbm2bxMap.get(bm)); | |
| 93 | + } | |
| 94 | + planTypesMap = rsMap; | |
| 95 | + } | |
| 96 | + | |
| 97 | + @Override | |
| 98 | + public Map<String, String> findMultiType(Set<String> jsySet) { | |
| 99 | + Map<String, String> rs = new HashMap<>(); | |
| 100 | + for(String jGh: jsySet){ | |
| 101 | + System.out.println(jGh + " " + planTypesMap.get(jGh)); | |
| 102 | + rs.put(jGh, planTypesMap.get(jGh)); | |
| 103 | + } | |
| 104 | + return rs; | |
| 105 | + } | |
| 106 | + | |
| 107 | + | |
| 108 | + @Autowired | |
| 109 | + RefreshPlanTypesThread refreshPlanTypesThread; | |
| 110 | + | |
| 111 | + @Override | |
| 112 | + public void run(String... strings) throws Exception { | |
| 113 | + //加载驾驶员班型数据 | |
| 114 | + Application.mainServices.scheduleWithFixedDelay(refreshPlanTypesThread, 30, 60 * 120, TimeUnit.SECONDS); | |
| 115 | + } | |
| 116 | + | |
| 117 | + @Component | |
| 118 | + public static class RefreshPlanTypesThread extends Thread{ | |
| 119 | + | |
| 120 | + @Autowired | |
| 121 | + DDYAuthorityService ddyAuthorityService; | |
| 122 | + | |
| 123 | + @Override | |
| 124 | + public void run() { | |
| 125 | + ddyAuthorityService.loadPlanTypes(); | |
| 126 | + } | |
| 127 | + } | |
| 128 | +} | ... | ... |