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

This commit is contained in:
高嵩
2023-03-29 16:21:16 +08:00
parent 6208f59321
commit 94202e0a19
6 changed files with 78 additions and 3 deletions
@@ -3,6 +3,7 @@ package com.jero.modules.ota.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -99,6 +100,6 @@ public class OtaBaCxAqcs implements Serializable {
private java.lang.String zmcl;
@TableField(exist = false)
private List<AttachmentEO> zmclList;
private List<AttachmentEO> zmclList = new ArrayList<>();
}
@@ -3,6 +3,7 @@ package com.jero.modules.ota.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -125,6 +126,6 @@ public class OtaBaCxZxsjyq implements Serializable {
private java.lang.String zmcl;
@TableField(exist = false)
private List<AttachmentEO> zmclList;
private List<AttachmentEO> zmclList = new ArrayList<>();
}
@@ -32,7 +32,6 @@ public enum OtaTitleEnum {
SJSBAQ("sjsbaq", "升级失败安全状态", "2"),
SJGG("sjgg", "升级公告", "2"),
SJZT("sjzt", "升级结果状态", "2"),
ZMCL("zmcl", "证明材料", "0"),
BHJZ("bhjz", "保护机制", "protection_mechanism"),
FSXJZ("fsxjz", "防失效机制", "fail_safe_mechanism"),
@@ -76,6 +76,7 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
otaBaCxAqcs.setCreateTime(now);
}
otaBaCxAqcs.setUpdateTime(now);
otaBaCxAqcs.setZmcl("");
if (null != otaBaCxAqcs.getZmclList() && otaBaCxAqcs.getZmclList().size() > 0) {
JSONArray obj = new JSONArray();
for (AttachmentEO aeo : otaBaCxAqcs.getZmclList()) {
@@ -83,12 +84,41 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
}
otaBaCxAqcs.setZmcl(obj.toString());
}
if (ObjectUtils.isNotEmpty(otaBaCxAqcsOld) && StringUtils.isNotEmpty(otaBaCxAqcsOld.getZmcl())) {
List<AttachmentEO> aeoList = JSONArray.parseArray(otaBaCxAqcsOld.getZmcl(), AttachmentEO.class);
otaBaCxAqcsOld.setZmclList(aeoList);
}
saveOrUpdate(otaBaCxAqcs);
ComparisonUtil cu = new ComparisonUtil();
if (ObjectUtils.isEmpty(otaBaCxAqcsOld)) {
otaBaCxAqcsOld = new OtaBaCxAqcs();
}
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxAqcs.getOtaId(), OtaModuleEnum.CX_AQCS, otaBaCxAqcsOld, otaBaCxAqcs, sysDictService);
for (AttachmentEO aeoNew : otaBaCxAqcs.getZmclList()) {
boolean flag = true;
for (AttachmentEO aeoOld : otaBaCxAqcsOld.getZmclList()) {
if (aeoNew.getId().equals(aeoOld.getId())) {
flag = false;
break;
}
}
if (flag) {
reList.add(cu.addAttRecord(otaBaCxAqcs.getOtaId(), OtaModuleEnum.CX_AQCS, "证明材料", aeoNew.getFileName()));
}
}
for (AttachmentEO aeoOld : otaBaCxAqcsOld.getZmclList()) {
boolean flag = true;
for (AttachmentEO aeoNew : otaBaCxAqcs.getZmclList()) {
if (aeoOld.getId().equals(aeoNew.getId())) {
flag = false;
break;
}
}
if (flag) {
reList.add(cu.delAttRecord(otaBaCxAqcs.getOtaId(), OtaModuleEnum.CX_AQCS, "证明材料", aeoOld.getFileName()));
}
}
otaBaCxTxjlService.saveBatch(reList);
}
}
@@ -81,6 +81,7 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
}
}
otaBaCxZxsjyq.setUpdateTime(now);
otaBaCxZxsjyq.setZmcl("");
if (null != otaBaCxZxsjyq.getZmclList() && otaBaCxZxsjyq.getZmclList().size() > 0) {
JSONArray obj = new JSONArray();
for (AttachmentEO aeo : otaBaCxZxsjyq.getZmclList()) {
@@ -88,12 +89,42 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
}
otaBaCxZxsjyq.setZmcl(obj.toString());
}
if (ObjectUtils.isNotEmpty(otaBaCxZxsjyqOld) && StringUtils.isNotEmpty(otaBaCxZxsjyqOld.getZmcl())) {
List<AttachmentEO> aeoList = JSONArray.parseArray(otaBaCxZxsjyqOld.getZmcl(), AttachmentEO.class);
otaBaCxZxsjyqOld.setZmclList(aeoList);
}
saveOrUpdate(otaBaCxZxsjyq);
ComparisonUtil cu = new ComparisonUtil();
if (ObjectUtils.isEmpty(otaBaCxZxsjyqOld)) {
otaBaCxZxsjyqOld = new OtaBaCxZxsjyq();
}
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxZxsjyq.getOtaId(), OtaModuleEnum.CX_ZXSJYQ, otaBaCxZxsjyqOld, otaBaCxZxsjyq, sysDictService);
for (AttachmentEO aeoNew : otaBaCxZxsjyq.getZmclList()) {
boolean flag = true;
for (AttachmentEO aeoOld : otaBaCxZxsjyqOld.getZmclList()) {
if (aeoNew.getId().equals(aeoOld.getId())) {
flag = false;
break;
}
}
if (flag) {
reList.add(cu.addAttRecord(otaBaCxZxsjyq.getOtaId(), OtaModuleEnum.CX_ZXSJYQ, "证明材料", aeoNew.getFileName()));
}
}
for (AttachmentEO aeoOld : otaBaCxZxsjyqOld.getZmclList()) {
boolean flag = true;
for (AttachmentEO aeoNew : otaBaCxZxsjyq.getZmclList()) {
if (aeoOld.getId().equals(aeoNew.getId())) {
flag = false;
break;
}
}
if (flag) {
reList.add(cu.delAttRecord(otaBaCxZxsjyq.getOtaId(), OtaModuleEnum.CX_ZXSJYQ, "证明材料", aeoOld.getFileName()));
}
}
otaBaCxTxjlService.saveBatch(reList);
}
@@ -22,6 +22,19 @@ public class ComparisonUtil<T> {
public ComparisonUtil() {
}
public OtaBaCxTxjl addAttRecord(String otaId, OtaModuleEnum otaModuleEnum, String title, String attName) {
String content = title + "中添加了附件:'" + attName;
OtaBaCxTxjl jl = new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content);
return jl;
}
public OtaBaCxTxjl delAttRecord(String otaId, OtaModuleEnum otaModuleEnum, String title, String attName) {
String content = title + "中删除了附件:'" + attName;
OtaBaCxTxjl jl = new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content);
return jl;
}
/**
* 对比字段并添加到记录
*/