From ab14726215678ac69adfeafbd845ebc5b0776ea2 Mon Sep 17 00:00:00 2001
From: zhangc <zc@123>
Date: 星期二, 14 一月 2025 14:56:41 +0800
Subject: [PATCH] 优化订单同步逻辑及库位查找
---
src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java | 273 ++++++++++++++++++++++++++++++-----------------------
1 files changed, 154 insertions(+), 119 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
index cee1f4d..46ced6e 100644
--- a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
@@ -1,10 +1,8 @@
package com.zy.asrs.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
-import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
@@ -22,6 +20,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Optional;
import java.util.stream.Collectors;
/**
@@ -69,10 +68,10 @@
if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
throw new CoolException(BaseRes.PARAM);
}
- if (!CodeDetectionUtil.barcodeDetection(param.getBarcode())){
+ if (!CodeDetectionUtil.barcodeDetection(param.getBarcode())) {
throw new CoolException(param.getBarcode() + "璐ф灦鐮佹湁璇紝璇锋纭壂鐮侊紒锛侊紒");
}
- param.setContainerType(Short.valueOf(param.getBarcode().substring(0,2)));
+ param.setContainerType(Short.valueOf(param.getBarcode().substring(0, 2)));
// //妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鐨勮揣鏋舵潯鐮侊紝瀛樺湪鍒欐姏鍑哄紓甯�
// if (agvWaitPakinService.selectCount(new EntityWrapper<AgvWaitPakin>().eq("supp_code", param.getBarcode())) > 0) {
@@ -80,32 +79,32 @@
// }
//妫�鏌ュ簱瀛樻槸鍚︽湁鐩稿悓璐ф灦锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
- if(!Cools.isEmpty(agvLocDetlService.selectOne(new EntityWrapper<AgvLocDetl>().eq("supp_code",param.getBarcode())))){
+ if (!Cools.isEmpty(agvLocDetlService.selectOne(new EntityWrapper<AgvLocDetl>().eq("supp_code", param.getBarcode())))) {
throw new CoolException(param.getBarcode() + "璐ф灦鐮佸凡瀛樺湪AGV搴撳瓨鏄庣粏涓�");
}
//妫�鏌ュ簱瀛樻槸鍚︽湁鐩稿悓璐ф灦锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
- if(!Cools.isEmpty(agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("barcode",param.getBarcode())))){
+ if (!Cools.isEmpty(agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("barcode", param.getBarcode())))) {
throw new CoolException(param.getBarcode() + "璐ф灦鐮佸凡瀛樺湪AGV搴撳瓨涓绘。涓�");
}
//鏌ョ湅宸ヤ綔妗f槸鍚︽湁鐩稿悓璐ф灦锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
- if(!Cools.isEmpty(agvWrkMastService.selectByContainerCode(param.getBarcode()))){
+ if (!Cools.isEmpty(agvWrkMastService.selectByContainerCode(param.getBarcode()))) {
throw new CoolException(param.getBarcode() + "璐ф灦鐮佸凡瀛樺湪AGV宸ヤ綔妗d腑");
}
if (Cools.isEmpty(param.getOrderNo())) {
//鏃犲崟缁勬墭
- NoOrderComb(param,userId);
- }else {
+ NoOrderComb(param, userId);
+ } else {
//鏈夊崟缁勬墭
- OrderComb(param,userId);
+ OrderComb(param, userId);
}
- if(StringUtils.isEmpty(param.getLocno())){
+ if (StringUtils.isEmpty(param.getLocno())) {
return "缁勬墭鎴愬姛";
- }else {
- combBinding(param.getBarcode(),param.getLocno(),param.getContainerType());
+ } else {
+ combBinding(param.getBarcode(), param.getLocno(), param.getContainerType());
return "缁勬墭鎴愬姛锛岀粦瀹氱珯鐐规垚鍔�";
}
@@ -116,53 +115,64 @@
*/
@Override
@Transactional
- public String pickAgain(PickParam pickParams, Long userId) {
+ public synchronized String pickAgain(PickParam pickParams, Long userId) {
Date now = new Date();
List<AgvLocDetl> agvLocDetls = agvLocDetlService.selectList(new EntityWrapper<AgvLocDetl>().eq("loc_no", pickParams.getLocNo()));
AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("wrk_no", pickParams.getWrkNo()));
- if (Cools.isEmpty(agvWrkMast)){
- return "澶辫触锛屾湭鏌ュ埌宸ヤ綔涓绘。锛屽伐浣滃彿锛�"+pickParams.getWrkNo();
+ if (Cools.isEmpty(agvWrkMast)) {
+ return "澶辫触锛屾湭鏌ュ埌宸ヤ綔涓绘。锛屽伐浣滃彿锛�" + pickParams.getWrkNo();
}
for (PickParam.Pick pick : pickParams.getPicks()) {
if (pick.getCount().equals(0D)) continue;
+
Double count = 0.0D;
- AgvWrkDetl agvWrkDetl = agvWrkDetlService.selectOne(new EntityWrapper<AgvWrkDetl>().eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode()).eq("supp_code",pick.getSuppCode()));
+ AgvWrkDetl agvWrkDetl = agvWrkDetlService.selectOne(new EntityWrapper<AgvWrkDetl>().eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode()).eq("supp_code", pick.getSuppCode()));
if (Cools.isEmpty(agvWrkDetl)) {
- AgvWrkDetl wrkDetl = new AgvWrkDetl();
+ agvWrkDetl = new AgvWrkDetl();
Mat mat = matService.selectByMatnr(pick.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(pick.getMatnr() + "鍟嗗搧涓嶅瓨鍦�");
}
- wrkDetl.sync(mat);
- wrkDetl.setWrkNo(pickParams.getWrkNo());
- wrkDetl.setOrderNo(pick.getOrderNo());
- wrkDetl.setIoTime(agvWrkMast.getIoTime());
- wrkDetl.setAnfme(pick.getCount()); // 鏁伴噺
- wrkDetl.setSuppCode(pick.getSuppCode()); // 璐ф灦鏉$爜
- wrkDetl.setAppeUser(userId);
- wrkDetl.setAppeTime(now);
- wrkDetl.setModiUser(userId);
- wrkDetl.setModiTime(now);
- wrkDetl.setThreeCode(pick.getThreeCode());
- agvWrkDetlService.insert(wrkDetl);
+ agvWrkDetl.sync(mat);
+ agvWrkDetl.setWrkNo(pickParams.getWrkNo());
+ agvWrkDetl.setOrderNo(pick.getOrderNo());
+ agvWrkDetl.setIoTime(agvWrkMast.getIoTime());
+ agvWrkDetl.setAnfme(pick.getCount()); // 鏁伴噺
+ agvWrkDetl.setSuppCode(pick.getSuppCode()); // 璐ф灦鏉$爜
+ agvWrkDetl.setAppeUser(userId);
+ agvWrkDetl.setAppeTime(now);
+ agvWrkDetl.setModiUser(userId);
+ agvWrkDetl.setModiTime(now);
+ agvWrkDetl.setThreeCode(pick.getThreeCode());
+ agvWrkDetlService.insert(agvWrkDetl);
} else {
Double anfme = agvWrkDetl.getAnfme() + pick.getCount();
agvWrkDetl.setIoTime(agvWrkMast.getIoTime());
agvWrkDetl.setAnfme(anfme);
agvWrkDetl.setModiTime(now);
- agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>().eq("matnr",agvWrkDetl.getMatnr()).eq("three_code",agvWrkDetl.getThreeCode()).eq("supp_code",pick.getSuppCode()));
+ agvWrkDetlService.update(agvWrkDetl, new EntityWrapper<AgvWrkDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code", agvWrkDetl.getThreeCode()).eq("supp_code", pick.getSuppCode()));
}
-
+ // 搴撳瓨鏍¢獙
+ Optional<AgvLocDetl> first = agvLocDetls.stream().filter(agvLocDetl -> agvLocDetl.getThreeCode().equals(pick.getThreeCode()))
+ .filter(agvLocDetl -> agvLocDetl.getMatnr().equals(pick.getMatnr())).findFirst();
+ if (first.isPresent()) {
+ AgvLocDetl agvLocDetl = first.get();
+ if (agvLocDetl.getAnfme() < agvWrkDetl.getAnfme()) {
+ throw new CoolException("鎷f枡鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺");
+ }
+ } else {
+ throw new CoolException("鎷f枡鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺,瀛樺簱涓嶅瓨鍦�");
+ }
// 鏇存柊璁㈠崟
- OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code",pick.getThreeCode()));
+ OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode()));
orderDetl.setQty(orderDetl.getQty() + pick.getCount());
- if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code",pick.getThreeCode()))){
- throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�"+pick.getOrderNo()+pick.getMatnr());
+ if (!orderDetlService.update(orderDetl, new EntityWrapper<OrderDetl>().eq("order_no", pick.getOrderNo()).eq("matnr", pick.getMatnr()).eq("three_code", pick.getThreeCode()))) {
+ throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�" + pick.getOrderNo() + pick.getMatnr());
}
Order order = orderService.selectByNo(orderDetl.getOrderNo());
if (order.getSettle() == 1) {
@@ -183,7 +193,7 @@
}
if (totleWrkdetl >= totleLocdetl) {
agvWrkMast.setIoType(101);
- agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no", pickParams.getWrkNo()));
+ agvWrkMastService.update(agvWrkMast, new EntityWrapper<AgvWrkMast>().eq("wrk_no", pickParams.getWrkNo()));
}
// agvLocDetls.size() == 1
@@ -195,25 +205,24 @@
/*
AGV鏃犲崟缁勬墭
*/
- private void NoOrderComb(CombParam param, Long userId){
- List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,null);
+ private void NoOrderComb(CombParam param, Long userId) {
+ List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param, null);
//鐢ㄤ簬缁熶竴涓�涓揣鏋朵笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
Date now = new Date();
detlDtos.forEach(detlDto -> {
- syncWaitPakin(detlDto,"",param.getBarcode(),userId,now);
+ syncWaitPakin(detlDto, "", param.getBarcode(), userId, now);
});
}
-
/*
AGV鏈夊崟缁勬墭
*/
- private void OrderComb(CombParam param, Long userId){
+ private void OrderComb(CombParam param, Long userId) {
//鍏宠仈缁勬墭
Order order = orderService.selectByNo(param.getOrderNo());
- if(Cools.isEmpty(order)){
+ if (Cools.isEmpty(order)) {
throw new CoolException("鍗曟嵁缂栧彿涓嶅瓨鍦�");
}
//璁㈠崟鐘舵��2浠ヤ笂涓哄畬鎴愭垨鑰呭彇娑堢殑璁㈠崟
@@ -221,12 +230,12 @@
throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
}
// 鐢ㄤ簬鐢熸垚鍏ュ簱閫氱煡妗f墍闇�鍙傛暟
- List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,order);
+ List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param, order);
//鐢ㄤ簬缁熶竴涓�涓揣鏋朵笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
Date now = new Date();
for (DetlDto detlDto : detlDtos) {
//鍚屾鐢熸垚鍏ュ簱閫氱煡妗�
- syncWaitPakin(detlDto,order.getOrderNo(),param.getBarcode(),userId,now);
+ syncWaitPakin(detlDto, order.getOrderNo(), param.getBarcode(), userId, now);
}
//淇敼鍗曟嵁鐘舵�佷负2.浣滀笟涓�
orderService.updateSettle(order.getId(), 2L, userId);
@@ -235,19 +244,19 @@
/*
鏍规嵁PDA鎵爜鎵�浼犵殑鐗╂枡淇℃伅鍙傛暟鏄犲皠涓篋etlDto
*/
- private List<DetlDto> mappingDetlDtoByCombMat(CombParam param, Order order){
+ private List<DetlDto> mappingDetlDtoByCombMat(CombParam param, Order order) {
List<DetlDto> detlDtos = new ArrayList<>();
param.getCombMats().forEach(combMat -> {
- if(!Cools.isEmpty(order)){
+ if (!Cools.isEmpty(order)) {
//妫�鏌ュ叆搴撴暟閲�
- checkOrderQty(order,combMat);
+ checkOrderQty(order, combMat);
}
- DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode(),param.getLocType(),combMat.getProcessSts());
+ DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(), combMat.getContainerCode(), param.getLocType(), combMat.getProcessSts());
//鍚屼竴璐ф灦涓嬬浉鍚岀墿鏂欎俊鎭拰鎵瑰彿杞负涓�涓叆搴撻�氱煡妗�
if (DetlDto.has(detlDtos, detlDto)) {
- DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(),detlDto.getContainerCode());
+ DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(), detlDto.getContainerCode());
assert one != null;
one.setAnfme(one.getAnfme() + detlDto.getAnfme());
} else {
@@ -261,17 +270,17 @@
/*
妫�鏌ュ叆搴撴暟閲忔槸鍚﹀皬浜庣瓑浜庡崟鎹暟閲忥紝鍚堢悊鍒欎慨鏀筄rderDetl浣滀笟鏁伴噺淇℃伅锛屽惁鍒欐姏鍑哄紓甯�
*/
- private void checkOrderQty(Order order, CombParam.CombMat combMat){
+ private void checkOrderQty(Order order, CombParam.CombMat combMat) {
// 璁㈠崟鏄庣粏鏁伴噺鏍¢獙锛屽鏋滀綔涓氭暟閲忓ぇ浜庡崟鎹暟閲忓垯鎶涘嚭寮傚父
- OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getCsocode(),combMat.getIsoseq());
- if(Cools.isEmpty(orderDetl)){
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getCsocode(), combMat.getIsoseq());
+ if (Cools.isEmpty(orderDetl)) {
throw new CoolException("鏈尮閰嶅埌璇ュ崟鎹笅鐨勭墿鏂�");
}
if (combMat.getAnfme() > orderDetl.getEnableQty()) {
throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
}
// 淇敼璁㈠崟鏄庣粏鏁伴噺
- if (!orderDetlService.increase(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(),combMat.getIsoseq())) {
+ if (!orderDetlService.increase(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq())) {
throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触");
}
}
@@ -279,13 +288,18 @@
/*
鍚屾鐢熸垚AGV鍏ュ簱閫氱煡妗f暟鎹�
*/
- private void syncWaitPakin(DetlDto detlDto, String orderNo, String zpallet, Long userId, Date now ){
+ private void syncWaitPakin(DetlDto detlDto, String orderNo, String zpallet, Long userId, Date now) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
+ OrderDetl orderDetl = orderDetlService.selectItem(orderNo, mat.getMatnr(), detlDto.getBatch(), detlDto.getCsocode());
AgvWaitPakin waitPakin = new AgvWaitPakin();
waitPakin.sync(mat);
+ if (orderDetl != null) {
+ waitPakin.setWeight(orderDetl.getWeight());
+ waitPakin.setVolume(orderDetl.getVolume());
+ }
waitPakin.setOrderNo(orderNo); // 鍗曟嵁缂栧彿
waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮�
//waitPakin.setZpallet(zpallet); // 璐ф灦鐮�
@@ -331,40 +345,40 @@
AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode));
- if(Cools.eq(agvBasDevp.getBarcode(),barcode)){
+ if (Cools.eq(agvBasDevp.getBarcode(), barcode)) {
return;
}
- if(Cools.isEmpty(agvWaitPakinService.selectByContainerCode(barcode))){
+ if (Cools.isEmpty(agvWaitPakinService.selectByContainerCode(barcode))) {
throw new CoolException("璇ヨ揣鏋舵湭缁勬墭锛屾棤娉曠粦瀹氱珯鐐�");
}
AgvBasDevp agvBasDevp1 = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("barcode", barcode));
- if(!Cools.isEmpty(agvBasDevp1)){
- throw new CoolException(barcode + "宸茬粡缁戝畾鍦�"+ agvBasDevp.getDevNo() +"绔欑偣");
+ if (!Cools.isEmpty(agvBasDevp1)) {
+ throw new CoolException(barcode + "宸茬粡缁戝畾鍦�" + agvBasDevp.getDevNo() + "绔欑偣");
}
- if(agvBasDevp == null){
+ if (agvBasDevp == null) {
throw new CoolException(stationCode + "绔欑偣淇℃伅閿欒");
}
- if(!"O".equals(agvBasDevp.getLocSts())){
+ if (!"O".equals(agvBasDevp.getLocSts())) {
throw new CoolException(stationCode + "璇ョ珯鐐硅揣浣嶇姸鎬侀潪绌�");
}
AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", agvBasDevp.getDevNo()));
- if(!Cools.isEmpty(agvWrkMast)){
+ if (!Cools.isEmpty(agvWrkMast)) {
throw new CoolException(stationCode + "璇ョ珯鐐瑰凡琚伐浣滃彿涓�" + agvWrkMast.getWrkNo() + "鍗犵敤锛屾棤娉曠粦瀹�");
}
agvBasDevp.setBarcode(barcode);
agvBasDevp.setLocSts("F");
agvBasDevp.setLocType2(containerType);
- agvBasDevpService.update(agvBasDevp,(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode)));
+ agvBasDevpService.update(agvBasDevp, (new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode)));
}
public List<AgvBasDevp> getAgvBasDevpByFloor(int floor) {
EntityWrapper<AgvBasDevp> wrapper = new EntityWrapper<>();
- wrapper.eq("floor",floor).eq("cache_shelves","Y").eq("loc_sts","F");
+ wrapper.eq("floor", floor).eq("cache_shelves", "Y").eq("loc_sts", "F");
List<AgvBasDevp> agvBasDevpList = agvBasDevpService.selectList(wrapper);
return agvBasDevpList.stream().filter(agvBasDevp -> {
return !Cools.isEmpty(agvWaitPakinService.selectByContainerCode(agvBasDevp.getBarcode()));
@@ -394,7 +408,7 @@
@Transactional
public String handControlLocMove(LocMoveParam param, Long userId) {
String fl = String.valueOf(param.getFloor());
- short floor =(short)Integer.parseInt(fl.substring(0, 1));
+ short floor = (short) Integer.parseInt(fl.substring(0, 1));
switch (param.getFloor()) {
case "1F01":
floor = 1;
@@ -428,7 +442,7 @@
if (agvLocMast.getFloor() != floor) {
if (agvLocMast.getFloor() == 1 && (floor == 2 || floor == 3)) {
throw new CoolException("褰撳墠搴撲綅璇烽�夋嫨璋冩嫧鍗曡皟鎷紒");
- } else if ((agvLocMast.getFloor() == 2 || agvLocMast.getFloor() == 3) && (floor == 1 || floor == 4)) {
+ } else if ((agvLocMast.getFloor() == 2 || agvLocMast.getFloor() == 3) && (floor == 1 || floor == 4)) {
throw new CoolException("褰撳墠搴撲綅璇烽�夋嫨璋冩嫧鍥炴祦鍗曞洖閫�锛�");
} else {
ioType = 12;
@@ -448,15 +462,15 @@
Date now = new Date();
//鏌ヨ宸ヤ綔妗�
AgvWrkMast agvWrkMast = agvWrkMastService.selectByContainerCode(agvLocMast.getBarcode());
- if(!Cools.isEmpty(agvWrkMast)){
- throw new CoolException("褰撳墠"+agvLocMast.getBarcode()+"璐ф灦鐮佸凡鍦ㄥ伐浣滄。涓�");
+ if (!Cools.isEmpty(agvWrkMast)) {
+ throw new CoolException("褰撳墠" + agvLocMast.getBarcode() + "璐ф灦鐮佸凡鍦ㄥ伐浣滄。涓�");
}
//妫�绱㈠簱浣嶏紝閫夋嫨鍚堥�傜殑搴撲綅
AgvLocMast locMast = null;
if (floor == 1) {
- locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(),floor,true,false);
+ locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(), floor, true, false);
} else {
- locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(),floor,false,false);
+ locMast = agvCommonService.getLocNo(agvLocMast.getLocType1(), floor, false, false);
}
// 鐩爣妤煎眰鍘� 鍚稿2妤�
@@ -473,9 +487,9 @@
//鐢熸垚宸ヤ綔妗�
AgvWrkMast mast = new AgvWrkMast();
//宸ヤ綔鐘舵��
- if (ioType==121) {
+ if (ioType == 121) {
mast.setWrkSts(11L);
- }else {
+ } else {
mast.setWrkSts(201L);
}
//鍏ュ嚭搴撶被鍨�
@@ -501,7 +515,7 @@
throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
}
if (agvLocMast.getLocSts().equals("F")) {
- AgvWrkMast mast1 = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", locMast.getLocNo()).eq("source_loc_no",agvLocMast.getLocNo()));
+ AgvWrkMast mast1 = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", locMast.getLocNo()).eq("source_loc_no", agvLocMast.getLocNo()));
//鐢熸垚宸ヤ綔妗f槑缁�
List<AgvLocDetl> agvLocDetls = agvLocDetlService.selectList(new EntityWrapper<AgvLocDetl>().eq("loc_no", agvLocMast.getLocNo()));
agvLocDetls.forEach(agvLocDetl -> {
@@ -544,8 +558,8 @@
// }
// }
//鏇存柊鐩爣搴撲綅鐘舵��
- updateAgvLocMast(agvLocMast,"P");
- updateAgvLocMast(locMast,"Q");
+ updateAgvLocMast(agvLocMast, "P");
+ updateAgvLocMast(locMast, "Q");
return "ok";
}
@@ -557,7 +571,7 @@
@Synchronized
public String allocationOut(AgvMobileStartPakin param, Long userId) {
Date now = new Date();
- if(Cools.isEmpty(param.getBarcode())) {
+ if (Cools.isEmpty(param.getBarcode())) {
throw new CoolException("璇疯緭鍏ヨ揣鏋剁爜");
}
AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", param.getDevNo()));
@@ -569,26 +583,26 @@
throw new CoolException("褰撳墠璐ф灦鐮佷笌浠诲姟涓嶅尮閰�");
}
if (!agvWrkMast.getWrkSts().equals(207L) && !agvWrkMast.getWrkSts().equals(205L)) {
- throw new CoolException("褰撳墠宸ヤ綔鐘舵��:" + agvWrkMast.getWrkSts$() +"涓嶇鍚堢鍦烘潯浠�");
+ throw new CoolException("褰撳墠宸ヤ綔鐘舵��:" + agvWrkMast.getWrkSts$() + "涓嶇鍚堢鍦烘潯浠�");
}
if (agvWrkMast.getWrkSts().equals(205L)) {
// 搴撲綅 -- 鎺ラ┏浣� / 搴撲綅
- if (agvWrkMast.getLocNo().substring(0,2).equals("DB")) {
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"F",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ if (agvWrkMast.getLocNo().substring(0, 2).equals("DB")) {
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(), "F", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue());
// 鎺ラ┏浣� -- 搴撲綅
} else {
- agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(),"D",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ agvLocMastService.updateLocStsByLocNo(agvWrkMast.getLocNo(), "D", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue());
}
// 鎺ラ┏浣� -- 搴撲綅
- if (agvWrkMast.getSourceLocNo().substring(0,2).equals("DB")) {
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(),"O","",(short)0);
+ if (agvWrkMast.getSourceLocNo().substring(0, 2).equals("DB")) {
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getSourceLocNo(), "O", "", (short) 0);
// 搴撲綅 -- 鎺ラ┏浣� / 搴撲綅
} else {
//淇敼婧愬簱浣嶇姸鎬佷负O
- agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",agvWrkMast.getWhsType().shortValue(),"",(short)0);
+ agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(), "O", "", agvWrkMast.getWhsType().shortValue(), "", (short) 0);
//鏇存柊鐩爣搴撲綅鏄庣粏 101.鍑哄簱 鍒犻櫎婧愬簱浣嶅簱瀛樻槑缁�
- agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",agvWrkMast.getSourceLocNo()));
+ agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no", agvWrkMast.getSourceLocNo()));
}
}
@@ -615,12 +629,13 @@
// 鏇存柊绔欑偣鐘舵��
// agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",null);
// 鏇存柊婧愬簱浣嶇姸鎬�
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"O","",agvWrkMast.getWhsType().shortValue());
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(), "O", "", agvWrkMast.getWhsType().shortValue());
//鍒犻櫎AGV宸ヤ綔鏄庣粏妗�
- agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",oldWrkNo));
+ agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no", oldWrkNo));
return "ok";
}
+
/*
璋冩嫧杩涘満
*/
@@ -645,7 +660,7 @@
if (agvWrkMast.getCrnNo() != agvBasDevp.getFloor()) {
throw new CoolException("璇风Щ鍔ㄥ埌->" + agvWrkMast.getCrnNo() + "妤煎叆搴撶偣鍏ュ簱");
}
- AgvLocMast locNo = agvCommonService.getLocNo(3, 1,false,true);
+ AgvLocMast locNo = agvCommonService.getLocNo(3, 1, false, true);
//宸ヤ綔鐘舵��
agvWrkMast.setWrkSts(211L);
//鍏ュ嚭搴撶被鍨�
@@ -653,16 +668,17 @@
agvWrkMast.setSourceLocNo(param.getDevNo());
agvWrkMast.setModiUser(userId);
agvWrkMast.setModiTime(now);
- if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
+ if (!agvWrkMastService.update(agvWrkMast, new EntityWrapper<AgvWrkMast>().eq("wrk_no", agvWrkMast.getWrkNo()))) {
throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
}
//
- agvLocMastService.updateLocStsByLocNo(locNo.getLocNo(),"S",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ agvLocMastService.updateLocStsByLocNo(locNo.getLocNo(), "S", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue());
// 鏇存柊婧愬簱浣嶇姸鎬�
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"R",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(), "R", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue());
//鍒犻櫎AGV宸ヤ綔妗�
return "ok";
}
+
/*
绌烘灦绂诲満
*/
@@ -685,13 +701,14 @@
agvWrkMast.setModiTime(new Date());
agvWrkMast.setWrkSts(213L);
agvWrkMast.setSourceLocNo("");
- if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
+ if (!agvWrkMastService.update(agvWrkMast, new EntityWrapper<AgvWrkMast>().eq("wrk_no", agvWrkMast.getWrkNo()))) {
throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
}
// 鏇存柊婧愬簱浣嶇姸鎬�
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"O","",agvWrkMast.getWhsType().shortValue());
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(), "O", "", agvWrkMast.getWhsType().shortValue());
return "ok";
}
+
/*
绌烘灦杩涘満
*/
@@ -713,16 +730,17 @@
agvWrkMast.setWrkSts(214L);
agvWrkMast.setModiTime(new Date());
agvWrkMast.setSourceLocNo(param.getDevNo());
- if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
+ if (!agvWrkMastService.update(agvWrkMast, new EntityWrapper<AgvWrkMast>().eq("wrk_no", agvWrkMast.getWrkNo()))) {
throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
}
// 鏇存柊婧愬簱浣嶇姸鎬�
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"F",param.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(), "F", param.getBarcode(), agvWrkMast.getWhsType().shortValue());
return "ok";
}
+
/*
* 杞墜鍔ㄥ洖娴�
- */
+ */
@Override
@Transactional
public String handBack(AgvMobileStartPakin param, Long userId) {
@@ -731,7 +749,7 @@
agvWrkMast.setIoType(113);
agvWrkMast.setModiUser(userId);
agvWrkMast.setModiTime(now);
- if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
+ if (!agvWrkMastService.update(agvWrkMast, new EntityWrapper<AgvWrkMast>().eq("wrk_no", agvWrkMast.getWrkNo()))) {
throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
}
return "ok";
@@ -755,7 +773,7 @@
agvWrkMastLogService.save(agvWrkMast);
agvWrkDetlLogService.save(agvWrkMast.getWrkNo());
String sourceLocNo = agvWrkMast.getSourceLocNo();
- AgvLocMast newLocMast = agvCommonService.getLocNo(3, 1,false,false);
+ AgvLocMast newLocMast = agvCommonService.getLocNo(3, 1, false, false);
agvWrkMast.setSourceLocNo(agvWrkMast.getLocNo());
agvWrkMast.setLocNo(newLocMast.getLocNo());
agvWrkMast.setIoType(57);
@@ -765,18 +783,17 @@
agvWrkMast.setIoTime(now);
-
- if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
+ if (!agvWrkMastService.update(agvWrkMast, new EntityWrapper<AgvWrkMast>().eq("wrk_no", agvWrkMast.getWrkNo()))) {
throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
}
// 鏇存柊婧愮珯鐐� + 鐩爣搴撲綅鐘舵�� + 鍘嗗彶婧愬簱浣�
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"R",param.getBarcode(),agvWrkMast.getWhsType().shortValue());
- agvLocMastService.updateLocStsByLocNo(newLocMast.getLocNo(),"S",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
- agvLocMastService.updateLocStsByLocNo(sourceLocNo,"O","",(short)30);
- agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no",sourceLocNo));
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(), "R", param.getBarcode(), agvWrkMast.getWhsType().shortValue());
+ agvLocMastService.updateLocStsByLocNo(newLocMast.getLocNo(), "S", agvWrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue());
+ agvLocMastService.updateLocStsByLocNo(sourceLocNo, "O", "", (short) 30);
+ agvLocDetlService.delete(new EntityWrapper<AgvLocDetl>().eq("loc_no", sourceLocNo));
- List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code",param.getBarcode()));
+ List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", param.getBarcode()));
agvWrkDetls.forEach(agvWrkDetl -> {
for (AgvWrkDetl wrkDetl : param.getWrkDetls()) {
if (wrkDetl.getMatnr().equals(agvWrkDetl.getMatnr()) && wrkDetl.getThreeCode().equals(agvWrkDetl.getThreeCode())) {
@@ -789,16 +806,15 @@
agvWrkDetl.setModiUser(userId);
agvWrkDetl.setModiTime(now);
agvWrkDetl.setIoTime(now);
- if (!agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>()
- .eq("matnr",agvWrkDetl.getMatnr())
- .eq("three_code",agvWrkDetl.getThreeCode())
- .eq("supp_code",param.getBarcode()))) {
+ if (!agvWrkDetlService.update(agvWrkDetl, new EntityWrapper<AgvWrkDetl>()
+ .eq("matnr", agvWrkDetl.getMatnr())
+ .eq("three_code", agvWrkDetl.getThreeCode())
+ .eq("supp_code", param.getBarcode()))) {
throw new CoolException("鏇存柊宸ヤ綔鏄庣粏澶辫触");
}
});
return "ok";
}
-
/*
@@ -807,10 +823,10 @@
@Override
@Transactional
public String doBack(AgvMobileStartPakin param, Long userId) {
- if (Cools.isEmpty(param.getBarcode()) || !CodeDetectionUtil.barcodeDetection(param.getBarcode())){
+ if (Cools.isEmpty(param.getBarcode()) || !CodeDetectionUtil.barcodeDetection(param.getBarcode())) {
throw new CoolException(param.getBarcode() + "璐ф灦鐮佹湁璇紝璇锋纭壂鐮侊紒锛侊紒");
}
- if (Cools.isEmpty(param.getDevNo()) || !CodeDetectionUtil.carCodeDetection(param.getDevNo())){
+ if (Cools.isEmpty(param.getDevNo()) || !CodeDetectionUtil.carCodeDetection(param.getDevNo())) {
throw new CoolException(param.getDevNo() + "灏忚溅鍦扮爜鏈夎锛岃姝g‘鎵爜锛侊紒锛�");
}
Date now = new Date();
@@ -829,8 +845,8 @@
// 鏂板缓鍥為��宸ヤ綔妗�
AgvWrkMast wrkMast = createWrkMast(58, 201L, agvWrkMast.getLocNo(), agvWrkMast.getSourceLocNo(), agvWrkMast.getBarcode(), now, userId, agvWrkMast.getWhsType(), 0);
// 鏇存柊鎺ラ┏浣嶏紝鏇存柊搴撲綅鐘舵��
- agvLocMastService.updateLocStsByLocNo(wrkMast.getLocNo(),"S",wrkMast.getBarcode(),wrkMast.getWhsType().shortValue());
- agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getSourceLocNo(),"R",wrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ agvLocMastService.updateLocStsByLocNo(wrkMast.getLocNo(), "S", wrkMast.getBarcode(), wrkMast.getWhsType().shortValue());
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getSourceLocNo(), "R", wrkMast.getBarcode(), agvWrkMast.getWhsType().shortValue());
// 鏇存柊宸ヤ綔鏄庣粏
List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", agvWrkMast.getBarcode()));
for (AgvWrkDetl agvWrkDetl : agvWrkDetls) {
@@ -844,10 +860,28 @@
throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触");
}
// 鍚屾璁㈠崟鏁伴噺
- OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code",agvWrkDetl.getThreeCode()).eq("order_no",agvWrkDetl.getOrderNo()).in("source",18,31,34));
+ //OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code", agvWrkDetl.getThreeCode()).eq("order_no", agvWrkDetl.getOrderNo()).in("source", 18, 31, 34));
+ List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code", agvWrkDetl.getThreeCode()).eq("order_no", agvWrkDetl.getOrderNo()));
+ OrderDetl orderDetl = null;
+ if (orderDetls.isEmpty()) {
+ throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
+ } else if (orderDetls.size() > 1) {
+ for (OrderDetl detl : orderDetls) {
+ if (Cools.isEmpty(agvWrkDetl.getBatch()) && Cools.isEmpty(detl.getBatch())) {
+ orderDetl = detl;
+ } else if (!Cools.isEmpty(agvWrkDetl.getBatch()) && !Cools.isEmpty(detl.getBatch()) && agvWrkDetl.getBatch().equals(detl.getBatch())) {
+ orderDetl = detl;
+ }
+ }
+ if (orderDetl == null) {
+ throw new CoolException("璁㈠崟鏄庣粏涓嶅尮閰�");
+ }
+ } else {
+ orderDetl = orderDetls.get(0);
+ }
orderDetl.setQty(orderDetl.getQty() - agvWrkDetl.getAnfme());
- if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no",orderDetl.getOrderNo()).eq("matnr", orderDetl.getMatnr()).eq("three_code",orderDetl.getThreeCode()))){
- throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�"+orderDetl.getOrderNo()+orderDetl.getMatnr());
+ if (!orderDetlService.updateById(orderDetl)) {
+ throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�" + orderDetl.getOrderNo() + orderDetl.getMatnr());
}
}
@@ -857,13 +891,14 @@
//鍒犻櫎AGV宸ヤ綔妗�
agvWrkMastService.deleteById(agvWrkMast);
//鍒犻櫎AGV宸ヤ綔鏄庣粏妗�
- agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",oldWrkNo));
+ agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no", oldWrkNo));
return "ok";
}
+
/*
鏇存柊鐩爣搴撲綅淇℃伅
*/
- private void updateAgvLocMast(AgvLocMast locMast, String locSts){
+ private void updateAgvLocMast(AgvLocMast locMast, String locSts) {
locMast.setLocSts(locSts);
agvLocMastService.updateById(locMast);
}
@@ -871,7 +906,7 @@
/*
鐢熸垚宸ヤ綔妗�
*/
- private AgvWrkMast createWrkMast(int ioType, long wrkSts, String sourceLocNo, String locNo, String barcode, Date now, Long userId, int containerType,int floor){
+ private AgvWrkMast createWrkMast(int ioType, long wrkSts, String sourceLocNo, String locNo, String barcode, Date now, Long userId, int containerType, int floor) {
AgvWrkMast wrkMast = new AgvWrkMast();
//宸ヤ綔鐘舵��
wrkMast.setWrkSts(wrkSts);
@@ -900,7 +935,7 @@
throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
}
- wrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", locNo).eq("source_loc_no",sourceLocNo).eq("barcode",barcode).orderBy("modi_time",false));
+ wrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", locNo).eq("source_loc_no", sourceLocNo).eq("barcode", barcode).orderBy("modi_time", false));
return wrkMast;
}
--
Gitblit v1.9.1