From 54fcd4c3164c6971d079f6605bbacaa53e968a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B1=9F=E7=8E=AE?= Date: Thu, 27 Apr 2023 17:24:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/nl/wms/common/PickType.java | 27 ++ .../wms/ext/acs/rest/AcsToWmsController.java | 56 +++- .../acs/service/impl/AcsToWmsServiceImpl.java | 257 +++++++++--------- .../org/nl/wms/sch/manage/AutoCreateTask.java | 2 +- .../org/nl/wms/sch/rest/TaskController.java | 10 +- .../wms/sch/service/impl/TaskServiceImpl.java | 3 +- .../sch/task/call/empty/YZCallEmptyTask.java | 4 - .../task/call/empty/wql/CALL_EMPTY_TASK.wql | 2 +- .../call/material/FJCallMaterialTask.java | 1 - .../call/material/SZCallMaterialTask.java | 1 - .../sch/task/send/empty/FJSendEmptyTask.java | 3 +- .../task/send/empty/wql/SEND_EMPTY_TASK.wql | 17 +- .../send/material/SZSendMaterialTask.java | 2 +- .../send/material/YZSendMaterialTask.java | 14 +- .../org/nl/wms/sch/task/util/TaskUtils.java | 14 +- 15 files changed, 244 insertions(+), 169 deletions(-) create mode 100644 lms/nladmin-system/src/main/java/org/nl/wms/common/PickType.java diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/common/PickType.java b/lms/nladmin-system/src/main/java/org/nl/wms/common/PickType.java new file mode 100644 index 0000000..4f4d794 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/common/PickType.java @@ -0,0 +1,27 @@ +package org.nl.wms.common; + +import lombok.RequiredArgsConstructor; + +/** + * @author zhangjiangwei + * @date 2023/04/25 15:29 + */ +@RequiredArgsConstructor +public enum PickType { + + YL("原料", "1"), + YZ("压制", "2"), + GZ("干燥", "3"), + CP("成品", "4"); + + private final String label; + private final String value; + + public String label() { + return this.label; + } + + public String value() { + return this.value; + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java index d515fbd..7839f30 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java @@ -4,14 +4,19 @@ package org.nl.wms.ext.acs.rest; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaIgnore; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.logging.annotation.Log; +import org.nl.modules.wql.util.SpringContextHolder; import org.nl.wms.ext.acs.service.AcsToWmsService; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; @@ -20,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Map; +import java.util.concurrent.TimeUnit; /** * @author ludj @@ -55,7 +61,30 @@ public class AcsToWmsController { @ApiOperation("申请任务") @SaIgnore public ResponseEntity apply(@RequestBody JSONObject whereJson) { - return new ResponseEntity<>(acsToWmsService.apply(whereJson), HttpStatus.OK); + String point_code = whereJson.getString("device_code"); + if (StrUtil.isBlank(point_code)) { + throw new BadRequestException("点位不能为空!"); + } + + RLock lock = SpringContextHolder.getBean(RedissonClient.class).getFairLock(point_code); + boolean try_lock = false; + try { + try_lock = lock.tryLock(5, TimeUnit.SECONDS); + if (try_lock) { + return new ResponseEntity<>(acsToWmsService.apply(whereJson), HttpStatus.OK); + } + } catch (InterruptedException e) { + throw new BadRequestException(e.getMessage()); + } finally { + if (try_lock) { + lock.unlock(); + } + } + + JSONObject result = new JSONObject(); + result.put("message", "申请任务失败!"); + result.put("status", HttpStatus.BAD_REQUEST.value()); + return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST); } @PostMapping("/manipulatorApply") @@ -63,7 +92,30 @@ public class AcsToWmsController { @ApiOperation("ACS机械手给WMS发送任务") @SaIgnore public ResponseEntity manipulatorApply(@RequestBody JSONObject whereJson) { - return new ResponseEntity<>(acsToWmsService.manipulatorApply(whereJson), HttpStatus.OK); + String point_code = whereJson.getString("device_code"); + if (StrUtil.isBlank(point_code)) { + throw new BadRequestException("点位不能为空!"); + } + + RLock lock = SpringContextHolder.getBean(RedissonClient.class).getFairLock(point_code); + boolean try_lock = false; + try { + try_lock = lock.tryLock(5, TimeUnit.SECONDS); + if (try_lock) { + return new ResponseEntity<>(acsToWmsService.manipulatorApply(whereJson), HttpStatus.OK); + } + } catch (InterruptedException e) { + throw new BadRequestException(e.getMessage()); + } finally { + if (try_lock) { + lock.unlock(); + } + } + + JSONObject result = new JSONObject(); + result.put("message", "申请任务失败!"); + result.put("status", HttpStatus.BAD_REQUEST.value()); + return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST); } @PostMapping("/reverseGroup") diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index c48ee46..3d2ef51 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -44,8 +44,6 @@ import java.util.concurrent.TimeUnit; @Slf4j public class AcsToWmsServiceImpl implements AcsToWmsService { - private final RedissonClient redissonClient; - private final HLCallEmptyTask hlCallEmptyTask; private final HLSendMaterialTask hlSendMaterialTask; @@ -187,155 +185,142 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { @Transactional(rollbackFor = Exception.class) public JSONObject apply(JSONObject param) { String point_code = param.getString("device_code"); - if (StrUtil.isBlank(point_code)) { - throw new BadRequestException("点位不能为空!"); - } String type = param.getString("type"); if (StrUtil.isBlank(type)) { throw new BadRequestException("任务类型不能为空!"); } - RLock lock = redissonClient.getFairLock("acs_to_wms:" + point_code); - boolean try_lock = false; - String task_code = null; - try { - try_lock = lock.tryLock(5, TimeUnit.SECONDS); - if (try_lock) { - JSONObject point = param.getJSONObject("point"); - if (ObjectUtil.isEmpty(point)) { - point = WQLObject - .getWQLObject("sch_base_point") - .query("is_used = '1' AND point_code = '" + point_code + "'") - .uniqueResult(0); - if (ObjectUtil.isEmpty(point)) { - throw new BadRequestException("[" + point_code + "] 已删除或未启用!"); - } - } - TaskUtils.isLocked(point); - - Region region = Region.get(point.getString("region_code")); + String task_code; + JSONObject point = param.getJSONObject("point"); + if (ObjectUtil.isEmpty(point)) { + point = WQLObject + .getWQLObject("sch_base_point") + .query("is_used = '1' AND point_code = '" + point_code + "'") + .uniqueResult(0); + if (ObjectUtil.isEmpty(point)) { + throw new BadRequestException("[" + point_code + "] 已删除或未启用!"); + } + } + TaskUtils.isLocked(point); - JSONObject method_param = new JSONObject(); - method_param.put("point", point); - method_param.put("create_mode", CreateMode.ACSSQ.value()); - String request_param = param.getString("request_param"); - if (StrUtil.isBlank(request_param)) { - request_param = param.toJSONString(); + Region region = Region.get(point.getString("region_code")); + + JSONObject method_param = new JSONObject(); + method_param.put("point", point); + method_param.put("create_mode", CreateMode.ACSSQ.value()); + String request_param = param.getString("request_param"); + if (StrUtil.isBlank(request_param)) { + request_param = param.toJSONString(); + } + method_param.put("request_param", request_param); + method_param.put("create_id", ACSSystem.id); + method_param.put("create_name", ACSSystem.nick_name); + switch (type) { + case "1": + // 送料 + String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code")); + if ("0000".equals(vehicle_code)) { + throw new BadRequestException("载具编码不能为空!"); } - method_param.put("request_param", request_param); - method_param.put("create_id", ACSSystem.id); - method_param.put("create_name", ACSSystem.nick_name); - switch (type) { - case "1": - // 送料 - String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code")); - if ("0000".equals(vehicle_code)) { - throw new BadRequestException("载具编码不能为空!"); - } - method_param.put("vehicle_code", vehicle_code); - - switch (region) { - case HL: - JSONObject workorder = TaskUtils.hasWorkOrder(point); - method_param.put("workorder", workorder); - task_code = hlSendMaterialTask.createTask(method_param); - break; - case YZ: - method_param.put("workorder", param.getJSONObject("workorder")); - method_param.put("vd", param.getJSONObject("vd")); - JSONObject device = WQLObject - .getWQLObject("pdm_bi_device") - .query("device_code = '" + point.getString("device_code") + "'") - .uniqueResult(0); - method_param.put("device", device); - task_code = yzSendMaterialTask.createTask(method_param); - break; - case SZ: - WQLObject vd_table = WQLObject.getWQLObject("st_ivt_vehicle_detail"); - JSONObject vd = vd_table - .query("is_delete = '0' AND vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'") - .uniqueResult(0); - if (ObjectUtil.isEmpty(vd)) { - throw new BadRequestException("未找到 [" + vehicle_code + "] 的组盘信息!"); - } - vd.put("is_fire", "1"); - vd.put("is_in_kiln", "0"); - vd_table.update(vd); - method_param.put("vd", vd); - - task_code = szSendMaterialTask.createTask(method_param); - break; - default: - throw new BadRequestException("[" + region.label() + "] 不能发起送料任务!"); - } - break; - case "2": - // 叫料 + method_param.put("vehicle_code", vehicle_code); + + switch (region) { + case HL: JSONObject workorder = TaskUtils.hasWorkOrder(point); method_param.put("workorder", workorder); - - switch (region) { - case FJ: - task_code = fjCallMaterialTask.createTask(method_param); - break; - default: - throw new BadRequestException("[" + region.label() + "] 不能发起叫料任务!"); - } + task_code = hlSendMaterialTask.createTask(method_param); break; - case "3": - // 送空 - switch (region) { - case FJ: - task_code = fjSendEmptyTask.createTask(method_param); - break; - default: - throw new BadRequestException("[" + region.label() + "] 不能发起送空任务!"); - } + case YZ: + method_param.put("workorder", param.getJSONObject("workorder")); + method_param.put("vd", param.getJSONObject("vd")); + task_code = yzSendMaterialTask.createTask(method_param); break; - case "4": - // 叫空 - switch (region) { - case HL: - String device_code = point.getString("device_code"); - JSONObject work_order = WQLObject - .getWQLObject("pdm_bd_workorder") - .query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") - .uniqueResult(0); - method_param.put("workorder", work_order); - task_code = hlCallEmptyTask.createTask(method_param); - break; - case YZ: - device_code = point.getString("device_code"); - work_order = WQLObject - .getWQLObject("pdm_bd_workorder") - .query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") - .uniqueResult(0); - method_param.put("workorder", work_order); - JSONObject device = WQLObject - .getWQLObject("pdm_bi_device") - .query("device_code = '" + device_code + "'") - .uniqueResult(0); - method_param.put("device", device); - task_code = yzCallEmptyTask.createTask(method_param); - break; - case GTK: - task_code = gtkCallEmptyTask.createTask(method_param); - break; - default: - throw new BadRequestException("[" + region.label() + "] 不能发起叫空任务!"); + case SZ: + WQLObject vd_table = WQLObject.getWQLObject("st_ivt_vehicle_detail"); + JSONObject vd = vd_table + .query("is_delete = '0' AND vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'") + .uniqueResult(0); + if (ObjectUtil.isEmpty(vd)) { + throw new BadRequestException("未找到 [" + vehicle_code + "] 的组盘信息!"); } + vd.put("is_fire", "1"); + vd.put("is_in_kiln", "0"); + vd_table.update(vd); + method_param.put("vd", vd); + + task_code = szSendMaterialTask.createTask(method_param); break; default: - throw new BadRequestException("未知任务类型!"); + throw new BadRequestException("[" + region.label() + "] 不能发起送料任务!"); } - } - } catch (InterruptedException e) { - log.error("lock fail!", e); - } finally { - if (try_lock) { - lock.unlock(); - } - } + break; + case "2": + // 叫料 + JSONObject workorder = TaskUtils.hasWorkOrder(point); + method_param.put("workorder", workorder); + switch (region) { + case FJ: + task_code = fjCallMaterialTask.createTask(method_param); + break; + default: + throw new BadRequestException("[" + region.label() + "] 不能发起叫料任务!"); + } + break; + case "3": + // 送空 + vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code")); + if ("0000".equals(vehicle_code)) { + vehicle_code = point.getString("vehicle_code"); + if (StrUtil.isBlank(vehicle_code) || "0000".equals(vehicle_code)) { + throw new BadRequestException("未知载具编码!"); + } + } + method_param.put("vehicle_code", vehicle_code); + + switch (region) { + case FJ: + JSONObject vd_update = new JSONObject(); + vd_update.put("is_delete", TrueOrFalse.TRUE.value()); + WQLObject + .getWQLObject("st_ivt_vehicle_detail") + .update(vd_update, "vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'"); + task_code = fjSendEmptyTask.createTask(method_param); + break; + default: + throw new BadRequestException("[" + region.label() + "] 不能发起送空任务!"); + } + break; + case "4": + // 叫空 + switch (region) { + case HL: + String device_code = point.getString("device_code"); + JSONObject work_order = WQLObject + .getWQLObject("pdm_bd_workorder") + .query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") + .uniqueResult(0); + method_param.put("workorder", work_order); + task_code = hlCallEmptyTask.createTask(method_param); + break; + case YZ: + device_code = point.getString("device_code"); + work_order = WQLObject + .getWQLObject("pdm_bd_workorder") + .query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") + .uniqueResult(0); + method_param.put("workorder", work_order); + task_code = yzCallEmptyTask.createTask(method_param); + break; + case GTK: + task_code = gtkCallEmptyTask.createTask(method_param); + break; + default: + throw new BadRequestException("[" + region.label() + "] 不能发起叫空任务!"); + } + break; + default: + throw new BadRequestException("未知任务类型!"); + } JSONObject result = new JSONObject(); result.put("message", "申请任务成功,任务编码 [" + task_code + "]"); result.put("status", HttpStatus.OK.value()); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoCreateTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoCreateTask.java index bebf85a..489df89 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoCreateTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoCreateTask.java @@ -21,7 +21,7 @@ import java.util.List; import java.util.Set; @Slf4j -@Component +@Component("autoCreateTask") public class AutoCreateTask { // 下发acs的任务集合 private List taskList = null; diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/rest/TaskController.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/rest/TaskController.java index fd6d20a..41b5623 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/rest/TaskController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/rest/TaskController.java @@ -45,17 +45,17 @@ public class TaskController { public ResponseEntity getTaskStatus() { TaskStatus[] values = TaskStatus.values(); JSONArray arr = new JSONArray(); + //增加未完成状态 + JSONObject unFinish = new JSONObject(); + unFinish.put("code", "-1"); + unFinish.put("name", "未完成"); + arr.add(unFinish); for (TaskStatus value : values) { JSONObject json = new JSONObject(); json.put("code", value.value()); json.put("name", value.label()); arr.add(json); } - //增加未完成状态 - JSONObject unFinish = new JSONObject(); - unFinish.put("code", "-1"); - unFinish.put("name", "未完成"); - arr.add(unFinish); return new ResponseEntity<>(arr, HttpStatus.OK); } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/TaskServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/TaskServiceImpl.java index 3897074..2a3075b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/TaskServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/TaskServiceImpl.java @@ -125,7 +125,6 @@ public class TaskServiceImpl implements TaskService { param.put("remark", json.getString("message")); wo.update(param); } - throw new BadRequestException("任务操作失败!"); } else { JSONObject param = new JSONObject(); param.put("task_id", task_id); @@ -134,7 +133,7 @@ public class TaskServiceImpl implements TaskService { } } catch (Exception e) { e.printStackTrace(); - throw new BadRequestException("任务操作失败!"); + throw new BadRequestException(e.getMessage()); } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/YZCallEmptyTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/YZCallEmptyTask.java index 4dce321..f22cfa0 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/YZCallEmptyTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/YZCallEmptyTask.java @@ -44,10 +44,6 @@ public class YZCallEmptyTask extends AbstractAcsTask { if (ObjectUtil.isNotEmpty(work_order)) { priority = TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1; } - JSONObject device = form.getJSONObject("device"); - if (ObjectUtil.isNotEmpty(device) && "4".equals(device.getString("device_model"))) { - ++priority; - } JSONObject task = TaskUtils.buildTask( "压制区叫空", diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/wql/CALL_EMPTY_TASK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/wql/CALL_EMPTY_TASK.wql index 44fb294..faab788 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/wql/CALL_EMPTY_TASK.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/wql/CALL_EMPTY_TASK.wql @@ -77,7 +77,7 @@ IF 输入.flag = "3" QUERY SELECT - * + point.* FROM sch_base_point point LEFT JOIN sch_base_task task ON point.point_code = task.point_code1 diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/FJCallMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/FJCallMaterialTask.java index fccf4c4..7ec5a9e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/FJCallMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/FJCallMaterialTask.java @@ -91,7 +91,6 @@ public class FJCallMaterialTask extends AbstractAcsTask { task.put("task_status", TaskStatus.START_AND_END.value()); task.put("point_code1", point.getString("point_code")); task.put("vehicle_code", TaskUtils.formatVehicleCode(point.getString("vehicle_code"))); - task.put("group_id", point.getString("vd_id")); task.put("remark", ""); TaskUtils.addAutoUpdateColum(task); task_table.update(task); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/SZCallMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/SZCallMaterialTask.java index e7f2caf..6188cb9 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/SZCallMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/SZCallMaterialTask.java @@ -107,7 +107,6 @@ public class SZCallMaterialTask extends AbstractAcsTask { task.put("point_code1", point.getString("point_code")); task.put("material_id", point.getString("material_id")); task.put("vehicle_code", TaskUtils.formatVehicleCode(point.getString("vehicle_code"))); - task.put("group_id", point.getString("vd_id")); task.put("remark", ""); TaskUtils.addAutoUpdateColum(task); task_table.update(task); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java index 84e2522..e07e3b1 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java @@ -38,7 +38,6 @@ public class FJSendEmptyTask extends AbstractAcsTask { @Override public String createTask(JSONObject form) { JSONObject point = form.getJSONObject("point"); - String vehicle_code = point.getString("vehicle_code"); JSONObject task = TaskUtils.buildTask( "分拣区送空", @@ -49,7 +48,7 @@ public class FJSendEmptyTask extends AbstractAcsTask { null, null, VehicleType.STEEL_TRAY.value(), - vehicle_code, + form.getString("vehicle_code"), 1, FJSendEmptyTask.class.getName(), form.getString("create_mode"), diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql index 580a08b..8ce7492 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql @@ -40,15 +40,18 @@ IF 输入.flag = "1" QUERY SELECT - * + point.* FROM - sch_base_point + sch_base_point point + LEFT JOIN sch_base_task task ON point.point_code = task.point_code2 + AND task.task_status <> '7' + AND task_status <> '8' WHERE - is_used = '1' - AND lock_type = '1' - AND region_code = 'GTK' - AND point_type = '1' - AND point_status = '0' + point.is_used = '1' + AND point.lock_type = '1' + AND point.region_code = 'GTK' + AND point.point_type = '1' + AND task.task_id IS NULL ENDSELECT ENDQUERY ENDIF diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/SZSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/SZSendMaterialTask.java index 5aa5be6..05d2d9b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/SZSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/SZSendMaterialTask.java @@ -45,7 +45,7 @@ public class SZSendMaterialTask extends AbstractAcsTask { TaskStatus.SURE_START.value(), point.getString("point_code"), null, - vd.getString("vd_id"), + null, vd.getString("material_id"), vd.getString("vehicle_type"), vd.getString("vehicle_code"), 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 672a4a9..22cbc04 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 @@ -1,5 +1,7 @@ package org.nl.wms.sch.task.send.material; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -8,6 +10,7 @@ import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.wql.WQL; import org.nl.modules.wql.core.bean.WQLObject; import org.nl.wms.basedata.eum.TrueOrFalse; +import org.nl.wms.common.PickType; import org.nl.wms.sch.manage.*; import org.nl.wms.sch.task.util.TaskUtils; import org.springframework.stereotype.Component; @@ -40,19 +43,18 @@ public class YZSendMaterialTask extends AbstractAcsTask { JSONObject point = form.getJSONObject("point"); JSONObject work_order = form.getJSONObject("workorder"); int priority = TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1; - JSONObject device = form.getJSONObject("device"); - if (ObjectUtil.isNotEmpty(device) && "4".equals(device.getString("device_model"))) { - ++priority; - } JSONObject vd = form.getJSONObject("vd"); + JSONObject pn = TaskUtils.buildPN(PickType.YZ, vd.getLongValue("qty"), vd.getLongValue("workorder_id")); + WQLObject.getWQLObject("das_produce_number").insert(pn); + JSONObject task = TaskUtils.buildTask( "压制区送料", TaskType.SEND_MATERIAL.value(), TaskStatus.SURE_START.value(), point.getString("point_code"), null, - vd.getString("vd_id"), + pn.getLongValue("data_id"), vd.getString("material_id"), vd.getString("vehicle_type"), vd.getString("vehicle_code"), @@ -163,6 +165,8 @@ public class YZSendMaterialTask extends AbstractAcsTask { TaskUtils.addCurrentUpdateColum(point2); } point_table.update(point2, "point_code = '" + task.getString("point_code2") + "'"); + + WQLObject.getWQLObject("das_produce_number").delete("data_id = " + task.getLongValue("group_id")); } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java index ea73fdb..17c92af 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java @@ -9,6 +9,7 @@ import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.utils.SecurityUtils; import org.nl.modules.system.util.CodeUtil; import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.common.PickType; import org.nl.wms.sch.manage.ACSSystem; import org.nl.wms.sch.manage.AutoCreate; import org.nl.wms.sch.manage.LockType; @@ -53,7 +54,7 @@ public class TaskUtils { String task_status, String point_code1, String point_code2, - String group_id, + Long group_id, String material_id, String vehicle_type, String vehicle_code, @@ -72,6 +73,7 @@ public class TaskUtils { task.put("task_status", task_status); task.put("point_code1", point_code1); task.put("point_code2", point_code2); + task.put("group_id", group_id); task.put("material_id", material_id); task.put("vehicle_type", vehicle_type); task.put("vehicle_code", vehicle_code); @@ -125,4 +127,14 @@ public class TaskUtils { row.put("update_optname", form.getString("create_name")); row.put("update_time", DateUtil.now()); } + + public static JSONObject buildPN(PickType pickType, long real_qty, long workorder_id) { + JSONObject pn = new JSONObject(); + pn.put("data_id", IdUtil.getSnowflake(1L, 1L).nextId()); + pn.put("pick_type", pickType.value()); + pn.put("real_qty", real_qty); + pn.put("workorder_id", workorder_id); + pn.put("create_time", DateUtil.now()); + return pn; + } }