Commit 9cdf9f97 authored by 赵啸非's avatar 赵啸非

添加批量激活设备

parent 8fed0612
......@@ -131,10 +131,6 @@ export default {
},
},
methods: {
refresh(data) {
this.fileList=data;
},
// 上传前校检格式和大小
handleBeforeUpload(file) {
// 校检文件类型
......
......@@ -32,10 +32,7 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.common.utils.DownMsgTask;
import com.mortals.xhx.common.utils.EncryptUtil;
import com.mortals.xhx.common.utils.SendTaskThreadPool;
import com.mortals.xhx.common.utils.*;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
......@@ -158,7 +155,7 @@ public class DeviceApiController {
authInfo.setMessageTtl(messageTtl);
authInfo.setVirtualHost(virtualHost);
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
ProductEntity productEntity = productService.getCache(deviceEntity.getProductId().toString());
if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException(PRODUCT_IS_EMPTY, PRODUCT_IS_EMPTY_CONTENT);
}
......@@ -167,7 +164,7 @@ public class DeviceApiController {
throw new AppException(PLATFORM_UNEXIST, PLATFORM_UNEXIST_CONTENT);
}
PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId());
PlatformEntity platformEntity = platformService.getCache(productEntity.getPlatformId().toString());
if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException(PLATFORM_IS_EMPTY, PLATFORM_IS_EMPTY_CONTENT);
}
......@@ -176,21 +173,16 @@ public class DeviceApiController {
throw new AppException(DEVICE_UNACTIVE, DEVICE_UNACTIVE_CONTENT);
}
// authInfo.setExchangeName(platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode());
//单一交换机
authInfo.setExchangeName(QueueKey.DEFAULT_EXCHANGE);
authInfo.setUploadTopicFilter(Constant.UPLOAD_TOPIC + deviceEntity.getDeviceCode());
authInfo.setDownTopicFilter(Constant.DOWN_TOPIC + deviceEntity.getDeviceCode());
RegisterResp registerResp = new RegisterResp();
registerResp.setRabbmitInfo(authInfo);
ServerInfo serverInfo = new ServerInfo();
//判断设备是否设置了url 如果设置了,则用设备的 否则用产品的
buildHomeUrl(deviceEntity, productEntity, serverInfo);
//对外
// serverInfo.setServerUrl(platformEntity.getSendUrl());
String phpUrl=GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://10.12.185.213:8090");
serverInfo.setServerUrl(phpUrl);
......@@ -214,8 +206,8 @@ public class DeviceApiController {
deviceEntity.setDeviceVersion(req.getDeviceVersion() == null ? "" : req.getDeviceVersion());
deviceService.getDeviceDao().update(deviceEntity);
rsp.setData(deviceResp);
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ONLINE);
SendThirdPartyTask sendThirdPartyTask = new SendThirdPartyTask(deviceEntity, productEntity, platformEntity,deviceService);
sendTaskThreadPool.execute(sendThirdPartyTask);
} catch (AppException e) {
log.error("接收数据失败", e);
rsp.setCode(e.getCode());
......@@ -362,7 +354,7 @@ public class DeviceApiController {
if (ObjectUtils.isEmpty(req.getSiteId())) {
throw new AppException(SITEID_IS_EMPTY, SITEID_IS_EMPTY_CONTENT);
}
ProductEntity productEntity = productService.get(req.getProductId());
ProductEntity productEntity = productService.getCache(req.getProductId().toString());
if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException(PRODUCT_IS_EMPTY, PRODUCT_IS_EMPTY_CONTENT);
}
......@@ -371,7 +363,7 @@ public class DeviceApiController {
throw new AppException(PLATFORM_UNEXIST, PLATFORM_UNEXIST_CONTENT);
}
PlatformEntity platformEntity = platformService.get(productEntity.getPlatformId());
PlatformEntity platformEntity = platformService.getCache(productEntity.getPlatformId().toString());
if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException(PLATFORM_IS_EMPTY, PLATFORM_IS_EMPTY_CONTENT);
}
......@@ -907,15 +899,14 @@ public class DeviceApiController {
if (!ObjectUtils.isEmpty(deviceEntity.getHomeUrl())) {
homeUrl = deviceEntity.getHomeUrl();
}
log.info("domain:" + GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, ""));
//log.info("domain:" + GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, ""));
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.3.24:11078");
//domain+homeUrl;
String str = UrlBuilder.of(domain.trim()).addPath(homeUrl).build();
String decodeStr = URLDecoder.decode(str, Charset.defaultCharset());
serverInfo.setHomeUrl(decodeStr);
//serverInfo.setHomeUrl(domain + "/" + homeUrl);
log.info("homeurl:" + serverInfo.getHomeUrl());
//log.info("homeurl:" + serverInfo.getHomeUrl());
serverInfo.setEventUrl(productEntity.getEventUrl());
}
......@@ -925,7 +916,6 @@ public class DeviceApiController {
download = productVersionEntity.getFilePath();
}
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
//String temp = domain + "/" + download;
productVersionInfo.setDownloadUrl(UrlBuilder.of(domain).addPath(download).build());
//productVersionInfo.setDownloadUrl(temp);
......
package com.mortals.xhx.common.utils;
import com.mortals.xhx.common.code.DeviceMethodEnum;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.product.model.ProductEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* 发送任务
*
* @author: zxfei
* @date: 2022/4/28 10:56
* @description:
**/
@Slf4j
@AllArgsConstructor
public class SendThirdPartyTask implements Runnable {
private DeviceEntity deviceEntity;
private ProductEntity productEntity;
private PlatformEntity platformEntity;
private DeviceService deviceService;
@Override
public void run() {
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ONLINE);
}
}
package com.mortals.xhx.module.platform.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
/**
* PlatformService
......@@ -9,6 +10,6 @@ import com.mortals.xhx.module.platform.model.PlatformEntity;
* @author zxfei
* @date 2022-06-27
*/
public interface PlatformService extends ICRUDService<PlatformEntity,Long>{
public interface PlatformService extends ICRUDCacheService<PlatformEntity,Long>{
}
\ No newline at end of file
package com.mortals.xhx.module.product.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.module.product.model.ProductEntity;
/**
* ProductService
......@@ -10,7 +11,7 @@ import com.mortals.xhx.module.product.model.ProductEntity;
* @author zxfei
* @date 2022-06-27
*/
public interface ProductService extends ICRUDService<ProductEntity,Long>{
public interface ProductService extends ICRUDCacheService<ProductEntity,Long>{
void upGrade(Long productId, Context context);
......
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