开发OTA备案工具-填写记录
This commit is contained in:
@@ -76,4 +76,12 @@ public class OtaBaCxTxjl implements Serializable {
|
|||||||
@ApiModelProperty(value = "填写内容")
|
@ApiModelProperty(value = "填写内容")
|
||||||
private String content;
|
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;
|
package com.jero.modules.ota.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.OtaModuleEnum;
|
||||||
|
import com.jero.modules.ota.enums.OtaTitleEnum;
|
||||||
import com.jero.modules.ota.mapper.OtaBaCxJsfzbacsMapper;
|
import com.jero.modules.ota.mapper.OtaBaCxJsfzbacsMapper;
|
||||||
import com.jero.modules.ota.service.IOtaBaCxJsfzbacsService;
|
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.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;
|
||||||
@@ -19,8 +21,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 车型备案-驾驶辅助系统基础备案参数
|
* @Description: 车型备案-驾驶辅助系统基础备案参数
|
||||||
* @Author: jero-boot
|
* @Author: jero-boot
|
||||||
@@ -52,12 +52,15 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
|
|||||||
saveOrUpdate(otaBaCxJsfzbacs);
|
saveOrUpdate(otaBaCxJsfzbacs);
|
||||||
ComparisonUtil cu = new ComparisonUtil();
|
ComparisonUtil cu = new ComparisonUtil();
|
||||||
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, otaBaCxJsfzbacsOld, otaBaCxJsfzbacs);
|
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, otaBaCxJsfzbacsOld, otaBaCxJsfzbacs);
|
||||||
otaBaCxTxjlService.saveBatch(reList);
|
|
||||||
//处理控制器列表,先删除,后添加
|
//处理控制器列表,先删除,后添加
|
||||||
|
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.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.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.jero.modules.ota.entity.*;
|
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.mapper.OtaBaCxKsjjsmccsMapper;
|
||||||
import com.jero.modules.ota.service.IOtaBaCxKsjjsmccsService;
|
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.utils.ComparisonUtil;
|
||||||
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;
|
||||||
@@ -31,6 +35,9 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IOtaBaCxListService otaBaCxListService;
|
private IOtaBaCxListService otaBaCxListService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOtaBaCxTxjlService otaBaCxTxjlService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*
|
*
|
||||||
@@ -38,9 +45,12 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void add(JSONObject json) {
|
public void add(JSONObject json) {
|
||||||
|
List<OtaBaCxKsjjsmccs> newList = new ArrayList<>();
|
||||||
|
List<OtaBaCxKsjjsmccs> oldList;
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
String otaId = (String) json.get("otaId");
|
String otaId = (String) json.get("otaId");
|
||||||
if (StringUtils.isNotEmpty(otaId)) {
|
if (StringUtils.isNotEmpty(otaId)) {
|
||||||
|
oldList = getByOtaId(otaId);
|
||||||
deleteByOtaId(otaId);
|
deleteByOtaId(otaId);
|
||||||
JSONArray list = json.getJSONArray("list");
|
JSONArray list = json.getJSONArray("list");
|
||||||
for (Object obj : list) {
|
for (Object obj : list) {
|
||||||
@@ -65,7 +75,11 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
|
|||||||
otaBaCxJsfzbacs.setCreateTime(now);
|
otaBaCxJsfzbacs.setCreateTime(now);
|
||||||
otaBaCxJsfzbacs.setUpdateTime(now);
|
otaBaCxJsfzbacs.setUpdateTime(now);
|
||||||
save(otaBaCxJsfzbacs);
|
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");
|
String fj = (String) json.get("fj");
|
||||||
if (StringUtils.isNotEmpty(fj)) {
|
if (StringUtils.isNotEmpty(fj)) {
|
||||||
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
|
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.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.jero.modules.ota.entity.OtaBaCxJbxx;
|
import com.jero.modules.ota.entity.*;
|
||||||
import com.jero.modules.ota.entity.OtaBaCxKsjjsmccs;
|
import com.jero.modules.ota.enums.OtaModuleEnum;
|
||||||
import com.jero.modules.ota.entity.OtaBaCxKsjxtmccs;
|
import com.jero.modules.ota.enums.OtaTitleEnum;
|
||||||
import com.jero.modules.ota.entity.OtaBaCxList;
|
|
||||||
import com.jero.modules.ota.mapper.OtaBaCxKsjxtmccsMapper;
|
import com.jero.modules.ota.mapper.OtaBaCxKsjxtmccsMapper;
|
||||||
import com.jero.modules.ota.service.IOtaBaCxKsjxtmccsService;
|
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.utils.ComparisonUtil;
|
||||||
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;
|
||||||
@@ -33,6 +34,9 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IOtaBaCxListService otaBaCxListService;
|
private IOtaBaCxListService otaBaCxListService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOtaBaCxTxjlService otaBaCxTxjlService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*
|
*
|
||||||
@@ -40,9 +44,12 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void add(JSONObject json) {
|
public void add(JSONObject json) {
|
||||||
|
List<OtaBaCxKsjxtmccs> newList = new ArrayList<>();
|
||||||
|
List<OtaBaCxKsjxtmccs> oldList;
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
String otaId = (String) json.get("otaId");
|
String otaId = (String) json.get("otaId");
|
||||||
if (StringUtils.isNotEmpty(otaId)) {
|
if (StringUtils.isNotEmpty(otaId)) {
|
||||||
|
oldList = getByOtaId(otaId);
|
||||||
deleteByOtaId(otaId);
|
deleteByOtaId(otaId);
|
||||||
JSONArray list = json.getJSONArray("list");
|
JSONArray list = json.getJSONArray("list");
|
||||||
for (Object obj : list) {
|
for (Object obj : list) {
|
||||||
@@ -67,7 +74,11 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
|
|||||||
otaBaCxKsjxtmccs.setCreateTime(now);
|
otaBaCxKsjxtmccs.setCreateTime(now);
|
||||||
otaBaCxKsjxtmccs.setUpdateTime(now);
|
otaBaCxKsjxtmccs.setUpdateTime(now);
|
||||||
save(otaBaCxKsjxtmccs);
|
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");
|
String fj = (String) json.get("fj");
|
||||||
if (StringUtils.isNotEmpty(fj)) {
|
if (StringUtils.isNotEmpty(fj)) {
|
||||||
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
|
OtaBaCxList otaBaCxList = otaBaCxListService.queryById(otaId);
|
||||||
|
|||||||
+93
-6
@@ -12,6 +12,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 对比新老数据,添加填写记录
|
* 对比新老数据,添加填写记录
|
||||||
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
public class ComparisonUtil<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) {
|
public List<OtaBaCxTxjl> comparisonRecord(String otaId, OtaModuleEnum otaModuleEnum, T oldClazz, T newClazz) {
|
||||||
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) {
|
||||||
try {
|
try {
|
||||||
@@ -44,11 +44,8 @@ public class ComparisonUtil<T> {
|
|||||||
oldStr = oldVal.toString();
|
oldStr = oldVal.toString();
|
||||||
}
|
}
|
||||||
if (!newStr.equals(oldStr)) {
|
if (!newStr.equals(oldStr)) {
|
||||||
OtaBaCxTxjl otaBaCxTxjl = new OtaBaCxTxjl();
|
String content = "由" + title + "的" + oldStr + "改为" + newStr;
|
||||||
otaBaCxTxjl.setModule(otaModuleEnum.getName());
|
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
|
||||||
otaBaCxTxjl.setContent("由" + title + "的" + oldStr + "改为" + newStr);
|
|
||||||
otaBaCxTxjl.setOtaId(otaId);
|
|
||||||
resList.add(otaBaCxTxjl);
|
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -56,4 +53,94 @@ public class ComparisonUtil<T> {
|
|||||||
}
|
}
|
||||||
return resList;
|
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