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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?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.TechniqueMapper">
    <!--根据技术指标id删除-->
    <update id="delByProId">
        update mom_ocean.technique
        set state=0
        where technology_id = (select technology_id from mom_ocean.product where product.id = #{id})
          and product_father = (select father from mom_ocean.product where product.id = #{id})
          and product = (select name from mom_ocean.product where product.id = #{id})
    </update>
    <!--根据技术指标id批量删除-->
    <update id="delAll">
        update mom_ocean.technique
        set state=0
        where technology_id in (select technology_id from mom_ocean.product where product.id in (${ids}))
          and product_father in (select father from mom_ocean.product where product.id in (${ids}))
          and product in (select name from mom_ocean.product where product.id in (${ids}))
    </update>
    <!--根据型号id查询所有版本-->
    <select id="selectVerByTeq" resultType="java.lang.Integer">
        select distinct version
        from mom_ocean.technique
        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="name" column="name"/>
        <collection property="children" resultMap="threeMap" javaType="List"/>
    </resultMap>
    <resultMap id="threeMap" type="map">
        <result property="device" column="device"/>
        <collection property="children" resultMap="fourMap" javaType="List"/>
    </resultMap>
    <resultMap id="fourMap" type="map">
        <result property="productFather" column="product_father"/>
        <collection property="children" resultMap="fiveMap" javaType="List"/>
    </resultMap>
    <resultMap id="fiveMap" type="map">
        <id property="tqid" column="tqid"/>
        <result property="product" column="product"/>
        <result property="unit" column="unit"/>
    </resultMap>
    <select id="selectAllTeq" resultMap="oneMap">
        select tq.id tqid,
        device,
        product_father,
        product,
        unit,
        name,
        father
        from mom_ocean.technique tq
        left join mom_ocean.technology tc on tq.technology_id = tc.id
        where tq.state = 1
        and specifications_id = #{specificationsId}
        and tq.version = #{version}
        <if test="message!=null and message!=''">
            and device like concat('%',#{message},'%')
        </if>
    </select>
 
    <!--右上角新增-生产工艺-选择设备-->
    <select id="chooseDev" resultType="java.util.Map">
        select name device
        from mom_ocean.device
        where state = 1
          and device_status in (1, 5)
          and father = (select distinct device_group
                        from mom_ocean.technology
                        where technology.state = 1
                          and technology.id = #{technologyId})
    </select>
 
    <!--右上角新增-生产工艺-选择项目(父子),单位-->
    <resultMap id="chooseProMap" type="map">
        <id property="name" column="productFather"/>
        <collection property="children" resultMap="chooseProMaps" javaType="List"/>
    </resultMap>
    <resultMap id="chooseProMaps" type="map">
        <id property="name" column="product"/>
        <result property="unit" column="unit"/>
    </resultMap>
    <select id="choosePro" resultMap="chooseProMap">
        select name   product,
               father productFather,
               unit
        from mom_ocean.product
        where state = 1
          and technology_id = #{technologyId}
    </select>
 
    <!--根据型号id查询该型号下所有工艺的生产工艺-->
    <select id="selAllBySpeId" resultType="com.yuanchu.mom.pojo.Technique">
        select *
        from mom_ocean.technique
        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查询所有版本-->
    <select id="selectVerByTeId" resultType="java.lang.Integer">
        select distinct version
        from mom_ocean.technique
        where state = 1
          and technology_id = #{technologyId}
    </select>
 
    <!--查询该工艺下最新版本在一个检验项目下可以使用哪些设备-->
    <select id="selDevByVerTecIdFaNam" resultType="java.util.Map">
        select device.id, device
        from mom_ocean.technique
                 left join mom_ocean.device on name = device
        where technique.state = 1
          and technology_id = #{technologyId}
          and product_father = #{father}
          and product = #{name}
          and version = #{ver}
    </select>
 
    <!--根据id查看详情-->
    <select id="selTeqById" resultType="java.util.Map">
        select m.father,
               type,
               m.name,
               st.name,
               sp.name,
               t.father,
               t.name,
               technology_id,
               device,
               product_father,
               product,
               unit
        from mom_ocean.technique tq
                 left join mom_ocean.technology t on tq.technology_id = t.id
                 left join mom_ocean.specifications sp on t.specifications_id = sp.id
                 left join mom_ocean.standard st on sp.standard_id = st.id
                 left join mom_ocean.material m on st.material_id = m.id
        where tq.state = 1
          and tq.id = #{id}
    </select>
 
    <!--根据工艺路线id删除生产工艺-->
    <update id="delTeqByTecId">
        update mom_ocean.technique
        set state=0
        where technology_id = #{id}
    </update>
 
    <!--根据工艺路线id批量删除-->
    <update id="delAllByTecId">
        update mom_ocean.technique
        set state=0
        where technology_id in (${ids})
    </update>
 
    <!--根据生产工艺id批量删除-->
    <update id="delAllTeq">
        update mom_ocean.technique
        set state=0
        where id in (${ids})
    </update>
</mapper>