Ver código fonte

采购退货

yzc 2 anos atrás
pai
commit
a55b72e66b

+ 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);
 }

+ 63 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/purchase/impl/PurchaseBackServiceImpl.java

@@ -24,6 +24,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.*;
@@ -176,4 +177,66 @@ public class PurchaseBackServiceImpl extends ServiceImpl<PurchaseBackMapper, Pur
         logisticsDetailsService.save(logisticsDetails);
     }
 
+    @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<>();
+
+        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());
+        //退货出库
+        stockJournal.setType(JournalType.BACK_OUT.getDetailType());
+
+        DynamicDataSourceContextHolder.push(SourceConstant.WMS);
+        stockJournal.setCode(CodeEnum.SOUT_CODE.getCode());
+        DynamicDataSourceContextHolder.poll();
+
+        stockJournal.setWarehouseId(stockWaitDto.getWarehouseId());
+        stockJournal.setBusinessId(byId.getId());
+        //保存出入库记录
+        stockJournalService.save(stockJournal);
+
+        //退货出库出次品库存
+        List<StockJournalDetails> stockJournalDetailsList = stockService.ModifyInventory(stockJournal.getId(), 4, stockList, stockWaitDto.getWarehouseId());
+        //保存出入库明细
+        stockJournalDetailsService.saveBatch(stockJournalDetailsList);
+    }
+
+
 }

+ 0 - 3
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockServiceImpl.java

@@ -154,9 +154,6 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
                 BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
                 defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
                 json.put("defectiveQuantity", defectiveQuantity);
-
-                JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString);
-
                 item.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
             });
         }