Browse Source

修改大屏接口

1.大屏接口应前端习惯修改接口方式为post;
2.修改生产统计,增加枚举处理完成量及工序中文描述;
3.增加返回code和描述信息,增加常用异常状态码以便排查;
4.修改所有返回枚举类型的增加中文描述;
5.按页面区域切分一 一返回数组对象,以便前端直接绑值 。
master
龚宝雄 2 years ago
parent
commit
fbef8c3342
  1. 14
      lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/PointStatusEnum.java
  2. 58
      lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java
  3. 7
      lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RequestMethodEnum.java
  4. 27
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/rest/CockpitController.java
  5. 4
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/CockpitService.java
  6. 9
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/DeviceStatusDto.java
  7. 10
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/ProductionStatisticsDto.java
  8. 77
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java
  9. 3
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql

14
lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/PointStatusEnum.java

@ -7,17 +7,21 @@ 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;

58
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;
}
}

7
lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RequestMethodEnum.java

@ -27,37 +27,30 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum RequestMethodEnum{
/**
* 搜寻 @AnonymousGetMapping
*/
GET("GET"),
/**
* 搜寻 @AnonymousPostMapping
*/
POST("POST"),
/**
* 搜寻 @AnonymousPutMapping
*/
PUT("PUT"),
/**
* 搜寻 @AnonymousPatchMapping
*/
PATCH("PATCH"),
/**
* 搜寻 @AnonymousDeleteMapping
*/
DELETE("DELETE"),
/**
* 否则就是所有 Request 接口都放行
*/
ALL("All");
/**
* Request 类型
*/

27
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<Object> productionStatistics() {
@ -42,7 +45,7 @@ public class CockpitController{
/**
* 仓储监控
*/
@GetMapping("/storageMonitor")
@PostMapping("/storageMonitor")
@Log("仓储监控")
@ApiOperation("仓储监控")
public CommonResult<Object> storageMonitor() {
@ -52,13 +55,13 @@ public class CockpitController{
/**
* 根据点位id获取仓储信息
*/
@GetMapping("/findStorageById/{id}")
@PostMapping("/findStorageById")
@Log("根据点位id获取仓储信息")
@ApiOperation("根据点位id获取仓储信息")
public CommonResult<SchBasePointDto> findStorageById(@PathVariable String id) {
public CommonResult<SchBasePointDto> findStorageById(@RequestBody Map<String,String> 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<List<DeviceStatusDto>> deviceMonitor() {
@ -77,13 +80,13 @@ public class CockpitController{
/**
* 根据点位id获取设备信息
*/
@GetMapping("/findDeviceById/{id}")
@PostMapping("/findDeviceById")
@Log("根据点位id获取设备信息")
@ApiOperation("根据点位id获取设备信息")
public CommonResult<DeviceDetailDto> findDeviceById(@PathVariable String id) {
public CommonResult<DeviceDetailDto> findDeviceById(@RequestBody Map<String,String> 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<Object> workshopCondition() {

4
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<String,String> id);
/**
* 设备监控
@ -50,7 +50,7 @@ public interface CockpitService{
* @param id 点位id
* @return 返回结果集
*/
DeviceDetailDto findDeviceById(String id);
DeviceDetailDto findDeviceById(Map<String,String> id);
/**
* 車间情况

9
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;
}

10
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;
/**
* 计划生产数量
*/

77
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<String,Object> productionStatistics() {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll();
ConcurrentHashMap<String,Object> map = new ConcurrentHashMap<>(3);
// 1、获取生产任务列表
// 1、获取生产任务列表
CompletableFuture<List<WorkorderDto>> productionTask = CompletableFuture.supplyAsync(() -> {
List<WorkorderDto> 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<List<ProductionStatisticsDto>> finishedTask = CompletableFuture.supplyAsync(() -> {
List<ProductionStatisticsDto> res = new CopyOnWriteArrayList<>();
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "3").process().getResultJSONArray(0);
CompletableFuture<JSONArray> finishedTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "3").process().getResultJSONArray(0), pool);
finishedTask.thenAccept((result) -> {
List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>();
List<ProductionStatisticsDto> 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<Void> 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<Void> 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<String,String> 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<String,String> 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<ProductionStatisticsDto> 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()));
}
});
}
}
/**
* 判断静置状态
*/

3
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql

@ -86,10 +86,13 @@
PAGEQUERY
SELECT
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

Loading…
Cancel
Save