Commit f9721565b5400854573e9834b7cd010f2f8e14e2
1 parent
9b76e9a7
为换人换车情况表写入数据...
Showing
3 changed files
with
121 additions
and
13 deletions
src/main/java/com/bsth/data/schedule/SchModifyLog.java
0 → 100644
| 1 | +package com.bsth.data.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.controller.realcontrol.dto.ChangePersonCar; | |
| 4 | +import com.bsth.entity.mcy_forms.Changetochange; | |
| 5 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 6 | +import com.bsth.entity.sys.SysUser; | |
| 7 | +import com.bsth.repository.form.ChangetochangeRepository; | |
| 8 | +import com.bsth.security.util.SecurityUtils; | |
| 9 | +import org.apache.commons.lang3.StringUtils; | |
| 10 | +import org.joda.time.format.DateTimeFormat; | |
| 11 | +import org.joda.time.format.DateTimeFormatter; | |
| 12 | +import org.slf4j.Logger; | |
| 13 | +import org.slf4j.LoggerFactory; | |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | + | |
| 17 | +import java.util.Date; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * 线调实际排班修改日志记录 | |
| 21 | + * Created by panzhao on 2017/5/7. | |
| 22 | + */ | |
| 23 | +@Service | |
| 24 | +public class SchModifyLog { | |
| 25 | + | |
| 26 | + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | |
| 27 | + | |
| 28 | + Logger log = LoggerFactory.getLogger(this.getClass()); | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + ChangetochangeRepository changetochangeRepository; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 换人换车情况表 | |
| 35 | + */ | |
| 36 | + public void saveChangetochange(ScheduleRealInfo sch, ChangePersonCar cpc){ | |
| 37 | + try { | |
| 38 | + String newNbbm = cpc.getClZbh(); | |
| 39 | + String newJsy = cpc.getJsy(); | |
| 40 | + String oldJsy = sch.getjGh()+"/"+sch.getjName(); | |
| 41 | + | |
| 42 | + if(newNbbm == null && newJsy == null) | |
| 43 | + return; | |
| 44 | + | |
| 45 | + if(newNbbm != null && newJsy != null | |
| 46 | + && newNbbm.equals(sch.getClZbh()) && newJsy.equals(oldJsy)) | |
| 47 | + return; | |
| 48 | + | |
| 49 | + Date d = new Date(); | |
| 50 | + SysUser user = SecurityUtils.getCurrentUser(); | |
| 51 | + Changetochange cc = new Changetochange(); | |
| 52 | + cc.setRq(sch.getScheduleDateStr()); | |
| 53 | + cc.setGs(sch.getGsBm()); | |
| 54 | + cc.setFgs(sch.getFgsBm()); | |
| 55 | + cc.setXl(sch.getXlBm()); | |
| 56 | + cc.setLp(sch.getLpName()); | |
| 57 | + cc.setFssj(fmtHHmm.print(d.getTime())); | |
| 58 | + cc.setXgsj(fmtHHmm.print(d.getTime())); | |
| 59 | + if(user != null) | |
| 60 | + cc.setXgr(user.getUserName()); | |
| 61 | + | |
| 62 | + cc.setPcch(sch.getClZbh()); | |
| 63 | + cc.setPcry(oldJsy); | |
| 64 | + cc.setJhch(sch.getClZbh()); | |
| 65 | + cc.setJhgh(sch.getjGh()); | |
| 66 | + | |
| 67 | + if(StringUtils.isNotEmpty(newNbbm)) | |
| 68 | + cc.setSjch(newNbbm); | |
| 69 | + if(StringUtils.isNotEmpty(newJsy)) | |
| 70 | + cc.setSjgh(newJsy); | |
| 71 | + | |
| 72 | + changetochangeRepository.save(cc); | |
| 73 | + }catch (Exception e){ | |
| 74 | + log.error("纪录换人换车情况表", e); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + public void saveChangetochange(ScheduleRealInfo sch, String nbbm, String jsy){ | |
| 79 | + ChangePersonCar cpc = new ChangePersonCar(); | |
| 80 | + cpc.setClZbh(nbbm); | |
| 81 | + cpc.setJsy(jsy); | |
| 82 | + saveChangetochange(sch, cpc); | |
| 83 | + } | |
| 84 | +} | ... | ... |
src/main/java/com/bsth/repository/form/ChangetochangeRepository.java
0 → 100644
| 1 | +package com.bsth.repository.form; | |
| 2 | + | |
| 3 | +import com.bsth.entity.mcy_forms.Changetochange; | |
| 4 | +import com.bsth.repository.BaseRepository; | |
| 5 | +import org.springframework.stereotype.Repository; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Created by panzhao on 2017/5/7. | |
| 9 | + */ | |
| 10 | +@Repository | |
| 11 | +public interface ChangetochangeRepository extends BaseRepository<Changetochange, Integer>{ | |
| 12 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -12,6 +12,7 @@ import com.bsth.data.BasicData; |
| 12 | 12 | import com.bsth.data.LineConfigData; |
| 13 | 13 | import com.bsth.data.schedule.DayOfSchedule; |
| 14 | 14 | import com.bsth.data.schedule.SchAttrCalculator; |
| 15 | +import com.bsth.data.schedule.SchModifyLog; | |
| 15 | 16 | import com.bsth.data.schedule.ScheduleComparator; |
| 16 | 17 | import com.bsth.data.schedule.late_adjust.LateAdjustHandle; |
| 17 | 18 | import com.bsth.entity.Cars; |
| ... | ... | @@ -52,7 +53,6 @@ import com.google.common.base.Splitter; |
| 52 | 53 | import com.google.common.collect.Lists; |
| 53 | 54 | import org.apache.commons.lang3.StringEscapeUtils; |
| 54 | 55 | import org.apache.commons.lang3.StringUtils; |
| 55 | -import org.drools.compiler.lang.dsl.DSLMapParser.statement_return; | |
| 56 | 56 | import org.joda.time.format.DateTimeFormat; |
| 57 | 57 | import org.joda.time.format.DateTimeFormatter; |
| 58 | 58 | import org.slf4j.Logger; |
| ... | ... | @@ -132,6 +132,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 132 | 132 | @Autowired |
| 133 | 133 | CulateMileageService culateService; |
| 134 | 134 | |
| 135 | + @Autowired | |
| 136 | + SchModifyLog schModifyLog; | |
| 137 | + | |
| 135 | 138 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 136 | 139 | |
| 137 | 140 | SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), |
| ... | ... | @@ -1171,10 +1174,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1171 | 1174 | return rs; |
| 1172 | 1175 | } |
| 1173 | 1176 | |
| 1177 | + String clZbh = map.get("clZbh"); | |
| 1178 | + String jsy = map.get("jsy"); | |
| 1179 | + if(!clZbh.equals(sch.getClZbh()) | |
| 1180 | + || !jsy.equals(sch.getjGh() + "/" + sch.getjName())) | |
| 1181 | + schModifyLog.saveChangetochange(sch, clZbh, jsy);//为换人换车情况表写入数据 | |
| 1174 | 1182 | /** |
| 1175 | 1183 | * 换车 |
| 1176 | 1184 | */ |
| 1177 | - String clZbh = map.get("clZbh"); | |
| 1178 | 1185 | if (StringUtils.isNotEmpty(clZbh)) { |
| 1179 | 1186 | //换车 |
| 1180 | 1187 | if (!carExist(sch.getGsBm(), clZbh)) { |
| ... | ... | @@ -1189,7 +1196,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1189 | 1196 | /** |
| 1190 | 1197 | * 换驾驶员 |
| 1191 | 1198 | */ |
| 1192 | - String jsy = map.get("jsy"); | |
| 1193 | 1199 | if (StringUtils.isNotEmpty(jsy) && jsy.indexOf("/") != -1) { |
| 1194 | 1200 | String jGh = jsy.split("/")[0]; |
| 1195 | 1201 | String jName = getPersonName(sch.getGsBm(), jGh); |
| ... | ... | @@ -1978,11 +1984,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1978 | 1984 | int dtbcZ = 0, dtbc_mZ = 0, dtbc_aZ = 0; |
| 1979 | 1985 | int djgZ = 0, djg_mZ = 0, djg_aZ = 0, djg_timeZ = 0; |
| 1980 | 1986 | Map<String, Object> map = null; |
| 1981 | - | |
| 1987 | + | |
| 1982 | 1988 | double xgssgl=0,xgljgl=0,lj=0,cj=0; |
| 1983 | 1989 | for (int i = 0; i < list.size(); i++) { |
| 1984 | 1990 | ScheduleRealInfo scheduleRealInfo = list.get(i); |
| 1985 | - | |
| 1991 | + | |
| 1986 | 1992 | if (scheduleRealInfo != null) { |
| 1987 | 1993 | Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); |
| 1988 | 1994 | //计算实际里程,少驶里程,计划里程=实际里程+少驶里程 |
| ... | ... | @@ -1993,7 +1999,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1993 | 1999 | if (childTaskPlans.isEmpty()) { |
| 1994 | 2000 | tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); |
| 1995 | 2001 | jhlcOrig = scheduleRealInfo.getJhlcOrig() == null ? 0 : scheduleRealInfo.getJhlcOrig(); |
| 1996 | - | |
| 2002 | + | |
| 1997 | 2003 | if(jhlcOrig-tempJhlc>0){ |
| 1998 | 2004 | xgssgl +=jhlcOrig-tempJhlc; |
| 1999 | 2005 | cj += jhlcOrig-tempJhlc; |
| ... | ... | @@ -2005,8 +2011,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2005 | 2011 | if (scheduleRealInfo.isSflj()) { |
| 2006 | 2012 | ljgl += tempJhlc; |
| 2007 | 2013 | ljglZ += tempJhlc; |
| 2008 | - } | |
| 2009 | - | |
| 2014 | + } | |
| 2015 | + | |
| 2010 | 2016 | if (scheduleRealInfo.getStatus() == -1) { |
| 2011 | 2017 | ssgl += tempJhlc; |
| 2012 | 2018 | ssglZ += tempJhlc; |
| ... | ... | @@ -2771,7 +2777,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2771 | 2777 | for(ScheduleRealInfo info:listInfo){ |
| 2772 | 2778 | for(ScheduleRealInfo total:listTotal){ |
| 2773 | 2779 | if(info.getjGh().equals(total.getjGh()) && info.getLpName().equals(total.getLpName()) && info.getClZbh().equals(total.getClZbh())){ |
| 2774 | - | |
| 2780 | + | |
| 2775 | 2781 | } |
| 2776 | 2782 | } |
| 2777 | 2783 | }*/ |
| ... | ... | @@ -2867,7 +2873,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2867 | 2873 | for(ScheduleRealInfo info:listInfo){ |
| 2868 | 2874 | for(ScheduleRealInfo total:listTotal){ |
| 2869 | 2875 | if(info.getjGh().equals(total.getjGh()) && info.getLpName().equals(total.getLpName()) && info.getClZbh().equals(total.getClZbh())){ |
| 2870 | - | |
| 2876 | + | |
| 2871 | 2877 | } |
| 2872 | 2878 | } |
| 2873 | 2879 | }*/ |
| ... | ... | @@ -2944,7 +2950,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2944 | 2950 | fage = false; |
| 2945 | 2951 | } |
| 2946 | 2952 | listS.add(scheduleRealInfo); |
| 2947 | - | |
| 2953 | + | |
| 2948 | 2954 | /* if (scheduleRealInfo != null) { |
| 2949 | 2955 | //计划里程(主任务过滤掉临加班次), |
| 2950 | 2956 | //烂班里程(主任务烂班), |
| ... | ... | @@ -2960,7 +2966,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2960 | 2966 | || scheduleRealInfo.getBcType().equals("out"))) { |
| 2961 | 2967 | jhlc =Arith.add(jhlc,tempJhlc); |
| 2962 | 2968 | } |
| 2963 | - | |
| 2969 | + | |
| 2964 | 2970 | if (scheduleRealInfo.getStatus() == -1) { |
| 2965 | 2971 | remMileage =Arith.add(remMileage,tempJhlc); |
| 2966 | 2972 | } |
| ... | ... | @@ -3046,7 +3052,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3046 | 3052 | ScheduleRealInfo sch; |
| 3047 | 3053 | //BiMap<String, String> map = BasicData.deviceId2NbbmMap.inverse(); |
| 3048 | 3054 | |
| 3049 | - String jGh,jName,sGh,sName; | |
| 3055 | + String jGh = null,jName,sGh,sName; | |
| 3050 | 3056 | for (ChangePersonCar cpc : cpcs) { |
| 3051 | 3057 | |
| 3052 | 3058 | sch = dayOfSchedule.get(cpc.getSchId()); |
| ... | ... | @@ -3067,6 +3073,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3067 | 3073 | rs.put("status", ResponseCode.ERROR); |
| 3068 | 3074 | return rs; |
| 3069 | 3075 | } |
| 3076 | + } | |
| 3077 | + | |
| 3078 | + //为换人换车情况表写入数据 | |
| 3079 | + schModifyLog.saveChangetochange(sch, cpc); | |
| 3080 | + | |
| 3081 | + if (StringUtils.isNotEmpty(cpc.getJsy())) { | |
| 3070 | 3082 | //换驾驶员 |
| 3071 | 3083 | persoChange(sch, jGh); |
| 3072 | 3084 | set.add(sch); | ... | ... |