|
|
@ -1,20 +1,15 @@ |
|
|
|
package com.kms.config; |
|
|
|
package com.water; |
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.http.HttpRequest; |
|
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.jianwei.common.core.domain.AjaxResult; |
|
|
|
import com.jianwei.common.exception.CustomException; |
|
|
|
import com.kms.config.scheduled.WaterScheduled; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
@ -50,6 +45,10 @@ public class WaterRequestUtil { |
|
|
|
//验证用户登录
|
|
|
|
@Value("${water.userUrl}") |
|
|
|
public String userUrl; |
|
|
|
|
|
|
|
@Value("${water.messageUrl}") |
|
|
|
public String messageUrl; |
|
|
|
|
|
|
|
@Value("${water.authUserServiceId}") |
|
|
|
public String authUserServiceId; |
|
|
|
@Value("${water.authUserAppsecret}") |
|
|
@ -194,6 +193,71 @@ public class WaterRequestUtil { |
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
HttpRequest httpRequest = HttpRequest.post("http://210.76.82.26:880/ebus/1606128918164250625/services/am-msgc/msgc/open-api/msg/add"); |
|
|
|
// String tifTimestamp = String.valueOf(new Date().getTime() / 1000);
|
|
|
|
// String tspTimestamp = String.valueOf(new Date().getTime() / 1000);
|
|
|
|
//
|
|
|
|
// String tifnonce = IdUtil.fastSimpleUUID();
|
|
|
|
// String tspnonce = IdUtil.fastSimpleUUID();
|
|
|
|
// String tifSignature = tifTimestamp + "459c2793c1434cf781cc6ed644c29ecd" + tifnonce + tifTimestamp;
|
|
|
|
// String tspSignature = tspTimestamp + "sgc-jg~sMO8Ha2" + tspnonce + tspTimestamp;
|
|
|
|
//// System.out.println(signature);
|
|
|
|
// try {
|
|
|
|
// tifSignature = SHACoder.encodeSHA256Hex(tifSignature).toUpperCase();
|
|
|
|
// tspSignature = SHACoder.encodeSHA256Hex(tspSignature).toUpperCase();
|
|
|
|
//
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
// httpRequest
|
|
|
|
// .header("x-tsp-paasid","sgc-jg")
|
|
|
|
// .header("x-tsp-signature",tspSignature)
|
|
|
|
// .header("x-tsp-timestamp",tspTimestamp)
|
|
|
|
// .header("x-tsp-nonce", tspnonce)
|
|
|
|
// .header("x-tif-paasid","jgThinking")
|
|
|
|
// .header("x-tif-signature",tifSignature)
|
|
|
|
// .header("x-tif-timestamp",tifTimestamp)
|
|
|
|
// .header("x-tif-nonce",tifnonce)
|
|
|
|
// .header("Authorization","xxxx");
|
|
|
|
//// .header("x-tsp-serviceid","DGSP_1606192911177592833")
|
|
|
|
//// .header("x-tsp-appsecret","4961464000044bb6907e9b61d736d194");
|
|
|
|
|
|
|
|
|
|
|
|
String tifTimestamp = String.valueOf(new Date().getTime() / 1000); |
|
|
|
String tspTimestamp = String.valueOf(new Date().getTime() / 1000); |
|
|
|
String nonceTif = IdUtil.fastSimpleUUID(); |
|
|
|
String nonceTsp = IdUtil.fastSimpleUUID(); |
|
|
|
String tifSignature = tifTimestamp + "459c2793c1434cf781cc6ed644c29ecd" + nonceTif + tifTimestamp; |
|
|
|
String tspSignature = tspTimestamp + "sgc-jg~sMO8Ha2" + nonceTsp + tspTimestamp; |
|
|
|
// System.out.println(signature);
|
|
|
|
try { |
|
|
|
tifSignature = SHACoder.encodeSHA256Hex(tifSignature).toUpperCase(); |
|
|
|
tspSignature = SHACoder.encodeSHA256Hex(tspSignature).toUpperCase(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
httpRequest |
|
|
|
.header("x-tsp-paasid","sgc-jg") |
|
|
|
.header("x-tsp-signature",tspSignature) |
|
|
|
.header("x-tsp-timestamp",tspTimestamp) |
|
|
|
.header("x-tsp-nonce", nonceTsp) |
|
|
|
.header("x-tif-paasid","jgThinking") |
|
|
|
.header("x-tif-signature",tifSignature) |
|
|
|
.header("x-tif-timestamp",tifTimestamp) |
|
|
|
.header("x-tif-nonce",nonceTif); |
|
|
|
JSONObject reqJson = new JSONObject(); |
|
|
|
reqJson.put("content",1); |
|
|
|
reqJson.put("receiveNo","20240311000002"); |
|
|
|
reqJson.put("receiver","1"); |
|
|
|
reqJson.put("contentType","提醒"); |
|
|
|
reqJson.put("type","inMail"); |
|
|
|
reqJson.put("msg_send_type","2-6"); |
|
|
|
String body = httpRequest.body(reqJson.toJSONString()).execute().body(); |
|
|
|
System.out.println(body); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 单点登录 |
|
|
@ -307,6 +371,27 @@ public class WaterRequestUtil { |
|
|
|
return waterResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 发送消息通知 |
|
|
|
* @param messageType |
|
|
|
* @param content |
|
|
|
* @param userId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public WaterResult sendMessage(String messageType,String content,String userId,String username){ |
|
|
|
JSONObject reqJson = new JSONObject(); |
|
|
|
reqJson.put("content",content); |
|
|
|
reqJson.put("receiveNo",userId); |
|
|
|
reqJson.put("receiver",username); |
|
|
|
reqJson.put("type",messageType); |
|
|
|
HttpRequest post = createPost(messageUrl , null, null); |
|
|
|
String body = post.body(reqJson.toJSONString()).execute() |
|
|
|
.body(); |
|
|
|
WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); |
|
|
|
isSuccess(waterResult); |
|
|
|
return waterResult; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void isSuccess(WaterResult waterResult){ |