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

设备添加定时重启窗口屏与评价器

parent 3c2504d6
......@@ -95,6 +95,11 @@ public final class Constant {
*/
public final static String PARAM_SMS_HTTP_URL = "sms_http_url";
/**
* 产品重启列表
*/
public final static String PARAM_RESTART_PRODUCT_LIST = "restart_product_list";
/**
* rabbmit exchange分隔符
*/
......
package com.mortals.xhx.daemon.task;
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.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.message.impl.MessageProducer;
import com.mortals.xhx.common.code.LogTypeEnum;
import com.mortals.xhx.common.key.Constant;
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.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.queue.DefaultTbQueueMsg;
import com.mortals.xhx.queue.TbQueueMsg;
import com.mortals.xhx.queue.TbQueueMsgHeaders;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_NOTIFY_RESTART_APP;
/**
* 设备定时重启
*/
@Slf4j
@Service("DeviceRestartTask")
public class DeviceRestartTaskImpl implements ITaskExcuteService {
@Autowired
private DeviceService deviceService;
@Autowired
private MessageProducer messageProducer;
@Autowired
private DeviceLogService deviceLogService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("设备定时重启任务");
String restartProduct = GlobalSysInfo.getParamValue(Constant.PARAM_RESTART_PRODUCT_LIST, "ckp,hjq");
StrUtil.split(restartProduct,",").stream().forEach(productCode->{
List<DeviceEntity> deviceEntities = deviceService.find(new DeviceQuery().productCode(productCode));
for (DeviceEntity device : deviceEntities) {
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, MESSAGETYPE_NOTIFY_RESTART_APP);
header.put(MessageHeader.DEVICECODE, device.getDeviceCode());
header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), "W10=", header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + device.getDeviceCode(), JSON.toJSONString(queueMsg));
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setSiteId(device.getSiteId());
deviceLogEntity.setDeviceId(device.getId());
deviceLogEntity.setDeviceName(device.getDeviceName());
deviceLogEntity.setDeviceCode(device.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);
}
});
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
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