瀏覽代碼

问题处理

yzc 2 年之前
父節點
當前提交
cba7cf5773

+ 2 - 1
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductSpuServiceImpl.java

@@ -83,7 +83,8 @@ public class ProductSpuServiceImpl extends ServiceImpl<ProductSpuMapper, Product
         if(ObjectUtil.isNotEmpty(productInfos)){
             //移除被删除的条目
             List<Long> productIds = productInfos.stream().map(ProductInfo::getId).collect(Collectors.toList());
-            List<ProductInfo> productInfos1 = productInfoService.list(q->q.notIn(ProductInfo::getId,productIds));
+            List<ProductInfo> productInfos1 = productInfoService.list(q->q.notIn(ProductInfo::getId,productIds)
+                    .eq(ProductInfo::getProductSpuId,productSpuDto.getId()));
             for (ProductInfo productInfo :productInfos1){
                 productInfo.setProductSpuId(-1l);
             }

+ 11 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/stock/vo/StockVo.java

@@ -89,4 +89,15 @@ public class StockVo extends Stock {
      */
     private Long combinationQuantity;
 
+    /**
+     * 冻结库存
+     */
+    private BigDecimal frozenQuantity;
+
+    /**
+     * 次品库存
+     */
+    private BigDecimal defectiveQuantity;
+
+
 }

+ 7 - 0
hx-wms/src/main/java/com/fjhx/wms/entity/stock/vo/StockWaitDetailsVo.java

@@ -4,6 +4,8 @@ import com.fjhx.wms.entity.stock.po.StockWaitDetails;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.math.BigDecimal;
+
 /**
  * 待出入库明细列表查询返回值实体
  *
@@ -64,4 +66,9 @@ public class StockWaitDetailsVo extends StockWaitDetails {
      */
     private Integer status;
 
+    /**
+     * 已出库数量
+     */
+    private BigDecimal receiptQuantity;
+
 }

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

@@ -160,6 +160,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         Page<StockVo> page = this.baseMapper.pageByProduct(dto.getPage(), wrapper);
         List<StockVo> stockVos = page.getRecords();
 
+        //赋值冻结库存和次品库存
+        for (StockVo stockVo : stockVos) {
+            JSONObject json = new JSONObject();
+            BigDecimal frozenQuantity = stockVo.getFrozenQuantity();
+            frozenQuantity = frozenQuantity == null ? BigDecimal.ZERO : frozenQuantity;
+            json.put("frozenQuantity", frozenQuantity);
+            BigDecimal defectiveQuantity = stockVo.getDefectiveQuantity();
+            defectiveQuantity = defectiveQuantity == null ? BigDecimal.ZERO : defectiveQuantity;
+            json.put("defectiveQuantity", defectiveQuantity);
+            stockVo.setVictoriatouristJson(json.toJSONString());
+        }
+
         //赋值产品名称
         productInfoService.attributeAssign(stockVos, StockVo::getProductId, (item, productInfo) -> {
             item.setType(productInfo.getType());
@@ -213,7 +225,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         //赋值关联产品数
         List<StockVo> records = page.getRecords();
         List<Long> spuids = records.stream().map(StockVo::getProductSpuId).collect(Collectors.toList());
-        if(ObjectUtil.isEmpty(spuids)){
+        if (ObjectUtil.isEmpty(spuids)) {
             return page;
         }
         List<ProductInfo> productInfoList = productInfoService.list(q -> q.in(ProductInfo::getProductSpuId, spuids));
@@ -228,7 +240,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         for (StockVo record : records) {
             String victoriatouristJson = record.getVictoriatouristJson();
             JSONObject json = JSONObject.parseObject(victoriatouristJson);
-            if(json.getInteger("combination")!=1){
+            if (json.getInteger("combination") != 1) {
                 continue;
             }
             JSONArray productCombinationList = json.getJSONArray("productCombinationList");
@@ -239,7 +251,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
 //                BigDecimal linkQuantity = item.getBigDecimal("linkQuantity");
             }
         }
-        if(ObjectUtil.isEmpty(linkProductIds)){
+        if (ObjectUtil.isEmpty(linkProductIds)) {
             return page;
         }
         //查询关联产品库存
@@ -248,7 +260,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         for (StockVo record : records) {
             String victoriatouristJson = record.getVictoriatouristJson();
             JSONObject json = JSONObject.parseObject(victoriatouristJson);
-            if(json.getInteger("combination")!=1){
+            if (json.getInteger("combination") != 1) {
                 continue;
             }
             JSONArray productCombinationList = json.getJSONArray("productCombinationList");
@@ -259,7 +271,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
                 Long linkProductId = item.getLong("linkProductId");
                 BigDecimal linkQuantity = item.getBigDecimal("linkQuantity");
 
-                BigDecimal stockQuantity = stockMap.getOrDefault(linkProductId,BigDecimal.ZERO);
+                BigDecimal stockQuantity = stockMap.getOrDefault(linkProductId, BigDecimal.ZERO);
 
                 BigDecimal divide = stockQuantity.divide(linkQuantity, 0, BigDecimal.ROUND_DOWN);
 
@@ -378,6 +390,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
                 newStocks.setQuantity(quantity);
             } else if (type == 2) {
                 ProductInfo productInfo = productInfoService.getById(stock.getProductId());
+                if (productInfo == null) {
+                    throw new ServiceException("产品id:" + stock.getProductId() + "不存在");
+                }
                 throw new ServiceException("以下商品库存不足,无法出库:" + productInfo.getName());
             }
 

+ 6 - 0
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitDetailsServiceImpl.java

@@ -20,6 +20,7 @@ import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
 import cn.hutool.core.bean.BeanUtil;
 
 import javax.xml.ws.soap.Addressing;
+import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
 
@@ -57,6 +58,11 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
         wrapper.eq("sw", StockWait::getStatus,dto.getStatus());
         Page<StockWaitDetailsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<StockWaitDetailsVo> records = page.getRecords();
+        for (StockWaitDetailsVo record : records) {
+            if(ObjectUtil.isEmpty(record.getReceiptQuantity())){
+                record.setReceiptQuantity(BigDecimal.ZERO);
+            }
+        }
         // 赋值产品属性
         productInfoService.attributeAssign(records, StockWaitDetailsVo::getProductId, (item, productInfo) -> {
             item.setProductCode(productInfo.getCode());

+ 2 - 1
hx-wms/src/main/resources/mapper/stock/StockMapper.xml

@@ -28,7 +28,8 @@
             s.create_time,
             s.update_user,
             s.update_time,
-            JSON_REPLACE( s.victoriatourist_json, '$.frozenQuantity', sum( json_unquote( s.victoriatourist_json -> '$.frozenQuantity' )), '$.defectiveQuantity', sum( json_unquote( s.victoriatourist_json -> '$.defectiveQuantity' )) ) victoriatourist_json
+            sum(json_unquote( s.victoriatourist_json -> '$.frozenQuantity' )) frozenQuantity,
+            sum(json_unquote( s.victoriatourist_json -> '$.defectiveQuantity' )) defectiveQuantity
         FROM
             stock s
                 LEFT JOIN bytesailing_item.product_info pi ON s.product_id = pi.id