|
@@ -9,13 +9,9 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
-import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
-import com.alibaba.excel.write.metadata.WriteTable;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.ruoyi.common.importExcel.excel.EasyPoiHelper;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.google.common.base.Functions;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.ruoyi.common.enums.FileBuzType;
|
|
@@ -34,7 +30,6 @@ import com.ruoyi.project.business.domain.vo.contract.TqContractExportVo;
|
|
|
import com.ruoyi.project.business.domain.vo.contract.TqContractLiftVo;
|
|
|
import com.ruoyi.project.business.domain.vo.contract.TqContractVo;
|
|
|
import com.ruoyi.project.business.domain.vo.currency.ContractCurrencyTime;
|
|
|
-import com.ruoyi.project.business.domain.vo.quotation.QuotationVO;
|
|
|
import com.ruoyi.project.business.dto.ContractSigningStatistic;
|
|
|
import com.ruoyi.project.business.dto.LiftCount;
|
|
|
import com.ruoyi.project.business.dto.LiftMonthCount;
|
|
@@ -62,11 +57,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
-import static com.ruoyi.common.utils.DateUtils.getMonthEnd;
|
|
|
-import static com.ruoyi.common.utils.DateUtils.getMonthStart;
|
|
|
import static com.ruoyi.common.utils.DecimalUtils.add;
|
|
|
import static com.ruoyi.project.business.enums.AuditFlowEnum.*;
|
|
|
-import static java.util.Objects.isNull;
|
|
|
+import static java.math.BigDecimal.ZERO;
|
|
|
import static java.util.Objects.nonNull;
|
|
|
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
|
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
|
@@ -503,36 +496,33 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
result.setWeek(DateUtils.getWeekNumber(end));
|
|
|
// 1. 各区域本周、月电梯(签单、排产、发货)数量统计
|
|
|
List<LiftCount> weekCountList = tqContractLiftMapper.countStatistic(begin, end);
|
|
|
- List<LiftCount> monthCountList = tqContractLiftMapper.countStatistic(getMonthStart(end), getMonthEnd(end));
|
|
|
- result.setWeekCountList(weekCountList);
|
|
|
- weekCountList.forEach(count -> {
|
|
|
- result.setWeekSignCountTotal(add(result.getWeekSignCountTotal(), count.getSignCount()));
|
|
|
- result.setWeekProductionCountTotal(add(result.getWeekProductionCountTotal(), count.getProductionCount()));
|
|
|
- result.setWeekDeliveryCountTotal(add(result.getWeekDeliveryCountTotal(), count.getDeliveryCount()));
|
|
|
- });
|
|
|
- monthCountList.forEach(count -> {
|
|
|
- result.setMonthSignCountTotal(add(result.getMonthSignCountTotal(), count.getSignCount()));
|
|
|
- result.setMonthProductionCountTotal(add(result.getMonthProductionCountTotal(), count.getProductionCount()));
|
|
|
- result.setMonthDeliveryCountTotal(add(result.getMonthDeliveryCountTotal(), count.getDeliveryCount()));
|
|
|
- });
|
|
|
+ List<List<String>> weekCountStatistics = Lists.newArrayList();
|
|
|
+ weekCountStatistics.add(Lists.newArrayList("区域", "签单", "排产", "发货"));
|
|
|
+ weekCountStatistics.addAll(getTotalList(weekCountList, "周合计"));
|
|
|
+ result.setAreaCountStatisticsTitle(year + "周各区域数据");
|
|
|
+ result.setAreaCountStatistics(weekCountStatistics);
|
|
|
|
|
|
// 2. 全年月度(签单、排产、发货)数量统计
|
|
|
List<LiftCount> monthCountListAll = tqContractLiftMapper.countStatisticByMonthAll(year);
|
|
|
- result.setMonthCountListAll(monthCountListAll);
|
|
|
- monthCountListAll.forEach(count -> {
|
|
|
- result.setMonthSignCountTotalAll(add(result.getMonthSignCountTotalAll(), count.getSignCount()));
|
|
|
- result.setMonthProductionCountTotalAll(add(result.getMonthProductionCountTotalAll(), count.getProductionCount()));
|
|
|
- result.setMonthDeliveryCountTotalAll(add(result.getMonthDeliveryCountTotalAll(), count.getDeliveryCount()));
|
|
|
- });
|
|
|
+ String month = DateUtils.getMonth(end).toString();
|
|
|
+ LiftCount monthCount = monthCountListAll.stream().filter(item -> item.getKey().equals(month))
|
|
|
+ .findFirst().orElse(new LiftCount(month, ZERO, ZERO, ZERO));
|
|
|
+ weekCountStatistics.add(Lists.newArrayList("月合计",
|
|
|
+ MONEY.format(monthCount.getSignCount()), MONEY.format(monthCount.getProductionCount()), MONEY.format(monthCount.getDeliveryCount())));
|
|
|
+
|
|
|
+ List<List<String>> monthCountStatistics = Lists.newArrayList();
|
|
|
+ monthCountStatistics.add(Lists.newArrayList("月份", "签约合计", "排产合计", "发货合计"));
|
|
|
+ monthCountStatistics.addAll(getTotalList(monthCountListAll, "合计"));
|
|
|
+ result.setMonthCountStatisticsTitle(year + "国际月度签约、排产、发货");
|
|
|
+ result.setMonthCountStatistics(monthCountStatistics);
|
|
|
|
|
|
// 3. 全年周(签单、排产、发货)数量统计
|
|
|
List<LiftCount> weekCountListAll = tqContractLiftMapper.countStatisticByWeekAll(year);
|
|
|
- result.setWeekCountListAll(weekCountListAll);
|
|
|
- weekCountListAll.forEach(count -> {
|
|
|
- result.setWeekSignCountTotalAll(add(result.getWeekSignCountTotalAll(), count.getSignCount()));
|
|
|
- result.setWeekProductionCountTotalAll(add(result.getWeekProductionCountTotalAll(), count.getProductionCount()));
|
|
|
- result.setWeekDeliveryCountTotalAll(add(result.getWeekDeliveryCountTotalAll(), count.getDeliveryCount()));
|
|
|
- });
|
|
|
+ List<List<String>> weekCountStatisticsAll = Lists.newArrayList();
|
|
|
+ weekCountStatisticsAll.add(Lists.newArrayList("周", "签约合计", "排产合计", "发货合计"));
|
|
|
+ weekCountStatisticsAll.addAll(getTotalList(weekCountListAll, "合计"));
|
|
|
+ result.setWeekCountStatisticsTitle(year + "国际每周签约、排产、发货数据");
|
|
|
+ result.setWeekCountStatistics(weekCountStatisticsAll);
|
|
|
|
|
|
// 4. 全年各区域签约金额
|
|
|
List<LiftMonthCount> signingAmountAll = tqContractLiftMapper.countSigningStatisticAll(year);
|
|
@@ -547,12 +537,29 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
result.setDeliveryMonthColStatisticsTitle(year + "发货金额");
|
|
|
result.setDeliveryMonthColStatistics(getMonthColList(deliveryAmountAll));
|
|
|
// 7. 全年各区域排产金额
|
|
|
- result.setProductionAreaColStatisticsTitle(year + "排产金额");
|
|
|
+ result.setProductionMonthColStatisticsTitle(year + "排产金额");
|
|
|
result.setProductionMonthColStatistics(getMonthColList(productionAmountAll));
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private static List<List<String>> getTotalList(List<LiftCount> countListAll, String totalTitle) {
|
|
|
+ List<List<String>> result = Lists.newArrayList();
|
|
|
+ BigDecimal signCountTotal = ZERO;
|
|
|
+ BigDecimal productionCountTotal = ZERO;
|
|
|
+ BigDecimal deliveryCountTotal = ZERO;
|
|
|
+ for (LiftCount item : countListAll) {
|
|
|
+ result.add(Lists.newArrayList(item.getKey(),
|
|
|
+ MONEY.format(item.getSignCount()), MONEY.format(item.getProductionCount()), MONEY.format(item.getDeliveryCount())));
|
|
|
+ signCountTotal = add(signCountTotal, item.getSignCount());
|
|
|
+ productionCountTotal = add(productionCountTotal, item.getProductionCount());
|
|
|
+ deliveryCountTotal = add(deliveryCountTotal, item.getDeliveryCount());
|
|
|
+ }
|
|
|
+ result.add(Lists.newArrayList(totalTitle,
|
|
|
+ MONEY.format(signCountTotal), MONEY.format(productionCountTotal), MONEY.format(deliveryCountTotal)));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private List<List<String>> getAreaColList(List<LiftMonthCount> amountAll) {
|
|
|
List<List<String>> result = Lists.newArrayList();
|
|
|
if (CollectionUtils.isEmpty(amountAll)){
|
|
@@ -563,7 +570,7 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
result.add(areaColHeader);
|
|
|
|
|
|
// 底部区域合计行
|
|
|
- List<String> areaSum = Lists.newArrayList("总计");
|
|
|
+ List<String> areaSum = Lists.newArrayList("合计");
|
|
|
amountAll.forEach(item -> {
|
|
|
areaColHeader.add(item.getKey());
|
|
|
// 1. 添加各区域每月的数据
|
|
@@ -575,7 +582,7 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
monthAreaCount = Lists.newArrayList(i + "月");
|
|
|
result.add(monthAreaCount);
|
|
|
}
|
|
|
- BigDecimal current = BigDecimal.ZERO;
|
|
|
+ BigDecimal current = ZERO;
|
|
|
switch (i) {
|
|
|
case 1:
|
|
|
current = item.getJanuary();
|
|
@@ -637,7 +644,7 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
areaColHeader.add("合计");
|
|
|
for (int i = 1; i < result.size(); i++) {
|
|
|
List<String> row = result.get(i);
|
|
|
- BigDecimal total = BigDecimal.ZERO;
|
|
|
+ BigDecimal total = ZERO;
|
|
|
for (int j = 1; j < row.size(); j++) {
|
|
|
total = total.add(new BigDecimal(row.get(j).replaceAll(",", "")));
|
|
|
}
|
|
@@ -661,7 +668,7 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
List<BigDecimal> list = Lists.newArrayList(item.getJanuary(), item.getFebruary(), item.getMarch(), item.getApril(), item.getMay(),
|
|
|
item.getJune(), item.getJuly(), item.getAugust(), item.getSeptember(), item.getOctober(), item.getNovember(),
|
|
|
item.getDecember());
|
|
|
- BigDecimal total = list.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal total = list.stream().reduce(ZERO, BigDecimal::add);
|
|
|
List<String> row = Lists.newArrayList(item.getKey());
|
|
|
list.forEach(amount -> row.add(MONEY.format(amount)));
|
|
|
row.add(MONEY.format(total));
|
|
@@ -702,7 +709,9 @@ public class TqContractServiceImpl implements ITqContractService
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build()) {
|
|
|
-
|
|
|
+ excelWriter.write(contractSigningStatistic.getAreaCountStatistics(), EasyExcel.writerSheet(contractSigningStatistic.getAreaCountStatisticsTitle()).build());
|
|
|
+ excelWriter.write(contractSigningStatistic.getMonthCountStatistics(), EasyExcel.writerSheet(contractSigningStatistic.getMonthCountStatisticsTitle()).build());
|
|
|
+ excelWriter.write(contractSigningStatistic.getWeekCountStatistics(), EasyExcel.writerSheet(contractSigningStatistic.getWeekCountStatisticsTitle()).build());
|
|
|
excelWriter.write(contractSigningStatistic.getSigningAreaColStatistics(), EasyExcel.writerSheet(contractSigningStatistic.getSigningAreaColStatisticsTitle()).build());
|
|
|
excelWriter.write(contractSigningStatistic.getProductionAreaColStatistics(), EasyExcel.writerSheet(contractSigningStatistic.getProductionAreaColStatisticsTitle()).build());
|
|
|
excelWriter.write(contractSigningStatistic.getDeliveryMonthColStatistics(), EasyExcel.writerSheet(contractSigningStatistic.getDeliveryMonthColStatisticsTitle()).build());
|