开发OTA备案工具
This commit is contained in:
+14
-2
@@ -2,6 +2,7 @@ package com.jero.modules.ota.enums;
|
||||
|
||||
public enum OtaTitleEnum {
|
||||
|
||||
|
||||
CPDJBH("cpdjbh", "产品登记编号"),
|
||||
GGPC("ggpc", "公告批次"),
|
||||
CPSB("cpsb", "产品商标"),
|
||||
@@ -15,8 +16,8 @@ public enum OtaTitleEnum {
|
||||
QYMC("qymc", "企业名称"),
|
||||
DJBH("djbh", "产品登记编号"),
|
||||
CPLB("cplb", "产品类别"),
|
||||
DLLX1("dllx1", "车辆动力类型1"),
|
||||
DLLX2("dllx2", "车辆动力类型2"),
|
||||
DLLX1("dllx1", "车辆动力类型"),
|
||||
DLLX2("dllx2", "车辆动力类型"),
|
||||
TXZD("txzd", "通信终端"),
|
||||
CDOTASJ("cdotasj", "车端OTA升级管理系统"),
|
||||
BHSJB("bhsjb", "保护升级包"),
|
||||
@@ -216,4 +217,15 @@ public enum OtaTitleEnum {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -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);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
|
||||
+89
-75
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -3,9 +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.entity.OtaBaSjLsjl;
|
||||
import com.jero.modules.ota.enums.OtaModuleEnum;
|
||||
import com.jero.modules.ota.enums.OtaTitleEnum;
|
||||
import com.jero.modules.ota.mapper.OtaBaCxTxjlMapper;
|
||||
import com.jero.modules.ota.service.IOtaBaCxTxjlService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -22,6 +20,7 @@ import java.util.List;
|
||||
@Service
|
||||
public class OtaBaCxTxjlServiceImpl extends ServiceImpl<OtaBaCxTxjlMapper, OtaBaCxTxjl> implements IOtaBaCxTxjlService {
|
||||
|
||||
|
||||
/**
|
||||
* 添加填写历史
|
||||
*
|
||||
@@ -33,7 +32,7 @@ public class OtaBaCxTxjlServiceImpl extends ServiceImpl<OtaBaCxTxjlMapper, OtaBa
|
||||
public void addHistory(OtaModuleEnum otaModuleEnum, String title, String oldStr, String newStr) {
|
||||
OtaBaCxTxjl otaBaCxTxjl = new OtaBaCxTxjl();
|
||||
otaBaCxTxjl.setModule(otaModuleEnum.getName());
|
||||
otaBaCxTxjl.setContent("将" + title + "的" + oldStr + "改为" + newStr);
|
||||
otaBaCxTxjl.setContent("由" + title + "的" + oldStr + "改为" + newStr);
|
||||
add(otaBaCxTxjl);
|
||||
}
|
||||
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
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)) {
|
||||
OtaBaCxTxjl otaBaCxTxjl = new OtaBaCxTxjl();
|
||||
otaBaCxTxjl.setModule(otaModuleEnum.getName());
|
||||
otaBaCxTxjl.setContent("由" + title + "的" + oldStr + "改为" + newStr);
|
||||
otaBaCxTxjl.setOtaId(otaId);
|
||||
resList.add(otaBaCxTxjl);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user