Selaa lähdekoodia

json长数值问题处理,待出库修改

ControlDream 1 vuosi sitten
vanhempi
commit
c98648eb01
19 muutettua tiedostoa jossa 285 lisäystä ja 158 poistoa
  1. 3 0
      hx-account/src/main/java/com/fjhx/account/service/account/impl/AccountRequestFundsServiceImpl.java
  2. 3 3
      hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java
  3. 1 1
      hx-purchase/src/main/java/com/fjhx/purchase/service/arrival/impl/ArrivalServiceImpl.java
  4. 1 1
      hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchasePayRecordDetailServiceImpl.java
  5. 1 1
      hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchasePayRecordServiceImpl.java
  6. 1 1
      hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchaseServiceImpl.java
  7. 2 2
      hx-purchase/src/main/java/com/fjhx/purchase/service/subscribe/impl/SubscribeDetailServiceImpl.java
  8. 2 2
      hx-purchase/src/main/java/com/fjhx/purchase/service/subscribe/impl/SubscribeServiceImpl.java
  9. 1 1
      hx-sale/src/main/java/com/fjhx/sale/flow/PurchaseFlowByWdly.java
  10. 2 2
      hx-sale/src/main/java/com/fjhx/sale/service/documents/impl/DocumentsServiceImpl.java
  11. 2 2
      hx-supply/src/main/java/com/fjhx/supply/service/supplier/impl/SupplierInfoServiceImpl.java
  12. 9 0
      hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/controller/purchase/PurchaseBackController.java
  13. 7 0
      hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/purchase/PurchaseBackService.java
  14. 103 29
      hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/purchase/impl/PurchaseBackServiceImpl.java
  15. 4 2
      hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/quality/impl/QualityInfoServiceImpl.java
  16. 3 2
      hx-wms/src/main/java/com/fjhx/wms/service/stock/StockWaitDetailsService.java
  17. 19 16
      hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockServiceImpl.java
  18. 87 67
      hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitDetailsServiceImpl.java
  19. 34 26
      hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitServiceImpl.java

+ 3 - 0
hx-account/src/main/java/com/fjhx/account/service/account/impl/AccountRequestFundsServiceImpl.java

@@ -77,6 +77,9 @@ public class AccountRequestFundsServiceImpl extends ServiceImpl<AccountRequestFu
         Page<AccountRequestFundsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         //赋值部门名称、归属公司名称
         List<AccountRequestFundsVo> records = page.getRecords();
+        if(ObjectUtil.isEmpty(records)){
+            return page;
+        }
 
         //切换数据源
         DynamicDataSourceContextHolder.push(SourceConstant.COMMON);

+ 3 - 3
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -181,7 +181,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
             //将部门id转为字符串(帮助解决前端问题)
             json.put("deptId", json.getString("deptId"));
 
-            record.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            record.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
         }
 
         return page;
@@ -447,7 +447,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         if (ObjectUtil.isNotEmpty(victoriatouristJson)) {
             JSONObject json = JSONObject.parseObject(victoriatouristJson);
             json.put("deptId", SecurityUtils.getDeptId());
-            productInfoDto.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            productInfoDto.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
         }
         add(productInfoDto);
     }
@@ -511,7 +511,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         String victoriatouristJson = productInfo.getVictoriatouristJson();
         JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
         json.put("deptId", productInfoDto.getDeptId());
-        productInfo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+        productInfo.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
         updateById(productInfo);
     }
 

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

@@ -250,7 +250,7 @@ public class ArrivalServiceImpl extends ServiceImpl<ArrivalMapper, Arrival> impl
 
         json.put("arrivalId", arrival.getId());
         json.put("arrivalCode", arrival.getCode());
-        stockWait.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+        stockWait.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
         stockWaitService.save(stockWait);
 
         //取出到货明细

+ 1 - 1
hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchasePayRecordDetailServiceImpl.java

@@ -62,7 +62,7 @@ public class PurchasePayRecordDetailServiceImpl extends ServiceImpl<PurchasePayR
         String victoriatouristJson = purchase.getVictoriatouristJson();
         JSONObject json = ObjectUtil.isEmpty(victoriatouristJson) ? new JSONObject() : JSONObject.parseObject(victoriatouristJson);
         json.put("paidAmount", BigDecimal.ZERO);
-        purchase.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+        purchase.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
         purchaseService.updateById(purchase);
 
         //清空付款记录记录信息

+ 1 - 1
hx-purchase/src/main/java/com/fjhx/purchase/service/purchase/impl/PurchasePayRecordServiceImpl.java

@@ -84,7 +84,7 @@ public class PurchasePayRecordServiceImpl extends ServiceImpl<PurchasePayRecordM
             String victoriatouristJson = purchase.getVictoriatouristJson();
             JSONObject json = ObjectUtil.isEmpty(victoriatouristJson) ? new JSONObject() : JSONObject.parseObject(victoriatouristJson);
             json.put("paidAmount", add);
-            purchase.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            purchase.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
 
             purchaseService.updateById(purchase);
 

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

@@ -239,7 +239,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase>
                     JSONObject json = JSONObject.parseObject(victoriatouristJson);
                     String warehouseName = warehousesMap.get(json.getLong("receiptWarehouseId"));
                     json.put("receiptWarehouseName", warehouseName);
-                    purchaseVo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+                    purchaseVo.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
                 }
             }
             //赋值到货状态

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

@@ -1,7 +1,7 @@
 package com.fjhx.purchase.service.subscribe.impl;
 
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
@@ -180,7 +180,7 @@ public class SubscribeDetailServiceImpl extends ServiceImpl<SubscribeDetailMappe
                 if (ObjectUtil.isNotEmpty(victoriatouristJson)) {
                     JSONObject json = JSONObject.parseObject(victoriatouristJson);
                     json.put("receiptWarehouseName", warehousesMap.get(json.getLong("receiptWarehouseId")));
-                    subscribeDetailVo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+                    subscribeDetailVo.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
                 }
             }
         }

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

@@ -1,7 +1,7 @@
 package com.fjhx.purchase.service.subscribe.impl;
 
 import cn.hutool.extra.spring.SpringUtil;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
@@ -128,7 +128,7 @@ public class SubscribeServiceImpl extends ServiceImpl<SubscribeMapper, Subscribe
             Warehouse warehouse = warehouseService.getById(receiptWarehouseId);
             if (ObjectUtils.isNotEmpty(victoriatouristJson)) {
                 json.put("receiptWarehouseName", warehouse.getName());
-                subscribe.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+                subscribe.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
             }
         }
         return subscribe;

+ 1 - 1
hx-sale/src/main/java/com/fjhx/sale/flow/PurchaseFlowByWdly.java

@@ -124,7 +124,7 @@ public class PurchaseFlowByWdly extends FlowDelegate {
                 String victoriatouristJson1 = purchase.getVictoriatouristJson();
                 JSONObject json1 = JSONObject.parseObject(victoriatouristJson1);
                 json1.put("receiptWarehouseId", receiptWarehouseId);
-                purchase.setVictoriatouristJson(json1.toJSONString(JSONWriter.Feature.WriteLongAsString));
+                purchase.setVictoriatouristJson(com.alibaba.fastjson2.JSONObject.toJSONString(json1,JSONWriter.Feature.WriteLongAsString));
                 purchaseService.updateById(purchase);
             }
             return purchase.getId();

+ 2 - 2
hx-sale/src/main/java/com/fjhx/sale/service/documents/impl/DocumentsServiceImpl.java

@@ -2,7 +2,7 @@ package com.fjhx.sale.service.documents.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -393,7 +393,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
             pdfData.setDocumentId(documents.getId());
             pdfData.setContractCode(contract.getCode());
             pdfData.setDataType(0);//报关单
-            pdfData.setContent(data.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            pdfData.setContent(JSONObject.toJSONString(data,JSONWriter.Feature.WriteLongAsString));
         }
         return pdfData;
     }

+ 2 - 2
hx-supply/src/main/java/com/fjhx/supply/service/supplier/impl/SupplierInfoServiceImpl.java

@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.stream.CollectorUtil;
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
@@ -133,7 +133,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
         JSONObject json = ObjectUtil.isNotEmpty(result.getVictoriatouristJson()) ? JSONObject.parseObject(result.getVictoriatouristJson()) : new JSONObject();
         json.put("accountPeriod",json.getString("accountPeriod"));
         json.put("returnPeriod",json.getString("returnPeriod"));
-        result.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+        result.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
         return result;
     }
 

+ 9 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/controller/purchase/PurchaseBackController.java

@@ -1,6 +1,7 @@
 package com.fjhx.victoriatourist.controller.purchase;
 
 import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
+import com.fjhx.wms.entity.stock.dto.StockWaitDto;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.victoriatourist.entity.purchase.vo.PurchaseBackVo;
@@ -58,4 +59,12 @@ public class PurchaseBackController {
         purchaseBackService.backOut(stockWaitDetailsDto);
     }
 
+    /**
+     * 采购退货待出库 批量
+     */
+    @PostMapping("/backOuts")
+    public void backOuts(@RequestBody StockWaitDto stockWaitDto) {
+        purchaseBackService.backOuts(stockWaitDto);
+    }
+
 }

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

@@ -1,7 +1,9 @@
 package com.fjhx.victoriatourist.service.purchase;
 
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.fjhx.victoriatourist.entity.purchase.po.PurchaseBack;
 import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
+import com.fjhx.wms.entity.stock.dto.StockWaitDto;
 import com.ruoyi.common.core.service.BaseService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.victoriatourist.entity.purchase.vo.PurchaseBackVo;
@@ -38,4 +40,9 @@ public interface PurchaseBackService extends BaseService<PurchaseBack> {
      * 采购退货待出库出库
      */
     void backOut(StockWaitDetailsDto stockWaitDetailsDto);
+
+    /**
+     * 采购退货待出库 多个
+     */
+    void backOuts (StockWaitDto stockWaitDto);
 }

+ 103 - 29
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/purchase/impl/PurchaseBackServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.common.utils.Assert;
 import com.fjhx.purchase.entity.purchase.po.Purchase;
 import com.fjhx.purchase.service.purchase.PurchaseService;
 import com.fjhx.victoriatourist.entity.logistics.po.LogisticsDetails;
@@ -24,6 +25,7 @@ import com.fjhx.victoriatourist.service.logistics.LogisticsInfosService;
 import com.fjhx.victoriatourist.service.purchase.PurchaseBackDetailsService;
 import com.fjhx.victoriatourist.service.purchase.PurchaseBackService;
 import com.fjhx.wms.entity.stock.dto.StockWaitDetailsDto;
+import com.fjhx.wms.entity.stock.dto.StockWaitDto;
 import com.fjhx.wms.entity.stock.emums.JournalType;
 import com.fjhx.wms.entity.stock.emums.StockWaitType;
 import com.fjhx.wms.entity.stock.po.*;
@@ -36,7 +38,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 
@@ -129,10 +131,103 @@ public class PurchaseBackServiceImpl extends ServiceImpl<PurchaseBackMapper, Pur
     @Override
     @DSTransactional
     public void backOut(StockWaitDetailsDto stockWaitDetailsDto) {
-        //修改待出入库状态
-        stockWaitDetailsService.changeStockWaitStatus(stockWaitDetailsDto);
+//        //修改待出入库状态
+//        stockWaitDetailsService.changeStockWaitStatus(stockWaitDetailsDto);
+//        StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
+//        StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
+//        //创建出入库记录
+//        StockJournal stockJournal = new StockJournal();
+//        stockJournal.setOpType(byId.getType());
+//        //退货出库
+//        stockJournal.setType(JournalType.BACK_OUT.getDetailType());
+//
+//        DynamicDataSourceContextHolder.push(SourceConstant.WMS);
+//        stockJournal.setCode(CodeEnum.SOUT_CODE.getCode());
+//        DynamicDataSourceContextHolder.poll();
+//
+//        stockJournal.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
+//        stockJournal.setBusinessId(byId.getId());
+//        //保存出入库记录
+//        stockJournalService.save(stockJournal);
+//        //操作库存
+//        Stock stock = new Stock();
+//        stock.setQuantity(stockWaitDetailsDto.getQuantity());
+//        stock.setProductId(stockWaitDetails.getProductId());
+//        //退货出库出次品库存
+//        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), 4, Arrays.asList(stock), stockWaitDetailsDto.getWarehouseId());
+//        //保存出入库明细
+//        stockJournalDetailsService.saveBatch(stockJournalDetailsList);
+//
+//        //创建物流数据
+//        LogisticsInfos logisticsInfos = new LogisticsInfos();
+//        logisticsInfos.setBusinessId(byId.getId());
+//        logisticsInfos.setBusinessCode(byId.getBusinessCode());
+//        logisticsInfos.setBusinessType(5);//采购退货
+//        logisticsInfos.setLogisticsCompanyCode(stockWaitDetailsDto.getLogisticsCompanyCode());
+//        logisticsInfos.setCode(stockWaitDetailsDto.getLogisticsCode());
+//        logisticsInfos.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
+//        logisticsInfos.setIsKd100(0);
+//        logisticsInfosService.save(logisticsInfos);
+//
+//        LogisticsDetails logisticsDetails = new LogisticsDetails();
+//        logisticsDetails.setLogisticsInfoId(logisticsInfos.getId());
+//        logisticsDetails.setLogisticsInfoCode(logisticsInfos.getCode());
+//        logisticsDetails.setBusinessDetailsId(stockWaitDetailsDto.getId());
+//        logisticsDetails.setReceiptQuantity(stockWaitDetailsDto.getQuantity());
+//        logisticsDetailsService.save(logisticsDetails);
+
+        //优化
         StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
-        StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
+        Assert.notEmpty(stockWaitDetails, "查询不到待出库明细信息");
+        StockWaitDto stockWaitDto = BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDto.class);
+        stockWaitDto.setId(stockWaitDetails.getStockWaitId());
+        stockWaitDto.setStockWaitDetailsList(Collections.singletonList(BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDetails.class)));
+        backOuts(stockWaitDto);
+    }
+
+    @DSTransactional
+    @Override
+    public void backOuts(StockWaitDto stockWaitDto) {
+        //创建物流数据
+        LogisticsInfos logisticsInfos = new LogisticsInfos();
+        logisticsInfos.setBusinessId(stockWaitDto.getId());
+        logisticsInfos.setBusinessCode(stockWaitDto.getBusinessCode());
+        logisticsInfos.setBusinessType(5);//采购退货
+        logisticsInfos.setLogisticsCompanyCode(stockWaitDto.getLogisticsCompanyCode());
+        logisticsInfos.setCode(stockWaitDto.getLogisticsCode());
+        logisticsInfos.setWarehouseId(stockWaitDto.getWarehouseId());
+        logisticsInfos.setIsKd100(0);
+        logisticsInfosService.save(logisticsInfos);
+
+        List<StockWaitDetails> stockWaitDetailsList = stockWaitDto.getStockWaitDetailsList();
+
+        List<Stock> stockList = new ArrayList<>();
+
+        stockWaitDetailsService.changeStockWaitStatus(stockWaitDto);
+
+
+        for (StockWaitDetails stockWaitDetails0 : stockWaitDetailsList) {
+            //修改待出入库状态
+            StockWaitDetailsDto stockWaitDetailsDto = BeanUtil.copyProperties(stockWaitDetails0, StockWaitDetailsDto.class);
+//            stockWaitDetailsService.changeStockWaitStatus(stockWaitDetailsDto);
+            StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(stockWaitDetailsDto.getId());
+
+            //操作库存
+            Stock stock = new Stock();
+            stock.setQuantity(stockWaitDetailsDto.getQuantity());
+            stock.setProductId(stockWaitDetails.getProductId());
+            stockList.add(stock);
+
+
+            LogisticsDetails logisticsDetails = new LogisticsDetails();
+            logisticsDetails.setLogisticsInfoId(logisticsInfos.getId());
+            logisticsDetails.setLogisticsInfoCode(logisticsInfos.getCode());
+            logisticsDetails.setBusinessDetailsId(stockWaitDetailsDto.getId());
+            logisticsDetails.setReceiptQuantity(stockWaitDetailsDto.getQuantity());
+            logisticsDetailsService.save(logisticsDetails);
+        }
+
+        StockWait byId = stockWaitService.getById(stockWaitDto.getId());
         //创建出入库记录
         StockJournal stockJournal = new StockJournal();
         stockJournal.setOpType(byId.getType());
@@ -143,37 +238,16 @@ public class PurchaseBackServiceImpl extends ServiceImpl<PurchaseBackMapper, Pur
         stockJournal.setCode(CodeEnum.SOUT_CODE.getCode());
         DynamicDataSourceContextHolder.poll();
 
-        stockJournal.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
+        stockJournal.setWarehouseId(stockWaitDto.getWarehouseId());
         stockJournal.setBusinessId(byId.getId());
         //保存出入库记录
         stockJournalService.save(stockJournal);
-        //操作库存
-        Stock stock = new Stock();
-        stock.setQuantity(stockWaitDetailsDto.getQuantity());
-        stock.setProductId(stockWaitDetails.getProductId());
+
         //退货出库出次品库存
-        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), 4, Arrays.asList(stock), stockWaitDetailsDto.getWarehouseId());
+        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), 4, stockList, stockWaitDto.getWarehouseId());
         //保存出入库明细
         stockJournalDetailsService.saveBatch(stockJournalDetailsList);
-
-
-        //创建物流数据
-        LogisticsInfos logisticsInfos = new LogisticsInfos();
-        logisticsInfos.setBusinessId(byId.getId());
-        logisticsInfos.setBusinessCode(byId.getBusinessCode());
-        logisticsInfos.setBusinessType(5);//采购退货
-        logisticsInfos.setLogisticsCompanyCode(stockWaitDetailsDto.getLogisticsCompanyCode());
-        logisticsInfos.setCode(stockWaitDetailsDto.getLogisticsCode());
-        logisticsInfos.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
-        logisticsInfos.setIsKd100(0);
-        logisticsInfosService.save(logisticsInfos);
-
-        LogisticsDetails logisticsDetails = new LogisticsDetails();
-        logisticsDetails.setLogisticsInfoId(logisticsInfos.getId());
-        logisticsDetails.setLogisticsInfoCode(logisticsInfos.getCode());
-        logisticsDetails.setBusinessDetailsId(stockWaitDetailsDto.getId());
-        logisticsDetails.setReceiptQuantity(stockWaitDetailsDto.getQuantity());
-        logisticsDetailsService.save(logisticsDetails);
     }
 
+
 }

+ 4 - 2
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/quality/impl/QualityInfoServiceImpl.java

@@ -3,7 +3,7 @@ package com.fjhx.victoriatourist.service.quality.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.ObjectUtil;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@@ -134,6 +134,8 @@ public class QualityInfoServiceImpl extends ServiceImpl<QualityInfoMapper, Quali
     @DSTransactional
     @Override
     public void add(QualityInfoDto qualityInfoDto) {
+        qualityInfoDto.setId(IdWorker.getId());
+
         qualityInfoDto.setType(1);//设置为到货质检
         qualityInfoDto.setStatus(2);//部分质检
         ArrivalStockRecords arrivalStockRecords = arrivalStockRecordsService.getById(qualityInfoDto.getArrivalStockRecordsId());
@@ -257,7 +259,7 @@ public class QualityInfoServiceImpl extends ServiceImpl<QualityInfoMapper, Quali
             }
             json.put("frozenQuantity", frozenQuantity);
 
-            stock.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            stock.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
             stockList.add(stock);
 
             StockJournalDetails stockJournalDetails = new StockJournalDetails();

+ 3 - 2
hx-wms/src/main/java/com/fjhx/wms/service/stock/StockWaitDetailsService.java

@@ -1,5 +1,6 @@
 package com.fjhx.wms.service.stock;
 
+import com.fjhx.wms.entity.stock.dto.StockWaitDto;
 import com.fjhx.wms.entity.stock.po.StockWaitDetails;
 import com.ruoyi.common.core.service.BaseService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -32,8 +33,8 @@ public interface StockWaitDetailsService extends BaseService<StockWaitDetails> {
      * 待出入库明细新增
      */
     void add(StockWaitDetailsDto stockWaitDetailsDto);
-
-    void changeStockWaitStatus(StockWaitDetailsDto stockWaitDetailsDto);
+    
+    void changeStockWaitStatus(StockWaitDto stockWaitDto);
 
     /**
      * 待出入库明细编辑

+ 19 - 16
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockServiceImpl.java

@@ -2,15 +2,14 @@ package com.fjhx.wms.service.stock.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.item.entity.product.po.ProductClassify;
 import com.fjhx.item.entity.product.po.ProductInfo;
-import com.fjhx.item.entity.product.vo.ProductInfoVo;
 import com.fjhx.item.service.product.ProductClassifyService;
 import com.fjhx.item.service.product.ProductInfoService;
 import com.fjhx.wms.entity.stock.bo.InOutBo;
@@ -33,7 +32,6 @@ import com.fjhx.wms.utils.CodeEnum;
 import com.obs.services.internal.ServiceException;
 import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
-import com.ruoyi.common.utils.wrapper.SqlField;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -73,11 +71,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         wrapper.eq(Stock::getWarehouseId, dto.getId());
 //        wrapper.like(Stock::getQuantity, dto.getKeyword());
         String keyword = dto.getKeyword();
-        if(ObjectUtil.isNotEmpty(keyword)) {
+        if (ObjectUtil.isNotEmpty(keyword)) {
             //根据 库存数量 产品自定义编码 产品名称 过滤
             List<Long> productIds = productInfoService.listObject(ProductInfo::getId,
                     q -> q.like(ProductInfo::getCustomCode, keyword).or().like(ProductInfo::getName, keyword));
-            wrapper.and(q->q.like(Stock::getQuantity,keyword).or().in(Stock::getProductId,productIds));
+            wrapper.and(q -> q.like(Stock::getQuantity, keyword).or().in(Stock::getProductId, productIds));
         }
         wrapper.in(Stock::getProductId, dto.getProductIds());
         wrapper.eq("pi.definition", dto.getDefinition());
@@ -154,7 +152,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
                 BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
                 defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
                 json.put("defectiveQuantity", defectiveQuantity);
-                item.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+                item.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
             });
         }
 
@@ -179,7 +177,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
             JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
             String warehouseName = warehouseMap.get(json.getLong("warehouseId"));
             json.put("warehouseName", warehouseName);
-            stockVo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            stockVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         }
         return page;
     }
@@ -191,11 +189,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         wrapper.eq(Stock::getWarehouseId, dto.getId());
 //        wrapper.like(Stock::getQuantity, dto.getKeyword());
         String keyword = dto.getKeyword();
-        if(ObjectUtil.isNotEmpty(keyword)) {
+        if (ObjectUtil.isNotEmpty(keyword)) {
             //根据 库存数量 产品自定义编码 产品名称 过滤
             List<Long> productIds = productInfoService.listObject(ProductInfo::getId,
                     q -> q.like(ProductInfo::getCustomCode, keyword).or().like(ProductInfo::getName, keyword));
-            wrapper.and(q->q.like(Stock::getQuantity,keyword).or().in(Stock::getProductId,productIds));
+            wrapper.and(q -> q.like(Stock::getQuantity, keyword).or().in(Stock::getProductId, productIds));
         }
         wrapper.eq("pi.definition", dto.getDefinition());
         wrapper.groupBy("s.product_id");
@@ -211,7 +209,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
             BigDecimal defectiveQuantity = stockVo.getDefectiveQuantity();
             defectiveQuantity = defectiveQuantity == null ? BigDecimal.ZERO : defectiveQuantity;
             json.put("defectiveQuantity", defectiveQuantity);
-            stockVo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            stockVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         }
 
         //赋值产品名称
@@ -239,7 +237,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
             BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
             defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
             json.put("defectiveQuantity", defectiveQuantity);
-            item.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            item.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         });
 
         //赋值产品分类
@@ -394,6 +392,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
 
         List<StockJournalDetails> stockJournalDetailsList = new ArrayList<>();
         for (Stock stock : list) {
+            //忽略操作数量为0的记录 避免出现出入库记录为0的条目
+            if (BigDecimal.ZERO.compareTo(stock.getQuantity()) == 0) {
+                continue;
+            }
+
             Stock oldStocks = stockMap.get(stock.getProductId());
             //如果库存不存在 就创建一条空库存
             if (ObjectUtil.isEmpty(oldStocks)) {
@@ -426,7 +429,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
                 frozenQuantity = frozenQuantity == null ? BigDecimal.ZERO : frozenQuantity;
                 frozenQuantity = frozenQuantity.add(stock.getQuantity());
                 json.put("frozenQuantity", frozenQuantity);
-                oldStocks.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+                oldStocks.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
             } else if (type == 4) {
                 //维多利亚待出库操作次品库存
                 String victoriatouristJson = oldStocks.getVictoriatouristJson();
@@ -442,7 +445,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
                     throw new ServiceException("以下商品次品库存不足,无法出库:" + productInfo.getName());
                 }
                 json.put("defectiveQuantity", defectiveQuantity);
-                oldStocks.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+                oldStocks.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
             } else {
                 throw new ServiceException("未知库存操作类型");
             }
@@ -482,7 +485,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         }
         stock1.setQuantity(quantity.add(stock.getQuantity()));
         json.put("defectiveQuantity", defectiveQuantity.subtract(stock.getQuantity()));
-        stock1.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+        stock1.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         updateById(stock1);
     }
 
@@ -521,7 +524,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         }
         stock1.setQuantity(quantity.subtract(stock.getQuantity()));
         json.put("defectiveQuantity", defectiveQuantity.add(stock.getQuantity()));
-        stock1.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+        stock1.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         updateById(stock1);
     }
 

+ 87 - 67
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitDetailsServiceImpl.java

@@ -5,25 +5,28 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.stock.dto.StockWaitDetailsDto;
 import com.fjhx.wms.entity.stock.dto.StockWaitDetailsSelectDto;
-import com.fjhx.wms.entity.stock.emums.StockWaitType;
-import com.fjhx.wms.entity.stock.po.*;
+import com.fjhx.wms.entity.stock.dto.StockWaitDto;
+import com.fjhx.wms.entity.stock.po.StockWait;
+import com.fjhx.wms.entity.stock.po.StockWaitDetails;
 import com.fjhx.wms.entity.stock.vo.StockWaitDetailsVo;
 import com.fjhx.wms.mapper.stock.StockWaitDetailsMapper;
-import com.fjhx.wms.service.WmsService;
-import com.fjhx.wms.service.stock.*;
-import com.fjhx.wms.utils.CodeEnum;
+import com.fjhx.wms.service.stock.StockWaitDetailsService;
+import com.fjhx.wms.service.stock.StockWaitService;
 import com.obs.services.internal.ServiceException;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
@@ -40,16 +43,16 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
     private ProductInfoService productInfoService;
     @Autowired
     private StockWaitService stockWaitService;
-    @Autowired
-    private StockJournalService stockJournalService;
-    @Autowired
-    private StockJournalDetailsService stockJournalDetailsService;
-    @Autowired
-    private StockService stockService;
-    @Autowired
-    private WmsService wmsService;
-    @Autowired
-    private StockFrozenService stockFrozenService;
+//    @Autowired
+//    private StockJournalService stockJournalService;
+//    @Autowired
+//    private StockJournalDetailsService stockJournalDetailsService;
+//    @Autowired
+//    private StockService stockService;
+//    @Autowired
+//    private WmsService wmsService;
+//    @Autowired
+//    private StockFrozenService stockFrozenService;
 
     @Override
     public Page<StockWaitDetailsVo> getPage(StockWaitDetailsSelectDto dto) {
@@ -92,7 +95,6 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
         }
         result.setBusinessType(stockWait.getBusinessType());
         result.setBusinessCode(stockWait.getBusinessCode());
-        ;
         ProductInfo byId = productInfoService.getById(StockWaitDetails.getProductId());
         if (ObjectUtil.isEmpty(byId)) {
             throw new ServiceException("无法查询到产品信息,产品id" + StockWaitDetails.getProductId());
@@ -104,42 +106,50 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
     @Override
     @DSTransactional
     public void add(StockWaitDetailsDto stockWaitDetailsDto) {
-        //修改待出库状态
-        changeStockWaitStatus(stockWaitDetailsDto);
-        StockWaitDetails stockWaitDetails = getById(stockWaitDetailsDto.getId());
-        StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
-        Integer businessType = byId.getBusinessType();
-
-        if (StockWaitType.SALE_ORDER_OUT.getDetailType().equals(businessType)) {
-            //销售订单出库
-            wmsService.outbound(stockWaitDetailsDto);
-        }
-        if (StockWaitType.PRODUCTION_TASK_OUT.getDetailType().equals(businessType)) {
-            //生产任务待出库
-            //减少冻结库存
-            StockFrozen stockFrozen = stockFrozenService.getOne(q -> q.eq(StockFrozen::getProductId, stockWaitDetails.getProductId()));
-            BigDecimal subtract = stockFrozen.getFrozenQuantity().subtract(stockWaitDetailsDto.getQuantity());
-            stockFrozen.setFrozenQuantity(subtract);
-            stockFrozenService.updateById(stockFrozen);
-        }
+//        //修改待出库状态
+//        changeStockWaitStatus(stockWaitDetailsDto);
+//        StockWaitDetails stockWaitDetails = getById(stockWaitDetailsDto.getId());
+//        StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
+//        Integer businessType = byId.getBusinessType();
+//
+//        if (StockWaitType.SALE_ORDER_OUT.getDetailType().equals(businessType)) {
+//            //销售订单出库
+//            wmsService.outbound(stockWaitDetailsDto);
+//        }
+//        if (StockWaitType.PRODUCTION_TASK_OUT.getDetailType().equals(businessType)) {
+//            //生产任务待出库
+//            //减少冻结库存
+//            StockFrozen stockFrozen = stockFrozenService.getOne(q -> q.eq(StockFrozen::getProductId, stockWaitDetails.getProductId()));
+//            BigDecimal subtract = stockFrozen.getFrozenQuantity().subtract(stockWaitDetailsDto.getQuantity());
+//            stockFrozen.setFrozenQuantity(subtract);
+//            stockFrozenService.updateById(stockFrozen);
+//        }
+//
+//        //创建出入库记录
+//        StockJournal stockJournal = new StockJournal();
+//        stockJournal.setOpType(byId.getType());
+//        //根据待入库业务类型创建待出入库记录
+//        stockJournal.setType(stockWaitService.getStockJournalType(businessType));
+//        stockJournal.setCode(byId.getType() == 1 ? CodeEnum.SIN_CODE.getCode() : CodeEnum.SOUT_CODE.getCode());
+//        stockJournal.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
+//        stockJournal.setBusinessId(byId.getId());
+//        //保存出入库记录
+//        stockJournalService.save(stockJournal);
+//        //操作库存
+//        Stock stock = new Stock();
+//        stock.setQuantity(stockWaitDetailsDto.getQuantity());
+//        stock.setProductId(stockWaitDetails.getProductId());
+//        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), byId.getType(), Arrays.asList(stock), stockWaitDetailsDto.getWarehouseId());
+//        //保存出入库明细
+//        stockJournalDetailsService.saveBatch(stockJournalDetailsList);
 
-        //创建出入库记录
-        StockJournal stockJournal = new StockJournal();
-        stockJournal.setOpType(byId.getType());
-        //根据待入库业务类型创建待出入库记录
-        stockJournal.setType(stockWaitService.getStockJournalType(businessType));
-        stockJournal.setCode(byId.getType() == 1 ? CodeEnum.SIN_CODE.getCode() : CodeEnum.SOUT_CODE.getCode());
-        stockJournal.setWarehouseId(stockWaitDetailsDto.getWarehouseId());
-        stockJournal.setBusinessId(byId.getId());
-        //保存出入库记录
-        stockJournalService.save(stockJournal);
-        //操作库存
-        Stock stock = new Stock();
-        stock.setQuantity(stockWaitDetailsDto.getQuantity());
-        stock.setProductId(stockWaitDetails.getProductId());
-        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), byId.getType(), Arrays.asList(stock), stockWaitDetailsDto.getWarehouseId());
-        //保存出入库明细
-        stockJournalDetailsService.saveBatch(stockJournalDetailsList);
+        //优化
+        StockWaitDetails stockWaitDetails = this.getById(stockWaitDetailsDto.getId());
+        Assert.notEmpty(stockWaitDetails, "查询不到待出库明细信息");
+        StockWaitDto stockWaitDto = BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDto.class);
+        stockWaitDto.setId(stockWaitDetails.getStockWaitId());
+        stockWaitDto.setStockWaitDetailsList(Collections.singletonList(BeanUtil.copyProperties(stockWaitDetailsDto, StockWaitDetails.class)));
+        stockWaitService.addByWdly(stockWaitDto);
     }
 
 
@@ -147,22 +157,32 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
      * 更新待出入库状态
      */
     @Override
-    public void changeStockWaitStatus(StockWaitDetailsDto stockWaitDetailsDto) {
-        //更新已入库数量 根据明细id
-        StockWaitDetails stockWaitDetails = getById(stockWaitDetailsDto.getId());
-        if (ObjectUtil.isEmpty(stockWaitDetails)) {
-            throw new ServiceException("无法查询到明细信息");
-        }
-        BigDecimal receiptQuantity = stockWaitDetails.getReceiptQuantity();
-        receiptQuantity = ObjectUtil.isEmpty(receiptQuantity) ? BigDecimal.ZERO : receiptQuantity;
-        stockWaitDetails.setReceiptQuantity(receiptQuantity.add(stockWaitDetailsDto.getQuantity()));
-        if (stockWaitDetails.getReceiptQuantity().compareTo(stockWaitDetails.getQuantity()) > 0) {
-            throw new ServiceException("出库数量+已出库数量不能大于待出库数量");
+    public void changeStockWaitStatus(StockWaitDto stockWaitDto) {
+        List<StockWaitDetails> stockWaitDetailsDtoList = stockWaitDto.getStockWaitDetailsList();
+        List<StockWaitDetailsDto> stockWaitDetailsDtoList1 = BeanUtil.copyToList(stockWaitDetailsDtoList, StockWaitDetailsDto.class);
+
+        //获取待入库明细信息
+        List<Long> swdIds = stockWaitDetailsDtoList.stream().map(StockWaitDetails::getId).collect(Collectors.toList());
+        Map<Long, StockWaitDetails> stockWaitDetailsMap = this.mapKEntity(StockWaitDetails::getId, q -> q.in(StockWaitDetails::getId, swdIds));
+
+        for (StockWaitDetailsDto stockWaitDetailsDto : stockWaitDetailsDtoList1) {
+            //更新已入库数量 根据明细id
+            StockWaitDetails stockWaitDetails = stockWaitDetailsMap.get(stockWaitDetailsDto.getId());
+            if (ObjectUtil.isEmpty(stockWaitDetails)) {
+                throw new ServiceException("无法查询到明细信息");
+            }
+            BigDecimal receiptQuantity = stockWaitDetails.getReceiptQuantity();
+            receiptQuantity = ObjectUtil.isEmpty(receiptQuantity) ? BigDecimal.ZERO : receiptQuantity;
+            stockWaitDetails.setReceiptQuantity(receiptQuantity.add(stockWaitDetailsDto.getQuantity()));
+            if (stockWaitDetails.getReceiptQuantity().compareTo(stockWaitDetails.getQuantity()) > 0) {
+                throw new ServiceException("出库数量+已出库数量不能大于待出库数量");
+            }
+            updateById(stockWaitDetails);
         }
-        updateById(stockWaitDetails);
+
         //更新待出库记录状态
-        Integer statusFlag = 0;
-        List<StockWaitDetails> stockWaitDetailsList = list(q -> q.eq(StockWaitDetails::getStockWaitId, stockWaitDetails.getStockWaitId()));
+        int statusFlag = 0;
+        List<StockWaitDetails> stockWaitDetailsList = list(q -> q.eq(StockWaitDetails::getStockWaitId, stockWaitDto.getId()));
         for (StockWaitDetails waitDetails : stockWaitDetailsList) {
             //计算已经完全出库的数量
             BigDecimal receiptQuantity1 = ObjectUtil.isEmpty(waitDetails.getReceiptQuantity()) ? BigDecimal.ZERO : waitDetails.getReceiptQuantity();
@@ -170,7 +190,7 @@ public class StockWaitDetailsServiceImpl extends ServiceImpl<StockWaitDetailsMap
                 statusFlag++;
             }
         }
-        StockWait byId = stockWaitService.getById(stockWaitDetails.getStockWaitId());
+        StockWait byId = stockWaitService.getById(stockWaitDto.getId());
         if (statusFlag == stockWaitDetailsList.size()) {
             byId.setStatus(2);//入库完成
         } else {

+ 34 - 26
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitServiceImpl.java

@@ -106,6 +106,7 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         wrapper.eq(StockWait::getType, dto.getType());
         wrapper.eq(StockWait::getBusinessCode, dto.getKeyword());
         wrapper.eq(StockWait::getStatus, dto.getStatus());
+        wrapper.eq("sw", StockWait::getBusinessType, dto.getBusinessType());
         Page<StockWaitVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
 
         List<StockWaitVo> records = page.getRecords();
@@ -136,7 +137,7 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
             }
             JSONObject json = JSONObject.parseObject(victoriatouristJson);
             json.put("receiptWarehouseName", warehousesMap.get(json.getLong("receiptWarehouseId")));
-            stockWaitVo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+            stockWaitVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         }
 
         return page;
@@ -205,42 +206,51 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         List<Stock> stockList = new ArrayList<>();
 
         List<StockWaitDetails> stockWaitDetailsDtoList = stockWaitDto.getStockWaitDetailsList();
-        List<Long> dids = stockWaitDetailsDtoList.stream().map(StockWaitDetails::getId).collect(Collectors.toList());
+//        List<Long> dids = stockWaitDetailsDtoList.stream().map(StockWaitDetails::getId).collect(Collectors.toList());
         Map<Long, StockWaitDetails> stockWaitDetailsMap = stockWaitDetailsDtoList.stream().collect(Collectors.toMap(StockWaitDetails::getId, Function.identity()));
-        List<StockWaitDetails> stockWaitDetailss = stockWaitDetailsService.listByIds(dids);
+//        List<StockWaitDetails> stockWaitDetailss = stockWaitDetailsService.listByIds(dids);
 
         //已经完全入库数量统计
-        Integer statusFlag = 0;
-        for (StockWaitDetails stockWaitDetail : stockWaitDetailss) {
-            StockWaitDetails temp = stockWaitDetailsMap.get(stockWaitDetail.getId());
-            //更新已入库数量
-            BigDecimal receiptQuantity = stockWaitDetail.getReceiptQuantity() == null ? BigDecimal.ZERO : stockWaitDetail.getReceiptQuantity();
-            stockWaitDetail.setReceiptQuantity(receiptQuantity.add(temp.getQuantity()));
-
-            //计算已经完全入库的数量
-            if (stockWaitDetail.getReceiptQuantity().compareTo(stockWaitDetail.getQuantity()) >= 0) {
-                statusFlag++;
-            }
-        }
-        stockWaitDetailsService.updateBatchById(stockWaitDetailss);
-        //修改待入库状态
+//        int statusFlag = 0;
+//        for (StockWaitDetails stockWaitDetail : stockWaitDetailss) {
+//            StockWaitDetails temp = stockWaitDetailsMap.get(stockWaitDetail.getId());
+//            //更新已入库数量
+//            BigDecimal receiptQuantity = stockWaitDetail.getReceiptQuantity() == null ? BigDecimal.ZERO : stockWaitDetail.getReceiptQuantity();
+//            stockWaitDetail.setReceiptQuantity(receiptQuantity.add(temp.getQuantity()));
+//
+//            //计算已经完全入库的数量
+//            if (stockWaitDetail.getReceiptQuantity().compareTo(stockWaitDetail.getQuantity()) >= 0) {
+//                statusFlag++;
+//            }
+//        }
+//        stockWaitDetailsService.updateBatchById(stockWaitDetailss);
+//        //修改待入库状态
+//        StockWait stockWait = getById(stockWaitDto.getId());
+//        if (statusFlag == stockWaitDetailss.size()) {
+//            stockWait.setStatus(2);//入库完成
+//        } else {
+//            stockWait.setStatus(1);//部分入库
+//        }
+
+        //更新已出入库数量以及待出入库状态
+        stockWaitDetailsService.changeStockWaitStatus(stockWaitDto);
         StockWait stockWait = getById(stockWaitDto.getId());
-        if (statusFlag == stockWaitDetailss.size()) {
-            stockWait.setStatus(2);//入库完成
-        } else {
-            stockWait.setStatus(1);//部分入库
-        }
+
+
         String victoriatouristJson = stockWait.getVictoriatouristJson();
         JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
         json.put("receiptWarehouseId", stockWaitDto.getWarehouseId());
-        stockWait.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
+        stockWait.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
         updateById(stockWait);
 
         //操作库存
+        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));
         for (StockWaitDetails waitDetails : stockWaitDetailsDtoList) {
+            StockWaitDetails temp = oldStockWaitDetailsMap.get(waitDetails.getId());
             Stock stock = new Stock();
             stock.setQuantity(waitDetails.getQuantity());
-            stock.setProductId(waitDetails.getProductId());
+            stock.setProductId(temp.getProductId());
             stockList.add(stock);
         }
         //创建出入库记录
@@ -310,8 +320,6 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
 
     /**
      * 根据待出入库业务类型获取对应的出入库记录类型
-     *
-     * @return
      */
     @Override
     public Integer getStockJournalType(int businessType) {