| | |
| | | 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系统主流程业务 |
| | |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | | for (DevpSlave.Sta inSta : devp.getInSta()) { |
| | | inSta.setStaNo(102); |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | | if (barcodeThread == null) { |
| | |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | //staProtocol.setPakMk(true); |
| | | // // 入出库模式判断 |
| | | // if ( inSta.getStaNo()==180 && devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } |
| | | |
| | | // 判断是否满足入库条件 |
| | | 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; |
| | |
| | | // } |
| | | |
| | | try { |
| | | |
| | | 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(); |
| | |
| | | param.setIoType(1); |
| | | param.setSourceStaNo(inSta.getStaNo()); |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | param.setPackNo(pack); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | |
| | | } else if (jsonObject.getInteger("code").equals(700) && (!barcodeThread.getBarcode().equals("NG"))){ |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo((short)9998); |
| | | staProtocol.setStaNo((short)101); |
| | | staProtocol.setWorkNo((short)9999); |
| | | 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); |
| | | }else { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo((short)9998); |
| | | staProtocol.setStaNo((short)101); |
| | | staProtocol.setWorkNo((short)9999); |
| | | 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); |
| | |
| | | crnCommand.setSourcePosZ(crnStn.getLev().shortValue()); // 源库位层 |
| | | crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层 |
| | | crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层\ |
| | | crnCommand.setBarcode(wrkMast.getBarcode());//托盘码 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | |
| | | 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; |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 堆垛机控制过滤 |
| | |
| | | crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 目标库位层 |
| | | crnCommand.setBarcode(wrkMast.getBarcode()); |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | |
| | | 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 { |
| | |
| | | int olsStatus = 0;//testMast表原来status数据状态 |
| | | int newStatus = 0;//testMast表待修改的status数据状态 |
| | | short newSingle = 0; //PLC地址待修改的新值 |
| | | switch (devpThread.startSignal[i]){//根据信号查找testMast表中对应状态条件,olsStatus,newStatus根据实际流程调整 |
| | | case 1://启动复核信号 |
| | | olsStatus = 2; |
| | | newStatus = 3; |
| | | newSingle = 2;//测试复核,寄存器地址,1===>>2 |
| | | switch (devpThread.startSignal[i][0]){//根据信号查找testMast表中对应状态条件,olsStatus,newStatus根据实际流程调整 |
| | | case 0://初始状态,入库 |
| | | olsStatus = 1;//待测 |
| | | newStatus = 1;//待测 |
| | | newSingle = 1;//库存有资料,寄存器地址,0===>>1 |
| | | break; |
| | | case 3://完成测试信号 |
| | | olsStatus = 3; |
| | | newStatus = 4; |
| | | newSingle = 0;//测试完成,寄存器地址清零,3===>>0 |
| | | case 2://启动复核信号 |
| | | olsStatus = 1;//待测 |
| | | newStatus = 2;//复核中 |
| | | newSingle = 3;//测试复核,寄存器地址,2===>>3 |
| | | break; |
| | | case 5://暂停信号 |
| | | case 3://测试完成 |
| | | olsStatus = 4;//测试完成 |
| | | newStatus = 4;//测试完成 |
| | | newSingle = 4;//(NG:4\OK:41)测试完成,寄存器地址,3===>>4\41 |
| | | break; |
| | | case 5://NG测试信号 |
| | | case 6://完成测试信号 |
| | | case 22://完成测试信号 |
| | | olsStatus = 4;//测试完成 |
| | | newStatus = 5;//已移库 |
| | | newSingle = 0;//启动移库,寄存器地址清零,5/6===>>0 |
| | | break; |
| | | case 7://暂停信号 |
| | | olsStatus = 99;//plc给出暂停信号 |
| | | newStatus = 0;//WCS收到暂停信号后,更新testMast |
| | | newSingle = 6;//暂停测试,寄存器地址,5===>>6 |
| | | newSingle = 8;//暂停测试,寄存器地址,7===>>8 |
| | | break; |
| | | case 7://紧急出库确认充电线已经拔出 |
| | | case 9://紧急出库确认充电线已经拔出 |
| | | olsStatus = 99;//plc给出暂停信号 |
| | | newStatus = 0;//WCS收到暂停信号后,更新testMast |
| | | newSingle = 6;//暂停测试,寄存器地址,7===>>6 |
| | | newSingle = 8;//暂停测试,寄存器地址,9===>>8 |
| | | break; |
| | | case 8://解除暂停 |
| | | olsStatus = 99; |
| | | newStatus = 0; |
| | | newSingle = 0;//测试复核,寄存器地址,8===>>0 |
| | | case 10://解除暂停信号 |
| | | olsStatus = 0;//plc给出暂停信号 |
| | | newStatus = 1;//WCS收到暂停信号后,更新testMast |
| | | newSingle = 0;//暂停测试,寄存器地址,10===>>0/11 |
| | | break; |
| | | case 11://入库前判断充电线是否放好 |
| | | olsStatus = 99; |
| | | newStatus = 0; |
| | | newSingle = 11;// |
| | | case 12://紧急出库确认充电线已经拔出 |
| | | newSingle = 11;//暂停测试,寄存器地址,12===>>11 |
| | | break; |
| | | case 12://充电线放好 |
| | | olsStatus = 99; |
| | | newStatus = 0; |
| | | newSingle = 0;//测试复核,寄存器地址,12===>>0 |
| | | case 13://入库前判断充电线是否放好 |
| | | newSingle = 14;//禁用库位,寄存器地址,13===>>14 |
| | | break; |
| | | case 15://充电线放好 |
| | | newSingle = 0;//复位,寄存器地址,12===>>0 |
| | | break; |
| | | default: |
| | | log.info("读取通道"+(i+1)+"测试库位按钮信号:为"+devpThread.startSignal[i][0]); |
| | | continue; |
| | | } |
| | | |
| | | TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("channel",(i+1)).eq("status",olsStatus));//查找原来的状态 |
| | | if(null != testMast && |
| | | (devpThread.startSignal[i] == 1 || devpThread.startSignal[i] == 3)){ |
| | | testMast.setStatus(newStatus); |
| | | testMast.setModiTime(new Date()); |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>() |
| | | .eq("channel",(i+1)).eq("status",olsStatus))){ |
| | | throw new CoolException("更新产品测试状态失败"); |
| | | } |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,1==>2或3==>0,5==>6 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | LocMast locMast=null; |
| | | boolean sign=false; |
| | | switch (devpThread.startSignal[i][0]){ |
| | | case 0: |
| | | if (!Cools.isEmpty(testMast)){ |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (!Cools.isEmpty(locMast) && locMast.getLocSts().equals("F")){ |
| | | sign=true; |
| | | } |
| | | } |
| | | break; |
| | | case 3: |
| | | if (!Cools.isEmpty(testMast)){ |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (!Cools.isEmpty(locMast) && locMast.getLocSts().equals("F")){ |
| | | sign=true; |
| | | if (locMast.getPackStatus()==3){//测试完成 |
| | | newSingle=41; |
| | | }else if (locMast.getPackStatus()==4){//测试失败 |
| | | newSingle=4; |
| | | }else { |
| | | log.info("读取通道"+(i+1)+"测试库位按钮信号:为"+devpThread.startSignal[i][0]+"通道库位pack状态信息异常"+locMast.getPackStatus()); |
| | | sign=false; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case 5: |
| | | case 6: |
| | | if (!Cools.isEmpty(testMast)){ |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (!Cools.isEmpty(locMast) && locMast.getLocSts().equals("F")){ |
| | | if (devpThread.startSignal[i][0]==5 && locMast.getPackStatus()==4){ |
| | | sign=true; |
| | | }else if (devpThread.startSignal[i][0]==6 && locMast.getPackStatus()==3){ |
| | | sign=true; |
| | | }else { |
| | | log.error("测试完成移库时按下完成按钮与测试结果不一致===>>[channel:{}", i+1); |
| | | } |
| | | }else { |
| | | log.error("测试完成移库时未查询到测试档案===>>[channel:{}", i+1); |
| | | } |
| | | } |
| | | break; |
| | | case 2: |
| | | if (!Cools.isEmpty(testMast)){ |
| | | testMast.setStatus(newStatus); |
| | | testMast.setModiTime(new Date()); |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>().eq("channel",(i+1)).eq("barcode",testMast.getBarcode()))){ |
| | | throw new CoolException("更新产品测试状态失败"); |
| | | }else { |
| | | sign=true; |
| | | } |
| | | }else { |
| | | log.error("启动测试时未查询到测试档案===>>[channel:{}", i+1); |
| | | } |
| | | break; |
| | | case 7: |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setBarcode(i+1+""); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/mobile/test/suspend/auth") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | testMast = testMastService.selectOne(new EntityWrapper<TestMast>().eq("channel",(i+1))); |
| | | testMast.setStatus(newStatus); |
| | | testMast.setModiTime(new Date()); |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>().eq("channel",(i+1)).eq("barcode",testMast.getBarcode()))){ |
| | | log.error("更新产品测试状态失败"); |
| | | } |
| | | sign=true; |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl+"/mobile/test/suspend/auth", JSON.toJSONString(param), response); |
| | | } |
| | | break; |
| | | case 9: |
| | | case 12: |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (!Cools.isEmpty(locMast) && locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D")){ |
| | | locMast.setPackStatus(8); //8.紧急出库 |
| | | if (locMastService.update(locMast,new EntityWrapper<LocMast>().eq("channel",(i+1)))){ |
| | | log.info("库位:{},紧急出库!",locMast.getLocNo()); |
| | | } |
| | | }else { |
| | | log.error("库位不是在库状态,无需紧急出库!"); |
| | | } |
| | | sign=true; |
| | | break; |
| | | case 10: |
| | | if (!Cools.isEmpty(testMast)){ |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (!Cools.isEmpty(locMast) && locMast.getLocSts().equals("F") ){ |
| | | if ( locMast.getFireStatus().equals(1)){ |
| | | newSingle=11; |
| | | }else { |
| | | testMast.setStatus(newStatus); |
| | | testMast.setModiTime(new Date()); |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>().eq("channel",(i+1)).eq("barcode",testMast.getBarcode()))){ |
| | | throw new CoolException("更新产品测试状态失败"); |
| | | }else { |
| | | sign=true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | sign=true; |
| | | break; |
| | | case 13: |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (locMast.getLocSts().equals("O")){ |
| | | locMast.setLocSts("X"); |
| | | locMastService.update(locMast,new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | } |
| | | sign=true; |
| | | break; |
| | | case 15: |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if (locMast.getLocSts().equals("X")){ |
| | | locMast.setLocSts("O"); |
| | | locMastService.update(locMast,new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | } |
| | | sign=true; |
| | | break; |
| | | default: |
| | | log.info("读取通道"+(i+1)+"测试库位按钮信号:为"+devpThread.startSignal[i][0]); |
| | | continue; |
| | | } |
| | | if (sign){ |
| | | boolean result = messageQueueOffer(i,newSingle,SlaveType.Devp, devp.getId()); |
| | | if(!result){ |
| | | log.error("更新测试信号失败===>>[channel:{},locNo:{},barcode:{}]", i+1, testMast.getLocNo(), testMast.getBarcode()); |
| | | // throw new CoolException("更新测试信号失败===>>" + i); |
| | | } else { |
| | | devpThread.startSignal[i] = newSingle; |
| | | devpThread.startSignal[i][0] = newSingle; |
| | | } |
| | | }else if (devpThread.startSignal[i] == 5){ |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setBarcode(i+1+""); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/mobile/test/suspend/auth") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,5==>6 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | if(!result){ |
| | | log.error("暂停测试失败===>>["+i+1+"]号通道"); |
| | | // throw new CoolException("更新测试信号失败===>>" + i); |
| | | } else { |
| | | devpThread.startSignal[i] = newSingle; |
| | | } |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl+"/mobile/test/suspend/auth", JSON.toJSONString(param), response); |
| | | } |
| | | try{ |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",(i+1))); |
| | | if(devpThread.startSignal[i][1]!=locMast.getFireStatus()){ |
| | | messageQueueOffer2(i+1,(short)((int)locMast.getFireStatus()),SlaveType.Devp, devp.getId()); |
| | | } |
| | | }else if (devpThread.startSignal[i] == 7){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("channel",(i+1))); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | locMast.setPackStatus(8); //8.紧急出库 |
| | | locMastService.update(locMast,new EntityWrapper<LocMast>() |
| | | .eq("channel",(i+1))); |
| | | } |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,7==>6 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | if(!result){ |
| | | log.error("更新库位紧急出库信号失败===>>[channel:{},locNo:{},barcode:{}]", i+1, locMast.getLocNo(), locMast.getBarcode()); |
| | | // throw new CoolException("更新测试信号失败===>>" + i); |
| | | } else { |
| | | devpThread.startSignal[i] = newSingle; |
| | | } |
| | | }else if (devpThread.startSignal[i] == 8){ |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,8==>0 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | if(!result){ |
| | | // log.error("更新库位紧急出库信号失败===>>[channel:{},locNo:{},barcode:{}]", i+1, locMast.getLocNo(), locMast.getBarcode()); |
| | | // throw new CoolException("更新测试信号失败===>>" + i); |
| | | } else { |
| | | devpThread.startSignal[i] = newSingle; |
| | | } |
| | | }else if (devpThread.startSignal[i] == 11){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("channel",(i+1))); |
| | | if (locMast.getLocSts().equals("O")){ |
| | | locMast.setLocSts("X"); |
| | | locMastService.update(locMast,new EntityWrapper<LocMast>() |
| | | .eq("channel",(i+1))); |
| | | } |
| | | }else if (devpThread.startSignal[i] == 12){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("channel",(i+1))); |
| | | if (locMast.getLocSts().equals("X")){ |
| | | locMast.setLocSts("O"); |
| | | locMastService.update(locMast,new EntityWrapper<LocMast>() |
| | | .eq("channel",(i+1))); |
| | | } |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,12==>0 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); |
| | | if(!result){ |
| | | // log.error("更新库位紧急出库信号失败===>>[channel:{},locNo:{},barcode:{}]", i+1, locMast.getLocNo(), locMast.getBarcode()); |
| | | // throw new CoolException("更新测试信号失败===>>" + i); |
| | | } else { |
| | | devpThread.startSignal[i] = newSingle; |
| | | } |
| | | }else { } |
| | | }catch (Exception e){ |
| | | log.error("火警 ===>> 给输送线发送警报失败,通道号:", i+1); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public boolean messageQueueOffer(int i ,short newSingle,SlaveType devp,Integer id){ |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i*2);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,8==>0 |
| | | return MessageQueue.offer(devp, id, new Task(3, staProtocol)); |
| | | } |
| | | |
| | | public boolean messageQueueOffer2(int i ,short newSingle,SlaveType devp,Integer id){ |
| | | //复位PLC信号,借用输送站点实体类 |
| | | StaProtocol staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i);//寄存器地址 |
| | | staProtocol.setStaNo(newSingle);//修改PLC寄存器地址值,8==>0 |
| | | return MessageQueue.offer(devp, id, new Task(5, staProtocol)); |
| | | } |
| | | |
| | | /** |
| | | * 将火警报警信号写入到堆垛机PLC中 |
| | | */ |
| | |
| | | public void fierCrn() { |
| | | try { |
| | | for (CrnSlave crn :slaveProperties.getCrn()) { |
| | | if(crn.getId()!=1){ |
| | | continue; |
| | | } |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | 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("火警 ===>> 给堆垛机清零复位报警信号失败"); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 103站点有物下发pack码 |
| | | */ |
| | | @Transactional |
| | | public void packDevp() { |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no",103)); |
| | | if (Cools.isEmpty(basDevp)){ |
| | | log.error("103站点查询失败-MainServiceImpl.java-2255行"); |
| | | } |
| | | if (basDevp.getAutoing().equals("Y") && basDevp.getWrkNo()>0 && basDevp.getLoading().equals("Y") ){ |
| | | WrkDetl wrkDetl = wrkDetlService.devpPackNo(basDevp.getWrkNo()); |
| | | if (Cools.isEmpty(wrkDetl)){ |
| | | log.error("103站点查询失败-MainServiceImpl.java-2255行"); |
| | | } |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4,wrkDetl.getMatnr())); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("103 ===>> 给输送线发送Pack码失败", e); |
| | | e.printStackTrace(); |
| | | 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()); |
| | | testMastService.insertPackQualified(true,new Date()); |
| | | }else if(devpThread.startSignal[i][0]==5){ |
| | | locMast.setPackStatus(4); |
| | | testMast.setStatus(4); |
| | | testMast.setModiTime(new Date()); |
| | | testMastService.insertPackQualified(false,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(); |
| | | } |
| | | } |
| | | } |