瀏覽代碼

离线设备查询2.0-完善动态分页查询功能

fuyuhchuan 1 年之前
父節點
當前提交
99460e196e

+ 0 - 27
service-backend/service-backend-api/pom.xml

@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>service-backend</artifactId>
-        <groupId>com.usky</groupId>
-        <version>0.0.1</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>service-backend-api</artifactId>
-    <!-- SpringCloud Openfeign -->
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-openfeign</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.usky</groupId>
-            <artifactId>usky-common-core</artifactId>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <finalName>${project.artifactId}</finalName>
-    </build>
-
-</project>

+ 2 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/mapper/BaseBuildFacilityMapper.java

@@ -5,6 +5,7 @@ import com.usky.iot.domain.BaseBuildFacility;
 import com.usky.common.mybatis.core.CrudMapper;
 import com.usky.iot.domain.BaseBuildFacilityType;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
 
 import java.util.List;
 
@@ -16,6 +17,7 @@ import java.util.List;
  * @author han
  * @since 2023-07-26
  */
+@Repository
 public interface BaseBuildFacilityMapper extends CrudMapper<BaseBuildFacility> {
     BaseBuildFacilityType baseBuildFacilityTypeList(@Param("facilityType") String facilityType);
     List<BaseBuild> getBuildName(@Param("buildIdList") List<Integer> buildIdList);

+ 2 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/mapper/BaseBuildFacilityTypeMapper.java

@@ -2,6 +2,7 @@ package com.usky.iot.mapper;
 
 import com.usky.iot.domain.BaseBuildFacilityType;
 import com.usky.common.mybatis.core.CrudMapper;
+import org.springframework.stereotype.Repository;
 
 /**
  * <p>
@@ -11,6 +12,7 @@ import com.usky.common.mybatis.core.CrudMapper;
  * @author han
  * @since 2023-07-26
  */
+@Repository
 public interface BaseBuildFacilityTypeMapper extends CrudMapper<BaseBuildFacilityType> {
 
 }

+ 2 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/mapper/DmpProductAttributeMapper.java

@@ -2,6 +2,7 @@ package com.usky.iot.mapper;
 
 import com.usky.common.mybatis.core.CrudMapper;
 import com.usky.iot.domain.DmpProductAttribute;
+import org.springframework.stereotype.Repository;
 
 
 /**
@@ -12,6 +13,7 @@ import com.usky.iot.domain.DmpProductAttribute;
  * @author ya
  * @since 2022-10-08
  */
+@Repository
 public interface DmpProductAttributeMapper extends CrudMapper<DmpProductAttribute> {
 
 }

+ 0 - 0
service-issue/service-issue-biz/git


+ 3 - 1
service-issue/service-issue-biz/src/main/java/com/usky/issue/mapper/YtDeviceStatusMapper.java

@@ -17,5 +17,7 @@ import java.util.List;
  */
 @Repository
 public interface YtDeviceStatusMapper extends CrudMapper<YtDeviceStatus> {
-    List<YtDeviceStatus> getDeviceStatusType(@Param("deviceType") String deviceType);
+    List<YtDeviceStatus> getDeviceStatusType(@Param("deviceType") String deviceType,
+                                             @Param("Current") int Current,
+                                             @Param("Size") int Size);
 }

+ 20 - 30
service-issue/service-issue-biz/src/main/java/com/usky/issue/service/impl/YtDeviceStatusServiceImpl.java

@@ -30,41 +30,31 @@ public class YtDeviceStatusServiceImpl extends AbstractCrudService<YtDeviceStatu
     @Override
     public CommonPage<YtDeviceStatus> page(YtDeviceStatusRequestVO requestVO) {
 
-//        IPage<YtDeviceStatus> page = new Page<>(requestVO.getCurrent(),requestVO.getSize());
-//        LambdaQueryWrapper<YtDeviceStatus> queryWrapper = Wrappers.lambdaQuery();
-//        queryWrapper.eq(StringUtils.isNotBlank(requestVO.getDeviceType()),YtDeviceStatus::getDeviceType,
-//                requestVO.getDeviceType())
-//                .orderByDesc(YtDeviceStatus::getDeviceType);
-//        page  = this.page(page,queryWrapper);
-//        return new CommonPage<>(page.getRecords(),page.getTotal(),page.getSize(),page.getCurrent());
+        String deviceType = requestVO.getDeviceType();
+        int pageCurrent = requestVO.getCurrent();
+        int pageSize = requestVO.getSize();
 
-//        LambdaQueryWrapper<YtDeviceStatus> queryWrapper = Wrappers.lambdaQuery();
-//        queryWrapper.eq(requestVO.getDeviceType() != null,YtDeviceStatus::getId,requestVO.getDeviceType())
-//                .eq(StringUtils.isNotBlank(requestVO.getDeviceType()),YtDeviceStatus::getDeviceType,requestVO.getDeviceType())
-//                .orderByDesc(YtDeviceStatus::getId);
+        List<YtDeviceStatus> list = ytDeviceStatusMapper.getDeviceStatusType(deviceType, pageCurrent, pageSize);
+        // 计算总记录数
+        int total = list.size();
 
+        // 计算总页数
+        int current = (total + pageSize - 1) / pageSize;
 
-        List<YtDeviceStatus> list = ytDeviceStatusMapper.getDeviceStatusType(requestVO.getDeviceType());
-        Integer total = list.size();
-        if (total == 0) {
-            return null;
-        }
+        // 计算当前页的起始索引
+        int startIndex = (pageCurrent - 1) * pageSize;
 
-        Integer pageSize = 10;
-        if (total < pageSize) {
-            pageSize = total;
-        }
+        //对传入类型进行判断筛选
+        List<YtDeviceStatus> filteredList = list.stream()
+                .filter(device -> device.getDeviceType().equals(deviceType))
+                .collect(Collectors.toList());
 
-        Integer pageCurrent = 1;
-        if (total < 0) {
-            pageCurrent = (total / pageSize) + 1;
-        }
-
-        Integer current = (pageCurrent - 1) * pageSize;
-
-        List<YtDeviceStatus> records = list.stream().skip(current).limit(pageSize).collect(Collectors.toList());
+        // 对记录进行分页操作
+        List<YtDeviceStatus> records = filteredList.stream()
+                .skip(startIndex)//跳过startIndex个元素,从startIndex+1开始
+                .limit(pageSize)//限制显示大小,只处理pageSize个元素
+                .collect(Collectors.toList());//将流中的元素收集到List<YtDeviceStatus> == 获取当前页记录
 
         return new CommonPage<>(records, total, pageSize, pageCurrent);
     }
-
-}
+}

+ 1 - 0
service-issue/service-issue-biz/src/main/java/com/usky/issue/service/vo/YtDeviceStatusRequestVO.java

@@ -24,5 +24,6 @@ public class YtDeviceStatusRequestVO {
      * 设备类型
      */
     private String deviceType;
+
 }
 

+ 1 - 12
service-issue/service-issue-biz/src/main/resources/mapper/issue/YtDeviceStatusMapper.xml

@@ -16,17 +16,6 @@
         <result column="difference" property="difference"/>
     </resultMap>
 
-    <!--    <select id="YtDeviceStatusTypeList" resultType="com.usky.issue.domain.YtDeviceStatus">
-            select
-                yds.*
-            from yt_device_status yds
-            <where>
-                <if test="1 == 1">
-                    AND yds.deviceType = #{deviceType}
-                </if>
-            </where>
-        </select>-->
-
     <select id="getDeviceStatusType" resultType="com.usky.issue.domain.YtDeviceStatus">
         select
         device_code,device_name,address,device_type,company_name,company_code,data_time
@@ -41,7 +30,7 @@
                 '10363','10368','10371','10341','10375','10373','10126','10374','10376','10378')
                 AND difference > 48
         </where>
-
+        order by company_code asc
     </select>
 
 </mapper>

+ 0 - 70
usky-module-demo/usky-module-demo-biz/pom.xml

@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>usky-module-demo</artifactId>
-        <groupId>com.usky</groupId>
-        <version>0.0.1</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>usky-module-demo-biz</artifactId>
-    <dependencies>
-        <dependency>
-            <groupId>com.usky</groupId>
-            <artifactId>common-cloud-starter</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <!-- Pagehelper -->
-        <dependency>
-            <groupId>com.github.pagehelper</groupId>
-            <artifactId>pagehelper-spring-boot-starter</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>com.usky</groupId>
-            <artifactId>ruoyi-common-swagger</artifactId>
-        </dependency>
-
-    </dependencies>
-
-    <build>
-        <finalName>${project.artifactId}</finalName>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-                <version>2.2.6.RELEASE</version>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>repackage</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>com.github.shalousun</groupId>
-                <artifactId>smart-doc-maven-plugin</artifactId>
-                <version>2.1.1</version>
-                <configuration>
-                    <!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
-                    <configFile>./src/main/resources/smart-doc.json</configFile>
-                    <!--指定项目名称-->
-                    <projectName>test</projectName>
-                    <!--                    <excludes>-->
-                    <!--                        <exclude>com.bizmatics:product-service-provider</exclude>-->
-                    <!--                        <exclude>cn.afterturn:easypoi-web</exclude>-->
-                    <!--                    </excludes>-->
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>