From cd3d553f88fb74f1b15eca9fd50b4318956fb01d Mon Sep 17 00:00:00 2001
From: yupeng <roc__yu@163.com>
Date: 星期二, 15 四月 2025 10:51:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into xizang-changyun

---
 ruoyi-system/src/main/java/com/ruoyi/system/task/utils/TaskUtil.java                          |    4 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java               |  302 +++++++++++++++++++++++++++++++++++++-----
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StateProcessTemplateServiceImpl.java |   22 +++
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRentalReturnRecordServiceImpl.java  |    3 
 ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java                         |    1 
 pom.xml                                                                                       |   28 +--
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/WordUtil.java                         |   18 +-
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/SysFileController.java                 |   25 +++
 8 files changed, 336 insertions(+), 67 deletions(-)

diff --git a/pom.xml b/pom.xml
index fbf1dea..b573aee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,24 +87,18 @@
             </dependency>
 
             <!-- excel工具 -->
-           <dependency>
-               <groupId>org.apache.poi</groupId>
-               <artifactId>poi-ooxml</artifactId>
-               <version>${poi.version}</version>
-           </dependency>
+            <!-- Apache POI核心依赖 -->
+            <dependency>
+                <groupId>org.apache.poi</groupId>
+                <artifactId>poi</artifactId>
+                <version>3.17</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.poi</groupId>
+                <artifactId>poi-ooxml</artifactId>
+                <version>3.17</version>
+            </dependency>
 
-
-           <dependency>
-               <groupId>org.apache.poi</groupId>
-               <artifactId>poi</artifactId>
-               <version>${poi.version}</version>
-           </dependency>
-
-           <dependency>
-               <groupId>org.apache.poi</groupId>
-               <artifactId>poi-ooxml-schemas</artifactId>
-               <version>${poi.version}</version>
-           </dependency>
 
             <!-- velocity代码生成使用模板 -->
             <dependency>
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/SysFileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/SysFileController.java
index b213e84..097a86e 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/SysFileController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/SysFileController.java
@@ -1,8 +1,18 @@
 package com.ruoyi.web.controller.api;
 
 
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.util.Units;
+import org.apache.poi.xwpf.usermodel.*;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -16,7 +26,22 @@
 @RequestMapping("/sys-file")
 public class SysFileController {
 
+    public static void main(String[] args) throws IOException, InvalidFormatException {
+        XWPFDocument document= new XWPFDocument();
+        FileOutputStream out = new FileOutputStream(new File("D:\\a.docx"));
+        //基本信息表格
+        XWPFParagraph pic = document.createParagraph();
+        XWPFRun picRun = pic.createRun();
+            picRun.addPicture(
+                    new FileInputStream("C:\\Users\\Admin\\Pictures\\Camera Roll\\1.jpg"),XWPFDocument.PICTURE_TYPE_JPEG,
+                    "C:\\Users\\Admin\\Pictures\\Camera Roll\\1.jpg",
+                    Units.toEMU(60),
+                    Units.toEMU(30)
+            );
 
+        document.write(out);
+        out.close();
+    }
 
 }
 
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 3bdf4f4..7cf2d9f 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
@@ -71,6 +71,7 @@
 import java.net.URLEncoder;
 import java.time.LocalDateTime;
 import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -365,7 +366,7 @@
         List<TContract> list = contractService.lambdaQuery().in(TContract::getId, dto.getIds()).list();
         List<String> res = new ArrayList<>();
         for (TContract contract : list) {
-            String url = generateContract(contract);
+            String url = generateContract(contract,new TContractDTO());
             res.add(url);
         }
 
@@ -384,7 +385,7 @@
 
     }
 
-    private String generateContract(TContract contract) {
+    private String generateContract(TContract contract,TContractDTO dto) {
         String templateFileName = "1_yzj_租赁合同_个人.docx";
         String contractId = contract.getId();
         TBill firstBill = null;
@@ -426,10 +427,10 @@
             fill(templateParam, "email", tenant.getEmail());
 
             // 企业、政府机构、国有企业
-            if (Objects.nonNull(tenant.getTenantType())
-                    && (tenant.getTenantType().equals("2")
-                    || tenant.getTenantType().equals("5")
-                    || tenant.getTenantType().equals("7"))) {
+            if (Objects.nonNull(tenant.getTenantAttributes())
+                    && (tenant.getTenantAttributes().equals("2")
+                    || tenant.getTenantAttributes().equals("5")
+                    || tenant.getTenantAttributes().equals("7"))) {
                 fill(templateParam, "creditCode", tenant.getCreditCode());
                 fill(templateParam, "legalPerson", tenant.getLegalPerson());
                 templateFileName = "1_yzj_租赁合同_企业.docx";
@@ -484,39 +485,30 @@
                 : contract.getPayType().equals("2") ? "季"
                 : "年";
         fill(templateParam, "payType", payType);
-
-        // 首期租金处理
-        if (firstBill != null) {
-            double firstRent = (contract.getPayType().equals("1")
-                    ? contract.getMonthRent()
-                    : contract.getPayType().equals("2")
-                    ? contract.getMonthRent().multiply(new BigDecimal("3"))
-                    : contract.getMonthRent().multiply(new BigDecimal("12")))
-                    .setScale(2, RoundingMode.DOWN).doubleValue();
-            fill(templateParam, "firstRent", "¥" + firstBill.getPayableFeesMoney() + "元");
-            // 其他财务字段
-            fill(templateParam, "firstRentString", "人民币" + NumberToChineseUtils.numberToChinese(firstBill.getPayableFeesMoney().doubleValue()));
-        } else {
-//            fill(templateParam, "firstRent", "");
-        }
-
-        fill(templateParam, "firstRent",
-                "¥"+(contract.getPayType().equals("1")
-                        ? contract.getMonthRent()
-                        :contract.getPayType().equals("2")
-                        ?contract.getMonthRent().multiply(new BigDecimal("3"))
-                        :contract.getMonthRent().multiply(new BigDecimal("12"))
-                        .setScale(2, RoundingMode.DOWN)).doubleValue()+"元");
+        BigDecimal extracted = extracted(contract,dto);
+        System.out.println("金额========================="+extracted);
+        fill(templateParam, "firstRent", "¥" + extracted + "元");
+        // 其他财务字段
+        fill(templateParam, "firstRentString", "人民币" + NumberToChineseUtils.numberToChinese(extracted.doubleValue()));
 
 
-        fill(templateParam, "firstRentString",
-                "人民币"+NumberToChineseUtils.numberToChinese(
-                        (contract.getPayType().equals("1")
-                                ? contract.getMonthRent()
-                                :contract.getPayType().equals("2")
-                                ?contract.getMonthRent().multiply(new BigDecimal("3"))
-                                :contract.getMonthRent().multiply(new BigDecimal("12"))
-                                .setScale(2, RoundingMode.DOWN)).doubleValue()));
+//        fill(templateParam, "firstRent",
+//                "¥"+(contract.getPayType().equals("1")
+//                        ? contract.getMonthRent()
+//                        :contract.getPayType().equals("2")
+//                        ?contract.getMonthRent().multiply(new BigDecimal("3"))
+//                        :contract.getMonthRent().multiply(new BigDecimal("12"))
+//                        .setScale(2, RoundingMode.DOWN)).doubleValue()+"元");
+//
+//
+//        fill(templateParam, "firstRentString",
+//                "人民币"+NumberToChineseUtils.numberToChinese(
+//                        (contract.getPayType().equals("1")
+//                                ? contract.getMonthRent()
+//                                :contract.getPayType().equals("2")
+//                                ?contract.getMonthRent().multiply(new BigDecimal("3"))
+//                                :contract.getMonthRent().multiply(new BigDecimal("12"))
+//                                .setScale(2, RoundingMode.DOWN)).doubleValue()));
 
 
 
@@ -548,6 +540,240 @@
                 "/usr/local/project/file/");
     }
 
+    private BigDecimal extracted(TContract contract,TContractDTO dto) {
+        TContractRentType tContractRentType = null;
+        if (contract.getIsIncreasing()){
+            tContractRentType = new TContractRentType();
+            tContractRentType.setContractId(contract.getId());
+            tContractRentType.setIncreasingDecreasing(dto.getIncreasingDecreasing());
+            tContractRentType.setIncreasingDecreasingType(dto.getIncreasingDecreasingType());
+            tContractRentType.setNumericalValue(dto.getNumericalValue());
+            tContractRentType.setChangeTime(dto.getChangeTime());
+            tContractRentType.setCycleTime(dto.getCycleTime());
+        }
+        // 生成第一笔账单
+        // 第一次应缴费日期
+
+        LocalDateTime firstPayTime = contract.getStartTime().plusDays(10).withHour(0).withMinute(0).withSecond(0);
+        TBill rentBill = new TBill();
+        rentBill.setContractId(contract.getId());
+        rentBill.setContractNumber(contract.getContractNumber());
+        rentBill.setPayableFeesTime(firstPayTime.toLocalDate());
+        rentBill.setPayFeesStatus("1");
+        rentBill.setBillType("1");
+        rentBill.setStartTime(contract.getStartPayTime());
+        if (contract.getPayType().equals("2")) {
+            // 季付 取3 6 9 12
+            int temp = 0 ;
+            if (contract.getStartPayTime().getMonthValue() <= 3 ) {
+                temp = 3;
+            } else if (contract.getStartPayTime().getMonthValue() <= 6) {
+                temp = 6;
+            } else if (contract.getStartPayTime().getMonthValue() <= 9) {
+                temp = 9;
+            } else {
+                temp = 12;
+            }
+            if (contract.getEndTime().isAfter(contract.getStartPayTime().withMonth(temp).with(TemporalAdjusters.lastDayOfMonth()))){
+                rentBill.setEndTime(contract.getStartPayTime().withMonth(temp).with(TemporalAdjusters.lastDayOfMonth()));
+            }else {
+                rentBill.setEndTime(contract.getEndTime());
+            }
+        } else if (contract.getPayType().equals("3")) {
+            if (contract.getEndTime().isAfter(contract.getStartPayTime().withMonth(12).with(TemporalAdjusters.lastDayOfMonth()))){
+                rentBill.setEndTime(contract.getStartPayTime().withMonth(12).with(TemporalAdjusters.lastDayOfMonth()));
+            }else {
+                rentBill.setEndTime(contract.getEndTime());
+            }
+        } else {
+            rentBill.setEndTime(rentBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()));
+        }
+        if (tContractRentType != null && rentBill.getEndTime().isAfter(tContractRentType.getChangeTime())){
+            long moneyDays = 0;
+            if (tContractRentType.getChangeTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(rentBill.getEndTime())){
+                moneyDays = ChronoUnit.DAYS.between(tContractRentType.getChangeTime(), tContractRentType.getChangeTime().with(TemporalAdjusters.lastDayOfMonth())) + 1;
+            }else{
+                moneyDays = ChronoUnit.DAYS.between(tContractRentType.getChangeTime(),rentBill.getEndTime()) + 1;
+            }
+            // 计算租金变动的天数
+            contract.setChangeTime(tContractRentType.getChangeTime());
+            // 递增递减的租金
+            BigDecimal contractRentTypeMoney = new BigDecimal("0");
+            // 不递增递减的租金
+            BigDecimal originalMoney = new BigDecimal("0");
+            switch (tContractRentType.getIncreasingDecreasingType()) {
+                case 1:
+                    switch (tContractRentType.getIncreasingDecreasing()) {
+                        case 1:
+                            contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().multiply(new BigDecimal(100).add(tContractRentType.getNumericalValue())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN).divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(moneyDays)).setScale(2, BigDecimal.ROUND_DOWN));
+                            // 变动后的每月租金
+                            contract.setChangeRent(contract.getChangeRent().multiply(new BigDecimal(100).add(tContractRentType.getNumericalValue())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN));
+                            break;
+                        case 2:
+                            contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().multiply((new BigDecimal(100).subtract(tContractRentType.getNumericalValue()))).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN).divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(moneyDays)).setScale(2, BigDecimal.ROUND_DOWN));
+                            contract.setChangeRent(contract.getChangeRent().multiply((new BigDecimal(100).subtract(tContractRentType.getNumericalValue()))).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN));
+                            break;
+                    }
+                    break;
+                case 2:
+                    switch (tContractRentType.getIncreasingDecreasing()) {
+                        case 1:
+                            contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().add(tContractRentType.getNumericalValue())).divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(moneyDays)).setScale(2, BigDecimal.ROUND_DOWN);
+                            contract.setChangeRent(contract.getChangeRent().add(tContractRentType.getNumericalValue()));
+                            break;
+                        case 2:
+                            contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().subtract(tContractRentType.getNumericalValue())).divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(moneyDays)).setScale(2, BigDecimal.ROUND_DOWN);
+                            contract.setChangeRent(contract.getChangeRent().subtract(tContractRentType.getNumericalValue()));
+                            break;
+                    }
+                    break;
+            }
+            LocalDateTime localDateTime = tContractRentType.getChangeTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1);
+            while(true){
+                if (localDateTime.isBefore(rentBill.getEndTime())){
+                    if (localDateTime.plusMonths(1).isBefore(rentBill.getEndTime())){
+                        contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent());
+                        localDateTime = localDateTime.plusMonths(1);
+                    }else {
+                        break;
+                    }
+                }else{
+                    break;
+                }
+            }
+            long temp  = ChronoUnit.DAYS.between(localDateTime,rentBill.getEndTime()) + 1;
+            contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(temp)));
+            // 不需要涨租金的时间段
+            long originalDays = 0;
+            if (contract.getFirstPayTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tContractRentType.getChangeTime())){
+                originalDays = Math.abs(ChronoUnit.DAYS.between(contract.getFirstPayTime(), contract.getFirstPayTime().with(TemporalAdjusters.lastDayOfMonth())));
+            }else{
+                originalDays = Math.abs(ChronoUnit.DAYS.between(contract.getFirstPayTime(), tContractRentType.getChangeTime()));
+            }
+            originalMoney = originalMoney.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(originalDays)));
+            LocalDateTime originalTime = contract.getFirstPayTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1);
+            while(true){
+                if (originalTime.isBefore(tContractRentType.getChangeTime())){
+                    if (originalTime.plusMonths(1).isBefore(tContractRentType.getChangeTime())){
+                        originalMoney = originalMoney.add(contract.getMonthRent());
+                        originalTime = originalTime.plusMonths(1);
+                    }else {
+                        break;
+                    }
+                }else{
+                    break;
+                }
+            }
+            long tempOriginal  = ChronoUnit.DAYS.between(localDateTime,tContractRentType.getChangeTime()) ;
+            originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal)));
+            rentBill.setPayableFeesMoney(contractRentTypeMoney.add(originalMoney));
+            rentBill.setOutstandingMoney(rentBill.getPayableFeesMoney());
+        } else {
+            // 不走递增递减
+            if (contract.getPayType().equals("2")){
+                BigDecimal money = new BigDecimal("0");
+                // 第一个月计算天
+                int dayOfMonth = rentBill.getStartTime().getDayOfMonth();
+                if (dayOfMonth == 1) {
+                    System.err.println("第一笔账单 1号计算整月:");
+                    money = money.add(contract.getMonthRent());
+                } else {
+                    long allDays = Math.abs(ChronoUnit.DAYS.between(rentBill.getStartTime(), rentBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth())) + 1);
+                    System.err.println("第一笔账单 计算天数"+allDays);
+                    money =money.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(allDays)));
+                    System.err.println("第一笔账单 计算天数金额"+money);
+                }
+                // 后续
+                if (contract.getStartPayTime().getMonthValue()==3|| contract.getStartPayTime().getMonthValue()==6|| contract.getStartPayTime().getMonthValue()==9|| contract.getStartPayTime().getMonthValue()==12){
+                    System.err.println("后续账单 月为3 6 9 12金额"+money);
+                    rentBill.setPayableFeesMoney(money);
+                    rentBill.setOutstandingMoney(rentBill.getPayableFeesMoney());
+                }else{
+
+                    LocalDateTime localDateTime = rentBill.getStartTime().plusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
+                    System.err.println("后续账单逻辑时间"+localDateTime);
+                    while (true){
+                        if (localDateTime.toLocalDate().isBefore(rentBill.getEndTime().toLocalDate())){
+                            System.err.println("后续while 在结束之前");
+                            money = money.add(contract.getMonthRent());
+                        }else if(localDateTime.toLocalDate().equals(rentBill.getEndTime().toLocalDate())){
+                            System.err.println("后续while 结束");
+                            money = money.add(contract.getMonthRent());
+                            break;
+                        }else {
+                            System.err.println("后续while 加一个月大于结束时间");
+                            if (localDateTime.with(TemporalAdjusters.firstDayOfMonth()).isBefore(rentBill.getEndTime())){
+                                long a = ChronoUnit.DAYS.between(localDateTime.with(TemporalAdjusters.firstDayOfMonth()),rentBill.getEndTime())+1;
+                                System.err.println("后续while 加一个月大于结束时间 计算天数"+a);
+                                money = money.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(
+                                        new BigDecimal(ChronoUnit.DAYS.between(localDateTime.with(TemporalAdjusters.firstDayOfMonth()),rentBill.getEndTime())+1))
+                                );
+                            }
+
+                            break;
+                        }
+                        localDateTime = localDateTime.plusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
+                    }
+                    rentBill.setPayableFeesMoney(money);
+                    rentBill.setOutstandingMoney(rentBill.getPayableFeesMoney());
+                }
+            }else if (contract.getPayType().equals("3")){
+                BigDecimal money = new BigDecimal("0");
+                // 第一个月计算天
+                int dayOfMonth = rentBill.getStartTime().getDayOfMonth();
+                if (dayOfMonth == 1) {
+                    money = money.add(contract.getMonthRent());
+                } else {
+                    long allDays = ChronoUnit.DAYS.between(rentBill.getStartTime(), rentBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth())) ;
+                    money =money.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(allDays)));
+                }
+                // 后续
+                if (contract.getStartPayTime().getMonthValue()==12){
+                    rentBill.setPayableFeesMoney(money);
+                    rentBill.setOutstandingMoney(rentBill.getPayableFeesMoney());
+                }else{
+//                                LocalDateTime localDateTime = rentBill.getStartTime().plusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
+                    LocalDateTime localDateTime = rentBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1);
+                    while (true){
+                        if (localDateTime.isBefore(rentBill.getEndTime())){
+                            localDateTime = localDateTime.plusMonths(1);
+                            money = money.add(contract.getMonthRent());
+                        }else{
+                            money = money.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(ChronoUnit.DAYS.between(rentBill.getEndTime(),localDateTime.with(TemporalAdjusters.firstDayOfMonth())))));
+                            break;
+                        }
+                    }
+                    rentBill.setPayableFeesMoney(money);
+                    rentBill.setOutstandingMoney(rentBill.getPayableFeesMoney());
+                }
+            }else {
+                long allDays = ChronoUnit.DAYS.between(contract.getStartPayTime(), rentBill.getEndTime()) + 1;
+                int dayOfMonth = rentBill.getStartTime().getDayOfMonth();
+                if (dayOfMonth == 1) {
+                    rentBill.setPayableFeesMoney(contract.getMonthRent());
+                } else {
+                    rentBill.setPayableFeesMoney(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(allDays)));
+                }
+                rentBill.setOutstandingMoney(rentBill.getPayableFeesMoney());
+            }
+        }
+        // 押金账单
+        TBill depositBill = new TBill();
+        depositBill.setContractId(contract.getId());
+        depositBill.setContractNumber(contract.getContractNumber());
+        depositBill.setPayableFeesMoney(contract.getDeposit());
+        depositBill.setOutstandingMoney(depositBill.getPayableFeesMoney());
+        depositBill.setStartTime(contract.getStartPayTime());
+        depositBill.setEndTime(contract.getEndTime());
+        depositBill.setPayableFeesTime(firstPayTime.toLocalDate());
+        depositBill.setPayFeesStatus("1");
+        depositBill.setBillType("2");
+        rentBill.setBusinessDeptId(contract.getBusinessDeptId());
+        depositBill.setBusinessDeptId(contract.getBusinessDeptId());
+        return rentBill.getPayableFeesMoney() ;
+
+    }
+
 
     private void fill(Map<String, Object> templateParam, String key, Object value) {
         if (StringUtils.isEmpty(key)){
@@ -565,7 +791,7 @@
     {
         TContract contract = new TContract();
         BeanUtil.copyProperties(dto,contract);
-        return R.ok(generateContract(contract));
+        return R.ok(generateContract(contract,dto));
     }
 
     /**
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/WordUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/WordUtil.java
index e3153a8..e1edb1b 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/WordUtil.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/WordUtil.java
@@ -5,13 +5,8 @@
 import freemarker.template.Template;
 import freemarker.template.TemplateException;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.xwpf.usermodel.UnderlinePatterns;
-import org.apache.poi.xwpf.usermodel.XWPFDocument;
-import org.apache.poi.xwpf.usermodel.XWPFParagraph;
-import org.apache.poi.xwpf.usermodel.XWPFRun;
-import org.apache.poi.xwpf.usermodel.XWPFTable;
-import org.apache.poi.xwpf.usermodel.XWPFTableCell;
-import org.apache.poi.xwpf.usermodel.XWPFTableRow;
+import org.apache.poi.util.Units;
+import org.apache.poi.xwpf.usermodel.*;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -187,6 +182,15 @@
             System.setProperty("file.encoding", "UTF-8");
 
             XWPFDocument document = new XWPFDocument(fis);
+            XWPFParagraph pic = document.createParagraph();
+            XWPFRun picRun = pic.createRun();
+            XWPFPicture xwpfPicture = picRun.addPicture(
+                    new FileInputStream("C:\\Users\\Admin\\Pictures\\Camera Roll\\1.jpg"), XWPFDocument.PICTURE_TYPE_JPEG,
+                    "C:\\Users\\Admin\\Pictures\\Camera Roll\\1.jpg",
+                    Units.toEMU(60),
+                    Units.toEMU(30)
+            );
+            dataMap.put("picture", xwpfPicture);
 
             // 处理段落
             for (XWPFParagraph paragraph : document.getParagraphs()) {
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
index 619dd06..1946395 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
@@ -116,7 +116,6 @@
      * @return
      */
     List<TBill> getJiFuBillListByTime(String businessDeptId, Date first, Date last);
-    List<ScreenRentRankVO> getStreetRentRank();
 
     void editAmount(TbillSaveDto bill);
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StateProcessTemplateServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StateProcessTemplateServiceImpl.java
index b7eb5cb..70c7101 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StateProcessTemplateServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/StateProcessTemplateServiceImpl.java
@@ -581,7 +581,8 @@
             stateTaskQuery.orderByDesc(BaseModel::getCreateTime);
         }
         // 查询合同信息
-        List<TContract> tContracts = contractMapper.selectList(Wrappers.<TContract>lambdaQuery());
+        List<TContract> tContracts = contractMapper.selectList(Wrappers.<TContract>lambdaQuery()
+                .in(TContract::getStatus, 2,3,4));
         List<String> contractIds = tContracts.stream().map(TContract::getId).collect(Collectors.toList());
         if(CollectionUtils.isEmpty(contractIds)){
             return new PageInfo<>();
@@ -810,6 +811,14 @@
         if (processTaskListBO.getSortBy() == 2) {
             stateTaskQuery.orderByDesc(BaseModel::getCreateTime);
         }
+        // 查询合同信息
+        List<TContract> tContracts = contractMapper.selectList(Wrappers.<TContract>lambdaQuery()
+                .in(TContract::getStatus, 2,3,4));
+        List<String> contractIds = tContracts.stream().map(TContract::getId).collect(Collectors.toList());
+        if(CollectionUtils.isEmpty(contractIds)){
+            return new PageInfo<>();
+        }
+        stateTaskQuery.in(StateTaskCenter::getProjectId, contractIds);
         stateTaskQuery.in(StateTaskCenter::getFlowId, instanceId);
         PageInfo pageInfo = new PageInfo<>(processTaskListBO.getPageNum(), processTaskListBO.getPageSize());
         PageInfo<StateTaskCenter> taskCenters = stateTaskCenterService.page(pageInfo,stateTaskQuery);
@@ -1342,6 +1351,17 @@
         if (processTaskListBO.getSortBy() == 2) {
             stateTaskQuery.orderByDesc(FlwHisTask::getCreateTime);
         }
+        List<TContract> tContracts = contractMapper.selectList(Wrappers.<TContract>lambdaQuery()
+                .in(TContract::getStatus, 2,3,4));
+        List<String> contractIds = tContracts.stream().map(TContract::getId).collect(Collectors.toList());
+        if(CollectionUtils.isEmpty(contractIds)){
+            return new PageInfo<>();
+        }
+        List<StateTaskCenter> list = stateTaskCenterService.list(Wrappers.<StateTaskCenter>lambdaQuery().in(StateTaskCenter::getProjectId, contractIds));
+        if(!CollectionUtils.isEmpty(list)){
+            List<String> flowIds = list.stream().map(StateTaskCenter::getFlowId).collect(Collectors.toList());
+            stateTaskQuery.in(FlwHisTask::getInstanceId, flowIds);
+        }
         stateTaskQuery.eq(FlwHisTask::getParentTaskId, 0L);
         stateTaskQuery.like(FlwHisTask::getCreateId, userId);
         PageInfo pageInfo = new PageInfo<>(processTaskListBO.getPageNum(), processTaskListBO.getPageSize());
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRentalReturnRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRentalReturnRecordServiceImpl.java
index c7f07fa..138b8dd 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRentalReturnRecordServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRentalReturnRecordServiceImpl.java
@@ -92,11 +92,12 @@
         if (returnAuditQuery.getAuditResult() == 2){
             TContract contract = contractService.getById(record.getContractId());
             contract.setTerminateRemark(returnAuditQuery.getAuditOpinion());
+            contract.setTerminateTime(record.getCreateTime());
             contractService.updateById(contract);
             // 进入合同提前终止审批流程
             ProcessStartBO processStartBO = new ProcessStartBO();
             processStartBO.setCategory(ProcessCategoryEnum.CATEGORY3.getValue().toString());
-            processStartBO.setModuleName("房屋退租合同终止审批");
+            processStartBO.setModuleName("合同提前终止审批");
             processStartBO.setName(contract.getContractName());
             processStartBO.setRemark("");
             Map<String, Object> variable = new HashMap<>();
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/task/utils/TaskUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/task/utils/TaskUtil.java
index d6d21a6..7697d8f 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/task/utils/TaskUtil.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/task/utils/TaskUtil.java
@@ -39,8 +39,8 @@
     public void dayOfProportionBill() {
         try {
             // 查询所有未缴费账单
-            List<TBill> list = billMapper.selectList(new LambdaQueryWrapper<TBill>().eq(TBill::getPayFeesStatus, 1)
-                    .le(TBill::getPayableFeesTime,LocalDate.now()));
+            List<TBill> list = billMapper.selectList(new LambdaQueryWrapper<TBill>().ne(TBill::getPayFeesStatus, 5)
+                    .ne(TBill::getOutstandingMoney,0));
             for (TBill tBill : list) {
                 tBill.setPayFeesStatus("4");
                 TContract contract = contractService.getById(tBill.getContractId());

--
Gitblit v1.7.1