|
@@ -1,8 +1,10 @@
|
|
|
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 com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -10,6 +12,7 @@ import com.fjhx.file.entity.FileInfoVo;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
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;
|
|
@@ -28,10 +31,12 @@ import com.sd.business.service.sku.SkuSpecService;
|
|
|
import com.sd.business.service.statement.StatementOfAccountService;
|
|
|
import com.sd.business.util.CodeEnum;
|
|
|
import com.sd.framework.util.Assert;
|
|
|
+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;
|
|
@@ -403,6 +408,51 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void exportDocumentBySku(HttpServletResponse response, Long id) {
|
|
|
+ List<DocumentBySkuVo> list = getDocumentBySku(id);
|
|
|
+ StatementOfAccount statementOfAccount = getById(id);
|
|
|
+ Assert.notNull(statementOfAccount, "没有找到对账单");
|
|
|
+ Department department = departmentService.getById(statementOfAccount.getDepartmentId());
|
|
|
+ Assert.notNull(department, "没有找到事业部");
|
|
|
+
|
|
|
+ BigDecimal totalQuantity = list.stream().map(DocumentBySkuVo::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalSubtotal = list.stream().map(DocumentBySkuVo::getSubtotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ Date timePeriodBegin = statementOfAccount.getTimePeriodBegin();
|
|
|
+ Date timePeriodEnd = statementOfAccount.getTimePeriodEnd();
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("department", department.getName());
|
|
|
+ map.put("beginDate", timePeriodBegin != null ? DateUtil.formatDate(timePeriodBegin) : StringPool.EMPTY);
|
|
|
+ map.put("endDate", timePeriodEnd != null ? DateUtil.formatDate(timePeriodEnd) : StringPool.EMPTY);
|
|
|
+ map.put("totalQuantity", totalQuantity);
|
|
|
+ map.put("totalSubtotal", totalSubtotal);
|
|
|
+
|
|
|
+ TemplateExcelUtil.writeBrowser("skuDocument.xlsx", "事业部sku对账单", response, list, map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportDocumentByBom(HttpServletResponse response, Long id) {
|
|
|
+ List<DocumentByBomVo> list = getDocumentByBom(id);
|
|
|
+ StatementOfAccount statementOfAccount = getById(id);
|
|
|
+ Assert.notNull(statementOfAccount, "没有找到对账单");
|
|
|
+ Department department = departmentService.getById(statementOfAccount.getDepartmentId());
|
|
|
+ Assert.notNull(department, "没有找到事业部");
|
|
|
+
|
|
|
+ BigDecimal totalQuantity = list.stream().map(DocumentByBomVo::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalSubtotal = list.stream().map(DocumentByBomVo::getSubtotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ Date timePeriodBegin = statementOfAccount.getTimePeriodBegin();
|
|
|
+ Date timePeriodEnd = statementOfAccount.getTimePeriodEnd();
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("department", department.getName());
|
|
|
+ map.put("beginDate", timePeriodBegin != null ? DateUtil.formatDate(timePeriodBegin) : StringPool.EMPTY);
|
|
|
+ map.put("endDate", timePeriodEnd != null ? DateUtil.formatDate(timePeriodEnd) : StringPool.EMPTY);
|
|
|
+ map.put("totalQuantity", totalQuantity);
|
|
|
+ map.put("totalSubtotal", totalSubtotal);
|
|
|
+
|
|
|
+ TemplateExcelUtil.writeBrowser("bomDocument.xlsx", "事业部sku对账单", response, list, map);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 根据对账单id获取对账订单id列表
|