|
|
@@ -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<FieldDiff> projDiffs = BeanDiffUtil.diffSameField(projDetailOld, reqProject, |
|
|
|
ProjectDTO.SYSTEM_REPLACE_INFOS); |
|
|
|
List<GovSystemReplaceInfoDTO> systemReplaceInfos = reqProject.getSystemReplaceInfos(); |
|
|
|
List<FieldDiff> projDiffs = BeanDiffUtil.diffSameField(projDetailOld, projJsonObj, ProjectDTO.SYSTEM_REPLACE_INFOS); |
|
|
|
List<GovSystemReplaceInfoDTO> systemReplaceInfos = reqProj.getSystemReplaceInfos(); |
|
|
|
List<GovSystemReplaceInfoDTO> 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<JSONObject> purchaseJsonObjs = projectEditDetail.getBeanList(ProjectEditDTO.FIELD_PURCHASES, JSONObject.class); |
|
|
|
if (CollUtil.isNotEmpty(purchaseJsonObjs)) { |
|
|
|
List<PurchaseFullInfoVO> purchaseDetails = projDetailOld.getPurchaseDetails(); |
|
|
|
if (purchaseDetails != null && !purchaseDetails.isEmpty()) { |
|
|
|
Map<Long, PurchaseEditDTO> reqPurchaseMap = CollUtils.listToMap(projectEdit.getPurchases(), |
|
|
|
w -> w.getPurchase().getId()); |
|
|
|
Map<Long, JSONObject> 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<FieldDiff> purchaseDiffs = BeanDiffUtil.diffSameField(purchase, reqPurchase); |
|
|
|
List<FieldDiff> operationDiffs = BeanDiffUtil.diffSameField(operation, reqOperation); |
|
|
|
List<FieldDiff> 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()); |
|
|
|