wangggziwen 2 лет назад
Родитель
Сommit
8257422012

+ 84 - 0
master/src/main/java/com/ruoyi/project/production/domain/TMonthlyProductionReport.java

@@ -570,6 +570,30 @@ public class TMonthlyProductionReport extends BaseEntity
     @Excel(name = "Runing Rate calendar day")
     private String calendarDay;
 
+    /** Plant Load Cracker load */
+    @Excel(name = "Plant Load Cracker load")
+    private String crackerLoad;
+
+    /** Plant Load C2+C3 Capacity */
+    @Excel(name = "Plant Load C2+C3 Capacity")
+    private String c2C3Capacity;
+
+    /** Plant Load Ethylene load */
+    @Excel(name = "Plant Load Ethylene load")
+    private String ethyleneLoad;
+
+    /** Plant Load Ethylene Capacity */
+    @Excel(name = "Plant Load Ethylene Capacity")
+    private String ethyleneCapacity;
+
+    /** Plant Load AEU load */
+    @Excel(name = "Plant Load AEU load")
+    private String aeuLoad;
+
+    /** Plant Load BTX Capacity */
+    @Excel(name = "Plant Load BTX Capacity")
+    private String btxCapacity;
+
     public void setId(Long id)
     {
         this.id = id;
@@ -1821,6 +1845,60 @@ public class TMonthlyProductionReport extends BaseEntity
     {
         return calendarDay;
     }
+    public void setCrackerLoad(String crackerLoad)
+    {
+        this.crackerLoad = crackerLoad;
+    }
+
+    public String getCrackerLoad()
+    {
+        return crackerLoad;
+    }
+    public void setC2C3Capacity(String c2C3Capacity)
+    {
+        this.c2C3Capacity = c2C3Capacity;
+    }
+
+    public String getC2C3Capacity()
+    {
+        return c2C3Capacity;
+    }
+    public void setEthyleneLoad(String ethyleneLoad)
+    {
+        this.ethyleneLoad = ethyleneLoad;
+    }
+
+    public String getEthyleneLoad()
+    {
+        return ethyleneLoad;
+    }
+    public void setEthyleneCapacity(String ethyleneCapacity)
+    {
+        this.ethyleneCapacity = ethyleneCapacity;
+    }
+
+    public String getEthyleneCapacity()
+    {
+        return ethyleneCapacity;
+    }
+    public void setAeuLoad(String aeuLoad)
+    {
+        this.aeuLoad = aeuLoad;
+    }
+
+    public String getAeuLoad()
+    {
+        return aeuLoad;
+    }
+    public void setBtxCapacity(String btxCapacity)
+    {
+        this.btxCapacity = btxCapacity;
+    }
+
+    public String getBtxCapacity()
+    {
+        return btxCapacity;
+    }
 
     @Override
     public String toString() {
@@ -1964,6 +2042,12 @@ public class TMonthlyProductionReport extends BaseEntity
             .append("runRate", getRunRate())
             .append("calendarHour", getCalendarHour())
             .append("calendarDay", getCalendarDay())
+            .append("crackerLoad", getCrackerLoad())
+            .append("c2C3Capacity", getC2C3Capacity())
+            .append("ethyleneLoad", getEthyleneLoad())
+            .append("ethyleneCapacity", getEthyleneCapacity())
+            .append("aeuLoad", getAeuLoad())
+            .append("btxCapacity", getBtxCapacity())
             .toString();
     }
 }

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

@@ -11,7 +11,6 @@ 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.thread.SyncAfterDailyUpdateThread;
 import com.ruoyi.project.production.service.impl.thread.SyncAfterMonthlyUpdateThread;
 import com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -1180,7 +1179,62 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
      */
     @Override
     public List<MonthlyProductionReportVO> selectPlantLoadByYear(Long year) {
-        return  null;
+        // 当前日期
+        Date currentDate = new Date();
+        // 当前年份
+        Long currentYear = Long.parseLong(currentDate.getYear() + 1900 + "");
+        // 当前月份
+        Long currentMonth = Long.parseLong(currentDate.getMonth() + 1 + "");
+        // 从数据库中查出的当前year的月报数据集合,每个元素对应当前year某个月的数据
+        List<TMonthlyProductionReport> tMonthlyProductionReports = tMonthlyProductionReportMapper.selectPlantLoadByYear(year);
+        // 前端月报数据集合,每个元素对应当前某个指标的title、unit、1~12月的数据以及年度汇总数据
+        List<MonthlyProductionReportVO> monthlyProductionReportVOs = new ArrayList<>();
+        monthlyProductionReportVOs.add(new MonthlyProductionReportVO("cracker_load","Cracker load","%"));
+        monthlyProductionReportVOs.add(new MonthlyProductionReportVO("c2_c3_capacity","C2+C3 Capacity",""));
+        monthlyProductionReportVOs.add(new MonthlyProductionReportVO("ethylene_load","Ethylene load","%"));
+        monthlyProductionReportVOs.add(new MonthlyProductionReportVO("ethylene_capacity","Ethylene Capacity",""));
+        monthlyProductionReportVOs.add(new MonthlyProductionReportVO("aeu_load","AEU load","%"));
+        monthlyProductionReportVOs.add(new MonthlyProductionReportVO("btx_capacity","BTX Capacity",""));
+        // 遍历从数据库中查出的月报数据集合,结果为0~12条数据不等
+        for (int i = 0; i < tMonthlyProductionReports.size(); i++) {
+            TMonthlyProductionReport tMonthlyProductionReport = tMonthlyProductionReports.get(i);
+            String crackerLoad = tMonthlyProductionReport.getCrackerLoad();
+            String c2C3Capacity = tMonthlyProductionReport.getC2C3Capacity();
+            String ethyleneLoad = tMonthlyProductionReport.getEthyleneLoad();
+            String ethyleneCapacity = tMonthlyProductionReport.getEthyleneCapacity();
+            String aeuLoad = tMonthlyProductionReport.getAeuLoad();
+            String btxCapacity = tMonthlyProductionReport.getBtxCapacity();
+            Long reportMonth = tMonthlyProductionReport.getReportMonth();   // 当前元素的所属月份
+            Long reportYear = tMonthlyProductionReport.getReportYear();     // 当前元素的所属年份
+            // 前端数据集合的class
+            Class clazz = null;
+            // 当前元素调用的set方法
+            Method method = null;
+            try {
+                clazz = Class.forName("com.ruoyi.project.production.service.impl.vo.MonthlyProductionReportVO");
+                method = this.getSetMethod(reportMonth, clazz);
+                // 按照当前元素的所属月份调取相应set方法
+                method.invoke(monthlyProductionReportVOs.get(0), crackerLoad);
+                method.invoke(monthlyProductionReportVOs.get(1), c2C3Capacity);
+                method.invoke(monthlyProductionReportVOs.get(2), ethyleneLoad);
+                method.invoke(monthlyProductionReportVOs.get(3), ethyleneCapacity);
+                method.invoke(monthlyProductionReportVOs.get(4), aeuLoad);
+                method.invoke(monthlyProductionReportVOs.get(5), btxCapacity);
+                // 当前年份=所属年份,当前月份=所属月份
+                if (currentMonth.equals(reportMonth) && currentYear.equals(reportYear)) {
+                    monthlyProductionReportVOs.get(0).setCurrently(crackerLoad);
+                    monthlyProductionReportVOs.get(1).setCurrently(c2C3Capacity);
+                    monthlyProductionReportVOs.get(2).setCurrently(ethyleneLoad);
+                    monthlyProductionReportVOs.get(3).setCurrently(ethyleneCapacity);
+                    monthlyProductionReportVOs.get(4).setCurrently(aeuLoad);
+                    monthlyProductionReportVOs.get(5).setCurrently(btxCapacity);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        this.calcAvg(monthlyProductionReportVOs);
+        return monthlyProductionReportVOs;
     }
 
     /**

+ 43 - 1
master/src/main/java/com/ruoyi/project/production/service/impl/thread/SyncAfterMonthlyUpdateThread.java

@@ -145,11 +145,53 @@ public class SyncAfterMonthlyUpdateThread extends Thread {
         BigDecimal calendarDay = new BigDecimal(calendarDayStr == null ? "0" : calendarDayStr);
         calendarHour = calendarDay.multiply(new BigDecimal("24"));
         runHour = calendarHour.subtract(shutdouwnTh);
-        runRate = runHour.multiply(new BigDecimal("100")).divide(calendarHour, 2, RoundingMode.HALF_UP);
+        if (calendarHour.compareTo(BigDecimal.ZERO) != 0) {
+            runRate = runHour.multiply(new BigDecimal("100")).divide(calendarHour, 2, RoundingMode.HALF_UP);
+        }
         report.setRunHour(runHour.toString());
         report.setRunRate(runRate.toString());
         report.setCalendarHour(calendarHour.toString());
 
+        String propyleneProducedStr = report.getPropyleneProduced();
+        String aeuBenzeneProducedStr = report.getAeuBenzeneProduced();
+        String aeuTolueneProducedStr = report.getAeuTolueneProduced();
+        String aeuXyleneProducedStr = report.getAeuXyleneProduced();
+        BigDecimal propyleneProduced = new BigDecimal(propyleneProducedStr == null ? "0" : propyleneProducedStr);
+        BigDecimal aeuBenzeneProduced = new BigDecimal(aeuBenzeneProducedStr == null ? "0" : aeuBenzeneProducedStr);
+        BigDecimal aeuTolueneProduced = new BigDecimal(aeuTolueneProducedStr == null ? "0" : aeuTolueneProducedStr);
+        BigDecimal aeuXyleneProduced = new BigDecimal(aeuXyleneProducedStr == null ? "0" : aeuXyleneProducedStr);
+        BigDecimal crackerLoad = new BigDecimal("0");
+        BigDecimal c2C3Capacity = new BigDecimal("0");
+        BigDecimal ethyleneLoad = new BigDecimal("0");
+        BigDecimal ethyleneCapacity = new BigDecimal("0");
+        BigDecimal aeuLoad = new BigDecimal("0");
+        BigDecimal btxCapacity = new BigDecimal("0");
+        c2C3Capacity = calendarHour.multiply(new BigDecimal("94").add(new BigDecimal(51.625)))
+                .divide(new BigDecimal("1"), 2, RoundingMode.HALF_UP);
+        if (c2C3Capacity.compareTo(BigDecimal.ZERO) != 0) {
+            crackerLoad = (ethylenProduced.add(propyleneProduced))
+                    .multiply(new BigDecimal("100"))
+                    .divide(c2C3Capacity, 2, RoundingMode.HALF_UP);
+        }
+        ethyleneCapacity = calendarHour.multiply(new BigDecimal("94"));
+        if (ethyleneCapacity.compareTo(BigDecimal.ZERO) != 0) {
+            ethyleneLoad = ethylenProduced
+                    .multiply(new BigDecimal("100"))
+                    .divide(ethyleneCapacity, 2, RoundingMode.HALF_UP);
+        }
+        btxCapacity = calendarHour.multiply(new BigDecimal("45"));
+        if (btxCapacity.compareTo(BigDecimal.ZERO) != 0) {
+            aeuLoad = (aeuBenzeneProduced.add(aeuTolueneProduced).add(aeuXyleneProduced))
+                    .multiply(new BigDecimal("100"))
+                    .divide(btxCapacity, 2, RoundingMode.HALF_UP);
+        }
+        report.setCrackerLoad(crackerLoad.toString());
+        report.setC2C3Capacity(c2C3Capacity.toString());
+        report.setEthyleneLoad(ethyleneLoad.toString());
+        report.setEthyleneCapacity(ethyleneCapacity.toString());
+        report.setAeuLoad(aeuLoad.toString());
+        report.setBtxCapacity(btxCapacity.toString());
+
         tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
 
     }

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

@@ -144,6 +144,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="runRate"                  column="run_rate"    />
         <result property="calendarHour"             column="calendar_hour"    />
         <result property="calendarDay"              column="calendar_day"    />
+        <result property="crackerLoad"              column="cracker_load"    />
+        <result property="c2C3Capacity"             column="c2_c3_capacity"    />
+        <result property="ethyleneLoad"             column="ethylene_load"    />
+        <result property="ethyleneCapacity"         column="ethylene_capacity"    />
+        <result property="aeuLoad"                  column="aeu_load"    />
+        <result property="btxCapacity"              column="btx_capacity"    />
     </resultMap>
 
     <select id="selectCrackerRawMaterialByYear" parameterType="Long" resultMap="TMonthlyProductionReportResult">
@@ -247,7 +253,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where d.report_year = #{year}
     </select>
 
-    <select id="selectPlantLoadByYear" parameterType="Long" resultMap="TMonthlyProductionReportResult"></select>
+    <select id="selectPlantLoadByYear" parameterType="Long" resultMap="TMonthlyProductionReportResult">
+        select
+               d.id, d.report_month, d.report_year,
+               d.cracker_load, d.c2_c3_capacity, d.ethylene_load,
+               d.ethylene_capacity, d.aeu_load, d.btx_capacity
+        from
+             t_monthly_production_report d
+        where d.report_year = #{year}
+    </select>
 
     <select id="selectCostFrEthyleneByYear" parameterType="Long" resultMap="TMonthlyProductionReportResult"></select>
 
@@ -448,6 +462,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="runRate != null">run_rate,</if>
             <if test="calendarHour != null">calendar_hour,</if>
             <if test="calendarDay != null">calendar_day,</if>
+            <if test="crackerLoad != null">cracker_load,</if>
+            <if test="c2C3Capacity != null">c2_c3_capacity,</if>
+            <if test="ethyleneLoad != null">ethylene_load,</if>
+            <if test="ethyleneCapacity != null">ethylene_capacity,</if>
+            <if test="aeuLoad != null">aeu_load,</if>
+            <if test="btxCapacity != null">btx_capacity,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -589,6 +609,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="runRate != null">#{runRate},</if>
             <if test="calendarHour != null">#{calendarHour},</if>
             <if test="calendarDay != null">#{calendarDay},</if>
+            <if test="crackerLoad != null">#{crackerLoad},</if>
+            <if test="c2C3Capacity != null">#{c2C3Capacity},</if>
+            <if test="ethyleneLoad != null">#{ethyleneLoad},</if>
+            <if test="ethyleneCapacity != null">#{ethyleneCapacity},</if>
+            <if test="aeuLoad != null">#{aeuLoad},</if>
+            <if test="btxCapacity != null">#{btxCapacity},</if>
         </trim>
     </insert>
 
@@ -731,6 +757,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="runRate != null">run_rate = #{runRate},</if>
             <if test="calendarHour != null">calendar_hour = #{calendarHour},</if>
             <if test="calendarDay != null">calendar_day = #{calendarDay},</if>
+            <if test="crackerLoad != null">cracker_load = #{crackerLoad},</if>
+            <if test="c2C3Capacity != null">c2_c3_capacity = #{c2C3Capacity},</if>
+            <if test="ethyleneLoad != null">ethylene_load = #{ethyleneLoad},</if>
+            <if test="ethyleneCapacity != null">ethylene_capacity = #{ethyleneCapacity},</if>
+            <if test="aeuLoad != null">aeu_load = #{aeuLoad},</if>
+            <if test="btxCapacity != null">btx_capacity = #{btxCapacity},</if>
         </trim>
         where report_month = #{reportMonth} and report_year = #{reportYear}
     </update>

+ 5 - 12
ui/src/views/production/monthly/index.vue

@@ -1136,7 +1136,7 @@
         <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="total" label="total"></el-table-column>
+        <el-table-column prop="avg" label="avg"></el-table-column>
       </el-table-column>
     </el-table>
     <!-- Cost Fr Ethylene -->
@@ -1788,14 +1788,7 @@ export default {
       tableCrackerEnergyConsumption: [],
       tableAromaticsUtilityConsumption: [],
       tableAromaticsEnergyConsumption: [],
-      tablePlantLoad: [
-        {title: "Cracker load"},
-        {title: "C2+C3 Capacity"},
-        {title: "Ethylene load"},
-        {title: "Ethylene Capacity"},
-        {title: "AEU load"},
-        {title: "BTX Capacity"},
-      ],
+      tablePlantLoad: [],
       tableCostFrEthylene: [
         {title: "the cost"},
       ],
@@ -2279,9 +2272,9 @@ export default {
       getAromaticsEnergyConsumption(year).then(response => {
         this.tableAromaticsEnergyConsumption = response.data;
       });
-      // getPlantLoad(year).then(response => {
-      //   this.tablePlantLoad = response.data;
-      // });
+      getPlantLoad(year).then(response => {
+        this.tablePlantLoad = response.data;
+      });
       // getCostFrEthylene(year).then(response => {
       //   this.tableCostFrEthylene = response.data;
       // });