getRestartFunction(Integer status) {
diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java
index ce4aa67..0bb22a8 100644
--- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java
+++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhProjectController.java
@@ -1,6 +1,7 @@
package com.hz.pm.api.projectlib.controller;
-import com.hz.pm.api.projectlib.manage.MhProjectManage;
+import com.hz.pm.api.projectdeclared.model.dto.DefaultDeclaredDTO;
+import com.hz.pm.api.projectlib.manage.DeclaredRecordManage;
import com.hz.pm.api.projectlib.model.req.DeclaredProjectListReq;
import com.hz.pm.api.projectlib.model.vo.DeclaredProjectListVO;
import com.hz.pm.api.projectlib.model.vo.MhProjectBaseInfoVO;
@@ -8,10 +9,9 @@ import com.ningdatech.basic.model.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
/**
*
@@ -24,21 +24,33 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "信产项目(立项备案)列表")
@RestController
@RequiredArgsConstructor
-@RequestMapping("/api/v1/mh/project")
+@RequestMapping("/api/v1/declared/record")
public class MhProjectController {
- private final MhProjectManage mhProjectManage;
+ private final DeclaredRecordManage declaredRecordManage;
@ApiOperation("立项备案列表")
@GetMapping("/pageDeclaredProject")
public PageVo pageDeclaredProject(DeclaredProjectListReq req) {
- return mhProjectManage.pageDeclaredProject(req);
+ return declaredRecordManage.pageDeclaredProject(req);
}
@ApiOperation("信产项目基本信息")
@GetMapping("/baseInfo/{mhProjectId}")
public MhProjectBaseInfoVO projectBaseInfo(@PathVariable Long mhProjectId) {
- return mhProjectManage.getProjectBaseInfo(mhProjectId);
+ return declaredRecordManage.getProjectBaseInfo(mhProjectId);
+ }
+
+ @ApiOperation("立项备案提交")
+ @PostMapping("/submit")
+ public void submit(@Valid @RequestBody DefaultDeclaredDTO req) {
+ declaredRecordManage.startDeclaredRecord(req);
+ }
+
+ @ApiOperation("立项备案重新提交")
+ @PostMapping("/resubmit")
+ public void resubmit(@Valid @RequestBody DefaultDeclaredDTO req) {
+ declaredRecordManage.restartDeclaredRecord(req);
}
diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java
new file mode 100644
index 0000000..e15037d
--- /dev/null
+++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java
@@ -0,0 +1,301 @@
+package com.hz.pm.api.projectlib.manage;
+
+import cn.hutool.core.lang.Assert;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+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.CommonEnum;
+import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum;
+import com.hz.pm.api.common.model.constant.BizConst;
+import com.hz.pm.api.projectdeclared.manage.DefaultDeclaredProjectManage;
+import com.hz.pm.api.projectdeclared.model.dto.DefaultDeclaredDTO;
+import com.hz.pm.api.projectdeclared.model.dto.ProjectConditionDTO;
+import com.hz.pm.api.projectdeclared.service.IProjectDraftService;
+import com.hz.pm.api.projectlib.model.dto.ProjectDTO;
+import com.hz.pm.api.projectlib.model.entity.MhProject;
+import com.hz.pm.api.projectlib.model.entity.MhProjectSchemaTargetData;
+import com.hz.pm.api.projectlib.model.entity.Project;
+import com.hz.pm.api.projectlib.model.enumeration.ProjectStatusEnum;
+import com.hz.pm.api.projectlib.model.req.DeclaredProjectListReq;
+import com.hz.pm.api.projectlib.model.vo.DeclaredProjectListVO;
+import com.hz.pm.api.projectlib.model.vo.MhProjectBaseInfoVO;
+import com.hz.pm.api.projectlib.service.IMhProjectSchemaTargetDataService;
+import com.hz.pm.api.projectlib.service.IMhProjectService;
+import com.hz.pm.api.projectlib.service.IProjectService;
+import com.hz.pm.api.staging.enums.MsgTypeEnum;
+import com.hz.pm.api.sys.manage.NoticeManage;
+import com.hz.pm.api.todocenter.constant.WorkNoticeConst;
+import com.hz.pm.api.user.helper.MhUnitCache;
+import com.hz.pm.api.user.model.dto.UnitDTO;
+import com.hz.pm.api.user.security.model.UserInfoDetails;
+import com.hz.pm.api.user.util.LoginUserUtil;
+import com.ningdatech.basic.exception.BizException;
+import com.ningdatech.basic.function.VUtils;
+import com.ningdatech.basic.model.PageVo;
+import com.ningdatech.basic.util.CollUtils;
+import com.wflow.bean.entity.WflowModels;
+import com.wflow.workflow.bean.dto.OrgInfoDTO;
+import com.wflow.workflow.bean.vo.ProcessStartParamsVo;
+import com.wflow.workflow.service.ProcessInstanceService;
+import com.wflow.workflow.service.ProcessModelService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ *
+ * MhProjectManage
+ *
+ *
+ * @author WendyYang
+ * @since 19:06 2024/1/30
+ */
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class DeclaredRecordManage {
+
+ private final IMhProjectService mhProjectService;
+ private final IMhProjectSchemaTargetDataService mhProjectSchemaTargetDataService;
+ private final IProjectService projectService;
+ private final MhUnitCache mhUnitCache;
+ private final NoticeManage noticeManage;
+ private final IProjectDraftService projectDraftService;
+ private final ProcessModelService processModelService;
+ private final DefaultDeclaredProjectManage defaultDeclaredProjectManage;
+ private final ProcessInstanceService processInstanceService;
+ private final ProjectLibManage projectLibManage;
+
+ private LambdaQueryWrapper buildQuery(DeclaredProjectListReq req) {
+ LambdaQueryWrapper query = Wrappers.lambdaQuery(MhProject.class)
+ .like(StrUtil.isNotBlank(req.getProjectName()), MhProject::getProjectName, req.getProjectName())
+ .like(StrUtil.isNotBlank(req.getDeclaredUnit()), MhProject::getUnitName, req.getDeclaredUnit());
+ if (req.getCreateDateMin() != null) {
+ query.ge(MhProject::getCreateTime, req.getCreateDateMin());
+ }
+ if (req.getCreateDateMax() != null) {
+ query.lt(MhProject::getCreateTime, req.getCreateDateMax().minusDays(1));
+ }
+ UserInfoDetails user = LoginUserUtil.loginUserDetail();
+ if (!user.getSuperAdmin() && !user.getRegionAdmin()) {
+ query.eq(MhProject::getUnitId, user.getMhUnitId());
+ }
+ return query;
+ }
+
+ public PageVo pageDeclaredProject(DeclaredProjectListReq req) {
+ LambdaQueryWrapper query = buildQuery(req);
+ Page page = mhProjectService.page(req.page(), query);
+ if (page.getTotal() == 0) {
+ return PageVo.empty();
+ }
+ List records = page.getRecords();
+ List projectCodes = CollUtils.fieldList(records, MhProject::getProjectCode);
+ Map projectMap;
+ if (!projectCodes.isEmpty()) {
+ List projects = projectService.listNewestByProjectCodes(projectCodes);
+ projectMap = CollUtils.listToMap(projects, Project::getProjectCode);
+ } else {
+ projectMap = Collections.emptyMap();
+ }
+ List data = records.stream().map(w -> {
+ DeclaredProjectListVO item = new DeclaredProjectListVO();
+ item.setMhProjectId(w.getId());
+ Project project = projectMap.get(w.getProjectCode());
+ if (project == null) {
+ item.setStatus(null);
+ item.setStage(null);
+ } else {
+ item.setStatus(project.getStatus());
+ item.setStage(project.getStage());
+ }
+ item.setProjectCode(w.getProjectCode());
+ item.setProjectName(w.getProjectName());
+ item.setDeclaredAmount(w.getTotalMoney());
+ item.setCreateTime(w.getCreateTime());
+ return item;
+ }).collect(Collectors.toList());
+ return PageVo.of(data, page.getTotal());
+ }
+
+ public MhProjectBaseInfoVO getProjectBaseInfo(Long mhProjectId) {
+ MhProject mhProject = mhProjectService.getById(mhProjectId);
+ if (mhProject == null) {
+ throw BizException.wrap("项目不存在");
+ }
+ MhProjectBaseInfoVO detail = new MhProjectBaseInfoVO();
+ detail.setMhProjectId(mhProject.getId());
+ detail.setProjectName(mhProject.getProjectName());
+ detail.setDeclaredUnit(mhProject.getUnitName());
+ detail.setDeclaredUnitId(mhProject.getUnitId());
+ detail.setTotalInvestAmount(mhProject.getTotalMoney());
+ detail.setReviewInvestAmount(mhProject.getMoney());
+ MhProjectSchemaTargetData schemaTargetData = mhProjectSchemaTargetDataService.getByMhProjectId(mhProjectId);
+ if (schemaTargetData != null) {
+ detail.setTotalInvestBudgetAmount(schemaTargetData.getMoney());
+ }
+ UnitDTO unit = mhUnitCache.getById(mhProject.getId());
+ if (unit != null) {
+ detail.setDeclaredUnitUnifiedSocialCreditCode(unit.getUnifiedSocialCreditCode());
+ }
+ return detail;
+ }
+
+ public String startDeclaredRecord(DefaultDeclaredDTO req) {
+ UserInfoDetails user = LoginUserUtil.loginUserDetail();
+ ProjectDTO projectInfo = req.getProjectInfo();
+
+ projectInfo.setBuildOrgCode(user.getMhUnitIdStr());
+ projectInfo.setBuildOrgName(user.getMhUnitName());
+
+ // 项目名称去重
+ defaultDeclaredProjectManage.checkDuplication(projectInfo);
+ // 判断申报金额 是否等于总的 判断年度支付金额 是否等于总金额
+ defaultDeclaredProjectManage.checkAmount(projectInfo);
+
+ // 写死 是否有主管单位
+ projectInfo.setIsHigherSuperOrg(CommonEnum.YES.getCode());
+ projectInfo.setIsSuperOrg(CommonEnum.YES.getCode());
+
+ //如果主管单位没有 那么主管单位就是自己
+ if (CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())) {
+ projectInfo.setSuperOrgCode(user.getMhUnitIdStr());
+ projectInfo.setSuperOrg(user.getMhUnitName());
+ }
+
+ //如果是重新提交的话 判断下 项目是否存在
+ if (Objects.nonNull(projectInfo.getId())) {
+ //新申报的项目不允许带项目id
+ projectInfo.setId(null);
+ }
+
+ WflowModels model = processModelService.getOne(Wrappers.lambdaQuery(WflowModels.class)
+ .eq(WflowModels::getProcessType, ProjectProcessStageEnum.PROJECT_RECORD_APPROVAL_PROCESS.getCode())
+ .last(BizConst.LIMIT_1));
+
+ if (Objects.isNull(model)) {
+ throw BizException.wrap("找不到立项备案审批流程配置");
+ }
+
+ ProcessStartParamsVo params = new ProcessStartParamsVo();
+ params.setUser(defaultDeclaredProjectManage.buildUser(user.getUserId()));
+ params.setProcessUsers(Collections.emptyMap());
+ //放入条件判断的项目字段
+ ProjectConditionDTO conditionDto = new ProjectConditionDTO();
+ BeanUtils.copyProperties(req.getProjectInfo(), conditionDto);
+ req.getFormData().putAll(
+ JSON.parseObject(JSON.toJSONString(conditionDto), new TypeReference