ProtDataServiceImpl.java 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. package com.huimv.admin.service.impl;
  2. import cn.hutool.core.date.DateTime;
  3. import cn.hutool.core.date.DateUtil;
  4. import cn.hutool.core.util.ObjectUtil;
  5. import com.alibaba.fastjson.JSONArray;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import com.huimv.admin.common.utils.DataUill;
  9. import com.huimv.admin.common.utils.Result;
  10. import com.huimv.admin.common.utils.ResultCode;
  11. import com.huimv.admin.entity.ProdFermentDevice;
  12. import com.huimv.admin.entity.ProtData;
  13. import com.huimv.admin.entity.ProtWarningInfo;
  14. import com.huimv.admin.entity.WriteProtData;
  15. import com.huimv.admin.entity.dto.ProCountDto;
  16. import com.huimv.admin.entity.vo.ProCountVo;
  17. import com.huimv.admin.entity.vo.ProDataVo;
  18. import com.huimv.admin.entity.vo.WriteProtDataVo;
  19. import com.huimv.admin.mapper.ProdFermentDeviceMapper;
  20. import com.huimv.admin.mapper.ProtDataMapper;
  21. import com.huimv.admin.mapper.ProtWarningInfoMapper;
  22. import com.huimv.admin.mapper.WriteProtDataMapper;
  23. import com.huimv.admin.service.IProtDataService;
  24. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.stereotype.Service;
  27. import javax.servlet.http.HttpServletRequest;
  28. import java.text.SimpleDateFormat;
  29. import java.util.*;
  30. /**
  31. * <p>
  32. * 服务实现类
  33. * </p>
  34. *
  35. * @author author
  36. * @since 2023-02-14
  37. */
  38. @Service
  39. public class ProtDataServiceImpl extends ServiceImpl<ProtDataMapper, ProtData> implements IProtDataService {
  40. @Autowired
  41. private ProtDataMapper protDataMapper;
  42. @Autowired
  43. private ProtWarningInfoMapper protWarningInfoMapper;
  44. @Autowired
  45. private ProdFermentDeviceMapper fermentDeviceMapper;
  46. @Autowired
  47. private WriteProtDataMapper writeProtDataMapper;
  48. @Override
  49. public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  50. String farmId = paramsMap.get("farmId");
  51. String displayType = paramsMap.get("displayType");//2为填报数据展示
  52. String startTime = paramsMap.get("startTime");
  53. String endTime = paramsMap.get("endTime");
  54. String type = paramsMap.get("type");
  55. String dataType = paramsMap.get("dataType");
  56. if (type == null || type == "") {
  57. type = "1";
  58. }
  59. if (dataType == null || dataType == "") {
  60. dataType = "1";
  61. }
  62. if (displayType == null || displayType == "") {
  63. displayType = "0";
  64. }
  65. ProCountDto proCountDto = new ProCountDto();
  66. if ("0".equals(displayType)) {
  67. QueryWrapper<ProtData> queryWrapper = new QueryWrapper<>();
  68. queryWrapper.eq("farm_id", farmId);
  69. //ph
  70. if ("1".equals(dataType)) {
  71. if ("4".equals(type)) {
  72. startTime = startTime + " 00:00:00";
  73. endTime = endTime + " 23:59:59";
  74. queryWrapper.between("create_date", startTime, endTime);
  75. queryWrapper.eq("loction_type", 1);
  76. List<ProCountVo> protData1 = protDataMapper.listPh(queryWrapper);
  77. proCountDto.setInList(protData1);
  78. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  79. queryWrapper2.eq("farm_id", farmId);
  80. queryWrapper2.between("create_date", startTime, endTime);
  81. queryWrapper2.eq("loction_type", 2);
  82. List<ProCountVo> protData2 = protDataMapper.listPh(queryWrapper2);
  83. proCountDto.setDealList(protData2);
  84. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  85. queryWrapper3.eq("farm_id", farmId);
  86. queryWrapper3.between("create_date", startTime, endTime);
  87. queryWrapper3.eq("loction_type", 3);
  88. List<ProCountVo> protData3 = protDataMapper.listPh(queryWrapper3);
  89. proCountDto.setOutList(protData3);
  90. }
  91. //本年
  92. else if ("3".equals(type)) {
  93. Calendar dateTime = Calendar.getInstance();
  94. int i = dateTime.get(Calendar.YEAR);
  95. // DateTime dateTime = DateUtil.beginOfYear(new Date());
  96. queryWrapper.ge("create_date", i);
  97. queryWrapper.eq("loction_type", 1);
  98. List<ProCountVo> protData1 = protDataMapper.listPhYear(queryWrapper);
  99. proCountDto.setInList(protData1);
  100. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  101. queryWrapper2.eq("farm_id", farmId).ge("create_date", i);
  102. queryWrapper2.eq("loction_type", 2);
  103. List<ProCountVo> protData2 = protDataMapper.listPhYear(queryWrapper2);
  104. proCountDto.setDealList(protData2);
  105. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  106. queryWrapper3.eq("farm_id", farmId).ge("create_date", i);
  107. queryWrapper3.eq("loction_type", 3);
  108. List<ProCountVo> protData3 = protDataMapper.listPhYear(queryWrapper3);
  109. proCountDto.setOutList(protData3);
  110. }
  111. //本月
  112. else if ("2".equals(type)) {
  113. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  114. queryWrapper.ge("create_date", timesMonthmorning);
  115. queryWrapper.eq("loction_type", 1);
  116. List<ProCountVo> protData1 = protDataMapper.listPh(queryWrapper);
  117. proCountDto.setInList(protData1);
  118. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  119. queryWrapper2.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  120. queryWrapper2.eq("loction_type", 2);
  121. List<ProCountVo> protData2 = protDataMapper.listPh(queryWrapper2);
  122. proCountDto.setDealList(protData2);
  123. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  124. queryWrapper3.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  125. queryWrapper3.eq("loction_type", 3);
  126. List<ProCountVo> protData3 = protDataMapper.listPh(queryWrapper3);
  127. proCountDto.setOutList(protData3);
  128. }
  129. //本周
  130. else if ("1".equals(type)) {
  131. Calendar calendar = Calendar.getInstance();
  132. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  133. Date dateTime = calendar.getTime();
  134. queryWrapper.ge("create_date", dateTime);
  135. queryWrapper.eq("loction_type", 1);
  136. List<ProCountVo> protData1 = protDataMapper.listPh(queryWrapper);
  137. proCountDto.setInList(protData1);
  138. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  139. queryWrapper2.eq("farm_id", farmId).ge("create_date", dateTime);
  140. queryWrapper2.eq("loction_type", 2);
  141. List<ProCountVo> protData2 = protDataMapper.listPh(queryWrapper2);
  142. proCountDto.setDealList(protData2);
  143. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  144. queryWrapper3.eq("farm_id", farmId).ge("create_date", dateTime);
  145. queryWrapper3.eq("loction_type", 3);
  146. List<ProCountVo> protData3 = protDataMapper.listPh(queryWrapper3);
  147. proCountDto.setOutList(protData3);
  148. }
  149. }
  150. //cod
  151. else if ("2".equals(dataType)) {
  152. if ("4".equals(type)) {
  153. startTime = startTime + " 00:00:00";
  154. endTime = endTime + " 23:59:59";
  155. queryWrapper.between("create_date", startTime, endTime);
  156. queryWrapper.eq("loction_type", 1);
  157. List<ProCountVo> protData1 = protDataMapper.listCod(queryWrapper);
  158. proCountDto.setInList(protData1);
  159. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  160. queryWrapper2.eq("farm_id", farmId);
  161. queryWrapper2.between("create_date", startTime, endTime);
  162. queryWrapper2.eq("loction_type", 2);
  163. List<ProCountVo> protData2 = protDataMapper.listCod(queryWrapper2);
  164. proCountDto.setDealList(protData2);
  165. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  166. queryWrapper3.eq("farm_id", farmId);
  167. queryWrapper3.between("create_date", startTime, endTime);
  168. queryWrapper3.eq("loction_type", 3);
  169. List<ProCountVo> protData3 = protDataMapper.listCod(queryWrapper3);
  170. proCountDto.setOutList(protData3);
  171. }
  172. //本年
  173. else if ("3".equals(type)) {
  174. Calendar dateTime = Calendar.getInstance();
  175. int i = dateTime.get(Calendar.YEAR);
  176. // DateTime dateTime = DateUtil.beginOfYear(new Date());
  177. queryWrapper.ge("create_date", i);
  178. queryWrapper.eq("loction_type", 1);
  179. List<ProCountVo> protData1 = protDataMapper.listCodYear(queryWrapper);
  180. proCountDto.setInList(protData1);
  181. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  182. queryWrapper2.eq("farm_id", farmId).ge("create_date", i);
  183. queryWrapper2.eq("loction_type", 2);
  184. List<ProCountVo> protData2 = protDataMapper.listCodYear(queryWrapper2);
  185. proCountDto.setDealList(protData2);
  186. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  187. queryWrapper3.eq("farm_id", farmId).ge("create_date", i);
  188. queryWrapper3.eq("loction_type", 3);
  189. List<ProCountVo> protData3 = protDataMapper.listCodYear(queryWrapper3);
  190. proCountDto.setOutList(protData3);
  191. }
  192. //本月
  193. else if ("2".equals(type)) {
  194. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  195. queryWrapper.ge("create_date", timesMonthmorning);
  196. queryWrapper.eq("loction_type", 1);
  197. List<ProCountVo> protData1 = protDataMapper.listCod(queryWrapper);
  198. proCountDto.setInList(protData1);
  199. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  200. queryWrapper2.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  201. queryWrapper2.eq("loction_type", 2);
  202. List<ProCountVo> protData2 = protDataMapper.listCod(queryWrapper2);
  203. proCountDto.setDealList(protData2);
  204. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  205. queryWrapper3.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  206. queryWrapper3.eq("loction_type", 3);
  207. List<ProCountVo> protData3 = protDataMapper.listCod(queryWrapper3);
  208. proCountDto.setOutList(protData3);
  209. }
  210. //本周
  211. else if ("1".equals(type)) {
  212. Calendar calendar = Calendar.getInstance();
  213. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  214. Date dateTime = calendar.getTime();
  215. queryWrapper.ge("create_date", dateTime);
  216. queryWrapper.eq("loction_type", 1);
  217. List<ProCountVo> protData1 = protDataMapper.listCod(queryWrapper);
  218. proCountDto.setInList(protData1);
  219. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  220. queryWrapper2.eq("farm_id", farmId).ge("create_date", dateTime);
  221. queryWrapper2.eq("loction_type", 2);
  222. List<ProCountVo> protData2 = protDataMapper.listCod(queryWrapper2);
  223. proCountDto.setDealList(protData2);
  224. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  225. queryWrapper3.eq("farm_id", farmId).ge("create_date", dateTime);
  226. queryWrapper3.eq("loction_type", 3);
  227. List<ProCountVo> protData3 = protDataMapper.listCod(queryWrapper3);
  228. proCountDto.setOutList(protData3);
  229. }
  230. }
  231. //NH3N
  232. else if ("3".equals(dataType)) {
  233. if ("4".equals(type)) {
  234. startTime = startTime + " 00:00:00";
  235. endTime = endTime + " 23:59:59";
  236. queryWrapper.between("create_date", startTime, endTime);
  237. queryWrapper.eq("loction_type", 1);
  238. List<ProCountVo> protData1 = protDataMapper.listNh3n(queryWrapper);
  239. proCountDto.setInList(protData1);
  240. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  241. queryWrapper2.eq("farm_id", farmId);
  242. queryWrapper2.between("create_date", startTime, endTime);
  243. queryWrapper2.eq("loction_type", 2);
  244. List<ProCountVo> protData2 = protDataMapper.listNh3n(queryWrapper2);
  245. proCountDto.setDealList(protData2);
  246. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  247. queryWrapper3.eq("farm_id", farmId);
  248. queryWrapper3.between("create_date", startTime, endTime);
  249. queryWrapper3.eq("loction_type", 3);
  250. List<ProCountVo> protData3 = protDataMapper.listNh3n(queryWrapper3);
  251. proCountDto.setOutList(protData3);
  252. // protDataList=endList;
  253. }
  254. //本年
  255. else if ("3".equals(type)) {
  256. Calendar dateTime = Calendar.getInstance();
  257. int i = dateTime.get(Calendar.YEAR);
  258. // DateTime dateTime = DateUtil.beginOfYear(new Date());
  259. queryWrapper.ge("create_date", i);
  260. queryWrapper.eq("loction_type", 1);
  261. List<ProCountVo> protData1 = protDataMapper.listNh3nYear(queryWrapper);
  262. proCountDto.setInList(protData1);
  263. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  264. queryWrapper2.eq("farm_id", farmId).ge("create_date", i);
  265. queryWrapper2.eq("loction_type", 2);
  266. List<ProCountVo> protData2 = protDataMapper.listNh3nYear(queryWrapper2);
  267. proCountDto.setDealList(protData2);
  268. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  269. queryWrapper3.eq("farm_id", farmId).ge("create_date", i);
  270. queryWrapper3.eq("loction_type", 3);
  271. List<ProCountVo> protData3 = protDataMapper.listNh3nYear(queryWrapper3);
  272. proCountDto.setOutList(protData3);
  273. }
  274. //本月
  275. else if ("2".equals(type)) {
  276. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  277. queryWrapper.ge("create_date", timesMonthmorning);
  278. queryWrapper.eq("loction_type", 1);
  279. List<ProCountVo> protData1 = protDataMapper.listNh3n(queryWrapper);
  280. proCountDto.setInList(protData1);
  281. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  282. queryWrapper2.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  283. queryWrapper2.eq("loction_type", 2);
  284. List<ProCountVo> protData2 = protDataMapper.listNh3n(queryWrapper2);
  285. proCountDto.setDealList(protData2);
  286. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  287. queryWrapper3.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  288. queryWrapper3.eq("loction_type", 3);
  289. List<ProCountVo> protData3 = protDataMapper.listNh3n(queryWrapper3);
  290. proCountDto.setOutList(protData3);
  291. }
  292. //本周
  293. else if ("1".equals(type)) {
  294. Calendar calendar = Calendar.getInstance();
  295. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  296. Date dateTime = calendar.getTime();
  297. queryWrapper.ge("create_date", dateTime);
  298. queryWrapper.eq("loction_type", 1);
  299. List<ProCountVo> protData1 = protDataMapper.listNh3n(queryWrapper);
  300. proCountDto.setInList(protData1);
  301. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  302. queryWrapper2.eq("farm_id", farmId).ge("create_date", dateTime);
  303. queryWrapper2.eq("loction_type", 2);
  304. List<ProCountVo> protData2 = protDataMapper.listNh3n(queryWrapper2);
  305. proCountDto.setDealList(protData2);
  306. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  307. queryWrapper3.eq("farm_id", farmId).ge("create_date", dateTime);
  308. queryWrapper3.eq("loction_type", 3);
  309. List<ProCountVo> protData3 = protDataMapper.listNh3n(queryWrapper3);
  310. proCountDto.setOutList(protData3);
  311. }
  312. }
  313. //TP
  314. else if ("4".equals(dataType)) {
  315. if ("4".equals(type)) {
  316. startTime = startTime + " 00:00:00";
  317. endTime = endTime + " 23:59:59";
  318. queryWrapper.between("create_date", startTime, endTime);
  319. queryWrapper.eq("loction_type", 1);
  320. List<ProCountVo> protData1 = protDataMapper.listTp(queryWrapper);
  321. proCountDto.setInList(protData1);
  322. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  323. queryWrapper2.eq("farm_id", farmId);
  324. queryWrapper2.between("create_date", startTime, endTime);
  325. queryWrapper2.eq("loction_type", 2);
  326. List<ProCountVo> protData2 = protDataMapper.listTp(queryWrapper2);
  327. proCountDto.setDealList(protData2);
  328. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  329. queryWrapper3.eq("farm_id", farmId);
  330. queryWrapper3.between("create_date", startTime, endTime);
  331. queryWrapper3.eq("loction_type", 3);
  332. List<ProCountVo> protData3 = protDataMapper.listTp(queryWrapper3);
  333. proCountDto.setOutList(protData3);
  334. // protDataList=endList;
  335. }
  336. //本年
  337. else if ("3".equals(type)) {
  338. Calendar dateTime = Calendar.getInstance();
  339. int i = dateTime.get(Calendar.YEAR);
  340. // DateTime dateTime = DateUtil.beginOfYear(new Date());
  341. queryWrapper.ge("create_date", i);
  342. queryWrapper.eq("loction_type", 1);
  343. List<ProCountVo> protData1 = protDataMapper.listTpYear(queryWrapper);
  344. proCountDto.setInList(protData1);
  345. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  346. queryWrapper2.eq("farm_id", farmId).ge("create_date", i);
  347. queryWrapper2.eq("loction_type", 2);
  348. List<ProCountVo> protData2 = protDataMapper.listTpYear(queryWrapper2);
  349. proCountDto.setDealList(protData2);
  350. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  351. queryWrapper3.eq("farm_id", farmId).ge("create_date", i);
  352. queryWrapper3.eq("loction_type", 3);
  353. List<ProCountVo> protData3 = protDataMapper.listTpYear(queryWrapper3);
  354. proCountDto.setOutList(protData3);
  355. }
  356. //本月
  357. else if ("2".equals(type)) {
  358. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  359. queryWrapper.ge("create_date", timesMonthmorning);
  360. queryWrapper.eq("loction_type", 1);
  361. List<ProCountVo> protData1 = protDataMapper.listTp(queryWrapper);
  362. proCountDto.setInList(protData1);
  363. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  364. queryWrapper2.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  365. queryWrapper2.eq("loction_type", 2);
  366. List<ProCountVo> protData2 = protDataMapper.listTp(queryWrapper2);
  367. proCountDto.setDealList(protData2);
  368. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  369. queryWrapper3.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  370. queryWrapper3.eq("loction_type", 3);
  371. List<ProCountVo> protData3 = protDataMapper.listTp(queryWrapper3);
  372. proCountDto.setOutList(protData3);
  373. }
  374. //本周
  375. else if ("1".equals(type)) {
  376. Calendar calendar = Calendar.getInstance();
  377. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  378. Date dateTime = calendar.getTime();
  379. queryWrapper.ge("create_date", dateTime);
  380. queryWrapper.eq("loction_type", 1);
  381. List<ProCountVo> protData1 = protDataMapper.listTp(queryWrapper);
  382. proCountDto.setInList(protData1);
  383. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  384. queryWrapper2.eq("farm_id", farmId).ge("create_date", dateTime);
  385. queryWrapper2.eq("loction_type", 2);
  386. List<ProCountVo> protData2 = protDataMapper.listTp(queryWrapper2);
  387. proCountDto.setDealList(protData2);
  388. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  389. queryWrapper3.eq("farm_id", farmId).ge("create_date", dateTime);
  390. queryWrapper3.eq("loction_type", 3);
  391. List<ProCountVo> protData3 = protDataMapper.listTp(queryWrapper3);
  392. proCountDto.setOutList(protData3);
  393. }
  394. }
  395. //TN
  396. else if ("5".equals(dataType)) {
  397. if ("4".equals(type)) {
  398. startTime = startTime + " 00:00:00";
  399. endTime = endTime + " 23:59:59";
  400. queryWrapper.between("create_date", startTime, endTime);
  401. queryWrapper.eq("loction_type", 1);
  402. List<ProCountVo> protData1 = protDataMapper.listTn(queryWrapper);
  403. proCountDto.setInList(protData1);
  404. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  405. queryWrapper2.eq("farm_id", farmId);
  406. queryWrapper2.between("create_date", startTime, endTime);
  407. queryWrapper2.eq("loction_type", 2);
  408. List<ProCountVo> protData2 = protDataMapper.listTn(queryWrapper2);
  409. proCountDto.setDealList(protData2);
  410. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  411. queryWrapper3.eq("farm_id", farmId);
  412. queryWrapper3.between("create_date", startTime, endTime);
  413. queryWrapper3.eq("loction_type", 3);
  414. List<ProCountVo> protData3 = protDataMapper.listTn(queryWrapper3);
  415. proCountDto.setOutList(protData3);
  416. // protDataList=endList;
  417. }
  418. //本年
  419. else if ("3".equals(type)) {
  420. Calendar dateTime = Calendar.getInstance();
  421. int i = dateTime.get(Calendar.YEAR);
  422. // DateTime dateTime = DateUtil.beginOfYear(new Date());
  423. queryWrapper.ge("create_date", i);
  424. queryWrapper.eq("loction_type", 1);
  425. List<ProCountVo> protData1 = protDataMapper.listTnYear(queryWrapper);
  426. proCountDto.setInList(protData1);
  427. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  428. queryWrapper2.eq("farm_id", farmId).ge("create_date", i);
  429. queryWrapper2.eq("loction_type", 2);
  430. List<ProCountVo> protData2 = protDataMapper.listTnYear(queryWrapper2);
  431. proCountDto.setDealList(protData2);
  432. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  433. queryWrapper3.eq("farm_id", farmId).ge("create_date", i);
  434. queryWrapper3.eq("loction_type", 3);
  435. List<ProCountVo> protData3 = protDataMapper.listTnYear(queryWrapper3);
  436. proCountDto.setOutList(protData3);
  437. }
  438. //本月
  439. else if ("2".equals(type)) {
  440. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  441. queryWrapper.ge("create_date", timesMonthmorning);
  442. queryWrapper.eq("loction_type", 1);
  443. List<ProCountVo> protData1 = protDataMapper.listTn(queryWrapper);
  444. proCountDto.setInList(protData1);
  445. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  446. queryWrapper2.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  447. queryWrapper2.eq("loction_type", 2);
  448. List<ProCountVo> protData2 = protDataMapper.listTn(queryWrapper2);
  449. proCountDto.setDealList(protData2);
  450. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  451. queryWrapper3.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  452. queryWrapper3.eq("loction_type", 3);
  453. List<ProCountVo> protData3 = protDataMapper.listTn(queryWrapper3);
  454. proCountDto.setOutList(protData3);
  455. }
  456. //本周
  457. else if ("1".equals(type)) {
  458. Calendar calendar = Calendar.getInstance();
  459. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  460. Date dateTime = calendar.getTime();
  461. queryWrapper.ge("create_date", dateTime);
  462. queryWrapper.eq("loction_type", 1);
  463. List<ProCountVo> protData1 = protDataMapper.listTn(queryWrapper);
  464. proCountDto.setInList(protData1);
  465. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  466. queryWrapper2.eq("farm_id", farmId).ge("create_date", dateTime);
  467. queryWrapper2.eq("loction_type", 2);
  468. List<ProCountVo> protData2 = protDataMapper.listTn(queryWrapper2);
  469. proCountDto.setDealList(protData2);
  470. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  471. queryWrapper3.eq("farm_id", farmId).ge("create_date", dateTime);
  472. queryWrapper3.eq("loction_type", 3);
  473. List<ProCountVo> protData3 = protDataMapper.listTn(queryWrapper3);
  474. proCountDto.setOutList(protData3);
  475. }
  476. }
  477. //FLOW
  478. else if ("6".equals(dataType)) {
  479. if ("4".equals(type)) {
  480. startTime = startTime + " 00:00:00";
  481. endTime = endTime + " 23:59:59";
  482. queryWrapper.between("create_date", startTime, endTime);
  483. queryWrapper.eq("loction_type", 1);
  484. List<ProCountVo> protData1 = protDataMapper.listFlow(queryWrapper);
  485. proCountDto.setInList(protData1);
  486. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  487. queryWrapper2.eq("farm_id", farmId);
  488. queryWrapper2.between("create_date", startTime, endTime);
  489. queryWrapper2.eq("loction_type", 2);
  490. List<ProCountVo> protData2 = protDataMapper.listFlow(queryWrapper2);
  491. proCountDto.setDealList(protData2);
  492. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  493. queryWrapper3.eq("farm_id", farmId);
  494. queryWrapper3.between("create_date", startTime, endTime);
  495. queryWrapper3.eq("loction_type", 3);
  496. List<ProCountVo> protData3 = protDataMapper.listFlow(queryWrapper3);
  497. proCountDto.setOutList(protData3);
  498. // protDataList=endList;
  499. }
  500. //本年
  501. else if ("3".equals(type)) {
  502. Calendar dateTime = Calendar.getInstance();
  503. int i = dateTime.get(Calendar.YEAR);
  504. // DateTime dateTime = DateUtil.beginOfYear(new Date());
  505. queryWrapper.ge("create_date", i);
  506. queryWrapper.eq("loction_type", 1);
  507. List<ProCountVo> protData1 = protDataMapper.listFlowYear(queryWrapper);
  508. proCountDto.setInList(protData1);
  509. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  510. queryWrapper2.eq("farm_id", farmId).ge("create_date", i);
  511. queryWrapper2.eq("loction_type", 2);
  512. List<ProCountVo> protData2 = protDataMapper.listFlowYear(queryWrapper2);
  513. proCountDto.setDealList(protData2);
  514. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  515. queryWrapper3.eq("farm_id", farmId).ge("create_date", i);
  516. queryWrapper3.eq("loction_type", 3);
  517. List<ProCountVo> protData3 = protDataMapper.listFlowYear(queryWrapper3);
  518. proCountDto.setOutList(protData3);
  519. }
  520. //本月
  521. else if ("2".equals(type)) {
  522. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  523. queryWrapper.ge("create_date", timesMonthmorning);
  524. queryWrapper.eq("loction_type", 1);
  525. List<ProCountVo> protData1 = protDataMapper.listFlow(queryWrapper);
  526. proCountDto.setInList(protData1);
  527. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  528. queryWrapper2.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  529. queryWrapper2.eq("loction_type", 2);
  530. List<ProCountVo> protData2 = protDataMapper.listFlow(queryWrapper2);
  531. proCountDto.setDealList(protData2);
  532. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  533. queryWrapper3.eq("farm_id", farmId).ge("create_date", timesMonthmorning);
  534. queryWrapper3.eq("loction_type", 3);
  535. List<ProCountVo> protData3 = protDataMapper.listFlow(queryWrapper3);
  536. proCountDto.setOutList(protData3);
  537. }
  538. //本周
  539. else if ("1".equals(type)) {
  540. Calendar calendar = Calendar.getInstance();
  541. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  542. Date dateTime = calendar.getTime();
  543. queryWrapper.ge("create_date", dateTime);
  544. queryWrapper.eq("loction_type", 1);
  545. List<ProCountVo> protData1 = protDataMapper.listFlow(queryWrapper);
  546. proCountDto.setInList(protData1);
  547. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  548. queryWrapper2.eq("farm_id", farmId).ge("create_date", dateTime);
  549. queryWrapper2.eq("loction_type", 2);
  550. List<ProCountVo> protData2 = protDataMapper.listFlow(queryWrapper2);
  551. proCountDto.setDealList(protData2);
  552. QueryWrapper<ProtData> queryWrapper3 = new QueryWrapper<>();
  553. queryWrapper3.eq("farm_id", farmId).ge("create_date", dateTime);
  554. queryWrapper3.eq("loction_type", 3);
  555. List<ProCountVo> protData3 = protDataMapper.listFlow(queryWrapper3);
  556. proCountDto.setOutList(protData3);
  557. }
  558. }
  559. } else {
  560. QueryWrapper<WriteProtData> queryWrapper = new QueryWrapper<>();
  561. queryWrapper.eq("farm_id", farmId);
  562. //ph
  563. List<ProCountVo> inList = new ArrayList<>();
  564. List<ProCountVo> dealList = new ArrayList<>();
  565. List<ProCountVo> outList = new ArrayList<>();
  566. List<WriteProtDataVo> writeProtDataVos;
  567. if ("1".equals(dataType)) {
  568. if ("3".equals(type)) {
  569. Calendar dateTime = Calendar.getInstance();
  570. int i = dateTime.get(Calendar.YEAR);
  571. queryWrapper.ge("create_date", i);
  572. writeProtDataVos = writeProtDataMapper.listWriteYear(queryWrapper);
  573. } else {
  574. if ("4".equals(type)) {
  575. startTime = startTime + " 00:00:00";
  576. endTime = endTime + " 23:59:59";
  577. queryWrapper.between("create_date", startTime, endTime);
  578. } else if ("2".equals(type)) {
  579. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  580. queryWrapper.ge("create_date", timesMonthmorning);
  581. } else if ("1".equals(type)) {
  582. Calendar calendar = Calendar.getInstance();
  583. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  584. Date dateTime = calendar.getTime();
  585. queryWrapper.ge("create_date", dateTime);
  586. }
  587. writeProtDataVos = writeProtDataMapper.listWrite(queryWrapper);
  588. }
  589. for (WriteProtDataVo writeProtDataVo : writeProtDataVos) {
  590. ProCountVo proCountVo = new ProCountVo();
  591. proCountVo.setValue(writeProtDataVo.getPh());
  592. proCountVo.setCreateDate(writeProtDataVo.getCreateDate());
  593. if (writeProtDataVo.getLoctionType().equals("1")) {
  594. proCountVo.setLoctionType("1");
  595. inList.add(proCountVo);
  596. }
  597. if (writeProtDataVo.getLoctionType().equals("2")) {
  598. proCountVo.setLoctionType("2");
  599. dealList.add(proCountVo);
  600. }
  601. if (writeProtDataVo.getLoctionType().equals("3")) {
  602. proCountVo.setLoctionType("3");
  603. outList.add(proCountVo);
  604. }
  605. }
  606. proCountDto.setInList(inList);
  607. proCountDto.setDealList(dealList);
  608. proCountDto.setOutList(outList);
  609. }
  610. else if ("2".equals(dataType)) {
  611. if ("3".equals(type)) {
  612. Calendar dateTime = Calendar.getInstance();
  613. int i = dateTime.get(Calendar.YEAR);
  614. queryWrapper.ge("create_date", i);
  615. writeProtDataVos = writeProtDataMapper.listWriteYear(queryWrapper);
  616. } else {
  617. if ("4".equals(type)) {
  618. startTime = startTime + " 00:00:00";
  619. endTime = endTime + " 23:59:59";
  620. queryWrapper.between("create_date", startTime, endTime);
  621. } else if ("2".equals(type)) {
  622. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  623. queryWrapper.ge("create_date", timesMonthmorning);
  624. } else if ("1".equals(type)) {
  625. Calendar calendar = Calendar.getInstance();
  626. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  627. Date dateTime = calendar.getTime();
  628. queryWrapper.ge("create_date", dateTime);
  629. }
  630. writeProtDataVos = writeProtDataMapper.listWrite(queryWrapper);
  631. }
  632. for (WriteProtDataVo writeProtDataVo : writeProtDataVos) {
  633. ProCountVo proCountVo = new ProCountVo();
  634. proCountVo.setValue(writeProtDataVo.getCod());
  635. proCountVo.setCreateDate(writeProtDataVo.getCreateDate());
  636. if (writeProtDataVo.getLoctionType().equals("1")) {
  637. proCountVo.setLoctionType("1");
  638. inList.add(proCountVo);
  639. }
  640. if (writeProtDataVo.getLoctionType().equals("2")) {
  641. proCountVo.setLoctionType("2");
  642. dealList.add(proCountVo);
  643. }
  644. if (writeProtDataVo.getLoctionType().equals("3")) {
  645. proCountVo.setLoctionType("3");
  646. outList.add(proCountVo);
  647. }
  648. }
  649. proCountDto.setInList(inList);
  650. proCountDto.setDealList(dealList);
  651. proCountDto.setOutList(outList);
  652. }
  653. else if ("3".equals(dataType)) {
  654. if ("3".equals(type)) {
  655. Calendar dateTime = Calendar.getInstance();
  656. int i = dateTime.get(Calendar.YEAR);
  657. queryWrapper.ge("create_date", i);
  658. writeProtDataVos = writeProtDataMapper.listWriteYear(queryWrapper);
  659. } else {
  660. if ("4".equals(type)) {
  661. startTime = startTime + " 00:00:00";
  662. endTime = endTime + " 23:59:59";
  663. queryWrapper.between("create_date", startTime, endTime);
  664. } else if ("2".equals(type)) {
  665. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  666. queryWrapper.ge("create_date", timesMonthmorning);
  667. } else if ("1".equals(type)) {
  668. Calendar calendar = Calendar.getInstance();
  669. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  670. Date dateTime = calendar.getTime();
  671. queryWrapper.ge("create_date", dateTime);
  672. }
  673. writeProtDataVos = writeProtDataMapper.listWrite(queryWrapper);
  674. }
  675. for (WriteProtDataVo writeProtDataVo : writeProtDataVos) {
  676. ProCountVo proCountVo = new ProCountVo();
  677. proCountVo.setValue(writeProtDataVo.getNh3n());
  678. proCountVo.setCreateDate(writeProtDataVo.getCreateDate());
  679. if (writeProtDataVo.getLoctionType().equals("1")) {
  680. proCountVo.setLoctionType("1");
  681. inList.add(proCountVo);
  682. }
  683. if (writeProtDataVo.getLoctionType().equals("2")) {
  684. proCountVo.setLoctionType("2");
  685. dealList.add(proCountVo);
  686. }
  687. if (writeProtDataVo.getLoctionType().equals("3")) {
  688. proCountVo.setLoctionType("3");
  689. outList.add(proCountVo);
  690. }
  691. }
  692. proCountDto.setInList(inList);
  693. proCountDto.setDealList(dealList);
  694. proCountDto.setOutList(outList);
  695. }
  696. else if ("4".equals(dataType)) {
  697. if ("3".equals(type)) {
  698. Calendar dateTime = Calendar.getInstance();
  699. int i = dateTime.get(Calendar.YEAR);
  700. queryWrapper.ge("create_date", i);
  701. writeProtDataVos = writeProtDataMapper.listWriteYear(queryWrapper);
  702. } else {
  703. if ("4".equals(type)) {
  704. startTime = startTime + " 00:00:00";
  705. endTime = endTime + " 23:59:59";
  706. queryWrapper.between("create_date", startTime, endTime);
  707. } else if ("2".equals(type)) {
  708. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  709. queryWrapper.ge("create_date", timesMonthmorning);
  710. } else if ("1".equals(type)) {
  711. Calendar calendar = Calendar.getInstance();
  712. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  713. Date dateTime = calendar.getTime();
  714. queryWrapper.ge("create_date", dateTime);
  715. }
  716. writeProtDataVos = writeProtDataMapper.listWrite(queryWrapper);
  717. }
  718. for (WriteProtDataVo writeProtDataVo : writeProtDataVos) {
  719. ProCountVo proCountVo = new ProCountVo();
  720. proCountVo.setValue(writeProtDataVo.getTp());
  721. proCountVo.setCreateDate(writeProtDataVo.getCreateDate());
  722. if (writeProtDataVo.getLoctionType().equals("1")) {
  723. proCountVo.setLoctionType("1");
  724. inList.add(proCountVo);
  725. }
  726. if (writeProtDataVo.getLoctionType().equals("2")) {
  727. proCountVo.setLoctionType("2");
  728. dealList.add(proCountVo);
  729. }
  730. if (writeProtDataVo.getLoctionType().equals("3")) {
  731. proCountVo.setLoctionType("3");
  732. outList.add(proCountVo);
  733. }
  734. }
  735. proCountDto.setInList(inList);
  736. proCountDto.setDealList(dealList);
  737. proCountDto.setOutList(outList);
  738. }
  739. else if ("5".equals(dataType)) {
  740. if ("3".equals(type)) {
  741. Calendar dateTime = Calendar.getInstance();
  742. int i = dateTime.get(Calendar.YEAR);
  743. queryWrapper.ge("create_date", i);
  744. writeProtDataVos = writeProtDataMapper.listWriteYear(queryWrapper);
  745. } else {
  746. if ("4".equals(type)) {
  747. startTime = startTime + " 00:00:00";
  748. endTime = endTime + " 23:59:59";
  749. queryWrapper.between("create_date", startTime, endTime);
  750. } else if ("2".equals(type)) {
  751. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  752. queryWrapper.ge("create_date", timesMonthmorning);
  753. } else if ("1".equals(type)) {
  754. Calendar calendar = Calendar.getInstance();
  755. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  756. Date dateTime = calendar.getTime();
  757. queryWrapper.ge("create_date", dateTime);
  758. }
  759. writeProtDataVos = writeProtDataMapper.listWrite(queryWrapper);
  760. }
  761. for (WriteProtDataVo writeProtDataVo : writeProtDataVos) {
  762. ProCountVo proCountVo = new ProCountVo();
  763. proCountVo.setValue(writeProtDataVo.getTn());
  764. proCountVo.setCreateDate(writeProtDataVo.getCreateDate());
  765. if (writeProtDataVo.getLoctionType().equals("1")) {
  766. proCountVo.setLoctionType("1");
  767. inList.add(proCountVo);
  768. }
  769. if (writeProtDataVo.getLoctionType().equals("2")) {
  770. proCountVo.setLoctionType("2");
  771. dealList.add(proCountVo);
  772. }
  773. if (writeProtDataVo.getLoctionType().equals("3")) {
  774. proCountVo.setLoctionType("3");
  775. outList.add(proCountVo);
  776. }
  777. }
  778. proCountDto.setInList(inList);
  779. proCountDto.setDealList(dealList);
  780. proCountDto.setOutList(outList);
  781. }
  782. else if ("6".equals(dataType)) {
  783. if ("3".equals(type)) {
  784. Calendar dateTime = Calendar.getInstance();
  785. int i = dateTime.get(Calendar.YEAR);
  786. queryWrapper.ge("create_date", i);
  787. writeProtDataVos = writeProtDataMapper.listWriteYear(queryWrapper);
  788. } else {
  789. if ("4".equals(type)) {
  790. startTime = startTime + " 00:00:00";
  791. endTime = endTime + " 23:59:59";
  792. queryWrapper.between("create_date", startTime, endTime);
  793. } else if ("2".equals(type)) {
  794. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  795. queryWrapper.ge("create_date", timesMonthmorning);
  796. } else if ("1".equals(type)) {
  797. Calendar calendar = Calendar.getInstance();
  798. calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 7);
  799. Date dateTime = calendar.getTime();
  800. queryWrapper.ge("create_date", dateTime);
  801. }
  802. writeProtDataVos = writeProtDataMapper.listWrite(queryWrapper);
  803. }
  804. for (WriteProtDataVo writeProtDataVo : writeProtDataVos) {
  805. ProCountVo proCountVo = new ProCountVo();
  806. proCountVo.setValue(writeProtDataVo.getFlow());
  807. proCountVo.setCreateDate(writeProtDataVo.getCreateDate());
  808. if (writeProtDataVo.getLoctionType().equals("1")) {
  809. proCountVo.setLoctionType("1");
  810. inList.add(proCountVo);
  811. }
  812. if (writeProtDataVo.getLoctionType().equals("2")) {
  813. proCountVo.setLoctionType("2");
  814. dealList.add(proCountVo);
  815. }
  816. if (writeProtDataVo.getLoctionType().equals("3")) {
  817. proCountVo.setLoctionType("3");
  818. outList.add(proCountVo);
  819. }
  820. }
  821. proCountDto.setInList(inList);
  822. proCountDto.setDealList(dealList);
  823. proCountDto.setOutList(outList);
  824. }
  825. }
  826. return new Result(ResultCode.SUCCESS, proCountDto);
  827. }
  828. @Override
  829. public Result listProt(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  830. String farmId = paramsMap.get("farmId");
  831. QueryWrapper<ProtWarningInfo> queryWrapper = new QueryWrapper<>();
  832. queryWrapper.eq("farm_id", farmId).orderByDesc("date").last(" limit 10");
  833. List<ProtWarningInfo> protWarningInfos = protWarningInfoMapper.selectList(queryWrapper);
  834. //今日
  835. Date timesmorning = DataUill.getTimesmorning();
  836. //本周
  837. DateTime dateTime = DateUtil.beginOfWeek(new Date());
  838. //本月
  839. Date timesMonthmorning = DataUill.getTimesMonthmorning();
  840. List<ProDataVo> voList = new LinkedList<>();
  841. for (int i = 0; i < protWarningInfos.size(); i++) {
  842. ProDataVo proDataVo = new ProDataVo();
  843. proDataVo.setContent(protWarningInfos.get(i).getWarningContent());
  844. proDataVo.setTime(protWarningInfos.get(i).getDate());
  845. voList.add(proDataVo);
  846. }
  847. QueryWrapper<ProtWarningInfo> queryWrapper1 = new QueryWrapper<>();
  848. queryWrapper1.eq("farm_id", farmId).ge("date", timesmorning);
  849. Integer dayCount = protWarningInfoMapper.selectCount(queryWrapper1);
  850. QueryWrapper<ProtWarningInfo> queryWrapper2 = new QueryWrapper<>();
  851. queryWrapper2.eq("farm_id", farmId).ge("date", dateTime);
  852. Integer weekCount = protWarningInfoMapper.selectCount(queryWrapper2);
  853. QueryWrapper<ProtWarningInfo> queryWrapper3 = new QueryWrapper<>();
  854. queryWrapper3.eq("farm_id", farmId).ge("date", timesMonthmorning);
  855. Integer monthCount = protWarningInfoMapper.selectCount(queryWrapper3);
  856. QueryWrapper<ProtWarningInfo> queryWrapper4 = new QueryWrapper<>();
  857. queryWrapper4.eq("farm_id", farmId);
  858. Integer count = protWarningInfoMapper.selectCount(queryWrapper4);
  859. JSONObject jsonObject = new JSONObject();
  860. jsonObject.put("dayCount", dayCount);
  861. jsonObject.put("weekCount", weekCount);
  862. jsonObject.put("monthCount", monthCount);
  863. jsonObject.put("count", count);
  864. jsonObject.put("data", voList);
  865. return new Result(ResultCode.SUCCESS, jsonObject);
  866. }
  867. @Override
  868. public Result listType(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  869. String farmId = paramsMap.get("farmId");
  870. String displayType = paramsMap.get("displayType");
  871. if ("".equals(displayType) || null == displayType) {
  872. displayType = "0";
  873. }
  874. JSONObject jsonObject = new JSONObject();
  875. if ("0".equals(displayType)) {
  876. QueryWrapper<ProtData> queryWrapper = new QueryWrapper<>();
  877. // ProCountDto proCountDto = new ProCountDto();
  878. queryWrapper.eq("farm_id", farmId).eq("loction_type", 1).orderByDesc("create_date").last(" limit 1");
  879. ProtData protData = protDataMapper.selectOne(queryWrapper);
  880. jsonObject.put("in", protData);
  881. QueryWrapper<ProtData> queryWrapper1 = new QueryWrapper<>();
  882. queryWrapper1.eq("farm_id", farmId).eq("loction_type", 2).orderByDesc("create_date").last(" limit 1");
  883. ProtData protData1 = protDataMapper.selectOne(queryWrapper1);
  884. jsonObject.put("deal", protData1);
  885. QueryWrapper<ProtData> queryWrapper2 = new QueryWrapper<>();
  886. queryWrapper2.eq("farm_id", farmId).eq("loction_type", 3).orderByDesc("create_date").last(" limit 1");
  887. ProtData protData2 = protDataMapper.selectOne(queryWrapper2);
  888. jsonObject.put("out", protData2);
  889. } else {
  890. QueryWrapper<WriteProtData> queryWrapper = new QueryWrapper<>();
  891. // ProCountDto proCountDto = new ProCountDto();
  892. queryWrapper.eq("farm_id", farmId).eq("type", 1).orderByDesc("create_date").last(" limit 1");
  893. WriteProtData writeProtData = writeProtDataMapper.selectOne(queryWrapper);
  894. if (ObjectUtil.isEmpty(writeProtData)) {
  895. jsonObject.put("in", new WriteProtData());
  896. } else {
  897. jsonObject.put("in", writeProtData);
  898. }
  899. QueryWrapper<WriteProtData> queryWrapper1 = new QueryWrapper<>();
  900. queryWrapper1.eq("farm_id", farmId).eq("type", 2).orderByDesc("create_date").last(" limit 1");
  901. WriteProtData writeProtData1 = writeProtDataMapper.selectOne(queryWrapper1);
  902. if (ObjectUtil.isEmpty(writeProtData1)) {
  903. jsonObject.put("deal", new WriteProtData());
  904. } else {
  905. jsonObject.put("deal", writeProtData1);
  906. }
  907. QueryWrapper<WriteProtData> queryWrapper2 = new QueryWrapper<>();
  908. queryWrapper2.eq("farm_id", farmId).eq("type", 3).orderByDesc("create_date").last(" limit 1");
  909. WriteProtData writeProtData2 = writeProtDataMapper.selectOne(queryWrapper2);
  910. if (ObjectUtil.isEmpty(writeProtData2)) {
  911. jsonObject.put("out", new WriteProtData());
  912. } else {
  913. jsonObject.put("out", writeProtData2);
  914. }
  915. }
  916. return new Result(ResultCode.SUCCESS, jsonObject);
  917. }
  918. @Override
  919. public Result listScreen(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
  920. Date timesmorning = DataUill.getTimesmorning();
  921. String farmId = paramsMap.get("farmId");
  922. QueryWrapper<ProtData> queryWrapper = new QueryWrapper<>();
  923. queryWrapper.eq("farm_id", farmId).ge("create_date", timesmorning);
  924. Integer count = protDataMapper.selectCount(queryWrapper);//监测数据条数
  925. QueryWrapper<ProtWarningInfo> queryWrapper1 = new QueryWrapper<>();
  926. queryWrapper1.eq("farm_id", farmId);
  927. Integer count1 = protWarningInfoMapper.selectCount(queryWrapper1);//全年报警条数
  928. queryWrapper1.ge("date", timesmorning);
  929. Integer countDay = protWarningInfoMapper.selectCount(queryWrapper1);//今日报警条数
  930. QueryWrapper<ProdFermentDevice> queryWrapper2 = new QueryWrapper<>();
  931. queryWrapper2.eq("farm_id", farmId);
  932. Integer day = fermentDeviceMapper.selectCount(queryWrapper2);
  933. JSONObject jsonObject = new JSONObject();
  934. jsonObject.put("locCount", 27);
  935. jsonObject.put("ProtCount", count);
  936. jsonObject.put("WarningCount", countDay);
  937. jsonObject.put("day", day);
  938. jsonObject.put("flowCount", count1);
  939. return new Result(ResultCode.SUCCESS, jsonObject);
  940. }
  941. }