| | |
| | | import com.zy.asrs.entity.result.HIKResultDTO; |
| | | import com.zy.asrs.enums.LocStsType; |
| | | import com.zy.asrs.enums.TaskIOType; |
| | | import com.zy.asrs.enums.TaskStatusType; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.LocCacheService; |
| | | import com.zy.asrs.service.TaskService; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R callAgvCarry(CallAgvParams params) { |
| | | if (params.getType().equals(OrderType.ORDER_OUT.type)) { |
| | | //缓存区出库 |
| | | } else if (params.getType().equals(OrderType.ORDER_IN.type)) { |
| | | //缓存区入库 |
| | | } else { |
| | | |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getWrkNo())) { |
| | | return R.error("任务号不能为空!!"); |
| | | } |
| | | |
| | | Task task = taskService.selectOne(new EntityWrapper<Task>().eq("wrk_no", params.getWrkNo())); |
| | | if (Objects.isNull(task)) { |
| | | return R.error("任务信息不存在!!"); |
| | | } |
| | | |
| | | if (Arrays.asList(TaskIOType.ALL_IN.type, TaskIOType.PICK_IN.type, TaskIOType.MERGE_IN.type) |
| | | .contains(task.getIoType())) { |
| | | // 入库 |
| | | task.setWrkSts(TaskStatusType.AGV_TASK_ISSUED_IN.type); |
| | | } else if (Arrays.asList(TaskIOType.ALL_OUT.type, TaskIOType.PICK_OUT.type, TaskIOType.MERGE_OUT.type) |
| | | .contains(task.getIoType())) { |
| | | // 出库 |
| | | task.setWrkSts(TaskStatusType.AGV_TASK_ISSUED_OUT.type); |
| | | } |
| | | |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务状态更新失败!!"); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R callback(CallAgvParams params) { |
| | | //TODO 1. 搬运完成,修改站点库位状态 |
| | | if (params.getType().equals(OrderType.ORDER_OUT.type)) { |
| | | //出库单 |
| | | if (params.getStatus().equals("RUNING")) { |
| | | LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", params.getOrgLoc())); |
| | | if (Objects.isNull(locCache)) { |
| | | throw new CoolException("库位信息不存在!!"); |
| | | } |
| | | if (!locCache.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | } |
| | | } else if (params.getStatus().equals("FINISHED")) { |
| | | Task task = taskService.selectOne(new EntityWrapper<Task>().eq("wrk_no", params.getWrkNo())); |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("任务信息不存在!!"); |
| | | } |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务状态更新失败!!"); |
| | | } |
| | | } |
| | | } else { |
| | | //入库单 |
| | | |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getWrkNo())) { |
| | | return R.error("任务号不能为空!!"); |
| | | } |
| | | Task task = taskService.selectOne(new EntityWrapper<Task>().eq("wrk_no", params.getWrkNo())); |
| | | if (Objects.isNull(task)) { |
| | | return R.error("任务信息不存在!!"); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | // if (!Arrays.asList(TaskStatusType.AGV_TASK_ISSUED_IN.type, TaskStatusType.AGV_TASK_ISSUED_OUT.type).contains(task.getIoType())) { |
| | | // return R.error(""); |
| | | // } |
| | | // |
| | | if (Arrays.asList(TaskIOType.ALL_IN.type, TaskIOType.PICK_IN.type, TaskIOType.MERGE_IN.type) |
| | | .contains(task.getIoType())) { |
| | | // 入库 |
| | | if (params.getStatus().equals("RUNNING")) { |
| | | task.setWrkSts(TaskStatusType.AGV_TASK_RUNNING_IN.type); |
| | | } else if (params.getStatus().equals("FINISHED")){ |
| | | task.setWrkSts(TaskStatusType.AGV_TASK_FINISHED_IN.type); |
| | | |
| | | } |
| | | } else if (Arrays.asList(TaskIOType.ALL_OUT.type, TaskIOType.PICK_OUT.type, TaskIOType.MERGE_OUT.type) |
| | | .contains(task.getIoType())) { |
| | | // 出库 |
| | | if (params.getStatus().equals("RUNNING")) { |
| | | task.setWrkSts(TaskStatusType.AGV_TASK_RUNNING_OUT.type); |
| | | } else if (params.getStatus().equals("FINISHED")){ |
| | | task.setWrkSts(TaskStatusType.AGV_TASK_FINISHED_OUT.type); |
| | | } |
| | | } |
| | | |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("状态修改失败!!"); |
| | | } |
| | | |
| | | return R.ok("执行完成 !!"); |
| | | } |
| | | |
| | | public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO, String path) { |
| | | HIKResultDTO result = new HIKResultDTO(); |
| | |
| | | forwardAGVTaskParam.setCtnrTyp(haiKangApiDTO.getCtnrType()); |
| | | forwardAGVTaskParam.setPriority(haiKangApiDTO.getPriority()); |
| | | List<ForwardAGVTaskDTO.PositionCodePaths> positionCodePathsList = new ArrayList<>(); |
| | | positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType())); |
| | | positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType())); |
| | | positionCodePathsList |
| | | .add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType())); |
| | | positionCodePathsList |
| | | .add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType())); |
| | | forwardAGVTaskParam.setPositionCodePath(positionCodePathsList); |
| | | String body = JSON.toJSONString(forwardAGVTaskParam); |
| | | String response = ""; |
| | |
| | | result.setMessage(jsonObject.getString("message")); |
| | | log.error("发送agv任务失败!!!url:{};request:{};response:{}", HIKApiConstant.AGV_IP + path, body, response); |
| | | } |
| | | // {"code":"1","data":"","interrupt":false,"message":"重复提交","msgErrCode":"0x3a80D012","reqCode":"fa92b49481a44627ae4d80c1400f28f6"} |
| | | // {"code":"1","data":"","interrupt":false,"message":"重复提交","msgErrCode":"0x3a80D012","reqCode":"fa92b49481a44627ae4d80c1400f28f6"} |
| | | } catch (Exception e) { |
| | | result.setMessage(e.getMessage()); |
| | | log.error("发送agv任务异常", e); |
| | |
| | | "127.0.0.1", |
| | | body, |
| | | response, |
| | | result.isSuccess() |
| | | ); |
| | | result.isSuccess()); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |