ViolationCaseFileMapper.xml 10.1 KB
<?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.trash.casefile.mapper.ViolationCaseFileMapper">
    
    <resultMap type="violationCaseFile" id="violationCaseFileResult">
        <result property="id"    column="id"    />
        <result property="number"    column="number"    />
        <result property="violationObjectType"    column="violation_object_type"    />
        <result property="owningRegion"    column="owning_region"    />
        <result property="violationType"    column="violation_type"    />
        <result property="violationGrade"    column="violation_grade"    />
        <result property="projectName"    column="project_name"    />
        <result property="companyName"    column="company_name"    />
        <result property="describe"    column="describe"    />
        <result property="sendObject"    column="send_object"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="status"    column="status"    />
        <result property="receive"    column="receive"    />
        <result property="receiveStatus"    column="receive_status"    />
        <result property="readBy"    column="read_by"    />
        <result property="readTime"    column="read_time"    />
        <result property="abbreviation"    column="abbreviation"    />
        <result property="needUpload"    column="need_upload"    />
        <result property="status1"    column="status1"    />
        
        
    </resultMap>

    <sql id="selectViolationCaseFileVo">
        select id, `number`, violation_object_type, owning_region, violation_type, violation_grade, project_name, company_name, `describe`, send_object, create_time, create_by, update_time, update_by, status, receive, receive_status, read_by, read_time,abbreviation,need_upload from casefile_violation
    </sql>

    <select id="selectViolationCaseFileList" parameterType="violationCaseFile" resultMap="violationCaseFileResult">
        select a.*,c.status1 from casefile_violation a
        left join (select a.table_name,count(*) status1 from 
					(select * from reply_approval_process b where table_name like "%workflow_casefile%" GROUP BY b.table_name,b.reply_people) a
					group by a.table_name) c 
		on CONCAT("workflow_casefile:",a.id) = c.table_name
        <where>
            <if test="number != null  and number != ''"> and number = #{number}</if>
            <if test="violationObjectType != null  and violationObjectType != ''"> and violation_object_type = #{violationObjectType}</if>
            <if test="owningRegion != null  and owningRegion != ''">and LOCATE(owning_region , #{owningRegion}) > 0</if>
            <if test="violationType != null  and violationType != ''"> and violation_type = #{violationType}</if>
            <if test="violationGrade != null  and violationGrade != ''"> and violation_grade = #{violationGrade}</if>
            <if test="projectName != null  and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="describe != null  and describe != ''"> and describe = #{describe}</if>
            <if test="sendObject != null  and sendObject != ''"> and send_object = #{sendObject}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="receive != null  and receive != ''"> and receive = #{receive}</if>
            <if test="receiveStatus != null "> and receive_status = #{receiveStatus}</if>
            <if test="readBy != null  and readBy != ''"> and read_by = #{readBy}</if>
            <if test="readTime != null "> and read_time = #{readTime}</if>
            <if test="createTime != null "> and create_time > #{createTime}</if>
            <if test="startTime != null "> and create_time between #{startTime} and #{endTime}</if>
            <if test="names != null "> 
            	${names}
			</if>
			<if test="needUpload == null or needUpload == 0 "> 
            	and need_upload != 1
			</if>
			<if test="needUpload == 1 "> 
            	and need_upload = 1
			</if>
			<if test="status1 != null "> 
				${status1}
			</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectViolationCaseFileListByTable" parameterType="violationCaseFile" resultMap="violationCaseFileResult">
                select a.*,c.status1 from casefile_violation a
        left join (select a.table_name,count(*) status1 from 
					(select * from reply_approval_process b where table_name like "%workflow_casefile%" GROUP BY b.table_name,b.reply_people) a
					group by a.table_name) c 
		on CONCAT("workflow_casefile:",a.id) = c.table_name
        <where>
            <if test="owningRegion != null and owningRegion != ''">and LOCATE(owning_region , #{owningRegion}) > 0</if>
            <if test="startDate!=null and endDate!=null and startDate!='' and endDate!=''">and create_time between #{startDate} and #{endDate}</if>
        </where>
    </select>

    <select id="selectViolationCaseFileById" parameterType="String" resultMap="violationCaseFileResult">
        <include refid="selectViolationCaseFileVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertViolationCaseFile" parameterType="ViolationCaseFile" useGeneratedKeys="true" keyProperty="id">
        insert into casefile_violation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">`id`,</if>
            create_time,
            <if test="number != null">`number`,</if>
            <if test="violationObjectType != null">violation_object_type,</if>
            <if test="owningRegion != null">owning_region,</if>
            <if test="violationType != null">violation_type,</if>
            <if test="violationGrade != null">violation_grade,</if>
            <if test="projectName != null">project_name,</if>
            <if test="companyName != null">company_name,</if>
            <if test="describe != null">`describe`,</if>
            <if test="sendObject != null">send_object,</if>
            <if test="createBy != null">create_by,</if>
            <if test="status != null">status,</if>
            <if test="receive != null">receive,</if>
            <if test="receiveStatus != null">receive_status,</if>
            <if test="readBy != null">read_by,</if>
            <if test="readTime != null">read_time,</if>
            <if test="abbreviation != null">abbreviation,</if>
            <if test="needUpload != null">need_upload,</if>
            
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            now(),
            <if test="number != null">#{number},</if>
            <if test="violationObjectType != null">#{violationObjectType},</if>
            <if test="owningRegion != null">#{owningRegion},</if>
            <if test="violationType != null">#{violationType},</if>
            <if test="violationGrade != null">#{violationGrade},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="companyName != null">#{companyName},</if>
            <if test="describe != null">#{describe},</if>
            <if test="sendObject != null">#{sendObject},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="status != null">#{status},</if>
            <if test="receive != null">#{receive},</if>
            <if test="receiveStatus != null">#{receiveStatus},</if>
            <if test="readBy != null">#{readBy},</if>
            <if test="readTime != null">#{readTime},</if>
            <if test="abbreviation != null">#{abbreviation},</if>
            <if test="needUpload != null">#{needUpload},</if>
         </trim>
    </insert>

    <update id="updateViolationCaseFile" parameterType="ViolationCaseFile">
        update casefile_violation
        <trim prefix="SET" suffixOverrides=",">
            update_time = now(),
            <if test="number != null">`number` = #{number},</if>
            <if test="violationObjectType != null">violation_object_type = #{violationObjectType},</if>
            <if test="owningRegion != null">owning_region = #{owningRegion},</if>
            <if test="violationType != null">violation_type = #{violationType},</if>
            <if test="violationGrade != null">violation_grade = #{violationGrade},</if>
            <if test="projectName != null">project_name = #{projectName},</if>
            <if test="companyName != null">company_name = #{companyName},</if>
            <if test="describe != null">`describe` = #{describe},</if>
            <if test="sendObject != null">send_object = #{sendObject},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="status != null">status = #{status},</if>
            <if test="receive != null">receive = #{receive},</if>
            <if test="receiveStatus != null">receive_status = #{receiveStatus},</if>
            <if test="readBy != null">read_by = #{readBy},</if>
            <if test="readTime != null">read_time = #{readTime},</if>
            <if test="abbreviation != null">abbreviation = #{abbreviation},</if>
            <if test="needUpload != null">need_upload = #{needUpload},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteViolationCaseFileById" parameterType="String">
        delete from casefile_violation where id = #{id}
    </delete>

    <delete id="deleteViolationCaseFileByIds" parameterType="String">
        delete from casefile_violation where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>