RepairApplicationFormMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.platform.dao.mapper.repair.RepairApplicationFormMapper">
  4. <sql id="Base_Column_List">
  5. application.*,
  6. user.real_name as userName,
  7. user2.real_name as repairUserName,
  8. user3.username as checkUserName,
  9. sb.model as model,
  10. sb.name as sbName,part.name as partName,
  11. sb.no as sbNo, sb.cph as sbCph, sb.model_id as modelId,
  12. error.name as repairErrorTypeName
  13. </sql>
  14. <select id="selectPageList" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
  15. resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
  16. select
  17. <include refid="Base_Column_List"/>
  18. from t_repair_application_form application
  19. left join t_sys_user user on application.user_id = user.user_id
  20. left join t_sys_user user2 on application.repair_user_id = user2.user_id
  21. left join t_sys_user user3 on application.dispatch_user_id = user3.user_id
  22. left join t_sb_info sb on application.sb_id = sb.id
  23. left join t_error_type error on application.repair_error_type_id = error.id
  24. left join t_part_info part on application.part_id = part.id
  25. <where>
  26. <if test="keyword != null and keyword != ''">
  27. and ( sb.name like concat('%',#{keyword},'%') or
  28. sb.no like concat('%',#{keyword},'%') or
  29. application.content like concat('%',#{keyword},'%') )
  30. </if>
  31. <if test="content != null and content != ''">
  32. and application.content like concat('%',#{content},'%')
  33. </if>
  34. <if test="sbId != null and sbId != ''">
  35. and application.sb_id = #{sbId}
  36. </if>
  37. <if test="category != null and category != ''">
  38. and application.category = #{category}
  39. </if>
  40. <if test="categoryList != null and categoryList.size > 0">
  41. AND application.category in
  42. <foreach item="item" index="index" collection="categoryList" open="(" close=")" separator=",">
  43. #{item}
  44. </foreach>
  45. </if>
  46. <if test="zbh != null and zbh != ''">
  47. and sb.zbh = #{zbh}
  48. </if>
  49. <if test="no != null and no != ''">
  50. and application.no = #{no}
  51. </if>
  52. <if test="planFlag != null and planFlag != ''">
  53. and application.plan_flag = #{planFlag}
  54. </if>
  55. <if test="status != null and status != ''">
  56. and application.status = #{status}
  57. </if>
  58. <if test="actualUser != null and actualUser != ''">
  59. and application.actual_user = #{actualUser}
  60. </if>
  61. <if test="mainRepairId != null and mainRepairId != ''">
  62. and application.main_repair_id = #{mainRepairId}
  63. </if>
  64. <if test="outType != null and outType != ''">
  65. and application.out_type = #{outType}
  66. </if>
  67. <if test="type != null and type != ''">
  68. and application.type = #{type}
  69. </if>
  70. <if test="status != null and status != ''">
  71. and application.status = #{status}
  72. </if>
  73. <if test="userId != null and userId != ''">
  74. and application.user_id = #{userId}
  75. </if>
  76. <if test="repairUserId != null and repairUserId != ''">
  77. and application.repair_user_id = #{repairUserId}
  78. </if>
  79. <if test="checkUserId != null and checkUserId != ''">
  80. and application.check_user_id = #{checkUserId}
  81. </if>
  82. <if test="repairUserName != null and repairUserName != ''">
  83. and user2.real_name like concat('%',#{repairUserName},'%')
  84. </if>
  85. <if test="searchStartTime != null">
  86. and application.apply_time <![CDATA[ >= ]]> #{searchStartTime}
  87. </if>
  88. <if test="searchEndTime != null">
  89. and application.apply_time <![CDATA[ <= ]]> #{searchEndTime}
  90. </if>
  91. <!-- 新增查询参数 -->
  92. <if test="statusList != null and statusList.size > 0">
  93. AND application.status in
  94. <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
  95. #{item}
  96. </foreach>
  97. </if>
  98. <if test="repairStartTimeStart != null">
  99. and application.repair_start_time <![CDATA[ > ]]> #{repairStartTimeStart}
  100. </if>
  101. <if test="repairStartTimeEnd != null">
  102. and application.repair_start_time <![CDATA[ < ]]> #{repairStartTimeEnd}
  103. </if>
  104. <if test="dispatchUserId != null">
  105. and application.dispatch_user_id = #{dispatchUserId}
  106. </if>
  107. <if test="checkAllFlag != null and checkAllFlag == 1">
  108. and application.check_user_id is not null
  109. </if>
  110. <if test="repairDeptId != null and repairDeptId != ''">
  111. and application.repair_dept_id = #{repairDeptId}
  112. </if>
  113. <if test="reportLeaderId != null and reportLeaderId != ''">
  114. and application.report_leader_id = #{reportLeaderId}
  115. </if>
  116. </where>
  117. </select>
  118. <select id="selectById" parameterType="java.lang.Object"
  119. resultType="com.platform.dao.entity.repair.RepairApplicationForm">
  120. select
  121. <include refid="Base_Column_List"/>
  122. from t_repair_application_form application
  123. left join t_sys_user user on application.user_id = user.user_id
  124. left join t_sys_user user2 on application.repair_user_id = user2.user_id
  125. left join t_sys_user user3 on application.dispatch_user_id = user3.user_id
  126. left join t_sb_info sb on application.sb_id = sb.id
  127. left join t_part_info part on application.part_id = part.id
  128. left join t_error_type error on application.repair_error_type_id = error.id
  129. where application.id = #{id,jdbcType=VARCHAR}
  130. </select>
  131. <select id="selectNoById" parameterType="java.lang.Object" resultType="java.lang.String">
  132. select no
  133. from t_repair_application_form
  134. where id = #{id,jdbcType=VARCHAR}
  135. </select>
  136. <!-- 维修统计数据 -->
  137. <select id="getWorkplaceRepairData" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
  138. resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
  139. select count(1) as tempTotalNum,rf.status from t_repair_application_form rf
  140. <where>
  141. <if test="repairUserId != null">
  142. and rf.repair_user_id = #{repairUserId}
  143. </if>
  144. <if test="searchTime != null">
  145. and rf.repair_start_time like concat('',#{searchTime},'%')
  146. </if>
  147. <if test="type != null">
  148. and rf.type = #{type}
  149. </if>
  150. </where>
  151. group by rf.status
  152. </select>
  153. <!-- 维修统计数据 -->
  154. <select id="getCurrentlyList" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
  155. resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
  156. select * from t_repair_application_form
  157. <where>
  158. <if test="searchStartTime != null">
  159. and repair_start_time <![CDATA[>]]> #{searchStartTime}
  160. </if>
  161. <if test="searchEndTime != null">
  162. and repair_start_time <![CDATA[<]]> #{searchEndTime}
  163. </if>
  164. <if test="repairUserId != null">
  165. and repair_user_id = #{repairUserId}
  166. </if>
  167. </where>
  168. </select>
  169. <!-- 近月统计单数和费用 -->
  170. <select id="getWorkplaceRepairSumData" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
  171. resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
  172. select count(1) as tempTotalNum from t_repair_application_form rf
  173. <where>
  174. <if test="repairUserId != null">
  175. and rf.repair_user_id = #{repairUserId}
  176. </if>
  177. <if test="searchStartTime != null">
  178. and rf.repair_start_time <![CDATA[>]]> #{searchStartTime}
  179. </if>
  180. <if test="searchEndTime != null">
  181. and rf.repair_start_time <![CDATA[<]]> #{searchEndTime}
  182. </if>
  183. <if test="type != null">
  184. and rf.type = #{type}
  185. </if>
  186. </where>
  187. </select>
  188. <!-- 修改派工维修单 -->
  189. <update id="updateForRepairDispatch" parameterType="com.platform.dao.entity.repair.RepairApplicationForm">
  190. update t_repair_application_form
  191. <set>
  192. repair_end_time = null,
  193. <if test="sbId != null">
  194. sb_id = #{sbId},
  195. </if>
  196. <if test="needStop != null">
  197. need_stop = #{needStop},
  198. </if>
  199. <if test="no != null">
  200. no = #{no},
  201. </if>
  202. <if test="source != null">
  203. source = #{source},
  204. </if>
  205. <if test="applyTime != null">
  206. apply_time = #{applyTime},
  207. </if>
  208. <if test="level != null">
  209. level = #{level},
  210. </if>
  211. <if test="content != null">
  212. content = #{content},
  213. </if>
  214. <if test="status != null">
  215. status= #{status},
  216. </if>
  217. <if test="repairStartTime != null">
  218. repair_start_time = #{repairStartTime},
  219. </if>
  220. <if test="repairDispatchList != null">
  221. repair_dispatch_list = #{repairDispatchList},
  222. </if>
  223. <if test="repairDispatchRemark != null">
  224. repair_dispatch_remark = #{repairDispatchRemark},
  225. </if>
  226. <if test="receiveMinutes != null">
  227. receive_minutes = #{receiveMinutes},
  228. </if>
  229. <if test="repairMinutes != null">
  230. repair_minutes = #{repairMinutes},
  231. </if>
  232. <if test="dealMinutes != null">
  233. deal_minutes = #{dealMinutes},
  234. </if>
  235. <if test="repairOvertime != null">
  236. repair_overtime = #{repairOvertime},
  237. </if>
  238. <if test="receiveOvertime != null">
  239. receive_overtime = #{receiveOvertime},
  240. </if>
  241. <if test="userId != null">
  242. user_id = #{userId},
  243. </if>
  244. <if test="repairUserId != null">
  245. repair_user_id = #{repairUserId},
  246. </if>
  247. <if test="checkUserId != null">
  248. check_user_id = #{checkUserId},
  249. </if>
  250. <if test="checkStartTime != null">
  251. check_start_time = #{checkStartTime},
  252. </if>
  253. <if test="checkContent != null">
  254. check_content = #{checkContent},
  255. </if>
  256. <if test="createdTime != null">
  257. created_time = #{createdTime},
  258. </if>
  259. <if test="updateTime != null">
  260. update_time = #{updateTime},
  261. </if>
  262. <if test="actualUser != null">
  263. actual_user = #{actualUser},
  264. </if>
  265. <if test="type != null">
  266. type = #{type},
  267. </if>
  268. <!--<if test="dispatchUserId">
  269. and dispatch_user_id = #{dispatchUserId}
  270. </if>-->
  271. </set>
  272. where id = #{id}
  273. </update>
  274. <select id="getRepairCount" resultType="com.platform.dao.vo.repair.RepairApplicationFormVO"
  275. parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
  276. >
  277. select status, count(1) repairCount from t_repair_application_form form left JOIN t_sys_user_dept dept ON
  278. dept.user_id=form.repair_user_id
  279. <where>
  280. <if test="statusList != null and statusList.size > 0">
  281. AND form.status in
  282. <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
  283. #{item}
  284. </foreach>
  285. </if>
  286. <if test="userId!=null and userId!=''">
  287. and form.user_id=#{userId}
  288. </if>
  289. <if test="repairUserId!=null and repairUserId!=''">
  290. and form.repair_user_id=#{repairUserId}
  291. </if>
  292. <if test="dispatchUserId!=null and dispatchUserId!=''">
  293. and form.dispatch_user_id=#{dispatchUserId}
  294. </if>
  295. <if test="deptId!=null and deptId!=null">
  296. and dept.dept_id=#{deptId}
  297. </if>
  298. </where>
  299. group by status
  300. </select>
  301. <update id="updateLongYan" parameterType="com.platform.dao.entity.repair.RepairApplicationForm">
  302. update t_repair_application_form
  303. <set>
  304. <choose>
  305. <when test="repairUserId != null">
  306. repair_user_id = #{repairUserId},
  307. </when>
  308. <otherwise>
  309. repair_user_id = null,
  310. </otherwise>
  311. </choose>
  312. <choose>
  313. <when test="repairUseName != null">
  314. repair_user_name = #{repairUseName},
  315. </when>
  316. <otherwise>
  317. repair_user_name = null,
  318. </otherwise>
  319. </choose>
  320. <if test="remark != null">
  321. remark = #{remark},
  322. </if>
  323. <if test="remarkTwo != null">
  324. remark_two = #{remarkTwo},
  325. </if>
  326. <if test="status != null">
  327. status = #{status},
  328. </if>
  329. <if test="repairMinutes != null">
  330. repair_minutes = #{repairMinutes},
  331. </if>
  332. <if test="dispatchUserId != null">
  333. dispatch_user_id = #{dispatchUserId},
  334. </if>
  335. </set>
  336. where id = #{id}
  337. </update>
  338. <select id="getDeptName" parameterType="String"
  339. resultType="String">
  340. select name from t_sys_dept
  341. where dept_id=#{id}
  342. </select>
  343. <select id="getFirstRepairApplicationFormVO" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
  344. resultType="com.platform.dao.vo.repair.RepairApplicationFormVO">
  345. select form.*,info.name sbName,info.cph sbCph,info.no sbNo from t_repair_application_form form left join t_sb_info info
  346. on form.sb_id=info.id
  347. <where>
  348. <if test="userId!=null and userId!=''">
  349. and form.user_id=#{userId}
  350. </if>
  351. <if test="repairUserId!=null and repairUserId!=''">
  352. and form.repair_user_id=#{repairUserId}
  353. </if>
  354. <if test="dispatchUserId!=null and dispatchUserId!=''">
  355. and form.dispatch_user_id=#{dispatchUserId}
  356. </if>
  357. </where>
  358. order by form.update_time desc
  359. limit 1
  360. </select>
  361. <select id="getRepairCount1" parameterType="com.platform.dao.dto.repair.RepairApplicationFormDTO"
  362. resultType="BigDecimal">
  363. select count(*) from t_repair_application_form form
  364. <where>
  365. <if test="statusList != null and statusList.size > 0">
  366. AND form.status in
  367. <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
  368. #{item}
  369. </foreach>
  370. </if>
  371. <if test="userId!=null and userId!=''">
  372. and form.user_id=#{userId}
  373. </if>
  374. <if test="repairUserId!=null and repairUserId!=''">
  375. and form.repair_user_id=#{repairUserId}
  376. </if>
  377. <if test="dispatchUserId!=null and dispatchUserId!=''">
  378. and form.dispatch_user_id=#{dispatchUserId}
  379. </if>
  380. <if test="status!=null and status!=null">
  381. and form.status=#{status}
  382. </if>
  383. </where>
  384. </select>
  385. </mapper>