add: 新增刻字机送料、叫载具,包装机叫料、送载具
This commit is contained in:
@@ -34,7 +34,7 @@ import java.util.Map;
|
||||
@Api(tags = "acs接收wms")
|
||||
@RequestMapping("/api/acsToWms/task")
|
||||
@Slf4j
|
||||
|
||||
@SaIgnore
|
||||
public class AcsToWmsController {
|
||||
private final AcsToWmsService acsToWmsService;
|
||||
private final SpeMachineryTask speMachineryTask;
|
||||
|
||||
@@ -20,6 +20,10 @@ import org.nl.wms.pda.service.CacheLineHandService;
|
||||
import org.nl.wms.sch.service.TaskService;
|
||||
import org.nl.wms.sch.service.dto.TaskDto;
|
||||
import org.nl.wms.sch.tasks.SpeMachineryTask;
|
||||
import org.nl.wms.sch.tasks.callEmpty.PlotterCallEmptyTask;
|
||||
import org.nl.wms.sch.tasks.callMaterial.WrapCallMaterialTask;
|
||||
import org.nl.wms.sch.tasks.sendEmpty.WrapSendEmptyTask;
|
||||
import org.nl.wms.sch.tasks.sendMaterial.PlotterSendMaterialTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -43,6 +47,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
@Autowired
|
||||
private CacheLineHandService cacheLineHandService;
|
||||
private final SpeMachineryTask speMachineryTask;
|
||||
private final PlotterSendMaterialTask plotterSendMaterialTask;
|
||||
private final PlotterCallEmptyTask plotterCallEmptyTask;
|
||||
private final WrapCallMaterialTask wrapCallMaterialTask;
|
||||
private final WrapSendEmptyTask wrapSendEmptyTask;
|
||||
@Override
|
||||
public Map<String, Object> apply(JSONObject param) {
|
||||
Map result = MapOf.of("status", HttpStatus.OK.value(), "message", "ACS向WMS申请任务成功!");
|
||||
@@ -55,6 +63,18 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
case REQUEST_CALLTYPE_FULL: case REQUEST_CALLTYPE_EMP:
|
||||
speMachineryTask.createTask(param);
|
||||
break;
|
||||
case REQUEST_PLOTTER_SEND_FULL:
|
||||
plotterSendMaterialTask.createTask(param);
|
||||
break;
|
||||
case REQUEST_PLOTTER_CALL_EMP:
|
||||
plotterCallEmptyTask.createTask(param);
|
||||
break;
|
||||
case REQUEST_WARP_CALL_FULL:
|
||||
wrapCallMaterialTask.createTask(param);
|
||||
break;
|
||||
case REQUEST_WARP_SEND_EMP:
|
||||
wrapSendEmptyTask.createTask(param);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -112,7 +132,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService{
|
||||
TaskDto taskDto = taskService.findById(task_id);
|
||||
String processing_class = taskDto.getHandle_class();
|
||||
//1:执行中,2:完成 ,3:acs取消
|
||||
String acs_task_status = row.getString("status");
|
||||
String acs_task_status = row.getString("task_status");
|
||||
String message = "";
|
||||
String status = "";
|
||||
if ("1".equals(acs_task_status)) {
|
||||
|
||||
@@ -66,10 +66,10 @@ public class PointServiceImpl implements PointService {
|
||||
String point_status = object.getString("point_status");
|
||||
String point_type = object.getString("point_type");
|
||||
RegionDto regionDto = regionService.findByCode(region_code);
|
||||
String point_status_explain = regionDto.getPoint_status_explain();
|
||||
String point_type_explain = regionDto.getPoint_type_explain();
|
||||
String point_status_explain = ObjectUtil.isNotEmpty(regionDto.getPoint_status_explain())?regionDto.getPoint_status_explain():null;
|
||||
String point_type_explain = ObjectUtil.isNotEmpty(regionDto.getPoint_type_explain())?regionDto.getPoint_type_explain():null;
|
||||
// 获取点位状态名称
|
||||
if (!ObjectUtil.isEmpty(point_status)) {
|
||||
if (ObjectUtil.isNotEmpty(point_status)) {
|
||||
JSONObject statusArr = new JSONObject();
|
||||
String[] split = point_status_explain.split(",");
|
||||
for ( int j = 0; j < split.length; j++) {
|
||||
@@ -79,7 +79,7 @@ public class PointServiceImpl implements PointService {
|
||||
object.put("point_status_name", statusArr.getString(point_status));
|
||||
}
|
||||
// 获取点位类型
|
||||
if (!ObjectUtil.isEmpty(point_type)) {
|
||||
if (ObjectUtil.isNotEmpty(point_type)) {
|
||||
JSONObject typeArr = new JSONObject();
|
||||
String[] split = point_type_explain.split(",");
|
||||
for ( int j = 0; j < split.length; j++) {
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
package org.nl.wms.sch.tasks.callEmpty;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.AcsUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 刻字机呼叫空框
|
||||
* @Date: 2023/4/3
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PlotterCallEmptyTask extends AbstractAcsTask {
|
||||
private static final String OPT_NAME = "刻字机#";
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject task, String status) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject taskObj = taskTab.query("task_id = '" + task.getString("task_id") + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_FINISH.getCode() + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_CANNEL.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("任务已完成,不可取消!");
|
||||
}
|
||||
String pointCode1 = taskObj.getString("point_code1");
|
||||
JSONObject pointObj = null;
|
||||
if (ObjectUtil.isNotEmpty(pointCode1)) {
|
||||
pointObj = pointTab.query("point_code = '" + pointCode1 + "'").uniqueResult(0);
|
||||
}
|
||||
if (status.equals(AcsTaskEnum.STATUS_START.getCode())) {
|
||||
// 执行中
|
||||
// 任务执行中
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else if (status.equals(AcsTaskEnum.STATUS_FINISH.getCode())) {
|
||||
// 完成
|
||||
if (ObjectUtil.isNotEmpty(pointCode1)) {
|
||||
// 释放点位并赋值
|
||||
pointTab.query("point_code = '" + pointCode1 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("point_status", StatusEnum.POINT_STATUS_EMPTY.getCode());
|
||||
pointObj.put("material_id", "");
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
// todo: 是否需要记录库存
|
||||
}
|
||||
// 2任务完成
|
||||
taskObj.put("task_status", StatusEnum.TASK_FINISH.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
/**
|
||||
* 取消任务
|
||||
* 1、点位恢复
|
||||
* 2、任务状态修改
|
||||
*/
|
||||
// 2点位恢复
|
||||
if (ObjectUtil.isNotEmpty(pointCode1)) {
|
||||
// 释放点位
|
||||
pointTab.query("point_code = '" + pointCode1 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
}
|
||||
// 2任务取消
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTask(JSONObject param) {
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
String end_point_code = param.getString("point_code"); // todo
|
||||
String workorder = param.getString("workorder_code");
|
||||
if(StrUtil.isEmpty(end_point_code)) {
|
||||
throw new BadRequestException("终点不能为空!");
|
||||
}
|
||||
// 判断当前点是否有未完成的任务
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and point_code2 = '" + end_point_code + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj)) {
|
||||
throw new BadRequestException("当前点位" + end_point_code + "存在未完成的任务");
|
||||
}
|
||||
// 判断工单
|
||||
JSONObject workOrderObj = workOrderTab.query("workorder_code = '" + workorder + "' and workorder_status <> '" + StatusEnum.TASK_FINISH.getCode() + "' and is_delete ='0'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(workOrderObj)){
|
||||
throw new BadRequestException("下发工单不存在未完成工单:"+workorder);
|
||||
}
|
||||
// 查找任务状态
|
||||
// JSONObject classObj = classTab.query("class_code = '010301'").uniqueResult(0);
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextIdStr();
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.put("task_name", "刻字机呼叫空框");
|
||||
// task.put("task_type", classObj.getString("class_id")); // todo: 未知
|
||||
task.put("task_status", StatusEnum.TASK_CREATE.getCode());
|
||||
task.put("material_id", workOrderObj.getString("material_id"));
|
||||
task.put("point_code2", end_point_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("is_delete", StatusEnum.STATUS_FLASE.getCode());
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_id", currentUserId);
|
||||
task.put("update_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
// 找终点
|
||||
try {
|
||||
pointConfirm(task);
|
||||
// JSONArray data = new JSONArray();
|
||||
// data.add(task);
|
||||
// AcsUtil.notifyAcs("api/wms/task", data);
|
||||
} catch (Exception ex) {
|
||||
// 未找到
|
||||
task.put("remark", ex.getMessage());
|
||||
task.put("task_status", StatusEnum.TASK_START_ERROR.getCode());
|
||||
task.put("update_time", DateUtil.now());
|
||||
taskTab.update(task);
|
||||
}
|
||||
return taskdtl_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 呼叫空框
|
||||
* 从缓存区获取空框
|
||||
* @param taskObj
|
||||
*/
|
||||
@Override
|
||||
public void pointConfirm(JSONObject taskObj) {
|
||||
log.info(OPT_NAME+"callEmptyVehicle param:{}",JSONObject.toJSONString(taskObj));
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
// 去刻字缓存区找空盘
|
||||
JSONObject point = pointTab.query("region_code = 'A1_KZHC' AND point_status = '" +
|
||||
StatusEnum.POINT_STATUS_EMPTY_VEHICLE.getCode() + "' AND lock_type = '" + StatusEnum.LOCK_OFF.getCode() +
|
||||
"' AND is_used = '" + StatusEnum.STATUS_TRUE.getCode() + "' AND is_delete = '" +
|
||||
StatusEnum.STATUS_FLASE.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(point)) {
|
||||
// 找到位置
|
||||
// 点位上锁
|
||||
point.put("lock_type", StatusEnum.LOCK_ON.getCode());
|
||||
pointTab.update(point);
|
||||
// 任务修改
|
||||
taskObj.put("point_code1", point.getString("point_code"));
|
||||
taskObj.put("task_status", StatusEnum.TASK_START_END_P.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
throw new BadRequestException("刻字缓存区没有可用空框.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package org.nl.wms.sch.tasks.callMaterial;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.AcsUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 包装叫料任务
|
||||
* @Date: 2023/4/3
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WrapCallMaterialTask extends AbstractAcsTask {
|
||||
private static final String OPT_NAME = "包装机#";
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject task, String status) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject taskObj = taskTab.query("task_id = '" + task.getString("task_id") + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_FINISH.getCode() + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_CANNEL.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("任务已完成,不可取消!");
|
||||
}
|
||||
String pointCode1 = taskObj.getString("point_code1");
|
||||
JSONObject pointObj = null;
|
||||
if (ObjectUtil.isNotEmpty(pointCode1)) {
|
||||
pointObj = pointTab.query("point_code = '" + pointCode1 + "'").uniqueResult(0);
|
||||
}
|
||||
if (status.equals(AcsTaskEnum.STATUS_START.getCode())) {
|
||||
// 执行中
|
||||
// 任务执行中
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else if (status.equals(AcsTaskEnum.STATUS_FINISH.getCode())) {
|
||||
// 完成
|
||||
if (ObjectUtil.isNotEmpty(pointCode1)) {
|
||||
// 释放点位并赋值
|
||||
pointTab.query("point_code = '" + pointCode1 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("point_status", StatusEnum.POINT_STATUS_EMPTY.getCode());
|
||||
pointObj.put("material_id", "");
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
}
|
||||
// 2任务完成
|
||||
taskObj.put("task_status", StatusEnum.TASK_FINISH.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
/**
|
||||
* 取消任务
|
||||
* 1、点位恢复
|
||||
* 2、任务状态修改
|
||||
*/
|
||||
// 2点位恢复
|
||||
if (ObjectUtil.isNotEmpty(pointCode1)) {
|
||||
// 释放点位
|
||||
pointTab.query("point_code = '" + pointCode1 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
}
|
||||
// 2任务取消
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTask(JSONObject param) {
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
String end_point_code = param.getString("point_code"); // todo
|
||||
String workorder = param.getString("workorder_code");
|
||||
if(StrUtil.isEmpty(end_point_code)) {
|
||||
throw new BadRequestException("终点不能为空!");
|
||||
}
|
||||
// 判断当前点是否有未完成的任务
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and point_code2 = '" + end_point_code + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj)) {
|
||||
throw new BadRequestException("当前点位" + end_point_code + "存在未完成的任务");
|
||||
}
|
||||
// 判断工单
|
||||
JSONObject workOrderObj = workOrderTab.query("workorder_code = '" + workorder + "' and workorder_status <> '" + StatusEnum.TASK_FINISH.getCode() + "' and is_delete ='0'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(workOrderObj)){
|
||||
throw new BadRequestException("下发工单不存在未完成工单:"+workorder);
|
||||
}
|
||||
// 查找任务状态
|
||||
// JSONObject classObj = classTab.query("class_code = '010301'").uniqueResult(0);
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextIdStr();
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_name", "包装叫料");
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
// task.put("task_type", classObj.getString("class_id")); // todo: 未知
|
||||
task.put("task_status", StatusEnum.TASK_CREATE.getCode());
|
||||
task.put("point_code2", end_point_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("is_delete", StatusEnum.STATUS_FLASE.getCode());
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_id", currentUserId);
|
||||
task.put("update_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
// 找终点
|
||||
try {
|
||||
pointConfirm(task);
|
||||
// JSONArray data = new JSONArray();
|
||||
// data.add(task);
|
||||
// AcsUtil.notifyAcs("api/wms/task", data);
|
||||
} catch (Exception ex) {
|
||||
// 未找到
|
||||
task.put("remark", ex.getMessage());
|
||||
task.put("task_status", StatusEnum.TASK_START_ERROR.getCode());
|
||||
task.put("update_time", DateUtil.now());
|
||||
taskTab.update(task);
|
||||
}
|
||||
return taskdtl_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pointConfirm(JSONObject taskObj) {
|
||||
log.info(OPT_NAME+"callMaterial param:{}",JSONObject.toJSONString(taskObj));
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
// 去刻字缓存区找物料
|
||||
JSONObject point = pointTab.query("region_code = 'A1_KZHC' AND point_status = '" +
|
||||
StatusEnum.POINT_STATUS_FULL.getCode() + "' AND lock_type = '" + StatusEnum.LOCK_OFF.getCode() +
|
||||
"' AND is_used = '" + StatusEnum.STATUS_TRUE.getCode() + "' AND is_delete = '" +
|
||||
StatusEnum.STATUS_FLASE.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(point)) {
|
||||
// 找到位置
|
||||
// 点位上锁
|
||||
point.put("lock_type", StatusEnum.LOCK_ON.getCode());
|
||||
pointTab.update(point);
|
||||
// 任务修改
|
||||
taskObj.put("point_code1", point.getString("point_code"));
|
||||
taskObj.put("task_status", StatusEnum.TASK_START_END_P.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
throw new BadRequestException("刻字缓存区没有可用空框.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package org.nl.wms.sch.tasks.sendEmpty;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.AcsUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 包装机送空框
|
||||
* @Date: 2023/4/3
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WrapSendEmptyTask extends AbstractAcsTask {
|
||||
private static final String OPT_NAME = "包装机#";
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject task, String status) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject taskObj = taskTab.query("task_id = '" + task.getString("task_id") + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_FINISH.getCode() + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_CANNEL.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("任务已完成,不可取消!");
|
||||
}
|
||||
String pointCode2 = taskObj.getString("point_code2");
|
||||
JSONObject pointObj = null;
|
||||
if (ObjectUtil.isNotEmpty(pointCode2)) {
|
||||
pointObj = pointTab.query("point_code = '" + pointCode2 + "'").uniqueResult(0);
|
||||
}
|
||||
if (status.equals(AcsTaskEnum.STATUS_START.getCode())) {
|
||||
// 执行中
|
||||
// 任务执行中
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else if (status.equals(AcsTaskEnum.STATUS_FINISH.getCode())) {
|
||||
// 完成
|
||||
if (ObjectUtil.isNotEmpty(pointCode2)) {
|
||||
// 释放点位并赋值
|
||||
pointTab.query("point_code = '" + pointCode2 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("point_status", StatusEnum.POINT_STATUS_EMPTY_VEHICLE.getCode());
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
// todo: 是否需要载具类型
|
||||
}
|
||||
// 2任务完成
|
||||
taskObj.put("task_status", StatusEnum.TASK_FINISH.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
/**
|
||||
* 取消任务
|
||||
* 1、点位恢复
|
||||
* 2、任务状态修改
|
||||
*/
|
||||
// 2点位恢复
|
||||
if (ObjectUtil.isNotEmpty(pointCode2)) {
|
||||
// 释放点位
|
||||
pointTab.query("point_code = '" + pointCode2 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
}
|
||||
// 2任务取消
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createTask(JSONObject param) {
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
String start_point_code = param.getString("point_code"); // todo
|
||||
String workorder = param.getString("workorder_code");
|
||||
if(StrUtil.isEmpty(start_point_code)) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
// 判断当前点是否有未完成的任务
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + start_point_code + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj)) {
|
||||
throw new BadRequestException("当前点位" + start_point_code + "存在未完成的任务");
|
||||
}
|
||||
// todo: 判断工单?
|
||||
// 判断工单
|
||||
// JSONObject workOrderObj = workOrderTab.query("workorder_code <> '" + workorder + "' and workorder_status = '" + StatusEnum.TASK_FINISH.getCode() + "' and is_delete ='0'").uniqueResult(0);
|
||||
// if (ObjectUtil.isEmpty(workOrderObj)){
|
||||
// throw new BadRequestException("下发工单不存在未完成工单:"+workorder);
|
||||
// }
|
||||
// 查找任务状态
|
||||
// JSONObject classObj = classTab.query("class_code = '010301'").uniqueResult(0);
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_name", "包装送空框");
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
// task.put("task_type", classObj.getString("class_id")); // todo: 未知
|
||||
task.put("task_status", StatusEnum.TASK_CREATE.getCode());
|
||||
task.put("point_code1", start_point_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("is_delete", StatusEnum.STATUS_FLASE.getCode());
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_id", currentUserId);
|
||||
task.put("update_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
// 找终点
|
||||
try {
|
||||
pointConfirm(task);
|
||||
// JSONArray data = new JSONArray();
|
||||
// data.add(task);
|
||||
// AcsUtil.notifyAcs("api/wms/task", data);
|
||||
} catch (Exception ex) {
|
||||
// 未找到
|
||||
task.put("remark", ex.getMessage());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("task_status", StatusEnum.TASK_START_END_P.getCode());
|
||||
taskTab.update(task);
|
||||
}
|
||||
return taskdtl_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pointConfirm(JSONObject taskObj) {
|
||||
log.info(OPT_NAME+"sendEmptyVehicle param:{}",JSONObject.toJSONString(taskObj));
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
// 去刻字缓存区找空位
|
||||
JSONObject point = pointTab.query("region_code = 'A1_KZHC' AND point_status = '" +
|
||||
StatusEnum.POINT_STATUS_EMPTY.getCode() + "' AND lock_type = '" + StatusEnum.LOCK_OFF.getCode() +
|
||||
"' AND is_used = '" + StatusEnum.STATUS_TRUE.getCode() + "' AND is_delete = '" +
|
||||
StatusEnum.STATUS_FLASE.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(point)) {
|
||||
// 找到位置
|
||||
// 点位上锁
|
||||
point.put("lock_type", StatusEnum.LOCK_ON.getCode());
|
||||
pointTab.update(point);
|
||||
// 设置点位
|
||||
taskObj.put("point_code2", point.getString("point_code"));
|
||||
taskObj.put("task_status", StatusEnum.TASK_START_END_P.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
throw new BadRequestException("刻字缓存区没有可用货位.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package org.nl.wms.sch.tasks.sendMaterial;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.enums.AcsTaskEnum;
|
||||
import org.nl.common.enums.StatusEnum;
|
||||
import org.nl.common.utils.AcsUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 刻字机送料
|
||||
* @Date: 2023/4/3
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PlotterSendMaterialTask extends AbstractAcsTask {
|
||||
private static final String OPT_NAME = "刻字机#";
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject task, String status) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONObject taskObj = taskTab.query("task_id = '" + task.getString("task_id") + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_FINISH.getCode() + "' " +
|
||||
"AND task_status <> '" + StatusEnum.TASK_CANNEL.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(taskObj)) {
|
||||
throw new BadRequestException("任务已完成,不可取消!");
|
||||
}
|
||||
String pointCode2 = taskObj.getString("point_code2");
|
||||
JSONObject pointObj = null;
|
||||
if (ObjectUtil.isNotEmpty(pointCode2)) {
|
||||
pointObj = pointTab.query("point_code = '" + pointCode2 + "'").uniqueResult(0);
|
||||
}
|
||||
if (status.equals(AcsTaskEnum.STATUS_START.getCode())) {
|
||||
// 执行中
|
||||
// 任务执行中
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else if (status.equals(AcsTaskEnum.STATUS_FINISH.getCode())) {
|
||||
// 完成
|
||||
if (ObjectUtil.isNotEmpty(pointCode2)) {
|
||||
// 释放点位并赋值
|
||||
pointTab.query("point_code = '" + pointCode2 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("point_status", StatusEnum.POINT_STATUS_FULL.getCode());
|
||||
pointObj.put("material_id", taskObj.getString("material_id"));
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
// todo: 是否需要记录库存
|
||||
}
|
||||
// 2任务完成
|
||||
taskObj.put("task_status", StatusEnum.TASK_FINISH.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
/**
|
||||
* 取消任务
|
||||
* 1、点位恢复
|
||||
* 2、任务状态修改
|
||||
*/
|
||||
// 2点位恢复
|
||||
if (ObjectUtil.isNotEmpty(pointCode2)) {
|
||||
// 释放点位
|
||||
pointTab.query("point_code = '" + pointCode2 + "'").uniqueResult(0);
|
||||
pointObj.put("lock_type", StatusEnum.LOCK_OFF.getCode());
|
||||
pointObj.put("update_time", DateUtil.now());
|
||||
pointTab.update(pointObj);
|
||||
}
|
||||
// 2任务取消
|
||||
taskObj.put("task_status", StatusEnum.TASK_CANNEL.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTask(JSONObject param) {
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_produce_workOrder");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject classTab = WQLObject.getWQLObject("MD_PB_ClassStandard");
|
||||
String start_point_code = param.getString("point_code"); // todo
|
||||
String workorder = param.getString("workorder_code");
|
||||
if(StrUtil.isEmpty(start_point_code)) {
|
||||
throw new BadRequestException("起点不能为空!");
|
||||
}
|
||||
// 判断当前点是否有未完成的任务
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + start_point_code + "' " +
|
||||
"and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "' " +
|
||||
"and task_status <> '" + TaskStatusEnum.CANCEL.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj)) {
|
||||
throw new BadRequestException("当前点位" + start_point_code + "存在未完成的任务");
|
||||
}
|
||||
// 判断工单
|
||||
JSONObject workOrderObj = workOrderTab.query("workorder_code = '" + workorder + "' and workorder_status <> '" + StatusEnum.TASK_FINISH.getCode() + "' and is_delete ='0'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(workOrderObj)){
|
||||
throw new BadRequestException("下发工单不存在未完成工单:"+workorder);
|
||||
}
|
||||
// 查找任务状态
|
||||
JSONObject classObj = classTab.query("class_code = '010301'").uniqueResult(0);
|
||||
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("task_id", taskdtl_id);
|
||||
task.put("task_name", "刻字机送料");
|
||||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.put("task_type", classObj.getString("class_id")); // todo: 未知
|
||||
task.put("material_id", workOrderObj.getString("material_id"));
|
||||
task.put("task_status", StatusEnum.TASK_CREATE.getCode());
|
||||
task.put("point_code1", start_point_code);
|
||||
task.put("handle_class", this.getClass().getName());
|
||||
task.put("is_delete", StatusEnum.STATUS_FLASE.getCode());
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
task.put("create_id", currentUserId);
|
||||
task.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("update_id", currentUserId);
|
||||
task.put("update_name", SecurityUtils.getCurrentNickName());
|
||||
task.put("create_time", DateUtil.now());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("priority", "1");
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||
// 找终点
|
||||
try {
|
||||
pointConfirm(task);
|
||||
// JSONArray data = new JSONArray();
|
||||
// data.add(task);
|
||||
// AcsUtil.notifyAcs("api/wms/task", data);
|
||||
} catch (Exception ex) {
|
||||
// 未找到
|
||||
task.put("remark", ex.getMessage());
|
||||
task.put("update_time", DateUtil.now());
|
||||
task.put("task_status", StatusEnum.TASK_START_ERROR.getCode());
|
||||
taskTab.update(task);
|
||||
}
|
||||
return taskdtl_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 满料请求
|
||||
* 从刻字机满料缓存区中获取空位放入就行
|
||||
* @param taskObj: 任务对象
|
||||
*/
|
||||
@Override
|
||||
public void pointConfirm(JSONObject taskObj) {
|
||||
log.info(OPT_NAME+"fullMaterial param:{}",JSONObject.toJSONString(taskObj));
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
// 去刻字缓存区寻找空位
|
||||
JSONObject point = pointTab.query("region_code = 'A1_KZHC' AND point_status = '" +
|
||||
StatusEnum.POINT_STATUS_EMPTY.getCode() + "' AND lock_type = '" + StatusEnum.LOCK_OFF.getCode() +
|
||||
"' AND is_used = '" + StatusEnum.STATUS_TRUE.getCode() + "' AND is_delete = '" +
|
||||
StatusEnum.STATUS_FLASE.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(point)) {
|
||||
// 找到位置
|
||||
// 点位上锁
|
||||
point.put("lock_type", StatusEnum.LOCK_ON.getCode());
|
||||
pointTab.update(point);
|
||||
// 设置点位
|
||||
taskObj.put("point_code2", point.getString("point_code"));
|
||||
taskObj.put("task_status", StatusEnum.TASK_START_END_P.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
} else {
|
||||
throw new BadRequestException("刻字缓存区没有可用货位.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user