|
|
|
@ -7,6 +7,7 @@ import com.mh.common.core.domain.vo.EnergyConsumptionVO;
|
|
|
|
|
import com.mh.common.utils.DateUtils; |
|
|
|
|
import com.mh.common.utils.EnergyThreadPoolService; |
|
|
|
|
import com.mh.common.utils.StringUtils; |
|
|
|
|
import com.mh.common.utils.bean.BeanUtils; |
|
|
|
|
import com.mh.system.mapper.energy.EnergyMapper; |
|
|
|
|
import com.mh.system.service.energy.IEnergyService; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
@ -351,7 +352,7 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
String deviceType = vo.getParamType(); |
|
|
|
|
if ("meter".equals(deviceType)) { |
|
|
|
|
deviceType = "5"; |
|
|
|
|
} else if ("cold".equals(deviceType)){ |
|
|
|
|
} else if ("cloud".equals(deviceType)) { |
|
|
|
|
deviceType = "6"; |
|
|
|
|
} |
|
|
|
|
if ("cop".equalsIgnoreCase(vo.getParamType())) { |
|
|
|
@ -391,7 +392,7 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
consumptionAnalyzeEntities = energyMapper.queryOneTableYoy(vo.getStartTime(), vo.getEndTime(), lastTableName, curTableName, |
|
|
|
|
startTime, endTime, getTimeLen(vo.getTimeType()), deviceType, vo.getTimeType(), vo.getSystemType()); |
|
|
|
|
} |
|
|
|
|
return getConsumptionDTOHttpResult(consumptionAnalyzeEntities, "yoy"); |
|
|
|
|
return getConsumptionDTOHttpResult(consumptionAnalyzeEntities, "yoy", getTimeLen(vo.getTimeType())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private AjaxResult calcCopYoyData(EnergyConsumptionVO vo) { |
|
|
|
@ -410,46 +411,48 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
return AjaxResult.error(); |
|
|
|
|
} |
|
|
|
|
// 计算COP值
|
|
|
|
|
return getEnergyConsumptionDTOHttpResult(meterEnergyData, cloudEnergyData); |
|
|
|
|
return getEnergyConsumptionDTOHttpResult(meterEnergyData, cloudEnergyData, "yoy"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static AjaxResult getEnergyConsumptionDTOHttpResult(EnergyConsumptionDTO meterEnergyData, EnergyConsumptionDTO cloudEnergyData) { |
|
|
|
|
private static AjaxResult getEnergyConsumptionDTOHttpResult(EnergyConsumptionDTO meterEnergyData, EnergyConsumptionDTO cloudEnergyData, String type) { |
|
|
|
|
// 计算COP值
|
|
|
|
|
EnergyConsumptionDTO energyConsumptionDTO = new EnergyConsumptionDTO(); |
|
|
|
|
//
|
|
|
|
|
// 获取冷量数据
|
|
|
|
|
List<Map<String, Object>> cloudListData = cloudEnergyData.getData(); |
|
|
|
|
String[] cloudCurData = new String[cloudListData.size()]; |
|
|
|
|
String[] cloudLastData = new String[cloudListData.size()]; |
|
|
|
|
String[] curStr = (String[]) cloudListData.getFirst().get("curValue"); |
|
|
|
|
String[] cloudCurData = new String[curStr.length]; |
|
|
|
|
String[] cloudLastData = new String[curStr.length]; |
|
|
|
|
for (Map<String, Object> cloudListDatum : cloudListData) { |
|
|
|
|
if (cloudListDatum.get("curValue") != null) { |
|
|
|
|
cloudCurData = (String[]) cloudListDatum.get("curValue"); |
|
|
|
|
if (cloudCurData == null) { |
|
|
|
|
cloudCurData = new String[cloudListData.size()]; |
|
|
|
|
cloudCurData = new String[curStr.length]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (cloudListDatum.get("lastValue") != null) { |
|
|
|
|
cloudLastData = (String[]) cloudListDatum.get("curValue"); |
|
|
|
|
if (cloudLastData == null) { |
|
|
|
|
cloudLastData = new String[cloudListData.size()]; |
|
|
|
|
cloudLastData = new String[curStr.length]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 获取电量数据
|
|
|
|
|
List<Map<String, Object>> meterListData = meterEnergyData.getData(); |
|
|
|
|
String[] meterCurData = new String[meterListData.size()]; |
|
|
|
|
String[] meterLastData = new String[meterListData.size()]; |
|
|
|
|
String[] meterCurStr = (String[]) meterListData.getFirst().get("curValue"); |
|
|
|
|
String[] meterCurData = new String[meterCurStr.length]; |
|
|
|
|
String[] meterLastData = new String[meterCurStr.length]; |
|
|
|
|
for (Map<String, Object> meterListDatum : meterListData) { |
|
|
|
|
if (meterListDatum.get("curValue") != null) { |
|
|
|
|
meterCurData = (String[]) meterListDatum.get("curValue"); |
|
|
|
|
if (meterCurData == null) { |
|
|
|
|
meterCurData = new String[meterListData.size()]; |
|
|
|
|
meterCurData = new String[meterCurStr.length]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (meterListDatum.get("lastValue") != null) { |
|
|
|
|
meterLastData = (String[]) meterListDatum.get("curValue"); |
|
|
|
|
if (meterLastData == null) { |
|
|
|
|
meterLastData = new String[meterListData.size()]; |
|
|
|
|
meterLastData = new String[meterCurStr.length]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -523,13 +526,24 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
copLastMap[i] = lastCop; |
|
|
|
|
yoyMap[i] = yoy; |
|
|
|
|
} |
|
|
|
|
energyConsumptionDTO.setData(Arrays.asList( |
|
|
|
|
new HashMap<String, Object>() {{ |
|
|
|
|
put("curValue", copMap); |
|
|
|
|
put("lastValue", copLastMap); |
|
|
|
|
put("yoy", yoyMap); |
|
|
|
|
}} |
|
|
|
|
)); |
|
|
|
|
// energyConsumptionDTO.setData(Arrays.asList(
|
|
|
|
|
// new HashMap<String, Object>() {{
|
|
|
|
|
// put("curValue", copMap);
|
|
|
|
|
// put("lastValue", copLastMap);
|
|
|
|
|
// put("yoy", yoyMap);
|
|
|
|
|
// }}
|
|
|
|
|
// ));
|
|
|
|
|
List<Map<String, Object>> listData = new ArrayList<>(); |
|
|
|
|
Map<String, Object> cur = new HashMap<>(); |
|
|
|
|
cur.put("curValue",copMap); |
|
|
|
|
listData.add(cur); |
|
|
|
|
Map<String, Object> last = new HashMap<>(); |
|
|
|
|
last.put("lastValue",copLastMap); |
|
|
|
|
listData.add(last); |
|
|
|
|
Map<String, Object> yoy = new HashMap<>(); |
|
|
|
|
yoy.put(type,yoyMap); |
|
|
|
|
listData.add(yoy); |
|
|
|
|
energyConsumptionDTO.setData(listData); |
|
|
|
|
} |
|
|
|
|
return AjaxResult.success(energyConsumptionDTO); |
|
|
|
|
} |
|
|
|
@ -543,7 +557,7 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
String deviceType = vo.getParamType(); |
|
|
|
|
if ("meter".equals(deviceType)) { |
|
|
|
|
deviceType = "5"; |
|
|
|
|
} else if ("cold".equals(deviceType)){ |
|
|
|
|
} else if ("cloud".equals(deviceType)){ |
|
|
|
|
deviceType = "6"; |
|
|
|
|
} |
|
|
|
|
// 判断查询时间类型是month,year
|
|
|
|
@ -575,26 +589,26 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
consumptionAnalyzeEntities = energyMapper.queryManyTableMom(vo.getStartTime(), vo.getEndTime(), startTime, endTime, tableName1, tableName2, getTimeLen(vo.getTimeType()), deviceType, vo.getTimeType(), vo.getSystemType()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return getConsumptionDTOHttpResult(consumptionAnalyzeEntities, "mom"); |
|
|
|
|
return getConsumptionDTOHttpResult(consumptionAnalyzeEntities, "mom", getTimeLen(vo.getTimeType())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private AjaxResult calcCopMomData(EnergyConsumptionVO vo) { |
|
|
|
|
// 获取冷量读数
|
|
|
|
|
vo.setParamType("cloud"); |
|
|
|
|
vo.setParamType("6"); |
|
|
|
|
AjaxResult cloudData = mom(vo); |
|
|
|
|
EnergyConsumptionDTO cloudEnergyData = (EnergyConsumptionDTO) cloudData.get("data"); |
|
|
|
|
if (cloudEnergyData == null) { |
|
|
|
|
return AjaxResult.error(); |
|
|
|
|
} |
|
|
|
|
// 获取电量读数
|
|
|
|
|
vo.setParamType("meter"); |
|
|
|
|
vo.setParamType("5"); |
|
|
|
|
AjaxResult meterData = mom(vo); |
|
|
|
|
EnergyConsumptionDTO meterEnergyData = (EnergyConsumptionDTO) meterData.get("data"); |
|
|
|
|
if (meterEnergyData == null) { |
|
|
|
|
return AjaxResult.error(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return getEnergyConsumptionDTOHttpResult(meterEnergyData, cloudEnergyData); |
|
|
|
|
return getEnergyConsumptionDTOHttpResult(meterEnergyData, cloudEnergyData, "mom"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -605,13 +619,17 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
List<Future<Map<String, Object>>> futures = new ArrayList<>(); |
|
|
|
|
futures.add(executor.submit(() -> { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("yoy", yoy(vo)); |
|
|
|
|
EnergyConsumptionVO vo1 = new EnergyConsumptionVO(); |
|
|
|
|
BeanUtils.copyProperties(vo, vo1); |
|
|
|
|
map.put("yoy", yoy(vo1)); |
|
|
|
|
latch.countDown(); |
|
|
|
|
return map; |
|
|
|
|
})); |
|
|
|
|
futures.add(executor.submit(() -> { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("mom", mom(vo)); |
|
|
|
|
EnergyConsumptionVO vo1 = new EnergyConsumptionVO(); |
|
|
|
|
BeanUtils.copyProperties(vo, vo1); |
|
|
|
|
map.put("mom", mom(vo1)); |
|
|
|
|
latch.countDown(); |
|
|
|
|
return map; |
|
|
|
|
})); |
|
|
|
@ -681,7 +699,7 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
return AjaxResult.success(null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static AjaxResult getConsumptionDTOHttpResult(List<ConsumptionAnalyze> consumptionAnalyzeEntities, String compareType) { |
|
|
|
|
private static AjaxResult getConsumptionDTOHttpResult(List<ConsumptionAnalyze> consumptionAnalyzeEntities, String compareType, String len) { |
|
|
|
|
EnergyConsumptionDTO energyConsumptionDTO = new EnergyConsumptionDTO(); |
|
|
|
|
if (null == consumptionAnalyzeEntities || consumptionAnalyzeEntities.size() == 0) { |
|
|
|
|
return AjaxResult.success(energyConsumptionDTO); |
|
|
|
@ -701,7 +719,7 @@ public class EnergyServiceImpl implements IEnergyService {
|
|
|
|
|
if ("mom".equalsIgnoreCase(compareType)) { |
|
|
|
|
yoyValue[i] = entity.getMom(); |
|
|
|
|
} |
|
|
|
|
timeStrArr[i] = entity.getTimeStr(); |
|
|
|
|
timeStrArr[i] = entity.getTimeStr().substring(0, Integer.parseInt(len)); |
|
|
|
|
} |
|
|
|
|
energyConsumptionDTO.setTitles(titleArr); |
|
|
|
|
energyConsumptionDTO.setTimes(timeStrArr); |
|
|
|
|