SupplierQuotationProjectMapper.xml
5.29 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
<?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.procurement.mappers.quotation.SupplierQuotationProjectMapper">
<resultMap id="SupplierQuotationProject" type="com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject">
<id column="id" property="id"/>
<result column="code" property="code"/>
<result column="name" property="name"/>
<result column="product_id" property="productId"/>
<result column="product_name" property="productName"/>
<result column="product_code" property="productCode"/>
<result column="quantity" property="quantity"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
<result column="project_type" property="projectType"/>
<result column="bid_time" property="bidTime"/>
<result column="purchase_rule" property="purchaseRule"/>
<result column="status" property="status"/>
<result column="supplier_department_id" property="supplierDepartmentId"/>
<result column="supplier_department_name" property="supplierDepartmentName"/>
<result column="create_by_id" property="createById"/>
<result column="create_by" property="createBy"/>
<result column="update_by_id" property="updateById"/>
<result column="update_by" property="updateBy"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="SupplierQuotationProjectSql">
SELECT
tb.id,
tb.code,
tb.name,
tb.product_id,
br.product_name,
br.code AS product_code,
tb.quantity,
tb.start_time,
tb.end_time,
tb.project_type,
tb.bid_time,
tb.purchase_rule,
tb.status,
tb.supplier_department_id,
sd.name AS supplier_department_name,
tb.create_by_id,
tb.create_by,
tb.update_by_id,
tb.update_by,
tb.create_time,
tb.update_time
FROM procurement_supplier_quotation_project tb
LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id
LEFT JOIN sys_dept sd ON sd.id = tb.supplier_department_id
</sql>
<select id="query" resultMap="SupplierQuotationProject">
<include refid="SupplierQuotationProjectSql"/>
<where>
<if test="vo.name != null and vo.name != ''">
AND tb.name LIKE CONCAT('%', #{vo.name}, '%')
</if>
<if test="vo.startTimeStart != null">
AND tb.start_time <![CDATA[ >= ]]> #{vo.startTimeStart}
</if>
<if test="vo.startTimeEnd != null">
AND tb.start_time <![CDATA[ <= ]]> #{vo.startTimeEnd}
</if>
<if test="vo.endTimeStart != null">
AND tb.end_time <![CDATA[ >= ]]> #{vo.endTimeStart}
</if>
<if test="vo.endTimeEnd != null">
AND tb.end_time <![CDATA[ <= ]]> #{vo.endTimeEnd}
</if>
<if test="vo.bidTimeStart != null">
AND tb.bid_time <![CDATA[ >= ]]> #{vo.bidTimeStart}
</if>
<if test="vo.bidTimeEnd != null">
AND tb.bid_time <![CDATA[ <= ]]> #{vo.bidTimeEnd}
</if>
<!-- 供应商数据权限过滤 -->
<if test="vo.currentSupplierDeptIds != null and vo.currentSupplierDeptIds.size() > 0">
AND (
tb.supplier_department_id in
<foreach collection="vo.currentSupplierDeptIds" open="(" separator="," close=")" item="item">
#{item}
</foreach>
OR
tb.supplier_department_id IS NULL
)
</if>
</where>
ORDER BY tb.create_time DESC, tb.id DESC
</select>
<select id="findById" resultMap="SupplierQuotationProject">
<include refid="SupplierQuotationProjectSql"/>
WHERE tb.id = #{id}
</select>
<select id="getMaxCodeByDay" resultType="java.lang.String">
SELECT tb.code
FROM procurement_supplier_quotation_project tb
WHERE tb.code LIKE CONCAT(#{dayPrefix}, '%')
ORDER BY CAST(RIGHT(tb.code, 2) AS UNSIGNED) DESC
LIMIT 1
</select>
<select id="queryCurrentMonthList" resultMap="SupplierQuotationProject">
<include refid="SupplierQuotationProjectSql"/>
WHERE tb.create_time <![CDATA[ >= ]]> CONCAT(#{monthStart}, ' 00:00:00')
AND tb.create_time <![CDATA[ < ]]> CONCAT(#{nextMonthStart}, ' 00:00:00')
AND tb.status='PUBLISHED'
ORDER BY tb.create_time DESC, tb.id DESC
</select>
<select id="queryCurrentMonthFinishedList" resultMap="SupplierQuotationProject">
<include refid="SupplierQuotationProjectSql"/>
WHERE tb.create_time <![CDATA[ >= ]]> CONCAT(#{monthStart}, ' 00:00:00')
AND tb.create_time <![CDATA[ < ]]> CONCAT(#{nextMonthStart}, ' 00:00:00')
AND tb.status IN ('COMPLETED', 'ABORTED')
ORDER BY tb.update_time DESC, tb.id DESC
</select>
</mapper>