Commit 839c055c authored by tangwei's avatar tangwei

运行记录接口

parent 1e732fdf
......@@ -29,7 +29,7 @@ public class MonitorFanIndicatorDto extends BaseEntity {
private String frontModule;//所属模块
private String indexAddress;// 指标地址
private String addressGateway;// 指标地址
private String equipmentNumber;// 设备编号
......
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2023/7/5
*/
//运行记录
@Data
public class RunRecord {
//风机名称
private String FanName;
//有功功率
private String power;
//风速
private String windSpeed;
//风向
private String windDirection;
//日发电量
private String PowerGeneration;
}
......@@ -43,8 +43,8 @@ public class MonitorFanIndicator extends BaseEntity {
private String indexAddress;// 指标地址
@TableField("address_gateway")
private String addressGateway;// 指标地址
@TableField("equipment_number")
private String equipmentNumber;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mysql.cj.x.protobuf.MysqlxCrud;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import org.apache.ibatis.annotations.Param;
......@@ -28,4 +29,12 @@ public interface MonitorFanIndicatorMapper extends BaseMapper<MonitorFanIndicato
@Param("frontModule") String frontModule,
@Param("offset") int offset);
Object getIndicatoralueAvage(String gateway,String indicator);
List<RunRecord> queryRunRecord(@Param("size") long size,
@Param("list") String[] list,
@Param("offset") long offset);
int queryRunRecordTotal( @Param("list") String[] list);
}
......@@ -72,4 +72,49 @@
WHERE gateway=#{gateway} and
indicator like concat('%',#{indicator},'%')
</select>
<select id="queryRunRecord" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord">
SELECT
t.equipment_number AS FanName,
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="有功功率") AS 'power',
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="瞬时风速") AS 'windSpeed',
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="60秒平均风向角") AS 'windDirection',
(SELECT indicator_value FROM monitor_fan_indicator WHERE equipment_number=t.equipment_number AND gateway=t.gateway and indicator="日发电量") AS 'PowerGeneration'
FROM
(select
DISTINCT a.equipment_number,a.gateway
from monitor_fan_indicator a where a.equipment_number is not null and a.gateway in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item}
</foreach>
ORDER BY a.equipment_number ) AS t
limit #{offset}, #{size}
</select>
<select id="queryRunRecordTotal" resultType="java.lang.Integer">
select
count(DISTINCT a.equipment_number) num
from monitor_fan_indicator a where a.equipment_number is not null and a.gateway in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
......@@ -53,11 +55,14 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "运行记录")
@GetMapping("/runRecord")
public ResponseModel<IPage<MonitorFanIndicator>> runRecord(
public ResponseModel<IPage<RunRecord>> runRecord(
@RequestParam(value = "gateway", required = false) String gateway,
@RequestParam(value = "current", required = false) int current,
@RequestParam(value = "size", required = false) int size) {
return null;
String[] gateways=gateway.split(",");
IPage<RunRecord> page= monitorFanIndicator.queryRunRecord( size,gateways, current);
return ResponseHelper.buildResponse(page);
}
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
......@@ -15,6 +16,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -104,5 +106,20 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public Object getIndicatoralueAvage(String gateway,String indicator){
return monitorFanIndicatorregionMapper.getIndicatoralueAvage(gateway,indicator);
}
public IPage<RunRecord> queryRunRecord(long size,String[] gateway, int current){
Page<RunRecord> page = new Page<>(current, size);
Integer integer = monitorFanIndicatorregionMapper.queryRunRecordTotal(gateway);
List<RunRecord> runRecord = monitorFanIndicatorregionMapper.queryRunRecord(page.getSize(), gateway, (current - 1) * size);
page.setTotal(integer);
page.setRecords(runRecord);
return page;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment