Browse Source

add 自动更新工单生产数量

master
张江玮 1 year ago
parent
commit
00bbc04eaf
  1. 80
      lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoUpdateWorkOrder.java
  2. 36
      lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/wql/MANAGE_QUERY.wql
  3. 13
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java
  4. 13
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java
  5. 2
      lms/nladmin-system/src/main/resources/config/application.yml
  6. 10
      lms/nladmin-ui/src/views/wms/basedata/material/index.vue

80
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<Object> 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);
}
}
}

36
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

13
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"));
}
}
}

13
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"));
}
}
}

2
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:

10
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'
}
}
}
}
}

Loading…
Cancel
Save