ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java
New file @@ -0,0 +1,78 @@ package com.ruoyi.web.controller.api; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.system.model.TContract; import com.ruoyi.system.service.TContractService; import com.ruoyi.system.service.impl.ScreenService; import com.ruoyi.system.vo.ScreenRentIncomeTrendVO; import com.ruoyi.system.vo.ScreenRentRankVO; import com.ruoyi.system.vo.ScreenTopStaticsDataVO; import com.ruoyi.system.vo.TenantCountTrendVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.stream.Collectors; /** * @author mitao * @date 2025/3/19 */ @Api(tags = {"大屏相关接口"}) @RestController @RequestMapping("/screen") @RequiredArgsConstructor(onConstructor_ = {@Lazy}) public class ScreenController { private final ScreenService screenService; @GetMapping("/statics-data") @ApiOperation(value = "获取顶部统计数据") public R<ScreenTopStaticsDataVO> getTopStaticsData() { return R.ok(screenService.getTopStaticsData()); } @GetMapping("/rent-rank") @ApiOperation("区域租金排名") public R<List<ScreenRentRankVO>> rentRank() { return R.ok(screenService.streetRentRank()); } @GetMapping("/rent-income-trend") @ApiOperation("租金收入趋势") public R<ScreenRentIncomeTrendVO> rentIncomeTrend() { return R.ok(screenService.rentIncomeTrend()); } private final TContractService contractService; @GetMapping("/getTenantCountTrend") @ApiModelProperty(value = "租户数量趋势统计") public R<?> getTenantCountTrend() { // 获取所有签约时间不为空的合同 List<TContract> contracts = contractService.list(new LambdaQueryWrapper<TContract>() .isNotNull(TContract::getSignTime)); // 使用年-月格式化日期,并按此分组计算每个时间段的合同数量 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy-M"); List<TenantCountTrendVO> trendData = contracts.stream() .collect(Collectors.groupingBy(contract -> contract.getSignTime().toLocalDate() .withDayOfMonth(1) // 将日期调整为该月的第一天,以便正确分组 .atStartOfDay())) .entrySet().stream() .map(entry -> { String period = entry.getKey().format(formatter); long count = entry.getValue().size(); return new TenantCountTrendVO(period, count); }) .collect(Collectors.toList()); return R.ok(trendData); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBannerController.java
@@ -39,7 +39,7 @@ /** * 获取轮播图管理列表 */ @PreAuthorize("@ss.hasPermi('system:banner:list')") @PreAuthorize("@ss.hasPermi('system:banner')") @ApiOperation(value = "获取轮播图分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TBanner>> pageList(@RequestBody TBannerQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCheckAcceptRecordController.java
@@ -58,7 +58,7 @@ /** * 获取验收记录管理列表 */ @PreAuthorize("@ss.hasPermi('houseManage:check:list')") @PreAuthorize("@ss.hasPermi('houseManage:check')") @ApiOperation(value = "获取验收记录分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TCheckAcceptRecordVO>> pageList(@RequestBody TCheckAcceptRecordQuery query) { @@ -113,6 +113,7 @@ tBill.setContractId(dto.getContractId()); tBill.setContractNumber(contract.getContractNumber()); tBill.setPayableFeesMoney(dto.getCheckMoney()); tBill.setOutstandingMoney(dto.getCheckMoney()); tBill.setPayableFeesTime(LocalDate.now()); tBill.setPayFeesStatus("1"); tBill.setBillType("4"); ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
@@ -80,6 +80,8 @@ private StateProcessTemplateService stateProcessTemplateService; @Autowired private FlwTaskMapper flwTaskMapper; @Autowired private TTenantService tenantService; @ApiOperation(value = "获取合同分页列表") @PostMapping(value = "/contractList") @@ -295,13 +297,25 @@ List<TContract> list = contractService.lambdaQuery().in(TContract::getId, dto.getIds()).list(); List<String> res = new ArrayList<>(); for (TContract contract : list) { String templateFileName = "1_yzj_租赁合同_个人.docx"; TBill firstBill = billService.lambdaQuery().eq(TBill::getContractId, contract.getId()) .orderByDesc(TBill::getStartTime).last("limit 1").one(); TTenant tenant = tenantService.getById(contract.getTenantId()); THouse tHouse = houseService.getById(contract.getHouseId()); Map<String, Object> templateParam = new HashMap<>(5); templateParam.put("${contractNumber}", contract.getContractNumber()); templateParam.put("${partyOneName}", contract.getPartyOneName()); templateParam.put("${partyTwoName}", contract.getPartyTwoName()); if (Objects.nonNull(tenant)) { templateParam.put("${mailAddress}", StringUtils.isNotBlank(tenant.getMailAddress()) ? tenant.getMailAddress() : ""); templateParam.put("${idCard}", StringUtils.isNotBlank(tenant.getIdCard()) ? tenant.getIdCard() : ""); //企业、政府机构、国有企业 if (tenant.getTenantType().equals("2") || tenant.getTenantType().equals("5") || tenant.getTenantType().equals("7")){ templateParam.put("${creditCode}", StringUtils.isNotBlank(tenant.getCreditCode()) ? tenant.getCreditCode() : ""); templateParam.put("${legalPerson}", StringUtils.isNotBlank(tenant.getLegalPerson()) ? tenant.getLegalPerson() : ""); templateFileName = "1_yzj_租赁合同_企业.docx"; } } templateParam.put("${houseAddress}", tHouse.getHouseAddress()); templateParam.put("${houseArea}", tHouse.getHouseArea()+"m²"); long between = ChronoUnit.DAYS.between(contract.getStartTime(), contract.getStartPayTime())+1; @@ -339,7 +353,7 @@ templateParam.put("${checkTime}", ""); } String url = wordUtil.generatePdf("/usr/local/project/file/", "1_yzj_租赁合同.docx", templateParam, "租赁合同", "/usr/local/project/file/"); String url = wordUtil.generatePdf("/usr/local/project/file/", templateFileName, templateParam, "租赁合同", "/usr/local/project/file/"); res.add(url); } ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDeptController.java
@@ -51,7 +51,7 @@ /** * 获取部门管理管理列表 */ @PreAuthorize("@ss.hasPermi('system:department:list')") @PreAuthorize("@ss.hasPermi('system:department')") @ApiOperation(value = "获取部门管理分页列表") @PostMapping(value = "/pageList") public R<PageInfo<DeptVO>> pageList(@RequestBody TDeptQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFaultAreaDicController.java
@@ -46,7 +46,7 @@ /** * 获取故障区域管理列表 */ @PreAuthorize("@ss.hasPermi('system:faultArea:list')") @PreAuthorize("@ss.hasPermi('system:faultArea')") @ApiOperation(value = "获取故障区域分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TFaultAreaDic>> pageList(@RequestBody TFaultAreaDicQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFaultDescribeDicController.java
@@ -42,7 +42,7 @@ /** * 获取故障描述管理列表 */ @PreAuthorize("@ss.hasPermi('system:tag:list')") @PreAuthorize("@ss.hasPermi('system:tag')") @ApiOperation(value = "获取故障描述分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TFaultDescribeDicVO>> pageList(@RequestBody TFaultDescribeDicQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFaultRepairMessageController.java
@@ -41,7 +41,7 @@ /** * 获取报修管理列表 */ @PreAuthorize("@ss.hasPermi('houseManage:acceptance:list')") @PreAuthorize("@ss.hasPermi('houseManage:acceptance')") @ApiOperation(value = "获取报修分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TFaultRepairMessageVO>> pageList(@RequestBody TFaultRepairMessageQuery query) { ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TStreetController.java
New file @@ -0,0 +1,50 @@ package com.ruoyi.web.controller.api; import com.google.common.collect.Lists; import com.ruoyi.common.core.domain.R; import com.ruoyi.system.model.TStreet; import com.ruoyi.system.service.ITStreetService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; /** * <p> * 街道 前端控制器 * </p> * * @author mitao * @since 2025-03-19 */ @Api(tags = {"街道相关接口"}) @RestController @RequestMapping("/t-street") @RequiredArgsConstructor(onConstructor_ = {@Lazy}) public class TStreetController { private final ITStreetService tStreetService; @GetMapping("/list") @ApiOperation(value = "获取街道列表") public R<List<TStreet>> list() { return R.ok(tStreetService.list()); } @GetMapping("/init") @ApiOperation(value = "初始化街道列表") public R<?> init(){ ArrayList<String> strings = Lists.newArrayList("八廓街道", "吉日街道", "布达拉宫广场街道", "公德林街道", "扎细街道", "纳金街道", "娘热街道", "金珠西路街道", "堆龙德庆区东嘎街道", "两岛街道", "柳梧新区柳梧乡", "色拉街道", "蔡公堂街道", "娘热路街道", "夺底街道", "纳如街道"); strings.forEach(streetName->{ TStreet tStreet = new TStreet(); tStreet.setStreetName(streetName); tStreetService.save(tStreet); }); return R.ok(); } } ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
@@ -62,7 +62,7 @@ @Autowired private ISysMenuService menuService; @PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role')") @ApiOperation(value = "角色列表") @PostMapping("/list") public AjaxResult list(@RequestBody SysRoleQuery query) @@ -71,7 +71,7 @@ return AjaxResult.success(list); } @PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role')") @ApiOperation(value = "角色列表不分页") @PostMapping("/listNotPage") public AjaxResult list() ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -22,6 +22,7 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -56,6 +57,7 @@ */ @ApiOperation(value = "获取用户列表") @PostMapping("/list") @PreAuthorize("@ss.hasPermi('system:user')") public AjaxResult list(@RequestBody SysUserQuery query) { PageInfo<SysUserVO> list = userService.pageList(query); @@ -64,6 +66,8 @@ @ApiOperation(value = "获取用户列表-不分页") @PostMapping("/listNotPage") @PreAuthorize("@ss.hasPermi('system:user')") public AjaxResult listNotPage() { List<SysUser> list = userService.selectList(); ruoyi-admin/src/main/resources/application-test.yml
@@ -162,7 +162,7 @@ # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) expireTime: 120 expireTime: 1 mybatis-plus: # 此处在多数据源中生效 ruoyi-admin/src/main/resources/application.yml
@@ -1,4 +1,4 @@ # 项目相关配置 spring: profiles: active: test active: prod ruoyi-applet/src/main/resources/application.yml
@@ -1,4 +1,4 @@ # 项目相关配置 spring: profiles: active: test active: prod ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
@@ -1,16 +1,21 @@ package com.ruoyi.common.utils; import org.apache.commons.lang3.time.DateFormatUtils; import java.lang.management.ManagementFactory; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.*; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; import org.apache.commons.lang3.time.DateFormatUtils; /** * 时间工具类 @@ -267,7 +272,7 @@ cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, startMonth); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR, 0); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); Date first = cal.getTime(); @@ -279,9 +284,9 @@ cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, lastMonth); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); Date last = cal.getTime(); map.put("last", last); ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java
@@ -5,9 +5,9 @@ import com.ruoyi.system.dto.TBillDto; import com.ruoyi.system.model.TBill; import com.ruoyi.system.query.TBillQuery; import com.ruoyi.system.vo.ScreenRentRankVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.math.BigDecimal; import java.util.List; @@ -46,4 +46,9 @@ BigDecimal statisticsOverdue(); Integer batchBillCount(@Param("userId")String userId, @Param("billIds")List<String> billIds); /** * 街道租金排行 * @return */ List<ScreenRentRankVO> getStreetRentRank(); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/TContractMapper.java
@@ -28,4 +28,9 @@ List<BillVO> contractBillList(@Param("query") TContractBillQuery query, @Param("pageInfo") PageInfo<BillVO> pageInfo); List<TContract> contractExportList(@Param("query")TContractQuery query); /** * 本月新增租户数 * @return */ Integer getCurrentMonthRentCount(); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/THouseMapper.java
@@ -24,4 +24,5 @@ List<HouseVO> userHistoryList(@Param("req")TUserHistoryQuery query, @Param("pageInfo")PageInfo<HouseVO> pageInfo); Double getHouseRentedArea(); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/TStreetMapper.java
New file @@ -0,0 +1,16 @@ package com.ruoyi.system.mapper; import com.ruoyi.system.model.TStreet; import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * <p> * 街道 Mapper 接口 * </p> * * @author mitao * @since 2025-03-19 */ public interface TStreetMapper extends BaseMapper<TStreet> { } ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java
@@ -149,6 +149,15 @@ @ApiModelProperty(value = "合同状态 1=待提交 2=待审批 3=未签订 4=已签订 5=已驳回 6=已终止 7=待结算 8=已结算 9 = 签订待审核") @TableField("status") private String status; /** * 签订时间 */ @ApiModelProperty(value = "签订时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("sign_time") private LocalDateTime signTime; @ApiModelProperty(value = "内存大小多个文件逗号拼接") @TableField("memory") private String memory; ruoyi-system/src/main/java/com/ruoyi/system/model/THouse.java
@@ -1,18 +1,18 @@ package com.ruoyi.system.model; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableId; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.BaseModel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import java.math.BigDecimal; import java.time.LocalDateTime; /** * <p> @@ -94,4 +94,16 @@ @ApiModelProperty(value = "住户类型 1月租 2季租 3年租") @TableField(exist = false) private String tenantType; @ApiModelProperty(value = "所属街道id") @TableField("street_id") private String streetId; @ApiModelProperty(value = "经度") @TableField("longitude") private BigDecimal longitude; @ApiModelProperty(value = "纬度") @TableField("latitude") private BigDecimal latitude; } ruoyi-system/src/main/java/com/ruoyi/system/model/TStreet.java
New file @@ -0,0 +1,38 @@ package com.ruoyi.system.model; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.ruoyi.common.core.domain.BaseModel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.io.Serializable; /** * <p> * 街道 * </p> * * @author mitao * @since 2025-03-19 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("t_street") @ApiModel(value="TStreet对象", description="街道") public class TStreet extends BaseModel implements Serializable { private static final long serialVersionUID = 1L; @TableId(value = "id", type = IdType.ASSIGN_ID) private String id; @ApiModelProperty(value = "物品名称") private String streetName; } ruoyi-system/src/main/java/com/ruoyi/system/model/TTenant.java
@@ -1,14 +1,9 @@ package com.ruoyi.system.model; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableId; import java.time.LocalDate; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableField; import java.io.Serializable; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.BaseModel; import io.swagger.annotations.ApiModel; @@ -18,6 +13,7 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.time.LocalDate; /** * <p> @@ -92,4 +88,12 @@ @TableField("open_id") private String openId; @ApiModelProperty(value = "法人") @TableField("legal_person") private String legalPerson; @ApiModelProperty(value = "社会统一信用代码") @TableField("credit_code") private String creditCode; } ruoyi-system/src/main/java/com/ruoyi/system/service/ITStreetService.java
New file @@ -0,0 +1,16 @@ package com.ruoyi.system.service; import com.ruoyi.system.model.TStreet; import com.baomidou.mybatisplus.extension.service.IService; /** * <p> * 街道 服务类 * </p> * * @author mitao * @since 2025-03-19 */ public interface ITStreetService extends IService<TStreet> { } ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
@@ -2,18 +2,21 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.system.dto.*; import com.ruoyi.system.dto.BillStatisticsDto; import com.ruoyi.system.dto.CachPayDto; import com.ruoyi.system.dto.OfflinePayCheckDto; import com.ruoyi.system.dto.SmsByBillDto; import com.ruoyi.system.dto.TBillDto; import com.ruoyi.system.dto.TbillSaveDto; import com.ruoyi.system.model.TBill; import com.ruoyi.system.query.TBillQuery; import com.ruoyi.system.vo.ScreenRentRankVO; import com.taxi591.bankapi.dto.ChargeBillRequest; import javax.validation.constraints.NotEmpty; import java.math.BigDecimal; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; import java.util.List; /** * <p> @@ -87,4 +90,10 @@ BillStatisticsDto statistics(); Integer batchBillCount(String userId, List<String> billIds); /** * 查询街道租金排行 * @return */ List<ScreenRentRankVO> getStreetRentRank(); } ruoyi-system/src/main/java/com/ruoyi/system/service/TContractService.java
@@ -43,4 +43,9 @@ Boolean updateContractAuditStatus(String projectId, Integer submitStatus); /** * 本月新增租户数 * @return */ Integer getCurrentMonthRentCount(); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java
@@ -81,14 +81,21 @@ private final THouseService houseService; public static void main(String[] args) { // LocalDate localDate1 = LocalDate.now().withYear(2025).withMonth(4).withDayOfMonth(1); // LocalDate localDate2 = LocalDate.now().withYear(2025).withMonth(4).withDayOfMonth(16); LocalDateTime localDate1 = LocalDateTime.now().withYear(2025).withMonth(4).withDayOfMonth(16); LocalDateTime localDate2 = LocalDateTime.now().withYear(2025).withMonth(10).withDayOfMonth(24); LocalDate localDate1 = LocalDate.now().withYear(2025).withMonth(1).withDayOfMonth(31); System.err.println(localDate1.plusMonths(1)); long between = ChronoUnit.DAYS.between(localDate1, localDate2)+1; System.err.println(between); //// LocalDate localDate2 = LocalDate.now().withYear(2025).withMonth(4).withDayOfMonth(16); // LocalDateTime localDate1 = LocalDateTime.now().withYear(2025).withMonth(4).withDayOfMonth(16); // LocalDateTime localDate2 = LocalDateTime.now().withYear(2025).withMonth(10).withDayOfMonth(24); // // long between = ChronoUnit.DAYS.between(localDate1, localDate2)+1; int monthValue = LocalDateTime.now().getMonthValue(); LocalDateTime.now(); LocalDateTime.now(); System.err.println(LocalDateTime.now().isBefore(LocalDateTime.now())); } @Override public boolean notify(EventType eventType, Supplier<FlwTask> supplier, NodeModel nodeModel, FlowCreator flowCreator) { FlwTask flwTask = supplier.get(); @@ -251,6 +258,7 @@ return true; } /** * 业务状态变更 */ @@ -283,7 +291,6 @@ } List<TContractRentType> contractRentTypes = contractRentTypeService.list(); TContractRentType tContractRentType = contractRentTypes.stream().filter(e -> e.getContractId().equals(contract.getId())).findFirst().orElse(null); // 生成第一笔账单 // 第一次应缴费日期 LocalDateTime firstPayTime = contract.getStartTime().plusDays(10).withHour(0).withMinute(0).withSecond(0); @@ -292,28 +299,47 @@ rentBill.setContractNumber(contract.getContractNumber()); rentBill.setPayableFeesTime(firstPayTime.toLocalDate()); rentBill.setPayFeesStatus("1"); rentBill.setBillType("1"); rentBill.setStartTime(contract.getStartPayTime()); if (rentBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isAfter(contract.getEndTime())) { if (rentBill.getStartTime().getDayOfMonth() != 1) { rentBill.setEndTime(rentBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth())); 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 { rentBill.setEndTime(rentBill.getStartTime().plusMonths(contract.getPayType().equals("1") ? 1 : contract.getPayType().equals("2") ? 3 : 12).with(TemporalAdjusters.lastDayOfMonth())); 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()) { @@ -341,22 +367,115 @@ } 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 = 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)); 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) { money = money.add(contract.getMonthRent()); } else { long allDays = ChronoUnit.DAYS.between(contract.getStartPayTime(), contract.getStartPayTime().with(TemporalAdjusters.lastDayOfMonth())) + 1; money =money.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(allDays))); } // 后续 if (contract.getStartPayTime().getMonthValue()==3||contract.getStartPayTime().getMonthValue()==6||contract.getStartPayTime().getMonthValue()==9||contract.getStartPayTime().getMonthValue()==12){ rentBill.setPayableFeesMoney(money); rentBill.setOutstandingMoney(rentBill.getPayableFeesMoney()); }else{ LocalDateTime localDateTime = rentBill.getStartTime().plusMonths(1).with(TemporalAdjusters.lastDayOfMonth()); while (true){ if (localDateTime.isBefore(rentBill.getEndTime())){ 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()))+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().multiply(new BigDecimal(contract.getPayType().equals("1") ? 1 : contract.getPayType().equals("2") ? 3 : 12))); 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(); @@ -403,8 +522,12 @@ // 之前已经涨、跌过租金了 需要判断周期是否还需要再涨、跌 if (changeTime.isBefore(tBill.getEndTime()) && changeTime.isAfter(tBill.getStartTime())) { contract.setChangeTime(changeTime); // 租金递增递减的时长 天 long moneyDays = Math.abs(ChronoUnit.DAYS.between(tContractRentType.getChangeTime(), tBill.getEndTime()))+1; long moneyDays = 0; if (changeTime.with(TemporalAdjusters.lastDayOfMonth()).isBefore(tBill.getEndTime())){ moneyDays = ChronoUnit.DAYS.between(changeTime, changeTime.with(TemporalAdjusters.lastDayOfMonth())) + 1; }else{ moneyDays = ChronoUnit.DAYS.between(changeTime,tBill.getEndTime()) + 1; } // 递增递减的租金 BigDecimal contractRentTypeMoney = new BigDecimal("0"); // 不递增递减的租金 @@ -437,12 +560,45 @@ } break; } // 不需要涨租金的时间段 long originalDays = ChronoUnit.DAYS.between(tBill.getStartTime(), tContractRentType.getChangeTime()); if (originalDays > 0) { originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN)) .multiply(new BigDecimal(originalDays)); LocalDateTime localDateTime = changeTime.with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (localDateTime.isBefore(tBill.getEndTime())){ if (localDateTime.plusMonths(1).isBefore(tBill.getEndTime())){ contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent()); localDateTime = localDateTime.plusMonths(1); }else { break; } }else{ break; } } long temp = ChronoUnit.DAYS.between(localDateTime,tBill.getEndTime()) + 1; contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(temp))); // 不需要涨租金的时间段 long originalDays = 0; if (tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(changeTime)){ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()))); }else{ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), changeTime)); } originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(originalDays))); LocalDateTime originalTime = tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (originalTime.isBefore(changeTime)){ if (originalTime.plusMonths(1).isBefore(changeTime)){ originalMoney = originalMoney.add(contract.getChangeRent()); originalTime = originalTime.plusMonths(1); }else { break; } }else{ break; } } long tempOriginal = ChronoUnit.DAYS.between(originalTime,changeTime); originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal))); tBill.setPayableFeesMoney(contractRentTypeMoney.add(originalMoney)); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); contractService.updateById(contract); @@ -456,7 +612,12 @@ System.err.println("首次递增递减"); contract.setChangeTime(tContractRentType.getChangeTime()); // 租金递增递减的时长 天 long moneyDays = Math.abs(ChronoUnit.DAYS.between(tContractRentType.getChangeTime(), tBill.getEndTime()))+1; 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; } // 递增递减的租金 BigDecimal contractRentTypeMoney = new BigDecimal("0"); @@ -490,13 +651,46 @@ } break; } // 不需要涨租金的时间段 long originalDays = ChronoUnit.DAYS.between(tBill.getStartTime(), tContractRentType.getChangeTime()); System.err.println("不需要长租金时长"+originalDays); if (originalDays > 0) { originalMoney = originalMoney.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN)) .multiply(new BigDecimal(originalDays)); LocalDateTime localDateTime = tContractRentType.getChangeTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (localDateTime.isBefore(tBill.getEndTime())){ if (localDateTime.plusMonths(1).isBefore(tBill.getEndTime())){ contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent()); localDateTime = localDateTime.plusMonths(1); }else { break; } }else{ break; } } long temp = ChronoUnit.DAYS.between(localDateTime,tBill.getEndTime()) + 1; contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(temp))); // 不需要涨租金的时间段 long originalDays = 0; if (tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tContractRentType.getChangeTime())){ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()))); }else{ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), 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(originalTime,tContractRentType.getChangeTime()) ; originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal))); tBill.setPayableFeesMoney(contractRentTypeMoney.add(originalMoney)); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); contractService.updateById(contract); @@ -548,7 +742,12 @@ if (changeTime.isBefore(tBill.getEndTime()) && changeTime.isAfter(tBill.getStartTime())) { contract.setChangeTime(changeTime); // 租金递增递减的时长 天 long moneyDays = Math.abs(ChronoUnit.DAYS.between(changeTime, tBill.getEndTime()))+1; long moneyDays = 0; if (changeTime.with(TemporalAdjusters.lastDayOfMonth()).isBefore(tBill.getEndTime())){ moneyDays = ChronoUnit.DAYS.between(changeTime, changeTime.with(TemporalAdjusters.lastDayOfMonth())) + 1; }else{ moneyDays = ChronoUnit.DAYS.between(changeTime,tBill.getEndTime()) + 1; } // 递增递减的租金 BigDecimal contractRentTypeMoney = new BigDecimal("0"); // 不递增递减的租金 @@ -581,12 +780,46 @@ } break; } // 不需要涨租金的时间段 long originalDays = ChronoUnit.DAYS.between(tBill.getStartTime(), changeTime); if (originalDays > 0) { originalMoney = originalMoney.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN)) .multiply(new BigDecimal(originalDays)); LocalDateTime localDateTime = changeTime.with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (localDateTime.isBefore(tBill.getEndTime())){ if (localDateTime.plusMonths(1).isBefore(tBill.getEndTime())){ contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent()); localDateTime = localDateTime.plusMonths(1); }else { break; } }else{ break; } } long temp = ChronoUnit.DAYS.between(localDateTime,tBill.getEndTime()) + 1; contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(temp))); // 不需要涨租金的时间段 long originalDays = 0; if (tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tContractRentType.getChangeTime())){ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), changeTime.with(TemporalAdjusters.lastDayOfMonth()))); }else{ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), changeTime)); } originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(originalDays))); LocalDateTime originalTime = tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (originalTime.isBefore(changeTime)){ if (originalTime.plusMonths(1).isBefore(changeTime)){ originalMoney = originalMoney.add(contract.getChangeRent()); originalTime = originalTime.plusMonths(1); }else { break; } }else{ break; } } long tempOriginal = ChronoUnit.DAYS.between(originalTime,changeTime); originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal))); tBill.setPayableFeesMoney(contractRentTypeMoney.add(originalMoney)); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); contractService.updateById(contract); @@ -599,7 +832,13 @@ if (tContractRentType.getChangeTime().isBefore(tBill.getEndTime()) && tContractRentType.getChangeTime().isAfter(tBill.getStartTime())) { contract.setChangeTime(tContractRentType.getChangeTime()); // 租金递增递减的时长 天 long moneyDays = Math.abs(ChronoUnit.DAYS.between(tContractRentType.getChangeTime(), tBill.getEndTime()))+1; // 租金递增递减的时长 天 long moneyDays = 0; if (tContractRentType.getChangeTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tBill.getEndTime())){ moneyDays = ChronoUnit.DAYS.between(tContractRentType.getChangeTime(), tContractRentType.getChangeTime().with(TemporalAdjusters.lastDayOfMonth())) + 1; }else{ moneyDays = ChronoUnit.DAYS.between(tContractRentType.getChangeTime(),tBill.getEndTime()) + 1; } // 递增递减的租金 BigDecimal contractRentTypeMoney = new BigDecimal("0"); // 不递增递减的租金 @@ -632,12 +871,44 @@ } break; } // 不需要涨租金的时间段 long originalDays = ChronoUnit.DAYS.between(tBill.getStartTime(), tContractRentType.getChangeTime()); if (originalDays > 0) { originalMoney = originalMoney.add(contract.getMonthRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN)) .multiply(new BigDecimal(originalDays)).setScale(2,BigDecimal.ROUND_DOWN); LocalDateTime localDateTime = tContractRentType.getChangeTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (localDateTime.isBefore(tBill.getEndTime())){ if (localDateTime.plusMonths(1).isBefore(tBill.getEndTime())){ contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent()); localDateTime = localDateTime.plusMonths(1); }else { break; } }else{ break; } } long temp = ChronoUnit.DAYS.between(localDateTime,tBill.getEndTime()) + 1; contractRentTypeMoney = contractRentTypeMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(temp))); // 不需要涨租金的时间段 long originalDays = 0; if (tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tContractRentType.getChangeTime())){ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()))); }else{ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tContractRentType.getChangeTime())); } originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(originalDays))); LocalDateTime originalTime = tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (originalTime.isBefore(tContractRentType.getChangeTime())){ if (originalTime.plusMonths(1).isBefore(tContractRentType.getChangeTime())){ originalMoney = originalMoney.add(contract.getChangeRent()); originalTime = originalTime.plusMonths(1); }else { break; } }else{ break; } } long tempOriginal = ChronoUnit.DAYS.between(originalTime,tContractRentType.getChangeTime()); originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal))); tBill.setPayableFeesMoney(contractRentTypeMoney.add(originalMoney)); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); contractService.updateById(contract); @@ -645,19 +916,61 @@ } } } else { if (tBill.getStartTime().getDayOfMonth()==1 && tBill.getEndTime().toLocalDate().equals(tBill.getEndTime().with(TemporalAdjusters.lastDayOfMonth()).toLocalDate())){ tBill.setPayableFeesMoney(contract.getChangeRent().multiply(new BigDecimal(contract.getPayType().equals("1") ? 1 : contract.getPayType().equals("2") ? 3 : 12))); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); BigDecimal originalMoney = new BigDecimal("0"); // 不需要涨租金的时间段 long originalDays = 0; if (tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tBill.getEndTime())){ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()))); }else{ // 最后一笔账单时间 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()); originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getEndTime())); } originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(originalDays))); LocalDateTime originalTime = tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (originalTime.isBefore(tBill.getEndTime())){ if (originalTime.plusMonths(1).isBefore(tContractRentType.getChangeTime())){ originalMoney = originalMoney.add(contract.getChangeRent()); originalTime = originalTime.plusMonths(1); }else { break; } }else{ 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))); break; } } long tempOriginal = ChronoUnit.DAYS.between(originalTime,tBill.getEndTime()); originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal))); tBill.setPayableFeesMoney(originalMoney); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); } } else { BigDecimal originalMoney = new BigDecimal("0"); // 不需要涨租金的时间段 long originalDays = 0; if (tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).isBefore(tBill.getEndTime())){ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth())))+1; }else{ originalDays = Math.abs(ChronoUnit.DAYS.between(tBill.getStartTime(), tBill.getEndTime()))+1; } originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(originalDays))); LocalDateTime originalTime = tBill.getStartTime().with(TemporalAdjusters.lastDayOfMonth()).plusDays(1); while(true){ if (originalTime.isBefore(tBill.getEndTime())){ if (originalTime.plusMonths(1).isBefore(tBill.getEndTime())){ originalMoney = originalMoney.add(contract.getChangeRent()); originalTime = originalTime.plusMonths(1); }else { break; } }else{ break; } } if (originalTime.isBefore(tBill.getEndTime())){ long tempOriginal = ChronoUnit.DAYS.between(originalTime,tBill.getEndTime()); originalMoney = originalMoney.add(contract.getChangeRent().divide(new BigDecimal(30), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(tempOriginal))); } tBill.setPayableFeesMoney(originalMoney); tBill.setOutstandingMoney(tBill.getPayableFeesMoney()); } if (tBill.getEndTime().getDayOfMonth()>=15){ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java
New file @@ -0,0 +1,129 @@ package com.ruoyi.system.service.impl; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.system.model.TBill; import com.ruoyi.system.model.TContract; import com.ruoyi.system.model.THouse; import com.ruoyi.system.service.ITStreetService; import com.ruoyi.system.service.TBillService; import com.ruoyi.system.service.TContractService; import com.ruoyi.system.service.THouseService; import com.ruoyi.system.vo.ScreenRentIncomeTrendVO; import com.ruoyi.system.vo.ScreenRentRankVO; import com.ruoyi.system.vo.ScreenTopStaticsDataVO; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Calendar; import java.util.ArrayList; /** * @author mitao * @date 2025/3/19 */ @Service @RequiredArgsConstructor(onConstructor_ = {@Lazy}) public class ScreenService { private final THouseService tHouseService; private final TContractService tContractService; private final TBillService tBillService; private final ITStreetService tStreetService; /** * 获取顶部统计数据 * @return */ public ScreenTopStaticsDataVO getTopStaticsData() { ScreenTopStaticsDataVO vo = new ScreenTopStaticsDataVO(); //房屋总面积 List<THouse> houseList = tHouseService.list(); Double totalArea = houseList.stream().map(item -> Double.parseDouble(item.getHouseArea())).reduce(0D, Double::sum); vo.setHouseTotalArea(totalArea); //已出租面积 Double totalRentedArea = houseList.stream().filter(item -> !item.getLeaseStatus().equals("1")) .map(item -> Double.parseDouble(item.getHouseArea())).reduce(0D, Double::sum); vo.setHouseRentedArea(totalRentedArea); //总计应收租金 List<TBill> billList = tBillService.list(); BigDecimal totalReceivableRent = billList.stream().filter(item -> !item.getPayFeesStatus().equals("5")) .map(TBill::getPayableFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add); vo.setTotalReceivableRent(totalReceivableRent); //总计已收租金 BigDecimal totalReceivedRent = billList.stream().map(TBill::getPayFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add); vo.setTotalReceivedRent(totalReceivedRent); //本月新增租户数 Integer newTenantCount = tContractService.getCurrentMonthRentCount(); vo.setNewTenantCount(newTenantCount); //总计租户数 系统租户列表里有生效合同绑定的租户总数。 Long count = tContractService.lambdaQuery().in(TContract::getStatus, "4", "5", "6", "7", "8", "9").groupBy(TContract::getTenantId).count(); vo.setTotalTenantCount(count.intValue()); Map<String, Date> quarterDate = DateUtils.getQuarterDate(new Date()); Date first = quarterDate.get("first"); Date last = quarterDate.get("last"); List<TBill> currentQuarterBillList = tBillService.lambdaQuery().between(TBill::getPayableFeesTime, first, last).list(); //本季度已交租金 BigDecimal totalRentPaid = currentQuarterBillList.stream().map(TBill::getPayFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add); vo.setTotalRentPaid(totalRentPaid); //本季度应交租金 BigDecimal totalRentShould = currentQuarterBillList.stream().filter(item -> !item.getPayFeesStatus().equals("5")) .map(TBill::getPayableFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add); vo.setTotalRentShould(totalRentShould); return vo; } /** * 区域租金排名 * @return */ public List<ScreenRentRankVO> streetRentRank() { return tBillService.getStreetRentRank(); } /** * 租金收入趋势 * @return */ public ScreenRentIncomeTrendVO rentIncomeTrend() { ScreenRentIncomeTrendVO vo = new ScreenRentIncomeTrendVO(); // 获取当前日期 Date currentDate = new Date(); List<String> quarterLabels = new ArrayList<>(); List<BigDecimal> incomeData = new ArrayList<>(); // 获取最近7个季度的数据 for (int i = 6; i >= 0; i--) { // 计算对应季度的起止时间 Date targetDate = DateUtils.addMonths(currentDate, -3 * i); Map<String, Date> quarterDate = DateUtils.getQuarterDate(targetDate); Date quarterStart = quarterDate.get("first"); Date quarterEnd = quarterDate.get("last"); // 获取该季度的账单数据并计算总和 BigDecimal quarterIncome = tBillService.lambdaQuery() .between(TBill::getPayableFeesTime, quarterStart, quarterEnd) .list() .stream() .map(TBill::getPayFeesMoney) .reduce(BigDecimal.ZERO, BigDecimal::add); // 生成季度标签 (格式: YY-MM月) Calendar cal = Calendar.getInstance(); cal.setTime(quarterEnd); String label = String.format("%02d-%d月", cal.get(Calendar.YEAR) % 100, cal.get(Calendar.MONTH) + 1); quarterLabels.add(label); incomeData.add(quarterIncome); } vo.setQuarters(quarterLabels); vo.setIncomeData(incomeData); return vo; } } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -1,21 +1,42 @@ package com.ruoyi.system.service.impl; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.config.SmsProperties; import com.ruoyi.common.constant.AmountConstant; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.*; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.OrderNos; import com.ruoyi.common.utils.SmsUtil; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.TencentMailUtil; import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.system.dto.*; import com.ruoyi.system.dto.BillStatisticsDto; import com.ruoyi.system.dto.CachPayDto; import com.ruoyi.system.dto.OfflinePayCheckDto; import com.ruoyi.system.dto.SmsByBillDto; import com.ruoyi.system.dto.TBillDto; import com.ruoyi.system.dto.TbillSaveDto; import com.ruoyi.system.mapper.TBillMapper; import com.ruoyi.system.model.*; import com.ruoyi.system.model.TBankFlow; import com.ruoyi.system.model.TBill; import com.ruoyi.system.model.TBillDetail; import com.ruoyi.system.model.TFlowManagement; import com.ruoyi.system.model.TInvoiceToBill; import com.ruoyi.system.model.TOrderBill; import com.ruoyi.system.model.TPayOrder; import com.ruoyi.system.query.TBillQuery; import com.ruoyi.system.query.TInvoiceToBillQuery; import com.ruoyi.system.service.*; import com.ruoyi.system.service.TBankFlowService; import com.ruoyi.system.service.TBillConfirmService; import com.ruoyi.system.service.TBillDetailService; import com.ruoyi.system.service.TBillService; import com.ruoyi.system.service.TFlowManagementService; import com.ruoyi.system.service.TInvoiceToBillService; import com.ruoyi.system.service.TOrderBillService; import com.ruoyi.system.service.TPayOrderService; import com.ruoyi.system.vo.ScreenRentRankVO; import com.taxi591.bankapi.dto.ChargeBillRequest; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -28,7 +49,6 @@ import javax.validation.constraints.NotEmpty; import java.math.BigDecimal; import java.text.ParseException; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; @@ -557,5 +577,12 @@ return this.baseMapper.batchBillCount(userId,billIds); } /** * 街道租金排行 * @return */ @Override public List<ScreenRentRankVO> getStreetRentRank() { return baseMapper.getStreetRentRank(); } } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TContractServiceImpl.java
@@ -4,6 +4,7 @@ import com.aizuda.bpm.mybatisplus.mapper.FlwHisTaskMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.constant.DictConstants; import com.ruoyi.common.core.domain.R; @@ -17,7 +18,9 @@ import com.ruoyi.system.mapper.TCheckAcceptRecordMapper; import com.ruoyi.system.mapper.TContractMapper; import com.ruoyi.system.mapper.THouseMapper; import com.ruoyi.system.model.*; import com.ruoyi.system.model.TCheckAcceptRecord; import com.ruoyi.system.model.TContract; import com.ruoyi.system.model.THouse; import com.ruoyi.system.query.TContractAppletQuery; import com.ruoyi.system.query.TContractBillQuery; import com.ruoyi.system.query.TContractQuery; @@ -25,21 +28,17 @@ import com.ruoyi.system.service.TBillService; import com.ruoyi.system.service.TContractRentTypeService; import com.ruoyi.system.service.TContractService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.vo.BillVO; import com.ruoyi.system.vo.CheckAcceptRecordVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.stream.Collectors; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; /** * <p> @@ -195,7 +194,19 @@ @Override public Boolean updateContractAuditStatus(String projectId, Integer status) { LambdaUpdateWrapper<TContract> contractLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); contractLambdaUpdateWrapper.eq(TContract::getId, projectId).set(TContract::getStatus, status); contractLambdaUpdateWrapper .eq(TContract::getId, projectId) .set(TContract::getStatus, status) .set(TContract::getSignTime, LocalDateTime.now()); return this.update(contractLambdaUpdateWrapper); } /** * 本月新增租户数 * @return */ @Override public Integer getCurrentMonthRentCount() { return baseMapper.getCurrentMonthRentCount(); } } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java
@@ -1,6 +1,7 @@ package com.ruoyi.system.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.constant.DictConstants; import com.ruoyi.common.utils.DictUtils; @@ -12,12 +13,12 @@ import com.ruoyi.system.query.THouseQuery; import com.ruoyi.system.query.TUserHistoryQuery; import com.ruoyi.system.service.THouseService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.vo.HouseVO; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; /** @@ -37,7 +38,7 @@ PageInfo<THouse> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<THouse> list = this.baseMapper.houseList(query,pageInfo); List<TContract> tContracts = contractMapper.selectList(new LambdaQueryWrapper<TContract>() .eq(TContract::getStatus, 4) .in(TContract::getStatus, Arrays.asList(4,6,7)) .le(TContract::getStartTime, LocalDateTime.now()) .ge(TContract::getEndTime, LocalDateTime.now())); for (THouse tHouse : list) { @@ -46,10 +47,11 @@ if (tContract!=null){ tHouse.setTenantType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CONTRACT_PAY_TYPE,tContract.getPayType())); // tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,"2")); tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,"2")); }else{ // tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,tHouse.getLeaseStatus())); } tHouse.setLeaseStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,tHouse.getLeaseStatus())); } } pageInfo.setRecords(list); ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TStreetServiceImpl.java
New file @@ -0,0 +1,20 @@ package com.ruoyi.system.service.impl; import com.ruoyi.system.model.TStreet; import com.ruoyi.system.mapper.TStreetMapper; import com.ruoyi.system.service.ITStreetService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; /** * <p> * 街道 服务实现类 * </p> * * @author mitao * @since 2025-03-19 */ @Service public class TStreetServiceImpl extends ServiceImpl<TStreetMapper, TStreet> implements ITStreetService { } ruoyi-system/src/main/java/com/ruoyi/system/task/utils/TaskUtil.java
@@ -31,7 +31,6 @@ // 每分钟执行一次的定时任务 @Scheduled(cron = "0 0 0 * * ?") // @Scheduled(cron = "0 * * * * ?") public void dayOfProportionBill() { try { // 查询所有未缴费账单 ruoyi-system/src/main/java/com/ruoyi/system/vo/ScreenRentIncomeTrendVO.java
New file @@ -0,0 +1,23 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; /** * @author mitao * @date 2025/3/20 */ @Data @ApiModel("租金收入区域视图对象") public class ScreenRentIncomeTrendVO { @ApiModelProperty("x轴 时间列表") private List<String> quarters; @ApiModelProperty("y轴 收入列表") private List<BigDecimal> incomeData; } ruoyi-system/src/main/java/com/ruoyi/system/vo/ScreenRentRankVO.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; /** * @author mitao * @date 2025/3/19 */ @Data @ApiModel("区域租金排名") public class ScreenRentRankVO { @ApiModelProperty("街道名称") private String streetName; @ApiModelProperty("租金") private BigDecimal rentAmount; } ruoyi-system/src/main/java/com/ruoyi/system/vo/ScreenTopStaticsDataVO.java
New file @@ -0,0 +1,41 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; /** * @author mitao * @date 2025/3/19 */ @Data @ApiModel("顶部统计数据") public class ScreenTopStaticsDataVO { @ApiModelProperty("房屋总面积") private Double houseTotalArea; @ApiModelProperty("已出租面积") private Double houseRentedArea; @ApiModelProperty("总计应收租金") private BigDecimal totalReceivableRent; @ApiModelProperty("总计已收租金") private BigDecimal totalReceivedRent; @ApiModelProperty("本月新增租户数") private Integer newTenantCount; @ApiModelProperty("总计租户数") private Integer totalTenantCount; @ApiModelProperty("本季度已交租金") private BigDecimal totalRentPaid; @ApiModelProperty("本季度应交租金") private BigDecimal totalRentShould; } ruoyi-system/src/main/java/com/ruoyi/system/vo/TenantCountTrendVO.java
New file @@ -0,0 +1,22 @@ package com.ruoyi.system.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel("租户数量趋势统计") public class TenantCountTrendVO { @ApiModelProperty(value = "日期") private String date; @ApiModelProperty(value = "租户数量") private Long count; public TenantCountTrendVO(String date, Long count) { this.date = date; this.count = count; } public TenantCountTrendVO() { } } ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml
@@ -186,4 +186,15 @@ AND b.bill_type = 3 </where> </select> <select id="getStreetRentRank" resultType="com.ruoyi.system.vo.ScreenRentRankVO"> SELECT ts.street_name,ROUND(COALESCE(SUM(tb.pay_fees_money),0) /10000,2) AS rentAmount FROM t_street ts LEFT JOIN t_house th ON ts.id = th.street_id LEFT JOIN t_contract tc ON tc.house_id = th.id LEFT JOIN t_bill tb ON tc.id = tb.contract_id GROUP BY ts.id ORDER BY rentAmount DESC </select> </mapper> ruoyi-system/src/main/resources/mapper/system/TContractMapper.xml
@@ -124,5 +124,19 @@ </where> </select> <select id="getCurrentMonthRentCount" resultType="java.lang.Integer"> SELECT COUNT(DISTINCT tc.tenant_id) AS new_tenant_count FROM t_contract tc WHERE -- 筛选本月签订的合同 DATE_FORMAT(tc.sign_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m') AND tc.status IN ("4", "5", "6", "7", "8", "9") -- 且租户在本月前从未签订过任何合同 AND NOT EXISTS ( SELECT 1 FROM t_contract tc_hist WHERE tc_hist.tenant_id = tc.tenant_id AND tc_hist.sign_time <![CDATA[ < ]]> DATE_FORMAT(CURDATE(), '%Y-%m-01') AND tc_hist.status IN ("4", "5", "6", "7", "8", "9") ) </select> </mapper> ruoyi-system/src/main/resources/mapper/system/TStreetMapper.xml
New file @@ -0,0 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.TStreetMapper"> </mapper>