| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | @Value("${wms.inboundTaskApplyPath}") |
| | | private String inboundTaskApplyPath; |
| | | @Value("${wms.movePath}") |
| | | private String movePath; |
| | | |
| | |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | StaDescService staDescService = SpringUtils.getBean(StaDescService.class); |
| | | |
| | | ToWmsDTO toWmsDTO = new ToWmsDTO(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2"); |
| | | List<Integer> list = openServiceImpl.getInEnableRoadway(); |
| | | TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); |
| | | |
| | | if (Cools.isEmpty(taskWrk)){ |
| | | // 请求wms接口,获取工作号和目标库位 |
| | | ToWmsDTO toWmsDTO = new ToWmsDTO(barcode,staProtocol.getSiteId()); |
| | | String response; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(null) |
| | | .setUri(wmsUrl) |
| | | .setPath(inboundTaskApplyPath) |
| | | .setJson(JSON.toJSONString(toWmsDTO)) |
| | | .build() |
| | | .doPost(); |
| | | }catch (Exception e){ |
| | | log.error("wms通讯失败,"+e.getMessage()); |
| | | continue; |
| | | } |
| | | //StaDesc staDesc1 = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no",inSta.getBackSta())); |
| | | if (taskWrk.getTargetPoint() != null && taskWrk.getStartPoint() != null){ |
| | | if ( taskWrk.getWrkNo() != null && taskWrk.getWrkNo().shortValue() == workNo ){ |
| | | continue; |
| | | } |
| | | //获取堆垛机站点 |
| | | StaDesc staDesc = new StaDesc(); |
| | | if (devp.getId() <= 1){ |
| | | staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).lt("stn_no", 200)); |
| | | }else { |
| | | staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).lt("stn_no", 400).ge("stn_no", 250)); |
| | | } |
| | | staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | Thread.sleep(500); |
| | | }else { |
| | | //TaskWrk taskWrk = taskWrkService.selectByTaskNo(param.getTaskNo()); |
| | | toWmsDTO.setWarehouseId("1688469798893297665"); |
| | | toWmsDTO.setContainerCode(barcode); |
| | | toWmsDTO.setApplyType("TUNNEL_LOCATION"); |
| | | toWmsDTO.setTaskTunnel(taskWrk.getCrnNo()); |
| | | toWmsDTO.setCanInboundTunnels(list); |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(map) |
| | | .setUri(wmsUrl) |
| | | .setPath("wcsManager/wcsInterface/inboundTaskApply") |
| | | .setJson(JSON.toJSONString(toWmsDTO)) |
| | | .build() |
| | | .doPost(); |
| | | }catch (Exception e){ |
| | | log.error("wms通讯失败,"+e.getMessage()); |
| | | continue; |
| | | } |
| | | apiLogService.save("wms请求入库货位接口" |
| | | ,wmsUrl+"wcsManager/wcsInterface/inboundTaskApply" |
| | | ,null |
| | | ,"127.0.0.1" |
| | | ,JSON.toJSONString(toWmsDTO) |
| | | ,response |
| | | ,true |
| | | ); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); |
| | | taskWrk.setOriginTargetPoint(getWmsDto.getTargetLocationCode()); |
| | | taskWrk.setTargetPoint(Utils.getWcsLocNo(getWmsDto.getTargetLocationCode())); |
| | | taskWrk.setStartPoint(String.valueOf(inSta.getBackSta())); |
| | | if (!taskWrkService.updateById(taskWrk)){ |
| | | log.error("保存wms库位号失败"); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200) && !Cools.isEmpty(jsonObject.get("data").toString())) { |
| | | GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); |
| | | // 创新一个入库工作档 |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(getWmsDto.getTaskNo()); |
| | | if(Cools.isEmpty(taskWrk)) { |
| | | taskWrk = createTask(getWmsDto,staProtocol.getStaNo().intValue()); |
| | | if (Cools.isEmpty(taskWrk)){ |
| | | log.error("库位异常,库位号:{}", getWmsDto.getTargetLocationCode()); |
| | | }else { |
| | | taskWrkService.insert(taskWrk); |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).eq("stn_no",staProtocol.getStaNo().intValue())); |
| | | staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | } |
| | | |
| | | }else { |
| | | log.error("wms通讯失败,"+jsonObject.get("msg")); |
| | | |
| | | } |
| | | |
| | | }else { |
| | | continue; |
| | | } |
| | | |
| | | // StaDescService staDescService = SpringUtils.getBean(StaDescService.class); |
| | | // |
| | | // ToWmsDTO toWmsDTO = new ToWmsDTO(); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2"); |
| | | // List<Integer> list = openServiceImpl.getInEnableRoadway(); |
| | | // TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); |
| | | // |
| | | // if (Cools.isEmpty(taskWrk)){ |
| | | // continue; |
| | | // } |
| | | // //StaDesc staDesc1 = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("stn_no",inSta.getBackSta())); |
| | | // if (taskWrk.getTargetPoint() != null && taskWrk.getStartPoint() != null){ |
| | | // if ( taskWrk.getWrkNo() != null && taskWrk.getWrkNo().shortValue() == workNo ){ |
| | | // continue; |
| | | // } |
| | | // //获取堆垛机站点 |
| | | // StaDesc staDesc = new StaDesc(); |
| | | // if (devp.getId() <= 1){ |
| | | // staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | // .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).lt("stn_no", 200)); |
| | | // }else { |
| | | // staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | // .eq("crn_no", taskWrk.getCrnNo()).eq("type_no",1).lt("stn_no", 400).ge("stn_no", 250)); |
| | | // } |
| | | // staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue()); |
| | | // staProtocol.setStaNo(staDesc.getCrnStn().shortValue()); |
| | | // MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | // Thread.sleep(500); |
| | | // }else { |
| | | // //TaskWrk taskWrk = taskWrkService.selectByTaskNo(param.getTaskNo()); |
| | | // toWmsDTO.setWarehouseId("1688469798893297665"); |
| | | // toWmsDTO.setContainerCode(barcode); |
| | | // toWmsDTO.setApplyType("TUNNEL_LOCATION"); |
| | | // toWmsDTO.setTaskTunnel(taskWrk.getCrnNo()); |
| | | // toWmsDTO.setCanInboundTunnels(list); |
| | | // String response = null; |
| | | // try { |
| | | // response = new HttpHandler.Builder() |
| | | // .setHeaders(map) |
| | | // .setUri(wmsUrl) |
| | | // .setPath(inboundTaskApplyPath) |
| | | // .setJson(JSON.toJSONString(toWmsDTO)) |
| | | // .build() |
| | | // .doPost(); |
| | | // }catch (Exception e){ |
| | | // log.error("wms通讯失败,"+e.getMessage()); |
| | | // continue; |
| | | // } |
| | | // apiLogService.save("wms请求入库货位接口" |
| | | // ,wmsUrl+"wcsManager/wcsInterface/inboundTaskApply" |
| | | // ,null |
| | | // ,"127.0.0.1" |
| | | // ,JSON.toJSONString(toWmsDTO) |
| | | // ,response |
| | | // ,true |
| | | // ); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getInteger("code").equals(200)) { |
| | | // GetWmsDto getWmsDto = JSON.parseObject(jsonObject.get("data").toString(), GetWmsDto.class); |
| | | // taskWrk.setOriginTargetPoint(getWmsDto.getTargetLocationCode()); |
| | | // taskWrk.setTargetPoint(Utils.getWcsLocNo(getWmsDto.getTargetLocationCode())); |
| | | // taskWrk.setStartPoint(String.valueOf(inSta.getBackSta())); |
| | | // if (!taskWrkService.updateById(taskWrk)){ |
| | | // log.error("保存wms库位号失败"); |
| | | // } |
| | | // |
| | | // }else { |
| | | // log.error("wms通讯失败,"+jsonObject.get("msg")); |
| | | // |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 堆垛机站出库到出库站 |
| | | */ |
| | | @Async |
| | | public void crnStnToOutStn() { |
| | | for (CrnSlave crnSlave : slaveProperties.getCrn()) { |
| | | // 遍历堆垛机出库站 |
| | |
| | | continue; |
| | | } |
| | | |
| | | //取出命令 |
| | | List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskWrk.getTaskNo()); |
| | | Integer commandStep = taskWrk.getCommandStep(); |
| | | if (commandInfos.isEmpty()) { |
| | | continue;//命令空 |
| | | } |
| | | CommandInfo commandInfo = commandInfos.get(commandStep); |
| | | CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文 |
| | | CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class); |
| | | |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | Date now = new Date(); |
| | | taskWrk.setWrkSts(3); |
| | | taskWrk.setModiTime(now); |
| | | if (taskWrkMapper.updateById(taskWrk) == 0) { |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", taskWrk.getWrkNo()); |
| | | } |
| | | //开始运行 |
| | | String response = CrnStartRunning(taskWrk); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | |
| | | }else { |
| | | log.error("入库开始运行通讯失败,"+jsonObject.get("msg")); |
| | | |
| | | } |
| | | } |
| | | |
| | | // // 命令下发区 -------------------------------------------------------------------------- |
| | | // CrnCommand crnCommand = new CrnCommand(); |
| | | // crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | // crnCommand.setTaskNo(taskWrk.getWrkNo().shortValue()); // 工作号 |
| | | // crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | // crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | // crnCommand.setSourcePosX(crnStn.getBay().shortValue()); // 源库位列 |
| | | // crnCommand.setSourcePosY(crnStn.getLev().shortValue()); // 源库位层 |
| | | // crnCommand.setSourcePosZ(crnStn.getRow().shortValue()); // 源库位排 |
| | | // crnCommand.setDestinationPosX(Utils.getBayShort(taskWrk.getTargetPoint())); // 目标库位列 |
| | | // crnCommand.setDestinationPosY(Utils.getLevShort(taskWrk.getTargetPoint())); // 目标库位层 |
| | | // crnCommand.setDestinationPosZ(Utils.getRowShort(taskWrk.getTargetPoint())); // 目标库位排 |
| | | // crnCommand.setCommand((short)1); |
| | | // if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | // //取出命令 |
| | | // List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskWrk.getTaskNo()); |
| | | // Integer commandStep = taskWrk.getCommandStep(); |
| | | // if (commandInfos.isEmpty()) { |
| | | // continue;//命令空 |
| | | // } |
| | | // CommandInfo commandInfo = commandInfos.get(commandStep); |
| | | // CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class);//取出命令报文 |
| | | // CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class); |
| | | // |
| | | // if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | // log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | // } else { |
| | | // // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | |
| | | // if (taskWrkMapper.updateById(taskWrk) == 0) { |
| | | // log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", taskWrk.getWrkNo()); |
| | | // } |
| | | // //开始运行 |
| | | // String response = CrnStartRunning(taskWrk); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getInteger("code").equals(200)) { |
| | | // |
| | | // }else { |
| | | // log.error("入库开始运行通讯失败,"+jsonObject.get("msg")); |
| | | // |
| | | // } |
| | | // } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | | crnCommand.setTaskNo(taskWrk.getWrkNo().shortValue()); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 任务模式: 库位移转 |
| | | crnCommand.setSourcePosX(crnStn.getBay().shortValue()); // 源库位列 |
| | | crnCommand.setSourcePosY(crnStn.getLev().shortValue()); // 源库位层 |
| | | crnCommand.setSourcePosZ(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setDestinationPosX(Utils.getBayShort(taskWrk.getTargetPoint())); // 目标库位列 |
| | | crnCommand.setDestinationPosY(Utils.getLevShort(taskWrk.getTargetPoint())); // 目标库位层 |
| | | crnCommand.setDestinationPosZ(Utils.getRowShort(taskWrk.getTargetPoint())); // 目标库位排 |
| | | crnCommand.setCommand((short)1); |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | | Date now = new Date(); |
| | | taskWrk.setWrkSts(3); |
| | | taskWrk.setModiTime(now); |
| | | if (taskWrkMapper.updateById(taskWrk) == 0) { |
| | | log.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", taskWrk.getWrkNo()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // return; |
| | |
| | | /** |
| | | * 执行对工作档的完成操作 |
| | | */ |
| | | @Async |
| | | public void storeFinished() { |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { continue; } |
| | | |
| | | // 状态:等待确认 并且 任务完成位 = 1 |
| | | if (crnProtocol.getTaskFinish() == 0 && crnProtocol.statusType == CrnStatusType.HANDLING_COMPLETED && crnProtocol.getTaskNo() != 0) { |
| | | //获取入库待确认工作档 |
| | | TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crn.getId(),crnProtocol.getTaskNo().intValue()); |
| | | if (Cools.isEmpty(taskWrk)) { |
| | | // log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | //获取指令ID |
| | | Integer commandId = crnProtocol.getCommandId(); |
| | | CommandInfo commandInfo = new CommandInfo(); |
| | | if (Cools.isEmpty(commandId)){ |
| | | commandInfo = commandInfoService.selectOne(new EntityWrapper<CommandInfo>() |
| | | .eq("wrk_no",crnProtocol.getTaskNo()) |
| | | .eq("device","Crn")); |
| | | }else { |
| | | commandInfo = commandInfoService.selectById(commandId); |
| | | } |
| | | |
| | | |
| | | if (commandInfo == null) { |
| | | //指令不存在 |
| | | continue; |
| | | } |
| | | if (commandInfo.getCommandStatus() == 3){ |
| | | continue; |
| | | } |
| | | commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//指令完成 |
| | | commandInfo.setCompleteTime(new Date());//指令完成时间 |
| | | if (commandInfoService.updateById(commandInfo)) {//修改成功后复位堆垛机 |
| | | // 堆垛机复位 |
| | | crnThread.setResetFlag(true); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 执行对工作档的完成操作 |
| | | // */ |
| | | // @Async |
| | | // public void storeFinished() { |
| | | // for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // // 获取堆垛机信息 |
| | | // CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | // CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | // if (crnProtocol == null) { continue; } |
| | | // |
| | | // // 状态:等待确认 并且 任务完成位 = 1 |
| | | // if (crnProtocol.getTaskFinish() == 0 && crnProtocol.statusType == CrnStatusType.HANDLING_COMPLETED && crnProtocol.getTaskNo() != 0) { |
| | | // // 获取入库待确认工作档 |
| | | // TaskWrk taskWrk = taskWrkMapper.selectCrnNoWorking(crn.getId(),crnProtocol.getTaskNo().intValue()); |
| | | // //获取入库待确认工作档 |
| | | // TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crn.getId(),crnProtocol.getTaskNo().intValue()); |
| | | // if (Cools.isEmpty(taskWrk)) { |
| | | // log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo()); |
| | | //// log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo()); |
| | | // continue; |
| | | // } |
| | | // // 入库 + 库位转移 ==> 4.入库完成 |
| | | // if ((taskWrk.getWrkSts() == 3 && taskWrk.getIoType() == 1) || (taskWrk.getWrkSts() == 12 && taskWrk.getIoType() == 3)) { |
| | | // taskWrk.setWrkSts(4); |
| | | // } else { |
| | | // |
| | | // //获取指令ID |
| | | // Integer commandId = crnProtocol.getCommandId(); |
| | | // CommandInfo commandInfo = new CommandInfo(); |
| | | // if (Cools.isEmpty(commandId)){ |
| | | // commandInfo = commandInfoService.selectOne(new EntityWrapper<CommandInfo>() |
| | | // .eq("wrk_no",crnProtocol.getTaskNo()) |
| | | // .eq("device","Crn")); |
| | | // }else { |
| | | // commandInfo = commandInfoService.selectById(commandId); |
| | | // } |
| | | // |
| | | // |
| | | // if (commandInfo == null) { |
| | | // //指令不存在 |
| | | // continue; |
| | | // } |
| | | // Date now = new Date(); |
| | | // taskWrk.setModiTime(now); |
| | | // Integer integerTaskWrk = taskWrkMapper.updateById(taskWrk); |
| | | // // 修改成功后复位堆垛机 |
| | | // if (integerTaskWrk > 0) { |
| | | // if (commandInfo.getCommandStatus() == 3){ |
| | | // continue; |
| | | // } |
| | | // commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//指令完成 |
| | | // commandInfo.setCompleteTime(new Date());//指令完成时间 |
| | | // if (commandInfoService.updateById(commandInfo)) {//修改成功后复位堆垛机 |
| | | // // 堆垛机复位 |
| | | // crnThread.setResetFlag(true); |
| | | // |
| | | // //更新库位状态 |
| | | // LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); |
| | | // locMast.setLocSts("F");//F.在库 |
| | | // locMast.setBarcode(taskWrk.getBarcode());//托盘码 |
| | | // locMast.setModiTime(now); |
| | | // locMast.setModiUser(9999L); |
| | | // locMastService.updateById(locMast); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 执行对工作档的完成操作 |
| | | */ |
| | | public void storeFinished() { |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { continue; } |
| | | // 状态:等待确认 并且 任务完成位 = 1 |
| | | if (crnProtocol.getTaskFinish() == 0 && crnProtocol.statusType == CrnStatusType.HANDLING_COMPLETED && crnProtocol.getTaskNo() != 0) { |
| | | // 获取入库待确认工作档 |
| | | TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crn.getId(),crnProtocol.getTaskNo().intValue()); |
| | | if (Cools.isEmpty(taskWrk)) { |
| | | log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | // 入库 + 库位转移 ==> 4.入库完成 |
| | | if ((taskWrk.getWrkSts() == 3 && taskWrk.getIoType() == 1) || (taskWrk.getWrkSts() == 12 && taskWrk.getIoType() == 3)) { |
| | | taskWrk.setWrkSts(4); |
| | | } else { |
| | | continue; |
| | | } |
| | | Date now = new Date(); |
| | | taskWrk.setModiTime(now); |
| | | Integer integerTaskWrk = taskWrkMapper.updateById(taskWrk); |
| | | // 修改成功后复位堆垛机 |
| | | if (integerTaskWrk > 0) { |
| | | // 堆垛机复位 |
| | | crnThread.setResetFlag(true); |
| | | |
| | | //更新库位状态 |
| | | LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); |
| | | locMast.setLocSts("F");//F.在库 |
| | | locMast.setBarcode(taskWrk.getBarcode());//托盘码 |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(9999L); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 堆垛机异常信息记录 |
| | | */ |
| | | @Async |
| | | public void recCrnErr(){ |
| | | Date now = new Date(); |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | |
| | | return response; |
| | | } |
| | | |
| | | private TaskWrk createTask(GetWmsDto dto, Integer staNo){ |
| | | String wcsLocNo = Utils.getWcsLocNo(dto.getTargetLocationCode()); |
| | | if(Cools.isEmpty(wcsLocNo)){ |
| | | return null; |
| | | } |
| | | Date now = new Date(); |
| | | TaskWrk taskWrk = new TaskWrk(); |
| | | taskWrk.setTaskNo(dto.getTaskNo());//任务号 |
| | | taskWrk.setStatus(TaskStatusType.RECEIVE.id);//任务状态:接收 |
| | | taskWrk.setCreateTime(now); |
| | | taskWrk.setIoType(1);//任务类型 |
| | | taskWrk.setIoPri(Cools.isEmpty(dto.getTaskPriority()) ? 300 : Integer.parseInt(dto.getTaskPriority()));//优先级 |
| | | taskWrk.setBarcode(dto.getContainerCode());//条码 |
| | | LocMast locMast = locMastService.selectByLocNo(wcsLocNo); |
| | | taskWrk.setCrnNo(locMast.getCrnNo()); |
| | | taskWrk.setTargetPoint(dto.getTargetLocationCode()); |
| | | taskWrk.setStartPoint(staNo.toString()); |
| | | if(taskWrk.getIoType() == 1){ |
| | | taskWrk.setWrkSts(2); |
| | | if (!Cools.isEmpty(taskWrk.getTargetPoint())) { |
| | | taskWrk.setTargetPoint(wcsLocNo);//终点 |
| | | taskWrk.setOriginTargetPoint(taskWrk.getTargetPoint()); |
| | | } |
| | | |
| | | // } else if (param.getIoType() == 2) { |
| | | // taskWrk.setWrkSts(11); |
| | | // if (!Cools.isEmpty(param.getStartPoint())) { |
| | | // taskWrk.setStartPoint(Utils.getWcsLocNo(param.getStartPoint()));//起点 |
| | | // taskWrk.setOriginStartPoint(param.getStartPoint()); |
| | | // } |
| | | // taskWrk.setTargetPoint(param.getTargetPoint()); |
| | | // }else if (param.getIoType() == 3){ |
| | | // taskWrk.setWrkSts(11); |
| | | // if (!Cools.isEmpty(param.getStartPoint())) { |
| | | // taskWrk.setStartPoint(param.getStartPoint());//起点 |
| | | // taskWrk.setOriginStartPoint(param.getStartPoint()); |
| | | // } |
| | | } |
| | | return taskWrk; |
| | | } |
| | | |
| | | |
| | | } |