package com.ruoyi.project.production.controller;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.stuxuhai.jpinyin.PinyinException;
import com.ruoyi.common.jpush.JiGuangPushService;
import com.ruoyi.common.sendEmail.IMailService;
import com.ruoyi.common.thread.furnance.FurnancePressureThread;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.config.RuoYiConfig;
import com.ruoyi.framework.task.FurnanceTask;
import com.ruoyi.project.common.domain.TCommonfile;
import com.ruoyi.project.common.service.ITCommonfileService;
import com.ruoyi.project.plant.domain.TStaffmgr;
import com.ruoyi.project.plant.service.ITStaffmgrService;
import com.ruoyi.project.production.controller.vo.FurnancePressureFvpVO;
import com.ruoyi.project.production.controller.vo.FurnancePressureVO;
import com.ruoyi.project.production.controller.vo.FurnanceSummaryVO;
import com.ruoyi.project.production.controller.vo.FvpAnalysisQueryVO;
import com.ruoyi.project.production.domain.TFurnanceTemperature;
import com.ruoyi.project.production.mapper.TFurnancePressureMapper;
import com.ruoyi.project.production.service.ITFurnanceTemperatureService;
import com.ruoyi.project.system.domain.SysDictData;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.ISysConfigService;
import com.ruoyi.project.system.service.ISysDictTypeService;
import com.ruoyi.project.system.service.ISysUserService;
import net.sf.jsqlparser.statement.select.ExceptOp;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.production.domain.TFurnancePressure;
import com.ruoyi.project.production.service.ITFurnancePressureService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 裂解炉炉管测压Controller
 *
 * @author ssy
 * @date 2024-03-21
 */
@RestController
@RequestMapping("/production/pressure")
public class TFurnancePressureController extends BaseController {
    @Autowired
    private ITFurnancePressureService tFurnancePressureService;

    @Autowired
    private ITFurnanceTemperatureService tFurnanceTemperatureService;

    @Resource
    private TFurnancePressureMapper tFurnancePressureMapper;

    @Autowired
    private ITCommonfileService tCommonfileService;

    //系统基础配置
    @Autowired
    private RuoYiConfig ruoyiConfig;

    @Autowired
    private ISysDictTypeService iSysDictTypeService;

    @Autowired
    private IMailService mailService;

    @Autowired
    private ITStaffmgrService staffmgrService;

    @Autowired
    private ISysUserService userService;

    @Autowired
    private JiGuangPushService jiGuangPushService;

    @Autowired
    private ISysConfigService configService;

    /**
     * 删除裂解炉Pass图片（APP）
     */
    @PostMapping("/deleteFile")
    public AjaxResult deleteFile(@RequestBody TCommonfile tCommonfile) {
        return toAjax(tCommonfileService.deleteTCommonfileById(tCommonfile.getId()));
    }

    /**
     * 查询通用附件列表
     */
    @PostMapping("/allFileList")
    public List<TCommonfile> allFileList(@RequestBody TCommonfile tCommonfile) {
        List<TCommonfile> list = tCommonfileService.selectAllFileList(tCommonfile);
        return list;
    }

    /**
     * 裂解炉测压图片识别（APP）
     */
    @PostMapping("/scan")
    public AjaxResult scan(@RequestParam("file") MultipartFile file,
                           @RequestParam("furnanceName") String furnanceName,
                           @RequestParam("pass") int pass,
                           @RequestParam("isInlet") boolean isInlet,
                           @RequestParam("pType") String pType,
                           @RequestParam("pId") String pId) throws IOException {
        String[] newArray = null;
        try {
            // 判断图片中的压力仪表数量
            int num = 0;
            switch (furnanceName) {
                case "H109":
                    num = 15;
                    break;
                case "H111":
                case "H112":
                case "H113":
                case "H114":
                case "H115":
                case "H116":
                case "H117":
                case "H118":
                case "H110":
                    num = 11;
                    break;
                case "H130":
                    num = isInlet ? 1 : 2;
                    break;
            }
            // 调用图片识别接口
            String goodsUrl = this.ruoyiConfig.getImagePath();
            //本地文件位置
            String str = null;
            try {
                //添加请求头
                HashMap<String, String> map = new HashMap<>();
                //map.put("token", CommonConstant.token);
                File f = this.multipartFileToFile(file);
                str = doPostUploadFile(goodsUrl + "", map, f, num);
                if (f.exists()) {
                    boolean delete = f.delete();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            // 获取数组
            JSONObject json = JSONObject.parseObject(str);
            JSONArray jsonArray = json.getJSONObject("data").getJSONArray("readings");
            // 转换为String数组（排序前的数组）
            String[] stringArray = new String[jsonArray.size()];
            for (int i = 0; i < jsonArray.size(); i++) {
                stringArray[i] = jsonArray.getString(i);
            }
            // 排序后的数组
            newArray = new String[jsonArray.size()];
            // 数组排序（格式：入,出,出,出,...）
            switch (furnanceName) {
                case "H109":
                    if (jsonArray.size() == 15) {
                        String temp0 = stringArray[0];
                        String temp1 = stringArray[1];
                        String temp2 = stringArray[2];
                        String temp3 = stringArray[3];
                        String temp4 = stringArray[4];
                        String temp5 = stringArray[5];
                        String temp6 = stringArray[6];
                        String temp7 = stringArray[7];
                        String temp8 = stringArray[8];
                        String temp9 = stringArray[9];
                        String temp10 = stringArray[10];
                        String temp11 = stringArray[11];
                        String temp12 = stringArray[12];
                        String temp13 = stringArray[13];
                        String temp14 = stringArray[14];
                        if (pass % 2 == 1) {
                            newArray[0] = temp0;
                            newArray[1] = temp14;
                            newArray[2] = temp7;
                            newArray[3] = temp13;
                            newArray[4] = temp6;
                            newArray[5] = temp12;
                            newArray[6] = temp5;
                            newArray[7] = temp11;
                            newArray[8] = temp4;
                            newArray[9] = temp10;
                            newArray[10] = temp3;
                            newArray[11] = temp9;
                            newArray[12] = temp2;
                            newArray[13] = temp8;
                            newArray[14] = temp1;
                        } else {
                            newArray[0] = temp0;
                            newArray[1] = temp1;
                            newArray[2] = temp8;
                            newArray[3] = temp2;
                            newArray[4] = temp9;
                            newArray[5] = temp3;
                            newArray[6] = temp10;
                            newArray[7] = temp4;
                            newArray[8] = temp11;
                            newArray[9] = temp5;
                            newArray[10] = temp12;
                            newArray[11] = temp6;
                            newArray[12] = temp13;
                            newArray[13] = temp7;
                            newArray[14] = temp14;
                        }
                    } else {
                        return AjaxResult.error("图片与裂解炉位号不匹配！");
                    }
                    break;
                case "H111":
                case "H112":
                case "H113":
                case "H114":
                case "H115":
                case "H116":
                case "H117":
                case "H118":
                case "H110":
                    if (jsonArray.size() == 11) {
                        String temp0 = stringArray[0];
                        String temp1 = stringArray[1];
                        String temp2 = stringArray[2];
                        String temp3 = stringArray[3];
                        String temp4 = stringArray[4];
                        String temp5 = stringArray[5];
                        String temp6 = stringArray[6];
                        String temp7 = stringArray[7];
                        String temp8 = stringArray[8];
                        String temp9 = stringArray[9];
                        String temp10 = stringArray[10];
                        if (pass % 2 == 1) {
                            newArray[0] = temp0;
                            newArray[1] = temp10;
                            newArray[2] = temp5;
                            newArray[3] = temp9;
                            newArray[4] = temp4;
                            newArray[5] = temp8;
                            newArray[6] = temp3;
                            newArray[7] = temp7;
                            newArray[8] = temp2;
                            newArray[9] = temp6;
                            newArray[10] = temp1;
                        } else {
                            newArray[0] = temp0;
                            newArray[1] = temp1;
                            newArray[2] = temp6;
                            newArray[3] = temp2;
                            newArray[4] = temp7;
                            newArray[5] = temp3;
                            newArray[6] = temp8;
                            newArray[7] = temp4;
                            newArray[8] = temp9;
                            newArray[9] = temp5;
                            newArray[10] = temp10;
                        }
                    } else {
                        return AjaxResult.error("图片与裂解炉位号不匹配！");
                    }
                    break;
                case "H130":
                    newArray = stringArray;
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // 上传图片
            if (file.isEmpty()) {
                return AjaxResult.error("上传失败，文件为空！");
            }
            String url = FileUploadUtils.upload(RuoYiConfig.getFilePath("/" + pType), file);
            long size = file.getSize() / 1024;
            TCommonfile tCommonfile = new TCommonfile();
            tCommonfile.setFileUrl(url);
            tCommonfile.setFileName(file.getOriginalFilename());
            tCommonfile.setCreaterCode(String.valueOf(getUserId()));
            tCommonfile.setpId(Long.parseLong(pId));
            tCommonfile.setpType(pType);
            tCommonfile.setFileSize(String.valueOf(size));
            tCommonfileService.insertTCommonfile(tCommonfile);
            //组装返回
            JSONObject returnObj = new JSONObject();
            returnObj.put("readings", newArray);
            returnObj.put("fileName", tCommonfile.getFileName());
            returnObj.put("url", tCommonfile.getFileUrl());
            returnObj.put("fileId", tCommonfile.getId());
            return AjaxResult.success(returnObj);
        }
    }

    /**
     * MultipartFile转File
     *
     * @param file
     * @return
     * @throws IOException
     */
    public File multipartFileToFile(MultipartFile file) throws IOException {
        File convFile = null;
        if (file.getSize() > 0) {
            convFile = new File(file.getOriginalFilename());
            convFile.createNewFile();
            FileOutputStream fos = new FileOutputStream(convFile);
            fos.write(file.getBytes());
            fos.close();
        }
        return convFile;
    }

    /**
     * post请求提交form-data上传文件
     *
     * @param url     上传地址
     * @param headers 请求头
     * @param file    上传文件
     * @return
     */
    public String doPostUploadFile(String url, Map<String, String> headers, File file, int num) {
        HttpPost httpPost = new HttpPost(url);
        packageHeader(headers, httpPost);
        String fileName = file.getName();

        CloseableHttpResponse response = null;

        String respContent = null;

        long startTime = System.currentTimeMillis();

        // 设置请求头 boundary边界不可重复，重复会导致提交失败
        String boundary = "-------------------------" + UUID.randomUUID().toString();
        httpPost.setHeader("Content-Type", "multipart/form-data; boundary=" + boundary);

        // 创建MultipartEntityBuilder
        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        // 设置字符编码
        builder.setCharset(StandardCharsets.UTF_8);
        // 模拟浏览器
        builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
        // 设置边界
        builder.setBoundary(boundary);
        // 设置multipart/form-data流文件
        builder.addPart("image", new FileBody(file));
        builder.addTextBody("num", num + "");
        // application/octet-stream代表不知道是什么格式的文件
        builder.addBinaryBody("media", file, ContentType.create("application/octet-stream"), fileName);

        HttpEntity entity = builder.build();
        httpPost.setEntity(entity);
        CloseableHttpClient httpClient = HttpClients.createDefault();
        try {
            response = httpClient.execute(httpPost);
            if (response != null && response.getStatusLine() != null && response.getStatusLine().getStatusCode() < 400) {
                HttpEntity he = response.getEntity();
                if (he != null) {
                    respContent = EntityUtils.toString(he, "UTF-8");
                }
            } else {
                logger.error("对方响应的状态码不在符合的范围内!");
                throw new RuntimeException();
            }
            return respContent;
        } catch (Exception e) {
            logger.error("网络访问异常,请求url地址={},响应体={},error={}", url, response, e);
            throw new RuntimeException();
        } finally {
            logger.info("统一外网请求参数打印,post请求url地址={},响应={},耗时={}毫秒", url, respContent, (System.currentTimeMillis() - startTime));
            try {
                if (response != null) {
                    response.close();
                }
                if (null != httpClient) {
                    httpClient.close();
                }
            } catch (IOException e) {
                logger.error("请求链接释放异常", e);
            }
        }
    }

    /**
     * 封装请求头
     *
     * @param paramsHeads
     * @param httpMethod
     */
    private static void packageHeader(Map<String, String> paramsHeads, HttpRequestBase httpMethod) {
        if (null != paramsHeads && paramsHeads.size() > 0) {
            Set<Map.Entry<String, String>> entrySet = paramsHeads.entrySet();
            for (Map.Entry<String, String> entry : entrySet) {
                httpMethod.setHeader(entry.getKey(), entry.getValue());
            }
        }
    }

    /**
     * 裂解炉测压列表Summary（APP）
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:list')")
    @GetMapping("/summary")
    public AjaxResult getPressureSummary() throws ParseException {
        TFurnancePressure query = new TFurnancePressure();
        Date date = new Date();
        date.setHours(0);
        date.setMinutes(0);
        date.setSeconds(0);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = sdf.parse(sdf.format(date));
        query.setRecordTime(parse);
        List<TFurnancePressure> result = tFurnancePressureService.selectTFurnancePressureByDate(query);
        List<TFurnancePressure> list = new ArrayList<>();
        List<FurnanceSummaryVO> voList = new ArrayList<>();
        double maxValue109 = 0;
        double maxValue110 = 0;
        double maxValue111 = 0;
        double maxValue112 = 0;
        double maxValue113 = 0;
        double maxValue114 = 0;
        double maxValue115 = 0;
        double maxValue116 = 0;
        double maxValue117 = 0;
        double maxValue118 = 0;
        double maxValue130 = 0;
        for (TFurnancePressure pressure : result) {
            String furnanceName = pressure.getFurnanceName();
            switch (furnanceName) {
                case "H109":
                    double maxValue1091 = this.getMaxValue109(pressure);
                    if (maxValue1091 > maxValue109) {
                        maxValue109 = maxValue1091;
                    }
                    break;
                case "H110":
                    double maxValue1101 = this.getMaxValue11x(pressure);
                    if (maxValue1101 > maxValue110) {
                        maxValue110 = maxValue1101;
                    }
                    break;
                case "H111":
                    double maxValue1111 = this.getMaxValue11x(pressure);
                    if (maxValue1111 > maxValue111) {
                        maxValue111 = maxValue1111;
                    }
                    break;
                case "H112":
                    double maxValue1121 = this.getMaxValue11x(pressure);
                    if (maxValue1121 > maxValue112) {
                        maxValue112 = maxValue1121;
                    }
                    break;
                case "H113":
                    double maxValue1131 = this.getMaxValue11x(pressure);
                    if (maxValue1131 > maxValue113) {
                        maxValue113 = maxValue1131;
                    }
                    break;
                case "H114":
                    double maxValue1141 = this.getMaxValue11x(pressure);
                    if (maxValue1141 > maxValue114) {
                        maxValue114 = maxValue1141;
                    }
                    break;
                case "H115":
                    double maxValue151 = this.getMaxValue11x(pressure);
                    if (maxValue151 > maxValue115) {
                        maxValue115 = maxValue151;
                    }
                    break;
                case "H116":
                    double maxValue1161 = this.getMaxValue11x(pressure);
                    if (maxValue1161 > maxValue116) {
                        maxValue116 = maxValue1161;
                    }
                    break;
                case "H117":
                    double maxValue1171 = this.getMaxValue11x(pressure);
                    if (maxValue1171 > maxValue117) {
                        maxValue117 = maxValue1171;
                    }
                    break;
                case "H118":
                    double maxValue1181 = this.getMaxValue11x(pressure);
                    if (maxValue1181 > maxValue118) {
                        maxValue118 = maxValue1181;
                    }
                    break;
                case "H130":
                    double maxValue1301 = this.getMaxValue130(pressure);
                    if (maxValue1301 > maxValue130) {
                        maxValue130 = maxValue1301;
                    }
                    break;
            }
            Date recordTime = pressure.getRecordTime();
            if (recordTime.getHours() == 20) {
                list.add(pressure);
            }
        }
        for (TFurnancePressure pressure : list) {
            Long id = pressure.getId();
            String furnanceName = pressure.getFurnanceName();
            String status = pressure.getStatus();
            FurnanceSummaryVO vo = new FurnanceSummaryVO();
            vo.setId(id);
            vo.setFurnanceName(furnanceName);
            vo.setStatus(status);
            switch (furnanceName) {
                case "H109":
                    vo.setMaxValue(maxValue109);
                    break;
                case "H110":
                    vo.setMaxValue(maxValue110);
                    break;
                case "H111":
                    vo.setMaxValue(maxValue111);
                    break;
                case "H112":
                    vo.setMaxValue(maxValue112);
                    break;
                case "H113":
                    vo.setMaxValue(maxValue113);
                    break;
                case "H114":
                    vo.setMaxValue(maxValue114);
                    break;
                case "H115":
                    vo.setMaxValue(maxValue115);
                    break;
                case "H116":
                    vo.setMaxValue(maxValue116);
                    break;
                case "H117":
                    vo.setMaxValue(maxValue117);
                    break;
                case "H118":
                    vo.setMaxValue(maxValue118);
                    break;
                case "H130":
                    vo.setMaxValue(maxValue130);
                    break;
            }
            voList.add(vo);
        }
        return AjaxResult.success(voList);
    }

    public double getMaxValue109(TFurnancePressure pressure) {
        String pass1 = pressure.getPass1();
        String pass2 = pressure.getPass2();
        String pass3 = pressure.getPass3();
        String pass4 = pressure.getPass4();
        String pass5 = pressure.getPass5();
        String pass6 = pressure.getPass6();
        String pass7 = pressure.getPass7();
        String pass8 = pressure.getPass8();
        String pass9 = pressure.getPass9();
        String pass10 = pressure.getPass10();
        String pass11 = pressure.getPass11();
        String pass12 = pressure.getPass12();
        String pass13 = pressure.getPass13();
        String pass14 = pressure.getPass14();
        String pass15 = pressure.getPass15();
        String pass16 = pressure.getPass16();
        int maxValue1 = this.getMaxValue(pass1);
        int maxValue2 = this.getMaxValue(pass2);
        int maxValue3 = this.getMaxValue(pass3);
        int maxValue4 = this.getMaxValue(pass4);
        int maxValue5 = this.getMaxValue(pass5);
        int maxValue6 = this.getMaxValue(pass6);
        int maxValue7 = this.getMaxValue(pass7);
        int maxValue8 = this.getMaxValue(pass8);
        int maxValue9 = this.getMaxValue(pass9);
        int maxValue10 = this.getMaxValue(pass10);
        int maxValue11 = this.getMaxValue(pass11);
        int maxValue12 = this.getMaxValue(pass12);
        int maxValue13 = this.getMaxValue(pass13);
        int maxValue14 = this.getMaxValue(pass14);
        int maxValue15 = this.getMaxValue(pass15);
        int maxValue16 = this.getMaxValue(pass16);
        return this.getMaxValue(
                maxValue1 + "," + maxValue2 + "," + maxValue3 + "," + maxValue4 + ","
                        + maxValue5 + "," + maxValue6 + "," + maxValue7 + "," + maxValue8 + ","
                        + maxValue9 + "," + maxValue10 + "," + maxValue11 + "," + maxValue12 + ","
                        + maxValue13 + "," + maxValue14 + "," + maxValue15 + "," + maxValue16 + ","
        );
    }

    public double getMaxValue11x(TFurnancePressure pressure) {
        String pass1 = pressure.getPass1();
        String pass2 = pressure.getPass2();
        String pass3 = pressure.getPass3();
        String pass4 = pressure.getPass4();
        String pass5 = pressure.getPass5();
        String pass6 = pressure.getPass6();
        String pass7 = pressure.getPass7();
        String pass8 = pressure.getPass8();
        int maxValue1 = this.getMaxValue(pass1);
        int maxValue2 = this.getMaxValue(pass2);
        int maxValue3 = this.getMaxValue(pass3);
        int maxValue4 = this.getMaxValue(pass4);
        int maxValue5 = this.getMaxValue(pass5);
        int maxValue6 = this.getMaxValue(pass6);
        int maxValue7 = this.getMaxValue(pass7);
        int maxValue8 = this.getMaxValue(pass8);
        return this.getMaxValue(
                maxValue1 + "," + maxValue2 + "," + maxValue3 + "," + maxValue4 + ","
                        + maxValue5 + "," + maxValue6 + "," + maxValue7 + "," + maxValue8 + ","
        );
    }

    public double getMaxValue130(TFurnancePressure pressure) {
        String pass1 = pressure.getPass1();
        String pass2 = pressure.getPass2();
        String pass3 = pressure.getPass3();
        String pass4 = pressure.getPass4();
        int maxValue1 = this.getMaxValue(pass1);
        int maxValue2 = this.getMaxValue(pass2);
        int maxValue3 = this.getMaxValue(pass3);
        int maxValue4 = this.getMaxValue(pass4);
        return this.getMaxValue(maxValue1 + "," + maxValue2 + "," + maxValue3 + "," + maxValue4 + ",");
    }

    /**
     * 现场照片上传（APP）
     */
    @PostMapping("/uploadFile")
    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, String pType, String pId) throws IOException {
        if (!file.isEmpty()) {
            String url = FileUploadUtils.upload(RuoYiConfig.getFilePath("/" + pType), file);
            long size = file.getSize() / 1024;
            TCommonfile tCommonfile = new TCommonfile();
            tCommonfile.setFileUrl(url);
            tCommonfile.setFileName(file.getOriginalFilename());
            tCommonfile.setCreaterCode(String.valueOf(getUserId()));
            tCommonfile.setpId(Long.parseLong(pId));
            tCommonfile.setpType(pType);
            tCommonfile.setFileSize(String.valueOf(size));
            tCommonfileService.insertTCommonfile(tCommonfile);

            AjaxResult ajax = AjaxResult.success();
            ajax.put("url", tCommonfile.getFileUrl());
            ajax.put("fileName", tCommonfile.getFileName());
            return ajax;
        }
        return AjaxResult.error("上传失败，请联系管理员");
    }

    /**
     * 获取裂解炉炉管测压fvp分析数据
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:list')")
    @PostMapping("/getFvpAnalysis")
    public AjaxResult getFvpAnalysis(@RequestBody FvpAnalysisQueryVO fvpAnalysisQueryVO) {
        String furnanceName = fvpAnalysisQueryVO.getFurnanceName();
        furnanceName = furnanceName.replace("-", "").replace("A", "").replace("B", "");
        Date startDate = new Date(fvpAnalysisQueryVO.getRecordTime().getTime());
        startDate.setMonth(startDate.getMonth() - 3);
        Date endDate = new Date(fvpAnalysisQueryVO.getRecordTime().getTime());
        endDate.setDate(endDate.getDate() + 1);
        TFurnancePressure pressure = new TFurnancePressure();
        pressure.setFurnanceName(furnanceName);
        pressure.setStartDate(startDate);
        pressure.setEndDate(endDate);
        List<TFurnancePressure> tFurnancePressures = tFurnancePressureMapper.selectTFurnancePressureAnalysis(pressure);
        LinkedHashMap<Date, Double> resultMap = new LinkedHashMap<>();
        switch (fvpAnalysisQueryVO.getFurnanceName()) {
            case "H-110":
            case "H-111":
            case "H-112":
            case "H-113":
            case "H-114":
            case "H-115":
            case "H-116":
            case "H-117":
            case "H-118":
                resultMap = this.calcAnalysis(tFurnancePressures, fvpAnalysisQueryVO.getPass());
                break;
            case "H-130":
                resultMap = this.calcAnalysis130(tFurnancePressures, fvpAnalysisQueryVO.getPass());
                break;
            case "H-109A":
                resultMap = this.calcAnalysis109A(tFurnancePressures, fvpAnalysisQueryVO.getPass());
                break;
            case "H-109B":
                resultMap = this.calcAnalysis109B(tFurnancePressures, fvpAnalysisQueryVO.getPass());
                break;
        }
        return AjaxResult.success(resultMap);
    }

    public LinkedHashMap<Date, Double> calcAnalysis(List<TFurnancePressure> tFurnancePressures, String pass) {
        LinkedHashMap<Date, Double> map = new LinkedHashMap<>();
        if (tFurnancePressures != null && tFurnancePressures.size() != 0) {
            // pass max inlet
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            double pass5Inlet = 0;
            double pass6Inlet = 0;
            double pass7Inlet = 0;
            double pass8Inlet = 0;
            // pass max outlet
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            double pass5Out = 0;
            double pass6Out = 0;
            double pass7Out = 0;
            double pass8Out = 0;
            // pass ratio
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            double pass5Ratio = 0;
            double pass6Ratio = 0;
            double pass7Ratio = 0;
            double pass8Ratio = 0;
            for (TFurnancePressure tFurnancePressure : tFurnancePressures) {
                String pass1Array = tFurnancePressure.getPass1();
                String pass2Array = tFurnancePressure.getPass2();
                String pass3Array = tFurnancePressure.getPass3();
                String pass4Array = tFurnancePressure.getPass4();
                String pass5Array = tFurnancePressure.getPass5();
                String pass6Array = tFurnancePressure.getPass6();
                String pass7Array = tFurnancePressure.getPass7();
                String pass8Array = tFurnancePressure.getPass8();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    pass1Inlet = Double.parseDouble(pass1Array.substring(pass1Array.lastIndexOf(",") + 1));
                    pass1Out = this.getMaxValue(pass1Array.substring(0, pass1Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    pass2Inlet = Double.parseDouble(pass2Array.substring(pass2Array.lastIndexOf(",") + 1));
                    pass2Out = this.getMaxValue(pass2Array.substring(0, pass2Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    pass3Inlet = Double.parseDouble(pass3Array.substring(pass3Array.lastIndexOf(",") + 1));
                    pass3Out = this.getMaxValue(pass3Array.substring(0, pass3Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    pass4Inlet = Double.parseDouble(pass4Array.substring(pass4Array.lastIndexOf(",") + 1));
                    pass4Out = this.getMaxValue(pass4Array.substring(0, pass4Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass5Array)) {
                    pass5Inlet = Double.parseDouble(pass5Array.substring(pass5Array.lastIndexOf(",") + 1));
                    pass5Out = this.getMaxValue(pass5Array.substring(0, pass5Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass6Array)) {
                    pass6Inlet = Double.parseDouble(pass6Array.substring(pass6Array.lastIndexOf(",") + 1));
                    pass6Out = this.getMaxValue(pass6Array.substring(0, pass6Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass7Array)) {
                    pass7Inlet = Double.parseDouble(pass7Array.substring(pass7Array.lastIndexOf(",") + 1));
                    pass7Out = this.getMaxValue(pass7Array.substring(0, pass7Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass8Array)) {
                    pass8Inlet = Double.parseDouble(pass8Array.substring(pass8Array.lastIndexOf(",") + 1));
                    pass8Out = this.getMaxValue(pass8Array.substring(0, pass8Array.indexOf(",")));
                }
                DecimalFormat df = new DecimalFormat("#.00");
                if (pass1Inlet != 0 && pass1Out != 0) {
                    pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
                }
                if (pass2Inlet != 0 && pass2Out != 0) {
                    pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
                }
                if (pass3Inlet != 0 && pass3Out != 0) {
                    pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
                }
                if (pass4Inlet != 0 && pass4Out != 0) {
                    pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
                }
                if (pass5Inlet != 0 && pass5Out != 0) {
                    pass5Ratio = Double.parseDouble(df.format(pass5Out / pass5Inlet));
                }
                if (pass6Inlet != 0 && pass6Out != 0) {
                    pass6Ratio = Double.parseDouble(df.format(pass6Out / pass6Inlet));
                }
                if (pass7Inlet != 0 && pass7Out != 0) {
                    pass7Ratio = Double.parseDouble(df.format(pass7Out / pass7Inlet));
                }
                if (pass8Inlet != 0 && pass8Out != 0) {
                    pass8Ratio = Double.parseDouble(df.format(pass8Out / pass8Inlet));
                }
                Date recordTime = tFurnancePressure.getRecordTime();
                double ratio = 0;
                switch (pass) {
                    case "pass1":
                        ratio = pass1Ratio;
                        break;
                    case "pass2":
                        ratio = pass2Ratio;
                        break;
                    case "pass3":
                        ratio = pass3Ratio;
                        break;
                    case "pass4":
                        ratio = pass4Ratio;
                        break;
                    case "pass5":
                        ratio = pass5Ratio;
                        break;
                    case "pass6":
                        ratio = pass6Ratio;
                        break;
                    case "pass7":
                        ratio = pass7Ratio;
                        break;
                    case "pass8":
                        ratio = pass8Ratio;
                        break;
                    case "passAll":
                        ratio = this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio, pass5Ratio, pass6Ratio, pass7Ratio, pass8Ratio});
                        break;
                }
                map.put(recordTime, ratio);
            }
            return map;
        }
        return null;
    }

    public LinkedHashMap<Date, Double> calcAnalysis109A(List<TFurnancePressure> tFurnancePressures, String pass) {
        LinkedHashMap<Date, Double> map = new LinkedHashMap<>();
        if (tFurnancePressures != null && tFurnancePressures.size() != 0) {
            // pass max inlet
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            double pass5Inlet = 0;
            double pass6Inlet = 0;
            double pass7Inlet = 0;
            double pass8Inlet = 0;
            // pass max outlet
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            double pass5Out = 0;
            double pass6Out = 0;
            double pass7Out = 0;
            double pass8Out = 0;
            // pass ratio
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            double pass5Ratio = 0;
            double pass6Ratio = 0;
            double pass7Ratio = 0;
            double pass8Ratio = 0;
            for (TFurnancePressure tFurnancePressure : tFurnancePressures) {
                String pass1Array = tFurnancePressure.getPass1();
                String pass2Array = tFurnancePressure.getPass3();
                String pass3Array = tFurnancePressure.getPass5();
                String pass4Array = tFurnancePressure.getPass7();
                String pass5Array = tFurnancePressure.getPass9();
                String pass6Array = tFurnancePressure.getPass11();
                String pass7Array = tFurnancePressure.getPass13();
                String pass8Array = tFurnancePressure.getPass15();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    pass1Inlet = Double.parseDouble(pass1Array.substring(pass1Array.lastIndexOf(",") + 1));
                    pass1Out = this.getMaxValue(pass1Array.substring(0, pass1Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    pass2Inlet = Double.parseDouble(pass2Array.substring(pass2Array.lastIndexOf(",") + 1));
                    pass2Out = this.getMaxValue(pass2Array.substring(0, pass2Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    pass3Inlet = Double.parseDouble(pass3Array.substring(pass3Array.lastIndexOf(",") + 1));
                    pass3Out = this.getMaxValue(pass3Array.substring(0, pass3Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    pass4Inlet = Double.parseDouble(pass4Array.substring(pass4Array.lastIndexOf(",") + 1));
                    pass4Out = this.getMaxValue(pass4Array.substring(0, pass4Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass5Array)) {
                    pass5Inlet = Double.parseDouble(pass5Array.substring(pass5Array.lastIndexOf(",") + 1));
                    pass5Out = this.getMaxValue(pass5Array.substring(0, pass5Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass6Array)) {
                    pass6Inlet = Double.parseDouble(pass6Array.substring(pass6Array.lastIndexOf(",") + 1));
                    pass6Out = this.getMaxValue(pass6Array.substring(0, pass6Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass7Array)) {
                    pass7Inlet = Double.parseDouble(pass7Array.substring(pass7Array.lastIndexOf(",") + 1));
                    pass7Out = this.getMaxValue(pass7Array.substring(0, pass7Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass8Array)) {
                    pass8Inlet = Double.parseDouble(pass8Array.substring(pass8Array.lastIndexOf(",") + 1));
                    pass8Out = this.getMaxValue(pass8Array.substring(0, pass8Array.indexOf(",")));
                }
                DecimalFormat df = new DecimalFormat("#.00");
                if (pass1Inlet != 0 && pass1Out != 0) {
                    pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
                }
                if (pass2Inlet != 0 && pass2Out != 0) {
                    pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
                }
                if (pass3Inlet != 0 && pass3Out != 0) {
                    pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
                }
                if (pass4Inlet != 0 && pass4Out != 0) {
                    pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
                }
                if (pass5Inlet != 0 && pass5Out != 0) {
                    pass5Ratio = Double.parseDouble(df.format(pass5Out / pass5Inlet));
                }
                if (pass6Inlet != 0 && pass6Out != 0) {
                    pass6Ratio = Double.parseDouble(df.format(pass6Out / pass6Inlet));
                }
                if (pass7Inlet != 0 && pass7Out != 0) {
                    pass7Ratio = Double.parseDouble(df.format(pass7Out / pass7Inlet));
                }
                if (pass8Inlet != 0 && pass8Out != 0) {
                    pass8Ratio = Double.parseDouble(df.format(pass8Out / pass8Inlet));
                }
                Date recordTime = tFurnancePressure.getRecordTime();
                double ratio = 0;
                switch (pass) {
                    case "pass1":
                        ratio = pass1Ratio;
                        break;
                    case "pass2":
                        ratio = pass2Ratio;
                        break;
                    case "pass3":
                        ratio = pass3Ratio;
                        break;
                    case "pass4":
                        ratio = pass4Ratio;
                        break;
                    case "pass5":
                        ratio = pass5Ratio;
                        break;
                    case "pass6":
                        ratio = pass6Ratio;
                        break;
                    case "pass7":
                        ratio = pass7Ratio;
                        break;
                    case "pass8":
                        ratio = pass8Ratio;
                        break;
                    case "passAll":
                        ratio = this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio, pass5Ratio, pass6Ratio, pass7Ratio, pass8Ratio});
                        break;
                }
                map.put(recordTime, ratio);
            }
            return map;
        }
        return null;
    }

    public LinkedHashMap<Date, Double> calcAnalysis109B(List<TFurnancePressure> tFurnancePressures, String pass) {
        LinkedHashMap<Date, Double> map = new LinkedHashMap<>();
        if (tFurnancePressures != null && tFurnancePressures.size() != 0) {
            // pass max inlet
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            double pass5Inlet = 0;
            double pass6Inlet = 0;
            double pass7Inlet = 0;
            double pass8Inlet = 0;
            // pass max outlet
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            double pass5Out = 0;
            double pass6Out = 0;
            double pass7Out = 0;
            double pass8Out = 0;
            // pass ratio
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            double pass5Ratio = 0;
            double pass6Ratio = 0;
            double pass7Ratio = 0;
            double pass8Ratio = 0;
            for (TFurnancePressure tFurnancePressure : tFurnancePressures) {
                String pass1Array = tFurnancePressure.getPass2();
                String pass2Array = tFurnancePressure.getPass4();
                String pass3Array = tFurnancePressure.getPass6();
                String pass4Array = tFurnancePressure.getPass8();
                String pass5Array = tFurnancePressure.getPass10();
                String pass6Array = tFurnancePressure.getPass12();
                String pass7Array = tFurnancePressure.getPass14();
                String pass8Array = tFurnancePressure.getPass16();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    pass1Inlet = Double.parseDouble(pass1Array.substring(pass1Array.lastIndexOf(",") + 1));
                    pass1Out = this.getMaxValue(pass1Array.substring(0, pass1Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    pass2Inlet = Double.parseDouble(pass2Array.substring(pass2Array.lastIndexOf(",") + 1));
                    pass2Out = this.getMaxValue(pass2Array.substring(0, pass2Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    pass3Inlet = Double.parseDouble(pass3Array.substring(pass3Array.lastIndexOf(",") + 1));
                    pass3Out = this.getMaxValue(pass3Array.substring(0, pass3Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    pass4Inlet = Double.parseDouble(pass4Array.substring(pass4Array.lastIndexOf(",") + 1));
                    pass4Out = this.getMaxValue(pass4Array.substring(0, pass4Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass5Array)) {
                    pass5Inlet = Double.parseDouble(pass5Array.substring(pass5Array.lastIndexOf(",") + 1));
                    pass5Out = this.getMaxValue(pass5Array.substring(0, pass5Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass6Array)) {
                    pass6Inlet = Double.parseDouble(pass6Array.substring(pass6Array.lastIndexOf(",") + 1));
                    pass6Out = this.getMaxValue(pass6Array.substring(0, pass6Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass7Array)) {
                    pass7Inlet = Double.parseDouble(pass7Array.substring(pass7Array.lastIndexOf(",") + 1));
                    pass7Out = this.getMaxValue(pass7Array.substring(0, pass7Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass8Array)) {
                    pass8Inlet = Double.parseDouble(pass8Array.substring(pass8Array.lastIndexOf(",") + 1));
                    pass8Out = this.getMaxValue(pass8Array.substring(0, pass8Array.indexOf(",")));
                }
                DecimalFormat df = new DecimalFormat("#.00");
                if (pass1Inlet != 0 && pass1Out != 0) {
                    pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
                }
                if (pass2Inlet != 0 && pass2Out != 0) {
                    pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
                }
                if (pass3Inlet != 0 && pass3Out != 0) {
                    pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
                }
                if (pass4Inlet != 0 && pass4Out != 0) {
                    pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
                }
                if (pass5Inlet != 0 && pass5Out != 0) {
                    pass5Ratio = Double.parseDouble(df.format(pass5Out / pass5Inlet));
                }
                if (pass6Inlet != 0 && pass6Out != 0) {
                    pass6Ratio = Double.parseDouble(df.format(pass6Out / pass6Inlet));
                }
                if (pass7Inlet != 0 && pass7Out != 0) {
                    pass7Ratio = Double.parseDouble(df.format(pass7Out / pass7Inlet));
                }
                if (pass8Inlet != 0 && pass8Out != 0) {
                    pass8Ratio = Double.parseDouble(df.format(pass8Out / pass8Inlet));
                }
                Date recordTime = tFurnancePressure.getRecordTime();
                double ratio = 0;
                switch (pass) {
                    case "pass1":
                        ratio = pass1Ratio;
                        break;
                    case "pass2":
                        ratio = pass2Ratio;
                        break;
                    case "pass3":
                        ratio = pass3Ratio;
                        break;
                    case "pass4":
                        ratio = pass4Ratio;
                        break;
                    case "pass5":
                        ratio = pass5Ratio;
                        break;
                    case "pass6":
                        ratio = pass6Ratio;
                        break;
                    case "pass7":
                        ratio = pass7Ratio;
                        break;
                    case "pass8":
                        ratio = pass8Ratio;
                        break;
                    case "passAll":
                        ratio = this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio, pass5Ratio, pass6Ratio, pass7Ratio, pass8Ratio});
                        break;
                }
                map.put(recordTime, ratio);
            }
            return map;
        }
        return null;
    }

    public LinkedHashMap<Date, Double> calcAnalysis130(List<TFurnancePressure> tFurnancePressures, String pass) {
        LinkedHashMap<Date, Double> map = new LinkedHashMap<>();
        if (tFurnancePressures != null && tFurnancePressures.size() != 0) {
            // pass max inlet
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            // pass max outlet
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            // pass ratio
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            for (TFurnancePressure tFurnancePressure : tFurnancePressures) {
                String pass1Array = tFurnancePressure.getPass1();
                String pass2Array = tFurnancePressure.getPass2();
                String pass3Array = tFurnancePressure.getPass3();
                String pass4Array = tFurnancePressure.getPass4();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    pass1Inlet = Double.parseDouble(pass1Array.substring(pass1Array.lastIndexOf(",") + 1));
                    pass1Out = this.getMaxValue(pass1Array.substring(0, pass1Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    pass2Inlet = Double.parseDouble(pass2Array.substring(pass2Array.lastIndexOf(",") + 1));
                    pass2Out = this.getMaxValue(pass2Array.substring(0, pass2Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    pass3Inlet = Double.parseDouble(pass3Array.substring(pass3Array.lastIndexOf(",") + 1));
                    pass3Out = this.getMaxValue(pass3Array.substring(0, pass3Array.indexOf(",")));
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    pass4Inlet = Double.parseDouble(pass4Array.substring(pass4Array.lastIndexOf(",") + 1));
                    pass4Out = this.getMaxValue(pass4Array.substring(0, pass4Array.indexOf(",")));
                }
                DecimalFormat df = new DecimalFormat("#.00");
                if (pass1Inlet != 0 && pass1Out != 0) {
                    pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
                }
                if (pass2Inlet != 0 && pass2Out != 0) {
                    pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
                }
                if (pass3Inlet != 0 && pass3Out != 0) {
                    pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
                }
                if (pass4Inlet != 0 && pass4Out != 0) {
                    pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
                }
                Date recordTime = tFurnancePressure.getRecordTime();
                double ratio = 0;
                switch (pass) {
                    case "pass1":
                        ratio = pass1Ratio;
                        break;
                    case "pass2":
                        ratio = pass2Ratio;
                        break;
                    case "pass3":
                        ratio = pass3Ratio;
                        break;
                    case "pass4":
                        ratio = pass4Ratio;
                        break;
                    case "passAll":
                        ratio = this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio});
                        break;
                }
                map.put(recordTime, ratio);
            }
            return map;
        }
        return null;
    }

    /**
     * 获取裂解炉炉管测压详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:list')")
    @PostMapping("/info")
    public AjaxResult getPressureInfo(@RequestBody TFurnancePressure tFurnancePressure) throws ParseException {
        String furnanceName = tFurnancePressure.getFurnanceName();
        Date recordTime = new Date();
        if ("".equals(furnanceName) || recordTime == null) {
            return AjaxResult.success();
        }
        Date date = new Date();
        date.setYear(recordTime.getYear());
        date.setMonth(recordTime.getMonth());
        if (date.getHours() < 8) {
            date.setDate(recordTime.getDate() - 1);
        } else {
            date.setDate(recordTime.getDate());
        }
        date.setHours(0);
        date.setMinutes(0);
        date.setSeconds(0);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = sdf.parse(sdf.format(date));
        tFurnancePressure.setRecordTime(parse);
        List<TFurnancePressure> tFurnancePressures = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        if (tFurnancePressures.size() == 0) {
            tFurnancePressures = this.genData(tFurnancePressure);
        }
        TFurnancePressure am = new TFurnancePressure();
        TFurnancePressure pm = new TFurnancePressure();
        parse.setHours(20);
        long dateTime = parse.getTime();
        tFurnancePressure.setRecordTime(recordTime);
        for (TFurnancePressure furnancePressure : tFurnancePressures) {
            long time = furnancePressure.getRecordTime().getTime();
            if (time >= dateTime) {
                pm = furnancePressure;
            } else {
                am = furnancePressure;
            }
        }
        if (recordTime.getTime() >= parse.getTime()) {
            this.isComplete(pm);
            return AjaxResult.success(pm);
        } else {
            this.isComplete(am);
            return AjaxResult.success(am);
        }
    }

    public TFurnancePressure isComplete(TFurnancePressure tFurnancePressure) {
        String furnanceName = tFurnancePressure.getFurnanceName();
        tFurnancePressure.setProgress(0L);
        tFurnancePressure.setPass1Complete(false);
        tFurnancePressure.setPass2Complete(false);
        tFurnancePressure.setPass3Complete(false);
        tFurnancePressure.setPass4Complete(false);
        tFurnancePressure.setPass5Complete(false);
        tFurnancePressure.setPass6Complete(false);
        tFurnancePressure.setPass7Complete(false);
        tFurnancePressure.setPass8Complete(false);
        tFurnancePressure.setPass9Complete(false);
        tFurnancePressure.setPass10Complete(false);
        tFurnancePressure.setPass11Complete(false);
        tFurnancePressure.setPass12Complete(false);
        tFurnancePressure.setPass13Complete(false);
        tFurnancePressure.setPass14Complete(false);
        tFurnancePressure.setPass15Complete(false);
        tFurnancePressure.setPass16Complete(false);
        switch (furnanceName) {
            case "H109":
                this.isComplete109(tFurnancePressure);
                break;
            case "H110":
            case "H111":
            case "H112":
            case "H113":
            case "H114":
            case "H115":
            case "H116":
            case "H117":
            case "H118":
                this.isComplete11x(tFurnancePressure);
                break;
            case "H130":
                this.isComplete130(tFurnancePressure);
                break;
        }
        return tFurnancePressure;
    }

    public TFurnancePressure isComplete109(TFurnancePressure tFurnancePressure) {
        String pass1 = tFurnancePressure.getPass1();
        String pass2 = tFurnancePressure.getPass2();
        String pass3 = tFurnancePressure.getPass3();
        String pass4 = tFurnancePressure.getPass4();
        String pass5 = tFurnancePressure.getPass5();
        String pass6 = tFurnancePressure.getPass6();
        String pass7 = tFurnancePressure.getPass7();
        String pass8 = tFurnancePressure.getPass8();
        String pass9 = tFurnancePressure.getPass9();
        String pass10 = tFurnancePressure.getPass10();
        String pass11 = tFurnancePressure.getPass11();
        String pass12 = tFurnancePressure.getPass12();
        String pass13 = tFurnancePressure.getPass13();
        String pass14 = tFurnancePressure.getPass14();
        String pass15 = tFurnancePressure.getPass15();
        String pass16 = tFurnancePressure.getPass16();
        double count = 0;
        if (StringUtils.isNotNull(pass1) && StringUtils.isNotEmpty(pass1)) {
            String[] split = pass1.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass1Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass2) && StringUtils.isNotEmpty(pass2)) {
            String[] split = pass2.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass2Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass3) && StringUtils.isNotEmpty(pass3)) {
            String[] split = pass3.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass3Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass4) && StringUtils.isNotEmpty(pass4)) {
            String[] split = pass4.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass4Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass5) && StringUtils.isNotEmpty(pass5)) {
            String[] split = pass5.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass5Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass6) && StringUtils.isNotEmpty(pass6)) {
            String[] split = pass6.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass6Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass7) && StringUtils.isNotEmpty(pass7)) {
            String[] split = pass7.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass7Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass8) && StringUtils.isNotEmpty(pass8)) {
            String[] split = pass8.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass8Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass9) && StringUtils.isNotEmpty(pass9)) {
            String[] split = pass9.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass9Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass10) && StringUtils.isNotEmpty(pass10)) {
            String[] split = pass10.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass10Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass11) && StringUtils.isNotEmpty(pass11)) {
            String[] split = pass11.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass11Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass12) && StringUtils.isNotEmpty(pass12)) {
            String[] split = pass12.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass12Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass13) && StringUtils.isNotEmpty(pass13)) {
            String[] split = pass13.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass13Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass14) && StringUtils.isNotEmpty(pass14)) {
            String[] split = pass14.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass14Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass15) && StringUtils.isNotEmpty(pass15)) {
            String[] split = pass15.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass15Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass16) && StringUtils.isNotEmpty(pass16)) {
            String[] split = pass16.split(",");
            if (split.length >= 15) {
                tFurnancePressure.setPass16Complete(true);
                count++;
            }
        }
        tFurnancePressure.setProgress(count * 1.00d / 16L);
        return tFurnancePressure;
    }

    public TFurnancePressure isComplete11x(TFurnancePressure tFurnancePressure) {
        String pass1 = tFurnancePressure.getPass1();
        String pass2 = tFurnancePressure.getPass2();
        String pass3 = tFurnancePressure.getPass3();
        String pass4 = tFurnancePressure.getPass4();
        String pass5 = tFurnancePressure.getPass5();
        String pass6 = tFurnancePressure.getPass6();
        String pass7 = tFurnancePressure.getPass7();
        String pass8 = tFurnancePressure.getPass8();
        double count = 0;
        if (StringUtils.isNotNull(pass1) && StringUtils.isNotEmpty(pass1)) {
            String[] split = pass1.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass1Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass2) && StringUtils.isNotEmpty(pass2)) {
            String[] split = pass2.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass2Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass3) && StringUtils.isNotEmpty(pass3)) {
            String[] split = pass3.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass3Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass4) && StringUtils.isNotEmpty(pass4)) {
            String[] split = pass4.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass4Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass5) && StringUtils.isNotEmpty(pass5)) {
            String[] split = pass5.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass5Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass6) && StringUtils.isNotEmpty(pass6)) {
            String[] split = pass6.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass6Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass7) && StringUtils.isNotEmpty(pass7)) {
            String[] split = pass7.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass7Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass8) && StringUtils.isNotEmpty(pass8)) {
            String[] split = pass8.split(",");
            if (split.length >= 11) {
                tFurnancePressure.setPass8Complete(true);
                count++;
            }
        }
        tFurnancePressure.setProgress(count * 1.00d / 8L);
        return tFurnancePressure;
    }

    public TFurnancePressure isComplete130(TFurnancePressure tFurnancePressure) {
        String pass1 = tFurnancePressure.getPass1();
        String pass2 = tFurnancePressure.getPass2();
        String pass3 = tFurnancePressure.getPass3();
        String pass4 = tFurnancePressure.getPass4();
        double count = 0;
        if (StringUtils.isNotNull(pass1) && StringUtils.isNotEmpty(pass1)) {
            String[] split = pass1.split(",");
            if (split.length >= 7) {
                tFurnancePressure.setPass1Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass2) && StringUtils.isNotEmpty(pass2)) {
            String[] split = pass2.split(",");
            if (split.length >= 7) {
                tFurnancePressure.setPass2Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass3) && StringUtils.isNotEmpty(pass3)) {
            String[] split = pass3.split(",");
            if (split.length >= 7) {
                tFurnancePressure.setPass3Complete(true);
                count++;
            }
        }
        if (StringUtils.isNotNull(pass4) && StringUtils.isNotEmpty(pass4)) {
            String[] split = pass4.split(",");
            if (split.length >= 7) {
                tFurnancePressure.setPass4Complete(true);
                count++;
            }
        }
        tFurnancePressure.setProgress(count * 1.00d / 4L);
        return tFurnancePressure;
    }

    /**
     * 每日巡检数据生成
     */
    public synchronized List<TFurnancePressure> genData(TFurnancePressure tFurnancePressure) {
        List<TFurnancePressure> list = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        if (list.size() != 0) {
            return list;
        } else {
            // yyyy-MM-dd 08:00:00
            Date am = new Date();
            am.setHours(8);
            am.setMinutes(0);
            am.setSeconds(0);
            // yyyy-MM-dd 20:00:00
            Date pm = new Date();
            pm.setHours(20);
            pm.setMinutes(0);
            pm.setSeconds(0);
            // furnanceName array
            String[] furnanceNames = {"H109", "H110", "H111", "H112", "H113", "H114", "H115", "H116", "H117", "H118", "H130"};
            // 遍历生成数据
            for (String furnanceName : furnanceNames) {
                // 测压 08:00:00
                TFurnancePressure pressure1 = new TFurnancePressure();
                pressure1.setRecordTime(am);
                pressure1.setDeptId(103L);
                pressure1.setFurnanceName(furnanceName);
                // 测压 20:00:00
                TFurnancePressure pressure2 = new TFurnancePressure();
                pressure2.setRecordTime(pm);
                pressure2.setDeptId(103L);
                pressure2.setFurnanceName(furnanceName);
                // 默认赋值=0
//                switch (furnanceName) {
//                    case "H109":
//                        this.setZeroPressure(pressure1, 16, 15);
//                        this.setZeroPressure(pressure2, 16, 15);
//                        break;
//                    case "H110":
//                    case "H111":
//                    case "H112":
//                    case "H113":
//                    case "H114":
//                    case "H115":
//                    case "H116":
//                    case "H117":
//                    case "H118":
//                        this.setZeroPressure(pressure1, 8, 11);
//                        this.setZeroPressure(pressure2, 8, 11);
//                        break;
//                    case "H130":
//                        this.setZeroPressure(pressure1, 4, 7);
//                        this.setZeroPressure(pressure2, 4, 7);
//                        break;
//                }
                // 新增
                tFurnancePressureService.insertTFurnancePressure(pressure1);
                tFurnancePressureService.insertTFurnancePressure(pressure2);
            }
            return tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        }
    }

    public String getZeroString(int length) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            sb.append("0");
            if (i != length - 1) {
                sb.append(",");
            }
        }
        return sb.toString();
    }

    public void setZeroPressure(TFurnancePressure pressure, int passNum, int length) {
        String zeroString = this.getZeroString(length);
        pressure.setPass1(zeroString);
        pressure.setPass2(zeroString);
        pressure.setPass3(zeroString);
        pressure.setPass4(zeroString);
        if (passNum == 8 || passNum == 16) {
            pressure.setPass5(zeroString);
            pressure.setPass6(zeroString);
            pressure.setPass7(zeroString);
            pressure.setPass8(zeroString);
        }
        if (passNum == 16) {
            pressure.setPass9(zeroString);
            pressure.setPass10(zeroString);
            pressure.setPass11(zeroString);
            pressure.setPass12(zeroString);
            pressure.setPass13(zeroString);
            pressure.setPass14(zeroString);
            pressure.setPass15(zeroString);
            pressure.setPass16(zeroString);
        }
    }

    /**
     * 查询裂解炉炉管测压FVP
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:list')")
    @GetMapping("/fvp")
    public AjaxResult fvp(TFurnancePressure tFurnancePressure) {
        tFurnancePressure.setFurnanceName("H109");
        List<TFurnancePressure> list109 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H110");
        List<TFurnancePressure> list110 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H111");
        List<TFurnancePressure> list111 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H112");
        List<TFurnancePressure> list112 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H113");
        List<TFurnancePressure> list113 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H114");
        List<TFurnancePressure> list114 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H115");
        List<TFurnancePressure> list115 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H116");
        List<TFurnancePressure> list116 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H117");
        List<TFurnancePressure> list117 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H118");
        List<TFurnancePressure> list118 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H130");
        List<TFurnancePressure> list130 = tFurnancePressureService.selectTFurnancePressureByDate(tFurnancePressure);
        if (list109.size() != list110.size() || list109.size() != list111.size()
                || list109.size() != list112.size() || list109.size() != list113.size()
                || list109.size() != list114.size() || list109.size() != list115.size()
                || list109.size() != list116.size() || list109.size() != list117.size()
                || list109.size() != list118.size() || list109.size() != list130.size()
                || list109.size() == 0 || list109.size() == 0 || list109.size() == 0 || list109.size() == 0
                || list109.size() == 0 || list109.size() == 0 || list109.size() == 0 || list109.size() == 0
                || list109.size() == 0 || list109.size() == 0) {
            return AjaxResult.success("incompleteData");
        } else {
            List<FurnancePressureFvpVO> voList = new ArrayList<>();
            for (TFurnancePressure pressure : list109) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO voA = this.calcRatio109A(list);
                voA.setFurnanceName("H-109A");
                FurnancePressureFvpVO voB = this.calcRatio109B(list);
                voB.setFurnanceName("H-109B");
                if (pressure.getRecordTime().getHours() == 20) {
                    voA.setTime("晚班");
                    voB.setTime("晚班");
                } else {
                    voA.setTime("早班");
                    voB.setTime("早班");
                }
                voList.add(voA);
                voList.add(voB);
            }
            for (TFurnancePressure pressure : list110) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-110");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list111) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-111");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list112) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-112");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list113) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-113");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list114) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-114");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list115) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-115");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list116) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-116");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list117) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-117");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list118) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio(list);
                vo.setFurnanceName("H-118");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
            for (TFurnancePressure pressure : list130) {
                ArrayList<TFurnancePressure> list = new ArrayList<>();
                list.add(pressure);
                FurnancePressureFvpVO vo = this.calcRatio130(list);
                vo.setFurnanceName("H-130");
                if (pressure.getRecordTime().getHours() == 20) {
                    vo.setTime("晚班");
                } else {
                    vo.setTime("早班");
                }
                voList.add(vo);
            }
//            FurnancePressureFvpVO vo109A = this.calcRatio109A(list109);
//            FurnancePressureFvpVO vo109B = this.calcRatio109B(list109);
//            FurnancePressureFvpVO vo110 = this.calcRatio(list110);
//            FurnancePressureFvpVO vo111 = this.calcRatio(list111);
//            FurnancePressureFvpVO vo112 = this.calcRatio(list112);
//            FurnancePressureFvpVO vo113 = this.calcRatio(list113);
//            FurnancePressureFvpVO vo114 = this.calcRatio(list114);
//            FurnancePressureFvpVO vo115 = this.calcRatio(list115);
//            FurnancePressureFvpVO vo116 = this.calcRatio(list116);
//            FurnancePressureFvpVO vo117 = this.calcRatio(list117);
//            FurnancePressureFvpVO vo118 = this.calcRatio(list118);
//            FurnancePressureFvpVO vo130 = this.calcRatio130(list130);
//            vo110.setFurnanceName("H-110");
//            vo111.setFurnanceName("H-111");
//            vo112.setFurnanceName("H-112");
//            vo113.setFurnanceName("H-113");
//            vo114.setFurnanceName("H-114");
//            vo115.setFurnanceName("H-115");
//            vo116.setFurnanceName("H-116");
//            vo117.setFurnanceName("H-117");
//            vo118 .setFurnanceName("H-118");
//            vo130.setFurnanceName("H-130");
//            vo109A.setFurnanceName("H-109A");
//            vo109B.setFurnanceName("H-109B");
//            List<FurnancePressureFvpVO> voList = new ArrayList<>();
//            voList.add(vo110);
//            voList.add(vo111);
//            voList.add(vo112);
//            voList.add(vo113);
//            voList.add(vo114);
//            voList.add(vo115);
//            voList.add(vo116);
//            voList.add(vo117);
//            voList.add(vo118);
//            voList.add(vo130);
//            voList.add(vo109A);
//            voList.add(vo109B);
            return AjaxResult.success(voList);
        }
    }

    public FurnancePressureFvpVO calcRatio(List<TFurnancePressure> tFurnancePressure) {
        if (tFurnancePressure != null && tFurnancePressure.size() != 0) {
            // pass max inlet
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            double pass5Inlet = 0;
            double pass6Inlet = 0;
            double pass7Inlet = 0;
            double pass8Inlet = 0;
            // pass max outlet
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            double pass5Out = 0;
            double pass6Out = 0;
            double pass7Out = 0;
            double pass8Out = 0;
            // pass ratio
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            double pass5Ratio = 0;
            double pass6Ratio = 0;
            double pass7Ratio = 0;
            double pass8Ratio = 0;
            // 获取pass max值
            // xxx,xxx,xxx,...->xxx
            for (TFurnancePressure furnancePressure : tFurnancePressure) {
                String pass1Array = furnancePressure.getPass1();
                String pass2Array = furnancePressure.getPass2();
                String pass3Array = furnancePressure.getPass3();
                String pass4Array = furnancePressure.getPass4();
                String pass5Array = furnancePressure.getPass5();
                String pass6Array = furnancePressure.getPass6();
                String pass7Array = furnancePressure.getPass7();
                String pass8Array = furnancePressure.getPass8();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    double in = Double.parseDouble(pass1Array.substring(pass1Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass1Array.substring(0, pass1Array.indexOf(",")));
                    if (in > pass1Inlet) {
                        pass1Inlet = in;
                    }
                    if (out > pass1Out) {
                        pass1Out = out;
                    }
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    double in = Double.parseDouble(pass2Array.substring(pass2Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass2Array.substring(0, pass2Array.indexOf(",")));
                    if (in > pass2Inlet) {
                        pass2Inlet = in;
                    }
                    if (out > pass2Out) {
                        pass2Out = out;
                    }
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    double in = Double.parseDouble(pass3Array.substring(pass3Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass3Array.substring(0, pass3Array.indexOf(",")));
                    if (in > pass3Inlet) {
                        pass3Inlet = in;
                    }
                    if (out > pass3Out) {
                        pass3Out = out;
                    }
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    double in = Double.parseDouble(pass4Array.substring(pass4Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass4Array.substring(0, pass4Array.indexOf(",")));
                    if (in > pass4Inlet) {
                        pass4Inlet = in;
                    }
                    if (out > pass4Out) {
                        pass4Out = out;
                    }
                }
                if (StringUtils.isNotEmpty(pass5Array)) {
                    double in = Double.parseDouble(pass5Array.substring(pass5Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass5Array.substring(0, pass5Array.indexOf(",")));
                    if (in > pass5Inlet) {
                        pass5Inlet = in;
                    }
                    if (out > pass5Out) {
                        pass5Out = out;
                    }
                }
                if (StringUtils.isNotEmpty(pass6Array)) {
                    double in = Double.parseDouble(pass6Array.substring(pass6Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass6Array.substring(0, pass6Array.indexOf(",")));
                    if (in > pass6Inlet) {
                        pass6Inlet = in;
                    }
                    if (out > pass6Out) {
                        pass6Out = out;
                    }
                }
                if (StringUtils.isNotEmpty(pass7Array)) {
                    double in = Double.parseDouble(pass7Array.substring(pass7Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass7Array.substring(0, pass7Array.indexOf(",")));
                    if (in > pass7Inlet) {
                        pass7Inlet = in;
                    }
                    if (out > pass7Out) {
                        pass7Out = out;
                    }
                }
                if (StringUtils.isNotEmpty(pass8Array)) {
                    double in = Double.parseDouble(pass8Array.substring(pass8Array.lastIndexOf(",") + 1));
                    double out = this.getMaxValue(pass8Array.substring(0, pass8Array.indexOf(",")));
                    if (in > pass8Inlet) {
                        pass8Inlet = in;
                    }
                    if (out > pass8Out) {
                        pass8Out = out;
                    }
                }
            }
            DecimalFormat df = new DecimalFormat("#.00");
            if (pass1Inlet != 0 && pass1Out != 0) {
                pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
            }
            if (pass2Inlet != 0 && pass2Out != 0) {
                pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
            }
            if (pass3Inlet != 0 && pass3Out != 0) {
                pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
            }
            if (pass4Inlet != 0 && pass4Out != 0) {
                pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
            }
            if (pass5Inlet != 0 && pass5Out != 0) {
                pass5Ratio = Double.parseDouble(df.format(pass5Out / pass5Inlet));
            }
            if (pass6Inlet != 0 && pass6Out != 0) {
                pass6Ratio = Double.parseDouble(df.format(pass6Out / pass6Inlet));
            }
            if (pass7Inlet != 0 && pass7Out != 0) {
                pass7Ratio = Double.parseDouble(df.format(pass7Out / pass7Inlet));
            }
            if (pass8Inlet != 0 && pass8Out != 0) {
                pass8Ratio = Double.parseDouble(df.format(pass8Out / pass8Inlet));
            }
            FurnancePressureFvpVO vo = new FurnancePressureFvpVO();
            vo.setPass1Inlet(pass1Inlet);
            vo.setPass2Inlet(pass2Inlet);
            vo.setPass3Inlet(pass3Inlet);
            vo.setPass4Inlet(pass4Inlet);
            vo.setPass5Inlet(pass5Inlet);
            vo.setPass6Inlet(pass6Inlet);
            vo.setPass7Inlet(pass7Inlet);
            vo.setPass8Inlet(pass8Inlet);
            vo.setPass1Out(pass1Out);
            vo.setPass2Out(pass2Out);
            vo.setPass3Out(pass3Out);
            vo.setPass4Out(pass4Out);
            vo.setPass5Out(pass5Out);
            vo.setPass6Out(pass6Out);
            vo.setPass7Out(pass7Out);
            vo.setPass8Out(pass8Out);
            vo.setPass1Ratio(pass1Ratio);
            vo.setPass2Ratio(pass2Ratio);
            vo.setPass3Ratio(pass3Ratio);
            vo.setPass4Ratio(pass4Ratio);
            vo.setPass5Ratio(pass5Ratio);
            vo.setPass6Ratio(pass6Ratio);
            vo.setPass7Ratio(pass7Ratio);
            vo.setPass8Ratio(pass8Ratio);
            vo.setAllPassMaxInlet(this.getMaxDouble(new double[]{pass1Inlet, pass2Inlet, pass3Inlet, pass4Inlet, pass5Inlet, pass6Inlet, pass7Inlet, pass8Inlet}));
            vo.setAllPassMaxOut(this.getMaxDouble(new double[]{pass1Out, pass2Out, pass3Out, pass4Out, pass5Out, pass6Out, pass7Out, pass8Out}));
            vo.setAllPassMaxRatio(this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio, pass5Ratio, pass6Ratio, pass7Ratio, pass8Ratio}));
            return vo;
        } else {
            return null;
        }
    }

    public FurnancePressureFvpVO calcRatio109A(List<TFurnancePressure> tFurnancePressure) {
        if (tFurnancePressure != null && tFurnancePressure.size() != 0) {
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            double pass5Inlet = 0;
            double pass6Inlet = 0;
            double pass7Inlet = 0;
            double pass8Inlet = 0;
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            double pass5Out = 0;
            double pass6Out = 0;
            double pass7Out = 0;
            double pass8Out = 0;
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            double pass5Ratio = 0;
            double pass6Ratio = 0;
            double pass7Ratio = 0;
            double pass8Ratio = 0;
            // 获取pass max值
            // xxx,xxx,xxx,...->xxx
            for (TFurnancePressure furnancePressure : tFurnancePressure) {
                String pass1Array = furnancePressure.getPass1();
                String pass2Array = furnancePressure.getPass3();
                String pass3Array = furnancePressure.getPass5();
                String pass4Array = furnancePressure.getPass7();
                String pass5Array = furnancePressure.getPass9();
                String pass6Array = furnancePressure.getPass11();
                String pass7Array = furnancePressure.getPass13();
                String pass8Array = furnancePressure.getPass15();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    int lastIndex = pass1Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass1Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass1Inlet) {
                                pass1Inlet = in;
                            }
                        }
                    }
                    int index = pass1Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass1Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass1Out) {
                                pass1Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    int lastIndex = pass2Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass2Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass2Inlet) {
                                pass2Inlet = in;
                            }
                        }
                    }
                    int index = pass2Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass2Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass2Out) {
                                pass2Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    int lastIndex = pass3Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass3Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass3Inlet) {
                                pass3Inlet = in;
                            }
                        }
                    }
                    int index = pass3Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass3Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass3Out) {
                                pass3Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    int lastIndex = pass4Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass4Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass4Inlet) {
                                pass4Inlet = in;
                            }
                        }
                    }
                    int index = pass4Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass4Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass4Out) {
                                pass4Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass5Array)) {
                    int lastIndex = pass5Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass5Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass5Inlet) {
                                pass5Inlet = in;
                            }
                        }
                    }
                    int index = pass5Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass5Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass5Out) {
                                pass5Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass6Array)) {
                    int lastIndex = pass6Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass6Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass6Inlet) {
                                pass6Inlet = in;
                            }
                        }
                    }
                    int index = pass6Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass6Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass6Out) {
                                pass6Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass7Array)) {
                    int lastIndex = pass7Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass7Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass7Inlet) {
                                pass7Inlet = in;
                            }
                        }
                    }
                    int index = pass7Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass7Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass7Out) {
                                pass7Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass8Array)) {
                    int lastIndex = pass8Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass8Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass8Inlet) {
                                pass8Inlet = in;
                            }
                        }
                    }
                    int index = pass8Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass8Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass8Out) {
                                pass8Out = out;
                            }
                        }
                    }
                }
            }
            DecimalFormat df = new DecimalFormat("#.00");
            if (pass1Inlet != 0 && pass1Out != 0) {
                pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
            }
            if (pass2Inlet != 0 && pass2Out != 0) {
                pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
            }
            if (pass3Inlet != 0 && pass3Out != 0) {
                pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
            }
            if (pass4Inlet != 0 && pass4Out != 0) {
                pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
            }
            if (pass5Inlet != 0 && pass5Out != 0) {
                pass5Ratio = Double.parseDouble(df.format(pass5Out / pass5Inlet));
            }
            if (pass6Inlet != 0 && pass6Out != 0) {
                pass6Ratio = Double.parseDouble(df.format(pass6Out / pass6Inlet));
            }
            if (pass7Inlet != 0 && pass7Out != 0) {
                pass7Ratio = Double.parseDouble(df.format(pass7Out / pass7Inlet));
            }
            if (pass8Inlet != 0 && pass8Out != 0) {
                pass8Ratio = Double.parseDouble(df.format(pass8Out / pass8Inlet));
            }
            FurnancePressureFvpVO vo = new FurnancePressureFvpVO();
            vo.setPass1Inlet(pass1Inlet);
            vo.setPass2Inlet(pass2Inlet);
            vo.setPass3Inlet(pass3Inlet);
            vo.setPass4Inlet(pass4Inlet);
            vo.setPass5Inlet(pass5Inlet);
            vo.setPass6Inlet(pass6Inlet);
            vo.setPass7Inlet(pass7Inlet);
            vo.setPass8Inlet(pass8Inlet);
            vo.setPass1Out(pass1Out);
            vo.setPass2Out(pass2Out);
            vo.setPass3Out(pass3Out);
            vo.setPass4Out(pass4Out);
            vo.setPass5Out(pass5Out);
            vo.setPass6Out(pass6Out);
            vo.setPass7Out(pass7Out);
            vo.setPass8Out(pass8Out);
            vo.setPass1Ratio(pass1Ratio);
            vo.setPass2Ratio(pass2Ratio);
            vo.setPass3Ratio(pass3Ratio);
            vo.setPass4Ratio(pass4Ratio);
            vo.setPass5Ratio(pass5Ratio);
            vo.setPass6Ratio(pass6Ratio);
            vo.setPass7Ratio(pass7Ratio);
            vo.setPass8Ratio(pass8Ratio);
            vo.setAllPassMaxInlet(this.getMaxDouble(new double[]{pass1Inlet, pass2Inlet, pass3Inlet, pass4Inlet, pass5Inlet, pass6Inlet, pass7Inlet, pass8Inlet}));
            vo.setAllPassMaxOut(this.getMaxDouble(new double[]{pass1Out, pass2Out, pass3Out, pass4Out, pass5Out, pass6Out, pass7Out, pass8Out}));
            vo.setAllPassMaxRatio(this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio, pass5Ratio, pass6Ratio, pass7Ratio, pass8Ratio}));
            return vo;
        } else {
            return null;
        }
    }

    public FurnancePressureFvpVO calcRatio109B(List<TFurnancePressure> tFurnancePressure) {
        if (tFurnancePressure != null && tFurnancePressure.size() != 0) {
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            double pass5Inlet = 0;
            double pass6Inlet = 0;
            double pass7Inlet = 0;
            double pass8Inlet = 0;
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            double pass5Out = 0;
            double pass6Out = 0;
            double pass7Out = 0;
            double pass8Out = 0;
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            double pass5Ratio = 0;
            double pass6Ratio = 0;
            double pass7Ratio = 0;
            double pass8Ratio = 0;
            // 获取pass max值
            // xxx,xxx,xxx,...->xxx
            for (TFurnancePressure furnancePressure : tFurnancePressure) {
                String pass1Array = furnancePressure.getPass2();
                String pass2Array = furnancePressure.getPass4();
                String pass3Array = furnancePressure.getPass6();
                String pass4Array = furnancePressure.getPass8();
                String pass5Array = furnancePressure.getPass10();
                String pass6Array = furnancePressure.getPass12();
                String pass7Array = furnancePressure.getPass14();
                String pass8Array = furnancePressure.getPass16();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    int lastIndex = pass1Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass1Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass1Inlet) {
                                pass1Inlet = in;
                            }
                        }
                    }
                    int index = pass1Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass1Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass1Out) {
                                pass1Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    int lastIndex = pass2Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass2Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass2Inlet) {
                                pass2Inlet = in;
                            }
                        }
                    }
                    int index = pass2Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass2Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass2Out) {
                                pass2Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    int lastIndex = pass3Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass3Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass3Inlet) {
                                pass3Inlet = in;
                            }
                        }
                    }
                    int index = pass3Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass3Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass3Out) {
                                pass3Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    int lastIndex = pass4Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass4Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass4Inlet) {
                                pass4Inlet = in;
                            }
                        }
                    }
                    int index = pass4Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass4Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass4Out) {
                                pass4Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass5Array)) {
                    int lastIndex = pass5Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass5Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass5Inlet) {
                                pass5Inlet = in;
                            }
                        }
                    }
                    int index = pass5Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass5Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass5Out) {
                                pass5Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass6Array)) {
                    int lastIndex = pass6Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass6Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass6Inlet) {
                                pass6Inlet = in;
                            }
                        }
                    }
                    int index = pass6Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass6Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass6Out) {
                                pass6Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass7Array)) {
                    int lastIndex = pass7Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass7Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass7Inlet) {
                                pass7Inlet = in;
                            }
                        }
                    }
                    int index = pass7Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass7Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass7Out) {
                                pass7Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass8Array)) {
                    int lastIndex = pass8Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass8Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass8Inlet) {
                                pass8Inlet = in;
                            }
                        }
                    }
                    int index = pass8Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass8Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass8Out) {
                                pass8Out = out;
                            }
                        }
                    }
                }
            }
            DecimalFormat df = new DecimalFormat("#.00");
            if (pass1Inlet != 0 && pass1Out != 0) {
                pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
            }
            if (pass2Inlet != 0 && pass2Out != 0) {
                pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
            }
            if (pass3Inlet != 0 && pass3Out != 0) {
                pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
            }
            if (pass4Inlet != 0 && pass4Out != 0) {
                pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
            }
            if (pass5Inlet != 0 && pass5Out != 0) {
                pass5Ratio = Double.parseDouble(df.format(pass5Out / pass5Inlet));
            }
            if (pass6Inlet != 0 && pass6Out != 0) {
                pass6Ratio = Double.parseDouble(df.format(pass6Out / pass6Inlet));
            }
            if (pass7Inlet != 0 && pass7Out != 0) {
                pass7Ratio = Double.parseDouble(df.format(pass7Out / pass7Inlet));
            }
            if (pass8Inlet != 0 && pass8Out != 0) {
                pass8Ratio = Double.parseDouble(df.format(pass8Out / pass8Inlet));
            }
            FurnancePressureFvpVO vo = new FurnancePressureFvpVO();
            vo.setPass1Inlet(pass1Inlet);
            vo.setPass2Inlet(pass2Inlet);
            vo.setPass3Inlet(pass3Inlet);
            vo.setPass4Inlet(pass4Inlet);
            vo.setPass5Inlet(pass5Inlet);
            vo.setPass6Inlet(pass6Inlet);
            vo.setPass7Inlet(pass7Inlet);
            vo.setPass8Inlet(pass8Inlet);
            vo.setPass1Out(pass1Out);
            vo.setPass2Out(pass2Out);
            vo.setPass3Out(pass3Out);
            vo.setPass4Out(pass4Out);
            vo.setPass5Out(pass5Out);
            vo.setPass6Out(pass6Out);
            vo.setPass7Out(pass7Out);
            vo.setPass8Out(pass8Out);
            vo.setPass1Ratio(pass1Ratio);
            vo.setPass2Ratio(pass2Ratio);
            vo.setPass3Ratio(pass3Ratio);
            vo.setPass4Ratio(pass4Ratio);
            vo.setPass5Ratio(pass5Ratio);
            vo.setPass6Ratio(pass6Ratio);
            vo.setPass7Ratio(pass7Ratio);
            vo.setPass8Ratio(pass8Ratio);
            vo.setAllPassMaxInlet(this.getMaxDouble(new double[]{pass1Inlet, pass2Inlet, pass3Inlet, pass4Inlet, pass5Inlet, pass6Inlet, pass7Inlet, pass8Inlet}));
            vo.setAllPassMaxOut(this.getMaxDouble(new double[]{pass1Out, pass2Out, pass3Out, pass4Out, pass5Out, pass6Out, pass7Out, pass8Out}));
            vo.setAllPassMaxRatio(this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio, pass5Ratio, pass6Ratio, pass7Ratio, pass8Ratio}));
            return vo;
        } else {
            return null;
        }
    }

    public FurnancePressureFvpVO calcRatio130(List<TFurnancePressure> tFurnancePressure) {
        if (tFurnancePressure != null && tFurnancePressure.size() != 0) {
            double pass1Inlet = 0;
            double pass2Inlet = 0;
            double pass3Inlet = 0;
            double pass4Inlet = 0;
            double pass1Out = 0;
            double pass2Out = 0;
            double pass3Out = 0;
            double pass4Out = 0;
            double pass1Ratio = 0;
            double pass2Ratio = 0;
            double pass3Ratio = 0;
            double pass4Ratio = 0;
            // 获取pass max值
            // xxx,xxx,xxx,...->xxx
            for (TFurnancePressure furnancePressure : tFurnancePressure) {
                String pass1Array = furnancePressure.getPass1();
                String pass2Array = furnancePressure.getPass2();
                String pass3Array = furnancePressure.getPass3();
                String pass4Array = furnancePressure.getPass4();
                if (StringUtils.isNotEmpty(pass1Array)) {
                    int lastIndex = pass1Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass1Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass1Inlet) {
                                pass1Inlet = in;
                            }
                        }
                    }
                    int index = pass1Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass1Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass1Out) {
                                pass1Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass2Array)) {
                    int lastIndex = pass2Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass2Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass2Inlet) {
                                pass2Inlet = in;
                            }
                        }
                    }
                    int index = pass2Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass2Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass2Out) {
                                pass2Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass3Array)) {
                    int lastIndex = pass3Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass3Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass3Inlet) {
                                pass3Inlet = in;
                            }
                        }
                    }
                    int index = pass3Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass3Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass3Out) {
                                pass3Out = out;
                            }
                        }
                    }
                }
                if (StringUtils.isNotEmpty(pass4Array)) {
                    int lastIndex = pass4Array.lastIndexOf(",");
                    if (lastIndex != -1) {
                        String substring = pass4Array.substring(lastIndex + 1);
                        if (StringUtils.isNotEmpty(substring)) {
                            double in = Double.parseDouble(substring);
                            if (in > pass4Inlet) {
                                pass4Inlet = in;
                            }
                        }
                    }
                    int index = pass4Array.indexOf(",");
                    if (index != -1) {
                        String substring = pass4Array.substring(0, index);
                        if (StringUtils.isNotEmpty(substring)) {
                            double out = this.getMaxValue(substring);
                            if (out > pass4Out) {
                                pass4Out = out;
                            }
                        }
                    }
                }
            }
            DecimalFormat df = new DecimalFormat("#.00");
            if (pass1Inlet != 0 && pass1Out != 0) {
                pass1Ratio = Double.parseDouble(df.format(pass1Out / pass1Inlet));
            }
            if (pass2Inlet != 0 && pass2Out != 0) {
                pass2Ratio = Double.parseDouble(df.format(pass2Out / pass2Inlet));
            }
            if (pass3Inlet != 0 && pass3Out != 0) {
                pass3Ratio = Double.parseDouble(df.format(pass3Out / pass3Inlet));
            }
            if (pass4Inlet != 0 && pass4Out != 0) {
                pass4Ratio = Double.parseDouble(df.format(pass4Out / pass4Inlet));
            }
            FurnancePressureFvpVO vo = new FurnancePressureFvpVO();
            vo.setPass1Inlet(pass1Inlet);
            vo.setPass2Inlet(pass2Inlet);
            vo.setPass3Inlet(pass3Inlet);
            vo.setPass4Inlet(pass4Inlet);
            vo.setPass1Out(pass1Out);
            vo.setPass2Out(pass2Out);
            vo.setPass3Out(pass3Out);
            vo.setPass4Out(pass4Out);
            vo.setPass1Ratio(pass1Ratio);
            vo.setPass2Ratio(pass2Ratio);
            vo.setPass3Ratio(pass3Ratio);
            vo.setPass4Ratio(pass4Ratio);
            vo.setAllPassMaxInlet(this.getMaxDouble(new double[]{pass1Inlet, pass2Inlet, pass3Inlet, pass4Inlet}));
            vo.setAllPassMaxOut(this.getMaxDouble(new double[]{pass1Out, pass2Out, pass3Out, pass4Out}));
            vo.setAllPassMaxRatio(this.getMaxDouble(new double[]{pass1Ratio, pass2Ratio, pass3Ratio, pass4Ratio}));
            return vo;
        } else {
            return null;
        }
    }

    public double getMaxDouble(double[] list) {
        double max = list[0];
        for (int i = 1; i < list.length; i++) {
            if (list[i] > max) {
                max = list[i];
            }
        }
        return max;
    }

    public String checkNull(String pass) {
        if (StringUtils.isNull(pass)) {
            return "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0";
        } else {
            return pass;
        }
    }

    /**
     * 查询裂解炉炉管测压MAX
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:list')")
    @GetMapping("/max")
    public AjaxResult max(TFurnancePressure tFurnancePressure) {
        tFurnancePressure.setFurnanceName("H109");
        List<TFurnancePressure> list109 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H110");
        List<TFurnancePressure> list110 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H111");
        List<TFurnancePressure> list111 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H112");
        List<TFurnancePressure> list112 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H113");
        List<TFurnancePressure> list113 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H114");
        List<TFurnancePressure> list114 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H115");
        List<TFurnancePressure> list115 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H116");
        List<TFurnancePressure> list116 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H117");
        List<TFurnancePressure> list117 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H118");
        List<TFurnancePressure> list118 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H130");
        List<TFurnancePressure> list130 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        if (list109.size() != list110.size() || list109.size() != list111.size()
                || list109.size() != list112.size() || list109.size() != list113.size()
                || list109.size() != list114.size() || list109.size() != list115.size()
                || list109.size() != list116.size() || list109.size() != list117.size()
                || list109.size() != list118.size() || list109.size() != list130.size()) {
            return AjaxResult.success("incompleteData");
        }
        List<FurnancePressureVO> coilList = new ArrayList<FurnancePressureVO>(list109.size());
        if (list109.size() != 0) {
            for (int i = 0; i < list109.size(); i++) {
                TFurnancePressure ft = list109.get(i);
                FurnancePressureVO coil = new FurnancePressureVO();
                coil.setRecordTime(ft.getRecordTime());
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                String pass9 = this.checkNull(ft.getPass9());
                String pass10 = this.checkNull(ft.getPass10());
                String pass11 = this.checkNull(ft.getPass11());
                String pass12 = this.checkNull(ft.getPass12());
                String pass13 = this.checkNull(ft.getPass13());
                String pass14 = this.checkNull(ft.getPass14());
                String pass15 = this.checkNull(ft.getPass15());
                String pass16 = this.checkNull(ft.getPass16());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)
                        || "".equals(pass9) || "".equals(pass10) || "".equals(pass11) || "".equals(pass12)
                        || "".equals(pass13) || "".equals(pass14) || "".equals(pass15) || "".equals(pass16)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                pass9 = pass9.substring(0, pass9.lastIndexOf(","));
                pass10 = pass10.substring(0, pass10.lastIndexOf(","));
                pass11 = pass11.substring(0, pass11.lastIndexOf(","));
                pass12 = pass12.substring(0, pass12.lastIndexOf(","));
                pass13 = pass13.substring(0, pass13.lastIndexOf(","));
                pass14 = pass14.substring(0, pass14.lastIndexOf(","));
                pass15 = pass15.substring(0, pass15.lastIndexOf(","));
                pass16 = pass16.substring(0, pass16.lastIndexOf(","));
                coil.setH109Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8) + ","
                        + this.getMaxValue(pass9 + "," + pass10) + ","
                        + this.getMaxValue(pass11 + "," + pass12) + ","
                        + this.getMaxValue(pass13 + "," + pass14) + ","
                        + this.getMaxValue(pass15 + "," + pass16));
                coilList.add(coil);
            }
        }
        if (list110.size() != 0) {
            for (int i = 0; i < list110.size(); i++) {
                TFurnancePressure ft = list110.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH110Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list111.size() != 0) {
            for (int i = 0; i < list111.size(); i++) {
                TFurnancePressure ft = list111.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH111Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list112.size() != 0) {
            for (int i = 0; i < list112.size(); i++) {
                TFurnancePressure ft = list112.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH112Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list113.size() != 0) {
            for (int i = 0; i < list113.size(); i++) {
                TFurnancePressure ft = list113.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH113Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list114.size() != 0) {
            for (int i = 0; i < list114.size(); i++) {
                TFurnancePressure ft = list114.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH114Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list115.size() != 0) {
            for (int i = 0; i < list115.size(); i++) {
                TFurnancePressure ft = list115.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH115Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list116.size() != 0) {
            for (int i = 0; i < list116.size(); i++) {
                TFurnancePressure ft = list116.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH116Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list117.size() != 0) {
            for (int i = 0; i < list117.size(); i++) {
                TFurnancePressure ft = list117.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH117Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list118.size() != 0) {
            for (int i = 0; i < list118.size(); i++) {
                TFurnancePressure ft = list118.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH118Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8));
            }
        }
        if (list130.size() != 0) {
            for (int i = 0; i < list130.size(); i++) {
                TFurnancePressure ft = list130.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                String pass9 = this.checkNull(ft.getPass9());
                String pass10 = this.checkNull(ft.getPass10());
                String pass11 = this.checkNull(ft.getPass11());
                String pass12 = this.checkNull(ft.getPass12());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)
                        || "".equals(pass9) || "".equals(pass10) || "".equals(pass11) || "".equals(pass12)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                pass9 = pass9.substring(0, pass9.lastIndexOf(","));
                pass10 = pass10.substring(0, pass10.lastIndexOf(","));
                pass11 = pass11.substring(0, pass11.lastIndexOf(","));
                pass12 = pass12.substring(0, pass12.lastIndexOf(","));
                coilList.get(i).setH130Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8) + ","
                        + this.getMaxValue(pass9) + "," + this.getMaxValue(pass10) + ","
                        + this.getMaxValue(pass11) + "," + this.getMaxValue(pass12));
            }
        }
        for (FurnancePressureVO vo : coilList) {
            vo.setH109Out(this.getMaxValue(vo.getH109Out()) + "");
            vo.setH110Out(this.getMaxValue(vo.getH110Out()) + "");
            vo.setH111Out(this.getMaxValue(vo.getH111Out()) + "");
            vo.setH112Out(this.getMaxValue(vo.getH112Out()) + "");
            vo.setH113Out(this.getMaxValue(vo.getH113Out()) + "");
            vo.setH114Out(this.getMaxValue(vo.getH114Out()) + "");
            vo.setH115Out(this.getMaxValue(vo.getH115Out()) + "");
            vo.setH116Out(this.getMaxValue(vo.getH116Out()) + "");
            vo.setH117Out(this.getMaxValue(vo.getH117Out()) + "");
            vo.setH118Out(this.getMaxValue(vo.getH118Out()) + "");
            vo.setH130Out(this.getMaxValue(vo.getH130Out()) + "");
        }
        return AjaxResult.success(coilList);
    }

    /**
     * 查询裂解炉炉管测压COIL
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:list')")
    @GetMapping("/coil")
    public AjaxResult coil(TFurnancePressure tFurnancePressure) {
        tFurnancePressure.setFurnanceName("H109");
        List<TFurnancePressure> list109 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H110");
        List<TFurnancePressure> list110 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H111");
        List<TFurnancePressure> list111 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H112");
        List<TFurnancePressure> list112 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H113");
        List<TFurnancePressure> list113 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H114");
        List<TFurnancePressure> list114 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H115");
        List<TFurnancePressure> list115 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H116");
        List<TFurnancePressure> list116 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H117");
        List<TFurnancePressure> list117 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H118");
        List<TFurnancePressure> list118 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        tFurnancePressure.setFurnanceName("H130");
        List<TFurnancePressure> list130 = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        if (list109.size() != list110.size() || list109.size() != list111.size()
                || list109.size() != list112.size() || list109.size() != list113.size()
                || list109.size() != list114.size() || list109.size() != list115.size()
                || list109.size() != list116.size() || list109.size() != list117.size()
                || list109.size() != list118.size() || list109.size() != list130.size()) {
            return AjaxResult.success("incompleteData");
        }
        List<FurnancePressureVO> coilList = new ArrayList<FurnancePressureVO>(list109.size());
        if (list109.size() != 0) {
            for (int i = 0; i < list109.size(); i++) {
                TFurnancePressure ft = list109.get(i);
                FurnancePressureVO coil = new FurnancePressureVO();
                coil.setRecordTime(ft.getRecordTime());
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                String pass9 = this.checkNull(ft.getPass9());
                String pass10 = this.checkNull(ft.getPass10());
                String pass11 = this.checkNull(ft.getPass11());
                String pass12 = this.checkNull(ft.getPass12());
                String pass13 = this.checkNull(ft.getPass13());
                String pass14 = this.checkNull(ft.getPass14());
                String pass15 = this.checkNull(ft.getPass15());
                String pass16 = this.checkNull(ft.getPass16());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)
                        || "".equals(pass9) || "".equals(pass10) || "".equals(pass11) || "".equals(pass12)
                        || "".equals(pass13) || "".equals(pass14) || "".equals(pass15) || "".equals(pass16)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                pass9 = pass9.substring(0, pass9.lastIndexOf(","));
                pass10 = pass10.substring(0, pass10.lastIndexOf(","));
                pass11 = pass11.substring(0, pass11.lastIndexOf(","));
                pass12 = pass12.substring(0, pass12.lastIndexOf(","));
                pass13 = pass13.substring(0, pass13.lastIndexOf(","));
                pass14 = pass14.substring(0, pass14.lastIndexOf(","));
                pass15 = pass15.substring(0, pass15.lastIndexOf(","));
                pass16 = pass16.substring(0, pass16.lastIndexOf(","));
                coil.setH109Out(this.getMaxValue(pass1 + "," + pass2) + ","
                        + this.getMaxValue(pass3 + "," + pass4) + ","
                        + this.getMaxValue(pass5 + "," + pass6) + ","
                        + this.getMaxValue(pass7 + "," + pass8) + ","
                        + this.getMaxValue(pass9 + "," + pass10) + ","
                        + this.getMaxValue(pass11 + "," + pass12) + ","
                        + this.getMaxValue(pass13 + "," + pass14) + ","
                        + this.getMaxValue(pass15 + "," + pass16));
                coilList.add(coil);
            }
        }
        if (list110.size() != 0) {
            for (int i = 0; i < list110.size(); i++) {
                TFurnancePressure ft = list110.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH110Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list111.size() != 0) {
            for (int i = 0; i < list111.size(); i++) {
                TFurnancePressure ft = list111.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH111Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list112.size() != 0) {
            for (int i = 0; i < list112.size(); i++) {
                TFurnancePressure ft = list112.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH112Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list113.size() != 0) {
            for (int i = 0; i < list113.size(); i++) {
                TFurnancePressure ft = list113.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH113Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list114.size() != 0) {
            for (int i = 0; i < list114.size(); i++) {
                TFurnancePressure ft = list114.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH114Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list115.size() != 0) {
            for (int i = 0; i < list115.size(); i++) {
                TFurnancePressure ft = list115.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH115Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list116.size() != 0) {
            for (int i = 0; i < list116.size(); i++) {
                TFurnancePressure ft = list116.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH116Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list117.size() != 0) {
            for (int i = 0; i < list117.size(); i++) {
                TFurnancePressure ft = list117.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH117Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list118.size() != 0) {
            for (int i = 0; i < list118.size(); i++) {
                TFurnancePressure ft = list118.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                coilList.get(i).setH118Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8));
            }
        }
        if (list130.size() != 0) {
            for (int i = 0; i < list130.size(); i++) {
                TFurnancePressure ft = list130.get(i);
                String pass1 = this.checkNull(ft.getPass1());
                String pass2 = this.checkNull(ft.getPass2());
                String pass3 = this.checkNull(ft.getPass3());
                String pass4 = this.checkNull(ft.getPass4());
                String pass5 = this.checkNull(ft.getPass5());
                String pass6 = this.checkNull(ft.getPass6());
                String pass7 = this.checkNull(ft.getPass7());
                String pass8 = this.checkNull(ft.getPass8());
                String pass9 = this.checkNull(ft.getPass9());
                String pass10 = this.checkNull(ft.getPass10());
                String pass11 = this.checkNull(ft.getPass11());
                String pass12 = this.checkNull(ft.getPass12());
                if ("".equals(pass1) || "".equals(pass2) || "".equals(pass3) || "".equals(pass4)
                        || "".equals(pass5) || "".equals(pass6) || "".equals(pass7) || "".equals(pass8)
                        || "".equals(pass9) || "".equals(pass10) || "".equals(pass11) || "".equals(pass12)) {
                    return AjaxResult.success("incompleteData");
                }
                pass1 = pass1.substring(0, pass1.lastIndexOf(","));
                pass2 = pass2.substring(0, pass2.lastIndexOf(","));
                pass3 = pass3.substring(0, pass3.lastIndexOf(","));
                pass4 = pass4.substring(0, pass4.lastIndexOf(","));
                pass5 = pass5.substring(0, pass5.lastIndexOf(","));
                pass6 = pass6.substring(0, pass6.lastIndexOf(","));
                pass7 = pass7.substring(0, pass7.lastIndexOf(","));
                pass8 = pass8.substring(0, pass8.lastIndexOf(","));
                pass9 = pass9.substring(0, pass9.lastIndexOf(","));
                pass10 = pass10.substring(0, pass10.lastIndexOf(","));
                pass11 = pass11.substring(0, pass11.lastIndexOf(","));
                pass12 = pass12.substring(0, pass12.lastIndexOf(","));
                coilList.get(i).setH130Out(this.getMaxValue(pass1) + "," + this.getMaxValue(pass2) + ","
                        + this.getMaxValue(pass3) + "," + this.getMaxValue(pass4) + ","
                        + this.getMaxValue(pass5) + "," + this.getMaxValue(pass6) + ","
                        + this.getMaxValue(pass7) + "," + this.getMaxValue(pass8) + ","
                        + this.getMaxValue(pass9) + "," + this.getMaxValue(pass10) + ","
                        + this.getMaxValue(pass11) + "," + this.getMaxValue(pass12));
            }
        }
        return AjaxResult.success(coilList);
    }

    public int getMaxValue(String value) {
        if (StringUtils.isNotNull(value) && StringUtils.isNotEmpty(value)) {
            String[] split = value.split(",");
            int max = Integer.parseInt(split[0]);
            for (int i = 0; i < split.length; i++) {
                int element = Integer.parseInt(split[i]);
                if (element > max) {
                    max = element;
                }
            }
            return max;
        } else {
            return 0;
        }
    }

    /**
     * 查询裂解炉炉管测压列表
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFurnancePressure tFurnancePressure) {
        startPage();
        List<TFurnancePressure> list = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        return getDataTable(list);
    }

    /**
     * 导出裂解炉炉管测压列表
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:export')")
    @Log(title = "裂解炉炉管测压", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TFurnancePressure tFurnancePressure) {
        List<TFurnancePressure> list = tFurnancePressureService.selectTFurnancePressureList(tFurnancePressure);
        ExcelUtil<TFurnancePressure> util = new ExcelUtil<TFurnancePressure>(TFurnancePressure.class);
        return util.exportExcel(list, "pressure");
    }

    /**
     * 获取裂解炉炉管测压详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tFurnancePressureService.selectTFurnancePressureById(id));
    }

    /**
     * 新增裂解炉炉管测压
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:add')")
    @Log(title = "裂解炉炉管测压", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFurnancePressure tFurnancePressure) {
        return toAjax(tFurnancePressureService.insertTFurnancePressure(tFurnancePressure));
    }

    public boolean isNegativeOrNull(TFurnancePressure tFurnancePressure) {
        String pass1 = tFurnancePressure.getPass1();
        String pass2 = tFurnancePressure.getPass2();
        String pass3 = tFurnancePressure.getPass3();
        String pass4 = tFurnancePressure.getPass4();
        String pass5 = tFurnancePressure.getPass5();
        String pass6 = tFurnancePressure.getPass6();
        String pass7 = tFurnancePressure.getPass7();
        String pass8 = tFurnancePressure.getPass8();
        String pass9 = tFurnancePressure.getPass9();
        String pass10 = tFurnancePressure.getPass10();
        String pass11 = tFurnancePressure.getPass11();
        String pass12 = tFurnancePressure.getPass12();
        String pass13 = tFurnancePressure.getPass13();
        String pass14 = tFurnancePressure.getPass14();
        String pass15 = tFurnancePressure.getPass15();
        String pass16 = tFurnancePressure.getPass16();
        if ("H109".equals(tFurnancePressure.getFurnanceName())) {
            if (this.isPassNegativeOrNull(pass1)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass2)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass3)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass4)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass5)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass6)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass7)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass8)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass9)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass10)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass11)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass12)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass13)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass14)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass15)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass16)) {
                return true;
            } else {
                return false;
            }
        } else if ("H130".equals(tFurnancePressure.getFurnanceName())) {
            if (this.isPassNegativeOrNull(pass1)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass2)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass3)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass4)) {
                return true;
            }
        } else {
            if (this.isPassNegativeOrNull(pass1)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass2)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass3)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass4)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass5)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass6)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass7)) {
                return true;
            } else if (this.isPassNegativeOrNull(pass8)) {
                return true;
            }
        }
        return false;
    }

    public boolean isPassNegativeOrNull(String pass) {
        boolean flag = false;
        if (StringUtils.isNotNull(pass) && StringUtils.isNotEmpty(pass)) {
            String[] split = pass.split(",");
            for (int i = 0; i < split.length; i++) {
                if (StringUtils.isNull(split[i]) || StringUtils.isEmpty(split[i])) {
                    flag = true;
                    break;
                } else {
                    int element = Integer.parseInt(split[i]);
                    if (element < 0) {
                        flag = true;
                        break;
                    }
                }
            }
            return flag;
        } else {
            return true;
        }
    }

    /**
     * 修改裂解炉炉管测压（APP）
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:edit')")
    @Log(title = "裂解炉炉管测压", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFurnancePressure tFurnancePressure) throws PinyinException {
        String pass1 = tFurnancePressure.getPass1();
        String pass2 = tFurnancePressure.getPass2();
        String pass3 = tFurnancePressure.getPass3();
        String pass4 = tFurnancePressure.getPass4();
        String pass5 = tFurnancePressure.getPass5();
        String pass6 = tFurnancePressure.getPass6();
        String pass7 = tFurnancePressure.getPass7();
        String pass8 = tFurnancePressure.getPass8();
        String pass9 = tFurnancePressure.getPass9();
        String pass10 = tFurnancePressure.getPass10();
        String pass11 = tFurnancePressure.getPass11();
        String pass12 = tFurnancePressure.getPass12();
        String pass13 = tFurnancePressure.getPass13();
        String pass14 = tFurnancePressure.getPass14();
        String pass15 = tFurnancePressure.getPass15();
        String pass16 = tFurnancePressure.getPass16();
        //更新
        tFurnancePressureService.updateTFurnancePressure(tFurnancePressure);
        //计算ratio
        TFurnancePressure pressure = tFurnancePressureService.selectTFurnancePressureById(tFurnancePressure.getId());
        String furnanceName = pressure.getFurnanceName();
        List<TFurnancePressure> list = new ArrayList();
        list.add(pressure);
        String msg = "";
        if (StringUtils.isNotNull(furnanceName)) {//快捷修改不检查发邮件
            switch (furnanceName) {
                case "H109":
                    FurnancePressureFvpVO furnancePressureFvpVO109A = this.calcRatio109A(list);
                    FurnancePressureFvpVO furnancePressureFvpVO109B = this.calcRatio109B(list);
                    String msgA = this.checkRatio(furnancePressureFvpVO109A, pressure);
                    String msgB = this.checkRatio(furnancePressureFvpVO109B, pressure);
                    if ("".equals(msgA)) {
                        msg = "左侧" + msgA;
                    }
                    if ("".equals(msgB)) {
                        msg = "右侧" + msgB;
                    }
                    break;
                case "H110":
                    FurnancePressureFvpVO furnancePressureFvpVO110 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO110, pressure);
                    break;
                case "H111":
                    FurnancePressureFvpVO furnancePressureFvpVO111 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO111, pressure);
                    break;
                case "H112":
                    FurnancePressureFvpVO furnancePressureFvpVO112 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO112, pressure);
                    break;
                case "H113":
                    FurnancePressureFvpVO furnancePressureFvpVO113 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO113, pressure);
                    break;
                case "H114":
                    FurnancePressureFvpVO furnancePressureFvpVO114 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO114, pressure);
                    break;
                case "H115":
                    FurnancePressureFvpVO furnancePressureFvpVO115 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO115, pressure);
                    break;
                case "H116":
                    FurnancePressureFvpVO furnancePressureFvpVO116 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO116, pressure);
                    break;
                case "H117":
                    FurnancePressureFvpVO furnancePressureFvpVO117 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO117, pressure);
                    break;
                case "H118":
                    FurnancePressureFvpVO furnancePressureFvpVO118 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO118, pressure);
                    break;
                case "H130":
                    FurnancePressureFvpVO furnancePressureFvpVO130 = this.calcRatio130(list);
                    msg = this.checkRatio130(furnancePressureFvpVO130, pressure);
                    break;
            }
            boolean isFull = false;
            if ("H109".equals(furnanceName)) {
                isFull = StringUtils.isNotNull(pass1) && StringUtils.isNotNull(pass2) && StringUtils.isNotNull(pass3) && StringUtils.isNotNull(pass4)
                        && StringUtils.isNotNull(pass5) && StringUtils.isNotNull(pass6) && StringUtils.isNotNull(pass7) && StringUtils.isNotNull(pass8)
                        && StringUtils.isNotNull(pass9) && StringUtils.isNotNull(pass10) && StringUtils.isNotNull(pass11) && StringUtils.isNotNull(pass12)
                        && StringUtils.isNotNull(pass13) && StringUtils.isNotNull(pass14) && StringUtils.isNotNull(pass15) && StringUtils.isNotNull(pass16)
                        && !"".equals(pass1) && !"".equals(pass2) && !"".equals(pass3) && !"".equals(pass4)
                        && !"".equals(pass5) && !"".equals(pass6) && !"".equals(pass7) && !"".equals(pass8)
                        && !"".equals(pass9) && !"".equals(pass10) && !"".equals(pass11) && !"".equals(pass12)
                        && !"".equals(pass13) && !"".equals(pass14) && !"".equals(pass15) && !"".equals(pass16);
            } else if ("H130".equals(furnanceName)) {
                isFull = StringUtils.isNotNull(pass1) && StringUtils.isNotNull(pass2) && StringUtils.isNotNull(pass3) && StringUtils.isNotNull(pass4)
                        && !"".equals(pass1) && !"".equals(pass2) && !"".equals(pass3) && !"".equals(pass4);
            } else {
                isFull = StringUtils.isNotNull(pass1) && StringUtils.isNotNull(pass2) && StringUtils.isNotNull(pass3) && StringUtils.isNotNull(pass4)
                        && StringUtils.isNotNull(pass5) && StringUtils.isNotNull(pass6) && StringUtils.isNotNull(pass7) && StringUtils.isNotNull(pass8)
                        && !"".equals(pass1) && !"".equals(pass2) && !"".equals(pass3) && !"".equals(pass4)
                        && !"".equals(pass5) && !"".equals(pass6) && !"".equals(pass7) && !"".equals(pass8);
            }
            if (isFull && !"".equals(msg)) {
                msg = msg.substring(0, msg.length() - 1);
                msg += "压差<0.45或>0.9，请注意处理。";
                // 发邮件
                String mailMsg = furnanceName + "：" + msg;
                List<SysDictData> furnanceRecipientDict = iSysDictTypeService.selectDictDataByType("FURNANCE_RECIPIENT");
                for (SysDictData sysDictData : furnanceRecipientDict) {
                    String dictValue = sysDictData.getDictValue();
                    TStaffmgr staffmgr = staffmgrService.selectTStaffmgrByStaffId(dictValue);
                    SysUser sysUser = userService.selectUserByStaffId(dictValue);
                    FurnancePressureThread mailThread = new FurnancePressureThread(mailService, staffmgr, sysUser.getUserName(), mailMsg + "，");
                    Thread thread = new Thread(mailThread);
                    thread.start();
                }
                // APP推送
                String pushList = configService.selectConfigByKey("production.furnance.pushList");
                String[] staffIds = pushList.split(",");
                String[] userIds = new String[staffIds.length];
                for (int i = 0; i < staffIds.length; i++) {
                    userIds[i] = userService.selectUserByStaffId(staffIds[i]).getUserId().toString();
                }
                jiGuangPushService.send("裂解炉压差预警", mailMsg, userIds);
            }
        }
        //更新
        int result = tFurnancePressureService.updateTFurnancePressure(pressure);
        return AjaxResult.success(result + "", pressure);
    }

    /**
     * 修改裂解炉炉管测压（WEB）
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:edit')")
    @Log(title = "裂解炉炉管测压", businessType = BusinessType.UPDATE)
    @PutMapping("/editWeb")
    public AjaxResult editWeb(@RequestBody TFurnancePressure tFurnancePressure) throws PinyinException {
        // 检查数据是否包含负值或为Null
        if (!this.isNegativeOrNull(tFurnancePressure)) {
            //更新
            tFurnancePressureService.updateTFurnancePressure(tFurnancePressure);
            //计算ratio
            TFurnancePressure pressure = tFurnancePressureService.selectTFurnancePressureById(tFurnancePressure.getId());
            String furnanceName = pressure.getFurnanceName();
            List<TFurnancePressure> list = new ArrayList();
            list.add(pressure);
            String msg = "";
            switch (furnanceName) {
                case "H109":
                    FurnancePressureFvpVO furnancePressureFvpVO109A = this.calcRatio109A(list);
                    FurnancePressureFvpVO furnancePressureFvpVO109B = this.calcRatio109B(list);
                    String msgA = this.checkRatio(furnancePressureFvpVO109A, pressure);
                    String msgB = this.checkRatio(furnancePressureFvpVO109B, pressure);
                    if ("".equals(msgA)) {
                        msg = "左侧" + msgA;
                    }
                    if ("".equals(msgB)) {
                        msg = "右侧" + msgB;
                    }
                    break;
                case "H110":
                    FurnancePressureFvpVO furnancePressureFvpVO110 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO110, pressure);
                    break;
                case "H111":
                    FurnancePressureFvpVO furnancePressureFvpVO111 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO111, pressure);
                    break;
                case "H112":
                    FurnancePressureFvpVO furnancePressureFvpVO112 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO112, pressure);
                    break;
                case "H113":
                    FurnancePressureFvpVO furnancePressureFvpVO113 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO113, pressure);
                    break;
                case "H114":
                    FurnancePressureFvpVO furnancePressureFvpVO114 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO114, pressure);
                    break;
                case "H115":
                    FurnancePressureFvpVO furnancePressureFvpVO115 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO115, pressure);
                    break;
                case "H116":
                    FurnancePressureFvpVO furnancePressureFvpVO116 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO116, pressure);
                    break;
                case "H117":
                    FurnancePressureFvpVO furnancePressureFvpVO117 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO117, pressure);
                    break;
                case "H118":
                    FurnancePressureFvpVO furnancePressureFvpVO118 = this.calcRatio(list);
                    msg = this.checkRatio(furnancePressureFvpVO118, pressure);
                    break;
                case "H130":
                    FurnancePressureFvpVO furnancePressureFvpVO130 = this.calcRatio130(list);
                    msg = this.checkRatio130(furnancePressureFvpVO130, pressure);
                    break;
            }
            if (!"".equals(msg)) {
                msg = msg.substring(0, msg.length() - 1);
                msg += "压差<0.45或>0.9，请注意处理。";
                // 发邮件
                String mailMsg = furnanceName + msg;
                List<SysDictData> furnanceRecipientDict = iSysDictTypeService.selectDictDataByType("FURNANCE_RECIPIENT");
                for (SysDictData sysDictData : furnanceRecipientDict) {
                    String dictValue = sysDictData.getDictValue();
                    TStaffmgr staffmgr = staffmgrService.selectTStaffmgrByStaffId(dictValue);
                    SysUser sysUser = userService.selectUserByStaffId(dictValue);
                    FurnancePressureThread mailThread = new FurnancePressureThread(mailService, staffmgr, sysUser.getUserName(), mailMsg + "，");
                    Thread thread = new Thread(mailThread);
                    thread.start();
                }
            }
            //更新
            int result = tFurnancePressureService.updateTFurnancePressure(pressure);
            return AjaxResult.success(msg, pressure);
        } else {
            return AjaxResult.error("提交失败，数据必须>=0！");
        }
    }

    public String checkRatio(FurnancePressureFvpVO vo, TFurnancePressure pressure) {
        String msg = "";
        double pass1Ratio = vo.getPass1Ratio();
        double pass2Ratio = vo.getPass2Ratio();
        double pass3Ratio = vo.getPass3Ratio();
        double pass4Ratio = vo.getPass4Ratio();
        double pass5Ratio = vo.getPass5Ratio();
        double pass6Ratio = vo.getPass6Ratio();
        double pass7Ratio = vo.getPass7Ratio();
        double pass8Ratio = vo.getPass8Ratio();
        if (pass1Ratio > 0.9 || pass1Ratio < 0.45) {
            pressure.setPass1RatioExceeded(true);
            msg += "PASS 1、";
        } else {
            pressure.setPass1RatioExceeded(false);
        }
        if (pass2Ratio > 0.9 || pass2Ratio < 0.45) {
            pressure.setPass2RatioExceeded(true);
            msg += "PASS 2、";
        } else {
            pressure.setPass2RatioExceeded(false);
        }
        if (pass3Ratio > 0.9 || pass3Ratio < 0.45) {
            msg += "PASS 3、";
            pressure.setPass3RatioExceeded(true);
        } else {
            pressure.setPass3RatioExceeded(false);
        }
        if (pass4Ratio > 0.9 || pass4Ratio < 0.45) {
            msg += "PASS 4、";
            pressure.setPass4RatioExceeded(true);
        } else {
            pressure.setPass4RatioExceeded(false);
        }
        if (pass5Ratio > 0.9 || pass5Ratio < 0.45) {
            msg += "PASS 5、";
            pressure.setPass5RatioExceeded(true);
        } else {
            pressure.setPass5RatioExceeded(false);
        }
        if (pass6Ratio > 0.9 || pass6Ratio < 0.45) {
            msg += "PASS 6、";
            pressure.setPass6RatioExceeded(true);
        } else {
            pressure.setPass6RatioExceeded(false);
        }
        if (pass7Ratio > 0.9 || pass7Ratio < 0.45) {
            msg += "PASS 7、";
            pressure.setPass7RatioExceeded(true);
        } else {
            pressure.setPass7RatioExceeded(false);
        }
        if (pass8Ratio > 0.9 || pass8Ratio < 0.45) {
            msg += "PASS 8、";
            pressure.setPass8RatioExceeded(true);
        } else {
            pressure.setPass8RatioExceeded(false);
        }
        return msg;
    }

    public String checkRatio130(FurnancePressureFvpVO vo, TFurnancePressure pressure) {
        String msg = "";
        double pass1Ratio = vo.getPass1Ratio();
        double pass2Ratio = vo.getPass2Ratio();
        double pass3Ratio = vo.getPass3Ratio();
        double pass4Ratio = vo.getPass4Ratio();
        if (pass1Ratio > 0.9 || pass1Ratio < 0.45) {
            pressure.setPass1RatioExceeded(true);
            msg += "PASS 1、";
        } else {
            pressure.setPass1RatioExceeded(false);
        }
        if (pass2Ratio > 0.9 || pass2Ratio < 0.45) {
            pressure.setPass2RatioExceeded(true);
            msg += "PASS 2、";
        } else {
            pressure.setPass2RatioExceeded(false);
        }
        if (pass3Ratio > 0.9 || pass3Ratio < 0.45) {
            msg += "PASS 3、";
            pressure.setPass3RatioExceeded(true);
        } else {
            pressure.setPass3RatioExceeded(false);
        }
        if (pass4Ratio > 0.9 || pass4Ratio < 0.45) {
            msg += "PASS 4、";
            pressure.setPass4RatioExceeded(true);
        } else {
            pressure.setPass4RatioExceeded(false);
        }
        return msg;
    }

    /**
     * 删除裂解炉炉管测压
     */
    @PreAuthorize("@ss.hasPermi('production:pressure:remove')")
    @Log(title = "裂解炉炉管测压", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tFurnancePressureService.deleteTFurnancePressureByIds(ids));
    }
}
