DataStatisticsController.java 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489
  1. package com.zd.security.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.github.pagehelper.PageHelper;
  6. import com.zd.common.core.annotation.Log;
  7. import com.zd.common.core.annotation.PreAuthorize;
  8. import com.zd.common.core.log.BusinessType;
  9. import com.zd.common.core.security.TokenService;
  10. import com.zd.common.core.utils.Convert;
  11. import com.zd.common.core.utils.DateUtils;
  12. import com.zd.common.core.utils.ExcelUtil;
  13. import com.zd.common.core.utils.StringUtils;
  14. import com.zd.common.core.web.controller.AbstractController;
  15. import com.zd.laboratory.api.feign.RemoteLaboratoryService;
  16. import com.zd.model.constant.HttpStatus;
  17. import com.zd.model.domain.AjaxResult;
  18. import com.zd.model.domain.R;
  19. import com.zd.model.domain.ResultData;
  20. import com.zd.model.domain.per.PerFun;
  21. import com.zd.model.domain.per.PerPrefix;
  22. import com.zd.model.entity.LoginModel;
  23. import com.zd.model.entity.SysDept;
  24. import com.zd.model.page.TableDataInfo;
  25. import com.zd.security.api.bo.CheckHazardBo;
  26. import com.zd.security.api.bo.CheckManageBo;
  27. import com.zd.security.api.vo.*;
  28. import com.zd.security.entity.*;
  29. import com.zd.security.scope.DataPermission;
  30. import com.zd.security.scope.DataPermissionAspect;
  31. import com.zd.security.service.*;
  32. import com.zd.system.api.feign.RemoteDeptService;
  33. import com.zd.system.api.feign.RemoteUserService;
  34. import io.swagger.annotations.Api;
  35. import io.swagger.annotations.ApiOperation;
  36. import org.springframework.beans.BeanUtils;
  37. import org.springframework.beans.factory.annotation.Autowired;
  38. import org.springframework.beans.factory.annotation.Value;
  39. import org.springframework.web.bind.annotation.GetMapping;
  40. import org.springframework.web.bind.annotation.PostMapping;
  41. import org.springframework.web.bind.annotation.RequestMapping;
  42. import org.springframework.web.bind.annotation.RestController;
  43. import javax.servlet.http.HttpServletResponse;
  44. import java.io.IOException;
  45. import java.time.LocalDate;
  46. import java.time.temporal.TemporalAdjusters;
  47. import java.util.*;
  48. import java.util.stream.Collectors;
  49. /**
  50. * @Author: xxf
  51. * @Date: 2023/05/04/10:48
  52. * @Description:
  53. */
  54. @Api(tags = "数据统计")
  55. @RestController
  56. @RequestMapping("/DataStatistics")
  57. public class DataStatisticsController extends AbstractController {
  58. @Autowired
  59. private CheckHazardService checkHazardService;
  60. @Autowired
  61. private CheckManageService checkManageService;
  62. @Autowired
  63. private CheckMemberService checkMemberService;
  64. @Autowired
  65. private CheckRectifyService checkRectifyService;
  66. @Autowired
  67. private CheckStaffUserService checkStaffUserService;
  68. @Autowired
  69. private RemoteLaboratoryService remoteLaboratoryService;
  70. @Autowired
  71. private TokenService tokenService;
  72. @Autowired
  73. private RemoteUserService remoteUserService;
  74. @Autowired
  75. private CheckPlanService checkPlanService;
  76. @Autowired
  77. private CheckOptionService checkOptionService;
  78. @Autowired
  79. private RemoteDeptService remoteDeptService;
  80. @Value("${check.manageSign}")
  81. private String manageSign;
  82. @DataPermission()
  83. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  84. @ApiOperation("实验室列表")
  85. @GetMapping(value = "/subList")
  86. public ResultData subList(CheckManageBo bo) {
  87. List<Long> users = DataPermissionAspect.threadLocal.get();
  88. if(users!=null && !users.isEmpty()){
  89. bo.setUserIds(users.stream().toArray(Long[]::new));
  90. DataPermissionAspect.threadLocal.remove();
  91. }
  92. Page<CheckManageVo> page = new Page<>(bo.getPageNum(), bo.getPageSize());
  93. return ResultData.success(getSubList(page, bo));
  94. }
  95. private Page<CheckManageVo> getSubList(Page page, CheckManageBo bo) {
  96. Page<CheckManageVo> list = checkManageService.selecSubCheckManageList(page, bo);
  97. if (list != null && list.getRecords().size() > 0) {
  98. Long[] ids = list.getRecords().stream().map(a -> a.getSubId()).toArray(Long[]::new);
  99. ResultData rd = remoteLaboratoryService.selectLabSubSafeInfoByIds(ids);
  100. if (rd.getCode() != HttpStatus.SUCCESS) {
  101. log.info("数据统计实验室列表,查询负责人电话异常:" + rd.getMsg());
  102. } else {
  103. if (list.getRecords().size() > 0) {
  104. List<LinkedHashMap<String, Object>> linkedHashMap = (List<LinkedHashMap<String, Object>>) rd.getData();
  105. //实验室负责人、安全负责人数据整合
  106. for (CheckManageVo vo : list.getRecords()) {
  107. for (int i = 0; i < linkedHashMap.size(); i++) {
  108. if (linkedHashMap != null && vo.getSubId().equals(Long.valueOf(linkedHashMap.get(i).get("id").toString()))) {
  109. vo.setSafeUserNameAdminPhone(linkedHashMap.get(i).get("safeUserNameAdminPhone") != null ? linkedHashMap.get(i).get("safeUserNameAdminPhone").toString().replace("@", "-") : null);
  110. vo.setAdminNameAndPhone(linkedHashMap.get(i).get("adminNameAndPhone") != null ? linkedHashMap.get(i).get("adminNameAndPhone").toString().replace("@", "-") : null);
  111. }
  112. }
  113. //查询实验室下的危险源
  114. R hazardRd = remoteLaboratoryService.getBySubjectId(vo.getSubId());
  115. if (rd.getCode() == HttpStatus.SUCCESS) {
  116. List<LinkedHashMap<String, Object>> linkedHazardRdMap = (List<LinkedHashMap<String, Object>>) hazardRd.getData();
  117. if (linkedHazardRdMap != null) {
  118. String anotherName = "";
  119. for (int j = 0; j < linkedHazardRdMap.size(); j++) {
  120. if (vo.getSubId().equals(Long.valueOf(linkedHazardRdMap.get(j).get("subjectId").toString()))) {
  121. anotherName += linkedHazardRdMap.get(j).get("anotherName") + ",";
  122. }
  123. }
  124. vo.setHazardName(anotherName.length() > 1 ? anotherName.substring(0, anotherName.length() - 1) : anotherName);
  125. }
  126. }
  127. //该实验室所有隐患整改数
  128. CheckHazardBo checkHazardBo = new CheckHazardBo();
  129. checkHazardBo.setSubId(vo.getSubId());
  130. checkHazardBo.setCheckTimeOrder(100);//已整改并,包含无法整改
  131. Long rectifyCount = checkHazardService.hiddenDangerCount(checkHazardBo);
  132. //该实验室检查不符合数(隐患总数)
  133. checkHazardBo = new CheckHazardBo();
  134. checkHazardBo.setSubId(vo.getSubId());
  135. Long resultCount = checkHazardService.hiddenDangerCount(checkHazardBo);
  136. //整改率
  137. vo.setPercent(WorkSchoolController.myPercent(Convert.toInt(rectifyCount), Convert.toInt(resultCount), "##.##%"));
  138. //该实验室复核总数
  139. checkHazardBo = new CheckHazardBo();
  140. checkHazardBo.setSubId(vo.getSubId());
  141. checkHazardBo.setCheckTimeOrder(101);
  142. Long FhCount = checkHazardService.hiddenDangerCount(checkHazardBo);
  143. //该实验室所有整改复核通过数
  144. checkHazardBo.setExamineResult(1);
  145. Long TgCount = checkHazardService.hiddenDangerCount(checkHazardBo);
  146. //复核通过率
  147. vo.setPercent2(WorkSchoolController.myPercent(Convert.toInt(TgCount), Convert.toInt(FhCount), "##.##%"));
  148. }
  149. }
  150. }
  151. }
  152. return list;
  153. }
  154. /***
  155. *实验室头部数据统计
  156. * @param bo
  157. * @return
  158. */
  159. @DataPermission()
  160. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  161. @ApiOperation("实验室列表头部数据统计")
  162. @GetMapping(value = "/subListTop")
  163. public ResultData subListTop(CheckManageBo bo) {
  164. List<Long> users = DataPermissionAspect.threadLocal.get();
  165. if(users!=null && !users.isEmpty()){
  166. bo.setUserIds(users.stream().toArray(Long[]::new));
  167. DataPermissionAspect.threadLocal.remove();
  168. }
  169. return ResultData.success(getSubListTop(bo));
  170. }
  171. private Map<String, Object> getSubListTop(CheckManageBo bo) {
  172. Map<String, Object> map = new HashMap<>();
  173. //安全分级
  174. Map<Long, Integer> classmap = new HashMap<>();
  175. //安全分类
  176. Map<Long, Integer> classTypemap = new HashMap<>();
  177. //安全分级
  178. List<CheckManageVo> classListVo = new ArrayList<>();
  179. //安全分类
  180. List<CheckManageVo> classTypeListVo = new ArrayList<>();
  181. //总数
  182. Integer sumTotal = 0;
  183. //存在危险源的实验室数量
  184. Integer hazardSubjectTotal = 0;
  185. //危险源总数
  186. Integer hazardTotal = 0;
  187. //特种设备总数
  188. Integer specialTotal = 0;
  189. Page<CheckManageVo> page = new Page().setSize(-1);
  190. Page<CheckManageVo> list = checkManageService.selecSubCheckManageList(page, bo);
  191. if (list != null && list.getRecords().size() > 0) {
  192. sumTotal = list.getRecords().size();
  193. //安全检查实验室集合
  194. Long[] ids = list.getRecords().stream().map(a -> a.getSubId()).toArray(Long[]::new);
  195. //查询关联危险源的实验室
  196. R rHd = remoteLaboratoryService.getBySubjectIds(ids);
  197. if (rHd.getCode() == HttpStatus.SUCCESS) {
  198. List<LinkedHashMap<String, Object>> linkedHashMap = (List<LinkedHashMap<String, Object>>) rHd.getData();
  199. if (linkedHashMap != null && !linkedHashMap.isEmpty()) {
  200. hazardSubjectTotal = linkedHashMap.size();
  201. for (int i = 0; i < linkedHashMap.size(); i++) {
  202. Integer count = Integer.valueOf(linkedHashMap.get(i).get("count").toString());
  203. hazardTotal = hazardTotal + count;
  204. }
  205. }
  206. }
  207. //查询安全分级列表
  208. R rClassified = remoteLaboratoryService.classifiedListAll();
  209. if (rClassified.getCode() == HttpStatus.SUCCESS) {
  210. List<LinkedHashMap<String, Object>> linkedHashMap = (List<LinkedHashMap<String, Object>>) rClassified.getData();
  211. if (linkedHashMap != null && !linkedHashMap.isEmpty()) {
  212. for (int i = 0; i < linkedHashMap.size(); i++) {
  213. classmap.put(Long.valueOf(linkedHashMap.get(i).get("id").toString()), 0);
  214. CheckManageVo vo = new CheckManageVo();
  215. vo.setLevelName(linkedHashMap.get(i).get("classifiedName").toString());
  216. vo.setAmount(0);
  217. vo.setLevel(Long.valueOf(linkedHashMap.get(i).get("id").toString()));
  218. classListVo.add(vo);
  219. }
  220. }
  221. }
  222. //查询安全分类列表
  223. R rClassiType = remoteLaboratoryService.classtypeListAll();
  224. if (rClassiType.getCode() == HttpStatus.SUCCESS) {
  225. List<LinkedHashMap<String, Object>> linkedHashMap = (List<LinkedHashMap<String, Object>>) rClassiType.getData();
  226. if (linkedHashMap != null && !linkedHashMap.isEmpty()) {
  227. for (int i = 0; i < linkedHashMap.size(); i++) {
  228. classTypemap.put(Long.valueOf(linkedHashMap.get(i).get("id").toString()), 0);
  229. CheckManageVo vo = new CheckManageVo();
  230. vo.setTypeName(linkedHashMap.get(i).get("typeName").toString());
  231. vo.setAmount2(0);
  232. vo.setTypeId(Long.valueOf(linkedHashMap.get(i).get("id").toString()));
  233. classTypeListVo.add(vo);
  234. }
  235. }
  236. }
  237. //循环实验室集合计算各个安全等级数量
  238. for (CheckManageVo vo : list.getRecords()) {
  239. //安全等级数量
  240. if (classmap.containsKey(vo.getLevel())) {
  241. Integer value = classmap.get(vo.getLevel());
  242. value = value + 1;
  243. classmap.put(vo.getLevel(), value);
  244. }
  245. //特种设备
  246. if (vo.getTypeName() != null && vo.getTypeName().indexOf("特种设备") != -1) {
  247. specialTotal++;
  248. }
  249. //安全分类数量
  250. if (classTypemap.containsKey(vo.getTypeId())) {
  251. Integer value2 = classTypemap.get(vo.getTypeId());
  252. value2 = value2 + 1;
  253. classTypemap.put(vo.getTypeId(), value2);
  254. }
  255. }
  256. //将各个等级的安全数量赋值给安全等级集合列表
  257. for (CheckManageVo v : classListVo) {
  258. for (Long key : classmap.keySet()) {
  259. if (v.getLevel().equals(key)) {
  260. v.setAmount(classmap.get(key));
  261. }
  262. }
  263. }
  264. //将各个安全分类的安全数量赋值给安全分类集合列表
  265. for (CheckManageVo v : classTypeListVo) {
  266. for (Long key : classTypemap.keySet()) {
  267. if (v.getTypeId().equals(key)) {
  268. v.setAmount2(classTypemap.get(key));
  269. }
  270. }
  271. }
  272. }
  273. map.put("sumTotal", sumTotal);
  274. map.put("hazardSubjectTotal", hazardSubjectTotal);
  275. map.put("hazardTotal", hazardTotal);
  276. map.put("classListVo", classListVo);
  277. map.put("classTypeListVo", classTypeListVo);
  278. map.put("specialTotal", specialTotal);
  279. return map;
  280. }
  281. /**
  282. * 数据统计-按实验室导出
  283. */
  284. @DataPermission()
  285. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.EXPORT)
  286. @Log(title = "数据统计-按实验室导出", businessType = BusinessType.EXPORT)
  287. @PostMapping("/subExport")
  288. public void export(HttpServletResponse response, CheckManageBo bo) throws IOException {
  289. List<SubjectExcel> excelList = new ArrayList<>();
  290. Page<CheckManageVo> page = new Page().setSize(-1);
  291. bo.setSubListIds(bo.getIds());
  292. Page<CheckManageVo> list = getSubList(page, bo);
  293. if (list != null && list.getRecords().size() > 0) {
  294. for (CheckManageVo vo : list.getRecords()) {
  295. SubjectExcel excel = new SubjectExcel();
  296. BeanUtils.copyProperties(vo, excel);
  297. excelList.add(excel);
  298. }
  299. }
  300. String fw = "全部";//范围
  301. String aufl = "全部";//安全分类
  302. String audj = "全部";//安全等级
  303. //String zq = "全部";//统计周期
  304. String audjList = "";//安全等级描述
  305. String auflList = "";//安全分类描述
  306. //获取列表集合
  307. if (list.getRecords().size() > 0) {
  308. fw = bo.getSubIds() == null ? fw : list.getRecords().get(0).getCollegeName();
  309. aufl = bo.getTypeId() == null ? aufl : list.getRecords().get(0).getTypeName();
  310. audj = bo.getLevel() == null ? audj : list.getRecords().get(0).getLevelName();
  311. }
  312. //获取头部数据
  313. Map<String, Object> map = getSubListTop(bo);
  314. //安全等级
  315. List<CheckManageVo> classListVoList = (List<CheckManageVo>) map.get("classListVo");
  316. if (classListVoList != null && !classListVoList.isEmpty()) {
  317. for (CheckManageVo vo : classListVoList) {
  318. audjList += vo.getLevelName() + ":" + vo.getAmount() + " ";
  319. }
  320. }
  321. //安全分类
  322. List<CheckManageVo> classTypeList = (List<CheckManageVo>) map.get("classTypeListVo");
  323. if (classTypeList != null && !classTypeList.isEmpty()) {
  324. for (CheckManageVo vo : classTypeList) {
  325. auflList += vo.getTypeName() + ":" + vo.getAmount2() + " ";
  326. }
  327. }
  328. //获取当前登录用户
  329. LoginModel sysUser = tokenService.getLoginUser();
  330. String tips = "统计范围:" + fw + " 安全分类:" + aufl + " 安全等级:" + audj + " \n" +
  331. "生成时间:" + DateUtils.getTime() + " 生成者:" + sysUser.getNickName() + " \n" +
  332. "实验室总数:" + map.get("sumTotal") + " 存在危险源的实验室数:" + map.get("hazardSubjectTotal") + " 危险源总数:" + map.get("hazardTotal") + " \n" +
  333. audjList + "\n" + auflList + "\n";
  334. ExcelUtil<SubjectExcel> util = new ExcelUtil<>(SubjectExcel.class);
  335. util.exportExcel(response, excelList, "实验室安全检查统计", tips, "实验室安全检查统计导出报表" + LocalDate.now());
  336. }
  337. /***
  338. * 安全隐患列表
  339. * @param hazardBo
  340. * @return
  341. */
  342. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  343. @DataPermission()
  344. @ApiOperation("安全隐患列表")
  345. @GetMapping(value = "/hazardList")
  346. public ResultData hazardList(CheckHazardBo hazardBo) {
  347. // 获取数据
  348. List<Long> users = DataPermissionAspect.threadLocal.get();
  349. if(users!=null && !users.isEmpty()){
  350. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  351. DataPermissionAspect.threadLocal.remove();
  352. }
  353. Page<CheckHazardBo> page = new Page<>(hazardBo.getPageNum(), hazardBo.getPageSize());
  354. //排序标识
  355. hazardBo.setAppFlag(1);
  356. Page<CheckHazardVo> list = checkHazardService.hiddenDataStatisticsList(page, hazardBo);
  357. return ResultData.success(list);
  358. }
  359. /***
  360. *安全隐患列表头部数据统计
  361. * @param hazardBo
  362. * @return
  363. */
  364. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  365. @DataPermission()
  366. @ApiOperation("安全隐患列表头部数据统计")
  367. @GetMapping(value = "/hazardListTop")
  368. public ResultData hazardListTop(CheckHazardBo hazardBo) {
  369. // 获取数据
  370. List<Long> users = DataPermissionAspect.threadLocal.get();
  371. if(users!=null && !users.isEmpty()){
  372. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  373. DataPermissionAspect.threadLocal.remove();
  374. }
  375. return ResultData.success(getHazardListTop(hazardBo));
  376. }
  377. private Map<String, Object> getHazardListTop(CheckHazardBo hazardBo) {
  378. Map<String, Object> map = new HashMap<>();
  379. //总数
  380. Integer sumTotal = 0;
  381. //重大隐患
  382. Integer zdHazardTotal = 0;
  383. //一般隐患
  384. Integer ybHazardTotal = 0;
  385. //管理隐患
  386. Integer glHazardTotal = 0;
  387. //待整改
  388. Integer rectifiedTotal = 0;
  389. //复核总数
  390. Integer resultTotal = 0;
  391. //复核通过总数
  392. Integer ratifyTotal = 0;
  393. //通过率
  394. String rate = "0%";
  395. Page<CheckHazardBo> page = new Page().setSize(-1);
  396. Page<CheckHazardVo> list = checkHazardService.hiddenDataStatisticsList(page, hazardBo);
  397. if (list.getRecords().size() > 0) {
  398. sumTotal = list.getRecords().size();
  399. for (CheckHazardVo vo : list.getRecords()) {
  400. if (StringUtils.isNotNull(vo.getHazardLevel()) && vo.getHazardLevel().equals(1)) {
  401. zdHazardTotal++;
  402. } else if (StringUtils.isNotNull(vo.getHazardLevel()) && vo.getHazardLevel().equals(2)) {
  403. ybHazardTotal++;
  404. } else if (StringUtils.isNotNull(vo.getHazardLevel()) && vo.getHazardLevel().equals(3)) {
  405. glHazardTotal++;
  406. }
  407. //驳回的也按照未整改统计
  408. if (StringUtils.isNotNull(vo.getRectifyStatus()) && vo.getRectifyStatus().equals(2)) {
  409. rectifiedTotal++;
  410. }
  411. if (StringUtils.isNotNull(vo.getExamineResult())) {
  412. resultTotal++;
  413. }
  414. if (StringUtils.isNotNull(vo.getExamineResult()) && vo.getExamineResult().equals(1)) {
  415. ratifyTotal++;
  416. }
  417. }
  418. }
  419. rate = WorkSchoolController.myPercent(ratifyTotal, resultTotal, "##.##%");
  420. map.put("sumTotal", sumTotal);
  421. map.put("zdHazardTotal", zdHazardTotal);
  422. map.put("ybHazardTotal", ybHazardTotal);
  423. map.put("glHazardTotal", glHazardTotal);
  424. map.put("rectifiedTotal", rectifiedTotal);
  425. map.put("resultTotal", resultTotal);
  426. map.put("rate", rate);
  427. return map;
  428. }
  429. /****
  430. * 数据统计-按照安全隐患列表导出
  431. * @param hazardBo
  432. * @return
  433. */
  434. @DataPermission()
  435. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.EXPORT)
  436. @ApiOperation("安全隐患列表导出")
  437. @PostMapping(value = "/hazardExport")
  438. public void hazardExport(HttpServletResponse response, CheckHazardBo hazardBo) throws IOException {
  439. List<Long> users = DataPermissionAspect.threadLocal.get();
  440. if(users!=null && !users.isEmpty()){
  441. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  442. DataPermissionAspect.threadLocal.remove();
  443. }
  444. Page<CheckHazardBo> page = new Page().setSize(-1);
  445. List<HazardExcel> excelList = new ArrayList<>();
  446. Page<CheckHazardVo> list = checkHazardService.hiddenDataStatisticsList(page, hazardBo);
  447. for (CheckHazardVo vo : list.getRecords()) {
  448. HazardExcel excel = new HazardExcel();
  449. BeanUtils.copyProperties(vo, excel);
  450. //整改状态
  451. excel.setRectifyStatusStr(getRectifyStatusName(vo.getRectifyStatus()));
  452. //隐患级别
  453. excel.setHazardLevelStr(StringUtils.isNotNull(vo.getHazardLevel()) ? getHazardLevelName(vo.getHazardLevel()) : "");
  454. excel.setHazardCheckName(vo.getHazardCheckCode() + vo.getHazardCheckName());
  455. excelList.add(excel);
  456. }
  457. Map<String, Object> map = getHazardListTop(hazardBo);
  458. //获取当前登录用户
  459. LoginModel sysUser = tokenService.getLoginUser();
  460. String fw = "全部";//范围
  461. String zgzt = "全部";//整改状态
  462. String yhdj = "全部";//隐患等级
  463. String zq = "全部";//统计周期
  464. if (list.getRecords().size() > 0) {
  465. fw = hazardBo.getSubId() == null ? fw : list.getRecords().get(0).getCollegeName();
  466. zgzt = hazardBo.getRectifyStatus() == null ? zgzt : getRectifyStatusName(list.getRecords().get(0).getRectifyStatus());
  467. yhdj = hazardBo.getHdLevel() == null ? yhdj : getHazardLevelName(list.getRecords().get(0).getHazardLevel());
  468. zq = StringUtils.isEmpty(hazardBo.getBeginTime()) ? zq : (hazardBo.getBeginTime() + "-" + hazardBo.getEndTime());
  469. }
  470. String tips = "统计范围:" + fw + " 整改状态:" + zgzt + " 隐患等级:" + yhdj + " 统计周期:" + zq + "\n" +
  471. "生成时间:" + DateUtils.getTime() + " 生成者:" + sysUser.getNickName() + " \n" +
  472. "隐患总数:" + map.get("sumTotal") + " 重大隐患数:" + map.get("zdHazardTotal") + " 一般隐患数:" + map.get("ybHazardTotal") +
  473. " 管理问题数:" + map.get("glHazardTotal") + " 待整改总数:" + map.get("rectifiedTotal") +
  474. " 复核总数:" + map.get("resultTotal") + " 复核通过率:" + map.get("rate");
  475. ExcelUtil<HazardExcel> util = new ExcelUtil<>(HazardExcel.class);
  476. util.exportExcel(response, excelList, "实验室安全检查统计", tips, "实验室安全检查统计导出报表" + LocalDate.now());
  477. }
  478. /***
  479. * 检查内容列表
  480. * @param hazardBo
  481. * @return
  482. */
  483. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  484. @DataPermission()
  485. @ApiOperation("检查内容列表")
  486. @GetMapping(value = "/contentList")
  487. public ResultData contentList(CheckHazardBo hazardBo) {
  488. List<Long> users = DataPermissionAspect.threadLocal.get();
  489. if(users!=null && !users.isEmpty()){
  490. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  491. DataPermissionAspect.threadLocal.remove();
  492. }
  493. Page<CheckHazardBo> page = new Page<>(hazardBo.getPageNum(), hazardBo.getPageSize());
  494. Page<CheckHazardVo> list = getCountList(page, hazardBo);
  495. return ResultData.success(list);
  496. }
  497. /***
  498. *检查内容列表头部数据统计
  499. * @param hazardBo
  500. * @return
  501. */
  502. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  503. @DataPermission()
  504. @ApiOperation("检查内容列表头部数据统计")
  505. @GetMapping(value = "/hazardContentTop")
  506. public ResultData hazardContenttTop(CheckHazardBo hazardBo) {
  507. List<Long> users = DataPermissionAspect.threadLocal.get();
  508. if(users!=null && !users.isEmpty()){
  509. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  510. DataPermissionAspect.threadLocal.remove();
  511. }
  512. return ResultData.success(getHazardContentTop(hazardBo));
  513. }
  514. private Map<String, Object> getHazardContentTop(CheckHazardBo hazardBo) {
  515. Map<String, Object> map = new HashMap<>();
  516. //总数
  517. Integer sumTotal = 0;
  518. //已整改
  519. Integer sumYzg = 0;
  520. //未整改
  521. Integer sumWzg = 0;
  522. //整改率
  523. String rate = "0%";
  524. Page<CheckHazardBo> page = new Page().setSize(-1);
  525. Page<CheckHazardVo> pageList = getCountList(page, hazardBo);
  526. if (pageList.getRecords() != null && pageList.getRecords().size() > 0) {
  527. for (CheckHazardVo vo : pageList.getRecords()) {
  528. sumTotal = sumTotal + vo.getSumTotal();
  529. sumYzg = sumYzg + vo.getSumYzg();
  530. sumWzg = sumWzg + vo.getSumWzg();
  531. }
  532. }
  533. rate = WorkSchoolController.myPercent(sumYzg, sumTotal, "##.##%");
  534. map.put("sumTotal", sumTotal);
  535. map.put("sumYzg", sumYzg);
  536. map.put("sumWzg", sumWzg);
  537. map.put("rate", rate);
  538. return map;
  539. }
  540. private Page<CheckHazardVo> getCountList(Page page, CheckHazardBo bo) {
  541. Page<CheckHazardVo> list = checkHazardService.hiddenDataContentList(page, bo);
  542. if (list.getRecords() != null && list.getRecords().size() > 0) {
  543. //查询检查内容危险源总数
  544. QueryWrapper<CheckHazard> queryWrapper = new QueryWrapper<>();
  545. queryWrapper.lambda().eq(CheckHazard::getCheckCategory, 2);
  546. Integer total = checkHazardService.list(queryWrapper).size();
  547. for (CheckHazardVo vo : list.getRecords()) {
  548. //隐患占比
  549. vo.setPercent(WorkSchoolController.myPercent(vo.getSumTotal(), total, "##.##%"));
  550. //整改率
  551. vo.setPercent2(WorkSchoolController.myPercent(vo.getSumYzg(), total, "##.##%"));
  552. }
  553. }
  554. return list;
  555. }
  556. /****
  557. * 数据统计-按照安全隐患列表导出
  558. * @param hazardBo
  559. * @return
  560. */
  561. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.EXPORT)
  562. @ApiOperation("安全隐患列表导出")
  563. @PostMapping(value = "/contentExport")
  564. public void contentExport(HttpServletResponse response, CheckHazardBo hazardBo) throws IOException {
  565. List<Long> users = DataPermissionAspect.threadLocal.get();
  566. if(users!=null && !users.isEmpty()){
  567. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  568. DataPermissionAspect.threadLocal.remove();
  569. }
  570. //查询检查内容危险源总数
  571. QueryWrapper<CheckHazard> queryWrapper = new QueryWrapper<>();
  572. queryWrapper.lambda().eq(CheckHazard::getCheckCategory, 2);
  573. if(users!=null && !users.isEmpty()){
  574. queryWrapper.lambda().in(CheckHazard::getCreateBy,users);
  575. }
  576. Integer total = checkHazardService.list(queryWrapper).size();
  577. Page<CheckHazardBo> page = new Page().setSize(-1);
  578. List<ContentExcel> excelList = new ArrayList<>();
  579. Page<CheckHazardVo> list = checkHazardService.hiddenDataContentList(page, hazardBo);
  580. for (CheckHazardVo vo : list.getRecords()) {
  581. ContentExcel excel = new ContentExcel();
  582. BeanUtils.copyProperties(vo, excel);
  583. //隐患占比
  584. if (vo.getSumTotal() != null && vo.getSumTotal() > 0) {
  585. excel.setPercent(WorkSchoolController.myPercent(vo.getSumTotal(), total, "##.##%"));
  586. } else {
  587. excel.setPercent("0%");
  588. }
  589. //整改率
  590. if (vo.getSumYzg() != null && vo.getSumYzg() > 0) {
  591. excel.setPercent2(WorkSchoolController.myPercent(vo.getSumYzg(), total, "##.##%"));
  592. } else {
  593. excel.setPercent2("0%");
  594. }
  595. excelList.add(excel);
  596. }
  597. Map<String, Object> map = getHazardContentTop(hazardBo);
  598. //获取当前登录用户
  599. LoginModel sysUser = tokenService.getLoginUser();
  600. String jcnr = "全部";//检查内容
  601. String deptName = "全部";//学院
  602. String subName = "全部";//实验室
  603. String zq = "全部";//统计周期
  604. if (list.getRecords().size() > 0) {
  605. jcnr = hazardBo.getHazardTypeMode() == null ? jcnr : list.getRecords().get(0).getHazardTypeModeName();
  606. deptName = hazardBo.getDeptId() == null ? deptName : list.getRecords().get(0).getCollegeName();
  607. subName = hazardBo.getSubId() == null ? subName : list.getRecords().get(0).getSubjectName();
  608. zq = StringUtils.isEmpty(hazardBo.getBeginTime()) ? zq : (hazardBo.getBeginTime() + " ~ " + hazardBo.getEndTime());
  609. }
  610. String tips = " 检查内容:" + jcnr + "\n"
  611. + " 学院:" + deptName + "\n"
  612. + " 实验室:" + subName + "\n"
  613. + " 统计周期:" + zq + "\n"
  614. + " 生成时间:" + DateUtils.getTime() + "\n"
  615. + " 生成者:" + sysUser.getNickName() + " \n"
  616. + " 隐患总数:" + map.get("sumTotal") + " 已整改:" + map.get("sumYzg") + " 未整改:" + map.get("sumWzg")
  617. + " 整改率:" + map.get("rate");
  618. ExcelUtil<ContentExcel> util = new ExcelUtil<>(ContentExcel.class);
  619. util.exportExcel(response, excelList, "实验室安全检查统计", tips, "实验室安全检查统计导出报表" + LocalDate.now());
  620. }
  621. /***
  622. * 根据整改状态获取描述
  623. * @param key
  624. * @return
  625. */
  626. private static String getRectifyStatusName(Integer key) {
  627. String value = null;
  628. switch (key) {
  629. case 1:
  630. value = "复核完毕";
  631. break;
  632. case 2:
  633. value = "未整改";
  634. break;
  635. case 3:
  636. value = "已整改";
  637. break;
  638. case 4:
  639. value = "暂无法整改";
  640. break;
  641. default:
  642. value = "未知";
  643. }
  644. return value;
  645. }
  646. /***
  647. * 根据隐患级别获取 隐患描述
  648. * @param key
  649. * @return
  650. */
  651. private static String getHazardLevelName(Integer key) {
  652. String value = null;
  653. switch (key) {
  654. case 1:
  655. value = "重大隐患";
  656. break;
  657. case 2:
  658. value = "一般隐患";
  659. break;
  660. case 3:
  661. value = "管理问题";
  662. break;
  663. default:
  664. value = "未知";
  665. }
  666. return value;
  667. }
  668. /***
  669. * 安全指标列表
  670. * @param hazardBo
  671. * @return
  672. */
  673. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  674. @DataPermission()
  675. @ApiOperation("安全指标列表")
  676. @GetMapping(value = "/itemsList")
  677. public ResultData itemsList(CheckHazardBo hazardBo) {
  678. // 获取数据
  679. List<Long> users = DataPermissionAspect.threadLocal.get();
  680. if(users!=null && !users.isEmpty()){
  681. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  682. DataPermissionAspect.threadLocal.remove();
  683. }
  684. Page<CheckHazardVo> list = checkHazardService.hiddenDataItemsList(hazardBo);
  685. if (list.getRecords().size() > 0) {
  686. for (CheckHazardVo vo : list.getRecords()) {
  687. vo.setPercent(WorkSchoolController.myPercent(vo.getItemsTotal1(), vo.getSchoolItemsTotal1(), "##.##%"));
  688. vo.setPercent2(WorkSchoolController.myPercent(vo.getItemsTotal2(), vo.getSchoolItemsTotal2(), "##.##%"));
  689. vo.setPercent3(WorkSchoolController.myPercent(vo.getItemsTotal3(), vo.getSchoolItemsTotal3(), "##.##%"));
  690. vo.setPercent4(WorkSchoolController.myPercent(vo.getItemsTotal4(), vo.getSchoolItemsTotal4(), "##.##%"));
  691. }
  692. }
  693. return ResultData.success(list);
  694. }
  695. /***
  696. * 安全指标列表头部统计
  697. * @param hazardBo
  698. * @return
  699. */
  700. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.LIST)
  701. @DataPermission()
  702. @ApiOperation("安全指标列表头部统计")
  703. @GetMapping(value = "/itemsListTop")
  704. public ResultData itemsListTitle(CheckHazardBo hazardBo) {
  705. // 获取数据
  706. List<Long> users = DataPermissionAspect.threadLocal.get();
  707. if(users!=null && !users.isEmpty()){
  708. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  709. DataPermissionAspect.threadLocal.remove();
  710. }
  711. return ResultData.success(getItemsListTop(hazardBo));
  712. }
  713. private Map<String, Object> getItemsListTop(CheckHazardBo hazardBo) {
  714. Map<String, Object> map = new HashMap<>();
  715. //总数
  716. Integer sumTotal = 0;
  717. //1级隐患
  718. Integer level1 = 0;
  719. //2级隐患
  720. Integer level2 = 0;
  721. //3级隐患
  722. Integer level3 = 0;
  723. //4级隐患
  724. Integer level4 = 0;
  725. //1级指标占比
  726. String percent1 = "0%";
  727. //2级指标占比
  728. String percent2 = "0%";
  729. //3级指标占比
  730. String percent3 = "0%";
  731. //4级指标占比
  732. String percent4 = "0%";
  733. hazardBo.setPageSize(-1);
  734. Page<CheckHazardVo> list = checkHazardService.hiddenDataItemsList(hazardBo);
  735. if (list.getRecords().size() > 0) {
  736. for (CheckHazardVo vo : list.getRecords()) {
  737. sumTotal += vo.getSumTotal();
  738. level1 += vo.getItemsTotal1();
  739. level2 += vo.getItemsTotal2();
  740. level3 += vo.getItemsTotal3();
  741. level4 += vo.getItemsTotal4();
  742. }
  743. percent1 = WorkSchoolController.myPercent(level1, sumTotal, "##.##%");
  744. percent2 = WorkSchoolController.myPercent(level2, sumTotal, "##.##%");
  745. percent3 = WorkSchoolController.myPercent(level3, sumTotal, "##.##%");
  746. percent4 = WorkSchoolController.myPercent(level4, sumTotal, "##.##%");
  747. }
  748. map.put("sumTotal", sumTotal);
  749. map.put("level1", level1);
  750. map.put("level2", level2);
  751. map.put("level3", level3);
  752. map.put("level4", level4);
  753. map.put("percent1", percent1);
  754. map.put("percent2", percent2);
  755. map.put("percent3", percent3);
  756. map.put("percent4", percent4);
  757. return map;
  758. }
  759. /****
  760. * 数据统计-按照安全指标列表导出
  761. * @param hazardBo
  762. * @return
  763. */
  764. @DataPermission()
  765. @PreAuthorize(hasPermi = PerPrefix.SECURITY_DATA_SUB + PerFun.EXPORT)
  766. @ApiOperation("安全指标列表导出")
  767. @PostMapping(value = "/itemsExport")
  768. public void itemsExport(HttpServletResponse response, CheckHazardBo hazardBo) throws IOException {
  769. List<Long> users = DataPermissionAspect.threadLocal.get();
  770. if(users!=null && !users.isEmpty()){
  771. hazardBo.setUserIds(users.stream().toArray(Long[]::new));
  772. DataPermissionAspect.threadLocal.remove();
  773. }
  774. List<ItemsExcel> excelList = new ArrayList<>();
  775. Page<CheckHazardVo> list = checkHazardService.hiddenDataItemsList(hazardBo);
  776. if (list.getRecords().size() > 0) {
  777. for (CheckHazardVo vo : list.getRecords()) {
  778. ItemsExcel excel = new ItemsExcel();
  779. vo.setPercent(WorkSchoolController.myPercent(vo.getItemsTotal1(), vo.getSchoolItemsTotal1(), "##.##%"));
  780. vo.setPercent2(WorkSchoolController.myPercent(vo.getItemsTotal2(), vo.getSchoolItemsTotal2(), "##.##%"));
  781. vo.setPercent3(WorkSchoolController.myPercent(vo.getItemsTotal3(), vo.getSchoolItemsTotal3(), "##.##%"));
  782. vo.setPercent4(WorkSchoolController.myPercent(vo.getItemsTotal4(), vo.getSchoolItemsTotal4(), "##.##%"));
  783. BeanUtils.copyProperties(vo, excel);
  784. excelList.add(excel);
  785. }
  786. }
  787. Map<String, Object> map = getItemsListTop(hazardBo);
  788. //获取当前登录用户
  789. LoginModel sysUser = tokenService.getLoginUser();
  790. String fw = "全部";//范围
  791. String zq = "全部";//统计周期
  792. if (list.getRecords().size() > 0) {
  793. zq = StringUtils.isEmpty(hazardBo.getBeginTime()) ? zq : (hazardBo.getBeginTime() + "-" + hazardBo.getEndTime());
  794. fw = hazardBo.getDeptId() == null ? fw : list.getRecords().get(0).getCollegeName();
  795. }
  796. String tips = "统计范围:" + fw + " 统计周期:" + zq + "\n" +
  797. "生成时间:" + DateUtils.getTime() + " 生成者:" + sysUser.getNickName() + " \n" +
  798. "隐患总数:" + map.get("sumTotal") + " ,一级指标隐患总数:" + map.get("level1") + " 占比:" + map.get("percent1") +
  799. " ,二级指标隐患总数:" + map.get("level2") + " 占比:" + map.get("percent2") +
  800. " ,三级指标隐患总数:" + map.get("level3") + " 占比:" + map.get("percent3") +
  801. " ,四级指标隐患总数:" + map.get("level4") + " 占比:" + map.get("percent4");
  802. ExcelUtil<ItemsExcel> util = new ExcelUtil<>(ItemsExcel.class);
  803. util.exportExcel(response, excelList, "实验室安全检查统计", tips, "实验室安全检查统计导出报表" + LocalDate.now());
  804. }
  805. /***
  806. * 判断当前登录用户安全检查身份类型
  807. * 管理员:1 检查人员:2 整改人员:3
  808. * @return
  809. */
  810. public Integer getUserIdentity() {
  811. //等级
  812. Integer level = 3;
  813. //获取当前登录用户
  814. LoginModel sysUser = tokenService.getLoginUser();
  815. //查看用户是否管理员
  816. AjaxResult arOption = remoteUserService.optionselect();
  817. if (HttpStatus.SUCCESS == Integer.valueOf(arOption.get("code").toString())) {
  818. List<LinkedHashMap<String, Object>> linkedHashMap = (List<LinkedHashMap<String, Object>>) arOption.get("data");
  819. if (linkedHashMap != null) {
  820. for (int i = 0; i < linkedHashMap.size(); i++) {
  821. String postCode = linkedHashMap.get(i).get("postCode").toString();
  822. String postId = linkedHashMap.get(i).get("postId").toString();
  823. if (sysUser.getPosition() != null && manageSign.equals(postCode) && sysUser.getPosition().equals(postId)) {
  824. return 1;
  825. }
  826. }
  827. }
  828. }
  829. QueryWrapper<CheckStaffUser> userQueryWrapper = new QueryWrapper<>();
  830. //是否实验室检查人员
  831. userQueryWrapper.lambda().eq(CheckStaffUser::getUserId, sysUser.getUserId()).eq(CheckStaffUser::getStaffType, 1);
  832. if (checkStaffUserService.list(userQueryWrapper).size() > 0) {
  833. return 2;
  834. }
  835. QueryWrapper<CheckMember> memberQueryWrapper = new QueryWrapper<>();
  836. //是否检查组成员
  837. memberQueryWrapper.lambda().eq(CheckMember::getUserId, sysUser.getUserId());
  838. if (checkMemberService.list(memberQueryWrapper).size() > 0) {
  839. return 2;
  840. }
  841. //是否实验室整改人员
  842. QueryWrapper<CheckStaffUser> userQueryWrapper2 = new QueryWrapper<>();
  843. userQueryWrapper2.lambda().eq(CheckStaffUser::getUserId, sysUser.getUserId()).eq(CheckStaffUser::getStaffType, 2);
  844. if (checkStaffUserService.list(userQueryWrapper2).size() > 0) {
  845. return level;
  846. }
  847. return level;
  848. }
  849. /***
  850. * 安全检查统计-小程序端使用
  851. * @param flg
  852. * 人员身份 3整改人 2检查人 1管理员
  853. * @return
  854. */
  855. @ApiOperation("安全检查统计-小程序端使用")
  856. @GetMapping(value = "/countApp")
  857. public ResultData countApp(Integer flg) {
  858. //本月检查数
  859. Integer checkTotal = 0;
  860. //本月隐患数
  861. Integer hazardTotal = 0;
  862. //本月已整改
  863. Integer rectifyTotal = 0;
  864. //本月检查合格率
  865. String qualifyRate = "0%";
  866. //本月整改率
  867. String rectificationRate = "0%";
  868. //本月复核通过率
  869. String passRate = "0%";
  870. Map<String, Object> map = new HashMap<>();
  871. LocalDate now = LocalDate.now();
  872. //获取当前登录用户
  873. LoginModel sysUser = tokenService.getLoginUser();
  874. if (StringUtils.isNull(flg)) {
  875. return ResultData.success(map);
  876. }
  877. if (3 == flg) {
  878. //本月已整改=已整改的次数(不含暂无法整改)
  879. LambdaQueryWrapper<CheckRectify> rectifyWrapper = new LambdaQueryWrapper<>();
  880. rectifyWrapper.eq(CheckRectify::getCreateBy, sysUser.getUserId()).notIn(CheckRectify::getRectifyResult, 0);
  881. rectifyWrapper.apply("date_format(create_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  882. .apply("date_format(create_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  883. rectifyTotal = checkRectifyService.list(rectifyWrapper).size();
  884. //查询该用户关联实验室集合
  885. QueryWrapper<CheckStaffUser> staffUserWrapper = new QueryWrapper<>();
  886. staffUserWrapper.select("sub_id subId ,count(1) sumCount").groupBy("sub_id").lambda().eq(CheckStaffUser::getUserId, sysUser.getUserId());
  887. List<Map<String, Object>> subListMap = checkStaffUserService.listMaps(staffUserWrapper);
  888. Long[] ids = subListMap.stream().map(a -> a.get("subId")).toArray(Long[]::new);
  889. CheckHazardBo bo = new CheckHazardBo();
  890. bo.setBeginTime(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()).toString());
  891. bo.setEndTime(DateUtils.getDate());
  892. if (ids != null && ids.length > 0) {
  893. bo.setSubIds(ids);
  894. }
  895. bo.setManageStatus(2);
  896. //当月检查隐患总数
  897. List<CheckHazardVo> hazardVoList = checkHazardService.seletHazardList(bo);
  898. hazardTotal = Integer.valueOf(!hazardVoList.isEmpty() ? hazardVoList.size() : 0);
  899. //已整改数(已整改的次数(不含暂无法整改))
  900. LambdaQueryWrapper<CheckRectify> rectifyWrapper2 = new LambdaQueryWrapper<>();
  901. rectifyWrapper2.eq(CheckRectify::getCreateBy, sysUser.getUserId()).notIn(CheckRectify::getRectifyResult, 0);
  902. if (!hazardVoList.isEmpty()) {
  903. Long[] hazardIds = hazardVoList.stream().map(CheckHazardVo::getId).toArray(Long[]::new);
  904. rectifyWrapper2.in(CheckRectify::getCheckHazardId, hazardIds);
  905. }
  906. rectifyWrapper2.apply("date_format(create_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  907. .apply("date_format(create_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')").groupBy(CheckRectify::getCheckHazardId);
  908. Integer yzgHazard = checkRectifyService.list(rectifyWrapper2).size();
  909. //本月整改率(用户整改的隐患数/隐患总数)
  910. rectificationRate = WorkSchoolController.myPercent(Convert.toInt(yzgHazard), hazardTotal, "##.##%");
  911. CheckHazardBo checkHazardBo = new CheckHazardBo();
  912. checkHazardBo.setCheckTimeOrder(2);//按照整改时间查询
  913. checkHazardBo.setBeginTime(now.with(TemporalAdjusters.firstDayOfMonth()).toString());
  914. checkHazardBo.setEndTime(DateUtils.getDate());
  915. //复核通过
  916. checkHazardBo.setExamineResult(1);
  917. Long tgCheck = checkHazardService.hiddenDangerRectifyCount(checkHazardBo);
  918. //复核未通过
  919. checkHazardBo.setCreateBy(sysUser.getUserId());
  920. checkHazardBo.setExamineResult(0);
  921. Long wtgCheck = checkHazardService.hiddenDangerRectifyCount(checkHazardBo);
  922. //本月复核通过率
  923. passRate = WorkSchoolController.myPercent(Convert.toInt(tgCheck), Convert.toInt((tgCheck + wtgCheck)), "##.##%");
  924. } else if (2 == flg) {
  925. //本月已检查数 sec_check_manage=2 的数据
  926. LambdaQueryWrapper<CheckManage> manageWrapper = new LambdaQueryWrapper<>();
  927. manageWrapper.eq(CheckManage::getCheckUserId, sysUser.getUserId()).eq(CheckManage::getManageStatus, 2);
  928. manageWrapper.apply("date_format(check_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  929. .apply("date_format(check_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  930. checkTotal = checkManageService.list(manageWrapper).size();
  931. //查询该用户关联实验室集合
  932. QueryWrapper<CheckStaffUser> staffUserWrapper = new QueryWrapper<>();
  933. staffUserWrapper.select("sub_id subId ,count(1) sumCount").groupBy("sub_id").lambda().eq(CheckStaffUser::getUserId, sysUser.getUserId());
  934. List<Map<String, Object>> subListMap = checkStaffUserService.listMaps(staffUserWrapper);
  935. Long[] ids = subListMap.stream().map(a -> a.get("subId")).toArray(Long[]::new);
  936. CheckHazardBo bo = new CheckHazardBo();
  937. bo.setBeginTime(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()).toString());
  938. bo.setEndTime(DateUtils.getDate());
  939. if (ids != null && ids.length > 0) {
  940. bo.setSubIds(ids);
  941. }
  942. bo.setManageStatus(2);
  943. //当月检查隐患总数
  944. List<CheckHazardVo> hazardVoList = checkHazardService.seletHazardList(bo);
  945. hazardTotal = Integer.valueOf(!hazardVoList.isEmpty() ? hazardVoList.size() : 0);
  946. //已整改数(已整改的次数(不含暂无法整改))
  947. LambdaQueryWrapper<CheckRectify> rectifyWrapper = new LambdaQueryWrapper<>();
  948. rectifyWrapper.eq(CheckRectify::getCreateBy, sysUser.getUserId()).notIn(CheckRectify::getRectifyResult, 0);
  949. rectifyWrapper.apply("date_format(create_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  950. .apply("date_format(create_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  951. rectifyTotal = checkRectifyService.list(rectifyWrapper).size();
  952. //用户当月整改的隐患数
  953. /*CheckHazardBo haBo = new CheckHazardBo();
  954. haBo.setCheckTimeOrder(2);//按整改时间查询
  955. haBo.setBeginTime(now.with(TemporalAdjusters.firstDayOfMonth()).toString());
  956. haBo.setEndTime(DateUtils.getDate());
  957. haBo.setCreateBy(sysUser.getUserId());
  958. //haBo.setExamineResult(1);//审核通过
  959. haBo.setZgTermOrder(1);//已整改,且不包含无法整改
  960. Long yzgHazard = checkHazardService.hiddenDangerRectifyCount(haBo);*/
  961. LambdaQueryWrapper<CheckRectify> rectifyWrapper2 = new LambdaQueryWrapper<>();
  962. rectifyWrapper2.eq(CheckRectify::getCreateBy, sysUser.getUserId()).notIn(CheckRectify::getRectifyResult, 4).isNotNull(CheckRectify::getRectifyResult);
  963. if (!hazardVoList.isEmpty()) {
  964. Long[] hazardIds = hazardVoList.stream().map(CheckHazardVo::getId).toArray(Long[]::new);
  965. rectifyWrapper2.in(CheckRectify::getCheckHazardId, hazardIds);
  966. }
  967. rectifyWrapper2.apply("date_format(create_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  968. .apply("date_format(create_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')").groupBy(CheckRectify::getCheckHazardId);
  969. Integer yzgHazard = checkRectifyService.list(rectifyWrapper2).size();
  970. //检查通过 补充时间条件
  971. LambdaQueryWrapper<CheckManage> manWrapper = new LambdaQueryWrapper<>();
  972. manWrapper.eq(CheckManage::getCheckUserId, sysUser.getUserId()).eq(CheckManage::getCheckResult, 1);
  973. manWrapper.apply("date_format(check_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  974. .apply("date_format(check_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  975. Integer tgTotal = checkManageService.list(manWrapper).size();
  976. //检查不通过 补充时间条件
  977. LambdaQueryWrapper<CheckManage> manWrapper2 = new LambdaQueryWrapper<>();
  978. manWrapper2.eq(CheckManage::getCheckUserId, sysUser.getUserId()).eq(CheckManage::getCheckResult, 0);
  979. manWrapper2.apply("date_format(check_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  980. .apply("date_format(check_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  981. Integer bhTotal = checkManageService.list(manWrapper2).size();
  982. //合格率
  983. qualifyRate = WorkSchoolController.myPercent(tgTotal, (tgTotal + bhTotal), "##.##%");
  984. //本月整改率 :已整改数(不含暂无法整改)÷检查隐患数
  985. rectificationRate = WorkSchoolController.myPercent(Convert.toInt(yzgHazard), hazardTotal, "##.##%");
  986. CheckHazardBo checkHazardBo = new CheckHazardBo();
  987. checkHazardBo.setCheckTimeOrder(1);//按照复核时间查询
  988. checkHazardBo.setBeginTime(now.with(TemporalAdjusters.firstDayOfMonth()).toString());
  989. checkHazardBo.setEndTime(DateUtils.getDate());
  990. checkHazardBo.setReviewedBy(sysUser.getUserId());
  991. //复核未通过
  992. checkHazardBo.setExamineResult(0);
  993. Long wtgCheck = checkHazardService.hiddenDangerRectifyCount(checkHazardBo);
  994. //复核通过
  995. checkHazardBo.setExamineResult(1);
  996. Long tgCheck = checkHazardService.hiddenDangerRectifyCount(checkHazardBo);
  997. //本月复核通过率
  998. passRate = WorkSchoolController.myPercent(Convert.toInt(tgCheck), Convert.toInt((tgCheck + wtgCheck)), "##.##%");
  999. } else if (1 == flg || 11 == flg) {
  1000. LoginModel loginModel = tokenService.getLoginUser();
  1001. List<Long> userIds = null;
  1002. if (11 == flg) {
  1003. //如果是院级查询本部门子集集合
  1004. ResultData<List<SysDept>> listResultData = remoteDeptService.getDeptListBySubset(loginModel.getDeptId());
  1005. if (listResultData.getCode().equals(HttpStatus.SUCCESS)) {
  1006. List<SysDept> deptList = listResultData.getData();
  1007. if (!deptList.isEmpty()) {
  1008. List<Long> deptIds = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList());
  1009. deptIds.add(loginModel.getDeptId());
  1010. //查询部门下的用户集合
  1011. ResultData<List<Long>> userDeptIDS = remoteUserService.getSysCustomRoleUserIds(deptIds);
  1012. if (userDeptIDS.getCode().equals(HttpStatus.SUCCESS) && !userDeptIDS.getData().isEmpty()) {
  1013. userIds = userDeptIDS.getData();
  1014. }
  1015. }
  1016. }
  1017. }
  1018. //本月已检查数 sec_check_manage=2 的数据
  1019. LambdaQueryWrapper<CheckManage> manageWrapper = new LambdaQueryWrapper<>();
  1020. manageWrapper.eq(CheckManage::getManageStatus, 2);
  1021. manageWrapper.apply("date_format(check_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  1022. .apply("date_format(check_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  1023. if (userIds != null) {
  1024. manageWrapper.in(CheckManage::getCreateBy, userIds);
  1025. }
  1026. checkTotal = checkManageService.list(manageWrapper).size();
  1027. CheckHazardBo bo = new CheckHazardBo();
  1028. bo.setBeginTime(LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()).toString());
  1029. bo.setEndTime(DateUtils.getDate());
  1030. //当月检查隐患总数
  1031. bo.setManageStatus(2);
  1032. if (userIds != null) {
  1033. bo.setUserIds(userIds.stream().toArray(Long[]::new));
  1034. }
  1035. //hazardTotal = Integer.valueOf(checkHazardService.hiddenDangerCount(bo).toString());
  1036. List<CheckHazardVo> hazardVoList = checkHazardService.seletHazardList(bo);
  1037. hazardTotal = Integer.valueOf(!hazardVoList.isEmpty() ? hazardVoList.size() : 0);
  1038. //本月已整改(已整改的次数(不含暂无法整改))
  1039. LambdaQueryWrapper<CheckRectify> rectifyWrapper = new LambdaQueryWrapper<>();
  1040. rectifyWrapper.notIn(CheckRectify::getRectifyResult, 0);
  1041. rectifyWrapper.apply("date_format(create_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  1042. .apply("date_format(create_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  1043. if (userIds != null) {
  1044. rectifyWrapper.in(CheckRectify::getCreateBy, userIds);
  1045. //bo.setUserIds(userIds.stream().toArray(Long[]::new));
  1046. }
  1047. rectifyTotal = checkRectifyService.list(rectifyWrapper).size();
  1048. //当月整改的隐患数
  1049. /*CheckHazardBo haBo = new CheckHazardBo();
  1050. haBo.setCheckTimeOrder(2);//按照整改时间查询
  1051. haBo.setBeginTime(now.with(TemporalAdjusters.firstDayOfMonth()).toString());
  1052. haBo.setEndTime(DateUtils.getDate());
  1053. //haBo.setExamineResult(1);//审核通过
  1054. haBo.setZgTermOrder(1);//已整改,且不包含无法整改
  1055. if(userIds!=null){
  1056. //rectifyWrapper.in(CheckRectify::getCreateBy,userIds);
  1057. haBo.setUserIds(userIds.stream().toArray(Long[]::new));
  1058. }
  1059. Long yzgHazard = checkHazardService.hiddenDangerRectifyCount(haBo);*/
  1060. LambdaQueryWrapper<CheckRectify> rectifyWrapper2 = new LambdaQueryWrapper<>();
  1061. rectifyWrapper2.notIn(CheckRectify::getRectifyResult, 4).isNotNull(CheckRectify::getRectifyResult);
  1062. if(userIds!=null){
  1063. rectifyWrapper2.in(CheckRectify::getCreateBy,userIds);
  1064. }
  1065. if (!hazardVoList.isEmpty()) {
  1066. Long[] hazardIds = hazardVoList.stream().map(CheckHazardVo::getId).toArray(Long[]::new);
  1067. rectifyWrapper2.in(CheckRectify::getCheckHazardId, hazardIds);
  1068. }
  1069. rectifyWrapper2.apply("date_format(create_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  1070. .apply("date_format(create_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')").groupBy(CheckRectify::getCheckHazardId);
  1071. Integer yzgHazard = checkRectifyService.list(rectifyWrapper2).size();
  1072. //检查通过 补充时间条件
  1073. LambdaQueryWrapper<CheckManage> manWrapper = new LambdaQueryWrapper<>();
  1074. manWrapper.eq(CheckManage::getCheckResult, 1);
  1075. manWrapper.apply("date_format(check_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  1076. .apply("date_format(check_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  1077. if (userIds != null) {
  1078. manWrapper.in(CheckManage::getCreateBy, userIds);
  1079. //haBo.setUserIds(userIds.stream().toArray(Long[]::new));
  1080. }
  1081. Integer tgTotal = checkManageService.list(manWrapper).size();
  1082. //检查不通过 补充时间条件
  1083. LambdaQueryWrapper<CheckManage> manWrapper2 = new LambdaQueryWrapper<>();
  1084. manWrapper2.eq(CheckManage::getCheckResult, 0);
  1085. manWrapper2.apply("date_format(check_time,'%Y-%m-%d')>=DATE_FORMAT('" + now.with(TemporalAdjusters.firstDayOfMonth()) + "','%Y-%m-%d')")
  1086. .apply("date_format(check_time,'%Y-%m-%d')<=DATE_FORMAT('" + DateUtils.getDate() + "','%Y-%m-%d')");
  1087. if (userIds != null) {
  1088. manWrapper2.in(CheckManage::getCreateBy, userIds);
  1089. //haBo.setUserIds(userIds.stream().toArray(Long[]::new));
  1090. }
  1091. Integer bhTotal = checkManageService.list(manWrapper2).size();
  1092. //合格率
  1093. qualifyRate = WorkSchoolController.myPercent(tgTotal, (tgTotal + bhTotal), "##.##%");
  1094. //本月整改率 :已整改数(不含暂无法整改)÷检查隐患数
  1095. rectificationRate = WorkSchoolController.myPercent(Convert.toInt(yzgHazard), hazardTotal, "##.##%");
  1096. CheckHazardBo checkHazardBo = new CheckHazardBo();
  1097. checkHazardBo.setCheckTimeOrder(1);//按照复核时间查询
  1098. checkHazardBo.setBeginTime(now.with(TemporalAdjusters.firstDayOfMonth()).toString());
  1099. checkHazardBo.setEndTime(DateUtils.getDate());
  1100. //复核未通过
  1101. checkHazardBo.setExamineResult(0);
  1102. if (userIds != null) {
  1103. //manWrapper2.in(CheckManage::getCreateBy,userIds);
  1104. checkHazardBo.setUserIds(userIds.stream().toArray(Long[]::new));
  1105. }
  1106. Long wtgCheck = checkHazardService.hiddenDangerRectifyCount(checkHazardBo);
  1107. //复核通过
  1108. checkHazardBo.setExamineResult(1);
  1109. Long tgCheck = checkHazardService.hiddenDangerRectifyCount(checkHazardBo);
  1110. //本月复核通过率
  1111. passRate = WorkSchoolController.myPercent(Convert.toInt(tgCheck), Convert.toInt((tgCheck + wtgCheck)), "##.#%");
  1112. }
  1113. map.put("checkTotal", checkTotal);
  1114. map.put("hazardTotal", hazardTotal);
  1115. map.put("rectifyTotal", rectifyTotal);
  1116. map.put("qualifyRate", qualifyRate);
  1117. map.put("rectificationRate", rectificationRate);
  1118. map.put("passRate", passRate);
  1119. map.put("userType", flg);
  1120. return ResultData.success(map);
  1121. }
  1122. /*********************************数据大屏*********************************************/
  1123. /***
  1124. * 获取最新一条进行中的计划
  1125. * @return
  1126. */
  1127. private Long getPantId() {
  1128. Long planId = null;
  1129. //进行中的计划
  1130. QueryWrapper<CheckPlan> planWrapper = new QueryWrapper<>();
  1131. planWrapper.lambda().eq(CheckPlan::getCheckStatus, 2);
  1132. List<CheckPlan> list = checkPlanService.list(planWrapper);
  1133. if (list != null && !list.isEmpty()) {
  1134. //根据所有正在进行中的计划获取最新一条进行中的计划信息
  1135. Long[] planIds = list.stream().map(a -> a.getId()).toArray(Long[]::new);
  1136. QueryWrapper<CheckManage> manageWper = new QueryWrapper<>();
  1137. manageWper.lambda().in(CheckManage::getCheckPlanId, planIds).orderByDesc(CheckManage::getCreateTime).last(" limit 1");
  1138. List<CheckManage> mgList = checkManageService.list(manageWper);
  1139. if (mgList != null && !mgList.isEmpty()) {
  1140. planId = mgList.get(0).getCheckPlanId();
  1141. }
  1142. }
  1143. return planId;
  1144. }
  1145. /****
  1146. * 大屏数据统计,获取最新一条开始中的计划
  1147. * @param
  1148. * @return
  1149. */
  1150. @ApiOperation("大屏数据统计,获取最新一条开始中的计划")
  1151. @GetMapping(value = "/bigViewCount")
  1152. public ResultData bigViewCount() {
  1153. Map<String, Object> map = new HashMap<>();
  1154. //隐患数总
  1155. Integer yhTotal = 0;
  1156. //本次已整改
  1157. Integer yzgTotal = 0;
  1158. //遗留数
  1159. Integer ylTotal = 0;
  1160. //日期
  1161. String dateTime = "";
  1162. //标题
  1163. String title = "";
  1164. //获取最新一条进行中的计划
  1165. Long planId = getPantId();
  1166. if (planId != null) {
  1167. QueryWrapper<CheckPlan> planWrapper = new QueryWrapper<>();
  1168. planWrapper.lambda().eq(CheckPlan::getId, planId);
  1169. List<CheckPlan> list = checkPlanService.list(planWrapper);
  1170. if (list != null && !list.isEmpty()) {
  1171. CheckPlan plan = list.get(0);
  1172. Long pantId = plan.getId();
  1173. dateTime = plan.getCreateTime().getYear() + "年" + plan.getCreateTime().getMonthValue() + "月" + plan.getCreateTime().getDayOfMonth() + "日";
  1174. title = plan.getTitle();
  1175. //该计划下的隐患总数
  1176. Page<CheckHazardBo> page = new Page().setSize(-1);
  1177. CheckHazardBo bo = new CheckHazardBo();
  1178. bo.setPlanId(pantId);
  1179. Page<CheckHazardVo> hazardList = checkHazardService.hiddenDataStatisticsList(page, bo);
  1180. yhTotal = hazardList.getRecords().size();
  1181. //已整改数
  1182. if (yhTotal > 0) {
  1183. for (CheckHazardVo vo : hazardList.getRecords()) {
  1184. if (vo.getRectifyStatus().equals(1)) {
  1185. yzgTotal++;
  1186. }
  1187. }
  1188. //该计划下的遗留总数(未整改的)
  1189. bo.setRectifyStatus(2);
  1190. Page<CheckHazardVo> notStartedList = checkHazardService.hiddenDataStatisticsList(page, bo);
  1191. ylTotal = notStartedList.getRecords().size();
  1192. }
  1193. }
  1194. }
  1195. map.put("ylTotal", ylTotal);
  1196. map.put("yzgTotal", yzgTotal);
  1197. map.put("yhTotal", yhTotal);
  1198. map.put("dateTime", dateTime);
  1199. map.put("title", title);
  1200. map.put("planId", String.valueOf(planId));
  1201. return ResultData.success(map);
  1202. }
  1203. /***
  1204. * 大屏数据统计,获取最新一条开始中的计划下的实验室隐患信息
  1205. * @return
  1206. */
  1207. @ApiOperation("大屏数据统计,获取最新一条开始中的计划")
  1208. @GetMapping(value = "/bigViewList")
  1209. public TableDataInfo bigViewList(CheckManageBo bo) {
  1210. List<CheckManageVo> listVo = new ArrayList<>();
  1211. //获取最新一条进行中的计划
  1212. Long planId = getPantId();
  1213. if (planId != null) {
  1214. //查询计划信息
  1215. QueryWrapper<CheckPlan> planQueryWrapper = new QueryWrapper<>();
  1216. planQueryWrapper.lambda().eq(CheckPlan::getId, planId);
  1217. List<CheckPlan> checkPlanList = checkPlanService.list(planQueryWrapper);
  1218. CheckPlan plan = checkPlanList.get(0);
  1219. //查询该计划下 检查中和已完成的数据
  1220. PageHelper.startPage(bo.getPageNum(), bo.getPageSize());
  1221. QueryWrapper<CheckManage> manageWrapper = new QueryWrapper<>();
  1222. manageWrapper.lambda().eq(CheckManage::getCheckPlanId, plan.getId()).notIn(CheckManage::getManageStatus, 0);
  1223. List<CheckManage> manageList = checkManageService.list(manageWrapper);
  1224. for (CheckManage m : manageList) {
  1225. QueryWrapper<CheckHazard> hazardWrapper = new QueryWrapper<>();
  1226. //查询该条计划的隐患已整改数量(已完成,不包含暂无法整改)
  1227. CheckManageVo mVo = new CheckManageVo();
  1228. BeanUtils.copyProperties(m, mVo);
  1229. hazardWrapper.lambda().eq(CheckHazard::getCheckManageId, m.getId()).eq(CheckHazard::getRectifyStatus, 1);
  1230. List<CheckHazard> haList = checkHazardService.list(hazardWrapper);
  1231. //已整改数量
  1232. mVo.setAmount(haList.size());
  1233. listVo.add(mVo);
  1234. }
  1235. }
  1236. return getDataTable(listVo);
  1237. }
  1238. /****
  1239. * 大屏遗留问题列表
  1240. * @param bo
  1241. * @return
  1242. */
  1243. @ApiOperation("大屏遗留问题列表")
  1244. @GetMapping(value = "/remainList")
  1245. public TableDataInfo bigViewRemainHazardList(CheckHazardBo bo) {
  1246. List<CheckHazardVo> list = new ArrayList<>();
  1247. if (StringUtils.isNull(bo.getPlanId())) {
  1248. return getDataTable(list);
  1249. }
  1250. PageHelper.startPage(bo.getPageNum(), bo.getPageSize());
  1251. //未整改
  1252. bo.setRectifyStatus(2);
  1253. list = checkHazardService.hazardList(bo);
  1254. return getDataTable(list);
  1255. }
  1256. /****
  1257. * 大屏本次检查问题
  1258. * @param bo
  1259. * @return
  1260. */
  1261. @ApiOperation("大屏本次检查问题")
  1262. @GetMapping(value = "/rectificationList")
  1263. public TableDataInfo bigViewRectificationHazardList(CheckHazardBo bo) {
  1264. List<CheckHazardVo> list = new ArrayList<>();
  1265. if (StringUtils.isNull(bo.getPlanId())) {
  1266. return getDataTable(list);
  1267. }
  1268. PageHelper.startPage(bo.getPageNum(), bo.getPageSize());
  1269. list = checkHazardService.hazardList(bo);
  1270. return getDataTable(list);
  1271. }
  1272. /***
  1273. * 数据大屏 安全隐患统计-按指标分组
  1274. * @param bo
  1275. * @return
  1276. */
  1277. @DataPermission()
  1278. @ApiOperation("安全隐患统计-按指标分组")
  1279. @GetMapping(value = "/groupHazard")
  1280. public TableDataInfo groupHazard(CheckHazardBo bo) {
  1281. List<Long> users = DataPermissionAspect.threadLocal.get();
  1282. if(users!=null && !users.isEmpty()){
  1283. bo.setUserIds(users.stream().toArray(Long[]::new));
  1284. DataPermissionAspect.threadLocal.remove();
  1285. }
  1286. PageHelper.startPage(bo.getPageNum(), bo.getPageSize());
  1287. return getDataTable(checkHazardService.groupByHazard(bo));
  1288. }
  1289. /***
  1290. * 安全隐患统计-按实验室分组
  1291. * @param bo
  1292. * @return
  1293. */
  1294. @DataPermission()
  1295. @ApiOperation("安全隐患统计-按实验室分组")
  1296. @GetMapping(value = "/groupSub")
  1297. public TableDataInfo groupSub(CheckHazardBo bo) {
  1298. List<Long> users = DataPermissionAspect.threadLocal.get();
  1299. if(users!=null && !users.isEmpty()){
  1300. bo.setUserIds(users.stream().toArray(Long[]::new));
  1301. DataPermissionAspect.threadLocal.remove();
  1302. }
  1303. return getDataTable(checkHazardService.groupBySub(bo));
  1304. }
  1305. @ApiOperation("安全隐患指标列表")
  1306. @GetMapping(value = "/optionList")
  1307. public ResultData optionList() {
  1308. QueryWrapper<CheckOption> mgWrapper = new QueryWrapper<>();
  1309. mgWrapper.lambda().eq(CheckOption::getLevel, 1).eq(CheckOption::getIsDeleted, 0);
  1310. Page<CheckOption> page = new Page().setSize(-1);
  1311. return ResultData.success(checkOptionService.page(page, mgWrapper));
  1312. }
  1313. /***
  1314. * 数据大屏 安全隐患统计 检查项、实验室分组列表
  1315. * @return
  1316. */
  1317. @DataPermission()
  1318. @ApiOperation("安全隐患指标、实验室列表")
  1319. @GetMapping(value = "/hazardSubList")
  1320. public ResultData hazardSubList(CheckHazardBo bo) {
  1321. List<Long> users = DataPermissionAspect.threadLocal.get();
  1322. if(users!=null && !users.isEmpty()){
  1323. bo.setUserIds(users.stream().toArray(Long[]::new));
  1324. DataPermissionAspect.threadLocal.remove();
  1325. }
  1326. Page<CheckHazardBo> page = new Page<>(bo.getPageNum(), bo.getPageSize());
  1327. return ResultData.success(checkHazardService.groupBySubAndOption(page, bo));
  1328. }
  1329. }