GxtRepairOrderMapper.xml 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ygtx.gxt.mapper.GxtRepairOrderMapper">
  6. <resultMap type="GxtRepairOrder" id="GxtRepairOrderResult">
  7. <result property="id" column="id" />
  8. <result property="workOrderProjectNo" column="work_order_project_no" />
  9. <result property="workOrderStatus" column="work_order_status" />
  10. <result property="gxtCenterId" column="gxt_center_id" />
  11. <result property="gxtCenter" column="gxt_center" />
  12. <result property="pcsStationId" column="pcs_station_id" />
  13. <result property="pcsStationName" column="pcs_station_name" />
  14. <result property="pcsDeviceId" column="pcs_device_id" />
  15. <result property="pcsDeviceName" column="pcs_device_name" />
  16. <result property="brand" column="brand" />
  17. <result property="model" column="model" />
  18. <result property="faultCode" column="fault_code" />
  19. <result property="faultDesc" column="fault_desc" />
  20. <result property="assignTime" column="assign_time" />
  21. <result property="assignUserId" column="assign_user_id" />
  22. <result property="assignUserName" column="assign_user_name" />
  23. <result property="acceptTime" column="accept_time" />
  24. <result property="acceptUserId" column="accept_user_id" />
  25. <result property="acceptUserName" column="accept_user_name" />
  26. <result property="realStartTime" column="real_start_time" />
  27. <result property="realEndTime" column="real_end_time" />
  28. <result property="teamLeaderId" column="team_leader_id" />
  29. <result property="teamLeaderName" column="team_leader_name" />
  30. <result property="workGroupMemberId" column="work_group_member_id" />
  31. <result property="workGroupMemberName" column="work_group_member_name" />
  32. <result property="createBy" column="create_by" />
  33. <result property="createTime" column="create_time" />
  34. <result property="updateBy" column="update_by" />
  35. <result property="updateTime" column="update_time" />
  36. <result property="remark" column="remark" />
  37. <result property="content" column="content" />
  38. <result property="planHour" column="plan_hour" />
  39. <result property="priorityType" column="priority_type" />
  40. <result property="score" column="score" />
  41. <result property="reviewContent" column="review_content" />
  42. <result property="maintenanceType" column="maintenance_type" />
  43. <result property="occurTime" column="occur_time" />
  44. <result property="faultBarcode" column="fault_barcode" />
  45. <result property="suspendReason" column="suspend_reason" />
  46. <result property="suspendDescription" column="suspend_description" />
  47. <result property="approvalStatus" column="approval_status" />
  48. <result property="rejectionReason" column="rejection_reason" />
  49. <result property="modifyReason" column="modify_reason" />
  50. <result property="finalizationRemark" column="finalization_remark" />
  51. <result property="relatedOrderCode" column="related_order_code" />
  52. <result property="relatedOrderContent" column="related_order_content" />
  53. <result property="misOrderNo" column="mis_order_no" />
  54. <result property="restartTime" column="restart_time" />
  55. <result property="scoringStatus" column="scoring_status" />
  56. <result property="pcsStationPid" column="pcs_station_pid" />
  57. <result property="attachmentUrls" column="attachment_urls" />
  58. <result property="reviewScoreNum" column="review_score_num" />
  59. <result property="finalCoefficient" column="final_coefficient" />
  60. <result property="orderType" column="order_type" />
  61. <result property="orderEntryType" column="order_entry_type" />
  62. <result property="repairMethod" column="repair_method" />
  63. <result property="resetMethod" column="reset_method" />
  64. <result property="invalidReason" column="invalid_reason" />
  65. <result property="returnType" column="return_type" />
  66. <result property="returnReason" column="return_reason" />
  67. <result property="feedbackReason" column="feedback_reason" />
  68. <result property="confirmStatus" column="confirm_status" />
  69. <result property="wwryNum" column="wwry_num" />
  70. <result property="wlryNum" column="wlry_num" />
  71. <result property="workArea" column="work_area" />
  72. <result property="infoEntry" column="info_entry" />
  73. <result property="realFailureReason" column="real_failure_reason" />
  74. <result property="lostPower" column="lost_power" />
  75. <result property="workPermitNum" column="work_permit_num" />
  76. <result property="finalizeMethod" column="finalize_method" />
  77. <result property="appealUserName" column="appeal_user_name" />
  78. <result property="appealUserId" column="appeal_user_id" />
  79. <result property="appealTime" column="appeal_time" />
  80. <result property="appealReason" column="appeal_reason" />
  81. <result property="suspendExplain" column="suspend_explain" />
  82. <result property="orderAttachment" column="order_attachment" />
  83. <result property="extraWork" column="extra_work" />
  84. <result property="acceptReturnType" column="accept_return_type" />
  85. <result property="acceptReturnReason" column="accept_return_reason" />
  86. <result property="scoreReturnReason" column="score_return_reason" />
  87. <result property="leader" column="leader" />
  88. <result property="userId" column="user_id" />
  89. </resultMap>
  90. <resultMap type="GxtRepairOrder" id="GxtRepairOrderWithPersonResult" extends="GxtRepairOrderResult">
  91. <collection property="repairOrderPersonList" ofType="com.ygtx.gxt.domain.GxtRepairOrderPerson">
  92. <result property="id" column="person_id"/>
  93. <result property="userId" column="person_user_id"/>
  94. <result property="nickName" column="person_nick_name"/>
  95. <result property="orderId" column="person_order_id"/>
  96. <result property="orderCode" column="person_order_code"/>
  97. <result property="status" column="person_status"/>
  98. <result property="selfScore" column="person_self_score"/>
  99. <result property="reviewScore" column="person_review_score"/>
  100. <result property="finalScore" column="person_final_score"/>
  101. <result property="isLeader" column="person_is_leader"/>
  102. <result property="extraScore" column="person_extra_score"/>
  103. <result property="totalScore" column="person_total_score"/>
  104. </collection>
  105. </resultMap>
  106. <resultMap type="GxtOrderData" id="GxtOrderDataResult">
  107. <result property="userId" column="user_id" />
  108. <result property="workOrderNum" column="workOrderNum" />
  109. <result property="workOrderNumLast" column="workOrderNumLast" />
  110. <result property="repairOrderNum" column="repairOrderNum" />
  111. <result property="repairOrderNumLast" column="repairOrderNumLast" />
  112. <result property="wxgs" column="wxgs" />
  113. <result property="wxgsLast" column="wxgs_last" />
  114. <result property="wbgs" column="wbgs" />
  115. <result property="wbgsLast" column="wbgs_last" />
  116. <result property="score" column="score" />
  117. <result property="scoreLast" column="score_last" />
  118. <result property="pcsWorkOrderNum" column="pcsWorkOrderNum" />
  119. <result property="centerWorkOrderNum" column="centerWorkOrderNum" />
  120. <result property="companyWorkOrderNum" column="companyWorkOrderNum" />
  121. <result property="pcsRepairOrderNum" column="pcsRepairOrderNum" />
  122. <result property="centerRepairOrderNum" column="centerRepairOrderNum" />
  123. <result property="companyRepairOrderNum" column="companyRepairOrderNum" />
  124. </resultMap>
  125. <resultMap type="GxtUserScore" id="GxtUserScoreResult">
  126. <result property="monthPeriod" column="month_period"/>
  127. <result property="userId" column="user_id"/>
  128. <result property="userName" column="user_name"/>
  129. <result property="nickName" column="nick_name"/>
  130. <result property="deptId" column="dept_id"/>
  131. <result property="deptName" column="dept_name"/>
  132. <result property="finalScore" column="final_score"/>
  133. <result property="centerId" column="center_id"/>
  134. <result property="center" column="center"/>
  135. <result property="companyName" column="companyName"/>
  136. <result property="permission" column="permission"/>
  137. </resultMap>
  138. <sql id="selectGxtRepairOrderVo">
  139. select id, work_order_project_no, work_order_status, gxt_center_id, gxt_center, pcs_station_id, pcs_station_name, pcs_device_id,
  140. pcs_device_name, brand, model, fault_code, fault_desc, assign_time, assign_user_id, assign_user_name, accept_time,
  141. accept_user_id, accept_user_name, real_start_time, real_end_time, team_leader_id, team_leader_name, work_group_member_id,
  142. work_group_member_name, t.create_by, t.create_time, t.update_by, t.update_time, t.remark, content, plan_hour, priority_type, score,
  143. review_content, maintenance_type, occur_time, fault_barcode, suspend_reason, suspend_description, approval_status,
  144. rejection_reason, modify_reason, finalization_remark, related_order_code, related_order_content, mis_order_no, restart_time,
  145. scoring_status, pcs_station_pid, attachment_urls, review_score_num, final_coefficient, order_type, repair_method, reset_method, invalid_reason, return_type, return_reason, feedback_reason, confirm_status,
  146. wwry_num, wlry_num, work_area, info_entry, real_failure_reason, lost_power, work_permit_num, finalize_method, appeal_user_name, appeal_user_id, appeal_time, appeal_reason, suspend_explain, order_entry_type, order_attachment, extra_work, accept_return_type, accept_return_reason, score_return_reason from gxt_repair_order t
  147. left join sys_user u on u.user_name = t.create_by
  148. left join sys_dept d on u.dept_id = d.dept_id
  149. </sql>
  150. <select id="selectGxtRepairOrderList" parameterType="GxtRepairOrder" resultMap="GxtRepairOrderResult">
  151. <include refid="selectGxtRepairOrderVo"/>
  152. <where>
  153. <if test="workOrderProjectNo != null and workOrderProjectNo != ''"> and work_order_project_no = #{workOrderProjectNo}</if>
  154. <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status = #{workOrderStatus}</if>
  155. <if test="gxtCenterId != null "> and gxt_center_id = #{gxtCenterId}</if>
  156. <if test="gxtCenter != null and gxtCenter != ''"> and gxt_center = #{gxtCenter}</if>
  157. <if test="pcsStationId != null "> and pcs_station_id = #{pcsStationId}</if>
  158. <if test="pcsStationName != null and pcsStationName != ''"> and pcs_station_name = #{pcsStationName} </if>
  159. <if test="pcsDeviceId != null "> and pcs_device_id = #{pcsDeviceId}</if>
  160. <if test="pcsDeviceName != null and pcsDeviceName != ''"> and pcs_device_name like concat('%', #{pcsDeviceName}, '%')</if>
  161. <if test="brand != null and brand != ''"> and brand = #{brand}</if>
  162. <if test="model != null and model != ''"> and model = #{model}</if>
  163. <if test="faultCode != null and faultCode != ''"> and fault_code like concat('%', #{faultCode}, '%')</if>
  164. <if test="faultDesc != null and faultDesc != ''"> and fault_desc = #{faultDesc}</if>
  165. <if test="assignTime != null "> and assign_time = #{assignTime}</if>
  166. <if test="assignUserId != null "> and assign_user_id = #{assignUserId}</if>
  167. <if test="assignUserName != null and assignUserName != ''"> and assign_user_name like concat('%', #{assignUserName}, '%')</if>
  168. <if test="acceptTime != null "> and accept_time = #{acceptTime}</if>
  169. <if test="acceptUserId != null "> and accept_user_id = #{acceptUserId}</if>
  170. <if test="acceptUserName != null and acceptUserName != ''"> and accept_user_name like concat('%', #{acceptUserName}, '%')</if>
  171. <if test="realStartTime != null "> and real_start_time = #{realStartTime}</if>
  172. <if test="realEndTime != null "> and real_end_time = #{realEndTime}</if>
  173. <if test="teamLeaderId != null "> and team_leader_id = #{teamLeaderId}</if>
  174. <if test="teamLeaderName != null and teamLeaderName != ''"> and team_leader_name like concat('%', #{teamLeaderName}, '%')</if>
  175. <if test="workGroupMemberId != null "> and work_group_member_id = #{workGroupMemberId}</if>
  176. <if test="workGroupMemberName != null and workGroupMemberName != ''"> and work_group_member_name like concat('%', #{workGroupMemberName}, '%')</if>
  177. <if test="content != null and content != ''"> and content = #{content}</if>
  178. <if test="planHour != null "> and plan_hour = #{planHour}</if>
  179. <if test="priorityType != null "> and priority_type = #{priorityType}</if>
  180. <if test="score != null "> and score = #{score}</if>
  181. <if test="reviewContent != null and reviewContent != ''"> and review_content = #{reviewContent}</if>
  182. <if test="maintenanceType != null and maintenanceType != ''"> and maintenance_type = #{maintenanceType}</if>
  183. <if test="occurTime != null "> and occur_time = #{occurTime}</if>
  184. <if test="faultBarcode != null and faultBarcode != ''"> and fault_barcode = #{faultBarcode}</if>
  185. <if test="suspendReason != null and suspendReason != ''"> and suspend_reason = #{suspendReason}</if>
  186. <if test="suspendDescription != null and suspendDescription != ''"> and suspend_description = #{suspendDescription}</if>
  187. <if test="approvalStatus != null and approvalStatus != ''"> and approval_status = #{approvalStatus}</if>
  188. <if test="rejectionReason != null and rejectionReason != ''"> and rejection_reason = #{rejectionReason}</if>
  189. <if test="modifyReason != null and modifyReason != ''"> and modify_reason = #{modifyReason}</if>
  190. <if test="finalizationRemark != null and finalizationRemark != ''"> and finalization_remark = #{finalizationRemark}</if>
  191. <if test="relatedOrderCode != null and relatedOrderCode != ''"> and related_order_code = #{relatedOrderCode}</if>
  192. <if test="relatedOrderContent != null and relatedOrderContent != ''"> and related_order_content = #{relatedOrderContent}</if>
  193. <if test="misOrderNo != null and misOrderNo != ''"> and mis_order_no = #{misOrderNo}</if>
  194. <if test="restartTime != null "> and restart_time = #{restartTime}</if>
  195. <if test="scoringStatus != null "> and scoring_status = #{scoringStatus}</if>
  196. <if test="pcsStationPid != null "> and pcs_station_pid = #{pcsStationPid}</if>
  197. <if test="attachmentUrls != null and attachmentUrls != ''"> and attachment_urls = #{attachmentUrls}</if>
  198. <if test="reviewScoreNum != null "> and review_score_num = #{reviewScoreNum}</if>
  199. <if test="finalCoefficient != null "> and final_coefficient = #{finalCoefficient}</if>
  200. <if test="orderType != null "> and order_type = #{orderType}</if>
  201. <if test="repairMethod != null and repairMethod != ''"> and repair_method = #{repairMethod}</if>
  202. <if test="resetMethod != null and resetMethod != ''"> and reset_method = #{resetMethod}</if>
  203. <if test="returnType != null and returnType != ''"> and return_type = #{returnType}</if>
  204. <if test="returnReason != null and returnReason != ''"> and return_reason = #{returnReason}</if>
  205. <if test="outTimeParam != null"> and DATE_SUB(NOW(), INTERVAL #{outTimeParam} MINUTE) > t.update_time </if>
  206. <if test="wwryNum != null"> and wwry_num = #{wwryNum}</if>
  207. <if test="wlryNum != null"> and wlry_num = #{wlryNum}</if>
  208. <if test="workArea != null and workArea != ''"> and work_area = #{workArea}</if>
  209. <if test="infoEntry != null and infoEntry != ''"> and info_entry = #{infoEntry}</if>
  210. <if test="realFailureReason != null and realFailureReason != ''"> and real_failure_reason = #{realFailureReason}</if>
  211. <if test="lostPower != null"> and lost_power = #{lostPower}</if>
  212. <if test="workPermitNum != null and workPermitNum != ''"> and work_permit_num = #{workPermitNum}</if>
  213. <!-- 业务特定数据权限过滤条件 -->
  214. <if test="params.businessDataScope != null and params.businessDataScope != ''">
  215. ${params.businessDataScope}
  216. </if>
  217. <!-- 限制待下发工单只能创建人本部门查看 -->
  218. <if test="params.currentUser != null and params.currentUser != ''">
  219. and ((t.work_order_status != 'to_issue' and t.work_order_status != 'accept_return') or t.create_by in
  220. (select user_name from sys_user t1
  221. left join sys_dept t2 on t1.dept_id = t2.dept_id
  222. where t2.dept_id = (select dept_id from sys_user where user_name = #{params.currentUser,jdbcType=VARCHAR} and del_flag='0')))
  223. </if>
  224. </where>
  225. order by create_time desc
  226. </select>
  227. <select id="selectGxtRepairOrderListByMonth" parameterType="GxtRepairOrder" resultMap="GxtRepairOrderResult">
  228. SELECT
  229. t.*
  230. FROM
  231. gxt_repair_order t
  232. <if test="userId != null">LEFT JOIN gxt_repair_order_person p ON p.order_id = t.id</if>
  233. <where>
  234. <if test="userId != null"> and p.user_id=#{userId}</if>
  235. <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status = #{workOrderStatus}</if>
  236. <if test="pcsStationPid != null "> and pcs_station_pid = #{pcsStationPid}</if>
  237. <if test="maintenanceType != null and maintenanceType != ''"> and maintenance_type = #{maintenanceType}</if>
  238. <if test="monthPeriod != null"> and DATE_FORMAT(occur_time, '%Y-%m') = #{monthPeriod}</if>
  239. <if test="params.businessDataScope != null and params.businessDataScope != ''">
  240. ${params.businessDataScope}
  241. </if>
  242. </where>
  243. order by t.occur_time desc
  244. </select>
  245. <select id="selectGxtRepairOrderById" parameterType="Long" resultMap="GxtRepairOrderResult">
  246. <include refid="selectGxtRepairOrderVo"/>
  247. where id = #{id}
  248. </select>
  249. <insert id="insertGxtRepairOrder" parameterType="GxtRepairOrder" useGeneratedKeys="true" keyProperty="id">
  250. insert into gxt_repair_order
  251. <trim prefix="(" suffix=")" suffixOverrides=",">
  252. <if test="workOrderProjectNo != null and workOrderProjectNo != ''">work_order_project_no,</if>
  253. <if test="workOrderStatus != null">work_order_status,</if>
  254. <if test="gxtCenterId != null">gxt_center_id,</if>
  255. <if test="gxtCenter != null">gxt_center,</if>
  256. <if test="pcsStationId != null">pcs_station_id,</if>
  257. <if test="pcsStationName != null">pcs_station_name,</if>
  258. <if test="pcsDeviceId != null">pcs_device_id,</if>
  259. <if test="pcsDeviceName != null">pcs_device_name,</if>
  260. <if test="brand != null">brand,</if>
  261. <if test="model != null">model,</if>
  262. <if test="faultCode != null">fault_code,</if>
  263. <if test="faultDesc != null">fault_desc,</if>
  264. <if test="assignTime != null">assign_time,</if>
  265. <if test="assignUserId != null">assign_user_id,</if>
  266. <if test="assignUserName != null">assign_user_name,</if>
  267. <if test="acceptTime != null">accept_time,</if>
  268. <if test="acceptUserId != null">accept_user_id,</if>
  269. <if test="acceptUserName != null">accept_user_name,</if>
  270. <if test="realStartTime != null">real_start_time,</if>
  271. <if test="realEndTime != null">real_end_time,</if>
  272. <if test="teamLeaderId != null">team_leader_id,</if>
  273. <if test="teamLeaderName != null">team_leader_name,</if>
  274. <if test="workGroupMemberId != null">work_group_member_id,</if>
  275. <if test="workGroupMemberName != null">work_group_member_name,</if>
  276. <if test="createBy != null">create_by,</if>
  277. <if test="createTime != null">create_time,</if>
  278. <if test="updateBy != null">update_by,</if>
  279. <if test="updateTime != null">update_time,</if>
  280. <if test="remark != null">remark,</if>
  281. <if test="content != null">content,</if>
  282. <if test="planHour != null">plan_hour,</if>
  283. <if test="priorityType != null">priority_type,</if>
  284. <if test="score != null">score,</if>
  285. <if test="reviewContent != null">review_content,</if>
  286. <if test="maintenanceType != null and maintenanceType != ''">maintenance_type,</if>
  287. <if test="occurTime != null">occur_time,</if>
  288. <if test="faultBarcode != null">fault_barcode,</if>
  289. <if test="suspendReason != null">suspend_reason,</if>
  290. <if test="suspendDescription != null">suspend_description,</if>
  291. <if test="approvalStatus != null">approval_status,</if>
  292. <if test="rejectionReason != null">rejection_reason,</if>
  293. <if test="modifyReason != null">modify_reason,</if>
  294. <if test="finalizationRemark != null">finalization_remark,</if>
  295. <if test="relatedOrderCode != null">related_order_code,</if>
  296. <if test="relatedOrderContent != null">related_order_content,</if>
  297. <if test="misOrderNo != null">mis_order_no,</if>
  298. <if test="restartTime != null">restart_time,</if>
  299. <if test="scoringStatus != null">scoring_status,</if>
  300. <if test="pcsStationPid != null">pcs_station_pid,</if>
  301. <if test="attachmentUrls != null and attachmentUrls != ''">attachment_urls,</if>
  302. <if test="reviewScoreNum != null">review_score_num,</if>
  303. <if test="finalCoefficient != null">final_coefficient,</if>
  304. <if test="orderType != null">order_type,</if>
  305. <if test="repairMethod != null and repairMethod != ''">repair_method,</if>
  306. <if test="resetMethod != null and resetMethod != ''">reset_method,</if>
  307. <if test="invalidReason != null and invalidReason != ''">invalid_reason,</if>
  308. <if test="returnType != null and returnType != ''">return_type,</if>
  309. <if test="returnReason != null and returnReason != ''">return_reason,</if>
  310. <if test="feedbackReason != null and feedbackReason != ''">feedback_reason,</if>
  311. <if test="confirmStatus != null">confirm_status,</if>
  312. <if test="wwryNum != null">wwry_num,</if>
  313. <if test="wlryNum != null">wlry_num,</if>
  314. <if test="workArea != null and workArea != ''">work_area,</if>
  315. <if test="infoEntry != null and infoEntry != ''">info_entry,</if>
  316. <if test="realFailureReason != null and realFailureReason != ''">real_failure_reason,</if>
  317. <if test="lostPower != null">lost_power,</if>
  318. <if test="workPermitNum != null and workPermitNum != ''">work_permit_num,</if>
  319. <if test="appealUserName != null and appealUserName != ''">appeal_user_name,</if>
  320. <if test="appealUserId != null">appeal_user_id,</if>
  321. <if test="appealTime != null">appeal_time,</if>
  322. <if test="appealReason != null and appealReason != ''">appeal_reason,</if>
  323. <if test="suspendExplain != null and suspendExplain != ''">suspend_explain,</if>
  324. <if test="orderEntryType != null and orderEntryType != ''">order_entry_type,</if>
  325. <if test="orderAttachment != null and orderAttachment != ''">order_attachment,</if>
  326. <if test="extraWork != null and extraWork != ''">extra_work,</if>
  327. <if test="acceptReturnType != null and acceptReturnType != ''">accept_return_type,</if>
  328. <if test="acceptReturnReason != null and acceptReturnReason != ''">accept_return_reason,</if>
  329. <if test="scoreReturnReason != null and scoreReturnReason != ''">score_return_reason,</if>
  330. <if test="finalizeMethod != null and finalizeMethod != ''">finalize_method,</if>
  331. </trim>
  332. <trim prefix="values (" suffix=")" suffixOverrides=",">
  333. <if test="workOrderProjectNo != null and workOrderProjectNo != ''">#{workOrderProjectNo},</if>
  334. <if test="workOrderStatus != null">#{workOrderStatus},</if>
  335. <if test="gxtCenterId != null">#{gxtCenterId},</if>
  336. <if test="gxtCenter != null">#{gxtCenter},</if>
  337. <if test="pcsStationId != null">#{pcsStationId},</if>
  338. <if test="pcsStationName != null">#{pcsStationName},</if>
  339. <if test="pcsDeviceId != null">#{pcsDeviceId},</if>
  340. <if test="pcsDeviceName != null">#{pcsDeviceName},</if>
  341. <if test="brand != null">#{brand},</if>
  342. <if test="model != null">#{model},</if>
  343. <if test="faultCode != null">#{faultCode},</if>
  344. <if test="faultDesc != null">#{faultDesc},</if>
  345. <if test="assignTime != null">#{assignTime},</if>
  346. <if test="assignUserId != null">#{assignUserId},</if>
  347. <if test="assignUserName != null">#{assignUserName},</if>
  348. <if test="acceptTime != null">#{acceptTime},</if>
  349. <if test="acceptUserId != null">#{acceptUserId},</if>
  350. <if test="acceptUserName != null">#{acceptUserName},</if>
  351. <if test="realStartTime != null">#{realStartTime},</if>
  352. <if test="realEndTime != null">#{realEndTime},</if>
  353. <if test="teamLeaderId != null">#{teamLeaderId},</if>
  354. <if test="teamLeaderName != null">#{teamLeaderName},</if>
  355. <if test="workGroupMemberId != null">#{workGroupMemberId},</if>
  356. <if test="workGroupMemberName != null">#{workGroupMemberName},</if>
  357. <if test="createBy != null">#{createBy},</if>
  358. <if test="createTime != null">#{createTime},</if>
  359. <if test="updateBy != null">#{updateBy},</if>
  360. <if test="updateTime != null">#{updateTime},</if>
  361. <if test="remark != null">#{remark},</if>
  362. <if test="content != null">#{content},</if>
  363. <if test="planHour != null">#{planHour},</if>
  364. <if test="priorityType != null">#{priorityType},</if>
  365. <if test="score != null">#{score},</if>
  366. <if test="reviewContent != null">#{reviewContent},</if>
  367. <if test="maintenanceType != null and maintenanceType != ''">#{maintenanceType},</if>
  368. <if test="occurTime != null">#{occurTime},</if>
  369. <if test="faultBarcode != null">#{faultBarcode},</if>
  370. <if test="suspendReason != null">#{suspendReason},</if>
  371. <if test="suspendDescription != null">#{suspendDescription},</if>
  372. <if test="approvalStatus != null">#{approvalStatus},</if>
  373. <if test="rejectionReason != null">#{rejectionReason},</if>
  374. <if test="modifyReason != null">#{modifyReason},</if>
  375. <if test="finalizationRemark != null">#{finalizationRemark},</if>
  376. <if test="relatedOrderCode != null">#{relatedOrderCode},</if>
  377. <if test="relatedOrderContent != null">#{relatedOrderContent},</if>
  378. <if test="misOrderNo != null">#{misOrderNo},</if>
  379. <if test="restartTime != null">#{restartTime},</if>
  380. <if test="scoringStatus != null">#{scoringStatus},</if>
  381. <if test="pcsStationPid != null">#{pcsStationPid},</if>
  382. <if test="attachmentUrls != null and attachmentUrls != ''">#{attachmentUrls},</if>
  383. <if test="reviewScoreNum != null">#{reviewScoreNum},</if>
  384. <if test="finalCoefficient != null">#{finalCoefficient},</if>
  385. <if test="orderType != null">#{orderType},</if>
  386. <if test="repairMethod != null and repairMethod != ''">#{repairMethod},</if>
  387. <if test="resetMethod != null and resetMethod != ''">#{resetMethod},</if>
  388. <if test="invalidReason != null and invalidReason != ''">#{invalidReason},</if>
  389. <if test="returnType != null and returnType != ''">#{returnType},</if>
  390. <if test="returnReason != null and returnReason != ''">#{returnReason},</if>
  391. <if test="feedbackReason != null and feedbackReason != ''">#{feedbackReason},</if>
  392. <if test="confirmStatus != null">#{confirmStatus},</if>
  393. <if test="wwryNum != null">#{wwryNum},</if>
  394. <if test="wlryNum != null">#{wlryNum},</if>
  395. <if test="workArea != null and workArea != ''">#{workArea},</if>
  396. <if test="infoEntry != null and infoEntry != ''">#{infoEntry},</if>
  397. <if test="realFailureReason != null and realFailureReason != ''">#{realFailureReason},</if>
  398. <if test="lostPower != null">#{lostPower},</if>
  399. <if test="workPermitNum != null and workPermitNum != ''">#{workPermitNum},</if>
  400. <if test="appealUserName != null and appealUserName != ''">#{appealUserName},</if>
  401. <if test="appealUserId != null">#{appealUserId},</if>
  402. <if test="appealTime != null">#{appealTime},</if>
  403. <if test="appealReason != null and appealReason != ''">#{appealReason},</if>
  404. <if test="suspendExplain != null and suspendExplain != ''">#{suspendExplain},</if>
  405. <if test="orderEntryType != null and orderEntryType != ''">#{orderEntryType},</if>
  406. <if test="orderAttachment != null and orderAttachment != ''">#{orderAttachment},</if>
  407. <if test="extraWork != null and extraWork != ''">#{extraWork},</if>
  408. <if test="acceptReturnType != null and acceptReturnType != ''">#{acceptReturnType},</if>
  409. <if test="acceptReturnReason != null and acceptReturnReason != ''">#{acceptReturnReason},</if>
  410. <if test="scoreReturnReason != null and scoreReturnReason != ''">#{scoreReturnReason},</if>
  411. <if test="finalizeMethod != null and finalizeMethod != ''">#{finalizeMethod},</if>
  412. </trim>
  413. </insert>
  414. <update id="updateGxtRepairOrder" parameterType="GxtRepairOrder">
  415. update gxt_repair_order
  416. <trim prefix="SET" suffixOverrides=",">
  417. <if test="workOrderProjectNo != null and workOrderProjectNo != ''">work_order_project_no = #{workOrderProjectNo},</if>
  418. <if test="workOrderStatus != null">work_order_status = #{workOrderStatus},</if>
  419. <if test="gxtCenterId != null">gxt_center_id = #{gxtCenterId},</if>
  420. <if test="gxtCenter != null">gxt_center = #{gxtCenter},</if>
  421. <if test="pcsStationId != null">pcs_station_id = #{pcsStationId},</if>
  422. <if test="pcsStationName != null">pcs_station_name = #{pcsStationName},</if>
  423. <if test="pcsDeviceId != null">pcs_device_id = #{pcsDeviceId},</if>
  424. <if test="pcsDeviceName != null">pcs_device_name = #{pcsDeviceName},</if>
  425. <if test="brand != null">brand = #{brand},</if>
  426. <if test="model != null">model = #{model},</if>
  427. <if test="faultCode != null">fault_code = #{faultCode},</if>
  428. <if test="faultDesc != null">fault_desc = #{faultDesc},</if>
  429. <if test="assignTime != null">assign_time = #{assignTime},</if>
  430. <if test="assignUserId != null">assign_user_id = #{assignUserId},</if>
  431. <if test="assignUserName != null">assign_user_name = #{assignUserName},</if>
  432. <if test="acceptTime != null">accept_time = #{acceptTime},</if>
  433. <if test="acceptUserId != null">accept_user_id = #{acceptUserId},</if>
  434. <if test="acceptUserName != null">accept_user_name = #{acceptUserName},</if>
  435. <if test="realStartTime != null">real_start_time = #{realStartTime},</if>
  436. <if test="realEndTime != null">real_end_time = #{realEndTime},</if>
  437. <if test="teamLeaderId != null">team_leader_id = #{teamLeaderId},</if>
  438. <if test="teamLeaderName != null">team_leader_name = #{teamLeaderName},</if>
  439. <if test="workGroupMemberId != null">work_group_member_id = #{workGroupMemberId},</if>
  440. <if test="workGroupMemberName != null">work_group_member_name = #{workGroupMemberName},</if>
  441. <if test="createBy != null">create_by = #{createBy},</if>
  442. <if test="createTime != null">create_time = #{createTime},</if>
  443. <if test="updateBy != null">update_by = #{updateBy},</if>
  444. <if test="updateTime != null">update_time = #{updateTime},</if>
  445. <if test="remark != null">remark = #{remark},</if>
  446. <if test="content != null">content = #{content},</if>
  447. <if test="planHour != null">plan_hour = #{planHour},</if>
  448. <if test="priorityType != null">priority_type = #{priorityType},</if>
  449. <if test="score != null">score = #{score},</if>
  450. <if test="reviewContent != null">review_content = #{reviewContent},</if>
  451. <if test="maintenanceType != null and maintenanceType != ''">maintenance_type = #{maintenanceType},</if>
  452. <if test="occurTime != null">occur_time = #{occurTime},</if>
  453. <if test="faultBarcode != null">fault_barcode = #{faultBarcode},</if>
  454. <if test="suspendReason != null">suspend_reason = #{suspendReason},</if>
  455. <if test="suspendDescription != null">suspend_description = #{suspendDescription},</if>
  456. <if test="approvalStatus != null">approval_status = #{approvalStatus},</if>
  457. <if test="rejectionReason != null">rejection_reason = #{rejectionReason},</if>
  458. <if test="modifyReason != null">modify_reason = #{modifyReason},</if>
  459. <if test="finalizationRemark != null">finalization_remark = #{finalizationRemark},</if>
  460. <if test="relatedOrderCode != null">related_order_code = #{relatedOrderCode},</if>
  461. <if test="relatedOrderContent != null">related_order_content = #{relatedOrderContent},</if>
  462. <if test="misOrderNo != null">mis_order_no = #{misOrderNo},</if>
  463. <if test="restartTime != null">restart_time = #{restartTime},</if>
  464. <if test="scoringStatus != null">scoring_status = #{scoringStatus},</if>
  465. <if test="pcsStationPid != null">pcs_station_pid = #{pcsStationPid},</if>
  466. <if test="attachmentUrls != null and attachmentUrls != ''">attachment_urls = #{attachmentUrls},</if>
  467. <if test="reviewScoreNum != null">review_score_num = #{reviewScoreNum},</if>
  468. <if test="finalCoefficient != null">final_coefficient = #{finalCoefficient},</if>
  469. <if test="orderType != null">order_type = #{orderType},</if>
  470. <if test="repairMethod != null and repairMethod != ''">repair_method = #{repairMethod},</if>
  471. <if test="resetMethod != null and resetMethod != ''">reset_method = #{resetMethod},</if>
  472. <if test="invalidReason != null and invalidReason != ''">invalid_reason = #{invalidReason},</if>
  473. <if test="returnType != null and returnType != ''">return_type = #{returnType},</if>
  474. <if test="workOrderStatus != null and workOrderStatus == 'return'">
  475. return_reason = #{returnReason},
  476. </if>
  477. <if test="feedbackReason != null and feedbackReason != ''">feedback_reason = #{feedbackReason},</if>
  478. <if test="confirmStatus != null">confirm_status = #{confirmStatus},</if>
  479. <if test="wwryNum != null">wwry_num = #{wwryNum},</if>
  480. <if test="wlryNum != null">wlry_num = #{wlryNum},</if>
  481. <if test="workArea != null and workArea != ''">work_area = #{workArea},</if>
  482. <if test="infoEntry != null and infoEntry != ''">info_entry = #{infoEntry},</if>
  483. <if test="realFailureReason != null and realFailureReason != ''">real_failure_reason = #{realFailureReason},</if>
  484. <if test="lostPower != null">lost_power = #{lostPower},</if>
  485. <if test="workPermitNum != null and workPermitNum != ''">work_permit_num = #{workPermitNum},</if>
  486. <if test="appealUserName != null and appealUserName != ''">appeal_user_name = #{appealUserName},</if>
  487. <if test="appealUserId != null">appeal_user_id = #{appealUserId},</if>
  488. <if test="appealTime != null">appeal_time = #{appealTime},</if>
  489. <if test="appealReason != null and appealReason != ''">appeal_reason = #{appealReason},</if>
  490. <if test="suspendExplain != null and suspendExplain != ''">suspend_explain = #{suspendExplain},</if>
  491. <if test="orderEntryType != null and orderEntryType != ''">order_entry_type = #{orderEntryType},</if>
  492. <if test="orderAttachment != null and orderAttachment != ''">order_attachment = #{orderAttachment},</if>
  493. <if test="extraWork != null and extraWork != ''">extra_work = #{extraWork},</if>
  494. <if test="acceptReturnType != null and acceptReturnType != ''">accept_return_type = #{acceptReturnType},</if>
  495. <if test="workOrderStatus != null and workOrderStatus == 'accept_return'">
  496. accept_return_reason = #{acceptReturnReason},
  497. </if>
  498. <if test="scoreReturnReason != null and scoreReturnReason != ''">score_return_reason = #{scoreReturnReason},</if>
  499. <if test="finalizeMethod != null and finalizeMethod != ''">finalize_method = #{finalizeMethod},</if>
  500. </trim>
  501. where id = #{id}
  502. </update>
  503. <delete id="deleteGxtRepairOrderById" parameterType="Long">
  504. delete from gxt_repair_order where id = #{id}
  505. </delete>
  506. <delete id="deleteGxtRepairOrderByIds" parameterType="String">
  507. delete from gxt_repair_order where id in
  508. <foreach item="id" collection="array" open="(" separator="," close=")">
  509. #{id}
  510. </foreach>
  511. </delete>
  512. <select id="selectGxtRepairOrderListForAutoFinalize" parameterType="GxtRepairOrder" resultMap="GxtRepairOrderResult">
  513. <include refid="selectGxtRepairOrderVo"/>
  514. <where>
  515. <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status in
  516. <foreach collection="workOrderStatus.split(',')" item="status" open="(" close=")" separator=",">
  517. #{status}
  518. </foreach>
  519. </if>
  520. and accept_time is not null
  521. and occur_time is not null
  522. and restart_time is not null
  523. </where>
  524. order by create_time desc
  525. </select>
  526. <select id="selectGxtRepairOrderByWorkOrderProjectNo" parameterType="String" resultMap="GxtRepairOrderResult">
  527. <include refid="selectGxtRepairOrderVo"/>
  528. where work_order_project_no = #{workOrderProjectNo}
  529. </select>
  530. <select id="selectGxtRepairOrderListNoPermi" parameterType="GxtRepairOrder" resultMap="GxtRepairOrderResult">
  531. <include refid="selectGxtRepairOrderVo"/>
  532. <where>
  533. <if test="workOrderProjectNo != null and workOrderProjectNo != ''"> and work_order_project_no = #{workOrderProjectNo}</if>
  534. <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status = #{workOrderStatus}</if>
  535. <if test="gxtCenterId != null "> and gxt_center_id = #{gxtCenterId}</if>
  536. <if test="gxtCenter != null and gxtCenter != ''"> and gxt_center = #{gxtCenter}</if>
  537. <if test="pcsStationId != null "> and pcs_station_id = #{pcsStationId}</if>
  538. <if test="pcsStationName != null and pcsStationName != ''"> and pcs_station_name = #{pcsStationName} </if>
  539. <if test="pcsDeviceId != null "> and pcs_device_id = #{pcsDeviceId}</if>
  540. <if test="pcsDeviceName != null and pcsDeviceName != ''"> and pcs_device_name like concat('%', #{pcsDeviceName}, '%')</if>
  541. <if test="brand != null and brand != ''"> and brand = #{brand}</if>
  542. <if test="model != null and model != ''"> and model = #{model}</if>
  543. <if test="faultCode != null and faultCode != ''"> and fault_code like concat('%', #{faultCode}, '%')</if>
  544. <if test="faultDesc != null and faultDesc != ''"> and fault_desc = #{faultDesc}</if>
  545. <if test="assignTime != null "> and assign_time = #{assignTime}</if>
  546. <if test="assignUserId != null "> and assign_user_id = #{assignUserId}</if>
  547. <if test="assignUserName != null and assignUserName != ''"> and assign_user_name like concat('%', #{assignUserName}, '%')</if>
  548. <if test="acceptTime != null "> and accept_time = #{acceptTime}</if>
  549. <if test="acceptUserId != null "> and accept_user_id = #{acceptUserId}</if>
  550. <if test="acceptUserName != null and acceptUserName != ''"> and accept_user_name like concat('%', #{acceptUserName}, '%')</if>
  551. <if test="realStartTime != null "> and real_start_time = #{realStartTime}</if>
  552. <if test="realEndTime != null "> and real_end_time = #{realEndTime}</if>
  553. <if test="teamLeaderId != null "> and team_leader_id = #{teamLeaderId}</if>
  554. <if test="teamLeaderName != null and teamLeaderName != ''"> and team_leader_name like concat('%', #{teamLeaderName}, '%')</if>
  555. <if test="workGroupMemberId != null "> and work_group_member_id = #{workGroupMemberId}</if>
  556. <if test="workGroupMemberName != null and workGroupMemberName != ''"> and work_group_member_name like concat('%', #{workGroupMemberName}, '%')</if>
  557. <if test="content != null and content != ''"> and content = #{content}</if>
  558. <if test="planHour != null "> and plan_hour = #{planHour}</if>
  559. <if test="priorityType != null "> and priority_type = #{priorityType}</if>
  560. <if test="score != null "> and score = #{score}</if>
  561. <if test="reviewContent != null and reviewContent != ''"> and review_content = #{reviewContent}</if>
  562. <if test="maintenanceType != null and maintenanceType != ''"> and maintenance_type = #{maintenanceType}</if>
  563. <if test="occurTime != null "> and occur_time = #{occurTime}</if>
  564. <if test="faultBarcode != null and faultBarcode != ''"> and fault_barcode = #{faultBarcode}</if>
  565. <if test="suspendReason != null and suspendReason != ''"> and suspend_reason = #{suspendReason}</if>
  566. <if test="suspendDescription != null and suspendDescription != ''"> and suspend_description = #{suspendDescription}</if>
  567. <if test="approvalStatus != null and approvalStatus != ''"> and approval_status = #{approvalStatus}</if>
  568. <if test="rejectionReason != null and rejectionReason != ''"> and rejection_reason = #{rejectionReason}</if>
  569. <if test="modifyReason != null and modifyReason != ''"> and modify_reason = #{modifyReason}</if>
  570. <if test="finalizationRemark != null and finalizationRemark != ''"> and finalization_remark = #{finalizationRemark}</if>
  571. <if test="relatedOrderCode != null and relatedOrderCode != ''"> and related_order_code = #{relatedOrderCode}</if>
  572. <if test="relatedOrderContent != null and relatedOrderContent != ''"> and related_order_content = #{relatedOrderContent}</if>
  573. <if test="misOrderNo != null and misOrderNo != ''"> and mis_order_no = #{misOrderNo}</if>
  574. <if test="restartTime != null "> and restart_time = #{restartTime}</if>
  575. <if test="scoringStatus != null "> and scoring_status = #{scoringStatus}</if>
  576. <if test="pcsStationPid != null "> and pcs_station_pid = #{pcsStationPid}</if>
  577. <if test="attachmentUrls != null and attachmentUrls != ''"> and attachment_urls = #{attachmentUrls}</if>
  578. <if test="reviewScoreNum != null "> and review_score_num = #{reviewScoreNum}</if>
  579. <if test="repairMethod != null and repairMethod != ''"> and repair_method = #{repairMethod}</if>
  580. <if test="resetMethod != null and resetMethod != ''"> and reset_method = #{resetMethod}</if>
  581. <if test="returnType != null and returnType != ''"> and return_type = #{returnType}</if>
  582. <if test="returnReason != null and returnReason != ''"> and return_reason = #{returnReason}</if>
  583. <if test="wwryNum != null"> and wwry_num = #{wwryNum}</if>
  584. <if test="wlryNum != null"> and wlry_num = #{wlryNum}</if>
  585. <if test="workArea != null and workArea != ''"> and work_area = #{workArea}</if>
  586. <if test="infoEntry != null and infoEntry != ''"> and info_entry = #{infoEntry}</if>
  587. <if test="realFailureReason != null and realFailureReason != ''"> and real_failure_reason = #{realFailureReason}</if>
  588. <if test="lostPower != null"> and lost_power = #{lostPower}</if>
  589. <if test="workPermitNum != null and workPermitNum != ''"> and work_permit_num = #{workPermitNum}</if>
  590. </where>
  591. order by id desc
  592. </select>
  593. <select id="selectRepairOrderWithPersonById" parameterType="Long" resultMap="GxtRepairOrderWithPersonResult">
  594. SELECT
  595. t1.id,
  596. t1.work_order_project_no,
  597. t1.work_order_status,
  598. t1.gxt_center_id,
  599. t1.gxt_center,
  600. t1.pcs_station_id,
  601. t1.pcs_station_name,
  602. t1.pcs_device_id,
  603. t1.pcs_device_name,
  604. t1.brand,
  605. t1.model,
  606. t1.fault_code,
  607. t1.fault_desc,
  608. t1.assign_time,
  609. t1.assign_user_id,
  610. t1.assign_user_name,
  611. t1.accept_time,
  612. t1.accept_user_id,
  613. t1.accept_user_name,
  614. t1.real_start_time,
  615. t1.real_end_time,
  616. t1.team_leader_id,
  617. t1.team_leader_name,
  618. t1.work_group_member_id,
  619. t1.work_group_member_name,
  620. t1.content,
  621. t1.plan_hour,
  622. t1.priority_type,
  623. t1.score,
  624. t1.review_content,
  625. t1.maintenance_type,
  626. t1.occur_time,
  627. t1.fault_barcode,
  628. t1.suspend_reason,
  629. t1.suspend_description,
  630. t1.approval_status,
  631. t1.rejection_reason,
  632. t1.modify_reason,
  633. t1.finalization_remark,
  634. t1.related_order_code,
  635. t1.related_order_content,
  636. t1.mis_order_no,
  637. t1.restart_time,
  638. t1.scoring_status,
  639. t1.pcs_station_pid,
  640. t1.attachment_urls,
  641. t1.review_score_num,
  642. t1.final_coefficient,
  643. t1.create_by,
  644. t1.create_time,
  645. t1.update_by,
  646. t1.update_time,
  647. t1.remark,
  648. t1.return_type,
  649. t1.return_reason,
  650. t1.order_attachment,
  651. t1.extra_work,
  652. t1.accept_return_type,
  653. t1.accept_return_reason,
  654. t1.score_return_reason,
  655. t2.id as person_id,
  656. t2.user_id as person_user_id,
  657. t2.nick_name as person_nick_name,
  658. t2.order_id as person_order_id,
  659. t2.order_code as person_order_code,
  660. t2.status as person_status,
  661. t2.self_score as person_self_score,
  662. t2.review_score as person_review_score,
  663. t2.final_score as person_final_score,
  664. t2.is_leader as person_is_leader,
  665. t2.extra_score as person_extra_score,
  666. t2.total_score as person_total_score
  667. FROM gxt_repair_order t1
  668. LEFT JOIN gxt_repair_order_person t2 ON t1.id = t2.order_id
  669. WHERE t1.id = #{id}
  670. </select>
  671. <select id="selectHomePageData" resultMap="GxtOrderDataResult">
  672. SELECT
  673. u.user_id,
  674. IFNULL( a.order_num, 0 ) AS workOrderNum,
  675. IFNULL( b.order_num_last, 0 ) AS workOrderNumLast,
  676. IFNULL( c.repair_num, 0 ) AS repairOrderNum,
  677. IFNULL( d.repair_num_last, 0 ) AS repairOrderNumLast,
  678. IFNULL( j.wxgs, 0 ) AS wxgs,
  679. IFNULL( k.wxgs_last, 0 ) AS wxgs_last,
  680. IFNULL( l.wbgs, 0 ) AS wbgs,
  681. IFNULL( m.wbgs_last, 0 ) AS wbgs_last,
  682. IFNULL( n.score, 0 ) AS score,
  683. IFNULL( o.score, 0 ) AS score_last,
  684. IFNULL( p.pcsWorkOrderNum, 0 ) AS pcsWorkOrderNum,
  685. IFNULL( q.pcsRepairOrderNum, 0 ) AS pcsRepairOrderNum,
  686. IFNULL( r.centerWorkOrderNum, 0 ) AS centerWorkOrderNum,
  687. IFNULL( s.centerRepairOrderNum, 0 ) AS centerRepairOrderNum,
  688. IFNULL( t.companyWorkOrderNum, 0 ) AS companyWorkOrderNum,
  689. IFNULL( tt.companyRepairOrderNum, 0 ) AS companyRepairOrderNum
  690. FROM
  691. sys_user u
  692. LEFT JOIN (
  693. SELECT
  694. COUNT(*) AS order_num,
  695. wop.user_id
  696. FROM
  697. gxt_work_order wo
  698. LEFT JOIN gxt_work_order_person wop ON wo.id = wop.order_id
  699. WHERE wo.work_order_status IN ('completed','archived') AND
  700. wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  701. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  702. GROUP BY
  703. wop.user_id
  704. ) a ON a.user_id = u.user_id
  705. LEFT JOIN (
  706. SELECT
  707. COUNT(*) AS order_num_last,
  708. wop.user_id
  709. FROM
  710. gxt_work_order wo
  711. LEFT JOIN gxt_work_order_person wop ON wo.id = wop.order_id
  712. WHERE wo.work_order_status IN ('completed','archived') AND
  713. wo.create_time >= DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL - 1 MONTH )
  714. AND wo.create_time <![CDATA[<]]> STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  715. GROUP BY
  716. wop.user_id
  717. ) b ON u.user_id = b.user_id
  718. LEFT JOIN (
  719. SELECT
  720. COUNT(*) AS repair_num,
  721. rop.user_id
  722. FROM
  723. gxt_repair_order ro
  724. LEFT JOIN gxt_repair_order_person rop ON ro.id = rop.order_id
  725. WHERE ro.work_order_status IN ('completed','archived') AND
  726. ro.occur_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  727. AND ro.occur_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  728. GROUP BY
  729. rop.user_id
  730. ) c ON u.user_id = c.user_id
  731. LEFT JOIN (
  732. SELECT
  733. COUNT(*) AS repair_num_last,
  734. rop.user_id
  735. FROM
  736. gxt_repair_order ro
  737. LEFT JOIN gxt_repair_order_person rop ON ro.id = rop.order_id
  738. WHERE ro.work_order_status IN ('completed','archived') AND
  739. ro.occur_time >= DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL - 1 MONTH )
  740. AND ro.occur_time <![CDATA[<]]> STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  741. GROUP BY
  742. rop.user_id
  743. ) d ON u.user_id = d.user_id
  744. LEFT JOIN (
  745. SELECT
  746. rop.user_id,
  747. SUM(TIMESTAMPDIFF( MINUTE, ro.real_start_time, ro.real_end_time ) / 60 - IFNULL(gq.total_in_work_suspend_seconds, 0) / 3600) AS wxgs
  748. FROM
  749. gxt_repair_order_person rop
  750. LEFT JOIN gxt_repair_order ro ON rop.order_id = ro.id
  751. LEFT JOIN gxt_repair_order_flow_records_next gq ON gq.order_id = rop.order_id
  752. LEFT JOIN ( SELECT MIN( action_time ) AS accept_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'accept' GROUP BY order_id ) e ON ro.id = e.order_id
  753. LEFT JOIN ( SELECT MIN( action_time ) AS process_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'process' GROUP BY order_id ) f ON ro.id = f.order_id
  754. LEFT JOIN ( SELECT MAX( action_time ) AS complete_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'complete' GROUP BY order_id ) g ON ro.id = g.order_id
  755. WHERE
  756. ro.occur_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  757. AND ro.occur_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  758. GROUP BY
  759. rop.user_id
  760. ) j ON u.user_id = j.user_id
  761. LEFT JOIN (
  762. SELECT
  763. rop.user_id,
  764. SUM( TIMESTAMPDIFF( MINUTE, ro.accept_time, ro.real_start_time ) / 60 ) + SUM( TIMESTAMPDIFF( MINUTE, ro.real_start_time, ro.real_end_time ) / 60 ) AS wxgs_last
  765. FROM
  766. gxt_repair_order_person rop
  767. LEFT JOIN gxt_repair_order ro ON rop.order_id = ro.id
  768. LEFT JOIN ( SELECT MIN( action_time ) AS accept_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'accept' GROUP BY order_id ) e ON ro.id = e.order_id
  769. LEFT JOIN ( SELECT MIN( action_time ) AS process_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'process' GROUP BY order_id ) f ON ro.id = f.order_id
  770. LEFT JOIN ( SELECT MAX( action_time ) AS complete_time, order_id FROM gxt_repair_order_flow WHERE action_type = 'complete' GROUP BY order_id ) g ON ro.id = g.order_id
  771. WHERE
  772. ro.occur_time >= DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL - 1 MONTH )
  773. AND ro.occur_time <![CDATA[<]]> STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  774. GROUP BY
  775. rop.user_id
  776. ) k ON u.user_id = k.user_id
  777. LEFT JOIN (
  778. SELECT
  779. wop.user_id,
  780. SUM(TIMESTAMPDIFF( MINUTE, wo.real_start_time, wo.real_end_time ) / 60 - IFNULL(gq.total_in_work_suspend_seconds, 0) / 3600) AS wbgs
  781. FROM
  782. gxt_work_order_person wop
  783. LEFT JOIN gxt_work_order wo ON wop.order_id = wo.id
  784. LEFT JOIN gxt_work_order_flow_records_next gq ON gq.order_id = wop.order_id
  785. LEFT JOIN ( SELECT MIN( action_time ) AS process_time, order_id FROM gxt_work_order_flow WHERE action_type = 'process' GROUP BY order_id ) h ON wo.id = h.order_id
  786. LEFT JOIN ( SELECT MIN( action_time ) AS complete_time, order_id FROM gxt_work_order_flow WHERE action_type = 'complete' GROUP BY order_id ) i ON wo.id = i.order_id
  787. WHERE
  788. wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  789. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  790. GROUP BY
  791. wop.user_id
  792. ) l ON u.user_id = l.user_id
  793. LEFT JOIN (
  794. SELECT
  795. wop.user_id,
  796. SUM( TIMESTAMPDIFF( MINUTE, h.process_time, i.complete_time ) / 60 ) AS wbgs_last
  797. FROM
  798. gxt_work_order_person wop
  799. LEFT JOIN gxt_work_order wo ON wop.order_id = wo.id
  800. LEFT JOIN ( SELECT MIN( action_time ) AS process_time, order_id FROM gxt_work_order_flow WHERE action_type = 'process' GROUP BY order_id ) h ON wo.id = h.order_id
  801. LEFT JOIN ( SELECT MIN( action_time ) AS complete_time, order_id FROM gxt_work_order_flow WHERE action_type = 'complete' GROUP BY order_id ) i ON wo.id = i.order_id
  802. WHERE
  803. wo.create_time >= DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL - 1 MONTH )
  804. AND wo.create_time <![CDATA[<]]> STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  805. GROUP BY
  806. wop.user_id
  807. ) m ON u.user_id = m.user_id
  808. LEFT JOIN (
  809. SELECT
  810. SUM( us.final_score ) AS score,
  811. su.user_id
  812. FROM
  813. gxt_user_score us
  814. LEFT JOIN sys_user su ON us.user_name = su.user_name
  815. WHERE
  816. us.month_period = #{monthPeriod}
  817. GROUP BY
  818. su.user_id
  819. ) n ON u.user_id = n.user_id
  820. LEFT JOIN (
  821. SELECT
  822. SUM( us.final_score ) AS score,
  823. su.user_id
  824. FROM
  825. gxt_user_score us
  826. LEFT JOIN sys_user su ON us.user_name = su.user_name
  827. WHERE
  828. us.month_period = DATE_FORMAT( DATE_SUB( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01' ), '%Y-%m-%d' ), INTERVAL 1 MONTH ), '%Y-%m' )
  829. GROUP BY
  830. su.user_id
  831. ) o ON u.user_id = o.user_id
  832. LEFT JOIN (
  833. SELECT
  834. COUNT(*) AS pcsWorkOrderNum,
  835. su.dept_id,su.user_id
  836. FROM
  837. gxt_work_order wo
  838. LEFT JOIN sys_user su ON wo.pcs_station_pid = su.dept_id
  839. WHERE wo.work_order_status IN ('completed','archived') AND
  840. su.user_id = #{userId}
  841. AND wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  842. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  843. ) p ON u.user_id = p.user_id
  844. LEFT JOIN (
  845. SELECT
  846. COUNT(*) AS pcsRepairOrderNum,
  847. su.dept_id,su.user_id
  848. FROM
  849. gxt_repair_order wo
  850. LEFT JOIN sys_user su ON wo.pcs_station_pid = su.dept_id
  851. WHERE wo.work_order_status IN ('completed','archived') AND
  852. su.user_id = #{userId}
  853. AND wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  854. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  855. ) q ON u.user_id = q.user_id
  856. LEFT JOIN (
  857. SELECT
  858. COUNT(*) AS centerWorkOrderNum,
  859. su.dept_id,su.user_id
  860. FROM
  861. gxt_work_order wo
  862. LEFT JOIN sys_dept sd ON wo.gxt_center_id = sd.parent_id
  863. LEFT JOIN sys_user su ON sd.dept_id = su.dept_id
  864. WHERE wo.work_order_status IN ('completed','archived') AND
  865. su.user_id = #{userId}
  866. AND wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  867. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  868. ) r ON u.user_id = p.user_id
  869. LEFT JOIN (
  870. SELECT
  871. COUNT(*) AS centerRepairOrderNum,
  872. su.dept_id,su.user_id
  873. FROM
  874. gxt_repair_order wo
  875. LEFT JOIN sys_dept sd ON wo.gxt_center_id = sd.parent_id
  876. LEFT JOIN sys_user su ON sd.dept_id = su.dept_id
  877. WHERE wo.work_order_status IN ('completed','archived') AND
  878. su.user_id = #{userId}
  879. AND wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  880. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  881. ) s ON u.user_id = q.user_id
  882. LEFT JOIN (
  883. SELECT
  884. COUNT(*) AS companyWorkOrderNum,#{userId} AS user_id
  885. FROM
  886. gxt_work_order wo
  887. WHERE wo.work_order_status IN ('completed','archived') AND
  888. wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  889. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  890. ) t ON u.user_id = t.user_id
  891. LEFT JOIN (
  892. SELECT
  893. COUNT(*) AS companyRepairOrderNum,#{userId} AS user_id
  894. FROM
  895. gxt_repair_order wo
  896. WHERE wo.work_order_status IN ('completed','archived') AND
  897. wo.create_time >= STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' )
  898. AND wo.create_time <![CDATA[<]]> DATE_ADD( STR_TO_DATE( CONCAT( #{monthPeriod}, '-01 00:00:00' ), '%Y-%m-%d %H:%i:%s' ), INTERVAL 1 MONTH )
  899. ) tt ON u.user_id = tt.user_id
  900. WHERE
  901. u.user_id = #{userId}
  902. </select>
  903. <select id="selectHomePageRank" parameterType="GxtUserScore" resultMap="GxtUserScoreResult">
  904. SELECT
  905. u.user_id,
  906. u.user_name,
  907. u.nick_name,
  908. d.dept_id,
  909. d.dept_name,
  910. p.dept_id AS center_id,
  911. p.dept_name AS center,
  912. (SELECT dept_name FROM sys_dept WHERE parent_id=0) AS companyName,
  913. IFNULL(us.final_score,0) AS final_score
  914. FROM
  915. sys_user u
  916. LEFT JOIN sys_dept d ON u.dept_id = d.dept_id
  917. LEFT JOIN sys_dept p ON d.parent_id = p.dept_id
  918. LEFT JOIN gxt_user_score us ON u.user_name = us.user_name AND us.month_period = DATE_FORMAT(CURDATE(), '%Y-%m')
  919. WHERE 1=1
  920. <if test="deptId != null">
  921. AND d.dept_id=#{deptId}
  922. </if>
  923. <if test="centerId != null">
  924. AND p.dept_id=#{centerId}
  925. </if>
  926. <if test="permission != null and permission != ''">
  927. AND u.user_id IN
  928. <foreach item="item" collection="permission.split(',')" open="(" separator="," close=")">
  929. #{item}
  930. </foreach>
  931. </if>
  932. ORDER BY
  933. IFNULL(us.final_score,0) DESC
  934. </select>
  935. <select id="selectLatestGxtRepairOrderByDeviceId" parameterType="map" resultMap="GxtRepairOrderResult">
  936. <include refid="selectGxtRepairOrderVo"/>
  937. <where>
  938. <if test="pcsDeviceId != null"> and pcs_device_id = #{pcsDeviceId}</if>
  939. <if test="limit != null and limit > 0">
  940. ORDER BY create_time DESC LIMIT #{limit}
  941. </if>
  942. </where>
  943. </select>
  944. <select id="selectGxtRepairOrderByDeviceIdWithCondition" parameterType="map" resultMap="GxtRepairOrderResult">
  945. <include refid="selectGxtRepairOrderVo"/>
  946. <where>
  947. <if test="pcsDeviceId != null"> and pcs_device_id = #{pcsDeviceId}</if>
  948. <if test="workOrderStatus != null and workOrderStatus != ''">
  949. <if test="excludeStatus">
  950. and work_order_status != #{workOrderStatus}
  951. </if>
  952. <if test="!excludeStatus">
  953. and work_order_status = #{workOrderStatus}
  954. </if>
  955. </if>
  956. </where>
  957. <choose>
  958. <when test="orderByField != null and orderByField == 'occurTime'">
  959. ORDER BY occur_time DESC
  960. </when>
  961. <when test="orderByField != null and orderByField == 'restartTime'">
  962. ORDER BY restart_time DESC
  963. </when>
  964. <otherwise>
  965. ORDER BY create_time DESC
  966. </otherwise>
  967. </choose>
  968. <if test="limit != null and limit > 0">
  969. LIMIT #{limit}
  970. </if>
  971. </select>
  972. </mapper>