Browse Source

fix: 修复大屏

master
李永德 2 years ago
parent
commit
1d66c65d7e
  1. 3
      lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java
  2. 1
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/dto/WorkorderDto.java
  3. 78
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java
  4. 11
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql
  5. 6
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_STORAGE.wql

3
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 * @since 2023-03-01
*/ */
public enum ProductionStatisticsEnum{ public enum ProductionStatisticsEnum{
RAW_MATERIAL("原料", "1"),
/** /**
* 今日压制量 * 今日压制量
*/ */
@ -17,7 +18,7 @@ public enum ProductionStatisticsEnum{
/** /**
* 今日成品量 * 今日成品量
*/ */
FINISHED("成品", "4"); FINISHED("包装", "4");
private String name; private String name;
private String index; private String index;

1
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 realproducestart_date;
private String realproduceend_date;
} }

78
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.nl.wms.sch.manage.PointEnum;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -57,7 +55,6 @@ public class CockpitServiceImpl implements CockpitService{
if(ObjectUtil.isNotEmpty(result)) { if(ObjectUtil.isNotEmpty(result)) {
res = result.toJavaList(WorkorderDto.class); res = result.toJavaList(WorkorderDto.class);
// res.forEach(r -> { // res.forEach(r -> {
// todo: 未根据实际,可以不需要客户
// r.setCust_name("新余钢铁"); // r.setCust_name("新余钢铁");
// if(StringUtils.isNotEmpty(r.getLabel())) { // if(StringUtils.isNotEmpty(r.getLabel())) {
// r.setLabel(r.getLabel().substring(0, 2)); // r.setLabel(r.getLabel().substring(0, 2));
@ -77,7 +74,17 @@ public class CockpitServiceImpl implements CockpitService{
*/ */
// 2、获取原料计划完成情况 // 2、获取原料计划完成情况
CompletableFuture<JSONArray> materialTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "5").process().getResultJSONArray(0), pool); CompletableFuture<JSONArray> 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); log.error("获取原料计划完成情况: {}", e.getMessage(), e);
map.put("materialTask", ""); map.put("materialTask", "");
return null; return null;
@ -90,10 +97,10 @@ public class CockpitServiceImpl implements CockpitService{
if(ObjectUtil.isNotEmpty(result)) { if(ObjectUtil.isNotEmpty(result)) {
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集 //成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集
planRes = result.toJavaList(ProductionStatisticsDto.class); planRes = result.toJavaList(ProductionStatisticsDto.class);
// getProcedureName(planRes, 1); setResultComplete(planRes);
//今日压制量,干燥量,成品量 //今日压制量,干燥量,成品量
finishedRes = result.toJavaList(ProductionStatisticsDto.class); finishedRes = result.toJavaList(ProductionStatisticsDto.class);
// getProcedureName(finishedRes, 2); setResultComplete(finishedRes);
} }
map.put("planRes", planRes); map.put("planRes", planRes);
map.put("finishedRes", finishedRes); map.put("finishedRes", finishedRes);
@ -314,25 +321,52 @@ public class CockpitServiceImpl implements CockpitService{
} }
/** /**
* 处理工序字段 * 处理空白数据设置默认值
*/ */
private void getProcedureName(List<ProductionStatisticsDto> result, Integer type) { private void setResultComplete(List<ProductionStatisticsDto> result) {
if(type == 1) { HashSet<String> existingLabels = new HashSet<>(); // 创建一个 HashSet 对象
result.forEach(r -> { // 遍历 result 列表中的每个 ProductionStatisticsDto 对象
if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { for (ProductionStatisticsDto dto : result) {
r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); // 检查 label 字段是否存在于 existingLabels 集合中
} if (!existingLabels.contains(dto.getLabel())) {
}); // 将缺少的标签值添加到 existingLabels 集合中
existingLabels.add(dto.getLabel());
}
} }
else{ // 检查 1、2、3、4 标签值是否全部存在,如果有缺失则创建新的 ProductionStatisticsDto 对象并添加到 result 列表中
result.forEach(r -> { for (int i = 1; i <= 4; i++) {
if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { // 处理字段 if (!existingLabels.contains(i+"")) {
r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); 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<ProductionStatisticsDto> 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()));
// }
// });
// }
}
/** /**
* 判断静置状态 * 判断静置状态
*/ */

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

@ -50,7 +50,14 @@
dicts.label order_status_name, dicts.label order_status_name,
material.material_code, material.material_code,
device.device_name, 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 FROM
PDM_BD_WORKORDER workorder PDM_BD_WORKORDER workorder
LEFT JOIN md_me_materialbase material ON material.material_id = workorder.material_id LEFT JOIN md_me_materialbase material ON material.material_id = workorder.material_id
@ -60,7 +67,7 @@
WHERE WHERE
workorder.is_delete = '0' workorder.is_delete = '0'
ORDER BY ORDER BY
workorder.create_time DESC workorder.order_status ASC, workorder.create_time DESC
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF

6
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_STORAGE.wql

@ -63,7 +63,7 @@
WHERE WHERE
point.region_code = 'KLHJ' point.region_code = 'KLHJ'
ORDER BY ORDER BY
point.point_code DESC point.point_code ASC
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF
@ -93,7 +93,7 @@
WHERE WHERE
point.region_code = 'BCPHJ' point.region_code = 'BCPHJ'
ORDER BY ORDER BY
point.create_time DESC point.point_code ASC
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF
@ -114,7 +114,7 @@
point.point_id = 输入.point_id point.point_id = 输入.point_id
ENDOPTION ENDOPTION
ORDER BY ORDER BY
point.create_time DESC point.point_code ASC
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF

Loading…
Cancel
Save