<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
~
|
~ Copyright (c) 2018-2025, ztt All rights reserved.
|
~
|
~ Redistribution and use in source and binary forms, with or without
|
~ modification, are permitted provided that the following conditions are met:
|
~
|
~ Redistributions of source code must retain the above copyright notice,
|
~ this list of conditions and the following disclaimer.
|
~ Redistributions in binary form must reproduce the above copyright
|
~ notice, this list of conditions and the following disclaimer in the
|
~ documentation and/or other materials provided with the distribution.
|
~ Neither the name of the pig4cloud.com developer nor the names of its
|
~ contributors may be used to endorse or promote products derived from
|
~ this software without specific prior written permission.
|
~ Author: ztt
|
~
|
-->
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.chinaztt.mes.basic.mapper.PartMapper">
|
|
<resultMap id="partMap" type="com.chinaztt.mes.basic.entity.Part">
|
<id property="id" column="id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="materialType" column="material_type"/>
|
<result property="unit" column="unit"/>
|
<result property="description" column="description"/>
|
<result property="category" column="category"/>
|
<result property="assortment" column="assortment"/>
|
<result property="specs" column="specs"/>
|
<result property="drawingNumber" column="drawing_number"/>
|
<result property="ean" column="ean"/>
|
<result property="testRuleId" column="test_rule_id"/>
|
<result property="partFamilyName" column="part_family_name"/>
|
<result property="weight" column="weight"/>
|
<result property="useSystemNo" column="use_system_no"/>
|
<result property="voltageLevel" column="voltage_level"/>
|
<result property="lotTrackingIfs" column="lot_tracking_ifs"/>
|
<result property="engChgLevel" column="eng_chg_level"/>
|
<result property="planningMethod" column="planning_method"/>
|
<result property="threeLevelClassification" column="three_level_classification"/>
|
<result property="characteristic1" column="characteristic1"/>
|
<result property="characteristic2" column="characteristic2"/>
|
<result property="characteristic3" column="characteristic3"/>
|
<result property="partModel" column="part_model"/>
|
<result property="materialAttribute" column="material_attribute"/>
|
<result property="examiner" column="examiner"/>
|
<result property="prodName" column="prod_name"/>
|
<result property="partPitch" column="part_pitch"/>
|
</resultMap>
|
|
<sql id="partPage">
|
SELECT
|
part.*,
|
bpf.part_family_name part_family_name
|
FROM
|
basic_part part
|
LEFT JOIN (SELECT * FROM basic_part_family WHERE active = TRUE) bpf ON part.part_family_id = bpf.id
|
WHERE part.active = TRUE
|
ORDER BY part.create_time DESC
|
</sql>
|
|
<select id="getPartPage" resultMap="partMap">
|
select * from(<include refid="partPage"/>) a
|
<where>
|
<if test="bomId != null and bomId != 0">
|
exists(select 1 from technology_bom_component tbc where tbc.bom_id=#{bomId} and tbc.part_id=a."id"
|
and exists(select 1 from technology_bom_component child where child.parent=tbc."id" and
|
child.bom_id=tbc.bom_id))
|
</if>
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</where>
|
</select>
|
|
<select id="query" resultMap="partMap">
|
<bind name="searchKey" value="'%' + keyword + '%'"/>
|
select * from basic_part a where a.active=true and a.part_no like #{searchKey} or a.part_name like #{searchKey}
|
order by id limit 100
|
</select>
|
|
<sql id="qualityPartPage">
|
SELECT
|
bp.*
|
FROM
|
basic_part bp
|
WHERE bp."id" IN
|
(SELECT part_id FROM quality_join_template_part)
|
AND bp."id" NOT IN (SELECT part_id FROM quality_inspection_task WHERE quality_inspection_task.active = TRUE)
|
</sql>
|
|
<select id="getQualityPartPage" resultMap="partMap">
|
select * from (<include refid="qualityPartPage"/>) a
|
<if test="ew.emptyOfWhere == false">
|
<where>
|
${ew.SqlSegment}
|
</where>
|
</if>
|
</select>
|
|
<sql id="notInQualityPartPage">
|
SELECT
|
bp.*
|
FROM
|
basic_part bp
|
WHERE bp."id" NOT IN
|
(SELECT part_id FROM quality_join_template_part)
|
AND bp.active = TRUE
|
</sql>
|
|
<select id="getNotInQualityPartPage" resultMap="partMap">
|
select * from (<include refid="notInQualityPartPage"/>) a
|
<if test="ew.emptyOfWhere == false">
|
<where>
|
${ew.SqlSegment}
|
</where>
|
</if>
|
</select>
|
|
<sql id="reportPartPage">
|
SELECT
|
bp.*
|
FROM
|
basic_part bp
|
WHERE bp."id" IN
|
(SELECT part_id FROM quality_inspection_task WHERE quality_inspection_task.active = TRUE)
|
AND bp."id" NOT IN
|
(SELECT part_id
|
FROM quality_inspection_task
|
WHERE quality_inspection_task.id IN (SELECT test_task_id FROM quality_test_report WHERE active = TRUE))
|
AND bp.active = TRUE
|
</sql>
|
|
<select id="getReportPartsPage" resultMap="partMap">
|
select * from (<include refid="reportPartPage"/>) a
|
<if test="ew.emptyOfWhere == false">
|
<where>
|
${ew.SqlSegment}
|
</where>
|
</if>
|
</select>
|
|
<select id="selectReportIdBySystemNoAndType" resultType="java.lang.Long">
|
SELECT
|
ap.report_id
|
FROM
|
quality_apply_part ap
|
LEFT JOIN quality_apply a ON a.id = ap.apply_id
|
WHERE
|
ap.system_no = #{systemNo}
|
AND a.apply_type = #{applyType}
|
</select>
|
|
|
<select id="getPartConcatEcl" resultType="java.lang.String">
|
SELECT part_no || '_' || eng_chg_level
|
FROM basic_part
|
</select>
|
|
|
<select id="getByConcateCondition" resultType="com.chinaztt.mes.basic.entity.Part">
|
SELECT *
|
FROM basic_part
|
WHERE part_no || '_' || eng_chg_level = #{partNoEngChgLevel}
|
</select>
|
|
<select id="countComponentNum" resultType="java.lang.Integer">
|
SELECT
|
count(1)
|
FROM
|
technology_bom_component tbc
|
WHERE
|
tbc.bom_id = #{bomId}
|
</select>
|
|
<select id="getPartPageIncludeOwn" resultMap="partMap">
|
select * from(<include refid="partPage"/>) a
|
<where>
|
<if test="bomId != null and bomId != 0">
|
exists(select 1 from technology_bom_component tbc where tbc.bom_id=#{bomId} and tbc.part_id=a."id")
|
</if>
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</where>
|
</select>
|
</mapper>
|