lishuangjiang@potevio.com пре 1 година
родитељ
комит
28492e9ea4

+ 5 - 0
iot-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ProductRepository.java

@@ -14,6 +14,8 @@ import cc.iotkit.model.product.Product;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 
 import java.util.List;
 
@@ -28,4 +30,7 @@ public interface ProductRepository extends JpaRepository<TbProduct, Long> {
     long countByUid(String uid);
 
     TbProduct findByProductKey(String productKey);
+
+    @Query(nativeQuery = true, value = "SELECT * FROM product WHERE product_key = :productKey")
+    TbProduct findByProductKeyWithoutTenantId(@Param("productKey") String productKey);
 }

+ 5 - 1
iot-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductDataImpl.java

@@ -15,6 +15,7 @@ import cc.iotkit.data.util.PredicateBuilder;
 import cc.iotkit.model.device.DeviceInfo;
 import cc.iotkit.model.product.Product;
 import cc.iotkit.model.system.SysConfig;
+import cn.hutool.core.collection.CollectionUtil;
 import com.querydsl.core.QueryResults;
 import com.querydsl.core.types.Predicate;
 import com.querydsl.jpa.impl.JPAQuery;
@@ -27,6 +28,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import static cc.iotkit.data.model.QTbDeviceInfo.tbDeviceInfo;
@@ -65,11 +67,13 @@ public class ProductDataImpl implements IProductData, IJPACommData<Product, Long
 
     @Override
     public Product findByProductKey(String productKey) {
-        return MapstructUtils.convert(productRepository.findByProductKey(productKey), Product.class);
+//        List<TbProduct> products = jpaQueryFactory.select(tbProduct).from(tbProduct).where(tbProduct.productKey.eq(productKey)).fetch();
+        return MapstructUtils.convert(productRepository.findByProductKeyWithoutTenantId(productKey), Product.class);
     }
 
     @Override
     public void delByProductKey(String productKey) {
+
         jpaQueryFactory.delete(tbProduct).where(tbProduct.productKey.eq(productKey)).execute();
     }
 

+ 3 - 0
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/AlertMessageEventListener.java

@@ -26,8 +26,11 @@ public class AlertMessageEventListener implements MessageEventListener {
     @Override
     @EventListener(classes = MessageEvent.class)
     public void doEvent(MessageEvent event) {
+        log.info("**********产生告警*******");
         Message message = event.getMessage();
         AlertConfig alertConfig = alertConfigData.findById(message.getAlertConfigId());
+        log.info("**********告警配置:"+alertConfig.toString());
         alertService.addAlert(alertConfig, message.getFormatContent());
+        log.info("+++++++++++++++++已保存告警信息++++++++++++++++");
     }
 }

+ 1 - 0
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/AlertService.java

@@ -71,6 +71,7 @@ public class AlertService {
                 .alertTime(System.currentTimeMillis())
                 .details(content)
                 .build();
+        log.info("**********告警内容:"+alertRecord.toString());
         alertRecordData.save(alertRecord);
     }
 }

+ 4 - 0
iot-module/iot-message-notify/src/main/java/cc/iotkit/message/listener/EmailEventListener.java

@@ -26,6 +26,7 @@ public class EmailEventListener implements MessageEventListener {
     @Override
     @EventListener(classes = MessageEvent.class, condition = "#event.message.channel=='Email'")
     public void doEvent(MessageEvent event) {
+        log.error("发送邮件开始处理");
         Message message = event.getMessage();
         String channelConfig = message.getChannelConfig();
         EmailConfig emailConfig = JsonUtils.parse(channelConfig, EmailConfig.class);
@@ -46,6 +47,8 @@ public class EmailEventListener implements MessageEventListener {
             //收件人
             String[] split = emailConfig.getTo().split(",");
             messageHelper.setTo(split);
+            log.info("*************邮件告警收件人:"+emailConfig.getTo());
+            log.info("*************邮件告警内容:"+content);
 //            //标题
 //            messageHelper.setSubject(emailConfig.getTitle());
             //标题
@@ -55,6 +58,7 @@ public class EmailEventListener implements MessageEventListener {
             //发件人
             messageHelper.setFrom(emailConfig.getFrom());
             jms.send(mimeMessage);
+            log.error("发送邮件成功.");
         } catch (Exception e) {
             log.error("发送邮件失败.", e);
         }

+ 1 - 1
iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenDeviceServiceImpl.java

@@ -4,6 +4,7 @@ import cc.iotkit.common.constant.GlobalConstants;
 import cc.iotkit.common.enums.ErrCode;
 import cc.iotkit.common.exception.BizException;
 import cc.iotkit.common.redis.utils.RedisUtils;
+import cc.iotkit.common.satoken.utils.LoginHelper;
 import cc.iotkit.common.utils.DeviceUtil;
 import cc.iotkit.common.utils.JsonUtils;
 import cc.iotkit.common.utils.MapstructUtils;
@@ -64,7 +65,6 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
         String productKey = bo.getProductKey();
         String deviceName = bo.getDeviceName();
         String parentId = bo.getParentId();
-
         Product product = productData.findByProductKey(productKey);
         if (product == null) {
             throw new BizException(ErrCode.PRODUCT_NOT_FOUND);