From 08b4403ec8d6b69528d161cfcad80b5d64dea76c Mon Sep 17 00:00:00 2001 From: Administrator <876263681@qq.com> Date: 星期三, 02 七月 2025 15:12:43 +0800 Subject: [PATCH] #优化库位检索 --- src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 168 insertions(+), 11 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 20e0152..162604f 100644 --- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java @@ -1,27 +1,23 @@ package com.zy.asrs.service.impl; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; 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.CheckBom; import com.zy.asrs.entity.param.CombParam; import com.zy.asrs.entity.param.MobileAdjustParam; import com.zy.asrs.entity.param.OffSaleParam; -import com.zy.asrs.entity.param.OpenOrderPakinParam; import com.zy.asrs.mapper.ManLocDetlMapper; import com.zy.asrs.service.*; -import com.zy.asrs.utils.MatUtils; -import com.zy.common.CodeRes; -import com.zy.common.constant.MesConstant; -import com.zy.common.entity.Parameter; import com.zy.common.model.DetlDto; -import com.zy.common.model.MesCombParam; import com.zy.common.service.CommonService; -import com.zy.common.utils.HttpHandler; import com.zy.common.utils.Synchro; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -83,11 +79,15 @@ private DocTypeService docTypeService; @Autowired private MatV2Service matV2Service; + @Override @Transactional public void comb(CombParam param, Long userId) { if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { throw new CoolException(BaseRes.PARAM); + } + if(param.getCombMats().stream().anyMatch(obj -> obj.getAnfme() == null)){ + throw new CoolException("鍏ュ簱鐗╂枡鏁伴噺涓嶈兘涓虹┖"); } // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁 if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). @@ -144,6 +144,7 @@ throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); } waitPakin.sync(matV2); + waitPakin.setBrand("缁勪欢"); } else { waitPakin.sync(mat); } @@ -219,6 +220,159 @@ } + } + + @Override + @Transactional + public void comb2(CombParam param, Long userId) { + + if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { + throw new CoolException(BaseRes.PARAM); + } + if(param.getCombMats().stream().anyMatch(obj -> obj.getAnfme() == null)){ + throw new CoolException("鍏ュ簱鐗╂枡鏁伴噺涓嶈兘涓虹┖"); + } + // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁 + if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). + eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { + throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱"); + } + + int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); + WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode()); + if (wrkMast != null && wrkMast.getIoType() < 100){ + throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode()); + + } + if (countLoc > 0 ) { + throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode()); + } + + + //璁剧疆闈瀗ull鎵瑰彿锛� + for (CombParam.CombMat combMat : param.getCombMats()) { + if (combMat.getBatch() == null){ + combMat.setBatch(""); + } + } + + + + + Date now = new Date(); + + // 鏃犲崟缁勬墭 + 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.getAnfme()); + if (DetlDto.has(detlDtos, detlDto)) { + DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); + assert one != null; + one.setAnfme(one.getAnfme() + detlDto.getAnfme()); + } else { + detlDtos.add(detlDto); + } + }); + + + for (DetlDto detlDto : detlDtos) { + Mat mat = matService.selectByMatnr(detlDto.getMatnr()); + WaitPakin waitPakin = new WaitPakin(); + if (Cools.isEmpty(mat)) { + MatV2 matV2 = matV2Service.selectOne(new EntityWrapper<MatV2>().eq("matnr", detlDto.getMatnr())); + if(Cools.isEmpty(matV2)){ + throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); + } + waitPakin.sync(matV2); + waitPakin.setBrand("缁勪欢"); + } else { + waitPakin.sync(mat); + } + waitPakin.setBatch(detlDto.getBatch()); + waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� + waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� + waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺 + waitPakin.setStatus("Y"); // 鐘舵�� + waitPakin.setAppeUser(userId); + waitPakin.setBomCode(param.getBomCode()); + waitPakin.setAppeTime(now); + waitPakin.setModiUser(userId); + waitPakin.setModiTime(now); + if (!waitPakinService.insert(waitPakin)) { + throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); + } + } + // 鍏宠仈缁勬墭 + } else { + for (CombParam.CombMat combMat : param.getCombMats()) { + // 鐢熸垚鍏ュ簱閫氱煡妗� + Order order = orderService.selectByNo(combMat.getOrderNo()); + + //鍒ゆ柇璁㈠崟绫诲瀷鏄惁鏄叆搴� + DocType docType=docTypeService.selectById(order.getDocType()); + if(docType.getPakin()!=1 || docType.getStatus()!=1){ + throw new CoolException("璁㈠崟涓哄嚭搴撹鍗曪紝涓嶈兘缁勬墭锛�"); + } + + if (order.getSettle() > 2) { + throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�"); + } + OrderDetl orderDetl = orderDetlService.selectItem(combMat.getOrderNo(), combMat.getMatnr(), combMat.getBatch()); + if (orderDetl == null) { + throw new CoolException("鎵句笉鍒扮粍鎵樼殑鍗曟嵁鏄庣粏"); + } + //璁㈠崟鏁�-宸ヤ綔涓殑鏁伴噺-缁勬墭鏁伴噺 + if ( orderDetl.getAnfme() - orderDetl.getWorkQty() - combMat.getAnfme()<0) { + throw new CoolException("缁勬墭鏁伴噺宸茶秴鍑鸿鍗曢渶姹傞噺锛岃妫�鏌ユ槸鍚︽湁鍏朵粬鐨勭粍鎵樺凡瀹屾垚"); + } + // 淇敼璁㈠崟浣滀笟鏁伴噺 + if (!orderDetlService.increaseWorkQty(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) { + throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触"); + } + Mat mat = matService.selectByMatnr(combMat.getMatnr()); + if (Cools.isEmpty(mat)) { + throw new CoolException(combMat.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); + } + WaitPakin waitPakin = new WaitPakin(); + waitPakin.sync(mat); + waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿 + waitPakin.setBatch(combMat.getBatch()); // 搴忓垪鐮� + waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� + waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� + waitPakin.setAnfme(combMat.getAnfme()); // 鏁伴噺 + waitPakin.setStatus("Y"); // 鐘舵�� + waitPakin.setAppeUser(userId); + waitPakin.setAppeTime(now); + waitPakin.setBomCode(param.getBomCode()); + waitPakin.setModiUser(userId); + waitPakin.setModiTime(now); + if (!waitPakinService.insert(waitPakin)) { + throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); + } + +// DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme()); +// if (DetlDto.has(detlDtos, detlDto)) { +// DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); +// assert one != null; +// one.setAnfme(one.getAnfme() + detlDto.getAnfme()); +// } else { +// } + orderService.updateSettle(order.getId(), 2L, userId); + } + + } + + } + + @Override + @Transactional + public R checkBom(CheckBom param, Long userId) { + + + return R.ok(); } // 鍟嗗搧涓婃灦 @@ -679,10 +833,13 @@ if (Cools.isEmpty(orderDetl)) { return R.error("鍗曟嵁鏄庣粏鏈夎,璇锋鏌�"); } + if (Cools.isEmpty(orderDetl.getAnfme())) { + return R.error("鏁伴噺涓虹┖锛�"); + } if (orderDetl.getAnfme() - (jsonOrderDetl.getAnfme() + orderDetl.getWorkQty()) < 0) { return R.error("鍏ュ簱鏁伴噺澶т簬鍙叆鏁伴噺"); } - //鏌ヨ骞冲簱涓槸鍚︽湁涓�鏍风殑鐗╂枡鍙凤紝鏈夌殑璇濈洿鎺ュ鍔犳暟閲� + //鏌ヨ骞冲簱涓槸鍚︽湁涓�鏍风殑鍝佸彿锛屾湁鐨勮瘽鐩存帴澧炲姞鏁伴噺 ManLocDetl checkManLocDetl = manLocDetlService.selectInventory(jsonLocNo,orderDetl.getMatnr(),jsonOrderDetl.getBatch()); if (checkManLocDetl == null) { ManLocDetl manLocDetl = new ManLocDetl(); @@ -756,7 +913,7 @@ if (jsonOrderDetl.getAnfme() > (orderDetl.getAnfme() - orderDetl.getWorkQty())) { return R.error("鍑哄簱鏁伴噺澶т簬鍗曟嵁鍙嚭鏁伴噺"); } - //鏌ヨ骞冲簱涓槸鍚︽湁涓�鏍风殑鐗╂枡鍙� + //鏌ヨ骞冲簱涓槸鍚︽湁涓�鏍风殑鍝佸彿 ManLocDetl checkManLocDetl = manLocDetlService.selectInventory(jsonLocNo,orderDetl.getMatnr(),orderDetl.getBatch()); if (checkManLocDetl == null) { return R.error("璇ュ簱浣嶆病鏈夊嚭搴撶殑鐗╂枡淇℃伅"); -- Gitblit v1.9.1