修改OTA

This commit is contained in:
高嵩
2023-04-03 13:44:25 +08:00
parent 3613ed6623
commit b9a02809d9
3 changed files with 29 additions and 10 deletions
@@ -183,7 +183,7 @@ public enum OtaTitleEnum {
CSRJSJ("csrjsj", "初始软件包的完整性数据", "0", "", 500),
SJBYZSJ("sjbyzsj", "升级包完整性验证数据", "0", "", 500),
SJBDX("sjbdx", "升级包大小", "0", "", 50),
SFCFSJ("sfcfsj", "是否差分升级", "0", "", 50),
SFCFSJ("sfcfsj", "是否差分升级", "2", "", 0),
SJMDLX("sjmdlx", "升级目的类型", "0", "", 50),
GNBGMS("gnbgms", "功能变更描述", "0", "", 500),
SYTJBG("sytjbg", "适用条件变更", "0", "", 500),
@@ -74,6 +74,9 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
String otaId = (String) json.get("otaId");
if (StringUtils.isNotEmpty(otaId)) {
oldList = getByOtaId(otaId);
if (ObjectUtils.isEmpty(oldList)) {
oldList = setDefault(otaId);
}
deleteByOtaId(otaId);
JSONArray list = json.getJSONArray("list");
if (null != list) {
@@ -111,6 +114,19 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
}
}
public List<OtaBaSjSjxtbh> setDefault(String otaId) {
List<OtaBaSjSjxtbh> list = this.getByOtaId(otaId);
Date now = new Date();
OtaBaSjSjxtbh bh = new OtaBaSjSjxtbh();
bh.setOtaId(otaId);
bh.setSjkzqmc("ADC ADAS主控制器");
bh.setCreateTime(now);
bh.setId(UUID.randomUUID().toString().replace("-", ""));
list.add(bh);
saveBatch(list);
return list;
}
public void deleteByOtaId(String otaId) {
List<OtaBaSjSjxtbh> list = this.getByOtaId(otaId);
List<String> ids = new ArrayList<>();
@@ -183,6 +199,9 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
if (ObjectUtil.isEmpty(res)) {
res = getByOtaId(otaIdT);
}
if (ObjectUtils.isEmpty(res)) {
res = setDefault(otaId);
}
JSONObject json = new JSONObject();
json.put("list", res);
@@ -204,13 +223,13 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
}
@Override
public void importData(MultipartFile file, String otaId, String cut, StringBuilder errMsg) 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,errMsg);
parseFileList(upLoadFiles, otaId, cut, errMsg);
}
@Override
public void parseFileList(List<File> upLoadFiles, String otaId, String cut, StringBuilder errMsg) 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 +240,7 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
throw new JeroBootException("请上传正确的文件");
}
List<OtaBaSjSjxtbh> newList = parseFile(upFile, otaId, cut,errMsg);
List<OtaBaSjSjxtbh> newList = parseFile(upFile, otaId, cut, errMsg);
List<OtaBaSjSjxtbh> oldList = getByOtaId(otaId);
if (ObjectUtils.isEmpty(oldList)) {
oldList = new ArrayList<>();
@@ -233,7 +252,7 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
otaBaCxTxjlService.saveBatch(reList);
}
private List<OtaBaSjSjxtbh> parseFile(File upFile, String otaId, String cut, StringBuilder errMsg) 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);
@@ -270,7 +289,7 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
cell = row.getCell(9);
xtbh.setSjbdx(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(10);
xtbh.setSfcfsj(ImportFileUtil.getCellValue(cell, wb));
xtbh.setSfcfsj(ImportFileUtil.getCellValueYesOrNo(cell, wb));
ComparisonUtil cu = new ComparisonUtil();
cu.checkError(xtbh, errMsg, sysDictService, cut);
if (xtbh.isNull()) {
@@ -319,7 +338,7 @@ public class OtaBaSjSjxtbhServiceImpl extends ServiceImpl<OtaBaSjSjxtbhMapper, O
cell = row.createCell(10);
cell.setCellValue(bh.getSjbdx());
cell = row.createCell(11);
cell.setCellValue(bh.getSfcfsj());
cell.setCellValue(ImportFileUtil.getCellValueYesOrNo(bh.getSfcfsj()));
start++;
}
wb.write(new FileOutputStream(file));
@@ -160,8 +160,8 @@ public class OtaBaSjSjyxpgServiceImpl extends ServiceImpl<OtaBaSjSjyxpgMapper, O
Date now = new Date();
OtaBaSjSjyxpg res = new OtaBaSjSjyxpg();
res.setOtaId(otaId);
res.setFhgd(2);
res.setZdjsxg(1);
res.setFhgd(1);
res.setZdjsxg(2);
res.setZxsj(2);
res.setAqjz("2");
res.setSfyxaq(2);