| | |
| | | @Operation(summary = "查询最大值") |
| | | Map<String, Object> queryPointMaxValue(@RequestBody ApiPointValueQueryDTO queryDto); |
| | | |
| | | @PostMapping(PREFIX + "/query-point/max-value-range") |
| | | @Operation(summary = "查询最大值") |
| | | Map<String, Object> queryPointMaxValueRange(@RequestBody ApiPointValueQueryDTO queryDto); |
| | | |
| | | @PostMapping(PREFIX + "/query-point/min-value-range") |
| | | @Operation(summary = "查询最小值") |
| | | Map<String, Object> queryPointMinValueRange(@RequestBody ApiPointValueQueryDTO queryDto); |
| | | |
| | | @PutMapping(PREFIX + "/write-point/real-value") |
| | | @Operation(summary = "写入单个测点值") |
| | | Boolean writePointRealValue(@RequestBody ApiPointValueWriteDTO queryDto); |
| | |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='定时归档设置表'; |
| | | |
| | | ALTER TABLE `t_da_cumulate_point` ADD COLUMN `cumulate_unit` varchar(10) DEFAULT 'min' COMMENT '累计单位'; |
| | | ALTER TABLE `t_da_cumulate_point` ADD COLUMN `is_cumu_neg` tinyint(1) DEFAULT 0 COMMENT '是否累计负数'; |
| | | ALTER TABLE `t_da_cumulate_point` ADD COLUMN `is_cumu_neg` tinyint(1) DEFAULT 0 COMMENT '是否累计负数'; |
| | | |
| | | |
| | | CREATE TABLE t_da_extremal_point( |
| | | `id` VARCHAR(36) NOT NULL COMMENT 'ID' , |
| | | `point_id` VARCHAR(36) COMMENT '测点ID' , |
| | | `moment_point` VARCHAR(36) COMMENT '瞬时测点' , |
| | | `length` int COMMENT '统计长度', |
| | | `extremal_unit` varchar(10) DEFAULT 'min' COMMENT '统计单位', |
| | | `extremal_type` int NOT NULL COMMENT '极值类型(1:最大值,2:最小值)', |
| | | PRIMARY KEY (id) USING BTREE, |
| | | UNIQUE KEY `uk_point_id` (`point_id`) USING BTREE |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT = '实时极值点表'; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> queryPointMaxValueRange(ApiPointValueQueryDTO queryDto) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | if (StringUtils.isEmpty(queryDto.getPointNo())) { |
| | | return null; |
| | | } |
| | | if (queryDto.getStart() == null) { |
| | | return null; |
| | | } |
| | | if (queryDto.getEnd() == null) { |
| | | queryDto.setEnd(new Date()); |
| | | } |
| | | DaPointDTO daPointDTO = daPointService.getByNo(queryDto.getPointNo()); |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(queryDto.getPointNo()); |
| | | pojo.setType(daPointDTO.getDataType()); |
| | | Object val = influxDBService.queryPointMaxValueRange(pojo, queryDto.getStart(), queryDto.getEnd()); |
| | | result.put(queryDto.getPointNo(), val); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> queryPointMinValueRange(ApiPointValueQueryDTO queryDto) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | if (StringUtils.isEmpty(queryDto.getPointNo())) { |
| | | return null; |
| | | } |
| | | if (queryDto.getStart() == null) { |
| | | return null; |
| | | } |
| | | if (queryDto.getEnd() == null) { |
| | | queryDto.setEnd(new Date()); |
| | | } |
| | | DaPointDTO daPointDTO = daPointService.getByNo(queryDto.getPointNo()); |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(queryDto.getPointNo()); |
| | | pojo.setType(daPointDTO.getDataType()); |
| | | Object val = influxDBService.queryPointMinValueRange(pojo, queryDto.getStart(), queryDto.getEnd()); |
| | | result.put(queryDto.getPointNo(), val); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, List<Map<String, Object>>> queryPointsHistoryValue(ApiPointsValueQueryDTO queryDto) { |
| | | Map<String, List<Map<String, Object>>> data = new HashMap<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | |
| | | * @date 2021年05月24日 9:41 |
| | | */ |
| | | public enum IncreaseCodeEnum { |
| | | POINT_M, POINT_C, POINT_F, POINT_L, IND_A, IND_D, IND_C, PLAN; |
| | | POINT_M, POINT_C, POINT_F, POINT_L, POINT_E, IND_A, IND_D, IND_C, PLAN; |
| | | } |
| | |
| | | Object queryPointMaxValue(InfluxPointValuePOJO point, Date startTime); |
| | | |
| | | List<PointValueExportVO> exportPointValue(ApiPointValueQueryDTO queryDto); |
| | | |
| | | Object queryPointMaxValueRange(InfluxPointValuePOJO point, Date startTime, Date endTime); |
| | | |
| | | Object queryPointMinValueRange(InfluxPointValuePOJO point, Date startTime, Date endTime); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Object queryPointMaxValueRange(InfluxPointValuePOJO point, Date startTime, Date endTime) { |
| | | if (influxQLQueryApi == null) { |
| | | influxQLQueryApi = influxDBInstance.getClient().getInfluxQLQueryApi(); |
| | | } |
| | | long utcMillisS = startTime.getTime() - rawOffset; |
| | | String utsStart = DateUtils.format(new Date(utcMillisS), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | log.info("utsStart=" + utsStart); |
| | | long utcMillisE = endTime.getTime() - rawOffset; |
| | | String utsEnd = DateUtils.format(new Date(utcMillisE), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | log.info("utsEnd=" + utsEnd); |
| | | |
| | | String measurement = PointValueUtils.getMeasurement(point.getType()); |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append("SELECT MAX(value) FROM "); |
| | | sql.append(measurement); |
| | | sql.append(" WHERE point = '"); |
| | | sql.append(point.getPoint()); |
| | | sql.append("' AND time >= '" + utsStart + "'"); |
| | | sql.append("' AND time <= '" + utsEnd + "'"); |
| | | InfluxQLQueryResult data = influxQLQueryApi.query(new InfluxQLQuery(sql.toString(), influxDBInstance.getBucket())); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | return data.getResults().get(0).getSeries().get(0).getValues().get(0).getValues()[1]; |
| | | } |
| | | |
| | | @Override |
| | | public Object queryPointMinValueRange(InfluxPointValuePOJO point, Date startTime, Date endTime) { |
| | | if (influxQLQueryApi == null) { |
| | | influxQLQueryApi = influxDBInstance.getClient().getInfluxQLQueryApi(); |
| | | } |
| | | long utcMillisS = startTime.getTime() - rawOffset; |
| | | String utsStart = DateUtils.format(new Date(utcMillisS), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | log.info("utsStart=" + utsStart); |
| | | long utcMillisE = endTime.getTime() - rawOffset; |
| | | String utsEnd = DateUtils.format(new Date(utcMillisE), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | log.info("utsEnd=" + utsEnd); |
| | | |
| | | String measurement = PointValueUtils.getMeasurement(point.getType()); |
| | | StringBuilder sql = new StringBuilder(); |
| | | sql.append("SELECT MIN(value) FROM "); |
| | | sql.append(measurement); |
| | | sql.append(" WHERE point = '"); |
| | | sql.append(point.getPoint()); |
| | | sql.append("' AND time >= '" + utsStart + "'"); |
| | | sql.append("' AND time <= '" + utsEnd + "'"); |
| | | InfluxQLQueryResult data = influxQLQueryApi.query(new InfluxQLQuery(sql.toString(), influxDBInstance.getBucket())); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | return data.getResults().get(0).getSeries().get(0).getValues().get(0).getValues()[1]; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryPointValues(InfluxPointValuePOJO pojo, Date startTime, Date endTime) { |
| | | List<InfluxPointValuePOJO> influxParams = new ArrayList<>(); |
| | | influxParams.add(pojo); |
| | |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValueBoolPOJO; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValueDigPOJO; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO; |
| | | import com.iailab.module.data.point.collection.handler.CalculateHandle; |
| | | import com.iailab.module.data.point.collection.handler.CumulateHandle; |
| | | import com.iailab.module.data.point.collection.handler.*; |
| | | import com.iailab.module.data.point.common.PointTypeEnum; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointCollectStatusService; |
| | |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import com.iailab.module.data.channel.modbus.collector.ModBusCollector; |
| | | import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; |
| | | import com.iailab.module.data.point.collection.handler.ConstantHandle; |
| | | import com.iailab.module.data.point.collection.handler.MeasureHandle; |
| | | import com.iailab.module.data.point.dto.DaPointWriteValueDTO; |
| | | import com.iailab.module.data.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Resource |
| | | private CumulateHandle cumulateHandle; |
| | | |
| | | @Resource |
| | | private ExtremalHandle extremalHandle; |
| | | |
| | | @Autowired |
| | | private DaPointCollectStatusService daPointCollectStatusService; |
| | | |
| | |
| | | List<DaPointDTO> pointCumulateList = daPointService.getCumulatePoint(minfreq); |
| | | pointValues.addAll(cumulateHandle.handle(collectTime, pointCumulateList, listGood, listBad)); |
| | | |
| | | log.info("读取极值点"); |
| | | List<DaPointDTO> pointExtremalList = daPointService.getExtremalPoint(minfreq); |
| | | pointValues.addAll(extremalHandle.handle(collectTime, pointExtremalList, listGood, listBad)); |
| | | |
| | | log.info("存入时序库"); |
| | | log.info("pointValueTimestamp=" + (pointValues.get(0) == null ? 0 : pointValues.get(0).getTimestamp().getNano())); |
| | | influxDBService.asyncWritePointValues(pointValues); |
| | |
| | | data.putAll(measureHandle.getCurrent(pointNos)); |
| | | data.putAll(calculateHandle.getCurrent(pointNos)); |
| | | data.putAll(cumulateHandle.getCurrent(pointNos)); |
| | | data.putAll(extremalHandle.getCurrent(pointNos)); |
| | | return data; |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.collection.handler; |
| | | |
| | | import com.iailab.module.data.api.point.DataPointApi; |
| | | import com.iailab.module.data.api.point.dto.ApiPointDTO; |
| | | import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.enums.DataPointFreqEnum; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | | import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; |
| | | import com.iailab.module.data.point.common.ExtremaUnitEnum; |
| | | import com.iailab.module.data.point.common.ExtremalTypeEnum; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 极值点处理类 |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class ExtremalHandle { |
| | | |
| | | @Resource |
| | | private DaPointService daPointService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, List<String> listGood, List<String> listBad) { |
| | | List<InfluxPointValuePOJO> result = new ArrayList<>(); |
| | | try { |
| | | log.info("极值点处理开始"); |
| | | if (CollectionUtils.isEmpty(dtos)) { |
| | | return result; |
| | | } |
| | | dtos.forEach(dto -> { |
| | | try { |
| | | Object value = singleCompute(dto, collectTime, listGood, listBad); |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value); |
| | | pojo.setTimestamp(GenInfluxPointValueUtils.getByMin(collectTime, DataPointFreqEnum.getEumByCode(dto.getMinfreqid()))); |
| | | result.add(pojo); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | log.info("极值点异常!PointNo=" + dto.getPointNo()); |
| | | } |
| | | }); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | log.info("极值点处理异常!"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, Object> getCurrent(List<String> pointNos) { |
| | | Map<String, Object> data = new HashMap<>(); |
| | | List<DaPointDTO> pointExtremalList = daPointService.getExtremalPoint(pointNos); |
| | | if (CollectionUtils.isEmpty(pointExtremalList)) { |
| | | return data; |
| | | } |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | pointExtremalList.forEach(item -> { |
| | | Object value = CommonConstant.BAD_VALUE; |
| | | if (redisTemplate.hasKey(PointCollector.PV + item.getPointNo())) { |
| | | value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo()); |
| | | } else { |
| | | value = singleCompute(item, calendar.getTime(), new ArrayList<>(), new ArrayList<>()); |
| | | } |
| | | data.put(item.getPointNo(), value); |
| | | }); |
| | | return data; |
| | | } |
| | | |
| | | private Object singleCompute(DaPointDTO dto, Date collectTime, List<String> listGood, List<String> listBad) { |
| | | Object value = CommonConstant.BAD_VALUE; |
| | | ApiPointDTO pointDTO = dataPointApi.getInfoByNo(dto.getMomentPoint()); |
| | | if (pointDTO == null) { |
| | | if (listBad != null) { |
| | | listBad.add(dto.getPointNo()); |
| | | } |
| | | return CommonConstant.BAD_VALUE; |
| | | } |
| | | log.info("极值:" + dto.getPointNo()); |
| | | |
| | | // 动态长度 |
| | | ApiPointDTO momentPoint = dataPointApi.getInfoByNo(dto.getMomentPoint()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(collectTime); |
| | | calendar.add(Calendar.SECOND, -1 * DataPointFreqEnum.getEumByCode(momentPoint.getMinfreqid()).getValue()); |
| | | Date endTime = calendar.getTime(); |
| | | Date startTime = ExtremaUnitEnum.getStartTime(calendar, dto.getLength(), dto.getCumulateUnit()); |
| | | ApiPointValueQueryDTO queryDto = new ApiPointValueQueryDTO(); |
| | | queryDto.setPointNo(momentPoint.getPointNo()); |
| | | queryDto.setStart(startTime); |
| | | queryDto.setEnd(endTime); |
| | | Map<String, Object> eValue = new HashMap<>(); |
| | | switch (ExtremalTypeEnum.getEumByCode(dto.getExtremalType())) { |
| | | case MAX: |
| | | eValue = dataPointApi.queryPointMaxValueRange(queryDto); |
| | | break; |
| | | case MIN: |
| | | eValue = dataPointApi.queryPointMinValueRange(queryDto); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (eValue != null) { |
| | | value = eValue.get(momentPoint.getPointNo()); |
| | | listGood.add(dto.getPointNo()); |
| | | } |
| | | return value; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.common; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.function.BiFunction; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum ExtremaUnitEnum { |
| | | MIN("min", (end, length) -> { |
| | | Calendar cal = (Calendar) end.clone(); |
| | | cal.add(Calendar.MINUTE, -length); |
| | | return cal; |
| | | }), |
| | | HOUR("hour", (end, length) -> { |
| | | Calendar cal = (Calendar) end.clone(); |
| | | cal.add(Calendar.HOUR_OF_DAY, -length); |
| | | return cal; |
| | | }), |
| | | DAY("day", (end, length) -> { |
| | | Calendar cal = (Calendar) end.clone(); |
| | | cal.add(Calendar.DAY_OF_MONTH, -length); |
| | | return cal; |
| | | }), |
| | | THIS_MONTH("this_month", (end, length) -> { |
| | | Calendar cal = (Calendar) end.clone(); |
| | | cal.set(Calendar.DAY_OF_MONTH, 1); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | return cal; |
| | | }); |
| | | |
| | | private final String code; |
| | | private final BiFunction<Calendar, Integer, Calendar> calculator; |
| | | |
| | | public Calendar calculate(Calendar endTime, Integer length) { |
| | | return calculator.apply(endTime, length); |
| | | } |
| | | |
| | | public static ExtremaUnitEnum fromCode(String code) { |
| | | for (ExtremaUnitEnum unit : values()) { |
| | | if (unit.code.equals(code)) { |
| | | return unit; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Date getStartTime(Calendar endTime, Integer length, String cumulateUnit) { |
| | | |
| | | ExtremaUnitEnum unit = ExtremaUnitEnum.fromCode(cumulateUnit); |
| | | |
| | | if (unit == null) { |
| | | return endTime.getTime(); |
| | | } else if (unit != THIS_MONTH) { |
| | | if (length == null || length <= 0) { |
| | | return endTime.getTime(); |
| | | } |
| | | } |
| | | |
| | | Calendar startCal = unit.calculate(endTime, length); |
| | | return startCal.getTime(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.common; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum ExtremalTypeEnum { |
| | | MAX(1, "最大值"), |
| | | MIN(2, "最小值"); |
| | | |
| | | private Integer code; |
| | | private String desc; |
| | | |
| | | public static ExtremalTypeEnum getEumByCode(Integer code) { |
| | | if (code == null) { |
| | | return null; |
| | | } |
| | | |
| | | for (ExtremalTypeEnum statusEnum : ExtremalTypeEnum.values()) { |
| | | if (statusEnum.getCode().equals(code)) { |
| | | return statusEnum; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | MEASURE_POINT("MEASURE", "测量点"), |
| | | CALCULATE_POINT("CALCULATE", "计算点"), |
| | | CONSTANT("CONSTANT", "常量点"), |
| | | CUMULATE("CUMULATE", "累计点"); |
| | | CUMULATE("CUMULATE", "累计点"), |
| | | EXTREMAL("EXTREMAL", "极值点"); |
| | | |
| | | private String code; |
| | | |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.data.point.entity.DaExtremalPointEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | @TenantDS |
| | | @Mapper |
| | | public interface DaExtremalPointDao extends BaseDao<DaExtremalPointEntity> { |
| | | } |
| | |
| | | |
| | | List<DaPointDTO> getCumulatePoint(Map<String, Object> params); |
| | | |
| | | List<DaPointDTO> getExtremalPoint(Map<String, Object> params); |
| | | |
| | | default IPage<DaPointDTO> selectPageList(DaPointPageReqVO reqVO) { |
| | | return getPageList(getPage(reqVO), reqVO); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.dto; |
| | | |
| | | import com.iailab.framework.common.validation.group.AddGroup; |
| | | import com.iailab.framework.common.validation.group.UpdateGroup; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import javax.validation.constraints.Null; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | @Data |
| | | @Tag(name = "极值点表") |
| | | public class DaExtremalPointDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "id") |
| | | @Null(message="{id.null}", groups = AddGroup.class) |
| | | @NotNull(message="{id.require}", groups = UpdateGroup.class) |
| | | private String id; |
| | | |
| | | @Schema(description = "测点ID", required = true) |
| | | private String pointId; |
| | | |
| | | @Schema(description = "瞬时测点", required = true) |
| | | private String momentPoint; |
| | | |
| | | @Schema(description = "累计长度", required = true) |
| | | private Integer length; |
| | | |
| | | @Schema(description = "极值单位", required = true) |
| | | private String extremalUnit; |
| | | |
| | | @Schema(description = "极值类型", required = true) |
| | | private Integer extremalType; |
| | | } |
| | |
| | | @Schema(description = "是否累计负数") |
| | | private Integer isCumuNeg; |
| | | |
| | | @Schema(description = "极值单位") |
| | | private String extremalUnit; |
| | | |
| | | @Schema(description = "极值类型") |
| | | private Integer extremalType; |
| | | |
| | | @Schema(description = "数据源选项") |
| | | private List<String> sourceOption; |
| | | |
| | |
| | | @Schema(description = "累计点") |
| | | private DaCumulatePointDTO cumulatePoint; |
| | | |
| | | @Schema(description = "极值点") |
| | | private DaExtremalPointDTO extremalPoint; |
| | | |
| | | @Schema(description = "采集值") |
| | | private String collectValue; |
| | | |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | @Data |
| | | @TableName("t_da_cumulate_point") |
| | | public class DaExtremalPointEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId(type = IdType.ASSIGN_UUID) |
| | | private String id; |
| | | |
| | | /** |
| | | * 测点ID |
| | | */ |
| | | private String pointId; |
| | | |
| | | /** |
| | | * 累计测点 |
| | | */ |
| | | private String momentPoint; |
| | | |
| | | /** |
| | | * 累计长度 |
| | | */ |
| | | private Integer length; |
| | | |
| | | /** |
| | | * 极值单位 |
| | | */ |
| | | private String extremalUnit; |
| | | |
| | | /** |
| | | * 极值类型(1:最大值,2:最小值) |
| | | */ |
| | | private Integer extremalType; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.service; |
| | | |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.point.dto.DaExtremalPointDTO; |
| | | import com.iailab.module.data.point.entity.DaExtremalPointEntity; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | public interface DaExtremalPointService extends BaseService<DaExtremalPointEntity> { |
| | | |
| | | void add(DaExtremalPointDTO dto, String pointId); |
| | | |
| | | DaExtremalPointDTO getByPoint(String pointId); |
| | | |
| | | void update(DaExtremalPointDTO dto); |
| | | |
| | | void deleteBatch(String[] ids); |
| | | |
| | | void deleteByPoint(String[] ids); |
| | | } |
| | |
| | | |
| | | List<DaPointDTO> getCumulatePoint(DaPointPageReqVO reqVO); |
| | | |
| | | List<DaPointDTO> getExtremalPoint(String freq); |
| | | |
| | | List<DaPointDTO> getExtremalPoint(List<String> pointNos); |
| | | |
| | | DaPointDTO getByNo(String pointNo); |
| | | |
| | | List<DaPointDTO> getByNos(List<String> pointNos); |
对比新文件 |
| | |
| | | package com.iailab.module.data.point.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.point.dao.DaExtremalPointDao; |
| | | import com.iailab.module.data.point.dto.DaExtremalPointDTO; |
| | | import com.iailab.module.data.point.entity.DaExtremalPointEntity; |
| | | import com.iailab.module.data.point.service.DaExtremalPointService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2025年05月14日 |
| | | */ |
| | | @Service |
| | | public class DaExtremalPointServiceImpl extends BaseServiceImpl<DaExtremalPointDao, DaExtremalPointEntity> implements DaExtremalPointService { |
| | | |
| | | @Override |
| | | public void add(DaExtremalPointDTO dto, String pointId) { |
| | | DaExtremalPointEntity entity = ConvertUtils.sourceToTarget(dto, DaExtremalPointEntity.class); |
| | | entity.setPointId(pointId); |
| | | baseDao.insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public DaExtremalPointDTO getByPoint(String pointId) { |
| | | QueryWrapper<DaExtremalPointEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("point_id", pointId); |
| | | DaExtremalPointEntity entity = baseDao.selectOne(wrapper); |
| | | return ConvertUtils.sourceToTarget(entity, DaExtremalPointDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public void update(DaExtremalPointDTO dto) { |
| | | DaExtremalPointEntity entity = ConvertUtils.sourceToTarget(dto, DaExtremalPointEntity.class); |
| | | this.updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteBatch(String[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByPoint(String[] ids) { |
| | | QueryWrapper<DaExtremalPointEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.in("point_id", Arrays.asList(ids)); |
| | | baseDao.delete(wrapper); |
| | | } |
| | | } |
| | |
| | | |
| | | @Autowired |
| | | private DaSequenceNumService daSequenceNumService; |
| | | |
| | | @Autowired |
| | | private DaExtremalPointService daExtremalPointService; |
| | | |
| | | @Resource |
| | | private DaPointDao daPointDao; |
| | |
| | | break; |
| | | case CUMULATE: |
| | | result.setCumulatePoint(daCumulatePointService.getByPoint(id)); |
| | | break; |
| | | case EXTREMAL: |
| | | result.setExtremalPoint(daExtremalPointService.getByPoint(id)); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | daCumulatePointService.add(dataPoint.getCumulatePoint(), daPointEntity.getId()); |
| | | daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name())); |
| | | break; |
| | | case EXTREMAL: |
| | | daExtremalPointService.add(dataPoint.getExtremalPoint(), daPointEntity.getId()); |
| | | daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_E.name())); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | case CUMULATE: |
| | | daCumulatePointService.update(dataPoint.getCumulatePoint()); |
| | | break; |
| | | case EXTREMAL: |
| | | daExtremalPointService.update(dataPoint.getExtremalPoint()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | daMeasurePointService.deleteByPoint(ids); |
| | | daMathPointService.deleteByPoint(ids); |
| | | daCumulatePointService.deleteByPoint(ids); |
| | | daExtremalPointService.deleteByPoint(ids); |
| | | // 清空缓存 |
| | | clearCache(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<DaPointDTO> getExtremalPoint(String freq) { |
| | | Map<String, Object> params = new HashMap<>(3); |
| | | params.put("pointType", PointTypeEnum.CUMULATE.getCode()); |
| | | params.put("isEnable", CommonConstant.IS_ENABLE); |
| | | params.put("minfreqid", freq); |
| | | return daPointDao.getExtremalPoint(params); |
| | | } |
| | | |
| | | @Override |
| | | public List<DaPointDTO> getExtremalPoint(List<String> pointNos) { |
| | | Map<String, Object> params = new HashMap<>(3); |
| | | params.put("pointType", PointTypeEnum.CUMULATE.getCode()); |
| | | params.put("isEnable", CommonConstant.IS_ENABLE); |
| | | params.put("pointNos", pointNos); |
| | | return daPointDao.getExtremalPoint(params); |
| | | } |
| | | |
| | | @Override |
| | | public List<DaPointDTO> getCumulatePoint(DaPointPageReqVO reqVO) { |
| | | Map<String, Object> params = new HashMap<>(3); |
| | | params.put("pointType", PointTypeEnum.CUMULATE.getCode()); |
| | |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="getExtremalPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO"> |
| | | SELECT |
| | | t1.point_no, |
| | | t1.point_name, |
| | | t1.default_value, |
| | | t1.point_type, |
| | | t1.data_type, |
| | | t1.store_type, |
| | | t1.unittransfactor, |
| | | t1.max_value, |
| | | t1.min_value, |
| | | t1.minfreqid, |
| | | t2.moment_point, |
| | | t2.length, |
| | | t2.extremal_unit, |
| | | t2.extremal_type |
| | | FROM t_da_point t1 |
| | | LEFT JOIN t_da_extremal_point t2 ON t2.point_id = t1.id |
| | | <where> |
| | | t1.point_type = #{pointType} |
| | | <if test="isEnable != null"> |
| | | AND t1.is_enable = #{isEnable} |
| | | </if> |
| | | <if test="minfreqid != null and minfreqid != ''"> |
| | | AND t1.minfreqid = #{minfreqid} |
| | | </if> |
| | | <if test="pointNos != null"> |
| | | AND t1.point_no in |
| | | <foreach collection="pointNos" item="item" index="item" open="(" close=")" separator=","> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="getPointPage" parameterType="map" resultType="com.iailab.module.data.api.point.dto.ApiPointDTO"> |
| | | select point_no pointNo,point_name pointName from t_da_point |
| | | <where> |