<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeeplus.modules.projectcontentinfo.dao.ProjectReportDataCompanyDao">


	<select id="findList" resultType="ProjectReportDataCompany" >
		select
		a.id AS "id",
		a.top_company AS "name",
		a.type As "type",
		count(DISTINCT t3.id) AS "reportCount"
		from sys_office a
		left join sys_office t2 on (t2.parent_ids like concat('%',a.id,'%') and t2.type='2')
		left join project_report_data t3 on t3.office_id = t2.id and t3.status = '5' and t3.del_flag = '0'
		<if test="date!=null and date !=''">
			AND YEAR(t3.report_date) = #{date}
		</if>
		where a.type in('1','3')
			<if test="officeId != null and officeId != ''">
				AND a.office_id = #{officeId}
			</if>
		and ( a.parent_id = #{companyId} or a.id = #{companyId})
		group by a.id
		order by a.create_date ASC;
	</select>

</mapper>