国内外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) { for (SarStandardsInfo row : sarlist) {
@@ -732,26 +729,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
String name = entry.getKey(); String name = entry.getKey();
String value = ""; 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)) { if ("SVPPS".equals(name)) {
Object svpps = entry.getValue(); Object svpps = entry.getValue();
@@ -763,28 +741,49 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
} }
value = String.valueOf(getAttrMap.get("SVPPSName")); value = String.valueOf(getAttrMap.get("SVPPSName"));
entry.setValue(value); entry.setValue(value);
} else if (entry.getValue() != null && InitStandAttrUtil.fileFieldList != null && InitStandAttrUtil.fileFieldList.size() > 0 && InitStandAttrUtil.fileFieldList.contains(name)) { }
value = entry.getValue().toString(); // else if (entry.getValue() != null && InitStandAttrUtil.fileFieldList != null && InitStandAttrUtil.fileFieldList.size() > 0 && InitStandAttrUtil.fileFieldList.contains(name)) {
if (StringUtils.isNotBlank(value)) { // value = entry.getValue().toString();
List<AttFileEO> fileObj = attFileEOService.getMultiFileInfos(value); // if (StringUtils.isNotBlank(value)) {
entry.setValue(fileObj); // 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)) { else if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
value = sysInfoEOService.getGroupNamesByIds(value); // value = entry.getValue().toString();
} else { // String selVal = InitStandAttrUtil.selectFieldMap.get(name);
String selVal = InitStandAttrUtil.selectFieldMap.get(name); // if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal) || SelectionTypeEnum.USERLIST.getValue().equals(selVal) || SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) {
if (SelectionTypeEnum.ORGLIST.getValue().equals(selVal) || SelectionTypeEnum.USERLIST.getValue().equals(selVal) || SelectionTypeEnum.ROLELIST.getValue().equals(selVal)) { // if (getAttrMap.get(name + "Name") != null) {
if (getAttrMap.get(name + "Name") != null) { // value = String.valueOf(getAttrMap.get(name + "Name"));
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(",")); *============================ 对getAttrMap的value赋值中文名称===============================
value = dicTypeEODao.getDicNamesByCodes(valArr); */
} // }
}
entry.setValue(value); // entry.setValue(value);
} }
} }
getAttrMap.put("SVPPSTips", svppsTip); getAttrMap.put("SVPPSTips", svppsTip);
@@ -1705,7 +1704,13 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
nowOrderFunc(page); nowOrderFunc(page);
} }
List<SarStandardsInfo> getList = dao.getSarStandardsExportInfo(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; return getList;
} }
@@ -602,6 +602,11 @@
</foreach> </foreach>
FROM FROM
TS_DICTYPE TS_DICTYPE
<where>
<foreach collection="filed" index="index" item="item" separator=" and " >
${item} is not NULL
</foreach>
</where>
</select> </select>