瀏覽代碼

问题处理

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

+ 5 - 0
hx-purchase/src/main/java/com/fjhx/purchase/entity/subscribe/vo/SubscribeDetailVo.java

@@ -66,4 +66,9 @@ public class SubscribeDetailVo extends SubscribeDetail {
      * 产品类型定义
      */
     private Integer productDefinition;
+
+    /**
+     * 产品自定义编码
+     */
+    private String productCustomCode;
 }

+ 3 - 1
hx-purchase/src/main/java/com/fjhx/purchase/service/subscribe/impl/SubscribeDetailServiceImpl.java

@@ -96,6 +96,7 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
             s.setProductCategory(productInfo.getClassifyName());
             s.setProductUnit(productInfo.getUnit());
             s.setProductDefinition(productInfo.getDefinition());
+            s.setProductCustomCode(productInfo.getCustomCode());
         }
 
         return page;
@@ -160,7 +161,7 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
             List<Long> productIds = list.stream().map(SubscribeDetail::getBussinessId).collect(Collectors.toList());
             List<ProductInfoVo> productInfoVos = productInfoService.getListByProductIds(productIds);
             Map<Long, List<ProductInfoVo>> productMap = productInfoVos.stream().collect(Collectors.groupingBy(ProductInfoVo::getId));
-            for (SubscribeDetail s : list) {
+            for (SubscribeDetailVo  s: list) {
                 if (MapUtils.isNotEmpty(productMap)) {
                     ProductInfoVo p = productMap.get(s.getBussinessId()).get(0);
                     s.setProductCategory(p.getClassifyName());
@@ -169,6 +170,7 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
                     s.setProductType(p.getType());
                     s.setProductName(p.getName());
                     s.setProductSpec(p.getSpec());
+                    s.setProductCustomCode(p.getCustomCode());
 
                     //维多利亚赋值部门id
                     String victoriatouristJson = p.getVictoriatouristJson();

+ 29 - 38
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockServiceImpl.java

@@ -353,52 +353,43 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
 
         List<StockJournalDetails> stockJournalDetailsList = new ArrayList<>();
         for (Stock stock : list) {
-            Stock newStocks = new Stock();
-            newStocks.setWarehouseId(warehouseId);
-            newStocks.setProductId(stock.getProductId());
-            if (ObjectUtil.isEmpty(stock.getQuantity())) {
-                //判断传操作的库存是否为空 空赋值0
-                stock.setQuantity(BigDecimal.ZERO);
+            Stock oldStocks = stockMap.get(stock.getProductId());
+            //如果库存不存在 就创建一条空库存
+            if (ObjectUtil.isEmpty(oldStocks)) {
+                oldStocks = new Stock();
+                oldStocks.setProductId(stock.getProductId());
+                oldStocks.setWarehouseId(warehouseId);
+                oldStocks.setQuantity(BigDecimal.ZERO);
             }
-            newStocks.setQuantity(stock.getQuantity());
 
-            //合并库存数量
-            Stock oldStocks = stockMap.get(stock.getProductId());
-            //用来存储操作数据
-            if (ObjectUtil.isNotEmpty(oldStocks)) {
-                BigDecimal quantity = oldStocks.getQuantity();
-                if (type == 1) {
-                    //入库库存相加
-                    quantity = quantity.add(stock.getQuantity());
-                } else if (type == 2) {
-                    //出库库存相减
-                    quantity = quantity.subtract(stock.getQuantity());
-                    if (quantity.compareTo(BigDecimal.ZERO) < 0) {
-                        throw new ServiceException("库存不足无法出库");
-                    }
-                } else if (type == 3) {
-                    //维多利亚入库增加冻结库存
-                    String victoriatouristJson = oldStocks.getVictoriatouristJson();
-                    JSONObject json = ObjectUtil.isEmpty(victoriatouristJson) ? new JSONObject() : JSONObject.parseObject(victoriatouristJson);
-                    BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
-                    frozenQuantity = frozenQuantity == null ? BigDecimal.ZERO : frozenQuantity;
-                    frozenQuantity = frozenQuantity.add(stock.getQuantity());
-                    json.put("frozenQuantity", frozenQuantity);
-                    newStocks.setVictoriatouristJson(json.toJSONString());
-                } else {
-                    throw new ServiceException("未知库存操作类型");
-                }
-                newStocks.setId(oldStocks.getId());
-                newStocks.setQuantity(quantity);
+            if (type == 1) {
+                //入库库存相加
+                BigDecimal quantity = oldStocks.getQuantity().add(stock.getQuantity());
+                oldStocks.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());
+                BigDecimal quantity = oldStocks.getQuantity().subtract(stock.getQuantity());
+                if (quantity.compareTo(BigDecimal.ZERO) < 0) {
+                    throw new ServiceException("以下商品库存不足,无法出库:" + productInfo.getName());
+                }
+                oldStocks.setQuantity(quantity);
+            } else if (type == 3) {
+                //维多利亚待入库增加冻结库存
+                String victoriatouristJson = oldStocks.getVictoriatouristJson();
+                JSONObject json = ObjectUtil.isEmpty(victoriatouristJson) ? new JSONObject() : JSONObject.parseObject(victoriatouristJson);
+                BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
+                frozenQuantity = frozenQuantity == null ? BigDecimal.ZERO : frozenQuantity;
+                frozenQuantity = frozenQuantity.add(stock.getQuantity());
+                json.put("frozenQuantity", frozenQuantity);
+                oldStocks.setVictoriatouristJson(json.toJSONString());
+            } else {
+                throw new ServiceException("未知库存操作类型");
             }
-
-            data.add(newStocks);
+            data.add(oldStocks);
             //创建出入库明细
             StockJournalDetails stockJournalDetails = new StockJournalDetailsDto();
             stockJournalDetails.setStockJournalId(stockJournalId);