Fixiaobai
2023-08-31 dfea650104b9ad8529fc2df46225c30a0df8c6f5
laboratory-server/src/main/resources/mapper/InstrumentMapper.xml
@@ -23,23 +23,63 @@
    <!--选择设备-->
    <resultMap id="chooseinstumMap" type="map">
        <id property="father_name" column="father_name"/>
        <collection property="father" resultMap="chooseinstumTowMap" javaType="List"/>
        <id property="id" column="cid"/>
        <result property="name" column="father_name"/>
        <collection property="children" resultMap="chooseinstumTowMap" javaType="List"/>
    </resultMap>
    <resultMap id="chooseinstumTowMap" type="map">
        <id property="son_name" column="son_name"/>
        <collection property="chldren" resultMap="chooseinstumTowsMap" javaType="List"/>
        <id property="id" column="cid"/>
        <result property="name" column="son_name"/>
        <collection property="children" resultMap="chooseinstumTowsMap" javaType="List"/>
    </resultMap>
    <resultMap id="chooseinstumTowsMap" type="map">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
    </resultMap>
    <select id="chooseinstum" resultMap="chooseinstumMap">
        select instrument.id,
        select c.id           cid,
               instrument.id,
               father_name,
               son_name,
               equipment_name name
        from lims_laboratory.instrument
                 left join lims_laboratory.classify c on c.id = instrument.classify_id
        where conditions in (1, 5)
    </select>
    <select id="getInstrument" resultMap="treeMapClassAndInstrument">
        SELECT
            *
        FROM
            classify f,(
            SELECT
                cl.id cId,
                cl.son_name cSonName,
                cl.father_name cFatherName,
                i.id iId,
                equipment_name equipmentName
            FROM
                classify cl,
                instrument i
            WHERE
                i.classify_id = cl.id
              AND i.state = 1
              AND conditions = 5
        ) s
        WHERE
            f.father_name = s.cFatherName
          AND f.son_name IS NULL
    </select>
    <resultMap id="treeMapClassAndInstrument" type="com.yuanchu.limslaboratory.pojo.ClassAndInsTree" >
        <result property="fatherId" column="id"/>
        <result property="fatherName" column="father_name"/>
        <collection property="childrenList" ofType="classAndIns">
            <result property="sonId" column="cId"/>
            <result property="sonName" column="cSonName"/>
            <collection property="childrenList" ofType="ins">
                <result property="insId" column="iId"/>
                <result property="name" column="equipmentName"/>
            </collection>
        </collection>
    </resultMap>
</mapper>