|
@@ -1,8 +1,10 @@
|
|
package com.sd.business.service.order.impl;
|
|
package com.sd.business.service.order.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
@@ -71,7 +73,7 @@ public class IssueBillServiceImpl implements IssueBillService {
|
|
wrapper.orderByDesc("oi", OrderInfo::getWlnCreateTime);
|
|
wrapper.orderByDesc("oi", OrderInfo::getWlnCreateTime);
|
|
|
|
|
|
wrapper.eq("oi", OrderInfo::getSource, 1);
|
|
wrapper.eq("oi", OrderInfo::getSource, 1);
|
|
- wrapper.eq("oi", OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey());
|
|
|
|
|
|
+ wrapper.in("oi", OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey(), OrderStatusEnum.COMPLETION_PRODUCTION.getKey());
|
|
|
|
|
|
wrapper.like("oi", OrderInfo::getCode, dto.getCode());
|
|
wrapper.like("oi", OrderInfo::getCode, dto.getCode());
|
|
wrapper.eq("oi", OrderInfo::getDepartmentId, dto.getDepartmentId());
|
|
wrapper.eq("oi", OrderInfo::getDepartmentId, dto.getDepartmentId());
|
|
@@ -105,7 +107,6 @@ public class IssueBillServiceImpl implements IssueBillService {
|
|
Collectors.groupingBy(OrderInfo::getMasterOrderId, Collectors.mapping(OrderInfo::getCode, Collectors.toList())));
|
|
Collectors.groupingBy(OrderInfo::getMasterOrderId, Collectors.mapping(OrderInfo::getCode, Collectors.toList())));
|
|
records.forEach(item -> item.setGroupOrderCodeList(map.getOrDefault(item.getId(), Collections.emptyList())));
|
|
records.forEach(item -> item.setGroupOrderCodeList(map.getOrDefault(item.getId(), Collections.emptyList())));
|
|
|
|
|
|
-
|
|
|
|
QueryWrapper<OrderEncasement> orderEncasementWrapper = new QueryWrapper<>();
|
|
QueryWrapper<OrderEncasement> orderEncasementWrapper = new QueryWrapper<>();
|
|
orderEncasementWrapper.select(
|
|
orderEncasementWrapper.select(
|
|
"order_id as orderId",
|
|
"order_id as orderId",
|
|
@@ -124,7 +125,7 @@ public class IssueBillServiceImpl implements IssueBillService {
|
|
if (itemMap != null) {
|
|
if (itemMap != null) {
|
|
record.setTotalNetWeight((BigDecimal) itemMap.get("totalNetWeight"));
|
|
record.setTotalNetWeight((BigDecimal) itemMap.get("totalNetWeight"));
|
|
record.setTotalVolume((BigDecimal) itemMap.get("totalVolume"));
|
|
record.setTotalVolume((BigDecimal) itemMap.get("totalVolume"));
|
|
- record.setTotal((Integer) itemMap.get("total"));
|
|
|
|
|
|
+ record.setTotal((Convert.toInt(itemMap.get("total"))));
|
|
} else {
|
|
} else {
|
|
record.setTotalNetWeight(BigDecimal.ZERO);
|
|
record.setTotalNetWeight(BigDecimal.ZERO);
|
|
record.setTotalVolume(BigDecimal.ZERO);
|
|
record.setTotalVolume(BigDecimal.ZERO);
|
|
@@ -192,18 +193,88 @@ public class IssueBillServiceImpl implements IssueBillService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public AssemblyDetailVo assemblyDetail(Long id) {
|
|
|
|
|
|
+ public AssemblyDetailVo assemblyDetail(Long orderId) {
|
|
AssemblyDetailVo result = new AssemblyDetailVo();
|
|
AssemblyDetailVo result = new AssemblyDetailVo();
|
|
|
|
|
|
|
|
+ List<AssemblyDetailVo.SkuInfo> skuInfoList = getSkuInfoList(orderId);
|
|
|
|
+
|
|
|
|
+ List<OrderEncasement> tempOrderEncasementList = orderEncasementService.list(q -> q.eq(OrderEncasement::getOrderId, orderId));
|
|
|
|
+ if (tempOrderEncasementList.size() == 0) {
|
|
|
|
+ result.setSkuInfoList(skuInfoList);
|
|
|
|
+ result.setOrderEncasementList(Collections.emptyList());
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ List<OrderEncasementVo> orderEncasementList = getOrderEncasementVoList(tempOrderEncasementList, skuInfoList);
|
|
|
|
+
|
|
|
|
+ result.setSkuInfoList(skuInfoList);
|
|
|
|
+ result.setOrderEncasementList(orderEncasementList);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteAllowance(Long id) {
|
|
|
|
+ orderEncasementService.delete(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public AssemblyDetailVo copyAllowance(OrderEncasement dto) {
|
|
|
|
+ OrderEncasement orderEncasement = orderEncasementService.getById(dto.getId());
|
|
|
|
+ orderEncasement.setTotal(orderEncasement.getTotal() + dto.getTotal());
|
|
|
|
+ orderEncasementService.updateById(dto);
|
|
|
|
+ return verifiedQuantityAndGetDetail(orderEncasement.getOrderId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public AssemblyDetailVo addAllowance(OrderEncasementDto dto) {
|
|
|
|
+ dto.setId(IdWorker.getId());
|
|
|
|
+ dto.setNetWeight(BigDecimal.ZERO);
|
|
|
|
+
|
|
|
|
+ List<OrderEncasementDetail> orderEncasementDetailList = dto.getOrderEncasementDetailList();
|
|
|
|
+ List<Long> bomSpecIdList = orderEncasementDetailList.stream().map(OrderEncasementDetail::getBomSpecId).collect(Collectors.toList());
|
|
|
|
+ Map<Long, BomSpec> bomSpecMap = bomSpecService.mapKEntity(BaseIdPo::getId, q -> q.in(BaseIdPo::getId, bomSpecIdList));
|
|
|
|
+ orderEncasementDetailList.forEach(item -> {
|
|
|
|
+ BomSpec bomSpec = bomSpecMap.get(item.getBomSpecId());
|
|
|
|
+ BigDecimal netWeight = ObjectUtil.defaultIfNull(bomSpec.getNetWeight(), BigDecimal.ZERO);
|
|
|
|
+ dto.setNetWeight(dto.getNetWeight().add(netWeight));
|
|
|
|
+
|
|
|
|
+ item.setOrderEncasementId(dto.getId());
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ orderEncasementService.save(dto);
|
|
|
|
+ orderEncasementDetailService.saveBatch(orderEncasementDetailList);
|
|
|
|
+
|
|
|
|
+ return verifiedQuantityAndGetDetail(dto.getOrderId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 验证数量并获取明细
|
|
|
|
+ */
|
|
|
|
+ private AssemblyDetailVo verifiedQuantityAndGetDetail(Long orderId) {
|
|
|
|
+ AssemblyDetailVo assemblyDetailVo = assemblyDetail(orderId);
|
|
|
|
+ List<AssemblyDetailVo.SkuInfo> skuInfoList = assemblyDetailVo.getSkuInfoList();
|
|
|
|
+ for (AssemblyDetailVo.SkuInfo skuInfo : skuInfoList) {
|
|
|
|
+ if (skuInfo.getSurplusQuantity().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
+ throw new ServiceException("数量不足:装箱数量大于被装箱数量");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return assemblyDetailVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<AssemblyDetailVo.SkuInfo> getSkuInfoList(Long orderId) {
|
|
|
|
+
|
|
// 获取合并订单
|
|
// 获取合并订单
|
|
- List<OrderInfo> mergeOrderList = orderService.list(q -> q.eq(OrderInfo::getMasterOrderId, id));
|
|
|
|
|
|
+ List<OrderInfo> mergeOrderList = orderService.list(q -> q.eq(OrderInfo::getMasterOrderId, orderId));
|
|
|
|
|
|
// 订单id列表
|
|
// 订单id列表
|
|
List<Long> orderIdList = mergeOrderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
List<Long> orderIdList = mergeOrderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
- orderIdList.add(id);
|
|
|
|
|
|
+ orderIdList.add(orderId);
|
|
|
|
|
|
// 赋值产品清单
|
|
// 赋值产品清单
|
|
List<OrderSku> list = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
List<OrderSku> list = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
|
+
|
|
List<AssemblyDetailVo.SkuInfo> skuInfoList = list.stream().map(item -> {
|
|
List<AssemblyDetailVo.SkuInfo> skuInfoList = list.stream().map(item -> {
|
|
AssemblyDetailVo.SkuInfo skuInfo = new AssemblyDetailVo.SkuInfo();
|
|
AssemblyDetailVo.SkuInfo skuInfo = new AssemblyDetailVo.SkuInfo();
|
|
skuInfo.setOrderSkuId(item.getId());
|
|
skuInfo.setOrderSkuId(item.getId());
|
|
@@ -219,14 +290,11 @@ public class IssueBillServiceImpl implements IssueBillService {
|
|
item.setSkuSpecCode(skuSpec.getCode());
|
|
item.setSkuSpecCode(skuSpec.getCode());
|
|
item.setSkuSpecName(skuSpec.getName());
|
|
item.setSkuSpecName(skuSpec.getName());
|
|
});
|
|
});
|
|
- result.setSkuInfoList(skuInfoList);
|
|
|
|
|
|
|
|
- // 包裹规格数
|
|
|
|
- List<OrderEncasement> tempOrderEncasementList = orderEncasementService.list(q -> q.eq(OrderEncasement::getOrderId, id));
|
|
|
|
- if (tempOrderEncasementList.size() == 0) {
|
|
|
|
- result.setOrderEncasementList(Collections.emptyList());
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
|
|
+ return skuInfoList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<OrderEncasementVo> getOrderEncasementVoList(List<OrderEncasement> tempOrderEncasementList, List<AssemblyDetailVo.SkuInfo> skuInfoList) {
|
|
|
|
|
|
List<OrderEncasementVo> orderEncasementList = BeanUtil.copyToList(tempOrderEncasementList, OrderEncasementVo.class);
|
|
List<OrderEncasementVo> orderEncasementList = BeanUtil.copyToList(tempOrderEncasementList, OrderEncasementVo.class);
|
|
Map<Long, OrderEncasementVo> orderEncasementVoMap = orderEncasementList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
Map<Long, OrderEncasementVo> orderEncasementVoMap = orderEncasementList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
@@ -258,55 +326,7 @@ public class IssueBillServiceImpl implements IssueBillService {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- result.setOrderEncasementList(orderEncasementList);
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- @Override
|
|
|
|
- public void deleteAllowance(Long id) {
|
|
|
|
- orderEncasementService.delete(id);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- @Override
|
|
|
|
- public AssemblyDetailVo copyAllowance(OrderEncasement dto) {
|
|
|
|
- OrderEncasement orderEncasement = orderEncasementService.getById(dto.getId());
|
|
|
|
- orderEncasement.setTotal(orderEncasement.getTotal() + dto.getTotal());
|
|
|
|
- orderEncasementService.updateById(dto);
|
|
|
|
- return verifiedQuantityAndGetDetail(orderEncasement.getOrderId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- @Override
|
|
|
|
- public AssemblyDetailVo addAllowance(OrderEncasementDto dto) {
|
|
|
|
- dto.setNetWeight(BigDecimal.ZERO);
|
|
|
|
- orderEncasementService.save(dto);
|
|
|
|
- List<OrderEncasementDetail> orderEncasementDetailList = dto.getOrderEncasementDetailList();
|
|
|
|
- List<Long> bomSpecIdList = orderEncasementDetailList.stream().map(OrderEncasementDetail::getBomSpecId).collect(Collectors.toList());
|
|
|
|
- List<BomSpec> bomSpecList = bomSpecService.listByIds(bomSpecIdList);
|
|
|
|
- Map<Long, BomSpec> bomSpecMap = bomSpecList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
|
-
|
|
|
|
- orderEncasementDetailList.forEach(item -> {
|
|
|
|
- item.setOrderEncasementId(dto.getId());
|
|
|
|
- BigDecimal netWeight = ObjectUtil.defaultIfNull(bomSpecMap.get(item.getBomSpecId()).getNetWeight(), BigDecimal.ZERO);
|
|
|
|
- dto.setNetWeight(dto.getNetWeight().add(netWeight));
|
|
|
|
- });
|
|
|
|
- return verifiedQuantityAndGetDetail(dto.getOrderId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 验证数量并获取明细
|
|
|
|
- */
|
|
|
|
- private AssemblyDetailVo verifiedQuantityAndGetDetail(Long orderId) {
|
|
|
|
- AssemblyDetailVo assemblyDetailVo = assemblyDetail(orderId);
|
|
|
|
- List<AssemblyDetailVo.SkuInfo> skuInfoList = assemblyDetailVo.getSkuInfoList();
|
|
|
|
- for (AssemblyDetailVo.SkuInfo skuInfo : skuInfoList) {
|
|
|
|
- if (skuInfo.getSurplusQuantity().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
- throw new ServiceException("数量不足:装箱数量大于被装箱数量");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return assemblyDetailVo;
|
|
|
|
|
|
+ return orderEncasementList;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|