TSpecdevYlrqController.java 25 KB

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