mitao
22 小时以前 291a72bf35e2d39b816abc0ebf085cfa9da3ee06
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaApprovalServiceImpl.java
@@ -1,10 +1,22 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.TDept;
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.query.ApprovalNodeListQuery;
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>
@@ -17,4 +29,27 @@
@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();
            if(StringUtils.hasLength(approvalVO.getDeptIds())&&approvalVO.getDeptIds().equals("-1")){
                approvalVO.setDeptName("所有部门");
            }else{
                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;
    }
}