Explorar el Código

数据中心:修复分页查询每次称重记录。

zhuoning hace 3 años
padre
commit
d15c8debca

+ 2 - 2
huimv-farm-produce/src/main/java/com/huimv/produce/produce/repo/ProdBatchWeightRepo.java

@@ -10,8 +10,8 @@ import java.util.Date;
 
 
 public interface ProdBatchWeightRepo extends JpaRepository<ProdBatchWeightEntity, Integer>, JpaSpecificationExecutor<ProdBatchWeightEntity> {
 public interface ProdBatchWeightRepo extends JpaRepository<ProdBatchWeightEntity, Integer>, JpaSpecificationExecutor<ProdBatchWeightEntity> {
     //
     //
-    @Query(nativeQuery = true,value = "SELECT * FROM prod_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d') ORDER BY id DESC",
-            countQuery = "SELECT COUNT(*) FROM prod_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d')")
+    @Query(nativeQuery = true,value = "SELECT * FROM prod_batch_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d') ORDER BY id DESC",
+            countQuery = "SELECT COUNT(*) FROM prod_batch_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d')")
     Page<ProdBatchWeightEntity> findByFarmIdAndStartDateAndEndDate(Integer farmId, Date startDate, Date endDate, Pageable pageable);
     Page<ProdBatchWeightEntity> findByFarmIdAndStartDateAndEndDate(Integer farmId, Date startDate, Date endDate, Pageable pageable);
 
 
 }
 }

+ 2 - 2
huimv-farm-produce/src/main/java/com/huimv/produce/produce/repo/ProdWeightRepo.java

@@ -10,8 +10,8 @@ import java.util.Date;
 
 
 public interface ProdWeightRepo extends JpaRepository<ProdWeightEntity, Integer>, JpaSpecificationExecutor<ProdWeightEntity> {
 public interface ProdWeightRepo extends JpaRepository<ProdWeightEntity, Integer>, JpaSpecificationExecutor<ProdWeightEntity> {
     //
     //
-    @Query(nativeQuery = true,value = "SELECT * FROM prod_batch_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d') ORDER BY id DESC",
-            countQuery = "SELECT COUNT(*) FROM prod_batch_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d')")
+    @Query(nativeQuery = true,value = "SELECT * FROM prod_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d') ORDER BY id DESC",
+            countQuery = "SELECT COUNT(*) FROM prod_weight WHERE farm_id=?1 AND DATE_FORMAT(add_time,'%Y-%m-%d')>=DATE_FORMAT(?2,'%Y-%m-%d') AND DATE_FORMAT(add_time,'%Y-%m-%d')<=DATE_FORMAT(?3,'%Y-%m-%d')")
     Page<ProdWeightEntity> findWeightByFarmIdAndStartDateAndEndDate(Integer farmId, Date startDate, Date endDate, Pageable pageable);
     Page<ProdWeightEntity> findWeightByFarmIdAndStartDateAndEndDate(Integer farmId, Date startDate, Date endDate, Pageable pageable);
 
 
 }
 }

+ 10 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/produce/service/impl/WeightImpl.java

@@ -225,6 +225,16 @@ public class WeightImpl implements IWeight {
         return new Result(ResultCode.SUCCESS, batchWeightRepo.findByFarmIdAndStartDateAndEndDate(farmId, startDate, endDate, pageable));
         return new Result(ResultCode.SUCCESS, batchWeightRepo.findByFarmIdAndStartDateAndEndDate(farmId, startDate, endDate, pageable));
     }
     }
 
 
+    /**
+     * @Method      : getEveryTimeWeightOnPage
+     * @Description : 
+     * @Params      : [farmId, startDate, endDate, pageNo, pageSize]
+     * @Return      : com.huimv.common.utils.Result
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/12/22       
+     * @Time        : 19:33
+     */
     @Override
     @Override
     public Result getEveryTimeWeightOnPage(Integer farmId, Date startDate, Date endDate, Integer pageNo, Integer pageSize) throws ParseException {
     public Result getEveryTimeWeightOnPage(Integer farmId, Date startDate, Date endDate, Integer pageNo, Integer pageSize) throws ParseException {
         Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.Direction.DESC, "id");
         Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.Direction.DESC, "id");