Selaa lähdekoodia

库存中的数量根据规格转换显示,入库修改后同步库存

huangguoce 16 tuntia sitten
vanhempi
commit
4f4b69be70

+ 114 - 3
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/mapper/xml/PsiWareHouseBasicMapper.xml

@@ -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 &lt;= 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 &lt;&gt; ''
+					AND a.shelf_life REGEXP '^[0-9]+([.][0-9]+)?$'
+					AND a.shelf_life_unit IS NOT NULL
+					AND a.shelf_life_unit &lt;&gt; ''
+					AND CAST(IFNULL(NULLIF(a.current_inventory, ''), '0') AS DECIMAL(18, 6)) &gt; 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 &gt;= 0
+			AND (
+				t.remainingDays &lt;= 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
 

+ 19 - 5
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/service/PsiWareHouseBasicService.java

@@ -165,11 +165,11 @@ public class PsiWareHouseBasicService {
         }
         IPage<PsiWareHouseDto> iPage = basicMapper.collectHistoryList(page, queryWrapper);
         //根据时间查询当前库存
-        iPage.getRecords().stream().forEach(i->{
-            //根据商品名称,物品类型,时间查当前库存
-            String d = basicMapper.getCollectInfoByTime(i.getGoodsName(),i.getCollectType(),i.getDateTest2());
-            i.setCurrentInventory(d);
-        });
+        //iPage.getRecords().stream().forEach(i->{
+        //    //根据商品名称,物品类型,时间查当前库存
+        //    String d = basicMapper.getCollectInfoByTime(i.getGoodsName(),i.getCollectType(),i.getDateTest2());
+        //    i.setCurrentInventory(d);
+        //});
         return iPage;
     }
 
@@ -485,6 +485,7 @@ public class PsiWareHouseBasicService {
                         psiDetailedMapper.deleteById(detailInfo.getId());
                     }
                 }
+                detailInfo.setCurrentInventory(detailInfo.getTradeNumber());
                 psiDetailedMapper.updateById(detailInfo);
                 // 修改附件信息列表
                 psiOssService.saveOrUpdateFileList(detailInfo.getFileInfoLost(), detailInfo.getId(),"ware_house_detail",TokenProvider.getCurrentToken ( ));
@@ -1068,6 +1069,19 @@ public class PsiWareHouseBasicService {
         return wareHouseDtoIPage;
     }
 
+    public IPage<PsiWareHouseDto> nearExpiryList(Page<PsiWareHouseDto> page, PsiWareHouseDto dto) {
+        IPage<PsiWareHouseDto> iPage = basicMapper.nearExpiryList(page, dto);
+        iPage.getRecords().forEach(item -> {
+            if (StringUtils.isNotBlank(item.getCurrentInventory())) {
+                item.setCurrentInventory(convertByBigDecimal(item.getCurrentInventory()));
+            }
+            if (StringUtils.isNotBlank(item.getTradeNumber())) {
+                item.setTradeNumber(convertByBigDecimal(item.getTradeNumber()));
+            }
+        });
+        return iPage;
+    }
+
     /**
      * 列表查询
      */