2023-08-26 00:36:09 +08:00
<?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.SurProjectCheckDetectionMapper" >
<resultMap type= "SurProjectCheckDetection" id= "SurProjectCheckDetectionResult" >
<result property= "id" column= "id" />
<result property= "projectId" column= "project_id" />
<result property= "deptId" column= "dept_id" />
<result property= "checkType" column= "check_type" />
<result property= "checkTime" column= "check_time" />
<result property= "checkState" column= "check_state" />
<result property= "detectionResult" column= "detection_result" />
<result property= "detectionFile" column= "detection_file" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "remark" column= "remark" />
</resultMap>
<sql id= "selectSurProjectCheckDetectionVo" >
select id, project_id, dept_id, check_type, check_time, check_state, detection_result, detection_file, create_by, create_time, update_by, update_time, remark from sur_project_check_detection
</sql>
<select id= "selectSurProjectCheckDetectionList" parameterType= "SurProjectCheckDetection" resultMap= "SurProjectCheckDetectionResult" >
<include refid= "selectSurProjectCheckDetectionVo" />
<where >
<if test= "projectId != null " > and project_id = #{projectId}</if>
<if test= "deptId != null " > and dept_id = #{deptId}</if>
<if test= "checkType != null and checkType != ''" > and check_type = #{checkType}</if>
<if test= "params.beginCheckTime != null and params.beginCheckTime != '' and params.endCheckTime != null and params.endCheckTime != ''" > and check_time between #{params.beginCheckTime} and #{params.endCheckTime}</if>
<if test= "checkState != null and checkState != ''" > and check_state = #{checkState}</if>
<if test= "detectionResult != null and detectionResult != ''" > and detection_result = #{detectionResult}</if>
<if test= "detectionFile != null and detectionFile != ''" > and detection_file = #{detectionFile}</if>
</where>
</select>
<select id= "selectSurProjectCheckDetectionById" parameterType= "Long" resultMap= "SurProjectCheckDetectionResult" >
<include refid= "selectSurProjectCheckDetectionVo" />
where id = #{id}
</select>
<insert id= "insertSurProjectCheckDetection" parameterType= "SurProjectCheckDetection" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_check_detection
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > project_id,</if>
<if test= "deptId != null" > dept_id,</if>
<if test= "checkType != null" > check_type,</if>
<if test= "checkTime != null" > check_time,</if>
<if test= "checkState != null" > check_state,</if>
<if test= "detectionResult != null" > detection_result,</if>
<if test= "detectionFile != null" > detection_file,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "remark != null" > remark,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > #{projectId},</if>
<if test= "deptId != null" > #{deptId},</if>
<if test= "checkType != null" > #{checkType},</if>
<if test= "checkTime != null" > #{checkTime},</if>
<if test= "checkState != null" > #{checkState},</if>
<if test= "detectionResult != null" > #{detectionResult},</if>
<if test= "detectionFile != null" > #{detectionFile},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "remark != null" > #{remark},</if>
</trim>
</insert>
<update id= "updateSurProjectCheckDetection" parameterType= "SurProjectCheckDetection" >
update sur_project_check_detection
<trim prefix= "SET" suffixOverrides= "," >
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "deptId != null" > dept_id = #{deptId},</if>
<if test= "checkType != null" > check_type = #{checkType},</if>
<if test= "checkTime != null" > check_time = #{checkTime},</if>
<if test= "checkState != null" > check_state = #{checkState},</if>
<if test= "detectionResult != null" > detection_result = #{detectionResult},</if>
<if test= "detectionFile != null" > detection_file = #{detectionFile},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "remark != null" > remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id= "deleteSurProjectCheckDetectionById" parameterType= "Long" >
delete from sur_project_check_detection where id = #{id}
</delete>
<delete id= "deleteSurProjectCheckDetectionByIds" parameterType= "String" >
delete from sur_project_check_detection where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
2023-08-26 01:22:51 +08:00
<select id= "groupByCheckType" parameterType= "SurProjectCheckDetection" resultMap= "SurProjectCheckDetectionResult" >
SELECT 1 id,COUNT(1) project_id,'送检数' check_type
FROM sur_project_check_detection WHERE check_type= #{checkType}
<if test= "deptId !=null and deptId>0" >
and project_id IN (SELECT id FROM sur_project WHERE deptid=#{deptId})
</if>
<if test= "projectId !=null" >
and project_id=#{projectId}
</if>
UNION
SELECT 2 id,COUNT(1) project_id,'待检数' check_type
FROM sur_project_check_detection WHERE check_type= #{checkType} AND check_state='1'
<if test= "deptId !=null and deptId>0" >
and project_id IN (SELECT id FROM sur_project WHERE deptid=#{deptId})
</if>
<if test= "projectId !=null" >
and project_id=#{projectId}
</if>
UNION
SELECT 3 id,COUNT(1) project_id,'合格数' check_type
FROM sur_project_check_detection WHERE check_type= #{checkType} AND detection_result='1'
<if test= "deptId !=null and deptId>0" >
and project_id IN (SELECT id FROM sur_project WHERE deptid=#{deptId})
</if>
<if test= "projectId !=null" >
and project_id=#{projectId}
</if>
</select>
2023-08-26 00:36:09 +08:00
</mapper>