|
|
|
@ -3,6 +3,7 @@ package com.thing.qingyuan.board.service.impl; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.thing.common.core.exception.SysException; |
|
|
|
import com.thing.common.core.utils.DateTimeUtils; |
|
|
|
import com.thing.common.data.tskv.TsKvDTO; |
|
|
|
import com.thing.common.tskv.service.TsKvService; |
|
|
|
@ -49,14 +50,43 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
Long dayStartTimeStamp = DateTimeUtils.dateToStamp(dayStartTime); |
|
|
|
//当月结束时间 |
|
|
|
Long dayEndTimeStamp = DateTimeUtils.dateToStamp(dayEndTime); |
|
|
|
//获取租户编码 |
|
|
|
Long realTenantCode = UserContext.getRealTenantCode(); |
|
|
|
List<TsKvDTO> attr = tsKvService.findTsKvByCodeAndAttr("CO_" + realTenantCode, "A16", dayStartTimeStamp, dayEndTimeStamp, true); |
|
|
|
// 检查数据是否为空 |
|
|
|
if (CollectionUtil.isEmpty(attr)) { |
|
|
|
// 如果没有数据,返回错误 |
|
|
|
throw new SysException("没有找到电力负荷数据"); |
|
|
|
} |
|
|
|
for (TsKvDTO kv : attr) { |
|
|
|
// 获取时间戳 |
|
|
|
Long timestamp = kv.getTs(); |
|
|
|
// 电力负荷值 |
|
|
|
String value = kv.getVal(); |
|
|
|
// 将时间戳转换为日期格式 |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
String timestampStr = sdf.format(new Date(timestamp)); |
|
|
|
// 填充电力负荷数据 |
|
|
|
EnergyDataAnalyseDetailDTO detailDTO = new EnergyDataAnalyseDetailDTO(); |
|
|
|
// 设置时间 |
|
|
|
detailDTO.setDate(timestampStr); |
|
|
|
// 设置电力负荷值 |
|
|
|
detailDTO.setValue(new BigDecimal(value)); |
|
|
|
currentMonthData.add(detailDTO); |
|
|
|
} |
|
|
|
result.setCurrentMonthData(currentMonthData); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 参数格式:{"总用电": "G01","总用水": "G03","总蒸汽": "G02","总压缩空气": "D_V0000151_1"} |
|
|
|
*/ |
|
|
|
String cqStr = sysParamsService.getValue("BOARD_TOTAL_ENERGY"); |
|
|
|
Map<String, String> codeMap = JSONObject.parseObject(cqStr, Map.class); |
|
|
|
List<String> keys = new ArrayList<>(); |
|
|
|
keys.add("A16"); |
|
|
|
|
|
|
|
|
|
|
|
// /** |
|
|
|
// * 参数格式:{"总用电": "G01","总用水": "G03","总蒸汽": "G02","总压缩空气": "D_V0000151_1"} |
|
|
|
// */ |
|
|
|
// String cqStr = sysParamsService.getValue("BOARD_TOTAL_ENERGY"); |
|
|
|
// Map<String, String> codeMap = JSONObject.parseObject(cqStr, Map.class); |
|
|
|
// List<String> keys = new ArrayList<>(); |
|
|
|
// keys.add("A16"); |
|
|
|
//注释说明:获取电表在所传时间内A16属性的数据,该接口传的是天的时间,A16表示电负荷, todo |
|
|
|
// ThingsDTO thingsDTO = thingsService.getThingsByCode(codeMap.get("总用电")); |
|
|
|
// if(thingsDTO==null && StringUtils.isBlank(thingsDTO.getEntityId())){ |
|
|
|
@ -73,9 +103,7 @@ public class BoardNewServiceImpl implements BoardNewService { |
|
|
|
// currentMonthData.add(energyDataAnalyseDetailDTO); |
|
|
|
// } |
|
|
|
// } |
|
|
|
result.setCurrentMonthData(currentMonthData); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|