package com.yccrc.kede.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yccrc.kede.domain.Enterprise;
import com.yccrc.kede.domain.EnterpriseProject;
import com.yccrc.kede.vo.IndexRptVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author pengzhiqiang
 * @description 针对表【enterprise_project】的数据库操作Mapper
 * @createDate 2023-07-26 15:44:00
 * @Entity com.yccrc.common.core.domain.entity.domain.EnterpriseProject
 */
public interface EnterpriseProjectMapper extends BaseMapper<EnterpriseProject> {

    @Select("SELECT a.*,b.license AS creditCode from enterprise_project a left join enterprise b on a.ent_id = b.id  ${ew.customSqlSegment}")
    Page<EnterpriseProject> selectPage(Page<EnterpriseProject> page, @Param(Constants.WRAPPER) Wrapper<EnterpriseProject> queryWrapper);

    @Select("select count(*) as pro_sum_cnt,sum(case when report_state=4 then 1 else 0 end) as pro_finish_cnt,sum(case when report_state!=4 then 1 else 0 end) as pro_unfinish_cnt from enterprise_project a left join enterprise b on a.ent_id=b.id ${ew.customSqlSegment}")
    IndexRptVO rptProject(@Param(Constants.WRAPPER) QueryWrapper<Enterprise> queryWrapper);
}




