| | |
| | | import com.zy.core.thread.SiemensCrnThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Async; |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | staProtocol.setPakMk(true); |
| | | // // 入出库模式判断 |
| | | // if ( inSta.getStaNo()==180 && devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } |
| | | staProtocol.setPakMk(true); |
| | | // 判断是否满足入库条件 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | |
| | | // } |
| | | |
| | | // 判断重复工作档 |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); |
| | | WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode.substring(0,6)); |
| | | if (wrkMast != null) { |
| | | log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo()); |
| | | continue; |
| | |
| | | String pack =null;//pack码 |
| | | if(barcode.length()>6){ |
| | | pack=barcode.substring(6); |
| | | if(pack.equals("00000000000000000000")){ |
| | | log.error("没有获得Pack码",pack); |
| | | continue; |
| | | } |
| | | } |
| | | //String pack="MJY0136 0400"; |
| | | barcode=barcode.substring(0,6);//托盘码 |
| | | if(barcode.equals("000000")){ |
| | | log.error("没有获得条码",barcode); |
| | | continue; |
| | | } |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | locTypeDto.setLocType1((short)1); |
| | | SearchLocParam param = new SearchLocParam(); |
| | |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo((short)9998); |
| | | staProtocol.setStaNo((short)101); |
| | | staProtocol.setStaNo((short)201); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | log.error("url:{};request:{};response:{}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo((short)9998); |
| | | staProtocol.setStaNo((short)101); |
| | | staProtocol.setStaNo((short)201); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | |
| | | break; |
| | | // continue; |
| | | } |
| | | //查询在库信息 |
| | | LocMast locMast =locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","R") |
| | | .eq("loc_no",wrkMast.getSourceLocNo())); |
| | | if(Cools.isEmpty(locMast)){ |
| | | log.error("出库 ===>> 库位中没有这笔资料",wrkMast.getSourceLocNo()); |
| | | continue; |
| | | } |
| | | |
| | | |
| | | // 判断堆垛机出库站状态 |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() !=null && staDetl.getCanouting().equals("Y") |
| | | && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { |
| | | //测试库位出库必须要按启动按钮才能出库 |
| | | if(wrkMast.getStaNo()==206 && locMast.getCtnKind()==0){ |
| | | log.error("出库 ===>> 等待启动出库按钮",wrkMast); |
| | | continue; |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 堆垛机控制过滤 |
| | |
| | | return; |
| | | } |
| | | |
| | | //测试库位出库必须要按启动按钮才能出库 |
| | | if(sourceSta.getLocType1()==1 && sourceSta.getCtnKind()==0){ |
| | | log.error("出库 ===>> 等待启动按钮",wrkMast); |
| | | return; |
| | | } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | |
| | | crnCommand.setDestinationPosX(sta.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 目标库位层 |
| | | if(!sta.getLocNo().equals("0102501")){ |
| | | crnCommand.setBarcode(wrkMast.getBarcode());//托盘码 |
| | | }else { |
| | | crnCommand.setFireStaut((short) 1); |
| | | } |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (!Cools.isEmpty(locMast) && locMast.getLocSts().equals("F")){ |
| | | sign=true; |
| | | if (locMast.getPackStatus()==3){ |
| | | if (locMast.getPackStatus()==3){//测试完成 |
| | | newSingle=41; |
| | | }else if (locMast.getPackStatus()==4){ |
| | | }else if (locMast.getPackStatus()==4){//测试失败 |
| | | newSingle=4; |
| | | }else { |
| | | log.info("读取通道"+(i+1)+"测试库位按钮信号:为"+devpThread.startSignal[i][0]+"通道库位pack状态信息异常"+locMast.getPackStatus()); |
| | |
| | | } |
| | | try{ |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | messageQueueOffer2(i,(short)((int)locMast.getFireStatus()),SlaveType.Devp, devp.getId()); |
| | | if(devpThread.startSignal[i][1]!=locMast.getFireStatus()){ |
| | | messageQueueOffer2(i+1,(short)((int)locMast.getFireStatus()),SlaveType.Devp, devp.getId()); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("火警 ===>> 给输送线发送警报失败,通道号:", i+1); |
| | | } |
| | |
| | | public boolean messageQueueOffer2(int i ,short newSingle,SlaveType devp,Integer id){ |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setSiteId(i);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,8==>0 |
| | | return MessageQueue.offer(devp, id, new Task(5, staProtocol)); |
| | | } |
| | |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("fire_status", 1)); |
| | | if (!Cools.isEmpty(locMast)){ |
| | | //报警信号写入1 |
| | | if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, (short)1))) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, "1"))) { |
| | | log.error("火警 ===>> 给堆垛机发送报警信号失败"); |
| | | } |
| | | } else { |
| | | //报警信号没有后,复位地址 |
| | | if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, (short)0))) { |
| | | if (!MessageQueue.offer(SlaveType.Crn, 1, new Task(4, "0"))) { |
| | | log.error("火警 ===>> 给堆垛机清零复位报警信号失败"); |
| | | } |
| | | } |
| | |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("bas_devp",103)); |
| | | BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no",103)); |
| | | if (Cools.isEmpty(basDevp)){ |
| | | log.error("103站点查询失败-MainServiceImpl.java-2255行"); |
| | | } |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | /** |
| | | * 根据PLC按钮测试、完成、暂停信号,更新testMast表中status值,交由WMS系统处理 |
| | | */ |
| | | @Transactional |
| | | public void packTest1() { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | if(null != devpThread){ |
| | | for (int i = 0; i < 48; i++){ |
| | | //查询在库和预约出库 |
| | | LocMast locMast=locMastService.selectztgx("F","R",i); |
| | | if(!Cools.isEmpty(locMast)){ |
| | | TestMast testMast=testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("loc_no",locMast.getLocNo()) |
| | | .eq("user_id",locMast.getBarcode())); |
| | | if(Cools.isEmpty(testMast)){ |
| | | continue; |
| | | } |
| | | //devpThread.startSignal[i][0] |
| | | //0:空,1:启动中,2:工作中,3:自动暂停,4:正常完成(OK),5:异常停止(NG),6:在线,7:离线,8:空闲 |
| | | |
| | | //locMast.setPackStatus |
| | | // "产品状态{0:无,1:待测,2:测试中;3.测试完成;4.测试失败;5.静置中;6:静置完成;7:暂停测试;8:紧急出库;9:在线;10:离线;11:空闲;}" |
| | | |
| | | //testMast.setStatus |
| | | //"状态 0: 待申请 1: 申请中 2: 已复核 3:测试中 4:完成 5:移库 6:火警" |
| | | if(devpThread.startSignal[i][0]==1){ |
| | | testMast.setStatus(1); |
| | | testMast.setModiTime(new Date()); |
| | | }else if(devpThread.startSignal[i][0]==2){ |
| | | testMast.setStatus(3); |
| | | testMast.setModiTime(new Date()); |
| | | }else if(devpThread.startSignal[i][0]==3){ |
| | | locMast.setPackStatus(7); |
| | | testMast.setModiTime(new Date()); |
| | | }else if(devpThread.startSignal[i][0]==4){ |
| | | locMast.setPackStatus(3); |
| | | testMast.setStatus(4); |
| | | testMast.setModiTime(new Date()); |
| | | }else if(devpThread.startSignal[i][0]==5){ |
| | | locMast.setPackStatus(4); |
| | | testMast.setStatus(4); |
| | | testMast.setModiTime(new Date()); |
| | | } |
| | | // else if(devpThread.startSignal[i][0]==6||devpThread.startSignal[i][0]==7||devpThread.startSignal[i][0]==8){ |
| | | // locMast.setPackStatus(devpThread.startSignal[i][0]+3); |
| | | // } |
| | | //通道启动按钮状态,1:可以启动出库或者移库,0:不能启动出库或者移库 |
| | | locMast.setCtnKind(devpThread.startSignal[i][2]); |
| | | if(devpThread.startSignal[i][2]==1){ |
| | | if(!locMastService.update(locMast,new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","R") |
| | | .eq("channel",i+1))){ |
| | | log.error("修改启动按钮状态,测试库位状态失败"+locMast.getLocNo(),locMast); |
| | | } |
| | | }else if(!locMast.getLocSts().equals("R")){ |
| | | if(!locMastService.update(locMast,new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","F") |
| | | .eq("channel",i+1))){ |
| | | log.error("修改测试库位状态失败"+locMast.getLocNo(),locMast); |
| | | } |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>() |
| | | .eq("loc_no",locMast.getLocNo()) |
| | | .eq("user_id",locMast.getBarcode()))) { |
| | | log.error("修改测试档状态失败" + locMast.getLocNo(), locMast); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //给PLC写消防信号 |
| | | for (int i=0;i<48;i++){ |
| | | LocMast locMast=locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",i+1)); |
| | | TestMast testMast=testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("loc_no",locMast.getLocNo()) |
| | | .eq("user_id",locMast.getBarcode())); |
| | | try{ |
| | | if(locMast.getFireStatus()!=devpThread.startSignal[i][1]){ |
| | | messageQueueOffer2(i,(short)((int)locMast.getFireStatus()),SlaveType.Devp, devp.getId()); |
| | | if(Cools.isEmpty(testMast)){ |
| | | continue; |
| | | } |
| | | if(locMast.getFireStatus()==1){ |
| | | testMast.setStatus(6);//火警 |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>() |
| | | .eq("loc_no",locMast.getLocNo()) |
| | | .eq("user_id",locMast.getBarcode()))) { |
| | | log.error("修改测试档状态失败" + locMast.getLocNo(), locMast); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("火警 ===>> 给输送线发送警报失败,通道号:", i+1); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("获得测试库位状态失败", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | } |