Commit aa4371b4 authored by 赵啸非's avatar 赵啸非

修改应用克隆

parent ef9ea330
...@@ -176,7 +176,8 @@ public class DeviceReq implements Serializable { ...@@ -176,7 +176,8 @@ public class DeviceReq implements Serializable {
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(1080, 1920, 2));
System.out.println(NumberUtil.div(1280, 1280, 2)); System.out.println(NumberUtil.div(800, 1280, 2));
System.out.println(NumberUtil.div(1024, 600, 2));
} }
......
...@@ -6,7 +6,6 @@ import cn.hutool.core.lang.Validator; ...@@ -6,7 +6,6 @@ import cn.hutool.core.lang.Validator;
import cn.hutool.core.net.URLDecoder; import cn.hutool.core.net.URLDecoder;
import cn.hutool.core.net.url.UrlBuilder; import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.extra.servlet.ServletUtil;
...@@ -433,6 +432,7 @@ public class DeviceApiController { ...@@ -433,6 +432,7 @@ public class DeviceApiController {
Double width = req.getWidth(); Double width = req.getWidth();
Double height = req.getHeight(); Double height = req.getHeight();
try { try {
if (ObjectUtils.isEmpty(req.getDeviceCode())) { if (ObjectUtils.isEmpty(req.getDeviceCode())) {
throw new AppException(DEVICE_CODE_IS_EMPTY, DEVICE_CODE_IS_EMPTY_CONTENT); throw new AppException(DEVICE_CODE_IS_EMPTY, DEVICE_CODE_IS_EMPTY_CONTENT);
...@@ -457,20 +457,21 @@ public class DeviceApiController { ...@@ -457,20 +457,21 @@ public class DeviceApiController {
DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode()); DeviceEntity deviceEntity = deviceService.getExtCache(req.getDeviceCode());
if (!ObjectUtils.isEmpty(width) && !ObjectUtils.isEmpty(height)) {
/* if (!ObjectUtils.isEmpty(width) && !ObjectUtils.isEmpty(height)) {
//根据分辨率 自适应设置分辨率 //根据分辨率 自适应设置分辨率
double div = NumberUtil.div(width, height, 2); double div = NumberUtil.div(width, height, 2);
if (div >= 1.7 && div <= 1.8) { if (div >= 1.7 && div <= 1.8) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1920X1080.getDesc()); deviceEntity.setResolutionValue(ImageReEnum.RE_1920X1080.getDesc());
System.out.println("1.7 < div < 1.8"); //System.out.println("1.7 < div < 1.8");
} else if (div >= 0.4 && div <= 0.7) { } else if (div >= 0.4 && div <= 0.7) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1080X1920.getDesc()); deviceEntity.setResolutionValue(ImageReEnum.RE_1080X1920.getDesc());
System.out.println("1.7 < div < 1.8"); //System.out.println("1.7 < div < 1.8");
} else if (div >= 0.9 && div <= 1.1) { } else if (div >= 0.9 && div <= 1.1) {
deviceEntity.setResolutionValue(ImageReEnum.RE_1280X1280.getDesc()); deviceEntity.setResolutionValue(ImageReEnum.RE_1280X1280.getDesc());
System.out.println("div >= 0.9 && div <= 1.1"); //System.out.println("div >= 0.9 && div <= 1.1");
} }
} }*/
if (ObjectUtils.isEmpty(deviceEntity)) { if (ObjectUtils.isEmpty(deviceEntity)) {
//初始化新增基础设备,后续在线完善信息后再行注册添加 //初始化新增基础设备,后续在线完善信息后再行注册添加
...@@ -485,17 +486,17 @@ public class DeviceApiController { ...@@ -485,17 +486,17 @@ 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);
} }
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);
} }
if (!ObjectUtils.isEmpty(deviceEntity) && !ObjectUtils.isEmpty(width) && !ObjectUtils.isEmpty(height)) {
deviceEntity.setWidth(width);
deviceEntity.setHeight(height);
}
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 +504,14 @@ public class DeviceApiController { ...@@ -503,18 +504,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 +540,6 @@ public class DeviceApiController { ...@@ -543,25 +540,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 +554,6 @@ public class DeviceApiController { ...@@ -576,9 +554,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();
...@@ -621,8 +596,6 @@ public class DeviceApiController { ...@@ -621,8 +596,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 +608,6 @@ public class DeviceApiController { ...@@ -635,10 +608,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 +644,6 @@ public class DeviceApiController { ...@@ -675,8 +644,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 +694,6 @@ public class DeviceApiController { ...@@ -727,8 +694,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 +865,6 @@ public class DeviceApiController { ...@@ -900,7 +865,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 +876,9 @@ public class DeviceApiController { ...@@ -912,18 +876,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);
...@@ -1069,6 +1024,8 @@ public class DeviceApiController { ...@@ -1069,6 +1024,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());
...@@ -1193,6 +1150,10 @@ public class DeviceApiController { ...@@ -1193,6 +1150,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());
...@@ -1214,32 +1175,6 @@ public class DeviceApiController { ...@@ -1214,32 +1175,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())) {
...@@ -1266,7 +1201,6 @@ public class DeviceApiController { ...@@ -1266,7 +1201,6 @@ public class DeviceApiController {
productVersionInfo.setDownloadUrl(decodeStr); productVersionInfo.setDownloadUrl(decodeStr);
} }
/* productVersionInfo.setDownloadUrl(download);*/
log.info("downurl:" + productVersionInfo.getDownloadUrl()); log.info("downurl:" + productVersionInfo.getDownloadUrl());
} }
......
...@@ -51,6 +51,16 @@ public class DeviceVo extends BaseEntityLong { ...@@ -51,6 +51,16 @@ public class DeviceVo extends BaseEntityLong {
private List <Integer> deviceStatusList; private List <Integer> deviceStatusList;
/**
* 设备宽度
*/
private Double width;
/**
* 设备高度
*/
private Double height;
......
...@@ -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
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;
/** /**
...@@ -107,6 +112,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -107,6 +112,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
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 +379,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -372,9 +379,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 +389,12 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -384,12 +389,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());
} }
...@@ -763,7 +768,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -763,7 +768,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
try { try {
String key = StringUtils.trim(queueName); String key = StringUtils.trim(queueName);
container.addQueueNames(key); container.addQueueNames(key);
if (container.isRunning()) { if (container.isRunning()) {
container.stop(); container.stop();
container.start(); container.start();
...@@ -776,6 +780,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -776,6 +780,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");
......
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