diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectStoppedChangeController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectStoppedChangeController.java index 4addcdb..b42aadb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectStoppedChangeController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/ProjectStoppedChangeController.java @@ -8,6 +8,7 @@ import com.hz.pm.api.projectlib.model.req.SubmitProjectStoppedApplyReq; import com.hz.pm.api.projectlib.model.vo.ProjectChangeDetailVO; import com.hz.pm.api.projectlib.model.vo.ProjectChangeListVO; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; +import com.hz.pm.api.projectlib.model.vo.ProjectStoppedDetailVO; import com.ningdatech.basic.model.PageVo; import com.ningdatech.log.annotation.WebLog; import io.swagger.annotations.Api; @@ -35,6 +36,13 @@ public class ProjectStoppedChangeController { private final ProjectStoppedManage projectStoppedManage; private final ProjectChangeManage projectChangeManage; + @GetMapping("/stopped/detail/{projectId}") + @ApiOperation("项目终止详情") + @WebLog("项目终止详情") + public ProjectStoppedDetailVO stoppedDetail(@PathVariable("projectId") Long projectId) { + return projectStoppedManage.detail(projectId); + } + @PostMapping("/stopped/submitApply") @ApiOperation("提交项目终止申请") @WebLog("提交项目终止申请") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java index 64c2acc..dad7310 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/helper/ProjectChangeStopHelper.java @@ -107,7 +107,8 @@ public class ProjectChangeStopHelper { .afterStatus(status.getCode()) .build(); projectStatusChangeService.save(projectStatusChange); - project.setStage(project.getStatus() - project.getStatus() % 10000); + project.setStatus(status.getCode()); + project.setStage(status.getStage().getCode()); projectService.updateById(project); List purchases = purchaseService.listByProjectId(project.getId()); List purchaseStatusChanges = CollUtils.convert(purchases, @@ -189,9 +190,11 @@ public class ProjectChangeStopHelper { IStatus bizStatus; switch (event) { case STOPPED_APPLY_PASS: - case STOPPED_APPLY_AUTO_PASS: bizStatus = ProjectStoppedStatus.STOPPED_PASSED; break; + case STOPPED_APPLY_AUTO_PASS: + bizStatus = ProjectStoppedStatus.STOPPED_AUTO_PASSED; + break; case STOPPED_APPLY_SUBMIT: bizStatus = ProjectStoppedStatus.ON_STOPPED_APPLY; break; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectChangeManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectChangeManage.java index 91a2b48..2143cdf 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectChangeManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectChangeManage.java @@ -133,7 +133,7 @@ public class ProjectChangeManage { ProcessStartParamsVo params = new ProcessStartParamsVo(); params.setUser(declaredProjectHelper.buildUser(userDetail)); params.setProcessUsers(Collections.emptyMap()); - params.setFormData(BeanUtil.beanToMap(req)); + params.setFormData(BeanUtil.beanToMap(req, false, true)); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 Map orgModelMap = declaredProjectHelper.buildOrgModelMap(userDetail, project); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectStoppedManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectStoppedManage.java index f914f8e..00dd1bf 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectStoppedManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectStoppedManage.java @@ -1,11 +1,13 @@ package com.hz.pm.api.projectlib.manage; import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.enumeration.ProjectProcessType; import com.hz.pm.api.common.statemachine.event.ProjectStateChangeEvent; +import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; import com.hz.pm.api.projectdeclared.manage.DeclaredProjectHelper; import com.hz.pm.api.projectlib.helper.ProjectChangeStopHelper; @@ -17,6 +19,7 @@ import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; import com.hz.pm.api.projectlib.model.req.ProjectListReq; import com.hz.pm.api.projectlib.model.req.SubmitProjectStoppedApplyReq; import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; +import com.hz.pm.api.projectlib.model.vo.ProjectStoppedDetailVO; import com.hz.pm.api.projectlib.service.IProjectInstService; import com.hz.pm.api.projectlib.service.IProjectService; import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; @@ -36,6 +39,7 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -72,7 +76,7 @@ public class ProjectStoppedManage { throw BizException.wrap("暂无法提交终止申请"); } long hasDeclared = projectStatusChangeService.count(Wrappers.lambdaQuery(ProjectStatusChange.class) - .eq(ProjectStatusChange::getProjectId, project.getProjectCode()) + .eq(ProjectStatusChange::getProjectCode, project.getProjectCode()) .eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.DECLARED_RECORD_PASS)); project.setStoppedFiles(req.getStoppedFiles()); @@ -89,7 +93,7 @@ public class ProjectStoppedManage { ProcessStartParamsVo params = new ProcessStartParamsVo(); params.setUser(declaredProjectHelper.buildUser(userDetail)); params.setProcessUsers(Collections.emptyMap()); - params.setFormData(BeanUtil.beanToMap(req)); + params.setFormData(BeanUtil.beanToMap(req, false, true)); // 获取发起单位、发起单位主管单位、发起单位上级主管条线单位信息 Map orgModelMap = declaredProjectHelper.buildOrgModelMap(userDetail, project); @@ -114,12 +118,23 @@ public class ProjectStoppedManage { return PageVo.empty(); } List records = page.getRecords(); + Wrapper projectInstQuery = Wrappers.lambdaQuery(ProjectInst.class) + .eq(ProjectInst::getInstType, ProjectProcessType.PROJECT_STOPPED.getCode()) + .in(ProjectInst::getProjectId, CollUtils.fieldList(records, Project::getId)); + List projectInstList = projectInstService.list(projectInstQuery); + Map projectInstMap = BizUtils.groupFirstMap(projectInstList, + ProjectInst::getProjectId, + Comparator.comparing(ProjectInst::getCreateOn).reversed()); List data = records.stream().map(w -> { ProjectLibListItemVO project = new ProjectLibListItemVO(); project.setProjectName(w.getProjectName()); project.setProjectCode(w.getProjectCode()); project.setStoppedStatus(w.getStoppedStatus()); project.setId(w.getId()); + ProjectInst projectInst = projectInstMap.get(w.getId()); + if (projectInst != null) { + project.setInstCode(projectInst.getInstCode()); + } project.setStage(w.getStage()); project.setStatus(w.getStatus()); project.setCreateOn(w.getCreateOn()); @@ -151,4 +166,18 @@ public class ProjectStoppedManage { }); } + public ProjectStoppedDetailVO detail(Long projectId) { + Project project = projectService.getById(projectId); + if (project == null) { + throw BizException.wrap("项目不存在"); + } + return ProjectStoppedDetailVO.builder() + .projectId(project.getId()) + .projectName(project.getProjectName()) + .stoppedStatus(project.getStoppedStatus()) + .stoppedReason(project.getStoppedReason()) + .stoppedFiles(project.getStoppedFiles()) + .build(); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectStatusChange.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectStatusChange.java index 517f6bb..2e7ad81 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectStatusChange.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/ProjectStatusChange.java @@ -1,8 +1,7 @@ package com.hz.pm.api.projectlib.model.entity; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; + import java.io.Serializable; import java.time.LocalDateTime; import io.swagger.annotations.ApiModel; @@ -47,6 +46,7 @@ public class ProjectStatusChange implements Serializable { private String event; @ApiModelProperty("状态变更发生的时间") + @TableField(fill = FieldFill.INSERT) private LocalDateTime createOn; @ApiModelProperty("项目code") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java index 471272b..97df4f6 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStatus.java @@ -83,6 +83,17 @@ public enum ProjectStatus implements IStatus { private final Integer code; private final String desc; + /** + * 项目阶段增量 + */ + private static final Integer STAGE_INCR = 10000; + + + public ProjectStatus getStage() { + int stageCode = this.getCode() - this.getCode() % STAGE_INCR; + return getNoNull(stageCode); + } + public static String getDesc(Integer code) { return get(code).flatMap(w -> Optional.of(w.getDesc())).orElse(StrUtil.EMPTY); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStoppedStatus.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStoppedStatus.java index 9979068..d3e5612 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStoppedStatus.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/enumeration/status/ProjectStoppedStatus.java @@ -19,7 +19,8 @@ public enum ProjectStoppedStatus implements IStatus { * 项目终止 */ ON_STOPPED_APPLY(40001, "项目终止审核中"), - STOPPED_PASSED(40002, "项目终止"), + STOPPED_PASSED(40002, "项目终止审核通过"), + STOPPED_AUTO_PASSED(40004, "项目终止审核通过"), STOPPED_FAILED(40003, "项目终止审核不通过"); private final Integer code; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectStoppedApplyReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectStoppedApplyReq.java index 2c9e818..24dc996 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectStoppedApplyReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectStoppedApplyReq.java @@ -1,7 +1,12 @@ package com.hz.pm.api.projectlib.model.req; import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; import lombok.Data; +import lombok.experimental.Tolerate; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; /** *

@@ -12,12 +17,20 @@ import lombok.Data; * @since 11:07 2024/8/5 */ @Data +@Builder public class SubmitProjectStoppedApplyReq { + @Tolerate + public SubmitProjectStoppedApplyReq() { + // 默认构造方法 + } + @ApiModelProperty(value = "项目id") + @NotNull(message = "项目id不能为空") private Long projectId; @ApiModelProperty(value = "项目终止原因") + @NotBlank(message = "项目终止原因不能为空") private String stoppedReason; @ApiModelProperty(value = "项目终止附件") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectStoppedDetailVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectStoppedDetailVO.java new file mode 100644 index 0000000..464fdab --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectStoppedDetailVO.java @@ -0,0 +1,40 @@ +package com.hz.pm.api.projectlib.model.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Tolerate; + +/** + *

+ * SubmitProjectStoppedApplyReq + *

+ * + * @author WendyYang + * @since 11:07 2024/8/5 + */ +@Data +@Builder +public class ProjectStoppedDetailVO { + + @Tolerate + public ProjectStoppedDetailVO() { + // 默认构造方法 + } + + @ApiModelProperty(value = "项目id") + private Long projectId; + + @ApiModelProperty(value = "项目终止状态") + private Integer stoppedStatus; + + @ApiModelProperty(value = "项目名称") + private String projectName; + + @ApiModelProperty(value = "项目终止原因") + private String stoppedReason; + + @ApiModelProperty(value = "项目终止附件") + private String stoppedFiles; + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/controller/SysProcDefController.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/controller/SysProcDefController.java index 59fa435..5781dc8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/controller/SysProcDefController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/controller/SysProcDefController.java @@ -13,6 +13,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -74,6 +75,7 @@ public class SysProcDefController { } @GetMapping("/initProcessForUnits") + @PreAuthorize("hasAuthority('SUPER_ADMIN')") public void initProcessForUnits(@RequestParam Set unitIds) { initProcessManage.initProcessForUnits(unitIds); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/InitProcessManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/InitProcessManage.java index f39acc4..2f9542b 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/InitProcessManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/InitProcessManage.java @@ -36,7 +36,7 @@ public class InitProcessManage { private final ProcessModelService processModelService; @Transactional(rollbackFor = Exception.class) - public void initProcessForUnits(Set unitIds) { + public synchronized void initProcessForUnits(Set unitIds) { if (CollUtil.isEmpty(unitIds)) { return; }