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

修改应用克隆

parent ef9ea330
......@@ -176,7 +176,8 @@ public class DeviceReq implements Serializable {
System.out.println(NumberUtil.div(1920, 1080, 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));
}
......
......@@ -51,6 +51,16 @@ public class DeviceVo extends BaseEntityLong {
private List <Integer> deviceStatusList;
/**
* 设备宽度
*/
private Double width;
/**
* 设备高度
*/
private Double height;
......
......@@ -5,6 +5,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.busiz.req.DeviceMsgReq;
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.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity;
......@@ -27,12 +28,31 @@ import java.util.List;
*/
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);
/**
*
* @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);
/**
* 设备激活
* @param deviceCode
......@@ -40,8 +60,6 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/
void active(String deviceCode,Context context);
/**
* 设备重启应用
* @param deviceEntity
......@@ -49,7 +67,11 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/
void restartApp(DeviceEntity deviceEntity,Context context);
/**
*
* @param deviceEntity
* @param context
*/
void batchUpdateHall(DeviceEntity deviceEntity,Context context);
/**
......@@ -58,24 +80,55 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
* @param 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);
/**
*
* @param key
* @param deviceEntity
*/
void putCache(String key,DeviceEntity deviceEntity);
DeviceDao getDeviceDao();
/**
*
* @param query
* @param context
* @return
*/
List<DeviceMapEntity> deviceMap(DeviceEntity query, Context context);
/**
*
* @param 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;
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.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.ErrorLogPdu;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.message.MessageService;
import com.mortals.xhx.base.system.message.impl.MessageProducer;
import com.mortals.xhx.busiz.req.DeviceMsgReq;
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.key.Constant;
import com.mortals.xhx.common.key.QueueKey;
......@@ -29,11 +35,9 @@ import com.mortals.xhx.feign.IOfficeDeviceFeign;
import com.mortals.xhx.feign.ISampleDeviceFeign;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity;
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.model.*;
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.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.model.PlatformQuery;
......@@ -62,6 +66,7 @@ import java.util.*;
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.PARAM_SERVER_HTTP_URL;
import static java.math.BigDecimal.ROUND_HALF_DOWN;
/**
......@@ -107,6 +112,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
private String platFormType;//版本,默认云服务版本
@Autowired
private SiteService siteService;
@Autowired
private DeviceModuleDistributeService deviceModuleDistributeService;
public void refresh() {
log.info("开始初始化系统参数...");
......@@ -372,9 +379,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//注册rabbmit相关队列与绑定
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());
restartMessageListener(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
//监听上行队列
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.UPDATE);
}
......@@ -384,12 +389,12 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
public Rest<String> sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceMethodEnum update) {
//todo 修改为异步发送消息,当前消息存放到redis的队列中
if(ObjectUtils.isEmpty(productEntity)){
return Rest.fail("产品实体为空!deviceCode:"+entity.getDeviceCode());
if (ObjectUtils.isEmpty(productEntity)) {
return Rest.fail("产品实体为空!deviceCode:" + entity.getDeviceCode());
}
if(ObjectUtils.isEmpty(platformEntity)){
return Rest.fail("所属平台实体为空!deviceCode:"+entity.getDeviceCode());
if (ObjectUtils.isEmpty(platformEntity)) {
return Rest.fail("所属平台实体为空!deviceCode:" + entity.getDeviceCode());
}
......@@ -763,7 +768,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
try {
String key = StringUtils.trim(queueName);
container.addQueueNames(key);
if (container.isRunning()) {
container.stop();
container.start();
......@@ -776,6 +780,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
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) {
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