tao.mo

Merge branch 'consignmentCodeCheck' of http://118.178.128.178//Fedex/iClear-api into API-2023-03-12

 Conflicts:
	src/main/java/com/erry/iclear/dateInterface/api/FedexDataInterface.java
ALTER TABLE T_ICLEAR_API_APPINFO
ADD C_CODE_CHECK VARCHAR(1)
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'C类校验是否校验运单号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_ICLEAR_API_APPINFO', @level2type=N'COLUMN',@level2name=N'C_CODE_CHECK'
GO
\ No newline at end of file
......@@ -10,10 +10,8 @@ import com.erry.iclear.dateInterface.api.request.*;
import com.erry.iclear.dateInterface.api.response.FedexResultChmRS;
import com.erry.iclear.dateInterface.api.response.FedexResultRS;
import com.erry.iclear.dateInterface.api.response.ResultRS;
import com.erry.iclear.dateInterface.entity.ChmConsignment;
import com.erry.iclear.dateInterface.entity.DeclaredInfo;
import com.erry.iclear.dateInterface.entity.IClearApiLog;
import com.erry.iclear.dateInterface.entity.TIClearApiCheckLog;
import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.*;
import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
import com.erry.iclear.dateInterface.repository.IClearApiCheckLogRepository;
import com.erry.iclear.dateInterface.service.*;
......@@ -77,6 +75,9 @@ public class FedexDataInterface {
String token=(String) request.getHeader("Token");
String addr = request.getRemoteAddr();
//获取APPINFO信息
AppInfo appInfo = Constant.appInfoCache.get(appId + appKey);
TIClearApiCheckLog tIclearApiCheckLog = new TIClearApiCheckLog();
tIclearApiCheckLog.setRequestAppid(appId);
tIclearApiCheckLog.setRequestAppkey(appKey);
......@@ -95,7 +96,7 @@ public class FedexDataInterface {
log.info("checkBASFMawbFedex:"+fedexc.toString());
log.info("appId:{},appKey:{},timeStamp:{},token:{}",appId,appKey,timeStamp,token);
ResultRS result = fedexService.checkBasfInterfaceData(fedexc);
ResultRS result = fedexService.checkBasfInterfaceData(fedexc,appInfo);
StopWatch sw = new StopWatch("checkBASFMawbFedex");
sw.start("generate FedexMawb");
......@@ -105,7 +106,7 @@ public class FedexDataInterface {
sw.start("checkFedexMawb");
String msg = result.getMsg();
String iclearCheckMsg = fedexService.checkFedexMawb(saveMawbFedexResult).getMsg();
String iclearCheckMsg = fedexService.checkFedexMawb(saveMawbFedexResult,appInfo).getMsg();
if(StringUtil.isEmpty(msg) && StringUtil.isEmpty(iclearCheckMsg)){
result.setSuccess(Boolean.TRUE);
}else{
......@@ -141,7 +142,6 @@ public class FedexDataInterface {
return result;
}
//1、保存请求信息,保存到iClear的 SQLServer
StopWatch sw = new StopWatch("receice mawbFedex");
sw.start("save log");
......@@ -172,7 +172,7 @@ public class FedexDataInterface {
//2、TODO 校验主单
sw.start("checkFedexMawb");
result=fedexService.checkFedexMawb(saveMawbFedexResult);
result=fedexService.checkFedexMawb(saveMawbFedexResult,null);
if(!result.getSuccess()){
return result;
}
......
package com.erry.iclear.dateInterface.common;
import com.erry.iclear.dateInterface.entity.ChmCarryPort;
import com.erry.iclear.dateInterface.entity.DictionaryEntries;
import com.erry.iclear.dateInterface.entity.DomesticDestinationMapping;
import com.erry.iclear.dateInterface.entity.OrigplacecodeMapping;
import com.erry.iclear.dateInterface.entity.*;
import org.springframework.stereotype.Component;
import java.util.HashMap;
......@@ -21,6 +18,11 @@ public class Constant {
public static Map<String,HashMap<String,String>> appIdSecurityCache = new HashMap<>();
/**
* APP INFO信息
*/
public static Map<String,AppInfo> appInfoCache = new HashMap<>();
/**
* 字典表 code:entity
*/
public static Map<String , DictionaryEntries> dictionaryEntriesCache = new HashMap<>();
......
......@@ -34,5 +34,9 @@ public class AppInfo implements Serializable {
@Column(name = "IS_ENABLE")
private String isEnable;
/**
* C类校验是否校验运单号,非空则不校验
*/
@Column(name = "C_CODE_CHECK")
private String codeCheck;
}
......
......@@ -416,6 +416,11 @@ public class ChmConsignment implements Serializable {
@OneToMany(mappedBy = "chmConsignment", cascade = CascadeType.ALL)
private List<ChmConsignmentDetail> chmConsignmentDetailList;
/**
* C类校验是否校验运单号,非空则不校验
*/
@Transient
private String codeCheck;
@Override
public String toString() {
......
......@@ -43,6 +43,7 @@ public class AppInfoService {
HashMap<String, String> appkeyMap = new HashMap<String, String>();
appkeyMap.put(appInfo.getAppKey(), appInfo.getSecurity());
Constant.appIdSecurityCache.put(appInfo.getAppId(), appkeyMap);
Constant.appInfoCache.put(appInfo.getAppId()+appInfo.getAppKey(),appInfo);
}
} catch (Exception e) {
log.error("initAppInfo() error" + e.getMessage());
......
......@@ -242,7 +242,7 @@ public class ChmConsignmentService {
return result;
}
public ChmConsignment convertToChmConsignmentFedex(FedexMawb mawb, Date pushTime, String creator){
public ChmConsignment convertToChmConsignmentFedex(FedexMawb mawb, Date pushTime, String creator,AppInfo appInfo){
ChmConsignment result = new ChmConsignment();
try{
//运单号
......@@ -259,6 +259,11 @@ public class ChmConsignmentService {
result.setTradeModeDic(tradeModeDictionaryEntries);
result.setTradeMode(tradeModeDictionaryEntries.getChineseName());
}*/
if(appInfo != null){
//C类校验是否校验运单号,非空则不校验
result.setCodeCheck(appInfo.getCodeCheck());
}
//境内收发货人社会信用证代码
result.setTradeCoSCC(mawb.getTradeCodeScc());
//境内发货人(经营单位编码)
......@@ -578,7 +583,7 @@ public class ChmConsignmentService {
ResultRS result = new ResultRS(Boolean.FALSE,null,null);
try {
Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp));
ChmConsignment chmConsignment = this.convertToChmConsignmentFedex(fedexMawb,pushTime,creator);
ChmConsignment chmConsignment = this.convertToChmConsignmentFedex(fedexMawb,pushTime,creator,null);
if(Objects.equals(chmConsignment,null)){
result.setCode(ErrorCodeEnum.ERROR_30001.getCode());
result.setMsg(ErrorCodeEnum.ERROR_30001.getName());
......
......@@ -4,6 +4,7 @@ import com.erry.iclear.dateInterface.ErrorCodeEnum;
import com.erry.iclear.dateInterface.api.request.*;
import com.erry.iclear.dateInterface.api.response.IClearCheckResponseResult;
import com.erry.iclear.dateInterface.api.response.ResultRS;
import com.erry.iclear.dateInterface.entity.AppInfo;
import com.erry.iclear.dateInterface.entity.ChmConsignment;
import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
import com.erry.iclear.dateInterface.repository.FedexMawbRepository;
......@@ -112,13 +113,13 @@ public class FedexService {
* @param fedexMawb
* @return
*/
public ResultRS checkFedexMawb(FedexMawb fedexMawb){
public ResultRS checkFedexMawb(FedexMawb fedexMawb,AppInfo appInfo){
ResultRS result = new ResultRS(Boolean.FALSE,null,null);
try{
log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(fedexMawb));
//1、将请求转换为运单
ChmConsignment chmConsignment=consignmentService.convertToChmConsignmentFedex(fedexMawb,null,"IDE-ICLEAR-API");
ChmConsignment chmConsignment=consignmentService.convertToChmConsignmentFedex(fedexMawb,null,"IDE-ICLEAR-API",appInfo);
if(Objects.equals(chmConsignment,null)){
result.setCode(ErrorCodeEnum.ERROR_7.getCode());
result.setMsg(ErrorCodeEnum.ERROR_7.getName());
......@@ -166,7 +167,7 @@ public class FedexService {
* @param fedexc
* @return
*/
public ResultRS checkBasfInterfaceData(Fedexc fedexc){
public ResultRS checkBasfInterfaceData(Fedexc fedexc, AppInfo appInfo){
ResultRS result = new ResultRS(Boolean.FALSE,"","");
......@@ -177,7 +178,8 @@ public class FedexService {
List<String> msgList = new ArrayList<>();
// 参数consignmentCode不能为空
String consignmentCode = fedexc.getConsignmentCode();
if(StringUtils.isEmpty(consignmentCode)){
//C类校验是否校验运单号,非空则不校验
if(appInfo.getCodeCheck() == null && StringUtils.isEmpty(consignmentCode)){
msgList.add("参数consignmentCode不能为空");
}
// 参数consignmentId不能为空
......
......@@ -40,22 +40,22 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
@Test
public void testProcessChmConsignment1(){
try{
ResultRS result = new ResultRS(Boolean.FALSE,"","");
Fedexc fedexc = this.createNewFedex();
FedexMawb mawb = fedexService.saveMawbFedex(fedexc);
//Basfc fedexc = this.createNewBasf();
String timeStamp = String.valueOf(new Date().getTime());
ResultRS resultRS = chmConsignmentService.processChmConsignmentFedex(mawb, timeStamp, "BASF");
/*result=fedexService.checkBasfMawb(mawb);
if(!result.getSuccess()){
System.out.println(result.getMsg());
}*/
System.out.println(resultRS.toString());
}catch (Exception e){
e.printStackTrace();
}
System.out.println("1");
// try{
// ResultRS result = new ResultRS(Boolean.FALSE,"","");
// Fedexc fedexc = this.createNewFedex();
// FedexMawb mawb = fedexService.saveMawbFedex(fedexc);
// //Basfc fedexc = this.createNewBasf();
// String timeStamp = String.valueOf(new Date().getTime());
// ResultRS resultRS = chmConsignmentService.processChmConsignmentFedex(mawb, timeStamp, "BASF");
// /*result=fedexService.checkBasfMawb(mawb);
// if(!result.getSuccess()){
// System.out.println(result.getMsg());
// }*/
// System.out.println(resultRS.toString());
// }catch (Exception e){
// e.printStackTrace();
// }
// System.out.println("1");
}
private Fedexc createNewFedex(){
......