From dd571bf55de7f9a72d458adc179958ed2f9473c0 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期一, 21 八月 2023 09:39:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 standard-server/src/main/resources/mapper/MaterialMapper.xml |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/standard-server/src/main/resources/mapper/MaterialMapper.xml b/standard-server/src/main/resources/mapper/MaterialMapper.xml
index 7f77634..bb41247 100644
--- a/standard-server/src/main/resources/mapper/MaterialMapper.xml
+++ b/standard-server/src/main/resources/mapper/MaterialMapper.xml
@@ -1,13 +1,13 @@
 <?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.yuanchu.limslaboratory.mapper.MaterialMapper">
-
     <select id="selectMaterialLimit" resultType="Map">
-        select id, name
+        select id, code, name
         from lims_laboratory.material
         where state = 1
+          and type = #{type}
         order by create_time desc
-        limit #{num1},#{num2}
+        limit #{num1}, #{num2}
     </select>
     <select id="selectMaterialById" resultType="Map">
         select m.id,
@@ -27,6 +27,51 @@
              lims_laboratory.serial_number sn
         where m.specifications_id = s.id
           and s.serial_id = sn.id
-        and m.id=#{materialId}
+          and m.id = #{materialId}
+    </select>
+
+    <resultMap id="OneLevelTreeMap" type="Map">
+        <id property="id" column="materialId"/>
+        <result property="name" column="materialName"/>
+        <collection property="children" resultMap="TwoLevelTreeMap" javaType="List"/>
+    </resultMap>
+
+    <resultMap id="TwoLevelTreeMap" type="Map">
+        <id property="id" column="standardId"/>
+        <result property="name" column="standardName"/>
+        <collection property="children" resultMap="ThreeLevelTreeMap" javaType="List"/>
+    </resultMap>
+
+    <resultMap id="ThreeLevelTreeMap" type="Map">
+        <id property="id" column="specificationsId"/>
+        <result property="name" column="specificationsName"/>
+        <collection property="children" resultMap="FourLevelTreeMap" javaType="List"/>
+    </resultMap>
+
+    <resultMap id="FourLevelTreeMap" type="Map">
+        <id property="id" column="productId"/>
+        <result property="name" column="productName"/>
+    </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
+        <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`
+        WHERE m.`state` = 1
+    </select>
+    <!--娣诲姞鏍囧噯閫夋嫨鏍峰搧鍚嶇О-->
+    <select id="selectmater" resultType="java.lang.String">
+        select  name
+        from lims_laboratory.material
+        where state = 1
     </select>
 </mapper>

--
Gitblit v1.9.3