From ce8ecb49c20ac41d7fcbb319ac1c5aaa47910350 Mon Sep 17 00:00:00 2001 From: sjh Date: Tue, 29 Oct 2024 15:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E7=A1=80=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E5=8D=95=E4=BD=8D=E5=8F=96=E5=80=BC=E6=9D=A5?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/SupExternalDepartMapper.java | 12 +++++++ .../service/BusinessDepartService.java | 33 ++++++++----------- .../service/BusinessPoliceService.java | 27 ++++++++------- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java b/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java index c2c7d80..e06405f 100644 --- a/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java @@ -2,6 +2,18 @@ package com.biutag.supervision.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.supervision.pojo.entity.SupExternalDepart; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; public interface SupExternalDepartMapper extends BaseMapper { + + @Select("") + List> getIdsByDepartIds(List departIds); } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java index 10923bf..1ef2dbd 100644 --- a/src/main/java/com/biutag/supervision/service/BusinessDepartService.java +++ b/src/main/java/com/biutag/supervision/service/BusinessDepartService.java @@ -37,14 +37,14 @@ public class BusinessDepartService extends ServiceImpl page(BusinessQueryParam businessQueryParam) { // 测基础数据 if (businessQueryParam.getDepartName() != null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) { @@ -110,29 +110,24 @@ public class BusinessDepartService extends ServiceImpl> idsByDepartIds = supDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011 - List> idsByCode = supDepartMapper.getIdsByCode(departIds); - Map resultMap2 = idsByDepartIds.stream().collect(Collectors.toMap(map -> (String) map.get("domain_name"), map -> (String) map.get("id"))); + List> idsByDepartIds = supExternalDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011 + Map resultMap2 = idsByDepartIds.stream().filter(map -> map.get("external_id") != null).collect(Collectors.toMap( + map -> (String) map.get("external_id"), + map -> map.get("internal_id") == null ? "" : (String) map.get("internal_id") + )); List values = resultMap2.values().stream().filter(Objects::nonNull).toList();// 1011 - Map resultMap3 = idsByCode.stream().collect(Collectors.toMap(map -> (String) map.get("code"), map -> (String) map.get("id"))); - List values3 = resultMap3.values().stream().filter(Objects::nonNull).toList();// 1011 List> resultList = new ArrayList<>(); if (!values.isEmpty()) { resultList = statisticsDepartMapper.getGroupIdsByDepartIds(values); } - List> resultList2 = new ArrayList<>(); - if (!values3.isEmpty()) { - resultList2 = statisticsDepartMapper.getGroupIdsByDepartIds(values3); - } - if (resultList.isEmpty() && resultList2.isEmpty()) { + if (resultList.isEmpty()) { businessLogMapper.insert(new BusinessLog().setType("单位业务数据").setNum(0).setCreateTime(LocalDateTime.now())); log.info("{}没有单位数据", happenTime.get(0)); return; } Map resultMap = resultList.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId"))); - Map resultMap4 = resultList2.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId"))); List groupIds = new ArrayList<>(); - generateBusinessDepartList(happenTime, gBaseJJDSList, resultMap, resultMap2, resultMap4, groupIds, businessDepartList, gBaseAJJBXXListSA, gBaseAJJBXXListLA, gBaseAJJBXXListPA); + generateBusinessDepartList(happenTime, gBaseJJDSList, resultMap, resultMap2, groupIds, businessDepartList, gBaseAJJBXXListSA, gBaseAJJBXXListLA, gBaseAJJBXXListPA); List> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds); Map names = nameList.stream().collect(Collectors.toMap(map -> (Long) map.get("groupId"), map -> (String) map.get("name"))); for (BusinessDepart businessDepart : businessDepartList) { @@ -146,11 +141,11 @@ public class BusinessDepartService extends ServiceImpl happenTime, List gBaseJJDSList, Map resultMap, Map resultMap2, Map resultMap4, List groupIds, List businessDepartList, List gBaseAJJBXXListSA, List gBaseAJJBXXListLA, List gBaseAJJBXXListPA) { + private static void generateBusinessDepartList(List happenTime, List gBaseJJDSList, Map resultMap, Map resultMap2, List groupIds, List businessDepartList, List gBaseAJJBXXListSA, List gBaseAJJBXXListLA, List gBaseAJJBXXListPA) { for (GBaseJJD gBaseJJD : gBaseJJDSList) { Long groupId = resultMap.get(resultMap2.get(gBaseJJD.getGxdwdm())); if (groupId == null) { - groupId = resultMap4.get(resultMap2.get(gBaseJJD.getGxdwdm())); + continue; } groupIds.add(groupId); BusinessDepart businessDepart = getJJDBusinessDepart(happenTime, gBaseJJD, groupId); @@ -159,7 +154,7 @@ public class BusinessDepartService extends ServiceImpl page(BusinessQueryParam businessQueryParam) { if (businessQueryParam.getDepartName()!=null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) { LocalDate start = LocalDate.parse("2024-01-01"); @@ -105,22 +107,19 @@ public class BusinessPoliceService extends ServiceImpl> idsByDepartIds = supDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011 - List> idsByCode = supDepartMapper.getIdsByCode(departIds); - Map resultMap2 = idsByDepartIds.stream().collect(Collectors.toMap(map -> (String) map.get("domain_name"), map -> (String) map.get("id"))); + List> idsByDepartIds = supExternalDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011 + Map resultMap2 = idsByDepartIds.stream().filter(map -> map.get("external_id") != null).collect(Collectors.toMap( + map -> (String) map.get("external_id"), + map -> map.get("internal_id") == null ? "" : (String) map.get("internal_id") + )); List values = resultMap2.values().stream().filter(Objects::nonNull).toList();// 1011 - Map resultMap3 = idsByCode.stream().collect(Collectors.toMap(map -> (String) map.get("code"), map -> (String) map.get("id"))); - List values3 = resultMap3.values().stream().filter(Objects::nonNull).toList();// 1011 List> resultList = statisticsDepartMapper.getGroupIdsByDepartIds(values); - List> resultList2 = statisticsDepartMapper.getGroupIdsByDepartIds(values3); Map resultMap = resultList.stream().collect(Collectors.toMap( map -> (String) map.get("departId"), map -> (Long) map.get("groupId") )); - Map resultMap4 = resultList2.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId"))); - List groupIds = new ArrayList<>(); - generateBusinessPoliceList(happenTime, gBaseCJDSList, resultMap, resultMap2, resultMap4, groupIds, businessPoliceList, gBaseAJJBXXMapSR, gBaseAJJBXXMapLR, gBaseAJJBXXMapPR); + generateBusinessPoliceList(happenTime, gBaseCJDSList, resultMap, resultMap2, groupIds, businessPoliceList, gBaseAJJBXXMapSR, gBaseAJJBXXMapLR, gBaseAJJBXXMapPR); List> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds); Map names = nameList.stream().collect(Collectors.toMap( map -> (Long) map.get("groupId"), @@ -137,11 +136,11 @@ public class BusinessPoliceService extends ServiceImpl happenTime, List gBaseCJDSList, Map resultMap, Map resultMap2, Map resultMap4, List groupIds, List businessPoliceList, Map gBaseAJJBXXMapSR, Map gBaseAJJBXXMapLR, Map gBaseAJJBXXMapPR) { + private static void generateBusinessPoliceList(List happenTime, List gBaseCJDSList, Map resultMap, Map resultMap2, List groupIds, List businessPoliceList, Map gBaseAJJBXXMapSR, Map gBaseAJJBXXMapLR, Map gBaseAJJBXXMapPR) { for (GBaseCJD gBaseCJD : gBaseCJDSList) { Long groupId = resultMap.get(resultMap2.get(gBaseCJD.getCjdxssdwdm())); if (groupId == null) { - groupId = resultMap4.get(resultMap2.get(gBaseCJD.getCjdxssdwdm())); + continue; } groupIds.add(groupId); BusinessPolice businessPolice = getJJDBusinessPolice(happenTime, gBaseCJD, groupId); @@ -150,7 +149,7 @@ public class BusinessPoliceService extends ServiceImpl