This commit is contained in:
linfso 2024-08-15 11:55:09 +08:00
parent bcd005da3c
commit 8c4b4ac75f
2 changed files with 74 additions and 2 deletions

View File

@ -629,4 +629,25 @@ public class EmisCommonController extends EmisBaseController
return AjaxResult.success("发送成功");
}
@GetMapping("/notifyTraceByKD100")
public AjaxResult notifyTraceByKD100(){
String lockKey="notifyTraceByKD100";
log.error("notifyTraceByKD100 start");
// 加锁查询
// redissonService.lock(lockKey,300);
// try{
// }catch(Exception ex){
// ex.printStackTrace();
// log.error("autoDoQueryTransferInfoTrigger exception:"+ex.getMessage());
// }
log.error("notifyTraceByKD100 end");
// redissonService.unlock(lockKey);
return AjaxResult.success("发送成功");
}
}

View File

@ -4,6 +4,7 @@ package com.xdadan.erp.emis.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.emis.domain.EmisTmsScanRecord;
import com.xdadan.erp.emis.domain.EmisTmsTransferTrace;
@ -27,6 +28,7 @@ public class Kd100Helper {
private static final String POLL_QUERY_URL = "https://poll.kuaidi100.com/poll/query.do";
private static final String POLL_URL = "https://poll.kuaidi100.com/poll";
// 授权码,授权码,请到快递100页面申请企业版接口获取
private static final String KEY = "UpQfyYaY2889";
@ -55,12 +57,60 @@ public class Kd100Helper {
postDataMap.put("sign", genDigest(mgsData, KEY, CUSTOMER)); // 数字签名
postDataMap.put("param", mgsData);
System.out.println(JSON.toJSONString(postDataMap));
// log.debug("===KD100==POST==>{}",JSON.toJSONString(postDataMap));
String allResult=HTTPHelperV3.post(POLL_QUERY_URL,postDataMap,"application/x-www-form-urlencoded");
// log.debug("===KD100==REST==>{}",allResult);
try {
// 订阅轨迹
pollTraceByMainNoAndCom(mainNo, com, phone);
}catch (Exception ex){
ex.printStackTrace();
}
return allResult;
}
/**
* 订阅
* @param mainNo
* @param com
* @param phone
* @return
* @throws Exception
*/
public static String pollTraceByMainNoAndCom(String mainNo, String com,String phone) {
JSONObject param = new JSONObject();
param.put("company", com);//快递公司编码
param.put("number", mainNo);//快递单号
param.put("from", "VN");
param.put("to", "CN");
param.put("key", KEY);
JSONObject parameters = new JSONObject();
parameters.put("callbackurl", "http://api.emis.tanex56.com/api/bizsvr/emis/common/notifyTraceByKD100");
param.put("parameters", parameters);
param.put("salt", "tanex56");
param.put("phone", "138188161237");
param.put("resultv2", "4");
String mgsData = param.toJSONString();
Map<String, String> postDataMap = new HashMap<>();
postDataMap.put("schema", "json");
postDataMap.put("param", mgsData);
try {
log.debug("===KD100==POST==>{}",JSON.toJSONString(postDataMap));
String restStr = HTTPHelperV3.post(POLL_URL,postDataMap,"application/x-www-form-urlencoded");
log.debug("===KD100==REST==>{}",restStr);
return restStr;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static List<EmisTmsScanRecord> cvtTraceToScanRecord(String billCode,String traceInfo) {
List<EmisTmsScanRecord> recordList= null;
try {
@ -145,7 +195,8 @@ public class Kd100Helper {
// emisTmsTransferTrace = queryTmsTransferTraceByKd100(emisTmsTransferTrace);
// String str=queryTraceByMainNoAndCom("T7080300002588","探路速运");
String str=queryTraceByMainNoAndCom("T7080300002588","探路速运","1234");
// String str=queryTraceByMainNoAndCom("SF080300002588","shunfeng","1234");
String str=pollTraceByMainNoAndCom("SF080300002588","shunfeng","1234");
// String str=queryTraceByMainNoAndCom("T7080398716","探路速运");
System.out.println(str);
List<EmisTmsScanRecord> list=cvtTraceToScanRecord("12321",str);