|
@@ -6,6 +6,7 @@ import org.dromara.web.domain.ProductInOutRecord;
|
|
import org.dromara.web.domain.vo.FoodStockBalanceVo;
|
|
import org.dromara.web.domain.vo.FoodStockBalanceVo;
|
|
import org.dromara.web.domain.vo.ProductInOutRecordVo;
|
|
import org.dromara.web.domain.vo.ProductInOutRecordVo;
|
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
|
|
|
+import org.dromara.web.domain.vo.indexData.StorageOverviewVo;
|
|
import org.springframework.stereotype.Repository;
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -18,7 +19,7 @@ import java.util.List;
|
|
*/
|
|
*/
|
|
@Repository
|
|
@Repository
|
|
public interface ProductInOutRecordMapper extends BaseMapperPlus<ProductInOutRecord, ProductInOutRecordVo> {
|
|
public interface ProductInOutRecordMapper extends BaseMapperPlus<ProductInOutRecord, ProductInOutRecordVo> {
|
|
- @Select(" <script> SELECT pr.product_id AS productId, pr.category_id AS categoryId, pr.location_id AS locationId,pr.serial_no AS serialNo,pr.product_name AS productName, pr.product_type as productType, " +
|
|
|
|
|
|
+ @Select(" <script> SELECT pr.product_id AS productId, pr.category_id AS categoryId, pr.location_id AS locationId,pr.serial_no AS serialNo,pr.product_name AS productName, pr.product_type as productType,pr.line_no as lineNo , " +
|
|
"pr.category_name AS categoryName,pr.location_name AS locationName,pr.product_no AS productNo,SUM( CASE WHEN pr.type = '0' THEN pr.num ELSE - pr.num END ) AS stockNum," +
|
|
"pr.category_name AS categoryName,pr.location_name AS locationName,pr.product_no AS productNo,SUM( CASE WHEN pr.type = '0' THEN pr.num ELSE - pr.num END ) AS stockNum," +
|
|
"pr.product_batch_no as productBatchNo,pr.unit, ANY_VALUE(pr.specs_name) as specsName, ANY_VALUE(pr.line_no) as lineNo,ANY_VALUE(pr.invoice_no) as invoiceNo, pr.price, " +
|
|
"pr.product_batch_no as productBatchNo,pr.unit, ANY_VALUE(pr.specs_name) as specsName, ANY_VALUE(pr.line_no) as lineNo,ANY_VALUE(pr.invoice_no) as invoiceNo, pr.price, " +
|
|
"ANY_VALUE(pr.warning_month) as warningMonth,ANY_VALUE(pr.manufacture_date) as manufactureDate,ANY_VALUE(pr.expiration_date) as expirationDate " +
|
|
"ANY_VALUE(pr.warning_month) as warningMonth,ANY_VALUE(pr.manufacture_date) as manufactureDate,ANY_VALUE(pr.expiration_date) as expirationDate " +
|
|
@@ -28,7 +29,7 @@ public interface ProductInOutRecordMapper extends BaseMapperPlus<ProductInOutRec
|
|
"<if test='categoryId != null '> and (pr.category_id = #{categoryId}) </if>" +
|
|
"<if test='categoryId != null '> and (pr.category_id = #{categoryId}) </if>" +
|
|
"<if test='productType != null and productType != \"\"'> and (pr.product_type = #{productType}) </if>" +
|
|
"<if test='productType != null and productType != \"\"'> and (pr.product_type = #{productType}) </if>" +
|
|
"<if test='searchValue != null and searchValue != \"\"'> and (pr.product_name like concat('%', #{searchValue}, '%')) </if>" +
|
|
"<if test='searchValue != null and searchValue != \"\"'> and (pr.product_name like concat('%', #{searchValue}, '%')) </if>" +
|
|
- "GROUP BY pr.product_id,pr.category_id,pr.location_id,pr.serial_no,pr.product_name,pr.category_name,pr.location_name,pr.product_no,pr.product_batch_no,pr.unit,pr.product_type,pr.price " +
|
|
|
|
|
|
+ "GROUP BY pr.product_id,pr.category_id,pr.location_id,pr.serial_no,pr.product_name,pr.category_name,pr.location_name,pr.product_no,pr.product_batch_no,pr.unit,pr.product_type,pr.price,pr.line_no " +
|
|
"<if test='offset != null and rows != null'>LIMIT #{offset}, #{rows}</if>" +
|
|
"<if test='offset != null and rows != null'>LIMIT #{offset}, #{rows}</if>" +
|
|
"</script>" )
|
|
"</script>" )
|
|
List<ProductInOutRecordVo> queryStockBalance( @Param("productType") String productType,@Param("locationId") Long locationId, @Param("categoryId") Long categoryId, @Param("searchValue") String searchValue, @Param("offset") Integer offset, @Param("rows") Integer rows);
|
|
List<ProductInOutRecordVo> queryStockBalance( @Param("productType") String productType,@Param("locationId") Long locationId, @Param("categoryId") Long categoryId, @Param("searchValue") String searchValue, @Param("offset") Integer offset, @Param("rows") Integer rows);
|
|
@@ -39,8 +40,27 @@ public interface ProductInOutRecordMapper extends BaseMapperPlus<ProductInOutRec
|
|
"<if test='productType != null and productType != \"\"'> and (pr.product_type = #{productType}) </if>" +
|
|
"<if test='productType != null and productType != \"\"'> and (pr.product_type = #{productType}) </if>" +
|
|
" <if test='searchValue != null and searchValue != \"\"'> " +
|
|
" <if test='searchValue != null and searchValue != \"\"'> " +
|
|
" AND (pr.product_name LIKE CONCAT('%', #{searchValue}, '%') ) </if> " +
|
|
" AND (pr.product_name LIKE CONCAT('%', #{searchValue}, '%') ) </if> " +
|
|
- " GROUP BY pr.product_id,pr.category_id,pr.location_id,pr.serial_no,pr.product_name,pr.category_name,pr.location_name,pr.product_no,pr.product_batch_no,pr.unit " +
|
|
|
|
|
|
+ " GROUP BY pr.product_id,pr.category_id,pr.location_id,pr.serial_no,pr.product_name,pr.category_name,pr.location_name,pr.product_no,pr.product_batch_no,pr.unit,pr.line_no " +
|
|
") AS grouped_data " +
|
|
") AS grouped_data " +
|
|
"</script>" )
|
|
"</script>" )
|
|
Integer queryStockBalanceCount(@Param("productType") String productType, @Param("locationId") Long locationId, @Param("categoryId") Long categoryId,@Param("searchValue") String searchValue);
|
|
Integer queryStockBalanceCount(@Param("productType") String productType, @Param("locationId") Long locationId, @Param("categoryId") Long categoryId,@Param("searchValue") String searchValue);
|
|
|
|
+
|
|
|
|
+ @Select("SELECT " +
|
|
|
|
+ " COUNT(DISTINCT CASE WHEN days_to_expire <= 30 THEN batch_product_id END) AS expiringLicenses, " +
|
|
|
|
+ " COUNT(DISTINCT CASE WHEN warning_month <= 1 THEN batch_product_id END) AS expiringValidity, " +
|
|
|
|
+ " COUNT(DISTINCT CASE WHEN current_stock <= alert_num THEN batch_product_id END) AS inventoryAlerts " +
|
|
|
|
+ "FROM ( " +
|
|
|
|
+ " SELECT " +
|
|
|
|
+ " CONCAT(product_id, '-', COALESCE(product_batch_no, ''), '-', COALESCE(serial_no, '')) AS batch_product_id, " +
|
|
|
|
+ " alert_num, " +
|
|
|
|
+ " warning_month, " +
|
|
|
|
+ " DATEDIFF(expiration_date, CURDATE()) AS days_to_expire, " +
|
|
|
|
+ " SUM(CASE WHEN type = '0' THEN num ELSE -num END) AS current_stock " +
|
|
|
|
+ " FROM product_in_out_record " +
|
|
|
|
+ " WHERE del_flag = '0' " +
|
|
|
|
+ " AND status = '0' " +
|
|
|
|
+ " GROUP BY product_id, product_batch_no, serial_no, alert_num, warning_month, expiration_date " +
|
|
|
|
+ ") AS stock_summary " +
|
|
|
|
+ "WHERE current_stock > 0 ")
|
|
|
|
+ StorageOverviewVo selectCount();
|
|
}
|
|
}
|