|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.hnac.hzims.bigmodel.interactive.service.impl; |
|
|
|
package com.hnac.hzims.bigmodel.interactive.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.constants.DataMethodEnum; |
|
|
@ -17,8 +18,10 @@ import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
|
|
|
import org.springblade.core.log.logger.BladeLogger; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
@ -40,11 +43,13 @@ import java.util.stream.Collectors; |
|
|
|
public class AnalyseDataServiceImpl implements IAnalyseDataService { |
|
|
|
public class AnalyseDataServiceImpl implements IAnalyseDataService { |
|
|
|
|
|
|
|
|
|
|
|
private final DeviceDataClient deviceDataClient; |
|
|
|
private final DeviceDataClient deviceDataClient; |
|
|
|
|
|
|
|
private final BladeLogger logger; |
|
|
|
public static final int DATA_COUNT_MAX = 8000; |
|
|
|
public static final int DATA_COUNT_MAX = 8000; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) { |
|
|
|
public ExtraVO getHistoryData(HistoryDataSearchVO searchVO) { |
|
|
|
if(DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) { |
|
|
|
if(Func.isEmpty(searchVO.getDataType()) || StringUtil.isBlank(searchVO.getDataType()) |
|
|
|
|
|
|
|
|| DataMethodEnum.USUAL.getMethod().equals(searchVO.getMethod())) { |
|
|
|
searchVO.setDataType(DateEnum.SECOND.getDateType()); |
|
|
|
searchVO.setDataType(DateEnum.SECOND.getDateType()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 聚合数据方式处理
|
|
|
|
// 聚合数据方式处理
|
|
|
@ -52,12 +57,11 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { |
|
|
|
searchVO.setDataType(dateEnum.getDateType()); |
|
|
|
searchVO.setDataType(dateEnum.getDateType()); |
|
|
|
// 获取最适配时间段
|
|
|
|
// 获取最适配时间段
|
|
|
|
DateEnum adapterDate = this.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); |
|
|
|
DateEnum adapterDate = this.getDateEnumByDuration(searchVO.getStartTime(), searchVO.getEndTime(), dateEnum); |
|
|
|
|
|
|
|
String note = adapterDate.getDateType().equals(searchVO.getDataType()) ? "" : "(由于数据量过大,只能帮您" + adapterDate.getDateType() + "查询)"; |
|
|
|
searchVO.setDataType(adapterDate.getDateType()); |
|
|
|
searchVO.setDataType(adapterDate.getDateType()); |
|
|
|
String label = "根据数据量匹配到的取数规则为:" + adapterDate.getDateType() + "查询,查询结果如下:"; |
|
|
|
|
|
|
|
ExtraVO extraVO = new ExtraVO(); |
|
|
|
ExtraVO extraVO = new ExtraVO(); |
|
|
|
extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); |
|
|
|
extraVO.setType(FuncRouteEnum.HISTORY_DATA.getType().getType()); |
|
|
|
extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode()); |
|
|
|
extraVO.setFuncCode(FuncRouteEnum.HISTORY_DATA.getFuncCode()); |
|
|
|
extraVO.setLabel(label); |
|
|
|
|
|
|
|
Map<String,Object> params = new HashMap<>(1); |
|
|
|
Map<String,Object> params = new HashMap<>(1); |
|
|
|
ReductionDataVO dataVO = this.getPolymerizationData(searchVO); |
|
|
|
ReductionDataVO dataVO = this.getPolymerizationData(searchVO); |
|
|
|
List<Map> datalist = dataVO.getDataList().stream().map(m -> { |
|
|
|
List<Map> datalist = dataVO.getDataList().stream().map(m -> { |
|
|
@ -65,6 +69,15 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { |
|
|
|
m.remove(searchVO.getSignage()); |
|
|
|
m.remove(searchVO.getSignage()); |
|
|
|
return m; |
|
|
|
return m; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
DataMethodEnum enumByMethod = DataMethodEnum.getEnumByMethod(searchVO.getMethod()); |
|
|
|
|
|
|
|
String label = searchVO.getStationName() + "_" |
|
|
|
|
|
|
|
+ searchVO.getDeviceName() + "_" |
|
|
|
|
|
|
|
+ dataVO.getFieldMap().get(searchVO.getSignage()) + "_" |
|
|
|
|
|
|
|
+ adapterDate.getName() |
|
|
|
|
|
|
|
+ enumByMethod.getMethod() |
|
|
|
|
|
|
|
+ note |
|
|
|
|
|
|
|
+ ":"; |
|
|
|
|
|
|
|
extraVO.setLabel(label); |
|
|
|
params.put("data",datalist); |
|
|
|
params.put("data",datalist); |
|
|
|
params.put("deviceName",searchVO.getDeviceName()); |
|
|
|
params.put("deviceName",searchVO.getDeviceName()); |
|
|
|
params.put("attrName",dataVO.getFieldMap().get(searchVO.getSignage())); |
|
|
|
params.put("attrName",dataVO.getFieldMap().get(searchVO.getSignage())); |
|
|
@ -92,6 +105,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { |
|
|
|
dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); |
|
|
|
dataDTO.setSaveTimeType(dateEnum.getSaveTimeType()); |
|
|
|
dataDTO.setTimeInterval(1); |
|
|
|
dataDTO.setTimeInterval(1); |
|
|
|
dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); |
|
|
|
dataDTO.setDtos(Lists.newArrayList(reductionAttrData)); |
|
|
|
|
|
|
|
logger.info("interactive:getPolymerizationData","config传参为:" + JSON.toJSONString(dataDTO)); |
|
|
|
Result<ReductionDataVO> dataVO = deviceDataClient.pageDeviceCodeAndSignages(dataDTO); |
|
|
|
Result<ReductionDataVO> dataVO = deviceDataClient.pageDeviceCodeAndSignages(dataDTO); |
|
|
|
Assert.isTrue(dataVO.isSuccess(),() -> { |
|
|
|
Assert.isTrue(dataVO.isSuccess(),() -> { |
|
|
|
throw new ServiceException("聚合历史数据查询失败!"); |
|
|
|
throw new ServiceException("聚合历史数据查询失败!"); |
|
|
|