zss
2023-08-11 24a1aa1d7470998522aa28b4abc728fff5bcbaf7
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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">
    <resultMap id="BaseResultMap" type="Material">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="state" column="state" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="version" column="version" jdbcType="INTEGER"/>
    </resultMap>
 
    <resultMap id="materialTreeDto" type="materialTreeDto">
        <id property="id" column="mid"/>
        <result property="name" column="mname"/>
        <result property="type" column="type"/>
        <association property="children" resultMap="standardDto"/>
    </resultMap>
    <resultMap id="standardDto" type="standardDto">
        <id property="id" column="sid"/>
        <result property="name" column="sname"/>
        <association property="children" resultMap="specificationsDto"/>
    </resultMap>
    <resultMap id="specificationsDto" type="specificationsDto">
        <id property="id" column="spid"/>
        <result property="name" column="spname"/>
    </resultMap>
 
    <select id="selectTreeByMaterial" resultMap="materialTreeDto">
        select m.type,
               m.id    mid,
               m.name  mname,
               s.id    sid,
               s.name  sname,
               s2.id   spid,
               s2.name spname,
               p.id    pid,
               p.name  pname
        from (select type, id, name from material where state = 1) m
                 left join (select id, name, material_id from standard where state = 1) s on m.id = s.material_id
                 left join (select id, name, standard_id from specifications where state = 1) s2
                           on s2.standard_id = s.id
                 left join (select id, name, specifications_id from product where state = 1) p
                           on s2.id = p.specifications_id
    </select>
 
    <select id="selectMcodeId" resultType="com.yuanchu.mom.pojo.Material">
        select id, code
        from mom_ocean.material
        where name = #{name}
    </select>
 
    <select id="selectIdByCoNa" resultType="java.util.Map">
        select m.id     '物料id',
               st.id    '规格id',
               st.name  '规格名称',
               sp.name  '型号名称'
        from mom_ocean.material m,
             mom_ocean.standard st,
             mom_ocean.specifications sp
        where m.id = material_id
          and material_id = standard_id
          and m.name = #{name}
          and code = #{code}
    </select>
</mapper>