zss
2023-09-04 e4aed6ad69c6b4b55d6d043f3706967439e2500d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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.mom.mapper.MaterialMapper">
    <!--标准MOM 左侧五级树展示-->
    <resultMap id="selectTreeByMaterialMap" type="map">
        <id property="id" column="type"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps1" javaType="List"/>
    </resultMap>
    <resultMap id="selectTreeByMaterialMaps1" type="map">
        <id property="name" column="father"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps2" javaType="List"/>
    </resultMap>
    <resultMap id="selectTreeByMaterialMaps2" type="map">
        <id property="id" column="mid"/>
        <result property="name" column="mname"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps3" javaType="List"/>
    </resultMap>
    <resultMap id="selectTreeByMaterialMaps3" type="map">
        <id property="id" column="sid"/>
        <result property="name" column="sname"/>
        <collection property="children" resultMap="selectTreeByMaterialMaps4" javaType="List"/>
    </resultMap>
    <resultMap id="selectTreeByMaterialMaps4" type="map">
        <id property="id" column="spid"/>
        <result property="name" column="spname"/>
    </resultMap>
    <select id="selectTreeByMaterial" resultMap="selectTreeByMaterialMap">
        select m.type,        #一级类型
               father,        #二级产品大类(4大类)
               m.id    mid,   #三级物料id
               m.name  mname, #三级样品名称
               s.id    sid,   #四级标准id
               s.name  sname, #四级标准名
               sp.id   spid,  #五级型号id
               sp.name spname #五级型号名
        from (select type, id, name, father from mom_ocean.material where state = 1) m
                 left join (select id, name, material_id from mom_ocean.standard where state = 1) s
                           on m.id = s.material_id
                 left join (select id, name, standard_id from mom_ocean.specifications where state = 1) sp
                           on sp.standard_id = s.id
    </select>
 
    <!--根据标准id查询物料-->
    <select id="selFath" resultType="com.yuanchu.mom.pojo.Material">
        select *
        from mom_ocean.material
        where state = 1
          and id = (select material_id
                    from mom_ocean.standard
                    where standard.state = 1
                      and standard.id = #{id})
    </select>
</mapper>