ソースを参照

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

wangggziwen 2 年 前
コミット
20adda6639

+ 7 - 10
master/src/main/java/com/ruoyi/project/production/controller/TDailyProductionReportController.java

@@ -1,13 +1,10 @@
 package com.ruoyi.project.production.controller;
 
 import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.List;
 
-import com.ruoyi.project.production.controller.vo.AnalysisDataVO;
-import com.ruoyi.project.production.controller.vo.AnalysisQueryVO;
-import com.ruoyi.project.system.domain.SysUser;
-import com.ruoyi.project.training.spec.domain.vo.TStPlanImportVO;
+import com.ruoyi.project.production.controller.vo.DailyAnalysisDataVO;
+import com.ruoyi.project.production.controller.vo.DailyAnalysisQueryVO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -46,13 +43,13 @@ public class TDailyProductionReportController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('production:report:list')")
     @GetMapping("/getAnalysisData")
-    public AjaxResult getAnalysisData(AnalysisQueryVO analysisQueryVO)
+    public AjaxResult getAnalysisData(DailyAnalysisQueryVO dailyAnalysisQueryVO)
     {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        String startDate = sdf.format(analysisQueryVO.getStartDate());
-        String endDate = sdf.format(analysisQueryVO.getEndDate());
-        List<AnalysisDataVO> analysisDataVOList = tDailyProductionReportService.selectAnalysisData(analysisQueryVO.getFieldName(), startDate, endDate);
-        return AjaxResult.success(analysisDataVOList);
+        String startDate = sdf.format(dailyAnalysisQueryVO.getStartDate());
+        String endDate = sdf.format(dailyAnalysisQueryVO.getEndDate());
+        List<DailyAnalysisDataVO> dailyAnalysisDataVOList = tDailyProductionReportService.selectAnalysisData(dailyAnalysisQueryVO.getFieldName(), startDate, endDate);
+        return AjaxResult.success(dailyAnalysisDataVOList);
     }
 
     /**

+ 14 - 1
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyProductionReportController.java

@@ -1,6 +1,9 @@
 package com.ruoyi.project.production.controller;
 
 import java.util.List;
+
+import com.ruoyi.project.production.controller.vo.DailyAnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -37,12 +40,22 @@ public class TMonthlyProductionReportController extends BaseController
      * 按年份查询Cracker Raw Material
      */
     @PreAuthorize("@ss.hasPermi('production:monthly:query')")
-    @GetMapping(value = "/CrackerRawMaterial/{year}")
+    @GetMapping(value = "/crackerRawMaterial/{year}")
     public AjaxResult getCrackerRawMaterialByYear(@PathVariable("year") Long year)
     {
         return AjaxResult.success(tMonthlyProductionReportService.selectCrackerRawMaterialByYear(year));
     }
 
+    /**
+     * 查询月报趋势数据
+     */
+    @PreAuthorize("@ss.hasPermi('production:monthly:list')")
+    @GetMapping("/analysis")
+    public AjaxResult getAnalysisData(MonthlyAnalysisQueryVO monthlyAnalysisQueryVO)
+    {
+        return AjaxResult.success(tMonthlyProductionReportService.selectAnalysisData(monthlyAnalysisQueryVO));
+    }
+
     /**
      * 查询每月生产报告列表
      */

+ 2 - 2
master/src/main/java/com/ruoyi/project/production/controller/vo/AnalysisDataVO.java → master/src/main/java/com/ruoyi/project/production/controller/vo/DailyAnalysisDataVO.java

@@ -5,13 +5,13 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import java.util.Date;
 
 /**
- * 趋势分析数据VO
+ * 日报趋势分析数据VO
  *
  * @author Wang Zi Wen
  * @email wangggziwen@163.com
  * @date 2022/10/18 09:27:50
  */
-public class AnalysisDataVO {
+public class DailyAnalysisDataVO {
 
     /** 值 */
     String valueData;

+ 2 - 2
master/src/main/java/com/ruoyi/project/production/controller/vo/AnalysisQueryVO.java → master/src/main/java/com/ruoyi/project/production/controller/vo/DailyAnalysisQueryVO.java

@@ -6,13 +6,13 @@ import com.ruoyi.framework.web.domain.BaseEntity;
 import java.util.Date;
 
 /**
- * 趋势分析查询VO
+ * 日报趋势分析查询VO
  *
  * @author Wang Zi Wen
  * @email wangggziwen@163.com
  * @date 2022/10/18 09:27:31
  */
-public class AnalysisQueryVO  extends BaseEntity {
+public class DailyAnalysisQueryVO extends BaseEntity {
 
     private static final long serialVersionUID = 1L;
 

+ 34 - 0
master/src/main/java/com/ruoyi/project/production/controller/vo/MonthlyAnalysisDataVO.java

@@ -0,0 +1,34 @@
+package com.ruoyi.project.production.controller.vo;
+
+/**
+ * 月报趋势分析数据VO
+ *
+ * @author: Wang Zi Wen
+ * @email: wangggziwen@163.com
+ * @datetime: 2022/11/2 10:16
+ */
+public class MonthlyAnalysisDataVO {
+
+    /** 值 */
+    String valueData;
+
+    /** 日期 */
+    String dateData;
+
+    public String getValueData() {
+        return valueData;
+    }
+
+    public void setValueData(String valueData) {
+        this.valueData = valueData;
+    }
+
+    public String getDateData() {
+        return dateData;
+    }
+
+    public void setDateData(String dateData) {
+        this.dateData = dateData;
+    }
+
+}

+ 67 - 0
master/src/main/java/com/ruoyi/project/production/controller/vo/MonthlyAnalysisQueryVO.java

@@ -0,0 +1,67 @@
+package com.ruoyi.project.production.controller.vo;
+
+/**
+ * 月报趋势分析查询VO
+ *
+ * @author: Wang Zi Wen
+ * @email: wangggziwen@163.com
+ * @datetime: 2022/11/2 10:13
+ */
+public class MonthlyAnalysisQueryVO {
+
+    /** 指标 */
+    private String item;
+
+    /** 截止年份 */
+    private int toYear;
+
+    /** 截止月份 */
+    private int toMonth;
+
+    /** 开始年份 */
+    private int fromYear;
+
+    /** 开始月份 */
+    private int fromMonth;
+
+    public String getItem() {
+        return item;
+    }
+
+    public void setItem(String item) {
+        this.item = item;
+    }
+
+    public int getToYear() {
+        return toYear;
+    }
+
+    public void setToYear(int toYear) {
+        this.toYear = toYear;
+    }
+
+    public int getToMonth() {
+        return toMonth;
+    }
+
+    public void setToMonth(int toMonth) {
+        this.toMonth = toMonth;
+    }
+
+    public int getFromYear() {
+        return fromYear;
+    }
+
+    public void setFromYear(int fromYear) {
+        this.fromYear = fromYear;
+    }
+
+    public int getFromMonth() {
+        return fromMonth;
+    }
+
+    public void setFromMonth(int fromMonth) {
+        this.fromMonth = fromMonth;
+    }
+
+}

+ 4 - 6
master/src/main/java/com/ruoyi/project/production/mapper/TDailyProductionReportMapper.java

@@ -1,10 +1,8 @@
 package com.ruoyi.project.production.mapper;
 
-import java.util.Date;
 import java.util.List;
 import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
-import com.ruoyi.project.production.controller.vo.AnalysisDataVO;
-import com.ruoyi.project.production.controller.vo.AnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.DailyAnalysisDataVO;
 import com.ruoyi.project.production.domain.TDailyProductionReport;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -86,7 +84,7 @@ public interface TDailyProductionReportMapper
             "where d.REPORT_DATE >= to_date('${startDate}', 'yyyy-mm-dd') " +
             "and d.REPORT_DATE <= to_date('${endDate}', 'yyyy-mm-dd') " +
             "order by d.report_date")
-    List<AnalysisDataVO> selectAnalysisData(@Param("fieldName") String fieldName,
-                                            @Param("startDate") String startDate,
-                                            @Param("endDate") String endDate);
+    List<DailyAnalysisDataVO> selectAnalysisData(@Param("fieldName") String fieldName,
+                                                 @Param("startDate") String startDate,
+                                                 @Param("endDate") String endDate);
 }

+ 27 - 0
master/src/main/java/com/ruoyi/project/production/mapper/TMonthlyProductionReportMapper.java

@@ -2,7 +2,12 @@ package com.ruoyi.project.production.mapper;
 
 import java.util.List;
 import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
+import com.ruoyi.project.production.controller.vo.DailyAnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
+import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
 import com.ruoyi.project.production.domain.TMonthlyProductionReport;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * 每月生产报告Mapper接口
@@ -62,4 +67,26 @@ public interface TMonthlyProductionReportMapper
     public int deleteTMonthlyProductionReportByIds(Long[] ids);
 
     public List<TMonthlyProductionReport> selectCrackerRawMaterialByYear(Long year);
+
+    @Select(" select d.${item} as valueData, concat(concat(d.REPORT_YEAR, '-'), d.REPORT_MONTH) as dateData, " +
+            " d.REPORT_MONTH, d.REPORT_YEAR from t_monthly_production_report d " +
+            " where (d.REPORT_YEAR = ${fromYear} and d.REPORT_MONTH >= ${fromMonth}) " +
+            " and (d.REPORT_YEAR = ${toYear} and d.REPORT_MONTH <= ${toMonth}) " +
+            " ORDER by d.REPORT_YEAR, d.REPORT_MONTH ")
+    List<MonthlyAnalysisDataVO> selectAnalysisDataSameYear(@Param("item") String item,
+                                                   @Param("fromYear") int fromYear,
+                                                   @Param("fromMonth") int fromMonth,
+                                                   @Param("toYear") int toYear,
+                                                   @Param("toMonth") int toMonth);
+
+    @Select(" select d.${item} as valueData, concat(concat(d.REPORT_YEAR, '-'), d.REPORT_MONTH) as dateData, " +
+            " d.REPORT_MONTH, d.REPORT_YEAR from t_monthly_production_report d " +
+            " where (d.REPORT_YEAR = ${fromYear} and d.REPORT_MONTH >= ${fromMonth}) " +
+            " or (d.REPORT_YEAR = ${toYear} and d.REPORT_MONTH <= ${toMonth}) " +
+            " ORDER by d.REPORT_YEAR, d.REPORT_MONTH ")
+    List<MonthlyAnalysisDataVO> selectAnalysisDataDiffYear(@Param("item") String item,
+                                                           @Param("fromYear") int fromYear,
+                                                           @Param("fromMonth") int fromMonth,
+                                                           @Param("toYear") int toYear,
+                                                           @Param("toMonth") int toMonth);
 }

+ 2 - 4
master/src/main/java/com/ruoyi/project/production/service/ITDailyProductionReportService.java

@@ -1,11 +1,9 @@
 package com.ruoyi.project.production.service;
 
 import java.io.IOException;
-import java.util.Date;
 import java.util.List;
 
-import com.ruoyi.project.production.controller.vo.AnalysisDataVO;
-import com.ruoyi.project.production.controller.vo.AnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.DailyAnalysisDataVO;
 import com.ruoyi.project.production.domain.TDailyProductionReport;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -80,5 +78,5 @@ public interface ITDailyProductionReportService
      */
     public String importData(MultipartFile file) throws IOException;
 
-    List<AnalysisDataVO> selectAnalysisData(String fieldName, String startDate, String endDate);
+    List<DailyAnalysisDataVO> selectAnalysisData(String fieldName, String startDate, String endDate);
 }

+ 6 - 0
master/src/main/java/com/ruoyi/project/production/service/ITMonthlyProductionReportService.java

@@ -1,6 +1,10 @@
 package com.ruoyi.project.production.service;
 
 import java.util.List;
+
+import com.ruoyi.project.production.controller.vo.DailyAnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
+import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
 import com.ruoyi.project.production.domain.TMonthlyProductionReport;
 import com.ruoyi.project.production.service.impl.vo.CrackerRawMaterialVO;
 
@@ -61,4 +65,6 @@ public interface ITMonthlyProductionReportService
     public int deleteTMonthlyProductionReportById(Long id);
 
     public List<CrackerRawMaterialVO> selectCrackerRawMaterialByYear(Long year);
+
+    List<MonthlyAnalysisDataVO> selectAnalysisData(MonthlyAnalysisQueryVO monthlyAnalysisQueryVO);
 }

+ 2 - 2
master/src/main/java/com/ruoyi/project/production/service/impl/TDailyProductionReportServiceImpl.java

@@ -6,7 +6,7 @@ import java.math.RoundingMode;
 import java.util.Date;
 import java.util.List;
 
-import com.ruoyi.project.production.controller.vo.AnalysisDataVO;
+import com.ruoyi.project.production.controller.vo.DailyAnalysisDataVO;
 import org.apache.poi.ss.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -795,7 +795,7 @@ public class TDailyProductionReportServiceImpl implements ITDailyProductionRepor
     }
 
     @Override
-    public List<AnalysisDataVO> selectAnalysisData(String fieldName, String startDate, String endDate) {
+    public List<DailyAnalysisDataVO> selectAnalysisData(String fieldName, String startDate, String endDate) {
         return tDailyProductionReportMapper.selectAnalysisData(fieldName, startDate, endDate);
     }
 

+ 17 - 0
master/src/main/java/com/ruoyi/project/production/service/impl/TMonthlyProductionReportServiceImpl.java

@@ -7,6 +7,9 @@ import java.util.Date;
 import java.util.List;
 
 import com.alibaba.druid.sql.ast.statement.SQLForeignKeyImpl;
+import com.ruoyi.project.production.controller.vo.DailyAnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
+import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
 import com.ruoyi.project.production.service.impl.vo.CrackerRawMaterialVO;
 import org.junit.platform.commons.JUnitException;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -273,4 +276,18 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
         }
         return crackerRawMaterialVOs;
     }
+
+    @Override
+    public List<MonthlyAnalysisDataVO> selectAnalysisData(MonthlyAnalysisQueryVO monthlyAnalysisQueryVO) {
+        if (monthlyAnalysisQueryVO.getFromYear()==monthlyAnalysisQueryVO.getToYear()) {
+            return tMonthlyProductionReportMapper.selectAnalysisDataSameYear(monthlyAnalysisQueryVO.getItem(),
+                    monthlyAnalysisQueryVO.getFromYear(), monthlyAnalysisQueryVO.getFromMonth(),
+                    monthlyAnalysisQueryVO.getToYear(), monthlyAnalysisQueryVO.getToMonth());
+        } else {
+            return tMonthlyProductionReportMapper.selectAnalysisDataDiffYear(monthlyAnalysisQueryVO.getItem(),
+                    monthlyAnalysisQueryVO.getFromYear(), monthlyAnalysisQueryVO.getFromMonth(),
+                    monthlyAnalysisQueryVO.getToYear(), monthlyAnalysisQueryVO.getToMonth());
+        }
+
+    }
 }

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

@@ -3,11 +3,20 @@ import request from '@/utils/request'
 // 按年份查询Cracker Raw Material
 export function getCrackerRawMaterial(year) {
   return request({
-    url: '/production/monthly/CrackerRawMaterial/' + year,
+    url: '/production/monthly/crackerRawMaterial/' + year,
     method: 'get'
   })
 }
 
+// 查询趋势分析数据
+export function getAnalysisData(query) {
+  return request({
+    url: '/production/monthly/analysis',
+    method: 'get',
+    params: query
+  })
+}
+
 // 查询每月生产报告列表
 export function listReport(query) {
   return request({

+ 0 - 3
ui/src/views/production/daily/index.vue

@@ -3452,9 +3452,6 @@ export default {
       lastSelectedDate: null,
       // 修改中
       updating: false,
-
-
-
       // 遮罩层
       loading: true,
       // 选中数组

+ 17 - 6
ui/src/views/production/monthly/index.vue

@@ -469,6 +469,7 @@
 
 <script>
 import {
+  getAnalysisData,
   getCrackerRawMaterial,
 } from "@/api/production/monthly";
 
@@ -476,6 +477,8 @@ export default {
   name: "Monthly",
   data() {
     return {
+      // 对比指标下拉框
+      chemicalsOptions: [],
       // 趋势图y轴数值
       valueList: [],
       // 趋势图x轴日期
@@ -496,13 +499,13 @@ export default {
       // 趋势图查询参数
       analysisQueryParams: {
         // 指标
-        title: null,
+        item: null,
         // 截止年份
         toYear: 0,
         // 截止月份
         toMonth: 0,
         // 开始年份
-        fromTear: 0,
+        fromYear: 0,
         // 开始月份
         fromMonth: 0,
       },
@@ -813,6 +816,9 @@ export default {
     }
   },
   created() {
+    this.getDicts("CHEMICALS").then(response => {
+      this.chemicalsOptions = response.data;
+    });
     // 加载时设置year为今年
     this.year = new Date();
     // 加载月报数据
@@ -828,11 +834,16 @@ export default {
       let title = row.title;
       let toYear = this.year.getFullYear();
       let toMonth = this.year.getMonth() + 1;
-      let fromTear = toYear - 1;
+      let fromYear = toYear - 1;
       let fromMonth = toMonth;
+      for (let i = 0; i < this.chemicalsOptions.length; i++) {
+        if (this.chemicalsOptions[i].dictLabel == title) {
+          this.analysisQueryParams.item = this.chemicalsOptions[i].dictValue;
+        }
+      }
       this.analysisQueryParams.toYear = toYear;
       this.analysisQueryParams.toMonth = toMonth;
-      this.analysisQueryParams.fromTear = fromTear;
+      this.analysisQueryParams.fromYear = fromYear;
       this.analysisQueryParams.fromMonth = fromMonth;
       let startDate = new Date();
       let endDate = new Date();
@@ -841,11 +852,11 @@ export default {
       this.analysisDialogElement.endDate = endDate;
       this.analysis.title = row.title + "趋势分析";
       this.analysis.open = true;
-      // this.draw();
+      this.draw();
     },
     /** 绘制趋势图 */
     draw() {
-      查询方法(this.analysisQueryParams).then(response => {
+      getAnalysisData(this.analysisQueryParams).then(response => {
         let data = response.data;
         this.maxValue = 0;
         this.minValue = data[0].valueData;