|
|
@@ -2,16 +2,21 @@ package com.ruoyi.framework.task;
|
|
|
|
|
|
import com.github.stuxuhai.jpinyin.PinyinException;
|
|
|
import com.ruoyi.common.sendEmail.IMailService;
|
|
|
+import com.ruoyi.common.thread.furnance.FurnanceMonthlyMailThread;
|
|
|
import com.ruoyi.common.thread.furnance.FurnancePressureThread;
|
|
|
import com.ruoyi.common.thread.furnance.FurnanceTemperatureThread;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.document.ZipUtil;
|
|
|
+import com.ruoyi.framework.config.RuoYiConfig;
|
|
|
import com.ruoyi.framework.web.controller.BaseController;
|
|
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
|
import com.ruoyi.project.plant.service.ITStaffmgrService;
|
|
|
import com.ruoyi.project.production.controller.TFurnancePressureController;
|
|
|
import com.ruoyi.project.production.controller.TFurnanceTemperatureController;
|
|
|
+import com.ruoyi.project.production.controller.vo.FurnancePressureCoilVO;
|
|
|
import com.ruoyi.project.production.controller.vo.FurnancePressureFvpVO;
|
|
|
+import com.ruoyi.project.production.controller.vo.FurnanceTemperatureCoilVO;
|
|
|
import com.ruoyi.project.production.controller.vo.FurnanceTemperatureVO;
|
|
|
import com.ruoyi.project.production.domain.TFurnancePressure;
|
|
|
import com.ruoyi.project.production.domain.TFurnanceTemperature;
|
|
|
@@ -21,12 +26,40 @@ import com.ruoyi.project.system.domain.SysDictData;
|
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
|
import com.ruoyi.project.system.service.ISysDictTypeService;
|
|
|
import com.ruoyi.project.system.service.ISysUserService;
|
|
|
+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;
|
|
|
+import org.jfree.chart.ChartFactory;
|
|
|
+import org.jfree.chart.ChartUtils;
|
|
|
+import org.jfree.chart.JFreeChart;
|
|
|
+import org.jfree.chart.axis.*;
|
|
|
+import org.jfree.chart.plot.PlotOrientation;
|
|
|
+import org.jfree.chart.plot.XYPlot;
|
|
|
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
|
|
+import org.jfree.chart.title.LegendTitle;
|
|
|
+import org.jfree.chart.title.TextTitle;
|
|
|
+import org.jfree.data.time.Day;
|
|
|
+import org.jfree.data.time.Hour;
|
|
|
+import org.jfree.data.time.TimeSeries;
|
|
|
+import org.jfree.data.time.TimeSeriesCollection;
|
|
|
+import org.jfree.data.xy.XYSeries;
|
|
|
+import org.jfree.data.xy.XYSeriesCollection;
|
|
|
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageMar;
|
|
|
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPageSz;
|
|
|
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr;
|
|
|
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STPageOrientation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.awt.*;
|
|
|
+import java.io.*;
|
|
|
+import java.math.BigInteger;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.*;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -36,6 +69,12 @@ import java.util.List;
|
|
|
@Component("furnanceTask")
|
|
|
public class FurnanceTask extends BaseController {
|
|
|
|
|
|
+ // 全局中文字体(兼容Windows/Linux/Mac,避免中文方块)
|
|
|
+ private static final Font CHINESE_FONT = new Font("宋体", Font.PLAIN, 12);
|
|
|
+
|
|
|
+ // 标题字体(稍大)
|
|
|
+ private static final Font TITLE_FONT = new Font("宋体", Font.BOLD, 16);
|
|
|
+
|
|
|
@Autowired
|
|
|
private ITFurnancePressureService pressureService;
|
|
|
|
|
|
@@ -374,4 +413,391 @@ public class FurnanceTask extends BaseController {
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 每月一号测温/测压趋势图发邮件
|
|
|
+ */
|
|
|
+ public void sendMonthlyEmail() throws ParseException, PinyinException, IOException {
|
|
|
+ // 1. 设置日期范围
|
|
|
+ Date startDate = new Date();//上个月第一天
|
|
|
+ Date endDate = new Date();//上个月最后一天
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(new Date());
|
|
|
+ cal.add(Calendar.MONTH, -1);//上个月
|
|
|
+ cal.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ cal.set(Calendar.MINUTE, 0);
|
|
|
+ cal.set(Calendar.SECOND, 0);
|
|
|
+ cal.set(Calendar.MILLISECOND, 0);
|
|
|
+ cal.set(Calendar.DAY_OF_MONTH, 1);//上个月第一天
|
|
|
+ startDate.setTime(cal.getTimeInMillis());
|
|
|
+ cal.roll(Calendar.DAY_OF_MONTH, -1);//上个月最后一天
|
|
|
+ endDate.setTime(cal.getTimeInMillis());
|
|
|
+ String[] furnaceArray = {"H109", "H110", "H111", "H112", "H113", "H114", "H115", "H116", "H117", "H118", "H130"};// 裂解炉名称列表
|
|
|
+ TFurnanceTemperature temperature = new TFurnanceTemperature();//温度趋势图数据查询方法入参
|
|
|
+ temperature.setStartDate(startDate);
|
|
|
+ temperature.setEndDate(endDate);
|
|
|
+ TFurnancePressure pressure = new TFurnancePressure();//压力趋势图数据查询方法入参
|
|
|
+ pressure.setStartDate(startDate);
|
|
|
+ pressure.setEndDate(endDate);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+ String yearMonth = sdf.format(cal.getTime());//日期yyyy-MM
|
|
|
+ // 2. 生成JFreeChart图表
|
|
|
+ List<JFreeChart> tempChartList = new ArrayList<JFreeChart>();//测温趋势图集合
|
|
|
+ List<JFreeChart> pressureChartList = new ArrayList<JFreeChart>();//测压趋势图集合
|
|
|
+ for (String furnace : furnaceArray) {
|
|
|
+ temperature.setFurnanceName(furnace);
|
|
|
+ pressure.setFurnanceName(furnace);
|
|
|
+ switch (furnace) {//温度/压力趋势图数据查询&生成趋势图
|
|
|
+ case "H109":
|
|
|
+ this.selectTemp109(temperature, tempChartList);
|
|
|
+ this.selectPressure109(pressure, pressureChartList);
|
|
|
+ break;
|
|
|
+ case "H130":
|
|
|
+ this.selectTemp130(temperature, tempChartList);
|
|
|
+ this.selectPressure130(pressure, pressureChartList);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ this.selectTemp11x(temperature, tempChartList);
|
|
|
+ this.selectPressure11x(pressure, pressureChartList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 3. 将JFreeChart图表转换为图片字节数组
|
|
|
+ List<byte[]> tempChartImages = new ArrayList<>();
|
|
|
+ for (JFreeChart chart : tempChartList) {
|
|
|
+ tempChartImages.add(this.convertChartToImage(chart, 600, 400));
|
|
|
+ }
|
|
|
+ List<byte[]> pressureChartImages = new ArrayList<>();
|
|
|
+ for (JFreeChart chart : pressureChartList) {
|
|
|
+ pressureChartImages.add(this.convertChartToImage(chart, 600, 400));
|
|
|
+ }
|
|
|
+ // 4. 新建文件目录
|
|
|
+ String profile = RuoYiConfig.getProfile();
|
|
|
+ String rootPath = profile + "/crackingTrendChart";//保存word文件的目录
|
|
|
+ File file = new File(rootPath);
|
|
|
+ file.mkdirs();
|
|
|
+ String zipPath = profile + "/crackingTrendChartZip";//保存zip文件的目录
|
|
|
+ File fileZip = new File(zipPath);
|
|
|
+ fileZip.mkdirs();
|
|
|
+ // 5. 将JFreeChart插入到word,并保存到刚才创建的word文件目录中
|
|
|
+ String tempFilePath = rootPath + "/裂解炉测温趋势图汇总(" + yearMonth + ").docx";//测温word文件
|
|
|
+ String pressureFilePath = rootPath + "/裂解炉测压趋势图汇总(" + yearMonth + ").docx";//测压word文件
|
|
|
+ this.createWordWithCharts(tempFilePath, tempChartImages, yearMonth);
|
|
|
+ this.createWordWithCharts(pressureFilePath, pressureChartImages, yearMonth);
|
|
|
+ // 6. 将word文件打包成zip,并保存到刚才创建的zip文件目录中
|
|
|
+ String zipName = fileZip + "/" + "裂解炉测温趋势图汇总(" + yearMonth + ").zip";//zip文件
|
|
|
+ ZipUtil.toZipWithDirectory(rootPath, zipName);
|
|
|
+ // 7. 发邮件(带zip附件)
|
|
|
+ List<SysDictData> furnanceRecipientDict = iSysDictTypeService.selectDictDataByType("FURNANCE_RECIPIENT_MONTHLY");//接收人字典
|
|
|
+ for (SysDictData sysDictData : furnanceRecipientDict) {
|
|
|
+ String dictValue = sysDictData.getDictValue();
|
|
|
+ TStaffmgr staffmgr = staffmgrService.selectTStaffmgrByStaffId(dictValue);
|
|
|
+ SysUser sysUser = userService.selectUserByStaffId(dictValue);
|
|
|
+ FurnanceMonthlyMailThread mailThread = new FurnanceMonthlyMailThread(mailService, staffmgr, sysUser.getUserName(), zipName);
|
|
|
+ Thread thread = new Thread(mailThread);
|
|
|
+ thread.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 创建Word并插入多个图表 */
|
|
|
+ private static void createWordWithCharts(String filePath, List<byte[]> chartImages, String yearMonth) {
|
|
|
+ // 新建word对象
|
|
|
+ XWPFDocument document = new XWPFDocument();
|
|
|
+ // 设置A4横版
|
|
|
+ CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
|
|
|
+ CTPageSz pageSz = sectPr.addNewPgSz();
|
|
|
+ pageSz.setW(BigInteger.valueOf(16840)); // A4宽度:21cm×91440 EMU/2.54cm = 16840
|
|
|
+ pageSz.setH(BigInteger.valueOf(11907)); // A4高度:14.85cm×91440 EMU/2.54cm = 11907
|
|
|
+ pageSz.setOrient(STPageOrientation.LANDSCAPE); // 横版
|
|
|
+ // 文档标题
|
|
|
+ XWPFParagraph titlePara = document.createParagraph();
|
|
|
+ titlePara.setAlignment(ParagraphAlignment.CENTER); // 段落居中
|
|
|
+ XWPFRun titleRun = titlePara.createRun();
|
|
|
+ titleRun.setText("裂解炉测温趋势图汇总(" + yearMonth + ")");
|
|
|
+ titleRun.setFontSize(16);
|
|
|
+ titleRun.addBreak();
|
|
|
+ // 遍历插入每个图表
|
|
|
+ for (int i = 0; i < chartImages.size(); i++) {
|
|
|
+ // 图表序号标题
|
|
|
+// XWPFParagraph chartTitlePara = document.createParagraph();
|
|
|
+// XWPFRun chartTitleRun = chartTitlePara.createRun();
|
|
|
+// chartTitleRun.setText("第" + (i + 1) + "个图表");
|
|
|
+// chartTitleRun.addBreak();
|
|
|
+ // 插入图片
|
|
|
+ XWPFParagraph imagePara = document.createParagraph();
|
|
|
+ ByteArrayInputStream bais = new ByteArrayInputStream(chartImages.get(i));
|
|
|
+ XWPFRun imageRun = imagePara.createRun();
|
|
|
+ // 插入时的图片尺寸(宽度600像素,高度400像素,和生成时一致)
|
|
|
+ try {
|
|
|
+ imageRun.addPicture(bais, XWPFDocument.PICTURE_TYPE_PNG, "chart" + i + ".png", Units.toEMU(600), Units.toEMU(400));
|
|
|
+ bais.close();
|
|
|
+ } catch (InvalidFormatException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ // 图表间空行
|
|
|
+// document.createParagraph().createRun().addBreak();
|
|
|
+ }
|
|
|
+ // 保存文档
|
|
|
+ FileOutputStream fos = null;
|
|
|
+ try {
|
|
|
+ fos = new FileOutputStream(filePath);
|
|
|
+ document.write(fos);
|
|
|
+ fos.close();
|
|
|
+ document.close();
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 图表转图片字节数组 */
|
|
|
+ private static byte[] convertChartToImage(JFreeChart chart, int width, int height) throws IOException {
|
|
|
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+ javax.imageio.ImageIO.write(chart.createBufferedImage(width, height), "PNG", baos);
|
|
|
+ byte[] bytes = baos.toByteArray();
|
|
|
+ baos.close();
|
|
|
+ return bytes;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 生成温度趋势图 */
|
|
|
+ private JFreeChart genTempChart(List<FurnanceTemperatureCoilVO> list, String furnanceName, String passNo) throws IOException {
|
|
|
+ // 时间序列
|
|
|
+ TimeSeries series = new TimeSeries(furnanceName + "_Pass" + passNo);
|
|
|
+ for (FurnanceTemperatureCoilVO item : list) {
|
|
|
+ series.addOrUpdate(new Day(item.getRecordTime().getDate(), item.getRecordTime().getMonth()+1, item.getRecordTime().getYear()+1900), item.getPassMaxValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 封装时间序列为数据集
|
|
|
+ TimeSeriesCollection dataset = new TimeSeriesCollection();
|
|
|
+ dataset.addSeries(series);
|
|
|
+
|
|
|
+ // 1. 创建基础时序图
|
|
|
+ JFreeChart chart = ChartFactory.createTimeSeriesChart(
|
|
|
+ "Temperature_" + furnanceName + "_Pass" + passNo, // 图表标题
|
|
|
+ "RecordTime", // X轴标签
|
|
|
+ "PassMaxValue", // Y轴标签
|
|
|
+ dataset, // 数据集
|
|
|
+ true, // 显示图例
|
|
|
+ false, // 关闭工具提示(无GUI无需)
|
|
|
+ false // 关闭URL链接
|
|
|
+ );
|
|
|
+
|
|
|
+ // 2. 优化中文显示:设置图表标题字体
|
|
|
+ TextTitle chartTitle = chart.getTitle();
|
|
|
+ chartTitle.setFont(TITLE_FONT);
|
|
|
+ chartTitle.setPaint(Color.BLACK); // 标题颜色
|
|
|
+
|
|
|
+ // 3. 优化图例中文显示
|
|
|
+ LegendTitle legend = chart.getLegend();
|
|
|
+ legend.setItemFont(CHINESE_FONT); // 图例文字字体
|
|
|
+ legend.setBackgroundPaint(Color.WHITE); // 图例背景(避免透明叠加)
|
|
|
+
|
|
|
+ // 4. 优化绘图区域样式
|
|
|
+ XYPlot plot = chart.getXYPlot();
|
|
|
+ plot.setBackgroundPaint(Color.LIGHT_GRAY);
|
|
|
+ plot.setDomainGridlinePaint(Color.WHITE); // X轴网格线
|
|
|
+ plot.setRangeGridlinePaint(Color.WHITE); // Y轴网格线
|
|
|
+
|
|
|
+ // 5. X轴(日期轴)格式化
|
|
|
+ DateAxis dateAxis = (DateAxis) plot.getDomainAxis();
|
|
|
+ dateAxis.setLocale(Locale.CHINA); // 设置中国地区(避免日期显示英文)
|
|
|
+ // 自定义日期格式(如 "2025-01-01")
|
|
|
+ dateAxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
|
|
|
+ // 调整日期标签旋转角度(-45度,避免重叠)
|
|
|
+// dateAxis.setLabelAngle(-Math.PI / 4);
|
|
|
+ // 设置X轴标签字体(中文支持)
|
|
|
+ dateAxis.setLabelFont(CHINESE_FONT);
|
|
|
+ dateAxis.setTickLabelFont(CHINESE_FONT); // 日期刻度字体
|
|
|
+ // 设置日期轴最小间隔(1天,避免刻度过密)
|
|
|
+ dateAxis.setTickUnit(new org.jfree.chart.axis.DateTickUnit(org.jfree.chart.axis.DateTickUnitType.DAY, 1));
|
|
|
+
|
|
|
+
|
|
|
+ // 6. 优化Y轴(数值轴)中文显示
|
|
|
+ ValueAxis valueAxis = plot.getRangeAxis();
|
|
|
+ valueAxis.setLabelFont(CHINESE_FONT); // Y轴标签字体
|
|
|
+ valueAxis.setTickLabelFont(CHINESE_FONT); // Y轴刻度字体
|
|
|
+
|
|
|
+ // 7. 优化线条和数据点样式
|
|
|
+ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
|
|
|
+ renderer.setSeriesLinesVisible(0, true);
|
|
|
+ renderer.setSeriesShapesVisible(0, true);
|
|
|
+ renderer.setSeriesLinesVisible(1, true);
|
|
|
+ renderer.setSeriesShapesVisible(1, true);
|
|
|
+ // 可选:自定义线条颜色(区分两条序列)
|
|
|
+ renderer.setSeriesPaint(0, Color.RED); // 温度线:红色
|
|
|
+ renderer.setSeriesPaint(1, Color.BLUE); // 湿度线:蓝色
|
|
|
+ plot.setRenderer(renderer);
|
|
|
+
|
|
|
+ // 保存为PNG,参数:文件、图表、宽度、高度
|
|
|
+// ChartUtils.saveChartAsPNG(new File("furnanceAnalysis/Temperature_" + furnanceName + "_Pass" + passNo + ".png"), chart, 800, 600);
|
|
|
+
|
|
|
+ return chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 生成压力趋势图 */
|
|
|
+ private JFreeChart genPressureChart(List<FurnancePressureCoilVO> list, String furnanceName, String passNo) throws IOException {
|
|
|
+ // 时间序列
|
|
|
+ TimeSeries series = new TimeSeries(furnanceName + "_Pass" + passNo);
|
|
|
+ for (FurnancePressureCoilVO item : list) {
|
|
|
+ series.addOrUpdate(new Hour(item.getRecordTime().getHours(), item.getRecordTime().getDate(), item.getRecordTime().getMonth()+1, item.getRecordTime().getYear()+1900), item.getPassMaxValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 封装时间序列为数据集
|
|
|
+ TimeSeriesCollection dataset = new TimeSeriesCollection();
|
|
|
+ dataset.addSeries(series);
|
|
|
+
|
|
|
+ // 1. 创建基础时序图
|
|
|
+ JFreeChart chart = ChartFactory.createTimeSeriesChart(
|
|
|
+ "Pressure_" + furnanceName + "_Pass" + passNo, // 图表标题
|
|
|
+ "RecordTime", // X轴标签
|
|
|
+ "PassMaxValue", // Y轴标签
|
|
|
+ dataset, // 数据集
|
|
|
+ true, // 显示图例
|
|
|
+ false, // 关闭工具提示(无GUI无需)
|
|
|
+ false // 关闭URL链接
|
|
|
+ );
|
|
|
+
|
|
|
+ // 2. 优化中文显示:设置图表标题字体
|
|
|
+ TextTitle chartTitle = chart.getTitle();
|
|
|
+ chartTitle.setFont(TITLE_FONT);
|
|
|
+ chartTitle.setPaint(Color.BLACK); // 标题颜色
|
|
|
+
|
|
|
+ // 3. 优化图例中文显示
|
|
|
+ LegendTitle legend = chart.getLegend();
|
|
|
+ legend.setItemFont(CHINESE_FONT); // 图例文字字体
|
|
|
+ legend.setBackgroundPaint(Color.WHITE); // 图例背景(避免透明叠加)
|
|
|
+
|
|
|
+ // 4. 优化绘图区域样式
|
|
|
+ XYPlot plot = chart.getXYPlot();
|
|
|
+ plot.setBackgroundPaint(Color.LIGHT_GRAY);
|
|
|
+ plot.setDomainGridlinePaint(Color.WHITE); // X轴网格线
|
|
|
+ plot.setRangeGridlinePaint(Color.WHITE); // Y轴网格线
|
|
|
+
|
|
|
+ // 5. X轴(日期轴)格式化
|
|
|
+ DateAxis dateAxis = (DateAxis) plot.getDomainAxis();
|
|
|
+ dateAxis.setLocale(Locale.CHINA); // 设置中国地区(避免日期显示英文)
|
|
|
+ // 自定义日期格式(如 "2025-01-01")
|
|
|
+ dateAxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd-HH"));
|
|
|
+ // 调整日期标签旋转角度(-45度,避免重叠)
|
|
|
+// dateAxis.setLabelAngle(-Math.PI / 4);
|
|
|
+ // 设置X轴标签字体(中文支持)
|
|
|
+ dateAxis.setLabelFont(CHINESE_FONT);
|
|
|
+ dateAxis.setTickLabelFont(CHINESE_FONT); // 日期刻度字体
|
|
|
+ // 设置日期轴最小间隔(1天,避免刻度过密)
|
|
|
+ dateAxis.setTickUnit(new org.jfree.chart.axis.DateTickUnit(org.jfree.chart.axis.DateTickUnitType.DAY, 1));
|
|
|
+
|
|
|
+ // 6. 优化Y轴(数值轴)中文显示
|
|
|
+ ValueAxis valueAxis = plot.getRangeAxis();
|
|
|
+ valueAxis.setLabelFont(CHINESE_FONT); // Y轴标签字体
|
|
|
+ valueAxis.setTickLabelFont(CHINESE_FONT); // Y轴刻度字体
|
|
|
+
|
|
|
+ // 7. 优化线条和数据点样式
|
|
|
+ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
|
|
|
+ renderer.setSeriesLinesVisible(0, true);
|
|
|
+ renderer.setSeriesShapesVisible(0, true);
|
|
|
+ renderer.setSeriesLinesVisible(1, true);
|
|
|
+ renderer.setSeriesShapesVisible(1, true);
|
|
|
+ // 可选:自定义线条颜色(区分两条序列)
|
|
|
+ renderer.setSeriesPaint(0, Color.RED); // 温度线:红色
|
|
|
+ renderer.setSeriesPaint(1, Color.BLUE); // 湿度线:蓝色
|
|
|
+ plot.setRenderer(renderer);
|
|
|
+
|
|
|
+ // 保存为PNG,参数:文件、图表、宽度、高度
|
|
|
+// ChartUtils.saveChartAsPNG(new File("furnanceAnalysis/Pressure_" + furnanceName + "_Pass" + passNo + ".png"), chart, 800, 600);
|
|
|
+
|
|
|
+ return chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 温度趋势图数据查询(H109) */
|
|
|
+ private void selectTemp109(TFurnanceTemperature temperature, List<JFreeChart> chartList) throws IOException {
|
|
|
+ logger.info("开始执行温度趋势图数据查询(H109)接口,入参: temperature={}", temperature.toString());
|
|
|
+ String[] passNoArray = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"};
|
|
|
+ for (String passNo : passNoArray) {
|
|
|
+ temperature.setPassNo(passNo);
|
|
|
+ AjaxResult ajaxResult = temperatureService.coilAnalysis(temperature);
|
|
|
+ List<FurnanceTemperatureCoilVO> coilVoList = (List<FurnanceTemperatureCoilVO>)ajaxResult.get("data");
|
|
|
+ // 生成趋势图
|
|
|
+ JFreeChart chart = this.genTempChart(coilVoList, temperature.getFurnanceName(), passNo);
|
|
|
+ chartList.add(chart);
|
|
|
+ logger.info(temperature.getFurnanceName()+" pass"+passNo+" 查询到数据条数:"+coilVoList.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 温度趋势图数据查询(H130) */
|
|
|
+ private void selectTemp130(TFurnanceTemperature temperature, List<JFreeChart> chartList) throws IOException {
|
|
|
+ logger.info("开始执行温度趋势图数据查询(H130)接口,入参: temperature={}", temperature.toString());
|
|
|
+ String[] passNoArray = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
|
|
|
+ for (String passNo : passNoArray) {
|
|
|
+ temperature.setPassNo(passNo);
|
|
|
+ AjaxResult ajaxResult = temperatureService.coilAnalysis(temperature);
|
|
|
+ List<FurnanceTemperatureCoilVO> coilVoList = (List<FurnanceTemperatureCoilVO>)ajaxResult.get("data");
|
|
|
+ // 生成趋势图
|
|
|
+ JFreeChart chart = this.genTempChart(coilVoList, temperature.getFurnanceName(), passNo);
|
|
|
+ chartList.add(chart);
|
|
|
+ logger.info(temperature.getFurnanceName()+" pass"+passNo+" 查询到数据条数:"+coilVoList.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 温度趋势图数据查询(H11x) */
|
|
|
+ private void selectTemp11x(TFurnanceTemperature temperature, List<JFreeChart> chartList) throws IOException {
|
|
|
+ logger.info("开始执行温度趋势图数据查询(H11x)接口,入参: temperature={}", temperature.toString());
|
|
|
+ String[] passNoArray = {"1", "2", "3", "4", "5", "6", "7", "8"};
|
|
|
+ for (String passNo : passNoArray) {
|
|
|
+ temperature.setPassNo(passNo);
|
|
|
+ AjaxResult ajaxResult = temperatureService.coilAnalysis(temperature);
|
|
|
+ List<FurnanceTemperatureCoilVO> coilVoList = (List<FurnanceTemperatureCoilVO>)ajaxResult.get("data");
|
|
|
+ // 生成趋势图
|
|
|
+ JFreeChart chart = this.genTempChart(coilVoList, temperature.getFurnanceName(), passNo);
|
|
|
+ chartList.add(chart);
|
|
|
+ logger.info(temperature.getFurnanceName()+" pass"+passNo+" 查询到数据条数:"+coilVoList.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 压力趋势图数据查询(H109) */
|
|
|
+ private void selectPressure109(TFurnancePressure pressure, List<JFreeChart> chartList) throws IOException {
|
|
|
+ logger.info("开始执行压力趋势图数据查询(H109)接口,入参: temperature={}", pressure.toString());
|
|
|
+ String[] passNoArray = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"};
|
|
|
+ for (String passNo : passNoArray) {
|
|
|
+ pressure.setPassNo(passNo);
|
|
|
+ AjaxResult ajaxResult = pressureService.coilAnalysis(pressure);
|
|
|
+ List<FurnancePressureCoilVO> coilVoList = (List<FurnancePressureCoilVO>)ajaxResult.get("data");
|
|
|
+ // 生成趋势图
|
|
|
+ JFreeChart chart = this.genPressureChart(coilVoList, pressure.getFurnanceName(), passNo);
|
|
|
+ chartList.add(chart);
|
|
|
+ logger.info(pressure.getFurnanceName()+" pass"+passNo+" 查询到数据条数:"+coilVoList.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 压力趋势图数据查询(H130) */
|
|
|
+ private void selectPressure130(TFurnancePressure pressure, List<JFreeChart> chartList) throws IOException {
|
|
|
+ logger.info("开始执行压力趋势图数据查询(H130)接口,入参: temperature={}", pressure.toString());
|
|
|
+ String[] passNoArray = {"1", "2", "3", "4"};
|
|
|
+ for (String passNo : passNoArray) {
|
|
|
+ pressure.setPassNo(passNo);
|
|
|
+ AjaxResult ajaxResult = pressureService.coilAnalysis(pressure);
|
|
|
+ List<FurnancePressureCoilVO> coilVoList = (List<FurnancePressureCoilVO>)ajaxResult.get("data");
|
|
|
+ // 生成趋势图
|
|
|
+ JFreeChart chart = this.genPressureChart(coilVoList, pressure.getFurnanceName(), passNo);
|
|
|
+ chartList.add(chart);
|
|
|
+ logger.info(pressure.getFurnanceName()+" pass"+passNo+" 查询到数据条数:"+coilVoList.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 压力趋势图数据查询(H11x) */
|
|
|
+ private void selectPressure11x(TFurnancePressure pressure, List<JFreeChart> chartList) throws IOException {
|
|
|
+ logger.info("开始执行压力趋势图数据查询(H11x)接口,入参: temperature={}", pressure.toString());
|
|
|
+ String[] passNoArray = {"1", "2", "3", "4", "5", "6", "7", "8"};
|
|
|
+ for (String passNo : passNoArray) {
|
|
|
+ pressure.setPassNo(passNo);
|
|
|
+ AjaxResult ajaxResult = pressureService.coilAnalysis(pressure);
|
|
|
+ List<FurnancePressureCoilVO> coilVoList = (List<FurnancePressureCoilVO>)ajaxResult.get("data");
|
|
|
+ // 生成趋势图
|
|
|
+ JFreeChart chart = this.genPressureChart(coilVoList, pressure.getFurnanceName(), passNo);
|
|
|
+ chartList.add(chart);
|
|
|
+ logger.info(pressure.getFurnanceName()+" pass"+passNo+" 查询到数据条数:"+coilVoList.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|