Commit af40e454 authored by tangwei's avatar tangwei

优化写入数据

parent 42b02cff
...@@ -19,4 +19,5 @@ public class IndexDto { ...@@ -19,4 +19,5 @@ public class IndexDto {
private String equipmentSpecificName;// private String equipmentSpecificName;//
private String value; private String value;
private int count; private int count;
private String equipmentsIdx;
} }
...@@ -28,7 +28,7 @@ public class MonitorFanIndicatorDto extends BaseEntity { ...@@ -28,7 +28,7 @@ public class MonitorFanIndicatorDto extends BaseEntity {
private String systemType;//所属系统 private String systemType;//所属系统
private String frontModule;//所属模块 private String frontModule;//所属模块
private String indexAddress;// 指标地址 private String indexAddress;// 指标地址
private String addressGateway;// 指标地址
......
...@@ -41,6 +41,8 @@ public class MonitorFanIndicator extends BaseEntity { ...@@ -41,6 +41,8 @@ public class MonitorFanIndicator extends BaseEntity {
private String frontModule;//所属模块 private String frontModule;//所属模块
@TableField("index_address") @TableField("index_address")
private String indexAddress;// 指标地址 private String indexAddress;// 指标地址
@TableField("address_gateway")
private String addressGateway;// 指标地址
......
...@@ -4,10 +4,36 @@ ...@@ -4,10 +4,36 @@
<update id="UpdateMonitorFanIndicator"> <update id="UpdateMonitorFanIndicator">
update monitor_fan_indicator
<trim prefix="set" suffixOverrides=",">
<trim prefix="indicator_value=case" suffix="end,">
<foreach collection="list" item="item" index="index">
when address_gateway=#{item.equipmentsIdx} then #{item.valueLabel}
</foreach>
</trim>
<trim prefix="indicator_time=case" suffix="end,">
<foreach collection="list" item="item" index="index"> <foreach collection="list" item="item" index="index">
update monitor_fan_indicator set indicator_value =#{item.valueLabel} , indicator_time =#{item.createdTime}
where gateway=#{item.gatewayId} and index_address=#{item.address}; when address_gateway=#{item.equipmentsIdx} then #{item.createdTime}
</foreach>
</trim>
</trim>
where address_gateway in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.equipmentsIdx}
</foreach> </foreach>
</update> </update>
<select id="queryByPage" resultType="com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator"> <select id="queryByPage" resultType="com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator">
......
...@@ -49,4 +49,18 @@ public class MonitorFanIdxController extends BaseController { ...@@ -49,4 +49,18 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr)); return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "运行记录")
@GetMapping("/runRecord")
public ResponseModel<IPage<MonitorFanIndicator>> runRecord(
@RequestParam(value = "gateway", required = false) String gateway,
@RequestParam(value = "current", required = false) int current,
@RequestParam(value = "size", required = false) int size) {
return null;
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2023/7/4
*/
@Component
public class MonitorFanIndicatorAsync {
@Autowired
MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@Value("${station.section}")
private int stationSection;
@Value("${station.isok}")
private boolean isok;
@Async("jxiopAsyncExecutor")
public void UpdateMonitorFanIndicator(List<IndexDto> list){
monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list);
}
}
...@@ -44,6 +44,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -44,6 +44,9 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
monitorFanIndicatorregionMapper.UpdateMonitorFanIndicator(list); monitorFanIndicatorregionMapper.UpdateMonitorFanIndicator(list);
} }
public IPage<MonitorFanIndicator> getFanIdxInfoByPage(String fanCode, String gateway, String frontModule, int current, int size) { public IPage<MonitorFanIndicator> getFanIdxInfoByPage(String fanCode, String gateway, String frontModule, int current, int size) {
......
...@@ -35,17 +35,17 @@ public class StationDataTaskImpl { ...@@ -35,17 +35,17 @@ public class StationDataTaskImpl {
InfluxDbConnection influxDbConnection; InfluxDbConnection influxDbConnection;
@Autowired @Autowired
MonitorFanIndicatorImpl monitorFanIndicatorImpl; MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@Autowired
InfluxDButils influxDButils;
@Value("${station.section}") @Value("${station.section}")
private int stationSection; private int stationSection;
@Value("${station.isok}") @Value("${station.isok}")
private boolean isok; private boolean isok;
@Autowired
InfluxDButils influxDButils;
@Autowired
MonitorFanIndicatorAsync monitorFanIndicatorAsync;
public List<StationTaksDto> getListStationBasic() { public List<StationTaksDto> getListStationBasic() {
List<StationTaksDto> stationTaksDtoList = new ArrayList<>(); List<StationTaksDto> stationTaksDtoList = new ArrayList<>();
List<StationBasic> stationBasicList= stationBasicServiceImpl.list(); List<StationBasic> stationBasicList= stationBasicServiceImpl.list();
...@@ -77,7 +77,7 @@ public class StationDataTaskImpl { ...@@ -77,7 +77,7 @@ public class StationDataTaskImpl {
@Async("jxiopAsyncExecutor") @Async("jxiopAsyncExecutor")
public List<IndexDto> getIndexDto(DeviceDto deviceDto) { public List<IndexDto> getIndexDto(DeviceDto deviceDto) {
String querysql ="SELECT createdTime ,gatewayId,address,valueLabel FROM iot_data WHERE equipmentSpecificName=~/.*"+deviceDto.getNumberName()+"风机"+".*/ and gatewayId='"+deviceDto.getGateway()+"' ORDER BY time desc LIMIT 600"; String querysql ="SELECT createdTime ,gatewayId,address,valueLabel ,equipmentsIdx FROM iot_data WHERE equipmentSpecificName=~/.*"+deviceDto.getNumberName()+"风机"+".*/ and gatewayId='"+deviceDto.getGateway()+"' ORDER BY time desc LIMIT 600";
//每个分机的指标数据 //每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysql,IndexDto.class); List<IndexDto> list = influxDButils.getListData(querysql,IndexDto.class);
if(list!=null&&list.size()>0){ if(list!=null&&list.size()>0){
...@@ -86,16 +86,20 @@ public class StationDataTaskImpl { ...@@ -86,16 +86,20 @@ public class StationDataTaskImpl {
monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list); monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list);
}else{ }else{
//进行分片处理 //进行分片处理
List<List<IndexDto>> listfp4= Lists.partition(list,100);
List<List<IndexDto>> listfp4= Lists.partition(list,stationSection);
for (List<IndexDto> indexDtos : listfp4) { for (List<IndexDto> indexDtos : listfp4) {
//每个分级信息处理 //每个分级信息处理
monitorFanIndicatorImpl.UpdateMonitorFanIndicator(indexDtos); monitorFanIndicatorAsync.UpdateMonitorFanIndicator(indexDtos);
} }
} }
} }
return list; return list;
} }
} }
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