ShipmentsOrderInfoMapper.xml
4.75 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
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
<?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.lframework.xingyun.sc.mappers.ShipmentsOrderInfoMapper">
<resultMap id="ShipmentsOrderInfo" type="com.lframework.xingyun.sc.entity.ShipmentsOrderInfo">
<id column="id" property="id"/>
<result column="plan_id" property="planId"/>
<result column="customer_id" property="customerId"/>
<result column="customer_name" property="customerName"/>
<result column="workshop_id" property="workshopId"/>
<result column="workshop_name" property="workshopName"/>
<result column="shipments_date" property="shipmentsDate"/>
<result column="dept_id" property="deptId"/>
<result column="region" property="region"/>
<result column="delivery_type" property="deliveryType"/>
<result column="destination" property="destination"/>
<result column="status" property="status"/>
<result column="create_by_id" property="createById"/>
<result column="update_by_id" property="updateById"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="ShipmentsOrderInfo_sql">
SELECT
tb.id,
tb.plan_id,
tb.customer_id,
c.name AS customer_name,
tb.workshop_id,
w.name AS workshop_name,
tb.shipments_date,
tb.dept_id,
tb.region,
tb.delivery_type,
tb.destination,
tb.status,
u.name as create_by,
tb.create_by_id,
tb.update_by_id,
tb.create_time,
tb.update_time
FROM shipments_order_info AS tb
LEFT JOIN base_data_customer c ON tb.customer_id = c.id
LEFT JOIN base_data_workshop w ON tb.workshop_id = w.id
LEFT JOIN sys_user u ON tb.create_by_id = u.id
</sql>
<select id="query" resultMap="ShipmentsOrderInfo">
<include refid="ShipmentsOrderInfo_sql"/>
<where>
<if test="vo.workshopId != null and vo.workshopId != ''">
AND tb.workshop_id = #{vo.workshopId}
</if>
<if test="vo.shipmentsDateStart != null">
AND tb.shipments_date >= #{vo.shipmentsDateStart}
</if>
<if test="vo.shipmentsDateEnd != null">
AND tb.shipments_date <= #{vo.shipmentsDateEnd}
</if>
<if test="vo.deptIds != null and vo.deptIds.size() > 0">
AND (
<foreach collection="vo.deptIds" item="deptId" separator=" OR ">
FIND_IN_SET(#{deptId}, tb.dept_id) > 0
</foreach>
)
</if>
<if test="vo.status != null and vo.status != ''">
AND tb.status = #{vo.status}
</if>
<if test="vo.customerName != null and vo.customerName != ''">
AND c.name like concat('%', #{vo.customerName}, '%')
</if>
</where>
ORDER BY tb.create_time DESC
</select>
<insert id="batchAdd">
INSERT INTO shipments_order_info (
id,
plan_id,
customer_id,
workshop_id,
shipments_date,
dept_id,
region,
delivery_type,
destination,
payment_type,
status,
create_by_id,
update_by_id
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.planId},
#{item.customerId},
#{item.workshopId},
#{item.shipmentsDate},
#{item.deptId},
#{item.region},
#{item.deliveryType},
#{item.destination},
#{item.paymentType},
#{item.status},
#{item.createById},
#{item.updateById}
)
</foreach>
</insert>
<select id="queryByIds" resultType="com.lframework.xingyun.sc.entity.ShipmentsOrderInfo">
<include refid="ShipmentsOrderInfo_sql"/>
where tb.id in
<foreach collection="ids" open="(" separator="," close=")" item="item">
#{item}
</foreach>
</select>
<select id="statisticsActualNum" resultType="java.util.Map">
select o.customer_id,sum(d.actual_shipment_quantity) as actual_num
from shipments_order_info o
inner join shipments_plan_detail d on o.id = d.shipment_order_id
where o.customer_id in
<foreach collection="customerIds" open="(" separator="," close=")" item="item">
#{item}
</foreach>
group by o.customer_id
</select>
</mapper>