fix: 81309 法规合规评估流程-添加标准,新车型实施日期和在产车实施日期回显数据重复了

This commit is contained in:
2024-02-01 16:05:55 +08:00
parent 3e906d0123
commit 6064b6ba01
3 changed files with 105 additions and 0 deletions
@@ -150,4 +150,16 @@ public class LawsAsmsDomesticController extends JeroController<LawsAsmsDomestic,
return Result.OK(lawsAsmsDomestic);
}
/**
* 清理数据接口
*
* @return
*/
@AutoLog(value = "ASMS国内法规-清理数据接口")
@ApiOperation(value="ASMS国内法规-清理数据接口", notes="ASMS国内法规-清理数据接口")
@GetMapping(value = "/cleanData")
public Result<LawsAsmsDomestic> cleanData() {
lawsAsmsDomesticService.cleanData();
return Result.OK("清理成功!");
}
}
@@ -73,4 +73,9 @@ public interface ILawsAsmsDomesticService extends IService<LawsAsmsDomestic> {
* @return
*/
LawsAsmsDomestic queryById(String id);
/**
* 清理同步进来的脏数据
*/
void cleanData();
}
@@ -1,16 +1,28 @@
package com.jero.modules.docking.asms.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.modules.docking.asms.entity.LawsAsmsDomestic;
import com.jero.modules.docking.asms.mapper.LawsAsmsDomesticMapper;
import com.jero.modules.docking.asms.service.ILawsAsmsDomesticService;
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
import org.hibernate.validator.constraints.pl.REGON;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jero.common.exception.JeroBootException;
import java.util.Arrays;
import java.util.List;
import java.util.Date;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.system.query.QueryGenerator;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -26,6 +38,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@Transactional(rollbackFor = JeroBootException.class)
public class LawsAsmsDomesticServiceImpl extends ServiceImpl<LawsAsmsDomesticMapper, LawsAsmsDomestic> implements ILawsAsmsDomesticService {
@Resource
private ILawsDomesticStandardService lawsDomesticStandardService;
@Resource
private ILawsOverseasStandardService lawsOverseasStandardService;
/**
* 分页查询
@@ -110,4 +127,75 @@ public class LawsAsmsDomesticServiceImpl extends ServiceImpl<LawsAsmsDomesticMap
public LawsAsmsDomestic queryById(String id) {
return getById(id);
}
/**
* 清理导入进来的脏数据
*/
@Override
public void cleanData() {
List<LawsDomesticStandard> gblist = lawsDomesticStandardService.list();
List<LawsOverseasStandard> fblist = lawsOverseasStandardService.list();
// 遍历所有国标数据,清理新车型实施日期 在产车实施日期两个字段中的脏数据
for (LawsDomesticStandard standard : gblist) {
String newModelImplementationDate = standard.getNewModelImplementationDate();
String onTheProductionDate = standard.getOnTheProductionDate();
if (StrUtil.isBlank(newModelImplementationDate) && StrUtil.isBlank(onTheProductionDate)) {
continue;
}
if (StrUtil.isNotBlank(newModelImplementationDate)) {
if (newModelImplementationDate.equals(",")) {
standard.setNewModelImplementationDate("");
} else {
List<String> dateList = Arrays.asList(newModelImplementationDate.split(","));
// 去重
standard.setNewModelImplementationDate(dateList.stream()
.distinct().collect(Collectors.joining(",")));
}
}
if (StrUtil.isNotBlank(onTheProductionDate)) {
if (onTheProductionDate.equals(",")) {
standard.setOnTheProductionDate("");
} else {
List<String> dateList = Arrays.asList(onTheProductionDate.split(","));
// 去重
standard.setOnTheProductionDate(dateList.stream()
.distinct().collect(Collectors.joining(",")));
}
}
lawsDomesticStandardService.updateById(standard);
}
for (LawsOverseasStandard standard : fblist) {
String newModelImplementationDate = standard.getNewModelImplementationDate();
String onTheProductionDate = standard.getOnTheProductionDate();
if (StrUtil.isBlank(newModelImplementationDate) && StrUtil.isBlank(onTheProductionDate)) {
continue;
}
if (StrUtil.isNotBlank(newModelImplementationDate)) {
if (newModelImplementationDate.equals(",")) {
standard.setNewModelImplementationDate("");
} else {
List<String> dateList = Arrays.asList(newModelImplementationDate.split(","));
// 去重
standard.setNewModelImplementationDate(dateList.stream()
.distinct().collect(Collectors.joining(",")));
}
}
if (StrUtil.isNotBlank(onTheProductionDate)) {
if (onTheProductionDate.equals(",")) {
standard.setOnTheProductionDate("");
} else {
List<String> dateList = Arrays.asList(onTheProductionDate.split(","));
// 去重
standard.setOnTheProductionDate(dateList.stream()
.distinct().collect(Collectors.joining(",")));
}
}
lawsOverseasStandardService.updateById(standard);
}
}
}