From 431f88fdade07a22b636714f1690cee3a55668d0 Mon Sep 17 00:00:00 2001
From: cp <513960435@qq.com>
Date: 星期三, 30 十月 2024 13:35:56 +0800
Subject: [PATCH] 完善
---
zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 512 insertions(+), 9 deletions(-)
diff --git a/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java b/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java
index ee572f3..c2d6f71 100644
--- a/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java
+++ b/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java
@@ -3,7 +3,13 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.common.domain.dto.DetlDto;
import com.zy.asrs.common.domain.param.MobileAdjustParam;
+import com.zy.asrs.common.openapi.entity.dto.MergeBoardManyDto;
+import com.zy.asrs.common.openapi.entity.dto.PickMergeDto;
+import com.zy.asrs.common.openapi.entity.dto.PickMergeOrderDto;
import com.zy.asrs.common.openapi.entity.param.CombParam;
+import com.zy.asrs.common.openapi.entity.param.WarehouseOutMergeBoardManyParam;
+import com.zy.asrs.common.openapi.entity.param.WarehouseOutPickMergeParam;
+import com.zy.asrs.common.web.BaseController;
import com.zy.asrs.common.wms.entity.*;
import com.zy.asrs.common.wms.mapper.LocDetlMapper;
import com.zy.asrs.common.wms.service.*;
@@ -19,10 +25,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
+import java.math.BigDecimal;
+import java.util.*;
/**
* 绉诲姩绔湇鍔℃牳蹇冪被
@@ -51,6 +55,8 @@
private LocDetlService locDetlService;
@Autowired
private WaitPakinLogService waitPakinLogService;
+ @Autowired
+ private AdjDetlService adjDetlService;
@Override
@Transactional
@@ -98,12 +104,14 @@
waitPakin.setAppeTime(now);
waitPakin.setModiUser(userId);
waitPakin.setModiTime(now);
+ waitPakin.setFullPlt(param.getFullPlt());
+ waitPakin.setOwner(param.getOwner());
if (!waitPakinService.save(waitPakin)) {
throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
}
}
// 鍏宠仈缁勬墭
- } else {
+ } else {
Order order = orderService.selectByNo(param.getOrderNo(), hostId);
if (order.getSettle() > 2) {
throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
@@ -113,16 +121,19 @@
param.getCombMats().forEach(elem -> {
// 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
- OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch());
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch(),hostId);
if (elem.getAnfme() > orderDetl.getEnableQty()) {
throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
}
// 淇敼璁㈠崟鏄庣粏鏁伴噺
- if (!orderDetlService.increase(order.getId(), hostId, elem.getMatnr(), elem.getBatch(), elem.getAnfme())) {
+ if (!orderDetlService.increaseWorkQtyByOrderNo(order.getOrderNo(), elem.getMatnr(), elem.getBatch(), elem.getAnfme(), hostId)) {
throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触");
}
DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
+ detlDto.setWarehouse(orderDetl.getThreeCode());//鏉ユ簮浠撳簱
+ detlDto.setOrigin(orderDetl.getSupp());//鏉ユ簮鍗曞彿
+ detlDto.setOriginNo(orderDetl.getSuppCode());//鏉ユ簮搴忓彿
if (DetlDto.has(detlDtos, detlDto)) {
DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
assert one != null;
@@ -143,11 +154,15 @@
waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺
+ waitPakin.setThreeCode(detlDto.getWarehouse()); // 浠撳簱
+ waitPakin.setSupp(detlDto.getOrigin()); // 鏉ユ簮鍗曞彿
+ waitPakin.setSuppCode(detlDto.getOriginNo()); // 鏉ユ簮搴忓彿
waitPakin.setStatus("Y"); // 鐘舵��
waitPakin.setAppeUser(userId);
waitPakin.setAppeTime(now);
waitPakin.setModiUser(userId);
waitPakin.setModiTime(now);
+ waitPakin.setOwner(Optional.ofNullable(param.getOwner()).orElse(""));
if (!waitPakinService.save(waitPakin)) {
throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
}
@@ -237,8 +252,8 @@
@Override
@Transactional
public R WarehouseIn(String locNo, String barcode,Long hostId) {
- //鍒ゆ柇搴撲綅鐘舵��
- LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, locNo).eq(LocMast::getHostId,hostId));
+ //鍒ゆ柇搴撲綅鐘舵��
+ LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, locNo).eq(LocMast::getHostId,hostId).eq(LocMast::getWhsType,1L));
if (Cools.isEmpty(locMast)){
return R.error("璇ュ簱浣嶄笉瀛樺湪");
}
@@ -266,11 +281,31 @@
locDetl.setModiTime(now);
locDetl.setAppeTime(now);
locDetlService.save(locDetl);
+ //鏄惁灞炰簬璁㈠崟鏁版嵁
+ if (!Cools.isEmpty(waitPakin.getOrderNo())){
+ Order order = orderService.selectByNo(waitPakin.getOrderNo(), hostId);
+ if (Cools.isEmpty(order)){
+ continue;
+ }
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), waitPakin.getMatnr(), waitPakin.getBatch(),hostId);
+ if (Cools.isEmpty(orderDetl)){
+ continue;
+ }
+ // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺
+ if (!orderDetlService.increase(order.getId(), hostId, waitPakin.getMatnr(), waitPakin.getBatch(), waitPakin.getAnfme())) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鐘舵�� 浣滀笟涓� ===>> 宸插畬鎴�
+ orderService.checkComplete(waitPakin.getOrderNo(), hostId);
+
+ }
}
//淇敼搴撲綅鐘舵��
locMast.setLocSts("F");
locMast.setModiTime(now);
locMastService.updateById(locMast);
+
+
// 淇濆瓨鍏ュ簱閫氱煡妗e巻鍙叉。
if (!waitPakinLogService.saveToHistory(barcode, hostId)) {
@@ -282,4 +317,472 @@
}
return R.ok("涓婃灦鎴愬姛");
}
+
+ @Override
+ @Transactional
+ public R WarehouseOut(CombParam combParam, Long hostId) {
+ //鍒ゆ柇搴撲綅鐘舵��
+ LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId,hostId).eq(LocMast::getWhsType,1L));
+ if (Cools.isEmpty(locMast)){
+ return R.error("璇ュ簱浣嶄笉瀛樺湪");
+ }
+ if (!locMast.getLocSts().equals("F")){
+ return R.error("璇ュ簱浣嶇姸鎬佷负锛�"+locMast.getLocSts()+",绂佹鍑哄簱");
+ }
+ //鏌ヨ搴撳瓨鏁版嵁
+ for (CombParam.CombMat combMat :combParam.getCombMats()){
+ LocDetl locDetl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>()
+ .eq(LocDetl::getLocNo, combParam.getLocno())
+ .eq(LocDetl::getHostId, hostId)
+ .eq(LocDetl::getZpallet, combMat.getZpallet())
+ .eq(LocDetl::getMatnr, combMat.getMatnr())
+ .eq(LocDetl::getBatch, combMat.getBatch())
+ );
+ if (Cools.isEmpty(locDetl)){
+ return R.error("鏈煡璇㈠埌搴撳瓨鏁版嵁");
+ }
+ if (combMat.getAnfme() > locDetl.getAnfme()){
+ return R.error("涓嬫灦鏁伴噺閿欒锛岃秴鍑哄簱瀛樻暟閲�");
+ }
+ if (!Cools.isEmpty(combParam.getOrderNo())){
+ Order order = orderService.selectByNo(combParam.getOrderNo(), hostId);
+ if (Cools.isEmpty(order)){
+ continue;
+ }
+ if (order.getSettle() == 1){
+ orderService.updateSettle(order.getId(), 2L, 9527L, hostId);
+ }
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(),hostId);
+ if (Cools.isEmpty(orderDetl)){
+ continue;
+ }
+ if (orderDetl.getAnfme() < orderDetl.getWorkQty()+combMat.getAnfme()){
+ throw new CoolException("涓嬫灦鏁伴噺鍑洪敊");
+ }
+ // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺
+ if (!orderDetlService.increaseWorkQtyByOrderNo(combParam.getOrderNo(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), hostId)) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺
+ if (!orderDetlService.increase(order.getId(), hostId, combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏瀹屾垚鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鐘舵�� 浣滀笟涓� ===>> 宸插畬鎴�
+ orderService.checkComplete(combParam.getOrderNo(), hostId);
+ }
+ try {
+ //澶勭悊搴撳瓨淇℃伅
+ if (combMat.getAnfme().equals(locDetl.getAnfme())){
+ //搴撳瓨鐩哥瓑鍒犻櫎鏁版嵁
+ locDetlService.removeById(locDetl);
+ int count = locDetlService.count(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo,combParam.getLocno()).eq(LocDetl::getHostId, hostId));
+ if (count == 0){
+ LocMast locMast1 = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId, hostId));
+ locMast1.setLocSts("O");
+ locMastService.updateById(locMast1);
+ }
+ }else {
+ BigDecimal subtract = BigDecimal.valueOf(locDetl.getAnfme()).subtract(BigDecimal.valueOf(combMat.getAnfme()));
+ locDetl.setAnfme(subtract.doubleValue());
+ locDetlService.updateById(locDetl);
+ }
+ }catch (Exception e){
+ throw new CoolException("鏇存柊搴撳瓨鏁版嵁鍑洪敊"+e.getMessage());
+ }
+ }
+
+
+
+
+
+ return R.ok();
+ }
+
+ @Override
+ @Transactional
+ public R WarehouseOutV1(CombParam combParam, Long hostId,Long userId) {
+ //鍒ゆ柇搴撲綅鐘舵��
+ LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId,hostId).eq(LocMast::getWhsType,0L));
+ if (Cools.isEmpty(locMast)){
+ return R.error("璇ュ簱浣嶄笉瀛樺湪");
+ }
+ if (!locMast.getLocSts().equals("P")){
+ return R.error("璇ュ簱浣嶇姸鎬佷负锛�"+locMast.getLocSts()+",涓嶆弧瓒冲苟鏉块�斾腑鎷i�夋潯浠讹紒锛侊紒");
+ }
+ //鏌ヨ搴撳瓨鏁版嵁
+ for (CombParam.CombMat combMat :combParam.getCombMats()){
+ List<LocDetl> locDetlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>()
+ .eq(LocDetl::getLocNo, combParam.getLocno())
+ .eq(LocDetl::getHostId, hostId)
+// .eq(LocDetl::getZpallet, combMat.getZpallet())
+ .eq(LocDetl::getMatnr, combMat.getMatnr())
+// .eq(LocDetl::getBatch, combMat.getBatch())
+ );
+ if (locDetlList.isEmpty()){
+ return R.error("鏈煡璇㈠埌搴撳瓨鏁版嵁");
+ }
+ if (locDetlList.size()>1){
+ return R.error("搴撳瓨鏁版嵁澶т簬1鏉★紝涓轰繚璇佹暟鎹噯纭�э紝璇风敤姝e父娴佺▼鍑哄簱锛侊紒锛�");
+ }
+ LocDetl locDetl = locDetlList.get(0);
+ if (combMat.getAnfme() > locDetl.getAnfme()){
+ return R.error("鎷i�夋暟閲忛敊璇紝瓒呭嚭搴撳瓨鏁伴噺");
+ }
+ if (!Cools.isEmpty(combMat.getOrderNo())){
+ Order order = orderService.selectByNo(combMat.getOrderNo(), hostId);
+ if (Cools.isEmpty(order)){
+ continue;
+ }
+ if (order.getSettle() == 1){
+ orderService.updateSettle(order.getId(), 2L, 9527L, hostId);
+ }
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(),hostId);
+ if (Cools.isEmpty(orderDetl)){
+ continue;
+ }
+ if (orderDetl.getAnfme() < (orderDetl.getWorkQty()+combMat.getAnfme())){
+ throw new CoolException("鎷i�夋暟閲忓嚭閿�,璁㈠崟鍓╀綑鍑哄簱鏁伴噺灏忎簬宸插嚭搴撴暟閲忎笌灏嗘嫞閫夋暟閲忎箣鍜岋紒锛侊紒");
+ }
+ // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺
+ if (!orderDetlService.increaseWorkQtyByOrderNo(combMat.getOrderNo(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), hostId)) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺
+ if (!orderDetlService.increase(order.getId(), hostId, combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏瀹屾垚鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鐘舵�� 浣滀笟涓� ===>> 宸插畬鎴�
+ orderService.checkComplete(combMat.getOrderNo(), hostId);
+ }
+ try {
+ //澶勭悊搴撳瓨淇℃伅
+ AdjDetl adjDetl = new AdjDetl();
+ adjDetl.setLocNo(locDetl.getLocNo());
+ adjDetl.setMatnr(locDetl.getMatnr());
+ adjDetl.setBatch(locDetl.getBatch());
+ adjDetl.setOriQty(locDetl.getAnfme());
+ adjDetl.setMemo("WarehouseOutV1-pick");
+ adjDetl.setModiUser(userId);
+ adjDetl.setAppeUser(userId);
+ adjDetl.setAppeTime(new Date());
+ adjDetl.setModiTime(new Date());
+ adjDetl.setOrderNo(combMat.getOrderNo());
+ if (combMat.getAnfme().equals(locDetl.getAnfme())){
+ adjDetl.setAdjQty(0D);
+ //搴撳瓨鐩哥瓑鍒犻櫎鏁版嵁
+ locDetlService.removeById(locDetl);
+ int count = locDetlService.count(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo,combParam.getLocno()).eq(LocDetl::getHostId, hostId));
+ if (count == 0){
+ LocMast locMast1 = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId, hostId));
+// locMast1.setLocSts("O");
+// locMastService.updateById(locMast1);
+ }
+ } else {
+ BigDecimal subtract = BigDecimal.valueOf(locDetl.getAnfme()).subtract(BigDecimal.valueOf(combMat.getAnfme()));
+ locDetl.setAnfme(subtract.doubleValue());
+ locDetlService.updateById(locDetl);
+ adjDetl.setAdjQty(subtract.doubleValue());
+ }
+
+ if (!adjDetlService.save(adjDetl)) {
+ throw new CoolException("淇濆瓨搴撳瓨璋冩暣璁板綍澶辫触");
+ }
+ }catch (Exception e){
+ throw new CoolException("鏇存柊搴撳瓨鏁版嵁鍑洪敊"+e.getMessage());
+ }
+ }
+ return R.ok();
+ }
+
+ @Override
+ @Transactional
+ public R WarehouseOutPickMergeV1(WarehouseOutPickMergeParam param, Long hostId,Long userId) {
+ //鍒ゆ柇搴撲綅鐘舵��
+ LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, param.getLocNo()).eq(LocMast::getHostId,hostId).eq(LocMast::getWhsType,0L));
+ 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();
+ if (!Cools.isEmpty(orderDetl.getBatch())) {
+ key += "_" + orderDetl.getBatch();
+ }
+
+ 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.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, locMast.getLocNo()));
+
+ HashMap<String, PickMergeDto> locData = new HashMap<>();
+ for (LocDetl locDetl : locDetls) {
+ String matKey = locDetl.getMatnr();
+ if (!Cools.isEmpty(locDetl.getBatch())) {
+ matKey += "_" + locDetl.getBatch();
+ }
+
+ 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.setId(null);
+ locDetl.setLocNo(param.getLocNo());
+ locDetl.setBarcode(locMast.getBarcode());
+ Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr,locDetl.getMatnr()));
+ locDetl.setHostId(hostId);
+ locDetl.setMaktx(mat.getMaktx());
+ if(hostId==1){
+ locDetl.setOwner("瀹佹尝浠�");
+ }else{
+ locDetl.setOwner("鏂版槍浠�");
+ }
+
+ String matKey = locDetl.getMatnr();
+ if (!Cools.isEmpty(locDetl.getBatch())) {
+ matKey += "_" + locDetl.getBatch();
+ }
+
+ 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(locDetl.getAnfme());
+ 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();
+
+ if (locDetl.getId() == null) {
+ if (!locDetlService.save(locDetl)) {
+ throw new CoolException("骞舵澘搴撳瓨鎻掑叆澶辫触");
+ }
+ }else {
+ if (!locDetlService.updateById(locDetl)) {
+ throw new CoolException("骞舵澘搴撳瓨鏇存柊澶辫触");
+ }
+ }
+
+ if (!orders.isEmpty()){
+ for (PickMergeOrderDto orderDto : orders) {
+ Order order = orderService.selectByNo(orderDto.getOrderNo(), hostId);
+ if (Cools.isEmpty(order)){
+ continue;
+ }
+ if (order.getSettle() == 1){
+ orderService.updateSettle(order.getId(), 2L, 9527L, hostId);
+ }
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), locDetl.getMatnr(), locDetl.getBatch(),hostId);
+ if (Cools.isEmpty(orderDetl)){
+ continue;
+ }
+ if (orderDetl.getAnfme() < (orderDetl.getWorkQty() + orderDto.getAnfme())) {
+ throw new CoolException("骞舵澘鏁伴噺鍑洪敊,璁㈠崟鍓╀綑鍑哄簱鏁伴噺灏忎簬宸插嚭搴撴暟閲忎笌灏嗗苟鏉挎暟閲忎箣鍜岋紒锛侊紒");
+ }
+ // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺
+ if (!orderDetlService.increaseWorkQtyByOrderNo(orderDto.getOrderNo(), locDetl.getMatnr(), locDetl.getBatch(), orderDto.getAnfme(), hostId)) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺
+ if (!orderDetlService.increase(order.getId(), hostId, locDetl.getMatnr(), locDetl.getBatch(), orderDto.getAnfme())) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏瀹屾垚鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鐘舵�� 浣滀笟涓� ===>> 宸插畬鎴�
+ orderService.checkComplete(orderDto.getOrderNo(), hostId);
+
+ 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("WarehouseOutV1-pick");
+ adjDetl.setModiUser(userId);
+ adjDetl.setAppeUser(userId);
+ adjDetl.setAppeTime(new Date());
+ adjDetl.setModiTime(new Date());
+ adjDetl.setOrderNo(order.getOrderNo());
+ if (!adjDetlService.save(adjDetl)) {
+ throw new CoolException("淇濆瓨搴撳瓨璋冩暣璁板綍澶辫触");
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new CoolException("鏇存柊搴撳瓨鏁版嵁鍑洪敊" + e.getMessage());
+ }
+ }
+ }
+
+
+ }
+ return R.ok();
+ }
+
+ @Override
+ @Transactional
+ public R WarehouseOutMergeBoardMany(WarehouseOutMergeBoardManyParam param, Long hostId,Long userId) {
+ WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode(), hostId);
+ if (wrkMast == null) {
+ throw new CoolException("宸ヤ綔妗d笉瀛樺湪");
+ }
+
+ if (wrkMast.getIoType() != 104) {
+ throw new CoolException("宸ヤ綔绫诲瀷涓嶅睘浜庡苟鏉垮嚭搴�");
+ }
+
+ if (wrkMast.getWrkSts() != 199) {
+ throw new CoolException("宸ヤ綔鐘舵�佷笉婊¤冻澶氭骞舵澘鍏ュ簱鐘舵��");
+ }
+
+ List<WrkDetl> wrkDetls = wrkDetlService.list(new LambdaQueryWrapper<WrkDetl>().eq(WrkDetl::getWrkNo, wrkMast.getWrkNo()));
+
+ HashMap<String, MergeBoardManyDto> wrkData = new HashMap<>();
+ for (WrkDetl wrkDetl : wrkDetls) {
+ String matKey = wrkDetl.getMatnr();
+ if (!Cools.isEmpty(wrkDetl.getBatch())) {
+ matKey += "_" + wrkDetl.getBatch() + "-" +wrkDetl.getOrderNo();
+ }
+
+ MergeBoardManyDto dto = new MergeBoardManyDto();
+ dto.setOriginAnfme(wrkDetl.getAnfme());
+ dto.setWrkDetl(wrkDetl);
+ dto.setOrders(new ArrayList<>());
+ wrkData.put(matKey, dto);
+ }
+
+ for (OrderDetl orderDetl : param.getCombMats()) {
+ String matKey = orderDetl.getMatnr();
+ if (!Cools.isEmpty(orderDetl.getBatch())) {
+ matKey += "_" + orderDetl.getBatch() + "-" +orderDetl.getOrderNo();
+ }
+
+ MergeBoardManyDto dto = wrkData.get(matKey);
+ if(dto == null){
+ WrkDetl wrkDetl = new WrkDetl();
+ wrkDetl.sync(orderDetl);
+ Mat mat=matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr,wrkDetl.getMatnr()));
+ wrkDetl.sync(mat);
+ wrkDetl.setId(null);
+ wrkDetl.setWrkNo(wrkMast.getWrkNo());
+ wrkDetl.setWrkMastId(wrkMast.getId());
+ wrkDetl.setZpallet(wrkMast.getBarcode());
+ wrkDetl.setIoTime(new Date());
+ wrkDetl.setHostId(hostId);
+ wrkDetl.setAppeUser(userId);
+ wrkDetl.setAppeTime(new Date());
+ wrkDetl.setModiUser(userId);
+ wrkDetl.setModiTime(new Date());
+ ArrayList<PickMergeOrderDto> orderDtos = new ArrayList<>();
+ orderDtos.add(new PickMergeOrderDto(orderDetl.getOrderNo(), orderDetl.getAnfme()));
+
+ dto = new MergeBoardManyDto();
+ dto.setOriginAnfme(orderDetl.getAnfme());
+ dto.setWrkDetl(wrkDetl);
+ dto.setOrders(orderDtos);
+ }else {
+ WrkDetl wrkDetl = dto.getWrkDetl();
+ List<PickMergeOrderDto> orders = dto.getOrders();
+
+ wrkDetl.setAnfme(wrkDetl.getAnfme() + orderDetl.getAnfme());
+ wrkDetl.setIoTime(new Date());
+ wrkDetl.setHostId(hostId);
+ wrkDetl.setModiUser(userId);
+ wrkDetl.setModiTime(new Date());
+ orders.add(new PickMergeOrderDto(orderDetl.getOrderNo(), orderDetl.getAnfme()));
+ dto.setWrkDetl(wrkDetl);
+ dto.setOrders(orders);
+ }
+
+ wrkData.put(matKey, dto);
+ }
+
+ for (Map.Entry<String, MergeBoardManyDto> entry : wrkData.entrySet()) {
+ MergeBoardManyDto dto = entry.getValue();
+ List<PickMergeOrderDto> orders = dto.getOrders();
+ WrkDetl wrkDetl = dto.getWrkDetl();
+
+ if (wrkDetl.getId() == null) {
+ if (!wrkDetlService.save(wrkDetl)) {
+ throw new CoolException("澶氭骞舵澘鎻掑叆宸ヤ綔鏄庣粏澶辫触");
+ }
+ }else {
+ if (!wrkDetlService.updateById(wrkDetl)) {
+ throw new CoolException("澶氭骞舵澘鏇存柊宸ヤ綔鏄庣粏澶辫触");
+ }
+ }
+
+ if (!orders.isEmpty()){
+ for (PickMergeOrderDto orderDto : orders) {
+ Order order = orderService.selectByNo(orderDto.getOrderNo(), hostId);
+ if (Cools.isEmpty(order)){
+ continue;
+ }
+ if (order.getSettle() == 1){
+ orderService.updateSettle(order.getId(), 2L, 9527L, hostId);
+ }
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), wrkDetl.getMatnr(), wrkDetl.getBatch(),hostId);
+ if (Cools.isEmpty(orderDetl)){
+ continue;
+ }
+ if (orderDetl.getAnfme() < (orderDetl.getWorkQty() + orderDto.getAnfme())) {
+ throw new CoolException("鎷i�夋暟閲忓嚭閿�,璁㈠崟鍓╀綑鍑哄簱鏁伴噺灏忎簬宸插嚭搴撴暟閲忎笌灏嗘嫞閫夋暟閲忎箣鍜岋紒锛侊紒");
+ }
+ // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺
+ if (!orderDetlService.increaseWorkQtyByOrderNo(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme(), hostId)) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺
+ if (!orderDetlService.increase(order.getId(), hostId, wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) {
+ throw new CoolException("淇敼鍗曟嵁鏄庣粏瀹屾垚鏁伴噺澶辫触");
+ }
+ // 淇敼璁㈠崟鐘舵�� 浣滀笟涓� ===>> 宸插畬鎴�
+ orderService.checkComplete(orderDto.getOrderNo(), hostId);
+
+
+ }
+ }
+ }
+
+ return R.ok();
+ }
}
--
Gitblit v1.9.1