|
@@ -16,6 +16,7 @@ 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;
|
|
@@ -31,6 +32,7 @@ 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.StreamUtil;
|
|
|
import com.sd.framework.util.TemplateExcelUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -252,9 +254,9 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
item -> item.getUnitPrice() + ":" + item.getSkuSpecId(),
|
|
|
Function.identity(),
|
|
|
(v1, v2) -> {
|
|
|
- v1.setQuantity(v2.getQuantity());
|
|
|
- v1.setSubtotal(v2.getSubtotal());
|
|
|
- v1.setTotal(v2.getTotal());
|
|
|
+ v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
+ v1.setSubtotal(v1.getSubtotal().add(v2.getSubtotal()));
|
|
|
+ v1.setTotal(v1.getTotal().add(v2.getTotal()));
|
|
|
return v1;
|
|
|
}
|
|
|
)).values();
|
|
@@ -376,7 +378,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
List<DocumentByOrderVo> result = orderList.stream().map(item ->
|
|
|
DocumentByOrderVo.builder()
|
|
|
.orderId(item.getId())
|
|
|
- .wlnCreateTime(item.getWlnCreateTime())
|
|
|
+ .wlnCreateTime(ObjectUtil.defaultIfNull(item.getWlnCreateTime(), item.getCreateTime()))
|
|
|
.code(item.getCode())
|
|
|
.wlnCode(item.getWlnCode())
|
|
|
.build()
|
|
@@ -410,14 +412,14 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
|
|
|
@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);
|
|
|
+ List<DocumentBySkuVo> list = getDocumentBySku(id);
|
|
|
+
|
|
|
Date timePeriodBegin = statementOfAccount.getTimePeriodBegin();
|
|
|
Date timePeriodEnd = statementOfAccount.getTimePeriodEnd();
|
|
|
|
|
@@ -425,22 +427,83 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
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);
|
|
|
+ map.put("totalQuantity", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getQuantity));
|
|
|
+ map.put("totalSubtotal", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getSubtotal));
|
|
|
|
|
|
- TemplateExcelUtil.writeBrowser("skuDocument.xlsx", "事业部sku对账单", response, list, map);
|
|
|
+ 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 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("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, "没有找到事业部");
|
|
|
|
|
|
- BigDecimal totalQuantity = list.stream().map(DocumentByBomVo::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal totalSubtotal = list.stream().map(DocumentByBomVo::getSubtotal).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Date timePeriodBegin = statementOfAccount.getTimePeriodBegin();
|
|
|
Date timePeriodEnd = statementOfAccount.getTimePeriodEnd();
|
|
|
|
|
@@ -448,10 +511,10 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
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);
|
|
|
+ map.put("all", all);
|
|
|
|
|
|
- TemplateExcelUtil.writeBrowser("bomDocument.xlsx", "事业部sku对账单", response, list, map);
|
|
|
+ TemplateExcelUtil.writeBrowser("orderDocument.xlsx", "订单对账单",
|
|
|
+ new DocumentByOrderExcelCellMergeStrategy(list), response, exportDocumentByOrderBos, map);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -506,15 +569,18 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.quantity(item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice())
|
|
|
.laserLogoSummary((Objects.equals(item.getCustomProcessingType(), "20")
|
|
|
- ? item.getCustomProcessingFee() : BigDecimal.ZERO).multiply(item.getQuantity()))
|
|
|
+ ? item.getCustomProcessingFee() : BigDecimal.ZERO))
|
|
|
.laserMitochondrialSummary((Objects.equals(item.getCustomProcessingType(), "10")
|
|
|
- ? item.getCustomProcessingFee() : BigDecimal.ZERO).multiply(item.getQuantity()))
|
|
|
- .lssueFeeSummary(item.getLssueFee().multiply(item.getQuantity()))
|
|
|
- .deliveryMaterialsFeeSummary(item.getDeliveryMaterialsFee().multiply(item.getQuantity()))
|
|
|
- .packingLaborSummary(item.getPackingLabor().multiply(item.getQuantity()))
|
|
|
+ ? item.getCustomProcessingFee() : BigDecimal.ZERO))
|
|
|
+ .lssueFeeSummary(item.getLssueFee())
|
|
|
+ .deliveryMaterialsFeeSummary(item.getDeliveryMaterialsFee())
|
|
|
+ .packingLaborSummary(item.getPackingLabor())
|
|
|
.build()
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
+ Map<Long, BigDecimal> collect = bomSpecList.stream().collect(
|
|
|
+ Collectors.toMap(DocumentByOrderVo.BomSpec::getOrderSkuId, DocumentByOrderVo.BomSpec::getQuantity));
|
|
|
+
|
|
|
List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
|
|
|
|
|
|
List<DocumentByOrderVo.BomSpec> packBomSpecList = orderSkuBomList.stream()
|
|
@@ -523,8 +589,9 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
.bomSpecId(item.getBomSpecId())
|
|
|
.quantity(item.getQuantity())
|
|
|
.unitPrice(item.getUnitPrice())
|
|
|
- .build()
|
|
|
- ).collect(Collectors.toList());
|
|
|
+ .build())
|
|
|
+ .peek(item -> item.setQuantity(collect.get(item.getOrderSkuId()).multiply(item.getQuantity())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
bomSpecList.addAll(packBomSpecList);
|
|
|
|