Commit f22dd4a469593778ed3e912342c87627c196738e
1 parent
772893f3
优化签到流程
Showing
10 changed files
with
130 additions
and
80 deletions
Bsth-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
| ... | ... | @@ -3,25 +3,28 @@ package com.ruoyi.common.cache; |
| 3 | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 4 | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | 5 | import com.ruoyi.common.utils.StringUtils; |
| 6 | +import com.ruoyi.domain.DriverScheduling; | |
| 6 | 7 | import com.ruoyi.driver.mapper.DriverSchedulingMapper; |
| 7 | 8 | import com.ruoyi.errorScheduling.domain.ErrorJobcode; |
| 8 | 9 | import com.ruoyi.errorScheduling.service.IErrorJobcodeService; |
| 9 | 10 | import com.ruoyi.in.domain.SignIn; |
| 10 | -import com.ruoyi.domain.DriverScheduling; | |
| 11 | +import com.ruoyi.service.BigViewServiceV1; | |
| 11 | 12 | import com.ruoyi.service.ThreadJobService; |
| 12 | 13 | import com.ruoyi.utils.ConstDateUtil; |
| 13 | -import lombok.extern.slf4j.Slf4j; | |
| 14 | 14 | import org.apache.commons.collections4.CollectionUtils; |
| 15 | 15 | import org.slf4j.Logger; |
| 16 | 16 | import org.slf4j.LoggerFactory; |
| 17 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | 18 | import org.springframework.stereotype.Component; |
| 18 | -import org.springframework.stereotype.Service; | |
| 19 | 19 | |
| 20 | 20 | import java.util.*; |
| 21 | 21 | import java.util.concurrent.ConcurrentHashMap; |
| 22 | 22 | |
| 23 | 23 | @Component |
| 24 | 24 | public class NowSchedulingCache { |
| 25 | + @Autowired | |
| 26 | + private BigViewServiceV1 bigViewServiceV1; | |
| 27 | + | |
| 25 | 28 | private final DriverSchedulingMapper schedulingMapper; |
| 26 | 29 | static Logger log = LoggerFactory.getLogger(SchedulingCache.class); |
| 27 | 30 | /** |
| ... | ... | @@ -151,17 +154,43 @@ public class NowSchedulingCache { |
| 151 | 154 | * @param index |
| 152 | 155 | * @param signIn |
| 153 | 156 | */ |
| 154 | - public void updateCacheByJobCode(String remark, String key, Integer index, SignIn signIn) { | |
| 157 | + public void updateCacheByJobCode(String remark, String key, Integer index, SignIn signIn,boolean isNew,DriverScheduling sourceScheduling) { | |
| 158 | + if(isNew && Objects.nonNull(sourceScheduling)){ | |
| 159 | + if(Objects.isNull(cacheNowDayScheduling.get(key))){ | |
| 160 | + return; | |
| 161 | + } | |
| 162 | + | |
| 163 | + int size = CollectionUtils.size(cacheNowDayScheduling.get(key).get(signIn.getJobCode())); | |
| 164 | + for (int i = 0; i < size; i++) { | |
| 165 | + if(Objects.equals(cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(i).getId(),sourceScheduling.getId())){ | |
| 166 | + index = i; | |
| 167 | + break; | |
| 168 | + } | |
| 169 | + } | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + } | |
| 155 | 175 | if (key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(0))) |
| 156 | 176 | || key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)))) { |
| 157 | 177 | DriverScheduling scheduling = cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(index); |
| 158 | 178 | scheduling.setSignInId(signIn.getId()); |
| 159 | 179 | scheduling.setRemark(remark); |
| 160 | - scheduling.setExType(signIn.getExType()); | |
| 180 | + | |
| 181 | + Integer exType = signIn.getExType(); | |
| 182 | + if(isNew){ | |
| 183 | + exType = bigViewServiceV1.isSignStatusWineEnum(signIn)?3:bigViewServiceV1.isSignStatusDelayEnum(signIn)?1:Objects.equals(2,signIn.getExType())?2:0; | |
| 184 | + } | |
| 185 | + scheduling.setExType(exType); | |
| 161 | 186 | scheduling.setSignTime(signIn.getCreateTime()); |
| 162 | 187 | scheduling.setSignType(signIn.getType()); |
| 163 | 188 | scheduling.setAlcoholFlag(signIn.getAlcoholFlag()); |
| 164 | 189 | scheduling.setAlcoholIntake(signIn.getAlcoholIntake()); |
| 190 | + | |
| 191 | + | |
| 192 | + cacheNowDayScheduling.get(key).get(signIn.getJobCode()).set(index,scheduling); | |
| 165 | 193 | } |
| 166 | 194 | } |
| 195 | + | |
| 167 | 196 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/domain/DriverSchedulingV1.java
| 1 | 1 | package com.ruoyi.domain; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 3 | 4 | import com.baomidou.mybatisplus.annotation.TableName; |
| 5 | +import lombok.Data; | |
| 4 | 6 | |
| 5 | 7 | /** |
| 6 | 8 | * @author liujun |
| 7 | 9 | * @date 2024年09月23日 15:36 |
| 8 | 10 | */ |
| 9 | 11 | @TableName("scheduling") |
| 12 | +@Data | |
| 10 | 13 | public class DriverSchedulingV1 extends DriverScheduling { |
| 14 | + @TableField(exist = false) | |
| 15 | + private Integer index; | |
| 11 | 16 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| ... | ... | @@ -450,10 +450,12 @@ public class DriverServiceImpl implements IDriverService { |
| 450 | 450 | vo = DriverResponseVo.createDriverResponseVo(recommendation.getTimestamps(), driver, SIGN_IN_OUT_STRING, !alcoholFlag, schedulingFlag, recommendation.getNbbm(), recommendation.getLpName(), recommendation.getLineName()); |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | + | |
| 453 | 454 | // 如果驾驶员酒精测试在之前不合格 必须重测 |
| 454 | - if ("驾驶员".equals(driver.getPosts())) { | |
| 455 | + if ("驾驶员".equals(driver.getPosts()) && BC_TYPE_OUT.equals(recommendation.getBcType())) { | |
| 455 | 456 | String key = REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW + ConstDateUtil.formatDate("yyyyMMdd") + ":" + driver.getJobCode(); |
| 456 | 457 | Integer count = redisCache.getCacheObject(key); |
| 458 | + log.info("key:[{}],count:[{}]",key,count); | |
| 457 | 459 | if (!Objects.isNull(count) && !Objects.isNull(vo)) { |
| 458 | 460 | vo.setCheckAlcohol(alcoholFlag); |
| 459 | 461 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/controller/SignInController.java
| ... | ... | @@ -12,13 +12,10 @@ import com.ruoyi.in.domain.SignIn; |
| 12 | 12 | import com.ruoyi.in.service.ISignInService; |
| 13 | 13 | import com.ruoyi.in.service.SignInServiceV1; |
| 14 | 14 | import com.ruoyi.pojo.response.SignInResponseVo; |
| 15 | -import com.ruoyi.utils.ConstDateUtil; | |
| 16 | 15 | import io.swagger.annotations.Api; |
| 17 | 16 | import io.swagger.annotations.ApiOperation; |
| 18 | 17 | import io.swagger.annotations.ApiParam; |
| 19 | 18 | import lombok.extern.slf4j.Slf4j; |
| 20 | -import org.apache.commons.lang3.RandomUtils; | |
| 21 | -import org.apache.commons.lang3.StringUtils; | |
| 22 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | 20 | import org.springframework.validation.annotation.Validated; |
| 24 | 21 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -26,13 +23,7 @@ import org.springframework.web.bind.annotation.*; |
| 26 | 23 | import javax.servlet.http.HttpServletRequest; |
| 27 | 24 | import javax.servlet.http.HttpServletResponse; |
| 28 | 25 | import java.io.IOException; |
| 29 | -import java.text.MessageFormat; | |
| 30 | -import java.util.Date; | |
| 31 | 26 | import java.util.List; |
| 32 | -import java.util.Objects; | |
| 33 | -import java.util.concurrent.TimeUnit; | |
| 34 | - | |
| 35 | -import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW; | |
| 36 | 27 | |
| 37 | 28 | /** |
| 38 | 29 | * 签到Controller |
| ... | ... | @@ -110,36 +101,36 @@ public class SignInController extends BaseController { |
| 110 | 101 | @PostMapping("/newAdd") |
| 111 | 102 | @ApiOperation("新增签到(设备传入)") |
| 112 | 103 | public AjaxResult addSignIn(@ApiParam @RequestBody @Validated SignIn signIn) throws FileUploadException, IOException { |
| 113 | - String key = MessageFormat.format("sign:assignment:{0}", signIn.getJobCode()); | |
| 114 | - if (redisCache.hasKey(key)) { | |
| 115 | - log.info(" sing method old sign :[{}]", signIn); | |
| 116 | - return signInService.addSignIn(signIn); | |
| 117 | - } | |
| 118 | - | |
| 119 | - Integer num = RandomUtils.nextInt(0, 10); | |
| 120 | - if (num < 3) { | |
| 121 | - redisCache.setCacheObject(key, num, 5, TimeUnit.MINUTES); | |
| 122 | - log.info("[{}] sing method 走新的签到方式 :[{}] ", num, signIn); | |
| 123 | - key = StringUtils.join(REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW, ConstDateUtil.FAST_YYYY_MM_DD.format(new Date()), ":", signIn.getJobCode()); | |
| 124 | - Integer count = redisCache.getCacheObject(key); | |
| 125 | - try { | |
| 104 | +// String key = MessageFormat.format("sign:assignment:{0}", signIn.getJobCode()); | |
| 105 | +// if (redisCache.hasKey(key)) { | |
| 106 | +// log.info(" sing method old sign :[{}]", signIn); | |
| 107 | +// return signInService.addSignIn(signIn); | |
| 108 | +// } | |
| 109 | +// | |
| 110 | +// Integer num = RandomUtils.nextInt(0, 10); | |
| 111 | +// if (num < 3) { | |
| 112 | +// redisCache.setCacheObject(key, num, 5, TimeUnit.MINUTES); | |
| 113 | +// log.info("[{}] sing method 走新的签到方式 :[{}] ", num, signIn); | |
| 114 | +// key = StringUtils.join(REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW, ConstDateUtil.FAST_YYYY_MM_DD.format(new Date()), ":", signIn.getJobCode()); | |
| 115 | +// Integer count = redisCache.getCacheObject(key); | |
| 116 | +// try { | |
| 126 | 117 | return signInServiceV1.addsignInV1(signIn); |
| 127 | - } catch (Exception e) { | |
| 128 | - if (Objects.isNull(count)) { | |
| 129 | - count = 0; | |
| 130 | - } else { | |
| 131 | - count = count - 1; | |
| 132 | - } | |
| 133 | - if (redisCache.hasKey(key)) { | |
| 134 | - redisCache.setCacheObject(key, count, 1, TimeUnit.DAYS); | |
| 135 | - } | |
| 136 | - log.error("[{}] sing method 走新的签到方式,签到失败 :[{}]", num, signIn, e); | |
| 137 | - } | |
| 138 | - | |
| 139 | - } | |
| 140 | - | |
| 141 | - log.info("[{}] sing method old sign :[{}]", num, signIn); | |
| 142 | - return signInService.addSignIn(signIn); | |
| 118 | +// } catch (Exception e) { | |
| 119 | +// if (Objects.isNull(count) || count < 1) { | |
| 120 | +// count = 0; | |
| 121 | +// } else { | |
| 122 | +// count = count - 1; | |
| 123 | +// } | |
| 124 | +// if (redisCache.hasKey(key)) { | |
| 125 | +// redisCache.setCacheObject(key, count, 1, TimeUnit.DAYS); | |
| 126 | +// } | |
| 127 | +// log.error("[{}] sing method 走新的签到方式,签到失败 :[{}]", num, signIn, e); | |
| 128 | +// } | |
| 129 | +// | |
| 130 | +// } | |
| 131 | + | |
| 132 | +// log.info("[{}] sing method old sign :[{}]", num, signIn); | |
| 133 | +// return signInService.addSignIn(signIn); | |
| 143 | 134 | } |
| 144 | 135 | |
| 145 | 136 | // /** | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/domain/CalDriverScheduling.java
| 1 | 1 | package com.ruoyi.in.domain; |
| 2 | 2 | |
| 3 | 3 | import com.ruoyi.domain.DriverScheduling; |
| 4 | +import com.ruoyi.domain.DriverSchedulingV1; | |
| 4 | 5 | import lombok.Data; |
| 5 | 6 | |
| 7 | +import java.util.Objects; | |
| 8 | + | |
| 6 | 9 | /** |
| 7 | 10 | * @author liujun |
| 8 | 11 | * @date 2024年09月23日 11:29 |
| ... | ... | @@ -17,4 +20,9 @@ public class CalDriverScheduling { |
| 17 | 20 | this.index = index; |
| 18 | 21 | this.driverScheduling = driverScheduling; |
| 19 | 22 | } |
| 23 | + | |
| 24 | + public CalDriverScheduling(DriverSchedulingV1 driverScheduling) { | |
| 25 | + this.index = Objects.isNull(driverScheduling) ? null : driverScheduling.getIndex(); | |
| 26 | + this.driverScheduling = driverScheduling; | |
| 27 | + } | |
| 20 | 28 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/domain/SignIn.java
| ... | ... | @@ -92,7 +92,7 @@ public class SignIn extends BaseEntity { |
| 92 | 92 | @Excel(name = "酒精摄入量") |
| 93 | 93 | @ApiModelProperty("酒精摄入量 52.12") |
| 94 | 94 | private BigDecimal alcoholIntake; |
| 95 | - @Excel(name = "异常类型",readConverterExp = "0=无异常,1=超时异常,2=无排班异常,3=酒精超标异常,200=早签,300=迟到") | |
| 95 | + @Excel(name = "异常类型",readConverterExp = "0=无异常,1=超时异常,2=无排班异常,3=酒精超标异常,20=早签,30=迟到") | |
| 96 | 96 | @ApiModelProperty("异常类型") |
| 97 | 97 | private Integer exType; |
| 98 | 98 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
| ... | ... | @@ -155,6 +155,7 @@ public class SignInServiceImpl implements ISignInService { |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | @Override |
| 158 | + @Transactional(rollbackFor = Exception.class) | |
| 158 | 159 | public AjaxResult addSignIn(SignIn signIn) throws IOException { |
| 159 | 160 | // 查询员工信息 |
| 160 | 161 | Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode()); |
| ... | ... | @@ -170,16 +171,7 @@ public class SignInServiceImpl implements ISignInService { |
| 170 | 171 | List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now); |
| 171 | 172 | handleSignBody(signIn, driver, globalIndex, now, dto); |
| 172 | 173 | |
| 173 | - | |
| 174 | - if (CollectionUtils.isNotEmpty(dto)) { | |
| 175 | - int size = CollectionUtils.size(dto); | |
| 176 | - if (size > 0 && globalIndex.getIndex() < size) { | |
| 177 | - log.info("签到签退数据为:[{}]", dto.get(globalIndex.getIndex())); | |
| 178 | - } | |
| 179 | - } else { | |
| 180 | - log.info("没有签到或签退的数据"); | |
| 181 | - } | |
| 182 | - if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && CollectionUtils.isNotEmpty(dto) && Objects.equals(dto.get(globalIndex.getIndex()).getBcType(), BC_TYPE_OUT)) { | |
| 174 | + if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && CollectionUtils.isNotEmpty(dto) && Objects.nonNull(dto.get(globalIndex.getIndex())) && Objects.equals(dto.get(globalIndex.getIndex()).getBcType(), BC_TYPE_OUT)) { | |
| 183 | 175 | AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo); |
| 184 | 176 | if (!Objects.isNull(result)) { |
| 185 | 177 | String msg = "签到异常: 请使用手持式酒精测试棒进行酒测"; |
| ... | ... | @@ -191,7 +183,7 @@ public class SignInServiceImpl implements ISignInService { |
| 191 | 183 | uploadImage(signIn, vo); |
| 192 | 184 | signInMapper.insertSignIn(signIn); |
| 193 | 185 | // 更新考勤 |
| 194 | - schedulingService.computedSignInBySignIn(dto, signIn, globalIndex); | |
| 186 | + schedulingService.computedSignInBySignIn(dto, signIn, globalIndex,false,null); | |
| 195 | 187 | |
| 196 | 188 | if (TempCache.checkJobCodeExist(signIn.getJobCode())) { |
| 197 | 189 | TempCache.updateSignStatus(signIn.getJobCode()); |
| ... | ... | @@ -302,7 +294,7 @@ public class SignInServiceImpl implements ISignInService { |
| 302 | 294 | if (CollectionUtil.isNotEmpty(dto)) { |
| 303 | 295 | schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType(), signIn.getCreateTime(), signIn.getRemark(), signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 304 | 296 | // 更新缓存 |
| 305 | - nowSchedulingCache.updateCacheByJobCode(signIn.getRemark(), ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn); | |
| 297 | + nowSchedulingCache.updateCacheByJobCode(signIn.getRemark(), ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn,false,null); | |
| 306 | 298 | } |
| 307 | 299 | |
| 308 | 300 | // 异常保存到异常异常中 |
| ... | ... | @@ -362,7 +354,7 @@ public class SignInServiceImpl implements ISignInService { |
| 362 | 354 | for (SignInResponseVo sign : value) { |
| 363 | 355 | GlobalIndex globalIndex = new GlobalIndex(); |
| 364 | 356 | checkSignIn(sign.getCreateTime().getTime(), resultMap.get(sign.getJobCode()), globalIndex, sign, drivers.get(sign.getJobCode())); |
| 365 | - schedulingService.computedSignInBySignIn(resultMap.get(sign.getJobCode()), sign, globalIndex); | |
| 357 | + schedulingService.computedSignInBySignIn(resultMap.get(sign.getJobCode()), sign, globalIndex,false,null); | |
| 366 | 358 | } |
| 367 | 359 | } |
| 368 | 360 | } |
| ... | ... | @@ -387,9 +379,9 @@ public class SignInServiceImpl implements ISignInService { |
| 387 | 379 | for (SignIn signIn : signInList) { |
| 388 | 380 | handlerExOutData(transformMap.get(signIn.getJobCode()), signIn); |
| 389 | 381 | |
| 390 | - schedulingService.computedSignInBySignIn(new ArrayList<>(Arrays.asList(transformMap.get(signIn.getJobCode()))), signIn, new GlobalIndex()); | |
| 382 | + schedulingService.computedSignInBySignIn(new ArrayList<>(Arrays.asList(transformMap.get(signIn.getJobCode()))), signIn, new GlobalIndex(),false,null); | |
| 391 | 383 | // // 更新缓存 |
| 392 | - nowSchedulingCache.updateCacheByJobCode(signIn.getRemark(), ConstDateUtil.formatDate(transformMap.get(signIn.getJobCode()).getScheduleDate()), 0, signIn); | |
| 384 | + nowSchedulingCache.updateCacheByJobCode(signIn.getRemark(), ConstDateUtil.formatDate(transformMap.get(signIn.getJobCode()).getScheduleDate()), 0, signIn,false,null); | |
| 393 | 385 | signInMapper.updateSignIn(signIn); |
| 394 | 386 | |
| 395 | 387 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceV1Impl.java
| ... | ... | @@ -40,13 +40,13 @@ import org.apache.commons.lang3.time.FastDateFormat; |
| 40 | 40 | import org.springframework.beans.BeanUtils; |
| 41 | 41 | import org.springframework.beans.factory.annotation.Autowired; |
| 42 | 42 | import org.springframework.stereotype.Service; |
| 43 | +import org.springframework.transaction.annotation.Transactional; | |
| 43 | 44 | |
| 44 | 45 | import javax.annotation.Resource; |
| 45 | 46 | import java.io.File; |
| 46 | 47 | import java.io.IOException; |
| 47 | 48 | import java.math.BigDecimal; |
| 48 | 49 | import java.util.*; |
| 49 | -import java.util.concurrent.atomic.AtomicInteger; | |
| 50 | 50 | |
| 51 | 51 | import static com.ruoyi.common.ConstSignInConstSignInProperties.*; |
| 52 | 52 | import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_ERROR; |
| ... | ... | @@ -79,6 +79,7 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 79 | 79 | private static final FastDateFormat HHMM = FastDateFormat.getInstance("HH:mm"); |
| 80 | 80 | |
| 81 | 81 | @Override |
| 82 | + @Transactional(rollbackFor = Exception.class) | |
| 82 | 83 | public AjaxResult addsignInV1(SignIn signIn) throws IOException { |
| 83 | 84 | |
| 84 | 85 | SignInV1 signInV1 = new SignInV1(); |
| ... | ... | @@ -141,6 +142,7 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 141 | 142 | switchAndChooseAlcohol(signIn, driver, scheduling); |
| 142 | 143 | |
| 143 | 144 | } else { |
| 145 | + log.info("签到的数据为:[{}]",scheduling); | |
| 144 | 146 | SignInV1 sourceSign = getById(scheduling.getSignInId()); |
| 145 | 147 | if (Objects.nonNull(sourceSign)) { |
| 146 | 148 | switchAndChooseTime(signIn, scheduling, dateTime); |
| ... | ... | @@ -154,7 +156,7 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 154 | 156 | signInMapper.insertSignIn(signIn); |
| 155 | 157 | // 更新考勤 |
| 156 | 158 | if (Objects.nonNull(calDriverScheduling)) { |
| 157 | - schedulingService.computedSignInBySignIn(scheduling, calDriverScheduling.getIndex(), signIn); | |
| 159 | + schedulingService.computedSignInBySignIn(scheduling, calDriverScheduling.getIndex(), signIn,true); | |
| 158 | 160 | } |
| 159 | 161 | |
| 160 | 162 | if (TempCache.checkJobCodeExist(signIn.getJobCode())) { |
| ... | ... | @@ -173,7 +175,11 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 173 | 175 | // 酒精测试后续恢复的需要删除异常的酒测缓存 |
| 174 | 176 | BeanUtils.copyProperties(signIn, signInV1); |
| 175 | 177 | if (SIGN_IN_SUCCESS.equals(signIn.getStatus())) { |
| 176 | - String prompt = signIn.getRemark().replace("正常", ""); | |
| 178 | + String prompt = "正常"; | |
| 179 | + if (org.apache.commons.lang3.StringUtils.isNotEmpty(signIn.getRemark())) { | |
| 180 | + prompt = signIn.getRemark().replace("正常", ""); | |
| 181 | + } | |
| 182 | + | |
| 177 | 183 | if (signIn.getType().equals(SIGN_OUT)) { |
| 178 | 184 | return AjaxResult.success(SIGN_OUT_SUCCESS_STRING + "," + prompt, signInV1); |
| 179 | 185 | } else { |
| ... | ... | @@ -207,7 +213,7 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 207 | 213 | Integer extype = Objects.isNull(signIn.getExType()) ? 0 : signIn.getExType(); |
| 208 | 214 | if (checkAlcoholIntake(signIn.getAlcoholIntake())) { |
| 209 | 215 | threadJobService.asyncSendEmail(scheduling, signIn, driver); |
| 210 | - signIn.setRemark(join(signIn.getRemark(), ErrorTypeProperties.ALCOHOL_SIGN_IN_ERROR, signIn.getAlcoholIntake().toString(), "mg/100ml。")); | |
| 216 | + signIn.setRemark(join(signIn.getRemark(), org.apache.commons.lang3.StringUtils.join(ErrorTypeProperties.ALCOHOL_SIGN_IN_ERROR, signIn.getAlcoholIntake().toString(), "mg/100ml。"))); | |
| 211 | 217 | signIn.setExType(extype + ConstSignInConstSignInProperties.SIGN_ALCOHOL_EX_NUM); |
| 212 | 218 | |
| 213 | 219 | signIn.setStatus(ConstSignInConstSignInProperties.SIGN_IN_FAIL); |
| ... | ... | @@ -339,18 +345,21 @@ public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> i |
| 339 | 345 | * @return com.ruoyi.domain.DriverScheduling |
| 340 | 346 | */ |
| 341 | 347 | private CalDriverScheduling findSchedulingByDateTime(List<DriverSchedulingV1> schedulings, long dateTime, String type) { |
| 348 | + int size = CollectionUtils.size(schedulings); | |
| 349 | + for (int i = 0; i < size; i++) { | |
| 350 | + DriverSchedulingV1 s = schedulings.get(i); | |
| 351 | + s.setIndex(i); | |
| 342 | 352 | |
| 343 | - AtomicInteger atomicInteger = new AtomicInteger(-1); | |
| 344 | - Optional<DriverSchedulingV1> optional = schedulings.stream().map(s -> { | |
| 345 | - atomicInteger.addAndGet(1); | |
| 346 | 353 | if (Objects.nonNull(s.getFcsjT()) && org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase(org.apache.commons.lang3.StringUtils.trim(s.getBcType()), type)) { |
| 347 | 354 | s.setMinTime(Math.abs(s.getFcsjT() - dateTime)); |
| 348 | 355 | } else { |
| 349 | 356 | s.setMinTime(Long.MAX_VALUE); |
| 350 | 357 | } |
| 351 | - return s; | |
| 352 | - }).min(Comparator.comparing(DriverScheduling::getMinTime)); | |
| 353 | - return new CalDriverScheduling(atomicInteger.get(), optional.orElse(null)); | |
| 358 | + | |
| 359 | + } | |
| 360 | + | |
| 361 | + Optional<DriverSchedulingV1> optional = schedulings.stream().min(Comparator.comparing(DriverScheduling::getMinTime)); | |
| 362 | + return new CalDriverScheduling(optional.orElse(null)); | |
| 354 | 363 | } |
| 355 | 364 | |
| 356 | 365 | /** | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
| ... | ... | @@ -115,7 +115,7 @@ public class SchedulingService { |
| 115 | 115 | * @param signIn |
| 116 | 116 | * @param globalIndex |
| 117 | 117 | */ |
| 118 | - public void computedSignInBySignIn(List<DriverScheduling> dto, SignIn signIn, GlobalIndex globalIndex) { | |
| 118 | + public void computedSignInBySignIn(List<DriverScheduling> dto, SignIn signIn, GlobalIndex globalIndex, boolean isNew,DriverScheduling sourceScheduling) { | |
| 119 | 119 | // 无排班不记录不在考勤表不更新 |
| 120 | 120 | if (CollectionUtil.isEmpty(dto)) { |
| 121 | 121 | return; |
| ... | ... | @@ -126,12 +126,14 @@ public class SchedulingService { |
| 126 | 126 | if (Objects.isNull(dto.get(globalIndex.getIndex()).getSignInId()) || dto.size() == 1) { |
| 127 | 127 | schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 128 | 128 | // 更新缓存 |
| 129 | - nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn); | |
| 129 | + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn, isNew,sourceScheduling); | |
| 130 | + | |
| 130 | 131 | } |
| 131 | 132 | // 之前的无效 |
| 132 | 133 | else if (!SIGN_NO_EX_NUM.equals(dto.get(globalIndex.getIndex()).getExType())) { |
| 133 | 134 | schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 134 | - nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn); | |
| 135 | + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn, isNew,sourceScheduling); | |
| 136 | + | |
| 135 | 137 | } |
| 136 | 138 | // 之前的有效 |
| 137 | 139 | else { |
| ... | ... | @@ -145,7 +147,7 @@ public class SchedulingService { |
| 145 | 147 | * |
| 146 | 148 | * @param signIn |
| 147 | 149 | */ |
| 148 | - public void computedSignInBySignIn(DriverScheduling driverScheduling, int index, SignIn signIn) { | |
| 150 | + public void computedSignInBySignIn(DriverScheduling driverScheduling, int index, SignIn signIn,boolean isNew) { | |
| 149 | 151 | // 无排班不记录不在考勤表不更新 |
| 150 | 152 | if (Objects.isNull(driverScheduling)) { |
| 151 | 153 | return; |
| ... | ... | @@ -156,21 +158,21 @@ public class SchedulingService { |
| 156 | 158 | if (Objects.isNull(driverScheduling.getSignInId())) { |
| 157 | 159 | schedulingMapper.updateRoster(driverScheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 158 | 160 | // 更新缓存 |
| 159 | - nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn); | |
| 161 | + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn,isNew,driverScheduling); | |
| 160 | 162 | } |
| 161 | 163 | // 之前的无效 |
| 162 | 164 | else if (!SIGN_NO_EX_NUM.equals(driverScheduling.getExType())) { |
| 163 | 165 | schedulingMapper.updateRoster(driverScheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 164 | - nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn); | |
| 166 | + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn,isNew,driverScheduling); | |
| 165 | 167 | } |
| 166 | 168 | // 之前的有效 |
| 167 | 169 | else { |
| 168 | - handlerRecord(driverScheduling, signIn, index); | |
| 170 | + handlerRecord(driverScheduling, signIn, index,isNew); | |
| 169 | 171 | } |
| 170 | 172 | |
| 171 | 173 | } |
| 172 | 174 | |
| 173 | - private void handlerRecord(DriverScheduling scheduling, SignIn signIn, Integer index) { | |
| 175 | + private void handlerRecord(DriverScheduling scheduling, SignIn signIn, Integer index,boolean isNew) { | |
| 174 | 176 | if (Objects.isNull(scheduling)) { |
| 175 | 177 | return; |
| 176 | 178 | } |
| ... | ... | @@ -194,7 +196,7 @@ public class SchedulingService { |
| 194 | 196 | String remark = getRemark(scheduling, signIn); |
| 195 | 197 | signInMapper.updateSignIn(signIn); |
| 196 | 198 | schedulingMapper.updateRoster(scheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 197 | - nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(scheduling.getScheduleDate()), index, signIn); | |
| 199 | + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(scheduling.getScheduleDate()), index, signIn,isNew,scheduling); | |
| 198 | 200 | } |
| 199 | 201 | |
| 200 | 202 | |
| ... | ... | @@ -233,6 +235,13 @@ public class SchedulingService { |
| 233 | 235 | } |
| 234 | 236 | |
| 235 | 237 | if (bigViewServiceV1.isSignStatusWineEnum(signIn) && StringUtils.isNotEmpty(signIn.getRemark())) { |
| 238 | + if(StringUtils.indexOf(scheduling.getRemark(),signIn.getRemark()) > -1){ | |
| 239 | + return scheduling.getRemark(); | |
| 240 | + } | |
| 241 | + | |
| 242 | + if(StringUtils.indexOf(sb.toString(),signIn.getRemark()) > -1){ | |
| 243 | + return sb.toString(); | |
| 244 | + } | |
| 236 | 245 | int index = signIn.getRemark().indexOf(ALCOHOL_SIGN_IN_ERROR); |
| 237 | 246 | if (index != -1) { |
| 238 | 247 | sb.append("," + signIn.getRemark().substring(index)); |
| ... | ... | @@ -279,7 +288,7 @@ public class SchedulingService { |
| 279 | 288 | String remark = getRemark(dto, signIn, index); |
| 280 | 289 | signInMapper.updateSignIn(signIn); |
| 281 | 290 | schedulingMapper.updateRoster(scheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 282 | - nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex() + 1, signIn); | |
| 291 | + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex() + 1, signIn,false,scheduling); | |
| 283 | 292 | } |
| 284 | 293 | |
| 285 | 294 | private Integer bcTypeTransform(String bcType) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/BigViewServiceImpl.java
| ... | ... | @@ -460,10 +460,15 @@ public class BigViewServiceImpl implements BigViewService { |
| 460 | 460 | if (DRIVER_STRING.equals(scheduling.getPosts())) { |
| 461 | 461 | LineInfo.PersonInfoVo driverInfoVo = matchMap.get(nbbm).getDriverInfoVo(); |
| 462 | 462 | if (!Objects.isNull(driverInfoVo)) { |
| 463 | + | |
| 463 | 464 | // 第二次签到时间未到不记录状态 |
| 464 | 465 | if (time - scheduling.getFcsjT() < 0) { |
| 465 | 466 | return; |
| 466 | 467 | } |
| 468 | + | |
| 469 | + if(Objects.isNull(driverInfoVo.getSignStatus()) || Objects.isNull(personInfoVo.getSignStatus())){ | |
| 470 | + return; | |
| 471 | + } | |
| 467 | 472 | // 如有多异常覆盖策略 异常等级排 未签 -》 迟到 -》 酒驾 |
| 468 | 473 | if (driverInfoVo.getSignStatus().compareTo(personInfoVo.getSignStatus()) > 0) { |
| 469 | 474 | return; | ... | ... |