<iftest="sampleUserName != null and sampleUserName != ''"> and (spcd.sample_user like concat('%', #{sampleUserName}, '%') or spcd.sample_user_name like concat('%', #{sampleUserName}, '%'))</if>
<iftest="witnessUserName != null and witnessUserName != ''"> and (spcd.witness_user like concat('%', #{witnessUserName}, '%') or spcd.witness_user_name like concat('%', #{witnessUserName}, '%'))</if>
<iftest="laboratoryName != null and laboratoryName != ''"> and spcd.laboratory_name like concat('%', #{laboratoryName}, '%')</if>
<iftest="params.beginCheckTime != null and params.beginCheckTime != '' and params.endCheckTime != null and params.endCheckTime != ''"> and spcd.check_time between #{params.beginCheckTime} and #{params.endCheckTime}</if>
<iftest="checkState != null and checkState != ''"> and spcd.check_state = #{checkState}</if>
<iftest="detectionResult != null and detectionResult != ''"> and spcd.detection_result = #{detectionResult}</if>
<!-- 查询条件-项目部门 -->
<iftest="projectDeptId != null "> and sp.deptId = #{projectDeptId}</if>
<!--子部门数据-->
<iftest='nowRole == "4"'> and (sp.deptId = #{nowDept} or spm.quality_user=#{nowUserName} or spm.supervise_user=#{nowUserName})</if>
<!--监理单位/总包公司/分包单位查询当前关联数据-->
<iftest='nowRole == "5" or nowRole == "6" or nowRole == "7"'> and (spui.unitId = #{nowDept} or spm.quality_user=#{nowUserName} or spm.supervise_user=#{nowUserName})</if>
<!--普通用户查询项目人员-->
<iftest='nowRole == "99"'> and spu.is_del=0 and (spu.user_id = #{nowUser} or spm.quality_user=#{nowUserName} or spm.supervise_user=#{nowUserName})</if>
<iftest='activeName == "sjz"'> and spcd.check_state = '1'</if>
<iftest='activeName == "ywc"'> and spcd.check_state = '2'</if>
select spcd.check_state, count(1) as total from sur_project_check_detection spcd
left join sur_project sp on spcd.project_id = sp.id
left join sys_dept sd on sd.dept_id = spcd.dept_id
<!--监理单位/总包公司/分包单位-->
<iftest='nowRole == "5" or nowRole == "6" or nowRole == "7"'> left join sur_project_unit_info spui on spui.projectId = sp.id</if>
<!--普通用户查询项目人员-->
<iftest='nowRole == "99"'> left join sur_project_userinfo spu on spu.project_id = sp.id</if>
<where>
and spcd.is_del='0'
<iftest="projectId != null "> and spcd.project_id = #{projectId}</if>
<iftest="deptId != null "> and spcd.dept_id = #{deptId}</if>
<iftest="checkType != null and checkType != ''"> and spcd.check_type = #{checkType}</if>
<iftest="materialName != null and materialName != ''"> and spcd.material_name like concat('%', #{materialName}, '%')</if>
<iftest="usePosition != null and usePosition != ''"> and spcd.use_position like concat('%', #{usePosition}, '%')</if>
<iftest="sampleNum != null and sampleNum != ''"> and spcd.sample_num = #{sampleNum}</if>
<iftest="isDel != null and isDel != ''"> and spcd.is_del = #{isDel}</if>
<iftest="sampleUserName != null and sampleUserName != ''"> and spcd.sample_user_name like concat('%', #{sampleUserName}, '%')</if>
<iftest="witnessUserName != null and witnessUserName != ''"> and spcd.witness_user_name like concat('%', #{witnessUserName}, '%')</if>
<iftest="laboratoryName != null and laboratoryName != ''"> and spcd.laboratory_name like concat('%', #{laboratoryName}, '%')</if>
<iftest="params.beginCheckTime != null and params.beginCheckTime != '' and params.endCheckTime != null and params.endCheckTime != ''"> and spcd.check_time between #{params.beginCheckTime} and #{params.endCheckTime}</if>
<iftest="checkState != null and checkState != ''"> and spcd.check_state = #{checkState}</if>
<iftest="detectionResult != null and detectionResult != ''"> and spcd.detection_result = #{detectionResult}</if>
<!-- 查询条件-项目部门 -->
<iftest="projectDeptId != null "> and sp.deptId = #{projectDeptId}</if>
<!--子部门数据-->
<iftest='nowRole == "4"'> and (sp.deptId = #{nowDept} or spm.quality_user=#{nowUserName} or spm.supervise_user=#{nowUserName})</if>
<!--监理单位/总包公司/分包单位查询当前关联数据-->
<iftest='nowRole == "5" or nowRole == "6" or nowRole == "7"'> and (spui.unitId = #{nowDept} or spm.quality_user=#{nowUserName} or spm.supervise_user=#{nowUserName})</if>
<!--普通用户查询项目人员-->
<iftest='nowRole == "99"'> and spu.is_del=0 and (spu.user_id = #{nowUser} or spm.quality_user=#{nowUserName} or spm.supervise_user=#{nowUserName})</if>
select spcd.check_type as checkType,sdd.dict_label as checkTypeName, count(1) as total,checks.checkTotal,pass.passTotal from sur_project_check_detection spcd
left join sys_dict_data sdd on sdd.dict_type='check_detection_check_type' and sdd.dict_value = spcd.check_type
left join (select cd1.check_type as checks,count(1) as checkTotal from sur_project_check_detection cd1 where cd1.project_id=#{projectId} and cd1.check_state = '2' and cd1.is_del=0 GROUP BY cd1.check_type)checks on checks.checks=spcd.check_type
left join (select cd2.check_type as pass,count(1) as passTotal from sur_project_check_detection cd2 where cd2.project_id=#{projectId} and cd2.detection_result = '1' and cd2.is_del=0 GROUP BY cd2.check_type)pass on pass.pass=spcd.check_type
where spcd.project_id=#{projectId} and spcd.is_del=0