市场法规清单导出重复数据合并

This commit is contained in:
梁琦涛
2024-09-02 10:29:31 +08:00
parent d17cbd0ac7
commit 35957ea993
3 changed files with 93 additions and 21 deletions
@@ -1360,7 +1360,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
}
private ModelAndView exportExcelByClause(Map<String, Object> parameterMap) {
List<LawsHomeAdvancedSearchClauseVO> advancedSearchClause = getAdvancedSearchClause(parameterMap);
List<LawsHomeAdvancedSearchClauseVO> advancedSearchClause = getAdvancedSearchClauseExport(parameterMap);
List<Map<String, Object>> list = new ArrayList<>();
// 标准sheet页
@@ -1586,6 +1586,51 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
return lawsHomeAdvancedSearchClauseVOList;
}
public List<LawsHomeAdvancedSearchClauseVO> getAdvancedSearchClauseExport(Map<String, Object> parameterMap) {
List<LawsHomeAdvancedSearchClauseVO> lawsHomeAdvancedSearchClauseVOList = new ArrayList<>();
List<Map<String, Object>> data = documentSplitService.queryDocumentSplitDetailByHomeListExport(parameterMap);
// 过滤已发布数据
List<String> infoIdList = data.stream().map(v -> String.valueOf(v.get("info_id")))
.distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(infoIdList)){
return lawsHomeAdvancedSearchClauseVOList;
}
List<SarFileSplitInfoEO> list = sarFileSplitInfoService.list(new LambdaQueryWrapper<SarFileSplitInfoEO>()
.in(SarFileSplitInfoEO::getId, infoIdList).isNull(SarFileSplitInfoEO::getPublishBeforeId));
List<String> idList = list.stream().map(v -> v.getId()).collect(Collectors.toList());
// 根据info_id分组
if (!data.isEmpty()){
Map<String, List<Map<String, Object>>> groupMap =
data.stream().collect(Collectors.groupingBy(v -> String.valueOf(v.get("info_id"))));
groupMap.forEach((k, v) -> {
if (!idList.contains(k)){
return;
}
// 封装数据
SarFileSplitInfoEO sarFileSplitInfoEO = sarFileSplitInfoService.queryById(k);
if (!Objects.isNull(sarFileSplitInfoEO)){
LawsDomesticStandard lawsDomesticStandard =
lawsDomesticStandardService.getOne(new LambdaQueryWrapper<LawsDomesticStandard>()
.select(LawsDomesticStandard::getStandardNumber,
LawsDomesticStandard::getStandardName)
.eq(LawsDomesticStandard::getId, sarFileSplitInfoEO.getStandardId()));
if (!Objects.isNull(lawsDomesticStandard)){
LawsHomeAdvancedSearchClauseVO lawsHomeAdvancedSearchClauseVO =
new LawsHomeAdvancedSearchClauseVO();
lawsHomeAdvancedSearchClauseVO.setStandardId(sarFileSplitInfoEO.getStandardId());
lawsHomeAdvancedSearchClauseVO.setStandardNumber(lawsDomesticStandard.getStandardNumber());
lawsHomeAdvancedSearchClauseVO.setStandardName(lawsDomesticStandard.getStandardName());
lawsHomeAdvancedSearchClauseVO.setStandardNumberAndName(
lawsDomesticStandard.getStandardNumber() + " " + lawsDomesticStandard.getStandardName());
lawsHomeAdvancedSearchClauseVO.setClauseList(v);
lawsHomeAdvancedSearchClauseVOList.add(lawsHomeAdvancedSearchClauseVO);
}
}
});
}
return lawsHomeAdvancedSearchClauseVOList;
}
private boolean updateLawsDomesticStandardToEs(String resourceType, String ids,String opType) {
// 批量操作
// 从第0个下标开始
@@ -101,28 +101,28 @@ public class LawsMarketStandardDetail implements Serializable {
/**
* 新生产车实施日期
*/
@Excel(name = "新生产车实施日期", width = 15)
@Excel(name = "新生产车实施日期", width = 15, mergeVertical = true, mergeRely = 1)
@ApiModelProperty(value = "新生产车实施日期")
private String newProductImplDate;
/**
* 新认证车实施日期
*/
@Excel(name = "新认证车实施日期", width = 15)
@Excel(name = "新认证车实施日期", width = 15, mergeVertical = true, mergeRely = 1)
@ApiModelProperty(value = "新认证车实施日期")
private String newAuthImplDate;
/**
* 注册日期
*/
@Excel(name = "注册日期", width = 15)
@Excel(name = "注册日期", width = 15, mergeVertical = true, mergeRely = 1)
@ApiModelProperty(value = "注册日期")
private String registrationDate;
/**
* 国家
*/
@Excel(name = "适用国家/地区", width = 15,dicCode = "market_state")
@Excel(name = "适用国家/地区", width = 15,dicCode = "market_state", mergeVertical = true, mergeRely = 1)
@NotBlank(message = "适用国家/地区不能为空")
@ApiModelProperty(value = "国家")
@Dict(dicCode = "market_state")
@@ -131,7 +131,7 @@ public class LawsMarketStandardDetail implements Serializable {
/**
* 适用车型
*/
@Excel(name = "适用车型", width = 15, dicCode = "applicable_vehicle_type")
@Excel(name = "适用车型", width = 15, dicCode = "applicable_vehicle_type", mergeVertical = true, mergeRely = 1)
@Dict(dicCode = "applicable_vehicle_type")
@ApiModelProperty(value = "适用车型")
private String applicableVehicle;
@@ -141,21 +141,21 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@ApiModelProperty(value = "认证对象")
@Dict(dicCode = "authentication_object")
@Excel(name = "认证对象", width = 15, dicCode = "authentication_object")
@Excel(name = "认证对象", width = 15, dicCode = "authentication_object", mergeVertical = true, mergeRely = 1)
private String authenticationObject;
/**
* 认证交付物
*/
@ApiModelProperty(value = "认证交付物")
@Excel(name = "认证交付物", width = 15)
@Excel(name = "认证交付物", width = 15, mergeVertical = true, mergeRely = 1)
private String certifyTheDeliverables;
/**
* 类型
*/
@Dict(dicCode = "type")
@Excel(name = "类型", width = 15, dicCode = "type")
@Excel(name = "类型", width = 15, dicCode = "type", mergeVertical = true, mergeRely = 1)
@ApiModelProperty(value = "类型")
private String type;
@@ -164,7 +164,7 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dicCode = "dynamic_type")
@ApiModelProperty(value = "动力类型")
@Excel(name = "动力类型", width = 15, dicCode = "dynamic_type")
@Excel(name = "动力类型", width = 15, dicCode = "dynamic_type", mergeVertical = true, mergeRely = 1)
private String dynamicType;
/**
@@ -173,7 +173,7 @@ public class LawsMarketStandardDetail implements Serializable {
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
@ApiModelProperty(value = "主控部门")
@NotBlank(message = "主控部门不能为空")
@Excel(name = "主控部门", width = 15,dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
@Excel(name = "主控部门", width = 15,dictTable = "sys_depart", dicCode = "id", dicText = "depart_name", mergeVertical = true, mergeRely = 1)
private String mainDept;
/**
@@ -182,7 +182,7 @@ public class LawsMarketStandardDetail implements Serializable {
@ApiModelProperty(value = "主控部门专业模块")
@NotBlank(message = "主控部门专业模块不能为空")
@Dict(dicCode = "professional_module")
@Excel(name = "主控部门专业模块", width = 15, dicCode = "professional_module")
@Excel(name = "主控部门专业模块", width = 15, dicCode = "professional_module", mergeVertical = true, mergeRely = 1)
private String mainDeptProfMode;
/**
@@ -190,14 +190,14 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
@ApiModelProperty(value = "关联部门")
@Excel(name = "关联部门", width = 15,dictTable = "sys_depart", dicCode = "id", dicText = "depart_name")
@Excel(name = "关联部门", width = 15,dictTable = "sys_depart", dicCode = "id", dicText = "depart_name", mergeVertical = true, mergeRely = 1)
private String associateDept;
/**
* 关联部门专业模块
*/
@ApiModelProperty(value = "关联部门专业模块")
@Excel(name = "关联部门专业模块", width = 15, dicCode = "professional_module")
@Excel(name = "关联部门专业模块", width = 15, dicCode = "professional_module", mergeVertical = true, mergeRely = 1)
@Dict(dicCode = "professional_module")
private String associateDeptProfMode;
@@ -205,7 +205,7 @@ public class LawsMarketStandardDetail implements Serializable {
* 批量限制
*/
@ApiModelProperty(value = "批量限制")
@Excel(name = "批量限制", width = 15, dicCode = "batch_restriction")
@Excel(name = "批量限制", width = 15, dicCode = "batch_restriction", mergeVertical = true, mergeRely = 1)
@Dict(dicCode = "batch_restriction")
private String batchLimit;
@@ -214,7 +214,7 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dicCode = "automatic_driving_level")
@ApiModelProperty(value = "自动驾驶等级")
@Excel(name = "自动驾驶等级", width = 15,dicCode = "automatic_driving_level")
@Excel(name = "自动驾驶等级", width = 15,dicCode = "automatic_driving_level", mergeVertical = true, mergeRely = 1)
private String autopilotLevel;
/**
@@ -222,13 +222,13 @@ public class LawsMarketStandardDetail implements Serializable {
*/
@Dict(dicCode = "requirement_type")
@ApiModelProperty(value = "要求类型")
@Excel(name = "要求类型", width = 15,dicCode = "requirement_type")
@Excel(name = "要求类型", width = 15,dicCode = "requirement_type", mergeVertical = true, mergeRely = 1)
private String requireType;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
@Excel(name = "备注", width = 15)
@Excel(name = "备注", width = 15, mergeVertical = true, mergeRely = 1)
private String remark;
@@ -39,6 +39,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -310,11 +311,11 @@ public class LawsMarketStandardServiceImpl extends ServiceImpl<LawsMarketStandar
LambdaQueryWrapper<LawsMarketStandardDetail> wrapper = new LambdaQueryWrapper<>();
wrapper.in(LawsMarketStandardDetail::getManifestId, listIds);
wrapper.orderByDesc(LawsMarketStandardDetail::getStandardNumber);
wrapper.orderByDesc(LawsMarketStandardDetail::getCreateTime);
listLawsMarketStandardDetail = lawsMarketStandardDetailService.list(wrapper);
}
listLawsMarketStandardDetail = listLawsMarketStandardDetail.stream()
.sorted(Comparator.comparing(LawsMarketStandardDetail::getStandardNumber).reversed()).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(listLawsMarketStandardDetail)){
replaceNullFieldsWithOne(listLawsMarketStandardDetail);
}
// AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
@@ -329,6 +330,32 @@ public class LawsMarketStandardServiceImpl extends ServiceImpl<LawsMarketStandar
return mv;
}
public void replaceNullFieldsWithOne(List<LawsMarketStandardDetail> list) {
for (LawsMarketStandardDetail obj : list) {
Class<?> clazz = obj.getClass();
Field[] fields = clazz.getDeclaredFields();
// 遍历所有字段
for (Field field : fields) {
// 设置访问权限
field.setAccessible(true);
try {
Object fieldValue = field.get(obj);
// 检查字段值是否为 null 或空字符串
if (fieldValue == null || (fieldValue instanceof String && ((String) fieldValue).trim().isEmpty())) {
// 根据字段类型赋值
if (field.getType().equals(Integer.class) || field.getType().equals(int.class)) {
field.set(obj, 1);
} else if (field.getType().equals(String.class)) {
field.set(obj, "");
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
@Override
public Result<?> deleteById(String id) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();