10 changed files with 165 additions and 321 deletions
@ -0,0 +1,21 @@ |
|||||||
|
package com.biutag.supervisiondata.pojo.enums; |
||||||
|
|
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author kami on 2024-11-25 16:54:01 |
||||||
|
* @version 0.0.1 |
||||||
|
* @since 1.8 |
||||||
|
*/ |
||||||
|
@AllArgsConstructor |
||||||
|
@Getter |
||||||
|
@Slf4j |
||||||
|
public enum OrgType { |
||||||
|
|
||||||
|
POINT( "重点人员"), |
||||||
|
INSTANCE( "情指行"); |
||||||
|
|
||||||
|
private final String type; |
||||||
|
} |
||||||
@ -0,0 +1,72 @@ |
|||||||
|
package com.biutag.supervisiondata.util; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.biutag.supervisiondata.pojo.database.PointOrg; |
||||||
|
import com.biutag.supervisiondata.pojo.entity.mine.SupExternalDepart; |
||||||
|
import com.biutag.supervisiondata.pojo.enums.OrgType; |
||||||
|
import com.biutag.supervisiondata.repository.GBaseZDRYRepository; |
||||||
|
import com.biutag.supervisiondata.repository.SupExternalDepartRepository; |
||||||
|
import lombok.experimental.UtilityClass; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.WeakHashMap; |
||||||
|
import java.util.function.Function; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author kami on 2024-12-18 15:42 |
||||||
|
* @version 1.0 |
||||||
|
* @since 1.8 |
||||||
|
*/ |
||||||
|
@UtilityClass |
||||||
|
public class DepartUtil { |
||||||
|
|
||||||
|
static Map<String, PointOrg> orgIdMap = new WeakHashMap<>(); |
||||||
|
static Map<String, PointOrg> orgCodeMap = new WeakHashMap<>(); |
||||||
|
static Map<String, SupExternalDepart> pointExternalDepart = new WeakHashMap<>(); |
||||||
|
static Map<String, SupExternalDepart> jqExternalDepart = new WeakHashMap<>(); |
||||||
|
|
||||||
|
|
||||||
|
public static void init(GBaseZDRYRepository ryRepository, SupExternalDepartRepository externalDepartRepository) { |
||||||
|
List<PointOrg> orgList = ryRepository.getBaseMapper().selectOrg(); |
||||||
|
for (PointOrg org : orgList) { |
||||||
|
orgIdMap.put(org.getId(), org); |
||||||
|
orgCodeMap.put(org.getDm(), org); |
||||||
|
} |
||||||
|
List<SupExternalDepart> supDeparts = externalDepartRepository.list(new LambdaQueryWrapper<SupExternalDepart>() |
||||||
|
.select(SupExternalDepart::getExternalId, SupExternalDepart::getInternalId, SupExternalDepart::getInternalShortName, SupExternalDepart::getSource) |
||||||
|
.in(SupExternalDepart::getSource, List.of(OrgType.POINT.getType(), OrgType.INSTANCE.getType()))); |
||||||
|
Map<String, List<SupExternalDepart>> amp = supDeparts.stream().collect(Collectors.groupingBy(SupExternalDepart::getSource)); |
||||||
|
|
||||||
|
pointExternalDepart.putAll(amp.get(OrgType.POINT.getType()).stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val, old) -> val))); |
||||||
|
jqExternalDepart.putAll(amp.get(OrgType.INSTANCE.getType()).stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val, old) -> val))); |
||||||
|
} |
||||||
|
|
||||||
|
public static SupExternalDepart findLevelThereOrg(String dm, OrgType type) { |
||||||
|
if(dm == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
PointOrg org = orgCodeMap.get(dm); |
||||||
|
org = findOrg(org); |
||||||
|
if (org == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
SupExternalDepart depart = null; |
||||||
|
switch (type) { |
||||||
|
case OrgType.POINT -> depart = pointExternalDepart.get(org.getDm()); |
||||||
|
case OrgType.INSTANCE -> depart = jqExternalDepart.get(org.getDm()); |
||||||
|
} |
||||||
|
return depart; |
||||||
|
} |
||||||
|
|
||||||
|
private static PointOrg findOrg(PointOrg org) { |
||||||
|
if (org == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
if (org.getPcs() == null || !org.getPcs().equals("1")) { |
||||||
|
return findOrg(orgIdMap.get(org.getPid())); |
||||||
|
} |
||||||
|
return org; |
||||||
|
} |
||||||
|
} |
||||||
@ -1,25 +0,0 @@ |
|||||||
package com.biutag.supervisiondata.util; |
|
||||||
|
|
||||||
import com.biutag.supervisiondata.pojo.database.PointOrg; |
|
||||||
import lombok.experimental.UtilityClass; |
|
||||||
|
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author kami on 2024-12-06 10:43:55 |
|
||||||
* @version 0.0.1 |
|
||||||
* @since 1.8 |
|
||||||
*/ |
|
||||||
@UtilityClass |
|
||||||
public class OrgUtil { |
|
||||||
|
|
||||||
public static PointOrg findOrg(PointOrg org, Map<String, PointOrg> orgIdMap) { |
|
||||||
if (org == null) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
if (org.getPcs() == null || !org.getPcs().equals("1")) { |
|
||||||
return findOrg(orgIdMap.get(org.getPid()), orgIdMap); |
|
||||||
} |
|
||||||
return org; |
|
||||||
} |
|
||||||
} |
|
||||||
Loading…
Reference in new issue