| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ygtx.gxt.mapper.GxtWorkOrderMapper">
- <resultMap type="GxtWorkOrder" id="GxtWorkOrderResult">
- <result property="id" column="id" />
- <result property="workOrderProjectNo" column="work_order_project_no" />
- <result property="workOrderStatus" column="work_order_status" />
- <result property="gxtCenterId" column="gxt_center_id" />
- <result property="gxtCenter" column="gxt_center" />
- <result property="pcsStationId" column="pcs_station_id" />
- <result property="pcsStationPid" column="pcs_station_pid" />
- <result property="pcsStationName" column="pcs_station_name" />
- <result property="pcsDeviceId" column="pcs_device_id" />
- <result property="pcsDeviceName" column="pcs_device_name" />
- <result property="brand" column="brand" />
- <result property="model" column="model" />
- <result property="inspectionType" column="inspection_type" />
- <result property="misNo" column="mis_no" />
- <result property="planStartTime" column="plan_start_time" />
- <result property="planEndTime" column="plan_end_time" />
- <result property="orderSource" column="order_source" />
- <result property="assignTime" column="assign_time" />
- <result property="assignUserId" column="assign_user_id" />
- <result property="assignUserName" column="assign_user_name" />
- <result property="acceptTime" column="accept_time" />
- <result property="acceptUserId" column="accept_user_id" />
- <result property="acceptUserName" column="accept_user_name" />
- <result property="realStartTime" column="real_start_time" />
- <result property="realEndTime" column="real_end_time" />
- <result property="teamLeaderId" column="team_leader_id" />
- <result property="teamLeaderName" column="team_leader_name" />
- <result property="workGroupMemberId" column="work_group_member_id" />
- <result property="workGroupMemberName" column="work_group_member_name" />
- <result property="suspendReason" column="suspend_reason" />
- <result property="suspendTime" column="suspend_time" />
- <result property="statusBeforeSuspend" column="status_before_suspend" />
- <result property="rejectionReason" column="rejection_reason" />
- <result property="modifyReason" column="modify_reason" />
- <result property="pauseReason" column="pause_reason" />
- <result property="pauseTime" column="pause_time" />
- <result property="restartTime" column="restart_time" />
- <result property="completeTime" column="complete_time" />
- <result property="planHour" column="plan_hour" />
- <result property="content" column="content" />
- <result property="realContent" column="real_content" />
- <result property="faultCode" column="fault_code" />
- <result property="faultDesc" column="fault_desc" />
- <result property="orderType" column="order_type" />
- <result property="orderEntryType" column="order_entry_type" />
- <result property="priorityType" column="priority_type" />
- <result property="score" column="score" />
- <result property="reviewContent" column="review_content" />
- <result property="issuerName" column="issuer_name" />
- <result property="permitterName" column="permitter_name" />
- <result property="scoringStatus" column="scoring_status" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- <result property="attachmentUrls" column="attachment_urls" />
- <result property="itemCompletionFactor" column="item_completion_factor" />
- <result property="itemCompletionFactorSum" column="item_completion_factor_sum" />
- <result property="reviewScoreNum" column="review_score_num" />
- <result property="finalCoefficient" column="final_coefficient" />
- <result property="isDeferred" column="is_deferred" />
- <result property="invalidReason" column="invalid_reason" />
- <result property="feedbackReason" column="feedback_reason" />
- <result property="confirmStatus" column="confirm_status" />
- <result property="wwryNum" column="wwry_num" />
- <result property="wlryNum" column="wlry_num" />
- <result property="infoEntry" column="info_entry" />
- <result property="lostPower" column="lost_power" />
- <result property="workPermitNum" column="work_permit_num" />
- <result property="finalizeMethod" column="finalize_method" />
- <result property="appealUserId" column="appeal_user_id" />
- <result property="appealUserName" column="appeal_user_name" />
- <result property="appealTime" column="appeal_time" />
- <result property="appealReason" column="appeal_reason" />
- <result property="suspendExplain" column="suspend_explain" />
- <result property="scoreReturnReason" column="score_return_reason" />
- <result property="leader" column="leader" />
- <result property="runningDays" column="running_days" />
- <result property="stopDays" column="stop_days" />
- <result property="deptName" column="dept_name" />
- <result property="userId" column="user_id" />
- </resultMap>
- <resultMap type="GxtOrderData" id="GxtOrderDataResult">
- <result property="startTime" column="startTime" />
- <result property="endTime" column="endTime" />
- <result property="code" column="code" />
- <result property="brand" column="brand" />
- <result property="model" column="model" />
- <result property="system" column="system" />
- <result property="pcs" column="pcs" />
- <result property="center" column="center" />
- <result property="orderType" column="orderType" />
- <result property="repairPerson" column="repairPerson" />
- <result property="chargePerson" column="chargePerson" />
- <result property="score" column="score" />
- <result property="xfsc" column="xfsc" />
- <result property="xysc" column="xysc" />
- <result property="zbsc" column="zbsc" />
- <result property="tjsc" column="tjsc" />
- <result property="qjbwsc" column="qjbwsc" />
- <result property="clsc" column="clsc" />
- <result property="gqsc" column="gqsc" />
- <result property="workOrderNum" column="workOrderNum" />
- <result property="repairOrderNum" column="repairOrderNum" />
- <result property="orderCode" column="order_code" />
- <result property="restartNum" column="restart_num" />
- <result property="devices" column="devices" />
- </resultMap>
- <sql id="selectGxtWorkOrderVo">
- select id, work_order_project_no, work_order_status, gxt_center_id, gxt_center, pcs_station_id, pcs_station_pid, pcs_station_name,
- pcs_device_id, pcs_device_name, e.brand, e.model, inspection_type, mis_no, plan_start_time, plan_end_time, order_source, assign_time,
- assign_user_id, assign_user_name, accept_time, accept_user_id, accept_user_name, real_start_time, real_end_time,
- team_leader_id, team_leader_name, work_group_member_id, work_group_member_name, suspend_reason,
- suspend_time,status_before_suspend, modify_reason, pause_reason, pause_time, restart_time, complete_time, plan_hour,
- content, real_content, fault_code, fault_desc, order_type, priority_type, score, review_content, issuer_name,
- permitter_name, scoring_status, t.create_by, t.create_time, t.update_by, t.update_time, t.remark, t.attachment_urls,
- item_completion_factor, item_completion_factor_sum, review_score_num, final_coefficient, is_deferred, invalid_reason, feedback_reason, confirm_status,
- 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
- from gxt_work_order t
- left join sys_user u on u.user_name = t.create_by
- left join sys_dept d on u.dept_id = d.dept_id
- left join gxt_equipment e on t.pcs_device_name = e.equipment_code and t.pcs_station_name = e.station
- </sql>
- <select id="selectGxtWorkOrderList" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- <where>
- <if test="pcsDeviceName != null and pcsDeviceName != ''"> and pcs_device_name like concat('%', #{pcsDeviceName}, '%')</if>
- <if test="workOrderProjectNo != null and workOrderProjectNo != ''"> and work_order_project_no like concat('%', #{workOrderProjectNo}, '%')</if>
- <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status = #{workOrderStatus}</if>
- <if test="gxtCenter != null and gxtCenter != ''"> and gxt_center = #{gxtCenter}</if>
- <if test="pcsStationName != null and pcsStationName != ''"> and pcs_station_name = #{pcsStationName}</if>
- <if test="orderSource != null and orderSource != ''"> and order_source = #{orderSource}</if>
- <if test="teamLeaderId != null"> and team_leader_id = #{teamLeaderId}</if>
- <if test="workGroupMemberId != null"> and work_group_member_id = #{workGroupMemberId}</if>
- <if test="scoringStatus != null"> and scoring_status = #{scoringStatus}</if>
- <if test="itemCompletionFactor != null"> and item_completion_factor = #{itemCompletionFactor}</if>
- <if test="itemCompletionFactorSum != null"> and item_completion_factor_sum = #{itemCompletionFactorSum}</if>
- <if test="reviewScoreNum != null"> and review_score_num = #{reviewScoreNum}</if>
- <if test="finalCoefficient != null"> and final_coefficient = #{finalCoefficient}</if>
- <if test="misNo != null"> and mis_no = #{misNo}</if>
- <!-- 超时工单条件:realEndTime为空且当前时间超过planEndTime -->
- <if test="params.overdueCondition != null and params.overdueCondition == 'overdue'">
- and real_end_time is null and plan_end_time < NOW()
- </if>
- <!-- 即将超时工单条件:根据配置判断 -->
- <if test="params.overdueCondition != null and params.overdueCondition == 'almostOverdue'">
- and real_end_time is null and plan_end_time > NOW()
- and TIMESTAMPDIFF(HOUR, NOW(), plan_end_time) <= (
- SELECT config_value FROM sys_config WHERE config_key = 'gxt.order.timeout' LIMIT 1
- )
- </if>
- <if test="params.keyword != null and params.keyword != ''">
- and (work_order_project_no like concat('%', #{params.keyword}, '%') or pcs_device_name like concat('%', #{params.keyword}, '%'))
- </if>
- <if test="wwryNum != null"> and wwry_num = #{wwryNum}</if>
- <if test="wlryNum != null"> and wlry_num = #{wlryNum}</if>
- <if test="infoEntry != null and infoEntry != ''"> and info_entry = #{infoEntry}</if>
- <if test="lostPower != null"> and lost_power = #{lostPower}</if>
- <if test="workPermitNum != null and workPermitNum != ''"> and work_permit_num = #{workPermitNum}</if>
- <if test="beginCreateTime != null and beginCreateTime != ''"> and date_format(t.create_time,'%y%m%d') >= date_format(#{beginCreateTime},'%y%m%d')</if>
- <if test="endCreateTime != null and endCreateTime != ''"> and date_format(t.create_time,'%y%m%d') <= date_format(#{endCreateTime},'%y%m%d')</if>
- <!-- 业务特定数据权限过滤条件 -->
- <if test="params.businessDataScope != null and params.businessDataScope != ''">
- ${params.businessDataScope}
- </if>
- <!-- 限制待下发工单只能创建人本部门查看 -->
- <if test="params.currentUser != null and params.currentUser != ''">
- and ((t.work_order_status != 'to_issue' and t.work_order_status != 'accept_return') or t.create_by in
- (select user_name from sys_user t1
- left join sys_dept t2 on t1.dept_id = t2.dept_id
- where t2.dept_id = (select dept_id from sys_user where user_name = #{params.currentUser,jdbcType=VARCHAR} and del_flag='0')))
- </if>
- </where>
- order by create_time desc
- </select>
- <select id="selectGxtWorkOrderListByMonth" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
- SELECT
- t.*
- FROM
- gxt_work_order t
- <if test="userId != null">LEFT JOIN gxt_work_order_person p ON p.order_id = t.id</if>
- <where>
- <if test="userId != null"> and p.user_id=#{userId}</if>
- <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status IN ('completed','archived')</if>
- <if test="model != null and model != ''"> and t.model = #{model}</if>
- <if test="inspectionType != null and inspectionType != ''"> and FIND_IN_SET(#{inspectionType}, inspection_type) > 0</if>
- <if test="pcsStationPid != null"> and pcs_station_pid = #{pcsStationPid}</if>
- <if test="monthPeriod != null"> and DATE_FORMAT(t.create_time, '%Y-%m') = #{monthPeriod}</if>
- <if test="params.businessDataScope != null and params.businessDataScope != ''">
- ${params.businessDataScope}
- </if>
- </where>
- order by t.create_time desc
- </select>
- <select id="selectGxtWorkOrderById" parameterType="Long" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- where id = #{id}
- </select>
- <select id="selectGxtWorkOrderListForAutoFinalize" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- <where>
- <if test="workOrderStatus != null and workOrderStatus != ''"> and work_order_status in
- <foreach collection="workOrderStatus.split(',')" item="status" open="(" close=")" separator=",">
- #{status}
- </foreach>
- </if>
- and accept_time is not null
- and pause_time is not null
- and restart_time is not null
- </where>
- order by create_time desc
- </select>
- <select id="selectGxtWorkOrderByCode" parameterType="String" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- where work_order_project_no = #{workOrderProjectNo}
- limit 1
- </select>
- <insert id="insertGxtWorkOrder" parameterType="GxtWorkOrder" useGeneratedKeys="true" keyProperty="id">
- insert into gxt_work_order
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="workOrderProjectNo != null and workOrderProjectNo != ''">work_order_project_no,</if>
- <if test="workOrderStatus != null and workOrderStatus != ''">work_order_status,</if>
- <if test="gxtCenterId != null">gxt_center_id,</if>
- <if test="gxtCenter != null">gxt_center,</if>
- <if test="pcsStationId != null">pcs_station_id,</if>
- <if test="pcsStationPid != null">pcs_station_pid,</if>
- <if test="pcsStationName != null">pcs_station_name,</if>
- <if test="pcsDeviceId != null">pcs_device_id,</if>
- <if test="pcsDeviceName != null">pcs_device_name,</if>
- <if test="brand != null">brand,</if>
- <if test="model != null">model,</if>
- <if test="inspectionType != null">inspection_type,</if>
- <if test="misNo != null">mis_no,</if>
- <if test="planStartTime != null">plan_start_time,</if>
- <if test="planEndTime != null">plan_end_time,</if>
- <if test="orderSource != null">order_source,</if>
- <if test="assignTime != null">assign_time,</if>
- <if test="assignUserId != null">assign_user_id,</if>
- <if test="assignUserName != null">assign_user_name,</if>
- <if test="acceptTime != null">accept_time,</if>
- <if test="acceptUserId != null">accept_user_id,</if>
- <if test="acceptUserName != null">accept_user_name,</if>
- <if test="realStartTime != null">real_start_time,</if>
- <if test="realEndTime != null">real_end_time,</if>
- <if test="teamLeaderId != null">team_leader_id,</if>
- <if test="teamLeaderName != null">team_leader_name,</if>
- <if test="workGroupMemberId != null">work_group_member_id,</if>
- <if test="workGroupMemberName != null">work_group_member_name,</if>
- <if test="suspendReason != null">suspend_reason,</if>
- <if test="suspendTime != null">suspend_time,</if>
- <if test="statusBeforeSuspend != null">status_before_suspend,</if>
- <if test="modifyReason != null">modify_reason,</if>
- <if test="pauseReason != null">pause_reason,</if>
- <if test="pauseTime != null">pause_time,</if>
- <if test="restartTime != null">restart_time,</if>
- <if test="completeTime != null">complete_time,</if>
- <if test="planHour != null">plan_hour,</if>
- <if test="content != null">content,</if>
- <if test="realContent != null">real_content,</if>
- <if test="faultCode != null">fault_code,</if>
- <if test="faultDesc != null">fault_desc,</if>
- <if test="orderType != null">order_type,</if>
- <if test="priorityType != null">priority_type,</if>
- <if test="score != null">score,</if>
- <if test="reviewContent != null">review_content,</if>
- <if test="issuerName != null">issuer_name,</if>
- <if test="permitterName != null">permitter_name,</if>
- <if test="scoringStatus != null">scoring_status,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- <if test="attachmentUrls != null">attachment_urls,</if>
- <if test="itemCompletionFactor != null">item_completion_factor,</if>
- <if test="itemCompletionFactorSum != null">item_completion_factor_sum,</if>
- <if test="reviewScoreNum != null">review_score_num,</if>
- <if test="finalCoefficient != null">final_coefficient,</if>
- <if test="invalidReason != null and invalidReason != ''">invalid_reason,</if>
- <if test="feedbackReason != null and feedbackReason != ''">feedback_reason,</if>
- <if test="confirmStatus != null">confirm_status,</if>
- <if test="wwryNum != null">wwry_num,</if>
- <if test="wlryNum != null">wlry_num,</if>
- <if test="infoEntry != null and infoEntry != ''">info_entry,</if>
- <if test="lostPower != null">lost_power,</if>
- <if test="workPermitNum != null and workPermitNum != ''">work_permit_num,</if>
- <if test="appealUserId != null">appeal_user_id,</if>
- <if test="appealUserName != null and appealUserName != ''">appeal_user_name,</if>
- <if test="appealTime != null">appeal_time,</if>
- <if test="appealReason != null and appealReason != ''">appeal_reason,</if>
- <if test="suspendExplain != null and suspendExplain != ''">suspend_explain,</if>
- <if test="orderEntryType != null and orderEntryType != ''">order_entry_type,</if>
- <if test="scoreReturnReason != null and scoreReturnReason != ''">score_return_reason,</if>
- <if test="finalizeMethod != null and finalizeMethod != ''">finalize_method,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="workOrderProjectNo != null and workOrderProjectNo != ''">#{workOrderProjectNo},</if>
- <if test="workOrderStatus != null and workOrderStatus != ''">#{workOrderStatus},</if>
- <if test="gxtCenterId != null">#{gxtCenterId},</if>
- <if test="gxtCenter != null">#{gxtCenter},</if>
- <if test="pcsStationId != null">#{pcsStationId},</if>
- <if test="pcsStationPid != null">#{pcsStationPid},</if>
- <if test="pcsStationName != null">#{pcsStationName},</if>
- <if test="pcsDeviceId != null">#{pcsDeviceId},</if>
- <if test="pcsDeviceName != null">#{pcsDeviceName},</if>
- <if test="brand != null">#{brand},</if>
- <if test="model != null">#{model},</if>
- <if test="inspectionType != null">#{inspectionType},</if>
- <if test="misNo != null">#{misNo},</if>
- <if test="planStartTime != null">#{planStartTime},</if>
- <if test="planEndTime != null">#{planEndTime},</if>
- <if test="orderSource != null">#{orderSource},</if>
- <if test="assignTime != null">#{assignTime},</if>
- <if test="assignUserId != null">#{assignUserId},</if>
- <if test="assignUserName != null">#{assignUserName},</if>
- <if test="acceptTime != null">#{acceptTime},</if>
- <if test="acceptUserId != null">#{acceptUserId},</if>
- <if test="acceptUserName != null">#{acceptUserName},</if>
- <if test="realStartTime != null">#{realStartTime},</if>
- <if test="realEndTime != null">#{realEndTime},</if>
- <if test="teamLeaderId != null">#{teamLeaderId},</if>
- <if test="teamLeaderName != null">#{teamLeaderName},</if>
- <if test="workGroupMemberId != null">#{workGroupMemberId},</if>
- <if test="workGroupMemberName != null">#{workGroupMemberName},</if>
- <if test="suspendReason != null">#{suspendReason},</if>
- <if test="suspendTime != null">#{suspendTime},</if>
- <if test="statusBeforeSuspend != null">#{statusBeforeSuspend},</if>
- <if test="modifyReason != null">#{modifyReason},</if>
- <if test="pauseReason != null">#{pauseReason},</if>
- <if test="pauseTime != null">#{pauseTime},</if>
- <if test="restartTime != null">#{restartTime},</if>
- <if test="completeTime != null">#{completeTime},</if>
- <if test="planHour != null">#{planHour},</if>
- <if test="content != null">#{content},</if>
- <if test="realContent != null">#{realContent},</if>
- <if test="faultCode != null">#{faultCode},</if>
- <if test="faultDesc != null">#{faultDesc},</if>
- <if test="orderType != null">#{orderType},</if>
- <if test="priorityType != null">#{priorityType},</if>
- <if test="score != null">#{score},</if>
- <if test="reviewContent != null">#{reviewContent},</if>
- <if test="issuerName != null">#{issuerName},</if>
- <if test="permitterName != null">#{permitterName},</if>
- <if test="scoringStatus != null">#{scoringStatus},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="attachmentUrls != null">#{attachmentUrls},</if>
- <if test="itemCompletionFactor != null">#{itemCompletionFactor},</if>
- <if test="itemCompletionFactorSum != null">#{itemCompletionFactorSum},</if>
- <if test="reviewScoreNum != null">#{reviewScoreNum},</if>
- <if test="finalCoefficient != null">#{finalCoefficient},</if>
- <if test="invalidReason != null and invalidReason != ''">#{invalidReason},</if>
- <if test="feedbackReason != null and feedbackReason != ''">#{feedbackReason},</if>
- <if test="confirmStatus != null">#{confirmStatus},</if>
- <if test="wwryNum != null">#{wwryNum},</if>
- <if test="wlryNum != null">#{wlryNum},</if>
- <if test="infoEntry != null and infoEntry != ''">#{infoEntry},</if>
- <if test="lostPower != null">#{lostPower},</if>
- <if test="workPermitNum != null and workPermitNum != ''">#{workPermitNum},</if>
- <if test="appealUserId != null">#{appealUserId},</if>
- <if test="appealUserName != null and appealUserName != ''">#{appealUserName},</if>
- <if test="appealTime != null">#{appealTime},</if>
- <if test="appealReason != null and appealReason != ''">#{appealReason},</if>
- <if test="suspendExplain != null and suspendExplain != ''">#{suspendExplain},</if>
- <if test="orderEntryType != null and orderEntryType != ''">#{orderEntryType},</if>
- <if test="scoreReturnReason != null and scoreReturnReason != ''">#{scoreReturnReason},</if>
- <if test="finalizeMethod != null and finalizeMethod != ''">#{finalizeMethod},</if>
- </trim>
- </insert>
- <update id="updateGxtWorkOrderByStatus" parameterType="GxtWorkOrder">
- update gxt_work_order
- SET is_deferred = #{isDeferred}
- <where>
- <if test="itemCompletionFactorSum != null"> AND #{itemCompletionFactorSum} > item_completion_factor_sum</if>
- <if test="workOrderStatus != null and workOrderStatus != ''"> AND work_order_status = #{workOrderStatus}</if>
- <if test="realEndTime != null"> AND #{realEndTime} > create_time</if>
- </where>
- </update>
- <update id="updateGxtWorkOrderByDeferred" parameterType="GxtWorkOrder">
- update gxt_work_order
- SET is_deferred = null
- <where>
- <if test="itemCompletionFactorSum != null"> AND item_completion_factor_sum = #{itemCompletionFactorSum}</if>
- <if test="workOrderStatus != null and workOrderStatus != ''"> AND work_order_status = #{workOrderStatus}</if>
- <if test="realEndTime != null"> AND #{realEndTime} > create_time</if>
- </where>
- </update>
- <update id="updateGxtWorkOrder" parameterType="GxtWorkOrder">
- update gxt_work_order
- <trim prefix="SET" suffixOverrides=",">
- <if test="workOrderProjectNo != null and workOrderProjectNo != ''">work_order_project_no = #{workOrderProjectNo},</if>
- <if test="workOrderStatus != null and workOrderStatus != ''">work_order_status = #{workOrderStatus},</if>
- <if test="gxtCenterId != null">gxt_center_id = #{gxtCenterId},</if>
- <if test="gxtCenter != null">gxt_center = #{gxtCenter},</if>
- <if test="pcsStationId != null">pcs_station_id = #{pcsStationId},</if>
- <if test="pcsStationPid != null">pcs_station_pid = #{pcsStationPid},</if>
- <if test="pcsStationName != null">pcs_station_name = #{pcsStationName},</if>
- <if test="pcsDeviceId != null">pcs_device_id = #{pcsDeviceId},</if>
- <if test="pcsDeviceName != null">pcs_device_name = #{pcsDeviceName},</if>
- <if test="brand != null">brand = #{brand},</if>
- <if test="model != null">model = #{model},</if>
- <if test="inspectionType != null">inspection_type = #{inspectionType},</if>
- <if test="misNo != null">mis_no = #{misNo},</if>
- <if test="planStartTime != null">plan_start_time = #{planStartTime},</if>
- <if test="planEndTime != null">plan_end_time = #{planEndTime},</if>
- <if test="orderSource != null">order_source = #{orderSource},</if>
- <if test="assignTime != null">assign_time = #{assignTime},</if>
- <if test="assignUserId != null">assign_user_id = #{assignUserId},</if>
- <if test="assignUserName != null">assign_user_name = #{assignUserName},</if>
- <if test="acceptTime != null">accept_time = #{acceptTime},</if>
- <if test="acceptUserId != null">accept_user_id = #{acceptUserId},</if>
- <if test="acceptUserName != null">accept_user_name = #{acceptUserName},</if>
- <if test="realStartTime != null">real_start_time = #{realStartTime},</if>
- <if test="realEndTime != null">real_end_time = #{realEndTime},</if>
- <if test="teamLeaderId != null">team_leader_id = #{teamLeaderId},</if>
- <if test="teamLeaderName != null">team_leader_name = #{teamLeaderName},</if>
- <if test="workGroupMemberId != null">work_group_member_id = #{workGroupMemberId},</if>
- <if test="workGroupMemberName != null">work_group_member_name = #{workGroupMemberName},</if>
- <if test="suspendReason != null">suspend_reason = #{suspendReason},</if>
- <if test="suspendTime != null">suspend_time = #{suspendTime},</if>
- <if test="statusBeforeSuspend != null">status_before_suspend = #{statusBeforeSuspend},</if>
- <if test="modifyReason != null">modify_reason = #{modifyReason},</if>
- <if test="pauseReason != null">pause_reason = #{pauseReason},</if>
- <if test="pauseTime != null">pause_time = #{pauseTime},</if>
- <if test="restartTime != null">restart_time = #{restartTime},</if>
- <if test="completeTime != null">complete_time = #{completeTime},</if>
- <if test="planHour != null">plan_hour = #{planHour},</if>
- <if test="content != null">content = #{content},</if>
- <if test="realContent != null">real_content = #{realContent},</if>
- <if test="faultCode != null">fault_code = #{faultCode},</if>
- <if test="faultDesc != null">fault_desc = #{faultDesc},</if>
- <if test="orderType != null">order_type = #{orderType},</if>
- <if test="priorityType != null">priority_type = #{priorityType},</if>
- <if test="score != null">score = #{score},</if>
- <if test="reviewContent != null">review_content = #{reviewContent},</if>
- <if test="issuerName != null">issuer_name = #{issuerName},</if>
- <if test="permitterName != null">permitter_name = #{permitterName},</if>
- <if test="scoringStatus != null">scoring_status = #{scoringStatus},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="attachmentUrls != null">attachment_urls = #{attachmentUrls},</if>
- <if test="itemCompletionFactor != null">item_completion_factor = #{itemCompletionFactor},</if>
- <if test="itemCompletionFactorSum != null">item_completion_factor_sum = #{itemCompletionFactorSum},</if>
- <if test="reviewScoreNum != null">review_score_num = #{reviewScoreNum},</if>
- <if test="finalCoefficient != null">final_coefficient = #{finalCoefficient},</if>
- <if test="invalidReason != null and invalidReason != ''">invalid_reason = #{invalidReason},</if>
- <if test="feedbackReason != null and feedbackReason != ''">feedback_reason = #{feedbackReason},</if>
- <if test="confirmStatus != null">confirm_status = #{confirmStatus},</if>
- <if test="wwryNum != null">wwry_num = #{wwryNum},</if>
- <if test="wlryNum != null">wlry_num = #{wlryNum},</if>
- <if test="infoEntry != null and infoEntry != ''">info_entry = #{infoEntry},</if>
- <if test="lostPower != null">lost_power = #{lostPower},</if>
- <if test="workPermitNum != null and workPermitNum != ''">work_permit_num = #{workPermitNum},</if>
- <if test="appealUserId != null">appeal_user_id = #{appealUserId},</if>
- <if test="appealUserName != null and appealUserName != ''">appeal_user_name = #{appealUserName},</if>
- <if test="appealTime != null">appeal_time = #{appealTime},</if>
- <if test="appealReason != null and appealReason != ''">appeal_reason = #{appealReason},</if>
- <if test="suspendExplain != null and suspendExplain != ''">suspend_explain = #{suspendExplain},</if>
- <if test="orderEntryType != null and orderEntryType != ''">order_entry_type = #{orderEntryType},</if>
- <if test="scoreReturnReason != null and scoreReturnReason != ''">score_return_reason = #{scoreReturnReason},</if>
- <if test="finalizeMethod != null and finalizeMethod != ''">finalize_method = #{finalizeMethod},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteGxtWorkOrderById" parameterType="Long">
- delete from gxt_work_order where id = #{id}
- </delete>
- <delete id="deleteGxtWorkOrderByIds" parameterType="String">
- delete from gxt_work_order where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <!-- 查询会超时的工单(待归档且超时3天) -->
- <select id="selectExpiredWorkOrders" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- where work_order_status = #{status}
- and t.update_time < #{thresholdDate}
- order by t.update_time asc
- </select>
- <!-- 根据MIS系统编号查询维保工单 -->
- <select id="selectGxtWorkOrderByMisNo" parameterType="String" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- where mis_no = #{misNo}
- limit 1
- </select>
- <resultMap type="GxtWorkOrder" id="GxtWorkOrderWithPersonResult" extends="GxtWorkOrderResult">
- <collection property="workOrderPersonList" ofType="com.ygtx.gxt.domain.GxtWorkOrderPerson">
- <result property="id" column="person_id"/>
- <result property="userId" column="person_user_id"/>
- <result property="nickName" column="person_nick_name"/>
- <result property="orderId" column="person_order_id"/>
- <result property="orderCode" column="person_order_code"/>
- <result property="status" column="person_status"/>
- <result property="misNo" column="person_mis_no"/>
- <result property="userName" column="person_user_name"/>
- <result property="selfScore" column="person_self_score"/>
- <result property="reviewScore" column="person_review_score"/>
- <result property="finalScore" column="person_final_score"/>
- <result property="isLeader" column="person_is_leader"/>
- </collection>
- </resultMap>
- <select id="selectWorkOrderWithPersonById" parameterType="Long" resultMap="GxtWorkOrderWithPersonResult">
- SELECT
- t1.id,
- t1.work_order_project_no,
- t1.work_order_status,
- t1.gxt_center_id,
- t1.gxt_center,
- t1.pcs_station_id,
- t1.pcs_station_name,
- t1.pcs_device_id,
- t1.pcs_device_name,
- t1.brand,
- t1.model,
- t1.inspection_type,
- t1.mis_no,
- t1.plan_start_time,
- t1.plan_end_time,
- t1.order_source,
- t1.assign_time,
- t1.assign_user_id,
- t1.assign_user_name,
- t1.accept_time,
- t1.accept_user_id,
- t1.accept_user_name,
- t1.real_start_time,
- t1.real_end_time,
- t1.team_leader_id,
- t1.team_leader_name,
- t1.work_group_member_id,
- t1.work_group_member_name,
- t1.suspend_reason,
- t1.suspend_time,
- t1.status_before_suspend,
- t1.modify_reason,
- t1.pause_reason,
- t1.pause_time,
- t1.restart_time,
- t1.complete_time,
- t1.plan_hour,
- t1.content,
- t1.real_content,
- t1.fault_code,
- t1.fault_desc,
- t1.order_type,
- t1.priority_type,
- t1.score,
- t1.review_content,
- t1.issuer_name,
- t1.permitter_name,
- t1.scoring_status,
- t1.attachment_urls,
- t1.attachment_file_names,
- t1.attachment_original_names,
- t1.review_score_num,
- t1.final_coefficient,
- t1.create_by,
- t1.create_time,
- t1.update_by,
- t1.update_time,
- t1.remark,
- t1.work_permit_num,
- t1.appeal_user_id,
- t1.appeal_user_name,
- t1.appeal_time,
- t1.appeal_reason,
- t2.id as person_id,
- t2.user_id as person_user_id,
- t2.nick_name as person_nick_name,
- t2.order_id as person_order_id,
- t2.order_code as person_order_code,
- t2.status as person_status,
- t2.mis_no as person_mis_no,
- t2.user_name as person_user_name,
- t2.self_score as person_self_score,
- t2.review_score as person_review_score,
- t2.final_score as person_final_score,
- t2.is_leader as person_is_leader
- FROM gxt_work_order t1
- LEFT JOIN gxt_work_order_person t2 ON t1.id = t2.order_id
- WHERE t1.id = #{id}
- </select>
- <select id="selectHomePageWorkOrderList" parameterType="GxtOrderData" resultMap="GxtOrderDataResult">
- <trim prefix="SELECT" suffixOverrides=",">
- <choose>
- <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)">
- o.work_order_project_no AS order_code,
- <if test="workOrderNum != null and workOrderNum == 1">
- CASE
- WHEN o.orderType='维保工单' THEN 1
- ELSE NULL
- END AS workOrderNum,
- </if>
- <if test="repairOrderNum != null and repairOrderNum == 1">
- CASE
- WHEN o.orderType='维修工单' THEN 1-o.restart_flag
- ELSE NULL
- END AS repairOrderNum,
- </if>
- <if test="restartNum != null and restartNum == 1">
- o.restart_flag AS restart_num,
- </if>
- </when>
- <otherwise>
- <if test="workOrderNum != null and workOrderNum == 1">
- CASE
- WHEN o.orderType='维保工单' THEN COUNT(*)
- ELSE NULL
- END AS workOrderNum,
- </if>
- <if test="repairOrderNum != null and repairOrderNum == 1">
- CASE
- WHEN o.orderType='维修工单' THEN COUNT(*)-SUM(o.restart_flag)
- ELSE NULL
- END AS repairOrderNum,
- </if>
- <if test="restartNum != null and restartNum == 1">
- SUM(o.restart_flag) AS restart_num,
- </if>
- </otherwise>
- </choose>
- <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
- <if test="code != null and code == 'true'">o.`code`,</if>
- <if test="brand != null and brand == 'true'">o.brand,</if>
- <if test="model != null and model == 'true'">o.model,</if>
- <if test="system != null and system == 'true'">o.`system`,</if>
- <if test="pcs != null and pcs == 'true'">o.pcs,</if>
- <if test="center != null and center == 'true'">IFNULL(o.center,'未知中心') AS center,</if>
- <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
- <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
- <if test="score != null and score == 1">o.score,</if>
- <if test="xfsc != null and xfsc == 'true'">o.xfsc,</if>
- <if test="xysc != null and xysc == 'true'">o.xysc,</if>
- <if test="zbsc != null and zbsc == 'true'">
- CASE
- WHEN o.zbsc IS NULL THEN NULL
- WHEN o.zbsc <![CDATA[<]]> 0 THEN 0
- ELSE o.zbsc
- END AS zbsc,</if>
- <if test="tjsc != null and tjsc == 'true'">o.tjsc,</if>
- <if test="qjbwsc != null and qjbwsc == 'true'">o.qjbwsc,</if>
- <if test="clsc != null and clsc == 'true'">o.clsc,</if>
- <if test="gqsc != null and gqsc == 'true'">o.gqsc,</if>
- </trim>
- FROM (
- SELECT
- wo.work_order_project_no,
- wo.create_time,
- wo.pcs_device_name AS `code`,
- wo.pcs_station_name AS pcs,
- wo.brand,
- wo.model,
- IF(wo.repair_method='2', 1, null) AS restart_flag,
- wo.mis_no AS `system`,
- wo.gxt_center AS center,
- '维保工单' AS orderType,
- wo.team_leader_name AS chargePerson,
- <if test="repairPerson != null and repairPerson == 'true'">wop.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
- <if test="repairPerson == null or repairPerson == '' or repairPerson == 'false'">ROUND(wo.score,2) AS score,</if>
- ROUND(TIMESTAMPDIFF( SECOND, wo.create_time, wo.assign_time ) / 3600,2) AS xfsc,
- ROUND(TIMESTAMPDIFF( SECOND, wo.assign_time, wo.accept_time ) / 3600,2) AS xysc,
- ROUND((TIMESTAMPDIFF( SECOND, wo.accept_time, wo.real_start_time ) - IFNULL(gq.total_before_start_suspend_seconds, 0)) / 3600,2) AS zbsc,
- ROUND(TIMESTAMPDIFF( SECOND, COALESCE ( wo.pause_time, wo.real_start_time ), wo.restart_time ) / 3600,2) AS tjsc,
- ROUND(TIMESTAMPDIFF( SECOND, wo.real_end_time, wo.restart_time ) / 3600,2) AS qjbwsc,
- ROUND(( TIMESTAMPDIFF( SECOND, wo.real_start_time, wo.real_end_time ) - IFNULL(gq.total_in_work_suspend_seconds, 0)) / 3600,2) AS clsc,
- 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
- FROM
- gxt_work_order wo
- <if test="repairPerson != null and repairPerson == 'true'">
- LEFT JOIN gxt_work_order_person wop ON wo.id = wop.order_id
- </if>
- LEFT JOIN gxt_work_order_flow_records_next gq ON gq.order_id = wo.id
- 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
- 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
- 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
- <where>
- <if test="startTime != null ">
- <choose>
- <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')">
- AND gsflow.finish_time > #{startTime}
- </when>
- <when test="score != null and score == 1">
- AND gfflow.score_time > #{startTime}
- </when>
- <otherwise>
- AND wo.create_time > #{startTime}
- </otherwise>
- </choose>
- </if>
- <if test="endTime != null ">
- <choose>
- <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')">
- AND gsflow.finish_time <![CDATA[<]]> #{endTime}
- </when>
- <when test="score != null and score == 1">
- AND gfflow.score_time <![CDATA[<]]> #{endTime}
- </when>
- <otherwise>
- AND wo.create_time <![CDATA[<]]> #{endTime}
- </otherwise>
- </choose>
- </if>
- <if test="pcsId != null "> AND wo.pcs_station_pid = #{pcsId}</if>
- <if test="centerId != null "> AND wo.gxt_center_id = #{centerId}</if>
- <if test="remark != null and remark != '' ">
- AND (
- wo.work_order_project_no LIKE concat('%', #{remark}, '%')
- OR wo.pcs_device_name LIKE concat('%', #{remark}, '%')
- OR wo.brand LIKE concat('%', #{remark}, '%')
- OR wo.model LIKE concat('%', #{remark}, '%')
- OR wo.gxt_center LIKE concat('%', #{remark}, '%')
- OR wo.pcs_station_name LIKE concat('%', #{remark}, '%')
- OR wo.team_leader_name LIKE concat('%', #{remark}, '%')
- )
- </if>
- <if test="devices != null and devices != ''">
- AND wo.pcs_device_id IN
- <foreach item="item" collection="devices.split(',')" open="(" separator="," close=")">
- #{item, jdbcType=BIGINT} <!-- 指定 Long 类型 -->
- </foreach>
- </if>
- <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
- <choose>
- <when test="score != null and score == 1">
- AND wo.work_order_status IN ('archived')
- </when>
- <otherwise>
- AND wo.work_order_status IN ('completed','archived')
- </otherwise>
- </choose>
- AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL
- </where>
- UNION ALL
- SELECT
- wo.work_order_project_no,
- wo.occur_time AS create_time,
- wo.pcs_device_name AS `code`,
- wo.pcs_station_name AS pcs,
- wo.brand,
- wo.model,
- IF(wo.repair_method='2', 1, 0) AS restart_flag,
- NULL AS `system`,
- wo.gxt_center AS center,
- '维修工单' AS orderType,
- wo.team_leader_name AS chargePerson,
- <if test="repairPerson != null and repairPerson == 'true'">wop.nick_name AS repairPerson,ROUND(wop.score,2) AS score,</if>
- <if test="repairPerson == null or repairPerson == '' or repairPerson == 'false'">ROUND(wo.score,2) AS score,</if>
- ROUND(TIMESTAMPDIFF( SECOND, wo.occur_time, wo.assign_time ) / 3600,2) AS xfsc,
- ROUND(( TIMESTAMPDIFF( SECOND, wo.assign_time, wo.accept_time ) - IFNULL(gq.total_night_auto_suspend_seconds, 0))/ 3600,2) AS xysc,
- ROUND((TIMESTAMPDIFF( SECOND, wo.accept_time, wo.real_start_time ) - IFNULL(gq.total_before_start_suspend_seconds, 0)) / 3600,2) AS zbsc,
- ROUND(TIMESTAMPDIFF( SECOND, wo.occur_time, wo.restart_time ) / 3600,2) AS tjsc,
- ROUND(TIMESTAMPDIFF( SECOND, wo.real_end_time, wo.restart_time ) / 3600,2) AS qjbwsc,
- ROUND((TIMESTAMPDIFF( SECOND, wo.real_start_time, wo.real_end_time ) - IFNULL(gq.total_in_work_suspend_seconds, 0)) / 3600,2) AS clsc,
- 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
- FROM
- gxt_repair_order wo
- <if test="repairPerson != null and repairPerson == 'true'">
- LEFT JOIN gxt_repair_order_person wop ON wo.id = wop.order_id
- </if>
- LEFT JOIN gxt_repair_order_flow_records_next gq ON gq.order_id = wo.id
- 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
- 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
- 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
- <where>
- <if test="startTime != null ">
- <choose>
- <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')">
- AND gsflow.finish_time > #{startTime}
- </when>
- <when test="score != null and score == 1">
- AND gfflow.score_time > #{startTime}
- </when>
- <otherwise>
- AND wo.occur_time > #{startTime}
- </otherwise>
- </choose>
- </if>
- <if test="endTime != null ">
- <choose>
- <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')">
- AND gsflow.finish_time <![CDATA[<]]> #{endTime}
- </when>
- <when test="score != null and score == 1">
- AND gfflow.score_time <![CDATA[<]]> #{endTime}
- </when>
- <otherwise>
- AND wo.occur_time <![CDATA[<]]> #{endTime}
- </otherwise>
- </choose>
- </if>
- <if test="repairOrderNum != null and repairOrderNum == 1 and (restartNum == null or restartNum != 1)">
- AND wo.repair_method!='2'
- </if>
- <if test="restartNum != null and restartNum == 1 and (repairOrderNum == null or repairOrderNum != 1)">
- AND wo.repair_method='2'
- </if>
- <if test="pcsId != null "> AND wo.pcs_station_pid = #{pcsId}</if>
- <if test="centerId != null "> AND wo.gxt_center_id = #{centerId}</if>
- <if test="remark != null and remark != '' ">
- AND (
- wo.work_order_project_no LIKE concat('%', #{remark}, '%')
- OR wo.pcs_device_name LIKE concat('%', #{remark}, '%')
- OR wo.brand LIKE concat('%', #{remark}, '%')
- OR wo.model LIKE concat('%', #{remark}, '%')
- OR wo.gxt_center LIKE concat('%', #{remark}, '%')
- OR wo.pcs_station_name LIKE concat('%', #{remark}, '%')
- OR wo.team_leader_name LIKE concat('%', #{remark}, '%')
- )
- </if>
- <if test="devices != null and devices != ''">
- AND wo.pcs_device_id IN
- <foreach item="item" collection="devices.split(',')" open="(" separator="," close=")">
- #{item, jdbcType=BIGINT} <!-- 指定 Long 类型 -->
- </foreach>
- </if>
- <if test="dataPermission != null and dataPermission != ''">${dataPermission}</if>
- <choose>
- <when test="score != null and score == 1">
- AND wo.work_order_status IN ('archived')
- </when>
- <otherwise>
- AND wo.work_order_status IN ('completed','archived')
- </otherwise>
- </choose>
- AND wopp.wop_num>0 AND wo.work_order_status IS NOT NULL
- </where>
- ) o
- <where>
- <if test="orderType != null and orderType != ''"> AND o.orderType=#{orderType}</if>
- <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)">
- AND (o.restart_flag IS NULL OR o.restart_flag = 0 )
- </if>
- </where>
- <choose>
- <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)">
- <trim prefix="ORDER BY" suffixOverrides=",">
- <if test="center != null and center == 'true'">o.center,</if>
- <if test="pcs != null and pcs == 'true'">o.pcs,</if>
- <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
- o.work_order_project_no,
- <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
- <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
- <if test="brand != null and brand == 'true'">o.brand,</if>
- <if test="model != null and model == 'true'">o.model,</if>
- <if test="system != null and system == 'true'">o.`system`,</if>
- <if test="code != null and code == 'true'">o.`code`,</if>
- </trim>
- </when>
- <otherwise>
- <trim prefix="GROUP BY" suffixOverrides=",">
- <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
- <if test="code != null and code == 'true'">o.`code`,</if>
- <if test="brand != null and brand == 'true'">o.brand,</if>
- <if test="model != null and model == 'true'">o.model,</if>
- <if test="system != null and system == 'true'">o.`system`,</if>
- <if test="pcs != null and pcs == 'true'">o.pcs,</if>
- <if test="center != null and center == 'true'">o.center,</if>
- <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
- <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
- <if test="score != null and score == 1">o.score,</if>
- <if test="xfsc != null and xfsc == 'true'">o.xfsc,</if>
- <if test="xysc != null and xysc == 'true'">o.xysc,</if>
- <if test="zbsc != null and zbsc == 'true'">o.zbsc,</if>
- <if test="tjsc != null and tjsc == 'true'">o.tjsc,</if>
- <if test="qjbwsc != null and qjbwsc == 'true'">o.qjbwsc,</if>
- <if test="clsc != null and clsc == 'true'">o.clsc,</if>
- <if test="gqsc != null and gqsc == 'true'">o.gqsc,</if>
- </trim>
- <trim prefix="ORDER BY" suffixOverrides=",">
- <if test="center != null and center == 'true'">o.center,</if>
- <if test="pcs != null and pcs == 'true'">o.pcs,</if>
- <if test="chargePerson != null and chargePerson == 'true'">o.chargePerson,</if>
- <if test="(workOrder != null and workOrder == true) or (repairOrder != null and repairOrder==true)">o.orderType,</if>
- <if test="repairPerson != null and repairPerson == 'true'">o.repairPerson,</if>
- <if test="brand != null and brand == 'true'">o.brand,</if>
- <if test="model != null and model == 'true'">o.model,</if>
- <if test="system != null and system == 'true'">o.`system`,</if>
- <if test="code != null and code == 'true'">o.`code`,</if>
- <if test="score != null and score == 1">o.score,</if>
- <if test="xfsc != null and xfsc == 'true'">o.xfsc,</if>
- <if test="xysc != null and xysc == 'true'">o.xysc,</if>
- <if test="zbsc != null and zbsc == 'true'">o.zbsc,</if>
- <if test="tjsc != null and tjsc == 'true'">o.tjsc,</if>
- <if test="qjbwsc != null and qjbwsc == 'true'">o.qjbwsc,</if>
- <if test="clsc != null and clsc == 'true'">o.clsc,</if>
- <if test="gqsc != null and gqsc == 'true'">o.gqsc,</if>
- </trim>
- </otherwise>
- </choose>
- </select>
- <select id="selectLatestGxtWorkOrderByDeviceId" parameterType="map" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- <where>
- <if test="pcsDeviceId != null"> and pcs_device_id = #{pcsDeviceId}</if>
- <if test="limit != null and limit > 0">
- ORDER BY create_time DESC LIMIT #{limit}
- </if>
- </where>
- </select>
-
- <select id="selectGxtWorkOrderByDeviceIdWithCondition" parameterType="map" resultMap="GxtWorkOrderResult">
- <include refid="selectGxtWorkOrderVo"/>
- <where>
- <if test="pcsDeviceId != null"> and pcs_device_id = #{pcsDeviceId}</if>
- <if test="workOrderStatus != null and workOrderStatus != ''">
- <if test="excludeStatus">
- and work_order_status != #{workOrderStatus}
- </if>
- <if test="!excludeStatus">
- and work_order_status = #{workOrderStatus}
- </if>
- </if>
- </where>
- <choose>
- <when test="orderByField != null and orderByField == 'pauseTime'">
- ORDER BY pause_time DESC
- </when>
- <when test="orderByField != null and orderByField == 'restartTime'">
- ORDER BY restart_time DESC
- </when>
- <otherwise>
- ORDER BY create_time DESC
- </otherwise>
- </choose>
- <if test="limit != null and limit > 0">
- LIMIT #{limit}
- </if>
- </select>
-
- <select id="selectGxtWorkOrderRunningDaysInfo" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
- SELECT
- t.pcs_device_name,
- t.model,
- t.work_order_project_no,
- t.restart_time,
- COALESCE ( t.pause_time, t.real_start_time ) AS pause_time,
- t.pcs_station_pid,
- 1 AS order_type,
- t.pcs_device_id,t.gxt_center_id,t.gxt_center,t.pcs_station_id,t.pcs_station_name,d.dept_name,
- DATEDIFF( t.restart_time, COALESCE ( t.pause_time, t.real_start_time ) ) AS stop_days,
- DATEDIFF( NOW(), DATE(t.restart_time) + INTERVAL 1 DAY ) AS running_days
- FROM
- gxt_work_order t
- INNER JOIN (
- SELECT
- pcs_device_id,
- MAX( COALESCE ( pause_time, real_start_time )) AS latest_time,
- MAX( CASE WHEN pause_time IS NOT NULL THEN 1 ELSE 0 END ) AS is_pause_time
- FROM
- gxt_work_order
- WHERE
- ( pause_time IS NOT NULL OR real_start_time IS NOT NULL )
- AND restart_time IS NOT NULL
- GROUP BY
- pcs_device_id
- ) latest ON t.pcs_device_id = latest.pcs_device_id
- AND ( ( latest.is_pause_time = 1 AND t.pause_time = latest.latest_time )
- OR
- ( latest.is_pause_time = 0 AND t.pause_time IS NULL AND t.real_start_time = latest.latest_time ) )
- LEFT JOIN sys_dept d ON d.dept_id=t.pcs_station_pid
- WHERE
- latest.pcs_device_id IS NOT NULL AND t.work_order_status IN ('completed','archived')
- AND t.restart_time IS NOT NULL
- <if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
- <if test="pcsStationName != null and pcsStationName != ''"> and t.pcs_station_name like concat('%', #{pcsStationName}, '%')</if>
- <if test="pcsStationId != null"> and t.pcs_station_id = #{pcsStationId}</if>
- <if test="pcsStationPid != null"> and t.pcs_station_pid = #{pcsStationPid}</if>
- <if test="params.businessDataScope != null and params.businessDataScope != ''">
- ${params.businessDataScope}
- </if>
- </select>
- <select id="selectGxtRepairOrderRunningDaysInfo" parameterType="GxtWorkOrder" resultMap="GxtWorkOrderResult">
- SELECT
- t.pcs_device_name,
- t.model,
- t.work_order_project_no,
- t.restart_time,
- t.pcs_station_pid,
- t.occur_time AS pause_time,
- 2 AS order_type,
- t.pcs_device_id,t.gxt_center_id,t.gxt_center,t.pcs_station_id,t.pcs_station_name,d.dept_name,
- DATEDIFF( t.restart_time, t.occur_time ) AS stop_days,
- DATEDIFF( NOW(), DATE(t.restart_time) + INTERVAL 1 DAY ) AS running_days
- FROM
- gxt_repair_order t
- INNER JOIN (
- SELECT
- pcs_device_id,
- MAX( occur_time ) AS latest_pause_time
- FROM
- gxt_repair_order
- WHERE
- occur_time IS NOT NULL AND restart_time IS NOT NULL
- GROUP BY
- pcs_device_id
- ) latest ON t.pcs_device_id = latest.pcs_device_id
- AND t.occur_time = latest.latest_pause_time
- LEFT JOIN sys_dept d ON d.dept_id=t.pcs_station_pid
- WHERE
- t.occur_time IS NOT NULL AND t.work_order_status IN ('completed','archived')
- AND t.restart_time IS NOT NULL
- <if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
- <if test="pcsStationName != null and pcsStationName != ''"> and t.pcs_station_name like concat('%', #{pcsStationName}, '%')</if>
- <if test="pcsStationId != null"> and t.pcs_station_id = #{pcsStationId}</if>
- <if test="pcsStationPid != null"> and t.pcs_station_pid = #{pcsStationPid}</if>
- <if test="params.businessDataScope != null and params.businessDataScope != ''">
- ${params.businessDataScope}
- </if>
- </select>
- <select id="selectGxtWorkOrderListForDeduction" resultMap="GxtWorkOrderResult">
- SELECT DISTINCT t.*
- FROM gxt_work_order t
- LEFT JOIN gxt_order_score_detail osd ON t.id = osd.order_id AND osd.order_type = 2 AND osd.score_type = 3
- WHERE t.work_order_status = 'archived'
- AND osd.order_id IS NULL
- </select>
- </mapper>
|