wzy
2021-04-01 d388e2788b7ef088d7cd40f901b0acdcec460bc3
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<?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.matrix.system.hive.dao.SysCheckInfoDao">
    
    <resultMap type="SysCheckInfo" id="SysCheckInfoMap">
            <id property="id" column="ID" />
            <result property="checkNo" column="CHECK_NO" />
            <result property="checkType" column="CHECK_TYPE" />
            <result property="checkStoreid" column="CHECK_STORE_ID" />
            <result property="createDate" column="create_Date" />
            <result property="makingManId" column="MAKINGMAN_ID" />
            <result property="appManId" column="APPMAN_ID" />
            <result property="checkDate" column="CHECK_DATE" />
            <result property="appRemark" column="APP_REMARK" />
            <result property="checkStatus" column="CHECK_STATUS" />
            <result property="remark" column="REMARK" />
            <result property="shopId" column="shop_id"/>
            <result property="companyId" column="company_id"/>
 
            <!-- 扩展属性 -->    
            <result property="checkStoreName" column="CHECK_STORE_NAME" />
            <result property="makingManName" column="MAKING_MAN_NAME" />            
            <result property="appManName" column="APP_MAN_NAME" />
            
    </resultMap>  
    
    <!-- 获得调拨单明细 -->
    <select id="getCheckDetailInfo" resultMap="com.matrix.system.hive.dao.SysCheckDetailDao.SysCheckDetailMap">
        select 
            id,
            check_id,
            sku_id,
            begin_balance,
            income_num,
            outcome_num,
            end_balance,
            price,
            priceSum,
            actuallySum,
            remark
        from 
            sys_check_detail
        where
            check_id=#{checkId}
    </select> 
    
    
    
    <!--  插入方法   -->
    <insert id="insert" parameterType="SysCheckInfo"
        useGeneratedKeys="true" keyProperty="id">
        INSERT INTO sys_check_info (
            ID,
            CHECK_NO,
            CHECK_TYPE,
            CHECK_STORE_ID,
            create_Date,
            MAKINGMAN_ID,
            APPMAN_ID,
            CHECK_DATE,
            APP_REMARK,
            CHECK_STATUS,
            REMARK,
            shop_id,
            company_id
        )
    VALUES (
            #{id},
            #{checkNo},
            #{checkType},
            #{checkStoreid},
            #{createDate},
            #{makingManId},
            #{appManId},
            #{checkDate},
            #{appRemark},
            #{checkStatus},
            #{remark},
            #{shopId},
            #{companyId}
    )
    </insert>
    
    
    <!--  根据id更新 部分更新   -->
    <update id="update" >
        UPDATE sys_check_info
        <set>
                <if test="checkNo != null and checkNo !='' ">
                    CHECK_NO = #{checkNo},
                </if>        
                <if test="checkType != null and checkType !='' ">
                    CHECK_TYPE = #{checkType},
                </if>        
                <if test="checkStoreid != null and checkStoreid !='' ">
                    CHECK_STORE_ID = #{checkStoreid},
                </if>        
                <if test="createDate != null ">
                    create_Date = #{createDate},
                </if>        
                <if test="makingManId != null and makingManId !='' ">
                    MAKINGMAN_ID = #{makingManId},
                </if>        
                <if test="appManId != null and appManId !='' ">
                    APPMAN_ID = #{appManId},
                </if>        
                <if test="checkDate != null and checkDate !='' ">
                    CHECK_DATE = #{checkDate},
                </if>        
                <if test="appRemark != null and appRemark !='' ">
                    APP_REMARK = #{appRemark},
                </if>    
                <if test="checkStatus != null and checkStatus !='' ">
                    CHECK_STATUS = #{checkStatus},
                </if>    
                <if test="remark != null and remark !='' ">
                    REMARK = #{remark},
                </if>                    
                    
        </set>
        WHERE ID=#{id} 
    </update>
    
    
    
    <!-- 批量删除 -->
    <delete id="deleteByIds" parameterType="java.util.List">
        delete from sys_check_info where  ID in
        <foreach collection="list" index="index" item="item" open="("
            separator="," close=")">
            #{item}
        </foreach>
    </delete>
        
    <!-- 根据id删除-->
    <delete id="deleteById" >
        DELETE FROM sys_check_info
        where  ID=#{id} 
    </delete>
    
    
    
    <!-- 分页查询 -->
    <select id="selectInPage" resultMap="SysCheckInfoMap">
        select 
            ID,
            CHECK_NO,
            CHECK_TYPE,
            CHECK_STORE_ID,
        (select NAME from warehouse t where t.id=CHECK_STORE_ID) CHECK_STORE_NAME,
            create_Date,
            MAKINGMAN_ID,
            (select su_name from sys_users t where t.su_id=  MAKINGMAN_ID) MAKING_MAN_NAME,
            APPMAN_ID,
            (select su_name from sys_users t where t.su_id=  APPMAN_ID) APP_MAN_NAME,
            CHECK_DATE,
            APP_REMARK,
            CHECK_STATUS,
            REMARK,
            shop_id,
            company_id
        from sys_check_info
        where 1=1
        <if test="record!=null">
            <if test="record.id != null and record.id !='' ">
                and ID = #{record.id}
            </if>
            <if test="record.checkNo != null and record.checkNo !='' ">
                and CHECK_NO = #{record.checkNo}
            </if>
            <if test="record.checkType != null and record.checkType !='' ">
                and CHECK_TYPE = #{record.checkType}
            </if>
            <if test="record.checkStoreid != null and record.checkStoreid !='' ">
                and CHECK_STORE_ID = #{record.checkStoreid}
            </if>
            <if test="record.makingManId != null and record.makingManId !='' ">
                and MAKINGMAN_ID = #{record.makingManId}
            </if>
            <if test="record.appManId != null and record.appManId !='' ">
                and APPMAN_ID = #{record.appManId}
            </if>
            <if test="record.startTime != null  ">
                <![CDATA[
                and create_Date >= #{record.startTime}
                ]]>
            </if>
            <if test="record.endTime != null  ">
                <![CDATA[
                     and create_Date <= #{record.endTime}
                ]]>
            </if>    
            <if test="record.checkDate != null and record.checkDate !='' ">
                and CHECK_DATE = #{record.checkDate}
            </if>        
            <if test="record.appRemark != null and record.appRemark !='' ">
                and APP_REMARK = #{record.appRemark}
            </if>
            <if test="record.checkStatus != null and record.checkStatus !='' ">
                and CHECK_STATUS = #{record.checkStatus}
            </if>
            <if test="record.remark != null and record.remark !='' ">
                and REMARK = #{record.remark}
            </if>
            <if test="record.shopId != null and record.shopId !='' ">
                and shop_id = #{record.shopId}
            </if>
            <if test="record.companyId != null and record.companyId !='' ">
                and company_id = #{record.companyId}
            </if>
        </if>
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
            <if test="pageVo.sort !=null  and pageVo.order !=null">
                order by
                ${pageVo.sort} ${pageVo.order}
            </if>
            <if test="pageVo.offset >=0  and pageVo.limit >0">
                limit
                #{pageVo.offset},#{pageVo.limit}
            </if>
        </if>
    </select>
    
    <!-- 查询总条 -->
    <select id="selectTotalRecord"    resultType="java.lang.Integer">
    select count(*)
    from sys_check_info
        where 1=1
        <if test="record!=null">
            <if test="record.id != null and record.id !='' ">
                and ID = #{record.id}
            </if>
            <if test="record.checkNo != null and record.checkNo !='' ">
                and CHECK_NO = #{record.checkNo}
            </if>
            <if test="record.checkType != null and record.checkType !='' ">
                and CHECK_TYPE = #{record.checkType}
            </if>
            <if test="record.checkStoreid != null and record.checkStoreid !='' ">
                and CHECK_STORE_ID = #{record.checkStoreid}
            </if>
            <if test="record.makingManId != null and record.makingManId !='' ">
                and MAKINGMAN_ID = #{record.makingManId}
            </if>
            <if test="record.appManId != null and record.appManId !='' ">
                and APPMAN_ID = #{record.appManId}
            </if>
            <if test="record.startTime != null  ">
                <![CDATA[
                and create_Date >= #{record.startTime}
                ]]>
            </if>
            <if test="record.endTime != null  ">
                <![CDATA[
                     and create_Date <= #{record.endTime}
                ]]>
            </if>    
            <if test="record.checkDate != null and record.checkDate !='' ">
                and CHECK_DATE = #{record.checkDate}
            </if>    
            <if test="record.appRemark != null and record.appRemark !='' ">
                and APP_REMARK = #{record.appRemark}
            </if>
            <if test="record.checkStatus != null and record.checkStatus !='' ">
                and CHECK_STATUS = #{record.checkStatus}
            </if>
            <if test="record.remark != null and record.remark !='' ">
                and REMARK = #{record.remark}
            </if>
            <if test="record.shopId != null and record.shopId !='' ">
                and shop_id = #{record.shopId}
            </if>
            <if test="record.companyId != null and record.companyId !='' ">
                and company_id = #{record.companyId}
            </if>
        </if>
    </select>
 
    <!-- 根据id查询-->
    <select id="selectById" resultMap="SysCheckInfoMap">
        select 
            ID,
            CHECK_NO,
            CHECK_TYPE,
            CHECK_STORE_ID,
            (select NAME from warehouse t where t.id=CHECK_STORE_ID) CHECK_STORE_NAME,
            create_Date,
            MAKINGMAN_ID,
            (select su_name from sys_users t where t.su_id=  MAKINGMAN_ID) MAKING_MAN_NAME,
            APPMAN_ID,
            (select su_name from sys_users t where t.su_id=  APPMAN_ID) APP_MAN_NAME,
            CHECK_DATE,
            APP_REMARK,
            CHECK_STATUS,
            REMARK,
            shop_id,
            company_id
        from sys_check_info
        where  id=#{id} 
    </select>    
    
    
    <!-- 根据对象查询-->
    <select id="selectByModel" resultMap="SysCheckInfoMap">
        select 
            ID,
            CHECK_NO,
            CHECK_TYPE,
            CHECK_STORE_ID,
        (select NAME from warehouse t where t.id=CHECK_STORE_ID) CHECK_STORE_NAME,
            create_Date,
            MAKINGMAN_ID,
            (select su_name from sys_users t where t.su_id=  MAKINGMAN_ID) MAKING_MAN_NAME,
            APPMAN_ID,
            (select su_name from sys_users t where t.su_id=  APPMAN_ID) APP_MAN_NAME,
            CHECK_DATE,
            APP_REMARK,
            CHECK_STATUS,
            REMARK,
            shop_id,
            company_id
        from sys_check_info
        where 1=1
        <if test="record!=null">
            <if test="record.id != null and record.id !='' ">
                and ID = #{record.id}
            </if>
            <if test="record.checkNo != null and record.checkNo !='' ">
                and CHECK_NO = #{record.checkNo}
            </if>
            <if test="record.checkType != null and record.checkType !='' ">
                and CHECK_TYPE = #{record.checkType}
            </if>
            <if test="record.checkStoreid != null and record.checkStoreid !='' ">
                and CHECK_STORE_ID = #{record.checkStoreid}
            </if>
            <if test="record.createDate != null  ">
                and create_Date = #{record.createDate}
            </if>
            <if test="record.makingManId != null and record.makingManId !='' ">
                and MAKINGMAN_ID = #{record.makingManId}
            </if>
            <if test="record.appManId != null and record.appManId !='' ">
                and APPMAN_ID = #{record.appManId}
            </if>
            <if test="record.startTime != null  ">
                and CHECK_DATE >= #{record.startTime}
            </if>
            <if test="record.endTime != null  ">
                <![CDATA[
                     and CHECK_DATE = #{record.endTime}
                ]]>
            </if>
            <if test="record.appRemark != null and record.appRemark !='' ">
                and APP_REMARK = #{record.appRemark}
            </if>
            <if test="record.checkStatus != null and record.checkStatus !='' ">
                and CHECK_STATUS = #{record.checkStatus}
            </if>
            <if test="record.remark != null and record.remark !='' ">
                and REMARK = #{record.remark}
            </if>
            <if test="record.shopId != null and record.shopId !='' ">
                and shop_id = #{record.shopId}
            </if>
            <if test="record.companyId != null and record.companyId !='' ">
                and company_id = #{record.companyId}
            </if>
        </if>
    </select>
    
    
    <select id="insertDetail">
    call pro_check(#{storeId},#{checkId});
    </select>
</mapper>