From 0b7b06876c925941b61467cd5db5e021270b38be Mon Sep 17 00:00:00 2001
From: yang_shj <1069818635@QQ.com>
Date: Mon, 10 Jul 2023 13:39:54 +0800
Subject: [PATCH] =?UTF-8?q?#=E9=A3=8E=E7=94=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../access/mapper/OperAccessMaterialMapper.xml | 6 ++--
.../service/impl/AccessPlanV4ServiceImpl.java | 39 +++++++++++++++-------
.../service/impl/AccessTaskV4ServiceImpl.java | 1 +
3 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml
index 4d658b6..1e3758a 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml
@@ -30,12 +30,12 @@
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
index 997314a..2ec9697 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
@@ -8,6 +8,7 @@ import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse;
import com.hnac.hzims.operational.access.dto.*;
+import com.hnac.hzims.operational.access.entity.OperAccessContentDetailEntity;
import com.hnac.hzims.operational.access.entity.OperAccessContentEntity;
import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity;
import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity;
@@ -51,6 +52,8 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
private final IOperAccessContentService contentService;
+ private final IOperAccessContentDetailService contentDetailService;
+
private final AccessTaskV4Service accessTaskV4Service;
private final ISysClient sysClient;
@@ -105,23 +108,17 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
return;
}
// 查询计划是否绑定检修材料
- List existsDetails = materialService.list(new LambdaQueryWrapper() {{
+ List materials = materialService.list(new LambdaQueryWrapper() {{
eq(OperAccessMaterialEntity::getPlanId, entity.getId());
eq(OperAccessMaterialEntity::getIsDeleted, 0L);
}});
- Set detailIds = entity.getAccessMaterials().stream().map(OperAccessMaterialDTO::getId).filter(Objects::nonNull).collect(Collectors.toSet());
- List ids = existsDetails.stream().map(OperAccessMaterialEntity::getId).filter(id -> !detailIds.contains(id)).collect(Collectors.toList());
- if (!CollectionUtils.isEmpty(ids)) {
- materialService.deleteLogic(ids);
+ if(CollectionUtil.isNotEmpty(materials)){
+ materialService.deleteLogic(materials.stream().map(OperAccessMaterialEntity::getId).collect(Collectors.toList()));
}
- // 材料添加/修改
- for (OperAccessMaterialDTO material : entity.getAccessMaterials()) {
+ for (OperAccessMaterialDTO material : entity.getAccessMaterials()){
+ material.setId(null);
material.setPlanId(entity.getId());
- if (ObjectUtil.isEmpty(material.getId())) {
- materialService.doSave(material);
- continue;
- }
- materialService.updateById(material);
+ materialService.save(material);
}
}
@@ -143,7 +140,23 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
}
for (OperAccessContentDTO detail : entity.getAccessContents()){
detail.setPlanId(entity.getId());
+ detail.setId(null);
contentService.save(detail);
+ if(CollectionUtil.isNotEmpty(detail.getAccessContentDetails())){
+ for (OperAccessContentDetailDTO contentDetail : detail.getAccessContentDetails()){
+ List contentDetails = contentDetailService.list(new LambdaQueryWrapper() {{
+ eq(OperAccessContentDetailEntity::getContentId, detail.getId());
+ }});
+ // 先删除
+ if(CollectionUtil.isNotEmpty(contentDetails)){
+ contentDetailService.deleteLogic(contentDetails.stream().map(OperAccessContentDetailEntity::getId).collect(Collectors.toList()));
+ }
+ // 再保存
+ contentDetail.setId(null);
+ contentDetail.setContentId(detail.getId());
+ contentDetailService.save(contentDetail);
+ }
+ }
}
}
@@ -221,10 +234,12 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{
task.setPlanId(entity.getId());
task.setContentId(item.getId());
task.setEmCode(item.getEmCode());
+ task.setCreateUser(item.getManager());
// 任务详情
if(CollectionUtil.isNotEmpty(item.getAccessContentDetails())){
task.setAccessTaskDetails(item.getAccessContentDetails().stream().map(content -> {
OperAccessTaskDetailDTO detail = BeanUtil.copy(content, OperAccessTaskDetailDTO.class);
+ detail.setCreateUser(entity.getCreateUser());
detail.setContentDetailId(content.getId());
detail.setContent(content.getContent());
detail.setName(content.getName());
diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java
index 88aca69..f757463 100644
--- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java
+++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java
@@ -146,6 +146,7 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service {
detailService.deleteLogic(exists.stream().map(OperAccessTaskDetailEntity::getId).collect(Collectors.toList()));
}
for (OperAccessTaskDetailDTO detail : entity.getAccessTaskDetails()){
+ detail.setId(null);
detail.setTaskId(entity.getId());
detailService.save(detail);
}