文档拆分条款-详情树形结构转数组
This commit is contained in:
+67
-9
@@ -655,7 +655,27 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
|
||||
@Override
|
||||
public Map<String, Object> selectByPrimaryKey(String id) {
|
||||
return dao.selectByPrimaryKey(id);
|
||||
Map<String, Object> itemsMap = dao.selectByPrimaryKey(id);
|
||||
// 查询条款表单字段
|
||||
List<OnlCgformField> formFieldList = onlCgformFieldService.getFieldList(ModuleEnum.FILE_SPLIT_ITEMS.getValue());
|
||||
if (formFieldList.size() != 0) {
|
||||
//过滤出表单字段中 控件类型为树结构的
|
||||
formFieldList = formFieldList.stream()
|
||||
.filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowForm()))
|
||||
&& FieldTypeEnum.TREE.getValue().equals(e.getFieldShowType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
for (OnlCgformField onlCgformField : formFieldList){
|
||||
String fieldType = onlCgformField.getFieldShowType();
|
||||
String dbFieldName = onlCgformField.getDbFieldName();
|
||||
if (FieldTypeEnum.FILE.getValue().equals(fieldType)) {
|
||||
if (StringUtils.isNotBlank(itemsMap.get(dbFieldName).toString())) {
|
||||
String[] values = itemsMap.get(dbFieldName).toString().split(",");
|
||||
itemsMap.put(dbFieldName, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemsMap;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -702,7 +722,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
StringBuilder con = new StringBuilder();
|
||||
// 去重合并内容
|
||||
oldItemMapList.forEach(item -> {
|
||||
if(ObjectUtils.isNotEmpty(item.get(dbFieldName))) {
|
||||
if(StringUtils.isNotBlank(item.get(dbFieldName).toString())) {
|
||||
con.append(",").append(item.get(dbFieldName).toString());
|
||||
}
|
||||
}); // 合并
|
||||
@@ -713,7 +733,20 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
newItemMap.put(dbFieldName, conditionSb.toString());
|
||||
} else if(FieldTypeEnum.FILE.getValue().equals(fieldType)){
|
||||
|
||||
// 查询合并条款的所有文件列表
|
||||
String connectIds = null;
|
||||
for(Map<String, Object> oldItemMap : oldItemMapList){
|
||||
if(StringUtils.isNotBlank(oldItemMap.get(dbFieldName).toString())){
|
||||
connectIds += oldItemMap.get(dbFieldName).toString();
|
||||
}
|
||||
}
|
||||
if(connectIds != null){
|
||||
List<OSSFile> ossFileList = ossFileService.getFileInfosByConnectId(connectIds);
|
||||
ossFileList.forEach(file->{
|
||||
file.setConnectId(firstItemMap.get(dbFieldName).toString());
|
||||
});
|
||||
ossFileService.updateFileInfo(ossFileList);
|
||||
}
|
||||
} else if(FieldTypeEnum.TEXT_NUMBER.getValue().equals(fieldType)){
|
||||
Double num = null;
|
||||
for(Map<String, Object> oldItemMap : oldItemMapList){
|
||||
@@ -1107,7 +1140,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
} else if (excelfilelist.size()>1) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
return Result.error("压缩包内有多个Excel数据源");
|
||||
return Result.error("压缩包根目录下仅能存在一个excel为导入数据");
|
||||
}
|
||||
File excelfile = excelfilelist.get(0);
|
||||
// 导入参数设置,默认即可
|
||||
@@ -1121,7 +1154,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
String dbfields = getFieldForExport();
|
||||
List<String> dbfieldList = Arrays.asList(dbfields.split(",")); // 有顺序
|
||||
// 解析excel,并返回校验信息
|
||||
result = read(excelfile, dbfieldList);
|
||||
result = read(excelfile, dbfieldList,fields);
|
||||
Long getExcelInfo = System.currentTimeMillis();
|
||||
//excel读取到的数据
|
||||
List<Map<String, Object>> datas = result;
|
||||
@@ -1174,6 +1207,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
} catch (NoSuchElementException e){
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
return Result.error("没有可导入的数据,请检查!");
|
||||
} catch (JeroBootException e){
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
return Result.error(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
//删除原上传文件
|
||||
FileUnZip.deleteDir(saveDirectory);
|
||||
@@ -1230,8 +1266,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
return mFile;
|
||||
}
|
||||
|
||||
|
||||
private List<Map<String, Object>> read(File file, List<String> dbfieldList) {
|
||||
private List<Map<String, Object>> read(File file, List<String> dbfieldList, String[] titles) {
|
||||
try {
|
||||
//最终返回数据
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
@@ -1245,18 +1280,39 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
}
|
||||
//得到一个工作表
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
//获得数据的总行数
|
||||
int totalRowNum = sheet.getLastRowNum();
|
||||
|
||||
//获得总列数
|
||||
int cellLength = sheet.getRow(0).getPhysicalNumberOfCells();
|
||||
// 验证模板表头是否正确
|
||||
Row row = sheet.getRow(0);
|
||||
for (int i = 0; i < cellLength; i++) {
|
||||
if (!(row == null)) {
|
||||
Cell cell = row.getCell(i);
|
||||
if(ObjectUtil.isNotNull(cell)){
|
||||
//设置单元格类型
|
||||
cell.setCellType(CellType.STRING);
|
||||
String cellValue = cell.getStringCellValue();
|
||||
if(!cellValue.equals(titles[i])){
|
||||
throw new JeroBootException("请导入正确模板!");
|
||||
}
|
||||
} else{
|
||||
throw new JeroBootException("请导入正确模板!");
|
||||
}
|
||||
}else{
|
||||
throw new JeroBootException("请导入正确模板!");
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> map = null;
|
||||
//获得所有数据
|
||||
//从第x行开始获取
|
||||
for (int x = 2; x <= totalRowNum; x++) {
|
||||
map = new HashMap<String, Object>();
|
||||
//获得第i行对象
|
||||
Row row = sheet.getRow(x);
|
||||
Row rowTitle = sheet.getRow(x);
|
||||
//如果一行里的所有单元格都为空则不放进list里面
|
||||
int a = 0;
|
||||
for (int y = 0; y < cellLength; y++) {
|
||||
@@ -1689,7 +1745,8 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
map.put("result", false);
|
||||
String html = "";
|
||||
for (String message : stringMessage) {
|
||||
html += message + "</br>";
|
||||
html += message + ";";
|
||||
// html += message + "</br>";
|
||||
}
|
||||
map.put("message", html);
|
||||
}
|
||||
@@ -1901,6 +1958,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
||||
if (fieldList.size() != 0) {
|
||||
fieldList = fieldList.stream()
|
||||
.filter(e -> YesOrNoEnum.YES.getValue().equals(String.valueOf(e.getIsShowForm())) || "条款内容".equals(e.getDbFieldTxt()))
|
||||
.sorted(Comparator.comparing(OnlCgformField::getOrderNum)) // 必须按顺序
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
//树形数据字典
|
||||
|
||||
Reference in New Issue
Block a user