|
@@ -1,14 +1,17 @@
|
|
|
package com.ruoyi.project.sems.controller;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.document.PDFTemplateUtil;
|
|
|
+import com.ruoyi.common.utils.document.ZipUtil;
|
|
|
import com.ruoyi.framework.config.RuoYiConfig;
|
|
|
import com.ruoyi.project.sems.domain.*;
|
|
|
import com.ruoyi.project.sems.service.ITReportYlgdService;
|
|
@@ -43,8 +46,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/sems/historyYlrq")
|
|
|
-public class TReportHiYlrqController extends BaseController
|
|
|
-{
|
|
|
+public class TReportHiYlrqController extends BaseController {
|
|
|
@Autowired
|
|
|
private ITReportHiYlrqService tReportHiYlrqService;
|
|
|
|
|
@@ -68,8 +70,7 @@ public class TReportHiYlrqController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('sems:historyYlrq:list')")
|
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(TReportHiYlrq tReportHiYlrq)
|
|
|
- {
|
|
|
+ public TableDataInfo list(TReportHiYlrq tReportHiYlrq) {
|
|
|
startPage();
|
|
|
List<TReportHiYlrq> list = tReportHiYlrqService.selectTReportHiYlrqList(tReportHiYlrq);
|
|
|
return getDataTable(list);
|
|
@@ -81,8 +82,7 @@ public class TReportHiYlrqController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('sems:historyYlrq:export')")
|
|
|
@Log(title = "压力容器报告历史", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(TReportHiYlrq tReportHiYlrq)
|
|
|
- {
|
|
|
+ public AjaxResult export(TReportHiYlrq tReportHiYlrq) {
|
|
|
List<TReportHiYlrq> list = tReportHiYlrqService.selectTReportHiYlrqList(tReportHiYlrq);
|
|
|
ExcelUtil<TReportHiYlrq> util = new ExcelUtil<TReportHiYlrq>(TReportHiYlrq.class);
|
|
|
return util.exportExcel(list, "historyYlrq");
|
|
@@ -93,8 +93,7 @@ public class TReportHiYlrqController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('sems:historyYlrq:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return AjaxResult.success(tReportHiYlrqService.selectTReportHiYlrqById(id));
|
|
|
}
|
|
|
|
|
@@ -104,8 +103,7 @@ public class TReportHiYlrqController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('sems:historyYlrq:add')")
|
|
|
@Log(title = "压力容器报告历史", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody TReportHiYlrq tReportHiYlrq)
|
|
|
- {
|
|
|
+ public AjaxResult add(@RequestBody TReportHiYlrq tReportHiYlrq) {
|
|
|
return toAjax(tReportHiYlrqService.insertTReportHiYlrq(tReportHiYlrq));
|
|
|
}
|
|
|
|
|
@@ -115,8 +113,7 @@ public class TReportHiYlrqController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('sems:historyYlrq:edit')")
|
|
|
@Log(title = "压力容器报告历史", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody TReportHiYlrq tReportHiYlrq)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@RequestBody TReportHiYlrq tReportHiYlrq) {
|
|
|
return toAjax(tReportHiYlrqService.updateTReportHiYlrq(tReportHiYlrq));
|
|
|
}
|
|
|
|
|
@@ -125,15 +122,14 @@ public class TReportHiYlrqController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('sems:historyYlrq:remove')")
|
|
|
@Log(title = "压力容器报告历史", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(tReportHiYlrqService.deleteTReportHiYlrqByIds(ids));
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/exportPDF")
|
|
|
public String exportPDF(@RequestParam String id, HttpServletRequest request, HttpServletResponse response) {
|
|
|
- OutputStream out= null;
|
|
|
+ OutputStream out = null;
|
|
|
try {
|
|
|
out = response.getOutputStream();
|
|
|
//获取信息,就是上面的结构
|
|
@@ -141,36 +137,36 @@ public class TReportHiYlrqController extends BaseController
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
TReportHiYlrq tReportHiYlrq = this.tReportHiYlrqService.selectTReportHiYlrqById(Long.parseLong(id));
|
|
|
List<SysDictData> con = iSysDictTypeService.selectDictDataByType("REPORT_CON");
|
|
|
- if(StringUtils.isNotEmpty(tReportHiYlrq.getCon())){
|
|
|
+ if (StringUtils.isNotEmpty(tReportHiYlrq.getCon())) {
|
|
|
for (SysDictData c : con) {
|
|
|
if (tReportHiYlrq.getCon().equals(c.getDictValue())) {
|
|
|
tReportHiYlrq.setCon(c.getDictLabel());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(tReportHiYlrq.getPlantCode())){
|
|
|
+ if (StringUtils.isNotEmpty(tReportHiYlrq.getPlantCode())) {
|
|
|
SysUser sysUser = this.iSysUserService.selectSafeManagerUserByPlantCode(tReportHiYlrq.getPlantCode());
|
|
|
- if(sysUser != null){
|
|
|
- map.put("safeUserName",sysUser.getNickName());
|
|
|
- map.put("safePhonenumber",sysUser.getPhonenumber());
|
|
|
- }else{
|
|
|
- map.put("safeUserName","");
|
|
|
- map.put("safePhonenumber","");
|
|
|
+ if (sysUser != null) {
|
|
|
+ map.put("safeUserName", sysUser.getNickName());
|
|
|
+ map.put("safePhonenumber", sysUser.getPhonenumber());
|
|
|
+ } else {
|
|
|
+ map.put("safeUserName", "");
|
|
|
+ map.put("safePhonenumber", "");
|
|
|
}
|
|
|
}
|
|
|
map.put("reportHiYlrq", tReportHiYlrq);
|
|
|
TReportYlrq reportYlrq = tReportYlrqService.selectTReportYlrqById(tReportHiYlrq.getReportId());
|
|
|
TSpecdevYlrq devYlrq = tSpecdevYlrqService.selectTSpecdevYlrqById(reportYlrq.getDevId());
|
|
|
map.put("devYlrq", devYlrq);
|
|
|
- if(tReportHiYlrq.getCheckDate() != null){
|
|
|
+ if (tReportHiYlrq.getCheckDate() != null) {
|
|
|
map.put("checkDate", sdf.format(tReportHiYlrq.getCheckDate()));
|
|
|
}
|
|
|
- if(tReportHiYlrq.getNextWarnDate() != null){
|
|
|
+ if (tReportHiYlrq.getNextWarnDate() != null) {
|
|
|
String[] nextWarnDateGD = sdf.format(tReportHiYlrq.getNextWarnDate()).split("-");
|
|
|
map.put("nextWarnDateYear", nextWarnDateGD[0]);
|
|
|
map.put("nextWarnDateMonth", nextWarnDateGD[1]);
|
|
|
}
|
|
|
- if(tReportHiYlrq.getNextCheckDate() != null){
|
|
|
+ if (tReportHiYlrq.getNextCheckDate() != null) {
|
|
|
String[] nextCheckDateGD = sdf.format(tReportHiYlrq.getNextCheckDate()).split("-");
|
|
|
map.put("nextCheckDateYear", nextCheckDateGD[0]);
|
|
|
map.put("nextCheckDateMonth", nextCheckDateGD[1]);
|
|
@@ -178,24 +174,118 @@ public class TReportHiYlrqController extends BaseController
|
|
|
HistoricTaskInstanceQuery htiq = historyService.createHistoricTaskInstanceQuery();
|
|
|
List<HistoricTaskInstance> htiLists = htiq.processInstanceId(tReportHiYlrq.getApproveId()).finished().orderByHistoricTaskInstanceEndTime().asc().list();
|
|
|
logger.info("历史任务:" + JSON.toJSONString(htiLists));
|
|
|
- if( htiLists != null ){
|
|
|
+ if (htiLists != null) {
|
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- map.put("inspectorOne",htiLists.get(0).getName());
|
|
|
- map.put("inspectorOneEndTime",sdf2.format(htiLists.get(0).getEndTime()));
|
|
|
- map.put("inspectorTwo",htiLists.get(1).getName());
|
|
|
- map.put("inspectorTwoEndTime",sdf2.format(htiLists.get(1).getEndTime()));
|
|
|
- map.put("inspectorThree",htiLists.get(2).getName());
|
|
|
- map.put("inspectorThreeEndTime",sdf2.format(htiLists.get(2).getEndTime()));
|
|
|
- map.put("auditor",htiLists.get(3).getName());
|
|
|
- map.put("auditorEndTime",sdf2.format(htiLists.get(3).getEndTime()));
|
|
|
- map.put("approveUser",htiLists.get(4).getName());
|
|
|
- map.put("approveEndTime",sdf2.format(htiLists.get(4).getEndTime()));
|
|
|
+ map.put("inspectorOne", htiLists.get(0).getName());
|
|
|
+ map.put("inspectorOneEndTime", sdf2.format(htiLists.get(0).getEndTime()));
|
|
|
+ map.put("inspectorTwo", htiLists.get(1).getName());
|
|
|
+ map.put("inspectorTwoEndTime", sdf2.format(htiLists.get(1).getEndTime()));
|
|
|
+ map.put("inspectorThree", htiLists.get(2).getName());
|
|
|
+ map.put("inspectorThreeEndTime", sdf2.format(htiLists.get(2).getEndTime()));
|
|
|
+ map.put("auditor", htiLists.get(3).getName());
|
|
|
+ map.put("auditorEndTime", sdf2.format(htiLists.get(3).getEndTime()));
|
|
|
+ map.put("approveUser", htiLists.get(4).getName());
|
|
|
+ map.put("approveEndTime", sdf2.format(htiLists.get(4).getEndTime()));
|
|
|
}
|
|
|
- PDFTemplateUtil.exportPdf("yearYlrqFMaker.ftl", "压力容器年度检查报告.pdf","file:/"+ RuoYiConfig.getProfile(), map, response);
|
|
|
+ PDFTemplateUtil.exportPdf("yearYlrqFMaker.ftl", "压力容器年度检查报告.pdf", "file:/" + RuoYiConfig.getProfile(), map, response);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
- if(out!=null)
|
|
|
+ } finally {
|
|
|
+ if (out != null)
|
|
|
+ try {
|
|
|
+ out.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping("/exportPDFForYear")
|
|
|
+ public String exportPDFForYear(@RequestParam String year, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ OutputStream out = null;
|
|
|
+ try {
|
|
|
+ out = response.getOutputStream();
|
|
|
+ //获取信息,就是上面的结构
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ List<TReportHiYlrq> tReportHiYlrqs = this.tReportHiYlrqService.selectTReportHiYlrqForYear(year);
|
|
|
+ List<SysDictData> con = iSysDictTypeService.selectDictDataByType("REPORT_CON");
|
|
|
+ //使用当前时间作为文件夹,所有文件保存在当中
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ //存放所有pdf文件路径
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (TReportHiYlrq tReportHiYlrq : tReportHiYlrqs) {
|
|
|
+ if (StringUtils.isNotEmpty(tReportHiYlrq.getCon())) {
|
|
|
+ for (SysDictData c : con) {
|
|
|
+ if (tReportHiYlrq.getCon().equals(c.getDictValue())) {
|
|
|
+ tReportHiYlrq.setCon(c.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(tReportHiYlrq.getPlantCode())) {
|
|
|
+ SysUser sysUser = this.iSysUserService.selectSafeManagerUserByPlantCode(tReportHiYlrq.getPlantCode());
|
|
|
+ if (sysUser != null) {
|
|
|
+ map.put("safeUserName", sysUser.getNickName());
|
|
|
+ map.put("safePhonenumber", sysUser.getPhonenumber());
|
|
|
+ } else {
|
|
|
+ map.put("safeUserName", "");
|
|
|
+ map.put("safePhonenumber", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("reportHiYlrq", tReportHiYlrq);
|
|
|
+ TReportYlrq reportYlrq = tReportYlrqService.selectTReportYlrqById(tReportHiYlrq.getReportId());
|
|
|
+ TSpecdevYlrq devYlrq = tSpecdevYlrqService.selectTSpecdevYlrqById(reportYlrq.getDevId());
|
|
|
+ map.put("devYlrq", devYlrq);
|
|
|
+ if (tReportHiYlrq.getCheckDate() != null) {
|
|
|
+ map.put("checkDate", sdf.format(tReportHiYlrq.getCheckDate()));
|
|
|
+ }
|
|
|
+ if (tReportHiYlrq.getNextWarnDate() != null) {
|
|
|
+ String[] nextWarnDateGD = sdf.format(tReportHiYlrq.getNextWarnDate()).split("-");
|
|
|
+ map.put("nextWarnDateYear", nextWarnDateGD[0]);
|
|
|
+ map.put("nextWarnDateMonth", nextWarnDateGD[1]);
|
|
|
+ }
|
|
|
+ if (tReportHiYlrq.getNextCheckDate() != null) {
|
|
|
+ String[] nextCheckDateGD = sdf.format(tReportHiYlrq.getNextCheckDate()).split("-");
|
|
|
+ map.put("nextCheckDateYear", nextCheckDateGD[0]);
|
|
|
+ map.put("nextCheckDateMonth", nextCheckDateGD[1]);
|
|
|
+ }
|
|
|
+ HistoricTaskInstanceQuery htiq = historyService.createHistoricTaskInstanceQuery();
|
|
|
+ List<HistoricTaskInstance> htiLists = htiq.processInstanceId(tReportHiYlrq.getApproveId()).finished().orderByHistoricTaskInstanceEndTime().asc().list();
|
|
|
+ logger.info("报告数据:" + JSON.toJSONString(htiLists));
|
|
|
+ if (htiLists != null) {
|
|
|
+ SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ map.put("inspectorOne", htiLists.get(0).getName());
|
|
|
+ map.put("inspectorOneEndTime", sdf2.format(htiLists.get(0).getEndTime()));
|
|
|
+ map.put("inspectorTwo", htiLists.get(1).getName());
|
|
|
+ map.put("inspectorTwoEndTime", sdf2.format(htiLists.get(1).getEndTime()));
|
|
|
+ map.put("inspectorThree", htiLists.get(2).getName());
|
|
|
+ map.put("inspectorThreeEndTime", sdf2.format(htiLists.get(2).getEndTime()));
|
|
|
+ map.put("auditor", htiLists.get(3).getName());
|
|
|
+ map.put("auditorEndTime", sdf2.format(htiLists.get(3).getEndTime()));
|
|
|
+ map.put("approveUser", htiLists.get(4).getName());
|
|
|
+ map.put("approveEndTime", sdf2.format(htiLists.get(4).getEndTime()));
|
|
|
+ }
|
|
|
+ //多个文件区分文件名
|
|
|
+ String pdfName = tReportHiYlrq.getPlantCode()
|
|
|
+ + "-" + tReportHiYlrq.getUnit()
|
|
|
+ + "-" + tReportHiYlrq.getDevno()
|
|
|
+ + "-" + tReportHiYlrq.getDevname()
|
|
|
+ + "-" + sdf.format(tReportHiYlrq.getCheckDate())
|
|
|
+ + "-压力容器年度检查报告.pdf"
|
|
|
+ .replace(" ", "")
|
|
|
+ .replace("\\s", "")
|
|
|
+ .replace("\n", "");
|
|
|
+ // 生成PDF文件
|
|
|
+ PDFTemplateUtil.createPdf("yearYlrqFMaker.ftl", pdfName, RuoYiConfig.getProfile() + "/" + now, map, response);
|
|
|
+ list.add(pdfName);
|
|
|
+ //PDFTemplateUtil.exportPdf("yearYlrqFMaker.ftl", pdfName, "file:/" + RuoYiConfig.getProfile(), map, response);
|
|
|
+ }
|
|
|
+ ZipUtil.createZip(RuoYiConfig.getProfile(), now + "", year + "年压力容器年度检查历史报告.zip", list, response);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (out != null)
|
|
|
try {
|
|
|
out.close();
|
|
|
} catch (IOException e) {
|