ProtTimer.java 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. package com.huimv.admin.timer;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.huimv.admin.common.utils.NumberUtils;
  4. import com.huimv.admin.entity.ProtData;
  5. import com.huimv.admin.entity.ProtThreshold;
  6. import com.huimv.admin.entity.ProtWarningInfo;
  7. import com.huimv.admin.mapper.ProtDataMapper;
  8. import com.huimv.admin.mapper.ProtThresholdMapper;
  9. import com.huimv.admin.mapper.ProtWarningInfoMapper;
  10. import com.huimv.admin.service.IProtDataService;
  11. import com.huimv.admin.service.IProtThresholdService;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.context.annotation.Configuration;
  14. import org.springframework.scheduling.annotation.EnableScheduling;
  15. import org.springframework.scheduling.annotation.Scheduled;
  16. import java.text.NumberFormat;
  17. import java.util.Date;
  18. @Configuration
  19. @EnableScheduling
  20. public class ProtTimer {
  21. @Autowired
  22. private ProtThresholdMapper protThresholdMapper;
  23. @Autowired
  24. private ProtDataMapper protDataMapper;
  25. @Autowired
  26. private ProtWarningInfoMapper warningInfoMapper;
  27. // 环保数据
  28. @Scheduled(cron = "0 0 */1 * * ? ")
  29. private void getShenChan() throws Exception {
  30. for (int i = 1; i < 4; i++) {
  31. //假设已经拿到了数据
  32. String num = NumberUtils.getNumFloat(6.4, 8.6);//ph
  33. ProtData protData = new ProtData();
  34. protData.setLoctionType(i);
  35. protData.setCreateDate(new Date());
  36. protData.setFarmId(21);
  37. protData.setPh(num);
  38. QueryWrapper<ProtThreshold> queryWrapper = new QueryWrapper<>();
  39. if (i == 1) {
  40. String num1 = NumberUtils.getNum(8000, 20001,0);//cod
  41. String num2 = NumberUtils.getNumFloat(1000.0, 1501.0);//nh3n
  42. String num3 = NumberUtils.getNumFloat(100.0, 260.0);//tp
  43. String num4 = NumberUtils.getNum(1000, 1550, 0);//tn
  44. String num5 = NumberUtils.getNum(0, 51, 0);//flow
  45. protData.setCod(num1);
  46. protData.setNh3n(num2);
  47. protData.setTp(num3);
  48. protData.setTn(num4);
  49. protData.setFlow(num5);
  50. protDataMapper.insert(protData);
  51. queryWrapper.eq("farm_id", 21).eq("prot_type", 1);
  52. ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
  53. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
  54. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  55. protWarningInfo.setWarningContent("进污口ph值为" + num + "达到红色预警");
  56. protWarningInfo.setWarningType(1);
  57. protWarningInfo.setFarmId(protThreshold.getFarmId());
  58. protWarningInfo.setDate(new Date());
  59. protWarningInfo.setUserIds(protThreshold.getUserIds());
  60. protWarningInfo.setDeviceId(i);
  61. protWarningInfo.setBuildLocation("进污口");
  62. warningInfoMapper.insert(protWarningInfo);
  63. }
  64. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther2())) {
  65. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  66. protWarningInfo.setWarningContent("进污口ph值为" + num + "达到橙色预警");
  67. protWarningInfo.setWarningType(1);
  68. protWarningInfo.setFarmId(protThreshold.getFarmId());
  69. protWarningInfo.setDate(new Date());
  70. protWarningInfo.setUserIds(protThreshold.getUserIds());
  71. protWarningInfo.setDeviceId(i);
  72. protWarningInfo.setBuildLocation("进污口");
  73. warningInfoMapper.insert(protWarningInfo);
  74. }
  75. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
  76. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  77. protWarningInfo.setWarningContent("进污口cod值为" + num1 + "达到红色预警");
  78. protWarningInfo.setWarningType(0);
  79. protWarningInfo.setFarmId(protThreshold.getFarmId());
  80. protWarningInfo.setDate(new Date());
  81. protWarningInfo.setUserIds(protThreshold.getUserIds());
  82. protWarningInfo.setDeviceId(i);
  83. protWarningInfo.setBuildLocation("进污口");
  84. warningInfoMapper.insert(protWarningInfo);
  85. }
  86. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
  87. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  88. protWarningInfo.setWarningContent("进污口cod值为" + num1 + "达到橙色预警");
  89. protWarningInfo.setWarningType(0);
  90. protWarningInfo.setFarmId(protThreshold.getFarmId());
  91. protWarningInfo.setDate(new Date());
  92. protWarningInfo.setUserIds(protThreshold.getUserIds());
  93. protWarningInfo.setDeviceId(i);
  94. protWarningInfo.setBuildLocation("进污口");
  95. warningInfoMapper.insert(protWarningInfo);
  96. }
  97. if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
  98. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  99. protWarningInfo.setWarningContent("进污口NH3N值为" + num2 + "达到红色预警");
  100. protWarningInfo.setWarningType(2);
  101. protWarningInfo.setFarmId(protThreshold.getFarmId());
  102. protWarningInfo.setDate(new Date());
  103. protWarningInfo.setUserIds(protThreshold.getUserIds());
  104. protWarningInfo.setDeviceId(i);
  105. protWarningInfo.setBuildLocation("进污口");
  106. warningInfoMapper.insert(protWarningInfo);
  107. }
  108. if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
  109. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  110. protWarningInfo.setWarningContent("进污口NH3N值为" + num2 + "达到橙色预警");
  111. protWarningInfo.setWarningType(2);
  112. protWarningInfo.setFarmId(protThreshold.getFarmId());
  113. protWarningInfo.setDate(new Date());
  114. protWarningInfo.setUserIds(protThreshold.getUserIds());
  115. protWarningInfo.setDeviceId(i);
  116. protWarningInfo.setBuildLocation("进污口");
  117. warningInfoMapper.insert(protWarningInfo);
  118. }
  119. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
  120. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  121. protWarningInfo.setWarningContent("进污口TP值为" + num3 + "达到红色预警");
  122. protWarningInfo.setWarningType(3);
  123. protWarningInfo.setFarmId(protThreshold.getFarmId());
  124. protWarningInfo.setDate(new Date());
  125. protWarningInfo.setUserIds(protThreshold.getUserIds());
  126. protWarningInfo.setDeviceId(i);
  127. protWarningInfo.setBuildLocation("进污口");
  128. warningInfoMapper.insert(protWarningInfo);
  129. }
  130. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
  131. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  132. protWarningInfo.setWarningContent("进污口TP值为" + num3 + "达到橙色预警");
  133. protWarningInfo.setWarningType(3);
  134. protWarningInfo.setFarmId(protThreshold.getFarmId());
  135. protWarningInfo.setDate(new Date());
  136. protWarningInfo.setUserIds(protThreshold.getUserIds());
  137. protWarningInfo.setDeviceId(i);
  138. protWarningInfo.setBuildLocation("进污口");
  139. warningInfoMapper.insert(protWarningInfo);
  140. }
  141. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
  142. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  143. protWarningInfo.setWarningContent("进污口TN值为" + num4 + "达到红色预警");
  144. protWarningInfo.setWarningType(4);
  145. protWarningInfo.setFarmId(protThreshold.getFarmId());
  146. protWarningInfo.setDate(new Date());
  147. protWarningInfo.setUserIds(protThreshold.getUserIds());
  148. protWarningInfo.setDeviceId(i);
  149. protWarningInfo.setBuildLocation("进污口");
  150. warningInfoMapper.insert(protWarningInfo);
  151. }
  152. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
  153. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  154. protWarningInfo.setWarningContent("进污口TN值为" + num4 + "达到橙色预警");
  155. protWarningInfo.setWarningType(4);
  156. protWarningInfo.setFarmId(protThreshold.getFarmId());
  157. protWarningInfo.setDate(new Date());
  158. protWarningInfo.setUserIds(protThreshold.getUserIds());
  159. protWarningInfo.setDeviceId(i);
  160. protWarningInfo.setBuildLocation("进污口");
  161. warningInfoMapper.insert(protWarningInfo);
  162. }
  163. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
  164. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  165. protWarningInfo.setWarningContent("进污口累计流量值为" + num5 + "达到红色预警");
  166. protWarningInfo.setWarningType(5);
  167. protWarningInfo.setFarmId(protThreshold.getFarmId());
  168. protWarningInfo.setDate(new Date());
  169. protWarningInfo.setUserIds(protThreshold.getUserIds());
  170. protWarningInfo.setDeviceId(i);
  171. protWarningInfo.setBuildLocation("进污口");
  172. warningInfoMapper.insert(protWarningInfo);
  173. }
  174. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
  175. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  176. protWarningInfo.setWarningContent("进污口累计流量值为" + num5 + "达到橙色预警");
  177. protWarningInfo.setWarningType(5);
  178. protWarningInfo.setFarmId(protThreshold.getFarmId());
  179. protWarningInfo.setDate(new Date());
  180. protWarningInfo.setUserIds(protThreshold.getUserIds());
  181. protWarningInfo.setDeviceId(i);
  182. protWarningInfo.setBuildLocation("进污口");
  183. warningInfoMapper.insert(protWarningInfo);
  184. }
  185. }
  186. if (i == 2) {
  187. String num1 = NumberUtils.getNum(0, 310,0);//cod
  188. String num2 = NumberUtils.getNumFloat(0.0, 35.0);//nh3n
  189. String num3 = NumberUtils.getNumFloat(0.0, 4.0);//tp
  190. String num4 = NumberUtils.getNum(0, 32, 0);//tn
  191. String num5 = NumberUtils.getNum(0, 55, 0);//flow
  192. protData.setCod(num1);
  193. protData.setNh3n(num2);
  194. protData.setTp(num3);
  195. protData.setTn(num4);
  196. protData.setFlow(num5);
  197. protDataMapper.insert(protData);
  198. queryWrapper.eq("farm_id", 21).eq("prot_type", 2);
  199. ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//污口
  200. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
  201. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  202. protWarningInfo.setWarningContent("处理口ph值为" + num + "达到红色预警");
  203. protWarningInfo.setWarningType(1);
  204. protWarningInfo.setFarmId(protThreshold.getFarmId());
  205. protWarningInfo.setWarningType(i);
  206. protWarningInfo.setDate(new Date());
  207. protWarningInfo.setUserIds(protThreshold.getUserIds());
  208. protWarningInfo.setDeviceId(i);
  209. protWarningInfo.setBuildLocation("处理口");
  210. warningInfoMapper.insert(protWarningInfo);
  211. }
  212. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther2())) {
  213. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  214. protWarningInfo.setWarningContent("处理口ph值为" + num + "达到橙色预警");
  215. protWarningInfo.setWarningType(1);
  216. protWarningInfo.setFarmId(protThreshold.getFarmId());
  217. protWarningInfo.setWarningType(i);
  218. protWarningInfo.setDate(new Date());
  219. protWarningInfo.setUserIds(protThreshold.getUserIds());
  220. protWarningInfo.setDeviceId(i);
  221. protWarningInfo.setBuildLocation("处理口");
  222. warningInfoMapper.insert(protWarningInfo);
  223. }
  224. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
  225. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  226. protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到红色预警");
  227. protWarningInfo.setWarningType(0);
  228. protWarningInfo.setFarmId(protThreshold.getFarmId());
  229. protWarningInfo.setWarningType(i);
  230. protWarningInfo.setDate(new Date());
  231. protWarningInfo.setUserIds(protThreshold.getUserIds());
  232. protWarningInfo.setDeviceId(i);
  233. protWarningInfo.setBuildLocation("处理口");
  234. warningInfoMapper.insert(protWarningInfo);
  235. }
  236. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
  237. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  238. protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到橙色预警");
  239. protWarningInfo.setWarningType(0);
  240. protWarningInfo.setFarmId(protThreshold.getFarmId());
  241. protWarningInfo.setWarningType(i);
  242. protWarningInfo.setDate(new Date());
  243. protWarningInfo.setUserIds(protThreshold.getUserIds());
  244. protWarningInfo.setDeviceId(i);
  245. protWarningInfo.setBuildLocation("处理口");
  246. warningInfoMapper.insert(protWarningInfo);
  247. }
  248. if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
  249. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  250. protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到红色预警");
  251. protWarningInfo.setWarningType(2);
  252. protWarningInfo.setFarmId(protThreshold.getFarmId());
  253. protWarningInfo.setWarningType(i);
  254. protWarningInfo.setDate(new Date());
  255. protWarningInfo.setUserIds(protThreshold.getUserIds());
  256. protWarningInfo.setDeviceId(i);
  257. protWarningInfo.setBuildLocation("处理口");
  258. warningInfoMapper.insert(protWarningInfo);
  259. }
  260. if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
  261. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  262. protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到橙色预警");
  263. protWarningInfo.setWarningType(2);
  264. protWarningInfo.setFarmId(protThreshold.getFarmId());
  265. protWarningInfo.setWarningType(i);
  266. protWarningInfo.setDate(new Date());
  267. protWarningInfo.setUserIds(protThreshold.getUserIds());
  268. protWarningInfo.setDeviceId(i);
  269. protWarningInfo.setBuildLocation("处理口");
  270. warningInfoMapper.insert(protWarningInfo);
  271. }
  272. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
  273. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  274. protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到红色预警");
  275. protWarningInfo.setWarningType(3);
  276. protWarningInfo.setFarmId(protThreshold.getFarmId());
  277. protWarningInfo.setWarningType(i);
  278. protWarningInfo.setDate(new Date());
  279. protWarningInfo.setUserIds(protThreshold.getUserIds());
  280. protWarningInfo.setDeviceId(i);
  281. protWarningInfo.setBuildLocation("处理口");
  282. warningInfoMapper.insert(protWarningInfo);
  283. }
  284. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
  285. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  286. protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到橙色预警");
  287. protWarningInfo.setWarningType(3);
  288. protWarningInfo.setFarmId(protThreshold.getFarmId());
  289. protWarningInfo.setWarningType(i);
  290. protWarningInfo.setDate(new Date());
  291. protWarningInfo.setUserIds(protThreshold.getUserIds());
  292. protWarningInfo.setDeviceId(i);
  293. protWarningInfo.setBuildLocation("处理口");
  294. warningInfoMapper.insert(protWarningInfo);
  295. }
  296. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
  297. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  298. protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到红色预警");
  299. protWarningInfo.setWarningType(4);
  300. protWarningInfo.setFarmId(protThreshold.getFarmId());
  301. protWarningInfo.setWarningType(i);
  302. protWarningInfo.setDate(new Date());
  303. protWarningInfo.setUserIds(protThreshold.getUserIds());
  304. protWarningInfo.setDeviceId(i);
  305. protWarningInfo.setBuildLocation("处理口");
  306. warningInfoMapper.insert(protWarningInfo);
  307. }
  308. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
  309. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  310. protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到橙色预警");
  311. protWarningInfo.setWarningType(4);
  312. protWarningInfo.setFarmId(protThreshold.getFarmId());
  313. protWarningInfo.setWarningType(i);
  314. protWarningInfo.setDate(new Date());
  315. protWarningInfo.setUserIds(protThreshold.getUserIds());
  316. protWarningInfo.setDeviceId(i);
  317. protWarningInfo.setBuildLocation("处理口");
  318. warningInfoMapper.insert(protWarningInfo);
  319. }
  320. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
  321. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  322. protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到红色预警");
  323. protWarningInfo.setWarningType(5);
  324. protWarningInfo.setFarmId(protThreshold.getFarmId());
  325. protWarningInfo.setWarningType(i);
  326. protWarningInfo.setDate(new Date());
  327. protWarningInfo.setUserIds(protThreshold.getUserIds());
  328. protWarningInfo.setDeviceId(i);
  329. protWarningInfo.setBuildLocation("处理口");
  330. warningInfoMapper.insert(protWarningInfo);
  331. }
  332. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
  333. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  334. protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到橙色预警");
  335. protWarningInfo.setWarningType(5);
  336. protWarningInfo.setFarmId(protThreshold.getFarmId());
  337. protWarningInfo.setWarningType(i);
  338. protWarningInfo.setDate(new Date());
  339. protWarningInfo.setUserIds(protThreshold.getUserIds());
  340. protWarningInfo.setDeviceId(i);
  341. protWarningInfo.setBuildLocation("处理口");
  342. warningInfoMapper.insert(protWarningInfo);
  343. }
  344. }
  345. if (i == 3) {
  346. //排污口专用数据
  347. String ph = NumberUtils.getNumFloat(6.6, 8.4);//ph
  348. String cod = NumberUtils.getNum(0, 380, 0);//cod
  349. String nh3n = NumberUtils.getNum(0, 50, 1);//nh3n
  350. String tp = NumberUtils.getNumFloat(0.0, 10.0);//tp
  351. String tn = NumberUtils.getNum(0, 150, 1);//tn
  352. String flow = NumberUtils.getNum(0, 100, 1);//flow
  353. protData.setPh(ph);
  354. protData.setFlow(flow);
  355. protData.setTp(tp);
  356. protData.setTn(tn);
  357. protData.setCod(cod);
  358. protData.setNh3n(nh3n);
  359. protDataMapper.insert(protData);
  360. queryWrapper.eq("farm_id", 21).eq("prot_type", 3);
  361. ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
  362. if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther3())) {
  363. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  364. protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到红色预警");
  365. protWarningInfo.setWarningType(1);
  366. protWarningInfo.setFarmId(protThreshold.getFarmId());
  367. protWarningInfo.setWarningType(i);
  368. protWarningInfo.setDate(new Date());
  369. protWarningInfo.setUserIds(protThreshold.getUserIds());
  370. protWarningInfo.setDeviceId(i);
  371. protWarningInfo.setBuildLocation("排污口");
  372. warningInfoMapper.insert(protWarningInfo);
  373. }
  374. if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther2())) {
  375. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  376. protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到橙色预警");
  377. protWarningInfo.setWarningType(1);
  378. protWarningInfo.setFarmId(protThreshold.getFarmId());
  379. protWarningInfo.setWarningType(i);
  380. protWarningInfo.setDate(new Date());
  381. protWarningInfo.setUserIds(protThreshold.getUserIds());
  382. protWarningInfo.setDeviceId(i);
  383. protWarningInfo.setBuildLocation("排污口");
  384. warningInfoMapper.insert(protWarningInfo);
  385. }
  386. if (Double.parseDouble(cod) > Double.parseDouble(protThreshold.getCod2())) {
  387. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  388. protWarningInfo.setWarningContent("排污口cod值为" + cod + "达到红色预警");
  389. protWarningInfo.setWarningType(0);
  390. protWarningInfo.setFarmId(protThreshold.getFarmId());
  391. protWarningInfo.setWarningType(i);
  392. protWarningInfo.setDate(new Date());
  393. protWarningInfo.setUserIds(protThreshold.getUserIds());
  394. protWarningInfo.setDeviceId(i);
  395. protWarningInfo.setBuildLocation("排污口");
  396. warningInfoMapper.insert(protWarningInfo);
  397. }
  398. if (Double.parseDouble(cod) > Double.parseDouble(protThreshold.getCod1())) {
  399. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  400. protWarningInfo.setWarningContent("排污口cod值为" + cod + "达到橙色预警");
  401. protWarningInfo.setWarningType(0);
  402. protWarningInfo.setFarmId(protThreshold.getFarmId());
  403. protWarningInfo.setWarningType(i);
  404. protWarningInfo.setDate(new Date());
  405. protWarningInfo.setUserIds(protThreshold.getUserIds());
  406. protWarningInfo.setDeviceId(i);
  407. protWarningInfo.setBuildLocation("排污口");
  408. warningInfoMapper.insert(protWarningInfo);
  409. }
  410. if (Double.parseDouble(nh3n) > Double.parseDouble(protThreshold.getNh3n2())) {
  411. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  412. protWarningInfo.setWarningContent("排污口NH3N值为" + nh3n + "达到红色预警");
  413. protWarningInfo.setWarningType(2);
  414. protWarningInfo.setFarmId(protThreshold.getFarmId());
  415. protWarningInfo.setWarningType(i);
  416. protWarningInfo.setDate(new Date());
  417. protWarningInfo.setUserIds(protThreshold.getUserIds());
  418. protWarningInfo.setDeviceId(i);
  419. protWarningInfo.setBuildLocation("排污口");
  420. warningInfoMapper.insert(protWarningInfo);
  421. }
  422. if (Double.parseDouble(nh3n) > Double.parseDouble(protThreshold.getNh3n1())) {
  423. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  424. protWarningInfo.setWarningContent("排污口NH3N值为" + nh3n + "达到橙色预警");
  425. protWarningInfo.setWarningType(2);
  426. protWarningInfo.setFarmId(protThreshold.getFarmId());
  427. protWarningInfo.setWarningType(i);
  428. protWarningInfo.setDate(new Date());
  429. protWarningInfo.setUserIds(protThreshold.getUserIds());
  430. protWarningInfo.setDeviceId(i);
  431. protWarningInfo.setBuildLocation("排污口");
  432. warningInfoMapper.insert(protWarningInfo);
  433. }
  434. if (Double.parseDouble(tp) > Double.parseDouble(protThreshold.getTp2())) {
  435. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  436. protWarningInfo.setWarningContent("排污口TP值为" + tp + "达到红色预警");
  437. protWarningInfo.setWarningType(3);
  438. protWarningInfo.setFarmId(protThreshold.getFarmId());
  439. protWarningInfo.setWarningType(i);
  440. protWarningInfo.setDate(new Date());
  441. protWarningInfo.setUserIds(protThreshold.getUserIds());
  442. protWarningInfo.setDeviceId(i);
  443. protWarningInfo.setBuildLocation("排污口");
  444. warningInfoMapper.insert(protWarningInfo);
  445. }
  446. if (Double.parseDouble(tp) > Double.parseDouble(protThreshold.getTp1())) {
  447. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  448. protWarningInfo.setWarningContent("排污口TP值为" + tp + "达到橙色预警");
  449. protWarningInfo.setWarningType(3);
  450. protWarningInfo.setFarmId(protThreshold.getFarmId());
  451. protWarningInfo.setWarningType(i);
  452. protWarningInfo.setDate(new Date());
  453. protWarningInfo.setUserIds(protThreshold.getUserIds());
  454. protWarningInfo.setDeviceId(i);
  455. protWarningInfo.setBuildLocation("排污口");
  456. warningInfoMapper.insert(protWarningInfo);
  457. }
  458. if (Double.parseDouble(tn) > Double.parseDouble(protThreshold.getTn2())) {
  459. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  460. protWarningInfo.setWarningContent("排污口TN值为" + tn + "达到红色预警");
  461. protWarningInfo.setWarningType(4);
  462. protWarningInfo.setFarmId(protThreshold.getFarmId());
  463. protWarningInfo.setWarningType(i);
  464. protWarningInfo.setDate(new Date());
  465. protWarningInfo.setUserIds(protThreshold.getUserIds());
  466. protWarningInfo.setDeviceId(i);
  467. protWarningInfo.setBuildLocation("排污口");
  468. warningInfoMapper.insert(protWarningInfo);
  469. }
  470. if (Double.parseDouble(tn) > Double.parseDouble(protThreshold.getTn1())) {
  471. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  472. protWarningInfo.setWarningContent("排污口TN值为" + tn + "达到橙色预警");
  473. protWarningInfo.setWarningType(4);
  474. protWarningInfo.setFarmId(protThreshold.getFarmId());
  475. protWarningInfo.setWarningType(i);
  476. protWarningInfo.setDate(new Date());
  477. protWarningInfo.setUserIds(protThreshold.getUserIds());
  478. protWarningInfo.setDeviceId(i);
  479. protWarningInfo.setBuildLocation("排污口");
  480. warningInfoMapper.insert(protWarningInfo);
  481. }
  482. if (Double.parseDouble(flow) > Double.parseDouble(protThreshold.getFlow2())) {
  483. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  484. protWarningInfo.setWarningContent("排污口累计流量值为" + flow + "达到红色预警");
  485. protWarningInfo.setWarningType(5);
  486. protWarningInfo.setFarmId(protThreshold.getFarmId());
  487. protWarningInfo.setWarningType(i);
  488. protWarningInfo.setDate(new Date());
  489. protWarningInfo.setUserIds(protThreshold.getUserIds());
  490. protWarningInfo.setDeviceId(i);
  491. protWarningInfo.setBuildLocation("排污口");
  492. warningInfoMapper.insert(protWarningInfo);
  493. }
  494. if (Double.parseDouble(flow) > Double.parseDouble(protThreshold.getFlow1())) {
  495. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  496. protWarningInfo.setWarningContent("排污口累计流量值为" + flow + "达到橙色预警");
  497. protWarningInfo.setWarningType(5);
  498. protWarningInfo.setFarmId(protThreshold.getFarmId());
  499. protWarningInfo.setWarningType(i);
  500. protWarningInfo.setDate(new Date());
  501. protWarningInfo.setUserIds(protThreshold.getUserIds());
  502. protWarningInfo.setDeviceId(i);
  503. protWarningInfo.setBuildLocation("排污口");
  504. warningInfoMapper.insert(protWarningInfo);
  505. }
  506. }
  507. }
  508. }
  509. }