| | |
| | | */ |
| | | @Slf4j |
| | | @Service("mainService") |
| | | @Transactional |
| | | public class MainServiceImpl { |
| | | |
| | | public static final long COMMAND_TIMEOUT = 5 * 1000; |
| | |
| | | .eq("loc_no", dto.getLocNo())); |
| | | |
| | | short staNo = dto.getStaNo().shortValue(); |
| | | |
| | | int sourceStaNo = dto.getSourceStaNo(); |
| | | if (sourceStaNo == 1007) { |
| | | staNo = 2002; |
| | | } |
| | | |
| | | if (inSta.getStaNo() == 1002) { |
| | | staNo = 2002; |
| | | } |
| | |
| | | // continue; |
| | | // } |
| | | |
| | | //堆垛机回原点任务中 |
| | | Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK + crn.getId()); |
| | | if (object != null) { |
| | | continue; |
| | | } |
| | | |
| | | // 只有当堆垛机空闲 并且 无任务时才继续执行 |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO |
| | | && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK); |
| | | Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK + crn.getId()); |
| | | if (object != null) { |
| | | continue; |
| | | } |
| | |
| | | News.error("堆垛机移动命令下发失败,堆垛机号={},任务数据={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | crnThread.setBackHpFlag(true); |
| | | redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 60); |
| | | redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 10); |
| | | try { |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK); |
| | | Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK + crn.getId()); |
| | | if (object != null) { |
| | | continue; |
| | | } |
| | |
| | | News.error("堆垛机移动命令下发失败,堆垛机号={},任务数据={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | crnThread.setBackHpFlag(true); |
| | | redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 60); |
| | | redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 10); |
| | | try { |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | |
| | | // continue; |
| | | } |
| | | // 判断堆垛机出库站状态 |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") |
| | | && staProtocol.getWorkNo() == 0) { |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")) { |
| | | |
| | | //根据参数判断是否校验可出信号 |
| | | String crnOutVerifyOut = "Y"; |
| | |
| | | |
| | | if (crnOutVerifyOut.equals("Y")) { |
| | | if (!staProtocol.isOutEnable()) { |
| | | continue; |
| | | } |
| | | |
| | | if (staProtocol.getWorkNo() > 0) { |
| | | continue; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | if (crnProtocol.getCrnNo() == 1) { |
| | | //判断堆垛机和当前任务是否处于一个巷道 |
| | | if (Utils.getLaneByLocNo(wrkMast.getSourceLocNo()) != crnProtocol.getCrnLane()) { |
| | | //判断堆垛机所在巷道是否存在其他任务,如存在则优先执行 |
| | | List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false); |
| | | if (!currentWrkMasts.isEmpty()) { |
| | | continue;//当前堆垛机所在巷道存在任务 |
| | | String turnCrnExecuteCurrentChannel = "Y"; |
| | | Config turnCrnExecuteCurrentChannelConfig = configService.selectOne(new EntityWrapper<Config>() |
| | | .eq("code", "turnCrnExecuteCurrentChannel") |
| | | ); |
| | | if (turnCrnExecuteCurrentChannelConfig != null) { |
| | | turnCrnExecuteCurrentChannel = turnCrnExecuteCurrentChannelConfig.getValue(); |
| | | } |
| | | |
| | | if(turnCrnExecuteCurrentChannel.equals("Y")) { |
| | | //判断堆垛机和当前任务是否处于一个巷道 |
| | | if (Utils.getLaneByLocNo(wrkMast.getSourceLocNo()) != crnProtocol.getCrnLane()) { |
| | | //判断堆垛机所在巷道是否存在其他任务,如存在则优先执行 |
| | | List<WrkMast> currentWrkMasts = wrkMastService.selectLaneWrkMast(crnProtocol.getCrnLane(), false); |
| | | if (!currentWrkMasts.isEmpty()) { |
| | | continue;//当前堆垛机所在巷道存在任务 |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | News.error("" + mark + " - 3" + " - 5" + " - 【库位移转】 修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo()); |
| | | } |
| | | crnProtocol.setLastIo("I"); |
| | | } |
| | | News.infoNoLog("" + mark + " - 3" + " - 0" + " - 堆垛机入出库作业下发:库位移转完成"); |
| | | |
| | |
| | | if (crnProtocol.getTaskNo() == 9999) { |
| | | // 堆垛机复位 |
| | | crnThread.setResetFlag(true); |
| | | redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 8);//防止回原点后下发指令过快 |
| | | continue; |
| | | } |
| | | |
| | |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", dto.getLocNo())); |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | | staProtocol.setPalletSize(locMast.getLocType2()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | |
| | | wrkMast1.setIoType(3); // 入出库状态:3.站到站 |
| | | wrkMast1.setIoPri(13D); // 优先级 |
| | | wrkMast1.setSourceStaNo(emptyInSta.getStaNo()); |
| | | wrkMast1.setStaNo(1007); |
| | | wrkMast1.setStaNo(1004); |
| | | wrkMast1.setBarcode(barcode); |
| | | // 操作人员数据 |
| | | wrkMast1.setAppeTime(new Date()); |
| | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo((short) workNo); |
| | | staProtocol.setStaNo((short) 2003); |
| | | staProtocol.setPalletSize((short) 1); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | |
| | | // }catch (Exception e){ |
| | | // log.error("工作档案明细输入电视机失败1:异常信息==》"+e); |
| | | // } |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetl.getMatnr() |
| | | , wrkDetl.getMaktx() |
| | | , wrkDetl.getAnfme() |
| | | , wrkDetl.getWeight() |
| | | , wrkDetl.getStockNum() |
| | | , wrkDetl.getStockNum2() |
| | | , wrkDetl.getSpecs() |
| | | , wrkDetl.getSku() |
| | | , wrkDetl.getZpallet() |
| | | , wrkDetl.getModel() |
| | | , wrkDetl.getSupp() |
| | | , wrkDetl.getKpCstmrName() |
| | | , wrkDetl.getOrderNo() |
| | | , wrkDetl.getCstateid$() |
| | | ))); |
| | | |
| | | if (!wrkDetls.isEmpty()) { |
| | | WrkDetl wrkDetl = wrkDetls.get(0); |
| | | double anfme = 0D; |
| | | double weight = 0D; |
| | | for (WrkDetl detl : wrkDetls) { |
| | | anfme += detl.getAnfme(); |
| | | weight += detl.getWeight(); |
| | | wrkDetl.setAnfme(anfme); |
| | | wrkDetl.setWeight(weight); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", wrkMast.getSourceLocNo())); |
| | | double totalAnfme = 0D; |
| | | double totalWeight = 0D; |
| | | for (LocDetl locDetl : locDetls) { |
| | | totalAnfme += locDetl.getAnfme(); |
| | | totalWeight += locDetl.getWeight(); |
| | | } |
| | | wrkDetl.setStockNum(totalAnfme); |
| | | wrkDetl.setStockNum2(totalWeight); |
| | | |
| | | ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetl.getMatnr() |
| | | , wrkDetl.getMaktx() |
| | | , wrkDetl.getAnfme() |
| | | , wrkDetl.getWeight() |
| | | , wrkDetl.getStockNum() |
| | | , wrkDetl.getStockNum2() |
| | | , wrkDetl.getSpecs() |
| | | , wrkDetl.getSku() |
| | | , wrkDetl.getZpallet() |
| | | , wrkDetl.getModel() |
| | | , wrkDetl.getSupp() |
| | | , wrkDetl.getKpCstmrName() |
| | | , wrkDetl.getOrderNo() |
| | | , wrkDetl.getCstateid$() |
| | | )); |
| | | |
| | | // wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto( |
| | | // wrkDetl.getMatnr() |
| | | // , wrkDetl.getMaktx() |
| | | // , wrkDetl.getAnfme() |
| | | // , wrkDetl.getWeight() |
| | | // , wrkDetl.getStockNum() |
| | | // , wrkDetl.getStockNum2() |
| | | // , wrkDetl.getSpecs() |
| | | // , wrkDetl.getSku() |
| | | // , wrkDetl.getZpallet() |
| | | // , wrkDetl.getModel() |
| | | // , wrkDetl.getSupp() |
| | | // , wrkDetl.getKpCstmrName() |
| | | // , wrkDetl.getOrderNo() |
| | | // , wrkDetl.getCstateid$() |
| | | // ))); |
| | | } |
| | | |
| | | } |
| | | commands.add(ledCommand); |
| | | } |