Commit 30aae562 authored by wujiang's avatar wujiang

提交代码

parent 35b81f8b
...@@ -93,4 +93,6 @@ public class EquipmentIndexVO implements Serializable { ...@@ -93,4 +93,6 @@ public class EquipmentIndexVO implements Serializable {
@ApiModelProperty(value = "装备指标名称") @ApiModelProperty(value = "装备指标名称")
private String equipmentIndexName; private String equipmentIndexName;
private String newAddress;
} }
...@@ -43,7 +43,6 @@ public class EquipmentSpecificIndex extends BaseEntity { ...@@ -43,7 +43,6 @@ public class EquipmentSpecificIndex extends BaseEntity {
@ApiModelProperty(value = "装备名称(冗余字段)") @ApiModelProperty(value = "装备名称(冗余字段)")
@TableField("equipment_specific_name") @TableField("equipment_specific_name")
private String equipmentSpecificName; private String equipmentSpecificName;
// equipmentSpecialName
@ApiModelProperty(value = "指标名称(冗余字段)") @ApiModelProperty(value = "指标名称(冗余字段)")
@TableField("equipment_index_name") @TableField("equipment_index_name")
...@@ -104,8 +103,6 @@ public class EquipmentSpecificIndex extends BaseEntity { ...@@ -104,8 +103,6 @@ public class EquipmentSpecificIndex extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String indexName; private String indexName;
@TableField(exist = false) @TableField(exist = false)
private String equipmentSpecificIndexName; private String equipmentSpecificIndexName;
...@@ -206,4 +203,7 @@ public class EquipmentSpecificIndex extends BaseEntity { ...@@ -206,4 +203,7 @@ public class EquipmentSpecificIndex extends BaseEntity {
@ApiModelProperty(value = "网关标识") @ApiModelProperty(value = "网关标识")
@TableField(value = "gateway_id") @TableField(value = "gateway_id")
private String gatewayId; private String gatewayId;
@TableField(value = "new_address")
private String newAddress;
} }
...@@ -6,6 +6,7 @@ import com.yeejoin.equip.kafka.KafkaProducerService; ...@@ -6,6 +6,7 @@ import com.yeejoin.equip.kafka.KafkaProducerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
...@@ -17,6 +18,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -17,6 +18,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Component @Component
@Slf4j @Slf4j
@DependsOn("SystemInit")
public class ConnectionManager { public class ConnectionManager {
private final Map<String, Connector> connectors = new ConcurrentHashMap<>(); private final Map<String, Connector> connectors = new ConcurrentHashMap<>();
......
...@@ -103,10 +103,18 @@ public class MqttConnector implements Connector, MqttCallback { ...@@ -103,10 +103,18 @@ public class MqttConnector implements Connector, MqttCallback {
} }
String values = msg.getString("values"); String values = msg.getString("values");
JSONObject vobj = JSONObject.parseObject(values,JSONObject.class); JSONObject vobj = JSONObject.parseObject(values,JSONObject.class);
Map<String,String> map = SystemInit.map.get(gatewayId);
for(String key:vobj.keySet()) for(String key:vobj.keySet())
{ {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if(map.containsKey(key))
{
String oldAddress = map.get(key);
result.put("address",oldAddress);
}else
{
result.put("address",key); result.put("address",key);
}
result.put("value",vobj.get(key)); result.put("value",vobj.get(key));
result.put("gatewayId",gatewayId); result.put("gatewayId",gatewayId);
//log.info("===========接收MQTT订阅消息,address:{},gatewayId:{},value:{}", address,gatewayId,value); //log.info("===========接收MQTT订阅消息,address:{},gatewayId:{},value:{}", address,gatewayId,value);
...@@ -130,10 +138,18 @@ public class MqttConnector implements Connector, MqttCallback { ...@@ -130,10 +138,18 @@ public class MqttConnector implements Connector, MqttCallback {
} }
String values = msg.getString("values"); String values = msg.getString("values");
JSONObject vobj = JSONObject.parseObject(values,JSONObject.class); JSONObject vobj = JSONObject.parseObject(values,JSONObject.class);
Map<String,String> map = SystemInit.map.get(gatewayId);
for(String key:vobj.keySet()) for(String key:vobj.keySet())
{ {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if(map.containsKey(key))
{
String oldAddress = map.get(key);
result.put("address",oldAddress);
}else
{
result.put("address",key); result.put("address",key);
}
result.put("value",vobj.get(key)); result.put("value",vobj.get(key));
result.put("gatewayId",gatewayId); result.put("gatewayId",gatewayId);
//log.info("===========接收MQTT订阅消息,address:{},gatewayId:{},value:{}", address,gatewayId,value); //log.info("===========接收MQTT订阅消息,address:{},gatewayId:{},value:{}", address,gatewayId,value);
......
package com.yeejoin.equip.eqmx;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.equip.entity.EquipmentIndexVO;
import com.yeejoin.equip.entity.EquipmentSpecificIndex;
import com.yeejoin.equip.mapper.mysql.EquipmentSpecificIndexMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@Component("SystemInit")
public class SystemInit {
public static Map<String, Map<String,String>> map = new HashMap<>();
@Autowired
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@PostConstruct
public void point()
{
List<EquipmentIndexVO> list = equipmentSpecificIndexMapper.getEquipSpecificIndexList(null);
Map<String, Map<String, String>> result = list.stream()
.collect(Collectors.groupingBy(
EquipmentIndexVO::getGatewayId,
Collectors.toMap(
vo-> Optional.ofNullable(vo.getNewAddress()).orElse(""),
EquipmentIndexVO::getIndexAddress
)
));
map=result;
}
}
...@@ -187,7 +187,7 @@ public class ElasticSearchUtil { ...@@ -187,7 +187,7 @@ public class ElasticSearchUtil {
@Override @Override
public void onResponse(UpdateResponse updateResponse) { public void onResponse(UpdateResponse updateResponse) {
if (DocWriteResponse.Result.UPDATED.equals(updateResponse.getResult())) { if (DocWriteResponse.Result.UPDATED.equals(updateResponse.getResult())) {
log.info("索引:【{}】,主键:【{}】修改成功", indexName, id); //log.info("索引:【{}】,主键:【{}】修改成功", indexName, id);
} }
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<result property="equipmentIndexName" column="equipment_index_name"/> <result property="equipmentIndexName" column="equipment_index_name"/>
<result property="equipmentSpecificName" column="equipment_specific_name"/> <result property="equipmentSpecificName" column="equipment_specific_name"/>
<result property="dataType" column="data_type"/> <result property="dataType" column="data_type"/>
<result property="newAddress" column="new_address"/>
</resultMap> </resultMap>
<select id="getEquipSpecificIndexList" resultMap="ComplementCode"> <select id="getEquipSpecificIndexList" resultMap="ComplementCode">
...@@ -30,7 +31,8 @@ ...@@ -30,7 +31,8 @@
si.data_type, si.data_type,
si.equipment_specific_name, si.equipment_specific_name,
si.equipment_index_name, si.equipment_index_name,
si.is_alarm si.is_alarm,
si.new_address
FROM FROM
wl_equipment_specific_index si wl_equipment_specific_index si
LEFT JOIN wl_equipment_index ei ON si.equipment_index_id = ei.id LEFT JOIN wl_equipment_index ei ON si.equipment_index_id = ei.id
......
...@@ -59,10 +59,11 @@ public class JXDZExecute { ...@@ -59,10 +59,11 @@ public class JXDZExecute {
@Scheduled(cron = "0 0 */1 * * ?") @Scheduled(cron = "0 0 */1 * * ?")
@PostConstruct
public void hourInterface() { public void hourInterface() {
// if (!jxdzScheduledEnable) { if (!jxdzScheduledEnable) {
// return; return;
// } }
log.info("开始执行小时任务"); log.info("开始执行小时任务");
//发送请求传入的参数 //发送请求传入的参数
NeedDataVO needDataVO = new NeedDataVO(); NeedDataVO needDataVO = new NeedDataVO();
...@@ -149,6 +150,7 @@ public class JXDZExecute { ...@@ -149,6 +150,7 @@ public class JXDZExecute {
} }
@Scheduled(cron = "0 0 1 * * ?") @Scheduled(cron = "0 0 1 * * ?")
@PostConstruct
public void dayInterface() { public void dayInterface() {
if (!jxdzScheduledEnable) { if (!jxdzScheduledEnable) {
return; return;
......
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils; package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import cn.hutool.crypto.asymmetric.SM2;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.csii.pp.icbc.util.SM2Utils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO; import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.component.robot.AmosRequestContext; import com.yeejoin.amos.component.robot.AmosRequestContext;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
//import org.bouncycastle.asn1.gm.GMNamedCurves; import org.bouncycastle.asn1.gm.GMNamedCurves;
//import org.bouncycastle.asn1.x9.X9ECParameters; import org.bouncycastle.asn1.x9.X9ECParameters;
//import org.bouncycastle.crypto.engines.SM2Engine; import org.bouncycastle.crypto.engines.SM2Engine;
//import org.bouncycastle.crypto.params.ECDomainParameters; import org.bouncycastle.crypto.params.ECDomainParameters;
//import org.bouncycastle.crypto.params.ECPublicKeyParameters; import org.bouncycastle.crypto.params.ECPublicKeyParameters;
//import org.bouncycastle.crypto.params.ParametersWithRandom; import org.bouncycastle.crypto.params.ParametersWithRandom;
//import org.bouncycastle.math.ec.ECPoint; import org.bouncycastle.math.ec.ECPoint;
//import org.bouncycastle.util.encoders.Hex; import org.bouncycastle.util.encoders.Hex;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*; import org.springframework.http.*;
...@@ -20,6 +22,7 @@ import org.springframework.stereotype.Component; ...@@ -20,6 +22,7 @@ import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.List; import java.util.List;
...@@ -33,7 +36,7 @@ import java.util.Objects; ...@@ -33,7 +36,7 @@ import java.util.Objects;
public class JXDZUtils { public class JXDZUtils {
@Value("${coreIp:iiet-jepcc.powerchina.cn:8088}") @Value("${coreIp:iiet-jepcc.powerchina.cn:8088}")
String coreIp; String coreIp;
@Value("${jxdzIp:122.70.153.215:9003}") @Value("${jxdzIp:210.12.143.88:9003}")
String jxdzIp; String jxdzIp;
@Value("${jxdzTokenUserName:jiangxi_epc}") @Value("${jxdzTokenUserName:jiangxi_epc}")
String jxdzTokenUserName; String jxdzTokenUserName;
...@@ -49,25 +52,24 @@ public class JXDZUtils { ...@@ -49,25 +52,24 @@ public class JXDZUtils {
public static String GF_CODE="PPC17063608260011"; public static String GF_CODE="PPC17063608260011";
private String dataEncrypt(String obj, String publicKey) { private String dataEncrypt(String obj, String publicKey) {
// X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1"); X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
// ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(), ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(),
// sm2ECParameters.getN(), sm2ECParameters.getH()); sm2ECParameters.getN(), sm2ECParameters.getH());
// ECPoint pukPoint = sm2ECParameters.getCurve() ECPoint pukPoint = sm2ECParameters.getCurve()
// .decodePoint(Hex.decode(publicKey)); .decodePoint(Hex.decode(publicKey));
// ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters); ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
// SM2Engine.Mode mode = SM2Engine.Mode.C1C3C2; SM2Engine.Mode mode = SM2Engine.Mode.C1C3C2;
// SM2Engine sm2Engine = new SM2Engine(mode); SM2Engine sm2Engine = new SM2Engine(mode);
// // 设置sm2为加密模式 // 设置sm2为加密模式
// sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom())); sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom()));
// byte[] arrayOfBytes = null; byte[] arrayOfBytes = null;
// byte[] in = obj.getBytes(StandardCharsets.UTF_8); byte[] in = obj.getBytes(StandardCharsets.UTF_8);
// try { try {
// arrayOfBytes = sm2Engine.processBlock(in, 0, in.length); arrayOfBytes = sm2Engine.processBlock(in, 0, in.length);
// } catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); e.printStackTrace();
// } }
// return Base64.encode(arrayOfBytes); return Base64.encode(arrayOfBytes);
return null;
} }
...@@ -222,6 +224,11 @@ public class JXDZUtils { ...@@ -222,6 +224,11 @@ public class JXDZUtils {
jsonObject.put("time", time); jsonObject.put("time", time);
jsonObject.put("data", data); jsonObject.put("data", data);
log.info("发送的原始数据{}",jsonObject); log.info("发送的原始数据{}",jsonObject);
// try {
// return SM2Utils.encrypt(publicKey.getBytes(),jsonObject.toJSONString().getBytes());
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
return dataEncrypt(jsonObject.toJSONString(), publicKey); return dataEncrypt(jsonObject.toJSONString(), publicKey);
} }
} }
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