diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/ProjectEditDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/ProjectEditDTO.java index 691b627..53f0a4e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/ProjectEditDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/ProjectEditDTO.java @@ -21,6 +21,12 @@ public class ProjectEditDTO implements Serializable { private static final long serialVersionUID = 7066112975653039072L; + public static final String FIELD_PROJECT = "project"; + + public static final String FIELD_PURCHASES = "purchases"; + + public static final String FIELD_PROJECT_DIFFS = "projectDiffs"; + @ApiModelProperty("项目信息") private ProjectDTO project; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseDTO.java index b4e579d..2f25a80 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseDTO.java @@ -22,6 +22,8 @@ import java.time.LocalDateTime; @AllArgsConstructor public class PurchaseDTO { + public static final String FIELD_ID = "id"; + @ApiModelProperty("id") private Long id; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseEditDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseEditDTO.java index 6f77880..d6ca696 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseEditDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/model/dto/PurchaseEditDTO.java @@ -17,6 +17,18 @@ import java.util.List; @Data public class PurchaseEditDTO { + public static final String FIELD_PURCHASE = "purchase"; + + public static final String FIELD_CONTRACT = "contract"; + + public static final String FIELD_OPERATION = "operation"; + + public static final String FIELD_PURCHASE_DIFFS = "purchaseDiffs"; + + public static final String FIELD_CONTRACT_DIFFS = "contractDiffs"; + + public static final String FIELD_OPERATION_DIFFS = "operationDiffs"; + @ApiModelProperty("采购信息") private PurchaseDTO purchase; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/utils/ProjectIdCodeCacheUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/utils/ProjectIdCodeCacheUtil.java index 82f7447..4f02556 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/utils/ProjectIdCodeCacheUtil.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/utils/ProjectIdCodeCacheUtil.java @@ -69,7 +69,7 @@ public class ProjectIdCodeCacheUtil { public static List get(String projectCode) { return CACHE.entrySet() .stream() - .filter(w -> w.getValue().getProjectCode().equals(projectCode)) + .filter(w -> StrUtil.equals(w.getValue().getProjectCode(), projectCode)) .map(Map.Entry::getKey) .collect(Collectors.toList()); } 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 c77b831..22f027e 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 @@ -2,7 +2,7 @@ package com.hz.pm.api.projectlib.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.json.JSONConfig; +import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -83,18 +83,18 @@ public class ProjectChangeManage { @Transactional(rollbackFor = Exception.class) public synchronized void submitProjectChangeApply(SubmitProjectChangeApplyReq req) { - ProjectEditDTO projectEdit = req.getProjectEditDetail(); - ProjectDTO reqProject = projectEdit.getProject(); - Project project = projectService.getNewProject(reqProject.getId()); + JSONObject projectEditDetail = req.getProjectEditDetail(); + JSONObject projJsonObj = projectEditDetail.getJSONObject(ProjectEditDTO.FIELD_PROJECT); + ProjectDTO reqProj = projJsonObj.toBean(ProjectDTO.class); + Project project = projectService.getNewProject(reqProj.getId()); if (ProjectStatus.ON_CHANGE_APPLY.eq(project.getStatus()) || ProjectStatus.STOPPED_PASSED.eq(project.getStatus())) { throw BizException.wrap("暂无法提交变更申请"); } ProjectDetailVO projDetailOld = projectLibManage.getProjectDetail(project); - List projDiffs = BeanDiffUtil.diffSameField(projDetailOld, reqProject, - ProjectDTO.SYSTEM_REPLACE_INFOS); - List systemReplaceInfos = reqProject.getSystemReplaceInfos(); + List projDiffs = BeanDiffUtil.diffSameField(projDetailOld, projJsonObj, ProjectDTO.SYSTEM_REPLACE_INFOS); + List systemReplaceInfos = reqProj.getSystemReplaceInfos(); List systemReplaceInfosOld = projDetailOld.getSystemReplaceInfos(); if (!CollUtil.isEqualList(systemReplaceInfos, systemReplaceInfosOld)) { projDiffs.add(FieldDiff.builder() @@ -104,28 +104,29 @@ public class ProjectChangeManage { .newValue(systemReplaceInfos) .build()); } - projectEdit.setProjectDiffs(projDiffs); - if (CollUtil.isNotEmpty(projectEdit.getPurchases())) { + projJsonObj.set(ProjectEditDTO.FIELD_PROJECT_DIFFS, projDiffs); + List purchaseJsonObjs = projectEditDetail.getBeanList(ProjectEditDTO.FIELD_PURCHASES, JSONObject.class); + if (CollUtil.isNotEmpty(purchaseJsonObjs)) { List purchaseDetails = projDetailOld.getPurchaseDetails(); if (purchaseDetails != null && !purchaseDetails.isEmpty()) { - Map reqPurchaseMap = CollUtils.listToMap(projectEdit.getPurchases(), - w -> w.getPurchase().getId()); + Map reqPurchaseMap = CollUtils.listToMap(purchaseJsonObjs, + w -> w.getJSONObject(PurchaseEditDTO.FIELD_PURCHASE).getLong(PurchaseDTO.FIELD_ID)); for (PurchaseFullInfoVO purchaseDetail : purchaseDetails) { PurchaseVO purchase = purchaseDetail.getPurchase(); ContractVO contract = purchaseDetail.getConstruction(); OperationVO operation = purchaseDetail.getOperation(); - PurchaseEditDTO reqPurchaseDetail = reqPurchaseMap.get(purchase.getId()); - PurchaseDTO reqPurchase = reqPurchaseDetail.getPurchase(); - OperationDTO reqOperation = reqPurchaseDetail.getOperation(); - ContractDTO reqContract = reqPurchaseDetail.getContract(); + JSONObject reqPurchaseDetail = reqPurchaseMap.get(purchase.getId()); + JSONObject reqPurchase = reqPurchaseDetail.getJSONObject(PurchaseEditDTO.FIELD_PURCHASE); + JSONObject reqOperation = reqPurchaseDetail.getJSONObject(PurchaseEditDTO.FIELD_OPERATION); + JSONObject reqContract = reqPurchaseDetail.getJSONObject(PurchaseEditDTO.FIELD_CONTRACT); List purchaseDiffs = BeanDiffUtil.diffSameField(purchase, reqPurchase); List operationDiffs = BeanDiffUtil.diffSameField(operation, reqOperation); List contractDiffs = BeanDiffUtil.diffSameField(contract, reqContract); - reqPurchaseDetail.setPurchaseDiffs(purchaseDiffs); - reqPurchaseDetail.setContractDiffs(contractDiffs); - reqPurchaseDetail.setOperationDiffs(operationDiffs); + reqPurchaseDetail.set(PurchaseEditDTO.FIELD_PURCHASE_DIFFS, purchaseDiffs); + reqPurchaseDetail.set(PurchaseEditDTO.FIELD_CONTRACT_DIFFS, contractDiffs); + reqPurchaseDetail.set(PurchaseEditDTO.FIELD_OPERATION_DIFFS, operationDiffs); } } } @@ -149,9 +150,11 @@ public class ProjectChangeManage { projectInstService.save(projectInst); projectChangeStopHelper.changeProjectPurchaseStatus(project, CHANGE_APPLY_SUBMIT); + projectEditDetail.getConfig().setIgnoreNullValue(false); + // 保存变更历史 ProjectChangeHistory projectChangeHistory = new ProjectChangeHistory(); - projectChangeHistory.setChangeContent(JSONUtil.toJsonStr(projectEdit, BizConst.JSON_NOT_IGNORE_NULL_VALUE)); + projectChangeHistory.setChangeContent(projectEditDetail.toString()); projectChangeHistory.setChangeReason(req.getChangeReason()); projectChangeHistory.setProjectId(project.getId()); projectChangeHistory.setProjectCode(project.getProjectCode()); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectChangeApplyReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectChangeApplyReq.java index b760a59..eebffa1 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectChangeApplyReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/SubmitProjectChangeApplyReq.java @@ -1,5 +1,7 @@ package com.hz.pm.api.projectlib.model.req; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.json.JSONObject; import com.hz.pm.api.projectdeclared.model.dto.ProjectEditDTO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,6 +24,10 @@ public class SubmitProjectChangeApplyReq { private String changeReason; @ApiModelProperty("项目信息") - private ProjectEditDTO projectEditDetail; + private JSONObject projectEditDetail; + + public ProjectEditDTO getProjectDetail() { + return BeanUtil.toBean(projectEditDetail, ProjectEditDTO.class); + } }