CustomRushRepairMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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.tofly.ghrq.custom.mapper.CustomRushRepairMapper">
  4. <resultMap id="rushMap" type="com.tofly.ghrq.custom.entity.CustomRushRepair">
  5. <id property="id" column="ID"/>
  6. <result property="workOrderId" column="WORK_ORDER_ID"/>
  7. <result property="workOrderType" column="WORK_ORDER_TYPE"/>
  8. <result property="workOrderSource" column="WORK_ORDER_SOURCE"/>
  9. <result property="dispatchUserId" column="DISPATCH_USER_ID"/>
  10. <result property="dispatchDate" column="DISPATCH_DATE"/>
  11. <result property="address" column="ADDRESS"/>
  12. <result property="contact" column="CONTACT"/>
  13. <result property="contactPhone" column="CONTACT_PHONE"/>
  14. <result property="rushRepairResponsible" column="RUSH_REPAIR_RESPONSIBLE"/>
  15. <result property="rushRepairPersons" column="RUSH_REPAIR_PERSONS"/>
  16. <result property="x" column="X"/>
  17. <result property="y" column="Y"/>
  18. <result property="introduction" column="INTRODUCTION"/>
  19. <result property="description" column="DESCRIPTION"/>
  20. <result property="note" column="NOTE"/>
  21. <result property="noteTaker" column="NOTE_TAKER"/>
  22. <result property="delFlag" column="DEL_FLAG"/>
  23. <result property="workOrderState" column="WORK_ORDER_STATE"/>
  24. <association property="workOrderTypeName" column="WORK_ORDER_TYPE" select="getworkOrderTypeName"></association>
  25. <association property="workOrderStateName" column="WORK_ORDER_STATE"
  26. select="getworkOrderStateName"></association>
  27. <association property="dispatchUserName" column="DISPATCH_USER_ID"
  28. select="com.tofly.common.mapper.ToflyCodeCommonMapper.getUserName"></association>
  29. <association property="responsibleName" column="RUSH_REPAIR_RESPONSIBLE"
  30. select="com.tofly.common.mapper.ToflyCodeCommonMapper.getUserName"></association>
  31. <association property="departmentName" column="DEPARTMENT" select="getdeptName"></association>
  32. </resultMap>
  33. <resultMap id="customRushMap" type="com.tofly.ghrq.custom.entity.CustomRushRepair">
  34. <id property="id" column="ID"/>
  35. <result property="workOrderId" column="WORK_ORDER_ID"/>
  36. <result property="workOrderType" column="WORK_ORDER_TYPE"/>
  37. <result property="workOrderSource" column="WORK_ORDER_SOURCE"/>
  38. <result property="dispatchUserId" column="DISPATCH_USER_ID"/>
  39. <result property="dispatchDate" column="DISPATCH_DATE"/>
  40. <result property="address" column="ADDRESS"/>
  41. <result property="contact" column="CONTACT"/>
  42. <result property="contactPhone" column="CONTACT_PHONE"/>
  43. <result property="rushRepairResponsible" column="RUSH_REPAIR_RESPONSIBLE"/>
  44. <result property="rushRepairPersons" column="RUSH_REPAIR_PERSONS"/>
  45. <result property="x" column="X"/>
  46. <result property="y" column="Y"/>
  47. <result property="introduction" column="INTRODUCTION"/>
  48. <result property="description" column="DESCRIPTION"/>
  49. <result property="note" column="NOTE"/>
  50. <result property="noteTaker" column="NOTE_TAKER"/>
  51. <result property="delFlag" column="DEL_FLAG"/>
  52. <result property="workOrderState" column="WORK_ORDER_STATE"/>
  53. <result property="creatUser" column="CREAT_USER"/>
  54. <result property="creatTime" column="CREAT_TIME"/>
  55. <result property="department" column="DEPARTMENT"/>
  56. <association property="workOrderTypeName" column="WORK_ORDER_TYPE" select="getworkOrderTypeName"></association>
  57. <association property="workOrderStateName" column="WORK_ORDER_STATE"
  58. select="getworkOrderStateName"></association>
  59. <association property="dispatchUserName" column="DISPATCH_USER_ID"
  60. select="com.tofly.common.mapper.ToflyCodeCommonMapper.getUserName"></association>
  61. <association property="responsibleName" column="RUSH_REPAIR_RESPONSIBLE"
  62. select="com.tofly.common.mapper.ToflyCodeCommonMapper.getUserName"></association>
  63. <association property="departmentName" column="DEPARTMENT" select="getdeptName"></association>
  64. <association property="creatUserName" column="CREAT_USER" select="com.tofly.common.mapper.ToflyCodeCommonMapper.getUserName"/>
  65. <collection property="files" ofType="java.util.List" select="getFilesName" column="ID"/>
  66. <collection property="voice" ofType="java.util.List" select="getVoice" column="ID"/>
  67. <collection property="processManages" ofType="java.util.List" select="getProcess" column="ID"/>
  68. <collection property="auditList" ofType="java.util.List" select="getAuditList" column="ID"/>
  69. <collection property="endVoice" ofType="java.util.List" select="getEndVoice" column="ID"/>
  70. </resultMap>
  71. <resultMap id="customRushRepairAuditEndMap" type="com.tofly.ghrq.custom.entity.CustomRushAudit">
  72. <id property="id" column="ID"/>
  73. <result property="auditor" column="AUDITOR"/>
  74. <result property="auditmind" column="AUDITMIND"/>
  75. <result property="auditDescription" column="AUDIT_DESCRIPTION"/>
  76. <result property="workOrderId" column="WORK_ORDER_ID"/>
  77. <result property="auditTime" column="AUDIT_TIME"/>
  78. <result property="delFlag" column="DEL_FLAG"/>
  79. <association property="auditMindName" column="AUDITMIND" select="getauditMindName"></association>
  80. <association property="auditorName" column="AUDITOR" select="com.tofly.common.mapper.ToflyCodeCommonMapper.getUserName"/>
  81. <collection property="auditEndFiles" ofType="java.util.List" select="getAuditFiles" column="ID"></collection>
  82. </resultMap>
  83. <select id="getauditMindName" resultType="java.lang.Object">
  84. select decode(#{auditmind},'0','通过','1','不通过') as auditMindName from dual
  85. </select>
  86. <select id="getworkOrderTypeName" resultType="java.lang.Object">
  87. select decode(#{workOrderType},'0','内部工单','1','外部转接') as workOrderTypeName from dual
  88. </select>
  89. <select id="getworkOrderStateName" resultType="java.lang.Object">
  90. select decode(#{workOrderState},'0','待派工','1','派工未通过','2','待处理','3','待审核','4','审核未通过','5','归档') as workOrderStateName from dual
  91. </select>
  92. <select id="getdeptName" resultType="java.lang.Object">
  93. select name as departmentName from tf_smpn_department_x where id=#{department}
  94. </select>
  95. <select id="getCustomRushRepairById" resultMap="customRushMap">
  96. select * from tf_rush_repair where DEL_FLAG = 1 AND id = #{id}
  97. </select>
  98. <select id="pageByCondition" resultMap="rushMap">
  99. select * from tf_rush_repair r where r.DEL_FLAG = 1
  100. <if test="rushRepairSearch.address != null and rushRepairSearch.address.trim() != ''">
  101. and (r.ADDRESS like '%'||#{rushRepairSearch.address}||'%')
  102. </if>
  103. <if test="rushRepairSearch.workOrderType !=null and rushRepairSearch.workOrderType.trim() != ''">
  104. and (r.WORK_ORDER_TYPE = #{rushRepairSearch.workOrderType})
  105. </if>
  106. <if test="rushRepairSearch.workOrderId !=null and rushRepairSearch.workOrderId.trim() != ''">
  107. and (r.WORK_ORDER_ID = #{rushRepairSearch.workOrderId})
  108. </if>
  109. <if test="rushRepairSearch.workOrderState !=null and rushRepairSearch.workOrderState.trim() != ''">
  110. and (r.WORK_ORDER_STATE = #{rushRepairSearch.workOrderState})
  111. </if>
  112. order by r.CREAT_TIME
  113. </select>
  114. <select id="getAll" resultMap="rushMap">
  115. select * from tf_rush_repair r where DEL_FLAG = 1
  116. <if test="rushRepairSearch.address != null and rushRepairSearch.address.trim() != ''">
  117. and (r.ADDRESS like '%'||#{rushRepairSearch.address}||'%')
  118. </if>
  119. <if test="rushRepairSearch.workOrderType !=null and rushRepairSearch.workOrderType.trim() != ''">
  120. and (r.WORK_ORDER_TYPE = #{rushRepairSearch.workOrderType})
  121. </if>
  122. <if test="rushRepairSearch.workOrderId !=null and rushRepairSearch.workOrderId.trim() != ''">
  123. and (r.WORK_ORDER_ID = #{rushRepairSearch.workOrderId})
  124. </if>
  125. <if test="rushRepairSearch.workOrderState !=null and rushRepairSearch.workOrderState.trim() != ''">
  126. and (r.WORK_ORDER_STATE = #{rushRepairSearch.workOrderState})
  127. </if>
  128. </select>
  129. <resultMap id="fileMap" type="java.util.Map">
  130. <result property="path" column="PATH"/>
  131. <result property="fileName" column="FILE_NAME"/>
  132. </resultMap>
  133. <select id="getFilesName" resultMap="fileMap">
  134. select f.PATH,f.FILE_NAME from tf_rush_repair_filetorepair fr,tf_rush_repair_file f
  135. where fr.WORK_ORDER_ID = #{id} AND fr.FILE_ID = f.ID AND f.DEL_FLAG = 1 AND (f.FILE_TYPE = 0 OR f.FILE_TYPE = 2)
  136. </select>
  137. <select id="getVoice" resultMap="fileMap">
  138. select f.PATH,f.FILE_NAME from tf_rush_repair_filetorepair fr,tf_rush_repair_file f
  139. where fr.WORK_ORDER_ID = #{id} AND fr.FILE_ID = f.ID AND f.DEL_FLAG = 1 AND f.FILE_TYPE = 1
  140. </select>
  141. <select id="getEndFilesName" resultMap="fileMap">
  142. select f.PATH,f.FILE_NAME from tf_rush_repair_filetoaudit fa,tf_rush_repair_audit_end ad,tf_rush_repair_file f
  143. where ad.WORK_ORDER_ID = #{id}
  144. AND fa.audit_end_id = ad.id
  145. AND fa.FILE_ID = f.ID
  146. AND f.DEL_FLAG = 1
  147. AND (f.FILE_TYPE = 0 OR f.FILE_TYPE = 2)
  148. </select>
  149. <select id="getEndVoice" resultMap="fileMap">
  150. select f.PATH,f.FILE_NAME from tf_rush_repair_filetoaudit fa,tf_rush_repair_audit_end ad,tf_rush_repair_file f
  151. where ad.WORK_ORDER_ID = #{id}
  152. AND fa.audit_end_id = ad.id
  153. AND fa.FILE_ID = f.ID
  154. AND f.DEL_FLAG = 1
  155. AND f.FILE_TYPE = 1
  156. </select>
  157. <resultMap id="rushProcessMap" type="com.tofly.ghrq.custom.entity.CustomRushRepairProcessManage">
  158. <id property="id" column="ID"/>
  159. <result property="description" column="DESCRIPTION"/>
  160. <result property="workOrderId" column="WORK_ORDER_ID"/>
  161. <result property="manageDate" column="MANAGE_DATE"/>
  162. <result property="x" column="X"/>
  163. <result property="y" column="Y"/>
  164. <result property="delFlag" column="DEL_FLAG"/>
  165. <collection property="processFiles" ofType="java.util.List" select="getProcessFiles" column="ID"></collection>
  166. <collection property="processVoice" ofType="java.util.List" select="getProcessVoice" column="ID"></collection>
  167. </resultMap>
  168. <select id="getProcess" resultMap="rushProcessMap">
  169. select * from tf_rush_repair_process_manage where work_order_id = #{id} AND DEL_FLAG = 1 order by manage_date
  170. </select>
  171. <select id="getProcessFiles" resultMap="fileMap">
  172. select f.PATH,f.FILE_NAME from tf_rush_repair_filetoprocess fp,tf_rush_repair_file f
  173. where fp.PROCESS_MANAGE_ID = #{id} AND fp.FILE_ID = f.ID AND f.DEL_FLAG = 1 AND (f.FILE_TYPE = 0 OR f.FILE_TYPE = 2)
  174. </select>
  175. <select id="getProcessVoice" resultMap="fileMap">
  176. select f.PATH,f.FILE_NAME from tf_rush_repair_filetoprocess fp,tf_rush_repair_file f
  177. where fp.PROCESS_MANAGE_ID = #{id} AND fp.FILE_ID = f.ID AND f.DEL_FLAG = 1 AND f.FILE_TYPE = 1
  178. </select>
  179. <select id="getIdByRole" resultType="java.lang.Long">
  180. select id from tf_rush_repair where (dispatch_user_id = #{id} or rush_repair_responsible = #{id}) AND DEL_FLAG = 1
  181. </select>
  182. <select id="getAuditList" resultMap="customRushRepairAuditEndMap">
  183. select * from tf_rush_repair_audit_end where work_order_id = #{id} AND DEL_FLAG = 1 order by audit_time
  184. </select>
  185. <select id="getAuditFiles" resultMap="fileMap">
  186. select f.PATH,f.FILE_NAME from tf_rush_repair_filetoaudit fa,tf_rush_repair_file f
  187. where fa.AUDIT_END_ID = #{id} AND fa.FILE_ID = f.ID AND f.DEL_FLAG = 1 AND (f.FILE_TYPE = 0 OR f.FILE_TYPE = 2)
  188. </select>
  189. <select id="getFiles" resultType="map">
  190. select f.*, t.lx,t.mxid,t.work_order_id
  191. from tf_rush_repair_file f,
  192. ((select file_id as fileid, '1' as lx,id as mxid,work_order_id
  193. from tf_rush_repair_filetorepair
  194. where 1=1
  195. <if test="rids !=null and rids.size()>0">
  196. and WORK_ORDER_ID in
  197. <foreach collection="rids" item="id" open="(" close=")" separator=",">
  198. #{id}
  199. </foreach>
  200. </if>
  201. ) union all
  202. (select fa.file_id as fileid, '2' as lx,ad.id as mxid,ad.work_order_id
  203. from tf_rush_repair_filetoaudit fa, tf_rush_repair_audit_end ad
  204. where fa.audit_end_id = ad.id
  205. <if test="rids !=null and rids.size()>0">
  206. and ad.WORK_ORDER_ID in
  207. <foreach collection="rids" item="id" open="(" close=")" separator=",">
  208. #{id}
  209. </foreach>
  210. </if>
  211. ) union all
  212. (select fp.file_id as fileid, '3' as lx,pm.id as mxid,pm.work_order_id
  213. from tf_rush_repair_process_manage pm,
  214. tf_rush_repair_filetoprocess fp
  215. where pm.id = fp.PROCESS_MANAGE_ID
  216. <if test="rids !=null and rids.size()>0">
  217. and pm.WORK_ORDER_ID in
  218. <foreach collection="rids" item="id" open="(" close=")" separator=",">
  219. #{id}
  220. </foreach>
  221. </if>
  222. )) t
  223. where f.id = t.fileid and f.DEL_FLAG='1'
  224. </select>
  225. <select id="getReportByTYpe" resultType="map">
  226. select work_order_type,
  227. decode(work_order_type, '0', '内部工单', '1', '外部转移') as work_order_type_name,
  228. count(1) as cunt
  229. from TF_RUSH_REPAIR
  230. where del_flag='1'
  231. <if test="deptId!=null">
  232. and exists (select 1
  233. from tf_smpn_user_x
  234. where DEPARTMENT_ID = #{deptId}
  235. and id = TF_RUSH_REPAIR.Creat_User)
  236. </if>
  237. <if test="startDate!=null and startDate.trim() != ''">
  238. and to_char(creat_time,'yyyy-MM-dd') >= #{startDate}
  239. </if>
  240. <if test="endDate!=null and endDate.trim() != ''">
  241. <![CDATA[ and to_char(creat_time,'yyyy-MM-dd') <= #{endDate} ]]>
  242. </if>
  243. group by work_order_type
  244. </select>
  245. <select id="getReportByTime" resultType="map">
  246. select ${reportType} as sj,
  247. work_order_type,
  248. decode(work_order_type, '0', '内部工单', '1', '外部转移') as work_order_type_name,
  249. count(1) as cunt
  250. from TF_RUSH_REPAIR
  251. where del_flag='1'
  252. <if test="deptId!=null">
  253. and exists (select 1
  254. from tf_smpn_user_x
  255. where DEPARTMENT_ID = #{deptId}
  256. and id = TF_RUSH_REPAIR.Creat_User)
  257. </if>
  258. <if test="startDate!=null and startDate.trim() != ''">
  259. and ${reportType} >= #{startDate}
  260. </if>
  261. <if test="endDate!=null and endDate.trim() != ''">
  262. <![CDATA[ and ${reportType} <= #{endDate} ]]>
  263. </if>
  264. group by work_order_type, ${reportType}
  265. order by work_order_type,sj
  266. </select>
  267. <select id="querySJByDay" resultType="java.lang.String">
  268. SELECT TO_CHAR(TO_DATE(#{startDate}, 'YYYY-MM-DD') + ROWNUM - 1,
  269. 'YYYY-MM-DD') sj
  270. FROM DUAL
  271. <![CDATA[ CONNECT BY ROWNUM <= nvl(TO_DATE(#{endDate}, 'YYYY-MM-DD') - ]]>
  272. TO_DATE(#{endDate}, 'YYYY-MM-DD') + 1
  273. </select>
  274. <select id="querySJByMonth" resultType="java.lang.String">
  275. SELECT TO_CHAR(add_months(TO_DATE(#{startDate}, 'YYYY-MM'), ROWNUM - 1),
  276. 'YYYY-MM') sj
  277. FROM DUAL
  278. <![CDATA[ CONNECT BY ROWNUM <= ]]>
  279. months_between(TO_DATE(#{endDate}, 'YYYY-MM'),
  280. TO_DATE(#{startDate}, 'YYYY-MM')) + 1
  281. </select>
  282. <select id="querySJByYear" resultType="java.lang.String">
  283. SELECT TO_CHAR(to_number(#{startDate}) + rownum - 1) sj
  284. FROM DUAL
  285. <![CDATA[ CONNECT BY ROWNUM <= to_number(#{endDate}) - to_number(#{startDate}) + 1 ]]>
  286. </select>
  287. </mapper>