Commit d4acd1aa200b3f65dba344035fd4538e6c2ee244

Authored by guzijian
1 parent 8add210f

feat: 补签优化,之前限定时间是两天内现在限定补签为当月内

Bsth-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
@@ -42,7 +42,7 @@ public class SchedulingCache { @@ -42,7 +42,7 @@ public class SchedulingCache {
42 42
43 public SchedulingCache() { 43 public SchedulingCache() {
44 log.info("项目启动加载中获取实时班次并存入缓存-----"); 44 log.info("项目启动加载中获取实时班次并存入缓存-----");
45 - schedulingInit(); 45 +// schedulingInit();
46 } 46 }
47 47
48 48
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
@@ -267,7 +267,12 @@ public class SignInServiceImpl implements ISignInService { @@ -267,7 +267,12 @@ public class SignInServiceImpl implements ISignInService {
267 if (Objects.isNull(driver)) return AjaxResult.warn("这个工号的员工不存在!"); 267 if (Objects.isNull(driver)) return AjaxResult.warn("这个工号的员工不存在!");
268 GlobalIndex globalIndex = new GlobalIndex(); 268 GlobalIndex globalIndex = new GlobalIndex();
269 long now = signIn.getCreateTime().getTime(); 269 long now = signIn.getCreateTime().getTime();
270 - List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now); 270 +// List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
  271 + // 只能补签当月
  272 + if (checkSupplementarySignatureTime(signIn.getCreateTime())) {
  273 + throw new RuntimeException("只能对当前月的数据进行补签!");
  274 + }
  275 + List<DriverScheduling> dto = schedulingMapper.queryToDay(ConstDateUtil.formatDate("yyyy-MM-dd",signIn.getCreateTime()),null,driver.getJobCode(),null);
271 handleSignBody(signIn, driver, globalIndex, now, dto); 276 handleSignBody(signIn, driver, globalIndex, now, dto);
272 signIn.setUpdateBy(SecurityUtils.getUsername()); 277 signIn.setUpdateBy(SecurityUtils.getUsername());
273 signIn.setRemark("补签"); 278 signIn.setRemark("补签");
@@ -285,6 +290,15 @@ public class SignInServiceImpl implements ISignInService { @@ -285,6 +290,15 @@ public class SignInServiceImpl implements ISignInService {
285 return AjaxResult.success("补签成功"); 290 return AjaxResult.success("补签成功");
286 } 291 }
287 292
  293 + private boolean checkSupplementarySignatureTime(Date createTime) {
  294 + String date = ConstDateUtil.formatDate("yyyy-MM", createTime);
  295 + String now = ConstDateUtil.formatDate("yyyy-MM", new Date());
  296 + if (date.equals(now)){
  297 + return false;
  298 + }
  299 + return true;
  300 + }
  301 +
288 @Override 302 @Override
289 public List<SignInResponseVo> selectSignInByIds(List<Long> collect) { 303 public List<SignInResponseVo> selectSignInByIds(List<Long> collect) {
290 if (CollectionUtil.isEmpty(collect)) { 304 if (CollectionUtil.isEmpty(collect)) {
Bsth-admin/src/main/test/com.ruoyi/Demo.java
1 package com.ruoyi; 1 package com.ruoyi;
2 2
  3 +import com.ruoyi.driver.domain.Driver;
  4 +
3 import java.util.ArrayList; 5 import java.util.ArrayList;
4 import java.util.Arrays; 6 import java.util.Arrays;
5 import java.util.List; 7 import java.util.List;
  8 +import java.util.Map;
  9 +import java.util.stream.Collectors;
6 10
7 public class Demo { 11 public class Demo {
8 public static void main(String[] args) { 12 public static void main(String[] args) {
9 - List<String> list = new ArrayList<>(Arrays.asList("123","2314"));  
10 - list.stream().filter(item->item.equals("123")).forEach(System.out::println); 13 +// List<String> list = new ArrayList<>(Arrays.asList("123","2314"));
  14 +// list.stream().filter(item->item.equals("123")).forEach(System.out::println);
  15 + List<Driver> list = new ArrayList<>();
  16 + Map<String, Driver> collect = list.stream().collect(Collectors.toMap(Driver::getJobCode, driver -> driver));
  17 + System.out.println(collect);
11 } 18 }
12 } 19 }
13 20