package com.gkhy.testFourierSpecialGasMonitor.service.impl;
|
|
import com.gkhy.testFourierSpecialGasMonitor.commons.domain.Result;
|
import com.gkhy.testFourierSpecialGasMonitor.commons.domain.SearchResult;
|
import com.gkhy.testFourierSpecialGasMonitor.commons.enums.ResultCode;
|
import com.gkhy.testFourierSpecialGasMonitor.commons.exception.BusinessException;
|
import com.gkhy.testFourierSpecialGasMonitor.commons.model.PageQuery;
|
import com.gkhy.testFourierSpecialGasMonitor.commons.utils.BeanCopyUtils;
|
import com.gkhy.testFourierSpecialGasMonitor.entity.*;
|
import com.gkhy.testFourierSpecialGasMonitor.entity.query.GasAtmospherePageQuery;
|
import com.gkhy.testFourierSpecialGasMonitor.entity.query.GasFluxPageQuery;
|
import com.gkhy.testFourierSpecialGasMonitor.entity.query.GasPageQuery;
|
import com.gkhy.testFourierSpecialGasMonitor.entity.req.*;
|
import com.gkhy.testFourierSpecialGasMonitor.entity.resp.*;
|
import com.gkhy.testFourierSpecialGasMonitor.repository.GasCategoryConfigurationRepository;
|
import com.gkhy.testFourierSpecialGasMonitor.service.*;
|
import com.gkhy.testFourierSpecialGasMonitor.utils.AreaHandle;
|
import com.gkhy.testFourierSpecialGasMonitor.utils.PositionHandle;
|
import io.micrometer.core.instrument.util.StringUtils;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Page;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
|
import java.lang.reflect.Field;
|
import java.time.LocalDateTime;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* @author Mr.huang
|
* @decription
|
* @date 2023/8/10 9:16
|
*/
|
@Service
|
public class MonitorDataServiceImpl implements MonitorDataService {
|
|
private LocalDateTime zeroTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
private LocalDateTime nowTime = LocalDateTime.now();
|
|
@Autowired
|
private GasCategoryService gasCategoryService;
|
|
@Autowired
|
private GasFluxService gasFluxService;
|
|
@Autowired
|
private RegionService regionService;
|
|
@Autowired
|
private GasCategoryConfigurationRepository gasCategoryConfigurationRepository;
|
|
@Autowired
|
private GasConcentrationService gasConcentrationService;
|
|
@Override
|
public Result gasLineChart(GasLineChartReqDTO reqDto) {
|
Result success = Result.success();
|
if (reqDto == null || reqDto.getGasName() == null)
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空");
|
LocalDateTime startTime = reqDto.getStartTime();
|
LocalDateTime endTime = reqDto.getEndTime();
|
if (startTime == null || endTime == null){
|
startTime = zeroTime;
|
endTime = nowTime;
|
}
|
List<GasConcentration> gasConcentrationList = gasConcentrationService.listDatabyTimeSlotAndPosition(startTime,endTime,reqDto.getPosition());
|
if (CollectionUtils.isEmpty(gasConcentrationList))
|
return success;
|
GasCategory gasCategory = gasCategoryService.findById(reqDto.getGasName());
|
if (gasCategory == null){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"暂无该气体实时数据");
|
}
|
String fileNamePrefix = "gasValue";
|
String fileName = fileNamePrefix + reqDto.getGasName();
|
if (reqDto.getGasName() < 10){
|
fileName = fileNamePrefix +"0"+ reqDto.getGasName();
|
}
|
String fileNameTemp = fileName;
|
List<GasLineChartRespDTO> respDTOS = gasConcentrationList.stream().map(gasConcentration -> {
|
GasLineChartRespDTO gasLineChartRespDTO = new GasLineChartRespDTO();
|
BeanUtils.copyProperties(gasCategory, gasLineChartRespDTO);
|
BeanUtils.copyProperties(gasConcentration, gasLineChartRespDTO);
|
|
if (reqDto.getPosition()!=null && reqDto.getGasName()!=null){
|
GasCategoryConfiguration byGasCateGoryIdAndOrientation = gasCategoryConfigurationRepository.findByGasCategoryIdAndOrientation(reqDto.getGasName(),reqDto.getPosition());
|
GasCategoryConfigurationRespDTO gasCategoryConfigurationRespDTO = new GasCategoryConfigurationRespDTO();
|
if (byGasCateGoryIdAndOrientation!=null){
|
BeanUtils.copyProperties(byGasCateGoryIdAndOrientation,gasCategoryConfigurationRespDTO);
|
}
|
gasLineChartRespDTO.setGasCategoryConfigurationRespDTO(gasCategoryConfigurationRespDTO);
|
} else if (reqDto.getPosition()!=null){
|
GasCategoryConfiguration byOrientation = gasCategoryConfigurationRepository.findByOrientation(reqDto.getPosition());
|
GasCategoryConfigurationRespDTO gasCategoryConfigurationRespDTO = new GasCategoryConfigurationRespDTO();
|
if (byOrientation!=null){
|
BeanUtils.copyProperties(byOrientation,gasCategoryConfigurationRespDTO);
|
}
|
gasLineChartRespDTO.setGasCategoryConfigurationRespDTO(gasCategoryConfigurationRespDTO);
|
}
|
|
gasLineChartRespDTO.setGasName(reqDto.getGasName());
|
Field[] fields = gasConcentration.getClass().getDeclaredFields();
|
for (Field field : fields) {
|
field.setAccessible(true); // 设置字段可访问,即使是私有字段
|
if (field.getName().equals(fileNameTemp)) {
|
Double value = null;
|
try {
|
value = (Double) field.get(gasConcentration);
|
gasLineChartRespDTO.setGasValue(value);
|
} catch (IllegalAccessException e) {
|
logger.info("【警告】气体浓度折线图反射获取气体浓度失败");
|
}
|
}
|
}
|
return gasLineChartRespDTO;
|
}).collect(Collectors.toList());
|
success.setData(respDTOS);
|
return success;
|
}
|
|
@Override
|
public Result gasPage(PageQuery<GasPageQuery> pageQuery) {
|
if (pageQuery == null || pageQuery.getPageIndex() == null || pageQuery.getPageSize() == null){
|
throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_NULL,"分页参数不能为空");
|
}
|
if (pageQuery == null || pageQuery.getSearchParams() == null || pageQuery.getSearchParams().getGasName() == null)
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空");
|
GasPageQuery searchParams = pageQuery.getSearchParams();
|
Integer gasName = searchParams.getGasName();
|
LocalDateTime startTime = searchParams.getStartTime();
|
LocalDateTime endTime = searchParams.getEndTime();
|
if (startTime == null || endTime == null){
|
searchParams.setStartTime(zeroTime);
|
searchParams.setEndTime(nowTime);
|
}
|
|
SearchResult<List<GasPageRespDTO>> searchResult = new SearchResult<>();
|
searchResult.setPageIndex(pageQuery.getPageIndex());
|
searchResult.setPageSize(pageQuery.getPageSize());
|
searchResult.setSuccess();
|
Page<GasConcentration> pageResult = gasConcentrationService.listDatabyTimeSlotAndPositionAndPage(pageQuery);
|
if (CollectionUtils.isEmpty(pageResult.getContent()))
|
return searchResult;
|
searchResult.setTotal(pageResult.getTotalElements());
|
searchResult.setPages(pageResult.getTotalPages());
|
GasCategory gasCategory = gasCategoryService.findById(gasName);
|
if (gasCategory == null){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"暂无该气体实时数据");
|
}
|
String fileNamePrefix = "gasValue";
|
String fileName = fileNamePrefix + gasName;
|
if (gasName < 10){
|
fileName = fileNamePrefix +"0"+ gasName;
|
}
|
String fileNameTemp = fileName;
|
List<GasPageRespDTO> respDTOS = pageResult.getContent().stream().map(gasConcentration -> {
|
GasPageRespDTO gasLineChartRespDTO = new GasPageRespDTO();
|
BeanUtils.copyProperties(gasCategory, gasLineChartRespDTO);
|
BeanUtils.copyProperties(gasConcentration, gasLineChartRespDTO);
|
if (searchParams.getPosition()!=null && searchParams.getGasName()!=null){
|
GasCategoryConfiguration byGasCateGoryIdAndOrientation = gasCategoryConfigurationRepository.findByGasCategoryIdAndOrientation(searchParams.getGasName(),searchParams.getPosition());
|
GasCategoryConfigurationRespDTO gasCategoryConfigurationRespDTO = new GasCategoryConfigurationRespDTO();
|
if(byGasCateGoryIdAndOrientation!=null){
|
BeanUtils.copyProperties(byGasCateGoryIdAndOrientation,gasCategoryConfigurationRespDTO);
|
}
|
gasLineChartRespDTO.setGasCategoryConfigurationRespDTO(gasCategoryConfigurationRespDTO);
|
} else if (searchParams.getPosition()!=null){
|
GasCategoryConfiguration byOrientation = gasCategoryConfigurationRepository.findByOrientation(searchParams.getPosition());
|
GasCategoryConfigurationRespDTO gasCategoryConfigurationRespDTO = new GasCategoryConfigurationRespDTO();
|
if(byOrientation!=null){
|
BeanUtils.copyProperties(byOrientation,gasCategoryConfigurationRespDTO);
|
}
|
gasLineChartRespDTO.setGasCategoryConfigurationRespDTO(gasCategoryConfigurationRespDTO);
|
}
|
gasLineChartRespDTO.setGasName(gasName);
|
Field[] fields = gasConcentration.getClass().getDeclaredFields();
|
for (Field field : fields) {
|
field.setAccessible(true); // 设置字段可访问,即使是私有字段
|
if (field.getName().equals(fileNameTemp)) {
|
Double value = null;
|
try {
|
value = (Double) field.get(gasConcentration);
|
gasLineChartRespDTO.setGasValue(value);
|
} catch (IllegalAccessException e) {
|
logger.info("【警告】气体浓度分页-反射获取气体浓度失败");
|
}
|
}
|
}
|
return gasLineChartRespDTO;
|
}).collect(Collectors.toList());
|
searchResult.setData(respDTOS);
|
return searchResult;
|
}
|
|
@Override
|
public Result gasFluxLineChart(GasFluxLineChartReqDTO reqDto) {
|
Result success = Result.success();
|
if (reqDto == null || reqDto.getGasName() == null)
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空");
|
LocalDateTime startTime = reqDto.getStartTime();
|
LocalDateTime endTime = reqDto.getEndTime();
|
if (startTime == null || endTime == null){
|
startTime = zeroTime;
|
endTime = nowTime;
|
}
|
List<GasFlux> gasFluxes = gasFluxService.listDatabyTimeSlotAndAreaId(startTime,endTime,reqDto.getAreaId());
|
if (CollectionUtils.isEmpty(gasFluxes))
|
return success;
|
GasCategory gasCategory = gasCategoryService.findById(reqDto.getGasName());
|
if (gasCategory == null){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"暂无该气体通量数据");
|
}
|
|
List<Region> regions = regionService.findAll();
|
if (CollectionUtils.isEmpty(regions)){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"无法获取区域信息");
|
}
|
Map<Integer, Region> regionMap = regions.stream().collect(Collectors.toMap(Region::getId, r -> r));
|
String fileNamePrefix = "gasValue";
|
String fileName = fileNamePrefix + reqDto.getGasName();
|
if (reqDto.getGasName() < 10){
|
fileName = fileNamePrefix +"0"+ reqDto.getGasName();
|
}
|
String fileNameTemp = fileName;
|
List<GasFluxLineChartRespDTO> respDTOS = gasFluxes.stream().map(gasFlux -> {
|
GasFluxLineChartRespDTO gasFluxLineChartRespDTO = new GasFluxLineChartRespDTO();
|
BeanUtils.copyProperties(gasCategory, gasFluxLineChartRespDTO);
|
BeanUtils.copyProperties(gasFlux, gasFluxLineChartRespDTO);
|
if (regionMap.get(gasFlux.getAreaId()) != null){
|
Region region = regionMap.get(gasFlux.getAreaId());
|
BeanUtils.copyProperties(region,gasFluxLineChartRespDTO,"name");
|
gasFluxLineChartRespDTO.setRegionName(region.getName());
|
}
|
gasFluxLineChartRespDTO.setGasName(reqDto.getGasName());
|
Field[] fields = gasFlux.getClass().getDeclaredFields();
|
for (Field field : fields) {
|
field.setAccessible(true); // 设置字段可访问,即使是私有字段
|
if (field.getName().equals(fileNameTemp)) {
|
Double value = null;
|
try {
|
value = (Double) field.get(gasFlux);
|
gasFluxLineChartRespDTO.setGasValue(value);
|
} catch (IllegalAccessException e) {
|
logger.info("【警告】气体通量折线图反射获取气体浓度失败");
|
}
|
}
|
}
|
return gasFluxLineChartRespDTO;
|
}).collect(Collectors.toList());
|
success.setData(respDTOS);
|
return success;
|
}
|
|
@Override
|
public Result gasFluxPage(PageQuery<GasFluxPageQuery> pageQuery) {
|
if (pageQuery == null || pageQuery.getPageIndex() == null || pageQuery.getPageSize() == null){
|
throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_NULL,"分页参数不能为空");
|
}
|
if (pageQuery == null || pageQuery.getSearchParams() == null || pageQuery.getSearchParams().getGasName() == null)
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空");
|
GasFluxPageQuery searchParams = pageQuery.getSearchParams();
|
Integer gasName = searchParams.getGasName();
|
LocalDateTime startTime = searchParams.getStartTime();
|
LocalDateTime endTime = searchParams.getEndTime();
|
if (startTime == null || endTime == null){
|
searchParams.setStartTime(zeroTime);
|
searchParams.setEndTime(nowTime);
|
}
|
SearchResult<List<GasFluxPageRespDTO>> searchResult = new SearchResult<>();
|
searchResult.setPageIndex(pageQuery.getPageIndex());
|
searchResult.setPageSize(pageQuery.getPageSize());
|
searchResult.setSuccess();
|
Page<GasFlux> pageResult = gasFluxService.listDatabyTimeSlotAndPage(pageQuery);
|
if (CollectionUtils.isEmpty(pageResult.getContent()))
|
return searchResult;
|
searchResult.setTotal(pageResult.getTotalElements());
|
searchResult.setPages(pageResult.getTotalPages());
|
GasCategory gasCategory = gasCategoryService.findById(gasName);
|
if (gasCategory == null){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"暂无该气体实时数据");
|
}
|
List<Region> regions = regionService.findAll();
|
if (CollectionUtils.isEmpty(regions)){
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"无法获取区域信息");
|
}
|
Map<Integer, Region> regionMap = regions.stream().collect(Collectors.toMap(Region::getId, r -> r));
|
String fileNamePrefix = "gasValue";
|
String fileName = fileNamePrefix + gasName;
|
if (gasName < 10){
|
fileName = fileNamePrefix +"0"+ gasName;
|
}
|
String fileNameTemp = fileName;
|
List<GasFluxPageRespDTO> respDTOS = pageResult.getContent().stream().map(gasFlux -> {
|
GasFluxPageRespDTO gasFluxPageRespDTO = new GasFluxPageRespDTO();
|
BeanUtils.copyProperties(gasCategory, gasFluxPageRespDTO);
|
BeanUtils.copyProperties(gasFlux, gasFluxPageRespDTO);
|
if (regionMap.get(gasFlux.getAreaId()) != null){
|
Region region = regionMap.get(gasFlux.getAreaId());
|
BeanUtils.copyProperties(region,gasFluxPageRespDTO,"name");
|
gasFluxPageRespDTO.setRegionName(region.getName());
|
}
|
gasFluxPageRespDTO.setGasName(pageQuery.getSearchParams().getGasName());
|
Field[] fields = gasFlux.getClass().getDeclaredFields();
|
for (Field field : fields) {
|
field.setAccessible(true); // 设置字段可访问,即使是私有字段
|
if (field.getName().equals(fileNameTemp)) {
|
Double value = null;
|
try {
|
value = (Double) field.get(gasFlux);
|
gasFluxPageRespDTO.setGasValue(value);
|
} catch (IllegalAccessException e) {
|
logger.info("【警告】气体通量分页数据-反射获取气体浓度失败");
|
}
|
}
|
}
|
return gasFluxPageRespDTO;
|
}).collect(Collectors.toList());
|
searchResult.setData(respDTOS);
|
return searchResult;
|
}
|
|
@Override
|
public Result gasAtmosphereLineChart(GasAtmosphereLineChartReqDTO reqDto) {
|
Result success = Result.success();
|
if (reqDto == null || StringUtils.isEmpty(reqDto.getAtmosphere()))
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空");
|
LocalDateTime startTime = reqDto.getStartTime();
|
LocalDateTime endTime = reqDto.getEndTime();
|
if (startTime == null || endTime == null){
|
startTime = zeroTime;
|
endTime = nowTime;
|
}
|
List<GasConcentration> gasConcentrations = gasConcentrationService.listDatabyTimeSlot(startTime,endTime);
|
if (CollectionUtils.isEmpty(gasConcentrations))
|
return success;
|
List<GasAtmosphereLineChartRespDTO> respDTOS = gasConcentrations.stream().map(gasConcentration -> {
|
GasAtmosphereLineChartRespDTO gasAtmosphereLineChartRespDTO = new GasAtmosphereLineChartRespDTO();
|
gasAtmosphereLineChartRespDTO.setTime(gasConcentration.getTime());
|
Field[] fields = gasConcentration.getClass().getDeclaredFields();
|
for (Field field : fields) {
|
field.setAccessible(true);
|
if (field.getName().equals(reqDto.getAtmosphere())) {
|
try {
|
Object value = field.get(gasConcentration);
|
gasAtmosphereLineChartRespDTO.setValue(value);
|
} catch (IllegalAccessException e) {
|
logger.info("【警告】气象折线图反射获取气体浓度失败");
|
}
|
}
|
}
|
return gasAtmosphereLineChartRespDTO;
|
}).collect(Collectors.toList());
|
success.setData(respDTOS);
|
return success;
|
}
|
|
|
@Override
|
public Result gasAtmospherePage(PageQuery<GasAtmospherePageQuery> pageQuery) {
|
if (pageQuery == null || pageQuery.getPageIndex() == null || pageQuery.getPageSize() == null){
|
throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_NULL,"分页参数不能为空");
|
}
|
if (pageQuery == null || pageQuery.getSearchParams() == null || StringUtils.isEmpty(pageQuery.getSearchParams().getAtmosphere()))
|
throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空");
|
GasAtmospherePageQuery searchParams = pageQuery.getSearchParams();
|
String atmosphere = searchParams.getAtmosphere();
|
LocalDateTime startTime = searchParams.getStartTime();
|
LocalDateTime endTime = searchParams.getEndTime();
|
if (startTime == null || endTime == null){
|
searchParams.setStartTime(zeroTime);
|
searchParams.setEndTime(nowTime);
|
}
|
|
SearchResult<List<GasAtmospherePageRespDTO>> searchResult = new SearchResult<>();
|
searchResult.setPageIndex(pageQuery.getPageIndex());
|
searchResult.setPageSize(pageQuery.getPageSize());
|
searchResult.setSuccess();
|
Page<GasConcentration> pageResult = gasConcentrationService.gasAtmospherePage(pageQuery);
|
if (CollectionUtils.isEmpty(pageResult.getContent()))
|
return searchResult;
|
searchResult.setTotal(pageResult.getTotalElements());
|
searchResult.setPages(pageResult.getTotalPages());
|
|
List<GasAtmospherePageRespDTO> respDTOS = pageResult.getContent().stream().map(gasConcentration -> {
|
GasAtmospherePageRespDTO gasAtmospherePageRespDTO = new GasAtmospherePageRespDTO();
|
gasAtmospherePageRespDTO.setTime(gasConcentration.getTime());
|
Field[] fields = gasConcentration.getClass().getDeclaredFields();
|
for (Field field : fields) {
|
field.setAccessible(true); // 设置字段可访问,即使是私有字段
|
if (field.getName().equals(atmosphere)) {
|
try {
|
Object value = field.get(gasConcentration);
|
gasAtmospherePageRespDTO.setValue(value);
|
} catch (IllegalAccessException e) {
|
logger.info("【警告】气象折线图反射获取气体浓度失败");
|
}
|
}
|
}
|
return gasAtmospherePageRespDTO;
|
}).collect(Collectors.toList());
|
searchResult.setData(respDTOS);
|
return searchResult;
|
}
|
|
@Override
|
public Result gasFluxExport(GasFluxExportBO gasFluxExportBO) {
|
|
Result<List<GasFluxExportDTO>> result = new Result<>();
|
|
List<GasFlux> gasFluxes = gasFluxService.gasFluxExport(gasFluxExportBO);
|
List<GasFluxExportDTO> exportLists = new ArrayList<>();
|
AreaHandle areaHandle = new AreaHandle();
|
for (GasFlux gasFlux : gasFluxes) {
|
GasFluxExportDTO gasFluxExportDTO = BeanCopyUtils.copyBean(gasFlux, GasFluxExportDTO.class);
|
gasFluxExportDTO.setGasName01("甲烷CH4");
|
gasFluxExportDTO.setGasName02("乙烷C2H6");
|
gasFluxExportDTO.setGasName03("丙烷C3H8");
|
gasFluxExportDTO.setGasName04("丁烷C4H10");
|
gasFluxExportDTO.setGasName05("硫化氢H2S");
|
gasFluxExportDTO.setGasName06("乙烯C2H4");
|
gasFluxExportDTO.setGasName07("异丁烷C4H10");
|
gasFluxExportDTO.setAreaId(areaHandle.areaHandleMethod(gasFlux.getAreaId()));
|
if (gasFluxExportBO.getCh4() == 0){
|
gasFluxExportDTO.setGasValue01(null);
|
}
|
if (gasFluxExportBO.getC2h6() == 0){
|
gasFluxExportDTO.setGasValue02(null);
|
}
|
if (gasFluxExportBO.getC3H8() == 0){
|
gasFluxExportDTO.setGasValue03(null);
|
}
|
if (gasFluxExportBO.getC4h101() == 0){
|
gasFluxExportDTO.setGasValue04(null);
|
}
|
if (gasFluxExportBO.getH2s() == 0){
|
gasFluxExportDTO.setGasValue05(null);
|
}
|
if (gasFluxExportBO.getC2h4() == 0){
|
gasFluxExportDTO.setGasValue06(null);
|
}
|
if (gasFluxExportBO.getC4h102() == 0){
|
gasFluxExportDTO.setGasValue07(null);
|
}
|
exportLists.add(gasFluxExportDTO);
|
}
|
|
//sql根据时间查所有,业务中处理数据项
|
|
|
result.setData(exportLists);
|
result.setCode(200);
|
result.setCount(exportLists.size());
|
result.setMsg("通量数据导出成功");
|
return result;
|
}
|
|
@Override
|
public Result gasConcentrationExport(GasConcentrationExportBO gasConcentrationExportBO) {
|
|
Result<List<GasConcentrationExportDTO>> result = new Result<>();
|
|
List<GasConcentration> gasConcentrationList = gasConcentrationService.gasConcentrationExport(gasConcentrationExportBO);
|
List<GasConcentrationExportDTO> exportLists = new ArrayList<>();
|
PositionHandle positionHandle = new PositionHandle();
|
|
for (GasConcentration gasConcentration : gasConcentrationList) {
|
GasConcentrationExportDTO gasConcentrationExportDTO = BeanCopyUtils.copyBean(gasConcentration, GasConcentrationExportDTO.class);
|
|
gasConcentrationExportDTO.setPosition(positionHandle.positionHandleMethod(gasConcentration.getPosition()));
|
gasConcentrationExportDTO.setGasName01("甲烷CH4");
|
gasConcentrationExportDTO.setGasName02("乙烷C2H6");
|
gasConcentrationExportDTO.setGasName03("丙烷C3H8");
|
gasConcentrationExportDTO.setGasName04("丁烷C4H10");
|
gasConcentrationExportDTO.setGasName05("硫化氢H2S");
|
gasConcentrationExportDTO.setGasName06("乙烯C2H4");
|
gasConcentrationExportDTO.setGasName07("异丁烷C4H10");
|
if (gasConcentrationExportBO.getCh4() == 0){
|
gasConcentrationExportDTO.setGasValue01(null);
|
}
|
if (gasConcentrationExportBO.getC2h6() == 0){
|
gasConcentrationExportDTO.setGasValue02(null);
|
}
|
if (gasConcentrationExportBO.getC3H8() == 0){
|
gasConcentrationExportDTO.setGasValue03(null);
|
}
|
if (gasConcentrationExportBO.getC4h101() == 0){
|
gasConcentrationExportDTO.setGasValue04(null);
|
}
|
if (gasConcentrationExportBO.getH2s() == 0){
|
gasConcentrationExportDTO.setGasValue05(null);
|
}
|
if (gasConcentrationExportBO.getC2h4() == 0){
|
gasConcentrationExportDTO.setGasValue06(null);
|
}
|
if (gasConcentrationExportBO.getC4h102() == 0){
|
gasConcentrationExportDTO.setGasValue07(null);
|
}
|
exportLists.add(gasConcentrationExportDTO);
|
}
|
|
//sql根据时间查所有,业务中处理数据项
|
|
result.setData(exportLists);
|
result.setCode(200);
|
result.setCount(exportLists.size());
|
result.setMsg("气体浓度数据导出成功");
|
return result;
|
}
|
}
|