代码提交

This commit is contained in:
liang.chao 2025-07-07 08:52:02 +08:00
parent 9db8a043a9
commit 3c694f2fd9
3 changed files with 120 additions and 149 deletions

View File

@ -89,21 +89,26 @@ public class SysDeptServiceImpl implements ISysDeptService {
for (Ownerdomin device : ownListFromManage) { for (Ownerdomin device : ownListFromManage) {
String key = device.getCompanyId() + "_" + device.getMaName(); String key = device.getCompanyId() + "_" + device.getMaName();
System.err.println("初始化的key:" + key+"-----------"+device.toString());
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(device); ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(device);
} }
for (NewOwnerdomin dev : ownListFromDevInfo) { for (NewOwnerdomin dev : ownListFromDevInfo) {
String key = dev.getCompanyId() + "_" + dev.getMaName(); String key = dev.getCompanyId() + "_" + dev.getMaName();
List<Ownerdomin> existList = ownIndex.get(key); List<Ownerdomin> existList = ownIndex.get(key);
System.err.println("existList:" + existList);
System.err.println("key:" + key+"-----------"+dev.getCompanyName());
if (existList != null && !existList.isEmpty()) { if (existList != null && !existList.isEmpty()) {
for (Ownerdomin device : existList) { for (Ownerdomin device : existList) {
device.setMaNum(device.getMaNum() + dev.getMaNum()); /*是否需要累加 待验证*/
device.setMaNum(device.getMaNum() );
device.setType("2");
} }
} else { } else {
Ownerdomin newDevice = new Ownerdomin(); Ownerdomin newDevice = new Ownerdomin();
newDevice.setCompanyId((long) dev.getCompanyId()); newDevice.setCompanyId((long) dev.getCompanyId());
newDevice.setMaName(dev.getMaName()); newDevice.setMaName(dev.getMaName());
newDevice.setType("2");
newDevice.setMaNum(dev.getMaNum()); newDevice.setMaNum(dev.getMaNum());
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(newDevice); ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(newDevice);
} }
@ -114,6 +119,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
for (DeptConfigRateSummary config : configList) { for (DeptConfigRateSummary config : configList) {
String company = config.getCompanyName(); String company = config.getCompanyName();
System.err.println( company);
String type = config.getConfigType().toPlainString(); // 0:线路 1:电缆 2:变电 String type = config.getConfigType().toPlainString(); // 0:线路 1:电缆 2:变电
String maName = config.getDeptName(); String maName = config.getDeptName();
BigDecimal orderCount = config.getOrderCount(); BigDecimal orderCount = config.getOrderCount();
@ -125,7 +131,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
DeptConfigRateSummary dto = companyMap.computeIfAbsent(company, k -> { DeptConfigRateSummary dto = companyMap.computeIfAbsent(company, k -> {
DeptConfigRateSummary d = new DeptConfigRateSummary(); DeptConfigRateSummary d = new DeptConfigRateSummary();
d.setDeptName(company); d.setDeptName(config.getDeptName());
d.setCompanyId(configCompanyId); d.setCompanyId(configCompanyId);
d.setCompanyName(company); d.setCompanyName(company);
d.setValueA(BigDecimal.ZERO); d.setValueA(BigDecimal.ZERO);
@ -169,7 +175,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
.findFirst(); .findFirst();
String companyName = matchDev.map(NewOwnerdomin::getCompanyName).orElse("未知公司"); String companyName = matchDev.map(NewOwnerdomin::getCompanyName).orElse("未知公司");
System.err.println("有关问题公司查看 "+companyName);
DeptConfigRateSummary dto = companyMap.computeIfAbsent(companyName, k -> { DeptConfigRateSummary dto = companyMap.computeIfAbsent(companyName, k -> {
DeptConfigRateSummary d = new DeptConfigRateSummary(); DeptConfigRateSummary d = new DeptConfigRateSummary();
d.setDeptName(companyName); d.setDeptName(companyName);
@ -191,44 +197,8 @@ public class SysDeptServiceImpl implements ISysDeptService {
} }
// 可选添加没有配置项但有设备的公司
private void addCompaniesWithoutConfig(List<DeptConfigRateSummary> configList,
Map<String, DeptConfigRateSummary> companyMap,
Map<String, List<Ownerdomin>> ownIndex) {
// 获取所有配置表中出现的公司ID
Set<Long> configCompanyIds = configList.stream()
.map(DeptConfigRateSummary::getCompanyId)
.collect(Collectors.toSet());
// 获取所有设备公司ID private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> owns, DeptConfigRateSummary config) {
Set<Long> deviceCompanyIds = ownIndex.keySet().stream()
.map(key -> Long.parseLong(key.split("_")[0]))
.collect(Collectors.toSet());
// 找出有设备但没配置的公司ID
Set<Long> missingCompanyIds = new HashSet<>(deviceCompanyIds);
missingCompanyIds.removeAll(configCompanyIds);
// 为这些公司创建空汇总对象
for (Long companyId : missingCompanyIds) {
// 获取公司名称需要查询或从设备中提取
String companyName = "未知公司"; // 实际应从设备数据中获取
companyMap.computeIfAbsent(companyName, k -> {
DeptConfigRateSummary d = new DeptConfigRateSummary();
d.setDeptName(companyName);
d.setCompanyId(companyId);
d.setCompanyName(companyName);
d.setValueA(BigDecimal.ZERO);
d.setValueB(BigDecimal.ZERO);
d.setValueC(BigDecimal.ZERO);
return d;
});
}
}
private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> owns, DeptConfigRateSummary config) {
if (config == null || owns == null || owns.isEmpty()) return BigDecimal.ZERO; if (config == null || owns == null || owns.isEmpty()) return BigDecimal.ZERO;
BigDecimal ownedTotal = BigDecimal.ZERO; BigDecimal ownedTotal = BigDecimal.ZERO;
@ -238,7 +208,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
BigDecimal num = new BigDecimal(own.getMaNum()); BigDecimal num = new BigDecimal(own.getMaNum());
if ("2".equals(own.getType())) { if ("2".equals(own.getType())) {
ownedTotal = ownedTotal.add(num); // 自有 ownedTotal = ownedTotal.add(num); // 自有
} else { } else if("1".equals(own.getType())) {
leasedTotal = leasedTotal.add(num); // 租赁 leasedTotal = leasedTotal.add(num); // 租赁
} }
} }
@ -262,7 +232,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
} else { } else {
return rate.multiply(score).setScale(2, RoundingMode.HALF_UP); return rate.multiply(score).setScale(2, RoundingMode.HALF_UP);
} }
} }
@Override @Override
public List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity) { public List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity) {
@ -300,7 +270,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
} }
} else { } else {
// 不存在新增一条 EquipmentDetail赋值必要字段 /* // 不存在新增一条 EquipmentDetail赋值必要字段
EquipmentDetail newItem = new EquipmentDetail(); EquipmentDetail newItem = new EquipmentDetail();
newItem.setCompanyId(devItem.getCompanyId()); newItem.setCompanyId(devItem.getCompanyId());
newItem.setName(devItem.getTypeName()); newItem.setName(devItem.getTypeName());
@ -308,7 +278,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
// 其他字段可根据业务决定是否赋默认值 // 其他字段可根据业务决定是否赋默认值
newItem.setDesc("来自装备配置管理"); newItem.setDesc("来自装备配置管理");
equipmentDetails.add(newItem); equipmentDetails.add(newItem);
indexMap.put(key, newItem); indexMap.put(key, newItem);*/
} }
} }
@ -386,3 +356,4 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
return getChildList(list, t).size() > 0 ? true : false; return getChildList(list, t).size() > 0 ? true : false;
} }
} }

View File

@ -221,7 +221,7 @@
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
WHERE WHERE
md.is_active = '1' md.is_active = '1'
AND md.own_co = 221 AND md.own_co = #{companyId}
GROUP BY GROUP BY
mt.type_id mt.type_id

View File

@ -75,6 +75,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
md.is_active = '1' md.is_active = '1'
GROUP BY GROUP BY
md.own_co, md.own_co,
mt.type_name mt2.type_id
</select> </select>
</mapper> </mapper>