From 219d79da7c3e64a94ba088885638022e96d67155 Mon Sep 17 00:00:00 2001 From: liuxy Date: Wed, 9 Oct 2024 17:40:09 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9Ames=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/nl/acs/ext/wms/LmsHttpUtil.java | 5 +- .../acs/controller/AcsToWmsController.java | 9 ++ .../wms/ext/acs/service/AcsToWmsService.java | 11 ++ .../acs/service/impl/AcsToWmsServiceImpl.java | 88 +++++++++++ .../mes/controller/WmsToMesController.java | 16 ++ .../wms/ext/mes/service/WmsToMesService.java | 52 +++++++ .../service/dto/ResultTaskConfirmMesDto.java | 139 ++++++++++++++++++ .../mes/service/impl/MesToWmsServiceImpl.java | 16 +- .../mes/service/impl/WmsToMesServiceImpl.java | 81 ++++++++++ .../nl/wms/sch/task_manage/AbstractTask.java | 4 - .../task_manage/task/tasks/fj/KABDMTask.java | 139 ++++++++++++++++++ .../task_manage/task/tasks/fj/KDMABTask.java | 139 ++++++++++++++++++ .../task_manage/task/tasks/fj/MABCTask.java | 9 +- .../task_manage/task/tasks/fj/MABDMTask.java | 139 ++++++++++++++++++ .../task/tasks/fj/MABGPTHJTask.java | 139 ++++++++++++++++++ .../task_manage/task/tasks/fj/MBZCPTask.java | 139 ++++++++++++++++++ .../task_manage/task/tasks/fj/MCDTask.java | 139 ++++++++++++++++++ .../task_manage/task/tasks/fj/MDDMTask.java | 139 ++++++++++++++++++ .../task_manage/task/tasks/fj/MDMCPTask.java | 139 ++++++++++++++++++ .../task/tasks/fj/MGPTHJABTask.java | 139 ++++++++++++++++++ .../task/tasks/fj/MGPTHJCPTask.java | 139 ++++++++++++++++++ 21 files changed, 1806 insertions(+), 14 deletions(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/ResultTaskConfirmMesDto.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KABDMTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KDMABTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABDMTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABGPTHJTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MBZCPTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MCDTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDDMTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDMCPTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJABTask.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJCPTask.java diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/ext/wms/LmsHttpUtil.java b/acs2/nladmin-system/src/main/java/org/nl/acs/ext/wms/LmsHttpUtil.java index d40b2da..f9b62cd 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/ext/wms/LmsHttpUtil.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/ext/wms/LmsHttpUtil.java @@ -3,6 +3,7 @@ package org.nl.acs.ext.wms; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import org.nl.acs.config.AcsConfig; import org.nl.acs.ext.RequestAdapter; import org.nl.acs.ext.ResponseAdapter; @@ -50,10 +51,12 @@ public class LmsHttpUtil { return new UnifiedResponse<>(false, "未开启连接该系统!"); } try { + JSONArray array = new JSONArray(); + array.add(requestParam); String body = HttpRequest .post(REQUEST_ADAPTER.getUrl() + path) .setConnectionTimeout(5000) - .body(JSON.toJSONString(requestParam)) + .body(JSON.toJSONString(array)) .execute() .body(); return RESPONSE_ADAPTER.adapt(body, null); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java index f16016f..89b00f5 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java @@ -3,6 +3,7 @@ package org.nl.wms.ext.acs.controller; import cn.dev33.satoken.annotation.SaIgnore; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; +import org.nl.common.logging.annotation.Log; import org.nl.wms.ext.acs.service.AcsToWmsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -24,4 +25,12 @@ public class AcsToWmsController { @Autowired private AcsToWmsService acsToWmsService; + @PostMapping("/status") + @Log(value = "ACS给WMS反馈任务状态") + @SaIgnore + public ResponseEntity receiveTaskStatusAcs(@RequestBody String string) { + log.info("ACS给WMS反馈任务状态:{}", string); + return new ResponseEntity<>(acsToWmsService.receiveTaskStatusAcs(string), HttpStatus.OK); + } + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java index 4f499e1..3512caf 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java @@ -6,10 +6,21 @@ import org.nl.wms.ext.acs.service.dto.to.acs.ApplyTaskResponse; import org.nl.wms.ext.acs.service.dto.to.acs.GetPalletizeResponse; import org.nl.wms.ext.acs.service.dto.to.wms.ApplyTaskRequest; +import java.util.Map; + /** * @Author: lyd * @Description: acs请求wms * @Date: 2023/6/26 */ public interface AcsToWmsService { + + /** + * ACS客户端--->WMS服务端 + * ACS向WMS反馈任务状态 + * + * @param string ACS反馈的任务数组 + * @return Map + */ + Map receiveTaskStatusAcs(String string); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index e62bde9..0e5fb9b 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -1,8 +1,28 @@ package org.nl.wms.ext.acs.service.impl; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.nl.common.exception.BadRequestException; +import org.nl.config.SpringContextHolder; import org.nl.wms.ext.acs.service.AcsToWmsService; +import org.nl.wms.sch.task.service.ISchBaseTaskService; +import org.nl.wms.sch.task.service.dao.SchBaseTask; +import org.nl.wms.sch.task_manage.AbstractTask; +import org.nl.wms.sch.task_manage.task.TaskFactory; +import org.nl.wms.sch.task_manage.task.core.TaskStatus; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.lang.reflect.Method; +import java.util.Map; +import java.util.concurrent.TimeUnit; /** * @Author: lyd @@ -12,4 +32,72 @@ import org.springframework.stereotype.Service; @Slf4j @Service public class AcsToWmsServiceImpl implements AcsToWmsService { + + /* + * redisson连接服务 + */ + @Autowired + private RedissonClient redissonClient; + + /* + * 任务服务 + */ + @Autowired + private ISchBaseTaskService iSchBaseTaskService; + + /** + * 任务工厂服务 + */ + @Autowired + private TaskFactory taskFactory; + + @Override + @Transactional(rollbackFor = Exception.class) + @SneakyThrows + public Map receiveTaskStatusAcs(String string) { + log.info("acs向lms反馈任务状态,请求参数:--------------------------------------" + string); + JSONArray array = JSONArray.parseArray(string); + //返回处理失败的任务 + JSONArray errArr = new JSONArray(); + for (int i = 0; i < array.size(); i++) { + JSONObject row = array.getJSONObject(i); + String task_id = row.getString("task_id"); + RLock lock = redissonClient.getLock(task_id); + boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS); + try { + if (tryLock) { + SchBaseTask taskObj = iSchBaseTaskService.getById(task_id); + + // acs反馈的任务类型 + String acs_task_status = row.getString("task_status"); + TaskStatus status = null; + if ("1".equals(acs_task_status)) { + status = TaskStatus.EXECUTING; + } else if ("2".equals(acs_task_status)) { + status = TaskStatus.FINISHED; + } else { + status = TaskStatus.CANCELED; + } + + // 根据配置编码执行相关配置内的方法 + AbstractTask task = taskFactory.getTask(taskObj.getConfig_code()); + task.updateTaskStatus(taskObj.getTask_code(),status); + + } else { + throw new BadRequestException("任务标识为:" + task_id + "的任务正在操作中!"); + } + } finally { + if (tryLock) { + lock.unlock(); + } + } + } + JSONObject result = new JSONObject(); + result.put("status", HttpStatus.OK.value()); + result.put("message", "任务状态反馈成功!"); + result.put("data", new JSONObject()); + result.put("errArr", errArr); + log.info("acs向lms反馈任务状态,返回参数:--------------------------------------" + result.toString()); + return result; + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/controller/WmsToMesController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/controller/WmsToMesController.java index 46bf64d..0a16762 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/controller/WmsToMesController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/controller/WmsToMesController.java @@ -1,9 +1,17 @@ package org.nl.wms.ext.mes.controller; +import cn.dev33.satoken.annotation.SaIgnore; +import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; +import org.nl.common.logging.annotation.Log; import org.nl.wms.ext.mes.service.WmsToMesService; +import org.nl.wms.sch.task.service.dao.SchBaseTask; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -19,4 +27,12 @@ import org.springframework.web.bind.annotation.RestController; public class WmsToMesController { @Autowired private WmsToMesService wmsToMesService; + + @PostMapping("/receiveTaskStatusMes") + @Log(value = "测试") + @SaIgnore + public ResponseEntity receiveTaskStatusMes(@RequestBody SchBaseTask string) { + return new ResponseEntity<>(wmsToMesService.receiveTaskStatusMesData(string), HttpStatus.OK); + } + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java index 02db4cc..33ef66e 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/WmsToMesService.java @@ -1,9 +1,61 @@ package org.nl.wms.ext.mes.service; +import com.alibaba.fastjson.JSONObject; +import org.nl.wms.sch.task.service.dao.SchBaseTask; + /** * @Author: lyd * @Description: wms请求acs * @Date: 2023/8/3 */ public interface WmsToMesService { + + /** + * 通知mes任务完成组织数据 + * @param task:任务实体类 + * @return JSONObject:返回结果 + */ + JSONObject receiveTaskStatusMesData(SchBaseTask task); + + + /** + * 通知mes任务完成 + * @param jo: { + * "header": { + * "method": "ServicesCUS.Module_CUS.CUS_AcceptAGVReturnInformation", + * "account": "DS", + * "password": "DS", + * "version": "", + * "modules": [], + * "mac": "", + * "lang": "zh_CN", + * "is_debug": true, + * "platform": "web", + * "session": "" + * }, + * "content": { + * "TaskCode": "RS1#2023-10-18000001", + * "AGVCode": "111", + * "ArrivedLocation": "111", + * "IsPlacedLocation": "0" + * } + * } + * @return JSONObject:返回参数 { + * "isSuccess": true, + * "needUpdate": false, + * "needLogout": false, + * "Code": 0, + * "uri": "ServicesCUS.Module_CUS.CUS_AcceptAGVReturnInformation", + * "Message": "", + * "Exception": null, + * "ExceptionMessage": null, + * "StackTrace": null, + * "Content": { + * "ReturnStatus": 0, + * "ReturnInfo": "返回成功", + * "MsgTime": "2023-10-19 10:59:56" + * } + * } + */ + JSONObject receiveTaskStatusMes(JSONObject jo); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/ResultTaskConfirmMesDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/ResultTaskConfirmMesDto.java new file mode 100644 index 0000000..b9ac182 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/dto/ResultTaskConfirmMesDto.java @@ -0,0 +1,139 @@ +package org.nl.wms.ext.mes.service.dto; + +import com.alibaba.fastjson.JSONArray; +import lombok.Builder; +import lombok.Data; + +@Data +public class ResultTaskConfirmMesDto { + + /* + * 方法 + */ + private String method; + + /* + * 账号 + */ + private String account; + + /* + * 密码 + */ + private String password; + + /* + * 版本 + */ + private String version; + + /* + * 模块 + */ + private JSONArray modules; + + /* + * mac + */ + private String mac; + + /* + * 语言 + */ + private String lang; + + /* + * 是否debug + */ + private boolean is_debug; + + /* + * 表单 + */ + private String platform; + + /* + * session + */ + private String session; + + public String getMethod() { + return "ServicesCUS.Module_CUS.CUS_AcceptAGVReturnInformation"; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getAccount() { + return "DS"; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getPassword() { + return "DS"; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getVersion() { + return ""; + } + + public void setVersion(String version) { + this.version = version; + } + + public JSONArray getModules() { + return new JSONArray(); + } + + public void setModules(JSONArray modules) { + this.modules = modules; + } + + public String getMac() { + return ""; + } + + public void setMac(String mac) { + this.mac = mac; + } + + public String getLang() { + return "zh_CN"; + } + + public void setLang(String lang) { + this.lang = lang; + } + + public boolean getIs_debug() { + return true; + } + + public void setIs_debug(boolean is_debug) { + this.is_debug = is_debug; + } + + public String getPlatform() { + return "web"; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public String getSession() { + return ""; + } + + public void setSession(String session) { + this.session = session; + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java index fe5d0a6..c778b88 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java @@ -101,7 +101,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { jsonErro.put("TaskCode", jsonItem.getString("TaskCode")); jsonErro.put("ReturnStatus", 1); jsonErro.put("ReturnInfo", json.getString("message")); - jsonErro.put("ReturnCount", ""); + jsonErro.put("ReturnCount", null); jsonErro.put("MsgTime", DateUtil.now()); erroList.add(jsonErro); } else { @@ -132,8 +132,8 @@ public class MesToWmsServiceImpl implements MesToWmsService { JSONObject jsonErro = new JSONObject(); jsonErro.put("TaskCode",json.getString("task_code")); jsonErro.put("ReturnStatus",1); - jsonErro.put("ReturnInfo",json.getString("message")); - jsonErro.put("ReturnCount", ""); + jsonErro.put("ReturnInfo","3.不能立即派送" + json.getString("message")); + jsonErro.put("ReturnCount", null); jsonErro.put("MsgTime", DateUtil.now()); erroList.add(jsonErro); } @@ -150,8 +150,8 @@ public class MesToWmsServiceImpl implements MesToWmsService { JSONObject jsonObject = new JSONObject(); jsonObject.put("TaskCode",json.getString("TaskCode")); jsonObject.put("ReturnStatus",0); - jsonObject.put("ReturnInfo",""); - jsonObject.put("ReturnCount",""); + jsonObject.put("ReturnInfo","1.AVG可立即执行任务"); + jsonObject.put("ReturnCount",null); jsonObject.put("MsgTime",DateUtil.now()); resultAllList.add(jsonObject); } @@ -243,7 +243,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { .findFirst().orElse(null); if (ObjectUtil.isEmpty(startPoint)) { result.put("is_erro",RegionEnum.IS_NOTANDYES.code("是")); - result.put("message","取货点位【"+jsonItem.getString("PickingLocation")+"】在LMS系统不存在或未启用!"); + result.put("message","4.取货点位【"+jsonItem.getString("PickingLocation")+"】在LMS系统不存在或未启用!"); return result; } @@ -253,7 +253,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { .findFirst().orElse(null); if (ObjectUtil.isEmpty(nextPoint)) { result.put("is_erro",RegionEnum.IS_NOTANDYES.code("是")); - result.put("message","放货点位【"+jsonItem.getString("PlacedLocation")+"】在LMS系统不存在或未启用!"); + result.put("message","4.放货点位【"+jsonItem.getString("PlacedLocation")+"】在LMS系统不存在或未启用!"); return result; } @@ -261,7 +261,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { String task_code = ifTaskRegion(startPoint.getRegion_code(), nextPoint.getRegion_code()); if (ObjectUtil.isEmpty(task_code)) { result.put("is_erro",RegionEnum.IS_NOTANDYES.code("是")); - result.put("message","请检查LMS任务配置是否存在!"); + result.put("message","5.请检查LMS任务配置是否存在!"); return result; } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java index 97fe2d8..9b4db20 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java @@ -1,7 +1,19 @@ package org.nl.wms.ext.mes.service.impl; +import cn.hutool.core.util.StrUtil; +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.system.service.param.ISysParamService; +import org.nl.system.service.param.impl.SysParamServiceImpl; import org.nl.wms.ext.mes.service.WmsToMesService; +import org.nl.wms.ext.mes.service.dto.ResultTaskConfirmMesDto; +import org.nl.wms.sch.region.enums.RegionEnum; +import org.nl.wms.sch.task.service.dao.SchBaseTask; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; /** @@ -13,4 +25,73 @@ import org.springframework.stereotype.Service; @Service public class WmsToMesServiceImpl implements WmsToMesService { + /** + * 系统参数服务 + */ + @Autowired + private ISysParamService iSysParamService; + + @Override + public JSONObject receiveTaskStatusMesData(SchBaseTask task) { + /* + * 组织数据 + */ + JSONObject result = new JSONObject(); + // 头 header + ResultTaskConfirmMesDto resultTaskConfirmMesDto = new ResultTaskConfirmMesDto(); + result.put("header", JSONObject.parseObject(JSON.toJSONString(resultTaskConfirmMesDto))); + + // 返回任务 content + JSONObject content = new JSONObject(); + // 任务号 + content.put("TaskCode", task.getTask_code()); + // AGV车号 + content.put("AGVCode", task.getCar_no()); + // 终点 + content.put("ArrivedLocation", task.getPoint_code2()); + // 是否到达终点 + content.put("IsPlacedLocation", 1); + result.put("content",content); + + // 通知mes任务完成 + return receiveTaskStatusMes(result); + } + + @Override + public JSONObject receiveTaskStatusMes(JSONObject jo) { + log.info("receiveTaskStatusMes接口输入参数为:-------------------" + jo.toString()); + + String is_connect_mes = iSysParamService.findByCode("IS_CONNECT_MES").getValue(); + JSONObject result = new JSONObject(); + if (StrUtil.equals("0", is_connect_mes)) { + result.put("status", HttpStatus.OK.value()); + result.put("message", "下发成功,但未连接MES!"); + result.put("data", new JSONObject()); + return result; + } + + // 获取mesurl + String url = iSysParamService.findByCode("MES_URL").getValue(); + String api = "CamstarApi/LMSUnPackage"; + url = url + api; + + try { + String resultMsg = HttpRequest.post(url) + .body(String.valueOf(jo)) + .execute().body(); + result = JSONObject.parseObject(resultMsg); + log.info("receiveTaskStatusMes接口输出参数为:-------------------" + result.toString()); + + // 判断是否报错 + JSONObject content = result.getJSONObject("Content"); + if (content.getString("ReturnStatus").equals(RegionEnum.IS_NOTANDYES.code("是"))) { + throw new BadRequestException(content.getString("ReturnInfo")); + } + + } catch (Exception e) { + throw new BadRequestException("MES提示错误:" + e.getMessage()); + } + return result; + + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java index da204c6..1ff15f7 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java @@ -96,10 +96,6 @@ public abstract class AbstractTask { taskDto.setExt_task_uuid(task.getTask_id()); taskDto.setTask_code(task.getTask_code()); taskDto.setRoute_plan_code("normal"); - taskDto.setStart_device_code(task.getPoint_code1()); - taskDto.setNext_device_code(task.getPoint_code2()); - taskDto.setStart_device_code2(task.getPoint_code3()); - taskDto.setNext_device_code2(task.getPoint_code4()); taskDto.setVehicle_code(task.getVehicle_code()); taskDto.setVehicle_code2(task.getVehicle_code2()); this.setTask(task.getConfig_code(), taskDto); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KABDMTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KABDMTask.java new file mode 100644 index 0000000..03ab43d --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KABDMTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: AB区送模具到地面货架 + * @Date: 2024/9/24 + */ +@Component(value = "KABDMTask") +@TaskType("KABDMTask") +public class KABDMTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KDMABTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KDMABTask.java new file mode 100644 index 0000000..8c75ad9 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/KDMABTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: 地面货架送模具到AB区 + * @Date: 2024/9/24 + */ +@Component(value = "KDMABTask") +@TaskType("KDMABTask") +public class KDMABTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABCTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABCTask.java index e56a85b..6c4119c 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABCTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABCTask.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; import org.nl.common.exception.BadRequestException; import org.nl.common.utils.SecurityUtils; import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; 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; @@ -34,6 +35,9 @@ public class MABCTask extends AbstractTask { @Autowired private ISchBaseTaskconfigService taskConfigService; + @Autowired + private WmsToMesService wmsToMesService; + @Override public String create(JSONObject json) { SchBaseTask task = new SchBaseTask(); @@ -63,7 +67,7 @@ public class MABCTask extends AbstractTask { acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); acsTaskDto.setPriority(taskDao.getPriority()); - acsTaskDto.setTask_type(taskDao.getConfig_code()); + acsTaskDto.setTask_type("1"); return acsTaskDto; } @@ -119,6 +123,9 @@ public class MABCTask extends AbstractTask { taskObj.setFinished_type(taskFinishedType.getCode()); TaskUtils.setUpdateByType(taskObj, taskFinishedType); taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); } @Transactional(rollbackFor = Exception.class) diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABDMTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABDMTask.java new file mode 100644 index 0000000..6d5a8d0 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABDMTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: AB区送满托盘到地面货架 + * @Date: 2024/9/24 + */ +@Component(value = "MABDMTask") +@TaskType("MABDMTask") +public class MABDMTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABGPTHJTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABGPTHJTask.java new file mode 100644 index 0000000..bc10915 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MABGPTHJTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: AB区送满托盘到钢平台货架 + * @Date: 2024/9/24 + */ +@Component(value = "MABGPTHJTask") +@TaskType("MABGPTHJTask") +public class MABGPTHJTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MBZCPTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MBZCPTask.java new file mode 100644 index 0000000..7af3d67 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MBZCPTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: 包装线下料送满托到拆盘机 + * @Date: 2024/9/24 + */ +@Component(value = "MBZCPTask") +@TaskType("MBZCPTask") +public class MBZCPTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MCDTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MCDTask.java new file mode 100644 index 0000000..b76a5dd --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MCDTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: C区送满托盘到D区 + * @Date: 2024/9/24 + */ +@Component(value = "MCDTask") +@TaskType("MCDTask") +public class MCDTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDDMTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDDMTask.java new file mode 100644 index 0000000..cbecaa8 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDDMTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: D区送满托盘到地面货架 + * @Date: 2024/9/24 + */ +@Component(value = "MDDMTask") +@TaskType("MDDMTask") +public class MDDMTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDMCPTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDMCPTask.java new file mode 100644 index 0000000..92d3cf3 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MDMCPTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: 地面货架送满托盘到拆盘输送线 + * @Date: 2024/9/24 + */ +@Component(value = "MDMCPTask") +@TaskType("MDMCPTask") +public class MDMCPTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJABTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJABTask.java new file mode 100644 index 0000000..e5a218a --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJABTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: 钢平台货架送满托到AB生产区 + * @Date: 2024/9/24 + */ +@Component(value = "MGPTHJABTask") +@TaskType("MGPTHJABTask") +public class MGPTHJABTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJCPTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJCPTask.java new file mode 100644 index 0000000..d8ea1b5 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/MGPTHJCPTask.java @@ -0,0 +1,139 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.config.IdUtil; +import org.nl.wms.ext.mes.service.WmsToMesService; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.sch.task_manage.GeneralDefinition; +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.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: lxy + * @Description: 钢平台货架送满托到拆盘机 + * @Date: 2024/9/24 + */ +@Component(value = "MGPTHJCPTask") +@TaskType("MGPTHJCPTask") +public class MGPTHJCPTask extends AbstractTask { + @Autowired + private ISchBaseTaskService taskService; + + @Autowired + private ISchBaseTaskconfigService taskConfigService; + + @Autowired + private WmsToMesService wmsToMesService; + + @Override + public String create(JSONObject json) { + SchBaseTask task = new SchBaseTask(); + task.setTask_id(IdUtil.getStringId()); + task.setTask_code(json.getString("TaskCode")); + task.setTask_status(TaskStatus.CREATE.getCode()); + task.setConfig_code(json.getString("task_type")); + task.setPoint_code1(json.getString("PickingLocation")); + task.setPoint_code2(json.getString("PlacedLocation")); + task.setRequest_param(json.toString()); + task.setPriority(json.getString("Priority")); + task.setCreate_id(SecurityUtils.getCurrentUserId()); + task.setCreate_name(SecurityUtils.getCurrentNickName()); + task.setCreate_time(DateUtil.now()); + taskService.save(task); + return task.getTask_id(); + } + + @Override + public AcsTaskDto sendAcsParam(String taskId) { + SchBaseTask taskDao = taskService.getById(taskId); + + // 组织下发给acs的数据 + AcsTaskDto acsTaskDto = new AcsTaskDto(); + acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); + acsTaskDto.setTask_code(taskDao.getTask_code()); + acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); + acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); + acsTaskDto.setPriority(taskDao.getPriority()); + acsTaskDto.setTask_type("1"); + + return acsTaskDto; + } + + @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("该任务已取消!"); + } + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + TaskUtils.setUpdateByAcs(taskObj); + taskService.updateById(taskObj); + } + if (status.equals(TaskStatus.FINISHED)) { + this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + if (status.equals(TaskStatus.CANCELED)) { + this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); + } + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Override + public void cancel(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); + } + + @Transactional(rollbackFor = Exception.class) + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + + // 通知mes任务完成 + wmsToMesService.receiveTaskStatusMesData(taskObj); + } + + @Transactional(rollbackFor = Exception.class) + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } +}