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 | 209 +++++++++++++++++++++++++++-------------------------
1 files changed, 108 insertions(+), 101 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 5d3f5c3..0506530 100644
--- a/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/OpenServiceImpl.java
@@ -1,7 +1,5 @@
package com.zy.asrs.service.impl;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.BaseRes;
@@ -16,22 +14,17 @@
import com.zy.asrs.mapper.TagMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.task.AbstractHandler;
-import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.utils.MatUtils;
-import com.zy.common.constant.MesConstant;
+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.HttpHandler;
import com.zy.common.utils.NodeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -70,15 +63,12 @@
@Autowired
private CommonService commonService;
@Autowired
- private ApiLogService apiLogService;
- @Autowired
private WrkMastService wrkMastService;
-
- @Value("${mes.url}")
- private String mesUrl;
@Value("${mes.inPath}")
private String inpath;
+ @Value("${mes.url}")
+ private String mesUrl;
@Override
@Transactional
@@ -579,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);
}
@@ -590,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());
@@ -616,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);
@@ -629,6 +635,15 @@
@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);
}
@@ -638,16 +653,10 @@
.eq("barcode", param.getPackNo()));
if (Cools.isEmpty(locMast)){
throw new CoolException("鏈煡璇㈠埌PACK鐮佷负锛�"+param.getPackNo()+"鐨勮揣鐗�");
- }else if (locMast.getLocSts().equals("F")){
+ }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 if (locMast.getFireStatus()!=0){
-// throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒");
-// }else if (locMast.getFireStatus()!=0){
-// throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒");
-// }else if (locMast.getFireStatus()!=0){
-// throw new CoolException("璀﹀憡锛侊紒锛丳ACK鐮佷负锛�"+param.getPackNo()+"鐨勫簱浣嶏細"+locMast.getLocNo()+"娑堥槻鐘舵�佸紓甯革紒锛侊紒");
}else {
Date now = new Date();
Integer ioType = 101; //鍏ュ嚭搴撶被鍨�
@@ -700,13 +709,13 @@
if (locMast.getLocSts().equals("F")) {
locMast.setLocSts("R");
locMast.setModiTime(now);
- locMast.setPackStatus(5); //5:闈欑疆瀹屾垚
+ locMast.setPackStatus(6); //6:闈欑疆瀹屾垚
CombParam combParam = new CombParam();
combParam.setPackNo(locMast.getBarcode());
combParam.setLocNo(locMast.getLocNo());
- combParam.setPackSts(6);
+ combParam.setPackSts(7);
combParam.setRequestTime(DateUtils.convert(new Date()));
- postMesData(inpath,combParam);
+ new PostMesDataUtils().postMesData("MES绯荤粺",mesUrl,inpath,combParam);
if (!locMastService.updateById(locMast)) {
throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細"+locMast.getLocNo());
@@ -722,7 +731,7 @@
@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鐮佷笉鍚�");
@@ -731,13 +740,22 @@
.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("鏇存柊娴嬭瘯鐘舵�佸け璐�");
@@ -748,11 +766,12 @@
combParam.setLocNo(locMast.getLocNo());
combParam.setPackSts(2);
combParam.setRequestTime(DateUtils.convert(new Date()));
- postMesData(inpath,combParam);
+ 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:鐢宠涓�");
@@ -760,6 +779,7 @@
} else {
throw new CoolException("娴嬭瘯鐢宠澶嶆牳澶辫触");
}
+ return testMast;
}
@@ -781,19 +801,56 @@
if(null != testMast){
if (testMast.getStatus()==3){
Date date = new Date();
- testMast.setStatus(4);
- testMast.setModiTime(date);
- if (!testMastService.update(testMast,wrapper)){
- throw new CoolException("鏇存敼娴嬭瘯鐘舵�佸け璐�");
- }
locMast.setPackStatus(3);
- testMast.setModiTime(date);
+ locMast.setModiTime(date);
CombParam combParam = new CombParam();
combParam.setPackNo(locMast.getBarcode());
combParam.setLocNo(locMast.getLocNo());
combParam.setPackSts(3);
combParam.setRequestTime(DateUtils.convert(new Date()));
- postMesData(inpath,combParam);
+ 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;
+ }
+
+ @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("鏇存敼浜у搧鐘舵�佸け璐�");
}
@@ -806,56 +863,6 @@
throw new CoolException("鐘舵�佸紓甯�");
}
return success;
- }
-
- private ReturnT<String> postMesData(String mesPath, Object combParam){
- if(combParam != null){
- String response = "";
- boolean success = false;
- try {
-// Map<String, Object> map = new HashMap<>();
-// map.put("appkey","ea1f0459efc02a79f046f982767939ae");
- response = new HttpHandler.Builder()
-// .setHeaders(map)
- .setUri(mesUrl)
- .setPath(mesPath)
- .setJson(JSON.toJSONString(combParam))
- .build()
- .doPost();
- JSONObject jsonObject = JSON.parseObject(response);
- if (jsonObject.getInteger("code").equals(200)) {
- if (jsonObject.getDate("isComplete").equals(true)){
- success = true;
- }else if (jsonObject.getDate("isComplete").equals(false)){
- success = false;
- }else {
- log.error("杩斿洖鍊煎嚭閿�!!!url锛歿}锛況equest锛歿}锛況esponse锛歿}", mesUrl+mesPath, JSON.toJSONString(combParam), response);
- throw new CoolException("杩斿洖鍊煎嚭閿�");
- }
- } else {
- log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", mesUrl+mesPath, JSON.toJSONString(combParam), response);
- throw new CoolException("涓婃姤mes绯荤粺澶辫触");
- }
- } catch (Exception e) {
- log.error("fail", e);
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return FAIL.setMsg(e.getMessage());
- } finally {
- try {
- // 淇濆瓨鎺ュ彛鏃ュ織
- apiLogService.save(
- "鎴愬搧搴撳叆搴撲笂鎶�",
- mesUrl + mesPath,
- null,
- "127.0.0.1",
- JSON.toJSONString(combParam),
- response,
- success
- );
- } catch (Exception e) { log.error("", e); }
- }
- }
- return SUCCESS;
}
/*...........................璧e窞鏂板..............浠ヤ笂.............璧e窞鏂板...........................*/
--
Gitblit v1.9.1