Browse Source

修改基础数据的单位取值来源

main
sjh 1 year ago
parent
commit
ce8ecb49c2
  1. 12
      src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java
  2. 33
      src/main/java/com/biutag/supervision/service/BusinessDepartService.java
  3. 27
      src/main/java/com/biutag/supervision/service/BusinessPoliceService.java

12
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<SupExternalDepart> {
@Select("<script>"
+ "SELECT DISTINCT external_id, internal_id FROM sup_external_depart WHERE external_id IN "
+ "<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>"
+ "#{item}"
+ "</foreach>"
+ "</script>")
List<Map<String, Object>> getIdsByDepartIds(List<String> departIds);
}

33
src/main/java/com/biutag/supervision/service/BusinessDepartService.java

@ -37,14 +37,14 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
private final BusinessLogMapper businessLogMapper;
private final SupDepartMapper supDepartMapper;
private final ModelClueService modelClueService;
private final SupExternalDepartService externalDepartService;
private final GBaseAJJBXXMapper gBaseAJJBXXMapper;
private final SupExternalDepartMapper supExternalDepartMapper;
public Page<BusinessPoliceModel> page(BusinessQueryParam businessQueryParam) {
// 测基础数据
if (businessQueryParam.getDepartName() != null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) {
@ -110,29 +110,24 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
if (departIds.isEmpty()) {
return;
}
List<Map<String, Object>> idsByDepartIds = supDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011
List<Map<String, Object>> idsByCode = supDepartMapper.getIdsByCode(departIds);
Map<String, String> resultMap2 = idsByDepartIds.stream().collect(Collectors.toMap(map -> (String) map.get("domain_name"), map -> (String) map.get("id")));
List<Map<String, Object>> idsByDepartIds = supExternalDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011
Map<String, String> 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<String> values = resultMap2.values().stream().filter(Objects::nonNull).toList();// 1011
Map<String, String> resultMap3 = idsByCode.stream().collect(Collectors.toMap(map -> (String) map.get("code"), map -> (String) map.get("id")));
List<String> values3 = resultMap3.values().stream().filter(Objects::nonNull).toList();// 1011
List<Map<String, Object>> resultList = new ArrayList<>();
if (!values.isEmpty()) {
resultList = statisticsDepartMapper.getGroupIdsByDepartIds(values);
}
List<Map<String, Object>> 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<String, Long> resultMap = resultList.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId")));
Map<String, Long> resultMap4 = resultList2.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId")));
List<Long> 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<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds);
Map<Long, String> 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<BusinessDepartMapper, Bus
businessLogMapper.insert(new BusinessLog().setType("单位业务数据").setNum(gBaseJJDSList.size() + gBaseAJJBXXListSA.size() + gBaseAJJBXXListLA.size() + gBaseAJJBXXListPA.size()).setActualNum(actualNum).setCreateTime(LocalDateTime.now()));
}
private static void generateBusinessDepartList(List<Date> happenTime, List<GBaseJJD> gBaseJJDSList, Map<String, Long> resultMap, Map<String, String> resultMap2, Map<String, Long> resultMap4, List<Long> groupIds, List<BusinessDepart> businessDepartList, List<GBaseAJJBXX> gBaseAJJBXXListSA, List<GBaseAJJBXX> gBaseAJJBXXListLA, List<GBaseAJJBXX> gBaseAJJBXXListPA) {
private static void generateBusinessDepartList(List<Date> happenTime, List<GBaseJJD> gBaseJJDSList, Map<String, Long> resultMap, Map<String, String> resultMap2, List<Long> groupIds, List<BusinessDepart> businessDepartList, List<GBaseAJJBXX> gBaseAJJBXXListSA, List<GBaseAJJBXX> gBaseAJJBXXListLA, List<GBaseAJJBXX> 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<BusinessDepartMapper, Bus
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListSA) {
Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
continue;
}
groupIds.add(groupId);
BusinessDepart businessDepart = getAJJBXXBusinessDepart(happenTime, gBaseAJJBXX, groupId, 1);
@ -168,7 +163,7 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListLA) {
Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
continue;
}
groupIds.add(groupId);
BusinessDepart businessDepart = getAJJBXXBusinessDepart(happenTime, gBaseAJJBXX, groupId, 2);
@ -177,7 +172,7 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXListPA) {
Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
continue;
}
groupIds.add(groupId);
BusinessDepart businessDepart = getAJJBXXBusinessDepart(happenTime, gBaseAJJBXX, groupId, 3);

27
src/main/java/com/biutag/supervision/service/BusinessPoliceService.java

@ -46,6 +46,8 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
private final SupDepartMapper supDepartMapper;
private final SupExternalDepartMapper supExternalDepartMapper;
public Page<BusinessPoliceModel> 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<BusinessPoliceMapper, Bus
if (departIds.isEmpty()) {
return;
}
List<Map<String, Object>> idsByDepartIds = supDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011
List<Map<String, Object>> idsByCode = supDepartMapper.getIdsByCode(departIds);
Map<String, String> resultMap2 = idsByDepartIds.stream().collect(Collectors.toMap(map -> (String) map.get("domain_name"), map -> (String) map.get("id")));
List<Map<String, Object>> idsByDepartIds = supExternalDepartMapper.getIdsByDepartIds(departIds);// 430100221100-1011
Map<String, String> 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<String> values = resultMap2.values().stream().filter(Objects::nonNull).toList();// 1011
Map<String, String> resultMap3 = idsByCode.stream().collect(Collectors.toMap(map -> (String) map.get("code"), map -> (String) map.get("id")));
List<String> values3 = resultMap3.values().stream().filter(Objects::nonNull).toList();// 1011
List<Map<String, Object>> resultList = statisticsDepartMapper.getGroupIdsByDepartIds(values);
List<Map<String, Object>> resultList2 = statisticsDepartMapper.getGroupIdsByDepartIds(values3);
Map<String, Long> resultMap = resultList.stream().collect(Collectors.toMap(
map -> (String) map.get("departId"),
map -> (Long) map.get("groupId")
));
Map<String, Long> resultMap4 = resultList2.stream().collect(Collectors.toMap(map -> (String) map.get("departId"), map -> (Long) map.get("groupId")));
List<Long> 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<Map<Long, Object>> nameList = statisticsGroupMapper.getNameByGroupIds(groupIds);
Map<Long, String> names = nameList.stream().collect(Collectors.toMap(
map -> (Long) map.get("groupId"),
@ -137,11 +136,11 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
businessLogMapper.insert(new BusinessLog().setType("个人业务数据").setNum(gBaseCJDSList.size()).setActualNum(actualNum).setCreateTime(LocalDateTime.now()));
}
private static void generateBusinessPoliceList(List<Date> happenTime, List<GBaseCJD> gBaseCJDSList, Map<String, Long> resultMap, Map<String, String> resultMap2, Map<String, Long> resultMap4, List<Long> groupIds, List<BusinessPolice> businessPoliceList, Map<String, GBaseAJJBXX> gBaseAJJBXXMapSR, Map<String, GBaseAJJBXX> gBaseAJJBXXMapLR, Map<String, GBaseAJJBXX> gBaseAJJBXXMapPR) {
private static void generateBusinessPoliceList(List<Date> happenTime, List<GBaseCJD> gBaseCJDSList, Map<String, Long> resultMap, Map<String, String> resultMap2, List<Long> groupIds, List<BusinessPolice> businessPoliceList, Map<String, GBaseAJJBXX> gBaseAJJBXXMapSR, Map<String, GBaseAJJBXX> gBaseAJJBXXMapLR, Map<String, GBaseAJJBXX> 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<BusinessPoliceMapper, Bus
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXMapSR.values()) {
Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
continue;
}
groupIds.add(groupId);
BusinessPolice businessPolice = getAJJBXXBusinessPolice(happenTime, gBaseAJJBXX, groupId, 4);
@ -159,7 +158,7 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXMapLR.values()) {
Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
continue;
}
groupIds.add(groupId);
BusinessPolice businessPolice = getAJJBXXBusinessPolice(happenTime, gBaseAJJBXX, groupId, 5);
@ -168,7 +167,7 @@ public class BusinessPoliceService extends ServiceImpl<BusinessPoliceMapper, Bus
for (GBaseAJJBXX gBaseAJJBXX : gBaseAJJBXXMapPR.values()) {
Long groupId = resultMap.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
if (groupId == null) {
groupId = resultMap4.get(resultMap2.get(gBaseAJJBXX.getBADWIDdm()));
continue;
}
groupIds.add(groupId);
BusinessPolice businessPolice = getAJJBXXBusinessPolice(happenTime, gBaseAJJBXX, groupId, 6);

Loading…
Cancel
Save