HandleDataController.java 111 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  1. package com.slibra.web.controller.business;
  2. import cn.hutool.core.date.DateUtil;
  3. import cn.hutool.http.HttpRequest;
  4. import cn.hutool.http.HttpUtil;
  5. import cn.hutool.poi.excel.ExcelReader;
  6. import cn.hutool.poi.excel.ExcelUtil;
  7. import com.alibaba.fastjson2.JSON;
  8. import com.alibaba.fastjson2.JSONArray;
  9. import com.alibaba.fastjson2.JSONObject;
  10. import com.slibra.business.domain.*;
  11. import com.slibra.business.mapper.*;
  12. import com.slibra.business.res.ChartBasic;
  13. import com.slibra.business.service.ITXinyiForecastComparisonService;
  14. import com.slibra.common.DecimalUtils;
  15. import com.slibra.common.core.domain.TXinyiDaily;
  16. import com.slibra.common.core.controller.BaseController;
  17. import com.slibra.common.enums.BusinessEnum;
  18. import com.slibra.common.utils.DateUtils;
  19. import com.slibra.common.utils.StringUtils;
  20. import com.slibra.quartz.task.AsyncTask;
  21. import com.slibra.quartz.task.RyTask;
  22. import lombok.extern.slf4j.Slf4j;
  23. import org.apache.ibatis.session.ExecutorType;
  24. import org.apache.ibatis.session.SqlSession;
  25. import org.apache.ibatis.session.SqlSessionFactory;
  26. import org.springframework.beans.BeanUtils;
  27. import org.springframework.beans.factory.annotation.Autowired;
  28. import org.springframework.util.CollectionUtils;
  29. import org.springframework.web.bind.annotation.*;
  30. import java.io.File;
  31. import java.math.BigDecimal;
  32. import java.math.RoundingMode;
  33. import java.time.LocalDateTime;
  34. import java.time.format.DateTimeFormatter;
  35. import java.util.*;
  36. import static com.slibra.common.constant.MyConstants.*;
  37. import static com.slibra.common.constant.MyConstants.BigDecimal_100;
  38. import static com.slibra.common.enums.BusinessEnum.WarningCategoryEnum.CS_TP_YC;
  39. /**
  40. * 参数配置 信息操作处理
  41. *
  42. *
  43. */
  44. @Slf4j
  45. @RestController
  46. @RequestMapping("/test")
  47. public class HandleDataController extends BaseController
  48. {
  49. @Autowired
  50. private TXinyiIndustryMapper xinyiIndustryMapper;
  51. @Autowired
  52. private TXinyiDailyMapper xinyiDailyMapper;
  53. @Autowired
  54. private TXinyiLaboratoryMapper xinyiLaboratoryMapper;
  55. @Autowired
  56. private TXinyiRobotMapper xinyiRobotMapper;
  57. @Autowired
  58. private TXinyiNormConfigMapper xinyiNormConfigMapper;
  59. @Autowired
  60. private TXinyiCalculateMapper xinyiCalculateMapper;
  61. @Autowired
  62. private TXinyiBigTableHourMapper tXinyiBigTableHourMapper;
  63. @Autowired
  64. private TXinyiBigTableDayMapper tXinyiBigTableDayMapper;
  65. @Autowired
  66. private TXinyiBigTableMonthMapper tXinyiBigTableMonthMapper;
  67. @Autowired
  68. private SqlSessionFactory sqlSessionFactory;
  69. @Autowired
  70. private RyTask ryTask;
  71. @Autowired
  72. private AsyncTask asyncTask;
  73. @Autowired
  74. private ITXinyiForecastComparisonService xinyiForecastComparisonService;
  75. 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"};
  76. public static final String[] predictorArr = {"出水COD", "出水SS", "出水总磷", "出水氨氮", "xsy1", "xsy2"};
  77. /**
  78. *手动处理水质报警
  79. */
  80. @GetMapping("/waterWarning")
  81. public String waterWarning(){
  82. log.info("进入了 手动触发水质报警的 操作");
  83. //获取配置表
  84. List<TXinyiNormConfig> tXinyiNormConfigs = this.xinyiNormConfigMapper.selectTXinyiNormConfigList(null);
  85. if(CollectionUtils.isEmpty(tXinyiNormConfigs))
  86. throw new RuntimeException("未查询到配置信息");
  87. TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0);
  88. TXinyiIndustry tXinyiIndustry = this.xinyiIndustryMapper.selectTXinyiIndustryNewest();
  89. if(Objects.isNull(tXinyiIndustry))
  90. throw new RuntimeException("未查询到工业库信息");
  91. asyncTask.handleSZWarning(tXinyiIndustry, normConfig);
  92. return "success";
  93. }
  94. /**
  95. *手动处理生化报警
  96. */
  97. @GetMapping("/shWarning")
  98. public String shWarning(){
  99. log.info("进入了 手动处理生化报警 操作");
  100. //获取配置表
  101. List<TXinyiNormConfig> tXinyiNormConfigs = this.xinyiNormConfigMapper.selectTXinyiNormConfigList(null);
  102. if(CollectionUtils.isEmpty(tXinyiNormConfigs))
  103. throw new RuntimeException("未查询到配置信息");
  104. TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0);
  105. TXinyiIndustry tXinyiIndustry = this.xinyiIndustryMapper.selectTXinyiIndustryNewest();
  106. if(Objects.isNull(tXinyiIndustry))
  107. throw new RuntimeException("未查询到工业库信息");
  108. List<TXinyiCalculate> tXinyiCalculates = xinyiCalculateMapper.selectTXinyiCalculateList(TXinyiCalculate.builder().testHour(tXinyiIndustry.getTestHour()).build());
  109. if (!CollectionUtils.isEmpty(tXinyiCalculates)) {
  110. TXinyiCalculate tXinyiCalculate = tXinyiCalculates.get(0);
  111. asyncTask.handleSHWarning(tXinyiIndustry, normConfig, tXinyiCalculate);
  112. }
  113. return "success";
  114. }
  115. /**
  116. *手动处理化验室报警
  117. */
  118. @GetMapping("/robotWarning")
  119. public String robotWarning(){
  120. log.info("进入了 手动触发化验室报警的 操作");
  121. asyncTask.handleRobotWarning(this.xinyiRobotMapper.selectNRobot(1));
  122. return "success";
  123. }
  124. /**
  125. *手动处理预测报警
  126. */
  127. @GetMapping("/forecastWarning")
  128. public String forecastWarning(){
  129. log.info("进入了 手动触发预测报警的 操作");
  130. //获取最新的6条工业科数据
  131. List<TXinyiIndustry> tXinyiIndustries6 = this.xinyiIndustryMapper.selectNIndustry(INT_6);
  132. List<TXinyiRobot> tXinyiRobots6 = this.xinyiRobotMapper.selectNRobot(INT_6);
  133. //2024年7月18日10:31:18 加个校验,只有从来没有数据的水厂才会进入下面的判断
  134. if(CollectionUtils.isEmpty(tXinyiIndustries6) || tXinyiIndustries6.size() < INT_6
  135. || CollectionUtils.isEmpty(tXinyiRobots6) || tXinyiRobots6.size() <INT_6){
  136. log.error("预测的时候,获取最新的6条工业数据或者化验数据不满足,任务终止,工业数据为{}\n化验数据为{}", JSON.toJSONString(tXinyiIndustries6), JSON.toJSONString(tXinyiRobots6));
  137. return "预测的时候,获取最新的6条工业数据或者化验数据不满足,任务终止";
  138. }
  139. //先处理xsy1 和 xsy2 合并成一个数据
  140. // this.predictorSpecial(tXinyiIndustries6, tXinyiRobots6);
  141. //2024年7月11日16:55:27 xsy1 和 xsy2 又不合并了。。。 再次分开处理
  142. for (int i = 0; i < predictorArr.length; i++) {
  143. String result = ryTask.getPredictor(predictorArr[i]);
  144. if(StringUtils.isBlank(result) || "error".equals(result)){
  145. log.info("预测数据返回结果不符合解析条件,返回结果为{}", result);
  146. continue;
  147. }
  148. JSONObject jsonObject = null;
  149. try {
  150. jsonObject = JSON.parseObject(result);
  151. } catch (Exception e) {
  152. log.error("[转JSON的时候]预测数据返回结果不符合解析条件,返回结果为{}", result);
  153. continue;
  154. }
  155. log.info("^^^^^^^^^^^^^预测接口转弯JSON对象后,原内容是{}", JSON.toJSONString(jsonObject));
  156. //2024年7月8日15:25:51 加个校验 因为各种奇葩返回。。 比如返回的结果是 "null"
  157. if(Objects.isNull(jsonObject)){
  158. log.error("[转JSON的时候]预测数据返回结果是null,不处里");
  159. continue;
  160. }
  161. String task = jsonObject.getString("task");
  162. String hour = jsonObject.getString("hour");
  163. String pred = jsonObject.getString("pred");
  164. String date = jsonObject.getString("date");
  165. if(StringUtils.isNotBlank(pred) && pred.contains(",")){
  166. String[] split = pred.split(",");
  167. if(split.length != 3){
  168. log.error("预测数据返回结果为{},长度不是3,无法正常解析", result);
  169. //因为部分预测还不支持 所以不需要
  170. // ryTask.handleXinYiWarningsYC(cscodBzz, split, cscodGkz, BusinessEnum.WarningCategoryEnum.CS_COD_YC.getCode(), hour, normConfig);
  171. continue;
  172. }
  173. //解析数据 处理报警 调研prompt 保存等
  174. this.handlePredictorWarning(split, hour, task, tXinyiIndustries6, tXinyiRobots6, date);
  175. }else {
  176. log.error("预测数据返回结果为{},无法正常解析", result);
  177. }
  178. }
  179. return "success";
  180. }
  181. @GetMapping("/dateAdd")
  182. public String dateAdd() {
  183. // 给定时间段的起始时间和结束时间
  184. LocalDateTime startTime = LocalDateTime.parse("2024-04-13T16:00:00");
  185. LocalDateTime endTime = LocalDateTime.parse("2024-04-13T17:00:00");
  186. /*LocalDateTime startTime = LocalDateTime.parse("2024-02-26T00:00:00");
  187. LocalDateTime endTime = LocalDateTime.parse("2024-02-27T00:00:00");*/
  188. // 每个小时的时间格式
  189. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  190. // 循环按小时分割
  191. LocalDateTime currentHour = startTime;
  192. while (currentHour.isBefore(endTime)) {
  193. String begin = currentHour.format(formatter);
  194. String end = currentHour.plusMinutes(10).format(formatter);
  195. // 输出当前小时的起始时间和结束时间
  196. System.out.println("起始时间:" + begin);
  197. System.out.println("结束时间:" + end);
  198. // 当前小时加一小时,作为下一个小时的起始时间
  199. currentHour = currentHour.plusMinutes(10);
  200. //每个小时查询一次数据
  201. String url = "http://10.0.0.27:4568/api/v1/khquerydata";
  202. HashMap<String, Object> req = new HashMap<>();
  203. req.put("tagNames", queryTags);
  204. req.put("startTime", begin);
  205. req.put("endTime", end);
  206. req.put("recordNumbers", 100000);
  207. String body = HttpRequest.post(url).header("Authorization", "c2E6c2E=").header("clientName", "hongshan").body(JSON.toJSONString(req)).execute().body();
  208. // System.out.println("body = " + body);
  209. List<HashMap<String, String>> list = new ArrayList<>();
  210. //行转列数据处理
  211. for (String queryTag : queryTags) {
  212. JSONArray array = JSON.parseObject(body).getJSONArray(queryTag);
  213. //特殊数据处理一
  214. if(Objects.isNull(array) || array.isEmpty()){
  215. System.out.println(queryTag + "查询到了空的数据,跳过本次循环");
  216. continue;
  217. }
  218. int size = array.size();
  219. //特殊数据处理二
  220. if("0".equals(array.get(1) + "")){
  221. System.out.println(queryTag + "查询到了数据,但是数据集合只有一条,且都是0");
  222. continue;
  223. }
  224. //结合至少62个数据才满足条件(有可能获取不到)
  225. /*if(size < 62){
  226. System.out.println(queryTag + "查询到了不符合条件的数据,跳过本次循环");
  227. continue;
  228. }*/
  229. //存放的数据集
  230. //利用map去重
  231. HashMap<String, String> map = new LinkedHashMap<>();
  232. for (int i = 2; i < size; i++) {
  233. // System.out.println(i + "" + array.get(i));
  234. JSONArray oneRecord = JSON.parseArray(JSON.toJSONString(array.get(i)));
  235. //处理为空或者为0的数据
  236. Object timeStampValue = oneRecord.get(2);
  237. if(Objects.isNull(timeStampValue) || "0".equals(timeStampValue + ""))
  238. continue;
  239. BigDecimal value = Objects.isNull(oneRecord.get(0)) ? null : new BigDecimal(oneRecord.get(0) + "");
  240. long timestamp = (long) timeStampValue;
  241. String format = DateUtil.format(new Date(timestamp), DateUtils.YYYYMMDDHH_TS);
  242. map.put(format, queryTag + "-" + value);
  243. }
  244. list.add(map);
  245. }
  246. // System.out.println("list = " + list);
  247. //先构造对象(list中任意一个map遍历的key个数) 因为合并完并不是1分钟60条,参考上面筛选区间,有时候会有几个值获取不到
  248. /*HashMap<String, String> oneRow = list.get(0);
  249. Set<String> set = oneRow.keySet();
  250. List<Industry> result = new ArrayList<>(set.size());
  251. set.forEach(s -> {
  252. Industry industry = new Industry();
  253. industry.setTestTime(s);
  254. result.add(industry);
  255. });*/
  256. Set<String> recordTimeSet = new HashSet<>();
  257. Map<String, TXinyiIndustry> recordMap = new HashMap<>();
  258. for (int i = 0; i < list.size(); i++) {
  259. HashMap<String, String> map = list.get(i);
  260. int finalJ = i;
  261. map.forEach((k, v) ->{
  262. TXinyiIndustry industry = null;
  263. if(!recordTimeSet.contains(k)){//第一次
  264. industry = new TXinyiIndustry();
  265. recordTimeSet.add(k);
  266. recordMap.put(k, industry);
  267. }else{
  268. industry = recordMap.get(k);
  269. }
  270. industry.setTestTime(k);
  271. //2024年4月15日11:19:52 额外增加2个字段
  272. industry.setTestDate(k.substring(0,10));
  273. industry.setTestHour(k.substring(0,13));
  274. //解析值
  275. String[] split = v.split("-");
  276. String type = split[0];
  277. BigDecimal value = new BigDecimal(split[1]);
  278. if ("信义污水厂JS_COD_Value".equals(type)) {
  279. industry.setJsCod(value);
  280. } else if ("信义污水厂JS_PH_Value".equals(type)) {
  281. industry.setJsPh(value);
  282. } else if ("信义污水厂JS_SS_Value".equals(type)) {
  283. industry.setJsSs(value);
  284. } else if ("信义污水厂JS_ZL_Value".equals(type)) {
  285. industry.setJsTp(value);
  286. } else if ("信义污水厂JS_ZA_Value".equals(type)) {
  287. industry.setJsTn(value);
  288. } else if ("信义污水厂JS_AD_Value".equals(type)) {
  289. industry.setJsNh3(value);
  290. } else if ("信义污水厂JS_T_Value".equals(type)) {
  291. industry.setJsSwPh(value);
  292. } else if ("信义污水厂进水泵房液位".equals(type)) {
  293. industry.setJsBfyw(value);
  294. } else if ("信义污水厂出水瞬时流量".equals(type)) {
  295. industry.setCsSlqc(value);
  296. } else if ("信义污水厂升级出水COD".equals(type)) {
  297. industry.setCsCod(value);
  298. } else if ("信义污水厂升级出水PH".equals(type)) {
  299. industry.setCsPh(value);
  300. } else if ("信义污水厂升级出水SS".equals(type)) {
  301. industry.setCsSs(value);
  302. } else if ("信义污水厂升级出水TN".equals(type)) {
  303. industry.setCsTn(value);
  304. } else if ("信义污水厂升级出水TP".equals(type)) {
  305. industry.setCsTp(value);
  306. } else if ("信义污水厂升级出水氨氮".equals(type)) {
  307. industry.setCsNh3(value);
  308. } else if ("信义污水厂AIT202_Value".equals(type)) {
  309. industry.setOneHyzdDo(value);
  310. } else if ("信义污水厂AIT203_Value".equals(type)) {
  311. industry.setOneHymdDo(value);
  312. } else if ("信义污水厂AIT207_Value".equals(type)) {
  313. industry.setTwoHyzdDo(value);
  314. } else if ("信义污水厂AIT206_Value".equals(type)) {
  315. industry.setTwoHymdDo(value);
  316. } else if ("信义污水厂AIT209_Value".equals(type)) {
  317. industry.setOneMlss(value);
  318. } else if ("信义污水厂AIT210_Value".equals(type)) {
  319. industry.setTwoMlss(value);
  320. } else if ("信义污水厂进水TDS".equals(type)) {
  321. industry.setJsTds(value);
  322. } else if ("信义污水厂FT101_Value".equals(type)) {
  323. industry.setJsSlq(value);
  324. } else if ("信义污水厂SWCHHYHLB1_R_Value".equals(type)) {
  325. industry.setNHlbOneGp(value);
  326. } else if ("信义污水厂SWCHHYHLB2_R_Value".equals(type)) {
  327. industry.setNHlbTwoGp(value);
  328. } else if ("信义污水厂SWCHHYHLB3_R_Value".equals(type)) {
  329. industry.setNHlbThreeGp(value);
  330. } else if ("信义污水厂SWCHHYHLB4_R_Value".equals(type)) {
  331. industry.setNHlbFourGp(value);
  332. } else if ("信义污水厂SWCHHYHLB5_R_Value".equals(type)) {
  333. industry.setNhlBFiveGp(value);
  334. } else if ("信义污水厂SWCHHYHLB6_R_Value".equals(type)) {
  335. industry.setNHlbSixGp(value);
  336. } else if ("信义污水厂SWCWNHLB1_R_Value".equals(type)) {
  337. industry.setWHlbOneGp(value);
  338. } else if ("信义污水厂SWCWNHLB2_R_Value".equals(type)) {
  339. industry.setWHlbTwoGp(value);
  340. } else if ("信义污水厂SWCWNHLB3_R_Value".equals(type)) {
  341. industry.setWHlbThreeGp(value);
  342. } else if ("信义污水厂SWCWNHLB4_R_Value".equals(type)) {
  343. industry.setWHlbFourGp(value);
  344. } else if ("信义污水厂SWCWNHLB5_R_Value".equals(type)) {
  345. industry.setWHlbFiveGp(value);
  346. } else if ("信义污水厂GFJ1_R_Value".equals(type)) {
  347. industry.setFjOne(value);
  348. } else if ("信义污水厂GFJ2_R_Value".equals(type)) {
  349. industry.setFjTwo(value);
  350. } else if ("信义污水厂GFJ3_R_Value".equals(type)) {
  351. industry.setFjThree(value);
  352. } else if ("信义污水厂GFJ4_R_Value".equals(type)) {
  353. industry.setFjFour(value);
  354. } else if ("信义污水厂GFJ5_R_Value".equals(type)) {
  355. industry.setFjFive(value);
  356. } else if ("信义污水厂GFJ6_R_Value".equals(type)) {
  357. industry.setFjSix(value);
  358. } else if ("信义污水厂GFJ1_KQLL_Value".equals(type)) {
  359. industry.setKqllOne(value);
  360. } else if ("信义污水厂GFJ2_KQLL_Value".equals(type)) {
  361. industry.setKqllTwo(value);
  362. } else if ("信义污水厂GFJ3_KQLL_Value".equals(type)) {
  363. industry.setKqllThree(value);
  364. } else if ("信义污水厂GFJ4_KQLL_Value".equals(type)) {
  365. industry.setKqllFour(value);
  366. } else if ("信义污水厂GFJ5_KQLL_Value".equals(type)) {
  367. industry.setKqllFive(value);
  368. } else if ("信义污水厂GFJ6_KQLL_Value".equals(type)) {
  369. industry.setKqllSix(value);
  370. }else if ("信义污水厂实际碳源加药量".equals(type)) {
  371. industry.setSJTYJLY(value);
  372. }else if ("信义污水厂除磷加药瞬时流量".equals(type)) {
  373. industry.setCLJYSSLL(value);
  374. }
  375. //只有最后一次才执行数据库添加
  376. if(finalJ == list.size()-1){
  377. //插入数据库
  378. xinyiIndustryMapper.insertTXinyiIndustry(industry);
  379. }
  380. });
  381. }
  382. }
  383. return "ok";
  384. }
  385. // @GetMapping("/dateUpdateCL")
  386. // public String dateUpdateCL() {
  387. // String fileName = "除磷加药瞬时流量";
  388. // //输入目录
  389. // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls");
  390. // //解析数据
  391. // List<List<Object>> readAll = reader.read();
  392. // if(!CollectionUtils.isEmpty(readAll)){
  393. // for (List<Object> objects : readAll) {
  394. // String time = "20" + objects.get(0) + " " + objects.get(1).toString().substring(0, 5);
  395. // System.out.println("time = " + time);
  396. // TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(time);
  397. // if(!Objects.isNull(uniqueTXinyiIndustry)){
  398. // System.out.println(objects.get(2));
  399. // BigDecimal CLJYSSLL = Objects.isNull(objects.get(2)) ? null : new BigDecimal(String.valueOf(objects.get(2)));
  400. // uniqueTXinyiIndustry.setCLJYSSLL(CLJYSSLL);
  401. // this.xinyiIndustryMapper.updateTXinyiIndustry(uniqueTXinyiIndustry);
  402. // }
  403. // }
  404. // }
  405. // return "ok";
  406. // }
  407. //
  408. //
  409. // @GetMapping("/dateUpdateSJTY")
  410. // public String dateUpdateSJTY() {
  411. // String fileName = "信义污水厂实际碳源加药量";
  412. // //输入目录
  413. // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls");
  414. // //解析数据
  415. // List<List<Object>> readAll = reader.read();
  416. // if(!CollectionUtils.isEmpty(readAll)){
  417. // int i = 0;
  418. // for (List<Object> objects : readAll) {
  419. // String format = "";
  420. // if(objects.get(0) instanceof String){
  421. // System.out.println("----------是字符串类型的");
  422. // String time = ((String) objects.get(0));
  423. // System.out.println("time = " + time);
  424. // format = time.replaceAll("-", "/").substring(0, 16);
  425. // }else if (objects.get(0) instanceof cn.hutool.core.date.DateTime){
  426. // System.out.println("++++++++++是日期类型的");
  427. // cn.hutool.core.date.DateTime time = (DateTime) objects.get(0);
  428. // System.out.println("time = " + time);
  429. // format = DateUtil.format(time, DateUtils.YYYYMMDDHHMM_TS);
  430. // System.out.println("format = " + format);
  431. // }else {
  432. // System.out.println(JSON.toJSONString(objects));
  433. // format = "";
  434. // i++;
  435. // }
  436. // TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(format);
  437. // if(!Objects.isNull(uniqueTXinyiIndustry)){
  438. // BigDecimal SJTYJLY = Objects.isNull(objects.get(1)) ? null : new BigDecimal(String.valueOf(objects.get(1)));
  439. // uniqueTXinyiIndustry.setSJTYJLY(SJTYJLY);
  440. // this.xinyiIndustryMapper.updateTXinyiIndustry(uniqueTXinyiIndustry);
  441. // }
  442. // }
  443. // System.out.println("i =" + i);
  444. // }
  445. // return "ok";
  446. // }
  447. //
  448. // //下面是新的 将一个小时的数据 更新到一个小时之内的所有的数据中
  449. // @GetMapping("/dateUpdateCLMinute")
  450. // public String dateUpdateCLMinute() {
  451. // String fileName = "除磷加药瞬时流量";
  452. // //输入目录
  453. // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls");
  454. // //解析数据
  455. // List<List<Object>> readAll = reader.read();
  456. // int i = 0;
  457. // if(!CollectionUtils.isEmpty(readAll)){
  458. // for (List<Object> objects : readAll) {
  459. // if(!Objects.isNull(objects.get(0)) && !Objects.isNull(objects.get(1))){
  460. // String beginTime = "20" + objects.get(0) + " " + objects.get(1).toString().substring(0, 5);
  461. // System.out.println("beginTime = " + beginTime);
  462. // String endTime = "20" + objects.get(0) + " " + objects.get(1).toString().substring(0, 3) + "59";
  463. // System.out.println("endTime = " + endTime);
  464. // //更新数据
  465. // System.out.println(objects.get(2));
  466. // //有特殊情况
  467. // if(Objects.isNull(objects.get(2)) || objects.get(2).toString().contains("-")){
  468. // System.out.println("存在特殊的情况,值包含-,不做更新");
  469. // i++;
  470. // }else{
  471. // this.xinyiIndustryMapper.updateTXinyiIndustryCLByBetweenTime(beginTime, endTime, new BigDecimal(String.valueOf(objects.get(2))));
  472. // }
  473. // }
  474. // }
  475. // }
  476. // System.out.println("i = " + i);
  477. // return "ok";
  478. // }
  479. //
  480. //
  481. // @GetMapping("/dateUpdateSJTYMinute")
  482. // public String dateUpdateSJTYMinute() {
  483. // String fileName = "信义污水厂实际碳源加药量";
  484. // //输入目录
  485. // ExcelReader reader = ExcelUtil.getReader("C:\\Users\\10109\\Desktop\\新程序\\" + fileName + ".xls");
  486. // //解析数据
  487. // List<List<Object>> readAll = reader.read();
  488. // if(!CollectionUtils.isEmpty(readAll)){
  489. // int i = 0;
  490. // for (List<Object> objects : readAll) {
  491. // String beginTime = "";
  492. // if(objects.get(0) instanceof String){
  493. // System.out.println("----------是字符串类型的");
  494. // String time = ((String) objects.get(0));
  495. //// System.out.println("time = " + time);
  496. // beginTime = time.replaceAll("-", "/").substring(0, 16);
  497. // }else if (objects.get(0) instanceof cn.hutool.core.date.DateTime){
  498. // System.out.println("++++++++++是日期类型的");
  499. // cn.hutool.core.date.DateTime time = (DateTime) objects.get(0);
  500. //// System.out.println("time = " + time);
  501. // beginTime = DateUtil.format(time, DateUtils.YYYYMMDDHHMM_TS);
  502. // System.out.println("beginTime = " + beginTime);
  503. // }else {
  504. // System.out.println(JSON.toJSONString(objects));
  505. // beginTime = "";
  506. // i++;
  507. // }
  508. // //endTime
  509. // String endTime = beginTime.substring(0, 14) + "59";
  510. // System.out.println("endTime = " + endTime);
  511. // //更新数据
  512. // BigDecimal sjtyjly = Objects.isNull(objects.get(1)) ? null : new BigDecimal(String.valueOf(objects.get(1)));
  513. // this.xinyiIndustryMapper.updateTXinyiIndustrySJByBetweenTime(beginTime, endTime, sjtyjly);
  514. // }
  515. // System.out.println("i =" + i);
  516. // }
  517. // return "ok";
  518. // }
  519. // @GetMapping("/dateUpdateSJTYMinute")
  520. // public String dateUpdateSJTYMinute() {
  521. // log.info("进入了手动处理两个值的操作~~~~~~~~");
  522. // File file = new File("/home/slibra/历史数据");
  523. // if(file.isDirectory()){
  524. // for (File listFile : file.listFiles()) {
  525. // // 输入目录
  526. // ExcelReader reader = ExcelUtil.getReader(listFile);
  527. // List<List<Object>> readAll = reader.read();
  528. // if(!CollectionUtils.isEmpty(readAll)){
  529. // for (int i = 3; i < readAll.size(); i++) {
  530. // //解析数据
  531. // List<Object> objects = readAll.get(i);
  532. // String time = "20" + objects.get(0).toString().replaceAll(" ", "") + " " + objects.get(1).toString().replaceAll(" ", "").substring(0, 5);
  533. //// System.out.println("time = " + time);
  534. // TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(time);
  535. // if(!Objects.isNull(uniqueTXinyiIndustry)){
  536. // TXinyiIndustry updateBean = new TXinyiIndustry();
  537. // updateBean.setID(uniqueTXinyiIndustry.getID());
  538. // BigDecimal CLJYSSLL = Objects.isNull(objects.get(2)) || String.valueOf(objects.get(2)).contains("-") ? null : new BigDecimal(String.valueOf(objects.get(2)));
  539. // updateBean.setCLJYSSLL(CLJYSSLL);
  540. // BigDecimal SJTYJLY = Objects.isNull(objects.get(3)) || String.valueOf(objects.get(3)).contains("-") ? null : new BigDecimal(String.valueOf(objects.get(3)));
  541. // updateBean.setSJTYJLY(SJTYJLY);
  542. // //如果两个都不为空再更新
  543. // if(!Objects.isNull(CLJYSSLL) || !Objects.isNull(SJTYJLY)){
  544. // this.xinyiIndustryMapper.updateTXinyiIndustry(updateBean);
  545. // }else{
  546. // log.error("要更新的两个字段全部为空--------");
  547. // }
  548. // }
  549. // }
  550. // }
  551. // }
  552. // }
  553. // return "ok";
  554. // }
  555. /**
  556. *
  557. * 从Excel读取数据 将新增的列数据更新到新的日报字段中
  558. * @return
  559. */
  560. @GetMapping("/dailyAddDataByExcel")
  561. public String dailyAddDataByExcel() {
  562. log.info("从Excel读取数据 将新增的列数据更新到新的日报字段中~~~~~~~~");
  563. File file = new File("/home/slibra/绝干泥量.xlsx");
  564. // File file = new File("C:\\Users\\10109\\Documents\\WeChat Files\\mz1010995810\\FileStorage\\File\\2024-05\\绝干泥量.xlsx");
  565. // 输入目录
  566. ExcelReader reader = ExcelUtil.getReader(file);
  567. List<List<Object>> readAll = reader.read();
  568. // log.info("Excel解析的结果为{}", JSON.toJSONString(readAll));
  569. if(!CollectionUtils.isEmpty(readAll)){
  570. for (int i = 1; i < readAll.size(); i++) {
  571. //解析数据
  572. List<Object> objects = readAll.get(i);
  573. String date = (String) objects.get(0);
  574. date = date.replaceAll("\\.", "/");
  575. date = handleDate(date);
  576. //用时间去查询 如果存在就更新,否则跳过
  577. List<TXinyiDaily> tXinyiDailies = this.xinyiDailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(date).build());
  578. if(CollectionUtils.isEmpty(tXinyiDailies)){
  579. log.error("没有查询到对应的历史数据,跳过~~~~~~{}", date);
  580. continue;
  581. }
  582. //目前集合就一个对象 以后可能会多个
  583. TXinyiDaily tXinyiDaily = tXinyiDailies.get(0);
  584. //出泥量
  585. Object o1 = objects.get(1);
  586. BigDecimal CHUNILIANG = null;
  587. if(o1 instanceof String){
  588. log.error("数据异常,解析为null");
  589. CHUNILIANG = null;
  590. }else if(o1 instanceof Double){
  591. CHUNILIANG = new BigDecimal((Double) o1);
  592. }else {
  593. log.error("错误的类型,不用解析了");
  594. CHUNILIANG = null;
  595. }
  596. //出泥含水率
  597. BigDecimal CNHSL = null;
  598. Object o2 = objects.get(2);
  599. if(o2 instanceof String){
  600. log.error("数据异常,解析为null");
  601. CNHSL = null;
  602. }else if(o2 instanceof Double){
  603. CNHSL = new BigDecimal((Double) o2);
  604. }else {
  605. log.error("错误的类型,不用解析了");
  606. CNHSL = null;
  607. }
  608. //干污泥量
  609. Object o3 = objects.get(3);
  610. BigDecimal GWNL = null;
  611. if(o3 instanceof String){
  612. log.error("数据异常,解析为null");
  613. GWNL = null;
  614. }else if(o3 instanceof Double){
  615. GWNL = new BigDecimal((Double) o3);
  616. }else {
  617. log.error("错误的类型,不用解析了");
  618. GWNL = null;
  619. }
  620. //更新数据
  621. tXinyiDaily.setCHUNILIANG(CHUNILIANG);
  622. tXinyiDaily.setCNHSL(CNHSL);
  623. tXinyiDaily.setGWNL(GWNL);
  624. this.xinyiDailyMapper.updateTXinyiDaily(tXinyiDaily);
  625. }
  626. }
  627. return "ok";
  628. }
  629. /**
  630. * 手动处理日报数据 增加两个字段 时间和小时
  631. * @return
  632. */
  633. @GetMapping("/dateUpdateDaily")
  634. public String dateUpdateDaily() {
  635. //获取全部数据
  636. List<TXinyiDaily> tXinyiDailies = this.xinyiDailyMapper.selectTXinyiDailyList(null);
  637. if(!CollectionUtils.isEmpty(tXinyiDailies)){
  638. for (TXinyiDaily tXinyiDaily : tXinyiDailies) {
  639. String handleTime = handleDate(tXinyiDaily.getTestTime());
  640. tXinyiDaily.setTestTime(handleTime);
  641. tXinyiDaily.setTestDate(handleTime);
  642. //更新
  643. this.xinyiDailyMapper.updateTXinyiDaily(tXinyiDaily);
  644. }
  645. }
  646. return "ok";
  647. }
  648. /**
  649. * 手动处理化验数据 增加两个字段 时间和小时
  650. * @return
  651. */
  652. @GetMapping("/dateUpdateHuaYan")
  653. public String dateUpdateHuaYan() {
  654. //获取全部数据
  655. List<TXinyiLaboratory> tXinyiLaboratories = this.xinyiLaboratoryMapper.selectTXinyiLaboratoryList(null);
  656. if(!CollectionUtils.isEmpty(tXinyiLaboratories)){
  657. for (TXinyiLaboratory tXinyiLaboratory : tXinyiLaboratories) {
  658. String handleTime = handleDate(tXinyiLaboratory.getTestTime());
  659. tXinyiLaboratory.setTestTime(handleTime);//到分为止
  660. tXinyiLaboratory.setTestDate(handleTime.substring(0, 10));
  661. tXinyiLaboratory.setTestHour(handleTime.substring(0, 13));
  662. //更新
  663. this.xinyiLaboratoryMapper.updateTXinyiLaboratory(tXinyiLaboratory);
  664. }
  665. }
  666. return "ok";
  667. }
  668. /**
  669. * 手动处理 工业库的 某个值,将历史数据全部都更新
  670. * @return
  671. */
  672. @GetMapping("/updateGYKSomeFields")
  673. public String updateGYKSomeFields() {
  674. //更新的某个指标
  675. String[] queryTags = {"信义污水厂_除磷P04预测值_"};
  676. //找到对应的数据,然后更新它
  677. // 给定时间段的起始时间和结束时间
  678. LocalDateTime startTime = LocalDateTime.parse("2022-07-01T00:00:00");
  679. LocalDateTime endTime = LocalDateTime.parse("2024-04-25T09:00:01");
  680. // 每个小时的时间格式
  681. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  682. // 循环按小时分割
  683. LocalDateTime currentHour = startTime;
  684. while (currentHour.isBefore(endTime)) {
  685. String begin = currentHour.format(formatter);
  686. String end = currentHour.plusDays(1).format(formatter);
  687. // 输出当前小时的起始时间和结束时间
  688. System.out.println("起始时间:" + begin);
  689. System.out.println("结束时间:" + end);
  690. // 当前小时加一小时,作为下一个小时的起始时间
  691. currentHour = currentHour.plusDays(1);
  692. //每个小时查询一次数据
  693. String url = "http://10.0.0.27:4568/api/v1/khquerydata";
  694. HashMap<String, Object> req = new HashMap<>();
  695. req.put("tagNames", queryTags);
  696. req.put("startTime", begin);
  697. req.put("endTime", end);
  698. req.put("recordNumbers", 100000);
  699. String body = HttpRequest.post(url).header("Authorization", "c2E6c2E=").header("clientName", "hongshan").body(JSON.toJSONString(req)).execute().body();
  700. // System.out.println("body = " + body);
  701. List<HashMap<String, String>> list = new ArrayList<>();
  702. //行转列数据处理
  703. for (String queryTag : queryTags) {
  704. JSONArray array = JSON.parseObject(body).getJSONArray(queryTag);
  705. //特殊数据处理一
  706. if(Objects.isNull(array) || array.isEmpty()){
  707. System.out.println(queryTag + "查询到了空的数据,跳过本次循环");
  708. continue;
  709. }
  710. int size = array.size();
  711. //特殊数据处理二
  712. if("0".equals(array.get(1) + "")){
  713. System.out.println(queryTag + "查询到了数据,但是数据集合只有一条,且都是0");
  714. continue;
  715. }
  716. //存放的数据集
  717. //利用map去重
  718. HashMap<String, String> map = new LinkedHashMap<>();
  719. for (int i = 2; i < size; i++) {
  720. // System.out.println(i + "" + array.get(i));
  721. JSONArray oneRecord = JSON.parseArray(JSON.toJSONString(array.get(i)));
  722. //处理为空或者为0的数据
  723. Object timeStampValue = oneRecord.get(2);
  724. if(Objects.isNull(timeStampValue) || "0".equals(timeStampValue + ""))
  725. continue;
  726. BigDecimal value = Objects.isNull(oneRecord.get(0)) ? null : new BigDecimal(oneRecord.get(0) + "");
  727. long timestamp = (long) timeStampValue;
  728. String format = DateUtil.format(new Date(timestamp), DateUtils.YYYYMMDDHH_TS);
  729. map.put(format, queryTag + "-" + value);
  730. }
  731. list.add(map);
  732. }
  733. Set<String> recordTimeSet = new HashSet<>();
  734. Map<String, TXinyiIndustry> recordMap = new HashMap<>();
  735. for (int i = 0; i < list.size(); i++) {
  736. HashMap<String, String> map = list.get(i);
  737. int finalJ = i;
  738. map.forEach((k, v) ->{
  739. TXinyiIndustry industry = null;
  740. if(!recordTimeSet.contains(k)){//第一次
  741. industry = new TXinyiIndustry();
  742. recordTimeSet.add(k);
  743. recordMap.put(k, industry);
  744. }else{
  745. industry = recordMap.get(k);
  746. }
  747. industry.setTestTime(k);
  748. //解析值
  749. String[] split = v.split("-");
  750. String type = split[0];
  751. BigDecimal value = new BigDecimal(split[1]);
  752. if ("信义污水厂_除磷P04预测值_".equals(type)) {
  753. industry.setCLP04YCZ(value);//目前值更新此字段
  754. }
  755. /*else if ("信义污水厂除磷加药瞬时流量".equals(type)) {
  756. industry.setCLJYSSLL(value);
  757. }*/
  758. //只有最后一次才执行数据库添加
  759. if(finalJ == list.size()-1){
  760. //先去查询数据库
  761. TXinyiIndustry uniqueTXinyiIndustry = this.xinyiIndustryMapper.getUniqueTXinyiIndustry(industry.getTestTime());
  762. if(Objects.isNull(uniqueTXinyiIndustry))
  763. log.error("查询到的工业库数据为null,化验时间为{}", industry.getTestTime());
  764. else {
  765. //防止其他信息被更新,新建对象
  766. TXinyiIndustry updateTXinyiIndustry = new TXinyiIndustry();
  767. //赋值
  768. updateTXinyiIndustry.setID(uniqueTXinyiIndustry.getID());
  769. updateTXinyiIndustry.setCLP04YCZ(industry.getCLP04YCZ());
  770. //更新数据库
  771. xinyiIndustryMapper.updateTXinyiIndustry(updateTXinyiIndustry);
  772. }
  773. }
  774. });
  775. }
  776. }
  777. return "ok";
  778. }
  779. /**
  780. * 手动处理 计算相关的数据,处理历史数据
  781. * @return
  782. */
  783. @GetMapping("/handleCalculateHistoryDates")
  784. public String handleCalculateHistoryDates() {
  785. log.info("进入了 手动处理-重置计算表历史数据");
  786. long begin = System.currentTimeMillis();
  787. List<TXinyiNormConfig> tXinyiNormConfigs = xinyiNormConfigMapper.selectTXinyiNormConfigList(null);
  788. if(CollectionUtils.isEmpty(tXinyiNormConfigs)) {
  789. log.error( "未查询到配置信息");
  790. return null;
  791. }
  792. TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0);
  793. int size = 500;
  794. int count = xinyiIndustryMapper.getCount();
  795. int num = ( count / size ) + 1;
  796. for (int i = 0; i < num; i++) {
  797. List<TXinyiIndustry> tXinyiIndustries = xinyiIndustryMapper.selectTXinyiIndustryListByPage(i * size, size);
  798. List<TXinyiCalculate> tempInsertData = new ArrayList<>();
  799. if (!CollectionUtils.isEmpty( tXinyiIndustries )) {
  800. for (int j = 0; j < tXinyiIndustries.size(); j++) {
  801. TXinyiIndustry tXinyiIndustry = tXinyiIndustries.get(j);
  802. //获取的一些配置信息
  803. BigDecimal nhlbqdsl = normConfig.getNHLBQDSL();
  804. BigDecimal nhlbdsjll = normConfig.getNHLBDSJLL();
  805. BigDecimal nhlbgzxl = normConfig.getNHLBGZXL();
  806. BigDecimal whlbqdsl = normConfig.getWHLBQDSL();
  807. BigDecimal whlbdsjll = normConfig.getWHLBDSJLL();
  808. BigDecimal whlbgzxl = normConfig.getWHLBGZXL();
  809. BigDecimal gfjgzts = normConfig.getGFJGZTS();
  810. BigDecimal gfjckll = normConfig.getGFJCKLL();
  811. BigDecimal fcxbsjll = normConfig.getFCXBSJLL();
  812. BigDecimal fclbsl = normConfig.getFCLBSL();
  813. BigDecimal fcxbgzxl = normConfig.getFCXBGZXL();
  814. //结算结果
  815. TXinyiCalculate tXinyiCalculate = new TXinyiCalculate();
  816. //时间相关
  817. tXinyiCalculate.setTestDate(tXinyiIndustry.getTestDate());
  818. tXinyiCalculate.setTestHour(tXinyiIndustry.getTestHour());
  819. tXinyiCalculate.setTestTime(tXinyiIndustry.getTestTime());
  820. //获取最新的一条日报信息
  821. TXinyiDaily tXinyiDaily = this.xinyiDailyMapper.getDetailByDay(tXinyiIndustry.getTestDate());
  822. if(Objects.isNull(tXinyiDaily)){
  823. //理论不会出现
  824. log.error("没有日报数据,取最新的");
  825. tXinyiDaily = this.xinyiDailyMapper.selectNewestData();
  826. }
  827. BigDecimal jsBod5 = tXinyiDaily.getJsBod5();
  828. BigDecimal csBod5 = tXinyiDaily.getCsBod5();
  829. BigDecimal whlR = tXinyiDaily.getWhlR();
  830. BigDecimal oneMlvss = tXinyiDaily.getShcHyOneMlvss();
  831. BigDecimal twoMlvss = tXinyiDaily.getShcHyTwoMlvss();
  832. BigDecimal avgMlvss = null;
  833. if(!Objects.isNull(oneMlvss) && !Objects.isNull(twoMlvss))
  834. avgMlvss = ((oneMlvss.add(twoMlvss)).divide(new BigDecimal(2),4, RoundingMode.HALF_UP));
  835. BigDecimal oneMlss = tXinyiDaily.getShcHyOneMlss();
  836. BigDecimal twoMlss = tXinyiDaily.getShcHyTwoMlss();
  837. BigDecimal avgMlss = null;
  838. if(!Objects.isNull(oneMlss) && !Objects.isNull(twoMlss))
  839. avgMlss = ((oneMlss.add(twoMlss)).divide(new BigDecimal(NUMBER_2),NUMBER_SCALE_4, RoundingMode.HALF_UP));
  840. //工业库的指标
  841. BigDecimal jsTn = tXinyiIndustry.getJsTn();
  842. BigDecimal jsTp = tXinyiIndustry.getJsTp();
  843. BigDecimal jsCod = tXinyiIndustry.getJsCod();
  844. BigDecimal jsSlq = tXinyiIndustry.getJsSlq();
  845. //计算
  846. if(!Objects.isNull(jsBod5)){
  847. if(!Objects.isNull(jsTn) && jsTn.compareTo(BigDecimal.ZERO) > 0)
  848. tXinyiCalculate.setJsTdb(jsBod5.divide(jsTn, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  849. if(!Objects.isNull(jsTp) && jsTp.compareTo(BigDecimal.ZERO) > 0)
  850. tXinyiCalculate.setJsTlb(jsBod5.divide(jsTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  851. if(!Objects.isNull(jsCod) && jsCod.compareTo(BigDecimal.ZERO) > 0)
  852. tXinyiCalculate.setJsBodBCod(jsBod5.divide(jsCod, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  853. if(!Objects.isNull(csBod5) && !Objects.isNull(avgMlss) && avgMlss.compareTo(BigDecimal.ZERO) > 0 && !Objects.isNull(jsSlq) && jsSlq.compareTo(BigDecimal.ZERO) > 0)
  854. 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));
  855. }
  856. if(!Objects.isNull(avgMlss) && avgMlss.compareTo(BigDecimal.ZERO) > 0 && !Objects.isNull(avgMlvss) && avgMlvss.compareTo(BigDecimal.ZERO) > 0)
  857. tXinyiCalculate.setHFXWNNDZB(avgMlvss.divide(avgMlss, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  858. if(!Objects.isNull(jsSlq) && jsSlq.compareTo(BigDecimal.ZERO) > 0){
  859. tXinyiCalculate.setYyqHrt(new BigDecimal(YYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  860. tXinyiCalculate.setQyqHrt(new BigDecimal(QYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  861. tXinyiCalculate.setHyqHrt(new BigDecimal(HYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  862. // 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));
  863. tXinyiCalculate.setGSLS(jsSlq.divide(GSLS_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  864. 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));
  865. 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));
  866. 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));
  867. tXinyiCalculate.setXlcscBmfh(jsSlq.divide(XLCSCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  868. tXinyiCalculate.setXlcscHrt(XLCSCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  869. tXinyiCalculate.setCccdcBmfh(jsSlq.divide(CCCDCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  870. tXinyiCalculate.setCccdcHrt(CCCDCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  871. tXinyiCalculate.setEccBmfh(jsSlq.divide(ECCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  872. tXinyiCalculate.setEccHrt(ECCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  873. //2024年7月1日17:16:16 计算逻辑调整
  874. if(!Objects.isNull(whlR) && avgMlss != null && jsSlq != null) {
  875. 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));
  876. }
  877. tXinyiCalculate.setClsnJcsj(CLSNJCSJ_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  878. tXinyiCalculate.setXgcdcQsqSsls(jsSlq.multiply(XGCDCQSQSSLS_LAST));
  879. //2024年6月29日15:18:01 增加几个新的计算指标
  880. if(!Objects.isNull(nhlbqdsl) && !Objects.isNull(nhlbdsjll) && !Objects.isNull(nhlbgzxl))
  881. tXinyiCalculate.setNHLB(nhlbqdsl.multiply(nhlbdsjll).multiply(nhlbgzxl).multiply(BigDecimal_100).divide(jsSlq, 4, RoundingMode.HALF_UP));
  882. if(!Objects.isNull(whlbqdsl) && !Objects.isNull(whlbdsjll) && !Objects.isNull(whlbgzxl))
  883. tXinyiCalculate.setWHLB(whlbqdsl.multiply(whlbdsjll).multiply(whlbgzxl).multiply(BigDecimal_100).divide(jsSlq, 4, RoundingMode.HALF_UP));
  884. if(!Objects.isNull(gfjgzts) && !Objects.isNull(gfjckll))
  885. tXinyiCalculate.setQSB(gfjgzts.multiply(gfjckll).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
  886. if(!Objects.isNull(fcxbsjll) && !Objects.isNull(fclbsl) && !Objects.isNull(fcxbgzxl)){
  887. BigDecimal fcxsl = fcxbsjll.multiply(fclbsl).multiply(fcxbgzxl);
  888. tXinyiCalculate.setFCXSL(fcxsl);
  889. //2024年7月3日10:54:28 额外再增加一个字段
  890. tXinyiCalculate.setFCXSLBL(fcxsl.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100));
  891. }
  892. //2024年7月11日15:43:47 之前给的外回流比计算不准确,额外一个字段记录新的外回流比
  893. BigDecimal divide = jsSlq.divide(DECIMAL_2, NUMBER_SCALE_4, RoundingMode.HALF_UP);
  894. if(divide.compareTo(DECIMAL_1500) < 0)
  895. tXinyiCalculate.setWhlRN(DECIMAL_1200.divide(divide, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100));
  896. else
  897. tXinyiCalculate.setWhlRN(DECIMAL_1620.divide(divide, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100));
  898. }
  899. tempInsertData.add(tXinyiCalculate);
  900. xinyiCalculateMapper.insertTXinyiCalculate(tXinyiCalculate);
  901. }
  902. // xinyiCalculateMapper.insertBatchData(tempInsertData);
  903. // return tXinyiCalculate;
  904. }
  905. }
  906. long end = System.currentTimeMillis();
  907. return "ok;耗时:" + (end - begin) /1000 + "秒。";
  908. }
  909. public void main(String[] args) {
  910. // handleBigTableDayHistoryData();
  911. // HandleDataController handleDataController = new HandleDataController();
  912. //
  913. // handleDataController.handleBigTableDayHistoryData();
  914. // File file = new File("C:\\Users\\10109\\Desktop\\新程序\\历史数据");
  915. // if(file.isDirectory()){
  916. // for (File listFile : file.listFiles()) {
  917. //// System.out.println(listFile.getName());
  918. // ExcelReader reader = ExcelUtil.getReader(listFile);
  919. // List<List<Object>> readAll = reader.read();
  920. // for (int i = 3; i < 10; i++) {
  921. // System.out.println(readAll.get(i));
  922. // }
  923. // System.out.println("------------------");
  924. // }
  925. // }
  926. String str = "2022/07/11 19:00";
  927. // String str = "2022/7/1";
  928. // String str = "0:0:1";
  929. // String newStr = handleDate(str);
  930. // System.out.println(newStr);
  931. // System.out.println(str.substring(0, 12));
  932. // System.out.println(str.substring(0, 9));
  933. // System.out.println(handleDate("2024-3-9"));
  934. System.out.println(handleDate("2023/12/26 02:00"));
  935. System.out.println(handleDate("2023/12/26 02:00").substring(0, 10));
  936. System.out.println(handleDate("2023/12/26 02:00").substring(0, 13));
  937. }
  938. public static String handleDate(String str){
  939. StringBuilder sb = new StringBuilder();
  940. if(str.contains(" ")){//包含空格 就是年月日时分秒了
  941. String[] split = str.split(" ");
  942. addBeforeZero(sb, split[0], "/");
  943. sb.append(" ");
  944. addBeforeZero(sb, split[1], ":");
  945. }else{
  946. if(str.contains("/")){//年月日
  947. addBeforeZero(sb, str, "/");
  948. }else if(str.contains(":")){//时分秒
  949. addBeforeZero(sb, str, ":");
  950. }else if(str.contains("-")){//只有年月日
  951. addBeforeZero(sb, str, "-");
  952. }else {
  953. sb.append(str);
  954. }
  955. }
  956. return sb.toString();
  957. }
  958. public static StringBuilder addBeforeZero(StringBuilder sb, String str, String tag){
  959. String[] split = str.split(tag);
  960. int length = split.length;
  961. for (int i = 0; i < length; i++) {
  962. String value = split[i];
  963. Integer intValue = Integer.parseInt(value);
  964. if(intValue < 10 && value.length() == 1){////防止有正确的情况 额外再补充字符串
  965. sb.append(0).append(value);
  966. }else{
  967. sb.append(value);
  968. }
  969. if(i < length-1){
  970. sb.append(tag);
  971. }
  972. }
  973. return sb;
  974. }
  975. public BigDecimal getListAvg (Collection<BigDecimal> bigDecimals) {
  976. if (bigDecimals.isEmpty()) {
  977. return null;
  978. }
  979. BigDecimal sum = bigDecimals.stream()
  980. .reduce(BigDecimal.ZERO, BigDecimal::add);
  981. int size = bigDecimals.size();
  982. return sum.divide(new BigDecimal(size), 6, RoundingMode.HALF_UP);
  983. }
  984. public String formatList(List<BigDecimal> list) {
  985. if (CollectionUtils.isEmpty(list)) {
  986. return null;
  987. }
  988. boolean isNullList = list.stream().allMatch(x -> x == null);
  989. return isNullList ? null : list.toString();
  990. }
  991. /**
  992. * 处理big_table_month历史数据
  993. * @return
  994. */
  995. @GetMapping("/handleBigTableMonthHistoryData")
  996. public String handleBigTableMonthHistoryData() {
  997. log.info("进入了处理big_table_month历史数据");
  998. long begin = System.currentTimeMillis();
  999. List<TXinyiBigTableMonth> tXinyiBigTableDayList = tXinyiBigTableDayMapper.selectTXinyiBigTableDayByMonthAvg();
  1000. if ( !CollectionUtils.isEmpty(tXinyiBigTableDayList) ) {
  1001. for (int i = 0; i < tXinyiBigTableDayList.size(); i++) {
  1002. TXinyiBigTableMonth tableMonth = tXinyiBigTableDayList.get(i);
  1003. ArrayList<BigDecimal> gyHycRjyAll = new ArrayList<>();
  1004. ArrayList<BigDecimal> gyHycRjyZdAll = new ArrayList<>();
  1005. ArrayList<BigDecimal> gyHycWnndAll = new ArrayList<>();
  1006. ArrayList<BigDecimal> rbHycRjyAll = new ArrayList<>();
  1007. ArrayList<BigDecimal> rbHycWnndAll = new ArrayList<>();
  1008. ArrayList<BigDecimal> rbYycRjyAll = new ArrayList<>();
  1009. ArrayList<BigDecimal> rbQycRjyAll = new ArrayList<>();
  1010. ArrayList<BigDecimal> rbWncjbAll = new ArrayList<>();
  1011. ArrayList<BigDecimal> rbWntjzsAll = new ArrayList<>();
  1012. ArrayList<BigDecimal> rbHfxwnndAll = new ArrayList<>();
  1013. ArrayList<BigDecimal> hyHycxsyAll = new ArrayList<>();
  1014. ArrayList<BigDecimal> hyQyanAll = new ArrayList<>();
  1015. ArrayList<BigDecimal> hyQyckxsyAll = new ArrayList<>();
  1016. ArrayList<BigDecimal> hyHyzlsyAll = new ArrayList<>();
  1017. gyHycRjyAll.add(tableMonth.getGyOneHymdDo());
  1018. gyHycRjyAll.add(tableMonth.getGyTwoHymdDo());
  1019. gyHycRjyZdAll.add(tableMonth.getGyOneHyzdDo());
  1020. gyHycRjyZdAll.add(tableMonth.getGyTwoHyzdDo());
  1021. gyHycWnndAll.add(tableMonth.getGyOneMlss());
  1022. gyHycWnndAll.add(tableMonth.getGyTwoMlss());
  1023. rbHycRjyAll.add(tableMonth.getRbShcHyOneDo());
  1024. rbHycRjyAll.add(tableMonth.getRbShcHyTwoDo());
  1025. rbHycWnndAll.add(tableMonth.getRbShcHyOneMlss());
  1026. rbHycWnndAll.add(tableMonth.getRbShcHyTwoMlss());
  1027. rbYycRjyAll.add(tableMonth.getRbShcYyOneDo());
  1028. rbYycRjyAll.add(tableMonth.getRbShcYyTwoDo());
  1029. rbQycRjyAll.add(tableMonth.getRbShcQyOneDo());
  1030. rbQycRjyAll.add(tableMonth.getRbShcQyTwoDo());
  1031. rbWncjbAll.add(tableMonth.getRbShcHyOneSv());
  1032. rbWncjbAll.add(tableMonth.getRbShcHyTwoSv());
  1033. rbWntjzsAll.add(tableMonth.getRbShcHyOneSvi());
  1034. rbWntjzsAll.add(tableMonth.getRbShcHyTwoSvi());
  1035. rbHfxwnndAll.add(tableMonth.getRbShcHyOneMlvss());
  1036. rbHfxwnndAll.add(tableMonth.getRbShcHyTwoMlvss());
  1037. hyHycxsyAll.add(tableMonth.getHyNo3Hlj1Jqr());
  1038. hyHycxsyAll.add(tableMonth.getHyNo3Hlj2Jqr());
  1039. hyQyanAll.add(tableMonth.getHyNh31Jqr());
  1040. hyQyanAll.add(tableMonth.getHyNh32Jqr());
  1041. hyQyckxsyAll.add(tableMonth.getHyNo3Qyc1Jqr());
  1042. hyQyckxsyAll.add(tableMonth.getHyNo3Qyc2Jqr());
  1043. hyHyzlsyAll.add(tableMonth.getHyTpHl1Jqr());
  1044. hyHyzlsyAll.add(tableMonth.getHyTpHl2Jqr());
  1045. tableMonth.setGyHycRjyAll(formatList(gyHycRjyAll));
  1046. tableMonth.setGyHycRjyZdAll(formatList(gyHycRjyZdAll));
  1047. tableMonth.setGyHycWnndAll(formatList(gyHycWnndAll));
  1048. tableMonth.setRbHycRjyAll(formatList(rbHycRjyAll));
  1049. tableMonth.setRbHycWnndAll(formatList(rbHycWnndAll));
  1050. tableMonth.setRbYycRjyAll(formatList(rbYycRjyAll));
  1051. tableMonth.setRbQycRjyAll(formatList(rbQycRjyAll));
  1052. tableMonth.setRbWncjbAll(formatList(rbWncjbAll));
  1053. tableMonth.setRbWntjzsAll(formatList(rbWntjzsAll));
  1054. tableMonth.setRbHfxwnndAll(formatList(rbHfxwnndAll));
  1055. tableMonth.setHyHycxsyAll(formatList(hyHycxsyAll));
  1056. tableMonth.setHyQyanAll(formatList(hyQyanAll));
  1057. tableMonth.setHyQyckxsyAll(formatList(hyQyckxsyAll));
  1058. tableMonth.setHyHyzlsyAll(formatList(hyHyzlsyAll));
  1059. tXinyiBigTableMonthMapper.insertTXinyiBigTableMonth(tableMonth);
  1060. }
  1061. }
  1062. long end = System.currentTimeMillis();
  1063. return "ok;耗时:" + (end - begin) / 1000 + "秒。";
  1064. }
  1065. /**
  1066. * 处理big_table_day历史数据
  1067. * @return
  1068. */
  1069. @GetMapping("/handleBigTableDayHistoryData")
  1070. public String handleBigTableDayHistoryData() {
  1071. log.info("进入了 处理big_table_day历史数据");
  1072. long begin = System.currentTimeMillis();
  1073. List<TXinyiBigTableHour> tXinyiBigTableHours = tXinyiBigTableHourMapper.selectTXinyiBigTableHourByTestDate();
  1074. if ( !CollectionUtils.isEmpty(tXinyiBigTableHours) ) {
  1075. List<TXinyiBigTableDay> bigTableDayList = new ArrayList<>();
  1076. for (int i = 0; i < tXinyiBigTableHours.size(); i++) {
  1077. TXinyiBigTableHour tXinyiBigTableHour = tXinyiBigTableHours.get(i);
  1078. String testDate = tXinyiBigTableHour.getTestDate();
  1079. TXinyiBigTableDay tableDay = tXinyiBigTableDayMapper.selectTXinyiBigTableHourAvg(testDate);
  1080. if (!Objects.isNull(tableDay)) {
  1081. ArrayList<BigDecimal> gyHycRjyAll = new ArrayList<>();
  1082. ArrayList<BigDecimal> gyHycRjyZdAll = new ArrayList<>();
  1083. ArrayList<BigDecimal> gyHycWnndAll = new ArrayList<>();
  1084. ArrayList<BigDecimal> rbHycRjyAll = new ArrayList<>();
  1085. ArrayList<BigDecimal> rbHycWnndAll = new ArrayList<>();
  1086. ArrayList<BigDecimal> rbYycRjyAll = new ArrayList<>();
  1087. ArrayList<BigDecimal> rbQycRjyAll = new ArrayList<>();
  1088. ArrayList<BigDecimal> rbWncjbAll = new ArrayList<>();
  1089. ArrayList<BigDecimal> rbWntjzsAll = new ArrayList<>();
  1090. ArrayList<BigDecimal> rbHfxwnndAll = new ArrayList<>();
  1091. ArrayList<BigDecimal> hyHycxsyAll = new ArrayList<>();
  1092. ArrayList<BigDecimal> hyQyanAll = new ArrayList<>();
  1093. ArrayList<BigDecimal> hyQyckxsyAll = new ArrayList<>();
  1094. ArrayList<BigDecimal> hyHyzlsyAll = new ArrayList<>();
  1095. gyHycRjyAll.add(tableDay.getGyOneHymdDo());
  1096. gyHycRjyAll.add(tableDay.getGyTwoHymdDo());
  1097. gyHycRjyZdAll.add(tableDay.getGyOneHyzdDo());
  1098. gyHycRjyZdAll.add(tableDay.getGyTwoHyzdDo());
  1099. gyHycWnndAll.add(tableDay.getGyOneMlss());
  1100. gyHycWnndAll.add(tableDay.getGyTwoMlss());
  1101. rbHycRjyAll.add(tableDay.getRbShcHyOneDo());
  1102. rbHycRjyAll.add(tableDay.getRbShcHyTwoDo());
  1103. rbHycWnndAll.add(tableDay.getRbShcHyOneMlss());
  1104. rbHycWnndAll.add(tableDay.getRbShcHyTwoMlss());
  1105. rbYycRjyAll.add(tableDay.getRbShcYyOneDo());
  1106. rbYycRjyAll.add(tableDay.getRbShcYyTwoDo());
  1107. rbQycRjyAll.add(tableDay.getRbShcQyOneDo());
  1108. rbQycRjyAll.add(tableDay.getRbShcQyTwoDo());
  1109. rbWncjbAll.add(tableDay.getRbShcHyOneSv());
  1110. rbWncjbAll.add(tableDay.getRbShcHyTwoSv());
  1111. rbWntjzsAll.add(tableDay.getRbShcHyOneSvi());
  1112. rbWntjzsAll.add(tableDay.getRbShcHyTwoSvi());
  1113. rbHfxwnndAll.add(tableDay.getRbShcHyOneMlvss());
  1114. rbHfxwnndAll.add(tableDay.getRbShcHyTwoMlvss());
  1115. hyHycxsyAll.add(tableDay.getHyNo3Hlj1Jqr());
  1116. hyHycxsyAll.add(tableDay.getHyNo3Hlj2Jqr());
  1117. hyQyanAll.add(tableDay.getHyNh31Jqr());
  1118. hyQyanAll.add(tableDay.getHyNh32Jqr());
  1119. hyQyckxsyAll.add(tableDay.getHyNo3Qyc1Jqr());
  1120. hyQyckxsyAll.add(tableDay.getHyNo3Qyc2Jqr());
  1121. hyHyzlsyAll.add(tableDay.getHyTpHl1Jqr());
  1122. hyHyzlsyAll.add(tableDay.getHyTpHl2Jqr());
  1123. tableDay.setGyHycRjyAll(formatList(gyHycRjyAll));
  1124. tableDay.setGyHycRjyZdAll(formatList(gyHycRjyZdAll));
  1125. tableDay.setGyHycWnndAll(formatList(gyHycWnndAll));
  1126. tableDay.setRbHycRjyAll(formatList(rbHycRjyAll));
  1127. tableDay.setRbHycWnndAll(formatList(rbHycWnndAll));
  1128. tableDay.setRbYycRjyAll(formatList(rbYycRjyAll));
  1129. tableDay.setRbQycRjyAll(formatList(rbQycRjyAll));
  1130. tableDay.setRbWncjbAll(formatList(rbWncjbAll));
  1131. tableDay.setRbWntjzsAll(formatList(rbWntjzsAll));
  1132. tableDay.setRbHfxwnndAll(formatList(rbHfxwnndAll));
  1133. tableDay.setHyHycxsyAll(formatList(hyHycxsyAll));
  1134. tableDay.setHyQyanAll(formatList(hyQyanAll));
  1135. tableDay.setHyQyckxsyAll(formatList(hyQyckxsyAll));
  1136. tableDay.setHyHyzlsyAll(formatList(hyHyzlsyAll));
  1137. tableDay.setTestDate(testDate);
  1138. bigTableDayList.add(tableDay);
  1139. }
  1140. }
  1141. if (!CollectionUtils.isEmpty(bigTableDayList)) {
  1142. SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
  1143. TXinyiBigTableDayMapper sqlSessionMapper = sqlSession.getMapper(TXinyiBigTableDayMapper.class);
  1144. bigTableDayList.forEach(sqlSessionMapper::insertTXinyiBigTableDay);
  1145. sqlSession.commit();
  1146. sqlSession.close();
  1147. }
  1148. }
  1149. long end = System.currentTimeMillis();
  1150. return "ok;耗时:" + (end - begin) / 1000 + "秒。";
  1151. }
  1152. /**
  1153. * 处理big_table_hour历史数据
  1154. * @return
  1155. */
  1156. @GetMapping("/handleBigTableHourHistoryData")
  1157. public String handleBigTableHourHistoryData () {
  1158. log.info("进入了 处理big_table_hour历史数据");
  1159. long begin = System.currentTimeMillis();
  1160. int size = 500;
  1161. int count = xinyiIndustryMapper.getCount();
  1162. int num = ( count / size ) + 1;
  1163. for (int i = 0; i < num; i++) {
  1164. List<TXinyiIndustry> tXinyiIndustries = xinyiIndustryMapper.selectTXinyiIndustryListByPage(i * size, size);
  1165. if ( !CollectionUtils.isEmpty(tXinyiIndustries) ) {
  1166. List<TXinyiBigTableHour> tXinyiBigTableHourList = new ArrayList();
  1167. for (int j = 0; j < tXinyiIndustries.size(); j++) {
  1168. TXinyiBigTableHour xinyiBigTableHour = new TXinyiBigTableHour();
  1169. TXinyiIndustry tXinyiIndustry = tXinyiIndustries.get(j);
  1170. String testHour = tXinyiIndustry.getTestHour();
  1171. String testDate = tXinyiIndustry.getTestDate();
  1172. // 处理工业库
  1173. handleIndustryData(xinyiBigTableHour, tXinyiIndustry);
  1174. // 处理计算表
  1175. List<TXinyiCalculate> tXinyiCalculates = xinyiCalculateMapper.selectTXinyiCalculateList(TXinyiCalculate.builder().testHour(testHour).build());
  1176. if ( !CollectionUtils.isEmpty(tXinyiCalculates) ) {
  1177. TXinyiCalculate tXinyiCalculate = tXinyiCalculates.get(0);
  1178. handleCalculateData(xinyiBigTableHour, tXinyiCalculate);
  1179. }
  1180. // 处理日报表
  1181. List<TXinyiDaily> tXinyiDailies = xinyiDailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(testDate).build());
  1182. if ( !CollectionUtils.isEmpty(tXinyiDailies) ) {
  1183. TXinyiDaily tXinyiDaily = tXinyiDailies.get(0);
  1184. handleDailyData(xinyiBigTableHour, tXinyiDaily);
  1185. }
  1186. // 处理化验室
  1187. List<TXinyiRobot> tXinyiRobots = xinyiRobotMapper.selectTXinyiRobotList(TXinyiRobot.builder().testHour(testHour).build());
  1188. if (!CollectionUtils.isEmpty(tXinyiRobots)) {
  1189. TXinyiRobot tXinyiRobot = tXinyiRobots.get(0);
  1190. handleRobotData(xinyiBigTableHour, tXinyiRobot);
  1191. }
  1192. // TXinyiRobot tXinyiRobot = xinyiRobotMapper.selectTXinyiRobotByAvg(TXinyiRobot.builder().testHour(testHour).build());
  1193. // if ( !Objects.isNull(tXinyiRobot) ) {
  1194. // handleRobotData(xinyiBigTableHour, tXinyiRobot);
  1195. // }
  1196. tXinyiBigTableHourList.add(xinyiBigTableHour);
  1197. }
  1198. if (!CollectionUtils.isEmpty(tXinyiBigTableHourList)) {
  1199. SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
  1200. TXinyiBigTableHourMapper sqlSessionMapper = sqlSession.getMapper(TXinyiBigTableHourMapper.class);
  1201. tXinyiBigTableHourList.stream().forEach(item -> sqlSessionMapper.insertTXinyiBigTableHour(item));
  1202. sqlSession.commit();
  1203. sqlSession.close();
  1204. }
  1205. }
  1206. }
  1207. long end = System.currentTimeMillis();
  1208. return "ok;耗时:" + (end - begin) /1000 + "秒。";
  1209. }
  1210. // 处理工业库
  1211. private void handleIndustryData(TXinyiBigTableHour xinyiBigTableHour, TXinyiIndustry tXinyiIndustry) {
  1212. xinyiBigTableHour.setTestDate(tXinyiIndustry.getTestDate());
  1213. xinyiBigTableHour.setTestHour(tXinyiIndustry.getTestHour());
  1214. xinyiBigTableHour.setGyJsCod(tXinyiIndustry.getJsCod());
  1215. xinyiBigTableHour.setGyJsPh(tXinyiIndustry.getJsPh());
  1216. xinyiBigTableHour.setGyJsSs(tXinyiIndustry.getJsSs());
  1217. xinyiBigTableHour.setGyJsTp(tXinyiIndustry.getJsTp());
  1218. xinyiBigTableHour.setGyJsTn(tXinyiIndustry.getJsTn());
  1219. xinyiBigTableHour.setGyJsNh3(tXinyiIndustry.getJsNh3());
  1220. xinyiBigTableHour.setGyJsSwPh(tXinyiIndustry.getJsSwPh());
  1221. xinyiBigTableHour.setGyJsBfyw(tXinyiIndustry.getJsBfyw());
  1222. xinyiBigTableHour.setGyCsSlqc(tXinyiIndustry.getCsSlqc());
  1223. xinyiBigTableHour.setGyCsCod(tXinyiIndustry.getCsCod());
  1224. xinyiBigTableHour.setGyCsPh(tXinyiIndustry.getCsPh());
  1225. xinyiBigTableHour.setGyCsSs(tXinyiIndustry.getCsSs());
  1226. xinyiBigTableHour.setGyCsTn(tXinyiIndustry.getCsTn());
  1227. xinyiBigTableHour.setGyCsTp(tXinyiIndustry.getCsTp());
  1228. xinyiBigTableHour.setGyCsNh3(tXinyiIndustry.getCsNh3());
  1229. xinyiBigTableHour.setGyOneHyzdDo(tXinyiIndustry.getOneHyzdDo());
  1230. xinyiBigTableHour.setGyOneHymdDo(tXinyiIndustry.getOneHymdDo());
  1231. xinyiBigTableHour.setGyTwoHyzdDo(tXinyiIndustry.getTwoHyzdDo());
  1232. xinyiBigTableHour.setGyTwoHymdDo(tXinyiIndustry.getTwoHymdDo());
  1233. xinyiBigTableHour.setGyOneMlss(tXinyiIndustry.getOneMlss());
  1234. xinyiBigTableHour.setGyTwoMlss(tXinyiIndustry.getTwoMlss());
  1235. xinyiBigTableHour.setGyJsTds(tXinyiIndustry.getJsTds());
  1236. xinyiBigTableHour.setGyJsSlq(tXinyiIndustry.getJsSlq());
  1237. xinyiBigTableHour.setGyNHlbOneGp(tXinyiIndustry.getNHlbOneGp());
  1238. xinyiBigTableHour.setGyNHlbTwoGp(tXinyiIndustry.getNHlbTwoGp());
  1239. xinyiBigTableHour.setGyNHlbThreeGp(tXinyiIndustry.getNHlbThreeGp());
  1240. xinyiBigTableHour.setGyNHlbFourGp(tXinyiIndustry.getNHlbFourGp());
  1241. xinyiBigTableHour.setGyNhlBFiveGp(tXinyiIndustry.getNhlBFiveGp());
  1242. xinyiBigTableHour.setGyNHlbSixGp(tXinyiIndustry.getNHlbSixGp());
  1243. xinyiBigTableHour.setGyWHlbOneGp(tXinyiIndustry.getWHlbOneGp());
  1244. xinyiBigTableHour.setGyWHlbTwoGp(tXinyiIndustry.getWHlbTwoGp());
  1245. xinyiBigTableHour.setGyWHlbThreeGp(tXinyiIndustry.getWHlbThreeGp());
  1246. xinyiBigTableHour.setGyWHlbFourGp(tXinyiIndustry.getWHlbFourGp());
  1247. xinyiBigTableHour.setGyWHlbFiveGp(tXinyiIndustry.getWHlbFiveGp());
  1248. xinyiBigTableHour.setGyFjOne(tXinyiIndustry.getFjOne());
  1249. xinyiBigTableHour.setGyFjTwo(tXinyiIndustry.getFjTwo());
  1250. xinyiBigTableHour.setGyFjThree(tXinyiIndustry.getFjThree());
  1251. xinyiBigTableHour.setGyFjFour(tXinyiIndustry.getFjFour());
  1252. xinyiBigTableHour.setGyFjFive(tXinyiIndustry.getFjFive());
  1253. xinyiBigTableHour.setGyFjSix(tXinyiIndustry.getFjSix());
  1254. xinyiBigTableHour.setGyKqllOne(tXinyiIndustry.getKqllOne());
  1255. xinyiBigTableHour.setGyKqllTwo(tXinyiIndustry.getKqllTwo());
  1256. xinyiBigTableHour.setGyKqllThree(tXinyiIndustry.getKqllThree());
  1257. xinyiBigTableHour.setGyKqllFour(tXinyiIndustry.getKqllFour());
  1258. xinyiBigTableHour.setGyKqllFive(tXinyiIndustry.getKqllFive());
  1259. xinyiBigTableHour.setGyKqllSix(tXinyiIndustry.getKqllSix());
  1260. xinyiBigTableHour.setGySjtyjly(tXinyiIndustry.getSJTYJLY());
  1261. xinyiBigTableHour.setGyCljyssll(tXinyiIndustry.getCLJYSSLL());
  1262. xinyiBigTableHour.setGyHycRjyAll(tXinyiIndustry.getHycRjyAll());
  1263. xinyiBigTableHour.setGyHycRjyZdAll(tXinyiIndustry.getHycRjyZdAll());
  1264. xinyiBigTableHour.setGyHycWnndAll(tXinyiIndustry.getHycWnndAll());
  1265. xinyiBigTableHour.setGyClP04Ycz(tXinyiIndustry.getCLP04YCZ());
  1266. }
  1267. // 处理计算表
  1268. private void handleCalculateData(TXinyiBigTableHour xinyiBigTableHour, TXinyiCalculate xinyiCalculate) {
  1269. xinyiBigTableHour.setJsJsTdb(xinyiCalculate.getJsTdb());
  1270. xinyiBigTableHour.setJsJsTlb(xinyiCalculate.getJsTlb());
  1271. xinyiBigTableHour.setJsJsBodBCod(xinyiCalculate.getJsBodBCod());
  1272. xinyiBigTableHour.setJsYyqHrt(xinyiCalculate.getYyqHrt());
  1273. xinyiBigTableHour.setJsQyqHrt(xinyiCalculate.getQyqHrt());
  1274. xinyiBigTableHour.setJsHyqHrt(xinyiCalculate.getHyqHrt());
  1275. xinyiBigTableHour.setJsHfxwnndzb(xinyiCalculate.getHFXWNNDZB());
  1276. xinyiBigTableHour.setJsFM(xinyiCalculate.getFM());
  1277. xinyiBigTableHour.setJsGsls(xinyiCalculate.getGSLS());
  1278. xinyiBigTableHour.setJsGslsOne(xinyiCalculate.getGslsOne());
  1279. xinyiBigTableHour.setJsGslsTwo(xinyiCalculate.getGslsTwo());
  1280. xinyiBigTableHour.setJsXgsGsls(xinyiCalculate.getXgsGsls());
  1281. xinyiBigTableHour.setJsXlcscBmfh(xinyiCalculate.getXlcscBmfh());
  1282. xinyiBigTableHour.setJsXlcscHrt(xinyiCalculate.getXlcscHrt());
  1283. xinyiBigTableHour.setJsCccdcBmfh(xinyiCalculate.getCccdcBmfh());
  1284. xinyiBigTableHour.setJsCccdcHrt(xinyiCalculate.getCccdcHrt());
  1285. xinyiBigTableHour.setJsEccBmfh(xinyiCalculate.getEccBmfh());
  1286. xinyiBigTableHour.setJsEccHrt(xinyiCalculate.getEccHrt());
  1287. xinyiBigTableHour.setJsEccGtfh(xinyiCalculate.getEccGtfh());
  1288. xinyiBigTableHour.setJsClsnJcsj(xinyiCalculate.getClsnJcsj());
  1289. xinyiBigTableHour.setJsXgcdcQsqSsls(xinyiCalculate.getXgcdcQsqSsls());
  1290. xinyiBigTableHour.setJsWhlb(xinyiCalculate.getWHLB());
  1291. xinyiBigTableHour.setJsNhlb(xinyiCalculate.getNHLB());
  1292. xinyiBigTableHour.setJsWdscnl(xinyiCalculate.getWDSCNL());
  1293. xinyiBigTableHour.setJsQsb(xinyiCalculate.getQSB());
  1294. xinyiBigTableHour.setJsFcxsl(xinyiCalculate.getFCXSL());
  1295. xinyiBigTableHour.setJsFcxslbl(xinyiCalculate.getFCXSLBL());
  1296. xinyiBigTableHour.setJsWhlbRN(xinyiCalculate.getWhlRN());
  1297. }
  1298. // 处理日报
  1299. private void handleDailyData(TXinyiBigTableHour tXinyiBigTableHour, TXinyiDaily tXinyiDaily) {
  1300. tXinyiBigTableHour.setRbJsCod(tXinyiDaily.getJsCod());
  1301. tXinyiBigTableHour.setRbJsPh(tXinyiDaily.getJsPh());
  1302. tXinyiBigTableHour.setRbJsBod5(tXinyiDaily.getJsBod5());
  1303. tXinyiBigTableHour.setRbJsSs(tXinyiDaily.getJsSs());
  1304. tXinyiBigTableHour.setRbJsNh3(tXinyiDaily.getJsNh3());
  1305. tXinyiBigTableHour.setRbJsTn(tXinyiDaily.getJsTn());
  1306. tXinyiBigTableHour.setRbJsTp(tXinyiDaily.getJsTp());
  1307. tXinyiBigTableHour.setRbJsDcgj(tXinyiDaily.getJsDcgj());
  1308. tXinyiBigTableHour.setRbCsCod(tXinyiDaily.getCsCod());
  1309. tXinyiBigTableHour.setRbCsPh(tXinyiDaily.getCsPh());
  1310. tXinyiBigTableHour.setRbCsBod5(tXinyiDaily.getCsBod5());
  1311. tXinyiBigTableHour.setRbCsSs(tXinyiDaily.getCsSs());
  1312. tXinyiBigTableHour.setRbCsNh3(tXinyiDaily.getCsNh3());
  1313. tXinyiBigTableHour.setRbCsTn(tXinyiDaily.getCsTn());
  1314. tXinyiBigTableHour.setRbCsTp(tXinyiDaily.getCsTp());
  1315. tXinyiBigTableHour.setRbCsDcgj(tXinyiDaily.getCsDcgj());
  1316. tXinyiBigTableHour.setRbJsSw(tXinyiDaily.getJsSw());
  1317. tXinyiBigTableHour.setRbCsSw(tXinyiDaily.getCsSw());
  1318. tXinyiBigTableHour.setRbShcOnePh(tXinyiDaily.getShcOnePh());
  1319. tXinyiBigTableHour.setRbShcTwoPh(tXinyiDaily.getShcTwoPh());
  1320. tXinyiBigTableHour.setRbShcHyOneSv(tXinyiDaily.getShcHyOneSv());
  1321. tXinyiBigTableHour.setRbShcHyTwoSv(tXinyiDaily.getShcHyTwoSv());
  1322. tXinyiBigTableHour.setRbShcHyOneSvi(tXinyiDaily.getShcHyOneSvi());
  1323. tXinyiBigTableHour.setRbShcHyTwoSvi(tXinyiDaily.getShcHyTwoSvi());
  1324. tXinyiBigTableHour.setRbShcHyOneMlss(tXinyiDaily.getShcHyOneMlss());
  1325. tXinyiBigTableHour.setRbShcHyTwoMlss(tXinyiDaily.getShcHyTwoMlss());
  1326. tXinyiBigTableHour.setRbShcHyOneMlvss(tXinyiDaily.getShcHyOneMlvss());
  1327. tXinyiBigTableHour.setRbShcHyTwoMlvss(tXinyiDaily.getShcHyTwoMlvss());
  1328. tXinyiBigTableHour.setRbShcYyOneDo(tXinyiDaily.getShcYyOneDo());
  1329. tXinyiBigTableHour.setRbShcYyTwoDo(tXinyiDaily.getShcYyTwoDo());
  1330. tXinyiBigTableHour.setRbShcQyOneDo(tXinyiDaily.getShcQyOneDo());
  1331. tXinyiBigTableHour.setRbShcQyTwoDo(tXinyiDaily.getShcQyTwoDo());
  1332. tXinyiBigTableHour.setRbShcHyOneDo(tXinyiDaily.getShcHyOneDo());
  1333. tXinyiBigTableHour.setRbShcHyTwoDo(tXinyiDaily.getShcHyTwoDo());
  1334. tXinyiBigTableHour.setRbJsl(tXinyiDaily.getJSL());
  1335. tXinyiBigTableHour.setRbCsl(tXinyiDaily.getCSL());
  1336. tXinyiBigTableHour.setRbSdclcxsl(tXinyiDaily.getSDCLCXSL());
  1337. tXinyiBigTableHour.setRbQsb(tXinyiDaily.getQSB());
  1338. tXinyiBigTableHour.setRbFM(tXinyiDaily.getFM());
  1339. tXinyiBigTableHour.setRbYyHrt(tXinyiDaily.getYyHrt());
  1340. tXinyiBigTableHour.setRbHyHrt(tXinyiDaily.getHyHrt());
  1341. tXinyiBigTableHour.setRbQyHrt(tXinyiDaily.getQyHrt());
  1342. tXinyiBigTableHour.setRbNhlR(tXinyiDaily.getNhlR());
  1343. tXinyiBigTableHour.setRbWhlR(tXinyiDaily.getWhlR());
  1344. tXinyiBigTableHour.setRbSrt(tXinyiDaily.getSRT());
  1345. tXinyiBigTableHour.setRbCnl(tXinyiDaily.getCNL());
  1346. tXinyiBigTableHour.setRbTyqBod5Tn(tXinyiDaily.getTyqBod5Tn());
  1347. tXinyiBigTableHour.setRbTyhBod5Tn(tXinyiDaily.getTyhBod5Tn());
  1348. tXinyiBigTableHour.setRbHycRjyAll(tXinyiDaily.getHycRjyAll());
  1349. tXinyiBigTableHour.setRbHycWnndAll(tXinyiDaily.getHycWnndAll());
  1350. tXinyiBigTableHour.setRbYycRjyAll(tXinyiDaily.getYycRjyAll());
  1351. tXinyiBigTableHour.setRbQycRjyAll(tXinyiDaily.getQycRjyAll());
  1352. tXinyiBigTableHour.setRbWncjbAll(tXinyiDaily.getWncjbAll());
  1353. tXinyiBigTableHour.setRbWntjzsAll(tXinyiDaily.getWntjzsAll());
  1354. tXinyiBigTableHour.setRbHfxwnndAll(tXinyiDaily.getHfxwnndAll());
  1355. tXinyiBigTableHour.setRbChuniliang(tXinyiDaily.getCHUNILIANG());
  1356. tXinyiBigTableHour.setRbCnhsl(tXinyiDaily.getCNHSL());
  1357. tXinyiBigTableHour.setRbGwnl(tXinyiDaily.getGWNL());
  1358. tXinyiBigTableHour.setRbDf(tXinyiDaily.getDF());
  1359. tXinyiBigTableHour.setRbXnjf(tXinyiDaily.getXNJF());
  1360. tXinyiBigTableHour.setRbClf(tXinyiDaily.getCLF());
  1361. tXinyiBigTableHour.setRbTyf(tXinyiDaily.getTYF());
  1362. tXinyiBigTableHour.setRbXdjf(tXinyiDaily.getXDJF());
  1363. tXinyiBigTableHour.setRbQtyjf(tXinyiDaily.getQTYJF());
  1364. tXinyiBigTableHour.setRbCnf(tXinyiDaily.getCNF());
  1365. tXinyiBigTableHour.setRbZlsf(tXinyiDaily.getZLSF());
  1366. tXinyiBigTableHour.setRbZjcb(tXinyiDaily.getZJCB());
  1367. tXinyiBigTableHour.setRbDwcb(tXinyiDaily.getDWCB());
  1368. }
  1369. // 处理化验室
  1370. private void handleRobotData(TXinyiBigTableHour tXinyiBigTableHour, TXinyiRobot tXinyiRobot) {
  1371. tXinyiBigTableHour.setHyCodYb(tXinyiRobot.getCodYb());
  1372. tXinyiBigTableHour.setHyCodJqr(tXinyiRobot.getCodJqr());
  1373. tXinyiBigTableHour.setHyCodYz(tXinyiRobot.getCodYz());
  1374. tXinyiBigTableHour.setHyTpHl1Jqr(tXinyiRobot.getTpHl1Jqr());
  1375. tXinyiBigTableHour.setHyTpHl2Jqr(tXinyiRobot.getTpHl2Jqr());
  1376. tXinyiBigTableHour.setHyTpRccJqr(tXinyiRobot.getTpRccJqr());
  1377. tXinyiBigTableHour.setHyTp1Yz(tXinyiRobot.getTp1Yz());
  1378. tXinyiBigTableHour.setHyTp2Yz(tXinyiRobot.getTp2Yz());
  1379. tXinyiBigTableHour.setHyTpRccYz(tXinyiRobot.getTpRccYz());
  1380. tXinyiBigTableHour.setHyNh31Jqr(tXinyiRobot.getNh31Jqr());
  1381. tXinyiBigTableHour.setHyNh32Jqr(tXinyiRobot.getNh32Jqr());
  1382. tXinyiBigTableHour.setHyNh31Yz(tXinyiRobot.getNh31Yz());
  1383. tXinyiBigTableHour.setHyNo3Hlc1Yz(tXinyiRobot.getNo3Hlc1Yz());
  1384. tXinyiBigTableHour.setHyNh32Yz(tXinyiRobot.getNh32Yz());
  1385. tXinyiBigTableHour.setHyNo3Hlc2Yz(tXinyiRobot.getNo3Hlc2Yz());
  1386. tXinyiBigTableHour.setHyNo3Hlj1Jqr(tXinyiRobot.getNo3Hlj1Jqr());
  1387. tXinyiBigTableHour.setHyNo3Hlj2Jqr(tXinyiRobot.getNo3Hlj2Jqr());
  1388. tXinyiBigTableHour.setHyTyll(tXinyiRobot.getTYLL());
  1389. tXinyiBigTableHour.setHyNo3Qyc1Jqr(tXinyiRobot.getNo3Qyc1Jqr());
  1390. tXinyiBigTableHour.setHyNo3Qyc2Jqr(tXinyiRobot.getNo3Qyc2Jqr());
  1391. tXinyiBigTableHour.setHyNo3Qyc1Yz(tXinyiRobot.getNo3Qyc1Yz());
  1392. tXinyiBigTableHour.setHyNo3Qyc2Yz(tXinyiRobot.getNo3Qyc2Yz());
  1393. tXinyiBigTableHour.setHyJsll(tXinyiRobot.getJSLL());
  1394. tXinyiBigTableHour.setHyHycxsyAll(tXinyiRobot.getHycxsyAll());
  1395. tXinyiBigTableHour.setHyQyanAll(tXinyiRobot.getQyanAll());
  1396. tXinyiBigTableHour.setHyQyckxsyAll(tXinyiRobot.getQyckxsyAll());
  1397. tXinyiBigTableHour.setHyHyzlsyAll(tXinyiRobot.getHyzlsyAll());
  1398. }
  1399. private void handlePredictorWarning(String[] split, String hour, String task, List<TXinyiIndustry> tXinyiIndustries6, List<TXinyiRobot> tXinyiRobots6, String date) {
  1400. String[] hours = hour.split(",");
  1401. //2024年6月23日18:28:55 因为存在跨天问题 所以日期也是逗号拼接的
  1402. String[] dates = date.split(",");
  1403. //2024年6月18日13:41:10 统一格式,否则查询不到结果
  1404. //2024年6月18日10:36:49 增加预测记录,预测准确度计算等
  1405. TXinyiForecastComparison tXinyiForecastComparison = new TXinyiForecastComparison();
  1406. //2024年7月11日17:04:11 TP改为zlsy
  1407. tXinyiForecastComparison.setCategory(BusinessEnum.BigModelForecastEnum.TP.getCode().equalsIgnoreCase(task) ? BusinessEnum.BigModelForecastEnum.ZLSY.getCode() : task);
  1408. tXinyiForecastComparison.setForecastTimeOne(dates[0].replaceAll("-", "/") + " " + hours[0]);
  1409. tXinyiForecastComparison.setForecastTimeTwo(dates[1].replaceAll("-", "/") + " " + hours[1]);
  1410. tXinyiForecastComparison.setForecastTimeThree(dates[2].replaceAll("-", "/") + " " + hours[2]);
  1411. tXinyiForecastComparison.setHsForecastOne(new BigDecimal(split[0]));
  1412. tXinyiForecastComparison.setHsForecastTwo(new BigDecimal(split[1]));
  1413. tXinyiForecastComparison.setHsForecastThree(new BigDecimal(split[2]));
  1414. //2024年6月20日14:28:31 增加字段,方便查询
  1415. tXinyiForecastComparison.setRemark(DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYYMMDDHH_TS));
  1416. //防止工业库挂掉以后持续预测同一数据
  1417. //2024年6月20日14:59:23 因为预测bug(以工业库为准,假如工业库挂了,获取的全是挂了时间段后的三小时) 判断是否生成过了否则不生成
  1418. TXinyiForecastComparison tXinyiForecastComparisonReq = new TXinyiForecastComparison();
  1419. //2024年08月20日16:24:56 因为remark存放的是当前时间,也就是每个小时的,所以都是不一样的,修复此bug
  1420. // tXinyiForecastComparisonReq.setRemark(tXinyiForecastComparison.getRemark());
  1421. tXinyiForecastComparisonReq.setCategory(tXinyiForecastComparison.getCategory());
  1422. //2024年7月18日15:04:37 如果工业库挂掉以后,不管什么时刻,调用预测返回的未来三小时时间都是一样的,再增加一个查询条件
  1423. tXinyiForecastComparisonReq.setForecastTimeOne(tXinyiForecastComparison.getForecastTimeOne());//一个时刻就可以了 没必要再比较第二和第三时刻了。
  1424. List<TXinyiForecastComparison> tXinyiForecastComparisons = this.xinyiForecastComparisonService.selectTXinyiForecastComparisonList(tXinyiForecastComparisonReq);
  1425. if(!CollectionUtils.isEmpty(tXinyiForecastComparisons)){
  1426. log.error("预测已经进行过了,无需重复运行~~~~~~~~~~~@@@@@@@,要保存的预测数据为{}", JSON.toJSONString(tXinyiForecastComparison));
  1427. return;
  1428. }
  1429. //获取配置表
  1430. List<TXinyiNormConfig> tXinyiNormConfigs = this.xinyiNormConfigMapper.selectTXinyiNormConfigList(null);
  1431. if(CollectionUtils.isEmpty(tXinyiNormConfigs)) {
  1432. log.error( "未查询到配置信息");
  1433. return;
  1434. }
  1435. TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0);
  1436. //获取最新的工业库的数据
  1437. // TXinyiIndustry tXinyiIndustry = this.xinyiIndustryMapper.selectTXinyiIndustryNewest();
  1438. //2024年7月18日10:29:44 因为获取了最新的六条数据,所以无需再查询最新的数据了
  1439. TXinyiIndustry tXinyiIndustry = tXinyiIndustries6.get(0);
  1440. TXinyiRobot tXinyiRobot = tXinyiRobots6.get(0);
  1441. List<ChartBasic> chartsDataList = new ArrayList<>(9);
  1442. if(BusinessEnum.BigModelForecastEnum.COD.getCode().equals(task)){
  1443. //同时调用跃渊的预测接口 保存记录值
  1444. try {
  1445. 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);
  1446. if(!StringUtils.isBlank(result)){
  1447. JSONArray array = JSON.parseArray(result);
  1448. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1449. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1450. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1451. }
  1452. } catch (Exception e) {
  1453. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1454. }
  1455. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1456. BigDecimal cscodBzz = normConfig.getCscodBzz();
  1457. BigDecimal cscodGkz = normConfig.getCscodGkz();
  1458. //处理展示数据
  1459. for (int i = 0; i < tXinyiIndustries6.size(); i++) {
  1460. TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i);
  1461. ChartBasic chartBasic = new ChartBasic();
  1462. chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11));
  1463. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsCod(), INT_2));
  1464. chartsDataList.add(chartBasic);
  1465. }
  1466. for (int i = 0; i < split.length; i++) {
  1467. String val = split[i];
  1468. ChartBasic chartBasic = new ChartBasic();
  1469. chartBasic.setTime(hours[i]);
  1470. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1471. chartsDataList.add(chartBasic);
  1472. }
  1473. ryTask.handleXinYiWarningsYC(cscodBzz, split, cscodGkz, BusinessEnum.WarningCategoryEnum.CS_COD_YC.getCode(), hour, normConfig, tXinyiIndustry.getCsCod(), tXinyiIndustry, chartsDataList, date);
  1474. }else if(BusinessEnum.BigModelForecastEnum.SS.getCode().equals(task)){
  1475. //同时调用跃渊的预测接口 保存记录值
  1476. try {
  1477. 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);
  1478. if(!StringUtils.isBlank(result)){
  1479. JSONArray array = JSON.parseArray(result);
  1480. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1481. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1482. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1483. }
  1484. } catch (Exception e) {
  1485. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1486. }
  1487. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1488. BigDecimal csSSBzz = normConfig.getCsssBzz();
  1489. BigDecimal csssGkz = normConfig.getCsssGkz();
  1490. //处理展示数据
  1491. for (int i = 0; i < tXinyiIndustries6.size(); i++) {
  1492. TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i);
  1493. ChartBasic chartBasic = new ChartBasic();
  1494. chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11));
  1495. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsSs(), INT_2));
  1496. chartsDataList.add(chartBasic);
  1497. }
  1498. for (int i = 0; i < split.length; i++) {
  1499. String val = split[i];
  1500. ChartBasic chartBasic = new ChartBasic();
  1501. chartBasic.setTime(hours[i]);
  1502. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1503. chartsDataList.add(chartBasic);
  1504. }
  1505. ryTask.handleXinYiWarningsYC(csSSBzz, split, csssGkz, BusinessEnum.WarningCategoryEnum.CS_SS_YC.getCode(), hour, normConfig, tXinyiIndustry.getCsSs(), tXinyiIndustry, chartsDataList, date);
  1506. }/*else if(BusinessEnum.BigModelForecastEnum.TN.getCode().equals(task)){
  1507. //同时调用跃渊的预测接口 保存记录值
  1508. try {
  1509. 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);
  1510. if(!StringUtils.isBlank(result)){
  1511. JSONArray array = JSON.parseArray(result);
  1512. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1513. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1514. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1515. }
  1516. } catch (Exception e) {
  1517. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1518. }
  1519. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1520. BigDecimal cszzBzz = normConfig.getCszzBzz();
  1521. BigDecimal cszzGkz = normConfig.getCszzGkz();
  1522. //处理展示数据
  1523. for (int i = 0; i < tXinyiIndustries6.size(); i++) {
  1524. TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i);
  1525. ChartBasic chartBasic = new ChartBasic();
  1526. chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11));
  1527. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsTn(), INT_2));
  1528. chartsDataList.add(chartBasic);
  1529. }
  1530. for (int i = 0; i < split.length; i++) {
  1531. String val = split[i];
  1532. ChartBasic chartBasic = new ChartBasic();
  1533. chartBasic.setTime(hours[i]);
  1534. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1535. chartsDataList.add(chartBasic);
  1536. }
  1537. handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.CS_TN_YC.getCode(), hour, normConfig,tXinyiIndustry.getCsCod(), tXinyiIndustry, chartsDataList, date);
  1538. }*/else if(BusinessEnum.BigModelForecastEnum.TP.getCode().equals(task)){
  1539. //同时调用跃渊的预测接口 保存记录值
  1540. try {
  1541. 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);
  1542. if(!StringUtils.isBlank(result)){
  1543. JSONArray array = JSON.parseArray(result);
  1544. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1545. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1546. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1547. }
  1548. } catch (Exception e) {
  1549. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1550. }
  1551. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1552. BigDecimal cszlBzz = normConfig.getCszlBzz();
  1553. BigDecimal cszlGkz = normConfig.getCszlGkz();
  1554. //处理展示数据
  1555. for (int i = 0; i < tXinyiRobots6.size(); i++) {
  1556. TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i);
  1557. ChartBasic chartBasic = new ChartBasic();
  1558. chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11));
  1559. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getTpRccJqr(), INT_2));
  1560. chartsDataList.add(chartBasic);
  1561. }
  1562. for (int i = 0; i < split.length; i++) {
  1563. String val = split[i];
  1564. ChartBasic chartBasic = new ChartBasic();
  1565. chartBasic.setTime(hours[i]);
  1566. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1567. chartsDataList.add(chartBasic);
  1568. }
  1569. ryTask.handleXinYiWarningsYC(cszlBzz, split, cszlGkz, CS_TP_YC.getCode(), hour, normConfig, tXinyiRobot.getTpRccJqr(), tXinyiIndustry, chartsDataList, date);
  1570. }else if(BusinessEnum.BigModelForecastEnum.NH3.getCode().equals(task)){
  1571. //同时调用跃渊的预测接口 保存记录值
  1572. try {
  1573. 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);
  1574. if(!StringUtils.isBlank(result)){
  1575. JSONArray array = JSON.parseArray(result);
  1576. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1577. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1578. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1579. }
  1580. } catch (Exception e) {
  1581. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1582. }
  1583. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1584. BigDecimal csadBzz = normConfig.getCsadBzz();
  1585. BigDecimal csadGkz = normConfig.getCsadGkz();
  1586. //处理展示数据
  1587. for (int i = 0; i < tXinyiIndustries6.size(); i++) {
  1588. TXinyiIndustry tXinyiIndustryTemp = tXinyiIndustries6.get(5 - i);
  1589. ChartBasic chartBasic = new ChartBasic();
  1590. chartBasic.setTime(tXinyiIndustryTemp.getTestHour().substring(11));
  1591. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiIndustryTemp.getCsNh3(), INT_2));
  1592. chartsDataList.add(chartBasic);
  1593. }
  1594. for (int i = 0; i < split.length; i++) {
  1595. String val = split[i];
  1596. ChartBasic chartBasic = new ChartBasic();
  1597. chartBasic.setTime(hours[i]);
  1598. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1599. chartsDataList.add(chartBasic);
  1600. }
  1601. ryTask.handleXinYiWarningsYC(csadBzz, split, csadGkz, BusinessEnum.WarningCategoryEnum.CS_AD_YC.getCode(), hour, normConfig, tXinyiIndustry.getCsNh3(), tXinyiIndustry, chartsDataList, date);
  1602. }else if(BusinessEnum.BigModelForecastEnum.XSY1.getCode().equals(task)){
  1603. //2024年6月21日14:57:02 红杉的出水总氮预测改成 不用工业库的,用化验科的两个xsy 相关指标
  1604. //同时调用跃渊的预测接口 保存记录值
  1605. try {
  1606. 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);
  1607. if(!StringUtils.isBlank(result)){
  1608. JSONArray array = JSON.parseArray(result);
  1609. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1610. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1611. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1612. }
  1613. } catch (Exception e) {
  1614. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1615. }
  1616. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1617. /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK);
  1618. BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/
  1619. //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警
  1620. BigDecimal cszzBzz = normConfig.getCszzBzz();
  1621. BigDecimal cszzGkz = normConfig.getCszzGkz();
  1622. //处理展示数据
  1623. for (int i = 0; i < tXinyiRobots6.size(); i++) {
  1624. TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i);
  1625. ChartBasic chartBasic = new ChartBasic();
  1626. chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11));
  1627. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Hlj1Jqr(), INT_2));
  1628. chartsDataList.add(chartBasic);
  1629. }
  1630. for (int i = 0; i < split.length; i++) {
  1631. String val = split[i];
  1632. ChartBasic chartBasic = new ChartBasic();
  1633. chartBasic.setTime(hours[i]);
  1634. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1635. chartsDataList.add(chartBasic);
  1636. }
  1637. ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.CS_XSY_1_YC.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj1Jqr(), tXinyiIndustry, chartsDataList, date);
  1638. }else if(BusinessEnum.BigModelForecastEnum.XSY2.getCode().equals(task)){
  1639. //同时调用跃渊的预测接口 保存记录值
  1640. try {
  1641. 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);
  1642. if(!StringUtils.isBlank(result)){
  1643. JSONArray array = JSON.parseArray(result);
  1644. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1645. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1646. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1647. }
  1648. } catch (Exception e) {
  1649. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1650. }
  1651. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1652. /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK);
  1653. BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/
  1654. //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警
  1655. BigDecimal cszzBzz = normConfig.getCszzBzz();
  1656. BigDecimal cszzGkz = normConfig.getCszzGkz();
  1657. //处理展示数据
  1658. for (int i = 0; i < tXinyiRobots6.size(); i++) {
  1659. TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i);
  1660. ChartBasic chartBasic = new ChartBasic();
  1661. chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11));
  1662. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Hlj2Jqr(), INT_2));
  1663. chartsDataList.add(chartBasic);
  1664. }
  1665. for (int i = 0; i < split.length; i++) {
  1666. String val = split[i];
  1667. ChartBasic chartBasic = new ChartBasic();
  1668. chartBasic.setTime(hours[i]);
  1669. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1670. chartsDataList.add(chartBasic);
  1671. }
  1672. ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.CS_XSY_2_YC.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date);
  1673. }else if(BusinessEnum.BigModelForecastEnum.QYXSY1.getCode().equals(task)){
  1674. //同时调用跃渊的预测接口 保存记录值
  1675. /*try {
  1676. 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);
  1677. if(!StringUtils.isBlank(result)){
  1678. JSONArray array = JSON.parseArray(result);
  1679. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1680. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1681. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1682. }
  1683. } catch (Exception e) {
  1684. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1685. }*/
  1686. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1687. /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK);
  1688. BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/
  1689. //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警
  1690. BigDecimal cszzBzz = normConfig.getCszzBzz();
  1691. BigDecimal cszzGkz = normConfig.getCszzGkz();
  1692. //处理展示数据
  1693. for (int i = 0; i < tXinyiRobots6.size(); i++) {
  1694. TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i);
  1695. ChartBasic chartBasic = new ChartBasic();
  1696. chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11));
  1697. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Qyc1Jqr(), INT_2));
  1698. chartsDataList.add(chartBasic);
  1699. }
  1700. for (int i = 0; i < split.length; i++) {
  1701. String val = split[i];
  1702. ChartBasic chartBasic = new ChartBasic();
  1703. chartBasic.setTime(hours[i]);
  1704. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1705. chartsDataList.add(chartBasic);
  1706. }
  1707. ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.QYCXSY_1.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date);
  1708. }else if(BusinessEnum.BigModelForecastEnum.QYXSY2.getCode().equals(task)){
  1709. //同时调用跃渊的预测接口 保存记录值
  1710. /*try {
  1711. 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);
  1712. if(!StringUtils.isBlank(result)){
  1713. JSONArray array = JSON.parseArray(result);
  1714. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1715. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1716. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1717. }
  1718. } catch (Exception e) {
  1719. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1720. }*/
  1721. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1722. /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK);
  1723. BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/
  1724. //2024年7月11日17:19:47 1#好氧硝酸盐、2#好氧硝酸盐使用总氮标准值和管控值来预警
  1725. BigDecimal cszzBzz = normConfig.getCszzBzz();
  1726. BigDecimal cszzGkz = normConfig.getCszzGkz();
  1727. //处理展示数据
  1728. for (int i = 0; i < tXinyiRobots6.size(); i++) {
  1729. TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i);
  1730. ChartBasic chartBasic = new ChartBasic();
  1731. chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11));
  1732. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNo3Qyc2Jqr(), INT_2));
  1733. chartsDataList.add(chartBasic);
  1734. }
  1735. for (int i = 0; i < split.length; i++) {
  1736. String val = split[i];
  1737. ChartBasic chartBasic = new ChartBasic();
  1738. chartBasic.setTime(hours[i]);
  1739. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1740. chartsDataList.add(chartBasic);
  1741. }
  1742. ryTask.handleXinYiWarningsYC(cszzBzz, split, cszzGkz, BusinessEnum.WarningCategoryEnum.QYCXSY_2.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date);
  1743. }else if(BusinessEnum.BigModelForecastEnum.QYNH31.getCode().equals(task)){
  1744. //同时调用跃渊的预测接口 保存记录值
  1745. /*try {
  1746. 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);
  1747. if(!StringUtils.isBlank(result)){
  1748. JSONArray array = JSON.parseArray(result);
  1749. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1750. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1751. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1752. }
  1753. } catch (Exception e) {
  1754. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1755. }*/
  1756. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1757. /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK);
  1758. BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/
  1759. //2024年09月08日11:21:25 采用出水氨氮的标准值和管控值
  1760. BigDecimal csadBzz = normConfig.getCsadBzz();
  1761. BigDecimal csadGkz = normConfig.getCsadGkz();
  1762. //处理展示数据
  1763. for (int i = 0; i < tXinyiRobots6.size(); i++) {
  1764. TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i);
  1765. ChartBasic chartBasic = new ChartBasic();
  1766. chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11));
  1767. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNh31Jqr(), INT_2));
  1768. chartsDataList.add(chartBasic);
  1769. }
  1770. for (int i = 0; i < split.length; i++) {
  1771. String val = split[i];
  1772. ChartBasic chartBasic = new ChartBasic();
  1773. chartBasic.setTime(hours[i]);
  1774. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1775. chartsDataList.add(chartBasic);
  1776. }
  1777. ryTask.handleXinYiWarningsYC(csadBzz, split, csadGkz, BusinessEnum.WarningCategoryEnum.QYAD_1.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date);
  1778. }else if(BusinessEnum.BigModelForecastEnum.QYNH32.getCode().equals(task)){
  1779. //同时调用跃渊的预测接口 保存记录值
  1780. /*try {
  1781. 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);
  1782. if(!StringUtils.isBlank(result)){
  1783. JSONArray array = JSON.parseArray(result);
  1784. tXinyiForecastComparison.setYyForecastOne(array.getBigDecimal(6));
  1785. tXinyiForecastComparison.setYyForecastTwo(array.getBigDecimal(7));
  1786. tXinyiForecastComparison.setYyForecastThree(array.getBigDecimal(8));
  1787. }
  1788. } catch (Exception e) {
  1789. log.error("调用跃渊的预测接口出现异常,异常信息为{}", e.getMessage());
  1790. }*/
  1791. // this.xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1792. /*BigDecimal cscodBzz = new BigDecimal(XIAOSUANYAN_BZK);
  1793. BigDecimal cscodGkz = new BigDecimal(XIAOSUANYAN_GKZ);*/
  1794. //2024年09月08日11:21:25 采用出水氨氮的标准值和管控值
  1795. BigDecimal csadBzz = normConfig.getCsadBzz();
  1796. BigDecimal csadGkz = normConfig.getCsadGkz();
  1797. //处理展示数据
  1798. for (int i = 0; i < tXinyiRobots6.size(); i++) {
  1799. TXinyiRobot tXinyiRobotTemp = tXinyiRobots6.get(5 - i);
  1800. ChartBasic chartBasic = new ChartBasic();
  1801. chartBasic.setTime(tXinyiRobotTemp.getTestHour().substring(11));
  1802. chartBasic.setVal(DecimalUtils.getAbsAndScale(tXinyiRobotTemp.getNh32Jqr(), INT_2));
  1803. chartsDataList.add(chartBasic);
  1804. }
  1805. for (int i = 0; i < split.length; i++) {
  1806. String val = split[i];
  1807. ChartBasic chartBasic = new ChartBasic();
  1808. chartBasic.setTime(hours[i]);
  1809. chartBasic.setVal(DecimalUtils.getAbsAndScale(new BigDecimal(val), INT_2));
  1810. chartsDataList.add(chartBasic);
  1811. }
  1812. ryTask.handleXinYiWarningsYC(csadBzz, split, csadGkz, BusinessEnum.WarningCategoryEnum.QYAD_2.getCode(), hour, normConfig, tXinyiRobot.getNo3Hlj2Jqr(), tXinyiIndustry, chartsDataList, date);
  1813. }else {
  1814. log.error("暂未支持的类型{}", task);
  1815. }
  1816. //插入到数据库
  1817. //2024年6月21日14:18:55 如果红杉预测和跃渊预测都有数据再保存
  1818. //2024年7月8日15:15:46 逻辑调整:只要红杉的数据不为空就保存
  1819. if(Objects.isNull(tXinyiForecastComparison.getHsForecastOne()) || Objects.isNull(tXinyiForecastComparison.getHsForecastTwo()) ||Objects.isNull(tXinyiForecastComparison.getHsForecastThree())){
  1820. // || Objects.isNull(tXinyiForecastComparison.getYyForecastOne()) || Objects.isNull(tXinyiForecastComparison.getYyForecastTwo()) || Objects.isNull(tXinyiForecastComparison.getYyForecastThree())){
  1821. log.error("保存预测对比数据时,有存在不满足条件的数据,不再保存数据,数据为{}", JSON.toJSONString(tXinyiForecastComparison));
  1822. }else
  1823. xinyiForecastComparisonService.insertTXinyiForecastComparison(tXinyiForecastComparison);
  1824. }
  1825. }