ViolationWarningInformationMapper.xml 9.24 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.ViolationWarningInformationMapper">
    
    <resultMap type="ViolationWarningInformation" id="ViolationWarningInformationResult">
        <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="status1"    column="status1"    />
    </resultMap>

    <sql id="selectViolationWarningInformationVo">
        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 from casefile_violation_warning_information
    </sql>

    <select id="selectViolationWarningInformationList" parameterType="ViolationWarningInformation" resultMap="ViolationWarningInformationResult">
        select a.*,c.status1
        from casefile_violation_warning_information a
        left join (select a.table_name,count(*) status1 from 
					(select * from reply_approval_process b where table_name like "%violation_warning%" GROUP BY b.table_name,b.reply_people) a
					group by a.table_name) c 
		on CONCAT("violation_warning:",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="createTime != null"> and DATE_FORMAT(create_time,("%y%m%d")) = DATE_FORMAT(#{createTime},("%y%m%d"))</if>
            <if test="startTime != null "> and create_time between #{startTime} and #{endTime}</if>
             <if test="names != null "> 
            	and project_name in 
            	
			        <foreach item="name" collection="names" open="(" separator="," close=")">
			            #{name}
			        </foreach>
			</if>
			 <if test="status1 != null "> 
            		${status1}
			</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectViolationWarningInformationListByTable" parameterType="ViolationWarningInformation" resultMap="ViolationWarningInformationResult">
        <include refid="selectViolationWarningInformationVo"/>
        <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="selectViolationWarningInformationById" parameterType="Long" resultMap="ViolationWarningInformationResult">
        <include refid="selectViolationWarningInformationVo"/>
        where id = #{id}
    </select>
    <select id="selectViolationWarningInformation"
            resultType="com.trash.casefile.domain.ViolationWarningInformation">
        <include refid="selectViolationWarningInformationVo"/>
        <where>
            <if test="projectName!=null">project_name = #{projectName}</if>
            <if test="companyName!=null">company_name = #{companyName}</if>
            and violation_type = #{type} and create_time between CONCAT(#{nowDate},' 06:00:00') and CONCAT(#{tomorrowDate},' 05:59:59')
        </where>
    </select>

    <insert id="insertViolationWarningInformation" parameterType="ViolationWarningInformation" useGeneratedKeys="true" keyProperty="id">
        insert into casefile_violation_warning_information
        <trim prefix="(" suffix=")" suffixOverrides=",">
            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="abbreviation!=null">abbreviation,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createTime != null">#{createTime},</if>
            <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="abbreviation!=null">#{abbreviation},</if>
         </trim>
    </insert>

    <update id="updateViolationWarningInformation" parameterType="ViolationWarningInformation">
        update casefile_violation_warning_information
        <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>
        </trim>
        where id = #{id}
    </update>
    
    
    <select id="selectViolationWarningInformationListLessTime" resultType="com.trash.casefile.domain.ViolationWarningInformation">
    	select * from casefile_violation_warning_information where create_time > #{createTime} 
    </select>

    <delete id="deleteViolationWarningInformationById" parameterType="Long">
        delete from casefile_violation_warning_information where id = #{id}
    </delete>

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