From 144d50c5ba277ba9df9613d3510655db314358f7 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期五, 31 十月 2025 16:26:44 +0800
Subject: [PATCH] 1
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 558 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 438 insertions(+), 120 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 c401b70..2c9a489 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -8,6 +8,8 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
+import com.zy.asrs.enums.CommonEnum;
+import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
@@ -21,12 +23,16 @@
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
+import java.util.stream.Collectors;
/**
* 绉诲姩绔湇鍔℃牳蹇冪被
@@ -96,16 +102,29 @@
@Resource
private OrderDetlPakoutService orderDetlPakoutService;
+ @Autowired
+ private LocCacheService locCacheService;
+
+ @Autowired
+ private TaskService taskService;
+
+ @Autowired
+ private TaskDetlService taskDetlService;
+ @Autowired
+ private BasStationService basStationService;
+ @Autowired
+ private BasContainerService basContainerService;
+
@Override
@Transactional
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();
@@ -117,8 +136,8 @@
wrkMast.setIoType(8); // 鍏ュ嚭搴撶姸鎬侊細8.鎷f枡閫斾腑骞舵澘
wrkMast.setIoPri(13D); // 浼樺厛绾�
wrkMast.setCrnNo(1);
- wrkMast.setSourceStaNo(1);
- wrkMast.setStaNo(1);
+ wrkMast.setSourceStaNo(1 + "");
+ wrkMast.setStaNo(1 + "");
wrkMast.setLocNo(param.getLocNo());
wrkMast.setBarcode(param.getBarcode()); // 鎵樼洏鐮�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
@@ -135,7 +154,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());
}
@@ -151,7 +170,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());
@@ -165,11 +184,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())) {
@@ -177,11 +196,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);
}
}
@@ -192,7 +211,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()));
@@ -216,9 +235,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("鐗╂枡鏁版嵁涓嶅瓨鍦�");
}
@@ -244,8 +263,8 @@
wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細101.鐢熸垚鍑哄簱
wrkMast.setIoType(104); // 鍏ュ嚭搴撶姸鎬�
wrkMast.setIoPri(13D); // 浼樺厛绾э細13
- wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
- wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
+ wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
+ wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
wrkMast.setSourceLocNo(param.getLocNo()); // 婧愬簱浣�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
wrkMast.setPicking("Y"); // 鎷f枡
@@ -282,7 +301,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)) {
@@ -291,10 +310,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()));
@@ -317,47 +336,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("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触");
}
// // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺
@@ -378,8 +397,8 @@
wrkMast.setIoType(108); // 鍏ュ嚭搴撶姸鎬侊細鍑哄簱锛屾嫞鏂欏叆搴�
wrkMast.setIoPri(13D); // 浼樺厛绾�
wrkMast.setCrnNo(1);
- wrkMast.setSourceStaNo(1);
- wrkMast.setStaNo(1);
+ wrkMast.setSourceStaNo(1 + "");
+ wrkMast.setStaNo(1 + "");
wrkMast.setSourceLocNo(combParam.getLocNo());
wrkMast.setBarcode(combParam.getBarcode()); // 鎵樼洏鐮�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
@@ -395,7 +414,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());
}
@@ -412,7 +431,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());
@@ -425,8 +444,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("鎿嶄綔鎴愬姛锛�");
@@ -509,7 +528,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);
}
@@ -539,44 +558,40 @@
}
@Override
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
public void comb(CombParam param, Long userId) {
if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
throw new CoolException(BaseRes.PARAM);
}
- if(param.getCombMats().size()>1){
+ if (param.getCombMats().size() < 1) {
throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒");
}
// 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
- eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
+ 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());
- }
- 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());
}
Date now = new Date();
-
// 鏃犲崟缁勬墭
if (Cools.isEmpty(param.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());
if (DetlDto.has(detlDtos, detlDto)) {
DetlDto one = DetlDto.findDto(detlDtos, detlDto);
assert one != null;
@@ -586,19 +601,21 @@
}
});
-
for (DetlDto detlDto : detlDtos) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
+ if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) {
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + mat.getUpQty());
+ }
WaitPakin waitPakin = new WaitPakin();
- waitPakin.sync(mat);
+ BeanUtils.copyProperties(mat, waitPakin);
waitPakin.setBatch(detlDto.getBatch());
- waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
- waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
- waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺
- waitPakin.setStatus("Y"); // 鐘舵��
+ waitPakin.setZpallet(param.getBarcode());
+ waitPakin.setIoStatus("N");
+ waitPakin.setAnfme(detlDto.getAnfme());
+ waitPakin.setStatus("Y");
waitPakin.setAppeUser(userId);
waitPakin.setAppeTime(now);
waitPakin.setModiUser(userId);
@@ -607,32 +624,36 @@
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 -> {
-
- // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-// 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());
- if (elem.getAnfme() > orderDetl.getEnableQty()) {
- throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+ Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, elem.getOrderNo());
+ if (Cools.isEmpty(order) || order.getSettle() > 2) {
+ throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
}
- // 淇敼璁㈠崟浣滀笟鏁伴噺
-// 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());
+ // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
+// 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());
+ OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
+ .eq("order_id", order.getId())
+ .eq("matnr", elem.getMatnr()));
+
+ if (Objects.isNull(detls)) {
+ throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗕笉瀛樺湪锛侊紒");
+ }
+
+ if (elem.getAnfme() > detls.getEnableQty()) {
+ throw new CoolException(detls.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+ }
+ 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.setOrderId(order.getId());
+ detlDto.setOrderNo(order.getOrderNo());
if (DetlDto.has(detlDtos, detlDto)) {
DetlDto one = DetlDto.findDto(detlDtos, detlDto);
assert one != null;
@@ -641,14 +662,45 @@
detlDtos.add(detlDto);
}
});
+
+ BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
+ if (Objects.isNull(container)) {
+ throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
+ }
+ if (container.getMixMax() < detlDtos.size()) {
+ throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
+ }
+ Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet());
+ List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
+ Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
+ if (tagIds.size() > 1) {
+ throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
+ }
+ //杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
+ Integer suplus = container.getMixMax();
for (DetlDto detlDto : detlDtos) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
+ //鏈�澶氬彲鏀炬暟閲�
+ Double singleMax = mat.getUpQty() * suplus;
+ if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
+ }
+ BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
+ //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
+ Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
+ suplus = suplus - curr;
+ if (suplus < 0) {
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+ }
+
WaitPakin waitPakin = new WaitPakin();
- waitPakin.sync(mat);
- waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿
+ BeanUtils.copyProperties(mat, waitPakin);
+// waitPakin.sync(mat);
+ waitPakin.setOrderNo(detlDto.getOrderNo()); // 鍗曟嵁缂栧彿
+ waitPakin.setOrderId(detlDto.getOrderId());
waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮�
waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
@@ -662,8 +714,12 @@
throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
}
}
-// orderService.updateSettle(order.getId(), 2L, userId);
- OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId);
+
+ Set<String> stringSet = param.getCombMats().stream().map(CombParam.CombMat::getOrderNo).collect(Collectors.toSet());
+ stringSet.forEach(orderNo -> {
+ Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, orderNo);
+ OrderInAndOutUtil.updateOrder(Boolean.TRUE, order.getId(), 2L, userId);
+ });
}
}
@@ -680,15 +736,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();
@@ -709,16 +765,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());
}
// 鏌ユ壘鍟嗗搧
@@ -777,7 +833,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());
@@ -793,7 +851,7 @@
}
// 淇敼鐩樼偣浠诲姟涓绘。鐘舵��
- wrkMast.setFullPlt(wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()).size() != 0?"Y":"N");
+ wrkMast.setFullPlt(wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()).size() != 0 ? "Y" : "N");
wrkMast.setModiTime(now);
wrkMast.setModiUser(userId);
if (!wrkMastService.updateById(wrkMast)) {
@@ -835,8 +893,8 @@
}
Mat analyse = MatUtils.analyseMat(elem.getMatnr());
// 鏉$爜銆佺墿鏂欎唬鐮併�佸簭鍒楀彿銆佹暟閲�
- DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),analyse.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),
- elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme());
+ DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), analyse.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
+ elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
// DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme());
// DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
@@ -873,10 +931,10 @@
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);
+ 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);
+ log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response);
throw new CoolException("涓婃姤mes绯荤粺澶辫触");
}
} catch (Exception e) {
@@ -894,7 +952,9 @@
response,
success
);
- } catch (Exception e) { log.error("", e); }
+ } catch (Exception e) {
+ log.error("", e);
+ }
}
}
@@ -924,8 +984,8 @@
// 淇敼浣滀笟鏁伴噺 ----------------------------------------
// 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
// OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch());
- OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), detlDto.getMatnr(), detlDto.getBatch(),detlDto.getBrand(),detlDto.getStandby1(),detlDto.getStandby2(),detlDto.getStandby3()
- ,detlDto.getBoxType1(),detlDto.getBoxType2(),detlDto.getBoxType3());
+ OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3()
+ , detlDto.getBoxType1(), detlDto.getBoxType2(), detlDto.getBoxType3());
if (detlDto.getAnfme() > orderDetl.getEnableQty()) {
throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
}
@@ -933,15 +993,15 @@
// if (!orderDetlService.increaseWorkQty(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme())) {
// throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
// }
- OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE,order.getId(), detlDto.getMatnr(), detlDto.getBatch(),detlDto.getBrand(),detlDto.getStandby1(),detlDto.getStandby2(),detlDto.getStandby3()
- ,detlDto.getBoxType1(),detlDto.getBoxType2(),detlDto.getBoxType3(), detlDto.getAnfme());
+ OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3()
+ , detlDto.getBoxType1(), detlDto.getBoxType2(), detlDto.getBoxType3(), detlDto.getAnfme());
// 淇濆瓨鍏ュ簱閫氱煡妗�
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
WaitPakin waitPakin = new WaitPakin();
- waitPakin.sync(mat);
+ BeanUtils.copyProperties(mat, waitPakin);
waitPakin.setOrderNo(orderNo);
waitPakin.setBatch(detlDto.getBatch());
waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
@@ -978,7 +1038,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("璇ヨ鍗曞凡澶勭悊");
}
@@ -986,13 +1046,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()));
@@ -1001,13 +1061,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){
+ if (outQty <= 0) {
break;
}
// 鍒ゆ柇鍏ュ嚭搴撶被鍨嬶細101.鍏ㄦ澘鍑哄簱 or 103.鎷f枡鍑哄簱
@@ -1022,19 +1082,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);
}
@@ -1067,8 +1127,8 @@
wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬�
wrkMast.setIoPri(13D); // 浼樺厛绾э細13
wrkMast.setCrnNo(locMast.getCrnNo());
- wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
- wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
+ wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
+ wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
wrkMast.setSourceLocNo(locDetl.getLocNo()); // 婧愬簱浣�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
wrkMast.setPicking("N"); // 鎷f枡
@@ -1111,4 +1171,262 @@
throw new CoolException(locDetl.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
}
}
+
+ /**
+ * @author Ryan
+ * @date 2025/9/22
+ * @description: 鑾峰彇缂撳啿鍖哄簱浣嶄俊鎭�
+ * @version 1.0
+ */
+ @Override
+ public R getCacheLocs() {
+ return R.ok().add(locCacheService.selectList(new EntityWrapper<LocCache>()
+ .eq("frozen", 0)
+ .ne("full_plt", "Y")
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type).orderAsc(Arrays.asList("row1"))));
+
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/22
+ * @description: 鍛煎彨AGV鎼繍
+ * @version 1.0
+ */
+ @Override
+ public R callAgvMove(AgvCallParams params, Long userId) {
+ if (Objects.isNull(params.getTarSite())) {
+ throw new CoolException("鐩爣鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ if (Objects.isNull(params.getOrgSite())) {
+ throw new CoolException("婧愮珯鐐逛笉鑳戒负绌猴紒锛�");
+ }
+ LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>()
+ .eq("frozen", 0)
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+ .eq("loc_no", params.getTarSite())
+ .orderAsc(Arrays.asList("loc_no"))
+ .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+ if (Objects.isNull(locCache)) {
+ throw new CoolException("璇锋鏌ョ洰鏍囧簱浣嶆槸鍚﹂棽缃腑锛侊紒");
+ }
+
+ generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId);
+
+ return R.ok();
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/24
+ * @description: 鑾峰彇璁㈠崟鐗╂枡淇℃伅
+ * @version 1.0
+ */
+ @Override
+ public R getMatsByQRcode(PakinMatsByQRParams params) {
+ if (Objects.isNull(params)) {
+ throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ if (Objects.isNull(params.getOrderNo())) {
+ throw new CoolException("鍗曞彿涓嶈兘涓虹┖锛侊紒");
+ }
+ OrderPakin orderPakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", params.getOrderNo()));
+ if (Objects.isNull(orderPakin)) {
+ throw new CoolException("鏁版嵁閿欒锛氬崟鎹笉瀛樺湪锛侊紒");
+ }
+ List<OrderDetlPakin> detlPakins = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>()
+ .eq(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr())
+ .eq("order_id", orderPakin.getId()));
+ if (Objects.isNull(detlPakins) || detlPakins.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒锛� 鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ return R.ok().add(detlPakins);
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/24
+ * @description: AGV鍛煎彨鎼繍
+ * @version 1.0
+ */
+ @Override
+ public R OutCallAgv(AgvCallParams params, Long userId) {
+ LocCache locCaches = locCacheService.selectOne(new EntityWrapper<LocCache>()
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_F.type)
+ .eq("frozen", 0)
+ .orderDesc(Arrays.asList("sort", "first_time"))
+ .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+ if (Objects.isNull(locCaches)) {
+ throw new CoolException("鏆傛棤婊¤冻闇�姹傚簱浣嶏紒");
+ }
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+ .eq("dev_no", params.getTarSite()));
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣姝e湪鎵ц浠诲姟锛侊紒");
+ }
+
+ generateOutTask(station, locCaches, userId);
+
+ return R.ok();
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/25
+ * @description: 鍛煎彨AGV鐢熸垚鍑哄簱浠诲姟
+ * @version 1.0
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void generateOutTask(BasStation station, LocCache loc, Long userId) {
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+ // 淇濆瓨宸ヤ綔妗�
+ Task task = new Task();
+ task.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setWrkSts(11L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setIoType(101) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ .setTaskType("agv")
+ .setIoPri(10D)
+ .setFullPlt("Y") // 婊℃澘锛歒
+ .setPicking("N") // 鎷f枡
+ .setExitMk("N")// 閫�鍑�
+ .setStaNo(station.getDevNo())
+ .setSourceLocNo(loc.getLocNo())
+ .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 绌烘澘
+ .setBarcode(loc.getBarcode())// 鎵樼洏鐮�
+ .setLinkMis("N")
+ .setAppeUser(userId)
+ .setAppeTime(new Date())
+ .setModiUser(userId)
+ .setModiTime(new Date());
+ if (!taskService.insert(task)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+ List<LocDetl> detls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_id", loc.getId()));
+ if (Objects.isNull(detls) || detls.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒锛氬簱浣嶆槑缁嗕负绌猴紒锛�");
+ }
+ List<TaskDetl> taskDetls = new ArrayList<>();
+ detls.forEach(pakin -> {
+ TaskDetl wrkDetl = new TaskDetl();
+ BeanUtils.copyProperties(pakin, wrkDetl);
+ wrkDetl.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setOrderNo(pakin.getOrderNo())
+ .setAnfme(pakin.getAnfme())
+ .setZpallet(pakin.getZpallet())
+ .setBatch(pakin.getBatch())
+ .setMatnr(pakin.getMatnr())
+ .setMaktx(pakin.getMaktx())
+ .setAppeUser(userId)
+ .setUnit(pakin.getUnit())
+ .setModel(pakin.getModel())
+ .setAppeTime(new Date())
+ .setModiUser(userId);
+ taskDetls.add(wrkDetl);
+ });
+
+ //淇濆瓨宸ヤ綔妗f槑缁�
+ if (!taskDetlService.insertBatch(taskDetls)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+
+ loc.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
+ loc.setModiUser(userId);
+ loc.setModiTime(new Date());
+
+ if (!locCacheService.updateById(loc)) {
+ throw new CoolException("鏇存柊搴撲綅鐘舵�佷俊鎭紒锛�");
+ }
+
+ // 淇敼鐩爣绔欑偣淇℃伅
+ if (station.getLocSts().equals("O")) {
+ station.setLocSts("S"); // S.鍏ュ簱棰勭害
+ station.setModiTime(new Date());
+ station.setModiUser(userId);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+ }
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/22
+ * @description: 鐢熸垚AGV鎼繍浠诲姟
+ * @version 1.0
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
+ List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+ if (Objects.isNull(pakins) || pakins.isEmpty()) {
+ throw new CoolException("缁勬墭淇℃伅涓嶅瓨鍦紒锛�");
+ }
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+ // 淇濆瓨宸ヤ綔妗�
+ Task task = new Task();
+ task.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setWrkSts(1L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ .setTaskType("agv")
+ .setIoPri(10D)
+ .setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
+ .setFullPlt("Y") // 婊℃澘锛歒
+ .setPicking("N") // 鎷f枡
+ .setExitMk("N")// 閫�鍑�
+ .setSourceStaNo(orgSite)
+ .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 绌烘澘
+ .setBarcode(barcode)// 鎵樼洏鐮�
+ .setLinkMis("N")
+ .setAppeUser(userId)
+ .setAppeTime(new Date())
+ .setModiUser(userId)
+ .setModiTime(new Date());
+ if (!taskService.insert(task)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+
+ List<TaskDetl> taskDetls = new ArrayList<>();
+ pakins.forEach(pakin -> {
+ TaskDetl wrkDetl = new TaskDetl();
+ BeanUtils.copyProperties(pakin, wrkDetl);
+ wrkDetl.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setOrderNo(pakin.getOrderNo())
+ .setAnfme(pakin.getAnfme())
+ .setZpallet(pakin.getZpallet())
+ .setBatch(pakin.getBatch())
+ .setMatnr(pakin.getMatnr())
+ .setMaktx(pakin.getMaktx())
+ .setAppeUser(userId)
+ .setUnit(pakin.getUnit())
+ .setModel(pakin.getModel())
+ .setAppeTime(new Date())
+ .setModiUser(userId);
+ taskDetls.add(wrkDetl);
+ });
+
+ //淇濆瓨宸ヤ綔妗f槑缁�
+ if (!taskDetlService.insertBatch(taskDetls)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+ // 淇敼鐩爣搴撲綅鐘舵��
+ if (loc.getLocSts().equals("O")) {
+ loc.setLocSts("S"); // S.鍏ュ簱棰勭害
+ loc.setModiTime(new Date());
+ loc.setModiUser(userId);
+ if (!locCacheService.updateById(loc)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
+ }
+ }
}
--
Gitblit v1.9.1