Commit 9ae08238 authored by wujiang's avatar wujiang

提交代码

parent 30aae562
...@@ -95,4 +95,6 @@ public class EquipmentIndexVO implements Serializable { ...@@ -95,4 +95,6 @@ public class EquipmentIndexVO implements Serializable {
private String newAddress; private String newAddress;
private String dType;
} }
...@@ -91,23 +91,29 @@ public class MqttConnector implements Connector, MqttCallback { ...@@ -91,23 +91,29 @@ public class MqttConnector implements Connector, MqttCallback {
{ {
com.alibaba.fastjson.JSONObject msg = com.alibaba.fastjson.JSONObject.parseObject(message.toString()); com.alibaba.fastjson.JSONObject msg = com.alibaba.fastjson.JSONObject.parseObject(message.toString());
String node = msg.getString("node"); String node = msg.getString("node");
if(node.contains("fan")) Map<String,String> map = null;
if(node.contains("fan2.5"))
{ {
gatewayId="1668801435891929089"; gatewayId="1668801435891929089";
map=SystemInit.fanmap.get("fan2.5");
}else if(node.contains("fan3.45"))
{
gatewayId="1668801435891929089";
map=SystemInit.fanmap.get("fan3.45");
}else if(node.contains("station")) }else if(node.contains("station"))
{ {
gatewayId="1668801570352926721"; gatewayId="1668801570352926721";
map=SystemInit.map.get(gatewayId);
}else }else
{ {
return; return;
} }
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)) if(map!=null&&map.containsKey(key))
{ {
String oldAddress = map.get(key); String oldAddress = map.get(key);
result.put("address",oldAddress); result.put("address",oldAddress);
...@@ -142,7 +148,7 @@ public class MqttConnector implements Connector, MqttCallback { ...@@ -142,7 +148,7 @@ public class MqttConnector implements Connector, MqttCallback {
for(String key:vobj.keySet()) for(String key:vobj.keySet())
{ {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
if(map.containsKey(key)) if(map!=null&&map.containsKey(key))
{ {
String oldAddress = map.get(key); String oldAddress = map.get(key);
result.put("address",oldAddress); result.put("address",oldAddress);
......
...@@ -20,23 +20,46 @@ public class SystemInit { ...@@ -20,23 +20,46 @@ public class SystemInit {
public static Map<String, Map<String,String>> map = new HashMap<>(); public static Map<String, Map<String,String>> map = new HashMap<>();
public static Map<String, Map<String,String>> fanmap = new HashMap<>();
@Autowired @Autowired
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper; private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@PostConstruct @PostConstruct
public void point() public void point()
{ {
List<EquipmentIndexVO> list = equipmentSpecificIndexMapper.getEquipSpecificIndexList(null); EquipmentIndexVO equipmentIndexVO = new EquipmentIndexVO();
Map<String, Map<String, String>> result = list.stream() equipmentIndexVO.setDType("null");
equipmentIndexVO.setNewAddress("notnull");
List<EquipmentIndexVO> list = equipmentSpecificIndexMapper.getEquipSpecificIndexList(equipmentIndexVO);
Map<String,List<EquipmentIndexVO>> glist = list.stream()
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
EquipmentIndexVO::getGatewayId, EquipmentIndexVO::getGatewayId
Collectors.toMap(
vo-> Optional.ofNullable(vo.getNewAddress()).orElse(""),
EquipmentIndexVO::getIndexAddress
)
)); ));
map=result; for(String key :glist.keySet())
{
Map<String,String> map1 = new HashMap<>();
for(EquipmentIndexVO v : glist.get(key))
{
map1.put(v.getNewAddress(),v.getIndexAddress());
}
map.put(key,map1);
}
equipmentIndexVO.setDType("notnull");
List<EquipmentIndexVO> list2 = equipmentSpecificIndexMapper.getEquipSpecificIndexList(equipmentIndexVO);
Map<String,List<EquipmentIndexVO>> list3 = list2.stream()
.collect(Collectors.groupingBy(
EquipmentIndexVO::getDType
));
for(String key :list3.keySet())
{
Map<String,String> map1 = new HashMap<>();
for(EquipmentIndexVO v : list3.get(key))
{
map1.put(v.getNewAddress(),v.getIndexAddress());
}
fanmap.put(key,map1);
}
} }
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<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"/> <result property="newAddress" column="new_address"/>
<result property="dType" column="d_type"/>
</resultMap> </resultMap>
<select id="getEquipSpecificIndexList" resultMap="ComplementCode"> <select id="getEquipSpecificIndexList" resultMap="ComplementCode">
...@@ -32,7 +33,8 @@ ...@@ -32,7 +33,8 @@
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 si.new_address,
si.d_type
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
...@@ -43,6 +45,15 @@ ...@@ -43,6 +45,15 @@
<if test="isIot != null and isIot !=''"> <if test="isIot != null and isIot !=''">
AND ei.is_iot = #{isIot} AND ei.is_iot = #{isIot}
</if> </if>
<if test="newAddress =='notnull'">
AND si.new_address is not null
</if>
<if test="dType =='null'">
AND si.d_type is null
</if>
<if test="dType =='notnull'">
AND si.d_type is not null
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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