diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/ProjectDeclareConstants.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/ProjectDeclareConstants.java new file mode 100644 index 0000000..0f18c2b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/constant/ProjectDeclareConstants.java @@ -0,0 +1,154 @@ +package com.ningdatech.pmapi.common.constant; +/** + * 项目申报表单数据常量key + * @return + * @author CMM + * @since 2023/01/19 10:31 + */ +public interface ProjectDeclareConstants { + + /** + * 基本信息 + */ + class BasicInformation { + // 项目名称 + public static final String PROJECT_NAME = "projectName"; + // 是否一地创新全省共享项目 + public static final String INNOVATION_SHARING_PROJECT = "innovationSharingProject"; + // 是否临时增补 + public static final String TEMPORARY_SUPPLEMENT = "temporarySupplement"; + // 项目负责人 + public static final String PROJECT_LEADER = "projectLeader"; + // 项目负责人手机号 + public static final String PROJECT_LEADER_PHONE_NUMBER = "projectLeaderPhoneNumber"; + // 项目联系人 + public static final String PROJECT_CONTACT = "projectContact"; + // 项目联系人手机号 + public static final String PROJECT_CONTACT_PHONE_NUMBER = "projectContactPhoneNumber"; + // 建设单位 + public static final String CONSTRUCTION_UNIT = "constructionUnit"; + // 建设单位统一信用代码 + public static final String CONSTRUCTION_UNIT_UNIFIED_CREDIT_CODE = "constructionUnitUnifiedCreditCode"; + // 项目类型 + public static final String PROJECT_TYPE = "projectType"; + // 是否首次新建 + public static final String FIRST_NEW_CONSTRUCTION = "firstNewConstruction"; + // 预算年度 + public static final String BUDGET_YEAR = "budgetYear"; + // 建设开始时间 + public static final String CONSTRUCTION_START_TIME = "constructionStartTime"; + // 建设结束时间 + public static final String CONSTRUCTION_END_TIME = "constructionEndTime"; + // 四大体系 + public static final String FOUR_SYSTEM = "fourSystem"; + // 是否数字化改革项目 + public static final String DIGITAL_REFORM_PROJECT = "digitalReformProject"; + // 建设层级 + public static final String CONSTRUCTION_HIERARCHY = "constructionHierarchy"; + // 立项依据材料 + public static final String PROJECT_BASIS_MATERIAL = "projectBasisMaterial"; + // 发改编码 + public static final String CHANGE_CODE = "changeCode"; + // 财政编码 + public static final String FISCAL_CODE = "fiscalCode"; + // 是否上云 + public static final String ON_CLOUD = "onCloud"; + // 项目简介 + public static final String PROJECT_INTRODUCTION = "projectIntroduction"; + } + + /** + * 资金申报情况 + */ + class FundDeclareInfo { + // 申报金额 + public static final String DECLARE_AMOUNT = "declareAmount"; + // 自有资金 + public static final String OWN_FUND = "ownFund"; + // 政府投资-本级财政资金 + public static final String GOVERNMENT_INVESTMENT_SAME_LEVEL_FUND = "governmentInvestmentSameLevelFund"; + // 政府投资-上级补助资金 + public static final String GOVERNMENT_INVESTMENT_SUPERIOR_FUND = "governmentInvestmentSuperiorFund"; + // 银行贷款 + public static final String BANK_LOAN = "bankLoan"; + // 其他资金 + public static final String OTHER_FUND = "otherFund"; + } + + /** + * 总投资分配情况 + */ + class TotalInvestmentAllocations { + // 软件开发 + public static final String SOFTWARE_DEVELOPMENT = "softwareDevelopment"; + // 云资源、硬件配置 + public static final String CLOUD_RESOURCE_HARDWARE_CONFIGURATION = "cloudResourceHardwareConfiguration"; + // 第三方服务 + public static final String THIRD_PARTY_SERVICE = "thirdPartyService"; + } + /** + * 年度支付计划 + */ + class AnnualPaymentPlan { + // 年度支付金额 + public static final String ANNUAL_PAYMENT_AMOUNT = "annualPaymentAmount"; + // 自有资金 + public static final String OWN_FUND = "ownFund"; + // 政府投资-本级财政资金 + public static final String GOVERNMENT_INVESTMENT_SAME_LEVEL_FUND = "governmentInvestmentSameLevelFund"; + // 政府投资-上级补助资金 + public static final String GOVERNMENT_INVESTMENT_SUPERIOR_FUND = "governmentInvestmentSuperiorFund"; + // 银行贷款 + public static final String BANK_LOAN = "bankLoan"; + // 其他 + public static final String OTHER = "other"; + } + /** + * 核心业务 + */ + class CoreBusiness { + + } + /** + * 安全投入 + */ + class SafetyInput { + // 投入项 + public static final String INPUT_ITEM = "inputItem"; + // 内容描述 + public static final String CONTENT_DESCRIPTION = "contentDescription"; + // 金额 + public static final String AMOUNT = "amount"; + } + /** + * 工程形象进度 + */ + class ProjectImageProgress { + // 第一季度 + public static final String FIRST_QUARTER = "firstQuarter"; + // 第二季度 + public static final String SECOND_QUARTER = "secondQuarter"; + // 第三季度 + public static final String THIRD_QUARTER = "thirdQuarter"; + // 第四季度 + public static final String FOURTH_QUARTER = "fourthQuarter"; + } + /** + * 附件 + */ + class Appendix { + + } + /** + * 备注 + */ + class Remark { + + } + /** + * 应用信息 + */ + class ApplicationInformation { + + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java new file mode 100644 index 0000000..0340347 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java @@ -0,0 +1,47 @@ +package com.ningdatech.pmapi.todocenter.controller; + + +import javax.validation.Valid; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.ningdatech.basic.model.ApiResponse; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.todocenter.manage.TodoCenterManage; +import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedDTO; +import com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeProcessedDTO; + +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; + +/** + *

+ * 待办中心 前端控制器 + *

+ * + * @author CMM + * @since 2023-01-12 + */ +@RestController +@AllArgsConstructor +@Api(tags = "待办中心控制器") +@RequestMapping("/api/v1/todo-center") +public class TodoCenterController { + + private final TodoCenterManage todoCenterManage; + + /** + * 查询待办中心-待我处理中非增补项目列表 + * @param param + * @return + */ + @GetMapping("/NotAppendProjectList") + public ApiResponse> queryProjectList(@Valid @ModelAttribute ReqToBeProcessedDTO param){ + PageVo result = todoCenterManage.queryProjectList(param); + return ApiResponse.ofSuccess(result); + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/IsAppendProjectEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/IsAppendProjectEnum.java new file mode 100644 index 0000000..a744804 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/IsAppendProjectEnum.java @@ -0,0 +1,70 @@ +package com.ningdatech.pmapi.todocenter.enums; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * 是否增补项目枚举 + * @author CMM + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "IsAppendProjectEnum", description = "是否增补项目-枚举") +public enum IsAppendProjectEnum { + /** + * 非增补项目 + */ + NOT_APPEND_PROJECT(0, "非增补项目"), + + /** + *增补项目 + */ + APPEND_PROJECT(1, "增补项目"); + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (IsAppendProjectEnum t : IsAppendProjectEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static IsAppendProjectEnum getEnumByValue(Integer code) { + if(Objects.isNull(code)){ + return null; + } + for (IsAppendProjectEnum t : IsAppendProjectEnum.values()) { + if (code.equals(t.getCode())) { + return t; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/ProcessStatusEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/ProcessStatusEnum.java new file mode 100644 index 0000000..66d3c73 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/enums/ProcessStatusEnum.java @@ -0,0 +1,93 @@ +package com.ningdatech.pmapi.todocenter.enums; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * 待办中心-流程状态枚举 + * @author CMM + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "ProcessStatusEnum", description = "流程状态-枚举") +public enum ProcessStatusEnum { + /** + * 审核中 + */ + + UNDER_REVIEW(1, "审核中"), + + /** + * 被退回 + */ + BE_RETURNED(2, "被退回"), + + /** + * 被驳回 + */ + BE_REJECTED(3,"被驳回"), + + /** + * 审核通过 + */ + APPROVED(4,"审核通过"); + + + private Integer code; + private String desc; + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public static String getDescByCode(Integer code) { + if(Objects.isNull(code)){ + return StringUtils.EMPTY; + } + for (ProcessStatusEnum t : ProcessStatusEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } + + public static Integer getCodeByDesc(String desc) { + if(Objects.isNull(desc)){ + return null; + } + for (ProcessStatusEnum t : ProcessStatusEnum.values()) { + if (desc.equals(t.getCode())) { + return t.code; + } + } + return null; + } + + public static ProcessStatusEnum getEnumByValue(Integer code) { + if(Objects.isNull(code)){ + return null; + } + for (ProcessStatusEnum t : ProcessStatusEnum.values()) { + if (code.equals(t.getCode())) { + return t; + } + } + return null; + } + + public boolean eq(String val) { + return this.name().equals(val); + } +} 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 new file mode 100644 index 0000000..f9d3f68 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -0,0 +1,124 @@ +package com.ningdatech.pmapi.todocenter.manage; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ningdatech.basic.util.NdDateUtils; +import com.ningdatech.pmapi.common.constant.ProjectDeclareConstants; +import com.ningdatech.pmapi.todocenter.enums.ProcessStatusEnum; +import com.ningdatech.pmapi.user.util.LoginUserUtil; +import com.wflow.workflow.bean.dto.ProcessInstanceOwnerDto; +import com.wflow.workflow.bean.process.OrgUser; +import com.wflow.workflow.bean.vo.ProcessProgressVo; +import com.wflow.workflow.bean.vo.ProcessTaskVo; +import com.wflow.workflow.service.ProcessInstanceService; +import com.wflow.workflow.service.UserDeptOrLeaderService; +import org.flowable.engine.RepositoryService; +import org.flowable.engine.RuntimeService; +import org.flowable.engine.TaskService; +import org.flowable.engine.repository.ProcessDefinition; +import org.flowable.engine.runtime.ProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskQuery; + +import org.springframework.stereotype.Component; +import com.ningdatech.basic.model.PageVo; + +import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedDTO; +import com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeProcessedDTO; +import lombok.RequiredArgsConstructor; + + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @author CMM + * @since 2023/01/12 16:09 + */ +@Component +@RequiredArgsConstructor +public class TodoCenterManage { + + private final TaskService taskService; + private final RepositoryService repositoryService; + private final RuntimeService runtimeService; + private final UserDeptOrLeaderService userDeptOrLeaderService; + private final ProcessInstanceService processService; + public PageVo queryProjectList(ReqToBeProcessedDTO param) { + // 获取登录用户ID + Long userId = LoginUserUtil.getUserId(); + // 获取入参分页信息 + Integer pageSize = param.getPageSize(); + Integer pageNumber = param.getPageNumber(); + + TaskQuery taskQuery = taskService.createTaskQuery(); + taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc(); + Page page = param.page(); + + List taskList = taskQuery.listPage(pageSize * (pageNumber - 1), pageSize); + Set staterUsers = new HashSet<>(); + List resVos = taskList.stream().map(task -> { + String nodeId = task.getTaskDefinitionKey(); + String instanceId = task.getProcessInstanceId(); + + ProcessProgressVo instanceProgress = processService.getInstanceProgress(nodeId, instanceId); + Map formData = instanceProgress.getFormData(); + String status = instanceProgress.getStatus(); + Boolean temporarySupplement = (Boolean) formData.get(ProjectDeclareConstants.BasicInformation.TEMPORARY_SUPPLEMENT); + ResToBeProcessedDTO res = new ResToBeProcessedDTO(); + if (temporarySupplement.equals(param.getIsSupplement())) { + ProcessDefinition processDef = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(task.getProcessDefinitionId()) + .singleResult(); + //从缓存取 + ProcessInstanceOwnerDto owner = runtimeService.getVariable(task.getExecutionId(), "owner", ProcessInstanceOwnerDto.class); + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult(); + staterUsers.add(owner.getOwner()); + ProcessTaskVo processTaskVo = ProcessTaskVo.builder() + .taskId(task.getId()) + .taskName(task.getName()) + .taskDefKey(task.getTaskDefinitionKey()) + .processDefId(task.getProcessDefinitionId()) + .executionId(task.getExecutionId()) + .nodeId(nodeId) + .deployId(processDef.getDeploymentId()) + .processDefName(processDef.getName()) + .version(processDef.getVersion()) + .instanceId(instanceId) + .ownerId(processInstance.getStartUserId()) + .ownerDeptId(owner.getOwnerDeptId()) + .ownerDeptName(owner.getOwnerDeptName()) + .createTime(processInstance.getStartTime()) + .taskCreateTime(task.getCreateTime()) + .build(); + res.setProcessTaskVo(processTaskVo); + String projectName = (String) formData.get(ProjectDeclareConstants.BasicInformation.PROJECT_NAME); + res.setProjectName(projectName); + res.setReportUnitId(owner.getOwnerDeptId()); + res.setReportUnitName(owner.getOwnerDeptName()); + res.setReportAmount((Integer) formData.get(ProjectDeclareConstants.FundDeclareInfo.DECLARE_AMOUNT)); + res.setBudgetYear((Integer) formData.get(ProjectDeclareConstants.BasicInformation.BUDGET_YEAR)); + res.setProcessStatus(ProcessStatusEnum.getCodeByDesc(status)); + res.setProcessStatusName(status); + res.setProcessLaunchTime(NdDateUtils.date2LocalDateTime(processInstance.getStartTime())); + } + return res; + }).collect(Collectors.toList()); + List result = resVos.stream() + .filter(r -> r.getProjectName().equals(param.getProjectName())) + .filter(r -> r.getReportUnitName().equals(param.getReportUnitName())) + .filter(r -> r.getBudgetYear().equals(param.getBudgetYear())) + .filter(r -> r.getProcessLaunchTime().isBefore(param.getProcessLaunchStartTime())) + .filter(r -> r.getProcessLaunchTime().isAfter(param.getProcessLaunchEndTime())).collect(Collectors.toList()); + //取用户信息,减少数据库查询,一次构建 + if (CollectionUtil.isNotEmpty(staterUsers)) { + Map userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers); + page.setRecords(result.stream().peek(v -> v.getProcessTaskVo().setOwner(userMap.get(v.getProcessTaskVo().getOwnerId()))).collect(Collectors.toList())); + } + return PageVo.of(resVos,page.getTotal()); + } + + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedDTO.java new file mode 100644 index 0000000..8e8f96e --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedDTO.java @@ -0,0 +1,42 @@ +package com.ningdatech.pmapi.todocenter.model.dto.req; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import com.ningdatech.basic.model.PagePo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 待办中心-待我处理查询实体信息 + * + * @author CMM + * @since 2023/01/12 16:01 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ReqToBeProcessedDTO extends PagePo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("申报单位名称") + private String reportUnitName; + + @ApiModelProperty("预算年度") + private Integer budgetYear; + + @ApiModelProperty("流程发起开始时间") + private LocalDateTime processLaunchStartTime; + + @ApiModelProperty("流程发起结束时间") + private LocalDateTime processLaunchEndTime; + + @ApiModelProperty(value = "是否增补项目",allowableValues = "非增补项目 false,增补项目 true") + private Boolean isSupplement; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java new file mode 100644 index 0000000..a336779 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/res/ResToBeProcessedDTO.java @@ -0,0 +1,53 @@ +package com.ningdatech.pmapi.todocenter.model.dto.res; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import com.wflow.workflow.bean.vo.ProcessTaskVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 待办中心-待我处理返回实体信息 + * + * @author CMM + * @since 2023/01/12 14:57 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ResToBeProcessedDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("项目ID") + private String projectId; + + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("申报单位ID") + private String reportUnitId; + + @ApiModelProperty("申报单位名称") + private String reportUnitName; + + @ApiModelProperty("申报金额") + private Integer reportAmount; + + @ApiModelProperty("预算年度") + private Integer budgetYear; + + @ApiModelProperty("流程状态") + private Integer processStatus; + + @ApiModelProperty("流程状态名称") + private String processStatusName; + + @ApiModelProperty("流程发起时间") + private LocalDateTime processLaunchTime; + + @ApiModelProperty("流程任务信息") + private ProcessTaskVo processTaskVo; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/model/UserInfoDetails.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/UserInfoDetails.java new file mode 100644 index 0000000..de91775 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/model/UserInfoDetails.java @@ -0,0 +1,71 @@ +package com.ningdatech.pmapi.user.model; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import com.ningdatech.basic.auth.AbstractLoginUser; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author LiuXinXin + * @date 2022/8/1 下午3:32 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class UserInfoDetails extends AbstractLoginUser implements UserDetails { + + private static final long serialVersionUID = 1L; + + private String nickName; + + private String password; + + private List roleList; + + private Integer dataScope; + + private Long roleId; + + private Long companyId; + + private String companyName; + + private Long regionId; + + private String regionName; + + /** + * 获取用户权限 + */ + @Override + public Collection getAuthorities() { + return new ArrayList<>(); + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/util/LoginUserUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/util/LoginUserUtil.java new file mode 100644 index 0000000..75d5215 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/util/LoginUserUtil.java @@ -0,0 +1,18 @@ +package com.ningdatech.pmapi.user.util; + +import com.ningdatech.basic.auth.AbstractLoginUserUtil; +import com.ningdatech.pmapi.user.model.UserInfoDetails; + + +/** + * @Author liuxinxin + * @Date 2022/9/30 12:26 下午 + * @Version 1.0 + **/ +public class LoginUserUtil extends AbstractLoginUserUtil { + + public static UserInfoDetails loginUserDetail() { + return getLoginUserPrincipal(); + } + +}