| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.enums.WorkNoType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.mapper.BasCrnErrorMapper; |
| | | import com.zy.asrs.mapper.TestMastMapper; |
| | |
| | | |
| | | |
| | | // 退回 |
| | | if (back ||(!Cools.isEmpty(barcode) && barcode.equals("00000000"))) { |
| | | if (back || (!Cools.isEmpty(barcode) && barcode.equals("00000000"))) { |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | |
| | | WrkMast wrkMast = null; |
| | | if (Cools.isEmpty(wrkMasts)) { |
| | | return; |
| | | }else { |
| | | } else { |
| | | wrkMast = wrkMasts.get(0); |
| | | } |
| | | // //后查等待库位转测试库位 |
| | |
| | | if (null == wrkMast) { |
| | | continue; |
| | | } |
| | | log.info(""+mark+" - 0"+" - 开始执行:出库 ===>> 工作档信息写入led显示器"); |
| | | log.info("" + mark + " - 0" + " - 开始执行:出库 ===>> 工作档信息写入led显示器"); |
| | | wrkMasts.add(wrkMast); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | |
| | | ledCommand.setEmptyMk(true); |
| | | break; |
| | | default: |
| | | News.error(""+mark+" - 1"+" - 任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); |
| | | News.error("" + mark + " - 1" + " - 任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); |
| | | break; |
| | | } |
| | | ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | |
| | | // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs()))); |
| | | wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getSpecs()))); |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | }else { |
| | | } else { |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | log.error(""+mark+" - 4"+" - 更新工作档失败"); |
| | | log.error("" + mark + " - 4" + " - 更新工作档失败"); |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | log.info(""+mark+" - 0"+" - 出库 ===>> 工作档信息写入led显示器执行完成"); |
| | | log.info("" + mark + " - 0" + " - 出库 ===>> 工作档信息写入led显示器执行完成"); |
| | | } |
| | | |
| | | /** |
| | |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | if(null != devpThread){ |
| | | if (null != devpThread) { |
| | | //devpThread.startSignal[i][0] |
| | | //0:空闲,1:待测,2:测试中;3.测试完成;4.测试失败; |
| | | |
| | |
| | | |
| | | //testMast.setStatus |
| | | //"状态 0: 无货 1: 等待测试 2:测试中 3.测试完成;4.测试失败; " |
| | | for (int i = 0; i < 24; i++){ |
| | | for (int i = 0; i < 24; i++) { |
| | | //查询在库和预约出库 |
| | | LocMast locMast=locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel",i+1)); |
| | | if(!Cools.isEmpty(locMast)){ |
| | | if (locMast.getLocSts().equals("F")){ |
| | | TestMast testMast=testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("loc_no",locMast.getLocNo()) |
| | | .eq("user_id",locMast.getBarcode())); |
| | | if(Cools.isEmpty(testMast)){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("channel", i + 1)); |
| | | if (!Cools.isEmpty(locMast)) { |
| | | if (locMast.getLocSts().equals("F")) { |
| | | TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("loc_no", locMast.getLocNo()) |
| | | .eq("user_id", locMast.getBarcode())); |
| | | if (Cools.isEmpty(testMast)) { |
| | | // log.info("2377行程序开始运行,测试档为空,跳过"); |
| | | continue; |
| | | } |
| | | HashMap<String,Short> hashMap=new HashMap<>(); |
| | | if(devpThread.startSignal[i][0]!=locMast.getPackStatus()){ |
| | | hashMap.put("locSts",locMast.getPackStatus().shortValue()); |
| | | hashMap.put("channel",(short)(i*2)); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(6,hashMap)); |
| | | HashMap<String, Short> hashMap = new HashMap<>(); |
| | | if (devpThread.startSignal[i][0] != locMast.getPackStatus()) { |
| | | hashMap.put("locSts", locMast.getPackStatus().shortValue()); |
| | | hashMap.put("channel", (short) (i * 2)); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(6, hashMap)); |
| | | } |
| | | //同步设备状态 |
| | | if(locMast.getPackStatus()!=testMast.getStatus()){ |
| | | if (locMast.getPackStatus() != testMast.getStatus()) { |
| | | testMast.setStatus(locMast.getPackStatus()); |
| | | testMastService.updateById(testMast); |
| | | } |
| | | if(devpThread.startSignal[i][1]!=locMast.getCtnKind()){ |
| | | if (devpThread.startSignal[i][1] != locMast.getCtnKind()) { |
| | | locMast.setCtnKind(devpThread.startSignal[i][1]); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | }else if(locMast.getLocSts().equals("O")){ |
| | | } else if (locMast.getLocSts().equals("O")) { |
| | | //当充放电库位为O空库位时 |
| | | //库位状态改为0空闲 |
| | | locMast=locMastService.selectztgx("O",i); |
| | | if(!Cools.isEmpty(locMast)){ |
| | | HashMap<String,Short> hashMap=new HashMap<>(); |
| | | if(devpThread.startSignal[i][0]!=locMast.getPackStatus()){ |
| | | hashMap.put("locSts",(short)0); |
| | | hashMap.put("channel",(short)(i*2)); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(6,hashMap)); |
| | | locMast = locMastService.selectztgx("O", i); |
| | | if (!Cools.isEmpty(locMast)) { |
| | | HashMap<String, Short> hashMap = new HashMap<>(); |
| | | if (devpThread.startSignal[i][0] != locMast.getPackStatus()) { |
| | | hashMap.put("locSts", (short) 0); |
| | | hashMap.put("channel", (short) (i * 2)); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(6, hashMap)); |
| | | locMast.setPackStatus(0); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | |
| | | if(devpThread.startSignal[i][1]!=locMast.getChannel()){ |
| | | if (devpThread.startSignal[i][1] != locMast.getChannel()) { |
| | | locMast.setCtnKind(devpThread.startSignal[i][1]); |
| | | locMastService.updateById(locMast); |
| | | } |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 出库站点无货时自动补空板到出库口 |
| | | */ |
| | | public void automaticEmptyBoardOutbound() { |
| | | // 获取入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | StaProtocol staProtocol = devpThread.getStation().get(101); |
| | | if (staProtocol == null) { |
| | | return; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() |
| | | && staProtocol.isOutEnable() && staProtocol.getWorkNo() == 0 |
| | | ) { |
| | | WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("io_type", 110)); |
| | | if (!Cools.isEmpty(wrkMast1)) { |
| | | return; |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "D").orderBy("row1")); |
| | | if (Cools.isEmpty(locMast)) { |
| | | return; |
| | | } |
| | | //生成空板出库任务 |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PAKOUT.type); |
| | | // 获取源站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", 110) |
| | | .eq("stn_no", 101) |
| | | .eq("crn_no", locMast.getCrnNo()); |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | Integer sourceStaNo = staDesc.getCrnStn(); |
| | | if (Cools.isEmpty(sourceStaNo)) { |
| | | throw new CoolException("检索源站失败"); |
| | | } |
| | | Date now = new Date(); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(110); // 入出库状态: 110.空板出库 |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setSourceStaNo(sourceStaNo); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeUser(9995L); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(9995L); |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新库位状态 D.空板 -> R.出库预约 |
| | | if (locMast.getLocSts().equals("D")){ |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(9995L); |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("更新库位状态失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |