| | |
| | | |
| | | @Autowired |
| | | private HikUtils hikUtils; |
| | | @Autowired |
| | | private AgvTaskServiceImpl agvTaskService; |
| | | |
| | | /** |
| | | * 组托 |
| | |
| | | //LED |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | |
| | | // 尺寸检测异常 |
| | | boolean back = false; |
| | | String errMsg = ""; |
| | | if (staProtocol.isFrontError()) { |
| | | errMsg = "前超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isBackError()) { |
| | | errMsg = "后超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isHighError()) { |
| | | errMsg = "高超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isLeftError()) { |
| | | errMsg = "左超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isRightError()) { |
| | | errMsg = "右超限"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isWeightError()) { |
| | | errMsg = "超重"; |
| | | back = true; |
| | | } |
| | | if (!back && staProtocol.isBarcodeError()) { |
| | | errMsg = "扫码失败"; |
| | | back = true; |
| | | } |
| | | |
| | | // 判断是否满足入库条件 |
| | | if (!staProtocol.isLoading()) { |
| | | continue; |
| | |
| | | && staProtocol.isPakMk()) { |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行"); |
| | | |
| | | if (back) { |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = errMsg; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); |
| | | } |
| | | log.error("输送线异常组托退回={}",errMsg); |
| | | staProtocol.setWorkNo((short) 9999); |
| | | |
| | | staProtocol.setStaNo((short) 0); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | continue; |
| | | } |
| | | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if (!Cools.isEmpty(barcode)) { |
| | | News.info("" + mark + " - 1" + " - {}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)|| "00000000".equals(barcode)) { |
| | | // staProtocol.setWorkNo((short) 9992); |
| | | // staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && staProtocol.getWorkNo() > 0 |
| | | && staProtocol.getWorkNo() == 9991 |
| | | && staProtocol.isPakMk()) { |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行"); |
| | | |
| | |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | String name="401"; |
| | | if (staProtocol.getSiteId()==402){ |
| | | name = "402"; |
| | | } |
| | | String bar = ""; |
| | | Config name1 = configService.selectOne(new EntityWrapper<Config>().eq("name", name)); |
| | | if (!Cools.isEmpty(name1)) { |
| | | bar = name1.getValue(); |
| | | } |
| | | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if (barcode.equals("00000000")){ |
| | | barcode = bar; |
| | | } |
| | | if (!Cools.isEmpty(barcode)) { |
| | | News.info("" + mark + " - 1" + " - {}号条码扫描器检测条码信息:{}", insta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | |
| | | throw new CoolException("保存工作明细档历史档失败"); |
| | | } |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | |
| | | if (!wrkMastLogService.save(wrkMast.getWrkNo())) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | } |
| | | |
| | |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading()) { |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | |
| | | if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue()) |
| | | && (crnProtocol.statusType == CrnStatusType.PUTTING || crnProtocol.statusType == CrnStatusType.WAITING)) { |
| | | && crnProtocol.statusType == CrnStatusType.WAITING) { |
| | | //放货中 或 等待确认 |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行"); |
| | | |
| | |
| | | .eq("loc_no", wrkMast.getSourceLocNo())); |
| | | |
| | | short staNo = wrkMast.getStaNo().shortValue(); |
| | | if (wrkMast.getStaNo() == 1004) { |
| | | staNo = 2003; |
| | | } |
| | | |
| | | // 下发站点信息 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | |
| | | } |
| | | //查询在库信息 |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "R") |
| | | .in("loc_sts", "R","P") |
| | | .eq("loc_no", wrkMast.getSourceLocNo())); |
| | | if (Cools.isEmpty(locMast)) { |
| | | News.error("出库 ===>> 库位中没有这笔资料", wrkMast.getSourceLocNo()); |
| | |
| | | } |
| | | } |
| | | |
| | | // 判断堆垛机出库站状态 |
| | | // 判断堆垛机出库站状态&& staProtocol.isOutEnable() |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") |
| | | && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable() && staProtocol.isEmptyOutType()) { |
| | | && staProtocol.isEmptyOutType()) { |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | //判断是否有正在执行中的AGV任务 |
| | | List<AgvTask> agvTasks = agvTaskService.selectList(new EntityWrapper<AgvTask>().eq("wrk_sts", 302).eq("source_sta_no", staProtocol.getSiteId())); |
| | | if (agvTasks != null && agvTasks.size() > 0) { |
| | | continue; |
| | | } |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | // continue; |
| | |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // // 工作档集合 |
| | | // List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | List<Integer> workNoList = new ArrayList<>(); |
| | | // 工作档集合 |
| | | List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | for (Integer staNo : led.getStaArr()) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | Integer wrkNo = null; |
| | | Integer ioType = null; |
| | | Integer targetStaNo = null; |
| | | String sourceLocNo = null; |
| | | String locNo = null; |
| | | String barcode = null; |
| | | |
| | | // 获取工作档数据 |
| | | WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); |
| | | // if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } |
| | | if (null == wrkMast) { |
| | | List<WrkMastLog> wrkMastLogs = wrkMastLogService.selectList(new EntityWrapper<WrkMastLog>() |
| | | .eq("wrk_no", staProtocol.getWorkNo()) |
| | | .orderBy("modi_time", false) |
| | | ); |
| | | if (wrkMastLogs.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | WrkMastLog wrkMastLog = wrkMastLogs.get(0); |
| | | wrkNo = wrkMastLog.getWrkNo(); |
| | | ioType = wrkMastLog.getIoType(); |
| | | sourceLocNo = wrkMastLog.getSourceLocNo(); |
| | | locNo = wrkMastLog.getLocNo(); |
| | | targetStaNo = wrkMastLog.getStaNo(); |
| | | barcode = wrkMastLog.getBarcode(); |
| | | }else { |
| | | wrkNo = wrkMast.getWrkNo(); |
| | | ioType = wrkMast.getIoType(); |
| | | sourceLocNo = wrkMast.getSourceLocNo(); |
| | | locNo = wrkMast.getLocNo(); |
| | | targetStaNo = wrkMast.getStaNo(); |
| | | barcode = wrkMast.getBarcode(); |
| | | continue; |
| | | } |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行:出库 ===>> 工作档信息写入led显示器"); |
| | | workNoList.add(wrkNo); |
| | | News.warnNoLog(""+mark+" - 0"+" - 开始执行:出库 ===>> 工作档信息写入led显示器"); |
| | | wrkMasts.add(wrkMast); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(wrkNo); |
| | | ledCommand.setIoType(ioType); |
| | | ledCommand.setWorkNo(wrkMast.getWrkNo()); |
| | | ledCommand.setIoType(wrkMast.getIoType()); |
| | | // 出库模式 |
| | | switch (ioType) { |
| | | switch (wrkMast.getIoType()) { |
| | | case 1: |
| | | ledCommand.setTitle("全板入库"); |
| | | break; |
| | |
| | | ledCommand.setTitle("并板入库"); |
| | | break; |
| | | default: |
| | | News.error("" + mark + " - 1" + " - 任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkNo, ioType); |
| | | News.error(""+mark+" - 1"+" - 任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); |
| | | break; |
| | | } |
| | | ledCommand.setSourceLocNo(sourceLocNo); |
| | | ledCommand.setLocNo(locNo); |
| | | ledCommand.setStaNo(targetStaNo); |
| | | ledCommand.setBarcode(barcode); |
| | | ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | ledCommand.setLocNo(wrkMast.getLocNo()); |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); |
| | | if (ioType != 110 && ioType != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkNo); |
| | | |
| | | 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$() |
| | | )); |
| | | |
| | | }else { |
| | | List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectTodayByWrkNo(wrkNo); |
| | | if(!wrkDetlLogs.isEmpty()) { |
| | | WrkDetlLog wrkDetlLog = wrkDetlLogs.get(0); |
| | | |
| | | double anfme = 0D; |
| | | double weight = 0D; |
| | | for (WrkDetlLog detl : wrkDetlLogs) { |
| | | anfme += detl.getAnfme(); |
| | | weight += detl.getWeight(); |
| | | wrkDetlLog.setAnfme(anfme); |
| | | wrkDetlLog.setWeight(weight); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | | try{ |
| | | if (wrkMast.getIoType()>100){ |
| | | for (WrkDetl wrkDetl : wrkDetls){ |
| | | LocDetl locDetl = locDetlService.selectMatnrSpecs(wrkDetl.getMatnr(), wrkDetl.getSpecs(), wrkMast.getSourceLocNo()); |
| | | wrkDetl.setWeight(locDetl.getAnfme()); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", sourceLocNo)); |
| | | double totalAnfme = 0D; |
| | | double totalWeight = 0D; |
| | | for (LocDetl locDetl : locDetls) { |
| | | totalAnfme += locDetl.getAnfme(); |
| | | totalWeight += locDetl.getWeight(); |
| | | }else { |
| | | for (WrkDetl wrkDetl : wrkDetls){ |
| | | wrkDetl.setWeight(wrkDetl.getAnfme()); |
| | | } |
| | | wrkDetlLog.setStockNum(totalAnfme); |
| | | wrkDetlLog.setStockNum2(totalWeight); |
| | | |
| | | ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetlLog.getMatnr() |
| | | , wrkDetlLog.getMaktx() |
| | | , wrkDetlLog.getAnfme() |
| | | , wrkDetlLog.getWeight() |
| | | , wrkDetlLog.getStockNum() |
| | | , wrkDetlLog.getStockNum2() |
| | | , wrkDetlLog.getSpecs() |
| | | , wrkDetlLog.getSku() |
| | | , wrkDetlLog.getZpallet() |
| | | , wrkDetlLog.getModel() |
| | | , wrkDetlLog.getSupp() |
| | | , wrkDetlLog.getKpCstmrName() |
| | | , wrkDetlLog.getOrderNo() |
| | | , wrkDetlLog.getCstateid$() |
| | | )); |
| | | } |
| | | }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()))); |
| | | } |
| | | commands.add(ledCommand); |
| | | } |
| | | Set<Integer> workNos = new HashSet<>(workNoList); |
| | | Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); |
| | | // 获取LED线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | // 相同工作号集合则过滤 |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | // 修改主档led标记 |
| | | for (Integer wrkNo : workNoList) { |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkNo)); |
| | | if (wrkMast != null) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | News.errorNoLog("" + mark + " - 4" + " - 更新工作档失败"); |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | News.errorNoLog(""+mark+" - 4"+" - 更新工作档失败"); |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | News.infoNoLog("" + mark + " - 0" + " - 出库 ===>> 工作档信息写入led显示器执行完成"); |
| | | News.infoNoLog(""+mark+" - 0"+" - 出库 ===>> 工作档信息写入led显示器执行完成"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public synchronized void ledReset(Integer mark) { |
| | | |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行:其他 ===>> LED显示器复位,显示默认信息"); |
| | | News.warnNoLog(""+mark+" - 0"+" - 开始执行:其他 ===>> LED显示器复位,显示默认信息"); |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | |
| | | // 获取输送线plc线程 |
| | |
| | | if (reset && !ledThread.isLedMk()) { |
| | | ledThread.setLedMk(true); |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { |
| | | News.error("" + mark + " - 1" + " - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | News.error(""+mark+" - 1"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | } |
| | | News.infoNoLog("" + mark + " - 0" + " - 执行完成:其他 ===>> LED显示器复位,显示默认信息"); |
| | | News.infoNoLog(""+mark+" - 0"+" - 执行完成:其他 ===>> LED显示器复位,显示默认信息"); |
| | | } |
| | | |
| | | /** |