TRX 1 år sedan
förälder
incheckning
a9507395f0

+ 3 - 2
src/main/java/com/zswl/dataservice/controller/TestController.java

@@ -1,6 +1,7 @@
 package com.zswl.dataservice.controller;
 
 import com.zswl.dataservice.model.mqtt.SendMessageModel;
+import com.zswl.dataservice.service.artemis.ArtemisService;
 import com.zswl.dataservice.service.user.impl.UserServiceImpl;
 import com.zswl.dataservice.utils.result.ResultContent;
 import io.swagger.v3.oas.annotations.Operation;
@@ -22,12 +23,12 @@ import org.springframework.web.bind.annotation.RestController;
 public class TestController {
 
     @Autowired
-    UserServiceImpl userService;
+    ArtemisService artemisService;
 
     @Operation(summary = "发送指令")
     @RequestMapping(value = "free/sendMessage", method = {RequestMethod.POST})
     public ResultContent sendMessage(@RequestBody SendMessageModel param) {
-        return userService.sendMessage(param);
+        return artemisService.sendMessage(param);
     }
 
     @Operation(summary = "ping")

+ 1 - 1
src/main/java/com/zswl/dataservice/controller/free/FixDataController.java

@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/fixData/free")
 @RestController
 @Validated
-@Tag(name = "修复数据")
+@Tag(name = "Fix修复数据")
 public class FixDataController {
 
     @Autowired

+ 1 - 1
src/main/java/com/zswl/dataservice/controller/hardware/OperationMessageController.java

@@ -2,7 +2,7 @@ package com.zswl.dataservice.controller.hardware;
 
 import com.zswl.dataservice.model.mqtt.*;
 import com.zswl.dataservice.service.mqtt.DeviceInfoService;
-import com.zswl.dataservice.service.mqtt.OperationMessageService;
+import com.zswl.dataservice.service.artemis.OperationMessageService;
 import com.zswl.dataservice.utils.result.ResultContent;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;

+ 5 - 0
src/main/java/com/zswl/dataservice/dao/mqtt/GateWay2DeviceDao.java

@@ -3,6 +3,8 @@ package com.zswl.dataservice.dao.mqtt;
 import com.zswl.dataservice.dao.MongoDao;
 import com.zswl.dataservice.domain.mqtt.*;
 
+import java.util.List;
+
 /**
  * @author TRX
  * @date 2024/3/21
@@ -10,4 +12,7 @@ import com.zswl.dataservice.domain.mqtt.*;
 public interface GateWay2DeviceDao extends MongoDao<GateWay2Device> {
 
     GateWay2Device findTopByGateWayInfoAndDeviceInfo(GateWayInfo gateWayInfo, DeviceInfo deviceInfo);
+
+    // 根据设备查询绑定关系
+    List<GateWay2Device> findByDeviceInfo(DeviceInfo deviceInfo);
 }

+ 3 - 0
src/main/java/com/zswl/dataservice/domain/mqtt/DeviceInfo.java

@@ -53,6 +53,9 @@ public class DeviceInfo extends SuperEntity {
     @DBRef(lazy = true)
     private ProjectInfo projectInfo;
 
+    @Schema(description = "项目code")
+    private String projectInfoCode;
+
     @Schema(description = "固件版本")
     private String firmwareVersion;
 

+ 30 - 1
src/main/java/com/zswl/dataservice/domain/mqtt/OperationMessage.java

@@ -1,12 +1,16 @@
 package com.zswl.dataservice.domain.mqtt;
 
 import com.zswl.dataservice.domain.base.SuperEntity;
+import com.zswl.dataservice.type.OperationType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.index.Indexed;
 import org.springframework.data.mongodb.core.mapping.Document;
 
+import java.util.Date;
+
 /**
  * 指令数据
  *
@@ -18,18 +22,37 @@ import org.springframework.data.mongodb.core.mapping.Document;
 @NoArgsConstructor
 @AllArgsConstructor
 public class OperationMessage extends SuperEntity {
-    @Schema(description = "消息ID")
+    @Schema(description = "mqtt服务器消息ID")
     private String messageId;
 
     @Schema(description = "topic")
     private String topic;
 
+    @Schema(description = "终端ID")
+    private String clientId;
+
+    @Schema(description = "业务生成的ID")
+    private String dataId;
+
     @Schema(description = "消息内容")
     private Object data;
 
     @Schema(description = "ttl时间(毫秒数)")
     private Long ttlTime;
 
+    @Schema(description = "发送时间")
+    private Long sendTime;
+
+    @Schema(description = "接收的消息是否超时")
+    private Boolean isTimeOut;
+
+    @Schema(description = "处理标记")
+    private String event;
+
+    //------------------------关联的消息
+
+    private String messageClass;
+
     @Schema(description = "关于的设备信息")
     private DeviceInfo deviceInfo;
 
@@ -53,4 +76,10 @@ public class OperationMessage extends SuperEntity {
 
     @Schema(description = "接收到的时间可阅读的")
     private String receiveTimeStr;
+
+    @Schema(description = "mqtt消息类型: 发送 接收")
+    OperationType operationType;
+
+    @Indexed(expireAfterSeconds = 0)
+    private Date ttl;
 }

+ 45 - 0
src/main/java/com/zswl/dataservice/model/hxz/ConsumTransactionsModel.java

@@ -0,0 +1,45 @@
+package com.zswl.dataservice.model.hxz;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ConsumTransactionsModel {
+
+    @JsonProperty("Order")
+    private String order;
+
+    @JsonProperty("CardNo")
+    private String cardNo;
+
+    @JsonProperty("CardMode")
+    private Integer cardMode;
+
+    @JsonProperty("Mode")
+    private Integer mode;
+
+    @JsonProperty("PayType")
+    private Integer payType;
+
+    @JsonProperty("Amount")
+    private String amount;
+
+    @JsonProperty("Menus")
+    private Menus[] menus;
+
+    @Data
+    @AllArgsConstructor
+    @NoArgsConstructor
+    public static class Menus {
+        @JsonProperty("MenuID")
+        private String menuID;
+
+        @JsonProperty("Count")
+        private String count;
+    }
+}
+

+ 3 - 0
src/main/java/com/zswl/dataservice/model/mqtt/DeviceInfoModel.java

@@ -60,6 +60,9 @@ public class DeviceInfoModel extends SuperModel {
     @Schema(description = "所属项目")
     private ProjectInfoModel projectInfo;
 
+    @Schema(description = "项目code")
+    private String projectInfoCode;
+
     @Schema(description = "固件版本")
     private String firmwareVersion;
 

+ 14 - 0
src/main/java/com/zswl/dataservice/model/mqtt/OperationMessageModel.java

@@ -1,6 +1,7 @@
 package com.zswl.dataservice.model.mqtt;
 
 import com.zswl.dataservice.model.baseParam.SuperModel;
+import com.zswl.dataservice.type.OperationType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -43,4 +44,17 @@ public class OperationMessageModel extends SuperModel {
 
     @Schema(description = "接收到的时间可阅读的")
     private String receiveTimeStr;
+
+    @Schema(description = "mqtt消息类型: 发送 接收")
+    OperationType operationType;
+
+    private String operationTypeStr;
+
+    public String getOperationTypeStr() {
+        if (operationType != null) {
+            return operationType.getRemark();
+        }
+        return "";
+    }
+
 }

+ 136 - 0
src/main/java/com/zswl/dataservice/service/artemis/ArtemisService.java

@@ -0,0 +1,136 @@
+package com.zswl.dataservice.service.artemis;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
+import com.zswl.dataservice.domain.mqtt.OperationMessage;
+import com.zswl.dataservice.httpRequest.ApiRequestService;
+import com.zswl.dataservice.model.mqtt.SendMessageModel;
+import com.zswl.dataservice.service.base.RedisService;
+import com.zswl.dataservice.service.base.SuperService;
+import com.zswl.dataservice.service.payment.HxzService;
+import com.zswl.dataservice.type.OperationType;
+import com.zswl.dataservice.utils.DateUtils;
+import com.zswl.dataservice.utils.mqtt.mqttConfig.client.MQClient;
+import com.zswl.dataservice.utils.mqtt.mqttConfig.constant.MQConstant;
+import com.zswl.dataservice.utils.result.ResultContent;
+import jakarta.jms.Message;
+import jakarta.jms.TextMessage;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage;
+import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jms.annotation.JmsListener;
+import org.springframework.stereotype.Service;
+
+import java.util.UUID;
+
+/**
+ * @author TRX
+ * @date 2024/6/27
+ */
+@Slf4j
+@Service
+public class ArtemisService extends SuperService {
+
+    @Autowired
+    RedisService redisService;
+
+    @Autowired
+    MQClient mqClient;
+
+    @Autowired
+    ApiRequestService apiRequestService;
+
+    @Autowired
+    OperationMessageService operationMessageService;
+
+    @Autowired
+    HxzService hxzService;
+
+    // 网关来的消息
+    @JmsListener(destination = "/v1/gateway/#", containerFactory = MQConstant.TopicListenerContainerFactory)
+    @JmsListener(destination = ".v1.gateway.#", containerFactory = MQConstant.TopicListenerContainerFactory)
+    public void receiveMessage(Message message) {
+        // 处理接收到的消息
+        try {
+            ActiveMQTopic activeMQTopic = (ActiveMQTopic) message.getJMSDestination();
+            String topicName = activeMQTopic.getTopicName();
+            if (topicName.equals("activemq.notifications")) {
+                return;
+            }
+            OperationMessage operationMessage = new OperationMessage();
+
+            String messageId = message.getJMSMessageID();
+            String clientId = message.getStringProperty("__AMQ_CID");
+            log.info("receiveMessage {} 消息监听clientId: {}", messageId, clientId);
+            log.info("Topic: {}", topicName);
+
+            operationMessage.setMessageId(messageId);
+            operationMessage.setClientId(clientId);
+            operationMessage.setTopic(topicName);
+            operationMessage.setOperationType(OperationType.Sub);
+
+            String messageClass = "";
+            String msg = "";
+            if (message instanceof ActiveMQBytesMessage) {
+                ActiveMQBytesMessage activeMQBytesMessage = (ActiveMQBytesMessage) message;
+                messageClass = ActiveMQBytesMessage.class.getSimpleName();
+                byte[] messageBody = new byte[(int) activeMQBytesMessage.getBodyLength()];
+                // 读取消息内容到字节数组
+                activeMQBytesMessage.readBytes(messageBody);
+                msg = new String(messageBody);
+            }
+            if (message instanceof TextMessage) {
+                messageClass = TextMessage.class.getSimpleName();
+                TextMessage textMessage = (TextMessage) message;
+                msg = textMessage.getText();
+            }
+            JSONObject json = JSONObject.parseObject(msg);
+            String id = json.getString("id");
+            Long time = json.getLong("time");
+            Long ttl = json.getLong("ttl");
+            boolean isTimeOut = false;
+            if (System.currentTimeMillis() > (time + ttl)) {
+                isTimeOut = true;
+            }
+            log.info("textMessage: {}", msg);
+            // --------------------处理业务 start------------------
+            operationMessage.setMessageClass(messageClass);
+            operationMessage.setData(msg);
+            operationMessage.setTtlTime(ttl);
+            operationMessage.setSendTime(time);
+            operationMessage.setDataId(id);
+            operationMessage.setIsTimeOut(isTimeOut);
+            if (!isTimeOut) {
+
+            }
+            operationMessageService.addOperationMessage(operationMessage);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 发送指令
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent sendMessage(SendMessageModel param) {
+        String msg = "发送成功";
+        try {
+            JsonObject jsonObject = new JsonObject();
+            jsonObject.addProperty("id", UUID.randomUUID().toString());
+            jsonObject.addProperty("data", param.getMessage());
+            jsonObject.addProperty("time", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
+            jsonObject.addProperty("ttl", 10 * 1000);
+//            mqClient.sendObject(param.getTopic(), jsonObject.toString());
+            log.info("mqtt msg 发送成功");
+        } catch (Exception e) {
+            e.printStackTrace();
+            msg = "发送失败: " + e.getMessage();
+        }
+        return ResultContent.buildSuccess(msg);
+    }
+
+}

+ 27 - 7
src/main/java/com/zswl/dataservice/service/mqtt/OperationMessageService.java → src/main/java/com/zswl/dataservice/service/artemis/OperationMessageService.java

@@ -1,4 +1,4 @@
-package com.zswl.dataservice.service.mqtt;
+package com.zswl.dataservice.service.artemis;
 
 import cn.hutool.json.JSONObject;
 import com.google.gson.JsonObject;
@@ -7,6 +7,8 @@ import com.zswl.dataservice.dao.mqtt.OperationMessageDao;
 import com.zswl.dataservice.domain.mqtt.DeviceInfo;
 import com.zswl.dataservice.domain.mqtt.OperationMessage;
 import com.zswl.dataservice.model.mqtt.*;
+import com.zswl.dataservice.service.mqtt.DeviceInfoService;
+import com.zswl.dataservice.service.mqtt.GateWayInfoService;
 import com.zswl.dataservice.utils.DateUtils;
 import com.zswl.dataservice.utils.bean.BeanUtils;
 import com.zswl.dataservice.utils.mqtt.MqttTopicUtils;
@@ -20,6 +22,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.UUID;
 
 /**
@@ -47,27 +50,31 @@ public class OperationMessageService {
     @Autowired
     DeviceInfoDao deviceInfoDao;
 
+    // 保存90天
+    private Long ttlMill = 90 * 24L * 60 * 60 * 1000L;
+
     /**
      * 给设备下发指令
+     *
      * @param deviceId 设备ID
      * @param command  指令,如:on,off
      * @param data     指令数据
      * @return
      */
-    public ResultContent sendMessage(String deviceId,String command, JSONObject data) {
+    public ResultContent sendMessage(String deviceId, String command, JSONObject data) {
         DeviceInfo deviceInfo = deviceInfoDao.findTopById(deviceId);
-        if (ObjectUtils.isEmpty(deviceInfo)){
+        if (ObjectUtils.isEmpty(deviceInfo)) {
             return ResultContent.buildFail(String.format("设备不存在:%s", deviceId));
         }
         try {
             // 消息的TTL时间
-            Long ttl = 10*1000L;
+            Long ttl = 10 * 1000L;
             // 消息的ID
             String messageId = "";
             OperationMessage message = new OperationMessage();
             if (data.containsKey("messageId")) {
                 messageId = data.getStr("messageId");
-            }else {
+            } else {
                 messageId = UUID.randomUUID().toString();
                 data.append("messageId", messageId);
             }
@@ -85,18 +92,31 @@ public class OperationMessageService {
             JsonObject jsonObject = new JsonObject();
             jsonObject.addProperty("id", messageId);
             jsonObject.addProperty("data", data.toString());
-            jsonObject.addProperty("time", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
+            jsonObject.addProperty("time", System.currentTimeMillis());
             jsonObject.addProperty("ttl", ttl);
             mqClient.sendObject(topic, jsonObject.toString());
             log.info("mqtt msg 发送成功");
 
             operationMessageDao.save(message);
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 添加
+     *
+     * @param entity
+     * @return
+     */
+    public ResultContent addOperationMessage(OperationMessage entity) {
+        entity.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+        entity.setTtl(new Date(System.currentTimeMillis() + ttlMill));
+        operationMessageDao.save(entity);
+        return ResultContent.buildSuccess();
+    }
+
     /**
      * 指令列表
      *

+ 1 - 1
src/main/java/com/zswl/dataservice/service/fix/FixDataService.java

@@ -2,7 +2,7 @@ package com.zswl.dataservice.service.fix;
 
 import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
 import com.zswl.dataservice.domain.mqtt.DeviceInfo;
-import com.zswl.dataservice.service.mqtt.DeviceSyncFullCardService;
+import com.zswl.dataservice.service.sync.DeviceSyncFullCardService;
 import com.zswl.dataservice.utils.result.ResultContent;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;

+ 2 - 0
src/main/java/com/zswl/dataservice/service/mqtt/DeviceInfoService.java

@@ -10,6 +10,7 @@ import com.zswl.dataservice.domain.mqtt.ProjectInfo;
 import com.zswl.dataservice.model.iot.IotMainModel;
 import com.zswl.dataservice.model.mqtt.*;
 import com.zswl.dataservice.service.iot.IotServiceImpl;
+import com.zswl.dataservice.service.sync.DeviceSyncFullCardService;
 import com.zswl.dataservice.type.FunctionType;
 import com.zswl.dataservice.utils.bean.BeanUtils;
 import com.zswl.dataservice.utils.mqtt.type.LogsLevel;
@@ -71,6 +72,7 @@ public class DeviceInfoService {
         if (StringUtils.isNotEmpty(param.getProjectInfoCode())) {
             ProjectInfo projectInfo = projectInfoDao.findTopByCode(param.getProjectInfoCode());
             deviceInfo.setProjectInfo(projectInfo);
+            deviceInfo.setProjectInfoCode(projectInfo.getCode());
         }
 
         deviceInfoDao.save(deviceInfo);

+ 4 - 2
src/main/java/com/zswl/dataservice/service/mqtt/GateWayInfoService.java

@@ -2,9 +2,9 @@ package com.zswl.dataservice.service.mqtt;
 
 import com.zswl.dataservice.dao.mqtt.*;
 import com.zswl.dataservice.domain.mqtt.*;
-import com.zswl.dataservice.event.GateWaySyncEvent;
 import com.zswl.dataservice.model.mqtt.*;
 import com.zswl.dataservice.service.base.SuperService;
+import com.zswl.dataservice.service.sync.DeviceSyncFullCardService;
 import com.zswl.dataservice.utils.DateUtils;
 import com.zswl.dataservice.utils.bean.BeanUtils;
 import com.zswl.dataservice.utils.mqtt.MqttTopicUtils;
@@ -142,12 +142,14 @@ public class GateWayInfoService extends SuperService {
             }
         }
 
+        String projectInfoCode = param.getProjectInfoCode();
+
         // 设备列表
         List<DeviceInfo> deviceInfos = new ArrayList<>();
         if (ObjectUtils.isNotEmpty(devices)) {
             // 绑定网关和设备的关系
             for (DeviceInfoAddParam device : devices) {
-                device.setProjectInfoCode(param.getProjectInfoCode());
+                device.setProjectInfoCode(projectInfoCode);
                 // 保存设备信息
                 ResultContent<DeviceInfo> resultContent = deviceInfoService.addDeviceInfo(device);
                 DeviceInfo deviceInfo = resultContent.getContent();

+ 12 - 6
src/main/java/com/zswl/dataservice/service/payment/HxzService.java

@@ -8,6 +8,7 @@ import com.zswl.dataservice.httpRequest.conf.FullCardAPIConfig;
 import com.zswl.dataservice.model.payment.ServerTimeModel;
 import com.zswl.dataservice.model.payment.ServerTimeResult;
 import com.zswl.dataservice.service.base.SuperService;
+import com.zswl.dataservice.utils.result.ResultContent;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,11 +44,10 @@ public class HxzService extends SuperService {
         ServerTimeResult result = new ServerTimeResult();
         DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
         if (ObjectUtils.isEmpty(deviceInfo)) {
-//            result.setFailed("设备未注册");
-//            requestInfoService.addRequestInfo(param, result);
-//            return result;
+            result.setFailed("设备未注册");
+            requestInfoService.addHXZRequestInfo(param, result);
+            return result;
         }
-
         // 业务验证
         APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
                 FullCardAPIConfig.ServerTime, param);
@@ -62,12 +62,18 @@ public class HxzService extends SuperService {
                 result.setWLPage(0);
                 result.setWLUptate(0);
                 log.info("ServerTime : {} - {}", result);
-            }else {
+            } else {
                 result.setFailed(timeResult.getMsg());
             }
-        }else {
+        } else {
             result.setFailed(resultContent.getMsg());
         }
         return result;
     }
+
+    public ResultContent consumTransactions() {
+
+        return ResultContent.buildSuccess();
+    }
+
 }

+ 15 - 4
src/main/java/com/zswl/dataservice/service/mqtt/DeviceSyncFullCardService.java → src/main/java/com/zswl/dataservice/service/sync/DeviceSyncFullCardService.java

@@ -1,10 +1,12 @@
-package com.zswl.dataservice.service.mqtt;
+package com.zswl.dataservice.service.sync;
 
 import com.github.microservice.models.device.DeviceInfoSyncParam;
 import com.github.microservice.models.device.DeviceSyncListParam;
 import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
+import com.zswl.dataservice.dao.mqtt.GateWay2DeviceDao;
 import com.zswl.dataservice.dao.mqtt.GateWayInfoDao;
 import com.zswl.dataservice.domain.mqtt.DeviceInfo;
+import com.zswl.dataservice.domain.mqtt.GateWay2Device;
 import com.zswl.dataservice.domain.mqtt.GateWayInfo;
 import com.zswl.dataservice.event.DeviceSyncEvent;
 import com.zswl.dataservice.event.GateWaySyncEvent;
@@ -12,7 +14,7 @@ import com.zswl.dataservice.httpRequest.ApiRequestService;
 import com.zswl.dataservice.httpRequest.apiConf.APIResponseModel;
 import com.zswl.dataservice.httpRequest.conf.FullCardAPIConfig;
 import com.zswl.dataservice.service.base.SuperService;
-import com.zswl.dataservice.utils.bean.BeanUtil;
+import com.zswl.dataservice.service.mqtt.OperationLogsService;
 import com.zswl.dataservice.utils.bean.BeanUtils;
 import com.zswl.dataservice.utils.result.ResultContent;
 import lombok.SneakyThrows;
@@ -24,7 +26,6 @@ import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -54,6 +55,9 @@ public class DeviceSyncFullCardService extends SuperService {
     @Autowired
     ApplicationContext applicationContext;
 
+    @Autowired
+    GateWay2DeviceDao gateWay2DeviceDao;
+
     /**
      * 通知同步设备
      *
@@ -114,9 +118,16 @@ public class DeviceSyncFullCardService extends SuperService {
         DeviceSyncListParam param = new DeviceSyncListParam();
         List<DeviceInfoSyncParam> deviceInfos = new ArrayList<>();
         if (ObjectUtils.isNotEmpty(list)) {
-            list.stream().map(it -> {
+            deviceInfos = list.stream().map(it -> {
                 DeviceInfoSyncParam syncParam = new DeviceInfoSyncParam();
                 BeanUtils.copyProperties(it, syncParam);
+                List<GateWay2Device> gateWay2Devices = gateWay2DeviceDao.findByDeviceInfo(it);
+                List<String> gateWayIds = gateWay2Devices.stream().map(it2 -> {
+                    return it2.getGateWayInfo().getGateWayId();
+                }).collect(Collectors.toList());
+                syncParam.setGateWayId(String.join(",", gateWayIds));
+                // 项目code
+                syncParam.setProjectInfoCode(it.getProjectInfoCode());
                 return syncParam;
             }).collect(Collectors.toList());
         }

+ 0 - 63
src/main/java/com/zswl/dataservice/service/user/impl/UserServiceImpl.java

@@ -173,67 +173,4 @@ public class UserServiceImpl extends SuperService implements UserService {
         return ResultContent.build(passwordEncoder.matches(passWord, user.getPassWord()) ? ResultState.Success : ResultState.UserPasswordError);
     }
 
-    /**
-     * 发送指令
-     *
-     * @param param
-     * @return
-     */
-    public ResultContent sendMessage(SendMessageModel param) {
-        String msg = "发送成功";
-        try {
-            JsonObject jsonObject = new JsonObject();
-            jsonObject.addProperty("id", UUID.randomUUID().toString());
-            jsonObject.addProperty("data", param.getMessage());
-            jsonObject.addProperty("time", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
-            jsonObject.addProperty("ttl", 10 * 1000);
-//            mqClient.sendObject(param.getTopic(), jsonObject.toString());
-            log.info("mqtt msg 发送成功");
-        } catch (Exception e) {
-            e.printStackTrace();
-            msg = "发送失败: " + e.getMessage();
-        }
-        APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
-                FullCardAPIConfig.sendMessage, param);
-        if (resultContent.isSuccess()) {
-
-        }
-        log.info("是否成功: {} {} {}", resultContent.isSuccess(), resultContent.getContent(), resultContent.getMsg());
-        return ResultContent.buildSuccess(msg);
-    }
-
-    //    @JmsListener(destination = "#", containerFactory = MQConstant.TopicListenerContainerFactory)
-    @JmsListener(destination = "v1/#", containerFactory = MQConstant.TopicListenerContainerFactory)
-    @JmsListener(destination = "v1.#", containerFactory = MQConstant.TopicListenerContainerFactory)
-    public void receiveMessage(Message message) {
-        // 处理接收到的消息
-        try {
-            ActiveMQTopic activeMQTopic = (ActiveMQTopic) message.getJMSDestination();
-            String topicName = activeMQTopic.getTopicName();
-            if (topicName.equals("activemq.notifications")) {
-                return;
-            }
-            log.info("receiveMessage {} 消息监听clientId: {}", message.getJMSMessageID(), message.getStringProperty("__AMQ_CID"));
-            log.info("Topic: {}", topicName);
-
-            if (message instanceof ActiveMQBytesMessage) {
-                ActiveMQBytesMessage activeMQBytesMessage = (ActiveMQBytesMessage) message;
-
-                byte[] messageBody = new byte[(int) activeMQBytesMessage.getBodyLength()];
-                // 读取消息内容到字节数组
-                activeMQBytesMessage.readBytes(messageBody);
-                String msg = new String(messageBody);
-                JSONObject json = JSONObject.parseObject(msg);
-                log.info("消息内容:{}", json.getString("msg"));
-            }
-            if (message instanceof TextMessage) {
-                TextMessage textMessage = (TextMessage) message;
-                log.info("textMessage: {}", textMessage.getText());
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
 }