无关风月
2 天以前 f431d9abcac90ea7ec3c351e311a85116d98e72b
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
package com.ruoyi.system.service.impl;
 
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.entity.TDept;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.system.mapper.OaApprovalMapper;
import com.ruoyi.system.mapper.TDeptMapper;
import com.ruoyi.system.model.OaApproval;
import com.ruoyi.system.query.ApprovalListQuery;
import com.ruoyi.system.service.OaApprovalService;
import com.ruoyi.system.vo.system.ApprovalVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
 
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 审批表 服务实现类
 * </p>
 *
 * @author WuGuanFengYue
 * @since 2025-09-15
 */
@Service
public class OaApprovalServiceImpl extends ServiceImpl<OaApprovalMapper, OaApproval> implements OaApprovalService {
 
    @Autowired
    private TDeptMapper deptMapper;
    @Override
    public PageInfo<ApprovalVO> pageList(ApprovalListQuery query) {
        List<TDept> tDepts = deptMapper.selectList(null);
        Map<Integer, String> deptMaps = tDepts.stream().collect(Collectors.toMap(TDept::getId, TDept::getDeptName));
        PageInfo<ApprovalVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<ApprovalVO> list = this.baseMapper.pageList(query,pageInfo);
        for (ApprovalVO approvalVO : list) {
            StringBuilder deptName = new StringBuilder();
            for (String deptId : approvalVO.getDeptIds().split(",")) {
                String orDefault = deptMaps.getOrDefault(Integer.parseInt(deptId), "");
                deptName.append(orDefault).append(",");
            }
            approvalVO.setDeptName(deptName.substring(0,deptName.length()-1));
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
}