检测报告管理
This commit is contained in:
parent
0a9295ff9b
commit
167b872ee6
|
|
@ -1,5 +1,10 @@
|
||||||
package com.bonus.aqgqj.basis.controller;
|
package com.bonus.aqgqj.basis.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import cn.hutool.poi.excel.ExcelWriter;
|
||||||
import com.bonus.aqgqj.annotation.DecryptAndVerify;
|
import com.bonus.aqgqj.annotation.DecryptAndVerify;
|
||||||
import com.bonus.aqgqj.annotation.LogAnnotation;
|
import com.bonus.aqgqj.annotation.LogAnnotation;
|
||||||
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
|
import com.bonus.aqgqj.basis.entity.dto.ParamsDto;
|
||||||
|
|
@ -13,22 +18,24 @@ import com.github.pagehelper.PageInfo;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -149,6 +156,24 @@ public class TestReportManageController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 一级页面下载
|
||||||
|
*/
|
||||||
|
@PostMapping("download")
|
||||||
|
// @DecryptAndVerify(decryptedClass = TestReportManageDto.class)//加解密统一管理
|
||||||
|
@LogAnnotation(operModul = "检测报告管理", operation = "下载", operDesc = "业务级事件", operType = "新增")
|
||||||
|
@PreAuthorize("@pms.hasPermission('sys:samples:dispatch')")
|
||||||
|
public ServerResponse download(EncryptedReq<TestReportManageDto> vo) {
|
||||||
|
try {
|
||||||
|
TestReportManageDto voo=new TestReportManageDto();
|
||||||
|
voo.setId(25);
|
||||||
|
return testReportManageService.download(voo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
return ServerResponse.createErroe("操作失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(value = "viewTestData")
|
@PostMapping(value = "viewTestData")
|
||||||
@DecryptAndVerify(decryptedClass = TestReportManageDto.class)//加解密统一管理
|
@DecryptAndVerify(decryptedClass = TestReportManageDto.class)//加解密统一管理
|
||||||
public ServerResponse viewTestData(EncryptedReq<TestReportManageDto> data) {
|
public ServerResponse viewTestData(EncryptedReq<TestReportManageDto> data) {
|
||||||
|
|
@ -263,4 +288,61 @@ public class TestReportManageController {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/export", method = RequestMethod.GET)
|
||||||
|
public void exportWorkerAttendance(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
String path = "D:\\poi\\";
|
||||||
|
//总列数
|
||||||
|
int all = 0;
|
||||||
|
//动态生成列数
|
||||||
|
int col = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 1.创建一个工作簿。03
|
||||||
|
Workbook workbook = new HSSFWorkbook();
|
||||||
|
// 2.创建一个工作表
|
||||||
|
Sheet sheet = workbook.createSheet("统计表");
|
||||||
|
// 3.创建行。第一行
|
||||||
|
Row row = sheet.createRow(0);
|
||||||
|
// 4.创建列。
|
||||||
|
// (1,1) 第一行第一列的单元格
|
||||||
|
Cell cell = row.createCell(0);
|
||||||
|
cell.setCellValue("安全帽检测报告附页");
|
||||||
|
// 合并单元格:从第一个到第十个单元格
|
||||||
|
sheet.addMergedRegion(new org.apache.poi.ss.util.CellRangeAddress(
|
||||||
|
0, // 起始行
|
||||||
|
0, // 结束行
|
||||||
|
0, // 起始列
|
||||||
|
all - 1 // 结束列
|
||||||
|
));
|
||||||
|
|
||||||
|
// 第二行。(1,0)
|
||||||
|
Row row1 = sheet.createRow(1);
|
||||||
|
//(2,1)第二行第一列的单元格
|
||||||
|
Cell cell1 = row1.createCell(0);
|
||||||
|
cell1.setCellValue("报告编号");
|
||||||
|
|
||||||
|
Cell cell2 = row1.createCell(1);
|
||||||
|
cell1.setCellValue("报告编号");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 判断文件是否存在,不存在就创建
|
||||||
|
if (FileUtil.isEmpty(new File(path))) {
|
||||||
|
FileUtil.mkdir(path);
|
||||||
|
}
|
||||||
|
// 5.生成一张表。03版本的工作簿是以.xls结尾
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream(path + "03.xls");
|
||||||
|
// 输出
|
||||||
|
workbook.write(fileOutputStream);
|
||||||
|
// 6.关闭流
|
||||||
|
fileOutputStream.close();
|
||||||
|
System.out.println("03表生成成功!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,4 +70,11 @@ public interface TestReportManageService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
TestReportManageDto downloadCertificateList(TestReportManageDto data);
|
TestReportManageDto downloadCertificateList(TestReportManageDto data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测报告下载
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ServerResponse download(TestReportManageDto data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.bonus.aqgqj.basis.service.impl;
|
package com.bonus.aqgqj.basis.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.bonus.aqgqj.basis.dao.TestReportManageDao;
|
import com.bonus.aqgqj.basis.dao.TestReportManageDao;
|
||||||
|
|
@ -8,18 +10,24 @@ import com.bonus.aqgqj.basis.entity.dto.TestReportManageDto;
|
||||||
import com.bonus.aqgqj.basis.entity.vo.*;
|
import com.bonus.aqgqj.basis.entity.vo.*;
|
||||||
import com.bonus.aqgqj.basis.service.SamplesManageService;
|
import com.bonus.aqgqj.basis.service.SamplesManageService;
|
||||||
import com.bonus.aqgqj.basis.service.TestReportManageService;
|
import com.bonus.aqgqj.basis.service.TestReportManageService;
|
||||||
import com.bonus.aqgqj.utils.DateTimeHelper;
|
import com.bonus.aqgqj.utils.*;
|
||||||
import com.bonus.aqgqj.utils.ServerResponse;
|
|
||||||
import com.bonus.aqgqj.utils.StringHelper;
|
|
||||||
import com.bonus.aqgqj.utils.UserUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 工器具个体管理
|
* @description 工器具个体管理
|
||||||
|
|
@ -212,6 +220,329 @@ public class TestReportManageServiceImpl implements TestReportManageService {
|
||||||
return testReportManageDao.downloadCertificateList(data);
|
return testReportManageDao.downloadCertificateList(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerResponse download(TestReportManageDto data) {
|
||||||
|
//根据选择的id获取详情数据
|
||||||
|
TestReportManageDto bean = new TestReportManageDto();
|
||||||
|
bean.setId(data.getId());
|
||||||
|
List<TestReportManageDto> list = getDetailsList(bean);
|
||||||
|
//查询详情里所有数据的检测报告
|
||||||
|
for (TestReportManageDto dto : list){
|
||||||
|
//根据试验id、设备类型、是否合格、部门id来查询每个检测报告
|
||||||
|
ServerResponse serverResponse = viewTestData(dto);
|
||||||
|
if (serverResponse.isSuccess()){
|
||||||
|
TestReportManageDto testVo = (TestReportManageDto) serverResponse.getData();
|
||||||
|
log.info("sj--->{}",testVo);
|
||||||
|
//将数据传给检测报告生成的方法
|
||||||
|
try {
|
||||||
|
generateReport(testVo);
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成检测报告
|
||||||
|
*/
|
||||||
|
public void generateReport(TestReportManageDto bean) throws IOException {
|
||||||
|
String path = "D:\\poi\\";
|
||||||
|
//先计算出总共有多少列和动态生成的有多少列
|
||||||
|
//总列数
|
||||||
|
int totalNum = 0;
|
||||||
|
//动态生成的列数
|
||||||
|
int trendsNum = 0;
|
||||||
|
//获取所有检测项目
|
||||||
|
List<ConfigItemsVo> configItemsVos = bean.getConfigItemsVos();
|
||||||
|
for (ConfigItemsVo configItemsVo : configItemsVos){
|
||||||
|
List<ConfigItemVo> itemList = configItemsVo.getItemList();
|
||||||
|
trendsNum += itemList.size();
|
||||||
|
}
|
||||||
|
List<ExperBasisVo> basisVos = bean.getBasisVos();
|
||||||
|
String yj="";
|
||||||
|
for (int i = 0; i < basisVos.size(); i++){
|
||||||
|
yj+=(i + 1)+"、"+basisVos.get(i).getBasisName() + "\n";
|
||||||
|
}
|
||||||
|
totalNum = trendsNum + 6;
|
||||||
|
List<ExperDevVo> devList=bean.getExperDevVos();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||||
|
Sheet sheet = workbook.createSheet("检测报告");
|
||||||
|
//第一行
|
||||||
|
Row row1 = sheet.createRow(0);
|
||||||
|
//单元格-创建第一个头
|
||||||
|
Cell cell11 = row1.createCell(0);
|
||||||
|
cell11.setCellValue(bean.getSampleTools()+"检测报告附页");
|
||||||
|
//合并全部列
|
||||||
|
addMergedRegion(0,0,0,totalNum-1,sheet);
|
||||||
|
XSSFCellStyle style= centerStyle(workbook);
|
||||||
|
cell11.setCellStyle(style);
|
||||||
|
|
||||||
|
|
||||||
|
//第二行
|
||||||
|
Row row2 = sheet.createRow(1);
|
||||||
|
Cell cell21 = row2.createCell(0);
|
||||||
|
cell21.setCellValue("报告编号");
|
||||||
|
cell21.setCellStyle(style);
|
||||||
|
//计算占用行数
|
||||||
|
int num21=(totalNum-4)/2;
|
||||||
|
Cell cell22 = row2.createCell(1);
|
||||||
|
addMergedRegion(1,1,1,num21,sheet);
|
||||||
|
cell22.setCellValue(bean.getReportCode());
|
||||||
|
|
||||||
|
Cell cell23 = row2.createCell(num21+1);
|
||||||
|
cell23.setCellValue("收样日期");
|
||||||
|
cell23.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell24 = row2.createCell(num21+2);
|
||||||
|
cell24.setCellValue(bean.getCollectSamplesTime());
|
||||||
|
cell24.setCellStyle(style);
|
||||||
|
addMergedRegion(1,1,num21+2,totalNum-3,sheet);
|
||||||
|
|
||||||
|
Cell cell25 = row2.createCell(totalNum-2);
|
||||||
|
cell25.setCellValue("样品数量");
|
||||||
|
cell25.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell26= row2.createCell(totalNum-1);
|
||||||
|
cell26.setCellValue(bean.getDevNum());
|
||||||
|
cell26.setCellStyle(style);
|
||||||
|
|
||||||
|
|
||||||
|
//第三行
|
||||||
|
Row row3 = sheet.createRow(2);
|
||||||
|
Cell cell31 = row3.createCell(0);
|
||||||
|
cell31.setCellValue("检测设备");
|
||||||
|
cell31.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell32 = row3.createCell(1);
|
||||||
|
cell32.setCellValue(bean.getDevTypeName());
|
||||||
|
cell32.setCellStyle(style);
|
||||||
|
addMergedRegion(2,2,1,totalNum-1,sheet);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//第四行
|
||||||
|
Row row4= sheet.createRow(3);
|
||||||
|
|
||||||
|
Cell cell41 = row4.createCell(0);
|
||||||
|
cell41.setCellValue("检测依据");
|
||||||
|
cell41.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell42 = row4.createCell(1);
|
||||||
|
cell42.setCellValue(yj);
|
||||||
|
cell42.setCellStyle(style);
|
||||||
|
addMergedRegion(3,3,1,totalNum-1,sheet);
|
||||||
|
|
||||||
|
//第5行 //第六行
|
||||||
|
Row row5= sheet.createRow(4);
|
||||||
|
Row row6= sheet.createRow(5);
|
||||||
|
//第五行//第六号合并
|
||||||
|
Cell cell51 = row5.createCell(0);
|
||||||
|
cell51.setCellValue("序号");
|
||||||
|
cell51.setCellStyle(style);
|
||||||
|
addMergedRegion(4,5,0,0,sheet);
|
||||||
|
|
||||||
|
Cell cell52 = row5.createCell(1);
|
||||||
|
cell52.setCellValue("样品编号");
|
||||||
|
cell52.setCellStyle(style);
|
||||||
|
addMergedRegion(4,5,1,1,sheet);
|
||||||
|
//
|
||||||
|
Cell cell53 = row5.createCell(2);
|
||||||
|
cell53.setCellValue("样品信息");
|
||||||
|
cell53.setCellStyle(style);
|
||||||
|
addMergedRegion(4,4,2,5,sheet);//
|
||||||
|
//第六行固定数据
|
||||||
|
Cell cell62= row6.createCell(2);
|
||||||
|
cell62.setCellStyle(style);
|
||||||
|
cell62.setCellValue("客户自编号");
|
||||||
|
Cell cell63 = row6.createCell(3);
|
||||||
|
cell63.setCellStyle(style);
|
||||||
|
cell63.setCellValue("生成厂家");
|
||||||
|
Cell cell64 = row6.createCell(4);
|
||||||
|
cell64.setCellStyle(style);
|
||||||
|
cell64.setCellValue("生产日期");
|
||||||
|
Cell cell65 = row6.createCell(5);
|
||||||
|
cell65.setCellStyle(style);
|
||||||
|
cell65.setCellValue("规格型号");
|
||||||
|
|
||||||
|
//第五第六号非固定数据
|
||||||
|
AtomicInteger num= new AtomicInteger(5);
|
||||||
|
AtomicInteger rowNums= new AtomicInteger(5);
|
||||||
|
configItemsVos.forEach(vo->{
|
||||||
|
List<ConfigItemVo> childList=vo.getItemList();
|
||||||
|
int rowNum=childList.size();
|
||||||
|
num.set(num.get() + 1);
|
||||||
|
Cell cell54 = row5.createCell(num.get());
|
||||||
|
cell54.setCellValue(vo.getExperTypeName());
|
||||||
|
cell54.setCellStyle(style);
|
||||||
|
addMergedRegion(4,4,num.get(),num.get()+rowNum-1,sheet);
|
||||||
|
num.addAndGet(rowNum-1);
|
||||||
|
childList.forEach(child->{
|
||||||
|
rowNums.set(rowNums.get() + 1);
|
||||||
|
Cell cell4 = row6.createCell(rowNums.get());
|
||||||
|
cell4.setCellStyle(style);
|
||||||
|
cell4.setCellValue(child.getItemName());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AtomicInteger row= new AtomicInteger(5);
|
||||||
|
AtomicInteger cellNum= new AtomicInteger(0);
|
||||||
|
if(ListHelper.isNotEmpty(devList)){
|
||||||
|
devList.forEach(dev->{
|
||||||
|
row.set(row.get() + 1);
|
||||||
|
Row row7= sheet.createRow(row.get());
|
||||||
|
|
||||||
|
Cell row71 = row7.createCell(cellNum.get());
|
||||||
|
cellNum.set(cellNum.get() + 1);
|
||||||
|
row71.setCellValue(cellNum.get());
|
||||||
|
row71.setCellStyle(style);
|
||||||
|
|
||||||
|
|
||||||
|
Cell row72 = row7.createCell(cellNum.get());
|
||||||
|
row72.setCellValue(dev.getCustomerCode());
|
||||||
|
row72.setCellStyle(style);
|
||||||
|
cellNum.set(cellNum.get() + 1);
|
||||||
|
|
||||||
|
Cell row73 = row7.createCell(cellNum.get());
|
||||||
|
row73.setCellValue(dev.getDevCode());
|
||||||
|
row73.setCellStyle(style);
|
||||||
|
cellNum.set(cellNum.get() + 1);
|
||||||
|
|
||||||
|
Cell row74 = row7.createCell(cellNum.get());
|
||||||
|
row74.setCellValue(dev.getManufacturer());
|
||||||
|
row74.setCellStyle(style);
|
||||||
|
cellNum.set(cellNum.get() + 1);
|
||||||
|
|
||||||
|
Cell row75= row7.createCell(cellNum.get());
|
||||||
|
row75.setCellValue(dev.getManufactureDate());
|
||||||
|
row75.setCellStyle(style);
|
||||||
|
cellNum.set(cellNum.get() + 1);
|
||||||
|
|
||||||
|
|
||||||
|
Cell row76= row7.createCell(cellNum.get());
|
||||||
|
row76.setCellValue(dev.getDevModule());
|
||||||
|
row76.setCellStyle(style);
|
||||||
|
cellNum.set(cellNum.get() + 1);
|
||||||
|
|
||||||
|
String val=dev.getDevData();
|
||||||
|
JSONArray jsonArray=JSON.parseArray(val);
|
||||||
|
|
||||||
|
jsonArray.forEach(json->{
|
||||||
|
Cell row77= row7.createCell(cellNum.get());
|
||||||
|
row77.setCellValue(json.toString());
|
||||||
|
row77.setCellStyle(style);
|
||||||
|
cellNum.set(cellNum.get() + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//
|
||||||
|
row.set(row.get() + 1);
|
||||||
|
Row row8= sheet.createRow(row.get());
|
||||||
|
Cell cell81 = row8.createCell(0);
|
||||||
|
cell81.setCellValue("技术要求");
|
||||||
|
cell81.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell82 = row8.createCell(1);
|
||||||
|
cell82.setCellValue(bean.getExperStand());
|
||||||
|
cell82.setCellStyle(style);
|
||||||
|
addMergedRegion(row.get(),row.get(),1,totalNum-1,sheet);
|
||||||
|
|
||||||
|
|
||||||
|
row.set(row.get() + 1);
|
||||||
|
Row row9= sheet.createRow(row.get());
|
||||||
|
|
||||||
|
Cell cell91 = row9.createCell(0);
|
||||||
|
cell91.setCellValue("检测结论");
|
||||||
|
cell91.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell92 = row9.createCell(1);
|
||||||
|
cell92.setCellValue(bean.getExperConclu());
|
||||||
|
cell92.setCellStyle(style);
|
||||||
|
addMergedRegion(row.get(),row.get(),1,totalNum-1,sheet);
|
||||||
|
|
||||||
|
|
||||||
|
row.set(row.get() + 1);
|
||||||
|
Row row10= sheet.createRow(row.get());
|
||||||
|
|
||||||
|
Cell cell101 = row10.createCell(0);
|
||||||
|
cell101.setCellValue("备注");
|
||||||
|
cell101.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell102 = row10.createCell(1);
|
||||||
|
cell102.setCellValue(bean.getRemarks());
|
||||||
|
cell102.setCellStyle(style);
|
||||||
|
addMergedRegion(row.get(),row.get(),1,totalNum-1,sheet);
|
||||||
|
|
||||||
|
|
||||||
|
row.set(row.get() + 1);
|
||||||
|
Row row11= sheet.createRow(row.get());
|
||||||
|
|
||||||
|
Cell cell111 = row11.createCell(0);
|
||||||
|
cell111.setCellValue("检测日期");
|
||||||
|
cell111.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell112 = row11.createCell(1);
|
||||||
|
cell112.setCellValue(bean.getExperTime());
|
||||||
|
cell112.setCellStyle(style);
|
||||||
|
int num112=(totalNum-2)/2;
|
||||||
|
addMergedRegion(row.get(),row.get(),1,num112,sheet);
|
||||||
|
|
||||||
|
Cell cell113 = row11.createCell(num112+1);
|
||||||
|
cell113.setCellValue("下次检测日期");
|
||||||
|
cell113.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell114= row11.createCell(num112+2);
|
||||||
|
cell114.setCellValue(bean.getNextExperTime());
|
||||||
|
cell114.setCellStyle(style);
|
||||||
|
addMergedRegion(row.get(),row.get(),num112+2,totalNum-1,sheet);
|
||||||
|
|
||||||
|
|
||||||
|
// 判断文件是否存在,不存在就创建
|
||||||
|
if (FileUtil.isEmpty(new File(path))) {
|
||||||
|
FileUtil.mkdir(path);
|
||||||
|
}
|
||||||
|
double math=Math.random();
|
||||||
|
// 5.生成一张表。03版本的工作簿是以.xls结尾
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream(path + math+".xls");
|
||||||
|
// 输出
|
||||||
|
workbook.write(fileOutputStream);
|
||||||
|
// 6.关闭流
|
||||||
|
fileOutputStream.close();
|
||||||
|
System.out.println("03表生成成功!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XSSFCellStyle centerStyle(XSSFWorkbook workbook){
|
||||||
|
XSSFCellStyle commonStyle = workbook.createCellStyle();
|
||||||
|
// 左右居中
|
||||||
|
commonStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
// 上下居中
|
||||||
|
commonStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
commonStyle.setLocked(true);
|
||||||
|
// 自动换行
|
||||||
|
commonStyle.setWrapText(false);
|
||||||
|
return commonStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并单元格
|
||||||
|
* @param startRow 开始行
|
||||||
|
* @param endRow 结束行
|
||||||
|
* @param startCol 开始列
|
||||||
|
* @param endCol 结束列
|
||||||
|
* @param sheet 创建的sheet页
|
||||||
|
*/
|
||||||
|
public static void addMergedRegion(int startRow,int endRow,int startCol,int endCol,Sheet sheet){
|
||||||
|
CellRangeAddress cra = new CellRangeAddress(startRow,endRow,startCol,endCol);
|
||||||
|
sheet.addMergedRegion(cra);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备编号--自动生成
|
* 设备编号--自动生成
|
||||||
* 生成规则:YYMMDDNNNN
|
* 生成规则:YYMMDDNNNN
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,228 @@
|
||||||
|
package com.bonus.aqgqj.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import io.netty.resolver.InetNameResolver;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
public class ExcelWriterTest03 {
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
int row =13;
|
||||||
|
|
||||||
|
// List<TestVo> list =getTestList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String path = "D:\\poi\\";
|
||||||
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||||
|
Sheet sheet = workbook.createSheet("检测报告");
|
||||||
|
//第一行
|
||||||
|
Row row1 = sheet.createRow(0);
|
||||||
|
//单元格-创建第一个头
|
||||||
|
Cell cell11 = row1.createCell(0);
|
||||||
|
cell11.setCellValue("安全帽检测报告");
|
||||||
|
//合并全部列
|
||||||
|
addMergedRegion(0,0,0,row-1,sheet);
|
||||||
|
XSSFCellStyle style= centerStyle(workbook);
|
||||||
|
cell11.setCellStyle(style);
|
||||||
|
|
||||||
|
|
||||||
|
//第二行
|
||||||
|
Row row2 = sheet.createRow(1);
|
||||||
|
Cell cell21 = row2.createCell(0);
|
||||||
|
cell21.setCellValue("报告编号");
|
||||||
|
cell21.setCellStyle(style);
|
||||||
|
//计算占用行数
|
||||||
|
int num21=(row-4)/2;
|
||||||
|
Cell cell22 = row2.createCell(1);
|
||||||
|
addMergedRegion(1,1,1,num21,sheet);
|
||||||
|
cell22.setCellValue("编号-value");
|
||||||
|
|
||||||
|
Cell cell23 = row2.createCell(num21+1);
|
||||||
|
cell23.setCellValue("收样日期");
|
||||||
|
cell23.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell24 = row2.createCell(num21+2);
|
||||||
|
cell24.setCellValue("收样日期-值");
|
||||||
|
cell24.setCellStyle(style);
|
||||||
|
addMergedRegion(1,1,num21+2,row-3,sheet);
|
||||||
|
|
||||||
|
Cell cell25 = row2.createCell(row-2);
|
||||||
|
cell25.setCellValue("样品数量");
|
||||||
|
cell25.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell26= row2.createCell(row-1);
|
||||||
|
cell26.setCellValue("样品数量-值");
|
||||||
|
cell26.setCellStyle(style);
|
||||||
|
|
||||||
|
|
||||||
|
//第三行
|
||||||
|
Row row3 = sheet.createRow(2);
|
||||||
|
Cell cell31 = row3.createCell(0);
|
||||||
|
cell31.setCellValue("检测设备");
|
||||||
|
cell31.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell32 = row3.createCell(1);
|
||||||
|
cell32.setCellValue("检测设备-值");
|
||||||
|
cell32.setCellStyle(style);
|
||||||
|
addMergedRegion(2,2,1,row-1,sheet);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//第四行
|
||||||
|
Row row4= sheet.createRow(3);
|
||||||
|
|
||||||
|
Cell cell41 = row4.createCell(0);
|
||||||
|
cell41.setCellValue("检测依据");
|
||||||
|
cell41.setCellStyle(style);
|
||||||
|
|
||||||
|
Cell cell42 = row4.createCell(1);
|
||||||
|
cell42.setCellValue("检测依据-值");
|
||||||
|
cell42.setCellStyle(style);
|
||||||
|
addMergedRegion(3,3,1,row-1,sheet);
|
||||||
|
|
||||||
|
//第5行 //第六行
|
||||||
|
Row row5= sheet.createRow(4);
|
||||||
|
Row row6= sheet.createRow(5);
|
||||||
|
//第五行//第六号合并
|
||||||
|
Cell cell51 = row5.createCell(0);
|
||||||
|
cell51.setCellValue("序号");
|
||||||
|
cell51.setCellStyle(style);
|
||||||
|
addMergedRegion(4,5,0,0,sheet);
|
||||||
|
|
||||||
|
Cell cell52 = row5.createCell(1);
|
||||||
|
cell52.setCellValue("样品编号");
|
||||||
|
cell52.setCellStyle(style);
|
||||||
|
addMergedRegion(4,5,1,1,sheet);
|
||||||
|
//
|
||||||
|
Cell cell53 = row5.createCell(2);
|
||||||
|
cell53.setCellValue("样品信息");
|
||||||
|
cell53.setCellStyle(style);
|
||||||
|
addMergedRegion(4,4,2,5,sheet);//
|
||||||
|
//第六行固定数据
|
||||||
|
Cell cell62= row6.createCell(2);
|
||||||
|
cell62.setCellStyle(style);
|
||||||
|
cell62.setCellValue("客户自编号");
|
||||||
|
Cell cell63 = row6.createCell(3);
|
||||||
|
cell63.setCellStyle(style);
|
||||||
|
cell63.setCellValue("生成厂家");
|
||||||
|
Cell cell64 = row6.createCell(4);
|
||||||
|
cell64.setCellStyle(style);
|
||||||
|
cell64.setCellValue("生产日期");
|
||||||
|
Cell cell65 = row6.createCell(5);
|
||||||
|
cell65.setCellStyle(style);
|
||||||
|
cell65.setCellValue("规格型号");
|
||||||
|
|
||||||
|
//第五第六号非固定数据
|
||||||
|
AtomicInteger num= new AtomicInteger(5);
|
||||||
|
AtomicInteger rowNums= new AtomicInteger(5);
|
||||||
|
// list.forEach(vo->{
|
||||||
|
// List<TestVo> childList=vo.getData();
|
||||||
|
// int rowNum=childList.size();
|
||||||
|
// num.set(num.get() + 1);
|
||||||
|
// Cell cell54 = row5.createCell(num.get());
|
||||||
|
// cell54.setCellValue(vo.getName());
|
||||||
|
// cell54.setCellStyle(style);
|
||||||
|
// addMergedRegion(4,4,num.get(),num.get()+rowNum-1,sheet);
|
||||||
|
// num.addAndGet(rowNum-1);
|
||||||
|
// childList.forEach(child->{
|
||||||
|
// rowNums.set(rowNums.get() + 1);
|
||||||
|
// Cell cell4 = row6.createCell(rowNums.get());
|
||||||
|
// cell4.setCellStyle(style);
|
||||||
|
// cell4.setCellValue(child.getName());
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 判断文件是否存在,不存在就创建
|
||||||
|
if (FileUtil.isEmpty(new File(path))) {
|
||||||
|
FileUtil.mkdir(path);
|
||||||
|
}
|
||||||
|
// 5.生成一张表。03版本的工作簿是以.xls结尾
|
||||||
|
FileOutputStream fileOutputStream = new FileOutputStream(path + "03.xls");
|
||||||
|
// 输出
|
||||||
|
workbook.write(fileOutputStream);
|
||||||
|
// 6.关闭流
|
||||||
|
fileOutputStream.close();
|
||||||
|
System.out.println("03表生成成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XSSFCellStyle centerStyle(XSSFWorkbook workbook){
|
||||||
|
XSSFCellStyle commonStyle = workbook.createCellStyle();
|
||||||
|
// 左右居中
|
||||||
|
commonStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
// 上下居中
|
||||||
|
commonStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
commonStyle.setLocked(true);
|
||||||
|
// 自动换行
|
||||||
|
commonStyle.setWrapText(false);
|
||||||
|
return commonStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并单元格
|
||||||
|
* @param startRow 开始行
|
||||||
|
* @param endRow 结束行
|
||||||
|
* @param startCol 开始列
|
||||||
|
* @param endCol 结束列
|
||||||
|
* @param sheet 创建的sheet页
|
||||||
|
*/
|
||||||
|
public static void addMergedRegion(int startRow,int endRow,int startCol,int endCol,Sheet sheet){
|
||||||
|
CellRangeAddress cra = new CellRangeAddress(startRow,endRow,startCol,endCol);
|
||||||
|
sheet.addMergedRegion(cra);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public static List<TestVo> getTestList(){
|
||||||
|
// List<TestVo> list=new ArrayList<>();
|
||||||
|
// List<TestVo> childeList=new ArrayList<>();
|
||||||
|
// List<TestVo> childeList2=new ArrayList<>();
|
||||||
|
// TestVo vo=new TestVo();
|
||||||
|
// vo.setName("测试1");
|
||||||
|
// TestVo vo11=new TestVo();
|
||||||
|
// vo11.setName("测试1-1");
|
||||||
|
// childeList.add(vo11);
|
||||||
|
// TestVo vo12=new TestVo();
|
||||||
|
// vo12.setName("测试1-2");
|
||||||
|
// childeList.add(vo12);
|
||||||
|
// TestVo vo13=new TestVo();
|
||||||
|
// vo13.setName("测试1-3");
|
||||||
|
// childeList.add(vo13);
|
||||||
|
// TestVo vo14=new TestVo();
|
||||||
|
// vo14.setName("测试1-4");
|
||||||
|
// childeList.add(vo14);
|
||||||
|
// vo.setData(childeList);
|
||||||
|
//
|
||||||
|
// list.add(vo);
|
||||||
|
// TestVo vo2=new TestVo();
|
||||||
|
// vo2.setName("测试2");
|
||||||
|
// TestVo vo21=new TestVo();
|
||||||
|
// vo21.setName("测试2-1");
|
||||||
|
// childeList2.add(vo21);
|
||||||
|
// TestVo vo22=new TestVo();
|
||||||
|
// vo22.setName("测试2-2");
|
||||||
|
// childeList2.add(vo22);
|
||||||
|
// TestVo vo23=new TestVo();
|
||||||
|
// vo23.setName("测试2-3");
|
||||||
|
// childeList2.add(vo23);
|
||||||
|
// vo2.setData(childeList2);
|
||||||
|
// list.add(vo2);
|
||||||
|
// return list;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.bonus.aqgqj.utils;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* excel 导出功能
|
||||||
|
* @author 黑子
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ExportUtils {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总列数
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
|
public void CreateWorkbook(int row){
|
||||||
|
Workbook workbook=new HSSFWorkbook();
|
||||||
|
Sheet sheet = workbook.createSheet("检测报告");
|
||||||
|
//第一行
|
||||||
|
Row row1 = sheet.createRow(0);
|
||||||
|
//单元格-创建第一个头
|
||||||
|
Cell cell11 = row1.createCell(0,row);
|
||||||
|
cell11.setCellValue("安全帽检测报告");
|
||||||
|
//合并全部列
|
||||||
|
addMergedRegion(1,1,0,row,sheet);
|
||||||
|
|
||||||
|
|
||||||
|
//第二行
|
||||||
|
Row row2 = sheet.createRow(1);
|
||||||
|
Cell cell21 = row2.createCell(0);
|
||||||
|
cell21.setCellValue("报告编号");
|
||||||
|
//计算占用行数
|
||||||
|
int num21=(row-4)/2;
|
||||||
|
Cell cell22 = row2.createCell(1,num21);
|
||||||
|
cell22.setCellValue("编号-value");
|
||||||
|
// Cell cell22 = row2.createCell(0);
|
||||||
|
// cell22.setCellValue("报告编号");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并单元格
|
||||||
|
* @param startRow 开始行
|
||||||
|
* @param endRow 结束行
|
||||||
|
* @param startCol 开始列
|
||||||
|
* @param endCol 结束列
|
||||||
|
* @param sheet 创建的sheet页
|
||||||
|
*/
|
||||||
|
public void addMergedRegion(int startRow,int endRow,int startCol,int endCol,Sheet sheet){
|
||||||
|
CellRangeAddress cra = new CellRangeAddress(1,2,0,1);
|
||||||
|
sheet.addMergedRegion(cra);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void createRow(Row row1,int startNum,int endNum){
|
||||||
|
for (int i = startNum; i < endNum; i++) {
|
||||||
|
Cell cell11 = row1.createCell(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
LEFT JOIN sys_user su on su.id=te.create_user and su.del_flag=0
|
LEFT JOIN sys_user su on su.id=te.create_user and su.del_flag=0
|
||||||
WHERE
|
WHERE
|
||||||
is_hg=0
|
is_hg=0
|
||||||
|
and tsd.dev_type_name is not null
|
||||||
<if test="sampleTools != null and sampleTools != ''">
|
<if test="sampleTools != null and sampleTools != ''">
|
||||||
and tsd.dev_type_name like concat('%',#{sampleTools}, '%')
|
and tsd.dev_type_name like concat('%',#{sampleTools}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
|
|
@ -97,14 +97,14 @@ function initTable(dataList, limit, page) {
|
||||||
return (page - 1) * limit + d.LAY_INDEX;
|
return (page - 1) * limit + d.LAY_INDEX;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field: "customName", title: "送样单位", unresize: true, align: "center"},
|
{field: "customName", width:260,title: "送样单位", unresize: true, align: "center"},
|
||||||
{field: "sampleUser", title: "送样人", unresize: true, align: "center"},
|
{field: "sampleUser", width:150,title: "送样人", unresize: true, align: "center"},
|
||||||
{field: "sampleTime", title: "送样时间", unresize: true, align: "center"},
|
{field: "sampleTime", width:210,title: "送样时间", unresize: true, align: "center"},
|
||||||
{field: "sampleTools", title: "送样设备", unresize: true, align: "center"},
|
{field: "sampleTools", width:280,title: "送样设备", unresize: true, align: "center"},
|
||||||
{field: "collectSamplesUser", title: "收样人", unresize: true, align: "center"},
|
{field: "collectSamplesUser", width:140,title: "收样人", unresize: true, align: "center"},
|
||||||
{field: "collectSamplesTime", title: "收样时间", unresize: true, align: "center"},
|
{field: "collectSamplesTime", width:210,title: "收样时间", unresize: true, align: "center"},
|
||||||
{
|
{
|
||||||
field: "teamName", title: "试验班组", unresize: true, align: "center", templet: function (d) {
|
field: "teamName", width:210,title: "试验班组", unresize: true, align: "center", templet: function (d) {
|
||||||
let html = '';
|
let html = '';
|
||||||
let view ='';
|
let view ='';
|
||||||
if (d.teamName == null) {
|
if (d.teamName == null) {
|
||||||
|
|
@ -116,7 +116,7 @@ function initTable(dataList, limit, page) {
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{title: "操作", unresize: true, width: 85, align: "center",
|
{title: "操作", unresize: true, width: 80, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
|
|
||||||
let html = '';
|
let html = '';
|
||||||
|
|
|
||||||
|
|
@ -98,11 +98,11 @@ function initTable(dataList, limit, page) {
|
||||||
return (page - 1) * limit + d.LAY_NUM;
|
return (page - 1) * limit + d.LAY_NUM;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field: "sampleTools", width: 150, title: "设备类型", unresize: true, align: "center"},
|
{field: "sampleTools", width: 230, title: "设备类型", unresize: true, align: "center"},
|
||||||
{field: "reportCode", title: "报告编号", unresize: true, align: "center"},
|
{field: "reportCode", width: 263,title: "报告编号", unresize: true, align: "center"},
|
||||||
{field: "sampleDepartment",width: 130, title: "送样部门", unresize: true, align: "center"},
|
{field: "sampleDepartment",width: 230, title: "送样部门", unresize: true, align: "center"},
|
||||||
{field: "devModule", title: "规格型号", unresize: true, align: "center"},
|
{field: "devModule",width: 230, title: "规格型号", unresize: true, align: "center"},
|
||||||
{field: "", title: "样品数量", width: 110, unresize: true, align: "center",
|
{field: "", title: "样品数量", width: 115, unresize: true, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
var testResult="";
|
var testResult="";
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|
@ -135,7 +135,7 @@ function initTable(dataList, limit, page) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "isHg", title: "检测结果", unresize: true, align: "center",
|
field: "isHg",width: 150, title: "检测结果", unresize: true, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
if (d.isHg === "0") {
|
if (d.isHg === "0") {
|
||||||
return "合格";
|
return "合格";
|
||||||
|
|
@ -144,9 +144,9 @@ function initTable(dataList, limit, page) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field: "detectionTime", title: "检测时间", unresize: true, align: "center"},
|
{field: "detectionTime",width: 230, title: "检测时间", unresize: true, align: "center"},
|
||||||
{
|
{
|
||||||
field: "view1", title: "检测报告",width: 110, unresize: true, align: "center",
|
field: "view1", title: "检测报告",width: 115, unresize: true, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
return '<a href="#" style="color: blue;" onclick="handleClick1(\'' + d.id + '\',\'' + d.isHg + '\',\'' + d.departmentId + '\',\'' + d.sampleTools + '\')">查看</a>';
|
return '<a href="#" style="color: blue;" onclick="handleClick1(\'' + d.id + '\',\'' + d.isHg + '\',\'' + d.departmentId + '\',\'' + d.sampleTools + '\')">查看</a>';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,14 +103,14 @@ function initTable(dataList, limit, page) {
|
||||||
return (page - 1) * limit + d.LAY_NUM;
|
return (page - 1) * limit + d.LAY_NUM;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field: "customName", title: "送样单位", unresize: true, align: "center"},
|
{field: "customName", width: 260,title: "送样单位", unresize: true, align: "center"},
|
||||||
{field: "sampleTime", title: "送样时间", unresize: true, align: "center"},
|
{field: "sampleTime", width: 250,title: "送样时间", unresize: true, align: "center"},
|
||||||
{field: "sampleTools", title: "送样设备", unresize: true, align: "center"},
|
{field: "sampleTools", width: 270,title: "送样设备", unresize: true, align: "center"},
|
||||||
{field: "devNum", title: "样品数量", unresize: true, align: "center"},
|
{field: "devNum", width: 150,title: "样品数量", unresize: true, align: "center"},
|
||||||
{field: "collectSamplesUser", title: "收样人", unresize: true, align: "center"},
|
{field: "collectSamplesUser", width: 150,title: "收样人", unresize: true, align: "center"},
|
||||||
{field: "collectSamplesTime", title: "收样时间", unresize: true, align: "center"},
|
{field: "collectSamplesTime", width: 180,title: "收样时间", unresize: true, align: "center"},
|
||||||
{
|
{
|
||||||
field: "teamName", title: "试验班组", unresize: true, align: "center", templet: function (d) {
|
field: "teamName", width: 200,title: "试验班组", unresize: true, align: "center", templet: function (d) {
|
||||||
let html = '';
|
let html = '';
|
||||||
let view ='';
|
let view ='';
|
||||||
if (d.teamName == null) {
|
if (d.teamName == null) {
|
||||||
|
|
@ -158,8 +158,6 @@ function getCheckedValues() {
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
ids.push(data[i].id);
|
ids.push(data[i].id);
|
||||||
}
|
}
|
||||||
console.log("ids1:", ids);
|
|
||||||
console.log("ids2:", ids.join(','))
|
|
||||||
// 将 ids 数组用逗号分隔成字符串
|
// 将 ids 数组用逗号分隔成字符串
|
||||||
return ids.join(',');
|
return ids.join(',');
|
||||||
}
|
}
|
||||||
|
|
@ -242,6 +240,28 @@ function addData(id) {
|
||||||
openIframe2("addOrEditUser", title, "child/testReportForm.html", '100%', '100%', param);
|
openIframe2("addOrEditUser", title, "child/testReportForm.html", '100%', '100%', param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载
|
||||||
|
*/
|
||||||
|
function downloadClick() {
|
||||||
|
var ids =getCheckedValues();
|
||||||
|
if (ids==='') {
|
||||||
|
return layer.msg('请选择需要下载的数据', {icon: 7})
|
||||||
|
}
|
||||||
|
let loadingMsg = layer.msg('数据下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
||||||
|
let url = dataUrl + '/testReport/download';
|
||||||
|
let params = {
|
||||||
|
'ids': ids
|
||||||
|
}
|
||||||
|
params = {
|
||||||
|
encryptedData: encryptCBC(JSON.stringify(params))
|
||||||
|
}
|
||||||
|
ajaxRequest(url, "POST", params, true, function () {
|
||||||
|
layer.close(loadingMsg);
|
||||||
|
window.location.href = dataUrl + '/testReport/download?ids=' + ids;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收样
|
* 收样
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -84,28 +84,28 @@ function initTable(dataList, limit, page) {
|
||||||
[
|
[
|
||||||
{type: "checkbox", width: 50, unresize: true, align: "center"},
|
{type: "checkbox", width: 50, unresize: true, align: "center"},
|
||||||
//表头
|
//表头
|
||||||
{title: "序号", width: 80, unresize: true, align: "center",
|
{title: "序号", width: 70, unresize: true, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
return (page - 1) * limit + d.LAY_INDEX;
|
return (page - 1) * limit + d.LAY_INDEX;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field: "sampleTools", title: "设备类型", unresize: true, align: "center"},
|
{field: "sampleTools", width:155,title: "设备类型", unresize: true, align: "center"},
|
||||||
{field: "devCode", title: "设备编号", unresize: true, align: "center"},
|
{field: "devCode", width:150,title: "设备编号", unresize: true, align: "center"},
|
||||||
{field: "customerCode", title: "设备编码", unresize: true, align: "center"},
|
{field: "customerCode", width:150,title: "设备编码", unresize: true, align: "center"},
|
||||||
{field: "devModule", title: "设备规格", unresize: true, align: "center"},
|
{field: "devModule", width:150,title: "设备规格", unresize: true, align: "center"},
|
||||||
{field: "customName", title: "送样单位", unresize: true, align: "center"},
|
{field: "customName", width:175,title: "送样单位", unresize: true, align: "center"},
|
||||||
{field: "sampleDepartment", title: "送样部门", unresize: true, align: "center"},
|
{field: "sampleDepartment", width:170,title: "送样部门", unresize: true, align: "center"},
|
||||||
{field: "manufactureDate", title: "生产日期", unresize: true, align: "center"},
|
{field: "manufactureDate", width:150,title: "生产日期", unresize: true, align: "center"},
|
||||||
{field: "experTime", title: "试验日期", unresize: true, align: "center"},
|
{field: "experTime", width:150,title: "试验日期", unresize: true, align: "center"},
|
||||||
{field: "experConclu", title: "试验结果", unresize: true, align: "center"},
|
{field: "experConclu", width:120,title: "试验结果", unresize: true, align: "center"},
|
||||||
{
|
{
|
||||||
field: "certificate", title: "合格证",width: '6%', unresize: true, align: "center", templet: function (d) {
|
field: "certificate", title: "合格证",width:90, unresize: true, align: "center", templet: function (d) {
|
||||||
console.log("d",d.id);
|
console.log("d",d.id);
|
||||||
return '<a href="#" style="color: blue;" onclick="handleClick1(\'' + d.submitLocation + '\',\'' + d.sampleTools + '\',\'' + d.devModule + '\',\'' + d.devCode + '\',\'' + d.experTime + '\',\'' + d.nextExperTime + '\',\'' + d.experUser + '\',\'' + d.experConclu + '\',\'' + d.customName + '\')">查看</a>';
|
return '<a href="#" style="color: blue;" onclick="handleClick1(\'' + d.submitLocation + '\',\'' + d.sampleTools + '\',\'' + d.devModule + '\',\'' + d.devCode + '\',\'' + d.experTime + '\',\'' + d.nextExperTime + '\',\'' + d.experUser + '\',\'' + d.experConclu + '\',\'' + d.customName + '\')">查看</a>';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "qrCode", title: "二维码", width: '6%', unresize: true, align: "center", templet: function (d) {
|
field: "qrCode", title: "二维码", width: 90, unresize: true, align: "center", templet: function (d) {
|
||||||
return '<a href="#" style="color: blue;" onclick="handleClick2(\'' + d.submitLocation + '\',\'' + d.sampleTools + '\',\'' + d.devModule + '\',\'' + d.devCode + '\',\'' + d.experTime + '\',\'' + d.nextExperTime + '\',\'' + d.experUser + '\',\'' + d.experConclu + '\',\'' + d.customName + '\')">打印</a>';
|
return '<a href="#" style="color: blue;" onclick="handleClick2(\'' + d.submitLocation + '\',\'' + d.sampleTools + '\',\'' + d.devModule + '\',\'' + d.devCode + '\',\'' + d.experTime + '\',\'' + d.nextExperTime + '\',\'' + d.experUser + '\',\'' + d.experConclu + '\',\'' + d.customName + '\')">打印</a>';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@
|
||||||
<div class="layui-inline btns">
|
<div class="layui-inline btns">
|
||||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" onclick="query(1)">查询
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" onclick="query(1)">查询
|
||||||
</button>
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm btn-1" onclick="downloadClick()"><i class="layui-icon layui-icon-download-circle" style="font-size: 24px;"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue