ReceiptContainerDetailMapper.xml
2.89 KB
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
<?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.huaheng.pc.receipt.receiptContainerDetail.mapper.ReceiptContainerDetailMapper">
<select id="ListEntityByLike" resultType="com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail">
SELECT H.id, H.headerId, H.receiptDetailId, D.materialCode,M.Name as 'materialName',M.specification as 'materialSpec',
D.batch,D.lot, H.qty, H.created, H.createdBy
FROM receipt_container_detail H left join receipt_detail D ON H.receiptDetailId=D.Id
INNER JOIN material M ON m.`code`=D.materialCode and m.`enable`=TRUE and m.deleted=FALSE
<where>
<if test="id != null ">
AND H.id = #{id}
</if>
<if test="headerId != null ">
AND H.headerId = #{headerId}
</if>
<if test="receiptId != null ">
AND H.receiptId = #{receiptId}
</if>
<if test="receiptDetailId != null ">
AND H.receiptDetailId = #{receiptDetailId}
</if>
<if test="materialCode != null and materialCode != ''">
<bind name="materialCodePattern" value="'%' + materialCode + '%'" />
AND D.materialCode like #{materialCodePattern}
</if>
<if test="qty != null ">
AND H.qty = #{qty}
</if>
<if test="params != null and params.createdBegin != null and params.createdBegin != ''">
AND H.created >= #{params.createdBegin}
</if>
<if test="params != null and params.createdEnd != null and params.createdEnd != ''">
AND H.created <= #{params.createdEnd}
</if>
<if test="createdBy != null and createdBy != ''">
<bind name="createdByPattern" value="'%' + createdBy + '%'" />
AND H.createdBy like #{createdByPattern}
</if>
</where>
</select>
<select id="countByHeaderId" resultType="java.lang.Integer">
select count(1) from receipt_container_detail where headerId =#{headerId}
</select>
<select id="countByReceiptId" resultType="java.lang.Integer">
select count(1) from receipt_container_detail where receiptId =#{receiptId}
</select>
<delete id="batchDelete">
DELETE FROM receipt_container_detail WHERE id in
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="updateReceiptDetailQty">
UPDATE receipt_detail SET qtyCompleted = qtyCompleted - #{qty} WHERE id = #{id}
</update>
<update id="updateReceiptDetailStatus">
UPDATE receipt_detail SET `status` = 0 WHERE qtyCompleted = 0 AND id = #{id}
</update>
</mapper>