Browse Source

工作通知扫表发送

master
CMM 1 year ago
parent
commit
c217960409
28 changed files with 601 additions and 195 deletions
  1. +1
    -1
      ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java
  2. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/util/StateMachineUtils.java
  3. +26
    -17
      pmapi/src/main/java/com/ningdatech/pmapi/common/util/SendWorkNoticeUtil.java
  4. +1
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java
  5. +10
    -11
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AnnualPlanHandle.java
  6. +4
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ArchivedHandle.java
  7. +4
    -9
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java
  8. +4
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectPreliminaryInspectionHandle.java
  9. +4
    -11
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/TenderPurchaseHandle.java
  10. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectStatusChangeMapper.java
  11. +0
    -95
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/NdProjectStatusChange.java
  12. +48
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectStatusChange.java
  13. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/INdProjectStatusChangeService.java
  14. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/NdProjectStatusChangeServiceImpl.java
  15. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java
  16. +87
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/WorkNoticeFlowTask.java
  17. +51
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java
  18. +21
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/NdWorkNoticeStagingMapper.java
  19. +12
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/NdWorkNoticeStagingMapper.xml
  20. +71
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/model/entity/WorkNoticeStaging.java
  21. +23
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/service/INdWorkNoticeStagingService.java
  22. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/staging/service/IProjectStagingService.java
  23. +84
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/service/impl/NdWorkNoticeStagingServiceImpl.java
  24. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/staging/service/impl/ProjectStagingServiceImpl.java
  25. +83
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/staging/utils/WorkNoticeFlowMapUtil.java
  26. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/WorkNoticeInfo.java
  27. +39
    -25
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  28. +15
    -2
      pmapi/src/test/java/com/ningdatech/pmapi/todocenter/TodoCenterTest.java

+ 1
- 1
ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java View File

@@ -56,7 +56,7 @@ public class GeneratorCodeKingbaseConfig {
}

public static void main(String[] args) {
generate("Liuxinxin", "expert", PATH_LXX, "expert_avoid_company");
generate("Liuxinxin", "expert", PATH_LXX, "expert_avoid_company");
}

}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/common/statemachine/util/StateMachineUtils.java View File

@@ -6,7 +6,7 @@ import com.ningdatech.pmapi.common.constant.StateMachineConstants;
import com.ningdatech.pmapi.common.statemachine.builder.ProjectDeclareStateMachineBuilder;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService;
import lombok.RequiredArgsConstructor;
@@ -44,7 +44,7 @@ public class StateMachineUtils {
public void execute(Project project, ProjectStatusChangeEvent event) throws Exception {
log.info("调用状态机前的项目状态为>>>>>>>>>>{}" + project.getStatus());
// 将状态变更记录保存到项目状态变更表中
NdProjectStatusChange projectStatusChange = new NdProjectStatusChange();
ProjectStatusChange projectStatusChange = new ProjectStatusChange();
projectStatusChange.setBeforeStatus(project.getStatus());
//获取TO状态机
StateMachine<ProjectStatusEnum, ProjectStatusChangeEvent> stateMachine = projectDeclareStateMachineBuilder.build();


+ 26
- 17
pmapi/src/main/java/com/ningdatech/pmapi/common/util/SendWorkNoticeUtil.java View File

@@ -4,8 +4,11 @@ import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.zwdd.client.ZwddClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.*;

/**
@@ -15,18 +18,22 @@ import java.util.concurrent.*;
* @since 2023/02/23 13:50
*/
@Slf4j
@RequiredArgsConstructor
@Component
public class SendWorkNoticeUtil {

private SendWorkNoticeUtil(){
private final ZwddClient zwddClient;

}
/**
* 初始化线程池
*/
public static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 10,
60, TimeUnit.SECONDS, new ArrayBlockingQueue(10), new ThreadPoolExecutor.AbortPolicy());

public static void sendWorkNotice(ZwddClient zwddClient, WorkNoticeInfo workNoticeInfo, String msg){
// 初始化线程池
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(10, 20,
60, TimeUnit.SECONDS, new ArrayBlockingQueue(20), new ThreadPoolExecutor.AbortPolicy());
public Boolean sendWorkNotice(WorkNoticeInfo workNoticeInfo){

// 将发送工作通知交给异步任务Future
String msg = workNoticeInfo.getMsg();
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
// 调用浙政钉的接口发送工作通知
long startTime = System.currentTimeMillis();
@@ -41,17 +48,19 @@ public class SendWorkNoticeUtil {
return "发送工作通知失败!";
}
return "发送工作通知成功!";
}, threadPool);
String s;
try {
s = future.get();
} catch (Exception e) {
throw new BizException("获取异步线程处理结果失败!");
}
threadPool.shutdown();
while (threadPool.isTerminated()) {
}, threadPool);
String s;
try {
s = future.get();
} catch (Exception e) {
throw new BizException("获取异步线程处理结果失败!");
}
threadPool.shutdown();
while (!threadPool.isTerminated()) {
log.info(s);
return Boolean.FALSE;
}
log.info(s);
break;
}
return Boolean.TRUE;
}
}

+ 1
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PrequalificationDeclaredProjectManage.java View File

@@ -8,7 +8,6 @@ import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.projectdeclared.contants.DeclaredProjectContant;
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.model.dto.ProjectConditionDTO;
import com.ningdatech.pmapi.projectdeclared.model.req.PrequalificationDeclaredListReq;
@@ -21,7 +20,7 @@ import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import com.ningdatech.pmapi.projectlib.service.IProjectInstService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.staging.serivice.IProjectStagingService;
import com.ningdatech.pmapi.staging.service.IProjectStagingService;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.wflow.bean.entity.WflowModels;


+ 10
- 11
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/AnnualPlanHandle.java View File

@@ -6,8 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.AnnualPlanLibManage;
import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
@@ -71,26 +70,26 @@ public class AnnualPlanHandle extends AbstractProcessBusinessHandle {
// 项目状态为年度计划中
if (ProjectStatusEnum.IN_THE_ANNUAL_PLAN.getCode().equals(status)){
// 根据部门联审通过的时间获取
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class)
.eq(NdProjectStatusChange::getProjectId, projectId)
.eq(NdProjectStatusChange::getEvent, ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS.name())
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.DEPARTMENT_UNITED_REVIEW_PASS.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);

} else if (ProjectStatusEnum.BE_SUSPENDED.getCode().equals(status)) {
// 根据年度计划暂缓的时间获取
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class)
.eq(NdProjectStatusChange::getProjectId, projectId)
.eq(NdProjectStatusChange::getEvent, ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND.name())
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.ANNUAL_PLAN_SUSPEND.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.REJECTED);
} else {
// 根据开启方案申报的时间获取
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class)
.eq(NdProjectStatusChange::getProjectId, projectId)
.eq(NdProjectStatusChange::getEvent, ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE.name())
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.ANNUAL_PLAN_PROJECT_OPEN_PLAN_DECLARE.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);


+ 4
- 4
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ArchivedHandle.java View File

@@ -11,7 +11,7 @@ import com.ningdatech.pmapi.common.constant.CommonConstant;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.StepStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.vo.ProcessDetailVO;
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService;

@@ -48,9 +48,9 @@ public class ArchivedHandle extends AbstractProcessBusinessHandle {
// 项目阶段为已归档
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
// 根据项目终验获取归档时间
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class)
.eq(NdProjectStatusChange::getProjectId, projectId)
.eq(NdProjectStatusChange::getEvent, ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS.name())
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.FINAL_ACCEPTANCE_PASS.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setProcessName(CommonConstant.ARCHIVED);


+ 4
- 9
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectApprovalHandle.java View File

@@ -3,24 +3,19 @@ package com.ningdatech.pmapi.projectlib.handle;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.constant.CommonConstant;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.StepStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.AnnualPlanLibManage;
import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.AnnualPlanListItemVO;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.vo.ProcessDetailVO;
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
@@ -86,9 +81,9 @@ public class ProjectApprovalHandle extends AbstractProcessBusinessHandle {
// 当前项目状态为待立项批复
if (ProjectStatusEnum.TO_BE_APPROVED.getCode().equals(status)){
// 根据建设方案评审通过的时间获取
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class)
.eq(NdProjectStatusChange::getProjectId, projectId)
.eq(NdProjectStatusChange::getEvent, ProjectStatusChangeEvent.PLAN_REVIEW_PASS.name())
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.PLAN_REVIEW_PASS.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING);


+ 4
- 6
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/ProjectPreliminaryInspectionHandle.java View File

@@ -4,7 +4,6 @@ import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@@ -15,8 +14,7 @@ import com.ningdatech.pmapi.common.constant.CommonConstant;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.StepStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.AnnualPlanLibManage;
import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.vo.ProcessDetailVO;
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService;
@@ -70,9 +68,9 @@ public class ProjectPreliminaryInspectionHandle extends AbstractProcessBusinessH
}else {
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
// 根据初验备案的时间获取
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class)
.eq(NdProjectStatusChange::getProjectId, projectId)
.eq(NdProjectStatusChange::getEvent, ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD.name())
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.PRELIMINARY_ACCEPTANCE_PUT_ON_RECORD.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
}


+ 4
- 11
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/handle/TenderPurchaseHandle.java View File

@@ -2,26 +2,19 @@ package com.ningdatech.pmapi.projectlib.handle;

import static com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.common.constant.CommonConstant;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.enumeration.StepStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.AnnualPlanLibManage;
import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.AnnualPlanListItemVO;
import com.ningdatech.pmapi.projectlib.model.vo.ProcessDetailVO;
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
@@ -74,9 +67,9 @@ public class TenderPurchaseHandle extends AbstractProcessBusinessHandle {
}else if (fieldList.contains(status)){
processDetailVO.setStepStatus(StepStatusEnum.COMPLETED);
// 根据采购备案的时间获取
NdProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(NdProjectStatusChange.class)
.eq(NdProjectStatusChange::getProjectId, projectId)
.eq(NdProjectStatusChange::getEvent, ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD.name())
ProjectStatusChange projectStatusChange = projectStatusChangeService.getOne(Wrappers.lambdaQuery(ProjectStatusChange.class)
.eq(ProjectStatusChange::getProjectId, projectId)
.eq(ProjectStatusChange::getEvent, ProjectStatusChangeEvent.PURCHASE_PUT_ON_RECORD.name())
.last("limit 1"));
processDetailVO.setFinishTime(projectStatusChange.getCreateOn());
}


+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/mapper/NdProjectStatusChangeMapper.java View File

@@ -1,6 +1,6 @@
package com.ningdatech.pmapi.projectlib.mapper;

import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author CMM
* @since 2023-02-27
*/
public interface NdProjectStatusChangeMapper extends BaseMapper<NdProjectStatusChange> {
public interface NdProjectStatusChangeMapper extends BaseMapper<ProjectStatusChange> {

}

+ 0
- 95
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/NdProjectStatusChange.java View File

@@ -1,95 +0,0 @@
package com.ningdatech.pmapi.projectlib.model.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
* <p>
*
* </p>
*
* @author CMM
* @since 2023-02-27
*/
@TableName("nd_project_status_change")
@ApiModel(value = "NdProjectStatusChange对象", description = "")
public class NdProjectStatusChange implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("主键")
private Long id;

@ApiModelProperty("项目ID")
private Long projectId;

@ApiModelProperty("状态机执行前的项目状态")
private Integer beforeStatus;

@ApiModelProperty("状态机执行后的项目状态")
private Integer afterStatus;

@ApiModelProperty("状态变更对应的事件")
private String event;

@ApiModelProperty("状态变更发生的时间")
private LocalDateTime createOn;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}
public Long getProjectId() {
return projectId;
}

public void setProjectId(Long projectId) {
this.projectId = projectId;
}
public Integer getBeforeStatus() {
return beforeStatus;
}

public void setBeforeStatus(Integer beforeStatus) {
this.beforeStatus = beforeStatus;
}
public Integer getAfterStatus() {
return afterStatus;
}

public void setAfterStatus(Integer afterStatus) {
this.afterStatus = afterStatus;
}
public String getEvent() {
return event;
}

public void setEvent(String event) {
this.event = event;
}
public LocalDateTime getCreateOn() {
return createOn;
}

public void setCreateOn(LocalDateTime createOn) {
this.createOn = createOn;
}

@Override
public String toString() {
return "NdProjectStatusChange{" +
"id=" + id +
", projectId=" + projectId +
", beforeStatus=" + beforeStatus +
", afterStatus=" + afterStatus +
", event=" + event +
", createOn=" + createOn +
"}";
}
}

+ 48
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectStatusChange.java View File

@@ -0,0 +1,48 @@
package com.ningdatech.pmapi.projectlib.model.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* <p>
*
* </p>
*
* @author CMM
* @since 2023-02-27
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("nd_project_status_change")
@ApiModel(value = "NdProjectStatusChange对象", description = "")
public class ProjectStatusChange implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("主键")
private Long id;

@ApiModelProperty("项目ID")
private Long projectId;

@ApiModelProperty("状态机执行前的项目状态")
private Integer beforeStatus;

@ApiModelProperty("状态机执行后的项目状态")
private Integer afterStatus;

@ApiModelProperty("状态变更对应的事件")
private String event;

@ApiModelProperty("状态变更发生的时间")
private LocalDateTime createOn;
}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/INdProjectStatusChangeService.java View File

@@ -1,6 +1,6 @@
package com.ningdatech.pmapi.projectlib.service;

import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.baomidou.mybatisplus.extension.service.IService;

/**
@@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @author CMM
* @since 2023-02-27
*/
public interface INdProjectStatusChangeService extends IService<NdProjectStatusChange> {
public interface INdProjectStatusChangeService extends IService<ProjectStatusChange> {

}

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/service/impl/NdProjectStatusChangeServiceImpl.java View File

@@ -1,6 +1,6 @@
package com.ningdatech.pmapi.projectlib.service.impl;

import com.ningdatech.pmapi.projectlib.model.entity.NdProjectStatusChange;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectStatusChange;
import com.ningdatech.pmapi.projectlib.mapper.NdProjectStatusChangeMapper;
import com.ningdatech.pmapi.projectlib.service.INdProjectStatusChangeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,6 +15,6 @@ import org.springframework.stereotype.Service;
* @since 2023-02-27
*/
@Service
public class NdProjectStatusChangeServiceImpl extends ServiceImpl<NdProjectStatusChangeMapper, NdProjectStatusChange> implements INdProjectStatusChangeService {
public class NdProjectStatusChangeServiceImpl extends ServiceImpl<NdProjectStatusChangeMapper, ProjectStatusChange> implements INdProjectStatusChangeService {

}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/ProjectStatusFlowTask.java View File

@@ -8,7 +8,7 @@ import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.scheduler.contants.TaskContant;
import com.ningdatech.pmapi.staging.contants.StagingContant;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import com.ningdatech.pmapi.staging.serivice.IProjectStagingService;
import com.ningdatech.pmapi.staging.service.IProjectStagingService;
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;


+ 87
- 0
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/WorkNoticeFlowTask.java View File

@@ -0,0 +1,87 @@
package com.ningdatech.pmapi.scheduler.task;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;

import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.pmapi.staging.model.entity.WorkNoticeStaging;
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService;
import com.ningdatech.pmapi.staging.utils.WorkNoticeFlowMapUtil;
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.zwdd.client.ZwddClient;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.scheduler.contants.TaskContant;
import com.ningdatech.pmapi.staging.contants.StagingContant;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import com.ningdatech.pmapi.staging.service.IProjectStagingService;
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil;

import cn.hutool.core.collection.CollUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
* 发送工作通知定时任务
* @return
* @author CMM
* @since 2023/02/28 21:23
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class WorkNoticeFlowTask {

private final INdWorkNoticeStagingService workNoticeStagingService;
private final ZwddClient zwddClient;

@Scheduled(cron = "0 */1 * * * ?")
public void statusFlow() throws UnknownHostException {
//测试暂时用自己电脑HOST
if (TaskContant.Host.HOST_CMM.equals(InetAddress.getLocalHost().getHostName())) {
//1. 定时取 工作通知暂存表的数据进行发送
List<WorkNoticeStaging> stagingList = workNoticeStagingService.list(Wrappers.lambdaQuery(WorkNoticeStaging.class)
.eq(WorkNoticeStaging::getDead, Boolean.FALSE)
.ge(WorkNoticeStaging::getNextTime, LocalDateTime.now())
.le(WorkNoticeStaging::getRetryTimes, StagingContant.Retry.MAX_RETRY_TIMES)
.orderByAsc(WorkNoticeStaging::getId));

log.info("需要发送的工作通知 size:{} :{}",stagingList.size(), JSON.toJSONString(stagingList));
if(CollUtil.isEmpty(stagingList)){
log.info("没有需要发送的工作通知!");
return;
}
//遍历
for(WorkNoticeStaging workNoticeStaging : stagingList){
try{
WorkNoticeInfo workNoticeInfo = new WorkNoticeInfo();
BeanUtils.copyProperties(workNoticeStaging,workNoticeInfo);
String receiverUserId = workNoticeInfo.getReceiverUserId();
String bizMsgId = workNoticeInfo.getBizMsgId();
String msg = workNoticeInfo.getMsg();
GenericResult<Void> result = zwddClient.sendWorkNotice(receiverUserId, bizMsgId, msg);
if (result.isSuccess()){
//执行成功了 删除暂存的数据
workNoticeStagingService.removeById(workNoticeStaging);
}
}catch (Exception e){
log.error("发送工作通知 异常 bizMsgId:【" + workNoticeStaging.getBizMsgId() + "】 异常内容:" + e);
}finally {
//增加重试的次数 和下次扫描时间
workNoticeStagingService.addRetryTimes(workNoticeStaging);
}
}
}
}
}

+ 51
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/enums/MsgTypeEnum.java View File

@@ -0,0 +1,51 @@
package com.ningdatech.pmapi.staging.enums;

import com.ningdatech.pmapi.projectlib.enumeration.StepStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
* 消息类型枚举
* @author CMM
* @since 2023/02/28 17:34
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum MsgTypeEnum {
/**
* 消息类型
*/
AUDIT(1, "项目审核(待审核)"),
PASS(2, "项目审核(通过)"),
REJECTED(3,"项目审核(被驳回)"),
BACKED(4,"项目审核(被退回)"),
WARING(5,"预警提醒"),
EXPORT_REVIEW(6,"专家评审"),
REVIEW_MEETING(7,"评审会议");

private Integer code;
private String desc;

public static String getDescByCode(Integer code) {
if (Objects.isNull(code)) {
return StringUtils.EMPTY;
}
for (MsgTypeEnum t : MsgTypeEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
}
return StringUtils.EMPTY;
}

public boolean eq(String val) {
return this.name().equals(val);
}


}

+ 21
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/NdWorkNoticeStagingMapper.java View File

@@ -0,0 +1,21 @@
package com.ningdatech.pmapi.staging.mapper;

import com.ningdatech.pmapi.staging.model.entity.WorkNoticeStaging;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;

/**
* <p>
* Mapper 接口
* </p>
*
* @author CMM
* @since 2023-02-28
*/
public interface NdWorkNoticeStagingMapper extends BaseMapper<WorkNoticeStaging> {

Boolean addRetryTimes(@Param("id") Long id, @Param("retryTimes") Integer retryTimes,
@Param("nextRetryTime") LocalDateTime nextRetryTime, @Param("dead") Boolean dead);
}

+ 12
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/mapper/NdWorkNoticeStagingMapper.xml View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ningdatech.pmapi.staging.mapper.NdWorkNoticeStagingMapper">

<update id="addRetryTimes">
update nd_work_notice_staging
set retry_times = #{retryTimes},
next_time = #{nextRetryTime},
dead = #{dead}
where id = #{id} and retry_times = #{retryTimes - 1}
</update>
</mapper>

+ 71
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/model/entity/WorkNoticeStaging.java View File

@@ -0,0 +1,71 @@
package com.ningdatech.pmapi.staging.model.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* <p>
*
* </p>
*
* @author CMM
* @since 2023-02-28
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("nd_work_notice_staging")
@ApiModel(value = "NdWorkNoticeStaging对象", description = "")
public class WorkNoticeStaging implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("主键")
private Long id;

@ApiModelProperty("浙政钉用户ID")
private Long accountId;

@ApiModelProperty("部门编号")
private String organizationCode;

@ApiModelProperty("部门名称")
private String organizationName;

@ApiModelProperty("工作通知唯一标识")
private String bizMsgId;

@ApiModelProperty("接收人浙政钉ID")
private String receiverUserId;

@ApiModelProperty("工作通知内容")
private String msg;

@ApiModelProperty("重试次数 最大10次")
private Integer retryTimes;

@ApiModelProperty("false 可继续扫描 true 死信")
private Boolean dead;

@ApiModelProperty("下次扫描时间")
private LocalDateTime nextTime;

@ApiModelProperty("消息类型")
private MsgTypeEnum msgType;

@ApiModelProperty("创建时间")
private LocalDateTime createOn;

@ApiModelProperty("更新时间")
private LocalDateTime updateOn;
}

+ 23
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/service/INdWorkNoticeStagingService.java View File

@@ -0,0 +1,23 @@
package com.ningdatech.pmapi.staging.service;

import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import com.ningdatech.pmapi.staging.model.entity.WorkNoticeStaging;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;

/**
* <p>
* 服务类
* </p>
*
* @author CMM
* @since 2023-02-28
*/
public interface INdWorkNoticeStagingService extends IService<WorkNoticeStaging> {

Boolean addRetryTimes(WorkNoticeStaging workNoticeStaging);

public Boolean addByWorkNotice(WorkNoticeInfo workNoticeInfo, MsgTypeEnum msgType) ;
}

pmapi/src/main/java/com/ningdatech/pmapi/staging/serivice/IProjectStagingService.java → pmapi/src/main/java/com/ningdatech/pmapi/staging/service/IProjectStagingService.java View File

@@ -1,4 +1,4 @@
package com.ningdatech.pmapi.staging.serivice;
package com.ningdatech.pmapi.staging.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.projectlib.model.entity.Project;

+ 84
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/service/impl/NdWorkNoticeStagingServiceImpl.java View File

@@ -0,0 +1,84 @@
package com.ningdatech.pmapi.staging.service.impl;

import com.ningdatech.pmapi.staging.contants.StagingContant;
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import com.ningdatech.pmapi.staging.model.entity.WorkNoticeStaging;
import com.ningdatech.pmapi.staging.mapper.NdWorkNoticeStagingMapper;
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.staging.utils.WorkNoticeFlowMapUtil;
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
* <p>
* 服务实现类
* </p>
*
* @author CMM
* @since 2023-02-28
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class NdWorkNoticeStagingServiceImpl extends ServiceImpl<NdWorkNoticeStagingMapper, WorkNoticeStaging> implements INdWorkNoticeStagingService {

private final NdWorkNoticeStagingMapper mapper;

private final WorkNoticeFlowMapUtil workNoticeFlowMapUtil;

/**
* 增加 重试次数 和下次扫描时间
* @param workNoticeStaging
* @return java.lang.Boolean
* @author CMM
* @since 2023/02/28 18:02
*/
@Override
public Boolean addRetryTimes(WorkNoticeStaging workNoticeStaging) {
Integer retryTimes = workNoticeStaging.getRetryTimes() + 1;
if(!workNoticeFlowMapUtil.intervalTimeMap.containsKey(retryTimes)){
log.info("没有对应重试间隔时间 添加重试信息失败");
return Boolean.FALSE;
}
Integer addSeconds = workNoticeFlowMapUtil.intervalTimeMap.get(retryTimes);
Boolean dead = Boolean.FALSE;
//超过重试最大次数 dead置为 true
if(retryTimes.compareTo(StagingContant.Retry.MAX_RETRY_TIMES) > 0){
dead = Boolean.TRUE;
}
LocalDateTime nextRetryTime = LocalDateTime.now().plusSeconds(addSeconds);
return mapper.addRetryTimes(workNoticeStaging.getId(),retryTimes,nextRetryTime,dead);
}

/**
* 在对应的流程处理后,增加一个工作通知到暂存表中
* @param workNoticeInfo
* @param msgType
* @return java.lang.Boolean
* @author CMM
* @since 2023/02/28 20:02
*/
@Override
public Boolean addByWorkNotice(WorkNoticeInfo workNoticeInfo, MsgTypeEnum msgType) {
WorkNoticeStaging workNoticeStaging = WorkNoticeStaging.builder()
.accountId(workNoticeInfo.getAccountId())
.msg(workNoticeInfo.getMsg())
.bizMsgId(workNoticeInfo.getBizMsgId())
.organizationCode(workNoticeInfo.getOrganizationCode())
.organizationName(workNoticeInfo.getOrganizationName())
.receiverUserId(workNoticeInfo.getReceiverUserId())
.msgType(msgType)
.createOn(LocalDateTime.now())
.updateOn(LocalDateTime.now())
.nextTime(LocalDateTime.now())
.retryTimes(0)
.build();
return this.save(workNoticeStaging);
}
}

pmapi/src/main/java/com/ningdatech/pmapi/staging/serivice/impl/ProjectStagingServiceImpl.java → pmapi/src/main/java/com/ningdatech/pmapi/staging/service/impl/ProjectStagingServiceImpl.java View File

@@ -1,11 +1,11 @@
package com.ningdatech.pmapi.staging.serivice.impl;
package com.ningdatech.pmapi.staging.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.staging.contants.StagingContant;
import com.ningdatech.pmapi.staging.mapper.ProjectStagingMapper;
import com.ningdatech.pmapi.staging.model.entity.ProjectStaging;
import com.ningdatech.pmapi.staging.serivice.IProjectStagingService;
import com.ningdatech.pmapi.staging.service.IProjectStagingService;
import com.ningdatech.pmapi.staging.utils.ProjectStatusFlowMapUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

+ 83
- 0
pmapi/src/main/java/com/ningdatech/pmapi/staging/utils/WorkNoticeFlowMapUtil.java View File

@@ -0,0 +1,83 @@
package com.ningdatech.pmapi.staging.utils;

import java.util.List;
import java.util.Map;
import java.util.function.Function;

import javax.annotation.PostConstruct;

import com.ningdatech.pmapi.common.util.SendWorkNoticeUtil;
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.staging.model.entity.WorkNoticeStaging;
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import org.springframework.stereotype.Component;

import com.google.common.collect.Maps;
import com.ningdatech.pmapi.projectdeclared.manage.ReviewByDeptJointManage;
import com.ningdatech.pmapi.projectdeclared.manage.ReviewByProvincialDeptManage;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project;

import lombok.RequiredArgsConstructor;

/**
* 工作通知流转 事件函数MAP
* @return
* @author CMM
* @since 2023/02/28 17:03
*/
@Component
@RequiredArgsConstructor
public class WorkNoticeFlowMapUtil {
//public Map<Integer, Function<WorkNoticeInfo,Boolean>> workNoticeFlowFunctionMap = Maps.newHashMap();
/**
* key 重试的次数 , value 是增加是描述
*/
public Map<Integer, Integer> intervalTimeMap = Maps.newHashMap();

///**
// * 初始化工作通知分派逻辑,代替了if-else部分
// * key: 枚举 消息类型
// * value: lambda表达式,最终会获取发送工作通知的函数
// */
//@PostConstruct
//public void workNoticeFlowFunctionInit(){
// // 待审核
// workNoticeFlowFunctionMap.put(MsgTypeEnum.AUDIT.getCode(),
// workNoticeInfos-> SendWorkNoticeUtil.sendWorkNotice(workNoticeInfos));
//
// // 审核通过
// workNoticeFlowFunctionMap.put(MsgTypeEnum.PASS.getCode(),
// workNoticeInfos-> SendWorkNoticeUtil.sendWorkNotice(workNoticeInfos));
//
// // 被驳回
// workNoticeFlowFunctionMap.put(MsgTypeEnum.REJECTED.getCode(),
// workNoticeInfos-> SendWorkNoticeUtil.sendWorkNotice(workNoticeInfos));
//
// // 被退回
// workNoticeFlowFunctionMap.put(MsgTypeEnum.BACKED.getCode(),
// workNoticeInfos-> SendWorkNoticeUtil.sendWorkNotice(workNoticeInfos));
//
// // 被驳回
// workNoticeFlowFunctionMap.put(MsgTypeEnum.REJECTED.getCode(),
// workNoticeInfos-> SendWorkNoticeUtil.sendWorkNotice(workNoticeInfos));
//
//}

/**
* 扫描的间隔越来越长 秒数
*/
@PostConstruct
public void intervalTimeMapInit(){
intervalTimeMap.put(1,60 * 2);
intervalTimeMap.put(2,60 * 6);
intervalTimeMap.put(3,60 * 15);
intervalTimeMap.put(4,60 * 30);
intervalTimeMap.put(5,60 * 60);
intervalTimeMap.put(6,60 * 60 * 2);
intervalTimeMap.put(7,60 * 60 * 5);
intervalTimeMap.put(8,60 * 60 * 12);
intervalTimeMap.put(9,60 * 60 * 24);
intervalTimeMap.put(10,60 * 60 * 72);
}
}

+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/bean/entity/WorkNoticeInfo.java View File

@@ -14,6 +14,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
public class WorkNoticeInfo {
private String msg;
private Long accountId;
private String organizationCode;
private String organizationName;


+ 39
- 25
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -10,10 +10,12 @@ import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.pmapi.common.constant.CommonConstant;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter;
import com.ningdatech.pmapi.common.statemachine.event.ProjectStatusChangeEvent;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.common.util.SendWorkNoticeUtil;
import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo;
import com.ningdatech.pmapi.organization.model.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService;
@@ -24,6 +26,8 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
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.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.enumeration.IsAppendProjectEnum;
@@ -33,6 +37,7 @@ import com.ningdatech.pmapi.todocenter.model.dto.req.ToBeProcessedExportReq;
import com.ningdatech.pmapi.todocenter.model.dto.vo.ResToBeProcessedVO;

import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.ningdatech.zwdd.client.ZwddClient;
@@ -87,6 +92,8 @@ public class TodoCenterManage {
private final IDingEmployeeInfoService dingEmployeeInfoService;
private final IDingOrganizationService dingOrganizationService;
private final ProcessInstanceService processInstanceService;
private final ZwddClient zwddClient;
private final INdWorkNoticeStagingService workNoticeStagingService;


/**
@@ -261,46 +268,46 @@ public class TodoCenterManage {
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo passWorkNoticeInfo = getSendWorkNoticeInfo(auditUserInfo);
String passMsg = String.format(PASS_MSG_TEMPLATE, passWorkNoticeInfo.getOrganizationName(), projectName);
// 异步发送工作通知
// SendWorkNoticeUtil.sendWorkNotice(zwddClient,passWorkNoticeInfo,passMsg);
passWorkNoticeInfo.setMsg(passMsg);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.AUDIT);
return;
}
// 若不是被退回状态,流程通过后,判断当前登录用户是不是最后一个审核人

// TODO 若当前流程是预审流程,需要在提交预审申报的时候,调用状态机判断申报后的项目状态,
// 若是省级部门联审中,要对接外部接口,获取省级部门联审的结果,更新项目状态(预审申报提交的时候处理)

// 若当前登录用户是最后一个审批人,需更新流程状态为审核完成,项目状态到下个状态
// 并向流程发起人发送浙政钉工作通知:【项目名称】已通过【流程名称】,请及时开始下一步操作。
if (HisProInsEndActId.END.equals(newInstance.getEndActivityId())) {
switch (Objects.requireNonNull(ProjectStatusEnum.getValue(projectStatus))) {
// 当前项目状态是单位内部审核中
case UNDER_INTERNAL_AUDIT:
// 当前项目状态是预审中
// 当前项目状态是预审中
case PRE_APPLYING:
// 当前项目状态是部门联审中
// 当前项目状态是部门联审中
case DEPARTMENT_JOINT_REVIEW:
// 当前项目状态是方案评审中
// 当前项目状态是方案评审中
case SCHEME_UNDER_REVIEW:
// 当前项目状态是终验审核中
// 当前项目状态是终验审核中
case FINAL_ACCEPTANCE_IS_UNDER_REVIEW:
updatePassProjectStatus(userId, declaredProject);
break;
default:
throw new IllegalStateException("Unexpected value: " + projectStatus);
}
// WorkNoticeInfo passWorkNoticeInfo2 = getSendWorkNoticeInfo(startUserInfo);
// String passMsg2 = String.format(PASS_MSG_TEMPLATE2, projectName, processDefinitionName);
// 异步发送工作通知
// SendWorkNoticeUtil.sendWorkNotice(zwddClient,passWorkNoticeInfo2,passMsg2);
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo passWorkNoticeInfo2 = getSendWorkNoticeInfo(startUserInfo);
String passMsg2 = String.format(PASS_MSG_TEMPLATE2, projectName, processDefinitionName);
passWorkNoticeInfo2.setMsg(passMsg2);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo2, MsgTypeEnum.PASS);
}else {
// 若有下一个审核人(当前节点的用户),
// 向其发送浙政钉工作通知:标题:审核任务 内容:【单位名称】的【项目名称】需要您审核。
// 获取发送浙政钉工作通知必要信息
// WorkNoticeInfo sendWorkNoticeInfo = getSendWorkNoticeInfo(auditUserInfo);
// String msg = String.format(PASS_MSG_TEMPLATE, null, projectName);
// 异步发送工作通知
// SendWorkNoticeUtil.sendWorkNotice(zwddClient,sendWorkNoticeInfo,msg);
WorkNoticeInfo sendWorkNoticeInfo = getSendWorkNoticeInfo(auditUserInfo);
String msg = String.format(PASS_MSG_TEMPLATE, sendWorkNoticeInfo.getOrganizationName(), projectName);
sendWorkNoticeInfo.setMsg(msg);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(sendWorkNoticeInfo, MsgTypeEnum.AUDIT);
}
break;
// 盖章并通过
@@ -314,12 +321,14 @@ public class TodoCenterManage {
// 驳回该任务,中止流程并使项目进入对应状态,给项目创建人、流程发起人发送浙政钉工作通知:
// 【项目名称】的【流程名称】被驳回,请及时处理。
processTaskService.handleTask(param, userId);
WorkNoticeInfo rejectWorkNoticeInfo = getSendWorkNoticeInfo(startUserInfo);
String rejectMsg = String.format(REJECT_MSG_TEMPLATE, projectName, processDefinitionName);
// 异步发送工作通知
// SendWorkNoticeUtil.sendWorkNotice(zwddClient,rejectWorkNoticeInfo,rejectMsg);
// 更新项目状态和流程状态
updateRejectProjectStatus(userId, declaredProject);
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo rejectWorkNoticeInfo = getSendWorkNoticeInfo(startUserInfo);
String rejectMsg = String.format(REJECT_MSG_TEMPLATE, projectName, processDefinitionName);
rejectWorkNoticeInfo.setMsg(rejectMsg);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(rejectWorkNoticeInfo, MsgTypeEnum.REJECTED);
break;
// 退回
case BACK:
@@ -331,10 +340,12 @@ public class TodoCenterManage {
declaredProject.setUpdateBy(userId);
projectService.updateById(declaredProject);
// 给项目创建人、流程发起人发送浙政钉工作通知:【项目名称】的【流程名称】被退回,请及时处理。
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo backWorkNoticeInfo = getSendWorkNoticeInfo(startUserInfo);
String backMsg = String.format(BACK_MSG_TEMPLATE, projectName, processDefinitionName);
// 异步发送工作通知
// SendWorkNoticeUtil.sendWorkNotice(zwddClient,backWorkNoticeInfo,backMsg);
backWorkNoticeInfo.setMsg(backMsg);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(backWorkNoticeInfo, MsgTypeEnum.BACKED);
break;
// 撤回(流程发起人和当前流程审核人的前一个审核人操作)
case WITHDRAW:
@@ -369,9 +380,12 @@ public class TodoCenterManage {
ProcessInstanceUserDto currentUser = currentProgressNode.getUser();
// 判断当前工作流任务前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常
boolean orgFlag = currentUser.getOrgCode().equals(beforeUser.getOrgCode());
boolean userFlag = beforeUser.getUserId().equals(String.valueOf( userId));
if (!orgFlag) {
throw new BizException("下一个审核人和您不是同一个部门,无法撤回!");
} else {
} else if (!userFlag){
throw new BizException("当前登录用户无法进行撤回操作!");
} else{
processTaskService.handleTask(param, userId);
}
}


+ 15
- 2
pmapi/src/test/java/com/ningdatech/pmapi/todocenter/TodoCenterTest.java View File

@@ -4,6 +4,8 @@ import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.beanconfig.BeanConfig;
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum;
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService;
import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo;
import com.ningdatech.pmapi.todocenter.manage.TodoCenterManage;
import com.ningdatech.pmapi.user.entity.UserInfo;
@@ -37,12 +39,12 @@ public class TodoCenterTest extends AppTests {

@Autowired
private TodoCenterManage todoCenterManage;

@Autowired
private IUserInfoService userInfoService;

@Autowired
private ZwddClient zwddClient;
@Autowired
private INdWorkNoticeStagingService workNoticeStagingService;
@Test
public void sendWorkNoticeTest() throws ExecutionException, InterruptedException {
//String msg = String.format(PASS_MSG_TEMPLATE, "发改委", "0223-00-测试项目");
@@ -93,4 +95,15 @@ public class TodoCenterTest extends AppTests {
break;
}
}

@Test
public void sendWorkNoticeTest2(){
UserInfo userInfo = userInfoService.getById(4L);
// 获取发送浙政钉工作通知必要信息
WorkNoticeInfo passWorkNoticeInfo = todoCenterManage.getSendWorkNoticeInfo(userInfo);
String passMsg = String.format(PASS_MSG_TEMPLATE, passWorkNoticeInfo.getOrganizationName(), "测试项目0301-1");
passWorkNoticeInfo.setMsg(passMsg);
// 放入工作通知暂存表中,通过扫表异步发送
workNoticeStagingService.addByWorkNotice(passWorkNoticeInfo, MsgTypeEnum.AUDIT);
}
}

Loading…
Cancel
Save