diff --git a/pom.xml b/pom.xml
index c2ad8c9..9b3f73c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -261,6 +261,11 @@
1.13
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
diff --git a/src/main/java/com/dreamchaser/depository_manage/config/JsonData.java b/src/main/java/com/dreamchaser/depository_manage/config/JsonData.java
new file mode 100644
index 0000000..a435828
--- /dev/null
+++ b/src/main/java/com/dreamchaser/depository_manage/config/JsonData.java
@@ -0,0 +1,100 @@
+package com.dreamchaser.depository_manage.config;
+
+public class JsonData {
+
+ /**
+ * 状态码 0表示成功过,1表示处理中,-1 表示失败
+ */
+ private Integer code;
+ /**
+ * 信息表示
+ */
+ private String msg;
+ /**
+ * 业务数据
+ */
+ private Object data;
+
+
+
+ public JsonData(){}
+
+ public JsonData(Integer code, Object data, String msg){
+ this.code = code;
+ this.data = data;
+ this.msg = msg;
+ }
+
+
+ /**
+ * 成功,不用返回数据
+ * @return
+ */
+ public static JsonData buildSuccess(){
+ return new JsonData(0,null,null);
+ }
+
+ /**
+ * 成功,返回数据
+ * @param data
+ * @return
+ */
+ public static JsonData buildSuccess(Object data){
+ return new JsonData(0,data,null);
+ }
+
+
+ /**
+ * 失败,固定状态码
+ * @param msg
+ * @return
+ */
+ public static JsonData buildError(String msg){
+ return new JsonData(1 ,null,msg);
+ }
+
+
+ /**
+ * 失败,自定义错误码和信息
+ * @param code
+ * @param msg
+ * @return
+ */
+ public static JsonData buildError(Integer code , String msg){
+ return new JsonData(code ,null,msg);
+ }
+
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ @Override
+ public String toString() {
+ return "JsonData{" +
+ "code=" + code +
+ ", msg='" + msg + '\'' +
+ ", data=" + data +
+ '}';
+ }
+}
diff --git a/src/main/java/com/dreamchaser/depository_manage/config/PublicConfig.java b/src/main/java/com/dreamchaser/depository_manage/config/PublicConfig.java
index 64efd72..7f141fa 100644
--- a/src/main/java/com/dreamchaser/depository_manage/config/PublicConfig.java
+++ b/src/main/java/com/dreamchaser/depository_manage/config/PublicConfig.java
@@ -8,6 +8,7 @@ import com.dreamchaser.depository_manage.entity.Post;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.pojo.AdministrationP;
import com.dreamchaser.depository_manage.utils.HttpUtils;
+import com.dreamchaser.depository_manage.utils.Md5;
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil;
import lombok.Data;
import org.apache.http.protocol.HTTP;
@@ -155,9 +156,66 @@ public class PublicConfig {
}
return userByPortList;
}
+ /**
+ * 外网获取userkey 和 number
+ * @return
+ */
+ public static Map getWaiKeyNumber(){
+
+ String url = "http://172.20.2.87:39168/empower/gaintoken";
+
+ Map map = new HashMap<>();
+ map.put("username", "luruankeji");
+ map.put("password", "lu@ruan#ke$ji");
+ String jsonString = JSONObject.toJSONString(map);
+ JSONObject paramObject = JSONObject.parseObject(jsonString);
+ String post = null;
+ try {
+ post = HttpUtils.send1(url, paramObject, HTTP.UTF_8);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ /*System.out.println(url);
+ System.out.println(jsonString);
+ System.out.println(JSONObject.toJSONString(post));*/
+ JSONObject jsonObject = JSONObject.parseObject(post);
+ JSONObject data = (JSONObject) jsonObject.get("data");
+ //{"number":"17612902927927","token":"691586a906491adc0a385688f5743ed5"}
+ String codeString = data.get("number").toString();
+
+ String token = data.get("token").toString();
+ String appKey = "luquan_hr";
+
+ String one1 = Md5.crypt(codeString);
+ String one2 = Md5.crypt(appKey);
+ String one = one1+one2;
+ System.out.println("one");
+ System.out.println(one);
+ String two = Md5.crypt(one)+appKey;
+ System.out.println("two");
+ System.out.println(two);
+ String therr = Md5.crypt(two);
+ System.out.println("therr");
+ System.out.println(therr);
+ String number = therr;
+ Map map1 = new HashMap<>();
+ map1.put("token",token);
+ map1.put("number",number);
+
+ //System.out.println("11111111111111111111111111111111111111111111111111111111111111111");
+ return map1;
+ }
+
+
+
+
// 通过获取的企业微信UserId获取数据库中的用户以及对应key与token
public static Map findUserByQyWxUserId(String userId) {
+ Map TokenNumberMap = getWaiKeyNumber();
+
+ System.out.println("getWaiKeyNumbergetWaiKeyNumbergetWaiKeyNumbergetWaiKeyNumbergetWaiKeyNumbergetWaiKeyNumber");
+ System.out.println(TokenNumberMap);
String url = external_url + "/staff/wechat_give_uscont";
Map result = new HashMap<>();
Map map = new HashMap<>();
@@ -166,10 +224,14 @@ public class PublicConfig {
JSONObject paramObject = JSONObject.parseObject(jsonString);
String post = null;
try {
- post = HttpUtils.send(url, paramObject, HTTP.UTF_8, null, null);
+ post = HttpUtils.send2(url, paramObject, HTTP.UTF_8, TokenNumberMap.get("token"), TokenNumberMap.get("number"));
} catch (IOException e) {
e.printStackTrace();
}
+ System.out.println(url);
+ //System.out.println("userId---> "+userId);
+ System.out.println(jsonString);
+ System.out.println(JSONObject.toJSONString(post));
JSONObject jsonObject = JSONObject.parseObject(post);
JSONObject data = (JSONObject) jsonObject.get("data");
UserByPort userByPort = JSONObject.toJavaObject((JSONObject) data.get("userinfo"), UserByPort.class);
diff --git a/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java b/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java
index 007882c..6c9ff17 100644
--- a/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java
+++ b/src/main/java/com/dreamchaser/depository_manage/utils/HttpUtils.java
@@ -244,6 +244,100 @@ public class HttpUtils {
+ /**
+ * 发送post请求
+ * @param url 路径
+ * @param jsonObject 参数(json类型)
+ * @param encoding 编码格式
+ * @return
+ * @throws ParseException
+ * @throws IOException
+ */
+ public static String send1(String url, JSONObject jsonObject, String encoding) throws ParseException, IOException{
+ String body = "";
+ //创建httpclient对象
+ CloseableHttpClient client = HttpClients.createDefault();
+ //创建post方式请求对象
+ HttpPost httpPost = new HttpPost(url);
+ //装填参数
+ StringEntity s = new StringEntity(jsonObject.toString(), "utf-8");
+ s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
+ "application/json"));
+ //设置参数到请求对象中
+ httpPost.setEntity(s);
+
+// System.out.println("请求参数:"+nvps.toString());
+
+ //设置header信息
+ //指定报文头【Content-type】、【User-Agent】
+ httpPost.setHeader("Content-type", "application/json");
+ httpPost.setHeader("Origin", "http://172.20.2.87");
+ httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+ System.out.println("请求地址:"+url);
+
+ //执行请求操作,并拿到结果(同步阻塞)
+ CloseableHttpResponse response = client.execute(httpPost);
+ //获取结果实体
+ org.apache.http.HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ //按指定编码转换结果实体为String类型
+ body = EntityUtils.toString(entity, encoding);
+ //System.out.println(body);
+ }
+ EntityUtils.consume(entity);
+ //释放链接
+ response.close();
+ return body;
+ }
+ /**
+ * 发送post请求
+ * @param url 路径
+ * @param jsonObject 参数(json类型)
+ * @param encoding 编码格式
+ * @return
+ * @throws ParseException
+ * @throws IOException
+ */
+ public static String send2(String url, JSONObject jsonObject, String encoding,String token,String number) throws ParseException, IOException{
+ String body = "";
+ //创建httpclient对象
+ CloseableHttpClient client = HttpClients.createDefault();
+ //创建post方式请求对象
+ HttpPost httpPost = new HttpPost(url);
+ //装填参数
+ StringEntity s = new StringEntity(jsonObject.toString(), "utf-8");
+ s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
+ "application/json"));
+ //设置参数到请求对象中
+ httpPost.setEntity(s);
+
+// System.out.println("请求参数:"+nvps.toString());
+
+ //设置header信息
+ //指定报文头【Content-type】、【User-Agent】
+ httpPost.setHeader("Content-type", "application/json");
+ httpPost.setHeader("Origin", "http://172.20.2.87");
+ httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+ httpPost.setHeader("token", token);
+ httpPost.setHeader("number", number);
+ System.out.println("请求地址:"+url);
+
+ //执行请求操作,并拿到结果(同步阻塞)
+ CloseableHttpResponse response = client.execute(httpPost);
+ //获取结果实体
+ org.apache.http.HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ //按指定编码转换结果实体为String类型
+ body = EntityUtils.toString(entity, encoding);
+ //System.out.println(body);
+ }
+ EntityUtils.consume(entity);
+ //释放链接
+ response.close();
+ return body;
+ }
+
+
}
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 1d70235..be5eb2f 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,6 +1,6 @@
spring:
profiles:
- active: test
+ active: prod
server:
port: 11111
#port: 13122
\ No newline at end of file