Преглед изворни кода

获取数据列表 按照化验ID分组,取最后一条数据 再获取列表或者分页

王苗苗 пре 5 месеци
родитељ
комит
74d268d8f5

+ 2 - 2
src/main/java/com/xlht/xlhtproject/controller/FrontController.java

@@ -117,7 +117,7 @@ public class FrontController extends BaseController{
     {
         log.info("进入了 修改碳源投加 首页-报表信息 接口");
         TShuju1 req = TShuju1.builder().timeBegin(timeBegin).timeEnd(timeEnd).build();
-        return R.ok(this.tShuju1Service.selectTShuju1List(req));
+        return R.ok(this.tShuju1Service.selectTShuju1ListGroupByAssayId(req));
     }
 
 
@@ -133,7 +133,7 @@ public class FrontController extends BaseController{
             throw new RuntimeException("请输入分页参数");
         TShuju1 req = TShuju1.builder().timeBegin(timeBegin).timeEnd(timeEnd).build();
         PageHelper.startPage(pageNum, pageSize);
-        return getDataTable(this.tShuju1Service.selectTShuju1List(req));
+        return getDataTable(this.tShuju1Service.selectTShuju1ListGroupByAssayId(req));
     }
 
 

+ 2 - 0
src/main/java/com/xlht/xlhtproject/mapper/TShuju1Mapper.java

@@ -65,4 +65,6 @@ public interface TShuju1Mapper
     SmartAdd getNewestData();
 
     int selectCountDistinctAssayNo();
+
+    List<TShuju1> selectTShuju1ListGroupByAssayId(TShuju1 req);
 }

+ 2 - 0
src/main/java/com/xlht/xlhtproject/service/ITShuju1Service.java

@@ -58,4 +58,6 @@ public interface ITShuju1Service
      * @return 结果
      */
     public int deleteTShuju1ByID(Long ID);
+
+    List<TShuju1> selectTShuju1ListGroupByAssayId(TShuju1 req);
 }

+ 7 - 1
src/main/java/com/xlht/xlhtproject/service/impl/TShuju1ServiceImpl.java

@@ -1,5 +1,6 @@
 package com.xlht.xlhtproject.service.impl;
 
+import java.util.Collections;
 import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -14,7 +15,7 @@ import com.xlht.xlhtproject.service.ITShuju1Service;
  * @date 2024-09-19
  */
 @Service
-public class TShuju1ServiceImpl implements ITShuju1Service 
+public class TShuju1ServiceImpl implements ITShuju1Service
 {
     @Autowired
     private TShuju1Mapper tShuju1Mapper;
@@ -90,4 +91,9 @@ public class TShuju1ServiceImpl implements ITShuju1Service
     {
         return tShuju1Mapper.deleteTShuju1ByID(ID);
     }
+
+    @Override
+    public List<TShuju1> selectTShuju1ListGroupByAssayId(TShuju1 req) {
+        return tShuju1Mapper.selectTShuju1ListGroupByAssayId(req);
+    }
 }

+ 16 - 0
src/main/resources/mapper/TShuju1Mapper.xml

@@ -266,6 +266,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by id desc
     </select>
 
+
+    <select id="selectTShuju1ListGroupByAssayId" parameterType="TShuju1" resultMap="TShuju1Result">
+        SELECT
+            A.*
+        FROM
+            T_SHUJU_1 A
+                INNER JOIN ( SELECT MAX ( ID ) ID FROM T_SHUJU_1 WHERE 1 = 1
+        <!-- 下面是新增的SQL检索条件  SqlServer写法-->
+        <if test="timeBegin != null  and timeBegin != ''"> and SUBSTRING (TIME, 1, 10 ) &gt;= #{timeBegin}</if>
+        <if test="timeEnd != null  and timeEnd != ''"> and SUBSTRING (TIME, 1, 10 ) &lt;= #{timeEnd}</if>
+            GROUP BY jqr_ID ) AS B ON A.ID = B.ID
+        ORDER BY
+            A.ID DESC
+    </select>
+
+
     <select id="selectCountDistinctAssayNo" resultType="int">
         SELECT COUNT(DISTINCT jqr_ID) FROM T_SHUJU_1
     </select>