liujie
2 天以前 f41b11c958ef7d0416d194278d1fe7cd1a1e8219
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
<?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.ruoyi.system.mapper.TErpGoodsMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TErpGoods">
        <id column="id" property="id"/>
        <result column="supplier_clinic_id" property="supplierClinicId"/>
        <result column="goods_source" property="goodsSource"/>
        <result column="clinic_id" property="clinicId"/>
        <result column="goods_name" property="goodsName"/>
        <result column="goods_id_code" property="goodsIdCode"/>
        <result column="quasi_number" property="quasiNumber"/>
        <result column="manufacturer" property="manufacturer"/>
        <result column="formulation_spec" property="formulationSpec"/>
        <result column="packing_spec" property="packingSpec"/>
        <result column="type_id" property="typeId"/>
        <result column="goods_yards" property="goodsYards"/>
        <result column="maintenance_interval" property="maintenanceInterval"/>
        <result column="low_purchase_quantity" property="lowPurchaseQuantity"/>
        <result column="low_unit_id" property="lowUnitId"/>
        <result column="is_prescription_drug" property="isPrescriptionDrug"/>
        <result column="goods_spec" property="goodsSpec"/>
        <result column="warning_inventory" property="warningInventory"/>
        <result column="sales_amount" property="salesAmount"/>
        <result column="packing_unit_id" property="packingUnitId"/>
        <result column="instructions_use" property="instructionsUse"/>
        <result column="side_effect" property="sideEffect"/>
        <result column="clinic_purchase_price" property="clinicPurchasePrice"/>
        <result column="platform_commission_price" property="platformCommissionPrice"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by" property="updateBy"/>
        <result column="disabled" property="disabled"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id
        , supplier_clinic_id, goods_source, goods_name, goods_id_code, quasi_number, manufacturer, formulation_spec, packing_spec, type_id, goods_yards, maintenance_interval,maintenance_interval_unit, low_purchase_quantity, low_unit_id, is_prescription_drug, goods_spec, warning_inventory, sales_amount, packing_unit_id, instructions_use, side_effect, clinic_purchase_price, platform_commission_price, create_time, update_time, create_by,`state`, update_by, disabled,
          simplified_code,
dosage_form,
usage_classification,
product_brand,
place_of_origin,
ingredient,
trait,
indication,
taboo,
precautions,
interaction,
storage
 
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select
        <include refid="Base_Column_List"/>
        from t_erp_goods where disabled = 0
        <if test="query.goodsName != null and query.goodsName != ''">
            and goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.goodsIdCode != null and query.goodsIdCode != ''">
            and goods_id_code like concat('%',#{query.goodsIdCode},'%')
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and quasi_number like concat('%',#{query.quasiNumber},'%')
        </if>
        <if test="query.state != null ">
            and state = #{query.state}
        </if>
        <if test="user.roleType != null and user.roleType == 4 ">
            and goods_source =1 and supplier_clinic_id = #{query.supplierClinicId}
        </if>
        <if test="user.roleType != null and user.roleType == 5 ">
            and  ( (goods_source =2 and supplier_clinic_id = #{query.supplierClinicId} ) or FIND_IN_SET(#{query.supplierClinicId},clinic_ids) )
        </if>
        order by create_time desc
    </select>
    <select id="listExport" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select
        <include refid="Base_Column_List"/>
        from t_erp_goods where disabled = 0
        <if test="query.goodsName != null and query.goodsName != ''">
            and goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.goodsIdCode != null and query.goodsIdCode != ''">
            and goods_id_code like concat('%',#{query.goodsIdCode},'%')
        </if>
        <if test="query.typeId != null and query.typeId != ''">
            and type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and quasi_number like concat('%',#{query.quasiNumber},'%')
        </if>
        <if test="query.state != null ">
            and state = #{query.state}
        </if>
        <if test="user.roleType != null and user.roleType == 4 ">
            and goods_source =1 and supplier_clinic_id =#{query.supplierClinicId}
        </if>
        <if test="user.roleType != null and user.roleType == 5 ">
            and goods_source =2 and supplier_clinic_id =#{query.supplierClinicId}
        </if>
        order by create_time desc
    </select>
 
 
    <select id="pageInventoryGoodsPageList" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
        select * from (
        SELECT t1.id,t2.warehouse_no,
        t3.goods_name,
        t4.supplier_name,
        t3.type_id,
        t3.packing_unit_id,
        t3.quasi_number,
        t3.goods_id_code,
        t1.batch_number,
        coalesce(sum(t5.outbound_count),0) as outbound_count,
        t1.warehousing_number,
        t2.create_time,
        t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num,
        t2.unit_amount as sales_amount,
        t1.expiry_date
        from t_erp_supplier_warehousing_batch t1
        LEFT JOIN t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_goods t3 on t2.goods_id = t3.id
        LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id
        LEFT JOIN t_erp_supplier_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0 and t2.warehouse_id = #{query.warehouseId}
        <if test="query.type != null and query.type ==1">
            and #{time} > t1.expiry_date
        </if>
        <if test="query.goodsName != null and query.goodsName != ''">
            and t3.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="user.roleType !=null and user.roleType ==4">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=1
        </if>
        <if test="user.roleType !=null and user.roleType ==5">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=2
        </if>
        <if test="query.supplierName != null and query.supplierName != ''">
            and t4.supplier_name like concat('%',#{query.supplierName},'%')
        </if>
 
        <if test="query.typeId != null and query.typeId != ''">
            and t3.type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and t3.quasi_number =#{query.quasiNumber}
        </if>
        <if test="query.batchNumber != null and query.batchNumber != ''">
            and t1.batch_number =#{query.batchNumber}
        </if>
        <if test="query.warehouseNo != null and query.warehouseNo != ''">
            and t2.warehouse_no = #{query.warehouseNo}
        </if>
        GROUP BY t1.id
        ) as o
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
    <select id="pageInventoryGoodsPageList1" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
        select * from (
        SELECT t1.id,t2.warehouse_no,
        t3.goods_name,t3.goods_source,
        t4.supplier_name,
        t3.type_id,
        t3.packing_unit_id,
        t3.quasi_number,
        t3.goods_id_code,
        t1.batch_number,
        coalesce(sum(t5.outbound_count),0) as outbound_count,
        t1.warehousing_number,
        t2.create_time,
        t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num,
        t2.unit_amount as sales_amount,
        t1.expiry_date
        from t_erp_clinic_warehousing_batch t1
        LEFT JOIN t_erp_clinic_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_goods t3 on t2.goods_id = t3.id
        LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id
        LEFT JOIN t_erp_clinic_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0 and t2.warehouse_id = #{query.warehouseId}
        <if test="query.type != null and query.type ==1">
            and #{time} > t1.expiry_date
        </if>
        <if test="query.goodsName != null and query.goodsName != ''">
            and t3.goods_name like concat('%',#{query.goodsName},'%')
        </if>
        <if test="query.supplierName != null and query.supplierName != ''">
            and (t4.supplier_name like concat('%',#{query.supplierName},'%') or t3.supplierName like concat('%',#{query.supplierName},'%'))
        </if>
 
        <if test="query.typeId != null and query.typeId != ''">
            and t3.type_id = #{query.typeId}
        </if>
        <if test="query.quasiNumber != null and query.quasiNumber != ''">
            and t3.quasi_number =#{query.quasiNumber}
        </if>
        <if test="query.batchNumber != null and query.batchNumber != ''">
            and t1.batch_number =#{query.batchNumber}
        </if>
        <if test="query.warehouseNo != null and query.warehouseNo != ''">
            and t2.warehouse_no = #{query.warehouseNo}
        </if>
        GROUP BY t1.id
        ) as o
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
    <select id="pageInventoryGoodsList" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
        select * from (
        SELECT t1.id,t2.warehouse_no,
        t3.goods_name,
        t4.supplier_name,
        t3.type_id,
        t3.packing_unit_id,
        t3.quasi_number,
        t3.goods_id_code,
        t1.batch_number,
        coalesce(sum(t5.outbound_count),0) as outbound_count,
        t1.warehousing_number,
        t2.create_time,
        t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num,
        t2.unit_amount as sales_amount,
        t1.expiry_date
        from t_erp_supplier_warehousing_batch t1
        LEFT JOIN t_erp_supplier_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_goods t3 on t2.goods_id = t3.id
        LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id
        LEFT JOIN t_erp_supplier_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0 and t2.warehouse_id = #{warehouseId}
        and #{endDate} > t1.expiry_date
        <if test="user.roleType !=null and user.roleType ==4">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=1
        </if>
        <if test="user.roleType !=null and user.roleType ==5">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=2
        </if>
 
        GROUP BY t1.id
        ) as o
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
    <select id="pageInventoryGoodsList1" resultType="com.ruoyi.system.vo.TErpGoodsInventoryVO">
        select * from (
        SELECT t1.id,t2.warehouse_no,
        t3.goods_name,
        t4.supplier_name,
        t3.type_id,
        t3.packing_unit_id,
        t3.quasi_number,
        t3.goods_id_code,
        t1.batch_number,
        coalesce(sum(t5.outbound_count),0) as outbound_count,
        t1.warehousing_number,
        t2.create_time,
        t1.warehousing_number - coalesce(sum(t5.outbound_count),0) as num,
        t2.unit_amount as sales_amount,
        t1.expiry_date
        from t_erp_clinic_warehousing_batch t1
        LEFT JOIN t_erp_clinic_warehousing t2 on t1.warehousing_id = t2.id
        LEFT JOIN t_erp_goods t3 on t2.goods_id = t3.id
        LEFT JOIN t_crm_supplier t4 on t3.supplier_clinic_id = t4.id
        LEFT JOIN t_erp_supplier_outbound_goods t5 on t5.warehousing_batch_id =t1.id
        where t2.disabled = 0
        and #{endDate} > t1.expiry_date
        <if test="user.roleType !=null and user.roleType ==4">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=1
        </if>
        <if test="user.roleType !=null and user.roleType ==5">
            and t3.supplier_clinic_id =#{supplierClinicId} and t3.goods_source=2
        </if>
 
        GROUP BY t1.id
        ) as o
        where (o.warehousing_number -o.outbound_count) >0
        order by o.create_time desc
    </select>
 
</mapper>