|
|
@@ -1,8 +1,7 @@
|
|
|
package com.uas.eis.service.Impl;
|
|
|
|
|
|
-import com.deppon.dop.module.sdk.shared.domain.price.QueryPriceRequest;
|
|
|
+
|
|
|
import com.deppon.dop.module.sdk.shared.util.FastJsonUtil;
|
|
|
-import com.deppon.dop.module.sdk.shared.util.HttpUtils;
|
|
|
import com.deppon.dop.module.sdk.shared.util.SecurityUtil;
|
|
|
import com.kyexpress.openapi.sdk.KyeDefaultOpenApi;
|
|
|
import com.sf.csim.express.service.CallExpressServiceTools;
|
|
|
@@ -12,6 +11,8 @@ import com.sf.csim.express.service.code.ExpressServiceCodeEnum;
|
|
|
import com.uas.eis.core.config.SpObserver;
|
|
|
import com.uas.eis.dao.*;
|
|
|
import com.uas.eis.entity.dop.DoPPriceQueryReq;
|
|
|
+import com.uas.eis.entity.ky.KYApiResp;
|
|
|
+import com.uas.eis.entity.ky.KYPirceData;
|
|
|
import com.uas.eis.entity.ky.KYPriceQueryReq;
|
|
|
import com.uas.eis.entity.sf.*;
|
|
|
import com.uas.eis.service.ERPService;
|
|
|
@@ -389,18 +390,22 @@ public class ERPServiceImpl implements ERPService {
|
|
|
public Map<String, Object> getLogisticsPrice(String master, Integer id) {
|
|
|
SpObserver.putSp(master);
|
|
|
Map<String, Object> modelMap = new HashMap<String, Object>();
|
|
|
- SqlRowList rs = baseDao.queryForRowSet("select * from LogisticsPrice where lp_id="+id);
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select LP_ID, LP_CODE, LP_INDATE, LP_CALDATE, LP_TYPE, LP_ROUTE, LP_WEIGHT, LP_VOLUME, LP_RECIPIENT, LP_TEL, LP_ADD, LP_RECORDER, LP_COMPANY1, LP_PROVINCE, LP_DISTRICT, LP_SENDDATETIME,to_char(LP_SENDDATETIME,'yyyy-mm-dd hh24:mi:ss') SENDDATETIME" +
|
|
|
+ " from LogisticsPrice where lp_id="+id);
|
|
|
if(rs.next()){
|
|
|
Map<String, Object> data = new HashMap<String, Object>();
|
|
|
+ System.out.println(rs.getString("SENDDATETIME"));
|
|
|
//顺丰
|
|
|
getPrice_SF(id,rs.getGeneralString("LP_TYPE"),rs.getGeneralDouble("LP_WEIGHT"),rs.getGeneralDouble("LP_VOLUME"),
|
|
|
rs.getGeneralString("lp_province"),
|
|
|
rs.getGeneralString("lp_route"),
|
|
|
- "广东省","深圳市");
|
|
|
- data.put("SF", id);
|
|
|
+ "广东省","深圳市",
|
|
|
+ rs.getDate("LP_SENDDATETIME"));
|
|
|
//跨越
|
|
|
- //getPrice_KY(id);
|
|
|
- /* getPrice_DoP(id);*/
|
|
|
+ getPrice_KY(id,rs.getGeneralString("LP_TYPE"),rs.getGeneralDouble("LP_WEIGHT"), rs.getGeneralString("lp_route"),
|
|
|
+ rs.getDate("LP_SENDDATETIME"));
|
|
|
+ /* getPrice_DoP(id,rs.getGeneralString("LP_TYPE")//,rs.getGeneralDouble("LP_WEIGHT"), rs.getGeneralString("lp_route"),rs.getGeneralString("SENDDATETIME")
|
|
|
+ );*/
|
|
|
modelMap.put("success", true);
|
|
|
}else{
|
|
|
modelMap.put("message", "单据不存在!");
|
|
|
@@ -410,7 +415,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
return modelMap;
|
|
|
}
|
|
|
//
|
|
|
- private Map<String, Object> getPrice_DoP(Integer id){
|
|
|
+ private Map<String, Object> getPrice_DoP(Integer id,String type){
|
|
|
/*
|
|
|
* http://dpsanbox.deppon.com/sandbox-web/standard-order/queryPriceTime.action
|
|
|
* params String 核算请求参数 是
|
|
|
@@ -421,42 +426,54 @@ public class ERPServiceImpl implements ERPService {
|
|
|
Map<String,Object> retMap = new HashMap<>();
|
|
|
try{
|
|
|
Object[] obs = baseDao.getFieldsDataByCondition("SZSI_P.DOCK_LOGISTICS_CONFIG A "
|
|
|
- , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='DOPTEST' and type_='GETPRICE' AND A.ENABLE_ = 1");
|
|
|
+ , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='DOP' and type_='GETPRICE' AND A.ENABLE_ = 1");
|
|
|
String CALL_URL = obs[0].toString();
|
|
|
String CHECK_WORD = obs[1].toString();
|
|
|
+ /* 特快:TZKJC(特快当日)
|
|
|
+ 普快:RCP(大件快递3.60)
|
|
|
+ 物流:HKDJG(航空大件隔日达)
|
|
|
+ */
|
|
|
+ String businessType="";
|
|
|
+ if("特快".equals(type)){
|
|
|
+ businessType="TZKJC";
|
|
|
+ }else if("普快".equals(type)){
|
|
|
+ businessType="RCP";//RCP
|
|
|
+ }else if("物流".equals(type)){
|
|
|
+ businessType="HKDJG";//HKDJG
|
|
|
+ }
|
|
|
/* originalsStreet": "上海-上海市-长宁区",
|
|
|
"originalsaddress": "上海-上海市-长宁区",
|
|
|
"sendDateTime": "2018-08-07 11:00:03",
|
|
|
"totalVolume": 0.001,
|
|
|
"totalWeight": 500,*/
|
|
|
- /*QueryPriceRequest queryPriceRequest=new QueryPriceRequest();
|
|
|
- queryPriceRequest.setLogisticCompanyID("DEPPON");
|
|
|
- queryPriceRequest.setOriginalProvince("广东省");
|
|
|
- queryPriceRequest.setOriginalCity("深圳市");
|
|
|
- queryPriceRequest.setDestProvince("广东省");
|
|
|
- queryPriceRequest.setDestCity("深圳市");*/
|
|
|
- //queryPriceRequest.set
|
|
|
DoPPriceQueryReq doPPriceQueryReq=new DoPPriceQueryReq();
|
|
|
+ //目标城市
|
|
|
doPPriceQueryReq.setOriginalsStreet("上海-上海市-长宁区");
|
|
|
- doPPriceQueryReq.setOriginalsaddress("上海-上海市-长宁区");
|
|
|
- doPPriceQueryReq.setSendDateTime("2025-03-14 11:00:03");
|
|
|
+ //出发城市
|
|
|
+ doPPriceQueryReq.setOriginalsaddress("广东省-深圳市-龙岗区");
|
|
|
+ doPPriceQueryReq.setSendDateTime("2025-03-22 11:00:03");
|
|
|
doPPriceQueryReq.setTotalVolume("0.001");
|
|
|
- doPPriceQueryReq.setTotalWeight("500");
|
|
|
+ doPPriceQueryReq.setTotalWeight("30");
|
|
|
+ doPPriceQueryReq.setProductCode(businessType);//特快专递
|
|
|
String msgData = FastJsonUtil.toJSONString(doPPriceQueryReq);
|
|
|
String timeStamp = SecurityUtil.getTimestamp();
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
- String appkey="6c64b3a0a580ac616b2e74454b6be7dc";
|
|
|
+ String appkey="8626840f067f147f983c499e03e1a873";
|
|
|
String digest= SecurityUtil.getDigest(msgData+appkey+timeStamp);
|
|
|
System.out.println(msgData);
|
|
|
- System.out.println(timeStamp);
|
|
|
- System.out.println(digest);
|
|
|
-
|
|
|
params.put("params", msgData);
|
|
|
params.put("digest", digest);
|
|
|
params.put("timestamp", timeStamp);
|
|
|
params.put("companyCode", CHECK_WORD);
|
|
|
String result = HttpClientUtil.post(CALL_URL, params);
|
|
|
System.out.println(result);
|
|
|
+ /*DoPApiResp dopApiResp= FlexJsonUtil.fromJson(result, DoPApiResp.class);
|
|
|
+ if(dopApiResp!=null){
|
|
|
+ if("true".equals(dopApiResp.getResult())){
|
|
|
+ *//* String responseParam= dopApiResp.getResponseParam();
|
|
|
+ DoPPriceMsgData doPPriceMsgData=FlexJsonUtil.fromJson(responseParam, DoPPriceMsgData.class);*//*
|
|
|
+ }
|
|
|
+ }*/
|
|
|
return retMap;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
@@ -467,7 +484,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
}
|
|
|
}
|
|
|
//跨越
|
|
|
- private Map<String, Object> getPrice_KY(Integer id){
|
|
|
+ private Map<String, Object> getPrice_KY(Integer id,String type,double weight,String city_d,Date sendDateTime){
|
|
|
/*
|
|
|
正式环境:https://open.ky-express.com/router/rest
|
|
|
沙箱环境:https://open.ky-express.com/sandbox/router/rest
|
|
|
@@ -483,27 +500,38 @@ public class ERPServiceImpl implements ERPService {
|
|
|
Map<String,Object> retMap = new HashMap<>();
|
|
|
try{
|
|
|
Object[] obs = baseDao.getFieldsDataByCondition("SZSI_P.DOCK_LOGISTICS_CONFIG A "
|
|
|
- , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='KYTEST' and type_='GETPRICE' AND A.ENABLE_ = 1");
|
|
|
+ , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='KY' and type_='GETPRICE' AND A.ENABLE_ = 1");
|
|
|
String timeStamp = String.valueOf(System.currentTimeMillis());
|
|
|
// 是否沙盒环境 true标识沙盒环境,false标识正式环境,发布生产环境时注意切换
|
|
|
boolean isSandbox = true;
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
- String appkey="83913";//obs[1].toString();
|
|
|
- String appSecret ="DF10929B05F1963BC3A6F140CEF1892E";// obs[2].toString();
|
|
|
+ String appkey="83955";//obs[1].toString();
|
|
|
+ String appSecret = obs[2].toString();//"46129BED8B381806B1FE15562523E2E0";
|
|
|
+ String businessType="";
|
|
|
+ /*次日达(特快),隔日达(普快),陆运件(物流)
|
|
|
+ * 10-当天达,20-次日达,30-隔日达,40-陆运件,50-同城次日,70-同城即日,160-省内次日,170-省内即日,210-空运,220-专运
|
|
|
+ * */
|
|
|
+ if("特快".equals(type)){
|
|
|
+ businessType="20";
|
|
|
+ }else if("普快".equals(type)){
|
|
|
+ businessType="30";
|
|
|
+ }else if("物流".equals(type)){
|
|
|
+ businessType="40";
|
|
|
+ }
|
|
|
params.put("format","json");
|
|
|
params.put("timestamp",timeStamp);
|
|
|
String method="open.api.openCommon.queryFreightCharge";
|
|
|
KYPriceQueryReq kyPriceQueryReq=new KYPriceQueryReq();
|
|
|
kyPriceQueryReq.setBeginAreaCode("0755");
|
|
|
- kyPriceQueryReq.setBeginAreaCode("0711");
|
|
|
- kyPriceQueryReq.setBillingTime("2025-03-14 14:25");
|
|
|
- kyPriceQueryReq.setPickupCustomerCode("075525131031");
|
|
|
- kyPriceQueryReq.setWeight(50.00);
|
|
|
+ kyPriceQueryReq.setBeginCityName("深圳");
|
|
|
+ kyPriceQueryReq.setBillingTime(DateUtil.format(sendDateTime,"yyyy-MM-dd HH:mm:ss"));
|
|
|
+ kyPriceQueryReq.setEndCityName(city_d);
|
|
|
+ kyPriceQueryReq.setWeight(weight);
|
|
|
+
|
|
|
String bizBody = FlexJsonUtil.toJsonDeep(kyPriceQueryReq);
|
|
|
- System.out.println(appkey);
|
|
|
- System.out.println(appSecret);
|
|
|
- String response = KyeDefaultOpenApi.builder(appkey, appSecret ) //应用Key,密钥
|
|
|
- .env("uat") // //对应环境,包含(uat:测试环境,prod:生产环境),获取对应环境的请求路径
|
|
|
+ System.out.println("msgData:"+bizBody);
|
|
|
+ String result = KyeDefaultOpenApi.builder(appkey, appSecret ) //应用Key,密钥
|
|
|
+ .env("prod") // //对应环境,包含(uat:测试环境,prod:生产环境),获取对应环境的请求路径
|
|
|
.api(method) //所调用Api Code
|
|
|
.sandbox(isSandbox) //是否沙盒环境(env=prod且isSandbox=true时对应的就是跨越测试环境)
|
|
|
.body(bizBody) //请求体参数,可接受字符串,List,Map三种类型的参数
|
|
|
@@ -511,7 +539,19 @@ public class ERPServiceImpl implements ERPService {
|
|
|
.readTimeout(15000) //读取超时时间
|
|
|
.request()
|
|
|
.response();
|
|
|
- System.out.println(response);
|
|
|
+ System.out.println(result);
|
|
|
+ KYApiResp kyApiResp= FlexJsonUtil.fromJson(result, KYApiResp.class);
|
|
|
+ if(kyApiResp.isSuccess()){
|
|
|
+ for(KYPirceData ky:kyApiResp.getData()){
|
|
|
+ if(businessType.equals(ky.getServiceMode())){
|
|
|
+ if(ky.getTotalJF()!=null){
|
|
|
+ baseDao.execute("update LogisticsPrice set lp_msg3='',LP_REALTIMEPRICE3="+ky.getTotalJF()+" where lp_id="+id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ baseDao.execute("update LogisticsPrice set lp_msg3='"+kyApiResp.getMsg()+"' where lp_id="+id);
|
|
|
+ }
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
retMap.put("success",false);
|
|
|
@@ -522,7 +562,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
return retMap;
|
|
|
}
|
|
|
//顺丰
|
|
|
- private Map<String, Object> getPrice_SF(Integer id,String type,double weight,double volume,String province_d,String city_d,String province_s,String city_s) {
|
|
|
+ private Map<String, Object> getPrice_SF(Integer id,String type,double weight,double volume,String province_d,String city_d,String province_s,String city_s,Date sendDateTime) {
|
|
|
Map<String,Object> retMap = new HashMap<>();
|
|
|
/*生产环境地址 https://bspgw.sf-express.com/std/service
|
|
|
沙箱环境地址 https://sfapi-sbox.sf-express.com/std/service*/
|
|
|
@@ -540,7 +580,7 @@ public class ERPServiceImpl implements ERPService {
|
|
|
String businessType="";
|
|
|
if("特快".equals(type)){
|
|
|
businessType="1";
|
|
|
- }else if("标快".equals(type)){
|
|
|
+ }else if("普快".equals(type)){
|
|
|
businessType="2";
|
|
|
}else if("物流".equals(type)){
|
|
|
businessType="255";//卡航
|
|
|
@@ -549,16 +589,14 @@ public class ERPServiceImpl implements ERPService {
|
|
|
sfPriceQueryReq.setBusinessType(businessType);//特快
|
|
|
sfPriceQueryReq.setWeight(weight);
|
|
|
sfPriceQueryReq.setVolume(volume);
|
|
|
- //sfPriceQueryReq.setConsignedTime("2025-03-14 09:00:00");
|
|
|
+ sfPriceQueryReq.setConsignedTime(DateUtil.format(sendDateTime,"yyyy-MM-dd HH:mm:ss"));
|
|
|
//目的地
|
|
|
SFDestAddress sfDestAddress=new SFDestAddress();
|
|
|
sfDestAddress.setProvince(province_d);
|
|
|
sfDestAddress.setCity(city_d);
|
|
|
- //sfDestAddress.setCode("3310");//不是这个code
|
|
|
sfPriceQueryReq.setDestAddress(sfDestAddress);
|
|
|
//寄件方信息
|
|
|
SFSrcAddress srcAddress=new SFSrcAddress();
|
|
|
- //srcAddress.setCode("5840");//深圳?
|
|
|
srcAddress.setProvince(province_s);
|
|
|
srcAddress.setCity(city_s);
|
|
|
sfPriceQueryReq.setSrcAddress(srcAddress);
|
|
|
@@ -568,9 +606,6 @@ public class ERPServiceImpl implements ERPService {
|
|
|
String CLIENT_CODE = obs[1].toString();
|
|
|
String CHECK_WORD = obs[2].toString();
|
|
|
String CALL_URL = obs[0].toString();
|
|
|
- System.out.println("CALL_URL:"+CALL_URL);
|
|
|
- System.out.println("CLIENT_CODE:"+CLIENT_CODE);
|
|
|
- System.out.println("CHECK_WORD:"+CHECK_WORD);
|
|
|
System.out.println("msgData:"+msgData);
|
|
|
String timeStamp = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
|
@@ -590,11 +625,12 @@ public class ERPServiceImpl implements ERPService {
|
|
|
if(sfPriceApiResultData.isSuccess()){
|
|
|
for(SFPriceDeliverTmDto sfd:sfPriceApiResultData.getMsgData().getDeliverTmDto() ){
|
|
|
if(businessType.equals(sfd.getBusinessType()) && sfd.getFee() !=null){
|
|
|
- baseDao.execute("update LogisticsPrice set LP_REALTIMEPRICE1="+sfd.getFee()+" where lp_id="+id);
|
|
|
+ baseDao.execute("update LogisticsPrice set lp_msg1='',LP_REALTIMEPRICE1="+sfd.getFee()+" where lp_id="+id);
|
|
|
}
|
|
|
}
|
|
|
+ }else{
|
|
|
+ baseDao.execute("update LogisticsPrice set lp_msg1='"+sfPriceApiResultData.getErrorMsg()+"', where lp_id="+id);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
System.out.println("result:"+result);
|