Merge remote-tracking branch 'origin/dev_2nd_LCYH' into dev_2nd_LCYH

This commit is contained in:
zyx.net
2023-03-26 12:06:36 +08:00
9 changed files with 84 additions and 44 deletions
@@ -8,7 +8,7 @@ public enum OtaTitleEnum {
CPSB("cpsb", "产品商标", "0"), CPSB("cpsb", "产品商标", "0"),
CPMC("cpmc", "产品名称", "0"), CPMC("cpmc", "产品名称", "0"),
CPXH("cpxh", "产品型号", "0"), CPXH("cpxh", "产品型号", "0"),
BAZT("bazt", "备案状态", "1"), BAZT("bazt", "备案状态", "recordstatus"),
BATJSJ("batjsj", "备案提交时间", "0"), BATJSJ("batjsj", "备案提交时间", "0"),
CJSJ("cjsj", "创建时间", "0"), CJSJ("cjsj", "创建时间", "0"),
BZ("bz", "备注", "0"), BZ("bz", "备注", "0"),
@@ -19,7 +19,7 @@ public enum OtaTitleEnum {
CPLB("cplb", "产品类别", "0"), CPLB("cplb", "产品类别", "0"),
DLLX1("dllx1", "车辆动力类型", "0"), DLLX1("dllx1", "车辆动力类型", "0"),
DLLX2("dllx2", "车辆动力类型", "0"), DLLX2("dllx2", "车辆动力类型", "0"),
TXZD("txzd", "通信终端", "1"), TXZD("txzd", "通信终端", "communication_terminal"),
CDOTASJ("cdotasj", "车端OTA升级管理系统", "0"), CDOTASJ("cdotasj", "车端OTA升级管理系统", "0"),
BHSJB("bhsjb", "保护升级包", "2"), BHSJB("bhsjb", "保护升级包", "2"),
@@ -34,10 +34,10 @@ public enum OtaTitleEnum {
SJZT("sjzt", "升级结果状态", "2"), SJZT("sjzt", "升级结果状态", "2"),
ZMCL("zmcl", "证明材料", "0"), ZMCL("zmcl", "证明材料", "0"),
BHJZ("bhjz", "保护机制", "1"), BHJZ("bhjz", "保护机制", "protection_mechanism"),
FSXJZ("fsxjz", "防失效机制", "1"), FSXJZ("fsxjz", "防失效机制", "fail_safe_mechanism"),
SJSBCS("sjsbcs", "升级失败措施", "1"), SJSBCS("sjsbcs", "升级失败措施", "upgrade_failure"),
XXAQJZ("xxaqjz", "信息安全机制", "1"), XXAQJZ("xxaqjz", "信息安全机制", "Information_security_mechanism"),
XTLB("xtlb", "系统类别", "0"), XTLB("xtlb", "系统类别", "0"),
SFKSJ("sfksj", "是否可升级", "2"), SFKSJ("sfksj", "是否可升级", "2"),
@@ -57,7 +57,7 @@ public enum OtaTitleEnum {
GNMC("gnmc", "功能名称", "0"), GNMC("gnmc", "功能名称", "0"),
PZQK("pzqk", "配置情况", "2"), PZQK("pzqk", "配置情况", "2"),
JSZDHJB("jszdhjb", "驾驶自动化级别", "1"), JSZDHJB("jszdhjb", "驾驶自动化级别", "driving_automation_level"),
SJGGCS("sjggcs", "升级可能变更的《公告》技术参数", "0"), SJGGCS("sjggcs", "升级可能变更的《公告》技术参数", "0"),
GNMS("gnms", "功能描述", "0"), GNMS("gnms", "功能描述", "0"),
SYTJ("sytj", "适用条件", "0"), SYTJ("sytj", "适用条件", "0"),
@@ -11,6 +11,7 @@ import com.jero.modules.ota.mapper.OtaBaCxAqcsMapper;
import com.jero.modules.ota.service.IOtaBaCxAqcsService; import com.jero.modules.ota.service.IOtaBaCxAqcsService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +34,10 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private ISysDictService sysDictService;
/** /**
* 保存 * 保存
* *
@@ -62,7 +67,7 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
if (ObjectUtils.isEmpty(otaBaCxAqcsOld)) { if (ObjectUtils.isEmpty(otaBaCxAqcsOld)) {
otaBaCxAqcsOld = new OtaBaCxAqcs(); otaBaCxAqcsOld = new OtaBaCxAqcs();
} }
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxAqcsOld.getOtaId(), OtaModuleEnum.CX_AQCS, otaBaCxAqcsOld, otaBaCxAqcs); List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxAqcsOld.getOtaId(), OtaModuleEnum.CX_AQCS, otaBaCxAqcsOld, otaBaCxAqcs, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
} }
} }
@@ -11,6 +11,7 @@ import com.jero.modules.ota.service.IOtaBaCxJbxxService;
import com.jero.modules.ota.service.IOtaBaCxListService; import com.jero.modules.ota.service.IOtaBaCxListService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +36,9 @@ public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBa
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private ISysDictService sysDictService;
/** /**
* 保存 * 保存
* *
@@ -63,7 +67,7 @@ public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBa
otaBaCxJbxx.setUpdateTime(now); otaBaCxJbxx.setUpdateTime(now);
saveOrUpdate(otaBaCxJbxx); saveOrUpdate(otaBaCxJbxx);
ComparisonUtil cu = new ComparisonUtil(); ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxJbxx.getOtaId(), OtaModuleEnum.CX_CXJBXX, OtaBaCxJbxxOld, otaBaCxJbxx); List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxJbxx.getOtaId(), OtaModuleEnum.CX_CXJBXX, OtaBaCxJbxxOld, otaBaCxJbxx, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
return otaBaCxJbxx; return otaBaCxJbxx;
} }
@@ -14,6 +14,7 @@ import com.jero.modules.ota.service.IOtaBaCxJsfzbacsService;
import com.jero.modules.ota.service.IOtaBaCxSjmkService; import com.jero.modules.ota.service.IOtaBaCxSjmkService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -36,6 +37,9 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
@Autowired @Autowired
private IOtaBaCxSjmkService OtaBaCxSjmkService; private IOtaBaCxSjmkService OtaBaCxSjmkService;
@Autowired
private ISysDictService sysDictService;
/** /**
* 保存 * 保存
*/ */
@@ -51,18 +55,18 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
otaBaCxJsfzbacs.setUpdateTime(now); otaBaCxJsfzbacs.setUpdateTime(now);
saveOrUpdate(otaBaCxJsfzbacs); saveOrUpdate(otaBaCxJsfzbacs);
ComparisonUtil cu = new ComparisonUtil(); ComparisonUtil cu = new ComparisonUtil();
if(ObjectUtils.isEmpty(otaBaCxJsfzbacsOld)){ if (ObjectUtils.isEmpty(otaBaCxJsfzbacsOld)) {
otaBaCxJsfzbacsOld = new OtaBaCxJsfzbacs(); otaBaCxJsfzbacsOld = new OtaBaCxJsfzbacs();
} }
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, otaBaCxJsfzbacsOld, otaBaCxJsfzbacs); List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, otaBaCxJsfzbacsOld, otaBaCxJsfzbacs, sysDictService);
//处理控制器列表,先删除,后添加 //处理控制器列表,先删除,后添加
List<OtaBaCxSjmk> oldList = OtaBaCxSjmkService.queryByOtaId(otaId); List<OtaBaCxSjmk> oldList = OtaBaCxSjmkService.queryByOtaId(otaId);
OtaBaCxSjmkService.deleteByOtaId(otaId); OtaBaCxSjmkService.deleteByOtaId(otaId);
JSONArray kzq = json.getJSONArray("kzq"); JSONArray kzq = json.getJSONArray("kzq");
List<OtaBaCxSjmk> sjmkList = parseKzqData(kzq, otaId); List<OtaBaCxSjmk> sjmkList = parseKzqData(kzq, otaId);
OtaBaCxSjmkService.saveBatch(sjmkList); OtaBaCxSjmkService.saveOrUpdateBatch(sjmkList);
cu.comparisonListRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, OtaTitleEnum.BJMC.getName(), oldList, sjmkList); cu.comparisonListRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, OtaTitleEnum.BJMC.getName(), oldList, sjmkList, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
} }
@@ -78,11 +82,14 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
OtaBaCxSjmk sjmk = new OtaBaCxSjmk(); OtaBaCxSjmk sjmk = new OtaBaCxSjmk();
sjmk.setOtaId(otaId); sjmk.setOtaId(otaId);
for (Field field : fields) { for (Field field : fields) {
if (field.getName().equals("createTime") || field.getName().equals("updateTime")) {
continue;
}
Object kzqObj = kzqMap.get(field.getName()); Object kzqObj = kzqMap.get(field.getName());
if (null != kzqObj) { if (null != kzqObj) {
try { try {
field.setAccessible(true); field.setAccessible(true);
field.set(sjmk, kzqObj); field.set(sjmk, kzqObj.toString());
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -102,11 +109,14 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
Map<String, Object> bjMap = bj.getInnerMap(); Map<String, Object> bjMap = bj.getInnerMap();
Field[] fields = OtaBaCxJsfzbacs.class.getDeclaredFields(); Field[] fields = OtaBaCxJsfzbacs.class.getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
if (field.getName().equals("createTime") || field.getName().equals("updateTime")) {
continue;
}
Object bjObj = bjMap.get(field.getName()); Object bjObj = bjMap.get(field.getName());
if (null != bjObj) { if (null != bjObj) {
try { try {
field.setAccessible(true); field.setAccessible(true);
field.set(otaBaCxJsfzbacs, bjObj); field.set(otaBaCxJsfzbacs, bjObj.toString());
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -12,6 +12,7 @@ import com.jero.modules.ota.service.IOtaBaCxKsjjsmccsService;
import com.jero.modules.ota.service.IOtaBaCxListService; import com.jero.modules.ota.service.IOtaBaCxListService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.system.service.ISysDictService;
import com.jero.modules.system.util.StringUtils; import com.jero.modules.system.util.StringUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -38,6 +39,9 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private ISysDictService sysDictService;
/** /**
* 保存 * 保存
* *
@@ -78,7 +82,7 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
newList.add(otaBaCxJsfzbacs); newList.add(otaBaCxJsfzbacs);
} }
ComparisonUtil cu = new ComparisonUtil(); ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.CX_KZXSJDJSFZGNMCYCS, OtaTitleEnum.GNMC.getName(), oldList, newList); List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.CX_KZXSJDJSFZGNMCYCS, OtaTitleEnum.GNMC.getName(), oldList, newList, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
String fj = (String) json.get("fj"); String fj = (String) json.get("fj");
if (StringUtils.isNotEmpty(fj)) { if (StringUtils.isNotEmpty(fj)) {
@@ -12,6 +12,7 @@ import com.jero.modules.ota.service.IOtaBaCxKsjxtmccsService;
import com.jero.modules.ota.service.IOtaBaCxListService; import com.jero.modules.ota.service.IOtaBaCxListService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.system.service.ISysDictService;
import com.jero.modules.system.util.StringUtils; import com.jero.modules.system.util.StringUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +38,9 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private ISysDictService sysDictService;
/** /**
* 保存 * 保存
* *
@@ -77,7 +81,7 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
newList.add(otaBaCxKsjxtmccs); newList.add(otaBaCxKsjxtmccs);
} }
ComparisonUtil cu = new ComparisonUtil(); ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.CX_KSJDXTMCYCS, OtaTitleEnum.XTLB.getName(), oldList, newList); List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.CX_KSJDXTMCYCS, OtaTitleEnum.XTLB.getName(), oldList, newList, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
String fj = (String) json.get("fj"); String fj = (String) json.get("fj");
if (StringUtils.isNotEmpty(fj)) { if (StringUtils.isNotEmpty(fj)) {
@@ -9,6 +9,7 @@ import com.jero.modules.ota.mapper.OtaBaCxQtMapper;
import com.jero.modules.ota.service.IOtaBaCxQtService; import com.jero.modules.ota.service.IOtaBaCxQtService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -30,6 +31,9 @@ public class OtaBaCxQtServiceImpl extends ServiceImpl<OtaBaCxQtMapper, OtaBaCxQt
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private ISysDictService sysDictService;
/** /**
* 保存 * 保存
* *
@@ -49,10 +53,10 @@ public class OtaBaCxQtServiceImpl extends ServiceImpl<OtaBaCxQtMapper, OtaBaCxQt
otaBaCxQt.setUpdateTime(now); otaBaCxQt.setUpdateTime(now);
saveOrUpdate(otaBaCxQt); saveOrUpdate(otaBaCxQt);
ComparisonUtil cu = new ComparisonUtil(); ComparisonUtil cu = new ComparisonUtil();
if(ObjectUtils.isEmpty(otaBaCxQtOld)){ if (ObjectUtils.isEmpty(otaBaCxQtOld)) {
otaBaCxQtOld = new OtaBaCxQt(); otaBaCxQtOld = new OtaBaCxQt();
} }
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxQt.getOtaId(), OtaModuleEnum.CX_QT, otaBaCxQtOld, otaBaCxQt); List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxQt.getOtaId(), OtaModuleEnum.CX_QT, otaBaCxQtOld, otaBaCxQt, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
} }
} }
@@ -12,6 +12,7 @@ import com.jero.modules.ota.mapper.OtaBaCxZxsjyqMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService; import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.service.IOtaBaCxZxsjyqService; import com.jero.modules.ota.service.IOtaBaCxZxsjyqService;
import com.jero.modules.ota.utils.ComparisonUtil; import com.jero.modules.ota.utils.ComparisonUtil;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +36,10 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
@Autowired @Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService; private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private ISysDictService sysDictService;
/** /**
* 保存 * 保存
* *
@@ -66,7 +71,7 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
if (ObjectUtils.isEmpty(otaBaCxZxsjyqOld)) { if (ObjectUtils.isEmpty(otaBaCxZxsjyqOld)) {
otaBaCxZxsjyqOld = new OtaBaCxZxsjyq(); otaBaCxZxsjyqOld = new OtaBaCxZxsjyq();
} }
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxZxsjyq.getOtaId(), OtaModuleEnum.CX_ZXSJYQ, otaBaCxZxsjyqOld, otaBaCxZxsjyq); List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxZxsjyq.getOtaId(), OtaModuleEnum.CX_ZXSJYQ, otaBaCxZxsjyqOld, otaBaCxZxsjyq, sysDictService);
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
} }
@@ -3,6 +3,7 @@ package com.jero.modules.ota.utils;
import com.jero.modules.ota.entity.OtaBaCxTxjl; import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.enums.OtaModuleEnum; import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.enums.OtaTitleEnum; import com.jero.modules.ota.enums.OtaTitleEnum;
import com.jero.modules.system.service.ISysDictService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@@ -23,7 +24,7 @@ public class ComparisonUtil<T> {
/** /**
* 对比字段并添加到记录 * 对比字段并添加到记录
*/ */
public List<OtaBaCxTxjl> comparisonRecord(String otaId, OtaModuleEnum otaModuleEnum, T oldClazz, T newClazz) { public List<OtaBaCxTxjl> comparisonRecord(String otaId, OtaModuleEnum otaModuleEnum, T oldClazz, T newClazz, ISysDictService sysDictService) {
List<OtaBaCxTxjl> resList = new ArrayList<>(); List<OtaBaCxTxjl> resList = new ArrayList<>();
Field[] fields = newClazz.getClass().getDeclaredFields(); Field[] fields = newClazz.getClass().getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
@@ -34,8 +35,8 @@ public class ComparisonUtil<T> {
} }
title = ote.getValue(); title = ote.getValue();
field.setAccessible(true); field.setAccessible(true);
String newStr = parseDictText(ote, field, newClazz); String newStr = parseDictText(ote, field, newClazz, sysDictService);
String oldStr = parseDictText(ote, field, oldClazz); String oldStr = parseDictText(ote, field, oldClazz, sysDictService);
if (!newStr.equals(oldStr)) { if (!newStr.equals(oldStr)) {
String content = "" + title + "" + oldStr + "改为" + newStr; String content = "" + title + "" + oldStr + "改为" + newStr;
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content)); resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
@@ -44,7 +45,7 @@ public class ComparisonUtil<T> {
return resList; return resList;
} }
public List<OtaBaCxTxjl> comparisonListRecord(String otaId, OtaModuleEnum otaModuleEnum, String tableTitle, List<T> oldList, List<T> newList) { public List<OtaBaCxTxjl> comparisonListRecord(String otaId, OtaModuleEnum otaModuleEnum, String tableTitle, List<T> oldList, List<T> newList, ISysDictService sysDictService) {
List<OtaBaCxTxjl> resList = new ArrayList<>(); List<OtaBaCxTxjl> resList = new ArrayList<>();
try { try {
for (T newObj : newList) { for (T newObj : newList) {
@@ -76,7 +77,7 @@ public class ComparisonUtil<T> {
for (T oldObj : oldList) { for (T oldObj : oldList) {
String oldId = idField.get(oldObj).toString(); String oldId = idField.get(oldObj).toString();
if (oldId.equals(id.toString())) { if (oldId.equals(id.toString())) {
resList.addAll(comparisonCertRecord(otaId, otaModuleEnum, tableTitle, newObj, oldObj)); resList.addAll(comparisonCertRecord(otaId, otaModuleEnum, tableTitle, newObj, oldObj, sysDictService));
} }
} }
} }
@@ -114,7 +115,7 @@ public class ComparisonUtil<T> {
} }
public List<OtaBaCxTxjl> comparisonCertRecord(String otaId, OtaModuleEnum otaModuleEnum, String tableTitle, T oldClazz, T newClazz) { public List<OtaBaCxTxjl> comparisonCertRecord(String otaId, OtaModuleEnum otaModuleEnum, String tableTitle, T oldClazz, T newClazz, ISysDictService sysDictService) {
List<OtaBaCxTxjl> resList = new ArrayList<>(); List<OtaBaCxTxjl> resList = new ArrayList<>();
Field[] fields = newClazz.getClass().getDeclaredFields(); Field[] fields = newClazz.getClass().getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
@@ -126,16 +127,17 @@ public class ComparisonUtil<T> {
} }
title = ote.getValue(); title = ote.getValue();
field.setAccessible(true); field.setAccessible(true);
String newStr = parseDictText(ote, field, newClazz); String newStr = parseDictText(ote, field, newClazz, sysDictService);
String oldStr = parseDictText(ote, field, oldClazz); String oldStr = parseDictText(ote, field, oldClazz, sysDictService);
if (!newStr.equals(oldStr)) { if (!newStr.equals(oldStr)) {
//TODO null
Object newVal = field.get(newClazz); Object newVal = field.get(newClazz);
Object newTitleVal = newVal.getClass().getDeclaredField(tableTitle).get(newVal);
String newTitleStr = ""; String newTitleStr = "";
if (ObjectUtils.isNotEmpty(newTitleVal)) { if (ObjectUtils.isNotEmpty(newVal)) {
newTitleStr = newTitleVal.toString(); Object newTitleVal = newVal.getClass().getDeclaredField(tableTitle).get(newVal);
if (ObjectUtils.isNotEmpty(newTitleVal)) {
newTitleStr = newTitleVal.toString();
}
} }
String content = newTitleStr + "" + title + "" + oldStr + "改为" + newStr; String content = newTitleStr + "" + title + "" + oldStr + "改为" + newStr;
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content)); resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
@@ -147,20 +149,13 @@ public class ComparisonUtil<T> {
return resList; return resList;
} }
private String parseDictText(OtaTitleEnum ote, Field field, T clazz) { private String parseDictText(OtaTitleEnum ote, Field field, T clazz, ISysDictService sysDictService) {
String res = ""; String res = "";
try { try {
Object newVal = field.get(clazz); Object newVal = field.get(clazz);
if ("1".equals(ote.getType())) { if ("0".equals(ote.getType())) {
try { if (ObjectUtils.isNotEmpty(newVal)) {
Field fieldDict = clazz.getClass().getDeclaredField(field.getName() + "_dictText"); res = newVal.toString();
fieldDict.setAccessible(true);
Object newValDict = fieldDict.get(clazz);
if (ObjectUtils.isNotEmpty(newValDict)) {
res = newValDict.toString();
}
} catch (NoSuchFieldException e) {
e.printStackTrace();
} }
} else if ("2".equals(ote.getType())) { } else if ("2".equals(ote.getType())) {
if (ObjectUtils.isNotEmpty(newVal)) { if (ObjectUtils.isNotEmpty(newVal)) {
@@ -171,8 +166,17 @@ public class ComparisonUtil<T> {
} }
} }
} else { } else {
newVal = field.get(clazz);
if (ObjectUtils.isNotEmpty(newVal)) { if (ObjectUtils.isNotEmpty(newVal)) {
res = newVal.toString(); String[] newValStr = newVal.toString().split(",");
res = "";
for (int i = 0; i < newValStr.length; i++) {
if (i == newValStr.length - 1) {
res += sysDictService.queryDictTextByKey(ote.getType(), newValStr[i]);
} else {
res += sysDictService.queryDictTextByKey(ote.getType(), newValStr[i]) + ",";
}
}
} }
} }
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {