fix: 修复大屏

This commit is contained in:
2023-04-26 12:09:42 +08:00
parent 523462ddd1
commit 1d66c65d7e
5 changed files with 72 additions and 29 deletions

View File

@@ -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;

View File

@@ -66,4 +66,5 @@ public class WorkorderDto implements Serializable{
* 开始时间
*/
private String realproducestart_date;
private String realproduceend_date;
}

View File

@@ -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<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);
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);
@@ -313,24 +320,51 @@ public class CockpitServiceImpl implements CockpitService{
return hashMap;
}
/**
* 处理空白数据设置默认值
*/
private void setResultComplete(List<ProductionStatisticsDto> result) {
HashSet<String> existingLabels = new HashSet<>(); // 创建一个 HashSet 对象
// 遍历 result 列表中的每个 ProductionStatisticsDto 对象
for (ProductionStatisticsDto dto : result) {
// 检查 label 字段是否存在于 existingLabels 集合中
if (!existingLabels.contains(dto.getLabel())) {
// 将缺少的标签值添加到 existingLabels 集合中
existingLabels.add(dto.getLabel());
}
}
// 检查 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<ProductionStatisticsDto> result, Integer 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()));
}
});
}
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()));
// }
// });
// }
}
/**

View File

@@ -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

View File

@@ -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