代码提交
This commit is contained in:
parent
9db8a043a9
commit
3c694f2fd9
|
|
@ -89,21 +89,26 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
|
||||
for (Ownerdomin device : ownListFromManage) {
|
||||
String key = device.getCompanyId() + "_" + device.getMaName();
|
||||
System.err.println("初始化的key:" + key+"-----------"+device.toString());
|
||||
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(device);
|
||||
}
|
||||
|
||||
for (NewOwnerdomin dev : ownListFromDevInfo) {
|
||||
String key = dev.getCompanyId() + "_" + dev.getMaName();
|
||||
List<Ownerdomin> existList = ownIndex.get(key);
|
||||
|
||||
System.err.println("existList:" + existList);
|
||||
System.err.println("key:" + key+"-----------"+dev.getCompanyName());
|
||||
if (existList != null && !existList.isEmpty()) {
|
||||
for (Ownerdomin device : existList) {
|
||||
device.setMaNum(device.getMaNum() + dev.getMaNum());
|
||||
/*是否需要累加 待验证*/
|
||||
device.setMaNum(device.getMaNum() );
|
||||
device.setType("2");
|
||||
}
|
||||
} else {
|
||||
Ownerdomin newDevice = new Ownerdomin();
|
||||
newDevice.setCompanyId((long) dev.getCompanyId());
|
||||
newDevice.setMaName(dev.getMaName());
|
||||
newDevice.setType("2");
|
||||
newDevice.setMaNum(dev.getMaNum());
|
||||
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(newDevice);
|
||||
}
|
||||
|
|
@ -114,6 +119,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
|
||||
for (DeptConfigRateSummary config : configList) {
|
||||
String company = config.getCompanyName();
|
||||
System.err.println( company);
|
||||
String type = config.getConfigType().toPlainString(); // 0:线路 1:电缆 2:变电
|
||||
String maName = config.getDeptName();
|
||||
BigDecimal orderCount = config.getOrderCount();
|
||||
|
|
@ -125,7 +131,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
|
||||
DeptConfigRateSummary dto = companyMap.computeIfAbsent(company, k -> {
|
||||
DeptConfigRateSummary d = new DeptConfigRateSummary();
|
||||
d.setDeptName(company);
|
||||
d.setDeptName(config.getDeptName());
|
||||
d.setCompanyId(configCompanyId);
|
||||
d.setCompanyName(company);
|
||||
d.setValueA(BigDecimal.ZERO);
|
||||
|
|
@ -169,7 +175,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
.findFirst();
|
||||
|
||||
String companyName = matchDev.map(NewOwnerdomin::getCompanyName).orElse("未知公司");
|
||||
|
||||
System.err.println("有关问题公司查看 "+companyName);
|
||||
DeptConfigRateSummary dto = companyMap.computeIfAbsent(companyName, k -> {
|
||||
DeptConfigRateSummary d = new DeptConfigRateSummary();
|
||||
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
|
||||
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) {
|
||||
private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> owns, DeptConfigRateSummary config) {
|
||||
if (config == null || owns == null || owns.isEmpty()) return BigDecimal.ZERO;
|
||||
|
||||
BigDecimal ownedTotal = BigDecimal.ZERO;
|
||||
|
|
@ -238,7 +208,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
|
|||
BigDecimal num = new BigDecimal(own.getMaNum());
|
||||
if ("2".equals(own.getType())) {
|
||||
ownedTotal = ownedTotal.add(num); // 自有
|
||||
} else {
|
||||
} else if("1".equals(own.getType())) {
|
||||
leasedTotal = leasedTotal.add(num); // 租赁
|
||||
}
|
||||
}
|
||||
|
|
@ -262,7 +232,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
|
|||
} else {
|
||||
return rate.multiply(score).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity) {
|
||||
|
|
@ -300,7 +270,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
|
|||
|
||||
}
|
||||
} else {
|
||||
// 不存在,新增一条 EquipmentDetail,赋值必要字段
|
||||
/* // 不存在,新增一条 EquipmentDetail,赋值必要字段
|
||||
EquipmentDetail newItem = new EquipmentDetail();
|
||||
newItem.setCompanyId(devItem.getCompanyId());
|
||||
newItem.setName(devItem.getTypeName());
|
||||
|
|
@ -308,7 +278,7 @@ private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> o
|
|||
// 其他字段可根据业务决定是否赋默认值
|
||||
newItem.setDesc("来自装备配置管理");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@
|
|||
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
||||
WHERE
|
||||
md.is_active = '1'
|
||||
AND md.own_co = 221
|
||||
AND md.own_co = #{companyId}
|
||||
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
|
|
|
|||
|
|
@ -75,6 +75,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
md.is_active = '1'
|
||||
GROUP BY
|
||||
md.own_co,
|
||||
mt.type_name
|
||||
mt2.type_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue