XiaoRuby
2023-08-22 dce5044043c3af93b84dae2804f2d54f779e7c1e
standard-server/src/main/resources/mapper/MaterialMapper.xml
@@ -31,43 +31,42 @@
    </select>
    <resultMap id="OneLevelTreeMap" type="Map">
        <id property="id" column="materialId"/>
        <result property="name" column="materialName"/>
        <id property="type" column="type"/>
        <collection property="children" resultMap="TwoLevelTreeMap" javaType="List"/>
    </resultMap>
    <resultMap id="TwoLevelTreeMap" type="Map">
        <id property="id" column="standardId"/>
        <result property="name" column="standardName"/>
        <id property="id" column="materialId"/>
        <result property="name" column="materialName"/>
        <collection property="children" resultMap="ThreeLevelTreeMap" javaType="List"/>
    </resultMap>
    <resultMap id="ThreeLevelTreeMap" type="Map">
        <id property="id" column="specificationsId"/>
        <result property="name" column="specificationsName"/>
        <id property="id" column="standardId"/>
        <result property="name" column="standardName"/>
        <collection property="children" resultMap="FourLevelTreeMap" javaType="List"/>
    </resultMap>
    <resultMap id="FourLevelTreeMap" type="Map">
        <id property="id" column="productId"/>
        <result property="name" column="productName"/>
        <id property="id" column="specificationsId"/>
        <result property="name" column="specificationsName"/>
    </resultMap>
    <select id="FourTree" resultMap="OneLevelTreeMap">
        SELECT m.`id` materialId, m.`name` materialName, s.`id` standardId, s.`name` standardName,
        f.`id` specificationsId, f.`name` specificationsName, p.`id` productId, p.`name` productName
        FROM lims_laboratory.material m
        LEFT JOIN (SELECT s.`id`, s.`name`, s.`material_id` FROM lims_laboratory.standard s WHERE s.`state` = 1) s ON m.id =
        s.`material_id`
        LEFT JOIN (SELECT f.`id`, f.`name`, f.`standard_id` FROM lims_laboratory.specifications f WHERE f.`state` = 1
        SELECT m.`type`, m.`id` materialId, m.`name` materialName, s.id standardId, s.name standardName,
        f.id specificationsId, f.name specificationsName
        FROM material m
        LEFT JOIN (SELECT s.`id`, s.`name`, s.`material_id` FROM standard s WHERE s.`state` = 1) s
        ON s.material_id = m.`id`
        LEFT JOIN (SELECT f.`id`, f.`name`, f.`standard_id` FROM specifications f WHERE f.`state` = 1
        <if test="specificationsName != null and specificationsName != ''">
            AND f.`name` = #{specificationsName}
        </if>
        ) f ON s.`id` = f.`standard_id`
        LEFT JOIN (SELECT p.`id`, p.`name`, p.`specifications_id` FROM lims_laboratory.product p WHERE p.`state` = 1) p ON f.`id` =
        p.`specifications_id`
        </if>) f
        ON f.standard_id = s.id
        WHERE m.`state` = 1
    </select>
    <!--添加标准选择样品名称-->
    <select id="selectmater" resultType="java.lang.String">
        select  name