Browse Source

fix: 生产统计大屏

master
李永德 2 years ago
parent
commit
6be529ed29
  1. 6
      lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java
  2. 33
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java
  3. 137
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PRODUCTION.wql

6
lms/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/ProductionStatisticsEnum.java

@ -9,15 +9,15 @@ public enum ProductionStatisticsEnum{
/** /**
* 今日压制量 * 今日压制量
*/ */
CRUSH("今日压制", "2"), CRUSH("压制", "2"),
/** /**
* 今日干燥量 * 今日干燥量
*/ */
DRY("今日干燥", "3"), DRY("干燥", "3"),
/** /**
* 今日成品量 * 今日成品量
*/ */
FINISHED("今日成品", "4"); FINISHED("成品", "4");
private String name; private String name;
private String index; private String index;

33
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/CockpitServiceImpl.java

@ -56,14 +56,14 @@ public class CockpitServiceImpl implements CockpitService{
JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0); JSONArray result = WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "1").process().getResultJSONArray(0);
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: 未根据实际,可以不需要客户 // 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));
r.setShift_type(r.getLabel().substring(0, 2) + "白班"); // r.setShift_type(r.getLabel().substring(0, 2) + "白班");
} // }
}); // });
} }
return res; return res;
}, pool); }, pool);
@ -72,25 +72,28 @@ public class CockpitServiceImpl implements CockpitService{
map.put("productionTask", ""); map.put("productionTask", "");
return null; return null;
}); });
/**
* 为了不破坏原来的输出形式会有冗余数据的输出
*/
// 2、获取原料计划完成情况 // 2、获取原料计划完成情况
CompletableFuture<JSONArray> materialTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "2").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) -> 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;
}); });
// 3、获取成品计划完成情况,今日压制量,干燥量,成品量 // 3、获取成品计划完成情况,今日压制量,干燥量,成品量
CompletableFuture<JSONArray> finishedTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "3").process().getResultJSONArray(0), pool); CompletableFuture<JSONArray> finishedTask = CompletableFuture.supplyAsync(() -> WQL.getWO("COCKPIT_PRODUCTION").addParam("flag", "4").process().getResultJSONArray(0), pool);
finishedTask.thenAccept((result) -> { finishedTask.thenAccept((result) -> {
List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>(); List<ProductionStatisticsDto> planRes = new CopyOnWriteArrayList<>();
List<ProductionStatisticsDto> finishedRes = new CopyOnWriteArrayList<>(); List<ProductionStatisticsDto> finishedRes = new CopyOnWriteArrayList<>();
if(ObjectUtil.isNotEmpty(result)) { if(ObjectUtil.isNotEmpty(result)) {
//成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用 //成品计划完成情况,应前端要求分开两个一样的数据结果,简化调用数据采集
planRes = result.toJavaList(ProductionStatisticsDto.class); planRes = result.toJavaList(ProductionStatisticsDto.class);
getProcedureName(planRes, 1); // getProcedureName(planRes, 1);
//今日压制量,干燥量,成品量 //今日压制量,干燥量,成品量
finishedRes = result.toJavaList(ProductionStatisticsDto.class); finishedRes = result.toJavaList(ProductionStatisticsDto.class);
getProcedureName(finishedRes, 2); // getProcedureName(finishedRes, 2);
} }
map.put("planRes", planRes); map.put("planRes", planRes);
map.put("finishedRes", finishedRes); map.put("finishedRes", finishedRes);
@ -319,14 +322,14 @@ public class CockpitServiceImpl implements CockpitService{
private void getProcedureName(List<ProductionStatisticsDto> result, Integer type) { private void getProcedureName(List<ProductionStatisticsDto> result, Integer type) {
if(type == 1) { if(type == 1) {
result.forEach(r -> { result.forEach(r -> {
if(StringUtils.isNotEmpty(r.getLabel())) { if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) {
r.setWorkorder_procedure(r.getLabel().substring(0, 2)); r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure()));
} }
}); });
} }
else{ else{
result.forEach(r -> { result.forEach(r -> {
if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { if(StringUtils.isNotEmpty(r.getWorkorder_procedure())) { // 处理字段
r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure())); r.setWorkorder_procedure(ProductionStatisticsEnum.getName(r.getWorkorder_procedure()));
} }
}); });

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

@ -47,7 +47,6 @@
IF 输入.flag = "1" IF 输入.flag = "1"
PAGEQUERY PAGEQUERY
SELECT SELECT
dict.label,
dicts.label order_status, dicts.label order_status,
material.material_code, material.material_code,
device.device_name, device.device_name,
@ -56,8 +55,6 @@
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
LEFT JOIN pdm_bi_device device ON workorder.device_id = device.device_id LEFT JOIN pdm_bi_device device ON workorder.device_id = device.device_id
LEFT JOIN sys_dict_detail dict ON dict.`VALUE` = workorder.workorder_procedure
AND dict.dict_id = 112
LEFT JOIN sys_dict_detail dicts ON dicts.`VALUE` = workorder.order_status LEFT JOIN sys_dict_detail dicts ON dicts.`VALUE` = workorder.order_status
AND dicts.dict_id = 90 AND dicts.dict_id = 90
WHERE WHERE
@ -71,33 +68,125 @@
IF 输入.flag = "2" IF 输入.flag = "2"
PAGEQUERY PAGEQUERY
SELECT SELECT
SUM( plan_qty ) plan_qty, IF(LENGTH(SUM(plan_qty)) > 0, SUM( plan_qty ), '0') plan_qty,
SUM( real_qty ) real_qty IF(LENGTH(SUM(real_qty)) > 0, SUM( real_qty ), '0') real_qty
FROM FROM
PDM_BD_WORKORDER workorder PDM_BD_WORKORDER workorder
WHERE WHERE
workorder.is_delete = '0' workorder.is_delete = '0'
ENDSELECT AND workorder.device_code IN (
SELECT device.device_code FROM pdm_bi_device device WHERE device.region_code = 'HL'
)
ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF
IF 输入.flag = "3" IF 输入.flag = "3"
PAGEQUERY PAGEQUERY
SELECT SELECT
workorder.workorder_procedure, d.region_code AS workorder_procedure,
any_value(dict.label) label, SUM( plan_qty ) plan_qty,
SUM( plan_qty ) plan_qty, SUM( real_qty ) real_qty
SUM( real_qty ) real_qty FROM
PDM_BD_WORKORDER workorder
LEFT JOIN pdm_bi_device d ON d.device_code = workorder.device_code
WHERE
workorder.is_delete = '0'
GROUP BY
d.region_code
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "4"
PAGEQUERY
SELECT
CASE t1.pick_type
WHEN '1' THEN '原料'
WHEN '2' THEN '压制'
WHEN '3' THEN '干燥'
WHEN '4' THEN '包装'
ELSE null
END AS workorder_procedure,
t1.pick_type AS label,
IF(LENGTH(t1.real_qty) > 0, t1.real_qty, '0') real_qty,
IF(LENGTH(t2.plan_qty) > 0, t2.plan_qty, '0') plan_qty
FROM FROM
PDM_BD_WORKORDER workorder (
LEFT JOIN sys_dict_detail dict ON dict.`VALUE` = workorder.workorder_procedure SELECT
AND dict.dict_id = 112 das.pick_type,
WHERE SUM( das.real_qty ) AS real_qty
workorder.is_delete = '0' FROM
GROUP BY `das_produce_number` das
workorder.workorder_procedure WHERE
ENDSELECT DATE( das.create_time ) = CURDATE()
ENDPAGEQUERY GROUP BY
ENDIF das.pick_type
) AS t1
JOIN (
SELECT
qtys.pick_type,
SUM( qtys.plan_qty ) AS plan_qty
FROM
(
SELECT
das.pick_type,
( SELECT SUM( wo.plan_qty ) FROM pdm_bd_workorder wo WHERE das.workorder_id = wo.workorder_id ) AS plan_qty
FROM
`das_produce_number` das
WHERE
DATE( das.create_time ) = CURDATE()) AS qtys
GROUP BY
qtys.pick_type
) AS t2 ON t1.pick_type = t2.pick_type
ORDER BY t1.pick_type
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "5"
PAGEQUERY
SELECT
CASE t1.pick_type
WHEN '1' THEN '原料'
WHEN '2' THEN '压制'
WHEN '3' THEN '干燥'
WHEN '4' THEN '包装'
ELSE null
END AS workorder_procedure,
t1.pick_type AS label,
IF(LENGTH(t1.real_qty) > 0, t1.real_qty, '0') real_qty,
IF(LENGTH(t2.plan_qty) > 0, t2.plan_qty, '0') plan_qty
FROM
(
SELECT
das.pick_type,
SUM( das.real_qty ) AS real_qty
FROM
`das_produce_number` das
WHERE
DATE( das.create_time ) = CURDATE()
GROUP BY
das.pick_type
) AS t1
JOIN (
SELECT
qtys.pick_type,
SUM( qtys.plan_qty ) AS plan_qty
FROM
(
SELECT
das.pick_type,
( SELECT SUM( wo.plan_qty ) FROM pdm_bd_workorder wo WHERE das.workorder_id = wo.workorder_id ) AS plan_qty
FROM
`das_produce_number` das
WHERE
DATE( das.create_time ) = CURDATE()) AS qtys
GROUP BY
qtys.pick_type
) AS t2 ON t1.pick_type = t2.pick_type
WHERE t1.pick_type = '1'
ORDER BY t1.pick_type
ENDSELECT
ENDPAGEQUERY
ENDIF

Loading…
Cancel
Save