!57 能源流向分析
Merge pull request !57 from DYL0109/dyl_dev
已添加33个文件
已删除4个文件
已修改16个文件
| | |
| | | package com.zhitan.web.controller.common; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.zhitan.common.config.BaseConfig; |
| | | import com.zhitan.common.constant.Constants; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.utils.StringUtils; |
| | | import com.zhitan.common.utils.file.FileUploadUtils; |
| | | import com.zhitan.common.utils.file.FileUtils; |
| | | import com.zhitan.framework.config.ServerConfig; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.http.MediaType; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.zhitan.common.config.BaseConfig; |
| | | import com.zhitan.common.constant.Constants; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.utils.StringUtils; |
| | | import com.zhitan.common.utils.file.FileUploadUtils; |
| | | import com.zhitan.common.utils.file.FileUtils; |
| | | import com.zhitan.framework.config.ServerConfig; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * éç¨è¯·æ±å¤ç |
| | |
| | | private ServerConfig serverConfig; |
| | | |
| | | private static final String FILE_DELIMETER = ","; |
| | | |
| | | @Resource |
| | | private BaseConfig baseConfig; |
| | | |
| | | /** |
| | | * éç¨ä¸è½½è¯·æ± |
| | |
| | | String filePath = BaseConfig.getUploadPath(); |
| | | // ä¸ä¼ å¹¶è¿åæ°æä»¶åç§° |
| | | String fileName = FileUploadUtils.upload(filePath, file); |
| | | String url = serverConfig.getUrl() + fileName; |
| | | String url = baseConfig.getDomainName() + fileName; |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | ajax.put("url", url); |
| | | ajax.put("fileName", fileName); |
| | |
| | | package com.zhitan.web.controller.energyMonitor; |
| | | |
| | | import com.zhitan.common.annotation.Log; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.core.controller.BaseController; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.energyMonitor.service.IEnergyUnitToDeviceService; |
| | | import com.zhitan.energyMonitor.domain.vo.ListElectricLoadVO; |
| | | import com.zhitan.energyMonitor.service.IElectricLoadService; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.model.service.IEnergyIndexService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @Slf4j |
| | | public class ElectricLoadController extends BaseController { |
| | | @Autowired |
| | | private IEnergyUnitToDeviceService energyUnitToDeviceService; |
| | | // @Autowired |
| | | // private IElectricLoadService electricLoadService; |
| | | 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 |
| | | * @param nodeId ç¨è½åå
id |
| | | * @param meterId çµè¡¨id |
| | | * @param timeType æ¶é´ç±»å DAY/MONTH/YEAR |
| | | * @param timeCode æ¶é´å¼ 䏿¶é´ç±»å对åºï¼2022-03-21/2022-03/2022 |
| | | */ |
| | | @Log(title = "æ ¹æ®çµè¡¨idè·åè´è·åææ°æ®") |
| | | @ApiOperation(value = "æ ¹æ®çµè¡¨idè·åè´è·åææ°æ®", notes = "æ ¹æ®çµè¡¨idè·åè´è·åææ°æ®") |
| | | @GetMapping(value = "/detail") |
| | | public AjaxResult list(@RequestParam(name = "energyUnitId") String energyUnitId, |
| | | public AjaxResult list(@RequestParam(name = "nodeId") String nodeId, |
| | | @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); |
| | | EnergyIndex energyIndex = energyIndexService.getDeviceIndexByCode(nodeId, meterId, CommonConst.TAG_CODE_ZYGGL); |
| | | |
| | | ListElectricLoadVO vo = electricLoadService.list(timeType, timeCode, energyIndex); |
| | | return AjaxResult.success(vo); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.web.controller.energyMonitor; |
| | | |
| | | import com.zhitan.common.annotation.Log; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.core.controller.BaseController; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.energyMonitor.service.IElectricPowerFactorService; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | 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("/powerFactorAnalysis") |
| | | @Slf4j |
| | | public class ElectricPowerFactorController extends BaseController { |
| | | |
| | | @Autowired |
| | | private IElectricPowerFactorService electricPowerFactorService; |
| | | |
| | | @Autowired |
| | | private IEnergyIndexService energyIndexService; |
| | | |
| | | /** |
| | | * æ ¹æ®çµè¡¨idè·ååçå æ°æ°æ® |
| | | * |
| | | * @param nodeId èç¹id |
| | | * @param meterId çµè¡¨id |
| | | * @param timeCode æ¶é´å¼ 䏿¶é´ç±»å对åºï¼2022-03-21 |
| | | */ |
| | | @Log(title = "æ ¹æ®çµè¡¨idè·ååçå æ°æ°æ®") |
| | | @ApiOperation(value = "æ ¹æ®çµè¡¨idè·ååçå æ°æ°æ®", notes = "æ ¹æ®çµè¡¨idè·ååçå æ°æ°æ®") |
| | | @GetMapping(value = "/detail") |
| | | public AjaxResult list(@RequestParam(name = "nodeId") String nodeId, |
| | | @RequestParam(name = "meterId") String meterId, |
| | | @RequestParam(name = "timeCode") String timeCode) { |
| | | EnergyIndex energyIndex = energyIndexService.getDeviceIndexByCode(nodeId, meterId, CommonConst.TAG_CODE_GLYS); |
| | | |
| | | return AjaxResult.success(electricPowerFactorService.list(timeCode, energyIndex)); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.IElectricThreePhaseService; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.model.service.IEnergyIndexService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: ä¸ç¸ä¸å¹³è¡¡ |
| | | * @Author: yxw |
| | | * @Date: 2022-04-24 |
| | | * @Version: V1.2 |
| | | */ |
| | | @Api(tags = "ä¸ç¸ä¸å¹³è¡¡") |
| | | @RestController |
| | | @RequestMapping("/threePhaseUnbalanceAnalysis") |
| | | @Slf4j |
| | | public class ElectricThreePhaseController extends BaseController { |
| | | |
| | | @Autowired |
| | | private IElectricThreePhaseService electricThreePhaseService; |
| | | @Autowired |
| | | private IEnergyIndexService energyIndexService; |
| | | |
| | | /** |
| | | * è·åç¨è½åå
ä¸çæä¸ªçµè¡¨çä¸ç¸ä¸å¹³è¡¡æ°æ® |
| | | * |
| | | * @param nodeId èç¹id |
| | | * @param meterId çµè¡¨id |
| | | * @param timeType æ¶é´ç±»å DAY/MONTH/YEAR |
| | | * @param timeCode æ¶é´å¼ 䏿¶é´ç±»å对åºï¼2022-03-21/2022-03/2022 |
| | | * @param requestType 请æ±ç±»åï¼0.çµåï¼1.çµæµ |
| | | * @return |
| | | */ |
| | | @Log(title = "æ ¹æ®çµè¡¨idæ¥è¯¢ä¸ç¸ä¸å¹³è¡¡æ°æ®") |
| | | @ApiOperation(value = "æ ¹æ®çµè¡¨idæ¥è¯¢ä¸ç¸ä¸å¹³è¡¡æ°æ®", notes = "æ ¹æ®çµè¡¨idæ¥è¯¢ä¸ç¸ä¸å¹³è¡¡æ°æ®") |
| | | @GetMapping(value = "/detail") |
| | | public AjaxResult list(@RequestParam(name = "nodeId") String nodeId, |
| | | @RequestParam(name = "meterId") String meterId, |
| | | @RequestParam(name = "timeType") String timeType, |
| | | @RequestParam(name = "timeCode") String timeCode, |
| | | @RequestParam(name = "requestType") String requestType) { |
| | | if (ObjectUtils.isEmpty(meterId)){ |
| | | return AjaxResult.error("çµè¡¨idä¸è½ä¸ºç©º"); |
| | | } |
| | | List<EnergyIndex> energyIndexList = energyIndexService.listDeviceIndex(nodeId, meterId); |
| | | |
| | | return AjaxResult.success(electricThreePhaseService.list(timeType, timeCode, energyIndexList, requestType, meterId)); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.web.controller.statisticalAnalysis; |
| | | |
| | | import com.zhitan.common.annotation.Log; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.dataitem.service.IDataItemService; |
| | | import com.zhitan.statisticalAnalysis.domain.dto.FlowChartsDTO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | |
| | | /** |
| | | * è½èç»è®¡åæ |
| | | */ |
| | | @Api(tags = "è½èç»è®¡åæ") |
| | | @RestController |
| | | @RequestMapping("/statisticsAnalysis") |
| | | public class EnergyDataItemController { |
| | | |
| | | @Autowired |
| | | private IDataItemService dataItemService; |
| | | |
| | | /** |
| | | * è·åè½æµå¾å½¢åæ |
| | | * |
| | | * @param dto 请æ±åæ° |
| | | * @return ç»æ |
| | | */ |
| | | @Log(title = "è·åè½æµå¾å½¢åæ") |
| | | @ApiOperation(value = "è·åè½æµå¾å½¢åæ", notes = "è·åè½æµå¾å½¢åæ") |
| | | @GetMapping(value = "/getFlowCharts") |
| | | public AjaxResult getFlowCharts(@Validated FlowChartsDTO dto) { |
| | | return AjaxResult.success(dataItemService.getFlowCharts(dto)); |
| | | } |
| | | } |
| | |
| | | addressEnabled: true |
| | | # éªè¯ç ç±»å math æ°åè®¡ç® char å符éªè¯ |
| | | captchaType: math |
| | | # ååå°å |
| | | domainName: https://demo-ems.zhitancloud.com/prod-api |
| | | |
| | | # å¼åç¯å¢é
ç½® |
| | | server: |
| | |
| | | /** éªè¯ç ç±»å */ |
| | | private static String captchaType; |
| | | |
| | | /** |
| | | * æä»¶å°ååå |
| | | */ |
| | | private String domainName; |
| | | |
| | | |
| | | public String getName() |
| | | { |
| | | return name; |
| | |
| | | public static String getConfigurePath() { |
| | | return getProfile() + "/configure"; |
| | | } |
| | | |
| | | public String getDomainName() { |
| | | return domainName; |
| | | } |
| | | |
| | | public void setDomainName(String domainName) { |
| | | this.domainName = domainName; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.common.utils; |
| | | |
| | | |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.constant.TimeTypeConst; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: ç»è®¡å¾ç¸å
³æ°æ®å·¥å
·ç±» |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ28æ¥ 15:29 |
| | | */ |
| | | public class ChartUtils { |
| | | |
| | | /** |
| | | * æé æ¥æå表 |
| | | * |
| | | * @param timeType |
| | | * @param timeCode |
| | | * @param dateList |
| | | */ |
| | | public static void generateDateList(String timeType, String timeCode, List<Date> dateList) { |
| | | Date now = new Date(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | if (!timeCode.contains(CommonConst.SINGLE_MINUS_SIGN)) { |
| | | timeCode = DateTimeUtil.toDateTimeStr(timeCode, DateTimeUtil.COMMON_PATTERN_DAY, DateTimeUtil.COMMON_PATTERN_TO_DAY); |
| | | } |
| | | int hour = 23; |
| | | for (int i = CommonConst.DIGIT_0; i <= hour; i++) { |
| | | String tempCode = timeCode + " 0" + i; |
| | | if (i > 9) { |
| | | tempCode = timeCode + " " + i; |
| | | } |
| | | Date tempD = DateTimeUtil.toDateTime(tempCode, DateTimeUtil.COMMON_PATTERN_TO_HOUR); |
| | | dateList.add(tempD); |
| | | } |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | if (!timeCode.contains(CommonConst.SINGLE_MINUS_SIGN)) { |
| | | timeCode = DateTimeUtil.toDateTimeStr(timeCode, DateTimeUtil.COMMON_PATTERN_MONTH, DateTimeUtil.COMMON_PATTERN_TO_MONTH); |
| | | } |
| | | int max = DateTimeUtil.getDateTimeLastDay(DateTimeUtil.toDateTime(timeCode, DateTimeUtil.COMMON_PATTERN_TO_MONTH)); |
| | | |
| | | for (int i = CommonConst.DIGIT_1; i <= max; i++) { |
| | | String tempCode = timeCode + "-0" + i; |
| | | if (i > 9) { |
| | | tempCode = timeCode + "-" + i; |
| | | } |
| | | Date tempD = DateTimeUtil.toDateTime(tempCode, DateTimeUtil.COMMON_PATTERN_TO_DAY); |
| | | dateList.add(tempD); |
| | | } |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | int monthMax = 12; |
| | | for (int i = CommonConst.DIGIT_1; i <= monthMax; i++) { |
| | | String tempCode = timeCode + "-0" + i; |
| | | if (i > 9) { |
| | | tempCode = timeCode + "-" + i; |
| | | } |
| | | Date tempD = DateTimeUtil.toDateTime(tempCode, DateTimeUtil.COMMON_PATTERN_TO_MONTH); |
| | | dateList.add(tempD); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å对åºçç»ææ¶é´ |
| | | * |
| | | * @param timeType |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public static Date getEndTime(String timeType, Date date) { |
| | | Date d1 = new Date(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | d1 = DateTimeUtil.addDays(date, CommonConst.DIGIT_1); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | d1 = DateTimeUtil.addMonths(date, CommonConst.DIGIT_1); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | d1 = DateTimeUtil.addYears(date, CommonConst.DIGIT_1); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return d1; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¥ææ¾ç¤ºå符 |
| | | * |
| | | * @param timeType |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public static String getTimeCode(String timeType, Date date) { |
| | | String str = CommonConst.EMPTY; |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | str = DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_TO_HOUR); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | str = DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_TO_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | str = DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_TO_MONTH); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¥ææ¾ç¤ºå符 |
| | | * |
| | | * @param timeType |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public static String getTimeCodeChart(String timeType, Date date) { |
| | | String str = CommonConst.EMPTY; |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | str = DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_HOUR_MINUTE); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | str = DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_MONTH_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | str = DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_TO_MONTH); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¥ææ¾ç¤ºå符 |
| | | * |
| | | * @param timeType |
| | | * @param timeCode |
| | | * @return |
| | | */ |
| | | public static Date getDateTime(String timeType, String timeCode) { |
| | | Date d1 = new Date(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | if (!timeCode.contains(CommonConst.SINGLE_MINUS_SIGN)) { |
| | | timeCode = DateTimeUtil.toDateTimeStr(timeCode, DateTimeUtil.COMMON_PATTERN_DAY, DateTimeUtil.COMMON_PATTERN_TO_DAY); |
| | | } |
| | | d1 = DateTimeUtil.toDateTime(timeCode, DateTimeUtil.COMMON_PATTERN_TO_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | if (!timeCode.contains(CommonConst.SINGLE_MINUS_SIGN)) { |
| | | timeCode = DateTimeUtil.toDateTimeStr(timeCode, DateTimeUtil.COMMON_PATTERN_MONTH, DateTimeUtil.COMMON_PATTERN_TO_MONTH); |
| | | } |
| | | d1 = DateTimeUtil.toDateTime(timeCode, DateTimeUtil.COMMON_PATTERN_TO_MONTH); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | d1 = DateTimeUtil.toDateTime(timeCode, DateTimeUtil.COMMON_PATTERN_YEAR); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return d1; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.common.utils; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.constant.TimeTypeConst; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.GregorianCalendar; |
| | | |
| | | /** |
| | | * @Description: æ¶é´å·¥å
·ç±» |
| | | * @author: yxw |
| | | * @date: 2022å¹´02æ02æ¥ 12:23 |
| | | */ |
| | | @Slf4j |
| | | public class DateTimeUtil { |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ |
| | | */ |
| | | public static final String COMMON_PATTERN = "yyyy-MM-dd HH:mm:ss"; |
| | | /** |
| | | * æ ¼å¼åæ¥æå°åé |
| | | */ |
| | | public static final String COMMON_PATTERN_END_WITH_MINUTE = "yyyy-MM-dd HH:mm"; |
| | | /** |
| | | * æ¥ææ ¼å¼ - å°æ¶:åé |
| | | */ |
| | | public static final String COMMON_PATTERN_HOUR_MINUTE = "HH:mm"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - 年份 |
| | | */ |
| | | public static final String COMMON_PATTERN_YEAR = "yyyy"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - æä¸å¹´, |
| | | */ |
| | | public static final String COMMON_PATTERN_CERTAIN_YEAR = "yy"; |
| | | |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - æä»½ |
| | | */ |
| | | public static final String COMMON_PATTERN_MONTH = "yyyyMM"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - æä»½ |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_MONTH = "yyyy-MM"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - æä»½ |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_MONTH_WORD = "yyyy-MMæ"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - æä»½ |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_MONTH_ZH = "yyyyå¹´MMæ"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - 天 |
| | | */ |
| | | public static final String COMMON_PATTERN_DAY = "yyyyMMdd"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - 天 |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_DAY = "yyyy-MM-dd"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - 天 |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_DAY_WORD = "yyyy-MM-ddæ¥"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - ææ¥ |
| | | */ |
| | | public static final String COMMON_PATTERN_MONTH_DAY = "MM-dd"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - 天æä¸å¤©, |
| | | */ |
| | | public static final String COMMON_PATTERN_DAY_OF_MONTH = "dd"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - å°æ¶ |
| | | */ |
| | | public static final String COMMON_PATTERN_HOUR = "yyyyMMddHH"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - å°æ¶ |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_HOUR = "yyyy-MM-dd HH"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - å°æ¶ |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_HOUR_WORD = "yyyy-MM-dd HHæ¶"; |
| | | /** |
| | | * æ¥æå¸¸ç¨æ ¼å¼ - å°æ¶ |
| | | */ |
| | | public static final String COMMON_PATTERN_TO_HOUR_TEXT = "yyyyå¹´MMæddæ¥ HHæ¶"; |
| | | |
| | | /** |
| | | * è·åå½åæ¶é´,æ¶é´æ ¼å¼ï¼yyyy-MM-dd HH:mm:ss |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getNowDateTime() { |
| | | return getNowDateTime(COMMON_PATTERN); |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åæ¶é´ |
| | | * |
| | | * @param pattern æ¶é´æ ¼å¼ |
| | | * @return |
| | | */ |
| | | public static String getNowDateTime(String pattern) { |
| | | //è®¾ç½®æ¥ææ ¼å¼ |
| | | SimpleDateFormat df = new SimpleDateFormat(pattern); |
| | | String dateTime = df.format(new Date()); |
| | | return dateTime; |
| | | } |
| | | |
| | | /** |
| | | * è·åä»å¹´çå¹´ä»½å¼ |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getNowYear() { |
| | | return getNowDateTime(COMMON_PATTERN_YEAR); |
| | | } |
| | | |
| | | /** |
| | | * è·åä»å¹´çæä»½å¼ |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getNowMonth() { |
| | | return getNowDateTime(COMMON_PATTERN_MONTH); |
| | | } |
| | | |
| | | /** |
| | | * åç¬¦ä¸²è½¬ææ¶é´ç±»å,é»è®¤æ ¼å¼ï¼yyyy-MM-dd HH:mm:ss |
| | | * |
| | | * @param dateTimeStr |
| | | * @return |
| | | */ |
| | | public static Date toDateTime(String dateTimeStr) { |
| | | DateTime dt = null; |
| | | try { |
| | | dt = DateTime.of(dateTimeStr, COMMON_PATTERN); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * åç¬¦ä¸²è½¬ææ¶é´ç±»å |
| | | * |
| | | * @param dateTimeStr |
| | | * @return |
| | | */ |
| | | public static Date toDateTime(String dateTimeStr, String pattern) { |
| | | DateTime dt = null; |
| | | try { |
| | | dt = DateTime.of(dateTimeStr, pattern); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * å符串转æç¹å®æ ¼å¼çæ¶é´å符串类å |
| | | * |
| | | * @param dateTimeStr æ¶é´å符串 |
| | | * @param sourcePattern å符串æ¶é´æ ¼å¼ |
| | | * @param toPattern è¦è½¬æä»ä¹æ ¼å¼çæ¶é´ |
| | | * @return |
| | | */ |
| | | public static String toDateTimeStr(String dateTimeStr, String sourcePattern, String toPattern) { |
| | | String str = CommonConst.EMPTY; |
| | | try { |
| | | DateTime dt = DateTime.of(dateTimeStr, sourcePattern); |
| | | str = getDateTime(dt, toPattern); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´è½¬ææå®çæ ¼å¼ |
| | | * |
| | | * @param pattern æ¶é´æ ¼å¼ |
| | | * @return |
| | | */ |
| | | public static String getDateTime(Date dt, String pattern) { |
| | | //è®¾ç½®æ¥ææ ¼å¼ |
| | | SimpleDateFormat df = new SimpleDateFormat(pattern); |
| | | return df.format(dt); |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´è½¬æyyyy-MM-dd HH:mm:ssæ ¼å¼ |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getDateTime(Date dt) { |
| | | if (ObjectUtil.isEmpty(dt)) { |
| | | return CommonConst.EMPTY; |
| | | } |
| | | return getDateTime(dt, COMMON_PATTERN); |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åæ¶é´æå±æä»½çæåä¸å¤© |
| | | * |
| | | * @return |
| | | */ |
| | | public static int getDateTimeLastDay(Date dt) { |
| | | String month = getMonth(dt); |
| | | String firstDate = month + "01"; |
| | | Date nextMonthFirstDate = addMonths(toDateTime(firstDate, COMMON_PATTERN_DAY), CommonConst.DIGIT_1); |
| | | Date currentMonthLastDate = addDays(nextMonthFirstDate, CommonConst.DIGIT_MINUS_1); |
| | | int day = IntegerUtil.toInt(getDateTime(currentMonthLastDate, COMMON_PATTERN_DAY_OF_MONTH)); |
| | | return day; |
| | | } |
| | | |
| | | /** |
| | | * è·åå¹´ä»½å¼ |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getYear(Date dt) { |
| | | return getDateTime(dt, COMMON_PATTERN_YEAR); |
| | | } |
| | | |
| | | /** |
| | | * è·åæä»½å¼ 202202 |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getMonth(Date dt) { |
| | | return getDateTime(dt, COMMON_PATTERN_MONTH); |
| | | } |
| | | |
| | | /** |
| | | * è·å天,æ ¼å¼ï¼yyyyMMdd |
| | | * |
| | | * @return |
| | | */ |
| | | public static String toDay(Date dt) { |
| | | return getDateTime(dt, COMMON_PATTERN_DAY); |
| | | } |
| | | |
| | | /** |
| | | * è·åå°æ¶:yyyyMMddHH |
| | | * |
| | | * @return |
| | | */ |
| | | public static String toHour(Date dt) { |
| | | return getDateTime(dt, COMMON_PATTERN_HOUR); |
| | | } |
| | | |
| | | /** |
| | | * 转æå符串类åå¼ |
| | | * |
| | | * @return |
| | | */ |
| | | public static String toString(Date dt) { |
| | | return getDateTime(dt, COMMON_PATTERN); |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´å¢å 对åºçå¹´æ° |
| | | * |
| | | * @param dateTime |
| | | * @param years |
| | | * @return |
| | | */ |
| | | public static Date addYears(Date dateTime, int years) { |
| | | return calcDate(dateTime, years, Calendar.YEAR); |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´å¢å 对åºçææ° |
| | | * |
| | | * @param dateTime |
| | | * @param months |
| | | * @return |
| | | */ |
| | | public static Date addMonths(Date dateTime, int months) { |
| | | return calcDate(dateTime, months, Calendar.MONTH); |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´å¢å 对åºçå¤©æ° |
| | | * |
| | | * @param dateTime |
| | | * @param days |
| | | * @return |
| | | */ |
| | | public static Date addDays(Date dateTime, int days) { |
| | | return calcDate(dateTime, days, Calendar.DATE); |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´å¢å 对åºçå°æ¶æ° |
| | | * |
| | | * @param dateTime |
| | | * @param hours |
| | | * @return |
| | | */ |
| | | public static Date addHours(Date dateTime, int hours) { |
| | | return calcDate(dateTime, hours, Calendar.HOUR); |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´å¢å 对åºçåéæ° |
| | | * |
| | | * @param dateTime |
| | | * @param minutes |
| | | * @return |
| | | */ |
| | | public static Date addMinutes(Date dateTime, int minutes) { |
| | | return calcDate(dateTime, minutes, Calendar.MINUTE); |
| | | } |
| | | |
| | | /** |
| | | * æ¶é´å¢å 对åºçå°æ¶æ° |
| | | * |
| | | * @param dateTime |
| | | * @param seconds |
| | | * @return |
| | | */ |
| | | public static Date addSeconds(Date dateTime, int seconds) { |
| | | return calcDate(dateTime, seconds, Calendar.SECOND); |
| | | } |
| | | |
| | | /** |
| | | * è®¡ç®æ¥æéç¨æ¹æ³ |
| | | * |
| | | * @param dateTime |
| | | * @param addValue |
| | | * @param calendarType 计ç®ç±»åï¼Calendar.YEARï¼Calendar.MONTH,Calendar.DAY |
| | | * @return |
| | | */ |
| | | private static Date calcDate(Date dateTime, int addValue, int calendarType) { |
| | | Date dt = null; |
| | | try { |
| | | Calendar calendar = new GregorianCalendar(); |
| | | calendar.setTime(dateTime); |
| | | //ææ¥æå¾åå¢å ä¸å¹´ï¼æ´æ°å¾åæ¨ï¼è´æ°å¾åç§» |
| | | calendar.add(calendarType, addValue); |
| | | // è·åç¸å æè
ç¸åä¹åçæ¶é´å¼ |
| | | Date tempDt = calendar.getTime(); |
| | | // ææ¶é´è½¬ææéè¦çæ ¼å¼ |
| | | String temp = getDateTime(tempDt, COMMON_PATTERN); |
| | | dt = toDateTime(temp); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * è·å该æ¶é´å±äºå½å¤©ç第å ä¸ªå°æ¶ |
| | | * |
| | | * @param dateTime |
| | | * @return |
| | | */ |
| | | public static int getHourOfDay(Date dateTime) { |
| | | return getDateValue(dateTime, Calendar.HOUR_OF_DAY); |
| | | } |
| | | |
| | | /** |
| | | * è·å该æ¶é´å±äºå½æç第å 天 |
| | | * |
| | | * @param dateTime |
| | | * @return |
| | | */ |
| | | public static int getDayOfMonth(Date dateTime) { |
| | | return getDateValue(dateTime, Calendar.DAY_OF_MONTH); |
| | | } |
| | | |
| | | /** |
| | | * è·å该æ¶é´å±äºå½å¨ç第å 天 |
| | | * ä¸å¨ç第ä¸å¤©æ¯å¨æ¥ |
| | | * |
| | | * @param dateTime |
| | | * @return |
| | | */ |
| | | public static int getDayOfWeek(Date dateTime) { |
| | | return getDateValue(dateTime, Calendar.DAY_OF_WEEK); |
| | | } |
| | | |
| | | /** |
| | | * è·å该æ¶é´å±äºå¹´ç第å 个æ |
| | | * æä»½å¼+1æ¯çå®çå½åæ |
| | | * |
| | | * @param dateTime |
| | | * @return å·²ç»å¨ç³»ç»ä¸è·åå¼çåºç¡ä¸å 1äºï¼ç°å¨æ¯çå®çå½åæä»½å¼ |
| | | */ |
| | | public static int getMonthOfYear(Date dateTime) { |
| | | return getDateValue(dateTime, Calendar.MONTH) + 1; |
| | | } |
| | | |
| | | /** |
| | | * è·åå½å¤©ç第å ä¸ªå°æ¶/彿ç第å 天/å½å¹´ç第å 个æ |
| | | * |
| | | * @param dateTime 妿æ¶é´å¼ä¸ºç©ºï¼é»è®¤å½åæ¶é´ |
| | | * @param calendarType |
| | | * @return |
| | | */ |
| | | private static int getDateValue(Date dateTime, int calendarType) { |
| | | int value = 0; |
| | | try { |
| | | if (ObjectUtil.isEmpty(dateTime)) { |
| | | dateTime = new Date(); |
| | | } |
| | | Calendar calendar = new GregorianCalendar(); |
| | | calendar.setTime(dateTime); |
| | | value = calendar.get(calendarType); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 对æ¯time1 å time2 çå¤§å° |
| | | * |
| | | * @param time1 |
| | | * @param time2 |
| | | * @return -1:time1å°äºtime2;0:time1çäºtime2;1:time1大äºtime2; |
| | | */ |
| | | public static int compareDateDiff(Date time1, Date time2) { |
| | | long diff = time1.getTime() - time2.getTime(); |
| | | int res = 0; |
| | | if (diff > 0) { |
| | | res = 1; |
| | | } else if (diff < 0) { |
| | | res = -1; |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¥è¯¢data_itemæéè¦çtimecodeå¼ |
| | | * |
| | | * @param timeType æ¥æç±»å |
| | | * @param date æ¶é´ |
| | | * @return |
| | | */ |
| | | public static String getTimeCode(String timeType, Date date) { |
| | | String timeCode = CommonConst.EMPTY; |
| | | if (ObjectUtil.isEmpty(date)) { |
| | | date = new Date(); |
| | | } |
| | | timeType = StringUtil.ifEmptyOrNullReturnValue(timeType).toUpperCase(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | timeCode = CommonConst.WORD_H + getDateTime(date, COMMON_PATTERN_HOUR); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | timeCode = CommonConst.WORD_D + getDateTime(date, COMMON_PATTERN_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | timeCode = CommonConst.WORD_M + getDateTime(date, COMMON_PATTERN_MONTH); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | timeCode = CommonConst.WORD_Y + getDateTime(date, COMMON_PATTERN_YEAR); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return timeCode; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¥è¯¢æ¥æå¹´æ¥è¡¨æéè¦çtimecodeå¼ |
| | | * |
| | | * @param timeType æ¥æç±»å |
| | | * @param date æ¶é´ |
| | | * @return |
| | | */ |
| | | public static String getReportTimeCode(String timeType, Date date) { |
| | | String timeCode = CommonConst.EMPTY; |
| | | if (ObjectUtil.isEmpty(date)) { |
| | | date = new Date(); |
| | | } |
| | | timeType = StringUtil.ifEmptyOrNullReturnValue(timeType).toUpperCase(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | timeCode = getDateTime(date, COMMON_PATTERN_TO_HOUR); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | timeCode = getDateTime(date, COMMON_PATTERN_TO_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | timeCode = getDateTime(date, COMMON_PATTERN_TO_MONTH); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | timeCode = getDateTime(date, COMMON_PATTERN_YEAR); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return timeCode; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ¶é´å¯¹åºçç¯æ¯æ¶é´ |
| | | * |
| | | * @param timeType HOUR/DAY/MONTH/YEAR |
| | | * @param date æ¶é´å¼ |
| | | * @return |
| | | */ |
| | | public static Date getLoopTime(String timeType, Date date) { |
| | | Date dt = null; |
| | | if (ObjectUtil.isEmpty(date)) { |
| | | date = new Date(); |
| | | } |
| | | timeType = StringUtil.ifEmptyOrNullReturnValue(timeType).toUpperCase(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | dt = addHours(date, CommonConst.DIGIT_MINUS_1); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | dt = addDays(date, CommonConst.DIGIT_MINUS_1); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | dt = addMonths(date, CommonConst.DIGIT_MINUS_1); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | dt = addYears(date, CommonConst.DIGIT_MINUS_1); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * è·åæ´ç¹æ¶é´ |
| | | * |
| | | * @param timeType HOUR/DAY/MONTH/YEAR |
| | | * @param date æ¶é´å¼ |
| | | * @return |
| | | */ |
| | | public static Date getHourTime(String timeType, Date date) { |
| | | Date dt = null; |
| | | if (ObjectUtil.isEmpty(date)) { |
| | | date = new Date(); |
| | | } |
| | | String tempStr = null; |
| | | timeType = StringUtil.ifEmptyOrNullReturnValue(timeType).toUpperCase(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | tempStr = getDateTime(date, COMMON_PATTERN_TO_HOUR); |
| | | dt = toDateTime(tempStr, COMMON_PATTERN_TO_HOUR); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | tempStr = getDateTime(date, COMMON_PATTERN_TO_DAY); |
| | | dt = toDateTime(tempStr, COMMON_PATTERN_TO_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | tempStr = getDateTime(date, COMMON_PATTERN_TO_MONTH); |
| | | dt = toDateTime(tempStr, COMMON_PATTERN_TO_MONTH); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | tempStr = getDateTime(date, COMMON_PATTERN_YEAR); |
| | | dt = toDateTime(tempStr, COMMON_PATTERN_YEAR); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * 计ç®ä¸¤ä¸ªæ¶é´é´é天æ°ï¼æ¥ææ ¼å¼æ¯è¾ï¼ |
| | | * |
| | | * @param beginTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | public static int daysBetween(Date beginTime, Date endTime) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(beginTime); |
| | | long beginStamp = calendar.getTimeInMillis(); |
| | | calendar.setTime(endTime); |
| | | long endStamp = calendar.getTimeInMillis(); |
| | | long betweenDays = (endStamp - beginStamp) / (1000 * 3600 * 24); |
| | | return Integer.parseInt(String.valueOf(betweenDays)); |
| | | } |
| | | |
| | | /** |
| | | * 计ç®ä¸¤ä¸ªæ¶é´é´é天æ°ï¼åç¬¦ä¸²æ ¼å¼æ¯è¾ï¼ |
| | | * |
| | | * @param beginTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | public static int daysBetween(String beginTime, String endTime) { |
| | | try { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date begin = format.parse(beginTime); |
| | | Date end = format.parse(endTime); |
| | | return daysBetween(begin, end); |
| | | } catch (ParseException exception) { |
| | | log.error("计ç®ä¸¤ä¸ªæ¶é´é´é天æ°" + exception.getMessage()); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æ¶é´ç±»åæå符串转æå¯¹åºçæ¶é´ |
| | | * |
| | | * @param timeType æ¶é´ç±»å |
| | | * @param time æ¶é´å符串 |
| | | * @return |
| | | */ |
| | | public static Date getTime(String timeType, String time) { |
| | | Date dt = null; |
| | | timeType = StringUtil.ifEmptyOrNullReturnValue(timeType).toUpperCase(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | dt = toDateTime(time, COMMON_PATTERN_TO_HOUR); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | dt = toDateTime(time, COMMON_PATTERN_TO_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | dt = toDateTime(time, COMMON_PATTERN_TO_MONTH); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | dt = toDateTime(time, COMMON_PATTERN_YEAR); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æ¶é´ç±»åæè¿ç»çæ¥æå符串转æå¯¹åºçæ¶é´ ï¼202303ã20230303ã2023030301ã202303030101ï¼ |
| | | * |
| | | * @param timeType æ¶é´ç±»å |
| | | * @param time æ¶é´å符串 |
| | | * @return |
| | | */ |
| | | public static Date getTimeByContinuousTimeCode(String timeType, String time) { |
| | | Date dt = null; |
| | | timeType = StringUtil.ifEmptyOrNullReturnValue(timeType).toUpperCase(); |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | dt = toDateTime(time, COMMON_PATTERN_HOUR); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | dt = toDateTime(time, COMMON_PATTERN_DAY); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | dt = toDateTime(time, COMMON_PATTERN_MONTH); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | dt = toDateTime(time, COMMON_PATTERN_YEAR); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æ¶é´ç±»åè¿å天ãæãå¹´æåçæ¶é´ |
| | | * |
| | | * @param timeType æ¶é´ç±»å |
| | | * @param time æ¶é´ |
| | | * @return |
| | | */ |
| | | public static Date getEndTimeByType(String timeType, Date time) { |
| | | Date dt = null; |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | dt = DateUtil.endOfDay(time); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | dt = DateUtil.endOfMonth(time); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | dt = DateUtil.endOfYear(time); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return dt; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å¨æç±»å对çäº§å¨æè¿è¡å åè®¡ç® |
| | | * å¡«æ¥å¨æç±»åï¼HOURå°æ¶ãDAY天ãMONTHæãYEARå¹´ï¼ |
| | | * |
| | | * @param date çäº§å¨æ |
| | | * @param cycleType çäº§å¨æç±»å |
| | | * @param cycleType çäº§å¨æç±»å |
| | | * @param val 计ç®å¼ |
| | | * @return |
| | | */ |
| | | public static Date productionCycleCal(Date date, String cycleType,int val) { |
| | | Date momDate = date; |
| | | switch (cycleType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | momDate = DateUtils.addHours(date, val); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | momDate = DateUtils.addDays(date, val); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | momDate = DateUtils.addMonths(date, val); |
| | | break; |
| | | } |
| | | return momDate; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å¨æç±»å对çäº§å¨æè¿è¡å åè®¡ç® å¹¶ä¸è¿ä½ ä¾å¦ï¼ HOUR +1è¿ä½å°±æ¯ å ä¸å¤© |
| | | * å¡«æ¥å¨æç±»åï¼HOURå°æ¶ãDAY天ãMONTHæãYEARå¹´ï¼ |
| | | * |
| | | * @param date çäº§å¨æ |
| | | * @param cycleType çäº§å¨æç±»å |
| | | * @param val 计ç®å¼ |
| | | * @return |
| | | */ |
| | | public static Date productionCycleCalCarry(Date date, String cycleType,int val) { |
| | | Date momDate = date; |
| | | switch (cycleType) { |
| | | case TimeTypeConst.TIME_TYPE_HOUR: |
| | | momDate = DateUtils.addDays(date, val); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | momDate = DateUtils.addMonths(date, val); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | momDate = DateUtils.addYears(date, val); |
| | | break; |
| | | } |
| | | return momDate; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.common.utils; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | |
| | | /** |
| | | * @Description: æ°åå·¥å
·ç±» |
| | | * @author: yxw |
| | | * @date: 2022å¹´02æ07æ¥ 15:03 |
| | | */ |
| | | public class DoubleUtil { |
| | | public static double toDouble(String str) { |
| | | double d = 0; |
| | | try { |
| | | d = Double.parseDouble(str); |
| | | } catch (Exception e) { |
| | | d = 0; |
| | | } |
| | | return d; |
| | | } |
| | | |
| | | /** |
| | | * long 转æ doubleç±»å |
| | | * |
| | | * @param l |
| | | * @return |
| | | */ |
| | | public static double toDouble(long l) { |
| | | return toDouble(l + ""); |
| | | } |
| | | |
| | | /** |
| | | * long 转æ doubleç±»å |
| | | * |
| | | * @param l |
| | | * @return |
| | | */ |
| | | public static double toDouble(Object l) { |
| | | return toDouble(l + ""); |
| | | } |
| | | |
| | | /** |
| | | * int 转æ doubleç±»å |
| | | * |
| | | * @param i |
| | | * @return |
| | | */ |
| | | public static double toDouble(int i) { |
| | | return toDouble(i + ""); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ ¼å¼åå°æ°ä¸ºæå®ä½æ°çå°æ°å符串 |
| | | * |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static String formatDoubleToStr(Double value, int format) { |
| | | if (ObjectUtil.isEmpty(value)) { |
| | | value = 0.00; |
| | | } |
| | | String str = String.format("%." + format + "f", value).toString(); |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * æ ¼å¼åå°æ°ä¸ºæå®ä½æ°çå°æ°å符串,é»è®¤æ ¼å¼å为2ä½å°æ° |
| | | * |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static String formatDoubleToStr(Double value) { |
| | | return formatDoubleToStr(value, 2); |
| | | } |
| | | |
| | | /** |
| | | * æ ¼å¼åå°æ°ä¸ºæå®ä½æ°çå°æ° |
| | | * |
| | | * @param value |
| | | * @param format |
| | | * @return |
| | | */ |
| | | public static double formatDouble(Double value, int format) { |
| | | if (ObjectUtil.isEmpty(value)) { |
| | | return 0D; |
| | | } |
| | | String str = formatDoubleToStr(value, format); |
| | | return toDouble(str); |
| | | } |
| | | |
| | | /** |
| | | * æ ¼å¼åå°æ°ä¸º2使°çå°æ° |
| | | * |
| | | * @param value |
| | | * @return |
| | | */ |
| | | public static double formatDouble(Double value) { |
| | | if (ObjectUtil.isEmpty(value)) { |
| | | return 0D; |
| | | } |
| | | return formatDouble(value, 2); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.common.utils; |
| | | |
| | | /** |
| | | * @Description: æ´æ°ç¸å
³å·¥å
·ç±» |
| | | * @author: yxw |
| | | * @date: 2022å¹´03æ10æ¥ 17:31 |
| | | */ |
| | | public class IntegerUtil { |
| | | /** |
| | | * å符串转æintç±»å |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static int toInt(String str) { |
| | | int d = 0; |
| | | try { |
| | | d = Integer.parseInt(str); |
| | | } catch (Exception e) { |
| | | d = 0; |
| | | } |
| | | return d; |
| | | } |
| | | |
| | | /** |
| | | * long转æintç±»å |
| | | * |
| | | * @param l |
| | | * @return |
| | | */ |
| | | public static int toInt(long l) { |
| | | int d = 0; |
| | | try { |
| | | d = (int) l; |
| | | } catch (Exception e) { |
| | | d = 0; |
| | | } |
| | | return d; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.common.utils; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | |
| | | /** |
| | | * @Description: å符串工å
·ç±» |
| | | * @author: yxw |
| | | * @date: 2022å¹´02æ02æ¥ 12:27 |
| | | */ |
| | | public class StringUtil { |
| | | /** |
| | | * 夿å符串æ¯å¦ä¸ºç©ºå符串æè
Null |
| | | * |
| | | * @param str éè¦å¤æçå符串 |
| | | * @return |
| | | */ |
| | | public static boolean isEmptyOrNull(String str) { |
| | | if (str == null || CommonConst.EMPTY.equals(str)) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * åç¬¦ä¸²å¦æä¸ºç©ºå符串æè
Nullè¿å空å符串ï¼å¦åè¿åå符串æ¬èº«çå¼ |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static String ifEmptyOrNullReturnValue(String str) { |
| | | if (isEmptyOrNull(str)) { |
| | | return CommonConst.EMPTY; |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | /** |
| | | * 对象转æjsonå符串 |
| | | * |
| | | * @param obj |
| | | * @return |
| | | */ |
| | | public static String toJson(Object obj) { |
| | | return JSONObject.toJSONString(obj); |
| | | } |
| | | |
| | | /** |
| | | * 对象转æJSONObject |
| | | * |
| | | * @param obj |
| | | * @return |
| | | */ |
| | | public static JSONObject toJsonObject(Object obj) { |
| | | return JSONObject.parseObject(toJson(obj)); |
| | | } |
| | | |
| | | /** |
| | | * é¦åæ¯å¤§å |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static String captureWord(String str) { |
| | | str = str.toLowerCase(); |
| | | char[] cs = str.toCharArray(); |
| | | cs[0] -= 32; |
| | | return String.valueOf(cs); |
| | | } |
| | | } |
| | |
| | | * @date 2020-03-25 |
| | | */ |
| | | public interface DailyComprehensiveMapper { |
| | | public List<DailyComprehensive> getDailyComprehensiveList(@Param("nodeId") String nodeId, |
| | | List<DailyComprehensive> getDailyComprehensiveList(@Param("nodeId") String nodeId, |
| | | @Param("dataList") List<DailyComprehensive> dataList, |
| | | @Param("beginTime") Date beginTime, |
| | | @Param("endTime") Date endTime, |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.dataitem.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Author DYL |
| | | **/ |
| | | @Data |
| | | public class NodeIndexValueVO { |
| | | |
| | | /** |
| | | * èç¹id |
| | | */ |
| | | private String nodeId; |
| | | |
| | | /** |
| | | * èç¹åç§° |
| | | */ |
| | | private String nodeName; |
| | | |
| | | /** |
| | | * ç¹ä½id |
| | | */ |
| | | private String indexId; |
| | | |
| | | /** |
| | | * 累积é |
| | | */ |
| | | private BigDecimal value; |
| | | } |
| | |
| | | package com.zhitan.dataitem.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zhitan.carbonemission.domain.CarbonEmission; |
| | | import com.zhitan.common.enums.TimeType; |
| | | import com.zhitan.dataitem.domain.StagseDataEntry; |
| | |
| | | * @author sys |
| | | * @date 2020-03-25 |
| | | */ |
| | | public interface DataItemMapper { |
| | | public interface DataItemMapper extends BaseMapper<DataItem> { |
| | | /** |
| | | * é¶æ®µæ°æ®å½å
¥ |
| | | * |
| | |
| | | import com.zhitan.common.enums.TimeType; |
| | | import com.zhitan.dataitem.domain.StagseDataEntry; |
| | | import com.zhitan.realtimedata.domain.DataItem; |
| | | import com.zhitan.statisticalAnalysis.domain.dto.FlowChartsDTO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.FlowChartsVO; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | |
| | | * @return |
| | | */ |
| | | List<DataItem> getDataItemHourInforByIndexIds(Date beginTime, Date endTime, String timeType, List<String> indexIds); |
| | | |
| | | /** |
| | | * è·åè½æµå¾å½¢åæ |
| | | * |
| | | * @param dto 请æ±åæ° |
| | | * @return ç»æ |
| | | */ |
| | | FlowChartsVO getFlowCharts(FlowChartsDTO dto); |
| | | } |
| | |
| | | |
| | | import com.zhitan.common.enums.TimeType; |
| | | import com.zhitan.dataitem.domain.StagseDataEntry; |
| | | import com.zhitan.dataitem.domain.vo.NodeIndexValueVO; |
| | | import com.zhitan.dataitem.mapper.DataItemMapper; |
| | | import com.zhitan.dataitem.service.IDataItemService; |
| | | import com.zhitan.model.domain.ModelNode; |
| | | import com.zhitan.model.mapper.EnergyIndexMapper; |
| | | import com.zhitan.model.mapper.ModelNodeMapper; |
| | | import com.zhitan.model.mapper.NodeIndexMapper; |
| | | import com.zhitan.realtimedata.domain.DataItem; |
| | | import com.zhitan.statisticalAnalysis.domain.dto.FlowChartsDTO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.FlowChartsItemVO; |
| | | import com.zhitan.statisticalAnalysis.domain.vo.FlowChartsVO; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * stagseDataEntryServiceä¸å¡å±å¤ç |
| | |
| | | @AllArgsConstructor |
| | | public class DataItemServiceImpl implements IDataItemService { |
| | | |
| | | private final DataItemMapper dataItemMapper; |
| | | @Resource |
| | | private DataItemMapper dataItemMapper; |
| | | @Resource |
| | | private ModelNodeMapper modelNodeMapper; |
| | | @Resource |
| | | private EnergyIndexMapper energyIndexMapper; |
| | | @Resource |
| | | private NodeIndexMapper nodeIndexMapper; |
| | | |
| | | |
| | | /** |
| | |
| | | public List<DataItem> getDataItemHourInforByIndexIds(Date beginTime, Date endTime, String timeType, List<String> indexIds) { |
| | | return dataItemMapper.getDataItemHourInforByIndexIds(beginTime, endTime, timeType, indexIds); |
| | | } |
| | | |
| | | /** |
| | | * è·åè½æµå¾å½¢åæ |
| | | * |
| | | * @param dto 请æ±åæ° |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public FlowChartsVO getFlowCharts(FlowChartsDTO dto) { |
| | | FlowChartsVO flowChartsVO = new FlowChartsVO(); |
| | | // ç¶èç¹id |
| | | String nodeId = dto.getNodeId(); |
| | | String energyType = dto.getEnergyType(); |
| | | LocalDate queryTime = dto.getQueryTime(); |
| | | TimeType timeType = dto.getTimeType(); |
| | | |
| | | // è·åèç¹ä¿¡æ¯ |
| | | ModelNode modelNode = modelNodeMapper.selectModelNodeById(nodeId); |
| | | if (ObjectUtils.isEmpty(modelNode)) { |
| | | return flowChartsVO; |
| | | } |
| | | // è·åæ¥è¯¢æ¶é´ |
| | | Map<String, LocalDateTime> dateTimeMap = getDataItemByIndexId(timeType, queryTime); |
| | | |
| | | // è·åèç¹åç¹ä½ç累积é |
| | | List<NodeIndexValueVO> parentDataItemList = modelNodeMapper.getDataItemByNodeId(nodeId, energyType, timeType, dateTimeMap); |
| | | |
| | | // è·ååèç¹ä¸çç¹ä½ç累积é |
| | | List<NodeIndexValueVO> childDataItemList = modelNodeMapper.getDataItemByParentNodeId(nodeId, energyType, timeType, dateTimeMap); |
| | | |
| | | // è·åç¶èç¹ä¸çè½èæ°æ®æ»å |
| | | if (ObjectUtils.isNotEmpty(parentDataItemList)) { |
| | | // ç¶èç¹ä¸çè½èæ°æ®æ»å |
| | | BigDecimal totalValue = parentDataItemList.stream().map(NodeIndexValueVO::getValue) |
| | | .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // æ»ç´¯ç§¯é |
| | | flowChartsVO.setTotalAccumulatedAmount(totalValue); |
| | | } |
| | | // è·ååèç¹ä¸çè½èæ°æ® |
| | | if (ObjectUtils.isNotEmpty(childDataItemList)) { |
| | | // åèç¹ä¸çè½èæ°æ®æ»å |
| | | BigDecimal childTotalValue = childDataItemList.stream().map(NodeIndexValueVO::getValue) |
| | | .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // åèç¹ç´¯ç§¯é |
| | | flowChartsVO.setChildNodeAccumulatedAmount(childTotalValue); |
| | | |
| | | // æ ¹æ®åèç¹idåç» |
| | | Map<String, List<NodeIndexValueVO>> voMap = childDataItemList.stream() |
| | | .collect(Collectors.groupingBy(NodeIndexValueVO::getNodeId)); |
| | | List<FlowChartsItemVO> itemList = new ArrayList<>(); |
| | | |
| | | for (String childNodeId : voMap.keySet()) { |
| | | FlowChartsItemVO vo = new FlowChartsItemVO(); |
| | | vo.setSource(modelNode.getName()); |
| | | List<NodeIndexValueVO> valueList = voMap.getOrDefault(childNodeId, Collections.emptyList()); |
| | | if (ObjectUtils.isNotEmpty(valueList)) { |
| | | // å个åèç¹çè½èæ°æ®æ»å |
| | | BigDecimal value = valueList.stream().map(NodeIndexValueVO::getValue) |
| | | .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | valueList.stream().findFirst().ifPresent(nodeIndexValueVO -> vo.setTarget(nodeIndexValueVO.getNodeName())); |
| | | vo.setValue(value); |
| | | } |
| | | itemList.add(vo); |
| | | } |
| | | flowChartsVO.setItemVOList(itemList); |
| | | } |
| | | return flowChartsVO; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®indexIdæ¥è¯¢è½èæ°æ® |
| | | */ |
| | | private Map<String, LocalDateTime> getDataItemByIndexId(TimeType timeType, LocalDate queryTime) { |
| | | LocalDateTime startTime; |
| | | LocalDateTime endTime; |
| | | LocalDate startDate; |
| | | LocalDate endDate; |
| | | switch (timeType) { |
| | | case DAY: |
| | | // å½å¤©çå¼å§æ¶é´ |
| | | startTime = LocalDateTime.of(queryTime, LocalTime.MIN); |
| | | // å½å¤©çç»ææ¶é´ |
| | | endTime = LocalDateTime.of(queryTime, LocalTime.MAX); |
| | | break; |
| | | case MONTH: |
| | | // 彿çå¼å§æ¶é´ |
| | | startDate = queryTime.with(TemporalAdjusters.firstDayOfMonth()); |
| | | startTime = LocalDateTime.of(startDate, LocalTime.MIN); |
| | | // 彿çç»ææ¶é´ |
| | | endDate = queryTime.with(TemporalAdjusters.lastDayOfMonth()); |
| | | endTime = LocalDateTime.of(endDate, LocalTime.MAX); |
| | | break; |
| | | case YEAR: |
| | | // å½å¹´çå¼å§æ¶é´ |
| | | startDate = queryTime.with(TemporalAdjusters.firstDayOfYear()); |
| | | startTime = LocalDateTime.of(startDate, LocalTime.MIN); |
| | | // å½å¹´çç»ææ¶é´ |
| | | endDate = queryTime.with(TemporalAdjusters.lastDayOfYear()); |
| | | endTime = LocalDateTime.of(endDate, LocalTime.MAX); |
| | | break; |
| | | default: |
| | | // å½å¤©çå¼å§æ¶é´ |
| | | startTime = LocalDateTime.of(queryTime, LocalTime.MIN); |
| | | // å½å¤©çç»ææ¶é´ |
| | | endTime = LocalDateTime.of(queryTime, LocalTime.MAX); |
| | | break; |
| | | } |
| | | Map<String, LocalDateTime> localDateTimeMap = new HashMap<>(); |
| | | localDateTimeMap.put("startTime", startTime); |
| | | localDateTimeMap.put("endTime", endTime); |
| | | return localDateTimeMap; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:59 |
| | | */ |
| | | @Data |
| | | public class ElectricPowerFactorDetail { |
| | | /** |
| | | * æå¤§åçå æ° |
| | | */ |
| | | private String max; |
| | | /** |
| | | * æå¤§åçå æ°åçæ¶é´ |
| | | */ |
| | | private String maxTime; |
| | | /** |
| | | * æå°åçå æ° |
| | | */ |
| | | private String min; |
| | | /** |
| | | * æå°åçå æ°åçæ¶é´ |
| | | */ |
| | | private String minTime; |
| | | /** |
| | | * å¹³ååçå æ° |
| | | */ |
| | | private String avg; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:59 |
| | | */ |
| | | @Data |
| | | public class ElectricPowerFactorItem { |
| | | /** |
| | | * æ¶é´ |
| | | */ |
| | | private String timeCode; |
| | | /** |
| | | * 宿¶å¼ |
| | | */ |
| | | private String value; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:58 |
| | | */ |
| | | @Data |
| | | public class ElectricPowerFactorVO { |
| | | /** |
| | | * è®°å½å表 |
| | | */ |
| | | private List<ElectricPowerFactorItem> itemList; |
| | | |
| | | /** |
| | | * 详æ
å®ä½ |
| | | */ |
| | | private ElectricPowerFactorDetail detail; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:59 |
| | | */ |
| | | @Data |
| | | public class ElectricThreePhaseDetail { |
| | | /** |
| | | * æå¤§åçå æ° |
| | | */ |
| | | private String max; |
| | | /** |
| | | * æå¤§åçå æ°åçæ¶é´ |
| | | */ |
| | | private String maxTime; |
| | | /** |
| | | * æå°åçå æ° |
| | | */ |
| | | private String min; |
| | | /** |
| | | * æå°åçå æ°åçæ¶é´ |
| | | */ |
| | | private String minTime; |
| | | |
| | | /** |
| | | * æå¤§å¼-Aç¸çµæµ/çµå |
| | | */ |
| | | private String valueMaxA; |
| | | /** |
| | | * æå¤§å¼-Bç¸çµæµ/çµå |
| | | */ |
| | | private String valueMaxB; |
| | | /** |
| | | * æå¤§å¼-Cç¸çµæµ/çµå |
| | | */ |
| | | private String valueMaxC; |
| | | |
| | | /** |
| | | * æå°å¼-Aç¸çµæµ/çµå |
| | | */ |
| | | private String valueMinA; |
| | | /** |
| | | * æå°å¼-Bç¸çµæµ/çµå |
| | | */ |
| | | private String valueMinB; |
| | | /** |
| | | * æå°å¼-Cç¸çµæµ/çµå |
| | | */ |
| | | private String valueMinC; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:59 |
| | | */ |
| | | @Data |
| | | public class ElectricThreePhaseItem { |
| | | /** |
| | | * çµè¡¨åç§° |
| | | */ |
| | | private String name; |
| | | /** |
| | | * æ¶é´ |
| | | */ |
| | | private String timeCode; |
| | | /** |
| | | * ç»è®¡å¾æ¾ç¤ºæ¶é´ |
| | | */ |
| | | private String timeCodeChart; |
| | | /** |
| | | * æå¤§ä¸ç¸ä¸å¹³è¡¡ |
| | | */ |
| | | private String max; |
| | | /** |
| | | * æå°ä¸ç¸ä¸å¹³è¡¡ |
| | | */ |
| | | private String min; |
| | | /** |
| | | * Aç¸çµæµ/çµå |
| | | */ |
| | | private String valueA; |
| | | /** |
| | | * Dç¸çµæµ/çµå |
| | | */ |
| | | private String valueB; |
| | | /** |
| | | * Cç¸çµæµ/çµå |
| | | */ |
| | | private String valueC; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´05æ06æ¥ 14:02 |
| | | */ |
| | | @Data |
| | | public class ElectricThreePhaseTempModel { |
| | | |
| | | private Double max; |
| | | private Date maxTime; |
| | | private Double min; |
| | | private Date minTime; |
| | | /** |
| | | * æå¤§å¼-Aç¸çµæµ/çµå |
| | | */ |
| | | private double valueMaxA; |
| | | /** |
| | | * æå¤§å¼-Bç¸çµæµ/çµå |
| | | */ |
| | | private double valueMaxB; |
| | | /** |
| | | * æå¤§å¼-Cç¸çµæµ/çµå |
| | | */ |
| | | private double valueMaxC; |
| | | |
| | | /** |
| | | * æå°å¼-Aç¸çµæµ/çµå |
| | | */ |
| | | private double valueMinA; |
| | | /** |
| | | * æå°å¼-Bç¸çµæµ/çµå |
| | | */ |
| | | private double valueMinB; |
| | | /** |
| | | * æå°å¼-Cç¸çµæµ/çµå |
| | | */ |
| | | private double valueMinC; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:58 |
| | | */ |
| | | @Data |
| | | public class ElectricThreePhaseVO { |
| | | /** |
| | | * è®°å½å表 |
| | | */ |
| | | private List<ElectricThreePhaseItem> itemList; |
| | | |
| | | /** |
| | | * 详æ
å®ä½ |
| | | */ |
| | | private ElectricThreePhaseDetail detail; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * ééç¹ç¨è½åå
çµè¡¨ |
| | | * |
| | | * @author fanxinfu |
| | | */ |
| | | @Data |
| | | public class EnergyIndexAndUnitDevice { |
| | | |
| | | private String indexId; |
| | | private String indexName; |
| | | private String energyType; |
| | | private String energyName; |
| | | private String energyUnitName; |
| | | private String energyUnitDeviceName; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | |
| | | /** |
| | | * ç¹ä½è¯¦ç»ä¿¡æ¯ |
| | | * |
| | | * @Author: Zhujw |
| | | * @Date: 2023/5/26 |
| | | */ |
| | | @Data |
| | | public class EnergyIndexInforModel { |
| | | |
| | | @ApiModelProperty(value = "ç¹ä½id") |
| | | private String indexId; |
| | | |
| | | @ApiModelProperty(value = "计éå¨å
·id") |
| | | private String meterId; |
| | | |
| | | @ApiModelProperty(value = "ç¹ä½åç§°") |
| | | private String indexName; |
| | | |
| | | @ApiModelProperty(value = "ç¹ä½ç±»å(ééã计ç®)") |
| | | private String indexType; |
| | | |
| | | @ApiModelProperty(value = "ç¹ä½code") |
| | | private String indexCode; |
| | | |
| | | @ApiModelProperty(value = "ç¹ä½åä½") |
| | | private String indexUnit; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:59 |
| | | */ |
| | | @Data |
| | | public class ListElectricLoadDetail { |
| | | /** |
| | | * æå¤§è´è· |
| | | */ |
| | | private String max; |
| | | /** |
| | | * æå¤§è´è·åçæ¶é´ |
| | | */ |
| | | private String maxTime; |
| | | /** |
| | | * æå°è´è· |
| | | */ |
| | | private String min; |
| | | /** |
| | | * æå°è´è·åçæ¶é´ |
| | | */ |
| | | private String minTime; |
| | | /** |
| | | * å¹³åè´è· |
| | | */ |
| | | private String avg; |
| | | /** |
| | | * è´è·ç = å¹³åè´è· / æå¤§è´è· |
| | | */ |
| | | private String rate; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:59 |
| | | */ |
| | | @Data |
| | | public class ListElectricLoadItem { |
| | | /** |
| | | * çµè¡¨åç§° |
| | | */ |
| | | private String name; |
| | | /** |
| | | * æ¶é´ |
| | | */ |
| | | private String timeCode; |
| | | /** |
| | | * ç»è®¡å¾æ¾ç¤ºæ¶é´ |
| | | */ |
| | | private String timeCodeChart; |
| | | /** |
| | | * æå¤§è´è· |
| | | */ |
| | | private String max; |
| | | /** |
| | | * æå°è´è· |
| | | */ |
| | | private String min; |
| | | /** |
| | | * å¹³åè´è· |
| | | */ |
| | | private String avg; |
| | | /** |
| | | * 宿¶å¼ |
| | | */ |
| | | private String value; |
| | | /** |
| | | * è´è·ç |
| | | */ |
| | | private String rate; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.domain.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: TODO |
| | | * @author: yxw |
| | | * @date: 2022å¹´04æ24æ¥ 16:58 |
| | | */ |
| | | @Data |
| | | public class ListElectricLoadVO { |
| | | /** |
| | | * è®°å½å表 |
| | | */ |
| | | private List<ListElectricLoadItem> itemList; |
| | | |
| | | /** |
| | | * 详æ
å®ä½ |
| | | */ |
| | | private ListElectricLoadDetail detail; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service; |
| | | |
| | | import com.zhitan.energyMonitor.domain.vo.ListElectricLoadVO; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | |
| | | /** |
| | | * @Description: |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-04-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IElectricLoadService { |
| | | |
| | | /** |
| | | * è·åè´è·åææ°æ® |
| | | */ |
| | | ListElectricLoadVO list(String timeType, String timeCode, EnergyIndex energyIndex); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service; |
| | | |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricPowerFactorVO; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | |
| | | |
| | | /** |
| | | * @Description: |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-04-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IElectricPowerFactorService { |
| | | |
| | | /** |
| | | * è·åè´è·åææ°æ® |
| | | */ |
| | | ElectricPowerFactorVO list(String timeCode, EnergyIndex energyIndex); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service; |
| | | |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricThreePhaseVO; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-04-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | public interface IElectricThreePhaseService { |
| | | |
| | | /** |
| | | * è·åä¸ç¸ä¸å¹³è¡¡æ°æ® |
| | | */ |
| | | ElectricThreePhaseVO list(String timeType, String timeCode, List<EnergyIndex> energyIndexList, String requestType, String meterId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.zhitan.basicdata.domain.MeterImplement; |
| | | import com.zhitan.basicdata.mapper.MeterImplementMapper; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.constant.TimeTypeConst; |
| | | import com.zhitan.common.enums.CollectionModes; |
| | | import com.zhitan.common.enums.GroupTimeType; |
| | | import com.zhitan.common.utils.ChartUtils; |
| | | import com.zhitan.common.utils.DateTimeUtil; |
| | | import com.zhitan.common.utils.DoubleUtil; |
| | | import com.zhitan.common.utils.StringUtil; |
| | | import com.zhitan.energyMonitor.domain.vo.ListElectricLoadDetail; |
| | | import com.zhitan.energyMonitor.domain.vo.ListElectricLoadItem; |
| | | import com.zhitan.energyMonitor.domain.vo.ListElectricLoadVO; |
| | | import com.zhitan.energyMonitor.service.IElectricLoadService; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | import com.zhitan.realtimedata.service.RealtimeDatabaseService; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.joda.time.DateTime; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: sensor_alarm_item |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-04-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class ElectricLoadServiceImpl implements IElectricLoadService { |
| | | @Autowired |
| | | private RealtimeDatabaseService realtimeDatabaseService; |
| | | @Resource |
| | | private MeterImplementMapper meterImplementMapper; |
| | | |
| | | @Override |
| | | public ListElectricLoadVO list(String timeType, String timeCode, EnergyIndex energyIndex) { |
| | | ListElectricLoadVO vo = new ListElectricLoadVO(); |
| | | List<ListElectricLoadItem> itemList = new ArrayList<>(); |
| | | vo.setItemList(itemList); |
| | | ListElectricLoadDetail detail = new ListElectricLoadDetail(); |
| | | detail.setMaxTime(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMax(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMin(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMinTime(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setAvg(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setRate(CommonConst.DOUBLE_MINUS_SIGN); |
| | | vo.setDetail(detail); |
| | | |
| | | MeterImplement meterImplement = meterImplementMapper.selectById(energyIndex.getMeterId()); |
| | | |
| | | if (ObjectUtil.isEmpty(meterImplement)) { |
| | | return vo; |
| | | } |
| | | List<Date> dateList = new ArrayList<>(); |
| | | ChartUtils.generateDateList(timeType, timeCode, dateList); |
| | | // å 为influxdb没ææç
§æåç»åæ°æ®ï¼åªè½æç
§æ¥æå¾ªç¯åæ°æ® |
| | | if (TimeTypeConst.TIME_TYPE_YEAR.equals(timeType)) { |
| | | getYearData(timeType, dateList, energyIndex, meterImplement.getMeterName(), itemList); |
| | | } else { |
| | | getDayAndMonthData(timeType, timeCode, energyIndex, meterImplement.getMeterName(), itemList); |
| | | } |
| | | if (!StringUtil.isEmptyOrNull(energyIndex.getCode())) { |
| | | Date start = ChartUtils.getDateTime(timeType, timeCode); |
| | | Date end = ChartUtils.getEndTime(timeType, start); |
| | | |
| | | String code = energyIndex.getCode(); |
| | | TagValue maxTagValueModel = realtimeDatabaseService.statistics(code, start, end, CollectionModes.max); |
| | | TagValue minTagValueModel = realtimeDatabaseService.statistics(code, start, end, CollectionModes.min); |
| | | TagValue avgTagValueModel = realtimeDatabaseService.statistics(code, start, end, CollectionModes.mean); |
| | | |
| | | double avg = CommonConst.DIGIT_DOUBLE_0; |
| | | if (!ObjectUtil.isEmpty(avgTagValueModel) && !ObjectUtil.isEmpty(avgTagValueModel.getValue())) { |
| | | detail.setAvg(DoubleUtil.formatDoubleToStr(avgTagValueModel.getValue()) + CommonConst.ELECTRIC_LOAD_UNIT); |
| | | avg = avgTagValueModel.getValue(); |
| | | } |
| | | |
| | | if (!ObjectUtil.isEmpty(maxTagValueModel) && !ObjectUtil.isEmpty(maxTagValueModel.getValue())) { |
| | | detail.setMax(DoubleUtil.formatDoubleToStr(maxTagValueModel.getValue())); |
| | | detail.setMaxTime(DateTimeUtil.getDateTime(maxTagValueModel.getDataTime(), DateTimeUtil.COMMON_PATTERN)); |
| | | |
| | | if (maxTagValueModel.getValue() != CommonConst.DIGIT_DOUBLE_0) { |
| | | double rate = avg * CommonConst.DIGIT_DOUBLE_100 / maxTagValueModel.getValue(); |
| | | detail.setRate(DoubleUtil.formatDoubleToStr(rate) + CommonConst.SYMBOL_PERCENT); |
| | | } |
| | | } |
| | | |
| | | if (!ObjectUtil.isEmpty(minTagValueModel) && !ObjectUtil.isEmpty(minTagValueModel.getValue())) { |
| | | detail.setMin(DoubleUtil.formatDoubleToStr(minTagValueModel.getValue())); |
| | | detail.setMinTime(DateTimeUtil.getDateTime(minTagValueModel.getDataTime(), DateTimeUtil.COMMON_PATTERN)); |
| | | } |
| | | |
| | | if (!CommonConst.DOUBLE_MINUS_SIGN.equals(detail.getMax())) { |
| | | String m = detail.getMax(); |
| | | detail.setMax(m + CommonConst.ELECTRIC_LOAD_UNIT); |
| | | } |
| | | if (!CommonConst.DOUBLE_MINUS_SIGN.equals(detail.getMin())) { |
| | | String min = detail.getMin(); |
| | | detail.setMin(min + CommonConst.ELECTRIC_LOAD_UNIT); |
| | | } |
| | | if (CommonConst.DOUBLE_MINUS_SIGN.equals(detail.getMax())) { |
| | | detail.setAvg(CommonConst.DOUBLE_MINUS_SIGN); |
| | | } |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * è·åæåå¤©æ°æ®,å 为influxdbå¯ä»¥æç
§åãæ¶ã天åç»åæ°ï¼ä¸å¯ä»¥æç
§æåç»åæ°ï¼æä»¥åæä¸¤ä¸ªæ¹æ³æ¥å |
| | | */ |
| | | private void getDayAndMonthData(String timeType, String timeCode, EnergyIndex energyIndex, String meterName, List<ListElectricLoadItem> itemList) { |
| | | String tagCodes = energyIndex.getCode(); |
| | | List<TagValue> maxList = new ArrayList<>(); |
| | | List<TagValue> minList = new ArrayList<>(); |
| | | List<TagValue> avgList = new ArrayList<>(); |
| | | if (TimeTypeConst.TIME_TYPE_DAY.equals(timeType)) { |
| | | } else { |
| | | String tempTimeCode = StringUtil.ifEmptyOrNullReturnValue(timeCode).replace(CommonConst.SINGLE_MINUS_SIGN, CommonConst.EMPTY); |
| | | Date start = DateTimeUtil.toDateTime(tempTimeCode, DateTimeUtil.COMMON_PATTERN_MONTH); |
| | | Date end = DateTimeUtil.addMonths(start, CommonConst.DIGIT_1); |
| | | if (!StringUtil.isEmptyOrNull(tagCodes)) { |
| | | maxList = realtimeDatabaseService.statistics(tagCodes, start, end, CollectionModes.max, GroupTimeType.d); |
| | | minList = realtimeDatabaseService.statistics(tagCodes, start, end, CollectionModes.min, GroupTimeType.d); |
| | | avgList = realtimeDatabaseService.statistics(tagCodes, start, end, CollectionModes.mean, GroupTimeType.d); |
| | | } |
| | | } |
| | | if (CollectionUtils.isEmpty(maxList)) { |
| | | maxList = new ArrayList<>(); |
| | | } |
| | | if (CollectionUtils.isEmpty(minList)) { |
| | | minList = new ArrayList<>(); |
| | | } |
| | | if (CollectionUtils.isEmpty(avgList)) { |
| | | avgList = new ArrayList<>(); |
| | | } |
| | | List<Date> dateList = new ArrayList<>(); |
| | | ChartUtils.generateDateList(timeType, timeCode, dateList); |
| | | Date now = new Date(); |
| | | Date temNow = now; |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | //å½åæ¶é´è½¬ææ´æ¶æ´ç¹ |
| | | temNow = DateTimeUtil.getHourTime(TimeTypeConst.TIME_TYPE_HOUR, now); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | //å½åæ¶é´è½¬ææ´æ¶æ´ç¹ |
| | | temNow = DateTimeUtil.getHourTime(TimeTypeConst.TIME_TYPE_DAY, now); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | for (Date date : dateList) { |
| | | ListElectricLoadItem temp = new ListElectricLoadItem(); |
| | | temp.setTimeCode(ChartUtils.getTimeCode(timeType, date)); |
| | | temp.setName(ObjectUtils.isNotEmpty(meterName) ? meterName : ""); |
| | | temp.setMax(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setMin(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setAvg(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setTimeCodeChart(ChartUtils.getTimeCodeChart(timeType, date)); |
| | | temp.setRate(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setValue(CommonConst.DOUBLE_MINUS_SIGN); |
| | | itemList.add(temp); |
| | | // 妿大äºå½åæ¶é´é»è®¤-- |
| | | if (DateTimeUtil.compareDateDiff(date, temNow) > CommonConst.DIGIT_0) { |
| | | continue; |
| | | } |
| | | //天ç夿 |
| | | if (TimeTypeConst.TIME_TYPE_DAY.equals(timeType)) { |
| | | // ç±äºå®æ¶åºè¿åçæ¶é´å¯¹åºå¼ä»£è¡¨çæ¯åä¸ä¸ªå¨æçå¼ |
| | | Date nextHour = DateTimeUtil.addHours(date, CommonConst.DIGIT_1); |
| | | if (!StringUtil.isEmptyOrNull(energyIndex.getCode())) { |
| | | TagValue tagValue = realtimeDatabaseService.retrieve(energyIndex.getCode(), nextHour); |
| | | if (!ObjectUtil.isEmpty(tagValue)) { |
| | | if (ObjectUtils.isEmpty(tagValue) || ObjectUtils.isEmpty(tagValue.getValue())) { |
| | | temp.setValue(CommonConst.DOUBLE_MINUS_SIGN); |
| | | } else { |
| | | temp.setValue(String.valueOf(DoubleUtil.formatDouble(tagValue.getValue()))); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | //æç夿ï¼ç±äºå®æ¶åºè¿åçæ¶é´å¯¹åºå¼ä»£è¡¨çæ¯åä¸ä¸ªå¨æçå¼ |
| | | Date nextDay = DateTimeUtil.addDays(date, CommonConst.DIGIT_1); |
| | | TagValue tagValueMonth = maxList.stream().filter(x -> (new DateTime(x.getDataTime())).withTimeAtStartOfDay().toDate().equals(nextDay)).findAny().orElse(null); |
| | | if (!ObjectUtil.isEmpty(tagValueMonth)) { |
| | | //æçæ¾å¤© |
| | | TagValue minModel = minList.stream().filter(x -> x.getDataTime().equals(tagValueMonth.getDataTime())).findAny().orElse(null); |
| | | if (!ObjectUtil.isEmpty(minModel)) { |
| | | temp.setMin(String.valueOf(DoubleUtil.formatDouble(minModel.getValue()))); |
| | | } |
| | | TagValue avgModel = avgList.stream().filter(x -> x.getDataTime().equals(tagValueMonth.getDataTime())).findAny().orElse(null); |
| | | if (!ObjectUtil.isEmpty(avgModel)) { |
| | | temp.setAvg(String.valueOf(DoubleUtil.formatDouble(avgModel.getValue()))); |
| | | } |
| | | temp.setMax(String.valueOf(DoubleUtil.formatDouble(tagValueMonth.getValue()))); |
| | | |
| | | temp.setRate(CommonConst.DOUBLE_MINUS_SIGN); |
| | | if (Double.parseDouble(temp.getMax()) != CommonConst.DIGIT_DOUBLE_0) { |
| | | double rate = Double.parseDouble(temp.getAvg()) * 100 / Double.parseDouble(temp.getMax()); |
| | | temp.setRate(DoubleUtil.formatDoubleToStr(rate) + CommonConst.SYMBOL_PERCENT); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åå¹´æ°æ® |
| | | */ |
| | | private void getYearData(String timeType, List<Date> dateList, EnergyIndex energyIndex, String meterName, List<ListElectricLoadItem> itemList) { |
| | | String tagCode = StringUtil.ifEmptyOrNullReturnValue(energyIndex.getCode()); |
| | | for (Date date : dateList) { |
| | | ListElectricLoadItem temp = new ListElectricLoadItem(); |
| | | Date endTime = DateTimeUtil.addMonths(date, CommonConst.DIGIT_1); |
| | | temp.setAvg(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setMax(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setMin(CommonConst.DOUBLE_MINUS_SIGN); |
| | | if (!StringUtil.isEmptyOrNull(tagCode)) { |
| | | String code = energyIndex.getCode(); |
| | | TagValue rt3 = realtimeDatabaseService.statistics(code, date, endTime, CollectionModes.max); |
| | | TagValue rt4 = realtimeDatabaseService.statistics(code, date, endTime, CollectionModes.min); |
| | | TagValue rt2 = realtimeDatabaseService.statistics(code, date, endTime, CollectionModes.mean); |
| | | if (ObjectUtils.isNotEmpty(rt2.getValue())) { |
| | | temp.setAvg(String.valueOf(DoubleUtil.formatDouble(rt2.getValue()))); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(rt3.getValue())) { |
| | | temp.setMax(String.valueOf(DoubleUtil.formatDouble(rt3.getValue()))); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(rt4.getValue())) { |
| | | temp.setMin(String.valueOf(DoubleUtil.formatDouble(rt4.getValue()))); |
| | | } |
| | | } |
| | | |
| | | temp.setTimeCode(ChartUtils.getTimeCode(timeType, date)); |
| | | temp.setTimeCodeChart(ChartUtils.getTimeCodeChart(timeType, date)); |
| | | temp.setName(StringUtil.ifEmptyOrNullReturnValue(meterName)); |
| | | temp.setRate(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setValue(CommonConst.DOUBLE_MINUS_SIGN); |
| | | if (!temp.getMax().equals(CommonConst.DOUBLE_MINUS_SIGN) && Double.parseDouble(temp.getMax()) != CommonConst.DIGIT_DOUBLE_0) { |
| | | double rate = Double.parseDouble(temp.getAvg()) * 100 / Double.parseDouble(temp.getMax()); |
| | | temp.setRate(DoubleUtil.formatDoubleToStr(rate) + CommonConst.SYMBOL_PERCENT); |
| | | } |
| | | itemList.add(temp); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.constant.TimeTypeConst; |
| | | import com.zhitan.common.utils.ChartUtils; |
| | | import com.zhitan.common.utils.DateTimeUtil; |
| | | import com.zhitan.common.utils.DoubleUtil; |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricPowerFactorDetail; |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricPowerFactorItem; |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricPowerFactorVO; |
| | | import com.zhitan.energyMonitor.service.IElectricPowerFactorService; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | import com.zhitan.realtimedata.service.RealtimeDatabaseService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: sensor_alarm_item |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-04-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ElectricPowerFactorServiceImpl implements IElectricPowerFactorService { |
| | | @Autowired |
| | | private RealtimeDatabaseService realtimeDatabaseService; |
| | | |
| | | @Override |
| | | public ElectricPowerFactorVO list(String timeCode, EnergyIndex energyIndex) { |
| | | ElectricPowerFactorVO vo = new ElectricPowerFactorVO(); |
| | | List<ElectricPowerFactorItem> itemList = new ArrayList<>(); |
| | | ElectricPowerFactorDetail detail = new ElectricPowerFactorDetail(); |
| | | detail.setMaxTime(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMax(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMin(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMinTime(CommonConst.DOUBLE_MINUS_SIGN); |
| | | vo.setItemList(itemList); |
| | | vo.setDetail(detail); |
| | | |
| | | List<Date> dateList = new ArrayList<>(); |
| | | ChartUtils.generateDateList(TimeTypeConst.TIME_TYPE_DAY, timeCode, dateList); |
| | | double max = CommonConst.DIGIT_0, min = CommonConst.MIN_INIT_VALUE; |
| | | //dateListè®¡æ° |
| | | Date now = new Date(); |
| | | //å½åæ¶é´è½¬ææ´æ¶æ´ç¹ |
| | | now = DateTimeUtil.getHourTime(TimeTypeConst.TIME_TYPE_HOUR, now); |
| | | int i = CommonConst.DIGIT_0; |
| | | for (Date date : dateList) { |
| | | ElectricPowerFactorItem temp = new ElectricPowerFactorItem(); |
| | | temp.setTimeCode(ChartUtils.getTimeCodeChart(TimeTypeConst.TIME_TYPE_DAY, date)); |
| | | temp.setValue(CommonConst.DOUBLE_MINUS_SIGN); |
| | | itemList.add(temp); |
| | | // 妿大äºå½åæ¶é´é»è®¤-- |
| | | if (DateTimeUtil.compareDateDiff(date, now) > CommonConst.DIGIT_0) { |
| | | i++; |
| | | continue; |
| | | } |
| | | TagValue tagValue = new TagValue(); |
| | | try { |
| | | TagValue retrieve = realtimeDatabaseService.retrieve(energyIndex.getCode(), date); |
| | | if (ObjectUtil.isNotEmpty(retrieve)) { |
| | | tagValue = retrieve; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("è·ååçå æ°å¼å¸¸ï¼" + e.getMessage()); |
| | | } |
| | | if (ObjectUtil.isNotEmpty(tagValue.getValue())) { |
| | | double value = DoubleUtil.formatDouble(tagValue.getValue()); |
| | | |
| | | temp.setValue(String.valueOf(value)); |
| | | //ç»æå°å¼èµå¼ç¬¬ä¸æ¡ |
| | | if (i == CommonConst.DIGIT_0) { |
| | | min = Double.parseDouble(temp.getValue()); |
| | | } |
| | | if (value > max) { |
| | | max = value; |
| | | detail.setMax(max + CommonConst.EMPTY); |
| | | detail.setMaxTime(DateTimeUtil.getDateTime(date)); |
| | | } |
| | | if (value <= min) { |
| | | min = value; |
| | | detail.setMin(min + CommonConst.EMPTY); |
| | | detail.setMinTime(DateTimeUtil.getDateTime(date)); |
| | | } |
| | | } |
| | | i++; |
| | | } |
| | | |
| | | detail.setAvg(CommonConst.DOUBLE_MINUS_SIGN); |
| | | if (ObjectUtil.isNotEmpty(itemList)) { |
| | | double avg = CommonConst.DIGIT_DOUBLE_0; |
| | | for (ElectricPowerFactorItem li : itemList) { |
| | | try { |
| | | if (!li.getValue().equals(CommonConst.DOUBLE_MINUS_SIGN)) { |
| | | avg += DoubleUtil.toDouble(li.getValue()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | } |
| | | detail.setAvg(DoubleUtil.formatDoubleToStr(avg / itemList.size())); |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.energyMonitor.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.zhitan.basicdata.domain.MeterImplement; |
| | | import com.zhitan.basicdata.mapper.MeterImplementMapper; |
| | | import com.zhitan.common.constant.CommonConst; |
| | | import com.zhitan.common.constant.TimeTypeConst; |
| | | import com.zhitan.common.utils.*; |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricThreePhaseDetail; |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricThreePhaseItem; |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricThreePhaseTempModel; |
| | | import com.zhitan.energyMonitor.domain.vo.ElectricThreePhaseVO; |
| | | import com.zhitan.energyMonitor.service.IElectricThreePhaseService; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | import com.zhitan.realtimedata.service.RealtimeDatabaseService; |
| | | import org.joda.time.DateTime; |
| | | import org.joda.time.Duration; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: sensor_alarm_item |
| | | * @Author: jeecg-boot |
| | | * @Date: 2022-04-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class ElectricThreePhaseServiceImpl implements IElectricThreePhaseService { |
| | | |
| | | @Autowired |
| | | private RealtimeDatabaseService realtimeDatabaseService; |
| | | @Resource |
| | | private MeterImplementMapper meterImplementMapper; |
| | | |
| | | /** |
| | | * è·åä¸ç¸ä¸å¹³è¡¡æ°æ® |
| | | * |
| | | * @param timeType æ¶é´ç±»å |
| | | * @param timeCode æ¶é´ç¼ç |
| | | * @param energyIndexList ç¹ä½éå |
| | | * @param requestType ç±»å |
| | | * @return ElectricThreePhaseVo |
| | | * @Date 14:27 2022/5/30 |
| | | **/ |
| | | @Override |
| | | public ElectricThreePhaseVO list(String timeType, String timeCode, List<EnergyIndex> energyIndexList, String requestType, String meterId) { |
| | | ElectricThreePhaseVO vo = new ElectricThreePhaseVO(); |
| | | if (ObjectUtil.isEmpty(energyIndexList)) { |
| | | return vo; |
| | | } |
| | | // è·åçµåä¸å¹³è¡¡æ°æ® |
| | | if (CommonConst.STR_NUMBER_0.equals(requestType)) { |
| | | energyIndexList = energyIndexList.stream() |
| | | .filter(x -> StringUtil.ifEmptyOrNullReturnValue(x.getCode()).trim().endsWith(CommonConst.TAG_CODE_VOLTAGE_A) |
| | | || StringUtil.ifEmptyOrNullReturnValue(x.getCode()).trim().endsWith(CommonConst.TAG_CODE_VOLTAGE_B) |
| | | || StringUtil.ifEmptyOrNullReturnValue(x.getCode()).trim().endsWith(CommonConst.TAG_CODE_VOLTAGE_C)).collect(Collectors.toList()); |
| | | } else { |
| | | energyIndexList = energyIndexList.stream() |
| | | .filter(x -> StringUtil.ifEmptyOrNullReturnValue(x.getCode()).trim().endsWith(CommonConst.TAG_CODE_CURRENT_A) |
| | | || StringUtil.ifEmptyOrNullReturnValue(x.getCode()).trim().endsWith(CommonConst.TAG_CODE_CURRENT_B) |
| | | || StringUtil.ifEmptyOrNullReturnValue(x.getCode()).trim().endsWith(CommonConst.TAG_CODE_CURRENT_C)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | List<String> tagCodeList = energyIndexList.stream().map(EnergyIndex::getCode).collect(Collectors.toList()); |
| | | tagCodeList.add(CommonConst.STR_NUMBER_MINUS_ONE); |
| | | String tagCodes = String.join(StrUtil.COMMA, tagCodeList); |
| | | |
| | | Date start = ChartUtils.getDateTime(timeType, timeCode); |
| | | Date end = getEndTime(timeType, start); |
| | | |
| | | DateTime begin = new DateTime(start); |
| | | DateTime finish = new DateTime(end); |
| | | long millis = new Duration(begin, finish).getMillis(); |
| | | int pointCount = IntegerUtil.toInt(millis / CommonConst.DIGIT_3600 / CommonConst.DIGIT_1000); |
| | | |
| | | List<TagValue> tagValueList = realtimeDatabaseService.retrieve(tagCodes, start, end, pointCount); |
| | | List<ElectricThreePhaseItem> itemList = new ArrayList<>(); |
| | | List<Date> dateList = new ArrayList<>(); |
| | | ChartUtils.generateDateList(timeType, timeCode, dateList); |
| | | ElectricThreePhaseTempModel tempModel = new ElectricThreePhaseTempModel(); |
| | | |
| | | Date now = new Date(); |
| | | for (Date date : dateList) { |
| | | Date tempDate = date; |
| | | Date temNow = now; |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | tempDate = DateTimeUtil.addHours(date, CommonConst.DIGIT_1); |
| | | //å½åæ¶é´è½¬ææ´æ¶æ´ç¹ |
| | | temNow = DateTimeUtil.getHourTime(TimeTypeConst.TIME_TYPE_HOUR, now); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | tempDate = date; |
| | | //å½åæ¶é´è½¬ææ´æ¶æ´ç¹ |
| | | temNow = DateTimeUtil.getHourTime(TimeTypeConst.TIME_TYPE_DAY, now); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | tempDate = date; |
| | | temNow = DateTimeUtil.getHourTime(TimeTypeConst.TIME_TYPE_MONTH, now); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | MeterImplement meterImplement = meterImplementMapper.selectById(meterId); |
| | | |
| | | ElectricThreePhaseItem temp = new ElectricThreePhaseItem(); |
| | | if (ObjectUtil.isNotEmpty(meterImplement)) { |
| | | temp.setName(meterImplement.getMeterName()); |
| | | } |
| | | temp.setTimeCode(ChartUtils.getTimeCode(timeType, date)); |
| | | temp.setTimeCodeChart(ChartUtils.getTimeCodeChart(timeType, date)); |
| | | temp.setValueA(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setValueB(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setValueC(CommonConst.DOUBLE_MINUS_SIGN); |
| | | itemList.add(temp); |
| | | // 妿大äºå½åæ¶é´é»è®¤-- |
| | | if (DateTimeUtil.compareDateDiff(date, temNow) > CommonConst.DIGIT_0) { |
| | | continue; |
| | | } |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | // æé å½å¤©æ¯ä¸ªå°æ¶çæ°æ® |
| | | listDayData(tempDate, tagValueList, temp, tempModel); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | // æé 彿æ¯å¤©çæ°æ® |
| | | listMonthData(tempDate, tagValueList, temp, tempModel); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | // æé å½å¹´æ¯æçæ°æ® |
| | | listYearData(tempDate, tagValueList, temp, tempModel); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (ObjectUtil.isEmpty(tempModel.getMin()) || CommonConst.MIN_INIT_VALUE == tempModel.getMin()) { |
| | | tempModel.setMin(null); |
| | | } |
| | | //è®¾ç½®å¼ |
| | | ElectricThreePhaseDetail detail = new ElectricThreePhaseDetail(); |
| | | BeanUtils.copyProperties(tempModel, detail); |
| | | detail.setMax(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMaxTime(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setValueMaxA(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setValueMaxB(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setValueMaxC(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMin(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setMinTime(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setValueMinA(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setValueMinB(CommonConst.DOUBLE_MINUS_SIGN); |
| | | detail.setValueMinC(CommonConst.DOUBLE_MINUS_SIGN); |
| | | if (ObjectUtil.isNotNull(tempModel.getMax())) { |
| | | detail.setMax(DoubleUtil.formatDoubleToStr(tempModel.getMax()) + CommonConst.SYMBOL_PERCENT); |
| | | detail.setMaxTime(DateTimeUtil.getDateTime(tempModel.getMaxTime())); |
| | | detail.setValueMaxA(DoubleUtil.formatDoubleToStr(tempModel.getValueMaxA())); |
| | | detail.setValueMaxB(DoubleUtil.formatDoubleToStr(tempModel.getValueMaxB())); |
| | | detail.setValueMaxC(DoubleUtil.formatDoubleToStr(tempModel.getValueMaxC())); |
| | | } |
| | | if (ObjectUtil.isNotNull(tempModel.getMin())) { |
| | | detail.setMin(DoubleUtil.formatDoubleToStr(tempModel.getMin()) + CommonConst.SYMBOL_PERCENT); |
| | | detail.setMinTime(DateTimeUtil.getDateTime(tempModel.getMinTime())); |
| | | detail.setValueMinA(DoubleUtil.formatDoubleToStr(tempModel.getValueMinA())); |
| | | detail.setValueMinB(DoubleUtil.formatDoubleToStr(tempModel.getValueMinB())); |
| | | detail.setValueMinC(DoubleUtil.formatDoubleToStr(tempModel.getValueMinC())); |
| | | } |
| | | vo.setDetail(detail); |
| | | vo.setItemList(itemList); |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * æé å½æçæ°æ®å表 |
| | | * |
| | | * @param date |
| | | * @param tagValueList |
| | | * @param temp |
| | | * @param tempModel |
| | | */ |
| | | private void listYearData(Date date, List<TagValue> tagValueList, ElectricThreePhaseItem temp, ElectricThreePhaseTempModel tempModel) { |
| | | List<Date> dateList = new ArrayList<>(); |
| | | ChartUtils.generateDateList(TimeTypeConst.TIME_TYPE_MONTH, DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_TO_MONTH), dateList); |
| | | ElectricThreePhaseTempModel tempModelMonth = new ElectricThreePhaseTempModel(); |
| | | for (Date date1 : dateList) { |
| | | listMonthData(date1, tagValueList, temp, tempModelMonth); |
| | | temp.setMax(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setMin(CommonConst.DOUBLE_MINUS_SIGN); |
| | | if (ObjectUtil.isNotNull(tempModelMonth.getMax())) { |
| | | temp.setMax(DoubleUtil.formatDoubleToStr(tempModelMonth.getMax())); |
| | | } |
| | | if (ObjectUtil.isNotNull(tempModelMonth.getMin())) { |
| | | temp.setMin(DoubleUtil.formatDoubleToStr(tempModelMonth.getMin())); |
| | | } |
| | | if (ObjectUtil.isEmpty(tempModel.getMin()) || CommonConst.MIN_INIT_VALUE == tempModel.getMin()) { |
| | | tempModel.setMin(null); |
| | | } |
| | | if (ObjectUtil.isNotNull(tempModelMonth.getMax())) { |
| | | if (ObjectUtil.isNull(tempModel.getMax()) || (ObjectUtil.isNotNull(tempModel.getMax()) && tempModelMonth.getMax() > tempModel.getMax())) { |
| | | tempModel.setMax(DoubleUtil.formatDouble(tempModelMonth.getMax())); |
| | | tempModel.setMaxTime(tempModelMonth.getMaxTime()); |
| | | tempModel.setValueMaxA(DoubleUtil.formatDouble(tempModelMonth.getValueMaxA())); |
| | | tempModel.setValueMaxB(DoubleUtil.formatDouble(tempModelMonth.getValueMaxB())); |
| | | tempModel.setValueMaxC(DoubleUtil.formatDouble(tempModelMonth.getValueMaxC())); |
| | | } |
| | | } |
| | | if (ObjectUtil.isNotNull(tempModelMonth.getMin())) { |
| | | if (ObjectUtil.isNull(tempModel.getMin()) || (ObjectUtil.isNotNull(tempModel.getMin()) && tempModelMonth.getMin() <= tempModel.getMin())) { |
| | | tempModel.setMin(DoubleUtil.formatDouble(tempModelMonth.getMin())); |
| | | tempModel.setMinTime(tempModelMonth.getMinTime()); |
| | | tempModel.setValueMinA(DoubleUtil.formatDouble(tempModelMonth.getValueMinA())); |
| | | tempModel.setValueMinB(DoubleUtil.formatDouble(tempModelMonth.getValueMinB())); |
| | | tempModel.setValueMinC(DoubleUtil.formatDouble(tempModelMonth.getValueMinC())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æé å½æçæ°æ®å表 |
| | | * |
| | | * @param date |
| | | * @param tagValueList |
| | | * @param temp |
| | | * @param tempModel |
| | | */ |
| | | private void listMonthData(Date date, List<TagValue> tagValueList, ElectricThreePhaseItem temp, ElectricThreePhaseTempModel tempModel) { |
| | | List<Date> dateList = new ArrayList<>(); |
| | | ChartUtils.generateDateList(TimeTypeConst.TIME_TYPE_DAY, DateTimeUtil.getDateTime(date, DateTimeUtil.COMMON_PATTERN_TO_DAY), dateList); |
| | | ElectricThreePhaseTempModel tempModelDay = new ElectricThreePhaseTempModel(); |
| | | for (Date date1 : dateList) { |
| | | Date tempDate = DateTimeUtil.addHours(date1, CommonConst.DIGIT_1); |
| | | listDayData(tempDate, tagValueList, temp, tempModelDay); |
| | | temp.setMax(CommonConst.DOUBLE_MINUS_SIGN); |
| | | temp.setMin(CommonConst.DOUBLE_MINUS_SIGN); |
| | | if (ObjectUtil.isNotNull(tempModelDay.getMax())) { |
| | | temp.setMax(DoubleUtil.formatDoubleToStr(tempModelDay.getMax())); |
| | | } |
| | | if (ObjectUtil.isNotNull(tempModelDay.getMin())) { |
| | | temp.setMin(DoubleUtil.formatDoubleToStr(tempModelDay.getMin())); |
| | | } |
| | | if (ObjectUtil.isEmpty(tempModel.getMin()) || CommonConst.MIN_INIT_VALUE == tempModel.getMin()) { |
| | | tempModel.setMin(null); |
| | | } |
| | | if (ObjectUtil.isNotNull(tempModelDay.getMax())) { |
| | | if (ObjectUtil.isNull(tempModel.getMax()) || (ObjectUtil.isNotNull(tempModel.getMax()) && tempModelDay.getMax() > tempModel.getMax())) { |
| | | tempModel.setMax(DoubleUtil.formatDouble(tempModelDay.getMax())); |
| | | tempModel.setMaxTime(tempModelDay.getMaxTime()); |
| | | tempModel.setValueMaxA(DoubleUtil.formatDouble(tempModelDay.getValueMaxA())); |
| | | tempModel.setValueMaxB(DoubleUtil.formatDouble(tempModelDay.getValueMaxB())); |
| | | tempModel.setValueMaxC(DoubleUtil.formatDouble(tempModelDay.getValueMaxC())); |
| | | } |
| | | } |
| | | if (ObjectUtil.isNotNull(tempModelDay.getMin())) { |
| | | if (ObjectUtil.isNull(tempModel.getMin()) || (ObjectUtil.isNotNull(tempModel.getMin()) && tempModelDay.getMin() <= tempModel.getMin())) { |
| | | tempModel.setMin(DoubleUtil.formatDouble(tempModelDay.getMin())); |
| | | tempModel.setMinTime(tempModelDay.getMinTime()); |
| | | tempModel.setValueMinA(DoubleUtil.formatDouble(tempModelDay.getValueMinA())); |
| | | tempModel.setValueMinB(DoubleUtil.formatDouble(tempModelDay.getValueMinB())); |
| | | tempModel.setValueMinC(DoubleUtil.formatDouble(tempModelDay.getValueMinC())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åå½å¤©çæ°æ®å表 |
| | | * |
| | | * @param date |
| | | * @param tagValueList |
| | | * @param tempModel |
| | | */ |
| | | private void listDayData(Date date, List<TagValue> tagValueList, ElectricThreePhaseItem temp, ElectricThreePhaseTempModel tempModel) { |
| | | Date endTime = DateTimeUtil.addHours(date, CommonConst.DIGIT_1); |
| | | List<TagValue> currentTagValueList = tagValueList.stream().filter(x -> DateTimeUtil.compareDateDiff(date, x.getDataTime()) <= 0 && DateTimeUtil.compareDateDiff(endTime, x.getDataTime()) > 0).collect(Collectors.toList()); |
| | | List<TagValue> currentATagValueList = currentTagValueList.stream().filter(x -> StringUtil.ifEmptyOrNullReturnValue(x.getTagCode()).trim().endsWith("_A")).collect(Collectors.toList()); |
| | | List<TagValue> currentBTagValueList = currentTagValueList.stream().filter(x -> StringUtil.ifEmptyOrNullReturnValue(x.getTagCode()).trim().endsWith("_B")).collect(Collectors.toList()); |
| | | List<TagValue> currentCTagValueList = currentTagValueList.stream().filter(x -> StringUtil.ifEmptyOrNullReturnValue(x.getTagCode()).trim().endsWith("_C")).collect(Collectors.toList()); |
| | | TagValue tagValueA = currentATagValueList.stream().filter(x -> DateTimeUtil.compareDateDiff(date, x.getDataTime()) == 0).findAny().orElse(null); |
| | | TagValue tagValueB = currentBTagValueList.stream().filter(x -> DateTimeUtil.compareDateDiff(date, x.getDataTime()) == 0).findAny().orElse(null); |
| | | TagValue tagValueC = currentCTagValueList.stream().filter(x -> DateTimeUtil.compareDateDiff(date, x.getDataTime()) == 0).findAny().orElse(null); |
| | | Double valueA = null, valueB = null, valueC = null; |
| | | if (ObjectUtil.isNotEmpty(tagValueA)) { |
| | | valueA = tagValueA.getValue(); |
| | | temp.setValueA(String.valueOf(DoubleUtil.formatDouble(tagValueA.getValue()))); |
| | | } else { |
| | | temp.setValueA(CommonConst.DOUBLE_MINUS_SIGN); |
| | | } |
| | | if (!ObjectUtil.isEmpty(tagValueB)) { |
| | | valueB = tagValueB.getValue(); |
| | | temp.setValueB(String.valueOf(DoubleUtil.formatDouble(tagValueB.getValue()))); |
| | | } else { |
| | | temp.setValueB(CommonConst.DOUBLE_MINUS_SIGN); |
| | | } |
| | | if (!ObjectUtil.isEmpty(tagValueC)) { |
| | | valueC = tagValueC.getValue(); |
| | | temp.setValueC(String.valueOf(DoubleUtil.formatDouble(tagValueC.getValue()))); |
| | | } else { |
| | | temp.setValueC(CommonConst.DOUBLE_MINUS_SIGN); |
| | | } |
| | | Double value = calcUnbalanceValue(valueA, valueB, valueC); |
| | | if (ObjectUtil.isEmpty(value)) { |
| | | return; |
| | | } |
| | | if (ObjectUtil.isEmpty(tempModel.getMin()) || CommonConst.MIN_INIT_VALUE == tempModel.getMin()) { |
| | | tempModel.setMin(value); |
| | | } |
| | | if (ObjectUtil.isEmpty(tempModel.getMax()) || value > tempModel.getMax()) { |
| | | tempModel.setMax(DoubleUtil.formatDouble(value)); |
| | | if (!ObjectUtil.isEmpty(tagValueA)) { |
| | | tempModel.setMaxTime(tagValueA.getDataTime()); |
| | | } |
| | | tempModel.setValueMaxA(DoubleUtil.formatDouble(valueA)); |
| | | tempModel.setValueMaxB(DoubleUtil.formatDouble(valueB)); |
| | | tempModel.setValueMaxC(DoubleUtil.formatDouble(valueC)); |
| | | } |
| | | if (ObjectUtil.isEmpty(tempModel.getMin()) || value <= tempModel.getMin()) { |
| | | tempModel.setMin(DoubleUtil.formatDouble(value)); |
| | | tempModel.setValueMinA(DoubleUtil.formatDouble(valueA)); |
| | | tempModel.setValueMinB(DoubleUtil.formatDouble(valueB)); |
| | | tempModel.setValueMinC(DoubleUtil.formatDouble(valueC)); |
| | | if (!ObjectUtil.isEmpty(tagValueA)) { |
| | | tempModel.setMinTime(tagValueA.getDataTime()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 计ç®ä¸ç¸ä¸å¹³è¡¡æå¼ |
| | | * |
| | | * @param valueA |
| | | * @param valueB |
| | | * @param valueC |
| | | * @return |
| | | */ |
| | | private Double calcUnbalanceValue(Double valueA, Double valueB, Double valueC) { |
| | | /** |
| | | * 1ã计ç®ä¸ç¸å¹³åçµæµï¼A/B/Cä¸ç¸çµæµç¸å é¤ä»¥3 |
| | | * 2ã MAXï¼ç¸çµæµ-ä¸ç¸å¹³åçµæµï¼/ä¸ç¸å¹³åçµæµï¼ |
| | | * æ¯å¦ä¸ç¸çµæµåå«ä¸ºIA=9A IB=8A IC=4Aï¼åä¸ç¸å¹³åçµæµä¸º7Aï¼ç¸çµæµ-ä¸ç¸å¹³åçµæµåå«ä¸º2A 1A 3Aï¼å差弿大é£ä¸ªï¼æ
MAXï¼ç¸çµæµ-ä¸ç¸å¹³åçµæµï¼=3Aï¼æä»¥ä¸ç¸çµæµä¸å¹³è¡¡åº¦=3/7ã |
| | | */ |
| | | Double result = null; |
| | | Double sum = null; |
| | | if (ObjectUtil.isNotNull(valueA)) { |
| | | sum = valueA; |
| | | } |
| | | if (ObjectUtil.isNotNull(valueB)) { |
| | | sum += valueB; |
| | | } |
| | | if (ObjectUtil.isNotNull(valueC)) { |
| | | sum += valueC; |
| | | } |
| | | if (ObjectUtil.isNotNull(sum)) { |
| | | double avg = sum / CommonConst.DIGIT_3; |
| | | double diff1 = 0, diff2 = 0, diff3 = 0; |
| | | if (ObjectUtil.isNotNull(valueA)) { |
| | | diff1 = Math.abs(valueA - avg); |
| | | } |
| | | if (ObjectUtil.isNotNull(valueB)) { |
| | | diff2 = Math.abs(valueB - avg); |
| | | } |
| | | if (ObjectUtil.isNotNull(valueC)) { |
| | | diff3 = Math.abs(valueC - avg); |
| | | } |
| | | double max = diff1; |
| | | if (diff2 > max) { |
| | | max = diff2; |
| | | } |
| | | if (diff3 > max) { |
| | | max = diff3; |
| | | } |
| | | if (avg != CommonConst.DIGIT_DOUBLE_0) { |
| | | result = max * CommonConst.DIGIT_DOUBLE_100 / avg; |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * è·å对åºçç»ææ¶é´ |
| | | * |
| | | * @param timeType |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public static Date getEndTime(String timeType, Date date) { |
| | | Date d1 = null; |
| | | switch (timeType) { |
| | | case TimeTypeConst.TIME_TYPE_DAY: |
| | | d1 = DateTimeUtil.addDays(date, CommonConst.DIGIT_1); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_MONTH: |
| | | d1 = DateTimeUtil.addMonths(date, CommonConst.DIGIT_1); |
| | | break; |
| | | case TimeTypeConst.TIME_TYPE_YEAR: |
| | | d1 = DateTimeUtil.addYears(date, CommonConst.DIGIT_1); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return d1; |
| | | } |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "表计id") |
| | | private String meterId; |
| | | |
| | | @ApiModelProperty(value = "顺åºå·") |
| | | @Excel(name = "顺åºå·") |
| | | private int orderNum; |
| | | |
| | | @ApiModelProperty(value = "") |
| | | private String equipment; |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | private String energyId; |
| | | |
| | | @Transient |
| | | @TableField(exist = false) |
| | | private String meterName; |
| | | |
| | | public void setIndexId(String indexId) { |
| | | this.indexId = indexId; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.model.domain; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 模åèç¹ä¸ææ çå
³èå
³ç³»(NodeIndex)å®ä½ç±» |
| | | * |
| | | * @author makejava |
| | | * @since 2025-02-10 15:08:14 |
| | | */ |
| | | @Data |
| | | public class NodeIndex implements Serializable { |
| | | private static final long serialVersionUID = 386292923712960012L; |
| | | /** |
| | | * èç¹ä¸»é® |
| | | */ |
| | | private String nodeId; |
| | | /** |
| | | * ææ ä¸»é® |
| | | */ |
| | | private String indexId; |
| | | |
| | | } |
| | | |
| | |
| | | import com.zhitan.basicdata.domain.MeterImplement; |
| | | import com.zhitan.basicdata.domain.SysEnergy; |
| | | import com.zhitan.basicdata.domain.SysProduct; |
| | | import com.zhitan.common.enums.TimeType; |
| | | import com.zhitan.dataitem.domain.vo.NodeIndexValueVO; |
| | | import com.zhitan.model.domain.EnergyIndex; |
| | | import com.zhitan.model.domain.ModelNode; |
| | | import com.zhitan.model.domain.vo.ModelNodeIndexInfor; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | ModelNode getFirstModeNodeInfo(String modelCode); |
| | | |
| | | List<ModelNodeIndexInfor> selectIndexByNodeIds(@Param("modelCode") String modelCode,@Param("nodeIds") List<String> nodeIds); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¶èç¹idåè½æºç±»åæ¥è¯¢ç¹ä½ä¸ç累积é |
| | | */ |
| | | List<NodeIndexValueVO> getDataItemByParentNodeId(@Param("parentId") String parentId, |
| | | @Param("energyType") String energyType, |
| | | @Param("timeType") TimeType timeType, |
| | | @Param("dateTimeMap") Map<String, LocalDateTime> dateTimeMap); |
| | | |
| | | /** |
| | | * æ ¹æ®èç¹idåè½æºç±»åæ¥è¯¢ç¹ä½ä¸ç累积é |
| | | */ |
| | | List<NodeIndexValueVO> getDataItemByNodeId(@Param("nodeId") String nodeId, |
| | | @Param("energyType") String energyType, |
| | | @Param("timeType") TimeType timeType, |
| | | @Param("dateTimeMap") Map<String, LocalDateTime> dateTimeMap); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.model.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.zhitan.model.domain.NodeIndex; |
| | | |
| | | /** |
| | | * 模åèç¹ä¸ææ çå
³èå
³ç³»(NodeIndex)è¡¨æ°æ®åºè®¿é®å± |
| | | * |
| | | * @author makejava |
| | | * @since 2025-02-10 15:09:17 |
| | | */ |
| | | public interface NodeIndexMapper extends BaseMapper<NodeIndex> { |
| | | |
| | | } |
| | | |
| | |
| | | * @author fanxinfu |
| | | * @date 2020-02-14 |
| | | */ |
| | | public interface IEnergyIndexService { |
| | | public interface IEnergyIndexService { |
| | | |
| | | EnergyIndex getiEnergyIndexByCode(String code); |
| | | EnergyIndex getiEnergyIndexByCode(String code); |
| | | |
| | | /** |
| | | * æ ¹æ®è®¡éå¨å
·idéåæ¥è¯¢ç¹ä½ä¿¡æ¯ |
| | | * |
| | | * @param meterId 计éå¨å
·idéå |
| | | * @return |
| | | */ |
| | | List<EnergyIndex> listIndexByMeterIds(String nodeId,List<String> meterId); |
| | | /** |
| | | * æ ¹æ®è®¡éå¨å
·idéåæ¥è¯¢ç¹ä½ä¿¡æ¯ |
| | | * |
| | | * @param meterId 计éå¨å
·idéå |
| | | * @return |
| | | */ |
| | | List<EnergyIndex> listIndexByMeterIds(String nodeId, List<String> meterId); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param indexId ææ ä¿¡æ¯ID |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | EnergyIndex selectEnergyIndexById(String indexId); |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param indexId ææ ä¿¡æ¯ID |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | EnergyIndex selectEnergyIndexById(String indexId); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param indexId ææ ä¿¡æ¯ID |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | List<EnergyIndex> selectEnergyIndexByIds(List<String> indexId); |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param indexId ææ ä¿¡æ¯ID |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | List<EnergyIndex> selectEnergyIndexByIds(List<String> indexId); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯å表 |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ææ ä¿¡æ¯éå |
| | | */ |
| | | List<EnergyIndex> selectEnergyIndexList(EnergyIndex energyIndex); |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯å表 |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ææ ä¿¡æ¯éå |
| | | */ |
| | | List<EnergyIndex> selectEnergyIndexList(EnergyIndex energyIndex); |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯å表 |
| | | * |
| | | * @param query ææ ä¿¡æ¯ |
| | | * @return ææ ä¿¡æ¯éå |
| | | */ |
| | | List<EnergyIndex> selectEnergyIndexList(EnergyIndexQuery query); |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯å表 |
| | | * |
| | | * @param query ææ ä¿¡æ¯ |
| | | * @return ææ ä¿¡æ¯éå |
| | | */ |
| | | List<EnergyIndex> selectEnergyIndexList(EnergyIndexQuery query); |
| | | |
| | | /** |
| | | * æ°å¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param nodeId |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | int insertEnergyIndex(String nodeId, EnergyIndex energyIndex); |
| | | /** |
| | | * æ°å¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param nodeId |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | int insertEnergyIndex(String nodeId, EnergyIndex energyIndex); |
| | | |
| | | /** |
| | | * ä¿®æ¹ææ ä¿¡æ¯ |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | int updateEnergyIndex(EnergyIndex energyIndex); |
| | | /** |
| | | * ä¿®æ¹ææ ä¿¡æ¯ |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | int updateEnergyIndex(EnergyIndex energyIndex); |
| | | |
| | | /** |
| | | * æ¹éå 餿æ ä¿¡æ¯ |
| | | * |
| | | * |
| | | * @param nodeId |
| | | * @param indexIds éè¦å é¤çææ ä¿¡æ¯ID |
| | | * @return ç»æ |
| | | */ |
| | | int deleteEnergyIndexByIds(String nodeId, String[] indexIds); |
| | | /** |
| | | * æ¹éå 餿æ ä¿¡æ¯ |
| | | * |
| | | * @param nodeId |
| | | * @param indexIds éè¦å é¤çææ ä¿¡æ¯ID |
| | | * @return ç»æ |
| | | */ |
| | | int deleteEnergyIndexByIds(String nodeId, String[] indexIds); |
| | | |
| | | boolean energyIndexHasExist(String code); |
| | | boolean energyIndexHasExist(String code); |
| | | |
| | | boolean energyIndexHasExist(String indexId, String code); |
| | | boolean energyIndexHasExist(String indexId, String code); |
| | | |
| | | AjaxResult addMeterIndex(String meterId); |
| | | AjaxResult addMeterIndex(String meterId); |
| | | |
| | | List<EnergyIndex> getMeterIndex(String meterId); |
| | | List<EnergyIndex> getMeterIndex(String meterId); |
| | | |
| | | boolean modelHasConfig(String modelCode); |
| | | boolean modelHasConfig(String modelCode); |
| | | |
| | | List<EnergyIndex> selectCollectIndex(String deviceId); |
| | | List<EnergyIndex> selectCollectIndex(String deviceId); |
| | | |
| | | List<EnergyIndex> getEnergyIndexByIds(List<String> indexIds); |
| | | List<EnergyIndex> getEnergyIndexByIds(List<String> indexIds); |
| | | |
| | | List<EnergyIndex> getEnergyIndexByCodes(List<String> indexCodes); |
| | | List<EnergyIndex> getEnergyIndexByCodes(List<String> indexCodes); |
| | | |
| | | List<EnergyIndex> getIndexByNodeAndChildrenNode(String nodeId); |
| | | List<EnergyIndex> getIndexByNodeAndChildrenNode(String nodeId); |
| | | |
| | | List<EnergyIndex> searchIndexByNodeAndChildrenNode(String nodeId, String filter); |
| | | List<EnergyIndex> searchIndexByNodeAndChildrenNode(String nodeId, String filter); |
| | | |
| | | void removeNodeIndex(String nodeId, List<String> removeLink); |
| | | void removeNodeIndex(String nodeId, List<String> removeLink); |
| | | |
| | | AjaxResult importEnergyIndex(List<EnergyIndex> energyIndexList, boolean updateSupport); |
| | | AjaxResult importEnergyIndex(List<EnergyIndex> energyIndexList, boolean updateSupport); |
| | | |
| | | List<EnergyIndex> getEnergyIndexMeterByCodes(List<String> indexCodes); |
| | | List<EnergyIndex> getEnergyIndexMeterByCodes(List<String> indexCodes); |
| | | |
| | | Page<EnergyIndex> selectEnergyIndexPage(EnergyIndexQuery query, Long pageNum, Long pageSize); |
| | | Page<EnergyIndex> selectEnergyIndexPage(EnergyIndexQuery query, Long pageNum, Long pageSize); |
| | | |
| | | Page<EnergyIndex> getMeterIndexList(List<String> meterIndexIds,String code, |
| | | String name,Long pageNum, Long pageSize); |
| | | Page<EnergyIndex> getMeterIndexList(List<String> meterIndexIds, String code, |
| | | String name, Long pageNum, Long pageSize); |
| | | |
| | | List<EnergyIndex> getIndexByCode(String code,String nodeId); |
| | | List<EnergyIndex> getIndexByCode(String code, String nodeId); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idå设å¤idï¼ä»¥åç¹ä½ç¼ç è·åç¹ä½ |
| | | * |
| | | * @param nodeId èç¹id |
| | | * @param meterId 设å¤id |
| | | * @param indexCode ç¹ä½ç¼ç æè
ç¹ä½ç¼ç çä¸é¨å |
| | | * @return |
| | | */ |
| | | EnergyIndex getDeviceIndexByCode(String nodeId, String meterId, String indexCode); |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idå设å¤idï¼ä»¥åç¹ä½ç¼ç è·åç¹ä½ |
| | | * |
| | | * @param nodeId èç¹id |
| | | * @param meterId 设å¤id |
| | | * @return |
| | | */ |
| | | List<EnergyIndex> listDeviceIndex(String nodeId, String meterId); |
| | | } |
| | |
| | | package com.zhitan.model.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zhitan.basicdata.domain.MeterImplement; |
| | | import com.zhitan.basicdata.services.IMeterImplementService; |
| | |
| | | import com.zhitan.model.service.IEnergyIndexService; |
| | | import com.zhitan.model.service.IModelNodeService; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Service |
| | | public class EnergyIndexServiceImpl implements IEnergyIndexService { |
| | | |
| | | @Autowired |
| | | private EnergyIndexMapper energyIndexMapper; |
| | | @Autowired |
| | | private IDaqTemplateService daqTemplateService; |
| | | @Autowired |
| | | private IMeterImplementService meterImplementService; |
| | | @Autowired |
| | | private IModelNodeService modelNodeService; |
| | | @Autowired |
| | | private EnergyIndexMapper energyIndexMapper; |
| | | @Autowired |
| | | private IDaqTemplateService daqTemplateService; |
| | | @Autowired |
| | | private IMeterImplementService meterImplementService; |
| | | @Autowired |
| | | private IModelNodeService modelNodeService; |
| | | |
| | | @Autowired |
| | | private ModelNodeMapper modelNodeMapper; |
| | | @Autowired |
| | | private ModelNodeMapper modelNodeMapper; |
| | | |
| | | @Override |
| | | public EnergyIndex getiEnergyIndexByCode(String code) { |
| | | return energyIndexMapper.getiEnergyIndexByCode(code); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> listIndexByMeterIds(String nodeId, List<String> meterId) { |
| | | return energyIndexMapper.listIndexByMeterIds(nodeId,meterId); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param indexId ææ ä¿¡æ¯ID |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public EnergyIndex selectEnergyIndexById(String indexId) { |
| | | return energyIndexMapper.selectEnergyIndexById(indexId); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> selectEnergyIndexByIds(List<String> indexId) { |
| | | if (CollectionUtils.isEmpty(indexId)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return energyIndexMapper.selectEnergyIndexByIds(indexId); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> selectEnergyIndexList(EnergyIndex energyIndex) { |
| | | return energyIndexMapper.selectEnergyIndexList(energyIndex); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯å表 |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public List<EnergyIndex> selectEnergyIndexList(EnergyIndexQuery query) { |
| | | return energyIndexMapper.selectEnergyIndex(query); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param nodeId |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int insertEnergyIndex(String nodeId, EnergyIndex energyIndex) { |
| | | energyIndex.setNodeId(nodeId); |
| | | energyIndexMapper.insertEnergyIndex( energyIndex); |
| | | return energyIndexMapper.insertNodeIndex(nodeId,energyIndex.getIndexId()); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ææ ä¿¡æ¯ |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int updateEnergyIndex(EnergyIndex energyIndex) { |
| | | return energyIndexMapper.updateEnergyIndex(energyIndex); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå 餿æ ä¿¡æ¯ |
| | | * |
| | | * @param nodeId |
| | | * @param indexIds éè¦å é¤çææ ä¿¡æ¯ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteEnergyIndexByIds(String nodeId, String[] indexIds) { |
| | | return energyIndexMapper.deleteEnergyIndexByIds(nodeId, indexIds); |
| | | } |
| | | |
| | | @Override |
| | | public boolean energyIndexHasExist(String code) { |
| | | int count = energyIndexMapper.energyIndexHasExist(code); |
| | | return count > 0; |
| | | } |
| | | |
| | | @Override |
| | | public boolean energyIndexHasExist(String indexId, String code) { |
| | | int count = energyIndexMapper.energyIndexHasExistWhenUpdate(indexId, code); |
| | | return count > 0; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addMeterIndex(String meterId) { |
| | | MeterImplement meterImplement = meterImplementService.selectMeterImplementById(meterId); |
| | | if (meterImplement == null) { |
| | | return AjaxResult.error("æ¾ä¸å°å¯¹åºç计éå¨å
·ï¼"); |
| | | @Override |
| | | public EnergyIndex getiEnergyIndexByCode(String code) { |
| | | return energyIndexMapper.getiEnergyIndexByCode(code); |
| | | } |
| | | |
| | | DaqTemplate query = new DaqTemplate(); |
| | | query.setDeviceType(meterImplement.getMeterType()); |
| | | List<DaqTemplate> daqTemplates = daqTemplateService.selectDaqTemplateList(query); |
| | | if (daqTemplates.isEmpty()) { |
| | | return AjaxResult.error("计éå¨å
·æå±çç±»åæ²¡ææ¾å°å¯¹åºç模æ¿ï¼"); |
| | | @Override |
| | | public List<EnergyIndex> listIndexByMeterIds(String nodeId, List<String> meterId) { |
| | | return energyIndexMapper.listIndexByMeterIds(nodeId, meterId); |
| | | } |
| | | |
| | | List<EnergyIndex> energyIndices = new ArrayList<>(); |
| | | daqTemplates.forEach(daqTemplate -> { |
| | | EnergyIndex energyIndex = new EnergyIndex(); |
| | | energyIndex.setIndexId(UUID.randomUUID().toString()); |
| | | energyIndex.setCode(meterImplement.getCode() + "_" + daqTemplate.getCode()); |
| | | energyIndex.setName(daqTemplate.getName()); |
| | | energyIndex.setUnitId(daqTemplate.getUnit()); |
| | | energyIndex.setIndexType(IndexType.COLLECT); |
| | | energyIndex.setMeterId(meterId); |
| | | energyIndices.add(energyIndex); |
| | | }); |
| | | |
| | | energyIndexMapper.deleteIndexByMeterId(meterId); |
| | | energyIndexMapper.insertEnergyIndices(energyIndices); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getMeterIndex(String meterId) { |
| | | return energyIndexMapper.getMeterIndex(meterId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean modelHasConfig(String modelCode) { |
| | | int count = energyIndexMapper.modelHasConfig(modelCode); |
| | | return count > 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> selectCollectIndex(String deviceId) { |
| | | return energyIndexMapper.selectCollectIndex(deviceId); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getEnergyIndexByIds(List<String> indexIds) { |
| | | return energyIndexMapper.getEnergyIndexByIds(indexIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getEnergyIndexByCodes(List<String> indexCodes) { |
| | | if (indexCodes.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param indexId ææ ä¿¡æ¯ID |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public EnergyIndex selectEnergyIndexById(String indexId) { |
| | | return energyIndexMapper.selectEnergyIndexById(indexId); |
| | | } |
| | | |
| | | return energyIndexMapper.getEnergyIndexByCodes(indexCodes); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getIndexByNodeAndChildrenNode(String nodeId) { |
| | | return energyIndexMapper.getIndexByNodeAndChildrenNode(nodeId); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> searchIndexByNodeAndChildrenNode(String nodeId, String filter) { |
| | | return energyIndexMapper.searchIndexByNodeAndChildrenNode(nodeId, filter); |
| | | } |
| | | |
| | | @Override |
| | | public void removeNodeIndex(String nodeId, List<String> removeLink) { |
| | | energyIndexMapper.removeNodeIndex(nodeId, removeLink); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult importEnergyIndex(List<EnergyIndex> energyIndexList, boolean updateSupport) { |
| | | List<String> codes = energyIndexList.stream().map(EnergyIndex::getCode) |
| | | .collect(Collectors.toList()); |
| | | List<String> nodeCodes = energyIndexList.stream().map(EnergyIndex::getNodeId) |
| | | .collect(Collectors.toList()); |
| | | List<EnergyIndex> indexList = energyIndexMapper.getEnergyIndexByCodes(codes); |
| | | List<ModelNode> modelNodes = modelNodeService.getModelNodeByNodeCodes(nodeCodes); |
| | | Map<String, String> nodeCodeToId = modelNodes.stream() |
| | | .collect(Collectors.toMap(ModelNode::getCode, ModelNode::getNodeId)); |
| | | Set<String> cacheIndexCodes = indexList.stream().map(EnergyIndex::getCode) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | List<EnergyIndex> insertData = new ArrayList<>(); |
| | | List<EnergyIndex> updateData = new ArrayList<>(); |
| | | List<String> errorNodeCode = new ArrayList<>(); |
| | | List<String> insertIndexCode = new ArrayList<>(); |
| | | AtomicBoolean existDuplicateCode = new AtomicBoolean(false); |
| | | energyIndexList.forEach(energyIndex -> { |
| | | if (cacheIndexCodes.contains(energyIndex.getCode())) { |
| | | updateData.add(energyIndex); |
| | | } else { |
| | | String nodeCode = energyIndex.getNodeId(); |
| | | if (nodeCodeToId.containsKey(nodeCode)) { |
| | | if (!insertIndexCode.contains(energyIndex.getCode())) { |
| | | insertIndexCode.add(energyIndex.getCode()); |
| | | energyIndex.setIndexId(UUID.randomUUID().toString()); |
| | | energyIndex.setNodeId(nodeCodeToId.get(nodeCode)); |
| | | insertData.add(energyIndex); |
| | | } else { |
| | | existDuplicateCode.set(true); |
| | | } |
| | | } else if (!errorNodeCode.contains(nodeCode)) { |
| | | errorNodeCode.add(nodeCode); |
| | | @Override |
| | | public List<EnergyIndex> selectEnergyIndexByIds(List<String> indexId) { |
| | | if (CollectionUtils.isEmpty(indexId)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | if (updateSupport && !updateData.isEmpty()) { |
| | | updateData.forEach(energyIndexMapper::updateEnergyIndex); |
| | | return energyIndexMapper.selectEnergyIndexByIds(indexId); |
| | | } |
| | | |
| | | if (!insertData.isEmpty()) { |
| | | energyIndexMapper.saveEnergyIndex(insertData); |
| | | @Override |
| | | public List<EnergyIndex> selectEnergyIndexList(EnergyIndex energyIndex) { |
| | | return energyIndexMapper.selectEnergyIndexList(energyIndex); |
| | | } |
| | | |
| | | String errMsg = ""; |
| | | if (existDuplicateCode.get()) { |
| | | errMsg += "åå¨éå¤çææ ç¼ç ï¼å·²èªå¨è¿æ»¤ï¼"; |
| | | /** |
| | | * æ¥è¯¢ææ ä¿¡æ¯å表 |
| | | * |
| | | * @return ææ ä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public List<EnergyIndex> selectEnergyIndexList(EnergyIndexQuery query) { |
| | | return energyIndexMapper.selectEnergyIndex(query); |
| | | } |
| | | |
| | | if (!errorNodeCode.isEmpty()) { |
| | | errMsg += String.join(",", errorNodeCode) + "æ²¡ææ¾å°å¯¹åºçèç¹æ°æ®ï¼å æ¤å
¶ä¸çææææ 导å
¥å¤±è´¥ï¼"; |
| | | /** |
| | | * æ°å¢ææ ä¿¡æ¯ |
| | | * |
| | | * @param nodeId |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int insertEnergyIndex(String nodeId, EnergyIndex energyIndex) { |
| | | energyIndex.setNodeId(nodeId); |
| | | energyIndexMapper.insertEnergyIndex(energyIndex); |
| | | return energyIndexMapper.insertNodeIndex(nodeId, energyIndex.getIndexId()); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(errMsg)) { |
| | | return AjaxResult.error(errMsg); |
| | | } |
| | | return AjaxResult.success("导å
¥æåï¼"); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getEnergyIndexMeterByCodes(List<String> indexCodes) { |
| | | if (indexCodes.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | /** |
| | | * ä¿®æ¹ææ ä¿¡æ¯ |
| | | * |
| | | * @param energyIndex ææ ä¿¡æ¯ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int updateEnergyIndex(EnergyIndex energyIndex) { |
| | | return energyIndexMapper.updateEnergyIndex(energyIndex); |
| | | } |
| | | |
| | | return energyIndexMapper.getEnergyIndexMeterByCodes(indexCodes); |
| | | } |
| | | /** |
| | | * æ¹éå 餿æ ä¿¡æ¯ |
| | | * |
| | | * @param nodeId |
| | | * @param indexIds éè¦å é¤çææ ä¿¡æ¯ID |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteEnergyIndexByIds(String nodeId, String[] indexIds) { |
| | | return energyIndexMapper.deleteEnergyIndexByIds(nodeId, indexIds); |
| | | } |
| | | |
| | | /** |
| | | * @description: hmj å页æ¥è¯¢ |
| | | * @param query |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.zhitan.model.domain.EnergyIndex> |
| | | * @author: hmj |
| | | * @date: 2024/10/11 23:56 |
| | | */ |
| | | @Override |
| | | public Page<EnergyIndex> selectEnergyIndexPage(EnergyIndexQuery query, Long pageNum, Long pageSize) { |
| | | return energyIndexMapper.selectEnergyIndexPage(new Page<>(pageNum,pageSize),query); |
| | | } |
| | | @Override |
| | | public boolean energyIndexHasExist(String code) { |
| | | int count = energyIndexMapper.energyIndexHasExist(code); |
| | | return count > 0; |
| | | } |
| | | |
| | | @Override |
| | | public Page<EnergyIndex> getMeterIndexList(List<String> meterIndexIds,String code, |
| | | String name,Long pageNum, Long pageSize) { |
| | | LambdaQueryWrapper<EnergyIndex> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(EnergyIndex::getMeterId,meterIndexIds); |
| | | queryWrapper.like(StringUtils.isNotEmpty(code),EnergyIndex::getCode,code); |
| | | queryWrapper.like(StringUtils.isNotEmpty(name),EnergyIndex::getName,name); |
| | | return energyIndexMapper.selectPage(new Page<>(pageNum,pageSize),queryWrapper); |
| | | } |
| | | @Override |
| | | public boolean energyIndexHasExist(String indexId, String code) { |
| | | int count = energyIndexMapper.energyIndexHasExistWhenUpdate(indexId, code); |
| | | return count > 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getIndexByCode(String code, String nodeId) { |
| | | List<EnergyIndex> energyIndexList = energyIndexMapper.getIndexByCode(code,nodeId); |
| | | @Override |
| | | public AjaxResult addMeterIndex(String meterId) { |
| | | MeterImplement meterImplement = meterImplementService.selectMeterImplementById(meterId); |
| | | if (meterImplement == null) { |
| | | return AjaxResult.error("æ¾ä¸å°å¯¹åºç计éå¨å
·ï¼"); |
| | | } |
| | | |
| | | return energyIndexList; |
| | | } |
| | | DaqTemplate query = new DaqTemplate(); |
| | | query.setDeviceType(meterImplement.getMeterType()); |
| | | List<DaqTemplate> daqTemplates = daqTemplateService.selectDaqTemplateList(query); |
| | | if (daqTemplates.isEmpty()) { |
| | | return AjaxResult.error("计éå¨å
·æå±çç±»åæ²¡ææ¾å°å¯¹åºç模æ¿ï¼"); |
| | | } |
| | | |
| | | List<EnergyIndex> energyIndices = new ArrayList<>(); |
| | | daqTemplates.forEach(daqTemplate -> { |
| | | EnergyIndex energyIndex = new EnergyIndex(); |
| | | energyIndex.setIndexId(UUID.randomUUID().toString()); |
| | | energyIndex.setCode(meterImplement.getCode() + "_" + daqTemplate.getCode()); |
| | | energyIndex.setName(daqTemplate.getName()); |
| | | energyIndex.setUnitId(daqTemplate.getUnit()); |
| | | energyIndex.setIndexType(IndexType.COLLECT); |
| | | energyIndex.setMeterId(meterId); |
| | | energyIndices.add(energyIndex); |
| | | }); |
| | | |
| | | energyIndexMapper.deleteIndexByMeterId(meterId); |
| | | energyIndexMapper.insertEnergyIndices(energyIndices); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getMeterIndex(String meterId) { |
| | | return energyIndexMapper.getMeterIndex(meterId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean modelHasConfig(String modelCode) { |
| | | int count = energyIndexMapper.modelHasConfig(modelCode); |
| | | return count > 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> selectCollectIndex(String deviceId) { |
| | | return energyIndexMapper.selectCollectIndex(deviceId); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getEnergyIndexByIds(List<String> indexIds) { |
| | | return energyIndexMapper.getEnergyIndexByIds(indexIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getEnergyIndexByCodes(List<String> indexCodes) { |
| | | if (indexCodes.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | return energyIndexMapper.getEnergyIndexByCodes(indexCodes); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getIndexByNodeAndChildrenNode(String nodeId) { |
| | | return energyIndexMapper.getIndexByNodeAndChildrenNode(nodeId); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> searchIndexByNodeAndChildrenNode(String nodeId, String filter) { |
| | | return energyIndexMapper.searchIndexByNodeAndChildrenNode(nodeId, filter); |
| | | } |
| | | |
| | | @Override |
| | | public void removeNodeIndex(String nodeId, List<String> removeLink) { |
| | | energyIndexMapper.removeNodeIndex(nodeId, removeLink); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult importEnergyIndex(List<EnergyIndex> energyIndexList, boolean updateSupport) { |
| | | List<String> codes = energyIndexList.stream().map(EnergyIndex::getCode) |
| | | .collect(Collectors.toList()); |
| | | List<String> nodeCodes = energyIndexList.stream().map(EnergyIndex::getNodeId) |
| | | .collect(Collectors.toList()); |
| | | List<EnergyIndex> indexList = energyIndexMapper.getEnergyIndexByCodes(codes); |
| | | List<ModelNode> modelNodes = modelNodeService.getModelNodeByNodeCodes(nodeCodes); |
| | | Map<String, String> nodeCodeToId = modelNodes.stream() |
| | | .collect(Collectors.toMap(ModelNode::getCode, ModelNode::getNodeId)); |
| | | Set<String> cacheIndexCodes = indexList.stream().map(EnergyIndex::getCode) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | List<EnergyIndex> insertData = new ArrayList<>(); |
| | | List<EnergyIndex> updateData = new ArrayList<>(); |
| | | List<String> errorNodeCode = new ArrayList<>(); |
| | | List<String> insertIndexCode = new ArrayList<>(); |
| | | AtomicBoolean existDuplicateCode = new AtomicBoolean(false); |
| | | energyIndexList.forEach(energyIndex -> { |
| | | if (cacheIndexCodes.contains(energyIndex.getCode())) { |
| | | updateData.add(energyIndex); |
| | | } else { |
| | | String nodeCode = energyIndex.getNodeId(); |
| | | if (nodeCodeToId.containsKey(nodeCode)) { |
| | | if (!insertIndexCode.contains(energyIndex.getCode())) { |
| | | insertIndexCode.add(energyIndex.getCode()); |
| | | energyIndex.setIndexId(UUID.randomUUID().toString()); |
| | | energyIndex.setNodeId(nodeCodeToId.get(nodeCode)); |
| | | insertData.add(energyIndex); |
| | | } else { |
| | | existDuplicateCode.set(true); |
| | | } |
| | | } else if (!errorNodeCode.contains(nodeCode)) { |
| | | errorNodeCode.add(nodeCode); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | if (updateSupport && !updateData.isEmpty()) { |
| | | updateData.forEach(energyIndexMapper::updateEnergyIndex); |
| | | } |
| | | |
| | | if (!insertData.isEmpty()) { |
| | | energyIndexMapper.saveEnergyIndex(insertData); |
| | | } |
| | | |
| | | String errMsg = ""; |
| | | if (existDuplicateCode.get()) { |
| | | errMsg += "åå¨éå¤çææ ç¼ç ï¼å·²èªå¨è¿æ»¤ï¼"; |
| | | } |
| | | |
| | | if (!errorNodeCode.isEmpty()) { |
| | | errMsg += String.join(",", errorNodeCode) + "æ²¡ææ¾å°å¯¹åºçèç¹æ°æ®ï¼å æ¤å
¶ä¸çææææ 导å
¥å¤±è´¥ï¼"; |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(errMsg)) { |
| | | return AjaxResult.error(errMsg); |
| | | } |
| | | return AjaxResult.success("导å
¥æåï¼"); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getEnergyIndexMeterByCodes(List<String> indexCodes) { |
| | | if (indexCodes.isEmpty()) { |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | return energyIndexMapper.getEnergyIndexMeterByCodes(indexCodes); |
| | | } |
| | | |
| | | /** |
| | | * @param query |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.zhitan.model.domain.EnergyIndex> |
| | | * @description: hmj å页æ¥è¯¢ |
| | | * @author: hmj |
| | | * @date: 2024/10/11 23:56 |
| | | */ |
| | | @Override |
| | | public Page<EnergyIndex> selectEnergyIndexPage(EnergyIndexQuery query, Long pageNum, Long pageSize) { |
| | | return energyIndexMapper.selectEnergyIndexPage(new Page<>(pageNum, pageSize), query); |
| | | } |
| | | |
| | | @Override |
| | | public Page<EnergyIndex> getMeterIndexList(List<String> meterIndexIds, String code, |
| | | String name, Long pageNum, Long pageSize) { |
| | | LambdaQueryWrapper<EnergyIndex> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(EnergyIndex::getMeterId, meterIndexIds); |
| | | queryWrapper.like(StringUtils.isNotEmpty(code), EnergyIndex::getCode, code); |
| | | queryWrapper.like(StringUtils.isNotEmpty(name), EnergyIndex::getName, name); |
| | | return energyIndexMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<EnergyIndex> getIndexByCode(String code, String nodeId) { |
| | | List<EnergyIndex> energyIndexList = energyIndexMapper.getIndexByCode(code, nodeId); |
| | | |
| | | return energyIndexList; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idå设å¤idï¼ä»¥åç¹ä½ç¼ç è·åç¹ä½ |
| | | * |
| | | * @param nodeId èç¹id |
| | | * @param meterId 设å¤id |
| | | * @param indexCode ç¹ä½ç¼ç æè
ç¹ä½ç¼ç çä¸é¨å |
| | | * @return |
| | | */ |
| | | @Override |
| | | public EnergyIndex getDeviceIndexByCode(String nodeId, String meterId, String indexCode) { |
| | | |
| | | List<EnergyIndex> energyIndexList = listDeviceIndexByCode(nodeId, meterId, indexCode); |
| | | EnergyIndex energyIndex = energyIndexList.stream().findFirst().orElse(null); |
| | | if (ObjectUtils.isEmpty(energyIndex)) { |
| | | energyIndex = new EnergyIndex(); |
| | | } |
| | | return energyIndex; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idå设å¤idï¼ä»¥åç¹ä½ç¼ç è·åç¹ä½ |
| | | * |
| | | * @param nodeId èç¹id |
| | | * @param meterId 设å¤id |
| | | * @param indexCode ç¹ä½ç¼ç æè
ç¹ä½ç¼ç çä¸é¨å |
| | | * @return |
| | | */ |
| | | public List<EnergyIndex> listDeviceIndexByCode(String nodeId, String meterId, String indexCode) { |
| | | return energyIndexMapper.selectList(Wrappers.<EnergyIndex>lambdaQuery() |
| | | .eq(EnergyIndex::getNodeId, nodeId) |
| | | .eq(EnergyIndex::getMeterId, meterId) |
| | | .like(EnergyIndex::getCode, indexCode)); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨è½åå
idå设å¤idï¼ä»¥åç¹ä½ç¼ç è·åç¹ä½ |
| | | * |
| | | * @param nodeId èç¹id |
| | | * @param meterId 设å¤id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<EnergyIndex> listDeviceIndex(String nodeId, String meterId) { |
| | | return energyIndexMapper.selectList(Wrappers.<EnergyIndex>lambdaQuery() |
| | | .eq(EnergyIndex::getNodeId, nodeId) |
| | | .eq(EnergyIndex::getMeterId, meterId)); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | import com.zhitan.common.enums.CollectionModes; |
| | | import com.zhitan.common.enums.GroupTimeType; |
| | | import com.zhitan.common.enums.RetrievalModes; |
| | | import com.zhitan.realtimedata.domain.TagValue; |
| | | |
| | |
| | | CollectionModes collectionModes); |
| | | |
| | | /** |
| | | * è·åæµç¹å¨ä¸æ®µæ¶é´å
æç
§æä¸æ¶é´å¨æçç»è®¡æ°æ®. |
| | | * |
| | | * @param tagCodes æµç¹ç¼å·éå |
| | | * @param beginTime å¼å§æ¶é´ |
| | | * @param endTime ç»ææ¶é´,å
æ¬ç»ææ¶é´ |
| | | * @param modes ç»è®¡ç±»å |
| | | * @param timeType åç»æ¶é´å¨æï¼åãæ¶ãå¤©ï¼ |
| | | * @return æµç¹ç»è®¡ç»æ |
| | | */ |
| | | List<TagValue> statistics(String tagCodes, Date beginTime, Date endTime, CollectionModes modes, GroupTimeType timeType); |
| | | |
| | | /** |
| | | * å卿µç¹ç宿¶æ°æ®. |
| | | * |
| | | * @param tagValues æµç¹å®æ¶æ°æ® |
| | |
| | | package com.zhitan.realtimedata.service.impl; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.google.common.collect.Lists; |
| | | import com.zhitan.common.enums.CollectionModes; |
| | | import com.zhitan.common.enums.GroupTimeType; |
| | | import com.zhitan.common.enums.RetrievalModes; |
| | | import com.zhitan.realtimedata.data.RealtimeDatabaseManager; |
| | | import com.zhitan.realtimedata.data.influxdb.InfluxDBRepository; |
| | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 宿¶æ°æ®åºåæ°æå¡å®ç°ç±». |
| | |
| | | return repository.statistics(tagCodes, beginTime, endTime, collectionModes); |
| | | } |
| | | |
| | | @Override |
| | | public List<TagValue> statistics(String tagCodes, Date beginTime, Date endTime, CollectionModes modes, GroupTimeType timeType) { |
| | | try { |
| | | List<String> tagCodeList = Arrays.asList(tagCodes.split(StrUtil.COMMA).clone()); |
| | | List<TagValue> tagValues = repository.statistics(tagCodeList, beginTime, endTime, modes, timeType); |
| | | if (ObjectUtil.isEmpty(tagValues)) { |
| | | tagValues = new ArrayList<>(); |
| | | } |
| | | return tagValues; |
| | | } catch (Exception e) { |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å卿µç¹ç宿¶æ°æ®. |
| | | * |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.zhitan.common.enums.TimeType; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * è½æµå¾æ¥è¯¢ |
| | | */ |
| | | @Data |
| | | public class FlowChartsDTO { |
| | | |
| | | /** |
| | | * è½æºç±»ååç§° |
| | | */ |
| | | @EnumValue |
| | | @ApiModelProperty(value = "æ¶é´ç±»å") |
| | | private TimeType timeType; |
| | | |
| | | /** |
| | | * æ¥è¯¢æ¶é´ |
| | | */ |
| | | @NotNull(message = "æ¥è¯¢æ¶é´ä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @ApiModelProperty(value = "æ¥è¯¢æ¶é´") |
| | | private LocalDate queryTime; |
| | | |
| | | /** |
| | | * è½æºç±»å |
| | | */ |
| | | @NotBlank(message = "è½æºç±»åä¸è½ä¸ºç©º") |
| | | @ApiModelProperty(value = "è½æºç±»å") |
| | | private String energyType; |
| | | |
| | | /** |
| | | * èç¹id |
| | | */ |
| | | @NotBlank(message = "èç¹idä¸è½ä¸ºç©º") |
| | | @ApiModelProperty(value = "èç¹id") |
| | | private String nodeId; |
| | | |
| | | public TimeType getTimeType() { |
| | | if (ObjectUtils.isEmpty(timeType)) { |
| | | return TimeType.DAY; |
| | | } |
| | | return timeType; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * è½æµå¾æ¥è¯¢ |
| | | */ |
| | | @Data |
| | | public class FlowChartsItemVO { |
| | | |
| | | /** |
| | | * æºå¤´ |
| | | */ |
| | | @ApiModelProperty(value = "æºå¤´") |
| | | private String source; |
| | | |
| | | /** |
| | | * ç®æ |
| | | */ |
| | | @ApiModelProperty(value = "ç®æ ") |
| | | private String target; |
| | | |
| | | /** |
| | | * å¼ |
| | | */ |
| | | @NotBlank(message = "å¼") |
| | | @ApiModelProperty(value = "å¼") |
| | | private BigDecimal value; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.zhitan.statisticalAnalysis.domain.vo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * è½æµå¾æ¥è¯¢ |
| | | */ |
| | | @Data |
| | | public class FlowChartsVO { |
| | | |
| | | // æ»ç´¯ç§¯é |
| | | @ApiModelProperty(value = "æ»ç´¯ç§¯é") |
| | | private BigDecimal totalAccumulatedAmount; |
| | | |
| | | // åèç¹ç´¯ç§¯é |
| | | @ApiModelProperty(value = "åèç¹ç´¯ç§¯é") |
| | | private BigDecimal childNodeAccumulatedAmount; |
| | | |
| | | // å·®å¼ |
| | | @ApiModelProperty(value = "å·®å¼") |
| | | private BigDecimal difference; |
| | | |
| | | // è½èæå¤±æ¯ä¾ |
| | | @ApiModelProperty(value = "è½èæå¤±æ¯ä¾") |
| | | private BigDecimal energyLossRatio; |
| | | |
| | | private List<FlowChartsItemVO> itemVOList; |
| | | |
| | | public BigDecimal getTotalAccumulatedAmount() { |
| | | if (totalAccumulatedAmount == null){ |
| | | return BigDecimal.ZERO; |
| | | } |
| | | return totalAccumulatedAmount; |
| | | } |
| | | |
| | | public BigDecimal getChildNodeAccumulatedAmount() { |
| | | if (childNodeAccumulatedAmount == null){ |
| | | return BigDecimal.ZERO; |
| | | } |
| | | return childNodeAccumulatedAmount; |
| | | } |
| | | |
| | | public BigDecimal getDifference() { |
| | | return difference = totalAccumulatedAmount.subtract(childNodeAccumulatedAmount); |
| | | } |
| | | |
| | | public BigDecimal getEnergyLossRatio() { |
| | | if (BigDecimal.ZERO.compareTo(totalAccumulatedAmount) == 0 |
| | | || BigDecimal.ZERO.compareTo(difference) == 0){ |
| | | return BigDecimal.ZERO; |
| | | } |
| | | return energyLossRatio = difference.divide(totalAccumulatedAmount, 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | public FlowChartsVO() { |
| | | this.totalAccumulatedAmount = BigDecimal.ZERO; |
| | | this.childNodeAccumulatedAmount = BigDecimal.ZERO; |
| | | this.difference = BigDecimal.ZERO; |
| | | this.energyLossRatio = BigDecimal.ZERO; |
| | | this.itemVOList = Collections.emptyList(); |
| | | } |
| | | } |
| | |
| | | <result column="value0" property="value0"/> |
| | | </resultMap> |
| | | <!--å
¨åè½èç»è®¡--> |
| | | <select id="getdailyComprehensiveList" resultMap="dataItemMap"> |
| | | <select id="getDailyComprehensiveList" resultType="com.zhitan.comprehensivestatistics.domain.DailyComprehensive"> |
| | | SELECT |
| | | aa.index_id, |
| | | aa.index_name, |
| | |
| | | ORDER BY aa.order_num ASC |
| | | </select> |
| | | |
| | | <select id="getListChart" resultMap="dataItemMap"> |
| | | <select id="getListChart" resultType="com.zhitan.comprehensivestatistics.domain.DailyComprehensive"> |
| | | SELECT |
| | | di.index_id, |
| | | ci.name AS "index_name", |
| | |
| | | resultType="com.zhitan.model.domain.EnergyIndex"> |
| | | select ei.index_id as indexId, code, name, index_type as indexType |
| | | from energy_index ei |
| | | left join node_index ni on ei.index_id = ni.index_id |
| | | left join node_index ni on ei.index_id = ni.index_id |
| | | where ni.node_id = #{nodeId} |
| | | and ei.index_type = #{indexType} |
| | | and ei.index_type = #{indexType} |
| | | <if test="code != null and code != ''"> |
| | | and code like concat('%', #{code}, '%') |
| | | </if> |
| | |
| | | node_category nodeCategory |
| | | FROM "model_node" |
| | | WHERE model_code = #{indexCode} |
| | | AND parent_id IS NULL LIMIT 1; |
| | | AND parent_id IS NULL |
| | | LIMIT 1; |
| | | </select> |
| | | <select id="selectIndexByModelCodeAndNodeId" |
| | | resultType="com.zhitan.model.domain.vo.ModelNodeIndexInfor"> |
| | | SELECT mn.node_id nodeId, |
| | | SELECT mn.node_id nodeId, |
| | | mn."name", |
| | | ni.index_id indexId |
| | | FROM model_node mn |
| | |
| | | |
| | | <select id="getSettingDeviceIndex" resultType="com.zhitan.basicdata.domain.MeterImplement"> |
| | | SELECT distinct |
| | | m."id", |
| | | m.code, |
| | | m.meter_name AS meterName, |
| | | m.meter_type meterType, |
| | | m.wire_diameter wireDiameter, |
| | | m.max_allowable_power maxAllowablePower |
| | | m."id", |
| | | m.code, |
| | | m.meter_name AS meterName, |
| | | m.meter_type meterType, |
| | | m.wire_diameter wireDiameter, |
| | | m.max_allowable_power maxAllowablePower |
| | | FROM meter_implement m |
| | | LEFT JOIN energy_index ei ON ei.meter_id = m."id" |
| | | LEFT JOIN node_index ni ON ni.index_id = ei.index_id |
| | | LEFT JOIN energy_index ei ON ei.meter_id = m."id" |
| | | LEFT JOIN node_index ni ON ni.index_id = ei.index_id |
| | | WHERE ni.node_id = #{nodeId} |
| | | <if test="energyType!=null and energyType!=''"> |
| | | AND M.energy_type = #{energyType} |
| | |
| | | <delete id="delIndexNodeIdAndIndexType"> |
| | | delete |
| | | from node_index |
| | | where node_id = #{nodeId} and index_id in ( |
| | | select ni.index_id |
| | | from node_index ni left join energy_index ei on ni.index_id = ei.index_id |
| | | where node_id = #{nodeId} and ei.index_type = #{indexType} |
| | | ); |
| | | where node_id = #{nodeId} |
| | | and index_id in (select ni.index_id |
| | | from node_index ni |
| | | left join energy_index ei on ni.index_id = ei.index_id |
| | | where node_id = #{nodeId} |
| | | and ei.index_type = #{indexType}); |
| | | </delete> |
| | | <insert id="setIndexAndNodeId"> |
| | | <foreach collection="indexIds" item="indexId" separator=";"> |
| | |
| | | </insert> |
| | | |
| | | <select id="getModelNodeIndexIdByNodeId" resultType="com.zhitan.model.domain.vo.ModelNodeIndexInfor"> |
| | | SELECT mn.node_id nodeId, |
| | | mn."name" "name", |
| | | ni.index_id indexId, |
| | | ei.energy_id energyId, |
| | | ei.index_type indexType |
| | | SELECT mn.node_id nodeId, |
| | | mn."name" "name", |
| | | ni.index_id indexId, |
| | | ei.energy_id energyId, |
| | | ei.index_type indexType |
| | | FROM "model_node" mn |
| | | LEFT JOIN "node_index" ni ON mn.node_id = ni.node_id |
| | | LEFT JOIN energy_index ei on ni.index_id = ei.index_id |
| | |
| | | FROM "model_node" mn |
| | | LEFT JOIN "node_index" ni ON mn.node_id = ni.node_id |
| | | left join energy_index ei on ni.index_id = ei.index_id |
| | | WHERE mn.parent_id = #{parentId} and ei.index_type = 'STATISTIC' |
| | | WHERE mn.parent_id = #{parentId} |
| | | and ei.index_type = 'STATISTIC' |
| | | </select> |
| | | <select id="getFirstModeNodeInfo" resultType="com.zhitan.model.domain.ModelNode"> |
| | | <include refid="selectModelNodeVo"/> |
| | | where model_code = #{modelCode} AND parent_id is null |
| | | where model_code = #{modelCode} AND parent_id is null |
| | | order by order_num |
| | | </select> |
| | | <select id="selectIndexByNodeIds" resultType="com.zhitan.model.domain.vo.ModelNodeIndexInfor"> |
| | | SELECT mn.node_id nodeId, |
| | | mn."name" "name", |
| | | SELECT mn.node_id nodeId, |
| | | mn."name" "name", |
| | | ni.index_id indexId, |
| | | ei.energy_id |
| | | FROM "model_node" mn |
| | |
| | | left join energy_index ei on ni.index_id = ei.index_id |
| | | <where> |
| | | mn.model_code = #{modelCode} |
| | | AND mn.node_id in |
| | | <foreach collection="nodeIds" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | <if test="modelCode!=null and modelCode!='' and nodeIds.size>0"> |
| | | and ei.index_type='STATISTIC' |
| | | </if> |
| | | AND mn.node_id in |
| | | <foreach collection="nodeIds" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | <if test="modelCode!=null and modelCode!='' and nodeIds.size>0"> |
| | | and ei.index_type='STATISTIC' |
| | | </if> |
| | | |
| | | </where> |
| | | |
| | | </select> |
| | | |
| | | <select id="getDataItemByParentNodeId" resultType="com.zhitan.dataitem.domain.vo.NodeIndexValueVO"> |
| | | SELECT mn.node_id nodeId, |
| | | mn."name" nodeName, |
| | | di.index_id indexId, |
| | | di."value" value |
| | | FROM model_node mn |
| | | LEFT JOIN "node_index" ni ON mn.node_id = ni.node_id |
| | | LEFT JOIN "energy_index" ei ON ei.index_id = ni.index_id |
| | | LEFT JOIN "data_item" di ON ei.index_id = di.index_id |
| | | WHERE mn.parent_id = #{parentId} |
| | | AND ei.energy_id = #{energyType} |
| | | AND ei.index_type = 'STATISTIC' |
| | | AND di.time_type = #{timeType.name} |
| | | AND di.data_time >= #{dateTimeMap.startTime} |
| | | AND di.data_time <= #{dateTimeMap.endTime} |
| | | </select> |
| | | |
| | | <select id="getDataItemByNodeId" resultType="com.zhitan.dataitem.domain.vo.NodeIndexValueVO"> |
| | | SELECT mn.node_id nodeId, |
| | | mn."name" nodeName, |
| | | di.index_id indexId, |
| | | di."value" value |
| | | FROM "model_node" mn |
| | | LEFT JOIN "node_index" ni ON mn.node_id = ni.node_id |
| | | LEFT JOIN "energy_index" ei ON ei.index_id = ni.index_id |
| | | LEFT JOIN "data_item" di ON ei.index_id = di.index_id |
| | | WHERE mn.node_id = #{nodeId} |
| | | AND ei.energy_id = #{energyType} |
| | | AND ei.index_type = 'STATISTIC' |
| | | AND di.time_type = #{timeType.name} |
| | | AND di.data_time >= #{dateTimeMap.startTime} |
| | | AND di.data_time <= #{dateTimeMap.endTime} |
| | | </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.model.mapper.NodeIndexMapper"> |
| | | |
| | | <resultMap type="com.zhitan.model.domain.NodeIndex" id="NodeIndexMap"> |
| | | <result property="nodeId" column="node_id" jdbcType="VARCHAR"/> |
| | | <result property="indexId" column="index_id" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | </mapper> |
| | | |