diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/enumeration/CommonEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/enumeration/CommonEnum.java index b4c5c10..be73781 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/enumeration/CommonEnum.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/enumeration/CommonEnum.java @@ -26,7 +26,9 @@ public enum CommonEnum { LS_QY(331126,"庆元县",2), LS_JN(331127,"景宁畲族自治县",2), LS_LQ(331181,"龙泉市",2), - LS_KFQ(331199,"开发区",2); + LS_KFQ(331199,"开发区",2), + ZWDD(0,"浙政钉",3), + MOBILE(1,"短信",3); private Integer code; private String desc; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java index 56aa2e6..0423328 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/listener/EarlyWarningListener.java @@ -4,15 +4,24 @@ import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.common.helper.UserInfoHelper; +import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; +import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; +import com.ningdatech.pmapi.sys.manage.NoticeManage; +import com.ningdatech.pmapi.sys.model.entity.Notify; import com.ningdatech.pmapi.sys.model.entity.WflowEarlyWarningRecords; import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; +import com.ningdatech.pmapi.sys.service.INotifyService; +import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import com.ningdatech.yxt.model.cmd.SendSmsCmd; import com.wflow.enums.WarningRuleTypeEnum; import com.wflow.workflow.notify.event.EarlyWarningEvent; import lombok.RequiredArgsConstructor; @@ -49,6 +58,14 @@ public class EarlyWarningListener { private final UserInfoHelper userInfoHelper; + private final YxtCallOrSmsHelper yxtCallOrSmsHelper; + + private final NoticeManage noticeManage; + + private final INdWorkNoticeStagingService workNoticeStagingService; + + private final INotifyService notifyService; + @Async @EventListener public void onApplicationEvent(EarlyWarningEvent event) { @@ -104,9 +121,19 @@ public class EarlyWarningListener { } for(HistoricActivityInstance hai : hais){ + if(StringUtils.isBlank(noticeMethod) || + (!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && + !noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ + log.info("通知方式为空或者错误!"); + return; + } + + //1.存入 预警记录 String assignee = hai.getAssignee(); UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(assignee); WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); + String content = convertContent(noticeContent,project.getProjectName(), + InstTypeEnum.getByCode(pi.getInstType()),timeout); records.setAreaCode(project.getAreaCode()); records.setBuildOrgCode(project.getBuildOrgCode()); records.setBuildOrgName(project.getBuildOrgName()); @@ -115,12 +142,34 @@ public class EarlyWarningListener { records.setInstStart(hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); records.setInstType(pi.getInstType()); records.setNoticeMethod(noticeMethod); - records.setNoticeContent(convertContent(noticeContent,project.getProjectName(),InstTypeEnum.getByCode(pi.getInstType()),timeout)); + records.setNoticeContent(content); records.setProjectName(project.getProjectName()); records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); records.setWarningEmployeecode(assignee); earlyWarningRecordsService.save(records); + + //2.消息提醒 + Notify notify = noticeManage.assemblyAuditNotify(user.getUserId(), project, content); + notify.setType(MsgTypeEnum.PROJECT_REVIEW.name()); + notifyService.save(notify); + + //3.发短信 + if(noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode()))){ + SendSmsCmd.SendSmsContext context = new SendSmsCmd.SendSmsContext(); + context.setReceiveNumber(user.getMobile()); + context.setContent(content); + yxtCallOrSmsHelper.sendSms(context); + } + + //4.浙政钉 + if(noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode()))){ + // 获取发送浙政钉工作通知必要信息 + WorkNoticeInfo passWorkNoticeInfo = noticeManage.getSendWorkNoticeInfo(assignee); + passWorkNoticeInfo.setMsg(content); + // 放入工作通知暂存表中,通过扫表异步发送 + workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.PROJECT_REVIEW); + } } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java index a5ff193..b08a020 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/NoticeManage.java @@ -237,7 +237,7 @@ public class NoticeManage { * @param project * @param msg */ - private Notify assemblyAuditNotify(Long userId, Project project, String msg) { + public Notify assemblyAuditNotify(Long userId, Project project, String msg) { Notify notify = new Notify(); notify.setTitle(AUDIT_WORK_TITLE); notify.setUserId(userId); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 9b91443..2a5d6ca 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -29,8 +29,6 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.irs.sign.IRSAPIRequest; -import com.ningdatech.pmapi.performance.model.dto.ProjectCoreBusinessDTO; -import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; import com.ningdatech.pmapi.projectlib.enumeration.*; @@ -103,7 +101,6 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; - import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -143,9 +140,7 @@ public class TodoCenterManage { private final PassHandle passHandle; private final RepositoryService repositoryService; private final IRegionService regionService; - private final ITodoService todoService; - private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; /** * 待办中心待我处理项目列表查询