退休人员定时任务

This commit is contained in:
mash 2023-10-30 15:20:10 +08:00
parent 1e20050371
commit 608709d2d4
3 changed files with 13 additions and 6 deletions

View File

@ -1,17 +1,20 @@
package com.ydool.platform.mybatis.handler;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
@Component
@Slf4j
public class CustomMetaObjectHandler implements MetaObjectHandler {
/**
* 插入时的填充策略
*
@ -19,9 +22,10 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
*/
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createdId", StpUtil.getLoginIdAsString(), metaObject);
// this.setFieldValByName("createdId", StpUtil.getLoginIdAsString(), metaObject);
this.setFieldValByName("createdAt", LocalDateTime.now(), metaObject);
this.setFieldValByName("updatedId", StpUtil.getLoginIdAsString(), metaObject);
// this.setFieldValByName("updatedId", StpUtil.getLoginIdAsString(), metaObject);
this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject);
}
@ -32,7 +36,7 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
*/
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updatedId", StpUtil.getLoginIdAsString(), metaObject);
// this.setFieldValByName("updatedId", StpUtil.getLoginIdAsString(), metaObject);
this.setFieldValByName("updatedAt", LocalDateTime.now(), metaObject);
}

View File

@ -128,7 +128,7 @@ public class PersonnelController extends BaseController {
@GetMapping("getPersonnelRetire")
@ApiOperation(value = "查看近两月是否有人退休")
//@Scheduled(cron = "0 0 7 * * ?") /*每天7点更新一次*/
//@Scheduled(cron = "0 */1 * * * ?") /*每天7点更新一次*/
@Scheduled(cron = "0 */1 * * * ?") /*每天7点更新一次*/
public void getPersonnelRetire(){
personnelService.getPersonnelRetire();
}

View File

@ -59,8 +59,11 @@ import com.ydool.system.mapper.ConfigMapper;
import com.ydool.system.mapper.DeptMapper;
import com.ydool.system.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.multipart.MultipartFile;
import org.thymeleaf.util.StringUtils;
import javax.annotation.Resource;
@ -73,6 +76,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@ -817,7 +821,6 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
}
}
}
}
}