汪菘 2 years ago
parent
commit
2005b73564
  1. 27
      lms/nladmin-system/src/main/java/org/nl/wms/common/PickType.java
  2. 52
      lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/rest/AcsToWmsController.java
  3. 45
      lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  4. 2
      lms/nladmin-system/src/main/java/org/nl/wms/sch/manage/AutoCreateTask.java
  5. 10
      lms/nladmin-system/src/main/java/org/nl/wms/sch/rest/TaskController.java
  6. 3
      lms/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/TaskServiceImpl.java
  7. 4
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/YZCallEmptyTask.java
  8. 2
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/wql/CALL_EMPTY_TASK.wql
  9. 1
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/FJCallMaterialTask.java
  10. 1
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/material/SZCallMaterialTask.java
  11. 3
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java
  12. 17
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/wql/SEND_EMPTY_TASK.wql
  13. 2
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/SZSendMaterialTask.java
  14. 14
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java
  15. 14
      lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java

27
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;
}
}

52
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,16 +61,62 @@ public class AcsToWmsController {
@ApiOperation("申请任务")
@SaIgnore
public ResponseEntity<Object> apply(@RequestBody JSONObject whereJson) {
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")
@Log("ACS机械手给WMS发送任务")
@ApiOperation("ACS机械手给WMS发送任务")
@SaIgnore
public ResponseEntity<Object> manipulatorApply(@RequestBody JSONObject whereJson) {
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")
@Log("入窑口反向组盘")

45
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,19 +185,11 @@ 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) {
String task_code;
JSONObject point = param.getJSONObject("point");
if (ObjectUtil.isEmpty(point)) {
point = WQLObject
@ -242,11 +232,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
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:
@ -283,8 +268,22 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
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:
@ -310,11 +309,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
.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:
@ -327,15 +321,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
default:
throw new BadRequestException("未知任务类型!");
}
}
} catch (InterruptedException e) {
log.error("lock fail!", e);
} finally {
if (try_lock) {
lock.unlock();
}
}
JSONObject result = new JSONObject();
result.put("message", "申请任务成功,任务编码 [" + task_code + "]");
result.put("status", HttpStatus.OK.value());

2
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<AcsTaskDTO> taskList = null;

10
lms/nladmin-system/src/main/java/org/nl/wms/sch/rest/TaskController.java

@ -45,17 +45,17 @@ public class TaskController {
public ResponseEntity<Object> 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);
}

3
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());
}
}

4
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(
"压制区叫空",

2
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

1
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);

1
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);

3
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"),

17
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

2
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"),

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

14
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;
}
}

Loading…
Cancel
Save