From 00bbc04eaf9bf3eed1e6ed0d74f46b8529131787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B1=9F=E7=8E=AE?= Date: Tue, 4 Jul 2023 14:51:42 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=94=9F=E4=BA=A7=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/sch/manage/AutoUpdateWorkOrder.java | 80 +++++++++++++++++++ .../nl/wms/sch/manage/wql/MANAGE_QUERY.wql | 36 +++++++++ .../send/material/FJSendMaterialTask.java | 13 --- .../send/material/YZSendMaterialTask.java | 13 --- .../src/main/resources/config/application.yml | 2 +- .../src/views/wms/basedata/material/index.vue | 10 +++ 6 files changed, 127 insertions(+), 27 deletions(-) create mode 100644 lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateWorkOrder.java diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateWorkOrder.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateWorkOrder.java new file mode 100644 index 0000000..f9a61c5 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateWorkOrder.java @@ -0,0 +1,80 @@ +package org.nl.wms.sch.manage; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.ext.acs.service.WmsToAcsService; +import org.nl.wms.sch.task.util.TaskUtils; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author zhangjiangwei + * @date 2023/07/04 09:56 + */ +@Slf4j +@RequiredArgsConstructor +@Component("autoUpdateWorkOrder") +public class AutoUpdateWorkOrder { + + private final WmsToAcsService wmsToAcsService; + + @SneakyThrows + public void run() { + JSONArray workOrders = WQL.getWO("MANAGE_QUERY").addParam("flag", "4").process().getResultJSONArray(0); + + if (ObjectUtil.isNotEmpty(workOrders)) { + List list = workOrders.stream().map(o -> { + JSONObject workOrder = (JSONObject) o; + JSONObject newData = new JSONObject(); + newData.put("workorder_id", workOrder.getString("workorder_id")); + newData.put("region_code", workOrder.getString("region_code")); + newData.put("device_code", workOrder.getString("device_code")); + return (Object) newData; + }).collect(Collectors.toList()); + JSONObject result = wmsToAcsService.getDeviceStatus(new JSONArray(list)); + WQLObject workOrderTable = WQLObject.getWQLObject("pdm_bd_workorder"); + + if ("200".equals(result.getString("status"))) { + JSONArray data = result.getJSONArray("data"); + + if (ObjectUtil.isNotEmpty(data)) { + JSONArray yzData = new JSONArray(data.stream().filter(o -> Region.YZ.value().equals(((JSONObject) o).getString("region_code"))).collect(Collectors.toList())); + JSONObject yzWorkOrderUpdate = new JSONObject(); + TaskUtils.addAutoUpdateColum(yzWorkOrderUpdate); + for (int i = 0; i < yzData.size(); i++) { + JSONObject newData = yzData.getJSONObject(i); + yzWorkOrderUpdate.put("real_qty", newData.getString("reql_qty")); + yzWorkOrderUpdate.put("qualified_qty", newData.getString("qualified")); + yzWorkOrderUpdate.put("unqualified_qty", newData.getString("unqualified")); + workOrderTable.update(yzWorkOrderUpdate, "workorder_id = " + newData.getString("workorder_id")); + } + + JSONArray fjData = new JSONArray(data.stream().filter(o -> Region.FJ.value().equals(((JSONObject) o).getString("region_code"))).collect(Collectors.toList())); + JSONObject fjWorkOrderUpdate = new JSONObject(); + TaskUtils.addAutoUpdateColum(fjWorkOrderUpdate); + for (int i = 0; i < fjData.size(); i++) { + JSONObject newData = fjData.getJSONObject(i); + yzWorkOrderUpdate.put("real_qty", newData.getString("reql_qty")); + workOrderTable.update(yzWorkOrderUpdate, "workorder_id = " + newData.getString("workorder_id")); + } + } + } + } + + JSONArray yield = WQL.getWO("MANAGE_QUERY").addParam("flag", "5").process().getResultJSONArray(0); + WQLObject materialTable = WQLObject.getWQLObject("md_me_materialbase"); + for (int i = 0; i < yield.size(); i++) { + JSONObject deviceYield = yield.getJSONObject(i); + deviceYield.put("surplus_aux_qty", Math.max(deviceYield.getIntValue("aux_qty") - deviceYield.getIntValue("current_aux_qty"), 0)); + materialTable.update(deviceYield); + } + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql index 2e574ff..89ec9f7 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql @@ -84,4 +84,40 @@ AND vd.stand_status > '2' ENDSELECT ENDQUERY + ENDIF + + IF 输入.flag = "4" + QUERY + SELECT + workorder.*, + device.region_code + FROM + pdm_bd_workorder workorder + LEFT JOIN pdm_bi_device device ON workorder.device_id = device.device_id + WHERE + workorder.is_delete = '0' + AND workorder.order_status = '3' + AND device.region_code IN ('YZ', 'FJ') + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "5" + QUERY + SELECT + workorder.material_id, + mb.aux_qty, + SUM(workorder.qualified_qty) AS current_aux_qty + FROM + pdm_bd_workorder workorder + LEFT JOIN pdm_bi_device device ON workorder.device_id = device.device_id + LEFT JOIN md_me_materialbase mb ON workorder.material_id = mb.material_id + WHERE + workorder.is_delete = '0' + AND workorder.order_status = '5' + AND device.region_code = 'YZ' + GROUP BY + workorder.material_id + ENDSELECT + ENDQUERY ENDIF \ No newline at end of file diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java index 0427665..0e035e7 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java @@ -324,19 +324,6 @@ public class FJSendMaterialTask extends AbstractAcsTask { param.add(info); wmsToAcsService.writeVehicle(param); } - - JSONObject workorder = WQL - .getWO("SEND_MATERIAL_TASK") - .addParam("flag", "7") - .addParam("vd_id", task.getString("group_id")) - .process() - .uniqueResult(0); - - JSONObject workorder_update = new JSONObject(); - workorder_update.put("real_qty", workorder.getIntValue("real_qty") + workorder.getIntValue("qty")); - workorder_update.put("qualified_qty", workorder.getIntValue("qualified_qty") + workorder.getIntValue("qty")); - TaskUtils.addACSUpdateColum(workorder_update); - WQLObject.getWQLObject("pdm_bd_workorder").update(workorder_update, "workorder_id = " + workorder.getString("workorder_id")); } } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java index 8b0a66e..305121e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java @@ -231,19 +231,6 @@ public class YZSendMaterialTask extends AbstractAcsTask { } point_table.update(point2, "point_code = '" + point_code2 + "'"); } - - JSONObject workorder = WQL - .getWO("SEND_MATERIAL_TASK") - .addParam("flag", "7") - .addParam("vd_id", task.getString("group_id")) - .process() - .uniqueResult(0); - - JSONObject workorder_update = new JSONObject(); - workorder_update.put("real_qty", workorder.getIntValue("real_qty") + workorder.getIntValue("qty")); - workorder_update.put("qualified_qty", workorder.getIntValue("qualified_qty") + workorder.getIntValue("qty")); - TaskUtils.addACSUpdateColum(workorder_update); - WQLObject.getWQLObject("pdm_bd_workorder").update(workorder_update, "workorder_id = " + workorder.getString("workorder_id")); } } } diff --git a/lms/nladmin-system/src/main/resources/config/application.yml b/lms/nladmin-system/src/main/resources/config/application.yml index 942ceff..6f01423 100644 --- a/lms/nladmin-system/src/main/resources/config/application.yml +++ b/lms/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: prod + active: dev jackson: time-zone: GMT+8 data: diff --git a/lms/nladmin-ui/src/views/wms/basedata/material/index.vue b/lms/nladmin-ui/src/views/wms/basedata/material/index.vue index 3b105e6..d7f65de 100644 --- a/lms/nladmin-ui/src/views/wms/basedata/material/index.vue +++ b/lms/nladmin-ui/src/views/wms/basedata/material/index.vue @@ -181,6 +181,7 @@ ref="table" v-loading="crud.loading" :data="crud.data" + :cell-style="cellStyle" size="mini" style="width: 100%;" @selection-change="crud.selectionChangeHandler" @@ -418,6 +419,15 @@ export default { }, 100) }) } + }, + cellStyle({ row, column }) { + if (column.property === 'surplus_aux_qty') { + const auxQty = row.aux_qty + const surplusAuxQty = row.surplus_aux_qty + if (surplusAuxQty <= auxQty * 0.1) { + return 'background: red' + } + } } } }