From 07dad0e9ef89346439cfcfb5978b0f1cb8f1b512 Mon Sep 17 00:00:00 2001 From: lsh <lsh@163.com> Date: 星期二, 27 五月 2025 12:31:30 +0800 Subject: [PATCH] 新增PDA并板操作 --- src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 760 +++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 489 insertions(+), 271 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 99f0779..153765b 100644 --- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java @@ -1,35 +1,28 @@ package com.zy.asrs.service.impl; -import com.alibaba.fastjson.JSON; 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.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.entity.param.*; 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.asrs.utils.MatCompareUtils; import com.zy.common.model.DetlDto; -import com.zy.common.model.MesCombParam; +import com.zy.common.model.LocDto; import com.zy.common.service.CommonService; -import com.zy.common.utils.HttpHandler; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; +import java.util.*; /** * 绉诲姩绔湇鍔℃牳蹇冪被 @@ -77,6 +70,8 @@ private ManLocDetlService manLocDetlService; @Autowired private ManLocDetlMapper manLocDetlMapper; + @Autowired + private AdjDetlService adjDetlService; @Override @@ -111,103 +106,94 @@ Date now = new Date(); // 鏃犲崟缁勬墭 - if (Cools.isEmpty(param.getOrderNo())) { +// if (Cools.isEmpty(param.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()); +// if (Cools.isEmpty(mat)) { +// throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); +// } +// WaitPakin waitPakin = new WaitPakin(); +// 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.setAppeTime(now); +// waitPakin.setModiUser(userId); +// waitPakin.setModiTime(now); +// if (!waitPakinService.insert(waitPakin)) { +// throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); +// } +// } +// // 鍏宠仈缁勬墭 +// } else { - // 鐢熸垚鍏ュ簱閫氱煡妗� - 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()); - if (Cools.isEmpty(mat)) { - throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); - } - WaitPakin waitPakin = new WaitPakin(); - 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.setAppeTime(now); - waitPakin.setModiUser(userId); - waitPakin.setModiTime(now); - if (!waitPakinService.insert(waitPakin)) { - throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); - } - } - // 鍏宠仈缁勬墭 - } else { - - Order order = orderService.selectOne(new EntityWrapper<Order>().eq("temp1", param.getOrderNo())); - if (Cools.isEmpty(order) || order.getSettle() > 2) { - throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�"); - } - // 鐢熸垚鍏ュ簱閫氱煡妗� - List<DetlDto> detlDtos = new ArrayList<>(); - param.getCombMats().forEach(elem -> { - - // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙 - OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch(),elem.getAnfme() ); - if (elem.getAnfme() > orderDetl.getEnableQty()) { - throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�"); - } - // 淇敼璁㈠崟浣滀笟鏁伴噺 - if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { - throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触"); - } - - 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()); - if (Cools.isEmpty(mat)) { - throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); - } - WaitPakin waitPakin = new WaitPakin(); - waitPakin.sync(mat); - waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿 - waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮� - waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� - waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� - waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺 - waitPakin.setStatus("Y"); // 鐘舵�� - waitPakin.setAppeUser(userId); - waitPakin.setAppeTime(now); - waitPakin.setModiUser(userId); - waitPakin.setModiTime(now); - OrderDetl orderDetl = orderDetlService.selectItem(order.getOrderNo(), waitPakin.getMatnr(), waitPakin.getBatch(),detlDto.getAnfme()); - if (orderDetl == null) { - orderDetl = orderDetlService.selectItem(order.getOrderNo(), waitPakin.getMatnr(), null,detlDto.getAnfme()); - } - if (orderDetl!=null){ - waitPakin.setSPgNO(orderDetl.getSPgNO()); - waitPakin.setOutOrderNo(orderDetl.getOutOrderNo()); - } - if (!waitPakinService.insert(waitPakin)) { - throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); - } - } - orderService.updateSettle(order.getId(), 2L, userId); + Order order = orderService.selectOne(new EntityWrapper<Order>().eq("temp1", param.getOrderNo())); + if (Cools.isEmpty(order) || order.getSettle() > 2) { + throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�"); } + // 鐢熸垚鍏ュ簱閫氱煡妗� + List<DetlDto> detlDtos = new ArrayList<>(); + param.getCombMats().forEach(elem -> { + + // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙 + //OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch(),elem.getAnfme() ); + OrderDetl orderDetl = orderDetlService.selectById(elem.getDetlId()); + if (elem.getAnfme() > orderDetl.getEnableQty()) { + throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�"); + } + // 淇敼璁㈠崟浣滀笟鏁伴噺 + if (!orderDetlService.increaseWorkQty(orderDetl, elem.getAnfme())) { + throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触"); + } + + Mat mat = matService.selectByMatnr(orderDetl.getMatnr()); + if (Cools.isEmpty(mat)) { + throw new CoolException(orderDetl.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); + } + WaitPakin waitPakin = new WaitPakin(); + waitPakin.sync(mat); + waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿 + waitPakin.setBatch(orderDetl.getBatch()); // 搴忓垪鐮� + waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� + waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� + waitPakin.setAnfme(elem.getAnfme()); // 鏁伴噺 + waitPakin.setStatus("Y"); // 鐘舵�� + waitPakin.setAppeUser(userId); + waitPakin.setAppeTime(now); + waitPakin.setModiUser(userId); + waitPakin.setModiTime(now); + + waitPakin.setBatch(orderDetl.getBatch()); + waitPakin.setSPgNO(orderDetl.getSPgNO()); + waitPakin.setOutOrderNo(orderDetl.getOutOrderNo()); + waitPakin.setProType(orderDetl.getProType()); + waitPakin.setLuHao(orderDetl.getLuHao()); + waitPakin.setPacking(orderDetl.getPacking()); + if (!waitPakinService.insert(waitPakin)) { + throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); + } + }); + + orderService.updateSettle(order.getId(), 2L, userId); + // } } @@ -347,164 +333,165 @@ } - @Override - @Transactional - public void packComb(CombParam param, Long userId) { - if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { - throw new CoolException(BaseRes.PARAM); - } - // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁 - if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). - eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { - throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱"); - } - Date now = new Date(); - - boolean packDown = Parameter.get().getPackDown().equals("true"); - - // 鏃犲崟缁勬墭 - if (Cools.isEmpty(param.getOrderNo())) { - - // 鐢熸垚鍏ュ簱閫氱煡妗� - List<DetlDto> detlDtos = new ArrayList<>(); - param.getCombMats().forEach(elem -> { - // 鎵撳寘涓婄嚎鏁版嵁鏍¢獙 - if (packDown) { - Pack pack = packService.selectByBarcode(elem.getMatnr()); - if (pack == null) { - throw new CoolException(elem.getMatnr() + "鏉$爜鍐椾綑锛岃妫�鏌ワ紒"); - } - if (pack.getSettle() != 1) { - throw new CoolException(elem.getMatnr() + "鏉$爜宸蹭笅绾匡紝璇锋鏌ワ紒"); - } - } - Mat analyse = MatUtils.analyseMat(elem.getMatnr()); - // 鏉$爜銆佺墿鏂欎唬鐮併�佸簭鍒楀彿銆佹暟閲� - DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme()); -// 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); - } - }); - - if (packDown) { - MesCombParam mesCombParam = new MesCombParam(); - mesCombParam.setZpallet(param.getBarcode()); - mesCombParam.setPakinTime(DateUtils.convert(now)); - mesCombParam.setLgort("5008"); - mesCombParam.setPlantCode("5000"); - mesCombParam.setFromCode("5012-20"); - mesCombParam.setStationCode("JJQ-PFZPDB-XX"); - for (DetlDto detlDto : detlDtos) { - mesCombParam.getList().add(new MesCombParam.Detl(detlDto.getOrderNo(), detlDto.getAnfme())); - } - String response = ""; - boolean success = false; - try { - response = new HttpHandler.Builder() - .setUri(MesConstant.URL) - .setPath(MesConstant.PACK_DOWN_URL) - .setJson(JSON.toJSONString(mesCombParam)) - .build() - .doPost(); - JSONObject jsonObject = JSON.parseObject(response); - if (jsonObject.getInteger("code").equals(200)) { - success = true; - } else if (jsonObject.getInteger("code").equals(500)) { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); - throw new CoolException(jsonObject.getString("msg")); - } else { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); - throw new CoolException("涓婃姤mes绯荤粺澶辫触"); - } - } catch (Exception e) { - log.error("fail", e); - throw new CoolException(e.getMessage()); - } finally { - try { - // 淇濆瓨鎺ュ彛鏃ュ織 - apiLogService.save( - "鎵撳寘涓嬬嚎甯墭涓婃姤", - MesConstant.URL + MesConstant.PACK_DOWN_URL, - null, - "127.0.0.1", - JSON.toJSONString(mesCombParam), - response, - success - ); - } catch (Exception e) { - log.error("", e); - } - } - - } - - // 鐢熸垚鍏ュ簱鍗曟嵁 - String orderNo = "PACK" + snowflakeIdWorker.nextId(); - OpenOrderPakinParam openParam = new OpenOrderPakinParam(); - openParam.setOrderNo(orderNo); - openParam.setOrderTime(DateUtils.convert(now)); - openParam.setOrderType("鎵撳寘鍏ュ簱鍗�"); - openParam.setOrderDetails(detlDtos); - openService.pakinOrderCreate(openParam); - Order order = orderService.selectByNo(orderNo); - if (null == order) { - throw new CoolException("鐢熸垚鍗曟嵁澶辫触"); - } - if (!orderService.updateSettle(order.getId(), 2L, userId)) { - throw new CoolException("淇敼鍗曟嵁鐘舵�佸け璐�"); - } - - // 鐢熸垚鍏ュ簱閫氱煡妗� - for (DetlDto detlDto : detlDtos) { - - // 淇敼浣滀笟鏁伴噺 ---------------------------------------- - // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙 - OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch(),detlDto.getAnfme()); - if (detlDto.getAnfme() > orderDetl.getEnableQty()) { - throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�"); - } - // 淇敼璁㈠崟浣滀笟鏁伴噺 - if (!orderDetlService.increaseWorkQty(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme())) { - throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触"); - } - - // 淇濆瓨鍏ュ簱閫氱煡妗� - Mat mat = matService.selectByMatnr(detlDto.getMatnr()); - if (Cools.isEmpty(mat)) { - throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); - } - WaitPakin waitPakin = new WaitPakin(); - waitPakin.sync(mat); - waitPakin.setOrderNo(orderNo); - waitPakin.setBatch(detlDto.getBatch()); - waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� - waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� - waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺 - waitPakin.setStatus("Y"); // 鐘舵�� - waitPakin.setAppeUser(userId); - waitPakin.setAppeTime(now); - waitPakin.setModiUser(userId); - waitPakin.setModiTime(now); - if (!waitPakinService.insert(waitPakin)) { - throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); - } - // 淇敼鎵撳寘鏁版嵁鐘舵�� - Pack pack = packService.selectByBarcode(detlDto.getOrderNo()); - pack.setSettle(2L); - pack.setUpdateTime(now); - pack.setUpdateBy(userId); - if (!packService.updateById(pack)) { - throw new CoolException("淇敼鎵撳寘鏁版嵁寮傚父"); - } - } - - } - } +// @Override +// @Transactional +// public void packComb(CombParam param, Long userId) { +// if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { +// throw new CoolException(BaseRes.PARAM); +// } +// // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁 +// if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). +// eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { +// throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱"); +// } +// Date now = new Date(); +// +// boolean packDown = Parameter.get().getPackDown().equals("true"); +// +// // 鏃犲崟缁勬墭 +// if (Cools.isEmpty(param.getOrderNo())) { +// +// // 鐢熸垚鍏ュ簱閫氱煡妗� +// List<DetlDto> detlDtos = new ArrayList<>(); +// param.getCombMats().forEach(elem -> { +// // 鎵撳寘涓婄嚎鏁版嵁鏍¢獙 +// if (packDown) { +// Pack pack = packService.selectByBarcode(elem.getMatnr()); +// if (pack == null) { +// throw new CoolException(elem.getMatnr() + "鏉$爜鍐椾綑锛岃妫�鏌ワ紒"); +// } +// if (pack.getSettle() != 1) { +// throw new CoolException(elem.getMatnr() + "鏉$爜宸蹭笅绾匡紝璇锋鏌ワ紒"); +// } +// } +// Mat analyse = MatUtils.analyseMat(elem.getMatnr()); +// // 鏉$爜銆佺墿鏂欎唬鐮併�佸簭鍒楀彿銆佹暟閲� +// DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme()); +//// 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); +// } +// }); +// +// if (packDown) { +// MesCombParam mesCombParam = new MesCombParam(); +// mesCombParam.setZpallet(param.getBarcode()); +// mesCombParam.setPakinTime(DateUtils.convert(now)); +// mesCombParam.setLgort("5008"); +// mesCombParam.setPlantCode("5000"); +// mesCombParam.setFromCode("5012-20"); +// mesCombParam.setStationCode("JJQ-PFZPDB-XX"); +// for (DetlDto detlDto : detlDtos) { +// mesCombParam.getList().add(new MesCombParam.Detl(detlDto.getOrderNo(), detlDto.getAnfme())); +// } +// String response = ""; +// boolean success = false; +// try { +// response = new HttpHandler.Builder() +// .setUri(MesConstant.URL) +// .setPath(MesConstant.PACK_DOWN_URL) +// .setJson(JSON.toJSONString(mesCombParam)) +// .build() +// .doPost(); +// JSONObject jsonObject = JSON.parseObject(response); +// if (jsonObject.getInteger("code").equals(200)) { +// success = true; +// } else if (jsonObject.getInteger("code").equals(500)) { +// log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); +// throw new CoolException(jsonObject.getString("msg")); +// } else { +// log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); +// throw new CoolException("涓婃姤mes绯荤粺澶辫触"); +// } +// } catch (Exception e) { +// log.error("fail", e); +// throw new CoolException(e.getMessage()); +// } finally { +// try { +// // 淇濆瓨鎺ュ彛鏃ュ織 +// apiLogService.save( +// "鎵撳寘涓嬬嚎甯墭涓婃姤", +// MesConstant.URL + MesConstant.PACK_DOWN_URL, +// null, +// "127.0.0.1", +// JSON.toJSONString(mesCombParam), +// response, +// success +// ); +// } catch (Exception e) { +// log.error("", e); +// } +// } +// +// } +// +// // 鐢熸垚鍏ュ簱鍗曟嵁 +// String orderNo = "PACK" + snowflakeIdWorker.nextId(); +// OpenOrderPakinParam openParam = new OpenOrderPakinParam(); +// openParam.setOrderNo(orderNo); +// openParam.setOrderTime(DateUtils.convert(now)); +// openParam.setOrderType("鎵撳寘鍏ュ簱鍗�"); +// openParam.setOrderDetails(detlDtos); +// openService.pakinOrderCreate(openParam); +// Order order = orderService.selectByNo(orderNo); +// if (null == order) { +// throw new CoolException("鐢熸垚鍗曟嵁澶辫触"); +// } +// if (!orderService.updateSettle(order.getId(), 2L, userId)) { +// throw new CoolException("淇敼鍗曟嵁鐘舵�佸け璐�"); +// } +// +// // 鐢熸垚鍏ュ簱閫氱煡妗� +// for (DetlDto detlDto : detlDtos) { +// +// // 淇敼浣滀笟鏁伴噺 ---------------------------------------- +// // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙 +// OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch(),detlDto.getAnfme()); +// +// if (detlDto.getAnfme() > orderDetl.getEnableQty()) { +// throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�"); +// } +// // 淇敼璁㈠崟浣滀笟鏁伴噺 +// if (!orderDetlService.increaseWorkQty(orderDetl, detlDto.getAnfme())) { +// throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触"); +// } +// +// // 淇濆瓨鍏ュ簱閫氱煡妗� +// Mat mat = matService.selectByMatnr(detlDto.getMatnr()); +// if (Cools.isEmpty(mat)) { +// throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); +// } +// WaitPakin waitPakin = new WaitPakin(); +// waitPakin.sync(mat); +// waitPakin.setOrderNo(orderNo); +// waitPakin.setBatch(detlDto.getBatch()); +// waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� +// waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� +// waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺 +// waitPakin.setStatus("Y"); // 鐘舵�� +// waitPakin.setAppeUser(userId); +// waitPakin.setAppeTime(now); +// waitPakin.setModiUser(userId); +// waitPakin.setModiTime(now); +// if (!waitPakinService.insert(waitPakin)) { +// throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); +// } +// // 淇敼鎵撳寘鏁版嵁鐘舵�� +// Pack pack = packService.selectByBarcode(detlDto.getOrderNo()); +// pack.setSettle(2L); +// pack.setUpdateTime(now); +// pack.setUpdateBy(userId); +// if (!packService.updateById(pack)) { +// throw new CoolException("淇敼鎵撳寘鏁版嵁寮傚父"); +// } +// } +// +// } +// } @Override @Transactional @@ -514,7 +501,7 @@ BasDevp sta = basDevpService.checkSiteStatus(staNo); //鏍规嵁璁㈠崟鍙风敓鎴愬嚭搴撲换鍔″伐浣滄。 - List<OrderDetl> pg_no = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("pg_no",orderNo)); + List<OrderDetl> pg_no = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("pg_no", orderNo)); Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", pg_no.get(0).getOrderNo())); if (order.getSettle() != 1 && order.getSettle() != 2) { throw new CoolException("璇ヨ鍗曞凡澶勭悊"); @@ -524,7 +511,7 @@ Date now = new Date(); for (OrderDetl orderDetl : orderDetls) { //鏌ヨ鎵�鏈夊簱浣嶇姸鎬佷负F鐨勫簱浣嶄俊鎭� - List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, null); + List<LocDetl> locDetls = locDetlService.queryStock(orderDetl); if (locDetls.size() == 0) { throw new CoolException("搴撳瓨涓病鏈夎鐗╂枡"); } @@ -644,4 +631,235 @@ throw new CoolException(locDetl.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); } } + + /** + * 鎷f枡閫斾腑骞舵澘鐩存帴鍔犲埌搴撳瓨涓� + * @param param + * @param userId + * @return + */ + @Override + @Transactional + public R WarehouseOutPickMergeV1(WarehouseOutPickMergeParam param, Long userId) { + //鍒ゆ柇搴撲綅鐘舵�� + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", param.getLocNo())); + if (Cools.isEmpty(locMast)){ + return R.error("璇ュ簱浣嶄笉瀛樺湪"); + } + if (!locMast.getLocSts().equals("P")){ + return R.error("璇ュ簱浣嶇姸鎬佷负锛�"+locMast.getLocSts()+",涓嶆弧瓒虫嫞鏂欓�斾腑骞舵澘鏉′欢锛侊紒锛�"); + } + + HashMap<String, OrderDetl> mapData = new HashMap<>(); + for (OrderDetl orderDetl : param.getCombMats()) { + String key = orderDetl.getMatnr(); +// private static final String[] sameFields = {"matnr", "batch", "outOrderNo", "luHao", "packing", "sPgNO", "proType","color"}; + if (!Cools.isEmpty(orderDetl.getBatch())) { + key += "_" + orderDetl.getBatch(); + } + if (!Cools.isEmpty(orderDetl.getOutOrderNo())) { + key += "_" + orderDetl.getOutOrderNo(); + } + if (!Cools.isEmpty(orderDetl.getLuHao())) { + key += "_" + orderDetl.getLuHao(); + } + if (!Cools.isEmpty(orderDetl.getPacking())) { + key += "_" + orderDetl.getPacking(); + } + if (!Cools.isEmpty(orderDetl.getSPgNO())) { + key += "_" + orderDetl.getSPgNO(); + } + if (!Cools.isEmpty(orderDetl.getProType())) { + key += "_" + orderDetl.getProType(); + } + if (!Cools.isEmpty(orderDetl.getColor())) { + key += "_" + orderDetl.getColor(); + } + + OrderDetl value = mapData.get(key); + if(value == null){ + mapData.put(key, orderDetl); + }else { + value.setAnfme(value.getAnfme() + orderDetl.getAnfme()); + mapData.put(key, value); + } + } + + List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); + + HashMap<String, PickMergeDto> locData = new HashMap<>(); + for (LocDetl locDetl : locDetls) { + String matKey = locDetl.getMatnr(); + if (!Cools.isEmpty(locDetl.getBatch())) { + matKey += "_" + locDetl.getBatch(); + } + if (!Cools.isEmpty(locDetl.getOutOrderNo())) { + matKey += "_" + locDetl.getOutOrderNo(); + } + if (!Cools.isEmpty(locDetl.getLuHao())) { + matKey += "_" + locDetl.getLuHao(); + } + if (!Cools.isEmpty(locDetl.getPacking())) { + matKey += "_" + locDetl.getPacking(); + } + if (!Cools.isEmpty(locDetl.getSPgNO())) { + matKey += "_" + locDetl.getSPgNO(); + } + if (!Cools.isEmpty(locDetl.getProType())) { + matKey += "_" + locDetl.getProType(); + } + if (!Cools.isEmpty(locDetl.getColor())) { + matKey += "_" + locDetl.getColor(); + } + + PickMergeDto dto = new PickMergeDto(); + dto.setOriginAnfme(locDetl.getAnfme()); + dto.setLocDetl(locDetl); + dto.setOrders(new ArrayList<>()); + locData.put(matKey, dto); + } + + for (Map.Entry<String, OrderDetl> entry : mapData.entrySet()) { + OrderDetl orderDetl = entry.getValue(); + LocDetl locDetl = new LocDetl(); + locDetl.sync(orderDetl); + locDetl.setLocNo(param.getLocNo()); + locDetl.setBarcode(locMast.getBarcode()); + Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr",locDetl.getMatnr())); + locDetl.setMaktx(mat.getMaktx()); + + String matKey = locDetl.getMatnr(); + if (!Cools.isEmpty(locDetl.getBatch())) { + matKey += "_" + locDetl.getBatch(); + } + if (!Cools.isEmpty(locDetl.getOutOrderNo())) { + matKey += "_" + locDetl.getOutOrderNo(); + } + if (!Cools.isEmpty(locDetl.getLuHao())) { + matKey += "_" + locDetl.getLuHao(); + } + if (!Cools.isEmpty(locDetl.getPacking())) { + matKey += "_" + locDetl.getPacking(); + } + if (!Cools.isEmpty(locDetl.getSPgNO())) { + matKey += "_" + locDetl.getSPgNO(); + } + if (!Cools.isEmpty(locDetl.getProType())) { + matKey += "_" + locDetl.getProType(); + } + if (!Cools.isEmpty(locDetl.getColor())) { + matKey += "_" + locDetl.getColor(); + } + + + PickMergeDto dto = locData.get(matKey); + if (dto == null) { + ArrayList<PickMergeOrderDto> orders = new ArrayList<>(); + orders.add(new PickMergeOrderDto(locDetl.getOrderNo(), locDetl.getAnfme())); + + dto = new PickMergeDto(); + dto.setOriginAnfme(0.0); + dto.setLocDetl(locDetl); + dto.setOrders(orders); + + locData.put(matKey, dto); + }else { + LocDetl detl = dto.getLocDetl(); + List<PickMergeOrderDto> orders = dto.getOrders(); + + detl.setAnfme(detl.getAnfme() + locDetl.getAnfme()); + orders.add(new PickMergeOrderDto(locDetl.getOrderNo(), locDetl.getAnfme())); + + dto.setLocDetl(detl); + dto.setOrders(orders); + + locData.put(matKey, dto); + } + } + + + for (Map.Entry<String, PickMergeDto> entry : locData.entrySet()) { + PickMergeDto dto = entry.getValue(); + + Double originAnfme = dto.getOriginAnfme(); + LocDetl locDetl = dto.getLocDetl(); + List<PickMergeOrderDto> orders = dto.getOrders(); + + Boolean b=false; + for (LocDetl detl : locDetls) { + b= MatCompareUtils.compare(detl, locDetl); + if (b) break; + } + + if (b){ + if (!locDetlService.updateAnfmeAdd(locDetl.getAnfme(),locDetl.getLocNo(),locDetl)) { + throw new CoolException("骞舵澘搴撳瓨鏇存柊澶辫触"); + } + }else { + locDetl.setZpallet(locDetl.getBarcode()); + if (!locDetlService.insert(locDetl)) { + throw new CoolException("骞舵澘搴撳瓨鎻掑叆澶辫触"); + } + } + + if (!orders.isEmpty()){ + for (PickMergeOrderDto orderDto : orders) { + Order order = orderService.selectByNo(orderDto.getOrderNo()); + if (Cools.isEmpty(order)){ + continue; + } + if (order.getSettle() == 1){ + orderService.updateSettle(order.getId(), 2L, 9527L); + } + + + LocDto locDto = new LocDto(locDetl.getOrderNo(),locDetl.getMatnr(),locDetl.getBatch(),locDetl.getOutOrderNo(),locDetl.getLuHao(),locDetl.getPacking(),locDetl.getSPgNO(),locDetl.getProType(),locDetl.getColor()); + OrderDetl orderDetl = orderDetlService.selectItem(locDto); + if (Cools.isEmpty(orderDetl)){ + continue; + } + if (orderDetl.getAnfme() < (orderDetl.getWorkQty() + orderDto.getAnfme())) { + throw new CoolException("骞舵澘鏁伴噺鍑洪敊,璁㈠崟鍓╀綑鍑哄簱鏁伴噺灏忎簬宸插嚭搴撴暟閲忎笌灏嗗苟鏉挎暟閲忎箣鍜岋紒锛侊紒"); + } + // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺 + if (!orderDetlService.increaseWorkQtyByOrderNo(orderDto.getOrderNo(), orderDetl, orderDto.getAnfme())) { + throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触"); + } + // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺 + if (!orderDetlService.increaseQtyByOrderNo1(orderDto.getOrderNo(), orderDetl, orderDto.getAnfme())) { + throw new CoolException("淇敼鍗曟嵁鏄庣粏瀹屾垚鏁伴噺澶辫触"); + } + // 淇敼璁㈠崟鐘舵�� 浣滀笟涓� ===>> 宸插畬鎴� + orderService.checkComplete(orderDto.getOrderNo()); + + try { + //澶勭悊搴撳瓨淇℃伅 + AdjDetl adjDetl = new AdjDetl(); + adjDetl.setLocNo(locDetl.getLocNo()); + adjDetl.setMatnr(locDetl.getMatnr()); + adjDetl.setBatch(locDetl.getBatch()); + adjDetl.setOriQty(originAnfme); + adjDetl.setAdjQty(locDetl.getAnfme()); + adjDetl.setMemo("鎷f枡閫斾腑骞舵澘"); + adjDetl.setModiUser(userId); + adjDetl.setAppeUser(userId); + adjDetl.setAppeTime(new Date()); + adjDetl.setModiTime(new Date()); + adjDetl.setExpand(locDetl);//瀵规墿鍏呰繘琛屾嫾鎺� + adjDetl.setOrderNo(order.getOrderNo()); + + if (!adjDetlService.save(adjDetl,userId)) { + throw new CoolException("淇濆瓨搴撳瓨璋冩暣璁板綍澶辫触"); + } + }catch (Exception e){ + e.printStackTrace(); + throw new CoolException("鏇存柊搴撳瓨鏁版嵁鍑洪敊" + e.getMessage()); + } + } + } + + + } + return R.ok(); + } } -- Gitblit v1.9.1