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

添加批量激活设备

parent cf881f2c
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
@size-change="handleSizeChange" @size-change="handleSizeChange"
:current-page="currPage" :current-page="currPage"
:page-size="currSize" :page-size="currSize"
:page-sizes="[10, 20, 50, 100, 200]" :page-sizes="[10, 20, 50, 100, 200, 500]"
layout="sizes, total, prev, pager, next, jumper" layout="sizes, total, prev, pager, next, jumper"
:total="total" :total="total"
> >
......
...@@ -47,7 +47,15 @@ ...@@ -47,7 +47,15 @@
icon="el-icon-tickets" icon="el-icon-tickets"
size="mini" size="mini"
@click="batchActiveDevice" @click="batchActiveDevice"
>批量激活设备</el-button >批量激活</el-button
>
<el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="batchRestartApp"
>批量重启</el-button
> >
<el-tag <el-tag
slot="table-head-row2-left" slot="table-head-row2-left"
...@@ -357,6 +365,36 @@ export default { ...@@ -357,6 +365,36 @@ export default {
}); });
}, },
batchRestartApp(row) {
this.$post("/device/restartApp", {
idList: this.selection,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("批量重启设备应用成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
restartApp(row) {
this.$post("/device/restartApp", {
idList: [row.id],
})
.then((res) => {
if (res.code == 1) {
this.$message.success("重启设备应用成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
updateSite(row) { updateSite(row) {
this.$get("/sitestat/siteTree", {}).then(({ data }) => { this.$get("/sitestat/siteTree", {}).then(({ data }) => {
this.areaData = data.siteTree; this.areaData = data.siteTree;
...@@ -464,6 +502,12 @@ export default { ...@@ -464,6 +502,12 @@ export default {
config: { config: {
getsocketData: null, getsocketData: null,
search: [ search: [
{
name: "deviceName",
type: "text",
label: "设备名称",
fuzzy: true,
},
{ {
name: "deviceCode", name: "deviceCode",
type: "text", type: "text",
...@@ -578,6 +622,15 @@ export default { ...@@ -578,6 +622,15 @@ export default {
二维码 二维码
</el-button> </el-button>
</div> </div>
<span> </span>
<el-button
type="text"
size="mini"
onClick={() => this.restart(row.id)}
>
重启
</el-button>
); );
}, },
}, },
......
...@@ -46,6 +46,12 @@ export default { ...@@ -46,6 +46,12 @@ export default {
label: "设备编号", label: "设备编号",
fuzzy: true, fuzzy: true,
}, },
{
name: "messageHead",
type: "text",
label: "业务标识",
fuzzy: true,
},
{ {
name: "logType", name: "logType",
type: "select", type: "select",
......
...@@ -5,7 +5,6 @@ import com.mortals.xhx.base.framework.listener.RabbitLoggingErrorHandler; ...@@ -5,7 +5,6 @@ import com.mortals.xhx.base.framework.listener.RabbitLoggingErrorHandler;
import com.mortals.xhx.base.framework.listener.SimpleDynamicListener; import com.mortals.xhx.base.framework.listener.SimpleDynamicListener;
import com.mortals.xhx.base.system.message.MessageCallbackService; import com.mortals.xhx.base.system.message.MessageCallbackService;
import com.mortals.xhx.base.system.message.impl.MessageProducer; import com.mortals.xhx.base.system.message.impl.MessageProducer;
import org.checkerframework.checker.units.qual.A;
import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.AsyncRabbitTemplate; import org.springframework.amqp.rabbit.AsyncRabbitTemplate;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
...@@ -56,7 +55,7 @@ public class RabbitConfig { ...@@ -56,7 +55,7 @@ public class RabbitConfig {
return message; return message;
}); });
//设置异常处理 //设置异常处理
container.setErrorHandler(rabbitLoggingErrorHandler); //container.setErrorHandler(rabbitLoggingErrorHandler);
// 并发消费,不使用 // 并发消费,不使用
// container.setConsumersPerQueue(3); // container.setConsumersPerQueue(3);
// container.setMaxConcurrentConsumers(10); // container.setMaxConcurrentConsumers(10);
......
package com.mortals.xhx.busiz.web; package com.mortals.xhx.busiz.web;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -31,6 +32,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -31,6 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_NOTIFY_REFRESH; import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_NOTIFY_REFRESH;
...@@ -46,7 +48,6 @@ public class DeviceSendMsgController { ...@@ -46,7 +48,6 @@ public class DeviceSendMsgController {
private DeviceLogService deviceLogService; private DeviceLogService deviceLogService;
@PostMapping("refreshMessage") @PostMapping("refreshMessage")
@UnAuth @UnAuth
public String refreshMessage(@RequestBody UploadDeviceReq req) { public String refreshMessage(@RequestBody UploadDeviceReq req) {
...@@ -57,13 +58,17 @@ public class DeviceSendMsgController { ...@@ -57,13 +58,17 @@ public class DeviceSendMsgController {
try { try {
//查询站点设备并通知每个设备 //查询站点设备并通知每个设备
List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().siteId(req.getSiteId())); List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery().siteId(req.getSiteId()));
for (DeviceEntity deviceEntity : deviceList) { Runnable runnable = () -> {
try {
List<List<DeviceEntity>> partition = ListUtil.partition(deviceList, 10);
for (List<DeviceEntity> deviceEntities : partition) {
for (DeviceEntity deviceEntity : deviceEntities) {
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders(); TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, MESSAGETYPE_NOTIFY_REFRESH); header.put(MessageHeader.MESSAGETYPE, MESSAGETYPE_NOTIFY_REFRESH);
header.put(MessageHeader.DEVICECODE, deviceEntity.getDeviceCode()); header.put(MessageHeader.DEVICECODE, deviceEntity.getDeviceCode());
header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime()); header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), "W10=", header); TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), "W10=", header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE,Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg)); messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg));
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue(); deviceLogEntity.initAttrValue();
...@@ -78,8 +83,16 @@ public class DeviceSendMsgController { ...@@ -78,8 +83,16 @@ public class DeviceSendMsgController {
deviceLogEntity.setCreateUserId(1L); deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,null); deviceLogService.save(deviceLogEntity,null);
} }
TimeUnit.SECONDS.sleep(1);
}
}
catch (InterruptedException e) {
log.error("异常",e);
}
};
Thread thread = new Thread(runnable);
thread.start();
} catch (Exception e) { } catch (Exception e) {
log.error("接收数据失败", e); log.error("接收数据失败", e);
rsp.setCode(ApiRespCodeEnum.FAILED.getValue()); rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
......
...@@ -113,6 +113,11 @@ public final class Constant { ...@@ -113,6 +113,11 @@ public final class Constant {
*/ */
public static final String MESSAGETYPE_NOTIFY_REFRESH = "sitechange"; public static final String MESSAGETYPE_NOTIFY_REFRESH = "sitechange";
/**
* 消息类型(重启应用)
*/
public static final String MESSAGETYPE_NOTIFY_RESTART_APP = "restartapp";
/** /**
* 消息类型(upgread) * 消息类型(upgread)
*/ */
......
package com.mortals.xhx.common.utils; package com.mortals.xhx.common.utils;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.xhx.base.system.message.impl.MessageProducer; import com.mortals.xhx.base.system.message.impl.MessageProducer;
...@@ -25,6 +26,8 @@ import org.springframework.util.ObjectUtils; ...@@ -25,6 +26,8 @@ import org.springframework.util.ObjectUtils;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/** /**
* 接收消息 * 接收消息
...@@ -41,35 +44,23 @@ public class DownMsgTask implements Runnable { ...@@ -41,35 +44,23 @@ public class DownMsgTask implements Runnable {
private ProductService productService; private ProductService productService;
private DeviceService deviceService; private DeviceService deviceService;
private DeviceLogService deviceLogService; private DeviceLogService deviceLogService;
private MessageProducer messageProducer; private MessageProducer messageProducer;
@Override @Override
public void run() { public void run() {
try { try {
list.stream().sorted(Comparator.comparing(DeviceMsgReq::getTimestamp)).forEach(item -> { List<DeviceMsgReq> collect = list.stream().sorted(Comparator.comparing(DeviceMsgReq::getTimestamp)).collect(Collectors.toList());
List<List<DeviceMsgReq>> partition = ListUtil.partition(collect, 10);
for (List<DeviceMsgReq> deviceMsgReqs : partition) {
for (DeviceMsgReq item : deviceMsgReqs) {
//根据设备编码查询设备 //根据设备编码查询设备
DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceCode()); DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceCode());
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
//将上报信息转发到mq中
/* PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
if (ObjectUtils.isEmpty(platformEntity)) {
log.error("当前设备未配置所属系统平台,请在后台配置后再激活!");
return;
}
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (ObjectUtils.isEmpty(productEntity)) {
log.error("当前设备未配置所属产品,请在后台配置后再激活!");
return;
}*/
// String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
// TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.DOWN_TOPIC + deviceEntity.getDeviceMac()).build();
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders(); TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, item.getMessageType()); header.put(MessageHeader.MESSAGETYPE, item.getMessageType());
header.put(MessageHeader.DEVICECODE, item.getDeviceCode()); header.put(MessageHeader.DEVICECODE, item.getDeviceCode());
header.put(MessageHeader.TIMESTAMP, item.getTimestamp().toString()); header.put(MessageHeader.TIMESTAMP, item.getTimestamp().toString());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), item.getData(), header); TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), item.getData(), header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE,Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg)); messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE,Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg));
...@@ -86,56 +77,45 @@ public class DownMsgTask implements Runnable { ...@@ -86,56 +77,45 @@ public class DownMsgTask implements Runnable {
deviceLogEntity.setCreateUserId(1L); deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,null); deviceLogService.save(deviceLogEntity,null);
/* } else {
TbQueueCallback callback = new TbQueueCallback() { log.info("未找到设备,deviceCode:{}", item.getDeviceCode());
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
//下行业务消息保存日志
if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(item.getMessageType())) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(metadata.getMessageId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType());
deviceLogEntity.setContent(item.getData());
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity);
} }
log.info("消息投递成功,设备通道编码:" + deviceEntity.getDeviceMac());
} }
@Override TimeUnit.SECONDS.sleep(1);
public void onFailure(Throwable t) { }
/*
list.stream().sorted(Comparator.comparing(DeviceMsgReq::getTimestamp)).forEach(item -> {
//根据设备编码查询设备
DeviceEntity deviceEntity = deviceService.getExtCache(item.getDeviceCode());
if (!ObjectUtils.isEmpty(deviceEntity)) {
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, item.getMessageType());
header.put(MessageHeader.DEVICECODE, item.getDeviceCode());
header.put(MessageHeader.TIMESTAMP, item.getTimestamp().toString());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), item.getData(), header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE,Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg));
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue(); deviceLogEntity.initAttrValue();
String traceID = IdUtil.fastSimpleUUID(); deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setTraceID(traceID);
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId()); deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName()); deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode()); deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType()); deviceLogEntity.setMessageHead(item.getMessageType());
deviceLogEntity.setContent(item.getData()); deviceLogEntity.setContent(item.getData());
deviceLogEntity.setLogType(LogTypeEnum.消息异常.getValue()); deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L); deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity); deviceLogService.save(deviceLogEntity,null);
log.error("traceID:"+traceID,"消息投递失败,设备通道编码:" + deviceEntity.getDeviceMac(), t);
}
};
deviceService.sendDeviceMessage(deviceEntity, info, header, item.getData(),callback, null);
*/
} else { } else {
log.info("未找到设备,deviceCode:{}", item.getDeviceCode()); log.info("未找到设备,deviceCode:{}", item.getDeviceCode());
} }
}); });*/
} catch (Exception e) { } catch (Exception e) {
log.error("异常:", e); log.error("异常:", e);
} }
......
...@@ -37,6 +37,15 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -37,6 +37,15 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/ */
void active(String deviceCode,Context context); void active(String deviceCode,Context context);
/**
* 设备重启应用
* @param deviceEntity
* @param context
*/
void restartApp(DeviceEntity deviceEntity,Context context);
/** /**
* 设备启用停用 * 设备启用停用
* @param id * @param id
......
...@@ -50,7 +50,7 @@ public class DeviceLogServiceImpl extends AbstractCRUDServiceImpl<DeviceLogDao, ...@@ -50,7 +50,7 @@ public class DeviceLogServiceImpl extends AbstractCRUDServiceImpl<DeviceLogDao,
@Override @Override
protected void saveAfter(DeviceLogEntity entity, Context context) throws AppException { protected void saveAfter(DeviceLogEntity entity, Context context) throws AppException {
log.info("业务日志保存成功!"); log.debug("业务日志保存成功!");
BizLogPdu bizLogPdu = new BizLogPdu(); BizLogPdu bizLogPdu = new BizLogPdu();
bizLogPdu.initAttrValue(); bizLogPdu.initAttrValue();
bizLogPdu.setAppName(appName); bizLogPdu.setAppName(appName);
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.PatternPool; import cn.hutool.core.lang.PatternPool;
import cn.hutool.core.net.url.UrlBuilder; 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.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
...@@ -18,6 +19,8 @@ import com.mortals.xhx.busiz.rsp.ApiResp; ...@@ -18,6 +19,8 @@ import com.mortals.xhx.busiz.rsp.ApiResp;
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;
import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.common.pdu.site.SitePdu; import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.utils.BeanUtil; import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.site.ISiteFeign; import com.mortals.xhx.feign.site.ISiteFeign;
...@@ -53,6 +56,7 @@ import java.nio.charset.Charset; ...@@ -53,6 +56,7 @@ import java.nio.charset.Charset;
import java.util.*; 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 java.math.BigDecimal.ROUND_HALF_DOWN; import static java.math.BigDecimal.ROUND_HALF_DOWN;
import static java.util.stream.Collectors.counting; import static java.util.stream.Collectors.counting;
...@@ -220,6 +224,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -220,6 +224,43 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
} }
@Override
public void restartApp(DeviceEntity deviceEntity, Context context) {
if(ObjectUtils.isEmpty(deviceEntity.getIdList())){
throw new AppException("请选择需要重启应用的设备!");
}
List<DeviceEntity> deviceEntities = this.find(deviceEntity, context);
for (DeviceEntity device : deviceEntities) {
if (!ObjectUtils.isEmpty(device)) {
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, MESSAGETYPE_NOTIFY_RESTART_APP);
header.put(MessageHeader.DEVICECODE, deviceEntity.getDeviceCode());
header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), "W10=", header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(),JSON.toJSONString(queueMsg));
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(MESSAGETYPE_NOTIFY_RESTART_APP);
deviceLogEntity.setContent("W10=");
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,null);
} else {
log.info("未找到设备,deviceCode:{}", device.getDeviceCode());
}
}
}
@Override @Override
public void deviceEnabled(Long id, Integer enabled, Context context) { public void deviceEnabled(Long id, Integer enabled, Context context) {
DeviceEntity deviceEntity = this.get(id, context); DeviceEntity deviceEntity = this.get(id, context);
......
...@@ -176,6 +176,25 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -176,6 +176,25 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return rest; return rest;
} }
/**
* 设备批量重启应用
*/
@PostMapping(value = "batchRestartApp")
public Rest<Void> batchRestartApp(@RequestBody DeviceEntity deviceEntity) {
log.info("批量设备重启", deviceEntity.getDeviceCode());
String busiDesc = this.getModuleDesc() + "设备重启";
Rest<Void> rest = Rest.ok(busiDesc + " 【成功】");
try {
this.service.restartApp(deviceEntity,getContext());
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
log.error("批量设备重启", e);
rest = Rest.fail(super.convertException(e));
}
return rest;
}
/** /**
* 查看二维码 * 查看二维码
*/ */
......
...@@ -158,44 +158,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao, ...@@ -158,44 +158,6 @@ public class ProductServiceImpl extends AbstractCRUDCacheServiceImpl<ProductDao,
deviceLogEntity.setCreateUserId(1L); deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,context); deviceLogService.save(deviceLogEntity,context);
/* TbQueueCallback callback = new TbQueueCallback() {
@Override
public void onSuccess(TbQueueMsgMetadata metadata) {
log.info("【成功】发送升级版本信息,设备编码:{}",deviceEntity.getDeviceCode());
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(metadata.getMessageId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(MESSAGETYPE_UPGREAD);
deviceLogEntity.setContent(Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()));
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity,context);
}
@Override
public void onFailure(Throwable t) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
String traceID = IdUtil.fastSimpleUUID();
deviceLogEntity.setTraceID(traceID);
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(MESSAGETYPE_UPGREAD);
deviceLogEntity.setContent(Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()));
deviceLogEntity.setLogType(LogTypeEnum.消息异常.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
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); // deviceService.sendDeviceMessage(deviceEntity, info, header, Base64.getEncoder().encodeToString(JSON.toJSONString(productVersionInfo).getBytes()), callback, null);
......
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