GxtWorkOrderMapper.xml 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  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.GxtWorkOrderMapper">
  6. <resultMap type="GxtWorkOrder" id="GxtWorkOrderResult">
  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="pcsStationPid" column="pcs_station_pid" />
  14. <result property="pcsStationName" column="pcs_station_name" />
  15. <result property="pcsDeviceId" column="pcs_device_id" />
  16. <result property="pcsDeviceName" column="pcs_device_name" />
  17. <result property="brand" column="brand" />
  18. <result property="model" column="model" />
  19. <result property="inspectionType" column="inspection_type" />
  20. <result property="misNo" column="mis_no" />
  21. <result property="planStartTime" column="plan_start_time" />
  22. <result property="planEndTime" column="plan_end_time" />
  23. <result property="orderSource" column="order_source" />
  24. <result property="assignTime" column="assign_time" />
  25. <result property="assignUserId" column="assign_user_id" />
  26. <result property="assignUserName" column="assign_user_name" />
  27. <result property="acceptTime" column="accept_time" />
  28. <result property="acceptUserId" column="accept_user_id" />
  29. <result property="acceptUserName" column="accept_user_name" />
  30. <result property="realStartTime" column="real_start_time" />
  31. <result property="realEndTime" column="real_end_time" />
  32. <result property="teamLeaderId" column="team_leader_id" />
  33. <result property="teamLeaderName" column="team_leader_name" />
  34. <result property="workGroupMemberId" column="work_group_member_id" />
  35. <result property="workGroupMemberName" column="work_group_member_name" />
  36. <result property="suspendReason" column="suspend_reason" />
  37. <result property="suspendTime" column="suspend_time" />
  38. <result property="statusBeforeSuspend" column="status_before_suspend" />
  39. <result property="rejectionReason" column="rejection_reason" />
  40. <result property="modifyReason" column="modify_reason" />
  41. <result property="pauseReason" column="pause_reason" />
  42. <result property="pauseTime" column="pause_time" />
  43. <result property="restartTime" column="restart_time" />
  44. <result property="completeTime" column="complete_time" />
  45. <result property="planHour" column="plan_hour" />
  46. <result property="content" column="content" />
  47. <result property="realContent" column="real_content" />
  48. <result property="faultCode" column="fault_code" />
  49. <result property="faultDesc" column="fault_desc" />
  50. <result property="orderType" column="order_type" />
  51. <result property="orderEntryType" column="order_entry_type" />
  52. <result property="priorityType" column="priority_type" />
  53. <result property="score" column="score" />
  54. <result property="reviewContent" column="review_content" />
  55. <result property="issuerName" column="issuer_name" />
  56. <result property="permitterName" column="permitter_name" />
  57. <result property="scoringStatus" column="scoring_status" />
  58. <result property="createBy" column="create_by" />
  59. <result property="createTime" column="create_time" />
  60. <result property="updateBy" column="update_by" />
  61. <result property="updateTime" column="update_time" />
  62. <result property="remark" column="remark" />
  63. <result property="attachmentUrls" column="attachment_urls" />
  64. <result property="itemCompletionFactor" column="item_completion_factor" />
  65. <result property="itemCompletionFactorSum" column="item_completion_factor_sum" />
  66. <result property="reviewScoreNum" column="review_score_num" />
  67. <result property="finalCoefficient" column="final_coefficient" />
  68. <result property="isDeferred" column="is_deferred" />
  69. <result property="invalidReason" column="invalid_reason" />
  70. <result property="feedbackReason" column="feedback_reason" />
  71. <result property="confirmStatus" column="confirm_status" />
  72. <result property="wwryNum" column="wwry_num" />
  73. <result property="wlryNum" column="wlry_num" />
  74. <result property="infoEntry" column="info_entry" />
  75. <result property="lostPower" column="lost_power" />
  76. <result property="workPermitNum" column="work_permit_num" />
  77. <result property="finalizeMethod" column="finalize_method" />
  78. <result property="appealUserId" column="appeal_user_id" />
  79. <result property="appealUserName" column="appeal_user_name" />
  80. <result property="appealTime" column="appeal_time" />
  81. <result property="appealReason" column="appeal_reason" />
  82. <result property="suspendExplain" column="suspend_explain" />
  83. <result property="scoreReturnReason" column="score_return_reason" />
  84. <result property="leader" column="leader" />
  85. <result property="runningDays" column="running_days" />
  86. <result property="stopDays" column="stop_days" />
  87. <result property="deptName" column="dept_name" />
  88. </resultMap>
  89. <resultMap type="GxtOrderData" id="GxtOrderDataResult">
  90. <result property="startTime" column="startTime" />
  91. <result property="endTime" column="endTime" />
  92. <result property="code" column="code" />
  93. <result property="brand" column="brand" />
  94. <result property="model" column="model" />
  95. <result property="system" column="system" />
  96. <result property="pcs" column="pcs" />
  97. <result property="center" column="center" />
  98. <result property="orderType" column="orderType" />
  99. <result property="repairPerson" column="repairPerson" />
  100. <result property="chargePerson" column="chargePerson" />
  101. <result property="score" column="score" />
  102. <result property="xfsc" column="xfsc" />
  103. <result property="xysc" column="xysc" />
  104. <result property="zbsc" column="zbsc" />
  105. <result property="tjsc" column="tjsc" />
  106. <result property="qjbwsc" column="qjbwsc" />
  107. <result property="clsc" column="clsc" />
  108. <result property="gqsc" column="gqsc" />
  109. <result property="workOrderNum" column="workOrderNum" />
  110. <result property="repairOrderNum" column="repairOrderNum" />
  111. <result property="orderCode" column="order_code" />
  112. <result property="restartNum" column="restart_num" />
  113. <result property="devices" column="devices" />
  114. </resultMap>
  115. <sql id="selectGxtWorkOrderVo">
  116. select id, work_order_project_no, work_order_status, gxt_center_id, gxt_center, pcs_station_id, pcs_station_pid, pcs_station_name,
  117. pcs_device_id, pcs_device_name, e.brand, e.model, inspection_type, mis_no, plan_start_time, plan_end_time, order_source, assign_time,
  118. assign_user_id, assign_user_name, accept_time, accept_user_id, accept_user_name, real_start_time, real_end_time,
  119. team_leader_id, team_leader_name, work_group_member_id, work_group_member_name, suspend_reason,
  120. suspend_time,status_before_suspend, modify_reason, pause_reason, pause_time, restart_time, complete_time, plan_hour,
  121. content, real_content, fault_code, fault_desc, order_type, priority_type, score, review_content, issuer_name,
  122. permitter_name, scoring_status, t.create_by, t.create_time, t.update_by, t.update_time, t.remark, t.attachment_urls,
  123. item_completion_factor, item_completion_factor_sum, review_score_num, final_coefficient, is_deferred, invalid_reason, feedback_reason, confirm_status,
  124. wwry_num, wlry_num, info_entry, lost_power, work_permit_num, finalize_method, appeal_user_id, appeal_user_name, appeal_time, appeal_reason, suspend_explain, order_entry_type, score_return_reason
  125. from gxt_work_order t
  126. left join sys_user u on u.user_name = t.create_by
  127. left join sys_dept d on u.dept_id = d.dept_id
  128. left join gxt_equipment e on t.pcs_device_name = e.equipment_code and t.pcs_station_name = e.station
  129. </sql>
  130. <select id="selectGxtWorkOrderList" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
  131. <include refid="selectGxtWorkOrderVo"/>
  132. <where>
  133. <if test="pcsDeviceName != null and pcsDeviceName != ''"> and pcs_device_name like concat('%', #{pcsDeviceName}, '%')</if>
  134. <if test="workOrderProjectNo != null and workOrderProjectNo != ''"> and work_order_project_no like concat('%', #{workOrderProjectNo}, '%')</if>
  135. <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status = #{workOrderStatus}</if>
  136. <if test="gxtCenter != null and gxtCenter != ''"> and gxt_center = #{gxtCenter}</if>
  137. <if test="pcsStationName != null and pcsStationName != ''"> and pcs_station_name = #{pcsStationName}</if>
  138. <if test="orderSource != null and orderSource != ''"> and order_source = #{orderSource}</if>
  139. <if test="teamLeaderId != null"> and team_leader_id = #{teamLeaderId}</if>
  140. <if test="workGroupMemberId != null"> and work_group_member_id = #{workGroupMemberId}</if>
  141. <if test="scoringStatus != null"> and scoring_status = #{scoringStatus}</if>
  142. <if test="itemCompletionFactor != null"> and item_completion_factor = #{itemCompletionFactor}</if>
  143. <if test="itemCompletionFactorSum != null"> and item_completion_factor_sum = #{itemCompletionFactorSum}</if>
  144. <if test="reviewScoreNum != null"> and review_score_num = #{reviewScoreNum}</if>
  145. <if test="finalCoefficient != null"> and final_coefficient = #{finalCoefficient}</if>
  146. <if test="misNo != null"> and mis_no = #{misNo}</if>
  147. <!-- 超时工单条件:realEndTime为空且当前时间超过planEndTime -->
  148. <if test="params.overdueCondition != null and params.overdueCondition == 'overdue'">
  149. and real_end_time is null and plan_end_time &lt; NOW()
  150. </if>
  151. <!-- 即将超时工单条件:根据配置判断 -->
  152. <if test="params.overdueCondition != null and params.overdueCondition == 'almostOverdue'">
  153. and real_end_time is null and plan_end_time &gt; NOW()
  154. and TIMESTAMPDIFF(HOUR, NOW(), plan_end_time) &lt;= (
  155. SELECT config_value FROM sys_config WHERE config_key = 'gxt.order.timeout' LIMIT 1
  156. )
  157. </if>
  158. <if test="params.keyword != null and params.keyword != ''">
  159. and (work_order_project_no like concat('%', #{params.keyword}, '%') or pcs_device_name like concat('%', #{params.keyword}, '%'))
  160. </if>
  161. <if test="wwryNum != null"> and wwry_num = #{wwryNum}</if>
  162. <if test="wlryNum != null"> and wlry_num = #{wlryNum}</if>
  163. <if test="infoEntry != null and infoEntry != ''"> and info_entry = #{infoEntry}</if>
  164. <if test="lostPower != null"> and lost_power = #{lostPower}</if>
  165. <if test="workPermitNum != null and workPermitNum != ''"> and work_permit_num = #{workPermitNum}</if>
  166. <!-- 业务特定数据权限过滤条件 -->
  167. <if test="params.businessDataScope != null and params.businessDataScope != ''">
  168. ${params.businessDataScope}
  169. </if>
  170. <!-- 限制待下发工单只能创建人本部门查看 -->
  171. <if test="params.currentUser != null and params.currentUser != ''">
  172. and ((t.work_order_status != 'to_issue' and t.work_order_status != 'accept_return') or t.create_by in
  173. (select user_name from sys_user t1
  174. left join sys_dept t2 on t1.dept_id = t2.dept_id
  175. where t2.dept_id = (select dept_id from sys_user where user_name = #{params.currentUser,jdbcType=VARCHAR} and del_flag='0')))
  176. </if>
  177. </where>
  178. order by create_time desc
  179. </select>
  180. <select id="selectGxtWorkOrderListByMonth" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
  181. SELECT
  182. t.*,
  183. p.nick_names AS leader
  184. FROM
  185. gxt_work_order t
  186. LEFT JOIN (
  187. SELECT
  188. order_id,
  189. GROUP_CONCAT(nick_name) AS nick_names
  190. FROM
  191. gxt_work_order_person
  192. WHERE
  193. is_leader = 1
  194. GROUP BY
  195. order_id
  196. ) p ON p.order_id = t.id
  197. <where>
  198. <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status = #{workOrderStatus}</if>
  199. <if test="model != null and model != ''"> and t.model = #{model}</if>
  200. <if test="inspectionType != null and inspectionType != ''"> and FIND_IN_SET(#{inspectionType}, inspection_type) > 0</if>
  201. <if test="pcsStationPid != null"> and pcs_station_pid = #{pcsStationPid}</if>
  202. <if test="monthPeriod != null"> and DATE_FORMAT(t.create_time, '%Y-%m') = #{monthPeriod}</if>
  203. <if test="params.businessDataScope != null and params.businessDataScope != ''">
  204. ${params.businessDataScope}
  205. </if>
  206. </where>
  207. order by t.create_time desc
  208. </select>
  209. <select id="selectGxtWorkOrderById" parameterType="Long" resultMap="GxtWorkOrderResult">
  210. <include refid="selectGxtWorkOrderVo"/>
  211. where id = #{id}
  212. </select>
  213. <select id="selectGxtWorkOrderListForAutoFinalize" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
  214. <include refid="selectGxtWorkOrderVo"/>
  215. <where>
  216. <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status in
  217. <foreach collection="workOrderStatus.split(',')" item="status" open="(" close=")" separator=",">
  218. #{status}
  219. </foreach>
  220. </if>
  221. and accept_time is not null
  222. and pause_time is not null
  223. and restart_time is not null
  224. </where>
  225. order by create_time desc
  226. </select>
  227. <select id="selectGxtWorkOrderByCode" parameterType="String" resultMap="GxtWorkOrderResult">
  228. <include refid="selectGxtWorkOrderVo"/>
  229. where work_order_project_no = #{workOrderProjectNo}
  230. limit 1
  231. </select>
  232. <insert id="insertGxtWorkOrder" parameterType="GxtWorkOrder" useGeneratedKeys="true" keyProperty="id">
  233. insert into gxt_work_order
  234. <trim prefix="(" suffix=")" suffixOverrides=",">
  235. <if test="workOrderProjectNo != null and workOrderProjectNo != ''">work_order_project_no,</if>
  236. <if test="workOrderStatus != null and workOrderStatus != ''">work_order_status,</if>
  237. <if test="gxtCenterId != null">gxt_center_id,</if>
  238. <if test="gxtCenter != null">gxt_center,</if>
  239. <if test="pcsStationId != null">pcs_station_id,</if>
  240. <if test="pcsStationPid != null">pcs_station_pid,</if>
  241. <if test="pcsStationName != null">pcs_station_name,</if>
  242. <if test="pcsDeviceId != null">pcs_device_id,</if>
  243. <if test="pcsDeviceName != null">pcs_device_name,</if>
  244. <if test="brand != null">brand,</if>
  245. <if test="model != null">model,</if>
  246. <if test="inspectionType != null">inspection_type,</if>
  247. <if test="misNo != null">mis_no,</if>
  248. <if test="planStartTime != null">plan_start_time,</if>
  249. <if test="planEndTime != null">plan_end_time,</if>
  250. <if test="orderSource != null">order_source,</if>
  251. <if test="assignTime != null">assign_time,</if>
  252. <if test="assignUserId != null">assign_user_id,</if>
  253. <if test="assignUserName != null">assign_user_name,</if>
  254. <if test="acceptTime != null">accept_time,</if>
  255. <if test="acceptUserId != null">accept_user_id,</if>
  256. <if test="acceptUserName != null">accept_user_name,</if>
  257. <if test="realStartTime != null">real_start_time,</if>
  258. <if test="realEndTime != null">real_end_time,</if>
  259. <if test="teamLeaderId != null">team_leader_id,</if>
  260. <if test="teamLeaderName != null">team_leader_name,</if>
  261. <if test="workGroupMemberId != null">work_group_member_id,</if>
  262. <if test="workGroupMemberName != null">work_group_member_name,</if>
  263. <if test="suspendReason != null">suspend_reason,</if>
  264. <if test="suspendTime != null">suspend_time,</if>
  265. <if test="statusBeforeSuspend != null">status_before_suspend,</if>
  266. <if test="modifyReason != null">modify_reason,</if>
  267. <if test="pauseReason != null">pause_reason,</if>
  268. <if test="pauseTime != null">pause_time,</if>
  269. <if test="restartTime != null">restart_time,</if>
  270. <if test="completeTime != null">complete_time,</if>
  271. <if test="planHour != null">plan_hour,</if>
  272. <if test="content != null">content,</if>
  273. <if test="realContent != null">real_content,</if>
  274. <if test="faultCode != null">fault_code,</if>
  275. <if test="faultDesc != null">fault_desc,</if>
  276. <if test="orderType != null">order_type,</if>
  277. <if test="priorityType != null">priority_type,</if>
  278. <if test="score != null">score,</if>
  279. <if test="reviewContent != null">review_content,</if>
  280. <if test="issuerName != null">issuer_name,</if>
  281. <if test="permitterName != null">permitter_name,</if>
  282. <if test="scoringStatus != null">scoring_status,</if>
  283. <if test="createBy != null">create_by,</if>
  284. <if test="createTime != null">create_time,</if>
  285. <if test="updateBy != null">update_by,</if>
  286. <if test="updateTime != null">update_time,</if>
  287. <if test="remark != null">remark,</if>
  288. <if test="attachmentUrls != null">attachment_urls,</if>
  289. <if test="itemCompletionFactor != null">item_completion_factor,</if>
  290. <if test="itemCompletionFactorSum != null">item_completion_factor_sum,</if>
  291. <if test="reviewScoreNum != null">review_score_num,</if>
  292. <if test="finalCoefficient != null">final_coefficient,</if>
  293. <if test="invalidReason != null and invalidReason != ''">invalid_reason,</if>
  294. <if test="feedbackReason != null and feedbackReason != ''">feedback_reason,</if>
  295. <if test="confirmStatus != null">confirm_status,</if>
  296. <if test="wwryNum != null">wwry_num,</if>
  297. <if test="wlryNum != null">wlry_num,</if>
  298. <if test="infoEntry != null and infoEntry != ''">info_entry,</if>
  299. <if test="lostPower != null">lost_power,</if>
  300. <if test="workPermitNum != null and workPermitNum != ''">work_permit_num,</if>
  301. <if test="appealUserId != null">appeal_user_id,</if>
  302. <if test="appealUserName != null and appealUserName != ''">appeal_user_name,</if>
  303. <if test="appealTime != null">appeal_time,</if>
  304. <if test="appealReason != null and appealReason != ''">appeal_reason,</if>
  305. <if test="suspendExplain != null and suspendExplain != ''">suspend_explain,</if>
  306. <if test="orderEntryType != null and orderEntryType != ''">order_entry_type,</if>
  307. <if test="scoreReturnReason != null and scoreReturnReason != ''">score_return_reason,</if>
  308. <if test="finalizeMethod != null and finalizeMethod != ''">finalize_method,</if>
  309. </trim>
  310. <trim prefix="values (" suffix=")" suffixOverrides=",">
  311. <if test="workOrderProjectNo != null and workOrderProjectNo != ''">#{workOrderProjectNo},</if>
  312. <if test="workOrderStatus != null and workOrderStatus != ''">#{workOrderStatus},</if>
  313. <if test="gxtCenterId != null">#{gxtCenterId},</if>
  314. <if test="gxtCenter != null">#{gxtCenter},</if>
  315. <if test="pcsStationId != null">#{pcsStationId},</if>
  316. <if test="pcsStationPid != null">#{pcsStationPid},</if>
  317. <if test="pcsStationName != null">#{pcsStationName},</if>
  318. <if test="pcsDeviceId != null">#{pcsDeviceId},</if>
  319. <if test="pcsDeviceName != null">#{pcsDeviceName},</if>
  320. <if test="brand != null">#{brand},</if>
  321. <if test="model != null">#{model},</if>
  322. <if test="inspectionType != null">#{inspectionType},</if>
  323. <if test="misNo != null">#{misNo},</if>
  324. <if test="planStartTime != null">#{planStartTime},</if>
  325. <if test="planEndTime != null">#{planEndTime},</if>
  326. <if test="orderSource != null">#{orderSource},</if>
  327. <if test="assignTime != null">#{assignTime},</if>
  328. <if test="assignUserId != null">#{assignUserId},</if>
  329. <if test="assignUserName != null">#{assignUserName},</if>
  330. <if test="acceptTime != null">#{acceptTime},</if>
  331. <if test="acceptUserId != null">#{acceptUserId},</if>
  332. <if test="acceptUserName != null">#{acceptUserName},</if>
  333. <if test="realStartTime != null">#{realStartTime},</if>
  334. <if test="realEndTime != null">#{realEndTime},</if>
  335. <if test="teamLeaderId != null">#{teamLeaderId},</if>
  336. <if test="teamLeaderName != null">#{teamLeaderName},</if>
  337. <if test="workGroupMemberId != null">#{workGroupMemberId},</if>
  338. <if test="workGroupMemberName != null">#{workGroupMemberName},</if>
  339. <if test="suspendReason != null">#{suspendReason},</if>
  340. <if test="suspendTime != null">#{suspendTime},</if>
  341. <if test="statusBeforeSuspend != null">#{statusBeforeSuspend},</if>
  342. <if test="modifyReason != null">#{modifyReason},</if>
  343. <if test="pauseReason != null">#{pauseReason},</if>
  344. <if test="pauseTime != null">#{pauseTime},</if>
  345. <if test="restartTime != null">#{restartTime},</if>
  346. <if test="completeTime != null">#{completeTime},</if>
  347. <if test="planHour != null">#{planHour},</if>
  348. <if test="content != null">#{content},</if>
  349. <if test="realContent != null">#{realContent},</if>
  350. <if test="faultCode != null">#{faultCode},</if>
  351. <if test="faultDesc != null">#{faultDesc},</if>
  352. <if test="orderType != null">#{orderType},</if>
  353. <if test="priorityType != null">#{priorityType},</if>
  354. <if test="score != null">#{score},</if>
  355. <if test="reviewContent != null">#{reviewContent},</if>
  356. <if test="issuerName != null">#{issuerName},</if>
  357. <if test="permitterName != null">#{permitterName},</if>
  358. <if test="scoringStatus != null">#{scoringStatus},</if>
  359. <if test="createBy != null">#{createBy},</if>
  360. <if test="createTime != null">#{createTime},</if>
  361. <if test="updateBy != null">#{updateBy},</if>
  362. <if test="updateTime != null">#{updateTime},</if>
  363. <if test="remark != null">#{remark},</if>
  364. <if test="attachmentUrls != null">#{attachmentUrls},</if>
  365. <if test="itemCompletionFactor != null">#{itemCompletionFactor},</if>
  366. <if test="itemCompletionFactorSum != null">#{itemCompletionFactorSum},</if>
  367. <if test="reviewScoreNum != null">#{reviewScoreNum},</if>
  368. <if test="finalCoefficient != null">#{finalCoefficient},</if>
  369. <if test="invalidReason != null and invalidReason != ''">#{invalidReason},</if>
  370. <if test="feedbackReason != null and feedbackReason != ''">#{feedbackReason},</if>
  371. <if test="confirmStatus != null">#{confirmStatus},</if>
  372. <if test="wwryNum != null">#{wwryNum},</if>
  373. <if test="wlryNum != null">#{wlryNum},</if>
  374. <if test="infoEntry != null and infoEntry != ''">#{infoEntry},</if>
  375. <if test="lostPower != null">#{lostPower},</if>
  376. <if test="workPermitNum != null and workPermitNum != ''">#{workPermitNum},</if>
  377. <if test="appealUserId != null">#{appealUserId},</if>
  378. <if test="appealUserName != null and appealUserName != ''">#{appealUserName},</if>
  379. <if test="appealTime != null">#{appealTime},</if>
  380. <if test="appealReason != null and appealReason != ''">#{appealReason},</if>
  381. <if test="suspendExplain != null and suspendExplain != ''">#{suspendExplain},</if>
  382. <if test="orderEntryType != null and orderEntryType != ''">#{orderEntryType},</if>
  383. <if test="scoreReturnReason != null and scoreReturnReason != ''">#{scoreReturnReason},</if>
  384. <if test="finalizeMethod != null and finalizeMethod != ''">#{finalizeMethod},</if>
  385. </trim>
  386. </insert>
  387. <update id="updateGxtWorkOrderByStatus" parameterType="GxtWorkOrder">
  388. update gxt_work_order
  389. SET is_deferred = #{isDeferred}
  390. <where>
  391. <if test="itemCompletionFactorSum != null"> AND #{itemCompletionFactorSum} > item_completion_factor_sum</if>
  392. <if test="workOrderStatus != null and workOrderStatus != ''"> AND work_order_status = #{workOrderStatus}</if>
  393. <if test="realEndTime != null"> AND #{realEndTime} > create_time</if>
  394. </where>
  395. </update>
  396. <update id="updateGxtWorkOrderByDeferred" parameterType="GxtWorkOrder">
  397. update gxt_work_order
  398. SET is_deferred = null
  399. <where>
  400. <if test="itemCompletionFactorSum != null"> AND item_completion_factor_sum = #{itemCompletionFactorSum}</if>
  401. <if test="workOrderStatus != null and workOrderStatus != ''"> AND work_order_status = #{workOrderStatus}</if>
  402. <if test="realEndTime != null"> AND #{realEndTime} > create_time</if>
  403. </where>
  404. </update>
  405. <update id="updateGxtWorkOrder" parameterType="GxtWorkOrder">
  406. update gxt_work_order
  407. <trim prefix="SET" suffixOverrides=",">
  408. <if test="workOrderProjectNo != null and workOrderProjectNo != ''">work_order_project_no = #{workOrderProjectNo},</if>
  409. <if test="workOrderStatus != null and workOrderStatus != ''">work_order_status = #{workOrderStatus},</if>
  410. <if test="gxtCenterId != null">gxt_center_id = #{gxtCenterId},</if>
  411. <if test="gxtCenter != null">gxt_center = #{gxtCenter},</if>
  412. <if test="pcsStationId != null">pcs_station_id = #{pcsStationId},</if>
  413. <if test="pcsStationPid != null">pcs_station_pid = #{pcsStationPid},</if>
  414. <if test="pcsStationName != null">pcs_station_name = #{pcsStationName},</if>
  415. <if test="pcsDeviceId != null">pcs_device_id = #{pcsDeviceId},</if>
  416. <if test="pcsDeviceName != null">pcs_device_name = #{pcsDeviceName},</if>
  417. <if test="brand != null">brand = #{brand},</if>
  418. <if test="model != null">model = #{model},</if>
  419. <if test="inspectionType != null">inspection_type = #{inspectionType},</if>
  420. <if test="misNo != null">mis_no = #{misNo},</if>
  421. <if test="planStartTime != null">plan_start_time = #{planStartTime},</if>
  422. <if test="planEndTime != null">plan_end_time = #{planEndTime},</if>
  423. <if test="orderSource != null">order_source = #{orderSource},</if>
  424. <if test="assignTime != null">assign_time = #{assignTime},</if>
  425. <if test="assignUserId != null">assign_user_id = #{assignUserId},</if>
  426. <if test="assignUserName != null">assign_user_name = #{assignUserName},</if>
  427. <if test="acceptTime != null">accept_time = #{acceptTime},</if>
  428. <if test="acceptUserId != null">accept_user_id = #{acceptUserId},</if>
  429. <if test="acceptUserName != null">accept_user_name = #{acceptUserName},</if>
  430. <if test="realStartTime != null">real_start_time = #{realStartTime},</if>
  431. <if test="realEndTime != null">real_end_time = #{realEndTime},</if>
  432. <if test="teamLeaderId != null">team_leader_id = #{teamLeaderId},</if>
  433. <if test="teamLeaderName != null">team_leader_name = #{teamLeaderName},</if>
  434. <if test="workGroupMemberId != null">work_group_member_id = #{workGroupMemberId},</if>
  435. <if test="workGroupMemberName != null">work_group_member_name = #{workGroupMemberName},</if>
  436. <if test="suspendReason != null">suspend_reason = #{suspendReason},</if>
  437. <if test="suspendTime != null">suspend_time = #{suspendTime},</if>
  438. <if test="statusBeforeSuspend != null">status_before_suspend = #{statusBeforeSuspend},</if>
  439. <if test="modifyReason != null">modify_reason = #{modifyReason},</if>
  440. <if test="pauseReason != null">pause_reason = #{pauseReason},</if>
  441. <if test="pauseTime != null">pause_time = #{pauseTime},</if>
  442. <if test="restartTime != null">restart_time = #{restartTime},</if>
  443. <if test="completeTime != null">complete_time = #{completeTime},</if>
  444. <if test="planHour != null">plan_hour = #{planHour},</if>
  445. <if test="content != null">content = #{content},</if>
  446. <if test="realContent != null">real_content = #{realContent},</if>
  447. <if test="faultCode != null">fault_code = #{faultCode},</if>
  448. <if test="faultDesc != null">fault_desc = #{faultDesc},</if>
  449. <if test="orderType != null">order_type = #{orderType},</if>
  450. <if test="priorityType != null">priority_type = #{priorityType},</if>
  451. <if test="score != null">score = #{score},</if>
  452. <if test="reviewContent != null">review_content = #{reviewContent},</if>
  453. <if test="issuerName != null">issuer_name = #{issuerName},</if>
  454. <if test="permitterName != null">permitter_name = #{permitterName},</if>
  455. <if test="scoringStatus != null">scoring_status = #{scoringStatus},</if>
  456. <if test="createBy != null">create_by = #{createBy},</if>
  457. <if test="createTime != null">create_time = #{createTime},</if>
  458. <if test="updateBy != null">update_by = #{updateBy},</if>
  459. <if test="updateTime != null">update_time = #{updateTime},</if>
  460. <if test="remark != null">remark = #{remark},</if>
  461. <if test="attachmentUrls != null">attachment_urls = #{attachmentUrls},</if>
  462. <if test="itemCompletionFactor != null">item_completion_factor = #{itemCompletionFactor},</if>
  463. <if test="itemCompletionFactorSum != null">item_completion_factor_sum = #{itemCompletionFactorSum},</if>
  464. <if test="reviewScoreNum != null">review_score_num = #{reviewScoreNum},</if>
  465. <if test="finalCoefficient != null">final_coefficient = #{finalCoefficient},</if>
  466. <if test="invalidReason != null and invalidReason != ''">invalid_reason = #{invalidReason},</if>
  467. <if test="feedbackReason != null and feedbackReason != ''">feedback_reason = #{feedbackReason},</if>
  468. <if test="confirmStatus != null">confirm_status = #{confirmStatus},</if>
  469. <if test="wwryNum != null">wwry_num = #{wwryNum},</if>
  470. <if test="wlryNum != null">wlry_num = #{wlryNum},</if>
  471. <if test="infoEntry != null and infoEntry != ''">info_entry = #{infoEntry},</if>
  472. <if test="lostPower != null">lost_power = #{lostPower},</if>
  473. <if test="workPermitNum != null and workPermitNum != ''">work_permit_num = #{workPermitNum},</if>
  474. <if test="appealUserId != null">appeal_user_id = #{appealUserId},</if>
  475. <if test="appealUserName != null and appealUserName != ''">appeal_user_name = #{appealUserName},</if>
  476. <if test="appealTime != null">appeal_time = #{appealTime},</if>
  477. <if test="appealReason != null and appealReason != ''">appeal_reason = #{appealReason},</if>
  478. <if test="suspendExplain != null and suspendExplain != ''">suspend_explain = #{suspendExplain},</if>
  479. <if test="orderEntryType != null and orderEntryType != ''">order_entry_type = #{orderEntryType},</if>
  480. <if test="scoreReturnReason != null and scoreReturnReason != ''">score_return_reason = #{scoreReturnReason},</if>
  481. <if test="finalizeMethod != null and finalizeMethod != ''">finalize_method = #{finalizeMethod},</if>
  482. </trim>
  483. where id = #{id}
  484. </update>
  485. <delete id="deleteGxtWorkOrderById" parameterType="Long">
  486. delete from gxt_work_order where id = #{id}
  487. </delete>
  488. <delete id="deleteGxtWorkOrderByIds" parameterType="String">
  489. delete from gxt_work_order where id in
  490. <foreach item="id" collection="array" open="(" separator="," close=")">
  491. #{id}
  492. </foreach>
  493. </delete>
  494. <!-- 查询会超时的工单(待归档且超时3天) -->
  495. <select id="selectExpiredWorkOrders" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
  496. <include refid="selectGxtWorkOrderVo"/>
  497. where work_order_status = #{status}
  498. and t.update_time &lt; #{thresholdDate}
  499. order by t.update_time asc
  500. </select>
  501. <!-- 根据MIS系统编号查询维保工单 -->
  502. <select id="selectGxtWorkOrderByMisNo" parameterType="String" resultMap="GxtWorkOrderResult">
  503. <include refid="selectGxtWorkOrderVo"/>
  504. where mis_no = #{misNo}
  505. limit 1
  506. </select>
  507. <resultMap type="GxtWorkOrder" id="GxtWorkOrderWithPersonResult" extends="GxtWorkOrderResult">
  508. <collection property="workOrderPersonList" ofType="com.ygtx.gxt.domain.GxtWorkOrderPerson">
  509. <result property="id" column="person_id"/>
  510. <result property="userId" column="person_user_id"/>
  511. <result property="nickName" column="person_nick_name"/>
  512. <result property="orderId" column="person_order_id"/>
  513. <result property="orderCode" column="person_order_code"/>
  514. <result property="status" column="person_status"/>
  515. <result property="misNo" column="person_mis_no"/>
  516. <result property="userName" column="person_user_name"/>
  517. <result property="selfScore" column="person_self_score"/>
  518. <result property="reviewScore" column="person_review_score"/>
  519. <result property="finalScore" column="person_final_score"/>
  520. <result property="isLeader" column="person_is_leader"/>
  521. </collection>
  522. </resultMap>
  523. <select id="selectWorkOrderWithPersonById" parameterType="Long" resultMap="GxtWorkOrderWithPersonResult">
  524. SELECT
  525. t1.id,
  526. t1.work_order_project_no,
  527. t1.work_order_status,
  528. t1.gxt_center_id,
  529. t1.gxt_center,
  530. t1.pcs_station_id,
  531. t1.pcs_station_name,
  532. t1.pcs_device_id,
  533. t1.pcs_device_name,
  534. t1.brand,
  535. t1.model,
  536. t1.inspection_type,
  537. t1.mis_no,
  538. t1.plan_start_time,
  539. t1.plan_end_time,
  540. t1.order_source,
  541. t1.assign_time,
  542. t1.assign_user_id,
  543. t1.assign_user_name,
  544. t1.accept_time,
  545. t1.accept_user_id,
  546. t1.accept_user_name,
  547. t1.real_start_time,
  548. t1.real_end_time,
  549. t1.team_leader_id,
  550. t1.team_leader_name,
  551. t1.work_group_member_id,
  552. t1.work_group_member_name,
  553. t1.suspend_reason,
  554. t1.suspend_time,
  555. t1.status_before_suspend,
  556. t1.modify_reason,
  557. t1.pause_reason,
  558. t1.pause_time,
  559. t1.restart_time,
  560. t1.complete_time,
  561. t1.plan_hour,
  562. t1.content,
  563. t1.real_content,
  564. t1.fault_code,
  565. t1.fault_desc,
  566. t1.order_type,
  567. t1.priority_type,
  568. t1.score,
  569. t1.review_content,
  570. t1.issuer_name,
  571. t1.permitter_name,
  572. t1.scoring_status,
  573. t1.attachment_urls,
  574. t1.attachment_file_names,
  575. t1.attachment_original_names,
  576. t1.review_score_num,
  577. t1.final_coefficient,
  578. t1.create_by,
  579. t1.create_time,
  580. t1.update_by,
  581. t1.update_time,
  582. t1.remark,
  583. t1.work_permit_num,
  584. t1.appeal_user_id,
  585. t1.appeal_user_name,
  586. t1.appeal_time,
  587. t1.appeal_reason,
  588. t2.id as person_id,
  589. t2.user_id as person_user_id,
  590. t2.nick_name as person_nick_name,
  591. t2.order_id as person_order_id,
  592. t2.order_code as person_order_code,
  593. t2.status as person_status,
  594. t2.mis_no as person_mis_no,
  595. t2.user_name as person_user_name,
  596. t2.self_score as person_self_score,
  597. t2.review_score as person_review_score,
  598. t2.final_score as person_final_score,
  599. t2.is_leader as person_is_leader
  600. FROM gxt_work_order t1
  601. LEFT JOIN gxt_work_order_person t2 ON t1.id = t2.order_id
  602. WHERE t1.id = #{id}
  603. </select>
  604. <select id="selectHomePageWorkOrderList" parameterType="GxtOrderData" resultMap="GxtOrderDataResult">
  605. <trim prefix="SELECT" suffixOverrides=",">
  606. <choose>
  607. <when test="(xfsc != null and xfsc == 'true') or (xysc != null and xysc == 'true') or (zbsc != null and zbsc == 'true') or (tjsc != null and tjsc == 'true') or (qjbwsc != null and qjbwsc == 'true') or (clsc != null and clsc == 'true') or (gqsc != null and gqsc == 'true') or (score != null and score == 1)">
  608. o.work_order_project_no AS order_code,
  609. <if test="workOrderNum != null and workOrderNum == 1">
  610. CASE
  611. WHEN o.orderType='维保工单' THEN 1
  612. ELSE NULL
  613. END AS workOrderNum,
  614. </if>
  615. <if test="repairOrderNum != null and repairOrderNum == 1">
  616. CASE
  617. WHEN o.orderType='维修工单' THEN 1
  618. ELSE NULL
  619. END AS repairOrderNum,
  620. </if>
  621. <if test="restartNum != null and restartNum == 1">
  622. o.restart_flag AS restart_num,
  623. </if>
  624. </when>
  625. <otherwise>
  626. <if test="workOrderNum != null and workOrderNum == 1">
  627. CASE
  628. WHEN o.orderType='维保工单' THEN COUNT(*)
  629. ELSE NULL
  630. END AS workOrderNum,
  631. </if>
  632. <if test="repairOrderNum != null and repairOrderNum == 1">
  633. CASE
  634. WHEN o.orderType='维修工单' THEN COUNT(*)
  635. ELSE NULL
  636. END AS repairOrderNum,
  637. </if>
  638. <if test="restartNum != null and restartNum == 1">
  639. SUM(o.restart_flag) AS restart_num,
  640. </if>
  641. </otherwise>
  642. </choose>
  643. <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
  644. <if test="code != null and code == 'true'">o.`code`,</if>
  645. <if test="brand != null and brand == 'true'">o.brand,</if>
  646. <if test="model != null and model == 'true'">o.model,</if>
  647. <if test="system != null and system == 'true'">o.`system`,</if>
  648. <if test="pcs != null and pcs == 'true'">o.pcs,</if>
  649. <if test="center != null and center == 'true'">IFNULL(o.center,'未知中心') AS center,</if>
  650. <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
  651. <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
  652. <if test="score != null and score == 1">o.score,</if>
  653. <if test="xfsc != null and xfsc == 'true'">o.xfsc,</if>
  654. <if test="xysc != null and xysc == 'true'">o.xysc,</if>
  655. <if test="zbsc != null and zbsc == 'true'">
  656. CASE
  657. WHEN o.zbsc IS NULL THEN NULL
  658. WHEN o.zbsc <![CDATA[<]]> 0 THEN 0
  659. ELSE o.zbsc
  660. END AS zbsc,</if>
  661. <if test="tjsc != null and tjsc == 'true'">o.tjsc,</if>
  662. <if test="qjbwsc != null and qjbwsc == 'true'">o.qjbwsc,</if>
  663. <if test="clsc != null and clsc == 'true'">o.clsc,</if>
  664. <if test="gqsc != null and gqsc == 'true'">o.gqsc,</if>
  665. </trim>
  666. FROM (
  667. SELECT
  668. wo.work_order_project_no,
  669. wo.create_time,
  670. wo.pcs_device_name AS `code`,
  671. wo.pcs_station_name AS pcs,
  672. wo.brand,
  673. wo.model,
  674. IF(wo.repair_method='2', 1, null) AS restart_flag,
  675. wo.mis_no AS `system`,
  676. wo.gxt_center AS center,
  677. '维保工单' AS orderType,
  678. wo.team_leader_name AS chargePerson,
  679. <if test="repairPerson != null and repairPerson == 'true'">wop.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
  680. <if test="repairPerson == null or repairPerson == '' or repairPerson == 'false'">ROUND(wo.score,2) AS score,</if>
  681. ROUND(TIMESTAMPDIFF( MINUTE, wo.create_time, wo.assign_time ) / 60,2) AS xfsc,
  682. ROUND(TIMESTAMPDIFF( MINUTE, wo.assign_time, wo.accept_time ) / 60,2) AS xysc,
  683. ROUND((TIMESTAMPDIFF( MINUTE, wo.accept_time, wo.real_start_time ) / 60) - (IFNULL(gq.total_before_start_suspend_seconds, 0) / 3600),2) AS zbsc,
  684. ROUND(TIMESTAMPDIFF( MINUTE, COALESCE ( wo.pause_time, wo.real_start_time ), wo.restart_time ) / 60,2) AS tjsc,
  685. ROUND(TIMESTAMPDIFF( MINUTE, wo.real_end_time, wo.restart_time ) / 60,2) AS qjbwsc,
  686. ROUND(( TIMESTAMPDIFF( MINUTE, wo.real_start_time, wo.real_end_time ) / 60 ) - (IFNULL(gq.total_in_work_suspend_seconds, 0) / 3600),2) AS clsc,
  687. ROUND(CASE WHEN gq.order_id IS NOT NULL THEN (gq.total_in_work_suspend_seconds)/3600 ELSE 0 END,2) AS gqsc
  688. FROM
  689. gxt_work_order wo
  690. <if test="repairPerson != null and repairPerson == 'true'">
  691. LEFT JOIN gxt_work_order_person wop ON wo.id = wop.order_id
  692. </if>
  693. LEFT JOIN gxt_work_order_flow_records_next gq ON gq.order_id = wo.id
  694. LEFT JOIN (SELECT order_id,COUNT(*) AS wop_num FROM gxt_work_order_person GROUP BY order_id) wopp ON wopp.order_id=wo.id
  695. <where>
  696. <if test="startTime != null "> AND wo.create_time > #{startTime}</if>
  697. <if test="endTime != null "> AND wo.create_time <![CDATA[<]]> #{endTime}</if>
  698. <if test="pcsId != null "> AND wo.pcs_station_pid = #{pcsId}</if>
  699. <if test="centerId != null "> AND wo.gxt_center_id = #{centerId}</if>
  700. <if test="remark != null and remark != '' ">
  701. AND (
  702. wo.pcs_device_name LIKE concat('%', #{remark}, '%')
  703. OR wo.brand LIKE concat('%', #{remark}, '%')
  704. OR wo.model LIKE concat('%', #{remark}, '%')
  705. OR wo.gxt_center LIKE concat('%', #{remark}, '%')
  706. OR wo.pcs_station_name LIKE concat('%', #{remark}, '%')
  707. OR wo.team_leader_name LIKE concat('%', #{remark}, '%')
  708. )
  709. </if>
  710. <if test="devices != null and devices != ''">
  711. AND wo.pcs_device_id IN
  712. <foreach item="item" collection="devices.split(',')" open="(" separator="," close=")">
  713. #{item, jdbcType=BIGINT} <!-- 指定 Long 类型 -->
  714. </foreach>
  715. </if>
  716. <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
  717. AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
  718. </where>
  719. UNION ALL
  720. SELECT
  721. wo.work_order_project_no,
  722. wo.occur_time AS create_time,
  723. wo.pcs_device_name AS `code`,
  724. wo.pcs_station_name AS pcs,
  725. wo.brand,
  726. wo.model,
  727. IF(wo.repair_method='2', 1, 0) AS restart_flag,
  728. NULL AS `system`,
  729. wo.gxt_center AS center,
  730. '维修工单' AS orderType,
  731. wo.team_leader_name AS chargePerson,
  732. <if test="repairPerson != null and repairPerson == 'true'">wop.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
  733. <if test="repairPerson == null or repairPerson == '' or repairPerson == 'false'">ROUND(wo.score,2) AS score,</if>
  734. ROUND(TIMESTAMPDIFF( MINUTE, wo.occur_time, wo.assign_time ) / 60,2) AS xfsc,
  735. ROUND((TIMESTAMPDIFF( MINUTE, wo.assign_time, wo.accept_time ) / 60)-(IFNULL(gq.total_night_auto_suspend_seconds, 0) / 3600),2) AS xysc,
  736. ROUND((TIMESTAMPDIFF( MINUTE, wo.accept_time, wo.real_start_time ) / 60)-(IFNULL(gq.total_before_start_suspend_seconds, 0) / 3600),2) AS zbsc,
  737. ROUND(TIMESTAMPDIFF( MINUTE, wo.occur_time, wo.restart_time ) / 60,2) AS tjsc,
  738. ROUND(TIMESTAMPDIFF( MINUTE, wo.real_end_time, wo.restart_time ) / 60,2) AS qjbwsc,
  739. ROUND((TIMESTAMPDIFF( MINUTE, wo.real_start_time, wo.real_end_time ) / 60 ) - (IFNULL(gq.total_before_start_suspend_seconds, 0) / 3600) - (IFNULL(gq.total_in_work_suspend_seconds, 0) / 3600),2) AS clsc,
  740. ROUND(CASE WHEN gq.order_id IS NOT NULL THEN (gq.total_before_start_suspend_seconds + gq.total_in_work_suspend_seconds + gq.total_night_auto_suspend_seconds)/3600 ELSE 0 END,2) AS gqsc
  741. FROM
  742. gxt_repair_order wo
  743. <if test="repairPerson != null and repairPerson == 'true'">
  744. LEFT JOIN gxt_repair_order_person wop ON wo.id = wop.order_id
  745. </if>
  746. LEFT JOIN gxt_repair_order_flow_records_next gq ON gq.order_id = wo.id
  747. LEFT JOIN (SELECT order_id,COUNT(*) AS wop_num FROM gxt_repair_order_person GROUP BY order_id) wopp ON wopp.order_id=wo.id
  748. <where>
  749. <if test="startTime != null "> AND wo.occur_time > #{startTime}</if>
  750. <if test="endTime != null "> AND wo.occur_time <![CDATA[<]]> #{endTime}</if>
  751. <if test="pcsId != null "> AND wo.pcs_station_pid = #{pcsId}</if>
  752. <if test="centerId != null "> AND wo.gxt_center_id = #{centerId}</if>
  753. <if test="remark != null and remark != '' ">
  754. AND (
  755. wo.pcs_device_name LIKE concat('%', #{remark}, '%')
  756. OR wo.brand LIKE concat('%', #{remark}, '%')
  757. OR wo.model LIKE concat('%', #{remark}, '%')
  758. OR wo.gxt_center LIKE concat('%', #{remark}, '%')
  759. OR wo.pcs_station_name LIKE concat('%', #{remark}, '%')
  760. OR wo.team_leader_name LIKE concat('%', #{remark}, '%')
  761. )
  762. </if>
  763. <if test="devices != null and devices != ''">
  764. AND wo.pcs_device_id IN
  765. <foreach item="item" collection="devices.split(',')" open="(" separator="," close=")">
  766. #{item, jdbcType=BIGINT} <!-- 指定 Long 类型 -->
  767. </foreach>
  768. </if>
  769. <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
  770. AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL AND wo.work_order_status IN ('completed','archived')
  771. </where>
  772. ) o
  773. <choose>
  774. <when test="(xfsc != null and xfsc == 'true') or (xysc != null and xysc == 'true') or (zbsc != null and zbsc == 'true') or (tjsc != null and tjsc == 'true') or (qjbwsc != null and qjbwsc == 'true') or (clsc != null and clsc == 'true') or (gqsc != null and gqsc == 'true') or (score != null and score == 1)">
  775. <trim prefix="ORDER BY" suffixOverrides=",">
  776. <if test="center != null and center == 'true'">o.center,</if>
  777. <if test="pcs != null and pcs == 'true'">o.pcs,</if>
  778. <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
  779. o.work_order_project_no,
  780. <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
  781. <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
  782. <if test="brand != null and brand == 'true'">o.brand,</if>
  783. <if test="model != null and model == 'true'">o.model,</if>
  784. <if test="system != null and system == 'true'">o.`system`,</if>
  785. <if test="code != null and code == 'true'">o.`code`,</if>
  786. </trim>
  787. </when>
  788. <otherwise>
  789. <trim prefix="GROUP BY" suffixOverrides=",">
  790. <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
  791. <if test="code != null and code == 'true'">o.`code`,</if>
  792. <if test="brand != null and brand == 'true'">o.brand,</if>
  793. <if test="model != null and model == 'true'">o.model,</if>
  794. <if test="system != null and system == 'true'">o.`system`,</if>
  795. <if test="pcs != null and pcs == 'true'">o.pcs,</if>
  796. <if test="center != null and center == 'true'">o.center,</if>
  797. <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
  798. <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
  799. <if test="score != null and score == 1">o.score,</if>
  800. <if test="xfsc != null and xfsc == 'true'">o.xfsc,</if>
  801. <if test="xysc != null and xysc == 'true'">o.xysc,</if>
  802. <if test="zbsc != null and zbsc == 'true'">o.zbsc,</if>
  803. <if test="tjsc != null and tjsc == 'true'">o.tjsc,</if>
  804. <if test="qjbwsc != null and qjbwsc == 'true'">o.qjbwsc,</if>
  805. <if test="clsc != null and clsc == 'true'">o.clsc,</if>
  806. <if test="gqsc != null and gqsc == 'true'">o.gqsc,</if>
  807. </trim>
  808. <trim prefix="ORDER BY" suffixOverrides=",">
  809. <if test="center != null and center == 'true'">o.center,</if>
  810. <if test="pcs != null and pcs == 'true'">o.pcs,</if>
  811. <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
  812. <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
  813. <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
  814. <if test="brand != null and brand == 'true'">o.brand,</if>
  815. <if test="model != null and model == 'true'">o.model,</if>
  816. <if test="system != null and system == 'true'">o.`system`,</if>
  817. <if test="code != null and code == 'true'">o.`code`,</if>
  818. <if test="score != null and score == 1">o.score,</if>
  819. <if test="xfsc != null and xfsc == 'true'">o.xfsc,</if>
  820. <if test="xysc != null and xysc == 'true'">o.xysc,</if>
  821. <if test="zbsc != null and zbsc == 'true'">o.zbsc,</if>
  822. <if test="tjsc != null and tjsc == 'true'">o.tjsc,</if>
  823. <if test="qjbwsc != null and qjbwsc == 'true'">o.qjbwsc,</if>
  824. <if test="clsc != null and clsc == 'true'">o.clsc,</if>
  825. <if test="gqsc != null and gqsc == 'true'">o.gqsc,</if>
  826. </trim>
  827. </otherwise>
  828. </choose>
  829. </select>
  830. <select id="selectLatestGxtWorkOrderByDeviceId" parameterType="map" resultMap="GxtWorkOrderResult">
  831. <include refid="selectGxtWorkOrderVo"/>
  832. <where>
  833. <if test="pcsDeviceId != null"> and pcs_device_id = #{pcsDeviceId}</if>
  834. <if test="limit != null and limit > 0">
  835. ORDER BY create_time DESC LIMIT #{limit}
  836. </if>
  837. </where>
  838. </select>
  839. <select id="selectGxtWorkOrderByDeviceIdWithCondition" parameterType="map" resultMap="GxtWorkOrderResult">
  840. <include refid="selectGxtWorkOrderVo"/>
  841. <where>
  842. <if test="pcsDeviceId != null"> and pcs_device_id = #{pcsDeviceId}</if>
  843. <if test="workOrderStatus != null and workOrderStatus != ''">
  844. <if test="excludeStatus">
  845. and work_order_status != #{workOrderStatus}
  846. </if>
  847. <if test="!excludeStatus">
  848. and work_order_status = #{workOrderStatus}
  849. </if>
  850. </if>
  851. </where>
  852. <choose>
  853. <when test="orderByField != null and orderByField == 'pauseTime'">
  854. ORDER BY pause_time DESC
  855. </when>
  856. <when test="orderByField != null and orderByField == 'restartTime'">
  857. ORDER BY restart_time DESC
  858. </when>
  859. <otherwise>
  860. ORDER BY create_time DESC
  861. </otherwise>
  862. </choose>
  863. <if test="limit != null and limit > 0">
  864. LIMIT #{limit}
  865. </if>
  866. </select>
  867. <select id="selectGxtWorkOrderRunningDaysInfo" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
  868. SELECT
  869. t.pcs_device_name,
  870. t.model,
  871. t.work_order_project_no,
  872. t.restart_time,
  873. COALESCE ( t.pause_time, t.real_start_time ) AS pause_time,
  874. t.pcs_station_pid,
  875. 1 AS order_type,
  876. t.pcs_device_id,t.gxt_center_id,t.gxt_center,t.pcs_station_id,t.pcs_station_name,d.dept_name,
  877. DATEDIFF( t.restart_time, COALESCE ( t.pause_time, t.real_start_time ) ) AS stop_days,
  878. DATEDIFF( NOW(), DATE(t.restart_time) + INTERVAL 1 DAY ) AS running_days
  879. FROM
  880. gxt_work_order t
  881. INNER JOIN (
  882. SELECT
  883. pcs_device_id,
  884. MAX( COALESCE ( pause_time, real_start_time )) AS latest_time,
  885. MAX( CASE WHEN pause_time IS NOT NULL THEN 1 ELSE 0 END ) AS is_pause_time
  886. FROM
  887. gxt_work_order
  888. WHERE
  889. ( pause_time IS NOT NULL OR real_start_time IS NOT NULL )
  890. AND restart_time IS NOT NULL
  891. GROUP BY
  892. pcs_device_id
  893. ) latest ON t.pcs_device_id = latest.pcs_device_id
  894. AND ( ( latest.is_pause_time = 1 AND t.pause_time = latest.latest_time )
  895. OR
  896. ( latest.is_pause_time = 0 AND t.pause_time IS NULL AND t.real_start_time = latest.latest_time ) )
  897. LEFT JOIN sys_dept d ON d.dept_id=t.pcs_station_pid
  898. WHERE
  899. latest.pcs_device_id IS NOT NULL
  900. AND t.restart_time IS NOT NULL
  901. <if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
  902. <if test="pcsStationName != null and pcsStationName != ''"> and t.pcs_station_name like concat('%', #{pcsStationName}, '%')</if>
  903. <if test="pcsStationId != null"> and t.pcs_station_id = #{pcsStationId}</if>
  904. <if test="pcsStationPid != null"> and t.pcs_station_pid = #{pcsStationPid}</if>
  905. <if test="params.businessDataScope != null and params.businessDataScope != ''">
  906. ${params.businessDataScope}
  907. </if>
  908. </select>
  909. <select id="selectGxtRepairOrderRunningDaysInfo" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
  910. SELECT
  911. t.pcs_device_name,
  912. t.model,
  913. t.work_order_project_no,
  914. t.restart_time,
  915. t.pcs_station_pid,
  916. t.occur_time AS pause_time,
  917. 2 AS order_type,
  918. t.pcs_device_id,t.gxt_center_id,t.gxt_center,t.pcs_station_id,t.pcs_station_name,d.dept_name,
  919. DATEDIFF( t.restart_time, t.occur_time ) AS stop_days,
  920. DATEDIFF( NOW(), DATE(t.restart_time) + INTERVAL 1 DAY ) AS running_days
  921. FROM
  922. gxt_repair_order t
  923. INNER JOIN (
  924. SELECT
  925. pcs_device_id,
  926. MAX( occur_time ) AS latest_pause_time
  927. FROM
  928. gxt_repair_order
  929. WHERE
  930. occur_time IS NOT NULL AND restart_time IS NOT NULL
  931. GROUP BY
  932. pcs_device_id
  933. ) latest ON t.pcs_device_id = latest.pcs_device_id
  934. AND t.occur_time = latest.latest_pause_time
  935. LEFT JOIN sys_dept d ON d.dept_id=t.pcs_station_pid
  936. WHERE
  937. t.occur_time IS NOT NULL
  938. AND t.restart_time IS NOT NULL
  939. <if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
  940. <if test="pcsStationName != null and pcsStationName != ''"> and t.pcs_station_name like concat('%', #{pcsStationName}, '%')</if>
  941. <if test="pcsStationId != null"> and t.pcs_station_id = #{pcsStationId}</if>
  942. <if test="pcsStationPid != null"> and t.pcs_station_pid = #{pcsStationPid}</if>
  943. <if test="params.businessDataScope != null and params.businessDataScope != ''">
  944. ${params.businessDataScope}
  945. </if>
  946. </select>
  947. </mapper>