Commit f28f7bdc authored by tangwei's avatar tangwei

增加曲线接口

parent 426dcdf5
...@@ -120,4 +120,19 @@ public class IdxBizFanHealthIndexController extends BaseController { ...@@ -120,4 +120,19 @@ public class IdxBizFanHealthIndexController extends BaseController {
return ResponseHelper.buildResponse(idxBizFanHealthIndexServiceImpl.queryForLeftTableList(STATION,HEALTHLEVEL)); return ResponseHelper.buildResponse(idxBizFanHealthIndexServiceImpl.queryForLeftTableList(STATION,HEALTHLEVEL));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "测点运行趋势图", notes = "测点运行趋势图")
@GetMapping(value = "/getqyt")
public ResponseModel<Object> getqyt(
String address,
String statioName,
String equipmentName,
String arae,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime
) {
return ResponseHelper.buildResponse(idxBizFanHealthIndexServiceImpl.getqyt( address,statioName,equipmentName,arae,startTime,endTime));
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanHealthIndexDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizUxfv;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizUxfvMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizFanHealthIndexService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IIdxBizFanHealthIndexService;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List; import java.text.SimpleDateFormat;
import java.util.*;
/** /**
* 服务实现类 * 服务实现类
...@@ -18,6 +27,12 @@ import java.util.List; ...@@ -18,6 +27,12 @@ import java.util.List;
*/ */
@Service @Service
public class IdxBizFanHealthIndexServiceImpl extends BaseService<IdxBizFanHealthIndexDto,IdxBizFanHealthIndex,IdxBizFanHealthIndexMapper> implements IIdxBizFanHealthIndexService { public class IdxBizFanHealthIndexServiceImpl extends BaseService<IdxBizFanHealthIndexDto,IdxBizFanHealthIndex,IdxBizFanHealthIndexMapper> implements IIdxBizFanHealthIndexService {
@Autowired
IdxBizUxfvMapper idxBizUxfvMapper;
@Autowired
IndicatorDataMapper indicatorDataMapper;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -35,4 +50,58 @@ public class IdxBizFanHealthIndexServiceImpl extends BaseService<IdxBizFanHealth ...@@ -35,4 +50,58 @@ public class IdxBizFanHealthIndexServiceImpl extends BaseService<IdxBizFanHealth
public List<IdxBizFanHealthIndexDto> queryForLeftTableList(String STATION,String HEALTHLEVEL){ public List<IdxBizFanHealthIndexDto> queryForLeftTableList(String STATION,String HEALTHLEVEL){
return this.getBaseMapper().queryForLeftTableList(STATION,HEALTHLEVEL); return this.getBaseMapper().queryForLeftTableList(STATION,HEALTHLEVEL);
} }
public Object getqyt(String address,String statioName,String equipmentName, String arae,String startTime,String endTime){
//获取场站网关
IdxBizUxfv idxBizUxfv= idxBizUxfvMapper.selectOne(
new QueryWrapper<IdxBizUxfv>()
.eq("INDEX_ADDRESS", address)
.eq("STATION", statioName)
.eq("EQUIPMENT_NAME", equipmentName)
.eq("ARAE", arae)
);
String tdid=address+"_"+idxBizUxfv.getGatewayId();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
//限制必须是区间时间段
if(startTime==null||endTime==null){
Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
startTime = sdf.format(currentDayStartTime);
endTime= sdf.format(currentDayEndTime);
}else{
Date currentDayStartTime =new Date(startTime);
Date currentDayEndTime = new Date(endTime);
startTime = sdf.format(currentDayStartTime);
endTime= sdf.format(currentDayEndTime);
}
List<IndicatorData> indicatorDataListActivePowers = new ArrayList<>();
indicatorDataListActivePowers= indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber(tdid,startTime,endTime);
List<String> axisData = new ArrayList<>();
List<String> activePowers = new ArrayList<>();
for (int i = 0; i < indicatorDataListActivePowers.size(); i++) {
activePowers.add(indicatorDataListActivePowers.get(i).getValue());
axisData.add(DateUtil.format(indicatorDataListActivePowers.get(i).getCreatedTime(), "HH:mm"));
}
List<Map<String, Object>> seriesData = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
map2.put("data", activePowers);
seriesData.add(map2);
map.put("seriesData", seriesData);
map.put("axisData", axisData);
return map;
}
} }
\ No newline at end of file
...@@ -39,4 +39,10 @@ public interface IndicatorDataMapper extends BaseMapper<IndicatorData> { ...@@ -39,4 +39,10 @@ public interface IndicatorDataMapper extends BaseMapper<IndicatorData> {
*/ */
@Select("SELECT created_time as createdTime, avg( `value_f` ) as valueF FROM iot_data.indicator_data WHERE gateway_id = #{gatewayId} AND equipment_index_name = #{equipmentIndexName} AND ts > #{date} GROUP BY created_time order by created_time desc LIMIT #{limitNum}") @Select("SELECT created_time as createdTime, avg( `value_f` ) as valueF FROM iot_data.indicator_data WHERE gateway_id = #{gatewayId} AND equipment_index_name = #{equipmentIndexName} AND ts > #{date} GROUP BY created_time order by created_time desc LIMIT #{limitNum}")
List<IndicatorData> selectByIndexNameAndDate(@Param("equipmentIndexName") String equipmentIndexName, @Param("gatewayId") String gatewayId, @Param("date") String date, @Param("limitNum") Integer limitNum); List<IndicatorData> selectByIndexNameAndDate(@Param("equipmentIndexName") String equipmentIndexName, @Param("gatewayId") String gatewayId, @Param("date") String date, @Param("limitNum") Integer limitNum);
@Select("select `value`, created_time, `value_f` as valueF from iot_data.indicator_data where id =#{id} and ts >= #{startTime} and ts <= #{endTime} ")
List<IndicatorData> selectDataByequipmentIndexNameAndtimeAndEquipmentNumber(@Param("id") String id, @Param("startTime") String startTime, @Param("endTime") String endTime);
} }
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