From 6b5c8b69c7fd9a816cefb805d71daaf64b3dabf3 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 07 三月 2025 17:25:02 +0800
Subject: [PATCH] 权限

---
 ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java                |   23 ++++++++++++++++-------
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java             |   10 ++++++----
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java             |    1 +
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java           |   13 ++++++++-----
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCheckAcceptRecordServiceImpl.java |    8 ++++----
 5 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
index eb12c0a..8a363c6 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
@@ -92,12 +92,13 @@
     @PostMapping(value = "/addContract")
     @PreAuthorize("@ss.hasPermi('contract:list:add')")
     public R<Boolean> addContract(@Validated @RequestBody TContractDTO dto) {
+        LocalDateTime changeTime = dto.getChangeTime();
         long count = contractService.count(new LambdaQueryWrapper<TContract>().eq(TContract::getContractNumber, dto.getContractNumber()));
         if (count!=0){
             return R.fail("合同编号不可重复");
         }
         dto.setChangeRent(dto.getMonthRent());
-
+        dto.setChangeTime(null);
         contractService.save(dto);
         if (dto.getStatus().equals("2")){
             //发起合同新增审批
@@ -135,7 +136,7 @@
             tContractRentType.setIncreasingDecreasing(dto.getIncreasingDecreasing());
             tContractRentType.setIncreasingDecreasingType(dto.getIncreasingDecreasingType());
             tContractRentType.setNumericalValue(dto.getNumericalValue());
-            tContractRentType.setChangeTime(dto.getChangeTime());
+            tContractRentType.setChangeTime(changeTime);
             tContractRentType.setCycleTime(dto.getCycleTime());
             contractRentTypeService.save(tContractRentType);
         }
@@ -146,6 +147,7 @@
     @PostMapping(value = "/updateContract")
     @PreAuthorize("@ss.hasPermi('contract:list:edit')")
     public R<Boolean> updateContract(@Validated @RequestBody TContractDTO dto) {
+        dto.setChangeTime(null);
         contractService.updateById(dto);
         contractRentTypeService.remove(new LambdaQueryWrapper<TContractRentType>()
                 .eq(TContractRentType::getContractId,dto.getId()));
@@ -223,14 +225,14 @@
         res.setHouse(house);
         List<TBill> list = billService.lambdaQuery()
                 .eq(TBill::getContractId, id)
-                .in(TBill::getPayFeesStatus, Arrays.asList("1,4"))
+                .ne(TBill::getPayFeesStatus, 3)
                 .list();
         BigDecimal payMoney = new BigDecimal("0");
         for (TBill tBill : list) {
             payMoney = payMoney.add(tBill.getOutstandingMoney()).add(tBill.getPayableFeesPenalty());
         }
         TCheckAcceptRecord tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery().eq(TCheckAcceptRecord::getContractId, id).one();
-        res.setCheckResult(Objects.nonNull(tCheckAcceptRecord)&&Objects.nonNull(tCheckAcceptRecord.getCheckResult())?tCheckAcceptRecord.getCheckResult():false);
+        res.setCheckResult(Objects.nonNull(tCheckAcceptRecord)&&Objects.nonNull(tCheckAcceptRecord.getCheckResult())?tCheckAcceptRecord.getCheckResult():null);
         res.setPayMoney(payMoney);
 
         return R.ok(res);
diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java
index b6939b8..c205b59 100644
--- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java
+++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java
@@ -28,6 +28,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -225,9 +226,15 @@
             myToDoVO.setExamineCount((int) processTaskListVOPageInfo.getTotal());
             List<String> contractIds = billService.lambdaQuery().eq(TBill::getPayFeesStatus, 4).list()
                     .stream().map(TBill::getContractId).collect(Collectors.toList());
-            int overdueCount = contractService.lambdaQuery().in(TContract::getId, contractIds).list()
-                    .stream().map(TContract::getTenantId).distinct().collect(Collectors.toList()).size();
-            myToDoVO.setOverdueCount(overdueCount);
+            if(contractIds.isEmpty()){
+                myToDoVO.setOverdueCount(0);
+
+            }else{
+                int overdueCount = contractService.lambdaQuery().in(TContract::getId, contractIds).list()
+                        .stream().map(TContract::getTenantId).distinct().collect(Collectors.toList()).size();
+                myToDoVO.setOverdueCount(overdueCount);
+            }
+
         } else {
             myToDoVO.setExamineCount(0);
             myToDoVO.setOverdueCount(0);
@@ -251,10 +258,11 @@
     @GetMapping(value = "/getDetailById")
     public R<TCheckAcceptRecordVO> getDetailById(@RequestParam String id) {
         TCheckAcceptRecord checkAcceptRecord = checkAcceptRecordService.getById(id);
-        checkAcceptRecord.setCleanSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getCleanSituation()));
-        checkAcceptRecord.setOverallSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getOverallSituation()));
-        checkAcceptRecord.setDeviceSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getDeviceSituation()));
-        checkAcceptRecord.setFurnitureSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getFurnitureSituation()));
+//        checkAcceptRecord.setCleanSituation(checkAcceptRecord.getCleanSituation());
+//        checkAcceptRecord.setOverallSituation(StringUtils.hasLength(checkAcceptRecord.getOverallSituation())?(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,checkAcceptRecord.getOverallSituation())):"");
+//        checkAcceptRecord.setDeviceSituation(StringUtils.hasLength(checkAcceptRecord.getDeviceSituation())?(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,checkAcceptRecord.getDeviceSituation())):"");
+//        checkAcceptRecord.setFurnitureSituation(StringUtils.hasLength(checkAcceptRecord.getDeviceSituation())?(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,checkAcceptRecord.getFurnitureSituation())):"");
+
         TCheckAcceptRecordVO checkAcceptRecordVO = new TCheckAcceptRecordVO();
         BeanUtils.copyProperties(checkAcceptRecord, checkAcceptRecordVO);
         // 查询合同信息
@@ -276,6 +284,7 @@
         dto.setCode(replace.substring(2)+String.format("%03d", size+1));
         dto.setStatus(true);
         // 添加验收记录
+        dto.setCheckPerson(tokenService.getLoginUser().getUser().getNickName());
         checkAcceptRecordService.updateById(dto);
         return R.ok();
     }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java
index 1c0db15..e4f3ba8 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java
@@ -443,6 +443,7 @@
                                         }
                                     }else{
                                         if (tContractRentType.getChangeTime().isBefore(tBill.getEndTime()) && tContractRentType.getChangeTime().isAfter(tBill.getStartTime())) {
+                                            System.err.println("首次递增递减");
                                             contract.setChangeTime(tContractRentType.getChangeTime());
                                             // 租金递增递减的时长 天
                                             long moneyDays = Math.abs(ChronoUnit.DAYS.between(tContractRentType.getChangeTime(), tBill.getEndTime()));
@@ -487,7 +488,9 @@
                                             tBill.setPayableFeesMoney(contractRentTypeMoney.add(originalMoney));
                                             tBill.setOutstandingMoney(tBill.getPayableFeesMoney());
                                             contractService.updateById(contract);
-
+                                        }else{
+                                            tBill.setPayableFeesMoney(contract.getChangeRent().multiply(new BigDecimal(contract.getPayType().equals("1") ? 1 : contract.getPayType().equals("2") ? 3 : 12)));
+                                            tBill.setOutstandingMoney(tBill.getPayableFeesMoney());
                                         }
                                     }
                                 } else {
@@ -533,7 +536,7 @@
                                 if (changeTime.isBefore(tBill.getEndTime()) && changeTime.isAfter(tBill.getStartTime())) {
                                     contract.setChangeTime(changeTime);
                                     // 租金递增递减的时长 天
-                                    long moneyDays = Math.abs(ChronoUnit.DAYS.between(tContractRentType.getChangeTime(), tBill.getEndTime()));
+                                    long moneyDays = Math.abs(ChronoUnit.DAYS.between(changeTime, tBill.getEndTime()));
                                     // 递增递减的租金
                                     BigDecimal contractRentTypeMoney = new BigDecimal("0");
                                     // 不递增递减的租金
@@ -567,7 +570,7 @@
                                             break;
                                     }
                                     // 不需要涨租金的时间段
-                                    long originalDays = ChronoUnit.DAYS.between(beforeBill.getEndTime(), tContractRentType.getChangeTime());
+                                    long originalDays = ChronoUnit.DAYS.between(beforeBill.getEndTime(), changeTime);
                                     if (originalDays > 0) {
                                         originalMoney = originalMoney.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN))
                                                 .multiply(new BigDecimal(originalDays));
@@ -576,8 +579,8 @@
                                     tBill.setOutstandingMoney(tBill.getPayableFeesMoney());
                                     contractService.updateById(contract);
                                 } else {
-                                    // 不涨租金 用上次的
-                                    tBill.setPayableFeesMoney(contract.getChangeRent().multiply(new BigDecimal(contract.getPayType().equals("1")?1:contract.getPayType().equals("2")?3:12)));
+                                    long finalDays = ChronoUnit.DAYS.between(beforeBill.getEndTime(), contract.getEndTime());
+                                    tBill.setPayableFeesMoney(contract.getChangeRent().divide(new BigDecimal("30"),2,BigDecimal.ROUND_DOWN).multiply(new BigDecimal(finalDays)));
                                     tBill.setOutstandingMoney(tBill.getPayableFeesMoney());
                                 }
                             }else{
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCheckAcceptRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCheckAcceptRecordServiceImpl.java
index f4e9e68..7006063 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCheckAcceptRecordServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCheckAcceptRecordServiceImpl.java
@@ -58,10 +58,10 @@
         PageInfo<TCheckAcceptRecordVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
         List<TCheckAcceptRecordVO> list = this.baseMapper.pageListApplet(query,pageInfo);
         list.forEach(item -> {
-            item.setCleanSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getCleanSituation()));
-            item.setOverallSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getOverallSituation()));
-            item.setDeviceSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getDeviceSituation()));
-            item.setFurnitureSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getFurnitureSituation()));
+            item.setCleanSituation(StringUtils.hasLength(item.getCleanSituation()) ?(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getCleanSituation())):"");
+            item.setOverallSituation(StringUtils.hasLength(item.getOverallSituation())?(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getOverallSituation())):"");
+            item.setDeviceSituation(StringUtils.hasLength(item.getDeviceSituation())?(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getDeviceSituation())):"");
+            item.setFurnitureSituation(StringUtils.hasLength(item.getDeviceSituation())?(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION,item.getFurnitureSituation())):"");
             item.setContract(tContracts.stream().filter(contract -> contract.getId().equals(item.getContractId())).findFirst().orElse(null));
             item.setHouse(tHouses.stream().filter(house -> house.getId().equals(item.getHouseId())).findFirst().orElse(null));
         });
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java
index 593d888..a2a49d9 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java
@@ -62,6 +62,7 @@
         List<HouseVO> list = this.baseMapper.userHistoryList(query,pageInfo);
         for (HouseVO houseVO : list) {
             houseVO.setTenantAttributes(StringUtils.isNotEmpty(houseVO.getTenantAttributes())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_ATTRIBUTE,houseVO.getTenantAttributes()):"");
+            houseVO.setProductType(StringUtils.isNotEmpty(houseVO.getProductType())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_TYPE,houseVO.getProductType()):"");
         }
         pageInfo.setRecords(list);
         return pageInfo;

--
Gitblit v1.7.1