From da8a535959c72cf61cf904f3dffaa1d0bd33b79f Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期五, 11 七月 2025 10:43:43 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 319 +++++++++++++++++++++++++++++++++++----------------- 1 files changed, 213 insertions(+), 106 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java index 4137a57..ed6c164 100644 --- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java @@ -4,22 +4,22 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; -import com.core.common.*; +import com.core.common.BaseRes; +import com.core.common.Cools; +import com.core.common.R; +import com.core.common.SnowflakeIdWorker; import com.core.exception.CoolException; import com.zy.asrs.entity.*; import com.zy.asrs.entity.param.*; import com.zy.asrs.mapper.LocMastMapper; import com.zy.asrs.mapper.ManLocDetlMapper; import com.zy.asrs.service.*; -import com.zy.asrs.utils.MatUtils; +import com.zy.asrs.utils.MathUtils; import com.zy.asrs.utils.OrderInAndOutUtil; -import com.zy.common.entity.Parameter; import com.zy.common.model.DetlDto; -import com.zy.common.model.MesCombParam; import com.zy.common.model.enums.WorkNoType; import com.zy.common.service.CommonService; -import com.zy.common.utils.HttpHandler; -import com.zy.nc.entity.NccJcQilibcBarcodeflowWms; +import com.zy.common.utils.Synchro; import com.zy.nc.service.NccJcQilibcBarcodeflowWmsService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +28,7 @@ import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; /** * 绉诲姩绔湇鍔℃牳蹇冪被 @@ -49,6 +50,8 @@ private BasDevpService basDevpService; @Autowired private WrkMastService wrkMastService; + @Autowired + private WorkService workService; @Autowired private WrkDetlService wrkDetlService; @Autowired @@ -75,6 +78,14 @@ private ManLocDetlService manLocDetlService; @Autowired private ManLocDetlMapper manLocDetlMapper; + @Autowired + private ReportToThirdService reportToThirdService; + + @Autowired + private InventoryCheckOrderService inventoryCheckOrderService; + + @Autowired + private InventoryCheckOrderDetlService inventoryCheckOrderDetlService; @Autowired private AdjDetlService adjDetlService; @@ -105,11 +116,11 @@ public R WarehouseOutPickMergeV1(WarehouseOutPickMergeParam param, Long hostId, Long userId) { //鍒ゆ柇搴撲綅鐘舵�� LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", param.getLocNo())); - if (Cools.isEmpty(locMast)){ + if (Cools.isEmpty(locMast)) { return R.error("璇ュ簱浣嶄笉瀛樺湪"); } - if (!locMast.getLocSts().equals("P")){ - return R.error("璇ュ簱浣嶇姸鎬佷负锛�"+locMast.getLocSts()+",涓嶆弧瓒虫嫞鏂欓�斾腑骞舵澘鏉′欢锛侊紒锛�"); + if (!locMast.getLocSts().equals("P")) { + return R.error("璇ュ簱浣嶇姸鎬佷负锛�" + locMast.getLocSts() + ",涓嶆弧瓒虫嫞鏂欓�斾腑骞舵澘鏉′欢锛侊紒锛�"); } Date now = new Date(); @@ -139,7 +150,7 @@ wrkMastService.insert(wrkMast); for (OrderDetl orderDetl : param.getCombMats()) { - Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr",orderDetl.getMatnr())); + Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", orderDetl.getMatnr())); if (mat == null) { throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鐗╂枡淇℃伅涓嶅瓨鍦細" + orderDetl.getMatnr()); } @@ -155,7 +166,7 @@ wrkDetl.setModiUser(userId); wrkDetl.setZpallet(wrkMast.getBarcode()); wrkDetl.setBatch(orderDetl.getBatch()); - if(Cools.isEmpty(orderDetl.getBatch())){ + if (Cools.isEmpty(orderDetl.getBatch())) { wrkDetl.setBatch(""); } wrkDetl.setBoxType1(orderDetl.getBoxType1()); @@ -169,11 +180,11 @@ if (!Cools.isEmpty(orderDetl.getOrderNo())) { OrderPakin order = orderPakinService.selectByNo(orderDetl.getOrderNo()); - if (Cools.isEmpty(order)){ + if (Cools.isEmpty(order)) { continue; } - OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3()); - if (Cools.isEmpty(orderDetlPakin)){ + OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); + if (Cools.isEmpty(orderDetlPakin)) { continue; } if (orderDetlPakin.getAnfme() < (orderDetlPakin.getWorkQty() + orderDetl.getAnfme())) { @@ -181,11 +192,11 @@ } // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺 if (!orderDetlPakinService.increaseWorkQty(orderDetlPakin.getOrderId(), orderDetlPakin.getMatnr(), orderDetlPakin.getBatch(), orderDetlPakin.getBrand(), - orderDetlPakin.getStandby1(), orderDetlPakin.getStandby2(), orderDetlPakin.getStandby3(), orderDetlPakin.getBoxType1(), orderDetlPakin.getBoxType2(), orderDetlPakin.getBoxType3(),orderDetl.getAnfme())) { + orderDetlPakin.getStandby1(), orderDetlPakin.getStandby2(), orderDetlPakin.getStandby3(), orderDetlPakin.getBoxType1(), orderDetlPakin.getBoxType2(), orderDetlPakin.getBoxType3(), orderDetl.getAnfme())) { throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触"); } - if (order.getSettle() == 1){ + if (order.getSettle() == 1) { orderPakinService.updateSettle(order.getId(), 2L, userId); } } @@ -196,7 +207,7 @@ @Override @Transactional - public R pickConfirm(PickConfirmParam param,Long userId) { + public R pickConfirm(PickConfirmParam param, Long userId) { LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() .eq("loc_no", param.getLocNo())); @@ -220,9 +231,9 @@ //妫�楠屼紶鍙傛槸鍚﹀拰璁㈠崟鏄庣粏鍖归厤 for (PickMatParam matParam : param.getList()) { orderDetlPakin = orderDetlPakinService.selectItem - (matParam.getOrderNo(), matParam.getMatnr(),matParam.getBatch(),matParam.getBrand(), - matParam.getStandby1(),matParam.getStandby2(),matParam.getStandby3(), - matParam.getBoxType1(),matParam.getBoxType2(),matParam.getBoxType3()); + (matParam.getOrderNo(), matParam.getMatnr(), matParam.getBatch(), matParam.getBrand(), + matParam.getStandby1(), matParam.getStandby2(), matParam.getStandby3(), + matParam.getBoxType1(), matParam.getBoxType2(), matParam.getBoxType3()); if (orderDetlPakin == null) { return R.error("鐗╂枡鏁版嵁涓嶅瓨鍦�"); } @@ -286,7 +297,7 @@ wrkDetl.setModiTime(now); wrkDetl.setModiUser(userId); wrkDetl.setZpallet(wrkMast.getBarcode()); - if(Cools.isEmpty(matParam.getBatch())){ + if (Cools.isEmpty(matParam.getBatch())) { wrkDetl.setBatch(""); } if (!wrkDetlService.insert(wrkDetl)) { @@ -295,10 +306,10 @@ //鏇存柊璁㈠崟宸ヤ綔鏁伴噺 orderDetlPakinService.increaseWorkQty(orderDetlPakin.getOrderId(), matParam.getMatnr(), - matParam.getBatch(),matParam.getBrand(),matParam.getStandby1(),matParam.getStandby2(),matParam.getStandby3(), - matParam.getBoxType1(),matParam.getBoxType2(),matParam.getBoxType3(),matParam.getUseCount()); + matParam.getBatch(), matParam.getBrand(), matParam.getStandby1(), matParam.getStandby2(), matParam.getStandby3(), + matParam.getBoxType1(), matParam.getBoxType2(), matParam.getBoxType3(), matParam.getUseCount()); // 鏇存柊宸ヤ綔妗g姸鎬� - orderPakinService.updateSettle(orderDetlPakin.getOrderId(),2L,userId); + orderPakinService.updateSettle(orderDetlPakin.getOrderId(), 2L, userId); } // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", param.getLocNo())); @@ -321,47 +332,47 @@ public R WarehouseOutV1(CombParam combParam, Long hostId, Long userId) { //鍒ゆ柇搴撲綅鐘舵�� LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", combParam.getLocNo())); - if (Cools.isEmpty(locMast)){ + if (Cools.isEmpty(locMast)) { return R.error("璇ュ簱浣嶄笉瀛樺湪"); } - if (!locMast.getLocSts().equals("P")){ - return R.error("璇ュ簱浣嶇姸鎬佷负锛�"+locMast.getLocSts()+",涓嶆弧瓒冲苟鏉块�斾腑鎷i�夋潯浠讹紒锛侊紒"); + if (!locMast.getLocSts().equals("P")) { + return R.error("璇ュ簱浣嶇姸鎬佷负锛�" + locMast.getLocSts() + ",涓嶆弧瓒冲苟鏉块�斾腑鎷i�夋潯浠讹紒锛侊紒"); } //鏌ヨ搴撳瓨鏁版嵁 - for (CombParam.CombMat combMat :combParam.getCombMats()){ + for (CombParam.CombMat combMat : combParam.getCombMats()) { List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>() - .eq("loc_no", combParam.getLocNo()) - .eq("matnr", combMat.getMatnr()) + .eq("loc_no", combParam.getLocNo()) + .eq("matnr", combMat.getMatnr()) ); - if (locDetlList.isEmpty()){ + if (locDetlList.isEmpty()) { return R.error("鏈煡璇㈠埌搴撳瓨鏁版嵁"); } - if (locDetlList.size()>1){ + if (locDetlList.size() > 1) { return R.error("搴撳瓨鏁版嵁澶т簬1鏉★紝涓轰繚璇佹暟鎹噯纭�э紝璇风敤姝e父娴佺▼鍑哄簱锛侊紒锛�"); } LocDetl locDetl = locDetlList.get(0); - if (combMat.getAnfme() > locDetl.getAnfme()){ + if (combMat.getAnfme() > locDetl.getAnfme()) { return R.error("鎷i�夋暟閲忛敊璇紝瓒呭嚭搴撳瓨鏁伴噺"); } - if (!Cools.isEmpty(combMat.getOrderNo())){ + if (!Cools.isEmpty(combMat.getOrderNo())) { OrderPakout orderPakout = orderPakoutService.selectByNo(combMat.getOrderNo()); - if (Cools.isEmpty(orderPakout)){ + if (Cools.isEmpty(orderPakout)) { continue; } - if (orderPakout.getSettle() == 1){ - OrderInAndOutUtil.updateOrder(false,orderPakout.getId(), 2L, 9527L); + if (orderPakout.getSettle() == 1) { + OrderInAndOutUtil.updateOrder(false, orderPakout.getId(), 2L, 9527L); } OrderDetlPakout orderDetlPakout = orderDetlPakoutService.selectItem(orderPakout.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getBrand(), combMat.getStandby1(), combMat.getStandby2(), combMat.getStandby3(), combMat.getBoxType1(), combMat.getBoxType2(), combMat.getBoxType3()); - if (Cools.isEmpty(orderDetlPakout)){ + if (Cools.isEmpty(orderDetlPakout)) { continue; } - if (orderDetlPakout.getAnfme() < (orderDetlPakout.getWorkQty()+combMat.getAnfme())){ + if (orderDetlPakout.getAnfme() < (orderDetlPakout.getWorkQty() + combMat.getAnfme())) { throw new CoolException("鎷i�夋暟閲忓嚭閿�,璁㈠崟鍓╀綑鍑哄簱鏁伴噺灏忎簬宸插嚭搴撴暟閲忎笌灏嗘嫞閫夋暟閲忎箣鍜岋紒锛侊紒"); } // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺 if (!orderDetlPakoutService.increaseWorkQty(orderDetlPakout.getOrderId(), combMat.getMatnr(), combMat.getBatch(), combMat.getBrand(), - combMat.getStandby1(), combMat.getStandby2(), combMat.getStandby3(), combMat.getBoxType1(), combMat.getBoxType2(), combMat.getBoxType3(),combMat.getAnfme())) { + combMat.getStandby1(), combMat.getStandby2(), combMat.getStandby3(), combMat.getBoxType1(), combMat.getBoxType2(), combMat.getBoxType3(), combMat.getAnfme())) { throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触"); } // // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺 @@ -399,7 +410,7 @@ wrkMast.setModiUser(userId); wrkMastService.insert(wrkMast); - Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr",combMat.getMatnr())); + Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", combMat.getMatnr())); if (mat == null) { throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鐗╂枡淇℃伅涓嶅瓨鍦細" + combMat.getMatnr()); } @@ -416,7 +427,7 @@ wrkDetl.setModiUser(userId); wrkDetl.setZpallet(wrkMast.getBarcode()); wrkDetl.setBatch(combMat.getBatch()); - if(Cools.isEmpty(combMat.getBatch())){ + if (Cools.isEmpty(combMat.getBatch())) { wrkDetl.setBatch(""); } wrkDetl.setBoxType1(combMat.getBoxType1()); @@ -429,8 +440,8 @@ wrkDetlService.insert(wrkDetl); System.out.println("姝e父"); - }catch (Exception e) { - throw new CoolException("鎿嶄綔鏁版嵁寮傚父锛�"+e.getMessage()); + } catch (Exception e) { + throw new CoolException("鎿嶄綔鏁版嵁寮傚父锛�" + e.getMessage()); } } return R.ok("鎿嶄綔鎴愬姛锛�"); @@ -513,7 +524,7 @@ Wrapper<OrderDetl> wrapper1 = new EntityWrapper<>(); wrapper1.eq("status", 1); wrapper1.in("order_id", orderIds); - wrapper1.orderBy("create_time",false); + wrapper1.orderBy("create_time", false); if (!Cools.isEmpty(matnr)) { wrapper1.like("matnr", matnr); } @@ -525,7 +536,7 @@ ArrayList<PickMatParam> maps = new ArrayList<>(); for (OrderDetl orderDetl : list) { //鍓╀綑鍙敤鏁伴噺 - double count = orderDetl.getAnfme() - orderDetl.getWorkQty(); + double count = MathUtils.subtract(orderDetl.getAnfme(), orderDetl.getWorkQty()); if (count <= 0) { continue; } @@ -548,25 +559,31 @@ if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { throw new CoolException(BaseRes.PARAM); } - if(param.getCombMats().size()>1){ - throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒"); + List<String> codes = param.getCombMats().stream().map(CombParam.CombMat::getTiaoma).collect(Collectors.toList()); + Set<String> sets = new HashSet<>(); + if (codes.stream().anyMatch(item -> !sets.add(item))) { + throw new CoolException("鏉$爜閲嶅鎵爜浜�"); } + // if (param.getCombMats().size() > 1) { +// throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒"); +// } + // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁 if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱"); } - if(param.getBarcode().length()!=8){ + if (param.getBarcode().length() != 8) { throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode()); } - if (param.getCombMats().size()>1){ - throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode()); - } +// if (param.getCombMats().size() > 1) { +// throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode()); +// } - int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); - int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode())); - int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode())); + int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode())); + int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode())); + int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode())); if (countLoc > 0 || countWrk > 0 || countwait > 0) { throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode()); } @@ -574,17 +591,19 @@ Date now = new Date(); // 鏃犲崟缁勬墭 - if (Cools.isEmpty(param.getOrderNo())) { + if (Cools.isEmpty(param.getCombMats().get(0).getOrderNo())) { // 鐢熸垚鍏ュ簱閫氱煡妗� List<DetlDto> detlDtos = new ArrayList<>(); param.getCombMats().forEach(elem -> { - DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), - elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); + DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), + elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme()); + detlDto.setWeight(elem.getWeight()); if (DetlDto.has(detlDtos, detlDto)) { DetlDto one = DetlDto.findDto(detlDtos, detlDto); assert one != null; one.setAnfme(one.getAnfme() + detlDto.getAnfme()); + one.setWeight(one.getWeight() + detlDto.getWeight()); } else { detlDtos.add(detlDto); } @@ -598,6 +617,7 @@ } WaitPakin waitPakin = new WaitPakin(); waitPakin.sync(mat); + waitPakin.setWeight(detlDto.getWeight()); waitPakin.setBatch(detlDto.getBatch()); waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� @@ -607,49 +627,59 @@ waitPakin.setAppeTime(now); waitPakin.setModiUser(userId); waitPakin.setModiTime(now); + waitPakin.setBoxType1(detlDto.getBoxType1()); + waitPakin.setBoxType2(detlDto.getBoxType2()); + waitPakin.setBoxType3(detlDto.getBoxType3()); + waitPakin.setStandby1(detlDto.getStandby1()); + waitPakin.setStandby2(detlDto.getStandby2()); + waitPakin.setStandby3(detlDto.getStandby3()); + waitPakin.setTkFlag(param.getTkFlag()); if (!waitPakinService.insert(waitPakin)) { throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); } } - // 鍏宠仈缁勬墭 + // 鍏宠仈缁勬墭 } else { // Order order = orderService.selectByNo(param.getOrderNo()); - Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getOrderNo()); - if (Cools.isEmpty(order) || order.getSettle() > 2) { - throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�"); - } + // 鐢熸垚鍏ュ簱閫氱煡妗� List<DetlDto> detlDtos = new ArrayList<>(); param.getCombMats().forEach(elem -> { - // TODO 涓嶈�冭檻浠g爜鏁堢巼锛屽洜涓烘棫浠g爜bug灏� - if (!Cools.isEmpty(elem.getVbarcode())){ - NccJcQilibcBarcodeflowWms vbarcode1 = barcodeflowWmsService.selectOne(new EntityWrapper<NccJcQilibcBarcodeflowWms>().eq("vbarcode", elem.getVbarcode())); - + Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, elem.getOrderNo()); + if (Cools.isEmpty(order)) { + throw new CoolException("鍗曟嵁缂栧彿涓嶅瓨鍦�"); + } + if (order.getSettle() > 2) { + throw new CoolException("鍗曟嵁缂栧彿宸蹭綔涓氬畬鎴�"); } // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙 -// OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); - OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), - elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3()); + OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), + elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3()); if (elem.getAnfme() > orderDetl.getEnableQty()) { - throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�"); + throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�,宸茬粡瓒呰繃鍗曟嵁鍏ュ簱鏁伴噺"); } // 淇敼璁㈠崟浣滀笟鏁伴噺 // if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { // throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触"); // } - OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE,order.getId(), elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), - elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); - DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), - elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); + OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), + elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme()); + DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), + elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme()); + detlDto.setOrderNo(elem.getOrderNo()); + detlDto.setWeight(elem.getWeight()); if (DetlDto.has(detlDtos, detlDto)) { DetlDto one = DetlDto.findDto(detlDtos, detlDto); assert one != null; one.setAnfme(one.getAnfme() + detlDto.getAnfme()); + one.setWeight(one.getWeight() + detlDto.getWeight()); } else { detlDtos.add(detlDto); } + + OrderInAndOutUtil.updateOrder(Boolean.TRUE, order.getId(), 2L, userId); }); for (DetlDto detlDto : detlDtos) { Mat mat = matService.selectByMatnr(detlDto.getMatnr()); @@ -658,7 +688,7 @@ } WaitPakin waitPakin = new WaitPakin(); waitPakin.sync(mat); - waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿 + waitPakin.setOrderNo(detlDto.getOrderNo()); // 鍗曟嵁缂栧彿 waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮� waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� @@ -668,12 +698,19 @@ waitPakin.setAppeTime(now); waitPakin.setModiUser(userId); waitPakin.setModiTime(now); + waitPakin.setBoxType1(detlDto.getBoxType1()); + waitPakin.setBoxType2(detlDto.getBoxType2()); + waitPakin.setBoxType3(detlDto.getBoxType3()); + waitPakin.setStandby1(detlDto.getStandby1()); + waitPakin.setStandby2(detlDto.getStandby2()); + waitPakin.setStandby3(detlDto.getStandby3()); + waitPakin.setWeight(detlDto.getWeight()); if (!waitPakinService.insert(waitPakin)) { throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); } } // orderService.updateSettle(order.getId(), 2L, userId); - OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId); + } } @@ -690,15 +727,15 @@ } // 鑾峰彇鍟嗗搧鍒楄〃 - for(CombParam.CombMat combMat : param.getCombMats()){ + for (CombParam.CombMat combMat : param.getCombMats()) { Mat mat = matService.selectByMatnr(combMat.getMatnr()); - if (Cools.isEmpty(mat)){ + if (Cools.isEmpty(mat)) { throw new CoolException(combMat.getMatnr() + ":鍟嗗搧妗f涓嶅瓨鍦紒"); } - if (Cools.isEmpty(combMat.getAnfme()) || combMat.getAnfme()==0){ + if (Cools.isEmpty(combMat.getAnfme()) || combMat.getAnfme() == 0) { throw new CoolException(combMat.getMatnr() + ":鍟嗗搧鏁伴噺鏈夎锛�"); } - if (Cools.isEmpty(combMat.getBatch())){ + if (Cools.isEmpty(combMat.getBatch())) { // throw new CoolException(combMat.getMatnr() + ":鍟嗗搧鎵瑰彿鏈夎锛�"); } ManLocDetl manLocDetl = new ManLocDetl(); @@ -719,16 +756,16 @@ @Override public void offSale(OffSaleParam offSaleParam) { ManLocDetl manLocDetl = manLocDetlMapper.selectLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr()); - if (Cools.isEmpty(manLocDetl)){ + if (Cools.isEmpty(manLocDetl)) { throw new CoolException("鏃犳鍟嗗搧锛�"); } double anfme = manLocDetl.getAnfme() - offSaleParam.getAnfme(); if (anfme < 0) { throw new CoolException("鍟嗗搧搴撳瓨涓嶈冻锛�"); - } else if (anfme == 0){ + } else if (anfme == 0) { manLocDetlMapper.deleteLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr()); } - manLocDetlMapper.updateAnfme0(anfme,manLocDetl.getNodeId()); + manLocDetlMapper.updateAnfme0(anfme, manLocDetl.getNodeId()); } // 鏌ユ壘鍟嗗搧 @@ -737,22 +774,25 @@ @Override @Transactional public void adjust(MobileAdjustParam param, Long userId) { - BasDevp basDevp = basDevpService.selectById(param.getStaNo()); - if (null == basDevp || basDevp.getWrkNo() == null) { - throw new CoolException(param.getStaNo() + "鐩樼偣绔欐棤鏁�"); - } - if (!param.getWrkNo().equals(basDevp.getWrkNo())) { - throw new CoolException(param.getStaNo() + "鐩樼偣绔欐洿鏂帮紝璇烽噸鏂版绱�"); - } - WrkMast wrkMast = wrkMastService.selectById(param.getWrkNo()); +// BasDevp basDevp = basDevpService.selectById(param.getStaNo()); +// if (null == basDevp || basDevp.getWrkNo() == null) { +// throw new CoolException(param.getStaNo() + "鐩樼偣绔欐棤鏁�"); +// } +// if (!param.getWrkNo().equals(basDevp.getWrkNo())) { +// throw new CoolException(param.getStaNo() + "鐩樼偣绔欐洿鏂帮紝璇烽噸鏂版绱�"); +// } + WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode()); if (wrkMast.getWrkSts() < 10) { throw new CoolException("鐩樼偣鏃犳晥锛屼换鍔″凡鐩樼偣鍐嶅叆搴�"); } Date now = new Date(); List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); - List<WrkDetl> list = param.getWrkDetls(); + List<WrkDetl> list = JSON.parseArray(JSON.toJSONString(param.getWrkDetls()), WrkDetl.class); + LocDetlAdjustParam adjustParam = new LocDetlAdjustParam(); + List<LocDetlAdjustParam.LocDetlAdjust> locDetlAdjusts = new ArrayList<>(); + adjustParam.setLocNo(wrkMast.getSourceLocNo()); // 淇敼鏁伴噺 Iterator<WrkDetl> iterator = wrkDetls.iterator(); while (iterator.hasNext()) { @@ -771,6 +811,7 @@ throw new CoolException(wrkMast.getWrkNo() + "鐩樼偣浠诲姟锛�" + wrkDetl.getMatnr() + "鍟嗗搧锛�" + wrkDetl.getBatch() + "鎵瑰彿淇敼鏁伴噺澶辫触"); } } + //濡傛灉宸茬粡鎷f枡鍥炲簱锛屽氨闇�瑕佸彇locNo瀛楁 iterator.remove(); iterator1.remove(); } @@ -787,7 +828,9 @@ // 娣诲姞鏄庣粏 for (WrkDetl wrkDetl : list) { - if (wrkDetl.getAnfme() == 0.0D) { continue; } + if (wrkDetl.getAnfme() == 0.0D) { + continue; + } // todo 鐩樼偣璁板綍銆佷繚瀛樿皟鏁磋褰� String orderNo = wrkDetl.getOrderNo(); Mat mat = matService.selectByMatnr(wrkDetl.getMatnr()); @@ -801,14 +844,37 @@ throw new CoolException("娣诲姞" + wrkMast.getWrkNo() + "鐩樼偣浠诲姟锛�" + wrkDetl.getMatnr() + "鍟嗗搧锛�" + wrkDetl.getBatch() + "鎵瑰彿浠诲姟鏄庣粏澶辫触"); } } + List<WrkDetl> wrkDetls1 = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); + for (WrkDetl wrkDetl : wrkDetls1) { + LocDetlAdjustParam.LocDetlAdjust locDetlAdjust = new LocDetlAdjustParam.LocDetlAdjust(wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme()); + locDetlAdjusts.add(locDetlAdjust); + } + + List<WrkDetl> paramWrkDetls = JSON.parseArray(JSON.toJSONString(param.getWrkDetls()), WrkDetl.class); + for (WrkDetl wrkDetl : paramWrkDetls) { + String locNo = Cools.isEmpty(wrkMast.getLocNo()) ? wrkMast.getSourceLocNo() : wrkMast.getLocNo(); + List<InventoryCheckOrderDetl> checkOrderDetls = inventoryCheckOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() + .eq("loc_no", locNo) + .eq("area", wrkDetl.getWrkNo()) + ); + for (InventoryCheckOrderDetl checkOrderDetl : checkOrderDetls) { + if (wrkDetl.getMatnr().equals(checkOrderDetl.getMatnr()) && Cools.eq(wrkDetl.getBatch(), checkOrderDetl.getBatch())) { + checkOrderDetl.setCheckAnfme(wrkDetl.getAnfme()); + checkOrderDetl.setStatus("2"); + inventoryCheckOrderDetlService.updateById(checkOrderDetl); + } + } + } // 淇敼鐩樼偣浠诲姟涓绘。鐘舵�� - wrkMast.setFullPlt(wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()).size() != 0?"Y":"N"); + wrkMast.setFullPlt("Y"); wrkMast.setModiTime(now); wrkMast.setModiUser(userId); if (!wrkMastService.updateById(wrkMast)) { throw new CoolException("淇敼鐩樼偣浠诲姟涓绘。澶辫触"); } + adjustParam.setList(locDetlAdjusts); + workService.adjustLocDetl2(adjustParam, userId); } @@ -988,7 +1054,7 @@ //鏍规嵁璁㈠崟鍙风敓鎴愬嚭搴撲换鍔″伐浣滄。 Order order = OrderInAndOutUtil.selectByNo(Boolean.FALSE, orderNo); // Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderNo)); - if (order.getSettle() != 1 && order.getSettle() != 2){ + if (order.getSettle() != 1 && order.getSettle() != 2) { throw new CoolException("璇ヨ鍗曞凡澶勭悊"); } @@ -996,13 +1062,13 @@ List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(Boolean.FALSE, order.getId()); Date now = new Date(); - for(OrderDetl orderDetl : orderDetls){ + for (OrderDetl orderDetl : orderDetls) { //鏌ヨ鎵�鏈夊簱浣嶇姸鎬佷负F鐨勫簱浣嶄俊鎭� - List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(),orderDetl.getBatch(),null,null); + List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, null); if (locDetls.size() == 0) { throw new CoolException("搴撳瓨涓病鏈夎鐗╂枡"); } - for(LocDetl locDetl : locDetls){ + for (LocDetl locDetl : locDetls) { //濡傛灉璇ュ簱浣嶅嚭搴撹矾绾挎墍鐢ㄧ殑鍫嗗灈鏈簅ut_enable涓嶄负Y,璺宠繃璇ュ惊鐜� LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() .eq("loc_no", locDetl.getLocNo())); @@ -1011,13 +1077,13 @@ } BasCrnp crn_no = basCrnpService.selectOne(new EntityWrapper<BasCrnp>() .eq("crn_no", locMast.getCrnNo())); - if (Cools.isEmpty(crn_no) || !crn_no.getOutEnable().equals("Y")){ + if (Cools.isEmpty(crn_no) || !crn_no.getOutEnable().equals("Y")) { continue; } //鍙嚭搴撴暟閲� = 璁㈠崟鏁伴噺 - 浣滀笟涓暟閲� - Double outQty = orderDetl.getAnfme() - orderDetl.getWorkQty(); - if(outQty <= 0){ + Double outQty = MathUtils.subtract(orderDetl.getAnfme(), orderDetl.getWorkQty()); + if (outQty <= 0) { break; } // 鍒ゆ柇鍏ュ嚭搴撶被鍨嬶細101.鍏ㄦ澘鍑哄簱 or 103.鎷f枡鍑哄簱 @@ -1032,19 +1098,19 @@ // if(!orderService.update(order, new EntityWrapper<Order>().eq("order_no", orderNo))){ // throw new CoolException("鏇存柊璁㈠崟鐘舵�佸け璐�"); // } - OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(),order.getId(),2L,userId); + OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 2L, userId); orderDetl.setWorkQty(orderDetl.getWorkQty() + curOutQty); orderDetl.setUpdateBy(userId); orderDetl.setUpdateTime(now); Wrapper wrapper = new EntityWrapper<OrderDetl>().eq("order_no", orderNo) - .eq("matnr",orderDetl.getMatnr()); - if(!Cools.isEmpty(orderDetl.getBatch())){ + .eq("matnr", orderDetl.getMatnr()); + if (!Cools.isEmpty(orderDetl.getBatch())) { wrapper.eq("batch", orderDetl.getBatch()); } // if(!orderDetlService.update(orderDetl, wrapper)){ // throw new CoolException("鏇存柊璁㈠崟鏄庣粏澶辫触"); // } - OrderInAndOutUtil.updateOrderDetl(order.getPakinPakoutStatus$(),order,orderDetl); + OrderInAndOutUtil.updateOrderDetl(order.getPakinPakoutStatus$(), order, orderDetl); } @@ -1121,4 +1187,45 @@ throw new CoolException(locDetl.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); } } + + @Override + public void checkOutSubmit(Integer orderId, Long userId) { + InventoryCheckOrder inventoryCheckOrder = inventoryCheckOrderService.selectOne(new EntityWrapper<InventoryCheckOrder>() + .eq("id", orderId)); + if (inventoryCheckOrder == null) { + throw new CoolException("鐩樼偣鍗曚笉瀛樺湪"); + } + + if (!inventoryCheckOrder.getStatus().equals("1")) { + throw new CoolException("鐩樼偣鍗曠姸鎬佸凡涓婃姤"); + } + + List<InventoryCheckOrderDetl> checkOrderDetlList = inventoryCheckOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() + .eq("order_no", inventoryCheckOrder.getOrderNo()) + ); + if (checkOrderDetlList.isEmpty()) { + throw new CoolException("鐩樼偣鍗曟棤鐗╂枡鏄庣粏"); + } + InventoryCheckOrderDetl orderDetl = checkOrderDetlList.get(0); + + List<InventoryCheckOrderDetl> checkOrderDetls = inventoryCheckOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() + .eq("matnr", orderDetl.getMatnr()) + .eq("batch", orderDetl.getBatch()) + ); + + boolean complete = true; + for (InventoryCheckOrderDetl checkOrderDetl : checkOrderDetls) { + if (!checkOrderDetl.getStatus().equals("2")) { + complete = false; + } + } + if (complete) { + boolean result = reportToThirdService.reportCheckOrder(orderDetl.getMatnr(), orderDetl.getBatch()); + if (!result) { + throw new CoolException("鐩樼偣鍗曚笂鎶ュけ璐�"); + } + }else { + throw new CoolException("鐩樼偣鏈畬鎴愭棤娉曚笂鎶�"); + } + } } -- Gitblit v1.9.1