流程内催办条件的判断

This commit is contained in:
wangliwen 2022-12-01 14:21:44 +08:00
parent 43441e4212
commit 86c0f106ff
7 changed files with 116 additions and 16 deletions

View File

@ -91,4 +91,14 @@ public class ProcessInstanceDTO {
@ApiModelProperty(value = "申请单号") @ApiModelProperty(value = "申请单号")
private String applyNumber; private String applyNumber;
/**
* 催办功能增加字段
*/
@ApiModelProperty(value = "该流程的节点当前是否允许催办")
private Boolean allowReminders;
@ApiModelProperty(value = "该流程的节点当前是否已经进行过催办")
private Boolean doneReminders;
@ApiModelProperty(value = "该流程的节点需几天后进行催办")
private Integer nextRemindersDays;
} }

View File

@ -12,6 +12,7 @@ import io.renren.modules.demandComment.entity.TDemandCommentEntityDelFlag;
import io.renren.modules.demandComment.service.TDemandCommentService; import io.renren.modules.demandComment.service.TDemandCommentService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.reminders.service.TRemindersService;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO; import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
@ -37,12 +38,15 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.InputStream; import java.io.InputStream;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -92,6 +96,11 @@ public class ActHistoryService {
@Autowired @Autowired
private ProcessEngine processEngine_; private ProcessEngine processEngine_;
@Autowired
private TRemindersService tRemindersService;
@Value("${reminders.interval:7}") // 流程发起后多少天允许催办
private Integer interval;
public void getProcessInstanceDiagram(String processInstanceId, HttpServletResponse response) throws Exception { public void getProcessInstanceDiagram(String processInstanceId, HttpServletResponse response) throws Exception {
if (StringUtils.isEmpty(processInstanceId)) { if (StringUtils.isEmpty(processInstanceId)) {
@ -375,10 +384,42 @@ public class ActHistoryService {
.filter(Objects::nonNull) .filter(Objects::nonNull)
.filter(index -> null != index.getName() && index.getName().contains(params.get("name").toString())) .filter(index -> null != index.getName() && index.getName().contains(params.get("name").toString()))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<ProcessInstanceDTO> list2 = list1.stream().skip((Integer.parseInt(page) - 1) * Integer.parseInt(limit)).limit(Integer.parseInt(limit)).collect(Collectors.toList()); List<ProcessInstanceDTO> list2 = list1.stream().skip((Integer.parseInt(page) - 1) * Integer.parseInt(limit))
.limit(Integer.parseInt(limit)).collect(Collectors.toList());
pageData.setTotal(list1.size()); pageData.setTotal(list1.size());
pageData.setList(list2); pageData.setList(list2);
} }
/**
* 处理催办相关条件数据
*/
pageData.setList(pageData.getList().stream().map(index -> {
Optional<Task> nowTask = taskService.createTaskQuery().processInstanceId(index.getProcessInstanceId())
.orderByTaskCreateTime().desc().active().list().stream().findFirst(); // 尝试获取当前task
if (nowTask.isPresent()) { // 存在正在进行的任务
LocalDate localDate = tRemindersService.selectRemindersTime(nowTask.get().getId());
if (localDate == null) {// 未进行过催办
index.setAllowReminders(Boolean.TRUE); // 允许催办
index.setDoneReminders(Boolean.FALSE); // 不存在催办记录
index.setNextRemindersDays(0); // 距离下次催办天数为0
} else { // 进行过催办
long between = ChronoUnit.DAYS.between(localDate, LocalDate.now()); // 上次催办距离今天已过天数
if (between <= interval) { // 间隔天数小于限制天数
index.setAllowReminders(Boolean.FALSE); // 不允许催办
index.setDoneReminders(Boolean.TRUE); // 存在催办记录
index.setNextRemindersDays((int) (interval - between)); // 距离下次催办天数为0
} else {
index.setAllowReminders(Boolean.TRUE); // 不允许催办
index.setDoneReminders(Boolean.TRUE); // 存在催办记录
index.setNextRemindersDays(0); // 距离下次催办天数为0
}
}
} else {
index.setAllowReminders(Boolean.FALSE);
index.setDoneReminders(Boolean.FALSE);
index.setNextRemindersDays(0);
}
return index;
}).collect(Collectors.toList()));
return pageData; return pageData;
} }

View File

@ -3,14 +3,24 @@ package io.renren.modules.reminders.dao;
import io.renren.common.dao.BaseDao; import io.renren.common.dao.BaseDao;
import io.renren.modules.reminders.entity.TRemindersEntity; import io.renren.modules.reminders.entity.TRemindersEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/** /**
* 催办信息 * 催办信息
* *
* @author wangliwen wangliwen@hisense.com * @author wangliwen wangliwen@hisense.com
* @since 1.0 2022-11-30 * @since 1.0 2022-11-30
*/ */
@Mapper @Mapper
public interface TRemindersDao extends BaseDao<TRemindersEntity> { public interface TRemindersDao extends BaseDao<TRemindersEntity> {
/**
* 获取该任务的最新催办记录时间
*
* @param taskId
* @return
*/
List<Map> selectRemindersTime(@Param("taskId") String taskId);
} }

View File

@ -4,6 +4,8 @@ import io.renren.common.service.CrudService;
import io.renren.modules.reminders.dto.TRemindersDTO; import io.renren.modules.reminders.dto.TRemindersDTO;
import io.renren.modules.reminders.entity.TRemindersEntity; import io.renren.modules.reminders.entity.TRemindersEntity;
import java.time.LocalDate;
/** /**
* 催办信息 * 催办信息
* *
@ -11,5 +13,11 @@ import io.renren.modules.reminders.entity.TRemindersEntity;
* @since 1.0 2022-11-30 * @since 1.0 2022-11-30
*/ */
public interface TRemindersService extends CrudService<TRemindersEntity, TRemindersDTO> { public interface TRemindersService extends CrudService<TRemindersEntity, TRemindersDTO> {
/**
* 获取该任务最近一次催办日期
*
* @param taskId
* @return
*/
LocalDate selectRemindersTime(String taskId);
} }

View File

@ -24,6 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -89,6 +93,8 @@ public class TRemindersServiceImpl extends CrudServiceImpl<TRemindersDao, TRemin
dto.setRecipient(assignee.get()); dto.setRecipient(assignee.get());
} }
Map<String, Object> kv = task.getProcessVariables(); Map<String, Object> kv = task.getProcessVariables();
LocalDate taskCreateDate = task.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
long between = ChronoUnit.DAYS.between(taskCreateDate, LocalDate.now());
Boolean allowEntrust = Boolean.valueOf(kv.get("allowEntrust") != null ? kv.get("allowEntrust").toString() : Boolean.FALSE.toString()); // 允许被委托他人(特殊通知) Boolean allowEntrust = Boolean.valueOf(kv.get("allowEntrust") != null ? kv.get("allowEntrust").toString() : Boolean.FALSE.toString()); // 允许被委托他人(特殊通知)
final StringBuilder resourceName = new StringBuilder(); final StringBuilder resourceName = new StringBuilder();
if (kv.containsKey("resourceDTO")) { if (kv.containsKey("resourceDTO")) {
@ -112,18 +118,19 @@ public class TRemindersServiceImpl extends CrudServiceImpl<TRemindersDao, TRemin
} }
SysUserDTO creatorDto = sysUserService.get(Long.parseLong(creator)); SysUserDTO creatorDto = sysUserService.get(Long.parseLong(creator));
String content = "【催办通知】" + creatorDto.getRealName() + "发起的流程 " + resourceName + dto.getProcessType() + String content = "【催办通知】" + creatorDto.getRealName() + "发起的流程 " + resourceName + dto.getProcessType() +
" 进入审核节点:" + task.getName() + " 进入审核节点:" + task.getName() + "" + between + "" +
";当前审核人指派为您"; ";当前审核人指派为您,请及时处理";
if (allowEntrust) { if (allowEntrust) {
content = "【催办通知】" + dto.getSponsor().getRealName() + "发起的流程 " + resourceName + dto.getProcessType() + content = "【催办通知】" + dto.getSponsor().getRealName() + "发起的流程 " + resourceName + dto.getProcessType() +
" 已进入审核节点:" + task.getName() + " 已进入审核节点:" + task.getName() + "" + between + "" +
";因无法分配到审核人,故当前审核人指派为您"; ";因无法分配到审核人,故当前审核人指派为您,请及时处理";
} }
Integer type = 12; Integer type = 12;
if ("能力申请".equals(dto.getProcessType())) { if ("能力申请".equals(dto.getProcessType())) {
type = 1; type = 1;
//待办通知通知的是流程当前审核人通知内容[待办通知]申请部门+申请人+提出资源名称+申请请进入UCS后台管理系统进行审核 // 催办通知通知的是流程当前审核人通知内容[待办通知]申请部门+申请人+提出资源名称+申请请进入UCS后台管理系统进行审核
content = "【催办通知】" + dto.getSponsor().getDeptName() + dto.getSponsor().getRealName() + "提出 ”" + resourceName + " ”申请请进入UCS后台管理系统进行审核。"; content = "【催办通知】" + dto.getSponsor().getDeptName() + dto.getSponsor().getRealName() + "提出 ”"
+ resourceName + " ”申请已过去" + between + "请进入UCS后台管理系统及时进行审核。";
if (allowEntrust) { if (allowEntrust) {
content = content + "(因无法分配到审核人,故当前审核人指派为您,您可进行委托他人转办)"; content = content + "(因无法分配到审核人,故当前审核人指派为您,您可进行委托他人转办)";
} }
@ -161,4 +168,17 @@ public class TRemindersServiceImpl extends CrudServiceImpl<TRemindersDao, TRemin
super.save(dto); super.save(dto);
} }
/**
* 获取该任务最近一次催办日期
*
* @param taskId
* @return
*/
@Override
public LocalDate selectRemindersTime(String taskId) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return baseDao.selectRemindersTime(taskId).stream().map(index ->
LocalDate.parse(index.get("reminders_time").toString(), formatter)
).findFirst().orElse(null);
}
} }

View File

@ -1,6 +1,5 @@
package io.renren.modules.sys.service.impl; package io.renren.modules.sys.service.impl;
import cn.hutool.core.collection.CollUtil;
import io.renren.common.service.impl.BaseServiceImpl; import io.renren.common.service.impl.BaseServiceImpl;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.controller.SysUserController; import io.renren.modules.sys.controller.SysUserController;
@ -25,7 +24,7 @@ public class SysRoleUserServiceImpl extends BaseServiceImpl<SysRoleUserDao, SysR
private static final Logger logger = LoggerFactory.getLogger(SysUserController.class); private static final Logger logger = LoggerFactory.getLogger(SysUserController.class);
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public void saveOrUpdate(Long userId, List<Long> roleIdList) { public void saveOrUpdate(Long userId, List<Long> roleIdList) {
logger.error("------------------准备更新用户角色信息-------------------"); logger.error("------------------准备更新用户角色信息-------------------");
//先删除角色用户关系 //先删除角色用户关系

View File

@ -21,4 +21,16 @@
<result property="additional3" column="additional3"/> <result property="additional3" column="additional3"/>
</resultMap> </resultMap>
<select id="selectRemindersTime" resultType="java.util.Map">
SELECT
DATE_FORMAT( reminders_time, '%Y-%m-%d' ) AS reminders_time
FROM
t_reminders
WHERE
process_task_id = #{taskId}
ORDER BY
create_date DESC
LIMIT 1;
</select>
</mapper> </mapper>