|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tofly.monitor.screenDisplay.entity.dto.WisdomDisplayDto;
|
|
|
import com.tofly.monitor.screenDisplay.mapper.CustomDisplayMapper;
|
|
|
import com.tofly.pojo.IndexVal;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.messaging.Message;
|
|
@@ -19,238 +20,90 @@ import java.util.Map;
|
|
|
|
|
|
@Service("hangZhengTopicHandler")
|
|
|
@Slf4j
|
|
|
+@AllArgsConstructor
|
|
|
public class HangZhengTopicHandler implements TopicHandler {
|
|
|
|
|
|
- @Autowired
|
|
|
- private CustomDisplayMapper customDisplayMapper;
|
|
|
+ private final CustomDisplayMapper customDisplayMapper;
|
|
|
|
|
|
@Override
|
|
|
public void handler(Message<?> message) {
|
|
|
String payload = String.valueOf(message.getPayload());
|
|
|
Map<String,Object> payloads = JSON.parseObject(payload);
|
|
|
+
|
|
|
List<IndexVal> indexValList = new ArrayList<>();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
-
|
|
|
-
|
|
|
- if (payloads!=null&&payloads.get("device_id")!=null&&payloads.get("device_id").equals("7e7e0071200366")) {
|
|
|
- IndexVal indexVal = new IndexVal();
|
|
|
- Long id = SnowFlake.nextId();
|
|
|
- indexVal.setId(id);
|
|
|
- indexVal.setDeviceCode("wxnlytj");
|
|
|
- indexVal.setItCd("ss");
|
|
|
- indexVal.setItVal(String.valueOf(payloads.get("depth_of_water")));
|
|
|
- Date collectTime;
|
|
|
- try {
|
|
|
- collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
|
|
|
- indexVal.setScadaTime(collectTime);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- WisdomDisplayDto wis = new WisdomDisplayDto();
|
|
|
- wis.setIndexCode("ss");
|
|
|
- wis.setDeviceCode("wxnlytj");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal1 == null || indexVal1.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(indexVal);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- indexVal.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(indexVal);
|
|
|
- }
|
|
|
- indexVal.setId(id);
|
|
|
+
|
|
|
+ if (payloads != null && payloads.get("device_id") != null && payloads.get("device_id").equals("7e7e0071200366")) {
|
|
|
+ IndexVal indexVal = getIndexInfo(payloads,"ss","wxnlytj","depth_of_water");
|
|
|
indexValList.add(indexVal);
|
|
|
}
|
|
|
+
|
|
|
+ if (payloads != null && payloads.get("device_model") != null && payloads.get("device_model").equals("HZ-RLS-60L-50Pi")) {
|
|
|
+ IndexVal swIndexVal = getIndexInfo(payloads,"sw","ldswytj1","water_levels");
|
|
|
+ indexValList.add(swIndexVal);
|
|
|
|
|
|
-
|
|
|
- if (payloads!=null&&payloads.get("device_model")!=null&&payloads.get("device_model").equals("HZ-RLS-60L-50Pi")) {
|
|
|
- IndexVal swIndex = new IndexVal();
|
|
|
- Long id = SnowFlake.nextId();
|
|
|
- swIndex.setId(id);
|
|
|
- swIndex.setDeviceCode("ldswytj1");
|
|
|
- swIndex.setItCd("sw");
|
|
|
- swIndex.setItVal(String.valueOf(payloads.get("water_levels")));
|
|
|
- Date collectTime;
|
|
|
- try {
|
|
|
- collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
|
|
|
- swIndex.setScadaTime(collectTime);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- WisdomDisplayDto wis = new WisdomDisplayDto();
|
|
|
- wis.setIndexCode("sw");
|
|
|
- wis.setDeviceCode("ldswytj1");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal1 == null || indexVal1.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(swIndex);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- swIndex.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(swIndex);
|
|
|
- }
|
|
|
- swIndex.setId(id);
|
|
|
- indexValList.add(swIndex);
|
|
|
-
|
|
|
- IndexVal kgIndex = new IndexVal();
|
|
|
- id = SnowFlake.nextId();
|
|
|
- kgIndex.setId(id);
|
|
|
- kgIndex.setItCd("kg");
|
|
|
- kgIndex.setItVal(String.valueOf(payloads.get("ullage")));
|
|
|
- wis.setIndexCode("kg");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal2 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal2 == null || indexVal2.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(kgIndex);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- kgIndex.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(kgIndex);
|
|
|
- }
|
|
|
- kgIndex.setId(id);
|
|
|
- indexValList.add(kgIndex);
|
|
|
+ IndexVal kgIndexVal = getIndexInfo(payloads,"kg","ldswytj1","ullage");
|
|
|
+ indexValList.add(kgIndexVal);
|
|
|
}
|
|
|
+
|
|
|
+ if (payloads != null && payloads.get("device_model") != null && payloads.get("device_model").equals("HZ-RLS-60L-50")) {
|
|
|
+ IndexVal swIndexVal = getIndexInfo(payloads,"sw","ldswytj2","water_levels");
|
|
|
+ indexValList.add(swIndexVal);
|
|
|
|
|
|
-
|
|
|
- if (payloads!=null&&payloads.get("device_model")!=null&&payloads.get("device_model").equals("HZ-RLS-60L-50")) {
|
|
|
- IndexVal swIndex = new IndexVal();
|
|
|
- Long id = SnowFlake.nextId();
|
|
|
- swIndex.setId(id);
|
|
|
- swIndex.setDeviceCode("ldswytj2");
|
|
|
- swIndex.setItCd("sw");
|
|
|
- swIndex.setItVal(String.valueOf(payloads.get("water_levels")));
|
|
|
- Date collectTime;
|
|
|
- try {
|
|
|
- collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
|
|
|
- swIndex.setScadaTime(collectTime);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- WisdomDisplayDto wis = new WisdomDisplayDto();
|
|
|
- wis.setIndexCode("sw");
|
|
|
- wis.setDeviceCode("ldswytj2");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal1 == null || indexVal1.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(swIndex);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- swIndex.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(swIndex);
|
|
|
- }
|
|
|
- swIndex.setId(id);
|
|
|
- indexValList.add(swIndex);
|
|
|
-
|
|
|
- IndexVal kgIndex = new IndexVal();
|
|
|
- id = SnowFlake.nextId();
|
|
|
- kgIndex.setId(id);
|
|
|
- kgIndex.setItCd("kg");
|
|
|
- kgIndex.setItVal(String.valueOf(payloads.get("ullage")));
|
|
|
- wis.setIndexCode("kg");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal2 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal2 == null || indexVal2.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(kgIndex);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- kgIndex.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(kgIndex);
|
|
|
- }
|
|
|
- kgIndex.setId(id);
|
|
|
- indexValList.add(kgIndex);
|
|
|
+ IndexVal kgIndexVal = getIndexInfo(payloads,"kg","ldswytj2","ullage");
|
|
|
+ indexValList.add(kgIndexVal);
|
|
|
}
|
|
|
+
|
|
|
+ if (payloads != null && payloads.get("device_model") != null && payloads.get("device_model").equals("HZ-SVR-122QP")) {
|
|
|
+ IndexVal ssIndexVal = getIndexInfo(payloads,"ss","ldllj","water_levels");
|
|
|
+ indexValList.add(ssIndexVal);
|
|
|
|
|
|
-
|
|
|
- if (payloads!=null&&payloads.get("device_model")!=null&&payloads.get("device_model").equals("HZ-SVR-122QP")) {
|
|
|
- IndexVal ssIndex = new IndexVal();
|
|
|
- Long id = SnowFlake.nextId();
|
|
|
- ssIndex.setId(id);
|
|
|
- ssIndex.setDeviceCode("ldllj");
|
|
|
- ssIndex.setItCd("ss");
|
|
|
- ssIndex.setItVal(String.valueOf(payloads.get("water_levels")));
|
|
|
- Date collectTime;
|
|
|
- try {
|
|
|
- collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
|
|
|
- ssIndex.setScadaTime(collectTime);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- WisdomDisplayDto wis = new WisdomDisplayDto();
|
|
|
- wis.setIndexCode("ss");
|
|
|
- wis.setDeviceCode("ldllj");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal1 == null || indexVal1.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(ssIndex);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- ssIndex.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(ssIndex);
|
|
|
- }
|
|
|
- ssIndex.setId(id);
|
|
|
- indexValList.add(ssIndex);
|
|
|
-
|
|
|
- IndexVal ssllIndex = new IndexVal();
|
|
|
- id = SnowFlake.nextId();
|
|
|
- ssllIndex.setId(id);
|
|
|
- ssllIndex.setItCd("ssll");
|
|
|
- ssllIndex.setItVal(String.valueOf(payloads.get("instantaneous_flow")));
|
|
|
- wis.setIndexCode("ssll");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal2 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal2 == null || indexVal2.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(ssllIndex);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- ssllIndex.setId(Long.parseLong(String.valueOf(indexVal2.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(ssllIndex);
|
|
|
- }
|
|
|
- ssllIndex.setId(id);
|
|
|
- indexValList.add(ssllIndex);
|
|
|
+ IndexVal ssllIndexVal = getIndexInfo(payloads,"ssll","ldllj","instantaneous_flow");
|
|
|
+ indexValList.add(ssllIndexVal);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if (payloads!=null&&payloads.get("device_model")!=null&&payloads.get("device_model").equals("HZ-SVR-24V-200")) {
|
|
|
- IndexVal indexVal = new IndexVal();
|
|
|
- Long id = SnowFlake.nextId();
|
|
|
- indexVal.setId(id);
|
|
|
- indexVal.setDeviceCode("ldlsy");
|
|
|
- indexVal.setItCd("bmls");
|
|
|
- indexVal.setItVal(String.valueOf(payloads.get("surface_velocity")));
|
|
|
- Date collectTime;
|
|
|
- try {
|
|
|
- collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
|
|
|
- indexVal.setScadaTime(collectTime);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- WisdomDisplayDto wis = new WisdomDisplayDto();
|
|
|
- wis.setIndexCode("bmls");
|
|
|
- wis.setDeviceCode("ldlsy");
|
|
|
- wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
- List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
- if (indexVal1 == null || indexVal1.size() == 0) {
|
|
|
- List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
- indexValNewList.add(indexVal);
|
|
|
- customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
- }else {
|
|
|
- indexVal.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
|
|
|
- customDisplayMapper.updateTemp(indexVal);
|
|
|
- }
|
|
|
- indexVal.setId(id);
|
|
|
- indexValList.add(indexVal);
|
|
|
+
|
|
|
+ if (payloads != null && payloads.get("device_model") != null && payloads.get("device_model").equals("HZ-SVR-24V-200")) {
|
|
|
+ IndexVal ssIndexVal = getIndexInfo(payloads,"bmls","ldlsy","surface_velocity");
|
|
|
+ indexValList.add(ssIndexVal);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
customDisplayMapper.insertBacthTemp(indexValList,"tf_ywpn_monitor_history_copy");
|
|
|
log.info("handler(),串口数据接收,payload:{}", payload);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private IndexVal getIndexInfo(Map<String,Object> payloads, String indexCode, String deviceCode, String indexValCode){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ IndexVal indexVal = new IndexVal();
|
|
|
+ Long id = SnowFlake.nextId();
|
|
|
+ indexVal.setId(id);
|
|
|
+ indexVal.setDeviceCode(deviceCode);
|
|
|
+ indexVal.setItCd(indexCode);
|
|
|
+ indexVal.setItVal(String.valueOf(payloads.get(indexValCode)));
|
|
|
+ Date collectTime;
|
|
|
+ try {
|
|
|
+ collectTime = sdf.parse(String.valueOf(payloads.get("collect_time")));
|
|
|
+ indexVal.setScadaTime(collectTime);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ WisdomDisplayDto wis = new WisdomDisplayDto();
|
|
|
+ wis.setIndexCode(indexCode);
|
|
|
+ wis.setDeviceCode(deviceCode);
|
|
|
+ wis.setTableName("tf_ywpn_monitor_reatime_copy");
|
|
|
+ List<Map<String,Object>> indexVal1 = customDisplayMapper.viewCopyIndex(wis);
|
|
|
+ if (indexVal1 == null || indexVal1.size() == 0) {
|
|
|
+
|
|
|
+ List<IndexVal> indexValNewList = new ArrayList<>();
|
|
|
+ indexValNewList.add(indexVal);
|
|
|
+ customDisplayMapper.insertBacthTemp(indexValNewList,"tf_ywpn_monitor_reatime_copy");
|
|
|
+ }else {
|
|
|
+
|
|
|
+ indexVal.setId(Long.parseLong(String.valueOf(indexVal1.get(0).get("id"))));
|
|
|
+ customDisplayMapper.updateTemp(indexVal);
|
|
|
+ }
|
|
|
+ indexVal.setId(id);
|
|
|
+ return indexVal;
|
|
|
+ }
|
|
|
+
|
|
|
}
|