|
@@ -1,14 +1,11 @@
|
|
package com.ruoyi.web.service;
|
|
package com.ruoyi.web.service;
|
|
|
|
|
|
-import cn.hutool.crypto.digest.HMac;
|
|
|
|
-import cn.hutool.crypto.digest.HmacAlgorithm;
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.ruoyi.web.bo.ResponseBo;
|
|
import com.ruoyi.web.bo.ResponseBo;
|
|
import com.ruoyi.web.config.ConfigComponent;
|
|
import com.ruoyi.web.config.ConfigComponent;
|
|
import com.ruoyi.web.config.RestUtil;
|
|
import com.ruoyi.web.config.RestUtil;
|
|
-import com.ruoyi.web.entity.GatherData;
|
|
|
|
-import com.ruoyi.web.entity.VerificationRes;
|
|
|
|
-import com.ruoyi.web.entity.WeightRes;
|
|
|
|
|
|
+import com.ruoyi.web.entity.*;
|
|
|
|
+import com.ruoyi.web.config.cache.RedisUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -30,9 +27,9 @@ import java.util.Map;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class BulkloadService {
|
|
public class BulkloadService {
|
|
|
|
|
|
- // private static HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
|
+ //private static HttpHeaders headers = new HttpHeaders();
|
|
private final static Map<String,HttpHeaders> HEADERS_MAP=new ConcurrentReferenceHashMap<>();
|
|
private final static Map<String,HttpHeaders> HEADERS_MAP=new ConcurrentReferenceHashMap<>();
|
|
- private final static Map<String,String> THRFLAG_MAP=new ConcurrentReferenceHashMap<>();
|
|
|
|
|
|
+ //private final static Map<String,String> THRFLAG_MAP=new ConcurrentReferenceHashMap<>();
|
|
@Autowired
|
|
@Autowired
|
|
private ConfigComponent configComponent;
|
|
private ConfigComponent configComponent;
|
|
|
|
|
|
@@ -85,7 +82,8 @@ public class BulkloadService {
|
|
if("I".equalsIgnoreCase(gatherData.getI_E_FLAG())) {//进港
|
|
if("I".equalsIgnoreCase(gatherData.getI_E_FLAG())) {//进港
|
|
res = this.InVerification(gatherData);
|
|
res = this.InVerification(gatherData);
|
|
} else {//出港
|
|
} else {//出港
|
|
- res = this.OutWeight(gatherData,THRFLAG_MAP.get(gatherData.getVE_LICENSE_NO()));
|
|
|
|
|
|
+ //res = this.OutWeight(gatherData,THRFLAG_MAP.get(gatherData.getVE_LICENSE_NO()));
|
|
|
|
+ res = this.OutWeight(gatherData,RedisUtil.get("数据交换中心:"+gatherData.getVE_LICENSE_NO()));
|
|
}
|
|
}
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
@@ -124,6 +122,16 @@ public class BulkloadService {
|
|
JSONObject result = RestUtil.get(url, headers);
|
|
JSONObject result = RestUtil.get(url, headers);
|
|
log.info("进港:预约确认接口返回结果:{}",result.toString());
|
|
log.info("进港:预约确认接口返回结果:{}",result.toString());
|
|
verificationRes = JSONObject.parseObject(result.toString(), VerificationRes.class);
|
|
verificationRes = JSONObject.parseObject(result.toString(), VerificationRes.class);
|
|
|
|
+ if("false".equalsIgnoreCase(verificationRes.getRESULT())) {
|
|
|
|
+ if(verificationRes.getMESSAGE().contains("未找到车辆") && verificationRes.getMESSAGE().contains("预约信息")) {
|
|
|
|
+ res.setFlag("散货无预约");
|
|
|
|
+ }
|
|
|
|
+ res.setCode(500);
|
|
|
|
+ res.setMsg(verificationRes.getMESSAGE());
|
|
|
|
+ //退出登录
|
|
|
|
+ this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
String message = e.getMessage();
|
|
String message = e.getMessage();
|
|
if(message.contains("Message")) {
|
|
if(message.contains("Message")) {
|
|
@@ -134,18 +142,10 @@ public class BulkloadService {
|
|
res.setMsg(message);
|
|
res.setMsg(message);
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
-
|
|
|
|
res.setCode(200);
|
|
res.setCode(200);
|
|
res.setMsg(verificationRes.getMESSAGE());
|
|
res.setMsg(verificationRes.getMESSAGE());
|
|
- if("false".equalsIgnoreCase(verificationRes.getRESULT())) {
|
|
|
|
- res.setCode(500);
|
|
|
|
- res.setFlag("散货无预约");
|
|
|
|
- //退出登录
|
|
|
|
- this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
|
|
- return res;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- THRFLAG_MAP.put(gatherData.getVE_LICENSE_NO(), verificationRes.getTHRFLAG());
|
|
|
|
|
|
+ RedisUtil.set("数据交换中心:"+gatherData.getVE_LICENSE_NO(), verificationRes.getTHRFLAG());
|
|
|
|
+ //THRFLAG_MAP.put(gatherData.getVE_LICENSE_NO(), verificationRes.getTHRFLAG());
|
|
res = this.InWeight(gatherData,verificationRes.getTHRFLAG());
|
|
res = this.InWeight(gatherData,verificationRes.getTHRFLAG());
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
@@ -219,21 +219,27 @@ public class BulkloadService {
|
|
JSONObject params = JSONObject.parseObject(body);
|
|
JSONObject params = JSONObject.parseObject(body);
|
|
log.info("进港:卡车称重接口url:{}",url);
|
|
log.info("进港:卡车称重接口url:{}",url);
|
|
log.info("进港:卡车称重接口params:{}",params);
|
|
log.info("进港:卡车称重接口params:{}",params);
|
|
|
|
+ VerificationRes verificationRes = new VerificationRes();
|
|
try {
|
|
try {
|
|
//{"MESSAGE":"一次过磅称重成功","RESULT":true}
|
|
//{"MESSAGE":"一次过磅称重成功","RESULT":true}
|
|
HttpHeaders headers= HEADERS_MAP.get(gatherData.getVE_LICENSE_NO());
|
|
HttpHeaders headers= HEADERS_MAP.get(gatherData.getVE_LICENSE_NO());
|
|
JSONObject jsonObject = RestUtil.post(url, headers, params);
|
|
JSONObject jsonObject = RestUtil.post(url, headers, params);
|
|
log.info("进港:卡车称重接口返回结果:{}",jsonObject);
|
|
log.info("进港:卡车称重接口返回结果:{}",jsonObject);
|
|
|
|
+ verificationRes = JSONObject.parseObject(jsonObject.toString(), VerificationRes.class);
|
|
|
|
+ if("false".equalsIgnoreCase(verificationRes.getRESULT())) {
|
|
|
|
+ res.setCode(500);
|
|
|
|
+ res.setMsg(verificationRes.getMESSAGE());
|
|
|
|
+ //退出登录
|
|
|
|
+ this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
if(jsonObject != null && jsonObject.toString().contains("ErrorCode")) {
|
|
if(jsonObject != null && jsonObject.toString().contains("ErrorCode")) {
|
|
res.setCode(500);
|
|
res.setCode(500);
|
|
res.setMsg(jsonObject.getString("Message"));
|
|
res.setMsg(jsonObject.getString("Message"));
|
|
|
|
+ //退出登录
|
|
|
|
+ this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
- /*if(jsonObject != null && jsonObject.toString().contains("RESULT")) {
|
|
|
|
- res.setCode(200);
|
|
|
|
- res.setMsg(jsonObject.getString("MESSAGE"));
|
|
|
|
- return res;
|
|
|
|
- }*/
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
String message = e.getMessage();
|
|
String message = e.getMessage();
|
|
if(message.contains("Message")) {
|
|
if(message.contains("Message")) {
|
|
@@ -281,12 +287,23 @@ public class BulkloadService {
|
|
log.info("出港:卡车称重接口url:{}",url);
|
|
log.info("出港:卡车称重接口url:{}",url);
|
|
log.info("出港:卡车称重接口params:{}",params);
|
|
log.info("出港:卡车称重接口params:{}",params);
|
|
HttpHeaders headers= HEADERS_MAP.get(gatherData.getVE_LICENSE_NO());
|
|
HttpHeaders headers= HEADERS_MAP.get(gatherData.getVE_LICENSE_NO());
|
|
|
|
+ VerificationRes verificationRes = new VerificationRes();
|
|
try {
|
|
try {
|
|
JSONObject jsonObject = RestUtil.post(url, headers, params);
|
|
JSONObject jsonObject = RestUtil.post(url, headers, params);
|
|
log.info("出港:卡车称重接口返回结果:{}",jsonObject);
|
|
log.info("出港:卡车称重接口返回结果:{}",jsonObject);
|
|
|
|
+ verificationRes = JSONObject.parseObject(jsonObject.toString(), VerificationRes.class);
|
|
|
|
+ if("false".equalsIgnoreCase(verificationRes.getRESULT())) {
|
|
|
|
+ res.setCode(500);
|
|
|
|
+ res.setMsg(verificationRes.getMESSAGE());
|
|
|
|
+ //退出登录
|
|
|
|
+ this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
if(jsonObject != null && jsonObject.toString().contains("ErrorCode")) {
|
|
if(jsonObject != null && jsonObject.toString().contains("ErrorCode")) {
|
|
res.setCode(500);
|
|
res.setCode(500);
|
|
res.setMsg(jsonObject.getString("Message"));
|
|
res.setMsg(jsonObject.getString("Message"));
|
|
|
|
+ //退出登录
|
|
|
|
+ this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -329,8 +346,6 @@ public class BulkloadService {
|
|
res.setMsg(message);
|
|
res.setMsg(message);
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
- /*WeightRes weightRes = JSONObject.parseObject(jsonObject.toString(), WeightRes.class);
|
|
|
|
- * res.setRegistrationNo(weightRes.getRegistrationNo());*/
|
|
|
|
res.setCode(200);
|
|
res.setCode(200);
|
|
res = this.GetOutReport(gatherData,THIRDFLAG);
|
|
res = this.GetOutReport(gatherData,THIRDFLAG);
|
|
return res;
|
|
return res;
|
|
@@ -403,10 +418,19 @@ public class BulkloadService {
|
|
JSONObject params = JSONObject.parseObject(body);
|
|
JSONObject params = JSONObject.parseObject(body);
|
|
log.info("出港:卡车放行报告接口url:{}",url);
|
|
log.info("出港:卡车放行报告接口url:{}",url);
|
|
log.info("出港:卡车放行报告接口params:{}",params);
|
|
log.info("出港:卡车放行报告接口params:{}",params);
|
|
|
|
+ VerificationRes verificationRes = new VerificationRes();
|
|
try {
|
|
try {
|
|
HttpHeaders headers= HEADERS_MAP.get(gatherData.getVE_LICENSE_NO());
|
|
HttpHeaders headers= HEADERS_MAP.get(gatherData.getVE_LICENSE_NO());
|
|
JSONObject jsonObject = RestUtil.post(url, headers, params);
|
|
JSONObject jsonObject = RestUtil.post(url, headers, params);
|
|
log.info("出港:卡车放行报告接口返回结果:{}",jsonObject);
|
|
log.info("出港:卡车放行报告接口返回结果:{}",jsonObject);
|
|
|
|
+ verificationRes = JSONObject.parseObject(jsonObject.toString(), VerificationRes.class);
|
|
|
|
+ if("false".equalsIgnoreCase(verificationRes.getRESULT())) {
|
|
|
|
+ res.setCode(500);
|
|
|
|
+ res.setMsg(verificationRes.getMESSAGE());
|
|
|
|
+ //退出登录
|
|
|
|
+ this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
if(jsonObject != null && jsonObject.toString().contains("ErrorCode")) {
|
|
if(jsonObject != null && jsonObject.toString().contains("ErrorCode")) {
|
|
res.setCode(500);
|
|
res.setCode(500);
|
|
res.setMsg(jsonObject.getString("Message"));
|
|
res.setMsg(jsonObject.getString("Message"));
|
|
@@ -429,7 +453,8 @@ public class BulkloadService {
|
|
res.setNotes(bo.getNotes());*/
|
|
res.setNotes(bo.getNotes());*/
|
|
//退出登录
|
|
//退出登录
|
|
this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
this.LogOff(gatherData.getVE_LICENSE_NO());
|
|
- THRFLAG_MAP.remove(gatherData.getVE_LICENSE_NO());
|
|
|
|
|
|
+ RedisUtil.del("数据交换中心:"+gatherData.getVE_LICENSE_NO());
|
|
|
|
+ //THRFLAG_MAP.remove(gatherData.getVE_LICENSE_NO());
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|