| | |
| | | <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> |