GxtWorkOrderMapper.xml 64 KB

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