ProtTimer.java 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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, 31.0);//nh3n
  189. String num3 = NumberUtils.getNumFloat(0.0, 3.6);//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.setDate(new Date());
  206. protWarningInfo.setUserIds(protThreshold.getUserIds());
  207. protWarningInfo.setDeviceId(i);
  208. protWarningInfo.setBuildLocation("处理口");
  209. warningInfoMapper.insert(protWarningInfo);
  210. }
  211. if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(num) < Double.parseDouble(protThreshold.getOther2())) {
  212. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  213. protWarningInfo.setWarningContent("处理口ph值为" + num + "达到橙色预警");
  214. protWarningInfo.setWarningType(1);
  215. protWarningInfo.setFarmId(protThreshold.getFarmId());
  216. protWarningInfo.setDate(new Date());
  217. protWarningInfo.setUserIds(protThreshold.getUserIds());
  218. protWarningInfo.setDeviceId(i);
  219. protWarningInfo.setBuildLocation("处理口");
  220. warningInfoMapper.insert(protWarningInfo);
  221. }
  222. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
  223. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  224. protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到红色预警");
  225. protWarningInfo.setWarningType(0);
  226. protWarningInfo.setFarmId(protThreshold.getFarmId());
  227. protWarningInfo.setDate(new Date());
  228. protWarningInfo.setUserIds(protThreshold.getUserIds());
  229. protWarningInfo.setDeviceId(i);
  230. protWarningInfo.setBuildLocation("处理口");
  231. warningInfoMapper.insert(protWarningInfo);
  232. }
  233. if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
  234. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  235. protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到橙色预警");
  236. protWarningInfo.setWarningType(0);
  237. protWarningInfo.setFarmId(protThreshold.getFarmId());
  238. protWarningInfo.setDate(new Date());
  239. protWarningInfo.setUserIds(protThreshold.getUserIds());
  240. protWarningInfo.setDeviceId(i);
  241. protWarningInfo.setBuildLocation("处理口");
  242. warningInfoMapper.insert(protWarningInfo);
  243. }
  244. if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
  245. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  246. protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到红色预警");
  247. protWarningInfo.setWarningType(2);
  248. protWarningInfo.setFarmId(protThreshold.getFarmId());
  249. protWarningInfo.setDate(new Date());
  250. protWarningInfo.setUserIds(protThreshold.getUserIds());
  251. protWarningInfo.setDeviceId(i);
  252. protWarningInfo.setBuildLocation("处理口");
  253. warningInfoMapper.insert(protWarningInfo);
  254. }
  255. if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
  256. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  257. protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到橙色预警");
  258. protWarningInfo.setWarningType(2);
  259. protWarningInfo.setFarmId(protThreshold.getFarmId());
  260. protWarningInfo.setDate(new Date());
  261. protWarningInfo.setUserIds(protThreshold.getUserIds());
  262. protWarningInfo.setDeviceId(i);
  263. protWarningInfo.setBuildLocation("处理口");
  264. warningInfoMapper.insert(protWarningInfo);
  265. }
  266. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
  267. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  268. protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到红色预警");
  269. protWarningInfo.setWarningType(3);
  270. protWarningInfo.setFarmId(protThreshold.getFarmId());
  271. protWarningInfo.setDate(new Date());
  272. protWarningInfo.setUserIds(protThreshold.getUserIds());
  273. protWarningInfo.setDeviceId(i);
  274. protWarningInfo.setBuildLocation("处理口");
  275. warningInfoMapper.insert(protWarningInfo);
  276. }
  277. if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
  278. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  279. protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到橙色预警");
  280. protWarningInfo.setWarningType(3);
  281. protWarningInfo.setFarmId(protThreshold.getFarmId());
  282. protWarningInfo.setDate(new Date());
  283. protWarningInfo.setUserIds(protThreshold.getUserIds());
  284. protWarningInfo.setDeviceId(i);
  285. protWarningInfo.setBuildLocation("处理口");
  286. warningInfoMapper.insert(protWarningInfo);
  287. }
  288. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
  289. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  290. protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到红色预警");
  291. protWarningInfo.setWarningType(4);
  292. protWarningInfo.setFarmId(protThreshold.getFarmId());
  293. protWarningInfo.setDate(new Date());
  294. protWarningInfo.setUserIds(protThreshold.getUserIds());
  295. protWarningInfo.setDeviceId(i);
  296. protWarningInfo.setBuildLocation("处理口");
  297. warningInfoMapper.insert(protWarningInfo);
  298. }
  299. if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
  300. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  301. protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到橙色预警");
  302. protWarningInfo.setWarningType(4);
  303. protWarningInfo.setFarmId(protThreshold.getFarmId());
  304. protWarningInfo.setDate(new Date());
  305. protWarningInfo.setUserIds(protThreshold.getUserIds());
  306. protWarningInfo.setDeviceId(i);
  307. protWarningInfo.setBuildLocation("处理口");
  308. warningInfoMapper.insert(protWarningInfo);
  309. }
  310. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
  311. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  312. protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到红色预警");
  313. protWarningInfo.setWarningType(5);
  314. protWarningInfo.setFarmId(protThreshold.getFarmId());
  315. protWarningInfo.setDate(new Date());
  316. protWarningInfo.setUserIds(protThreshold.getUserIds());
  317. protWarningInfo.setDeviceId(i);
  318. protWarningInfo.setBuildLocation("处理口");
  319. warningInfoMapper.insert(protWarningInfo);
  320. }
  321. if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
  322. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  323. protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到橙色预警");
  324. protWarningInfo.setWarningType(5);
  325. protWarningInfo.setFarmId(protThreshold.getFarmId());
  326. protWarningInfo.setDate(new Date());
  327. protWarningInfo.setUserIds(protThreshold.getUserIds());
  328. protWarningInfo.setDeviceId(i);
  329. protWarningInfo.setBuildLocation("处理口");
  330. warningInfoMapper.insert(protWarningInfo);
  331. }
  332. }
  333. if (i == 3) {
  334. //排污口专用数据
  335. String ph = NumberUtils.getNumFloat(6.6, 8.4);//ph
  336. String cod = NumberUtils.getNum(0, 380, 0);//cod
  337. String nh3n = NumberUtils.getNum(0, 50, 1);//nh3n
  338. String tp = NumberUtils.getNumFloat(0.0, 10.0);//tp
  339. String tn = NumberUtils.getNum(0, 150, 1);//tn
  340. String flow = NumberUtils.getNum(0, 100, 1);//flow
  341. protData.setPh(ph);
  342. protData.setFlow(flow);
  343. protData.setTp(tp);
  344. protData.setTn(tn);
  345. protData.setCod(cod);
  346. protData.setNh3n(nh3n);
  347. protDataMapper.insert(protData);
  348. queryWrapper.eq("farm_id", 21).eq("prot_type", 3);
  349. ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
  350. if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh2()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther3())) {
  351. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  352. protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到红色预警");
  353. protWarningInfo.setWarningType(1);
  354. protWarningInfo.setFarmId(protThreshold.getFarmId());
  355. protWarningInfo.setDate(new Date());
  356. protWarningInfo.setUserIds(protThreshold.getUserIds());
  357. protWarningInfo.setDeviceId(i);
  358. protWarningInfo.setBuildLocation("排污口");
  359. warningInfoMapper.insert(protWarningInfo);
  360. }
  361. if (Double.parseDouble(ph) > Double.parseDouble(protThreshold.getPh1()) || Double.parseDouble(ph) < Double.parseDouble(protThreshold.getOther2())) {
  362. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  363. protWarningInfo.setWarningContent("排污口ph值为" + ph + "达到橙色预警");
  364. protWarningInfo.setWarningType(1);
  365. protWarningInfo.setFarmId(protThreshold.getFarmId());
  366. protWarningInfo.setDate(new Date());
  367. protWarningInfo.setUserIds(protThreshold.getUserIds());
  368. protWarningInfo.setDeviceId(i);
  369. protWarningInfo.setBuildLocation("排污口");
  370. warningInfoMapper.insert(protWarningInfo);
  371. }
  372. if (Double.parseDouble(cod) > Double.parseDouble(protThreshold.getCod2())) {
  373. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  374. protWarningInfo.setWarningContent("排污口cod值为" + cod + "达到红色预警");
  375. protWarningInfo.setWarningType(0);
  376. protWarningInfo.setFarmId(protThreshold.getFarmId());
  377. protWarningInfo.setDate(new Date());
  378. protWarningInfo.setUserIds(protThreshold.getUserIds());
  379. protWarningInfo.setDeviceId(i);
  380. protWarningInfo.setBuildLocation("排污口");
  381. warningInfoMapper.insert(protWarningInfo);
  382. }
  383. if (Double.parseDouble(cod) > Double.parseDouble(protThreshold.getCod1())) {
  384. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  385. protWarningInfo.setWarningContent("排污口cod值为" + cod + "达到橙色预警");
  386. protWarningInfo.setWarningType(0);
  387. protWarningInfo.setFarmId(protThreshold.getFarmId());
  388. protWarningInfo.setDate(new Date());
  389. protWarningInfo.setUserIds(protThreshold.getUserIds());
  390. protWarningInfo.setDeviceId(i);
  391. protWarningInfo.setBuildLocation("排污口");
  392. warningInfoMapper.insert(protWarningInfo);
  393. }
  394. if (Double.parseDouble(nh3n) > Double.parseDouble(protThreshold.getNh3n2())) {
  395. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  396. protWarningInfo.setWarningContent("排污口NH3N值为" + nh3n + "达到红色预警");
  397. protWarningInfo.setWarningType(2);
  398. protWarningInfo.setFarmId(protThreshold.getFarmId());
  399. protWarningInfo.setDate(new Date());
  400. protWarningInfo.setUserIds(protThreshold.getUserIds());
  401. protWarningInfo.setDeviceId(i);
  402. protWarningInfo.setBuildLocation("排污口");
  403. warningInfoMapper.insert(protWarningInfo);
  404. }
  405. if (Double.parseDouble(nh3n) > Double.parseDouble(protThreshold.getNh3n1())) {
  406. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  407. protWarningInfo.setWarningContent("排污口NH3N值为" + nh3n + "达到橙色预警");
  408. protWarningInfo.setWarningType(2);
  409. protWarningInfo.setFarmId(protThreshold.getFarmId());
  410. protWarningInfo.setDate(new Date());
  411. protWarningInfo.setUserIds(protThreshold.getUserIds());
  412. protWarningInfo.setDeviceId(i);
  413. protWarningInfo.setBuildLocation("排污口");
  414. warningInfoMapper.insert(protWarningInfo);
  415. }
  416. if (Double.parseDouble(tp) > Double.parseDouble(protThreshold.getTp2())) {
  417. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  418. protWarningInfo.setWarningContent("排污口TP值为" + tp + "达到红色预警");
  419. protWarningInfo.setWarningType(3);
  420. protWarningInfo.setFarmId(protThreshold.getFarmId());
  421. protWarningInfo.setDate(new Date());
  422. protWarningInfo.setUserIds(protThreshold.getUserIds());
  423. protWarningInfo.setDeviceId(i);
  424. protWarningInfo.setBuildLocation("排污口");
  425. warningInfoMapper.insert(protWarningInfo);
  426. }
  427. if (Double.parseDouble(tp) > Double.parseDouble(protThreshold.getTp1())) {
  428. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  429. protWarningInfo.setWarningContent("排污口TP值为" + tp + "达到橙色预警");
  430. protWarningInfo.setWarningType(3);
  431. protWarningInfo.setFarmId(protThreshold.getFarmId());
  432. protWarningInfo.setDate(new Date());
  433. protWarningInfo.setUserIds(protThreshold.getUserIds());
  434. protWarningInfo.setDeviceId(i);
  435. protWarningInfo.setBuildLocation("排污口");
  436. warningInfoMapper.insert(protWarningInfo);
  437. }
  438. if (Double.parseDouble(tn) > Double.parseDouble(protThreshold.getTn2())) {
  439. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  440. protWarningInfo.setWarningContent("排污口TN值为" + tn + "达到红色预警");
  441. protWarningInfo.setWarningType(4);
  442. protWarningInfo.setFarmId(protThreshold.getFarmId());
  443. protWarningInfo.setDate(new Date());
  444. protWarningInfo.setUserIds(protThreshold.getUserIds());
  445. protWarningInfo.setDeviceId(i);
  446. protWarningInfo.setBuildLocation("排污口");
  447. warningInfoMapper.insert(protWarningInfo);
  448. }
  449. if (Double.parseDouble(tn) > Double.parseDouble(protThreshold.getTn1())) {
  450. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  451. protWarningInfo.setWarningContent("排污口TN值为" + tn + "达到橙色预警");
  452. protWarningInfo.setWarningType(4);
  453. protWarningInfo.setFarmId(protThreshold.getFarmId());
  454. protWarningInfo.setDate(new Date());
  455. protWarningInfo.setUserIds(protThreshold.getUserIds());
  456. protWarningInfo.setDeviceId(i);
  457. protWarningInfo.setBuildLocation("排污口");
  458. warningInfoMapper.insert(protWarningInfo);
  459. }
  460. if (Double.parseDouble(flow) > Double.parseDouble(protThreshold.getFlow2())) {
  461. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  462. protWarningInfo.setWarningContent("排污口累计流量值为" + flow + "达到红色预警");
  463. protWarningInfo.setWarningType(5);
  464. protWarningInfo.setFarmId(protThreshold.getFarmId());
  465. protWarningInfo.setDate(new Date());
  466. protWarningInfo.setUserIds(protThreshold.getUserIds());
  467. protWarningInfo.setDeviceId(i);
  468. protWarningInfo.setBuildLocation("排污口");
  469. warningInfoMapper.insert(protWarningInfo);
  470. }
  471. if (Double.parseDouble(flow) > Double.parseDouble(protThreshold.getFlow1())) {
  472. ProtWarningInfo protWarningInfo = new ProtWarningInfo();
  473. protWarningInfo.setWarningContent("排污口累计流量值为" + flow + "达到橙色预警");
  474. protWarningInfo.setWarningType(5);
  475. protWarningInfo.setFarmId(protThreshold.getFarmId());
  476. protWarningInfo.setDate(new Date());
  477. protWarningInfo.setUserIds(protThreshold.getUserIds());
  478. protWarningInfo.setDeviceId(i);
  479. protWarningInfo.setBuildLocation("排污口");
  480. warningInfoMapper.insert(protWarningInfo);
  481. }
  482. }
  483. }
  484. }
  485. }