From 16188764771553b6f6844ce292b94f3f8a8da98a Mon Sep 17 00:00:00 2001 From: songxiaopeng <1393756821@qq.com> Date: Tue, 14 May 2024 15:09:43 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E5=A2=9E=E5=8A=A0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/controller/IotToWmsController.java | 30 +++ .../nl/wms/ext/service/IotToWmsService.java | 12 +- .../wms/ext/service/dto/to/iot/BendReq.java | 16 ++ .../ext/service/impl/IotToWmsServiceImpl.java | 86 ++++++- .../ISchBaseVehiclematerialgroupService.java | 3 + .../SchBaseVehiclematerialgroupMapper.java | 4 + .../SchBaseVehiclematerialgroupMapper.xml | 8 + ...chBaseVehiclematerialgroupServiceImpl.java | 6 + .../task_manage/task/tasks/fj/FJHKTask.java | 214 ++++++++++++++++++ .../task_manage/task/tasks/fj/FJJKTask.java | 7 +- 10 files changed, 378 insertions(+), 8 deletions(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/dto/to/iot/BendReq.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJHKTask.java diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/IotToWmsController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/IotToWmsController.java index 5d50a66..17f6a88 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/IotToWmsController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/controller/IotToWmsController.java @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.common.logging.annotation.Log; import org.nl.wms.ext.service.AcsToWmsService; import org.nl.wms.ext.service.IotToWmsService; +import org.nl.wms.ext.service.dto.to.iot.BendReq; import org.nl.wms.ext.service.dto.to.iot.IotOrdersReq; import org.nl.wms.ext.service.dto.to.iot.IotPartsReq; import org.nl.wms.ext.service.dto.to.iot.SortingReq; @@ -67,5 +68,34 @@ public class IotToWmsController { return new ResponseEntity<>(iotToWmsService.sortingCallMaterial(sortingReq), HttpStatus.OK); } + @PostMapping("/sortingBack") + @Log("分拣系统下发回库请求") + @ApiOperation("分拣系统下发回库请求") + public ResponseEntity sortingBack(@RequestBody SortingReq sortingReq) { + return new ResponseEntity<>(iotToWmsService.sortingBack(sortingReq), HttpStatus.OK); + } + + @PostMapping("/sortingBackMaterial") + @Log("分拣系统下发回库托盘物料信息") + @ApiOperation("分拣系统下发回库托盘物料信息") + public ResponseEntity sortingBackMaterial(@RequestBody SortingReq sortingReq) { + return new ResponseEntity<>(iotToWmsService.sortingBackMaterial(sortingReq), HttpStatus.OK); + } + + @PostMapping("/autoBendMaterialInfo") + @Log("自动折弯系统查询物料库存") + @ApiOperation("自动折弯系统查询物料库存") + public ResponseEntity autoBendMaterialInfo(@RequestBody BendReq bendReq) { + return new ResponseEntity<>(iotToWmsService.autoBendMaterialInfo(bendReq), HttpStatus.OK); + } + + + @PostMapping("/autoBendCallMaterial") + @Log("自动折弯上料") + @ApiOperation("自动折弯上料") + public ResponseEntity autoBendCallMaterial(@RequestBody BendReq bendReq) { + return new ResponseEntity<>(iotToWmsService.autoBendCallMaterial(bendReq), HttpStatus.OK); + } + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/IotToWmsService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/IotToWmsService.java index 0b98941..26a5094 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/IotToWmsService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/IotToWmsService.java @@ -2,9 +2,11 @@ package org.nl.wms.ext.service; import com.alibaba.fastjson.JSONObject; import org.nl.wms.ext.service.dto.to.BaseResponse; +import org.nl.wms.ext.service.dto.to.iot.BendReq; import org.nl.wms.ext.service.dto.to.iot.IotOrdersReq; import org.nl.wms.ext.service.dto.to.iot.IotPartsReq; import org.nl.wms.ext.service.dto.to.iot.SortingReq; +import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.materialBind.service.dao.MaterialVehicleBind; import java.util.List; @@ -21,7 +23,15 @@ public interface IotToWmsService { BaseResponse orders(IotOrdersReq iotOrdersReq); - List sortingMaterialInfo(SortingReq sortingReq); + List sortingMaterialInfo(SortingReq sortingReq); BaseResponse sortingCallMaterial(SortingReq sortingReq); + + BaseResponse sortingBack(SortingReq sortingReq); + + BaseResponse sortingBackMaterial(SortingReq sortingReq); + + List autoBendMaterialInfo(BendReq bendReq); + + BaseResponse autoBendCallMaterial(BendReq bendReq); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/dto/to/iot/BendReq.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/dto/to/iot/BendReq.java new file mode 100644 index 0000000..1af7a82 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/dto/to/iot/BendReq.java @@ -0,0 +1,16 @@ +package org.nl.wms.ext.service.dto.to.iot; + +import lombok.Data; + +/** + * @author songxiaopeng + */ +@Data +public class BendReq { + //订单号 + private String order; + //组盘ID + private String groupId; + //请求点位 + private String endDeviceCode; +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/IotToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/IotToWmsServiceImpl.java index 6d8a1c6..b31308e 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/IotToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/IotToWmsServiceImpl.java @@ -1,17 +1,24 @@ package org.nl.wms.ext.service.impl; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; +import org.nl.common.exception.BadRequestException; import org.nl.wms.ext.service.AcsToWmsService; import org.nl.wms.ext.service.IotToWmsService; import org.nl.wms.ext.service.dto.to.BaseResponse; +import org.nl.wms.ext.service.dto.to.iot.BendReq; import org.nl.wms.ext.service.dto.to.iot.IotOrdersReq; import org.nl.wms.ext.service.dto.to.iot.IotPartsReq; import org.nl.wms.ext.service.dto.to.iot.SortingReq; import org.nl.wms.pda.service.dao.vo.PdaResponseVo; +import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; +import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.materialBind.service.IMaterialVehicleBindService; import org.nl.wms.sch.materialBind.service.dao.MaterialVehicleBind; +import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum; +import org.nl.wms.sch.task_manage.enums.GroupStatusEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -31,6 +38,9 @@ public class IotToWmsServiceImpl implements IotToWmsService { @Autowired private IMaterialVehicleBindService materialVehicleBindService; + @Autowired + private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService; + @Override public BaseResponse acsApply(JSONObject param) { return acsToWmsService.acsApply(param); @@ -49,9 +59,11 @@ public class IotToWmsServiceImpl implements IotToWmsService { } @Override - public List sortingMaterialInfo(SortingReq sortingReq) { + public List sortingMaterialInfo(SortingReq sortingReq) { + //todo 现在是查询该订单下的所有组盘信息 + // 需确认是否只查询分拣后的物料 以及需要把组盘绑定的物料信息都查出来 String order = sortingReq.getOrder(); - return materialVehicleBindService.selectByOrder(order); + return schBaseVehiclematerialgroupService.selectByOrder(order); } @Override @@ -59,8 +71,74 @@ public class IotToWmsServiceImpl implements IotToWmsService { JSONObject param = new JSONObject(); param.put("taskCode", IdUtil.getSnowflake(1, 1).nextIdStr()); param.put("taskType", "FJSLTask"); - param.put("start_device_code",sortingReq.getStartDeviceCode()); - param.put("end_device_code",sortingReq.getEndDeviceCode()); + param.put("start_device_code", sortingReq.getStartDeviceCode()); + param.put("end_device_code", sortingReq.getEndDeviceCode()); + acsToWmsService.acsApply(param); + return BaseResponse.responseOk("任务下发成功"); + } + + @Override + public BaseResponse sortingBack(SortingReq sortingReq) { + JSONObject param = new JSONObject(); + param.put("taskCode", IdUtil.getSnowflake(1, 1).nextIdStr()); + param.put("taskType", "FJHKTask"); + param.put("start_device_code", sortingReq.getStartDeviceCode()); + acsToWmsService.acsApply(param); + return BaseResponse.responseOk("任务下发成功"); + } + + @Override + public BaseResponse sortingBackMaterial(SortingReq sortingReq) { +// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup(); +// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr()); +// groupEntity.setCreate_id("2"); +// groupEntity.setCreate_name("ACS"); +// groupEntity.setCreate_time(DateUtil.now()); +// groupEntity.setVehicle_code(jsonObject.getString("vehicle_code")); +// groupEntity.setVehicle_type(schBaseTask.getVehicle_type()); +// groupEntity.setPoint_code(startPoint.getPoint_code()); +// groupEntity.setPoint_name(startPoint.getPoint_name()); +// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd")); +// groupEntity.setInstorage_time(DateUtil.now()); +// groupEntity.setTask_code(schBaseTask.getTask_code()); +// groupEntity.setMove_way(startPoint.getPoint_code()); +// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定 +// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。 +// groupEntity.setIs_delete(false); +// vehiclematerialgroupService.save(groupEntity); +// //todo 多个物料信息绑定 +// MaterialVehicleBind materialVehicleBind = new MaterialVehicleBind(); +// materialVehicleBind.setId(IdUtil.getSnowflake(1, 1).nextIdStr()); +// materialVehicleBind.setCreate_time(DateUtil.now()); +// materialVehicleBind.setVehicle_code(jsonObject.getString("vehicle_code")); +// materialVehicleBind.setGroup_id(groupEntity.getGroup_id()); +// materialVehicleBind.setMaterial_code(jsonObject.getString("material_code")); +// materialVehicleBind.setMaterial_name(jsonObject.getString("material_name")); +// materialVehicleBind.setOrder_code(jsonObject.getString("order_code")); +// materialVehicleBindService.save(materialVehicleBind); + return BaseResponse.responseOk("物料信息接收成功"); + } + + @Override + public List autoBendMaterialInfo(BendReq bendReq) { + //todo 现在是查询该订单下的所有组盘信息 + // 需确认是否只查询分拣后的物料 以及需要把组盘绑定的物料信息都查出来 + String order = bendReq.getOrder(); + return schBaseVehiclematerialgroupService.selectByOrder(order); + } + + @Override + public BaseResponse autoBendCallMaterial(BendReq bendReq) { + String groupId = bendReq.getGroupId(); + SchBaseVehiclematerialgroup groupInfo = schBaseVehiclematerialgroupService.getById(groupId); + if (null == groupInfo) { + throw new BadRequestException("请求物料为空"); + } + JSONObject param = new JSONObject(); + param.put("taskCode", IdUtil.getSnowflake(1, 1).nextIdStr()); + param.put("taskType", "ZWSLTask"); + param.put("start_device_code", groupInfo.getPoint_code()); + param.put("end_device_code", bendReq.getEndDeviceCode()); acsToWmsService.acsApply(param); return BaseResponse.responseOk("任务下发成功"); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/ISchBaseVehiclematerialgroupService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/ISchBaseVehiclematerialgroupService.java index f4c154d..431ec26 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/ISchBaseVehiclematerialgroupService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/ISchBaseVehiclematerialgroupService.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.group.service.dto.SchBaseVehiclematerialgroupQuery; +import java.util.List; import java.util.Map; import java.util.Set; @@ -49,4 +50,6 @@ public interface ISchBaseVehiclematerialgroupService extends IService selectByOrder(String order); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.java index 08e994d..0dbdb7b 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.group.service.dto.SchBaseVehiclematerialgroupQuery; +import java.util.List; + /** * @author lyd * @date 2023-05-16 @@ -15,4 +17,6 @@ public interface SchBaseVehiclematerialgroupMapper extends BaseMapper selectPageLeftJoin(IPage pages, SchBaseVehiclematerialgroupQuery query); SchBaseVehiclematerialgroup getGroup(JSONObject entity); + + List selectByOrder(String order); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.xml index 8ccaf69..fdaf1a4 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/mapper/SchBaseVehiclematerialgroupMapper.xml @@ -49,4 +49,12 @@ AND vg.group_bind_material_status = '2' + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/impl/SchBaseVehiclematerialgroupServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/impl/SchBaseVehiclematerialgroupServiceImpl.java index 3a97dec..59abbf4 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/impl/SchBaseVehiclematerialgroupServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/impl/SchBaseVehiclematerialgroupServiceImpl.java @@ -19,6 +19,7 @@ import org.nl.wms.sch.group.service.dto.SchBaseVehiclematerialgroupQuery; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Map; import java.util.Set; @@ -79,4 +80,9 @@ public class SchBaseVehiclematerialgroupServiceImpl extends ServiceImpl selectByOrder(String order) { + return vehiclematerialgroupMapper.selectByOrder(order); + } + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJHKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJHKTask.java new file mode 100644 index 0000000..8b2bf9a --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJHKTask.java @@ -0,0 +1,214 @@ +package org.nl.wms.sch.task_manage.task.tasks.fj; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.exception.BadRequestException; +import org.nl.config.SpringContextHolder; +import org.nl.system.service.param.impl.SysParamServiceImpl; +import org.nl.wms.ext.service.dto.to.BaseResponse; +import org.nl.wms.ext.service.dto.to.iot.AgvStateParam; +import org.nl.wms.pdm.service.IPdmBdWorkorderService; +import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; +import org.nl.wms.sch.point.service.ISchBasePointService; +import org.nl.wms.sch.point.service.dao.SchBasePoint; +import org.nl.wms.sch.task.service.ISchBaseTaskService; +import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; +import org.nl.wms.sch.task.service.dao.SchBaseTask; +import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; +import org.nl.wms.sch.task_manage.AbstractTask; +import org.nl.wms.sch.task_manage.enums.PointStatusEnum; +import org.nl.wms.sch.task_manage.task.TaskType; +import org.nl.wms.sch.task_manage.task.core.TaskStatus; +import org.nl.wms.util.PointUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.List; + +/** + * @Author: sxp + * @Description: 分拣回库 + * @Date: 2024/3/11 + */ +@Slf4j +@Component +@TaskType("FJHKTask") +@Lazy +public class FJHKTask extends AbstractTask { + private static String TASK_CONFIG_CODE = "FJHKTask"; + @Autowired + private ISchBasePointService pointService; + @Autowired + private ISchBaseTaskService taskService; + @Autowired + private ISchBaseTaskconfigService taskConfigService; + @Autowired + private ISchBaseVehiclematerialgroupService vehiclematerialgroupService; + + @Override + protected void create() throws BadRequestException { + List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); + SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() + .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); + for (SchBaseTask task : tasks) { + SchBasePoint point = findNextPoint(taskConfig.getNext_region_str(), task.getVehicle_type()); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + log.info("分拣下料未找到当前符合条件的点位!"); + continue; + } + task.setPoint_code2(point.getPoint_code()); + task.setTask_status(TaskStatus.CREATED.getCode()); + task.setRemark(""); + taskService.update(task); + //发起任务时先把点位占用,防止发起重复任务 + point.setIng_task_code(task.getTask_code()); + pointService.update(point); + this.renotifyAcs(task); + } + } + + /** + * 判断目标点位 + * + * @return + */ + private SchBasePoint findNextPoint(String nextReginStr, String vehicleType) { + String[] reginList = nextReginStr.split(","); + LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); + lam.in(SchBasePoint::getRegion_code, Arrays.asList(reginList)) + .eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_POINT.getCode()) + .eq(SchBasePoint::getCan_vehicle_type, vehicleType) + .and(la -> la.isNull(SchBasePoint::getIng_task_code) // 当前执行的任务为空或者NULL,有数据表示锁住 + .or() + .eq(SchBasePoint::getIng_task_code, "")) + .eq(SchBasePoint::getIs_used, true) + .orderByAsc(SchBasePoint::getIn_order_seq) + .orderByAsc(SchBasePoint::getPoint_code); + List schBasePoints = pointService.list(lam); + return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null; + } + + @Override +// @Transactional(rollbackFor = Exception.class) + protected void updateStatus(String task_code, TaskStatus status) { + // 校验任务 + SchBaseTask taskObj = taskService.getById(task_code); + if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { + throw new BadRequestException("该任务已完成!"); + } + if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { + throw new BadRequestException("该任务已取消!"); + } + String startPoint = taskObj.getPoint_code1(); // 获取起点 + String endPoint = taskObj.getPoint_code2(); // 获取终点 + SchBasePoint startPointObj = pointService.getById(startPoint); + SchBasePoint endPointObj = pointService.getById(endPoint); + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { // 执行中 + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + } + if (status.equals(TaskStatus.FINISHED)) { // 完成 + // 起点清空 + if (ObjectUtil.isNotEmpty(startPointObj)) { + PointUtils.clearPoint(startPointObj); + } + // 终点解锁 + endPointObj.setIng_task_code(""); +// endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ","); + endPointObj.setVehicle_qty(1); + pointService.update(endPointObj); + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark("任务完成"); + } + if (status.equals(TaskStatus.CANCELED)) { // 取消 + // 终点解锁 + if (ObjectUtil.isNotEmpty(endPointObj)) { + endPointObj.setIng_task_code(""); + //任务取消把原先占用的位置释放 + pointService.update(endPointObj); + } + taskObj.setRemark("任务取消"); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + } + taskService.update(taskObj); + } + + @Override + public void forceFinish(String task_code) { + this.updateStatus(task_code, TaskStatus.FINISHED); + } + + @Override + public void cancel(String task_code) { + this.updateStatus(task_code, TaskStatus.CANCELED); + } + + @Override + protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { + // 反馈上位系统 反馈上位系统成功后,返回200给acs + AgvStateParam agvStateParam = new AgvStateParam(); + agvStateParam.setTask_code(schBaseTask.getTask_code()); + agvStateParam.setDevice_code(schBaseTask.getPoint_code1()); + agvStateParam.setVehicle_code(schBaseTask.getVehicle_code()); + String phase = param.getString("phase"); + String iotUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("iot_url").getValue(); + SchBasePoint startPoint = pointService.getById(schBaseTask.getPoint_code1()); + if ("3".equals(phase)) { + agvStateParam.setStatus("1"); + //叉车到位 请求取货 + String url = iotUrl + "iot/agvarrive"; + applyIot(url, agvStateParam, result); + //锁住起点 + startPoint.setIng_task_code(schBaseTask.getTask_code()); + pointService.update(startPoint); + } + if ("5".equals(phase)) { + agvStateParam.setStatus("2"); + //取货完成,请求离开 + String url = iotUrl + "iot/agvfinish"; + applyIot(url, agvStateParam, result); + //起点解锁 下发补空托盘任务 + startPoint.setIng_task_code(""); + pointService.update(startPoint); + } + } + + private void applyIot(String url, AgvStateParam agvStateParam, BaseResponse result) { + String jsonParam = JSON.toJSONString(agvStateParam); + log.info("请求iot参数为:{}", jsonParam); + try { + String resultMsg = HttpRequest.post(url) + .body(jsonParam) + .execute().body(); + JSONObject res = JSONObject.parseObject(resultMsg); + if ("200".equals(res.getString("code"))) { + log.info("请求iot成功,返回结果为:{}", res); + result.setCode(HttpStatus.OK.value()); + result.setMessage("请求iot成功!"); + } else { + log.error("请求iot失败:{}", res); + result.setCode(HttpStatus.BAD_REQUEST.value()); + result.setMessage("请求iot失败!"); + } + } catch (Exception e) { + String msg = e.getMessage(); + //请求iot失败 + log.error("请求iot失败:{}", msg); + result.setCode(HttpStatus.BAD_REQUEST.value()); + result.setMessage("请求iot失败!"); + } + + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJJKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJJKTask.java index 2568ab6..d6ebf13 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJJKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJJKTask.java @@ -75,7 +75,7 @@ public class FJJKTask extends AbstractTask { SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); for (SchBaseTask task : tasks) { - SchBasePoint point = findStartPoint(taskConfig.getStart_region_str(),task.getVehicle_type()); + SchBasePoint point = findStartPoint(taskConfig.getStart_region_str(), task.getVehicle_type()); if (ObjectUtil.isEmpty(point)) { task.setRemark("未找到所需点位!"); taskService.update(task); @@ -101,8 +101,8 @@ public class FJJKTask extends AbstractTask { } } - //查找空托盘 - private SchBasePoint findStartPoint(String startRegionStr,String vehicleType) { + //查找空载具 + private SchBasePoint findStartPoint(String startRegionStr, String vehicleType) { if (StringUtils.isEmpty(startRegionStr)) { return null; } @@ -234,6 +234,7 @@ public class FJJKTask extends AbstractTask { pointService.update(endPoint); } } + private void applyIot(String url, AgvStateParam agvStateParam, BaseResponse result) { String jsonParam = JSON.toJSONString(agvStateParam); log.info("请求iot参数为:{}", jsonParam);