jhprjv2/yanzhu-jh/src/main/resources/mapper/project/ProjectViewMapper.xml

47 lines
4.6 KiB
XML

<?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.yanzhu.jh.project.mapper.ProjectViewMapper">
<!--查询项目总包单位-->
<select id="selectStatisticsProjectList" parameterType="com.yanzhu.jh.project.domain.SurProject" resultType="com.yanzhu.jh.project.domain.vo.ProjectViewExport">
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
<if test="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
<if test="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
<if test="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
<if test="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
<if test="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
<if test="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_insurance a where a.project_id = sp.id and a.dept_id=pui.unitId and a.is_del=0 and a.insurance_type=2)as azx
from sur_project sp
left JOIN sur_project_unit_info pui on sp.id=pui.projectId and pui.unitType=2
where pui.del_flag=0
<if test="projectName != null and projectName != ''"> and sp.projectName like concat('%', #{projectName}, '%')</if>
<if test="projectDeptId != null "> and sp.deptId = #{projectDeptId}</if>
<if test="projectType != null and projectType != ''"> and sp.projectType = #{projectType}</if>
<if test="projectNature != null and projectNature != ''"> and sp.projectNature = #{projectNature}</if>
ORDER by sp.projectSort
</select>
</mapper>