Browse Source

质量月报 - 裂解炉进料原料质量近一年油品变化曲线

wangggziwen 1 year ago
parent
commit
b659822eda

+ 36 - 0
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyQualityReportS0501Controller.java

@@ -1,6 +1,10 @@
 package com.ruoyi.project.production.controller;
 
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -33,6 +37,38 @@ public class TMonthlyQualityReportS0501Controller extends BaseController
     @Autowired
     private ITMonthlyQualityReportS0501Service tMonthlyQualityReportS0501Service;
 
+    /**
+     * 查询质量月报S0501列表
+     */
+    @PreAuthorize("@ss.hasPermi('production:quality:list')")
+    @GetMapping("/listMonth")
+    public AjaxResult listMonth(TMonthlyQualityReportS0501 tMonthlyQualityReportS0501)
+    {
+        Date startDate = tMonthlyQualityReportS0501.getStartDate();
+        Date endDate = tMonthlyQualityReportS0501.getEndDate();
+        int startYear = startDate.getYear() + 1900;
+        int endYear = endDate.getYear() + 1900;
+        int startMonth = startDate.getMonth() + 1;
+        int endMonth = endDate.getMonth() + 1;
+        Map<String, TMonthlyQualityReportS0501> dataMap = new HashMap<>();
+        do {
+            TMonthlyQualityReportS0501 reportS0501 = new TMonthlyQualityReportS0501();
+            reportS0501.setMonth(startMonth);
+            reportS0501.setYear(startYear);
+            TMonthlyQualityReportS0501 reportS05011 = tMonthlyQualityReportS0501Service.selectTMonthlyQualityReportS0501ListMonth(reportS0501);
+            if (reportS05011 != null) {
+                dataMap.put(startYear + "-" + startMonth, reportS05011);
+            }
+            if (startMonth == 12) {
+                startMonth = 1;
+                startYear++;
+            } else {
+                startMonth++;
+            }
+        } while (startYear != endYear || startMonth != endMonth + 1);
+        return AjaxResult.success(dataMap);
+    }
+
     /**
      * 查询质量月报S0501列表
      */

+ 20 - 0
master/src/main/java/com/ruoyi/project/production/domain/TMonthlyQualityReportS0501.java

@@ -122,6 +122,26 @@ public class TMonthlyQualityReportS0501 extends BaseEntity
 
     private String deptName;
 
+    private int month;
+
+    private int year;
+
+    public int getMonth() {
+        return month;
+    }
+
+    public void setMonth(int month) {
+        this.month = month;
+    }
+
+    public int getYear() {
+        return year;
+    }
+
+    public void setYear(int year) {
+        this.year = year;
+    }
+
     public String getDeptName() {
         return deptName;
     }

+ 2 - 0
master/src/main/java/com/ruoyi/project/production/mapper/TMonthlyQualityReportS0501Mapper.java

@@ -12,6 +12,8 @@ import com.ruoyi.project.production.domain.TMonthlyQualityReportS0501;
  */
 public interface TMonthlyQualityReportS0501Mapper 
 {
+    public TMonthlyQualityReportS0501 selectTMonthlyQualityReportS0501ListMonth(TMonthlyQualityReportS0501 tMonthlyQualityReportS0501);
+
     /**
      * 查询质量月报S0501
      * 

+ 2 - 0
master/src/main/java/com/ruoyi/project/production/service/ITMonthlyQualityReportS0501Service.java

@@ -11,6 +11,8 @@ import com.ruoyi.project.production.domain.TMonthlyQualityReportS0501;
  */
 public interface ITMonthlyQualityReportS0501Service 
 {
+    public TMonthlyQualityReportS0501 selectTMonthlyQualityReportS0501ListMonth(TMonthlyQualityReportS0501 tMonthlyQualityReportS0501);
+
     /**
      * 查询质量月报S0501
      * 

+ 5 - 0
master/src/main/java/com/ruoyi/project/production/service/impl/TMonthlyQualityReportS0501ServiceImpl.java

@@ -20,6 +20,11 @@ public class TMonthlyQualityReportS0501ServiceImpl implements ITMonthlyQualityRe
     @Autowired
     private TMonthlyQualityReportS0501Mapper tMonthlyQualityReportS0501Mapper;
 
+    @Override
+    public TMonthlyQualityReportS0501 selectTMonthlyQualityReportS0501ListMonth(TMonthlyQualityReportS0501 tMonthlyQualityReportS0501) {
+        return tMonthlyQualityReportS0501Mapper.selectTMonthlyQualityReportS0501ListMonth(tMonthlyQualityReportS0501);
+    }
+
     /**
      * 查询质量月报S0501
      *

+ 19 - 0
master/src/main/resources/mybatis/production/TMonthlyQualityReportS0501Mapper.xml

@@ -36,6 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="deptName" column="dept_name" />
         <result property="startDate" column="start_date" />
         <result property="endDate" column="end_date" />
+        <result property="month" column="month" />
+        <result property="year" column="year" />
     </resultMap>
 
     <sql id="selectTMonthlyQualityReportS0501Vo">
@@ -43,6 +45,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       left join sys_dept s on s.dept_id = d.dept_id
     </sql>
 
+    <select id="selectTMonthlyQualityReportS0501ListMonth" parameterType="TMonthlyQualityReportS0501" resultMap="TMonthlyQualityReportS0501Result">
+        select sum(translate(p, '0' || translate(p, '#.0123456789', '#'), '0')) as p,
+            sum(translate(i, '0' || translate(i, '#.0123456789', '#'), '0')) as i,
+            sum(translate(o, '0' || translate(o, '#.0123456789', '#'), '0')) as o,
+            sum(translate(n, '0' || translate(n, '#.0123456789', '#'), '0')) as n,
+            sum(translate(fifty, '0' || translate(fifty, '#.0123456789', '#'), '0')) as fifty
+        from t_monthly_quality_report_s0501 d
+        left join sys_dept s on s.dept_id = d.dept_id
+        <where>
+            <if test="month != null "> and extract(month from sample_date) = #{month}</if>
+            <if test="year != null "> and extract(year from sample_date) = #{year}</if>
+            and d.del_flag = 0
+        </where>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+    </select>
+
     <select id="selectTMonthlyQualityReportS0501List" parameterType="TMonthlyQualityReportS0501" resultMap="TMonthlyQualityReportS0501Result">
         <include refid="selectTMonthlyQualityReportS0501Vo"/>
         <where>

+ 10 - 1
ui/src/api/production/s0501.js

@@ -1,5 +1,14 @@
 import request from '@/utils/request'
 
+// 查询质量月报S0501列表
+export function listS0501Month(query) {
+  return request({
+    url: '/production/s0501/listMonth',
+    method: 'get',
+    params: query
+  })
+}
+
 // 查询质量月报S0501列表
 export function listS0501(query) {
   return request({
@@ -50,4 +59,4 @@ export function exportS0501(query) {
     method: 'get',
     params: query
   })
-}
+}

+ 78 - 5
ui/src/views/production/quality/index.vue

@@ -2194,7 +2194,7 @@
 </template>
 
 <script>
-import { listS0501, getS0501, delS0501, addS0501, updateS0501, exportS0501 } from "@/api/production/s0501";
+import { listS0501, listS0501Month, getS0501, delS0501, addS0501, updateS0501, exportS0501 } from "@/api/production/s0501";
 import { listS1301, getS1301, delS1301, addS1301, updateS1301, exportS1301 } from "@/api/production/s1301";
 import { listS2002, getS2002, delS2002, addS2002, updateS2002, exportS2002 } from "@/api/production/s2002";
 import { listS2005, getS2005, delS2005, addS2005, updateS2005, exportS2005 } from "@/api/production/s2005";
@@ -3280,19 +3280,92 @@ export default {
     handleAnalysisQuery() {
       this.analysisQueryParams.startDate = this.analysisSampleDate[0];
       this.analysisQueryParams.endDate = this.analysisSampleDate[1];
-
       let dictLabel = "";
       for(let i = 0; i < this.analysisOptions.length; i++) {
         if (this.analysisOptions[i].dictValue == this.analysisValue) {
           dictLabel = this.analysisOptions[i].dictLabel;
         }
       }
-
       switch (this.analysisValue) {
         case "1":
-          listS0501(this.analysisQueryParams).then(response => {
+          this.disposeChart();
+          listS0501Month(this.analysisQueryParams).then(response => {
             let data = response.data;
-            console.log(data)
+            let pArray = [];
+            let iArray = [];
+            let aArray = [];
+            let nArray = [];
+            let fiftyArray = [];
+            let sampleDateArray = [];
+            for(const key in data) {
+              sampleDateArray.push(key);
+              pArray.push(data[key].p);
+              iArray.push(data[key].i);
+              aArray.push(data[key].a);
+              nArray.push(data[key].n);
+              fiftyArray.push(data[key].fifty);
+            }
+            let option = {
+              title: {
+                text: dictLabel,
+                left: 'center',
+                textStyle: {
+                  fontSize: 16
+                }
+              },
+              tooltip: {
+                trigger: 'axis'
+              },
+              legend: {
+                x: 'center',
+                y: 'bottom',
+                data: ['正构烷烃', '异构烷烃', '芳烃', '烷烃', '50%BP']
+              },
+              grid: {
+                top: '10%',
+                left: '3%',
+                right: '4%',
+                bottom: '10%',
+                containLabel: true
+              },
+              xAxis: {
+                type: 'category',
+                boundaryGap: false,
+                data: sampleDateArray
+              },
+              yAxis: {
+                type: 'value'
+              },
+              series: [
+                {
+                  name: '正构烷烃',
+                  type: 'line',
+                  data: pArray
+                },
+                {
+                  name: '异构烷烃',
+                  type: 'line',
+                  data: iArray
+                },
+                {
+                  name: '芳烃',
+                  type: 'line',
+                  data: aArray
+                },
+                {
+                  name: '烷烃',
+                  type: 'line',
+                  data: nArray
+                },
+                {
+                  name: '50%BP',
+                  type: 'line',
+                  data: fiftyArray
+                }
+              ]
+            };
+            this.chart = this.echarts.init(document.getElementById('chart'));
+            this.chart.setOption(option);
           });
           break;
         case "2":