Compare commits
No commits in common. "259dfbb71c657625acabc9c851501eb0fdee5868" and "9aedf14508e2fdbfed4e604a97dc8b5df5548891" have entirely different histories.
259dfbb71c
...
9aedf14508
@ -1,14 +1,12 @@
|
||||
package com.inspur.order.service.impl;
|
||||
|
||||
import com.inspur.common.utils.SecurityUtils;
|
||||
import com.inspur.om.service.IOmTeamInfoService;
|
||||
import com.inspur.order.mapper.OmOrderAnalysisMapper;
|
||||
import com.inspur.order.service.IOmOrderAnalysisService;
|
||||
import com.inspur.order.utils.OmConstant;
|
||||
import org.apache.commons.math3.optim.InitialGuess;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
@ -34,8 +32,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* 订单收藏Service业务层处理
|
||||
@ -48,8 +44,7 @@ public class OmOrderAnalysisServiceImpl implements IOmOrderAnalysisService {
|
||||
|
||||
@Autowired
|
||||
private OmOrderAnalysisMapper omOrderAnalysisMapper;
|
||||
@Autowired
|
||||
private IOmTeamInfoService omTeamInfoService;
|
||||
|
||||
/**
|
||||
* 查询分析数据
|
||||
*
|
||||
@ -71,15 +66,14 @@ public class OmOrderAnalysisServiceImpl implements IOmOrderAnalysisService {
|
||||
|
||||
private Map<String, Object> getDateData() {
|
||||
Map<String, Object> typeOrderMap = new HashMap<>();
|
||||
// 获取当前租户ID和当前日期
|
||||
String tenantId = SecurityUtils.getTenantId();
|
||||
LocalDate now = LocalDate.now();
|
||||
int thisYear = now.getYear();
|
||||
int lastYear = now.minusYears(1).getYear();
|
||||
int theYearBefore = now.minusYears(2).getYear();
|
||||
// 查询数据库
|
||||
List<Map<String, Object>> list = omOrderAnalysisMapper.selectCountAndAmountByDate(tenantId);
|
||||
|
||||
List<Map<String, Object>> list = omOrderAnalysisMapper.selectCountAndAmountByDate(SecurityUtils.getTenantId());
|
||||
// 获取最近三年
|
||||
// 今年
|
||||
int thisYear = LocalDate.now().getYear();
|
||||
// 去年
|
||||
int lastYear = LocalDate.now().minusYears(1).getYear();
|
||||
// 前年
|
||||
int theYearBeafor = LocalDate.now().minusYears(2).getYear();
|
||||
// 初始化数据
|
||||
List<Object> numList1 = new ArrayList<>();
|
||||
List<Object> numList2 = new ArrayList<>();
|
||||
@ -107,7 +101,7 @@ public class OmOrderAnalysisServiceImpl implements IOmOrderAnalysisService {
|
||||
numList2.set(Integer.parseInt(String.valueOf(map.get("date_month"))) - 1, map.get("num"));
|
||||
amountList2.set(Integer.parseInt(String.valueOf(map.get("date_month"))) - 1, map.get("amount"));
|
||||
}
|
||||
if (year == theYearBefore) {
|
||||
if (year == theYearBeafor) {
|
||||
numList3.set(Integer.parseInt(String.valueOf(map.get("date_month"))) - 1, map.get("num"));
|
||||
amountList3.set(Integer.parseInt(String.valueOf(map.get("date_month"))) - 1, map.get("amount"));
|
||||
}
|
||||
@ -116,13 +110,13 @@ public class OmOrderAnalysisServiceImpl implements IOmOrderAnalysisService {
|
||||
Map<String, Object> amountMap = new HashMap<>();
|
||||
numMap.put(thisYear + "", numList1);
|
||||
numMap.put(lastYear + "", numList2);
|
||||
numMap.put(theYearBefore + "", numList3);
|
||||
numMap.put(theYearBeafor + "", numList3);
|
||||
amountMap.put(thisYear + "", amountList1);
|
||||
amountMap.put(lastYear + "", amountList2);
|
||||
amountMap.put(theYearBefore + "", amountList3);
|
||||
amountMap.put(theYearBeafor + "", amountList3);
|
||||
typeOrderMap.put("numMap", numMap);
|
||||
typeOrderMap.put("amountMap", amountMap);
|
||||
typeOrderMap.put("year", new int[]{theYearBefore, lastYear, thisYear});
|
||||
typeOrderMap.put("year", new int[]{theYearBeafor, lastYear, thisYear});
|
||||
typeOrderMap.put("month", OmConstant.MONTH_ARRAY);
|
||||
return typeOrderMap;
|
||||
}
|
||||
@ -148,16 +142,6 @@ public class OmOrderAnalysisServiceImpl implements IOmOrderAnalysisService {
|
||||
XWPFDocument doc = new XWPFDocument();
|
||||
XWPFParagraph p = doc.createParagraph();
|
||||
XWPFRun r = p.createRun();
|
||||
// 设置文字为粗体
|
||||
r.setFontSize(24); // 设置字号
|
||||
r.setColor("000000"); // 设置字体颜色,此处为黑色
|
||||
r.setBold(true); // 设置为粗体
|
||||
// 获取团队名称
|
||||
String teamName = omTeamInfoService.selectOmTeamInfoByTenantId(SecurityUtils.getTenantId()).getTeamName();
|
||||
// 设置文本内容
|
||||
r.setText(teamName+"分析报告");
|
||||
// 设置段落居中
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
// 将BufferedImage转换为字节数组
|
||||
try {
|
||||
ByteArrayOutputStream dateNumChartBaos = new ByteArrayOutputStream();
|
||||
@ -165,15 +149,15 @@ public class OmOrderAnalysisServiceImpl implements IOmOrderAnalysisService {
|
||||
byte[] dateNumChartBytes = dateNumChartBaos.toByteArray();
|
||||
|
||||
ByteArrayOutputStream dateAmountChartBaos = new ByteArrayOutputStream();
|
||||
ImageIO.write(dateAmountChartImage, "png", dateAmountChartBaos);
|
||||
ImageIO.write(dateNumChartImage, "png", dateAmountChartBaos);
|
||||
byte[] dateAmountChartBytes = dateAmountChartBaos.toByteArray();
|
||||
|
||||
ByteArrayOutputStream typeNumChartBaos = new ByteArrayOutputStream();
|
||||
ImageIO.write(typeNumChartImage, "png", typeNumChartBaos);
|
||||
ImageIO.write(dateNumChartImage, "png", typeNumChartBaos);
|
||||
byte[] typeNumChartBytes = typeNumChartBaos.toByteArray();
|
||||
|
||||
ByteArrayOutputStream typeAmountChartBaos = new ByteArrayOutputStream();
|
||||
ImageIO.write(typeAmountChartImage, "png", typeAmountChartBaos);
|
||||
ImageIO.write(dateNumChartImage, "png", typeAmountChartBaos);
|
||||
byte[] typeAmountChartBytes = typeAmountChartBaos.toByteArray();
|
||||
|
||||
r.addPicture(new ByteArrayInputStream(dateNumChartBytes), XWPFDocument.PICTURE_TYPE_PNG, "dateNumChart", Units.toEMU(500), Units.toEMU(500)); // 设置图片大小和位置
|
||||
|
Loading…
Reference in New Issue
Block a user