From 9e618c75cc30dbb6d53a2cebfada1584297c4a3d Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 5 Dec 2022 14:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=82=AC=E5=8A=9E=E4=BF=A1=E6=81=AF=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=89=8D=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TRemindersController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/controller/TRemindersController.java b/renren-admin/src/main/java/io/renren/modules/reminders/controller/TRemindersController.java index 7e0b70fd..29a6621f 100644 --- a/renren-admin/src/main/java/io/renren/modules/reminders/controller/TRemindersController.java +++ b/renren-admin/src/main/java/io/renren/modules/reminders/controller/TRemindersController.java @@ -21,11 +21,19 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import org.activiti.engine.TaskService; +import org.activiti.engine.task.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.servlet.http.HttpServletResponse; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.Map; @@ -40,11 +48,17 @@ import java.util.Map; @RequestMapping("reminders/treminders") @Api(tags = "催办信息") public class TRemindersController { + private static final Logger logger = LoggerFactory.getLogger(TRemindersController.class); @Autowired private TRemindersService tRemindersService; @Autowired private SysUserService sysUserService; + @Autowired + protected TaskService taskService; + + @Value("${reminders.interval:7}") // 流程发起后多少天允许催办 + private Integer interval; @GetMapping("page") @ApiOperation("分页") @@ -72,8 +86,28 @@ public class TRemindersController { @ApiOperation("保存") @LogOperation("保存") public Result save(@RequestBody TRemindersDTO dto) { + Task task = taskService.createTaskQuery().taskId(dto.getProcessTaskId().toString()).includeProcessVariables().singleResult(); + LocalDate taskCreateDate = task.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + long between = ChronoUnit.DAYS.between(taskCreateDate, LocalDate.now()); + if (between <= interval) { + logger.info("该任务未到允许催办的日期"); + return new Result().error("该任务未到允许催办的日期"); + } + LocalDate localDate = tRemindersService.selectRemindersTime(dto.getProcessTaskId().toString()); + if (localDate == null) { // 未进行过催办 + logger.info("允许催办"); + } else { // 进行过催办 + between = ChronoUnit.DAYS.between(localDate, LocalDate.now()); // 上次催办距离今天已过天数 + if (between <= interval) { // 间隔天数小于限制天数 + logger.info("该任务已催办但未到允许再次发起催办时间"); + return new Result().error("该任务已催办但未到允许再次发起催办时间"); + } else { + logger.info("允许催办"); + } + } UserDetail user = SecurityUser.getUser(); SysUserDTO userDTO = sysUserService.get(user.getId()); + dto.setProcessTaskStats(1); dto.setSponsor(userDTO); //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);