| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private BasCrnErrorMapper basCrnErrorMapper; |
| | | @Autowired |
| | | private WrkMastStaMapper wrkMastStaMapper; |
| | | @Autowired |
| | | private BasRgvService basRgvService; |
| | | @Autowired |
| | | private BasRgvMapMapper basRgvMapMapper; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private BasRgvMapService basRgvMapService; |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @Resource |
| | | private ApiLogService apiLogService; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | } |
| | | |
| | | try { |
| | | // 保存工作明细档历史档 |
| | | if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作明细档历史档失败"); |
| | | } |
| | | // 保存工作明细档历史档 //因为兼容u8工作模式 不能生成历史工作明细 |
| | | // if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | // throw new CoolException("保存工作明细档历史档失败"); |
| | | // } |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | |
| | | News.warnNoLog(""+mark+" - 1"+" - 12"+" - // F、D 库位状态={}",shallowLoc.getLocSts()); |
| | | // 此标记避免多次执行移库任务 |
| | | if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) { |
| | | wrkMast.setUpdMk("Y"); |
| | | wrkMast.setIoPri(14D); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | // 生成工作档,将浅库位移转到新的库位中 |
| | | moveLocForDeepLoc(slave, shallowLoc,mark); |
| | | // 生成工作档、改变浅库位的源库/目标库 库位状态、下发堆垛机命令(立马执行) |
| | | // moveLocForDeepLocPakin(slave, shallowLoc, wrkMast); |
| | | |
| | | if (moveLocForDeepLoc(slave, shallowLoc,mark)){ |
| | | wrkMast.setUpdMk("Y"); |
| | | wrkMast.setIoPri(14D); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | } |
| | | |
| | | } |
| | | continue; |
| | | } else if (shallowLoc.getLocSts().equals("Q")) { |
| | |
| | | // if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk()) |
| | | // || Cools.isEmpty(waitWrkMast)) { |
| | | if (Cools.isEmpty(waitWrkMast)) { |
| | | wrkMast.setUpdMk("Y"); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | // 生成工作档,将浅库位移转到新的库位中 |
| | | moveLocForDeepLoc(slave, shallowLoc,mark); |
| | | if (moveLocForDeepLoc(slave, shallowLoc,mark)){ |
| | | wrkMast.setUpdMk("Y"); |
| | | wrkMastMapper.updateById(wrkMast); |
| | | } |
| | | } |
| | | News.error("{}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo); |
| | | continue; |
| | |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | ledCommand.setBarcode(wrkMast.getBarcode()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | | List<WrkDetl> wrkDetls =wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); |
| | | |
| | | wrkDetls.forEach(wrkDetl -> { |
| | | Double total = 0.0; |
| | |
| | | } else { |
| | | total = locDetl.getAnfme(); |
| | | } |
| | | if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 1) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | if (!Cools.isEmpty(wrkDetl.getOrderNo())){ |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", wrkDetl.getOrderNo()) |
| | | .eq("matnr", wrkDetl.getMatnr()).eq("batch", wrkDetl.getBatch())); |
| | | if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 1) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total,orderDetl.getTemp1(),orderDetl.getTemp2())); |
| | | } |
| | | if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total,orderDetl.getTemp1(),orderDetl.getTemp2())); |
| | | } |
| | | if (wrkMast.getIoType() == 107 || wrkMast.getIoType() == 104) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total,orderDetl.getTemp1(),orderDetl.getTemp2())); |
| | | } |
| | | }else { |
| | | if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 1) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | if (wrkMast.getIoType() == 107 || wrkMast.getIoType() == 104) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | } |
| | | if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | if (wrkMast.getIoType() == 107 || wrkMast.getIoType() == 104) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | |
| | | |
| | | }); |
| | | } |
| | | commands.add(ledCommand); |
| | |
| | | * 因双深库位阻塞,对浅库位进行移转(立即执行版) |
| | | * tip:同步 |
| | | */ |
| | | private synchronized void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc,Integer mark) { |
| | | private synchronized boolean moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc,Integer mark) { |
| | | |
| | | try { |
| | | News.warnNoLog(""+mark+"moveLocForDeepLoc"+" - 0"+" - 开始执行:因双深库位阻塞,对浅库位进行移转(立即执行版)"); |
| | |
| | | |
| | | if (null == loc) { |
| | | News.error(""+mark+"moveLocForDeepLoc"+" - 1"+" - 双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo()); |
| | | throw new CoolException("双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo()); |
| | | } |
| | | |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 保存工作档 |
| | | WrkMast 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(shallowLoc.getLocNo()); // 源库位 |
| | | wrkMast.setLocNo(loc.getLocNo()); // 目标库位 |
| | | wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(shallowLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | int res = wrkMastMapper.insert(wrkMast); |
| | | if (res == 0) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 2"+" - 保存工作档失败"); |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 工作档明细保存 |
| | | if (shallowLoc.getLocSts().equals("F")) { |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 3"+" - 保存工作档明细失败"); |
| | | throw new CoolException("保存工作档明细失败"); |
| | | // throw new CoolException("双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo()); |
| | | return false; |
| | | }else { |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 保存工作档 |
| | | WrkMast 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(shallowLoc.getLocNo()); // 源库位 |
| | | wrkMast.setLocNo(loc.getLocNo()); // 目标库位 |
| | | wrkMast.setFullPlt(shallowLoc.getLocSts().equals("F") ? "Y" : "N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(shallowLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | int res = wrkMastMapper.insert(wrkMast); |
| | | if (res == 0) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 2"+" - 保存工作档失败"); |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 工作档明细保存 |
| | | if (shallowLoc.getLocSts().equals("F")) { |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制 |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 3"+" - 保存工作档明细失败"); |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 修改源库位状态 |
| | | if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) { |
| | | shallowLoc.setLocSts("R"); // R.出库预约 |
| | | shallowLoc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(shallowLoc)) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 4"+" - 更新源库位状态失败"); |
| | | throw new CoolException("更新源库位状态失败"); |
| | | // 修改源库位状态 |
| | | if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) { |
| | | shallowLoc.setLocSts("R"); // R.出库预约 |
| | | shallowLoc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(shallowLoc)) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 4"+" - 更新源库位状态失败"); |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 5"+" - 源库位出库失败"); |
| | | throw new CoolException("源库位出库失败"); |
| | | } |
| | | } else { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 5"+" - 源库位出库失败"); |
| | | throw new CoolException("源库位出库失败"); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(loc)) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 6"+" - 更新目标库位状态失败"); |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(loc)) { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 6"+" - 更新目标库位状态失败"); |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 7"+" - 移转失败"); |
| | | throw new CoolException("移转失败"); |
| | | } |
| | | } else { |
| | | News.errorNoLog(""+mark+"moveLocForDeepLoc"+" - 7"+" - 移转失败"); |
| | | throw new CoolException("移转失败"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | News.error(""+mark+"moveLocForDeepLoc"+" - 8"+" - 双深库位阻塞,对浅库位进行移转失败", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | // log.info("转发agv任务:请求体:"+JSONObject.toJSONString(requestParam)+",返回值:"+jsonObject); |
| | | }catch (Exception e){ |
| | | |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "出库呼叫agv", |
| | | url + path, |
| | | null, |
| | | "127.0.0.1", |
| | | JSONObject.toJSONString(requestParam), |
| | | response, |
| | | success.equals("SUCCESS") |
| | | ); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | return success; |
| | | } |