From 1d66c65d7eedc21dba64b25f4e05f0793336850a Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Wed, 26 Apr 2023 12:09:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/enums/ProductionStatisticsEnum.java | 3 +- .../wms/cockpit/service/dto/WorkorderDto.java | 1 + .../service/impl/CockpitServiceImpl.java | 78 +++++++++++++------ .../nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql | 11 ++- .../nl/wms/cockpit/wql/COCKPIT_STORAGE.wql | 6 +- 5 files changed, 71 insertions(+), 28 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java b/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java index 3287078..c2d533e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java @@ -6,6 +6,7 @@ package org.nl.modules.common.utils.enums; * @since 2023-03-01 */ public enum ProductionStatisticsEnum{ + RAW_MATERIAL("原料", "1"), /** * 今日压制量 */ @@ -17,7 +18,7 @@ public enum ProductionStatisticsEnum{ /** * 今日成品量 */ - FINISHED("成品", "4"); + FINISHED("包装", "4"); private String name; private String index; diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/WorkorderDto.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/WorkorderDto.java index 59df345..26832ec 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/WorkorderDto.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/WorkorderDto.java @@ -66,4 +66,5 @@ public class WorkorderDto implements Serializable{ * 开始时间 */ private String realproducestart_date; + private String realproduceend_date; } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java index 1d49bfa..5087b46 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java @@ -18,12 +18,10 @@ import org.nl.wms.sch.manage.DeviceEnum; import org.nl.wms.sch.manage.PointEnum; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.time.Duration; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -57,7 +55,6 @@ public class CockpitServiceImpl implements CockpitService{ if(ObjectUtil.isNotEmpty(result)) { res = result.toJavaList(WorkorderDto.class); // res.forEach(r -> { - // todo: 未根据实际,可以不需要客户 // r.setCust_name("新余钢铁"); // if(StringUtils.isNotEmpty(r.getLabel())) { // r.setLabel(r.getLabel().substring(0, 2)); @@ -77,7 +74,17 @@ public class CockpitServiceImpl implements CockpitService{ */ // 2、获取原料计划完成情况 CompletableFuture materialTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "5").process().getResultJSONArray(0), pool); - materialTask.thenAccept((result) -> map.put("materialTask", result)).exceptionally((e) -> { + materialTask.thenAccept((result) -> { + if (ObjectUtil.isEmpty(result)) { + JSONObject object = new JSONObject(); + object.put("workorder_procedure", "原料"); + object.put("label", "1"); + object.put("plan_qty", "0"); + object.put("real_qty", "0"); + result.add(object); + } + map.put("materialTask", result); + }).exceptionally((e) -> { log.error("获取原料计划完成情况: {}", e.getMessage(), e); map.put("materialTask", ""); return null; @@ -90,10 +97,10 @@ public class CockpitServiceImpl implements CockpitService{ if(ObjectUtil.isNotEmpty(result)) { //成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集 planRes = result.toJavaList(ProductionStatisticsDto.class); -// getProcedureName(planRes, 1); + setResultComplete(planRes); //今日压制量,干燥量,成品量 finishedRes = result.toJavaList(ProductionStatisticsDto.class); -// getProcedureName(finishedRes, 2); + setResultComplete(finishedRes); } map.put("planRes", planRes); map.put("finishedRes", finishedRes); @@ -314,25 +321,52 @@ public class CockpitServiceImpl implements CockpitService{ } /** - * 处理工序字段 + * 处理空白数据设置默认值 */ - private void getProcedureName(List result, Integer type) { - if(type == 1) { - result.forEach(r -> { - if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { - r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); - } - }); + private void setResultComplete(List result) { + HashSet existingLabels = new HashSet<>(); // 创建一个 HashSet 对象 + // 遍历 result 列表中的每个 ProductionStatisticsDto 对象 + for (ProductionStatisticsDto dto : result) { + // 检查 label 字段是否存在于 existingLabels 集合中 + if (!existingLabels.contains(dto.getLabel())) { + // 将缺少的标签值添加到 existingLabels 集合中 + existingLabels.add(dto.getLabel()); + } } - else{ - result.forEach(r -> { - if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { // 处理字段 - r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); - } - }); + // 检查 1、2、3、4 标签值是否全部存在,如果有缺失则创建新的 ProductionStatisticsDto 对象并添加到 result 列表中 + for (int i = 1; i <= 4; i++) { + if (!existingLabels.contains(i+"")) { + result.add(ProductionStatisticsDto + .builder() + .workorder_procedure(ProductionStatisticsEnum.getName(String.valueOf(i))) + .label(String.valueOf(i)) + .real_qty(BigDecimal.valueOf(0)) + .plan_qty(BigDecimal.valueOf(0)) + .build()); + } } } + /** + * 处理工序字段 + */ + private void getProcedureName(List result, int type) { +// if(type == 1) { +// result.forEach(r -> { +// if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { +// r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); +// } +// }); +// } +// else{ +// result.forEach(r -> { +// if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { // 处理字段 +// r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); +// } +// }); +// } + } + /** * 判断静置状态 */ diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql index f78e1e1..2004df8 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql @@ -50,7 +50,14 @@ dicts.label order_status_name, material.material_code, device.device_name, - workorder.* + workorder.workorder_id, + workorder.plan_qty, + workorder.real_qty, + workorder.qualified_qty, + workorder.unqualified_qty, + workorder.order_status, + IF(LENGTH(realproducestart_date) > 0, realproducestart_date, '-') realproducestart_date, + IF(LENGTH(realproduceend_date) > 0, realproduceend_date, '-') realproduceend_date FROM PDM_BD_WORKORDER workorder LEFT JOIN md_me_materialbase material ON material.material_id = workorder.material_id @@ -60,7 +67,7 @@ WHERE workorder.is_delete = '0' ORDER BY - workorder.create_time DESC + workorder.order_status ASC, workorder.create_time DESC ENDSELECT ENDPAGEQUERY ENDIF diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_STORAGE.wql b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_STORAGE.wql index 076f4e1..8e4501c 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_STORAGE.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_STORAGE.wql @@ -63,7 +63,7 @@ WHERE point.region_code = 'KLHJ' ORDER BY - point.point_code DESC + point.point_code ASC ENDSELECT ENDPAGEQUERY ENDIF @@ -93,7 +93,7 @@ WHERE point.region_code = 'BCPHJ' ORDER BY - point.create_time DESC + point.point_code ASC ENDSELECT ENDPAGEQUERY ENDIF @@ -114,7 +114,7 @@ point.point_id = 输入.point_id ENDOPTION ORDER BY - point.create_time DESC + point.point_code ASC ENDSELECT ENDPAGEQUERY ENDIF