开发OTA备案工具-导入导出

This commit is contained in:
高嵩
2023-03-31 02:52:03 +08:00
parent e8f44f1a5d
commit 35937db22a
15 changed files with 99 additions and 90 deletions
@@ -233,13 +233,14 @@ public class OtaBaSjListController extends JeroController<OtaBaSjList, IOtaBaSjL
// @RequiresPermissions("otaBaCx:importData")
public Result<?> importData(@RequestParam(value = "file", required = false) MultipartFile file,
@RequestParam(value = "cut", required = false) String cut) throws Exception {
StringBuilder errMsg = new StringBuilder();
try {
this.otaBaSjListService.importData(file, cut);
this.otaBaSjListService.importData(file, cut, errMsg);
} catch (Exception e) {
e.printStackTrace();
return Result.error(e.getMessage());
}
return Result.OK("导入成功");
return Result.error(errMsg.toString());
}
@ApiOperation(value = "升级备案-数据导出")
@@ -12,64 +12,65 @@ import java.util.List;
/**
* @Description: 升级备案-用户告知内容及方式
* @Author: jero-boot
* @Date: 2023-03-17
* @Date: 2023-03-17
* @Version: V1.0
*/
public interface IOtaBaSjGgnrfsService extends IService<OtaBaSjGgnrfs> {
/**
* 保存
*
* @param otaBaSjGgnrfs
* @return
*/
/**
* 保存
*
* @param otaBaSjGgnrfs
* @return
*/
void add(OtaBaSjGgnrfs otaBaSjGgnrfs);
/**
* 更新
*
* @param otaBaSjGgnrfs
* @return
*/
/**
* 更新
*
* @param otaBaSjGgnrfs
* @return
*/
void editById(OtaBaSjGgnrfs otaBaSjGgnrfs);
/**
* 通过id删除
*
* @param id
* @return
*/
/**
* 通过id删除
*
* @param id
* @return
*/
void deleteById(String id);
/**
* 批量删除
*
* @param ids
* @return
*/
/**
* 批量删除
*
* @param ids
* @return
*/
void deleteByIds(List<String> ids);
/**
* 通过id查询
*
* @param id
* @return
*/
/**
* 通过id查询
*
* @param id
* @return
*/
OtaBaSjGgnrfs queryById(String id);
/**
* 列表查询
*
* @return
*/
* 列表查询
*
* @return
*/
List<OtaBaSjGgnrfs> queryList();
OtaBaSjGgnrfs queryByOtaId(String otaId, String otaIdT);
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
void importData(MultipartFile file, String otaId, String cut) throws Exception;
void importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception;
void exportData(File file, File fsAttFile, String otaId, String cut) throws Exception;}
void exportData(File file, File fsAttFile, String otaId, String cut) throws Exception;
}
@@ -70,7 +70,7 @@ public interface IOtaBaSjListService extends IService<OtaBaSjList> {
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
void importData(MultipartFile file, String cut) throws Exception;
void importData(MultipartFile file, String cut, StringBuilder errMsg) throws Exception;
void exportData(String otaId, HttpServletResponse response, HttpServletRequest request) throws Exception;
}
@@ -69,9 +69,9 @@ public interface IOtaBaSjSjfzbhService extends IService<OtaBaSjSjfzbh> {
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
void importData(MultipartFile file, String otaId, String cut) throws Exception;
void importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
}
@@ -69,9 +69,9 @@ public interface IOtaBaSjSjmbclService extends IService<OtaBaSjSjmbcl> {
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
OtaBaSjSjmbcl parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
OtaBaSjSjmbcl parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception;
OtaBaSjSjmbcl importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaSjSjmbcl importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception;
void exportData(File file, File mbclAttFile, String otaId, String cut) throws Exception;
}
@@ -70,9 +70,9 @@ public interface IOtaBaSjSjmbcxService extends IService<OtaBaSjSjmbcx> {
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
OtaBaSjSjmbcx importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaSjSjmbcx importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception;
OtaBaSjSjmbcx parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
OtaBaSjSjmbcx parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
}
@@ -67,9 +67,9 @@ public interface IOtaBaSjSjxtbhService extends IService<OtaBaSjSjxtbh> {
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
void importData(MultipartFile file, String otaId, String cut) throws Exception;
void importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
void parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception;
void exportData(File file, String otaId, String cut) throws Exception;
}
@@ -69,9 +69,9 @@ public interface IOtaBaSjSjyxpgService extends IService<OtaBaSjSjyxpg> {
void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception;
OtaBaSjSjyxpg importData(MultipartFile file, String otaId, String cut) throws Exception;
OtaBaSjSjyxpg importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception;
OtaBaSjSjyxpg parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception;
OtaBaSjSjyxpg parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception;
void exportData(File file, File attFile, File attFile2, String otaId, String cut) throws Exception;
}
@@ -194,13 +194,13 @@ public class OtaBaSjGgnrfsServiceImpl extends ServiceImpl<OtaBaSjGgnrfsMapper, O
}
@Override
public void importData(MultipartFile file, String otaId, String cut) throws Exception {
public void importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception{
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
parseFileList(upLoadFiles, otaId, cut);
parseFileList(upLoadFiles, otaId, cut,errMsg);
}
@Override
public void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
public void parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception{
File attFile = null;
for (File f : upLoadFiles) {
if (f.isDirectory() && f.getName().equals("用户告知内容及方式")) {
@@ -210,11 +210,11 @@ public class OtaBaSjGgnrfsServiceImpl extends ServiceImpl<OtaBaSjGgnrfsMapper, O
if (null == attFile) {
throw new JeroBootException("请上传正确的文件");
}
OtaBaSjGgnrfs fs = parseFile(attFile, otaId, cut);
OtaBaSjGgnrfs fs = parseFile(attFile, otaId, cut,errMsg);
add(fs);
}
private OtaBaSjGgnrfs parseFile(File attFile, String otaId, String cut) throws Exception {
private OtaBaSjGgnrfs parseFile(File attFile, String otaId, String cut, StringBuilder errMsg) throws Exception{
OtaBaSjGgnrfs fs = new OtaBaSjGgnrfs();
fs.setOtaId(otaId);
OtaBaSjSjyxpg pg = otaBaSjSjyxpgService.queryByOtaId(otaId, "");
@@ -168,17 +168,17 @@ public class OtaBaSjListServiceImpl extends ServiceImpl<OtaBaSjListMapper, OtaBa
}
@Override
public void importData(MultipartFile file, String cut) throws Exception {
public void importData(MultipartFile file, String cut, StringBuilder errMsg) throws Exception {
List<File> fileList = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjmbcx mbcx = otaBaSjSjmbcxService.parseFileList(fileList, "", cut);
OtaBaSjSjmbcx mbcx = otaBaSjSjmbcxService.parseFileList(fileList, "", cut, errMsg);
String otaId = mbcx.getOtaId();
if (StringUtils.isNotEmpty(otaId)) {
otaBaSjSjmbclService.parseFileList(fileList, otaId, cut);
otaBaSjSjmbcxService.parseFileList(fileList, otaId, cut);
otaBaSjSjyxpgService.parseFileList(fileList, otaId, cut);
otaBaSjSjxtbhService.parseFileList(fileList, otaId, cut);
otaBaSjSjfzbhService.parseFileList(fileList, otaId, cut);
otaBaSjGgnrfsService.parseFileList(fileList, otaId, cut);
otaBaSjSjmbclService.parseFileList(fileList, otaId, cut, errMsg);
otaBaSjSjmbcxService.parseFileList(fileList, otaId, cut, errMsg);
otaBaSjSjyxpgService.parseFileList(fileList, otaId, cut, errMsg);
otaBaSjSjxtbhService.parseFileList(fileList, otaId, cut, errMsg);
otaBaSjSjfzbhService.parseFileList(fileList, otaId, cut, errMsg);
otaBaSjGgnrfsService.parseFileList(fileList, otaId, cut, errMsg);
} else {
throw new JeroBootException("导入失败");
}
@@ -204,13 +204,13 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
}
@Override
public void importData(MultipartFile file, String otaId, String cut) throws Exception {
public void importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception {
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
parseFileList(upLoadFiles, otaId, cut);
parseFileList(upLoadFiles, otaId, cut,errMsg);
}
@Override
public void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
public void parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception {
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("本次升级的驾驶辅助功能与参数变化.xlsx")) {
@@ -225,7 +225,7 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
if (ObjectUtils.isEmpty(oldList)) {
oldList = new ArrayList<>();
}
List<OtaBaSjSjfzbh> newList = parseFile(upFile, otaId, cut);
List<OtaBaSjSjfzbh> newList = parseFile(upFile, otaId, cut,errMsg);
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.SJ_SJJSMCBH, OtaTitleEnum.GNMC.getName(), oldList, newList, sysDictService);
deleteByOtaId(otaId);
@@ -233,7 +233,7 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
otaBaCxTxjlService.saveBatch(reList);
}
private List<OtaBaSjSjfzbh> parseFile(File upFile, String otaId, String cut) throws Exception {
private List<OtaBaSjSjfzbh> parseFile(File upFile, String otaId, String cut, StringBuilder errMsg) throws Exception {
Date now = new Date();
List<OtaBaSjSjfzbh> fzbhList = new ArrayList<>();
Workbook wb = ImportFileUtil.readExcel(upFile);
@@ -264,6 +264,9 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
fzbh.setOtaId(otaId);
fzbh.setCreateTime(now);
fzbh.setUpdateTime(now);
ComparisonUtil cu = new ComparisonUtil();
cu.checkError(fzbh, errMsg, sysDictService, cut);
fzbhList.add(fzbh);
}
return fzbhList;
@@ -181,7 +181,7 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
}
@Override
public OtaBaSjSjmbcl parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
public OtaBaSjSjmbcl parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception {
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("本次升级涉及的目标车辆.xlsx")) {
@@ -191,13 +191,13 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
if (null == upFile) {
throw new JeroBootException("请上传正确的文件");
}
OtaBaSjSjmbcl mbcl = parseFile(upFile, otaId, cut);
OtaBaSjSjmbcl mbcl = parseFile(upFile, otaId, cut, errMsg);
mbcl.setOtaId(otaId);
add(mbcl);
return mbcl;
}
private OtaBaSjSjmbcl parseFile(File upFile, String otaId, String cut) throws Exception {
private OtaBaSjSjmbcl parseFile(File upFile, String otaId, String cut, StringBuilder errMsg) throws Exception {
OtaBaSjSjmbcl mbcl = new OtaBaSjSjmbcl();
OtaBaSjSjmbcx mbcx = otaBaSjSjmbcxService.queryByOtaId(otaId, "");
if (ObjectUtils.isNotEmpty(mbcx) && StringUtils.isNotEmpty(mbcx.getCpxh())) {
@@ -269,9 +269,9 @@ public class OtaBaSjSjmbclServiceImpl extends ServiceImpl<OtaBaSjSjmbclMapper, O
}
@Override
public OtaBaSjSjmbcl importData(MultipartFile file, String otaId, String cut) throws Exception {
public OtaBaSjSjmbcl importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception {
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjmbcl mbcl = parseFileList(upLoadFiles, otaId, cut);
OtaBaSjSjmbcl mbcl = parseFileList(upLoadFiles, otaId, cut, errMsg);
return mbcl;
}
@@ -179,14 +179,14 @@ public class OtaBaSjSjmbcxServiceImpl extends ServiceImpl<OtaBaSjSjmbcxMapper, O
}
@Override
public OtaBaSjSjmbcx importData(MultipartFile file, String otaId, String cut) throws Exception {
public OtaBaSjSjmbcx importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception {
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjmbcx mbcx = parseFileList(upLoadFiles, otaId, cut);
OtaBaSjSjmbcx mbcx = parseFileList(upLoadFiles, otaId, cut, errMsg);
return mbcx;
}
@Override
public OtaBaSjSjmbcx parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
public OtaBaSjSjmbcx parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception {
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("升级目标车型.xlsx")) {
@@ -196,13 +196,13 @@ public class OtaBaSjSjmbcxServiceImpl extends ServiceImpl<OtaBaSjSjmbcxMapper, O
if (null == upFile) {
throw new JeroBootException("请上传正确的文件");
}
OtaBaSjSjmbcx mbcx = parseFile(upFile, cut);
OtaBaSjSjmbcx mbcx = parseFile(upFile, cut, errMsg);
mbcx.setOtaId(otaId);
add(mbcx);
return mbcx;
}
private OtaBaSjSjmbcx parseFile(File upFile, String cut) throws Exception {
private OtaBaSjSjmbcx parseFile(File upFile, String cut, StringBuilder errMsg) throws Exception {
OtaBaSjSjmbcx mbcx = new OtaBaSjSjmbcx();
Workbook wb = ImportFileUtil.readExcel(upFile);
Sheet s = wb.getSheetAt(0);
@@ -233,6 +233,8 @@ public class OtaBaSjSjmbcxServiceImpl extends ServiceImpl<OtaBaSjSjmbcxMapper, O
mbcx.setCpxh(jbxx.getCpxh());
mbcx.setDllx1(jbxx.getDllx1());
mbcx.setDllx2(jbxx.getDllx2());
ComparisonUtil cu = new ComparisonUtil();
cu.checkError(mbcx, errMsg, sysDictService, cut);
return mbcx;
}
@@ -204,13 +204,13 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
}
@Override
public void importData(MultipartFile file, String otaId, String cut) throws Exception {
public void importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception{
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
parseFileList(upLoadFiles, otaId, cut);
parseFileList(upLoadFiles, otaId, cut,errMsg);
}
@Override
public void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
public void parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception{
File upFile = null;
for (File f : upLoadFiles) {
if (f.getName().equals("本次升级的系统名称与变更参数.xlsx")) {
@@ -221,7 +221,7 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
throw new JeroBootException("请上传正确的文件");
}
List<OtaBaSjSjxtbh> newList = parseFile(upFile, otaId, cut);
List<OtaBaSjSjxtbh> newList = parseFile(upFile, otaId, cut,errMsg);
List<OtaBaSjSjxtbh> oldList = getByOtaId(otaId);
if (ObjectUtils.isEmpty(oldList)) {
oldList = new ArrayList<>();
@@ -233,7 +233,7 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
otaBaCxTxjlService.saveBatch(reList);
}
private List<OtaBaSjSjxtbh> parseFile(File upFile, String otaId, String cut) throws Exception {
private List<OtaBaSjSjxtbh> parseFile(File upFile, String otaId, String cut, StringBuilder errMsg) throws Exception{
Date now = new Date();
List<OtaBaSjSjxtbh> list = new ArrayList<>();
Workbook wb = ImportFileUtil.readExcel(upFile);
@@ -271,6 +271,8 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
xtbh.setSjbdx(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(10);
xtbh.setSfcfsj(ImportFileUtil.getCellValue(cell, wb));
ComparisonUtil cu = new ComparisonUtil();
cu.checkError(xtbh, errMsg, sysDictService, cut);
if (xtbh.isNull()) {
break;
}
@@ -201,13 +201,13 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
}
@Override
public OtaBaSjSjyxpg importData(MultipartFile file, String otaId, String cut) throws Exception {
public OtaBaSjSjyxpg importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) throws Exception {
List<File> upLoadFiles = ImportFileUtil.importZip(file, cut, uploadPath);
OtaBaSjSjyxpg sjyxpg = parseFileList(upLoadFiles, otaId, cut);
OtaBaSjSjyxpg sjyxpg = parseFileList(upLoadFiles, otaId, cut, errMsg);
return sjyxpg;
}
private OtaBaSjSjyxpg parseFile(File upFile, File attFile1, File attFile2, String cut) throws Exception {
private OtaBaSjSjyxpg parseFile(File upFile, File attFile1, File attFile2, String cut, StringBuilder errMsg) throws Exception {
OtaBaSjSjyxpg sjyxpg = new OtaBaSjSjyxpg();
InputStream is = new FileInputStream(upFile);
XWPFDocument doc = new XWPFDocument(is);
@@ -253,7 +253,7 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
}
@Override
public OtaBaSjSjyxpg parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
public OtaBaSjSjyxpg parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) throws Exception {
File upFile = null;
File attFile = null;
File attFile1 = null;
@@ -284,7 +284,7 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
}
OtaBaSjSjyxpg sjyxpg = parseFile(upFile, attFile1, attFile2, cut);
OtaBaSjSjyxpg sjyxpg = parseFile(upFile, attFile1, attFile2, cut, errMsg);
sjyxpg.setOtaId(otaId);
add(sjyxpg);
return sjyxpg;