懒羊羊
2024-03-15 b773030f37dc06a92bdb80e8af9a408843d5b317
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?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.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper">
    
    <resultMap type="BsFormulaChildInfo" id="BsFormulaChildInfoResult">
        <result property="id"    column="id"    />
        <result property="workshopCode"    column="workshop_code"    />
        <result property="lineCode"    column="line_code"    />
        <result property="processesCode"    column="processes_code"    />
        <result property="productCode"    column="product_code"    />
        <result property="operationSteps"    column="operation_steps"    />
        <result property="techRequirement"    column="tech_requirement"    />
        <result property="operationType"    column="operation_type"    />
        <result property="stepSort"    column="step_sort"    />
        <result property="paramCode"    column="param_code"    />
        <result property="materialCode"    column="material_code"    />
        <result property="formulaCode"    column="formula_code"    />
        <result property="picture"    column="picture"    />
        <result property="remarks"    column="remarks"    />
        <result property="createUser"    column="create_user"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateUser"    column="update_user"    />
        <result property="updateTime"    column="update_time"    />
        <result property="spareField1"    column="spare_field_1"    />
        <result property="spareField2"    column="spare_field_2"    />
        <result property="spareField3"    column="spare_field_3"    />
        <result property="spareField4"    column="spare_field_4"    />
        <result property="collectData"    column="collect_data"    />
        <result property="results"    column="results"    />
        <result property="counts"    column="counts"    />
 
    </resultMap>
 
    <sql id="selectBsFormulaChildInfoVo">
        select id, workshop_code, line_code, processes_code, product_code, operation_steps, tech_requirement, operation_type, step_sort, param_code, material_code, formula_code, picture, remarks, create_user, create_time, update_user, update_time, spare_field_1, spare_field_2, spare_field_3, spare_field_4, collect_data, results from bs_formula_child_info
    </sql>
 
    <select id="selectBsFormulaChildInfoList" parameterType="BsFormulaChildInfo" resultMap="BsFormulaChildInfoResult">
        <include refid="selectBsFormulaChildInfoVo"/>
        <where>  
            <if test="workshopCode != null  and workshopCode != ''"> and workshop_code like concat('%', #{workshopCode}, '%')</if>
            <if test="lineCode != null  and lineCode != ''"> and line_code like concat('%', #{lineCode}, '%')</if>
            <if test="processesCode != null  and processesCode != ''"> and processes_code like concat('%', #{processesCode}, '%')</if>
            <if test="productCode != null  and productCode != ''"> and product_code like concat('%', #{productCode}, '%')</if>
            <if test="operationType != null  and operationType != ''"> and operation_type like concat('%', #{operationType}, '%')</if>
            <if test="formulaCode != null  and formulaCode != ''"> and formula_code like concat('%', #{formulaCode}, '%')</if>
            <if test="collectData != null  and collectData != ''"> and collect_data = #{collectData}</if>
            <if test="results != null  and result != ''"> and result = #{results}</if>
            <if test="materialCode != null  and materialCode != ''"> and material_code = #{materialCode}</if>
            <if test="paramCode != null  and paramCode != ''"> and param_code = #{paramCode}</if>
 
 
        </where>
        ORDER BY step_sort ASC
    </select>
    
    <select id="selectBsFormulaChildInfoById" parameterType="Long" resultMap="BsFormulaChildInfoResult">
        <include refid="selectBsFormulaChildInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBsFormulaChildInfo" parameterType="BsFormulaChildInfo" useGeneratedKeys="true" keyProperty="id">
        insert into bs_formula_child_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workshopCode != null">workshop_code,</if>
            <if test="lineCode != null">line_code,</if>
            <if test="processesCode != null">processes_code,</if>
            <if test="productCode != null">product_code,</if>
            <if test="operationSteps != null">operation_steps,</if>
            <if test="techRequirement != null">tech_requirement,</if>
            <if test="operationType != null">operation_type,</if>
            <if test="stepSort != null">step_sort,</if>
            <if test="paramCode != null">param_code,</if>
            <if test="materialCode != null">material_code,</if>
            <if test="formulaCode != null">formula_code,</if>
            <if test="picture != null">picture,</if>
            <if test="remarks != null">remarks,</if>
            <if test="createUser != null">create_user,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateUser != null">update_user,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="spareField1 != null">spare_field_1,</if>
            <if test="spareField2 != null">spare_field_2,</if>
            <if test="spareField3 != null">spare_field_3,</if>
            <if test="spareField4 != null">spare_field_4,</if>
            <if test="collectData != null">collect_data,</if>
            <if test="results != null">results,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workshopCode != null">#{workshopCode},</if>
            <if test="lineCode != null">#{lineCode},</if>
            <if test="processesCode != null">#{processesCode},</if>
            <if test="productCode != null">#{productCode},</if>
            <if test="operationSteps != null">#{operationSteps},</if>
            <if test="techRequirement != null">#{techRequirement},</if>
            <if test="operationType != null">#{operationType},</if>
            <if test="stepSort != null">#{stepSort},</if>
            <if test="paramCode != null">#{paramCode},</if>
            <if test="materialCode != null">#{materialCode},</if>
            <if test="formulaCode != null">#{formulaCode},</if>
            <if test="picture != null">#{picture},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="createUser != null">#{createUser},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateUser != null">#{updateUser},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="spareField1 != null">#{spareField1},</if>
            <if test="spareField2 != null">#{spareField2},</if>
            <if test="spareField3 != null">#{spareField3},</if>
            <if test="spareField4 != null">#{spareField4},</if>
            <if test="collectData != null">collect_data,</if>
            <if test="results != null">results,</if>
         </trim>
    </insert>
 
    <update id="updateBsFormulaChildInfo" parameterType="BsFormulaChildInfo">
        update bs_formula_child_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="workshopCode != null">workshop_code = #{workshopCode},</if>
            <if test="lineCode != null">line_code = #{lineCode},</if>
            <if test="processesCode != null">processes_code = #{processesCode},</if>
            <if test="productCode != null">product_code = #{productCode},</if>
            <if test="operationSteps != null">operation_steps = #{operationSteps},</if>
            <if test="techRequirement != null">tech_requirement = #{techRequirement},</if>
            <if test="operationType != null">operation_type = #{operationType},</if>
            <if test="stepSort != null">step_sort = #{stepSort},</if>
            <if test="paramCode != null">param_code = #{paramCode},</if>
            <if test="materialCode != null">material_code = #{materialCode},</if>
            <if test="formulaCode != null">formula_code = #{formulaCode},</if>
            <if test="picture != null">picture = #{picture},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="createUser != null">create_user = #{createUser},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateUser != null">update_user = #{updateUser},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="spareField1 != null">spare_field_1 = #{spareField1},</if>
            <if test="spareField2 != null">spare_field_2 = #{spareField2},</if>
            <if test="spareField3 != null">spare_field_3 = #{spareField3},</if>
            <if test="spareField4 != null">spare_field_4 = #{spareField4},</if>
            <if test="collectData != null">collect_data = #{collectData},</if>
            <if test="results != null">results = #{results},</if>
        </trim>
        where id = #{id}
    </update>
 
    <delete id="deleteBsFormulaChildInfoById" parameterType="Long">
        delete from bs_formula_child_info where id = #{id}
    </delete>
 
    <delete id="deleteBsFormulaChildInfoByIds" parameterType="String">
        delete from bs_formula_child_info where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <select id="selectBsFormulaChildInfoByTypeTopOne" parameterType="BsFormulaChildInfo" resultMap="BsFormulaChildInfoResult">
--         SELECT
--             TOP 1 *
--         FROM
--             bs_formula_child_info
--         WHERE NOT results = 'OK'
--           AND product_code =  #{productCode}
--           AND processes_code = #{processesCode}
--           AND operation_type = #{operationType}
--         ORDER BY step_sort ASC
        SELECT
            TOP 1 *
        FROM
            bs_formula_child_info
        WHERE
            processes_code = #{processesCode}
          AND product_code = #{productCode}
          AND operation_type = #{operationType}
          AND (results IS NULL OR results = '')
        ORDER BY step_sort ASC
    </select>
 
    <select id="getCount" parameterType="BsFormulaChildInfo" resultMap="BsFormulaChildInfoResult">
        SELECT COUNT(*) AS counts
        FROM bs_formula_child_info
        WHERE (processes_code = #{processesCode} AND product_code = #{productCode})
          AND (results IS NULL OR results = '');
    </select>
 
    <select id="releaseCheck" parameterType="BsFormulaChildInfo" resultMap="BsFormulaChildInfoResult">
        SELECT COUNT(*) AS counts
        FROM bs_formula_child_info
        WHERE (processes_code = #{processesCode} AND product_code = #{productCode})
          AND (results IS NULL OR results = '');
    </select>
 
    <update id="workpieceRelease" parameterType="BsFormulaChildInfo">
        UPDATE bs_formula_child_info
        SET results = ''
        WHERE
            product_code = #{productCode}
          AND processes_code = #{processesCode};
    </update>
</mapper>