|
@@ -1,16 +1,27 @@
|
|
|
package com.ruoyi.project.pssr.controller;
|
|
|
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.*;
|
|
|
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrApprove;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrInstrumentCalibration;
|
|
|
-import com.ruoyi.project.pssr.domain.TPssrSubcontent;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
+import com.ruoyi.project.pssr.domain.*;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrApproveService;
|
|
|
import com.ruoyi.project.pssr.service.ITPssrSubcontentService;
|
|
|
+import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.service.ISysUserService;
|
|
|
import org.activiti.engine.ProcessEngine;
|
|
|
import org.activiti.engine.ProcessEngines;
|
|
|
import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -31,7 +42,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
|
|
|
/**
|
|
|
- * 仪校验Controller
|
|
|
+ * 仪表校验Controller
|
|
|
*
|
|
|
* @author ssy
|
|
|
* @date 2024-09-18
|
|
@@ -49,8 +60,12 @@ public class TPssrInstrumentCalibrationController extends BaseController
|
|
|
@Autowired
|
|
|
private ITPssrSubcontentService tPssrSubcontentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 查询仪校验列表
|
|
|
+ * 查询仪表校验列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('pssr:instrumentCalibration:list')")
|
|
|
@GetMapping("/list")
|
|
@@ -62,20 +77,82 @@ public class TPssrInstrumentCalibrationController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 导出仪校验列表
|
|
|
+ * 导出仪表校验列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('pssr:instrumentCalibration:export')")
|
|
|
- @Log(title = "仪校验", businessType = BusinessType.EXPORT)
|
|
|
+ @Log(title = "仪表校验", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(TPssrInstrumentCalibration tPssrInstrumentCalibration)
|
|
|
{
|
|
|
List<TPssrInstrumentCalibration> list = tPssrInstrumentCalibrationService.selectTPssrInstrumentCalibrationList(tPssrInstrumentCalibration);
|
|
|
- ExcelUtil<TPssrInstrumentCalibration> util = new ExcelUtil<TPssrInstrumentCalibration>(TPssrInstrumentCalibration.class);
|
|
|
- return util.exportExcel(list, "instrumentCalibration");
|
|
|
+ return AjaxResult.success(exportTmpl(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ public String exportTmpl(List<TPssrInstrumentCalibration> list) {
|
|
|
+ OutputStream out = null;
|
|
|
+ String filename = null;
|
|
|
+ try {
|
|
|
+ String tempUrl = "static/word/pssr/ybjy.xlsx"; // 模板文件
|
|
|
+ InputStream is = null;
|
|
|
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
|
|
|
+ XSSFWorkbook wb = null;
|
|
|
+ wb = new XSSFWorkbook(is);
|
|
|
+ XSSFSheet sheet = wb.getSheetAt(0);
|
|
|
+
|
|
|
+ //填充数据
|
|
|
+ int rowIndex = 3;
|
|
|
+ int num = 1;
|
|
|
+
|
|
|
+ Row originalRow = sheet.getRow(3);
|
|
|
+ Cell originalcell = originalRow.getCell(0);
|
|
|
+ // 获取单元格样式
|
|
|
+ CellStyle originalStyle = originalcell.getCellStyle();
|
|
|
+
|
|
|
+ for (TPssrInstrumentCalibration t : list) {
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.setHeight((short) 800);
|
|
|
+ row.createCell(0).setCellValue(num);
|
|
|
+ row.createCell(1).setCellValue(t.getUnit());
|
|
|
+ row.createCell(2).setCellValue(t.getDevNo());
|
|
|
+ row.createCell(3).setCellValue(t.getVisualInspection());
|
|
|
+ row.createCell(4).setCellValue(t.getInstallationInspection());
|
|
|
+ row.createCell(5).setCellValue(t.getFunctionalCheck());
|
|
|
+ row.createCell(6);
|
|
|
+ row.createCell(7);
|
|
|
+ try {
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(Long.valueOf(t.getConfirm1()));
|
|
|
+ SysUser sysUser2 = sysUserService.selectUserById(Long.valueOf(t.getConfirm2()));
|
|
|
+ String confirm1 = sysUser.getSignUrl();
|
|
|
+ String confirm2= sysUser2.getSignUrl();
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm1, row.getRowNum(), 6, 1, 1);
|
|
|
+ ExcelUtils.insertPicture(wb, sheet, confirm2, row.getRowNum(), 7, 1, 1);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ row.createCell(8).setCellValue(DateUtils.dateTime(t.getConfirmationDate()));
|
|
|
+ row.createCell(9).setCellValue(t.getRemarks());
|
|
|
+
|
|
|
+
|
|
|
+ //渲染样式
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ row.getCell(i).setCellStyle(originalStyle);
|
|
|
+ }
|
|
|
+ num++;
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ filename = ExcelUtil.encodingFilename("InstrumentCalibration");
|
|
|
+ out = new FileOutputStream(ExcelUtil.getAbsoluteFile(filename));
|
|
|
+ wb.write(out);
|
|
|
+ wb.close();
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return filename;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取仪校验详细信息
|
|
|
+ * 获取仪表校验详细信息
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('pssr:instrumentCalibration:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
@@ -85,10 +162,10 @@ public class TPssrInstrumentCalibrationController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 新增仪校验
|
|
|
+ * 新增仪表校验
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('pssr:instrumentCalibration:add')")
|
|
|
- @Log(title = "仪校验", businessType = BusinessType.INSERT)
|
|
|
+ @Log(title = "仪表校验", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody TPssrInstrumentCalibration tPssrInstrumentCalibration)
|
|
|
{
|
|
@@ -97,10 +174,10 @@ public class TPssrInstrumentCalibrationController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 修改仪校验
|
|
|
+ * 修改仪表校验
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('pssr:instrumentCalibration:edit')")
|
|
|
- @Log(title = "仪校验", businessType = BusinessType.UPDATE)
|
|
|
+ @Log(title = "仪表校验", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody TPssrInstrumentCalibration tPssrInstrumentCalibration)
|
|
|
{
|
|
@@ -108,10 +185,10 @@ public class TPssrInstrumentCalibrationController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 删除仪校验
|
|
|
+ * 删除仪表校验
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('pssr:instrumentCalibration:remove')")
|
|
|
- @Log(title = "仪校验", businessType = BusinessType.DELETE)
|
|
|
+ @Log(title = "仪表校验", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
{
|