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

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/sarLawsDetailedList/sar-laws-detailed-list/importData");
//企标标准导入模板下载
addInterceptor.excludePathPatterns("/api/lawss/sarBussionessStand/exportTemplateFile");
//doc文檔重新轉換
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_GNW");
addInterceptor.excludePathPatterns("/api/sarStandardsInfo/sar-standards-info/convertDocAll_QB");
@@ -1,6 +1,7 @@
package com.adc.da.slrs.sarBussionessStand.controller;
import cn.hutool.core.util.ZipUtil;
import com.adc.da.Log.BusinessType;
import com.adc.da.Log.EpcLog;
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.Result;
import com.adc.da.util.LoginUserUtil;
import com.adc.da.util.UUIDUtils;
import com.adc.da.util.exception.AdcDaBaseException;
import com.adc.da.util.utils.IOUtils;
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 io.swagger.annotations.ApiOperation;
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.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,9 +51,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -438,5 +441,67 @@ public class SarBussionessStandController extends BaseController<SarBussionessSt
public ResponseMessage 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.sarUpdLog.service.ISarUpdLogService;
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.sys.constant.ValueStateEnum;
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.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.web.multipart.MultipartFile;
import javax.net.ssl.*;
@@ -251,6 +253,9 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
@Autowired
private ITsResourceService tsResourceService;
@Autowired
private SarVppsTreeDao sarVppsTreeDao;
@Override
public SarBussionessStand getStandInfoByReviseStatus(String reviseStatus,String standSort,String taskId){
SarBussionessStand bussionessStand = new SarBussionessStand();
@@ -2036,437 +2041,484 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
public ResponseMessage<String> importSarBussionessStandFile(MultipartFile file,String menuId)throws Exception {
List<TsResource> tsResources = tsResourceService.getByMenuId(menuId);
if (ObjectUtils.isEmpty(tsResources)){
return Result.error("请选择目录进行导入");
}
if (ObjectUtils.isNotEmpty(tsResources)) {
//给出头部信息
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;
//给出头部信息
String[] headerExcel = {"企标类别,标准年份,企标编号,中文名称,英文名称,文本状态,发布日期,企标实施日期,企标制修订状态,起草部门,废止日期,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,上传时间,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--乘用车vpps中文名称,关联模块--卡车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);
//判断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文件");
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("上传的文件是空文件");
}
Workbook workbook = null;
try {
workbook = WorkbookFactory.create(fileInfo);
if (workbook != null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Sheet sheet = workbook.getSheetAt(0);
if (sheet != null){
StringBuilder sb = new StringBuilder();
//获取总条数
int rowNum = sheet.getLastRowNum();
//循环遍历
for (int i = 0;i <= rowNum;i++){
Row row = sheet.getRow(i);
Row headerRow = sheet.getRow(0);
boolean isBlank = sarLawsInfoEOService.isRowEmpty(row);
if (row != null && !isBlank) {
int columNos = headerRow.getLastCellNum();// 表头总共的列数
Map<String, String> rowList = new LinkedHashMap<>();
for (int j = 0; j < columNos; j++) {
Cell cell = row.getCell(j);
Cell headerCell = headerRow.getCell(j);
if (cell != null) {
if (i == 0) {
cell.setCellType(CellType.STRING);
sb.append(cell.getStringCellValue() + ",");
} else {
if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) {
Date d = cell.getDateCellValue();
rowList.put(headerCell.getStringCellValue(), sdf.format(d));
} else {
cell.setCellType(CellType.STRING);
rowList.put(headerCell.getStringCellValue(), cell.getStringCellValue());
}
}
} else {
if (i != 0) {
rowList.put(headerCell.getStringCellValue(), "");
}
}
}
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) {
//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;
try {
workbook = WorkbookFactory.create(fileInfo);
if (workbook != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Sheet sheet = workbook.getSheetAt(0);
if (sheet != null) {
StringBuilder sb = new StringBuilder();
//获取总条数
int rowNum = sheet.getLastRowNum();
//循环遍历
for (int i = 0; i <= rowNum; i++) {
Row row = sheet.getRow(i);
Row headerRow = sheet.getRow(0);
boolean isBlank = sarLawsInfoEOService.isRowEmpty(row);
if (row != null && !isBlank) {
int columNos = headerRow.getLastCellNum();// 表头总共的列数
Map<String, String> rowList = new LinkedHashMap<>();
for (int j = 0; j < columNos; j++) {
Cell cell = row.getCell(j);
Cell headerCell = headerRow.getCell(j);
if (cell != null) {
if (i == 0) {
cell.setCellType(CellType.STRING);
sb.append(cell.getStringCellValue() + ",");
} else {
if (CellType.NUMERIC == cell.getCellType() && HSSFDateUtil.isCellDateFormatted(cell)) {
Date d = cell.getDateCellValue();
rowList.put(headerCell.getStringCellValue(), sdf.format(d));
} else {
cell.setCellType(CellType.STRING);
rowList.put(headerCell.getStringCellValue(), cell.getStringCellValue());
}
}
} else {
if (i != 0) {
rowList.put(headerCell.getStringCellValue(), "");
}
}
}
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("企标类别");
if (StringUtils.isNotBlank(standSort)){
if (standSort.length() > 100){
return Result.error("企标类别输入过长");
}
sarBussStandAttrInfo.setStandSort(standSort);
}else {
return Result.error("企标类别不能为空");
}
String standSort = rowList.get("企标类别");
if (StringUtils.isNotBlank(standSort)) {
if (standSort.length() > 100) {
return Result.error("企标类别输入过长");
}
sarBussStandAttrInfo.setStandSort(standSort);
} else {
return Result.error("企标类别不能为空");
}
String standYear = rowList.get("标准年份");
if (StringUtils.isNotBlank(standYear)){
if (standYear.length() > 100){
return Result.error("标准年份输入过长");
}
sarBussStandAttrInfo.setStandYear(standYear);
}else {
return Result.error("标准年份不能为空");
}
String standYear = rowList.get("标准年份");
if (StringUtils.isNotBlank(standYear)) {
if (standYear.length() > 100) {
return Result.error("标准年份输入过长");
}
sarBussStandAttrInfo.setStandYear(standYear);
} else {
return Result.error("标准年份不能为空");
}
String standNumber = rowList.get("企标编号");
sarBussStandAttrInfo.setStandNumber(standNumber);
String standNumber = rowList.get("企标编号");
sarBussStandAttrInfo.setStandNumber(standNumber);
String standName = rowList.get("中文名称");
if(StringUtils.isNotBlank(standName)){
if(standName.length()>100){
return Result.error("输入的标准名称过长");
}
sarBussStandAttrInfo.setStandName(standName);
}else {
return Result.error("中文名称不能为空");
}
String standName = rowList.get("中文名称");
if (StringUtils.isNotBlank(standName)) {
if (standName.length() > 100) {
return Result.error("输入的标准名称过长");
}
sarBussStandAttrInfo.setStandName(standName);
} else {
return Result.error("中文名称不能为空");
}
String standEnName = rowList.get("英文名称");
sarBussStandAttrInfo.setStandEnName(standEnName);
String standEnName = rowList.get("英文名称");
sarBussStandAttrInfo.setStandEnName(standEnName);
String textStatusBuss = rowList.get("文本状态");
if (StringUtils.isNotBlank(textStatusBuss)){
if (textStatusBuss.length() > 200){
return Result.error("输入的文本状态过长");
}
String textStatusBuss = rowList.get("文本状态");
if (StringUtils.isNotBlank(textStatusBuss)) {
if (textStatusBuss.length() > 200) {
return Result.error("输入的文本状态过长");
}
switch (textStatusBuss){
case "发布":
sarBussStandAttrInfo.setTextStatusBuss("6jnqba2mby");
break;
case "被代替":
sarBussStandAttrInfo.setTextStatusBuss("quxujsuev5");
break;
case "参考":
sarBussStandAttrInfo.setTextStatusBuss("01i8opy07d");
break;
case "即将实施":
sarBussStandAttrInfo.setTextStatusBuss("rpvoxsvr60");
break;
case "有效":
sarBussStandAttrInfo.setTextStatusBuss("9z741h2m3j");
break;
case "直接上传":
sarBussStandAttrInfo.setTextStatusBuss("t769k1rkcy");
break;
case "作废":
sarBussStandAttrInfo.setTextStatusBuss("3lqnlgmgcn");
break;
case "待修订-指的其他企业标准":
sarBussStandAttrInfo.setTextStatusBuss("1w7cegukbs");
break;
default:
return Result.error("请提供准确的文本状态");
}
}else {
return Result.error("文本状态不能为空");
}
switch (textStatusBuss) {
case "发布":
sarBussStandAttrInfo.setTextStatusBuss("6jnqba2mby");
break;
case "被代替":
sarBussStandAttrInfo.setTextStatusBuss("quxujsuev5");
break;
case "参考":
sarBussStandAttrInfo.setTextStatusBuss("01i8opy07d");
break;
case "即将实施":
sarBussStandAttrInfo.setTextStatusBuss("rpvoxsvr60");
break;
case "有效":
sarBussStandAttrInfo.setTextStatusBuss("9z741h2m3j");
break;
case "直接上传":
sarBussStandAttrInfo.setTextStatusBuss("t769k1rkcy");
break;
case "作废":
sarBussStandAttrInfo.setTextStatusBuss("3lqnlgmgcn");
break;
case "待修订-指的其他企业标准":
sarBussStandAttrInfo.setTextStatusBuss("1w7cegukbs");
break;
default:
return Result.error("请提供准确的文本状态");
}
} else {
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 issueTimeStr = sdfs.format(issueTime);
if (StringUtils.isNotBlank(issueTimeStr)){
sarBussStandAttrInfo.setIssueTime(issueTimeStr);
}
String putTimeStr = rowList.get("企标实施日期");
if (putTimeStr.contains("-")) {
sarBussStandAttrInfo.setPutTime(putTimeStr);
}else {
return Result.error("企标实施日期格式必须为年-月-日");
}
Date putTime = sdfs.parse(rowList.get("企标实施日期"));
String putTimeStr = sdfs.format(putTime);
if (StringUtils.isNotBlank(putTimeStr)){
sarBussStandAttrInfo.setPutTime(putTimeStr);
}
String revisionStatus = rowList.get("企标制修订状态");
sarBussStandAttrInfo.setRevisionStatus(revisionStatus);
String qcdw = rowList.get("起草部门");
if (StringUtils.isNotBlank(qcdw)) {
if (qcdw.length() > 100) {
return Result.error("输入的起草部门过长");
}
sarBussStandAttrInfo.setQcdw(qcdw);
}
String revisionStatus = rowList.get("企标制修订状态");
sarBussStandAttrInfo.setRevisionStatus(revisionStatus);
String dtqbbhbuss = rowList.get("代替企标编号");
sarBussStandAttrInfo.setDtqbbhbuss(dtqbbhbuss);
String qcdw = rowList.get("起草部门");
if (StringUtils.isNotBlank(qcdw)){
if (qcdw.length() > 100){
return Result.error("输入的起草部门过长");
}
sarBussStandAttrInfo.setQcdw(qcdw);
}
String fzrqbuss = rowList.get("废止日期");
if (StringUtils.isNotBlank(fzrqbuss)){
sarBussStandAttrInfo.setFzrqbuss(fzrqbuss);
}
String fsrqbuss = rowList.get("复审日期");
if (fsrqbuss.contains("-")) {
sarBussStandAttrInfo.setFsrqbuss(fsrqbuss);
}else {
return Result.error("复审日期格式必须为年-月-日");
}
String dtqbbhbuss = rowList.get("代替企标编号");
sarBussStandAttrInfo.setDtqbbhbuss(dtqbbhbuss);
String qcrbuss = rowList.get("起草人");
if (StringUtils.isNotBlank(qcrbuss)) {
if (qcrbuss.length() > 100) {
return Result.error("输入的起草人过长");
}
sarBussStandAttrInfo.setQcrbuss(qcrbuss);
}
String fsrqbuss = rowList.get("复审日期");
if (StringUtils.isNotBlank(fsrqbuss)){
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);
String bdtqbbhbuss = rowList.get("被代替企标编号");
sarBussStandAttrInfo.setBdtqbbhbuss(bdtqbbhbuss);
//// //采用标准 13
String cybz = rowList.get("采用标准");
sarBussStandAttrInfo.setCybz(cybz);
String cybz = rowList.get("采用标准");
sarBussStandAttrInfo.setCybz(cybz);
String wjscrybuss = rowList.get("文件上传人员");
sarBussStandAttrInfo.setWjscrybuss(wjscrybuss);
String wjscrybuss = rowList.get("文件上传人员");
sarBussStandAttrInfo.setWjscrybuss(wjscrybuss);
//// //采标程度 15
String cycd = rowList.get("采标程度");
sarBussStandAttrInfo.setCycd(cycd);
String cycd = rowList.get("采标程度");
sarBussStandAttrInfo.setCycd(cycd);
//// //引用标准 16
String yybz = rowList.get("引用标准");
sarBussStandAttrInfo.setYybz(yybz);
String yybz = rowList.get("引用标准");
sarBussStandAttrInfo.setYybz(yybz);
String sycxclass = rowList.get("适用车型");
sarBussStandAttrInfo.setSycxclass(sycxclass);
String sycxclass = rowList.get("适用车型");
sarBussStandAttrInfo.setSycxclass(sycxclass);
String nylxclass = rowList.get("能源类型");
sarBussStandAttrInfo.setNylxclass(nylxclass);
String nylxclass = rowList.get("能源类型");
sarBussStandAttrInfo.setNylxclass(nylxclass);
String sycpxclass = rowList.get("适用产品线");
sarBussStandAttrInfo.setSycpxclass(sycpxclass);
String sycpxclass = rowList.get("适用产品线");
sarBussStandAttrInfo.setSycpxclass(sycpxclass);
String xcsjbuss = rowList.get("上传时间");
if (StringUtils.isNotBlank(xcsjbuss)){
sarBussStandAttrInfo.setXcsjbuss(xcsjbuss);
}
//上传时间
Date date = new Date();
String format = sdf.format(date);
sarBussStandAttrInfo.setXcsjbuss(format);
String txlbbuss = rowList.get("体系类别");
sarBussStandAttrInfo.setTxlbbuss(txlbbuss);
String txlbbuss = rowList.get("体系类别");
sarBussStandAttrInfo.setTxlbbuss(txlbbuss);
//// //备案日期 22
String barq = rowList.get("备案日期");
sarBussStandAttrInfo.setBarq(barq);
String barq = rowList.get("备案日期");
if (barq.contains("-")){
sarBussStandAttrInfo.setBarq(barq);
}else {
return Result.error("备案日期格式必须为年-月-日");
}
//// //关联模块-乘用车VPPS编码 23
String cycvppsbmbuss = rowList.get("关联模块-乘用车VPPS编码");
sarBussStandAttrInfo.setCycvppsbmbuss(cycvppsbmbuss);
String cycvppsbmbuss = rowList.get("关联模块-乘用车VPPS编码");
sarBussStandAttrInfo.setCycvppsbmbuss(cycvppsbmbuss);
//// //关联模块--乘用车vpps中文名称 24
String cycvppscnbuss = rowList.get("关联模块--乘用车vpps中文名称");
sarBussStandAttrInfo.setCycvppscnbuss(cycvppscnbuss);
// 关联模块-乘用车VPPS名称 24
String cycvppscnbuss = sarVppsTreeDao.getCycvppscnbuss(sarBussStandAttrInfo.getCycvppsbmbuss());
sarBussStandAttrInfo.setCycvppscnbuss(cycvppscnbuss);
//// //关联模块--卡车VPPS编码 25
String kcvppsbmbuss = rowList.get("关联模块--卡车VPPS编码");
sarBussStandAttrInfo.setKcvppsbmbuss(kcvppsbmbuss);
String kcvppsbmbuss = rowList.get("关联模块--卡车VPPS编码");
sarBussStandAttrInfo.setKcvppsbmbuss(kcvppsbmbuss);
//// //关联模块--卡车vpps中文名称 26
String kcvppscnbuss = rowList.get("关联模块--卡车vpps中文名称");
sarBussStandAttrInfo.setKcvppscnbuss(kcvppscnbuss);
//关联模块--卡车VPPS名称 26
String kcvppscnbuss = sarVppsTreeDao.getKcvppscnbuss(sarBussStandAttrInfo.getKcvppsbmbuss());
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("发布稿附件");
if (fbgbuss != null && !fbgbuss.equals("")) {
String[] split = fbgbuss.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.setFbgbuss(s);
}
}
String bzsmbuss = rowList.get("编制说明附件");
if (bzsmbuss != null && !bzsmbuss.equals("")) {
String[] split = bzsmbuss.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.setBzsmbuss(s);
}
}
String bzsmbuss = rowList.get("编制说明附件");
if (bzsmbuss != null && !bzsmbuss.equals("")) {
String[] split = bzsmbuss.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.setBzsmbuss(s);
}
}
String lsbbbuss = rowList.get("历史版本附件");
if (lsbbbuss != null && !lsbbbuss.equals("")) {
String[] split = lsbbbuss.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.setLsbbbuss(s);
}
}
String lsbbbuss = rowList.get("历史版本附件");
if (lsbbbuss != null && !lsbbbuss.equals("")) {
String[] split = lsbbbuss.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.setLsbbbuss(s);
}
}
String qtwjbuss = rowList.get("其他文件附件");
if (qtwjbuss != null && !qtwjbuss.equals("")) {
String[] split = qtwjbuss.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") || split2.equals("png")) {
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/png格式的附件");
return Result.error(fjName + "格式不正确,请上传pdf/ppt/pptx/doc/docx/xls/xlsx/png格式的附件");
}
}
sarBussStandAttrInfo.setQtwjbuss(s);
}
}
String qtwjbuss = rowList.get("其他文件附件");
if (qtwjbuss != null && !qtwjbuss.equals("")) {
String[] split = qtwjbuss.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.setQtwjbuss(s);
}
}
String xgd = rowList.get("修改单附件");
if (xgd != null && !xgd.equals("")) {
String[] split = xgd.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.setXgd(s);
}
}
String xgd = rowList.get("修改单附件");
if (xgd != null && !xgd.equals("")) {
String[] split = xgd.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.setXgd(s);
}
}
String glwjbuss = rowList.get("关联文件附件");
if (glwjbuss != null && !glwjbuss.equals("")) {
String[] split = glwjbuss.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.setGlwjbuss(s);
}
}
String glwjbuss = rowList.get("关联文件附件");
if (glwjbuss != null && !glwjbuss.equals("")) {
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<>();
list.add(sarBussStandAttrInfo);
List<SarBussStandAttrInfoExecl> list = new ArrayList<>();
list.add(sarBussStandAttrInfo);
com.alibaba.fastjson.JSONArray json = com.alibaba.fastjson.JSONArray.parseArray(JSON.toJSONString(list));
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;
for (int j = 0; j < json.size(); j++) {
jsonObjects = json.getJSONObject(j);
}
infoJson = String.valueOf(jsonObjects);
//入库
processCreateBuss(infoJson);
countSuccess++;
}
}
}
}
}
}catch (Exception e){
FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,请查看需要导入的企标标准号和企标名称是否已存在");
}
}
}
String msg = "成功导入" + countSuccess + "";
return Result.success("",msg,null);
}catch (Exception e){
FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,没有可导入的数据,请检查!");
}
//入库
processCreateBuss(infoJson);
countSuccess++;
}
}
}
}
}
} catch (Exception e) {
FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,请查看需要导入的企标标准号和企标名称是否已存在");
}
}
}
String msg = "成功导入" + countSuccess + "";
return Result.success("", msg, null);
} catch (Exception e) {
FileUnZip.deleteDir(saveDirectory);
return Result.error("导入失败,没有可导入的数据,请检查!");
}
}else {
return Result.error("请选择目录进行导入");
}
}
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.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* <p>
@@ -13,4 +15,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
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,项目评估角色," +
"文本说明,标签,要求类型,清单类型,入库模块";
public static String exportFieldName = "企标类别,标准年份,企标编号,中文名称,英文名称,文本状态,发布日期,企标实施日期,企标制修订状态,起草部门,代替企标编号,复审日期,起草人,被代替企标编号,采用标准,文件上传人员,采标程度,引用标准,适用车型,能源类型,适用产品线,体系类别,备案日期,关联模块-乘用车VPPS编码,关联模块--卡车VPPS编码,发布稿附件,编制说明附件,历史版本附件,其他文件附件,修改单附件,关联文件附件";
/***
* @Description: Clob类型 转String
* @Author: super_liu