开发OTA备案工具-车辆升级

This commit is contained in:
高嵩
2023-03-30 21:39:32 +08:00
parent 6883aa84e5
commit 5ac8fb595f
5 changed files with 142 additions and 10 deletions
@@ -72,4 +72,4 @@ public interface IOtaBaSjGgnrfsService extends IService<OtaBaSjGgnrfs> {
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;}
void exportData(File file, File fsAttFile, String otaId, String cut) throws Exception;}
@@ -1,12 +1,13 @@
package com.jero.modules.ota.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.oss.CosBootUtil;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.entity.OtaBaSjGgnrfs;
import com.jero.modules.ota.entity.OtaBaSjSjyxpg;
import com.jero.modules.ota.entity.*;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjGgnrfsMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
@@ -17,6 +18,10 @@ import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -25,6 +30,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -230,7 +237,62 @@ public class OtaBaSjGgnrfsServiceImpl extends ServiceImpl<OtaBaSjGgnrfsMapper, O
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
public void exportData(File file, File attFile, String otaId, String cut) throws Exception {
OtaBaSjGgnrfs fs = this.getByOtaId(otaId);
if (ObjectUtils.isNotEmpty(fs)) {
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(0);
Cell cell = row.getCell(1);
cell.setCellValue(ComparisonUtil.queryDictTextByKey("uipgrade_purpose", fs.getSjmd(), sysDictService));
row = s.getRow(1);
cell = row.getCell(1);
cell.setCellValue(fs.getGxbh());
row = s.getRow(2);
cell = row.getCell(1);
cell.setCellValue(fs.getSjsj());
row = s.getRow(3);
cell = row.getCell(1);
cell.setCellValue(fs.getSjky());
row = s.getRow(4);
cell = row.getCell(1);
cell.setCellValue(fs.getSjbkygn());
row = s.getRow(5);
cell = row.getCell(1);
cell.setCellValue(fs.getZdxx());
row = s.getRow(6);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(fs.getSjsfcg()));
row = s.getRow(7);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(fs.getGzbg()));
;
row = s.getRow(8);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(fs.getGzscnr()));
row = s.getRow(9);
cell = row.getCell(1);
cell.setCellValue(ComparisonUtil.queryDictTextByKey("user_notification_mode", fs.getGzyhfs(), sysDictService));
String attStr = fs.getXgwj();
List<AttachmentEO> attList = JSONArray.parseArray(attStr, AttachmentEO.class);
if (ObjectUtils.isNotEmpty(attList)) {
for (AttachmentEO aeo : attList) {
List<OSSFile> ossFileList = ossFileService.getFileInfos(aeo.getId());
for (OSSFile ossFile : ossFileList) {
String filePath = ossFile.getUrl();
boolean b = CosBootUtil.doesObjectExist(filePath);
if (b) {
InputStream download = CosBootUtil.download(filePath);
ImportFileUtil.writeToLocal(attFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
}
}
}
}
wb.write(new FileOutputStream(file));
wb.close();
}
}
}
@@ -195,18 +195,22 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
otaBaSjSjmbclService.exportData(mbclFile, mbclAttFile, otaId, cut);
File pgFile = ImportFileUtil.findFile(exportFile, "升级影响评估.docx");
File pgFile = ImportFileUtil.findFile(exportFile, "升级影响评估.xlsx");
File pgAttFile = ImportFileUtil.findFoder(exportFile, "升级影响评估");
File pgAtt1File = ImportFileUtil.findFoder(pgAttFile, "测试报告");
File pgAtt2File = ImportFileUtil.findFoder(pgAttFile, "硬件版本号附件");
otaBaSjSjyxpgService.exportData(pgFile, pgAtt1File, pgAtt2File, otaId, cut);
File sjSjxtbhFile = ImportFileUtil.findFile(exportFile, "本次升级的系统名称与变更参数.docx");
File sjSjxtbhFile = ImportFileUtil.findFile(exportFile, "本次升级的系统名称与变更参数.xlsx");
otaBaSjSjxtbhService.exportData(sjSjxtbhFile, otaId, cut);
File sjfzbhFile = ImportFileUtil.findFile(exportFile, "本次升级的驾驶辅助功能与参数变化.docx");
File sjfzbhFile = ImportFileUtil.findFile(exportFile, "本次升级的驾驶辅助功能与参数变化.xlsx");
otaBaSjSjfzbhService.exportData(sjfzbhFile, otaId, cut);
File fsFile = ImportFileUtil.findFile(exportFile, "用户告知内容及方式.xlsx");
File fsAttFile = ImportFileUtil.findFile(exportFile, "用户告知内容及方式");
otaBaSjGgnrfsService.exportData(sjfzbhFile, fsAttFile, otaId, cut);
String outPath = uploadPath + "/在线升级活动备案" + System.currentTimeMillis() + ".zip";
FileOutputStream fos1 = new FileOutputStream(outPath);
ImportFileUtil.toZip(exportFile.getCanonicalPath(), fos1, true);
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Field;
import java.util.*;
@@ -270,6 +271,33 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
List<OtaBaSjSjfzbh> fzbhList = this.getByOtaId(otaId);
if (ObjectUtils.isNotEmpty(fzbhList)) {
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row;
Cell cell;
int start = 4;
for (OtaBaSjSjfzbh bh : fzbhList) {
row = s.createRow(start);
cell = row.createCell(0);
cell.setCellValue(bh.getGnmc());
cell = row.createCell(1);
cell.setCellValue(bh.getSjmdlx());
cell = row.createCell(2);
cell.setCellValue(bh.getSjqbgcs());
cell = row.createCell(3);
cell.setCellValue(bh.getSjhbgcs());
cell = row.createCell(4);
cell.setCellValue(bh.getGnbgms());
cell = row.createCell(5);
cell.setCellValue(bh.getSytjbg());
cell = row.createCell(6);
cell.setCellValue(bh.getSjsjkzq());
start++;
}
wb.write(new FileOutputStream(file));
wb.close();
}
}
}
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Field;
import java.util.*;
@@ -284,6 +285,43 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
List<OtaBaSjSjxtbh> bhList = this.getByOtaId(otaId);
if (ObjectUtils.isNotEmpty(bhList)) {
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row;
Cell cell;
int start = 4;
for (OtaBaSjSjxtbh bh : bhList) {
row = s.createRow(start);
cell = row.createCell(0);
cell.setCellValue(bh.getXtmc());
cell = row.createCell(1);
cell.setCellValue(bh.getSjqbgcs());
cell = row.createCell(2);
cell.setCellValue(bh.getSjhbgcs());
cell = row.createCell(3);
cell.setCellValue(bh.getSjkzqmc());
cell = row.createCell(4);
cell.setCellValue(bh.getYjbb());
cell = row.createCell(5);
cell.setCellValue(bh.getSjqrjbb());
cell = row.createCell(6);
cell.setCellValue(bh.getSjhrjbb());
cell = row.createCell(7);
cell.setCellValue(bh.getSjqczxt());
cell = row.createCell(8);
cell.setCellValue(bh.getSjhczxt());
cell = row.createCell(9);
cell.setCellValue(bh.getSjbyzsj());
cell = row.createCell(10);
cell.setCellValue(bh.getSjbdx());
cell = row.createCell(11);
cell.setCellValue(bh.getSfcfsj());
start++;
}
wb.write(new FileOutputStream(file));
wb.close();
}
}
}