无关风月
2025-03-06 40158f61b8bf3f07c3ebc928ccd8e5ccbc2e22ff
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
@@ -298,46 +298,46 @@
            THouse tHouse = houseService.getById(contract.getHouseId());
            Map<String, Object> templateParam = new HashMap<>(5);
            templateParam.put("partyOneName", contract.getPartyOneName());
            templateParam.put("partyTwoName", contract.getPartyTwoName());
            templateParam.put("houseAddress", tHouse.getHouseAddress());
            templateParam.put("houseArea", tHouse.getHouseArea()+"m²");
            templateParam.put("${partyOneName}", contract.getPartyOneName());
            templateParam.put("${partyTwoName}", contract.getPartyTwoName());
            templateParam.put("${houseAddress}", tHouse.getHouseAddress());
            templateParam.put("${houseArea}", tHouse.getHouseArea()+"m²");
            long between = ChronoUnit.DAYS.between(contract.getStartTime(), contract.getStartPayTime())+1;
            templateParam.put("day", between);
            templateParam.put("endTimeFree", DateUtils.localDateTimeToStringYear(contract.getStartPayTime().plusDays(1)));
            templateParam.put("startPayTime", DateUtils.localDateTimeToStringYear(contract.getStartPayTime()));
            templateParam.put("startTime", DateUtils.localDateTimeToStringYear(contract.getStartTime()));
            templateParam.put("endTime", DateUtils.localDateTimeToStringYear(contract.getEndTime()));
            templateParam.put("monthRent", "¥¥"+contract.getMonthRent()+"元");
            templateParam.put("monthRentString", "人民币"+NumberToChineseUtils.numberToChinese(contract.getMonthRent().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
            templateParam.put("${day}", between);
            templateParam.put("${endTimeFree}", DateUtils.localDateTimeToStringYear(contract.getStartPayTime().plusDays(1)));
            templateParam.put("${startPayTime}", DateUtils.localDateTimeToStringYear(contract.getStartPayTime()));
            templateParam.put("${startTime}", DateUtils.localDateTimeToStringYear(contract.getStartTime()));
            templateParam.put("${endTime}", DateUtils.localDateTimeToStringYear(contract.getEndTime()));
            templateParam.put("${monthRent}", "¥"+contract.getMonthRent()+"元");
            templateParam.put("${monthRentString}", "人民币"+NumberToChineseUtils.numberToChinese(contract.getMonthRent().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
            String totalYear = Objects.nonNull(contract.getTotalYear())?contract.getTotalYear().toString():"";
            templateParam.put("totalYear", "¥¥"+totalYear+"元");
            templateParam.put("${totalYear}", "¥"+totalYear+"元");
            String totalYearString = StringUtils.isNotEmpty(totalYear)?NumberToChineseUtils.numberToChinese(contract.getTotalYear().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()):"";
            templateParam.put("totalYearString", "人民币"+totalYearString);
            templateParam.put("payType", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
            templateParam.put("${totalYearString}", "人民币"+totalYearString);
            templateParam.put("${payType}", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
            if(firstBill!=null){
                templateParam.put("firstRent", "¥"+(firstBill.getPayableFeesMoney())+"元");
                templateParam.put("${firstRent}", "¥"+(firstBill.getPayableFeesMoney())+"元");
            }else{
                templateParam.put("firstRent", "");
                templateParam.put("${firstRent}", "");
            }
            templateParam.put("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,BigDecimal.ROUND_DOWN)).doubleValue()));
            templateParam.put("nextPayTime", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
            templateParam.put("deposit", "¥"+contract.getDeposit()+"元");
            templateParam.put("depositString", NumberToChineseUtils.numberToChinese(contract.getDeposit().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
            templateParam.put("partyOnePerson", contract.getPartyOnePerson());
            templateParam.put("partyOnePhone", contract.getPartyOnePhone());
            templateParam.put("partyTwoPerson", contract.getPartyTwoPerson());
            templateParam.put("partyTwoPhone", contract.getPartyTwoPhone());
            templateParam.put("${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,BigDecimal.ROUND_DOWN)).doubleValue()));
            templateParam.put("${nextPayTime}", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年");
            templateParam.put("${deposit}", "¥"+contract.getDeposit()+"元");
            templateParam.put("${depositString}", NumberToChineseUtils.numberToChinese(contract.getDeposit().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()));
            templateParam.put("${partyOnePerson}", contract.getPartyOnePerson());
            templateParam.put("${partyOnePhone}", contract.getPartyOnePhone());
            templateParam.put("${partyTwoPerson}", contract.getPartyTwoPerson());
            templateParam.put("${partyTwoPhone}", contract.getPartyTwoPhone());
            // 验收时间
            TCheckAcceptRecord tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery().eq(TCheckAcceptRecord::getContractId, contract.getId()).last("limit 1").one();
            if (tCheckAcceptRecord!=null &&tCheckAcceptRecord.getCheckTime()!=null ){
                templateParam.put("checkTime", DateUtils.localDateTimeToStringYear(tCheckAcceptRecord.getCheckTime()));
                templateParam.put("${checkTime}", DateUtils.localDateTimeToStringYear(tCheckAcceptRecord.getCheckTime()));
            }else{
                templateParam.put("checkTime", "");
                templateParam.put("${checkTime}", "");
            }
            String url = wordUtil.generatePdf("/template", "1_yzj_租赁合同.xml", templateParam, "租赁合同", "E:\\");
            String url = wordUtil.generatePdf("/usr/local/project/file/", "1_yzj_租赁合同.docx", templateParam, "租赁合同", "/usr/local/project/file/");
            res.add(url);
        }