|
|
|
|
@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
|
@ -56,6 +57,8 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
@Qualifier("gatewayManageMapper") |
|
|
|
|
@Autowired |
|
|
|
|
private GatewayManageMapper gatewayManageMapper; |
|
|
|
|
@Autowired |
|
|
|
|
private CollectionParamsManageMapper collectionParamsManageMapper; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void updateMultiNowData(NowDataEntity nowDataEntity) { |
|
|
|
|
@ -110,8 +113,8 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NowDataEntity queryNowDataByPumpName(String buildingId, String buildingName, String deviceAddr, String deviceName) { |
|
|
|
|
int count = nowDataMapper.selectNowDataByPumName(buildingId,deviceAddr,deviceName); |
|
|
|
|
if (count==0){ |
|
|
|
|
int count = nowDataMapper.selectNowDataByPumName(buildingId, deviceAddr, deviceName); |
|
|
|
|
if (count == 0) { |
|
|
|
|
NowDataEntity nowDataEntity = new NowDataEntity(); |
|
|
|
|
nowDataEntity.setPumpId(deviceAddr); |
|
|
|
|
nowDataEntity.setPumpName(deviceName); |
|
|
|
|
@ -120,7 +123,7 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
nowDataMapper.saveNowData(nowDataEntity); |
|
|
|
|
return nowDataEntity; |
|
|
|
|
} |
|
|
|
|
return nowDataMapper.queryNowDataByPumpName(buildingId,deviceAddr,deviceName); |
|
|
|
|
return nowDataMapper.queryNowDataByPumpName(buildingId, deviceAddr, deviceName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -130,94 +133,94 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
|
|
|
|
|
//保存热泵采集数据
|
|
|
|
|
@Override |
|
|
|
|
public void saveNowHistoryData(String pumpId, String deviceType, String strData,String dataType,String buildingId) { |
|
|
|
|
public void saveNowHistoryData(String pumpId, String deviceType, String strData, String dataType, String buildingId) { |
|
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
Date date=new Date(); |
|
|
|
|
String strDate=sdf1.format(date); |
|
|
|
|
strDate=strDate.substring(0,13)+":00:00"; |
|
|
|
|
Date date = new Date(); |
|
|
|
|
String strDate = sdf1.format(date); |
|
|
|
|
strDate = strDate.substring(0, 13) + ":00:00"; |
|
|
|
|
|
|
|
|
|
NowDataEntity data=new NowDataEntity(); |
|
|
|
|
try{ |
|
|
|
|
if (dataType.equals("tempSet")){ //温度设定
|
|
|
|
|
NowDataEntity data = new NowDataEntity(); |
|
|
|
|
try { |
|
|
|
|
if (dataType.equals("tempSet")) { //温度设定
|
|
|
|
|
data.setTempSet(strData); |
|
|
|
|
}else if (dataType.equals("waterTemp")){ //水箱水温
|
|
|
|
|
} else if (dataType.equals("waterTemp")) { //水箱水温
|
|
|
|
|
data.setWaterTemp(strData); |
|
|
|
|
}else if (dataType.equals("runState")){ //运行状态
|
|
|
|
|
} else if (dataType.equals("runState")) { //运行状态
|
|
|
|
|
data.setRunState(strData); |
|
|
|
|
}else if (dataType.equals("isFault")){ //是否故障
|
|
|
|
|
} else if (dataType.equals("isFault")) { //是否故障
|
|
|
|
|
data.setIsFault(strData); |
|
|
|
|
} |
|
|
|
|
//从安装表获取设备信息
|
|
|
|
|
DeviceInstallEntity deviceInstallEntity=deviceInstallMapper.selectDevice(pumpId,deviceType,buildingId); |
|
|
|
|
DeviceInstallEntity deviceInstallEntity = deviceInstallMapper.selectDevice(pumpId, deviceType, buildingId); |
|
|
|
|
//获取对应水箱信息
|
|
|
|
|
DeviceModel tank=deviceFloorMapper.selectTankName(buildingId,"水箱",pumpId); |
|
|
|
|
if (tank!=null){ |
|
|
|
|
DeviceModel tank = deviceFloorMapper.selectTankName(buildingId, "水箱", pumpId); |
|
|
|
|
if (tank != null) { |
|
|
|
|
data.setTankId(String.valueOf(tank.getId())); //对应水箱编号
|
|
|
|
|
data.setTankName(tank.getDeviceName()); //对应水箱名称
|
|
|
|
|
} |
|
|
|
|
String buildingName=buildingService.queryBuildingName(buildingId); |
|
|
|
|
String buildingName = buildingService.queryBuildingName(buildingId); |
|
|
|
|
//判断实时表是否有记录
|
|
|
|
|
int r1 = nowDataMapper.selectNowDataCount(deviceInstallEntity.getBuildingId(),pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if(r1==0){ |
|
|
|
|
int r1 = nowDataMapper.selectNowDataCount(deviceInstallEntity.getBuildingId(), pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if (r1 == 0) { |
|
|
|
|
data.setPumpId(pumpId); //通讯地址
|
|
|
|
|
data.setPumpName(deviceInstallEntity.getDeviceName()); //通讯地址
|
|
|
|
|
data.setBuildingId(deviceInstallEntity.getBuildingId()); |
|
|
|
|
data.setBuildingName(buildingName); |
|
|
|
|
nowDataMapper.saveNowData(data); |
|
|
|
|
} else { |
|
|
|
|
NowDataEntity data1=nowDataMapper.selectNowData(deviceInstallEntity.getBuildingId(),pumpId); |
|
|
|
|
if (data1!=null){ |
|
|
|
|
if (dataType.equals("tempSet")){ //温度设定
|
|
|
|
|
NowDataEntity data1 = nowDataMapper.selectNowData(deviceInstallEntity.getBuildingId(), pumpId); |
|
|
|
|
if (data1 != null) { |
|
|
|
|
if (dataType.equals("tempSet")) { //温度设定
|
|
|
|
|
data1.setTempSet(strData); |
|
|
|
|
}else if (dataType.equals("waterTemp")){ //水箱水温
|
|
|
|
|
} else if (dataType.equals("waterTemp")) { //水箱水温
|
|
|
|
|
data1.setWaterTemp(strData); |
|
|
|
|
}else if (dataType.equals("runState")){ //运行状态
|
|
|
|
|
} else if (dataType.equals("runState")) { //运行状态
|
|
|
|
|
data1.setRunState(strData); |
|
|
|
|
}else if (dataType.equals("isFault")){ //是否故障
|
|
|
|
|
} else if (dataType.equals("isFault")) { //是否故障
|
|
|
|
|
data1.setIsFault(strData); |
|
|
|
|
} |
|
|
|
|
nowDataMapper.updateNowData(data1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//判断历史表是否有记录
|
|
|
|
|
int r2 = nowDataMapper.selectHistoryDataCount(strDate,deviceInstallEntity.getBuildingId(),pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if (r2==0){ |
|
|
|
|
int r2 = nowDataMapper.selectHistoryDataCount(strDate, deviceInstallEntity.getBuildingId(), pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if (r2 == 0) { |
|
|
|
|
data.setPumpId(pumpId); //通讯地址
|
|
|
|
|
data.setPumpName(deviceInstallEntity.getDeviceName()); //通讯地址
|
|
|
|
|
data.setBuildingId(deviceInstallEntity.getBuildingId()); |
|
|
|
|
data.setBuildingName(buildingName); |
|
|
|
|
data.setCurDate(strDate); |
|
|
|
|
nowDataMapper.saveHistoryData(data); |
|
|
|
|
}else { |
|
|
|
|
NowDataEntity data2=nowDataMapper.selectHistoryData(strDate,deviceInstallEntity.getBuildingId(),pumpId); |
|
|
|
|
if (data2!=null){ |
|
|
|
|
if (dataType.equals("tempSet")){ //温度设定
|
|
|
|
|
} else { |
|
|
|
|
NowDataEntity data2 = nowDataMapper.selectHistoryData(strDate, deviceInstallEntity.getBuildingId(), pumpId); |
|
|
|
|
if (data2 != null) { |
|
|
|
|
if (dataType.equals("tempSet")) { //温度设定
|
|
|
|
|
data2.setTempSet(strData); |
|
|
|
|
}else if (dataType.equals("waterTemp")){ //水箱水温
|
|
|
|
|
} else if (dataType.equals("waterTemp")) { //水箱水温
|
|
|
|
|
data2.setWaterTemp(strData); |
|
|
|
|
}else if (dataType.equals("runState")){ //运行状态
|
|
|
|
|
} else if (dataType.equals("runState")) { //运行状态
|
|
|
|
|
data2.setRunState(strData); |
|
|
|
|
}else if (dataType.equals("isFault")){ //是否故障
|
|
|
|
|
} else if (dataType.equals("isFault")) { //是否故障
|
|
|
|
|
data2.setIsFault(strData); |
|
|
|
|
} |
|
|
|
|
nowDataMapper.updateHistoryData(data2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//非热泵温控、状态检测数据
|
|
|
|
|
@Override |
|
|
|
|
public void saveNowHistoryData2(String deviceAddr, String deviceType, String strData, String dataType,String buildingId) { |
|
|
|
|
NowDataEntity data=new NowDataEntity(); |
|
|
|
|
public void saveNowHistoryData2(String deviceAddr, String deviceType, String strData, String dataType, String buildingId) { |
|
|
|
|
NowDataEntity data = new NowDataEntity(); |
|
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
Date date=new Date(); |
|
|
|
|
String strDate=sdf1.format(date); |
|
|
|
|
strDate=strDate.substring(0,13)+":00:00"; |
|
|
|
|
Date date = new Date(); |
|
|
|
|
String strDate = sdf1.format(date); |
|
|
|
|
strDate = strDate.substring(0, 13) + ":00:00"; |
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
try { |
|
|
|
|
switch (dataType) { |
|
|
|
|
case "tempSet": //温度设定
|
|
|
|
|
data.setTempSet(strData); |
|
|
|
|
@ -239,28 +242,28 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
//从安装表获取设备信息
|
|
|
|
|
DeviceInstallEntity deviceInstallEntity=deviceInstallMapper.selectDevice(deviceAddr,deviceType,buildingId); |
|
|
|
|
String buildingName=buildingService.queryBuildingName(buildingId); |
|
|
|
|
DeviceInstallEntity deviceInstallEntity = deviceInstallMapper.selectDevice(deviceAddr, deviceType, buildingId); |
|
|
|
|
String buildingName = buildingService.queryBuildingName(buildingId); |
|
|
|
|
data.setBuildingName(buildingName); |
|
|
|
|
// 获取项目名称
|
|
|
|
|
String name = dealDataService.customName(); |
|
|
|
|
if (deviceType.equals("温控") |
|
|
|
|
&& !name.contains(Constant.CUSTOM_NAME_HUAXIA) |
|
|
|
|
&& !name.contains(Constant.CUSTOM_NAME_HUARUAN) ) { |
|
|
|
|
&& !name.contains(Constant.CUSTOM_NAME_HUARUAN)) { |
|
|
|
|
log.error("进入到热泵1------------------------"); |
|
|
|
|
//为了兼容旧系统,旧系统热泵信息保存在楼面表,从楼面表获取热泵资料
|
|
|
|
|
PumpModel pump=deviceFloorMapper.selectDeviceId2("热泵",buildingId); |
|
|
|
|
String pumpId="1"; |
|
|
|
|
String pumpName="热泵1"; |
|
|
|
|
if (pump!=null){ |
|
|
|
|
pumpId=pump.getPumpId(); |
|
|
|
|
pumpName=pump.getPumpName(); |
|
|
|
|
PumpModel pump = deviceFloorMapper.selectDeviceId2("热泵", buildingId); |
|
|
|
|
String pumpId = "1"; |
|
|
|
|
String pumpName = "热泵1"; |
|
|
|
|
if (pump != null) { |
|
|
|
|
pumpId = pump.getPumpId(); |
|
|
|
|
pumpName = pump.getPumpName(); |
|
|
|
|
//获取对应水箱信息
|
|
|
|
|
DeviceModel tank=deviceFloorMapper.selectTankName(buildingId,"水箱",pumpId); |
|
|
|
|
if (tank!=null){ |
|
|
|
|
DeviceModel tank = deviceFloorMapper.selectTankName(buildingId, "水箱", pumpId); |
|
|
|
|
if (tank != null) { |
|
|
|
|
data.setTankId(String.valueOf(tank.getId())); //对应水箱编号
|
|
|
|
|
data.setTankName(tank.getDeviceName()); //对应水箱名称
|
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
data.setTankId("1"); //对应水箱编号
|
|
|
|
|
data.setTankName("水箱1"); //对应水箱名称
|
|
|
|
|
} |
|
|
|
|
@ -272,68 +275,68 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
data.setCurDate(strDate); |
|
|
|
|
//判断实时表是否有记录
|
|
|
|
|
int r1 = nowDataMapper.selectNowDataCount2(buildingId);//判断now_data表是否存在记录
|
|
|
|
|
if (r1==0){ |
|
|
|
|
if (r1 == 0) { |
|
|
|
|
nowDataMapper.saveNowData(data); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
if (deviceType.equals("压变")) { |
|
|
|
|
String seat=deviceInstallService.selectSeat(deviceType,deviceAddr,buildingId); |
|
|
|
|
log.info("-------楼栋:"+buildingName+",类型:"+deviceType+",地址:"+deviceAddr+",区位:"+seat+",数值:"+strData+"------"); |
|
|
|
|
if (!StringUtils.isBlank(seat)){ |
|
|
|
|
nowDataMapper.nowDataWaterLevel(strData,seat,buildingId); |
|
|
|
|
}else{ |
|
|
|
|
String seat = deviceInstallService.selectSeat(deviceType, deviceAddr, buildingId); |
|
|
|
|
log.info("-------楼栋:" + buildingName + ",类型:" + deviceType + ",地址:" + deviceAddr + ",区位:" + seat + ",数值:" + strData + "------"); |
|
|
|
|
if (!StringUtils.isBlank(seat)) { |
|
|
|
|
nowDataMapper.nowDataWaterLevel(strData, seat, buildingId); |
|
|
|
|
} else { |
|
|
|
|
nowDataMapper.updateNowData2(data); |
|
|
|
|
} |
|
|
|
|
}else if (deviceType.equals("水位开关")){ |
|
|
|
|
String seat=deviceInstallService.selectSeat(deviceType,deviceAddr,buildingId); |
|
|
|
|
log.info("-------楼栋:"+buildingName+",类型:"+deviceType+",地址:"+deviceAddr+",区位:"+seat+",数值:"+strData+"------"); |
|
|
|
|
if (seat!=null){ |
|
|
|
|
nowDataMapper.nowDataLevelSet(strData,seat,buildingId); |
|
|
|
|
}else{ |
|
|
|
|
} else if (deviceType.equals("水位开关")) { |
|
|
|
|
String seat = deviceInstallService.selectSeat(deviceType, deviceAddr, buildingId); |
|
|
|
|
log.info("-------楼栋:" + buildingName + ",类型:" + deviceType + ",地址:" + deviceAddr + ",区位:" + seat + ",数值:" + strData + "------"); |
|
|
|
|
if (seat != null) { |
|
|
|
|
nowDataMapper.nowDataLevelSet(strData, seat, buildingId); |
|
|
|
|
} else { |
|
|
|
|
nowDataMapper.updateNowData2(data); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
nowDataMapper.updateNowData2(data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//判断历史表是否有记录
|
|
|
|
|
int r2 = nowDataMapper.selectHistoryDataCount2(strDate,buildingId);//判断history_Data表是否存在记录
|
|
|
|
|
if (r2==0){ |
|
|
|
|
int r2 = nowDataMapper.selectHistoryDataCount2(strDate, buildingId);//判断history_Data表是否存在记录
|
|
|
|
|
if (r2 == 0) { |
|
|
|
|
nowDataMapper.saveHistoryData(data); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
if (deviceType.equals("压变")) { |
|
|
|
|
String seat=deviceInstallService.selectSeat(deviceType,deviceAddr,buildingId); |
|
|
|
|
if (!StringUtils.isBlank(seat)){ |
|
|
|
|
nowDataMapper.historyDataWaterLevel(strData,seat,buildingId,strDate); |
|
|
|
|
log.info("------楼栋:"+buildingName+",历史记录压变区位:"+seat+"------"); |
|
|
|
|
}else{ |
|
|
|
|
String seat = deviceInstallService.selectSeat(deviceType, deviceAddr, buildingId); |
|
|
|
|
if (!StringUtils.isBlank(seat)) { |
|
|
|
|
nowDataMapper.historyDataWaterLevel(strData, seat, buildingId, strDate); |
|
|
|
|
log.info("------楼栋:" + buildingName + ",历史记录压变区位:" + seat + "------"); |
|
|
|
|
} else { |
|
|
|
|
nowDataMapper.updateHistoryData2(data); |
|
|
|
|
} |
|
|
|
|
}else if (deviceType.equals("水位开关")){ |
|
|
|
|
String seat=deviceInstallService.selectSeat(deviceType,deviceAddr,buildingId); |
|
|
|
|
if (!StringUtils.isBlank(seat)){ |
|
|
|
|
nowDataMapper.historyDataLevelSet(strData,seat,buildingId,strDate); |
|
|
|
|
log.info("------楼栋:"+buildingName+",历史记录水位开关区位:"+seat+"------"); |
|
|
|
|
}else{ |
|
|
|
|
} else if (deviceType.equals("水位开关")) { |
|
|
|
|
String seat = deviceInstallService.selectSeat(deviceType, deviceAddr, buildingId); |
|
|
|
|
if (!StringUtils.isBlank(seat)) { |
|
|
|
|
nowDataMapper.historyDataLevelSet(strData, seat, buildingId, strDate); |
|
|
|
|
log.info("------楼栋:" + buildingName + ",历史记录水位开关区位:" + seat + "------"); |
|
|
|
|
} else { |
|
|
|
|
nowDataMapper.updateHistoryData2(data); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
nowDataMapper.updateHistoryData2(data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//非热泵温度变送器、状态检测相关数据
|
|
|
|
|
@Override |
|
|
|
|
public void saveNowHistoryData3(String pumpId, String deviceType, String strData,String dataType,String buildingId) { |
|
|
|
|
public void saveNowHistoryData3(String pumpId, String deviceType, String strData, String dataType, String buildingId) { |
|
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
Date date=new Date(); |
|
|
|
|
String strDate=sdf1.format(date); |
|
|
|
|
strDate=strDate.substring(0,13)+":00:00"; |
|
|
|
|
NowDataEntity data=new NowDataEntity(); |
|
|
|
|
try{ |
|
|
|
|
Date date = new Date(); |
|
|
|
|
String strDate = sdf1.format(date); |
|
|
|
|
strDate = strDate.substring(0, 13) + ":00:00"; |
|
|
|
|
NowDataEntity data = new NowDataEntity(); |
|
|
|
|
try { |
|
|
|
|
switch (dataType) { |
|
|
|
|
case "tempSet": //温度设定
|
|
|
|
|
data.setTempSet(strData); |
|
|
|
|
@ -348,48 +351,48 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
data.setIsFault(strData); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
String buildingName=buildingService.queryBuildingName(buildingId); |
|
|
|
|
String buildingName = buildingService.queryBuildingName(buildingId); |
|
|
|
|
//判断实时表是否有记录
|
|
|
|
|
int r1 = nowDataMapper.selectNowDataCount(buildingId,pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if(r1==0){ |
|
|
|
|
int r1 = nowDataMapper.selectNowDataCount(buildingId, pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if (r1 == 0) { |
|
|
|
|
data.setPumpId(pumpId); //热泵编号
|
|
|
|
|
String pumpName="热泵"+pumpId; |
|
|
|
|
String pumpName = "热泵" + pumpId; |
|
|
|
|
data.setPumpName(pumpName); //热泵名称
|
|
|
|
|
data.setBuildingId(buildingId); |
|
|
|
|
data.setBuildingName(buildingName); |
|
|
|
|
nowDataMapper.saveNowData(data); |
|
|
|
|
} else { |
|
|
|
|
NowDataEntity data1=nowDataMapper.selectNowData(buildingId,pumpId); |
|
|
|
|
if (data1!=null){ |
|
|
|
|
if (dataType.equals("tempSet")){ //温度设定
|
|
|
|
|
NowDataEntity data1 = nowDataMapper.selectNowData(buildingId, pumpId); |
|
|
|
|
if (data1 != null) { |
|
|
|
|
if (dataType.equals("tempSet")) { //温度设定
|
|
|
|
|
data1.setTempSet(strData); |
|
|
|
|
} else if (dataType.equals("waterTemp")){ //水箱水温
|
|
|
|
|
} else if (dataType.equals("waterTemp")) { //水箱水温
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(strData); |
|
|
|
|
if (bigDecimal.compareTo(new BigDecimal(0)) >= 0 |
|
|
|
|
&& bigDecimal.compareTo(new BigDecimal(100)) <= 0) { |
|
|
|
|
data1.setWaterTemp(strData); |
|
|
|
|
} |
|
|
|
|
}else if (dataType.equals("runState")){ //运行状态
|
|
|
|
|
} else if (dataType.equals("runState")) { //运行状态
|
|
|
|
|
data1.setRunState(strData); |
|
|
|
|
}else if (dataType.equals("isFault")){ //是否故障
|
|
|
|
|
} else if (dataType.equals("isFault")) { //是否故障
|
|
|
|
|
data1.setIsFault(strData); |
|
|
|
|
} |
|
|
|
|
nowDataMapper.updateNowData(data1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//判断历史表是否有记录
|
|
|
|
|
int r2 = nowDataMapper.selectHistoryDataCount(strDate,buildingId,pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if (r2==0){ |
|
|
|
|
int r2 = nowDataMapper.selectHistoryDataCount(strDate, buildingId, pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if (r2 == 0) { |
|
|
|
|
data.setPumpId(pumpId); //热泵编号
|
|
|
|
|
String pumpName="热泵"+pumpId; |
|
|
|
|
String pumpName = "热泵" + pumpId; |
|
|
|
|
data.setPumpName(pumpName); //热泵名称
|
|
|
|
|
data.setBuildingId(buildingId); |
|
|
|
|
data.setBuildingName(buildingName); |
|
|
|
|
data.setCurDate(strDate); |
|
|
|
|
nowDataMapper.saveHistoryData(data); |
|
|
|
|
}else { |
|
|
|
|
NowDataEntity data2=nowDataMapper.selectHistoryData(strDate,buildingId,pumpId); |
|
|
|
|
if (data2!=null){ |
|
|
|
|
} else { |
|
|
|
|
NowDataEntity data2 = nowDataMapper.selectHistoryData(strDate, buildingId, pumpId); |
|
|
|
|
if (data2 != null) { |
|
|
|
|
switch (dataType) { |
|
|
|
|
case "tempSet": //温度设定
|
|
|
|
|
data2.setTempSet(strData); |
|
|
|
|
@ -407,7 +410,7 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
nowDataMapper.updateHistoryData(data2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -422,22 +425,138 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
nowDataMapper.updateTempSet(buildingId); |
|
|
|
|
nowDataMapper.updateLevelSet(buildingId); |
|
|
|
|
List<NowDataEntity> nowDataEntities = nowDataMapper.queryNowData(buildingId); |
|
|
|
|
|
|
|
|
|
// 处理压变设备离线状态
|
|
|
|
|
handlePressureTransmitterOfflineStatus(buildingId, nowDataEntities); |
|
|
|
|
|
|
|
|
|
// 处理循环泵状态
|
|
|
|
|
handlePumpStatus(buildingId, nowDataEntities, "循环泵", |
|
|
|
|
new HashMap<String, String>() {{ |
|
|
|
|
put("循环泵1", "setCirculateState"); |
|
|
|
|
put("循环泵2", "setCirculateState2"); |
|
|
|
|
}}); |
|
|
|
|
|
|
|
|
|
// 处理回水泵状态
|
|
|
|
|
handlePumpStatus(buildingId, nowDataEntities, "回水泵", |
|
|
|
|
new HashMap<String, String>() {{ |
|
|
|
|
put("回水泵1", "setBackWaterState"); |
|
|
|
|
put("回水泵2", "setBackWaterState2"); |
|
|
|
|
}}); |
|
|
|
|
|
|
|
|
|
// 处理压力值和网关
|
|
|
|
|
handlePressureAndGatewayStatus(buildingId, nowDataEntities, "系统", "5"); |
|
|
|
|
|
|
|
|
|
return nowDataEntities; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handlePressureAndGatewayStatus(String buildingId, List<NowDataEntity> nowDataEntities, String deviceType, String paramTypeId) { |
|
|
|
|
List<DeviceInstallEntity> pumpList = deviceInstallMapper.selectOfflineDevice(buildingId, deviceType); |
|
|
|
|
for (DeviceInstallEntity pump : pumpList) { |
|
|
|
|
CollectionParamsManageEntity pressure = collectionParamsManageMapper.selectByDeviceIdAndParamTypeId(pump.getId(), paramTypeId); |
|
|
|
|
if (pressure != null) { |
|
|
|
|
String pressureValue = pressure.getCurValue().setScale(1, RoundingMode.HALF_UP).toString(); |
|
|
|
|
if (!StringUtils.isBlank(pressureValue)) { |
|
|
|
|
nowDataEntities.stream() |
|
|
|
|
.filter(nowDataEntity -> buildingId.equals(nowDataEntity.getBuildingId())) |
|
|
|
|
.forEach(nowDataEntity -> nowDataEntity.setPressure(pressureValue)); |
|
|
|
|
String dataCom = pump.getDataCom(); |
|
|
|
|
if (!StringUtils.isBlank(dataCom)) { |
|
|
|
|
int gwState = gatewayManageMapper.queryGatewayByDataCom(dataCom); |
|
|
|
|
nowDataEntities.stream() |
|
|
|
|
.filter(nowDataEntity -> buildingId.equals(nowDataEntity.getBuildingId())) |
|
|
|
|
.forEach(nowDataEntity -> nowDataEntity.setGwState(gwState == 0 ? "在线" : "离线")); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理压变设备离线状态 |
|
|
|
|
*/ |
|
|
|
|
private void handlePressureTransmitterOfflineStatus(String buildingId, List<NowDataEntity> nowDataEntities) { |
|
|
|
|
List<DeviceInstallEntity> list = deviceInstallMapper.selectOfflineDevice(buildingId, "压变"); |
|
|
|
|
if (list != null && list.size() > 0) { |
|
|
|
|
if (list != null && !list.isEmpty()) { |
|
|
|
|
for (DeviceInstallEntity deviceInstallEntity : list) { |
|
|
|
|
if (!DateUtil.isToday(deviceInstallEntity.getLastDate())) { |
|
|
|
|
// 使用stream流nowDataEntities,批量更新waterLevel="离线"
|
|
|
|
|
nowDataEntities.stream() |
|
|
|
|
.filter(nowDataEntity -> buildingId.equals(nowDataEntity.getBuildingId())) |
|
|
|
|
.forEach(nowDataEntity -> nowDataEntity.setWaterLevel("离线")); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理泵设备状态 |
|
|
|
|
*/ |
|
|
|
|
private void handlePumpStatus(String buildingId, List<NowDataEntity> nowDataEntities, |
|
|
|
|
String deviceType, Map<String, String> pumpMethodMapping) { |
|
|
|
|
List<DeviceInstallEntity> pumpList = deviceInstallMapper.selectOfflineDevice(buildingId, deviceType); |
|
|
|
|
|
|
|
|
|
for (DeviceInstallEntity pump : pumpList) { |
|
|
|
|
for (Map.Entry<String, String> entry : pumpMethodMapping.entrySet()) { |
|
|
|
|
String pumpIdentifier = entry.getKey(); |
|
|
|
|
String methodName = entry.getValue(); |
|
|
|
|
|
|
|
|
|
if (pump.getDeviceName().contains(pumpIdentifier)) { |
|
|
|
|
updatePumpStatus(nowDataEntities, buildingId, pump, methodName); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return nowDataEntities; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 更新单个泵的状态 |
|
|
|
|
*/ |
|
|
|
|
private void updatePumpStatus(List<NowDataEntity> nowDataEntities, String buildingId, |
|
|
|
|
DeviceInstallEntity pump, String setterMethodName) { |
|
|
|
|
try { |
|
|
|
|
// 查询对应collectionParamManage参数
|
|
|
|
|
CollectionParamsManageEntity runState = collectionParamsManageMapper |
|
|
|
|
.selectByDeviceIdAndParamTypeId(pump.getId(), "2"); |
|
|
|
|
|
|
|
|
|
String status; |
|
|
|
|
if (DateUtil.isToday(runState.getCurTime())) { |
|
|
|
|
status = runState.getCurValue().intValue() == 1 ? "运行" : "不运行"; |
|
|
|
|
} else { |
|
|
|
|
status = "离线"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 使用反射调用对应setter方法
|
|
|
|
|
nowDataEntities.stream() |
|
|
|
|
.filter(nowDataEntity -> buildingId.equals(nowDataEntity.getBuildingId())) |
|
|
|
|
.forEach(nowDataEntity -> { |
|
|
|
|
try { |
|
|
|
|
nowDataEntity.getClass() |
|
|
|
|
.getMethod(setterMethodName, String.class) |
|
|
|
|
.invoke(nowDataEntity, status); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 记录日志或适当处理异常
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 处理查询异常,设置为离线状态
|
|
|
|
|
nowDataEntities.stream() |
|
|
|
|
.filter(nowDataEntity -> buildingId.equals(nowDataEntity.getBuildingId())) |
|
|
|
|
.forEach(nowDataEntity -> { |
|
|
|
|
try { |
|
|
|
|
nowDataEntity.getClass() |
|
|
|
|
.getMethod(setterMethodName, String.class) |
|
|
|
|
.invoke(nowDataEntity, "离线"); |
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
// 记录日志或适当处理异常
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NowDataEntity queryNowDataByPump(String buildingId,String pumpId) { |
|
|
|
|
public NowDataEntity queryNowDataByPump(String buildingId, String pumpId) { |
|
|
|
|
// 查询当前楼栋离线的设备
|
|
|
|
|
List<DeviceInstallEntity> list = deviceInstallMapper.selectOfflineDevice(buildingId, "压变"); |
|
|
|
|
NowDataEntity nowDataEntity = nowDataMapper.queryNowDataByPump(buildingId, pumpId); |
|
|
|
|
@ -462,28 +581,28 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<NowDataEntity> queryHistoryData(String curDate, String buildingId,String pumpId,String tankId, int page, int limit) { |
|
|
|
|
return nowDataMapper.queryHistoryData(curDate,buildingId,pumpId,tankId,page,limit); |
|
|
|
|
public List<NowDataEntity> queryHistoryData(String curDate, String buildingId, String pumpId, String tankId, int page, int limit) { |
|
|
|
|
return nowDataMapper.queryHistoryData(curDate, buildingId, pumpId, tankId, page, limit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getHistoryDataCount(String curDate, String buildingId,String pumpId,String tankId, int page, int limit) { |
|
|
|
|
return nowDataMapper.getHistoryDataCount(curDate,buildingId,pumpId,tankId,page,limit); |
|
|
|
|
public int getHistoryDataCount(String curDate, String buildingId, String pumpId, String tankId, int page, int limit) { |
|
|
|
|
return nowDataMapper.getHistoryDataCount(curDate, buildingId, pumpId, tankId, page, limit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<WaterLevelEntity> queryWaterLevel(String curDate, String buildingID, int page, int limit) { |
|
|
|
|
return nowDataMapper.queryWaterLevel(curDate,buildingID,page,limit); |
|
|
|
|
return nowDataMapper.queryWaterLevel(curDate, buildingID, page, limit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getWaterLevelCount(String curDate, String buildingID) { |
|
|
|
|
return nowDataMapper.getWaterLevelCount(curDate,buildingID); |
|
|
|
|
return nowDataMapper.getWaterLevelCount(curDate, buildingID); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<WaterLevelModel> queryWaterLevelByTime(String curDate,int page,int limit) { |
|
|
|
|
return nowDataMapper.queryWaterLevelByTime(curDate,page,limit); |
|
|
|
|
public List<WaterLevelModel> queryWaterLevelByTime(String curDate, int page, int limit) { |
|
|
|
|
return nowDataMapper.queryWaterLevelByTime(curDate, page, limit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -508,36 +627,36 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String selectSingleTemp(String pumpId,String buildingId) { |
|
|
|
|
return nowDataMapper.selectSingleTemp(pumpId,buildingId); |
|
|
|
|
public String selectSingleTemp(String pumpId, String buildingId) { |
|
|
|
|
return nowDataMapper.selectSingleTemp(pumpId, buildingId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//从监视表查询热泵运行状态
|
|
|
|
|
@Override |
|
|
|
|
public String selectStateCount(String buildingId) { |
|
|
|
|
int count=nowDataMapper.selectStateCount(buildingId); |
|
|
|
|
String state=""; |
|
|
|
|
if (count==0){ |
|
|
|
|
state="不运行"; |
|
|
|
|
}else{ |
|
|
|
|
state="运行"; |
|
|
|
|
int count = nowDataMapper.selectStateCount(buildingId); |
|
|
|
|
String state = ""; |
|
|
|
|
if (count == 0) { |
|
|
|
|
state = "不运行"; |
|
|
|
|
} else { |
|
|
|
|
state = "运行"; |
|
|
|
|
} |
|
|
|
|
return state; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String selectState(String buildingId, String pumpId) { |
|
|
|
|
return nowDataMapper.selectState(buildingId,pumpId); |
|
|
|
|
return nowDataMapper.selectState(buildingId, pumpId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void upLevelSet(String buildingId, String levelSet) { |
|
|
|
|
nowDataMapper.upLevelSet(buildingId,levelSet); |
|
|
|
|
nowDataMapper.upLevelSet(buildingId, levelSet); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void upTempSet(String buildingId, String tempSet) { |
|
|
|
|
nowDataMapper.upTempSet(buildingId,tempSet); |
|
|
|
|
nowDataMapper.upTempSet(buildingId, tempSet); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -546,18 +665,18 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<WaterTempEntity> queryWaterTemp(String buildingID, String curDate,int page,int limit) { |
|
|
|
|
return nowDataMapper.queryWaterTemp(buildingID,curDate,page,limit); |
|
|
|
|
public List<WaterTempEntity> queryWaterTemp(String buildingID, String curDate, int page, int limit) { |
|
|
|
|
return nowDataMapper.queryWaterTemp(buildingID, curDate, page, limit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int queryWaterTempCount(String buildingID, String curDate) { |
|
|
|
|
return nowDataMapper.queryWaterTempCount(buildingID,curDate); |
|
|
|
|
return nowDataMapper.queryWaterTempCount(buildingID, curDate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询所有楼栋每栋楼的平均温度
|
|
|
|
|
@Override |
|
|
|
|
public List<WaterTempEntity> queryWaterTemp2(String curDate,int page,int limit, int level, String buildingID) { |
|
|
|
|
public List<WaterTempEntity> queryWaterTemp2(String curDate, int page, int limit, int level, String buildingID) { |
|
|
|
|
List<WaterTempEntity> waterTempEntityList = nowDataMapper.queryWaterTemp2(curDate, page, limit); |
|
|
|
|
// 根据level层级查询
|
|
|
|
|
if (level == 1) { |
|
|
|
|
@ -568,6 +687,7 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
} |
|
|
|
|
return waterTempEntityList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询所有楼栋每栋楼的平均温度记录数
|
|
|
|
|
@Override |
|
|
|
|
public int queryWaterTempCount2(String curDate, int level, String buildingID) { |
|
|
|
|
@ -581,7 +701,7 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
try { |
|
|
|
|
lockB.lock(); |
|
|
|
|
try { |
|
|
|
|
nowDataMapper.proWaterTemp(curDate,buildingID,pumpID); |
|
|
|
|
nowDataMapper.proWaterTemp(curDate, buildingID, pumpID); |
|
|
|
|
} finally { |
|
|
|
|
lockB.unlock(); |
|
|
|
|
} |
|
|
|
|
@ -613,11 +733,11 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void updateRunState(String buildingId, String pumpId,String strState, String buildingName) { |
|
|
|
|
DeviceInstallEntity deviceInstallEntity=deviceInstallMapper.selectDevice(pumpId,"热泵",buildingId); |
|
|
|
|
NowDataEntity data=new NowDataEntity(); |
|
|
|
|
int r1 = nowDataMapper.selectNowDataCount(buildingId,pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if(r1==0){ |
|
|
|
|
public void updateRunState(String buildingId, String pumpId, String strState, String buildingName) { |
|
|
|
|
DeviceInstallEntity deviceInstallEntity = deviceInstallMapper.selectDevice(pumpId, "热泵", buildingId); |
|
|
|
|
NowDataEntity data = new NowDataEntity(); |
|
|
|
|
int r1 = nowDataMapper.selectNowDataCount(buildingId, pumpId);//判断now_data表是否存在记录
|
|
|
|
|
if (r1 == 0) { |
|
|
|
|
data.setPumpId(pumpId); //通讯地址
|
|
|
|
|
data.setPumpName(deviceInstallEntity.getDeviceName()); //通讯地址
|
|
|
|
|
data.setBuildingId(buildingId); |
|
|
|
|
@ -625,22 +745,22 @@ public class NowDataServiceImpl implements NowDataService {
|
|
|
|
|
data.setRunState(strState); |
|
|
|
|
nowDataMapper.saveNowData(data); |
|
|
|
|
} |
|
|
|
|
nowDataMapper.updateRunState(buildingId,pumpId,strState); |
|
|
|
|
nowDataMapper.updateRunState(buildingId, pumpId, strState); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void proPumpMinutes(String buildingId, String pumpId, String runState) { |
|
|
|
|
nowDataMapper.proPumpMinutes(buildingId,pumpId,runState); |
|
|
|
|
nowDataMapper.proPumpMinutes(buildingId, pumpId, runState); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<PumpMinutesEntity> pumpMinutes(String startDate,String endDate, String buildingId, String pumpId, int page, int limit) { |
|
|
|
|
return nowDataMapper.pumpMinutes(startDate,endDate,buildingId,pumpId,page,limit); |
|
|
|
|
public List<PumpMinutesEntity> pumpMinutes(String startDate, String endDate, String buildingId, String pumpId, int page, int limit) { |
|
|
|
|
return nowDataMapper.pumpMinutes(startDate, endDate, buildingId, pumpId, page, limit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int pumpMinutesCount(String startDate,String endDate, String buildingId, String pumpId) { |
|
|
|
|
return nowDataMapper.pumpMinutesCount(startDate,endDate,buildingId,pumpId); |
|
|
|
|
public int pumpMinutesCount(String startDate, String endDate, String buildingId, String pumpId) { |
|
|
|
|
return nowDataMapper.pumpMinutesCount(startDate, endDate, buildingId, pumpId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|