TSpecdevYlrqController.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. package com.ruoyi.project.sems.controller;
  2. import java.io.FileOutputStream;
  3. import java.io.IOException;
  4. import java.io.OutputStream;
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.List;
  9. import com.alibaba.fastjson.JSON;
  10. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  11. import com.ruoyi.common.thread.SpecDevYlrqThread;
  12. import com.ruoyi.common.thread.SpecOverLifeThead;
  13. import com.ruoyi.common.utils.DateUtils;
  14. import com.ruoyi.common.utils.file.ExcelUtils;
  15. import com.ruoyi.project.sems.domain.ParamData;
  16. import com.ruoyi.project.sems.domain.TSpecCheck;
  17. import com.ruoyi.project.sems.domain.TSpecdevYlgd;
  18. import com.ruoyi.project.sems.service.ITSpecCheckService;
  19. import com.ruoyi.project.system.domain.SysDept;
  20. import com.ruoyi.project.system.domain.SysDictData;
  21. import com.ruoyi.project.system.service.ISysDeptService;
  22. import com.ruoyi.project.system.service.ISysDictTypeService;
  23. import org.apache.commons.lang.StringUtils;
  24. import org.apache.poi.ss.usermodel.*;
  25. import org.apache.poi.xssf.streaming.SXSSFWorkbook;
  26. import org.springframework.security.access.prepost.PreAuthorize;
  27. import org.springframework.beans.factory.annotation.Autowired;
  28. import org.springframework.web.bind.annotation.*;
  29. import com.ruoyi.framework.aspectj.lang.annotation.Log;
  30. import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
  31. import com.ruoyi.project.sems.domain.TSpecdevYlrq;
  32. import com.ruoyi.project.sems.service.ITSpecdevYlrqService;
  33. import com.ruoyi.framework.web.controller.BaseController;
  34. import com.ruoyi.framework.web.domain.AjaxResult;
  35. import com.ruoyi.common.utils.poi.ExcelUtil;
  36. import com.ruoyi.framework.web.page.TableDataInfo;
  37. import org.springframework.web.multipart.MultipartFile;
  38. /**
  39. * 特种设备压力容器台账Controller
  40. *
  41. * @author ruoyi
  42. * @date 2021-06-30
  43. */
  44. @RestController
  45. @RequestMapping("/sems/specYlrq")
  46. public class TSpecdevYlrqController extends BaseController
  47. {
  48. @Autowired
  49. private ITSpecdevYlrqService tSpecdevYlrqService;
  50. @Autowired
  51. private ITSpecCheckService tSpecCheckService;
  52. @Autowired
  53. private ISysDeptService iSysDeptService;
  54. @Autowired
  55. private ISysDictTypeService iSysDictTypeService;
  56. /**
  57. * 查询特种设备压力容器台账列表
  58. */
  59. @PreAuthorize("@ss.hasPermi('sems:specYlrq:list')")
  60. @GetMapping("/list")
  61. public TableDataInfo list(TSpecdevYlrq tSpecdevYlrq)
  62. {
  63. startPage();
  64. List<TSpecdevYlrq> list = tSpecdevYlrqService.selectTSpecdevYlrqList(tSpecdevYlrq);
  65. //
  66. // SpecOverLifeThead specOverLifeThead = new SpecOverLifeThead(tSpecdevYlrqService);
  67. // Thread t = new Thread(specOverLifeThead);
  68. // t.start();
  69. SpecDevYlrqThread specDevYlgdThread = new SpecDevYlrqThread(tSpecdevYlrqService);
  70. Thread t2 = new Thread(specDevYlgdThread);
  71. t2.start();
  72. return getDataTable(list);
  73. }
  74. /**
  75. * 导出特种设备压力容器台账列表
  76. */
  77. @PreAuthorize("@ss.hasPermi('sems:specYlrq:export')")
  78. @Log(title = "特种设备压力容器台账", businessType = BusinessType.EXPORT)
  79. @GetMapping("/export")
  80. public AjaxResult export(TSpecdevYlrq tSpecdevYlrq)
  81. {
  82. List<TSpecdevYlrq> list = tSpecdevYlrqService.selectTSpecdevYlrqList(tSpecdevYlrq);
  83. ExcelUtil<TSpecdevYlrq> util = new ExcelUtil<TSpecdevYlrq>(TSpecdevYlrq.class);
  84. return util.exportExcel(list, "specYlrq");
  85. }
  86. /**
  87. * 获取特种设备压力容器台账详细信息
  88. */
  89. @PreAuthorize("@ss.hasPermi('sems:specYlrq:query')")
  90. @GetMapping(value = "/{id}")
  91. public AjaxResult getInfo(@PathVariable("id") Long id)
  92. {
  93. return AjaxResult.success(tSpecdevYlrqService.selectTSpecdevYlrqById(id));
  94. }
  95. /**
  96. * 新增特种设备压力容器台账
  97. */
  98. @PreAuthorize("@ss.hasPermi('sems:specYlrq:add')")
  99. @Log(title = "特种设备压力容器台账", businessType = BusinessType.INSERT)
  100. @PostMapping
  101. public AjaxResult add(@RequestBody TSpecdevYlrq tSpecdevYlrq)
  102. {
  103. return toAjax(tSpecdevYlrqService.insertTSpecdevYlrq(tSpecdevYlrq));
  104. }
  105. /**
  106. * 修改特种设备压力容器台账
  107. */
  108. @PreAuthorize("@ss.hasPermi('sems:specYlrq:edit')")
  109. @Log(title = "特种设备压力容器台账", businessType = BusinessType.UPDATE)
  110. @PutMapping
  111. public AjaxResult edit(@RequestBody TSpecdevYlrq tSpecdevYlrq)
  112. {
  113. TSpecdevYlrq old = tSpecdevYlrqService.selectTSpecdevYlrqById(tSpecdevYlrq.getId());
  114. if (!old.getReportNo().equals(tSpecdevYlrq.getReportNo())) {
  115. TSpecCheck tc = new TSpecCheck();
  116. tc.setDevType(1l);
  117. tc.setCheckUnit(tSpecdevYlrq.getCheckUnit());
  118. tc.setDevId(tSpecdevYlrq.getId());
  119. tc.setNextWarnDate(tSpecdevYlrq.getNextWarnDate());
  120. tc.setReportNo(tSpecdevYlrq.getReportNo());
  121. tc.setWarnDate(tSpecdevYlrq.getWarnDate());
  122. tc.setYearNextWarnDate(tSpecdevYlrq.getYearNextWarnDate());
  123. tc.setYearWarnDate(tSpecdevYlrq.getYearWarnDate());
  124. tc.setYearReportNo(tSpecdevYlrq.getReportNo());
  125. tc.setSafeClass(tSpecdevYlrq.getSafeClass());
  126. tSpecCheckService.insertTSpecCheck(tc);
  127. }
  128. return toAjax(tSpecdevYlrqService.updateTSpecdevYlrq(tSpecdevYlrq));
  129. }
  130. /**
  131. * 修改特种设备压力容器台账
  132. */
  133. @PreAuthorize("@ss.hasPermi('sems:specYlrq:edit')")
  134. @Log(title = "特种设备压力容器台账", businessType = BusinessType.UPDATE)
  135. @PutMapping("/pre")
  136. public AjaxResult editPre(@RequestBody TSpecdevYlrq tSpecdevYlrq)
  137. {
  138. return toAjax(tSpecdevYlrqService.updateTSpecdevYlrq(tSpecdevYlrq));
  139. }
  140. /**
  141. * 删除特种设备压力容器台账
  142. */
  143. @PreAuthorize("@ss.hasPermi('sems:specYlrq:remove')")
  144. @Log(title = "特种设备压力容器台账", businessType = BusinessType.DELETE)
  145. @DeleteMapping("/{ids}")
  146. public AjaxResult remove(@PathVariable Long[] ids)
  147. {
  148. return toAjax(tSpecdevYlrqService.deleteTSpecdevYlrqByIds(ids));
  149. }
  150. /**
  151. * 去重
  152. */
  153. @PreAuthorize("@ss.hasPermi('sems:plant:remove')")
  154. @GetMapping("/duplicate")
  155. public AjaxResult duplicate()
  156. {
  157. tSpecdevYlrqService.duplicateTSpecdevYlrq();
  158. return AjaxResult.success();
  159. }
  160. /**
  161. * 批量导入
  162. */
  163. @PreAuthorize("@ss.hasPermi('sems:specYlrq:add')")
  164. @Log(title = "特种设备批量导入", businessType = BusinessType.INSERT)
  165. @PostMapping("/importData")
  166. public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException, ParseException {
  167. //获取操作人员ID
  168. Long userId = getUserId();
  169. //报错行数统计
  170. List<Integer> failRow =new ArrayList<Integer>();
  171. Workbook workbook = ExcelUtils.getWorkBook(file);
  172. Sheet sheet = workbook.getSheetAt(0);
  173. List<TSpecdevYlrq> list = new ArrayList<TSpecdevYlrq>();
  174. //字典查询
  175. List<SysDictData> plant = iSysDictTypeService.selectDictDataByType("PLANT_DIVIDE");
  176. //部门查询
  177. List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
  178. int rowNum = sheet.getPhysicalNumberOfRows();
  179. int failNumber = 0;
  180. for (int i = 1; i < rowNum; i++) {
  181. try {
  182. logger.info("读取行数:" + i);
  183. Row row = sheet.getRow(i);
  184. int cellNum = row.getLastCellNum();
  185. TSpecdevYlrq entity = new TSpecdevYlrq();
  186. for (int j = 0; j < cellNum; j++) {
  187. Cell cell = row.getCell(j);
  188. if (cell == null) {
  189. continue;
  190. }
  191. cell.getCellType();
  192. String cellValue = ExcelUtils.getCellValue(cell);
  193. if (StringUtils.trim(cellValue) == ""){
  194. continue;
  195. }
  196. logger.info("cellValue:" + cellValue);
  197. if (j == 0) {
  198. //序号
  199. } else if (j == 1) {
  200. entity.setPlantCode(cellValue);//装置名称
  201. } else if (j == 2) {
  202. entity.setUnit(cellValue);//单元
  203. } else if (j == 3) {
  204. entity.setPlantMaint(cellValue);//装置维修组
  205. } else if (j == 4) {
  206. entity.setEngineer(cellValue);//装置维修工程师
  207. } else if (j == 5) {
  208. entity.setDevno(cellValue);//位号
  209. } else if (j == 6) {
  210. entity.setDevname(cellValue);//设备名称
  211. } else if (j == 7) {
  212. entity.setUseno(cellValue);//使用证编号
  213. } else if (j == 8) {
  214. entity.setRegno(cellValue);//注册编号
  215. } else if (j == 9) {
  216. entity.setVesselType(cellValue);//容器类别
  217. } else if (j == 10) {
  218. entity.setCreateUnit(cellValue);//制造单位
  219. } else if (j == 11) {
  220. entity.setNation(cellValue);//国家
  221. } else if (j == 12) {
  222. entity.setOutSize(cellValue);//外形尺寸
  223. } else if (j == 13) {
  224. entity.setMaterial(cellValue);//材料
  225. } else if (j == 14) {
  226. entity.setMedium(cellValue);//介质
  227. } else if (j == 15) {
  228. entity.setDesPressure(cellValue);//设计压力
  229. } else if (j == 16) {
  230. entity.setOptPressure(cellValue);//操作压力
  231. } else if (j == 17) {
  232. entity.setDesTemp(cellValue);//设计温度
  233. } else if (j == 18) {
  234. entity.setOptTemp(cellValue);//操作温度
  235. } else if (j == 19) {
  236. logger.info("日期格式:" + cellValue);
  237. if (cellValue.length() > 3) {//投用日期
  238. entity.setSubmitdate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  239. }
  240. } else if (j == 20) {
  241. //是否涉危化品
  242. entity.setIsDanger(cellValue);
  243. } else if (j == 21) {
  244. //是否涉危化品
  245. entity.setDesYear(cellValue);
  246. } else if (j == 22) {
  247. //是否超设计使用寿命
  248. entity.setIsOverlife(cellValue);
  249. } else if (j == 23) {
  250. entity.setCheckUnit(cellValue);//检验单位
  251. } else if (j == 24) {
  252. logger.info("日期格式:" + cellValue);
  253. if (cellValue.length() > 3) {//检验日期
  254. entity.setWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  255. }
  256. } else if (j == 25) {
  257. entity.setSafeClass(cellValue);//安全状况等级
  258. } else if (j == 26) {
  259. if (cellValue.length() > 3) {//下次检验日期
  260. entity.setNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  261. }
  262. } else if (j == 27) {
  263. entity.setReportNo(cellValue);//报告编号
  264. } else if (j == 28) {
  265. if (cellValue.length() > 3) {//检验日期
  266. entity.setYearWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  267. }
  268. } else if (j == 29) {
  269. entity.setCheckConclusion(cellValue);//年度结论
  270. } else if (j == 30) {
  271. if (cellValue.length() > 3) {//下次年度检验日期
  272. entity.setYearNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  273. }
  274. } else if (j == 31) {
  275. entity.setYearReportNo(cellValue);//报告编号
  276. } else if (j == 32) {
  277. entity.setRemarks(cellValue);//备注
  278. }/*else if (j == 33) {
  279. for (SysDept d : dept) {
  280. if (d.getDeptName().equals(cellValue)) {
  281. entity.setDeptId(d.getDeptId());//部门编号
  282. }
  283. }
  284. }*/
  285. }
  286. entity.setCreaterCode(userId);
  287. logger.info("entity:" + entity);
  288. list.add(entity);
  289. }catch (Exception e){
  290. failNumber++;
  291. logger.info("e:" + JSON.toJSONString(e));
  292. failRow.add(i + 1);
  293. }
  294. }
  295. int successNumber = 0;
  296. int failNum = 0;
  297. for (TSpecdevYlrq t : list
  298. ) {
  299. failNum++;
  300. try {
  301. tSpecdevYlrqService.insertTSpecdevYlrq(t);
  302. successNumber++;
  303. }catch (Exception e){
  304. failNumber++;
  305. logger.info("e:" + e);
  306. failRow.add(failNum + 1);
  307. }
  308. }
  309. logger.info("list:" + JSON.toJSONString(list));
  310. logger.info("successNumber:" +String.valueOf(successNumber));
  311. logger.info("failNumber:" +String.valueOf(failNumber));
  312. logger.info("failRow:" +String.valueOf(failRow));
  313. return AjaxResult.success(String.valueOf(successNumber), failRow);
  314. }
  315. /**
  316. * 批量导入
  317. * 检验更新功能中的批量导入
  318. */
  319. @PreAuthorize("@ss.hasPermi('sems:specYlrq:add')")
  320. @Log(title = "特种设备批量导入", businessType = BusinessType.INSERT)
  321. @PostMapping("/updateData")
  322. public AjaxResult updateData(@RequestParam("file") MultipartFile file) throws IOException
  323. {
  324. //获取操作人员ID
  325. Long userId = getUserId();
  326. //报错行数统计
  327. List<Integer> failRow =new ArrayList<Integer>();
  328. Workbook workbook = ExcelUtils.getWorkBook(file);
  329. Sheet sheet = workbook.getSheetAt(0);
  330. List<TSpecdevYlrq> list = new ArrayList<TSpecdevYlrq>();
  331. List<TSpecdevYlrq> oldList = new ArrayList<TSpecdevYlrq>();
  332. //字典查询
  333. List<SysDictData> plant = iSysDictTypeService.selectDictDataByType("PLANT_DIVIDE");
  334. //部门查询
  335. List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
  336. int rowNum = sheet.getPhysicalNumberOfRows();
  337. int failNumber = 0;
  338. long devId = 0l;
  339. TSpecdevYlrq oldEntity = new TSpecdevYlrq();
  340. for (int i = 1; i < rowNum; i++) {
  341. try {
  342. logger.info("读取行数:" + i);
  343. Row row = sheet.getRow(i);
  344. int cellNum = row.getLastCellNum();
  345. TSpecdevYlrq entity = new TSpecdevYlrq();
  346. for (int j = 0; j < cellNum; j++) {
  347. Cell cell = row.getCell(j);
  348. if (cell == null) {
  349. continue;
  350. }
  351. String cellValue = ExcelUtils.getCellValue(cell);
  352. logger.info("cellValue:" + cellValue);
  353. if (j == 0) {
  354. //序号
  355. Double d = Double.parseDouble(cellValue);
  356. long s = new Double(d).longValue();
  357. entity.setId(s);
  358. } else if (j == 1) {
  359. entity.setPlantCode(cellValue);//装置名称
  360. } else if (j == 2) {
  361. entity.setDevno(cellValue);//位号
  362. } else if (j == 3) {
  363. entity.setDevname(cellValue);//设备名称
  364. } else if (j == 4) {
  365. entity.setUseno(cellValue);//使用证编号
  366. } else if (j == 5) {
  367. entity.setCheckUnit(cellValue);//检验单位
  368. } else if (j == 6) {
  369. logger.info("日期格式:" + cellValue);
  370. if (cellValue.length() > 3) {//检验日期
  371. entity.setWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  372. }
  373. } else if (j == 7) {
  374. entity.setSafeClass(cellValue);//安全状况等级
  375. } else if (j == 8) {
  376. logger.info("日期格式:" + cellValue);
  377. if (cellValue.length() > 3) {//下次检验日期
  378. entity.setNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  379. }
  380. } else if (j == 9) {
  381. entity.setReportNo(cellValue);//报告编号
  382. } else if (j == 10){ //年度检查日期
  383. logger.info("日期格式:" + cellValue);
  384. if (cellValue.length() > 3) {
  385. entity.setYearWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  386. }
  387. } else if (j == 11){//年度检查结论
  388. entity.setCheckConclusion(cellValue);
  389. } else if (j == 12){//下次年度检查日期
  390. logger.info("日期格式:" + cellValue);
  391. if (cellValue.length() > 3) {
  392. entity.setYearNextWarnDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
  393. }
  394. } else if (j == 13) {//年度检查编号
  395. entity.setYearReportNo(cellValue);
  396. }
  397. }
  398. logger.info("entity:" + entity);
  399. list.add(entity);
  400. oldEntity = entity;
  401. oldList.add(oldEntity);
  402. /*for (TSpecdevYlrq e :list){
  403. e.setId(null);
  404. }*/
  405. }catch (Exception e){
  406. failNumber++;
  407. e.printStackTrace();
  408. logger.info("e:" + JSON.toJSONString(e));
  409. failRow.add(i + 1);
  410. }
  411. }
  412. int successNumber = 0;
  413. int failNum = 0;
  414. for (TSpecdevYlrq t : list
  415. ) {
  416. failNum++;
  417. try {
  418. tSpecdevYlrqService.update(t,
  419. new QueryWrapper<TSpecdevYlrq>().eq("USENO", t.getUseno())
  420. .eq("PLANT_CODE", t.getPlantCode())
  421. .eq("DEVNO" , t.getDevno()));
  422. successNumber++;
  423. }catch (Exception e){
  424. e.printStackTrace();
  425. failNumber++;
  426. logger.info("e:" + e);
  427. failRow.add(failNum + 1);
  428. }
  429. }
  430. for (TSpecdevYlrq t : oldList) {
  431. // TSpecdevYlrq old = tSpecdevYlrqService.selectTSpecdevYlrqById(t.getId());
  432. // if (!old.getReportNo().equals(t.getReportNo())) {
  433. TSpecCheck tc = new TSpecCheck();
  434. tc.setDevType(1l);
  435. tc.setCheckUnit(t.getCheckUnit());
  436. tc.setDevId(t.getId());
  437. tc.setNextWarnDate(t.getNextWarnDate());
  438. tc.setReportNo(t.getReportNo());
  439. tc.setWarnDate(t.getWarnDate());
  440. tc.setYearNextWarnDate(t.getYearNextWarnDate());
  441. tc.setYearWarnDate(t.getYearWarnDate());
  442. tc.setYearReportNo(t.getReportNo());
  443. tc.setSafeClass(t.getSafeClass());
  444. tSpecCheckService.insertTSpecCheck(tc);
  445. // }
  446. }
  447. logger.info("list:" + JSON.toJSONString(list));
  448. logger.info("successNumber:" +String.valueOf(successNumber));
  449. logger.info("failNumber:" +String.valueOf(failNumber));
  450. logger.info("failRow:" +String.valueOf(failRow));
  451. return AjaxResult.success(String.valueOf(successNumber), failRow);
  452. }
  453. @GetMapping("/exportDevList")
  454. public AjaxResult exportbmy(ParamData params) throws IOException {
  455. logger.info(JSON.toJSONString(params));
  456. String id = params.getIds();
  457. String[] ids = id.split(",");
  458. List<TSpecdevYlrq> list = new ArrayList<>();
  459. for (String i : ids
  460. ) {
  461. TSpecdevYlrq t = tSpecdevYlrqService.getById(i);
  462. list.add(t);
  463. }
  464. SXSSFWorkbook wb = new SXSSFWorkbook(1000);
  465. CellStyle wrapStyle = wb.createCellStyle();
  466. wrapStyle.setWrapText(true); //设置自动换行
  467. //创建sheet页
  468. Sheet sheet = wb.createSheet("sheet1");
  469. //设置列的宽度,第一个参数为列的序号,从0开始,第二参数为列宽,单位1/256个字节
  470. sheet.setColumnWidth(0, 12*256);
  471. sheet.setColumnWidth(1, 26*256);
  472. sheet.setColumnWidth(2, 26*256);
  473. sheet.setColumnWidth(3, 26*256);
  474. sheet.setColumnWidth(4, 26*256);
  475. sheet.setColumnWidth(5, 26*256);
  476. sheet.setColumnWidth(6, 26*256);
  477. sheet.setColumnWidth(7, 26*256);
  478. sheet.setColumnWidth(8, 40*256);
  479. sheet.setColumnWidth(9, 40*256);
  480. sheet.setColumnWidth(10, 26*256);
  481. sheet.setColumnWidth(11, 26*256);
  482. sheet.setColumnWidth(12, 40*256);
  483. sheet.setColumnWidth(13, 40*256);
  484. //设置开始行和开始列
  485. Row row0 = sheet.createRow(0);
  486. CellStyle style = wb.createCellStyle();
  487. style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
  488. style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  489. // Font headerFont = wb.createFont();
  490. // headerFont.setFontName("Arial");
  491. // headerFont.setFontHeightInPoints((short) 12);
  492. // headerFont.setBold(false);
  493. // headerFont.setColor(IndexedColors.BLACK.getIndex());
  494. // style.setFont(headerFont);
  495. Cell cell0 = row0.createCell(0);
  496. row0.createCell(0).setCellValue("序号");
  497. row0.createCell(1).setCellValue("装置");
  498. row0.createCell(2).setCellValue("位号");
  499. row0.createCell(3).setCellValue("设备名称");
  500. row0.createCell(4).setCellValue("使用证号码");
  501. row0.createCell(5).setCellValue("检验单位");row0.getCell(5).setCellStyle(style);
  502. row0.createCell(6).setCellValue("定期检验日期");row0.getCell(6).setCellStyle(style);
  503. row0.createCell(7).setCellValue("安全状况等级");row0.getCell(7).setCellStyle(style);
  504. row0.createCell(8).setCellValue("定期检验报告编号");row0.getCell(8).setCellStyle(style);
  505. row0.createCell(9).setCellValue("下次定期检验日期");row0.getCell(9).setCellStyle(style);
  506. row0.createCell(10).setCellValue("年度检查日期");row0.getCell(10).setCellStyle(style);
  507. row0.createCell(11).setCellValue("年度检查结论");row0.getCell(11).setCellStyle(style);
  508. row0.createCell(12).setCellValue("下次年度检查日期");row0.getCell(12).setCellStyle(style);
  509. row0.createCell(13).setCellValue("年度检查报告编号");row0.getCell(13).setCellStyle(style);
  510. //填充数据
  511. int rowIndex = 1;
  512. int columnIndex = 1;
  513. for (TSpecdevYlrq t: list
  514. ) {
  515. Row row = sheet.createRow(rowIndex);
  516. row.createCell(0).setCellValue(t.getId());
  517. row.createCell(1).setCellValue(t.getPlantCode());
  518. row.createCell(2).setCellValue(t.getDevname());
  519. row.createCell(3).setCellValue(t.getDevno());
  520. row.createCell(4).setCellValue(t.getUseno());
  521. row.createCell(5).setCellValue(t.getCheckUnit());
  522. if (t.getWarnDate()!= null){
  523. row.createCell(6).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getWarnDate()));
  524. }
  525. row.createCell(7).setCellValue(t.getSafeClass());
  526. row.createCell(8).setCellValue(t.getReportNo());
  527. if (t.getNextWarnDate()!= null){
  528. row.createCell(9).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getNextWarnDate()));
  529. }
  530. if (t.getYearWarnDate()!= null){
  531. row.createCell(10).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getYearWarnDate()));
  532. }
  533. row.createCell(11).setCellValue(t.getCheckConclusion());
  534. if (t.getYearNextWarnDate()!= null){
  535. row.createCell(12).setCellValue(new SimpleDateFormat("yyyy-MM-dd").format(t.getYearNextWarnDate()));
  536. }
  537. row.createCell(13).setCellValue(t.getYearReportNo());
  538. rowIndex++;
  539. }
  540. OutputStream out = null;
  541. String filename = ExcelUtil.encodingFilename("压力容器批量更新");
  542. out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
  543. wb.write(out);
  544. wb.close();
  545. out.close();
  546. return AjaxResult.success(filename);
  547. }
  548. }