|
|
@@ -88,7 +88,8 @@
|
|
|
a.warn_flag,
|
|
|
a.produce_date,
|
|
|
a.shelf_life,
|
|
|
- a.shelf_life_unit
|
|
|
+ a.shelf_life_unit,
|
|
|
+ a.spec
|
|
|
FROM
|
|
|
psi_management_warehouse_detailed a
|
|
|
left join
|
|
|
@@ -237,6 +238,114 @@
|
|
|
ORDER BY a.produce_date asc
|
|
|
</select>
|
|
|
|
|
|
+ <select id="nearExpiryList"
|
|
|
+ resultType="com.jeeplus.psimanage.psiWareHouse.service.dto.PsiWareHouseDto">
|
|
|
+ SELECT
|
|
|
+ t.id,
|
|
|
+ t.basic_id AS basicId,
|
|
|
+ t.ware_house_type,
|
|
|
+ t.trade_name,
|
|
|
+ t.spec,
|
|
|
+ t.company,
|
|
|
+ t.current_inventory AS currentInventory,
|
|
|
+ t.current_inventory AS tradeNumber,
|
|
|
+ t.produce_date,
|
|
|
+ t.shelf_life,
|
|
|
+ t.shelf_life_unit,
|
|
|
+ t.expiryDate AS expiryDate,
|
|
|
+ CAST(t.remainingDays AS SIGNED) AS remainingDays,
|
|
|
+ CAST(t.warnDays AS SIGNED) AS warnDays,
|
|
|
+ t.ware_house_number,
|
|
|
+ t.ware_house_name,
|
|
|
+ t.ware_house_date,
|
|
|
+ tp.name AS wareHouseTypeName
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ src.*,
|
|
|
+ DATEDIFF(src.expiryDate, CURDATE()) AS remainingDays,
|
|
|
+ CASE
|
|
|
+ WHEN src.totalShelfDays <= 30 THEN CAST(GREATEST(1, CEILING(src.totalShelfDays / 3)) AS SIGNED)
|
|
|
+ ELSE CAST(GREATEST(1, CEILING(src.totalShelfDays / 4)) AS SIGNED)
|
|
|
+ END AS warnDays
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ a.id,
|
|
|
+ a.basic_id,
|
|
|
+ a.ware_house_type,
|
|
|
+ a.trade_name,
|
|
|
+ a.spec,
|
|
|
+ a.company,
|
|
|
+ a.current_inventory,
|
|
|
+ a.produce_date,
|
|
|
+ a.shelf_life,
|
|
|
+ a.shelf_life_unit,
|
|
|
+ a.supplier_id,
|
|
|
+ bas.ware_house_number,
|
|
|
+ bas.ware_house_name,
|
|
|
+ bas.ware_house_date,
|
|
|
+ CASE
|
|
|
+ WHEN TRIM(a.shelf_life_unit) = '年' THEN DATE_ADD(a.produce_date, INTERVAL CAST(a.shelf_life AS UNSIGNED) YEAR)
|
|
|
+ WHEN TRIM(a.shelf_life_unit) = '月' THEN DATE_ADD(a.produce_date, INTERVAL CAST(a.shelf_life AS UNSIGNED) MONTH)
|
|
|
+ WHEN TRIM(a.shelf_life_unit) = '天' OR TRIM(a.shelf_life_unit) = '日' THEN DATE_ADD(a.produce_date, INTERVAL CAST(a.shelf_life AS UNSIGNED) DAY)
|
|
|
+ ELSE NULL
|
|
|
+ END AS expiryDate,
|
|
|
+ CASE
|
|
|
+ WHEN TRIM(a.shelf_life_unit) = '年' THEN CAST(a.shelf_life AS DECIMAL(10, 2)) * 365
|
|
|
+ WHEN TRIM(a.shelf_life_unit) = '月' THEN CAST(a.shelf_life AS DECIMAL(10, 2)) * 30
|
|
|
+ WHEN TRIM(a.shelf_life_unit) = '天' OR TRIM(a.shelf_life_unit) = '日' THEN CAST(a.shelf_life AS DECIMAL(10, 2))
|
|
|
+ ELSE NULL
|
|
|
+ END AS totalShelfDays
|
|
|
+ FROM
|
|
|
+ psi_management_warehouse_detailed a
|
|
|
+ LEFT JOIN psi_management_warehouse_basics bas ON a.basic_id = bas.id
|
|
|
+ WHERE
|
|
|
+ a.del_flag = '0'
|
|
|
+ AND bas.del_flag = '0'
|
|
|
+ AND (bas.`status` = '0' OR bas.`status` = '5')
|
|
|
+ AND a.produce_date IS NOT NULL
|
|
|
+ AND a.shelf_life IS NOT NULL
|
|
|
+ AND a.shelf_life <> ''
|
|
|
+ AND a.shelf_life REGEXP '^[0-9]+([.][0-9]+)?$'
|
|
|
+ AND a.shelf_life_unit IS NOT NULL
|
|
|
+ AND a.shelf_life_unit <> ''
|
|
|
+ AND CAST(IFNULL(NULLIF(a.current_inventory, ''), '0') AS DECIMAL(18, 6)) > 0
|
|
|
+ <if test="dto.tradeName != null and dto.tradeName != ''">
|
|
|
+ AND a.trade_name LIKE concat('%', #{dto.tradeName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="dto.wareHouseType != null and dto.wareHouseType != ''">
|
|
|
+ AND a.ware_house_type = #{dto.wareHouseType}
|
|
|
+ </if>
|
|
|
+ <if test="dto.produceDate != null">
|
|
|
+ AND a.produce_date = #{dto.produceDate}
|
|
|
+ </if>
|
|
|
+ <if test="dto.supplierId != null and dto.supplierId != ''">
|
|
|
+ AND a.supplier_id = #{dto.supplierId}
|
|
|
+ </if>
|
|
|
+ <if test="dto.spec != null and dto.spec != ''">
|
|
|
+ AND a.spec LIKE concat('%', #{dto.spec}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="dto.wareHouseNumber != null and dto.wareHouseNumber != ''">
|
|
|
+ AND bas.ware_house_number LIKE concat('%', #{dto.wareHouseNumber}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="dto.wareHouseName != null and dto.wareHouseName != ''">
|
|
|
+ AND bas.ware_house_name LIKE concat('%', #{dto.wareHouseName}, '%')
|
|
|
+ </if>
|
|
|
+ ) src
|
|
|
+ WHERE
|
|
|
+ src.expiryDate IS NOT NULL
|
|
|
+ ) t
|
|
|
+ LEFT JOIN psi_management_type tp ON t.ware_house_type = tp.id
|
|
|
+ WHERE
|
|
|
+ t.remainingDays >= 0
|
|
|
+ AND (
|
|
|
+ t.remainingDays <= t.warnDays
|
|
|
+ OR t.remainingDays IN (30, 60, 90)
|
|
|
+ )
|
|
|
+ ORDER BY t.remainingDays ASC, t.expiryDate ASC, t.trade_name ASC
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="findRequestId" resultType="java.lang.String">
|
|
|
select id from psi_management_pruchase_request_basics where purchase_no = #{purchaseNo} and del_flag = 0
|
|
|
</select>
|
|
|
@@ -280,13 +389,15 @@
|
|
|
a.collect_date,
|
|
|
b.goods_name,
|
|
|
b.collect_number,
|
|
|
- b.current_inventory,
|
|
|
+ pmwd.current_inventory,
|
|
|
+ pmwd.spec,
|
|
|
b.collect_type as collectType
|
|
|
FROM
|
|
|
psi_management_collect_basics a
|
|
|
LEFT JOIN
|
|
|
psi_management_collect_detailed b on a.id = b.basic_id and b.del_flag = 0
|
|
|
-
|
|
|
+ LEFT JOIN psi_management_collect_detailed_record pmcdr ON b.id = pmcdr.detail_id
|
|
|
+ LEFT JOIN psi_management_warehouse_detailed pmwd ON pmcdr.inventory_id = pmwd.id
|
|
|
left join sys_user sy on sy.id = a.handled_by
|
|
|
left join sys_office so on sy.office_id = so.id
|
|
|
|