xuhy
2025-02-21 430eed3627a5184f6c4b00df9d5ce5b6994c4981
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.TContractMapper;
import com.ruoyi.system.mapper.THouseMapper;
import com.ruoyi.system.mapper.TTenantMapper;
import com.ruoyi.system.model.TContract;
import com.ruoyi.system.model.THouse;
import com.ruoyi.system.model.TTenant;
import com.ruoyi.system.query.TBillAppletQuery;
import com.ruoyi.system.query.TExamineAppletQuery;
import com.ruoyi.system.query.TTenantAppletQuery;
import com.ruoyi.system.query.TTenantQuery;
import com.ruoyi.system.service.TTenantService;
import com.ruoyi.system.vo.ExamineVO;
import com.ruoyi.system.vo.TBillVO;
import com.ruoyi.system.vo.TenantVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.token.TokenService;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 租户 服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2025-01-17
 */
@Service
public class TTenantServiceImpl extends ServiceImpl<TTenantMapper, TTenant> implements TTenantService {
 
    @Autowired
    private THouseMapper houseMapper;
    @Autowired
    private TContractMapper contractMapper;
    @Override
    public PageInfo<TenantVO> pageList(TTenantQuery query) {
        PageInfo<TenantVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TenantVO> list = this.baseMapper.pageList(query,pageInfo);
        for (TenantVO tenantVO : list) {
            tenantVO.setTenantAttributesName(StringUtils.isNotBlank(tenantVO.getTenantAttributes())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_ATTRIBUTE,tenantVO.getTenantAttributes()):"");
            tenantVO.setTenantTypeName(StringUtils.isNotBlank(tenantVO.getTenantType())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_TYPE,tenantVO.getTenantType()):"");
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
 
    @Override
    public PageInfo<TenantVO> pageListApplet(TTenantAppletQuery query) {
        PageInfo<TenantVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TenantVO> list = this.baseMapper.pageListApplet(query,pageInfo);
        for (TenantVO tenantVO : list) {
            tenantVO.setTenantAttributesName(StringUtils.isNotBlank(tenantVO.getTenantAttributes())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_ATTRIBUTE,tenantVO.getTenantAttributes()):"");
            tenantVO.setTenantTypeName(StringUtils.isNotBlank(tenantVO.getTenantType())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_TYPE,tenantVO.getTenantType()):"");
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
 
    @Override
    public List<THouse> listHouse(String id) {
        List<TContract> tContracts = contractMapper.selectList(new LambdaQueryWrapper<TContract>()
                        .eq(TContract::getTenantId,id)
                .eq(TContract::getStatus, 4));
        List<String> houseIds = tContracts.stream().map(TContract::getHouseId).collect(Collectors.toList());
        if (houseIds.isEmpty())houseIds.add("-1");
        return houseMapper.selectList(new LambdaQueryWrapper<THouse>()
                .in(THouse::getId, houseIds));
    }
 
    @Override
    public List<TContract> listContract(String id) {
        return contractMapper.selectList(new LambdaQueryWrapper<TContract>()
                .eq(TContract::getTenantId,id)
                .eq(TContract::getStatus, 4));
    }
 
    @Override
    public PageInfo<TBillVO> listBill(TBillAppletQuery query) {
        List<String> contractIds = contractMapper.selectList(new LambdaQueryWrapper<TContract>()
                        .eq(TContract::getTenantId, query.getId())).stream().map(TContract::getId)
                .collect(Collectors.toList());
        if (contractIds.isEmpty())contractIds.add("0");
        PageInfo<TBillVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TBillVO> list = this.baseMapper.listBill(query,pageInfo);
        for (TBillVO tBillVO : list) {
            tBillVO.setPayFeesStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_LEASE_STATUS,tBillVO.getPayFeesStatus()));
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
 
    @Override
    public PageInfo<ExamineVO> examineList(TExamineAppletQuery dto) {
        PageInfo<ExamineVO> pageInfo = new PageInfo<>(dto.getPageNum(), dto.getPageSize());
        List<ExamineVO> list = this.baseMapper.examineList(dto,pageInfo);
        pageInfo.setRecords(list);
        return pageInfo;
    }
}