소스 검색

王子文 月报 Eligible Product Rate修改

wangggziwen 2 년 전
부모
커밋
aad7d9a067

+ 11 - 0
master/src/main/java/com/ruoyi/project/production/controller/TMonthlyProductionReportController.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.production.controller;
 import java.util.List;
 
 import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.MonthlyUpdateVO;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -35,6 +36,16 @@ public class TMonthlyProductionReportController extends BaseController
     @Autowired
     private ITMonthlyProductionReportService tMonthlyProductionReportService;
 
+    /**
+     * 修改Eligible Product Rate
+     */
+    @PreAuthorize("@ss.hasPermi('production:monthly:edit')")
+    @PutMapping(value = "/eligibleProductRate")
+    public AjaxResult editEligibleProductRate(@RequestBody MonthlyUpdateVO monthlyUpdateVO)
+    {
+        return toAjax(tMonthlyProductionReportService.updateEligibleProductRate(monthlyUpdateVO));
+    }
+
     /**
      * 按年份查询Summary
      */

+ 39 - 0
master/src/main/java/com/ruoyi/project/production/controller/vo/MonthlyUpdateVO.java

@@ -0,0 +1,39 @@
+package com.ruoyi.project.production.controller.vo;
+
+import com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 月报修改VO
+ *
+ * @author: Wang Zi Wen
+ * @email: wangggziwen@163.com
+ * @datetime: 2022/11/11 8:52
+ */
+public class MonthlyUpdateVO {
+
+    /** 前端表格 */
+    private List<MonthlyProductionReportVO> tableData = new ArrayList<>();
+
+    /** 表格归属年份 */
+    private Integer year;
+
+    public List<MonthlyProductionReportVO> getTableData() {
+        return tableData;
+    }
+
+    public void setTableData(List<MonthlyProductionReportVO> tableData) {
+        this.tableData = tableData;
+    }
+
+    public Integer getYear() {
+        return year;
+    }
+
+    public void setYear(Integer year) {
+        this.year = year;
+    }
+
+}

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
 import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.MonthlyUpdateVO;
 import com.ruoyi.project.production.domain.TMonthlyProductionReport;
 import com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO;
 
@@ -86,4 +87,9 @@ public interface ITMonthlyProductionReportService
     public List<MonthlyProductionReportVO> selectSummaryByYear(Long year);
 
     List<MonthlyAnalysisDataVO> selectAnalysisData(MonthlyAnalysisQueryVO monthlyAnalysisQueryVO);
+
+    /**
+     * 修改Eligible Product Rate
+     */
+    public int updateEligibleProductRate(MonthlyUpdateVO monthlyUpdateVO);
 }

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

@@ -1,5 +1,6 @@
 package com.ruoyi.project.production.service.impl;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -9,6 +10,7 @@ import java.util.List;
 
 import com.ruoyi.project.production.controller.vo.MonthlyAnalysisDataVO;
 import com.ruoyi.project.production.controller.vo.MonthlyAnalysisQueryVO;
+import com.ruoyi.project.production.controller.vo.MonthlyUpdateVO;
 import com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -1030,4 +1032,75 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
         }
 
     }
+
+    /**
+     * 修改Eligible Product Rate
+     */
+    @Override
+    public int updateEligibleProductRate(MonthlyUpdateVO monthlyUpdateVO) {
+        // 受影响行数
+        int affectedRows = 0;
+        List<MonthlyProductionReportVO> tableData = monthlyUpdateVO.getTableData();
+        long year = monthlyUpdateVO.getYear();
+        Class clazz = null;
+        try {
+            clazz = Class.forName("com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO");
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+        }
+        for (MonthlyProductionReportVO tableDatum : tableData) {
+            for (int i = 0; i < 12; i++) {
+                TMonthlyProductionReport report = new TMonthlyProductionReport();
+                report.setReportMonth((long)(i + 1));
+                report.setReportYear(year);
+                Method getMethod = null;
+                String monthValue = null;
+                try {
+                    if (i == 0) { getMethod =  clazz.getDeclaredMethod("getJan"); }
+                    if (i == 1) { getMethod =  clazz.getDeclaredMethod("getFeb"); }
+                    if (i == 2) { getMethod =  clazz.getDeclaredMethod("getMar"); }
+                    if (i == 3) { getMethod =  clazz.getDeclaredMethod("getApr"); }
+                    if (i == 4) { getMethod =  clazz.getDeclaredMethod("getMay"); }
+                    if (i == 5) { getMethod =  clazz.getDeclaredMethod("getJun"); }
+                    if (i == 6) { getMethod =  clazz.getDeclaredMethod("getJul"); }
+                    if (i == 7) { getMethod =  clazz.getDeclaredMethod("getAug"); }
+                    if (i == 8) { getMethod =  clazz.getDeclaredMethod("getSep"); }
+                    if (i == 9) { getMethod =  clazz.getDeclaredMethod("getOct"); }
+                    if (i == 10) { getMethod =  clazz.getDeclaredMethod("getNov"); }
+                    if (i == 11) { getMethod =  clazz.getDeclaredMethod("getDec"); }
+                    monthValue = (String) getMethod.invoke(tableDatum);
+                } catch (NoSuchMethodException e1){
+                    e1.printStackTrace();
+                } catch (IllegalAccessException e2) {
+                    e2.printStackTrace();
+                } catch (InvocationTargetException e3) {
+                    e3.printStackTrace();
+                }
+                if (monthValue == null) {
+                    continue;
+                }
+                if ("c2_product_rate".equals(tableDatum.getDictLabel())) {
+                    report.setC2ProductRate(monthValue);
+                }
+                if ("c3_product_rate".equals(tableDatum.getDictLabel())) {
+                    report.setC3ProductRate(monthValue);
+                }
+                if ("c4s_product_rate".equals(tableDatum.getDictLabel())) {
+                    report.setC4sProductRate(monthValue);
+                }
+                // 当前报告年份
+                int reportYear = Integer.parseInt(report.getReportYear().toString());
+                // 当前报告月份
+                int reportMonth = Integer.parseInt(report.getReportMonth().toString());
+                // 查询年份=reportYear,月份=reportMonth的月报数据
+                int count = tMonthlyProductionReportMapper.selectTMonthlyProductionReportCountByDate(reportYear, reportMonth);
+                if (count == 0) {   // 新增月报数据
+                    affectedRows += tMonthlyProductionReportMapper.insertTMonthlyProductionReport(report);
+                } else {    // 更新月报数据
+                    affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
+                }
+            }
+        }
+        return affectedRows;
+    }
 }

+ 9 - 0
ui/src/api/production/monthly.js

@@ -1,5 +1,14 @@
 import request from '@/utils/request'
 
+// 修改Eligible Product Rate
+export function updateEligibleProductRate(data) {
+  return request({
+    url: '/production/monthly/eligibleProductRate',
+    method: 'put',
+    data: data
+  })
+}
+
 // 按年份查询Summary
 export function getSummary(year) {
   return request({

+ 117 - 29
ui/src/views/production/monthly/index.vue

@@ -160,24 +160,108 @@
     <el-table border :data="tableEligibleProductRate" style="width: 100%;">
       <el-table-column label="Eligible Product rate">
         <el-table-column width="150" prop="title" label="">
-          <template slot-scope="scope">
-            <div @click="columnOnclick(scope.row)">{{scope.row.title}}</div>
+          <template slot-scope="{row}">
+            <div @click="columnOnclick(row)">{{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>
-        <el-table-column prop="feb" :label="this.monthList[1]"></el-table-column>
-        <el-table-column prop="mar" :label="this.monthList[2]"></el-table-column>
-        <el-table-column prop="apr" :label="this.monthList[3]"></el-table-column>
-        <el-table-column prop="may" :label="this.monthList[4]"></el-table-column>
-        <el-table-column prop="jun" :label="this.monthList[5]"></el-table-column>
-        <el-table-column prop="jul" :label="this.monthList[6]"></el-table-column>
-        <el-table-column prop="aug" :label="this.monthList[7]"></el-table-column>
-        <el-table-column prop="sep" :label="this.monthList[8]"></el-table-column>
-        <el-table-column prop="oct" :label="this.monthList[9]"></el-table-column>
-        <el-table-column prop="nov" :label="this.monthList[10]"></el-table-column>
-        <el-table-column prop="dec" :label="this.monthList[11]"></el-table-column>
+        <el-table-column prop="jan" :label="this.monthList[0]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.jan}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.jan" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="feb" :label="this.monthList[1]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.feb}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.feb" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="mar" :label="this.monthList[2]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.mar}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.mar" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="apr" :label="this.monthList[3]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.apr}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.apr" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="may" :label="this.monthList[4]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.may}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.may" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="jun" :label="this.monthList[5]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.jun}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.jun" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="jul" :label="this.monthList[6]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.jul}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.jul" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="aug" :label="this.monthList[7]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.aug}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.aug" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="sep" :label="this.monthList[8]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.sep}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.sep" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="oct" :label="this.monthList[9]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.oct}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.oct" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="nov" :label="this.monthList[10]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.nov}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.nov" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
+        <el-table-column prop="dec" :label="this.monthList[11]">
+          <template slot-scope="{row}">
+            <div v-if="!eligibleProductRateUpdating">{{row.dec}}</div>
+            <div v-if="eligibleProductRateUpdating">
+              <el-input v-model="row.dec" clearable="true"></el-input>
+            </div>
+          </template>
+        </el-table-column>
         <el-table-column prop="avg" label="avg"></el-table-column>
       </el-table-column>
     </el-table>
@@ -617,7 +701,8 @@ import {
   getSUBUtilityConsumption,
   getSCTFUtilityConsumption,
   getKbi,
-  getSummary
+  getSummary,
+  updateEligibleProductRate
 } from "@/api/production/monthly";
 
 export default {
@@ -671,11 +756,7 @@ export default {
       tableCrackerOutputProduct: [],
       tableAromaticsRawMaterial: [],
       tableAromaticsOutputProduct: [],
-      tableEligibleProductRate: [
-        {title: "C2="},
-        {title: "C3="},
-        {title: "C4's"},
-      ],
+      tableEligibleProductRate: [],
       tableProductYield: [],
       tableCrackerUtilityConsumption: [
         {title: "FG(include NG+Offage)"},
@@ -911,19 +992,26 @@ export default {
     /** 确定修改按钮操作 */
     handleConfirmEligibleProductRateUpdate(row) {
       this.eligibleProductRateUpdating = false;
-      // updateReport(this.reportData).then(response => {
-      //   if (response.code == 200) {
-      //     this.$message.success("修改成功");
-      //   } else {
-      //     this.$message.error("未知错误,请联系管理员");
-      //   }
-      //   this.getReport();
-      // });
+      updateEligibleProductRate({
+        tableData: this.tableEligibleProductRate,
+        year: this.year.getFullYear()
+      }).then(response => {
+        if (response.code == 200) {
+          this.$message.success("修改成功");
+        } else {
+          this.$message.error("未知错误,请联系管理员");
+        }
+        getEligibleProductRate(year).then(response => {
+          this.tableEligibleProductRate = response.data;
+        });
+      });
     },
     /** 取消修改按钮操作 */
     handleCancelEligibleProductRateUpdate(row) {
       this.eligibleProductRateUpdating = false;
-      // this.getReport();
+      getEligibleProductRate(year).then(response => {
+        this.tableEligibleProductRate = response.data;
+      });
     },
     /** 销毁趋势图 */
     disposeChart() {