Commit d64c1cc4 authored by 廖旭伟's avatar 廖旭伟

Merge remote-tracking branch 'origin/master'

parents cf556ed6 6da6a96d
...@@ -149,13 +149,13 @@ public class DeviceReq implements Serializable { ...@@ -149,13 +149,13 @@ public class DeviceReq implements Serializable {
/** /**
* 设备宽度 * 设备宽度
*/ */
private Double width; private String width;
/** /**
* 设备高度 * 设备高度
*/ */
private Double height; private String height;
public static void main(String[] args) { public static void main(String[] args) {
...@@ -171,12 +171,12 @@ public class DeviceReq implements Serializable { ...@@ -171,12 +171,12 @@ public class DeviceReq implements Serializable {
System.out.println("div >= 0.9 && div <= 1.1"); System.out.println("div >= 0.9 && div <= 1.1");
} }
//double radio=1920/1080; //double radio=1920/1080;
System.out.println(NumberUtil.div(1280, 800, 2));
System.out.println(NumberUtil.div(1920, 1080, 2)); System.out.println(NumberUtil.div(1920, 1080, 2));
System.out.println(NumberUtil.div(1080, 1920, 2)); System.out.println(NumberUtil.div(400, 1280, 2));
System.out.println(NumberUtil.div(1280, 1280, 2)); System.out.println(NumberUtil.div(1024, 600, 2));
} }
......
...@@ -118,8 +118,6 @@ public class DeviceApiController { ...@@ -118,8 +118,6 @@ public class DeviceApiController {
@Value("${token.secret}") @Value("${token.secret}")
private String secret; private String secret;
//private String masterhost = "10.12.185.213";
//private String phpUrl = "http://10.12.185.213:8090";
@Autowired @Autowired
private SendTaskThreadPool sendTaskThreadPool; private SendTaskThreadPool sendTaskThreadPool;
@Autowired @Autowired
...@@ -216,6 +214,7 @@ public class DeviceApiController { ...@@ -216,6 +214,7 @@ public class DeviceApiController {
//判断当前设备是否设置了分辨率 如果设置了 查询当前设备的资源路径是否存在 如果存在 //判断当前设备是否设置了分辨率 如果设置了 查询当前设备的资源路径是否存在 如果存在
String resolution = deviceEntity.getResolution(); String resolution = deviceEntity.getResolution();
if (!ObjectUtils.isEmpty(resolution)) { if (!ObjectUtils.isEmpty(resolution)) {
//存在分辨率
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery(); DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setProductId(productEntity.getId()); query.setProductId(productEntity.getId());
query.setSiteId(deviceEntity.getSiteId()); query.setSiteId(deviceEntity.getSiteId());
...@@ -223,6 +222,7 @@ public class DeviceApiController { ...@@ -223,6 +222,7 @@ public class DeviceApiController {
query.setDistribute(DistributeEnum..getValue()); query.setDistribute(DistributeEnum..getValue());
DeviceModuleDistributeEntity distribute = deviceModuleDistributeService.selectOne(query); DeviceModuleDistributeEntity distribute = deviceModuleDistributeService.selectOne(query);
if (!ObjectUtils.isEmpty(distribute)) { if (!ObjectUtils.isEmpty(distribute)) {
//当前分辨率资源存在
String homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", distribute.getSiteId(), distribute.getProductCode(), distribute.getImageResolutionValue()); String homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", distribute.getSiteId(), distribute.getProductCode(), distribute.getImageResolutionValue());
//根据部署的资源 生成homeurl //根据部署的资源 生成homeurl
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078"); String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
...@@ -238,6 +238,7 @@ public class DeviceApiController { ...@@ -238,6 +238,7 @@ public class DeviceApiController {
serverInfo.setEventUrl(productEntity.getEventUrl()); serverInfo.setEventUrl(productEntity.getEventUrl());
} }
} else { } else {
//当前分辨率资源部存在,如果存在高宽,则用高宽比查询生成相近homeurl
buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort); buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort);
} }
} else { } else {
...@@ -430,8 +431,9 @@ public class DeviceApiController { ...@@ -430,8 +431,9 @@ public class DeviceApiController {
ApiResp<DeviceResp> rsp = new ApiResp<>(); ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue()); rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
DeviceResp deviceResp = new DeviceResp(); DeviceResp deviceResp = new DeviceResp();
Double width = req.getWidth(); String width = req.getWidth();
Double height = req.getHeight(); String height = req.getHeight();
try { try {
if (ObjectUtils.isEmpty(req.getDeviceCode())) { if (ObjectUtils.isEmpty(req.getDeviceCode())) {
...@@ -456,46 +458,29 @@ public class DeviceApiController { ...@@ -456,46 +458,29 @@ public class DeviceApiController {
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode()); DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode());
if (!ObjectUtils.isEmpty(width) && !ObjectUtils.isEmpty(height)) {
//根据分辨率 自适应设置分辨率
double div = NumberUtil.div(width, height, 2);
if (div >= 1.7 && div <= 1.8) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1920X1080.getDesc());
System.out.println("1.7 < div < 1.8");
} else if (div >= 0.4 && div <= 0.7) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1080X1920.getDesc());
System.out.println("1.7 < div < 1.8");
} else if (div >= 0.9 && div <= 1.1) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1280X1280.getDesc());
System.out.println("div >= 0.9 && div <= 1.1");
}
}
if (ObjectUtils.isEmpty(deviceEntity)) { if (ObjectUtils.isEmpty(deviceEntity)) {
//初始化新增基础设备,后续在线完善信息后再行注册添加 //初始化新增基础设备,后续在线完善信息后再行注册添加
deviceEntity = new DeviceEntity(); deviceEntity = new DeviceEntity();
deviceEntity.initAttrValue(); deviceEntity.initAttrValue();
checkAndUpdateImageRe(width, height, productEntity, deviceEntity);
saveDevice(req, platformEntity, productEntity, deviceEntity); saveDevice(req, platformEntity, productEntity, deviceEntity);
deviceEntity.setCreateTime(new Date()); deviceEntity.setCreateTime(new Date());
deviceEntity.setCreateUserId(1L); deviceEntity.setCreateUserId(1L);
deviceService.save(deviceEntity, null); deviceService.save(deviceEntity, null);
} else { } else {
//更新 //更新
checkAndUpdateImageRe(width, height, productEntity, deviceEntity);
updateDevice(req, platformEntity, productEntity, deviceEntity); updateDevice(req, platformEntity, productEntity, deviceEntity);
deviceEntity.setUpdateTime(new Date()); deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(1L); deviceEntity.setUpdateUserId(1L);
//cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE, deviceEntity);
deviceService.update(deviceEntity, null); deviceService.update(deviceEntity, null);
} }
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()) { if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()) {
throw new AppException(DEVICE_UNACTIVE, DEVICE_UNACTIVE_CONTENT); throw new AppException(DEVICE_UNACTIVE, DEVICE_UNACTIVE_CONTENT);
} }
DeviceQueueAuthInfo authInfo = new DeviceQueueAuthInfo(); DeviceQueueAuthInfo authInfo = new DeviceQueueAuthInfo();
URL url = getServerUrl(); URL url = getServerUrl();
//authInfo.setHost(masterhost);
authInfo.setHost(url.getHost()); authInfo.setHost(url.getHost());
authInfo.setPort(port); authInfo.setPort(port);
authInfo.setUsername(username); authInfo.setUsername(username);
...@@ -503,18 +488,14 @@ public class DeviceApiController { ...@@ -503,18 +488,14 @@ public class DeviceApiController {
authInfo.setMessageTtl(messageTtl); authInfo.setMessageTtl(messageTtl);
authInfo.setVirtualHost(virtualHost); authInfo.setVirtualHost(virtualHost);
// authInfo.setExchangeName(platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode());
authInfo.setExchangeName(QueueKey.DEFAULT_EXCHANGE); authInfo.setExchangeName(QueueKey.DEFAULT_EXCHANGE);
authInfo.setUploadTopicFilter(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode()); authInfo.setUploadTopicFilter(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode());
authInfo.setDownTopicFilter(Constant.DOWN_TOPIC + deviceEntity.getDeviceCode()); authInfo.setDownTopicFilter(Constant.DOWN_TOPIC + deviceEntity.getDeviceCode());
RegisterResp registerResp = new RegisterResp(); RegisterResp registerResp = new RegisterResp();
registerResp.setRabbmitInfo(authInfo); registerResp.setRabbmitInfo(authInfo);
ServerInfo serverInfo = new ServerInfo(); ServerInfo serverInfo = new ServerInfo();
serverInfo.setScheme(scheme); serverInfo.setScheme(scheme);
// buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
String resolution = deviceEntity.getResolution(); String resolution = deviceEntity.getResolution();
...@@ -543,25 +524,6 @@ public class DeviceApiController { ...@@ -543,25 +524,6 @@ public class DeviceApiController {
} else { } else {
buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort); buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort);
} }
} else if (!ObjectUtils.isEmpty(width) && !ObjectUtils.isEmpty(height)) {
//根据分辨率 自适应设置分辨率
double div = NumberUtil.div(width, height, 2);
if( div >= 1.7 && div <= 1.8){
deviceEntity.setResolutionValue(ImageReEnum.RE_1920X1080.getDesc());
System.out.println("1.7 < div < 1.8");
}else if( div >= 0.4 && div <= 0.7){
deviceEntity.setResolutionValue(ImageReEnum.RE_1080X1920.getDesc());
System.out.println("1.7 < div < 1.8");
}else if( div >= 0.9 && div <= 1.1){
deviceEntity.setResolutionValue(ImageReEnum.RE_1280X1280.getDesc());
System.out.println("div >= 0.9 && div <= 1.1");
}
// ImageReEnum.RE_1920X1080
} else { } else {
buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort); buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort);
} }
...@@ -576,9 +538,6 @@ public class DeviceApiController { ...@@ -576,9 +538,6 @@ public class DeviceApiController {
} else { } else {
serverInfo.setServerUrl(platformEntity.getSendUrl()); serverInfo.setServerUrl(platformEntity.getSendUrl());
} }
//serverInfo.setServerUrl(platformEntity.getSendUrl());
//String phpUrl=GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://10.12.185.213:8090");
//serverInfo.setServerUrl(phpUrl);
registerResp.setServiceInfo(serverInfo); registerResp.setServiceInfo(serverInfo);
DeviceInfo deviceInfo = new DeviceInfo(); DeviceInfo deviceInfo = new DeviceInfo();
...@@ -609,6 +568,47 @@ public class DeviceApiController { ...@@ -609,6 +568,47 @@ public class DeviceApiController {
return JSON.toJSONString(rsp); return JSON.toJSONString(rsp);
} }
private void checkAndUpdateImageRe(String width, String height, ProductEntity productEntity, DeviceEntity deviceEntity) {
if (!ObjectUtils.isEmpty(width)
&& !ObjectUtils.isEmpty(height)
&& ObjectUtils.isEmpty(deviceEntity.getResolution())) {
deviceEntity.setResolution(width + "x" + height);
deviceEntity.setResolutionValue(width + "x" + height);
//查询是否存在资源,如果不存在 则添加为相似资源
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setSiteId(deviceEntity.getSiteId());
query.setProductId(productEntity.getId());
query.setDistribute(DistributeEnum..getValue());
query.setImageResolution(deviceEntity.getResolution());
query.setOrderColList(Arrays.asList(new OrderCol("version", OrderCol.DESCENDING)));
DeviceModuleDistributeEntity deviceModuleDistributeEntity = deviceModuleDistributeService.selectOne(query);
if (ObjectUtils.isEmpty(deviceModuleDistributeEntity)) {
//没有资源 根据宽和高存在 找一个相近的资源。
if (!ObjectUtils.isEmpty(width) && !ObjectUtils.isEmpty(height)) {
//根据分辨率 自适应设置分辨率
double div = NumberUtil.div(Double.parseDouble(width), Double.parseDouble(height), 2);
if (div >= 1.4 && div <= 5.0) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1920X1080.getDesc());
deviceEntity.setResolution(ImageReEnum.RE_1920X1080.getDesc());
log.info("1.3 < div < 5.0");
//System.out.println("1.7 < div < 1.8");
} else if (div >= 0.1 && div <= 0.79) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1080X1920.getDesc());
deviceEntity.setResolution(ImageReEnum.RE_1080X1920.getDesc());
log.info("0.1 < div < 0.79");
//System.out.println("1.7 < div < 1.8");
} else if (div >= 0.8 && div <= 1.39) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1280X1280.getDesc());
deviceEntity.setResolution(ImageReEnum.RE_1280X1280.getDesc());
log.info("div >= 0.9 && div <= 1.1");
//System.out.println("div >= 0.9 && div <= 1.1");
}
}
}
}
}
/** /**
* 检查设备最新版本信息 * 检查设备最新版本信息
...@@ -621,8 +621,6 @@ public class DeviceApiController { ...@@ -621,8 +621,6 @@ public class DeviceApiController {
public String checkVersion(HttpServletRequest request, @RequestBody DeviceReq req) { public String checkVersion(HttpServletRequest request, @RequestBody DeviceReq req) {
String serverName = request.getHeader("server-name"); String serverName = request.getHeader("server-name");
Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"), 0); Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"), 0);
// String serverName = request.getServerName();
// int serverPort = request.getServerPort();
log.info("【检查设备最新版本信息】【请求体】--> " + JSONObject.toJSONString(req)); log.info("【检查设备最新版本信息】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp<DeviceResp> rsp = new ApiResp<>(); ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue()); rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
...@@ -635,10 +633,6 @@ public class DeviceApiController { ...@@ -635,10 +633,6 @@ public class DeviceApiController {
productVersionQuery.setProductId(deviceEntity.getProductId()); productVersionQuery.setProductId(deviceEntity.getProductId());
productVersionQuery.setSiteId(deviceEntity.getSiteId()); productVersionQuery.setSiteId(deviceEntity.getSiteId());
productVersionQuery.setOrderColList(Arrays.asList(new OrderCol("version", OrderCol.DESCENDING))); productVersionQuery.setOrderColList(Arrays.asList(new OrderCol("version", OrderCol.DESCENDING)));
/* ProductVersionEntity productVersionEntity = productVersionService.find(productVersionQuery)
.stream()
.filter(item -> StrUtil.endWith(item.getFilePath(), ".apk", true))
.findFirst().orElseGet(() -> null);*/
ProductVersionEntity productVersionEntity = productVersionService.selectOne(productVersionQuery); ProductVersionEntity productVersionEntity = productVersionService.selectOne(productVersionQuery);
if (ObjectUtils.isEmpty(productVersionEntity)) { if (ObjectUtils.isEmpty(productVersionEntity)) {
throw new AppException(DEVICE_VERSION_UNEXIST, DEVICE_VERSION_UNEXIST_CONTENT); throw new AppException(DEVICE_VERSION_UNEXIST, DEVICE_VERSION_UNEXIST_CONTENT);
...@@ -675,8 +669,6 @@ public class DeviceApiController { ...@@ -675,8 +669,6 @@ public class DeviceApiController {
public String checkVersionCopy(HttpServletRequest request, @RequestBody DeviceReq req) { public String checkVersionCopy(HttpServletRequest request, @RequestBody DeviceReq req) {
String serverName = request.getHeader("server-name"); String serverName = request.getHeader("server-name");
Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"), 0); Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"), 0);
// String serverName = request.getServerName();
// int serverPort = request.getServerPort();
log.info("【检查设备最新版本信息】【请求体】--> " + JSONObject.toJSONString(req)); log.info("【检查设备最新版本信息】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp<DeviceResp> rsp = new ApiResp<>(); ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue()); rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
...@@ -727,8 +719,6 @@ public class DeviceApiController { ...@@ -727,8 +719,6 @@ public class DeviceApiController {
public String checkVersionbak(HttpServletRequest request, @RequestBody DeviceReq req) { public String checkVersionbak(HttpServletRequest request, @RequestBody DeviceReq req) {
String serverName = request.getHeader("server-name"); String serverName = request.getHeader("server-name");
Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"), 0); Integer serverPort = DataUtil.converStr2Int(request.getHeader("server-port"), 0);
// String serverName = request.getServerName();
// int serverPort = request.getServerPort();
log.info("【检查设备最新版本信息】【请求体】--> " + JSONObject.toJSONString(req)); log.info("【检查设备最新版本信息】【请求体】--> " + JSONObject.toJSONString(req));
ApiResp<DeviceResp> rsp = new ApiResp<>(); ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue()); rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
...@@ -900,7 +890,6 @@ public class DeviceApiController { ...@@ -900,7 +890,6 @@ public class DeviceApiController {
if (ObjectUtils.isEmpty(platformEntity)) { if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!"); throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!");
} }
// authInfo.setHost(platformEntity.getPlatformSn());
ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString()); ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (ObjectUtils.isEmpty(productEntity)) { if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!"); throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!");
...@@ -912,18 +901,9 @@ public class DeviceApiController { ...@@ -912,18 +901,9 @@ public class DeviceApiController {
header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime()); header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime());
header.put(MessageHeader.MESSAGESIGN, "abcd1234"); header.put(MessageHeader.MESSAGESIGN, "abcd1234");
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), "==", header); TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), "==", header);
// String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
// TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode()).build();
// TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
// header.put(MessageHeader.MESSAGETYPE, Constant.MESSAGETYPE_HEARTBEAT);
// header.put(MessageHeader.DEVICECODE, deviceEntity.getDeviceCode());
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode(), JSON.toJSONString(queueMsg)); messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode(), JSON.toJSONString(queueMsg));
//log.info("sendMesageTopic:{}", JSON.toJSONString(info));
//deviceService.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(req), null, null);
//Thread.sleep(50);
} }
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
} }
} catch (Exception e) { } catch (Exception e) {
log.error("接收数据失败", e); log.error("接收数据失败", e);
...@@ -960,7 +940,6 @@ public class DeviceApiController { ...@@ -960,7 +940,6 @@ public class DeviceApiController {
break; break;
case UPDATE: case UPDATE:
deviceUpdate(req); deviceUpdate(req);
log.info("【设备更新】暂不支持!");
break; break;
case DEL: case DEL:
deviceDel(req); deviceDel(req);
...@@ -1069,6 +1048,8 @@ public class DeviceApiController { ...@@ -1069,6 +1048,8 @@ public class DeviceApiController {
// deviceEntity.setProductId(productEntity.getId()); // deviceEntity.setProductId(productEntity.getId());
//deviceEntity.setProductCode(productEntity.getProductCode()); //deviceEntity.setProductCode(productEntity.getProductCode());
//deviceEntity.setProductName(productEntity.getProductName()); //deviceEntity.setProductName(productEntity.getProductName());
deviceEntity.setResolution(req.getResolution());
deviceEntity.setResolutionValue(req.getResolution());
deviceEntity.setIp(req.getIp()); deviceEntity.setIp(req.getIp());
deviceEntity.setCenternum(req.getCenternum()); deviceEntity.setCenternum(req.getCenternum());
deviceEntity.setPort(req.getPort()); deviceEntity.setPort(req.getPort());
...@@ -1084,6 +1065,8 @@ public class DeviceApiController { ...@@ -1084,6 +1065,8 @@ public class DeviceApiController {
deviceEntity.setResolutionValue(req.getResolution()); deviceEntity.setResolutionValue(req.getResolution());
} }
deviceService.getDeviceDao().update(deviceEntity); deviceService.getDeviceDao().update(deviceEntity);
deviceService.putCache(deviceEntity.getId().toString(), deviceEntity);
deviceService.putCache(deviceEntity.getDeviceCode(), deviceEntity);
} }
private void deviceDel(DeviceReq req) throws AppException { private void deviceDel(DeviceReq req) throws AppException {
...@@ -1185,6 +1168,7 @@ public class DeviceApiController { ...@@ -1185,6 +1168,7 @@ public class DeviceApiController {
String scheme = serverInfo.getScheme(); String scheme = serverInfo.getScheme();
String homeUrl = ""; String homeUrl = "";
//根据站点与资源部署来生成homeurl //根据站点与资源部署来生成homeurl
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery(); DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setSiteId(deviceEntity.getSiteId()); query.setSiteId(deviceEntity.getSiteId());
query.setProductId(productEntity.getId()); query.setProductId(productEntity.getId());
...@@ -1193,10 +1177,10 @@ public class DeviceApiController { ...@@ -1193,10 +1177,10 @@ public class DeviceApiController {
query.setOrderColList(Arrays.asList(new OrderCol("selected", OrderCol.DESCENDING))); query.setOrderColList(Arrays.asList(new OrderCol("selected", OrderCol.DESCENDING)));
DeviceModuleDistributeEntity deviceModuleDistributeEntity = deviceModuleDistributeService.selectOne(query); DeviceModuleDistributeEntity deviceModuleDistributeEntity = deviceModuleDistributeService.selectOne(query);
if (ObjectUtils.isEmpty(deviceModuleDistributeEntity)) { if (ObjectUtils.isEmpty(deviceModuleDistributeEntity)) {
//判断如果宽和高存在 找一个相近的资源。
} else { } else {
//homeDeviceUrl/1/pdj/1920x1080 //homeDeviceUrl/1/pdj/1920x1080
homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", deviceModuleDistributeEntity.getSiteId(), deviceModuleDistributeEntity.getProductCode(), deviceModuleDistributeEntity.getImageResolutionValue()); homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", deviceModuleDistributeEntity.getSiteId(), deviceModuleDistributeEntity.getProductCode(), deviceModuleDistributeEntity.getImageResolutionValue());
//根据部署的资源 生成homeurl //根据部署的资源 生成homeurl
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078"); String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
if (!ObjectUtils.isEmpty(serverName) && Validator.isIpv4(serverName)) { if (!ObjectUtils.isEmpty(serverName) && Validator.isIpv4(serverName)) {
...@@ -1214,32 +1198,6 @@ public class DeviceApiController { ...@@ -1214,32 +1198,6 @@ public class DeviceApiController {
} }
private void buildHomeUrl(DeviceEntity deviceEntity, ProductEntity productEntity, ServerInfo serverInfo, String serverName, Integer serverPort) {
String homeUrl = "";
if (!ObjectUtils.isEmpty(productEntity.getHomeUrl())) {
homeUrl = productEntity.getHomeUrl();
}
if (!ObjectUtils.isEmpty(deviceEntity.getHomeUrl())) {
homeUrl = deviceEntity.getHomeUrl();
}
//log.info("domain:" + GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, ""));
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://127.0.0.1:11078");
if (!ObjectUtils.isEmpty(serverName) && Validator.isIpv4(serverName)) {
String str = UrlBuilder.ofHttp(serverName).setPort(serverPort > 0 ? serverPort : 11078).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
serverInfo.setHomeUrl(decodeStr);
serverInfo.setEventUrl(productEntity.getEventUrl());
} else {
String str = UrlBuilder.of(domain.trim()).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
serverInfo.setHomeUrl(decodeStr);
serverInfo.setEventUrl(productEntity.getEventUrl());
}
}
private void buildDownloadUrl(ProductVersionEntity productVersionEntity, ProductVersionInfo productVersionInfo, String serverName, Integer serverPort) { private void buildDownloadUrl(ProductVersionEntity productVersionEntity, ProductVersionInfo productVersionInfo, String serverName, Integer serverPort) {
String download = ""; String download = "";
if (!ObjectUtils.isEmpty(productVersionEntity.getFilePath())) { if (!ObjectUtils.isEmpty(productVersionEntity.getFilePath())) {
...@@ -1265,8 +1223,6 @@ public class DeviceApiController { ...@@ -1265,8 +1223,6 @@ public class DeviceApiController {
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset()); String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
productVersionInfo.setDownloadUrl(decodeStr); productVersionInfo.setDownloadUrl(decodeStr);
} }
/* productVersionInfo.setDownloadUrl(download);*/
log.info("downurl:" + productVersionInfo.getDownloadUrl()); log.info("downurl:" + productVersionInfo.getDownloadUrl());
} }
...@@ -1481,7 +1437,6 @@ public class DeviceApiController { ...@@ -1481,7 +1437,6 @@ public class DeviceApiController {
updateDevice(req, platformEntity, productEntity, deviceEntity); updateDevice(req, platformEntity, productEntity, deviceEntity);
deviceEntity.setUpdateTime(new Date()); deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(1L); deviceEntity.setUpdateUserId(1L);
//cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE, deviceEntity);
deviceService.update(deviceEntity, null); deviceService.update(deviceEntity, null);
} }
......
...@@ -47,33 +47,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService { ...@@ -47,33 +47,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("设备状态修正任务"); log.info("设备状态修正任务");
/* List<DeviceEntity> waitDeviceInfos = new ArrayList<>();
while (true) {
DeviceEntity deviceEntity = cacheService.blpop(RedisKey.KEY_DEVICE_ONLINE_QUEUE,10, DeviceEntity.class);
if (ObjectUtils.isEmpty(deviceEntity)) {
log.info("deviceEntity:{}",deviceEntity==null);
break;
} else {
waitDeviceInfos.add(deviceEntity);
}
try {
Thread.sleep(0);
} catch (InterruptedException e) {
log.error("线程休眠异常!",e);
}
}
log.info("waitDeviceInfos size:{}", waitDeviceInfos.size());
if (!ObjectUtils.isEmpty(waitDeviceInfos)) {
for (DeviceEntity waitDeviceInfo : waitDeviceInfos) {
cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE,waitDeviceInfo);
}
// deviceService.update(waitDeviceInfos);
}*/
//获取所有在线设备
List<DeviceEntity> deviceList = deviceService.getCacheList().stream().filter(f -> DeviceStatusEnum.在线.getValue() == f.getDeviceStatus()).collect(Collectors.toList()); List<DeviceEntity> deviceList = deviceService.getCacheList().stream().filter(f -> DeviceStatusEnum.在线.getValue() == f.getDeviceStatus()).collect(Collectors.toList());
// List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().deviceStatus(DeviceStatusEnum.在线.getValue()));
//更新离线 //更新离线
List<DeviceEntity> deviceOfflineList = deviceList.parallelStream().map(item -> { List<DeviceEntity> deviceOfflineList = deviceList.parallelStream().map(item -> {
if (ObjectUtils.isEmpty(item.getDeviceCode())) return null; if (ObjectUtils.isEmpty(item.getDeviceCode())) return null;
...@@ -90,8 +64,6 @@ public class DeviceStatTaskImpl implements ITaskExcuteService { ...@@ -90,8 +64,6 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
if (!ObjectUtils.isEmpty(deviceOfflineList)) { if (!ObjectUtils.isEmpty(deviceOfflineList)) {
log.info("修正设备数量:size:{}", deviceOfflineList.size()); log.info("修正设备数量:size:{}", deviceOfflineList.size());
// deviceService.update(deviceOfflineList);
for (DeviceEntity deviceEntity : deviceOfflineList) { for (DeviceEntity deviceEntity : deviceOfflineList) {
cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE, deviceEntity); cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE, deviceEntity);
if (ObjectUtils.isEmpty(deviceEntity.getPlatformId())) continue; if (ObjectUtils.isEmpty(deviceEntity.getPlatformId())) continue;
...@@ -115,7 +87,6 @@ public class DeviceStatTaskImpl implements ITaskExcuteService { ...@@ -115,7 +87,6 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
bizLogPdu.setLogLevel("INFO"); bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date()); bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu); messageProducer.syncBizSend(bizLogPdu);
} }
} }
} }
......
...@@ -32,11 +32,8 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService { ...@@ -32,11 +32,8 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
private DeviceStatService deviceStatService; private DeviceStatService deviceStatService;
@Autowired @Autowired
private DeviceMessageStatService deviceMessageStatService; private DeviceMessageStatService deviceMessageStatService;
@Value("${platform.type:cloud}") @Value("${platform.type:cloud}")
private String platFormType;//版本,默认云服务版本 private String platFormType;//版本,默认云服务版本
@Autowired @Autowired
private SiteService siteService; private SiteService siteService;
@Autowired @Autowired
...@@ -53,7 +50,6 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService { ...@@ -53,7 +50,6 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
for (SitePdu item : siteList) { for (SitePdu item : siteList) {
deviceStatService.deviceStat(item.getId(), null); deviceStatService.deviceStat(item.getId(), null);
deviceMessageStatService.deviceMessageStat(item.getId(), null); deviceMessageStatService.deviceMessageStat(item.getId(), null);
} }
} else if (platFormType.equalsIgnoreCase(PlatformTypeEnum.STANDALONE.getValue())) { } else if (platFormType.equalsIgnoreCase(PlatformTypeEnum.STANDALONE.getValue())) {
List<SiteEntity> siteEntities = siteService.find(new SiteQuery()); List<SiteEntity> siteEntities = siteService.find(new SiteQuery());
...@@ -64,12 +60,10 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService { ...@@ -64,12 +60,10 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
} }
} }
log.info("设备统计任务,生成当天统计数据结束"); log.info("设备统计任务,生成当天统计数据结束");
} }
@Override @Override
public void stopTask(ITask task) throws AppException { public void stopTask(ITask task) throws AppException {
} }
} }
...@@ -60,12 +60,9 @@ public class SmsSendTaskImpl implements ITaskExcuteService { ...@@ -60,12 +60,9 @@ public class SmsSendTaskImpl implements ITaskExcuteService {
sms.setSendStatus(SendStatusEnum.提交.getValue()); sms.setSendStatus(SendStatusEnum.提交.getValue());
sms.setSendTime(new Date()); sms.setSendTime(new Date());
alarmSmsSendService.update(sms,null); alarmSmsSendService.update(sms,null);
}); });
} }
@Override @Override
public void stopTask(ITask task) throws AppException { public void stopTask(ITask task) throws AppException {
......
...@@ -63,4 +63,5 @@ public class DeviceVo extends BaseEntityLong { ...@@ -63,4 +63,5 @@ public class DeviceVo extends BaseEntityLong {
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.mortals.framework.model.Context; ...@@ -5,6 +5,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.busiz.req.DeviceMsgReq; import com.mortals.xhx.busiz.req.DeviceMsgReq;
import com.mortals.xhx.busiz.rsp.ApiResp; import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.busiz.rsp.ServerInfo;
import com.mortals.xhx.common.code.DeviceMethodEnum; import com.mortals.xhx.common.code.DeviceMethodEnum;
import com.mortals.xhx.module.device.dao.DeviceDao; import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
...@@ -27,12 +28,31 @@ import java.util.List; ...@@ -27,12 +28,31 @@ import java.util.List;
*/ */
public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
DeviceDao getDeviceDao();
/**
*
* @param deviceEntity
* @param info
* @param header
* @param message
* @param callback
* @param context
* @return
*/
ApiResp<String> sendDeviceMessage(DeviceEntity deviceEntity, TopicPartitionInfo info, TbQueueMsgHeaders header, String message, TbQueueCallback callback , Context context); ApiResp<String> sendDeviceMessage(DeviceEntity deviceEntity, TopicPartitionInfo info, TbQueueMsgHeaders header, String message, TbQueueCallback callback , Context context);
/**
*
* @param deviceIds
* @param info
* @param header
* @param message
* @param context
* @return
*/
ApiResp<String> sendDeviceMessage(List<Long> deviceIds, TopicPartitionInfo info,TbQueueMsgHeaders header, String message , Context context); ApiResp<String> sendDeviceMessage(List<Long> deviceIds, TopicPartitionInfo info,TbQueueMsgHeaders header, String message , Context context);
/** /**
* 设备激活 * 设备激活
* @param deviceCode * @param deviceCode
...@@ -40,8 +60,6 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -40,8 +60,6 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/ */
void active(String deviceCode,Context context); void active(String deviceCode,Context context);
/** /**
* 设备重启应用 * 设备重启应用
* @param deviceEntity * @param deviceEntity
...@@ -49,7 +67,11 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -49,7 +67,11 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/ */
void restartApp(DeviceEntity deviceEntity,Context context); void restartApp(DeviceEntity deviceEntity,Context context);
/**
*
* @param deviceEntity
* @param context
*/
void batchUpdateHall(DeviceEntity deviceEntity,Context context); void batchUpdateHall(DeviceEntity deviceEntity,Context context);
/** /**
...@@ -58,24 +80,55 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -58,24 +80,55 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
* @param context * @param context
*/ */
void deviceEnabled(Long id,Integer status,Context context); void deviceEnabled(Long id,Integer status,Context context);
void stopOrStartComsumeQueue(Long id,Integer status,Context context);
/**
*
* @param id
* @param status
* @param context
*/
void stopOrStartComsumeQueue(Long id,Integer status,Context context);
/**
*
* @param entity
* @param productEntity
* @param platformEntity
* @param update
* @return
*/
Rest<String> sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update); Rest<String> sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update);
/**
*
* @param key
* @param deviceEntity
*/
void putCache(String key,DeviceEntity deviceEntity); void putCache(String key,DeviceEntity deviceEntity);
DeviceDao getDeviceDao(); /**
*
* @param query
* @param context
* @return
*/
List<DeviceMapEntity> deviceMap(DeviceEntity query, Context context); List<DeviceMapEntity> deviceMap(DeviceEntity query, Context context);
/**
*
* @param list
*/
void downMsg(List<DeviceMsgReq> list); void downMsg(List<DeviceMsgReq> list);
/**
*
* @param deviceEntity
* @param productEntity
* @param serverInfo
* @param serverName
* @param serverPort
*/
void buildHomeUrlBySite(DeviceEntity deviceEntity, ProductEntity productEntity, ServerInfo serverInfo, String serverName, Integer serverPort);
} }
\ No newline at end of file
...@@ -11,7 +11,6 @@ import com.mortals.xhx.module.device.model.DeviceAlarmInfoQuery; ...@@ -11,7 +11,6 @@ import com.mortals.xhx.module.device.model.DeviceAlarmInfoQuery;
import com.mortals.xhx.module.device.model.DeviceMessageStatEntity; import com.mortals.xhx.module.device.model.DeviceMessageStatEntity;
import com.mortals.xhx.module.device.model.DeviceMessageStatQuery; import com.mortals.xhx.module.device.model.DeviceMessageStatQuery;
import com.mortals.xhx.module.device.service.DeviceAlarmInfoService; import com.mortals.xhx.module.device.service.DeviceAlarmInfoService;
import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceMessageStatService; import com.mortals.xhx.module.device.service.DeviceMessageStatService;
import com.mortals.xhx.module.product.model.ProductEntity; import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService; import com.mortals.xhx.module.product.service.ProductService;
...@@ -35,15 +34,11 @@ import java.util.List; ...@@ -35,15 +34,11 @@ import java.util.List;
@Slf4j @Slf4j
public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<DeviceMessageStatDao, DeviceMessageStatEntity, Long> implements DeviceMessageStatService { public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<DeviceMessageStatDao, DeviceMessageStatEntity, Long> implements DeviceMessageStatService {
@Autowired @Autowired
private DeviceAlarmInfoService deviceAlarmInfoService; private DeviceAlarmInfoService deviceAlarmInfoService;
@Autowired @Autowired
private DeviceLogService deviceLogService;
@Autowired
private ProductService productService; private ProductService productService;
@Override @Override
public void deviceMessageStat(Long siteId, Context context) { public void deviceMessageStat(Long siteId, Context context) {
//查询当天统计,如果有 则更新统计结果,否则新增 //查询当天统计,如果有 则更新统计结果,否则新增
...@@ -87,9 +82,7 @@ public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<Device ...@@ -87,9 +82,7 @@ public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<Device
deviceStatEntity.setUpdateTime(new Date()); deviceStatEntity.setUpdateTime(new Date());
this.update(deviceStatEntity); this.update(deviceStatEntity);
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("统计异常", e); log.error("统计异常", e);
throw new AppException("统计异常!"); throw new AppException("统计异常!");
...@@ -106,8 +99,4 @@ public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<Device ...@@ -106,8 +99,4 @@ public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<Device
return deviceStatEntityResult; return deviceStatEntityResult;
} }
} }
\ No newline at end of file
...@@ -50,15 +50,11 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI ...@@ -50,15 +50,11 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI
@Override @Override
public void putCache(String key, DeviceModuleDistributeEntity data) { public void putCache(String key, DeviceModuleDistributeEntity data) {
super.putCache(key, data); super.putCache(key, data);
if (YesNoEnum.YES.getValue() == data.getSelected()) { if (YesNoEnum.YES.getValue() == data.getSelected()) {
updateYesSelectedPath(data, YesNoEnum.YES); updateYesSelectedPath(data, YesNoEnum.YES);
} else { } else {
updateYesSelectedPath(data, YesNoEnum.NO); updateYesSelectedPath(data, YesNoEnum.NO);
} }
//设置yes与no
} }
@Override @Override
...@@ -67,7 +63,6 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI ...@@ -67,7 +63,6 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI
entity.setProductCode(productEntity.getProductCode()); entity.setProductCode(productEntity.getProductCode());
entity.setProductName(productEntity.getProductName()); entity.setProductName(productEntity.getProductName());
entity.setImageResolutionValue(entity.getImageResolution()); entity.setImageResolutionValue(entity.getImageResolution());
super.updateBefore(entity, context); super.updateBefore(entity, context);
} }
...@@ -123,10 +118,7 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI ...@@ -123,10 +118,7 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI
} catch (Exception e) { } catch (Exception e) {
log.error("异常", e); log.error("异常", e);
} }
ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode)); ZipUtil.unzip(targetFilePath, disPath, Charset.forName(fileEncode));
// ZipReader.of(disPath,fileEncode).setMaxSizeDiff(1024 * 1024 * 1024)
//更新 //更新
distributeEntity.setDistributeFilePath(disPath); distributeEntity.setDistributeFilePath(disPath);
distributeEntity.setDistribute(YesNoEnum.YES.getValue()); distributeEntity.setDistribute(YesNoEnum.YES.getValue());
...@@ -138,7 +130,6 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI ...@@ -138,7 +130,6 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI
@Override @Override
public Rest<String> selected(DeviceModuleDistributeEntity distributeEntity, Context context) { public Rest<String> selected(DeviceModuleDistributeEntity distributeEntity, Context context) {
DeviceModuleDistributeEntity deviceModuleDistributeEntity = this.get(distributeEntity.getId(), context); DeviceModuleDistributeEntity deviceModuleDistributeEntity = this.get(distributeEntity.getId(), context);
//选择默认资源默认分辨率 //选择默认资源默认分辨率
//如果选择的资源未部署,则提示先部署后才能选择 //如果选择的资源未部署,则提示先部署后才能选择
if (!ObjectUtils.isEmpty(deviceModuleDistributeEntity) && deviceModuleDistributeEntity.getDistribute() == YesNoEnum.NO.getValue()) { if (!ObjectUtils.isEmpty(deviceModuleDistributeEntity) && deviceModuleDistributeEntity.getDistribute() == YesNoEnum.NO.getValue()) {
...@@ -163,7 +154,6 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI ...@@ -163,7 +154,6 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI
distributeEntity.setSelected(YesNoEnum.NO.getValue()); distributeEntity.setSelected(YesNoEnum.NO.getValue());
distributeEntity.setUpdateTime(new Date()); distributeEntity.setUpdateTime(new Date());
distributeEntity.setUpdateUserId(this.getContextUserId(context)); distributeEntity.setUpdateUserId(this.getContextUserId(context));
this.getDao().update(distributeEntity); this.getDao().update(distributeEntity);
updateYesSelectedPath(deviceModuleDistributeEntity, YesNoEnum.NO); updateYesSelectedPath(deviceModuleDistributeEntity, YesNoEnum.NO);
...@@ -172,30 +162,9 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI ...@@ -172,30 +162,9 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI
distributeEntity.setSelected(YesNoEnum.YES.getValue()); distributeEntity.setSelected(YesNoEnum.YES.getValue());
distributeEntity.setUpdateTime(new Date()); distributeEntity.setUpdateTime(new Date());
distributeEntity.setUpdateUserId(this.getContextUserId(context)); distributeEntity.setUpdateUserId(this.getContextUserId(context));
this.getDao().update(distributeEntity); this.getDao().update(distributeEntity);
updateYesSelectedPath(deviceModuleDistributeEntity, YesNoEnum.YES); updateYesSelectedPath(deviceModuleDistributeEntity, YesNoEnum.YES);
//更新缓存
} }
//查询同类资源,变更为非默认值后 再更新
/* DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setProductId(deviceModuleDistributeEntity.getProductId());
query.setSiteId(deviceModuleDistributeEntity.getSiteId());
List<Long> idList = this.find(query, context).stream().map(i -> i.getId()).collect(Collectors.toList());
DeviceModuleDistributeQuery condition = new DeviceModuleDistributeQuery();
condition.setIdList(idList);
DeviceModuleDistributeEntity entity = new DeviceModuleDistributeEntity();
entity.setSelected(YesNoEnum.NO.getValue());*/
//this.updateBatch(entity, condition, context);
return Rest.ok(); return Rest.ok();
} }
...@@ -207,19 +176,15 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI ...@@ -207,19 +176,15 @@ public class DeviceModuleDistributeServiceImpl extends AbstractCRUDCacheServiceI
@Override @Override
public Rest<String> cloneAppBySite(DeviceModuleDistributeEntity deviceModuleDistributeEntity, Context context) { public Rest<String> cloneAppBySite(DeviceModuleDistributeEntity deviceModuleDistributeEntity, Context context) {
//拷贝应用 //拷贝应用
Long targetSiteId = deviceModuleDistributeEntity.getTargetSiteId(); Long targetSiteId = deviceModuleDistributeEntity.getTargetSiteId();
Long sourceSiteId = deviceModuleDistributeEntity.getSourceSiteId(); Long sourceSiteId = deviceModuleDistributeEntity.getSourceSiteId();
Rest<SitePdu> sitePduRest = siteFeign.info(targetSiteId); Rest<SitePdu> sitePduRest = siteFeign.info(targetSiteId);
if (YesNoEnum.NO.getValue() == sitePduRest.getCode()) { if (YesNoEnum.NO.getValue() == sitePduRest.getCode()) {
throw new AppException("未查询到当前站点!"); throw new AppException("未查询到当前站点!");
} }
SitePdu sitePdu = sitePduRest.getData(); SitePdu sitePdu = sitePduRest.getData();
DeviceModuleDistributeQuery distributeQuery = new DeviceModuleDistributeQuery(); DeviceModuleDistributeQuery distributeQuery = new DeviceModuleDistributeQuery();
distributeQuery.setSiteId(sourceSiteId); distributeQuery.setSiteId(sourceSiteId);
List<DeviceModuleDistributeEntity> deviceModuleDistributeEntities = this.find(distributeQuery); List<DeviceModuleDistributeEntity> deviceModuleDistributeEntities = this.find(distributeQuery);
......
package com.mortals.xhx.module.device.service.impl; package com.mortals.xhx.module.device.service.impl;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.net.URLDecoder;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.net.url.UrlPath; import cn.hutool.core.net.url.UrlPath;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.ErrorLogPdu; import com.mortals.framework.model.ErrorLogPdu;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DateUtils; import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.message.MessageService; import com.mortals.xhx.base.system.message.MessageService;
import com.mortals.xhx.base.system.message.impl.MessageProducer; import com.mortals.xhx.base.system.message.impl.MessageProducer;
import com.mortals.xhx.busiz.req.DeviceMsgReq; import com.mortals.xhx.busiz.req.DeviceMsgReq;
import com.mortals.xhx.busiz.rsp.ApiResp; import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.busiz.rsp.ServerInfo;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.QueueKey; import com.mortals.xhx.common.key.QueueKey;
...@@ -29,11 +35,9 @@ import com.mortals.xhx.feign.IOfficeDeviceFeign; ...@@ -29,11 +35,9 @@ import com.mortals.xhx.feign.IOfficeDeviceFeign;
import com.mortals.xhx.feign.ISampleDeviceFeign; import com.mortals.xhx.feign.ISampleDeviceFeign;
import com.mortals.xhx.feign.site.ISiteFeign; import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.device.dao.DeviceDao; import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.*;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.model.DeviceMapEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceLogService; import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceModuleDistributeService;
import com.mortals.xhx.module.device.service.DeviceService; import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity; import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.model.PlatformQuery; import com.mortals.xhx.module.platform.model.PlatformQuery;
...@@ -62,6 +66,7 @@ import java.util.*; ...@@ -62,6 +66,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_NOTIFY_RESTART_APP; import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_NOTIFY_RESTART_APP;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
import static java.math.BigDecimal.ROUND_HALF_DOWN; import static java.math.BigDecimal.ROUND_HALF_DOWN;
/** /**
...@@ -96,17 +101,14 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -96,17 +101,14 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
private ISampleDeviceFeign sampleDeviceFeign; private ISampleDeviceFeign sampleDeviceFeign;
@Autowired @Autowired
private IFillDeviceFeign fillDeviceFeign; private IFillDeviceFeign fillDeviceFeign;
@Autowired @Autowired
private IInfoPublishDeviceFeign infoPublishDeviceFeign; private IInfoPublishDeviceFeign infoPublishDeviceFeign;
@Value("${thirdPartyPath:/inter/device/deviceIn}")
private String thirdPartyPath;
@Value("${platform.type:cloud}") @Value("${platform.type:cloud}")
private String platFormType;//版本,默认云服务版本 private String platFormType;//版本,默认云服务版本
@Autowired @Autowired
private SiteService siteService; private SiteService siteService;
@Autowired
private DeviceModuleDistributeService deviceModuleDistributeService;
public void refresh() { public void refresh() {
log.info("开始初始化系统参数..."); log.info("开始初始化系统参数...");
...@@ -372,9 +374,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -372,9 +374,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//注册rabbmit相关队列与绑定 //注册rabbmit相关队列与绑定
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + entity.getDeviceCode(), Constant.UPLOAD_TOPIC + entity.getDeviceCode()); messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + entity.getDeviceCode(), Constant.UPLOAD_TOPIC + entity.getDeviceCode());
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + entity.getDeviceCode(), Constant.DOWN_TOPIC + entity.getDeviceCode()); messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + entity.getDeviceCode(), Constant.DOWN_TOPIC + entity.getDeviceCode());
restartMessageListener(Constant.UPLOAD_TOPIC + entity.getDeviceCode()); restartMessageListener(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
//监听上行队列 //监听上行队列
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.UPDATE); sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.UPDATE);
} }
...@@ -384,12 +384,12 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -384,12 +384,12 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override @Override
public Rest<String> sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update) { public Rest<String> sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update) {
//todo 修改为异步发送消息,当前消息存放到redis的队列中 //todo 修改为异步发送消息,当前消息存放到redis的队列中
if(ObjectUtils.isEmpty(productEntity)){ if (ObjectUtils.isEmpty(productEntity)) {
return Rest.fail("产品实体为空!deviceCode:"+entity.getDeviceCode()); return Rest.fail("产品实体为空!deviceCode:" + entity.getDeviceCode());
} }
if(ObjectUtils.isEmpty(platformEntity)){ if (ObjectUtils.isEmpty(platformEntity)) {
return Rest.fail("所属平台实体为空!deviceCode:"+entity.getDeviceCode()); return Rest.fail("所属平台实体为空!deviceCode:" + entity.getDeviceCode());
} }
...@@ -762,8 +762,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -762,8 +762,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
public boolean restartMessageListener(String queueName) { public boolean restartMessageListener(String queueName) {
try { try {
String key = StringUtils.trim(queueName); String key = StringUtils.trim(queueName);
container.addQueueNames(key); List<String> queues = Arrays.asList(container.getQueueNames());
if(!queues.contains(key)){
container.addQueueNames(key);
}
if (container.isRunning()) { if (container.isRunning()) {
container.stop(); container.stop();
container.start(); container.start();
...@@ -776,6 +778,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -776,6 +778,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
return true; return true;
} }
@Override
public void buildHomeUrlBySite(DeviceEntity deviceEntity, ProductEntity productEntity, ServerInfo serverInfo, String serverName, Integer serverPort) {
String scheme = serverInfo.getScheme();
String homeUrl = "";
//根据站点与资源部署来生成homeurl
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setSiteId(deviceEntity.getSiteId());
query.setProductId(productEntity.getId());
query.setDistribute(DistributeEnum..getValue());
query.setSelectedList(Arrays.asList(YesNoEnum.YES.getValue(), YesNoEnum.NO.getValue()));
query.setOrderColList(Arrays.asList(new OrderCol("selected", OrderCol.DESCENDING)));
DeviceModuleDistributeEntity deviceModuleDistributeEntity = deviceModuleDistributeService.selectOne(query);
if (ObjectUtils.isEmpty(deviceModuleDistributeEntity)) {
//判断如果宽和高存在 找一个相近的资源。
} else {
//homeDeviceUrl/1/pdj/1920x1080
homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", deviceModuleDistributeEntity.getSiteId(), deviceModuleDistributeEntity.getProductCode(), deviceModuleDistributeEntity.getImageResolutionValue());
//根据部署的资源 生成homeurl
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
if (!ObjectUtils.isEmpty(serverName) && Validator.isIpv4(serverName)) {
String str = UrlBuilder.of().setScheme(scheme).setHost(serverName).setPort(serverPort > 0 ? serverPort : 11078).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
serverInfo.setHomeUrl(decodeStr);
serverInfo.setEventUrl(productEntity.getEventUrl());
} else {
String str = UrlBuilder.of(domain.trim()).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
serverInfo.setHomeUrl(decodeStr);
serverInfo.setEventUrl(productEntity.getEventUrl());
}
}
}
public static void main(String[] args) { public static void main(String[] args) {
BigDecimal bigDecimal = new BigDecimal("104.22241"); BigDecimal bigDecimal = new BigDecimal("104.22241");
......
...@@ -45,7 +45,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao ...@@ -45,7 +45,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao
@Autowired @Autowired
private DeviceService deviceService; private DeviceService deviceService;
@Autowired @Autowired
private SiteService siteService; private SiteService siteService;
@Value("${platform.type:cloud}") @Value("${platform.type:cloud}")
...@@ -58,7 +57,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao ...@@ -58,7 +57,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao
private AlarmSmsSendService alarmSmsSendService; private AlarmSmsSendService alarmSmsSendService;
@Autowired @Autowired
private DeviceLogService deviceLogService; private DeviceLogService deviceLogService;
@Autowired @Autowired
private ISiteFeign siteFeign; private ISiteFeign siteFeign;
...@@ -98,7 +96,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao ...@@ -98,7 +96,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao
billInfos = this.getBillInfos(query.getSiteId(), query.getCreateTimeStart(), TimeUnitEnum.MONTH.getValue(), page, context); billInfos = this.getBillInfos(query.getSiteId(), query.getCreateTimeStart(), TimeUnitEnum.MONTH.getValue(), page, context);
deviceStatEntityResult.setList(billInfos); deviceStatEntityResult.setList(billInfos);
deviceStatEntityResult.setPageInfo(page); deviceStatEntityResult.setPageInfo(page);
updateDeviceOnlineStats(query, context, page, billInfos); updateDeviceOnlineStats(query, context, page, billInfos);
break; break;
case 今年: case 今年:
...@@ -322,11 +319,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao ...@@ -322,11 +319,6 @@ public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao
int day = dateTime.dayOfMonth(); int day = dateTime.dayOfMonth();
int month = dateTime.month()+1; int month = dateTime.month()+1;
int year = dateTime.year(); int year = dateTime.year();
} }
} }
\ No newline at end of file
...@@ -10,7 +10,6 @@ import com.mortals.framework.model.Context; ...@@ -10,7 +10,6 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.feign.skin.ISkinBaseFeign; import com.mortals.xhx.feign.skin.ISkinBaseFeign;
import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity; import com.mortals.xhx.module.device.model.DeviceModuleDistributeEntity;
...@@ -43,8 +42,6 @@ import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL; ...@@ -43,8 +42,6 @@ import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
@RequestMapping("device/module/distribute") @RequestMapping("device/module/distribute")
public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingController<DeviceModuleDistributeService, DeviceModuleDistributeEntity, Long> { public class DeviceModuleDistributeController extends BaseCRUDJsonBodyMappingController<DeviceModuleDistributeService, DeviceModuleDistributeEntity, Long> {
@Autowired
private ParamService paramService;
@Autowired @Autowired
private ProductService productService; private ProductService productService;
@Autowired @Autowired
......
...@@ -21,7 +21,6 @@ import org.springframework.util.ObjectUtils; ...@@ -21,7 +21,6 @@ import org.springframework.util.ObjectUtils;
public class PlatformServiceImpl extends AbstractCRUDCacheServiceImpl<PlatformDao, PlatformEntity, Long> implements PlatformService { public class PlatformServiceImpl extends AbstractCRUDCacheServiceImpl<PlatformDao, PlatformEntity, Long> implements PlatformService {
@Override @Override
protected void validData(PlatformEntity entity, Context context) throws AppException { protected void validData(PlatformEntity entity, Context context) throws AppException {
if(!ObjectUtils.isEmpty(entity.getSendUrl())){ if(!ObjectUtils.isEmpty(entity.getSendUrl())){
if (!PatternPool.URL_HTTP.matcher(entity.getSendUrl()).find()) { if (!PatternPool.URL_HTTP.matcher(entity.getSendUrl()).find()) {
throw new AppException("URL不合法"); throw new AppException("URL不合法");
......
...@@ -166,10 +166,7 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -166,10 +166,7 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity, context); deviceLogService.save(deviceLogEntity, context);
log.info("【发送中】发送升级版本信息,设备编码:{}", deviceEntity.getDeviceCode()); log.info("【发送中】发送升级版本信息,设备编码:{}", deviceEntity.getDeviceCode());
// deviceService.sendDeviceMessage(deviceEntity, info, header, Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()), callback, null);
}); });
} }
...@@ -179,8 +176,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -179,8 +176,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
download = productVersionEntity.getFilePath(); download = productVersionEntity.getFilePath();
} }
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091"); String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
// String temp= domain+"/"+download;
//productVersionInfo.setDownloadUrl(temp);
productVersionInfo.setDownloadUrl(UrlBuilder.of(domain).addPath(download).toString()); productVersionInfo.setDownloadUrl(UrlBuilder.of(domain).addPath(download).toString());
} }
} }
\ No newline at end of file
...@@ -38,8 +38,6 @@ import java.util.stream.Collectors; ...@@ -38,8 +38,6 @@ import java.util.stream.Collectors;
@Service("siteService") @Service("siteService")
@Slf4j @Slf4j
public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteEntity, Long> implements SiteService { public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteEntity, Long> implements SiteService {
// private List<SiteTreeSelect> siteTreeList;
/** /**
* 根据用户id 暂存对应站点树 默认0为全站点树 * 根据用户id 暂存对应站点树 默认0为全站点树
*/ */
...@@ -209,9 +207,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -209,9 +207,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
}else{ }else{
//云服务版本,获取站点树 //云服务版本,获取站点树
// siteFeign.siteTree() // siteFeign.siteTree()
} }
return siteTreeSelects; return siteTreeSelects;
} }
...@@ -256,36 +252,9 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -256,36 +252,9 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
SiteQuery siteQuery = new SiteQuery(); SiteQuery siteQuery = new SiteQuery();
siteQuery.setAreaCode(matchCode+"%"); siteQuery.setAreaCode(matchCode+"%");
List<SiteEntity> siteEntities = this.find(siteQuery); List<SiteEntity> siteEntities = this.find(siteQuery);
//
// List<SiteEntity> siteEntities = this.find(new SiteQuery()).stream().peek(site -> changeUrlPath(site)).collect(Collectors.toList());
// ;
// for (SiteEntity siteEntity : siteEntities) {
// boolean bool = getSite(siteCache.getAreaCode(), siteEntity.getAreaCode(), siteList, siteEntity);
// if (bool) continue;
//
// }
return siteEntities; return siteEntities;
} }
private boolean getSite(String rootAreaCode, String areaCode, List<SiteEntity> siteList, SiteEntity siteEntity) {
// AreaEntity areaTemp = areaService.getExtCache(siteEntity.getAreaCode());
if (rootAreaCode.equals(areaCode)) {
siteList.add(siteEntity);
//log.info("add site:{}", siteEntity.getSiteCode());
return true;
} else {
AreaEntity areaTemp = areaService.getExtCache(areaCode);
if (!ObjectUtils.isEmpty(areaTemp) && !ObjectUtils.isEmpty(areaTemp.getPid())) {
//根据子节点查找父节点
AreaEntity areaEntity = areaService.selectOne(new AreaQuery().iid(areaTemp.getPid()));
if (!ObjectUtils.isEmpty(areaEntity)) {
return getSite(rootAreaCode, areaEntity.getAreaCode(), siteList, siteEntity);
}
}
return false;
}
}
@Override @Override
public void setSiteTree(List<SiteTreeSelect> list, Context context) { public void setSiteTree(List<SiteTreeSelect> list, Context context) {
siteTreeMap.put(context.getUser().getId(), list); siteTreeMap.put(context.getUser().getId(), list);
......
...@@ -337,9 +337,7 @@ public class SitestatServiceImpl extends AbstractCRUDCacheServiceImpl<SitestatDa ...@@ -337,9 +337,7 @@ public class SitestatServiceImpl extends AbstractCRUDCacheServiceImpl<SitestatDa
SiteTreeSelect siteTreeSelect = JSON.parseObject(item.toString(), SiteTreeSelect.class); SiteTreeSelect siteTreeSelect = JSON.parseObject(item.toString(), SiteTreeSelect.class);
return siteTreeSelect; return siteTreeSelect;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
System.out.println(JSON.toJSONString(collect)); System.out.println(JSON.toJSONString(collect));
} }
} }
\ No newline at end of file
...@@ -65,16 +65,13 @@ public class DeviceDownMsgThread extends AbstractThread { ...@@ -65,16 +65,13 @@ public class DeviceDownMsgThread extends AbstractThread {
while (true) { while (true) {
DeviceMsgReq deviceMsgReq = cacheService.lpop(KEY_DEVICE_DOWN_MSG_QUEUE, DeviceMsgReq.class); DeviceMsgReq deviceMsgReq = cacheService.lpop(KEY_DEVICE_DOWN_MSG_QUEUE, DeviceMsgReq.class);
if (ObjectUtils.isEmpty(deviceMsgReq)) { if (ObjectUtils.isEmpty(deviceMsgReq)) {
// log.info("deviceMsgReq:{}", deviceMsgReq == null);
break; break;
} }
deviceMsgReqs.add(deviceMsgReq); deviceMsgReqs.add(deviceMsgReq);
} }
if (!ObjectUtils.isEmpty(deviceMsgReqs)) { if (!ObjectUtils.isEmpty(deviceMsgReqs)) {
log.info("消息下发数量:{}", deviceMsgReqs.size()); log.info("消息下发数量:{}", deviceMsgReqs.size());
ArrayList<DeviceLogEntity> deviceLogList = new ArrayList<>(); ArrayList<DeviceLogEntity> deviceLogList = new ArrayList<>();
for (DeviceMsgReq item : deviceMsgReqs) { for (DeviceMsgReq item : deviceMsgReqs) {
//根据设备编码查询设备 //根据设备编码查询设备
DeviceEntity deviceEntity = null; DeviceEntity deviceEntity = null;
...@@ -107,7 +104,6 @@ public class DeviceDownMsgThread extends AbstractThread { ...@@ -107,7 +104,6 @@ public class DeviceDownMsgThread extends AbstractThread {
deviceLogEntity.setCreateUserId(1L); deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
deviceLogList.add(deviceLogEntity); deviceLogList.add(deviceLogEntity);
// deviceLogService.save(deviceLogEntity, null);
} else { } else {
log.info("未找到设备,deviceCode:{}", item.getDeviceCode()); log.info("未找到设备,deviceCode:{}", item.getDeviceCode());
} }
......
...@@ -34,8 +34,6 @@ public class DeviceUpdateComsumerThread extends AbstractThread { ...@@ -34,8 +34,6 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
private ICacheService cacheService; private ICacheService cacheService;
@Autowired @Autowired
private DeviceService deviceService; private DeviceService deviceService;
//
@Override @Override
protected int getSleepTime() { protected int getSleepTime() {
return 60*1000; return 60*1000;
...@@ -48,7 +46,6 @@ public class DeviceUpdateComsumerThread extends AbstractThread { ...@@ -48,7 +46,6 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
while (true) { while (true) {
DeviceEntity deviceEntity = cacheService.lpop(RedisKey.KEY_DEVICE_UPDATE_QUEUE, DeviceEntity.class); DeviceEntity deviceEntity = cacheService.lpop(RedisKey.KEY_DEVICE_UPDATE_QUEUE, DeviceEntity.class);
if (ObjectUtils.isEmpty(deviceEntity)) { if (ObjectUtils.isEmpty(deviceEntity)) {
// log.info("deviceEntity:{}", deviceEntity == null);
break; break;
} }
waitUpdateDeviceList.add(deviceEntity); waitUpdateDeviceList.add(deviceEntity);
...@@ -85,15 +82,7 @@ public class DeviceUpdateComsumerThread extends AbstractThread { ...@@ -85,15 +82,7 @@ public class DeviceUpdateComsumerThread extends AbstractThread {
} }
} }
}); });
/*
for (DeviceEntity deviceEntity : waitUpdateDeviceList) {
deviceService.update(deviceEntity);
}
*/
} }
} }
......
...@@ -49,12 +49,11 @@ public class SendThirdPartyThread extends AbstractThread { ...@@ -49,12 +49,11 @@ public class SendThirdPartyThread extends AbstractThread {
@Override @Override
protected void process() { protected void process() {
// log.info("SendThirdPartyThread process"); // log.info("SendThirdPartyThread process");
List<DeviceReq> deviceMsgReqs = new ArrayList<>(); List<DeviceReq> deviceMsgReqs = new ArrayList<>();
while (true) { while (true) {
DeviceReq deviceReq = cacheService.lpop(KEY_DEVICE_THIRDPARTY_QUEUE, DeviceReq.class); DeviceReq deviceReq = cacheService.lpop(KEY_DEVICE_THIRDPARTY_QUEUE, DeviceReq.class);
if (ObjectUtils.isEmpty(deviceReq)) { if (ObjectUtils.isEmpty(deviceReq)) {
// log.info("deviceMsgReq:{}", deviceMsgReq == null);
break; break;
} }
deviceMsgReqs.add(deviceReq); deviceMsgReqs.add(deviceReq);
......
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