<?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.qianwen.smartman.modules.trace.mapper.TraceFlowRecordMapper">
|
|
|
<select id="getExportData" resultType="com.qianwen.smartman.modules.trace.vo.TraceCatalogFlowRecordExportVO">
|
select
|
tc.part_no AS partNo,
|
tc.online_time AS onlineTime,
|
tc.batch_number AS batchNumber,
|
tc.qualified AS qualified,
|
tc.is_rework_part AS isReworkPart,
|
tc.shift_index_name AS shiftIndexName,
|
tfr.flow_code AS flowCode,
|
tfr.flow_display_name AS flowDisplayName,
|
tfr.workstation_code AS workstationCode,
|
tfr.workstation_name AS workstationName,
|
tfr.workbench_name AS workbenchName,
|
tfr.flow_state AS flowState,
|
tfr.flow_tag AS flowTag,
|
tfr.entry_time AS entryTime,
|
tfr.left_time AS leftTime,
|
tfs.flow_seq AS flowSeq
|
FROM blade_trace_catalog tc
|
LEFT JOIN blade_trace_flow_record tfr ON tfr.part_no = tc.part_no
|
<if test="searchVO.workstationId != null and searchVO.workstationId != ''">
|
and tfr.workstation_id = #{searchVO.workstationId}
|
</if>
|
LEFT jOIN blade_trace_flow_settings tfs ON tfs.id=tfr.trace_flow_setting_id
|
<where>
|
<if test="searchVO.keywords != null and searchVO.keywords != ''">
|
(tc.part_no like concat(#{searchVO.keywords},'%') or tc.batch_number like concat(#{searchVO.keywords},'%') )
|
</if>
|
<if test="searchVO.workstationGroupIds != null and searchVO.workstationGroupIds.size() > 0 ">
|
AND tc.workstation_group_id in
|
<foreach collection="searchVO.workstationGroupIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="searchVO.onlineStartTime != null and searchVO.onlineEndTime != null">
|
and tc.online_time between #{searchVO.onlineStartTime} and #{searchVO.onlineEndTime}
|
</if>
|
<if test="searchVO.offlineStartTime != null and searchVO.offlineEndTime != null">
|
and tc.offline_time between #{searchVO.offlineStartTime} and #{searchVO.offlineEndTime}
|
</if>
|
</where>
|
order by tc.online_time desc
|
</select>
|
|
<select id="workpieceTracePage" resultType="com.qianwen.smartman.modules.trace.vo.WorkpieceTraceVO">
|
select btfr.id recordId,
|
btc.id traceId,
|
btfr.part_no partNo,
|
btc.batch_number batchNumber,
|
btfr.workstation_id workstationId,
|
btfr.workstation_code workstationCode,
|
btfr.workstation_name workstationName,
|
btfr.workbench_id workbenchId,
|
btfr.workbench_name workbenchName,
|
btc.shift_index_name shiftIndexName,
|
btc.trace_status traceStatus,
|
btc.online_time onlineTime,
|
btc.offline_time offlineTime
|
from blade_trace_flow_record btfr
|
INNER JOIN blade_trace_catalog btc on btfr.part_no = btc.part_no
|
where btfr.is_deleted = 0
|
and btc.is_deleted = 0
|
and btfr.flow_tag = 2
|
<if test="ew != null">
|
and ${ew.sqlSegment}
|
</if>
|
order by btc.online_time DESC
|
</select>
|
|
<select id="exportWorkpieceTrace" resultType="com.qianwen.smartman.modules.trace.dto.WorkpieceTraceDTO">
|
select btc.batch_number batchNumber,
|
btfr.part_no partNo,
|
btc.online_time onlineTime,
|
btc.offline_time offlineTime,
|
btfr.workstation_code workstationCode,
|
btfr.workstation_name workstationName,
|
btfr.workbench_name workbenchName,
|
btc.shift_index_name shiftIndexName,
|
btc.trace_status traceStatus,
|
<if test="_databaseId == 'mysql' ">
|
group_concat(btrnr.reason_name) reasonCode
|
</if>
|
<if test="_databaseId == 'dm' ">
|
wm_concat(btrnr.reason_name) reasonCode
|
</if>
|
<if test="_databaseId == 'oracle' ">
|
LISTAGG(to_char(btrnr.reason_name), '/') WITHIN GROUP(ORDER BY btrnr.reason_name) as reasonCode
|
</if>
|
from blade_trace_flow_record btfr
|
INNER JOIN blade_trace_catalog btc on btfr.part_no = btc.part_no
|
LEFT JOIN blade_trace_record_ng_reason btrnr on btfr.id = btrnr.record_id
|
where btfr.is_deleted = 0
|
and btc.is_deleted = 0
|
and btfr.flow_tag = 2
|
<if test="ew != null">
|
and ${ew.sqlSegment}
|
</if>
|
group by btfr.id, btc.id, btfr.part_no, btc.batch_number, btfr.workstation_id, btfr.workstation_code,
|
btfr.workstation_name, btfr.workbench_id, btfr.workbench_name, btc.shift_index_name, btc.trace_status,
|
btc.online_time, btc.offline_time
|
order by btc.online_time desc
|
</select>
|
|
<select id="getNgTraceFlowRecord" resultType="com.qianwen.smartman.modules.trace.vo.WorkpieceTraceVO">
|
SELECT
|
tfr.id as recordId,
|
tc.id traceId,
|
tc.part_no as partNo
|
FROM
|
blade_trace_catalog tc
|
INNER JOIN blade_trace_flow_record tfr ON tc.part_no = tfr.part_no AND tfr.flow_tag = 2
|
<if test="searchVO.workstationId != null and searchVO.workstationId != ''">
|
and tfr.workstation_id = #{searchVO.workstationId}
|
</if>
|
<where>
|
<if test="searchVO.keyword != null and searchVO.keyword != ''">
|
(tc.part_no like concat(#{searchVO.keyword},'%') or tc.batch_number like concat(#{searchVO.keyword},'%') )
|
</if>
|
<if test="searchVO.groupIds != null and searchVO.groupIds.size() > 0 ">
|
AND tc.workstation_group_id in
|
<foreach collection="searchVO.groupIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="searchVO.startTime != null and searchVO.endTime != null">
|
and tc.online_time between #{searchVO.startTime} and #{searchVO.endTime}
|
</if>
|
</where>
|
order by tc.online_time desc
|
</select>
|
|
<select id="getNgFullTraceFlowRecord" resultType="com.qianwen.smartman.modules.trace.vo.WorkpieceTraceVO">
|
SELECT
|
tfr.id as recordId,
|
tc.id traceId,
|
tc.part_no as partNo,
|
tc.batch_number as batchNumber,
|
tfr.workstation_id as workstationId,
|
tfr.workstation_code as workstationCode,
|
tfr.workstation_name as workstationName,
|
tfr.workbench_id workbenchId,
|
tfr.workbench_name as workbenchName ,
|
tc.shift_index_name as shiftIndexName,
|
tc.trace_status as traceStatus,
|
tc.online_time as onlineTime,
|
tc.offline_time as offlineTime
|
FROM
|
blade_trace_flow_record tfr
|
INNER JOIN blade_trace_catalog tc ON tc.part_no = tfr.part_no
|
where tfr.id in
|
<foreach collection="recordIdList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
order by tc.online_time,tfr.entry_time
|
</select>
|
|
<select id="countNgTraceRecord" resultType="java.lang.Long" parameterType="com.qianwen.smartman.modules.trace.vo.WorkpieceTraceSearchVO">
|
SELECT
|
count(*)
|
FROM
|
blade_trace_catalog tc
|
INNER JOIN blade_trace_flow_record tfr ON tc.part_no = tfr.part_no AND tfr.flow_tag = 2
|
<if test="searchVO.workstationId != null and searchVO.workstationId != ''">
|
and tfr.workstation_id = #{searchVO.workstationId}
|
</if>
|
<where>
|
<if test="searchVO.keyword != null and searchVO.keyword != ''">
|
(tc.part_no like concat(#{searchVO.keyword},'%') or tc.batch_number like concat(#{searchVO.keyword},'%') )
|
</if>
|
<if test="searchVO.groupIds != null and searchVO.groupIds.size() > 0 ">
|
AND tc.workstation_group_id in
|
<foreach collection="searchVO.groupIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="searchVO.startTime != null and searchVO.endTime != null">
|
and tc.online_time between #{searchVO.startTime} and #{searchVO.endTime}
|
</if>
|
</where>
|
order by tc.online_time desc
|
</select>
|
|
<select id="exportNgTraceRecord" resultType="com.qianwen.smartman.modules.trace.dto.WorkpieceTraceDTO" parameterType="com.qianwen.smartman.modules.trace.vo.WorkpieceTraceSearchVO">
|
SELECT
|
tc.batch_number batchNumber,
|
tfr.part_no partNo,
|
tc.online_time onlineTime,
|
tc.offline_time offlineTime,
|
tfr.workstation_code workstationCode,
|
tfr.workstation_name workstationName,
|
tfr.workbench_name workbenchName,
|
tc.shift_index_name shiftIndexName,
|
tc.trace_status traceStatus,
|
trnr.reason_name reasonCode
|
FROM
|
blade_trace_catalog tc
|
INNER JOIN blade_trace_flow_record tfr ON tc.part_no = tfr.part_no AND tfr.flow_tag = 2
|
<if test="searchVO.workstationId != null and searchVO.workstationId != ''">
|
and tfr.workstation_id = #{searchVO.workstationId}
|
</if>
|
LEFT JOIN blade_trace_record_ng_reason trnr on tfr.id = trnr.record_id
|
<where>
|
<if test="searchVO.keyword != null and searchVO.keyword != ''">
|
(tc.part_no like concat(#{searchVO.keyword},'%') or tc.batch_number like concat(#{searchVO.keyword},'%') )
|
</if>
|
<if test="searchVO.groupIds != null and searchVO.groupIds.size() > 0 ">
|
AND tc.workstation_group_id in
|
<foreach collection="searchVO.groupIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="searchVO.startTime != null and searchVO.endTime != null">
|
and tc.online_time between #{searchVO.startTime} and #{searchVO.endTime}
|
</if>
|
</where>
|
order by tc.online_time desc
|
</select>
|
|
|
</mapper>
|