Эх сурвалжийг харах

设备采集点信息-通过deviceId查询接口开发

qiangxuan 7 сар өмнө
parent
commit
046f77732f

+ 11 - 1
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/controller/DeviceInformationController.java

@@ -1,6 +1,5 @@
 package org.jeecg.modules.deviceLesm.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,6 +15,7 @@ import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
+import org.jeecg.modules.deviceLesm.entity.DeviceModelInfo;
 import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
 import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
 import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
@@ -287,4 +287,14 @@ public class DeviceInformationController extends JeecgController<DeviceInformati
 		}
 		return Result.OK("文件导入失败!");
     }
+
+	 @ApiOperation(value="设备模型信息-通过区域id查询", notes="设备模型信息-通过区域id查询")
+	 @GetMapping(value = "/queryDeviceModelById")
+	 public Result<DeviceModelInfo> queryDeviceModelById(@RequestParam(name="deviceRegionId") String deviceRegionId) {
+		 DeviceModelInfo deviceModelInfo = deviceInformationService.queryDeviceModelById(deviceRegionId);
+		 if(deviceModelInfo==null) {
+			 return Result.error("未找到对应数据");
+		 }
+		 return Result.OK(deviceModelInfo);
+	 }
 }

+ 7 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/entity/DeviceInformation.java

@@ -68,4 +68,11 @@ public class DeviceInformation implements Serializable {
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "更新日期")
     private Date updateTime;
+    /**运行状态
+     * RUNNING: '0', STOPPED: '1', ABNORMAL: '2'
+     * */
+    @Excel(name = "运行状态 ", width = 15, dicCode = "sfqy")
+    @ApiModelProperty(value = "运行状态")
+    @Dict(dicCode = "sfqy")
+    private String status;
 }

+ 18 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/entity/DeviceModelInfo.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.deviceLesm.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@ApiModel(value="设备模型信息", description="设备模型信息")
+public class DeviceModelInfo {
+
+    @ApiModelProperty(value = "设备信息")
+    private List<DeviceInformation> deviceInformationList;
+
+    @ApiModelProperty(value = "模型信息")
+    private List<FpgStatiscsModelMongodb> fpgStatiscsModelMongodbList;
+}

+ 129 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/entity/FpgStatiscsModelMongodb.java

@@ -0,0 +1,129 @@
+package org.jeecg.modules.deviceLesm.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @Description: 峰平谷数据采集
+ * @Author: jeecg-boot
+ * @Date:   2024-10-28
+ * @Version: V1.0
+ */
+@Data
+public class FpgStatiscsModelMongodb {
+
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+	/**采集点ID*/
+    @ApiModelProperty(value = "采集点ID")
+    private String devicePointId;
+	/**区域ID*/
+    @ApiModelProperty(value = "区域ID")
+    private String deviceRegionId;
+	/**设备id*/
+    @ApiModelProperty(value = "设备id")
+    private String deviceInformationId;
+    /**产生费用*/
+    @ApiModelProperty(value = "产生费用")
+    private BigDecimal amount;
+	/**运行时长*/
+    @ApiModelProperty(value = "运行时长")
+    private BigDecimal ingTime;
+	/**运行总功率*/
+    @ApiModelProperty(value = "运行总功率")
+    private BigDecimal power;
+    /**尖总功率*/
+    @ApiModelProperty(value = "尖总功率")
+    private BigDecimal topsPower;
+    /**峰总功率*/
+    @ApiModelProperty(value = "峰总功率")
+    private BigDecimal peaksPower;
+    /**平总功率*/
+    @ApiModelProperty(value = "平总功率")
+    private BigDecimal flatPower;
+    /**谷总功率*/
+    @ApiModelProperty(value = "谷总功率")
+    private BigDecimal valleysPower;
+    /**尖运行时长*/
+    @ApiModelProperty(value = "尖运行时长")
+    private BigDecimal topsIngTime;
+    /**峰运行时长*/
+    @ApiModelProperty(value = "峰运行时长")
+    private BigDecimal peaksIngTime;
+    /**平运行时长*/
+    @ApiModelProperty(value = "平运行时长")
+    private BigDecimal flatIngTime;
+    /**谷运行时长*/
+    @ApiModelProperty(value = "谷运行时长")
+    private BigDecimal valleysIngTime;
+    /**尖运行时长*/
+    @ApiModelProperty(value = "尖产生费用")
+    private BigDecimal topsAmount;
+    /**峰运行时长*/
+    @ApiModelProperty(value = "峰产生费用")
+    private BigDecimal peaksAmount;
+    /**平运行时长*/
+    @ApiModelProperty(value = "平产费用")
+    private BigDecimal flatAmount;
+    /**产生费用*/
+    @ApiModelProperty(value = "谷产费用")
+    private BigDecimal valleysAmount;
+    /**尖单价电费*/
+    @ApiModelProperty(value = "尖单价电费")
+    private BigDecimal topsPrice;
+    /**峰单价电费*/
+    @ApiModelProperty(value = "峰单价电费")
+    private BigDecimal peaksPrice;
+    /**平单价电费*/
+    @ApiModelProperty(value = "平单价电费")
+    private BigDecimal flatPrice;
+    /**谷单价电费*/
+    @ApiModelProperty(value = "谷单价电费")
+    private BigDecimal valleysPrice;
+    /**尖电流*/
+    @ApiModelProperty(value = "尖电流")
+    private BigDecimal topsSelectricCurrent;
+    /**峰电流*/
+    @ApiModelProperty(value = "峰电流")
+    private BigDecimal peaksSelectricCurrent;
+    /**平电流*/
+    @ApiModelProperty(value = "平电流")
+    private BigDecimal flatSelectricCurrent;
+    /**谷电流*/
+    @ApiModelProperty(value = "谷电流")
+    private BigDecimal valleysSelectricCurrent;
+    /**尖占比%*/
+    @ApiModelProperty(value = "尖占比%")
+    private BigDecimal topsProportion;
+    /**峰占比%*/
+    @ApiModelProperty(value = "峰占比%")
+    private BigDecimal peaksProportion;
+    /**平占比%*/
+    @ApiModelProperty(value = "平占比%")
+    private BigDecimal flatProportion;
+    /**谷占比%*/
+    @ApiModelProperty(value = "谷占比%")
+    private BigDecimal valleysProportion;
+    /**占比处理%*/
+    @ApiModelProperty(value = "占比处理")
+    private Integer proportion;
+    /**班次*/
+    @ApiModelProperty(value = "班次")
+    private String classs;
+    /**日期*/
+    @ApiModelProperty(value = "日期")
+    private String dates;
+    /**统计单位存储对应时间格式*/
+    @ApiModelProperty(value = "统计单位存储对应时间格式")
+    private String datestr;
+    /**创建时间*/
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    public FpgStatiscsModelMongodb() {
+
+    }
+}

+ 2 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/service/IDeviceInformationService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.deviceLesm.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
+import org.jeecg.modules.deviceLesm.entity.DeviceModelInfo;
 
 /**
  * @Description: 设备管理信息表
@@ -11,4 +12,5 @@ import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
  */
 public interface IDeviceInformationService extends IService<DeviceInformation> {
 
+    DeviceModelInfo queryDeviceModelById(String deviceRegionId);
 }

+ 47 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/deviceLesm/service/impl/DeviceInformationServiceImpl.java

@@ -1,12 +1,23 @@
 package org.jeecg.modules.deviceLesm.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
+import org.jeecg.modules.deviceLesm.entity.DeviceModelInfo;
+import org.jeecg.modules.deviceLesm.entity.FpgStatiscsModelMongodb;
 import org.jeecg.modules.deviceLesm.mapper.DeviceInformationMapper;
 import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @Description: 设备管理信息表
  * @Author: jeecg-boot
@@ -16,4 +27,40 @@ import org.springframework.stereotype.Service;
 @Service
 public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationMapper, DeviceInformation> implements IDeviceInformationService {
 
+    @Autowired
+    MongoTemplate mongoTemplate;
+
+    @Override
+    public DeviceModelInfo queryDeviceModelById(String deviceRegionId) {
+        DeviceModelInfo result = new DeviceModelInfo();
+        LambdaQueryWrapper<DeviceInformation> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(DeviceInformation::getDeviceRegionId, deviceRegionId);
+        List<DeviceInformation> deviceInformationList = baseMapper.selectList(wrapper);
+        if (oConvertUtils.listIsEmpty(deviceInformationList)){
+            return null;
+        }
+        result.setDeviceInformationList(deviceInformationList);
+        List<String> deviceInformationIds = deviceInformationList.stream().map(DeviceInformation::getId).collect(Collectors.toList());
+        // 获取mongoDB中的模型信息
+        Query query = new Query();
+        query.addCriteria(Criteria.where("deviceRegionId").is(deviceRegionId))// 设备区域ID
+                .addCriteria(Criteria.where("deviceInformationId").in(deviceInformationIds));// 虚拟设备
+//        Date startTime = DateUtils.str2Date(startTimeParam, DateUtils.datetimeFormat.get());
+//        Calendar calendar1 = Calendar.getInstance();
+//        calendar1.setTime(startTime);
+//        calendar1.add(Calendar.HOUR, 8);
+//        Date specifiedTimePlus8HoursStartTime = calendar1.getTime();
+//        Date endTime = DateUtils.str2Date(endTimeParam, DateUtils.datetimeFormat.get());
+//        Calendar calendar2 = Calendar.getInstance();
+//        calendar2.setTime(endTime);
+//        calendar2.add(Calendar.HOUR, 8);
+//        Date specifiedTimePlus8HoursStartEndTime = calendar2.getTime();
+//        query.addCriteria(Criteria.where("createTime").gte(specifiedTimePlus8HoursStartTime).lt(specifiedTimePlus8HoursStartEndTime));
+        List<FpgStatiscsModelMongodb> fpgStatiscsModelMongodbList = mongoTemplate.find(query, FpgStatiscsModelMongodb.class, "leanmodel_run_power_minute");
+        if (oConvertUtils.listIsEmpty(fpgStatiscsModelMongodbList)){
+            return result;
+        }
+        result.setFpgStatiscsModelMongodbList(fpgStatiscsModelMongodbList);
+        return result;
+    }
 }