开发OTA备案工具-车辆升级

This commit is contained in:
高嵩
2023-03-30 19:38:54 +08:00
parent 1729430cd7
commit b3b0ce4096
2 changed files with 111 additions and 78 deletions
@@ -3,11 +3,13 @@ package com.jero.modules.ota.entity;
import java.io.Serializable; import java.io.Serializable;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel; import org.jeecgframework.poi.excel.annotation.Excel;
import com.jero.common.aspect.annotation.Dict; import com.jero.common.aspect.annotation.Dict;
@@ -21,89 +23,144 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/** /**
* @Description: 升级备案-本次升级的驾驶辅助功能与参数变化 * @Description: 升级备案-本次升级的驾驶辅助功能与参数变化
* @Author: jero-boot * @Author: jero-boot
* @Date: 2023-03-17 * @Date: 2023-03-17
* @Version: V1.0 * @Version: V1.0
*/ */
@Data @Data
@TableName("ota_ba_sj_sjfzbh") @TableName("ota_ba_sj_sjfzbh")
@Accessors(chain = true) @Accessors(chain = true)
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ApiModel(value="ota_ba_sj_sjfzbh对象", description="升级备案-本次升级的驾驶辅助功能与参数变化") @ApiModel(value = "ota_ba_sj_sjfzbh对象", description = "升级备案-本次升级的驾驶辅助功能与参数变化")
public class OtaBaSjSjfzbh implements Serializable { public class OtaBaSjSjfzbh implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**主键*/ /**
@TableId(type = IdType.ASSIGN_ID) * 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "主键")
private java.lang.String id; private java.lang.String id;
/**创建人*/ /**
* 创建人
*/
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private java.lang.String createBy; private java.lang.String createBy;
/**创建日期*/ /**
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") * 创建日期
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期") @ApiModelProperty(value = "创建日期")
private java.util.Date createTime; private java.util.Date createTime;
/**更新人*/ /**
* 更新人
*/
@ApiModelProperty(value = "更新人") @ApiModelProperty(value = "更新人")
private java.lang.String updateBy; private java.lang.String updateBy;
/**更新日期*/ /**
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") * 更新日期
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期") @ApiModelProperty(value = "更新日期")
private java.util.Date updateTime; private java.util.Date updateTime;
/**所属部门*/ /**
* 所属部门
*/
@ApiModelProperty(value = "所属部门") @ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode; private java.lang.String sysOrgCode;
/**otaId*/ /**
@Excel(name = "otaId", width = 15) * otaId
*/
@Excel(name = "otaId", width = 15)
@ApiModelProperty(value = "otaId") @ApiModelProperty(value = "otaId")
private java.lang.String otaId; private java.lang.String otaId;
/**功能名称*/ /**
@Excel(name = "功能名称", width = 15) * 功能名称
*/
@Excel(name = "功能名称", width = 15)
@ApiModelProperty(value = "功能名称") @ApiModelProperty(value = "功能名称")
private java.lang.String gnmc; private java.lang.String gnmc;
/**升级目的类型*/ /**
@Excel(name = "升级目的类型", width = 15) * 升级目的类型
*/
@Excel(name = "升级目的类型", width = 15)
@ApiModelProperty(value = "升级目的类型") @ApiModelProperty(value = "升级目的类型")
private java.lang.String sjmdlx; private java.lang.String sjmdlx;
/**升级前已变更《公告》参数的对应调整*/ /**
@Excel(name = "升级前已变更《公告》参数的对应调整", width = 15) * 升级前已变更《公告》参数的对应调整
*/
@Excel(name = "升级前已变更《公告》参数的对应调整", width = 15)
@ApiModelProperty(value = "升级前已变更《公告》参数的对应调整") @ApiModelProperty(value = "升级前已变更《公告》参数的对应调整")
private java.lang.String sjqbgcs; private java.lang.String sjqbgcs;
/**升级后已变更《公告》参数的对应调整*/ /**
@Excel(name = "升级后已变更《公告》参数的对应调整", width = 15) * 升级后已变更《公告》参数的对应调整
*/
@Excel(name = "升级后已变更《公告》参数的对应调整", width = 15)
@ApiModelProperty(value = "升级后已变更《公告》参数的对应调整") @ApiModelProperty(value = "升级后已变更《公告》参数的对应调整")
private java.lang.String sjhbgcs; private java.lang.String sjhbgcs;
/**功能变更描述*/ /**
@Excel(name = "功能变更描述", width = 15) * 功能变更描述
*/
@Excel(name = "功能变更描述", width = 15)
@ApiModelProperty(value = "功能变更描述") @ApiModelProperty(value = "功能变更描述")
private java.lang.String gnbgms; private java.lang.String gnbgms;
/**适用条件变更*/ /**
@Excel(name = "适用条件变更", width = 15) * 适用条件变更
*/
@Excel(name = "适用条件变更", width = 15)
@ApiModelProperty(value = "适用条件变更") @ApiModelProperty(value = "适用条件变更")
private java.lang.String sytjbg; private java.lang.String sytjbg;
/**升级涉及的电子控制器*/ /**
@Excel(name = "升级涉及的电子控制器", width = 15) * 升级涉及的电子控制器
*/
@Excel(name = "升级涉及的电子控制器", width = 15)
@ApiModelProperty(value = "升级涉及的电子控制器") @ApiModelProperty(value = "升级涉及的电子控制器")
private java.lang.String sjsjkzq; private java.lang.String sjsjkzq;
/**附件*/ /**
@Excel(name = "附件", width = 15) * 附件
*/
@Excel(name = "附件", width = 15)
@ApiModelProperty(value = "附件") @ApiModelProperty(value = "附件")
private java.lang.String fj; private java.lang.String fj;
public boolean isNull() {
if (StringUtils.isNotEmpty(gnmc)) {
return false;
}
if (StringUtils.isNotEmpty(sjmdlx)) {
return false;
}
if (StringUtils.isNotEmpty(sjqbgcs)) {
return false;
}
if (StringUtils.isNotEmpty(sjhbgcs)) {
return false;
}
if (StringUtils.isNotEmpty(gnbgms)) {
return false;
}
if (StringUtils.isNotEmpty(sytjbg)) {
return false;
}
if (StringUtils.isNotEmpty(sjsjkzq)) {
return false;
}
return true;
}
} }
@@ -107,12 +107,6 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
ComparisonUtil cu = new ComparisonUtil(); ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.SJ_SJJSMCBH, OtaTitleEnum.GNMC.getName(), oldList, newList, sysDictService); List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.SJ_SJJSMCBH, OtaTitleEnum.GNMC.getName(), oldList, newList, sysDictService);
saveOrUpdateBatch(newList); saveOrUpdateBatch(newList);
String fj = (String) json.get("fj");
OtaBaSjList otaBaSjList = otaBaSjListService.queryById(otaId);
String oldFjStr = otaBaSjList.getSjjsfj();
otaBaSjList.setSjjsfj(fj);
otaBaSjListService.editById(otaBaSjList);
reList.addAll(cu.comparisonRecord(otaId, fj, oldFjStr, OtaModuleEnum.SJ_SJJSMCBH, "附件", ossFileService));
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
} }
@@ -191,10 +185,6 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
} }
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("list", res); json.put("list", res);
OtaBaSjList otaBaSjList = otaBaSjListService.queryById(otaId);
if (ObjectUtils.isNotEmpty(otaBaSjList) && ObjectUtils.isNotEmpty(otaBaSjList.getSjjsfj())) {
json.put("fj", otaBaSjList.getSjjsfj());
}
return json; return json;
} }
@@ -220,16 +210,13 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
@Override @Override
public void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception { public void parseFileList(List<File> upLoadFiles, String otaId, String cut) throws Exception {
File attFile = null;
File upFile = null; File upFile = null;
for (File f : upLoadFiles) { for (File f : upLoadFiles) {
if (f.isDirectory() && f.getName().equals("本次升级的驾驶辅助功能与参数变化")) { if (f.getName().equals("本次升级的驾驶辅助功能与参数变化.xlsx")) {
attFile = f;
} else if (f.getName().equals("本次升级的驾驶辅助功能与参数变化.xlsx")) {
upFile = f; upFile = f;
} }
} }
if (null == upFile || null == attFile) { if (null == upFile) {
throw new JeroBootException("请上传正确的文件"); throw new JeroBootException("请上传正确的文件");
} }
@@ -237,7 +224,7 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
if (ObjectUtils.isEmpty(oldList)) { if (ObjectUtils.isEmpty(oldList)) {
oldList = new ArrayList<>(); oldList = new ArrayList<>();
} }
List<OtaBaSjSjfzbh> newList = parseFile(upFile, attFile, otaId, cut); List<OtaBaSjSjfzbh> newList = parseFile(upFile, otaId, cut);
ComparisonUtil cu = new ComparisonUtil(); ComparisonUtil cu = new ComparisonUtil();
List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.SJ_SJJSMCBH, OtaTitleEnum.GNMC.getName(), oldList, newList, sysDictService); List<OtaBaCxTxjl> reList = cu.comparisonListRecord(otaId, OtaModuleEnum.SJ_SJJSMCBH, OtaTitleEnum.GNMC.getName(), oldList, newList, sysDictService);
deleteByOtaId(otaId); deleteByOtaId(otaId);
@@ -245,7 +232,7 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
otaBaCxTxjlService.saveBatch(reList); otaBaCxTxjlService.saveBatch(reList);
} }
private List<OtaBaSjSjfzbh> parseFile(File upFile, File attFile, String otaId, String cut) throws Exception { private List<OtaBaSjSjfzbh> parseFile(File upFile, String otaId, String cut) throws Exception {
Date now = new Date(); Date now = new Date();
List<OtaBaSjSjfzbh> fzbhList = new ArrayList<>(); List<OtaBaSjSjfzbh> fzbhList = new ArrayList<>();
Workbook wb = ImportFileUtil.readExcel(upFile); Workbook wb = ImportFileUtil.readExcel(upFile);
@@ -256,38 +243,27 @@ public class OtaBaSjSjfzbhServiceImpl extends ServiceImpl<OtaBaSjSjfzbhMapper, O
Cell cell = row.getCell(0); Cell cell = row.getCell(0);
String str = ImportFileUtil.getCellValue(cell, wb); String str = ImportFileUtil.getCellValue(cell, wb);
OtaBaSjSjfzbh fzbh = new OtaBaSjSjfzbh(); OtaBaSjSjfzbh fzbh = new OtaBaSjSjfzbh();
if ("证明材料".equals(str)) { cell = row.getCell(0);
//列表数据数量,在证明材料处结束 fzbh.setGnmc(ImportFileUtil.getCellValue(cell, wb));
OtaBaSjList otaBaSjList = otaBaSjListService.queryById(otaId); cell = row.getCell(1);
if (ObjectUtils.isNotEmpty(otaBaSjList)) { fzbh.setSjmdlx(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(1); cell = row.getCell(2);
str = ImportFileUtil.getCellValue(cell, wb); fzbh.setSjqbgcs(ImportFileUtil.getCellValue(cell, wb));
String[] strs = str.split(","); cell = row.getCell(3);
otaBaSjList.setSjjsfj(ImportFileUtil.uploadFiles(attFile, strs, ossFileService)); fzbh.setSjhbgcs(ImportFileUtil.getCellValue(cell, wb));
otaBaSjListService.editById(otaBaSjList); cell = row.getCell(4);
} fzbh.setGnbgms(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(5);
fzbh.setSytjbg(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(6);
fzbh.setSjsjkzq(ImportFileUtil.getCellValue(cell, wb));
if (fzbh.isNull()) {
break; break;
} else {
fzbh.setOtaId(otaId);
fzbh.setCreateTime(now);
fzbh.setUpdateTime(now);
cell = row.getCell(0);
fzbh.setGnmc(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(1);
fzbh.setSjmdlx(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(2);
fzbh.setSjqbgcs(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(3);
fzbh.setSjhbgcs(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(4);
fzbh.setGnbgms(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(5);
fzbh.setSytjbg(ImportFileUtil.getCellValue(cell, wb));
cell = row.getCell(6);
fzbh.setSjsjkzq(ImportFileUtil.getCellValue(cell, wb));
fzbhList.add(fzbh);
} }
fzbh.setOtaId(otaId);
fzbh.setCreateTime(now);
fzbh.setUpdateTime(now);
fzbhList.add(fzbh);
} }
return fzbhList; return fzbhList;
} }