TRX 1 gadu atpakaļ
vecāks
revīzija
6a53ff6594

+ 17 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/base/BaseImpl.java

@@ -2,10 +2,13 @@ package com.zhongshu.iot.server.core.dao.base;
 
 import com.zhongshu.iot.client.model.baseParam.SuperSearchParam;
 import com.zhongshu.iot.server.core.util.CommonUtil;
+import com.zhongshu.iot.server.core.util.DateUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.query.Criteria;
 
+import java.util.List;
+
 /**
  * @author TRX
  * @date 2024/5/31
@@ -28,6 +31,20 @@ public abstract class BaseImpl {
         Criteria criteria = new Criteria();
         criteria.and("isDelete").ne(Boolean.TRUE);
 
+        if (ObjectUtils.isNotEmpty(param.getTimes()) && param.getTimes().size() == 2) {
+            List<Long> times = param.getTimes();
+            param.setStartTime(times.get(0));
+            param.setEndTime(times.get(1));
+        }
+
+        if (CommonUtil.longIsEmpty(param.getStartTime())) {
+            param.setStartTime(DateUtils.getDayStartTime(param.getStartTime()));
+        }
+
+        if (CommonUtil.longIsEmpty(param.getEndTime())) {
+            param.setEndTime(DateUtils.getDayEndTime(param.getEndTime()));
+        }
+
         if (!CommonUtil.longIsEmpty(param.getStartTime()) && !CommonUtil.longIsEmpty(param.getEndTime())) {
             criteria.and("createTime").gte(param.getStartTime()).lte(param.getEndTime());
         } else if (!CommonUtil.longIsEmpty(param.getStartTime()) && CommonUtil.longIsEmpty(param.getEndTime())) {

+ 0 - 5
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/impl/OperationMessageResultDaoImpl.java

@@ -73,11 +73,6 @@ public class OperationMessageResultDaoImpl extends BaseImpl implements Operation
             criteria.and("operationType").is(param.getOperationType());
         }
 
-        // 时间范围
-        if (!CommonUtil.longIsEmpty(param.getStartTime()) && !CommonUtil.longIsEmpty(param.getEndTime())) {
-            criteria.and("createTime").gte(param.getStartTime()).lte(param.getEndTime());
-        }
-
         // 模糊搜索
         List<Criteria> criterias = new ArrayList<>();
         if (StringUtils.isNotEmpty(param.getRealIotTopic())) {