zss
2023-09-13 2d6a0cdcb1e31510a6f7776abab17cc5cb82fdcb
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
71
72
73
74
75
76
77
78
79
80
81
82
<?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.MbomMapper">
    <!--根据型号id查询所有版本-->
    <select id="selectVerByMbom" resultType="java.lang.Integer">
        select distinct version
        from mom_ocean.mbom
        where state = 1
          and technology_id in (select id
                                from mom_ocean.technology
                                where technology.state = 1
                                  and specifications_id = #{specificationsId})
        order by version desc
    </select>
 
    <!--右侧数据展示 物料清单-->
    <resultMap id="oneMap" type="map">
        <id property="father" column="father"/>
        <collection property="children" resultMap="twoMap" javaType="List"/>
    </resultMap>
    <resultMap id="twoMap" type="map">
        <id property="tname" column="tname"/>
        <collection property="children" resultMap="threeMap" javaType="List"/>
    </resultMap>
    <resultMap id="threeMap" type="map">
        <id property="id" column="mid"/>
        <result property="mname" column="mname"/>
        <result property="specifications" column="specifications"/>
        <result property="unit" column="unit"/>
        <result property="num" column="num"/>
    </resultMap>
    <select id="selectAllMbom" resultMap="oneMap">
        select m.id mid,
        m.name mname,
        unit,
        num,
        specifications,
        t.name tname,
        father
        from mom_ocean.mbom m
        left join mom_ocean.technology t on m.technology_id = t.id
        where m.state = 1
        and m.version = #{version}
        and specifications_id = #{specificationsId}
        <if test="message!=null and message!=''">
            and m.name like concat('%',#{message},'%')
        </if>
    </select>
 
    <!--根据型号id查询该型号下所有工艺需要的物料清单-->
    <select id="selAllBySpeId" resultType="com.yuanchu.mom.pojo.Mbom">
        select *
        from mom_ocean.mbom
        where state = 1
          and version = #{version}
          and technology_id in (select id
                                from mom_ocean.technology
                                where technology.state = 1
                                  and specifications_id = #{specificationsId})
    </select>
 
    <!--根据工艺路线id删除物料清单-->
    <update id="delMbomByTecId">
        update mom_ocean.mbom
        set state=0
        where technology_id = #{id}
    </update>
 
    <!--根据工艺路线id批量删除-->
    <update id="delAllByTecId">
        update mom_ocean.mbom
        set state=0
        where technology_id in (${ids})
    </update>
 
    <!--根据物料清单id批量删除-->
    <update id="delAllMbom">
        update mom_ocean.mbom
        set state=0
        where id in (${ids})
    </update>
</mapper>