|
@@ -11,12 +11,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.file.entity.FileInfoVo;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.sd.business.entity.department.po.Department;
|
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
import com.sd.business.entity.order.po.OrderSku;
|
|
|
import com.sd.business.entity.order.po.OrderSkuBom;
|
|
|
-import com.sd.business.entity.statement.bo.ExportDocumentByOrderBo;
|
|
|
import com.sd.business.entity.statement.dto.FileUploadDto;
|
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountDto;
|
|
|
import com.sd.business.entity.statement.dto.StatementOfAccountSelectDto;
|
|
@@ -29,16 +29,14 @@ import com.sd.business.service.order.OrderService;
|
|
|
import com.sd.business.service.order.OrderSkuBomService;
|
|
|
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.StatementOfAccountService;
|
|
|
import com.sd.business.util.CodeEnum;
|
|
|
import com.sd.framework.util.Assert;
|
|
|
-import com.sd.framework.util.StreamUtil;
|
|
|
-import com.sd.framework.util.TemplateExcelUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
@@ -74,6 +72,9 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
@Autowired
|
|
|
private BomSpecService bomSpecService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StatementOfAccountExportService statementOfAccountExportService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<StatementOfAccountVo> getPage(StatementOfAccountSelectDto dto) {
|
|
|
|
|
@@ -214,10 +215,10 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<DocumentBySkuVo> getDocumentBySku(Long statementOfAccountId) {
|
|
|
+ public List<DocumentBySkuVo> getDocumentBySku(List<Long> statementOfAccountIdList) {
|
|
|
|
|
|
// 获取订单id列表
|
|
|
- List<Long> orderIdList = getOrderIdList(statementOfAccountId);
|
|
|
+ List<Long> orderIdList = getOrderIdList(statementOfAccountIdList);
|
|
|
|
|
|
if (orderIdList.size() == 0) {
|
|
|
return Collections.emptyList();
|
|
@@ -266,10 +267,10 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<DocumentByBomVo> getDocumentByBom(Long statementOfAccountId) {
|
|
|
+ public List<DocumentByBomVo> getDocumentByBom(List<Long> statementOfAccountIdList) {
|
|
|
|
|
|
// 获取订单id列表
|
|
|
- List<Long> orderIdList = getOrderIdList(statementOfAccountId);
|
|
|
+ List<Long> orderIdList = getOrderIdList(statementOfAccountIdList);
|
|
|
|
|
|
if (orderIdList.size() == 0) {
|
|
|
return Collections.emptyList();
|
|
@@ -368,10 +369,10 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<DocumentByOrderVo> getDocumentByOrder(Long statementOfAccountId) {
|
|
|
+ public List<DocumentByOrderVo> getDocumentByOrder(List<Long> statementOfAccountId) {
|
|
|
|
|
|
- Assert.notNull(statementOfAccountId, "对账单id不能为空");
|
|
|
- List<OrderInfo> orderList = orderService.list(q -> q.eq(OrderInfo::getStatementOfAccountId, statementOfAccountId));
|
|
|
+ Assert.notEmpty(statementOfAccountId, "对账单id不能为空");
|
|
|
+ List<OrderInfo> orderList = orderService.list(q -> q.in(OrderInfo::getStatementOfAccountId, statementOfAccountId));
|
|
|
if (orderList.size() == 0) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
@@ -412,118 +413,42 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void exportDocumentBySku(HttpServletResponse response, Long id) {
|
|
|
+ public void export(Long id, int type) {
|
|
|
|
|
|
StatementOfAccount statementOfAccount = getById(id);
|
|
|
Assert.notNull(statementOfAccount, "没有找到对账单");
|
|
|
- Department department = departmentService.getById(statementOfAccount.getDepartmentId());
|
|
|
- Assert.notNull(department, "没有找到事业部");
|
|
|
-
|
|
|
- List<DocumentBySkuVo> list = getDocumentBySku(id);
|
|
|
-
|
|
|
- Date timePeriod = statementOfAccount.getTimePeriod();
|
|
|
- String timePeriodStr = timePeriod != null ? DateUtil.formatDate(timePeriod) : StringPool.EMPTY;
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("department", department.getName() + " - ");
|
|
|
- map.put("beginDate", timePeriodStr);
|
|
|
- map.put("endDate", timePeriodStr);
|
|
|
- map.put("totalQuantity", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getQuantity));
|
|
|
- map.put("totalSubtotal", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getSubtotal));
|
|
|
|
|
|
- TemplateExcelUtil.writeBrowser("skuDocument.xlsx", "sku对账单", response, list, map);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void exportDocumentByBom(HttpServletResponse response, Long id) {
|
|
|
-
|
|
|
- StatementOfAccount statementOfAccount = getById(id);
|
|
|
- Assert.notNull(statementOfAccount, "没有找到对账单");
|
|
|
Department department = departmentService.getById(statementOfAccount.getDepartmentId());
|
|
|
Assert.notNull(department, "没有找到事业部");
|
|
|
|
|
|
- List<DocumentByBomVo> list = getDocumentByBom(id);
|
|
|
-
|
|
|
Date timePeriod = statementOfAccount.getTimePeriod();
|
|
|
- String timePeriodStr = timePeriod != null ? DateUtil.formatDate(timePeriod) : StringPool.EMPTY;
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("department", department.getName() + " - ");
|
|
|
- map.put("beginDate", timePeriodStr);
|
|
|
- map.put("endDate", timePeriodStr);
|
|
|
- map.put("totalSubtotal", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getSubtotal));
|
|
|
- map.put("totalLaserLogoSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getLaserLogoSummary));
|
|
|
- map.put("totalLaserMitochondrialSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getLaserMitochondrialSummary));
|
|
|
- map.put("totalLssueFeeSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getLssueFeeSummary));
|
|
|
- map.put("totalDeliveryMaterialsFeeSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getDeliveryMaterialsFeeSummary));
|
|
|
- map.put("totalPackingLaborSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getPackingLaborSummary));
|
|
|
-
|
|
|
- TemplateExcelUtil.writeBrowser("bomDocument.xlsx", "bom对账单", response, list, map);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void exportDocumentByOrder(HttpServletResponse response, Long id) {
|
|
|
-
|
|
|
- StatementOfAccount statementOfAccount = getById(id);
|
|
|
- Assert.notNull(statementOfAccount, "没有找到对账单");
|
|
|
- Department department = departmentService.getById(statementOfAccount.getDepartmentId());
|
|
|
- Assert.notNull(department, "没有找到事业部");
|
|
|
-
|
|
|
- List<DocumentByOrderVo> list = getDocumentByOrder(id);
|
|
|
-
|
|
|
- BigDecimal all = BigDecimal.ZERO;
|
|
|
-
|
|
|
- List<ExportDocumentByOrderBo> exportDocumentByOrderBos = new ArrayList<>();
|
|
|
- for (DocumentByOrderVo documentByOrderVo : list) {
|
|
|
- List<DocumentByOrderVo.SkuSpec> skuSpecList = documentByOrderVo.getSkuSpecList();
|
|
|
- for (DocumentByOrderVo.SkuSpec skuSpec : skuSpecList) {
|
|
|
- List<DocumentByOrderVo.BomSpec> bomSpecList = skuSpec.getBomSpecList();
|
|
|
- for (DocumentByOrderVo.BomSpec bomSpec : bomSpecList) {
|
|
|
- ExportDocumentByOrderBo exportDocumentByOrderBo = ExportDocumentByOrderBo.builder()
|
|
|
- .wlnCreateTime(documentByOrderVo.getWlnCreateTime())
|
|
|
- .code(documentByOrderVo.getCode())
|
|
|
- .wlnCode(documentByOrderVo.getWlnCode())
|
|
|
- .skuSpecCode(skuSpec.getSkuSpecCode())
|
|
|
- .skuSpecName(skuSpec.getSkuSpecName())
|
|
|
- .quantity(skuSpec.getQuantity())
|
|
|
- .unitPrice(skuSpec.getUnitPrice())
|
|
|
- .subtotal(skuSpec.getSubtotal())
|
|
|
- .total(skuSpec.getTotal())
|
|
|
- .bomSpecCode(bomSpec.getBomSpecCode())
|
|
|
- .bomSpecName(bomSpec.getBomSpecName())
|
|
|
- .bomQuantity(bomSpec.getQuantity())
|
|
|
- .bomUnitPrice(bomSpec.getUnitPrice())
|
|
|
- .laserLogoSummary(bomSpec.getLaserLogoSummary())
|
|
|
- .laserMitochondrialSummary(bomSpec.getLaserMitochondrialSummary())
|
|
|
- .lssueFeeSummary(bomSpec.getLssueFeeSummary())
|
|
|
- .deliveryMaterialsFeeSummary(bomSpec.getDeliveryMaterialsFeeSummary())
|
|
|
- .packingLaborSummary(bomSpec.getPackingLaborSummary())
|
|
|
- .build();
|
|
|
- exportDocumentByOrderBos.add(exportDocumentByOrderBo);
|
|
|
- }
|
|
|
- all = all.add(skuSpec.getTotal());
|
|
|
- }
|
|
|
+ String date = timePeriod != null ? DateUtil.formatDate(timePeriod) : StringPool.EMPTY;
|
|
|
+ String departmentName = department.getName();
|
|
|
+
|
|
|
+ List<Long> idList = Collections.singletonList(id);
|
|
|
+
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ statementOfAccountExportService.exportDocumentBySku(idList, departmentName, date, date);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ statementOfAccountExportService.exportDocumentByBom(idList, departmentName, date, date);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ statementOfAccountExportService.exportDocumentByOrder(idList, departmentName, date, date);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new ServiceException("未知对账单类型");
|
|
|
}
|
|
|
|
|
|
- Date timePeriod = statementOfAccount.getTimePeriod();
|
|
|
- String timePeriodStr = timePeriod != null ? DateUtil.formatDate(timePeriod) : StringPool.EMPTY;
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("department", department.getName() + " - ");
|
|
|
- map.put("beginDate", timePeriodStr);
|
|
|
- map.put("endDate", timePeriodStr);
|
|
|
- map.put("all", all);
|
|
|
-
|
|
|
- TemplateExcelUtil.writeBrowser("orderDocument.xlsx", "订单对账单",
|
|
|
- new DocumentByOrderExcelCellMergeStrategy(list), response, exportDocumentByOrderBos, map);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据对账单id获取对账订单id列表
|
|
|
*/
|
|
|
- private List<Long> getOrderIdList(Long statementOfAccountId) {
|
|
|
- Assert.notNull(statementOfAccountId, "对账单id不能为空");
|
|
|
- List<OrderInfo> orderList = orderService.list(q -> q.eq(OrderInfo::getStatementOfAccountId, statementOfAccountId));
|
|
|
+ private List<Long> getOrderIdList(List<Long> statementOfAccountIdList) {
|
|
|
+ Assert.notEmpty(statementOfAccountIdList, "对账单id不能为空");
|
|
|
+ List<OrderInfo> orderList = orderService.list(q -> q.in(OrderInfo::getStatementOfAccountId, statementOfAccountIdList));
|
|
|
return orderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
@@ -544,8 +469,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.add(item.getDeliveryMaterialsFee())
|
|
|
.add(item.getPackingLabor())
|
|
|
.add(item.getPackagingMaterialCost()))
|
|
|
- .build()
|
|
|
- )
|
|
|
+ .build())
|
|
|
.peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice())))
|
|
|
.peek(item -> item.setTotal(item.getSubtotal()))
|
|
|
.collect(Collectors.toList());
|
|
@@ -576,10 +500,10 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.lssueFeeSummary(item.getLssueFee())
|
|
|
.deliveryMaterialsFeeSummary(item.getDeliveryMaterialsFee())
|
|
|
.packingLaborSummary(item.getPackingLabor())
|
|
|
- .build()
|
|
|
- ).collect(Collectors.toList());
|
|
|
+ .build())
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- Map<Long, BigDecimal> collect = bomSpecList.stream().collect(
|
|
|
+ Map<Long, BigDecimal> map = bomSpecList.stream().collect(
|
|
|
Collectors.toMap(DocumentByOrderVo.BomSpec::getOrderSkuId, DocumentByOrderVo.BomSpec::getQuantity));
|
|
|
|
|
|
List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
|
|
@@ -591,7 +515,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.quantity(item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice())
|
|
|
.build())
|
|
|
- .peek(item -> item.setQuantity(collect.get(item.getOrderSkuId()).multiply(item.getQuantity())))
|
|
|
+ .peek(item -> item.setQuantity(map.get(item.getOrderSkuId()).multiply(item.getQuantity())))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
bomSpecList.addAll(packBomSpecList);
|