diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java index be9d474..8741db8 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java @@ -1,28 +1,34 @@ package org.nl.wms.ext.acs.service; -import com.alibaba.fastjson.JSONArray; import org.nl.wms.ext.acs.service.dto.ResultForAcs; import org.nl.wms.ext.acs.service.dto.to.acs.DeviceInfoDto; import org.nl.wms.ext.acs.service.dto.to.acs.PutActionRequest; -import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; +import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse; import org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo; +import org.nl.wms.sch.task_manage.AcsTaskDto; import java.util.List; -import java.util.Map; /** * @Author: lyd - * @Description: Wms请求Acs + * @Description: Wms请求Acs,统一管理与ACS对接的接口 * @Date: 2023/6/30 */ public interface WmsToAcsService { /** * 下发工单 - * @param workorder + * @param list: 工单链表 * @return */ - ResultForAcs order(AcsWorkOrderVo workorder); + AcsResponse order(List list); + /** + * 下发任务 + * 统一在这里维护 + * @param list: 任务链表 + * @return + */ + AcsResponse renotifyAcs(List list); /** * 下发信号 - 覆膜机释放托盘 diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/CreateTaskRequest.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/IssueAcsRequest.java similarity index 57% rename from lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/CreateTaskRequest.java rename to lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/IssueAcsRequest.java index 14dc059..7d8e1d6 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/CreateTaskRequest.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/IssueAcsRequest.java @@ -4,25 +4,23 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import lombok.Data; import org.nl.wms.ext.acs.service.dto.to.BaseRequest; -import org.nl.wms.sch.task_manage.AcsTaskDto; import java.util.List; -import java.util.Map; /** * @Author: lyd - * @Description: 下发任务实体类 + * @Description: 下发ACS实体类 * @Date: 2023/7/26 */ @Data -public class CreateTaskRequest extends BaseRequest { +public class IssueAcsRequest extends BaseRequest { /** - * 任务数组 + * 类型根据泛型来定义 */ - private List list = null; + private List list = null; - public static CreateTaskRequest buildRequestObj(String name, List list) { - CreateTaskRequest request = new CreateTaskRequest(); + public static IssueAcsRequest buildRequestObj(String name, List list) { + IssueAcsRequest request = new IssueAcsRequest<>(); request.setRequest_medthod_name(name); request.setRequestNo(IdUtil.simpleUUID()); request.setRequestDate(DateUtil.now()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/wms/CreateTaskResponse.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/wms/AcsResponse.java similarity index 65% rename from lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/wms/CreateTaskResponse.java rename to lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/wms/AcsResponse.java index a8dcfb4..25fa3c0 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/wms/CreateTaskResponse.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/wms/AcsResponse.java @@ -8,23 +8,23 @@ import org.nl.wms.ext.acs.service.dto.to.BaseResponse; /** * @Author: lyd - * @Description: 下发任务acs的反馈数据 + * @Description: 下发acs的反馈数据*new * @Date: 2023/7/26 */ @Data -public class CreateTaskResponse extends BaseResponse { +public class AcsResponse extends BaseResponse { private JSONArray errArr = new JSONArray(); - public static CreateTaskResponse requestRefuse(String message) { - CreateTaskResponse result = new CreateTaskResponse(); + public static AcsResponse requestRefuse(String message) { + AcsResponse result = new AcsResponse(); result.setCode(HttpStatus.HTTP_BAD_REQUEST); result.setMessage(message); result.setResponseDate(DateUtil.now()); return result; } - public static CreateTaskResponse requestOk() { - CreateTaskResponse result = new CreateTaskResponse(); + public static AcsResponse requestOk() { + AcsResponse result = new AcsResponse(); result.setCode(HttpStatus.HTTP_OK); result.setMessage("请求成功"); result.setResponseDate(DateUtil.now()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java index 9240df9..f520aca 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java @@ -1,21 +1,21 @@ package org.nl.wms.ext.acs.service.impl; -import cn.hutool.core.date.DateUtil; -import cn.hutool.http.HttpStatus; import lombok.extern.slf4j.Slf4j; import org.nl.wms.ext.acs.service.WmsToAcsService; import org.nl.wms.ext.acs.service.dto.ResultForAcs; import org.nl.wms.ext.acs.service.dto.to.acs.DeviceInfoDto; +import org.nl.wms.ext.acs.service.dto.to.acs.IssueAcsRequest; import org.nl.wms.ext.acs.service.dto.to.acs.PutActionRequest; +import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse; import org.nl.wms.ext.record.service.ISysInteractRecordService; import org.nl.wms.pdm.workorder.service.dao.vo.AcsWorkOrderVo; +import org.nl.wms.sch.task_manage.AcsTaskDto; import org.nl.wms.sch.task_manage.GeneralDefinition; import org.nl.wms.sch.task_manage.task.AcsUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; /** * @Author: lyd @@ -28,13 +28,20 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Autowired private ISysInteractRecordService interactRecordService; @Override - public ResultForAcs order(AcsWorkOrderVo workorder) { + public AcsResponse order(List list) { String api = "api/wms/order"; - List list = new CopyOnWriteArrayList<>(); - list.add(workorder); - ResultForAcs resultForAcs = AcsUtil.notifyAcs(api, list); + AcsResponse resultForAcs = AcsUtil.notifyAcs2(api, IssueAcsRequest.buildRequestObj("下发工单", list)); + // 记录日志 + interactRecordService.saveRecord("下发工单", list, resultForAcs, GeneralDefinition.LMS_ACS); + return resultForAcs; + } + + @Override + public AcsResponse renotifyAcs(List list) { + String api = "api/wms/task"; + AcsResponse resultForAcs = AcsUtil.notifyAcs2(api, IssueAcsRequest.buildRequestObj("下发任务", list)); // 记录日志 - interactRecordService.saveRecord("下发工单", workorder, resultForAcs, GeneralDefinition.LMS_ACS); + interactRecordService.saveRecord("下发任务", list, resultForAcs, GeneralDefinition.LMS_ACS); return resultForAcs; } @@ -49,7 +56,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public ResultForAcs getDeviceStatusByCode(List list) { - String api = "api/"; // todo: 地址未确认 + String api = ""; // todo: 地址未确认 ResultForAcs resultForAcs = AcsUtil.notifyAcs(api, list); // 记录日志 interactRecordService.saveRecord("获取设备状态", list, resultForAcs, GeneralDefinition.LMS_ACS); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/impl/SysInteractRecordServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/impl/SysInteractRecordServiceImpl.java index c5e902f..a3d90a8 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/impl/SysInteractRecordServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/impl/SysInteractRecordServiceImpl.java @@ -14,7 +14,7 @@ import org.nl.common.domain.query.PageQuery; import org.nl.common.exception.BadRequestException; import org.nl.wms.ext.acs.service.dto.ResultForAcs; import org.nl.wms.ext.acs.service.dto.to.BaseResponse; -import org.nl.wms.ext.acs.service.dto.to.wms.CreateTaskResponse; +import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse; import org.nl.wms.ext.record.service.ISysInteractRecordService; import org.nl.wms.ext.record.service.dao.mapper.SysInteractRecordMapper; import org.nl.wms.ext.record.service.dao.SysInteractRecord; @@ -25,7 +25,6 @@ import org.springframework.stereotype.Service; import java.util.Date; import java.util.Map; import java.util.Set; -import java.util.function.Consumer; /** * @description 服务实现 @@ -129,8 +128,8 @@ public class SysInteractRecordServiceImpl extends ServiceImpl list = new CopyOnWriteArrayList<>(); // 重装数据回ACS,重新根据id找一遍,省的改动以上代码 AcsWorkOrderVo acsWorkOrderVo = pdmBdWorkorderMapper.toAcsWorkOrderById(pdmBdWorkorder.getWorkorder_id()); - ResultForAcs resultForAcs; + list.add(acsWorkOrderVo); + AcsResponse resultForAcs; try { - resultForAcs = wmsToAcsService.order(acsWorkOrderVo); + resultForAcs = wmsToAcsService.order(list); } catch (Exception e) { log.error("工单下发异常:" + e.getMessage()); // 通知 @@ -144,7 +151,7 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl taskList = new ArrayList<>(); taskList.add(task); @@ -79,12 +82,12 @@ public abstract class AbstractTask { * @author ldjun * @created 2020年6月12日 下午5:52:28 */ - protected CreateTaskResponse renotifyAcs(List taskList) { - CreateTaskResponse resultForAcs = CreateTaskResponse.requestOk(); + protected AcsResponse renotifyAcs(List taskList) { + AcsResponse resultForAcs = AcsResponse.requestOk(); //1、获取任务 //2、根据任务配置补全任务 //3、下发 - List list = new ArrayList<>(); + List list = new CopyOnWriteArrayList<>(); for (SchBaseTask task : taskList) { AcsTaskDto taskDto = new AcsTaskDto(); String responseParam = task.getResponse_param(); @@ -106,14 +109,14 @@ public abstract class AbstractTask { } try { // 创建下发对象 - resultForAcs = AcsUtil.notifyAcs2("api/wms/task", - CreateTaskRequest.buildRequestObj("下发任务", list)); + resultForAcs = wmsToAcsService.renotifyAcs(list); } catch (Exception e) { log.error("任务下发异常: {}", e.getMessage()); resultForAcs.setResponseDate(DateUtil.now()); resultForAcs.setCode(HttpStatus.HTTP_BAD_REQUEST); resultForAcs.setMessage(e.getMessage()); } + // todo: 可优化点:解除双层循环判断任务的完成性 // 如果下发完毕,就修改状态 if (resultForAcs.getCode() == 200) { // 解析 @@ -138,8 +141,6 @@ public abstract class AbstractTask { } taskService.updateBatchById(taskList); } - // 记录日志 - interactRecordService.saveRecord("下发任务", list, resultForAcs, GeneralDefinition.LMS_ACS); return resultForAcs; } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AcsTaskDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AcsTaskDto.java index 0ee6ec0..a26b506 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AcsTaskDto.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AcsTaskDto.java @@ -1,7 +1,6 @@ package org.nl.wms.sch.task_manage; import lombok.Data; -import org.nl.wms.ext.acs.service.dto.to.acs.CreateTaskRequest; import java.util.Map; diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java index cd1e36c..b33c719 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java @@ -6,6 +6,8 @@ package org.nl.wms.sch.task_manage; * @Date: 2023/7/13 */ public class GeneralDefinition { + /** 未知 */ + public static final String UNKNOWN = "-"; // 统一编码定义 /** 窑自动任务开启 */ public static final String AUTO_KILN_CALL = "auto_kiln_call"; diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/AcsUtil.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/AcsUtil.java index ec7b382..8d79b4c 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/AcsUtil.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/AcsUtil.java @@ -6,13 +6,11 @@ import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; -import org.nl.common.exception.BadRequestException; import org.nl.config.SpringContextHolder; import org.nl.system.service.param.dao.Param; import org.nl.system.service.param.impl.SysParamServiceImpl; import org.nl.wms.ext.acs.service.dto.ResultForAcs; -import org.nl.wms.ext.acs.service.dto.to.acs.CreateTaskRequest; -import org.nl.wms.ext.acs.service.dto.to.wms.CreateTaskResponse; +import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse; import org.nl.wms.sch.task_manage.GeneralDefinition; import java.util.List; @@ -23,7 +21,7 @@ import java.util.List; @Slf4j public class AcsUtil { /** - * 统一多数据入口: 默认执行的参数都是jsonArray + * 原生默认请求方法: 默认执行的参数都是jsonArray * @param api * @param list * @return @@ -67,38 +65,45 @@ public class AcsUtil { return resultForAcs; } - public static CreateTaskResponse notifyAcs2(String api, T object) { + /** + * 新的请求方式:对象中包含数组 + * @param api + * @param object + * @return + * @param + */ + public static AcsResponse notifyAcs2(String api, T object) { SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class); //判断是否连接ACS系统 Param isConnectAcs = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_ACS); if (ObjectUtil.isEmpty(isConnectAcs)) { - return CreateTaskResponse.requestRefuse("参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在"); + return AcsResponse.requestRefuse("参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在"); } String isConnect = isConnectAcs.getValue(); //ACS地址:127.0.0.1:8010 Param acsUrlObj = sysParamService.findByCode(GeneralDefinition.ACS_URL); if (ObjectUtil.isEmpty(acsUrlObj)) { - return CreateTaskResponse.requestRefuse("参数表中:" + GeneralDefinition.ACS_URL + "不存在"); + return AcsResponse.requestRefuse("参数表中:" + GeneralDefinition.ACS_URL + "不存在"); } String acsUrl = acsUrlObj.getValue(); JSONObject result; if (StrUtil.equals(GeneralDefinition.NO, isConnect)) { - return CreateTaskResponse.requestRefuse("未连接ACS!"); + return AcsResponse.requestRefuse("未连接ACS!"); } String url = acsUrl + api; log.info("下发acs任务的参数为:{}", object.toString()); - CreateTaskResponse resultForAcs; + AcsResponse resultForAcs; try { String resultMsg = HttpRequest.post(url) .body(JSON.toJSONString(object)) .execute().body(); result = JSONObject.parseObject(resultMsg); - resultForAcs = JSONObject.toJavaObject(result, CreateTaskResponse.class); + resultForAcs = JSONObject.toJavaObject(result, AcsResponse.class); } catch (Exception e) { String msg = e.getMessage(); //网络不通 log.error("连接失败:{}", msg); - return CreateTaskResponse.requestRefuse("网络不通,操作失败!"); + return AcsResponse.requestRefuse("网络不通,操作失败!"); } return resultForAcs; } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java index 5aef859..e7d027e 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java @@ -102,8 +102,16 @@ public class FJMKTask extends AbstractTask { for (ApplyDeviceDto applyDeviceDto : list) { sum += Integer.parseInt(applyDeviceDto.getQty()); } - // 2 获取库存数量 + // 2.1 获取库存剩余数量 + 2.2 获取在搬运任务 - 组盘绑定状态是带绑定状态、任务类型是创建完成、下发、执行中 + int surplusNumber = fjMapper.getInventoryQuantity(); + int total = sum + surplusNumber; // 现有总数 // 3 获取木托盘需要多少块 + int needFullNumber = 0; // todo: 具体未知如何获取 + // 4 校验是否够码满一托 + if (total > needFullNumber) { + // 可以叫空木托盘 + } + /** 覆膜机木托盘位 */ SchBasePoint LaminatePoint = findStartPoint(startRegionStr, jsonObject); if (ObjectUtil.isEmpty(LaminatePoint)) { @@ -156,12 +164,11 @@ public class FJMKTask extends AbstractTask { String vehicleCode = basePoint.getVehicle_code(); String vehicleType = basePoint.getVehicle_type(); // 找到相同组盘信息就直接返回id,避免任务取消组盘信息还存在,重复插入 - SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup(); - groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr()); - SchBaseVehiclematerialgroup groupObject = vehiclematerialgroupService.getGroupInfo(vehicleCode, vehicleType, + SchBaseVehiclematerialgroup groupEntity = vehiclematerialgroupService.getGroupInfo(vehicleCode, vehicleType, GroupBindMaterialStatusEnum.BOUND.getValue(), workorderObject.getMaterial_id()); - if (groupObject != null) { - groupEntity = groupObject; + if (groupEntity == null) { + groupEntity = new SchBaseVehiclematerialgroup(); + groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr()); } // 要把数据存到组盘表 groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderObject) @@ -190,7 +197,7 @@ public class FJMKTask extends AbstractTask { groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。 groupEntity.setIs_delete(false); groupEntity.setIs_full(isFull.equals(GeneralDefinition.YES) ? true : false); - vehiclematerialgroupService.save(groupEntity); + vehiclematerialgroupService.saveOrUpdate(groupEntity); // 返回组盘id记录任务中 return groupEntity.getGroup_id(); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.java index 73cc238..4009f01 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.java @@ -16,4 +16,6 @@ public interface FJMapper { List findPointForFJSK(List regionCode); SchBasePoint findPointForFJQK(List regionCode, @Param("fluentPut") JSONObject fluentPut); + + int getInventoryQuantity(); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.xml index a755442..66688b8 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/mapper/FJMapper.xml @@ -46,4 +46,18 @@ #{code} + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNMLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNMLTask.java index 001183b..f25fba2 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNMLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNMLTask.java @@ -96,7 +96,7 @@ public class HNMLTask extends AbstractTask { */ @Override @Transactional(rollbackFor = Exception.class) - protected void create() { // 找点+下发、 定时任务 + protected void create() { // 找点+下发-定时任务 // 获取任务 List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); // 配置信息 @@ -125,10 +125,7 @@ public class HNMLTask extends AbstractTask { task.setRemark(""); task.setVehicle_type(GeneralDefinition.MATERIAL_CUP); // 告知acs去左边右边 - String deviceCode = point.getDevice_code(); // 获取设备编码 - int number = Integer.parseInt(deviceCode.replaceAll("[^0-9]", "")); - // 1左边2右边 - number = (number % 2) == 0 ? 2 : (number % 2); + int number = getNumber(point); task.setResponse_param(new JSONObject().fluentPut("direction", number).toJSONString()); taskService.updateById(task); @@ -142,6 +139,14 @@ public class HNMLTask extends AbstractTask { } + private static int getNumber(SchBasePoint point) { + String deviceCode = point.getDevice_code(); // 获取设备编码 + int number = Integer.parseInt(deviceCode.replaceAll("[^0-9]", "")); + // 1左边2右边 + number = (number % 2) == 0 ? 2 : (number % 2); + return number; + } + /** * 根据压机工单的原料编码以及点位的更新时间 * @@ -179,9 +184,7 @@ public class HNMLTask extends AbstractTask { public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { // 获取参数 - String startPoint = taskObj.getPoint_code1(); // 起点 String endPoint = taskObj.getPoint_code2(); // 终点 - SchBasePoint startPointObj = pointService.getById(startPoint); SchBasePoint endPointObj = pointService.getById(endPoint); String responseParam = taskObj.getResponse_param(); JSONObject responseObj = JSONObject.parseObject(responseParam); @@ -196,9 +199,6 @@ public class HNMLTask extends AbstractTask { // 终点去除正在执行的任务, 设置载具编码、载具类型、载具数量 if (ObjectUtil.isNotEmpty(endPointObj)) { endPointObj.setIng_task_code(""); -// endPointObj.setVehicle_code(vehicle_code); -// endPointObj.setVehicle_type(vehicleType); -// endPointObj.setPoint_status(PointStatusEnum.FULL_POINT.getCode()); // 有料 endPointObj.setVehicle_qty(1); PointUtils.setUpdateByType(endPointObj, taskFinishedType); pointService.updateById(endPointObj); @@ -240,7 +240,6 @@ public class HNMLTask extends AbstractTask { TaskUtils.setGroupUpdateByType(groupEntity, taskFinishedType); vehiclematerialgroupService.updateById(groupEntity); // 起点清空 - 由ACS请求修改 -// PointUtils.clearPoint(startPointObj); taskObj.setRemark(GeneralDefinition.TASK_FINISH); taskObj.setTask_status(TaskStatus.FINISHED.getCode()); taskObj.setFinished_type(taskFinishedType.getCode()); @@ -288,17 +287,16 @@ public class HNMLTask extends AbstractTask { if (vehicleCode == null || vehicleCode.equals(GeneralDefinition.NO)) { throw new BadRequestException("载具编码不能为空"); } - SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup(); - groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr()); // 找到相同组盘信息就直接返回id,避免任务取消组盘信息还存在,重复插入 // 找到不直接返回,用那条数据进行修改 - SchBaseVehiclematerialgroup groupObject = vehiclematerialgroupService.getGroupInfo(vehicleCode, vehicleType, + SchBaseVehiclematerialgroup groupEntity = vehiclematerialgroupService.getGroupInfo(vehicleCode, vehicleType, GroupBindMaterialStatusEnum.BOUND.getValue()); - if (groupObject != null) { - groupEntity = groupObject; + if (groupEntity == null) { + groupEntity = new SchBaseVehiclematerialgroup(); + groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr()); } // 要把数据存到组盘表 - groupEntity.setMaterial_id("-"); + groupEntity.setMaterial_id(GeneralDefinition.UNKNOWN); // 物料标识等任务完成后赋值 groupEntity.setRedundance_material_code(materialCode); groupEntity.setCreate_id(GeneralDefinition.ACS_ID); groupEntity.setCreate_name(GeneralDefinition.ACS_NAME); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNQKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNQKTask.java index 9742c1d..dc766a9 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNQKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/hn/HNQKTask.java @@ -1,166 +1,166 @@ -//package org.nl.wms.sch.task_manage.task.tasks.hn; -// -//import cn.hutool.core.date.DateUtil; -//import cn.hutool.core.util.ObjectUtil; -//import com.alibaba.fastjson.JSONObject; -//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -//import org.nl.common.exception.BadRequestException; -//import org.nl.wms.pdm.service.IPdmBdWorkorderService; -//import org.nl.wms.pdm.service.dao.PdmBdWorkorder; -//import org.nl.wms.sch.point.service.ISchBasePointService; -//import org.nl.wms.sch.point.service.dao.SchBasePoint; -//import org.nl.wms.sch.task.service.ISchBaseTaskService; -//import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; -//import org.nl.wms.sch.task.service.dao.SchBaseTask; -//import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; -//import org.nl.wms.sch.task_manage.AbstractTask; -//import org.nl.wms.sch.task_manage.enums.PointStatusEnum; -//import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; -//import org.nl.wms.sch.task_manage.task.TaskType; -//import org.nl.wms.sch.task_manage.task.core.TaskStatus; -//import org.nl.wms.util.PointUtils; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Component; -//import org.springframework.transaction.annotation.Transactional; -// -//import java.util.Arrays; -//import java.util.List; -//import java.util.stream.Collectors; -// -///** -// * @Author: lyd -// * @Description: 混料缺空:呼叫空载具 -// * @Date: 2023/5/19 -// */ -//@Component -//@TaskType("HLQKTask") -//public class HNQKTask extends AbstractTask { -// private static String TASK_CONFIG_CODE = "HLQKTask"; -// private static String EMPTY_ZHONG = "1"; -// -// @Autowired -// private ISchBasePointService pointService; -// @Autowired -// private ISchBaseTaskService taskService; -// @Autowired -// private ISchBaseTaskconfigService taskConfigService; -// @Autowired -// private IPdmBdWorkorderService workorderService; -// -// /** -// * 具体业务 -// */ -// @Override -// @Transactional(rollbackFor = Exception.class) -// protected void create() { -// // 获取任务 -// List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); -// // 配置信息 -// SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() -// .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); -// for (SchBaseTask task : tasks) { -// List startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList()); -// // 找起点 -// String extGroupData = task.getExt_group_data(); -// JSONObject jsonObject = JSONObject.parseObject(extGroupData); -// SchBasePoint point = findStartPoint(startRegionStr, jsonObject); -// if (ObjectUtil.isEmpty(point)) { -// task.setRemark("未找到所需点位!"); -// taskService.update(task); -// // 消息通知 -// continue; -// } -// // 设置终点并修改创建成功状态 -// task.setPoint_code1(point.getPoint_code()); -// task.setRemark(""); -// task.setTask_status(TaskStatus.CREATED.getCode()); -// taskService.update(task); -// -// point.setIng_task_code(task.getTask_code()); -// pointService.update(point); -// -// //下发 -//// this.renotifyAcs(task); -// } -// } -// -// /** -// * 找起点, 通过料盅睏料线区域的空盅位置找到空盅 -// * -// * @param startRegionStr -// * @param extGroupData -// * @return -// */ -// private SchBasePoint findStartPoint(List startRegionStr, JSONObject extGroupData) { -// LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); -// lam.in(SchBasePoint::getRegion_code, startRegionStr) -// .eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode()) -// .eq(SchBasePoint::getPoint_type, EMPTY_ZHONG) -// .and(la -> la.isNull(SchBasePoint::getIng_task_code) // 当前执行的任务为空或者NULL,有数据表示锁住 -// .or() -// .eq(SchBasePoint::getIng_task_code, "")) -// .orderByAsc(SchBasePoint::getIn_order_seq) -// .orderByAsc(SchBasePoint::getPoint_code); -// List schBasePoints = pointService.list(lam); -// return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null; -// } -// -// @Override -// @Transactional(rollbackFor = Exception.class) -// protected void updateStatus(String task_code, TaskStatus status) { -// // 校验任务 -// SchBaseTask taskObj = taskService.getByCode(task_code); -// if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { -// throw new BadRequestException("该任务已完成!"); -// } -// if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { -// throw new BadRequestException("该任务已取消!"); -// } -// // 获取参数 -// String startPoint = taskObj.getPoint_code1(); // 获取起点 -// String endPoint = taskObj.getPoint_code2(); // 获取起点 -// SchBasePoint startPointObj = pointService.getById(startPoint); -// SchBasePoint endPointObj = pointService.getById(endPoint); -// // 根据传来的类型去对任务进行操作 -// if (status.equals(TaskStatus.EXECUTING)) { // 执行中 -// taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); -// taskObj.setRemark("执行中"); -// } -// if (status.equals(TaskStatus.FINISHED)) { // 完成 -// // 起点清空 -// if (ObjectUtil.isNotEmpty(startPointObj)) { -// PointUtils.clearPoint(startPointObj); -// taskObj.setVehicle_code(startPointObj.getVehicle_code()); -// endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode()); -// endPointObj.setVehicle_type("1"); -// endPointObj.setVehicle_code(startPointObj.getVehicle_code()); -// endPointObj.setVehicle_qty(1); -// endPointObj.setUpdate_time(DateUtil.now()); -// pointService.updateById(endPointObj); -// } -// // 任务完成 -// taskObj.setTask_status(TaskStatus.FINISHED.getCode()); -// taskObj.setRemark(GeneralDefinition.TASK_FINISH); -// } -// if (status.equals(TaskStatus.CANCELED)) { // 取消 -// // 起点解锁 -// if (ObjectUtil.isNotEmpty(startPointObj)) { -// startPointObj.setIng_task_code(""); -// pointService.update(startPointObj); -// } -// taskObj.setTask_status(TaskStatus.CANCELED.getCode()); -// } -// taskService.update(taskObj); -// } -// -// @Override -// public void forceFinish(String task_code) { -// this.updateStatus(task_code, TaskStatus.FINISHED); -// } -// -// @Override -// public void cancel(String task_code) { -// this.updateStatus(task_code, TaskStatus.CANCELED); -// } -//} -// +package org.nl.wms.sch.task_manage.task.tasks.hn; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.nl.common.exception.BadRequestException; +import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; +import org.nl.wms.sch.point.service.ISchBasePointService; +import org.nl.wms.sch.point.service.dao.SchBasePoint; +import org.nl.wms.sch.task.service.ISchBaseTaskService; +import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; +import org.nl.wms.sch.task.service.dao.SchBaseTask; +import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; +import org.nl.wms.sch.task_manage.AbstractTask; +import org.nl.wms.sch.task_manage.GeneralDefinition; +import org.nl.wms.sch.task_manage.enums.PointStatusEnum; +import org.nl.wms.sch.task_manage.task.TaskType; +import org.nl.wms.sch.task_manage.task.core.TaskStatus; +import org.nl.wms.util.PointUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: lyd + * @Description: 混料缺空:呼叫空载具 + * @Date: 2023/5/19 + */ +@Deprecated +@Component +@TaskType("--") +public class HNQKTask extends AbstractTask { + private static String TASK_CONFIG_CODE = "--"; + private static String EMPTY_ZHONG = "1"; + + @Autowired + private ISchBasePointService pointService; + @Autowired + private ISchBaseTaskService taskService; + @Autowired + private ISchBaseTaskconfigService taskConfigService; + @Autowired + private IPdmBdWorkorderService workorderService; + + /** + * 具体业务 + */ + @Override + @Transactional(rollbackFor = Exception.class) + protected void create() { + // 获取任务 + List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); + // 配置信息 + SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() + .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); + for (SchBaseTask task : tasks) { + List startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList()); + // 找起点 + String extGroupData = task.getExt_group_data(); + JSONObject jsonObject = JSONObject.parseObject(extGroupData); + SchBasePoint point = findStartPoint(startRegionStr, jsonObject); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + continue; + } + // 设置终点并修改创建成功状态 + task.setPoint_code1(point.getPoint_code()); + task.setRemark(""); + task.setTask_status(TaskStatus.CREATED.getCode()); + taskService.update(task); + + point.setIng_task_code(task.getTask_code()); + pointService.update(point); + + //下发 +// this.renotifyAcs(task); + } + } + + /** + * 找起点, 通过料盅睏料线区域的空盅位置找到空盅 + * + * @param startRegionStr + * @param extGroupData + * @return + */ + private SchBasePoint findStartPoint(List startRegionStr, JSONObject extGroupData) { + LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); + lam.in(SchBasePoint::getRegion_code, startRegionStr) + .eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode()) + .eq(SchBasePoint::getPoint_type, EMPTY_ZHONG) + .and(la -> la.isNull(SchBasePoint::getIng_task_code) // 当前执行的任务为空或者NULL,有数据表示锁住 + .or() + .eq(SchBasePoint::getIng_task_code, "")) + .orderByAsc(SchBasePoint::getIn_order_seq) + .orderByAsc(SchBasePoint::getPoint_code); + List schBasePoints = pointService.list(lam); + return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null; + } + + @Override + @Transactional(rollbackFor = Exception.class) + protected void updateStatus(String task_code, TaskStatus status) { + // 校验任务 + SchBaseTask taskObj = taskService.getByCode(task_code); + if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { + throw new BadRequestException("该任务已完成!"); + } + if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { + throw new BadRequestException("该任务已取消!"); + } + // 获取参数 + String startPoint = taskObj.getPoint_code1(); // 获取起点 + String endPoint = taskObj.getPoint_code2(); // 获取起点 + SchBasePoint startPointObj = pointService.getById(startPoint); + SchBasePoint endPointObj = pointService.getById(endPoint); + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { // 执行中 + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + } + if (status.equals(TaskStatus.FINISHED)) { // 完成 + // 起点清空 + if (ObjectUtil.isNotEmpty(startPointObj)) { + PointUtils.clearPoint(startPointObj); + taskObj.setVehicle_code(startPointObj.getVehicle_code()); + endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode()); + endPointObj.setVehicle_type("1"); + endPointObj.setVehicle_code(startPointObj.getVehicle_code()); + endPointObj.setVehicle_qty(1); + endPointObj.setUpdate_time(DateUtil.now()); + pointService.updateById(endPointObj); + } + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + } + if (status.equals(TaskStatus.CANCELED)) { // 取消 + // 起点解锁 + if (ObjectUtil.isNotEmpty(startPointObj)) { + startPointObj.setIng_task_code(""); + pointService.update(startPointObj); + } + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + } + taskService.update(taskObj); + } + + @Override + public void forceFinish(String task_code) { + this.updateStatus(task_code, TaskStatus.FINISHED); + } + + @Override + public void cancel(String task_code) { + this.updateStatus(task_code, TaskStatus.CANCELED); + } +} + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZQLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZQLTask.java index 6ceb28c..7f59bdd 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZQLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZQLTask.java @@ -1,171 +1,171 @@ -//package org.nl.wms.sch.task_manage.task.tasks.yz; -// -//import cn.hutool.core.lang.Assert; -//import cn.hutool.core.util.ObjectUtil; -//import com.alibaba.fastjson.JSONObject; -//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -//import lombok.extern.slf4j.Slf4j; -//import org.nl.common.exception.BadRequestException; -//import org.nl.wms.pdm.service.IPdmBdWorkorderService; -//import org.nl.wms.pdm.service.dao.PdmBdWorkorder; -//import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; -//import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; -//import org.nl.wms.sch.point.service.ISchBasePointService; -//import org.nl.wms.sch.point.service.dao.SchBasePoint; -//import org.nl.wms.sch.task.service.ISchBaseTaskService; -//import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; -//import org.nl.wms.sch.task.service.dao.SchBaseTask; -//import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; -//import org.nl.wms.sch.task_manage.AbstractTask; -//import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum; -//import org.nl.wms.sch.task_manage.enums.PointStatusEnum; -//import org.nl.wms.sch.task_manage.task.TaskType; -//import org.nl.wms.sch.task_manage.task.core.TaskStatus; -//import org.nl.wms.sch.task_manage.task.tasks.yz.mapper.YZMapper; -//import org.nl.wms.util.PointUtils; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Component; -// -//import java.util.Arrays; -//import java.util.List; -//import java.util.stream.Collectors; -// -///** -// * @Author: lyd -// * @Description: 压制缺料任务 -// * @Date: 2023/5/25 -// */ -//@Slf4j -//@Component -//@TaskType("YZQLTask") -//public class YZQLTask extends AbstractTask { -// private static String TASK_CONFIG_CODE = "YZQLTask"; -// -// @Autowired -// private ISchBasePointService pointService; -// @Autowired -// private ISchBaseTaskService taskService; -// @Autowired -// private ISchBaseTaskconfigService taskConfigService; -// @Autowired -// private ISchBaseVehiclematerialgroupService vehiclematerialgroupService; -// @Autowired -// private IPdmBdWorkorderService workorderService; -// @Autowired -// private YZMapper yzMapper; -// -// @Override -// protected void create() throws BadRequestException { -// // 获取任务 -// List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); -// // 配置信息 -// SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() -// .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); -// for (SchBaseTask task : tasks) { -// List startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList()); -// // 找起点 -// String extGroupData = task.getExt_group_data(); -// JSONObject jsonObject = JSONObject.parseObject(extGroupData); -// jsonObject.put("vehicle_type", task.getVehicle_type()); -// SchBasePoint point = findStartPoint(startRegionStr, jsonObject); -// if (ObjectUtil.isEmpty(point)) { -// task.setRemark("未找到所需点位!"); -// taskService.update(task); -// // 消息通知 -// continue; -// } -// // 设置起点并修改创建成功状态 -// task.setPoint_code1(point.getPoint_code()); -// task.setTask_status(TaskStatus.CREATED.getCode()); -// task.setVehicle_code(point.getVehicle_code()); -// taskService.update(task); -// -// point.setIng_task_code(task.getTask_code()); -// pointService.update(point); -// -// //下发 -//// this.renotifyAcs(task); -// } -// } -// -// /** -// * 找起点业务:混碾机工单的物料标识相同的位置 -// * -// * @param startRegionStr : 区域列表 -// * @param extGroupData : 外部参数,包含条件所需的信息 -// * @return -// * @description : JSONObject获取不到就是null -// */ -// private SchBasePoint findStartPoint(List startRegionStr, JSONObject extGroupData) { -// // 获取当前工单 -// String workorderCode = extGroupData.getString("workorder_code"); -// PdmBdWorkorder workOrder = ObjectUtil.isNotEmpty(workorderCode) -// ? workorderService.getOne(new LambdaQueryWrapper() -// .eq(PdmBdWorkorder::getWorkorder_code, workorderCode)) -// : null; -// Assert.notNull(workOrder, "工单不能为空!"); -// // 查找混碾机工单的物料相同的位置 -// List points = yzMapper.findPointForYZQL(startRegionStr, workOrder.getMaterial_id()); -// return ObjectUtil.isNotEmpty(points) ? points.get(0) : null; -// } -// -// -// @Override -// protected void updateStatus(String task_code, TaskStatus status) { -// // 校验任务 -// SchBaseTask taskObj = taskService.getByCode(task_code); -// if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { -// throw new BadRequestException("该任务已完成!"); -// } -// if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { -// throw new BadRequestException("该任务已取消!"); -// } -// // 获取参数 -// String startPoint = taskObj.getPoint_code1(); // 起点 -// JSONObject extGroupData = ObjectUtil.isNotEmpty(taskObj.getExt_group_data()) -// ? JSONObject.parseObject(taskObj.getExt_group_data()) -// : null; -// SchBasePoint startPointObj = pointService.getById(startPoint); -// // 根据传来的类型去对任务进行操作 -// if (status.equals(TaskStatus.EXECUTING)) { // 执行中 -// taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); -// taskObj.setRemark("执行中"); -// } -// if (status.equals(TaskStatus.FINISHED)) { // 完成 -// // 任务上有载具编码 -> 获取当前载具编码的组盘信息 -// SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper() -// .eq(SchBaseVehiclematerialgroup::getVehicle_code, taskObj.getVehicle_code()) -// .eq(SchBaseVehiclematerialgroup::getVehicle_type, taskObj.getVehicle_type()) -// .eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue())); -// // 将载具设置为已解绑 -// one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); -// vehiclematerialgroupService.update(one); -// // 释放点位,将点位设置为空位,清空数据 -// if (ObjectUtil.isNotEmpty(startPointObj)) { -// PointUtils.clearPoint(startPointObj); -// // todo: 终点暂时无设置 -// } -// // 任务修改成完成 -// taskObj.setTask_status(TaskStatus.FINISHED.getCode()); -// } -// if (status.equals(TaskStatus.CANCELED)) { // 取消 -// taskObj.setTask_status(TaskStatus.CANCELED.getCode()); -// // 释放点位,起点正在执行的任务清空 -// if (ObjectUtil.isNotEmpty(startPointObj)) { -// startPointObj.setIng_task_code(""); -// pointService.update(startPointObj); -// } -// } -// taskService.update(taskObj); -// } -// -// @Override -// public void forceFinish(String task_code) { -// this.updateStatus(task_code, TaskStatus.FINISHED); -// } -// -// @Override -// public void cancel(String task_code) { -// this.updateStatus(task_code, TaskStatus.CANCELED); -// } -//} +package org.nl.wms.sch.task_manage.task.tasks.yz; + +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.exception.BadRequestException; +import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; +import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; +import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; +import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; +import org.nl.wms.sch.point.service.ISchBasePointService; +import org.nl.wms.sch.point.service.dao.SchBasePoint; +import org.nl.wms.sch.task.service.ISchBaseTaskService; +import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; +import org.nl.wms.sch.task.service.dao.SchBaseTask; +import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; +import org.nl.wms.sch.task_manage.AbstractTask; +import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum; +import org.nl.wms.sch.task_manage.task.TaskType; +import org.nl.wms.sch.task_manage.task.core.TaskStatus; +import org.nl.wms.sch.task_manage.task.tasks.yz.mapper.YZMapper; +import org.nl.wms.util.PointUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: lyd + * @Description: 压制缺料任务 + * @Date: 2023/5/25 + */ +@Slf4j +@Deprecated +@Component +@TaskType("-") +public class YZQLTask extends AbstractTask { + private static String TASK_CONFIG_CODE = "-"; + + @Autowired + private ISchBasePointService pointService; + @Autowired + private ISchBaseTaskService taskService; + @Autowired + private ISchBaseTaskconfigService taskConfigService; + @Autowired + private ISchBaseVehiclematerialgroupService vehiclematerialgroupService; + @Autowired + private IPdmBdWorkorderService workorderService; + @Autowired + private YZMapper yzMapper; + + @Override + protected void create() throws BadRequestException { + // 获取任务 + List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); + // 配置信息 + SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() + .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); + for (SchBaseTask task : tasks) { + List startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList()); + // 找起点 + String extGroupData = task.getExt_group_data(); + JSONObject jsonObject = JSONObject.parseObject(extGroupData); + jsonObject.put("vehicle_type", task.getVehicle_type()); + SchBasePoint point = findStartPoint(startRegionStr, jsonObject); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + continue; + } + // 设置起点并修改创建成功状态 + task.setPoint_code1(point.getPoint_code()); + task.setTask_status(TaskStatus.CREATED.getCode()); + task.setVehicle_code(point.getVehicle_code()); + taskService.update(task); + + point.setIng_task_code(task.getTask_code()); + pointService.update(point); + + //下发 +// this.renotifyAcs(task); + } + } + + /** + * 找起点业务:混碾机工单的物料标识相同的位置 + * + * @param startRegionStr : 区域列表 + * @param extGroupData : 外部参数,包含条件所需的信息 + * @return + * @description : JSONObject获取不到就是null + */ + private SchBasePoint findStartPoint(List startRegionStr, JSONObject extGroupData) { + // 获取当前工单 + String workorderCode = extGroupData.getString("workorder_code"); + PdmBdWorkorder workOrder = ObjectUtil.isNotEmpty(workorderCode) + ? workorderService.getOne(new LambdaQueryWrapper() + .eq(PdmBdWorkorder::getWorkorder_code, workorderCode)) + : null; + Assert.notNull(workOrder, "工单不能为空!"); + // 查找混碾机工单的物料相同的位置 + List points = yzMapper.findPointForYZQL(startRegionStr, workOrder.getMaterial_id()); + return ObjectUtil.isNotEmpty(points) ? points.get(0) : null; + } + + + @Override + protected void updateStatus(String task_code, TaskStatus status) { + // 校验任务 + SchBaseTask taskObj = taskService.getByCode(task_code); + if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { + throw new BadRequestException("该任务已完成!"); + } + if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { + throw new BadRequestException("该任务已取消!"); + } + // 获取参数 + String startPoint = taskObj.getPoint_code1(); // 起点 + JSONObject extGroupData = ObjectUtil.isNotEmpty(taskObj.getExt_group_data()) + ? JSONObject.parseObject(taskObj.getExt_group_data()) + : null; + SchBasePoint startPointObj = pointService.getById(startPoint); + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { // 执行中 + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + } + if (status.equals(TaskStatus.FINISHED)) { // 完成 + // 任务上有载具编码 -> 获取当前载具编码的组盘信息 + SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper() + .eq(SchBaseVehiclematerialgroup::getVehicle_code, taskObj.getVehicle_code()) + .eq(SchBaseVehiclematerialgroup::getVehicle_type, taskObj.getVehicle_type()) + .eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue())); + // 将载具设置为已解绑 + one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); + vehiclematerialgroupService.update(one); + // 释放点位,将点位设置为空位,清空数据 + if (ObjectUtil.isNotEmpty(startPointObj)) { + PointUtils.clearPoint(startPointObj); + // todo: 终点暂时无设置 + } + // 任务修改成完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + } + if (status.equals(TaskStatus.CANCELED)) { // 取消 + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + // 释放点位,起点正在执行的任务清空 + if (ObjectUtil.isNotEmpty(startPointObj)) { + startPointObj.setIng_task_code(""); + pointService.update(startPointObj); + } + } + taskService.update(taskObj); + } + + @Override + public void forceFinish(String task_code) { + this.updateStatus(task_code, TaskStatus.FINISHED); + } + + @Override + public void cancel(String task_code) { + this.updateStatus(task_code, TaskStatus.CANCELED); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java index 9f9c0f2..14b9548 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java @@ -211,15 +211,15 @@ public class YZSLTask extends AbstractTask { Integer qty = param.getInteger("qty"); SchBasePoint basePoint = pointService.getById(deviceCode); PdmBdWorkorder workorderObject = workorderService.getDeviceProductionTask(basePoint.getParent_point_code()); - // 找到相同组盘信息就直接返回id,避免任务取消组盘信息还存在,重复插入 + // 找到相同组盘信息就修改,避免任务取消组盘信息还存在,重复插入 + SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup(); + groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr()); SchBaseVehiclematerialgroup groupObject = vehiclematerialgroupService.getGroupInfo(vehicleCode, vehicleType, GroupBindMaterialStatusEnum.WAIT_BIND.getValue(), workorderObject.getMaterial_id()); if (groupObject != null) { - return groupObject.getGroup_id(); + groupEntity = groupObject; } // 要把数据存到组盘表 - SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup(); - groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr()); groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderObject) ? workorderObject.getMaterial_id() : ""); @@ -246,7 +246,7 @@ public class YZSLTask extends AbstractTask { groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。 groupEntity.setIs_delete(false); groupEntity.setIs_full(isFull.equals(GeneralDefinition.YES) ? true : false); - vehiclematerialgroupService.save(groupEntity); + vehiclematerialgroupService.saveOrUpdate(groupEntity); // 将所有当前位置的砖块设置组盘标识 baseBrickInfoService.setGroupByCurrentAllBrick(deviceCode, groupEntity.getGroup_id()); // 返回组盘id记录任务中 diff --git a/lms/nladmin-ui/src/views/wms/sch/task/config/index.vue b/lms/nladmin-ui/src/views/wms/sch/task/config/index.vue index c3eeda5..def0bb2 100644 --- a/lms/nladmin-ui/src/views/wms/sch/task/config/index.vue +++ b/lms/nladmin-ui/src/views/wms/sch/task/config/index.vue @@ -350,8 +350,8 @@ {{ scope.row.is_lock_next?'是':'否' }} - - + +