Merge remote-tracking branch 'origin/develop1.0' into develop_alioo
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.web.controller.basicSetup; |
| | | |
| | | import com.zhitan.basicSetup.service.ISysEquipmentfileService; |
| | | import com.zhitan.common.annotation.Log; |
| | | import com.zhitan.common.config.BaseConfig; |
| | | import com.zhitan.common.core.controller.BaseController; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.enums.BusinessType; |
| | | import com.zhitan.common.utils.file.FileUploadUtils; |
| | | import com.zhitan.common.utils.uuid.UUID; |
| | | import com.zhitan.realtimedata.domain.SysEquipmentFile; |
| | | import com.zhitan.realtimedata.domain.SysSvgInfo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * ç»æå¾Controller |
| | | * |
| | | * @author sys |
| | | * @date 2020-02-24 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/basicSetup/equipmentfile") |
| | | public class SysEquipmentfileController extends BaseController { |
| | | |
| | | private final ISysEquipmentfileService sysEquipmentfileService; |
| | | |
| | | public SysEquipmentfileController( |
| | | ISysEquipmentfileService sysEquipmentfileService) { |
| | | this.sysEquipmentfileService = sysEquipmentfileService; |
| | | } |
| | | |
| | | @PostMapping(value = "/upload") |
| | | @Log(title = "ç³»ç»å¾", businessType = BusinessType.IMPORT) |
| | | public AjaxResult upload(MultipartFile file) throws IOException { |
| | | if (!file.isEmpty()) { |
| | | String fileSuffix = FileUploadUtils.getExtension(file); |
| | | if (StringUtils.containsIgnoreCase(".svg,.jpg,.png,.gif", fileSuffix)) { |
| | | //æä»¶æç»ä¿åçç»å¯¹è·¯å¾ |
| | | String filePath = FileUploadUtils.upload(BaseConfig.getConfigurePath(), file); |
| | | return AjaxResult.success(filePath); |
| | | } |
| | | return AjaxResult.error("æä»¶æ ¼å¼é误"); |
| | | } |
| | | return AjaxResult.error("ç³»ç»å¾ä¸ä¼ 失败"); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç»æå¾ |
| | | */ |
| | | @Log(title = "ç³»ç»å¾", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody SysEquipmentFile sysEquipmentfile) { |
| | | try { |
| | | sysEquipmentfileService.saveEquipmentFile(sysEquipmentfile); |
| | | return AjaxResult.success(); |
| | | } catch (Exception ex) { |
| | | log.error("ç»æå¾æ´æ°å¤±è´¥", ex); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @PutMapping("/setting/{nodeId}") |
| | | public AjaxResult saveSetting(@PathVariable("nodeId") String nodeId, |
| | | @RequestBody List<SysSvgInfo> svgInfo) { |
| | | try { |
| | | svgInfo.forEach(info -> info.setId(UUID.fastUUID().toString())); |
| | | sysEquipmentfileService.saveSettingInfo(nodeId, svgInfo); |
| | | return AjaxResult.success("ä¿åæåï¼"); |
| | | } catch (Exception ex) { |
| | | return AjaxResult.error("ä¿å失败ï¼"); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/configure/{nodeId}") |
| | | public AjaxResult getConfigure(@PathVariable("nodeId") String nodeId) { |
| | | try { |
| | | SysEquipmentFile sysEquipmentfile = sysEquipmentfileService.getConfigure(nodeId); |
| | | return AjaxResult.success(sysEquipmentfile); |
| | | } catch (Exception ex) { |
| | | return AjaxResult.error("æ¥è¯¢å¤±è´¥ï¼"); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.web.controller.energyMonitor; |
| | | |
| | | import com.zhitan.common.annotation.Log; |
| | | import com.zhitan.common.core.controller.BaseController; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.energyMonitor.service.IEnergyUnitToDeviceService; |
| | | import com.zhitan.model.service.IEnergyIndexService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @Description: è´è·åæ |
| | | * @Author: yxw |
| | | * @Date: 2022-04-24 |
| | | * @Version: V1.2 |
| | | */ |
| | | @Api(tags = "è´è·åæ") |
| | | @RestController |
| | | @RequestMapping("/loadAnalysis") |
| | | @Slf4j |
| | | public class ElectricLoadController extends BaseController { |
| | | @Autowired |
| | | private IEnergyUnitToDeviceService energyUnitToDeviceService; |
| | | // @Autowired |
| | | // private IElectricLoadService electricLoadService; |
| | | @Autowired |
| | | private IEnergyIndexService energyIndexService; |
| | | |
| | | /** |
| | | * æ ¹æ®çµè¡¨idè·åè´è·åææ°æ® |
| | | * |
| | | * @param energyUnitId ç¨è½åå
id |
| | | * @param meterId çµè¡¨id |
| | | * @param timeType æ¶é´ç±»å DAY/MONTH/YEAR |
| | | * @param timeCode æ¶é´å¼ 䏿¶é´ç±»å对åºï¼2022-03-21/2022-03/2022 |
| | | * @return |
| | | */ |
| | | @Log(title = "æ ¹æ®çµè¡¨idè·åè´è·åææ°æ®") |
| | | @ApiOperation(value = "æ ¹æ®çµè¡¨idè·åè´è·åææ°æ®", notes = "æ ¹æ®çµè¡¨idè·åè´è·åææ°æ®") |
| | | @GetMapping(value = "/detail") |
| | | public AjaxResult list(@RequestParam(name = "energyUnitId") String energyUnitId, |
| | | @RequestParam(name = "meterId") String meterId, |
| | | @RequestParam(name = "timeType") String timeType, |
| | | @RequestParam(name = "timeCode") String timeCode) { |
| | | // EnergyIndex energyIndex = energyIndexService.getDeviceIndexByCode(energyUnitId, meterId, CommonConst.TAG_CODE_ZYGGL); |
| | | // |
| | | // EnergyUnitToDevice energyUnitToDevice = energyUnitToDeviceService.getEnergyUnitToDeviceById(energyUnitId, meterId); |
| | | // ListElectricLoadVO lsvo = electricLoadService.list(timeType, timeCode, energyIndex, energyUnitToDevice); |
| | | return AjaxResult.success(null); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.web.controller.history; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.zhitan.basicdata.domain.MeterImplement; |
| | | import com.zhitan.basicdata.services.IMeterImplementService; |
| | | import com.zhitan.common.annotation.Log; |
| | | import com.zhitan.common.core.controller.BaseController; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.enums.BusinessType; |
| | | import com.zhitan.common.enums.RetrievalModes; |
| | | import com.zhitan.common.utils.poi.ExcelUtil; |
| | | import com.zhitan.history.domain.dto.HistoricalDataDTO; |
| | | import com.zhitan.history.domain.vo.HistoricalDataExcel; |
| | | import com.zhitan.history.domain.vo.HistoricalDataVO; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.model.service.IEnergyIndexService; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | import com.zhitan.realtimedata.service.RealtimeDatabaseService; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 设å¤å¯å宿¶çæµController |
| | | * |
| | | * @author sys |
| | | * @date 2020-03-30 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/dataMonitoring/historyDataTrend") |
| | | public class HistoryDataTrendController extends BaseController { |
| | | @Autowired |
| | | private final IEnergyIndexService energyIndexService; |
| | | |
| | | @Autowired |
| | | private final IMeterImplementService meterImplementService; |
| | | |
| | | @Autowired |
| | | private final RealtimeDatabaseService realtimeDatabaseService; |
| | | |
| | | |
| | | public HistoryDataTrendController(IEnergyIndexService energyIndexService, |
| | | IMeterImplementService meterImplementService, |
| | | RealtimeDatabaseService realtimeDatabaseService) { |
| | | this.energyIndexService = energyIndexService; |
| | | this.meterImplementService = meterImplementService; |
| | | this.realtimeDatabaseService = realtimeDatabaseService; |
| | | } |
| | | |
| | | |
| | | @Log(title = "è·å模åèç¹å
³èééææ ", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/energyIndex/list") |
| | | public AjaxResult getSettingIndex(EnergyIndex energyIndex) { |
| | | try { |
| | | List<EnergyIndex> infoList = energyIndexService.selectEnergyIndexList(energyIndex); |
| | | // List<String> codeList= infoList.stream().map(EnergyIndex::getCode).collect(Collectors.toList()); |
| | | // List<TagValue> valList = realtimeDatabaseService.retrieve(codeList); |
| | | // List resultList = new ArrayList(); |
| | | return AjaxResult.success(infoList); |
| | | } catch (Exception ex) { |
| | | logger.error("è·åå
³èééææ åºéï¼", ex); |
| | | return AjaxResult.error("è·åå
³èææ åºé!"); |
| | | } |
| | | } |
| | | |
| | | @Log(title = "æ ¹æ®æ¶é´ä¸ç¹ä½æ¥è¯¢åå²çæµæ°æ®", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/getHistoricalDataByIndexId") |
| | | public AjaxResult getHistoricalDataByIndexId(HistoricalDataDTO dto) { |
| | | try { |
| | | // è·åç¹ä½ä¿¡æ¯ |
| | | EnergyIndex energyIndex = energyIndexService.selectEnergyIndexById(dto.getIndexId()); |
| | | if (ObjectUtils.isEmpty(energyIndex)) { |
| | | return AjaxResult.error("æªæ¾å°ç¹ä½ä¿¡æ¯"); |
| | | } |
| | | Date beginTime = dto.getDataTime(); |
| | | Date endTime; |
| | | // æ¥è¯¢æ¡æ° |
| | | int count = 1440; |
| | | if ("DAY".equals(dto.getTimeType())) { |
| | | endTime = DateUtil.endOfDay(beginTime); |
| | | } else { |
| | | count = 3600; |
| | | endTime = DateUtil.offsetSecond(DateUtil.offsetHour(beginTime, 1), -1); |
| | | } |
| | | // æ¥è¯¢è®¡éå¨å
· |
| | | MeterImplement info = meterImplementService.selectMeterImplementById(energyIndex.getMeterId()); |
| | | List<TagValue> tagValueList = realtimeDatabaseService.retrieve(energyIndex.getCode(), beginTime, endTime, |
| | | RetrievalModes.BestFit, count); |
| | | List<HistoricalDataVO> voList = new ArrayList<>(); |
| | | Date date = DateUtil.date(); |
| | | for (int i = 0; i < count + 1; i++) { |
| | | HistoricalDataVO vo = new HistoricalDataVO(); |
| | | vo.setIndexId(energyIndex.getIndexId()); |
| | | String indexName = energyIndex.getName(); |
| | | if (ObjectUtils.isNotEmpty(info)) { |
| | | indexName = info.getInstallactionLocation() + "_" + info.getMeterName() + "_" + indexName; |
| | | } |
| | | vo.setIndexName(indexName); |
| | | // åå¼ |
| | | String value = "--"; |
| | | String usedValue = "--"; |
| | | if (beginTime.getTime() <= date.getTime()) { |
| | | try { |
| | | TagValue tagValue = tagValueList.get(i); |
| | | BigDecimal cumulative = BigDecimal.valueOf(tagValue.getValue()); |
| | | |
| | | if ("SWWSDJ_SD".equals(energyIndex.getCode()) || "SWWSDJ_WD".equals(energyIndex.getCode())) { |
| | | cumulative = cumulative.multiply(BigDecimal.valueOf(0.1)); |
| | | } |
| | | if (i > 0) { |
| | | TagValue previousTagValue = tagValueList.get(i - 1); |
| | | BigDecimal previousValue = BigDecimal.ZERO; |
| | | if (ObjectUtils.isNotEmpty(previousTagValue.getValue())) { |
| | | previousValue = BigDecimal.valueOf(previousTagValue.getValue()); |
| | | } |
| | | if ("SWWSDJ_SD".equals(energyIndex.getCode()) || "SWWSDJ_WD".equals(energyIndex.getCode())) { |
| | | previousValue = previousValue.multiply(BigDecimal.valueOf(0.1)); |
| | | |
| | | } |
| | | usedValue = String.valueOf(cumulative.subtract(previousValue).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | |
| | | value = String.valueOf(cumulative.setScale(2, RoundingMode.HALF_UP)); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | // æ¶é´ |
| | | String timeName = DateUtil.formatDateTime(beginTime); |
| | | vo.setDataTime(timeName); |
| | | if ("DAY".equals(dto.getTimeType())) { |
| | | beginTime = DateUtil.offsetMinute(beginTime, 1); |
| | | } else { |
| | | beginTime = DateUtil.offsetSecond(beginTime, 1); |
| | | } |
| | | vo.setUsedValue(String.valueOf(usedValue)); |
| | | vo.setValue(String.valueOf(value)); |
| | | voList.add(vo); |
| | | } |
| | | return AjaxResult.success(voList); |
| | | } catch (Exception ex) { |
| | | logger.error("æ¥è¯¢åå²çæµæ°æ®åºéï¼", ex); |
| | | return AjaxResult.error("æ¥è¯¢åå²çæµæ°æ®åºé!"); |
| | | } |
| | | } |
| | | |
| | | @Log(title = "导åºExcel", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/export") |
| | | public AjaxResult export(HistoricalDataDTO dto) { |
| | | try { |
| | | // è·åç¹ä½ä¿¡æ¯ |
| | | EnergyIndex energyIndex = energyIndexService.selectEnergyIndexById(dto.getIndexId()); |
| | | if (ObjectUtils.isEmpty(energyIndex)) { |
| | | return AjaxResult.success("æªæ¾å°ç¹ä½ä¿¡æ¯"); |
| | | } |
| | | Date beginTime = dto.getDataTime(); |
| | | Date endTime; |
| | | // æ¥è¯¢æ¡æ° |
| | | int count = 23; |
| | | if ("DAY".equals(dto.getTimeType())) { |
| | | endTime = DateUtil.endOfDay(beginTime); |
| | | } else { |
| | | count = 19; |
| | | endTime = DateUtil.offsetSecond(DateUtil.offsetHour(beginTime, 1), -1); |
| | | } |
| | | // æ¥è¯¢è®¡éå¨å
· |
| | | MeterImplement infor = meterImplementService.selectMeterImplementById(energyIndex.getMeterId()); |
| | | List<TagValue> tagValueList = realtimeDatabaseService.retrieve(energyIndex.getCode(), beginTime, endTime, |
| | | RetrievalModes.BestFit, count); |
| | | List<HistoricalDataExcel> excelList = new ArrayList<>(); |
| | | Date date = DateUtil.date(); |
| | | for (int i = 0; i < count + 1; i++) { |
| | | HistoricalDataExcel vo = new HistoricalDataExcel(); |
| | | String indexName = energyIndex.getName(); |
| | | if (ObjectUtils.isNotEmpty(infor)) { |
| | | indexName = infor.getInstallactionLocation() + "_" + infor.getMeterName() + "_" + indexName; |
| | | } |
| | | vo.setIndexName(indexName); |
| | | // åå¼ |
| | | String value = "--"; |
| | | String usedValue = "--"; |
| | | if (beginTime.getTime() <= date.getTime()) { |
| | | try { |
| | | TagValue tagValue = tagValueList.get(i); |
| | | BigDecimal cumulative = BigDecimal.valueOf(tagValue.getValue()); |
| | | if (i > 0) { |
| | | TagValue previousTagValue = tagValueList.get(i - 1); |
| | | BigDecimal previousValue = BigDecimal.valueOf(previousTagValue.getValue()); |
| | | usedValue = String.valueOf(cumulative.subtract(previousValue).setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | value = String.valueOf(cumulative.setScale(2, RoundingMode.HALF_UP)); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | // æ¶é´ |
| | | String timeName = DateUtil.formatDateTime(beginTime); |
| | | vo.setDataTime(timeName); |
| | | if ("DAY".equals(dto.getTimeType())) { |
| | | beginTime = DateUtil.offsetHour(beginTime, 1); |
| | | } else { |
| | | beginTime = DateUtil.offsetMinute(beginTime, 3); |
| | | } |
| | | vo.setValue(String.valueOf(value)); |
| | | vo.setUsedValue(String.valueOf(usedValue)); |
| | | excelList.add(vo); |
| | | } |
| | | ExcelUtil<HistoricalDataExcel> util = new ExcelUtil<>(HistoricalDataExcel.class); |
| | | String sheetName = "å岿°æ®ç»è®¡" + DateUtil.formatDate(dto.getDataTime()); |
| | | // return util.exportRealTimeDataExcel(excelList, sheetName); |
| | | return util.exportExcel(excelList, sheetName); |
| | | } catch (Exception ex) { |
| | | logger.error("导åºExcelæ°æ®åºéï¼", ex); |
| | | return AjaxResult.error("导åºExcelæ°æ®åºé!"); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.enums.BusinessType; |
| | | import com.zhitan.common.utils.poi.ExcelUtil; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | import com.zhitan.realtimedata.domain.dto.EnergyIndexMonitorDTO; |
| | | import com.zhitan.realtimedata.domain.vo.EquipmentMeasuringPointParameters; |
| | | import com.zhitan.realtimedata.domain.vo.EquipmentPointParametersExcel; |
| | | import com.zhitan.realtimedata.domain.vo.ExportrealtimeTrendVO; |
| | | import com.zhitan.realtimedata.service.ISvgTrendService; |
| | | import com.zhitan.realtimedata.service.RealtimeDatabaseService; |
| | | import com.zhitan.realtimedata.service.RealtimeTrendService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description 宿¶çæµæ§å¶ç±» |
| | | * |
| | | * @Author zhoubg |
| | | * @date 2024-10-15 |
| | | * 宿¶çæµæ§å¶ç±» |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("rtdb/realtimeTrend") |
| | |
| | | |
| | | @Autowired |
| | | private RealtimeTrendService realtimeTrendService; |
| | | @Resource |
| | | private ISvgTrendService svgTrendService; |
| | | @Resource |
| | | private RealtimeDatabaseService realtimeDatabaseService; |
| | | |
| | | /** |
| | | * è·å模åèç¹å
³èééææ |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "è·å模åèç¹å
³èééææ ") |
| | |
| | | |
| | | /** |
| | | * è·åå岿¨¡åèç¹å
³èééææ æ°æ® |
| | | * @param tagCode |
| | | * @param dataTime |
| | | * @return |
| | | */ |
| | | @Log(title = "è·åå岿¨¡åèç¹å
³èééææ æ°æ®", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/chartByDay") |
| | |
| | | |
| | | /** |
| | | * 导åºå®æ¶çæµExcelä¿¡æ¯ |
| | | * @return |
| | | */ |
| | | @Log(title = "导åºå®æ¶çæµExcelä¿¡æ¯", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | |
| | | util.exportExcel(response,list, "宿¶çæµ"); |
| | | } |
| | | |
| | | /** |
| | | * è·å模åèç¹å
³èééææ |
| | | */ |
| | | @Log(title = "è·å模åèç¹å
³èééææ ", businessType = BusinessType.UPDATE) |
| | | @GetMapping("/svgTrendView/energyIndex/list") |
| | | @ApiOperation(value = "è·å模åèç¹å
³èééææ ") |
| | | public AjaxResult getSvgTrendViewSettingIndex(EnergyIndex energyIndex) { |
| | | try { |
| | | List<EnergyIndex> infoList = svgTrendService.selectSvgList(energyIndex); |
| | | if (infoList == null || infoList.isEmpty()){ |
| | | return AjaxResult.success(Collections.emptyList()); |
| | | } |
| | | List<String> codeList = infoList.stream().map(EnergyIndex::getCode).collect(Collectors.toList()); |
| | | |
| | | List<TagValue> valList = realtimeDatabaseService.retrieve(codeList); |
| | | if (valList == null || valList.isEmpty()) { |
| | | return AjaxResult.success(Collections.emptyList()); |
| | | } |
| | | |
| | | Map<String, List<TagValue>> tagValueMap = valList.stream().collect(Collectors.groupingBy(TagValue::getTagCode)); |
| | | |
| | | List<EquipmentMeasuringPointParameters> resultList = infoList.stream().map(index -> { |
| | | EquipmentMeasuringPointParameters item = new EquipmentMeasuringPointParameters(); |
| | | item.setCode(index.getCode()); |
| | | item.setIndexName(index.getName()); |
| | | item.setIndexUnit(index.getUnitId()); |
| | | item.setMeteName(index.getMeterName()); |
| | | item.setyValue("y0"); |
| | | |
| | | List<TagValue> tagValueList = tagValueMap.getOrDefault(index.getCode(), Collections.emptyList()); |
| | | if (!tagValueList.isEmpty()){ |
| | | Optional<Double> sumOptional = tagValueList.stream() |
| | | .map(TagValue::getValue) |
| | | .reduce(Double::sum); |
| | | sumOptional.ifPresent(sum -> item.setValue(BigDecimal.valueOf(sum) |
| | | .setScale(2, RoundingMode.HALF_UP).doubleValue())); |
| | | } |
| | | return item; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | return AjaxResult.success(resultList); |
| | | } catch (Exception ex) { |
| | | logger.error("è·åå
³èééææ åºéï¼", ex); |
| | | return AjaxResult.error("è·åå
³èææ åºé!"); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.web.controller.statisticalAnalysis; |
| | | |
| | | import com.zhitan.common.core.controller.BaseController; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.utils.poi.ExcelUtil; |
| | | import com.zhitan.statisticalAnalysis.domain.dto.DataAnalysisMoMDTO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisMoMExcel; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisMoMVO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisYoYExcel; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisYoYVO; |
| | | import com.zhitan.statisticalAnalysis.service.IStatisticalAnalysisService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * ç»è®¡åæ æ§å¶å± |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/statisticalAnalysis") |
| | | public class StatisticalAnalysisController extends BaseController { |
| | | |
| | | @Autowired |
| | | private IStatisticalAnalysisService analysisService; |
| | | |
| | | |
| | | @PostMapping("/getElectricDataComparisonYoY") |
| | | @ApiOperation(value = "è·åçµè½èåæ¯æ°æ®", notes = "è·åçµè½èåæ¯æ°æ®") |
| | | public AjaxResult listElectricDataComparisonYoY(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisYoYVO> yoyList = analysisService.listElectricDataComparisonYoY(dto); |
| | | return AjaxResult.success(yoyList); |
| | | } |
| | | |
| | | @PostMapping("/getElectricDataComparisonMoM") |
| | | @ApiOperation(value = "è·åçµè½èç¯æ¯æ°æ®", notes = "è·åçµè½èç¯æ¯æ°æ®") |
| | | public AjaxResult listElectricDataComparisonMoM(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisMoMVO> momList = analysisService.listElectricDataComparisonMoM(dto); |
| | | return AjaxResult.success(momList); |
| | | } |
| | | |
| | | @PostMapping("/getWaterDataComparisonYoY") |
| | | @ApiOperation(value = "è·åæ°´è½èåæ¯æ°æ®", notes = "è·åæ°´è½èåæ¯æ°æ®") |
| | | public AjaxResult listWaterDataComparisonYoY(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisYoYVO> yoyList = analysisService.listWaterDataComparisonYoY(dto); |
| | | return AjaxResult.success(yoyList); |
| | | } |
| | | |
| | | @PostMapping("/getWaterDataComparisonMoM") |
| | | @ApiOperation(value = "è·åæ°´è½èç¯æ¯æ°æ®", notes = "è·åæ°´è½èç¯æ¯æ°æ®") |
| | | public AjaxResult listWaterDataComparisonMoM(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisMoMVO> momList = analysisService.listWaterDataComparisonMoM(dto); |
| | | return AjaxResult.success(momList); |
| | | } |
| | | |
| | | @PostMapping("/exportElectricYoY") |
| | | @ApiOperation(value = "导åºçµè½èåæ¯æ°æ®", notes = "导åºçµè½èåæ¯æ°æ®") |
| | | public AjaxResult exportElectricComparisonYoY(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisYoYExcel> yoYExcelsList = new ArrayList<>(); |
| | | List<DataAnalysisYoYVO> yoYList = analysisService.listElectricDataComparisonYoY(dto); |
| | | if (CollectionUtils.isNotEmpty(yoYList)) { |
| | | for (DataAnalysisYoYVO vo : yoYList) { |
| | | DataAnalysisYoYExcel excel = new DataAnalysisYoYExcel(); |
| | | BeanUtils.copyProperties(vo, excel); |
| | | yoYExcelsList.add(excel); |
| | | } |
| | | } |
| | | ExcelUtil<DataAnalysisYoYExcel> util = new ExcelUtil<>(DataAnalysisYoYExcel.class); |
| | | return util.exportExcel(yoYExcelsList, "çµç»¼åè½èåæ¯ä¿¡æ¯"); |
| | | } |
| | | |
| | | // @PostMapping("/exportElectricMoM") |
| | | // @ApiOperation(value = "导åºçµè½èç¯æ¯æ°æ®", notes = "导åºçµè½èç¯æ¯æ°æ®") |
| | | // public AjaxResult exportElectricComparisonMoM(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | // List<DataAnalysisMoMExcel> moMExcelsList = new ArrayList<>(); |
| | | // List<DataAnalysisMoMVO> moMList = analysisService.listElectricDataComparisonMoM(dto); |
| | | // if (CollectionUtils.isNotEmpty(moMList)) { |
| | | // for (DataAnalysisMoMVO vo : moMList) { |
| | | // DataAnalysisMoMExcel excel = new DataAnalysisMoMExcel(); |
| | | // BeanUtils.copyProperties(vo, excel); |
| | | // moMExcelsList.add(excel); |
| | | // } |
| | | // } |
| | | // ExcelUtil<DataAnalysisMoMExcel> util = new ExcelUtil<>(DataAnalysisMoMExcel.class); |
| | | // return util.exportRealTimeDataExcel(moMExcelsList, "çµç»¼åè½èç¯æ¯ä¿¡æ¯"); |
| | | // } |
| | | |
| | | @PostMapping("/exportWaterYoY") |
| | | @ApiOperation(value = "å¯¼åºæ°´èåæ¯æ°æ®", notes = "å¯¼åºæ°´èåæ¯æ°æ®") |
| | | public AjaxResult exportWaterComparisonYoY(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisYoYExcel> yoYExcelsList = new ArrayList<>(); |
| | | List<DataAnalysisYoYVO> yoYList = analysisService.listWaterDataComparisonYoY(dto); |
| | | if (CollectionUtils.isNotEmpty(yoYList)) { |
| | | for (DataAnalysisYoYVO vo : yoYList) { |
| | | DataAnalysisYoYExcel excel = new DataAnalysisYoYExcel(); |
| | | BeanUtils.copyProperties(vo, excel); |
| | | yoYExcelsList.add(excel); |
| | | } |
| | | } |
| | | ExcelUtil<DataAnalysisYoYExcel> util = new ExcelUtil<>(DataAnalysisYoYExcel.class); |
| | | return util.exportExcel(yoYExcelsList, "水综åè½èèåæ¯ä¿¡æ¯"); |
| | | } |
| | | |
| | | @PostMapping("/exportWaterMoM") |
| | | @ApiOperation(value = "å¯¼åºæ°´èç¯æ¯æ°æ®", notes = "å¯¼åºæ°´èç¯æ¯æ°æ®") |
| | | public AjaxResult exportWaterComparisonMoM(@RequestBody @Validated DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisMoMExcel> moMExcelsList = new ArrayList<>(); |
| | | List<DataAnalysisMoMVO> moMList = analysisService.listWaterDataComparisonMoM(dto); |
| | | if (CollectionUtils.isNotEmpty(moMList)) { |
| | | for (DataAnalysisMoMVO vo : moMList) { |
| | | DataAnalysisMoMExcel excel = new DataAnalysisMoMExcel(); |
| | | BeanUtils.copyProperties(vo, excel); |
| | | moMExcelsList.add(excel); |
| | | } |
| | | } |
| | | ExcelUtil<DataAnalysisMoMExcel> util = new ExcelUtil<>(DataAnalysisMoMExcel.class); |
| | | return util.exportExcel(moMExcelsList, "水综åè½èèç¯æ¯ä¿¡æ¯"); |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | return getProfile() + "/upload"; |
| | | } |
| | | |
| | | public static String getConfigurePath() { |
| | | return getProfile() + "/configure"; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.common.constant; |
| | | |
| | | /** |
| | | * @Description: å¨æç±»å |
| | | * @author: yxw |
| | | * @date: 2022å¹´03æ17æ¥ 12:33 |
| | | */ |
| | | public class TimeTypeConst { |
| | | /** |
| | | * å¨æç±»å - å°æ¶ |
| | | */ |
| | | public static final String TIME_TYPE_HOUR="HOUR"; |
| | | /** |
| | | * å¨æç±»å - æ¥ |
| | | */ |
| | | public static final String TIME_TYPE_DAY="DAY"; |
| | | /** |
| | | * å¨æç±»å - æ |
| | | */ |
| | | public static final String TIME_TYPE_MONTH="MONTH"; |
| | | /** |
| | | * å¨æç±»å - å¹´ |
| | | */ |
| | | public static final String TIME_TYPE_YEAR="YEAR"; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.basicSetup.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zhitan.realtimedata.domain.SysEquipmentFile; |
| | | import com.zhitan.realtimedata.domain.SysSvgInfo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç»æå¾Mapperæ¥å£ |
| | | * |
| | | * @author sys |
| | | * @date 2020-02-24 |
| | | */ |
| | | public interface SysEquipmentfileMapper extends BaseMapper<SysEquipmentFile> { |
| | | |
| | | void saveEquipmentFile(SysEquipmentFile sysEquipmentfile); |
| | | |
| | | void saveSettingInfo(@Param("nodeId") String nodeId, @Param("svgInfo") List<SysSvgInfo> svgInfo); |
| | | |
| | | SysEquipmentFile getConfigure(String nodeId); |
| | | |
| | | List<SysSvgInfo> getConfigureTag(String nodeId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.basicSetup.service; |
| | | |
| | | import com.zhitan.realtimedata.domain.SysEquipmentFile; |
| | | import com.zhitan.realtimedata.domain.SysSvgInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç»æå¾Serviceæ¥å£ |
| | | * |
| | | * @author sys |
| | | * @date 2020-02-24 |
| | | */ |
| | | public interface ISysEquipmentfileService { |
| | | |
| | | void saveEquipmentFile(SysEquipmentFile sysEquipmentfile); |
| | | |
| | | void saveSettingInfo(String nodeId, List<SysSvgInfo> svgInfo); |
| | | |
| | | /** |
| | | * è·åç»æå¾é
ç½®ä¿¡æ¯ |
| | | * @param nodeId 模åèç¹ id |
| | | * @return |
| | | */ |
| | | SysEquipmentFile getConfigure(String nodeId); |
| | | |
| | | /** |
| | | * è·åç»æå¾é
ç½®çç¹ä½å· |
| | | * @param nodeId 模åèç¹ id |
| | | * @return |
| | | */ |
| | | List<SysSvgInfo> getConfigureTag(String nodeId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.basicSetup.service.impl; |
| | | |
| | | import com.zhitan.basicSetup.mapper.SysEquipmentfileMapper; |
| | | import com.zhitan.basicSetup.service.ISysEquipmentfileService; |
| | | import com.zhitan.realtimedata.domain.SysEquipmentFile; |
| | | import com.zhitan.realtimedata.domain.SysSvgInfo; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç»æå¾Serviceä¸å¡å±å¤ç |
| | | * |
| | | * @author sys |
| | | * @date 2020-02-24 |
| | | */ |
| | | @Service |
| | | public class SysEquipmentfileServiceImpl implements ISysEquipmentfileService { |
| | | |
| | | @Autowired |
| | | private SysEquipmentfileMapper equipmentfileMapper; |
| | | |
| | | @Override |
| | | public void saveEquipmentFile(SysEquipmentFile sysEquipmentfile) { |
| | | SysEquipmentFile sysEquipmentFile = equipmentfileMapper.selectById(sysEquipmentfile.getNodeId()); |
| | | if (ObjectUtils.isNotEmpty(sysEquipmentFile)){ |
| | | sysEquipmentFile.setFilePath(sysEquipmentfile.getFilePath()); |
| | | equipmentfileMapper.updateById(sysEquipmentFile); |
| | | }else { |
| | | SysEquipmentFile equipmentFile = new SysEquipmentFile(); |
| | | equipmentFile.setFilePath(sysEquipmentfile.getFilePath()); |
| | | equipmentFile.setNodeId(sysEquipmentfile.getNodeId()); |
| | | equipmentfileMapper.insert(equipmentFile); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void saveSettingInfo(String nodeId, List<SysSvgInfo> svgInfo) { |
| | | equipmentfileMapper.saveSettingInfo(nodeId, svgInfo); |
| | | } |
| | | |
| | | @Override |
| | | public SysEquipmentFile getConfigure(String nodeId) { |
| | | SysEquipmentFile sysEquipmentfile = equipmentfileMapper.getConfigure(nodeId); |
| | | List<SysSvgInfo> infos = getConfigureTag(nodeId); |
| | | if (sysEquipmentfile != null) { |
| | | sysEquipmentfile.setInfoList(infos); |
| | | } |
| | | |
| | | return sysEquipmentfile; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysSvgInfo> getConfigureTag(String nodeId) { |
| | | return equipmentfileMapper.getConfigureTag(nodeId); |
| | | } |
| | | } |
| | |
| | | */ |
| | | List<CarbonEmission> getDownCarbonEmission(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime, |
| | | @Param("timeType") String timeType, @Param("indexId") String indexId); |
| | | |
| | | /** |
| | | * æ ¹æ®indexId䏿¶é´èå´æ¥è¯¢å°æ¶çdataitemä¿¡æ¯ |
| | | * |
| | | * @param beginTime å¼å§æ¶é´ |
| | | * @param endTime æªæ¢æ¶é´ |
| | | * @param timeType æ¶é´ç±»å |
| | | * @param indexIds ç¹ä½éå |
| | | * @return |
| | | */ |
| | | List<DataItem> getDataItemHourInforByIndexIds(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime, |
| | | @Param("timeType") String timeType, @Param("indexIds") List<String> indexIds); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | BigDecimal getDataItemValueByIndexIds(String timeCode, List<String> indexIds); |
| | | |
| | | /** |
| | | * æ ¹æ®indexId䏿¶é´èå´æ¥è¯¢å°æ¶çdataitemä¿¡æ¯ |
| | | * |
| | | * @param beginTime å¼å§æ¶é´ |
| | | * @param endTime æªæ¢æ¶é´ |
| | | * @param timeType æ¶é´ç±»å |
| | | * @param indexIds ç¹ä½éå |
| | | * @return |
| | | */ |
| | | List<DataItem> getDataItemHourInforByIndexIds(Date beginTime, Date endTime, String timeType, List<String> indexIds); |
| | | } |
| | |
| | | public BigDecimal getDataItemValueByIndexIds(String timeCode, List<String> indexIds) { |
| | | return dataItemMapper.getDataItemValueByIndexIds(timeCode, indexIds); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®indexId䏿¶é´èå´æ¥è¯¢å°æ¶çdataitemä¿¡æ¯ |
| | | * |
| | | * @param beginTime å¼å§æ¶é´ |
| | | * @param endTime æªæ¢æ¶é´ |
| | | * @param timeType æ¶é´ç±»å |
| | | * @param indexIds ç¹ä½éå |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DataItem> getDataItemHourInforByIndexIds(Date beginTime, Date endTime, String timeType, List<String> indexIds) { |
| | | return dataItemMapper.getDataItemHourInforByIndexIds(beginTime, endTime, timeType, indexIds); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zhitan.common.annotation.Excel; |
| | | import com.zhitan.common.core.domain.BaseEntity; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Description: ç¨è½åå
å
³èç平尿¨¡æ¿ä¸ä»ªè¡¨ççé¢é»è¾å
³ç³» ä¸å«æ ééã计ç®ä¿¡æ¯ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-01-26 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Data |
| | | @TableName("energy_unit_to_device") |
| | | @Accessors(chain = true) |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="energy_unit_to_device对象", description="ç¨è½åå
å
³èç平尿¨¡æ¿ä¸ä»ªè¡¨ççé¢é»è¾å
³ç³» ä¸å«æ ééã计ç®ä¿¡æ¯") |
| | | public class EnergyUnitToDevice extends BaseEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "æ°ä¸»é®") |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String newId; |
| | | |
| | | /**主é®*/ |
| | | @ApiModelProperty(value = "主é®") |
| | | private String id; |
| | | |
| | | /**å
³è仪表åç§°*/ |
| | | @Excel(name = "å
³è仪表åç§°", width = 15) |
| | | @ApiModelProperty(value = "å
³è仪表åç§°") |
| | | private String name; |
| | | |
| | | /**å
³è仪表ç¼ç */ |
| | | @Excel(name = "å
³è仪表ç¼ç ", width = 15) |
| | | @ApiModelProperty(value = "å
³è仪表ç¼ç ") |
| | | private String code; |
| | | |
| | | /**è½æºç±»åï¼æ°´è¡¨ãçµè¡¨ãæ°è¡¨çï¼*/ |
| | | @Excel(name = "è½æºç±»åï¼æ°´è¡¨ãçµè¡¨ãæ°è¡¨çï¼", width = 15) |
| | | @ApiModelProperty(value = "è½æºç±»åï¼æ°´è¡¨ãçµè¡¨ãæ°è¡¨çï¼") |
| | | private String deviceType; |
| | | |
| | | /**ç¨è½åå
主é®*/ |
| | | @Excel(name = "ç¨è½åå
主é®", width = 15) |
| | | @ApiModelProperty(value = "ç¨è½åå
主é®") |
| | | private String energyUnitId; |
| | | |
| | | /**ç§æ·ä¸»é®*/ |
| | | @Excel(name = "ç§æ·ä¸»é®", width = 15) |
| | | @ApiModelProperty(value = "ç§æ·ä¸»é®") |
| | | private Integer tenantId; |
| | | |
| | | @ApiModelProperty(value = "åä¸è®¡é") |
| | | private String partMeasurement; |
| | | |
| | | @ApiModelProperty(value = "å®è£
ä½ç½®") |
| | | private String installPosition; |
| | | |
| | | @ApiModelProperty(value = "åææ¯ä¾") |
| | | private BigDecimal shareRatio; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 计ç®ç¹ä½å¯¹åºç计ç®å
¬å¼ |
| | | * @author zhw |
| | | */ |
| | | @Data |
| | | @ApiModel(value="计ç®ç¹ä½å¯¹åºç计ç®å
¬å¼", description="计ç®ç¹ä½å¯¹åºç计ç®å
¬å¼") |
| | | public class EnergyCalculateCalcTV { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "计ç®ç¹ä½ä¸»é®") |
| | | private String calculateIndexId; |
| | | |
| | | @ApiModelProperty(value = "仪表设å¤ä¸»é®") |
| | | private String deviceId; |
| | | |
| | | @ApiModelProperty(value = "仪表åç§°") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "计ç®ç¹ä½å
å«çééç¹ä½ä¸»é®") |
| | | private String collectIndexId; |
| | | |
| | | @ApiModelProperty(value = "ééç¹ä½å¯¹åºæä½ç¬¦å·") |
| | | private String operator; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:07 |
| | | */ |
| | | @Data |
| | | public class ListElectricityMeterVO { |
| | | /** |
| | | * çµè¡¨åç§° |
| | | */ |
| | | private String label; |
| | | /** |
| | | * çµè¡¨id |
| | | */ |
| | | private String code; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | |
| | | /** |
| | | * ç¨è½åå
ä¸è®¡éå¨å
·å
³ç³»vo |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/4/4 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ç¨è½åå
ä¸è®¡éå¨å
·å
³ç³»vo-è¿åvo", description = "ç¨è½åå
ä¸è®¡éå¨å
·å
³ç³»vo-è¿åvo") |
| | | public class UnitToDeviceRelationVO { |
| | | |
| | | /** |
| | | * ç¨è½åå
id |
| | | */ |
| | | @ApiModelProperty(value = "ç¨è½åå
id") |
| | | private String unitId; |
| | | |
| | | /** |
| | | * 计éå¨å
·id |
| | | */ |
| | | @ApiModelProperty(value = "计éå¨å
·id") |
| | | private String deviceId; |
| | | |
| | | /** |
| | | * 计éå¨å
·åç§° |
| | | */ |
| | | @ApiModelProperty(value = "计éå¨å
·åç§°") |
| | | private String deviceName; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zhitan.energyMonitor.domain.EnergyUnitToDevice; |
| | | import com.zhitan.energyMonitor.domain.vo.EnergyCalculateCalcTV; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: ç¨è½åå
å
³èç平尿¨¡æ¿ä¸ä»ªè¡¨ççé¢é»è¾å
³ç³» ä¸å«æ ééã计ç®ä¿¡æ¯ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-01-26 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface EnergyUnitToDeviceMapper extends BaseMapper<EnergyUnitToDevice> { |
| | | |
| | | /** |
| | | * æ ¹æ®è®¡ç®ç¹ä½ä¸»é®åç¨è½åå
ä¸»é® æ¥è¯¢ 使ç¨ç ééç¹åä»ªè¡¨ä¿¡æ¯ |
| | | * |
| | | * @param calculateIndexId |
| | | * @param energyUnitId |
| | | * @return |
| | | */ |
| | | public List<EnergyCalculateCalcTV> getCalculateDevices(@Param("calculateIndexId") String calculateIndexId, |
| | | @Param("energyUnitId") String energyUnitId, |
| | | @Param("tenantId") String tenantId); |
| | | |
| | | /** |
| | | * ä¸ç§-æ ¹æ®ç§æ·idéåæ¥è¯¢è®¡éå¨å
·id |
| | | * |
| | | * @param unitIds |
| | | * @return |
| | | */ |
| | | @InterceptorIgnore(tenantLine = "true") |
| | | List<String> listDeviceByTenantIds(@Param("unitIds") List<String> unitIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zhitan.energyMonitor.domain.EnergyUnitToDevice; |
| | | import com.zhitan.energyMonitor.domain.vo.ListElectricityMeterVO; |
| | | import com.zhitan.energyMonitor.domain.vo.UnitToDeviceRelationVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: ç¨è½åå
å
³èç平尿¨¡æ¿ä¸ä»ªè¡¨ççé¢é»è¾å
³ç³» ä¸å«æ ééã计ç®ä¿¡æ¯ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-01-26 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IEnergyUnitToDeviceService extends IService<EnergyUnitToDevice> { |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
IDè·åç§æ·ä¸ææç仪表éå |
| | | * @param unitId |
| | | * @return |
| | | */ |
| | | List<EnergyUnitToDevice> queryTenantUnitDeviceByUnitId(String unitId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
IDè·åç§æ·ä¸ææææçå®ä½è¡¨éå |
| | | * @param unitId |
| | | * @return |
| | | */ |
| | | List<EnergyUnitToDevice> queryTenantEntityMeterByUnitId(String unitId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitId ç¨è½åå
id |
| | | * @return 仪表idéå |
| | | */ |
| | | List<String> getEnergyUnitDeviceIdByUnitId(String unitId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idéåè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitIds ç¨è½åå
id |
| | | */ |
| | | List<String> getEnergyUnitDeviceIdByUnitIds(List<String> unitIds); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idéå+è½æºç±»åè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitIds ç¨è½åå
idéå |
| | | * @return |
| | | */ |
| | | List<String> getDeviceIdByUnitIds(List<String> unitIds); |
| | | |
| | | /** |
| | | * æ´æ°è½åå
idè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitId ç¨è½åå
id |
| | | * @return 仪表idéå |
| | | */ |
| | | List<String> updateEnergyUnitDeviceIdByUnitId(String unitId); |
| | | |
| | | /** |
| | | * å é¤è½åå
idè·åç§æ·ä¸ææç仪表idéå |
| | | * @param unitId ç¨è½åå
id |
| | | * @return 仪表idéå |
| | | */ |
| | | void deleteEnergyUnitDeviceIdByUnitId(String unitId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
IDè·åç§æ·ä¸ææççµè¡¨éå |
| | | * @param unitId |
| | | * @return |
| | | */ |
| | | List<ListElectricityMeterVO> listElectricityMeter(String unitId); |
| | | |
| | | /** |
| | | * è·åç§æ·ä¸ææç表éå |
| | | * @return |
| | | */ |
| | | List<EnergyUnitToDevice> listAllMeter(); |
| | | |
| | | /** |
| | | * æ ¹æ®è®¡éå¨å
·idåç¨è½åå
idæ¥è¯¢è¡¨å
³ç³» |
| | | * |
| | | * @param unitId ç¨è½åå
id |
| | | * @param id id |
| | | * @return EnergyUnitToDeviceå®ä½ |
| | | */ |
| | | EnergyUnitToDevice getEnergyUnitToDeviceById(String unitId, String id); |
| | | |
| | | /** |
| | | * æ ¹æ®è®¡éå¨å
·idéåæ¥è¯¢ä¸ç¨è½çå
³ç³» |
| | | * |
| | | * @param unitIds |
| | | * @return |
| | | */ |
| | | List<UnitToDeviceRelationVO> listDeviceByUnitIds(List<String> unitIds); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.energyMonitor.domain.EnergyUnitToDevice; |
| | | import com.zhitan.energyMonitor.domain.vo.ListElectricityMeterVO; |
| | | import com.zhitan.energyMonitor.domain.vo.UnitToDeviceRelationVO; |
| | | import com.zhitan.energyMonitor.mapper.EnergyUnitToDeviceMapper; |
| | | import com.zhitan.energyMonitor.service.IEnergyUnitToDeviceService; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: ç¨è½åå
å
³èç平尿¨¡æ¿ä¸ä»ªè¡¨ççé¢é»è¾å
³ç³» ä¸å«æ ééã计ç®ä¿¡æ¯ |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-01-26 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class EnergyUnitToDeviceServiceImpl extends ServiceImpl<EnergyUnitToDeviceMapper, EnergyUnitToDevice> |
| | | implements IEnergyUnitToDeviceService { |
| | | |
| | | |
| | | // @Autowired |
| | | // private IMeasuringInstrumentsService meterService; |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idè·åç§æ·ä¸çå
¶ä¸ç仪表å表 |
| | | * |
| | | * @param unitId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<EnergyUnitToDevice> queryTenantUnitDeviceByUnitId(String unitId) { |
| | | |
| | | QueryWrapper<EnergyUnitToDevice> queryWrapper = new QueryWrapper<EnergyUnitToDevice>(); |
| | | // .eq(TableColumnConst.TABLE_COLUMN_ENERGY_UNIT_ID, unitId); |
| | | return baseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
IDè·åç§æ·ä¸ææææçå®ä½è¡¨éå |
| | | * |
| | | * @param unitId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<EnergyUnitToDevice> queryTenantEntityMeterByUnitId(String unitId) { |
| | | |
| | | List<EnergyUnitToDevice> unitToDeviceList = baseMapper.selectList(Wrappers.<EnergyUnitToDevice>lambdaQuery() |
| | | .eq(EnergyUnitToDevice::getEnergyUnitId, unitId) |
| | | ); |
| | | // if (CollectionUtils.isNotEmpty(unitToDeviceList)) { |
| | | // List<String> meterIds = unitToDeviceList.stream().map(EnergyUnitToDevice::getId).collect(Collectors.toList()); |
| | | // // è¿æ»¤åºå®ä½è¡¨ |
| | | // Integer applianceType = EquipmentInformationEnum.MEASURING_INSTRUMENT_TYPE.ENTITY.getValue(); |
| | | // List<Meter> meterList = meterService.list(Wrappers.<Meter>lambdaQuery() |
| | | // .select(Meter::getId).in(Meter::getId, meterIds) |
| | | // .eq(Meter::getApplianceType, applianceType) |
| | | // ); |
| | | // List<String> newMeterIds = meterList.stream().map(Meter::getId).collect(Collectors.toList()); |
| | | // unitToDeviceList = unitToDeviceList.stream().filter(li -> newMeterIds.contains(li.getId())).collect(Collectors.toList()); |
| | | // } |
| | | return unitToDeviceList; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitId ç¨è½åå
id |
| | | * @return 仪表idéå |
| | | */ |
| | | @Override |
| | | // @Cacheable(value = CacheConstant.ENERGY_UNIT_DEVICE_ID_CACHE, key = "#unitId", unless = "#result == null") |
| | | public List<String> getEnergyUnitDeviceIdByUnitId(String unitId) { |
| | | |
| | | if (StringUtils.isEmpty(unitId)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<EnergyUnitToDevice> energyUnitToDevices = baseMapper.selectList(Wrappers.<EnergyUnitToDevice>lambdaQuery() |
| | | .select(EnergyUnitToDevice::getId).eq(EnergyUnitToDevice::getEnergyUnitId, unitId) |
| | | ); |
| | | if (CollectionUtils.isEmpty(energyUnitToDevices)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return energyUnitToDevices.stream().map(EnergyUnitToDevice::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idéåè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitIds ç¨è½åå
id |
| | | */ |
| | | @Override |
| | | public List<String> getEnergyUnitDeviceIdByUnitIds(List<String> unitIds) { |
| | | if (CollectionUtils.isEmpty(unitIds)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<String> deviceIdList = new ArrayList<>(); |
| | | for (String unitId : unitIds) { |
| | | List<String> unitDeviceIdByUnitId = this.getEnergyUnitDeviceIdByUnitId(unitId); |
| | | if (CollectionUtils.isNotEmpty(unitDeviceIdByUnitId)) { |
| | | deviceIdList.addAll(unitDeviceIdByUnitId); |
| | | } |
| | | } |
| | | return deviceIdList; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idéå+è½æºç±»åè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitIds ç¨è½åå
idéå |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<String> getDeviceIdByUnitIds(List<String> unitIds) { |
| | | if (CollectionUtils.isEmpty(unitIds)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | return baseMapper.listDeviceByTenantIds(unitIds); |
| | | } |
| | | |
| | | /** |
| | | * æ´æ°è½åå
idè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitId ç¨è½åå
id |
| | | * @return 仪表idéå |
| | | */ |
| | | @Override |
| | | // @CachePut(value = CacheConstant.ENERGY_UNIT_DEVICE_ID_CACHE, key = "#unitId", unless = "#result == null") |
| | | public List<String> updateEnergyUnitDeviceIdByUnitId(String unitId) { |
| | | |
| | | if (StringUtils.isEmpty(unitId)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<EnergyUnitToDevice> energyUnitToDevices = baseMapper.selectList(Wrappers.<EnergyUnitToDevice>lambdaQuery() |
| | | .select(EnergyUnitToDevice::getId).eq(EnergyUnitToDevice::getEnergyUnitId, unitId) |
| | | ); |
| | | if (CollectionUtils.isEmpty(energyUnitToDevices)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return energyUnitToDevices.stream().map(EnergyUnitToDevice::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * å é¤è½åå
idè·åç§æ·ä¸ææç仪表idéå |
| | | * |
| | | * @param unitId ç¨è½åå
id |
| | | */ |
| | | @Override |
| | | // @CacheEvict(value = CacheConstant.ENERGY_UNIT_DEVICE_ID_CACHE, key = "#unitId") |
| | | public void deleteEnergyUnitDeviceIdByUnitId(String unitId) { |
| | | } |
| | | |
| | | @Override |
| | | public List<ListElectricityMeterVO> listElectricityMeter(String unitId) { |
| | | |
| | | LambdaQueryWrapper<EnergyUnitToDevice> queryWrapper = new LambdaQueryWrapper<EnergyUnitToDevice>() |
| | | .eq(EnergyUnitToDevice::getEnergyUnitId, unitId); |
| | | // .eq(EnergyUnitToDevice::getDeviceType, EnergyTypeConst.ELECTRICITY); |
| | | List<EnergyUnitToDevice> models = baseMapper.selectList(queryWrapper); |
| | | |
| | | List<ListElectricityMeterVO> resultList = new ArrayList<>(); |
| | | for (EnergyUnitToDevice model : models) { |
| | | ListElectricityMeterVO temp = new ListElectricityMeterVO(); |
| | | temp.setCode(model.getId()); |
| | | temp.setLabel(model.getName()); |
| | | resultList.add(temp); |
| | | } |
| | | return resultList; |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyUnitToDevice> listAllMeter() { |
| | | QueryWrapper<EnergyUnitToDevice> queryWrapper = new QueryWrapper<EnergyUnitToDevice>(); |
| | | return baseMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public EnergyUnitToDevice getEnergyUnitToDeviceById(String unitId, String id) { |
| | | if (StringUtils.isEmpty(id)) { |
| | | return null; |
| | | } |
| | | LambdaQueryWrapper<EnergyUnitToDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(EnergyUnitToDevice::getEnergyUnitId, unitId); |
| | | lambdaQueryWrapper.eq(EnergyUnitToDevice::getId, id); |
| | | List<EnergyUnitToDevice> energyUnitToDevices = baseMapper.selectList(lambdaQueryWrapper); |
| | | if (CollectionUtils.isNotEmpty(energyUnitToDevices)) { |
| | | return energyUnitToDevices.get(CommonConst.DIGIT_0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®è®¡éå¨å
·idéåæ¥è¯¢ä¸ç¨è½çå
³ç³» |
| | | * |
| | | * @param unitIds |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<UnitToDeviceRelationVO> listDeviceByUnitIds(List<String> unitIds) { |
| | | List<UnitToDeviceRelationVO> relationList = new ArrayList<>(); |
| | | if (CollectionUtils.isEmpty(unitIds)) { |
| | | return relationList; |
| | | } |
| | | List<EnergyUnitToDevice> unitToDeviceList = baseMapper.selectList(Wrappers.<EnergyUnitToDevice>lambdaQuery() |
| | | .select(EnergyUnitToDevice::getId, EnergyUnitToDevice::getEnergyUnitId, EnergyUnitToDevice::getName) |
| | | .in(EnergyUnitToDevice::getEnergyUnitId, unitIds) |
| | | ); |
| | | if (CollectionUtils.isNotEmpty(unitToDeviceList)) { |
| | | unitToDeviceList.forEach(li -> { |
| | | UnitToDeviceRelationVO vo = new UnitToDeviceRelationVO(); |
| | | vo.setDeviceId(li.getId()); |
| | | vo.setUnitId(li.getEnergyUnitId()); |
| | | vo.setDeviceName(li.getName()); |
| | | relationList.add(vo); |
| | | }); |
| | | } |
| | | return relationList; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.history.domain.dto; |
| | | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * åå²çæµæ°æ®è¯·æ± DTO |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/7 |
| | | */ |
| | | public class HistoricalDataDTO { |
| | | |
| | | /** |
| | | * ç¹ä½id |
| | | */ |
| | | @NotBlank(message = "æªæ¾å°ç¹ä½ä¿¡æ¯") |
| | | private String indexId; |
| | | |
| | | /** |
| | | * æ¶é´ç±»å |
| | | */ |
| | | @NotBlank(message = "æªæ¾å°æ¶é´ç±»å") |
| | | private String timeType; |
| | | |
| | | /** |
| | | * æ¥è¯¢æ¶é´ |
| | | */ |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @NotNull(message = "æªæ¾å°æ¶é´ä¿¡æ¯") |
| | | private Date dataTime; |
| | | |
| | | public String getIndexId() { |
| | | return indexId; |
| | | } |
| | | |
| | | public void setIndexId(String indexId) { |
| | | this.indexId = indexId; |
| | | } |
| | | |
| | | public String getTimeType() { |
| | | return timeType; |
| | | } |
| | | |
| | | public void setTimeType(String timeType) { |
| | | this.timeType = timeType; |
| | | } |
| | | |
| | | public Date getDataTime() { |
| | | return dataTime; |
| | | } |
| | | |
| | | public void setDataTime(Date dataTime) { |
| | | this.dataTime = dataTime; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.history.domain.vo; |
| | | |
| | | |
| | | import com.zhitan.common.annotation.Excel; |
| | | |
| | | /** |
| | | * åå²çæµæ°æ®è¿å Excel |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/7 |
| | | */ |
| | | public class HistoricalDataExcel { |
| | | |
| | | /** |
| | | * ç¹ä½åç§° |
| | | */ |
| | | @Excel(name = "ç¹ä½åç§°") |
| | | private String indexName; |
| | | |
| | | /** |
| | | * å¼ |
| | | */ |
| | | @Excel(name = "å¼") |
| | | private String value; |
| | | |
| | | /** |
| | | * 使ç¨é |
| | | */ |
| | | @Excel(name = "使ç¨é") |
| | | private String usedValue; |
| | | |
| | | /** |
| | | * æ¶é´ |
| | | */ |
| | | @Excel(name = "æ¶é´") |
| | | private String dataTime; |
| | | |
| | | |
| | | public String getIndexName() { |
| | | return indexName; |
| | | } |
| | | |
| | | public void setIndexName(String indexName) { |
| | | this.indexName = indexName; |
| | | } |
| | | |
| | | public String getDataTime() { |
| | | return dataTime; |
| | | } |
| | | |
| | | public void setDataTime(String dataTime) { |
| | | this.dataTime = dataTime; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getUsedValue() { |
| | | return usedValue; |
| | | } |
| | | |
| | | public void setUsedValue(String usedValue) { |
| | | this.usedValue = usedValue; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.history.domain.vo; |
| | | |
| | | |
| | | /** |
| | | * åå²çæµæ°æ®è¿å VO |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/7 |
| | | */ |
| | | public class HistoricalDataVO { |
| | | |
| | | /** |
| | | * ç¹ä½id |
| | | */ |
| | | private String indexId; |
| | | |
| | | /** |
| | | * ç¹ä½åç§° |
| | | */ |
| | | private String indexName; |
| | | |
| | | /** |
| | | * æ¶é´ |
| | | */ |
| | | private String dataTime; |
| | | |
| | | /** |
| | | * å¼ |
| | | */ |
| | | private String value; |
| | | |
| | | /** |
| | | * 使ç¨é |
| | | */ |
| | | private String usedValue; |
| | | |
| | | |
| | | public String getIndexId() { |
| | | return indexId; |
| | | } |
| | | |
| | | public void setIndexId(String indexId) { |
| | | this.indexId = indexId; |
| | | } |
| | | |
| | | public String getIndexName() { |
| | | return indexName; |
| | | } |
| | | |
| | | public void setIndexName(String indexName) { |
| | | this.indexName = indexName; |
| | | } |
| | | |
| | | public String getDataTime() { |
| | | return dataTime; |
| | | } |
| | | |
| | | public void setDataTime(String dataTime) { |
| | | this.dataTime = dataTime; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public void setValue(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getUsedValue() { |
| | | return usedValue; |
| | | } |
| | | |
| | | public void setUsedValue(String usedValue) { |
| | | this.usedValue = usedValue; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.realtimedata.data; |
| | | |
| | | import com.influxdb.client.InfluxDBClient; |
| | | import com.influxdb.client.InfluxDBClientFactory; |
| | | import com.influxdb.client.domain.HealthCheck; |
| | | import com.zhitan.common.enums.CollectionModes; |
| | | import com.zhitan.common.enums.RetrievalModes; |
| | | import com.zhitan.realtimedata.config.RtdbConfig; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | import com.zhitan.realtimedata.service.RealtimeDatabase; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * @author èæ°å¯ å®æ¶æ°æ®åºè®¿é®ç®¡ç. |
| | | */ |
| | | @Component |
| | | public class RealtimeDatabaseManager { |
| | | |
| | | private final RealtimeDatabase connection; |
| | | |
| | | private final Logger logger = LogManager.getLogger(RealtimeDatabaseManager.class); |
| | | |
| | | public RealtimeDatabaseManager(RtdbConfig config) { |
| | | connection = new VirtualRtdb(); |
| | | try { |
| | | InfluxDBClient influxDBClient = InfluxDBClientFactory.create(config.getHost(), |
| | | config.getToken().toCharArray(), config.getOrg(), config.getBucket()); |
| | | |
| | | logger.error("--------------------宿¶åºè¿æ¥æå--------------------"); |
| | | HealthCheck health = influxDBClient.health(); |
| | | if (health.getStatus() == HealthCheck.StatusEnum.FAIL) { |
| | | influxDBClient.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | | } |
| | | |
| | | public TagValue retrieve(String tagCode) { |
| | | List<String> tagCodes = new ArrayList<>(); |
| | | tagCodes.add(tagCode); |
| | | List<TagValue> tagValues = retrieve(tagCodes); |
| | | if (!tagValues.isEmpty()) { |
| | | return tagValues.get(0); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | public List<TagValue> retrieve(List<String> tagCodes) { |
| | | List<TagValue> tagValues = new ArrayList<>(); |
| | | try { |
| | | tagValues = connection.retrieve(tagCodes); |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | | |
| | | return tagValues; |
| | | } |
| | | |
| | | public TagValue retrieve(String tagCode, Date dataTime, String timeCode) { |
| | | List<String> tagCodes = new ArrayList<>(); |
| | | tagCodes.add(tagCode); |
| | | List<TagValue> tagValues = retrieve(tagCodes, dataTime, timeCode); |
| | | if (!tagValues.isEmpty()) { |
| | | return tagValues.get(0); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | public List<TagValue> retrieve(List<String> tagCodes, Date dataTime, String timeCode) { |
| | | List<TagValue> tagValues = new ArrayList<>(); |
| | | try { |
| | | List<TagValue> tmp = connection.retrieve(tagCodes, dataTime, timeCode); |
| | | for (String tagCode : tagCodes) { |
| | | Optional<TagValue> tagValue = tmp.stream() |
| | | .filter(f -> StringUtils.equalsIgnoreCase(f.getTagCode(), tagCode)).findAny(); |
| | | TagValue value; |
| | | if (!tagValue.isPresent()) { |
| | | value = new TagValue(); |
| | | value.setTagCode(tagCode); |
| | | value.setDataTime(dataTime); |
| | | } else { |
| | | value = tagValue.get(); |
| | | } |
| | | |
| | | tagValues.add(value); |
| | | } |
| | | } catch (Exception e1) { |
| | | logger.error(e1); |
| | | } |
| | | |
| | | return tagValues; |
| | | } |
| | | |
| | | public List<TagValue> retrieve(String tagCode, Date beginTime, Date endTime, |
| | | RetrievalModes retrievalModes, int pointCount) { |
| | | List<String> tagCodes = new ArrayList<>(); |
| | | tagCodes.add(tagCode); |
| | | return retrieve(tagCodes, beginTime, endTime, retrievalModes, pointCount); |
| | | } |
| | | |
| | | public List<TagValue> retrieve(List<String> tagCodes, Date beginTime, Date endTime, |
| | | RetrievalModes retrievalModes, int pointCount) { |
| | | List<TagValue> tagValues = new ArrayList<>(); |
| | | try { |
| | | tagValues = connection.retrieve(tagCodes, beginTime, endTime, retrievalModes, pointCount); |
| | | } catch (Exception e1) { |
| | | logger.error(e1); |
| | | } |
| | | |
| | | return tagValues; |
| | | } |
| | | |
| | | public TagValue statistics(String tagCode, Date beginTime, Date endTime, |
| | | CollectionModes collectionModes) { |
| | | List<String> tagCodes = new ArrayList<>(); |
| | | tagCodes.add(tagCode); |
| | | List<TagValue> tagValues = statistics(tagCodes, beginTime, endTime, collectionModes); |
| | | if (!tagValues.isEmpty()) { |
| | | return tagValues.get(0); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | public List<TagValue> statistics(List<String> tagCodes, Date beginTime, Date endTime, |
| | | CollectionModes collectionModes) { |
| | | List<TagValue> tagValues = new ArrayList<>(); |
| | | try { |
| | | tagValues = connection.statistics(tagCodes, beginTime, endTime, collectionModes); |
| | | } catch (Exception e1) { |
| | | logger.error(e1); |
| | | } |
| | | |
| | | return tagValues; |
| | | } |
| | | |
| | | public void storeData(List<TagValue> tagValues) { |
| | | try { |
| | | connection.storeData(tagValues); |
| | | } catch (Exception e1) { |
| | | logger.error(e1); |
| | | } |
| | | } |
| | | |
| | | public void insertData(List<TagValue> tagValues) { |
| | | try { |
| | | connection.insertData(tagValues); |
| | | } catch (Exception e1) { |
| | | logger.error(e1); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.zhitan.realtimedata.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | |
| | | * |
| | | */ |
| | | @Data |
| | | @TableName("sys_equipmentfile") |
| | | public class SysEquipmentFile { |
| | | |
| | | @TableId |
| | | private String nodeId; |
| | | |
| | | @TableField(value = "filepath") |
| | | private String filePath; |
| | | |
| | | @TableField(exist = false) |
| | | private String svgType; |
| | | |
| | | @TableField(exist = false) |
| | | private List<SysSvgInfo> infoList; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.realtimedata.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 设å¤çæµåæ°å表对象 |
| | | */ |
| | | @Data |
| | | public class EquipmentMeasuringPointParameters { |
| | | |
| | | private String code; |
| | | |
| | | private String indexName; |
| | | |
| | | private String indexUnit; |
| | | |
| | | private Double value; |
| | | |
| | | private String yValue; |
| | | |
| | | private String meteName; |
| | | |
| | | public String getyValue() { |
| | | return yValue; |
| | | } |
| | | |
| | | public void setyValue(String yValue) { |
| | | this.yValue = yValue; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.realtimedata.mapper; |
| | | |
| | | |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface SvgTrendMapper { |
| | | /** |
| | | * 宿¶æ£æµ åè½ çå¤ sheet页 å±ç¤º ç»æå¾ æµç¹ æ¥è¦ä¿¡æ¯ |
| | | * |
| | | * @param energyIndex |
| | | * @return |
| | | */ |
| | | List<EnergyIndex> selectSvgTrendList(EnergyIndex energyIndex); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.realtimedata.service; |
| | | |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface ISvgTrendService { |
| | | |
| | | /** |
| | | * 宿¶æ£æµ åè½ çå¤ sheet页 å±ç¤ºè¶å¿å¾ |
| | | * @param energyIndex |
| | | * @return |
| | | */ |
| | | List<EnergyIndex> selectSvgList(EnergyIndex energyIndex); |
| | | } |
| | |
| | | |
| | | |
| | | import com.zhitan.common.enums.CollectionModes; |
| | | import com.zhitan.common.enums.RetrievalModes; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | |
| | | import java.util.Date; |
| | |
| | | * @param tagValues æµç¹å岿¶å»æ°æ® |
| | | */ |
| | | void insertData(List<TagValue> tagValues); |
| | | |
| | | /** |
| | | * è·å䏿®µæ¶é´å
æµç¹çå岿°æ®. |
| | | * |
| | | * @param tagCode æµç¹ç¼å· |
| | | * @param beginTime å¼å§æ¶é´ |
| | | * @param endTime ç»ææ¶é´ |
| | | * @param retrievalModes æ¥è¯¢æ°æ®æ¹å¼ |
| | | * @param pointCount æµç¹å¾å°çæ°æ®ä¸ªæ° |
| | | * @return æµç¹å岿°æ® |
| | | */ |
| | | List<TagValue> retrieve(String tagCode, Date beginTime, Date endTime, |
| | | RetrievalModes retrievalModes, int pointCount); |
| | | } |
| | |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import com.zhitan.common.enums.CollectionModes; |
| | | import com.zhitan.common.enums.RetrievalModes; |
| | | import com.zhitan.realtimedata.data.RealtimeDatabaseManager; |
| | | import com.zhitan.realtimedata.data.influxdb.InfluxDBRepository; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | import com.zhitan.realtimedata.service.RealtimeDatabaseService; |
| | |
| | | |
| | | private final InfluxDBRepository repository; |
| | | |
| | | public RealtimeDatabaseServiceImpl(InfluxDBRepository repository) { |
| | | private final RealtimeDatabaseManager realtimeDatabaseManager; |
| | | |
| | | public RealtimeDatabaseServiceImpl(InfluxDBRepository repository, RealtimeDatabaseManager realtimeDatabaseManager) { |
| | | this.repository = repository; |
| | | this.realtimeDatabaseManager = realtimeDatabaseManager; |
| | | } |
| | | |
| | | /** |
| | |
| | | repository.store(tagValues); |
| | | } |
| | | |
| | | @Override |
| | | public List<TagValue> retrieve(String tagCode, Date beginTime, Date endTime, |
| | | RetrievalModes retrievalModes, int pointCount) { |
| | | return realtimeDatabaseManager.retrieve(tagCode, beginTime, endTime, retrievalModes, pointCount); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.realtimedata.service.impl; |
| | | |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.realtimedata.mapper.SvgTrendMapper; |
| | | import com.zhitan.realtimedata.service.ISvgTrendService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class SvgTrendServicelmpl implements ISvgTrendService { |
| | | |
| | | @Autowired |
| | | private SvgTrendMapper svgTrendMapper; |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ID |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public List<EnergyIndex> selectSvgList(EnergyIndex energyIndex) { |
| | | return svgTrendMapper.selectSvgTrendList(energyIndex); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.zhitan.common.annotation.Excel; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * æ°æ®åæç¯æ¯ 请æ±åæ° |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/3 |
| | | */ |
| | | @Data |
| | | public class DataAnalysisMoMDTO { |
| | | |
| | | |
| | | /** |
| | | * ç»è®¡å¼å§æ¶é´ |
| | | */ |
| | | @NotNull(message = "è¯·ç»´æ¤æ¥è¯¢æ¶é´") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "æ¥è¦å¼å§æ¶é´", dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date beginTime; |
| | | |
| | | /** |
| | | * ç»è®¡å¼å§æ¶é´ |
| | | */ |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "æ¥è¦å¼å§æ¶é´", dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | @NotNull(message = "è¯·ç»´æ¤æ¥è¯¢æ¶é´") |
| | | private Date endTime; |
| | | |
| | | /** |
| | | * æ¶é´ç±»å |
| | | */ |
| | | @NotBlank(message = "æªæ¾å°æ¶é´ç±»å") |
| | | private String timeType; |
| | | |
| | | /** |
| | | * 模åèç¹id |
| | | */ |
| | | @NotBlank(message = "æªæ¾å°æ¨¡åèç¹ä¿¡æ¯") |
| | | private String nodeId; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.vo; |
| | | |
| | | import com.zhitan.common.annotation.Excel; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * æ°æ®åæç¯æ¯ 导åºExcel |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/3 |
| | | */ |
| | | @Data |
| | | public class DataAnalysisMoMExcel { |
| | | |
| | | |
| | | /** |
| | | * ç¨è½åå
åç§° |
| | | */ |
| | | @Excel(name = "ç¨è½åå
") |
| | | private String energyUnitName; |
| | | |
| | | /** |
| | | * æ¬æå¼ |
| | | */ |
| | | @Excel(name = "æ¬æå¼") |
| | | private BigDecimal currentValue; |
| | | |
| | | /** |
| | | * åæå¼ |
| | | */ |
| | | @Excel(name = "åæå¼") |
| | | private BigDecimal oldValue; |
| | | |
| | | /** |
| | | * åæ¯å¼ |
| | | */ |
| | | @Excel(name = "忝å¼") |
| | | private BigDecimal ratio; |
| | | |
| | | /** |
| | | * åä½ |
| | | */ |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.vo; |
| | | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * æ°æ®åæç¯æ¯ è¿åvo |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/3 |
| | | */ |
| | | @Data |
| | | public class DataAnalysisMoMVO { |
| | | |
| | | |
| | | /** |
| | | * åä½ |
| | | */ |
| | | private String unit; |
| | | |
| | | /** |
| | | * ç¨è½åå
åç§° |
| | | */ |
| | | private String energyUnitName; |
| | | |
| | | /** |
| | | * æ¬æå¼ |
| | | */ |
| | | private BigDecimal currentValue; |
| | | |
| | | /** |
| | | * åæå¼ |
| | | */ |
| | | private BigDecimal oldValue; |
| | | |
| | | /** |
| | | * åæ¯å¼ |
| | | */ |
| | | private BigDecimal ratio; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.vo; |
| | | |
| | | import com.zhitan.common.annotation.Excel; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * æ°æ®åæåæ¯ å¯¼åºExcel |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/3 |
| | | */ |
| | | @Data |
| | | public class DataAnalysisYoYExcel { |
| | | |
| | | |
| | | /** |
| | | * ç¨è½åå
åç§° |
| | | */ |
| | | @Excel(name = "ç¨è½åå
åç§°") |
| | | private String energyUnitName; |
| | | |
| | | /** |
| | | * æ¬æå¼ |
| | | */ |
| | | @Excel(name = "æ¬æå¼") |
| | | private BigDecimal currentValue; |
| | | |
| | | /** |
| | | * åæå¼ |
| | | */ |
| | | @Excel(name = "åæå¼") |
| | | private BigDecimal oldValue; |
| | | |
| | | /** |
| | | * åæ¯å¼ |
| | | */ |
| | | @Excel(name = "忝å¼") |
| | | private BigDecimal ratio; |
| | | |
| | | /** |
| | | * åä½ |
| | | */ |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.vo; |
| | | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * æ°æ®åæåæ¯ è¿åvo |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/3 |
| | | */ |
| | | @Data |
| | | public class DataAnalysisYoYVO { |
| | | |
| | | |
| | | /** |
| | | * åä½ |
| | | */ |
| | | private String unit; |
| | | |
| | | /** |
| | | * ç¨è½åå
åç§° |
| | | */ |
| | | private String energyUnitName; |
| | | |
| | | /** |
| | | * æ¬æå¼ |
| | | */ |
| | | private BigDecimal currentValue; |
| | | |
| | | /** |
| | | * åæå¼ |
| | | */ |
| | | private BigDecimal oldValue; |
| | | |
| | | /** |
| | | * åæ¯å¼ |
| | | */ |
| | | private BigDecimal ratio; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.service; |
| | | |
| | | import com.zhitan.statisticalAnalysis.domain.dto.DataAnalysisMoMDTO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisMoMVO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisYoYVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç»è®¡åæ æ¥å£å± |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/3/1 |
| | | */ |
| | | public interface IStatisticalAnalysisService { |
| | | |
| | | /** |
| | | * è·åçµè½èåæ¯æ°æ® |
| | | */ |
| | | List<DataAnalysisYoYVO> listElectricDataComparisonYoY(DataAnalysisMoMDTO dto); |
| | | |
| | | /** |
| | | * è·åçµè½èç¯æ¯æ°æ® |
| | | */ |
| | | List<DataAnalysisMoMVO> listElectricDataComparisonMoM(DataAnalysisMoMDTO dto); |
| | | |
| | | /** |
| | | * è·åè½èåæ¯æ°æ® |
| | | */ |
| | | List<DataAnalysisYoYVO> listWaterDataComparisonYoY(DataAnalysisMoMDTO dto); |
| | | |
| | | /** |
| | | * è·åè½èç¯æ¯æ°æ® |
| | | */ |
| | | List<DataAnalysisMoMVO> listWaterDataComparisonMoM(DataAnalysisMoMDTO dto); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateField; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.constant.TimeTypeConst; |
| | | import com.zhitan.common.enums.TimeType; |
| | | import com.zhitan.dataitem.service.IDataItemService; |
| | | import com.zhitan.model.domain.vo.ModelNodeIndexInfor; |
| | | import com.zhitan.model.service.IModelNodeService; |
| | | import com.zhitan.realtimedata.domain.DataItem; |
| | | import com.zhitan.statisticalAnalysis.domain.dto.DataAnalysisMoMDTO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisMoMVO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.DataAnalysisYoYVO; |
| | | import com.zhitan.statisticalAnalysis.service.IStatisticalAnalysisService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * ç»è®¡åæ æ¥å£å±å®ç°å± |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class StatisticalAnalysisServiceImpl implements IStatisticalAnalysisService { |
| | | |
| | | private final IDataItemService dataItemService; |
| | | |
| | | private final IModelNodeService modelNodeService; |
| | | |
| | | |
| | | /** |
| | | * è·åçµè½èåæ¯æ°æ® |
| | | */ |
| | | @Override |
| | | public List<DataAnalysisYoYVO> listElectricDataComparisonYoY(DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisYoYVO> yoyList = new ArrayList<>(); |
| | | // æ¥è¯¢ç¹ä½ä¸ç¨è½åå
ä¿¡æ¯ |
| | | List<ModelNodeIndexInfor> nodeInforList = listModelNodeIndexIdRelationInfor(dto.getNodeId()); |
| | | if (CollectionUtils.isEmpty(nodeInforList)) { |
| | | return yoyList; |
| | | } |
| | | List<String> indexIds = nodeInforList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | // æç
§ç¹ä½è¿è¡åç» |
| | | Map<String, List<ModelNodeIndexInfor>> nodeIndexMap = nodeInforList.stream().collect( |
| | | Collectors.groupingBy(ModelNodeIndexInfor::getNodeId)); |
| | | // è·åæ¥è¯¢æ¶é´ |
| | | Date beginTime = dto.getBeginTime(); |
| | | Date endTime = dto.getEndTime(); |
| | | // 忝æ¶é´ |
| | | Date lastTime = DateUtil.offset(beginTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | Date lastEndTime = DateUtil.offset(endTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | // æ¥è¯¢å¯¹åºindexIdsï¼æ¾å°å¯¹åºdataItemä¿¡æ¯ |
| | | List<DataItem> dataItemList = dataItemService.getDataItemHourInforByIndexIds(beginTime, endTime, TimeType.HOUR.name(), indexIds); |
| | | List<DataItem> lastDataItemList = dataItemService.getDataItemHourInforByIndexIds(lastTime, lastEndTime, TimeType.HOUR.name(), indexIds); |
| | | // åç |
| | | BigDecimal multiple = BigDecimal.valueOf(CommonConst.DIGIT_100); |
| | | nodeIndexMap.forEach((key, value) -> { |
| | | DataAnalysisYoYVO yoyVO = new DataAnalysisYoYVO(); |
| | | Optional<ModelNodeIndexInfor> first = value.stream().findFirst(); |
| | | first.ifPresent(modelNodeIndexInfor -> yoyVO.setEnergyUnitName(modelNodeIndexInfor.getName())); |
| | | // èµå¼åä½ |
| | | yoyVO.setUnit("kWh"); |
| | | // æ¾åºindexIds |
| | | List<String> indexIdList = value.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | // æ±å |
| | | BigDecimal sum = BigDecimal.valueOf(dataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | BigDecimal lastSum = BigDecimal.valueOf(lastDataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | yoyVO.setCurrentValue(sum); |
| | | yoyVO.setOldValue(lastSum); |
| | | // åæ¯å¼ |
| | | BigDecimal ratio = BigDecimal.ZERO; |
| | | if (lastSum.compareTo(BigDecimal.ZERO) != 0) { |
| | | ratio = sum.subtract(lastSum).divide(lastSum, CommonConst.DIGIT_2, RoundingMode.HALF_UP).multiply(multiple); |
| | | } |
| | | yoyVO.setRatio(ratio); |
| | | yoyList.add(yoyVO); |
| | | }); |
| | | return yoyList; |
| | | } |
| | | |
| | | /** |
| | | * è·åçµè½èç¯æ¯æ°æ® |
| | | */ |
| | | @Override |
| | | public List<DataAnalysisMoMVO> listElectricDataComparisonMoM(DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisMoMVO> momList = new ArrayList<>(); |
| | | // æ ¹æ®idæ¥è¯¢ç¹ä½ä¿¡æ¯ |
| | | List<ModelNodeIndexInfor> nodeIndexInforList = listModelNodeIndexIdRelationInfor(dto.getNodeId()); |
| | | if (CollectionUtils.isEmpty(nodeIndexInforList)) { |
| | | return momList; |
| | | } |
| | | List<String> indexIds = nodeIndexInforList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | Date beginTime = dto.getBeginTime(); |
| | | Date endTime = dto.getEndTime(); |
| | | Date lastTime; |
| | | Date lastEndTime; |
| | | String queryTimeType = dto.getTimeType(); |
| | | // å°æ¶ |
| | | if (TimeTypeConst.TIME_TYPE_HOUR.equals(queryTimeType)) { |
| | | lastTime = DateUtil.offsetHour(beginTime, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offsetHour(endTime, CommonConst.DIGIT_MINUS_1); |
| | | // 天 |
| | | } else if (TimeTypeConst.TIME_TYPE_DAY.equals(queryTimeType)) { |
| | | lastTime = DateUtil.offsetDay(beginTime, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offsetDay(endTime, CommonConst.DIGIT_MINUS_1); |
| | | // æ |
| | | } else if (TimeTypeConst.TIME_TYPE_MONTH.equals(queryTimeType)) { |
| | | lastTime = DateUtil.offsetMonth(beginTime, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offsetMonth(endTime, CommonConst.DIGIT_MINUS_1); |
| | | // å¹´ |
| | | } else { |
| | | lastTime = DateUtil.offset(beginTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offset(endTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | } |
| | | // æç
§ç¹ä½è¿è¡åç» |
| | | Map<String, List<ModelNodeIndexInfor>> nodeIndexMap = nodeIndexInforList.stream().collect( |
| | | Collectors.groupingBy(ModelNodeIndexInfor::getNodeId)); |
| | | // æ ¹æ®indexIdæ¥è¯¢dataItem |
| | | List<DataItem> dataItemList = dataItemService.getDataItemHourInforByIndexIds(beginTime, endTime, TimeType.HOUR.name(), indexIds); |
| | | List<DataItem> lastDataItemList = dataItemService.getDataItemHourInforByIndexIds(lastTime, lastEndTime, TimeType.HOUR.name(), indexIds); |
| | | // åç |
| | | BigDecimal multiple = BigDecimal.valueOf(CommonConst.DIGIT_100); |
| | | nodeIndexMap.forEach((key, value) -> { |
| | | DataAnalysisMoMVO momVO = new DataAnalysisMoMVO(); |
| | | Optional<ModelNodeIndexInfor> first = value.stream().findFirst(); |
| | | first.ifPresent(modelNodeIndexInfor -> momVO.setEnergyUnitName(modelNodeIndexInfor.getName())); |
| | | // èµå¼åä½ |
| | | momVO.setUnit("kWh"); |
| | | // æ¾åºindexIds |
| | | List<String> indexIdList = value.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | // æ±å |
| | | BigDecimal sum = BigDecimal.valueOf(dataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | BigDecimal lastSum = BigDecimal.valueOf(lastDataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | momVO.setCurrentValue(sum); |
| | | momVO.setOldValue(lastSum); |
| | | // åæ¯å¼ |
| | | BigDecimal ratio = BigDecimal.ZERO; |
| | | if (lastSum.compareTo(BigDecimal.ZERO) != 0) { |
| | | ratio = sum.subtract(lastSum).divide(lastSum, CommonConst.DIGIT_2, RoundingMode.HALF_UP).multiply(multiple); |
| | | } |
| | | momVO.setRatio(ratio); |
| | | momList.add(momVO); |
| | | }); |
| | | return momList; |
| | | } |
| | | |
| | | /** |
| | | * è·åè½èåæ¯æ°æ® |
| | | */ |
| | | @Override |
| | | public List<DataAnalysisYoYVO> listWaterDataComparisonYoY(DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisYoYVO> yoyList = new ArrayList<>(); |
| | | // æ¥è¯¢ç¹ä½ä¸ç¨è½åå
ä¿¡æ¯ |
| | | List<ModelNodeIndexInfor> nodeInforList = listModelNodeIndexIdRelationInfor(dto.getNodeId()); |
| | | if (CollectionUtils.isEmpty(nodeInforList)) { |
| | | return yoyList; |
| | | } |
| | | List<String> indexIds = nodeInforList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | // æç
§ç¹ä½è¿è¡åç» |
| | | Map<String, List<ModelNodeIndexInfor>> nodeIndexMap = nodeInforList.stream().collect( |
| | | Collectors.groupingBy(ModelNodeIndexInfor::getNodeId)); |
| | | // æ¶é´ç±»å |
| | | // è·åæ¥è¯¢æ¶é´ |
| | | Date beginTime = dto.getBeginTime(); |
| | | Date endTime = dto.getEndTime(); |
| | | // 忝æ¶é´ |
| | | Date lastTime = DateUtil.offset(beginTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | Date lastEndTime = DateUtil.offset(endTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | // æ¥è¯¢å¯¹åºindexIdsï¼æ¾å°å¯¹åºdataItemä¿¡æ¯ |
| | | List<DataItem> dataItemList = dataItemService.getDataItemHourInforByIndexIds(beginTime, endTime, TimeType.HOUR.name(), indexIds); |
| | | List<DataItem> lastDataItemList = dataItemService.getDataItemHourInforByIndexIds(lastTime, lastEndTime, TimeType.HOUR.name(), indexIds); |
| | | // åç |
| | | BigDecimal multiple = BigDecimal.valueOf(CommonConst.DIGIT_100); |
| | | nodeIndexMap.forEach((key, value) -> { |
| | | DataAnalysisYoYVO yoyVO = new DataAnalysisYoYVO(); |
| | | Optional<ModelNodeIndexInfor> first = value.stream().findFirst(); |
| | | first.ifPresent(modelNodeIndexInfor -> yoyVO.setEnergyUnitName(modelNodeIndexInfor.getName())); |
| | | // èµå¼åä½ |
| | | yoyVO.setUnit("m³"); |
| | | // æ¾åºindexIds |
| | | List<String> indexIdList = value.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | // æ±å |
| | | BigDecimal sum = BigDecimal.valueOf(dataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | BigDecimal lastSum = BigDecimal.valueOf(lastDataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | yoyVO.setCurrentValue(sum); |
| | | yoyVO.setOldValue(lastSum); |
| | | // åæ¯å¼ |
| | | BigDecimal ratio = BigDecimal.ZERO; |
| | | if (lastSum.compareTo(BigDecimal.ZERO) != 0) { |
| | | ratio = sum.subtract(lastSum).divide(lastSum, CommonConst.DIGIT_2, RoundingMode.HALF_UP).multiply(multiple); |
| | | } |
| | | yoyVO.setRatio(ratio); |
| | | yoyList.add(yoyVO); |
| | | }); |
| | | return yoyList; |
| | | } |
| | | |
| | | /** |
| | | * è·åè½èç¯æ¯æ°æ® |
| | | */ |
| | | @Override |
| | | public List<DataAnalysisMoMVO> listWaterDataComparisonMoM(DataAnalysisMoMDTO dto) { |
| | | List<DataAnalysisMoMVO> momList = new ArrayList<>(); |
| | | // æ ¹æ®idæ¥è¯¢ç¹ä½ä¿¡æ¯ |
| | | List<ModelNodeIndexInfor> nodeIndexInforList = listModelNodeIndexIdRelationInfor(dto.getNodeId()); |
| | | if (CollectionUtils.isEmpty(nodeIndexInforList)) { |
| | | return momList; |
| | | } |
| | | List<String> indexIds = nodeIndexInforList.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | Date beginTime = dto.getBeginTime(); |
| | | Date endTime = dto.getEndTime(); |
| | | Date lastTime; |
| | | Date lastEndTime; |
| | | String queryTimeType = dto.getTimeType(); |
| | | // å°æ¶ |
| | | if (TimeTypeConst.TIME_TYPE_HOUR.equals(queryTimeType)) { |
| | | lastTime = DateUtil.offsetHour(beginTime, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offsetHour(endTime, CommonConst.DIGIT_MINUS_1); |
| | | // 天 |
| | | } else if (TimeTypeConst.TIME_TYPE_DAY.equals(queryTimeType)) { |
| | | lastTime = DateUtil.offsetDay(beginTime, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offsetDay(endTime, CommonConst.DIGIT_MINUS_1); |
| | | // æ |
| | | } else if (TimeTypeConst.TIME_TYPE_MONTH.equals(queryTimeType)) { |
| | | lastTime = DateUtil.offsetMonth(beginTime, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offsetMonth(endTime, CommonConst.DIGIT_MINUS_1); |
| | | // å¹´ |
| | | } else { |
| | | lastTime = DateUtil.offset(beginTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | lastEndTime = DateUtil.offset(endTime, DateField.YEAR, CommonConst.DIGIT_MINUS_1); |
| | | } |
| | | // æç
§ç¹ä½è¿è¡åç» |
| | | Map<String, List<ModelNodeIndexInfor>> nodeIndexMap = nodeIndexInforList.stream().collect( |
| | | Collectors.groupingBy(ModelNodeIndexInfor::getNodeId)); |
| | | // æ¥è¯¢å¯¹åºindexIdsï¼æ¾å°å¯¹åºdataItemä¿¡æ¯ |
| | | List<DataItem> dataItemList = dataItemService.getDataItemHourInforByIndexIds(beginTime, endTime, TimeType.HOUR.name(), indexIds); |
| | | List<DataItem> lastDataItemList = dataItemService.getDataItemHourInforByIndexIds(lastTime, lastEndTime, TimeType.HOUR.name(), indexIds); |
| | | // åç |
| | | BigDecimal multiple = BigDecimal.valueOf(CommonConst.DIGIT_100); |
| | | nodeIndexMap.forEach((key, value) -> { |
| | | DataAnalysisMoMVO momVO = new DataAnalysisMoMVO(); |
| | | Optional<ModelNodeIndexInfor> first = value.stream().findFirst(); |
| | | first.ifPresent(modelNodeIndexInfor -> momVO.setEnergyUnitName(modelNodeIndexInfor.getName())); |
| | | // èµå¼åä½ |
| | | momVO.setUnit("m³"); |
| | | // æ¾åºindexIds |
| | | List<String> indexIdList = value.stream().map(ModelNodeIndexInfor::getIndexId).collect(Collectors.toList()); |
| | | // æ±å |
| | | BigDecimal sum = BigDecimal.valueOf(dataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | BigDecimal lastSum = BigDecimal.valueOf(lastDataItemList.stream().filter(li -> indexIdList.contains(li.getIndexId())) |
| | | .mapToDouble(DataItem::getValue).sum()).setScale(CommonConst.DIGIT_2, RoundingMode.HALF_UP); |
| | | momVO.setCurrentValue(sum); |
| | | momVO.setOldValue(lastSum); |
| | | // åæ¯å¼ |
| | | BigDecimal ratio = BigDecimal.ZERO; |
| | | if (lastSum.compareTo(BigDecimal.ZERO) != 0) { |
| | | ratio = sum.subtract(lastSum).divide(lastSum, CommonConst.DIGIT_2, RoundingMode.HALF_UP).multiply(multiple); |
| | | } |
| | | momVO.setRatio(ratio); |
| | | momList.add(momVO); |
| | | }); |
| | | return momList; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¹ä½ä¸ç¨è½åå
ä¿¡æ¯ |
| | | */ |
| | | private List<ModelNodeIndexInfor> listModelNodeIndexIdRelationInfor(String nodeId) { |
| | | List<ModelNodeIndexInfor> nodeInforList = modelNodeService.listModelNodeIndexIdRelationInforByParentId(nodeId); |
| | | // 妿æ¯ç©ºåå¨ä¸¤ç§æ
åµï¼1ï¼idæé®é¢ï¼2ï¼æåºå± |
| | | if (CollectionUtils.isEmpty(nodeInforList)) { |
| | | List<ModelNodeIndexInfor> inforList = modelNodeService.getModelNodeIndexIdRelationInforByNodeId(nodeId); |
| | | if (CollectionUtils.isNotEmpty(inforList)) { |
| | | nodeInforList.addAll(inforList); |
| | | } |
| | | } |
| | | return nodeInforList; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zhitan.basicSetup.mapper.SysEquipmentfileMapper"> |
| | | <resultMap id="SysEquipmentFile" |
| | | type="com.zhitan.realtimedata.domain.SysEquipmentFile"> |
| | | <result property="nodeId" column="node_id"/> |
| | | <result property="filePath" column="filepath"/> |
| | | </resultMap> |
| | | <resultMap id="SysSvgInfo" |
| | | type="com.zhitan.realtimedata.domain.SysSvgInfo"> |
| | | <result property="id" column="id"/> |
| | | <result property="param" column="param"/> |
| | | <result property="tag" column="tag"/> |
| | | </resultMap> |
| | | |
| | | <insert id="saveSettingInfo"> |
| | | delete |
| | | from sys_svg_info |
| | | where node_id = #{nodeId}; |
| | | |
| | | <foreach collection="svgInfo" item="info" separator=";"> |
| | | insert into sys_svg_info (id, node_id, param, tag) |
| | | values (#{info.id}, #{nodeId}, #{info.param}, #{info.tag}); |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <update id="saveEquipmentFile"> |
| | | INSERT INTO sys_equipmentfile (node_id, filepath) |
| | | VALUES(#{nodeId}, #{filePath}) ON CONFLICT (node_id) DO |
| | | UPDATE |
| | | SET filepath = excluded.filepath |
| | | </update> |
| | | |
| | | <select id="getConfigure" resultMap="SysEquipmentFile"> |
| | | select node_id, filepath |
| | | from sys_equipmentfile |
| | | where node_id = #{nodeId}; |
| | | </select> |
| | | |
| | | <select id="getConfigureTag" resultMap="SysSvgInfo"> |
| | | select id, param, tag |
| | | from sys_svg_info |
| | | where node_id = #{nodeId} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zhitan.dataitem.mapper.DataItemMapper"> |
| | | <resultMap type="StagseDataEntry" id="stagseDataEntryResult"> |
| | | <resultMap type="com.zhitan.dataitem.domain.StagseDataEntry" id="stagseDataEntryResult"> |
| | | <result property="code" column="code"/> |
| | | <result property="name" column="name"/> |
| | | <result property="indexId" column="index_id"/> |
| | |
| | | <result property="dataTime" column="data_time"/> |
| | | </resultMap> |
| | | |
| | | <select id="getSettingIndex" parameterType="StagseDataEntry" resultMap="stagseDataEntryResult"> |
| | | <select id="getSettingIndex" parameterType="com.zhitan.dataitem.domain.StagseDataEntry" resultMap="stagseDataEntryResult"> |
| | | |
| | | SELECT |
| | | ei.index_id, |
| | |
| | | and si.time_type = #{timeType} |
| | | AND si.calc_type = #{calcType} |
| | | </select> |
| | | <select id="getSettingEdit" parameterType="StagseDataEntry" resultMap="stagseDataEntryResult"> |
| | | <select id="getSettingEdit" parameterType="com.zhitan.dataitem.domain.StagseDataEntry" resultMap="stagseDataEntryResult"> |
| | | SELECT |
| | | ei.index_id, |
| | | code, |
| | |
| | | AND data_time >= #{beginTime} |
| | | AND data_time <= #{endTime} |
| | | </select> |
| | | <select id="stagseDataByCode" parameterType="StagseDataEntry" resultMap="stagseDataEntryResult"> |
| | | <select id="stagseDataByCode" parameterType="com.zhitan.dataitem.domain.StagseDataEntry" resultMap="stagseDataEntryResult"> |
| | | SELECT |
| | | ei.index_id, |
| | | code, |
| | |
| | | AND di.data_time BETWEEN #{beginTime} AND #{endTime} |
| | | AND di.time_type = #{timeType} |
| | | </select> |
| | | |
| | | <select id="getDataItemHourInforByIndexIds" resultType="com.zhitan.realtimedata.domain.DataItem"> |
| | | SELECT |
| | | index_id indexId, |
| | | data_time dataTime, |
| | | "value" |
| | | FROM |
| | | "data_item" |
| | | WHERE |
| | | index_id IN |
| | | <foreach collection="indexIds" item="indexId" open="(" separator="," close=")"> |
| | | #{indexId} |
| | | </foreach> |
| | | AND ( begin_time BETWEEN #{beginTime} AND #{endTime} ) |
| | | AND time_type = #{timeType} |
| | | </select> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zhitan.realtimedata.mapper.SvgTrendMapper"> |
| | | <resultMap type="com.zhitan.model.domain.EnergyIndex" id="EnergyIndexResult"> |
| | | <result property="indexId" column="index_id"/> |
| | | <result property="name" column="name"/> |
| | | <result property="code" column="code"/> |
| | | <result property="indexType" column="index_type"/> |
| | | <result property="indexCategory" column="index_category"/> |
| | | <result property="remark" column="remark"/> |
| | | <result property="unitId" column="unit_id"/> |
| | | <result property="meterId" column="meter_id"/> |
| | | <result property="meterName" column="meter_name"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectSvgTrendList" parameterType="com.zhitan.model.domain.EnergyIndex" resultMap="EnergyIndexResult"> |
| | | select ei.index_id, name, ei.code, index_type, ei.remark, ei.unit_id, index_category,meter_name |
| | | from |
| | | energy_index ei, |
| | | sys_svg_info svg, |
| | | meter_implement as me |
| | | <where> |
| | | ei.code = svg.tag |
| | | and ei.meter_id = me.id |
| | | <if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if> |
| | | <if test="code != null and code != ''">and ei.code like concat('%', #{code}, '%')</if> |
| | | <if test="indexType != null">and index_type = #{indexType}</if> |
| | | <if test="nodeId != null and nodeId != ''">and svg.node_id = #{nodeId}</if> |
| | | <if test="indexCategory != null and indexCategory != ''">and index_category = |
| | | #{indexCategory} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |