select sp.id as projectId,sp.projectName, pui.unitId,pui.unitName,
(select count(1) from smz_ssp_problemmodify a where a.projectId = sp.id and a.roleType=5 and a.infoType=0 and a.isDel=0
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as aqyhpc_jfdb,
(select count(1) from smz_ssp_problemmodify a where a.projectId = sp.id and a.roleType=6 and a.infoType=0 and a.isDel=0
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as aqyhpc_jldw,
(select count(1) from smz_ssp_problemmodify a LEFT JOIN sys_user u on u.user_name=a.createUser where a.isDel=0 and a.projectId = sp.id and a.roleType=7 and u.dept_id = pui.unitId and a.infoType=0
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as aqyhpc_zbdw,
(select count(1) from work_train a LEFT JOIN work_train_dept b on a.id=b.train_id and b.is_main='Y' where a.project_id=sp.id and b.dept_id=pui.unitId and a.train_type=1 and a.is_del=0 ) as yjyl,
(select count(1) from work_train a LEFT JOIN work_train_dept b on a.id=b.train_id and b.is_main='Y' where a.project_id=sp.id and b.dept_id=pui.unitId and a.train_type=0 and a.is_del=0 ) as zxpx,
(select count(1) from smz_ssp_problemmodify a where a.projectId = sp.id and a.roleType=5 and a.infoType=1 and a.isDel=0
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as zlyhpc_jfdb,
(select count(1) from smz_ssp_problemmodify a where a.projectId = sp.id and a.roleType=6 and a.infoType=1 and a.isDel=0
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as zlyhpc_jldw,
(select count(1) from smz_ssp_problemmodify a LEFT JOIN sys_user u on u.user_name=a.createUser where a.isDel=0 and a.projectId = sp.id and a.roleType=7 and u.dept_id = pui.unitId and a.infoType=1
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as zlyhpc_zbdw,
(select count(1) from sur_project_work_special a where a.project_id = sp.id and a.dept_id=pui.unitId and a.is_del=0)as tzry,
(select count(1) from sur_project_check_detection a where a.project_id = sp.id and a.dept_id=pui.unitId and a.is_del=0)as clqyfs,
(select count(1) from sur_project_checking a where a.project_id = sp.id and a.dept_id=pui.unitId and a.is_del=0)as jpys,
(select count(1) from sur_project_measure a where a.project_id = sp.id and a.dept_id=pui.unitId and a.is_del=0)as cscl,
(select count(1) from sur_project_material_seal a where a.project_id = sp.id and a.dept_id=pui.unitId and a.is_del=0)as clfy,
(select count(1) from sur_project_insurance a where a.project_id = sp.id and a.dept_id=pui.unitId and a.is_del=0 and a.insurance_type=1)as yqx,
(select count(1) from sur_project_attendance_user a left join sur_project_attendance_cfg b on a.cfgid = b.id where b.project_id = sp.id and b.sub_dept_id = pui.unitId and b.state=0)as lwry,
(select count(1) from smz_ssp_problemmodify a where a.projectId=sp.id and a.infoType=1 and a.isDel=0 and a.checkState!=4 and date(NOW())<![CDATA[ > ]]> date(a.nickedTime)) as zlyjs,
(select count(1) from smz_ssp_problemmodify a where a.projectId=sp.id and a.infoType=0 and a.isDel=0 and a.checkState!=4 and date(NOW())<![CDATA[ > ]]> date(a.nickedTime)) as aqyjs,
(select CASE when b.plan_end_date > now() then 1 else 2 end as jdyj from vw_sur_project_build_node_data_current b where b.id in (select max(id) from vw_sur_project_build_node_data_current a where LENGTH(a.node_lvl)=2
select sp.id as projectId,sp.projectName, pui.unitId,pui.unitName,
(select count(1) from smz_ssp_problemmodify a where a.projectId = sp.id and a.roleType=6 and a.infoType=0 and a.isDel=0
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as aqyhpc_jldw,
(select count(1) from work_train a LEFT JOIN work_train_dept b on a.id=b.train_id and b.is_main='Y' where a.project_id=sp.id and b.dept_id=pui.unitId and a.train_type=1 and a.is_del=0 ) as yjyl,
(select count(1) from work_train a LEFT JOIN work_train_dept b on a.id=b.train_id and b.is_main='Y' where a.project_id=sp.id and b.dept_id=pui.unitId and a.train_type=0 and a.is_del=0 ) as zxpx,
(select count(1) from smz_ssp_problemmodify a where a.projectId = sp.id and a.roleType=6 and a.infoType=1 and a.isDel=0
<iftest="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and a.createTime between #{params.beginTime} and #{params.endTime}</if>
)as zlyhpc_jldw,
(select count(1) from sur_project_check_detection a where a.project_id = sp.id and a.is_del=0 and approve_status=1)as clqyfs,
(select count(1) from sur_project_check_detection a where a.project_id = sp.id and a.is_del=0 and approve_status=4)as clqyfswc,
(select count(1) from sur_project_checking a where a.project_id = sp.id and a.is_del=0 and approve_status=1)as jpys,
(select count(1) from sur_project_checking a where a.project_id = sp.id and a.is_del=0 and approve_status=4)as jpyswc,
(select count(1) from sur_project_measure a where a.project_id = sp.id and a.is_del=0 and approve_status=1)as cscl,
(select count(1) from sur_project_measure a where a.project_id = sp.id and a.is_del=0 and approve_status=4)as csclwc,
(select count(1) from sur_project_material_seal a where a.project_id = sp.id and a.is_del=0 and approve_status=1)as clfy,
(select count(1) from sur_project_material_seal a where a.project_id = sp.id and a.is_del=0 and approve_status=4)as clfywc,
(select count(DISTINCT a.procInsId) from vw_flow_await a where a.businessKey = sp.id and a.taskName like '%监理%')as gcsq,
(select count(DISTINCT a.procInsId) from vw_flow_finished a where a.businessKey = sp.id and a.taskName like '%监理%')as gcsp
from sur_project sp
left JOIN sur_project_unit_info pui on sp.id=pui.projectId and pui.unitType=4
where (pui.del_flag=0 or pui.del_flag is null)
<iftest="projectName != null and projectName != ''"> and sp.projectName like concat('%', #{projectName}, '%')</if>
<iftest="deptId != null "> and sp.deptId = #{deptId}</if>
<iftest="projectType != null and projectType != ''"> and sp.projectType = #{projectType}</if>
<iftest="projectNature != null and projectNature != ''"> and sp.projectNature = #{projectNature}</if>