| | |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.constant.RedisConstantType; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.MatDto; |
| | | import com.zy.common.model.SearchLocParam; |
| | |
| | | import com.zy.common.utils.CollectionUtils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.News; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | import com.zy.core.thread.LedThread; |
| | | import com.zy.core.thread.RgvThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WrkMastLogService wrkMastLogService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", dto.getLocNo())); |
| | | |
| | | short staNo = dto.getStaNo().shortValue(); |
| | | if (inSta.getStaNo() == 1002) { |
| | | staNo = 2002; |
| | | } |
| | | |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | | staProtocol.setStaNo(staNo); |
| | | staProtocol.setPalletSize(locMast.getLocType2()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | |
| | | // led 入库信息显示 |
| | | if (ledThread != null) { |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(dto.getWorkNo()); |
| | | ledCommand.setIoType(1); |
| | | ledCommand.setTitle("全板入库"); |
| | | ledCommand.setLocNo(dto.getLocNo()); |
| | | ledCommand.setStaNo(dto.getStaNo()); |
| | | commands.add(ledCommand); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands)); |
| | | // ledThread.errorReset(); |
| | | } |
| | | // // led 入库信息显示 |
| | | // if (ledThread != null) { |
| | | // // 命令集合 |
| | | // List<LedCommand> commands = new ArrayList<>(); |
| | | // // 组装命令 |
| | | // LedCommand ledCommand = new LedCommand(); |
| | | // ledCommand.setWorkNo(dto.getWorkNo()); |
| | | // ledCommand.setIoType(1); |
| | | // ledCommand.setTitle("全板入库"); |
| | | // ledCommand.setLocNo(dto.getLocNo()); |
| | | // ledCommand.setStaNo(dto.getStaNo()); |
| | | // commands.add(ledCommand); |
| | | // MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands)); |
| | | //// ledThread.errorReset(); |
| | | // } |
| | | } else { |
| | | News.error(""+mark+" - 5"+" - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | // staProtocol.setWorkNo((short)9992); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 回原点,堆垛机没有执行中任务,设备存在入库任务时叫回原点 |
| | | * 堆垛机无任务两分钟,回入库口待机 |
| | | */ |
| | | public synchronized void crnRebackHp(CrnProtocol crnProtocol, CrnThread crnThread) { |
| | | // for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // // 获取堆垛机信息 |
| | | // CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | // CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | // if (crnProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); |
| | | // if (basCrnp == null) { |
| | | // log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId()); |
| | | // continue; |
| | | // } |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { |
| | | if (crnProtocol.getBay() == 1 && crnProtocol.getLevel() == 1) { |
| | | return; |
| | | public synchronized void crnMove() { |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | continue; |
| | | } |
| | | BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); |
| | | if (basCrnp == null) { |
| | | log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId()); |
| | | continue; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤3,12 |
| | | if (wrkMastMapper.selectWorking(crnProtocol.getCrnNo()) != null) { |
| | | return; |
| | | } |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { |
| | | if (crnProtocol.getBay() == 1 && crnProtocol.getLevel() == 1) { |
| | | continue; |
| | | } |
| | | |
| | | //堆垛机有执行中任务,过滤3,4,11,12 |
| | | if (wrkMastMapper.selectCrnWorking(crnProtocol.getCrnNo()) != null) { |
| | | return; |
| | | } |
| | | if (System.currentTimeMillis() - crnProtocol.getLastCommandTime() < 1000 * 60 * 2) { |
| | | continue; |
| | | } |
| | | |
| | | //输送线没有入库任务,过滤2 |
| | | if (wrkMastMapper.selectDevWorking(crnProtocol.getCrnNo()) == null) { |
| | | return; |
| | | Object object = redisUtil.get(RedisConstantType.CRN_MOVE_LOCK); |
| | | if (object != null) { |
| | | continue; |
| | | } |
| | | |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("crn_no", crn.getId()) |
| | | .notIn("wrk_sts", 5, 14, 15) |
| | | ); |
| | | if (!wrkMasts.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | CrnSlave.CrnStn crnStn = crn.getCrnInStn().get(0); |
| | | |
| | | News.info("堆垛机无任务自动回入库口待机==>>" + crnProtocol.getCrnNo() + "号堆垛机"); |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号 |
| | | crnCommand.setTaskNo((short) 9999); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.CRN_MOVE); // 任务模式: 堆垛机移动 |
| | | crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 源库位排 |
| | | crnCommand.setSourcePosY((short) 1); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) 1); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 0); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 0); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 0); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error("堆垛机移动命令下发失败,堆垛机号={},任务数据={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | crnThread.setBackHpFlag(true); |
| | | redisUtil.set(RedisConstantType.CRN_MOVE_LOCK + crn.getId(), "lock", 60); |
| | | try { |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | News.info("堆垛机召回原点==>>" + crnProtocol.getCrnNo() + "号堆垛机有入库任务,召回原点"); |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 堆垛机编号 |
| | | crnCommand.setTaskNo((short) 9999); // 工作号 |
| | | crnCommand.setAckFinish((short) 0); // 任务完成确认位 |
| | | crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 任务模式: 回原点 |
| | | crnCommand.setSourcePosX((short) 0); // 源库位排 |
| | | crnCommand.setSourcePosY((short) 0); // 源库位列 |
| | | crnCommand.setSourcePosZ((short) 0); // 源库位层 |
| | | crnCommand.setDestinationPosX((short) 0); // 目标库位排 |
| | | crnCommand.setDestinationPosY((short) 0); // 目标库位列 |
| | | crnCommand.setDestinationPosZ((short) 0); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, crnCommand))) { |
| | | News.error("堆垛机回原点命令下发失败,堆垛机号={},任务数据={}", crnProtocol.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } |
| | | crnThread.setBackHpFlag(true); |
| | | } |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | // 判断堆垛机出库站状态 |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") |
| | | && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { |
| | | && staProtocol.getWorkNo() == 0) { |
| | | |
| | | //根据参数判断是否校验可出信号 |
| | | String crnOutVerifyOut = "Y"; |
| | | Config crnOutVerifyOutEnableConfig = configService.selectOne(new EntityWrapper<Config>() |
| | | .eq("code", "crnOutVerifyOutEnable")); |
| | | if(crnOutVerifyOutEnableConfig != null) { |
| | | crnOutVerifyOut = crnOutVerifyOutEnableConfig.getValue(); |
| | | } |
| | | |
| | | if (crnOutVerifyOut.equals("Y")) { |
| | | if (!staProtocol.isOutEnable()) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 堆垛机控制过滤 |
| | |
| | | ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | ledCommand.setLocNo(wrkMast.getLocNo()); |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | ledCommand.setBarcode(wrkMast.getBarcode()); |
| | | // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | |
| | | // }catch (Exception e){ |
| | | // log.error("工作档案明细输入电视机失败1:异常信息==》"+e); |
| | | // } |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getWeight(),wrkDetl.getSpecs(),wrkDetl.getSku()))); |
| | | 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() |
| | | ))); |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | // VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | |
| | | |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | // VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | |
| | | |
| | | // RGV ===>> 执行对RGV操作 |
| | | public synchronized void rgvExecute(Integer mark) { |
| | | ArrayList<Integer> list = new ArrayList<Integer>(){{add(1090);add(1091);}}; |
| | | ArrayList<Integer> list = new ArrayList<Integer>(){{add(2003);add(2002);}}; |
| | | for (Integer staNo : list) { |
| | | Integer devpId = null; |
| | | Integer rgvStaNo = null; |
| | | if (staNo == 1090) { |
| | | if (staNo == 2003) { |
| | | devpId = 1; |
| | | rgvStaNo = 1091; |
| | | rgvStaNo = 2002; |
| | | }else { |
| | | devpId = 2; |
| | | rgvStaNo = 1090; |
| | | rgvStaNo = 2003; |
| | | } |
| | | |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devpId); |
| | |
| | | |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | // && staProtocol.isInEnable() |
| | | && staProtocol.getWorkNo() > 0 |
| | | ) { |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | |
| | | } |
| | | |
| | | // 状态:等待确认 并且 任务完成位 = 1 |
| | | if (rgvProtocol.statusType == RgvStatusType.WAITING && rgvProtocol.getTaskNo1() != 0) { |
| | | if (rgvProtocol.statusType1 == RgvStatusType.WAITING && rgvProtocol.getTaskNo1() != 0) { |
| | | News.warnNoLog(""+mark+" - 0"+" - 开始执行对RGV工作档的完成操作"); |
| | | // 获取入库待确认工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo1().intValue()); |
| | | if (wrkMast == null) { |
| | | News.error(""+mark+" - 1"+" - RGV处于等待确认且任务完成状态,但未找到工作档。RGV号={},工作号={}", rgvSlave.getId(), rgvProtocol.getTaskNo1()); |
| | | continue; |
| | | } |
| | | |
| | | if (Cools.isEmpty(wrkMast.getMemo())) { |
| | | News.error(""+mark+" - 1"+" - RGV处于等待确认且任务完成状态,但工作档数据异常。RGV号={},工作号={}", rgvSlave.getId(), rgvProtocol.getTaskNo1()); |
| | | continue; |
| | | } |
| | | |
| | |
| | | //入库 |
| | | wrkMast.setWrkSts(2L); |
| | | devpId = 1; |
| | | devpStaNo = 1090; |
| | | devpStaNo = 2003; |
| | | locNo = wrkMast.getLocNo(); |
| | | }else { |
| | | //出库 |
| | | wrkMast.setWrkSts(15L); |
| | | devpId = 2; |
| | | devpStaNo = 1091; |
| | | devpStaNo = 2002; |
| | | locNo = wrkMast.getSourceLocNo(); |
| | | } |
| | | |
| | |
| | | Date now = new Date(); |
| | | wrkMast.setModiTime(now); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | |
| | | rgvThread.setResetFlag1(true); |
| | | } |
| | | } |
| | | } |