| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.chuanghai.repair.mapper.RepairsOrderMapper">
- <resultMap id="BaseResultMap" type="com.chuanghai.repair.entity.RepairsOrder">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
- <result column="order_images" property="orderImages" jdbcType="VARCHAR"/>
- <result column="order_note" property="orderNote" jdbcType="VARCHAR"/>
- <result column="order_expected_time" property="orderExpectedTime" jdbcType="TIMESTAMP"/>
- <result column="order_complete_time" property="orderCompleteTime" jdbcType="TIMESTAMP"/>
- <result column="order_commit_time" property="orderCommitTime" jdbcType="TIMESTAMP"/>
- <result column="order_back_time" property="orderBackTime" jdbcType="TIMESTAMP"/>
- <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
- <result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
- <result column="order_price" property="orderPrice" jdbcType="DECIMAL"/>
- <result column="order_price_status" property="orderPriceStatus" jdbcType="VARCHAR"/>
- <result column="order_back" property="orderBack" jdbcType="VARCHAR"/>
- </resultMap>
- <resultMap id="OrderFaultStudentMap" type="com.chuanghai.repair.entity.RepairsOrder" >
- <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
- <result column="order_images" property="orderImages" jdbcType="VARCHAR"/>
- <result column="order_note" property="orderNote" jdbcType="VARCHAR"/>
- <result column="order_expected_time" property="orderExpectedTime" jdbcType="VARCHAR"/>
- <result column="order_complete_time" property="orderCompleteTime" jdbcType="TIMESTAMP"/>
- <result column="order_commit_time" property="orderCommitTime" jdbcType="TIMESTAMP"/>
- <result column="order_back_time" property="orderBackTime" jdbcType="TIMESTAMP"/>
- <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
- <result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
- <result column="order_price" property="orderPrice" jdbcType="DECIMAL"/>
- <result column="order_price_status" property="orderPriceStatus" jdbcType="VARCHAR"/>
- <result column="order_back" property="orderBack" jdbcType="VARCHAR"/>
- <!-- 订单与学生之间是 N:1 关系-->
- <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
- <id column="student_id" property="studentId"></id>
- <result column="dorm_number" property="dormNumber" jdbcType="VARCHAR"/>
- <result column="student_phone" property="studentPhone" jdbcType="VARCHAR"/>
- <result column="student_other_phone" property="studentOtherPhone" jdbcType="VARCHAR"/>
- </association >
- <!-- 订单与维修工之间是 N:1 关系-->
- <association property="repairsWork" javaType="com.chuanghai.repair.entity.RepairsWork">
- <id column="work_id" property="workId"></id>
- <id column="work_name" property="workName"></id>
- </association >
- <!-- 订单与故障类型之间是 N:1 关系-->
- <association property="repairsFault" javaType="com.chuanghai.repair.entity.RepairsFault">
- <id column="fault_id" property="faultId"></id>
- <result column="fault_name" property="faultName" jdbcType="VARCHAR"/>
- </association >
- </resultMap>
- <!-- 通过时间查询订单信息-->
- <select id="queryAllOrderByDate" parameterType="java.lang.String" resultMap="OrderFaultStudentMap">
- select od.order_id, od.order_status,od.order_commit_time, fa.fault_name,st.dorm_number,
- od.order_complete_time,od.order_expected_time,wo.work_name,od.order_back,st.student_phone,st.student_other_phone
- from
- repairs_order od left join repairs_student st on od.student_id = st.student_id
- left join repairs_fault fa on od.fault_id = fa.fault_id
- left join repairs_work wo on od.work_id = wo.work_id
- <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
- <if test="tody!='' and tody!=null">
- and od.order_complete_time BETWEEN #{tody} and #{tomorrow}
- </if>
- <if test = "orderStatus == '1'.toString()">
- and od.work_id = wo.work_id
- and od.order_status =#{orderStatus}
- </if>
- <if test = "orderStatus == '2'.toString()">
- and od.work_id = wo.work_id
- and od.order_status =#{orderStatus}
- </if>
- <if test = "orderStatus == '3'.toString()">
- and od.work_id = wo.work_id
- and od.order_status =#{orderStatus}
- </if>
- <if test = "orderStatus == '123'.toString()">
- and od.order_status not in ("0","4")
- </if>
- </trim>
- order by od.order_complete_time desc, fa.fault_level desc
- </select>
- <!-- 通过时间查询订单信息-->
- <select id="queryAllNewBackOrder" parameterType="java.lang.String" resultMap="OrderFaultStudentMap">
- select od.order_id, od.order_status,od.order_commit_time, fa.fault_name,st.dorm_number,
- od.order_complete_time,od.order_expected_time,wo.work_name,od.order_back,st.student_phone,
- st.student_other_phone,od.order_back_time
- from
- repairs_order od left join repairs_student st on od.student_id = st.student_id
- left join repairs_fault fa on od.fault_id = fa.fault_id
- left join repairs_work wo on od.work_id = wo.work_id
- <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
- <if test="tody!='' and tody!=null">
- and od.order_expected_time BETWEEN #{tody} and #{tomorrow}
- </if>
- <if test = "orderStatus == '0'.toString()">
- and od.order_status =#{orderStatus}
- order by od.order_expected_time desc
- </if>
- <if test = "orderStatus == '4'.toString()">
- and od.order_status =#{orderStatus}
- order by od.order_back_time desc
- </if>
- </trim>
- </select>
- <!-- 通过ID查询订单信息-->
- <select id="queryAllOrderById" parameterType="java.lang.String" resultMap="OrderFaultStudentMap">
- select od.order_id, od.order_status,od.order_commit_time, fa.fault_name,st.dorm_number, od.order_expected_time, od.order_back
- from repairs_order od ,repairs_student st ,repairs_fault fa
- <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
- od.student_id = st.student_id
- and od.fault_id = fa.fault_id
- <if test="studentId!='' and studentId!=null">
- and od.student_id = #{studentId}
- </if>
- <if test="workId!='' and workId!=null">
- and od.work_id = #{workId}
- </if>
- <if test="campus!='' and campus!=null">
- and st.student_campus = #{campus}
- </if>
- order by od.order_commit_time desc
- </trim>
- </select>
- <!-- 订单修后评价-->
- <select id="updateOrderAdvice" parameterType="java.lang.String" resultType="java.lang.Integer">
- update repairs_order
- <set>
- <if test="orderAdvice!='' and orderAdvice!= null">
- order_advice = #{orderAdvice},
- </if>
- </set>
- <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
- <if test="orderId!='' and orderId!=null">
- and order_id = #{orderId}
- </if>
- </trim>
- </select>
- <!-- 查询所有新订单状态的订单 order_status = 0 -->
- <select id="queryAllOrderNotReceive" resultMap="OrderFaultStudentMap">
- select * from repairs_order where order_status = 0
- </select>
- <resultMap id="queryByOrderIdMap" type="com.chuanghai.repair.entity.RepairsOrder" >
- <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
- <result column="order_images" property="orderImages" jdbcType="VARCHAR"/>
- <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
- <result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
- <result column="order_expected_time" property="orderExpectedTime" jdbcType="VARCHAR"/>
- <result column="order_back" property="orderBack" jdbcType="VARCHAR"/>
- <!-- 订单与学生之间是 N:1 关系-->
- <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
- <id column="student_id" property="studentId"></id>
- <result column="student_phone" property="studentPhone" jdbcType="VARCHAR"/>
- <result column="student_other_phone" property="studentOtherPhone" jdbcType="VARCHAR"/>
- <result column="dorm_number" property="dormNumber" jdbcType="VARCHAR"/>
- </association >
- <!-- 订单与故障类型之间是 N:1 关系-->
- <association property="repairsFault" javaType="com.chuanghai.repair.entity.RepairsFault">
- <id column="fault_id" property="faultId"></id>
- <result column="fault_name" property="faultName" jdbcType="VARCHAR"/>
- </association >
- <!-- 订单与维修工之间是 N:1 关系-->
- <association property="repairsWork" javaType="com.chuanghai.repair.entity.RepairsWork">
- <id column="work_id" property="workId"></id>
- <id column="work_name" property="workName"></id>
- </association >
- </resultMap>
- <!-- 查询指定订单ID 的订单-->
- <select id="queryByOrderId" parameterType="java.lang.String" resultMap="queryByOrderIdMap">
- select od.order_id, od.order_commit_time, fa.fault_name,st.dorm_number, od.order_complete_time,od.order_expected_time,od.order_back,
- st.student_phone,st.student_other_phone, od.order_images, wo.work_name,od.order_status
- from repairs_order od ,repairs_student st ,repairs_fault fa, repairs_work wo
- <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
- od.student_id = st.student_id
- and od.fault_id = fa.fault_id
- and od.work_id = wo.work_id
- <if test="orderId!='' and orderId!=null">
- and od.order_id =#{orderId}
- </if>
- </trim>
- </select>
- <!-- 查询指定订单ID 的订单-->
- <select id="queryByOrderIdNotWork" parameterType="java.lang.String" resultMap="queryByOrderIdMap">
- select od.order_id, od.order_commit_time, fa.fault_name,st.dorm_number, od.order_complete_time,od.order_expected_time,od.order_back,
- st.student_phone,st.student_other_phone, od.order_images,od.order_status
- from repairs_order od ,repairs_student st ,repairs_fault fa
- <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
- od.student_id = st.student_id
- and od.fault_id = fa.fault_id
- <if test="orderId!='' and orderId!=null">
- and od.order_id =#{orderId}
- </if>
- </trim>
- </select>
- <!-- 管理员手动派单 同时修改两个参数-->
- <update id="updateRepairsOrderBath" parameterType="java.util.List" >
- update repairs_order
- <trim prefix="set" suffixOverrides=",">
- <trim prefix="order_status=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- when order_id = #{item.orderId} then #{item.orderStatus}
- </foreach>
- </trim>
- <trim prefix="work_id=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- when order_id = #{item.orderId} then #{item.repairsWork.workId}
- </foreach>
- </trim>
- <trim prefix="order_complete_time=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- when order_id = #{item.orderId} then #{item.orderCompleteTime}
- </foreach>
- </trim>
- </trim>
- where order_id in
- <foreach collection="list" index="index" item="item"
- separator="," open="(" close=")">
- #{item.orderId,jdbcType=VARCHAR}
- </foreach>
- </update>
- <!-- 系统自动派单 修改对应的订单-->
- <update id="updateOrderWorkId" parameterType="java.util.Map">
- update repairs_order set work_id = #{workId},order_status = 1 where order_id = #{orderId}
- </update>
- <!-- 订单填报-->
- <insert id="insertOrder" parameterType="com.chuanghai.repair.entity.RepairsOrder">
- insert into repairs_order (order_id,order_images,order_note,order_expected_time,order_status,order_price,
- order_price_status,student_id,order_commit_time,fault_id)
- values(#{orderId},#{orderImages},#{orderNote},#{orderExpectedTime},#{orderStatus},
- #{orderPrice},#{orderPriceStatus},#{repairsStudent.studentId},#{orderCommitTime},#{repairsFault.faultId});
- </insert>
- <!-- 订单修改状态 已接单 已完成 退单 拒绝状态-->
- <update id="updateOrderStatus" parameterType="java.util.List" >
- update repairs_order
- <trim prefix="set" suffixOverrides=",">
- <trim prefix="order_status=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- when order_id = #{item.orderId} then #{item.orderStatus}
- </foreach>
- </trim>
- <trim prefix="order_back=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- when order_id = #{item.orderId} then #{item.orderBack}
- </foreach>
- </trim>
- <trim prefix="work_id=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- <if test="item.repairsWork.workId == null ">
- when order_id = #{item.orderId} then #{item.repairsWork.workId}
- </if>
- </foreach>
- </trim>
- <trim prefix="order_complete_time=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- <if test="item.orderCompleteTime != null ">
- when order_id = #{item.orderId} then #{item.orderCompleteTime}
- </if>
- </foreach>
- </trim>
- <trim prefix="order_back_time=case" suffix="end,">
- <foreach collection="list" item="item" index="index">
- <if test="item.orderBackTime != null ">
- when order_id = #{item.orderId} then #{item.orderBackTime}
- </if>
- </foreach>
- </trim>
- </trim>
- where order_id in
- <foreach collection="list" index="index" item="item"
- separator="," open="(" close=")">
- #{item.orderId,jdbcType=VARCHAR}
- </foreach>
- </update>
- <resultMap id="orderTimeMap" type="com.chuanghai.repair.entity.RepairsOrder">
- <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
- <!-- 订单与学生之间是 N:1 关系-->
- <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
- <id column="student_id" property="studentId"></id>
- </association >
- </resultMap>
- <!-- 查询与系统时间相差半小时的订单编号-->
- <select id="queryByTime" parameterType="java.lang.String" resultMap="orderTimeMap">
- select st.student_id from repairs_order od,repairs_student st
- where od.student_id = st.student_id
- and od.order_complete_time BETWEEN #{systemTime} AND #{changeTime}
- </select>
- <resultMap id="OrderAdviceMap" type="com.chuanghai.repair.entity.RepairsOrder" >
- <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
- <result column="order_complete_time" property="orderCompleteTime" jdbcType="TIMESTAMP"/>
- <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
- <!-- 订单与学生之间是 N:1 关系-->
- <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
- <id column="student_id" property="studentId"></id>
- <result column="dorm_number" property="dormNumber" jdbcType="VARCHAR"/>
- </association >
- <!-- 订单与维修工之间是 N:1 关系-->
- <association property="repairsWork" javaType="com.chuanghai.repair.entity.RepairsWork">
- <id column="work_id" property="workId"></id>
- <result column="work_name" property="workName" jdbcType="VARCHAR"/>
- </association >
- <!-- 订单与故障类型之间是 N:1 关系-->
- <association property="repairsFault" javaType="com.chuanghai.repair.entity.RepairsFault">
- <id column="fault_id" property="faultId"></id>
- <result column="fault_name" property="faultName" jdbcType="VARCHAR"/>
- </association >
- </resultMap>
- <!-- 订单意见投诉查询-->
- <select id="queryAllOrderByAdvice" parameterType="java.lang.String" resultMap="OrderAdviceMap">
- select od.order_id,fa.fault_name,od.order_complete_time,wo.work_name,od.order_advice,st.dorm_number
- from repairs_order od,repairs_work wo,repairs_student st ,repairs_fault fa
- <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
- od.work_id = wo.work_id
- and od.student_id = st.student_id
- and od.fault_id = fa.fault_id
- and order_advice is not null
- <if test="tody!='' and tody!=null">
- and od.order_complete_time BETWEEN #{tody} and #{tomorrow}
- </if>
- <if test="workID!='' and workID!=null">
- and wo.work_id = #{workID}
- </if>
- </trim>
- order by od.order_complete_time desc
- </select>
- </mapper>
|