Procházet zdrojové kódy

Merge remote-tracking branch 'origin/master'

caozj před 2 roky
rodič
revize
f5bb60fee8

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

@@ -35,4 +35,9 @@ public class PurchaseDetailVo extends PurchaseDetail {
      */
     private BigDecimal sumCount;
 
+    /**
+     * 产品定义
+     */
+    private Integer productDefinition;
+
 }

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

@@ -115,11 +115,13 @@ public class ArrivalServiceImpl extends ServiceImpl<ArrivalMapper, Arrival> impl
         purchase.setArrivalStatus(arrival.getArrivalStatus());
         purchase.setId(arrival.getPurchaseId());
         purchaseService.updateById(purchase);
+        Purchase purchase1 = purchaseService.getById(arrival.getPurchaseId());
         //取出到货明细
         List<ArrivalDetail> arrivalDetailList = arrival.getArrivalDetailList();
         if (CollectionUtils.isNotEmpty(arrivalDetailList)) {
             StockWait stockWait = new StockWait();
-            stockWait.setBusinessId(arrival.getId());//到货明细ID
+            stockWait.setBusinessId(purchase1.getId());//采购id
+            stockWait.setBusinessCode(purchase1.getCode());//采购id
             stockWait.setType(1);//入库
             stockWait.setStatus(0);//待入库
             stockWait.setBusinessType(StockWaitType.PURCHASE_ARRIVAL_IN.getDetailType());//采购到货
@@ -193,13 +195,17 @@ public class ArrivalServiceImpl extends ServiceImpl<ArrivalMapper, Arrival> impl
         //修改发货记录的状态为到货
         wdlyService.updateDeliverGoodsStatus(deliverGoodsId);
 
+        //获取采购信息
+        Purchase purchase = purchaseService.getById(deliverGoodsInfo.getPurchaseId());
+
         //----------
         StockWait stockWait = new StockWait();
         stockWait.setType(1);//入库
         stockWait.setStatus(0);//待入库
         stockWait.setBusinessType(StockWaitType.PURCHASE_ARRIVAL_IN.getDetailType());//采购到货
-        //将业务id设置成到货id
-        stockWait.setBusinessId(arrival.getId());
+        //将业务信息设置成采购id和采购编码
+        stockWait.setBusinessId(purchase.getId());
+        stockWait.setBusinessCode(purchase.getCode());
         stockWait.setVictoriatouristJson(json.toJSONString());
         stockWaitService.save(stockWait);
 

+ 14 - 0
hx-supply/src/main/java/com/fjhx/supply/controller/supplier/SupplierPriceController.java

@@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+import java.util.Map;
+
 
 /**
  * <p>
@@ -67,4 +70,15 @@ public class SupplierPriceController {
         supplierPriceService.delete(dto.getId());
     }
 
+    /**
+     * 根据供应商id和产品列表获取价格
+     *
+     * @return
+     */
+    @PostMapping("/getSupplierPriceByProductIds")
+    public Map<Long, BigDecimal> getSupplierPriceByProductIds(@RequestBody SupplierPriceDto dto) {
+        return supplierPriceService.getSupplierPriceByProductIds(dto);
+    }
+
+
 }

+ 10 - 0
hx-supply/src/main/java/com/fjhx/supply/entity/supplier/dto/SupplierPriceDto.java

@@ -26,4 +26,14 @@ public class SupplierPriceDto extends SupplierPrice {
      */
     private boolean renewWhileItExists;
 
+    /**
+     * 供应商id
+     */
+    private Long supplierInfoId;
+
+    /**
+     * 产品id列表
+     */
+    private List<Long> productIdList;
+
 }

+ 1 - 1
hx-supply/src/main/java/com/fjhx/supply/entity/supplier/vo/SupplierPriceVo.java

@@ -58,7 +58,7 @@ public class SupplierPriceVo extends SupplierPrice {
     /**
      * 供应商类型 1贸易商 2工厂
      */
-    private Integer supplierType;
+    private String supplierType;
 
     /**
      * 供应商名称

+ 7 - 0
hx-supply/src/main/java/com/fjhx/supply/service/supplier/SupplierPriceService.java

@@ -8,6 +8,9 @@ import com.fjhx.supply.entity.supplier.vo.SupplierPriceAddVo;
 import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
 import com.ruoyi.common.core.service.BaseService;
 
+import java.math.BigDecimal;
+import java.util.Map;
+
 
 /**
  * <p>
@@ -41,4 +44,8 @@ public interface SupplierPriceService extends BaseService<SupplierPrice> {
      */
     void delete(Long id);
 
+    /**
+     * 根据供应商id和产品列表获取价格
+     */
+    Map<Long, BigDecimal> getSupplierPriceByProductIds(SupplierPriceDto dto);
 }

+ 19 - 1
hx-supply/src/main/java/com/fjhx/supply/service/supplier/impl/SupplierPriceServiceImpl.java

@@ -2,6 +2,7 @@ package com.fjhx.supply.service.supplier.impl;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.common.constant.SourceConstant;
@@ -16,12 +17,14 @@ import com.fjhx.supply.entity.supplier.vo.SupplierPriceAddVo;
 import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
 import com.fjhx.supply.mapper.supplier.SupplierPriceMapper;
 import com.fjhx.supply.service.supplier.SupplierPriceService;
+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;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
@@ -156,4 +159,19 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
         this.removeById(id);
     }
 
-}
+    @Override
+    public Map<Long, BigDecimal> getSupplierPriceByProductIds(SupplierPriceDto dto) {
+        Long supplierId = dto.getSupplierInfoId();
+        if (ObjectUtils.isEmpty(supplierId)) {
+            throw new ServiceException("供应商id不能为空");
+        }
+        List<Long> productIdList = dto.getProductIdList();
+        if (ObjectUtils.isEmpty(supplierId)) {
+            throw new ServiceException("产品id数组不能为空");
+        }
+        List<SupplierPrice> list = list(q -> q.eq(SupplierPrice::getSupplierInfoId, supplierId).in(SupplierPrice::getProductInfoId, productIdList));
+        return list.stream().collect(Collectors.toMap(SupplierPrice::getProductInfoId, SupplierPrice::getPrice));
+    }
+
+
+}

+ 5 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/entity/deliver/vo/DeliverGoodsDetailsVo.java

@@ -42,6 +42,11 @@ public class DeliverGoodsDetailsVo extends DeliverGoodsDetails {
     private BigDecimal count;
 
     /**
+     * 产品类型定义
+     */
+    private Integer definition;
+
+    /**
      * 在途数量
      */
     private BigDecimal transitQuantity;

+ 14 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/deliver/impl/DeliverGoodsDetailsServiceImpl.java

@@ -4,11 +4,13 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.item.service.product.ProductInfoService;
 import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
 import com.fjhx.purchase.entity.purchase.vo.PurchaseDetailVo;
 import com.fjhx.purchase.entity.purchase.vo.PurchaseVo;
 import com.fjhx.purchase.service.purchase.PurchaseDetailService;
 import com.fjhx.purchase.service.purchase.PurchaseService;
+import com.fjhx.supply.entity.supplier.po.SupplierPrice;
 import com.fjhx.victoriatourist.entity.deliver.dto.DeliverGoodsDetailsDto;
 import com.fjhx.victoriatourist.entity.deliver.dto.DeliverGoodsDetailsSelectDto;
 import com.fjhx.victoriatourist.entity.deliver.po.DeliverGoodsDetails;
@@ -40,6 +42,8 @@ public class DeliverGoodsDetailsServiceImpl extends ServiceImpl<DeliverGoodsDeta
     PurchaseDetailService purchaseDetailService;
     @Autowired
     PurchaseService purchaseService;
+    @Autowired
+    ProductInfoService productInfoService;
 
     @Override
     public Page<DeliverGoodsDetailsVo> getPage(DeliverGoodsDetailsSelectDto dto) {
@@ -70,6 +74,16 @@ public class DeliverGoodsDetailsServiceImpl extends ServiceImpl<DeliverGoodsDeta
                     .reduce(BigDecimal.ZERO, BigDecimal::add);
             purchaseDetail.setDeliverGoodsQuantity(count);
         }
+        //赋值产品信息
+        productInfoService.attributeAssign(purchaseDetailVoList, PurchaseDetailVo::getBussinessId, (item, product) -> {
+            item.setProductDefinition(product.getDefinition());
+            item.setProductType(product.getType());
+            item.setProductCode(product.getCode());
+            item.setProductName(product.getName());
+            item.setProductSpec(product.getSpec());
+            item.setProductUnit(product.getUnit());
+        });
+
         return purchaseDetailVoList;
     }
 

+ 1 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/deliver/impl/DeliverGoodsServiceImpl.java

@@ -101,6 +101,7 @@ public class DeliverGoodsServiceImpl extends ServiceImpl<DeliverGoodsMapper, Del
                 deliverGoodsDetailsVo.setName(productInfo.getName());
                 deliverGoodsDetailsVo.setSpec(productInfo.getSpec());
                 deliverGoodsDetailsVo.setUnit(productInfo.getUnit());
+                deliverGoodsDetailsVo.setDefinition(productInfo.getDefinition());
             }
             //赋值采购数量
             PurchaseDetail purchaseDetail = purchaseDetailMap.get(deliverGoodsDetailsVo.getPurchaseDetailId());

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

@@ -113,11 +113,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
                 json.put("unit", productInfo.getUnit());
 
                 BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
-                frozenQuantity = ObjectUtil.isEmpty(frozenQuantity)?BigDecimal.ZERO:frozenQuantity;
-                json.put("frozenQuantity",frozenQuantity);
+                frozenQuantity = ObjectUtil.isEmpty(frozenQuantity) ? BigDecimal.ZERO : frozenQuantity;
+                json.put("frozenQuantity", frozenQuantity);
                 BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
-                defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity)?BigDecimal.ZERO:defectiveQuantity;
-                json.put("defectiveQuantity",defectiveQuantity);
+                defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
+                json.put("defectiveQuantity", defectiveQuantity);
                 item.setVictoriatouristJson(json.toJSONString());
             });
         }
@@ -178,11 +178,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
             json.put("unit", productInfo.getUnit());
 
             BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
-            frozenQuantity = ObjectUtil.isEmpty(frozenQuantity)?BigDecimal.ZERO:frozenQuantity;
-            json.put("frozenQuantity",frozenQuantity);
+            frozenQuantity = ObjectUtil.isEmpty(frozenQuantity) ? BigDecimal.ZERO : frozenQuantity;
+            json.put("frozenQuantity", frozenQuantity);
             BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
-            defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity)?BigDecimal.ZERO:defectiveQuantity;
-            json.put("defectiveQuantity",defectiveQuantity);
+            defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
+            json.put("defectiveQuantity", defectiveQuantity);
             item.setVictoriatouristJson(json.toJSONString());
         });
 
@@ -229,11 +229,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
 
 
             BigDecimal frozenQuantity = json.getBigDecimal("frozenQuantity");
-            frozenQuantity = ObjectUtil.isEmpty(frozenQuantity)?BigDecimal.ZERO:frozenQuantity;
-            json.put("frozenQuantity",frozenQuantity);
+            frozenQuantity = ObjectUtil.isEmpty(frozenQuantity) ? BigDecimal.ZERO : frozenQuantity;
+            json.put("frozenQuantity", frozenQuantity);
             BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
-            defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity)?BigDecimal.ZERO:defectiveQuantity;
-            json.put("defectiveQuantity",defectiveQuantity);
+            defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
+            json.put("defectiveQuantity", defectiveQuantity);
             item.setVictoriatouristJson(json.toJSONString());
         });
 
@@ -312,7 +312,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
             Stock newStocks = new Stock();
             newStocks.setWarehouseId(warehouseId);
             newStocks.setProductId(stock.getProductId());
-            if(ObjectUtil.isEmpty(stock.getQuantity())){
+            if (ObjectUtil.isEmpty(stock.getQuantity())) {
                 //判断传操作的库存是否为空 空赋值0
                 stock.setQuantity(BigDecimal.ZERO);
             }
@@ -379,9 +379,14 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         }
         Stock stock1 = getById(stock.getId());
         String victoriatouristJson = stock1.getVictoriatouristJson();
-        JSONObject json = JSONObject.parseObject(victoriatouristJson);
-        json.put("quantity", json.getBigDecimal("quantity").add(stock.getQuantity()));
-        json.put("defectiveQuantity", json.getBigDecimal("defectiveQuantity").subtract(stock.getQuantity()));
+        JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
+        BigDecimal quantity = stock1.getQuantity();
+        BigDecimal defectiveQuantity = ObjectUtil.isNotEmpty(json.getBigDecimal("defectiveQuantity")) ? json.getBigDecimal("defectiveQuantity") : BigDecimal.ZERO;
+        if (defectiveQuantity.compareTo(BigDecimal.ZERO) == 0) {
+            throw new ServiceException("库存不足,无法转换");
+        }
+        json.put("quantity", quantity.add(stock.getQuantity()));
+        json.put("defectiveQuantity", defectiveQuantity.subtract(stock.getQuantity()));
         stock1.setVictoriatouristJson(json.toJSONString());
         updateById(stock1);
     }
@@ -413,9 +418,15 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
         }
         Stock stock1 = getById(stock.getId());
         String victoriatouristJson = stock1.getVictoriatouristJson();
-        JSONObject json = JSONObject.parseObject(victoriatouristJson);
-        json.put("quantity", json.getBigDecimal("quantity").subtract(stock.getQuantity()));
-        json.put("defectiveQuantity", json.getBigDecimal("defectiveQuantity").add(stock.getQuantity()));
+        JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
+        BigDecimal quantity = stock1.getQuantity();
+        BigDecimal defectiveQuantity = ObjectUtil.isNotEmpty(json.getBigDecimal("defectiveQuantity")) ? json.getBigDecimal("defectiveQuantity") : BigDecimal.ZERO;
+        if (quantity.compareTo(BigDecimal.ZERO) == 0) {
+            throw new ServiceException("库存不足,无法转换");
+        }
+
+        json.put("quantity", quantity.subtract(stock.getQuantity()));
+        json.put("defectiveQuantity", defectiveQuantity.add(stock.getQuantity()));
         stock1.setVictoriatouristJson(json.toJSONString());
         updateById(stock1);
     }

+ 4 - 0
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockWaitServiceImpl.java

@@ -250,6 +250,10 @@ public class StockWaitServiceImpl extends ServiceImpl<StockWaitMapper, StockWait
         } 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());
         updateById(stockWait);
 
         //创建出入库记录