Merge branch 'dev_2nd_LCYH' of http://git.hzwlsoft.com/laws-nio/laws-weilai into dev_2nd_LCYH

This commit is contained in:
yuekuo
2023-03-26 10:40:39 +08:00
14 changed files with 720 additions and 155 deletions
@@ -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;
}
}
@@ -0,0 +1,46 @@
package com.jero.modules.ota.enums;
public enum OtaModuleEnum {
CX_CXJBXX("车型基本信息", "1","1"),
CX_ZXSJYQ("在线升级要求", "1","1"),
CX_AQCS("安全措施", "1","1"),
CX_KSJDXTMCYCS("可升级的系统名称与参数", "1","1"),
CX_KZXSJDJSFZGNMCYCS("可在线升级的驾驶辅助功能名称与参数", "1","1"),
CX_JSFZXTJCBACS("驾驶辅助系统基础备案参数", "1","1"),
CX_QT("其他", "1","1");
String name;
String nameEN;
String value;
private OtaModuleEnum(String name, String nameEN, String value) {
this.name = name;
this.nameEN = nameEN;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNameEN() {
return nameEN;
}
public void setNameEN(String nameEN) {
this.nameEN = nameEN;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -0,0 +1,231 @@
package com.jero.modules.ota.enums;
public enum OtaTitleEnum {
CPDJBH("cpdjbh", "产品登记编号"),
GGPC("ggpc", "公告批次"),
CPSB("cpsb", "产品商标"),
CPMC("cpmc", "产品名称"),
CPXH("cpxh", "产品型号"),
BAZT("bazt", "备案状态"),
BATJSJ("batjsj", "备案提交时间"),
CJSJ("cjsj", "创建时间"),
BZ("bz", "备注"),
CXMB("cxmb", "车型模板"),
QYMC("qymc", "企业名称"),
DJBH("djbh", "产品登记编号"),
CPLB("cplb", "产品类别"),
DLLX1("dllx1", "车辆动力类型"),
DLLX2("dllx2", "车辆动力类型"),
TXZD("txzd", "通信终端"),
CDOTASJ("cdotasj", "车端OTA升级管理系统"),
BHSJB("bhsjb", "保护升级包"),
BHCLBB("bhclbb", "保护车辆版本"),
CLGXNL("clgxnl", "车辆更新能力"),
CLSJTJ("clsjtj", "车辆升级条件"),
CLSJDL("clsjdl", "车辆升级所需电量"),
SJBHAQ("sjbhaq", "升级保护车辆安全"),
SJANTJ("sjantj", "升级所满足的安全条件"),
SJSBAQ("sjsbaq", "升级失败安全状态"),
SJGG("sjgg", "升级公告"),
SJZT("sjzt", "升级结果状态"),
ZMCL("zmcl", "证明材料"),
BHJZ("bhjz", "保护机制"),
FSXJZ("fsxjz", "防失效机制"),
SJSBCS("sjsbcs", "升级失败措施"),
XXAQJZ("xxaqjz", "信息安全机制"),
XTLB("xtlb", "系统类别"),
SFKSJ("sfksj", "是否可升级"),
SJBGCS("sjbgcs", "升级变更技术参数"),
TPT("tpt", "系统电子控制器架构拓扑图"),
KZQMC("kzqmc", "电子控制器名称"),
AQWZXDJ("aqwzxdj", "安全完整性等级"),
KZQSCQY("kzqscqy", "电子控制器生产企业"),
KZQXH("kzqxh", "电子控制器型号"),
YJBBXX("yjbbxx", "硬件版本信息"),
CSRJBBH("csrjbbh", "初始软件版本号"),
CSRJBWZSJ("csrjbwzsj", "初始软件包完整数据"),
SJSFYX("sjsfyx", "升级是否影响整车安全、节能、环保、防盗等"),
CZXTLX("czxtlx", "操作系统类型"),
CZXTSCQY("czxtscqy", "操作系统生产企业"),
CZXTBBH("czxtbbh", "操作系统版本号"),
GNMC("gnmc", "功能名称"),
PZQK("pzqk", "配置情况"),
JSZDHJB("jszdhjb", "驾驶自动化级别"),
SJGGCS("sjggcs", "升级可能变更的《公告》技术参数"),
GNMS("gnms", "功能描述"),
SYTJ("sytj", "适用条件"),
RJKFQY("rjkfqy", "软件开发企业"),
CSYZSJ("csyzsj", "初始软件包的完整性验证数据"),
FJ("fj", "附件"),
WLAQYQ_PZ("wlaqyqPz", "网络安全要求配置"),
WLAQYQ_SL("wlaqyqSl", "网络安全要求数量"),
WLAQYQ_BZWZ("wlaqyqBzwz", "网络安全要求布置位置"),
WLAQYQ_GGXH("wlaqyqGgxh", "网络安全要求规格型号"),
WLAQYQ_SCQY("wlaqyqScqy", "网络安全要求生产企业"),
HMBLD_PZ("hmbldPz", "毫米波雷达配置"),
HMBLD_SL("hmbldSl", "毫米波雷达数量"),
HMBLD_BZWZ("hmbldBzwz", "毫米波雷达布置位置"),
HMBLD_GGXH("hmbldGgxh", "毫米波雷达规格型号"),
HMBLD_SCQY("hmbldScqy", "毫米波雷达生产企业"),
CSBLD_PZ("csbldPz", "超声波雷达配置"),
CSBLD_SL("csbldSl", "超声波雷达数量"),
CSBLD_BZWZ("csbldBzwz", "超声波雷达布置位置"),
CSBLD_GGXH("csbldGgxh", "超声波雷达规格型号"),
CSBLD_SCQY("csbldScqy", "超声波雷达生产企业"),
SXTHS_PZ("sxthsPz", "摄像头倒车影像/(环视)配置"),
SXTHS_SL("sxthsSl", "摄像头倒车影像/(环视)数量"),
SXTHS_BZWZ("sxthsBzwz", "摄像头倒车影像/(环视)布置位置"),
SXTHS_GGXH("sxthsGgxh", "摄像头倒车影像/(环视)规格型号"),
SXTHS_SCQY("sxthsScqy", "摄像头倒车影像/(环视)生产企业"),
SXTDSD_PZ("sxtdsdPz", "摄像头单双多目配置"),
SXTDSD_SL("sxtdsdSl", "摄像头单双多目数量"),
SXTDSD_BZWZ("sxtdsdBzwz", "摄像头单双多目布置位置"),
SXTDSD_GGXH("sxtdsdGgxh", "摄像头单双多目规格型号"),
SXTDSD_SCQY("sxtdsdScqy", "摄像头单双多目生产企业"),
JSYJK_PZ("jsyjkPz", "驾驶员监控摄像头配置"),
JSYJK_SL("jsyjkSl", "驾驶员监控摄像头数量"),
JSYJK_BZWZ("jsyjkBzwz", "驾驶员监控摄像头布置位置"),
JSYJK_GGXH("jsyjkGgxh", "驾驶员监控摄像头规格型号"),
JSYJK_SCQY("jsyjkScqy", "驾驶员监控摄像头生产企业"),
JSYHW_PZ("jsyhwPz", "驾驶员监控红外传感器配置"),
JSYHW_SL("jsyhwSl", "驾驶员监控红外传感器数量"),
JSYHW_BZWZ("jsyhwBzwz", "驾驶员监控红外传感器布置位置"),
JSYHW_GGXH("jsyhwGgxh", "驾驶员监控红外传感器规格型号"),
JSYHW_SCQY("jsyhwScqy", "驾驶员监控红外传感器生产企业"),
CZWXDW_PZ("czwxdwPz", "车载卫星定位设备配置"),
CZWXDW_GGXH("czwxdwGgxh", "车载卫星定位设备规格型号"),
CZWXDW_SCQY("czwxdwScqy", "车载卫星定位设备生产企业"),
GXDH_PZ("gxdhPz", "惯性导航系统配置"),
GXDH_GGXH("gxdhGgxh", "惯性导航系统规格型号"),
GXDH_SCQY("gxdhScqy", "惯性导航系统生产企业"),
LSJ_PZ("lsjPz", "轮速计配置"),
LSJ_GGXH("lsjGgxh", "轮速计规格型号"),
LSJ_SCQY("lsjScqy", "轮速计生产企业"),
GJDDT_PZ("gjddtPz", "高精度地图配置"),
GJDDT_GGXH("gjddtGgxh", "高精度地图规格型号"),
GJDDT_SCQY("gjddtScqy", "高精度地图生产企业"),
DZWL_PZ("dzwlPz", "电子围栏配置"),
DZWL_DXXGCS("dzwlDxxgcs", "电子围栏"),
CZTX_PZ("cztxPz", "车载通信系统配置"),
CZTX_XTMC("cztx_xtmc", "车载通信系统系统名称"),
CZTX_GGXH("cztxGgxh", "车载通信系统规格型号"),
CZTX_SCQY("cztxScqy", "车载通信系统生产企业"),
CZTX_BBH("cztxBbh", "车载通信系统版本号"),
CZTX_KFQY("cztx_kfqy", "车载通信系统软件开发企业"),
JSFZCZJ_PZ("jsfzczjPz", "驾驶辅助功能操纵件配置"),
JSFZCZJ_MC("jsfzczjMc", "驾驶辅助功能操纵件名称"),
JSFZCZJ_YJXH("jsfzczjYjxh", "驾驶辅助功能操纵件硬件规格型号"),
JSFZCZJ_SCQY("jsfzczjScqy", "驾驶辅助功能操纵件生产企业"),
JSFZZSQ_PZ("jsfzzsqPz", "驾驶辅助功能指示器配置"),
JSFZZSQ_MC("jsfzzsqMc", "驾驶辅助功能指示器名称"),
JSFZZSQ_YJXH("jsfzzsqYjxh", "驾驶辅助功能指示器硬件规格型号"),
JSFZZSQ_SCQY("jsfzzsqScqy", "驾驶辅助功能指示器生产企业"),
FXPTSTS_PZ("fxptstsPz", "方向盘脱手提示器配置"),
FXPTSTS_MC("fxptstsMc", "方向盘脱手提示器名称"),
FXPTSTS_YJXH("fxptstsYjxh", "方向盘脱手提示器硬件规格型号"),
FXPTSTS_SCQY("fxptstsScqy", "方向盘脱手提示器生产企业"),
JSYZYLTS_PZ("jsyzyltsPz", "驾驶员注意力提醒指示器配置"),
JSYZYLTS_MC("jsyzyltsMc", "驾驶员注意力提醒指示器名称"),
JSYZYLTS_YJXH("jsyzyltsYjxh", "驾驶员注意力提醒指示器硬件规格型号"),
JSYZYLTS_SCQY("jsyzyltsScqy", "驾驶员注意力提醒指示器生产企业"),
DSSAD_PZ("dssadPz", "自动驾驶数据记录系统配置"),
DSSAD_GGXH("dssadGgxh", "自动驾驶数据记录系统规格型号"),
DSSAD_SCQY("dssadScqy", "自动驾驶数据记录系统生产企业"),
EDR_PZ("edrPz", "事件数据记录系统配置"),
EDR_GGXH("edrGgxh", "事件数据记录系统规格型号"),
EDR_SCQY("edrScqy", "事件数据记录系统生产企业"),
BJMC("bjmc", "部件名称"),
YJGGXH("yjggxh", "硬件规格型号"),
YJSCQY("yjscqy", "硬件生产企业"),
RJBB("rjbb", "软件版本"),
BZWZ("bzwz", "布置位置"),
SJBBHCS("sjbbhcs", "升级包保护措施"),
BABH("babh", "备案编号"),
BAPC("bapc", "备案批次"),
ZSL("zsl", "总数量"),
SCRQKS("scrqks", "生产日期开始"),
SCRQJS("scrqjs", "生产日期结束"),
VIN_LIST("vinList", "VIN码清单"),
SJMD("sjmd", "升级目的"),
SFBGCS("sfbgcs", "是否变更对应车型的《公告》技术参数"),
JSXNBH("jsxnbh", "是否涉及性能变化"),
FHGD("fhgd", "是否符合国家法律、行政法规、规章规定,以及道路机动车辆公告管理相关国家技术标准及安全技术条件等"),
ZDJSXG("zdjsxg", "是否涉及汽车自动驾驶功能相关升级"),
JRXXG("jrxxg", "兼容性评估相关"),
ZXSJ("zxsj", "如何执行升级"),
AQJZ("aqjz", "升级失败或中断后,车辆采取的安全机制"),
SFYXAQ("sfyxaq", "升级活动是否影响车辆安全"),
YHQR("yhqr", "升级活动是否提供用户确认选项"),
SJBCS("sjbcs", "升级包测试"),
AQKKX("aqkkx", "是杏已验证确认在线升级活动的安全性和可靠性"),
BGFJ("bgfj", "提供变更或扩展后的《公告》批次及证明材料"),
CLFJ("clfj", "提供证明材料"),
XTMC("xtmc", "系统名称"),
SJQBGCS("sjqbgcs", "升级前已变更《公告》参数的对应调整"),
SJHBGCS("sjhbgcs", "升级后已变更《公告》参数的对应调整"),
SJKZQMC("sjkzqmc", "升级的电子控制器名称"),
YJBB("yjbb", "适配的硬件版本"),
SJQRJBB("sjqrjbb", "软件版本号升级前"),
SJHRJBB("sjhrjbb", "软件版本号升级后"),
SJQCZXT("sjqczxt", "操作系统版本号升级前"),
SJHCZXT("sjhczxt", "操作系统版本号升级后"),
CSRJSJ("csrjsj", "初始软件包的完整性数据"),
SJBYZSJ("sjbyzsj", "升级包完整性验证数据"),
SJBDX("sjbdx", "升级包大小"),
SFCFSJ("sfcfsj", "是否差分升级"),
SJMDLX("sjmdlx", "升级目的类型"),
GNBGMS("gnbgms", "功能变更描述"),
SYTJBG("sytjbg", "适用条件变更"),
SJSJKZQ("sjsjkzq", "升级涉及的电子控制器"),
GXBH("gxbh", "由于软件升级活动而导致的车辆功能的任何变化"),
SJSJ("sjsj", "升级执行预计时间(分钟)"),
SJKY("sjky", "升级执行期问,车辆是否可用"),
SJBKYGN("sjbkygn", "升级执行期间不可用的车辆功能"),
ZDXX("zdxx", "帮助车辆用户安全执行升级的任何指导信息"),
SJSFCG("sjsfcg", "告知用户升级成功或失败"),
GZBG("gzbg", "告知实施的变更"),
GZSCNR("gzscnr", "告知了对用户手册的全部更新内容"),
GZYHFS("gzyhfs", "告知用户方式(可多选)"),
XGWJ("xgwj", "用户告知相关文件"),
RWMC("rwmc", "任务名称"),
SJFBSJ("sjfbsj", "升级发布时间"),
SJJZSJ("sjjzsj", "升级计划截止时间");
String name;
String value;
OtaTitleEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static String getVal(String name){
String res = "";
for (OtaTitleEnum e:values()) {
if(e.getName().equals(name)){
res = e.getValue();
break;
}
}
return res;
}
}
@@ -2,6 +2,9 @@ package com.jero.modules.ota.service;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.ota.enums.OtaModuleEnum;
import org.apache.poi.ss.formula.functions.T;
import java.util.List;
/**
@@ -12,6 +15,8 @@ import java.util.List;
*/
public interface IOtaBaCxTxjlService extends IService<OtaBaCxTxjl> {
public void addHistory(OtaModuleEnum otaModuleEnum, String title, String oldStr, String newStr);
/**
* 保存
*
@@ -5,10 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.ota.entity.AttachmentEO;
import com.jero.modules.ota.entity.OtaBaCxAqcs;
import com.jero.modules.ota.entity.OtaBaCxJbxx;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaCxAqcsMapper;
import com.jero.modules.ota.service.IOtaBaCxAqcsService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -25,6 +30,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBaCxAqcs> implements IOtaBaCxAqcsService {
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
/**
* 保存
*
@@ -50,6 +58,9 @@ public class OtaBaCxAqcsServiceImpl extends ServiceImpl<OtaBaCxAqcsMapper, OtaBa
otaBaCxAqcs.setZmcl(obj.toString());
}
saveOrUpdate(otaBaCxAqcs);
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxAqcsOld.getOtaId(), OtaModuleEnum.CX_AQCS, otaBaCxAqcsOld, otaBaCxAqcs);
otaBaCxTxjlService.saveBatch(reList);
}
}
@@ -4,9 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.ota.entity.OtaBaCxJbxx;
import com.jero.modules.ota.entity.OtaBaCxList;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaCxJbxxMapper;
import com.jero.modules.ota.service.IOtaBaCxJbxxService;
import com.jero.modules.ota.service.IOtaBaCxListService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,110 +23,120 @@ import java.util.UUID;
/**
* @Description: 车型备案-车型基本信息
* @Author: jero-boot
* @Date: 2023-03-17
* @Date: 2023-03-17
* @Version: V1.0
*/
@Service
public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBaCxJbxx> implements IOtaBaCxJbxxService {
@Autowired
private IOtaBaCxListService otaBaCxListService;
/**
* 保存
*
* @param otaBaCxJbxx
* @return
*/
@Autowired
private IOtaBaCxListService otaBaCxListService;
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
/**
* 保存
*
* @param otaBaCxJbxx
* @return
*/
public OtaBaCxJbxx add(OtaBaCxJbxx otaBaCxJbxx) {
Date now = new Date();
OtaBaCxList otaBaCxList;
if(StringUtils.isEmpty(otaBaCxJbxx.getOtaId())){
//在保存的时候设置一个id 并返回前端 下次保存的时候判断是否为更新
otaBaCxList = new OtaBaCxList();
otaBaCxList.setId(UUID.randomUUID().toString().replace("-", ""));
otaBaCxList.updateData(otaBaCxJbxx);
otaBaCxListService.add(otaBaCxList);
otaBaCxJbxx.setOtaId(otaBaCxList.getId());
otaBaCxJbxx.setCreateTime(now);
}else{
otaBaCxList = otaBaCxListService.queryById(otaBaCxJbxx.getOtaId());
otaBaCxList.updateData(otaBaCxJbxx);
otaBaCxListService.editById(otaBaCxList);
}
//对比填写记录用的
OtaBaCxJbxx OtaBaCxJbxxOld = new OtaBaCxJbxx();
Date now = new Date();
OtaBaCxList otaBaCxList;
if (StringUtils.isEmpty(otaBaCxJbxx.getOtaId())) {
//在保存的时候设置一个id 并返回前端 下次保存的时候判断是否为更新
otaBaCxList = new OtaBaCxList();
otaBaCxList.setId(UUID.randomUUID().toString().replace("-", ""));
otaBaCxList.updateData(otaBaCxJbxx);
otaBaCxListService.add(otaBaCxList);
otaBaCxJbxx.setOtaId(otaBaCxList.getId());
otaBaCxJbxx.setCreateTime(now);
} else {
OtaBaCxJbxxOld = this.getByOtaId(otaBaCxJbxx.getOtaId());
otaBaCxList = otaBaCxListService.queryById(otaBaCxJbxx.getOtaId());
otaBaCxList.updateData(otaBaCxJbxx);
otaBaCxListService.editById(otaBaCxList);
}
otaBaCxJbxx.setUpdateTime(now);
saveOrUpdate(otaBaCxJbxx);
return otaBaCxJbxx;
saveOrUpdate(otaBaCxJbxx);
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxJbxx.getOtaId(), OtaModuleEnum.CX_CXJBXX, OtaBaCxJbxxOld, otaBaCxJbxx);
otaBaCxTxjlService.saveBatch(reList);
return otaBaCxJbxx;
}
/**
* 更新
*
* @param otaBaCxJbxx
* @return
*/
@Override
/**
* 更新
*
* @param otaBaCxJbxx
* @return
*/
@Override
public void editById(OtaBaCxJbxx otaBaCxJbxx) {
Date now = new Date();
Date now = new Date();
otaBaCxJbxx.setUpdateTime(now);
saveOrUpdate(otaBaCxJbxx);
saveOrUpdate(otaBaCxJbxx);
}
/**
* 通过id删除
*
* @param id
* @return
*/
@Override
/**
* 通过id删除
*
* @param id
* @return
*/
@Override
public void deleteById(String id) {
removeById(id);
}
/**
* 批量删除
*
* @param ids
* @return
*/
@Override
/**
* 批量删除
*
* @param ids
* @return
*/
@Override
public void deleteByIds(List<String> ids) {
removeByIds(ids);
}
/**
* 通过id查询
*
* @param id
* @return
*/
@Override
/**
* 通过id查询
*
* @param id
* @return
*/
@Override
public OtaBaCxJbxx queryById(String id) {
return getById(id);
}
/**
* 列表查询
*
* @return
*/
@Override
* 列表查询
*
* @return
*/
@Override
public List<OtaBaCxJbxx> queryList() {
return list();
}
@Override
public OtaBaCxJbxx queryByOtaId(String otaId, String otaIdT){
//判断是否保存过,否则查询模版数据回显
OtaBaCxJbxx res = getByOtaId(otaId);
if(ObjectUtils.isEmpty(res)){
res = getByOtaId(otaIdT);
}
return res;
}
@Override
public OtaBaCxJbxx queryByOtaId(String otaId, String otaIdT) {
//判断是否保存过,否则查询模版数据回显
OtaBaCxJbxx res = getByOtaId(otaId);
if (ObjectUtils.isEmpty(res)) {
res = getByOtaId(otaIdT);
}
return res;
}
private OtaBaCxJbxx getByOtaId(String otaId) {
LambdaQueryWrapper<OtaBaCxJbxx> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OtaBaCxJbxx::getOtaId, otaId);
return this.getOne(queryWrapper,false);
}
private OtaBaCxJbxx getByOtaId(String otaId) {
LambdaQueryWrapper<OtaBaCxJbxx> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OtaBaCxJbxx::getOtaId, otaId);
return this.getOne(queryWrapper, false);
}
}
@@ -1,17 +1,19 @@
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.ota.entity.OtaBaCxJsfzbacs;
import com.jero.modules.ota.entity.OtaBaCxKsjxtmccs;
import com.jero.modules.ota.entity.OtaBaCxLsjl;
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;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -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
@@ -30,6 +30,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMapper, OtaBaCxJsfzbacs> implements IOtaBaCxJsfzbacsService {
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
@Autowired
private IOtaBaCxSjmkService OtaBaCxSjmkService;
@@ -41,17 +43,24 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
public void add(JSONObject json) {
OtaBaCxJsfzbacs otaBaCxJsfzbacs = new OtaBaCxJsfzbacs();
String otaId = json.getString("otaId");
OtaBaCxJsfzbacs otaBaCxJsfzbacsOld = this.getByOtaId(otaId);
otaBaCxJsfzbacs.setOtaId(otaId);
parseBjData(json, otaBaCxJsfzbacs);
Date now = new Date();
otaBaCxJsfzbacs.setCreateTime(now);
otaBaCxJsfzbacs.setUpdateTime(now);
saveOrUpdate(otaBaCxJsfzbacs);
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaId, OtaModuleEnum.CX_JSFZXTJCBACS, otaBaCxJsfzbacsOld, otaBaCxJsfzbacs);
//处理控制器列表,先删除,后添加
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);
}
@@ -86,33 +95,38 @@ public class OtaBaCxJsfzbacsServiceImpl extends ServiceImpl<OtaBaCxJsfzbacsMappe
*/
private void parseBjData(JSONObject json, OtaBaCxJsfzbacs otaBaCxJsfzbacs) {
JSONObject bj = json.getJSONObject("bj");
Map<String, Object> bjMap = bj.getInnerMap();
Field[] fields = OtaBaCxJsfzbacs.class.getDeclaredFields();
for (Field field : fields) {
Object bjObj = bjMap.get(field.getName());
if (null != bjObj) {
try {
field.setAccessible(true);
field.set(otaBaCxJsfzbacs, bjObj);
} catch (IllegalAccessException e) {
e.printStackTrace();
if (ObjectUtils.isNotEmpty(bj)) {
Map<String, Object> bjMap = bj.getInnerMap();
Field[] fields = OtaBaCxJsfzbacs.class.getDeclaredFields();
for (Field field : fields) {
Object bjObj = bjMap.get(field.getName());
if (null != bjObj) {
try {
field.setAccessible(true);
field.set(otaBaCxJsfzbacs, bjObj);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
JSONArray cs = json.getJSONArray("cs");
for (Object cdJson : cs) {
HashMap<String, Object> csMap = (HashMap<String, Object>) cdJson;
String csName = (String) csMap.get("key");
String csValue = (String) csMap.get("val");
if (null != csName) {
try {
Field field = OtaBaCxJsfzbacs.class.getDeclaredField(csName);
field.setAccessible(true);
field.set(otaBaCxJsfzbacs, csValue);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
if (ObjectUtils.isNotEmpty(cs)) {
for (Object cdJson : cs) {
HashMap<String, Object> csMap = (HashMap<String, Object>) cdJson;
String csName = (String) csMap.get("key");
String csValue = (String) csMap.get("val");
if (null != csName) {
try {
Field field = OtaBaCxJsfzbacs.class.getDeclaredField(csName);
field.setAccessible(true);
field.set(otaBaCxJsfzbacs, csValue);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
}
}
@@ -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) {
@@ -48,11 +58,14 @@ public class OtaBaCxKsjjsmccsServiceImpl extends ServiceImpl<OtaBaCxKsjjsmccsMap
OtaBaCxKsjjsmccs otaBaCxJsfzbacs = new OtaBaCxKsjjsmccs();
Field[] fields = OtaBaCxKsjjsmccs.class.getDeclaredFields();
for (Field field : fields) {
if (field.getName().equals("createTime") || field.getName().equals("updateTime")) {
continue;
}
Object bjObj = objMap.get(field.getName());
if (null != bjObj) {
try {
field.setAccessible(true);
field.set(otaBaCxJsfzbacs, bjObj);
field.set(otaBaCxJsfzbacs, bjObj.toString());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
@@ -62,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);
@@ -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) {
@@ -50,11 +57,14 @@ public class OtaBaCxKsjxtmccsServiceImpl extends ServiceImpl<OtaBaCxKsjxtmccsMap
OtaBaCxKsjxtmccs otaBaCxKsjxtmccs = new OtaBaCxKsjxtmccs();
Field[] fields = OtaBaCxKsjxtmccs.class.getDeclaredFields();
for (Field field : fields) {
if (field.getName().equals("createTime") || field.getName().equals("updateTime")) {
continue;
}
Object bjObj = objMap.get(field.getName());
if (null != bjObj) {
try {
field.setAccessible(true);
field.set(otaBaCxKsjxtmccs, bjObj);
field.set(otaBaCxKsjxtmccs, bjObj.toString());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
@@ -64,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);
@@ -3,9 +3,14 @@ package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.ota.entity.OtaBaCxAqcs;
import com.jero.modules.ota.entity.OtaBaCxQt;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaCxQtMapper;
import com.jero.modules.ota.service.IOtaBaCxQtService;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.utils.ComparisonUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -22,6 +27,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class OtaBaCxQtServiceImpl extends ServiceImpl<OtaBaCxQtMapper, OtaBaCxQt> implements IOtaBaCxQtService {
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
/**
* 保存
*
@@ -40,6 +48,9 @@ public class OtaBaCxQtServiceImpl extends ServiceImpl<OtaBaCxQtMapper, OtaBaCxQt
}
otaBaCxQt.setUpdateTime(now);
saveOrUpdate(otaBaCxQt);
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxQt.getOtaId(), OtaModuleEnum.CX_QT, otaBaCxQtOld, otaBaCxQt);
otaBaCxTxjlService.saveBatch(reList);
}
}
@@ -3,6 +3,7 @@ package com.jero.modules.ota.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaCxTxjlMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import org.springframework.stereotype.Service;
@@ -19,6 +20,38 @@ import java.util.List;
@Service
public class OtaBaCxTxjlServiceImpl extends ServiceImpl<OtaBaCxTxjlMapper, OtaBaCxTxjl> implements IOtaBaCxTxjlService {
/**
* 添加填写历史
*
* @param otaModuleEnum
* @param title
* @param oldStr
* @param newStr
*/
public void addHistory(OtaModuleEnum otaModuleEnum, String title, String oldStr, String newStr) {
OtaBaCxTxjl otaBaCxTxjl = new OtaBaCxTxjl();
otaBaCxTxjl.setModule(otaModuleEnum.getName());
otaBaCxTxjl.setContent("" + title + "" + oldStr + "改为" + newStr);
add(otaBaCxTxjl);
}
/**
* 添加填写历史(表格)
*
* @param otaModuleEnum
* @param title
* @param number
* @param oldStr
* @param newStr
*/
public void addTableHistory(OtaModuleEnum otaModuleEnum, String title, String number, String oldStr, String newStr) {
OtaBaCxTxjl otaBaCxTxjl = new OtaBaCxTxjl();
otaBaCxTxjl.setModule(otaModuleEnum.getName());
otaBaCxTxjl.setContent("" + title + "" + number + "" + oldStr + "改为" + newStr);
add(otaBaCxTxjl);
}
/**
* 保存
*
@@ -5,11 +5,16 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.modules.ota.entity.AttachmentEO;
import com.jero.modules.ota.entity.OtaBaCxJbxx;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.entity.OtaBaCxZxsjyq;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaCxZxsjyqMapper;
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
import com.jero.modules.ota.service.IOtaBaCxZxsjyqService;
import com.jero.modules.ota.utils.ComparisonUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -26,6 +31,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service
public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, OtaBaCxZxsjyq> implements IOtaBaCxZxsjyqService {
@Autowired
private IOtaBaCxTxjlService otaBaCxTxjlService;
/**
* 保存
*
@@ -34,9 +42,10 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
*/
@Override
public void add(OtaBaCxZxsjyq otaBaCxZxsjyq) {
OtaBaCxZxsjyq otaBaCxZxsjyqOld = new OtaBaCxZxsjyq();;
Date now = new Date();
if (otaBaCxZxsjyq.getOtaId() != null) {
OtaBaCxZxsjyq otaBaCxZxsjyqOld = getByOtaId(otaBaCxZxsjyq.getOtaId());
otaBaCxZxsjyqOld = getByOtaId(otaBaCxZxsjyq.getOtaId());
if (otaBaCxZxsjyqOld != null) {
otaBaCxZxsjyq.setId(otaBaCxZxsjyqOld.getId());
} else {
@@ -52,6 +61,9 @@ public class OtaBaCxZxsjyqServiceImpl extends ServiceImpl<OtaBaCxZxsjyqMapper, O
otaBaCxZxsjyq.setZmcl(obj.toString());
}
saveOrUpdate(otaBaCxZxsjyq);
ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonRecord(otaBaCxZxsjyq.getOtaId(), OtaModuleEnum.CX_ZXSJYQ, otaBaCxZxsjyqOld, otaBaCxZxsjyq);
otaBaCxTxjlService.saveBatch(reList);
}
/**
@@ -1,29 +1,32 @@
package com.jero.modules.ota.service.impl;
import com.jero.modules.ota.entity.OtaBaSjLsjl;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.mapper.OtaBaSjLsjlMapper;
import com.jero.modules.ota.service.IOtaBaSjLsjlService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Date;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 升级备案-历史记录
* @Author: jero-boot
* @Date: 2023-03-17
* @Date: 2023-03-17
* @Version: V1.0
*/
@Service
public class OtaBaSjLsjlServiceImpl extends ServiceImpl<OtaBaSjLsjlMapper, OtaBaSjLsjl> implements IOtaBaSjLsjlService {
/**
* 保存
*
* @param otaBaSjLsjl
* @return
*/
@Override
/**
* 保存
*
* @param otaBaSjLsjl
* @return
*/
@Override
public void add(OtaBaSjLsjl otaBaSjLsjl) {
Date now = new Date();
otaBaSjLsjl.setCreateTime(now);
@@ -31,58 +34,58 @@ public class OtaBaSjLsjlServiceImpl extends ServiceImpl<OtaBaSjLsjlMapper, OtaBa
save(otaBaSjLsjl);
}
/**
* 更新
*
* @param otaBaSjLsjl
* @return
*/
@Override
/**
* 更新
*
* @param otaBaSjLsjl
* @return
*/
@Override
public void editById(OtaBaSjLsjl otaBaSjLsjl) {
Date now = new Date();
Date now = new Date();
otaBaSjLsjl.setUpdateTime(now);
saveOrUpdate(otaBaSjLsjl);
saveOrUpdate(otaBaSjLsjl);
}
/**
* 通过id删除
*
* @param id
* @return
*/
@Override
/**
* 通过id删除
*
* @param id
* @return
*/
@Override
public void deleteById(String id) {
removeById(id);
}
/**
* 批量删除
*
* @param ids
* @return
*/
@Override
/**
* 批量删除
*
* @param ids
* @return
*/
@Override
public void deleteByIds(List<String> ids) {
removeByIds(ids);
}
/**
* 通过id查询
*
* @param id
* @return
*/
@Override
/**
* 通过id查询
*
* @param id
* @return
*/
@Override
public OtaBaSjLsjl queryById(String id) {
return getById(id);
}
/**
* 列表查询
*
* @return
*/
@Override
* 列表查询
*
* @return
*/
@Override
public List<OtaBaSjLsjl> queryList() {
return list();
}
@@ -0,0 +1,146 @@
package com.jero.modules.ota.utils;
import com.jero.modules.ota.entity.OtaBaCxTxjl;
import com.jero.modules.ota.enums.OtaModuleEnum;
import com.jero.modules.ota.enums.OtaTitleEnum;
import org.apache.commons.lang3.ObjectUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* 对比新老数据,添加填写记录
*
* @param <T>
*/
public class ComparisonUtil<T> {
public ComparisonUtil() {
}
/**
* 对比字段并添加到记录
*/
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 {
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 = "" + title + "" + oldStr + "改为" + newStr;
resList.add(new OtaBaCxTxjl(otaId, otaModuleEnum.getName(), content));
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
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;
}
}