RepairsOrderMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.chuanghai.repair.mapper.RepairsOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.chuanghai.repair.entity.RepairsOrder">
  5. <!--
  6. WARNING - @mbg.generated
  7. -->
  8. <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
  9. <result column="order_images" property="orderImages" jdbcType="VARCHAR"/>
  10. <result column="order_note" property="orderNote" jdbcType="VARCHAR"/>
  11. <result column="order_expected_time" property="orderExpectedTime" jdbcType="TIMESTAMP"/>
  12. <result column="order_complete_time" property="orderCompleteTime" jdbcType="TIMESTAMP"/>
  13. <result column="order_commit_time" property="orderCommitTime" jdbcType="TIMESTAMP"/>
  14. <result column="order_back_time" property="orderBackTime" jdbcType="TIMESTAMP"/>
  15. <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
  16. <result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
  17. <result column="order_price" property="orderPrice" jdbcType="DECIMAL"/>
  18. <result column="order_price_status" property="orderPriceStatus" jdbcType="VARCHAR"/>
  19. <result column="order_back" property="orderBack" jdbcType="VARCHAR"/>
  20. </resultMap>
  21. <resultMap id="OrderFaultStudentMap" type="com.chuanghai.repair.entity.RepairsOrder" >
  22. <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
  23. <result column="order_images" property="orderImages" jdbcType="VARCHAR"/>
  24. <result column="order_note" property="orderNote" jdbcType="VARCHAR"/>
  25. <result column="order_expected_time" property="orderExpectedTime" jdbcType="VARCHAR"/>
  26. <result column="order_complete_time" property="orderCompleteTime" jdbcType="TIMESTAMP"/>
  27. <result column="order_commit_time" property="orderCommitTime" jdbcType="TIMESTAMP"/>
  28. <result column="order_back_time" property="orderBackTime" jdbcType="TIMESTAMP"/>
  29. <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
  30. <result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
  31. <result column="order_price" property="orderPrice" jdbcType="DECIMAL"/>
  32. <result column="order_price_status" property="orderPriceStatus" jdbcType="VARCHAR"/>
  33. <result column="order_back" property="orderBack" jdbcType="VARCHAR"/>
  34. <!-- 订单与学生之间是 N:1 关系-->
  35. <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
  36. <id column="student_id" property="studentId"></id>
  37. <result column="dorm_number" property="dormNumber" jdbcType="VARCHAR"/>
  38. <result column="student_phone" property="studentPhone" jdbcType="VARCHAR"/>
  39. <result column="student_other_phone" property="studentOtherPhone" jdbcType="VARCHAR"/>
  40. </association >
  41. <!-- 订单与维修工之间是 N:1 关系-->
  42. <association property="repairsWork" javaType="com.chuanghai.repair.entity.RepairsWork">
  43. <id column="work_id" property="workId"></id>
  44. <id column="work_name" property="workName"></id>
  45. </association >
  46. <!-- 订单与故障类型之间是 N:1 关系-->
  47. <association property="repairsFault" javaType="com.chuanghai.repair.entity.RepairsFault">
  48. <id column="fault_id" property="faultId"></id>
  49. <result column="fault_name" property="faultName" jdbcType="VARCHAR"/>
  50. </association >
  51. </resultMap>
  52. <!-- 通过时间查询订单信息-->
  53. <select id="queryAllOrderByDate" parameterType="java.lang.String" resultMap="OrderFaultStudentMap">
  54. select od.order_id, od.order_status,od.order_commit_time, fa.fault_name,st.dorm_number,
  55. od.order_complete_time,od.order_expected_time,wo.work_name,od.order_back,st.student_phone,st.student_other_phone
  56. from
  57. repairs_order od left join repairs_student st on od.student_id = st.student_id
  58. left join repairs_fault fa on od.fault_id = fa.fault_id
  59. left join repairs_work wo on od.work_id = wo.work_id
  60. <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
  61. <if test="tody!='' and tody!=null">
  62. and od.order_complete_time BETWEEN #{tody} and #{tomorrow}
  63. </if>
  64. <if test = "orderStatus == '1'.toString()">
  65. and od.work_id = wo.work_id
  66. and od.order_status =#{orderStatus}
  67. </if>
  68. <if test = "orderStatus == '2'.toString()">
  69. and od.work_id = wo.work_id
  70. and od.order_status =#{orderStatus}
  71. </if>
  72. <if test = "orderStatus == '3'.toString()">
  73. and od.work_id = wo.work_id
  74. and od.order_status =#{orderStatus}
  75. </if>
  76. <if test = "orderStatus == '123'.toString()">
  77. and od.order_status not in ("0","4")
  78. </if>
  79. </trim>
  80. order by od.order_complete_time desc, fa.fault_level desc
  81. </select>
  82. <!-- 通过时间查询订单信息-->
  83. <select id="queryAllNewBackOrder" parameterType="java.lang.String" resultMap="OrderFaultStudentMap">
  84. select od.order_id, od.order_status,od.order_commit_time, fa.fault_name,st.dorm_number,
  85. od.order_complete_time,od.order_expected_time,wo.work_name,od.order_back,st.student_phone,
  86. st.student_other_phone,od.order_back_time
  87. from
  88. repairs_order od left join repairs_student st on od.student_id = st.student_id
  89. left join repairs_fault fa on od.fault_id = fa.fault_id
  90. left join repairs_work wo on od.work_id = wo.work_id
  91. <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
  92. <if test="tody!='' and tody!=null">
  93. and od.order_expected_time BETWEEN #{tody} and #{tomorrow}
  94. </if>
  95. <if test = "orderStatus == '0'.toString()">
  96. and od.order_status =#{orderStatus}
  97. order by od.order_expected_time desc
  98. </if>
  99. <if test = "orderStatus == '4'.toString()">
  100. and od.order_status =#{orderStatus}
  101. order by od.order_back_time desc
  102. </if>
  103. </trim>
  104. </select>
  105. <!-- 通过ID查询订单信息-->
  106. <select id="queryAllOrderById" parameterType="java.lang.String" resultMap="OrderFaultStudentMap">
  107. select od.order_id, od.order_status,od.order_commit_time, fa.fault_name,st.dorm_number, od.order_expected_time, od.order_back
  108. from repairs_order od ,repairs_student st ,repairs_fault fa
  109. <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
  110. od.student_id = st.student_id
  111. and od.fault_id = fa.fault_id
  112. <if test="studentId!='' and studentId!=null">
  113. and od.student_id = #{studentId}
  114. </if>
  115. <if test="workId!='' and workId!=null">
  116. and od.work_id = #{workId}
  117. </if>
  118. <if test="campus!='' and campus!=null">
  119. and st.student_campus = #{campus}
  120. </if>
  121. order by od.order_commit_time desc
  122. </trim>
  123. </select>
  124. <!-- 订单修后评价-->
  125. <select id="updateOrderAdvice" parameterType="java.lang.String" resultType="java.lang.Integer">
  126. update repairs_order
  127. <set>
  128. <if test="orderAdvice!='' and orderAdvice!= null">
  129. order_advice = #{orderAdvice},
  130. </if>
  131. </set>
  132. <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
  133. <if test="orderId!='' and orderId!=null">
  134. and order_id = #{orderId}
  135. </if>
  136. </trim>
  137. </select>
  138. <!-- 查询所有新订单状态的订单 order_status = 0 -->
  139. <select id="queryAllOrderNotReceive" resultMap="OrderFaultStudentMap">
  140. select * from repairs_order where order_status = 0
  141. </select>
  142. <resultMap id="queryByOrderIdMap" type="com.chuanghai.repair.entity.RepairsOrder" >
  143. <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
  144. <result column="order_images" property="orderImages" jdbcType="VARCHAR"/>
  145. <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
  146. <result column="order_status" property="orderStatus" jdbcType="VARCHAR"/>
  147. <result column="order_expected_time" property="orderExpectedTime" jdbcType="VARCHAR"/>
  148. <result column="order_back" property="orderBack" jdbcType="VARCHAR"/>
  149. <!-- 订单与学生之间是 N:1 关系-->
  150. <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
  151. <id column="student_id" property="studentId"></id>
  152. <result column="student_phone" property="studentPhone" jdbcType="VARCHAR"/>
  153. <result column="student_other_phone" property="studentOtherPhone" jdbcType="VARCHAR"/>
  154. <result column="dorm_number" property="dormNumber" jdbcType="VARCHAR"/>
  155. </association >
  156. <!-- 订单与故障类型之间是 N:1 关系-->
  157. <association property="repairsFault" javaType="com.chuanghai.repair.entity.RepairsFault">
  158. <id column="fault_id" property="faultId"></id>
  159. <result column="fault_name" property="faultName" jdbcType="VARCHAR"/>
  160. </association >
  161. <!-- 订单与维修工之间是 N:1 关系-->
  162. <association property="repairsWork" javaType="com.chuanghai.repair.entity.RepairsWork">
  163. <id column="work_id" property="workId"></id>
  164. <id column="work_name" property="workName"></id>
  165. </association >
  166. </resultMap>
  167. <!-- 查询指定订单ID 的订单-->
  168. <select id="queryByOrderId" parameterType="java.lang.String" resultMap="queryByOrderIdMap">
  169. 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,
  170. st.student_phone,st.student_other_phone, od.order_images, wo.work_name,od.order_status
  171. from repairs_order od ,repairs_student st ,repairs_fault fa, repairs_work wo
  172. <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
  173. od.student_id = st.student_id
  174. and od.fault_id = fa.fault_id
  175. and od.work_id = wo.work_id
  176. <if test="orderId!='' and orderId!=null">
  177. and od.order_id =#{orderId}
  178. </if>
  179. </trim>
  180. </select>
  181. <!-- 查询指定订单ID 的订单-->
  182. <select id="queryByOrderIdNotWork" parameterType="java.lang.String" resultMap="queryByOrderIdMap">
  183. 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,
  184. st.student_phone,st.student_other_phone, od.order_images,od.order_status
  185. from repairs_order od ,repairs_student st ,repairs_fault fa
  186. <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
  187. od.student_id = st.student_id
  188. and od.fault_id = fa.fault_id
  189. <if test="orderId!='' and orderId!=null">
  190. and od.order_id =#{orderId}
  191. </if>
  192. </trim>
  193. </select>
  194. <!-- 管理员手动派单 同时修改两个参数-->
  195. <update id="updateRepairsOrderBath" parameterType="java.util.List" >
  196. update repairs_order
  197. <trim prefix="set" suffixOverrides=",">
  198. <trim prefix="order_status=case" suffix="end,">
  199. <foreach collection="list" item="item" index="index">
  200. when order_id = #{item.orderId} then #{item.orderStatus}
  201. </foreach>
  202. </trim>
  203. <trim prefix="work_id=case" suffix="end,">
  204. <foreach collection="list" item="item" index="index">
  205. when order_id = #{item.orderId} then #{item.repairsWork.workId}
  206. </foreach>
  207. </trim>
  208. <trim prefix="order_complete_time=case" suffix="end,">
  209. <foreach collection="list" item="item" index="index">
  210. when order_id = #{item.orderId} then #{item.orderCompleteTime}
  211. </foreach>
  212. </trim>
  213. </trim>
  214. where order_id in
  215. <foreach collection="list" index="index" item="item"
  216. separator="," open="(" close=")">
  217. #{item.orderId,jdbcType=VARCHAR}
  218. </foreach>
  219. </update>
  220. <!-- 系统自动派单 修改对应的订单-->
  221. <update id="updateOrderWorkId" parameterType="java.util.Map">
  222. update repairs_order set work_id = #{workId},order_status = 1 where order_id = #{orderId}
  223. </update>
  224. <!-- 订单填报-->
  225. <insert id="insertOrder" parameterType="com.chuanghai.repair.entity.RepairsOrder">
  226. insert into repairs_order (order_id,order_images,order_note,order_expected_time,order_status,order_price,
  227. order_price_status,student_id,order_commit_time,fault_id)
  228. values(#{orderId},#{orderImages},#{orderNote},#{orderExpectedTime},#{orderStatus},
  229. #{orderPrice},#{orderPriceStatus},#{repairsStudent.studentId},#{orderCommitTime},#{repairsFault.faultId});
  230. </insert>
  231. <!-- 订单修改状态 已接单 已完成 退单 拒绝状态-->
  232. <update id="updateOrderStatus" parameterType="java.util.List" >
  233. update repairs_order
  234. <trim prefix="set" suffixOverrides=",">
  235. <trim prefix="order_status=case" suffix="end,">
  236. <foreach collection="list" item="item" index="index">
  237. when order_id = #{item.orderId} then #{item.orderStatus}
  238. </foreach>
  239. </trim>
  240. <trim prefix="order_back=case" suffix="end,">
  241. <foreach collection="list" item="item" index="index">
  242. when order_id = #{item.orderId} then #{item.orderBack}
  243. </foreach>
  244. </trim>
  245. <trim prefix="work_id=case" suffix="end,">
  246. <foreach collection="list" item="item" index="index">
  247. <if test="item.repairsWork.workId == null ">
  248. when order_id = #{item.orderId} then #{item.repairsWork.workId}
  249. </if>
  250. </foreach>
  251. </trim>
  252. <trim prefix="order_complete_time=case" suffix="end,">
  253. <foreach collection="list" item="item" index="index">
  254. <if test="item.orderCompleteTime != null ">
  255. when order_id = #{item.orderId} then #{item.orderCompleteTime}
  256. </if>
  257. </foreach>
  258. </trim>
  259. <trim prefix="order_back_time=case" suffix="end,">
  260. <foreach collection="list" item="item" index="index">
  261. <if test="item.orderBackTime != null ">
  262. when order_id = #{item.orderId} then #{item.orderBackTime}
  263. </if>
  264. </foreach>
  265. </trim>
  266. </trim>
  267. where order_id in
  268. <foreach collection="list" index="index" item="item"
  269. separator="," open="(" close=")">
  270. #{item.orderId,jdbcType=VARCHAR}
  271. </foreach>
  272. </update>
  273. <resultMap id="orderTimeMap" type="com.chuanghai.repair.entity.RepairsOrder">
  274. <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
  275. <!-- 订单与学生之间是 N:1 关系-->
  276. <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
  277. <id column="student_id" property="studentId"></id>
  278. </association >
  279. </resultMap>
  280. <!-- 查询与系统时间相差半小时的订单编号-->
  281. <select id="queryByTime" parameterType="java.lang.String" resultMap="orderTimeMap">
  282. select st.student_id from repairs_order od,repairs_student st
  283. where od.student_id = st.student_id
  284. and od.order_complete_time BETWEEN #{systemTime} AND #{changeTime}
  285. </select>
  286. <resultMap id="OrderAdviceMap" type="com.chuanghai.repair.entity.RepairsOrder" >
  287. <id column="order_id" property="orderId" jdbcType="VARCHAR"/>
  288. <result column="order_complete_time" property="orderCompleteTime" jdbcType="TIMESTAMP"/>
  289. <result column="order_advice" property="orderAdvice" jdbcType="VARCHAR"/>
  290. <!-- 订单与学生之间是 N:1 关系-->
  291. <association property="repairsStudent" javaType="com.chuanghai.repair.entity.RepairsStudent">
  292. <id column="student_id" property="studentId"></id>
  293. <result column="dorm_number" property="dormNumber" jdbcType="VARCHAR"/>
  294. </association >
  295. <!-- 订单与维修工之间是 N:1 关系-->
  296. <association property="repairsWork" javaType="com.chuanghai.repair.entity.RepairsWork">
  297. <id column="work_id" property="workId"></id>
  298. <result column="work_name" property="workName" jdbcType="VARCHAR"/>
  299. </association >
  300. <!-- 订单与故障类型之间是 N:1 关系-->
  301. <association property="repairsFault" javaType="com.chuanghai.repair.entity.RepairsFault">
  302. <id column="fault_id" property="faultId"></id>
  303. <result column="fault_name" property="faultName" jdbcType="VARCHAR"/>
  304. </association >
  305. </resultMap>
  306. <!-- 订单意见投诉查询-->
  307. <select id="queryAllOrderByAdvice" parameterType="java.lang.String" resultMap="OrderAdviceMap">
  308. select od.order_id,fa.fault_name,od.order_complete_time,wo.work_name,od.order_advice,st.dorm_number
  309. from repairs_order od,repairs_work wo,repairs_student st ,repairs_fault fa
  310. <trim prefix="where" prefixOverrides="and" suffix="" suffixOverrides="">
  311. od.work_id = wo.work_id
  312. and od.student_id = st.student_id
  313. and od.fault_id = fa.fault_id
  314. and order_advice is not null
  315. <if test="tody!='' and tody!=null">
  316. and od.order_complete_time BETWEEN #{tody} and #{tomorrow}
  317. </if>
  318. <if test="workID!='' and workID!=null">
  319. and wo.work_id = #{workID}
  320. </if>
  321. </trim>
  322. order by od.order_complete_time desc
  323. </select>
  324. </mapper>