TransferCompanyServiceImpl.java 2.21 KB
package com.laowu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.laowu.dto.assist.OneCompanyProjectsDTO;
import com.laowu.mapper.TransferCompanyMapper;
import com.laowu.mapper.TransferProjectMapper;
import com.laowu.mapper.TransferProjectMembersMapper;
import com.laowu.model.TransferCompanyDO;
import com.laowu.model.TransferProjectDO;
import com.laowu.service.TransferCompanyService;
import com.laowu.vo.assist.CompanyCntVO;
import com.laowu.vo.assist.CompanyProjectsVO;
import com.laowu.vo.assist.OneCompanyProjectsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Tuyp
 * @since 2023-09-11
 */
@Service
public class TransferCompanyServiceImpl extends ServiceImpl<TransferCompanyMapper, TransferCompanyDO> implements TransferCompanyService {

    @Autowired
    private TransferProjectMapper transferProjectMapper;

    @Autowired
    private TransferProjectMembersMapper transferProjectMembersMapper;

    public CompanyCntVO companyCnt() {
        CompanyCntVO companyCntVO = new CompanyCntVO();
        Integer count = this.baseMapper.selectCount(null);
        companyCntVO.setCompanyCnt(count);

        Integer memberCnt = transferProjectMembersMapper.selectCount(null);
        companyCntVO.setMemberCnt(memberCnt);

        return companyCntVO;
    }

    public List<CompanyProjectsVO> companyProjects() {
        List<CompanyProjectsVO> companyProjectsVOS = this.baseMapper.companyProjects();
        companyProjectsVOS.stream().forEach(x -> {
            //项目数
            Integer count = transferProjectMapper.selectCount(new QueryWrapper<TransferProjectDO>()
                    .lambda()
                    .eq(TransferProjectDO::getCompanyId, x.getId()));
            x.setProjectCnt(count);
        });
        return companyProjectsVOS;
    }

    public List<OneCompanyProjectsVO> oneCompanyProjects(OneCompanyProjectsDTO oneCompanyProjectsDTO) {

        return this.baseMapper.oneCompanyProjects(oneCompanyProjectsDTO.getCompanyId(),oneCompanyProjectsDTO.getYear());
    }


}