|  |  |  | 
|---|
|  |  |  | import com.core.common.SnowflakeIdWorker; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.EmptyPlateOutParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.FullStoreParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.LocDetlAdjustParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.StockOutParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.*; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.asrs.utils.Utils; | 
|---|
|  |  |  | import com.zy.common.model.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkDetlLogService wrkDetlLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SnowflakeIdWorker snowflakeIdWorker; | 
|---|
|  |  |  | private ManLocDetlService manLocDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | private SlaveProperties slaveProperties; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaitPakinService waitPakinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocOwnerService locOwnerService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | 
|---|
|  |  |  | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true); | 
|---|
|  |  |  | // 检索库位 | 
|---|
|  |  |  | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("source_sta_no", param.getDevpNo())); | 
|---|
|  |  |  | if (!wrkMasts.isEmpty()) { | 
|---|
|  |  |  | throw new CoolException("已有任务"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); | 
|---|
|  |  |  | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 1, param.getDevpNo(), matnrs, locTypeDto, 0); | 
|---|
|  |  |  | StartupDto dto = commonService.getLocNo(2, 1, param.getDevpNo(), null,null,null,0, locTypeDto,0); | 
|---|
|  |  |  | // 生成工作号 | 
|---|
|  |  |  | int workNo = dto.getWorkNo(); | 
|---|
|  |  |  | // 生成工作档 | 
|---|
|  |  |  | 
|---|
|  |  |  | assert ioType != null; | 
|---|
|  |  |  | // 获取库位 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectById(dto.getLocNo()); | 
|---|
|  |  |  | //zc | 
|---|
|  |  |  | if (!locMast.getLocSts().equals("F")){ | 
|---|
|  |  |  | throw new CoolException(locMast.getLocNo()+"该库位不是在库状态"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer outSta = staNo.getDevNo(); | 
|---|
|  |  |  | //2号堆垛机全板出库站指定为204站,拣料站指定为202 | 
|---|
|  |  |  | if(locMast.getCrnNo()==2){ | 
|---|
|  |  |  | outSta = ioType == 101 ? 204 : 202; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            //2号堆垛机全板出库站指定为204站,拣料站指定为202 | 
|---|
|  |  |  | //            if(locMast.getCrnNo()==2){ | 
|---|
|  |  |  | //                outSta = ioType == 101 ? 204 : 202; | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取路径 | 
|---|
|  |  |  | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 生成工作档明细 | 
|---|
|  |  |  | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { | 
|---|
|  |  |  | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} | 
|---|
|  |  |  | String uuid = String.valueOf(System.currentTimeMillis()); | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl.sync(detlDto.getLocDetl()); | 
|---|
|  |  |  | wrkDetl.setOrderNo(""); // 手动出库不需要带出库存中的单据编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkDetl.setAppeUser(userId); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  | wrkDetl.setModiUser(userId); | 
|---|
|  |  |  | wrkDetl.setUuid(uuid); | 
|---|
|  |  |  | wrkDetl.setOwner(detlDto.getLocDetl().getOwner()); | 
|---|
|  |  |  | wrkDetl.setPayment(detlDto.getLocDetl().getPayment()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | //            if (orderDetl == null) { | 
|---|
|  |  |  | //                orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | String uuid = String.valueOf(System.currentTimeMillis()); | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl.sync(orderDetl); | 
|---|
|  |  |  | wrkDetl.setZpallet(wrkMast.getBarcode()); | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkDetl.setAppeUser(userId); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  | wrkDetl.setModiUser(userId); | 
|---|
|  |  |  | wrkDetl.setUuid(uuid); | 
|---|
|  |  |  | wrkDetl.setOwner(orderDetl.getOwner()); | 
|---|
|  |  |  | wrkDetl.setPayment(orderDetl.getPayment()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); | 
|---|
|  |  |  | // 检索库位 | 
|---|
|  |  |  | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); | 
|---|
|  |  |  | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 10, devpNo, null, locTypeDto, 0); | 
|---|
|  |  |  | StartupDto dto = commonService.getLocNo(1, 10, devpNo, null,null,null,0, locTypeDto,0); | 
|---|
|  |  |  | int workNo = dto.getWorkNo(); | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | // 生成工作档 | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | throw new CoolException(locNo+"库位不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //zc | 
|---|
|  |  |  | if (!locMast.getLocSts().equals("D")){ | 
|---|
|  |  |  | throw new CoolException(locNo+"库位状态不对"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 获取源站 | 
|---|
|  |  |  | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", 110) | 
|---|
|  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public WrkMast emptyPlateOut(EmptyPlateOutParam param) { | 
|---|
|  |  |  | WrkMast wrkMast = new WrkMast(); | 
|---|
|  |  |  | if (Cools.isEmpty(param.getOutSite())) { | 
|---|
|  |  |  | throw new CoolException("站点不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (String locNo : param.getLocNos()) { | 
|---|
|  |  |  | // 获取工作号 | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(0); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 获取源站 | 
|---|
|  |  |  | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", 110) | 
|---|
|  |  |  | .eq("stn_no", param.getOutSite()) | 
|---|
|  |  |  | .eq("crn_no", locMast.getCrnNo()); | 
|---|
|  |  |  | .eq("crn_no", locMast.getCrnNo()) | 
|---|
|  |  |  | .eq("stn_no",param.getOutSite()); | 
|---|
|  |  |  | StaDesc staDesc = staDescService.selectOne(wrapper); | 
|---|
|  |  |  | Integer sourceStaNo = staDesc.getCrnStn(); | 
|---|
|  |  |  | if (Cools.isEmpty(sourceStaNo)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkMast.setIoType(110); // 入出库状态: 110.空板出库 | 
|---|
|  |  |  | wrkMast.setIoPri(10D); | 
|---|
|  |  |  | wrkMast.setSourceStaNo(sourceStaNo); // 源站 | 
|---|
|  |  |  | wrkMast.setStaNo(param.getOutSite()); // 目标站 | 
|---|
|  |  |  | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 | 
|---|
|  |  |  | wrkMast.setCrnNo(locMast.getCrnNo()); | 
|---|
|  |  |  | wrkMast.setSourceLocNo(locNo); // 源库位 | 
|---|
|  |  |  | wrkMast.setFullPlt("N"); // 满板:Y | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { | 
|---|
|  |  |  | throw new CoolException("移转库位属于不同堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //zc | 
|---|
|  |  |  | //        if (!loc.getLocSts().equals("F")){ | 
|---|
|  |  |  | //            throw new CoolException(locNo+"库位状态不对"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | // 获取工作号 | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); | 
|---|
|  |  |  | 
|---|
|  |  |  | wrkDetl.setAppeUser(userId); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  | wrkDetl.setModiUser(userId); | 
|---|
|  |  |  | wrkDetl.setOwner(locDetl.getOwner()); | 
|---|
|  |  |  | wrkDetl.setPayment(locDetl.getPayment()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) { | 
|---|
|  |  |  | wrkMast.setWrkSts(4L); | 
|---|
|  |  |  | // 出库 | 
|---|
|  |  |  | } else if (wrkMast.getWrkSts() > 10) { | 
|---|
|  |  |  | } else if (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()!=199) { | 
|---|
|  |  |  | wrkMast.setWrkSts(14L); | 
|---|
|  |  |  | }else if (wrkMast.getIoType() == 199) { | 
|---|
|  |  |  | wrkMast.setWrkSts(15L); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | wrkMast.setCrnStrTime(DateUtils.calculate(now, 1L, TimeUnit.SECONDS, true)); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(wrkMast)){ | 
|---|
|  |  |  | throw new CoolException(workNo+"工作档不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (wrkMast.getIoType() == 1 && (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 5)){ | 
|---|
|  |  |  | throw new CoolException(workNo+"不可取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (wrkMast.getIoType() == 101 && (wrkMast.getWrkSts() == 14 || wrkMast.getWrkSts() == 15)){ | 
|---|
|  |  |  | throw new CoolException(workNo+"不可取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String locNo = ""; // 待修改目标库位 | 
|---|
|  |  |  | String locSts = ""; // 待修改目标库位状态 | 
|---|
|  |  |  | // 入库取消(修改目标库位) | 
|---|
|  |  |  | 
|---|
|  |  |  | locMast.setModiUser(userId); | 
|---|
|  |  |  | locMastService.updateById(locMast); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (wrkMast.getIoType() == 199)  { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("当前工作状态无法取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 订单关联 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        // 订单关联 | 
|---|
|  |  |  | //        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("手动取消"); | 
|---|
|  |  |  | 
|---|
|  |  |  | // 删除工作档明细 | 
|---|
|  |  |  | boolean wrkDetlRes = wrkDetlService.delete(new EntityWrapper<WrkDetl>().eq("wrk_no", workNo)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (wrkMast.getIoType()!=199){ | 
|---|
|  |  |  | // 修改库位状态 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectById(locNo); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | throw new CoolException("取消工作档失败,库位不存在:"+ locNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locMast.setLocSts(locSts); | 
|---|
|  |  |  | locMast.setModiTime(now); | 
|---|
|  |  |  | locMast.setModiUser(userId); | 
|---|
|  |  |  | boolean locMastRes = locMastService.updateById(locMast); | 
|---|
|  |  |  | if (!wrkMastRes || !locMastRes) { | 
|---|
|  |  |  | throw new CoolException("保存数据失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 修改库位状态 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectById(locNo); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | throw new CoolException("取消工作档失败,库位不存在:"+ locNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locMast.setLocSts(locSts); | 
|---|
|  |  |  | locMast.setModiTime(now); | 
|---|
|  |  |  | locMast.setModiUser(userId); | 
|---|
|  |  |  | boolean locMastRes = locMastService.updateById(locMast); | 
|---|
|  |  |  | if (!wrkMastRes || !locMastRes) { | 
|---|
|  |  |  | throw new CoolException("保存数据失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | Integer deepRow = Utils.getDeepRow(slaveProperties, curRow); | 
|---|
|  |  |  | targetLoc = locMastService.queryFreeLocMast(deepRow, locMast.getLocType1()); | 
|---|
|  |  |  | // 因库位移转、需预留空库位 | 
|---|
|  |  |  | if (!locMastService.checkEmptyCount(targetLoc)) { | 
|---|
|  |  |  | if (!locMastService.checkEmptyCount(targetLoc,10)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(targetLoc)) { | 
|---|
|  |  |  | targetLoc = locMastService.queryFreeLocMast(curRow, locMast.getLocType1()); | 
|---|
|  |  |  | // 因库位移转、需预留空库位 | 
|---|
|  |  |  | if (!locMastService.checkEmptyCount(targetLoc)) { | 
|---|
|  |  |  | if (!locMastService.checkEmptyCount(targetLoc,10)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 目标库位 ===>> 浅库位, 则校验其深库位是否为 F D X | 
|---|
|  |  |  | 
|---|
|  |  |  | return targetLoc.getLocNo(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void turnOverOut(EmptyPlateOutParam param, Long userId) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getOwnerId())) { | 
|---|
|  |  |  | throw new CoolException("客户名称不能为空"); | 
|---|
|  |  |  | }else if (param.getLocDetls().size()<=0){ | 
|---|
|  |  |  | throw new CoolException("请提取明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ArrayList<String> locNos = new ArrayList<>(); | 
|---|
|  |  |  | String[][] locNos2 =new String[param.getLocDetls().size()][2]; | 
|---|
|  |  |  | int i=0; | 
|---|
|  |  |  | for (EmptyPlateOutParam.LocDetl locDetl : param.getLocDetls()){ | 
|---|
|  |  |  | if (!locNos.contains(locDetl.getLoc_no())){ | 
|---|
|  |  |  | locNos.add(locDetl.getLoc_no()); | 
|---|
|  |  |  | locNos2[i][0]=locDetl.getLoc_no(); | 
|---|
|  |  |  | locNos2[i][1]=locDetl.getManu(); | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LocOwner locOwner = locOwnerService.selectById(param.getOwnerId()); | 
|---|
|  |  |  | param.setOwner(locOwner.getOwner()); | 
|---|
|  |  |  | String lgort = ""; | 
|---|
|  |  |  | String owner=""; | 
|---|
|  |  |  | List<DetlDto> detlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (String[] locNo1 : locNos2) { | 
|---|
|  |  |  | String locNo = locNo1[0]; | 
|---|
|  |  |  | if (locNo1[1].equals("平库")){ | 
|---|
|  |  |  | List<ManLocDetl> manLocDetls = manLocDetlService.selectList(new EntityWrapper<ManLocDetl>().eq("loc_no", locNo)); | 
|---|
|  |  |  | for (ManLocDetl manLocDetl:manLocDetls){ | 
|---|
|  |  |  | if (Cools.isEmpty(owner)) { | 
|---|
|  |  |  | owner = manLocDetl.getOwner$(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | detlDtos.add(new DetlDto(manLocDetl.getMatnr(), manLocDetl.getBatch(), manLocDetl.getAnfme())); | 
|---|
|  |  |  | manLocDetl.setOwner(param.getOwnerId()); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>().eq("loc_no", locNo).eq("matnr",manLocDetl.getMatnr())); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new Exception("更新库存明细拥有者字段信息出错了"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (locNo1[1].equals("立库")){ | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locNo)); | 
|---|
|  |  |  | for (LocDetl locDetl:locDetls){ | 
|---|
|  |  |  | if (Cools.isEmpty(lgort)) { | 
|---|
|  |  |  | lgort = locDetl.getOrigin(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(owner)) { | 
|---|
|  |  |  | owner = locDetl.getOwner$(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | detlDtos.add(new DetlDto(locDetl.getMatnr(), locDetl.getBatch(), locDetl.getAnfme())); | 
|---|
|  |  |  | locDetl.setOwner(param.getOwnerId()); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | locDetlService.update(locDetl,new EntityWrapper<LocDetl>().eq("loc_no", locNo).eq("matnr",locDetl.getMatnr())); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new Exception("更新库存明细拥有者字段信息出错了"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | throw new Exception("更新库位拥有者字段信息出错了"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new CoolException("移交作业出错了:"+e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void turnOverOutPayment(EmptyPlateOutParam param, Long userId) { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getPayment())){ | 
|---|
|  |  |  | throw new CoolException("请选择目标货物形态"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("更新货物形态:目标货物形态:"+param.getPayment$(param.getPayment())+";更改货物信息:"+param.getLocDetls()); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if (param.getLocDetls().size()<=0){ | 
|---|
|  |  |  | throw new CoolException("请提取明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ArrayList<String> locNos = new ArrayList<>(); | 
|---|
|  |  |  | String[][] locNos2 =new String[param.getLocDetls().size()][2]; | 
|---|
|  |  |  | int i=0; | 
|---|
|  |  |  | for (EmptyPlateOutParam.LocDetl locDetl : param.getLocDetls()){ | 
|---|
|  |  |  | if (!locNos.contains(locDetl.getLoc_no())){ | 
|---|
|  |  |  | locNos.add(locDetl.getLoc_no()); | 
|---|
|  |  |  | locNos2[i][0]=locDetl.getLoc_no(); | 
|---|
|  |  |  | locNos2[i][1]=locDetl.getManu(); | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (String[] locNo1 : locNos2) { | 
|---|
|  |  |  | String locNo = locNo1[0]; | 
|---|
|  |  |  | if (locNo1[1].equals("平库")){ | 
|---|
|  |  |  | List<ManLocDetl> manLocDetls = manLocDetlService.selectList(new EntityWrapper<ManLocDetl>().eq("loc_no", locNo)); | 
|---|
|  |  |  | for (ManLocDetl manLocDetl:manLocDetls){ | 
|---|
|  |  |  | manLocDetl.setPayment(param.getPayment()); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>().eq("loc_no", locNo).eq("matnr",manLocDetl.getMatnr())); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new Exception("更新库存明细货物形态字段信息出错了"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (locNo1[1].equals("立库")){ | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locNo)); | 
|---|
|  |  |  | for (LocDetl locDetl:locDetls){ | 
|---|
|  |  |  | locDetl.setPayment(param.getPayment()); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | locDetlService.update(locDetl,new EntityWrapper<LocDetl>().eq("loc_no", locNo).eq("matnr",locDetl.getMatnr())); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new Exception("更新库存明细货物形态字段信息出错了"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | throw new Exception("更新库位货物形态字段信息出错了"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new CoolException("货物形态转换出错了:"+e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|