优化企业导入流程和新增模板下载接口

This commit is contained in:
SUNJIABIN
2023-03-30 15:36:23 +08:00
parent 6bddbb8e77
commit fd2d8bbc57
5 changed files with 513 additions and 384 deletions
@@ -156,6 +156,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/importSarBussionessStandFile"); addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/importSarBussionessStandFile");
addInterceptor.excludePathPatterns("/api/sarLawsDetailedList/sar-laws-detailed-list/importData"); addInterceptor.excludePathPatterns("/api/sarLawsDetailedList/sar-laws-detailed-list/importData");
//企标标准导入模板下载
addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/exportTemplateFile");
//doc文檔重新轉換 //doc文檔重新轉換
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_GNW"); addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_GNW");
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_QB"); addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_QB");
@@ -1,6 +1,7 @@
package com.adc.da.slrs.sarBussionessStand.controller; package com.adc.da.slrs.sarBussionessStand.controller;
import cn.hutool.core.util.ZipUtil;
import com.adc.da.Log.BusinessType; import com.adc.da.Log.BusinessType;
import com.adc.da.Log.EpcLog; import com.adc.da.Log.EpcLog;
import com.adc.da.common.FileUnZip; import com.adc.da.common.FileUnZip;
@@ -21,6 +22,7 @@ import com.adc.da.http.PageInfo;
import com.adc.da.http.ResponseMessage; import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result; import com.adc.da.http.Result;
import com.adc.da.util.LoginUserUtil; import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.util.exception.AdcDaBaseException; import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.utils.IOUtils; import com.adc.da.util.utils.IOUtils;
import com.adc.da.util.utils.StringUtils; import com.adc.da.util.utils.StringUtils;
@@ -31,7 +33,10 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -46,9 +51,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.*;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@@ -438,5 +441,67 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
public ResponseMessage newRpetitionFile (){ public ResponseMessage newRpetitionFile (){
return sarBussionessStandEOService.newRpetitionFile(); return sarBussionessStandEOService.newRpetitionFile();
} }
@ApiOperation(value = "|SarBussionessStand|导入模板下载")
@GetMapping("/exportTemplateFile")
public void exportTemplateFile(String fileName,HttpServletResponse response, HttpServletRequest request)throws Exception{
OutputStream os = null;
OutputStream excelOS = null;
HSSFWorkbook workbook = new HSSFWorkbook();
String fileOriName = "标准导入模板";
if (org.apache.commons.lang3.StringUtils.isNotEmpty(fileName)) {
fileOriName = fileName;
}
try{
//创建临时文件夹
String fileNowPath = filePath + "/tempZip/" + UUIDUtils.randomUUID20() + "/" + fileOriName;
File nowFile = new File(fileNowPath);
if (nowFile.exists()){
nowFile.delete();
}
nowFile.mkdirs();
String fileName2 = "导入模板.xls";
HSSFSheet sheetItems = workbook.createSheet("模板");
sheetItems.setDefaultColumnWidth(16);
HSSFCellStyle cellStyle =workbook.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
Row rowHeader = sheetItems.createRow(0);//开始创建标题行
String exportFieldName = FieldConvertUtil.exportFieldName;
if (org.apache.commons.lang3.StringUtils.isNotBlank(exportFieldName)) {
String[] headerArr = exportFieldName.split(",");
for (int i=0;i < headerArr.length; i++) {
rowHeader.createCell(i).setCellValue(headerArr[i]);
}
}
String repFileName = fileName2.replaceAll("/","_");
excelOS = new FileOutputStream(fileNowPath + "/" + repFileName);
response.setHeader("Content-Disposition",
"attachment; filename=\""+ ReadExcel.encodeFileName(fileOriName+".zip", request) +"\"");
response.setContentType("application/force-download");
response.flushBuffer();
os = response.getOutputStream();
workbook.write(excelOS);
excelOS.flush();
excelOS.close();
ZipUtil.zip(fileNowPath,fileNowPath+".zip");
FileInputStream fis = new FileInputStream(fileNowPath+".zip");
int len = 0;
while ((len = fis.read()) != -1) {
os.write(len);
}
os.flush();
os.close(); // 后开先关
fis.close(); // 先开后关
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new com.adc.da.exception.AdcDaBaseException("下载文件失败,请重试");
} finally {
org.apache.poi.util.IOUtils.closeQuietly(os);
org.apache.poi.util.IOUtils.closeQuietly(excelOS);
}
}
} }
@@ -66,6 +66,7 @@ import com.adc.da.slrs.sarStandardsInfo.entity.SarBussionessStandEOPage;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService; import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.slrs.sarVppsTree.dao.SarVppsTreeDao;
import com.adc.da.slrs.sysInfo.service.SysInfoEOService; import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
import com.adc.da.sys.constant.ValueStateEnum; import com.adc.da.sys.constant.ValueStateEnum;
import com.adc.da.sys.dao.DicTypeEODao; import com.adc.da.sys.dao.DicTypeEODao;
@@ -106,6 +107,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.net.ssl.*; import javax.net.ssl.*;
@@ -251,6 +253,9 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Autowired @Autowired
private ITsResourceService tsResourceService; private ITsResourceService tsResourceService;
@Autowired
private SarVppsTreeDao sarVppsTreeDao;
@Override @Override
public SarBussionessStand getStandInfoByReviseStatus(String reviseStatus,String standSort,String taskId){ public SarBussionessStand getStandInfoByReviseStatus(String reviseStatus,String standSort,String taskId){
SarBussionessStand bussionessStand = new SarBussionessStand(); SarBussionessStand bussionessStand = new SarBussionessStand();
@@ -2036,437 +2041,484 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
public ResponseMessage<String> importSarBussionessStandFile(MultipartFile file,String menuId)throws Exception { public ResponseMessage<String> importSarBussionessStandFile(MultipartFile file,String menuId)throws Exception {
List<TsResource> tsResources = tsResourceService.getByMenuId(menuId); List<TsResource> tsResources = tsResourceService.getByMenuId(menuId);
if (ObjectUtils.isEmpty(tsResources)){ if (ObjectUtils.isNotEmpty(tsResources)) {
return Result.error("请选择目录进行导入"); //给出头部信息
} String[] headerExcel = {"企标类别,标准年份,企标编号,中文名称,英文名称,文本状态,发布日期,企标实施日期,企标制修订状态,起草部门,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿附件,编制说明附件,历史版本附件,其他文件附件,修改单附件,关联文件附件,"};
//获取文件全称
String fileNameStr = file.getOriginalFilename();
//获取最后.的位置
int pos = fileNameStr.lastIndexOf(".");
//获取压缩文件名称并以小写显示
String fileStr = fileNameStr.substring(pos + 1).toLowerCase();
//校验是否是zip文件
if (!fileStr.equals("zip")) {
return Result.error("请上传zip格式的文件");
}
//进行拼接获取文件名称
String fileName = fileNameStr.substring(0, pos);
//获取路径和文件名称
String path = filePath + "/" + fileName;
//给出头部信息 File saveDirectory = new File(path);
String[] headerExcel = {"企标类别,标准年份,企标编号,中文名称,英文名称,文本状态,发布日期,企标实施日期,企标制修订状态,起草部门,废止日期,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,上传时间,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--乘用车vpps中文名称,关联模块--卡车VPPS编码,关联模块--卡车vpps中文名称,发布稿附件,编制说明附件,历史版本附件,其他文件附件,修改单附件,关联文件附件,"}; //判断saveDirectory中是否是文件夹
if (!saveDirectory.isDirectory()) {
//获取文件全称 saveDirectory.mkdir();
String fileNameStr = file.getOriginalFilename(); }
//获取最后.的位置 //将文件写入到指定路径中
int pos = fileNameStr.lastIndexOf("."); FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path + "/" + fileNameStr));
//获取压缩文件名称并以小写显示 int countSuccess = 0;
String fileStr = fileNameStr.substring(pos + 1).toLowerCase(); try {
//校验是否是zip文件 //解压缩
if (!fileStr.equals("zip")){ String zipEntryName = FileUnZip.unZipFiles(path + "/" + fileNameStr, path);
return Result.error("请上传zip格式的文件"); //获取文件信息
} List<File> fileList = readImpExcelFile(zipEntryName);
//进行拼接获取文件名称 //判断获取到的文件数量
String fileName = fileNameStr.substring(0,pos); if (fileList.size() < 1) {
//获取路径和文件名称 return Result.error("上传的文件是空文件");
String path = filePath + "/" + fileName;
File saveDirectory = new File(path);
//判断saveDirectory中是否是文件夹
if (!saveDirectory.isDirectory()){
saveDirectory.mkdir();
}
//将文件写入到指定路径中
FileUtils.copyInputStreamToFile(file.getInputStream(),new File(path + "/" + fileNameStr));
int countSuccess = 0;
try {
//解压缩
String zipEntryName = FileUnZip.unZipFiles(path + "/" + fileNameStr, path);
//获取文件信息
List<File> fileList = readImpExcelFile(zipEntryName);
//判断获取到的文件数量
if (fileList.size() < 1){
return Result.error("上传的文件是空文件");
}
//File excelfile = fileList.get(0);
int excel = 0;
for (File fileInfo:fileList){
String infoJson = "";
if (fileInfo.getName().contains(".xls") || fileInfo.getName().contains(".xlsx")) {
excel =excel+1;
if (excel > 1){
return Result.error("导入了多个Excel文件");
} }
Workbook workbook = null; //File excelfile = fileList.get(0);
try { int excel = 0;
workbook = WorkbookFactory.create(fileInfo); for (File fileInfo : fileList) {
if (workbook != null){ String infoJson = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if (fileInfo.getName().contains(".xls") || fileInfo.getName().contains(".xlsx")) {
Sheet sheet = workbook.getSheetAt(0); excel = excel + 1;
if (sheet != null){ if (excel > 1) {
StringBuilder sb = new StringBuilder(); return Result.error("导入了多个Excel文件");
//获取总条数 }
int rowNum = sheet.getLastRowNum(); Workbook workbook = null;
//循环遍历 try {
for (int i = 0;i <= rowNum;i++){ workbook = WorkbookFactory.create(fileInfo);
Row row = sheet.getRow(i); if (workbook != null) {
Row headerRow = sheet.getRow(0); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
boolean isBlank = sarLawsInfoEOService.isRowEmpty(row); Sheet sheet = workbook.getSheetAt(0);
if (row != null && !isBlank) { if (sheet != null) {
int columNos = headerRow.getLastCellNum();// 表头总共的列数 StringBuilder sb = new StringBuilder();
Map<String, String> rowList = new LinkedHashMap<>(); //获取总条数
for (int j = 0; j < columNos; j++) { int rowNum = sheet.getLastRowNum();
Cell cell = row.getCell(j); //循环遍历
Cell headerCell = headerRow.getCell(j); for (int i = 0; i <= rowNum; i++) {
if (cell != null) { Row row = sheet.getRow(i);
if (i == 0) { Row headerRow = sheet.getRow(0);
cell.setCellType(CellType.STRING); boolean isBlank = sarLawsInfoEOService.isRowEmpty(row);
sb.append(cell.getStringCellValue() + ","); if (row != null && !isBlank) {
} else { int columNos = headerRow.getLastCellNum();// 表头总共的列数
if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) { Map<String, String> rowList = new LinkedHashMap<>();
Date d = cell.getDateCellValue(); for (int j = 0; j < columNos; j++) {
rowList.put(headerCell.getStringCellValue(), sdf.format(d)); Cell cell = row.getCell(j);
} else { Cell headerCell = headerRow.getCell(j);
cell.setCellType(CellType.STRING); if (cell != null) {
rowList.put(headerCell.getStringCellValue(), cell.getStringCellValue()); if (i == 0) {
} cell.setCellType(CellType.STRING);
} sb.append(cell.getStringCellValue() + ",");
} else { } else {
if (i != 0) { if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) {
rowList.put(headerCell.getStringCellValue(), ""); Date d = cell.getDateCellValue();
} rowList.put(headerCell.getStringCellValue(), sdf.format(d));
} } else {
} cell.setCellType(CellType.STRING);
String fields = StringUtils.join(headerExcel); rowList.put(headerCell.getStringCellValue(), cell.getStringCellValue());
String excelHeader = sb.toString(); }
if (!fields.equals(excelHeader)) { }
workbook.close(); } else {
//删除原上传文件 if (i != 0) {
FileUnZip.deleteDir(saveDirectory); rowList.put(headerCell.getStringCellValue(), "");
return Result.error("fail", "读取失败,请严格按照模板文件导入数据"); }
} }
SarBussStandAttrInfoExecl sarBussStandAttrInfo = new SarBussStandAttrInfoExecl(); }
if (i != 0) { String fields = StringUtils.join(headerExcel);
String excelHeader = sb.toString();
if (!fields.equals(excelHeader)) {
workbook.close();
//删除原上传文件
FileUnZip.deleteDir(saveDirectory);
return Result.error("fail", "读取失败,请严格按照模板文件导入数据");
}
SarBussStandAttrInfoExecl sarBussStandAttrInfo = new SarBussStandAttrInfoExecl();
if (i != 0) {
String standSort = rowList.get("企标类别"); String standSort = rowList.get("企标类别");
if (StringUtils.isNotBlank(standSort)){ if (StringUtils.isNotBlank(standSort)) {
if (standSort.length() > 100){ if (standSort.length() > 100) {
return Result.error("企标类别输入过长"); return Result.error("企标类别输入过长");
} }
sarBussStandAttrInfo.setStandSort(standSort); sarBussStandAttrInfo.setStandSort(standSort);
}else { } else {
return Result.error("企标类别不能为空"); return Result.error("企标类别不能为空");
} }
String standYear = rowList.get("标准年份"); String standYear = rowList.get("标准年份");
if (StringUtils.isNotBlank(standYear)){ if (StringUtils.isNotBlank(standYear)) {
if (standYear.length() > 100){ if (standYear.length() > 100) {
return Result.error("标准年份输入过长"); return Result.error("标准年份输入过长");
} }
sarBussStandAttrInfo.setStandYear(standYear); sarBussStandAttrInfo.setStandYear(standYear);
}else { } else {
return Result.error("标准年份不能为空"); return Result.error("标准年份不能为空");
} }
String standNumber = rowList.get("企标编号"); String standNumber = rowList.get("企标编号");
sarBussStandAttrInfo.setStandNumber(standNumber); sarBussStandAttrInfo.setStandNumber(standNumber);
String standName = rowList.get("中文名称"); String standName = rowList.get("中文名称");
if(StringUtils.isNotBlank(standName)){ if (StringUtils.isNotBlank(standName)) {
if(standName.length()>100){ if (standName.length() > 100) {
return Result.error("输入的标准名称过长"); return Result.error("输入的标准名称过长");
} }
sarBussStandAttrInfo.setStandName(standName); sarBussStandAttrInfo.setStandName(standName);
}else { } else {
return Result.error("中文名称不能为空"); return Result.error("中文名称不能为空");
} }
String standEnName = rowList.get("英文名称"); String standEnName = rowList.get("英文名称");
sarBussStandAttrInfo.setStandEnName(standEnName); sarBussStandAttrInfo.setStandEnName(standEnName);
String textStatusBuss = rowList.get("文本状态"); String textStatusBuss = rowList.get("文本状态");
if (StringUtils.isNotBlank(textStatusBuss)){ if (StringUtils.isNotBlank(textStatusBuss)) {
if (textStatusBuss.length() > 200){ if (textStatusBuss.length() > 200) {
return Result.error("输入的文本状态过长"); return Result.error("输入的文本状态过长");
} }
switch (textStatusBuss){ switch (textStatusBuss) {
case "发布": case "发布":
sarBussStandAttrInfo.setTextStatusBuss("6jnqba2mby"); sarBussStandAttrInfo.setTextStatusBuss("6jnqba2mby");
break; break;
case "被代替": case "被代替":
sarBussStandAttrInfo.setTextStatusBuss("quxujsuev5"); sarBussStandAttrInfo.setTextStatusBuss("quxujsuev5");
break; break;
case "参考": case "参考":
sarBussStandAttrInfo.setTextStatusBuss("01i8opy07d"); sarBussStandAttrInfo.setTextStatusBuss("01i8opy07d");
break; break;
case "即将实施": case "即将实施":
sarBussStandAttrInfo.setTextStatusBuss("rpvoxsvr60"); sarBussStandAttrInfo.setTextStatusBuss("rpvoxsvr60");
break; break;
case "有效": case "有效":
sarBussStandAttrInfo.setTextStatusBuss("9z741h2m3j"); sarBussStandAttrInfo.setTextStatusBuss("9z741h2m3j");
break; break;
case "直接上传": case "直接上传":
sarBussStandAttrInfo.setTextStatusBuss("t769k1rkcy"); sarBussStandAttrInfo.setTextStatusBuss("t769k1rkcy");
break; break;
case "作废": case "作废":
sarBussStandAttrInfo.setTextStatusBuss("3lqnlgmgcn"); sarBussStandAttrInfo.setTextStatusBuss("3lqnlgmgcn");
break; break;
case "待修订-指的其他企业标准": case "待修订-指的其他企业标准":
sarBussStandAttrInfo.setTextStatusBuss("1w7cegukbs"); sarBussStandAttrInfo.setTextStatusBuss("1w7cegukbs");
break; break;
default: default:
return Result.error("请提供准确的文本状态"); return Result.error("请提供准确的文本状态");
} }
}else { } else {
return Result.error("文本状态不能为空"); return Result.error("文本状态不能为空");
} }
SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd"); String issueTimeStr =rowList.get("发布日期");
if (issueTimeStr.contains("-")) {
sarBussStandAttrInfo.setIssueTime(issueTimeStr);
}else {
return Result.error("发布日期格式必须为年-月-日");
}
Date issueTime = sdfs.parse( rowList.get("发布日期")); String putTimeStr = rowList.get("企标实施日期");
String issueTimeStr = sdfs.format(issueTime); if (putTimeStr.contains("-")) {
if (StringUtils.isNotBlank(issueTimeStr)){ sarBussStandAttrInfo.setPutTime(putTimeStr);
sarBussStandAttrInfo.setIssueTime(issueTimeStr); }else {
} return Result.error("企标实施日期格式必须为年-月-日");
}
Date putTime = sdfs.parse(rowList.get("企标实施日期")); String revisionStatus = rowList.get("企标制修订状态");
String putTimeStr = sdfs.format(putTime); sarBussStandAttrInfo.setRevisionStatus(revisionStatus);
if (StringUtils.isNotBlank(putTimeStr)){
sarBussStandAttrInfo.setPutTime(putTimeStr); String qcdw = rowList.get("起草部门");
} if (StringUtils.isNotBlank(qcdw)) {
if (qcdw.length() > 100) {
return Result.error("输入的起草部门过长");
}
sarBussStandAttrInfo.setQcdw(qcdw);
}
String revisionStatus = rowList.get("企标制修订状态"); String dtqbbhbuss = rowList.get("代替企标编号");
sarBussStandAttrInfo.setRevisionStatus(revisionStatus); sarBussStandAttrInfo.setDtqbbhbuss(dtqbbhbuss);
String qcdw = rowList.get("起草部门"); String fsrqbuss = rowList.get("复审日期");
if (StringUtils.isNotBlank(qcdw)){ if (fsrqbuss.contains("-")) {
if (qcdw.length() > 100){ sarBussStandAttrInfo.setFsrqbuss(fsrqbuss);
return Result.error("输入的起草部门过长"); }else {
} return Result.error("复审日期格式必须为年-月-日");
sarBussStandAttrInfo.setQcdw(qcdw); }
}
String fzrqbuss = rowList.get("废止日期");
if (StringUtils.isNotBlank(fzrqbuss)){
sarBussStandAttrInfo.setFzrqbuss(fzrqbuss);
}
String dtqbbhbuss = rowList.get("代替企标编号"); String qcrbuss = rowList.get("起草人");
sarBussStandAttrInfo.setDtqbbhbuss(dtqbbhbuss); if (StringUtils.isNotBlank(qcrbuss)) {
if (qcrbuss.length() > 100) {
return Result.error("输入的起草人过长");
}
sarBussStandAttrInfo.setQcrbuss(qcrbuss);
}
String fsrqbuss = rowList.get("复审日期"); String bdtqbbhbuss = rowList.get("被代替企标编号");
if (StringUtils.isNotBlank(fsrqbuss)){ sarBussStandAttrInfo.setBdtqbbhbuss(bdtqbbhbuss);
sarBussStandAttrInfo.setFsrqbuss(fsrqbuss);
}
String qcrbuss = rowList.get("起草人");
if (StringUtils.isNotBlank(qcrbuss)){
if (qcrbuss.length() > 100){
return Result.error("输入的起草人过长");
}
sarBussStandAttrInfo.setQcrbuss(qcrbuss);
}
String bdtqbbhbuss = rowList.get("被代替企标编号");
sarBussStandAttrInfo.setBdtqbbhbuss(bdtqbbhbuss);
//// //采用标准 13 //// //采用标准 13
String cybz = rowList.get("采用标准"); String cybz = rowList.get("采用标准");
sarBussStandAttrInfo.setCybz(cybz); sarBussStandAttrInfo.setCybz(cybz);
String wjscrybuss = rowList.get("文件上传人员"); String wjscrybuss = rowList.get("文件上传人员");
sarBussStandAttrInfo.setWjscrybuss(wjscrybuss); sarBussStandAttrInfo.setWjscrybuss(wjscrybuss);
//// //采标程度 15 //// //采标程度 15
String cycd = rowList.get("采标程度"); String cycd = rowList.get("采标程度");
sarBussStandAttrInfo.setCycd(cycd); sarBussStandAttrInfo.setCycd(cycd);
//// //引用标准 16 //// //引用标准 16
String yybz = rowList.get("引用标准"); String yybz = rowList.get("引用标准");
sarBussStandAttrInfo.setYybz(yybz); sarBussStandAttrInfo.setYybz(yybz);
String sycxclass = rowList.get("适用车型"); String sycxclass = rowList.get("适用车型");
sarBussStandAttrInfo.setSycxclass(sycxclass); sarBussStandAttrInfo.setSycxclass(sycxclass);
String nylxclass = rowList.get("能源类型"); String nylxclass = rowList.get("能源类型");
sarBussStandAttrInfo.setNylxclass(nylxclass); sarBussStandAttrInfo.setNylxclass(nylxclass);
String sycpxclass = rowList.get("适用产品线"); String sycpxclass = rowList.get("适用产品线");
sarBussStandAttrInfo.setSycpxclass(sycpxclass); sarBussStandAttrInfo.setSycpxclass(sycpxclass);
String xcsjbuss = rowList.get("上传时间"); //上传时间
if (StringUtils.isNotBlank(xcsjbuss)){ Date date = new Date();
sarBussStandAttrInfo.setXcsjbuss(xcsjbuss); String format = sdf.format(date);
} sarBussStandAttrInfo.setXcsjbuss(format);
String txlbbuss = rowList.get("体系类别"); String txlbbuss = rowList.get("体系类别");
sarBussStandAttrInfo.setTxlbbuss(txlbbuss); sarBussStandAttrInfo.setTxlbbuss(txlbbuss);
//// //备案日期 22 //// //备案日期 22
String barq = rowList.get("备案日期"); String barq = rowList.get("备案日期");
sarBussStandAttrInfo.setBarq(barq); if (barq.contains("-")){
sarBussStandAttrInfo.setBarq(barq);
}else {
return Result.error("备案日期格式必须为年-月-日");
}
//// //关联模块-乘用车VPPS编码 23 //// //关联模块-乘用车VPPS编码 23
String cycvppsbmbuss = rowList.get("关联模块-乘用车VPPS编码"); String cycvppsbmbuss = rowList.get("关联模块-乘用车VPPS编码");
sarBussStandAttrInfo.setCycvppsbmbuss(cycvppsbmbuss); sarBussStandAttrInfo.setCycvppsbmbuss(cycvppsbmbuss);
//// //关联模块--乘用车vpps中文名称 24 // 关联模块-乘用车VPPS名称 24
String cycvppscnbuss = rowList.get("关联模块--乘用车vpps中文名称"); String cycvppscnbuss = sarVppsTreeDao.getCycvppscnbuss(sarBussStandAttrInfo.getCycvppsbmbuss());
sarBussStandAttrInfo.setCycvppscnbuss(cycvppscnbuss); sarBussStandAttrInfo.setCycvppscnbuss(cycvppscnbuss);
//// //关联模块--卡车VPPS编码 25 //// //关联模块--卡车VPPS编码 25
String kcvppsbmbuss = rowList.get("关联模块--卡车VPPS编码"); String kcvppsbmbuss = rowList.get("关联模块--卡车VPPS编码");
sarBussStandAttrInfo.setKcvppsbmbuss(kcvppsbmbuss); sarBussStandAttrInfo.setKcvppsbmbuss(kcvppsbmbuss);
//// //关联模块--卡车vpps中文名称 26 //关联模块--卡车VPPS名称 26
String kcvppscnbuss = rowList.get("关联模块--卡车vpps中文名称"); String kcvppscnbuss = sarVppsTreeDao.getKcvppscnbuss(sarBussStandAttrInfo.getKcvppsbmbuss());
sarBussStandAttrInfo.setKcvppscnbuss(kcvppscnbuss); sarBussStandAttrInfo.setKcvppscnbuss(kcvppscnbuss);
String fbgbuss = rowList.get("发布稿附件");
if (fbgbuss != null && !fbgbuss.equals("")) {
String[] split = fbgbuss.split(",");
String s = "";
if (split.length != 0) {
for (int j = 0; j < split.length; j++) {
String fjName = split[j];
int one = fjName.lastIndexOf(".");
String split2 = fjName.substring(one + 1).toLowerCase();
if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]);
AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
if (StringUtils.isNotBlank(attFileVo.getId())) {
s += "," + attFileVo.getAttId();
} else {
s = attFileVo.getAttId();
}
} else {
logger.info(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setFbgbuss(s);
}
}
String fbgbuss = rowList.get("发布稿附件"); String bzsmbuss = rowList.get("编制说明附件");
if (fbgbuss != null && !fbgbuss.equals("")) { if (bzsmbuss != null && !bzsmbuss.equals("")) {
String[] split = fbgbuss.split(","); String[] split = bzsmbuss.split(",");
String s = ""; String s = "";
if (split.length != 0) { if (split.length != 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
String name = fileInfo.getName(); String fjName = split[j];
String[] split1 = fileInfo.toString().split(name); int one = fjName.lastIndexOf(".");
File files = new File(split1[0] + split[j]); String split2 = fjName.substring(one + 1).toLowerCase();
AttFileVo attFileVo = attFileEOService.saveFileInfo(files); if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
if (StringUtils.isNotBlank(attFileVo.getId())) { String name = fileInfo.getName();
s += "," + attFileVo.getAttId(); String[] split1 = fileInfo.toString().split(name);
} else { File files = new File(split1[0] + split[j]);
s = attFileVo.getAttId(); AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
} if (StringUtils.isNotBlank(attFileVo.getId())) {
} s += "," + attFileVo.getAttId();
sarBussStandAttrInfo.setFbgbuss(s); } else {
} s = attFileVo.getAttId();
} }
} else {
logger.info(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setBzsmbuss(s);
}
}
String bzsmbuss = rowList.get("编制说明附件"); String lsbbbuss = rowList.get("历史版本附件");
if (bzsmbuss != null && !bzsmbuss.equals("")) { if (lsbbbuss != null && !lsbbbuss.equals("")) {
String[] split = bzsmbuss.split(","); String[] split = lsbbbuss.split(",");
String s = ""; String s = "";
if (split.length != 0) { if (split.length != 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
String name = fileInfo.getName(); String fjName = split[j];
String[] split1 = fileInfo.toString().split(name); int one = fjName.lastIndexOf(".");
File files = new File(split1[0] + split[j]); String split2 = fjName.substring(one + 1).toLowerCase();
AttFileVo attFileVo = attFileEOService.saveFileInfo(files); if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
if (StringUtils.isNotBlank(attFileVo.getId())) { String name = fileInfo.getName();
s += "," + attFileVo.getAttId(); String[] split1 = fileInfo.toString().split(name);
} else { File files = new File(split1[0] + split[j]);
s = attFileVo.getAttId(); AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
} if (StringUtils.isNotBlank(attFileVo.getId())) {
} s += "," + attFileVo.getAttId();
sarBussStandAttrInfo.setBzsmbuss(s); } else {
} s = attFileVo.getAttId();
} }
} else {
logger.info(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setLsbbbuss(s);
}
}
String lsbbbuss = rowList.get("历史版本附件"); String qtwjbuss = rowList.get("其他文件附件");
if (lsbbbuss != null && !lsbbbuss.equals("")) { if (qtwjbuss != null && !qtwjbuss.equals("")) {
String[] split = lsbbbuss.split(","); String[] split = qtwjbuss.split(",");
String s = ""; String s = "";
if (split.length != 0) { if (split.length != 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
String name = fileInfo.getName(); String fjName = split[j];
String[] split1 = fileInfo.toString().split(name); int one = fjName.lastIndexOf(".");
File files = new File(split1[0] + split[j]); String split2 = fjName.substring(one + 1).toLowerCase();
AttFileVo attFileVo = attFileEOService.saveFileInfo(files); if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx") || split2.equals("png")) {
if (StringUtils.isNotBlank(attFileVo.getId())) { String name = fileInfo.getName();
s += "," + attFileVo.getAttId(); String[] split1 = fileInfo.toString().split(name);
} else { File files = new File(split1[0] + split[j]);
s = attFileVo.getAttId(); AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
} if (StringUtils.isNotBlank(attFileVo.getId())) {
} s += "," + attFileVo.getAttId();
sarBussStandAttrInfo.setLsbbbuss(s); } else {
} s = attFileVo.getAttId();
} }
} else {
logger.info(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx/png格式的附件");
return Result.error(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx/png格式的附件");
}
}
sarBussStandAttrInfo.setQtwjbuss(s);
}
}
String qtwjbuss = rowList.get("其他文件附件"); String xgd = rowList.get("修改单附件");
if (qtwjbuss != null && !qtwjbuss.equals("")) { if (xgd != null && !xgd.equals("")) {
String[] split = qtwjbuss.split(","); String[] split = xgd.split(",");
String s = ""; String s = "";
if (split.length != 0) { if (split.length != 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
String name = fileInfo.getName(); String fjName = split[j];
String[] split1 = fileInfo.toString().split(name); int one = fjName.lastIndexOf(".");
File files = new File(split1[0] + split[j]); String split2 = fjName.substring(one + 1).toLowerCase();
AttFileVo attFileVo = attFileEOService.saveFileInfo(files); if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
if (StringUtils.isNotBlank(attFileVo.getId())) { String name = fileInfo.getName();
s += "," + attFileVo.getAttId(); String[] split1 = fileInfo.toString().split(name);
} else { File files = new File(split1[0] + split[j]);
s = attFileVo.getAttId(); AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
} if (StringUtils.isNotBlank(attFileVo.getId())) {
} s += "," + attFileVo.getAttId();
sarBussStandAttrInfo.setQtwjbuss(s); } else {
} s = attFileVo.getAttId();
} }
} else {
logger.info(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setXgd(s);
}
}
String xgd = rowList.get("修改单附件"); String glwjbuss = rowList.get("关联文件附件");
if (xgd != null && !xgd.equals("")) { if (glwjbuss != null && !glwjbuss.equals("")) {
String[] split = xgd.split(","); String[] split = glwjbuss.split(",");
String s = ""; String s = "";
if (split.length != 0) { if (split.length != 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
String name = fileInfo.getName(); String fjName = split[j];
String[] split1 = fileInfo.toString().split(name); int one = fjName.lastIndexOf(".");
File files = new File(split1[0] + split[j]); String split2 = fjName.substring(one + 1).toLowerCase();
AttFileVo attFileVo = attFileEOService.saveFileInfo(files); if (split2.equals("pdf") || split2.equals("ppt") || split2.equals("pptx") || split2.equals("doc") || split2.equals("docx") || split2.equals("xls") || split2.equals("xlsx")) {
if (StringUtils.isNotBlank(attFileVo.getId())) { String name = fileInfo.getName();
s += "," + attFileVo.getAttId(); String[] split1 = fileInfo.toString().split(name);
} else { File files = new File(split1[0] + split[j]);
s = attFileVo.getAttId(); AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
} if (StringUtils.isNotBlank(attFileVo.getId())) {
} s += "," + attFileVo.getAttId();
sarBussStandAttrInfo.setXgd(s); } else {
} s = attFileVo.getAttId();
} }
} else {
logger.info(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
return Result.error(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx格式的附件");
}
}
sarBussStandAttrInfo.setGlwjbuss(s);
}
}
String glwjbuss = rowList.get("关联文件附件"); List<SarBussStandAttrInfoExecl> list = new ArrayList<>();
if (glwjbuss != null && !glwjbuss.equals("")) { list.add(sarBussStandAttrInfo);
String[] split = glwjbuss.split(",");
String s = "";
if (split.length != 0) {
for (int j = 0; j < split.length; j++) {
String name = fileInfo.getName();
String[] split1 = fileInfo.toString().split(name);
File files = new File(split1[0] + split[j]);
AttFileVo attFileVo = attFileEOService.saveFileInfo(files);
if (StringUtils.isNotBlank(attFileVo.getId())) {
s += "," + attFileVo.getAttId();
} else {
s = attFileVo.getAttId();
}
}
sarBussStandAttrInfo.setGlwjbuss(s);
}
}
List<SarBussStandAttrInfoExecl> list = new ArrayList<>(); com.alibaba.fastjson.JSONArray json = com.alibaba.fastjson.JSONArray.parseArray(JSON.toJSONString(list));
list.add(sarBussStandAttrInfo); com.alibaba.fastjson.JSONObject jsonObjects = null;
for (int j = 0; j < json.size(); j++) {
jsonObjects = json.getJSONObject(j);
}
infoJson = String.valueOf(jsonObjects);
com.alibaba.fastjson.JSONArray json = com.alibaba.fastjson.JSONArray.parseArray(JSON.toJSONString(list)); //入库
com.alibaba.fastjson.JSONObject jsonObjects = null; processCreateBuss(infoJson);
for (int j = 0; j < json.size(); j++) { countSuccess++;
jsonObjects = json.getJSONObject(j); }
} }
infoJson = String.valueOf(jsonObjects); }
}
//入库 }
processCreateBuss(infoJson); } catch (Exception e) {
countSuccess++; FileUnZip.deleteDir(saveDirectory);
} return Result.error("导入失败,请查看需要导入的企标标准号和企标名称是否已存在");
} }
} }
} }
} String msg = "成功导入" + countSuccess + "";
}catch (Exception e){ return Result.success("", msg, null);
FileUnZip.deleteDir(saveDirectory); } catch (Exception e) {
return Result.error("导入失败,请查看需要导入的企标标准号和企标名称是否已存在"); FileUnZip.deleteDir(saveDirectory);
} return Result.error("导入失败,没有可导入的数据,请检查!");
} }
} }else {
String msg = "成功导入" + countSuccess + ""; return Result.error("请选择目录进行导入");
return Result.success("",msg,null); }
}catch (Exception e){
FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,没有可导入的数据,请检查!");
}
} }
private static List<File> readImpExcelFile(String path) { private static List<File> readImpExcelFile(String path) {
@@ -2,6 +2,8 @@ package com.adc.da.slrs.sarVppsTree.dao;
import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree; import com.adc.da.slrs.sarVppsTree.entity.SarVppsTree;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/** /**
* <p> * <p>
@@ -13,4 +15,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface SarVppsTreeDao extends BaseMapper<SarVppsTree> { public interface SarVppsTreeDao extends BaseMapper<SarVppsTree> {
@Select("select sar_vpps_tree.CHINESE_NAME from sar_vpps_tree where sar_vpps_tree.VPPS_CODE = #{cycvppsbmbuss} and sar_vpps_tree.TYPE = 'car';")
String getCycvppscnbuss(@Param("cycvppsbmbuss") String cycvppsbmbuss);
@Select("select sar_vpps_tree.CHINESE_NAME from sar_vpps_tree where sar_vpps_tree.VPPS_CODE = #{kcvppsbmbuss} and sar_vpps_tree.TYPE = 'truck';")
String getKcvppscnbuss(@Param("kcvppsbmbuss") String kcvppsbmbuss);
} }
@@ -68,6 +68,8 @@ public class FieldConvertUtil {
"在产车实施日期(项目),EOP实施日期(项目),实施说明,认证交付物,认证对象,监管类型,适用车辆类型,责任部门,相关部门,FO,项目评估角色," + "在产车实施日期(项目),EOP实施日期(项目),实施说明,认证交付物,认证对象,监管类型,适用车辆类型,责任部门,相关部门,FO,项目评估角色," +
"文本说明,标签,要求类型,清单类型,入库模块"; "文本说明,标签,要求类型,清单类型,入库模块";
public static String exportFieldName = "企标类别,标准年份,企标编号,中文名称,英文名称,文本状态,发布日期,企标实施日期,企标制修订状态,起草部门,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿附件,编制说明附件,历史版本附件,其他文件附件,修改单附件,关联文件附件";
/*** /***
* @Description: Clob类型 转String * @Description: Clob类型 转String
* @Author: super_liu * @Author: super_liu