|
@@ -1,6 +1,9 @@
|
|
|
package com.warewms.hailiang.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSON;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -8,9 +11,11 @@ import com.warewms.common.core.domain.base.page.PageDomain;
|
|
|
import com.warewms.common.core.domain.base.page.TableDataInfo;
|
|
|
import com.warewms.common.utils.StringUtils;
|
|
|
import com.warewms.hailiang.config.DeviceMessageSocket;
|
|
|
+import com.warewms.hailiang.domain.Device;
|
|
|
import com.warewms.hailiang.domain.DeviceLog;
|
|
|
import com.warewms.hailiang.mapper.DeviceLogMapper;
|
|
|
import com.warewms.hailiang.service.DeviceLogService;
|
|
|
+import com.warewms.hailiang.service.DeviceService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -31,6 +36,9 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
|
|
|
@Autowired
|
|
|
DeviceLogMapper deviceLogMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DeviceService deviceService;
|
|
|
+
|
|
|
@Autowired
|
|
|
DeviceMessageSocket deviceMessageSocket;
|
|
|
|
|
@@ -56,7 +64,15 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
|
|
|
deviceLog.setUpdateBy("system");
|
|
|
deviceLogMapper.insert(deviceLog);
|
|
|
//推送消息
|
|
|
- deviceMessageSocket.sendAllMessage(deviceLog.toString());
|
|
|
+ for (Device device : deviceService.getList()) {
|
|
|
+ if (device.getDeviceId().equals(deviceLog.getDeviceId())){
|
|
|
+ deviceLog.setDeviceName(device.getAbbreviation());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.set("type","notify");
|
|
|
+ jsonObject.set("content",JSONUtil.parse(deviceLog));
|
|
|
+ deviceMessageSocket.sendAllMessage(jsonObject.toString());
|
|
|
}
|
|
|
|
|
|
}
|