From e7f7daae5d21ad2988cadd25b6987ca5e7ef8001 Mon Sep 17 00:00:00 2001 From: Fixiaobai <fixiaobai@163.com> Date: 星期六, 09 九月 2023 09:51:20 +0800 Subject: [PATCH] 修改bug --- standard-server/src/main/resources/mapper/MaterialMapper.xml | 75 +++++++++++++++++++++++++++---------- 1 files changed, 54 insertions(+), 21 deletions(-) diff --git a/standard-server/src/main/resources/mapper/MaterialMapper.xml b/standard-server/src/main/resources/mapper/MaterialMapper.xml index 5f9c4bf..7e625a6 100644 --- a/standard-server/src/main/resources/mapper/MaterialMapper.xml +++ b/standard-server/src/main/resources/mapper/MaterialMapper.xml @@ -7,7 +7,7 @@ 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, @@ -31,42 +31,75 @@ </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 - <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` + 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`, f.`create_time` + FROM specifications f + WHERE f.`state` = 1) f + ON f.standard_id = s.id WHERE m.`state` = 1 + ORDER BY f.create_time DESC </select> + <select id="getTreeByMaterialId" resultMap="getTreeById"> + SELECT m.id mId, + m.`name` mName, + sd.id sdId, + sd.`name` sdName, + ss.id ssId, + ss.`name` ssName + FROM material m, + standard sd, + specifications ss + WHERE m.id = sd.material_id + AND sd.id = ss.standard_id + AND m.id = #{id} + AND m.state != 0 + AND sd.state != 0 + AND ss.state !=0 + </select> + <resultMap id="getTreeById" type="map"> + <result property="id" column="mId"/> + <result property="name" column="mName"/> + <collection property="children" resultMap="getStan" javaType="List"/> + </resultMap> + <resultMap id="getStan" type="map"> + <result property="id" column="sdId"/> + <result property="name" column="sdName"/> + <collection property="children" resultMap="getModel" javaType="List"/> + </resultMap> + <resultMap id="getModel" type="map"> + <result property="id" column="ssId"/> + <result property="name" column="ssName"/> + </resultMap> </mapper> -- Gitblit v1.9.3