Commit 9a5a28e1 authored by KeYong's avatar KeYong

Merge branch 'develop_dl' of http://39.98.45.134:8090/moa/amos-boot-biz into develop_dl

parents 8c5e31e9 91640e91
......@@ -16,4 +16,6 @@ public interface ICcsToStationUserInfo {
* 保存用户信息至redis
*/
void saveUserInfoToRedis() throws Exception;
void test() throws Exception;
}
......@@ -48,6 +48,8 @@ public class StartLoader implements ApplicationRunner {
loadSysParams();
// 监听中心级登录信息
ccsToStationUserInfo.saveUserInfoToRedis();
ccsToStationUserInfo.test();
}
public void loadSysParams(){
......
......@@ -2,12 +2,15 @@ package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.yeejoin.amos.boot.module.jcs.api.dto.AuthDataDto;
import com.yeejoin.amos.boot.module.jcs.api.service.ICcsToStationUserInfo;
import com.yeejoin.amos.boot.module.jcs.biz.config.StartLoader;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -17,9 +20,15 @@ import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener;
import org.typroject.tyboot.core.auth.face.model.SsoSessionsModel;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.xml.crypto.Data;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
......@@ -78,9 +87,52 @@ public class CcsToStationUserInfoImpl implements ICcsToStationUserInfo {
if (!ValidationUtil.isEmpty(obj)) {
JSONObject json = JSON.parseObject(obj);
JSONObject body = JSON.parseObject(JSON.toJSONString(json.get("body")));
SsoSessionsModel ssoSessionsModel = new SsoSessionsModel();
AuthDataDto authData = JSON.parseObject(JSON.toJSONString(body.get("authData")), AuthDataDto.class);
if (!ObjectUtils.isEmpty(authData)) {
createSession(authData);
try {
BeanUtils.copyProperties(authData, ssoSessionsModel);
createSession(ssoSessionsModel);
} catch (Exception e) {
logger.error("同步用户登录信息失败:{}", e.getMessage());
}
}
}
});
} catch (Exception e) {
logger.info("订阅中心级用户登录信息异常>>{}", e.getMessage());
}
}
@Override
public void test() {
try {
emqKeeper.subscript("zxjlc/cs", 0, new EmqxListener() {
@Override
public void processMessage(String s, MqttMessage mqttMessage) throws MqttException {
byte[] payload = mqttMessage.getPayload();
String obj = new String(payload);
if (!ValidationUtil.isEmpty(obj)) {
JSONObject json = JSON.parseObject(obj);
String isOk = JSON.toJSONString(json.get("is_ok"));
if (!"1".equals(isOk)) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("indexKey", "TEST20230508WB");
jsonObject.put("indexValue", json.get("is_ok"));
jsonObject.put("traceId", json.get("id"));
JSONObject jsonObject1 = new JSONObject();
JSONObject jsonObject2 = new JSONObject();
jsonObject1.put("warningObjectName", "巡检点");
jsonObject1.put("warningObjectCode", json.get("input_id"));
jsonObject1.put("sourceAttribution", "LSHLZ1yOrS3WfXqzjn");
jsonObject1.put("sourceAttributionDesc", "鄱阳湖");
jsonObject2.put("tabName", "页签");
jsonObject2.put("tabContent", new ArrayList<>());
jsonObject1.put("dynamicDetails", jsonObject2);
jsonObject.put("bizInfo", jsonObject1);
emqKeeper.getMqttClient().publish("patrol/data/analysis", jsonObject.toJSONString().getBytes(StandardCharsets.UTF_8), 1, false);
// mqttSendGateway.sendToMqtt("patrol/data/analysis", JSON.toJSONString(jsonObject));
}
}
}
......@@ -90,7 +142,7 @@ public class CcsToStationUserInfoImpl implements ICcsToStationUserInfo {
}
}
private void createSession(AuthDataDto authData) {
private void createSession(SsoSessionsModel authData) {
this.removeSession(authData.getActionByProduct(),authData.getLoginId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment