SpecHomeController.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. package com.ruoyi.project.sems.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.fasterxml.jackson.databind.ObjectMapper;
  5. import com.ruoyi.common.utils.document.DocumentHandler;
  6. import com.ruoyi.common.utils.document.PDFTemplateUtil;
  7. import com.ruoyi.common.utils.poi.ExcelUtil;
  8. import com.ruoyi.framework.aspectj.lang.annotation.Log;
  9. import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
  10. import com.ruoyi.framework.web.controller.BaseController;
  11. import com.ruoyi.framework.web.domain.AjaxResult;
  12. import com.ruoyi.framework.web.page.TableDataInfo;
  13. import com.ruoyi.project.approve.damain.DevTask;
  14. import com.ruoyi.project.listener.semsApprove.*;
  15. import com.ruoyi.project.sems.domain.*;
  16. import com.ruoyi.project.sems.mapper.TApproveMapper;
  17. import com.ruoyi.project.sems.service.*;
  18. import com.ruoyi.project.system.domain.SysDictData;
  19. import com.ruoyi.project.system.domain.SysPlant;
  20. import com.ruoyi.project.system.domain.SysUser;
  21. import com.ruoyi.project.system.service.ISysDictTypeService;
  22. import com.ruoyi.project.system.service.ISysPlantService;
  23. import com.ruoyi.project.system.service.ISysUserService;
  24. import freemarker.template.Template;
  25. import org.activiti.engine.*;
  26. import org.activiti.engine.history.HistoricProcessInstance;
  27. import org.activiti.engine.history.HistoricTaskInstance;
  28. import org.activiti.engine.history.HistoricTaskInstanceQuery;
  29. import org.activiti.engine.impl.identity.Authentication;
  30. import org.activiti.engine.runtime.ProcessInstance;
  31. import org.activiti.engine.task.Comment;
  32. import org.activiti.engine.task.Task;
  33. import org.apache.commons.lang.StringUtils;
  34. import org.springframework.beans.factory.annotation.Autowired;
  35. import org.springframework.security.access.prepost.PreAuthorize;
  36. import org.springframework.web.bind.annotation.*;
  37. import javax.servlet.http.HttpServletRequest;
  38. import javax.servlet.http.HttpServletResponse;
  39. import java.io.IOException;
  40. import java.io.OutputStream;
  41. import java.math.BigDecimal;
  42. import java.text.SimpleDateFormat;
  43. import java.util.*;
  44. /**
  45. * 特种设备申请Controller
  46. *
  47. * @author ruoyi
  48. * @date 2021-08-05
  49. */
  50. @RestController
  51. @RequestMapping("/sems/home")
  52. public class SpecHomeController extends BaseController
  53. {
  54. @Autowired
  55. private ITApproveService tApproveService;
  56. @Autowired
  57. private RuntimeService runtimeService;
  58. @Autowired
  59. private HistoryService historyService;
  60. @Autowired
  61. private TaskService taskService;
  62. @Autowired
  63. private ITSpecdevDtService tSpecdevDtService;
  64. @Autowired
  65. private ITSpecdevDzsbService tSpecdevDzsbService;
  66. @Autowired
  67. private ITSpecdevGlService tSpecdevGlService;
  68. @Autowired
  69. private ITSpecdevYlgdService tSpecdevYlgdService;
  70. @Autowired
  71. private ITSpecdevYlrqService tSpecdevYlrqService;
  72. @Autowired
  73. private ITSpecdevCcService tSpecdevCcService;
  74. @Autowired
  75. private ITApproverFileService tApproverFileService;
  76. @Autowired
  77. private ISysUserService sysUserService;
  78. @Autowired
  79. private ISysPlantService sysPlantService;
  80. @Autowired
  81. private ISysDictTypeService iSysDictTypeService;
  82. /**
  83. * 查询装置管理列表
  84. */
  85. @GetMapping("/plantList")
  86. public AjaxResult list(SysPlant sysPlant)
  87. {
  88. List<SysPlant> list = sysPlantService.selectSysPlantList(sysPlant);
  89. return AjaxResult.success(list);
  90. }
  91. /**
  92. * 首页数据
  93. */
  94. @RequestMapping(value = "devData")
  95. public AjaxResult homeData(@RequestBody Map<String, Object> params) {
  96. logger.info(JSON.toJSONString(params));
  97. List plantIds = (List) params.get("plantIds");
  98. List unitIds = (List) params.get("unitIds");
  99. //压力管道
  100. int ylgdAll = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  101. .in("plant_code",plantIds)
  102. .eq("STATUS" , 1)
  103. .eq("del_flag" , 0)
  104. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
  105. );
  106. //查询管道长度
  107. List<TSpecdevYlgd> gdList = tSpecdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
  108. .eq("STATUS" , 1)
  109. .eq("del_flag" , 0)
  110. .in("plant_code",plantIds)
  111. // .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  112. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
  113. );
  114. double allLength = 0;
  115. for (int i = 0; i < gdList.size(); i++) {
  116. double gdLength = 0;
  117. if (!StringUtils.isBlank(gdList.get(i).getLength())) {
  118. if (gdList.get(i).getLength().indexOf("\n") > -1) {
  119. String[] arr = gdList.get(i).getLength().split("\n");
  120. logger.info(JSON.toJSONString(arr));
  121. for (int j = 0; j < arr.length; j++) {
  122. gdLength += Double.parseDouble(arr[j]);
  123. }
  124. }else {
  125. gdLength = Double.parseDouble(gdList.get(i).getLength());
  126. }
  127. }
  128. allLength += gdLength;
  129. }
  130. Map<String, Object> mapylgd = new HashMap<String, Object>();
  131. mapylgd.put("ylgdAll_num", ylgdAll);
  132. mapylgd.put("ylgd_length", allLength);
  133. //压力容器
  134. int ylrqAll = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  135. .eq("STATUS" , 1)
  136. .eq("del_flag" , 0)
  137. .in("plant_code",plantIds)
  138. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  139. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
  140. );
  141. Map<String, Object> mapylrq = new HashMap<String, Object>();
  142. mapylrq.put("ylrqAll_num", ylrqAll);
  143. //锅炉
  144. int glAll = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  145. .eq("STATUS" , 1)
  146. .eq("del_flag" , 0)
  147. .in("plant_code",plantIds)
  148. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  149. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  150. );
  151. Map<String, Object> mapgl = new HashMap<String, Object>();
  152. mapgl.put("glAll_num", glAll);
  153. //电梯
  154. int dtAll = tSpecdevDtService.count(new QueryWrapper<TSpecdevDt>()
  155. .eq("STATUS" , 1)
  156. .eq("del_flag" , 0)
  157. .in("plant_code",plantIds)
  158. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  159. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  160. );
  161. Map<String, Object> mapdt = new HashMap<String, Object>();
  162. mapdt.put("dtAll_num", dtAll);
  163. //吊装设备
  164. int dzsbAll = tSpecdevDzsbService.count(new QueryWrapper<TSpecdevDzsb>()
  165. .eq("STATUS" , 1)
  166. .eq("del_flag" , 0)
  167. .in("plant_code",plantIds)
  168. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  169. .like("CHECK_STRATEGY","强制")
  170. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  171. );
  172. int dzsbUn = tSpecdevDzsbService.count(new QueryWrapper<TSpecdevDzsb>()
  173. .eq("STATUS" , 1)
  174. .eq("del_flag" , 0)
  175. .in("plant_code",plantIds)
  176. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  177. .like("CHECK_STRATEGY","委托")
  178. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  179. );
  180. Map<String, Object> mapdzsb = new HashMap<String, Object>();
  181. mapdzsb.put("dzsbAll_num", dzsbAll);
  182. mapdzsb.put("dzsbUn_num", dzsbUn);
  183. //叉车
  184. int ccAll = tSpecdevCcService.count(new QueryWrapper<TSpecdevCc>()
  185. .eq("STATUS" , 1)
  186. .eq("del_flag" , 0)
  187. .in("plant_code",plantIds)
  188. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  189. .and(unitIds.size()>0 ,i -> i.in("plant_code",unitIds))
  190. );
  191. Map<String, Object> mapcc = new HashMap<String, Object>();
  192. mapcc.put("ccAll_num", ccAll);
  193. Map<String, Object> res = new HashMap<String, Object>();
  194. res.put("ylgdData", mapylgd);
  195. res.put("ylrqData", mapylrq);
  196. res.put("dtData", mapdt);
  197. res.put("dzsbData", mapdzsb);
  198. res.put("glData", mapgl);
  199. res.put("ccData" , mapcc);
  200. return AjaxResult.success(res);
  201. }
  202. /**
  203. * 压力容器数据
  204. */
  205. @RequestMapping(value = "devYlrqData")
  206. public AjaxResult devYlrqData(@RequestBody Map<String, Object> params) {
  207. List plantIds = (List) params.get("plantIds");
  208. List unitIds = (List) params.get("unitIds");
  209. Calendar now = Calendar.getInstance();
  210. int year = now.get(Calendar.YEAR);
  211. Map<String, Object> ylrqData = new HashMap<String, Object>();
  212. List yearList = new ArrayList();
  213. List countList = new ArrayList();
  214. String applySql = "to_char(NEXT_WARN_DATE,'yyyy') = {0}";
  215. for (int j = 0; j < 5; j++) {
  216. int num = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  217. .eq("STATUS" , 1)
  218. .eq("del_flag" , 0)
  219. .apply(true,applySql,year)
  220. .in("plant_code",plantIds)
  221. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  222. );
  223. yearList.add(year);
  224. countList.add(num);
  225. year++;
  226. }
  227. ylrqData.put("yearList" , yearList.toArray());
  228. ylrqData.put("countList" , countList.toArray());
  229. Map<String, Object> res = new HashMap<String, Object>();
  230. res.put("ylrqData" , ylrqData);
  231. return AjaxResult.success(res);
  232. }
  233. /**
  234. * 锅炉数据
  235. */
  236. @RequestMapping(value = "devGlData")
  237. public AjaxResult devGlData(@RequestBody Map<String, Object> params) {
  238. List plantIds = (List) params.get("plantIds");
  239. List unitIds = (List) params.get("unitIds");
  240. Calendar now = Calendar.getInstance();
  241. int year = now.get(Calendar.YEAR);
  242. Map<String, Object> GlData = new HashMap<String, Object>();
  243. //内检
  244. List yearList = new ArrayList();
  245. List countList = new ArrayList();
  246. String applySql = "to_char(NEXT_WARN_DATE,'yyyy') = {0}";
  247. for (int i = 0; i < 5; i++) {
  248. int num = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  249. .eq("STATUS" , 1)
  250. .eq("del_flag" , 0)
  251. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  252. .apply(true,applySql,year)
  253. .in("plant_code",plantIds)
  254. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  255. );
  256. yearList.add(year);
  257. countList.add(num);
  258. year++;
  259. }
  260. //外检
  261. List yearList2 = new ArrayList();
  262. List countList2 = new ArrayList();
  263. year = now.get(Calendar.YEAR);
  264. String applySql2 = "to_char(OUT_NEXT_WARN_DATE,'yyyy') = {0}";
  265. for (int i = 0; i < 5; i++) {
  266. int num = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  267. .eq("STATUS" , 1)
  268. .eq("del_flag" , 0)
  269. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  270. .apply(true,applySql2,year)
  271. .in("plant_code",plantIds)
  272. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  273. );
  274. yearList2.add(year);
  275. countList2.add(num);
  276. year++;
  277. }
  278. GlData.put("yearList" , yearList.toArray());
  279. GlData.put("countList" , countList.toArray());
  280. GlData.put("yearList2" , yearList2.toArray());
  281. GlData.put("countList2" , countList2.toArray());
  282. Map<String, Object> res = new HashMap<String, Object>();
  283. res.put("GlData" , GlData);
  284. return AjaxResult.success(res);
  285. }
  286. /**
  287. * 压力管道数据
  288. */
  289. @RequestMapping(value = "devYlgdData")
  290. public AjaxResult devYlgdData(@RequestBody Map<String, Object> params) {
  291. List plantIds = (List) params.get("plantIds");
  292. List unitIds = (List) params.get("unitIds");
  293. Calendar now = Calendar.getInstance();
  294. int year = now.get(Calendar.YEAR);
  295. Map<String, Object> ylrqData = new HashMap<String, Object>();
  296. List yearList = new ArrayList();
  297. List countList = new ArrayList();
  298. String applySql = "to_char(NEXT_WARN_DATE,'yyyy') = {0}";
  299. for (int i = 0; i < 5; i++) {
  300. int num = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  301. .eq("STATUS" , 1)
  302. .eq("del_flag" , 0)
  303. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  304. .apply(true,applySql,year)
  305. .in("plant_code",plantIds)
  306. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  307. );
  308. yearList.add(year);
  309. countList.add(num);
  310. year++;
  311. }
  312. ylrqData.put("yearList" , yearList.toArray());
  313. ylrqData.put("countList" , countList.toArray());
  314. Map<String, Object> res = new HashMap<String, Object>();
  315. res.put("ylrqData" , ylrqData);
  316. return AjaxResult.success(res);
  317. }
  318. /**
  319. * 压力管道数据
  320. */
  321. @RequestMapping(value = "devOtherData")
  322. public AjaxResult devOtherData(@RequestBody Map<String, Object> params) {
  323. Calendar now = Calendar.getInstance();
  324. int year = now.get(Calendar.YEAR);
  325. int month = now.get(Calendar.MONTH) + 1;
  326. List<DevData> listcc = tSpecdevCcService.otherDevCount(params);
  327. List<DevData> listdzsb = tSpecdevDzsbService.otherDevCount(params);
  328. List<DevData> listdt = tSpecdevDtService.otherDevCount(params);
  329. List ccList = new ArrayList();
  330. List dzsbList = new ArrayList();
  331. List dtList = new ArrayList();
  332. List monthList = new ArrayList();
  333. for (int i = 0; i < 24; i++) {
  334. String devDate = year + String.valueOf(month);
  335. if (month < 10){
  336. devDate = year + "0" +String.valueOf(month);
  337. }
  338. boolean flag = true;
  339. for (DevData d: listcc
  340. ) {
  341. flag = true;
  342. if (devDate.equals(d.getYearM())){
  343. ccList.add(d.getNum());
  344. flag = false;
  345. break;
  346. }
  347. }
  348. if (flag == true) {
  349. ccList.add(0);
  350. }
  351. for (DevData d: listdzsb
  352. ) {
  353. flag = true;
  354. if (devDate.equals(d.getYearM())){
  355. dzsbList.add(d.getNum());
  356. flag = false;
  357. break;
  358. }
  359. }
  360. if (flag == true) {
  361. dzsbList.add(0);
  362. }
  363. for (DevData d: listdt
  364. ) {
  365. flag = true;
  366. if (devDate.equals(d.getYearM())){
  367. dtList.add(d.getNum());
  368. flag = false;
  369. break;
  370. }
  371. }
  372. if (flag == true) {
  373. dtList.add(0);
  374. }
  375. if (!(ccList.size() == 0 && dzsbList.size() == 0 &&dtList.size() == 0)) {
  376. monthList.add(devDate);
  377. }
  378. if (month == 12){
  379. year++;
  380. month = 1;
  381. }else {
  382. month ++;
  383. }
  384. }
  385. for (int i = 0; i < 10; i++) {
  386. if (String.valueOf(ccList.get(0)).equals("0") && String.valueOf(dzsbList.get(0)).equals("0") && String.valueOf(dtList.get(0)).equals("0")) {
  387. ccList.remove(0);
  388. dzsbList.remove(0);
  389. dtList.remove(0);
  390. monthList.remove(0);
  391. }else {
  392. break;
  393. }
  394. }
  395. Map<String, Object> devData = new HashMap<String, Object>();
  396. devData.put("monthList" , monthList.toArray());
  397. devData.put("ccList" , ccList.toArray());
  398. devData.put("dzsbList" , dzsbList.toArray());
  399. devData.put("dtList" , dtList.toArray());
  400. Map<String, Object> res = new HashMap<String, Object>();
  401. res.put("otherDevData" ,devData);
  402. return AjaxResult.success(res);
  403. }
  404. /**
  405. * 首页申请数据
  406. */
  407. @RequestMapping(value = "finishApproveData")
  408. public AjaxResult finishApproveData(@RequestBody Map<String, Object> params) {
  409. Calendar now = Calendar.getInstance();
  410. int year = now.get(Calendar.YEAR);
  411. params.put("year",year);
  412. List<ApproveData> list =tApproveService.approveData(params);
  413. return AjaxResult.success(list);
  414. }
  415. /**
  416. * 数据
  417. */
  418. @RequestMapping(value = "devYlrqSafeData")
  419. public AjaxResult devYlrqSafeData(@RequestBody Map<String, Object> params) {
  420. List plantIds = (List) params.get("plantIds");
  421. List unitIds = (List) params.get("unitIds");
  422. int safe1 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  423. .eq("STATUS" , 1)
  424. .eq("del_flag" , 0)
  425. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  426. .in("plant_code",plantIds)
  427. .in("safe_class","1","1级","1.0")
  428. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  429. );
  430. int safe2 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  431. .eq("STATUS" , 1)
  432. .eq("del_flag" , 0)
  433. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  434. .in("plant_code",plantIds)
  435. .in("safe_class","2","2级","2.0")
  436. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  437. );
  438. int safe3 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  439. .eq("STATUS" , 1)
  440. .eq("del_flag" , 0)
  441. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  442. .in("plant_code",plantIds)
  443. .in("safe_class","3","3级","3.0")
  444. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  445. );
  446. int safe4 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  447. .eq("STATUS" , 1)
  448. .eq("del_flag" , 0)
  449. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  450. .in("plant_code",plantIds)
  451. .in("safe_class","4","4级","4.0")
  452. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  453. );
  454. int safe5 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  455. .eq("STATUS" , 1)
  456. .eq("del_flag" , 0)
  457. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  458. .in("plant_code",plantIds)
  459. .in("safe_class","5","5","5.0")
  460. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  461. );
  462. int safeall = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  463. .eq("STATUS" , 1)
  464. .eq("del_flag" , 0)
  465. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  466. .in("plant_code",plantIds)
  467. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  468. );
  469. int safeNa = safeall - safe1 - safe2- safe3- safe4 - safe5;
  470. List safeList = new ArrayList();
  471. safeList.add(safe1);
  472. safeList.add(safe2);
  473. safeList.add(safe3);
  474. safeList.add(safe4);
  475. safeList.add(safe5);
  476. safeList.add(safeNa);
  477. Map<String, Object> res = new HashMap<String, Object>();
  478. res.put("safeData", safeList);
  479. return AjaxResult.success(res);
  480. }
  481. /**
  482. * 数据
  483. */
  484. @RequestMapping(value = "devYlgdSafeData")
  485. public AjaxResult devYlgdSafeData(@RequestBody Map<String, Object> params) {
  486. List plantIds = (List) params.get("plantIds");
  487. List unitIds = (List) params.get("unitIds");
  488. int safe1 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  489. .eq("STATUS" , 1)
  490. .eq("del_flag" , 0)
  491. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  492. .in("plant_code",plantIds)
  493. .in("safe_class","1","1级","1.0")
  494. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  495. );
  496. int safe2 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  497. .eq("STATUS" , 1)
  498. .eq("del_flag" , 0)
  499. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  500. .in("plant_code",plantIds)
  501. .in("safe_class","2","2级","2.0")
  502. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  503. );
  504. int safe3 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  505. .eq("STATUS" , 1)
  506. .eq("del_flag" , 0)
  507. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  508. .in("plant_code",plantIds)
  509. .in("safe_class","3","3级","3.0")
  510. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  511. );
  512. int safe4 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  513. .eq("STATUS" , 1)
  514. .eq("del_flag" , 0)
  515. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  516. .in("plant_code",plantIds)
  517. .in("safe_class","4","4级","4.0")
  518. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  519. );
  520. int safeall = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  521. .eq("STATUS" , 1)
  522. .eq("del_flag" , 0)
  523. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  524. .in("plant_code",plantIds)
  525. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  526. );
  527. int safeNa = safeall - safe1 - safe2- safe3- safe4;
  528. List safeList = new ArrayList();
  529. safeList.add(safe1);
  530. safeList.add(safe2);
  531. safeList.add(safe3);
  532. safeList.add(safe4);
  533. safeList.add(safeNa);
  534. Map<String, Object> res = new HashMap<String, Object>();
  535. res.put("safeData", safeList);
  536. return AjaxResult.success(res);
  537. }
  538. /**
  539. * 锅炉数据
  540. */
  541. @RequestMapping(value = "devGlPerData")
  542. public AjaxResult devGlPerData(@RequestBody Map<String, Object> params) {
  543. List plantIds = (List) params.get("plantIds");
  544. List unitIds = (List) params.get("unitIds");
  545. int all = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  546. .eq("STATUS" , 1)
  547. .eq("del_flag" , 0)
  548. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  549. .in("plant_code",plantIds)
  550. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  551. );
  552. int cc = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  553. .eq("STATUS" , 1)
  554. .eq("del_flag" , 0)
  555. .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  556. .in("plant_code",plantIds)
  557. .in("CHECK_CONCLUSION","符合要求","允许运行")
  558. .and(unitIds.size()>0 ,j -> j.in("unit",unitIds).or().in("plant_code",unitIds))
  559. );
  560. logger.info(all + ":::::::::::" +cc);
  561. String per = new BigDecimal(cc).multiply(new BigDecimal(100)).divide(new BigDecimal(all) ,2, BigDecimal.ROUND_HALF_UP).setScale(1,BigDecimal.ROUND_HALF_DOWN).toString();
  562. Map<String, Object> res = new HashMap<String, Object>();
  563. res.put("per" , per);
  564. return AjaxResult.success(res);
  565. }
  566. /**
  567. * 申请中数据
  568. */
  569. @RequestMapping(value = "devApproveData")
  570. public AjaxResult devApproveData(@RequestBody Map<String, Object> params) {
  571. List plantIds = (List) params.get("plantIds");
  572. List unitIds = (List) params.get("unitIds");
  573. List<String> info = new ArrayList<>();
  574. List<SysDictData> approveStatus = iSysDictTypeService.selectDictDataByType("spec_approve_status");
  575. //压力容器申请
  576. List<TSpecdevYlrq> ylrqList = tSpecdevYlrqService.list(new QueryWrapper<TSpecdevYlrq>()
  577. .notIn("APPROVE_STATUS" , 0)
  578. .in("plant_code",plantIds)
  579. .eq("del_flag" , 0)
  580. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  581. );
  582. if (ylrqList!= null){
  583. for (TSpecdevYlrq t: ylrqList
  584. ) {
  585. String as ="";
  586. for (SysDictData p : approveStatus) {
  587. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  588. as = p.getDictLabel();
  589. }
  590. }
  591. info.add("压力容器:" + t.getDevname() + "-" + as);
  592. }
  593. }
  594. //压力管道申请
  595. List<TSpecdevYlgd> ylgdList = tSpecdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
  596. .notIn("APPROVE_STATUS" , 0)
  597. .in("plant_code",plantIds)
  598. .eq("del_flag" , 0)
  599. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  600. );
  601. if (ylgdList!= null){
  602. for (TSpecdevYlgd t: ylgdList
  603. ) {
  604. String as ="";
  605. for (SysDictData p : approveStatus) {
  606. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  607. as = p.getDictLabel();
  608. }
  609. }
  610. info.add("压力管道:" + t.getDevname() + "-" + as);
  611. }
  612. }
  613. //锅炉申请
  614. List<TSpecdevGl> GlList = tSpecdevGlService.list(new QueryWrapper<TSpecdevGl>()
  615. .notIn("APPROVE_STATUS" , 0)
  616. .in("plant_code",plantIds)
  617. .eq("del_flag" , 0)
  618. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  619. );
  620. if (GlList!= null){
  621. for (TSpecdevGl t: GlList
  622. ) {
  623. String as ="";
  624. for (SysDictData p : approveStatus) {
  625. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  626. as = p.getDictLabel();
  627. }
  628. }
  629. info.add("锅炉:" + t.getDevname() + "-" + as);
  630. }
  631. }
  632. //起重机械申请
  633. List<TSpecdevDzsb> dzsbList = tSpecdevDzsbService.list(new QueryWrapper<TSpecdevDzsb>()
  634. .notIn("APPROVE_STATUS" , 0)
  635. .in("plant_code",plantIds)
  636. .eq("del_flag" , 0)
  637. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  638. );
  639. if (dzsbList!= null){
  640. for (TSpecdevDzsb t: dzsbList
  641. ) {
  642. String as ="";
  643. for (SysDictData p : approveStatus) {
  644. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  645. as = p.getDictLabel();
  646. }
  647. }
  648. info.add("起重机械:" + t.getDevname() + "-" + as);
  649. }
  650. }
  651. //电梯申请t
  652. List<TSpecdevDt> dtList = tSpecdevDtService.list(new QueryWrapper<TSpecdevDt>()
  653. .notIn("APPROVE_STATUS" , 0)
  654. .in("plant_code",plantIds)
  655. .eq("del_flag" , 0)
  656. .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  657. );
  658. if (dtList!= null){
  659. for (TSpecdevDt t: dtList
  660. ) {
  661. String as ="";
  662. for (SysDictData p : approveStatus) {
  663. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  664. as = p.getDictLabel();
  665. }
  666. }
  667. info.add("电梯:" + t.getDevname() + "-" + as);
  668. }
  669. }
  670. //叉车申请t
  671. List<TSpecdevCc> ccList = tSpecdevCcService.list(new QueryWrapper<TSpecdevCc>()
  672. .notIn("APPROVE_STATUS" , 0)
  673. .in("plant_code",plantIds)
  674. .eq("del_flag" , 0)
  675. );
  676. if (ccList!= null){
  677. for (TSpecdevCc t: ccList
  678. ) {
  679. String as ="";
  680. for (SysDictData p : approveStatus) {
  681. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  682. as = p.getDictLabel();
  683. }
  684. }
  685. info.add("叉车:" + t.getDevname() + "-" + as);
  686. }
  687. }
  688. return AjaxResult.success(info);
  689. }
  690. }