|
@@ -2,28 +2,36 @@ package com.fjhx.victoriatourist.service.deliver.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+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.constant.SourceConstant;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
+import com.fjhx.purchase.entity.purchase.po.Purchase;
|
|
|
import com.fjhx.purchase.entity.purchase.po.PurchaseDetail;
|
|
|
import com.fjhx.purchase.service.purchase.PurchaseDetailService;
|
|
|
+import com.fjhx.purchase.service.purchase.PurchaseService;
|
|
|
import com.fjhx.victoriatourist.entity.deliver.dto.DeliverGoodsDto;
|
|
|
import com.fjhx.victoriatourist.entity.deliver.dto.DeliverGoodsSelectDto;
|
|
|
import com.fjhx.victoriatourist.entity.deliver.po.DeliverGoods;
|
|
|
import com.fjhx.victoriatourist.entity.deliver.po.DeliverGoodsDetails;
|
|
|
import com.fjhx.victoriatourist.entity.deliver.vo.DeliverGoodsDetailsVo;
|
|
|
import com.fjhx.victoriatourist.entity.deliver.vo.DeliverGoodsVo;
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.po.LogisticsDetails;
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.po.LogisticsInfos;
|
|
|
import com.fjhx.victoriatourist.mapper.deliver.DeliverGoodsMapper;
|
|
|
import com.fjhx.victoriatourist.service.deliver.DeliverGoodsDetailsService;
|
|
|
import com.fjhx.victoriatourist.service.deliver.DeliverGoodsService;
|
|
|
+import com.fjhx.victoriatourist.service.logistics.LogisticsDetailsService;
|
|
|
+import com.fjhx.victoriatourist.service.logistics.LogisticsInfosService;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.function.Function;
|
|
@@ -47,6 +55,12 @@ public class DeliverGoodsServiceImpl extends ServiceImpl<DeliverGoodsMapper, Del
|
|
|
ProductInfoService productInfoService;
|
|
|
@Autowired
|
|
|
PurchaseDetailService purchaseDetailService;
|
|
|
+ @Autowired
|
|
|
+ LogisticsInfosService logisticsInfosService;
|
|
|
+ @Autowired
|
|
|
+ LogisticsDetailsService logisticsDetailsService;
|
|
|
+ @Autowired
|
|
|
+ PurchaseService purchaseService;
|
|
|
|
|
|
@Override
|
|
|
public Page<DeliverGoodsVo> getPage(DeliverGoodsSelectDto dto) {
|
|
@@ -105,16 +119,42 @@ public class DeliverGoodsServiceImpl extends ServiceImpl<DeliverGoodsMapper, Del
|
|
|
return deliverGoodsDetailsVos;
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ @DSTransactional
|
|
|
@Override
|
|
|
public void add(DeliverGoodsDto deliverGoodsDto) {
|
|
|
deliverGoodsDto.setStatus(0);//设置未到货
|
|
|
this.save(deliverGoodsDto);
|
|
|
+
|
|
|
+ //获取采购信息
|
|
|
+ Purchase purchase = purchaseService.getById(deliverGoodsDto.getPurchaseId());
|
|
|
+ //创建物流信息
|
|
|
+ LogisticsInfos logisticsInfos = new LogisticsInfos();
|
|
|
+ logisticsInfos.setBusinessId(deliverGoodsDto.getId());//设置业务id为发货id
|
|
|
+ logisticsInfos.setBusinessCode(purchase.getCode());//设置采购单号为业务单号
|
|
|
+ logisticsInfos.setBusinessType(1);//采购到货
|
|
|
+ logisticsInfos.setStatus(0);
|
|
|
+ logisticsInfos.setInStockStatus(10);
|
|
|
+ logisticsInfos.setCode(deliverGoodsDto.getCode());
|
|
|
+ logisticsInfos.setLogisticsCompanyCode(deliverGoodsDto.getLogisticsCompanyCode());
|
|
|
+ logisticsInfos.setIsKd100(0);
|
|
|
+ logisticsInfosService.save(logisticsInfos);
|
|
|
+
|
|
|
List<DeliverGoodsDetails> deliverGoodsDetailsList = deliverGoodsDto.getDeliverGoodsDetailsList();
|
|
|
+ List<LogisticsDetails> logisticsDetailsList = new ArrayList<>();
|
|
|
+
|
|
|
for (DeliverGoodsDetails deliverGoodsDetails : deliverGoodsDetailsList) {
|
|
|
deliverGoodsDetails.setDeliverGoodsId(deliverGoodsDto.getId());
|
|
|
+
|
|
|
+ LogisticsDetails logisticsDetails = new LogisticsDetails();
|
|
|
+ logisticsDetails.setBusinessDetailsId(deliverGoodsDetails.getId());//设置发货明细id为业务id
|
|
|
+ logisticsDetails.setLogisticsInfoId(logisticsInfos.getId());
|
|
|
+ logisticsDetails.setPurchaseId(purchase.getId());
|
|
|
+ logisticsDetails.setPurchaseDetailsId(deliverGoodsDetails.getPurchaseDetailId());
|
|
|
+ logisticsDetails.setShipmentQuantity(deliverGoodsDetails.getDeliverGoodsQuantity());
|
|
|
+ logisticsDetailsList.add(logisticsDetails);
|
|
|
}
|
|
|
deliverGoodsDetailsService.saveBatch(deliverGoodsDetailsList);
|
|
|
+ logisticsDetailsService.saveBatch(logisticsDetailsList);
|
|
|
}
|
|
|
|
|
|
@Override
|