package com.slibra.web.controller.business; import cn.hutool.core.date.DateUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpUtil; import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.slibra.business.domain.*; import com.slibra.business.mapper.*; import com.slibra.business.res.ChartBasic; import com.slibra.business.service.ITXinyiForecastComparisonService; import com.slibra.common.DecimalUtils; import com.slibra.common.core.domain.TXinyiDaily; import com.slibra.common.core.controller.BaseController; import com.slibra.common.enums.BusinessEnum; import com.slibra.common.utils.DateUtils; import com.slibra.common.utils.StringUtils; import com.slibra.quartz.task.AsyncTask; import com.slibra.quartz.task.RyTask; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import java.io.File; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import static com.slibra.common.constant.MyConstants.*; import static com.slibra.common.constant.MyConstants.BigDecimal_100; import static com.slibra.common.enums.BusinessEnum.WarningCategoryEnum.CS_TP_YC; /** * 参数配置 信息操作处理 * * */ @Slf4j @RestController @RequestMapping("/test") public class HandleDataController extends BaseController { @Autowired private TXinyiIndustryMapper xinyiIndustryMapper; @Autowired private TXinyiDailyMapper xinyiDailyMapper; @Autowired private TXinyiLaboratoryMapper xinyiLaboratoryMapper; @Autowired private TXinyiRobotMapper xinyiRobotMapper; @Autowired private TXinyiNormConfigMapper xinyiNormConfigMapper; @Autowired private TXinyiCalculateMapper xinyiCalculateMapper; @Autowired private TXinyiBigTableHourMapper tXinyiBigTableHourMapper; @Autowired private TXinyiBigTableDayMapper tXinyiBigTableDayMapper; @Autowired private TXinyiBigTableMonthMapper tXinyiBigTableMonthMapper; @Autowired private SqlSessionFactory sqlSessionFactory; @Autowired private RyTask ryTask; @Autowired private AsyncTask asyncTask; @Autowired private ITXinyiForecastComparisonService xinyiForecastComparisonService; public static final String[] queryTags = {"信义污水厂JS_COD_Value","信义污水厂JS_PH_Value","信义污水厂JS_SS_Value","信义污水厂JS_ZL_Value","信义污水厂JS_ZA_Value","信义污水厂JS_AD_Value","信义污水厂JS_T_Value","信义污水厂进水泵房液位","信义污水厂出水瞬时流量","信义污水厂升级出水COD","信义污水厂升级出水PH","信义污水厂升级出水SS","信义污水厂升级出水TN","信义污水厂升级出水TP","信义污水厂升级出水氨氮","信义污水厂AIT202_Value","信义污水厂AIT203_Value","信义污水厂AIT207_Value","信义污水厂AIT206_Value","信义污水厂AIT209_Value","信义污水厂AIT210_Value","信义污水厂进水TDS","信义污水厂FT101_Value","信义污水厂SWCHHYHLB1_R_Value","信义污水厂SWCHHYHLB2_R_Value","信义污水厂SWCHHYHLB3_R_Value","信义污水厂SWCHHYHLB4_R_Value","信义污水厂SWCHHYHLB5_R_Value","信义污水厂SWCHHYHLB6_R_Value","信义污水厂SWCWNHLB1_R_Value","信义污水厂SWCWNHLB2_R_Value","信义污水厂SWCWNHLB3_R_Value","信义污水厂SWCWNHLB4_R_Value","信义污水厂SWCWNHLB5_R_Value","信义污水厂GFJ1_R_Value","信义污水厂GFJ2_R_Value","信义污水厂GFJ3_R_Value","信义污水厂GFJ4_R_Value","信义污水厂GFJ5_R_Value","信义污水厂GFJ6_R_Value","信义污水厂GFJ1_KQLL_Value","信义污水厂GFJ2_KQLL_Value","信义污水厂GFJ3_KQLL_Value","信义污水厂GFJ4_KQLL_Value","信义污水厂GFJ5_KQLL_Value","信义污水厂GFJ6_KQLL_Value"}; public static final String[] predictorArr = {"出水COD", "出水SS", "出水总磷", "出水氨氮", "xsy1", "xsy2"}; /** *手动处理水质报警 */ @GetMapping("/waterWarning") public String waterWarning(){ log.info("进入了 手动触发水质报警的 操作"); //获取配置表 List tXinyiNormConfigs = this.xinyiNormConfigMapper.selectTXinyiNormConfigList(null); if(CollectionUtils.isEmpty(tXinyiNormConfigs)) throw new RuntimeException("未查询到配置信息"); TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0); TXinyiIndustry tXinyiIndustry = this.xinyiIndustryMapper.selectTXinyiIndustryNewest(); if(Objects.isNull(tXinyiIndustry)) throw new RuntimeException("未查询到工业库信息"); asyncTask.handleSZWarning(tXinyiIndustry, normConfig); return "success"; } /** *手动处理生化报警 */ @GetMapping("/shWarning") public String shWarning(){ log.info("进入了 手动处理生化报警 操作"); //获取配置表 List tXinyiNormConfigs = this.xinyiNormConfigMapper.selectTXinyiNormConfigList(null); if(CollectionUtils.isEmpty(tXinyiNormConfigs)) throw new RuntimeException("未查询到配置信息"); TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0); TXinyiIndustry tXinyiIndustry = this.xinyiIndustryMapper.selectTXinyiIndustryNewest(); if(Objects.isNull(tXinyiIndustry)) throw new RuntimeException("未查询到工业库信息"); List tXinyiCalculates = xinyiCalculateMapper.selectTXinyiCalculateList(TXinyiCalculate.builder().testHour(tXinyiIndustry.getTestHour()).build()); if (!CollectionUtils.isEmpty(tXinyiCalculates)) { TXinyiCalculate tXinyiCalculate = tXinyiCalculates.get(0); asyncTask.handleSHWarning(tXinyiIndustry, normConfig, tXinyiCalculate); } return "success"; } /** *手动处理化验室报警 */ @GetMapping("/robotWarning") public String robotWarning(){ log.info("进入了 手动触发化验室报警的 操作"); asyncTask.handleRobotWarning(this.xinyiRobotMapper.selectNRobot(1)); return "success"; } /** *手动处理预测报警 */ @GetMapping("/forecastWarning") public String forecastWarning(){ log.info("进入了 手动触发预测报警的 操作"); //获取最新的6条工业科数据 List tXinyiIndustries6 = this.xinyiIndustryMapper.selectNIndustry(INT_6); List tXinyiRobots6 = this.xinyiRobotMapper.selectNRobot(INT_6); //2024年7月18日10:31:18 加个校验,只有从来没有数据的水厂才会进入下面的判断 if(CollectionUtils.isEmpty(tXinyiIndustries6) || tXinyiIndustries6.size() < INT_6 || CollectionUtils.isEmpty(tXinyiRobots6) || tXinyiRobots6.size() req = new HashMap<>(); req.put("tagNames", queryTags); req.put("startTime", begin); req.put("endTime", end); req.put("recordNumbers", 100000); String body = HttpRequest.post(url).header("Authorization", "c2E6c2E=").header("clientName", "hongshan").body(JSON.toJSONString(req)).execute().body(); // System.out.println("body = " + body); List> list = new ArrayList<>(); //行转列数据处理 for (String queryTag : queryTags) { JSONArray array = JSON.parseObject(body).getJSONArray(queryTag); //特殊数据处理一 if(Objects.isNull(array) || array.isEmpty()){ System.out.println(queryTag + "查询到了空的数据,跳过本次循环"); continue; } int size = array.size(); //特殊数据处理二 if("0".equals(array.get(1) + "")){ System.out.println(queryTag + "查询到了数据,但是数据集合只有一条,且都是0"); continue; } //结合至少62个数据才满足条件(有可能获取不到) /*if(size < 62){ System.out.println(queryTag + "查询到了不符合条件的数据,跳过本次循环"); continue; }*/ //存放的数据集 //利用map去重 HashMap map = new LinkedHashMap<>(); for (int i = 2; i < size; i++) { // System.out.println(i + "" + array.get(i)); JSONArray oneRecord = JSON.parseArray(JSON.toJSONString(array.get(i))); //处理为空或者为0的数据 Object timeStampValue = oneRecord.get(2); if(Objects.isNull(timeStampValue) || "0".equals(timeStampValue + "")) continue; BigDecimal value = Objects.isNull(oneRecord.get(0)) ? null : new BigDecimal(oneRecord.get(0) + ""); long timestamp = (long) timeStampValue; String format = DateUtil.format(new Date(timestamp), DateUtils.YYYYMMDDHH_TS); map.put(format, queryTag + "-" + value); } list.add(map); } // System.out.println("list = " + list); //先构造对象(list中任意一个map遍历的key个数) 因为合并完并不是1分钟60条,参考上面筛选区间,有时候会有几个值获取不到 /*HashMap oneRow = list.get(0); Set set = oneRow.keySet(); List result = new ArrayList<>(set.size()); set.forEach(s -> { Industry industry = new Industry(); industry.setTestTime(s); result.add(industry); });*/ Set recordTimeSet = new HashSet<>(); Map recordMap = new HashMap<>(); for (int i = 0; i < list.size(); i++) { HashMap map = list.get(i); int finalJ = i; map.forEach((k, v) ->{ TXinyiIndustry industry = null; if(!recordTimeSet.contains(k)){//第一次 industry = new TXinyiIndustry(); recordTimeSet.add(k); recordMap.put(k, industry); }else{ industry = recordMap.get(k); } industry.setTestTime(k); //2024年4月15日11:19:52 额外增加2个字段 industry.setTestDate(k.substring(0,10)); industry.setTestHour(k.substring(0,13)); //解析值 String[] split = v.split("-"); String type = split[0]; BigDecimal value = new BigDecimal(split[1]); if ("信义污水厂JS_COD_Value".equals(type)) { industry.setJsCod(value); } else if ("信义污水厂JS_PH_Value".equals(type)) { industry.setJsPh(value); } else if ("信义污水厂JS_SS_Value".equals(type)) { industry.setJsSs(value); } else if ("信义污水厂JS_ZL_Value".equals(type)) { industry.setJsTp(value); } else if ("信义污水厂JS_ZA_Value".equals(type)) { industry.setJsTn(value); } else if ("信义污水厂JS_AD_Value".equals(type)) { industry.setJsNh3(value); } else if ("信义污水厂JS_T_Value".equals(type)) { industry.setJsSwPh(value); } else if ("信义污水厂进水泵房液位".equals(type)) { industry.setJsBfyw(value); } else if ("信义污水厂出水瞬时流量".equals(type)) { industry.setCsSlqc(value); } else if ("信义污水厂升级出水COD".equals(type)) { industry.setCsCod(value); } else if ("信义污水厂升级出水PH".equals(type)) { industry.setCsPh(value); } else if ("信义污水厂升级出水SS".equals(type)) { industry.setCsSs(value); } else if ("信义污水厂升级出水TN".equals(type)) { industry.setCsTn(value); } else if ("信义污水厂升级出水TP".equals(type)) { industry.setCsTp(value); } else if ("信义污水厂升级出水氨氮".equals(type)) { industry.setCsNh3(value); } else if ("信义污水厂AIT202_Value".equals(type)) { industry.setOneHyzdDo(value); } else if ("信义污水厂AIT203_Value".equals(type)) { industry.setOneHymdDo(value); } else if ("信义污水厂AIT207_Value".equals(type)) { industry.setTwoHyzdDo(value); } else if ("信义污水厂AIT206_Value".equals(type)) { industry.setTwoHymdDo(value); } else if ("信义污水厂AIT209_Value".equals(type)) { industry.setOneMlss(value); } else if ("信义污水厂AIT210_Value".equals(type)) { industry.setTwoMlss(value); } else if ("信义污水厂进水TDS".equals(type)) { industry.setJsTds(value); } else if ("信义污水厂FT101_Value".equals(type)) { industry.setJsSlq(value); } else if ("信义污水厂SWCHHYHLB1_R_Value".equals(type)) { industry.setNHlbOneGp(value); } else if ("信义污水厂SWCHHYHLB2_R_Value".equals(type)) { industry.setNHlbTwoGp(value); } else if ("信义污水厂SWCHHYHLB3_R_Value".equals(type)) { industry.setNHlbThreeGp(value); } else if ("信义污水厂SWCHHYHLB4_R_Value".equals(type)) { industry.setNHlbFourGp(value); } else if ("信义污水厂SWCHHYHLB5_R_Value".equals(type)) { industry.setNhlBFiveGp(value); } else if ("信义污水厂SWCHHYHLB6_R_Value".equals(type)) { industry.setNHlbSixGp(value); } else if ("信义污水厂SWCWNHLB1_R_Value".equals(type)) { industry.setWHlbOneGp(value); } else if ("信义污水厂SWCWNHLB2_R_Value".equals(type)) { industry.setWHlbTwoGp(value); } else if ("信义污水厂SWCWNHLB3_R_Value".equals(type)) { industry.setWHlbThreeGp(value); } else if ("信义污水厂SWCWNHLB4_R_Value".equals(type)) { industry.setWHlbFourGp(value); } else if ("信义污水厂SWCWNHLB5_R_Value".equals(type)) { industry.setWHlbFiveGp(value); } else if ("信义污水厂GFJ1_R_Value".equals(type)) { industry.setFjOne(value); } else if ("信义污水厂GFJ2_R_Value".equals(type)) { industry.setFjTwo(value); } else if ("信义污水厂GFJ3_R_Value".equals(type)) { industry.setFjThree(value); } else if ("信义污水厂GFJ4_R_Value".equals(type)) { industry.setFjFour(value); } else if ("信义污水厂GFJ5_R_Value".equals(type)) { industry.setFjFive(value); } else if ("信义污水厂GFJ6_R_Value".equals(type)) { industry.setFjSix(value); } else if ("信义污水厂GFJ1_KQLL_Value".equals(type)) { industry.setKqllOne(value); } else if ("信义污水厂GFJ2_KQLL_Value".equals(type)) { industry.setKqllTwo(value); } else if ("信义污水厂GFJ3_KQLL_Value".equals(type)) { industry.setKqllThree(value); } else if ("信义污水厂GFJ4_KQLL_Value".equals(type)) { industry.setKqllFour(value); } else if ("信义污水厂GFJ5_KQLL_Value".equals(type)) { industry.setKqllFive(value); } else if ("信义污水厂GFJ6_KQLL_Value".equals(type)) { industry.setKqllSix(value); }else if ("信义污水厂实际碳源加药量".equals(type)) { industry.setSJTYJLY(value); }else if ("信义污水厂除磷加药瞬时流量".equals(type)) { industry.setCLJYSSLL(value); } //只有最后一次才执行数据库添加 if(finalJ == list.size()-1){ //插入数据库 xinyiIndustryMapper.insertTXinyiIndustry(industry); } }); } } return "ok"; } // @GetMapping("/dateUpdateCL") // public String dateUpdateCL() { // String fileName = "除磷加药瞬时流量"; // //输入目录 // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls"); // //解析数据 // List> readAll = reader.read(); // if(!CollectionUtils.isEmpty(readAll)){ // for (List objects : readAll) { // String time = "20" + objects.get(0) + " " + objects.get(1).toString().substring(0, 5); // System.out.println("time = " + time); // TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(time); // if(!Objects.isNull(uniqueTXinyiIndustry)){ // System.out.println(objects.get(2)); // BigDecimal CLJYSSLL = Objects.isNull(objects.get(2)) ? null : new BigDecimal(String.valueOf(objects.get(2))); // uniqueTXinyiIndustry.setCLJYSSLL(CLJYSSLL); // this.xinyiIndustryMapper.updateTXinyiIndustry(uniqueTXinyiIndustry); // } // } // } // return "ok"; // } // // // @GetMapping("/dateUpdateSJTY") // public String dateUpdateSJTY() { // String fileName = "信义污水厂实际碳源加药量"; // //输入目录 // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls"); // //解析数据 // List> readAll = reader.read(); // if(!CollectionUtils.isEmpty(readAll)){ // int i = 0; // for (List objects : readAll) { // String format = ""; // if(objects.get(0) instanceof String){ // System.out.println("----------是字符串类型的"); // String time = ((String) objects.get(0)); // System.out.println("time = " + time); // format = time.replaceAll("-", "/").substring(0, 16); // }else if (objects.get(0) instanceof cn.hutool.core.date.DateTime){ // System.out.println("++++++++++是日期类型的"); // cn.hutool.core.date.DateTime time = (DateTime) objects.get(0); // System.out.println("time = " + time); // format = DateUtil.format(time, DateUtils.YYYYMMDDHHMM_TS); // System.out.println("format = " + format); // }else { // System.out.println(JSON.toJSONString(objects)); // format = ""; // i++; // } // TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(format); // if(!Objects.isNull(uniqueTXinyiIndustry)){ // BigDecimal SJTYJLY = Objects.isNull(objects.get(1)) ? null : new BigDecimal(String.valueOf(objects.get(1))); // uniqueTXinyiIndustry.setSJTYJLY(SJTYJLY); // this.xinyiIndustryMapper.updateTXinyiIndustry(uniqueTXinyiIndustry); // } // } // System.out.println("i =" + i); // } // return "ok"; // } // // //下面是新的 将一个小时的数据 更新到一个小时之内的所有的数据中 // @GetMapping("/dateUpdateCLMinute") // public String dateUpdateCLMinute() { // String fileName = "除磷加药瞬时流量"; // //输入目录 // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls"); // //解析数据 // List> readAll = reader.read(); // int i = 0; // if(!CollectionUtils.isEmpty(readAll)){ // for (List objects : readAll) { // if(!Objects.isNull(objects.get(0)) && !Objects.isNull(objects.get(1))){ // String beginTime = "20" + objects.get(0) + " " + objects.get(1).toString().substring(0, 5); // System.out.println("beginTime = " + beginTime); // String endTime = "20" + objects.get(0) + " " + objects.get(1).toString().substring(0, 3) + "59"; // System.out.println("endTime = " + endTime); // //更新数据 // System.out.println(objects.get(2)); // //有特殊情况 // if(Objects.isNull(objects.get(2)) || objects.get(2).toString().contains("-")){ // System.out.println("存在特殊的情况,值包含-,不做更新"); // i++; // }else{ // this.xinyiIndustryMapper.updateTXinyiIndustryCLByBetweenTime(beginTime, endTime, new BigDecimal(String.valueOf(objects.get(2)))); // } // } // } // } // System.out.println("i = " + i); // return "ok"; // } // // // @GetMapping("/dateUpdateSJTYMinute") // public String dateUpdateSJTYMinute() { // String fileName = "信义污水厂实际碳源加药量"; // //输入目录 // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls"); // //解析数据 // List> readAll = reader.read(); // if(!CollectionUtils.isEmpty(readAll)){ // int i = 0; // for (List objects : readAll) { // String beginTime = ""; // if(objects.get(0) instanceof String){ // System.out.println("----------是字符串类型的"); // String time = ((String) objects.get(0)); //// System.out.println("time = " + time); // beginTime = time.replaceAll("-", "/").substring(0, 16); // }else if (objects.get(0) instanceof cn.hutool.core.date.DateTime){ // System.out.println("++++++++++是日期类型的"); // cn.hutool.core.date.DateTime time = (DateTime) objects.get(0); //// System.out.println("time = " + time); // beginTime = DateUtil.format(time, DateUtils.YYYYMMDDHHMM_TS); // System.out.println("beginTime = " + beginTime); // }else { // System.out.println(JSON.toJSONString(objects)); // beginTime = ""; // i++; // } // //endTime // String endTime = beginTime.substring(0, 14) + "59"; // System.out.println("endTime = " + endTime); // //更新数据 // BigDecimal sjtyjly = Objects.isNull(objects.get(1)) ? null : new BigDecimal(String.valueOf(objects.get(1))); // this.xinyiIndustryMapper.updateTXinyiIndustrySJByBetweenTime(beginTime, endTime, sjtyjly); // } // System.out.println("i =" + i); // } // return "ok"; // } // @GetMapping("/dateUpdateSJTYMinute") // public String dateUpdateSJTYMinute() { // log.info("进入了手动处理两个值的操作~~~~~~~~"); // File file = new File("/home/slibra/历史数据"); // if(file.isDirectory()){ // for (File listFile : file.listFiles()) { // // 输入目录 // ExcelReader reader = ExcelUtil.getReader(listFile); // List> readAll = reader.read(); // if(!CollectionUtils.isEmpty(readAll)){ // for (int i = 3; i < readAll.size(); i++) { // //解析数据 // List objects = readAll.get(i); // String time = "20" + objects.get(0).toString().replaceAll(" ", "") + " " + objects.get(1).toString().replaceAll(" ", "").substring(0, 5); //// System.out.println("time = " + time); // TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(time); // if(!Objects.isNull(uniqueTXinyiIndustry)){ // TXinyiIndustry updateBean = new TXinyiIndustry(); // updateBean.setID(uniqueTXinyiIndustry.getID()); // BigDecimal CLJYSSLL = Objects.isNull(objects.get(2)) || String.valueOf(objects.get(2)).contains("-") ? null : new BigDecimal(String.valueOf(objects.get(2))); // updateBean.setCLJYSSLL(CLJYSSLL); // BigDecimal SJTYJLY = Objects.isNull(objects.get(3)) || String.valueOf(objects.get(3)).contains("-") ? null : new BigDecimal(String.valueOf(objects.get(3))); // updateBean.setSJTYJLY(SJTYJLY); // //如果两个都不为空再更新 // if(!Objects.isNull(CLJYSSLL) || !Objects.isNull(SJTYJLY)){ // this.xinyiIndustryMapper.updateTXinyiIndustry(updateBean); // }else{ // log.error("要更新的两个字段全部为空--------"); // } // } // } // } // } // } // return "ok"; // } /** * * 从Excel读取数据 将新增的列数据更新到新的日报字段中 * @return */ @GetMapping("/dailyAddDataByExcel") public String dailyAddDataByExcel() { log.info("从Excel读取数据 将新增的列数据更新到新的日报字段中~~~~~~~~"); File file = new File("/home/slibra/绝干泥量.xlsx"); // File file = new File("C:\\Users\\10109\\Documents\\WeChat Files\\mz1010995810\\FileStorage\\File\\2024-05\\绝干泥量.xlsx"); // 输入目录 ExcelReader reader = ExcelUtil.getReader(file); List> readAll = reader.read(); // log.info("Excel解析的结果为{}", JSON.toJSONString(readAll)); if(!CollectionUtils.isEmpty(readAll)){ for (int i = 1; i < readAll.size(); i++) { //解析数据 List objects = readAll.get(i); String date = (String) objects.get(0); date = date.replaceAll("\\.", "/"); date = handleDate(date); //用时间去查询 如果存在就更新,否则跳过 List tXinyiDailies = this.xinyiDailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(date).build()); if(CollectionUtils.isEmpty(tXinyiDailies)){ log.error("没有查询到对应的历史数据,跳过~~~~~~{}", date); continue; } //目前集合就一个对象 以后可能会多个 TXinyiDaily tXinyiDaily = tXinyiDailies.get(0); //出泥量 Object o1 = objects.get(1); BigDecimal CHUNILIANG = null; if(o1 instanceof String){ log.error("数据异常,解析为null"); CHUNILIANG = null; }else if(o1 instanceof Double){ CHUNILIANG = new BigDecimal((Double) o1); }else { log.error("错误的类型,不用解析了"); CHUNILIANG = null; } //出泥含水率 BigDecimal CNHSL = null; Object o2 = objects.get(2); if(o2 instanceof String){ log.error("数据异常,解析为null"); CNHSL = null; }else if(o2 instanceof Double){ CNHSL = new BigDecimal((Double) o2); }else { log.error("错误的类型,不用解析了"); CNHSL = null; } //干污泥量 Object o3 = objects.get(3); BigDecimal GWNL = null; if(o3 instanceof String){ log.error("数据异常,解析为null"); GWNL = null; }else if(o3 instanceof Double){ GWNL = new BigDecimal((Double) o3); }else { log.error("错误的类型,不用解析了"); GWNL = null; } //更新数据 tXinyiDaily.setCHUNILIANG(CHUNILIANG); tXinyiDaily.setCNHSL(CNHSL); tXinyiDaily.setGWNL(GWNL); this.xinyiDailyMapper.updateTXinyiDaily(tXinyiDaily); } } return "ok"; } /** * 手动处理日报数据 增加两个字段 时间和小时 * @return */ @GetMapping("/dateUpdateDaily") public String dateUpdateDaily() { //获取全部数据 List tXinyiDailies = this.xinyiDailyMapper.selectTXinyiDailyList(null); if(!CollectionUtils.isEmpty(tXinyiDailies)){ for (TXinyiDaily tXinyiDaily : tXinyiDailies) { String handleTime = handleDate(tXinyiDaily.getTestTime()); tXinyiDaily.setTestTime(handleTime); tXinyiDaily.setTestDate(handleTime); //更新 this.xinyiDailyMapper.updateTXinyiDaily(tXinyiDaily); } } return "ok"; } /** * 手动处理化验数据 增加两个字段 时间和小时 * @return */ @GetMapping("/dateUpdateHuaYan") public String dateUpdateHuaYan() { //获取全部数据 List tXinyiLaboratories = this.xinyiLaboratoryMapper.selectTXinyiLaboratoryList(null); if(!CollectionUtils.isEmpty(tXinyiLaboratories)){ for (TXinyiLaboratory tXinyiLaboratory : tXinyiLaboratories) { String handleTime = handleDate(tXinyiLaboratory.getTestTime()); tXinyiLaboratory.setTestTime(handleTime);//到分为止 tXinyiLaboratory.setTestDate(handleTime.substring(0, 10)); tXinyiLaboratory.setTestHour(handleTime.substring(0, 13)); //更新 this.xinyiLaboratoryMapper.updateTXinyiLaboratory(tXinyiLaboratory); } } return "ok"; } /** * 手动处理 工业库的 某个值,将历史数据全部都更新 * @return */ @GetMapping("/updateGYKSomeFields") public String updateGYKSomeFields() { //更新的某个指标 String[] queryTags = {"信义污水厂_除磷P04预测值_"}; //找到对应的数据,然后更新它 // 给定时间段的起始时间和结束时间 LocalDateTime startTime = LocalDateTime.parse("2022-07-01T00:00:00"); LocalDateTime endTime = LocalDateTime.parse("2024-04-25T09:00:01"); // 每个小时的时间格式 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // 循环按小时分割 LocalDateTime currentHour = startTime; while (currentHour.isBefore(endTime)) { String begin = currentHour.format(formatter); String end = currentHour.plusDays(1).format(formatter); // 输出当前小时的起始时间和结束时间 System.out.println("起始时间:" + begin); System.out.println("结束时间:" + end); // 当前小时加一小时,作为下一个小时的起始时间 currentHour = currentHour.plusDays(1); //每个小时查询一次数据 String url = "http://10.0.0.27:4568/api/v1/khquerydata"; HashMap req = new HashMap<>(); req.put("tagNames", queryTags); req.put("startTime", begin); req.put("endTime", end); req.put("recordNumbers", 100000); String body = HttpRequest.post(url).header("Authorization", "c2E6c2E=").header("clientName", "hongshan").body(JSON.toJSONString(req)).execute().body(); // System.out.println("body = " + body); List> list = new ArrayList<>(); //行转列数据处理 for (String queryTag : queryTags) { JSONArray array = JSON.parseObject(body).getJSONArray(queryTag); //特殊数据处理一 if(Objects.isNull(array) || array.isEmpty()){ System.out.println(queryTag + "查询到了空的数据,跳过本次循环"); continue; } int size = array.size(); //特殊数据处理二 if("0".equals(array.get(1) + "")){ System.out.println(queryTag + "查询到了数据,但是数据集合只有一条,且都是0"); continue; } //存放的数据集 //利用map去重 HashMap map = new LinkedHashMap<>(); for (int i = 2; i < size; i++) { // System.out.println(i + "" + array.get(i)); JSONArray oneRecord = JSON.parseArray(JSON.toJSONString(array.get(i))); //处理为空或者为0的数据 Object timeStampValue = oneRecord.get(2); if(Objects.isNull(timeStampValue) || "0".equals(timeStampValue + "")) continue; BigDecimal value = Objects.isNull(oneRecord.get(0)) ? null : new BigDecimal(oneRecord.get(0) + ""); long timestamp = (long) timeStampValue; String format = DateUtil.format(new Date(timestamp), DateUtils.YYYYMMDDHH_TS); map.put(format, queryTag + "-" + value); } list.add(map); } Set recordTimeSet = new HashSet<>(); Map recordMap = new HashMap<>(); for (int i = 0; i < list.size(); i++) { HashMap map = list.get(i); int finalJ = i; map.forEach((k, v) ->{ TXinyiIndustry industry = null; if(!recordTimeSet.contains(k)){//第一次 industry = new TXinyiIndustry(); recordTimeSet.add(k); recordMap.put(k, industry); }else{ industry = recordMap.get(k); } industry.setTestTime(k); //解析值 String[] split = v.split("-"); String type = split[0]; BigDecimal value = new BigDecimal(split[1]); if ("信义污水厂_除磷P04预测值_".equals(type)) { industry.setCLP04YCZ(value);//目前值更新此字段 } /*else if ("信义污水厂除磷加药瞬时流量".equals(type)) { industry.setCLJYSSLL(value); }*/ //只有最后一次才执行数据库添加 if(finalJ == list.size()-1){ //先去查询数据库 TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(industry.getTestTime()); if(Objects.isNull(uniqueTXinyiIndustry)) log.error("查询到的工业库数据为null,化验时间为{}", industry.getTestTime()); else { //防止其他信息被更新,新建对象 TXinyiIndustry updateTXinyiIndustry = new TXinyiIndustry(); //赋值 updateTXinyiIndustry.setID(uniqueTXinyiIndustry.getID()); updateTXinyiIndustry.setCLP04YCZ(industry.getCLP04YCZ()); //更新数据库 xinyiIndustryMapper.updateTXinyiIndustry(updateTXinyiIndustry); } } }); } } return "ok"; } /** * 手动处理 计算相关的数据,处理历史数据 * @return */ @GetMapping("/handleCalculateHistoryDates") public String handleCalculateHistoryDates() { log.info("进入了 手动处理-重置计算表历史数据"); long begin = System.currentTimeMillis(); List tXinyiNormConfigs = xinyiNormConfigMapper.selectTXinyiNormConfigList(null); if(CollectionUtils.isEmpty(tXinyiNormConfigs)) { log.error( "未查询到配置信息"); return null; } TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0); int size = 500; int count = xinyiIndustryMapper.getCount(); int num = ( count / size ) + 1; for (int i = 0; i < num; i++) { List tXinyiIndustries = xinyiIndustryMapper.selectTXinyiIndustryListByPage(i * size, size); List tempInsertData = new ArrayList<>(); if (!CollectionUtils.isEmpty( tXinyiIndustries )) { for (int j = 0; j < tXinyiIndustries.size(); j++) { TXinyiIndustry tXinyiIndustry = tXinyiIndustries.get(j); //获取的一些配置信息 BigDecimal nhlbqdsl = normConfig.getNHLBQDSL(); BigDecimal nhlbdsjll = normConfig.getNHLBDSJLL(); BigDecimal nhlbgzxl = normConfig.getNHLBGZXL(); BigDecimal whlbqdsl = normConfig.getWHLBQDSL(); BigDecimal whlbdsjll = normConfig.getWHLBDSJLL(); BigDecimal whlbgzxl = normConfig.getWHLBGZXL(); BigDecimal gfjgzts = normConfig.getGFJGZTS(); BigDecimal gfjckll = normConfig.getGFJCKLL(); BigDecimal fcxbsjll = normConfig.getFCXBSJLL(); BigDecimal fclbsl = normConfig.getFCLBSL(); BigDecimal fcxbgzxl = normConfig.getFCXBGZXL(); //结算结果 TXinyiCalculate tXinyiCalculate = new TXinyiCalculate(); //时间相关 tXinyiCalculate.setTestDate(tXinyiIndustry.getTestDate()); tXinyiCalculate.setTestHour(tXinyiIndustry.getTestHour()); tXinyiCalculate.setTestTime(tXinyiIndustry.getTestTime()); //获取最新的一条日报信息 TXinyiDaily tXinyiDaily = this.xinyiDailyMapper.getDetailByDay(tXinyiIndustry.getTestDate()); if(Objects.isNull(tXinyiDaily)){ //理论不会出现 log.error("没有日报数据,取最新的"); tXinyiDaily = this.xinyiDailyMapper.selectNewestData(); } BigDecimal jsBod5 = tXinyiDaily.getJsBod5(); BigDecimal csBod5 = tXinyiDaily.getCsBod5(); BigDecimal whlR = tXinyiDaily.getWhlR(); BigDecimal oneMlvss = tXinyiDaily.getShcHyOneMlvss(); BigDecimal twoMlvss = tXinyiDaily.getShcHyTwoMlvss(); BigDecimal avgMlvss = null; if(!Objects.isNull(oneMlvss) && !Objects.isNull(twoMlvss)) avgMlvss = ((oneMlvss.add(twoMlvss)).divide(new BigDecimal(2),4, RoundingMode.HALF_UP)); BigDecimal oneMlss = tXinyiDaily.getShcHyOneMlss(); BigDecimal twoMlss = tXinyiDaily.getShcHyTwoMlss(); BigDecimal avgMlss = null; if(!Objects.isNull(oneMlss) && !Objects.isNull(twoMlss)) avgMlss = ((oneMlss.add(twoMlss)).divide(new BigDecimal(NUMBER_2),NUMBER_SCALE_4, RoundingMode.HALF_UP)); //工业库的指标 BigDecimal jsTn = tXinyiIndustry.getJsTn(); BigDecimal jsTp = tXinyiIndustry.getJsTp(); BigDecimal jsCod = tXinyiIndustry.getJsCod(); BigDecimal jsSlq = tXinyiIndustry.getJsSlq(); //计算 if(!Objects.isNull(jsBod5)){ if(!Objects.isNull(jsTn) && jsTn.compareTo(BigDecimal.ZERO) > 0) tXinyiCalculate.setJsTdb(jsBod5.divide(jsTn, NUMBER_SCALE_4, RoundingMode.HALF_UP)); if(!Objects.isNull(jsTp) && jsTp.compareTo(BigDecimal.ZERO) > 0) tXinyiCalculate.setJsTlb(jsBod5.divide(jsTp, NUMBER_SCALE_4, RoundingMode.HALF_UP)); if(!Objects.isNull(jsCod) && jsCod.compareTo(BigDecimal.ZERO) > 0) tXinyiCalculate.setJsBodBCod(jsBod5.divide(jsCod, NUMBER_SCALE_4, RoundingMode.HALF_UP)); if(!Objects.isNull(csBod5) && !Objects.isNull(avgMlss) && avgMlss.compareTo(BigDecimal.ZERO) > 0 && !Objects.isNull(jsSlq) && jsSlq.compareTo(BigDecimal.ZERO) > 0) tXinyiCalculate.setFM(new BigDecimal(ONE_DAY_HOURS).multiply((jsBod5.subtract(csBod5))).multiply(jsSlq).divide(avgMlss, NUMBER_SCALE_4, RoundingMode.HALF_UP).divide(new BigDecimal(F_M_LAST), NUMBER_SCALE_4, RoundingMode.HALF_UP)); } if(!Objects.isNull(avgMlss) && avgMlss.compareTo(BigDecimal.ZERO) > 0 && !Objects.isNull(avgMlvss) && avgMlvss.compareTo(BigDecimal.ZERO) > 0) tXinyiCalculate.setHFXWNNDZB(avgMlvss.divide(avgMlss, NUMBER_SCALE_4, RoundingMode.HALF_UP)); if(!Objects.isNull(jsSlq) && jsSlq.compareTo(BigDecimal.ZERO) > 0){ tXinyiCalculate.setYyqHrt(new BigDecimal(YYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setQyqHrt(new BigDecimal(QYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setHyqHrt(new BigDecimal(HYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); // tXinyiCalculate.setGSLS(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(NUMBER_4)).divide((new BigDecimal(Math.PI).multiply(new BigDecimal(NUMBER_0_0_0_3)).multiply(new BigDecimal(NUMBER_0_0_0_3)).multiply(new BigDecimal(NUMBER_4)).multiply(new BigDecimal(NUMBER_4)).multiply(new BigDecimal(NUMBER_97119))) , NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setGSLS(jsSlq.divide(GSLS_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setGslsOne(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.sin(Math.toRadians(DOUBLE_75))))).divide(GSLSONE_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setGslsTwo(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.sin(Math.toRadians(DOUBLE_75))))).divide(GSLSTWO_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setXgsGsls(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(NUMBER_4)).divide((GSLS_XGS_LAST) , NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setXlcscBmfh(jsSlq.divide(XLCSCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setXlcscHrt(XLCSCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setCccdcBmfh(jsSlq.divide(CCCDCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setCccdcHrt(CCCDCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setEccBmfh(jsSlq.divide(ECCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setEccHrt(ECCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); //2024年7月1日17:16:16 计算逻辑调整 if(!Objects.isNull(whlR) && avgMlss != null && jsSlq != null) { tXinyiCalculate.setEccGtfh((new BigDecimal(1).add(whlR.divide(BigDecimal_100, NUMBER_SCALE_4, RoundingMode.HALF_UP))).multiply(jsSlq).multiply(new BigDecimal(NUMBER_24)).multiply(avgMlss).divide(ECCGTFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP)); } tXinyiCalculate.setClsnJcsj(CLSNJCSJ_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); tXinyiCalculate.setXgcdcQsqSsls(jsSlq.multiply(XGCDCQSQSSLS_LAST)); //2024年6月29日15:18:01 增加几个新的计算指标 if(!Objects.isNull(nhlbqdsl) && !Objects.isNull(nhlbdsjll) && !Objects.isNull(nhlbgzxl)) tXinyiCalculate.setNHLB(nhlbqdsl.multiply(nhlbdsjll).multiply(nhlbgzxl).multiply(BigDecimal_100).divide(jsSlq, 4, RoundingMode.HALF_UP)); if(!Objects.isNull(whlbqdsl) && !Objects.isNull(whlbdsjll) && !Objects.isNull(whlbgzxl)) tXinyiCalculate.setWHLB(whlbqdsl.multiply(whlbdsjll).multiply(whlbgzxl).multiply(BigDecimal_100).divide(jsSlq, 4, RoundingMode.HALF_UP)); if(!Objects.isNull(gfjgzts) && !Objects.isNull(gfjckll)) tXinyiCalculate.setQSB(gfjgzts.multiply(gfjckll).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP)); if(!Objects.isNull(fcxbsjll) && !Objects.isNull(fclbsl) && !Objects.isNull(fcxbgzxl)){ BigDecimal fcxsl = fcxbsjll.multiply(fclbsl).multiply(fcxbgzxl); tXinyiCalculate.setFCXSL(fcxsl); //2024年7月3日10:54:28 额外再增加一个字段 tXinyiCalculate.setFCXSLBL(fcxsl.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100)); } //2024年7月11日15:43:47 之前给的外回流比计算不准确,额外一个字段记录新的外回流比 BigDecimal divide = jsSlq.divide(DECIMAL_2, NUMBER_SCALE_4, RoundingMode.HALF_UP); if(divide.compareTo(DECIMAL_1500) < 0) tXinyiCalculate.setWhlRN(DECIMAL_1200.divide(divide, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100)); else tXinyiCalculate.setWhlRN(DECIMAL_1620.divide(divide, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100)); } tempInsertData.add(tXinyiCalculate); xinyiCalculateMapper.insertTXinyiCalculate(tXinyiCalculate); } // xinyiCalculateMapper.insertBatchData(tempInsertData); // return tXinyiCalculate; } } long end = System.currentTimeMillis(); return "ok;耗时:" + (end - begin) /1000 + "秒。"; } public void main(String[] args) { // handleBigTableDayHistoryData(); // HandleDataController handleDataController = new HandleDataController(); // // handleDataController.handleBigTableDayHistoryData(); // File file = new File("C:\\Users\\10109\\Desktop\\新程序\\历史数据"); // if(file.isDirectory()){ // for (File listFile : file.listFiles()) { //// System.out.println(listFile.getName()); // ExcelReader reader = ExcelUtil.getReader(listFile); // List> readAll = reader.read(); // for (int i = 3; i < 10; i++) { // System.out.println(readAll.get(i)); // } // System.out.println("------------------"); // } // } String str = "2022/07/11 19:00"; // String str = "2022/7/1"; // String str = "0:0:1"; // String newStr = handleDate(str); // System.out.println(newStr); // System.out.println(str.substring(0, 12)); // System.out.println(str.substring(0, 9)); // System.out.println(handleDate("2024-3-9")); System.out.println(handleDate("2023/12/26 02:00")); System.out.println(handleDate("2023/12/26 02:00").substring(0, 10)); System.out.println(handleDate("2023/12/26 02:00").substring(0, 13)); } public static String handleDate(String str){ StringBuilder sb = new StringBuilder(); if(str.contains(" ")){//包含空格 就是年月日时分秒了 String[] split = str.split(" "); addBeforeZero(sb, split[0], "/"); sb.append(" "); addBeforeZero(sb, split[1], ":"); }else{ if(str.contains("/")){//年月日 addBeforeZero(sb, str, "/"); }else if(str.contains(":")){//时分秒 addBeforeZero(sb, str, ":"); }else if(str.contains("-")){//只有年月日 addBeforeZero(sb, str, "-"); }else { sb.append(str); } } return sb.toString(); } public static StringBuilder addBeforeZero(StringBuilder sb, String str, String tag){ String[] split = str.split(tag); int length = split.length; for (int i = 0; i < length; i++) { String value = split[i]; Integer intValue = Integer.parseInt(value); if(intValue < 10 && value.length() == 1){////防止有正确的情况 额外再补充字符串 sb.append(0).append(value); }else{ sb.append(value); } if(i < length-1){ sb.append(tag); } } return sb; } public BigDecimal getListAvg (Collection bigDecimals) { if (bigDecimals.isEmpty()) { return null; } BigDecimal sum = bigDecimals.stream() .reduce(BigDecimal.ZERO, BigDecimal::add); int size = bigDecimals.size(); return sum.divide(new BigDecimal(size), 6, RoundingMode.HALF_UP); } public String formatList(List list) { if (CollectionUtils.isEmpty(list)) { return null; } boolean isNullList = list.stream().allMatch(x -> x == null); return isNullList ? null : list.toString(); } /** * 处理big_table_month历史数据 * @return */ @GetMapping("/handleBigTableMonthHistoryData") public String handleBigTableMonthHistoryData() { log.info("进入了处理big_table_month历史数据"); long begin = System.currentTimeMillis(); List tXinyiBigTableDayList = tXinyiBigTableDayMapper.selectTXinyiBigTableDayByMonthAvg(); if ( !CollectionUtils.isEmpty(tXinyiBigTableDayList) ) { for (int i = 0; i < tXinyiBigTableDayList.size(); i++) { TXinyiBigTableMonth tableMonth = tXinyiBigTableDayList.get(i); ArrayList gyHycRjyAll = new ArrayList<>(); ArrayList gyHycRjyZdAll = new ArrayList<>(); ArrayList gyHycWnndAll = new ArrayList<>(); ArrayList rbHycRjyAll = new ArrayList<>(); ArrayList rbHycWnndAll = new ArrayList<>(); ArrayList rbYycRjyAll = new ArrayList<>(); ArrayList rbQycRjyAll = new ArrayList<>(); ArrayList rbWncjbAll = new ArrayList<>(); ArrayList rbWntjzsAll = new ArrayList<>(); ArrayList rbHfxwnndAll = new ArrayList<>(); ArrayList hyHycxsyAll = new ArrayList<>(); ArrayList hyQyanAll = new ArrayList<>(); ArrayList hyQyckxsyAll = new ArrayList<>(); ArrayList hyHyzlsyAll = new ArrayList<>(); gyHycRjyAll.add(tableMonth.getGyOneHymdDo()); gyHycRjyAll.add(tableMonth.getGyTwoHymdDo()); gyHycRjyZdAll.add(tableMonth.getGyOneHyzdDo()); gyHycRjyZdAll.add(tableMonth.getGyTwoHyzdDo()); gyHycWnndAll.add(tableMonth.getGyOneMlss()); gyHycWnndAll.add(tableMonth.getGyTwoMlss()); rbHycRjyAll.add(tableMonth.getRbShcHyOneDo()); rbHycRjyAll.add(tableMonth.getRbShcHyTwoDo()); rbHycWnndAll.add(tableMonth.getRbShcHyOneMlss()); rbHycWnndAll.add(tableMonth.getRbShcHyTwoMlss()); rbYycRjyAll.add(tableMonth.getRbShcYyOneDo()); rbYycRjyAll.add(tableMonth.getRbShcYyTwoDo()); rbQycRjyAll.add(tableMonth.getRbShcQyOneDo()); rbQycRjyAll.add(tableMonth.getRbShcQyTwoDo()); rbWncjbAll.add(tableMonth.getRbShcHyOneSv()); rbWncjbAll.add(tableMonth.getRbShcHyTwoSv()); rbWntjzsAll.add(tableMonth.getRbShcHyOneSvi()); rbWntjzsAll.add(tableMonth.getRbShcHyTwoSvi()); rbHfxwnndAll.add(tableMonth.getRbShcHyOneMlvss()); rbHfxwnndAll.add(tableMonth.getRbShcHyTwoMlvss()); hyHycxsyAll.add(tableMonth.getHyNo3Hlj1Jqr()); hyHycxsyAll.add(tableMonth.getHyNo3Hlj2Jqr()); hyQyanAll.add(tableMonth.getHyNh31Jqr()); hyQyanAll.add(tableMonth.getHyNh32Jqr()); hyQyckxsyAll.add(tableMonth.getHyNo3Qyc1Jqr()); hyQyckxsyAll.add(tableMonth.getHyNo3Qyc2Jqr()); hyHyzlsyAll.add(tableMonth.getHyTpHl1Jqr()); hyHyzlsyAll.add(tableMonth.getHyTpHl2Jqr()); tableMonth.setGyHycRjyAll(formatList(gyHycRjyAll)); tableMonth.setGyHycRjyZdAll(formatList(gyHycRjyZdAll)); tableMonth.setGyHycWnndAll(formatList(gyHycWnndAll)); tableMonth.setRbHycRjyAll(formatList(rbHycRjyAll)); tableMonth.setRbHycWnndAll(formatList(rbHycWnndAll)); tableMonth.setRbYycRjyAll(formatList(rbYycRjyAll)); tableMonth.setRbQycRjyAll(formatList(rbQycRjyAll)); tableMonth.setRbWncjbAll(formatList(rbWncjbAll)); tableMonth.setRbWntjzsAll(formatList(rbWntjzsAll)); tableMonth.setRbHfxwnndAll(formatList(rbHfxwnndAll)); tableMonth.setHyHycxsyAll(formatList(hyHycxsyAll)); tableMonth.setHyQyanAll(formatList(hyQyanAll)); tableMonth.setHyQyckxsyAll(formatList(hyQyckxsyAll)); tableMonth.setHyHyzlsyAll(formatList(hyHyzlsyAll)); tXinyiBigTableMonthMapper.insertTXinyiBigTableMonth(tableMonth); } } long end = System.currentTimeMillis(); return "ok;耗时:" + (end - begin) / 1000 + "秒。"; } /** * 处理big_table_day历史数据 * @return */ @GetMapping("/handleBigTableDayHistoryData") public String handleBigTableDayHistoryData() { log.info("进入了 处理big_table_day历史数据"); long begin = System.currentTimeMillis(); List tXinyiBigTableHours = tXinyiBigTableHourMapper.selectTXinyiBigTableHourByTestDate(); if ( !CollectionUtils.isEmpty(tXinyiBigTableHours) ) { List bigTableDayList = new ArrayList<>(); for (int i = 0; i < tXinyiBigTableHours.size(); i++) { TXinyiBigTableHour tXinyiBigTableHour = tXinyiBigTableHours.get(i); String testDate = tXinyiBigTableHour.getTestDate(); TXinyiBigTableDay tableDay = tXinyiBigTableDayMapper.selectTXinyiBigTableHourAvg(testDate); if (!Objects.isNull(tableDay)) { ArrayList gyHycRjyAll = new ArrayList<>(); ArrayList gyHycRjyZdAll = new ArrayList<>(); ArrayList gyHycWnndAll = new ArrayList<>(); ArrayList rbHycRjyAll = new ArrayList<>(); ArrayList rbHycWnndAll = new ArrayList<>(); ArrayList rbYycRjyAll = new ArrayList<>(); ArrayList rbQycRjyAll = new ArrayList<>(); ArrayList rbWncjbAll = new ArrayList<>(); ArrayList rbWntjzsAll = new ArrayList<>(); ArrayList rbHfxwnndAll = new ArrayList<>(); ArrayList hyHycxsyAll = new ArrayList<>(); ArrayList hyQyanAll = new ArrayList<>(); ArrayList hyQyckxsyAll = new ArrayList<>(); ArrayList hyHyzlsyAll = new ArrayList<>(); gyHycRjyAll.add(tableDay.getGyOneHymdDo()); gyHycRjyAll.add(tableDay.getGyTwoHymdDo()); gyHycRjyZdAll.add(tableDay.getGyOneHyzdDo()); gyHycRjyZdAll.add(tableDay.getGyTwoHyzdDo()); gyHycWnndAll.add(tableDay.getGyOneMlss()); gyHycWnndAll.add(tableDay.getGyTwoMlss()); rbHycRjyAll.add(tableDay.getRbShcHyOneDo()); rbHycRjyAll.add(tableDay.getRbShcHyTwoDo()); rbHycWnndAll.add(tableDay.getRbShcHyOneMlss()); rbHycWnndAll.add(tableDay.getRbShcHyTwoMlss()); rbYycRjyAll.add(tableDay.getRbShcYyOneDo()); rbYycRjyAll.add(tableDay.getRbShcYyTwoDo()); rbQycRjyAll.add(tableDay.getRbShcQyOneDo()); rbQycRjyAll.add(tableDay.getRbShcQyTwoDo()); rbWncjbAll.add(tableDay.getRbShcHyOneSv()); rbWncjbAll.add(tableDay.getRbShcHyTwoSv()); rbWntjzsAll.add(tableDay.getRbShcHyOneSvi()); rbWntjzsAll.add(tableDay.getRbShcHyTwoSvi()); rbHfxwnndAll.add(tableDay.getRbShcHyOneMlvss()); rbHfxwnndAll.add(tableDay.getRbShcHyTwoMlvss()); hyHycxsyAll.add(tableDay.getHyNo3Hlj1Jqr()); hyHycxsyAll.add(tableDay.getHyNo3Hlj2Jqr()); hyQyanAll.add(tableDay.getHyNh31Jqr()); hyQyanAll.add(tableDay.getHyNh32Jqr()); hyQyckxsyAll.add(tableDay.getHyNo3Qyc1Jqr()); hyQyckxsyAll.add(tableDay.getHyNo3Qyc2Jqr()); hyHyzlsyAll.add(tableDay.getHyTpHl1Jqr()); hyHyzlsyAll.add(tableDay.getHyTpHl2Jqr()); tableDay.setGyHycRjyAll(formatList(gyHycRjyAll)); tableDay.setGyHycRjyZdAll(formatList(gyHycRjyZdAll)); tableDay.setGyHycWnndAll(formatList(gyHycWnndAll)); tableDay.setRbHycRjyAll(formatList(rbHycRjyAll)); tableDay.setRbHycWnndAll(formatList(rbHycWnndAll)); tableDay.setRbYycRjyAll(formatList(rbYycRjyAll)); tableDay.setRbQycRjyAll(formatList(rbQycRjyAll)); tableDay.setRbWncjbAll(formatList(rbWncjbAll)); tableDay.setRbWntjzsAll(formatList(rbWntjzsAll)); tableDay.setRbHfxwnndAll(formatList(rbHfxwnndAll)); tableDay.setHyHycxsyAll(formatList(hyHycxsyAll)); tableDay.setHyQyanAll(formatList(hyQyanAll)); tableDay.setHyQyckxsyAll(formatList(hyQyckxsyAll)); tableDay.setHyHyzlsyAll(formatList(hyHyzlsyAll)); tableDay.setTestDate(testDate); bigTableDayList.add(tableDay); } } if (!CollectionUtils.isEmpty(bigTableDayList)) { SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); TXinyiBigTableDayMapper sqlSessionMapper = sqlSession.getMapper(TXinyiBigTableDayMapper.class); bigTableDayList.forEach(sqlSessionMapper::insertTXinyiBigTableDay); sqlSession.commit(); sqlSession.close(); } } long end = System.currentTimeMillis(); return "ok;耗时:" + (end - begin) / 1000 + "秒。"; } /** * 处理big_table_hour历史数据 * @return */ @GetMapping("/handleBigTableHourHistoryData") public String handleBigTableHourHistoryData () { log.info("进入了 处理big_table_hour历史数据"); long begin = System.currentTimeMillis(); int size = 500; int count = xinyiIndustryMapper.getCount(); int num = ( count / size ) + 1; for (int i = 0; i < num; i++) { List tXinyiIndustries = xinyiIndustryMapper.selectTXinyiIndustryListByPage(i * size, size); if ( !CollectionUtils.isEmpty(tXinyiIndustries) ) { List tXinyiBigTableHourList = new ArrayList(); for (int j = 0; j < tXinyiIndustries.size(); j++) { TXinyiBigTableHour xinyiBigTableHour = new TXinyiBigTableHour(); TXinyiIndustry tXinyiIndustry = tXinyiIndustries.get(j); String testHour = tXinyiIndustry.getTestHour(); String testDate = tXinyiIndustry.getTestDate(); // 处理工业库 handleIndustryData(xinyiBigTableHour, tXinyiIndustry); // 处理计算表 List tXinyiCalculates = xinyiCalculateMapper.selectTXinyiCalculateList(TXinyiCalculate.builder().testHour(testHour).build()); if ( !CollectionUtils.isEmpty(tXinyiCalculates) ) { TXinyiCalculate tXinyiCalculate = tXinyiCalculates.get(0); handleCalculateData(xinyiBigTableHour, tXinyiCalculate); } // 处理日报表 List tXinyiDailies = xinyiDailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(testDate).build()); if ( !CollectionUtils.isEmpty(tXinyiDailies) ) { TXinyiDaily tXinyiDaily = tXinyiDailies.get(0); handleDailyData(xinyiBigTableHour, tXinyiDaily); } // 处理化验室 List tXinyiRobots = xinyiRobotMapper.selectTXinyiRobotList(TXinyiRobot.builder().testHour(testHour).build()); if (!CollectionUtils.isEmpty(tXinyiRobots)) { TXinyiRobot tXinyiRobot = tXinyiRobots.get(0); handleRobotData(xinyiBigTableHour, tXinyiRobot); } // TXinyiRobot tXinyiRobot = xinyiRobotMapper.selectTXinyiRobotByAvg(TXinyiRobot.builder().testHour(testHour).build()); // if ( !Objects.isNull(tXinyiRobot) ) { // handleRobotData(xinyiBigTableHour, tXinyiRobot); // } tXinyiBigTableHourList.add(xinyiBigTableHour); } if (!CollectionUtils.isEmpty(tXinyiBigTableHourList)) { SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false); TXinyiBigTableHourMapper sqlSessionMapper = sqlSession.getMapper(TXinyiBigTableHourMapper.class); tXinyiBigTableHourList.stream().forEach(item -> sqlSessionMapper.insertTXinyiBigTableHour(item)); sqlSession.commit(); sqlSession.close(); } } } long end = System.currentTimeMillis(); return "ok;耗时:" + (end - begin) /1000 + "秒。"; } // 处理工业库 private void handleIndustryData(TXinyiBigTableHour xinyiBigTableHour, TXinyiIndustry tXinyiIndustry) { xinyiBigTableHour.setTestDate(tXinyiIndustry.getTestDate()); xinyiBigTableHour.setTestHour(tXinyiIndustry.getTestHour()); xinyiBigTableHour.setGyJsCod(tXinyiIndustry.getJsCod()); xinyiBigTableHour.setGyJsPh(tXinyiIndustry.getJsPh()); xinyiBigTableHour.setGyJsSs(tXinyiIndustry.getJsSs()); xinyiBigTableHour.setGyJsTp(tXinyiIndustry.getJsTp()); xinyiBigTableHour.setGyJsTn(tXinyiIndustry.getJsTn()); xinyiBigTableHour.setGyJsNh3(tXinyiIndustry.getJsNh3()); xinyiBigTableHour.setGyJsSwPh(tXinyiIndustry.getJsSwPh()); xinyiBigTableHour.setGyJsBfyw(tXinyiIndustry.getJsBfyw()); xinyiBigTableHour.setGyCsSlqc(tXinyiIndustry.getCsSlqc()); xinyiBigTableHour.setGyCsCod(tXinyiIndustry.getCsCod()); xinyiBigTableHour.setGyCsPh(tXinyiIndustry.getCsPh()); xinyiBigTableHour.setGyCsSs(tXinyiIndustry.getCsSs()); xinyiBigTableHour.setGyCsTn(tXinyiIndustry.getCsTn()); xinyiBigTableHour.setGyCsTp(tXinyiIndustry.getCsTp()); xinyiBigTableHour.setGyCsNh3(tXinyiIndustry.getCsNh3()); xinyiBigTableHour.setGyOneHyzdDo(tXinyiIndustry.getOneHyzdDo()); xinyiBigTableHour.setGyOneHymdDo(tXinyiIndustry.getOneHymdDo()); xinyiBigTableHour.setGyTwoHyzdDo(tXinyiIndustry.getTwoHyzdDo()); xinyiBigTableHour.setGyTwoHymdDo(tXinyiIndustry.getTwoHymdDo()); xinyiBigTableHour.setGyOneMlss(tXinyiIndustry.getOneMlss()); xinyiBigTableHour.setGyTwoMlss(tXinyiIndustry.getTwoMlss()); xinyiBigTableHour.setGyJsTds(tXinyiIndustry.getJsTds()); xinyiBigTableHour.setGyJsSlq(tXinyiIndustry.getJsSlq()); xinyiBigTableHour.setGyNHlbOneGp(tXinyiIndustry.getNHlbOneGp()); xinyiBigTableHour.setGyNHlbTwoGp(tXinyiIndustry.getNHlbTwoGp()); xinyiBigTableHour.setGyNHlbThreeGp(tXinyiIndustry.getNHlbThreeGp()); xinyiBigTableHour.setGyNHlbFourGp(tXinyiIndustry.getNHlbFourGp()); xinyiBigTableHour.setGyNhlBFiveGp(tXinyiIndustry.getNhlBFiveGp()); xinyiBigTableHour.setGyNHlbSixGp(tXinyiIndustry.getNHlbSixGp()); xinyiBigTableHour.setGyWHlbOneGp(tXinyiIndustry.getWHlbOneGp()); xinyiBigTableHour.setGyWHlbTwoGp(tXinyiIndustry.getWHlbTwoGp()); xinyiBigTableHour.setGyWHlbThreeGp(tXinyiIndustry.getWHlbThreeGp()); xinyiBigTableHour.setGyWHlbFourGp(tXinyiIndustry.getWHlbFourGp()); xinyiBigTableHour.setGyWHlbFiveGp(tXinyiIndustry.getWHlbFiveGp()); xinyiBigTableHour.setGyFjOne(tXinyiIndustry.getFjOne()); xinyiBigTableHour.setGyFjTwo(tXinyiIndustry.getFjTwo()); xinyiBigTableHour.setGyFjThree(tXinyiIndustry.getFjThree()); xinyiBigTableHour.setGyFjFour(tXinyiIndustry.getFjFour()); xinyiBigTableHour.setGyFjFive(tXinyiIndustry.getFjFive()); xinyiBigTableHour.setGyFjSix(tXinyiIndustry.getFjSix()); xinyiBigTableHour.setGyKqllOne(tXinyiIndustry.getKqllOne()); xinyiBigTableHour.setGyKqllTwo(tXinyiIndustry.getKqllTwo()); xinyiBigTableHour.setGyKqllThree(tXinyiIndustry.getKqllThree()); xinyiBigTableHour.setGyKqllFour(tXinyiIndustry.getKqllFour()); xinyiBigTableHour.setGyKqllFive(tXinyiIndustry.getKqllFive()); xinyiBigTableHour.setGyKqllSix(tXinyiIndustry.getKqllSix()); xinyiBigTableHour.setGySjtyjly(tXinyiIndustry.getSJTYJLY()); xinyiBigTableHour.setGyCljyssll(tXinyiIndustry.getCLJYSSLL()); xinyiBigTableHour.setGyHycRjyAll(tXinyiIndustry.getHycRjyAll()); xinyiBigTableHour.setGyHycRjyZdAll(tXinyiIndustry.getHycRjyZdAll()); xinyiBigTableHour.setGyHycWnndAll(tXinyiIndustry.getHycWnndAll()); xinyiBigTableHour.setGyClP04Ycz(tXinyiIndustry.getCLP04YCZ()); } // 处理计算表 private void handleCalculateData(TXinyiBigTableHour xinyiBigTableHour, TXinyiCalculate xinyiCalculate) { xinyiBigTableHour.setJsJsTdb(xinyiCalculate.getJsTdb()); xinyiBigTableHour.setJsJsTlb(xinyiCalculate.getJsTlb()); xinyiBigTableHour.setJsJsBodBCod(xinyiCalculate.getJsBodBCod()); xinyiBigTableHour.setJsYyqHrt(xinyiCalculate.getYyqHrt()); xinyiBigTableHour.setJsQyqHrt(xinyiCalculate.getQyqHrt()); xinyiBigTableHour.setJsHyqHrt(xinyiCalculate.getHyqHrt()); xinyiBigTableHour.setJsHfxwnndzb(xinyiCalculate.getHFXWNNDZB()); xinyiBigTableHour.setJsFM(xinyiCalculate.getFM()); xinyiBigTableHour.setJsGsls(xinyiCalculate.getGSLS()); xinyiBigTableHour.setJsGslsOne(xinyiCalculate.getGslsOne()); xinyiBigTableHour.setJsGslsTwo(xinyiCalculate.getGslsTwo()); xinyiBigTableHour.setJsXgsGsls(xinyiCalculate.getXgsGsls()); xinyiBigTableHour.setJsXlcscBmfh(xinyiCalculate.getXlcscBmfh()); xinyiBigTableHour.setJsXlcscHrt(xinyiCalculate.getXlcscHrt()); xinyiBigTableHour.setJsCccdcBmfh(xinyiCalculate.getCccdcBmfh()); xinyiBigTableHour.setJsCccdcHrt(xinyiCalculate.getCccdcHrt()); xinyiBigTableHour.setJsEccBmfh(xinyiCalculate.getEccBmfh()); xinyiBigTableHour.setJsEccHrt(xinyiCalculate.getEccHrt()); xinyiBigTableHour.setJsEccGtfh(xinyiCalculate.getEccGtfh()); xinyiBigTableHour.setJsClsnJcsj(xinyiCalculate.getClsnJcsj()); xinyiBigTableHour.setJsXgcdcQsqSsls(xinyiCalculate.getXgcdcQsqSsls()); xinyiBigTableHour.setJsWhlb(xinyiCalculate.getWHLB()); xinyiBigTableHour.setJsNhlb(xinyiCalculate.getNHLB()); xinyiBigTableHour.setJsWdscnl(xinyiCalculate.getWDSCNL()); xinyiBigTableHour.setJsQsb(xinyiCalculate.getQSB()); xinyiBigTableHour.setJsFcxsl(xinyiCalculate.getFCXSL()); xinyiBigTableHour.setJsFcxslbl(xinyiCalculate.getFCXSLBL()); xinyiBigTableHour.setJsWhlbRN(xinyiCalculate.getWhlRN()); } // 处理日报 private void handleDailyData(TXinyiBigTableHour tXinyiBigTableHour, TXinyiDaily tXinyiDaily) { tXinyiBigTableHour.setRbJsCod(tXinyiDaily.getJsCod()); tXinyiBigTableHour.setRbJsPh(tXinyiDaily.getJsPh()); tXinyiBigTableHour.setRbJsBod5(tXinyiDaily.getJsBod5()); tXinyiBigTableHour.setRbJsSs(tXinyiDaily.getJsSs()); tXinyiBigTableHour.setRbJsNh3(tXinyiDaily.getJsNh3()); tXinyiBigTableHour.setRbJsTn(tXinyiDaily.getJsTn()); tXinyiBigTableHour.setRbJsTp(tXinyiDaily.getJsTp()); tXinyiBigTableHour.setRbJsDcgj(tXinyiDaily.getJsDcgj()); tXinyiBigTableHour.setRbCsCod(tXinyiDaily.getCsCod()); tXinyiBigTableHour.setRbCsPh(tXinyiDaily.getCsPh()); tXinyiBigTableHour.setRbCsBod5(tXinyiDaily.getCsBod5()); tXinyiBigTableHour.setRbCsSs(tXinyiDaily.getCsSs()); tXinyiBigTableHour.setRbCsNh3(tXinyiDaily.getCsNh3()); tXinyiBigTableHour.setRbCsTn(tXinyiDaily.getCsTn()); tXinyiBigTableHour.setRbCsTp(tXinyiDaily.getCsTp()); tXinyiBigTableHour.setRbCsDcgj(tXinyiDaily.getCsDcgj()); tXinyiBigTableHour.setRbJsSw(tXinyiDaily.getJsSw()); tXinyiBigTableHour.setRbCsSw(tXinyiDaily.getCsSw()); tXinyiBigTableHour.setRbShcOnePh(tXinyiDaily.getShcOnePh()); tXinyiBigTableHour.setRbShcTwoPh(tXinyiDaily.getShcTwoPh()); tXinyiBigTableHour.setRbShcHyOneSv(tXinyiDaily.getShcHyOneSv()); tXinyiBigTableHour.setRbShcHyTwoSv(tXinyiDaily.getShcHyTwoSv()); tXinyiBigTableHour.setRbShcHyOneSvi(tXinyiDaily.getShcHyOneSvi()); tXinyiBigTableHour.setRbShcHyTwoSvi(tXinyiDaily.getShcHyTwoSvi()); tXinyiBigTableHour.setRbShcHyOneMlss(tXinyiDaily.getShcHyOneMlss()); tXinyiBigTableHour.setRbShcHyTwoMlss(tXinyiDaily.getShcHyTwoMlss()); tXinyiBigTableHour.setRbShcHyOneMlvss(tXinyiDaily.getShcHyOneMlvss()); tXinyiBigTableHour.setRbShcHyTwoMlvss(tXinyiDaily.getShcHyTwoMlvss()); tXinyiBigTableHour.setRbShcYyOneDo(tXinyiDaily.getShcYyOneDo()); tXinyiBigTableHour.setRbShcYyTwoDo(tXinyiDaily.getShcYyTwoDo()); tXinyiBigTableHour.setRbShcQyOneDo(tXinyiDaily.getShcQyOneDo()); tXinyiBigTableHour.setRbShcQyTwoDo(tXinyiDaily.getShcQyTwoDo()); tXinyiBigTableHour.setRbShcHyOneDo(tXinyiDaily.getShcHyOneDo()); tXinyiBigTableHour.setRbShcHyTwoDo(tXinyiDaily.getShcHyTwoDo()); tXinyiBigTableHour.setRbJsl(tXinyiDaily.getJSL()); tXinyiBigTableHour.setRbCsl(tXinyiDaily.getCSL()); tXinyiBigTableHour.setRbSdclcxsl(tXinyiDaily.getSDCLCXSL()); tXinyiBigTableHour.setRbQsb(tXinyiDaily.getQSB()); tXinyiBigTableHour.setRbFM(tXinyiDaily.getFM()); tXinyiBigTableHour.setRbYyHrt(tXinyiDaily.getYyHrt()); tXinyiBigTableHour.setRbHyHrt(tXinyiDaily.getHyHrt()); tXinyiBigTableHour.setRbQyHrt(tXinyiDaily.getQyHrt()); tXinyiBigTableHour.setRbNhlR(tXinyiDaily.getNhlR()); tXinyiBigTableHour.setRbWhlR(tXinyiDaily.getWhlR()); tXinyiBigTableHour.setRbSrt(tXinyiDaily.getSRT()); tXinyiBigTableHour.setRbCnl(tXinyiDaily.getCNL()); tXinyiBigTableHour.setRbTyqBod5Tn(tXinyiDaily.getTyqBod5Tn()); tXinyiBigTableHour.setRbTyhBod5Tn(tXinyiDaily.getTyhBod5Tn()); tXinyiBigTableHour.setRbHycRjyAll(tXinyiDaily.getHycRjyAll()); tXinyiBigTableHour.setRbHycWnndAll(tXinyiDaily.getHycWnndAll()); tXinyiBigTableHour.setRbYycRjyAll(tXinyiDaily.getYycRjyAll()); tXinyiBigTableHour.setRbQycRjyAll(tXinyiDaily.getQycRjyAll()); tXinyiBigTableHour.setRbWncjbAll(tXinyiDaily.getWncjbAll()); tXinyiBigTableHour.setRbWntjzsAll(tXinyiDaily.getWntjzsAll()); tXinyiBigTableHour.setRbHfxwnndAll(tXinyiDaily.getHfxwnndAll()); tXinyiBigTableHour.setRbChuniliang(tXinyiDaily.getCHUNILIANG()); tXinyiBigTableHour.setRbCnhsl(tXinyiDaily.getCNHSL()); tXinyiBigTableHour.setRbGwnl(tXinyiDaily.getGWNL()); tXinyiBigTableHour.setRbDf(tXinyiDaily.getDF()); tXinyiBigTableHour.setRbXnjf(tXinyiDaily.getXNJF()); tXinyiBigTableHour.setRbClf(tXinyiDaily.getCLF()); tXinyiBigTableHour.setRbTyf(tXinyiDaily.getTYF()); tXinyiBigTableHour.setRbXdjf(tXinyiDaily.getXDJF()); tXinyiBigTableHour.setRbQtyjf(tXinyiDaily.getQTYJF()); tXinyiBigTableHour.setRbCnf(tXinyiDaily.getCNF()); tXinyiBigTableHour.setRbZlsf(tXinyiDaily.getZLSF()); tXinyiBigTableHour.setRbZjcb(tXinyiDaily.getZJCB()); tXinyiBigTableHour.setRbDwcb(tXinyiDaily.getDWCB()); } // 处理化验室 private void handleRobotData(TXinyiBigTableHour tXinyiBigTableHour, TXinyiRobot tXinyiRobot) { tXinyiBigTableHour.setHyCodYb(tXinyiRobot.getCodYb()); tXinyiBigTableHour.setHyCodJqr(tXinyiRobot.getCodJqr()); tXinyiBigTableHour.setHyCodYz(tXinyiRobot.getCodYz()); tXinyiBigTableHour.setHyTpHl1Jqr(tXinyiRobot.getTpHl1Jqr()); tXinyiBigTableHour.setHyTpHl2Jqr(tXinyiRobot.getTpHl2Jqr()); tXinyiBigTableHour.setHyTpRccJqr(tXinyiRobot.getTpRccJqr()); tXinyiBigTableHour.setHyTp1Yz(tXinyiRobot.getTp1Yz()); tXinyiBigTableHour.setHyTp2Yz(tXinyiRobot.getTp2Yz()); tXinyiBigTableHour.setHyTpRccYz(tXinyiRobot.getTpRccYz()); tXinyiBigTableHour.setHyNh31Jqr(tXinyiRobot.getNh31Jqr()); tXinyiBigTableHour.setHyNh32Jqr(tXinyiRobot.getNh32Jqr()); tXinyiBigTableHour.setHyNh31Yz(tXinyiRobot.getNh31Yz()); tXinyiBigTableHour.setHyNo3Hlc1Yz(tXinyiRobot.getNo3Hlc1Yz()); tXinyiBigTableHour.setHyNh32Yz(tXinyiRobot.getNh32Yz()); tXinyiBigTableHour.setHyNo3Hlc2Yz(tXinyiRobot.getNo3Hlc2Yz()); tXinyiBigTableHour.setHyNo3Hlj1Jqr(tXinyiRobot.getNo3Hlj1Jqr()); tXinyiBigTableHour.setHyNo3Hlj2Jqr(tXinyiRobot.getNo3Hlj2Jqr()); tXinyiBigTableHour.setHyTyll(tXinyiRobot.getTYLL()); tXinyiBigTableHour.setHyNo3Qyc1Jqr(tXinyiRobot.getNo3Qyc1Jqr()); tXinyiBigTableHour.setHyNo3Qyc2Jqr(tXinyiRobot.getNo3Qyc2Jqr()); tXinyiBigTableHour.setHyNo3Qyc1Yz(tXinyiRobot.getNo3Qyc1Yz()); tXinyiBigTableHour.setHyNo3Qyc2Yz(tXinyiRobot.getNo3Qyc2Yz()); tXinyiBigTableHour.setHyJsll(tXinyiRobot.getJSLL()); tXinyiBigTableHour.setHyHycxsyAll(tXinyiRobot.getHycxsyAll()); tXinyiBigTableHour.setHyQyanAll(tXinyiRobot.getQyanAll()); tXinyiBigTableHour.setHyQyckxsyAll(tXinyiRobot.getQyckxsyAll()); tXinyiBigTableHour.setHyHyzlsyAll(tXinyiRobot.getHyzlsyAll()); } private void handlePredictorWarning(String[] split, String hour, String task, List tXinyiIndustries6, List tXinyiRobots6, String date) { String[] hours = hour.split(","); //2024年6月23日18:28:55 因为存在跨天问题 所以日期也是逗号拼接的 String[] dates = date.split(","); //2024年6月18日13:41:10 统一格式,否则查询不到结果 //2024年6月18日10:36:49 增加预测记录,预测准确度计算等 TXinyiForecastComparison tXinyiForecastComparison = new TXinyiForecastComparison(); //2024年7月11日17:04:11 TP改为zlsy tXinyiForecastComparison.setCategory(BusinessEnum.BigModelForecastEnum.TP.getCode().equalsIgnoreCase(task) ? BusinessEnum.BigModelForecastEnum.ZLSY.getCode() : task); tXinyiForecastComparison.setForecastTimeOne(dates[0].replaceAll("-", "/") + " " + hours[0]); tXinyiForecastComparison.setForecastTimeTwo(dates[1].replaceAll("-", "/") + " " + hours[1]); tXinyiForecastComparison.setForecastTimeThree(dates[2].replaceAll("-", "/") + " " + hours[2]); tXinyiForecastComparison.setHsForecastOne(new BigDecimal(split[0])); tXinyiForecastComparison.setHsForecastTwo(new BigDecimal(split[1])); tXinyiForecastComparison.setHsForecastThree(new BigDecimal(split[2])); //2024年6月20日14:28:31 增加字段,方便查询 tXinyiForecastComparison.setRemark(DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYYMMDDHH_TS)); //防止工业库挂掉以后持续预测同一数据 //2024年6月20日14:59:23 因为预测bug(以工业库为准,假如工业库挂了,获取的全是挂了时间段后的三小时) 判断是否生成过了否则不生成 TXinyiForecastComparison tXinyiForecastComparisonReq = new TXinyiForecastComparison(); //2024年08月20日16:24:56 因为remark存放的是当前时间,也就是每个小时的,所以都是不一样的,修复此bug // tXinyiForecastComparisonReq.setRemark(tXinyiForecastComparison.getRemark()); tXinyiForecastComparisonReq.setCategory(tXinyiForecastComparison.getCategory()); //2024年7月18日15:04:37 如果工业库挂掉以后,不管什么时刻,调用预测返回的未来三小时时间都是一样的,再增加一个查询条件 tXinyiForecastComparisonReq.setForecastTimeOne(tXinyiForecastComparison.getForecastTimeOne());//一个时刻就可以了 没必要再比较第二和第三时刻了。 List tXinyiForecastComparisons = this.xinyiForecastComparisonService.selectTXinyiForecastComparisonList(tXinyiForecastComparisonReq); if(!CollectionUtils.isEmpty(tXinyiForecastComparisons)){ log.error("预测已经进行过了,无需重复运行~~~~~~~~~~~@@@@@@@,要保存的预测数据为{}", JSON.toJSONString(tXinyiForecastComparison)); return; } //获取配置表 List tXinyiNormConfigs = this.xinyiNormConfigMapper.selectTXinyiNormConfigList(null); if(CollectionUtils.isEmpty(tXinyiNormConfigs)) { log.error( "未查询到配置信息"); return; } TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0); //获取最新的工业库的数据 // TXinyiIndustry tXinyiIndustry = this.xinyiIndustryMapper.selectTXinyiIndustryNewest(); //2024年7月18日10:29:44 因为获取了最新的六条数据,所以无需再查询最新的数据了 TXinyiIndustry tXinyiIndustry = tXinyiIndustries6.get(0); TXinyiRobot tXinyiRobot = tXinyiRobots6.get(0); List chartsDataList = new ArrayList<>(9); if(BusinessEnum.BigModelForecastEnum.COD.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=2&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); } // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); BigDecimal cscodBzz = normConfig.getCscodBzz(); BigDecimal cscodGkz = normConfig.getCscodGkz(); //处理展示数据 for (int i = 0; i < tXinyiIndustries6.size(); i++) { TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsCod(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(cscodBzz, split, cscodGkz, BusinessEnum.WarningCategoryEnum.CS_COD_YC.getCode(), hour, normConfig, tXinyiIndustry.getCsCod(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.SS.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=5&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); } // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); BigDecimal csSSBzz = normConfig.getCsssBzz(); BigDecimal csssGkz = normConfig.getCsssGkz(); //处理展示数据 for (int i = 0; i < tXinyiIndustries6.size(); i++) { TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsSs(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(csSSBzz, split, csssGkz, BusinessEnum.WarningCategoryEnum.CS_SS_YC.getCode(), hour, normConfig, tXinyiIndustry.getCsSs(), tXinyiIndustry, chartsDataList, date); }/*else if(BusinessEnum.BigModelForecastEnum.TN.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=3&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); } // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); BigDecimal cszzBzz = normConfig.getCszzBzz(); BigDecimal cszzGkz = normConfig.getCszzGkz(); //处理展示数据 for (int i = 0; i < tXinyiIndustries6.size(); i++) { TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsTn(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.CS_TN_YC.getCode(), hour, normConfig,tXinyiIndustry.getCsCod(), tXinyiIndustry, chartsDataList, date); }*/else if(BusinessEnum.BigModelForecastEnum.TP.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=1&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); } // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); BigDecimal cszlBzz = normConfig.getCszlBzz(); BigDecimal cszlGkz = normConfig.getCszlGkz(); //处理展示数据 for (int i = 0; i < tXinyiRobots6.size(); i++) { TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getTpRccJqr(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(cszlBzz, split, cszlGkz, CS_TP_YC.getCode(), hour, normConfig, tXinyiRobot.getTpRccJqr(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.NH3.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=4&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); } // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); BigDecimal csadBzz = normConfig.getCsadBzz(); BigDecimal csadGkz = normConfig.getCsadGkz(); //处理展示数据 for (int i = 0; i < tXinyiIndustries6.size(); i++) { TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsNh3(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(csadBzz, split, csadGkz, BusinessEnum.WarningCategoryEnum.CS_AD_YC.getCode(), hour, normConfig, tXinyiIndustry.getCsNh3(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.XSY1.getCode().equals(task)){ //2024年6月21日14:57:02 红杉的出水总氮预测改成 不用工业库的,用化验科的两个xsy 相关指标 //同时调用跃渊的预测接口 保存记录值 try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=6&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); } // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK); BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/ //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警 BigDecimal cszzBzz = normConfig.getCszzBzz(); BigDecimal cszzGkz = normConfig.getCszzGkz(); //处理展示数据 for (int i = 0; i < tXinyiRobots6.size(); i++) { TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Hlj1Jqr(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.CS_XSY_1_YC.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj1Jqr(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.XSY2.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=7&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); } // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK); BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/ //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警 BigDecimal cszzBzz = normConfig.getCszzBzz(); BigDecimal cszzGkz = normConfig.getCszzGkz(); //处理展示数据 for (int i = 0; i < tXinyiRobots6.size(); i++) { TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Hlj2Jqr(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.CS_XSY_2_YC.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.QYXSY1.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 /*try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=7&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); }*/ // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK); BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/ //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警 BigDecimal cszzBzz = normConfig.getCszzBzz(); BigDecimal cszzGkz = normConfig.getCszzGkz(); //处理展示数据 for (int i = 0; i < tXinyiRobots6.size(); i++) { TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Qyc1Jqr(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.QYCXSY_1.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.QYXSY2.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 /*try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=7&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); }*/ // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK); BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/ //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警 BigDecimal cszzBzz = normConfig.getCszzBzz(); BigDecimal cszzGkz = normConfig.getCszzGkz(); //处理展示数据 for (int i = 0; i < tXinyiRobots6.size(); i++) { TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Qyc2Jqr(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.QYCXSY_2.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.QYNH31.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 /*try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=7&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); }*/ // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK); BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/ //2024年09月08日11:21:25 采用出水氨氮的标准值和管控值 BigDecimal csadBzz = normConfig.getCsadBzz(); BigDecimal csadGkz = normConfig.getCsadGkz(); //处理展示数据 for (int i = 0; i < tXinyiRobots6.size(); i++) { TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNh31Jqr(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(csadBzz, split, csadGkz, BusinessEnum.WarningCategoryEnum.QYAD_1.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date); }else if(BusinessEnum.BigModelForecastEnum.QYNH32.getCode().equals(task)){ //同时调用跃渊的预测接口 保存记录值 /*try { String result = HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=7&time=" + DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH), INT_10000); if(!StringUtils.isBlank(result)){ JSONArray array = JSON.parseArray(result); tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6)); tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7)); tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8)); } } catch (Exception e) { log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage()); }*/ // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK); BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/ //2024年09月08日11:21:25 采用出水氨氮的标准值和管控值 BigDecimal csadBzz = normConfig.getCsadBzz(); BigDecimal csadGkz = normConfig.getCsadGkz(); //处理展示数据 for (int i = 0; i < tXinyiRobots6.size(); i++) { TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i); ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11)); chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNh32Jqr(), INT_2)); chartsDataList.add(chartBasic); } for (int i = 0; i < split.length; i++) { String val = split[i]; ChartBasic chartBasic = new ChartBasic(); chartBasic.setTime(hours[i]); chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2)); chartsDataList.add(chartBasic); } ryTask.handleXinYiWarningsYC(csadBzz, split, csadGkz, BusinessEnum.WarningCategoryEnum.QYAD_2.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date); }else { log.error("暂未支持的类型{}", task); } //插入到数据库 //2024年6月21日14:18:55 如果红杉预测和跃渊预测都有数据再保存 //2024年7月8日15:15:46 逻辑调整:只要红杉的数据不为空就保存 if(Objects.isNull(tXinyiForecastComparison.getHsForecastOne()) || Objects.isNull(tXinyiForecastComparison.getHsForecastTwo()) ||Objects.isNull(tXinyiForecastComparison.getHsForecastThree())){ // || Objects.isNull(tXinyiForecastComparison.getYyForecastOne()) || Objects.isNull(tXinyiForecastComparison.getYyForecastTwo()) || Objects.isNull(tXinyiForecastComparison.getYyForecastThree())){ log.error("保存预测对比数据时,有存在不满足条件的数据,不再保存数据,数据为{}", JSON.toJSONString(tXinyiForecastComparison)); }else xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison); } }