<?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.technology.mapper.StructureMapper">
|
|
<resultMap id="structureMap" type="com.chinaztt.mes.technology.dto.StructureDTO">
|
<id property="id" column="id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partId" column="part_id"/>
|
<result property="structureType" column="structure_type"/>
|
<result property="master" column="master"/>
|
<result property="remark" column="remark"/>
|
<result property="partName" column="part_name"/>
|
<result property="drawingNumber" column="drawing_number"/>
|
<result property="unit" column="unit"/>
|
<result property="version" column="version"/>
|
<result property="bomTypeDb" column="bom_type_db"/>
|
<result property="alternativeNo" column="alternative_no"/>
|
<result property="alternativeDesc" column="alternative_desc"/>
|
<result property="ifsSync" column="ifs_sync"/>
|
</resultMap>
|
|
<resultMap id="structureComponentMap" type="com.chinaztt.mes.technology.dto.StructureComponentDTO">
|
<id property="id" column="id"/>
|
<result property="structureId" column="structure_id"/>
|
<result property="partId" column="part_id"/>
|
<result property="qpa" column="qpa"/>
|
<result property="discNum" column="disc_num"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="drawingNumber" column="drawing_number"/>
|
<result property="unit" column="unit"/>
|
<result property="operationId" column="operation_id"/>
|
<result property="operationNo" column="operation_no"/>
|
<result property="operationName" column="operation_name"/>
|
<result property="lineItemNo" column="line_item_no"/>
|
<result property="color" column="color"/>
|
<result property="planningMethod" column="planning_method"/>
|
</resultMap>
|
|
<resultMap id="structureComponentDtoMap" type="com.chinaztt.mes.technology.dto.StructureDTO">
|
<id property="id" column="id"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partId" column="part_id"/>
|
<result property="structureType" column="structure_type"/>
|
<result property="master" column="master"/>
|
<result property="remark" column="remark"/>
|
<result property="partName" column="part_name"/>
|
<result property="drawingNumber" column="drawing_number"/>
|
<result property="unit" column="unit"/>
|
<result property="version" column="version"/>
|
<result property="bomTypeDb" column="bom_type_db"/>
|
<result property="alternativeNo" column="alternative_no"/>
|
<result property="alternativeDesc" column="alternative_desc"/>
|
<result property="ifsSync" column="ifs_sync"/>
|
<collection property="components" ofType="com.chinaztt.mes.technology.dto.StructureComponentDTO"
|
select="com.chinaztt.mes.technology.mapper.StructureMapper.getComponentDtoByStructureId"
|
column="id">
|
</collection>
|
</resultMap>
|
|
<sql id="structurePage">
|
SELECT A.*,
|
P.part_name,
|
p.part_no
|
FROM
|
technology_structure A
|
LEFT JOIN basic_part P ON A.part_id = P."id"
|
WHERE A.active = TRUE
|
ORDER BY A.id DESC
|
</sql>
|
|
<select id="getStructurePage" resultMap="structureMap">
|
select * from (<include refid="structurePage"/>) a
|
<if test="ew.emptyOfWhere == false">
|
<where>
|
${ew.SqlSegment}
|
</where>
|
</if>
|
</select>
|
|
<select id="getDtoById" resultMap="structureMap">
|
SELECT
|
s.*,
|
P.part_name,
|
P.part_no
|
FROM
|
technology_structure s
|
LEFT JOIN basic_part P ON P.ID = s.part_id
|
WHERE
|
s.ID = #{id}
|
AND s.active = TRUE
|
</select>
|
|
<select id="getComponentDtoByStructureId" resultMap="structureComponentMap">
|
SELECT
|
s.*,
|
P.*,
|
o.id operation_id,
|
o.name operation_name,
|
o.operation_no
|
FROM
|
technology_structure_component s
|
LEFT JOIN basic_part P ON P.ID = s.part_id
|
LEFT JOIN technology_operation o ON o.id = s.operation_id
|
WHERE
|
s.structure_id = #{structureId}
|
ORDER BY s."id"
|
</select>
|
|
<select id="getMasterComponentsByPartId" resultMap="structureComponentMap">
|
SELECT
|
C.*,
|
P.*
|
FROM
|
technology_structure s,
|
technology_structure_component C,
|
basic_part P
|
WHERE
|
s.part_id = #{partId}
|
AND s.master = TRUE
|
AND s.active = TRUE
|
AND C.structure_id = s."id"
|
AND C.part_id = P.ID
|
</select>
|
|
<select id="getParentPartIds" resultType="long">
|
SELECT
|
s.part_id
|
FROM
|
technology_structure_component T,
|
technology_structure s
|
WHERE
|
T.part_id = #{partId}
|
AND t.structure_id = s.id
|
AND s.active = TRUE
|
</select>
|
|
<select id="getStructureDtoByDocId" resultMap="structureComponentDtoMap">
|
SELECT
|
ts.*,
|
bp.part_no
|
FROM
|
technology_structure ts
|
LEFT JOIN basic_part bp ON bp.ID = ts.part_id
|
WHERE
|
ts."id" IN (
|
SELECT DISTINCT parent_structure_id
|
FROM technology_bom_component
|
WHERE bom_id IN (
|
SELECT bom_id
|
FROM technology_join_document_bom_routing
|
WHERE document_id = #{docId}));
|
</select>
|
|
<select id="getStructureDtoByIds" resultMap="structureComponentDtoMap">
|
SELECT
|
ts.*,
|
bp.part_no
|
FROM
|
technology_structure ts
|
LEFT JOIN basic_part bp ON bp.ID = ts.part_id
|
WHERE
|
ts."id" IN
|
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="getUnIfsedStructureDtoByDocId" resultType="com.chinaztt.mes.technology.entity.Structure">
|
SELECT
|
ts.*
|
FROM
|
technology_structure ts
|
LEFT JOIN basic_part bp ON bp.ID = ts.part_id
|
WHERE
|
ts.ifs_sync = FALSE
|
AND ts."id" IN (SELECT DISTINCT parent_structure_id
|
FROM technology_bom_component
|
WHERE bom_id IN (SELECT bom_id
|
FROM technology_join_document_bom_routing
|
WHERE document_id = #{docId}));
|
</select>
|
|
<update id="updateIfsTrue">
|
UPDATE technology_structure SET ifs_sync = TRUE WHERE id IN
|
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</update>
|
|
</mapper>
|