|
@@ -2,6 +2,7 @@ package com.sd.business.service.order.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
@@ -34,6 +35,7 @@ import com.sd.business.entity.order.vo.*;
|
|
|
import com.sd.business.entity.price.po.PriceBillingStandard;
|
|
|
import com.sd.business.entity.price.po.PriceBillingStandardDetail;
|
|
|
import com.sd.business.entity.sku.po.SkuSpec;
|
|
|
+import com.sd.business.entity.statement.po.StatementOfAccount;
|
|
|
import com.sd.business.entity.warehouse.constant.WarehouseConstant;
|
|
|
import com.sd.business.mapper.order.OrderMapper;
|
|
|
import com.sd.business.service.bom.BomService;
|
|
@@ -44,6 +46,7 @@ import com.sd.business.service.order.*;
|
|
|
import com.sd.business.service.price.PriceBillingStandardDetailService;
|
|
|
import com.sd.business.service.price.PriceBillingStandardService;
|
|
|
import com.sd.business.service.sku.SkuSpecService;
|
|
|
+import com.sd.business.service.statement.StatementOfAccountService;
|
|
|
import com.sd.framework.util.Assert;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -98,6 +101,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
|
|
|
private InOutStorageService inOutStorageService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private StatementOfAccountService statementOfAccountService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ISysUserService sysUserService;
|
|
|
|
|
|
@Override
|
|
@@ -119,11 +125,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
|
|
|
.or(r -> r.eq("o", OrderInfo::getSource, 1))
|
|
|
);
|
|
|
|
|
|
- List<Long> detpIdList = sysUserService.getDetpIdListByUserId(SecurityUtils.getUserId());
|
|
|
- if (detpIdList.size() > 0) {
|
|
|
- wrapper.in("o", OrderInfo::getDepartmentId, detpIdList);
|
|
|
- wrapper.eq("o", OrderInfo::getCreateUser, SecurityUtils.getUserId());
|
|
|
- }
|
|
|
+// List<Long> detpIdList = sysUserService.getDetpIdListByUserId(SecurityUtils.getUserId());
|
|
|
+// if (detpIdList.size() > 0) {
|
|
|
+// wrapper.in("o", OrderInfo::getDepartmentId, detpIdList);
|
|
|
+// wrapper.eq("o", OrderInfo::getCreateUser, SecurityUtils.getUserId());
|
|
|
+// }
|
|
|
|
|
|
if (Objects.equals(dto.getLinkedStatementOfAccount(), 0)) {
|
|
|
wrapper.isNull("o.statement_of_account_id");
|
|
@@ -621,6 +627,30 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
|
|
|
return compareVo;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public BigDecimal getOrderBomSpecOutStorageQuantity(Long bomSpecId, Integer days) {
|
|
|
+ Date date = DateUtil.date();
|
|
|
+ Date offsetDay = DateUtil.offsetDay(date, -days);
|
|
|
+
|
|
|
+ // 根据对账时间获取有对账单的订单
|
|
|
+ List<StatementOfAccount> list = statementOfAccountService.list(q -> q.ge(StatementOfAccount::getTimePeriod, offsetDay));
|
|
|
+ List<Long> accountIds = list.stream().map(StatementOfAccount::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(Collections.singleton(bomSpecId));
|
|
|
+ IWrapper<OrderInfo> wrapper = getWrapper();
|
|
|
+ wrapper.ge("o", OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey());
|
|
|
+ wrapper.in("o", OrderInfo::getStatementOfAccountId, accountIds);
|
|
|
+ if (ObjectUtil.equal(bomSpecBo.get(bomSpecId).getClassifyParentId(), 1L)) {
|
|
|
+ // 查询主材消耗数量
|
|
|
+ wrapper.eq("os", OrderSku::getBomSpecId, bomSpecId);
|
|
|
+ return this.baseMapper.getOrderSkuOutStorageQuantity(wrapper);
|
|
|
+ } else {
|
|
|
+ // 查询包材消耗数量
|
|
|
+ wrapper.eq("osb", OrderSkuBom::getBomSpecId, bomSpecId);
|
|
|
+ return this.baseMapper.getOrderSkuBomOutStorageQuantity(wrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 删除订单以及订单关联数据
|
|
|
*/
|