Ver Fonte

Merge branch 'master' of http://39.101.69.29:3000/wangb/runeconomy-nx

王波 há 1 mês atrás
pai
commit
bbc125dd4b

+ 6 - 22
runeconomy-xk/src/main/java/com/gyee/runeconomy/service/ShutdownEvent2Service.java

@@ -1,8 +1,6 @@
 package com.gyee.runeconomy.service;
 
-import cn.hutool.core.date.DateUnit;
-import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.runeconomy.model.auto.ProEconShutdownEvent2;
 import com.gyee.runeconomy.service.auto.IProEconShutdownEvent2Service;
@@ -11,7 +9,6 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.Date;
-import java.util.Iterator;
 
 @Service
 public class ShutdownEvent2Service {
@@ -32,31 +29,18 @@ public class ShutdownEvent2Service {
         if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {
 
             //构造条件构造器
-            LambdaQueryWrapper<ProEconShutdownEvent2> queryWrapper = new LambdaQueryWrapper<>();
+            QueryWrapper<ProEconShutdownEvent2> queryWrapper = new QueryWrapper<>();
             //添加过滤条件
 
-
-            queryWrapper.eq(ProEconShutdownEvent2::getWindturbineId, wtId).
-                    ge(ProEconShutdownEvent2::getStopTime, beginDate).
-                    le(ProEconShutdownEvent2::getStopTime, endDate);
+            queryWrapper.eq("windturbine_id", wtId)
+                    .ge("stop_time", beginDate)
+                    .le("stop_time", endDate)
+                    .apply("EXTRACT(EPOCH FROM (start_time - stop_time)) / 60 > 10");
 
             //执行查询
             proEconShutdownEvent2Service.page(pageInfo, queryWrapper);
         }
 
-        Iterator<ProEconShutdownEvent2> iterator = pageInfo.getRecords().iterator();
-        while (iterator.hasNext()) {
-            ProEconShutdownEvent2 record = iterator.next();
-            Date stopTime = record.getStopTime();
-            Date startTime = record.getStartTime();
-            long minutes = DateUtil.between(startTime, stopTime, DateUnit.MINUTE);
-
-            // 如果间隔小于 10 分钟,移除该记录
-            if (Math.abs(minutes) < 10) {
-                iterator.remove();
-            }
-        }
-
         return pageInfo;
 
     }