Showing
7 changed files
with
51 additions
and
87 deletions
| ... | @@ -33,13 +33,12 @@ CREATE TABLE T_ICLEAR_API_LOG( | ... | @@ -33,13 +33,12 @@ CREATE TABLE T_ICLEAR_API_LOG( |
| 33 | ,APPID VARCHAR(20) --用户ID | 33 | ,APPID VARCHAR(20) --用户ID |
| 34 | ,APPKEY VARCHAR(20) --用户key | 34 | ,APPKEY VARCHAR(20) --用户key |
| 35 | ,CREATE_TIME datetime --创建时间 | 35 | ,CREATE_TIME datetime --创建时间 |
| 36 | - ,UPDATE_TIME datetime --更新时间 | ||
| 37 | ,PUSH_TIME datetime --消息推送时间 | 36 | ,PUSH_TIME datetime --消息推送时间 |
| 38 | - --,REQUEST_MSG VARCHAR(500) | ||
| 39 | ,RECEIVE_RESULT VARCHAR(100) --记录接收后是否验证通过的结果 | 37 | ,RECEIVE_RESULT VARCHAR(100) --记录接收后是否验证通过的结果 |
| 38 | + ,ERROR_CODE VARCHAR(10) --错误代码 | ||
| 40 | ,RESPONSE_TIME datetime -- 响应时间 | 39 | ,RESPONSE_TIME datetime -- 响应时间 |
| 41 | ,SPEND_TIME numeric(5, 0) --消耗时间(ms) | 40 | ,SPEND_TIME numeric(5, 0) --消耗时间(ms) |
| 42 | - ,SENDTIMES datetime --更新次数 | 41 | + ,SENDTIMES int --更新次数 |
| 43 | ,BILLNO VARCHAR(20) --运单号 | 42 | ,BILLNO VARCHAR(20) --运单号 |
| 44 | ,CONTRNO VARCHAR(20) --合同号 | 43 | ,CONTRNO VARCHAR(20) --合同号 |
| 45 | ) | 44 | ) | ... | ... |
| ... | @@ -64,7 +64,7 @@ public class CustomsDataInterface { | ... | @@ -64,7 +64,7 @@ public class CustomsDataInterface { |
| 64 | String appId=(String) request.getHeader("Appid"); | 64 | String appId=(String) request.getHeader("Appid"); |
| 65 | String appKey=(String) request.getHeader("Appkey"); | 65 | String appKey=(String) request.getHeader("Appkey"); |
| 66 | String timeStamp=(String) request.getHeader("TimeStamp"); | 66 | String timeStamp=(String) request.getHeader("TimeStamp"); |
| 67 | - IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLog(mawb,appId,appKey,DateUtils.convertToDate(timeStamp))); | 67 | + IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLog(mawb,appId,appKey,new Date(Long.valueOf(timeStamp)))); |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | if(!Objects.equals(saveIClearApiLogResult,null)){ | 70 | if(!Objects.equals(saveIClearApiLogResult,null)){ |
| ... | @@ -124,6 +124,7 @@ public class CustomsDataInterface { | ... | @@ -124,6 +124,7 @@ public class CustomsDataInterface { |
| 124 | sw.start("updateIClearApiLog"); | 124 | sw.start("updateIClearApiLog"); |
| 125 | if(!Objects.equals(saveIClearApiLogResult,null)){ | 125 | if(!Objects.equals(saveIClearApiLogResult,null)){ |
| 126 | saveIClearApiLogResult.setReceiveResult(result.getSuccess().toString()); | 126 | saveIClearApiLogResult.setReceiveResult(result.getSuccess().toString()); |
| 127 | + saveIClearApiLogResult.setErrorCode(result.getCode()); | ||
| 127 | saveIClearApiLogResult.setResponseTime(new Date()); | 128 | saveIClearApiLogResult.setResponseTime(new Date()); |
| 128 | saveIClearApiLogResult.setSpendTime(sw.getTotalTimeMillis()); | 129 | saveIClearApiLogResult.setSpendTime(sw.getTotalTimeMillis()); |
| 129 | 130 | ... | ... |
| ... | @@ -40,4 +40,19 @@ public class IClearExportInterface { | ... | @@ -40,4 +40,19 @@ public class IClearExportInterface { |
| 40 | return "Faile"; | 40 | return "Faile"; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | + | ||
| 44 | + //TODO 根据已记录的MAWB生成 运单数据,用户处理解析失败时的策略 | ||
| 45 | + @ApiOperation(value = "重新生成运单", httpMethod = "GET", notes = "ex: http://192.168.1.75:8080/system/refreshSendMawbe") | ||
| 46 | + @GetMapping("/refreshSendMawbe") | ||
| 47 | + public String refreshSendMawbe() { | ||
| 48 | + try{ | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + return "Success"; | ||
| 52 | + }catch (Exception e){ | ||
| 53 | + log.error("refreshCache() error:"+e.getMessage()); | ||
| 54 | + } | ||
| 55 | + return "Faile"; | ||
| 56 | + } | ||
| 57 | + | ||
| 43 | } | 58 | } | ... | ... |
| ... | @@ -32,18 +32,15 @@ public class IClearApiLog implements Serializable { | ... | @@ -32,18 +32,15 @@ public class IClearApiLog implements Serializable { |
| 32 | @Column(name= "CREATE_TIME") | 32 | @Column(name= "CREATE_TIME") |
| 33 | private Date createTime; | 33 | private Date createTime; |
| 34 | 34 | ||
| 35 | - @Column(name= "UPDATE_TIME") | ||
| 36 | - private Date updateTime; | ||
| 37 | - | ||
| 38 | - //收到的json,用 T_ICLEAR_API_MAWB表保存 | ||
| 39 | - //@Column(name= "REQUEST_MSG") | ||
| 40 | - //private String request_msg; | ||
| 41 | @Column(name= "PUSH_TIME") | 35 | @Column(name= "PUSH_TIME") |
| 42 | private Date pushTime; | 36 | private Date pushTime; |
| 43 | 37 | ||
| 44 | @Column(name= "RECEIVE_RESULT") | 38 | @Column(name= "RECEIVE_RESULT") |
| 45 | private String receiveResult; | 39 | private String receiveResult; |
| 46 | 40 | ||
| 41 | + @Column(name= "ERROR_CODE") | ||
| 42 | + private String errorCode; | ||
| 43 | + | ||
| 47 | @Column(name= "RESPONSE_TIME") | 44 | @Column(name= "RESPONSE_TIME") |
| 48 | private Date responseTime; | 45 | private Date responseTime; |
| 49 | 46 | ... | ... |
| ... | @@ -277,6 +277,9 @@ public class ChmConsignmentService { | ... | @@ -277,6 +277,9 @@ public class ChmConsignmentService { |
| 277 | log.info("主单"+ mawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId()); | 277 | log.info("主单"+ mawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId()); |
| 278 | }else{ | 278 | }else{ |
| 279 | log.info("主单"+ mawb.getBillNo()+" 保存失败"); | 279 | log.info("主单"+ mawb.getBillNo()+" 保存失败"); |
| 280 | + result.setCode("30002"); | ||
| 281 | + result.setMsg("主单"+ mawb.getBillNo()+" 保存失败"); | ||
| 282 | + return result; | ||
| 280 | } | 283 | } |
| 281 | //更新: | 284 | //更新: |
| 282 | //如果有数据并且满足条件后才能更新数据 | 285 | //如果有数据并且满足条件后才能更新数据 |
| ... | @@ -317,13 +320,16 @@ public class ChmConsignmentService { | ... | @@ -317,13 +320,16 @@ public class ChmConsignmentService { |
| 317 | log.info("主单"+ mawb.getBillNo()+" 更新成功,chmConsignmentId:"+updateResult.getId()); | 320 | log.info("主单"+ mawb.getBillNo()+" 更新成功,chmConsignmentId:"+updateResult.getId()); |
| 318 | }else{ | 321 | }else{ |
| 319 | log.info("主单"+ mawb.getBillNo()+" 更新失败"); | 322 | log.info("主单"+ mawb.getBillNo()+" 更新失败"); |
| 323 | + result.setCode("30003"); | ||
| 324 | + result.setMsg("主单"+ mawb.getBillNo()+" 更新失败"); | ||
| 325 | + return result; | ||
| 320 | } | 326 | } |
| 321 | - | ||
| 322 | } | 327 | } |
| 323 | }catch (Exception e){ | 328 | }catch (Exception e){ |
| 324 | log.error(""+e.getMessage()); | 329 | log.error(""+e.getMessage()); |
| 325 | } | 330 | } |
| 326 | 331 | ||
| 332 | + result.setSuccess(Boolean.TRUE); | ||
| 327 | return result; | 333 | return result; |
| 328 | } | 334 | } |
| 329 | 335 | ... | ... |
| ... | @@ -45,7 +45,6 @@ public class IClearApiLogService { | ... | @@ -45,7 +45,6 @@ public class IClearApiLogService { |
| 45 | result.setAppId(appId); | 45 | result.setAppId(appId); |
| 46 | result.setAppKey(appKey); | 46 | result.setAppKey(appKey); |
| 47 | result.setCreateTime(new Date()); | 47 | result.setCreateTime(new Date()); |
| 48 | - result.setUpdateTime(new Date()); | ||
| 49 | result.setPushTime(pushTime); | 48 | result.setPushTime(pushTime); |
| 50 | result.setReceiveResult(null); | 49 | result.setReceiveResult(null); |
| 51 | result.setResponseTime(null); | 50 | result.setResponseTime(null); | ... | ... |
| ... | @@ -13,6 +13,7 @@ import com.erry.iclear.dateInterface.util.SHA256Util; | ... | @@ -13,6 +13,7 @@ import com.erry.iclear.dateInterface.util.SHA256Util; |
| 13 | import com.google.gson.Gson; | 13 | import com.google.gson.Gson; |
| 14 | import org.apache.http.client.HttpClient; | 14 | import org.apache.http.client.HttpClient; |
| 15 | import org.apache.http.Header; | 15 | import org.apache.http.Header; |
| 16 | + | ||
| 16 | import java.io.FileNotFoundException; | 17 | import java.io.FileNotFoundException; |
| 17 | import java.math.BigDecimal; | 18 | import java.math.BigDecimal; |
| 18 | import java.util.*; | 19 | import java.util.*; |
| ... | @@ -22,14 +23,13 @@ public class HttpClientTest { | ... | @@ -22,14 +23,13 @@ public class HttpClientTest { |
| 22 | // System.out.println(HttpClientUtil.get(HttpConfig.custom().url("https://40.73.78.157:8780/system/healthCheck"))); | 23 | // System.out.println(HttpClientUtil.get(HttpConfig.custom().url("https://40.73.78.157:8780/system/healthCheck"))); |
| 23 | // System.out.println(HttpClientUtil.post(HttpConfig.custom().url("https://40.73.78.157:8780/customs/sendMawb"))); | 24 | // System.out.println(HttpClientUtil.post(HttpConfig.custom().url("https://40.73.78.157:8780/customs/sendMawb"))); |
| 24 | 25 | ||
| 25 | - String timeStamp = "1623920478192"; | 26 | + //String timeStamp = "1623920478192"; |
| 26 | - //String timeStamp = "1624263798669"; | 27 | + String timeStamp = "1624263798669"; |
| 27 | System.out.println(new Date(Long.valueOf(timeStamp))); | 28 | System.out.println(new Date(Long.valueOf(timeStamp))); |
| 28 | - String token=SHA256Util.getSHA256String("IDE"+"iClearExport"+"b92131f03f19a348"+timeStamp); | 29 | + String token = SHA256Util.getSHA256String("IDE" + "iClearExport" + "b92131f03f19a348" + timeStamp); |
| 29 | System.out.println(token); | 30 | System.out.println(token); |
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | - | ||
| 33 | Header[] headers = HttpHeader.custom() | 33 | Header[] headers = HttpHeader.custom() |
| 34 | .other("Content-Type", "application/json") | 34 | .other("Content-Type", "application/json") |
| 35 | .other("Appid", "IDE") | 35 | .other("Appid", "IDE") |
| ... | @@ -38,68 +38,26 @@ public class HttpClientTest { | ... | @@ -38,68 +38,26 @@ public class HttpClientTest { |
| 38 | .other("token", token) | 38 | .other("token", token) |
| 39 | .build(); | 39 | .build(); |
| 40 | 40 | ||
| 41 | - //插件式配置生成HttpClient时所需参数(超时、连接池、ssl、重试) | ||
| 42 | HCB hcb = HCB.custom() | 41 | HCB hcb = HCB.custom() |
| 43 | - .timeout(3000) //超时 | 42 | + .timeout(3000) |
| 44 | - .pool(100, 10) //启用连接池,每个路由最大创建10个链接,总连接数限制为100个 | 43 | + .pool(100, 10) |
| 45 | - .sslpv(SSLs.SSLProtocolVersion.TLSv1_2) //设置ssl版本号,默认SSLv3,也可以调用sslpv("TLSv1.2") | 44 | + .sslpv(SSLs.SSLProtocolVersion.TLSv1_2) |
| 46 | - .ssl() //https,支持自定义ssl证书路径和密码,ssl(String keyStorePath, String keyStorepass) | 45 | + .ssl() |
| 47 | - .retry(5) //重试5次 | 46 | + .retry(5); |
| 48 | - ; | 47 | + |
| 49 | - | 48 | +// String url = "https://40.73.78.157:8780/customs/sendMawb"; |
| 50 | - HttpClient client = hcb.build(); | 49 | + String url = "https://192.168.1.75:8780/customs/sendMawb"; |
| 51 | - | ||
| 52 | - Map<String, Object> map = new HashMap<String, Object>(); | ||
| 53 | - map.put("mawb", createMawb()); | ||
| 54 | - //map.put("key2", "value2"); | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - Mawb mawb = createMawb(); | ||
| 58 | - | ||
| 59 | - Gson gson = new Gson(); | ||
| 60 | - String request =gson.toJson(mawb); | ||
| 61 | - //插件式配置请求参数(网址、请求参数、编码、client) | ||
| 62 | - String url="https://40.73.78.157:8780/customs/sendMawb"; | ||
| 63 | HttpConfig config = HttpConfig.custom() | 50 | HttpConfig config = HttpConfig.custom() |
| 64 | - .headers(headers) //设置headers,不需要时则无需设置 | 51 | + .headers(headers) |
| 65 | - .url(url) //设置请求的url | 52 | + .url(url) |
| 66 | - //.map(map) //设置请求参数,没有则无需设置 | 53 | + .encoding("utf-8") |
| 67 | - .encoding("utf-8") //设置请求和返回编码,默认就是Charset.defaultCharset() | 54 | + .client(hcb.build()) |
| 68 | - .client(client) //如果只是简单使用,无需设置,会自动获取默认的一个client对象 | 55 | + .json(new Gson().toJson(createMawb())); |
| 69 | - //.inenc("utf-8") //设置请求编码,如果请求返回一直,不需要再单独设置 | ||
| 70 | - //.inenc("utf-8") //设置返回编码,如果请求返回一直,不需要再单独设置 | ||
| 71 | - .json(request) //json方式请求的话,就不用设置map方法,当然二者可以共用。 | ||
| 72 | - //.context(HttpCookies.custom().getContext()) //设置cookie,用于完成携带cookie的操作 | ||
| 73 | - //.out(new FileOutputStream("保存地址")) //下载的话,设置这个方法,否则不要设置 | ||
| 74 | - //.files(new String[]{"d:/1.txt","d:/2.txt"}) //上传的话,传递文件路径,一般还需map配置,设置服务器保存路径 | ||
| 75 | - ; | ||
| 76 | - | ||
| 77 | - | ||
| 78 | - //使用方式: | ||
| 79 | - //System.out.println(HttpClientUtil.get(config)); | ||
| 80 | System.out.println(HttpClientUtil.post(config)); | 56 | System.out.println(HttpClientUtil.post(config)); |
| 81 | - | ||
| 82 | - //HttpClientUtil.down(config); //下载,需要调用config.out(fileOutputStream对象) | ||
| 83 | - //HttpClientUtil.upload(config); //上传,需要调用config.files(文件路径数组) | ||
| 84 | - | ||
| 85 | - //如果指向看是否访问正常 | ||
| 86 | - //String result3 = HttpClientUtil.head(config); // 返回Http协议号+状态码 | ||
| 87 | - //int statusCode = HttpClientUtil.status(config);//返回状态码 | ||
| 88 | - | ||
| 89 | - //[新增方法]sendAndGetResp,可以返回原生的HttpResponse对象, | ||
| 90 | - //同时返回常用的几类对象:result、header、StatusLine、StatusCode | ||
| 91 | -// HttpResult respResult = HttpClientUtil.sendAndGetResp(config); | ||
| 92 | -// System.out.println("返回结果:\n"+respResult.getResult()); | ||
| 93 | -// System.out.println("返回resp-header:"+respResult.getRespHeaders());//可以遍历 | ||
| 94 | -// System.out.println("返回具体resp-header:"+respResult.getHeaders("Date")); | ||
| 95 | -// System.out.println("返回StatusLine对象:"+respResult.getStatusLine()); | ||
| 96 | -// System.out.println("返回StatusCode:"+respResult.getStatusCode()); | ||
| 97 | -// System.out.println("返回HttpResponse对象)(可自行处理):"+respResult.getResp()); | ||
| 98 | - | ||
| 99 | } | 57 | } |
| 100 | 58 | ||
| 101 | 59 | ||
| 102 | - public static Mawb createMawb(){ | 60 | + public static Mawb createMawb() { |
| 103 | 61 | ||
| 104 | MawbDetail d1 = new MawbDetail(); | 62 | MawbDetail d1 = new MawbDetail(); |
| 105 | d1.setClassMark(""); | 63 | d1.setClassMark(""); |
| ... | @@ -113,9 +71,9 @@ public class HttpClientTest { | ... | @@ -113,9 +71,9 @@ public class HttpClientTest { |
| 113 | d1.setFirstQty(11); | 71 | d1.setFirstQty(11); |
| 114 | d1.setGunit("007"); | 72 | d1.setGunit("007"); |
| 115 | d1.setGmodel("商品规格、型号"); | 73 | d1.setGmodel("商品规格、型号"); |
| 116 | - d1.setGname("餐桌"); | 74 | + d1.setGname("餐桌2"); |
| 117 | d1.setGno("1"); | 75 | d1.setGno("1"); |
| 118 | - d1.setGqty(BigDecimal.valueOf(1.88)); | 76 | + d1.setGqty(BigDecimal.valueOf(15.88)); |
| 119 | d1.setOriginCountry("US"); | 77 | d1.setOriginCountry("US"); |
| 120 | d1.setSecondUnit("007"); | 78 | d1.setSecondUnit("007"); |
| 121 | d1.setSecondQty(2); | 79 | d1.setSecondQty(2); |
| ... | @@ -141,9 +99,9 @@ public class HttpClientTest { | ... | @@ -141,9 +99,9 @@ public class HttpClientTest { |
| 141 | d2.setFirstQty(11); | 99 | d2.setFirstQty(11); |
| 142 | d2.setGunit("007"); | 100 | d2.setGunit("007"); |
| 143 | d2.setGmodel("商品规格、型号"); | 101 | d2.setGmodel("商品规格、型号"); |
| 144 | - d2.setGname("餐桌"); | 102 | + d2.setGname("餐桌3"); |
| 145 | d2.setGno("2"); | 103 | d2.setGno("2"); |
| 146 | - d2.setGqty(BigDecimal.valueOf(22.88)); | 104 | + d2.setGqty(BigDecimal.valueOf(42.88)); |
| 147 | d2.setOriginCountry("US"); | 105 | d2.setOriginCountry("US"); |
| 148 | d2.setSecondUnit("007"); | 106 | d2.setSecondUnit("007"); |
| 149 | d2.setSecondQty(3); | 107 | d2.setSecondQty(3); |
| ... | @@ -157,14 +115,11 @@ public class HttpClientTest { | ... | @@ -157,14 +115,11 @@ public class HttpClientTest { |
| 157 | d2.setDistrictCode("4408W"); | 115 | d2.setDistrictCode("4408W"); |
| 158 | 116 | ||
| 159 | 117 | ||
| 160 | - | ||
| 161 | List<MawbDetail> mawbDetailList = new ArrayList<MawbDetail>(); | 118 | List<MawbDetail> mawbDetailList = new ArrayList<MawbDetail>(); |
| 162 | mawbDetailList.add(d1); | 119 | mawbDetailList.add(d1); |
| 163 | mawbDetailList.add(d2); | 120 | mawbDetailList.add(d2); |
| 164 | 121 | ||
| 165 | 122 | ||
| 166 | - | ||
| 167 | - | ||
| 168 | Mawb mawb = new Mawb(); | 123 | Mawb mawb = new Mawb(); |
| 169 | mawb.setIEFlag("E"); | 124 | mawb.setIEFlag("E"); |
| 170 | mawb.setType("EX"); | 125 | mawb.setType("EX"); |
| ... | @@ -219,12 +174,4 @@ public class HttpClientTest { | ... | @@ -219,12 +174,4 @@ public class HttpClientTest { |
| 219 | } | 174 | } |
| 220 | 175 | ||
| 221 | 176 | ||
| 222 | - | ||
| 223 | - | ||
| 224 | - | ||
| 225 | - | ||
| 226 | - | ||
| 227 | - | ||
| 228 | - | ||
| 229 | - | ||
| 230 | } | 177 | } | ... | ... |
-
Please register or login to post a comment