开发OTA备案工具-填写记录
This commit is contained in:
@@ -76,4 +76,12 @@ public class OtaBaCxTxjl implements Serializable {
|
||||
@ApiModelProperty(value = "填写内容")
|
||||
private String content;
|
||||
|
||||
public OtaBaCxTxjl() {
|
||||
}
|
||||
|
||||
public OtaBaCxTxjl(String otaId, String module, String content) {
|
||||
this.otaId = otaId;
|
||||
this.module = module;
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-6
@@ -1,14 +1,16 @@
|
||||
package com.jero.modules.ota.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.modules.ota.entity.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.modules.ota.entity.OtaBaCxJsfzbacs;
|
||||
import com.jero.modules.ota.entity.OtaBaCxSjmk;
|
||||
import com.jero.modules.ota.entity.OtaBaCxTxjl;
|
||||
import com.jero.modules.ota.enums.OtaModuleEnum;
|
||||
import com.jero.modules.ota.enums.OtaTitleEnum;
|
||||
import com.jero.modules.ota.mapper.OtaBaCxJsfzbacsMapper;
|
||||
import com.jero.modules.ota.service.IOtaBaCxJsfzbacsService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxLsjlService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxSjmkService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
|
||||
import com.jero.modules.ota.utils.ComparisonUtil;
|
||||
@@ -19,8 +21,6 @@ import org.springframework.stereotype.Service;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 车型备案-驾驶辅助系统基础备案参数
|
||||
* @Author: jero-boot
|
||||
@@ -52,12 +52,15 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
|
||||
saveOrUpdate(otaBaCxJsfzbacs);
|
||||
ComparisonUtil cu = new ComparisonUtil();
|
||||
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, otaBaCxJsfzbacsOld, otaBaCxJsfzbacs);
|
||||
otaBaCxTxjlService.saveBatch(reList);
|
||||
|
||||
//处理控制器列表,先删除,后添加
|
||||
List<OtaBaCxSjmk> oldList = OtaBaCxSjmkService.queryByOtaId(otaId);
|
||||
OtaBaCxSjmkService.deleteByOtaId(otaId);
|
||||
JSONArray kzq = json.getJSONArray("kzq");
|
||||
List<OtaBaCxSjmk> sjmkList = parseKzqData(kzq, otaId);
|
||||
OtaBaCxSjmkService.saveBatch(sjmkList);
|
||||
cu.comparisonListRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, OtaTitleEnum.BJMC.getName(), oldList, sjmkList);
|
||||
otaBaCxTxjlService.saveBatch(reList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
@@ -5,9 +5,13 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.modules.ota.entity.*;
|
||||
import com.jero.modules.ota.enums.OtaModuleEnum;
|
||||
import com.jero.modules.ota.enums.OtaTitleEnum;
|
||||
import com.jero.modules.ota.mapper.OtaBaCxKsjjsmccsMapper;
|
||||
import com.jero.modules.ota.service.IOtaBaCxKsjjsmccsService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxListService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
|
||||
import com.jero.modules.ota.utils.ComparisonUtil;
|
||||
import com.jero.modules.system.util.StringUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -31,6 +35,9 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
|
||||
@Autowired
|
||||
private IOtaBaCxListService otaBaCxListService;
|
||||
|
||||
@Autowired
|
||||
private IOtaBaCxTxjlService otaBaCxTxjlService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
@@ -38,9 +45,12 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
|
||||
*/
|
||||
@Override
|
||||
public void add(JSONObject json) {
|
||||
List<OtaBaCxKsjjsmccs> newList = new ArrayList<>();
|
||||
List<OtaBaCxKsjjsmccs> oldList;
|
||||
Date now = new Date();
|
||||
String otaId = (String) json.get("otaId");
|
||||
if (StringUtils.isNotEmpty(otaId)) {
|
||||
oldList = getByOtaId(otaId);
|
||||
deleteByOtaId(otaId);
|
||||
JSONArray list = json.getJSONArray("list");
|
||||
for (Object obj : list) {
|
||||
@@ -65,7 +75,11 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
|
||||
otaBaCxJsfzbacs.setCreateTime(now);
|
||||
otaBaCxJsfzbacs.setUpdateTime(now);
|
||||
save(otaBaCxJsfzbacs);
|
||||
newList.add(otaBaCxJsfzbacs);
|
||||
}
|
||||
ComparisonUtil cu = new ComparisonUtil();
|
||||
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.CX_KZXSJDJSFZGNMCYCS, OtaTitleEnum.GNMC.getName(), oldList, newList);
|
||||
otaBaCxTxjlService.saveBatch(reList);
|
||||
String fj = (String) json.get("fj");
|
||||
if (StringUtils.isNotEmpty(fj)) {
|
||||
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
|
||||
|
||||
+15
-4
@@ -4,13 +4,14 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.modules.ota.entity.OtaBaCxJbxx;
|
||||
import com.jero.modules.ota.entity.OtaBaCxKsjjsmccs;
|
||||
import com.jero.modules.ota.entity.OtaBaCxKsjxtmccs;
|
||||
import com.jero.modules.ota.entity.OtaBaCxList;
|
||||
import com.jero.modules.ota.entity.*;
|
||||
import com.jero.modules.ota.enums.OtaModuleEnum;
|
||||
import com.jero.modules.ota.enums.OtaTitleEnum;
|
||||
import com.jero.modules.ota.mapper.OtaBaCxKsjxtmccsMapper;
|
||||
import com.jero.modules.ota.service.IOtaBaCxKsjxtmccsService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxListService;
|
||||
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
|
||||
import com.jero.modules.ota.utils.ComparisonUtil;
|
||||
import com.jero.modules.system.util.StringUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -33,6 +34,9 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
|
||||
@Autowired
|
||||
private IOtaBaCxListService otaBaCxListService;
|
||||
|
||||
@Autowired
|
||||
private IOtaBaCxTxjlService otaBaCxTxjlService;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
@@ -40,9 +44,12 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
|
||||
*/
|
||||
@Override
|
||||
public void add(JSONObject json) {
|
||||
List<OtaBaCxKsjxtmccs> newList = new ArrayList<>();
|
||||
List<OtaBaCxKsjxtmccs> oldList;
|
||||
Date now = new Date();
|
||||
String otaId = (String) json.get("otaId");
|
||||
if (StringUtils.isNotEmpty(otaId)) {
|
||||
oldList = getByOtaId(otaId);
|
||||
deleteByOtaId(otaId);
|
||||
JSONArray list = json.getJSONArray("list");
|
||||
for (Object obj : list) {
|
||||
@@ -67,7 +74,11 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
|
||||
otaBaCxKsjxtmccs.setCreateTime(now);
|
||||
otaBaCxKsjxtmccs.setUpdateTime(now);
|
||||
save(otaBaCxKsjxtmccs);
|
||||
newList.add(otaBaCxKsjxtmccs);
|
||||
}
|
||||
ComparisonUtil cu = new ComparisonUtil();
|
||||
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.CX_KSJDXTMCYCS, OtaTitleEnum.XTLB.getName(), oldList, newList);
|
||||
otaBaCxTxjlService.saveBatch(reList);
|
||||
String fj = (String) json.get("fj");
|
||||
if (StringUtils.isNotEmpty(fj)) {
|
||||
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
|
||||
|
||||
+93
-6
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 对比新老数据,添加填写记录
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class ComparisonUtil<T> {
|
||||
@@ -24,7 +25,6 @@ public class ComparisonUtil<T> {
|
||||
*/
|
||||
public List<OtaBaCxTxjl> comparisonRecord(String otaId, OtaModuleEnum otaModuleEnum, T oldClazz, T newClazz) {
|
||||
List<OtaBaCxTxjl> resList = new ArrayList<>();
|
||||
|
||||
Field[] fields = newClazz.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
@@ -44,11 +44,8 @@ public class ComparisonUtil<T> {
|
||||
oldStr = oldVal.toString();
|
||||
}
|
||||
if (!newStr.equals(oldStr)) {
|
||||
OtaBaCxTxjl otaBaCxTxjl = new OtaBaCxTxjl();
|
||||
otaBaCxTxjl.setModule(otaModuleEnum.getName());
|
||||
otaBaCxTxjl.setContent("由" + title + "的" + oldStr + "改为" + newStr);
|
||||
otaBaCxTxjl.setOtaId(otaId);
|
||||
resList.add(otaBaCxTxjl);
|
||||
String content = "由" + title + "的" + oldStr + "改为" + newStr;
|
||||
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
@@ -56,4 +53,94 @@ public class ComparisonUtil<T> {
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
public List<OtaBaCxTxjl> comparisonListRecord(String otaId, OtaModuleEnum otaModuleEnum, String tableTitle, List<T> oldList, List<T> newList) {
|
||||
List<OtaBaCxTxjl> resList = new ArrayList<>();
|
||||
try {
|
||||
for (T newObj : newList) {
|
||||
if (ObjectUtils.isNotEmpty(newObj)) {
|
||||
Field idField = newObj.getClass().getDeclaredField("id");
|
||||
Object id = idField.get(newObj);
|
||||
if (ObjectUtils.isEmpty(id)) {
|
||||
String content = "新增了一条" + newObj.getClass().getDeclaredField(tableTitle).get(newObj).toString();
|
||||
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
|
||||
Field[] fields = newObj.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
String title = OtaTitleEnum.getVal(field.getName());
|
||||
if (ObjectUtils.isEmpty(title)) {
|
||||
continue;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
Object newVal = field.get(newObj);
|
||||
String newStr = "空";
|
||||
if (ObjectUtils.isNotEmpty(newVal)) {
|
||||
newStr = newVal.toString();
|
||||
}
|
||||
content = "增加" + newObj.getClass().getDeclaredField(tableTitle).get(newObj).toString() + "中" + title + "为" + newStr;
|
||||
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
|
||||
}
|
||||
} else {
|
||||
for (T oldObj : oldList) {
|
||||
String oldId = idField.get(oldObj).toString();
|
||||
if (oldId.equals(id.toString())) {
|
||||
resList.addAll(comparisonCertRecord(otaId, otaModuleEnum, tableTitle, newObj, oldObj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (T oldObj : oldList) {
|
||||
if (ObjectUtils.isNotEmpty(oldObj)) {
|
||||
Field idField = oldObj.getClass().getDeclaredField("id");
|
||||
String oldId = idField.get(oldObj).toString();
|
||||
for (T newObj : newList) {
|
||||
if (ObjectUtils.isNotEmpty(newObj)) {
|
||||
Object newId = idField.get(newObj);
|
||||
if (ObjectUtils.isNotEmpty(newObj) && oldId.equals(newId.toString())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String content = "删除了" + oldObj.getClass().getDeclaredField(tableTitle).get(oldObj).toString();
|
||||
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
public List<OtaBaCxTxjl> comparisonCertRecord(String otaId, OtaModuleEnum otaModuleEnum, String tableTitle, T oldClazz, T newClazz) {
|
||||
List<OtaBaCxTxjl> resList = new ArrayList<>();
|
||||
Field[] fields = newClazz.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
String title = OtaTitleEnum.getVal(field.getName());
|
||||
if (ObjectUtils.isEmpty(title)) {
|
||||
continue;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
Object newVal = field.get(newClazz);
|
||||
Object oldVal = field.get(oldClazz);
|
||||
String newStr = "空";
|
||||
if (ObjectUtils.isNotEmpty(newVal)) {
|
||||
newStr = newVal.toString();
|
||||
}
|
||||
String oldStr = "空";
|
||||
if (ObjectUtils.isNotEmpty(oldVal)) {
|
||||
oldStr = oldVal.toString();
|
||||
}
|
||||
if (!newStr.equals(oldStr)) {
|
||||
String content = newVal.getClass().getDeclaredField(tableTitle).get(newVal).toString() + "的" + title + "由" + oldStr + "改为" + newStr;
|
||||
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
|
||||
}
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user