Эх сурвалжийг харах

首页 - 学习资料当月没有文件则显示上月数据,以此类推

Wang Zi Wen 1 жил өмнө
parent
commit
1a3cdc3c90

+ 15 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/branch/TBranchManageController.java

@@ -58,15 +58,21 @@ public class TBranchManageController extends BaseController {
         int year = calendar.get(Calendar.YEAR);//年
         int month = calendar.get(Calendar.MONTH) + 1;//月
 
-        TBranchManage tBranchManage = new TBranchManage();
-        tBranchManage.setYear(year + "");
-        tBranchManage.setMonthly(month + "");
-        List<TBranchManage> tBranchManages = tBranchManageService.selectTBranchManageList(tBranchManage);
-
-        TFile tFile = new TFile();
-        tFile.setTableName("branchManage");
-        tFile.setTableId(tBranchManages.get(0).getManageId());
-        List<TFile> tFiles = tFileService.selectTFileList(tFile);
+        List<TFile> tFiles = null;
+
+        do {
+            TBranchManage tBranchManage = new TBranchManage();
+            tBranchManage.setYear(year + "");
+            tBranchManage.setMonthly(month + "");
+            List<TBranchManage> tBranchManages = tBranchManageService.selectTBranchManageList(tBranchManage);
+
+            TFile tFile = new TFile();
+            tFile.setTableName("branchManage");
+            tFile.setTableId(tBranchManages.get(0).getManageId());
+            tFiles = tFileService.selectTFileList(tFile);
+
+            month -= 1;
+        } while (tFiles.size() == 0);
 
         return AjaxResult.success(tFiles);
     }