mirror of https://github.com/jeecgboot/jeecg-boot
Merge branch 'dev' into feat/clientChangeOrderInfo
commit
26a7b39dc7
|
@ -43,7 +43,7 @@ public class CreateFulfillmentRequest extends ShopifyRequest {
|
||||||
POST_NL("https://postnl.post/", "PostNL International Mail", "LS[0-9]{9}NL"),
|
POST_NL("https://postnl.post/", "PostNL International Mail", "LS[0-9]{9}NL"),
|
||||||
COLI_COLI("https://www.colicoli.fr/trackings?id=%s", "Coli Coli", "CC[0-9]{14}[A-Z]*"),
|
COLI_COLI("https://www.colicoli.fr/trackings?id=%s", "Coli Coli", "CC[0-9]{14}[A-Z]*"),
|
||||||
LUXEMBOURG_POST("https://www.post.lu/particuliers/colis-courrier/track-and-trace#/search", "Luxembourg Post", "LL[0-9]{9}LU"),
|
LUXEMBOURG_POST("https://www.post.lu/particuliers/colis-courrier/track-and-trace#/search", "Luxembourg Post", "LL[0-9]{9}LU"),
|
||||||
CJ_LOGISTICS("https://www.cjlogistics.com/ko/tool/parcel/tracking", "CJ대한통운", "57575[0-9]{7}|58476[0-9]{7}"),
|
CJ_LOGISTICS("https://www.cjlogistics.com/ko/tool/parcel/tracking", "CJ대한통운", "57575[0-9]{7}|58476[0-9]{7}|59012[0-9]{7}|57476[0-9]{7}"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String trackingUrl;
|
private final String trackingUrl;
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.yd;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class YDParcelTraceRequestBody extends YDRequestBody {
|
||||||
|
|
||||||
|
private static final String SERVICE_METHOD = "gettrack";
|
||||||
|
private static final String TRACKING_NUMBER = "tracking_number";
|
||||||
|
|
||||||
|
public YDParcelTraceRequestBody(List<String> billCodes) {
|
||||||
|
super(SERVICE_METHOD, generateJsonString(billCodes));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String generateJsonString(List<String> billCodes) {
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
String billCodesWithComas = String.join(",", billCodes);
|
||||||
|
param.put(TRACKING_NUMBER, billCodesWithComas);
|
||||||
|
return param.toJSONString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.yd;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
public class YDParcelTraceResponse extends YDResponse {
|
||||||
|
|
||||||
|
@JsonProperty("data")
|
||||||
|
private List<YDTraceData> traceDataList;
|
||||||
|
|
||||||
|
public YDParcelTraceResponse(Integer returnValue, String cnMessage, String enMessage, List<YDTraceData> traceDataList) {
|
||||||
|
super(returnValue, cnMessage, enMessage);
|
||||||
|
this.traceDataList = traceDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public YDParcelTraceResponse() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package org.jeecg.modules.business.domain.api.yd;
|
package org.jeecg.modules.business.domain.api.yd;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
|
@ -23,18 +22,16 @@ import java.util.List;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class YDRequest {
|
public class YDRequest {
|
||||||
private final static String URL = "http://oms.ydhex.com/webservice/PublicService.asmx/ServiceInterfaceUTF8";
|
private final static String URL = "http://oms.ydhex.com/webservice/PublicService.asmx/ServiceInterfaceUTF8";
|
||||||
private String appToken;
|
private final String appToken;
|
||||||
private String appKey;
|
private final String appKey;
|
||||||
|
private final YDRequestBody ydRequestBody;
|
||||||
|
|
||||||
private static final String SERVICE_METHOD = "gettrack";
|
|
||||||
private static final RequestConfig REQUEST_CONFIG = RequestConfig.custom().build();
|
private static final RequestConfig REQUEST_CONFIG = RequestConfig.custom().build();
|
||||||
|
|
||||||
private final List<String> billCodes;
|
public YDRequest(String appToken, String appKey, YDRequestBody ydRequestBody) {
|
||||||
|
|
||||||
public YDRequest(String appToken, String appKey, List<String> billCodes) {
|
|
||||||
this.appToken = appToken;
|
this.appToken = appToken;
|
||||||
this.appKey = appKey;
|
this.appKey = appKey;
|
||||||
this.billCodes = billCodes;
|
this.ydRequestBody = ydRequestBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +50,7 @@ public class YDRequest {
|
||||||
request.setEntity(new UrlEncodedFormEntity(generateFormData(), "UTF-8"));
|
request.setEntity(new UrlEncodedFormEntity(generateFormData(), "UTF-8"));
|
||||||
return httpClient.execute(request);
|
return httpClient.execute(request);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Request failed on attempt n°" + attempts);
|
log.error("Request failed on attempt n°{}", attempts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -67,18 +64,11 @@ public class YDRequest {
|
||||||
*/
|
*/
|
||||||
private List<NameValuePair> generateFormData() {
|
private List<NameValuePair> generateFormData() {
|
||||||
List<NameValuePair> pairs = new ArrayList<>();
|
List<NameValuePair> pairs = new ArrayList<>();
|
||||||
String paramsJson = generateJsonString(billCodes);
|
|
||||||
pairs.add(new BasicNameValuePair("appToken", appToken));
|
pairs.add(new BasicNameValuePair("appToken", appToken));
|
||||||
pairs.add(new BasicNameValuePair("appKey", appKey));
|
pairs.add(new BasicNameValuePair("appKey", appKey));
|
||||||
pairs.add(new BasicNameValuePair("serviceMethod", SERVICE_METHOD));
|
pairs.add(new BasicNameValuePair("serviceMethod", ydRequestBody.getServiceMethod()));
|
||||||
pairs.add(new BasicNameValuePair("paramsJson", paramsJson));
|
pairs.add(new BasicNameValuePair("paramsJson", ydRequestBody.getParamsJson()));
|
||||||
return pairs;
|
return pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateJsonString(List<String> billCodes) {
|
|
||||||
JSONObject param = new JSONObject();
|
|
||||||
String billCodesWithComas = String.join(",", billCodes);
|
|
||||||
param.put("tracking_number", billCodesWithComas);
|
|
||||||
return param.toJSONString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.yd;
|
||||||
|
|
||||||
|
public abstract class YDRequestBody {
|
||||||
|
|
||||||
|
private final String serviceMethod;
|
||||||
|
|
||||||
|
private final String paramsJson;
|
||||||
|
|
||||||
|
public YDRequestBody(String serviceMethod, String paramsJson) {
|
||||||
|
this.serviceMethod = serviceMethod;
|
||||||
|
this.paramsJson = paramsJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServiceMethod() {
|
||||||
|
return serviceMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParamsJson() {
|
||||||
|
return paramsJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,38 +4,32 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
public class YDResponse {
|
public abstract class YDResponse {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回值
|
* 返回值
|
||||||
*/
|
*/
|
||||||
@JsonProperty("success")
|
@JsonProperty("success")
|
||||||
private Integer returnValue;
|
protected Integer returnValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回中文信息
|
* 返回中文信息
|
||||||
*/
|
*/
|
||||||
@JsonProperty("cnmessage")
|
@JsonProperty("cnmessage")
|
||||||
private String cnMessage;
|
protected String cnMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回英文信息
|
* 返回英文信息
|
||||||
*/
|
*/
|
||||||
@JsonProperty("enmessage")
|
@JsonProperty("enmessage")
|
||||||
private String enMessage;
|
protected String enMessage;
|
||||||
|
|
||||||
@JsonProperty("data")
|
public YDResponse(Integer returnValue, String cnMessage, String enMessage) {
|
||||||
private List<YDTraceData> traceDataList;
|
|
||||||
|
|
||||||
public YDResponse(Integer returnValue, String cnMessage, String enMessage, List<YDTraceData> traceDataList) {
|
|
||||||
this.returnValue = returnValue;
|
this.returnValue = returnValue;
|
||||||
this.cnMessage = cnMessage;
|
this.cnMessage = cnMessage;
|
||||||
this.enMessage = enMessage;
|
this.enMessage = enMessage;
|
||||||
this.traceDataList = traceDataList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public YDResponse() {
|
public YDResponse() {
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.yd;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
public class YDTrackingNumberData {
|
||||||
|
|
||||||
|
@JsonProperty("refrence_no")
|
||||||
|
private String platformOrderId;
|
||||||
|
|
||||||
|
@JsonProperty("channel_hawbcode")
|
||||||
|
private String localTrackingNumber;
|
||||||
|
|
||||||
|
public YDTrackingNumberData(String platformOrderId, String localTrackingNumber) {
|
||||||
|
this.platformOrderId = platformOrderId;
|
||||||
|
this.localTrackingNumber = localTrackingNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public YDTrackingNumberData() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.yd;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
|
public class YDTrackingNumberRequestBody extends YDRequestBody {
|
||||||
|
|
||||||
|
private static final String SERVICE_METHOD = "gettrackingnumber";
|
||||||
|
private static final String REFERENCE_NO = "reference_no";
|
||||||
|
|
||||||
|
public YDTrackingNumberRequestBody(String platformOrderId) {
|
||||||
|
super(SERVICE_METHOD, generateJsonString(platformOrderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String generateJsonString(String platformOrderId) {
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put(REFERENCE_NO, platformOrderId);
|
||||||
|
return param.toJSONString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.yd;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
public class YDTrackingNumberResponse extends YDResponse {
|
||||||
|
|
||||||
|
@JsonProperty("data")
|
||||||
|
private YDTrackingNumberData trackingNumberData;
|
||||||
|
|
||||||
|
public YDTrackingNumberResponse(Integer returnValue, String cnMessage, String enMessage, YDTrackingNumberData trackingNumberData) {
|
||||||
|
super(returnValue, cnMessage, enMessage);
|
||||||
|
this.trackingNumberData = trackingNumberData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public YDTrackingNumberResponse() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -252,8 +252,9 @@ public class AddPortraitTubeJob implements Job {
|
||||||
if (tube40SingleCount > 0) {
|
if (tube40SingleCount > 0) {
|
||||||
adequateTubes.add(Pair.of(TUBE_40_SKU_SINGLE, tube40SingleCount));
|
adequateTubes.add(Pair.of(TUBE_40_SKU_SINGLE, tube40SingleCount));
|
||||||
}
|
}
|
||||||
|
// 2024-06-13 Temporarily replace 40cm multiple tubes by 50cm multiple tubes
|
||||||
if (tube40MultipleCount > 0) {
|
if (tube40MultipleCount > 0) {
|
||||||
adequateTubes.add(Pair.of(TUBE_40_SKU_MULTIPLE, tube40MultipleCount));
|
adequateTubes.add(Pair.of(TUBE_50_SKU_MULTIPLE, tube40MultipleCount));
|
||||||
}
|
}
|
||||||
if (tube30SingleDoubleCount > 0) {
|
if (tube30SingleDoubleCount > 0) {
|
||||||
adequateTubes.add(Pair.of(TUBE_30_SKU_SINGLE_DOUBLE, tube30SingleDoubleCount));
|
adequateTubes.add(Pair.of(TUBE_30_SKU_SINGLE_DOUBLE, tube30SingleDoubleCount));
|
||||||
|
|
|
@ -9,8 +9,9 @@ import org.apache.http.util.EntityUtils;
|
||||||
import org.codehaus.jettison.json.JSONArray;
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
import org.codehaus.jettison.json.JSONException;
|
import org.codehaus.jettison.json.JSONException;
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDParcelTraceRequestBody;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDParcelTraceResponse;
|
||||||
import org.jeecg.modules.business.domain.api.yd.YDRequest;
|
import org.jeecg.modules.business.domain.api.yd.YDRequest;
|
||||||
import org.jeecg.modules.business.domain.api.yd.YDResponse;
|
|
||||||
import org.jeecg.modules.business.domain.api.yd.YDTraceData;
|
import org.jeecg.modules.business.domain.api.yd.YDTraceData;
|
||||||
import org.jeecg.modules.business.service.IParcelService;
|
import org.jeecg.modules.business.service.IParcelService;
|
||||||
import org.jeecg.modules.business.service.IPlatformOrderService;
|
import org.jeecg.modules.business.service.IPlatformOrderService;
|
||||||
|
@ -42,7 +43,7 @@ public class CWJob implements Job {
|
||||||
private static final Integer DEFAULT_NUMBER_OF_DAYS = 15;
|
private static final Integer DEFAULT_NUMBER_OF_DAYS = 15;
|
||||||
private static final Integer DEFAULT_NUMBER_OF_THREADS = 10;
|
private static final Integer DEFAULT_NUMBER_OF_THREADS = 10;
|
||||||
private static final Integer DEFAULT_MAXIMUM_NUMBER_OF_PARCELS_PER_TRANSACTION = 800;
|
private static final Integer DEFAULT_MAXIMUM_NUMBER_OF_PARCELS_PER_TRANSACTION = 800;
|
||||||
private static final List<String> DEFAULT_TRANSPORTERS = Arrays.asList("诚稳法邮普货" , "诚稳法邮膏体");
|
private static final List<String> DEFAULT_TRANSPORTERS = Arrays.asList("诚稳法邮普货", "诚稳法邮膏体");
|
||||||
|
|
||||||
private final static String APP_TOKEN = "y7j1p5o4obncsdhbk1zgasunb2erpyzvh";
|
private final static String APP_TOKEN = "y7j1p5o4obncsdhbk1zgasunb2erpyzvh";
|
||||||
private final static String APP_KEY = "ym27kj0wy5wgx69f58pgd7crm60w07p0l15flj1bacrf5n0e38vqjtrjkkvosd61p";
|
private final static String APP_KEY = "ym27kj0wy5wgx69f58pgd7crm60w07p0l15flj1bacrf5n0e38vqjtrjkkvosd61p";
|
||||||
|
@ -99,7 +100,8 @@ public class CWJob implements Job {
|
||||||
List<YDTraceData> parcelTraces = new ArrayList<>();
|
List<YDTraceData> parcelTraces = new ArrayList<>();
|
||||||
List<YDRequest> ydRequests = new ArrayList<>();
|
List<YDRequest> ydRequests = new ArrayList<>();
|
||||||
billCodeLists.forEach(billcodeList -> {
|
billCodeLists.forEach(billcodeList -> {
|
||||||
YDRequest ydRequest = new YDRequest(APP_TOKEN, APP_KEY, billcodeList);
|
YDParcelTraceRequestBody ydParcelTraceRequestBody = new YDParcelTraceRequestBody(billcodeList);
|
||||||
|
YDRequest ydRequest = new YDRequest(APP_TOKEN, APP_KEY, ydParcelTraceRequestBody);
|
||||||
ydRequests.add(ydRequest);
|
ydRequests.add(ydRequest);
|
||||||
});
|
});
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(DEFAULT_NUMBER_OF_THREADS);
|
ExecutorService executor = Executors.newFixedThreadPool(DEFAULT_NUMBER_OF_THREADS);
|
||||||
|
@ -110,7 +112,7 @@ public class CWJob implements Job {
|
||||||
try {
|
try {
|
||||||
// String of the response
|
// String of the response
|
||||||
String responseString = EntityUtils.toString(entity, "UTF-8");
|
String responseString = EntityUtils.toString(entity, "UTF-8");
|
||||||
YDResponse ydResponse = mapper.readValue(responseString, YDResponse.class);
|
YDParcelTraceResponse ydResponse = mapper.readValue(responseString, YDParcelTraceResponse.class);
|
||||||
parcelTraces.addAll(ydResponse.getTraceDataList());
|
parcelTraces.addAll(ydResponse.getTraceDataList());
|
||||||
success = true;
|
success = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -9,8 +9,9 @@ import org.apache.http.util.EntityUtils;
|
||||||
import org.codehaus.jettison.json.JSONArray;
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
import org.codehaus.jettison.json.JSONException;
|
import org.codehaus.jettison.json.JSONException;
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDParcelTraceRequestBody;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDParcelTraceResponse;
|
||||||
import org.jeecg.modules.business.domain.api.yd.YDRequest;
|
import org.jeecg.modules.business.domain.api.yd.YDRequest;
|
||||||
import org.jeecg.modules.business.domain.api.yd.YDResponse;
|
|
||||||
import org.jeecg.modules.business.domain.api.yd.YDTraceData;
|
import org.jeecg.modules.business.domain.api.yd.YDTraceData;
|
||||||
import org.jeecg.modules.business.service.IParcelService;
|
import org.jeecg.modules.business.service.IParcelService;
|
||||||
import org.jeecg.modules.business.service.IPlatformOrderService;
|
import org.jeecg.modules.business.service.IPlatformOrderService;
|
||||||
|
@ -99,7 +100,8 @@ public class YDJob implements Job {
|
||||||
List<YDTraceData> parcelTraces = new ArrayList<>();
|
List<YDTraceData> parcelTraces = new ArrayList<>();
|
||||||
List<YDRequest> ydRequests = new ArrayList<>();
|
List<YDRequest> ydRequests = new ArrayList<>();
|
||||||
billCodeLists.forEach(billcodeList -> {
|
billCodeLists.forEach(billcodeList -> {
|
||||||
YDRequest ydRequest = new YDRequest(APP_TOKEN, APP_KEY, billcodeList);
|
YDParcelTraceRequestBody ydParcelTraceRequestBody = new YDParcelTraceRequestBody(billcodeList);
|
||||||
|
YDRequest ydRequest = new YDRequest(APP_TOKEN, APP_KEY, ydParcelTraceRequestBody);
|
||||||
ydRequests.add(ydRequest);
|
ydRequests.add(ydRequest);
|
||||||
});
|
});
|
||||||
ExecutorService executor = Executors.newFixedThreadPool(DEFAULT_NUMBER_OF_THREADS);
|
ExecutorService executor = Executors.newFixedThreadPool(DEFAULT_NUMBER_OF_THREADS);
|
||||||
|
@ -110,7 +112,7 @@ public class YDJob implements Job {
|
||||||
try {
|
try {
|
||||||
// String of the response
|
// String of the response
|
||||||
String responseString = EntityUtils.toString(entity, "UTF-8");
|
String responseString = EntityUtils.toString(entity, "UTF-8");
|
||||||
YDResponse ydResponse = mapper.readValue(responseString, YDResponse.class);
|
YDParcelTraceResponse ydResponse = mapper.readValue(responseString, YDParcelTraceResponse.class);
|
||||||
parcelTraces.addAll(ydResponse.getTraceDataList());
|
parcelTraces.addAll(ydResponse.getTraceDataList());
|
||||||
success = true;
|
success = true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
package org.jeecg.modules.business.domain.job;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.http.HttpEntity;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
|
import org.codehaus.jettison.json.JSONException;
|
||||||
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDRequest;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberData;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberRequestBody;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberResponse;
|
||||||
|
import org.jeecg.modules.business.service.IPlatformOrderService;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobDataMap;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class YDTrackingNumberJob implements Job {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPlatformOrderService platformOrderService;
|
||||||
|
|
||||||
|
private static final Integer DEFAULT_NUMBER_OF_THREADS = 10;
|
||||||
|
|
||||||
|
private final static String APP_TOKEN = "y553qci626dds5d6lcughy3ogicvfaxmh";
|
||||||
|
private final static String APP_KEY = "ynpoeds5511hg791mmksg6xccqxhax11j16eqz1itylq7whijki20egl0nmyql5h9";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
|
List<String> shops = new ArrayList<>();
|
||||||
|
Map<String, List<String>> transportersByShop = new HashMap<>();
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
|
JobDataMap jobDataMap = context.getMergedJobDataMap();
|
||||||
|
String parameter = ((String) jobDataMap.get("parameter"));
|
||||||
|
if (parameter != null) {
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(parameter);
|
||||||
|
if (!jsonObject.isNull("transportersByShop")) {
|
||||||
|
JSONArray transportersByShopArray = jsonObject.getJSONArray("transportersByShop");
|
||||||
|
for (int i = 0; i < transportersByShopArray.length(); i++) {
|
||||||
|
JSONObject object = transportersByShopArray.getJSONObject((i));
|
||||||
|
if (!object.isNull("shop")) {
|
||||||
|
String shopCode = object.getString("shop");
|
||||||
|
shops.add(shopCode);
|
||||||
|
if (!object.isNull("transporters")) {
|
||||||
|
JSONArray transportersArray = object.getJSONArray("transporters");
|
||||||
|
List<String> transporters = new ArrayList<>();
|
||||||
|
for (int j = 0; j < transportersArray.length(); j++) {
|
||||||
|
transporters.add(transportersArray.getString(j));
|
||||||
|
}
|
||||||
|
transportersByShop.put(shopCode, transporters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("Error while parsing parameter as JSON, falling back to default parameters.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Starting to retrieve local tracking numbers");
|
||||||
|
List<YDTrackingNumberData> localTrackingNumbers = new ArrayList<>();
|
||||||
|
List<String> platformOrderIds = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, List<String>> entry : transportersByShop.entrySet()) {
|
||||||
|
platformOrderIds.addAll(platformOrderService.fetchShippedOrdersFromShopAndTransporters(entry.getKey(), entry.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<YDRequest> ydRequests = new ArrayList<>();
|
||||||
|
platformOrderIds.forEach(platformOrderId -> {
|
||||||
|
YDTrackingNumberRequestBody ydParcelTraceRequestBody = new YDTrackingNumberRequestBody(platformOrderId);
|
||||||
|
YDRequest ydRequest = new YDRequest(APP_TOKEN, APP_KEY, ydParcelTraceRequestBody);
|
||||||
|
ydRequests.add(ydRequest);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ExecutorService executor = Executors.newFixedThreadPool(DEFAULT_NUMBER_OF_THREADS);
|
||||||
|
List<CompletableFuture<Boolean>> futures = ydRequests.stream()
|
||||||
|
.map(request -> CompletableFuture.supplyAsync(() -> {
|
||||||
|
boolean success = false;
|
||||||
|
HttpEntity entity = request.send().getEntity();
|
||||||
|
try {
|
||||||
|
// String of the response
|
||||||
|
String responseString = EntityUtils.toString(entity, "UTF-8");
|
||||||
|
YDTrackingNumberResponse ydResponse = mapper.readValue(responseString, YDTrackingNumberResponse.class);
|
||||||
|
if (ydResponse.getTrackingNumberData().getLocalTrackingNumber() != null &&
|
||||||
|
!ydResponse.getTrackingNumberData().getLocalTrackingNumber().isEmpty()) {
|
||||||
|
localTrackingNumbers.add(ydResponse.getTrackingNumberData());
|
||||||
|
}
|
||||||
|
success = true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Error while parsing response into String", e);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}, executor))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<Boolean> results = futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
|
||||||
|
long nbSuccesses = results.stream().filter(b -> b).count();
|
||||||
|
log.info("{}/{} local tracking numbers have been retrieved.", nbSuccesses, ydRequests.size());
|
||||||
|
|
||||||
|
log.info("Started updating {} local tracking numbers", localTrackingNumbers.size());
|
||||||
|
platformOrderService.updateLocalTrackingNumber(localTrackingNumbers);
|
||||||
|
log.info("Ended updating local tracking numbers for the following orders : {}", localTrackingNumbers.stream()
|
||||||
|
.map(YDTrackingNumberData::getPlatformOrderId)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,14 +12,13 @@ import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 平台订单表
|
* @Description: 平台订单表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2024-05-30
|
* @Date: 2024-06-25
|
||||||
* @Version: V1.9
|
* @Version: V1.10
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "platform_order对象", description = "平台订单表")
|
@ApiModel(value = "platform_order对象", description = "平台订单表")
|
||||||
@Data
|
@Data
|
||||||
|
@ -258,5 +257,11 @@ public class PlatformOrder implements Serializable {
|
||||||
@Excel(name = "Shopify平台已同步(1=已同步,0=未同步)", width = 15, dicCode = "yn")
|
@Excel(name = "Shopify平台已同步(1=已同步,0=未同步)", width = 15, dicCode = "yn")
|
||||||
@Dict(dicCode = "yn")
|
@Dict(dicCode = "yn")
|
||||||
@ApiModelProperty(value = "Shopify平台已同步(1=已同步,0=未同步)")
|
@ApiModelProperty(value = "Shopify平台已同步(1=已同步,0=未同步)")
|
||||||
private java.lang.String shopifySynced;
|
private String shopifySynced;
|
||||||
|
/**
|
||||||
|
* 目的地转单号
|
||||||
|
*/
|
||||||
|
@Excel(name = "目的地转单号", width = 15)
|
||||||
|
@ApiModelProperty(value = "目的地转单号")
|
||||||
|
private String localTrackingNumber;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.business.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
|
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberData;
|
||||||
import org.jeecg.modules.business.entity.PlatformOrder;
|
import org.jeecg.modules.business.entity.PlatformOrder;
|
||||||
import org.jeecg.modules.business.entity.PlatformOrderShopSync;
|
import org.jeecg.modules.business.entity.PlatformOrderShopSync;
|
||||||
import org.jeecg.modules.business.vo.OrderKpi;
|
import org.jeecg.modules.business.vo.OrderKpi;
|
||||||
|
@ -231,4 +232,8 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
|
||||||
|
|
||||||
List<String> findReadyAbnormalOrdersWithSkus(@Param("skus") List<String> skus);
|
List<String> findReadyAbnormalOrdersWithSkus(@Param("skus") List<String> skus);
|
||||||
void updateShopifySynced(@Param("platformOrderIds") Collection<String> platformOrderIds);
|
void updateShopifySynced(@Param("platformOrderIds") Collection<String> platformOrderIds);
|
||||||
|
|
||||||
|
List<String> fetchShippedOrdersFromShopAndTransporters(@Param("shopCode")String shopCode, @Param("transporters") List<String> transporters);
|
||||||
|
|
||||||
|
void updateLocalTrackingNumber(@Param("data") List<YDTrackingNumberData> data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,7 +449,8 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="fetchOrderInShopsReadyForShopifySync" resultType="org.jeecg.modules.business.entity.PlatformOrderShopSync">
|
<select id="fetchOrderInShopsReadyForShopifySync" resultType="org.jeecg.modules.business.entity.PlatformOrderShopSync">
|
||||||
SELECT po.platform_order_id, po.tracking_number, s.shopify_prefix, s.shopify_token, po.postcode
|
SELECT po.platform_order_id, COALESCE(po.local_tracking_number, po.tracking_number) as tracking_number,
|
||||||
|
s.shopify_prefix, s.shopify_token, po.postcode
|
||||||
FROM platform_order po join shop s ON po.shop_id = s.id
|
FROM platform_order po join shop s ON po.shop_id = s.id
|
||||||
WHERE erp_code IN
|
WHERE erp_code IN
|
||||||
<foreach
|
<foreach
|
||||||
|
@ -1079,4 +1080,38 @@
|
||||||
#{platformOrderId}
|
#{platformOrderId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="fetchShippedOrdersFromShopAndTransporters" resultType="java.lang.String">
|
||||||
|
SELECT platform_order_id
|
||||||
|
FROM platform_order po join shop s ON po.shop_id = s.id
|
||||||
|
WHERE erp_code = #{shopCode}
|
||||||
|
AND erp_status = 3
|
||||||
|
AND shopify_synced = 0
|
||||||
|
AND logistic_channel_name IN
|
||||||
|
<foreach
|
||||||
|
collection="transporters"
|
||||||
|
separator=","
|
||||||
|
open="("
|
||||||
|
close=")"
|
||||||
|
index="index"
|
||||||
|
item="transporter">
|
||||||
|
#{transporter}
|
||||||
|
</foreach>
|
||||||
|
;
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateLocalTrackingNumber">
|
||||||
|
UPDATE platform_order
|
||||||
|
SET ready_for_shopify_sync = 1,
|
||||||
|
local_tracking_number =
|
||||||
|
case platform_order_id
|
||||||
|
<foreach collection="data" separator=" " open="" close="" index="index" item="item">
|
||||||
|
when #{item.platformOrderId} then #{item.localTrackingNumber}
|
||||||
|
</foreach>
|
||||||
|
end
|
||||||
|
where platform_order_id in
|
||||||
|
<foreach collection="data" separator="," open="(" close=")" index="index" item="item">
|
||||||
|
#{item.platformOrderId}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.business.service;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.jeecg.modules.business.controller.UserException;
|
import org.jeecg.modules.business.controller.UserException;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberData;
|
||||||
import org.jeecg.modules.business.entity.*;
|
import org.jeecg.modules.business.entity.*;
|
||||||
import org.jeecg.modules.business.vo.PlatformOrderOption;
|
import org.jeecg.modules.business.vo.PlatformOrderOption;
|
||||||
import org.jeecg.modules.business.vo.PlatformOrderQuantity;
|
import org.jeecg.modules.business.vo.PlatformOrderQuantity;
|
||||||
|
@ -257,4 +258,8 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
||||||
|
|
||||||
List<String> findReadyAbnormalOrdersWithSkus(List<String> skus);
|
List<String> findReadyAbnormalOrdersWithSkus(List<String> skus);
|
||||||
void updateShopifySynced(Collection<String> platformOrderIds);
|
void updateShopifySynced(Collection<String> platformOrderIds);
|
||||||
|
|
||||||
|
List<String> fetchShippedOrdersFromShopAndTransporters(String shopCode, List<String> transporters);
|
||||||
|
|
||||||
|
void updateLocalTrackingNumber(List<YDTrackingNumberData> data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.modules.business.controller.UserException;
|
import org.jeecg.modules.business.controller.UserException;
|
||||||
|
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberData;
|
||||||
import org.jeecg.modules.business.entity.*;
|
import org.jeecg.modules.business.entity.*;
|
||||||
import org.jeecg.modules.business.mapper.ExchangeRatesMapper;
|
import org.jeecg.modules.business.mapper.ExchangeRatesMapper;
|
||||||
import org.jeecg.modules.business.mapper.PlatformOrderContentMapper;
|
import org.jeecg.modules.business.mapper.PlatformOrderContentMapper;
|
||||||
|
@ -521,8 +522,19 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
||||||
public List<String> findReadyAbnormalOrdersWithSkus(List<String> skus) {
|
public List<String> findReadyAbnormalOrdersWithSkus(List<String> skus) {
|
||||||
return platformOrderMap.findReadyAbnormalOrdersWithSkus(skus);
|
return platformOrderMap.findReadyAbnormalOrdersWithSkus(skus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateShopifySynced(Collection<String> platformOrderIds) {
|
public void updateShopifySynced(Collection<String> platformOrderIds) {
|
||||||
platformOrderMap.updateShopifySynced(platformOrderIds);
|
platformOrderMap.updateShopifySynced(platformOrderIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> fetchShippedOrdersFromShopAndTransporters(String shopCode, List<String> transporters) {
|
||||||
|
return platformOrderMap.fetchShippedOrdersFromShopAndTransporters(shopCode, transporters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLocalTrackingNumber(List<YDTrackingNumberData> data) {
|
||||||
|
platformOrderMap.updateLocalTrackingNumber(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ ${AnsiColor.BRIGHT_BLUE}
|
||||||
|
|
||||||
|
|
||||||
${AnsiColor.BRIGHT_GREEN}
|
${AnsiColor.BRIGHT_GREEN}
|
||||||
WIA APP Version: 2.2.0
|
WIA APP Version: 2.4.1
|
||||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||||
Website: www.wia-sourcing.com
|
Website: www.wia-sourcing.com
|
||||||
${AnsiColor.BLACK}
|
${AnsiColor.BLACK}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -2,7 +2,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.jeecgframework.boot</groupId>
|
<groupId>org.jeecgframework.boot</groupId>
|
||||||
<artifactId>jeecg-boot-parent</artifactId>
|
<artifactId>jeecg-boot-parent</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>2.4.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>WIA APP ${project.version}</name>
|
<name>WIA APP ${project.version}</name>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue