From c2afcd75a12fd3dca1d7e480e96b4b83e3330c7b Mon Sep 17 00:00:00 2001 From: caihaohan Date: Wed, 7 Aug 2024 19:09:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=2088263=20=E9=A6=96=E9=A1=B5-=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E5=85=A5=E5=BA=93=E4=BC=81=E6=A0=87=E4=BB=A3=E6=9B=BF?= =?UTF-8?q?=E6=A0=87=E5=87=86=E7=BC=96=E5=8F=B7=E6=B2=A1=E6=9C=89=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LawsStandardEarlyWarningServiceImpl.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/localTool/service/impl/LawsStandardEarlyWarningServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/localTool/service/impl/LawsStandardEarlyWarningServiceImpl.java index 6999c067..bccb82b9 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/localTool/service/impl/LawsStandardEarlyWarningServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/localTool/service/impl/LawsStandardEarlyWarningServiceImpl.java @@ -8,16 +8,19 @@ import com.jero.modules.laws.localTool.entity.StandardEarlyWarning; import com.jero.modules.laws.localTool.service.ILawsStandardEarlyWarningService; import com.jero.modules.laws.standard.entity.LawsDomesticStandard; import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard; +import com.jero.modules.laws.standard.entity.LawsReplacedStandard; import com.jero.modules.laws.standard.entity.OutStandardStateEnum; import com.jero.modules.laws.standard.service.ILawsDomesticStandardService; import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService; +import com.jero.modules.laws.standard.service.ILawsReplacedStandardService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @Author: liao @@ -33,6 +36,9 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa @Resource private ILawsEnterpriseStandardService enterpriseStandardService; + @Resource + private ILawsReplacedStandardService replacedStandardService; + /** * @Author: liao * @Date: 2023/11/10 17:13 @@ -76,7 +82,26 @@ public class LawsStandardEarlyWarningServiceImpl implements ILawsStandardEarlyWa queryWrapper.between(LawsEnterpriseStandard::getCreateTime, LocalDateTime.now().minusDays(90), LocalDateTime.now()); queryWrapper.orderByDesc(LawsEnterpriseStandard::getCreateTime); IPage page = new Page<>(pageNo, pageSize); - return enterpriseStandardService.page(page, queryWrapper); + IPage dataPage = enterpriseStandardService.page(page, queryWrapper); + List records = dataPage.getRecords(); + if (records.isEmpty()) { + return dataPage; + } + // 设置代替标准编号字段 + List replaceByNumberList = records.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()); + LambdaQueryWrapper replaceByNumberQueryWrapper = new LambdaQueryWrapper<>(); + replaceByNumberQueryWrapper.in(LawsReplacedStandard::getReplacedBy, replaceByNumberList); + replaceByNumberQueryWrapper.eq(LawsReplacedStandard::getType, "1"); + List list = replacedStandardService.list(replaceByNumberQueryWrapper); + Map> replaceByMap = list.stream().collect(Collectors.groupingBy(LawsReplacedStandard::getReplacedBy)); + records.forEach(data -> { + List replacedStandardList = replaceByMap.get(data.getStandardNumber()); + if (replacedStandardList != null && !replacedStandardList.isEmpty()) { + String replaced = replacedStandardList.stream().map(LawsReplacedStandard::getReplaced).collect(Collectors.joining()); + data.setReplacedByStandardNumber(replaced); + } + }); + return dataPage; } @Override