Showing
11 changed files
with
108 additions
and
38 deletions
No preview for this file type
| ... | @@ -88,21 +88,21 @@ public class CustomsDataInterface { | ... | @@ -88,21 +88,21 @@ public class CustomsDataInterface { |
| 88 | sw.stop(); | 88 | sw.stop(); |
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | - //2、TODO 校验主单 | 91 | +// //2、TODO 校验主单 |
| 92 | - sw.start("checkMawb"); | 92 | +// sw.start("checkMawb"); |
| 93 | - result=mawbService.checkMawb(mawb); | 93 | +// result=mawbService.checkMawb(mawb); |
| 94 | - if(!result.getSuccess()){ | 94 | +// if(!result.getSuccess()){ |
| 95 | - return result; | 95 | +// return result; |
| 96 | - } | 96 | +// } |
| 97 | - sw.stop(); | 97 | +// sw.stop(); |
| 98 | - | 98 | + |
| 99 | - //3、TODO 校验子单 | 99 | +// //3、TODO 校验子单 |
| 100 | - sw.start("checkMawbDetail"); | 100 | +// sw.start("checkMawbDetail"); |
| 101 | - result=mawbDetailServicel.checkMawbDetail(mawb); | 101 | +// result=mawbDetailServicel.checkMawbDetail(mawb); |
| 102 | - if(!result.getSuccess()){ | 102 | +// if(!result.getSuccess()){ |
| 103 | - return result; | 103 | +// return result; |
| 104 | - } | 104 | +// } |
| 105 | - sw.stop(); | 105 | +// sw.stop(); |
| 106 | 106 | ||
| 107 | 107 | ||
| 108 | //4、保存运单到iclear中 | 108 | //4、保存运单到iclear中 | ... | ... |
| ... | @@ -51,12 +51,12 @@ public class Mawb implements Serializable { | ... | @@ -51,12 +51,12 @@ public class Mawb implements Serializable { |
| 51 | private String type; | 51 | private String type; |
| 52 | 52 | ||
| 53 | @ApiModelProperty(value = "申报单位代码", name = "agentCode", example = "固定值:1111980005") | 53 | @ApiModelProperty(value = "申报单位代码", name = "agentCode", example = "固定值:1111980005") |
| 54 | - @NotBlank(message="参数agentCode不能为空") | 54 | + //@NotBlank(message="参数agentCode不能为空") |
| 55 | @Column(name = "AGENTCODE") | 55 | @Column(name = "AGENTCODE") |
| 56 | private String agentCode; | 56 | private String agentCode; |
| 57 | 57 | ||
| 58 | @ApiModelProperty(value = "申报单位名称", name = "agentName", example = "固定值:联邦快递(中国)有限公司") | 58 | @ApiModelProperty(value = "申报单位名称", name = "agentName", example = "固定值:联邦快递(中国)有限公司") |
| 59 | - @NotBlank(message="参数agentName不能为空") | 59 | + //@NotBlank(message="参数agentName不能为空") |
| 60 | @Column(name = "AGENTNAME") | 60 | @Column(name = "AGENTNAME") |
| 61 | private String agentName; | 61 | private String agentName; |
| 62 | 62 | ||
| ... | @@ -80,7 +80,7 @@ public class Mawb implements Serializable { | ... | @@ -80,7 +80,7 @@ public class Mawb implements Serializable { |
| 80 | private String cutMode; | 80 | private String cutMode; |
| 81 | 81 | ||
| 82 | @ApiModelProperty(value = "报关/转关关系标志", name = "declTrnRel", example = "固定值:0") | 82 | @ApiModelProperty(value = "报关/转关关系标志", name = "declTrnRel", example = "固定值:0") |
| 83 | - @NotBlank(message="参数declTrnRel不能为空") | 83 | + //@NotBlank(message="参数declTrnRel不能为空") |
| 84 | @Column(name = "DECLTRNREL") | 84 | @Column(name = "DECLTRNREL") |
| 85 | private String declTrnRel; | 85 | private String declTrnRel; |
| 86 | 86 | ... | ... |
| 1 | +package com.erry.iclear.dateInterface.api.response; | ||
| 2 | + | ||
| 3 | +import lombok.AllArgsConstructor; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.io.Serializable; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@AllArgsConstructor | ||
| 10 | +public class IClearCheckResponseResult implements Serializable { | ||
| 11 | + //成功标识 | ||
| 12 | + private Boolean success = false; | ||
| 13 | + private String message; | ||
| 14 | +} |
| ... | @@ -88,7 +88,7 @@ public class Constant { | ... | @@ -88,7 +88,7 @@ public class Constant { |
| 88 | 88 | ||
| 89 | public static String DECLARED_DOC_TYPE="declaredDocType_"; | 89 | public static String DECLARED_DOC_TYPE="declaredDocType_"; |
| 90 | 90 | ||
| 91 | - | 91 | + public static String DECLARED_DOC_TYPE_ZERO="declaredDocType_00"; |
| 92 | 92 | ||
| 93 | 93 | ||
| 94 | } | 94 | } | ... | ... |
| ... | @@ -103,6 +103,11 @@ public class ApiService { | ... | @@ -103,6 +103,11 @@ public class ApiService { |
| 103 | public void pushCustoms(String token){ | 103 | public void pushCustoms(String token){ |
| 104 | //获取海关回执数据 | 104 | //获取海关回执数据 |
| 105 | List<ReceiptMessage> receiptMessageList = this.receiptMessageRepository.findReceiptMessageList(); | 105 | List<ReceiptMessage> receiptMessageList = this.receiptMessageRepository.findReceiptMessageList(); |
| 106 | + //去除微秒 | ||
| 107 | + for(int i = 0 ; i < receiptMessageList.size() ; i ++){ | ||
| 108 | + ReceiptMessage receiptMessage = receiptMessageList.get(i); | ||
| 109 | + receiptMessage.setNoticeDate(receiptMessage.getNoticeDate().substring(0,receiptMessage.getNoticeDate().length() - 4)); | ||
| 110 | + } | ||
| 106 | this.sendCustoms(token,receiptMessageList); | 111 | this.sendCustoms(token,receiptMessageList); |
| 107 | } | 112 | } |
| 108 | 113 | ||
| ... | @@ -140,7 +145,7 @@ public class ApiService { | ... | @@ -140,7 +145,7 @@ public class ApiService { |
| 140 | declearTask.setResponseResults(tokenResult.getErrorcode()); | 145 | declearTask.setResponseResults(tokenResult.getErrorcode()); |
| 141 | declearTask.setResponseContent(tokenResult.getErrormessage()); | 146 | declearTask.setResponseContent(tokenResult.getErrormessage()); |
| 142 | declearTaskList.add(declearTask); | 147 | declearTaskList.add(declearTask); |
| 143 | - }else if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10004)){ | 148 | + }else if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10004) || tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10013)){ |
| 144 | //如果凭证失效,则刷新凭证 | 149 | //如果凭证失效,则刷新凭证 |
| 145 | refreshToken(token); | 150 | refreshToken(token); |
| 146 | }else{ | 151 | }else{ |
| ... | @@ -238,7 +243,7 @@ public class ApiService { | ... | @@ -238,7 +243,7 @@ public class ApiService { |
| 238 | declearTask.setResponseResults(tokenResult.getErrorcode()); | 243 | declearTask.setResponseResults(tokenResult.getErrorcode()); |
| 239 | declearTask.setResponseContent(tokenResult.getErrormessage()); | 244 | declearTask.setResponseContent(tokenResult.getErrormessage()); |
| 240 | declearTaskList.add(declearTask); | 245 | declearTaskList.add(declearTask); |
| 241 | - }else if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10004)){ | 246 | + }else if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10004) || tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10013)){ |
| 242 | //如果凭证失效,则刷新凭证 | 247 | //如果凭证失效,则刷新凭证 |
| 243 | refreshToken(token); | 248 | refreshToken(token); |
| 244 | }else{ | 249 | }else{ | ... | ... |
| ... | @@ -78,8 +78,11 @@ public class ChmConsignmentService { | ... | @@ -78,8 +78,11 @@ public class ChmConsignmentService { |
| 78 | result.setThroughStopPortDic(chmCarryPort); | 78 | result.setThroughStopPortDic(chmCarryPort); |
| 79 | result.setThroughStopPort(chmCarryPort.getPortNo()); | 79 | result.setThroughStopPort(chmCarryPort.getPortNo()); |
| 80 | } | 80 | } |
| 81 | - //TODO 报关标志【待确认】 | 81 | + //TODO 报关标志【已确认】,IDE传递的是1,Export中是001,需要进行转换,如果是空,则转换成1 |
| 82 | - DictionaryEntries declaredDocTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.DECLARED_DOC_TYPE + mawb.getEdiId()); | 82 | + if(mawb.getEdiId() == null){ |
| 83 | + mawb.setEdiId("1"); | ||
| 84 | + } | ||
| 85 | + DictionaryEntries declaredDocTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.DECLARED_DOC_TYPE + Constant.DECLARED_DOC_TYPE_ZERO + mawb.getEdiId()); | ||
| 83 | if(!Objects.equals(declaredDocTypeDictionaryEntries,null)){ | 86 | if(!Objects.equals(declaredDocTypeDictionaryEntries,null)){ |
| 84 | result.setDeclaredDocTypeDic(declaredDocTypeDictionaryEntries); | 87 | result.setDeclaredDocTypeDic(declaredDocTypeDictionaryEntries); |
| 85 | result.setDeclaredDocType(declaredDocTypeDictionaryEntries.getChineseName()); | 88 | result.setDeclaredDocType(declaredDocTypeDictionaryEntries.getChineseName()); |
| ... | @@ -142,7 +145,7 @@ public class ChmConsignmentService { | ... | @@ -142,7 +145,7 @@ public class ChmConsignmentService { |
| 142 | result.setConsType(consType.getChineseName()); | 145 | result.setConsType(consType.getChineseName()); |
| 143 | } | 146 | } |
| 144 | //监管方式 | 147 | //监管方式 |
| 145 | - DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.SUPERVISION_MODE+mawb.getTradeMode()); | 148 | + DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.SUPERVISION_MODE+Integer.parseInt(mawb.getTradeMode())); |
| 146 | if(!Objects.equals(tradeModeDictionaryEntries,null)){ | 149 | if(!Objects.equals(tradeModeDictionaryEntries,null)){ |
| 147 | result.setTradeModeDic(tradeModeDictionaryEntries); | 150 | result.setTradeModeDic(tradeModeDictionaryEntries); |
| 148 | result.setTradeMode(tradeModeDictionaryEntries.getChineseName()); | 151 | result.setTradeMode(tradeModeDictionaryEntries.getChineseName()); |
| ... | @@ -236,13 +239,8 @@ public class ChmConsignmentService { | ... | @@ -236,13 +239,8 @@ public class ChmConsignmentService { |
| 236 | result.setAgentCode("1111980005"); | 239 | result.setAgentCode("1111980005"); |
| 237 | //申报单位名称:固定值 联邦快递(中国)有限公司 | 240 | //申报单位名称:固定值 联邦快递(中国)有限公司 |
| 238 | result.setAgentName("联邦快递(中国)有限公司"); | 241 | result.setAgentName("联邦快递(中国)有限公司"); |
| 239 | - //提单号:有总单号则取值“总单号_运单号”,没有总单号则取值“运单号” | 242 | + //运单号 |
| 240 | - //总单号不为空 | 243 | + result.setBillNo(consignment.getConsignmentCode()); |
| 241 | - if(StringUtils.isNotBlank(consignment.getConsignmentHeadCode())){ | ||
| 242 | - result.setBillNo(consignment.getConsignmentHeadCode() + "_" + consignment.getConsignmentCode()); | ||
| 243 | - }else{ | ||
| 244 | - result.setBillNo(consignment.getConsignmentCode()); | ||
| 245 | - } | ||
| 246 | //合同号 最大长度32 | 244 | //合同号 最大长度32 |
| 247 | result.setContrNo(consignment.getContractCode()); | 245 | result.setContrNo(consignment.getContractCode()); |
| 248 | //主管海关(申报地海关) 固定值 0101 | 246 | //主管海关(申报地海关) 固定值 0101 |
| ... | @@ -258,9 +256,10 @@ public class ChmConsignmentService { | ... | @@ -258,9 +256,10 @@ public class ChmConsignmentService { |
| 258 | result.setDistinatePort(consignment.getThroughStopPortDic().getPcCode()); | 256 | result.setDistinatePort(consignment.getThroughStopPortDic().getPcCode()); |
| 259 | } | 257 | } |
| 260 | 258 | ||
| 261 | - //报关标志 数字三字码或英文二字码 | 259 | + //TODO 报关标志【已确认】,IDE传递的是1,Export中是001,需要进行转换 数字三字码或英文二字码 |
| 262 | if(!Objects.equals(consignment.getDeclaredDocTypeDic(),null)){ | 260 | if(!Objects.equals(consignment.getDeclaredDocTypeDic(),null)){ |
| 263 | - result.setEdiId(consignment.getDeclaredDocTypeDic().getExt2()); | 261 | + Integer ediid = Integer.parseInt(consignment.getDeclaredDocTypeDic().getExt2()); |
| 262 | + result.setEdiId(ediid.toString()); | ||
| 264 | } | 263 | } |
| 265 | //海关编号 | 264 | //海关编号 |
| 266 | result.setEntryId(consignment.getCustomsNo()); | 265 | result.setEntryId(consignment.getCustomsNo()); | ... | ... |
| 1 | package com.erry.iclear.dateInterface.service; | 1 | package com.erry.iclear.dateInterface.service; |
| 2 | 2 | ||
| 3 | +import com.arronlong.httpclientutil.HttpClientUtil; | ||
| 4 | +import com.arronlong.httpclientutil.common.HttpConfig; | ||
| 5 | +import com.arronlong.httpclientutil.common.HttpHeader; | ||
| 3 | import com.erry.iclear.dateInterface.api.request.Mawb; | 6 | import com.erry.iclear.dateInterface.api.request.Mawb; |
| 7 | +import com.erry.iclear.dateInterface.api.response.IClearCheckResponseResult; | ||
| 4 | import com.erry.iclear.dateInterface.api.response.ResultRS; | 8 | import com.erry.iclear.dateInterface.api.response.ResultRS; |
| 9 | +import com.erry.iclear.dateInterface.api.response.TokenResult; | ||
| 10 | +import com.erry.iclear.dateInterface.entity.ChmConsignment; | ||
| 11 | +import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; | ||
| 5 | import com.erry.iclear.dateInterface.repository.MawbRepository; | 12 | import com.erry.iclear.dateInterface.repository.MawbRepository; |
| 13 | +import com.erry.iclear.dateInterface.util.JsonToJava; | ||
| 6 | import com.google.gson.Gson; | 14 | import com.google.gson.Gson; |
| 7 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 16 | +import org.apache.http.Header; | ||
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | +import org.springframework.beans.factory.annotation.Value; | ||
| 9 | import org.springframework.scheduling.annotation.Scheduled; | 19 | import org.springframework.scheduling.annotation.Scheduled; |
| 10 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 11 | 21 | ||
| 22 | +import java.util.ArrayList; | ||
| 23 | +import java.util.List; | ||
| 24 | +import java.util.Objects; | ||
| 25 | + | ||
| 12 | /** | 26 | /** |
| 13 | * @author Administrator | 27 | * @author Administrator |
| 14 | */ | 28 | */ |
| ... | @@ -18,9 +32,18 @@ public class MawbService { | ... | @@ -18,9 +32,18 @@ public class MawbService { |
| 18 | 32 | ||
| 19 | private Gson gson = new Gson(); | 33 | private Gson gson = new Gson(); |
| 20 | 34 | ||
| 35 | + @Value("${api.address.iclear-check-url}") | ||
| 36 | + String iclearCheckUrl; | ||
| 37 | + | ||
| 21 | @Autowired | 38 | @Autowired |
| 22 | private MawbRepository mawbRepository; | 39 | private MawbRepository mawbRepository; |
| 23 | 40 | ||
| 41 | + @Autowired | ||
| 42 | + private ChmConsignmentService consignmentService; | ||
| 43 | + | ||
| 44 | + @Autowired | ||
| 45 | + private ChmConsignmentDetailService consignmentDetailService; | ||
| 46 | + | ||
| 24 | /** | 47 | /** |
| 25 | * 保存主单Request | 48 | * 保存主单Request |
| 26 | * @param mawb | 49 | * @param mawb |
| ... | @@ -48,15 +71,38 @@ public class MawbService { | ... | @@ -48,15 +71,38 @@ public class MawbService { |
| 48 | try{ | 71 | try{ |
| 49 | log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(mawb)); | 72 | log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(mawb)); |
| 50 | 73 | ||
| 74 | + //1、将请求转换为运单 | ||
| 75 | + ChmConsignment chmConsignment=consignmentService.convertToChmConsignment(mawb,null,"IDE-ICLEAR-API"); | ||
| 76 | + if(Objects.equals(chmConsignment,null)){ | ||
| 77 | + result.setCode("30001"); | ||
| 78 | + result.setMsg("数据格式不正确"); | ||
| 79 | + return result; | ||
| 80 | + } | ||
| 81 | + List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>(); | ||
| 82 | + mawb.getMawbDetailList().forEach(detail ->{ | ||
| 83 | + chmConsignmentDetailList.add(consignmentDetailService.convertToChmConsignmentDetail(detail,chmConsignment)); | ||
| 84 | + }); | ||
| 85 | + chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList); | ||
| 51 | 86 | ||
| 52 | - | 87 | + //调用IClear接口进行运单数据校验 |
| 53 | - | 88 | + String objJson = JsonToJava.toJson(chmConsignment); |
| 54 | - result.setSuccess(Boolean.TRUE); | 89 | + Header[] headers = HttpHeader.custom() |
| 55 | - log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(mawb) +" result :" +result.getSuccess() ); | 90 | + .other("Content-Type", "application/json") |
| 91 | + .build(); | ||
| 92 | + //推送海关回执数据 | ||
| 93 | + HttpConfig config = HttpConfig.custom() | ||
| 94 | + .headers(headers) | ||
| 95 | + .url(this.iclearCheckUrl) | ||
| 96 | + .encoding("utf-8") | ||
| 97 | + .json(objJson); | ||
| 98 | + String json = HttpClientUtil.post(config); | ||
| 99 | + IClearCheckResponseResult iclearCheckResponseResult = JsonToJava.parseJson(json, IClearCheckResponseResult.class); | ||
| 100 | + result.setSuccess(iclearCheckResponseResult.getSuccess()); | ||
| 101 | + result.setMsg(iclearCheckResponseResult.getMessage()); | ||
| 102 | + log.info("checkMawb start>>>>>>>>>> mawb:"+gson.toJson(mawb) +" result :" +result.getSuccess() +" iclear check response : " + json + " status : " + result.getSuccess()); | ||
| 56 | }catch (Exception e){ | 103 | }catch (Exception e){ |
| 57 | log.error("checkMawb() error:" + e.getMessage()); | 104 | log.error("checkMawb() error:" + e.getMessage()); |
| 58 | } | 105 | } |
| 59 | return result; | 106 | return result; |
| 60 | } | 107 | } |
| 61 | - | ||
| 62 | } | 108 | } | ... | ... |
| ... | @@ -20,6 +20,8 @@ api: | ... | @@ -20,6 +20,8 @@ api: |
| 20 | #获取token密码 | 20 | #获取token密码 |
| 21 | password: toQu3arch6 | 21 | password: toQu3arch6 |
| 22 | address: | 22 | address: |
| 23 | + #IClear校验运单地址 | ||
| 24 | + iclear-check-url: http://192.168.1.253:8080/chmConsignmentController/checkChmAndDetaliD | ||
| 23 | #获取token地址 | 25 | #获取token地址 |
| 24 | token-url: https://apiuat.iclrccd-fedex.com/login | 26 | token-url: https://apiuat.iclrccd-fedex.com/login |
| 25 | #刷新token地址 | 27 | #刷新token地址 | ... | ... |
| ... | @@ -20,6 +20,8 @@ api: | ... | @@ -20,6 +20,8 @@ api: |
| 20 | #获取token密码 | 20 | #获取token密码 |
| 21 | password: toQu3arch6 | 21 | password: toQu3arch6 |
| 22 | address: | 22 | address: |
| 23 | + #IClear校验运单地址 | ||
| 24 | + iclear-check-url: https://www.iclrccd-fedex.com/chmConsignmentController/checkChmAndDetaliD | ||
| 23 | #获取token地址 | 25 | #获取token地址 |
| 24 | token-url: https://api.iclrccd-fedex.com/export/login | 26 | token-url: https://api.iclrccd-fedex.com/export/login |
| 25 | #刷新token地址 | 27 | #刷新token地址 | ... | ... |
| ... | @@ -20,6 +20,8 @@ api: | ... | @@ -20,6 +20,8 @@ api: |
| 20 | #获取token密码 | 20 | #获取token密码 |
| 21 | password: toQu3arch6 | 21 | password: toQu3arch6 |
| 22 | address: | 22 | address: |
| 23 | + #IClear校验运单地址 | ||
| 24 | + iclear-check-url: http://40.73.78.157:8081/chmConsignmentController/checkChmAndDetaliD | ||
| 23 | #获取token地址 | 25 | #获取token地址 |
| 24 | token-url: https://apiuat.iclrccd-fedex.com/login | 26 | token-url: https://apiuat.iclrccd-fedex.com/login |
| 25 | #刷新token地址 | 27 | #刷新token地址 | ... | ... |
-
Please register or login to post a comment