From 2f07589b54d56085af77b50d580890cd4130b444 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期一, 19 十月 2026 15:19:53 +0800
Subject: [PATCH] 设备模块后端业务规则、计划接口与日期联动
---
cnas-require/src/main/resources/mapper/FeStandardSubstanceMapper.xml | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/cnas-require/src/main/resources/mapper/FeStandardSubstanceMapper.xml b/cnas-require/src/main/resources/mapper/FeStandardSubstanceMapper.xml
index 5a9d0bd..bcb37fc 100644
--- a/cnas-require/src/main/resources/mapper/FeStandardSubstanceMapper.xml
+++ b/cnas-require/src/main/resources/mapper/FeStandardSubstanceMapper.xml
@@ -24,33 +24,41 @@
<result column="update_time" property="updateTime" />
</resultMap>
<select id="getPage" resultType="com.ruoyi.require.pojo.FeStandardSubstance">
- select * from cnas_fe_standard_substance
+ select s.*,
+ GREATEST(COALESCE(s.quantity, 0) - COALESCE((
+ SELECT SUM(CASE WHEN r.borrow_quantity IS NULL THEN COALESCE(s.quantity, 0)
+ ELSE r.borrow_quantity END)
+ FROM cnas_fe_standard_substance_record r
+ WHERE r.substance_id = s.id AND COALESCE(r.status, '0') <> '1'
+ ), 0), 0) AS remaining_quantity
+ from cnas_fe_standard_substance s
<where>
<if test="ew.name != null and ew.name != ''">
- name like CONCAT('%', #{ew.name}, '%')
+ s.name like CONCAT('%', #{ew.name}, '%')
</if>
<if test="ew.factoryManufacturer != null and ew.factoryManufacturer != ''">
- and factory_manufacturer like CONCAT('%', #{ew.factoryManufacturer}, '%')
+ and s.factory_manufacturer like CONCAT('%', #{ew.factoryManufacturer}, '%')
</if>
<if test="ew.factoryNum != null and ew.factoryNum != ''">
- and factory_num like CONCAT('%', #{factoryNum}, '%')
+ and s.factory_num like CONCAT('%', #{ew.factoryNum}, '%')
</if>
<if test="ew.manageNum != null and ew.manageNum != ''">
- and manage_num like CONCAT('%', #{ew.manageNum}, '%')
+ and s.manage_num like CONCAT('%', #{ew.manageNum}, '%')
</if>
<if test="ew.model != null and ew.model != ''">
- and model like CONCAT('%', #{ew.model}, '%')
+ and s.model like CONCAT('%', #{ew.model}, '%')
</if>
<if test="ew.effectiveDate != null and ew.effectiveDate != ''">
- and effective_date = #{ew.effectiveDate}
+ and s.effective_date = #{ew.effectiveDate}
</if>
<if test="ew.fileNum != null and ew.fileNum != ''">
- and file_num like CONCAT('%', #{ew.fileNum}, '%')
+ and s.file_num like CONCAT('%', #{ew.fileNum}, '%')
</if>
<if test="ew.position != null and ew.position != ''">
- and position like CONCAT('%', #{ew.position}, '%')
+ and s.position like CONCAT('%', #{ew.position}, '%')
</if>
</where>
+ ORDER BY s.acquisition_date DESC, s.id DESC
</select>
</mapper>
--
Gitblit v1.9.3