|
|
|
|
@ -17,18 +17,19 @@ import org.springblade.core.tool.utils.Charsets; |
|
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
|
import org.springblade.lims.entry.Instrument; |
|
|
|
|
import org.springblade.lims.entry.InstrumentData; |
|
|
|
|
import org.springblade.lims.entry.InstrumentStatus; |
|
|
|
|
import org.springblade.lims.entry.LargeScreenVO; |
|
|
|
|
import org.springblade.lims.mqtt.client.MyMQTTClient; |
|
|
|
|
import org.springblade.lims.mqtt.config.MqttConfiguration; |
|
|
|
|
import org.springblade.lims.service.IInstrumentDataService; |
|
|
|
|
import org.springblade.lims.service.IInstrumentService; |
|
|
|
|
import org.springblade.lims.service.IInstrumentStatusService; |
|
|
|
|
import org.springblade.lims.service.ILargeScreenService; |
|
|
|
|
import org.springblade.lims.tools.RedisLock; |
|
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
|
import org.springblade.system.entity.Dict; |
|
|
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author WXY |
|
|
|
|
@ -40,9 +41,10 @@ public class MyMQTTCallback implements MqttCallbackExtended { |
|
|
|
|
private MqttConfiguration mqttConfiguration = SpringUtil.getBean(MqttConfiguration.class); |
|
|
|
|
|
|
|
|
|
private IInstrumentDataService instrumentDataService = SpringUtil.getBean(IInstrumentDataService.class); |
|
|
|
|
private IInstrumentStatusService instrumentStatusService = SpringUtil.getBean(IInstrumentStatusService.class); |
|
|
|
|
//private IInstrumentStatusService instrumentStatusService = SpringUtil.getBean(IInstrumentStatusService.class);
|
|
|
|
|
private IInstrumentService instrumentService = SpringUtil.getBean(IInstrumentService.class); |
|
|
|
|
private ILargeScreenService largeScreenService = SpringUtil.getBean(ILargeScreenService.class); |
|
|
|
|
private RedisLock redisLock = SpringUtil.getBean(RedisLock.class); |
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(MyMQTTCallback.class); |
|
|
|
|
|
|
|
|
|
private MyMQTTClient mqttClient; |
|
|
|
|
@ -111,160 +113,175 @@ public class MyMQTTCallback implements MqttCallbackExtended { |
|
|
|
|
InstrumentData data = new InstrumentData(); |
|
|
|
|
Map map = (Map) JSON.parse(new String(mqttMessage.getPayload(), Charsets.UTF_8.name())); |
|
|
|
|
Map map1 = (Map) JSON.parse(map.get("vals").toString()); |
|
|
|
|
data.setSendTime(DateUtils.parseDate(map.get("tsstr").toString(),"yyyy-MM-dd hh:mm:ss")); |
|
|
|
|
data.setCurrentYear(map.get("tsstr").toString().substring(0,4)); |
|
|
|
|
data.setCurrentMonth(map.get("tsstr").toString().substring(0,7)); |
|
|
|
|
data.setCurrentDay(map.get("tsstr").toString().substring(0,10)); |
|
|
|
|
data.setImei(map.get("imei").toString()); |
|
|
|
|
//计算尖峰平谷
|
|
|
|
|
String today = DateFormatUtils.format(new Date(),"yyyy-MM-dd"); |
|
|
|
|
for(Map.Entry<String,String> entry : periodMap.entrySet()){ |
|
|
|
|
boolean flag = false; |
|
|
|
|
List<String> timeList = Arrays.asList(entry.getValue().split(",")); |
|
|
|
|
for(String timePeriod : timeList){ |
|
|
|
|
String[] times = timePeriod.split("-"); |
|
|
|
|
Date startTime = DateUtils.parseDate(today + " " + times[0],"yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
Date endTime = DateUtils.parseDate(today + " " + times[1],"yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if(data.getSendTime().compareTo(startTime) >0 && data.getSendTime().compareTo(endTime) <=0){ |
|
|
|
|
flag = true; |
|
|
|
|
break; |
|
|
|
|
String lockKey = map.get("imei").toString(); |
|
|
|
|
if(redisLock.tryLock(lockKey, TimeUnit.SECONDS,10,60)){ |
|
|
|
|
try { |
|
|
|
|
data.setSendTime(DateUtils.parseDate(map.get("tsstr").toString(),"yyyy-MM-dd hh:mm:ss")); |
|
|
|
|
data.setCurrentYear(map.get("tsstr").toString().substring(0,4)); |
|
|
|
|
data.setCurrentMonth(map.get("tsstr").toString().substring(0,7)); |
|
|
|
|
data.setCurrentDay(map.get("tsstr").toString().substring(0,10)); |
|
|
|
|
data.setImei(map.get("imei").toString()); |
|
|
|
|
//计算尖峰平谷
|
|
|
|
|
String today = DateFormatUtils.format(new Date(),"yyyy-MM-dd"); |
|
|
|
|
for(Map.Entry<String,String> entry : periodMap.entrySet()){ |
|
|
|
|
boolean flag = false; |
|
|
|
|
List<String> timeList = Arrays.asList(entry.getValue().split(",")); |
|
|
|
|
for(String timePeriod : timeList){ |
|
|
|
|
String[] times = timePeriod.split("-"); |
|
|
|
|
Date startTime = DateUtils.parseDate(today + " " + times[0],"yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
Date endTime = DateUtils.parseDate(today + " " + times[1],"yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if(data.getSendTime().compareTo(startTime) >0 && data.getSendTime().compareTo(endTime) <=0){ |
|
|
|
|
flag = true; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(flag){ |
|
|
|
|
data.setPeriod(entry.getKey()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总用电")){ |
|
|
|
|
data.setTotalElectricity(Double.parseDouble(map1.get("总用电").toString())); |
|
|
|
|
//计算电表从上一次到这一次的用电量
|
|
|
|
|
if(totalMap.get(map.get("imei").toString()) == null){ |
|
|
|
|
data.setSingleElectricity(0.0); |
|
|
|
|
}else{ |
|
|
|
|
data.setSingleElectricity(Double.parseDouble(map1.get("总用电").toString())-totalMap.get(map.get("imei").toString())); |
|
|
|
|
} |
|
|
|
|
totalMap.put(map.get("imei").toString(),Double.parseDouble(map1.get("总用电").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总有功功率")){ |
|
|
|
|
data.setTotalActivePower(Double.parseDouble(map1.get("总有功功率").toString())); |
|
|
|
|
//计算负载率
|
|
|
|
|
if(powerMap.get(map.get("imei").toString()) != null){ |
|
|
|
|
int loadRate = Math.abs((int)Math.round(data.getTotalActivePower()/powerMap.get(map.get("imei").toString())*100)); |
|
|
|
|
String loadLevel = ""; |
|
|
|
|
if(loadRate == loadRateMap.get("空载")){ |
|
|
|
|
loadLevel = "空载"; |
|
|
|
|
}else if(loadRate > loadRateMap.get("空载") && loadRate <= loadRateMap.get("轻载")){ |
|
|
|
|
loadLevel = "轻载"; |
|
|
|
|
}else if (loadRate > loadRateMap.get("轻载") && loadRate <= loadRateMap.get("正常")){ |
|
|
|
|
loadLevel = "正常"; |
|
|
|
|
}else if(loadRate >loadRateMap.get("正常") && loadRate <= loadRateMap.get("过载")){ |
|
|
|
|
loadLevel = "过载"; |
|
|
|
|
}else if(loadRate > loadRateMap.get("过载")){ |
|
|
|
|
loadLevel = "重载"; |
|
|
|
|
} |
|
|
|
|
data.setLoadRate(loadRate); |
|
|
|
|
data.setLoadLevel(loadLevel); |
|
|
|
|
}else{ |
|
|
|
|
data.setLoadRate(0); |
|
|
|
|
data.setLoadLevel("空载"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总无功功率")){ |
|
|
|
|
data.setTotalReactivePower(Double.parseDouble(map1.get("总无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总视在功率")){ |
|
|
|
|
data.setTotalApparentPower(Double.parseDouble(map1.get("总视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前正向有功")){ |
|
|
|
|
data.setCurrentPositiveActivePower(Double.parseDouble(map1.get("当前正向有功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前正向无功")){ |
|
|
|
|
data.setCurrentPositiveReactivePower(Double.parseDouble(map1.get("当前正向无功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前反向有功")){ |
|
|
|
|
data.setCurrentReverseActivePower(Double.parseDouble(map1.get("当前反向有功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前反向无功")){ |
|
|
|
|
data.setCurrentReverseReactivePower(Double.parseDouble(map1.get("当前反向无功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("电流不平衡度")){ |
|
|
|
|
data.setCurrentImbalance(Double.parseDouble(map1.get("电流不平衡度").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("电压不平衡度")){ |
|
|
|
|
data.setVoltageImbalance(Double.parseDouble(map1.get("电压不平衡度").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总功率因数")){ |
|
|
|
|
data.setTotalPowerFactor(Double.parseDouble(map1.get("总功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("零序电流")){ |
|
|
|
|
data.setZeroSequenceCurrent(Double.parseDouble(map1.get("零序电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("频率")){ |
|
|
|
|
data.setFrequency(Double.parseDouble(map1.get("频率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A线电压")){ |
|
|
|
|
data.setALineVoltage(Double.parseDouble(map1.get("A线电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B线电压")){ |
|
|
|
|
data.setBLineVoltage(Double.parseDouble(map1.get("B线电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C线电压")){ |
|
|
|
|
data.setCLineVoltage(Double.parseDouble(map1.get("C线电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相电流")){ |
|
|
|
|
data.setAPhaseCurrent(Double.parseDouble(map1.get("A相电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相电流")){ |
|
|
|
|
data.setBPhaseCurrent(Double.parseDouble(map1.get("B相电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相电流")){ |
|
|
|
|
data.setCPhaseCurrent(Double.parseDouble(map1.get("C相电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相电压")){ |
|
|
|
|
data.setAPhaseVoltage(Double.parseDouble(map1.get("A相电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相电压")){ |
|
|
|
|
data.setBPhaseVoltage(Double.parseDouble(map1.get("B相电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相电压")){ |
|
|
|
|
data.setCPhaseVoltage(Double.parseDouble(map1.get("C相电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相有功功率")){ |
|
|
|
|
data.setAPhaseActivePower(Double.parseDouble(map1.get("A相有功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相有功功率")){ |
|
|
|
|
data.setBPhaseActivePower(Double.parseDouble(map1.get("B相有功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相有功功率")){ |
|
|
|
|
data.setCPhaseActivePower(Double.parseDouble(map1.get("C相有功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相功率因数")){ |
|
|
|
|
data.setAPhasePowerFactor(Double.parseDouble(map1.get("A相功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相功率因数")){ |
|
|
|
|
data.setBPhasePowerFactor(Double.parseDouble(map1.get("B相功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相功率因数")){ |
|
|
|
|
data.setCPhasePowerFactor(Double.parseDouble(map1.get("C相功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相无功功率")){ |
|
|
|
|
data.setAPhaseReactivePower(Double.parseDouble(map1.get("A相无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相无功功率")){ |
|
|
|
|
data.setBPhaseReactivePower(Double.parseDouble(map1.get("B相无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相无功功率")){ |
|
|
|
|
data.setCPhaseReactivePower(Double.parseDouble(map1.get("C相无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相视在功率")){ |
|
|
|
|
data.setAPhaseApparentPower(Double.parseDouble(map1.get("A相视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相视在功率")){ |
|
|
|
|
data.setBPhaseApparentPower(Double.parseDouble(map1.get("B相视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相视在功率")){ |
|
|
|
|
data.setCPhaseApparentPower(Double.parseDouble(map1.get("C相视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
//你自己的业务接口
|
|
|
|
|
log.info(map1.toString()); |
|
|
|
|
dataList.add(data); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} finally { |
|
|
|
|
redisLock.unlock(lockKey); |
|
|
|
|
} |
|
|
|
|
if(flag){ |
|
|
|
|
data.setPeriod(entry.getKey()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总用电")){ |
|
|
|
|
data.setTotalElectricity(Double.parseDouble(map1.get("总用电").toString())); |
|
|
|
|
//计算电表从上一次到这一次的用电量
|
|
|
|
|
if(totalMap.get(map.get("imei").toString()) == null){ |
|
|
|
|
data.setSingleElectricity(0.0); |
|
|
|
|
}else{ |
|
|
|
|
data.setSingleElectricity(Double.parseDouble(map1.get("总用电").toString())-totalMap.get(map.get("imei").toString())); |
|
|
|
|
} |
|
|
|
|
totalMap.put(map.get("imei").toString(),Double.parseDouble(map1.get("总用电").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总有功功率")){ |
|
|
|
|
data.setTotalActivePower(Double.parseDouble(map1.get("总有功功率").toString())); |
|
|
|
|
//计算负载率
|
|
|
|
|
if(powerMap.get(map.get("imei").toString()) != null){ |
|
|
|
|
int loadRate = Math.abs((int)Math.round(data.getTotalActivePower()/powerMap.get(map.get("imei").toString())*100)); |
|
|
|
|
String loadLevel = ""; |
|
|
|
|
if(loadRate == loadRateMap.get("空载")){ |
|
|
|
|
loadLevel = "空载"; |
|
|
|
|
}else if(loadRate > loadRateMap.get("空载") && loadRate <= loadRateMap.get("轻载")){ |
|
|
|
|
loadLevel = "轻载"; |
|
|
|
|
}else if (loadRate > loadRateMap.get("轻载") && loadRate <= loadRateMap.get("正常")){ |
|
|
|
|
loadLevel = "正常"; |
|
|
|
|
}else if(loadRate >loadRateMap.get("正常") && loadRate <= loadRateMap.get("过载")){ |
|
|
|
|
loadLevel = "过载"; |
|
|
|
|
}else if(loadRate > loadRateMap.get("过载")){ |
|
|
|
|
loadLevel = "重载"; |
|
|
|
|
} |
|
|
|
|
data.setLoadRate(loadRate); |
|
|
|
|
data.setLoadLevel(loadLevel); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总无功功率")){ |
|
|
|
|
data.setTotalReactivePower(Double.parseDouble(map1.get("总无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总视在功率")){ |
|
|
|
|
data.setTotalApparentPower(Double.parseDouble(map1.get("总视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前正向有功")){ |
|
|
|
|
data.setCurrentPositiveActivePower(Double.parseDouble(map1.get("当前正向有功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前正向无功")){ |
|
|
|
|
data.setCurrentPositiveReactivePower(Double.parseDouble(map1.get("当前正向无功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前反向有功")){ |
|
|
|
|
data.setCurrentReverseActivePower(Double.parseDouble(map1.get("当前反向有功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("当前反向无功")){ |
|
|
|
|
data.setCurrentReverseReactivePower(Double.parseDouble(map1.get("当前反向无功").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("电流不平衡度")){ |
|
|
|
|
data.setCurrentImbalance(Double.parseDouble(map1.get("电流不平衡度").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("电压不平衡度")){ |
|
|
|
|
data.setVoltageImbalance(Double.parseDouble(map1.get("电压不平衡度").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("总功率因数")){ |
|
|
|
|
data.setTotalPowerFactor(Double.parseDouble(map1.get("总功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("零序电流")){ |
|
|
|
|
data.setZeroSequenceCurrent(Double.parseDouble(map1.get("零序电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("频率")){ |
|
|
|
|
data.setFrequency(Double.parseDouble(map1.get("频率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A线电压")){ |
|
|
|
|
data.setALineVoltage(Double.parseDouble(map1.get("A线电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B线电压")){ |
|
|
|
|
data.setBLineVoltage(Double.parseDouble(map1.get("B线电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C线电压")){ |
|
|
|
|
data.setCLineVoltage(Double.parseDouble(map1.get("C线电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相电流")){ |
|
|
|
|
data.setAPhaseCurrent(Double.parseDouble(map1.get("A相电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相电流")){ |
|
|
|
|
data.setBPhaseCurrent(Double.parseDouble(map1.get("B相电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相电流")){ |
|
|
|
|
data.setCPhaseCurrent(Double.parseDouble(map1.get("C相电流").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相电压")){ |
|
|
|
|
data.setAPhaseVoltage(Double.parseDouble(map1.get("A相电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相电压")){ |
|
|
|
|
data.setBPhaseVoltage(Double.parseDouble(map1.get("B相电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相电压")){ |
|
|
|
|
data.setCPhaseVoltage(Double.parseDouble(map1.get("C相电压").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相有功功率")){ |
|
|
|
|
data.setAPhaseActivePower(Double.parseDouble(map1.get("A相有功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相有功功率")){ |
|
|
|
|
data.setBPhaseActivePower(Double.parseDouble(map1.get("B相有功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相有功功率")){ |
|
|
|
|
data.setCPhaseActivePower(Double.parseDouble(map1.get("C相有功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相功率因数")){ |
|
|
|
|
data.setAPhasePowerFactor(Double.parseDouble(map1.get("A相功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相功率因数")){ |
|
|
|
|
data.setBPhasePowerFactor(Double.parseDouble(map1.get("B相功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相功率因数")){ |
|
|
|
|
data.setCPhasePowerFactor(Double.parseDouble(map1.get("C相功率因数").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相无功功率")){ |
|
|
|
|
data.setAPhaseReactivePower(Double.parseDouble(map1.get("A相无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相无功功率")){ |
|
|
|
|
data.setBPhaseReactivePower(Double.parseDouble(map1.get("B相无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相无功功率")){ |
|
|
|
|
data.setCPhaseReactivePower(Double.parseDouble(map1.get("C相无功功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("A相视在功率")){ |
|
|
|
|
data.setAPhaseApparentPower(Double.parseDouble(map1.get("A相视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("B相视在功率")){ |
|
|
|
|
data.setBPhaseApparentPower(Double.parseDouble(map1.get("B相视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
if(map1.containsKey("C相视在功率")){ |
|
|
|
|
data.setCPhaseApparentPower(Double.parseDouble(map1.get("C相视在功率").toString())); |
|
|
|
|
} |
|
|
|
|
//你自己的业务接口
|
|
|
|
|
log.info(map1.toString()); |
|
|
|
|
dataList.add(data); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if(dataList.size() ==100){ |
|
|
|
|
instrumentDataService.saveBatch(dataList); |
|
|
|
|
@ -285,14 +302,14 @@ public class MyMQTTCallback implements MqttCallbackExtended { |
|
|
|
|
instrumentService.update(instrument,wrapper); |
|
|
|
|
//保存数据
|
|
|
|
|
//根据网关编号、推送时间查询数据是否已存在
|
|
|
|
|
InstrumentStatus oldStatus = instrumentStatusService.getOne(new LambdaQueryWrapper<InstrumentStatus>().eq(InstrumentStatus::getImei,map.get("imei").toString()).eq(InstrumentStatus::getSendTime,DateUtils.parseDate(map.get("tsstr").toString(),"yyyy-MM-dd hh:mm:ss"))); |
|
|
|
|
/*InstrumentStatus oldStatus = instrumentStatusService.getOne(new LambdaQueryWrapper<InstrumentStatus>().eq(InstrumentStatus::getImei,map.get("imei").toString()).eq(InstrumentStatus::getSendTime,DateUtils.parseDate(map.get("tsstr").toString(),"yyyy-MM-dd hh:mm:ss"))); |
|
|
|
|
if(oldStatus == null){ |
|
|
|
|
InstrumentStatus instrumentStatus = new InstrumentStatus(); |
|
|
|
|
instrumentStatus.setImei(map.get("imei").toString()); |
|
|
|
|
instrumentStatus.setRunStatus(map.get("status").toString()); |
|
|
|
|
instrumentStatus.setSendTime(DateUtils.parseDate(map.get("tsstr").toString(),"yyyy-MM-dd hh:mm:ss")); |
|
|
|
|
instrumentStatusService.save(instrumentStatus); |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -332,20 +349,6 @@ public class MyMQTTCallback implements MqttCallbackExtended { |
|
|
|
|
periodlist.forEach(dict -> { |
|
|
|
|
periodMap.put(dict.getDictValue(),dict.getDictKey()); |
|
|
|
|
}); |
|
|
|
|
/*for(Dict dict : periodlist){ |
|
|
|
|
List<String> timeList1 = Arrays.asList(dict.getDictKey().split(",")); |
|
|
|
|
timeList1.forEach(s -> { |
|
|
|
|
String[] times = s.split("-"); |
|
|
|
|
Map<String,Date> map1 = new HashMap<>(); |
|
|
|
|
try { |
|
|
|
|
map1.put("startTime",DateUtils.parseDate(today+" "+times[0])); |
|
|
|
|
map1.put("endTime",DateUtils.parseDate(today+" "+times[1])); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|