Commit 9ae08238 authored by wujiang's avatar wujiang

提交代码

parent 30aae562
......@@ -95,4 +95,6 @@ public class EquipmentIndexVO implements Serializable {
private String newAddress;
private String dType;
}
......@@ -91,23 +91,29 @@ public class MqttConnector implements Connector, MqttCallback {
{
com.alibaba.fastjson.JSONObject msg = com.alibaba.fastjson.JSONObject.parseObject(message.toString());
String node = msg.getString("node");
if(node.contains("fan"))
Map<String,String> map = null;
if(node.contains("fan2.5"))
{
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"))
{
gatewayId="1668801570352926721";
map=SystemInit.map.get(gatewayId);
}else
{
return;
}
String values = msg.getString("values");
JSONObject vobj = JSONObject.parseObject(values,JSONObject.class);
Map<String,String> map = SystemInit.map.get(gatewayId);
for(String key:vobj.keySet())
{
JSONObject result = new JSONObject();
if(map.containsKey(key))
if(map!=null&&map.containsKey(key))
{
String oldAddress = map.get(key);
result.put("address",oldAddress);
......@@ -142,7 +148,7 @@ public class MqttConnector implements Connector, MqttCallback {
for(String key:vobj.keySet())
{
JSONObject result = new JSONObject();
if(map.containsKey(key))
if(map!=null&&map.containsKey(key))
{
String oldAddress = map.get(key);
result.put("address",oldAddress);
......
......@@ -20,23 +20,46 @@ public class SystemInit {
public static Map<String, Map<String,String>> map = new HashMap<>();
public static Map<String, Map<String,String>> fanmap = new HashMap<>();
@Autowired
private EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@PostConstruct
public void point()
{
List<EquipmentIndexVO> list = equipmentSpecificIndexMapper.getEquipSpecificIndexList(null);
Map<String, Map<String, String>> result = list.stream()
EquipmentIndexVO equipmentIndexVO = new EquipmentIndexVO();
equipmentIndexVO.setDType("null");
equipmentIndexVO.setNewAddress("notnull");
List<EquipmentIndexVO> list = equipmentSpecificIndexMapper.getEquipSpecificIndexList(equipmentIndexVO);
Map<String,List<EquipmentIndexVO>> glist = list.stream()
.collect(Collectors.groupingBy(
EquipmentIndexVO::getGatewayId,
Collectors.toMap(
vo-> Optional.ofNullable(vo.getNewAddress()).orElse(""),
EquipmentIndexVO::getIndexAddress
)
EquipmentIndexVO::getGatewayId
));
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 @@
<result property="equipmentSpecificName" column="equipment_specific_name"/>
<result property="dataType" column="data_type"/>
<result property="newAddress" column="new_address"/>
<result property="dType" column="d_type"/>
</resultMap>
<select id="getEquipSpecificIndexList" resultMap="ComplementCode">
......@@ -32,7 +33,8 @@
si.equipment_specific_name,
si.equipment_index_name,
si.is_alarm,
si.new_address
si.new_address,
si.d_type
FROM
wl_equipment_specific_index si
LEFT JOIN wl_equipment_index ei ON si.equipment_index_id = ei.id
......@@ -43,6 +45,15 @@
<if test="isIot != null and isIot !=''">
AND ei.is_iot = #{isIot}
</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>
</select>
</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