From 628bcae96cec914a88617a83af93cb986c98de79 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 13 Apr 2022 14:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/entity/LatestActInfoEntity.java | 2 +- .../service/impl/WorkActDraftServiceImpl.java | 46 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java index 491ed210f8..011a57519f 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActInfoEntity.java @@ -43,7 +43,7 @@ public class LatestActInfoEntity extends BaseEpmetEntity { * 客户id */ private String customerId; - + private String gridId; /** * 活动标题 */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java index a5fb199d5a..99fda3fbcf 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java @@ -18,6 +18,7 @@ import com.epmet.dto.result.work.*; import com.epmet.entity.LatestActServiceRelationEntity; import com.epmet.entity.LatestActUnitRelationEntity; import com.epmet.service.*; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -133,29 +134,32 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { //保存活动与服务关系 latestActServiceRelationService.deleteByAct(actDraftId); - AtomicInteger i = new AtomicInteger(NumConstant.ONE); - List serviceList = formDTO.getServiceMatterList().stream().map(service -> { - LatestActServiceRelationEntity entity = new LatestActServiceRelationEntity(); - entity.setCustomerId(formDTO.getCustomerId()); - entity.setActId(actDraftId); - entity.setServiceMatter(service); - entity.setSort(i.getAndIncrement()); - return entity; - }).collect(Collectors.toList()); - latestActServiceRelationService.insertBatch(serviceList); - + if (CollectionUtils.isNotEmpty(formDTO.getServiceMatterList())) { + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List serviceList = formDTO.getServiceMatterList().stream().map(service -> { + LatestActServiceRelationEntity entity = new LatestActServiceRelationEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setActId(actDraftId); + entity.setServiceMatter(service); + entity.setSort(i.getAndIncrement()); + return entity; + }).collect(Collectors.toList()); + latestActServiceRelationService.insertBatch(serviceList); + } //保存活动与单位关系 latestActUnitRelationService.deleteByAct(actDraftId); - AtomicInteger j = new AtomicInteger(NumConstant.ONE); - List unitList = formDTO.getUnitIdList().stream().map(unitId -> { - LatestActUnitRelationEntity entity = new LatestActUnitRelationEntity(); - entity.setCustomerId(formDTO.getCustomerId()); - entity.setActId(actDraftId); - entity.setUnitId(unitId); - entity.setSort(j.getAndIncrement()); - return entity; - }).collect(Collectors.toList()); - latestActUnitRelationService.insertBatch(unitList); + if (CollectionUtils.isNotEmpty(formDTO.getServiceMatterList())) { + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List unitList = formDTO.getUnitIdList().stream().map(unitId -> { + LatestActUnitRelationEntity entity = new LatestActUnitRelationEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setActId(actDraftId); + entity.setUnitId(unitId); + entity.setSort(j.getAndIncrement()); + return entity; + }).collect(Collectors.toList()); + latestActUnitRelationService.insertBatch(unitList); + } return resultDTO; }