From fbef8c33428de257330713d22d4f37c4ac45e54f Mon Sep 17 00:00:00 2001 From: baoge <751575283@qq.com> Date: Fri, 3 Mar 2023 17:13:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=A7=E5=B1=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.大屏接口应前端习惯修改接口方式为post; 2.修改生产统计,增加枚举处理完成量及工序中文描述; 3.增加返回code和描述信息,增加常用异常状态码以便排查; 4.修改所有返回枚举类型的增加中文描述; 5.按页面区域切分一 一返回数组对象,以便前端直接绑值 。 --- .../common/utils/enums/PointStatusEnum.java | 16 ++-- .../utils/enums/ProductionStatisticsEnum.java | 58 +++++++++++++ .../common/utils/enums/RequestMethodEnum.java | 81 +++++++++---------- .../wms/cockpit/rest/CockpitController.java | 27 ++++--- .../wms/cockpit/service/CockpitService.java | 4 +- .../cockpit/service/dto/DeviceStatusDto.java | 9 ++- .../service/dto/ProductionStatisticsDto.java | 10 ++- .../service/impl/CockpitServiceImpl.java | 77 +++++++++++++----- .../nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql | 5 +- 9 files changed, 194 insertions(+), 93 deletions(-) create mode 100644 lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/PointStatusEnum.java b/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/PointStatusEnum.java index 04dae52..784a847 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/PointStatusEnum.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/PointStatusEnum.java @@ -7,21 +7,25 @@ package org.nl.modules.common.utils.enums; */ public enum PointStatusEnum{ /** - * 运行 + * 暂停 */ - RUN("运行", "1"), + STOP("暂停", "1"), /** - * 暂停 + * 运行 */ - STOP("暂停", "2"), + RUN("运行中", "2"), /** * 故障 */ - FAULT("故障", "3"); + FAULT("故障", "3"), + /** + * 关机 + */ + SHUTDOWN("关机", "4"); private String name; private String index; - PointStatusEnum(String name, String index) { + PointStatusEnum(String name, String index) { this.name = name; this.index = index; } 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 new file mode 100644 index 0000000..e985582 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java @@ -0,0 +1,58 @@ +package org.nl.modules.common.utils.enums; + +/** + * @author gbx + * 大屏生产统计枚举 + * @since 2023-03-01 + */ +public enum ProductionStatisticsEnum{ + /** + * 今日压制量 + */ + CRUSH("今日压制量", "2"), + /** + * 今日干燥量 + */ + DRY("今日干燥量", "3"), + /** + * 今日成品量 + */ + FINISHED("今日成品量", "4"); + private String name; + private String index; + + ProductionStatisticsEnum(String name, String index) { + this.name = name; + this.index = index; + } + + public static String getName(String index) { + for(ProductionStatisticsEnum c : ProductionStatisticsEnum.values()) { + if(c.getIndex().equals(index)) { + return c.name; + } + } + return null; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + @Override + public String toString() { + return this.index + "_" + this.name; + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RequestMethodEnum.java b/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RequestMethodEnum.java index dff3cb9..0db68c9 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RequestMethodEnum.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RequestMethodEnum.java @@ -26,49 +26,42 @@ import lombok.Getter; **/ @Getter @AllArgsConstructor -public enum RequestMethodEnum { +public enum RequestMethodEnum{ + /** + * 搜寻 @AnonymousGetMapping + */ + GET("GET"), + /** + * 搜寻 @AnonymousPostMapping + */ + POST("POST"), + /** + * 搜寻 @AnonymousPutMapping + */ + PUT("PUT"), + /** + * 搜寻 @AnonymousPatchMapping + */ + PATCH("PATCH"), + /** + * 搜寻 @AnonymousDeleteMapping + */ + DELETE("DELETE"), + /** + * 否则就是所有 Request 接口都放行 + */ + ALL("All"); + /** + * Request 类型 + */ + private final String type; - /** - * 搜寻 @AnonymousGetMapping - */ - GET("GET"), - - /** - * 搜寻 @AnonymousPostMapping - */ - POST("POST"), - - /** - * 搜寻 @AnonymousPutMapping - */ - PUT("PUT"), - - /** - * 搜寻 @AnonymousPatchMapping - */ - PATCH("PATCH"), - - /** - * 搜寻 @AnonymousDeleteMapping - */ - DELETE("DELETE"), - - /** - * 否则就是所有 Request 接口都放行 - */ - ALL("All"); - - /** - * Request 类型 - */ - private final String type; - - public static RequestMethodEnum find(String type) { - for (RequestMethodEnum value : RequestMethodEnum.values()) { - if (type.equals(value.getType())) { - return value; - } - } - return ALL; - } + public static RequestMethodEnum find(String type) { + for(RequestMethodEnum value : RequestMethodEnum.values()) { + if(type.equals(value.getType())) { + return value; + } + } + return ALL; + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/rest/CockpitController.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/rest/CockpitController.java index 78be4ca..647b71d 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/rest/CockpitController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/rest/CockpitController.java @@ -1,7 +1,9 @@ package org.nl.wms.cockpit.rest; +import org.apache.commons.lang3.StringUtils; import org.nl.modules.common.api.CommonResult; import org.nl.modules.common.api.RestBusinessTemplate; +import org.nl.modules.common.api.ResultCode; import org.nl.modules.common.exception.BizCoreException; import org.nl.wms.cockpit.service.CockpitService; import org.nl.wms.cockpit.service.dto.DeviceDetailDto; @@ -14,6 +16,7 @@ import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; import java.util.List; +import java.util.Map; /** * 大屏数据 @@ -32,7 +35,7 @@ public class CockpitController{ /** * 生产统计 */ - @GetMapping("/productionStatistics") + @PostMapping("/productionStatistics") @Log("生产统计") @ApiOperation("生产统计") public CommonResult productionStatistics() { @@ -42,7 +45,7 @@ public class CockpitController{ /** * 仓储监控 */ - @GetMapping("/storageMonitor") + @PostMapping("/storageMonitor") @Log("仓储监控") @ApiOperation("仓储监控") public CommonResult storageMonitor() { @@ -52,13 +55,13 @@ public class CockpitController{ /** * 根据点位id获取仓储信息 */ - @GetMapping("/findStorageById/{id}") + @PostMapping("/findStorageById") @Log("根据点位id获取仓储信息") @ApiOperation("根据点位id获取仓储信息") - public CommonResult findStorageById(@PathVariable String id) { + public CommonResult findStorageById(@RequestBody Map id) { return RestBusinessTemplate.execute(() -> { - if(null == id) { - throw new BizCoreException("点位id不能为空"); + if(!StringUtils.isNotEmpty(id.get("id"))) { + throw new BizCoreException(ResultCode.VALIDATE_FAILED); } return cockpitService.findStorageById(id); }); @@ -67,7 +70,7 @@ public class CockpitController{ /** * 设备监控 */ - @GetMapping("/deviceMonitor") + @PostMapping("/deviceMonitor") @Log("设备监控") @ApiOperation("设备监控") public CommonResult> deviceMonitor() { @@ -77,13 +80,13 @@ public class CockpitController{ /** * 根据点位id获取设备信息 */ - @GetMapping("/findDeviceById/{id}") + @PostMapping("/findDeviceById") @Log("根据点位id获取设备信息") @ApiOperation("根据点位id获取设备信息") - public CommonResult findDeviceById(@PathVariable String id) { + public CommonResult findDeviceById(@RequestBody Map id) { return RestBusinessTemplate.execute(() -> { - if(null == id) { - throw new BizCoreException("点位id不能为空"); + if(!StringUtils.isNotEmpty(id.get("id"))) { + throw new BizCoreException(ResultCode.VALIDATE_FAILED); } return cockpitService.findDeviceById(id); }); @@ -92,7 +95,7 @@ public class CockpitController{ /** * 車间情况 */ - @GetMapping("/workshopCondition") + @PostMapping("/workshopCondition") @Log("车间情况") @ApiOperation("车间情况") public CommonResult workshopCondition() { diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/CockpitService.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/CockpitService.java index 7d39785..24f4f02 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/CockpitService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/CockpitService.java @@ -35,7 +35,7 @@ public interface CockpitService{ * @param id 点位id * @return 返回结果集 */ - SchBasePointDto findStorageById(String id); + SchBasePointDto findStorageById(Map id); /** * 设备监控 @@ -50,7 +50,7 @@ public interface CockpitService{ * @param id 点位id * @return 返回结果集 */ - DeviceDetailDto findDeviceById(String id); + DeviceDetailDto findDeviceById(Map id); /** * 車间情况 diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/DeviceStatusDto.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/DeviceStatusDto.java index 51e657d..6e76042 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/DeviceStatusDto.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/DeviceStatusDto.java @@ -32,9 +32,13 @@ public class DeviceStatusDto implements Serializable{ */ private String point_name; /** - * 设备状态:1未生产2已下发3生产中4暂停5完成 + * 设备状态枚举 */ private String point_status; + /** + * 设备状态:1未生产2已下发3生产中4暂停5完成 + */ + private String point_status_name; /** * 当前生产物料ID */ @@ -63,11 +67,8 @@ public class DeviceStatusDto implements Serializable{ * 容量 */ private BigDecimal vehicle_max_qty; - /** * 设备图片 */ private String device_url; - - } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/ProductionStatisticsDto.java b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/ProductionStatisticsDto.java index 857547b..6c3ec15 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/ProductionStatisticsDto.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/ProductionStatisticsDto.java @@ -6,7 +6,6 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; - import java.math.BigDecimal; /** @@ -20,10 +19,15 @@ import java.math.BigDecimal; @AllArgsConstructor public class ProductionStatisticsDto{ /** - * 1混料2压制3干燥4包装(成品) + * 今日完成量工序名称 */ - @ApiModelProperty(value = "/**1混料2压制3干燥4包装(成品)*/") + @ApiModelProperty(value = "/**今日完成量工序名称*/") private String workorder_procedure; + /** + * 成品计划完成情况工序名称 + */ + @ApiModelProperty(value = "/**1混料2压制3干燥4包装(成品)*/") + private String label; /** * 计划生产数量 */ 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 3323bad..d019442 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 @@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils; import org.nl.config.thread.ThreadPoolExecutorUtil; import org.nl.modules.common.utils.enums.IsOrNotEnum; import org.nl.modules.common.utils.enums.PointStatusEnum; +import org.nl.modules.common.utils.enums.ProductionStatisticsEnum; import org.nl.modules.wql.WQL; import org.nl.wms.cockpit.service.CockpitService; import org.nl.wms.cockpit.service.dto.*; @@ -42,7 +43,7 @@ public class CockpitServiceImpl implements CockpitService{ public ConcurrentHashMap productionStatistics() { ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll(); ConcurrentHashMap map = new ConcurrentHashMap<>(3); - // 1、获取生产任务列表、 + // 1、获取生产任务列表 CompletableFuture> productionTask = CompletableFuture.supplyAsync(() -> { List res = new CopyOnWriteArrayList<>(); JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0); @@ -71,22 +72,24 @@ public class CockpitServiceImpl implements CockpitService{ return null; }); // 3、获取成品计划完成情况,今日压制量,干燥量,成品量 - CompletableFuture> finishedTask = CompletableFuture.supplyAsync(() -> { - List res = new CopyOnWriteArrayList<>(); - JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "3").process().getResultJSONArray(0); + CompletableFuture finishedTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "3").process().getResultJSONArray(0), pool); + finishedTask.thenAccept((result) -> { + List planRes = new CopyOnWriteArrayList<>(); + List finishedRes = new CopyOnWriteArrayList<>(); if(ObjectUtil.isNotEmpty(result)) { - res = result.toJavaList(ProductionStatisticsDto.class); - res.forEach(r -> { - if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { - r.setWorkorder_procedure(Objects.equals(r.getWorkorder_procedure(), "2") ? "今日压制量" : Objects.equals(r.getWorkorder_procedure(), "3") ? "今日干燥量" : "今日成品量"); - } - }); + //成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用 + planRes = result.toJavaList(ProductionStatisticsDto.class); + getProcedureName(planRes, 1); + //今日压制量,干燥量,成品量 + finishedRes = result.toJavaList(ProductionStatisticsDto.class); + getProcedureName(finishedRes, 2); } - return res; - }, pool); - finishedTask.thenAccept((result) -> map.put("finishedTask", result)).exceptionally((e) -> { + map.put("planRes", planRes); + map.put("finishedRes", finishedRes); + }).exceptionally((e) -> { log.error("获取成品计划完成情况: {}", e.getMessage(), e); - map.put("finishedTask", ""); + map.put("planRes", ""); + map.put("finishedRes", ""); return null; }); CompletableFuture allQuery = CompletableFuture.allOf(productionTask, materialTask, finishedTask); @@ -126,9 +129,15 @@ public class CockpitServiceImpl implements CockpitService{ } return res; }, pool); - materialStorage.thenAccept((result) -> map.put("materialTask", result)).exceptionally((e) -> { + materialStorage.thenAccept((result) -> { + //原料仓储监控信息,应前端要求分开两个一样的数据结果,简化调用 + map.put("materialTask", result); + //原料库存 + map.put("materialList", result); + }).exceptionally((e) -> { log.error("获取原料仓储信息: {}", e.getMessage(), e); map.put("materialTask", ""); + map.put("materialList", ""); return null; }); // 2、获取成品仓储信息 @@ -140,9 +149,15 @@ public class CockpitServiceImpl implements CockpitService{ } return res; }, pool); - finishedStorage.thenAccept((result) -> map.put("productionTask", result)).exceptionally((e) -> { + finishedStorage.thenAccept((result) -> { + //成品仓储监控信息,应前端要求分开两个一样的数据结果,简化调用 + map.put("productionTask", result); + //成品库存 + map.put("productionList", result); + }).exceptionally((e) -> { log.error("获取成品仓储信息: {}", e.getMessage(), e); map.put("productionTask", ""); + map.put("productionList", ""); return null; }); CompletableFuture allQuery = CompletableFuture.allOf(materialStorage, finishedStorage); @@ -161,8 +176,8 @@ public class CockpitServiceImpl implements CockpitService{ * @since 2023/3/1 */ @Override - public SchBasePointDto findStorageById(String id) { - JSONObject rows = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "3").addParam("point_id", id).process().uniqueResult(0); + public SchBasePointDto findStorageById(Map id) { + JSONObject rows = WQL.getWO("COCKPIT_STORAGE").addParam("flag", "3").addParam("point_id", id.get("id")).process().uniqueResult(0); if(ObjectUtil.isNotEmpty(rows)) { SchBasePointDto res = rows.toJavaObject(SchBasePointDto.class); getStandingStatus(res); @@ -192,7 +207,7 @@ public class CockpitServiceImpl implements CockpitService{ r.setDevice_url("ylj"); //设备运行状态 if(StringUtils.isNotEmpty(r.getPoint_status())) { - r.setPoint_status(PointStatusEnum.getName(r.getPoint_status())); + r.setPoint_status_name(PointStatusEnum.getName(r.getPoint_status())); } }); return res; @@ -207,8 +222,8 @@ public class CockpitServiceImpl implements CockpitService{ * @since 2023/3/1 */ @Override - public DeviceDetailDto findDeviceById(String id) { - JSONObject rows = WQL.getWO("COCKPIT_DEVICE").addParam("flag", "2").addParam("point_id", id).process().uniqueResult(0); + public DeviceDetailDto findDeviceById(Map id) { + JSONObject rows = WQL.getWO("COCKPIT_DEVICE").addParam("flag", "2").addParam("point_id", id.get("id")).process().uniqueResult(0); if(ObjectUtil.isNotEmpty(rows)) { DeviceDetailDto deviceDetailDto = rows.toJavaObject(DeviceDetailDto.class); //Todo 点击设备弹窗临时演示数据,后面需要根据业务逻辑查询 @@ -283,6 +298,26 @@ public class CockpitServiceImpl implements CockpitService{ return hashMap; } + /** + * 处理工序字段 + */ + private void getProcedureName(List result, Integer type) { + if(type == 1) { + result.forEach(r -> { + if(StringUtils.isNotEmpty(r.getLabel())) { + r.setWorkorder_procedure(r.getLabel().substring(0, 2)); + } + }); + } + 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 1b29670..4d366c4 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 @@ -85,11 +85,14 @@ IF 输入.flag = "3" PAGEQUERY SELECT - workorder.workorder_procedure, + workorder.workorder_procedure, + any_value(dict.label) label, SUM( plan_qty ) plan_qty, SUM( real_qty ) real_qty FROM PDM_BD_WORKORDER workorder + LEFT JOIN sys_dict_detail dict ON dict.`VALUE` = workorder.workorder_procedure + AND dict.dict_id = 112 WHERE workorder.is_delete = '0' GROUP BY