From d5d20f04ef9435e539aa815e89fd7f94d6dd2ed8 Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Sun, 30 Jul 2023 15:42:52 +0800 Subject: [PATCH] =?UTF-8?q?opt:=20=E4=B8=8EACS=E9=80=9A=E4=BF=A1=E4=B8=8E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=94=E5=9B=9E=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/ext/acs/service/WmsToAcsService.java | 13 ++++ .../wms/ext/acs/service/dto/ResultForAcs.java | 44 +++++++++++ .../service/dto/to/acs/PutActionRequest.java | 1 + .../acs/service/impl/AcsToWmsServiceImpl.java | 10 +-- .../acs/service/impl/WmsToAcsServiceImpl.java | 33 +++++++- .../service/ISysInteractRecordService.java | 4 + .../impl/SysInteractRecordServiceImpl.java | 17 +++++ .../controller/PdmBdWorkorderController.java | 9 +++ .../service/IPdmBdWorkorderService.java | 6 ++ .../impl/PdmBdWorkorderServiceImpl.java | 57 ++++++++++++++ .../nl/wms/sch/task_manage/AbstractTask.java | 5 +- .../sch/task_manage/GeneralDefinition.java | 5 ++ .../nl/wms/sch/task_manage/task/AcsUtil.java | 76 +++++-------------- .../task_manage/task/tasks/fj/FJMKTask.java | 23 ++++-- .../task_manage/task/tasks/fj/FJQKTask.java | 1 + .../task_manage/task/tasks/fj/FJQLTask.java | 7 ++ .../main/java/org/nl/wms/util/PointUtils.java | 4 + .../test/java/org/nl/point/PointCreate.java | 24 ++++++ .../src/views/wms/pdm/workerorder/index.vue | 23 +++++- .../wms/pdm/workerorder/pdmBdWorkorder.js | 10 ++- 20 files changed, 298 insertions(+), 74 deletions(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/ResultForAcs.java 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 dab2890..a62cec5 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,9 +1,22 @@ 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.pdm.workorder.service.dao.PdmBdWorkorder; + +import java.util.Map; + /** * @Author: lyd * @Description: Wms请求Acs * @Date: 2023/6/30 */ public interface WmsToAcsService { + + /** + * 下发工单 + * @param workorder + * @return + */ + ResultForAcs order(PdmBdWorkorder workorder); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/ResultForAcs.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/ResultForAcs.java new file mode 100644 index 0000000..a578c53 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/ResultForAcs.java @@ -0,0 +1,44 @@ +package org.nl.wms.ext.acs.service.dto; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.http.HttpStatus; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +/** + * @Author: lyd + * @Description: 统一接口返回 - 请求ACS返回的数据类型 + * @Date: 2023/7/28 + */ +@Data +public class ResultForAcs { + private int status; + private String message; + private String timestamp; + private JSONObject data; + + public static ResultForAcs requestRefuse(String message) { + ResultForAcs result = new ResultForAcs(); + result.setStatus(HttpStatus.HTTP_BAD_REQUEST); + result.setMessage(message); + result.setTimestamp(DateUtil.now()); + return result; + } + + public static ResultForAcs requestOk() { + ResultForAcs result = new ResultForAcs(); + result.setStatus(HttpStatus.HTTP_OK); + result.setMessage("请求成功"); + result.setTimestamp(DateUtil.now()); + return result; + } + + public static ResultForAcs requestOk(String message, JSONObject data) { + ResultForAcs result = new ResultForAcs(); + result.setStatus(HttpStatus.HTTP_OK); + result.setMessage(message); + result.setTimestamp(DateUtil.now()); + result.setData(data); + return result; + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/PutActionRequest.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/PutActionRequest.java index c5cc3ce..1fa8b43 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/PutActionRequest.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/PutActionRequest.java @@ -18,6 +18,7 @@ public class PutActionRequest extends BaseRequest { * 设备号 */ private String device_code; + private String vehicle_type; /** * 信号数据 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 41d0937..f1c77e0 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 @@ -554,7 +554,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { try { abstractTask.updateTaskStatus(taskCode, status); } catch (Exception e) { - log.error("任务状态更新失败:{}", message); + log.error("任务状态更新失败: {}", message); return BaseResponse.responseError(requestNo, "任务:[" + taskCode + "]状态更新失败," + message); } return BaseResponse.responseOk(requestNo, "任务状态反馈成功!"); @@ -587,7 +587,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { String requestNo = actionRequest.getRequestNo(); String deviceCode = actionRequest.getDevice_code(); List list = actionRequest.getList(); -// String vehicleType = actionRequest.getVehicle_type(); + String vehicleType = actionRequest.getVehicle_type(); if (deviceCode == null) { return BaseResponse.responseError(requestNo, "设备编码不能为空"); } @@ -610,9 +610,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { && move.equals(PointStatusEnum.EMPTY_VEHICLE.getCode())) || (pointStatus.equals(move))) { // 不做操作 return BaseResponse.responseOk(requestNo); } -// if (vehicleType != null) { -// schBasePoint.setVehicle_type(vehicleType); -// } + if (vehicleType != null) { + schBasePoint.setVehicle_type(vehicleType); + } schBasePoint.setPoint_status(move); PointUtils.setUpdateByAcs(schBasePoint); pointService.updateById(schBasePoint); 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 87d87cb..75d467f 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,15 +1,46 @@ 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.record.service.ISysInteractRecordService; +import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; +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.ArrayList; +import java.util.List; + /** * @Author: lyd - * @Description: + * @Description: WMS请求ACS - 业务开发 * @Date: 2023/6/30 */ @Slf4j @Service public class WmsToAcsServiceImpl implements WmsToAcsService { + @Autowired + private ISysInteractRecordService interactRecordService; + @Override + public ResultForAcs order(PdmBdWorkorder workorder) { + String api = "api/wms/order"; + List list = new ArrayList<>(); + list.add(workorder); + ResultForAcs resultForAcs = ResultForAcs.requestOk(); + try { + resultForAcs = AcsUtil.notifyAcs(api, list); + } catch (Exception e) { + log.error(api + ": {}", e.getMessage()); + resultForAcs.setTimestamp(DateUtil.now()); + resultForAcs.setStatus(HttpStatus.HTTP_BAD_REQUEST); + resultForAcs.setMessage(e.getMessage()); + } + // 记录日志 + interactRecordService.saveRecord(workorder, resultForAcs, GeneralDefinition.LMS_ACS); + return resultForAcs; + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/ISysInteractRecordService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/ISysInteractRecordService.java index bfdfc1d..fe92fdf 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/ISysInteractRecordService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/ISysInteractRecordService.java @@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.nl.common.domain.query.PageQuery; +import org.nl.wms.ext.acs.service.dto.ResultForAcs; import org.nl.wms.ext.acs.service.dto.to.BaseResponse; import org.nl.wms.ext.record.service.dao.SysInteractRecord; +import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; import java.util.Map; import java.util.Set; @@ -47,4 +49,6 @@ public interface ISysInteractRecordService extends IService { * 创建记录 */ void saveRecord(Object request, BaseResponse response, String direction); + + void saveRecord(PdmBdWorkorder workorder, ResultForAcs resultForAcs, String lmsAcs); } 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 8882582..3ced7c8 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 @@ -11,10 +11,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; 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.record.service.ISysInteractRecordService; import org.nl.wms.ext.record.service.dao.mapper.SysInteractRecordMapper; import org.nl.wms.ext.record.service.dao.SysInteractRecord; +import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -77,4 +79,19 @@ public class SysInteractRecordServiceImpl extends ServiceImpl(HttpStatus.OK); } + + @PostMapping("/submits") + @Log("工单下发") + @ApiOperation("工单下发") + public ResponseEntity submits(@RequestBody PdmBdWorkorder entity){ + pdmBdWorkorderService.submits(entity); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java index b4d71f6..fed29d7 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java @@ -49,4 +49,10 @@ public interface IPdmBdWorkorderService extends IService { PdmBdWorkorder getDeviceProductionTask(String deviceCode); PdmBdWorkorder getByCode(String orderCode); + + /** + * 工单下发 + * @param entity + */ + void submits(PdmBdWorkorder entity); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java index 3d1bbff..9161ccc 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java @@ -2,6 +2,8 @@ package org.nl.wms.pdm.workorder.service.impl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.http.HttpStatus; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -12,15 +14,21 @@ import org.nl.common.domain.query.PageQuery; import org.nl.common.exception.BadRequestException; import org.nl.common.utils.CodeUtil; import org.nl.common.utils.SecurityUtils; +import org.nl.system.service.notice.ISysNoticeService; +import org.nl.wms.ext.acs.service.WmsToAcsService; +import org.nl.wms.ext.acs.service.dto.ResultForAcs; import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; import org.nl.wms.pdm.workorder.service.dao.mapper.PdmBdWorkorderMapper; import org.nl.wms.pdm.workorder.service.dto.PdmBdWorkorderQuery; import org.nl.wms.sch.task_manage.GeneralDefinition; +import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum; +import org.nl.wms.util.TaskUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Map; import java.util.Set; /** @@ -35,6 +43,11 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl queryAll(PdmBdWorkorderQuery query, PageQuery page){ IPage pages = new Page<>(page.getPage() + 1, page.getSize()); @@ -96,4 +109,48 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl lam = new QueryWrapper().lambda(); + lam.eq(PdmBdWorkorder::getPoint_code, entity.getPoint_code()) + .eq(PdmBdWorkorder::getWorkorder_status, WorkOrderStatusEnum.PRODUCING.getCode()) + .eq(PdmBdWorkorder::getIs_delete, false); + PdmBdWorkorder bdWorkorder = pdmBdWorkorderMapper.selectOne(lam); + if (ObjectUtil.isNotEmpty(bdWorkorder)) { + throw new BadRequestException("该设备已有生产工单,不能重复下发"); + } + ResultForAcs resultForAcs = null; + try { + resultForAcs = wmsToAcsService.order(pdmBdWorkorder); + } catch (Exception e) { + log.error("工单下发异常:" + e.getMessage()); + // 通知 + noticeService.createNotice("工单下发失败: " + e.getMessage(), "工单下发失败: " + + pdmBdWorkorder.getWorkorder_code(), NoticeTypeEnum.EXCEPTION.getCode()); + throw new BadRequestException("工单下发失败"); + } + if (resultForAcs.getStatus() != HttpStatus.HTTP_OK) { + // 不成功 + noticeService.createNotice(resultForAcs.getMessage(), "工单下发失败: " + pdmBdWorkorder.getWorkorder_code(), + NoticeTypeEnum.EXCEPTION.getCode()); + throw new BadRequestException("工单下发失败"); + } + // 修改工单数据 + pdmBdWorkorder.setWorkorder_status(WorkOrderStatusEnum.ISSUED.getCode()); + TaskUtils.setWorkOrderUpdateByAcs(pdmBdWorkorder); + pdmBdWorkorderMapper.updateById(pdmBdWorkorder); + } + } 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 b275391..e1dd81c 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 @@ -7,6 +7,7 @@ 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.ext.acs.service.dto.ResultForAcs; import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; import org.nl.wms.sch.point.service.ISchBasePointService; @@ -57,7 +58,7 @@ public abstract class AbstractTask { * @author ldjun * @created 2020年6月12日 下午5:52:28 */ - protected JSONObject renotifyAcs(SchBaseTask task) { + protected ResultForAcs renotifyAcs(SchBaseTask task) { Assert.notNull(task); List taskList = new ArrayList<>(); taskList.add(task); @@ -70,7 +71,7 @@ public abstract class AbstractTask { * @author ldjun * @created 2020年6月12日 下午5:52:28 */ - protected JSONObject renotifyAcs(List taskList) { + protected ResultForAcs renotifyAcs(List taskList) { //1、获取任务 //2、根据任务配置补全任务 //3、下发 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 21fa657..2fd17fe 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 @@ -62,4 +62,9 @@ public class GeneralDefinition { public static final String UPPER_CONVEYOR_LINE = "3"; /** 下输送线 */ public static final String LOWER_CONVEYOR_LINE = "4"; + // 参数名称 + /** 是否连接 */ + public static final String IS_CONNECT_ACS = "is_connect_acs"; + /** ACS路径 */ + public static final String ACS_URL = "acs_url"; } 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 fd5c9a6..c472d52 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 @@ -1,105 +1,67 @@ - package org.nl.wms.sch.task_manage.task; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpRequest; -import com.alibaba.fastjson.JSONArray; +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.record.service.ISysInteractRecordService; -import org.nl.wms.ext.record.service.impl.SysInteractRecordServiceImpl; -import org.nl.wms.sch.task_manage.AcsTaskDto; +import org.nl.wms.ext.acs.service.dto.ResultForAcs; import org.nl.wms.sch.task_manage.GeneralDefinition; -import org.springframework.http.HttpStatus; import java.util.List; /** - * ACS连接工具类: + * ACS连接工具类: 不允许直接操作结果,将其封装到ResultForAcs,由实现类操作 */ @Slf4j public class AcsUtil { /** - * 统一多数据入口 + * 统一多数据入口: 默认执行的参数都是jsonArray * @param api * @param list * @return * @param */ - public static JSONObject notifyAcs(String api, List list) { + public static ResultForAcs notifyAcs(String api, List list) { SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class); + // list转JSONArray + String s = JSON.toJSONString(list); //判断是否连接ACS系统 - Param isConnectAcs = sysParamService.findByCode("IS_CONNECT_ACS"); + Param isConnectAcs = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_ACS); if (ObjectUtil.isEmpty(isConnectAcs)) { - throw new BadRequestException("参数表中:IS_CONNECT_ACS不存在"); + throw new BadRequestException("参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在"); } String isConnect = isConnectAcs.getValue(); - JSONObject result = new JSONObject(); - if (StrUtil.equals(GeneralDefinition.NO, isConnect)) { - result.put("status", HttpStatus.BAD_REQUEST.value()); - result.put("message", "未连接ACS!"); - result.put("data", new JSONObject()); - return result; - } //ACS地址:127.0.0.1:8010 - Param acsUrlObj = sysParamService.findByCode("ACS_URL"); + Param acsUrlObj = sysParamService.findByCode(GeneralDefinition.ACS_URL); if (ObjectUtil.isEmpty(acsUrlObj)) { - throw new BadRequestException("参数表中:ACS_URL不存在"); + throw new BadRequestException("参数表中:" + GeneralDefinition.ACS_URL + "不存在"); } String acsUrl = acsUrlObj.getValue(); - String url = acsUrl + api; - log.info("下发acs任务的参数为:{}", list.toString()); - try { - String resultMsg = HttpRequest.post(url) - .body(String.valueOf(list)) - .execute().body(); - result = JSONObject.parseObject(resultMsg); - } catch (Exception e) { - String msg = e.getMessage(); - //ConnectException: Connection refused: connect - //网络不通 - log.error("连接失败:{}", msg); - result.put("status", HttpStatus.BAD_REQUEST); - result.put("message", "网络不通,操作失败!"); - result.put("data", new JSONObject()); - } - return result; - } - public static JSONObject notifyAcs(String api, T object) { - //判断是否连接ACS系统 - String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("IS_CONNECT_ACS").getValue(); - JSONObject result = new JSONObject(); + JSONObject result; if (StrUtil.equals(GeneralDefinition.NO, isConnect)) { - result.put("status", HttpStatus.BAD_REQUEST.value()); - result.put("message", "未连接ACS!"); - result.put("data", new JSONObject()); - return result; + return ResultForAcs.requestRefuse("未连接ACS!"); } - //ACS地址:127.0.0.1:8010 - String acsUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("ACS_URL").getValue(); - String url = acsUrl + api; - log.info("下发acs任务的参数为:{}", object.toString()); + log.info("下发acs任务的参数为:{}", list.toString()); + ResultForAcs resultForAcs; try { String resultMsg = HttpRequest.post(url) - .body(String.valueOf(object)) + .body(s) .execute().body(); result = JSONObject.parseObject(resultMsg); + resultForAcs = JSONObject.toJavaObject(result, ResultForAcs.class); } catch (Exception e) { String msg = e.getMessage(); - //ConnectException: Connection refused: connect //网络不通 log.error("连接失败:{}", msg); - result.put("status", HttpStatus.BAD_REQUEST); - result.put("message", "网络不通,操作失败!"); - result.put("data", new JSONObject()); + return ResultForAcs.requestRefuse("网络不通,操作失败!"); } - // 记录交互表 - return result; + 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 3986fc3..f8d2c09 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 @@ -73,6 +73,7 @@ public class FJMKTask extends AbstractTask { String requestParam = task.getRequest_param();// 任务的其他数据 JSONObject jsonObject = JSONObject.parseObject(requestParam); // 找终点 + /** 包装位 */ SchBasePoint packagePoint = findNextPoint(nextRegionStr, jsonObject); if (ObjectUtil.isEmpty(packagePoint)) { task.setRemark("包装线不可用!"); @@ -87,6 +88,7 @@ public class FJMKTask extends AbstractTask { // 1 获取点位相应数量 // 2 获取库存数量 // 3 木托盘需要多少块 + /** 覆膜机木托盘位 */ SchBasePoint LaminatePoint = findStartPoint(startRegionStr, jsonObject); if (ObjectUtil.isEmpty(LaminatePoint)) { task.setRemark("覆膜区不可用!"); @@ -101,7 +103,7 @@ public class FJMKTask extends AbstractTask { // 设置终点并修改创建成功状态 task.setPoint_code3(LaminatePoint.getParent_point_code()); task.setPoint_code4(task.getPoint_code1()); - task.setVehicle_code2(vehicleCode); + task.setVehicle_code2(vehicleCode); // 覆膜机下的木托盘编码 task.setTask_status(TaskStatus.CREATED.getCode()); task.setRemark(""); taskService.updateById(task); @@ -109,6 +111,7 @@ public class FJMKTask extends AbstractTask { packagePoint.setIng_task_code(task.getTask_code()); PointUtils.setUpdateByAcs(packagePoint); pointService.updateById(packagePoint); + // 覆膜机对接位 SchBasePoint basePoint = pointService.getById(LaminatePoint.getParent_point_code()); basePoint.setIng_task_code(task.getTask_code()); basePoint.setVehicle_code(vehicleCode); @@ -283,15 +286,23 @@ public class FJMKTask extends AbstractTask { SchBasePoint fjcPointObj = pointService.getById(fjcPoint); if (ObjectUtil.isNotEmpty(bzxPointObj)) { // 包装位: 解锁 + PointUtils.setUpdateByType(bzxPointObj, taskFinishedType); PointUtils.clearPoint(bzxPointObj); // 覆膜位: 解锁 . 清空 + PointUtils.setUpdateByType(fmPointObj, taskFinishedType); PointUtils.clearPoint(fmPointObj); - // 机械手对接位: 赋值 - fjcPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode()); - fjcPointObj.setVehicle_qty(1); - fjcPointObj.setVehicle_type(taskObj.getVehicle_type()); + // 分拣机械手: 清空 PointUtils.setUpdateByType(fjcPointObj, taskFinishedType); - pointService.updateById(fjcPointObj); + PointUtils.clearPoint(fjcPointObj); + if (ObjectUtil.isNotEmpty(fmPointObj)) { + // 机械手对接位: 赋值 + fjcPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode()); + fjcPointObj.setVehicle_qty(1); + fjcPointObj.setVehicle_type(taskObj.getVehicle_type()); + fjcPointObj.setVehicle_code(taskObj.getVehicle_code2()); // 拿过来的载具编码 + PointUtils.setUpdateByType(fjcPointObj, taskFinishedType); + pointService.updateById(fjcPointObj); + } // 组盘设置已经解绑 SchBaseVehiclematerialgroup vehicleMaterialGroupObj = vehiclematerialgroupService.getById(taskObj.getGroup_id()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQKTask.java index 22e724e..1df8f2d 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQKTask.java @@ -86,6 +86,7 @@ public class FJQKTask extends AbstractTask { task.setTask_status(TaskStatus.CREATED.getCode()); // 生产木托盘编码 String vehicleCode = CodeUtil.getNewCode("VEHICLE_CODE"); + // todo: 未确认是否放在1还是2,目前规定四点任务空盘的载具编码是2 task.setVehicle_code(vehicleCode); task.setRemark(""); task.setGroup_id(point.getGroup_id()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java index a9c1404..4497489 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java @@ -21,6 +21,7 @@ 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.NoticeTypeEnum; +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; @@ -191,6 +192,12 @@ public class FJQLTask extends AbstractTask { processTracking.setProcess_location(endPoint); processTracking.setRecord_time(DateUtil.now()); processTrackingService.create(processTracking); + // 终点设置对应的参数 + endPointObj.setVehicle_code(startPointObj.getVehicle_code()); + endPointObj.setVehicle_type(startPointObj.getVehicle_type()); + endPointObj.setPoint_status(PointStatusEnum.FULL_POINT.getCode()); + PointUtils.setUpdateByType(endPointObj, taskFinishedType); + pointService.updateById(endPointObj); } // 任务完成 taskObj.setTask_status(TaskStatus.FINISHED.getCode()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java index 239b725..0d52fa1 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java @@ -1,6 +1,7 @@ package org.nl.wms.util; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import org.nl.common.utils.SecurityUtils; import org.nl.config.SpringContextHolder; @@ -39,6 +40,9 @@ public class PointUtils { * @param point */ public static void clearPoint(SchBasePoint point) { + if (ObjectUtil.isEmpty(point)) { + return; // 空直接退出 + } SchBasePointServiceImpl pointService = SpringContextHolder.getBean(SchBasePointServiceImpl.class); point.setPoint_status(PointStatusEnum.EMPTY_POINT.getCode()); point.setVehicle_type(""); diff --git a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/PointCreate.java b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/PointCreate.java index 41c98c7..363ac9f 100644 --- a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/PointCreate.java +++ b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/PointCreate.java @@ -208,4 +208,28 @@ public class PointCreate { } pointService.saveBatch(pointList); } + @Test + void test07() { // 码垛机械手 + // 创建YJ01JLW01 + List pointList = new ArrayList<>(); + for (int i = 1; i <= 8; i++) { + String pointName = "压制不合格位0"; + String pointCode = "YZBHGW0"; + String papointCode = "YJ0"; + pointName = pointName + i; + pointCode = pointCode + i; + papointCode = papointCode + i; + SchBasePoint point = new SchBasePoint(); + point.setPoint_code(pointCode); + point.setPoint_name(pointName); + point.setRegion_code("YZ"); + point.setRegion_name("压制区域"); + point.setPoint_type("3"); + point.setParent_point_code(papointCode); + point.setIs_has_workder(false); + point.setIs_auto(false); + pointList.add(point); + } + pointService.saveBatch(pointList); + } } diff --git a/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue b/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue index f282fc2..8c14f22 100644 --- a/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue +++ b/lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue @@ -60,7 +60,19 @@ - + + + 开工 + + { + this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS) + this.crud.toQuery() + }) + }, } } diff --git a/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js b/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js index a47b51b..c32297c 100644 --- a/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js +++ b/lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js @@ -24,4 +24,12 @@ export function edit(data) { }) } -export default { add, edit, del } +export function submits(param) { + return request({ + url: 'api/pdmBdWorkorder/submits', + method: 'post', + data: param + }) +} + +export default { add, edit, del, submits }