|
|
@ -1,5 +1,6 @@ |
|
|
package com.dongjian.dashboard.back.service.impl; |
|
|
package com.dongjian.dashboard.back.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.dongjian.dashboard.back.bo.LatestValueBO; |
|
|
import com.dongjian.dashboard.back.common.Constants; |
|
|
import com.dongjian.dashboard.back.common.Constants; |
|
|
import com.dongjian.dashboard.back.common.language.msg.MsgLanguageChange; |
|
|
import com.dongjian.dashboard.back.common.language.msg.MsgLanguageChange; |
|
|
import com.dongjian.dashboard.back.common.response.PageInfo; |
|
|
import com.dongjian.dashboard.back.common.response.PageInfo; |
|
|
@ -14,10 +15,13 @@ import com.dongjian.dashboard.back.easyexcel.SecondsToHMSConverter; |
|
|
import com.dongjian.dashboard.back.model.*; |
|
|
import com.dongjian.dashboard.back.model.*; |
|
|
import com.dongjian.dashboard.back.service.DeviceDataBaStatusService; |
|
|
import com.dongjian.dashboard.back.service.DeviceDataBaStatusService; |
|
|
import com.dongjian.dashboard.back.service.common.CommonOpt; |
|
|
import com.dongjian.dashboard.back.service.common.CommonOpt; |
|
|
|
|
|
import com.dongjian.dashboard.back.util.DateUtil; |
|
|
|
|
|
import com.dongjian.dashboard.back.util.redis.RedisUtil; |
|
|
import com.dongjian.dashboard.back.vo.data.DeviceAccumulateData; |
|
|
import com.dongjian.dashboard.back.vo.data.DeviceAccumulateData; |
|
|
import com.dongjian.dashboard.back.vo.data.DeviceBaStatusData; |
|
|
import com.dongjian.dashboard.back.vo.data.DeviceBaStatusData; |
|
|
import com.dongjian.dashboard.back.vo.data.DeviceMeasureData; |
|
|
import com.dongjian.dashboard.back.vo.data.DeviceMeasureData; |
|
|
import com.dongjian.dashboard.back.vo.device.LineData; |
|
|
import com.dongjian.dashboard.back.vo.device.LineData; |
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
@ -59,6 +63,8 @@ public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService |
|
|
private MsgLanguageChange msgLanguageChange; |
|
|
private MsgLanguageChange msgLanguageChange; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private CommonOpt commonOpt; |
|
|
private CommonOpt commonOpt; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -183,6 +189,27 @@ public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService |
|
|
public SimpleDataResponse<List<LineData>> getLineData(Integer searchType, LineDataSearchParams lineDataSearchParams, Long companyId, Long userId, Integer languageType) { |
|
|
public SimpleDataResponse<List<LineData>> getLineData(Integer searchType, LineDataSearchParams lineDataSearchParams, Long companyId, Long userId, Integer languageType) { |
|
|
List<LineData> lineDataList = new ArrayList<>(); |
|
|
List<LineData> lineDataList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
LineData lineData = new LineData(); |
|
|
|
|
|
lineData.setAttrCode(lineDataSearchParams.getAttrCodeList()[0]); |
|
|
|
|
|
|
|
|
|
|
|
List<Object> yCommon = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
//** 获取昨日最新数据 **//
|
|
|
|
|
|
String redisKey = Constants.REDIS_BA_STATUS_LATEST_VALUE + DateUtil.getYesterdayInJapan(); |
|
|
|
|
|
Object cacheLastValue = redisUtil.HGet(redisKey, lineDataSearchParams.getDeviceId().toLowerCase()); |
|
|
|
|
|
if (null != cacheLastValue) { |
|
|
|
|
|
try { |
|
|
|
|
|
LatestValueBO latestValueBO = objectMapper.readValue(cacheLastValue.toString(), LatestValueBO.class); |
|
|
|
|
|
String dateFormatted = Instant.ofEpochMilli(latestValueBO.getUpdateTs()) |
|
|
|
|
|
.atZone(Constants.ZONE_TOKYO) |
|
|
|
|
|
.format(Constants.FORMATTER_YMDHMS); |
|
|
|
|
|
lineData.getXData().add(dateFormatted); |
|
|
|
|
|
yCommon.add(latestValueBO.getValue()); |
|
|
|
|
|
} catch (JsonProcessingException e) { |
|
|
|
|
|
logger.error("LatestValueBO error", e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
DeviceInfoExample devExample = new DeviceInfoExample(); |
|
|
DeviceInfoExample devExample = new DeviceInfoExample(); |
|
|
devExample.createCriteria() |
|
|
devExample.createCriteria() |
|
|
.andCompanyIdEqualTo(companyId) |
|
|
.andCompanyIdEqualTo(companyId) |
|
|
@ -208,8 +235,6 @@ public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService |
|
|
|
|
|
|
|
|
List<BaStatusHistory> result = baStatusHistoryMapperExt.selectByExample(bshExample); |
|
|
List<BaStatusHistory> result = baStatusHistoryMapperExt.selectByExample(bshExample); |
|
|
if (CollectionUtils.isNotEmpty(result)) { |
|
|
if (CollectionUtils.isNotEmpty(result)) { |
|
|
LineData lineData = new LineData(); |
|
|
|
|
|
List<Object> yCommon = new ArrayList<>(); |
|
|
|
|
|
for (BaStatusHistory item : result) { |
|
|
for (BaStatusHistory item : result) { |
|
|
String tsStr = item.getUpdateTs(); |
|
|
String tsStr = item.getUpdateTs(); |
|
|
if (tsStr == null || tsStr.isEmpty()) { |
|
|
if (tsStr == null || tsStr.isEmpty()) { |
|
|
@ -232,12 +257,10 @@ public class DeviceDataBaStatusServiceImpl implements DeviceDataBaStatusService |
|
|
lineData.getXData().add(formatted); |
|
|
lineData.getXData().add(formatted); |
|
|
yCommon.add(item.getIsRunning()); |
|
|
yCommon.add(item.getIsRunning()); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
lineData.setAttrCode(lineDataSearchParams.getAttrCodeList()[0]); |
|
|
|
|
|
lineData.getYData().put("common", yCommon); |
|
|
lineData.getYData().put("common", yCommon); |
|
|
|
|
|
|
|
|
lineDataList.add(lineData); |
|
|
lineDataList.add(lineData); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return SimpleDataResponse.success(lineDataList); |
|
|
return SimpleDataResponse.success(lineDataList); |
|
|
} |
|
|
} |
|
|
|