Przeglądaj źródła

王子文 月报 修改单价维护表时更新月报数据

wangggziwen 2 lat temu
rodzic
commit
6fba8b2354

+ 12 - 0
master/src/main/java/com/ruoyi/project/production/mapper/TMonthlyProductionPriceMapper.java

@@ -14,6 +14,18 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface TMonthlyProductionPriceMapper 
 {
+    /**
+     * 查询单价
+     *
+     * @param reportYear    年份
+     * @param reportMonth   月份
+     * @return
+     */
+    public TMonthlyProductionPrice selectTMonthlyProductionPriceByDate(
+            @Param("reportYear")int reportYear,
+            @Param("reportMonth")int reportMonth
+    );
+
     /**
      * 查询生产月报单价维护
      * 

+ 13 - 0
master/src/main/java/com/ruoyi/project/production/service/impl/TMonthlyProductionPriceServiceImpl.java

@@ -8,6 +8,8 @@ import java.util.List;
 
 import com.ruoyi.project.production.controller.vo.MonthlyUpdateVO;
 import com.ruoyi.project.production.domain.TMonthlyProductionReport;
+import com.ruoyi.project.production.mapper.TMonthlyProductionReportMapper;
+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;
 import org.springframework.stereotype.Service;
@@ -27,6 +29,9 @@ public class TMonthlyProductionPriceServiceImpl implements ITMonthlyProductionPr
     @Autowired
     private TMonthlyProductionPriceMapper tMonthlyProductionPriceMapper;
 
+    @Autowired
+    private TMonthlyProductionReportMapper tMonthlyProductionReportMapper;
+
     /**
      * 查询生产月报单价维护
      *
@@ -245,6 +250,14 @@ public class TMonthlyProductionPriceServiceImpl implements ITMonthlyProductionPr
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionPriceMapper.updateTMonthlyProductionPrice(price);
                 }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;

+ 66 - 13
master/src/main/java/com/ruoyi/project/production/service/impl/TMonthlyProductionReportServiceImpl.java

@@ -11,6 +11,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.mapper.TMonthlyProductionPriceMapper;
 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;
@@ -28,6 +29,9 @@ import com.ruoyi.project.production.service.ITMonthlyProductionReportService;
 @Service
 public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionReportService
 {
+    @Autowired
+    private TMonthlyProductionPriceMapper tMonthlyProductionPriceMapper;
+
     @Autowired
     private TMonthlyProductionReportMapper tMonthlyProductionReportMapper;
 
@@ -2280,6 +2284,14 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
                 }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;
@@ -2363,16 +2375,14 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
                 }
-                // 修改cracker_consumption_ia后同步更新月报数据
-                if (report.getCrackerConsumptionIa() != null) {
-                    // 同步更新月报数据
-                    SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
-                            (int)year,
-                            (i + 1),
-                            this.tMonthlyProductionReportMapper
-                    );
-                    thread.run();
-                }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;
@@ -2450,6 +2460,14 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
                 }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;
@@ -2546,7 +2564,8 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
                         (int)year,
                         (i + 1),
-                        this.tMonthlyProductionReportMapper
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
                 );
                 thread.run();
             }
@@ -2618,7 +2637,8 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
                         (int)year,
                         (i + 1),
-                        this.tMonthlyProductionReportMapper
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
                 );
                 thread.run();
             }
@@ -2740,6 +2760,14 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
                 }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;
@@ -2805,6 +2833,14 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
                 }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;
@@ -2895,7 +2931,8 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
                         (int)year,
                         (i + 1),
-                        this.tMonthlyProductionReportMapper
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
                 );
                 thread.run();
             }
@@ -3011,6 +3048,14 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
                 }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;
@@ -3094,6 +3139,14 @@ public class TMonthlyProductionReportServiceImpl implements ITMonthlyProductionR
                 } else {    // 更新月报数据
                     affectedRows += tMonthlyProductionReportMapper.updateTMonthlyProductionReport(report);
                 }
+                // 同步更新月报数据
+                SyncAfterMonthlyUpdateThread thread = new SyncAfterMonthlyUpdateThread(
+                        (int)year,
+                        (i + 1),
+                        this.tMonthlyProductionReportMapper,
+                        this.tMonthlyProductionPriceMapper
+                );
+                thread.run();
             }
         }
         return affectedRows;

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

@@ -1,6 +1,8 @@
 package com.ruoyi.project.production.service.impl.thread;
 
+import com.ruoyi.project.production.domain.TMonthlyProductionPrice;
 import com.ruoyi.project.production.domain.TMonthlyProductionReport;
+import com.ruoyi.project.production.mapper.TMonthlyProductionPriceMapper;
 import com.ruoyi.project.production.mapper.TMonthlyProductionReportMapper;
 
 import java.math.BigDecimal;
@@ -21,6 +23,8 @@ public class SyncAfterMonthlyUpdateThread extends Thread {
 
     private TMonthlyProductionReportMapper tMonthlyProductionReportMapper;
 
+    private TMonthlyProductionPriceMapper tMonthlyProductionPriceMapper;
+
     public SyncAfterMonthlyUpdateThread() {
         super();
     }
@@ -35,6 +39,18 @@ public class SyncAfterMonthlyUpdateThread extends Thread {
         this.tMonthlyProductionReportMapper = tMonthlyProductionReportMapper;
     }
 
+    public SyncAfterMonthlyUpdateThread(
+            int reportYear,
+            int reportMonth,
+            TMonthlyProductionReportMapper tMonthlyProductionReportMapper,
+            TMonthlyProductionPriceMapper tMonthlyProductionPriceMapper) {
+        super();
+        this.reportYear = reportYear;
+        this.reportMonth = reportMonth;
+        this.tMonthlyProductionReportMapper = tMonthlyProductionReportMapper;
+        this.tMonthlyProductionPriceMapper = tMonthlyProductionPriceMapper;
+    }
+
     @Override
     public void run() {
         this.syncMonthlyData();
@@ -44,8 +60,7 @@ public class SyncAfterMonthlyUpdateThread extends Thread {
      * 同步更新月报数据
      */
     private void syncMonthlyData() {
-        TMonthlyProductionReport report = tMonthlyProductionReportMapper
-                .selectTMonthlyProductionReportByDate(this.reportYear, this.reportMonth);
+        TMonthlyProductionReport report = tMonthlyProductionReportMapper.selectTMonthlyProductionReportByDate(this.reportYear, this.reportMonth);
 
         String ethylenProducedStr = report.getEthylenProduced();
         String fuelGasOffgasCrackerStr = report.getFuelGasOffgasCracker();
@@ -214,6 +229,68 @@ public class SyncAfterMonthlyUpdateThread extends Thread {
         report.setSubConCc(subConCc.toString());
         report.setSubConSc(subConSc.toString());
 
+        String subConElectricStr = report.getSubConElectric();
+        String subConNgStr = report.getSubConNg();
+        String subConFgFrEuStr = report.getSubConFgFrEu();
+        String subConLpgStr = report.getSubConLpg();
+        String subConPCondensateStr = report.getSubConPCondensate();
+        String subConCwStr = report.getSubConCw();
+        String subConIaPaStr = report.getSubConIaPa();
+        String subConBfwStr = report.getSubConBfw();
+        String subConEoEgPurgeGasStr = report.getSubConEoEgPurgeGas();
+        String subConH2FrSyngasAsFuleStr = report.getSubConH2FrSyngasAsFule();
+        BigDecimal subConElectric = new BigDecimal(subConElectricStr == null ? "0" : subConElectricStr);
+        BigDecimal subConNg = new BigDecimal(subConNgStr == null ? "0" : subConNgStr);
+        BigDecimal subConFgFrEu = new BigDecimal(subConFgFrEuStr == null ? "0" : subConFgFrEuStr);
+        BigDecimal subConLpg = new BigDecimal(subConLpgStr == null ? "0" : subConLpgStr);
+        BigDecimal subConPCondensate = new BigDecimal(subConPCondensateStr == null ? "0" : subConPCondensateStr);
+        BigDecimal subConCw = new BigDecimal(subConCwStr == null ? "0" : subConCwStr);
+        BigDecimal subConIaPa = new BigDecimal(subConIaPaStr == null ? "0" : subConIaPaStr);
+        BigDecimal subConBfw = new BigDecimal(subConBfwStr == null ? "0" : subConBfwStr);
+        BigDecimal subConEoEgPurgeGas = new BigDecimal(subConEoEgPurgeGasStr == null ? "0" : subConEoEgPurgeGasStr);
+        BigDecimal subConH2FrSyngasAsFule = new BigDecimal(subConH2FrSyngasAsFuleStr == null ? "0" : subConH2FrSyngasAsFuleStr);
+        BigDecimal subConCostOutput = new BigDecimal("0");
+        // 查询单价
+        TMonthlyProductionPrice price = tMonthlyProductionPriceMapper.selectTMonthlyProductionPriceByDate(this.reportYear, this.reportMonth);
+        String subConElectricPriceStr = price.getSubConElectricPrice();
+        String subConNgPriceStr = price.getSubConNgPrice();
+        String subConFgFrEuPriceStr = price.getSubConFgFrEuPrice();
+        String subConLpgPriceStr = price.getSubConLpgPrice();
+        String subConHhpSteamPriceStr = price.getSubConHhpSteamPrice();
+        String subConPCondensatePriceStr = price.getSubConPCondensatePrice();
+        String subConCwPriceStr = price.getSubConCwPrice();
+        String subConIaPaPriceStr = price.getSubConIaPaPrice();
+        String subConBfwPriceStr = price.getSubConBfwPrice();
+        String subConEoEgPurgeGasPriceStr = price.getSubConEoEgPurgeGasPrice();
+        String subConH2FulePriceStr = price.getSubConH2FulePrice();
+        BigDecimal subConElectricPrice = new BigDecimal(subConElectricPriceStr == null ? "0" : subConElectricPriceStr);
+        BigDecimal subConNgPrice = new BigDecimal(subConNgPriceStr == null ? "0" : subConNgPriceStr);
+        BigDecimal subConFgFrEuPrice = new BigDecimal(subConFgFrEuPriceStr == null ? "0" : subConFgFrEuPriceStr);
+        BigDecimal subConLpgPrice = new BigDecimal(subConLpgPriceStr == null ? "0" : subConLpgPriceStr);
+        BigDecimal subConHhpSteamPrice = new BigDecimal(subConHhpSteamPriceStr == null ? "0" : subConHhpSteamPriceStr);
+        BigDecimal subConPCondensatePrice = new BigDecimal(subConPCondensatePriceStr == null ? "0" : subConPCondensatePriceStr);
+        BigDecimal subConCwPrice = new BigDecimal(subConCwPriceStr == null ? "0" : subConCwPriceStr);
+        BigDecimal subConIaPaPrice = new BigDecimal(subConIaPaPriceStr == null ? "0" : subConIaPaPriceStr);
+        BigDecimal subConBfwPrice = new BigDecimal(subConBfwPriceStr == null ? "0" : subConBfwPriceStr);
+        BigDecimal subConEoEgPurgeGasPrice = new BigDecimal(subConEoEgPurgeGasPriceStr == null ? "0" : subConEoEgPurgeGasPriceStr);
+        BigDecimal subConH2FulePrice = new BigDecimal(subConH2FulePriceStr == null ? "0" : subConH2FulePriceStr);
+        if (subConHpSteamFrSubNet.compareTo(BigDecimal.ZERO) != 0 && subConHhpSteam.compareTo(BigDecimal.ZERO) != 0) {
+            subConCostOutput = (subConElectricPrice.multiply(subConElectric)
+                    .add(subConNgPrice.multiply(subConNg))
+                    .add(subConFgFrEuPrice.multiply(subConFgFrEu))
+                    .add(subConLpgPrice.multiply(subConLpg))
+                    .add(subConPCondensatePrice.multiply(subConPCondensate))
+                    .add(subConCwPrice.multiply(subConCw))
+                    .add(subConIaPaPrice.multiply(subConIaPa))
+                    .add(subConBfwPrice.multiply(subConBfw))
+                    .add(subConEoEgPurgeGasPrice.multiply(subConEoEgPurgeGas))
+                    .add(subConH2FulePrice.multiply(subConH2FrSyngasAsFule)))
+                    .divide((subConHpSteamFrSubNet.add(subConHhpSteam)), 2, RoundingMode.HALF_UP);
+        }
+        BigDecimal subConZfy = subConCostOutput.multiply(subConGljcl);
+        report.setSubConCostOutput(subConCostOutput.toString());
+        report.setSubConZfy(subConZfy.toString());
+
         report.setKbiPcur(crackerLoad.toString());
         report.setKbiEnergyConsumption(crackerEnergyTeTeo.toString());
         report.setKbiAeuEnergyConsumption(crackerEnergyEeKgect.toString());

+ 6 - 0
master/src/main/resources/mybatis/production/TMonthlyProductionPriceMapper.xml

@@ -26,6 +26,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
       left join sys_dept s on s.dept_id = d.dept_id
     </sql>
 
+    <select id="selectTMonthlyProductionPriceByDate" parameterType="int" resultMap="TMonthlyProductionPriceResult">
+        select *
+        from t_monthly_production_price d
+        where d.report_month = #{reportMonth} and d.report_year = #{reportYear}
+    </select>
+
     <select id="selectTMonthlyProductionPriceCountByDate" parameterType="int" resultType="int">
         select count(id)
         from t_monthly_production_price d