| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- <?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.GxtOrderPersonMapper">
-
- <resultMap type="com.ygtx.gxt.domain.GxtOrderPerson" id="GxtOrderPersonResult">
- <result property="userId" column="user_id"/>
- <result property="nickName" column="nick_name"/>
- <result property="orderCode" column="order_code"/>
- <result property="center" column="center"/>
- <result property="parent" column="parent"/>
- <result property="pcs" column="pcs"/>
- <result property="orderType" column="order_type"/>
- <result property="scoreType" column="score_type"/>
- <result property="finishDate" column="finish_date"/>
- <result property="score" column="score"/>
- </resultMap>
-
- <select id="selectGxtOrderPersonList" parameterType="GxtOrderPerson" resultMap="GxtOrderPersonResult">
- SELECT po.*,DATE( po.real_end_time ) AS finish_date FROM (
- SELECT
- o.work_order_project_no AS order_code,
- o.gxt_center AS center,
- d.dept_name AS parent,
- o.pcs_station_name AS pcs,
- '维修工单' AS order_type,
- o.real_end_time,
- p.score,p.user_id
- FROM
- gxt_repair_order_person p
- LEFT JOIN gxt_repair_order o ON p.order_id = o.id
- LEFT JOIN sys_dept d ON o.pcs_station_pid = d.dept_id
- WHERE
- o.occur_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01 00:00:00' )
- AND o.real_end_time <![CDATA[<]]> DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01 00:00:00' )
- AND p.score IS NOT NULL AND o.scoring_status IN ('to_archive','archived')
- UNION ALL
- SELECT
- o.work_order_project_no AS order_code,
- o.gxt_center AS center,
- d.dept_name AS parent,
- o.pcs_station_name AS pcs,
- '维保工单' AS order_type,
- o.real_end_time,
- p.score,p.user_id
- FROM
- gxt_work_order_person p
- LEFT JOIN gxt_work_order o ON p.order_id = o.id
- LEFT JOIN sys_dept d ON o.pcs_station_pid = d.dept_id
- WHERE
- o.create_time >= DATE_FORMAT( CURDATE(), '%Y-%m-01 00:00:00' )
- AND o.real_end_time <![CDATA[<]]> DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01 00:00:00' )
- AND p.score IS NOT NULL AND o.scoring_status IN ('to_archive','archived')
- ) po
- WHERE 1=1
- <if test="userId != null">
- AND po.user_id = #{userId}
- </if>
- <if test="orderCode != null and orderCode != ''">
- AND po.order_code LIKE CONCAT( '%', #{orderCode}, '%' )
- </if>
- ORDER BY po.real_end_time DESC
- </select>
- <select id="selectGxtScoreDetailList" parameterType="GxtOrderPerson" resultMap="GxtOrderPersonResult">
- SELECT
- u.nick_name,
- CASE WHEN t.order_type=1 THEN ro.work_order_project_no ELSE wo.work_order_project_no END AS order_code,
- CASE WHEN t.order_type=1 THEN ro.gxt_center ELSE wo.gxt_center END AS center,
- d.dept_name AS parent,DATE( t.create_time ) AS finish_date,t.user_id,
- CASE WHEN t.order_type=1 THEN ro.pcs_station_name ELSE wo.pcs_station_name END AS pcs,
- CASE WHEN t.order_type=1 THEN '维修工单' ELSE '维保工单' END AS order_type,
- CASE WHEN t.score_type=1 THEN '工单得分' WHEN t.score_type=2 THEN '运行得分' ELSE '停机扣分' END AS score_type,t.score
- FROM gxt_order_score_detail t
- LEFT JOIN sys_user u ON t.user_id=u.user_id
- LEFT JOIN gxt_repair_order ro ON t.order_id=ro.id
- LEFT JOIN gxt_work_order wo ON wo.id=t.order_id
- LEFT JOIN sys_dept d ON
- d.dept_id=CASE WHEN t.order_type=1 THEN ro.pcs_station_pid ELSE wo.pcs_station_pid END
- WHERE DATE_FORMAT(t.create_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
- <if test="userId != null">
- AND t.user_id = #{userId}
- </if>
- <if test="orderCode != null and orderCode != ''">
- AND t.order_code LIKE CONCAT( '%', #{orderCode}, '%' )
- </if>
- ORDER BY t.create_time DESC
- </select>
- <delete id="delRepairOrderFlowRecords">
- DELETE FROM gxt_repair_order_flow_records
- </delete>
- <delete id="delRepairOrderFlowRecordsNext">
- DELETE FROM gxt_repair_order_flow_records_next
- </delete>
- <delete id="delWorkOrderFlowRecords">
- DELETE FROM gxt_work_order_flow_records
- </delete>
- <delete id="delWorkOrderFlowRecordsNext">
- DELETE FROM gxt_work_order_flow_records_next
- </delete>
- <select id="selectRepairOrderFlowRecordsSize" resultType="Integer">
- SELECT count(*) FROM gxt_repair_order_flow_records
- </select>
- <select id="repairOrderFlowRecordsSize" resultType="Integer">
- SELECT COUNT(*) FROM (
- SELECT
- f.order_id,
- f.action_type,
- f.action_time,
- ro.real_start_time,
- (SELECT COUNT(*)
- FROM gxt_repair_order_flow f2
- WHERE f2.order_id = f.order_id
- AND f2.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
- AND f.action_time >= f2.action_time) AS order_seq
- FROM gxt_repair_order_flow f
- LEFT JOIN gxt_repair_order ro
- ON ro.id = f.order_id
- WHERE f.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
- ) t
- </select>
- <insert id="addRepairOrderFlowRecords">
- INSERT INTO gxt_repair_order_flow_records (
- order_id,
- action_type,
- action_time,
- real_start_time,
- order_seq
- )
- SELECT
- f.order_id,
- f.action_type,
- f.action_time,
- ro.real_start_time,
- (SELECT COUNT(*)
- FROM gxt_repair_order_flow f2
- WHERE f2.order_id = f.order_id
- AND f2.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
- AND f.action_time >= f2.action_time) AS order_seq
- FROM gxt_repair_order_flow f
- LEFT JOIN gxt_repair_order ro
- ON ro.id = f.order_id
- WHERE f.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
- ORDER BY f.order_id, f.action_time
- </insert>
- <insert id="addRepairOrderFlowRecordsNext">
- INSERT INTO gxt_repair_order_flow_records_next (
- order_id,
- total_before_start_suspend_seconds,
- total_in_work_suspend_seconds,
- total_night_auto_suspend_seconds,
- before_start_suspend_format,
- in_work_suspend_format,
- night_auto_suspend_format
- )
- SELECT
- t0.order_id,
- COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) AS total_before_start_suspend_seconds,
- COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) AS total_in_work_suspend_seconds,
- COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0) AS total_night_auto_suspend_seconds,
- CONCAT(
- FLOOR(COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) / 3600), '小时',
- FLOOR(MOD(COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 3600) / 60), '分钟',
- MOD(COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 60), '秒'
- ) AS before_start_suspend_format,
- CONCAT(
- FLOOR(COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) / 3600), '小时',
- FLOOR(MOD(COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 3600) / 60), '分钟',
- MOD(COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 60), '秒'
- ) AS in_work_suspend_format,
- CONCAT(
- FLOOR(COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0) / 3600), '小时',
- FLOOR(MOD(COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0), 3600) / 60), '分钟',
- MOD(COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0), 60), '秒'
- ) AS night_auto_suspend_format
- FROM (SELECT order_id FROM gxt_repair_order_flow_records GROUP BY order_id) t0
- LEFT JOIN gxt_repair_order_flow_records t1
- ON t0.order_id = t1.order_id
- AND t1.action_type = 'approved'
- LEFT JOIN gxt_repair_order_flow_records t2
- ON t1.order_id = t2.order_id
- AND t2.order_seq = t1.order_seq + 1
- AND t1.action_type = 'approved'
- AND t2.action_type IN ('resume','auto_resume')
- LEFT JOIN gxt_repair_order_flow_records t3
- ON t0.order_id = t3.order_id
- AND t3.action_type = 'auto_suspend'
- LEFT JOIN gxt_repair_order_flow_records t4
- ON t3.order_id = t4.order_id
- AND t4.order_seq = t3.order_seq + 1
- AND t3.action_type = 'auto_suspend'
- AND t4.action_type IN ('resume','auto_resume')
- GROUP BY t0.order_id
- ORDER BY t0.order_id
- </insert>
- <select id="selectWorkOrderFlowRecordsSize" resultType="Integer">
- SELECT count(*) FROM gxt_work_order_flow_records
- </select>
- <select id="workOrderFlowRecordsSize" resultType="Integer">
- SELECT COUNT(*) FROM (
- SELECT
- f.order_id,
- f.action_type,
- f.action_time,
- ro.real_start_time,
- (SELECT COUNT(*)
- FROM gxt_work_order_flow f2
- WHERE f2.order_id = f.order_id
- AND f2.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
- AND f.action_time >= f2.action_time) AS order_seq
- FROM gxt_work_order_flow f
- LEFT JOIN gxt_work_order ro
- ON ro.id = f.order_id
- WHERE f.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')) t
- </select>
- <insert id="addWorkOrderFlowRecords">
- INSERT INTO gxt_work_order_flow_records (
- order_id,
- action_type,
- action_time,
- real_start_time,
- order_seq
- )
- SELECT
- f.order_id,
- f.action_type,
- f.action_time,
- ro.real_start_time,
- (SELECT COUNT(*)
- FROM gxt_work_order_flow f2
- WHERE f2.order_id = f.order_id
- AND f2.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
- AND f.action_time >= f2.action_time) AS order_seq
- FROM gxt_work_order_flow f
- LEFT JOIN gxt_work_order ro
- ON ro.id = f.order_id
- WHERE f.action_type IN ('approved', 'resume', 'auto_suspend', 'auto_resume')
- ORDER BY f.order_id, f.action_time
- </insert>
- <insert id="addWorkOrderFlowRecordsNext">
- INSERT INTO gxt_work_order_flow_records_next (
- order_id,
- total_before_start_suspend_seconds,
- total_in_work_suspend_seconds,
- total_night_auto_suspend_seconds,
- before_start_suspend_format,
- in_work_suspend_format,
- night_auto_suspend_format
- )
- SELECT
- t0.order_id,
- COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) AS total_before_start_suspend_seconds,
- COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) AS total_in_work_suspend_seconds,
- COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0) AS total_night_auto_suspend_seconds,
- CONCAT(
- FLOOR(COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) / 3600), '小时',
- FLOOR(MOD(COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 3600) / 60), '分钟',
- MOD(COALESCE(SUM(CASE
- WHEN t1.action_time <![CDATA[<]]> t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 60), '秒'
- ) AS before_start_suspend_format,
- CONCAT(
- FLOOR(COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0) / 3600), '小时',
- FLOOR(MOD(COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 3600) / 60), '分钟',
- MOD(COALESCE(SUM(CASE
- WHEN t1.action_time >= t1.real_start_time
- THEN TIMESTAMPDIFF(SECOND, t1.action_time, t2.action_time)
- ELSE 0
- END), 0), 60), '秒'
- ) AS in_work_suspend_format,
- CONCAT(
- FLOOR(COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0) / 3600), '小时',
- FLOOR(MOD(COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0), 3600) / 60), '分钟',
- MOD(COALESCE(SUM(CASE
- WHEN t4.action_time IS NOT NULL
- THEN TIMESTAMPDIFF(SECOND, t3.action_time, t4.action_time)
- ELSE 0
- END), 0), 60), '秒'
- ) AS night_auto_suspend_format
- FROM (SELECT order_id FROM gxt_work_order_flow_records GROUP BY order_id) t0
- LEFT JOIN gxt_work_order_flow_records t1
- ON t0.order_id = t1.order_id
- AND t1.action_type = 'approved'
- LEFT JOIN gxt_work_order_flow_records t2
- ON t1.order_id = t2.order_id
- AND t2.order_seq = t1.order_seq + 1
- AND t1.action_type = 'approved'
- AND t2.action_type IN ('resume','auto_resume')
- LEFT JOIN gxt_work_order_flow_records t3
- ON t0.order_id = t3.order_id
- AND t3.action_type = 'auto_suspend'
- LEFT JOIN gxt_work_order_flow_records t4
- ON t3.order_id = t4.order_id
- AND t4.order_seq = t3.order_seq + 1
- AND t3.action_type = 'auto_suspend'
- AND t4.action_type IN ('resume','auto_resume')
- GROUP BY t0.order_id
- ORDER BY t0.order_id
- </insert>
-
- </mapper>
|