|
@@ -8,9 +8,12 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.entity.corporation.po.Corporation;
|
|
|
import com.fjhx.common.enums.CodingRuleEnum;
|
|
|
import com.fjhx.common.enums.PushBusinessTypeEnum;
|
|
|
import com.fjhx.common.service.coding.CodingRuleService;
|
|
|
+import com.fjhx.common.service.corporation.CorporationService;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
import com.fjhx.sale.entity.documents.po.Documents;
|
|
|
import com.fjhx.sale.entity.documents.po.DocumentsPdf;
|
|
@@ -19,6 +22,8 @@ import com.fjhx.sale.entity.documents.po.DocumentsTransport;
|
|
|
import com.fjhx.sale.entity.pack.dto.PackDto;
|
|
|
import com.fjhx.sale.entity.pack.dto.PackSelectDto;
|
|
|
import com.fjhx.sale.entity.pack.po.*;
|
|
|
+import com.fjhx.sale.entity.pack.vo.PackDetailProductVo;
|
|
|
+import com.fjhx.sale.entity.pack.vo.PackDetailVo;
|
|
|
import com.fjhx.sale.entity.pack.vo.PackVo;
|
|
|
import com.fjhx.sale.mapper.pack.PackMapper;
|
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
@@ -36,7 +41,9 @@ 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.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -47,7 +54,7 @@ import java.util.stream.Collectors;
|
|
|
* 装箱出货表 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
- * @author
|
|
|
+ * @author
|
|
|
* @since 2023-04-18
|
|
|
*/
|
|
|
@Service
|
|
@@ -76,6 +83,8 @@ public class PackServiceImpl extends ServiceImpl<PackMapper, Pack> implements Pa
|
|
|
private DocumentsTransportService documentsTransportService;
|
|
|
@Autowired
|
|
|
private ContractService contractService;
|
|
|
+ @Autowired
|
|
|
+ private CorporationService corporationService;
|
|
|
|
|
|
@Override
|
|
|
public Page<PackVo> getPage(PackSelectDto dto) {
|
|
@@ -94,28 +103,29 @@ public class PackServiceImpl extends ServiceImpl<PackMapper, Pack> implements Pa
|
|
|
|
|
|
/**
|
|
|
* 新增
|
|
|
+ *
|
|
|
* @param pack
|
|
|
*/
|
|
|
@Override
|
|
|
@DSTransactional
|
|
|
public void add(Pack pack) {
|
|
|
- if(StringUtils.isEmpty(pack.getContractIds())){
|
|
|
+ if (StringUtils.isEmpty(pack.getContractIds())) {
|
|
|
throw new ServiceException("参数异常");
|
|
|
}
|
|
|
// pack.setCode(CodeEnum.PACK.getCode());
|
|
|
- pack.setCode(codingRuleService.createCode(CodingRuleEnum.PACK.getKey(),null));
|
|
|
+ pack.setCode(codingRuleService.createCode(CodingRuleEnum.PACK.getKey(), null));
|
|
|
this.save(pack);
|
|
|
List<PackDetail> packDetailList = pack.getPackDetailList();
|
|
|
- if(CollectionUtils.isNotEmpty(packDetailList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(packDetailList)) {
|
|
|
List<PackDetailProduct> packDetailProductList = new ArrayList<>();
|
|
|
List<PackDetailGoods> packDetailGoodsList = new ArrayList<>();
|
|
|
- for(PackDetail p:packDetailList){
|
|
|
+ for (PackDetail p : packDetailList) {
|
|
|
p.setPackId(pack.getId());
|
|
|
p.setId(IdWorker.getId());
|
|
|
//处理装箱产品明细
|
|
|
- setPackDetailProducts(p,packDetailProductList);
|
|
|
+ setPackDetailProducts(p, packDetailProductList);
|
|
|
//处理自定义装箱货物
|
|
|
- setPackDetailGoods(p,packDetailGoodsList);
|
|
|
+ setPackDetailGoods(p, packDetailGoodsList);
|
|
|
}
|
|
|
packDetailService.saveBatch(packDetailList);
|
|
|
packDetailGoodsService.saveBatch(packDetailGoodsList);
|
|
@@ -125,27 +135,30 @@ public class PackServiceImpl extends ServiceImpl<PackMapper, Pack> implements Pa
|
|
|
|
|
|
/**
|
|
|
* 处理装箱产品明细
|
|
|
+ *
|
|
|
* @param packDetail
|
|
|
* @param packDetailProductList
|
|
|
*/
|
|
|
- private void setPackDetailProducts(PackDetail packDetail,List<PackDetailProduct> packDetailProductList){
|
|
|
+ private void setPackDetailProducts(PackDetail packDetail, List<PackDetailProduct> packDetailProductList) {
|
|
|
List<PackDetailProduct> list = packDetail.getPackDetailProductList();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- for(PackDetailProduct p:list){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ for (PackDetailProduct p : list) {
|
|
|
p.setPackDetailId(packDetail.getId());
|
|
|
packDetailProductList.add(p);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 处理装箱产品明细
|
|
|
+ *
|
|
|
* @param packDetail
|
|
|
* @param packDetailGoodsList
|
|
|
*/
|
|
|
- private void setPackDetailGoods(PackDetail packDetail,List<PackDetailGoods> packDetailGoodsList){
|
|
|
+ private void setPackDetailGoods(PackDetail packDetail, List<PackDetailGoods> packDetailGoodsList) {
|
|
|
List<PackDetailGoods> list = packDetail.getPackDetailGoodsList();
|
|
|
- if(CollectionUtils.isNotEmpty(list)){
|
|
|
- for(PackDetailGoods p:list){
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ for (PackDetailGoods p : list) {
|
|
|
p.setPackDetailId(packDetail.getId());
|
|
|
packDetailGoodsList.add(p);
|
|
|
}
|
|
@@ -242,4 +255,54 @@ public class PackServiceImpl extends ServiceImpl<PackMapper, Pack> implements Pa
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 出货通知单
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> shipmentNotification(Long id) {
|
|
|
+ Pack pack = getById(id);
|
|
|
+ Assert.notEmpty(pack, "查询不到装箱信息");
|
|
|
+
|
|
|
+
|
|
|
+ List<PackDetail> packDetailList = packDetailService.list(q -> q.eq(PackDetail::getPackId, pack.getId()));
|
|
|
+ List<PackDetailVo> packDetailVos = BeanUtil.copyToList(packDetailList, PackDetailVo.class);
|
|
|
+
|
|
|
+ for (PackDetailVo packDetailVo : packDetailVos) {
|
|
|
+ //赋值 订单编号 供应商
|
|
|
+ List<PackDetailProduct> packDetailProductList = packDetailProductService.list(q -> q.eq(PackDetailProduct::getPackDetailId, packDetailVo.getId()));
|
|
|
+ List<PackDetailProductVo> packDetailProductVos = BeanUtil.copyToList(packDetailProductList, PackDetailProductVo.class);
|
|
|
+ for (PackDetailProductVo packDetailProduct : packDetailProductVos) {
|
|
|
+ Contract contract = contractService.getById(packDetailProduct.getContractId());
|
|
|
+ Corporation corporation = corporationService.getById(contract.getSellCorporationId());
|
|
|
+ //赋值订单编号供应商
|
|
|
+ packDetailProduct.setSupplierName(corporation.getName());
|
|
|
+ packDetailProduct.setContractCode(contract.getCode());
|
|
|
+ }
|
|
|
+ packDetailVo.setPackDetailProductLists(packDetailProductVos);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ PackShipment packShipment = packShipmentService.getOne(q -> q.like(PackShipment::getPackDetailIds, packDetailList.get(0).getId()));
|
|
|
+ Documents documents = documentsService.getOne(q->q.eq(Documents::getPackShipmentId,packShipment.getId()));
|
|
|
+
|
|
|
+ BigDecimal packQuantity = packDetailList.stream().map(PackDetail::getPackQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal roughWeight = packDetailList.stream().map(PackDetail::getRoughWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal netWeight = packDetailList.stream().map(PackDetail::getNetWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ BigDecimal volume = packDetailList.stream().map(item -> {
|
|
|
+ return item.getBoxLong().multiply(item.getBoxWide()).multiply(item.getBoxHigh());
|
|
|
+ }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("remark", ObjectUtil.isEmpty(documents)?"":documents.getRemark());
|
|
|
+ map.put("packQuantity",packQuantity);
|
|
|
+ map.put("roughWeight",roughWeight);
|
|
|
+ map.put("netWeight",netWeight);
|
|
|
+ map.put("volume",volume);
|
|
|
+ map.put("packDetailList",packDetailVos);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
}
|