|
@@ -7,8 +7,8 @@ import cn.hutool.http.HttpStatus;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.annotation.TableName;
|
|
|
+import com.fjhx.kd100.constant.KD100Status;
|
|
|
import com.fjhx.kd100.constant.Kd100Constant;
|
|
|
-import com.fjhx.kd100.constant.LogisticsConstant;
|
|
|
import com.fjhx.kd100.entity.config.po.ConfigInfo;
|
|
|
import com.fjhx.kd100.entity.logistics.po.LogisticsInfo;
|
|
|
import com.fjhx.kd100.service.config.ConfigInfoService;
|
|
@@ -86,11 +86,11 @@ public class KD100Util {
|
|
|
KD100Result result = KD100Util.queryTrack(com, num);
|
|
|
String message = result.getMessage();
|
|
|
if (Objects.equals(message, "查询无结果,请隔段时间再查")) {
|
|
|
- return saveInfo(com, num, LogisticsConstant.KD100Status.STATUS_N, businessId, businessType, cls);
|
|
|
+ return saveInfo(com, num, KD100Status.STATUS_N, businessId, businessType, cls);
|
|
|
}
|
|
|
if (Objects.equals(message, "ok")) {
|
|
|
Integer state = result.getState();
|
|
|
- if (!Objects.equals(state, LogisticsConstant.KD100Status.STATUS_3)) {
|
|
|
+ if (!Objects.equals(state, KD100Status.STATUS_3)) {
|
|
|
// 如果不是已签收状态,则开启订阅(物流状态跟踪并推送)
|
|
|
KD100Util.subscribe(com, num);
|
|
|
}
|
|
@@ -101,42 +101,6 @@ public class KD100Util {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 保存快递信息
|
|
|
- */
|
|
|
- private static LogisticsInfo saveInfo(String com, String num, Integer state, Long businessId, Integer businessType, Class<?> cls) {
|
|
|
-
|
|
|
- LogisticsInfo logisticsInfo = new LogisticsInfo();
|
|
|
- logisticsInfo.setCompany(com);
|
|
|
- logisticsInfo.setNumber(num);
|
|
|
- logisticsInfo.setState(state);
|
|
|
- logisticsInfo.setBusinessId(businessId);
|
|
|
- logisticsInfo.setBusinessType(businessType);
|
|
|
- logisticsInfo.setTableName(getTableName(cls));
|
|
|
-
|
|
|
- LogisticsInfoService logisticsInfoService = SpringUtil.getBean(LogisticsInfoService.class);
|
|
|
- logisticsInfoService.save(logisticsInfo);
|
|
|
- return logisticsInfo;
|
|
|
- }
|
|
|
-
|
|
|
- public static String getTableName(Class<?> cls) {
|
|
|
- Annotation[] annotations = cls.getAnnotations();
|
|
|
- TableName tableName = null;
|
|
|
- for (Annotation annotation : annotations) {
|
|
|
- if (annotation instanceof TableName) {
|
|
|
- tableName = (TableName) annotation;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (tableName != null) {
|
|
|
- return tableName.value();
|
|
|
- } else {
|
|
|
- String name = cls.getSimpleName();
|
|
|
- return StrUtil.toUnderlineCase(name);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 订阅接口
|
|
|
*
|
|
|
* @param com 快递公司编码
|
|
@@ -209,10 +173,55 @@ public class KD100Util {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取表名
|
|
|
+ */
|
|
|
+ public static String getTableName(Class<?> cls) {
|
|
|
+ Annotation[] annotations = cls.getAnnotations();
|
|
|
+ TableName tableName = null;
|
|
|
+ for (Annotation annotation : annotations) {
|
|
|
+ if (annotation instanceof TableName) {
|
|
|
+ tableName = (TableName) annotation;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tableName != null) {
|
|
|
+ return tableName.value();
|
|
|
+ } else {
|
|
|
+ String name = cls.getSimpleName();
|
|
|
+ return StrUtil.toUnderlineCase(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存快递信息
|
|
|
+ */
|
|
|
+ private static LogisticsInfo saveInfo(String com, String num, Integer state, Long businessId, Integer businessType, Class<?> cls) {
|
|
|
+
|
|
|
+ LogisticsInfo logisticsInfo = new LogisticsInfo();
|
|
|
+ logisticsInfo.setCompany(com);
|
|
|
+ logisticsInfo.setNumber(num);
|
|
|
+ logisticsInfo.setState(state);
|
|
|
+ logisticsInfo.setBusinessId(businessId);
|
|
|
+ logisticsInfo.setBusinessType(businessType);
|
|
|
+ logisticsInfo.setTableName(getTableName(cls));
|
|
|
+
|
|
|
+ LogisticsInfoService logisticsInfoService = SpringUtil.getBean(LogisticsInfoService.class);
|
|
|
+ logisticsInfoService.save(logisticsInfo);
|
|
|
+ return logisticsInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取kd100回调地址
|
|
|
+ */
|
|
|
private static String getCallbackUrl() {
|
|
|
return HxConfig.getHttpUrl() + Kd100Constant.CALLBACK_URL;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取租户快递100配置
|
|
|
+ */
|
|
|
private static ConfigInfo getConfigInfo() {
|
|
|
ConfigInfoService configInfoService = SpringUtil.getBean(ConfigInfoService.class);
|
|
|
String tenantId = SecurityUtils.getTenantId();
|