ProtTimer.java 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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 org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.context.annotation.Configuration;
  12. import org.springframework.scheduling.annotation.EnableScheduling;
  13. import org.springframework.scheduling.annotation.Scheduled;
  14. import java.util.Date;
  15. @Configuration
  16. @EnableScheduling
  17. public class ProtTimer {
  18. @Autowired
  19. private ProtThresholdMapper protThresholdMapper;
  20. @Autowired
  21. private ProtDataMapper protDataMapper;
  22. @Autowired
  23. private ProtWarningInfoMapper warningInfoMapper;
  24. // 环保数据
  25. @Scheduled(cron = "0 0 */1 * * ? ")
  26. private void getShenChan() throws Exception {
  27. for (int i = 1; i < 10; i++) {
  28. //假设已经拿到了数据
  29. String num = NumberUtils.getNumFloat(6.4, 8.6);//ph
  30. ProtData protData = new ProtData();
  31. protData.setCreateDate(new Date());
  32. if (i < 4) {
  33. protData.setLoctionType(i);
  34. protData.setFarmId(21);
  35. } else if (i < 7) {
  36. protData.setLoctionType(i - 3);
  37. protData.setFarmId(24);//东阳
  38. } else {
  39. protData.setLoctionType(i - 6);
  40. protData.setFarmId(23);//浦江
  41. }
  42. protData.setPh(num);
  43. QueryWrapper<ProtThreshold> queryWrapper = new QueryWrapper<>();
  44. if (i == 1||i==4||i==7) {
  45. String num1 = NumberUtils.getNum(8000, 20001,0);//cod
  46. String num2 = NumberUtils.getNumFloat(1000.0, 1501.0);//nh3n
  47. String num3 = NumberUtils.getNumFloat(100.0, 260.0);//tp
  48. String num4 = NumberUtils.getNum(1000, 1550, 0);//tn
  49. String num5 = NumberUtils.getNum(0, 51, 0);//flow
  50. protData.setCod(num1);
  51. protData.setNh3n(num2);
  52. protData.setTp(num3);
  53. protData.setTn(num4);
  54. protData.setFlow(num5);
  55. protDataMapper.insert(protData);
  56. if (i == 1) {
  57. queryWrapper.eq("farm_id", 21).eq("prot_type", 1);
  58. } else if (i == 4) {
  59. queryWrapper.eq("farm_id", 24).eq("prot_type", 1);
  60. } else {
  61. queryWrapper.eq("farm_id", 23).eq("prot_type", 1);
  62. }
  63. ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
  64. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
  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(num) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther2())) {
  76. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  77. protWarningInfo.setWarningContent("进污口ph值为" + num + "达到橙色预警");
  78. protWarningInfo.setWarningType(1);
  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.getCod2())) {
  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(num1) > Double.parseDouble(protThreshold.getCod1())) {
  98. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  99. protWarningInfo.setWarningContent("进污口cod值为" + num1 + "达到橙色预警");
  100. protWarningInfo.setWarningType(0);
  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.getNh3n2())) {
  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(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
  120. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  121. protWarningInfo.setWarningContent("进污口NH3N值为" + num2 + "达到橙色预警");
  122. protWarningInfo.setWarningType(2);
  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.getTp2())) {
  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(num3) > Double.parseDouble(protThreshold.getTp1())) {
  142. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  143. protWarningInfo.setWarningContent("进污口TP值为" + num3 + "达到橙色预警");
  144. protWarningInfo.setWarningType(3);
  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.getTn2())) {
  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(num4) > Double.parseDouble(protThreshold.getTn1())) {
  164. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  165. protWarningInfo.setWarningContent("进污口TN值为" + num4 + "达到橙色预警");
  166. protWarningInfo.setWarningType(4);
  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.getFlow2())) {
  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. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
  186. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  187. protWarningInfo.setWarningContent("进污口累计流量值为" + num5 + "达到橙色预警");
  188. protWarningInfo.setWarningType(5);
  189. protWarningInfo.setFarmId(protThreshold.getFarmId());
  190. protWarningInfo.setDate(new Date());
  191. protWarningInfo.setUserIds(protThreshold.getUserIds());
  192. protWarningInfo.setDeviceId(i);
  193. protWarningInfo.setBuildLocation("进污口");
  194. warningInfoMapper.insert(protWarningInfo);
  195. }
  196. }
  197. if (i == 2 || i == 5 || i == 8) {
  198. String num1 = NumberUtils.getNum(0, 310, 0);//cod
  199. String num2 = NumberUtils.getNumFloat(0.0, 31.0);//nh3n
  200. String num3 = NumberUtils.getNumFloat(0.0, 3.6);//tp
  201. String num4 = NumberUtils.getNum(0, 32, 0);//tn
  202. String num5 = NumberUtils.getNum(0, 55, 0);//flow
  203. protData.setCod(num1);
  204. protData.setNh3n(num2);
  205. protData.setTp(num3);
  206. protData.setTn(num4);
  207. protData.setFlow(num5);
  208. protDataMapper.insert(protData);
  209. if (i == 2) {
  210. queryWrapper.eq("farm_id", 21).eq("prot_type", 2);
  211. } else if (i == 5) {
  212. queryWrapper.eq("farm_id", 24).eq("prot_type", 2);
  213. } else {
  214. queryWrapper.eq("farm_id", 23).eq("prot_type", 2);
  215. }
  216. ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//污口
  217. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther3())) {
  218. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  219. protWarningInfo.setWarningContent("处理口ph值为" + num + "达到红色预警");
  220. protWarningInfo.setWarningType(1);
  221. protWarningInfo.setFarmId(protThreshold.getFarmId());
  222. protWarningInfo.setDate(new Date());
  223. protWarningInfo.setUserIds(protThreshold.getUserIds());
  224. protWarningInfo.setDeviceId(i);
  225. protWarningInfo.setBuildLocation("处理口");
  226. warningInfoMapper.insert(protWarningInfo);
  227. }
  228. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther2())) {
  229. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  230. protWarningInfo.setWarningContent("处理口ph值为" + num + "达到橙色预警");
  231. protWarningInfo.setWarningType(1);
  232. protWarningInfo.setFarmId(protThreshold.getFarmId());
  233. protWarningInfo.setDate(new Date());
  234. protWarningInfo.setUserIds(protThreshold.getUserIds());
  235. protWarningInfo.setDeviceId(i);
  236. protWarningInfo.setBuildLocation("处理口");
  237. warningInfoMapper.insert(protWarningInfo);
  238. }
  239. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
  240. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  241. protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到红色预警");
  242. protWarningInfo.setWarningType(0);
  243. protWarningInfo.setFarmId(protThreshold.getFarmId());
  244. protWarningInfo.setDate(new Date());
  245. protWarningInfo.setUserIds(protThreshold.getUserIds());
  246. protWarningInfo.setDeviceId(i);
  247. protWarningInfo.setBuildLocation("处理口");
  248. warningInfoMapper.insert(protWarningInfo);
  249. }
  250. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
  251. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  252. protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到橙色预警");
  253. protWarningInfo.setWarningType(0);
  254. protWarningInfo.setFarmId(protThreshold.getFarmId());
  255. protWarningInfo.setDate(new Date());
  256. protWarningInfo.setUserIds(protThreshold.getUserIds());
  257. protWarningInfo.setDeviceId(i);
  258. protWarningInfo.setBuildLocation("处理口");
  259. warningInfoMapper.insert(protWarningInfo);
  260. }
  261. if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
  262. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  263. protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到红色预警");
  264. protWarningInfo.setWarningType(2);
  265. protWarningInfo.setFarmId(protThreshold.getFarmId());
  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(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
  273. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  274. protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到橙色预警");
  275. protWarningInfo.setWarningType(2);
  276. protWarningInfo.setFarmId(protThreshold.getFarmId());
  277. protWarningInfo.setDate(new Date());
  278. protWarningInfo.setUserIds(protThreshold.getUserIds());
  279. protWarningInfo.setDeviceId(i);
  280. protWarningInfo.setBuildLocation("处理口");
  281. warningInfoMapper.insert(protWarningInfo);
  282. }
  283. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
  284. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  285. protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到红色预警");
  286. protWarningInfo.setWarningType(3);
  287. protWarningInfo.setFarmId(protThreshold.getFarmId());
  288. protWarningInfo.setDate(new Date());
  289. protWarningInfo.setUserIds(protThreshold.getUserIds());
  290. protWarningInfo.setDeviceId(i);
  291. protWarningInfo.setBuildLocation("处理口");
  292. warningInfoMapper.insert(protWarningInfo);
  293. }
  294. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
  295. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  296. protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到橙色预警");
  297. protWarningInfo.setWarningType(3);
  298. protWarningInfo.setFarmId(protThreshold.getFarmId());
  299. protWarningInfo.setDate(new Date());
  300. protWarningInfo.setUserIds(protThreshold.getUserIds());
  301. protWarningInfo.setDeviceId(i);
  302. protWarningInfo.setBuildLocation("处理口");
  303. warningInfoMapper.insert(protWarningInfo);
  304. }
  305. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
  306. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  307. protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到红色预警");
  308. protWarningInfo.setWarningType(4);
  309. protWarningInfo.setFarmId(protThreshold.getFarmId());
  310. protWarningInfo.setDate(new Date());
  311. protWarningInfo.setUserIds(protThreshold.getUserIds());
  312. protWarningInfo.setDeviceId(i);
  313. protWarningInfo.setBuildLocation("处理口");
  314. warningInfoMapper.insert(protWarningInfo);
  315. }
  316. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
  317. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  318. protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到橙色预警");
  319. protWarningInfo.setWarningType(4);
  320. protWarningInfo.setFarmId(protThreshold.getFarmId());
  321. protWarningInfo.setDate(new Date());
  322. protWarningInfo.setUserIds(protThreshold.getUserIds());
  323. protWarningInfo.setDeviceId(i);
  324. protWarningInfo.setBuildLocation("处理口");
  325. warningInfoMapper.insert(protWarningInfo);
  326. }
  327. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
  328. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  329. protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到红色预警");
  330. protWarningInfo.setWarningType(5);
  331. protWarningInfo.setFarmId(protThreshold.getFarmId());
  332. protWarningInfo.setDate(new Date());
  333. protWarningInfo.setUserIds(protThreshold.getUserIds());
  334. protWarningInfo.setDeviceId(i);
  335. protWarningInfo.setBuildLocation("处理口");
  336. warningInfoMapper.insert(protWarningInfo);
  337. }
  338. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
  339. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  340. protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到橙色预警");
  341. protWarningInfo.setWarningType(5);
  342. protWarningInfo.setFarmId(protThreshold.getFarmId());
  343. protWarningInfo.setDate(new Date());
  344. protWarningInfo.setUserIds(protThreshold.getUserIds());
  345. protWarningInfo.setDeviceId(i);
  346. protWarningInfo.setBuildLocation("处理口");
  347. warningInfoMapper.insert(protWarningInfo);
  348. }
  349. }
  350. if (i == 3 || i == 6 || i == 9) {
  351. //排污口专用数据
  352. String ph = NumberUtils.getNumFloat(6.6, 8.4);//ph
  353. String cod = NumberUtils.getNum(0, 380, 0);//cod
  354. String nh3n = NumberUtils.getNum(0, 50, 1);//nh3n
  355. String tp = NumberUtils.getNumFloat(0.0, 10.0);//tp
  356. String tn = NumberUtils.getNum(0, 150, 1);//tn
  357. String flow = NumberUtils.getNum(0, 100, 1);//flow
  358. protData.setPh(ph);
  359. protData.setFlow(flow);
  360. protData.setTp(tp);
  361. protData.setTn(tn);
  362. protData.setCod(cod);
  363. protData.setNh3n(nh3n);
  364. protDataMapper.insert(protData);
  365. if (i == 3) {
  366. queryWrapper.eq("farm_id", 21).eq("prot_type", 3);
  367. } else if (i == 6) {
  368. queryWrapper.eq("farm_id", 24).eq("prot_type", 3);
  369. } else {
  370. queryWrapper.eq("farm_id", 23).eq("prot_type", 3);
  371. }
  372. ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
  373. if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther3())) {
  374. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  375. protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到红色预警");
  376. protWarningInfo.setWarningType(1);
  377. protWarningInfo.setFarmId(protThreshold.getFarmId());
  378. protWarningInfo.setDate(new Date());
  379. protWarningInfo.setUserIds(protThreshold.getUserIds());
  380. protWarningInfo.setDeviceId(i);
  381. protWarningInfo.setBuildLocation("排污口");
  382. warningInfoMapper.insert(protWarningInfo);
  383. }
  384. if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther2())) {
  385. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  386. protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到橙色预警");
  387. protWarningInfo.setWarningType(1);
  388. protWarningInfo.setFarmId(protThreshold.getFarmId());
  389. protWarningInfo.setDate(new Date());
  390. protWarningInfo.setUserIds(protThreshold.getUserIds());
  391. protWarningInfo.setDeviceId(i);
  392. protWarningInfo.setBuildLocation("排污口");
  393. warningInfoMapper.insert(protWarningInfo);
  394. }
  395. if (Double.parseDouble(cod) > Double.parseDouble(protThreshold.getCod2())) {
  396. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  397. protWarningInfo.setWarningContent("排污口cod值为" + cod + "达到红色预警");
  398. protWarningInfo.setWarningType(0);
  399. protWarningInfo.setFarmId(protThreshold.getFarmId());
  400. protWarningInfo.setDate(new Date());
  401. protWarningInfo.setUserIds(protThreshold.getUserIds());
  402. protWarningInfo.setDeviceId(i);
  403. protWarningInfo.setBuildLocation("排污口");
  404. warningInfoMapper.insert(protWarningInfo);
  405. }
  406. if (Double.parseDouble(cod) > Double.parseDouble(protThreshold.getCod1())) {
  407. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  408. protWarningInfo.setWarningContent("排污口cod值为" + cod + "达到橙色预警");
  409. protWarningInfo.setWarningType(0);
  410. protWarningInfo.setFarmId(protThreshold.getFarmId());
  411. protWarningInfo.setDate(new Date());
  412. protWarningInfo.setUserIds(protThreshold.getUserIds());
  413. protWarningInfo.setDeviceId(i);
  414. protWarningInfo.setBuildLocation("排污口");
  415. warningInfoMapper.insert(protWarningInfo);
  416. }
  417. if (Double.parseDouble(nh3n) > Double.parseDouble(protThreshold.getNh3n2())) {
  418. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  419. protWarningInfo.setWarningContent("排污口NH3N值为" + nh3n + "达到红色预警");
  420. protWarningInfo.setWarningType(2);
  421. protWarningInfo.setFarmId(protThreshold.getFarmId());
  422. protWarningInfo.setDate(new Date());
  423. protWarningInfo.setUserIds(protThreshold.getUserIds());
  424. protWarningInfo.setDeviceId(i);
  425. protWarningInfo.setBuildLocation("排污口");
  426. warningInfoMapper.insert(protWarningInfo);
  427. }
  428. if (Double.parseDouble(nh3n) > Double.parseDouble(protThreshold.getNh3n1())) {
  429. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  430. protWarningInfo.setWarningContent("排污口NH3N值为" + nh3n + "达到橙色预警");
  431. protWarningInfo.setWarningType(2);
  432. protWarningInfo.setFarmId(protThreshold.getFarmId());
  433. protWarningInfo.setDate(new Date());
  434. protWarningInfo.setUserIds(protThreshold.getUserIds());
  435. protWarningInfo.setDeviceId(i);
  436. protWarningInfo.setBuildLocation("排污口");
  437. warningInfoMapper.insert(protWarningInfo);
  438. }
  439. if (Double.parseDouble(tp) > Double.parseDouble(protThreshold.getTp2())) {
  440. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  441. protWarningInfo.setWarningContent("排污口TP值为" + tp + "达到红色预警");
  442. protWarningInfo.setWarningType(3);
  443. protWarningInfo.setFarmId(protThreshold.getFarmId());
  444. protWarningInfo.setDate(new Date());
  445. protWarningInfo.setUserIds(protThreshold.getUserIds());
  446. protWarningInfo.setDeviceId(i);
  447. protWarningInfo.setBuildLocation("排污口");
  448. warningInfoMapper.insert(protWarningInfo);
  449. }
  450. if (Double.parseDouble(tp) > Double.parseDouble(protThreshold.getTp1())) {
  451. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  452. protWarningInfo.setWarningContent("排污口TP值为" + tp + "达到橙色预警");
  453. protWarningInfo.setWarningType(3);
  454. protWarningInfo.setFarmId(protThreshold.getFarmId());
  455. protWarningInfo.setDate(new Date());
  456. protWarningInfo.setUserIds(protThreshold.getUserIds());
  457. protWarningInfo.setDeviceId(i);
  458. protWarningInfo.setBuildLocation("排污口");
  459. warningInfoMapper.insert(protWarningInfo);
  460. }
  461. if (Double.parseDouble(tn) > Double.parseDouble(protThreshold.getTn2())) {
  462. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  463. protWarningInfo.setWarningContent("排污口TN值为" + tn + "达到红色预警");
  464. protWarningInfo.setWarningType(4);
  465. protWarningInfo.setFarmId(protThreshold.getFarmId());
  466. protWarningInfo.setDate(new Date());
  467. protWarningInfo.setUserIds(protThreshold.getUserIds());
  468. protWarningInfo.setDeviceId(i);
  469. protWarningInfo.setBuildLocation("排污口");
  470. warningInfoMapper.insert(protWarningInfo);
  471. }
  472. if (Double.parseDouble(tn) > Double.parseDouble(protThreshold.getTn1())) {
  473. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  474. protWarningInfo.setWarningContent("排污口TN值为" + tn + "达到橙色预警");
  475. protWarningInfo.setWarningType(4);
  476. protWarningInfo.setFarmId(protThreshold.getFarmId());
  477. protWarningInfo.setDate(new Date());
  478. protWarningInfo.setUserIds(protThreshold.getUserIds());
  479. protWarningInfo.setDeviceId(i);
  480. protWarningInfo.setBuildLocation("排污口");
  481. warningInfoMapper.insert(protWarningInfo);
  482. }
  483. if (Double.parseDouble(flow) > Double.parseDouble(protThreshold.getFlow2())) {
  484. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  485. protWarningInfo.setWarningContent("排污口累计流量值为" + flow + "达到红色预警");
  486. protWarningInfo.setWarningType(5);
  487. protWarningInfo.setFarmId(protThreshold.getFarmId());
  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.setDate(new Date());
  500. protWarningInfo.setUserIds(protThreshold.getUserIds());
  501. protWarningInfo.setDeviceId(i);
  502. protWarningInfo.setBuildLocation("排污口");
  503. warningInfoMapper.insert(protWarningInfo);
  504. }
  505. }
  506. }
  507. }
  508. }