rev:出入库异常任务
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
package org.nl.b_lms.sch.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.AcsTaskDto;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 二期异常移库任务类
|
||||
* Created by Lxy on 2024/1/19.
|
||||
*/
|
||||
public class TwoExcepionalMoveTask extends AbstractAcsTask {
|
||||
|
||||
/**
|
||||
* 处理类
|
||||
*/
|
||||
private final String THIS_CLASS = TwoExcepionalMoveTask.class.getName();
|
||||
|
||||
@Override
|
||||
public List<AcsTaskDto> addTask() {
|
||||
/*
|
||||
* 下发给ACS时需要特殊处理
|
||||
*/
|
||||
JSONArray arr = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0'").getResultJSONArray(0);
|
||||
|
||||
ArrayList<AcsTaskDto> resultList = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
|
||||
char dtl_type = json.getString("task_type").charAt(json.getString("task_type").length() - 1);
|
||||
AcsTaskDto dto = AcsTaskDto.builder()
|
||||
.ext_task_id(json.getString("task_id"))
|
||||
.task_code(json.getString("task_code"))
|
||||
.task_type(json.getString("acs_task_type"))
|
||||
.start_device_code(json.getString("point_code1"))
|
||||
.next_device_code(json.getString("point_code2"))
|
||||
.vehicle_code(json.getString("vehicle_code"))
|
||||
.priority(json.getString("priority"))
|
||||
.class_type(json.getString("task_type"))
|
||||
.dtl_type(String.valueOf(dtl_type))
|
||||
.remark(json.getString("remark"))
|
||||
.build();
|
||||
resultList.add(dto);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject taskObj, String status) {
|
||||
|
||||
// 仓位表
|
||||
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
|
||||
// 任务表
|
||||
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
||||
|
||||
JSONObject jsonTask = taskTab.query("task_id = '" + taskObj.getString("task_id") + "'").uniqueResult(0);
|
||||
|
||||
// 更新任务的参数
|
||||
JSONObject map = new JSONObject();
|
||||
|
||||
/*
|
||||
* 1-执行中, 2-完成 ,0-acs取消
|
||||
*/
|
||||
// 执行中
|
||||
if (status.equals(TaskStatusEnum.EXECUTING.getCode())) {
|
||||
|
||||
map.put("task_status", TaskStatusEnum.EXECUTING.getCode());
|
||||
}
|
||||
|
||||
// 完成
|
||||
if (status.equals(TaskStatusEnum.FINISHED.getCode())) {
|
||||
|
||||
map.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
|
||||
// 更新起点仓位
|
||||
JSONObject jsonAttr = attrTab.query("struct_code = '" + jsonTask.getString("point_code1") + "'").uniqueResult(0);
|
||||
jsonAttr.put("lock_type",IOSEnum.LOCK_TYPE.code("未锁定"));
|
||||
jsonAttr.put("storagevehicle_code","");
|
||||
attrTab.update(jsonAttr);
|
||||
|
||||
// 更新终点仓位
|
||||
JSONObject jsonAttr1 = attrTab.query("struct_code = '" + jsonTask.getString("point_code2") + "'").uniqueResult(0);
|
||||
jsonAttr1.put("lock_type",IOSEnum.LOCK_TYPE.code("其它"));
|
||||
attrTab.update(jsonAttr1);
|
||||
}
|
||||
|
||||
// 取消
|
||||
if (status.equals(IOSEnum.IS_NOTANDYES.code("否"))) {
|
||||
|
||||
if (taskObj.getIntValue("task_status") > Integer.valueOf(TaskStatusEnum.ISSUE.getCode())) {
|
||||
throw new BadRequestException("任务已执行不能取消");
|
||||
}
|
||||
|
||||
// 更新任务表删除字段
|
||||
map.put("is_delete", IOSEnum.IS_NOTANDYES.code("是"));
|
||||
|
||||
// 解锁起点仓位
|
||||
JSONObject jsonAttr = attrTab.query("struct_code = '" + jsonTask.getString("point_code1") + "'").uniqueResult(0);
|
||||
jsonAttr.put("lock_type",IOSEnum.LOCK_TYPE.code("未锁定"));
|
||||
attrTab.update(jsonAttr);
|
||||
|
||||
// 解锁终点仓位
|
||||
JSONObject jsonAttr1 = attrTab.query("struct_code = '" + jsonTask.getString("point_code2") + "'").uniqueResult(0);
|
||||
jsonAttr1.put("lock_type",IOSEnum.LOCK_TYPE.code("未锁定"));
|
||||
attrTab.update(jsonAttr1);
|
||||
}
|
||||
|
||||
map.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
map.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
map.put("update_time", DateUtil.now());
|
||||
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + taskObj.getString("task_id") + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findStartPoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findNextPoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTask(JSONObject form) {
|
||||
|
||||
if (StrUtil.isBlank(form.getString("task_type"))) {
|
||||
throw new BadRequestException("业务类型不能为空!");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(form.getString("start_device_code"))) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(form.getString("next_device_code"))) {
|
||||
throw new BadRequestException("终点不能为空!");
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
json.put("task_code", IdUtil.getSnowflake(1, 1).nextId());
|
||||
json.put("task_type", form.getString("task_type"));
|
||||
json.put("vehicle_code", form.getString("vehicle_code"));
|
||||
json.put("vehicle_type", form.getString("vehicle_type"));
|
||||
json.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
json.put("task_group_id", form.getLongValue("task_group_id"));
|
||||
json.put("point_code1", form.getString("start_device_code"));
|
||||
json.put("point_code2", form.getString("next_device_code"));
|
||||
json.put("handle_class", this.getClass().getName());
|
||||
json.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
json.put("create_name", SecurityUtils.getCurrentUsername());
|
||||
json.put("create_time", DateUtil.now());
|
||||
json.put("priority", "1");
|
||||
json.put("acs_task_type", "7");
|
||||
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(json);
|
||||
return json.getString("task_id");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void forceFinish(String task_id) {
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
this.updateTaskStatus(taskObj, IOSEnum.ACS_RESULT.code("取消"));
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
||||
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
||||
import org.nl.b_lms.sch.tasks.TwoExcepionalMoveTask;
|
||||
import org.nl.b_lms.sch.tasks.TwoMoveBoxTask;
|
||||
import org.nl.b_lms.sch.tasks.TwoOutBoxTask;
|
||||
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService;
|
||||
@@ -162,6 +163,49 @@ public class OutBoxManageServiceImpl implements OutBoxManageService {
|
||||
return jsonAttrNow.getString("struct_code");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void taskExceptionalOut(JSONObject jsonObject) {
|
||||
// 任务表
|
||||
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
||||
// 仓位表
|
||||
WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||
|
||||
JSONObject jsonTask = taskTab.query("task_code = '" + jsonObject.getString("task_code") + "'").uniqueResult(0);
|
||||
|
||||
// 找出对应的浅货位
|
||||
JSONObject jsonAttrOrder = attrTab.query("struct_code = '" + jsonTask.getString("point_code1") + "'").uniqueResult(0);
|
||||
|
||||
JSONObject jsonAttrNow = attrTab.query("row_num = '" + jsonAttrOrder.getString("row_num") + "' AND layer_num = '" + jsonAttrOrder.getString("layer_num") + "' AND col_num = '" + jsonAttrOrder.getString("col_num") + "' and zdepth = '" + IOSEnum.ZDEPTH_STRUCT.code("浅") + "' and stor_id = '"+jsonAttrOrder.getString("stor_id")+"'")
|
||||
.uniqueResult(0);
|
||||
|
||||
// 查询移入货位
|
||||
JSONObject jsonAttrMove = attrTab.query("sect_id = '" + jsonAttrOrder.getString("sect_id") + "' and struct_id <> '" + jsonAttrNow.getString("struct_id") + "' and lock_type = '" + IOSEnum.LOCK_TYPE.code("未锁定") + "' and IFNULL(storagevehicle_code,'') = '' AND is_used = '1' AND is_delete = '0' order by zdepth DESC")
|
||||
.uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonAttrMove)) {
|
||||
throw new BadRequestException("仓库不足!");
|
||||
}
|
||||
|
||||
// 锁住仓位
|
||||
jsonAttrNow.put("lock_type", IOSEnum.LOCK_TYPE.code("其它"));
|
||||
attrTab.update(jsonAttrNow);
|
||||
|
||||
jsonAttrMove.put("lock_type", IOSEnum.LOCK_TYPE.code("其它"));
|
||||
attrTab.update(jsonAttrMove);
|
||||
|
||||
// 生成任务
|
||||
JSONObject taskParam = new JSONObject();
|
||||
taskParam.put("start_device_code", jsonAttrNow.getString("struct_code"));
|
||||
taskParam.put("next_device_code", jsonAttrMove.getString("struct_code"));
|
||||
taskParam.put("task_type", "010712");
|
||||
|
||||
TwoExcepionalMoveTask taskBean = new TwoExcepionalMoveTask();
|
||||
taskBean.createTask(taskParam);
|
||||
taskBean.immediateNotifyAcs(null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 找一个空木箱
|
||||
* @param whereJson {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
||||
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
||||
import org.nl.b_lms.sch.tasks.TwoExcepionalMoveTask;
|
||||
import org.nl.b_lms.sch.tasks.TwoInEmpTask;
|
||||
import org.nl.b_lms.sch.tasks.TwoOutEmpTask;
|
||||
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||
@@ -148,6 +149,48 @@ public class OutVehicleManageServiceImpl implements OutVehicleManageService {
|
||||
return jsonAttrNow.getString("struct_code");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void taskExceptionalOut(JSONObject jsonObject) {
|
||||
// 任务表
|
||||
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
||||
// 仓位表
|
||||
WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||
|
||||
JSONObject jsonTask = taskTab.query("task_code = '" + jsonObject.getString("task_code") + "'").uniqueResult(0);
|
||||
|
||||
// 找出对应的浅货位
|
||||
JSONObject jsonAttrOrder = attrTab.query("struct_code = '" + jsonTask.getString("point_code1") + "'").uniqueResult(0);
|
||||
|
||||
JSONObject jsonAttrNow = attrTab.query("row_num = '" + jsonAttrOrder.getString("row_num") + "' AND layer_num = '" + jsonAttrOrder.getString("layer_num") + "' AND col_num = '" + jsonAttrOrder.getString("col_num") + "' and zdepth = '" + IOSEnum.ZDEPTH_STRUCT.code("浅") + "' and stor_id = '"+jsonAttrOrder.getString("stor_id")+"'")
|
||||
.uniqueResult(0);
|
||||
|
||||
// 查询移入货位
|
||||
JSONObject jsonAttrMove = attrTab.query("sect_id = '" + jsonAttrOrder.getString("sect_id") + "' and struct_id <> '" + jsonAttrNow.getString("struct_id") + "' and lock_type = '" + IOSEnum.LOCK_TYPE.code("未锁定") + "' and IFNULL(storagevehicle_code,'') = '' AND is_used = '1' AND is_delete = '0' order by zdepth DESC")
|
||||
.uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonAttrMove)) {
|
||||
throw new BadRequestException("仓库不足!");
|
||||
}
|
||||
|
||||
// 锁住仓位
|
||||
jsonAttrMove.put("lock_type", IOSEnum.LOCK_TYPE.code("其它"));
|
||||
attrTab.update(jsonAttrMove);
|
||||
|
||||
jsonAttrNow.put("lock_type", IOSEnum.LOCK_TYPE.code("其它"));
|
||||
attrTab.update(jsonAttrNow);
|
||||
|
||||
// 生成任务
|
||||
JSONObject taskParam = new JSONObject();
|
||||
taskParam.put("start_device_code", jsonAttrNow.getString("struct_code"));
|
||||
taskParam.put("next_device_code", jsonAttrMove.getString("struct_code"));
|
||||
taskParam.put("task_type", "010712");
|
||||
|
||||
TwoExcepionalMoveTask taskBean = new TwoExcepionalMoveTask();
|
||||
taskBean.createTask(taskParam);
|
||||
taskBean.immediateNotifyAcs(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找一个空托盘(空托盘区)
|
||||
* @param whereJson {
|
||||
|
||||
@@ -26,7 +26,7 @@ public interface OutBoxManageService {
|
||||
|
||||
|
||||
/**
|
||||
* 任务异常处理(1.空出 2.浅货位有货-取货时)
|
||||
* 任务异常处理(1.空出 )
|
||||
* @param jsonObject {
|
||||
* task_code : 任务编码
|
||||
* }
|
||||
@@ -34,4 +34,12 @@ public interface OutBoxManageService {
|
||||
*/
|
||||
String taskExceptional(JSONObject jsonObject);
|
||||
|
||||
/**
|
||||
* 任务异常处理(2.浅货位有货-取货时)
|
||||
* @param jsonObject {
|
||||
* task_code : 任务编码
|
||||
* }
|
||||
*/
|
||||
void taskExceptionalOut(JSONObject jsonObject);
|
||||
|
||||
}
|
||||
|
||||
@@ -30,4 +30,12 @@ public interface OutVehicleManageService {
|
||||
*/
|
||||
String taskExceptional(JSONObject jsonObject);
|
||||
|
||||
/**
|
||||
* 任务异常处理(2.浅货位有货-取货时)
|
||||
* @param jsonObject {
|
||||
* task_code : 任务编码
|
||||
* }
|
||||
*/
|
||||
void taskExceptionalOut(JSONObject jsonObject);
|
||||
|
||||
}
|
||||
|
||||
@@ -1997,9 +1997,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
} else if (taskDao.getTask_type().equals(TASKEnum.BOX_TYPE.code("木箱出库"))) {
|
||||
// 木箱出库:空出、浅货位有货-取货时
|
||||
if (type.equals("2") || type.equals("3")) {
|
||||
if (type.equals("2")) {
|
||||
point_code = outBoxManageService.taskExceptional(whereJson);
|
||||
}
|
||||
if (type.equals("3")) {
|
||||
outBoxManageService.taskExceptionalOut(whereJson);
|
||||
}
|
||||
} else if (taskDao.getTask_type().equals(TASKEnum.VEHICLE_TYPE.code("托盘入库"))) {
|
||||
// 托盘入库:满入、浅货位有货-放货时
|
||||
if (type.equals("1") || type.equals("4")) {
|
||||
@@ -2007,9 +2010,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
} else if (taskDao.getTask_type().equals(TASKEnum.VEHICLE_TYPE.code("托盘出库"))) {
|
||||
// 托盘出库:空出、浅货位有货-取货时
|
||||
if (type.equals("2") || type.equals("3")) {
|
||||
if (type.equals("2")) {
|
||||
point_code = outVehicleManageService.taskExceptional(whereJson);
|
||||
}
|
||||
if (type.equals("3")) {
|
||||
outVehicleManageService.taskExceptionalOut(whereJson);
|
||||
}
|
||||
} else if (taskDao.getTask_type().equals(TASKEnum.PROUD_TYPE.code("成品入库"))) {
|
||||
// 成品入库:满入、浅货位有货-放货时
|
||||
if (type.equals("1") || type.equals("4")) {
|
||||
@@ -2017,7 +2023,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(point_code)) {
|
||||
if (!type.equals("3") && ObjectUtil.isEmpty(point_code)) {
|
||||
throw new BadRequestException("点位为空!");
|
||||
}
|
||||
|
||||
|
||||
@@ -382,6 +382,7 @@ public class CheckOutBillController {
|
||||
|
||||
@PostMapping("/testOutEmp")
|
||||
@Log("空载具出库测试")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> testOutEmp(@RequestBody JSONObject whereJson) {
|
||||
new OutVehicleManageServiceImpl().outVehicle(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
@@ -397,6 +398,7 @@ public class CheckOutBillController {
|
||||
|
||||
@PostMapping("/testOutBox")
|
||||
@Log("木箱出库测试")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> testOutBox(@RequestBody JSONObject whereJson) {
|
||||
new OutBoxManageServiceImpl().outBox(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
Reference in New Issue
Block a user