|
@@ -3,16 +3,22 @@ package com.sd.business.service.statement.impl;
|
|
|
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.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
|
import com.sd.business.entity.excel.enums.ExcelTypeEnum;
|
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
+import com.sd.business.entity.order.po.OrderSku;
|
|
|
+import com.sd.business.entity.sku.po.SkuSpec;
|
|
|
import com.sd.business.entity.statement.dto.ExportDocumentDto;
|
|
|
import com.sd.business.entity.statement.dto.GetDocumentDto;
|
|
|
+import com.sd.business.entity.statement.dto.SalesOutWarehouseDetailsDto;
|
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountMergePageDto;
|
|
|
import com.sd.business.entity.statement.po.StatementOfAccount;
|
|
|
import com.sd.business.entity.statement.vo.DocumentByBomVo;
|
|
@@ -22,6 +28,8 @@ import com.sd.business.entity.statement.vo.StatementOfAccountMergePageVo;
|
|
|
import com.sd.business.service.department.DepartmentService;
|
|
|
import com.sd.business.service.excel.ExcelGenerateLogService;
|
|
|
import com.sd.business.service.order.OrderService;
|
|
|
+import com.sd.business.service.order.OrderSkuService;
|
|
|
+import com.sd.business.service.sku.SkuSpecService;
|
|
|
import com.sd.business.service.statement.StatementOfAccountExportService;
|
|
|
import com.sd.business.service.statement.StatementOfAccountMergeService;
|
|
|
import com.sd.business.service.statement.StatementOfAccountService;
|
|
@@ -32,6 +40,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -60,6 +69,11 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
|
|
|
@Autowired
|
|
|
private ExcelGenerateLogService excelGenerateLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrderSkuService orderSkuService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SkuSpecService skuSpecService;
|
|
|
|
|
|
@Override
|
|
|
public Page<StatementOfAccountMergePageVo> getPage(StatementOfAccountMergePageDto dto) {
|
|
@@ -114,7 +128,7 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
|
|
|
Page<Map<String, Object>> mapPage = statementOfAccountService.pageMaps(dto.getPage(), wrapper);
|
|
|
Page<StatementOfAccountMergePageVo> page = PageUtils.copyPage(mapPage, StatementOfAccountMergePageVo.class);
|
|
|
List<StatementOfAccountMergePageVo> records = page.getRecords();
|
|
|
- if (records.size() == 0) {
|
|
|
+ if (records.isEmpty()) {
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -162,17 +176,17 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
|
|
|
|
|
|
@Override
|
|
|
public List<DocumentBySkuVo> getDocumentBySku(GetDocumentDto dto) {
|
|
|
- return statementOfAccountService.getDocumentBySku(getIdList(dto));
|
|
|
+ return statementOfAccountService.getSkuDocument(getIdList(dto));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DocumentByBomVo> getDocumentByBom(GetDocumentDto dto) {
|
|
|
- return statementOfAccountService.getDocumentByBom(getIdList(dto));
|
|
|
+ return statementOfAccountService.getBomDocument(getIdList(dto));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DocumentByOrderVo> getDocumentByOrder(GetDocumentDto dto) {
|
|
|
- return statementOfAccountService.getDocumentByOrder(getIdList(dto));
|
|
|
+ return statementOfAccountService.getOrderDocument(getIdList(dto));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -205,6 +219,91 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<DocumentByOrderVo> salesOutWarehouseDetails(SalesOutWarehouseDetailsDto dto) {
|
|
|
+
|
|
|
+ // 对账单条件查询
|
|
|
+ List<StatementOfAccount> statementOfAccountList = null;
|
|
|
+ List<Long> statementOfAccountIdList = null;
|
|
|
+
|
|
|
+ if (!ObjectUtil.isAllEmpty(dto.getBeginTime(), dto.getEndTime())) {
|
|
|
+ statementOfAccountList = statementOfAccountService.list(q -> q
|
|
|
+ .ge(ObjectUtil.isNotNull(dto.getBeginTime()), BasePo::getCreateTime, dto.getBeginTime())
|
|
|
+ .le(ObjectUtil.isNotNull(dto.getEndTime()), BasePo::getCreateTime, dto.getEndTime()));
|
|
|
+
|
|
|
+ if (statementOfAccountList.isEmpty()) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ statementOfAccountIdList = statementOfAccountList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ // sku条件查询
|
|
|
+ List<Long> orderIdList = null;
|
|
|
+ if (!StrUtil.isAllBlank(dto.getSkuSpecCode(), dto.getSkuSpecName())) {
|
|
|
+ List<SkuSpec> skuSpecList = skuSpecService.list(q -> q
|
|
|
+ .like(StrUtil.isNotBlank(dto.getSkuSpecCode()), SkuSpec::getCode, dto.getSkuSpecCode())
|
|
|
+ .like(StrUtil.isNotBlank(dto.getSkuSpecName()), SkuSpec::getName, dto.getSkuSpecName()));
|
|
|
+
|
|
|
+ if (skuSpecList.isEmpty()) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ List<Long> skuSpecIdList = skuSpecList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getSkuSpecId, skuSpecIdList));
|
|
|
+ if (orderSkuList.isEmpty()) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ orderIdList = orderSkuList.stream().map(OrderSku::getOrderId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询订单分页
|
|
|
+ Page<OrderInfo> page = orderService.page(dto.getPage(), Wrappers.lambdaQuery(OrderInfo.class)
|
|
|
+ .in(ObjectUtil.isNotEmpty(orderIdList), BaseIdPo::getId, orderIdList)
|
|
|
+ .in(ObjectUtil.isNotEmpty(statementOfAccountIdList), OrderInfo::getStatementOfAccountId, statementOfAccountIdList)
|
|
|
+ .isNotNull(ObjectUtil.isEmpty(statementOfAccountIdList), OrderInfo::getStatementOfAccountId)
|
|
|
+ .eq(ObjectUtil.isNotNull(dto.getDepartmentId()), OrderInfo::getDepartmentId, dto.getDepartmentId())
|
|
|
+ .and(StrUtil.isNotBlank(dto.getCode()), q -> q
|
|
|
+ .like(OrderInfo::getCode, dto.getCode()).or().like(OrderInfo::getWlnCode, dto.getCode()))
|
|
|
+ .orderByDesc(OrderInfo::getStatementOfAccountId)
|
|
|
+ );
|
|
|
+
|
|
|
+ List<OrderInfo> records = page.getRecords();
|
|
|
+
|
|
|
+ if (records.isEmpty()) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 赋值订单sku,包材
|
|
|
+ List<DocumentByOrderVo> orderDocumentByOrderList = statementOfAccountService.getOrderDocumentByOrderList(records);
|
|
|
+
|
|
|
+ // 赋值事业部名称
|
|
|
+ departmentService.attributeAssign(orderDocumentByOrderList, DocumentByOrderVo::getDepartmentId, (item, department) -> {
|
|
|
+ item.setDepartmentName(department.getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 赋值对账时间
|
|
|
+ if (statementOfAccountList == null) {
|
|
|
+ statementOfAccountList = statementOfAccountService.listByIds(
|
|
|
+ records.stream().map(OrderInfo::getStatementOfAccountId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ Map<Long, StatementOfAccount> map = statementOfAccountList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
+
|
|
|
+ for (DocumentByOrderVo documentByOrderVo : orderDocumentByOrderList) {
|
|
|
+ Long statementOfAccountId = documentByOrderVo.getStatementOfAccountId();
|
|
|
+ StatementOfAccount statementOfAccount = map.get(statementOfAccountId);
|
|
|
+ documentByOrderVo.setStatementOfAccountTime(statementOfAccount.getCreateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<DocumentByOrderVo> result = new Page<>();
|
|
|
+ result.setTotal(page.getTotal());
|
|
|
+ result.setRecords(orderDocumentByOrderList);
|
|
|
+ result.setPages(page.getPages());
|
|
|
+ result.setSize(page.getSize());
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private List<Long> getIdList(GetDocumentDto dto) {
|
|
|
|
|
|
String idGroupConcat = dto.getIdGroupConcat();
|