|
|
|
|
@ -11,6 +11,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
<result property="shutTypeId" column="shut_type_id" />
|
|
|
|
|
<result property="shutReason" column="shut_reason" />
|
|
|
|
|
<result property="isFlag" column="is_flag" />
|
|
|
|
|
<result property="deviceFreq" column="device_freq" />
|
|
|
|
|
<result property="lineFreq" column="line_freq" />
|
|
|
|
|
<result property="globalFreq" column="global_freq" />
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
<result property="createBy" column="create_by" />
|
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
|
@ -23,9 +26,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectDmsBaseShutReasonList" parameterType="DmsBaseShutReason" resultMap="DmsBaseShutReasonResult">
|
|
|
|
|
select a.shut_reason_id, a.reason_code, a.device_id, a.shut_type_id, a.shut_reason, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time
|
|
|
|
|
select a.shut_reason_id,
|
|
|
|
|
a.reason_code,
|
|
|
|
|
a.device_id,
|
|
|
|
|
a.shut_type_id,
|
|
|
|
|
a.shut_reason,
|
|
|
|
|
a.is_flag,
|
|
|
|
|
nvl(df.freq, 0) as device_freq,
|
|
|
|
|
nvl(lf.freq, 0) as line_freq,
|
|
|
|
|
nvl(gf.freq, 0) as global_freq,
|
|
|
|
|
a.remark,
|
|
|
|
|
a.create_by,
|
|
|
|
|
a.create_time,
|
|
|
|
|
a.update_by,
|
|
|
|
|
a.update_time
|
|
|
|
|
from dms_base_shut_reason a
|
|
|
|
|
left join base_deviceledger b on a.device_id = b.OBJ_ID
|
|
|
|
|
left join (
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="deviceId != null">
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
where r.machine_id = #{deviceId}
|
|
|
|
|
and r.shut_begin_time >= sysdate - 90
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
select cast(null as number) as shut_reason_id,
|
|
|
|
|
0 as freq
|
|
|
|
|
from dual
|
|
|
|
|
where 1 = 0
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
) df on df.shut_reason_id = a.shut_reason_id
|
|
|
|
|
left join (
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="deviceId != null">
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
join base_deviceledger d
|
|
|
|
|
on d.obj_id = r.machine_id
|
|
|
|
|
join base_deviceledger current_device
|
|
|
|
|
on current_device.obj_id = #{deviceId}
|
|
|
|
|
where d.product_line_code = current_device.product_line_code
|
|
|
|
|
and r.shut_begin_time >= sysdate - 90
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
select cast(null as number) as shut_reason_id,
|
|
|
|
|
0 as freq
|
|
|
|
|
from dual
|
|
|
|
|
where 1 = 0
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
) lf on lf.shut_reason_id = a.shut_reason_id
|
|
|
|
|
left join (
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
where r.shut_begin_time >= sysdate - 180
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
) gf on gf.shut_reason_id = a.shut_reason_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="reasonCode != null and reasonCode != ''"> and a.reason_code = #{reasonCode}</if>
|
|
|
|
|
<if test="deviceId != null "> and a.device_id = #{deviceId}</if>
|
|
|
|
|
@ -34,6 +103,170 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
<if test="shutReason != null and shutReason != ''"> and a.shut_reason = #{shutReason}</if>
|
|
|
|
|
<if test="isFlag != null and isFlag != ''"> and a.is_flag = #{isFlag}</if>
|
|
|
|
|
</where>
|
|
|
|
|
<!-- 为什么这样做:停机原因维护和导出都优先呈现高频项,现场录入时可以更快定位真实高发原因。 -->
|
|
|
|
|
order by
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="deviceId != null">
|
|
|
|
|
nvl(df.freq, 0) desc,
|
|
|
|
|
nvl(lf.freq, 0) desc,
|
|
|
|
|
nvl(gf.freq, 0) desc,
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
nvl(gf.freq, 0) desc,
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
a.reason_code,
|
|
|
|
|
a.shut_reason_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectAvailableShutReasonList" resultMap="DmsBaseShutReasonResult">
|
|
|
|
|
select a.shut_reason_id,
|
|
|
|
|
a.reason_code,
|
|
|
|
|
a.device_id,
|
|
|
|
|
a.shut_type_id,
|
|
|
|
|
a.shut_reason,
|
|
|
|
|
a.is_flag,
|
|
|
|
|
nvl(df.freq, 0) as device_freq,
|
|
|
|
|
nvl(lf.freq, 0) as line_freq,
|
|
|
|
|
nvl(gf.freq, 0) as global_freq,
|
|
|
|
|
a.remark,
|
|
|
|
|
a.create_by,
|
|
|
|
|
a.create_time,
|
|
|
|
|
a.update_by,
|
|
|
|
|
a.update_time
|
|
|
|
|
from dms_base_shut_reason a
|
|
|
|
|
left join (
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="deviceId != null">
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
where r.machine_id = #{deviceId}
|
|
|
|
|
and r.shut_begin_time >= sysdate - 90
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
select cast(null as number) as shut_reason_id,
|
|
|
|
|
0 as freq
|
|
|
|
|
from dual
|
|
|
|
|
where 1 = 0
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
) df on df.shut_reason_id = a.shut_reason_id
|
|
|
|
|
left join (
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="deviceId != null">
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
join base_deviceledger d
|
|
|
|
|
on d.obj_id = r.machine_id
|
|
|
|
|
join base_deviceledger current_device
|
|
|
|
|
on current_device.obj_id = #{deviceId}
|
|
|
|
|
where d.product_line_code = current_device.product_line_code
|
|
|
|
|
and r.shut_begin_time >= sysdate - 90
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
select cast(null as number) as shut_reason_id,
|
|
|
|
|
0 as freq
|
|
|
|
|
from dual
|
|
|
|
|
where 1 = 0
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
) lf on lf.shut_reason_id = a.shut_reason_id
|
|
|
|
|
left join (
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
where r.shut_begin_time >= sysdate - 180
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
) gf on gf.shut_reason_id = a.shut_reason_id
|
|
|
|
|
where a.is_flag = '1'
|
|
|
|
|
<if test="deviceId != null">
|
|
|
|
|
and (a.device_id is null or a.device_id = #{deviceId})
|
|
|
|
|
</if>
|
|
|
|
|
order by
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="deviceId != null">
|
|
|
|
|
nvl(df.freq, 0) desc,
|
|
|
|
|
nvl(lf.freq, 0) desc,
|
|
|
|
|
nvl(gf.freq, 0) desc,
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
nvl(gf.freq, 0) desc,
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
a.shut_type_id,
|
|
|
|
|
a.reason_code,
|
|
|
|
|
a.shut_reason_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectRecommendReasonList" resultType="com.aucma.dms.domain.vo.DmsShutReasonRecommendVo">
|
|
|
|
|
with device_freq as (
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
where r.machine_id = #{deviceId}
|
|
|
|
|
and r.shut_begin_time >= sysdate - 90
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
),
|
|
|
|
|
line_freq as (
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
join base_deviceledger d
|
|
|
|
|
on d.obj_id = r.machine_id
|
|
|
|
|
join base_deviceledger current_device
|
|
|
|
|
on current_device.obj_id = #{deviceId}
|
|
|
|
|
where d.product_line_code = current_device.product_line_code
|
|
|
|
|
and r.shut_begin_time >= sysdate - 90
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
),
|
|
|
|
|
global_freq as (
|
|
|
|
|
select r.shut_reason_id,
|
|
|
|
|
count(1) as freq
|
|
|
|
|
from dms_record_shut_down r
|
|
|
|
|
where r.shut_begin_time >= sysdate - 180
|
|
|
|
|
and r.shut_reason_id is not null
|
|
|
|
|
and r.active_flag = 1
|
|
|
|
|
group by r.shut_reason_id
|
|
|
|
|
)
|
|
|
|
|
select sr.shut_reason_id as shutReasonId,
|
|
|
|
|
sr.reason_code as reasonCode,
|
|
|
|
|
sr.shut_reason as shutReason,
|
|
|
|
|
sr.shut_type_id as shutTypeId,
|
|
|
|
|
st.shut_type_name as shutTypeName,
|
|
|
|
|
nvl(df.freq, 0) as deviceFreq,
|
|
|
|
|
nvl(lf.freq, 0) as lineFreq,
|
|
|
|
|
nvl(gf.freq, 0) as globalFreq
|
|
|
|
|
from dms_base_shut_reason sr
|
|
|
|
|
join dms_base_shut_type st
|
|
|
|
|
on st.shut_type_id = sr.shut_type_id
|
|
|
|
|
and st.is_flag = '1'
|
|
|
|
|
left join device_freq df
|
|
|
|
|
on df.shut_reason_id = sr.shut_reason_id
|
|
|
|
|
left join line_freq lf
|
|
|
|
|
on lf.shut_reason_id = sr.shut_reason_id
|
|
|
|
|
left join global_freq gf
|
|
|
|
|
on gf.shut_reason_id = sr.shut_reason_id
|
|
|
|
|
where sr.is_flag = '1'
|
|
|
|
|
and (sr.device_id is null or sr.device_id = #{deviceId})
|
|
|
|
|
order by nvl(df.freq, 0) desc,
|
|
|
|
|
nvl(lf.freq, 0) desc,
|
|
|
|
|
nvl(gf.freq, 0) desc,
|
|
|
|
|
sr.reason_code,
|
|
|
|
|
sr.shut_reason_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectDmsBaseShutReasonByShutReasonId" parameterType="Long" resultMap="DmsBaseShutReasonResult">
|
|
|
|
|
|