package com.ruoyi.project.production.controller;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.ExcelUtils;
import com.ruoyi.framework.config.RuoYiConfig;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.production.controller.vo.*;
import com.ruoyi.project.production.domain.*;
import com.ruoyi.project.production.service.*;
import com.ruoyi.project.system.service.ISysUserService;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 质量月报Controller
 *
 * @author ruoyi
 * @date 2023-10-27
 */
@RestController
@RequestMapping("/production/quality")
public class TMonthlyQualityReportController extends BaseController
{
    @Autowired
    private ISysUserService userService;

    @Autowired
    private ITMonthlyQualityReportS0501Service tMonthlyQualityReportS0501Service;

    @Autowired
    private ITMonthlyQualityReportS1301Service tMonthlyQualityReportS1301Service;

    @Autowired
    private ITMonthlyQualityReportS2002Service tMonthlyQualityReportS2002Service;

    @Autowired
    private ITMonthlyQualityReportS2005Service tMonthlyQualityReportS2005Service;

    @Autowired
    private ITMonthlyQualityReportS2007Service tMonthlyQualityReportS2007Service;

    @Autowired
    private ITMonthlyQualityReportS2011Service tMonthlyQualityReportS2011Service;

    @Autowired
    private ITMonthlyQualityReportS2400Service tMonthlyQualityReportS2400Service;

    @Autowired
    private ITMonthlyQualityReportS3004Service tMonthlyQualityReportS3004Service;

    @Autowired
    private ITMonthlyQualityReportS3009Service tMonthlyQualityReportS3009Service;

    @Autowired
    private ITMonthlyQualityReportS3010Service tMonthlyQualityReportS3010Service;

    @Autowired
    private ITMonthlyQualityReportS3011Service tMonthlyQualityReportS3011Service;

    @Autowired
    private ITMonthlyQualityReportS3012Service tMonthlyQualityReportS3012Service;

    @Autowired
    private ITMonthlyQualityReportS3022Service tMonthlyQualityReportS3022Service;

    @Autowired
    private ITMonthlyQualityReportS4012Service tMonthlyQualityReportS4012Service;

    @Autowired
    private ITMonthlyQualityReportS4013Service tMonthlyQualityReportS4013Service;

    @Autowired
    private ITMonthlyQualityReportS4501Service tMonthlyQualityReportS4501Service;

    @Autowired
    private ITMonthlyQualityReportS5001Service tMonthlyQualityReportS5001Service;

    @Autowired
    private ITMonthlyQualityReportS5003Service tMonthlyQualityReportS5003Service;

    @Autowired
    private ITMonthlyQualityReportS5010Service tMonthlyQualityReportS5010Service;

    @Autowired
    private ITMonthlyQualityReportS5012Service tMonthlyQualityReportS5012Service;

    @Autowired
    private ITMonthlyQualityReportS6101Service tMonthlyQualityReportS6101Service;

    @Autowired
    private ITMonthlyQualityReportS6107Service tMonthlyQualityReportS6107Service;

    @Autowired
    private ITMonthlyQualityReportS6301Service tMonthlyQualityReportS6301Service;

    @Autowired
    private ITMonthlyQualityReportZ404Service tMonthlyQualityReportZ404Service;

    @Autowired
    private ITMonthlyQualityCommentService tMonthlyQualityCommentService;

    @GetMapping("/yearMonth")
    public AjaxResult yearMonth() {
        String[] strings = tMonthlyQualityReportS0501Service.selectTMonthlyQualityReportYearMonth();
        return AjaxResult.success(strings);
    }

    /**
     * 批量删除
     */
    @PostMapping("/remove")
    public AjaxResult remove(MonthlyQualityRemoveVO vo) {
        tMonthlyQualityReportS0501Service.deleteTMonthlyQualityReportBranch(vo);
        return AjaxResult.success();
    }

    /**
     * 碳二反应器性能指标趋势图
     */
    @PreAuthorize("@ss.hasPermi('production:quality:list')")
    @GetMapping("/c2ReactorAnalysis")
    public AjaxResult c2ReactorAnalysis(MonthlyQualityReportQueryVO vo)
    {
        Date startDate = vo.getStartDate();
        Date endDate = vo.getEndDate();
        int startYear = startDate.getYear() + 1900;
        int endYear = endDate.getYear() + 1900;
        int startMonth = startDate.getMonth() + 1;
        int endMonth = endDate.getMonth() + 1;
        Map<String, C2ReactorAnalysisVO> dataMap = new HashMap<>();

        for (int i = 0; i < 12; i++) {
                //1st inlet
                TMonthlyQualityReportS3009 tMonthlyQualityReportS3009 = new TMonthlyQualityReportS3009();
                tMonthlyQualityReportS3009.setStartDate(startDate);
                tMonthlyQualityReportS3009.setEndDate(endDate);
                List<TMonthlyQualityReportS3009> tMonthlyQualityReportS3009s = tMonthlyQualityReportS3009Service.selectTMonthlyQualityReportS3009List(tMonthlyQualityReportS3009);
                //3rd outlet
                TMonthlyQualityReportS3010 tMonthlyQualityReportS3010 = new TMonthlyQualityReportS3010();
                tMonthlyQualityReportS3010.setStartDate(startDate);
                tMonthlyQualityReportS3010.setEndDate(endDate);
                List<TMonthlyQualityReportS3010> tMonthlyQualityReportS3010s = tMonthlyQualityReportS3010Service.selectTMonthlyQualityReportS3010List(tMonthlyQualityReportS3010);
                //2nd inlet
                TMonthlyQualityReportS3011 tMonthlyQualityReportS3011 = new TMonthlyQualityReportS3011();
                tMonthlyQualityReportS3011.setStartDate(startDate);
                tMonthlyQualityReportS3011.setEndDate(endDate);
                List<TMonthlyQualityReportS3011> tMonthlyQualityReportS3011s = tMonthlyQualityReportS3011Service.selectTMonthlyQualityReportS3011List(tMonthlyQualityReportS3011);
                //3rd inlet
                TMonthlyQualityReportS3012 tMonthlyQualityReportS3012 = new TMonthlyQualityReportS3012();
                tMonthlyQualityReportS3012.setStartDate(startDate);
                tMonthlyQualityReportS3012.setEndDate(endDate);
                List<TMonthlyQualityReportS3012> tMonthlyQualityReportS3012s = tMonthlyQualityReportS3012Service.selectTMonthlyQualityReportS3012List(tMonthlyQualityReportS3012);
                //avg
                BigDecimal ethane1InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene1InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene1InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane1InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene1InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd1InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma1InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethane3OutAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene3OutAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene3OutAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane3OutAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene3OutAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd3OutAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma3OutAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethane2InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene2InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene2InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane2InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene2InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd2InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma2InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethane3InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene3InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene3InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane3InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene3InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd3InAvg = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma3InAvg = new BigDecimal(BigInteger.ZERO);
                //sum
                BigDecimal ethane1InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene1InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene1InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane1InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene1InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd1InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma1InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethane3OutSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene3OutSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene3OutSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane3OutSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene3OutSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd3OutSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma3OutSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethane2InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene2InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene2InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane2InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene2InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd2InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma2InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethane3InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethylene3InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetylene3InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propane3InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal propylene3InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal pd3InSum = new BigDecimal(BigInteger.ZERO);
                BigDecimal ma3InSum = new BigDecimal(BigInteger.ZERO);
                //list
                ArrayList<BigDecimal> ethane1InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ethylene1InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> acetylene1InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propane1InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propylene1InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> pd1InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ma1InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ethane3OutList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ethylene3OutList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> acetylene3OutList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propane3OutList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propylene3OutList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> pd3OutList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ma3OutList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ethane2InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ethylene2InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> acetylene2InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propane2InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propylene2InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> pd2InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ma2InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ethane3InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ethylene3InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> acetylene3InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propane3InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> propylene3InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> pd3InList = new ArrayList<BigDecimal>();
                ArrayList<BigDecimal> ma3InList = new ArrayList<BigDecimal>();
                //放入list
                for (TMonthlyQualityReportS3009 monthlyQualityReportS3009 : tMonthlyQualityReportS3009s) {
                    String ethane = monthlyQualityReportS3009.getEthane();
                    String ethylene = monthlyQualityReportS3009.getEthylene();
                    String acetylene = monthlyQualityReportS3009.getAcetylene();
                    String propane = monthlyQualityReportS3009.getPropane();
                    String propylene = monthlyQualityReportS3009.getPropylene();
                    String pd = monthlyQualityReportS3009.getPropadiene();
                    String ma = monthlyQualityReportS3009.getMethylacetylene();
                    if (StringUtils.isNotEmpty(ethane)) { ethane1InList.add(new BigDecimal(ethane)); }
                    if (StringUtils.isNotEmpty(ethylene)) { ethylene1InList.add(new BigDecimal(ethylene)); }
                    if (StringUtils.isNotEmpty(acetylene)) { acetylene1InList.add(new BigDecimal(acetylene)); }
                    if (StringUtils.isNotEmpty(propane)) { propane1InList.add(new BigDecimal(propane)); }
                    if (StringUtils.isNotEmpty(propylene)) { propylene1InList.add(new BigDecimal(propylene)); }
                    if (StringUtils.isNotEmpty(pd)) { pd1InList.add(new BigDecimal(pd)); }
                    if (StringUtils.isNotEmpty(ma)) { ma1InList.add(new BigDecimal(ma)); }
                }
                for (TMonthlyQualityReportS3010 monthlyQualityReportS3010 : tMonthlyQualityReportS3010s) {
                    String ethane = monthlyQualityReportS3010.getEthane();
                    String ethylene = monthlyQualityReportS3010.getEthylene();
                    String acetylene = monthlyQualityReportS3010.getAcetylene();
                    String propane = monthlyQualityReportS3010.getPropane();
                    String propylene = monthlyQualityReportS3010.getPropylene();
                    String pd = monthlyQualityReportS3010.getPropadiene();
                    String ma = monthlyQualityReportS3010.getMethylacetylene();
                    if (StringUtils.isNotEmpty(ethane)) { ethane3OutList.add(new BigDecimal(ethane)); }
                    if (StringUtils.isNotEmpty(ethylene)) { ethylene3OutList.add(new BigDecimal(ethylene)); }
                    if (StringUtils.isNotEmpty(acetylene)) { acetylene3OutList.add(new BigDecimal(acetylene)); }
                    if (StringUtils.isNotEmpty(propane)) { propane3OutList.add(new BigDecimal(propane)); }
                    if (StringUtils.isNotEmpty(propylene)) { propylene3OutList.add(new BigDecimal(propylene)); }
                    if (StringUtils.isNotEmpty(pd)) { pd3OutList.add(new BigDecimal(pd)); }
                    if (StringUtils.isNotEmpty(ma)) { ma3OutList.add(new BigDecimal(ma)); }
                }
                for (TMonthlyQualityReportS3011 monthlyQualityReportS3011 : tMonthlyQualityReportS3011s) {
                    String ethane = monthlyQualityReportS3011.getEthane();
                    String ethylene = monthlyQualityReportS3011.getEthylene();
                    String acetylene = monthlyQualityReportS3011.getAcetylene();
                    String propane = monthlyQualityReportS3011.getPropane();
                    String propylene = monthlyQualityReportS3011.getPropylene();
                    String pd = monthlyQualityReportS3011.getPropadiene();
                    String ma = monthlyQualityReportS3011.getMethylacetylene();
                    if (StringUtils.isNotEmpty(ethane)) { ethane2InList.add(new BigDecimal(ethane)); }
                    if (StringUtils.isNotEmpty(ethylene)) { ethylene2InList.add(new BigDecimal(ethylene)); }
                    if (StringUtils.isNotEmpty(acetylene)) { acetylene2InList.add(new BigDecimal(acetylene)); }
                    if (StringUtils.isNotEmpty(propane)) { propane2InList.add(new BigDecimal(propane)); }
                    if (StringUtils.isNotEmpty(propylene)) { propylene2InList.add(new BigDecimal(propylene)); }
                    if (StringUtils.isNotEmpty(pd)) { pd2InList.add(new BigDecimal(pd)); }
                    if (StringUtils.isNotEmpty(ma)) { ma2InList.add(new BigDecimal(ma)); }
                }
                for (TMonthlyQualityReportS3012 monthlyQualityReportS3012 : tMonthlyQualityReportS3012s) {
                    String ethane = monthlyQualityReportS3012.getEthane();
                    String ethylene = monthlyQualityReportS3012.getEthylene();
                    String acetylene = monthlyQualityReportS3012.getAcetylene();
                    String propane = monthlyQualityReportS3012.getPropane();
                    String propylene = monthlyQualityReportS3012.getPropylene();
                    String pd = monthlyQualityReportS3012.getPropadiene();
                    String ma = monthlyQualityReportS3012.getMethylacetylene();
                    if (StringUtils.isNotEmpty(ethane)) { ethane3InList.add(new BigDecimal(ethane)); }
                    if (StringUtils.isNotEmpty(ethylene)) { ethylene3InList.add(new BigDecimal(ethylene)); }
                    if (StringUtils.isNotEmpty(acetylene)) { acetylene3InList.add(new BigDecimal(acetylene)); }
                    if (StringUtils.isNotEmpty(propane)) { propane3InList.add(new BigDecimal(propane)); }
                    if (StringUtils.isNotEmpty(propylene)) { propylene3InList.add(new BigDecimal(propylene)); }
                    if (StringUtils.isNotEmpty(pd)) { pd3InList.add(new BigDecimal(pd)); }
                    if (StringUtils.isNotEmpty(ma)) { ma3InList.add(new BigDecimal(ma)); }
                }
                //计算sum
                for (BigDecimal value : ethane1InList) { ethane1InSum = ethane1InSum.add(value); }
                for (BigDecimal value : ethylene1InList) { ethylene1InSum = ethylene1InSum.add(value); }
                for (BigDecimal value : acetylene1InList) { acetylene1InSum = acetylene1InSum.add(value); }
                for (BigDecimal value : propane1InList) { propane1InSum = propane1InSum.add(value); }
                for (BigDecimal value : propylene1InList) { propylene1InSum = propylene1InSum.add(value); }
                for (BigDecimal value : pd1InList) { pd1InSum = pd1InSum.add(value); }
                for (BigDecimal value : ma1InList) { ma1InSum = ma1InSum.add(value); }
                for (BigDecimal value : ethane3OutList) { ethane3OutSum = ethane3OutSum.add(value); }
                for (BigDecimal value : ethylene3OutList) { ethylene3OutSum = ethylene3OutSum.add(value); }
                for (BigDecimal value : acetylene3OutList) { acetylene3OutSum = acetylene3OutSum.add(value); }
                for (BigDecimal value : propane3OutList) { propane3OutSum = propane3OutSum.add(value); }
                for (BigDecimal value : propylene3OutList) { propylene3OutSum = propylene3OutSum.add(value); }
                for (BigDecimal value : pd3OutList) { pd3OutSum = pd3OutSum.add(value); }
                for (BigDecimal value : ma3OutList) { ma3OutSum = ma3OutSum.add(value); }
                for (BigDecimal value : ethane2InList) { ethane2InSum = ethane2InSum.add(value); }
                for (BigDecimal value : ethylene2InList) { ethylene2InSum = ethylene2InSum.add(value); }
                for (BigDecimal value : acetylene2InList) { acetylene2InSum = acetylene2InSum.add(value); }
                for (BigDecimal value : propane2InList) { propane2InSum = propane2InSum.add(value); }
                for (BigDecimal value : propylene2InList) { propylene2InSum = propylene2InSum.add(value); }
                for (BigDecimal value : pd2InList) { pd2InSum = pd2InSum.add(value); }
                for (BigDecimal value : ma2InList) { ma2InSum = ma2InSum.add(value); }
                for (BigDecimal value : ethane3InList) { ethane3InSum = ethane3InSum.add(value); }
                for (BigDecimal value : ethylene3InList) { ethylene3InSum = ethylene3InSum.add(value); }
                for (BigDecimal value : acetylene3InList) { acetylene3InSum = acetylene3InSum.add(value); }
                for (BigDecimal value : propane3InList) { propane3InSum = propane3InSum.add(value); }
                for (BigDecimal value : propylene3InList) { propylene3InSum = propylene3InSum.add(value); }
                for (BigDecimal value : pd3InList) { pd3InSum = pd3InSum.add(value); }
                for (BigDecimal value : ma3InList) { ma3InSum = ma3InSum.add(value); }
                //计算avg
                if (ethane1InList.size() != 0) { ethane1InAvg = ethane1InSum.divide(new BigDecimal(ethane1InList.size()), 2, RoundingMode.HALF_UP); }
                if (ethylene1InList.size() != 0) { ethylene1InAvg = ethylene1InSum.divide(new BigDecimal(ethylene1InList.size()), 2, RoundingMode.HALF_UP); }
                if (acetylene1InList.size() != 0) { acetylene1InAvg = acetylene1InSum.divide(new BigDecimal(acetylene1InList.size()), 2, RoundingMode.HALF_UP); }
                if (propane1InList.size() != 0) { propane1InAvg = propane1InSum.divide(new BigDecimal(propane1InList.size()), 2, RoundingMode.HALF_UP); }
                if (propylene1InList.size() != 0) { propylene1InAvg = propylene1InSum.divide(new BigDecimal(propylene1InList.size()), 2, RoundingMode.HALF_UP); }
                if (pd1InList.size() != 0) { pd1InAvg = pd1InSum.divide(new BigDecimal(pd1InList.size()), 2, RoundingMode.HALF_UP); }
                if (ma1InList.size() != 0) { ma1InAvg = ma1InSum.divide(new BigDecimal(ma1InList.size()), 2, RoundingMode.HALF_UP); }
                if (ethane3OutList.size() != 0) { ethane3OutAvg = ethane3OutSum.divide(new BigDecimal(ethane3OutList.size()), 2, RoundingMode.HALF_UP); }
                if (ethylene3OutList.size() != 0) { ethylene3OutAvg = ethylene3OutSum.divide(new BigDecimal(ethylene3OutList.size()), 2, RoundingMode.HALF_UP); }
                if (acetylene3OutList.size() != 0) {
                    acetylene3OutAvg = acetylene3OutSum.divide(new BigDecimal(acetylene3OutList.size()), 2, RoundingMode.HALF_UP)
                            .divide(new BigDecimal("10000"), 5, RoundingMode.HALF_UP);
                }
                if (propane3OutList.size() != 0) { propane3OutAvg = propane3OutSum.divide(new BigDecimal(propane3OutList.size()), 2, RoundingMode.HALF_UP); }
                if (propylene3OutList.size() != 0) { propylene3OutAvg = propylene3OutSum.divide(new BigDecimal(propylene3OutList.size()), 2, RoundingMode.HALF_UP); }
                if (pd3OutList.size() != 0) { pd3OutAvg = pd3OutSum.divide(new BigDecimal(pd3OutList.size()), 2, RoundingMode.HALF_UP); }
                if (ma3OutList.size() != 0) { ma3OutAvg = ma3OutSum.divide(new BigDecimal(ma3OutList.size()), 2, RoundingMode.HALF_UP); }
                if (ethane2InList.size() != 0) { ethane2InAvg = ethane2InSum.divide(new BigDecimal(ethane2InList.size()), 2, RoundingMode.HALF_UP); }
                if (ethylene2InList.size() != 0) { ethylene2InAvg = ethylene2InSum.divide(new BigDecimal(ethylene2InList.size()), 2, RoundingMode.HALF_UP); }
                if (acetylene2InList.size() != 0) { acetylene2InAvg = acetylene2InSum.divide(new BigDecimal(acetylene2InList.size()), 2, RoundingMode.HALF_UP); }
                if (propane2InList.size() != 0) { propane2InAvg = propane2InSum.divide(new BigDecimal(propane2InList.size()), 2, RoundingMode.HALF_UP); }
                if (propylene2InList.size() != 0) { propylene2InAvg = propylene2InSum.divide(new BigDecimal(propylene2InList.size()), 2, RoundingMode.HALF_UP); }
                if (pd2InList.size() != 0) { pd2InAvg = pd2InSum.divide(new BigDecimal(pd2InList.size()), 2, RoundingMode.HALF_UP); }
                if (ma2InList.size() != 0) { ma2InAvg = ma2InSum.divide(new BigDecimal(ma2InList.size()), 2, RoundingMode.HALF_UP); }
                if (ethane3InList.size() != 0) { ethane3InAvg = ethane3InSum.divide(new BigDecimal(ethane3InList.size()), 2, RoundingMode.HALF_UP); }
                if (ethylene3InList.size() != 0) { ethylene3InAvg = ethylene3InSum.divide(new BigDecimal(ethylene3InList.size()), 2, RoundingMode.HALF_UP); }
                if (acetylene3InList.size() != 0) {
                    acetylene3InAvg = acetylene3InSum.divide(new BigDecimal(acetylene3InList.size()), 2, RoundingMode.HALF_UP)
                            .divide(new BigDecimal("10000"), 5, RoundingMode.HALF_UP);
                }
                if (propane3InList.size() != 0) { propane3InAvg = propane3InSum.divide(new BigDecimal(propane3InList.size()), 2, RoundingMode.HALF_UP); }
                if (propylene3InList.size() != 0) { propylene3InAvg = propylene3InSum.divide(new BigDecimal(propylene3InList.size()), 2, RoundingMode.HALF_UP); }
                if (pd3InList.size() != 0) { pd3InAvg = pd3InSum.divide(new BigDecimal(pd3InList.size()), 2, RoundingMode.HALF_UP); }
                if (ma3InList.size() != 0) { ma3InAvg = ma3InSum.divide(new BigDecimal(ma3InList.size()), 2, RoundingMode.HALF_UP); }
                //%
                BigDecimal acetyleneConversion1stIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal conversionLoad1stIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethyleneSelectivity1stIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal mapdConversion1stIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal propyleneSelectivity1stIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetyleneConversion2ndIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal conversionLoad2ndIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethyleneSelectivity2ndIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal mapdConversion2ndIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal propyleneSelectivity2ndIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetyleneConversion3rdIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal conversionLoad3rdIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethyleneSelectivity3rdIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal mapdConversion3rdIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal propyleneSelectivity3rdIn = new BigDecimal(BigInteger.ZERO);
                BigDecimal acetyleneConversion3rdOut = new BigDecimal(BigInteger.ZERO);
                BigDecimal ethyleneSelectivity3rdOut = new BigDecimal(BigInteger.ZERO);
                BigDecimal mapdConversion3rdOut = new BigDecimal(BigInteger.ZERO);
                BigDecimal propyleneSelectivity3rdOut = new BigDecimal(BigInteger.ZERO);
                //计算%
                if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    acetyleneConversion1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((acetylene1InAvg.subtract(acetylene2InAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
                }
                conversionLoad1stIn = acetyleneConversion1stIn;
                if (ethane1InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene1InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                        && ethane2InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene2InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene2InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    ethyleneSelectivity1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((ethylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(ethylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP)))
                                    .divide(((acetylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP))
                                            .subtract(acetylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
                }
                if ((pd1InAvg.add(ma1InAvg)).compareTo(BigDecimal.ZERO) != 0) {
                    mapdConversion1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((pd1InAvg.add(ma1InAvg).subtract(pd2InAvg).subtract(ma2InAvg)).divide(pd1InAvg.add(ma1InAvg), 2, RoundingMode.HALF_UP));
                }
                if (propane1InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd1InAvg.compareTo(BigDecimal.ZERO) != 0 && ma1InAvg.compareTo(BigDecimal.ZERO) != 0
                        && propane2InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene2InAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd2InAvg.compareTo(BigDecimal.ZERO) != 0 && ma2InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    propyleneSelectivity1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((propylene2InAvg.divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract(propylene1InAvg.divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP)))
                                    .divide((((pd1InAvg.add(ma1InAvg)).divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP))
                                            .subtract((pd2InAvg.add(ma2InAvg).divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
                }
                if (acetylene2InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    acetyleneConversion2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((acetylene2InAvg.subtract(acetylene3InAvg)).divide(acetylene2InAvg, 2, RoundingMode.HALF_UP));
                }
                if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    conversionLoad2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((acetylene2InAvg.subtract(acetylene3InAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
                }
                if (ethane2InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene2InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene2InAvg.compareTo(BigDecimal.ZERO) != 0
                        && ethane3InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    ethyleneSelectivity2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((ethylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(ethylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP)))
                                    .divide(((acetylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP))
                                            .subtract(acetylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
                }
                if ((pd2InAvg.add(ma2InAvg)).compareTo(BigDecimal.ZERO) != 0) {
                    mapdConversion2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((pd2InAvg.add(ma2InAvg).subtract(pd3InAvg).subtract(ma3InAvg)).divide(pd2InAvg.add(ma2InAvg), 2, RoundingMode.HALF_UP));
                }
                if (propane2InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene2InAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd2InAvg.compareTo(BigDecimal.ZERO) != 0 && ma2InAvg.compareTo(BigDecimal.ZERO) != 0
                        && propane3InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3InAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd3InAvg.compareTo(BigDecimal.ZERO) != 0 && ma3InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    propyleneSelectivity2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((propylene3InAvg.divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract(propylene2InAvg.divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP)))
                                    .divide((((pd2InAvg.add(ma2InAvg)).divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP))
                                            .subtract((pd3InAvg.add(ma3InAvg).divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
                }
                if (acetylene3InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    acetyleneConversion3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((acetylene3InAvg.subtract(acetylene3OutAvg)).divide(acetylene3InAvg, 2, RoundingMode.HALF_UP));
                }
                if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    conversionLoad3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((acetylene3InAvg.subtract(acetylene3OutAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
                }
                if (ethane3InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3InAvg.compareTo(BigDecimal.ZERO) != 0
                        && ethane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3OutAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
                    ethyleneSelectivity3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((ethylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(ethylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP)))
                                    .divide(((acetylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP))
                                            .subtract(acetylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
                }
                if ((pd3InAvg.add(ma3InAvg)).compareTo(BigDecimal.ZERO) != 0) {
                    mapdConversion3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((pd3InAvg.add(ma3InAvg).subtract(pd3OutAvg).subtract(ma3OutAvg)).divide(pd3InAvg.add(ma3InAvg), 2, RoundingMode.HALF_UP));
                }
                if (propane3InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3InAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd3InAvg.compareTo(BigDecimal.ZERO) != 0 && ma3InAvg.compareTo(BigDecimal.ZERO) != 0
                        && propane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3OutAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ma3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
                    propyleneSelectivity3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((propylene3OutAvg.divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract(propylene3InAvg.divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP)))
                                    .divide((((pd3InAvg.add(ma3InAvg)).divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP))
                                            .subtract((pd3OutAvg.add(ma3OutAvg).divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
                }
                if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
                    acetyleneConversion3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((acetylene1InAvg.subtract(acetylene3OutAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
                }
                if (ethane1InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene1InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                        && ethane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3OutAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
                    ethyleneSelectivity3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((ethylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(ethylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP)))
                                    .divide(((acetylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP))
                                            .subtract(acetylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
                }
                if ((pd1InAvg.add(ma1InAvg)).compareTo(BigDecimal.ZERO) != 0) {
                    mapdConversion3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply((pd1InAvg.add(ma1InAvg).subtract(pd3OutAvg).subtract(ma3OutAvg)).divide(pd1InAvg.add(ma1InAvg), 2, RoundingMode.HALF_UP));
                }
                if (propane1InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd1InAvg.compareTo(BigDecimal.ZERO) != 0 && ma1InAvg.compareTo(BigDecimal.ZERO) != 0
                        && propane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3OutAvg.compareTo(BigDecimal.ZERO) != 0
                        && pd3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ma3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
                    propyleneSelectivity3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                            .multiply(((propylene3OutAvg.divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract(propylene1InAvg.divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP)))
                                    .divide((((pd1InAvg.add(ma1InAvg)).divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP))
                                            .subtract((pd3OutAvg.add(ma3OutAvg).divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
                }
                C2ReactorAnalysisVO analysisVO = new C2ReactorAnalysisVO();
                analysisVO.setEthyleneSelectivity3rdOut(ethyleneSelectivity3rdOut);
                analysisVO.setMapdConversion3rdOut(mapdConversion3rdOut);
                dataMap.put(startYear + "-" + startMonth, analysisVO);
                if (startMonth == 12) {
                    startMonth = 1;
                    startYear++;
                } else {
                    startMonth++;
                }
            if (!(startYear != endYear || startMonth != endMonth + 1)) {
                break;
            }
        }


        // 获取map第一个元素
        List<String> keys = new ArrayList<>(dataMap.keySet());
        String firstKey = keys.get(0);
        C2ReactorAnalysisVO firstValue = dataMap.get(firstKey);
        // 最大值
        BigDecimal ethyleneSelectivity3rdOutMax = firstValue.getEthyleneSelectivity3rdOut();
        BigDecimal mapdConversion3rdOutMax = firstValue.getMapdConversion3rdOut();
        // 最小值
        BigDecimal ethyleneSelectivity3rdOutMin = firstValue.getEthyleneSelectivity3rdOut();
        BigDecimal mapdConversion3rdOutMin = firstValue.getMapdConversion3rdOut();
        // 平均值
        BigDecimal ethyleneSelectivity3rdOutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal mapdConversion3rdOutAvg = new BigDecimal(BigInteger.ZERO);
        // 总和
        BigDecimal ethyleneSelectivity3rdOutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal mapdConversion3rdOutSum = new BigDecimal(BigInteger.ZERO);
        for(Map.Entry entry : dataMap.entrySet()) {
            C2ReactorAnalysisVO mapValue = (C2ReactorAnalysisVO) entry.getValue();
            BigDecimal ethyleneSelectivity3rdOut = mapValue.getEthyleneSelectivity3rdOut();
            BigDecimal mapdConversion3rdOut = mapValue.getMapdConversion3rdOut();
            if (ethyleneSelectivity3rdOut.compareTo(ethyleneSelectivity3rdOutMax) > 0) { ethyleneSelectivity3rdOutMax = ethyleneSelectivity3rdOut; }
            if (mapdConversion3rdOut.compareTo(mapdConversion3rdOutMax) > 0) { mapdConversion3rdOutMax = mapdConversion3rdOut; }
            if (ethyleneSelectivity3rdOut.compareTo(ethyleneSelectivity3rdOutMin) < 0) { ethyleneSelectivity3rdOutMin = ethyleneSelectivity3rdOut; }
            if (mapdConversion3rdOut.compareTo(mapdConversion3rdOutMin) < 0) { mapdConversion3rdOutMin = mapdConversion3rdOut; }
            ethyleneSelectivity3rdOutSum = ethyleneSelectivity3rdOutSum.add(ethyleneSelectivity3rdOut);
            mapdConversion3rdOutSum = mapdConversion3rdOutSum.add(mapdConversion3rdOut);
        }
        BigDecimal count = new BigDecimal(dataMap.size());
        ethyleneSelectivity3rdOutAvg = ethyleneSelectivity3rdOutSum.divide(count, 2, RoundingMode.HALF_UP);
        mapdConversion3rdOutAvg = mapdConversion3rdOutSum.divide(count, 2, RoundingMode.HALF_UP);
        StringBuffer description = new StringBuffer();
        description.append("Ethylene Selectivity(max)="+ ethyleneSelectivity3rdOutMax.toString() + "\t");
        description.append("MAPD Conversion(max)="+ mapdConversion3rdOutMax.toString() + "\n");
        description.append("Ethylene Selectivity(min)="+ ethyleneSelectivity3rdOutMin.toString() + "\t");
        description.append("MAPD Conversion(min)="+ mapdConversion3rdOutMin.toString() + "\n");
        description.append("Ethylene Selectivity(avg)="+ ethyleneSelectivity3rdOutAvg.toString() + "\t");
        description.append("MAPD Conversion(avg)="+ mapdConversion3rdOutAvg.toString() + "\n");
        QualityAnalysisVO qualityVO = new QualityAnalysisVO();
        qualityVO.setDataMap(dataMap);
        qualityVO.setDescription(description.toString());
        return AjaxResult.success(qualityVO);
    }

    /**
     * 碳二反应器性能指标表格
     */
    @PreAuthorize("@ss.hasPermi('production:quality:list')")
    @GetMapping("/c2ReactorTable")
    public AjaxResult c2ReactorTable(MonthlyQualityReportQueryVO vo)
    {
        return AjaxResult.success(this.calcC2ReactorTable(vo.getStartDate(), vo.getEndDate()));
    }

    private C2ReactorTableVO calcC2ReactorTable(Date startDate, Date endDate) {
        //1st inlet
        TMonthlyQualityReportS3009 tMonthlyQualityReportS3009 = new TMonthlyQualityReportS3009();
        tMonthlyQualityReportS3009.setStartDate(startDate);
        tMonthlyQualityReportS3009.setEndDate(endDate);
        List<TMonthlyQualityReportS3009> tMonthlyQualityReportS3009s = tMonthlyQualityReportS3009Service.selectTMonthlyQualityReportS3009List(tMonthlyQualityReportS3009);
        //3rd outlet
        TMonthlyQualityReportS3010 tMonthlyQualityReportS3010 = new TMonthlyQualityReportS3010();
        tMonthlyQualityReportS3010.setStartDate(startDate);
        tMonthlyQualityReportS3010.setEndDate(endDate);
        List<TMonthlyQualityReportS3010> tMonthlyQualityReportS3010s = tMonthlyQualityReportS3010Service.selectTMonthlyQualityReportS3010List(tMonthlyQualityReportS3010);
        //2nd inlet
        TMonthlyQualityReportS3011 tMonthlyQualityReportS3011 = new TMonthlyQualityReportS3011();
        tMonthlyQualityReportS3011.setStartDate(startDate);
        tMonthlyQualityReportS3011.setEndDate(endDate);
        List<TMonthlyQualityReportS3011> tMonthlyQualityReportS3011s = tMonthlyQualityReportS3011Service.selectTMonthlyQualityReportS3011List(tMonthlyQualityReportS3011);
        //3rd inlet
        TMonthlyQualityReportS3012 tMonthlyQualityReportS3012 = new TMonthlyQualityReportS3012();
        tMonthlyQualityReportS3012.setStartDate(startDate);
        tMonthlyQualityReportS3012.setEndDate(endDate);
        List<TMonthlyQualityReportS3012> tMonthlyQualityReportS3012s = tMonthlyQualityReportS3012Service.selectTMonthlyQualityReportS3012List(tMonthlyQualityReportS3012);
        //avg
        BigDecimal ethane1InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene1InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene1InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane1InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene1InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd1InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma1InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethane3OutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene3OutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene3OutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane3OutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene3OutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd3OutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma3OutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethane2InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene2InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene2InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane2InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene2InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd2InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma2InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethane3InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene3InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene3InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane3InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene3InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd3InAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma3InAvg = new BigDecimal(BigInteger.ZERO);
        //sum
        BigDecimal ethane1InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene1InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene1InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane1InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene1InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd1InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma1InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethane3OutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene3OutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene3OutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane3OutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene3OutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd3OutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma3OutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethane2InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene2InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene2InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane2InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene2InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd2InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma2InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethane3InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethylene3InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetylene3InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propane3InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propylene3InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal pd3InSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal ma3InSum = new BigDecimal(BigInteger.ZERO);
        //list
        ArrayList<BigDecimal> ethane1InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ethylene1InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> acetylene1InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propane1InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propylene1InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> pd1InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ma1InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ethane3OutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ethylene3OutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> acetylene3OutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propane3OutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propylene3OutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> pd3OutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ma3OutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ethane2InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ethylene2InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> acetylene2InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propane2InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propylene2InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> pd2InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ma2InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ethane3InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ethylene3InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> acetylene3InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propane3InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propylene3InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> pd3InList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> ma3InList = new ArrayList<BigDecimal>();
        //放入list
        for (TMonthlyQualityReportS3009 monthlyQualityReportS3009 : tMonthlyQualityReportS3009s) {
            String ethane = monthlyQualityReportS3009.getEthane();
            String ethylene = monthlyQualityReportS3009.getEthylene();
            String acetylene = monthlyQualityReportS3009.getAcetylene();
            String propane = monthlyQualityReportS3009.getPropane();
            String propylene = monthlyQualityReportS3009.getPropylene();
            String pd = monthlyQualityReportS3009.getPropadiene();
            String ma = monthlyQualityReportS3009.getMethylacetylene();
            if (StringUtils.isNotEmpty(ethane)) { ethane1InList.add(new BigDecimal(ethane)); }
            if (StringUtils.isNotEmpty(ethylene)) { ethylene1InList.add(new BigDecimal(ethylene)); }
            if (StringUtils.isNotEmpty(acetylene)) { acetylene1InList.add(new BigDecimal(acetylene)); }
            if (StringUtils.isNotEmpty(propane)) { propane1InList.add(new BigDecimal(propane)); }
            if (StringUtils.isNotEmpty(propylene)) { propylene1InList.add(new BigDecimal(propylene)); }
            if (StringUtils.isNotEmpty(pd)) { pd1InList.add(new BigDecimal(pd)); }
            if (StringUtils.isNotEmpty(ma)) { ma1InList.add(new BigDecimal(ma)); }
        }
        for (TMonthlyQualityReportS3010 monthlyQualityReportS3010 : tMonthlyQualityReportS3010s) {
            String ethane = monthlyQualityReportS3010.getEthane();
            String ethylene = monthlyQualityReportS3010.getEthylene();
            String acetylene = monthlyQualityReportS3010.getAcetylene();
            String propane = monthlyQualityReportS3010.getPropane();
            String propylene = monthlyQualityReportS3010.getPropylene();
            String pd = monthlyQualityReportS3010.getPropadiene();
            String ma = monthlyQualityReportS3010.getMethylacetylene();
            if (StringUtils.isNotEmpty(ethane)) { ethane3OutList.add(new BigDecimal(ethane)); }
            if (StringUtils.isNotEmpty(ethylene)) { ethylene3OutList.add(new BigDecimal(ethylene)); }
            if (StringUtils.isNotEmpty(acetylene)) { acetylene3OutList.add(new BigDecimal(acetylene)); }
            if (StringUtils.isNotEmpty(propane)) { propane3OutList.add(new BigDecimal(propane)); }
            if (StringUtils.isNotEmpty(propylene)) { propylene3OutList.add(new BigDecimal(propylene)); }
            if (StringUtils.isNotEmpty(pd)) { pd3OutList.add(new BigDecimal(pd)); }
            if (StringUtils.isNotEmpty(ma)) { ma3OutList.add(new BigDecimal(ma)); }
        }
        for (TMonthlyQualityReportS3011 monthlyQualityReportS3011 : tMonthlyQualityReportS3011s) {
            String ethane = monthlyQualityReportS3011.getEthane();
            String ethylene = monthlyQualityReportS3011.getEthylene();
            String acetylene = monthlyQualityReportS3011.getAcetylene();
            String propane = monthlyQualityReportS3011.getPropane();
            String propylene = monthlyQualityReportS3011.getPropylene();
            String pd = monthlyQualityReportS3011.getPropadiene();
            String ma = monthlyQualityReportS3011.getMethylacetylene();
            if (StringUtils.isNotEmpty(ethane)) { ethane2InList.add(new BigDecimal(ethane)); }
            if (StringUtils.isNotEmpty(ethylene)) { ethylene2InList.add(new BigDecimal(ethylene)); }
            if (StringUtils.isNotEmpty(acetylene)) { acetylene2InList.add(new BigDecimal(acetylene)); }
            if (StringUtils.isNotEmpty(propane)) { propane2InList.add(new BigDecimal(propane)); }
            if (StringUtils.isNotEmpty(propylene)) { propylene2InList.add(new BigDecimal(propylene)); }
            if (StringUtils.isNotEmpty(pd)) { pd2InList.add(new BigDecimal(pd)); }
            if (StringUtils.isNotEmpty(ma)) { ma2InList.add(new BigDecimal(ma)); }
        }
        for (TMonthlyQualityReportS3012 monthlyQualityReportS3012 : tMonthlyQualityReportS3012s) {
            String ethane = monthlyQualityReportS3012.getEthane();
            String ethylene = monthlyQualityReportS3012.getEthylene();
            String acetylene = monthlyQualityReportS3012.getAcetylene();
            String propane = monthlyQualityReportS3012.getPropane();
            String propylene = monthlyQualityReportS3012.getPropylene();
            String pd = monthlyQualityReportS3012.getPropadiene();
            String ma = monthlyQualityReportS3012.getMethylacetylene();
            if (StringUtils.isNotEmpty(ethane)) { ethane3InList.add(new BigDecimal(ethane)); }
            if (StringUtils.isNotEmpty(ethylene)) { ethylene3InList.add(new BigDecimal(ethylene)); }
            if (StringUtils.isNotEmpty(acetylene)) { acetylene3InList.add(new BigDecimal(acetylene)); }
            if (StringUtils.isNotEmpty(propane)) { propane3InList.add(new BigDecimal(propane)); }
            if (StringUtils.isNotEmpty(propylene)) { propylene3InList.add(new BigDecimal(propylene)); }
            if (StringUtils.isNotEmpty(pd)) { pd3InList.add(new BigDecimal(pd)); }
            if (StringUtils.isNotEmpty(ma)) { ma3InList.add(new BigDecimal(ma)); }
        }
        //计算sum
        for (BigDecimal value : ethane1InList) { ethane1InSum = ethane1InSum.add(value); }
        for (BigDecimal value : ethylene1InList) { ethylene1InSum = ethylene1InSum.add(value); }
        for (BigDecimal value : acetylene1InList) { acetylene1InSum = acetylene1InSum.add(value); }
        for (BigDecimal value : propane1InList) { propane1InSum = propane1InSum.add(value); }
        for (BigDecimal value : propylene1InList) { propylene1InSum = propylene1InSum.add(value); }
        for (BigDecimal value : pd1InList) { pd1InSum = pd1InSum.add(value); }
        for (BigDecimal value : ma1InList) { ma1InSum = ma1InSum.add(value); }
        for (BigDecimal value : ethane3OutList) { ethane3OutSum = ethane3OutSum.add(value); }
        for (BigDecimal value : ethylene3OutList) { ethylene3OutSum = ethylene3OutSum.add(value); }
        for (BigDecimal value : acetylene3OutList) { acetylene3OutSum = acetylene3OutSum.add(value); }
        for (BigDecimal value : propane3OutList) { propane3OutSum = propane3OutSum.add(value); }
        for (BigDecimal value : propylene3OutList) { propylene3OutSum = propylene3OutSum.add(value); }
        for (BigDecimal value : pd3OutList) { pd3OutSum = pd3OutSum.add(value); }
        for (BigDecimal value : ma3OutList) { ma3OutSum = ma3OutSum.add(value); }
        for (BigDecimal value : ethane2InList) { ethane2InSum = ethane2InSum.add(value); }
        for (BigDecimal value : ethylene2InList) { ethylene2InSum = ethylene2InSum.add(value); }
        for (BigDecimal value : acetylene2InList) { acetylene2InSum = acetylene2InSum.add(value); }
        for (BigDecimal value : propane2InList) { propane2InSum = propane2InSum.add(value); }
        for (BigDecimal value : propylene2InList) { propylene2InSum = propylene2InSum.add(value); }
        for (BigDecimal value : pd2InList) { pd2InSum = pd2InSum.add(value); }
        for (BigDecimal value : ma2InList) { ma2InSum = ma2InSum.add(value); }
        for (BigDecimal value : ethane3InList) { ethane3InSum = ethane3InSum.add(value); }
        for (BigDecimal value : ethylene3InList) { ethylene3InSum = ethylene3InSum.add(value); }
        for (BigDecimal value : acetylene3InList) { acetylene3InSum = acetylene3InSum.add(value); }
        for (BigDecimal value : propane3InList) { propane3InSum = propane3InSum.add(value); }
        for (BigDecimal value : propylene3InList) { propylene3InSum = propylene3InSum.add(value); }
        for (BigDecimal value : pd3InList) { pd3InSum = pd3InSum.add(value); }
        for (BigDecimal value : ma3InList) { ma3InSum = ma3InSum.add(value); }
        //计算avg
        if (ethane1InList.size() != 0) { ethane1InAvg = ethane1InSum.divide(new BigDecimal(ethane1InList.size()), 2, RoundingMode.HALF_UP); }
        if (ethylene1InList.size() != 0) { ethylene1InAvg = ethylene1InSum.divide(new BigDecimal(ethylene1InList.size()), 2, RoundingMode.HALF_UP); }
        if (acetylene1InList.size() != 0) { acetylene1InAvg = acetylene1InSum.divide(new BigDecimal(acetylene1InList.size()), 2, RoundingMode.HALF_UP); }
        if (propane1InList.size() != 0) { propane1InAvg = propane1InSum.divide(new BigDecimal(propane1InList.size()), 2, RoundingMode.HALF_UP); }
        if (propylene1InList.size() != 0) { propylene1InAvg = propylene1InSum.divide(new BigDecimal(propylene1InList.size()), 2, RoundingMode.HALF_UP); }
        if (pd1InList.size() != 0) { pd1InAvg = pd1InSum.divide(new BigDecimal(pd1InList.size()), 2, RoundingMode.HALF_UP); }
        if (ma1InList.size() != 0) { ma1InAvg = ma1InSum.divide(new BigDecimal(ma1InList.size()), 2, RoundingMode.HALF_UP); }
        if (ethane3OutList.size() != 0) { ethane3OutAvg = ethane3OutSum.divide(new BigDecimal(ethane3OutList.size()), 2, RoundingMode.HALF_UP); }
        if (ethylene3OutList.size() != 0) { ethylene3OutAvg = ethylene3OutSum.divide(new BigDecimal(ethylene3OutList.size()), 2, RoundingMode.HALF_UP); }
        if (acetylene3OutList.size() != 0) {
            acetylene3OutAvg = acetylene3OutSum.divide(new BigDecimal(acetylene3OutList.size()), 2, RoundingMode.HALF_UP)
                    .divide(new BigDecimal("10000"), 5, RoundingMode.HALF_UP);
        }
        if (propane3OutList.size() != 0) { propane3OutAvg = propane3OutSum.divide(new BigDecimal(propane3OutList.size()), 2, RoundingMode.HALF_UP); }
        if (propylene3OutList.size() != 0) { propylene3OutAvg = propylene3OutSum.divide(new BigDecimal(propylene3OutList.size()), 2, RoundingMode.HALF_UP); }
        if (pd3OutList.size() != 0) { pd3OutAvg = pd3OutSum.divide(new BigDecimal(pd3OutList.size()), 2, RoundingMode.HALF_UP); }
        if (ma3OutList.size() != 0) { ma3OutAvg = ma3OutSum.divide(new BigDecimal(ma3OutList.size()), 2, RoundingMode.HALF_UP); }
        if (ethane2InList.size() != 0) { ethane2InAvg = ethane2InSum.divide(new BigDecimal(ethane2InList.size()), 2, RoundingMode.HALF_UP); }
        if (ethylene2InList.size() != 0) { ethylene2InAvg = ethylene2InSum.divide(new BigDecimal(ethylene2InList.size()), 2, RoundingMode.HALF_UP); }
        if (acetylene2InList.size() != 0) { acetylene2InAvg = acetylene2InSum.divide(new BigDecimal(acetylene2InList.size()), 2, RoundingMode.HALF_UP); }
        if (propane2InList.size() != 0) { propane2InAvg = propane2InSum.divide(new BigDecimal(propane2InList.size()), 2, RoundingMode.HALF_UP); }
        if (propylene2InList.size() != 0) { propylene2InAvg = propylene2InSum.divide(new BigDecimal(propylene2InList.size()), 2, RoundingMode.HALF_UP); }
        if (pd2InList.size() != 0) { pd2InAvg = pd2InSum.divide(new BigDecimal(pd2InList.size()), 2, RoundingMode.HALF_UP); }
        if (ma2InList.size() != 0) { ma2InAvg = ma2InSum.divide(new BigDecimal(ma2InList.size()), 2, RoundingMode.HALF_UP); }
        if (ethane3InList.size() != 0) { ethane3InAvg = ethane3InSum.divide(new BigDecimal(ethane3InList.size()), 2, RoundingMode.HALF_UP); }
        if (ethylene3InList.size() != 0) { ethylene3InAvg = ethylene3InSum.divide(new BigDecimal(ethylene3InList.size()), 2, RoundingMode.HALF_UP); }
        if (acetylene3InList.size() != 0) {
            acetylene3InAvg = acetylene3InSum.divide(new BigDecimal(acetylene3InList.size()), 2, RoundingMode.HALF_UP)
                    .divide(new BigDecimal("10000"), 5, RoundingMode.HALF_UP);
        }
        if (propane3InList.size() != 0) { propane3InAvg = propane3InSum.divide(new BigDecimal(propane3InList.size()), 2, RoundingMode.HALF_UP); }
        if (propylene3InList.size() != 0) { propylene3InAvg = propylene3InSum.divide(new BigDecimal(propylene3InList.size()), 2, RoundingMode.HALF_UP); }
        if (pd3InList.size() != 0) { pd3InAvg = pd3InSum.divide(new BigDecimal(pd3InList.size()), 2, RoundingMode.HALF_UP); }
        if (ma3InList.size() != 0) { ma3InAvg = ma3InSum.divide(new BigDecimal(ma3InList.size()), 2, RoundingMode.HALF_UP); }
        //%
        BigDecimal acetyleneConversion1stIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal conversionLoad1stIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethyleneSelectivity1stIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal mapdConversion1stIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneSelectivity1stIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetyleneConversion2ndIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal conversionLoad2ndIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethyleneSelectivity2ndIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal mapdConversion2ndIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneSelectivity2ndIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetyleneConversion3rdIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal conversionLoad3rdIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethyleneSelectivity3rdIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal mapdConversion3rdIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneSelectivity3rdIn = new BigDecimal(BigInteger.ZERO);
        BigDecimal acetyleneConversion3rdOut = new BigDecimal(BigInteger.ZERO);
        BigDecimal ethyleneSelectivity3rdOut = new BigDecimal(BigInteger.ZERO);
        BigDecimal mapdConversion3rdOut = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneSelectivity3rdOut = new BigDecimal(BigInteger.ZERO);
        //计算%
        if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
            acetyleneConversion1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((acetylene1InAvg.subtract(acetylene2InAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
        }
        conversionLoad1stIn = acetyleneConversion1stIn;
        if (ethane1InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene1InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                && ethane2InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene2InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene2InAvg.compareTo(BigDecimal.ZERO) != 0) {
            ethyleneSelectivity1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((ethylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP))
                            .subtract(ethylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP)))
                            .divide(((acetylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(acetylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
        }
        if ((pd1InAvg.add(ma1InAvg)).compareTo(BigDecimal.ZERO) != 0) {
            mapdConversion1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((pd1InAvg.add(ma1InAvg).subtract(pd2InAvg).subtract(ma2InAvg)).divide(pd1InAvg.add(ma1InAvg), 2, RoundingMode.HALF_UP));
        }
        if (propane1InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                && pd1InAvg.compareTo(BigDecimal.ZERO) != 0 && ma1InAvg.compareTo(BigDecimal.ZERO) != 0
                && propane2InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene2InAvg.compareTo(BigDecimal.ZERO) != 0
                && pd2InAvg.compareTo(BigDecimal.ZERO) != 0 && ma2InAvg.compareTo(BigDecimal.ZERO) != 0) {
            propyleneSelectivity1stIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((propylene2InAvg.divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP))
                            .subtract(propylene1InAvg.divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP)))
                            .divide((((pd1InAvg.add(ma1InAvg)).divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract((pd2InAvg.add(ma2InAvg).divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
        }
        if (acetylene2InAvg.compareTo(BigDecimal.ZERO) != 0) {
            acetyleneConversion2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((acetylene2InAvg.subtract(acetylene3InAvg)).divide(acetylene2InAvg, 2, RoundingMode.HALF_UP));
        }
        if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
            conversionLoad2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((acetylene2InAvg.subtract(acetylene3InAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
        }
        if (ethane2InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene2InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene2InAvg.compareTo(BigDecimal.ZERO) != 0
                && ethane3InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3InAvg.compareTo(BigDecimal.ZERO) != 0) {
            ethyleneSelectivity2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((ethylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP))
                            .subtract(ethylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP)))
                            .divide(((acetylene2InAvg.divide(ethane2InAvg.add(ethylene2InAvg).add(acetylene2InAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(acetylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
        }
        if ((pd2InAvg.add(ma2InAvg)).compareTo(BigDecimal.ZERO) != 0) {
            mapdConversion2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((pd2InAvg.add(ma2InAvg).subtract(pd3InAvg).subtract(ma3InAvg)).divide(pd2InAvg.add(ma2InAvg), 2, RoundingMode.HALF_UP));
        }
        if (propane2InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene2InAvg.compareTo(BigDecimal.ZERO) != 0
                && pd2InAvg.compareTo(BigDecimal.ZERO) != 0 && ma2InAvg.compareTo(BigDecimal.ZERO) != 0
                && propane3InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3InAvg.compareTo(BigDecimal.ZERO) != 0
                && pd3InAvg.compareTo(BigDecimal.ZERO) != 0 && ma3InAvg.compareTo(BigDecimal.ZERO) != 0) {
            propyleneSelectivity2ndIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((propylene3InAvg.divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP))
                            .subtract(propylene2InAvg.divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP)))
                            .divide((((pd2InAvg.add(ma2InAvg)).divide((propane2InAvg.add(propylene2InAvg).add(pd2InAvg).add(ma2InAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract((pd3InAvg.add(ma3InAvg).divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
        }
        if (acetylene3InAvg.compareTo(BigDecimal.ZERO) != 0) {
            acetyleneConversion3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((acetylene3InAvg.subtract(acetylene3OutAvg)).divide(acetylene3InAvg, 2, RoundingMode.HALF_UP));
        }
        if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
            conversionLoad3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((acetylene3InAvg.subtract(acetylene3OutAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
        }
        if (ethane3InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3InAvg.compareTo(BigDecimal.ZERO) != 0
                && ethane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3OutAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
            ethyleneSelectivity3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((ethylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))
                            .subtract(ethylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP)))
                            .divide(((acetylene3InAvg.divide(ethane3InAvg.add(ethylene3InAvg).add(acetylene3InAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(acetylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
        }
        if ((pd3InAvg.add(ma3InAvg)).compareTo(BigDecimal.ZERO) != 0) {
            mapdConversion3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((pd3InAvg.add(ma3InAvg).subtract(pd3OutAvg).subtract(ma3OutAvg)).divide(pd3InAvg.add(ma3InAvg), 2, RoundingMode.HALF_UP));
        }
        if (propane3InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3InAvg.compareTo(BigDecimal.ZERO) != 0
                && pd3InAvg.compareTo(BigDecimal.ZERO) != 0 && ma3InAvg.compareTo(BigDecimal.ZERO) != 0
                && propane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3OutAvg.compareTo(BigDecimal.ZERO) != 0
                && pd3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ma3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
            propyleneSelectivity3rdIn = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((propylene3OutAvg.divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP))
                            .subtract(propylene3InAvg.divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP)))
                            .divide((((pd3InAvg.add(ma3InAvg)).divide((propane3InAvg.add(propylene3InAvg).add(pd3InAvg).add(ma3InAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract((pd3OutAvg.add(ma3OutAvg).divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
        }
        if (acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0) {
            acetyleneConversion3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((acetylene1InAvg.subtract(acetylene3OutAvg)).divide(acetylene1InAvg, 2, RoundingMode.HALF_UP));
        }
        if (ethane1InAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene1InAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                && ethane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ethylene3OutAvg.compareTo(BigDecimal.ZERO) != 0 && acetylene3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
            ethyleneSelectivity3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((ethylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))
                            .subtract(ethylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP)))
                            .divide(((acetylene1InAvg.divide(ethane1InAvg.add(ethylene1InAvg).add(acetylene1InAvg), 5, RoundingMode.HALF_UP))
                                    .subtract(acetylene3OutAvg.divide(ethane3OutAvg.add(ethylene3OutAvg).add(acetylene3OutAvg), 5, RoundingMode.HALF_UP))), 5, RoundingMode.HALF_UP));
        }
        if ((pd1InAvg.add(ma1InAvg)).compareTo(BigDecimal.ZERO) != 0) {
            mapdConversion3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply((pd1InAvg.add(ma1InAvg).subtract(pd3OutAvg).subtract(ma3OutAvg)).divide(pd1InAvg.add(ma1InAvg), 2, RoundingMode.HALF_UP));
        }
        if (propane1InAvg.compareTo(BigDecimal.ZERO) != 0 && propylene1InAvg.compareTo(BigDecimal.ZERO) != 0
                && pd1InAvg.compareTo(BigDecimal.ZERO) != 0 && ma1InAvg.compareTo(BigDecimal.ZERO) != 0
                && propane3OutAvg.compareTo(BigDecimal.ZERO) != 0 && propylene3OutAvg.compareTo(BigDecimal.ZERO) != 0
                && pd3OutAvg.compareTo(BigDecimal.ZERO) != 0 && ma3OutAvg.compareTo(BigDecimal.ZERO) != 0) {
            propyleneSelectivity3rdOut = BigDecimal.TEN.multiply(BigDecimal.TEN)
                    .multiply(((propylene3OutAvg.divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP))
                            .subtract(propylene1InAvg.divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP)))
                            .divide((((pd1InAvg.add(ma1InAvg)).divide((propane1InAvg.add(propylene1InAvg).add(pd1InAvg).add(ma1InAvg)), 5, RoundingMode.HALF_UP))
                                    .subtract((pd3OutAvg.add(ma3OutAvg).divide((propane3OutAvg.add(propylene3OutAvg).add(pd3OutAvg).add(ma3OutAvg)), 5, RoundingMode.HALF_UP)))), 5, RoundingMode.HALF_UP));
        }
        C2ReactorTableVO tableVO = new C2ReactorTableVO();
        tableVO.setEthane1InAvg(ethane1InAvg);
        tableVO.setEthylene1InAvg(ethylene1InAvg);
        tableVO.setAcetylene1InAvg(acetylene1InAvg);
        tableVO.setPropane1InAvg(propane1InAvg);
        tableVO.setPropylene1InAvg(propylene1InAvg);
        tableVO.setPd1InAvg(pd1InAvg);
        tableVO.setMa1InAvg(ma1InAvg);
        tableVO.setEthane3OutAvg(ethane3OutAvg);
        tableVO.setEthylene3OutAvg(ethylene3OutAvg);
        tableVO.setAcetylene3OutAvg(acetylene3OutAvg);
        tableVO.setPropane3OutAvg(propane3OutAvg);
        tableVO.setPropylene3OutAvg(propylene3OutAvg);
        tableVO.setPd3OutAvg(pd3OutAvg);
        tableVO.setMa3OutAvg(ma3OutAvg);
        tableVO.setEthane2InAvg(ethane2InAvg);
        tableVO.setEthylene2InAvg(ethylene2InAvg);
        tableVO.setAcetylene2InAvg(acetylene2InAvg);
        tableVO.setPropane2InAvg(propane2InAvg);
        tableVO.setPropylene2InAvg(propylene2InAvg);
        tableVO.setPd2InAvg(pd2InAvg);
        tableVO.setMa2InAvg(ma2InAvg);
        tableVO.setEthane3InAvg(ethane3InAvg);
        tableVO.setEthylene3InAvg(ethylene3InAvg);
        tableVO.setAcetylene3InAvg(acetylene3InAvg);
        tableVO.setPropane3InAvg(propane3InAvg);
        tableVO.setPropylene3InAvg(propylene3InAvg);
        tableVO.setPd3InAvg(pd3InAvg);
        tableVO.setMa3InAvg(ma3InAvg);
        tableVO.setAcetyleneConversion1stIn(acetyleneConversion1stIn);
        tableVO.setConversionLoad1stIn(conversionLoad1stIn);
        tableVO.setEthyleneSelectivity1stIn(ethyleneSelectivity1stIn);
        tableVO.setMapdConversion1stIn(mapdConversion1stIn);
        tableVO.setPropyleneSelectivity1stIn(propyleneSelectivity1stIn);
        tableVO.setAcetyleneConversion2ndIn(acetyleneConversion2ndIn);
        tableVO.setConversionLoad2ndIn(conversionLoad2ndIn);
        tableVO.setEthyleneSelectivity2ndIn(ethyleneSelectivity2ndIn);
        tableVO.setMapdConversion2ndIn(mapdConversion2ndIn);
        tableVO.setPropyleneSelectivity2ndIn(propyleneSelectivity2ndIn);
        tableVO.setAcetyleneConversion3rdIn(acetyleneConversion3rdIn);
        tableVO.setConversionLoad3rdIn(conversionLoad3rdIn);
        tableVO.setEthyleneSelectivity3rdIn(ethyleneSelectivity3rdIn);
        tableVO.setMapdConversion3rdIn(mapdConversion3rdIn);
        tableVO.setPropyleneSelectivity3rdIn(propyleneSelectivity3rdIn);
        tableVO.setAcetyleneConversion3rdOut(acetyleneConversion3rdOut);
        tableVO.setEthyleneSelectivity3rdOut(ethyleneSelectivity3rdOut);
        tableVO.setMapdConversion3rdOut(mapdConversion3rdOut);
        tableVO.setPropyleneSelectivity3rdOut(propyleneSelectivity3rdOut);
        return tableVO;
    }

    /**
     * 碳三反应器性能指标趋势图
     */
    @PreAuthorize("@ss.hasPermi('production:quality:list')")
    @GetMapping("/c3ReactorAnalysis")
    public AjaxResult c3ReactorAnalysis(MonthlyQualityReportQueryVO vo)
    {
        Date startDate = vo.getStartDate();
        Date endDate = vo.getEndDate();
        int startYear = startDate.getYear() + 1900;
        int endYear = endDate.getYear() + 1900;
        int startMonth = startDate.getMonth() + 1;
        int endMonth = endDate.getMonth() + 1;
        Map<String, C3ReactorAnalysisVO> dataMap = new HashMap<>();


        for (int i = 0; i < 12; i++) {
            //in
            TMonthlyQualityReportS5010 tMonthlyQualityReportS5010 = new TMonthlyQualityReportS5010();
            tMonthlyQualityReportS5010.setStartDate(startDate);
            tMonthlyQualityReportS5010.setEndDate(endDate);
            List<TMonthlyQualityReportS5010> tMonthlyQualityReportS5010s = tMonthlyQualityReportS5010Service.selectTMonthlyQualityReportS5010List(tMonthlyQualityReportS5010);
            //out
            TMonthlyQualityReportS5012 tMonthlyQualityReportS5012 = new TMonthlyQualityReportS5012();
            tMonthlyQualityReportS5012.setStartDate(startDate);
            tMonthlyQualityReportS5012.setEndDate(endDate);
            List<TMonthlyQualityReportS5012> tMonthlyQualityReportS5012s = tMonthlyQualityReportS5012Service.selectTMonthlyQualityReportS5012List(tMonthlyQualityReportS5012);
            //avg
            BigDecimal propaneInAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal propyleneInAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal pdInAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal maInAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal propaneOutAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal propyleneOutAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal pdOutAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal maOutAvg = new BigDecimal(BigInteger.ZERO);
            BigDecimal conversion = new BigDecimal(BigInteger.ZERO);
            BigDecimal propyleneSelectivity = new BigDecimal(BigInteger.ZERO);
            //sum
            BigDecimal propaneInSum = new BigDecimal(BigInteger.ZERO);
            BigDecimal propyleneInSum = new BigDecimal(BigInteger.ZERO);
            BigDecimal pdInSum = new BigDecimal(BigInteger.ZERO);
            BigDecimal maInSum = new BigDecimal(BigInteger.ZERO);
            BigDecimal propaneOutSum = new BigDecimal(BigInteger.ZERO);
            BigDecimal propyleneOutSum = new BigDecimal(BigInteger.ZERO);
            BigDecimal pdOutSum = new BigDecimal(BigInteger.ZERO);
            BigDecimal maOutSum = new BigDecimal(BigInteger.ZERO);
            //list
            ArrayList<BigDecimal> propaneInList = new ArrayList<BigDecimal>();
            ArrayList<BigDecimal> propyleneInList = new ArrayList<BigDecimal>();
            ArrayList<BigDecimal> pdInList = new ArrayList<BigDecimal>();
            ArrayList<BigDecimal> maInList = new ArrayList<BigDecimal>();
            ArrayList<BigDecimal> propaneOutList = new ArrayList<BigDecimal>();
            ArrayList<BigDecimal> propyleneOutList = new ArrayList<BigDecimal>();
            ArrayList<BigDecimal> pdOutList = new ArrayList<BigDecimal>();
            ArrayList<BigDecimal> maOutList = new ArrayList<BigDecimal>();
            //放入list
            for (TMonthlyQualityReportS5010 monthlyQualityReportS5010 : tMonthlyQualityReportS5010s) {
                String propane = monthlyQualityReportS5010.getPropane();
                String propylene = monthlyQualityReportS5010.getPropylene();
                String pd = monthlyQualityReportS5010.getPropadiene();
                String ma = monthlyQualityReportS5010.getMethylacetylene();
                if (StringUtils.isNotEmpty(propane)) {
                    propaneInList.add(new BigDecimal(propane));
                }
                if (StringUtils.isNotEmpty(propylene)) {
                    propyleneInList.add(new BigDecimal(propylene));
                }
                if (StringUtils.isNotEmpty(pd)) {
                    pdInList.add(new BigDecimal(pd));
                }
                if (StringUtils.isNotEmpty(ma)) {
                    maInList.add(new BigDecimal(ma));
                }
            }
            for (TMonthlyQualityReportS5012 monthlyQualityReportS5012 : tMonthlyQualityReportS5012s) {
                String propane = monthlyQualityReportS5012.getPropane();
                String propylene = monthlyQualityReportS5012.getPropylene();
                String pd = monthlyQualityReportS5012.getPropadiene();
                String ma = monthlyQualityReportS5012.getMethylacetylene();
                if (StringUtils.isNotEmpty(propane)) {
                    propaneOutList.add(new BigDecimal(propane));
                }
                if (StringUtils.isNotEmpty(propylene)) {
                    propyleneOutList.add(new BigDecimal(propylene));
                }
                if (StringUtils.isNotEmpty(pd)) {
                    pdOutList.add(new BigDecimal(pd));
                }
                if (StringUtils.isNotEmpty(ma)) {
                    maOutList.add(new BigDecimal(ma));
                }
            }
            //计算sum
            for (BigDecimal value : propaneInList) {
                propaneInSum = propaneInSum.add(value);
            }
            for (BigDecimal value : propyleneInList) {
                propyleneInSum = propyleneInSum.add(value);
            }
            for (BigDecimal value : pdInList) {
                pdInSum = pdInSum.add(value);
            }
            for (BigDecimal value : maInList) {
                maInSum = maInSum.add(value);
            }
            for (BigDecimal value : propaneOutList) {
                propaneOutSum = propaneOutSum.add(value);
            }
            for (BigDecimal value : propyleneOutList) {
                propyleneOutSum = propyleneOutSum.add(value);
            }
            for (BigDecimal value : pdOutList) {
                pdOutSum = pdOutSum.add(value);
            }
            for (BigDecimal value : maOutList) {
                maOutSum = maOutSum.add(value);
            }
            //计算avg
            if (propaneInList.size() != 0) {
                propaneInAvg = propaneInSum.divide(new BigDecimal(propaneInList.size()), 2, RoundingMode.HALF_UP);
            }
            if (propyleneInList.size() != 0) {
                propyleneInAvg = propyleneInSum.divide(new BigDecimal(propyleneInList.size()), 2, RoundingMode.HALF_UP);
            }
            if (pdInList.size() != 0) {
                pdInAvg = pdInSum.divide(new BigDecimal(pdInList.size()), 2, RoundingMode.HALF_UP);
            }
            if (maInList.size() != 0) {
                maInAvg = maInSum.divide(new BigDecimal(maInList.size()), 2, RoundingMode.HALF_UP);
            }
            if (propaneOutList.size() != 0) {
                propaneOutAvg = propaneOutSum.divide(new BigDecimal(propaneOutList.size()), 2, RoundingMode.HALF_UP);
            }
            if (propyleneOutList.size() != 0) {
                propyleneOutAvg = propyleneOutSum.divide(new BigDecimal(propyleneOutList.size()), 2, RoundingMode.HALF_UP);
            }
            if (pdOutList.size() != 0) {
                pdOutAvg = pdOutSum.divide(new BigDecimal(pdOutList.size()), 2, RoundingMode.HALF_UP);
            }
            if (maOutList.size() != 0) {
                maOutAvg = maOutSum.divide(new BigDecimal(maOutList.size()), 2, RoundingMode.HALF_UP);
            }
            if (pdInAvg.compareTo(BigDecimal.ZERO) != 0 && maInAvg.compareTo(BigDecimal.ZERO) != 0) {
                conversion = BigDecimal.TEN.multiply(BigDecimal.TEN).multiply((pdInAvg.add(maInAvg).subtract(pdOutAvg).subtract(maOutAvg)).divide(pdInAvg.add(maInAvg), 2, RoundingMode.HALF_UP));
            }
            if (propaneInAvg.compareTo(BigDecimal.ZERO) != 0 && propyleneInAvg.compareTo(BigDecimal.ZERO) != 0
                    && pdInAvg.compareTo(BigDecimal.ZERO) != 0 && maInAvg.compareTo(BigDecimal.ZERO) != 0
                    && propaneOutAvg.compareTo(BigDecimal.ZERO) != 0 && propyleneOutAvg.compareTo(BigDecimal.ZERO) != 0
                    && pdOutAvg.compareTo(BigDecimal.ZERO) != 0 && maOutAvg.compareTo(BigDecimal.ZERO) != 0) {
                propyleneSelectivity = BigDecimal.TEN.multiply(BigDecimal.TEN).multiply(((propyleneOutAvg.divide(propaneOutAvg.add(propyleneOutAvg).add(pdOutAvg).add(maOutAvg), 2, RoundingMode.HALF_UP))
                        .subtract(propyleneInAvg.divide(propaneInAvg.add(propyleneInAvg).add(pdInAvg).add(maInAvg), 2, RoundingMode.HALF_UP)))
                        .divide(((pdInAvg.add(maInAvg)).divide(propaneInAvg.add(propyleneInAvg).add(pdInAvg).add(maInAvg), 2, RoundingMode.HALF_UP))
                                .subtract((pdOutAvg.add(maOutAvg)).divide(propaneOutAvg.add(propyleneOutAvg).add(pdOutAvg).add(maOutAvg), 2, RoundingMode.HALF_UP)), 2, RoundingMode.HALF_UP));
            }
            C3ReactorAnalysisVO analysisVO = new C3ReactorAnalysisVO();
            analysisVO.setConversion(conversion);
            analysisVO.setPropyleneSelectivity(propyleneSelectivity);
            dataMap.put(startYear + "-" + startMonth, analysisVO);
            if (startMonth == 12) {
                startMonth = 1;
                startYear++;
            } else {
                startMonth++;
            }
            if (!(startYear != endYear || startMonth != endMonth + 1)) {
                break;
            }
        }
        // 获取map第一个元素
        List<String> keys = new ArrayList<>(dataMap.keySet());
        String firstKey = keys.get(0);
        C3ReactorAnalysisVO firstValue = dataMap.get(firstKey);
        // 最大值
        BigDecimal conversionMax = firstValue.getConversion();
        BigDecimal propyleneSelectivityMax = firstValue.getPropyleneSelectivity();
        // 最小值
        BigDecimal conversionMin = firstValue.getConversion();
        BigDecimal propyleneSelectivityMin = firstValue.getPropyleneSelectivity();
        // 平均值
        BigDecimal conversionAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneSelectivityAvg = new BigDecimal(BigInteger.ZERO);
        // 总和
        BigDecimal conversionSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneSelectivitySum = new BigDecimal(BigInteger.ZERO);
        for(Map.Entry entry : dataMap.entrySet()) {
            C3ReactorAnalysisVO mapValue = (C3ReactorAnalysisVO) entry.getValue();
            BigDecimal conversion = mapValue.getConversion();
            BigDecimal propyleneSelectivity = mapValue.getPropyleneSelectivity();
            if (conversion.compareTo(conversionMax) > 0) { conversionMax = conversion; }
            if (propyleneSelectivity.compareTo(propyleneSelectivityMax) > 0) { propyleneSelectivityMax = propyleneSelectivity; }
            if (conversion.compareTo(conversionMin) < 0) { conversionMin = conversion; }
            if (propyleneSelectivity.compareTo(propyleneSelectivityMin) < 0) { propyleneSelectivityMin = propyleneSelectivity; }
            conversionSum = conversionSum.add(conversion);
            propyleneSelectivitySum = propyleneSelectivitySum.add(propyleneSelectivity);
        }
        BigDecimal count = new BigDecimal(dataMap.size());
        conversionAvg = conversionSum.divide(count, 2, RoundingMode.HALF_UP);
        propyleneSelectivityAvg = propyleneSelectivitySum.divide(count, 2, RoundingMode.HALF_UP);
        StringBuffer description = new StringBuffer();
        description.append("conversion(max)="+ conversionMax.toString() + "\t");
        description.append("Selectivity(max)="+ propyleneSelectivityMax.toString() + "\n");
        description.append("conversion(min)="+ conversionMin.toString() + "\t");
        description.append("Selectivity(min)="+ propyleneSelectivityMin.toString() + "\n");
        description.append("conversion(avg)="+ conversionAvg.toString() + "\t");
        description.append("Selectivity(avg)="+ propyleneSelectivityAvg.toString() + "\n");
        QualityAnalysisVO qualityVO = new QualityAnalysisVO();
        qualityVO.setDataMap(dataMap);
        qualityVO.setDescription(description.toString());
        return AjaxResult.success(qualityVO);
    }

    /**
     * 碳三反应器性能指标表格
     */
    @PreAuthorize("@ss.hasPermi('production:quality:list')")
    @GetMapping("/c3ReactorTable")
    public AjaxResult c3ReactorTable(MonthlyQualityReportQueryVO vo)
    {
        return AjaxResult.success(this.calcC3ReactorTable(vo.getStartDate(), vo.getEndDate()));
    }

    private C3ReactorTableVO calcC3ReactorTable(Date startDate, Date endDate) {
        //in
        TMonthlyQualityReportS5010 tMonthlyQualityReportS5010 = new TMonthlyQualityReportS5010();
        tMonthlyQualityReportS5010.setStartDate(startDate);
        tMonthlyQualityReportS5010.setEndDate(endDate);
        List<TMonthlyQualityReportS5010> tMonthlyQualityReportS5010s = tMonthlyQualityReportS5010Service.selectTMonthlyQualityReportS5010List(tMonthlyQualityReportS5010);
        //out
        TMonthlyQualityReportS5012 tMonthlyQualityReportS5012 = new TMonthlyQualityReportS5012();
        tMonthlyQualityReportS5012.setStartDate(startDate);
        tMonthlyQualityReportS5012.setEndDate(endDate);
        List<TMonthlyQualityReportS5012> tMonthlyQualityReportS5012s = tMonthlyQualityReportS5012Service.selectTMonthlyQualityReportS5012List(tMonthlyQualityReportS5012);
        //avg
        BigDecimal propaneInAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneInAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal pdInAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal maInAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propaneOutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneOutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal pdOutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal maOutAvg = new BigDecimal(BigInteger.ZERO);
        BigDecimal conversion = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneSelectivity = new BigDecimal(BigInteger.ZERO);
        //sum
        BigDecimal propaneInSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneInSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal pdInSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal maInSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propaneOutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal propyleneOutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal pdOutSum = new BigDecimal(BigInteger.ZERO);
        BigDecimal maOutSum = new BigDecimal(BigInteger.ZERO);
        //list
        ArrayList<BigDecimal> propaneInList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propyleneInList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> pdInList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> maInList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propaneOutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> propyleneOutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> pdOutList = new ArrayList<BigDecimal>();
        ArrayList<BigDecimal> maOutList = new ArrayList<BigDecimal>();
        //放入list
        for (TMonthlyQualityReportS5010 monthlyQualityReportS5010 : tMonthlyQualityReportS5010s) {
            String propane = monthlyQualityReportS5010.getPropane();
            String propylene = monthlyQualityReportS5010.getPropylene();
            String pd = monthlyQualityReportS5010.getPropadiene();
            String ma = monthlyQualityReportS5010.getMethylacetylene();
            if (StringUtils.isNotEmpty(propane)) { propaneInList.add(new BigDecimal(propane)); }
            if (StringUtils.isNotEmpty(propylene)) { propyleneInList.add(new BigDecimal(propylene)); }
            if (StringUtils.isNotEmpty(pd)) { pdInList.add(new BigDecimal(pd)); }
            if (StringUtils.isNotEmpty(ma)) { maInList.add(new BigDecimal(ma)); }
        }
        for (TMonthlyQualityReportS5012 monthlyQualityReportS5012 : tMonthlyQualityReportS5012s) {
            String propane = monthlyQualityReportS5012.getPropane();
            String propylene = monthlyQualityReportS5012.getPropylene();
            String pd = monthlyQualityReportS5012.getPropadiene();
            String ma = monthlyQualityReportS5012.getMethylacetylene();
            if (StringUtils.isNotEmpty(propane)) { propaneOutList.add(new BigDecimal(propane)); }
            if (StringUtils.isNotEmpty(propylene)) { propyleneOutList.add(new BigDecimal(propylene)); }
            if (StringUtils.isNotEmpty(pd)) { pdOutList.add(new BigDecimal(pd)); }
            if (StringUtils.isNotEmpty(ma)) { maOutList.add(new BigDecimal(ma)); }
        }
        //计算sum
        for (BigDecimal value : propaneInList) { propaneInSum = propaneInSum.add(value); }
        for (BigDecimal value : propyleneInList) { propyleneInSum = propyleneInSum.add(value); }
        for (BigDecimal value : pdInList) { pdInSum = pdInSum.add(value); }
        for (BigDecimal value : maInList) { maInSum = maInSum.add(value); }
        for (BigDecimal value : propaneOutList) { propaneOutSum = propaneOutSum.add(value); }
        for (BigDecimal value : propyleneOutList) { propyleneOutSum = propyleneOutSum.add(value); }
        for (BigDecimal value : pdOutList) { pdOutSum = pdOutSum.add(value); }
        for (BigDecimal value : maOutList) { maOutSum = maOutSum.add(value); }
        //计算avg
        if (propaneInList.size() != 0) { propaneInAvg = propaneInSum.divide(new BigDecimal(propaneInList.size()), 2, RoundingMode.HALF_UP); }
        if (propyleneInList.size() != 0) { propyleneInAvg = propyleneInSum.divide(new BigDecimal(propyleneInList.size()), 2, RoundingMode.HALF_UP); }
        if (pdInList.size() != 0) { pdInAvg = pdInSum.divide(new BigDecimal(pdInList.size()), 2, RoundingMode.HALF_UP); }
        if (maInList.size() != 0) { maInAvg = maInSum.divide(new BigDecimal(maInList.size()), 2, RoundingMode.HALF_UP); }
        if (propaneOutList.size() != 0) { propaneOutAvg = propaneOutSum.divide(new BigDecimal(propaneOutList.size()), 2, RoundingMode.HALF_UP); }
        if (propyleneOutList.size() != 0) { propyleneOutAvg = propyleneOutSum.divide(new BigDecimal(propyleneOutList.size()), 2, RoundingMode.HALF_UP); }
        if (pdOutList.size() != 0) { pdOutAvg = pdOutSum.divide(new BigDecimal(pdOutList.size()), 2, RoundingMode.HALF_UP); }
        if (maOutList.size() != 0) { maOutAvg = maOutSum.divide(new BigDecimal(maOutList.size()), 2, RoundingMode.HALF_UP); }
        if (pdInAvg.compareTo(BigDecimal.ZERO) != 0 && maInAvg.compareTo(BigDecimal.ZERO) != 0) {
            conversion = BigDecimal.TEN.multiply(BigDecimal.TEN).multiply((pdInAvg.add(maInAvg).subtract(pdOutAvg).subtract(maOutAvg)).divide(pdInAvg.add(maInAvg), 2, RoundingMode.HALF_UP));
        }
        if (propaneInAvg.compareTo(BigDecimal.ZERO) != 0 && propyleneInAvg.compareTo(BigDecimal.ZERO) != 0
                && pdInAvg.compareTo(BigDecimal.ZERO) != 0 && maInAvg.compareTo(BigDecimal.ZERO) != 0
                && propaneOutAvg.compareTo(BigDecimal.ZERO) != 0 && propyleneOutAvg.compareTo(BigDecimal.ZERO) != 0
                && pdOutAvg.compareTo(BigDecimal.ZERO) != 0 && maOutAvg.compareTo(BigDecimal.ZERO) != 0) {
            propyleneSelectivity = BigDecimal.TEN.multiply(BigDecimal.TEN).multiply(((propyleneOutAvg.divide(propaneOutAvg.add(propyleneOutAvg).add(pdOutAvg).add(maOutAvg), 2, RoundingMode.HALF_UP))
                    .subtract(propyleneInAvg.divide(propaneInAvg.add(propyleneInAvg).add(pdInAvg).add(maInAvg), 2, RoundingMode.HALF_UP)))
                    .divide(((pdInAvg.add(maInAvg)).divide(propaneInAvg.add(propyleneInAvg).add(pdInAvg).add(maInAvg), 2, RoundingMode.HALF_UP))
                            .subtract((pdOutAvg.add(maOutAvg)).divide(propaneOutAvg.add(propyleneOutAvg).add(pdOutAvg).add(maOutAvg), 2, RoundingMode.HALF_UP)), 2, RoundingMode.HALF_UP));
        }
        C3ReactorTableVO tableVO = new C3ReactorTableVO();
        tableVO.setPropaneInAvg(propaneInAvg);
        tableVO.setPropyleneInAvg(propyleneInAvg);
        tableVO.setPdInAvg(pdInAvg);
        tableVO.setMaInAvg(maInAvg);
        tableVO.setPropaneOutAvg(propaneOutAvg);
        tableVO.setPropyleneOutAvg(propyleneOutAvg);
        tableVO.setPdOutAvg(pdOutAvg);
        tableVO.setMaOutAvg(maOutAvg);
        tableVO.setConversion(conversion);
        tableVO.setPropyleneSelectivity(propyleneSelectivity);
        return tableVO;
    }

    /**
     * 批量导入质量月报
     */
    @PreAuthorize("@ss.hasPermi('production:quality:add')")
    @PostMapping("/importData")
    public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException
    {
        //获取操作人员ID
        Long userId = getUserId();
        Workbook workbook = ExcelUtils.getWorkBook(file);
        Sheet sheet = workbook.getSheetAt(0);
        List<Row> listS0501 = new ArrayList<Row>();
        List<Row> listS1301 = new ArrayList<Row>();
        List<Row> listS2002 = new ArrayList<Row>();
        List<Row> listS2005 = new ArrayList<Row>();
        List<Row> listS2007 = new ArrayList<Row>();
        List<Row> listS2011 = new ArrayList<Row>();
        List<Row> listS2400 = new ArrayList<Row>();
        List<Row> listS3004 = new ArrayList<Row>();
        List<Row> listS3009 = new ArrayList<Row>();
        List<Row> listS3010 = new ArrayList<Row>();
        List<Row> listS3011 = new ArrayList<Row>();
        List<Row> listS3012 = new ArrayList<Row>();
        List<Row> listS3022 = new ArrayList<Row>();
        List<Row> listS4012 = new ArrayList<Row>();
        List<Row> listS4013 = new ArrayList<Row>();
        List<Row> listS4501 = new ArrayList<Row>();
        List<Row> listS5001 = new ArrayList<Row>();
        List<Row> listS5003 = new ArrayList<Row>();
        List<Row> listS5010 = new ArrayList<Row>();
        List<Row> listS5012 = new ArrayList<Row>();
        List<Row> listS6101 = new ArrayList<Row>();
        List<Row> listS6107 = new ArrayList<Row>();
        List<Row> listS6301 = new ArrayList<Row>();
        List<Row> listZ404 = new ArrayList<Row>();
        int rowNum = sheet.getPhysicalNumberOfRows();
        for (int i = 0; i <= rowNum + 100; i++) {
            try {
                Row row = sheet.getRow(i);
                Cell cell = row.getCell(1);
                cell.setCellType(CellType.STRING);
                String cellValue = ExcelUtils.getCellValue(cell);
                if ("S-0501".equals(cellValue) || "S0501".equals(cellValue)) {
                    listS0501.add(row);
                } else if ("S-2002".equals(cellValue) || "S2002".equals(cellValue)) {
                    listS2002.add(row);
                } else if ("S-2005".equals(cellValue) || "S2005".equals(cellValue)) {
                    listS2005.add(row);
                } else if ("S-2007".equals(cellValue) || "S2007".equals(cellValue)) {
                    listS2007.add(row);
                } else if ("S-2011".equals(cellValue) || "S2011".equals(cellValue)) {
                    listS2011.add(row);
                } else if ("S-2400".equals(cellValue) || "S2400".equals(cellValue)) {
                    listS2400.add(row);
                } else if ("S-3004".equals(cellValue) || "S3004".equals(cellValue)) {
                    listS3004.add(row);
                } else if ("S-3009".equals(cellValue) || "S3009".equals(cellValue)) {
                    listS3009.add(row);
                } else if ("S-3010".equals(cellValue) || "S3010".equals(cellValue)) {
                    listS3010.add(row);
                } else if ("S-3011".equals(cellValue) || "S3011".equals(cellValue)) {
                    listS3011.add(row);
                } else if ("S-3012".equals(cellValue) || "S3012".equals(cellValue)) {
                    listS3012.add(row);
                } else if ("S-3022".equals(cellValue) || "S3022".equals(cellValue)) {
                    listS3022.add(row);
                } else if ("S-4012".equals(cellValue) || "S4012".equals(cellValue)) {
                    listS4012.add(row);
                } else if ("S-4013".equals(cellValue) || "S4013".equals(cellValue)) {
                    listS4013.add(row);
                } else if ("S-5001".equals(cellValue) || "S5001".equals(cellValue)) {
                    listS5001.add(row);
                } else if ("S-5003".equals(cellValue) || "S5003".equals(cellValue)) {
                    listS5003.add(row);
                } else if ("S-5010".equals(cellValue) || "S5010".equals(cellValue)) {
                    listS5010.add(row);
                } else if ("S-5012".equals(cellValue) || "S5012".equals(cellValue)) {
                    listS5012.add(row);
                } else if ("S-6107".equals(cellValue) || "S6107".equals(cellValue)) {
                    listS6107.add(row);
                } else if ("S1301".equals(cellValue) || "S-1301".equals(cellValue)) {
                    listS1301.add(row);
                } else if ("S4501".equals(cellValue) || "S-4501".equals(cellValue)) {
                    listS4501.add(row);
                } else if ("S6101".equals(cellValue) || "S-6101".equals(cellValue)) {
                    listS6101.add(row);
                } else if ("S6301".equals(cellValue) || "S-6301".equals(cellValue)) {
                    listS6301.add(row);
                } else if ("Z-404".equals(cellValue) || "Z404".equals(cellValue)) {
                    listZ404.add(row);
                }
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        int successNumber = 0;
        for (Row row : listS0501) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS0501 entity = new TMonthlyQualityReportS0501();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 51) {
                        entity.setP(cellValue);
                    } else if (j == 52) {
                        entity.setI(cellValue);
                    } else if (j == 53) {
                        entity.setO(cellValue);
                    } else if (j == 54) {
                        entity.setN(cellValue);
                    } else if (j == 55) {
                        entity.setA(cellValue);
                    } else if (j == 56) {
                        entity.setPI(cellValue);
                    } else if (j == 81) {
                        entity.setDensity2(cellValue);
                    } else if (j == 82) {
                        entity.setIbp(cellValue);
                    } else if (j == 83) {
                        entity.setFive(cellValue);
                    } else if (j == 84) {
                        entity.setTen(cellValue);
                    } else if (j == 85) {
                        entity.setThrity(cellValue);
                    } else if (j == 86) {
                        entity.setFifty(cellValue);
                    } else if (j == 87) {
                        entity.setSeventy(cellValue);
                    } else if (j == 88) {
                        entity.setNinety(cellValue);
                    } else if (j == 89) {
                        entity.setNinetyFive(cellValue);
                    } else if (j == 90) {
                        entity.setFbp(cellValue);
                    } else if (j == 92) {
                        entity.setTotalSulfur(cellValue);
                    }
                }
                tMonthlyQualityReportS0501Service.insertTMonthlyQualityReportS0501(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS1301) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS1301 entity = new TMonthlyQualityReportS1301();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setNa(cellValue);
                    } else if (j == 5) {
                        entity.setBenzene(cellValue);
                    } else if (j == 6) {
                        entity.setToluene(cellValue);
                    } else if (j == 7) {
                        entity.setEthylbenzene(cellValue);
                    } else if (j == 8) {
                        entity.setpXylene(cellValue);
                    } else if (j == 9) {
                        entity.setmXylene(cellValue);
                    } else if (j == 10) {
                        entity.setoXylene(cellValue);
                    } else if (j == 11) {
                        entity.setStyrene(cellValue);
                    } else if (j == 12) {
                        entity.setPhenylacetylene(cellValue);
                    } else if (j == 15) {
                        entity.setTotalAromatics(cellValue);
                    } else if (j == 16) {
                        entity.setBrNumber(cellValue);
                    } else if (j == 27) {
                        entity.setDieneValue(cellValue);
                    } else if (j == 28) {
                        entity.setTotalNitrogen(cellValue);
                    } else if (j == 29) {
                        entity.setTemperatureIn(cellValue);
                    } else if (j == 30) {
                        entity.setTemperatureRaise(cellValue);
                    }
                }
                tMonthlyQualityReportS1301Service.insertTMonthlyQualityReportS1301(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS2002) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS2002 entity = new TMonthlyQualityReportS2002();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setCod(cellValue);
                    } else if (j == 5) {
                        entity.setPh(cellValue);
                    }
                }
                tMonthlyQualityReportS2002Service.insertTMonthlyQualityReportS2002(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS2005) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS2005 entity = new TMonthlyQualityReportS2005();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 5) {
                        entity.setPh(cellValue);
                    } else if (j == 13) {
                        entity.setOilRatio(cellValue);
                    }
                }
                tMonthlyQualityReportS2005Service.insertTMonthlyQualityReportS2005(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS2007) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS2007 entity = new TMonthlyQualityReportS2007();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setViscosity(cellValue);
                    } else if (j == 5) {
                        entity.setEndPoint(cellValue);
                    } else if (j == 6) {
                        entity.setPressureDifference(cellValue);
                    } else if (j == 7) {
                        entity.setProduction(cellValue);
                    }
                }
                tMonthlyQualityReportS2007Service.insertTMonthlyQualityReportS2007(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS2011) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS2011 entity = new TMonthlyQualityReportS2011();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setDensity1(cellValue);
                    } else if (j == 5) {
                        entity.setIbp(cellValue);
                    } else if (j == 13) {
                        entity.setFbp(cellValue);
                    }
                }
                tMonthlyQualityReportS2011Service.insertTMonthlyQualityReportS2011(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS2400) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS2400 entity = new TMonthlyQualityReportS2400();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setCod(cellValue);
                    } else if (j == 5) {
                        entity.setPh(cellValue);
                    }
                }
                tMonthlyQualityReportS2400Service.insertTMonthlyQualityReportS2400(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS3004) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS3004 entity = new TMonthlyQualityReportS3004();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setNaOh(cellValue);
                    } else if (j == 5) {
                        entity.setNa2Co3(cellValue);
                    } else if (j == 6) {
                        entity.setNa2S(cellValue);
                    }
                }
                tMonthlyQualityReportS3004Service.insertTMonthlyQualityReportS3004(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS3009) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS3009 entity = new TMonthlyQualityReportS3009();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setCarbonMonoxide(cellValue);
                    } else if (j == 5) {
                        entity.setMethane(cellValue);
                    } else if (j == 6) {
                        entity.setEthane(cellValue);
                    } else if (j == 7) {
                        entity.setEthylene(cellValue);
                    } else if (j == 8) {
                        entity.setPropane(cellValue);
                    } else if (j == 9) {
                        entity.setCycPropane(cellValue);
                    } else if (j == 10) {
                        entity.setPropylene(cellValue);
                    } else if (j == 11) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 12) {
                        entity.setAcetylene(cellValue);
                    } else if (j == 15) {
                        entity.setMethylacetylene(cellValue);
                    } else if (j == 21) {
                        entity.setHydrogen(cellValue);
                    }
                }
                tMonthlyQualityReportS3009Service.insertTMonthlyQualityReportS3009(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS3010) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS3010 entity = new TMonthlyQualityReportS3010();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setAcetylene(cellValue);
                    }  else if (j == 5) {
                        entity.setCarbonMonoxide(cellValue);
                    } else if (j == 6) {
                        entity.setMethane(cellValue);
                    } else if (j == 7) {
                        entity.setEthane(cellValue);
                    } else if (j == 8) {
                        entity.setEthylene(cellValue);
                    } else if (j == 9) {
                        entity.setPropane(cellValue);
                    } else if (j == 10) {
                        entity.setCycPropane(cellValue);
                    } else if (j == 11) {
                        entity.setPropylene(cellValue);
                    } else if (j == 12) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 16) {
                        entity.setMethylacetylene(cellValue);
                    } else if (j == 22) {
                        entity.setHydrogen(cellValue);
                    }
                }
                tMonthlyQualityReportS3010Service.insertTMonthlyQualityReportS3010(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS3011) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS3011 entity = new TMonthlyQualityReportS3011();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setCarbonMonoxide(cellValue);
                    } else if (j == 5) {
                        entity.setMethane(cellValue);
                    } else if (j == 6) {
                        entity.setEthane(cellValue);
                    } else if (j == 7) {
                        entity.setEthylene(cellValue);
                    } else if (j == 8) {
                        entity.setPropane(cellValue);
                    } else if (j == 9) {
                        entity.setCycPropane(cellValue);
                    } else if (j == 10) {
                        entity.setPropylene(cellValue);
                    } else if (j == 11) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 12) {
                        entity.setAcetylene(cellValue);
                    } else if (j == 15) {
                        entity.setMethylacetylene(cellValue);
                    } else if (j == 21) {
                        entity.setHydrogen(cellValue);
                    }
                }
                tMonthlyQualityReportS3011Service.insertTMonthlyQualityReportS3011(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS3012) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS3012 entity = new TMonthlyQualityReportS3012();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setAcetylene(cellValue);
                    }  else if (j == 5) {
                        entity.setCarbonMonoxide(cellValue);
                    } else if (j == 6) {
                        entity.setMethane(cellValue);
                    } else if (j == 7) {
                        entity.setEthane(cellValue);
                    } else if (j == 8) {
                        entity.setEthylene(cellValue);
                    } else if (j == 9) {
                        entity.setPropane(cellValue);
                    } else if (j == 10) {
                        entity.setCycPropane(cellValue);
                    } else if (j == 11) {
                        entity.setPropylene(cellValue);
                    } else if (j == 12) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 16) {
                        entity.setMethylacetylene(cellValue);
                    } else if (j == 22) {
                        entity.setHydrogen(cellValue);
                    }
                }
                tMonthlyQualityReportS3012Service.insertTMonthlyQualityReportS3012(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS3022) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS3022 entity = new TMonthlyQualityReportS3022();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 5) {
                        entity.setNaoh(cellValue);
                    } else if (j == 6) {
                        entity.setNa2co3(cellValue);
                    } else if (j == 7) {
                        entity.setNa2s(cellValue);
                    }
                }
                tMonthlyQualityReportS3022Service.insertTMonthlyQualityReportS3022(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS4012) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS4012 entity = new TMonthlyQualityReportS4012();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setMethane(cellValue);
                    } else if (j == 5) {
                        entity.setEthane(cellValue);
                    } else if (j == 6) {
                        entity.setEthylene(cellValue);
                    } else if (j == 7) {
                        entity.setPropane(cellValue);
                    } else if (j == 8) {
                        entity.setPropylene(cellValue);
                    }
                }
                tMonthlyQualityReportS4012Service.insertTMonthlyQualityReportS4012(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS4013) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS4013 entity = new TMonthlyQualityReportS4013();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 5) {
                        entity.setEthane(cellValue);
                    } else if (j == 8) {
                        entity.setMethaneEthane(cellValue);
                    } else if (j == 10) {
                        entity.setEthylene(cellValue);
                    } else if (j == 11) {
                        entity.setAcetylene(cellValue);
                    } else if (j == 12) {
                        entity.setCarbonMonoxide(cellValue);
                    } else if (j == 13) {
                        entity.setCarbonDioxide(cellValue);
                    }
                }
                tMonthlyQualityReportS4013Service.insertTMonthlyQualityReportS4013(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS4501) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS4501 entity = new TMonthlyQualityReportS4501();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setBenzene(cellValue);
                    } else if (j == 5) {
                        entity.setToluene(cellValue);
                    } else if (j == 7) {
                        entity.setEthylbenzene(cellValue);
                    } else if (j == 8) {
                        entity.setmXylene(cellValue);
                    } else if (j == 9) {
                        entity.setoXylene(cellValue);
                    } else if (j == 10) {
                        entity.setpXylene(cellValue);
                    } else if (j == 13) {
                        entity.setC5Na(cellValue);
                    } else if (j == 14) {
                        entity.setC6Na(cellValue);
                    } else if (j == 15) {
                        entity.setC7Na(cellValue);
                    } else if (j == 16) {
                        entity.setC8Na(cellValue);
                    } else if (j == 17) {
                        entity.setC9(cellValue);
                    } else if (j == 18) {
                        entity.setC8A(cellValue);
                    } else if (j == 19) {
                        entity.setC4C5Na(cellValue);
                    } else if (j == 20) {
                        entity.setC6C8Na(cellValue);
                    } else if (j == 21) {
                        entity.setC4C8Na(cellValue);
                    } else if (j == 22) {
                        entity.setBrIndex(cellValue);
                    } else if (j == 24) {
                        entity.setTotalSulfur(cellValue);
                    } else if (j == 25) {
                        entity.setTotalNitrogen(cellValue);
                    } else if (j == 26) {
                        entity.setTemperatureIn(cellValue);
                    } else if (j == 27) {
                        entity.setTemperatureRaise(cellValue);
                    } else if (j == 28) {
                        entity.setPressureDiff(cellValue);
                    }
                }
                tMonthlyQualityReportS4501Service.insertTMonthlyQualityReportS4501(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS5001) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS5001 entity = new TMonthlyQualityReportS5001();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 7) {
                        entity.setPropane(cellValue);
                    } else if (j == 8) {
                        entity.setCycPropane(cellValue);
                    } else if (j == 9) {
                        entity.setPropylene(cellValue);
                    } else if (j == 10) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 14) {
                        entity.setMethylacetylene(cellValue);
                    } else if (j == 18) {
                        entity.setButene(cellValue);
                    }
                }
                tMonthlyQualityReportS5001Service.insertTMonthlyQualityReportS5001(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS5003) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS5003 entity = new TMonthlyQualityReportS5003();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setMethane(cellValue);
                    } else if (j == 5) {
                        entity.setEthane(cellValue);
                    } else if (j == 6) {
                        entity.setEthylene(cellValue);
                    } else if (j == 7) {
                        entity.setPropane(cellValue);
                    } else if (j == 8) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 11) {
                        entity.setMethylacetylene(cellValue);
                    } else if (j == 15) {
                        entity.setButeneButadiene(cellValue);
                    } else if (j == 16) {
                        entity.setPropadieneMethylacetylene(cellValue);
                    } else if (j == 17) {
                        entity.setTotals(cellValue);
                    } else if (j == 18) {
                        entity.setParaffine(cellValue);
                    } else if (j == 19) {
                        entity.setPropylene(cellValue);
                    } else if (j == 20) {
                        entity.setMethanol(cellValue);
                    }
                }
                tMonthlyQualityReportS5003Service.insertTMonthlyQualityReportS5003(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS5010) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS5010 entity = new TMonthlyQualityReportS5010();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 7) {
                        entity.setPropane(cellValue);
                    } else if (j == 9) {
                        entity.setPropylene(cellValue);
                    } else if (j == 10) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 11) {
                        entity.setAcetylene(cellValue);
                    } else if (j == 12) {
                        entity.setButadiene12(cellValue);
                    } else if (j == 13) {
                        entity.setButadiene13(cellValue);
                    } else if (j == 14) {
                        entity.setMethylacetylene(cellValue);
                    }
                }
                tMonthlyQualityReportS5010Service.insertTMonthlyQualityReportS5010(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS5012) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS5012 entity = new TMonthlyQualityReportS5012();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 7) {
                        entity.setPropane(cellValue);
                    } else if (j == 9) {
                        entity.setPropylene(cellValue);
                    } else if (j == 10) {
                        entity.setPropadiene(cellValue);
                    } else if (j == 11) {
                        entity.setAcetylene(cellValue);
                    } else if (j == 12) {
                        entity.setButadiene12(cellValue);
                    } else if (j == 13) {
                        entity.setButadiene13(cellValue);
                    } else if (j == 14) {
                        entity.setMethylacetylene(cellValue);
                    }
                }
                tMonthlyQualityReportS5012Service.insertTMonthlyQualityReportS5012(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS6101) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS6101 entity = new TMonthlyQualityReportS6101();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setBenzene(cellValue);
                    } else if (j == 5) {
                        entity.setToluene(cellValue);
                    } else if (j == 6) {
                        entity.setDcpd(cellValue);
                    } else if (j == 7) {
                        entity.setEthylbenzene(cellValue);
                    } else if (j == 8) {
                        entity.setmXylene(cellValue);
                    } else if (j == 9) {
                        entity.setoXylene(cellValue);
                    } else if (j == 10) {
                        entity.setpXylene(cellValue);
                    } else if (j == 11) {
                        entity.setStyrene(cellValue);
                    } else if (j == 13) {
                        entity.setC5Na(cellValue);
                    } else if (j == 14) {
                        entity.setC6Na(cellValue);
                    } else if (j == 15) {
                        entity.setC7Na(cellValue);
                    } else if (j == 16) {
                        entity.setC8Na(cellValue);
                    } else if (j == 17) {
                        entity.setC9(cellValue);
                    } else if (j == 18) {
                        entity.setC8A(cellValue);
                    } else if (j == 19) {
                        entity.setC4C5Na(cellValue);
                    } else if (j == 20) {
                        entity.setC6C8Na(cellValue);
                    } else if (j == 21) {
                        entity.setC4C8Na(cellValue);
                    } else if (j == 22) {
                        entity.setDensity1(cellValue);
                    } else if (j == 23) {
                        entity.setBrNumber(cellValue);
                    } else if (j == 35) {
                        entity.setTotalSulfur(cellValue);
                    } else if (j == 36) {
                        entity.setTotalNitrogen(cellValue);
                    }
                }
                tMonthlyQualityReportS6101Service.insertTMonthlyQualityReportS6101(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS6107) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS6107 entity = new TMonthlyQualityReportS6107();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setCod(cellValue);
                    } else if (j == 5) {
                        entity.setPh(cellValue);
                    }
                }
                tMonthlyQualityReportS6107Service.insertTMonthlyQualityReportS6107(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listS6301) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportS6301 entity = new TMonthlyQualityReportS6301();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 7) {
                        entity.setIc5(cellValue);
                    } else if (j == 8) {
                        entity.setDcpd(cellValue);
                    } else if (j == 9) {
                        entity.setC5(cellValue);
                    } else if (j == 10) {
                        entity.setC5ConjugatedDienesDcpd30(cellValue);
                    } else if (j == 11) {
                        entity.setPentadieneCycc5(cellValue);
                    } else if (j == 12) {
                        entity.setC4(cellValue);
                    } else if (j == 14) {
                        entity.setC5ConjugatedDienesDcpd40(cellValue);
                    } else if (j == 15) {
                        entity.setC410(cellValue);
                    } else if (j == 17) {
                        entity.setTotalSulfur(cellValue);
                    } else if (j == 18) {
                        entity.setTotalSulfur150(cellValue);
                    } else if (j == 19) {
                        entity.setSilicon(cellValue);
                    } else if (j == 20) {
                        entity.setC250(cellValue);
                    }
                }
                tMonthlyQualityReportS6301Service.insertTMonthlyQualityReportS6301(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        for (Row row : listZ404) {
            try {
                int cellNum = row.getLastCellNum();
                TMonthlyQualityReportZ404 entity = new TMonthlyQualityReportZ404();
                entity.setDelFlag("0");
                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                entity.setCreateBy(userId.toString());
                for (int j = 0; j < cellNum; j++) {
                    Cell cell = row.getCell(j);
                    String cellValue = ExcelUtils.getCellValue(cell);
                    if (cellValue.indexOf("<") != -1) {
                        cellValue = cellValue.substring(cellValue.indexOf("<") + 1);
                    }
                    if (j == 0) {
                        entity.setLocationName(cellValue);
                    } else if (j == 1) {
                        entity.setSamplePoint(cellValue);
                    } else if (j == 2) {
                        if (cellValue.length() > 3) {
                            entity.setSampleDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
                        }
                    } else if (j == 3) {
                        entity.setSampleName(cellValue);
                    } else if (j == 4) {
                        entity.setMethane(cellValue);
                    } else if (j == 5) {
                        entity.setEthane(cellValue);
                    } else if (j == 6) {
                        entity.setEthylene(cellValue);
                    } else if (j == 7) {
                        entity.setPropane(cellValue);
                    } else if (j == 8) {
                        entity.setPropylene(cellValue);
                    } else if (j == 9) {
                        entity.setUnknown(cellValue);
                    } else if (j == 10) {
                        entity.setHydrogen(cellValue);
                    }
                }
                tMonthlyQualityReportZ404Service.insertTMonthlyQualityReportZ404(entity);
                successNumber++;
            } catch (Exception e) {
                logger.info("e:" + e);
            }
        }
        logger.info("successNumber:" +String.valueOf(successNumber));
        return AjaxResult.success("成功导入: " + String.valueOf(successNumber) + " 条");
    }

    /**
     * 导出质量月报
     */
    @PostMapping("/export")
    public AjaxResult export(HttpServletResponse response,
                             @RequestParam("files") MultipartFile[] files,
                             @RequestParam("startDate") Date startDate,
                             @RequestParam("endDate") Date endDate) throws IOException, InvalidFormatException {
        // 碳二反应器性能指标表格数据
        C2ReactorTableVO c2ReactorTableVO = this.calcC2ReactorTable(startDate, endDate);
        // 碳三反应器性能指标表格数据
        C3ReactorTableVO c3ReactorTableVO = this.calcC3ReactorTable(startDate, endDate);
        // echarts截图
        String[] base64Image = new String[15];
        for (MultipartFile file : files) {
            // 文件名
            String fileName = file.getOriginalFilename();
            // base64编码
            BASE64Encoder encoder = new BASE64Encoder();
            String baseStr = encoder.encode(file.getBytes());
            baseStr = baseStr.replaceAll("\r\n", "");
            switch (fileName) {
                case "chart1.jpg": base64Image[0] = baseStr; break;
                case "chart2.jpg": base64Image[1] = baseStr; break;
                case "chart3.jpg": base64Image[2] = baseStr; break;
                case "chart4.jpg": base64Image[3] = baseStr; break;
                case "chart5.jpg": base64Image[4] = baseStr; break;
                case "chart6.jpg": base64Image[5] = baseStr; break;
                case "chart7.jpg": base64Image[6] = baseStr; break;
                case "chart8.jpg": base64Image[7] = baseStr; break;
                case "chart9.jpg": base64Image[8] = baseStr; break;
                case "chart10.jpg": base64Image[9] = baseStr; break;
                case "chart11.jpg": base64Image[10] = baseStr; break;
                case "chart12.jpg": base64Image[11] = baseStr; break;
                case "chart13.jpg": base64Image[12] = baseStr; break;
                case "chart14.jpg": base64Image[13] = baseStr; break;
                case "chart15.jpg": base64Image[14] = baseStr; break;
            }
        }
        // 创建一个新的Word文档
        XWPFDocument document = new XWPFDocument();
        for (int i = 0; i < 15; i++) {
            // 创建一个段落
            XWPFParagraph paragraph = document.createParagraph();
            // 左对齐
            paragraph.setAlignment(ParagraphAlignment.LEFT);
            XWPFRun run = paragraph.createRun();
            // base64解码
            byte[] decode = Base64.getDecoder().decode(base64Image[i]);
            // 在段落中添加图片
            run.addPicture(new ByteArrayInputStream(decode), XWPFDocument.PICTURE_TYPE_PNG, "chart"+ (i + 1) +".png", Units.toEMU(400), Units.toEMU(200));
            if (i == 9) {
                // 创建一个新的表格
                XWPFTable table = document.createTable();

                // 添加表格头行
                XWPFTableRow headerRow = table.getRow(0);
                headerRow.getCell(0).setText("BYC performance of C2 reactor");
                headerRow.addNewTableCell().setText("");
                headerRow.addNewTableCell().setText("");
                headerRow.addNewTableCell().setText("");
                headerRow.addNewTableCell().setText("");

                // 添加表格数据行
                XWPFTableRow dataRow1 = table.createRow();
                dataRow1.getCell(0).setText("");
                dataRow1.getCell(1).setText("1st inlet");
                dataRow1.getCell(2).setText("2nd inlet");
                dataRow1.getCell(3).setText("3rd inlet");
                dataRow1.getCell(4).setText("3rd outlet");

                XWPFTableRow dataRow2 = table.createRow();
                dataRow2.getCell(0).setText("ethane");
                dataRow2.getCell(1).setText(c2ReactorTableVO.getEthane1InAvg().toString());
                dataRow2.getCell(2).setText(c2ReactorTableVO.getEthane2InAvg().toString());
                dataRow2.getCell(3).setText(c2ReactorTableVO.getEthane3InAvg().toString());
                dataRow2.getCell(4).setText(c2ReactorTableVO.getEthane3OutAvg().toString());

                XWPFTableRow dataRow3 = table.createRow();
                dataRow3.getCell(0).setText("ethylene");
                dataRow3.getCell(1).setText(c2ReactorTableVO.getEthylene1InAvg().toString());
                dataRow3.getCell(2).setText(c2ReactorTableVO.getEthylene2InAvg().toString());
                dataRow3.getCell(3).setText(c2ReactorTableVO.getEthylene3InAvg().toString());
                dataRow3.getCell(4).setText(c2ReactorTableVO.getEthylene3OutAvg().toString());

                XWPFTableRow dataRow4 = table.createRow();
                dataRow4.getCell(0).setText("acetylene");
                dataRow4.getCell(1).setText(c2ReactorTableVO.getAcetylene1InAvg().toString());
                dataRow4.getCell(2).setText(c2ReactorTableVO.getAcetylene2InAvg().toString());
                dataRow4.getCell(3).setText(c2ReactorTableVO.getAcetylene3InAvg().toString());
                dataRow4.getCell(4).setText(c2ReactorTableVO.getAcetylene3OutAvg().toString());

                XWPFTableRow dataRow5 = table.createRow();
                dataRow5.getCell(0).setText("propane");
                dataRow5.getCell(1).setText(c2ReactorTableVO.getPropane1InAvg().toString());
                dataRow5.getCell(2).setText(c2ReactorTableVO.getPropane2InAvg().toString());
                dataRow5.getCell(3).setText(c2ReactorTableVO.getPropane3InAvg().toString());
                dataRow5.getCell(4).setText(c2ReactorTableVO.getPropane3OutAvg().toString());

                XWPFTableRow dataRow6 = table.createRow();
                dataRow6.getCell(0).setText("propylene");
                dataRow6.getCell(1).setText(c2ReactorTableVO.getPropylene1InAvg().toString());
                dataRow6.getCell(2).setText(c2ReactorTableVO.getPropylene2InAvg().toString());
                dataRow6.getCell(3).setText(c2ReactorTableVO.getPropylene3InAvg().toString());
                dataRow6.getCell(4).setText(c2ReactorTableVO.getPropylene3OutAvg().toString());

                XWPFTableRow dataRow7 = table.createRow();
                dataRow7.getCell(0).setText("PD");
                dataRow7.getCell(1).setText(c2ReactorTableVO.getPd1InAvg().toString());
                dataRow7.getCell(2).setText(c2ReactorTableVO.getPd2InAvg().toString());
                dataRow7.getCell(3).setText(c2ReactorTableVO.getPd3InAvg().toString());
                dataRow7.getCell(4).setText(c2ReactorTableVO.getPd3OutAvg().toString());

                XWPFTableRow dataRow8 = table.createRow();
                dataRow8.getCell(0).setText("MA");
                dataRow8.getCell(1).setText(c2ReactorTableVO.getMa1InAvg().toString());
                dataRow8.getCell(2).setText(c2ReactorTableVO.getMa2InAvg().toString());
                dataRow8.getCell(3).setText(c2ReactorTableVO.getMa3InAvg().toString());
                dataRow8.getCell(4).setText(c2ReactorTableVO.getMa3OutAvg().toString());

                XWPFTableRow dataRow9 = table.createRow();
                dataRow9.getCell(0).setText("acetylene Conversion");
                dataRow9.getCell(1).setText(c2ReactorTableVO.getAcetyleneConversion1stIn().toString());
                dataRow9.getCell(2).setText(c2ReactorTableVO.getAcetyleneConversion2ndIn().toString());
                dataRow9.getCell(3).setText(c2ReactorTableVO.getAcetyleneConversion3rdIn().toString());
                dataRow9.getCell(4).setText(c2ReactorTableVO.getAcetyleneConversion3rdOut().toString());

                XWPFTableRow dataRow10 = table.createRow();
                dataRow10.getCell(0).setText("Conversion load%");
                dataRow10.getCell(1).setText(c2ReactorTableVO.getConversionLoad1stIn().toString());
                dataRow10.getCell(2).setText(c2ReactorTableVO.getConversionLoad2ndIn().toString());
                dataRow10.getCell(3).setText(c2ReactorTableVO.getConversionLoad3rdIn().toString());
                dataRow10.getCell(4).setText("");

                XWPFTableRow dataRow11 = table.createRow();
                dataRow11.getCell(0).setText("Ethylene Selectivity");
                dataRow11.getCell(1).setText(c2ReactorTableVO.getEthyleneSelectivity1stIn().toString());
                dataRow11.getCell(2).setText(c2ReactorTableVO.getEthyleneSelectivity2ndIn().toString());
                dataRow11.getCell(3).setText(c2ReactorTableVO.getEthyleneSelectivity3rdIn().toString());
                dataRow11.getCell(4).setText(c2ReactorTableVO.getEthyleneSelectivity3rdOut().toString());

                XWPFTableRow dataRow12 = table.createRow();
                dataRow12.getCell(0).setText("MAPD Conversion");
                dataRow12.getCell(1).setText(c2ReactorTableVO.getMapdConversion1stIn().toString() + "%");
                dataRow12.getCell(2).setText(c2ReactorTableVO.getMapdConversion2ndIn().toString() + "%");
                dataRow12.getCell(3).setText(c2ReactorTableVO.getMapdConversion3rdIn().toString() + "%");
                dataRow12.getCell(4).setText(c2ReactorTableVO.getMapdConversion3rdOut().toString() + "%");

                XWPFTableRow dataRow13 = table.createRow();
                dataRow13.getCell(0).setText("Propylene Selectivity");
                dataRow13.getCell(1).setText(c2ReactorTableVO.getPropyleneSelectivity1stIn().toString() + "%");
                dataRow13.getCell(2).setText(c2ReactorTableVO.getPropyleneSelectivity2ndIn().toString() + "%");
                dataRow13.getCell(3).setText(c2ReactorTableVO.getPropyleneSelectivity3rdIn().toString() + "%");
                dataRow13.getCell(4).setText(c2ReactorTableVO.getPropyleneSelectivity3rdOut().toString() + "%");
            } else if (i == 10) {
                // 创建一个新的表格
                XWPFTable table = document.createTable();

                // 添加表格头行
                XWPFTableRow headerRow = table.getRow(0);
                headerRow.getCell(0).setText("BYC performance of C3 reactor");
                headerRow.addNewTableCell().setText("");
                headerRow.addNewTableCell().setText("R520B");

                // 添加表格数据行
                XWPFTableRow dataRow1 = table.createRow();
                dataRow1.getCell(0).setText("");
                dataRow1.getCell(1).setText("reactor inlet");
                dataRow1.getCell(2).setText("reactor outlet");

                XWPFTableRow dataRow2 = table.createRow();
                dataRow2.getCell(0).setText("propane");
                dataRow2.getCell(1).setText(c3ReactorTableVO.getPropaneInAvg().toString());
                dataRow2.getCell(2).setText(c3ReactorTableVO.getPropaneOutAvg().toString());

                XWPFTableRow dataRow3 = table.createRow();
                dataRow3.getCell(0).setText("propylene");
                dataRow3.getCell(1).setText(c3ReactorTableVO.getPropyleneInAvg().toString());
                dataRow3.getCell(2).setText(c3ReactorTableVO.getPropyleneOutAvg().toString());

                XWPFTableRow dataRow4 = table.createRow();
                dataRow4.getCell(0).setText("PD");
                dataRow4.getCell(1).setText(c3ReactorTableVO.getPdInAvg().toString());
                dataRow4.getCell(2).setText(c3ReactorTableVO.getPdOutAvg().toString());

                XWPFTableRow dataRow5 = table.createRow();
                dataRow5.getCell(0).setText("MA");
                dataRow5.getCell(1).setText(c3ReactorTableVO.getMaInAvg().toString());
                dataRow5.getCell(2).setText(c3ReactorTableVO.getMaOutAvg().toString());

                XWPFTableRow dataRow6 = table.createRow();
                dataRow6.getCell(0).setText("conversion");
                dataRow6.getCell(1).setText(c3ReactorTableVO.getConversion().toString() + "%");
                dataRow6.getCell(2).setText("");

                XWPFTableRow dataRow7 = table.createRow();
                dataRow7.getCell(0).setText("Propylene Selectivity");
                dataRow7.getCell(1).setText(c3ReactorTableVO.getPropyleneSelectivity().toString() + "%");
                dataRow7.getCell(2).setText("");
            }
            run.addCarriageReturn();
            String comment = this.getComment(Long.valueOf(i + 1), startDate, endDate);
            run.setText(comment);
            run.addCarriageReturn();
        }
        // 保存文档
        String fileName = UUID.randomUUID().toString() + "_" + "质量月报.docx";
        String downloadPath = RuoYiConfig.getDownloadPath() + fileName;
        File desc = new File(downloadPath);
        if (!desc.getParentFile().exists())
        {
            desc.getParentFile().mkdirs();
        }
        FileOutputStream out = new FileOutputStream(downloadPath);
        document.write(out);
        out.close();
        return AjaxResult.success(fileName);
    }
    private String getComment(Long CommentType, Date startDate, Date endDate) {
        TMonthlyQualityComment comment = new TMonthlyQualityComment();
        comment.setStartDate(startDate);
        comment.setEndDate(endDate);
        comment.setCommentType(CommentType);
        TMonthlyQualityComment result = tMonthlyQualityCommentService.selectTMonthlyQualityCommentByTypeAndDate(comment);
        if (result != null) {
            return result.getQualityComment();
        } else {
            return "";
        }
    }
}