Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

wxf 2 yıl önce
ebeveyn
işleme
0a62a5541e

+ 10 - 3
hx-mes/src/main/java/com/fjhx/mes/service/border/impl/BorderOfLineServiceImpl.java

@@ -17,6 +17,8 @@ import com.fjhx.mes.mapper.border.BorderOfLineMapper;
 import com.fjhx.mes.service.border.BorderOfLineJournalService;
 import com.fjhx.mes.service.border.BorderOfLineService;
 import com.fjhx.wms.entity.stock.po.StockWait;
+import com.fjhx.wms.entity.stock.po.StockWaitDetails;
+import com.fjhx.wms.service.stock.StockWaitDetailsService;
 import com.fjhx.wms.service.stock.StockWaitService;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,6 +49,8 @@ public class BorderOfLineServiceImpl extends ServiceImpl<BorderOfLineMapper, Bor
     ProductClassifyService productClassifyService;
     @Autowired
     StockWaitService stockWaitService;
+    @Autowired
+    StockWaitDetailsService stockWaitDetailsService;
 
     @Override
     public Page<BorderOfLineVo> getPage(BorderOfLineSelectDto dto) {
@@ -161,11 +165,14 @@ public class BorderOfLineServiceImpl extends ServiceImpl<BorderOfLineMapper, Bor
             stockWait.setType(1);
             stockWait.setBusinessType(1);
             stockWait.setBusinessId(borderOfLineJournal.getId());
-            stockWait.setProductId(borderOfLine.getProductId());
-            stockWait.setQuantity(borderOfLineDto.getQuantity());
-            stockWait.setReceiptQuantity(BigDecimal.ZERO);
             stockWait.setStatus(0);
             stockWaitService.save(stockWait);
+            StockWaitDetails stockWaitDetails = new StockWaitDetails();
+            stockWaitDetails.setStockWaitId(stockWait.getId());
+            stockWaitDetails.setProductId(borderOfLine.getProductId());
+            stockWaitDetails.setQuantity(borderOfLineDto.getQuantity());
+            stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
+            stockWaitDetailsService.save(stockWaitDetails);
         }
     }
 

+ 10 - 3
hx-mes/src/main/java/com/fjhx/mes/service/completion/impl/CompletionInfoServiceImpl.java

@@ -20,6 +20,8 @@ import com.fjhx.mes.service.production.ProductionPlanService;
 import com.fjhx.mes.service.production.ProductionTaskService;
 import com.fjhx.mes.service.work.WorkOrderService;
 import com.fjhx.wms.entity.stock.po.StockWait;
+import com.fjhx.wms.entity.stock.po.StockWaitDetails;
+import com.fjhx.wms.service.stock.StockWaitDetailsService;
 import com.fjhx.wms.service.stock.StockWaitService;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +46,8 @@ public class CompletionInfoServiceImpl extends ServiceImpl<CompletionInfoMapper,
     @Autowired
     StockWaitService stockWaitService;
     @Autowired
+    StockWaitDetailsService stockWaitDetailsService;
+    @Autowired
     ProductionTaskService productionTaskService;
     @Autowired
     ProductInfoService productInfoService;
@@ -111,11 +115,14 @@ public class CompletionInfoServiceImpl extends ServiceImpl<CompletionInfoMapper,
         stockWait.setType(1);
         stockWait.setBusinessType(2);
         stockWait.setBusinessId(completionInfoDto.getId());
-        stockWait.setProductId(detail.getProductId());
-        stockWait.setQuantity(completionInfoDto.getQuantity());
-        stockWait.setReceiptQuantity(BigDecimal.ZERO);
         stockWait.setStatus(0);
         stockWaitService.save(stockWait);
+        StockWaitDetails stockWaitDetails =new StockWaitDetails();
+        stockWaitDetails.setStockWaitId(stockWait.getId());
+        stockWaitDetails.setProductId(detail.getProductId());
+        stockWaitDetails.setQuantity(completionInfoDto.getQuantity());
+        stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
+        stockWaitDetailsService.save(stockWaitDetails);
         //判断完工数量是否等于任务数量如果是修改任务状态为完成
         if (completionInfoDto.getQuantity().compareTo(detail.getQuantity()) >= 0) {
             detail.setStatus(2);

+ 20 - 10
hx-purchase/src/main/java/com/fjhx/purchase/flow/SalesReturnFlow.java

@@ -16,8 +16,11 @@ import com.fjhx.purchase.service.sales.SalesReturnDetailService;
 import com.fjhx.purchase.service.sales.SalesReturnService;
 import com.fjhx.purchase.util.code.CodeEnum;
 import com.fjhx.wms.entity.stock.po.StockWait;
+import com.fjhx.wms.entity.stock.po.StockWaitDetails;
+import com.fjhx.wms.service.stock.StockWaitDetailsService;
 import com.fjhx.wms.service.stock.StockWaitService;
 import com.obs.services.internal.ServiceException;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -34,6 +37,9 @@ import java.util.List;
 @Component
 public class SalesReturnFlow extends FlowDelegate {
 
+    @Autowired
+    StockWaitDetailsService stockWaitDetailsService;
+
     @Override
     public String getFlowKey() {
         return "sales_return_flow";
@@ -93,18 +99,22 @@ public class SalesReturnFlow extends FlowDelegate {
         List<SalesReturnDetail> salesReturnDetailList = salesReturnDetailService.list(Wrappers.<SalesReturnDetail>query()
                 .lambda().eq(SalesReturnDetail::getSalesReturnId, salesReturn.getId()));
         //添加一份待出库数据
-        List<StockWait> stockWaitList = new ArrayList<>();
+        StockWait stockWait = new StockWait();
+        stockWait.setBusinessId(businessId);
+        stockWait.setType(2);//入库
+        stockWait.setStatus(0);//待入库
+        stockWait.setBusinessType(4);//退货出库
+        stockWaitService.save(stockWait);
+        List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
         for (SalesReturnDetail s : salesReturnDetailList) {
-            StockWait stockWait = new StockWait();
-            stockWait.setProductId(s.getBussinessId());
-            stockWait.setBusinessId(s.getId());//到货明细ID
-            stockWait.setType(2);//入库
-            stockWait.setStatus(0);//待入库
-            stockWait.setBusinessType(4);//退货出库
-            stockWait.setQuantity(s.getCount());
-            stockWaitList.add(stockWait);
+            StockWaitDetails stockWaitDetails = new StockWaitDetails();
+            stockWaitDetails.setStockWaitId(stockWait.getId());
+            stockWaitDetails.setProductId(s.getBussinessId());
+            stockWaitDetails.setBusinessDetailsId(s.getId());//到货明细ID
+            stockWaitDetails.setQuantity(s.getCount());
+            stockWaitDetailsList.add(stockWaitDetails);
         }
-        stockWaitService.saveBatch(stockWaitList);
+        stockWaitDetailsService.saveBatch(stockWaitDetailsList);
     }
 
 }

+ 13 - 10
hx-purchase/src/main/java/com/fjhx/purchase/service/arrival/impl/ArrivalServiceImpl.java

@@ -115,7 +115,13 @@ public class ArrivalServiceImpl extends ServiceImpl<ArrivalMapper, Arrival> impl
         //取出到货明细
         List<ArrivalDetail> arrivalDetailList = arrival.getArrivalDetailList();
         if (CollectionUtils.isNotEmpty(arrivalDetailList)) {
-            List<StockWait> stockWaitList = new ArrayList<>();
+            StockWait stockWait = new StockWait();
+            stockWait.setBusinessId(arrival.getId());//到货明细ID
+            stockWait.setType(1);//入库
+            stockWait.setStatus(0);//待入库
+            stockWait.setBusinessType(3);//采购到货
+            stockWaitService.save(stockWait);
+            List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
             for (ArrivalDetail d : arrivalDetailList) {
                 //todo 这一块是做了采购到货状态修改。前端已经完成
                 //查询采购明细
@@ -128,17 +134,14 @@ public class ArrivalServiceImpl extends ServiceImpl<ArrivalMapper, Arrival> impl
 //
 //                }
                 d.setArrivalId(arrival.getId());
-                StockWait stockWait = new StockWait();
-                stockWait.setProductId(d.getBussinessId());
-                stockWait.setBusinessId(d.getId());//到货明细ID
-                stockWait.setType(1);//入库
-                stockWait.setStatus(0);//待入库
-                stockWait.setBusinessType(3);//采购到货
-                stockWait.setQuantity(d.getCount());
-                stockWaitList.add(stockWait);
+                StockWaitDetails stockWaitDetails = new StockWaitDetails();
+                stockWaitDetails.setStockWaitId(stockWait.getId());
+                stockWaitDetails.setProductId(d.getBussinessId());
+                stockWaitDetails.setQuantity(d.getCount());
+                stockWaitDetailsList.add(stockWaitDetails);
             }
             arrivalDetailService.saveBatch(arrivalDetailList);
-            stockWaitService.saveBatch(stockWaitList);
+            stockWaitDetailsService.saveBatch(stockWaitDetailsList);
         }
     }
 

+ 4 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/stock/dto/StockWaitDto.java

@@ -5,6 +5,7 @@ import com.fjhx.wms.entity.stock.po.StockWaitDetails;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -27,4 +28,7 @@ public class StockWaitDto extends StockWait {
      */
     private List<StockWaitDetails> stockWaitDetailsList;
 
+    /**待入库数量*/
+    private BigDecimal quantity;
+
 }

+ 14 - 14
hx-wms/src/main/java/com/fjhx/wms/entity/stock/po/StockWait.java

@@ -42,20 +42,20 @@ public class StockWait extends BasePo {
      */
     private String businessCode;
 
-    /**
-     * 商品id
-     */
-    private Long productId;
-
-    /**
-     * 数量
-     */
-    private BigDecimal quantity;
-
-    /**
-     * 已入库数量
-     */
-    private BigDecimal receiptQuantity;
+//    /**
+//     * 商品id
+//     */
+//    private Long productId;
+//
+//    /**
+//     * 数量
+//     */
+//    private BigDecimal quantity;
+//
+//    /**
+//     * 已入库数量
+//     */
+//    private BigDecimal receiptQuantity;
 
     /**
      * 入库状态 0待入库 1部分入库 2入库完成

+ 39 - 2
hx-wms/src/main/java/com/fjhx/wms/entity/stock/vo/StockWaitVo.java

@@ -1,10 +1,10 @@
 package com.fjhx.wms.entity.stock.vo;
 
 import com.fjhx.wms.entity.stock.po.StockWait;
-import com.fjhx.wms.entity.stock.po.StockWaitDetails;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -18,16 +18,53 @@ import java.util.List;
 public class StockWaitVo extends StockWait {
 
     /**
+     * 商品id
+     */
+    private Long productId;
+
+    /**
+     * 数量
+     */
+    private BigDecimal quantity;
+
+    /**
+     * 已入库数量
+     */
+    private BigDecimal receiptQuantity;
+
+    /**
      * 商品名称
      */
     private String productName;
 
     /**
+     * 产品编码
+     */
+    private String productCode;
+
+    /**
+     * 产品类型
+     */
+    private Integer productType;
+
+    /**
+     * 规格型号
+     */
+    private String productSpec;
+
+    /**
+     * 单位
+     */
+    private String productUnit;
+
+    /**
      * 待入库明细
      */
     private List<StockWaitDetailsVo> stockWaitDetailsList;
 
-    /**操作人名称*/
+    /**
+     * 操作人名称
+     */
     private String operatorName;
 
 }

+ 21 - 20
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitServiceImpl.java

@@ -69,18 +69,14 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         Page<StockWaitVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
 
         List<StockWaitVo> records = page.getRecords();
-        List<Long> productIds = records.stream().map(StockWaitVo::getProductId).collect(Collectors.toList());
-        if (ObjectUtil.isNotEmpty(productIds)) {
-            List<ProductInfo> productInfos = productInfoService.listByIds(productIds);
-            Map<Long, ProductInfo> productInfoMap = productInfos.stream().collect(Collectors.groupingBy(ProductInfo::getId,
-                    Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
-            for (StockWaitVo stockWaitVo : records) {
-                ProductInfo productInfo = productInfoMap.get(stockWaitVo.getProductId());
-                if (ObjectUtil.isNotEmpty(productInfo)) {
-                    stockWaitVo.setProductName(productInfo.getName());
-                }
-            }
-        }
+        // 赋值产品属性
+        productInfoService.attributeAssign(records, StockWaitVo::getProductId, (item, productInfo) -> {
+            item.setProductCode(productInfo.getCode());
+            item.setProductUnit(productInfo.getUnit());
+            item.setProductType(productInfo.getType());
+            item.setProductName(productInfo.getName());
+            item.setProductSpec(productInfo.getSpec());
+        });
 
         return page;
     }
@@ -131,10 +127,12 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
 
     @Override
     public StockWaitVo detail(Long id) {
-        StockWait stockWait = this.getById(id);
+        StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(id);
+        StockWait stockWait = this.getById(stockWaitDetails.getStockWaitId());
         StockWaitVo result = BeanUtil.toBean(stockWait, StockWaitVo.class);
-        ProductInfo byId = productInfoService.getById(result.getProductId());
+        ProductInfo byId = productInfoService.getById(stockWaitDetails.getProductId());
         result.setProductName(byId.getName());
+        result.setQuantity(stockWaitDetails.getQuantity());
         return result;
     }
 
@@ -168,13 +166,16 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void add(StockWaitDto stockWaitDto) {
-        //更新已入库数量
-        StockWait byId = getById(stockWaitDto.getId());
-        byId.setReceiptQuantity(byId.getReceiptQuantity().add(stockWaitDto.getQuantity()));
-        if (byId.getReceiptQuantity().compareTo(byId.getQuantity()) > 0) {
+        //更新已入库数量 根据明细id
+//        StockWait byId = getById(stockWaitDto.getId());
+        StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDto.getId());
+        stockWaitDetails.setReceiptQuantity(stockWaitDetails.getReceiptQuantity().add(stockWaitDto.getQuantity()));
+        if (stockWaitDetails.getReceiptQuantity().compareTo(stockWaitDetails.getQuantity()) > 0) {
             throw new ServiceException("入库数量+已入库数量不能大于待采购数量");
         }
-        updateById(byId);
+//        updateById(byId);
+        stockWaitDetailsService.updateById(stockWaitDetails);
+        StockWait byId = getById(stockWaitDetails.getStockWaitId());
         //创建出入库记录
         StockJournal stockJournal = new StockJournal();
         stockJournal.setType(byId.getType() == 1 ? 4 : 5);
@@ -186,7 +187,7 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         //操作库存
         Stock stock = new Stock();
         stock.setQuantity(stockWaitDto.getQuantity());
-        stock.setProductId(byId.getProductId());
+        stock.setProductId(stockWaitDetails.getProductId());
         List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), byId.getType(), Arrays.asList(stock), stockWaitDto.getWarehouseId());
         //保存出入库明细
         stockJournalDetailsService.saveBatch(stockJournalDetailsList);

+ 10 - 7
hx-wms/src/main/resources/mapper/stock/StockWaitMapper.xml

@@ -2,22 +2,25 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.wms.mapper.stock.StockWaitMapper">
     <select id="getPage" resultType="com.fjhx.wms.entity.stock.vo.StockWaitVo">
-        select
-            sw.id,
+        SELECT
+            swd.id,
             sw.type,
             sw.business_id,
             sw.business_code,
             sw.business_type,
-            sw.product_id,
-            sw.quantity,
-            sw.receipt_quantity,
-            sw.status,
+            swd.stock_wait_id,
+            swd.product_id,
+            swd.quantity,
+            swd.receipt_quantity,
+            sw.`status`,
             sw.create_user,
             sw.create_time,
             sw.update_user,
             sw.update_time,
             sw.victoriatourist_json
-        from stock_wait sw
+        FROM
+            stock_wait sw
+                JOIN stock_wait_details swd ON swd.stock_wait_id = sw.id
             ${ew.customSqlSegment}
     </select>