@@ -26,7 +26,9 @@ public enum CommonEnum { | |||||
LS_QY(331126,"庆元县",2), | LS_QY(331126,"庆元县",2), | ||||
LS_JN(331127,"景宁畲族自治县",2), | LS_JN(331127,"景宁畲族自治县",2), | ||||
LS_LQ(331181,"龙泉市",2), | LS_LQ(331181,"龙泉市",2), | ||||
LS_KFQ(331199,"开发区",2); | |||||
LS_KFQ(331199,"开发区",2), | |||||
ZWDD(0,"浙政钉",3), | |||||
MOBILE(1,"短信",3); | |||||
private Integer code; | private Integer code; | ||||
private String desc; | private String desc; | ||||
@@ -0,0 +1,58 @@ | |||||
package com.ningdatech.pmapi.projectlib.enumeration; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.Getter; | |||||
import lombok.NoArgsConstructor; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.Objects; | |||||
/** | |||||
* | |||||
* 预警填报类型枚举 | |||||
* @author CMM | |||||
* @since 2023/02/24 16:14 | |||||
*/ | |||||
@Getter | |||||
@NoArgsConstructor | |||||
@AllArgsConstructor | |||||
public enum WarningFlowTypeEnum { | |||||
/** | |||||
* 预警填报类型枚举 | |||||
*/ | |||||
UNIT_INNER_AUDIT(1, "预审申报",ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode()), | |||||
PRELIMINARY_PREVIEW(2, "建设方案申报",ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode()), | |||||
DEPT_UNITED_REVIEW(3,"采购结果备案",ProjectStatusEnum.TO_BE_PURCHASED.getCode()), | |||||
CONSTRUCTION_PLAN_REVIEW(4,"初验备案",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()), | |||||
PROJECT_FINAL_INSPECTION(5,"验收申报",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()); | |||||
private Integer code; | |||||
private String desc; | |||||
//对应的 待提交时的项目状态 | |||||
private Integer projectStutas; | |||||
public static String getDescByCode(Integer code) { | |||||
if (Objects.isNull(code)) { | |||||
return StringUtils.EMPTY; | |||||
} | |||||
for (WarningFlowTypeEnum t : WarningFlowTypeEnum.values()) { | |||||
if (code.equals(t.getCode())) { | |||||
return t.desc; | |||||
} | |||||
} | |||||
return StringUtils.EMPTY; | |||||
} | |||||
public static WarningFlowTypeEnum getByCode(Integer code) { | |||||
if (Objects.isNull(code)) { | |||||
return null; | |||||
} | |||||
for (WarningFlowTypeEnum t : WarningFlowTypeEnum.values()) { | |||||
if (code.equals(t.getCode())) { | |||||
return t; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
} |
@@ -4,15 +4,24 @@ import cn.hutool.core.collection.CollUtil; | |||||
import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.ningdatech.pmapi.common.constant.BizConst; | 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.common.helper.UserInfoHelper; | ||||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; | import com.ningdatech.pmapi.projectlib.enumeration.InstTypeEnum; | ||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | import com.ningdatech.pmapi.projectlib.model.entity.Project; | ||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | import com.ningdatech.pmapi.projectlib.model.entity.ProjectInst; | ||||
import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | import com.ningdatech.pmapi.projectlib.service.IProjectInstService; | ||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | 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.model.entity.WflowEarlyWarningRecords; | ||||
import com.ningdatech.pmapi.sys.service.IEarlyWarningRecordsService; | 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.pmapi.user.security.auth.model.UserFullInfoDTO; | ||||
import com.ningdatech.yxt.model.cmd.SendSmsCmd; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | import com.wflow.enums.WarningRuleTypeEnum; | ||||
import com.wflow.workflow.notify.event.EarlyWarningEvent; | import com.wflow.workflow.notify.event.EarlyWarningEvent; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
@@ -49,6 +58,14 @@ public class EarlyWarningListener { | |||||
private final UserInfoHelper userInfoHelper; | private final UserInfoHelper userInfoHelper; | ||||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||||
private final NoticeManage noticeManage; | |||||
private final INdWorkNoticeStagingService workNoticeStagingService; | |||||
private final INotifyService notifyService; | |||||
@Async | @Async | ||||
@EventListener | @EventListener | ||||
public void onApplicationEvent(EarlyWarningEvent event) { | public void onApplicationEvent(EarlyWarningEvent event) { | ||||
@@ -104,9 +121,19 @@ public class EarlyWarningListener { | |||||
} | } | ||||
for(HistoricActivityInstance hai : hais){ | 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(); | String assignee = hai.getAssignee(); | ||||
UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(assignee); | UserFullInfoDTO user = userInfoHelper.getUserFullInfoByEmployeeCode(assignee); | ||||
WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); | WflowEarlyWarningRecords records = new WflowEarlyWarningRecords(); | ||||
String content = convertContent(noticeContent,project.getProjectName(), | |||||
InstTypeEnum.getByCode(pi.getInstType()),timeout); | |||||
records.setAreaCode(project.getAreaCode()); | records.setAreaCode(project.getAreaCode()); | ||||
records.setBuildOrgCode(project.getBuildOrgCode()); | records.setBuildOrgCode(project.getBuildOrgCode()); | ||||
records.setBuildOrgName(project.getBuildOrgName()); | records.setBuildOrgName(project.getBuildOrgName()); | ||||
@@ -115,12 +142,34 @@ public class EarlyWarningListener { | |||||
records.setInstStart(hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); | records.setInstStart(hai.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); | ||||
records.setInstType(pi.getInstType()); | records.setInstType(pi.getInstType()); | ||||
records.setNoticeMethod(noticeMethod); | records.setNoticeMethod(noticeMethod); | ||||
records.setNoticeContent(convertContent(noticeContent,project.getProjectName(),InstTypeEnum.getByCode(pi.getInstType()),timeout)); | |||||
records.setNoticeContent(content); | |||||
records.setProjectName(project.getProjectName()); | records.setProjectName(project.getProjectName()); | ||||
records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); | records.setRuleType(WarningRuleTypeEnum.PROCESS_WARNING.getCode()); | ||||
records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); | records.setWarningUsername(Objects.nonNull(user) ? user.getUsername() : StringUtils.EMPTY); | ||||
records.setWarningEmployeecode(assignee); | records.setWarningEmployeecode(assignee); | ||||
earlyWarningRecordsService.save(records); | 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); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -0,0 +1,119 @@ | |||||
package com.ningdatech.pmapi.scheduler.task; | |||||
import cn.hutool.core.collection.CollUtil; | |||||
import cn.hutool.core.date.StopWatch; | |||||
import com.alibaba.fastjson.JSON; | |||||
import com.alibaba.fastjson.JSONArray; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.ningdatech.pmapi.common.enumeration.CommonEnum; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.WarningFlowTypeEnum; | |||||
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.wflow.bean.entity.WflowEarlyWarning; | |||||
import com.wflow.enums.WarningRuleTypeEnum; | |||||
import com.wflow.service.IEarlyWarningService; | |||||
import lombok.RequiredArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.scheduling.annotation.Scheduled; | |||||
import org.springframework.stereotype.Component; | |||||
import java.net.InetAddress; | |||||
import java.net.UnknownHostException; | |||||
import java.util.List; | |||||
import java.util.Objects; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* @author ZPF | |||||
* @date 2023/8/3 上午9:53 | |||||
* 预警填报 超时任务 | |||||
*/ | |||||
@Component | |||||
@Slf4j | |||||
@RequiredArgsConstructor | |||||
public class EarlyWarningInstanceNotStartTask { | |||||
@Value("${hostname}") | |||||
private String HOST_NAME; | |||||
private final IEarlyWarningService earlyWarningService; | |||||
private final IProjectService projectService; | |||||
private final IProjectInstService projectInstService; | |||||
@Scheduled(cron = "0 2 * * * ?") | |||||
public void doTask() throws UnknownHostException { | |||||
if (!HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) { | |||||
return; | |||||
} | |||||
log.info("=========== 预警填报超时任务开始 ========"); | |||||
StopWatch stopWatch = new StopWatch(); | |||||
stopWatch.start(); | |||||
// 1.查询 填报的 预警规则 填报类型的 每个区域 每个规则 | |||||
List<WflowEarlyWarning> warnings = earlyWarningService.list(Wrappers.lambdaQuery(WflowEarlyWarning.class) | |||||
.eq(WflowEarlyWarning::getRuleType, WarningRuleTypeEnum.DECLARED_WARNING.getCode())); | |||||
for(WflowEarlyWarning warning : warnings){ | |||||
//2. 取出rule的数据 | |||||
if(!warning.getIsOpen()){ | |||||
log.info(warning.getId() + " 此规则关闭了"); | |||||
continue; | |||||
} | |||||
String noticeMethod = warning.getNoticeMethod(); | |||||
if(StringUtils.isBlank(noticeMethod) || | |||||
(!noticeMethod.contains(String.valueOf(CommonEnum.ZWDD.getCode())) && | |||||
!noticeMethod.contains(String.valueOf(CommonEnum.MOBILE.getCode())))){ | |||||
log.info("通知方式为空或者错误!"); | |||||
return; | |||||
} | |||||
String rule = warning.getRule(); | |||||
if(StringUtils.isNotBlank(rule)){ | |||||
JSONArray ruleArray = JSON.parseArray(rule); | |||||
if(CollUtil.isNotEmpty(ruleArray)){ | |||||
ruleArray.forEach(r -> { | |||||
JSONObject rJson = JSON.parseObject(JSON.toJSONString(r)); | |||||
Integer time = rJson.getInteger("time"); | |||||
Integer biz = rJson.getInteger("biz"); | |||||
if(Objects.isNull(time) || Objects.isNull(biz)){ | |||||
log.info("规则数据 错误 :{}",rJson); | |||||
return; | |||||
} | |||||
WarningFlowTypeEnum flowTypeEnum = WarningFlowTypeEnum.getByCode(biz); | |||||
if(Objects.isNull(flowTypeEnum)){ | |||||
log.info("匹配不到 流程类型"); | |||||
return; | |||||
} | |||||
//得出 对应待提交的项目状态 | |||||
Integer projectStutas = flowTypeEnum.getProjectStutas(); | |||||
String areaCode = warning.getAreaCode(); | |||||
//测试先用分钟 | |||||
//查询 所有这个区域的项目 未提交的项目 | |||||
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.eq(Project::getAreaCode, areaCode) | |||||
.eq(Project::getNewest, Boolean.TRUE) | |||||
.eq(Project::getStatus,projectStutas)); | |||||
List<Long> projectIds = projects.stream().map(Project::getId) | |||||
.collect(Collectors.toList()); | |||||
projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) | |||||
.in(ProjectInst::getProjectId,projectIds) | |||||
.eq(ProjectInst::getInstType,biz)); | |||||
}); | |||||
} | |||||
} | |||||
} | |||||
stopWatch.stop(); | |||||
log.info("=========== 预警填报超时任务结束 耗时{}s", stopWatch.getTotalTimeSeconds()); | |||||
} | |||||
} |
@@ -237,7 +237,7 @@ public class NoticeManage { | |||||
* @param project | * @param project | ||||
* @param msg | * @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 notify = new Notify(); | ||||
notify.setTitle(AUDIT_WORK_TITLE); | notify.setTitle(AUDIT_WORK_TITLE); | ||||
notify.setUserId(userId); | notify.setUserId(userId); | ||||
@@ -32,4 +32,7 @@ public class WarningListReq extends PagePo { | |||||
@ApiModelProperty("提醒结束时间") | @ApiModelProperty("提醒结束时间") | ||||
private LocalDateTime endTime; | private LocalDateTime endTime; | ||||
@ApiModelProperty("区域Code") | |||||
private String areaCode; | |||||
} | } |
@@ -40,6 +40,7 @@ public class EarlyWarningRecordsServiceImpl extends ServiceImpl<EarlyWarningReco | |||||
Page<WflowEarlyWarningRecords> page = req.page(); | Page<WflowEarlyWarningRecords> page = req.page(); | ||||
LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) | LambdaQueryWrapper<WflowEarlyWarningRecords> wrapper = Wrappers.lambdaQuery(WflowEarlyWarningRecords.class) | ||||
.eq(WflowEarlyWarningRecords::getRuleType, ruleType) | .eq(WflowEarlyWarningRecords::getRuleType, ruleType) | ||||
.eq(StringUtils.isNotBlank(req.getAreaCode()),WflowEarlyWarningRecords::getAreaCode,req.getAreaCode()) | |||||
.like(StringUtils.isNotBlank(req.getProjectName()), WflowEarlyWarningRecords::getProjectName, req.getProjectName()) | .like(StringUtils.isNotBlank(req.getProjectName()), WflowEarlyWarningRecords::getProjectName, req.getProjectName()) | ||||
.like(StringUtils.isNotBlank(req.getBuildOrgName()), WflowEarlyWarningRecords::getBuildOrgName, req.getBuildOrgName()) | .like(StringUtils.isNotBlank(req.getBuildOrgName()), WflowEarlyWarningRecords::getBuildOrgName, req.getBuildOrgName()) | ||||
.ge(Objects.nonNull(req.getStartTime()),WflowEarlyWarningRecords::getWarningTime,req.getStartTime()) | .ge(Objects.nonNull(req.getStartTime()),WflowEarlyWarningRecords::getWarningTime,req.getStartTime()) | ||||
@@ -29,8 +29,6 @@ import com.ningdatech.pmapi.common.helper.UserInfoHelper; | |||||
import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; | import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; | ||||
import com.ningdatech.pmapi.common.util.ExcelDownUtil; | import com.ningdatech.pmapi.common.util.ExcelDownUtil; | ||||
import com.ningdatech.pmapi.irs.sign.IRSAPIRequest; | 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.performance.service.IProjectCoreBusinessIndicatorsService; | ||||
import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; | import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; | ||||
import com.ningdatech.pmapi.projectlib.enumeration.*; | import com.ningdatech.pmapi.projectlib.enumeration.*; | ||||
@@ -103,7 +101,6 @@ import org.springframework.stereotype.Component; | |||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import org.springframework.web.multipart.MultipartFile; | import org.springframework.web.multipart.MultipartFile; | ||||
import sun.misc.BASE64Decoder; | import sun.misc.BASE64Decoder; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
@@ -143,9 +140,7 @@ public class TodoCenterManage { | |||||
private final PassHandle passHandle; | private final PassHandle passHandle; | ||||
private final RepositoryService repositoryService; | private final RepositoryService repositoryService; | ||||
private final IRegionService regionService; | private final IRegionService regionService; | ||||
private final ITodoService todoService; | private final ITodoService todoService; | ||||
private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; | |||||
/** | /** | ||||
* 待办中心待我处理项目列表查询 | * 待办中心待我处理项目列表查询 | ||||
@@ -1102,15 +1097,12 @@ public class TodoCenterManage { | |||||
project.setUpdateOn(LocalDateTime.now()); | project.setUpdateOn(LocalDateTime.now()); | ||||
projectService.save(project); | projectService.save(project); | ||||
oldProject.setIsBackReject(Boolean.TRUE); | |||||
projectService.updateById(oldProject); | |||||
ProjectInst oldInst = projectInstService.getOne(Wrappers.lambdaUpdate(ProjectInst.class) | ProjectInst oldInst = projectInstService.getOne(Wrappers.lambdaUpdate(ProjectInst.class) | ||||
.eq(ProjectInst::getProjectId, oldProject.getId()) | .eq(ProjectInst::getProjectId, oldProject.getId()) | ||||
.eq(ProjectInst::getInstCode, oldProject.getInstCode())); | .eq(ProjectInst::getInstCode, oldProject.getInstCode())); | ||||
String instCode = oldProject.getInstCode(); | String instCode = oldProject.getInstCode(); | ||||
oldInst.setInstCode(TodoCenterConstant.Declared.NULL_INST_CODE); | |||||
oldInst.setInstCode("EMPTY"); | |||||
projectInstService.updateById(oldInst); | projectInstService.updateById(oldInst); | ||||
ProjectInst newPi = new ProjectInst(); | ProjectInst newPi = new ProjectInst(); | ||||