取redis点位数据最新值,没有就是0
This commit is contained in:
@ -66,6 +66,8 @@ import org.elasticsearch.index.query.QueryBuilders;
|
|||||||
import org.elasticsearch.search.sort.SortBuilders;
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.redisson.api.RMapCache;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
@ -88,9 +90,11 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/work/mpoint")
|
@RequestMapping("/work/mpoint")
|
||||||
@ -164,6 +168,8 @@ public class MPointController {
|
|||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MPointRepo mPointRepo;
|
private MPointRepo mPointRepo;
|
||||||
|
@Resource
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从数据库查数据
|
* 从数据库查数据
|
||||||
@ -583,7 +589,20 @@ public class MPointController {
|
|||||||
mp.setProcessSection(processSections.get(0));
|
mp.setProcessSection(processSections.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 取redis点位数据最新值,没有就是0
|
||||||
|
for (MPoint mPoint : list) {
|
||||||
|
String id = mPoint.getId();
|
||||||
|
int num = mPoint.getId().hashCode() % 25;
|
||||||
|
RMapCache<String, String> map_redis_data = redissonClient.getMapCache(CommString.RedisMpointFlag + num);
|
||||||
|
if (map_redis_data.get(id) != null && !"".equals(map_redis_data.get(id))) {
|
||||||
|
String[] str = map_redis_data.get(id).split(";");
|
||||||
|
if (str.length >= 3 && str[1] != null && !str[1].isEmpty() && !"null".equals(str[1])) {
|
||||||
|
mPoint.setParmvalue(new BigDecimal(str[1]));
|
||||||
|
} else {
|
||||||
|
mPoint.setParmvalue(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
JSONArray json = JSONArray.fromObject(list.getContent());
|
JSONArray json = JSONArray.fromObject(list.getContent());
|
||||||
result = "{\"total\":" + list.getTotalElements() + ",\"rows\":" + json + "}";
|
result = "{\"total\":" + list.getTotalElements() + ",\"rows\":" + json + "}";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@ package com.sipai.entity.alarm;
|
|||||||
|
|
||||||
public enum PipelineAreaEnum {
|
public enum PipelineAreaEnum {
|
||||||
|
|
||||||
PipelineArea_Out_Side("OUT_SIDE", "场外管道"),
|
PipelineArea_Out_Side("OUT_SIDE", "厂外管道"),
|
||||||
PipelineArea_In_Side("In_SIDE", "场内管道");
|
PipelineArea_In_Side("In_SIDE", "厂内管道");
|
||||||
|
|
||||||
private String code;
|
private String code;
|
||||||
private String description;
|
private String description;
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class PipelineData extends SQLAdapter implements Serializable {
|
|||||||
private BigDecimal pipelineInvertElevationM;
|
private BigDecimal pipelineInvertElevationM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管道场内场外标识(场外管道/场内管道)
|
* 管道场内场外标识(厂外管道/厂内管道)
|
||||||
*/
|
*/
|
||||||
@Column(name = "pipeline_area", length = 20)
|
@Column(name = "pipeline_area", length = 20)
|
||||||
private String pipelineArea;
|
private String pipelineArea;
|
||||||
|
|||||||
Reference in New Issue
Block a user