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 new file mode 100644 index 00000000..a00819ee --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/reminders/controller/TRemindersController.java @@ -0,0 +1,109 @@ +package io.renren.modules.reminders.controller; + +import io.renren.common.annotation.LogOperation; +import io.renren.common.constant.Constant; +import io.renren.common.page.PageData; +import io.renren.common.utils.ExcelUtils; +import io.renren.common.utils.Result; +import io.renren.common.validator.AssertUtils; +import io.renren.common.validator.ValidatorUtils; +import io.renren.common.validator.group.AddGroup; +import io.renren.common.validator.group.DefaultGroup; +import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.reminders.dto.TRemindersDTO; +import io.renren.modules.reminders.excel.TRemindersExcel; +import io.renren.modules.reminders.service.TRemindersService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 催办信息 + * + * @author wangliwen wangliwen@hisense.com + * @since 1.0 2022-11-30 + */ +@RestController +@RequestMapping("reminders/treminders") +@Api(tags = "催办信息") +public class TRemindersController { + @Autowired + private TRemindersService tRemindersService; + + @GetMapping("page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"), + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String") + }) + public Result> page(@ApiIgnore @RequestParam Map params) { + PageData page = tRemindersService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("{id}") + @ApiOperation("信息") + public Result get(@PathVariable("id") Long id) { + TRemindersDTO data = tRemindersService.get(id); + + return new Result().ok(data); + } + + @PostMapping + @ApiOperation("保存") + @LogOperation("保存") + public Result save(@RequestBody TRemindersDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + tRemindersService.save(dto); + + return new Result(); + } + + @PutMapping + @ApiOperation("修改") + @LogOperation("修改") + public Result update(@RequestBody TRemindersDTO dto) { + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + tRemindersService.update(dto); + + return new Result(); + } + + @DeleteMapping + @ApiOperation("删除") + @LogOperation("删除") + public Result delete(@RequestBody Long[] ids) { + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + + tRemindersService.delete(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = tRemindersService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, "催办信息", list, TRemindersExcel.class); + } + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/dao/TRemindersDao.java b/renren-admin/src/main/java/io/renren/modules/reminders/dao/TRemindersDao.java new file mode 100644 index 00000000..b5ca7961 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/reminders/dao/TRemindersDao.java @@ -0,0 +1,16 @@ +package io.renren.modules.reminders.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.reminders.entity.TRemindersEntity; +import org.apache.ibatis.annotations.Mapper; + +/** +* 催办信息 +* +* @author wangliwen wangliwen@hisense.com +* @since 1.0 2022-11-30 +*/ +@Mapper +public interface TRemindersDao extends BaseDao { + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/dto/TRemindersDTO.java b/renren-admin/src/main/java/io/renren/modules/reminders/dto/TRemindersDTO.java new file mode 100644 index 00000000..9a34880b --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/reminders/dto/TRemindersDTO.java @@ -0,0 +1,49 @@ +package io.renren.modules.reminders.dto; + +import io.renren.modules.sys.dto.SysUserDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 催办信息 + * + * @author wangliwen wangliwen@hisense.com + * @since 1.0 2022-11-30 + */ +@Data +@ApiModel(value = "催办信息") +public class TRemindersDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + private Long id; + @ApiModelProperty(value = "催办流程实例ID") + private Long instanceId; + @ApiModelProperty(value = "催办流程节点id") + private Long processTaskId; + @ApiModelProperty(value = "催办流程节点当前状态(0:流程节点仍然阻塞,1:流程节点经办人已完成)") + private Integer processTaskStats; + @ApiModelProperty(value = "流程申请单号") + private String applyNumber; + @ApiModelProperty(value = "流程类型") + private String processType; + @ApiModelProperty(value = "催办发起人信息") + private SysUserDTO sponsor; + @ApiModelProperty(value = "催办接收人信息") + private SysUserDTO recipient; + @ApiModelProperty(value = "催办发起时间") + private Date remindersTime; + @ApiModelProperty(value = "催办通知的文案内容") + private String content; + @ApiModelProperty(value = "附加备用字段1") + private String additional1; + @ApiModelProperty(value = "附加备用字段2") + private String additional2; + @ApiModelProperty(value = "附加备用字段3") + private String additional3; + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/entity/TRemindersEntity.java b/renren-admin/src/main/java/io/renren/modules/reminders/entity/TRemindersEntity.java new file mode 100644 index 00000000..74067943 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/reminders/entity/TRemindersEntity.java @@ -0,0 +1,76 @@ +package io.renren.modules.reminders.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; +import io.renren.common.entity.BaseEntity; +import io.renren.modules.sys.dto.SysUserDTO; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + * 催办信息 + * + * @author wangliwen wangliwen@hisense.com + * @since 1.0 2022-11-30 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName(value = "t_reminders", autoResultMap = true) +public class TRemindersEntity extends BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 催办流程实例ID + */ + private Long instanceId; + /** + * 催办流程节点id + */ + private Long processTaskId; + /** + * 催办流程节点当前状态(0:流程节点仍然阻塞,1:流程节点经办人已完成) + */ + private Integer processTaskStats; + /** + * 流程申请单号 + */ + private String applyNumber; + /** + * 流程类型 + */ + private String processType; + /** + * 催办发起人信息 + */ + @TableField(value = "`sponsor`", typeHandler = FastjsonTypeHandler.class) + private SysUserDTO sponsor; + /** + * 催办接收人信息 + */ + @TableField(value = "`recipient`", typeHandler = FastjsonTypeHandler.class) + private SysUserDTO recipient; + /** + * 催办发起时间 + */ + private Date remindersTime; + /** + * 催办通知的文案内容 + */ + private String content; + /** + * 附加备用字段1 + */ + private String additional1; + /** + * 附加备用字段2 + */ + private String additional2; + /** + * 附加备用字段3 + */ + private String additional3; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/excel/TRemindersExcel.java b/renren-admin/src/main/java/io/renren/modules/reminders/excel/TRemindersExcel.java new file mode 100644 index 00000000..f04edd46 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/reminders/excel/TRemindersExcel.java @@ -0,0 +1,49 @@ +package io.renren.modules.reminders.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import io.renren.modules.sys.dto.SysUserDTO; +import lombok.Data; + +import java.util.Date; + +/** + * 催办信息 + * + * @author wangliwen wangliwen@hisense.com + * @since 1.0 2022-11-30 + */ +@Data +@ContentRowHeight(20) +@HeadRowHeight(20) +@ColumnWidth(25) +public class TRemindersExcel { + @ExcelProperty(value = "主键ID", index = 0) + private Long id; + @ExcelProperty(value = "催办流程实例ID", index = 1) + private Long instanceId; + @ExcelProperty(value = "催办流程节点id", index = 2) + private Long processTaskId; + @ExcelProperty(value = "催办流程节点当前状态(0:流程节点仍然阻塞,1:流程节点经办人已完成)", index = 3) + private Integer processTaskStats; + @ExcelProperty(value = "流程申请单号", index = 4) + private String applyNumber; + @ExcelProperty(value = "流程类型", index = 5) + private String processType; + @ExcelProperty(value = "催办发起人信息", index = 6) + private SysUserDTO sponsor; + @ExcelProperty(value = "催办接收人信息", index = 7) + private SysUserDTO recipient; + @ExcelProperty(value = "催办发起时间", index = 8) + private Date remindersTime; + @ExcelProperty(value = "催办通知的文案内容", index = 9) + private String content; + @ExcelProperty(value = "附加备用字段1", index = 10) + private String additional1; + @ExcelProperty(value = "附加备用字段2", index = 11) + private String additional2; + @ExcelProperty(value = "附加备用字段3", index = 12) + private String additional3; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/service/TRemindersService.java b/renren-admin/src/main/java/io/renren/modules/reminders/service/TRemindersService.java new file mode 100644 index 00000000..6afd759d --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/reminders/service/TRemindersService.java @@ -0,0 +1,15 @@ +package io.renren.modules.reminders.service; + +import io.renren.common.service.CrudService; +import io.renren.modules.reminders.dto.TRemindersDTO; +import io.renren.modules.reminders.entity.TRemindersEntity; + +/** + * 催办信息 + * + * @author wangliwen wangliwen@hisense.com + * @since 1.0 2022-11-30 + */ +public interface TRemindersService extends CrudService { + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/reminders/service/impl/TRemindersServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/reminders/service/impl/TRemindersServiceImpl.java new file mode 100644 index 00000000..27a1f5ed --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/reminders/service/impl/TRemindersServiceImpl.java @@ -0,0 +1,160 @@ +package io.renren.modules.reminders.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.modules.notice.dto.SysNoticeDTO; +import io.renren.modules.notice.enums.NoticeStatusEnum; +import io.renren.modules.notice.service.SysNoticeService; +import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.reminders.dao.TRemindersDao; +import io.renren.modules.reminders.dto.TRemindersDTO; +import io.renren.modules.reminders.entity.TRemindersEntity; +import io.renren.modules.reminders.service.TRemindersService; +import io.renren.modules.sys.dto.SysUserDTO; +import io.renren.modules.sys.service.SysUserService; +import org.activiti.engine.HistoryService; +import org.activiti.engine.TaskService; +import org.activiti.engine.history.HistoricProcessInstance; +import org.activiti.engine.task.Task; +import org.apache.commons.lang3.StringUtils; +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.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * 催办信息 + * + * @author wangliwen wangliwen@hisense.com + * @since 1.0 2022-11-30 + */ +@Service +public class TRemindersServiceImpl extends CrudServiceImpl implements TRemindersService { + private static final Logger logger = LoggerFactory.getLogger(TRemindersServiceImpl.class); + + @Value("#{new Boolean(${notice.yawei})}") + private Boolean noticeYaWei; // 是否发送消息到亚微中心 + + @Value("${reminders.interval:7}") // 流程发起后多少天允许催办 + private Integer interval; + + // @Autowired +// private RestTemplate restTemplate; +// @Autowired +// private SysUserDao sysUserDao; +// @Autowired +// private SysNoticeUserService sysNoticeUserService; +// @Autowired +// private NoticeUntil noticeUntil; +// @Autowired +// private ActTaskService actTaskService; + @Autowired + protected HistoryService historyService; + @Autowired + private SysUserService sysUserService; + + @Autowired + protected TaskService taskService; + @Autowired + private SysNoticeService sysNoticeService; + + @Override + public QueryWrapper getWrapper(Map params) { + QueryWrapper wrapper = new QueryWrapper<>(); + return wrapper; + } + + @Override + public void save(TRemindersDTO dto) { + // TODO 发送催办消息 + HistoricProcessInstance processInstanceDTO = + historyService.createHistoricProcessInstanceQuery().processInstanceId(dto.getInstanceId().toString()).includeProcessVariables().singleResult(); + if (processInstanceDTO != null) { + logger.info(JSON.toJSONString(processInstanceDTO.getProcessVariables())); + if (processInstanceDTO.getProcessVariables().containsKey("flowType")) { // 获取流程类型 + dto.setProcessType(processInstanceDTO.getProcessVariables().getOrDefault("flowType", "未知流程").toString()); + } + Task task = taskService.createTaskQuery().taskId(dto.getProcessTaskId().toString()).includeProcessVariables().singleResult(); + if (StringUtils.isNumeric(task.getAssignee())) { // 对审核人发消息 + Optional assignee = Optional.ofNullable(sysUserService.get(Long.parseLong(task.getAssignee()))); // 获取审批人 + dto.setRecipient(assignee.get()); + } + Map kv = task.getProcessVariables(); + Boolean allowEntrust = Boolean.valueOf(kv.get("allowEntrust") != null ? kv.get("allowEntrust").toString() : Boolean.FALSE.toString()); // 允许被委托他人(特殊通知) + final StringBuilder resourceName = new StringBuilder(); + if (kv.containsKey("resourceDTO")) { + resourceName.append("'"); + resourceName.append(((Map) kv.get("resourceDTO")).get("name")); + resourceName.append("'"); + } else if (kv.containsKey("tAbilityApplicationDTOList")) { + resourceName.append("'"); + resourceName.append(((List) kv.get("tAbilityApplicationDTOList")).get(0).getTitle()); + resourceName.append("'"); + } + String creator = null; + if (kv.containsKey("creator")) { // 表单存在创建者 + creator = kv.get("creator").toString(); + } else if (kv.containsKey("userId")) { + creator = kv.get("userId").toString(); + } + if (StringUtils.isEmpty(creator)) { + logger.info("无流程创建者"); + return; + } + String content = "【催办通知】" + dto.getSponsor().getRealName() + "发起的流程 " + resourceName + dto.getProcessType() + + " 已进入审核节点:" + task.getName() + + ";当前审核人指派为您"; + if (allowEntrust) { + content = "【催办通知】" + dto.getSponsor().getRealName() + "发起的流程 " + resourceName + dto.getProcessType() + + " 已进入审核节点:" + task.getName() + + ";因无法分配到审核人,故当前审核人指派为您"; + } + Integer type = 12; + if ("能力申请".equals(dto.getProcessType())) { + type = 1; + //待办通知,通知的是流程当前审核人,通知内容:[待办通知]申请部门+申请人+提出“资源名称”+申请,请进入UCS后台管理系统进行审核。 + content = "【催办通知】" + dto.getSponsor().getDeptName() + dto.getSponsor().getRealName() + "提出 ”" + resourceName + " ”申请,请进入UCS后台管理系统进行审核。"; + if (allowEntrust) { + content = content + "(因无法分配到审核人,故当前审核人指派为您,您可进行委托他人转办)"; + } + } else if ("资源上架".equals(dto.getProcessType())) { + type = 3; + } else if ("资源下架".equals(dto.getProcessType())) { + type = 5; + } else if ("能力需求申请".equals(dto.getProcessType())) { + type = 7; + } else if ("评论审核".equals(dto.getProcessType())) { + type = 9; + } + logger.info("催办通知内容:{}", content); + try { // 审批者 + SysNoticeDTO noticeDTO = new SysNoticeDTO(); + noticeDTO.setType(type); + noticeDTO.setTitle("流程流转系统通知"); + noticeDTO.setContent(content); // 通知内容 + noticeDTO.setReceiverType(1); + noticeDTO.setReceiverTypeIds(task.getAssignee()); + noticeDTO.setStatus(NoticeStatusEnum.SEND.value()); + noticeDTO.setSenderName("流程系统"); + noticeDTO.setSenderDate(new Date()); + noticeDTO.setCreator(sysUserService.getByUsername("admin").getId()); + noticeDTO.setCreateDate(new Date()); + noticeDTO.setFrom("通知"); + noticeDTO.setApplyId(task.getProcessInstanceId()); + noticeDTO.setApplyState(0); + sysNoticeService.save(noticeDTO); + } catch (Exception exception) { + logger.error("通知审批人失败", exception); + } + } + super.save(dto); + } + +} \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/reminders/TRemindersDao.xml b/renren-admin/src/main/resources/mapper/reminders/TRemindersDao.xml new file mode 100644 index 00000000..4e31f521 --- /dev/null +++ b/renren-admin/src/main/resources/mapper/reminders/TRemindersDao.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file