|
|
|
@ -1,6 +1,20 @@
|
|
|
|
|
package com.haiwei.manage.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
|
|
import com.haiwei.common.exception.BusinessException;
|
|
|
|
|
import com.haiwei.common.utils.poi.ExcelUtil_2;
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
@ -21,14 +35,13 @@ import com.haiwei.common.core.page.TableDataInfo;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 实验报告Controller
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @author wangh
|
|
|
|
|
* @date 2023-10-30
|
|
|
|
|
*/
|
|
|
|
|
@Controller
|
|
|
|
|
@RequestMapping("/manage/record_report")
|
|
|
|
|
public class RecordTestReportController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
public class RecordTestReportController extends BaseController {
|
|
|
|
|
private String prefix = "manage/record_report";
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@ -36,23 +49,22 @@ public class RecordTestReportController extends BaseController
|
|
|
|
|
|
|
|
|
|
@RequiresPermissions("manage:record_report:view")
|
|
|
|
|
@GetMapping()
|
|
|
|
|
public String record_report()
|
|
|
|
|
{
|
|
|
|
|
public String record_report() {
|
|
|
|
|
return prefix + "/record_report";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/selectData")
|
|
|
|
|
public String record_piont_data()
|
|
|
|
|
{
|
|
|
|
|
public String record_piont_data() {
|
|
|
|
|
return "manage/record_piont_data/record_piont_data";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询实验报告列表
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("manage:record_report:list")
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public TableDataInfo list(RecordTestReport recordTestReport)
|
|
|
|
|
{
|
|
|
|
|
public TableDataInfo list(RecordTestReport recordTestReport) {
|
|
|
|
|
startPage();
|
|
|
|
|
List<RecordTestReport> list = recordTestReportService.selectRecordTestReportList(recordTestReport);
|
|
|
|
|
return getDataTable(list);
|
|
|
|
@ -63,21 +75,58 @@ public class RecordTestReportController extends BaseController
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("manage:record_report:export")
|
|
|
|
|
@Log(title = "实验报告", businessType = BusinessType.EXPORT)
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
@PostMapping("/export/{id}")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult export(RecordTestReport recordTestReport)
|
|
|
|
|
{
|
|
|
|
|
List<RecordTestReport> list = recordTestReportService.selectRecordTestReportList(recordTestReport);
|
|
|
|
|
ExcelUtil<RecordTestReport> util = new ExcelUtil<RecordTestReport>(RecordTestReport.class);
|
|
|
|
|
return util.exportExcel(list, "record_report");
|
|
|
|
|
public AjaxResult export(@PathVariable("id") Long id) {
|
|
|
|
|
RecordTestReport recordTestReport = recordTestReportService.selectRecordTestReportById(id);
|
|
|
|
|
String targetFile = null;
|
|
|
|
|
WriteSheet sheet = null;
|
|
|
|
|
ExcelWriter workBook = null;
|
|
|
|
|
OutputStream out = null;
|
|
|
|
|
try {
|
|
|
|
|
File file = new File("D:/moban/实验报告.xlsx");
|
|
|
|
|
//目标文件
|
|
|
|
|
targetFile = "实验报告.xlsx";
|
|
|
|
|
out = new FileOutputStream(ExcelUtil_2.getAbsoluteFilew(targetFile));
|
|
|
|
|
workBook = EasyExcel.write(out).withTemplate(file).build();
|
|
|
|
|
//创建工作表
|
|
|
|
|
sheet = EasyExcel.writerSheet().build();
|
|
|
|
|
//写入数据
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("testData", recordTestReport.getTestData());
|
|
|
|
|
map.put("sampleName", recordTestReport.getSampleName());
|
|
|
|
|
map.put("entrustedUnit", recordTestReport.getEntrustedUnit());
|
|
|
|
|
map.put("testParam", recordTestReport.getTestParam());
|
|
|
|
|
map.put("inStatus", recordTestReport.getInStatus());
|
|
|
|
|
map.put("temperature", recordTestReport.getTemperature());
|
|
|
|
|
map.put("viscosity", recordTestReport.getViscosity());
|
|
|
|
|
map.put("weight", recordTestReport.getWeight());
|
|
|
|
|
map.put("testResults", recordTestReport.getTestResults());
|
|
|
|
|
workBook.fill(map, sheet);//单组
|
|
|
|
|
workBook.fill(recordTestReport.getRecordTestParamList(), sheet);//多组
|
|
|
|
|
workBook.finish();
|
|
|
|
|
out.flush();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
//log.error("导出Excel异常{}", e.getMessage());
|
|
|
|
|
throw new BusinessException("导出Excel失败,请联系网站管理员!");
|
|
|
|
|
} finally {
|
|
|
|
|
if (null != out) {
|
|
|
|
|
try {
|
|
|
|
|
out.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(targetFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增实验报告
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/add")
|
|
|
|
|
public String add()
|
|
|
|
|
{
|
|
|
|
|
public String add() {
|
|
|
|
|
return prefix + "/add";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -88,8 +137,7 @@ public class RecordTestReportController extends BaseController
|
|
|
|
|
@Log(title = "实验报告", businessType = BusinessType.INSERT)
|
|
|
|
|
@PostMapping("/add")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult addSave(RecordTestReport recordTestReport)
|
|
|
|
|
{
|
|
|
|
|
public AjaxResult addSave(RecordTestReport recordTestReport) {
|
|
|
|
|
return toAjax(recordTestReportService.insertRecordTestReport(recordTestReport));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -97,8 +145,7 @@ public class RecordTestReportController extends BaseController
|
|
|
|
|
* 修改实验报告
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/edit/{objid}")
|
|
|
|
|
public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
|
|
|
|
|
{
|
|
|
|
|
public String edit(@PathVariable("objid") Long objid, ModelMap mmap) {
|
|
|
|
|
RecordTestReport recordTestReport = recordTestReportService.selectRecordTestReportById(objid);
|
|
|
|
|
mmap.put("recordTestReport", recordTestReport);
|
|
|
|
|
return prefix + "/edit";
|
|
|
|
@ -111,8 +158,7 @@ public class RecordTestReportController extends BaseController
|
|
|
|
|
@Log(title = "实验报告", businessType = BusinessType.UPDATE)
|
|
|
|
|
@PostMapping("/edit")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult editSave(RecordTestReport recordTestReport)
|
|
|
|
|
{
|
|
|
|
|
public AjaxResult editSave(RecordTestReport recordTestReport) {
|
|
|
|
|
return toAjax(recordTestReportService.updateRecordTestReport(recordTestReport));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -121,10 +167,9 @@ public class RecordTestReportController extends BaseController
|
|
|
|
|
*/
|
|
|
|
|
@RequiresPermissions("manage:record_report:remove")
|
|
|
|
|
@Log(title = "实验报告", businessType = BusinessType.DELETE)
|
|
|
|
|
@PostMapping( "/remove")
|
|
|
|
|
@PostMapping("/remove")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult remove(String ids)
|
|
|
|
|
{
|
|
|
|
|
public AjaxResult remove(String ids) {
|
|
|
|
|
return toAjax(recordTestReportService.deleteRecordTestReportByIds(ids));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|