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 | 118 +++++++++++++++-------------------------------------------
1 files changed, 31 insertions(+), 87 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 8d37d41..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
@@ -599,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());
@@ -625,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);
@@ -660,12 +657,6 @@
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; //鍏ュ嚭搴撶被鍨�
@@ -724,7 +715,7 @@
combParam.setLocNo(locMast.getLocNo());
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());
@@ -775,7 +766,8 @@
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("鏇存柊浜у搧鐘舵�佸け璐�");
}
@@ -816,7 +808,8 @@
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("鏇存敼浜у搧鐘舵�佸け璐�");
}
@@ -856,7 +849,8 @@
combParam.setLocNo(locMast.getLocNo());
combParam.setPackSts(4);
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("鏇存敼浜у搧鐘舵�佸け璐�");
}
@@ -869,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(
- "涓婃姤mes绯荤粺",
- 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