|
@@ -1,6 +1,10 @@
|
|
|
package com.ruoyi.web.controller.task;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
@@ -8,6 +12,10 @@ import com.ruoyi.system.service.ISysUserService;
|
|
|
import com.ruoyi.zhdd.domain.GatewayDept;
|
|
|
import com.ruoyi.zhdd.domain.GatewayOrg;
|
|
|
import com.ruoyi.zhdd.domain.GatewaySUser;
|
|
|
+import com.ruoyi.zhdd.domain.SingleDevice;
|
|
|
+import com.ruoyi.zhdd.domain.bo.SingleDeviceBo;
|
|
|
+import com.ruoyi.zhdd.domain.vo.SingleDeviceVo;
|
|
|
+import com.ruoyi.zhdd.service.ISingleDeviceService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.kafka.annotation.KafkaListener;
|
|
@@ -26,6 +34,9 @@ public class SysGatewayUserTask {
|
|
|
@Autowired
|
|
|
ISysDeptService deptService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISingleDeviceService singleDeviceService;
|
|
|
+
|
|
|
@KafkaListener(topics = "t_uc_user")
|
|
|
public void onUserMessage(String message){
|
|
|
log.info("kafka用户信息消费:{}", message);
|
|
@@ -214,9 +225,22 @@ public class SysGatewayUserTask {
|
|
|
System.out.println(message);
|
|
|
}
|
|
|
|
|
|
- @KafkaListener(topics = "executestation_5ee63b516d4e4d79a46cdf88a202caa1"/*, groupId = "huashe-consumer-group"*/)
|
|
|
+ @KafkaListener(topics = "executestation_5ee63b516d4e4d79a46cdf88a202caa1")
|
|
|
public void onDeviceMessage(String message){
|
|
|
log.info("kafka单兵设备信息消费:{}", message);
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(message);
|
|
|
+ JSONObject info = jsonObject.getJSONObject("info");
|
|
|
+ if (info != null) {
|
|
|
+ JSONArray gps = info.getJSONArray("gps");
|
|
|
+ if (gps != null && !gps.isEmpty()) {
|
|
|
+ for (Object gp : gps) {
|
|
|
+ SingleDeviceBo singleDeviceBo = JSONUtil.toBean(Convert.toStr(gp), SingleDeviceBo.class);
|
|
|
+ // 根据deviceCod删除再新增
|
|
|
+ singleDeviceService.remove(Wrappers.<SingleDevice>lambdaQuery().eq(SingleDevice::getDeviceCode, singleDeviceBo.getDeviceCode()));
|
|
|
+ singleDeviceService.insertByBo(singleDeviceBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|