Explorar el Código

库存分析 结存单价

yzc hace 1 año
padre
commit
28730424dd
Se han modificado 24 ficheros con 929 adiciones y 14 borrados
  1. 6 0
      hx-purchase/src/main/java/com/fjhx/purchase/mapper/purchase/PurchaseMapper.java
  2. 9 1
      hx-purchase/src/main/java/com/fjhx/purchase/mapper/subscribe/SubscribeMapper.java
  3. 38 0
      hx-purchase/src/main/java/com/fjhx/purchase/service/purServiceImpl.java
  4. 7 0
      hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/PurchaseService.java
  5. 9 0
      hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchaseServiceImpl.java
  6. 10 5
      hx-purchase/src/main/java/com/fjhx/purchase/service/subscribe/SubscribeService.java
  7. 9 0
      hx-purchase/src/main/java/com/fjhx/purchase/service/subscribe/impl/SubscribeServiceImpl.java
  8. 9 0
      hx-purchase/src/main/resources/mapper/purchase/PurchaseMapper.xml
  9. 9 0
      hx-purchase/src/main/resources/mapper/subscribe/SubscribeMapper.xml
  10. 19 0
      hx-wms/src/main/java/com/fjhx/wms/controller/stock/StockController.java
  11. 58 0
      hx-wms/src/main/java/com/fjhx/wms/entity/ArrivalDetailPo.java
  12. 153 0
      hx-wms/src/main/java/com/fjhx/wms/entity/PurchaseDetailPo.java
  13. 106 0
      hx-wms/src/main/java/com/fjhx/wms/entity/SubscribeDetailPo.java
  14. 10 0
      hx-wms/src/main/java/com/fjhx/wms/entity/stock/dto/StockSelectDto.java
  15. 139 0
      hx-wms/src/main/java/com/fjhx/wms/entity/stock/po/StockAnalysis.java
  16. 12 0
      hx-wms/src/main/java/com/fjhx/wms/mapper/stock/StockMapper.java
  17. 9 1
      hx-wms/src/main/java/com/fjhx/wms/mapper/stock/StockWaitMapper.java
  18. 27 0
      hx-wms/src/main/java/com/fjhx/wms/service/PurService.java
  19. 12 0
      hx-wms/src/main/java/com/fjhx/wms/service/stock/StockService.java
  20. 9 0
      hx-wms/src/main/java/com/fjhx/wms/service/stock/StockWaitService.java
  21. 190 5
      hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockServiceImpl.java
  22. 50 2
      hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitServiceImpl.java
  23. 21 0
      hx-wms/src/main/resources/mapper/stock/StockMapper.xml
  24. 8 0
      hx-wms/src/main/resources/mapper/stock/StockWaitMapper.xml

+ 6 - 0
hx-purchase/src/main/java/com/fjhx/purchase/mapper/purchase/PurchaseMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.purchase.entity.purchase.dto.PurchaseDto;
 import com.fjhx.purchase.entity.purchase.po.Purchase;
 import com.fjhx.purchase.entity.purchase.vo.PurchaseVo;
+import com.fjhx.wms.entity.PurchaseDetailPo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
@@ -55,4 +56,9 @@ public interface PurchaseMapper extends BaseMapper<Purchase> {
      * 获取已采购产品部门列表
      */
     List<SysDept> getDepts();
+
+    /**
+     * 获取已采购数量
+     */
+    List<PurchaseDetailPo> getPurchaseCountList(@Param("ew") IWrapper<Object> wrapper);
 }

+ 9 - 1
hx-purchase/src/main/java/com/fjhx/purchase/mapper/subscribe/SubscribeMapper.java

@@ -1,12 +1,15 @@
 package com.fjhx.purchase.mapper.subscribe;
 
-import com.fjhx.purchase.entity.subscribe.po.Subscribe;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.purchase.entity.subscribe.po.Subscribe;
 import com.fjhx.purchase.entity.subscribe.vo.SubscribeVo;
+import com.fjhx.wms.entity.SubscribeDetailPo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 
 /**
  * <p>
@@ -23,4 +26,9 @@ public interface SubscribeMapper extends BaseMapper<Subscribe> {
      */
     Page<SubscribeVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<Subscribe> wrapper);
 
+    /**
+     * 获取已采购数量
+     */
+    List<SubscribeDetailPo> getSubscribeCountList(@Param("ew") IWrapper<Object> wrapper);
+
 }

+ 38 - 0
hx-purchase/src/main/java/com/fjhx/purchase/service/purServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fjhx.purchase.service;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.fjhx.purchase.entity.arrival.po.ArrivalDetail;
 import com.fjhx.purchase.entity.purchase.po.Purchase;
@@ -7,9 +8,14 @@ import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
 import com.fjhx.purchase.service.arrival.ArrivalDetailService;
 import com.fjhx.purchase.service.purchase.PurchaseDetailService;
 import com.fjhx.purchase.service.purchase.PurchaseService;
+import com.fjhx.purchase.service.subscribe.SubscribeService;
+import com.fjhx.wms.entity.ArrivalDetailPo;
+import com.fjhx.wms.entity.PurchaseDetailPo;
+import com.fjhx.wms.entity.SubscribeDetailPo;
 import com.fjhx.wms.entity.stock.po.StockWaitDetails;
 import com.fjhx.wms.service.PurService;
 import com.fjhx.wms.service.stock.StockWaitDetailsService;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -28,6 +34,8 @@ public class purServiceImpl implements PurService {
     private ArrivalDetailService arrivalDetailService;
     @Autowired
     private StockWaitDetailsService stockWaitDetailsService;
+    @Autowired
+    private SubscribeService subscribeService;
 
     /**
      * 修改采购到货状态
@@ -67,4 +75,34 @@ public class purServiceImpl implements PurService {
             }
         }
     }
+
+    /**
+     * 获取已采购数量
+     */
+    @Override
+    public List<PurchaseDetailPo> getPurchaseCountList(IWrapper<Object> wrapper){
+        return purchaseService.getPurchaseCountList(wrapper);
+    }
+
+    /**
+     * 获取已申购数量
+     */
+    @Override
+    public List<SubscribeDetailPo> getSubscribeCountList(IWrapper<Object> wrapper) {
+        return subscribeService.getSubscribeCountList(wrapper);
+    }
+
+    @Override
+    public List<ArrivalDetailPo> getArrivalDetailByIds(List<Long> ids) {
+        List<ArrivalDetail> list = arrivalDetailService.list(q -> q.in(ArrivalDetail::getId, ids));
+        List<ArrivalDetailPo> arrivalDetailPos = BeanUtil.copyToList(list, ArrivalDetailPo.class);
+        return arrivalDetailPos;
+    }
+
+    @Override
+    public List<PurchaseDetailPo> getPurchaseDetailByIds(List<Long> ids) {
+        List<PurchaseDetail> list = purchaseDetailService.list(q -> q.in(PurchaseDetail::getId, ids));
+        List<PurchaseDetailPo> purchaseDetailPos = BeanUtil.copyToList(list, PurchaseDetailPo.class);
+        return purchaseDetailPos;
+    }
 }

+ 7 - 0
hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/PurchaseService.java

@@ -5,9 +5,11 @@ import com.fjhx.purchase.entity.purchase.dto.PurchaseDto;
 import com.fjhx.purchase.entity.purchase.dto.PurchaseSelectDto;
 import com.fjhx.purchase.entity.purchase.po.Purchase;
 import com.fjhx.purchase.entity.purchase.vo.PurchaseVo;
+import com.fjhx.wms.entity.PurchaseDetailPo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.service.BaseService;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 
 import java.util.List;
 
@@ -74,4 +76,9 @@ public interface PurchaseService extends BaseService<Purchase> {
      * 获取已采购产品部门列表
      */
     List<SysDept> getDepts();
+
+    /**
+     * 获取已采购数量
+     */
+     List<PurchaseDetailPo> getPurchaseCountList(IWrapper<Object> wrapper);
 }

+ 9 - 0
hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchaseServiceImpl.java

@@ -47,6 +47,7 @@ import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
 import com.fjhx.purchase.service.subscribe.SubscribeService;
 import com.fjhx.supply.entity.supplier.po.SupplierInfo;
 import com.fjhx.supply.service.supplier.SupplierInfoService;
+import com.fjhx.wms.entity.PurchaseDetailPo;
 import com.fjhx.wms.entity.stock.po.Stock;
 import com.fjhx.wms.entity.warehouse.po.Warehouse;
 import com.fjhx.wms.service.stock.StockService;
@@ -594,4 +595,12 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
     public List<SysDept> getDepts() {
         return baseMapper.getDepts();
     }
+
+    /**
+     * 获取已采购数量
+     */
+    @Override
+    public List<PurchaseDetailPo> getPurchaseCountList(IWrapper<Object> wrapper){
+        return baseMapper.getPurchaseCountList(wrapper);
+    }
 }

+ 10 - 5
hx-purchase/src/main/java/com/fjhx/purchase/service/subscribe/SubscribeService.java

@@ -1,14 +1,15 @@
 package com.fjhx.purchase.service.subscribe;
 
-import com.fjhx.purchase.entity.subscribe.dto.SubscribeDetailDto;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.purchase.entity.subscribe.dto.SubscribeDetailSelectDto;
+import com.fjhx.purchase.entity.subscribe.dto.SubscribeDto;
+import com.fjhx.purchase.entity.subscribe.dto.SubscribeSelectDto;
 import com.fjhx.purchase.entity.subscribe.po.Subscribe;
+import com.fjhx.purchase.entity.subscribe.vo.SubscribeVo;
+import com.fjhx.wms.entity.SubscribeDetailPo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.service.BaseService;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.fjhx.purchase.entity.subscribe.vo.SubscribeVo;
-import com.fjhx.purchase.entity.subscribe.dto.SubscribeSelectDto;
-import com.fjhx.purchase.entity.subscribe.dto.SubscribeDto;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 
 import java.util.List;
 
@@ -58,4 +59,8 @@ public interface SubscribeService extends BaseService<Subscribe> {
      */
     List<SysDept> getDepts(SubscribeDetailSelectDto subscribeDetailDto);
 
+    /**
+     * 获取已申购数量
+     */
+    List<SubscribeDetailPo> getSubscribeCountList(IWrapper<Object> wrapper);
 }

+ 9 - 0
hx-purchase/src/main/java/com/fjhx/purchase/service/subscribe/impl/SubscribeServiceImpl.java

@@ -26,6 +26,7 @@ import com.fjhx.purchase.entity.subscribe.vo.SubscribeVo;
 import com.fjhx.purchase.mapper.subscribe.SubscribeMapper;
 import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
 import com.fjhx.purchase.service.subscribe.SubscribeService;
+import com.fjhx.wms.entity.SubscribeDetailPo;
 import com.fjhx.wms.entity.warehouse.po.Warehouse;
 import com.fjhx.wms.service.warehouse.WarehouseService;
 import com.obs.services.internal.ServiceException;
@@ -198,4 +199,12 @@ public class SubscribeServiceImpl extends ServiceImpl<SubscribeMapper, Subscribe
         return sysDepts;
     }
 
+    /**
+     * 获取已申购数量
+     */
+    @Override
+    public List<SubscribeDetailPo> getSubscribeCountList(IWrapper<Object> wrapper) {
+        return baseMapper.getSubscribeCountList(wrapper);
+    }
+
 }

+ 9 - 0
hx-purchase/src/main/resources/mapper/purchase/PurchaseMapper.xml

@@ -84,5 +84,14 @@
         GROUP BY
             de.dept_id
     </select>
+    <select id="getPurchaseCountList" resultType="com.fjhx.wms.entity.PurchaseDetailPo">
+        SELECT
+            count( pd.count ) AS `count`,
+	        pd.bussiness_id
+        FROM
+            purchase_detail pd
+            JOIN purchase p ON pd.purchase_id = p.id
+        ${ew.customSqlSegment}
+    </select>
 
 </mapper>

+ 9 - 0
hx-purchase/src/main/resources/mapper/subscribe/SubscribeMapper.xml

@@ -20,5 +20,14 @@
         from subscribe s
             ${ew.customSqlSegment}
     </select>
+    <select id="getSubscribeCountList" resultType="com.fjhx.wms.entity.SubscribeDetailPo">
+        SELECT
+            count( sd.count ) AS `count`,
+            sd.bussiness_id
+        FROM
+            subscribe_detail sd
+                JOIN subscribe s ON sd.subscribe_id = s.id
+            ${ew.customSqlSegment}
+    </select>
 
 </mapper>

+ 19 - 0
hx-wms/src/main/java/com/fjhx/wms/controller/stock/StockController.java

@@ -6,6 +6,7 @@ import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.wms.entity.stock.dto.StockDto;
 import com.fjhx.wms.entity.stock.dto.StockSelectDto;
 import com.fjhx.wms.entity.stock.po.Stock;
+import com.fjhx.wms.entity.stock.po.StockAnalysis;
 import com.fjhx.wms.entity.stock.vo.StockVo;
 import com.fjhx.wms.service.stock.StockService;
 import com.ruoyi.common.core.domain.BaseSelectDto;
@@ -13,6 +14,7 @@ import com.ruoyi.common.core.domain.entity.SysDept;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 
@@ -124,5 +126,22 @@ public class StockController {
         return stockService.getDepts();
     }
 
+    /**
+     * 库存分析
+     */
+    @PostMapping("/stockAnalysis")
+    public Page<StockAnalysis> stockAnalysis(@RequestBody StockSelectDto dto) {
+        return stockService.stockAnalysis(dto);
+    }
+
+    /**
+     * 库存分析导出excel
+     */
+    @PostMapping("/stockAnalysis/exportExcel")
+    public void exportExcel(@RequestBody StockSelectDto dto, HttpServletResponse httpServletResponse) {
+        stockService.exportExcel(dto,httpServletResponse);
+    }
+
+
 
 }

+ 58 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/ArrivalDetailPo.java

@@ -0,0 +1,58 @@
+package com.fjhx.wms.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 到货明细单
+ * </p>
+ *
+ * @author
+ * @since 2023-04-07
+ */
+@Getter
+@Setter
+@TableName("arrival_detail")
+public class ArrivalDetailPo extends BasePo {
+
+    /**
+     * 关联ID  产品ID/货品ID
+     */
+    private Long bussinessId;
+
+    /**
+     * 到货主表ID
+     */
+    private Long arrivalId;
+
+    /**
+     * 采购明细ID
+     */
+    private Long purchaseDetailId;
+
+    /**
+     * 到货数量
+     */
+    private BigDecimal count;
+
+    /**
+     * 质检状态 0未质检 10部分质检 20全部质检
+     */
+    private Integer status;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 发货明细id
+     */
+    private Long deliverGoodsDetailsId;
+
+}

+ 153 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/PurchaseDetailPo.java

@@ -0,0 +1,153 @@
+package com.fjhx.wms.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 申购单
+ * </p>
+ *
+ * @author 
+ * @since 2023-04-06
+ */
+@Getter
+@Setter
+@TableName("purchase_detail")
+public class PurchaseDetailPo extends BasePo {
+
+    /**
+     * 业务来源 0自建  1外销合同采购
+     */
+    private Integer dataResource;
+
+    /**
+     * 业务来源ID
+     */
+    private Long dataResourceId;
+
+    /**
+     * 关联ID  产品ID/货品ID
+     */
+    private Long bussinessId;
+
+    /**
+     * 申购明细ID
+     */
+    private Long subscribeDetailId;
+
+    /**
+     * 采购单ID
+     */
+    private Long purchaseId;
+
+    /**
+     * 采购数量
+     */
+    private BigDecimal count;
+
+    /**
+     * 单价
+     */
+    private BigDecimal price;
+
+    /**
+     * 总价
+     */
+    private BigDecimal amount;
+
+    /**
+     * 采购事由
+     */
+    private String content;
+
+    /**
+     * 状态 10、审批中 15:待采购 20、已采购  30、部分采购  40、已采购  99 作废
+     */
+    private Integer status;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 货品类型
+     */
+    @TableField(exist = false)
+    private String productType;
+
+    /**
+     * 所属分类
+     */
+    @TableField(exist = false)
+    private String productCategory;
+
+    /**
+     * 货品编码
+     */
+    @TableField(exist = false)
+    private String productCode;
+
+    /**
+     * 货品名称
+     */
+    @TableField(exist = false)
+    private String productName;
+
+    /**
+     * 单位
+     */
+    @TableField(exist = false)
+    private String productUnit;
+
+    /**
+     * 货品规格型号
+     */
+    @TableField(exist = false)
+    private String productSpec;
+
+    /**
+     * 到货总量
+     */
+    @TableField(exist = false)
+    private BigDecimal sumArrivalCount;
+
+    @TableField(exist = false)
+    private String productCustomCode;
+
+    /**
+     * 次品数量
+     */
+    @TableField(exist = false)
+    private BigDecimal defectiveQuantity;
+
+    /**
+     * 产品定义
+     */
+    @TableField(exist = false)
+    private Integer productDefinition;
+
+    /**
+     * 申购数量
+     */
+    @TableField(exist = false)
+    private BigDecimal subscribeQuantity;
+    /**
+     * 已采购数量
+     */
+    @TableField(exist = false)
+    private BigDecimal purchaseQuantity;
+
+    /**
+     * 产品部门id
+     */
+    @TableField(exist = false)
+    private Long productDeptId;
+
+}

+ 106 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/SubscribeDetailPo.java

@@ -0,0 +1,106 @@
+package com.fjhx.wms.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 申购单
+ * </p>
+ *
+ * @author
+ * @since 2023-04-03
+ */
+@Getter
+@Setter
+@TableName("subscribe_detail")
+public class SubscribeDetailPo extends BasePo {
+
+    /**
+     * 关联ID  产品ID/货品ID
+     */
+    private Long bussinessId;
+
+    /**
+     * 申购单ID
+     */
+    private Long subscribeId;
+
+    /**
+     * 申购数量
+     */
+    private BigDecimal count;
+
+    /**
+     * 申购事由
+     */
+    private String content;
+
+    /**
+     * 状态 10、审批中  20、已采购  30、部分到货  40、完成
+     */
+    private Integer status;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 是否删除
+     */
+    private Integer delFlag;
+
+    /**
+     * 货品类型
+     */
+    @TableField(exist = false)
+    private String productType;
+
+    /**
+     * 所属分类
+     */
+    @TableField(exist = false)
+    private String productCategory;
+
+    /**
+     * 货品编码
+     */
+    @TableField(exist = false)
+    private String productCode;
+
+    /**
+     * 货品名称
+     */
+    @TableField(exist = false)
+    private String productName;
+
+    /**
+     * 单位
+     */
+    @TableField(exist = false)
+    private String productUnit;
+
+    /**
+     * 货品规格型号
+     */
+    @TableField(exist = false)
+    private String productSpec;
+
+    /**
+     * 部门id
+     */
+    @TableField(exist = false)
+    private Long deptId;
+
+    /**
+     * 产品定义
+     */
+    @TableField(exist = false)
+    private Integer productDefinition;
+}

+ 10 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/stock/dto/StockSelectDto.java

@@ -48,4 +48,14 @@ public class StockSelectDto extends BaseSelectDto {
      */
     private Long deptId;
 
+    /**
+     * 产品类型
+     */
+    private Integer type;
+
+    /**
+     * 是否组合
+     */
+    private String isCombination;
+
 }

+ 139 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/stock/po/StockAnalysis.java

@@ -0,0 +1,139 @@
+package com.fjhx.wms.entity.stock.po;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 库存分析实体类
+ */
+@Getter
+@Setter
+@ExcelIgnoreUnannotated
+public class StockAnalysis {
+
+    /**
+     * 产品id
+     */
+    private Long productId;
+
+    /**
+     * 产品定义
+     */
+    private String productDefinition;
+
+    /**
+     * 产品类型
+     */
+    @ExcelProperty("商品类型")
+    private String productType;
+
+    /**
+     * 产品编码
+     */
+    @ColumnWidth(20)
+    @ExcelProperty("商品编码")
+    private String productCustomCode;
+
+    /**
+     * 产品名称
+     */
+    @ColumnWidth(20)
+    @ExcelProperty("商品名称")
+    private String productName;
+
+    /**
+     * 规格型号
+     */
+    @ColumnWidth(20)
+    @ExcelProperty("规格型号")
+    private String productSpec;
+
+    /**
+     * 是否是组合
+     */
+    @ExcelProperty("是否组合")
+    private String isCombination;
+
+    /**
+     * 管理部门名称
+     */
+    private Long deptId;
+
+    /**
+     * 管理部门名称
+     */
+    @ColumnWidth(20)
+    @ExcelProperty("管理部门")
+    private String deptName;
+
+    /**
+     * 待采购数量
+     */
+    @ExcelProperty("待采购数量")
+    private BigDecimal purchaseWaitQuantity;
+
+    /**
+     * 待入库数量
+     */
+    @ExcelProperty("待入库数量")
+    private BigDecimal stockWaitInQuantity;
+
+    /**
+     * 待出库数量
+     */
+    @ExcelProperty("待出库数量")
+    private BigDecimal stockWaitOutQuantity;
+
+    /**
+     * 可支配数量
+     */
+    @ExcelProperty("可支配库存")
+    private BigDecimal disposableQuantity;
+
+    /**
+     * 库存数量
+     */
+    @ExcelProperty("可用库存")
+    private BigDecimal quantity;
+
+    /**
+     * 冻结数量
+     */
+    @ExcelProperty("冻结库存")
+    private BigDecimal frozenQuantity;
+
+    /**
+     * 次品数量
+     */
+    @ExcelProperty("次品库存")
+    private BigDecimal defectiveQuantity;
+
+    /**
+     * 京东在途数量
+     */
+    @ExcelProperty("京东在途")
+    private BigDecimal jdInTransitQuantity;
+
+    /**
+     * 总数量
+     */
+    @ExcelProperty("总库存")
+    private BigDecimal totalQuantity;
+
+    /**
+     * 结存单价
+     */
+    @ExcelProperty("结存单价")
+    private BigDecimal unitPrice;
+
+    /**
+     * 库存金额
+     */
+    @ExcelProperty("库存金额")
+    private BigDecimal amount;
+}

+ 12 - 0
hx-wms/src/main/java/com/fjhx/wms/mapper/stock/StockMapper.java

@@ -3,6 +3,7 @@ package com.fjhx.wms.mapper.stock;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.wms.entity.stock.po.Stock;
+import com.fjhx.wms.entity.stock.po.StockAnalysis;
 import com.fjhx.wms.entity.stock.vo.StockVo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.utils.wrapper.IWrapper;
@@ -34,4 +35,15 @@ public interface StockMapper extends BaseMapper<Stock> {
      * 获取库存产品部门列表
      */
     List<SysDept> getDepts();
+
+    /**
+     * 库存分析
+     */
+    Page<StockAnalysis> getStockAnalysisPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<Stock> wrapper);
+
+    /**
+     * 库存分析列表
+     */
+    List<StockAnalysis> getStockAnalysisPage( @Param("ew") IWrapper<Stock> wrapper);
+
 }

+ 9 - 1
hx-wms/src/main/java/com/fjhx/wms/mapper/stock/StockWaitMapper.java

@@ -1,12 +1,15 @@
 package com.fjhx.wms.mapper.stock;
 
-import com.fjhx.wms.entity.stock.po.StockWait;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.wms.entity.stock.po.StockWait;
+import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
 import com.fjhx.wms.entity.stock.vo.StockWaitVo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 
 /**
  * <p>
@@ -28,4 +31,9 @@ public interface StockWaitMapper extends BaseMapper<StockWait> {
      */
     Page<StockWaitVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<StockWait> wrapper);
 
+    /**
+     * 获取待出入库列表
+     */
+    List<StockWaitDetailsVo> getStockWaitList(IWrapper<Object> wrapper);
+
 }

+ 27 - 0
hx-wms/src/main/java/com/fjhx/wms/service/PurService.java

@@ -1,8 +1,35 @@
 package com.fjhx.wms.service;
 
+import com.fjhx.wms.entity.ArrivalDetailPo;
+import com.fjhx.wms.entity.PurchaseDetailPo;
+import com.fjhx.wms.entity.SubscribeDetailPo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+
+import java.util.List;
+
 public interface PurService {
     /**
      * 修改采购到货状态
      */
     void updatePurchaseArrivalStatus(Long id);
+
+    /**
+     * 获取已采购数量
+     */
+     List<PurchaseDetailPo> getPurchaseCountList(IWrapper<Object> wrapper);
+
+    /**
+     * 获取已申购数量
+     */
+     List<SubscribeDetailPo> getSubscribeCountList(IWrapper<Object> wrapper);
+
+    /**
+     * 获取到货明细列表
+     */
+     List <ArrivalDetailPo>getArrivalDetailByIds(List<Long> ids);
+
+    /**
+     * 获取采购明细列表
+     */
+    List <PurchaseDetailPo>getPurchaseDetailByIds(List<Long> ids);
 }

+ 12 - 0
hx-wms/src/main/java/com/fjhx/wms/service/stock/StockService.java

@@ -6,11 +6,13 @@ import com.fjhx.wms.entity.stock.dto.StockDto;
 import com.fjhx.wms.entity.stock.dto.StockSelectDto;
 import com.fjhx.wms.entity.stock.emums.JournalType;
 import com.fjhx.wms.entity.stock.po.Stock;
+import com.fjhx.wms.entity.stock.po.StockAnalysis;
 import com.fjhx.wms.entity.stock.po.StockJournalDetails;
 import com.fjhx.wms.entity.stock.vo.StockVo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.service.BaseService;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 
@@ -91,4 +93,14 @@ public interface StockService extends BaseService<Stock> {
     void inOut(List<? extends InOutBo> list, Long warehouseId, JournalType journalType, Long businessId);
 
     List<SysDept> getDepts();
+
+    /**
+     * 库存分析
+     */
+    Page<StockAnalysis> stockAnalysis(StockSelectDto dto);
+
+    /**
+     * 库存分析导出excel
+     */
+    void exportExcel(StockSelectDto dto, HttpServletResponse httpServletResponse);
 }

+ 9 - 0
hx-wms/src/main/java/com/fjhx/wms/service/stock/StockWaitService.java

@@ -5,8 +5,12 @@ import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
 import com.fjhx.wms.entity.stock.dto.StockWaitDto;
 import com.fjhx.wms.entity.stock.dto.StockWaitSelectDto;
 import com.fjhx.wms.entity.stock.po.StockWait;
+import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
 import com.fjhx.wms.entity.stock.vo.StockWaitVo;
 import com.ruoyi.common.core.service.BaseService;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+
+import java.util.List;
 
 
 /**
@@ -65,4 +69,9 @@ public interface StockWaitService extends BaseService<StockWait> {
      * 结束入库
      */
     void endInStock(Long id);
+
+    /**
+     * 获取待出入库列表
+     */
+    List<StockWaitDetailsVo> getStockWaitList(IWrapper<Object> wrapper);
 }

+ 190 - 5
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockServiceImpl.java

@@ -14,6 +14,12 @@ import com.fjhx.item.entity.product.po.ProductClassify;
 import com.fjhx.item.entity.product.po.ProductInfo;
 import com.fjhx.item.service.product.ProductClassifyService;
 import com.fjhx.item.service.product.ProductInfoService;
+import com.fjhx.item.util.excel.util.ExcelUtil;
+import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
+import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
+import com.fjhx.tenant.service.dict.DictTenantDataService;
+import com.fjhx.wms.entity.PurchaseDetailPo;
+import com.fjhx.wms.entity.SubscribeDetailPo;
 import com.fjhx.wms.entity.stock.bo.InOutBo;
 import com.fjhx.wms.entity.stock.dto.StockDto;
 import com.fjhx.wms.entity.stock.dto.StockJournalDetailsDto;
@@ -21,14 +27,18 @@ import com.fjhx.wms.entity.stock.dto.StockSelectDto;
 import com.fjhx.wms.entity.stock.emums.InOutType;
 import com.fjhx.wms.entity.stock.emums.JournalType;
 import com.fjhx.wms.entity.stock.po.Stock;
+import com.fjhx.wms.entity.stock.po.StockAnalysis;
 import com.fjhx.wms.entity.stock.po.StockJournal;
 import com.fjhx.wms.entity.stock.po.StockJournalDetails;
 import com.fjhx.wms.entity.stock.vo.StockVo;
+import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
 import com.fjhx.wms.entity.warehouse.po.Warehouse;
 import com.fjhx.wms.mapper.stock.StockMapper;
+import com.fjhx.wms.service.PurService;
 import com.fjhx.wms.service.stock.StockJournalDetailsService;
 import com.fjhx.wms.service.stock.StockJournalService;
 import com.fjhx.wms.service.stock.StockService;
+import com.fjhx.wms.service.stock.StockWaitService;
 import com.fjhx.wms.service.warehouse.WarehouseService;
 import com.fjhx.wms.utils.CodeEnum;
 import com.obs.services.internal.ServiceException;
@@ -36,15 +46,14 @@ import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.ruoyi.common.utils.wrapper.SqlField;
 import com.ruoyi.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -69,9 +78,14 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
     ProductClassifyService productClassifyService;
     @Autowired
     WarehouseService warehouseService;
-
     @Autowired
     private ISysRoleService sysRoleService;
+    @Autowired
+    private PurService purService;
+    @Autowired
+    private StockWaitService stockWaitService;
+    @Autowired
+    private DictTenantDataService dictTenantDataService;
 
     @Override
     public Page<StockVo> getPage(StockSelectDto dto) {
@@ -760,4 +774,175 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         return baseMapper.getDepts();
     }
 
+    /**
+     * 库存分析
+     */
+    @Override
+    public Page<StockAnalysis> stockAnalysis(StockSelectDto dto) {
+        IWrapper<Stock> wrapper = getWrapper();
+        wrapper.eq("de.dept_id", dto.getDeptId());
+        wrapper.eq("pi.definition", dto.getDefinition());
+        wrapper.eq("pi.type", dto.getType());
+        wrapper.eq("ifnull(json_unquote( pi.victoriatourist_json -> '$.combination' ),0)", dto.getIsCombination());
+
+        wrapper.keyword(dto.getKeyword(),
+                new SqlField("pi.custom_code"),
+                new SqlField("pi.name"),
+                new SqlField("pi.spec")
+        );
+
+        wrapper.groupBy("s.product_id");
+        Page<StockAnalysis> page = baseMapper.getStockAnalysisPage(dto.getPage(), wrapper);
+        List<StockAnalysis> records = page.getRecords();
+        if (ObjectUtil.isEmpty(records)) {
+            return page;
+        }
+
+        //调用公共代码块处理数据
+        stockAnalysisComm(records);
+
+        return page;
+    }
+
+    @Override
+    public void exportExcel(StockSelectDto dto, HttpServletResponse httpServletResponse) {
+        IWrapper<Stock> wrapper = getWrapper();
+        wrapper.eq("de.dept_id", dto.getDeptId());
+        wrapper.eq("pi.definition", dto.getDefinition());
+        wrapper.eq("pi.type", dto.getType());
+        wrapper.eq("ifnull(json_unquote( pi.victoriatourist_json -> '$.combination' ),0)", dto.getIsCombination());
+
+        wrapper.keyword(dto.getKeyword(),
+                new SqlField("pi.custom_code"),
+                new SqlField("pi.name"),
+                new SqlField("pi.spec")
+        );
+
+        wrapper.groupBy("s.product_id");
+        List<StockAnalysis> list = baseMapper.getStockAnalysisPage(wrapper);
+
+        //调用公共代码块处理数据
+        stockAnalysisComm(list);
+
+        //获取字典Map
+        Map<String, String> dictMap = getDictMap("product_type");
+
+        for (StockAnalysis stockAnalysis : list) {
+            String productDefinition = "0".equals(stockAnalysis.getProductDefinition()) ? "产品" : "物料";
+            String isCombination = "0".equals(stockAnalysis.getIsCombination()) ? "否" : "是";
+            String productType = dictMap.get(stockAnalysis.getProductType());
+
+            stockAnalysis.setProductDefinition(productDefinition);
+            stockAnalysis.setIsCombination(isCombination);
+            stockAnalysis.setProductType(productType);
+        }
+
+        //导出Excel
+        ExcelUtil.export(httpServletResponse, list, StockAnalysis.class);
+    }
+
+    /**
+     * 库存分析 公共代码块
+     */
+    private void stockAnalysisComm(List<StockAnalysis> stockAnalysisList) {
+        List<Long> ids = stockAnalysisList.stream().map(StockAnalysis::getProductId).collect(Collectors.toList());
+
+        //获取已采购数量(审批中/审批通过)
+        List<PurchaseDetailPo> purchaseCountList = purService.getPurchaseCountList(IWrapper.<Object>getWrapper()
+                .in("pd.bussiness_id", ids)
+                .in("p.purchase_status", 10, 30)
+                .groupBy("pd.bussiness_id"));
+        purchaseCountList = ObjectUtil.isEmpty(purchaseCountList) ? new ArrayList<>() : purchaseCountList;
+        //获取已申购数量(审批中/审批通过)
+        List<SubscribeDetailPo> subscribeCountList = purService.getSubscribeCountList(IWrapper.<Object>getWrapper()
+                .in("sd.bussiness_id", ids)
+                .in("s.subcribe_status", 10, 30)
+                .groupBy("sd.bussiness_id"));
+        subscribeCountList = ObjectUtil.isEmpty(subscribeCountList) ? new ArrayList<>() : subscribeCountList;
+        //获取已采购数量(审批通过)
+        List<PurchaseDetailPo> purchaseCountList1 = purService.getPurchaseCountList(IWrapper.<Object>getWrapper()
+                .in("pd.bussiness_id", ids)
+                .eq("p.purchase_status", 30)
+                .groupBy("pd.bussiness_id"));
+        purchaseCountList1 = ObjectUtil.isEmpty(purchaseCountList1) ? new ArrayList<>() : purchaseCountList1;
+        //获取已入库数量
+        List<StockWaitDetailsVo> stockWaitList = stockWaitService.getStockWaitList(IWrapper.<Object>getWrapper()
+                .in("swd.product_id", ids)
+                .eq("sw.type", 1)
+        );
+        stockWaitList = ObjectUtil.isEmpty(stockWaitList) ? new ArrayList<>() : stockWaitList;
+        //获取待出库数量
+        List<StockWaitDetailsVo> stockWaitOutList = stockWaitService.getStockWaitList(IWrapper.<Object>getWrapper()
+                .in("swd.product_id", ids)
+                .eq("sw.type", 2)
+                .in("sw.business_type", 5, 6)
+        );
+        stockWaitOutList = ObjectUtil.isEmpty(stockWaitOutList) ? new ArrayList<>() : stockWaitOutList;
+        //京东订单待出库数量
+        List<StockWaitDetailsVo> jdStockWaitOutList = stockWaitService.getStockWaitList(IWrapper.<Object>getWrapper()
+                .in("swd.product_id", ids)
+                .eq("sw.type", 2)
+                .eq("sw.business_type", 5)
+        );
+        jdStockWaitOutList = ObjectUtil.isEmpty(jdStockWaitOutList) ? new ArrayList<>() : jdStockWaitOutList;
+
+        for (StockAnalysis record : stockAnalysisList) {
+            //待采购数量(申购数-采购数)
+            BigDecimal subscribeCount = subscribeCountList.stream()
+                    .filter(item -> item.getBussinessId().equals(record.getProductId()))
+                    .map(SubscribeDetailPo::getCount).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal purchaseCount = purchaseCountList.stream()
+                    .filter(item -> item.getBussinessId().equals(record.getProductId()))
+                    .map(PurchaseDetailPo::getCount).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal purchaseWaitCount = subscribeCount.subtract(purchaseCount);
+            //待入库数量
+            BigDecimal purchaseCount1 = purchaseCountList1.stream()
+                    .filter(item -> item.getBussinessId().equals(record.getProductId()))
+                    .map(PurchaseDetailPo::getCount).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal reduce = stockWaitList.stream()
+                    .filter(item -> item.getProductId().equals(record.getProductId()))
+                    .map(StockWaitDetailsVo::getReceiptQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal stockWaitInCount = purchaseCount1.subtract(reduce);
+            //待出库数量
+            BigDecimal stockWaitOutCount = stockWaitOutList.stream()
+                    .filter(item -> item.getProductId().equals(record.getProductId()))
+                    .map(item -> {
+                        return item.getQuantity().subtract(item.getReceiptQuantity());
+                    }).reduce(BigDecimal.ZERO, BigDecimal::add);
+            //可支配库存
+            BigDecimal disposableCount = record.getQuantity().subtract(stockWaitOutCount);
+            //京东订单待出库数量
+            BigDecimal jdStockWaitOutCount = jdStockWaitOutList.stream()
+                    .filter(item -> item.getProductId().equals(record.getProductId()))
+                    .map(item -> item.getQuantity().subtract(item.getReceiptQuantity())).reduce(BigDecimal.ZERO, BigDecimal::add);
+            //总库存
+            BigDecimal totalQuantity = record.getQuantity().add(record.getFrozenQuantity())
+                    .add(record.getDefectiveQuantity()).add(stockWaitInCount).add(jdStockWaitOutCount);
+            //总金额
+            BigDecimal amount = totalQuantity.multiply(record.getUnitPrice());
+            amount = amount.setScale(4, BigDecimal.ROUND_HALF_DOWN);
+
+            record.setPurchaseWaitQuantity(purchaseWaitCount);
+            record.setStockWaitInQuantity(stockWaitInCount);
+            record.setStockWaitOutQuantity(stockWaitOutCount);
+            record.setDisposableQuantity(disposableCount);
+            record.setJdInTransitQuantity(jdStockWaitOutCount);
+            record.setTotalQuantity(totalQuantity);
+            record.setAmount(amount);
+        }
+    }
+
+    Map<String, String> getDictMap(String code) {
+        DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
+        dto.setDictCode(code);
+        DynamicDataSourceContextHolder.push(SourceConstant.BASE);
+        List<DictTenantDataVo> dictTenantDataServiceList = dictTenantDataService.getList(dto);
+        DynamicDataSourceContextHolder.poll();
+        Map<String, String> dictMap = new HashMap<>();
+        if (ObjectUtil.isNotEmpty(dictTenantDataServiceList)) {
+            dictMap = dictTenantDataServiceList.stream().collect(Collectors.toMap(DictTenantDataVo::getDictKey, DictTenantDataVo::getDictValue));
+        }
+        return dictMap;
+    }
+
 }

+ 50 - 2
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitServiceImpl.java

@@ -12,6 +12,8 @@ import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.utils.Assert;
 import com.fjhx.item.entity.product.po.ProductInfo;
 import com.fjhx.item.service.product.ProductInfoService;
+import com.fjhx.wms.entity.ArrivalDetailPo;
+import com.fjhx.wms.entity.PurchaseDetailPo;
 import com.fjhx.wms.entity.arrival.po.ArrivalStockRecords;
 import com.fjhx.wms.entity.arrival.po.ArrivalStockRecordsDetails;
 import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
@@ -221,7 +223,7 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
 
     @DSTransactional
     @Override
-    public void addByWdly(StockWaitDto stockWaitDto) {
+    public synchronized void addByWdly(StockWaitDto stockWaitDto) {
         List<Stock> stockList = new ArrayList<>();
 
         List<StockWaitDetails> stockWaitDetailsDtoList = stockWaitDto.getStockWaitDetailsList();
@@ -255,13 +257,53 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         stockWaitDetailsService.changeStockWaitStatus(stockWaitDto);
         StockWait stockWait = getById(stockWaitDto.getId());
 
-
         String victoriatouristJson = stockWait.getVictoriatouristJson();
         JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
         json.put("receiptWarehouseId", stockWaitDto.getWarehouseId());
         stockWait.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         updateById(stockWait);
 
+        //如果是采购到货 计算结存单价
+        if (StockWaitType.PURCHASE_ARRIVAL_IN.getDetailType().equals(stockWait.getBusinessType())) {
+            List<Long> productIds = stockWaitDetailsDtoList.stream().map(StockWaitDetails::getProductId).distinct().collect(Collectors.toList());
+            Map<Long, ProductInfo> productInfoMap = productInfoService.mapKEntity(ProductInfo::getId, q -> q.in(ProductInfo::getId, productIds));
+            Map<Long, List<Stock>> stockListMap = stockService.mapKGroup(Stock::getProductId, q -> q.in(Stock::getProductId, productIds));
+
+            List<Long> arrIds = stockWaitDetailsDtoList.stream().map(StockWaitDetails::getBusinessDetailsId).distinct().collect(Collectors.toList());
+            List<ArrivalDetailPo> arrivalDetailByIds = purService.getArrivalDetailByIds(arrIds);
+            Map<Long, ArrivalDetailPo> arrivalDetailMap = arrivalDetailByIds.stream().collect(Collectors.toMap(ArrivalDetailPo::getId, Function.identity()));
+
+            List<Long> purchaseIds = arrivalDetailByIds.stream().map(ArrivalDetailPo::getPurchaseDetailId).distinct().collect(Collectors.toList());
+            List<PurchaseDetailPo> purchaseDetailByIds = purService.getPurchaseDetailByIds(purchaseIds);
+            Map<Long, PurchaseDetailPo> purchaseDetailMap = purchaseDetailByIds.stream().collect(Collectors.toMap(PurchaseDetailPo::getId, Function.identity()));
+
+            List<ProductInfo> productInfoList = new ArrayList<>();
+            for (StockWaitDetails stockWaitDetails : stockWaitDetailsDtoList) {
+                ProductInfo productInfo = productInfoMap.get(stockWaitDetails.getProductId());
+
+                //获取所有仓库的该商品库存数量
+                List<Stock> stockList1 = stockListMap.getOrDefault(stockWaitDetails.getProductId(), new ArrayList<>());
+                BigDecimal quantity = stockList1.stream().map(Stock::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+                ArrivalDetailPo arrivalDetailPo = arrivalDetailMap.get(stockWaitDetails.getBusinessDetailsId());
+                PurchaseDetailPo purchaseDetailPo = purchaseDetailMap.get(arrivalDetailPo.getPurchaseDetailId());
+
+                //计算结存单价(库存数量*结存单价+入库数量*入库单价)/(库存数量+入库数量)
+                BigDecimal unitPrice = productInfo.getUnitPrice();
+                unitPrice = ObjectUtil.isNotEmpty(unitPrice) ? unitPrice : BigDecimal.ZERO;
+                BigDecimal multiply = quantity.multiply(unitPrice);
+                BigDecimal multiply1 = stockWaitDetails.getQuantity().multiply(purchaseDetailPo.getPrice());
+                BigDecimal add = multiply.add(multiply1);
+                BigDecimal add1 = quantity.add(stockWaitDetails.getQuantity());
+                BigDecimal divide = add.divide(add1, 4, BigDecimal.ROUND_HALF_DOWN);
+
+                productInfo.setUnitPrice(divide);
+                productInfoList.add(productInfo);
+            }
+
+            productInfoService.updateBatchById(productInfoList);
+        }
+
         //操作库存
         List<Long> swdIds = stockWaitDetailsDtoList.stream().map(StockWaitDetails::getId).collect(Collectors.toList());
         Map<Long, StockWaitDetails> oldStockWaitDetailsMap = stockWaitDetailsService.mapKEntity(StockWaitDetails::getId, q -> q.in(StockWaitDetails::getId, swdIds));
@@ -387,4 +429,10 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         wmsService.addEndInStockAbnormal(stockWait.getId(), stockWait.getBusinessCode(), purchaseId);
     }
 
+    @Override
+    public List<StockWaitDetailsVo> getStockWaitList(IWrapper<Object> wrapper) {
+        return null;
+    }
+
+
 }

+ 21 - 0
hx-wms/src/main/resources/mapper/stock/StockMapper.xml

@@ -66,5 +66,26 @@
         GROUP BY
             de.dept_id
     </select>
+    <select id="getStockAnalysisPage" resultType="com.fjhx.wms.entity.stock.po.StockAnalysis">
+        SELECT
+            s.product_id,
+            sum( ifnull( s.quantity, 0 ) ) AS quantity,
+            sum( ifnull( json_unquote( s.victoriatourist_json -> '$.frozenQuantity' ), 0 )) AS frozenQuantity,
+            sum( ifnull( json_unquote( s.victoriatourist_json -> '$.defectiveQuantity' ), 0 )) AS defectiveQuantity,
+            ifnull( pi.unit_price, 0 ) AS unitPrice,
+            de.dept_id deptId,
+            de.dept_name deptName,
+            pi.definition productDefinition,
+            pi.type AS productType,
+            pi.custom_code AS productCustomCode,
+            pi.name AS productName,
+            pi.spec AS productSpec,
+            ifnull( json_unquote( pi.victoriatourist_json -> '$.combination' ), 0 ) isCombination
+        FROM
+            stock s
+                LEFT JOIN bytesailing_item.product_info pi ON s.product_id = pi.id
+                LEFT JOIN bytesailing_base.sys_dept de ON CAST(json_unquote(pi.victoriatourist_json -> '$.deptId') AS UNSIGNED) = de.dept_id
+        ${ew.customSqlSegment}
+    </select>
 
 </mapper>

+ 8 - 0
hx-wms/src/main/resources/mapper/stock/StockWaitMapper.xml

@@ -41,5 +41,13 @@
             stock_wait sw
             ${ew.customSqlSegment}
     </select>
+    <select id="getStockWaitList" resultType="com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo">
+        SELECT
+            *
+        FROM
+            stock_wait_details swd
+                LEFT JOIN stock_wait sw ON swd.stock_wait_id = sw.id
+            ${ew.customSqlSegment}
+    </select>
 
 </mapper>