完成龙兴发运看板

uat-temp-nht-202502180000-shippingkanban
jason 3 months ago
parent cb50635c6c
commit ff7b11e271

@ -1043,8 +1043,7 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer
List<String> values = new ArrayList<>();
List<String> strShippingGroupList = Arrays.asList(cfg.getShippingGroupCode().split(","));
if (CollectionUtils.isEmpty(strShippingGroupList)) {
values.add("0");
return values;
return Collections.singletonList("0");
}
Date nowTime = DateUtil.now();
@ -1083,19 +1082,19 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer
List<String> values = new ArrayList<>();
List<MesPartShippingGroup> partShippingGroups = getShippingGroups(cfg);
if (CollectionUtils.isEmpty(partShippingGroups)) {
values.add("0");
return values;
return Collections.singletonList("0");
}
Date nowTime = DateUtil.now();
Date prevHourTime = DateUtil.addMinutes(nowTime, -60);
StringBuilder hql = new StringBuilder();
hql.append("select new map(workCenterCode, count(1) as totalCount) from " + MesProductionRecord.class.getName());
hql.append(" where organizeCode = :organizeCode and isDeleted = :isDeleted and isValid = :isValid ");
hql.append(" and createDatetime BETWEEN :startDateTime AND :endDateTime ");
hql.append(" group by workCenterCode");
List<Map> ddd = entityManager.createQuery(hql.toString())
// Use a single query to fetch counts grouped by work center code
List<Map> productionCounts = entityManager.createQuery(
"SELECT new map(pr.workCenterCode as workCenterCode, COUNT(pr) as totalCount) " +
"FROM " + MesProductionRecord.class.getName() + " pr " +
"WHERE pr.organizeCode = :organizeCode AND pr.isDeleted = :isDeleted AND pr.isValid = :isValid " +
"AND pr.createDatetime BETWEEN :startDateTime AND :endDateTime " +
"GROUP BY pr.workCenterCode", Map.class)
.setParameter("organizeCode", cfg.getOrganizeCode())
.setParameter("isValid", CommonEnumUtil.VALID)
.setParameter("isDeleted", CommonEnumUtil.FALSE)
@ -1103,21 +1102,23 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer
.setParameter("endDateTime", DateUtil.formatDate(prevHourTime))
.getResultList();
Map<String, String> shippingGroupCount = new HashMap<>();
if (!CollectionUtils.isEmpty(ddd)) {
for (Map dd : ddd) {
Object totalCount = dd.get("totalCount");
if (totalCount != null) {
shippingGroupCount.put(dd.get("workCenterCode").toString(), totalCount.toString());
}
}
}
// Use a map to store counts for quick access
Map<String, String> shippingGroupCount = productionCounts.stream()
.collect(Collectors.toMap(
map -> map.get("workCenterCode").toString(),
map -> map.get("totalCount").toString(),
(existing, replacement) -> existing // Handle duplicates if any
));
// Collect counts for each shipping group
for (MesPartShippingGroup shippingGroup : partShippingGroups) {
if (StringUtils.isEmpty(shippingGroup.getCarrierCode())) {
continue;
}
values.add(shippingGroupCount.getOrDefault(shippingGroup.getCarrierCode(), "0"));
}
// Ensure at least one value is returned
if (values.isEmpty()) {
values.add("0");
}

Loading…
Cancel
Save