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