|
@@ -2,6 +2,7 @@ package com.yh.saas.plugin.yiliangyiyun.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.openapi.sdk.service.DataExchangeService;
|
|
import com.openapi.sdk.service.DataExchangeService;
|
|
@@ -25,9 +26,16 @@ import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.view.UserDefinedBean;
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.view.UserDefinedBean;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IHyBaoTokenService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IHyTokenService;
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IHyTokenService;
|
|
import com.yh.saas.plugin.yiliangyiyun.util.*;
|
|
import com.yh.saas.plugin.yiliangyiyun.util.*;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -39,6 +47,7 @@ import com.aliyuncs.profile.DefaultProfile;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
import com.aliyuncs.sts.model.v20150401.*;
|
|
import com.aliyuncs.sts.model.v20150401.*;
|
|
@@ -81,6 +90,8 @@ public class CommonUserController {
|
|
private WebSocket webSocket;
|
|
private WebSocket webSocket;
|
|
@Autowired
|
|
@Autowired
|
|
private IHyTokenService hyToken;
|
|
private IHyTokenService hyToken;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IHyBaoTokenService hyBaoTokenService;
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getAuth")
|
|
@GetMapping("/getAuth")
|
|
@@ -482,5 +493,141 @@ public class CommonUserController {
|
|
orderPath();
|
|
orderPath();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void loginBao() {
|
|
|
|
+ try {
|
|
|
|
+ Map<String, String> map = new HashMap<String, String>(4);
|
|
|
|
+ map.put("user", "d25e76de-31f6-4dc1-8009-3dbd17628e76");
|
|
|
|
+ map.put("pwd", "Xw846GfNv073t8779PrtMa6z02Ui43");
|
|
|
|
+ map.put("srt", "e8eaf629-014c-4884-a976-459380b9cb66");
|
|
|
|
+ map.put("cid", "dfaf33d6-68f0-4b3a-b9ba-9228a2480faf");
|
|
|
|
+ String url = "https://testopen.95155.com/save/apis/login";
|
|
|
|
+ // 设置http读写超时
|
|
|
|
+ DataExchangeService des = new DataExchangeService(5000, 8000);
|
|
|
|
+ System.out.println("请求地址:"+url);
|
|
|
|
+ // 通过https方式调用,此方法内部会使用私钥生成签名参数sign,私钥不会发送
|
|
|
|
+ String res = des.postHttps(url, map);
|
|
|
|
+ res = res.substring(1, res.length() - 1);
|
|
|
|
+ String[] strs = res.split(",");
|
|
|
|
+ Map<String, String> map1 = new HashMap<String, String>();
|
|
|
|
+ for (String string : strs) {
|
|
|
|
+ String key = string.split(":")[0];
|
|
|
|
+ String value = string.split(":")[1];
|
|
|
|
+ // 去掉头部空格
|
|
|
|
+ String key1 = key.trim().replaceAll("\"", "");
|
|
|
|
+ String value1 = value.trim().replaceAll("\"", "");
|
|
|
|
+ map1.put(key1, value1);
|
|
|
|
+ }
|
|
|
|
+ hyBaoTokenService.delete(new EntityWrapper<HyBaoToken>().eq("delete_flag", "0"));
|
|
|
|
+ HyBaoToken token = new HyBaoToken();
|
|
|
|
+ token.setId(IdGenerator.generateUUID());
|
|
|
|
+ token.setToken(map1.get("\"result\"").replaceAll("\"", ""));
|
|
|
|
+ hyBaoTokenService.insert(token);
|
|
|
|
+ System.out.println("返回:" + res);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ System.out.println("e:" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping("/baodan")
|
|
|
|
+ public void baodan() throws Exception {
|
|
|
|
+ HyBaoToken token = hyBaoTokenService.selectOne(new EntityWrapper<HyBaoToken>()
|
|
|
|
+ .eq("delete_flag", 0));
|
|
|
|
+ if (token == null) {
|
|
|
|
+ login();
|
|
|
|
+ token = hyBaoTokenService.selectOne(new EntityWrapper<HyBaoToken>()
|
|
|
|
+ .eq("delete_flag", "0"));
|
|
|
|
+ }
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("token", token.getToken());
|
|
|
|
+ params.put("cid", "dfaf33d6-68f0-4b3a-b9ba-9228a2480faf");
|
|
|
|
+ params.put("srt", "e8eaf629-014c-4884-a976-459380b9cb66");
|
|
|
|
+ JSONObject insurance = new JSONObject();
|
|
|
|
+ insurance.put("channelOrderId", "450324");
|
|
|
|
+ insurance.put("productCode", "P200001");
|
|
|
|
+ insurance.put("amount", 10000);
|
|
|
|
+ insurance.put("payMoney", 5);
|
|
|
|
+ JSONObject startPlace = new JSONObject();
|
|
|
|
+ startPlace.put("areaName", "安徽省安庆市枞阳县");
|
|
|
|
+ startPlace.put("areaCode", "340000-340800-340823");
|
|
|
|
+ JSONObject finishPlace = new JSONObject();
|
|
|
|
+ finishPlace.put("areaName", "安徽省安庆市枞阳县");
|
|
|
|
+ finishPlace.put("areaCode", "340000-340800-340823");
|
|
|
|
+ insurance.put("startPlace", startPlace);
|
|
|
|
+ insurance.put("finishPlace", finishPlace);
|
|
|
|
+
|
|
|
|
+// JSONObject vehicleInfoList = new JSONObject();
|
|
|
|
+ JSONObject vehicleInfoList1 = new JSONObject();
|
|
|
|
+ vehicleInfoList1.put("licensePlateNo", "陕YH0009");
|
|
|
|
+ List<JSONObject> vehicleInfoLists = new ArrayList<>();
|
|
|
|
+ vehicleInfoLists.add(vehicleInfoList1);
|
|
|
|
+ insurance.put("vehicleInfoList", vehicleInfoLists);
|
|
|
|
+
|
|
|
|
+// JSONObject goodsInfoList = new JSONObject();
|
|
|
|
+ JSONObject goodsInfoList1 = new JSONObject();
|
|
|
|
+ goodsInfoList1.put("goodsName", "玉米");
|
|
|
|
+ List<JSONObject> goodsInfoLists = new ArrayList<>();
|
|
|
|
+ goodsInfoLists.add(goodsInfoList1);
|
|
|
|
+ insurance.put("goodsInfoList", goodsInfoLists);
|
|
|
|
+
|
|
|
|
+ insurance.put("schemeCode",0);
|
|
|
|
+
|
|
|
|
+ JSONObject insurantInfoList = new JSONObject();
|
|
|
|
+ insurantInfoList.put("personnelType ", "1");
|
|
|
|
+ insurantInfoList.put("name", "王东镇");
|
|
|
|
+ insurantInfoList.put("certificateType", "01");
|
|
|
|
+ insurantInfoList.put("certificateNo", "210103195103222113");
|
|
|
|
+ insurantInfoList.put("mobile", "13333333333");
|
|
|
|
+ List<JSONObject> insurantInfoLists = new ArrayList<>();
|
|
|
|
+ insurantInfoLists.add(insurantInfoList);
|
|
|
|
+ insurance.put("insurantInfoList", insurantInfoLists);
|
|
|
|
+ params.put("insuranceInfoList", insurance);
|
|
|
|
+ String url = "https://testopen.95155.com/save/apis/bxcx_openapi_insure";
|
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
|
+ httpPost.setEntity(new StringEntity("[" + params.toString() + "]", StandardCharsets.UTF_8));
|
|
|
|
+ // 设置header信息
|
|
|
|
+ httpPost.setHeader("Content-type", "application/json");
|
|
|
|
+ httpPost.setHeader("token", token.getToken());
|
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
|
+
|
|
|
|
+ // 设置 http 读写超时
|
|
|
|
+ DataExchangeService des = new DataExchangeService(5000, 8000);
|
|
|
|
+ System.out.println("请求地址:" + url);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ // 执行请求操作,并拿到结果(同步阻塞)
|
|
|
|
+ String body = EntityUtils.toString(response.getEntity());
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
|
+ String result = jsonObject.getString("result");
|
|
|
|
+ System.out.println("result = " + result);
|
|
|
|
+ // 通过 https 方式调用,此方法内部会使用私钥生成签名参数 sign,私钥不会发送
|
|
|
|
+ if (result.contains("1016")) {
|
|
|
|
+ login();
|
|
|
|
+ baodan();
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ // 释放链接
|
|
|
|
+ response.close();
|
|
|
|
+ httpClient.close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// public static void main(String[] args)throws Exception {
|
|
|
|
+// this.baodan();
|
|
|
|
+// }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|