From f8dec6bfaef15f807d760ba0fde963498fbc78f3 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Fri, 09 May 2025 03:44:17 +0000
Subject: [PATCH] 项目报销页添加上传文件提醒
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserInsuranceRepository.java | 105 ++++++++++++++++++++++++++++++++++++----------------
1 files changed, 73 insertions(+), 32 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserInsuranceRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserInsuranceRepository.java
index 98bbf2a..12a3dd4 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserInsuranceRepository.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserInsuranceRepository.java
@@ -1,33 +1,74 @@
-/*
-* Copyright 2019-2020 Zheng Jie
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package me.zhengjie.modules.treatment.repository;
-
-import me.zhengjie.modules.treatment.domain.UserInsurance;
-
-import java.util.Optional;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-/**
-* @website https://eladmin.vip
-* @author 姚增春
-* @date 2023-05-07
-**/
-public interface UserInsuranceRepository extends JpaRepository<UserInsurance, Long>, JpaSpecificationExecutor<UserInsurance> {
-
- Optional<UserInsurance> findByUserIdAndYearMonth(Long userId, String monthYear);
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.treatment.repository;
+
+import me.zhengjie.modules.treatment.domain.CmnLevelRank;
+import me.zhengjie.modules.treatment.domain.UserInsurance;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+/**
+* @website https://eladmin.vip
+* @author 姚增春
+* @date 2023-05-07
+**/
+public interface UserInsuranceRepository extends JpaRepository<UserInsurance, Long>, JpaSpecificationExecutor<UserInsurance> {
+
+ Optional<UserInsurance> findByUserIdAndYearMonth(Long userId, String monthYear);
+
+ @Query(value = "SELECT * from new_user_insurance WHERE user_id = ?1 AND `year_month` >= ?2 ORDER BY `year_month` DESC LIMIT 1",nativeQuery = true)
+ UserInsurance findbyUserIdAndDate(Long userId, String yearMonth);
+
+ @Query(value = "SELECT * FROM `new_user_insurance` WHERE user_id = ?1 AND `year_month` != ?2",nativeQuery = true)
+ UserInsurance findbyUserIdAndNotEqualTo(Long userId, String yearMonth);
+
+ @Query(value = "SELECT * FROM `new_user_insurance` WHERE user_id = ?1 AND `year_month` < ?2 ORDER BY `year_month` DESC LIMIT 1",nativeQuery = true)
+ UserInsurance findbyUserIdAndYearMonthLessThan(Long userId, String yearMonth);
+
+ @Query(value = "SELECT * FROM `new_user_insurance` WHERE user_id = ?1 AND `year_month` >= ?2",nativeQuery = true)
+ UserInsurance findbyUserIdAnYearMonthGreaterThanEqual(Long userId, String yearMonth);
+
+ @Query(value = "SELECT * FROM `new_user_insurance` WHERE user_id in (SELECT user_id FROM sys_user WHERE company_id = ?1 AND enabled is true)",nativeQuery = true)
+ List<UserInsurance> findbyCompanyId(Long companyId);
+
+ List<UserInsurance> findByUserId(Long userId);
+
+// /**
+// * 查询第二条
+// * @param companyId
+// * @return
+// */
+// @Query(value = "SELECT * FROM (\n" +
+// " SELECT *,\n" +
+// " ROW_NUMBER() OVER(PARTITION BY user_id ORDER BY id) as row_num\n" +
+// " FROM new_user_insurance\n" +
+// " WHERE user_id IN (\n" +
+// " SELECT user_id \n" +
+// " FROM sys_user \n" +
+// " WHERE company_id = ?1 AND enabled is true\n" +
+// " )\n" +
+// ") t\n" +
+// "WHERE t.row_num = 2",nativeQuery = true)
+// List<UserInsurance> findbyCompanyId(Long companyId);
+
+// @Query(value = "SELECT * from new_user_insurance WHERE user_id = ?1 ORDER BY 'year_month' DESC LIMIT 1",nativeQuery = true)
+// UserInsurance findByUserId(Long userId);
}
\ No newline at end of file
--
Gitblit v1.9.3