TWorkOrderMapper.xml 5.75 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
<?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.TWorkOrderMapper">
    
    <resultMap type="TWorkOrder" id="TWorkOrderResult">
        <result property="orderId"    column="order_id"    />
        <result property="orderType"    column="order_type"    />
        <result property="resourceId"    column="resource_id"    />
        <result property="orderName"    column="order_name"    />
        <result property="orderStatus"    column="order_status"    />
王晓倩's avatar
王晓倩 committed
13
        <result property="archiving"    column="archiving"    />
王晓倩's avatar
王晓倩 committed
14
        <result property="updateTime"    column="update_time"    />
15 16 17 18 19 20 21 22 23 24 25 26
        <result property="appointInspector"    column="appoint_inspector"    />
        <result property="allotTime"    column="allot_time"    />
        <result property="actualInspector"    column="actual_inspector"    />
        <result property="actualTime"    column="actual_time"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <select id="getWorkOrderId" resultType="String">
        select nextval('seq_work_order_id') as id
    </select>

    <sql id="selectTWorkOrderVo">
王晓倩's avatar
王晓倩 committed
27
        select t.order_id, t.order_type, t.resource_id, t.order_name, t.order_status, t.archiving, t.update_time, t.appoint_inspector, t.allot_time, t.actual_inspector, t.actual_time, t.remarks
28 29
        from t_work_order t
        left join sys_user s on t.appoint_inspector = s.user_id
30 31
    </sql>

32
    <select id="selectTWorkOrderList" parameterType="TWorkOrderForm" resultMap="TWorkOrderResult">
33
        <include refid="selectTWorkOrderVo"/>
34 35 36 37 38 39 40 41 42
        <where>
            <if test="orderId != null  and orderId != ''"> and t.order_id like concat('%',#{orderId},'%')</if>
            <if test="orderType != null  and orderType != ''"> and t.order_type = #{orderType}</if>
            <if test="orderName != null  and orderName != ''"> and t.order_name like concat('%', #{orderName}, '%')</if>
            <if test="orderStatus != null  and orderStatus != ''"> and t.order_status = #{orderStatus}</if>
            <if test="appointInspector != null "> and t.appoint_inspector = #{appointInspector}</if>
            <if test="startAllotTime != null "> and t.allot_time &gt;= #{startAllotTime}</if>
            <if test="endAllotTime != null "> and t.allot_time &lt;= #{endAllotTime}</if>
            <if test="userName != null  and userName != ''"> and s.user_name = #{userName}</if>
43 44 45 46 47
        </where>
    </select>
    
    <select id="selectTWorkOrderById" parameterType="String" resultMap="TWorkOrderResult">
        <include refid="selectTWorkOrderVo"/>
48
        where t.order_id = #{orderId}
49 50 51 52 53 54 55 56 57 58
    </select>
        
    <insert id="insertTWorkOrder" parameterType="TWorkOrder">
        insert into t_work_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="orderType != null">order_type,</if>
            <if test="resourceId != null">resource_id,</if>
            <if test="orderName != null">order_name,</if>
            <if test="orderStatus != null">order_status,</if>
王晓倩's avatar
王晓倩 committed
59
            <if test="archiving != null">archiving,</if>
王晓倩's avatar
王晓倩 committed
60
            <if test="updateTime != null">update_time,</if>
61 62 63 64 65 66 67 68 69 70 71 72
            <if test="appointInspector != null">appoint_inspector,</if>
            <if test="allotTime != null">allot_time,</if>
            <if test="actualInspector != null">actual_inspector,</if>
            <if test="actualTime != null">actual_time,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="orderType != null">#{orderType},</if>
            <if test="resourceId != null">#{resourceId},</if>
            <if test="orderName != null">#{orderName},</if>
            <if test="orderStatus != null">#{orderStatus},</if>
王晓倩's avatar
王晓倩 committed
73
            <if test="archiving != null">#{archiving},</if>
王晓倩's avatar
王晓倩 committed
74
            <if test="updateTime != null">#{updateTime},</if>
75 76 77 78 79 80 81 82 83 84 85 86 87 88
            <if test="appointInspector != null">#{appointInspector},</if>
            <if test="allotTime != null">#{allotTime},</if>
            <if test="actualInspector != null">#{actualInspector},</if>
            <if test="actualTime != null">#{actualTime},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTWorkOrder" parameterType="TWorkOrder">
        update t_work_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderType != null">order_type = #{orderType},</if>
            <if test="orderName != null">order_name = #{orderName},</if>
            <if test="orderStatus != null">order_status = #{orderStatus},</if>
王晓倩's avatar
王晓倩 committed
89
            <if test="archiving != null">archiving = #{archiving},</if>
王晓倩's avatar
王晓倩 committed
90
            <if test="updateTime != null">update_time = #{updateTime},</if>
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
            <if test="appointInspector != null">appoint_inspector = #{appointInspector},</if>
            <if test="allotTime != null">allot_time = #{allotTime},</if>
            <if test="actualInspector != null">actual_inspector = #{actualInspector},</if>
            <if test="actualTime != null">actual_time = #{actualTime},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where order_id = #{orderId}
    </update>

    <delete id="deleteTWorkOrderById" parameterType="String">
        delete from t_work_order where order_id = #{orderId}
    </delete>

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