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

This commit is contained in:
高嵩
2023-03-30 21:12:03 +08:00
parent 7d88ddccc0
commit 6883aa84e5
6 changed files with 149 additions and 12 deletions
@@ -73,5 +73,5 @@ public interface IOtaBaSjSjmbclService extends IService<OtaBaSjSjmbcl> {
OtaBaSjSjmbcl importData(MultipartFile file, String otaId, String cut) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
void exportData(File file, File mbclAttFile, String otaId, String cut) throws Exception;
}
@@ -73,5 +73,5 @@ public interface IOtaBaSjSjyxpgService extends IService<OtaBaSjSjyxpg> {
OtaBaSjSjyxpg 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 attFile, File attFile2, String otaId, String cut) throws Exception;
}
@@ -190,12 +190,16 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
File sjmbcxFile = ImportFileUtil.findFile(exportFile, "升级目标车型.xlsx");
otaBaSjSjmbcxService.exportData(sjmbcxFile, otaId, cut);
File jbxxFile = ImportFileUtil.findFile(exportFile, "本次升级涉及的目标车辆.xlsx");
otaBaSjSjmbclService.exportData(jbxxFile, otaId, cut);
File mbclFile = ImportFileUtil.findFile(exportFile, "本次升级涉及的目标车辆.xlsx");
File mbclAttFile = ImportFileUtil.findFoder(exportFile, "本次升级涉及的目标车辆");
otaBaSjSjmbclService.exportData(mbclFile, mbclAttFile, otaId, cut);
File pgFile = ImportFileUtil.findFile(exportFile, "升级影响评估.docx");
otaBaSjSjyxpgService.exportData(pgFile, otaId, cut);
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");
otaBaSjSjxtbhService.exportData(sjSjxtbhFile, otaId, cut);
@@ -1,15 +1,14 @@
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.constant.enums.CutEnum;
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.OtaBaSjSjmbcl;
import com.jero.modules.ota.entity.OtaBaSjSjmbcx;
import com.jero.modules.ota.entity.VinObj;
import com.jero.modules.ota.entity.*;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjSjmbclMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
@@ -33,6 +32,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.text.SimpleDateFormat;
import java.util.*;
@@ -275,8 +276,39 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
public void exportData(File file, File mbclAttFile, String otaId, String cut) throws Exception {
OtaBaSjSjmbcl cl = this.getByOtaId(otaId);
if (ObjectUtils.isNotEmpty(cl)) {
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(0);
Cell cell = row.getCell(1);
cell.setCellValue(cl.getZsl());
row = s.getRow(1);
cell = row.getCell(1);
cell.setCellValue(sdf.format(cl.getScrqks()) + " - " + sdf.format(cl.getScrqjs()));
row = s.getRow(2);
cell = row.getCell(1);
cell.setCellValue(cl.getVinList());
String attStr = cl.getCsv();
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(mbclAttFile.getCanonicalPath() + "/" + ossFile.getFileName(), download);
}
}
}
}
wb.write(new FileOutputStream(file));
wb.close();
}
}
}
@@ -245,9 +245,24 @@ public class OtaBaSjSjmbcxServiceImpl extends ServiceImpl<OtaBaSjSjmbcxMapper, O
Row row = s.getRow(1);
Cell cell = row.getCell(2);
cell.setCellValue(cx.getBabh());
row = s.getRow(2);
row = s.getRow(3);
cell = row.getCell(2);
cell.setCellValue(cx.getBapc());
row = s.getRow(4);
cell = row.getCell(2);
cell.setCellValue(cx.getCpsb());
row = s.getRow(5);
cell = row.getCell(2);
cell.setCellValue(cx.getCpmc());
row = s.getRow(6);
cell = row.getCell(2);
cell.setCellValue(cx.getCpxh());
row = s.getRow(7);
cell = row.getCell(2);
cell.setCellValue(cx.getDllx1());
row = s.getRow(8);
cell = row.getCell(2);
cell.setCellValue(cx.getDllx2());
wb.write(new FileOutputStream(file));
wb.close();
}
@@ -3,6 +3,8 @@ package com.jero.modules.ota.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.*;
import com.jero.modules.ota.enums.OtaModuleEnum;
@@ -14,6 +16,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.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +28,7 @@ import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Date;
@@ -284,7 +291,86 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
public void exportData(File file, File attFile1, File attFile2,String otaId, String cut) throws Exception {
OtaBaSjSjyxpg pg = this.getByOtaId(otaId);
if (ObjectUtils.isNotEmpty(pg)) {
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", pg.getSjmd(), sysDictService));
row = s.getRow(1);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getSfbgcs()));
row = s.getRow(2);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getSjxnbh()));
row = s.getRow(3);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getFhgd()));
row = s.getRow(4);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getZdjsxg()));
row = s.getRow(5);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getJrxxg()));
row = s.getRow(6);
cell = row.getCell(1);
cell.setCellValue(ComparisonUtil.queryDictTextByKey("conditions_upgrades", pg.getZxsj().toString(), sysDictService));
row = s.getRow(7);
cell = row.getCell(1);
cell.setCellValue(ComparisonUtil.queryDictTextByKey("upgrade_failed", pg.getAqjz(), sysDictService));
row = s.getRow(8);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getSfyxaq()));
row = s.getRow(9);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getYhqr()));
row = s.getRow(10);
cell = row.getCell(1);
cell.setCellValue(ComparisonUtil.queryDictTextByKey("package_test", pg.getSjbcs(), sysDictService));
row = s.getRow(9);
cell = row.getCell(1);
cell.setCellValue(ImportFileUtil.getCellValueYesOrNoInt(pg.getAqkkx()));
String attStr = pg.getBgfj();
if(StringUtils.isNotEmpty(attStr)){
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(attFile1.getCanonicalPath() + "/" + ossFile.getFileName(), download);
}
}
}
}
}
String attStr1 = pg.getBgfj();
if(StringUtils.isNotEmpty(attStr1)){
List<AttachmentEO> attList = JSONArray.parseArray(attStr1, 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(attFile2.getCanonicalPath() + "/" + ossFile.getFileName(), download);
}
}
}
}
}
wb.write(new FileOutputStream(file));
wb.close();
}
}
}