bug 54232

This commit is contained in:
liyawei
2022-06-16 18:10:55 +08:00
parent 6489c8ab0c
commit f3ca6f763b
11 changed files with 115 additions and 58 deletions
@@ -213,8 +213,8 @@ public class ParamsInfoEOController extends JeroController<ParamsInfoEO, IParams
@ApiOperation(value="参数项基本信息表-通过id查询", notes="参数项基本信息表-通过id查询")
@GetMapping(value = "/queryById")
@RequiresPermissions("params:paramsInfo:edit")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
ParamsInfoEO paramsInfoEO = paramsInfoEOService.queryById(id);
public Result<?> queryById(@RequestParam(name="id",required=true) String id, @RequestParam(name="cut",required=true) String cut) {
ParamsInfoEO paramsInfoEO = paramsInfoEOService.queryById(id,cut);
if(paramsInfoEO==null) {
return Result.error("未找到对应数据");
}
@@ -75,7 +75,7 @@ public class CertCategoryParamsInfoEO implements Serializable {
private String description;
/**nio编号*/
@Excel(name = "*nio编号", width = 15, orderNum = "1")
@Excel(name = "*NIO编号", width = 15, orderNum = "1")
@ApiModelProperty(value = "nio编号")
private String nioNumber;
@@ -62,7 +62,7 @@ public class ParamsInfoEO implements Serializable {
private String sysOrgCode;
/**nio编号*/
@Excel(name = "*nio编号", width = 15)
@Excel(name = "*NIO编号", width = 15)
@ApiModelProperty(value = "nio编号")
private String nioNumber;
@@ -100,7 +100,7 @@ public class ParamsInfoEO implements Serializable {
private String description;
/**认证类别*/
@Excel(name = "*认证类别", width = 15, dicCode = "cert_category")
// @Excel(name = "*认证类别", width = 15, dicCode = "cert_category")
@Dict(dicCode = "cert_category")
@ApiModelProperty(value = "认证类别")
private String certCategory;
@@ -60,7 +60,7 @@ public interface IParamsInfoEOService extends IService<ParamsInfoEO> {
* @param id
* @return
*/
ParamsInfoEO queryById(String id);
ParamsInfoEO queryById(String id, String cut);
/**
* 列表查询
@@ -38,6 +38,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.checkerframework.checker.units.qual.C;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
@@ -265,15 +266,19 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
* @return
*/
@Override
public ParamsInfoEO queryById(String id) {
public ParamsInfoEO queryById(String id, String cut) {
ParamsInfoEO paramsInfoEO = getById(id);
// 关联查询认证类别参数
List<CertCategoryParamsInfoEO> certCategoryParamsInfoEOList = certCategoryParamsInfoEOService.selectListByNioNumber(paramsInfoEO.getNioNumber(), paramsInfoEO.getParamsTemplateId());
// 认证类别 数据字典 map
List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByDictCode("cert_category");
Map<String, String> certCategoryMap = sysDictItemList.stream().collect(Collectors.toMap(c->c.getItemValue(), c->c.getItemText()));
Map<String, String> certCategoryMap = new HashMap<>();
if (CutEnum.CN.getValue().equals(cut)) {
certCategoryMap = sysDictItemList.stream().collect(Collectors.toMap(c -> c.getItemValue(), c -> c.getItemText()));
} else {
certCategoryMap = sysDictItemList.stream().collect(Collectors.toMap(c -> c.getItemValue(), c -> c.getEnName()));
}
for (CertCategoryParamsInfoEO certCategoryParamsInfoEO : certCategoryParamsInfoEOList) {
certCategoryParamsInfoEO.setCertCategory_dictText(certCategoryMap.get(certCategoryParamsInfoEO.getCertCategory()));
}
@@ -309,7 +314,11 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
// 基本参数项
ExportParams bussExportParams = new ExportParams();
bussExportParams.setSheetName("企业参数表");
if (CutEnum.CN.getValue().equals(cut)) {
bussExportParams.setSheetName("企业参数表");
} else {
bussExportParams.setSheetName("Company Params");
}
bussExportParams.setType(ExcelType.XSSF); // 解决HSSFRichTextString cannot cast XSSFRichTextString问题
bussExportParams.setStyle(CommonExcelExportStyler.class);
@@ -327,7 +336,12 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
// 认证类别参数项
List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByDictCode("cert_category");
List<String> certCategoryNameList = sysDictItemList.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
List<String> certCategoryNameList = new ArrayList<>();
if (CutEnum.CN.getValue().equals(cut)) {
certCategoryNameList = sysDictItemList.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
} else {
certCategoryNameList = sysDictItemList.stream().map(SysDictItem::getEnName).collect(Collectors.toList());
}
if (CollectionUtil.isNotEmpty(certCategoryNameList)) {
for (String certCategoryName : certCategoryNameList) {
ExportParams certExportParams = new ExportParams();
@@ -468,7 +482,7 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
List<String> certCategoryList = certCategoryParamsInfoEOList.stream().map(CertCategoryParamsInfoEO::getCertCategory).distinct().collect(Collectors.toList());
List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByDictCode("cert_category");
List<String> finalCertCategoryList = certCategoryList;
certCategoryNameList = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).map(SysDictItem::getItemText).collect(Collectors.toList());
certCategoryNameList = sysDictItemList.stream().filter(e -> finalCertCategoryList.contains(e.getItemValue())).map(SysDictItem::getItemText).collect(Collectors.toList());
certCategoryMap = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).collect(Collectors.toMap(c->c.getItemText(),c->c.getItemValue()));
}
//导出数据
@@ -555,8 +569,8 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
List<String> certCategoryList = certCategoryParamsInfoEOList.stream().map(CertCategoryParamsInfoEO::getCertCategory).distinct().collect(Collectors.toList());
List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByDictCode("cert_category");
List<String> finalCertCategoryList = certCategoryList;
certCategoryNameList = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).map(SysDictItem::getItemText).collect(Collectors.toList());
certCategoryMap = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).collect(Collectors.toMap(c->c.getItemText(),c->c.getItemValue()));
certCategoryNameList = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).map(SysDictItem::getEnName).collect(Collectors.toList());
certCategoryMap = sysDictItemList.stream().filter(e-> finalCertCategoryList.contains(e.getItemValue())).collect(Collectors.toMap(c->c.getEnName(),c->c.getItemValue()));
}
//导出数据
List<Map<String, Object>> sheetsList = new ArrayList<>();
@@ -564,7 +578,7 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
// 创建参数对象(用来设定excel得sheet得内容等信息)
ExportParams bussExportParams = new ExportParams();
// 设置sheet得名称
bussExportParams.setSheetName("企业参数表");
bussExportParams.setSheetName("Company Params");
bussExportParams.setType(ExcelType.XSSF); // 解决HSSFRichTextString cannot cast XSSFRichTextString问题
bussExportParams.setStyle(CommonExcelExportStyler.class);
// 创建sheet1使用得map
@@ -732,14 +746,19 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
// 导入参数设置,默认即可
ImportParams params = new ImportParams();
try {
// 取数据 TODO 英文导入待处理
// 取数据
XSSFWorkbook workbook=new XSSFWorkbook(new FileInputStream(excelfile));
List<ParamsInfoCnImport> paramsInfoEOList = new ArrayList<>();
Map<String,List<CertCategoryParamsInfoCnImport>> certCategoryParamsInfoEOListMap = new HashMap<>();
// 认证类别 数据字典 map
List<SysDictItem> sysDictItemList = sysDictItemService.selectItemsByDictCode("cert_category");
Map<String, String> certCategoryMap = sysDictItemList.stream().collect(Collectors.toMap(c->c.getItemText(),c->c.getItemValue()));
Map<String, String> certCategoryMap = new HashMap<>();
if (CutEnum.CN.getValue().equals(cut)) {
certCategoryMap = sysDictItemList.stream().collect(Collectors.toMap(c->c.getItemText(),c->c.getItemValue()));
} else {
certCategoryMap = sysDictItemList.stream().collect(Collectors.toMap(c->c.getEnName(),c->c.getItemValue()));
}
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
params.setStartSheetIndex(numSheet);
@@ -986,6 +1005,8 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
Map<String,String> controlVerifyEnumMap = ControlVerifyEnum.toMapForImport(cut);
Map<String,String> paramsIsMustEnumMap = ParamsIsMustEnum.toMapForImport(cut);
// 认证类别map
Map<String, String> certCategoryMap = new HashMap<>();
//树形数据字典
List<String> treeNameList = new ArrayList<>();
//普通数据字典
@@ -993,11 +1014,17 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
if (CutEnum.CN.getValue().equals(cut)) {
treeNameList = categoryList.stream().map(SysCategory::getName).collect(Collectors.toList());
itemNameList = dictItemList.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
certCategoryMap = dictItemList.stream().filter(e->"cert_category".equals(e.getDictCode())).collect(Collectors.toMap(c->c.getItemText(),c->c.getItemValue()));
} else if(CutEnum.EN.getValue().equals(cut)){
treeNameList = categoryList.stream().map(SysCategory::getEnName).collect(Collectors.toList());
itemNameList = dictItemList.stream().map(SysDictItem::getEnName).collect(Collectors.toList());
certCategoryMap = dictItemList.stream().filter(e->"cert_category".equals(e.getDictCode())).collect(Collectors.toMap(c->c.getEnName(),c->c.getItemValue()));
}
Map<String, String> nioCertCategoryMap = getNioCertCategoryMap(certCategoryParamsInfoEOListMap, certCategoryMap); // 认证类别专用
//存放数据验证结果信息
List<String> stringMessage = new ArrayList<>();
int i = 1; //记录行号
@@ -1090,15 +1117,21 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
countError += (int)resultMap.get("countError");
// 认证类别
String certCategory = dto.getCertCategory();
resultMap = validateMustAndLength(certCategory, "认证类别", "cert category", IsMustEnum.YES.getValue(), "1000", false, cut);
// 来源:认证类别sheet页
resultMap = validateMustAndLength(nioCertCategoryMap.get(nioNumber), "认证类别", "cert category", IsMustEnum.YES.getValue(), "1000", false, cut);
errorMsg += (String)resultMap.get("errorMsg");
countError += (int)resultMap.get("countError");
resultMap = getCodeByName(certCategory,"认证类别", "cert category", "dicCode",null,itemNameList,dictItemList,cut);
errorMsg += (String)resultMap.get("errorMsg");
countError += (int)resultMap.get("countError");
certCategory = (String)resultMap.get("value");
dto.setCertCategory(certCategory);
dto.setCertCategory(nioCertCategoryMap.get(nioNumber));
// String certCategory = dto.getCertCategory();
// resultMap = validateMustAndLength(certCategory, "认证类别", "cert category", IsMustEnum.YES.getValue(), "1000", false, cut);
// errorMsg += (String)resultMap.get("errorMsg");
// countError += (int)resultMap.get("countError");
// resultMap = getCodeByName(certCategory,"认证类别", "cert category", "dicCode",null,itemNameList,dictItemList,cut);
// errorMsg += (String)resultMap.get("errorMsg");
// countError += (int)resultMap.get("countError");
// certCategory = (String)resultMap.get("value");
// dto.setCertCategory(certCategory);
// 控件类型
String controlType = dto.getControlType();
@@ -1274,6 +1307,30 @@ public class ParamsInfoEOServiceImpl extends ServiceImpl<ParamsInfoEOMapper, Par
return map;
}
private Map<String, String> getNioCertCategoryMap(Map<String,List<CertCategoryParamsInfoCnImport>> certCategoryParamsInfoEOListMap,Map<String, String> certCategoryMap) {
Map<String, String> nioCertCategoryMap = new HashMap<>();
// 获取nio最大级
List<CertCategoryParamsInfoCnImport> listAll = new ArrayList<>();
for (Map.Entry<String, List<CertCategoryParamsInfoCnImport>> ccDtoMap : certCategoryParamsInfoEOListMap.entrySet()) {
List<CertCategoryParamsInfoCnImport> list = ccDtoMap.getValue();
if (CollectionUtil.isNotEmpty(list)) {
listAll.addAll(list);
}
}
List<CertCategoryParamsInfoCnImport> listAfterDistinct = listAll.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
new TreeSet<>(Comparator.comparing(o -> o.getNioNumber() + ";" + o.getCertCategory()))), ArrayList::new));
listAfterDistinct.forEach(item -> {
String certs = listAfterDistinct.stream()
.filter(e->item.getNioNumber().equals(e.getNioNumber()))
.map(CertCategoryParamsInfoCnImport::getCertCategory)
.collect(Collectors.joining(","));
nioCertCategoryMap.put(item.getNioNumber(), certs);
});
return nioCertCategoryMap;
}
private Map<String, Object> validateMustAndLength (String value, String fieldNameCn, String fieldNameEn, String mustInput, String dbLength, Boolean isSingle, String cut) {
String errorMsg = "";
int countError= 0;
@@ -57,7 +57,7 @@ public class CertCategoryParamsInfoCnImport {
private String description;
/**nio编号*/
@Excel(name = "*nio编号", width = 15, orderNum = "1")
@Excel(name = "*NIO编号", width = 15, orderNum = "1")
@ApiModelProperty(value = "nio编号")
private String nioNumber;
@@ -42,22 +42,22 @@ public class CertCategoryParamsInfoEnExport {
private String sysOrgCode;
/**编号*/
@Excel(name = "*number", width = 15, orderNum = "2")
@Excel(name = "*Number", width = 15, orderNum = "2")
@ApiModelProperty(value = "编号")
private String paramsNumber;
/**参数名称*/
@Excel(name = "*params name", width = 15, orderNum = "3")
@Excel(name = "*Params Name", width = 15, orderNum = "3")
@ApiModelProperty(value = "参数名称")
private String paramsName;
/**参数说明*/
@Excel(name = "description", width = 36, orderNum = "4")
@Excel(name = "Description", width = 36, orderNum = "4")
@ApiModelProperty(value = "参数说明")
private String description;
/**nio编号*/
@Excel(name = "*nio number", width = 15, orderNum = "1")
@Excel(name = "*NIO Number", width = 15, orderNum = "1")
@ApiModelProperty(value = "nio编号")
private String nioNumber;
@@ -42,12 +42,12 @@ public class CertCategoryParamsInfoEnImport {
private String sysOrgCode;
/**编号*/
@Excel(name = "*number", width = 15, orderNum = "2")
@Excel(name = "*Number", width = 15, orderNum = "2")
@ApiModelProperty(value = "编号")
private String paramsNumber;
/**参数名称*/
@Excel(name = "*params name", width = 15, orderNum = "3")
@Excel(name = "*Params Name", width = 15, orderNum = "3")
@ApiModelProperty(value = "参数名称")
private String paramsName;
@@ -57,7 +57,7 @@ public class CertCategoryParamsInfoEnImport {
private String description;
/**nio编号*/
@Excel(name = "*nio number", width = 15, orderNum = "1")
@Excel(name = "*NIO Number", width = 15, orderNum = "1")
@ApiModelProperty(value = "nio编号")
private String nioNumber;
@@ -13,7 +13,7 @@ import lombok.Data;
public class ParamsInfoCnImport {
/**nio编号*/
@Excel(name = "*nio编号", width = 15)
@Excel(name = "*NIO编号", width = 15)
@ApiModelProperty(value = "nio编号")
private String nioNumber;
@@ -48,7 +48,7 @@ public class ParamsInfoCnImport {
private String description;
/**认证类别*/
@Excel(name = "*认证类别", width = 15)
// @Excel(name = "*认证类别", width = 15)
@ApiModelProperty(value = "认证类别")
private String certCategory;
@@ -45,61 +45,61 @@ public class ParamsInfoEnExport {
private String sysOrgCode;
/**nio编号*/
@Excel(name = "*nio number", width = 15)
@Excel(name = "*NIO Number", width = 15)
@ApiModelProperty(value = "nio编号")
private String nioNumber;
/**是否必填*/
@Excel(name = "*is must", width = 15, replace = {"yes_1","no_0"})
@Excel(name = "*Is Must", width = 15, replace = {"yes_1","no_0"})
@ApiModelProperty(value = "是否必填")
private String isMust;
/**参数名称*/
@Excel(name = "*params name", width = 15)
@Excel(name = "*Params Name", width = 15)
@ApiModelProperty(value = "参数名称")
private String paramsName;
/**技术领域*/
@Excel(name = "*technology territory", width = 15)
@Excel(name = "*Technical Field", width = 15)
// @Dict(dicCode = "technology_territory")
@ApiModelProperty(value = "技术领域")
private String technologyTerritory;
/**参数批次*/
@Excel(name = "*params batch", width = 15, dicCode = "params_batch_en")
@Excel(name = "*Params Batch", width = 15, dicCode = "params_batch_en")
@Dict(dicCode = "params_batch")
@ApiModelProperty(value = "参数批次")
private String paramsBatch;
/**责任领域*/
@Excel(name = "*duty territory", width = 15, dicCode = "duty_territory_en")
@Excel(name = "*Duty Territory", width = 15, dicCode = "duty_territory_en")
@Dict(dicCode = "duty_territory")
@ApiModelProperty(value = "责任领域")
private String dutyTerritory;
/**参数说明*/
@Excel(name = "description", width = 36)
@Excel(name = "Description", width = 36)
@ApiModelProperty(value = "参数说明")
private String description;
/**认证类别*/
@Excel(name = "*cert category", width = 15, dicCode = "cert_category_en")
// @Excel(name = "*Cert Category", width = 15, dicCode = "cert_category_en")
@Dict(dicCode = "cert_category")
@ApiModelProperty(value = "认证类别")
private String certCategory;
/**控件类型*/
@Excel(name = "*control type", width = 15, replace = {"text_1","pull single_2","pull more_3","file_4","text+pull single_5","text+pull more_6","text+file_7","pull single+file_8","pull more+file_9","text+pull single+file_10"})
@Excel(name = "*Control Type", width = 15, replace = {"text_1","pull single_2","pull more_3","file_4","text+pull single_5","text+pull more_6","text+file_7","pull single+file_8","pull more+file_9","text+pull single+file_10"})
@ApiModelProperty(value = "控件类型")
private String controlType;
/**控件校验*/
@Excel(name = "control verify", width = 15, replace = {"null_1","chinese_2","positive integer_3","positive float_4","integer decimaL_5","decimal one_6","decimal two_7","decimal three_8","decimal four_9"})
@Excel(name = "Control Verify", width = 15, replace = {"null_1","chinese_2","positive integer_3","positive float_4","integer decimaL_5","decimal one_6","decimal two_7","decimal three_8","decimal four_9"})
@ApiModelProperty(value = "控件校验")
private String controlVerify;
/**控件备选值*/
@Excel(name = "control values", width = 15)
@Excel(name = "Control Values", width = 15)
@ApiModelProperty(value = "控件备选值")
private String controlValues;
@@ -107,7 +107,7 @@ public class ParamsInfoEnExport {
@ApiModelProperty(value = "附件模板")
private String fileTemplateConnectId;
@Excel(name = "file template", width = 15)
@Excel(name = "File Template", width = 15)
private String fileTemplateName; //附件模板文件名
/**参数模板id*/
@@ -13,57 +13,57 @@ import lombok.Data;
public class ParamsInfoEnImport {
/**nio编号*/
@Excel(name = "*nio number", width = 15)
@Excel(name = "*NIO Number", width = 15)
@ApiModelProperty(value = "nio编号")
private String nioNumber;
/**是否必填*/
@Excel(name = "*is must", width = 15)
@Excel(name = "*Is Must", width = 15)
@ApiModelProperty(value = "是否必填")
private String isMust;
/**参数名称*/
@Excel(name = "*params name", width = 15)
@Excel(name = "*Params Name", width = 15)
@ApiModelProperty(value = "参数名称")
private String paramsName;
/**技术领域*/
@Excel(name = "*technology territory", width = 15)
@Excel(name = "*Technical Field", width = 15)
@ApiModelProperty(value = "技术领域")
private String technologyTerritory;
/**参数批次*/
@Excel(name = "*params batch", width = 15)
@Excel(name = "*Params Batch", width = 15)
@ApiModelProperty(value = "参数批次")
private String paramsBatch;
/**责任领域*/
@Excel(name = "*duty territory", width = 15)
@Excel(name = "*Duty Territory", width = 15)
@ApiModelProperty(value = "责任领域")
private String dutyTerritory;
/**参数说明*/
@Excel(name = "description", width = 36)
@Excel(name = "Description", width = 36)
@ApiModelProperty(value = "参数说明")
private String description;
/**认证类别*/
@Excel(name = "*cert category", width = 15)
// @Excel(name = "*Cert Category", width = 15)
@ApiModelProperty(value = "认证类别")
private String certCategory;
/**控件类型*/
@Excel(name = "*control type", width = 15)
@Excel(name = "*Control Type", width = 15)
@ApiModelProperty(value = "控件类型")
private String controlType;
/**控件校验*/
@Excel(name = "control verify", width = 15)
@Excel(name = "Control Verify", width = 15)
@ApiModelProperty(value = "控件校验")
private String controlVerify;
/**控件备选值*/
@Excel(name = "control values", width = 15)
@Excel(name = "Control Values", width = 15)
@ApiModelProperty(value = "控件备选值")
private String controlValues;
@@ -71,7 +71,7 @@ public class ParamsInfoEnImport {
@ApiModelProperty(value = "附件模板")
private String fileTemplateConnectId;
@Excel(name = "file template", width = 15)
@Excel(name = "File Template", width = 15)
private String fileTemplateName; //附件模板文件名
/**参数模板id*/