TWorkPermitMapper.xml 13.3 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
<?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.zehong.system.mapper.TWorkPermitMapper">
    
    <resultMap type="TWorkPermit" id="TWorkPermitResult">
        <result property="workPermitId"    column="work_permit_id"    />
        <result property="applyDept"    column="apply_dept"    />
        <result property="linkMan"    column="link_man"    />
        <result property="linkPhone"    column="link_phone"    />
        <result property="workBound"    column="work_bound"    />
        <result property="deviceName"    column="device_name"    />
        <result property="deviceNum"    column="device_num"    />
        <result property="applyWorkStartTime"    column="apply_work_start_time"    />
        <result property="applyWorkEndTime"    column="apply_work_end_time"    />
        <result property="workContent"    column="work_content"    />
        <result property="contractor"    column="contractor"    />
        <result property="ratifier"    column="ratifier"    />
        <result property="mainDangerousMark"    column="main_dangerous_mark"    />
        <result property="dangerousMarkDetial"    column="dangerous_mark_detial"    />
        <result property="licenceInfo"    column="licence_info"    />
        <result property="relationSign"    column="relation_sign"    />
        <result property="produceComfirm"    column="produce_comfirm"    />
        <result property="workDeal"    column="work_deal"    />
        <result property="applyStatus"    column="apply_status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTWorkPermitVo">
        select work_permit_id, apply_dept, link_man, link_phone, work_bound, device_name, device_num, apply_work_start_time, apply_work_end_time, work_content, contractor, ratifier, main_dangerous_mark, dangerous_mark_detial, licence_info, relation_sign, produce_comfirm, work_deal, apply_status, create_time, update_time, remarks from t_work_permit
    </sql>

    <select id="selectTWorkPermitList" parameterType="TWorkPermit" resultMap="TWorkPermitResult">
        <include refid="selectTWorkPermitVo"/>
        <where>  
            <if test="applyDept != null  and applyDept != ''"> and apply_dept = #{applyDept}</if>
            <if test="linkMan != null  and linkMan != ''"> and link_man = #{linkMan}</if>
            <if test="linkPhone != null  and linkPhone != ''"> and link_phone = #{linkPhone}</if>
            <if test="workBound != null  and workBound != ''"> and work_bound = #{workBound}</if>
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
            <if test="deviceNum != null  and deviceNum != ''"> and device_num like concat('%', #{deviceNum},'%')</if>
            <if test="applyWorkStartTime != null "> and apply_work_start_time = #{applyWorkStartTime}</if>
            <if test="applyWorkEndTime != null "> and apply_work_end_time = #{applyWorkEndTime}</if>
            <if test="workContent != null  and workContent != ''"> and work_content = #{workContent}</if>
            <if test="contractor != null "> and contractor = #{contractor}</if>
            <if test="ratifier != null "> and ratifier = #{ratifier}</if>
            <if test="mainDangerousMark != null  and mainDangerousMark != ''"> and main_dangerous_mark = #{mainDangerousMark}</if>
            <if test="dangerousMarkDetial != null  and dangerousMarkDetial != ''"> and dangerous_mark_detial = #{dangerousMarkDetial}</if>
            <if test="licenceInfo != null  and licenceInfo != ''"> and licence_info = #{licenceInfo}</if>
            <if test="relationSign != null  and relationSign != ''"> and relation_sign = #{relationSign}</if>
            <if test="produceComfirm != null  and produceComfirm != ''"> and produce_comfirm = #{produceComfirm}</if>
            <if test="workDeal != null  and workDeal != ''"> and work_deal = #{workDeal}</if>
            <if test="applyStatus != null  and applyStatus != ''"> and apply_status = #{applyStatus}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
        ORDER BY create_time DESC,apply_status
    </select>
    
    <select id="selectTWorkPermitById" parameterType="Long" resultMap="TWorkPermitResult">
        <include refid="selectTWorkPermitVo"/>
        where work_permit_id = #{workPermitId}
    </select>
        
    <insert id="insertTWorkPermit" parameterType="TWorkPermit" useGeneratedKeys="true" keyProperty="workPermitId">
        insert into t_work_permit
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="applyDept != null">apply_dept,</if>
            <if test="linkMan != null">link_man,</if>
            <if test="linkPhone != null">link_phone,</if>
            <if test="workBound != null">work_bound,</if>
            <if test="deviceName != null">device_name,</if>
            <if test="deviceNum != null">device_num,</if>
            <if test="applyWorkStartTime != null">apply_work_start_time,</if>
            <if test="applyWorkEndTime != null">apply_work_end_time,</if>
            <if test="workContent != null">work_content,</if>
            <if test="contractor != null">contractor,</if>
            <if test="ratifier != null">ratifier,</if>
            <if test="mainDangerousMark != null">main_dangerous_mark,</if>
            <if test="dangerousMarkDetial != null">dangerous_mark_detial,</if>
            <if test="licenceInfo != null">licence_info,</if>
            <if test="relationSign != null">relation_sign,</if>
            <if test="produceComfirm != null">produce_comfirm,</if>
            <if test="workDeal != null">work_deal,</if>
            <if test="applyStatus != null">apply_status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="applyDept != null">#{applyDept},</if>
            <if test="linkMan != null">#{linkMan},</if>
            <if test="linkPhone != null">#{linkPhone},</if>
            <if test="workBound != null">#{workBound},</if>
            <if test="deviceName != null">#{deviceName},</if>
            <if test="deviceNum != null">#{deviceNum},</if>
            <if test="applyWorkStartTime != null">#{applyWorkStartTime},</if>
            <if test="applyWorkEndTime != null">#{applyWorkEndTime},</if>
            <if test="workContent != null">#{workContent},</if>
            <if test="contractor != null">#{contractor},</if>
            <if test="ratifier != null">#{ratifier},</if>
            <if test="mainDangerousMark != null">#{mainDangerousMark},</if>
            <if test="dangerousMarkDetial != null">#{dangerousMarkDetial},</if>
            <if test="licenceInfo != null">#{licenceInfo},</if>
            <if test="relationSign != null">#{relationSign},</if>
            <if test="produceComfirm != null">#{produceComfirm},</if>
            <if test="workDeal != null">#{workDeal},</if>
            <if test="applyStatus != null">#{applyStatus},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTWorkPermit" parameterType="TWorkPermit">
        update t_work_permit
        <trim prefix="SET" suffixOverrides=",">
            <if test="applyDept != null">apply_dept = #{applyDept},</if>
            <if test="linkMan != null">link_man = #{linkMan},</if>
            <if test="linkPhone != null">link_phone = #{linkPhone},</if>
            <if test="workBound != null">work_bound = #{workBound},</if>
            <if test="deviceName != null">device_name = #{deviceName},</if>
            <if test="deviceNum != null">device_num = #{deviceNum},</if>
            <if test="applyWorkStartTime != null">apply_work_start_time = #{applyWorkStartTime},</if>
            <if test="applyWorkEndTime != null">apply_work_end_time = #{applyWorkEndTime},</if>
            <if test="workContent != null">work_content = #{workContent},</if>
            <if test="contractor != null">contractor = #{contractor},</if>
            <if test="ratifier != null">ratifier = #{ratifier},</if>
            <if test="mainDangerousMark != null">main_dangerous_mark = #{mainDangerousMark},</if>
            <if test="dangerousMarkDetial != null">dangerous_mark_detial = #{dangerousMarkDetial},</if>
            <if test="licenceInfo != null">licence_info = #{licenceInfo},</if>
            <if test="relationSign != null">relation_sign = #{relationSign},</if>
            <if test="produceComfirm != null">produce_comfirm = #{produceComfirm},</if>
            <if test="workDeal != null">work_deal = #{workDeal},</if>
            <if test="applyStatus != null">apply_status = #{applyStatus},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where work_permit_id = #{workPermitId}
    </update>

    <delete id="deleteTWorkPermitById" parameterType="Long">
        delete from t_work_permit where work_permit_id = #{workPermitId}
    </delete>

    <delete id="deleteTWorkPermitByIds" parameterType="String">
        delete from t_work_permit where work_permit_id in 
        <foreach item="workPermitId" collection="array" open="(" separator="," close=")">
            #{workPermitId}
        </foreach>
    </delete>
耿迪迪's avatar
耿迪迪 committed
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180

    <select id="selectTWorkPermitListByLoginUser" parameterType="TWorkPermit" resultMap="TWorkPermitResult">
        SELECT
        permit.work_permit_id,
        permit.apply_dept,
        permit.link_man,
        permit.link_phone,
        permit.work_bound,
        permit.device_name,
        permit.device_num,
        permit.apply_work_start_time,
        permit.apply_work_end_time,
        permit.work_content,
        permit.contractor,
        permit.ratifier,
        permit.main_dangerous_mark,
        permit.dangerous_mark_detial,
        permit.licence_info,
        permit.relation_sign,
        permit.produce_comfirm,
        permit.work_deal,
        permit.apply_status,
        permit.create_time,
        permit.update_time,
        permit.remarks
        FROM
181 182 183
         t_work_permit permit
        LEFT JOIN t_special_work_permit special ON permit.work_permit_id = special.work_permit_id
        LEFT JOIN t_special_work_permit_sign sign ON special.special_work_permit_id = sign.permit_id
184 185
        <where>
            (
186
            permit.link_man = #{currentLoginUser}
187
            OR sign.staff_id = #{currentLoginUser}
188 189
            )
            <if test="applyDept != null  and applyDept != ''">and apply_dept like concat('%', #{applyDept}, '%')</if>
耿迪迪's avatar
耿迪迪 committed
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
            <if test="linkMan != null  and linkMan != ''"> and link_man = #{linkMan}</if>
            <if test="linkPhone != null  and linkPhone != ''"> and link_phone = #{linkPhone}</if>
            <if test="workBound != null  and workBound != ''"> and work_bound = #{workBound}</if>
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
            <if test="deviceNum != null  and deviceNum != ''"> and device_num like concat('%', #{deviceNum},'%')</if>
            <if test="applyWorkStartTime != null "> and apply_work_start_time = #{applyWorkStartTime}</if>
            <if test="applyWorkEndTime != null "> and apply_work_end_time = #{applyWorkEndTime}</if>
            <if test="workContent != null  and workContent != ''"> and work_content = #{workContent}</if>
            <if test="contractor != null "> and contractor = #{contractor}</if>
            <if test="ratifier != null "> and ratifier = #{ratifier}</if>
            <if test="mainDangerousMark != null  and mainDangerousMark != ''"> and main_dangerous_mark = #{mainDangerousMark}</if>
            <if test="dangerousMarkDetial != null  and dangerousMarkDetial != ''"> and dangerous_mark_detial = #{dangerousMarkDetial}</if>
            <if test="licenceInfo != null  and licenceInfo != ''"> and licence_info = #{licenceInfo}</if>
            <if test="relationSign != null  and relationSign != ''"> and relation_sign = #{relationSign}</if>
            <if test="produceComfirm != null  and produceComfirm != ''"> and produce_comfirm = #{produceComfirm}</if>
            <if test="workDeal != null  and workDeal != ''"> and work_deal = #{workDeal}</if>
            <if test="applyStatus != null  and applyStatus != ''"> and apply_status = #{applyStatus}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
        GROUP BY permit.work_permit_id
        ORDER BY create_time DESC
    </select>
212 213 214 215 216
    <select id="selectSign" resultType="java.lang.Integer" parameterType="java.lang.Long">
        SELECT COUNT(sign_id) FROM t_special_work_permit_sign WHERE
        permit_id IN (SELECT special_work_permit_id FROM t_special_work_permit WHERE work_permit_id = #{workPermitId} )
        AND sign_name IS NULL
    </select>
耿迪迪's avatar
耿迪迪 committed
217
</mapper>