You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
9.9 KiB
XML

<?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.op.mes.mapper.MesInspectionReportMapper">
<resultMap type="MesInspectionReport" id="MesInspectionReportResult">
<!-- 子表-->
<result property="id" column="id"/>
<result property="belongTo" column="belong_to"/>
<result property="bz" column="bz"/>
<result property="checkTimeS" column="check_time_s"/>
<result property="checkTimeE" column="check_time_e"/>
<result property="checkResult" column="check_result"/>
<result property="infoCode" column="info_code"/>
<result property="infoName" column="info_name"/>
<result property="tableLine" column="table_line"/>
<result property="delFlag" column="del_flag"/>
<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="lineCode" column="line_code"/>
<result property="productDate" column="product_date"/>
<result property="productCode" column="product_code"/>
<result property="productName" column="product_name"/>
<result property="checkDate" column="check_date"/>
<result property="bz" column="bz"/>
<result property="timeArray" column="timeArray"/>
<result property="equipmentCode" column="equipment_code"/>
<result property="equipmentName" column="equipment_name"/>
<result property="projectName" column="project_name"/>
<result property="lineName" column="line_name"/>
<result property="workorderId" column="workorder_id"/>
<result property="shiftId" column="shiftId"/>
</resultMap>
<select id="selectSelfMutualInspectionList" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select
mts.line_code,
mts.product_date,
mts.product_code,
mts.product_name,
mtsd.id,
mtsd.belong_to,
mtsd.check_time_s,
mtsd.check_time_e,
mtsd.check_result,
mtsd.check_time_s + '-' + mtsd.check_time_e as timeArray,
mtsd.info_code,
mtsd.info_name,
mtsd.table_line,
mtsd.bz,
mtsd.remark
from mes_table_self mts
left join mes_table_self_detial mtsd on mts.id = mtsd.belong_to
where 1 = 1
and mts.id = #{id}
and mtsd.del_flag = '0'
</select>
<select id="selectProjectName" resultType="MesInspectionReport" parameterType="java.lang.String">
select dict_label as projectName , dict_code as projectCode ,dict_sort as tableLine
from base_dict_data
where dict_type = #{param}
order by dict_sort asc
</select>
<select id="selectPointInspectionProjectList" resultMap="MesInspectionReportResult" parameterType="java.lang.String">
select
dict_label as info_name,
remark as project_name,
dict_sort as table_line
from base_dict_data
where dict_type = #{param}
order by dict_sort asc
</select>
<select id="selectTimeArray" resultType="MesInspectionReport" parameterType="MesInspectionReport">
select
mtsd.check_time_s as checkTimeS,
mtsd.check_time_e as checkTimeE,
mtsd.check_time_s + '-' + mtsd.check_time_e as timeArray,
mtsd.table_line as tableLine
from mes_table_self mts
left join mes_table_self_detial mtsd on mts.id = mtsd.belong_to
<where>
and mts.del_flag = '0'
and mtsd.del_flag = '0'
and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate})
and mts.line_code = #{lineCode}
<choose>
<when test="shiftId != null">
AND mts.report_name = CONCAT(#{reportName}, (SELECT Shift_Desc FROM base_shifts_t WHERE Shift_Id = #{shiftId}))
</when>
<otherwise>
AND mts.report_name = #{reportName}
</otherwise>
</choose>
</where>
group by mtsd.check_time_s , mtsd.check_time_e , mtsd.table_line
order by mtsd.check_time_s
</select>
<select id="selectTeamArray" resultType="java.lang.String" parameterType="MesInspectionReport">
select
mtsd.remark
from mes_table_self mts
left join mes_table_self_detial mtsd on mts.id = mtsd.belong_to
where 1=1
and mts.del_flag = '0'
and mtsd.del_flag = '0'
and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate})
and mts.line_code = #{lineCode}
<choose>
<when test="shiftId != null">
AND mts.report_name = CONCAT(#{reportName}, (SELECT Shift_Desc FROM base_shifts_t WHERE Shift_Id = #{shiftId}))
</when>
<otherwise>
AND mts.report_name = #{reportName}
</otherwise>
</choose>
group by mtsd.remark
order by mtsd.remark
</select>
<select id="selectSelfMutualInspectionData" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select
mts.id,
mts.line_code,
mts.product_date,
mts.product_code,
mts.product_name,
mts.check_date,
mts.bz,
mts.remark,
mts.create_by
from mes_table_self mts
where 1=1
<choose>
<when test="shiftId != null and reportName = 'CheckReport'">
and report_name = CONCAT(#{reportName}, (SELECT Shift_Desc FROM base_shifts_t WHERE Shift_Id = #{shiftId}))
and line_code = #{lineCode}
and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate})
</when>
<when test="shiftId = null and reportName = 'CheckReport'">
AND mts.report_name = #{reportName}
and line_code = #{lineCode}
and CONVERT(date, mts.check_date) = CONVERT(date,#{checkDate})
</when>
<otherwise>
and id = #{id}
</otherwise>
</choose>
and del_flag = '0'
</select>
<select id="getLineCodeList" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select equipment_code, equipment_name
from base_equipment
where del_flag = '0'
and equipment_category = '1'
</select>
<select id="getProductList" resultMap="MesInspectionReportResult" parameterType="MesInspectionReport">
select
mts.id,
mts.product_name,
mts.product_code
from mes_table_self mts
where DATEDIFF(DAY, mts.check_date, #{checkDate}) = 0
and mts.del_flag = '0'
<choose>
<when test="shiftId != null">
AND mts.report_name = CONCAT(#{reportName}, (SELECT Shift_Desc FROM base_shifts_t WHERE Shift_Id = #{shiftId}))
</when>
<otherwise>
AND mts.report_name = #{reportName}
</otherwise>
</choose>
and mts.line_code = #{lineCode}
group by
mts.id,
mts.product_name,
mts.product_code
</select>
<select id="getDataCodeList" resultType ="com.op.mes.domain.ProOrderWorkorder" parameterType="MesInspectionReport">
select a.batch_code as batchCode
from pro_order_workorder_batch a
join pro_order_workorder b on a.workorder_id = b.workorder_id
where b.workorder_id = #{workorderId}
and a.del_flag = '0'
</select>
<update id="updateHeaderFooter" parameterType="MesInspectionReport">
update mes_table_self
<trim prefix="SET" suffixOverrides=",">
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="bz != null">bz = #{bz},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<!-- 批量更新 -->
<update id="updateBatch" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";">
update mes_table_self_detial
<trim prefix="SET" suffixOverrides=",">
<if test="item.checkTimeS != null">check_time_s = #{item.checkTimeS},</if>
check_time_e = #{item.checkTimeE},
<if test="item.checkResult != null">check_result = #{item.checkResult},</if>
<if test="item.updateBy != null">update_by = #{item.updateBy},</if>
<if test="item.updateTime != null">update_time = #{item.updateTime},</if>
<if test="item.remark != null">remark = #{item.remark},</if>
<if test="item.bz != null">bz = #{item.bz},</if>
</trim>
where id = #{item.id}
</foreach>
</update>
<insert id="addBatch">
insert into mes_table_self_detial(
id, belong_to,
remark, bz,
create_by, create_time,
update_by, update_time,
factory_code, del_flag,
check_time_s, check_time_e,
check_result, info_code,
info_name, table_line
) values
<foreach item="item" index="index" collection="list" separator=",">
(
#{item.id}, #{item.belongTo},
#{item.remark}, #{item.bz},
#{item.createBy}, #{item.createTime},
#{item.updateBy}, #{item.updateTime},
#{item.factoryCode}, #{item.delFlag},
#{item.checkTimeS}, #{item.checkTimeE},
#{item.checkResult}, #{item.infoCode},
#{item.infoName}, #{item.tableLine}
)
</foreach>
</insert>
</mapper>