|
|
@@ -1,14 +1,22 @@
|
|
|
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;
|
|
|
import com.sf.csim.express.service.HttpClientUtil;
|
|
|
import com.sf.csim.express.service.IServiceCodeStandard;
|
|
|
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.KYPriceQueryReq;
|
|
|
import com.uas.eis.entity.sf.*;
|
|
|
import com.uas.eis.service.ERPService;
|
|
|
import com.uas.eis.utils.*;
|
|
|
+
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -376,4 +384,226 @@ public class ERPServiceImpl implements ERPService {
|
|
|
retMap.put("message","取消成功。");
|
|
|
return retMap;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getLogisticsPrice(Integer id) {
|
|
|
+ Map<String, Object> modelMap = new HashMap<String, Object>();
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select * from LogisticsPrice where lp_id="+id);
|
|
|
+ if(rs.next()){
|
|
|
+ Map<String, Object> data = new HashMap<String, Object>();
|
|
|
+ //顺丰
|
|
|
+ getPrice_SF(id,rs.getGeneralString("LP_TYPE"),rs.getGeneralDouble("LP_WEIGHT"),rs.getGeneralDouble("LP_VOLUME"),
|
|
|
+ "上海市",//rs.getGeneralString("上海市"),
|
|
|
+ rs.getGeneralString("lp_route"),
|
|
|
+ "广东省","深圳市");
|
|
|
+ data.put("SF", id);
|
|
|
+ //跨越
|
|
|
+ //getPrice_KY(id);
|
|
|
+ /* getPrice_DoP(id);*/
|
|
|
+ modelMap.put("success", true);
|
|
|
+ }else{
|
|
|
+ modelMap.put("message", "单据不存在!");
|
|
|
+ modelMap.put("success", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return modelMap;
|
|
|
+ }
|
|
|
+ //
|
|
|
+ private Map<String, Object> getPrice_DoP(Integer id){
|
|
|
+ /*
|
|
|
+ * http://dpsanbox.deppon.com/sandbox-web/standard-order/queryPriceTime.action
|
|
|
+ * params String 核算请求参数 是
|
|
|
+ digest String 区域密文摘要 是
|
|
|
+ timestamp String 核算当前时间戳 ,当前时间毫秒数 是
|
|
|
+ companyCode String 核算第三方接入商的公司编码(双方约定,建议公司简拼或者代码,字母大写)请求报文字段 是
|
|
|
+ * */
|
|
|
+ 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");
|
|
|
+ String CALL_URL = obs[0].toString();
|
|
|
+ String CHECK_WORD = obs[1].toString();
|
|
|
+ /* 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.setTotalVolume("0.001");
|
|
|
+ doPPriceQueryReq.setTotalWeight("500");
|
|
|
+ String msgData = FastJsonUtil.toJSONString(doPPriceQueryReq);
|
|
|
+ String timeStamp = SecurityUtil.getTimestamp();
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
+ String appkey="6c64b3a0a580ac616b2e74454b6be7dc";
|
|
|
+ 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);
|
|
|
+ return retMap;
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ retMap.put("success",false);
|
|
|
+ retMap.put("message","获取失败"+(StringUtil.nvl(e.getMessage(),"")));
|
|
|
+ logger.info("getPrice_dop-F:id {} err {}",id,retMap.get("message"));
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //跨越
|
|
|
+ private Map<String, Object> getPrice_KY(Integer id){
|
|
|
+ /*
|
|
|
+ 正式环境:https://open.ky-express.com/router/rest
|
|
|
+ 沙箱环境:https://open.ky-express.com/sandbox/router/rest
|
|
|
+ ======================================================
|
|
|
+ 参数名称 类型 是否必填 描述
|
|
|
+ appkey string 是 应用key 11000
|
|
|
+ format string 是 返回参数格式(默认json) json
|
|
|
+ timestamp string 否 时间戳 12345672333
|
|
|
+ method string 是 请求方法 open.api.openCommon.queryFreightCharge
|
|
|
+ sign string 否 签名 CF529FFB8B49499EC30BE2C29C02AE67
|
|
|
+ token string 是 请求票据 eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....
|
|
|
+ */
|
|
|
+ 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");
|
|
|
+ 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();
|
|
|
+ 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);
|
|
|
+ String bizBody = FlexJsonUtil.toJsonDeep(kyPriceQueryReq);
|
|
|
+ System.out.println(appkey);
|
|
|
+ System.out.println(appSecret);
|
|
|
+ String response = KyeDefaultOpenApi.builder(appkey, appSecret ) //应用Key,密钥
|
|
|
+ .env("uat") // //对应环境,包含(uat:测试环境,prod:生产环境),获取对应环境的请求路径
|
|
|
+ .api(method) //所调用Api Code
|
|
|
+ .sandbox(isSandbox) //是否沙盒环境(env=prod且isSandbox=true时对应的就是跨越测试环境)
|
|
|
+ .body(bizBody) //请求体参数,可接受字符串,List,Map三种类型的参数
|
|
|
+ .connectTimeout(3000) //连接超时时间
|
|
|
+ .readTimeout(15000) //读取超时时间
|
|
|
+ .request()
|
|
|
+ .response();
|
|
|
+ System.out.println(response);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ retMap.put("success",false);
|
|
|
+ retMap.put("message","获取失败"+(StringUtil.nvl(e.getMessage(),"")));
|
|
|
+ logger.info("getPrice_KY-F:id {} err {}",id,retMap.get("message"));
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ Map<String,Object> retMap = new HashMap<>();
|
|
|
+ /*生产环境地址 https://bspgw.sf-express.com/std/service
|
|
|
+ 沙箱环境地址 https://sfapi-sbox.sf-express.com/std/service*/
|
|
|
+ /*1 partnerID String(64) 是 合作伙伴编码(即顾客编码)
|
|
|
+ 2 requestID String(40) 是 请求唯一号UUID
|
|
|
+ 3 serviceCode String(50) 是 接口服务代码
|
|
|
+ 4 timestamp long 是 调用接口时间戳
|
|
|
+ 5 msgDigest String(128) 条件 数字签名,使用数字签名方式认证时必填
|
|
|
+ 6 accessToken Number 条件 访问令牌,使用OAuth2方式认证时必填
|
|
|
+ 7 msgData String 是 业务数据报文*/
|
|
|
+ try{
|
|
|
+ Object[] obs = baseDao.getFieldsDataByCondition("SZSI_P.DOCK_LOGISTICS_CONFIG A "
|
|
|
+ , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='SF' and type_='GETPRICE' AND A.ENABLE_ = 1");
|
|
|
+ String msgData = "";
|
|
|
+ String businessType="";
|
|
|
+ if("特快".equals(type)){
|
|
|
+ businessType="1";
|
|
|
+ }else if("标快".equals(type)){
|
|
|
+ businessType="2";
|
|
|
+ }else if("物流".equals(type)){
|
|
|
+ businessType="255";//卡航
|
|
|
+ }
|
|
|
+ SFPriceQueryReq sfPriceQueryReq=new SFPriceQueryReq();
|
|
|
+ sfPriceQueryReq.setBusinessType(businessType);//特快
|
|
|
+ sfPriceQueryReq.setWeight(weight);
|
|
|
+ sfPriceQueryReq.setVolume(volume);
|
|
|
+ //sfPriceQueryReq.setConsignedTime("2025-03-14 09:00:00");
|
|
|
+ //目的地
|
|
|
+ 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);
|
|
|
+
|
|
|
+ msgData = FlexJsonUtil.toJsonDeep(sfPriceQueryReq);
|
|
|
+ CallExpressServiceTools tools=CallExpressServiceTools.getInstance();
|
|
|
+ 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());
|
|
|
+
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
+ params.put("partnerID", CLIENT_CODE); // 顾客编码 ,对应丰桥上获取的clientCode
|
|
|
+ params.put("requestID", UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ params.put("serviceCode",ExpressServiceCodeEnum.EXP_RECE_QUERY_DELIVERTM.getCode());// 接口服务码
|
|
|
+ params.put("timestamp", timeStamp);
|
|
|
+ params.put("msgData", msgData);
|
|
|
+ params.put("msgDigest", tools.getMsgDigest(msgData,timeStamp,CHECK_WORD));
|
|
|
+ String result = HttpClientUtil.post(CALL_URL, params);
|
|
|
+ SFApiResp sfApiResp= FlexJsonUtil.fromJson(result, SFApiResp.class);
|
|
|
+ if(sfApiResp!=null){
|
|
|
+ if("A1000".equals(sfApiResp.getApiResultCode())){
|
|
|
+ String apiResultData = sfApiResp.getApiResultData();
|
|
|
+ SFPriceApiResultData sfPriceApiResultData=FlexJsonUtil.fromJson(apiResultData, SFPriceApiResultData.class);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("result:"+result);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ retMap.put("success",false);
|
|
|
+ retMap.put("message","获取失败"+(StringUtil.nvl(e.getMessage(),"")));
|
|
|
+ logger.info("getPrice_SF-F:id {} err {}",id,retMap.get("message"));
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
}
|