Commit 58bd1241 authored by 赵啸非's avatar 赵啸非

部署资源添加分辨率字典

parent 10dbad6d
......@@ -82,3 +82,5 @@ ALTER TABLE mortals_xhx_idgenerator ADD COLUMN `createTime` datetime(0) NULL DE
ALTER TABLE mortals_xhx_device ADD COLUMN `resolution` varchar(64) DEFAULT '' COMMENT '设备分辨率' AFTER deviceInFloor;
ALTER TABLE mortals_xhx_device ADD COLUMN `resolutionValue` varchar(64) DEFAULT '' COMMENT '设备分辨率' AFTER resolution;
UPDATE mortals_xhx_device_module_distribute SET imageResolution =imageResolutionValue
\ No newline at end of file
......@@ -159,7 +159,7 @@ public class DeviceApiController {
if (ObjectUtils.isEmpty(scheme)) {
scheme = "http";
}
log.info("scheme:{},request uri:{},request url:{},serverName:{},serverPort:{},xforwardedfor:{},realIP:{}", scheme, request.getRequestURI(), request.getRequestURL(), serverName, serverPort, xforwardedfor,realIP);
log.info("scheme:{},request uri:{},request url:{},serverName:{},serverPort:{},xforwardedfor:{},realIP:{}", scheme, request.getRequestURI(), request.getRequestURL(), serverName, serverPort, xforwardedfor, realIP);
ApiResp<DeviceResp> rsp = new ApiResp<>();
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
DeviceResp deviceResp = new DeviceResp();
......@@ -215,7 +215,33 @@ public class DeviceApiController {
serverInfo.setScheme(scheme);
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
//buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort);
//判断当前设备是否设置了分辨率 如果设置了 查询当前设备的资源路径是否存在 如果存在
String resolution = deviceEntity.getResolution();
if (!ObjectUtils.isEmpty(resolution)) {
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setProductId(productEntity.getId());
query.setImageResolution(resolution);
query.setDistribute(DistributeEnum..getValue());
DeviceModuleDistributeEntity distribute = deviceModuleDistributeService.selectOne(query);
//homeDeviceUrl/1/pdj/1920x1080
String homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", distribute.getSiteId(), distribute.getProductCode(), distribute.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());
}
}else{
buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort);
}
//对外地址,访问ip+端口 端口号由platformEntity.getSendUrl()获取
URI uri = new URI(platformEntity.getSendUrl());
int port = uri.getPort();
......@@ -248,15 +274,15 @@ public class DeviceApiController {
deviceEntity.setDeviceStatus(DeviceStatusEnum.在线.getValue());
deviceEntity.setDeviceVersion(req.getDeviceVersion() == null ? "" : req.getDeviceVersion());
if(deviceEntity.getDeviceStatus()== DeviceStatusEnum.离线.getValue()){
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.离线.getValue()) {
DeviceEntity condition = new DeviceEntity();
condition.setId(deviceEntity.getId());
condition.setOnlineTime(new Date());
condition.setDeviceStatus(DeviceStatusEnum.在线.getValue());
cacheService.lpush(RedisKey.KEY_DEVICE_THIRDPARTY_QUEUE, condition);
cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE,condition);
cacheService.lpush(RedisKey.KEY_DEVICE_UPDATE_QUEUE, condition);
}
// deviceService.getDeviceDao().update(deviceEntity);
// deviceService.getDeviceDao().update(deviceEntity);
rsp.setData(deviceResp);
/* SendThirdPartyTask sendThirdPartyTask = new SendThirdPartyTask(deviceEntity, productEntity, platformEntity, deviceService);
sendTaskThreadPool.execute(sendThirdPartyTask);*/
......@@ -477,7 +503,31 @@ public class DeviceApiController {
ServerInfo serverInfo = new ServerInfo();
serverInfo.setScheme(scheme);
// buildHomeUrl(deviceEntity, productEntity, serverInfo, serverName, serverPort);
buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort);
String resolution = deviceEntity.getResolution();
if (!ObjectUtils.isEmpty(resolution)) {
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setProductId(productEntity.getId());
query.setImageResolution(resolution);
query.setDistribute(DistributeEnum..getValue());
DeviceModuleDistributeEntity distribute = deviceModuleDistributeService.selectOne(query);
//homeDeviceUrl/1/pdj/1920x1080
String homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", distribute.getSiteId(), distribute.getProductCode(), distribute.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());
}
}else{
buildHomeUrlBySite(deviceEntity, productEntity, serverInfo, serverName, serverPort);
}
URI uri = new URI(platformEntity.getSendUrl());
int port = uri.getPort();
......@@ -675,15 +725,7 @@ public class DeviceApiController {
rsp.setMsg(ApiRespCodeEnum.SUCCESS.getLabel());
rsp.setCode(ApiRespCodeEnum.SUCCESS.getValue());
try {
/* list.stream()
.sorted(Comparator.comparing(DeviceMsgReq::getTimestamp))
.forEach(item -> {
cacheService.lpush(KEY_DEVICE_DOWN_MSG_QUEUE, item);
});*/
/* DownMsgTask downMsgTask = new DownMsgTask(list, platformService, productService, deviceService, deviceLogService, messageProducer);
sendTaskThreadPool.execute(downMsgTask);*/
deviceService.downMsg(list);
} catch (AppException e) {
log.error("接收数据失败", e);
rsp.setCode(e.getCode());
......@@ -894,9 +936,9 @@ public class DeviceApiController {
deviceEntity.setCreateUserId(1L);
deviceEntity.setCreateTime(new Date());
deviceEntity.setSwitchSend(false);
if(!ObjectUtils.isEmpty(req.getResolution())&&!ObjectUtils.isEmpty(req.getResolutionValue())){
if (!ObjectUtils.isEmpty(req.getResolution())) {
deviceEntity.setResolution(req.getResolution());
deviceEntity.setResolutionValue(req.getResolutionValue());
deviceEntity.setResolutionValue(req.getResolution());
}
deviceService.save(deviceEntity);
......@@ -942,9 +984,9 @@ public class DeviceApiController {
deviceEntity.setLeadingOfficial(req.getLeadingOfficial());
deviceEntity.setDeviceInFloor(req.getDeviceInFloor());
deviceEntity.setDeviceInBuilding(req.getDeviceInBuilding());
if(!ObjectUtils.isEmpty(req.getResolution())&&!ObjectUtils.isEmpty(req.getResolutionValue())){
if (!ObjectUtils.isEmpty(req.getResolution())) {
deviceEntity.setResolution(req.getResolution());
deviceEntity.setResolutionValue(req.getResolutionValue());
deviceEntity.setResolutionValue(req.getResolution());
}
deviceService.update(deviceEntity);
}
......@@ -1051,40 +1093,11 @@ public class DeviceApiController {
DeviceModuleDistributeQuery query = new DeviceModuleDistributeQuery();
query.setSiteId(deviceEntity.getSiteId());
query.setProductId(productEntity.getId());
//query.setSelected(YesNoEnum.YES.getValue());
query.setSelectedList(Arrays.asList(YesNoEnum.YES.getValue(),YesNoEnum.NO.getValue()));
query.setOrderColList(Arrays.asList(new OrderCol("selected",OrderCol.DESCENDING)));
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)) {
/* //没有默认选择的资源,实施部署更新一个默认选择 todo
query = new DeviceModuleDistributeQuery();
query.setSiteId(deviceEntity.getSiteId());
query.setProductId(productEntity.getId());
query.setSelectedList(Arrays.asList(1,0));
// query.setSelected(YesNoEnum.NO.getValue());
deviceModuleDistributeEntity = deviceModuleDistributeService.selectOne(query);
if (!ObjectUtils.isEmpty(deviceModuleDistributeEntity)) {
//deviceModuleDistributeService.active(deviceModuleDistributeEntity, null);
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 str = UrlBuilder.of().setScheme("http").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());
}
} else {
log.info("资源为空!产品名称:{}",deviceEntity.getProductName());
}*/
} else {
//homeDeviceUrl/1/pdj/1920x1080
homeUrl = String.format("/homeDeviceUrl/%s/%s/%s", deviceModuleDistributeEntity.getSiteId(), deviceModuleDistributeEntity.getProductCode(), deviceModuleDistributeEntity.getImageResolutionValue());
......@@ -1093,7 +1106,6 @@ public class DeviceApiController {
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 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());
......@@ -1159,7 +1171,7 @@ public class DeviceApiController {
productVersionInfo.setDownloadUrl(decodeStr);
}
/* productVersionInfo.setDownloadUrl(download);*/
/* productVersionInfo.setDownloadUrl(download);*/
log.info("downurl:" + productVersionInfo.getDownloadUrl());
}
......
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