国内外excel导出code转字符

This commit is contained in:
zhaokaiyao@91isoft.com
2021-12-29 15:55:58 +08:00
parent ad8f68de4c
commit b8c494d4c5
2 changed files with 56 additions and 46 deletions
@@ -714,12 +714,9 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
}
}
public void attrInfoShowExport(List<SarStandardsInfo> sarlist) throws Exception {
public void attrInfoShowExport(List<SarStandardsInfo> sarlist,Map<String,String> dicMap) throws Exception {
List<DicTypeEO> dicInfo = dicTypeEODao.getDicInfo("dic_type_code", "dic_type_name");
Map<String, String> dicMap =
dicInfo.stream()
.collect(Collectors.toMap(DicTypeEO::getDicTypeCode,DicTypeEO::getDicTypeName,(value1, value2 )->value2));
for (SarStandardsInfo row : sarlist) {
@@ -732,26 +729,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
String name = entry.getKey();
String value = "";
/**
*============================ 对getAttrMap的value赋值中文名称===============================
*/
if(entry.getValue()!=null) {
StringBuilder builder = new StringBuilder("");
for (String s : entry.getValue().toString().split(",")) {
if (dicMap.containsKey(s)) {
builder.append(dicMap.get(s)+" ");
} else {
builder.append(entry.getValue().toString());
}
getAttrMap.put(name, builder.toString());
}
}
/**
*============================ 对getAttrMap的value赋值中文名称===============================
*/
if ("SVPPS".equals(name)) {
Object svpps = entry.getValue();
@@ -763,28 +741,49 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
}
value = String.valueOf(getAttrMap.get("SVPPSName"));
entry.setValue(value);
} else if (entry.getValue() != null && InitStandAttrUtil.fileFieldList != null && InitStandAttrUtil.fileFieldList.size() > 0 && InitStandAttrUtil.fileFieldList.contains(name)) {
value = entry.getValue().toString();
if (StringUtils.isNotBlank(value)) {
List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(value);
entry.setValue(fileObj);
}
} else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
value = entry.getValue().toString();
if ("GZZXX".equals(name)) {
value = sysInfoEOService.getGroupNamesByIds(value);
} else {
String selVal = InitStandAttrUtil.selectFieldMap.get(name);
if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal) || SelectionTypeEnum.USERLIST.getValue().equals(selVal) || SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) {
if (getAttrMap.get(name + "Name") != null) {
value = String.valueOf(getAttrMap.get(name + "Name"));
}
// else if (entry.getValue() != null && InitStandAttrUtil.fileFieldList != null && InitStandAttrUtil.fileFieldList.size() > 0 && InitStandAttrUtil.fileFieldList.contains(name)) {
// value = entry.getValue().toString();
// if (StringUtils.isNotBlank(value)) {
// List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(value);
// entry.setValue(fileObj);
// }
// }
else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
// value = entry.getValue().toString();
// String selVal = InitStandAttrUtil.selectFieldMap.get(name);
// if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal) || SelectionTypeEnum.USERLIST.getValue().equals(selVal) || SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) {
// if (getAttrMap.get(name + "Name") != null) {
// value = String.valueOf(getAttrMap.get(name + "Name"));
// }
//
//
// } else {
/**
*============================ 对getAttrMap的value赋值中文名称===============================
*/
if(entry.getValue()!=null) {
StringBuilder builder = new StringBuilder("");
for (String s : entry.getValue().toString().split(",")) {
if (dicMap.containsKey(s) && !"ZRBM".equals(name)){
builder.append(dicMap.get(s)+" ");
}
}
if (builder.toString().isEmpty()){
getAttrMap.put(name, entry.getValue().toString());
}else {
getAttrMap.put(name, builder.toString());
}
}
} else {
List<String> valArr = Arrays.asList(value.split(","));
value = dicTypeEODao.getDicNamesByCodes(valArr);
}
}
entry.setValue(value);
/**
*============================ 对getAttrMap的value赋值中文名称===============================
*/
// }
// entry.setValue(value);
}
}
getAttrMap.put("SVPPSTips", svppsTip);
@@ -1705,7 +1704,13 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
nowOrderFunc(page);
}
List<SarStandardsInfo> getList = dao.getSarStandardsExportInfo(page);
attrInfoShowExport(getList);
//查询字典表,形成Hash映射提升速度
List<DicTypeEO> dicInfo = dicTypeEODao.getDicInfo("dic_type_code", "dic_type_name");
Map<String, String> dicMap = dicInfo.stream()
.filter(item-> !item.getDicTypeCode().isEmpty())
.collect(Collectors.toMap(DicTypeEO::getDicTypeCode,DicTypeEO::getDicTypeName,(value1, value2 )->value2));
attrInfoShowExport(getList,dicMap);
return getList;
}
@@ -602,6 +602,11 @@
</foreach>
FROM
TS_DICTYPE
<where>
<foreach collection="filed" index="index" item="item" separator=" and " >
${item} is not NULL
</foreach>
</where>
</select>