|
|
|
@ -1,17 +1,24 @@
|
|
|
|
|
package com.mh.user.service.chillers.impl; |
|
|
|
|
|
|
|
|
|
import com.mh.user.entity.ChillersEntity; |
|
|
|
|
import com.mh.user.entity.HostValue; |
|
|
|
|
import com.mh.user.entity.TableDataEntity; |
|
|
|
|
import com.mh.user.entity.TableInfoEntity; |
|
|
|
|
import com.alibaba.fastjson2.JSONArray; |
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.mh.user.entity.*; |
|
|
|
|
import com.mh.user.mapper.DevicesManageMapper; |
|
|
|
|
import com.mh.user.mapper.MeterManageMapper; |
|
|
|
|
import com.mh.user.mapper.ProjectInfoMapper; |
|
|
|
|
import com.mh.user.mapper.chillers.ChillersMapper; |
|
|
|
|
import com.mh.user.service.chillers.ChillersService; |
|
|
|
|
import com.mh.user.utils.DateUtil; |
|
|
|
|
import com.mh.user.utils.TimeDifferenceUtil; |
|
|
|
|
import com.mh.user.vo.HostListVO; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author ljf |
|
|
|
@ -23,267 +30,411 @@ import java.util.List;
|
|
|
|
|
@Service |
|
|
|
|
public class ChillersServiceImpl implements ChillersService { |
|
|
|
|
|
|
|
|
|
// 构造方法注入
|
|
|
|
|
private final ChillersMapper chillersMapper; |
|
|
|
|
private List<HostValue> hostValueList; |
|
|
|
|
double chillerWaterInt = 0.00; // 冷冻水回水温度 0A
|
|
|
|
|
double chillerWaterOut = 0.00; // 冷冻水出水温度 0B
|
|
|
|
|
double coldWaterInt = 0.00; // 冷却水回水温度 0E
|
|
|
|
|
double coldWaterOut = 0.00; // 冷却水出水温度 0F
|
|
|
|
|
// 构造方法注入
|
|
|
|
|
private final ChillersMapper chillersMapper; |
|
|
|
|
private List<HostValue> hostValueList; |
|
|
|
|
double chillerWaterInt = 0.00; // 冷冻水回水温度 0A
|
|
|
|
|
double chillerWaterOut = 0.00; // 冷冻水出水温度 0B
|
|
|
|
|
double coldWaterInt = 0.00; // 冷却水回水温度 0E
|
|
|
|
|
double coldWaterOut = 0.00; // 冷却水出水温度 0F
|
|
|
|
|
|
|
|
|
|
public ChillersServiceImpl(ChillersMapper chillersMapper, List<HostValue> hostValueList) { |
|
|
|
|
this.chillersMapper = chillersMapper; |
|
|
|
|
this.hostValueList = hostValueList; |
|
|
|
|
} |
|
|
|
|
private final DevicesManageMapper devicesManageMapper; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HostValue> queryTempValue(String deviceType) { |
|
|
|
|
hostValueList.clear(); |
|
|
|
|
if (deviceType.equalsIgnoreCase("other")) { |
|
|
|
|
List<ChillersEntity> chillersEntityList = getRunningChillers(); |
|
|
|
|
if (chillersEntityList.size() == 2) { |
|
|
|
|
// 获取对应的冷冻水、冷却水温度
|
|
|
|
|
List<ChillersEntity> chillersEntityList1 = chillersMapper.getChillersTemp(chillersEntityList.get(0).getDeviceCode()); |
|
|
|
|
List<ChillersEntity> chillersEntityList2 = chillersMapper.getChillersTemp(chillersEntityList.get(1).getDeviceCode()); |
|
|
|
|
for (int i = 0; i < chillersEntityList1.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList1.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < chillersEntityList2.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList2.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterOut; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterOut; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 四舍五入,保留两位小数
|
|
|
|
|
BigDecimal b2 = BigDecimal.valueOf(chillerWaterOut / 2); |
|
|
|
|
chillerWaterOut = b2.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf(chillerWaterInt / 2); |
|
|
|
|
chillerWaterInt = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b4 = BigDecimal.valueOf(coldWaterOut / 2); |
|
|
|
|
coldWaterOut = b4.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b3 = BigDecimal.valueOf(coldWaterInt / 2); |
|
|
|
|
coldWaterInt = b3.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
private final MeterManageMapper meterManageMapper; |
|
|
|
|
|
|
|
|
|
} else if (chillersEntityList.size() == 1) { |
|
|
|
|
// 获取对应的冷冻水、冷却水温度
|
|
|
|
|
List<ChillersEntity> chillersEntityList1 = chillersMapper.getChillersTemp(chillersEntityList.get(0).getDeviceCode()); |
|
|
|
|
for (int i = 0; i < chillersEntityList1.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList1.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (chillersEntityList.size() == 0) { // update by ljf on 2021-01-11
|
|
|
|
|
// 获取对应的冷水机组
|
|
|
|
|
List<ChillersEntity> chillersEntityList3 = getStopChillers(); |
|
|
|
|
// 获取对应的冷冻水、冷却水温度
|
|
|
|
|
List<ChillersEntity> chillersEntityList1 = chillersMapper.getChillersTemp(chillersEntityList3.get(0).getDeviceCode()); |
|
|
|
|
List<ChillersEntity> chillersEntityList2 = chillersMapper.getChillersTemp(chillersEntityList3.get(1).getDeviceCode()); |
|
|
|
|
for (int i = 0; i < chillersEntityList1.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList1.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < chillersEntityList2.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList2.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterOut; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterOut; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 四舍五入,保留两位小数
|
|
|
|
|
BigDecimal b2 = BigDecimal.valueOf(chillerWaterOut / 2); |
|
|
|
|
chillerWaterOut = b2.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf(chillerWaterInt / 2); |
|
|
|
|
chillerWaterInt = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b4 = BigDecimal.valueOf(coldWaterOut / 2); |
|
|
|
|
coldWaterOut = b4.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b3 = BigDecimal.valueOf(coldWaterInt / 2); |
|
|
|
|
coldWaterInt = b3.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
} |
|
|
|
|
HostValue hostValue = new HostValue(); |
|
|
|
|
hostValue.setId(1); |
|
|
|
|
hostValue.setType("chilledOutWater"); |
|
|
|
|
hostValue.setValue(chillerWaterOut); |
|
|
|
|
hostValueList.add(hostValue); |
|
|
|
|
HostValue hostValue1 = new HostValue(); |
|
|
|
|
hostValue1.setId(2); |
|
|
|
|
hostValue1.setType("chilledInWater"); |
|
|
|
|
hostValue1.setValue(chillerWaterInt); |
|
|
|
|
hostValueList.add(hostValue1); |
|
|
|
|
HostValue hostValue2 = new HostValue(); |
|
|
|
|
hostValue2.setId(3); |
|
|
|
|
hostValue2.setType("coolingOutWater"); |
|
|
|
|
hostValue2.setValue(coldWaterOut); |
|
|
|
|
hostValueList.add(hostValue2); |
|
|
|
|
HostValue hostValue3 = new HostValue(); |
|
|
|
|
hostValue3.setId(4); |
|
|
|
|
hostValue3.setType("coolingInWater"); |
|
|
|
|
hostValue3.setValue(coldWaterInt); |
|
|
|
|
hostValueList.add(hostValue3); |
|
|
|
|
} else if (deviceType.equalsIgnoreCase("hostOne")) { |
|
|
|
|
private final ProjectInfoMapper projectInfoMapper; |
|
|
|
|
|
|
|
|
|
public ChillersServiceImpl(ChillersMapper chillersMapper, |
|
|
|
|
List<HostValue> hostValueList, |
|
|
|
|
DevicesManageMapper devicesManageMapper, |
|
|
|
|
MeterManageMapper meterManageMapper, ProjectInfoMapper projectInfoMapper) { |
|
|
|
|
this.chillersMapper = chillersMapper; |
|
|
|
|
this.hostValueList = hostValueList; |
|
|
|
|
this.devicesManageMapper = devicesManageMapper; |
|
|
|
|
this.meterManageMapper = meterManageMapper; |
|
|
|
|
this.projectInfoMapper = projectInfoMapper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HostValue> queryTempValue(String deviceType) { |
|
|
|
|
hostValueList.clear(); |
|
|
|
|
if (deviceType.equalsIgnoreCase("other")) { |
|
|
|
|
List<ChillersEntity> chillersEntityList = getRunningChillers(); |
|
|
|
|
if (chillersEntityList.size() == 2) { |
|
|
|
|
// 获取对应的冷冻水、冷却水温度
|
|
|
|
|
List<ChillersEntity> chillersEntityList1 = chillersMapper.getChillersTemp(chillersEntityList.get(0).getDeviceCode()); |
|
|
|
|
List<ChillersEntity> chillersEntityList2 = chillersMapper.getChillersTemp(chillersEntityList.get(1).getDeviceCode()); |
|
|
|
|
for (int i = 0; i < chillersEntityList1.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList1.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < chillersEntityList2.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList2.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterOut; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterOut; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 四舍五入,保留两位小数
|
|
|
|
|
BigDecimal b2 = BigDecimal.valueOf(chillerWaterOut / 2); |
|
|
|
|
chillerWaterOut = b2.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf(chillerWaterInt / 2); |
|
|
|
|
chillerWaterInt = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b4 = BigDecimal.valueOf(coldWaterOut / 2); |
|
|
|
|
coldWaterOut = b4.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b3 = BigDecimal.valueOf(coldWaterInt / 2); |
|
|
|
|
coldWaterInt = b3.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
|
|
|
|
|
} else if (deviceType.equalsIgnoreCase("hostTwo")) { |
|
|
|
|
} else if (chillersEntityList.size() == 1) { |
|
|
|
|
// 获取对应的冷冻水、冷却水温度
|
|
|
|
|
List<ChillersEntity> chillersEntityList1 = chillersMapper.getChillersTemp(chillersEntityList.get(0).getDeviceCode()); |
|
|
|
|
for (int i = 0; i < chillersEntityList1.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList1.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (chillersEntityList.size() == 0) { // update by ljf on 2021-01-11
|
|
|
|
|
// 获取对应的冷水机组
|
|
|
|
|
List<ChillersEntity> chillersEntityList3 = getStopChillers(); |
|
|
|
|
// 获取对应的冷冻水、冷却水温度
|
|
|
|
|
List<ChillersEntity> chillersEntityList1 = chillersMapper.getChillersTemp(chillersEntityList3.get(0).getDeviceCode()); |
|
|
|
|
List<ChillersEntity> chillersEntityList2 = chillersMapper.getChillersTemp(chillersEntityList3.get(1).getDeviceCode()); |
|
|
|
|
for (int i = 0; i < chillersEntityList1.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList1.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList1.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < chillersEntityList2.size(); i++) { |
|
|
|
|
String registerAddr = chillersEntityList2.get(i).getRegisterAddress(); |
|
|
|
|
if (registerAddr.equalsIgnoreCase("0A")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0B")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
chillerWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + chillerWaterOut; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0E")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterInt = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterInt; |
|
|
|
|
} else if (registerAddr.equalsIgnoreCase("0F")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(chillersEntityList2.get(i).getLastValue()); |
|
|
|
|
coldWaterOut = Double.parseDouble(String.valueOf(bigDecimal)) + coldWaterOut; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 四舍五入,保留两位小数
|
|
|
|
|
BigDecimal b2 = BigDecimal.valueOf(chillerWaterOut / 2); |
|
|
|
|
chillerWaterOut = b2.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b1 = BigDecimal.valueOf(chillerWaterInt / 2); |
|
|
|
|
chillerWaterInt = b1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b4 = BigDecimal.valueOf(coldWaterOut / 2); |
|
|
|
|
coldWaterOut = b4.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
BigDecimal b3 = BigDecimal.valueOf(coldWaterInt / 2); |
|
|
|
|
coldWaterInt = b3.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
|
} |
|
|
|
|
HostValue hostValue = new HostValue(); |
|
|
|
|
hostValue.setId(1); |
|
|
|
|
hostValue.setType("chilledOutWater"); |
|
|
|
|
hostValue.setValue(chillerWaterOut); |
|
|
|
|
hostValueList.add(hostValue); |
|
|
|
|
HostValue hostValue1 = new HostValue(); |
|
|
|
|
hostValue1.setId(2); |
|
|
|
|
hostValue1.setType("chilledInWater"); |
|
|
|
|
hostValue1.setValue(chillerWaterInt); |
|
|
|
|
hostValueList.add(hostValue1); |
|
|
|
|
HostValue hostValue2 = new HostValue(); |
|
|
|
|
hostValue2.setId(3); |
|
|
|
|
hostValue2.setType("coolingOutWater"); |
|
|
|
|
hostValue2.setValue(coldWaterOut); |
|
|
|
|
hostValueList.add(hostValue2); |
|
|
|
|
HostValue hostValue3 = new HostValue(); |
|
|
|
|
hostValue3.setId(4); |
|
|
|
|
hostValue3.setType("coolingInWater"); |
|
|
|
|
hostValue3.setValue(coldWaterInt); |
|
|
|
|
hostValueList.add(hostValue3); |
|
|
|
|
} else if (deviceType.equalsIgnoreCase("hostOne")) { |
|
|
|
|
|
|
|
|
|
} else if (deviceType.equalsIgnoreCase("town")) { |
|
|
|
|
} else if (deviceType.equalsIgnoreCase("hostTwo")) { |
|
|
|
|
|
|
|
|
|
} else if (deviceType.equalsIgnoreCase("town")) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return hostValueList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询冷水机组进出水温度两者的平均值
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> getRunningChillers() { |
|
|
|
|
return chillersMapper.getRunningChillers(); |
|
|
|
|
} |
|
|
|
|
return hostValueList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询冷水机组进出水温度两者的平均值
|
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> getStopChillers() { |
|
|
|
|
return chillersMapper.getStopChillers(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> getRunningChillers() { |
|
|
|
|
return chillersMapper.getRunningChillers(); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> queryChillersByOther(int grade, String ddcAddr) { |
|
|
|
|
return chillersMapper.queryChillersByOther(grade, ddcAddr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> getStopChillers() { |
|
|
|
|
return chillersMapper.getStopChillers(); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public int insertChillersHistory(ChillersEntity chillersEntity) { |
|
|
|
|
try { |
|
|
|
|
System.out.println(chillersEntity.toString()); |
|
|
|
|
// 判断是否大于等于最近插入时间的30分钟,
|
|
|
|
|
String lastTimeStr = queryLastChillersHistory(chillersEntity); |
|
|
|
|
if (lastTimeStr == null || lastTimeStr.equalsIgnoreCase("")) { |
|
|
|
|
// 格式化时间分钟为15,30,45,00
|
|
|
|
|
chillersEntity.setLastTime(DateUtil.formatDateStr(chillersEntity.getLastTime())); |
|
|
|
|
// 大于就插入数据库,否则就更新基表安装信息的表
|
|
|
|
|
return chillersMapper.insertChillersHistory(chillersEntity); |
|
|
|
|
} else { |
|
|
|
|
int dValue = TimeDifferenceUtil.dValue(lastTimeStr); |
|
|
|
|
if (dValue >= 30) { |
|
|
|
|
// 格式化时间分钟为15,30,45,00
|
|
|
|
|
chillersEntity.setLastTime(DateUtil.formatDateStr(chillersEntity.getLastTime())); |
|
|
|
|
// 大于就插入数据库,否则就更新基表安装信息的表
|
|
|
|
|
return chillersMapper.insertChillersHistory(chillersEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 不管时间差如何都进行更新基表安装信息
|
|
|
|
|
chillersMapper.updateChillerRegisterAddr(chillersEntity); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> queryChillersByOther(int grade, String ddcAddr) { |
|
|
|
|
return chillersMapper.queryChillersByOther(grade, ddcAddr); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public void updateChillerRegisterAddr(ChillersEntity chillersEntity) { |
|
|
|
|
chillersMapper.updateChillerRegisterAddr(chillersEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int insertChillersHistory(ChillersEntity chillersEntity) { |
|
|
|
|
try { |
|
|
|
|
System.out.println(chillersEntity.toString()); |
|
|
|
|
// 判断是否大于等于最近插入时间的30分钟,
|
|
|
|
|
String lastTimeStr = queryLastChillersHistory(chillersEntity); |
|
|
|
|
if (lastTimeStr == null || lastTimeStr.equalsIgnoreCase("")) { |
|
|
|
|
// 格式化时间分钟为15,30,45,00
|
|
|
|
|
chillersEntity.setLastTime(DateUtil.formatDateStr(chillersEntity.getLastTime())); |
|
|
|
|
// 大于就插入数据库,否则就更新基表安装信息的表
|
|
|
|
|
return chillersMapper.insertChillersHistory(chillersEntity); |
|
|
|
|
} else { |
|
|
|
|
int dValue = TimeDifferenceUtil.dValue(lastTimeStr); |
|
|
|
|
if (dValue >= 30) { |
|
|
|
|
// 格式化时间分钟为15,30,45,00
|
|
|
|
|
chillersEntity.setLastTime(DateUtil.formatDateStr(chillersEntity.getLastTime())); |
|
|
|
|
// 大于就插入数据库,否则就更新基表安装信息的表
|
|
|
|
|
return chillersMapper.insertChillersHistory(chillersEntity); |
|
|
|
|
@Override |
|
|
|
|
public void updateDataNow(ChillersEntity chillersEntity) { |
|
|
|
|
try { |
|
|
|
|
// 判断是否存在实时记录表
|
|
|
|
|
int a = chillersMapper.queryDataNowByOthers(chillersEntity); |
|
|
|
|
if (a == 0) { |
|
|
|
|
// 不存在则进行插入处理
|
|
|
|
|
chillersMapper.insertChillerDataNow(chillersEntity); |
|
|
|
|
} else { |
|
|
|
|
// 存在则进行更新处理
|
|
|
|
|
chillersMapper.updateDataNow(chillersEntity); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 不管时间差如何都进行更新基表安装信息
|
|
|
|
|
chillersMapper.updateChillerRegisterAddr(chillersEntity); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void updateChillerRegisterAddr(ChillersEntity chillersEntity) { |
|
|
|
|
chillersMapper.updateChillerRegisterAddr(chillersEntity); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public int batchUpdateRegisterAddr(List<ChillersEntity> chillersEntityLists) { |
|
|
|
|
return chillersMapper.updateRegisterAddr(chillersEntityLists); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<TableDataEntity> queryTopData(String deviceName, int grade) { |
|
|
|
|
return chillersMapper.queryTopData(deviceName, grade); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<TableInfoEntity> queryLeftAndRightData(String deviceName, int grade) { |
|
|
|
|
return chillersMapper.queryLeftAndRightData(deviceName, grade); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void updateDataNow(ChillersEntity chillersEntity) { |
|
|
|
|
try { |
|
|
|
|
// 判断是否存在实时记录表
|
|
|
|
|
int a = chillersMapper.queryDataNowByOthers(chillersEntity); |
|
|
|
|
if (a == 0) { |
|
|
|
|
// 不存在则进行插入处理
|
|
|
|
|
chillersMapper.insertChillerDataNow(chillersEntity); |
|
|
|
|
} else { |
|
|
|
|
// 存在则进行更新处理
|
|
|
|
|
chillersMapper.updateDataNow(chillersEntity); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> queryChillersDDC(int grade) { |
|
|
|
|
return chillersMapper.queryChillersDDC(grade); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int batchUpdateRegisterAddr(List<ChillersEntity> chillersEntityLists) { |
|
|
|
|
return chillersMapper.updateRegisterAddr(chillersEntityLists); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public void batchInsertChillersHistory(List<ChillersEntity> chillersEntityLists) { |
|
|
|
|
chillersMapper.batchInsertChillersHistory(chillersEntityLists); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<TableDataEntity> queryTopData(String deviceName, int grade) { |
|
|
|
|
return chillersMapper.queryTopData(deviceName, grade); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public String queryLastChillersHistory(ChillersEntity chillersEntity) { |
|
|
|
|
return chillersMapper.queryLastChillersHistory(chillersEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<TableInfoEntity> queryLeftAndRightData(String deviceName, int grade) { |
|
|
|
|
return chillersMapper.queryLeftAndRightData(deviceName, grade); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<String> queryDDCAddr(String ddcAddr) { |
|
|
|
|
return chillersMapper.queryDDCAddr(ddcAddr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<ChillersEntity> queryChillersDDC(int grade) { |
|
|
|
|
return chillersMapper.queryChillersDDC(grade); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public JSONArray queryChillersByProId(String systemId, String proId) { |
|
|
|
|
JSONArray resultJson = new JSONArray(); |
|
|
|
|
QueryWrapper<DevicesManageEntity> deviceQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
if (systemId != null && !systemId.equalsIgnoreCase("")) { |
|
|
|
|
deviceQueryWrapper.eq("system_id", systemId); |
|
|
|
|
} |
|
|
|
|
if (proId != null && !proId.equalsIgnoreCase("")) { |
|
|
|
|
deviceQueryWrapper.eq("project_id", proId); |
|
|
|
|
} |
|
|
|
|
List<DevicesManageEntity> devicesManageEntityList = devicesManageMapper.selectList(deviceQueryWrapper.orderByAsc("id")); |
|
|
|
|
if (devicesManageEntityList != null && !devicesManageEntityList.isEmpty()) { |
|
|
|
|
HostListVO hostListVO = new HostListVO(); |
|
|
|
|
// 根据projectId进行分组
|
|
|
|
|
Map<Long, List<DevicesManageEntity>> proDevicesMap = |
|
|
|
|
devicesManageEntityList.stream().collect(Collectors.groupingBy(DevicesManageEntity::getProjectId)); |
|
|
|
|
// 遍历分组后的数据
|
|
|
|
|
for (Map.Entry<Long, List<DevicesManageEntity>> entry : proDevicesMap.entrySet()) { |
|
|
|
|
if (entry.getValue() != null && !entry.getValue().isEmpty()) { |
|
|
|
|
// 根据key(projectId)获取对应的项目名称
|
|
|
|
|
String projectName = projectInfoMapper.selectById(entry.getKey()).getProjectName(); |
|
|
|
|
JSONObject proJson = new JSONObject(); |
|
|
|
|
proJson.put("name", projectName); |
|
|
|
|
proJson.put("value", entry.getKey()); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void batchInsertChillersHistory(List<ChillersEntity> chillersEntityLists) { |
|
|
|
|
chillersMapper.batchInsertChillersHistory(chillersEntityLists); |
|
|
|
|
} |
|
|
|
|
JSONArray children = new JSONArray(); |
|
|
|
|
List<DevicesManageEntity> devicesManageEntities = entry.getValue(); |
|
|
|
|
for (DevicesManageEntity devicesManageEntity : devicesManageEntities) { |
|
|
|
|
JSONObject deviceJson = new JSONObject(); |
|
|
|
|
deviceJson.put("name", devicesManageEntity.getDeviceName()); |
|
|
|
|
deviceJson.put("value", devicesManageEntity.getId()); |
|
|
|
|
JSONArray mtArray = new JSONArray(); |
|
|
|
|
List<MeterManageEntity> meterManageEntities = meterManageMapper.selectList( |
|
|
|
|
new QueryWrapper<MeterManageEntity>() |
|
|
|
|
.eq("device_id", devicesManageEntity.getId()) |
|
|
|
|
.orderByAsc("sort")); |
|
|
|
|
if (meterManageEntities != null && !meterManageEntities.isEmpty()) { |
|
|
|
|
matchingChillersData(meterManageEntities, hostListVO); |
|
|
|
|
// 额定制冷量
|
|
|
|
|
hostListVO.setRatedRef(String.valueOf(devicesManageEntity.getRatedRefrigerationCapacity())); |
|
|
|
|
// 额定功率
|
|
|
|
|
hostListVO.setRatedPower(String.valueOf(devicesManageEntity.getRatedInputPower())); |
|
|
|
|
// 额定COP
|
|
|
|
|
hostListVO.setRatedCop(String.valueOf(devicesManageEntity.getRatedCop())); |
|
|
|
|
} |
|
|
|
|
mtArray.add(hostListVO); |
|
|
|
|
deviceJson.put("children", mtArray); |
|
|
|
|
children.add(deviceJson); |
|
|
|
|
} |
|
|
|
|
proJson.put("children", children); |
|
|
|
|
resultJson.add(proJson); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return resultJson; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String queryLastChillersHistory(ChillersEntity chillersEntity) { |
|
|
|
|
return chillersMapper.queryLastChillersHistory(chillersEntity); |
|
|
|
|
} |
|
|
|
|
private void matchingChillersData(List<MeterManageEntity> meterManageEntities, HostListVO hostListVO) { |
|
|
|
|
hostListVO.reset(); |
|
|
|
|
for (MeterManageEntity meterManageEntity : meterManageEntities) { |
|
|
|
|
// 匹配HostListVO展示给前端
|
|
|
|
|
String funCode = meterManageEntity.getFuncCode(); |
|
|
|
|
String curValue = String.valueOf(meterManageEntity.getCurValue()); |
|
|
|
|
switch (meterManageEntity.getMtCode()) { |
|
|
|
|
case "0001": |
|
|
|
|
if (funCode.equals("1")) { |
|
|
|
|
hostListVO.setRunningStatus(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0003": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setEnteringTempSet(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0005": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setEvapLeavingChWTemp(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0006": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setEvapEnteringChWTemp(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0015": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setEvapApproach(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0009": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setCondLeavingChWTemp(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0010": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setCondEnteringChWTemp(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0023": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setCondApproach(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0139": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setRealTimeChillerAmps(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0013": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setRealTimePower(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0014": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setRealTimeCop(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case "0122": |
|
|
|
|
if (funCode.equals("3")) { |
|
|
|
|
hostListVO.setRealTimeWarning(curValue); |
|
|
|
|
hostListVO.setRealTimeFault(curValue); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<String> queryDDCAddr(String ddcAddr) { |
|
|
|
|
return chillersMapper.queryDDCAddr(ddcAddr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|