Эх сурвалжийг харах

王子文 生产月报 Cracker Raw Material 趋势分析

wangggziwen 2 жил өмнө
parent
commit
88198e5c07

+ 47 - 15
master/src/main/java/com/ruoyi/project/production/service/impl/TMonthlyProductionReportServiceImpl.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.production.service.impl;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 import com.alibaba.druid.sql.ast.statement.SQLForeignKeyImpl;
@@ -14,6 +15,8 @@ import com.ruoyi.project.production.mapper.TMonthlyProductionReportMapper;
 import com.ruoyi.project.production.domain.TMonthlyProductionReport;
 import com.ruoyi.project.production.service.ITMonthlyProductionReportService;
 
+import javax.sound.midi.Soundbank;
+
 /**
  * 每月生产报告Service业务层处理
  *
@@ -100,11 +103,17 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
 
     @Override
     public List<CrackerRawMaterialVO> selectCrackerRawMaterialByYear(Long year) {
+        // 当前日期
+        Date currentDate = new Date();
+        // 当前年份
+        Long currentYear = Long.parseLong(currentDate.getYear() + 1900 + "");
+        // 当前月份
+        Long currentMonth = Long.parseLong(currentDate.getMonth() + 1 + "");
         // 从数据库中查出的当前year的月报数据集合,每个元素对应当前year某个月的数据
         List<TMonthlyProductionReport> tMonthlyProductionReports = tMonthlyProductionReportMapper.selectCrackerRawMaterialByYear(year);
         // 前端月报数据集合,每个元素对应当前某个指标的title、unit、1~12月的数据以及年度汇总数据
         List<CrackerRawMaterialVO> crackerRawMaterialVOs = new ArrayList<>();
-        crackerRawMaterialVOs.add(new CrackerRawMaterialVO("Cracker Raw Material", ""));
+        crackerRawMaterialVOs.add(new CrackerRawMaterialVO("Cracker Raw Material", "t"));
         crackerRawMaterialVOs.add(new CrackerRawMaterialVO("NAP", "t"));
         crackerRawMaterialVOs.add(new CrackerRawMaterialVO("C5", "t"));
         crackerRawMaterialVOs.add(new CrackerRawMaterialVO("NA", "t"));
@@ -120,7 +129,7 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
         crackerRawMaterialVOs.add(new CrackerRawMaterialVO("toluene", "t"));
         crackerRawMaterialVOs.add(new CrackerRawMaterialVO("C4 Recycle(ton)", "t"));
         crackerRawMaterialVOs.add(new CrackerRawMaterialVO("input total", "t"));
-        crackerRawMaterialVOs.add(new CrackerRawMaterialVO("Total feed", ""));
+        crackerRawMaterialVOs.add(new CrackerRawMaterialVO("Total feed", "t"));
         // 遍历从数据库中查出的月报数据集合,结果为0~12条数据不等
         for (int i = 0; i < tMonthlyProductionReports.size(); i++) {
             TMonthlyProductionReport tMonthlyProductionReport = tMonthlyProductionReports.get(i);
@@ -141,13 +150,17 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
             String hyC4FrR800 = tMonthlyProductionReport.getHyC4FrR800();
             String crackerRawInput = tMonthlyProductionReport.getCrackerRawInput();
             String crackerRawFeed = tMonthlyProductionReport.getCrackerRawFeed();
+            Long raff3FrBdAndRaffinate2pFr2ph = Long.parseLong(raff3FrBd) + Long.parseLong(raffinate2pFr2ph);
+            String raff3FrBdAndRaffinate2pFr2phStr = raff3FrBdAndRaffinate2pFr2ph.toString();
             // 前端数据集合的class
             Class clazz = null;
             // 当前元素调用的set方法
             Method method = null;
             try {
+                Long reportMonth = tMonthlyProductionReport.getReportMonth();   // 当前元素的所属月份
+                Long reportYear = tMonthlyProductionReport.getReportYear();     // 当前元素的所属年份
                 clazz = Class.forName("com.ruoyi.project.production.service.impl.vo.CrackerRawMaterialVO");
-                switch (tMonthlyProductionReport.getReportMonth().toString()) { // 当前元素的所属月份
+                switch (reportMonth.toString()) {
                     case "1":   // 一月
                         method = clazz.getDeclaredMethod("setJan", String.class);
                         break;
@@ -192,18 +205,37 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 method.invoke(crackerRawMaterialVOs.get(3), c6C8Na);
                 method.invoke(crackerRawMaterialVOs.get(4), wisonEthane);
                 method.invoke(crackerRawMaterialVOs.get(5), lpgToFurnace);
-                method.invoke(crackerRawMaterialVOs.get(6), raff3FrBd);
-                method.invoke(crackerRawMaterialVOs.get(7), raffinate2pFr2ph);
-                method.invoke(crackerRawMaterialVOs.get(8), c2FrLdpe);
-                method.invoke(crackerRawMaterialVOs.get(9), c3FrOxo);
-                method.invoke(crackerRawMaterialVOs.get(10), mixedC3C4);
-                method.invoke(crackerRawMaterialVOs.get(11), hyC9);
-                method.invoke(crackerRawMaterialVOs.get(12), pguOffgas);
-                method.invoke(crackerRawMaterialVOs.get(13), washOil);
-                method.invoke(crackerRawMaterialVOs.get(14), toluene);
-                method.invoke(crackerRawMaterialVOs.get(15), hyC4FrR800);
-                method.invoke(crackerRawMaterialVOs.get(16), crackerRawInput);
-                method.invoke(crackerRawMaterialVOs.get(17), crackerRawFeed);
+                method.invoke(crackerRawMaterialVOs.get(6), raff3FrBdAndRaffinate2pFr2phStr);
+                method.invoke(crackerRawMaterialVOs.get(7), c2FrLdpe);
+                method.invoke(crackerRawMaterialVOs.get(8), c3FrOxo);
+                method.invoke(crackerRawMaterialVOs.get(9), mixedC3C4);
+                method.invoke(crackerRawMaterialVOs.get(10), hyC9);
+                method.invoke(crackerRawMaterialVOs.get(11), pguOffgas);
+                method.invoke(crackerRawMaterialVOs.get(12), washOil);
+                method.invoke(crackerRawMaterialVOs.get(13), toluene);
+                method.invoke(crackerRawMaterialVOs.get(14), hyC4FrR800);
+                method.invoke(crackerRawMaterialVOs.get(15), crackerRawInput);
+                method.invoke(crackerRawMaterialVOs.get(16), crackerRawFeed);
+                // 当前年份=所属年份,当前月份=所属月份
+                if (currentMonth.equals(reportMonth) && currentYear.equals(reportYear)) {
+                    crackerRawMaterialVOs.get(0).setCurrently(crackerRawInput);
+                    crackerRawMaterialVOs.get(1).setCurrently(nap);
+                    crackerRawMaterialVOs.get(2).setCurrently(c5);
+                    crackerRawMaterialVOs.get(3).setCurrently(c6C8Na);
+                    crackerRawMaterialVOs.get(4).setCurrently(wisonEthane);
+                    crackerRawMaterialVOs.get(5).setCurrently(lpgToFurnace);
+                    crackerRawMaterialVOs.get(6).setCurrently(raff3FrBdAndRaffinate2pFr2phStr);
+                    crackerRawMaterialVOs.get(7).setCurrently(c2FrLdpe);
+                    crackerRawMaterialVOs.get(8).setCurrently(c3FrOxo);
+                    crackerRawMaterialVOs.get(9).setCurrently(mixedC3C4);
+                    crackerRawMaterialVOs.get(10).setCurrently(hyC9);
+                    crackerRawMaterialVOs.get(11).setCurrently(pguOffgas);
+                    crackerRawMaterialVOs.get(12).setCurrently(washOil);
+                    crackerRawMaterialVOs.get(13).setCurrently(toluene);
+                    crackerRawMaterialVOs.get(14).setCurrently(hyC4FrR800);
+                    crackerRawMaterialVOs.get(15).setCurrently(crackerRawInput);
+                    crackerRawMaterialVOs.get(16).setCurrently(crackerRawFeed);
+                }
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 21 - 21
master/src/main/resources/mybatis/production/TMonthlyProductionReportMapper.xml

@@ -5,27 +5,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.project.production.mapper.TMonthlyProductionReportMapper">
     
     <resultMap type="TMonthlyProductionReport" id="TMonthlyProductionReportResult">
-        <result property="id"    column="id"    />
-        <result property="reportMonth"    column="report_month"    />
-        <result property="reportYear"    column="report_year"    />
-        <result property="nap"    column="nap"    />
-        <result property="c5"    column="c5"    />
-        <result property="c6C8Na"    column="c6_c8_na"    />
-        <result property="wisonEthane"    column="wison_ethane"    />
-        <result property="lpgToFurnace"    column="lpg_to_furnace"    />
-        <result property="raff3FrBd"    column="raff3_fr_bd"    />
-        <result property="raffinate2pFr2ph"    column="raffinate2p_fr_2ph"    />
-        <result property="c2FrLdpe"    column="c2_fr_ldpe"    />
-        <result property="c3FrOxo"    column="c3_fr_oxo"    />
-        <result property="mixedC3C4"    column="mixed_c3_c4"    />
-        <result property="hyC9"    column="hy_c9"    />
-        <result property="pguOffgas"    column="pgu_offgas"    />
-        <result property="washOil"    column="wash_oil"    />
-        <result property="toluene"    column="toluene"    />
-        <result property="hyC4FrR800"    column="hy_c4_fr_r800"    />
-        <result property="crackerRawInput"    column="cracker_raw_input"    />
-        <result property="crackerRawFeed"    column="cracker_raw_feed"    />
-        <result property="deptName" column="dept_name" />
+        <result property="id"                   column="id"    />
+        <result property="reportMonth"          column="report_month"    />
+        <result property="reportYear"           column="report_year"    />
+        <result property="nap"                  column="nap"    />
+        <result property="c5"                   column="c5"    />
+        <result property="c6C8Na"               column="c6_c8_na"    />
+        <result property="wisonEthane"          column="wison_ethane"    />
+        <result property="lpgToFurnace"         column="lpg_to_furnace"    />
+        <result property="raff3FrBd"            column="raff3_fr_bd"    />
+        <result property="raffinate2pFr2ph"     column="raffinate2p_fr_2ph"    />
+        <result property="c2FrLdpe"             column="c2_fr_ldpe"    />
+        <result property="c3FrOxo"              column="c3_fr_oxo"    />
+        <result property="mixedC3C4"            column="mixed_c3_c4"    />
+        <result property="hyC9"                 column="hy_c9"    />
+        <result property="pguOffgas"            column="pgu_offgas"    />
+        <result property="washOil"              column="wash_oil"    />
+        <result property="toluene"              column="toluene"    />
+        <result property="hyC4FrR800"           column="hy_c4_fr_r800"    />
+        <result property="crackerRawInput"      column="cracker_raw_input"    />
+        <result property="crackerRawFeed"       column="cracker_raw_feed"    />
+        <result property="deptName"             column="dept_name" />
     </resultMap>
 
     <sql id="selectTMonthlyProductionReportVo">

+ 150 - 21
ui/src/views/production/monthly/index.vue

@@ -24,7 +24,11 @@
     </el-form>
     <el-table border :data="tableCrackerRawMaterial" style="width: 100%;">
       <el-table-column label="Cracker Raw Material">
-        <el-table-column prop="title" label=""></el-table-column>
+        <el-table-column width="150" prop="title" label="">
+          <template slot-scope="scope">
+            <div @click="columnOnclick(scope.row)">{{scope.row.title}}</div>
+          </template>
+        </el-table-column>
         <el-table-column prop="unit" label="unit"></el-table-column>
         <el-table-column prop="currently" label="currently"></el-table-column>
         <el-table-column prop="jan" :label="this.monthList[0]"></el-table-column>
@@ -440,6 +444,26 @@
         <el-table-column prop="total" label="total"></el-table-column>
       </el-table-column>
     </el-table>
+    <!-- 趋势分析对话框 -->
+    <el-dialog @close="disposeChart" :title="analysis.title" :visible.sync="analysis.open" width="1400px" append-to-body>
+      <el-form :model="analysisQueryParams" ref="queryForm" :inline="true" label-width="68px">
+        <el-form-item label="开始时间" prop="startDate">
+          <el-date-picker
+            v-model="analysisDialogElement.startDate"
+            type="month"
+            placeholder="选择开始时间">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="结束时间" prop="endDate">
+          <el-date-picker
+            v-model="analysisDialogElement.endDate"
+            type="month"
+            placeholder="选择结束时间">
+          </el-date-picker>
+        </el-form-item>
+      </el-form>
+      <div id="trendChart" style="width:1340px;height:600px;"></div>
+    </el-dialog>
   </div>
 </template>
 
@@ -452,30 +476,48 @@ export default {
   name: "Monthly",
   data() {
     return {
+      // 趋势图y轴数值
+      valueList: [],
+      // 趋势图x轴日期
+      dateList: [],
+      // y轴最大值
+      maxValue: null,
+      // y轴最小值
+      minValue: null,
+      // 趋势图
+      chart: null,
+      // 趋势分析参数
+      analysis: {
+        // 是否显示弹出层
+        open: false,
+        // 弹出层标题
+        title: "",
+      },
+      // 趋势图查询参数
+      analysisQueryParams: {
+        // 指标
+        title: null,
+        // 截止年份
+        toYear: 0,
+        // 截止月份
+        toMonth: 0,
+        // 开始年份
+        fromTear: 0,
+        // 开始月份
+        fromMonth: 0,
+      },
+      // 对话框控件值
+      analysisDialogElement: {
+        // 开始时间
+        startDate: null,
+        // 结束时间
+        endDate: null,
+      },
       // 年份
       year: null,
       // 月份的固定表示
       monthList: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
-      tableCrackerRawMaterial:[],
-      // [
-      //   {title: "Cracker Raw Material"},
-      //   {title: "NAP"},
-      //   {title: "C5"},
-      //   {title: "NA"},
-      //   {title: "Wison Ethane"},
-      //   {title: "LPG to Furnace"},
-      //   {title: "C4 Raff3  fr bd and 2ph"},
-      //   {title: "C2 fr LDPE"},
-      //   {title: "C3 fr OXO"},
-      //   {title: "Mixed C3/C4 fr BD"},
-      //   {title: "HC9"},
-      //   {title: "Offgas fr AEU"},
-      //   {title: "wash oil"},
-      //   {title: "toluene"},
-      //   {title: "C4 Recycle(ton)"},
-      //   {title: "input total"},
-      //   {title: "Total feed"},
-      // ],
+      tableCrackerRawMaterial: [],
       tableCrackerOutputProduct: [
         {title: "Cracker Output Product"},
         {title: "H2"},
@@ -777,6 +819,93 @@ export default {
     this.getMonthlyReport();
   },
   methods: {
+    /** 销毁趋势图 */
+    disposeChart() {
+      this.echarts.dispose(this.chart);
+    },
+    /** 处理最左列指标点击事件 */
+    columnOnclick(row) {
+      let title = row.title;
+      let toYear = this.year.getFullYear();
+      let toMonth = this.year.getMonth() + 1;
+      let fromTear = toYear - 1;
+      let fromMonth = toMonth;
+      this.analysisQueryParams.toYear = toYear;
+      this.analysisQueryParams.toMonth = toMonth;
+      this.analysisQueryParams.fromTear = fromTear;
+      this.analysisQueryParams.fromMonth = fromMonth;
+      let startDate = new Date();
+      let endDate = new Date();
+      startDate.setFullYear(startDate.getFullYear() - 1);
+      this.analysisDialogElement.startDate = startDate;
+      this.analysisDialogElement.endDate = endDate;
+      this.analysis.title = row.title + "趋势分析";
+      this.analysis.open = true;
+      // this.draw();
+    },
+    /** 绘制趋势图 */
+    draw() {
+      查询方法(this.analysisQueryParams).then(response => {
+        let data = response.data;
+        this.maxValue = 0;
+        this.minValue = data[0].valueData;
+        for (let i = 0; i < data.length; i++) {
+          if (data[i].valueData != null) {
+            this.valueList[i] = data[i].valueData;
+            this.dateList[i] = data[i].dateData;
+            if (data[i].valueData > this.maxValue) {
+              this.maxValue = data[i].valueData;
+            }
+            if (data[i].valueData < this.minValue) {
+              this.minValue = data[i].valueData;
+            }
+          }
+        }
+        this.chart = this.echarts.init(document.getElementById("trendChart"));
+        let option = {
+          tooltip: {
+            trigger: "item"
+          },
+          grid: {
+            left: 90,
+            right: 80,
+          },
+          xAxis: {
+            data: this.dateList,
+          },
+          yAxis: {
+            max: this.maxValue,
+            min: this.minValue,
+            min: function(value) {  // 取最小值向下取整为最小刻度
+              return Math.floor(value.min)
+            },
+            max: function(value) {  // 取最大值向上取整为最大刻度
+              return  Math.ceil(value.max)
+            },
+            scale: true,
+            type: 'value',
+          },
+          series: [
+            {
+              name: this.fieldNameTitle,
+              label: {
+                show: true,
+                position: 'top'
+              },
+              data: this.valueList,
+              type: 'line',
+              smooth: true,
+              symbolSize: 15,
+              color:"#5470c6",
+              lineStyle: {
+                width: 6
+              }
+            }
+          ],
+        };
+        this.chart.setOption(option);
+      });
+    },
     /** 设置表头 */
     setTableTitle() {
       // 拼接年份后的数组