From 3284076d954004eed648633eed9b8abed4f0b277 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期一, 13 二月 2023 16:16:04 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java | 260 ++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 213 insertions(+), 47 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
index 50f8bb7..0506530 100644
--- a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -13,29 +13,26 @@
import com.zy.asrs.entity.result.StockVo;
import com.zy.asrs.mapper.TagMapper;
import com.zy.asrs.service.*;
+import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.utils.MatUtils;
+import com.zy.asrs.utils.PostMesDataUtils;
import com.zy.common.model.DetlDto;
import com.zy.common.model.enums.WorkNoType;
+import com.zy.common.service.CommonService;
import com.zy.common.utils.NodeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.expression.spel.ast.NullLiteral;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-
-import javax.tools.JavaCompiler;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
/**
* Created by vincent on 2022/4/9
*/
@Slf4j
@Service
-public class OpenServiceImpl implements OpenService {
+public class OpenServiceImpl extends AbstractHandler<String> implements OpenService {
@Autowired
private OrderService orderService;
@@ -64,7 +61,14 @@
@Autowired
private LocMastService locMastService;
@Autowired
- private WorkService workService;
+ private CommonService commonService;
+ @Autowired
+ private WrkMastService wrkMastService;
+
+ @Value("${mes.inPath}")
+ private String inpath;
+ @Value("${mes.url}")
+ private String mesUrl;
@Override
@Transactional
@@ -565,6 +569,15 @@
@Override
@Transactional
public void combPACK(CombParam param) {
+ if (Cools.isEmpty(param.getPackNo())){
+ throw new CoolException("缂哄皯鍙傛暟锛歱ackNo");
+ }else if (Cools.isEmpty(param.getPackName())){
+ throw new CoolException("缂哄皯鍙傛暟锛歱ackName");
+ }else if (Cools.isEmpty(param.getSettingTimes())){
+ throw new CoolException("缂哄皯鍙傛暟锛歴ettingTimes");
+ }else if (Cools.isEmpty(param.getRequestTime())){
+ throw new CoolException("缂哄皯鍙傛暟锛歳equestTime");
+ }
if (Cools.isEmpty(param.getPackNo())) {
throw new CoolException(BaseRes.PARAM);
}
@@ -576,24 +589,31 @@
int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getPackNo()));
int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getPackNo()));
+ int countPakin = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getPackNo()));
if (countLoc > 0 || countWrk > 0) {
throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getPackNo());
+ }else if (countPakin>0){
+ throw new CoolException("閲嶅鐢宠" + param.getPackNo());
}
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- java.util.Date date1=null;
- try {
- date1= sdf.parse(param.getRequestTime());
- } catch (ParseException e) {
- e.printStackTrace();
- }
- java.sql.Date requestTime = new java.sql.Date(date1.getTime());
-
- // 鐢熸垚鍏ュ簱閫氱煡妗�
-// Mat mat = matService.selectByMatnr(param.getPackName());
-// if (Cools.isEmpty(mat)) {
+// 鐢熸垚鍏ュ簱閫氱煡妗�
+ Mat mat = matService.selectByMatnr(param.getPackName());
+ if (Cools.isEmpty(mat)) {
+ Tag tag = tagService.selectByName("鍏ㄩ儴", 1);
+ Mat matNew = new Mat();
+ matNew.setTagId(tag.getId());
+ matNew.setMatnr(param.getPackName());
+ matNew.setMaktx(param.getPackName());
+ matNew.setDeadWarn(param.getSettingTimes());
+ matNew.setCreateBy(9999L);//9999琛ㄧずerp涓嬪彂
+ matNew.setCreateTime(new Date());
+ matNew.setUpdateBy(9999L);//9999琛ㄧずerp涓嬪彂
+ matNew.setUpdateTime(new Date());
+ if (!matService.insert(matNew)){
+ throw new CoolException(param.getPackName() + "鍟嗗搧妗f鑷姩鐢熸垚澶辫触");
+ }
// throw new CoolException(param.getPackName() + "鍟嗗搧妗f涓嶅瓨鍦�");
-// }
+ }
WaitPakin waitPakin = new WaitPakin();
// waitPakin.sync(mat);
waitPakin.setMatnr(param.getPackName());
@@ -602,7 +622,7 @@
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
waitPakin.setAnfme(1.0); // 鏁伴噺
waitPakin.setStatus("Y"); // 鐘舵��
- waitPakin.setManuDate(requestTime.toString());
+ waitPakin.setManuDate(param.getRequestTime());
waitPakin.setAppeUser(null);
waitPakin.setAppeTime(new Date());
waitPakin.setModiUser(null);
@@ -612,10 +632,106 @@
throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
}
}
+ @Override
+ @Transactional
+ public void combPackOut(CombParam param) {
+ if (Cools.isEmpty(param.getPackNo())){
+ throw new CoolException("缂哄皯鍙傛暟锛歱ackNo");
+ }else if (Cools.isEmpty(param.getPackName())){
+ throw new CoolException("缂哄皯鍙傛暟锛歱ackName");
+ }else if (Cools.isEmpty(param.getSettingTimes())){
+ throw new CoolException("缂哄皯鍙傛暟锛歴ettingTimes");
+ }else if (Cools.isEmpty(param.getRequestTime())){
+ throw new CoolException("缂哄皯鍙傛暟锛歳equestTime");
+ }
+ if (Cools.isEmpty(param.getPackNo())) {
+ throw new CoolException(BaseRes.PARAM);
+ }
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+// .eq("fire_status", 0)
+// .eq("loc_sts", "F")
+ .eq("barcode", param.getPackNo()));
+ if (Cools.isEmpty(locMast)){
+ throw new CoolException("鏈煡璇㈠埌PACK鐮佷负锛�"+param.getPackNo()+"鐨勮揣鐗�");
+ }else if (!locMast.getLocSts().equals("F")){
+ throw new CoolException("PACK鐮佷负锛�"+param.getPackNo()+"鐨勮揣鐗╁簱浣嶇姸鎬佷笉鏄�淔鈥�");
+ }else if (locMast.getFireStatus()!=0){
+ throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒");
+ }else {
+ Date now = new Date();
+ Integer ioType = 101; //鍏ュ嚭搴撶被鍨�
+ LocDetl locDetl=locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no",locMast.getLocNo()));
+ if (Cools.isEmpty(locDetl)){
+ log.error("搴撲綅:"+locMast.getLocNo()+"娌℃湁鏄庣粏");
+// } else if (Cools.isEmpty(locDetl.getDeadWarn())){
+// log.error("搴撲綅:"+locMast.getLocNo()+"娌℃湁闈欑疆鏃堕棿");
+// } else if (Cools.isEmpty(locMast.getModiTime())){
+// log.error("搴撲綅:"+locMast.getLocNo()+"modiTime涓虹┖");
+ } else if (Cools.isEmpty(locMast.getBarcode())){
+ log.error("搴撲綅:"+locMast.getLocNo()+"Pack鐮佷负绌�");
+ } else {
+ // 鐢熸垚宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType));
+ // 鐢熸垚宸ヤ綔妗�
+ WrkMast wrkMast = new WrkMast();
+ wrkMast.setWrkNo(workNo);
+ wrkMast.setIoTime(now);
+ wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬�
+ wrkMast.setIoPri(13D); // 浼樺厛绾э細13
+ wrkMast.setCrnNo(1);
+ wrkMast.setSourceStaNo(107); // 婧愮珯
+ wrkMast.setStaNo(104); // 鐩爣绔�
+ wrkMast.setSourceLocNo(locMast.getLocNo()); // 婧愬簱浣�
+ wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
+ wrkMast.setPicking("N"); // 鎷f枡
+ wrkMast.setExitMk("N"); // 閫�鍑�
+ wrkMast.setEmptyMk("N"); // 绌烘澘
+ wrkMast.setLinkMis("N");
+ wrkMast.setBarcode(locMast.getBarcode());
+ wrkMast.setAppeTime(now);
+ wrkMast.setModiTime(now);
+ if (!wrkMastService.insert(wrkMast)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細"+locMast.getLocNo());
+ }
+ // 鐢熸垚宸ヤ綔妗f槑缁�
+ WrkDetl wrkDetl = new WrkDetl();
+ wrkDetl.sync(locDetl);
+ wrkDetl.setWrkNo(workNo);
+ wrkDetl.setIoTime(now);
+ wrkDetl.setAnfme(1.0); // 鏁伴噺
+ wrkDetl.setAppeTime(now);
+ wrkDetl.setModiTime(now);
+ if (!wrkDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+ // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害
+ if (locMast.getLocSts().equals("F")) {
+ locMast.setLocSts("R");
+ locMast.setModiTime(now);
+ locMast.setPackStatus(6); //6:闈欑疆瀹屾垚
+ CombParam combParam = new CombParam();
+ combParam.setPackNo(locMast.getBarcode());
+ combParam.setLocNo(locMast.getLocNo());
+ combParam.setPackSts(7);
+ combParam.setRequestTime(DateUtils.convert(new Date()));
+ new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
+
+ if (!locMastService.updateById(locMast)) {
+ throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細"+locMast.getLocNo());
+ }
+ } else {
+ throw new CoolException(locMast.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
+ }
+ }
+ }
+
+
+ }
@Override
@Transactional
- public void infoReview(Review review) {
+ public TestMast infoReview(Review review) {
LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()));
if (!review.getBarcode().equals(locMast.getBarcode())){
throw new CoolException("pack鐮佷笉鍚�");
@@ -624,22 +740,38 @@
.eq("loc_no", review.getLocNo())
.eq("barcode", review.getBarcode())
.eq("user_Id", review.getUserId());
- if (null == locMast ||locMast.getPackStatus()!=1) {
- throw new CoolException("浜у搧鐘舵�佷笉鏄� 1:寰呮祴璇�");
- }
TestMast testMast = testMastService.selectOne(wrapper);
+ if (null == locMast) {
+ throw new CoolException("浜у搧鐘舵�佷负绌�");
+ }else if (locMast.getPackStatus()==2){
+ if (!Cools.isEmpty(testMast)){
+ if (testMast.getStatus()==2 || testMast.getStatus()==3){
+ return testMast;
+ }
+ }
+ }else if (locMast.getPackStatus()!=1){
+ throw new CoolException("浜у搧鐘舵�佷笉鏄�1寰呮祴璇�");
+ }
+
if(null != testMast){
if (testMast.getStatus()==1){
- testMast.setStatus(3);
+ testMast.setStatus(2);
testMast.setModiTime(new Date());
if (!testMastService.update(testMast,wrapper)){
throw new CoolException("鏇存柊娴嬭瘯鐘舵�佸け璐�");
}
locMast.setPackStatus(2);
+ CombParam combParam = new CombParam();
+ combParam.setPackNo(locMast.getBarcode());
+ combParam.setLocNo(locMast.getLocNo());
+ combParam.setPackSts(2);
+ combParam.setRequestTime(DateUtils.convert(new Date()));
+ new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
+
if (!locMastService.update(locMast,new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()))){
throw new CoolException("鏇存柊浜у搧鐘舵�佸け璐�");
}
- }else if (Cools.isEmpty(testMast.getStatus())){
+ } else if (Cools.isEmpty(testMast.getStatus())){
throw new CoolException("鐘舵�佸紓甯�");
}else {
throw new CoolException("鐘舵�佷笉鏄� 1:鐢宠涓�");
@@ -647,6 +779,7 @@
} else {
throw new CoolException("娴嬭瘯鐢宠澶嶆牳澶辫触");
}
+ return testMast;
}
@@ -667,37 +800,70 @@
TestMast testMast = testMastService.selectOne(wrapper);
if(null != testMast){
if (testMast.getStatus()==3){
- testMast.setStatus(4);
- testMast.setModiTime(new Date());
- if (!testMastService.update(testMast,wrapper)){
- throw new CoolException("鏇存敼娴嬭瘯鐘舵�佸け璐�");
- }
+ Date date = new Date();
locMast.setPackStatus(3);
+ locMast.setModiTime(date);
+ CombParam combParam = new CombParam();
+ combParam.setPackNo(locMast.getBarcode());
+ combParam.setLocNo(locMast.getLocNo());
+ combParam.setPackSts(3);
+ combParam.setRequestTime(DateUtils.convert(new Date()));
+ new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
+
if (!locMastService.update(locMast, new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()))){
throw new CoolException("鏇存敼浜у搧鐘舵�佸け璐�");
}
}else if (Cools.isEmpty(testMast.getStatus())){
throw new CoolException("鐘舵�佸紓甯�");
}else {
- throw new CoolException("鐘舵�佷笉鏄� 2:娴嬭瘯涓�");
+ throw new CoolException("娴嬭瘯鐘舵�佷笉鏄� 3:娴嬭瘯涓�");
}
} else {
throw new CoolException("鐘舵�佸紓甯�");
}
- //绉诲簱寮�濮嬶紝鏌ヨ鐩爣搴撲綅
- LocMast targetLocNo = locMastService.selectOne(new EntityWrapper<LocMast>()
- .eq("row1",2)
- .eq("loc_sts","O")
- .eq("fire_status", 0)
- .eq("pack_status",0));
- if (targetLocNo != null){
- workService.locMove(review.getLocNo(),targetLocNo.getLocNo(),(long)Integer.parseInt(review.getUserId()));
- }else {
- throw new CoolException("娌℃湁绌哄簱浣�");
- }
return success;
}
+ @Override
+ @Transactional
+ public Boolean testNG(Review review) {
+ Boolean success=true;
+ Wrapper wrapper = new EntityWrapper<TestMast>()
+ .eq("loc_no", review.getLocNo())
+ .eq("barcode", review.getBarcode())
+ .eq("user_Id", review.getUserId());
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()));
+ if (null == locMast ||locMast.getPackStatus()!=2){
+ throw new CoolException("浜у搧鐘舵�佷笉鏄� 2:娴嬭瘯涓�");
+ }else if (!review.getBarcode().equals(locMast.getBarcode())){
+ throw new CoolException("pack鐮佷笉鍚�");
+ }
+ TestMast testMast = testMastService.selectOne(wrapper);
+ if(null != testMast){
+ if (testMast.getStatus()==3){
+ Date date = new Date();
+ locMast.setPackStatus(4);
+ locMast.setModiTime(date);
+ CombParam combParam = new CombParam();
+ combParam.setPackNo(locMast.getBarcode());
+ combParam.setLocNo(locMast.getLocNo());
+ combParam.setPackSts(4);
+ combParam.setRequestTime(DateUtils.convert(new Date()));
+ new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
+
+ if (!locMastService.update(locMast, new EntityWrapper<LocMast>().eq("loc_no", review.getLocNo()))){
+ throw new CoolException("鏇存敼浜у搧鐘舵�佸け璐�");
+ }
+ }else if (Cools.isEmpty(testMast.getStatus())){
+ throw new CoolException("鐘舵�佸紓甯�");
+ }else {
+ throw new CoolException("鐘舵�佷笉鏄� 3:娴嬭瘯涓�");
+ }
+ } else {
+ throw new CoolException("鐘舵�佸紓甯�");
+ }
+ return success;
+ }
/*...........................璧e窞鏂板..............浠ヤ笂.............璧e窞鏂板...........................*/
}
--
Gitblit v1.9.1