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

This commit is contained in:
高嵩
2023-03-30 21:47:02 +08:00
parent 5ac8fb595f
commit 419a381fa4
6 changed files with 69 additions and 1 deletions
@@ -3,6 +3,7 @@ package com.jero.modules.ota.service;
import com.jero.modules.ota.entity.OtaBaCxQt;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.File;
import java.util.List;
/**
@@ -61,4 +62,6 @@ public interface IOtaBaCxQtService extends IService<OtaBaCxQt> {
List<OtaBaCxQt> queryList();
OtaBaCxQt queryByOtaId(String otaId, String otaIdT);
void exportData(File file, String otaId, String cut) throws Exception;
}
@@ -3,6 +3,8 @@ package com.jero.modules.ota.service;
import com.jero.modules.ota.entity.OtaBaCxQt;
import com.jero.modules.ota.entity.OtaBaSjQtsjxx;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.File;
import java.util.List;
/**
@@ -61,4 +63,6 @@ public interface IOtaBaSjQtsjxxService extends IService<OtaBaSjQtsjxx> {
List<OtaBaSjQtsjxx> queryList();
OtaBaSjQtsjxx queryByOtaId(String otaId, String otaIdT);
void exportData(File file, String otaId, String cut) throws Exception;
}
@@ -60,6 +60,9 @@ public class OtaBaCxListServiceImpl extends ServiceImpl<OtaBaCxListMapper, OtaBa
@Autowired
private IOtaBaCxJsfzbacsService otaBaCxJsfzbacsService;
@Autowired
private IOtaBaCxQtService otaBaCxQtService;
@Value(value = "${ota.templatePath}")
private String templatePath;
@@ -213,6 +216,8 @@ public class OtaBaCxListServiceImpl extends ServiceImpl<OtaBaCxListMapper, OtaBa
File bacsFile = ImportFileUtil.findFile(exportFile, "驾驶辅助系统基础备案参数.xlsx");
otaBaCxJsfzbacsService.exportData(bacsFile, otaId, cut);
File qtFile = ImportFileUtil.findFile(exportFile, "其他.xlsx");
otaBaCxQtService.exportData(qtFile, otaId, cut);
String outPath = uploadPath + "/车型及功能备案" + System.currentTimeMillis() + ".zip";
//FileUtils.forceDelete(template);
@@ -4,16 +4,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.ota.entity.OtaBaCxAqcs;
import com.jero.modules.ota.entity.OtaBaCxQt;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.entity.OtaBaSjQtsjxx;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaCxQtMapper;
import com.jero.modules.ota.service.IOtaBaCxQtService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils;
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.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import java.util.Date;
@@ -127,7 +135,7 @@ public class OtaBaCxQtServiceImpl extends ServiceImpl<OtaBaCxQtMapper, OtaBaCxQt
}
public OtaBaCxQt getByOtaId(String otaId) {
if(org.apache.commons.lang3.StringUtils.isEmpty(otaId)){
if (org.apache.commons.lang3.StringUtils.isEmpty(otaId)) {
return null;
}
LambdaQueryWrapper<OtaBaCxQt> queryWrapper = new LambdaQueryWrapper<>();
@@ -135,4 +143,16 @@ public class OtaBaCxQtServiceImpl extends ServiceImpl<OtaBaCxQtMapper, OtaBaCxQt
return this.getOne(queryWrapper, false);
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
OtaBaCxQt qt = this.getByOtaId(otaId);
if (ObjectUtils.isNotEmpty(qt)) {
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(0);
Cell cell = row.getCell(1);
cell.setCellValue(qt.getSjbbhcs());
wb.close();
}
}
}
@@ -61,6 +61,9 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
@Autowired
private IOtaBaSjSjyxpgService otaBaSjSjyxpgService;
@Autowired
private IOtaBaSjQtsjxxService otaBaSjQtsjxxService;
/**
* 保存
@@ -211,6 +214,9 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
File fsAttFile = ImportFileUtil.findFile(exportFile, "用户告知内容及方式");
otaBaSjGgnrfsService.exportData(sjfzbhFile, fsAttFile, otaId, cut);
File qtFile = ImportFileUtil.findFile(exportFile, "其他升级任务信息.xlsx");
otaBaSjQtsjxxService.exportData(qtFile, otaId, cut);
String outPath = uploadPath + "/在线升级活动备案" + System.currentTimeMillis() + ".zip";
FileOutputStream fos1 = new FileOutputStream(outPath);
ImportFileUtil.toZip(exportFile.getCanonicalPath(), fos1, true);
@@ -3,17 +3,26 @@ package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.ota.entity.OtaBaCxQt;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.entity.OtaBaSjGgnrfs;
import com.jero.modules.ota.entity.OtaBaSjQtsjxx;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjQtsjxxMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.service.IOtaBaSjQtsjxxService;
import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.ota.utils.ImportFileUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils;
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.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Date;
@@ -28,6 +37,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class OtaBaSjQtsjxxServiceImpl extends ServiceImpl<OtaBaSjQtsjxxMapper, OtaBaSjQtsjxx> implements IOtaBaSjQtsjxxService {
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
@@ -134,4 +144,24 @@ public class OtaBaSjQtsjxxServiceImpl extends ServiceImpl<OtaBaSjQtsjxxMapper, O
queryWrapper.eq(OtaBaSjQtsjxx::getOtaId, otaId);
return this.getOne(queryWrapper, false);
}
@Override
public void exportData(File file, String otaId, String cut) throws Exception {
OtaBaSjQtsjxx qt = this.getByOtaId(otaId);
if (ObjectUtils.isNotEmpty(qt)) {
Workbook wb = ImportFileUtil.readExcel(file);
Sheet s = wb.getSheetAt(0);
Row row = s.getRow(0);
Cell cell = row.getCell(1);
cell.setCellValue(qt.getRwmc());
row = s.getRow(1);
cell = row.getCell(1);
cell.setCellValue(sdf.format(qt.getSjfbsj()));
row = s.getRow(2);
cell = row.getCell(1);
cell.setCellValue(sdf.format(qt.getSjjzsj()));
wb.write(new FileOutputStream(file));
wb.close();
}
}
}