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
Showing
9 changed files
with
59 additions
and
35 deletions
sql/C类运单号校验/C类运单号校验.sql
0 → 100644
| 1 | +ALTER TABLE T_ICLEAR_API_APPINFO | ||
| 2 | +ADD C_CODE_CHECK VARCHAR(1) | ||
| 3 | + | ||
| 4 | +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' | ||
| 5 | +GO | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -10,10 +10,8 @@ import com.erry.iclear.dateInterface.api.request.*; | ... | @@ -10,10 +10,8 @@ import com.erry.iclear.dateInterface.api.request.*; |
| 10 | import com.erry.iclear.dateInterface.api.response.FedexResultChmRS; | 10 | import com.erry.iclear.dateInterface.api.response.FedexResultChmRS; |
| 11 | import com.erry.iclear.dateInterface.api.response.FedexResultRS; | 11 | import com.erry.iclear.dateInterface.api.response.FedexResultRS; |
| 12 | import com.erry.iclear.dateInterface.api.response.ResultRS; | 12 | import com.erry.iclear.dateInterface.api.response.ResultRS; |
| 13 | -import com.erry.iclear.dateInterface.entity.ChmConsignment; | 13 | +import com.erry.iclear.dateInterface.common.Constant; |
| 14 | -import com.erry.iclear.dateInterface.entity.DeclaredInfo; | 14 | +import com.erry.iclear.dateInterface.entity.*; |
| 15 | -import com.erry.iclear.dateInterface.entity.IClearApiLog; | ||
| 16 | -import com.erry.iclear.dateInterface.entity.TIClearApiCheckLog; | ||
| 17 | import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; | 15 | import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; |
| 18 | import com.erry.iclear.dateInterface.repository.IClearApiCheckLogRepository; | 16 | import com.erry.iclear.dateInterface.repository.IClearApiCheckLogRepository; |
| 19 | import com.erry.iclear.dateInterface.service.*; | 17 | import com.erry.iclear.dateInterface.service.*; |
| ... | @@ -77,6 +75,9 @@ public class FedexDataInterface { | ... | @@ -77,6 +75,9 @@ public class FedexDataInterface { |
| 77 | String token=(String) request.getHeader("Token"); | 75 | String token=(String) request.getHeader("Token"); |
| 78 | String addr = request.getRemoteAddr(); | 76 | String addr = request.getRemoteAddr(); |
| 79 | 77 | ||
| 78 | + //获取APPINFO信息 | ||
| 79 | + AppInfo appInfo = Constant.appInfoCache.get(appId + appKey); | ||
| 80 | + | ||
| 80 | TIClearApiCheckLog tIclearApiCheckLog = new TIClearApiCheckLog(); | 81 | TIClearApiCheckLog tIclearApiCheckLog = new TIClearApiCheckLog(); |
| 81 | tIclearApiCheckLog.setRequestAppid(appId); | 82 | tIclearApiCheckLog.setRequestAppid(appId); |
| 82 | tIclearApiCheckLog.setRequestAppkey(appKey); | 83 | tIclearApiCheckLog.setRequestAppkey(appKey); |
| ... | @@ -95,7 +96,7 @@ public class FedexDataInterface { | ... | @@ -95,7 +96,7 @@ public class FedexDataInterface { |
| 95 | log.info("checkBASFMawbFedex:"+fedexc.toString()); | 96 | log.info("checkBASFMawbFedex:"+fedexc.toString()); |
| 96 | log.info("appId:{},appKey:{},timeStamp:{},token:{}",appId,appKey,timeStamp,token); | 97 | log.info("appId:{},appKey:{},timeStamp:{},token:{}",appId,appKey,timeStamp,token); |
| 97 | 98 | ||
| 98 | - ResultRS result = fedexService.checkBasfInterfaceData(fedexc); | 99 | + ResultRS result = fedexService.checkBasfInterfaceData(fedexc,appInfo); |
| 99 | 100 | ||
| 100 | StopWatch sw = new StopWatch("checkBASFMawbFedex"); | 101 | StopWatch sw = new StopWatch("checkBASFMawbFedex"); |
| 101 | sw.start("generate FedexMawb"); | 102 | sw.start("generate FedexMawb"); |
| ... | @@ -105,7 +106,7 @@ public class FedexDataInterface { | ... | @@ -105,7 +106,7 @@ public class FedexDataInterface { |
| 105 | 106 | ||
| 106 | sw.start("checkFedexMawb"); | 107 | sw.start("checkFedexMawb"); |
| 107 | String msg = result.getMsg(); | 108 | String msg = result.getMsg(); |
| 108 | - String iclearCheckMsg = fedexService.checkFedexMawb(saveMawbFedexResult).getMsg(); | 109 | + String iclearCheckMsg = fedexService.checkFedexMawb(saveMawbFedexResult,appInfo).getMsg(); |
| 109 | if(StringUtil.isEmpty(msg) && StringUtil.isEmpty(iclearCheckMsg)){ | 110 | if(StringUtil.isEmpty(msg) && StringUtil.isEmpty(iclearCheckMsg)){ |
| 110 | result.setSuccess(Boolean.TRUE); | 111 | result.setSuccess(Boolean.TRUE); |
| 111 | }else{ | 112 | }else{ |
| ... | @@ -141,7 +142,6 @@ public class FedexDataInterface { | ... | @@ -141,7 +142,6 @@ public class FedexDataInterface { |
| 141 | return result; | 142 | return result; |
| 142 | } | 143 | } |
| 143 | //1、保存请求信息,保存到iClear的 SQLServer | 144 | //1、保存请求信息,保存到iClear的 SQLServer |
| 144 | - | ||
| 145 | StopWatch sw = new StopWatch("receice mawbFedex"); | 145 | StopWatch sw = new StopWatch("receice mawbFedex"); |
| 146 | sw.start("save log"); | 146 | sw.start("save log"); |
| 147 | 147 | ||
| ... | @@ -172,7 +172,7 @@ public class FedexDataInterface { | ... | @@ -172,7 +172,7 @@ public class FedexDataInterface { |
| 172 | 172 | ||
| 173 | //2、TODO 校验主单 | 173 | //2、TODO 校验主单 |
| 174 | sw.start("checkFedexMawb"); | 174 | sw.start("checkFedexMawb"); |
| 175 | - result=fedexService.checkFedexMawb(saveMawbFedexResult); | 175 | + result=fedexService.checkFedexMawb(saveMawbFedexResult,null); |
| 176 | if(!result.getSuccess()){ | 176 | if(!result.getSuccess()){ |
| 177 | return result; | 177 | return result; |
| 178 | } | 178 | } | ... | ... |
| 1 | package com.erry.iclear.dateInterface.common; | 1 | package com.erry.iclear.dateInterface.common; |
| 2 | 2 | ||
| 3 | -import com.erry.iclear.dateInterface.entity.ChmCarryPort; | 3 | +import com.erry.iclear.dateInterface.entity.*; |
| 4 | -import com.erry.iclear.dateInterface.entity.DictionaryEntries; | ||
| 5 | -import com.erry.iclear.dateInterface.entity.DomesticDestinationMapping; | ||
| 6 | -import com.erry.iclear.dateInterface.entity.OrigplacecodeMapping; | ||
| 7 | import org.springframework.stereotype.Component; | 4 | import org.springframework.stereotype.Component; |
| 8 | 5 | ||
| 9 | import java.util.HashMap; | 6 | import java.util.HashMap; |
| ... | @@ -21,6 +18,11 @@ public class Constant { | ... | @@ -21,6 +18,11 @@ public class Constant { |
| 21 | public static Map<String,HashMap<String,String>> appIdSecurityCache = new HashMap<>(); | 18 | public static Map<String,HashMap<String,String>> appIdSecurityCache = new HashMap<>(); |
| 22 | 19 | ||
| 23 | /** | 20 | /** |
| 21 | + * APP INFO信息 | ||
| 22 | + */ | ||
| 23 | + public static Map<String,AppInfo> appInfoCache = new HashMap<>(); | ||
| 24 | + | ||
| 25 | + /** | ||
| 24 | * 字典表 code:entity | 26 | * 字典表 code:entity |
| 25 | */ | 27 | */ |
| 26 | public static Map<String , DictionaryEntries> dictionaryEntriesCache = new HashMap<>(); | 28 | public static Map<String , DictionaryEntries> dictionaryEntriesCache = new HashMap<>(); | ... | ... |
| ... | @@ -34,5 +34,9 @@ public class AppInfo implements Serializable { | ... | @@ -34,5 +34,9 @@ public class AppInfo implements Serializable { |
| 34 | @Column(name = "IS_ENABLE") | 34 | @Column(name = "IS_ENABLE") |
| 35 | private String isEnable; | 35 | private String isEnable; |
| 36 | 36 | ||
| 37 | - | 37 | + /** |
| 38 | + * C类校验是否校验运单号,非空则不校验 | ||
| 39 | + */ | ||
| 40 | + @Column(name = "C_CODE_CHECK") | ||
| 41 | + private String codeCheck; | ||
| 38 | } | 42 | } | ... | ... |
| ... | @@ -416,6 +416,11 @@ public class ChmConsignment implements Serializable { | ... | @@ -416,6 +416,11 @@ public class ChmConsignment implements Serializable { |
| 416 | @OneToMany(mappedBy = "chmConsignment", cascade = CascadeType.ALL) | 416 | @OneToMany(mappedBy = "chmConsignment", cascade = CascadeType.ALL) |
| 417 | private List<ChmConsignmentDetail> chmConsignmentDetailList; | 417 | private List<ChmConsignmentDetail> chmConsignmentDetailList; |
| 418 | 418 | ||
| 419 | + /** | ||
| 420 | + * C类校验是否校验运单号,非空则不校验 | ||
| 421 | + */ | ||
| 422 | + @Transient | ||
| 423 | + private String codeCheck; | ||
| 419 | 424 | ||
| 420 | @Override | 425 | @Override |
| 421 | public String toString() { | 426 | public String toString() { | ... | ... |
| ... | @@ -43,6 +43,7 @@ public class AppInfoService { | ... | @@ -43,6 +43,7 @@ public class AppInfoService { |
| 43 | HashMap<String, String> appkeyMap = new HashMap<String, String>(); | 43 | HashMap<String, String> appkeyMap = new HashMap<String, String>(); |
| 44 | appkeyMap.put(appInfo.getAppKey(), appInfo.getSecurity()); | 44 | appkeyMap.put(appInfo.getAppKey(), appInfo.getSecurity()); |
| 45 | Constant.appIdSecurityCache.put(appInfo.getAppId(), appkeyMap); | 45 | Constant.appIdSecurityCache.put(appInfo.getAppId(), appkeyMap); |
| 46 | + Constant.appInfoCache.put(appInfo.getAppId()+appInfo.getAppKey(),appInfo); | ||
| 46 | } | 47 | } |
| 47 | } catch (Exception e) { | 48 | } catch (Exception e) { |
| 48 | log.error("initAppInfo() error" + e.getMessage()); | 49 | log.error("initAppInfo() error" + e.getMessage()); | ... | ... |
| ... | @@ -242,7 +242,7 @@ public class ChmConsignmentService { | ... | @@ -242,7 +242,7 @@ public class ChmConsignmentService { |
| 242 | return result; | 242 | return result; |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | - public ChmConsignment convertToChmConsignmentFedex(FedexMawb mawb, Date pushTime, String creator){ | 245 | + public ChmConsignment convertToChmConsignmentFedex(FedexMawb mawb, Date pushTime, String creator,AppInfo appInfo){ |
| 246 | ChmConsignment result = new ChmConsignment(); | 246 | ChmConsignment result = new ChmConsignment(); |
| 247 | try{ | 247 | try{ |
| 248 | //运单号 | 248 | //运单号 |
| ... | @@ -259,6 +259,11 @@ public class ChmConsignmentService { | ... | @@ -259,6 +259,11 @@ public class ChmConsignmentService { |
| 259 | result.setTradeModeDic(tradeModeDictionaryEntries); | 259 | result.setTradeModeDic(tradeModeDictionaryEntries); |
| 260 | result.setTradeMode(tradeModeDictionaryEntries.getChineseName()); | 260 | result.setTradeMode(tradeModeDictionaryEntries.getChineseName()); |
| 261 | }*/ | 261 | }*/ |
| 262 | + if(appInfo != null){ | ||
| 263 | + //C类校验是否校验运单号,非空则不校验 | ||
| 264 | + result.setCodeCheck(appInfo.getCodeCheck()); | ||
| 265 | + } | ||
| 266 | + | ||
| 262 | //境内收发货人社会信用证代码 | 267 | //境内收发货人社会信用证代码 |
| 263 | result.setTradeCoSCC(mawb.getTradeCodeScc()); | 268 | result.setTradeCoSCC(mawb.getTradeCodeScc()); |
| 264 | //境内发货人(经营单位编码) | 269 | //境内发货人(经营单位编码) |
| ... | @@ -578,7 +583,7 @@ public class ChmConsignmentService { | ... | @@ -578,7 +583,7 @@ public class ChmConsignmentService { |
| 578 | ResultRS result = new ResultRS(Boolean.FALSE,null,null); | 583 | ResultRS result = new ResultRS(Boolean.FALSE,null,null); |
| 579 | try { | 584 | try { |
| 580 | Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp)); | 585 | Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp)); |
| 581 | - ChmConsignment chmConsignment = this.convertToChmConsignmentFedex(fedexMawb,pushTime,creator); | 586 | + ChmConsignment chmConsignment = this.convertToChmConsignmentFedex(fedexMawb,pushTime,creator,null); |
| 582 | if(Objects.equals(chmConsignment,null)){ | 587 | if(Objects.equals(chmConsignment,null)){ |
| 583 | result.setCode(ErrorCodeEnum.ERROR_30001.getCode()); | 588 | result.setCode(ErrorCodeEnum.ERROR_30001.getCode()); |
| 584 | result.setMsg(ErrorCodeEnum.ERROR_30001.getName()); | 589 | result.setMsg(ErrorCodeEnum.ERROR_30001.getName()); | ... | ... |
| ... | @@ -4,6 +4,7 @@ import com.erry.iclear.dateInterface.ErrorCodeEnum; | ... | @@ -4,6 +4,7 @@ import com.erry.iclear.dateInterface.ErrorCodeEnum; |
| 4 | import com.erry.iclear.dateInterface.api.request.*; | 4 | import com.erry.iclear.dateInterface.api.request.*; |
| 5 | import com.erry.iclear.dateInterface.api.response.IClearCheckResponseResult; | 5 | import com.erry.iclear.dateInterface.api.response.IClearCheckResponseResult; |
| 6 | import com.erry.iclear.dateInterface.api.response.ResultRS; | 6 | import com.erry.iclear.dateInterface.api.response.ResultRS; |
| 7 | +import com.erry.iclear.dateInterface.entity.AppInfo; | ||
| 7 | import com.erry.iclear.dateInterface.entity.ChmConsignment; | 8 | import com.erry.iclear.dateInterface.entity.ChmConsignment; |
| 8 | import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; | 9 | import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; |
| 9 | import com.erry.iclear.dateInterface.repository.FedexMawbRepository; | 10 | import com.erry.iclear.dateInterface.repository.FedexMawbRepository; |
| ... | @@ -112,13 +113,13 @@ public class FedexService { | ... | @@ -112,13 +113,13 @@ public class FedexService { |
| 112 | * @param fedexMawb | 113 | * @param fedexMawb |
| 113 | * @return | 114 | * @return |
| 114 | */ | 115 | */ |
| 115 | - public ResultRS checkFedexMawb(FedexMawb fedexMawb){ | 116 | + public ResultRS checkFedexMawb(FedexMawb fedexMawb,AppInfo appInfo){ |
| 116 | ResultRS result = new ResultRS(Boolean.FALSE,null,null); | 117 | ResultRS result = new ResultRS(Boolean.FALSE,null,null); |
| 117 | try{ | 118 | try{ |
| 118 | log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(fedexMawb)); | 119 | log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(fedexMawb)); |
| 119 | 120 | ||
| 120 | //1、将请求转换为运单 | 121 | //1、将请求转换为运单 |
| 121 | - ChmConsignment chmConsignment=consignmentService.convertToChmConsignmentFedex(fedexMawb,null,"IDE-ICLEAR-API"); | 122 | + ChmConsignment chmConsignment=consignmentService.convertToChmConsignmentFedex(fedexMawb,null,"IDE-ICLEAR-API",appInfo); |
| 122 | if(Objects.equals(chmConsignment,null)){ | 123 | if(Objects.equals(chmConsignment,null)){ |
| 123 | result.setCode(ErrorCodeEnum.ERROR_7.getCode()); | 124 | result.setCode(ErrorCodeEnum.ERROR_7.getCode()); |
| 124 | result.setMsg(ErrorCodeEnum.ERROR_7.getName()); | 125 | result.setMsg(ErrorCodeEnum.ERROR_7.getName()); |
| ... | @@ -166,7 +167,7 @@ public class FedexService { | ... | @@ -166,7 +167,7 @@ public class FedexService { |
| 166 | * @param fedexc | 167 | * @param fedexc |
| 167 | * @return | 168 | * @return |
| 168 | */ | 169 | */ |
| 169 | - public ResultRS checkBasfInterfaceData(Fedexc fedexc){ | 170 | + public ResultRS checkBasfInterfaceData(Fedexc fedexc, AppInfo appInfo){ |
| 170 | 171 | ||
| 171 | ResultRS result = new ResultRS(Boolean.FALSE,"",""); | 172 | ResultRS result = new ResultRS(Boolean.FALSE,"",""); |
| 172 | 173 | ||
| ... | @@ -177,7 +178,8 @@ public class FedexService { | ... | @@ -177,7 +178,8 @@ public class FedexService { |
| 177 | List<String> msgList = new ArrayList<>(); | 178 | List<String> msgList = new ArrayList<>(); |
| 178 | // 参数consignmentCode不能为空 | 179 | // 参数consignmentCode不能为空 |
| 179 | String consignmentCode = fedexc.getConsignmentCode(); | 180 | String consignmentCode = fedexc.getConsignmentCode(); |
| 180 | - if(StringUtils.isEmpty(consignmentCode)){ | 181 | + //C类校验是否校验运单号,非空则不校验 |
| 182 | + if(appInfo.getCodeCheck() == null && StringUtils.isEmpty(consignmentCode)){ | ||
| 181 | msgList.add("参数consignmentCode不能为空"); | 183 | msgList.add("参数consignmentCode不能为空"); |
| 182 | } | 184 | } |
| 183 | // 参数consignmentId不能为空 | 185 | // 参数consignmentId不能为空 | ... | ... |
| ... | @@ -40,22 +40,22 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests { | ... | @@ -40,22 +40,22 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests { |
| 40 | 40 | ||
| 41 | @Test | 41 | @Test |
| 42 | public void testProcessChmConsignment1(){ | 42 | public void testProcessChmConsignment1(){ |
| 43 | - try{ | 43 | +// try{ |
| 44 | - ResultRS result = new ResultRS(Boolean.FALSE,"",""); | 44 | +// ResultRS result = new ResultRS(Boolean.FALSE,"",""); |
| 45 | - Fedexc fedexc = this.createNewFedex(); | 45 | +// Fedexc fedexc = this.createNewFedex(); |
| 46 | - FedexMawb mawb = fedexService.saveMawbFedex(fedexc); | 46 | +// FedexMawb mawb = fedexService.saveMawbFedex(fedexc); |
| 47 | - //Basfc fedexc = this.createNewBasf(); | 47 | +// //Basfc fedexc = this.createNewBasf(); |
| 48 | - String timeStamp = String.valueOf(new Date().getTime()); | 48 | +// String timeStamp = String.valueOf(new Date().getTime()); |
| 49 | - ResultRS resultRS = chmConsignmentService.processChmConsignmentFedex(mawb, timeStamp, "BASF"); | 49 | +// ResultRS resultRS = chmConsignmentService.processChmConsignmentFedex(mawb, timeStamp, "BASF"); |
| 50 | - /*result=fedexService.checkBasfMawb(mawb); | 50 | +// /*result=fedexService.checkBasfMawb(mawb); |
| 51 | - if(!result.getSuccess()){ | 51 | +// if(!result.getSuccess()){ |
| 52 | - System.out.println(result.getMsg()); | 52 | +// System.out.println(result.getMsg()); |
| 53 | - }*/ | 53 | +// }*/ |
| 54 | - System.out.println(resultRS.toString()); | 54 | +// System.out.println(resultRS.toString()); |
| 55 | - }catch (Exception e){ | 55 | +// }catch (Exception e){ |
| 56 | - e.printStackTrace(); | 56 | +// e.printStackTrace(); |
| 57 | - } | 57 | +// } |
| 58 | - System.out.println("1"); | 58 | +// System.out.println("1"); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | private Fedexc createNewFedex(){ | 61 | private Fedexc createNewFedex(){ | ... | ... |
-
Please register or login to post a comment