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