文档库--数据字典纸中英文切换处理

This commit is contained in:
zhn
2022-03-02 09:31:55 +08:00
parent cafaa48f09
commit 3111ffec48
@@ -419,7 +419,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
dataList.get(0).entrySet().forEach(entry -> {
if (fieldPullList.contains(entry.getKey())) {
//下拉选处理数据字典
dictItem(sysDictItems, entry, onlCgformFieldList);
dictItem(sysDictItems, entry, onlCgformFieldList,cut);
}
});
@@ -614,6 +614,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param map
*/
public void updateInfo(Map<String, Object> map) {
String cut = (String) map.get("cut");
if (ObjectUtils.isNotEmpty(map.get("replace_standard_id"))) {
map.put("replace_standard", map.get("replace_standard_id"));
}
@@ -642,7 +643,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
queryWrapper.eq(BussDocumentLibraryEO::getId, id);
List<Map<String, Object>> dataList = bussDocumentLibraryEOMapper.selectMaps(queryWrapper);
//更新log
updateLog(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList);
updateLog(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList,cut);
//判断该条数据是否订阅
@@ -742,7 +743,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
List<OnlCgformField> fieldList,
List<OnlCgformField> fieldDateList,
List<OnlCgformField> fieldFileList,
List<OnlCgformField> fieldPullList) {
List<OnlCgformField> fieldPullList,
String cut) {
Map<String, Object> mapTemp = new HashMap<>();
mapCopy(map, mapTemp);
//时间类型的字段
@@ -760,14 +762,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
for (Map.Entry<String, Object> entry : mapTemp.entrySet()) {
List<OnlCgformField> collect = fieldPullList.stream()
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
StringBuilder sb = new StringBuilder();
@@ -1058,6 +1060,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
public IPage getInfoPage(Map<String, Object> parameter) {
String cut = (String) parameter.get("cut");//中英文切换标识
//需要查询的字段
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList("1");
if (fieldList.size() != 0) {
@@ -1100,7 +1103,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
}
//收藏和订阅
@@ -1218,13 +1221,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
* @param entry
* @param collect
*/
private void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, List<OnlCgformField> collect) {
private void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, List<OnlCgformField> collect,String cut) {
Map<String, Object> map = new HashMap<>();
//通过dictField判断字段是否为下拉选(不为空则为下拉选)
if (collect.size() != 0 && StringUtils.isNotBlank(collect.get(0).getDictField())) {
String value = (String) entry.getValue();
//数据字典中文
List<String> dictItemsCh = new ArrayList<>();
List<String> dictItemsEn = new ArrayList<>();
if (StringUtils.isNotBlank(value)) {
for (String itemValue : value.split(",")) {
//字段的数据字典
@@ -1236,13 +1240,23 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> itemValue.equals(e.getItemValue()))
.collect(Collectors.toList());
if (dictItems.size() != 0) {
List<String> itemText = dictItems.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
List<String> itemText = new ArrayList<>();
if(CutEnum.CN.getValue().equals(cut)){
itemText = dictItems.stream().map(SysDictItem::getItemText).collect(Collectors.toList());
}else {
itemText = dictItems.stream().map(SysDictItem::getEnName).collect(Collectors.toList());
}
dictItemsCh.addAll(itemText);
dictItemsEn.addAll(itemText);
}
}
}
}
entry.setValue(StringUtils.join(dictItemsCh, ","));
if(CutEnum.CN.getValue().equals(cut)){
entry.setValue(StringUtils.join(dictItemsCh, ","));
}else{
entry.setValue(StringUtils.join(dictItemsEn, ","));
}
}
}
@@ -1330,6 +1344,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
*/
@Override
public void exportExcel(Map<String, Object> map, HttpServletResponse response, HttpServletRequest request) {
String cut = (String) map.get("cut");
//String flag = "file"为带文件导出标识
String flag = (String) map.get("flag");
// String flag = "file";
@@ -1359,8 +1374,11 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
if (!"file".equals(flag)) {
fieldListTemp = fieldListTemp.stream().filter(e -> !FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
}
headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldTxt).collect(Collectors.toList());
if(CutEnum.CN.getValue().equals(cut)){
headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldTxt).collect(Collectors.toList());
}else{
headerFieldList = fieldListTemp.stream().map(OnlCgformField::getDbFieldEnName).collect(Collectors.toList());
}
}
//查询字段
List<String> conditionFieldList = fieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
@@ -1380,7 +1398,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
String header = StringUtils.join(headerFieldList, ",");
createHeader(workbook, sheet, header);
// 创建数据
createDatas(workbook, sheet, datas, header, fieldListTemp);
createDatas(workbook, sheet, datas, header, fieldListTemp,cut);
if (!"file".equals(flag)) {
//不带文件导出
@@ -1453,7 +1471,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
}
}
public void createDatas(Workbook workbook, Sheet sheet, List<Map<String, Object>> datas, String header, List<OnlCgformField> fieldList) {
public void createDatas(Workbook workbook, Sheet sheet, List<Map<String, Object>> datas, String header, List<OnlCgformField> fieldList,String cut) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
cellStyle.setAlignment(HorizontalAlignment.CENTER);
@@ -1485,7 +1503,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
.filter(e -> entry.getKey().equals(e.getDictField()))
.collect(Collectors.toList());
//下拉选处理数据字典
dictItem(sysDictItems, entry, collect);
dictItem(sysDictItems, entry, collect,cut);
}
Row row = sheet.createRow(i + 1);
i++;