| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private BasErrLogService basErrLogService; |
| | | @Autowired |
| | | private BasSteErrLogService basSteErrLogService; |
| | | @Autowired |
| | | private BasCrnErrorMapper basCrnErrorMapper; |
| | | @Autowired |
| | | private BasSteService basSteService; |
| | | @Autowired |
| | | private WrkChargeService wrkChargeService; |
| | | @Autowired |
| | | private BasSteErrService basSteErrService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | // log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { |
| | | staProtocol.setWorkNo((short) 9995); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | // led 异常显示 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | if (ledThread != null) { |
| | | String errorMsg = "扫码失败,请重试"; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | continue; |
| | | } |
| | | } else { |
| | | staProtocol.setWorkNo((short) 9995); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | // led 异常显示 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | if (ledThread != null) { |
| | | String errorMsg = "扫码失败,请重试"; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | // plc 处理 |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } else if (code == 500){ |
| | | if (ledThread != null) { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } else if (code == 700) { |
| | | staProtocol.setWorkNo((short) 9995); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = barcode + "托盘识别异常,请先进行组托!"; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){ |
| | | |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); |
| | | if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); |
| | | // if (barcodeThread == null) { |
| | | // continue; |
| | | // } |
| | | // String barcode = barcodeThread.getBarcode(); |
| | | // if(!Cools.isEmpty(barcode)) { |
| | | // log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode); |
| | | // if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { |
| | | // continue; |
| | | // } |
| | | // } else { |
| | | // continue; |
| | | // } |
| | | |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo()); |
| | | if (wrkMast == null) { |
| | | // 无拣料数据 |
| | | continue; |
| | |
| | | |
| | | try { |
| | | // 保存工作明细档历史档 |
| | | if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作明细档历史档失败"); |
| | | } |
| | | // if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | // throw new CoolException("保存工作明细档历史档失败"); |
| | | // } |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { |
| | | // throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 过滤 |
| | | if (null != wrkMastMapper.selectPakout(slave.getId(), null)) { |
| | | log.error("{}入库任务无法作业,因存在出库中任务!", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | |
| | | // 置顶任务 |
| | | wrkMast.setIoPri((double) 9999); |
| | | wrkMastMapper.updateById(wrkMast); |
| | |
| | | // 目标库位 ===>> 最外层库位 |
| | | if (locMastService.isOutMost(wrkMast.getLocNo())) { |
| | | // 判断小车是否在最外层库位,如果是则搬走,如果不是,则直接堆垛机入库 |
| | | Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo()); |
| | | Integer steNo = this.hasCar(wrkMast.getLocNo()); |
| | | // 有小车 |
| | | if (steNo != null) { |
| | | // 小车行走到堆垛机待搬移点 |
| | | if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) { |
| | | // if (null != wrkMastMapper.selectPakin(slave.getId(), steNo)) { |
| | | // continue; |
| | | // } |
| | | this.letCarBeReady(wrkMast, steNo, wrkMast.getLocNo()); |
| | | } |
| | | // 小车搬走 |
| | |
| | | |
| | | // 堆垛机控制过滤 |
| | | if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { |
| | | continue; |
| | | } |
| | | |
| | | // 过滤 |
| | | if (null != wrkMastMapper.selectPakin(slave.getId(), null)) { |
| | | log.error("{}出库任务无法作业,因存在入库中任务!", wrkMast.getWrkNo()); |
| | | continue; |
| | | } |
| | | |
| | |
| | | if (locMastService.isOutMost(wrkMast.getSourceLocNo())) { |
| | | // 目标库位 ===>> 最外层库位 |
| | | if (locMastService.isOutMost(wrkMast.getLocNo())) { |
| | | // todo:luxiaotao 判断目标库位是否存在小车,如果存在,则搬走小车 |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setCrnNo(slave.getId()); // 堆垛机编号 |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 当前库位组是否存在空闲小车 |
| | | */ |
| | | public Integer hasCar(String locNo) { |
| | | for (SteSlave ste : slaveProperties.getSte()) { |
| | | // 获取堆垛机信息 |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { continue; } |
| | | if (Utils.getGroupRow(locNo).equals(Utils.getGroupRow(steProtocol.getRow().intValue())) && steProtocol.getBay() == Utils.getBay(locNo) && steProtocol.getLev() == Utils.getLev(locNo)) { |
| | | return steProtocol.getSteNo().intValue(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | continue; |
| | | } |
| | | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); |
| | | String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); |
| | | String errName = crnError==null? "未知异常":crnError.getErrName(); |
| | | BasErrLog basErrLog = new BasErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | |
| | | // 记录新异常 |
| | | if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) { |
| | | BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); |
| | | String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); |
| | | String errName = crnError==null? "未知异常":crnError.getErrName(); |
| | | BasErrLog basErrLog = new BasErrLog( |
| | | null, // 编号 |
| | | null, // 工作号 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 穿梭车异常信息记录 |
| | | */ |
| | | @Async |
| | | public void recSteErr(){ |
| | | Date now = new Date(); |
| | | for (SteSlave ste : slaveProperties.getSte()) { |
| | | // 获取堆垛机信息 |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | if (steProtocol == null) { |
| | | continue; |
| | | } |
| | | // 有任务 |
| | | if (steProtocol.getTaskNo() != 0) { |
| | | BasSteErrLog latest = basSteErrLogService.findLatestByTaskNo(ste.getId(), steProtocol.getTaskNo().intValue()); |
| | | // 有异常 |
| | | if (latest == null) { |
| | | if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) { |
| | | WrkMast wrkMast = wrkMastMapper.selectById(steProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm()); |
| | | String errName = steErr==null? "未知异常":steErr.getErrName(); |
| | | BasSteErrLog basSteErrLog = new BasSteErrLog( |
| | | null, // 编号 |
| | | wrkMast.getWrkNo(), // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | wrkMast.getWrkSts(), // 工作状态 |
| | | wrkMast.getIoType(), // 入出库类型 |
| | | ste.getId(), // 堆垛机 |
| | | null, // plc |
| | | wrkMast.getLocNo(), // 目标库位 |
| | | wrkMast.getStaNo(), // 目标站 |
| | | wrkMast.getSourceStaNo(), // 源站 |
| | | wrkMast.getSourceLocNo(), // 源库位 |
| | | wrkMast.getBarcode(), // 条码 |
| | | (int) steProtocol.getAlarm(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "任务中异常" // 备注 |
| | | ); |
| | | if (!basSteErrLogService.insert(basSteErrLog)) { |
| | | log.error("穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", ste.getId(), errName); |
| | | } |
| | | } |
| | | } else { |
| | | // 异常修复 |
| | | if (steProtocol.getAlarm() == null || !steProtocol.isAlarm()) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basSteErrLogService.updateById(latest)) { |
| | | log.error("穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | // 无任务 |
| | | } else { |
| | | BasSteErrLog latest = basSteErrLogService.findLatest(ste.getId()); |
| | | // 有异常 |
| | | if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) { |
| | | // 记录新异常 |
| | | if (latest == null || (latest.getErrCode() != steProtocol.getAlarm().intValue())) { |
| | | BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm()); |
| | | String errName = steErr==null? "未知异常":steErr.getErrName(); |
| | | BasSteErrLog basSteErrLog = new BasSteErrLog( |
| | | null, // 编号 |
| | | null, // 工作号 |
| | | now, // 发生时间 |
| | | null, // 结束时间 |
| | | null, // 工作状态 |
| | | null, // 入出库类型 |
| | | ste.getId(), // 堆垛机 |
| | | null, // plc |
| | | null, // 目标库位 |
| | | null, // 目标站 |
| | | null, // 源站 |
| | | null, // 源库位 |
| | | null, // 条码 |
| | | (int)steProtocol.getAlarm(), // 异常码 |
| | | errName, // 异常 |
| | | 1, // 异常情况 |
| | | now, // 添加时间 |
| | | null, // 添加人员 |
| | | now, // 修改时间 |
| | | null, // 修改人员 |
| | | "无任务异常" // 备注 |
| | | ); |
| | | if (!basSteErrLogService.insert(basSteErrLog)) { |
| | | log.error("穿梭车plc异常记录失败 ===>> [id:{}] [error:{}]", ste.getId(), errName); |
| | | } |
| | | } |
| | | // 无异常 |
| | | } else { |
| | | // 异常修复 |
| | | if (latest != null && latest.getStatus() == 1) { |
| | | latest.setEndTime(now); |
| | | latest.setUpdateTime(now); |
| | | latest.setStatus(2); |
| | | if (!basSteErrLogService.updateById(latest)) { |
| | | log.error("穿梭车plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // ------------------------------------------------------------------------------- |
| | | |
| | |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | // 站点条件判断 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() |
| | | && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 && staProtocol.getWorkNo() <= 9999) || staProtocol.getWorkNo() == 9997) && staProtocol.isPakMk()) { |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable() |
| | | && staProtocol.isEmptyMk() |
| | | && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 || staProtocol.getWorkNo() <= 9999)) |
| | | && staProtocol.isPakMk()) { |
| | | |
| | | // 获取条码扫描仪信息 |
| | | String barcode = null; |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); |
| | | if (barcodeThread != null) { |
| | | String barcode0 = barcodeThread.getBarcode(); |
| | | if(!Cools.isEmpty(barcode0)) { |
| | | // log.info("{}号条码扫描器检测条码信息:{}", emptyInSta.getBarcode(), barcode0); |
| | | if(!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) { |
| | | barcode = barcode0; |
| | | } |
| | | } |
| | | } |
| | | |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); |
| | | |
| | | try { |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setIoType(10); |
| | | if (!Cools.isEmpty(barcode)) { |
| | | param.setBarcode(barcode); |
| | | } |
| | | param.setSourceStaNo(emptyInSta.getStaNo()); |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | String response = new HttpHandler.Builder() |
| | |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | if (ledThread != null) { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | |
| | | |
| | | public List<String> crn1DemoLocs = new ArrayList<String>(); public String crn1LastLoc = ""; |
| | | public List<String> crn2DemoLocs = new ArrayList<String>(); public String crn2LastLoc = ""; |
| | | public List<String> crn3DemoLocs = new ArrayList<String>(); public String crn3LastLoc = ""; |
| | | public synchronized void demo() { |
| | | if (Cools.isEmpty(crn1DemoLocs)) { |
| | | crn1DemoLocs = locMastService.getDemoNextLoc(1); |
| | | } |
| | | if (Cools.isEmpty(crn2DemoLocs)) { |
| | | crn2DemoLocs = locMastService.getDemoNextLoc(2); |
| | | } |
| | | if (Cools.isEmpty(crn3DemoLocs)) { |
| | | crn3DemoLocs = locMastService.getDemoNextLoc(3); |
| | | } |
| | | for (CrnSlave crn : slaveProperties.getCrn()) { |
| | | // 获取堆垛机信息 |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { |
| | | if (!crn.getDemo()) { |
| | | continue; |
| | | } |
| | | BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); |
| | | if (basCrnp == null) { |
| | | log.error("{}号堆垛机尚未在数据库进行维护!", crn.getId()); |
| | | continue; |
| | | } // 必须为演示状态 |
| | | |
| | | // CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); |
| | | // CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | // if (crnProtocol == null) { |
| | | // continue; |
| | | // } |
| | | |
| | | // 只有当堆垛机空闲 并且 无任务时才继续执行 |
| | | // if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { |
| | | |
| | | String locNo = null; |
| | | Iterator<String> iterator = crn1DemoLocs.iterator(); |
| | | if (crn.getId() == 1) { |
| | | iterator = crn1DemoLocs.iterator(); |
| | | } else if (crn.getId() == 2) { |
| | | iterator = crn2DemoLocs.iterator(); |
| | | } else if (crn.getId() == 3) { |
| | | iterator = crn3DemoLocs.iterator(); |
| | | } |
| | | while (iterator.hasNext()) { |
| | | String next = iterator.next(); |
| | | String lastLoc = ""; |
| | | if (crn.getId() == 1) { |
| | | lastLoc = crn1LastLoc; |
| | | } else if (crn.getId() == 2) { |
| | | lastLoc = crn2LastLoc; |
| | | } else if (crn.getId() == 3) { |
| | | lastLoc = crn3LastLoc; |
| | | } |
| | | if (!Cools.isEmpty(lastLoc)) { |
| | | if (!lastLoc.substring(2, 7).equals(next.substring(2, 7)) || !Utils.getGroupRow(lastLoc).equals(Utils.getGroupRow(next))) { |
| | | locNo = next; |
| | | iterator.remove(); |
| | | break; |
| | | } else { |
| | | iterator.remove(); |
| | | } |
| | | } else { |
| | | locNo = next; |
| | | iterator.remove(); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | if (!Cools.isEmpty(locNo)) { |
| | | if (crn.getId() == 1) { |
| | | crn1LastLoc = locNo; |
| | | } else if (crn.getId() == 2) { |
| | | crn2LastLoc = locNo; |
| | | } else if (crn.getId() == 3) { |
| | | crn3LastLoc = locNo; |
| | | } |
| | | } |
| | | |
| | | // log.info("{}号堆垛机对{}库位进行演示", crn.getId(), locNo); |
| | | |
| | | // 获取移库工作档信息 |
| | | // WrkMast wrkMast = wrkMastMapper.selectLocMove(crn.getId()); |
| | | // if (null != wrkMast) { continue; } |
| | | // |
| | | // LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId()); |
| | | // LocMast loc = locMastService.queryDemoLoc(crn.getId()); |
| | | // if (null == sourceLoc || null == loc) { continue; } |
| | | // |
| | | // String sourceLocNo = sourceLoc.getLocNo(); |
| | | // String locNo = loc.getLocNo(); |
| | | // |
| | | // // 获取工作号 |
| | | // int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // // 保存工作档 |
| | | // wrkMast = new WrkMast(); |
| | | // wrkMast.setWrkNo(workNo); |
| | | // wrkMast.setIoTime(new Date()); |
| | | // wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | // wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | // wrkMast.setIoPri(13D); |
| | | // wrkMast.setCrnNo(crn.getId()); |
| | | // wrkMast.setSourceLocNo(sourceLocNo); // 源库位 |
| | | // wrkMast.setLocNo(locNo); // 目标库位 |
| | | // wrkMast.setFullPlt("N"); // 满板:Y |
| | | // wrkMast.setPicking("N"); // 拣料 |
| | | // wrkMast.setExitMk("N"); // 退出 |
| | | // wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板 |
| | | // wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码 |
| | | // wrkMast.setLinkMis("N"); |
| | | // wrkMast.setAppeTime(new Date()); |
| | | // wrkMast.setModiTime(new Date()); |
| | | // int res = wrkMastMapper.insert(wrkMast); |
| | | // if (res == 0) { |
| | | // throw new CoolException("保存工作档失败"); |
| | | // } |
| | | |
| | | } |
| | | |
| | | } |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol == null) { continue; } |
| | | |
| | | log.info("{}号堆垛机正在演示", crn.getId()); |
| | | |
| | | // 只有当堆垛机空闲 并且 无任务时才继续执行 |
| | | if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { |
| | | // 获取移库工作档信息 |
| | | WrkMast wrkMast = wrkMastMapper.selectLocMove(crn.getId()); |
| | | if (null != wrkMast) { continue; } |
| | | |
| | | LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId()); |
| | | LocMast loc = locMastService.queryDemoLoc(crn.getId()); |
| | | if (null == sourceLoc || null == loc) { continue; } |
| | | |
| | | String sourceLocNo = sourceLoc.getLocNo(); |
| | | String locNo = loc.getLocNo(); |
| | | |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // 保存工作档 |
| | | wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | wrkMast.setIoPri(13D); |
| | | wrkMast.setCrnNo(crn.getId()); |
| | | wrkMast.setSourceLocNo(sourceLocNo); // 源库位 |
| | | wrkMast.setLocNo(locNo); // 目标库位 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板 |
| | | wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | int res = wrkMastMapper.insert(wrkMast); |
| | | if (res == 0) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 工作档明细保存 |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | // 修改源库位状态 |
| | | if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { |
| | | sourceLoc.setLocSts("R"); // R.出库预约 |
| | | sourceLoc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(sourceLoc)){ |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("源库位出库失败"); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(loc)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败"); |
| | | } |
| | | // // 获取移库工作档信息 |
| | | // WrkMast wrkMast = wrkMastMapper.selectLocMove(crn.getId()); |
| | | // if (null != wrkMast) { continue; } |
| | | // |
| | | // LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId()); |
| | | // LocMast loc = locMastService.queryDemoLoc(crn.getId()); |
| | | // if (null == sourceLoc || null == loc) { continue; } |
| | | // |
| | | // String sourceLocNo = sourceLoc.getLocNo(); |
| | | // String locNo = loc.getLocNo(); |
| | | // |
| | | // // 获取工作号 |
| | | // int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // // 保存工作档 |
| | | // wrkMast = new WrkMast(); |
| | | // wrkMast.setWrkNo(workNo); |
| | | // wrkMast.setIoTime(new Date()); |
| | | // wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | // wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | // wrkMast.setIoPri(13D); |
| | | // wrkMast.setCrnNo(crn.getId()); |
| | | // wrkMast.setSourceLocNo(sourceLocNo); // 源库位 |
| | | // wrkMast.setLocNo(locNo); // 目标库位 |
| | | // wrkMast.setFullPlt("N"); // 满板:Y |
| | | // wrkMast.setPicking("N"); // 拣料 |
| | | // wrkMast.setExitMk("N"); // 退出 |
| | | // wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板 |
| | | // wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码 |
| | | // wrkMast.setLinkMis("N"); |
| | | // wrkMast.setAppeTime(new Date()); |
| | | // wrkMast.setModiTime(new Date()); |
| | | // int res = wrkMastMapper.insert(wrkMast); |
| | | // if (res == 0) { |
| | | // throw new CoolException("保存工作档失败"); |
| | | // } |
| | | // // 工作档明细保存 |
| | | // List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); |
| | | // for (LocDetl locDetl : locDetls) { |
| | | // WrkDetl wrkDetl = new WrkDetl(); |
| | | // wrkDetl.sync(locDetl); |
| | | // wrkDetl.setWrkNo(workNo); |
| | | // wrkDetl.setIoTime(new Date()); |
| | | // wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | // wrkDetl.setAppeTime(new Date()); |
| | | // wrkDetl.setModiTime(new Date()); |
| | | // if (!wrkDetlService.insert(wrkDetl)) { |
| | | // throw new CoolException("保存工作档明细失败"); |
| | | // } |
| | | // } |
| | | // // 修改源库位状态 |
| | | // if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { |
| | | // sourceLoc.setLocSts("R"); // R.出库预约 |
| | | // sourceLoc.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(sourceLoc)){ |
| | | // throw new CoolException("更新源库位状态失败"); |
| | | // } |
| | | // } else { |
| | | // throw new CoolException("源库位出库失败"); |
| | | // } |
| | | // // 修改目标库位状态 |
| | | // if (loc.getLocSts().equals("O")) { |
| | | // loc.setLocSts("S"); // S.入库预约 |
| | | // loc.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(loc)) { |
| | | // throw new CoolException("更新目标库位状态失败"); |
| | | // } |
| | | // } else { |
| | | // throw new CoolException("移转失败"); |
| | | // } |
| | | |
| | | } |
| | | |