Selaa lähdekoodia

Merge branch 'master' into dev
合并太排放相关代码

王苗苗 7 kuukautta sitten
vanhempi
commit
8294af8bdb

+ 3 - 0
slibra-common/src/main/java/com/slibra/common/constant/MyConstants.java

@@ -104,6 +104,9 @@ public class MyConstants {
     public static final BigDecimal BigDecimal_0_006 = new BigDecimal("0.006");
     public static final BigDecimal BigDecimal_0_7 = new BigDecimal("0.7");
     public static final BigDecimal BigDecimal_1_45 = new BigDecimal("1.45");
+    public static final BigDecimal BigDecimal_1000000000000  = new BigDecimal("1000000000000");
+    public static final BigDecimal BigDecimal_0_0022  = new BigDecimal("0.0022");
+
 
     //温度的范围  超过该温度表示夏季;没有超过表示冬季
     public static final String TEMPERATURE_VALUE = "12";

+ 8 - 0
slibra-system/src/main/java/com/slibra/business/domain/TXinyiCarbonExtra.java

@@ -48,6 +48,14 @@ public class TXinyiCarbonExtra extends BaseEntity
     @Excel(name = "数量")
     private BigDecimal amount;
 
+    /** 厌氧消化沼气富余热能利用量/污泥焚烧或热解热能利用量 */
+    @Excel(name = "厌氧消化沼气富余热能利用量/污泥焚烧或热解热能利用量")
+    private BigDecimal lyl;
+
+    /** 沼气提纯并网的天然气量/对应焓值 */
+    @Excel(name = "沼气提纯并网的天然气量/对应焓值")
+    private BigDecimal hz;
+
     /** 值 */
     @Excel(name = "值")
     private BigDecimal val;

+ 87 - 83
slibra-system/src/main/java/com/slibra/business/service/impl/TXinyiCarbonMajorServiceImpl.java

@@ -3,7 +3,6 @@ package com.slibra.business.service.impl;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
-import java.util.stream.Collectors;
 
 import com.alibaba.fastjson2.JSON;
 import com.slibra.business.domain.TXinyiCarbonExtra;
@@ -29,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import static com.slibra.common.constant.MyConstants.*;
+import static org.apache.el.lang.ELArithmetic.divide;
 
 /**
  * 碳排放主Service业务层处理
@@ -99,12 +99,25 @@ public class TXinyiCarbonMajorServiceImpl implements ITXinyiCarbonMajorService
         int i = tXinyiCarbonMajorMapper.insertTXinyiCarbonMajor(tXinyiCarbonMajor);
         Long id = tXinyiCarbonMajor.getId();
         log.info("要保存的主表的碳核查智能体的记录ID为{}", id);
+        //查看污水厂所在区域电力行业的平均CO2当量排放因子(kg CO2-eq/(kW·h))
+        Long provinceId = tXinyiCarbonMajor.getProvinceId();
+        BigDecimal yz = null;
+        if(!Objects.isNull(provinceId)) {
+            SysDictData sysDictData = this.sysDictDataMapper.selectDictDataById(provinceId);
+            if (Objects.nonNull(sysDictData)) {
+                String dictValue = sysDictData.getDictValue();
+                if (StringUtils.isNotBlank(dictValue)) {
+                    yz = new BigDecimal(dictValue);
+                }
+            }
+        }
+
         //处理关联表
         List<TXinyiCarbonExtra> extraList = tXinyiCarbonMajor.getExtraList();
         if(!CollectionUtils.isEmpty(extraList)){
             for (TXinyiCarbonExtra tXinyiCarbonExtra : extraList) {
                 tXinyiCarbonExtra.setMajorId(id);
-                tXinyiCarbonExtra.setVal(this.calculate(tXinyiCarbonExtra));//需要单独计算
+                tXinyiCarbonExtra.setVal(this.calculate(tXinyiCarbonExtra, yz));//需要单独计算
                 tXinyiCarbonExtra.setCreateTime(nowDate);
                 tXinyiCarbonExtra.setCreateBy(username);
                 this.xinyiCarbonExtraMapper.insertTXinyiCarbonExtra(tXinyiCarbonExtra);
@@ -191,72 +204,62 @@ public class TXinyiCarbonMajorServiceImpl implements ITXinyiCarbonMajorService
 
         //------------能源、药剂排放------------
         //耗电相关
-        Long provinceId = tXinyiCarbonMajor.getProvinceId();
         BigDecimal nyyjTotalCo2 = BigDecimal.ZERO;
-        BigDecimal yz = null;
         BigDecimal nyyjDlxhZhdlCo2 = null;
-        if(!Objects.isNull(provinceId)){
-            SysDictData sysDictData = this.sysDictDataMapper.selectDictDataById(provinceId);
-            if(Objects.nonNull(sysDictData)){
-                String dictValue = sysDictData.getDictValue();
-                if(StringUtils.isNotBlank(dictValue)){
-                    yz = new BigDecimal(dictValue);
-
-                    //总耗电
-                    BigDecimal nyyjDlxhZhdl = tXinyiCarbonMajor.getNyyjDlxhZhdl();
-                    if(!Objects.isNull(nyyjDlxhZhdl)){
-                        nyyjDlxhZhdlCo2 = nyyjDlxhZhdl.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP);
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhZhdlCo2(nyyjDlxhZhdlCo2);
-                    }
+        if(!Objects.isNull(yz)){
+            //总耗电
+            BigDecimal nyyjDlxhZhdl = tXinyiCarbonMajor.getNyyjDlxhZhdl();
+            if(!Objects.isNull(nyyjDlxhZhdl)){
+                nyyjDlxhZhdlCo2 = nyyjDlxhZhdl.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP);
+                tXinyiCarbonMajorUpdate.setNyyjDlxhZhdlCo2(nyyjDlxhZhdlCo2);
+            }
 
-                    //进水泵房
-                    BigDecimal nyyjDlxhJsbf = tXinyiCarbonMajor.getNyyjDlxhJsbf();
-                    if(!Objects.isNull(nyyjDlxhJsbf)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhJsbfCo2(nyyjDlxhJsbf.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
+            //进水泵房
+            BigDecimal nyyjDlxhJsbf = tXinyiCarbonMajor.getNyyjDlxhJsbf();
+            if(!Objects.isNull(nyyjDlxhJsbf)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhJsbfCo2(nyyjDlxhJsbf.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
+            }
 
-                    //鼓风机房
-                    BigDecimal nyyjDlxhGfjf = tXinyiCarbonMajor.getNyyjDlxhGfjf();
-                    if(!Objects.isNull(nyyjDlxhGfjf)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhGfjfCo2(nyyjDlxhGfjf.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
+            //鼓风机房
+            BigDecimal nyyjDlxhGfjf = tXinyiCarbonMajor.getNyyjDlxhGfjf();
+            if(!Objects.isNull(nyyjDlxhGfjf)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhGfjfCo2(nyyjDlxhGfjf.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
+            }
 
-                    //脱水机房
-                    BigDecimal nyyjDlxhTsjf = tXinyiCarbonMajor.getNyyjDlxhTsjf();
-                    if(!Objects.isNull(nyyjDlxhTsjf)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhTsjfCo2(nyyjDlxhTsjf.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
+            //脱水机房
+            BigDecimal nyyjDlxhTsjf = tXinyiCarbonMajor.getNyyjDlxhTsjf();
+            if(!Objects.isNull(nyyjDlxhTsjf)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhTsjfCo2(nyyjDlxhTsjf.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
+            }
 
-                    //消毒间
-                    BigDecimal nyyjDlxhXdj = tXinyiCarbonMajor.getNyyjDlxhXdj();
-                    if(!Objects.isNull(nyyjDlxhXdj)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhXdjCo2(nyyjDlxhXdj.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
+            //消毒间
+            BigDecimal nyyjDlxhXdj = tXinyiCarbonMajor.getNyyjDlxhXdj();
+            if(!Objects.isNull(nyyjDlxhXdj)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhXdjCo2(nyyjDlxhXdj.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
+            }
 
-                    //深度处理用电
-                    BigDecimal nyyjDlxhSdcl = tXinyiCarbonMajor.getNyyjDlxhSdcl();
-                    if(!Objects.isNull(nyyjDlxhSdcl)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhSdclCo2(nyyjDlxhSdcl.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
+            //深度处理用电
+            BigDecimal nyyjDlxhSdcl = tXinyiCarbonMajor.getNyyjDlxhSdcl();
+            if(!Objects.isNull(nyyjDlxhSdcl)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhSdclCo2(nyyjDlxhSdcl.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
+            }
 
-                    //污泥处置
-                    BigDecimal nyyjDlxhWncz = tXinyiCarbonMajor.getNyyjDlxhWncz();
-                    if(!Objects.isNull(nyyjDlxhWncz)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhWnczCo2(nyyjDlxhWncz.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
+            //污泥处置
+            BigDecimal nyyjDlxhWncz = tXinyiCarbonMajor.getNyyjDlxhWncz();
+            if(!Objects.isNull(nyyjDlxhWncz)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhWnczCo2(nyyjDlxhWncz.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
+            }
 
-                    //生活区
-                    BigDecimal nyyjDlxhShq = tXinyiCarbonMajor.getNyyjDlxhShq();
-                    if(!Objects.isNull(nyyjDlxhShq)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhShqCo2(nyyjDlxhShq.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
+            //生活区
+            BigDecimal nyyjDlxhShq = tXinyiCarbonMajor.getNyyjDlxhShq();
+            if(!Objects.isNull(nyyjDlxhShq)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhShqCo2(nyyjDlxhShq.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
+            }
 
-                    //其他耗电区
-                    BigDecimal nyyjDlxhQt = tXinyiCarbonMajor.getNyyjDlxhQt();
-                    if(!Objects.isNull(nyyjDlxhQt)){
-                        tXinyiCarbonMajorUpdate.setNyyjDlxhQtCo2(nyyjDlxhQt.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
-                    }
-                }
+            //其他耗电区
+            BigDecimal nyyjDlxhQt = tXinyiCarbonMajor.getNyyjDlxhQt();
+            if(!Objects.isNull(nyyjDlxhQt)){
+                tXinyiCarbonMajorUpdate.setNyyjDlxhQtCo2(nyyjDlxhQt.multiply(yz).divide(BigDecimal_1000, NUMBER_SCALE_2, RoundingMode.HALF_UP));
             }
         }
 
@@ -513,21 +516,19 @@ public class TXinyiCarbonMajorServiceImpl implements ITXinyiCarbonMajorService
         //计算各个大类和总的co2
         tXinyiCarbonMajorUpdate.setZtTotalCo2(wsclTotalCo2.add(nyyjTotalCo2).add(wnclTotalCo2).subtract(ttthTotalCo2));
 
-        //一对多的的计算的存在问题。 todo
-
         //处理百分比信息
         if(nyyjTotalCo2.compareTo(BigDecimal.ZERO) > 0){//必须是正数
             if(!Objects.isNull(nyyjDlxhZhdlCo2)){
-                tXinyiCarbonMajorUpdate.setDlxhPercent(nyyjDlxhZhdlCo2.divide(nyyjTotalCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                tXinyiCarbonMajorUpdate.setDlxhPercent(nyyjDlxhZhdlCo2.divide(nyyjTotalCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP));
             }
             if(!Objects.isNull(wscljdyjxhCo2)){
-                tXinyiCarbonMajorUpdate.setYjxhPercent(wscljdyjxhCo2.divide(nyyjTotalCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                tXinyiCarbonMajorUpdate.setYjxhPercent(wscljdyjxhCo2.divide(nyyjTotalCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP));
             }
             if(!Objects.isNull(nyyjGrrlCo2)){
-                tXinyiCarbonMajorUpdate.setJgrrlPercent(nyyjGrrlCo2.divide(nyyjTotalCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                tXinyiCarbonMajorUpdate.setJgrrlPercent(nyyjGrrlCo2.divide(nyyjTotalCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP));
             }
             if(!Objects.isNull(gdsnyrlCo2)){
-                tXinyiCarbonMajorUpdate.setRlxhPercent(gdsnyrlCo2.divide(nyyjTotalCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                tXinyiCarbonMajorUpdate.setRlxhPercent(gdsnyrlCo2.divide(nyyjTotalCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP));
             }
         }
 
@@ -536,7 +537,7 @@ public class TXinyiCarbonMajorServiceImpl implements ITXinyiCarbonMajorService
         BigDecimal ztTotalCo2 = tXinyiCarbonMajorUpdate.getZtTotalCo2();
         if(!Objects.isNull(avgJsl) && !Objects.isNull(ztTotalCo2)){
             //2024年08月27日09:36:14 计算公式有调整:再乘以10的三次方。
-            BigDecimal wschytpfqd = ztTotalCo2.divide(avgJsl, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_1000);
+            BigDecimal wschytpfqd = ztTotalCo2.divide(avgJsl, NUMBER_SCALE_2, RoundingMode.HALF_UP).multiply(BigDecimal_1000);
             tXinyiCarbonMajorUpdate.setWschytpfqd(wschytpfqd);
             BigDecimal avgCod = this.tXinyiCarbonMajorMapper.selectAvgCodByMonth(addYearMonth.replaceAll("-", "/"));
             //从字典获取不同cod对应的标准
@@ -566,38 +567,41 @@ public class TXinyiCarbonMajorServiceImpl implements ITXinyiCarbonMajorService
     }
 
     /**
-     *
      * 明细字段的计算处理
      * 类型放入到值集中,然后再判断
+     *
      * @param tXinyiCarbonExtra
+     * @param yz
      * @return
      */
-    private BigDecimal calculate(TXinyiCarbonExtra tXinyiCarbonExtra) {
-//        int type = tXinyiCarbonExtra.getType();
+    private BigDecimal calculate(TXinyiCarbonExtra tXinyiCarbonExtra, BigDecimal yz) {
+        int type = tXinyiCarbonExtra.getType();
         BigDecimal amount = tXinyiCarbonExtra.getAmount();
+        BigDecimal lyl = tXinyiCarbonExtra.getLyl();
+        BigDecimal hz = tXinyiCarbonExtra.getHz();
         SysDictData sysDictData = this.sysDictDataMapper.selectDictDataById(tXinyiCarbonExtra.getDictCode());
         if(Objects.isNull(sysDictData)){
             throw new ServiceException("没有查询到对应的配置项");
         }
-        /*if(type == BusinessEnum.CarbonExtraTeypEnum.ZERO.getCode()){
-
+        //2024年08月30日14:08:19 计算公式 不统一,并且字段不太一致,所以需要TXinyiCarbonExtra表新增2个字段,代表四个含义。
+        if(type == BusinessEnum.CarbonExtraTeypEnum.ZERO.getCode()){
+            return amount.multiply(new BigDecimal(sysDictData.getDictValue()).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP));
         }else if(type == BusinessEnum.CarbonExtraTeypEnum.ONE.getCode()){
-
+            return amount.multiply(new BigDecimal(sysDictData.getDictValue()).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP));
         }else if(type == BusinessEnum.CarbonExtraTeypEnum.TWO.getCode()){
-
+            return amount.multiply(new BigDecimal(sysDictData.getDictValue()).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP));
         }else if(type == BusinessEnum.CarbonExtraTeypEnum.THREE.getCode()){
-
+            return amount.multiply(new BigDecimal(sysDictData.getDictValue()).divide(BigDecimal_1000000000000,NUMBER_SCALE_2, RoundingMode.HALF_UP));
         }else if(type == BusinessEnum.CarbonExtraTeypEnum.FOUR.getCode()){
-
+            return Objects.isNull(yz) ? null : (amount.multiply(yz).add((lyl.multiply(new BigDecimal(sysDictData.getDictValue()))).add((hz.multiply(BigDecimal_0_0022))))).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP);
         }else if(type == BusinessEnum.CarbonExtraTeypEnum.FIVE.getCode()){
-
+            return Objects.isNull(yz) ? null : (amount.multiply(yz).add((lyl.multiply(hz.subtract(BigDecimal_83_74)).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP))).multiply(new BigDecimal(sysDictData.getDictValue())).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP)).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP);
         }else {
             log.error("暂不支持的类型");
             throw new ServiceException("暂不支持的类型");
         }
-        return null;*/
         //2024年08月28日17:43:58 所有的公式都统一了,都采用下面的方式【感谢郭京京】
-        return amount.multiply(new BigDecimal(sysDictData.getDictValue()).divide(BigDecimal_1000,NUMBER_SCALE_4, RoundingMode.HALF_UP));
+//        return amount.multiply(new BigDecimal(sysDictData.getDictValue()).divide(BigDecimal_1000,NUMBER_SCALE_2, RoundingMode.HALF_UP));
     }
 
     /**
@@ -680,35 +684,35 @@ public class TXinyiCarbonMajorServiceImpl implements ITXinyiCarbonMajorService
             BigDecimal nowCo2 = tXinyiCarbonMajorLastMonth.getWsclTotalCo2();
             BigDecimal lastMonthCo2 = tXinyiCarbonMajor.getWsclTotalCo2();
             if(!Objects.isNull(nowCo2) && !Objects.isNull(lastMonthCo2)){
-                tXinyiCarbonMajor.setWsclTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP) ,NUMBER_SCALE_4));
+                tXinyiCarbonMajor.setWsclTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP) ,NUMBER_SCALE_2));
             }
 
             //能源、药剂碳排量-环比上个月
             nowCo2 = tXinyiCarbonMajorLastMonth.getNyyjTotalCo2();
             lastMonthCo2 = tXinyiCarbonMajor.getNyyjTotalCo2();
             if(!Objects.isNull(nowCo2) && !Objects.isNull(lastMonthCo2)){
-                tXinyiCarbonMajor.setNyyjTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP) ,NUMBER_SCALE_4));
+                tXinyiCarbonMajor.setNyyjTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP) ,NUMBER_SCALE_2));
             }
 
             //污泥处理碳排量-环比上个月
             nowCo2 = tXinyiCarbonMajorLastMonth.getWnclTotalCo2();
             lastMonthCo2 = tXinyiCarbonMajor.getWnclTotalCo2();
             if(!Objects.isNull(nowCo2) && !Objects.isNull(lastMonthCo2)){
-                tXinyiCarbonMajor.setWnclTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP) ,NUMBER_SCALE_4));
+                tXinyiCarbonMajor.setWnclTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP) ,NUMBER_SCALE_2));
             }
 
             //替碳、碳汇替碳量-环比上个月
             nowCo2 = tXinyiCarbonMajorLastMonth.getTtthTotalCo2();
             lastMonthCo2 = tXinyiCarbonMajor.getTtthTotalCo2();
             if(!Objects.isNull(nowCo2) && !Objects.isNull(lastMonthCo2)){
-                tXinyiCarbonMajor.setTtthTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP) ,NUMBER_SCALE_4));
+                tXinyiCarbonMajor.setTtthTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP) ,NUMBER_SCALE_2));
             }
 
             //总碳排放量-环比上个月
             nowCo2 = tXinyiCarbonMajorLastMonth.getZtTotalCo2();
             lastMonthCo2 = tXinyiCarbonMajor.getZtTotalCo2();
             if(!Objects.isNull(nowCo2) && !Objects.isNull(lastMonthCo2)){
-                tXinyiCarbonMajor.setZtTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_4, RoundingMode.HALF_UP) ,NUMBER_SCALE_4));
+                tXinyiCarbonMajor.setZtTotalCo2Hb(DecimalUtils.getAbsAndScale((nowCo2.subtract(lastMonthCo2)).divide(lastMonthCo2, NUMBER_SCALE_2, RoundingMode.HALF_UP) ,NUMBER_SCALE_2));
             }
         }
         //最近7个月的数据集合
@@ -728,7 +732,7 @@ public class TXinyiCarbonMajorServiceImpl implements ITXinyiCarbonMajorService
                 //获取某个月份的平均进水cod
                 BigDecimal avgJsl = this.tXinyiCarbonMajorMapper.selectSumJslByMonth(addYearMonthTmp.replaceAll("-", "/"));
                 if(!Objects.isNull(avgJsl) && !Objects.isNull(ztTotalCo2)){
-                    chartBasic.setWschytpfqd(ztTotalCo2.divide(avgJsl, NUMBER_SCALE_4, RoundingMode.HALF_UP));
+                    chartBasic.setWschytpfqd(ztTotalCo2.divide(avgJsl, NUMBER_SCALE_2, RoundingMode.HALF_UP));
                 }
                 recent7PflDatas.add(chartBasic);
             }

+ 19 - 9
slibra-system/src/main/resources/mapper/business/TXinyiCarbonExtraMapper.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.slibra.business.mapper.TXinyiCarbonExtraMapper">
-    
+
     <resultMap type="TXinyiCarbonExtra" id="TXinyiCarbonExtraResult">
         <result property="id"    column="id"    />
         <result property="majorId"    column="major_id"    />
@@ -11,6 +11,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="dictLabel"    column="dict_label"    />
         <result property="type"    column="type"    />
         <result property="amount"    column="amount"    />
+        <result property="lyl"    column="lyl"    />
+        <result property="hz"    column="hz"    />
         <result property="val"    column="val"    />
         <result property="delFlag"    column="del_flag"    />
         <result property="revision"    column="revision"    />
@@ -21,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTXinyiCarbonExtraVo">
-        select id, major_id, dict_code, dict_label, type, amount, val, del_flag, revision, create_by, create_time, update_by, update_time from t_xinyi_carbon_extra
+        select id, major_id, dict_code, dict_label, type, amount, lyl, hz, val, del_flag, revision, create_by, create_time, update_by, update_time from t_xinyi_carbon_extra
     </sql>
 
     <select id="selectTXinyiCarbonExtraList" parameterType="TXinyiCarbonExtra" resultMap="TXinyiCarbonExtraResult">
@@ -33,17 +35,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="dictLabel != null  and dictLabel != ''"> and dict_label = #{dictLabel}</if>
             <if test="type != null "> and type = #{type}</if>
             <if test="amount != null "> and amount = #{amount}</if>
+            <if test="lyl != null "> and lyl = #{lyl}</if>
+            <if test="hz != null "> and hz = #{hz}</if>
             <if test="val != null "> and val = #{val}</if>
             <if test="revision != null "> and revision = #{revision}</if>
         </where>
         and del_flag = 0 order by id desc
     </select>
-    
+
     <select id="selectTXinyiCarbonExtraById" parameterType="Long" resultMap="TXinyiCarbonExtraResult">
         <include refid="selectTXinyiCarbonExtraVo"/>
         where id = #{id} and del_flag = 0
     </select>
-        
+
     <insert id="insertTXinyiCarbonExtra" parameterType="TXinyiCarbonExtra" useGeneratedKeys="true" keyProperty="id">
         insert into t_xinyi_carbon_extra
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -52,6 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="dictLabel != null">dict_label,</if>
             <if test="type != null">type,</if>
             <if test="amount != null">amount,</if>
+            <if test="lyl != null">lyl,</if>
+            <if test="hz != null">hz,</if>
             <if test="val != null">val,</if>
             <if test="delFlag != null">del_flag,</if>
             <if test="revision != null">revision,</if>
@@ -59,13 +65,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="majorId != null">#{majorId},</if>
             <if test="dictCode != null">#{dictCode},</if>
             <if test="dictLabel != null">#{dictLabel},</if>
             <if test="type != null">#{type},</if>
             <if test="amount != null">#{amount},</if>
+            <if test="lyl != null">#{lyl},</if>
+            <if test="hz != null">#{hz},</if>
             <if test="val != null">#{val},</if>
             <if test="delFlag != null">#{delFlag},</if>
             <if test="revision != null">#{revision},</if>
@@ -73,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateTXinyiCarbonExtra" parameterType="TXinyiCarbonExtra">
@@ -84,6 +92,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="dictLabel != null">dict_label = #{dictLabel},</if>
             <if test="type != null">type = #{type},</if>
             <if test="amount != null">amount = #{amount},</if>
+            <if test="lyl != null">lyl = #{lyl},</if>
+            <if test="hz != null">hz = #{hz},</if>
             <if test="val != null">val = #{val},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="revision != null">revision = #{revision},</if>
@@ -96,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </update>
 
-    
+
 
     <delete id="deleteTXinyiCarbonExtraById" parameterType="Long">
         update t_xinyi_carbon_extra set del_flag = 2,revision = revision + 1 where del_flag = 0 and id = #{id}