| | |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.web.WcsController; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.WorkMastHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private MonitorLocMapCacheService monitorLocMapCacheService; |
| | | @Autowired |
| | | private WorkMastHandler workMastHandler; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | Integer outSta = staNo.getDevNo(); |
| | | |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta); |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, outSta); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | |
| | | LocMast locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | // 获取路径 |
| | | int ioType = taskDto.isAll() ? 101 : 103; |
| | | StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, locMast.getCrnNo(), staNo.getDevNo()); |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, staNo.getDevNo()); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | int yz=staDesc.getStnNo()*10+Integer.valueOf(taskDto.getLocNo().substring(6)); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(yz); // 源站 |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | |
| | | orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); |
| | | } |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locDto.getLocNo()).eq("matnr", locDto.getMatnr())); |
| | | Mat mat=matService.selectOne(new EntityWrapper<Mat>().eq("matnr",locDto.getMatnr())); |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", locDto.getMatnr())); |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(orderDetl); |
| | | wrkDetl.setZpallet(wrkMast.getBarcode()); |
| | |
| | | wrkMast.setStaNo(param.getOutSite()); // 目标站 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locNo); // 源库位 |
| | | wrkMast.setIoPri(10.0+locMast.getLocAttribute());//优先级 |
| | | wrkMast.setIoPri(10.0D);//优先级 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | } |
| | | if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) { |
| | | long sts = wrkMast.getWrkSts(); |
| | | if (sts == 4 || sts == 5 || sts == 14 || sts == 15 || sts == 20) { |
| | | throw new CoolException("当前工作档已完成"); |
| | | } |
| | | // 入库 + 库位转移 |
| | | if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) { |
| | | boolean inboundFinish = wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType() != null && wrkMast.getIoType() == 11); |
| | | boolean outboundFinish = wrkMast.getWrkSts() > 10 && (wrkMast.getIoType() == null || wrkMast.getIoType() != 11); |
| | | if (!inboundFinish && !outboundFinish) { |
| | | throw new CoolException("当前工作状态无法手动完成"); |
| | | } |
| | | if (inboundFinish) { |
| | | wrkMast.setWrkSts(4L); |
| | | // 出库 |
| | | } else if (wrkMast.getWrkSts() > 10) { |
| | | } else { |
| | | wrkMast.setWrkSts(14L); |
| | | } |
| | | Date now = new Date(); |
| | |
| | | wrkMast.setCrnEndTime(now); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | // 完成操作人员记录 |
| | | wrkMast.setManuType("手动完成"); |
| | | ReturnT<String> rt = workMastHandler.start(wrkMast); |
| | | if (!rt.isSuccess()) { |
| | | throw new CoolException(Cools.isEmpty(rt.getMsg()) ? "完成处理失败" : rt.getMsg()); |
| | | } |
| | | // doOut 对 103/107 不落 15 时,手动补齐 15;源库位 O 与定时任务 doOut 一致 |
| | | if (wrkMast.getWrkSts() == 14) { |
| | | wrkMast.setWrkSts(15L); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | if (!Cools.isEmpty(wrkMast.getSourceLocNo())) { |
| | | LocMast src = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (!Cools.isEmpty(src) && !"O".equals(src.getLocSts())) { |
| | | Integer io = wrkMast.getIoType(); |
| | | if (io != null && (io == 101 || io == 110)) { |
| | | src.setLocSts("O"); |
| | | src.setModiTime(now); |
| | | src.setIoTime(now); |
| | | src.setModiUser(userId); |
| | | if (!locMastService.updateById(src)) { |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else if ("R".equals(src.getLocSts())) { |
| | | src.setLocSts("O"); |
| | | src.setModiTime(now); |
| | | src.setIoTime(now); |
| | | src.setModiUser(userId); |
| | | if (!locMastService.updateById(src)) { |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | wrkMast.setManuType("手动完成"); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setCrnStrTime(DateUtils.calculate(now, 1L, TimeUnit.SECONDS, true)); |
| | | wrkMast.setCrnEndTime(now); |
| | | wrkMast.setModiTime(now); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("修改工作档失败"); |
| | | } |
| | | monitorLocMapCacheService.clearQuietly(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | } |
| | | |
| | | // // 订单关联 |
| | | // List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | // for (WrkDetl wrkDetl : wrkDetls) { |
| | | // if (!Cools.isEmpty(wrkDetl.getOrderNo())) { |
| | | // if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { |
| | | // throw new CoolException("订单数据回滚失败"); |
| | | // } |
| | | // // 生成新的出库作业 |
| | | //// stockOutRe(wrkMast, wrkDetls); |
| | | // } |
| | | // } |
| | | |
| | | // 取消操作人员记录 |
| | | wrkMast.setManuType("手动取消"); |
| | | wrkMast.setModiUser(userId); |
| | |
| | | if (!wrkMastRes || !locMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | | monitorLocMapCacheService.clearQuietly(); |
| | | } |
| | | |
| | | @Override |