Parcourir la source

物资-库存导出

huangguoce il y a 2 jours
Parent
commit
82a161dd06

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

@@ -152,12 +152,15 @@
 			sum( trade_number ) AS allNumber,
 			b.collect_number AS borrowNumber,
 			loss.loss_number AS lossNumber,
-			a.current_inventory AS tradeNumber,
+			sum(a.current_inventory) AS tradeNumber,
 			a.warn_num,
 			a.warn_flag,
 			a.produce_date,
 			a.shelf_life,
-			a.shelf_life_unit
+			a.shelf_life_unit,
+			a.spec,
+			pmcdra.returned_num as returnedNum,
+			pmcdra.not_surplus_stock as notSurplusStock
 		FROM
 			psi_management_warehouse_detailed a
 				left join
@@ -168,7 +171,7 @@
 					status
 				from psi_management_collect_detailed e
 						 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-				WHERE f.`status` = 5 and e.del_flag = 0
+				WHERE f.`status` = 5 and e.del_flag = 0 and e.is_return = '0'
 				GROUP BY e.goods_name
 			) b
 			on a.trade_name = b.goods_name
@@ -184,6 +187,20 @@
 				GROUP BY e.goods_name
 			) loss
 			on a.trade_name = loss.goods_name
+				left join
+			(
+				select
+					sum(returned_num) AS returned_num,
+					sum(not_surplus_stock) AS not_surplus_stock,
+					inventory_id,
+					goods_name,
+					status
+				from psi_management_collect_detailed_record e
+						 left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
+				WHERE pmcba.`status` = 5 and e.del_flag = 0
+				group BY e.goods_name
+			) pmcdra
+			on a.trade_name = pmcdra.goods_name
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
@@ -256,110 +273,16 @@
 
 	<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
+		    a.trade_name,
+		    a.produce_date,
+		    a.shelf_life,
+		    a.spec,
+		    a.shelf_life_unit,
+		    a.current_inventory
+		from psi_management_warehouse_detailed a
+		left join psi_management_warehouse_basics pmwb on pmwb.id = a.basic_id and pmwb.del_flag= '0'
+		where a.del_flag = '0'
 	</select>
 
     <select id="findRequestId" resultType="java.lang.String">

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

@@ -972,11 +972,6 @@ public class PsiWareHouseBasicService {
                 String s = convertByBigDecimal(item.getAllNumber());
                 item.setAllNumber(s);
             }
-            //领用量  格式化
-            if (StringUtils.isNotBlank(item.getBorrowNumber())) {
-                String s = convertByBigDecimal(item.getBorrowNumber());
-                item.setBorrowNumber(s);
-            }
             //剩余量  格式化
             if (StringUtils.isNotBlank(item.getTradeNumber())) {
                 String s = convertByBigDecimal(item.getTradeNumber());
@@ -997,6 +992,47 @@ public class PsiWareHouseBasicService {
             if(StringUtils.isBlank(item.getLossNumber())){
                 item.setLossNumber("0");
             }
+
+            if (StringUtils.isNotBlank(item.getNotSurplusStock())) {
+                String notSurplusStockStr = item.getNotSurplusStock();
+                String specStr = item.getSpec();
+
+                if (StringUtils.isBlank(notSurplusStockStr) || StringUtils.isBlank(specStr)) {
+                    item.setNotSurplusStock(item.getNotSurplusStock());
+                }else{
+                    double notSurplusStock = Double.parseDouble(notSurplusStockStr);
+                    double spec = Double.parseDouble(specStr);
+
+                    if (spec == 0) {
+                        item.setNotSurplusStock(item.getNotSurplusStock());
+                    }else{
+                        double total = notSurplusStock / spec;
+                        String totalStr = String.valueOf( total);
+                        item.setNotSurplusStock(totalStr);
+                    }
+                }
+            }
+
+            if (StringUtils.isNotBlank(item.getLossNumber())) {
+                String specStr = item.getSpec();
+                String lossNumberStr = item.getLossNumber();
+
+                if (StringUtils.isBlank(specStr)) {
+                    item.setLossNumber(item.getLossNumber());
+                }else{
+                    double spec = Double.parseDouble(specStr);
+                    double lossNumber = Double.parseDouble(lossNumberStr);
+                    if (spec == 0) {
+                        item.setLossNumber(item.getLossNumber());
+                    }else{
+                        double total = lossNumber / spec;
+                        String totalStr = String.valueOf( total);
+                        item.setLossNumber(totalStr);
+                    }
+                }
+            }
+
+
         });
         return wareHouseDtoIPage;
     }
@@ -1072,12 +1108,7 @@ public class PsiWareHouseBasicService {
     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;
     }

+ 3 - 2
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/service/dto/PsiWareSummaryExportDto.java

@@ -17,7 +17,7 @@ public class PsiWareSummaryExportDto {
     private String allNumber;
 
     @ExcelProperty("领用量")
-    private String borrowNumber;
+    private String notSurplusStock;
 
     @ExcelProperty("报损量")
     private String lossNumber;
@@ -34,5 +34,6 @@ public class PsiWareSummaryExportDto {
     @ExcelProperty("是否提醒")
     private String warnFlag;
 
-
+    @ExcelIgnore
+    private String spec;
 }