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

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

@ -47,7 +47,6 @@
IF 输入.flag = "1"
PAGEQUERY
SELECT
dict.label,
dicts.label order_status,
material.material_code,
device.device_name,
@ -56,8 +55,6 @@
PDM_BD_WORKORDER workorder
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 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
AND dicts.dict_id = 90
WHERE
@ -71,12 +68,15 @@
IF 输入.flag = "2"
PAGEQUERY
SELECT
SUM( plan_qty ) plan_qty,
SUM( real_qty ) real_qty
IF(LENGTH(SUM(plan_qty)) > 0, SUM( plan_qty ), '0') plan_qty,
IF(LENGTH(SUM(real_qty)) > 0, SUM( real_qty ), '0') real_qty
FROM
PDM_BD_WORKORDER workorder
WHERE
workorder.is_delete = '0'
AND workorder.device_code IN (
SELECT device.device_code FROM pdm_bi_device device WHERE device.region_code = 'HL'
)
ENDSELECT
ENDPAGEQUERY
ENDIF
@ -84,20 +84,109 @@
IF 输入.flag = "3"
PAGEQUERY
SELECT
workorder.workorder_procedure,
any_value(dict.label) label,
d.region_code AS workorder_procedure,
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
LEFT JOIN pdm_bi_device d ON d.device_code = workorder.device_code
WHERE
workorder.is_delete = '0'
GROUP BY
workorder.workorder_procedure
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
(
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
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