SpecHomeController.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  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.DecimalFormat;
  43. import java.text.SimpleDateFormat;
  44. import java.util.*;
  45. /**
  46. * 特种设备申请Controller
  47. *
  48. * @author ruoyi
  49. * @date 2021-08-05
  50. */
  51. @RestController
  52. @RequestMapping("/sems/home")
  53. public class SpecHomeController extends BaseController
  54. {
  55. @Autowired
  56. private ITApproveService tApproveService;
  57. @Autowired
  58. private RuntimeService runtimeService;
  59. @Autowired
  60. private HistoryService historyService;
  61. @Autowired
  62. private TaskService taskService;
  63. @Autowired
  64. private ITSpecdevDtService tSpecdevDtService;
  65. @Autowired
  66. private ITSpecdevDzsbService tSpecdevDzsbService;
  67. @Autowired
  68. private ITSpecdevGlService tSpecdevGlService;
  69. @Autowired
  70. private ITSpecdevYlgdService tSpecdevYlgdService;
  71. @Autowired
  72. private ITSpecdevYlrqService tSpecdevYlrqService;
  73. @Autowired
  74. private ITSpecdevCcService tSpecdevCcService;
  75. @Autowired
  76. private ITApproverFileService tApproverFileService;
  77. @Autowired
  78. private ISysUserService sysUserService;
  79. @Autowired
  80. private ISysPlantService sysPlantService;
  81. @Autowired
  82. private ISysDictTypeService iSysDictTypeService;
  83. /**
  84. * 查询装置管理列表
  85. */
  86. @GetMapping("/plantList")
  87. public AjaxResult list(SysPlant sysPlant)
  88. {
  89. List<SysPlant> list = sysPlantService.selectSysPlantList(sysPlant);
  90. return AjaxResult.success(list);
  91. }
  92. /**
  93. * 首页数据
  94. */
  95. @RequestMapping(value = "devData")
  96. public AjaxResult homeData(@RequestBody Map<String, Object> params) {
  97. logger.info(JSON.toJSONString(params));
  98. List plantIds = (List) params.get("plantIds");
  99. List unitIds = (List) params.get("unitIds");
  100. if (unitIds.size() ==0) {
  101. unitIds.add("");
  102. }
  103. //压力管道
  104. int ylgdAll = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  105. .in("plant_code",plantIds)
  106. // .in("unit",unitIds)
  107. .eq("STATUS" , 1)
  108. .eq("del_flag" , 0)
  109. );
  110. //查询管道长度
  111. List<TSpecdevYlgd> gdList = tSpecdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
  112. .eq("STATUS" , 1)
  113. .eq("del_flag" , 0)
  114. .in("plant_code",plantIds)
  115. // .in("unit",unitIds)
  116. // .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  117. // .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
  118. );
  119. double allLength = 0;
  120. for (int i = 0; i < gdList.size(); i++) {
  121. double gdLength = 0;
  122. if (!StringUtils.isBlank(gdList.get(i).getLength())) {
  123. if (gdList.get(i).getLength().indexOf("\n") > -1) {
  124. String[] arr = gdList.get(i).getLength().split("\n");
  125. logger.info(JSON.toJSONString(arr));
  126. for (int j = 0; j < arr.length; j++) {
  127. try {
  128. gdLength += Double.parseDouble(arr[j]);
  129. }catch (NumberFormatException e) {
  130. logger.error(JSON.toJSONString(e));
  131. continue;
  132. }
  133. }
  134. }else {
  135. try {
  136. gdLength = Double.parseDouble(gdList.get(i).getLength());
  137. }catch (NumberFormatException e) {
  138. logger.error(JSON.toJSONString(e));
  139. }
  140. }
  141. }
  142. allLength += gdLength;
  143. }
  144. DecimalFormat df = new DecimalFormat("#");
  145. System.out.println(df.format(allLength));
  146. Map<String, Object> mapylgd = new HashMap<String, Object>();
  147. mapylgd.put("ylgdAll_num", ylgdAll);
  148. mapylgd.put("ylgd_length", df.format(allLength));
  149. //压力容器
  150. int ylrqAll = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  151. .eq("STATUS" , 1)
  152. .eq("del_flag" , 0)
  153. .in("plant_code",plantIds)
  154. // .in("unit",unitIds)
  155. // .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  156. // .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds).or().isNull("unit"))
  157. );
  158. Map<String, Object> mapylrq = new HashMap<String, Object>();
  159. mapylrq.put("ylrqAll_num", ylrqAll);
  160. //锅炉
  161. int glAll = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  162. .eq("STATUS" , 1)
  163. .eq("del_flag" , 0)
  164. .in("plant_code",plantIds)
  165. // .in("unit",unitIds)
  166. // .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  167. // .and(unitIds.size()>0 ,i -> i.in("unit",unitIds).or().in("plant_code",unitIds))
  168. );
  169. Map<String, Object> mapgl = new HashMap<String, Object>();
  170. mapgl.put("glAll_num", glAll);
  171. //电梯
  172. int dtAll = tSpecdevDtService.count(new QueryWrapper<TSpecdevDt>()
  173. .eq("STATUS" , 1)
  174. .eq("del_flag" , 0)
  175. .in("plant_code",plantIds)
  176. // .in("unit",unitIds)
  177. );
  178. Map<String, Object> mapdt = new HashMap<String, Object>();
  179. mapdt.put("dtAll_num", dtAll);
  180. //吊装设备
  181. int dzsbAll = tSpecdevDzsbService.count(new QueryWrapper<TSpecdevDzsb>()
  182. .eq("STATUS" , 1)
  183. .eq("del_flag" , 0)
  184. .in("plant_code",plantIds)
  185. // .in("unit",unitIds)
  186. .like("CHECK_STRATEGY","强制")
  187. );
  188. int dzsbUn = tSpecdevDzsbService.count(new QueryWrapper<TSpecdevDzsb>()
  189. .eq("STATUS" , 1)
  190. .eq("del_flag" , 0)
  191. .in("plant_code",plantIds)
  192. // .in("unit",unitIds)
  193. .notLike("CHECK_STRATEGY","强制")
  194. );
  195. Map<String, Object> mapdzsb = new HashMap<String, Object>();
  196. mapdzsb.put("dzsbAll_num", dzsbAll);
  197. mapdzsb.put("dzsbUn_num", dzsbUn);
  198. //叉车
  199. int ccAll = tSpecdevCcService.count(new QueryWrapper<TSpecdevCc>()
  200. .eq("STATUS" , 1)
  201. .eq("del_flag" , 0)
  202. .in("plant_code",plantIds)
  203. // .in("unit",unitIds)
  204. );
  205. Map<String, Object> mapcc = new HashMap<String, Object>();
  206. mapcc.put("ccAll_num", ccAll);
  207. Map<String, Object> res = new HashMap<String, Object>();
  208. res.put("ylgdData", mapylgd);
  209. res.put("ylrqData", mapylrq);
  210. res.put("dtData", mapdt);
  211. res.put("dzsbData", mapdzsb);
  212. res.put("glData", mapgl);
  213. res.put("ccData" , mapcc);
  214. return AjaxResult.success(res);
  215. }
  216. /**
  217. * 压力容器数据
  218. */
  219. @RequestMapping(value = "devYlrqData")
  220. public AjaxResult devYlrqData(@RequestBody Map<String, Object> params) {
  221. List plantIds = (List) params.get("plantIds");
  222. List unitIds = (List) params.get("unitIds");
  223. Calendar now = Calendar.getInstance();
  224. int year = now.get(Calendar.YEAR);
  225. Map<String, Object> ylrqData = new HashMap<String, Object>();
  226. List yearList = new ArrayList();
  227. List countList = new ArrayList();
  228. String applySql = "to_char(NEXT_WARN_DATE,'yyyy') = {0}";
  229. for (int j = 0; j < 5; j++) {
  230. int num = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  231. .eq("STATUS" , 1)
  232. .eq("del_flag" , 0)
  233. .apply(true,applySql,year)
  234. .in("plant_code",plantIds)
  235. // .in("unit",unitIds)
  236. );
  237. yearList.add(year);
  238. countList.add(num);
  239. year++;
  240. }
  241. ylrqData.put("yearList" , yearList.toArray());
  242. ylrqData.put("countList" , countList.toArray());
  243. Map<String, Object> res = new HashMap<String, Object>();
  244. res.put("ylrqData" , ylrqData);
  245. return AjaxResult.success(res);
  246. }
  247. /**
  248. * 压力容器数据
  249. */
  250. @GetMapping("/devYlrqDataByYear")
  251. public TableDataInfo devYlrqDataByYear(TSpecdevYlrq tSpecdevYlrq) {
  252. startPage();
  253. List<TSpecdevYlrq> list = tSpecdevYlrqService.selectTSpecdevYlrqListByYear(tSpecdevYlrq);
  254. return getDataTable(list);
  255. }
  256. /**
  257. * 导出特种设备压力容器台账列表
  258. */
  259. @GetMapping("/exportYlrq")
  260. public AjaxResult export(TSpecdevYlrq tSpecdevYlrq)
  261. {
  262. List<TSpecdevYlrq> list = tSpecdevYlrqService.selectTSpecdevYlrqListByYear(tSpecdevYlrq);
  263. ExcelUtil<TSpecdevYlrq> util = new ExcelUtil<TSpecdevYlrq>(TSpecdevYlrq.class);
  264. return util.exportExcel(list, "specYlrq");
  265. }
  266. /**
  267. * 导出特种设备压力管道台账列表
  268. */
  269. @GetMapping("/exportYlgd")
  270. public AjaxResult export(TSpecdevYlgd tSpecdevYlgd) {
  271. List<TSpecdevYlgd> list = tSpecdevYlgdService.selectTSpecdevYlgdListByYear(tSpecdevYlgd);
  272. ExcelUtil<TSpecdevYlgd> util = new ExcelUtil<TSpecdevYlgd>(TSpecdevYlgd.class);
  273. return util.exportExcel(list, "specYlgd");
  274. }
  275. /**
  276. * 导出特种设备锅炉台账列表
  277. */
  278. @GetMapping("/exportGl")
  279. public AjaxResult export(TSpecdevGl tSpecdevGl)
  280. {
  281. List<TSpecdevGl> list = tSpecdevGlService.selectTSpecdevGlListByYear(tSpecdevGl);
  282. ExcelUtil<TSpecdevGl> util = new ExcelUtil<TSpecdevGl>(TSpecdevGl.class);
  283. return util.exportExcel(list, "specGl");
  284. }
  285. /**
  286. * 导出特种设备电梯台账列表
  287. */
  288. @GetMapping("/exportDt")
  289. public AjaxResult export(TSpecdevDt tSpecdevDt)
  290. {
  291. List<TSpecdevDt> list = tSpecdevDtService.selectTSpecdevDtListByYear(tSpecdevDt);
  292. ExcelUtil<TSpecdevDt> util = new ExcelUtil<TSpecdevDt>(TSpecdevDt.class);
  293. return util.exportExcel(list, "specDt");
  294. }
  295. /**
  296. * 导出特种设备吊装设备台账列表
  297. */
  298. @GetMapping("/exportDzsb")
  299. public AjaxResult export(TSpecdevDzsb tSpecdevDzsb)
  300. {
  301. List<TSpecdevDzsb> list = tSpecdevDzsbService.selectTSpecdevDzsbListByYear(tSpecdevDzsb);
  302. ExcelUtil<TSpecdevDzsb> util = new ExcelUtil<TSpecdevDzsb>(TSpecdevDzsb.class);
  303. return util.exportExcel(list, "specDzsb");
  304. }
  305. /**
  306. * 导出特种设备叉车台账列表
  307. */
  308. @GetMapping("/exportCc")
  309. public AjaxResult export(TSpecdevCc tSpecdevCc)
  310. {
  311. List<TSpecdevCc> list = tSpecdevCcService.selectTSpecdevCcListByYear(tSpecdevCc);
  312. ExcelUtil<TSpecdevCc> util = new ExcelUtil<TSpecdevCc>(TSpecdevCc.class);
  313. return util.exportExcel(list, "specCc");
  314. }
  315. /**
  316. * 锅炉数据
  317. */
  318. @RequestMapping(value = "devGlData")
  319. public AjaxResult devGlData(@RequestBody Map<String, Object> params) {
  320. List plantIds = (List) params.get("plantIds");
  321. List unitIds = (List) params.get("unitIds");
  322. Calendar now = Calendar.getInstance();
  323. int year = now.get(Calendar.YEAR);
  324. Map<String, Object> GlData = new HashMap<String, Object>();
  325. //内检
  326. List yearList = new ArrayList();
  327. List countList = new ArrayList();
  328. String applySql = "to_char(NEXT_WARN_DATE,'yyyy') = {0}";
  329. for (int i = 0; i < 5; i++) {
  330. int num = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  331. .eq("STATUS" , 1)
  332. .eq("del_flag" , 0)
  333. .apply(true,applySql,year)
  334. .in("plant_code",plantIds)
  335. );
  336. yearList.add(year);
  337. countList.add(num);
  338. year++;
  339. }
  340. //外检
  341. List yearList2 = new ArrayList();
  342. List countList2 = new ArrayList();
  343. year = now.get(Calendar.YEAR);
  344. String applySql2 = "to_char(OUT_NEXT_WARN_DATE,'yyyy') = {0}";
  345. for (int i = 0; i < 5; i++) {
  346. int num = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  347. .eq("STATUS" , 1)
  348. .eq("del_flag" , 0)
  349. .apply(true,applySql2,year)
  350. .in("plant_code",plantIds)
  351. );
  352. yearList2.add(year);
  353. countList2.add(num);
  354. year++;
  355. }
  356. GlData.put("yearList" , yearList.toArray());
  357. GlData.put("countList" , countList.toArray());
  358. GlData.put("yearList2" , yearList2.toArray());
  359. GlData.put("countList2" , countList2.toArray());
  360. Map<String, Object> res = new HashMap<String, Object>();
  361. res.put("GlData" , GlData);
  362. return AjaxResult.success(res);
  363. }
  364. /**
  365. * guolu
  366. */
  367. @GetMapping("/devGlDataByYear")
  368. public TableDataInfo devGlDataByYear(TSpecdevGl tSpecdevGl) {
  369. startPage();
  370. List<TSpecdevGl> list = tSpecdevGlService.selectTSpecdevGlListByYear(tSpecdevGl);
  371. return getDataTable(list);
  372. }
  373. /**
  374. * 压力管道数据
  375. */
  376. @RequestMapping(value = "devYlgdData")
  377. public AjaxResult devYlgdData(@RequestBody Map<String, Object> params) {
  378. List plantIds = (List) params.get("plantIds");
  379. List unitIds = (List) params.get("unitIds");
  380. Calendar now = Calendar.getInstance();
  381. int year = now.get(Calendar.YEAR);
  382. Map<String, Object> ylrqData = new HashMap<String, Object>();
  383. List yearList = new ArrayList();
  384. List countList = new ArrayList();
  385. String applySql = "to_char(NEXT_WARN_DATE,'yyyy') = {0}";
  386. for (int i = 0; i < 5; i++) {
  387. int num = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  388. .eq("STATUS" , 1)
  389. .eq("del_flag" , 0)
  390. // .eq(!StringUtils.isBlank((String)params.get("plantName")) , "plant_code" ,params.get("plantName"))
  391. .apply(true,applySql,year)
  392. .in("plant_code",plantIds)
  393. );
  394. yearList.add(year);
  395. countList.add(num);
  396. year++;
  397. }
  398. ylrqData.put("yearList" , yearList.toArray());
  399. ylrqData.put("countList" , countList.toArray());
  400. Map<String, Object> res = new HashMap<String, Object>();
  401. res.put("ylrqData" , ylrqData);
  402. return AjaxResult.success(res);
  403. }
  404. /**
  405. * 压力容器数据
  406. */
  407. @GetMapping("/devYlgdDataByYear")
  408. public TableDataInfo devYlgdDataByYear(TSpecdevYlgd tSpecdevYlgd) {
  409. startPage();
  410. List<TSpecdevYlgd> list = tSpecdevYlgdService.selectTSpecdevYlgdListByYear(tSpecdevYlgd);
  411. return getDataTable(list);
  412. }
  413. /**
  414. * 压力容器数据
  415. */
  416. @GetMapping("/devDzsbDataByYear")
  417. public TableDataInfo devDzsbDataByYear(TSpecdevDzsb tSpecdevDzsb) {
  418. startPage();
  419. List<TSpecdevDzsb> list = tSpecdevDzsbService.selectTSpecdevDzsbListByYear(tSpecdevDzsb);
  420. return getDataTable(list);
  421. }
  422. /**
  423. * 压力容器数据
  424. */
  425. @GetMapping("/devCcDataByYear")
  426. public TableDataInfo devCcDataByYear(TSpecdevCc tSpecdevCc) {
  427. startPage();
  428. List<TSpecdevCc> list = tSpecdevCcService.selectTSpecdevCcListByYear(tSpecdevCc);
  429. return getDataTable(list);
  430. }
  431. /**
  432. * 压力容器数据
  433. */
  434. @GetMapping("/devDtDataByYear")
  435. public TableDataInfo devDtDataByYear(TSpecdevDt tSpecdevDt) {
  436. startPage();
  437. List<TSpecdevDt> list = tSpecdevDtService.selectTSpecdevDtListByYear(tSpecdevDt);
  438. return getDataTable(list);
  439. }
  440. /**
  441. * 压力管道数据
  442. */
  443. @RequestMapping(value = "devOtherData")
  444. public AjaxResult devOtherData(@RequestBody Map<String, Object> params) {
  445. Calendar now = Calendar.getInstance();
  446. int year = now.get(Calendar.YEAR);
  447. int month = now.get(Calendar.MONTH) + 1;
  448. List<DevData> listcc = tSpecdevCcService.otherDevCount(params);
  449. List<DevData> listdzsb = tSpecdevDzsbService.otherDevCount(params);
  450. List<DevData> listdt = tSpecdevDtService.otherDevCount(params);
  451. List ccList = new ArrayList();
  452. List dzsbList = new ArrayList();
  453. List dtList = new ArrayList();
  454. List monthList = new ArrayList();
  455. for (int i = 0; i < 24; i++) {
  456. String devDate = year + String.valueOf(month);
  457. if (month < 10){
  458. devDate = year + "0" +String.valueOf(month);
  459. }
  460. boolean flag = true;
  461. for (DevData d: listcc
  462. ) {
  463. flag = true;
  464. if (devDate.equals(d.getYearM())){
  465. ccList.add(d.getNum());
  466. flag = false;
  467. break;
  468. }
  469. }
  470. if (flag == true) {
  471. ccList.add(0);
  472. }
  473. for (DevData d: listdzsb
  474. ) {
  475. flag = true;
  476. if (devDate.equals(d.getYearM())){
  477. dzsbList.add(d.getNum());
  478. flag = false;
  479. break;
  480. }
  481. }
  482. if (flag == true) {
  483. dzsbList.add(0);
  484. }
  485. for (DevData d: listdt
  486. ) {
  487. flag = true;
  488. if (devDate.equals(d.getYearM())){
  489. dtList.add(d.getNum());
  490. flag = false;
  491. break;
  492. }
  493. }
  494. if (flag == true) {
  495. dtList.add(0);
  496. }
  497. if (!(ccList.size() == 0 && dzsbList.size() == 0 &&dtList.size() == 0)) {
  498. monthList.add(devDate);
  499. }
  500. if (month == 12){
  501. year++;
  502. month = 1;
  503. }else {
  504. month ++;
  505. }
  506. }
  507. for (int i = 0; i < 10; i++) {
  508. if (String.valueOf(ccList.get(0)).equals("0") && String.valueOf(dzsbList.get(0)).equals("0") && String.valueOf(dtList.get(0)).equals("0")) {
  509. ccList.remove(0);
  510. dzsbList.remove(0);
  511. dtList.remove(0);
  512. monthList.remove(0);
  513. }else {
  514. break;
  515. }
  516. }
  517. Map<String, Object> devData = new HashMap<String, Object>();
  518. devData.put("monthList" , monthList.toArray());
  519. devData.put("ccList" , ccList.toArray());
  520. devData.put("dzsbList" , dzsbList.toArray());
  521. devData.put("dtList" , dtList.toArray());
  522. Map<String, Object> res = new HashMap<String, Object>();
  523. res.put("otherDevData" ,devData);
  524. return AjaxResult.success(res);
  525. }
  526. /**
  527. * 首页申请数据
  528. */
  529. @RequestMapping(value = "finishApproveData")
  530. public AjaxResult finishApproveData(@RequestBody Map<String, Object> params) {
  531. Calendar now = Calendar.getInstance();
  532. int year = now.get(Calendar.YEAR);
  533. params.put("year",year);
  534. List<ApproveData> list =tApproveService.approveData(params);
  535. return AjaxResult.success(list);
  536. }
  537. /**
  538. * 数据
  539. */
  540. @RequestMapping(value = "devYlrqSafeData")
  541. public AjaxResult devYlrqSafeData(@RequestBody Map<String, Object> params) {
  542. List plantIds = (List) params.get("plantIds");
  543. List unitIds = (List) params.get("unitIds");
  544. int safe1 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  545. .eq("STATUS" , 1)
  546. .eq("del_flag" , 0)
  547. .in("plant_code",plantIds)
  548. .in("safe_class","1","1级","1.0","一级","Ⅰ级")
  549. );
  550. int safe2 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  551. .eq("STATUS" , 1)
  552. .eq("del_flag" , 0)
  553. .in("plant_code",plantIds)
  554. .in("safe_class","2","2级","2.0","二级","Ⅱ级")
  555. );
  556. int safe3 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  557. .eq("STATUS" , 1)
  558. .eq("del_flag" , 0)
  559. .in("plant_code",plantIds)
  560. .in("safe_class","3","3级","3.0","三级","Ⅲ级")
  561. );
  562. int safe4 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  563. .eq("STATUS" , 1)
  564. .eq("del_flag" , 0)
  565. .in("plant_code",plantIds)
  566. .in("safe_class","4","4级","4.0","四级","Ⅳ级")
  567. );
  568. int safe5 = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  569. .eq("STATUS" , 1)
  570. .eq("del_flag" , 0)
  571. .in("plant_code",plantIds)
  572. .in("safe_class","5","5级","5.0","五级","Ⅴ级")
  573. );
  574. int safeall = tSpecdevYlrqService.count(new QueryWrapper<TSpecdevYlrq>()
  575. .eq("STATUS" , 1)
  576. .eq("del_flag" , 0)
  577. .in("plant_code",plantIds)
  578. );
  579. int safeNa = safeall - safe1 - safe2- safe3- safe4 - safe5;
  580. List safeList = new ArrayList();
  581. safeList.add(safe1);
  582. safeList.add(safe2);
  583. safeList.add(safe3);
  584. safeList.add(safe4);
  585. safeList.add(safe5);
  586. safeList.add(safeNa);
  587. Map<String, Object> res = new HashMap<String, Object>();
  588. res.put("safeData", safeList);
  589. return AjaxResult.success(res);
  590. }
  591. /**
  592. * 数据
  593. */
  594. @RequestMapping(value = "devYlgdSafeData")
  595. public AjaxResult devYlgdSafeData(@RequestBody Map<String, Object> params) {
  596. List plantIds = (List) params.get("plantIds");
  597. List unitIds = (List) params.get("unitIds");
  598. int safe1 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  599. .eq("STATUS" , 1)
  600. .eq("del_flag" , 0)
  601. .in("plant_code",plantIds)
  602. .in("safe_class","1","1级","1.0","一级","Ⅰ级")
  603. );
  604. int safe2 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  605. .eq("STATUS" , 1)
  606. .eq("del_flag" , 0)
  607. .in("plant_code",plantIds)
  608. .in("safe_class","2","2级","2.0","二级","Ⅱ级")
  609. );
  610. int safe3 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  611. .eq("STATUS" , 1)
  612. .eq("del_flag" , 0)
  613. .in("plant_code",plantIds)
  614. .in("safe_class","3","3级","3.0","三级","Ⅲ级")
  615. );
  616. int safe4 = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  617. .eq("STATUS" , 1)
  618. .eq("del_flag" , 0)
  619. .in("plant_code",plantIds)
  620. .in("safe_class","4","4级","4.0","四级","Ⅳ级")
  621. );
  622. int safeall = tSpecdevYlgdService.count(new QueryWrapper<TSpecdevYlgd>()
  623. .eq("STATUS" , 1)
  624. .eq("del_flag" , 0)
  625. .in("plant_code",plantIds)
  626. );
  627. int safeNa = safeall - safe1 - safe2- safe3- safe4;
  628. List safeList = new ArrayList();
  629. safeList.add(safe1);
  630. safeList.add(safe2);
  631. safeList.add(safe3);
  632. safeList.add(safe4);
  633. safeList.add(safeNa);
  634. Map<String, Object> res = new HashMap<String, Object>();
  635. res.put("safeData", safeList);
  636. return AjaxResult.success(res);
  637. }
  638. /**
  639. * 锅炉数据
  640. */
  641. @RequestMapping(value = "devGlPerData")
  642. public AjaxResult devGlPerData(@RequestBody Map<String, Object> params) {
  643. List plantIds = (List) params.get("plantIds");
  644. List unitIds = (List) params.get("unitIds");
  645. int all = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  646. .eq("STATUS" , 1)
  647. .eq("del_flag" , 0)
  648. .in("plant_code",plantIds)
  649. );
  650. int cc = tSpecdevGlService.count(new QueryWrapper<TSpecdevGl>()
  651. .eq("STATUS" , 1)
  652. .eq("del_flag" , 0)
  653. .in("plant_code",plantIds)
  654. .in("CHECK_CONCLUSION","符合要求","允许运行")
  655. );
  656. String per = "0";
  657. if (all != 0) {
  658. per = new BigDecimal(cc).multiply(new BigDecimal(100)).divide(new BigDecimal(all), 2, BigDecimal.ROUND_HALF_UP).setScale(1, BigDecimal.ROUND_HALF_DOWN).toString();
  659. }
  660. Map<String, Object> res = new HashMap<String, Object>();
  661. res.put("per" , per);
  662. return AjaxResult.success(res);
  663. }
  664. /**
  665. * 申请中数据
  666. */
  667. @RequestMapping(value = "devApproveData")
  668. public AjaxResult devApproveData(@RequestBody Map<String, Object> params) {
  669. List plantIds = (List) params.get("plantIds");
  670. List unitIds = (List) params.get("unitIds");
  671. List<String> info = new ArrayList<>();
  672. List<SysDictData> approveStatus = iSysDictTypeService.selectDictDataByType("spec_approve_status");
  673. //压力容器申请
  674. List<TSpecdevYlrq> ylrqList = tSpecdevYlrqService.list(new QueryWrapper<TSpecdevYlrq>()
  675. .notIn("APPROVE_STATUS" , 0)
  676. .in("plant_code",plantIds)
  677. .eq("del_flag" , 0)
  678. );
  679. if (ylrqList!= null){
  680. for (TSpecdevYlrq t: ylrqList
  681. ) {
  682. String as ="";
  683. for (SysDictData p : approveStatus) {
  684. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  685. as = p.getDictLabel();
  686. }
  687. }
  688. info.add("压力容器:" + t.getDevname() + "-" + as);
  689. }
  690. }
  691. //压力管道申请
  692. List<TSpecdevYlgd> ylgdList = tSpecdevYlgdService.list(new QueryWrapper<TSpecdevYlgd>()
  693. .notIn("APPROVE_STATUS" , 0)
  694. .in("plant_code",plantIds)
  695. .eq("del_flag" , 0)
  696. );
  697. if (ylgdList!= null){
  698. for (TSpecdevYlgd t: ylgdList
  699. ) {
  700. String as ="";
  701. for (SysDictData p : approveStatus) {
  702. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  703. as = p.getDictLabel();
  704. }
  705. }
  706. info.add("压力管道:" + t.getDevname() + "-" + as);
  707. }
  708. }
  709. //锅炉申请
  710. List<TSpecdevGl> GlList = tSpecdevGlService.list(new QueryWrapper<TSpecdevGl>()
  711. .notIn("APPROVE_STATUS" , 0)
  712. .in("plant_code",plantIds)
  713. .eq("del_flag" , 0)
  714. );
  715. if (GlList!= null){
  716. for (TSpecdevGl t: GlList
  717. ) {
  718. String as ="";
  719. for (SysDictData p : approveStatus) {
  720. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  721. as = p.getDictLabel();
  722. }
  723. }
  724. info.add("锅炉:" + t.getDevname() + "-" + as);
  725. }
  726. }
  727. //起重机械申请
  728. List<TSpecdevDzsb> dzsbList = tSpecdevDzsbService.list(new QueryWrapper<TSpecdevDzsb>()
  729. .notIn("APPROVE_STATUS" , 0)
  730. .in("plant_code",plantIds)
  731. .eq("del_flag" , 0)
  732. );
  733. if (dzsbList!= null){
  734. for (TSpecdevDzsb t: dzsbList
  735. ) {
  736. String as ="";
  737. for (SysDictData p : approveStatus) {
  738. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  739. as = p.getDictLabel();
  740. }
  741. }
  742. info.add("起重机械:" + t.getDevname() + "-" + as);
  743. }
  744. }
  745. //电梯申请t
  746. List<TSpecdevDt> dtList = tSpecdevDtService.list(new QueryWrapper<TSpecdevDt>()
  747. .notIn("APPROVE_STATUS" , 0)
  748. .in("plant_code",plantIds)
  749. .eq("del_flag" , 0)
  750. );
  751. if (dtList!= null){
  752. for (TSpecdevDt t: dtList
  753. ) {
  754. String as ="";
  755. for (SysDictData p : approveStatus) {
  756. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  757. as = p.getDictLabel();
  758. }
  759. }
  760. info.add("电梯:" + t.getDevname() + "-" + as);
  761. }
  762. }
  763. //叉车申请t
  764. List<TSpecdevCc> ccList = tSpecdevCcService.list(new QueryWrapper<TSpecdevCc>()
  765. .notIn("APPROVE_STATUS" , 0)
  766. .in("plant_code",plantIds)
  767. .eq("del_flag" , 0)
  768. );
  769. if (ccList!= null){
  770. for (TSpecdevCc t: ccList
  771. ) {
  772. String as ="";
  773. for (SysDictData p : approveStatus) {
  774. if (p.getDictValue().equals(t.getApproveStatus().toString())) {
  775. as = p.getDictLabel();
  776. }
  777. }
  778. info.add("叉车:" + t.getDevname() + "-" + as);
  779. }
  780. }
  781. return AjaxResult.success(info);
  782. }
  783. }