文档拆分条款-导入
This commit is contained in:
+16
-8
@@ -12,14 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -218,6 +211,21 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
|||||||
return Result.OK(list);
|
return Result.OK(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ocr识别调取已入库文件-中英文切换
|
||||||
|
* @param flag 标识传 1-->用于查询文档库字段属性
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "文档库信息表-文档拆分表头和查询条件")
|
||||||
|
@ApiOperation(value="文档库信息表-文档拆分表头和查询条件", notes="文档库信息表-文档拆分表头和查询条件")
|
||||||
|
@GetMapping(value = "/getHeaderOrConditionForSplit")
|
||||||
|
// @RequiresPermissions("document:getHeaderOrConditionForSplit")
|
||||||
|
public Result<List<Map<String,Object>>> getHeaderOrConditionForSplit(@RequestParam(name="flag",required=true) String flag,
|
||||||
|
@RequestParam(name="cut",required=true) String cut) {
|
||||||
|
List<Map<String, Object>> list = bussDocumentLibraryEOService.getHeaderOrConditionForSplit(flag,cut);
|
||||||
|
return Result.OK(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑数据查询
|
* 编辑数据查询
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
+2
@@ -185,6 +185,8 @@ public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibr
|
|||||||
*/
|
*/
|
||||||
List<Map<String, Object>> getHeaderOrConditionForOcr(String flag, String cut);
|
List<Map<String, Object>> getHeaderOrConditionForOcr(String flag, String cut);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getHeaderOrConditionForSplit(String flag, String cut);
|
||||||
|
|
||||||
String pullMessage(String departIds, String ids, String documentIds);
|
String pullMessage(String departIds, String ids, String documentIds);
|
||||||
|
|
||||||
void importZip(MultipartFile file);
|
void importZip(MultipartFile file);
|
||||||
|
|||||||
+83
@@ -3317,6 +3317,89 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文档拆分调取已入库文件-中英文切换
|
||||||
|
*
|
||||||
|
* @param flag header-表头,condition-查询条件
|
||||||
|
* @param cut
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getHeaderOrConditionForSplit(String flag, String cut) {
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
Map<String, Object> map1 = new HashMap<>();
|
||||||
|
Map<String, Object> map2 = new HashMap<>();
|
||||||
|
Map<String, Object> map3 = new HashMap<>();
|
||||||
|
Map<String, Object> map4 = new HashMap<>();
|
||||||
|
|
||||||
|
if ("header".equals(flag)) {
|
||||||
|
if (CutEnum.CN.getValue().equals(cut)) {
|
||||||
|
//编号
|
||||||
|
map1.put("db_field_name", "serial_number");//字段
|
||||||
|
map1.put("db_field_txt", "编号");//字段中文名
|
||||||
|
list.add(map1);
|
||||||
|
//标题
|
||||||
|
map2.put("db_field_name", "title");//字段
|
||||||
|
map2.put("db_field_txt", "标题");//字段中文名
|
||||||
|
list.add(map2);
|
||||||
|
//文件名称
|
||||||
|
map3.put("db_field_name", "file_name");//字段
|
||||||
|
map3.put("db_field_txt", "文件名称");//字段中文名
|
||||||
|
list.add(map3);
|
||||||
|
//文件状态
|
||||||
|
map4.put("db_field_name", "text_info");//字段
|
||||||
|
map4.put("db_field_txt", "文本状态");//字段中文名
|
||||||
|
list.add(map4);
|
||||||
|
} else {
|
||||||
|
//编号
|
||||||
|
map1.put("db_field_name", "serial_number");//字段
|
||||||
|
map1.put("db_field_txt", "serial number");//字段中文名
|
||||||
|
list.add(map1);
|
||||||
|
//标题
|
||||||
|
map2.put("db_field_name", "title");//字段
|
||||||
|
map2.put("db_field_txt", "title");//字段中文名
|
||||||
|
list.add(map2);
|
||||||
|
//文件名称
|
||||||
|
map3.put("db_field_name", "file_name");//字段
|
||||||
|
map3.put("db_field_txt", "file name");//字段中文名
|
||||||
|
list.add(map3);
|
||||||
|
//文件信息
|
||||||
|
map4.put("db_field_name", "text_info");//字段
|
||||||
|
map4.put("db_field_txt", "text info");//字段中文名
|
||||||
|
list.add(map4);
|
||||||
|
}
|
||||||
|
} else if ("condition".equals(flag)) {
|
||||||
|
if (CutEnum.CN.getValue().equals(cut)) {
|
||||||
|
//编号
|
||||||
|
map1.put("db_field_name", "serial_number");//字段
|
||||||
|
map1.put("db_field_txt", "编号");//字段中文名
|
||||||
|
map1.put("dict_field", "");//数据字典
|
||||||
|
map1.put("field_show_type", "1");
|
||||||
|
list.add(map1);
|
||||||
|
//标题
|
||||||
|
map2.put("db_field_name", "title");//字段
|
||||||
|
map2.put("db_field_txt", "标题");//字段中文名
|
||||||
|
map2.put("dict_field", "");//数据字典
|
||||||
|
map2.put("field_show_type", "1");
|
||||||
|
list.add(map2);
|
||||||
|
} else {
|
||||||
|
//编号
|
||||||
|
map1.put("db_field_name", "serial_number");//字段
|
||||||
|
map1.put("db_field_txt", "serial number");//字段中文名
|
||||||
|
map1.put("dict_field", "");//数据字典
|
||||||
|
map1.put("field_show_type", "1");
|
||||||
|
list.add(map1);
|
||||||
|
//标题
|
||||||
|
map2.put("db_field_name", "title");//字段
|
||||||
|
map2.put("db_field_txt", "title");//字段中文名
|
||||||
|
map2.put("dict_field", "");//数据字典
|
||||||
|
map2.put("field_show_type", "1");
|
||||||
|
list.add(map2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送
|
* 推送
|
||||||
*
|
*
|
||||||
|
|||||||
+12
-117
@@ -1,30 +1,22 @@
|
|||||||
package com.jero.modules.split.controller;
|
package com.jero.modules.split.controller;
|
||||||
|
|
||||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
||||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.common.aspect.annotation.AutoLog;
|
import com.jero.common.aspect.annotation.AutoLog;
|
||||||
import com.jero.common.system.base.controller.JeroController;
|
import com.jero.common.system.base.controller.JeroController;
|
||||||
import com.jero.modules.split.common.FileUnZip;
|
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||||
import com.jero.modules.split.common.SplitTableInfo;
|
|
||||||
import com.jero.modules.split.dto.SarFileSplitItemsImportDto;
|
|
||||||
import com.jero.modules.split.entity.SarFileSplitItemsEO;
|
import com.jero.modules.split.entity.SarFileSplitItemsEO;
|
||||||
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
||||||
import com.jero.modules.split.service.IFileSplitItemsEOService;
|
import com.jero.modules.split.service.IFileSplitItemsEOService;
|
||||||
import com.jero.modules.split.service.impl.FileSplitItemsEOServiceImpl;
|
import com.jero.modules.split.service.impl.FileSplitItemsEOServiceImpl;
|
||||||
import com.jero.modules.split.util.POIReadExcelToHtml;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -32,14 +24,10 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.File;
|
import java.io.IOException;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
import static com.jero.modules.split.util.ExcelUtil.checkObjAllFieldsIsNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: liyawei
|
* @Author: liyawei
|
||||||
@@ -201,6 +189,14 @@ public class FileSplitItemsEOController extends JeroController<SarFileSplitItems
|
|||||||
fileSplitItemsEOService.exportSplitInfo(cut, idList, infoId, exportName, response, request);
|
fileSplitItemsEOService.exportSplitInfo(cut, idList, infoId, exportName, response, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "文档拆分条款信息-导入拆分结果")
|
||||||
|
@PostMapping(value = "/importSplitResult")
|
||||||
|
public Result<?> importSplitResult( MultipartFile file,
|
||||||
|
String cut,
|
||||||
|
SarFileSplitInfoEO splitInfoEO) throws IOException {
|
||||||
|
return fileSplitItemsEOService.importSplitResult(file,cut,splitInfoEO);
|
||||||
|
}
|
||||||
|
|
||||||
@AutoLog(value = "文档拆分条款信息-导入")
|
@AutoLog(value = "文档拆分条款信息-导入")
|
||||||
@ApiOperation(value = "文档拆分条款信息-导入")
|
@ApiOperation(value = "文档拆分条款信息-导入")
|
||||||
@PostMapping(value = "/importSplitItems")
|
@PostMapping(value = "/importSplitItems")
|
||||||
@@ -208,108 +204,7 @@ public class FileSplitItemsEOController extends JeroController<SarFileSplitItems
|
|||||||
@RequestParam(value = "cut") String cut,
|
@RequestParam(value = "cut") String cut,
|
||||||
@RequestParam(value = "menuId") String menuId,
|
@RequestParam(value = "menuId") String menuId,
|
||||||
@RequestParam(value = "infoId") String infoId) throws Exception {
|
@RequestParam(value = "infoId") String infoId) throws Exception {
|
||||||
//验证文件名是否合格
|
return fileSplitItemsEOService.importSplitItems(file, cut, menuId, infoId);
|
||||||
/* 截取后缀名 */
|
|
||||||
int pos = file.getOriginalFilename().lastIndexOf(".");
|
|
||||||
String str = file.getOriginalFilename().substring(pos+1).toLowerCase();
|
|
||||||
String filenameorg = file.getOriginalFilename().substring(0,pos);
|
|
||||||
//判断上传文件必须是zip
|
|
||||||
// TODO 允许导入rar
|
|
||||||
if (!str.equals("zip")) {
|
|
||||||
return Result.error("请上传zip文件");
|
|
||||||
}
|
|
||||||
String path = uploadpath + "/modal/"+filenameorg;
|
|
||||||
File saveDirectory = new File(path);
|
|
||||||
if(!saveDirectory.isDirectory()){
|
|
||||||
saveDirectory.mkdir();
|
|
||||||
}
|
|
||||||
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +"/"+ file.getOriginalFilename()));
|
|
||||||
try{
|
|
||||||
//解压缩
|
|
||||||
String zipEntryName = FileUnZip.unZipFiles(path +"/"+ file.getOriginalFilename(),path);
|
|
||||||
// 数据相关处理,
|
|
||||||
// 1.获取其中的Excel,
|
|
||||||
List<File> excelfilelist = FileUnZip.readExcelFile(zipEntryName);
|
|
||||||
if(excelfilelist.size()<1){
|
|
||||||
//删除原上传文件
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return Result.error("压缩包内没有上传Excel数据");
|
|
||||||
} else if (excelfilelist.size()>1) {
|
|
||||||
//删除原上传文件
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return Result.error("压缩包内有多个Excel数据源");
|
|
||||||
}
|
|
||||||
File excelfile = excelfilelist.get(0);
|
|
||||||
// 导入参数设置,默认即可
|
|
||||||
ImportParams params = new ImportParams();
|
|
||||||
try {
|
|
||||||
// 导入表头
|
|
||||||
String fields[] = {"条款号", "条款名称","条款内容","新车型实施日期",
|
|
||||||
"在产车实施日期","关联零部件","适用车型","引用标准","备注","关联文件"};
|
|
||||||
params.setImportFields(fields);
|
|
||||||
List<Map<String, Object>> result = new ArrayList<>();
|
|
||||||
// 解析excel,并返回校验信息
|
|
||||||
result = ExcelImportUtil.importExcel(excelfile, SarFileSplitItemsImportDto.class, params);
|
|
||||||
Long getExcelInfo = System.currentTimeMillis();
|
|
||||||
//excel读取到的数据
|
|
||||||
List<Map<String, Object>> datas = result;
|
|
||||||
if(datas!=null &&!datas.isEmpty()){
|
|
||||||
try {
|
|
||||||
//获取全部sheet页中表格
|
|
||||||
XSSFWorkbook workbook=new XSSFWorkbook(new FileInputStream(excelfile));
|
|
||||||
XSSFSheet sheet=null;
|
|
||||||
List<SplitTableInfo> getSheetTableList = new ArrayList();
|
|
||||||
for (int i = 1; i < workbook.getNumberOfSheets(); i++) {//获取每个Sheet表
|
|
||||||
sheet = workbook.getSheetAt(i);
|
|
||||||
SplitTableInfo splitTableInfo = new SplitTableInfo();
|
|
||||||
splitTableInfo.setTableName(sheet.getSheetName());
|
|
||||||
String tableHtml = POIReadExcelToHtml.readExcelToHtml(workbook,i,false);
|
|
||||||
splitTableInfo.setTableHtml(tableHtml);
|
|
||||||
getSheetTableList.add(splitTableInfo);
|
|
||||||
}
|
|
||||||
int i = 0 ;
|
|
||||||
List<Map<String, Object>> datasUpdate = new ArrayList<>();
|
|
||||||
//2019.05.14 当读取exceL出现空行过多时,空行数为20以上时中断读取,将数据清洗为新的list
|
|
||||||
for(Map<String, Object> sarStandImportDto :datas){
|
|
||||||
if(i>20){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//判断此行数据是否全部为空
|
|
||||||
if(checkObjAllFieldsIsNull(sarStandImportDto)){
|
|
||||||
i++;
|
|
||||||
//是则不读取
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
i = 0;
|
|
||||||
datasUpdate.add(sarStandImportDto);
|
|
||||||
}
|
|
||||||
String unzipfilepath = zipEntryName;
|
|
||||||
Result<?> message = fileSplitItemsEOService.importSplitItems(datasUpdate,menuId,unzipfilepath,infoId,getSheetTableList);
|
|
||||||
//删除原上传文件
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return message;
|
|
||||||
} catch (Exception e) {
|
|
||||||
//删除原上传文件
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return Result.error(e.getMessage());
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
//删除原上传文件
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return Result.error("没有可导入的数据,请检查!");
|
|
||||||
}
|
|
||||||
} catch (NoSuchElementException e){
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return Result.error("没有可导入的数据,请检查!");
|
|
||||||
} catch (Exception e) {
|
|
||||||
//删除原上传文件
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return Result.error( "读取失败,请严格按照模板文件导入数据");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
//删除原上传文件
|
|
||||||
FileUnZip.deleteDir(saveDirectory);
|
|
||||||
return Result.error("读取失败,请严格按照模板文件导入数据");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -49,7 +49,9 @@ public class SarFileSplitInfoController extends JeroController<SarFileSplitInfoE
|
|||||||
public Result<?> queryPageList(SarFileSplitInfoEOPage sarFileSplitInfoEOPage) {
|
public Result<?> queryPageList(SarFileSplitInfoEOPage sarFileSplitInfoEOPage) {
|
||||||
LambdaQueryWrapper<SarFileSplitInfoEO> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SarFileSplitInfoEO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.like(StringUtils.isNotEmpty(sarFileSplitInfoEOPage.getSerialNumber()), SarFileSplitInfoEO::getSerialNumber, sarFileSplitInfoEOPage.getSerialNumber())
|
queryWrapper.like(StringUtils.isNotEmpty(sarFileSplitInfoEOPage.getSerialNumber()), SarFileSplitInfoEO::getSerialNumber, sarFileSplitInfoEOPage.getSerialNumber())
|
||||||
.like(StringUtils.isNotEmpty(sarFileSplitInfoEOPage.getTitle()), SarFileSplitInfoEO::getTitle, sarFileSplitInfoEOPage.getTitle());
|
.like(StringUtils.isNotEmpty(sarFileSplitInfoEOPage.getTitle()), SarFileSplitInfoEO::getTitle, sarFileSplitInfoEOPage.getTitle())
|
||||||
|
.orderBy(StringUtils.isNotBlank(sarFileSplitInfoEOPage.getOrderByField()), "1".equals(sarFileSplitInfoEOPage.getOrderBy())?true:false, SarFileSplitInfoEO::getCreateTime)
|
||||||
|
.orderBy(StringUtils.isBlank(sarFileSplitInfoEOPage.getOrderByField()), false, SarFileSplitInfoEO::getCreateTime);
|
||||||
Page<SarFileSplitInfoEO> page = new Page<SarFileSplitInfoEO>(sarFileSplitInfoEOPage.getPageNo(), sarFileSplitInfoEOPage.getPageSize());
|
Page<SarFileSplitInfoEO> page = new Page<SarFileSplitInfoEO>(sarFileSplitInfoEOPage.getPageNo(), sarFileSplitInfoEOPage.getPageSize());
|
||||||
IPage<SarFileSplitInfoEO> pageList = sarFileSplitInfoService.page(page, queryWrapper);
|
IPage<SarFileSplitInfoEO> pageList = sarFileSplitInfoService.page(page, queryWrapper);
|
||||||
List<SarFileSplitInfoEO> rows = pageList.getRecords();
|
List<SarFileSplitInfoEO> rows = pageList.getRecords();
|
||||||
|
|||||||
+3
@@ -61,4 +61,7 @@ public interface FileSplitItemsEOMapper extends BaseMapper<SarFileSplitItemsEO>
|
|||||||
List<Map<String, Object>> queryByOrdersForExport(@Param("field") String field,
|
List<Map<String, Object>> queryByOrdersForExport(@Param("field") String field,
|
||||||
@Param("idList")List<String> idList,
|
@Param("idList")List<String> idList,
|
||||||
@Param("infoId") String infoId);
|
@Param("infoId") String infoId);
|
||||||
|
|
||||||
|
int deleteByMenuIds(@Param("idList") List<String> idList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -90,4 +90,13 @@
|
|||||||
</if>
|
</if>
|
||||||
order by SAR_FILE_SPLIT_MENU.display_seq ASC
|
order by SAR_FILE_SPLIT_MENU.display_seq ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteByMenuIds" parameterType="java.util.List">
|
||||||
|
delete from sar_file_split_items
|
||||||
|
where menu_id in
|
||||||
|
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
-1
@@ -55,5 +55,4 @@ public class SarFileSplitInfoEOPage {
|
|||||||
private String orderByField;
|
private String orderByField;
|
||||||
|
|
||||||
private String cut;
|
private String cut;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -7,9 +7,11 @@ import com.jero.modules.split.common.SplitTableInfo;
|
|||||||
import com.jero.modules.split.dto.FileSpiltValTableExportDto;
|
import com.jero.modules.split.dto.FileSpiltValTableExportDto;
|
||||||
import com.jero.modules.split.dto.FileSplitValExportDto;
|
import com.jero.modules.split.dto.FileSplitValExportDto;
|
||||||
import com.jero.modules.split.dto.FileSplitValImgExportDto;
|
import com.jero.modules.split.dto.FileSplitValImgExportDto;
|
||||||
|
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||||
import com.jero.modules.split.entity.SarFileSplitItemsEO;
|
import com.jero.modules.split.entity.SarFileSplitItemsEO;
|
||||||
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
||||||
import com.jero.modules.split.page.SarFileSplitItemsEOPage;
|
import com.jero.modules.split.page.SarFileSplitItemsEOPage;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -43,7 +45,11 @@ public interface IFileSplitItemsEOService extends IService<SarFileSplitItemsEO>
|
|||||||
|
|
||||||
int batchSet(Map<String,Object> parameter);
|
int batchSet(Map<String,Object> parameter);
|
||||||
|
|
||||||
Result<?> importSplitItems(List<Map<String, Object>> list, String menuId, String filepath, String infoId, List<SplitTableInfo> getSheetTableList);
|
Result<?> importSplitItemsData(List<Map<String, Object>> list, String menuId, String filepath, String infoId, List<SplitTableInfo> getSheetTableList);
|
||||||
|
|
||||||
|
Result<?> importSplitItems(MultipartFile file, String cut, String menuId, String infoId) throws IOException;
|
||||||
|
|
||||||
|
Result<?> importSplitResult(MultipartFile file, String cut, SarFileSplitInfoEO sarFileSplitInfoEO) throws IOException;
|
||||||
|
|
||||||
void exportTemplate(String cut, HttpServletResponse response, HttpServletRequest request);
|
void exportTemplate(String cut, HttpServletResponse response, HttpServletRequest request);
|
||||||
|
|
||||||
@@ -62,5 +68,8 @@ public interface IFileSplitItemsEOService extends IService<SarFileSplitItemsEO>
|
|||||||
List<FileSplitValImgExportDto> allImgList,
|
List<FileSplitValImgExportDto> allImgList,
|
||||||
SarFileSplitItemsEOPage page);
|
SarFileSplitItemsEOPage page);
|
||||||
|
|
||||||
public String[] getWorkbookTitleForExport(String cut);
|
String[] getWorkbookTitleForExport(String cut);
|
||||||
|
|
||||||
|
int deleteByMenuIds(List<String> idList);
|
||||||
|
String getFieldForExport();
|
||||||
}
|
}
|
||||||
|
|||||||
+702
-7
@@ -1,5 +1,6 @@
|
|||||||
package com.jero.modules.split.service.impl;
|
package com.jero.modules.split.service.impl;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.ZipUtil;
|
import cn.hutool.core.util.ZipUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -18,31 +19,35 @@ import com.jero.generater.modules.online.cgform.entity.OnlCgformField;
|
|||||||
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
|
||||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||||
import com.jero.modules.lanswitch.service.ILanguageSwitchService;
|
import com.jero.modules.lanswitch.service.ILanguageSwitchService;
|
||||||
|
import com.jero.modules.ocr.util.UUIDUtils;
|
||||||
import com.jero.modules.oss.entity.OSSFile;
|
import com.jero.modules.oss.entity.OSSFile;
|
||||||
import com.jero.modules.oss.service.IOSSFileService;
|
import com.jero.modules.oss.service.IOSSFileService;
|
||||||
import com.jero.modules.split.common.ConvertHtml2Excel;
|
import com.jero.modules.split.common.ConvertHtml2Excel;
|
||||||
|
import com.jero.modules.split.common.FileUnZip;
|
||||||
import com.jero.modules.split.common.ReadExcel;
|
import com.jero.modules.split.common.ReadExcel;
|
||||||
import com.jero.modules.split.common.SplitTableInfo;
|
import com.jero.modules.split.common.SplitTableInfo;
|
||||||
import com.jero.modules.split.dto.FileSpiltValTableExportDto;
|
import com.jero.modules.split.dto.FileSpiltValTableExportDto;
|
||||||
import com.jero.modules.split.dto.FileSplitValExportDto;
|
import com.jero.modules.split.dto.FileSplitValExportDto;
|
||||||
import com.jero.modules.split.dto.FileSplitValImgExportDto;
|
import com.jero.modules.split.dto.FileSplitValImgExportDto;
|
||||||
import com.jero.modules.split.entity.SarFileSplitItemsEO;
|
import com.jero.modules.split.entity.*;
|
||||||
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
|
||||||
import com.jero.modules.split.entity.SarFileSplitMenuEO;
|
|
||||||
import com.jero.modules.split.mapper.FileSplitItemsEOMapper;
|
import com.jero.modules.split.mapper.FileSplitItemsEOMapper;
|
||||||
import com.jero.modules.split.mapper.SarFileSplitItemsValEOMapper;
|
import com.jero.modules.split.mapper.SarFileSplitItemsValEOMapper;
|
||||||
import com.jero.modules.split.mapper.SarFileSplitMenuEOMapper;
|
import com.jero.modules.split.mapper.SarFileSplitMenuEOMapper;
|
||||||
import com.jero.modules.split.page.SarFileSplitItemsEOPage;
|
import com.jero.modules.split.page.SarFileSplitItemsEOPage;
|
||||||
import com.jero.modules.split.page.SarFileSplitItemsTableEOPage;
|
import com.jero.modules.split.page.SarFileSplitItemsTableEOPage;
|
||||||
import com.jero.modules.split.page.SarFileSplitItemsValEOPage;
|
import com.jero.modules.split.page.SarFileSplitItemsValEOPage;
|
||||||
|
import com.jero.modules.split.page.SarFileSplitMenuEOPage;
|
||||||
import com.jero.modules.split.service.IFileSplitItemsEOService;
|
import com.jero.modules.split.service.IFileSplitItemsEOService;
|
||||||
|
import com.jero.modules.split.service.ISarFileSplitInfoService;
|
||||||
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
||||||
|
import com.jero.modules.split.util.POIReadExcelToHtml;
|
||||||
import com.jero.modules.system.entity.SysCategory;
|
import com.jero.modules.system.entity.SysCategory;
|
||||||
import com.jero.modules.system.entity.SysCategoryTreeVO;
|
import com.jero.modules.system.entity.SysCategoryTreeVO;
|
||||||
import com.jero.modules.system.entity.SysDictItem;
|
import com.jero.modules.system.entity.SysDictItem;
|
||||||
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
|
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
|
||||||
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
|
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
|
||||||
import com.jero.modules.system.util.UserUtils;
|
import com.jero.modules.system.util.UserUtils;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.common.usermodel.HyperlinkType;
|
import org.apache.poi.common.usermodel.HyperlinkType;
|
||||||
@@ -56,10 +61,12 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -71,6 +78,9 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.afterturn.easypoi.util.PoiCellUtil.getCellValue;
|
||||||
|
import static com.jero.modules.split.util.ExcelUtil.checkObjAllFieldsIsNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: liyawei
|
* @Author: liyawei
|
||||||
* @Description:
|
* @Description:
|
||||||
@@ -94,11 +104,11 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysDictItemServiceImpl sysDictItemServiceImpl;
|
private SysDictItemServiceImpl sysDictItemServiceImpl;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ILanguageSwitchService languageSwitchService;
|
|
||||||
@Autowired
|
|
||||||
private ISarFileSplitItemsValEOService sarFileSplitItemsValEOService;
|
private ISarFileSplitItemsValEOService sarFileSplitItemsValEOService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOSSFileService ossFileService;
|
private IOSSFileService ossFileService;
|
||||||
|
@Autowired
|
||||||
|
private ISarFileSplitInfoService sarFileSplitInfoService;
|
||||||
|
|
||||||
@Value(value = "${jero.path.upload}")
|
@Value(value = "${jero.path.upload}")
|
||||||
private String uploadpath;
|
private String uploadpath;
|
||||||
@@ -663,9 +673,688 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<?> importSplitItems(List<Map<String, Object>> list, String menuId, String filepath, String infoId, List<SplitTableInfo> getSheetTableList) {
|
public Result<?> importSplitItemsData(List<Map<String, Object>> list, String menuId, String filepath, String infoId, List<SplitTableInfo> getSheetTableList) {
|
||||||
|
//此处需要做各种验证,数据库操作
|
||||||
|
try {
|
||||||
|
//验证导入数据是否符合规则
|
||||||
|
Map map = validateImportDatas(list,filepath);
|
||||||
|
boolean isOk = (boolean) map.get("result");
|
||||||
|
if (!isOk) {
|
||||||
|
//验证没有通过
|
||||||
|
String message = (String) map.get("message");
|
||||||
|
return Result.error(message);
|
||||||
|
}
|
||||||
|
//将导入数据循环合并整理后 新增至相应表
|
||||||
|
list = (List<Map<String, Object>>) map.get("resultList");
|
||||||
|
int countSuccess = 0;
|
||||||
|
// 最终添加的数据
|
||||||
|
List<Map<String, Object>> addItemsEOList = new ArrayList<>();
|
||||||
|
int itemNum = 0;
|
||||||
|
for (Map<String, Object> importDto : list) {
|
||||||
|
//判断此行数据是否全部为空,是则不读取
|
||||||
|
if(checkObjAllFieldsIsNull(importDto)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String importDtoId = UUID.randomUUID().toString().replace("-", "");
|
||||||
|
importDto.put("id", importDtoId); // 记得去掉
|
||||||
|
importDto.put("info_id", infoId);
|
||||||
|
List<SarFileSplitItemsValEO> addItemValList = new ArrayList<>();
|
||||||
|
if (addItemsEOList != null && !addItemsEOList.isEmpty()) {
|
||||||
|
Map<String, Object> oldItems = addItemsEOList.get(addItemsEOList.size()-1);
|
||||||
|
if (itemNum > 0 && importDto.get("items_num").equals(oldItems.get("items_num"))
|
||||||
|
&& importDto.get("items_name").equals(oldItems.get("items_name"))) {
|
||||||
|
addItemValList = (List<SarFileSplitItemsValEO>) oldItems.get("itemValEOList"); // TODO
|
||||||
|
String itemContent = oldItems.get("iterms_conditions").toString() + importDto.get("iterms_conditions").toString();
|
||||||
|
oldItems.put("iterms_conditions", itemContent);
|
||||||
|
String[] valArr = importDto.get("iterms_conditions").toString().split("\n");
|
||||||
|
if (valArr != null && valArr.length > 0) {
|
||||||
|
for (int i=0;i<valArr.length;i++) {
|
||||||
|
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
|
||||||
|
boolean isText = true;
|
||||||
|
if (getSheetTableList != null && !getSheetTableList.isEmpty()) {
|
||||||
|
for (SplitTableInfo splitTableInfo : getSheetTableList) {
|
||||||
|
if (splitTableInfo.getTableName().equals(valArr[i])) {
|
||||||
|
isText = false;
|
||||||
|
valEO.setType("TABLE");
|
||||||
|
valEO.setItemContent(splitTableInfo.getTableHtml());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
|
||||||
|
if (nowfilelist != null && !nowfilelist.isEmpty()) {
|
||||||
|
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1"); // TODO MultipartFile强转不知道会不会成功
|
||||||
|
if(oSSFile!=null){
|
||||||
|
isText = false;
|
||||||
|
String path = "uploadPath/" + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/")+1);
|
||||||
|
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||||
|
valEO.setType("IMG");
|
||||||
|
valEO.setItemContent(imgCon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isText) {
|
||||||
|
valEO.setType("TEXT");
|
||||||
|
valEO.setItemContent(valArr[i]);
|
||||||
|
}
|
||||||
|
addItemValList.add(valEO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oldItems.put("itemValEOList", addItemValList);
|
||||||
|
}else {
|
||||||
|
String[] valArr = importDto.get("iterms_conditions").toString().split("\n");
|
||||||
|
if (valArr != null && valArr.length > 0) {
|
||||||
|
for (int i=0;i<valArr.length;i++) {
|
||||||
|
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
|
||||||
|
boolean isText = true;
|
||||||
|
if (getSheetTableList != null && !getSheetTableList.isEmpty()) {
|
||||||
|
for (SplitTableInfo splitTableInfo : getSheetTableList) {
|
||||||
|
if (splitTableInfo.getTableName().equals(valArr[i])) {
|
||||||
|
isText = false;
|
||||||
|
valEO.setType("TABLE");
|
||||||
|
valEO.setItemContent(splitTableInfo.getTableHtml());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
|
||||||
|
if (nowfilelist != null && !nowfilelist.isEmpty()) {
|
||||||
|
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1"); // TODO MultipartFile强转不知道会不会成功
|
||||||
|
if(oSSFile!=null){
|
||||||
|
isText = false;
|
||||||
|
String path = "uploadPath/" + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/")+1);
|
||||||
|
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||||
|
valEO.setType("IMG");
|
||||||
|
valEO.setItemContent(imgCon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isText) {
|
||||||
|
valEO.setType("TEXT");
|
||||||
|
valEO.setItemContent(valArr[i]);
|
||||||
|
}
|
||||||
|
addItemValList.add(valEO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
importDto.put("itemValEOList", addItemValList);
|
||||||
|
addItemsEOList.add(importDto);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] valArr = importDto.get("iterms_conditions").toString().split("\n");
|
||||||
|
if (valArr != null && valArr.length > 0) {
|
||||||
|
for (int i=0;i<valArr.length;i++) {
|
||||||
|
SarFileSplitItemsValEO valEO = new SarFileSplitItemsValEO();
|
||||||
|
boolean isText = true;
|
||||||
|
if (getSheetTableList != null && !getSheetTableList.isEmpty()) {
|
||||||
|
for (SplitTableInfo splitTableInfo : getSheetTableList) {
|
||||||
|
if (splitTableInfo.getTableName().equals(valArr[i])) {
|
||||||
|
isText = false;
|
||||||
|
valEO.setType("TABLE");
|
||||||
|
valEO.setItemContent(splitTableInfo.getTableHtml());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<File> nowfilelist = FileUnZip.readFileByFilename(filepath, valArr[i]);
|
||||||
|
if (nowfilelist != null && !nowfilelist.isEmpty()) {
|
||||||
|
OSSFile oSSFile = ossFileService.uploadLocal((MultipartFile) nowfilelist.get(0), "","1"); // TODO MultipartFile强转不知道会不会成功
|
||||||
|
if(oSSFile!=null){
|
||||||
|
isText = false;
|
||||||
|
String path = "uploadPath/" + oSSFile.getUrl().substring(oSSFile.getUrl().lastIndexOf("/")+1);
|
||||||
|
String imgCon = "<img class=\'wordImg\' src=\'" + path + "\'>";
|
||||||
|
valEO.setType("IMG");
|
||||||
|
valEO.setItemContent(imgCon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isText) {
|
||||||
|
valEO.setType("TEXT");
|
||||||
|
valEO.setItemContent(valArr[i]);
|
||||||
|
}
|
||||||
|
addItemValList.add(valEO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
importDto.put("itemValEOList", addItemValList);
|
||||||
|
addItemsEOList.add(importDto);
|
||||||
|
}
|
||||||
|
itemNum++;
|
||||||
|
}
|
||||||
|
//TODO 创建树结构
|
||||||
|
Long treeListDisplay = 1L;
|
||||||
|
//获取导入数据一级节点级数
|
||||||
|
int levelNum = 0;
|
||||||
|
SarFileSplitMenuEO targetMenuEO = sarFileSplitMenuEOMapper.selectByPrimaryKey(menuId);
|
||||||
|
if(targetMenuEO != null){
|
||||||
|
//判断导入节点是否有子节点
|
||||||
|
int childrenCount = sarFileSplitMenuEOMapper.getChildrenCountByParentId(menuId);
|
||||||
|
if(childrenCount > 1){
|
||||||
|
//获取导入节点的下一级最后一个子节点的序号
|
||||||
|
treeListDisplay = Long.valueOf(sarFileSplitMenuEOMapper.getMaxDisplayByidNextLevel(menuId));
|
||||||
|
}else{
|
||||||
|
//当导入节点没有子节点时,获取当前节点的序号
|
||||||
|
treeListDisplay = targetMenuEO.getDisplaySeq();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(!"总目录".equals(targetMenuEO.getName())){
|
||||||
|
// String regex = "^[0-9]{0}([0-9]|[.])+$"; //TODO 待优化:数字和点必须交替
|
||||||
|
// if(!targetMenuEO.getName().matches(regex)){
|
||||||
|
// throw new AdcDaBaseException("所选目录命名不规范");
|
||||||
|
// }
|
||||||
|
// String[] str = targetMenuEO.getName().split(".");
|
||||||
|
// if(str.length == 0){
|
||||||
|
// levelNum = 2;
|
||||||
|
// }else {
|
||||||
|
// levelNum = str.length + 1;
|
||||||
|
// }
|
||||||
|
// }else{
|
||||||
|
// levelNum = 1;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取导入数据的所有一级节点
|
||||||
|
int finalLevelNum = levelNum;
|
||||||
|
/*List<SarFileSplitItemsEO> itemNumList = new ArrayList<>();
|
||||||
|
for(SarFileSplitItemsEO sarFileSplitItemsEO : addItemsEOList){
|
||||||
|
String[] str = sarFileSplitItemsEO.getItemsNum().split(".");
|
||||||
|
if(str.length == finalLevelNum){
|
||||||
|
itemNumList.add(sarFileSplitItemsEO);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
// 2022-03-31 注释
|
||||||
|
// List<SarFileSplitItemsEO> itemNumList = addItemsEOList.stream()
|
||||||
|
// .filter(e->e.getItemsNum().split("\\.").length == finalLevelNum || e.getItemsNum().contains("附录"))
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
//构造目录树
|
||||||
|
HashMap<String, String> menuAndItemMap = new HashMap<>();
|
||||||
|
// if(CollectionUtils.isNotEmpty(itemNumList)) {
|
||||||
|
List<Map<String, Object>> itemsEOList = new ArrayList<>(addItemsEOList);
|
||||||
|
List<SarFileSplitMenuTreeNode> treeList = buildTree(itemsEOList, treeListDisplay, menuId);
|
||||||
|
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
String userId = sysUser.getId();
|
||||||
|
for (SarFileSplitMenuTreeNode treeNode : treeList) {
|
||||||
|
//创建菜单
|
||||||
|
SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
|
||||||
|
sarFileSplitMenuEO.setId(treeNode.getId());
|
||||||
|
sarFileSplitMenuEO.setInfoId(infoId);
|
||||||
|
sarFileSplitMenuEO.setName(treeNode.getName());
|
||||||
|
sarFileSplitMenuEO.setItemName(treeNode.getItemName());
|
||||||
|
sarFileSplitMenuEO.setPId(treeNode.getParentId());
|
||||||
|
sarFileSplitMenuEO.setDisplaySeq(treeNode.getOrderNum());
|
||||||
|
sarFileSplitMenuEO.setCreationUser(userId);
|
||||||
|
sarFileSplitMenuEO.setModifyUser(userId);
|
||||||
|
sarFileSplitMenuEO.setValidFlag(0);
|
||||||
|
sarFileSplitMenuEO.setCreationTime(new Date());
|
||||||
|
sarFileSplitMenuEO.setModifyTime(new Date());
|
||||||
|
sarFileSplitMenuEOMapper.insertSelective(sarFileSplitMenuEO);
|
||||||
|
menuAndItemMap.put(treeNode.getItemId(), treeNode.getId());
|
||||||
|
}
|
||||||
|
// }else{
|
||||||
|
// throw new AdcDaBaseException("导入目录命名不规范");
|
||||||
|
// }
|
||||||
|
//添加条款
|
||||||
|
for (Map<String, Object> itemsEO : addItemsEOList) {
|
||||||
|
if(menuAndItemMap.get(itemsEO.get("id")) != null) {
|
||||||
|
createItemsInfo(itemsEO, menuAndItemMap.get(itemsEO.get("id").toString()), infoId);
|
||||||
|
}
|
||||||
|
countSuccess++;
|
||||||
|
}
|
||||||
|
//导入之后的节点(包括子节点),序号加一
|
||||||
|
SarFileSplitMenuEOPage page = new SarFileSplitMenuEOPage();
|
||||||
|
page.setInfoId(targetMenuEO.getInfoId());
|
||||||
|
page.setValidFlag("0");
|
||||||
|
page.setOrderBy("display_seq asc");
|
||||||
|
List<SarFileSplitMenuEO> getList = sarFileSplitMenuEOMapper.queryByList(page);
|
||||||
|
if (getList != null && !getList.isEmpty()) {
|
||||||
|
//除去导入节点
|
||||||
|
for(SarFileSplitMenuEO menu : getList){
|
||||||
|
if(menuAndItemMap.containsValue(menu.getId())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(targetMenuEO.getId().equals(menu.getId())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Long oldSeq = menu.getDisplaySeq();
|
||||||
|
if (oldSeq > treeListDisplay) {
|
||||||
|
menu.setDisplaySeq(oldSeq + countSuccess);
|
||||||
|
sarFileSplitMenuEOMapper.updateByPrimaryKeySelective(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String msg = "成功导入" + countSuccess + "条";
|
||||||
|
return Result.OK( msg, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
return Result.error("导入失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> importSplitItems(MultipartFile file, String cut, String menuId, String infoId) throws IOException {
|
||||||
|
//验证文件名是否合格
|
||||||
|
/* 截取后缀名 */
|
||||||
|
int pos = file.getOriginalFilename().lastIndexOf(".");
|
||||||
|
String str = file.getOriginalFilename().substring(pos+1).toLowerCase();
|
||||||
|
String filenameorg = file.getOriginalFilename().substring(0,pos);
|
||||||
|
//判断上传文件必须是zip
|
||||||
|
// TODO 允许导入rar
|
||||||
|
if (!str.equals("zip")) {
|
||||||
|
return Result.error("请上传zip文件");
|
||||||
|
}
|
||||||
|
String path = uploadpath + "/modal/"+filenameorg;
|
||||||
|
File saveDirectory = new File(path);
|
||||||
|
if(!saveDirectory.isDirectory()){
|
||||||
|
saveDirectory.mkdir();
|
||||||
|
}
|
||||||
|
FileUtils.copyInputStreamToFile(file.getInputStream(), new File(path +"/"+ file.getOriginalFilename()));
|
||||||
|
try{
|
||||||
|
//解压缩
|
||||||
|
String zipEntryName = FileUnZip.unZipFiles(path +"/"+ file.getOriginalFilename(),path);
|
||||||
|
// 数据相关处理,
|
||||||
|
// 1.获取其中的Excel,
|
||||||
|
List<File> excelfilelist = FileUnZip.readExcelFile(zipEntryName);
|
||||||
|
if(excelfilelist.size()<1){
|
||||||
|
//删除原上传文件
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return Result.error("压缩包内没有上传Excel数据");
|
||||||
|
} else if (excelfilelist.size()>1) {
|
||||||
|
//删除原上传文件
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return Result.error("压缩包内有多个Excel数据源");
|
||||||
|
}
|
||||||
|
File excelfile = excelfilelist.get(0);
|
||||||
|
// 导入参数设置,默认即可
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
try {
|
||||||
|
// 导入表头
|
||||||
|
String fields[] = getWorkbookTitleForExport(cut); // 有顺序
|
||||||
|
params.setImportFields(fields);
|
||||||
|
|
||||||
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
|
String dbfields = getFieldForExport();
|
||||||
|
List<String> dbfieldList = Arrays.asList(dbfields.split(",")); // 有顺序
|
||||||
|
// 解析excel,并返回校验信息
|
||||||
|
result = read(excelfile, dbfieldList);
|
||||||
|
Long getExcelInfo = System.currentTimeMillis();
|
||||||
|
//excel读取到的数据
|
||||||
|
List<Map<String, Object>> datas = result;
|
||||||
|
if(datas!=null &&!datas.isEmpty()){
|
||||||
|
try {
|
||||||
|
//获取全部sheet页中表格
|
||||||
|
XSSFWorkbook workbook=new XSSFWorkbook(new FileInputStream(excelfile));
|
||||||
|
XSSFSheet sheet=null;
|
||||||
|
List<SplitTableInfo> getSheetTableList = new ArrayList();
|
||||||
|
for (int i = 1; i < workbook.getNumberOfSheets(); i++) {//获取每个Sheet表
|
||||||
|
sheet = workbook.getSheetAt(i);
|
||||||
|
SplitTableInfo splitTableInfo = new SplitTableInfo();
|
||||||
|
splitTableInfo.setTableName(sheet.getSheetName());
|
||||||
|
String tableHtml = POIReadExcelToHtml.readExcelToHtml(workbook,i,false);
|
||||||
|
splitTableInfo.setTableHtml(tableHtml);
|
||||||
|
getSheetTableList.add(splitTableInfo);
|
||||||
|
}
|
||||||
|
int i = 0 ;
|
||||||
|
List<Map<String, Object>> datasUpdate = new ArrayList<>();
|
||||||
|
//2019.05.14 当读取exceL出现空行过多时,空行数为20以上时中断读取,将数据清洗为新的list
|
||||||
|
for(Map<String, Object> sarStandImportDto :datas){
|
||||||
|
if(i>20){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//判断此行数据是否全部为空
|
||||||
|
if(checkObjAllFieldsIsNull(sarStandImportDto)){
|
||||||
|
i++;
|
||||||
|
//是则不读取
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
datasUpdate.add(sarStandImportDto);
|
||||||
|
}
|
||||||
|
String unzipfilepath = zipEntryName;
|
||||||
|
Result<?> message = importSplitItemsData(datasUpdate,menuId,unzipfilepath,infoId,getSheetTableList);
|
||||||
|
//删除原上传文件
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return message;
|
||||||
|
} catch (Exception e) {
|
||||||
|
//删除原上传文件
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return Result.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//删除原上传文件
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return Result.error("没有可导入的数据,请检查!");
|
||||||
|
}
|
||||||
|
} catch (NoSuchElementException e){
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return Result.error("没有可导入的数据,请检查!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
//删除原上传文件
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return Result.error( "读取失败,请严格按照模板文件导入数据");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//删除原上传文件
|
||||||
|
FileUnZip.deleteDir(saveDirectory);
|
||||||
|
return Result.error("读取失败,请严格按照模板文件导入数据");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> importSplitResult(MultipartFile file, String cut, SarFileSplitInfoEO sarFileSplitInfoEO) throws IOException {
|
||||||
|
// 新增拆分记录
|
||||||
|
Date now = new Date();
|
||||||
|
String infoId = UUID.randomUUID().toString().replace("-", "");
|
||||||
|
sarFileSplitInfoEO.setId(infoId);
|
||||||
|
sarFileSplitInfoEO.setSplitResult("成功");
|
||||||
|
sarFileSplitInfoEO.setCreateTime(now);
|
||||||
|
sarFileSplitInfoEO.setUpdateTime(now);
|
||||||
|
sarFileSplitInfoService.save(sarFileSplitInfoEO);
|
||||||
|
// 添加条款总目录
|
||||||
|
SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
|
||||||
|
String menuId = UUID.randomUUID().toString().replace("-", "");
|
||||||
|
sarFileSplitMenuEO.setName("总目录");
|
||||||
|
sarFileSplitMenuEO.setInfoId(infoId);
|
||||||
|
sarFileSplitMenuEO.setDisplaySeq(1L);
|
||||||
|
sarFileSplitMenuEO.setId(menuId);
|
||||||
|
sarFileSplitMenuEO.setValidFlag(0);
|
||||||
|
sarFileSplitMenuEO.setCreationTime(new Date());
|
||||||
|
sarFileSplitMenuEO.setModifyTime(new Date());
|
||||||
|
sarFileSplitMenuEOMapper.insertSelective(sarFileSplitMenuEO);
|
||||||
|
// 导入文件
|
||||||
|
return importSplitItems(file, cut, menuId, infoId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> read(File file, List<String> dbfieldList) {
|
||||||
|
try {
|
||||||
|
//最终返回数据
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
|
||||||
|
Workbook workbook = null;
|
||||||
|
InputStream is = new FileInputStream(file);
|
||||||
|
String name = file.getName().toLowerCase();
|
||||||
|
// 创建excel操作对象
|
||||||
|
if (name.contains(".xlsx") || name.contains(".xls")) {
|
||||||
|
workbook = WorkbookFactory.create(is);
|
||||||
|
}
|
||||||
|
//得到一个工作表
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
//获得数据的总行数
|
||||||
|
int totalRowNum = sheet.getLastRowNum();
|
||||||
|
|
||||||
|
//获得总列数
|
||||||
|
int cellLength = sheet.getRow(0).getPhysicalNumberOfCells();
|
||||||
|
Map<String, Object> map = null;
|
||||||
|
//获得所有数据
|
||||||
|
//从第x行开始获取
|
||||||
|
for (int x = 2; x <= totalRowNum; x++) {
|
||||||
|
map = new HashMap<String, Object>();
|
||||||
|
//获得第i行对象
|
||||||
|
Row row = sheet.getRow(x);
|
||||||
|
//如果一行里的所有单元格都为空则不放进list里面
|
||||||
|
int a = 0;
|
||||||
|
for (int y = 0; y < cellLength; y++) {
|
||||||
|
if (!(row == null)) {
|
||||||
|
Cell cell = row.getCell(y);
|
||||||
|
//设置单元格类型
|
||||||
|
cell.setCellType(CellType.STRING);
|
||||||
|
|
||||||
|
String cellValue = null;
|
||||||
|
boolean isMerge = isMergedRegion(sheet, row.getRowNum(), cell.getColumnIndex());
|
||||||
|
//判断是否具有合并单元格
|
||||||
|
if (isMerge) {
|
||||||
|
cellValue = getMergedRegionValue(sheet, row.getRowNum(), cell.getColumnIndex());
|
||||||
|
} else {
|
||||||
|
cellValue = cell.getStringCellValue();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (cell == null) {
|
||||||
|
map.put(dbfieldList.get(y), "");
|
||||||
|
} else {
|
||||||
|
map.put(dbfieldList.get(y), cellValue);
|
||||||
|
}
|
||||||
|
if (map.get(dbfieldList.get(y)) == null || "".equals(map.get(dbfieldList.get(y)))) {
|
||||||
|
a++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (a != cellLength && row != null) {
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取合并单元格的值
|
||||||
|
*
|
||||||
|
* @param sheet
|
||||||
|
* @param row
|
||||||
|
* @param column
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getMergedRegionValue(Sheet sheet, int row, int column) {
|
||||||
|
int sheetMergeCount = sheet.getNumMergedRegions();
|
||||||
|
for (int i = 0; i < sheetMergeCount; i++) {
|
||||||
|
CellRangeAddress ca = sheet.getMergedRegion(i);
|
||||||
|
int firstColumn = ca.getFirstColumn();
|
||||||
|
int lastColumn = ca.getLastColumn();
|
||||||
|
int firstRow = ca.getFirstRow();
|
||||||
|
int lastRow = ca.getLastRow();
|
||||||
|
if (row >= firstRow && row <= lastRow) {
|
||||||
|
if (column >= firstColumn && column <= lastColumn) {
|
||||||
|
Row fRow = sheet.getRow(firstRow);
|
||||||
|
Cell fCell = fRow.getCell(firstColumn);
|
||||||
|
return getCellValue(fCell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断指定的单元格是否是合并单元格
|
||||||
|
*
|
||||||
|
* @param sheet
|
||||||
|
* @param row 行下标
|
||||||
|
* @param column 列下标
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isMergedRegion(Sheet sheet, int row, int column) {
|
||||||
|
int sheetMergeCount = sheet.getNumMergedRegions();
|
||||||
|
for (int i = 0; i < sheetMergeCount; i++) {
|
||||||
|
CellRangeAddress range = sheet.getMergedRegion(i);
|
||||||
|
int firstColumn = range.getFirstColumn();
|
||||||
|
int lastColumn = range.getLastColumn();
|
||||||
|
int firstRow = range.getFirstRow();
|
||||||
|
int lastRow = range.getLastRow();
|
||||||
|
if (row >= firstRow && row <= lastRow) {
|
||||||
|
if (column >= firstColumn && column <= lastColumn) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map validateImportDatas(List<Map<String, Object>> datas, String filepath) throws Exception {
|
||||||
|
//存放数据验证结果信息
|
||||||
|
List<String> stringMessage = new ArrayList<>();
|
||||||
|
int i = 1; //记录行号
|
||||||
|
int num = 0; //记录是第几条数据
|
||||||
|
//循环验证数据
|
||||||
|
for (Map<String, Object> dto : datas) {
|
||||||
|
i++;
|
||||||
|
int countError = 0; //记录失败数据数量
|
||||||
|
String errorMsg = "第" + i + "行:";
|
||||||
|
if (num > 0 && org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_num").toString())
|
||||||
|
&& org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_name").toString())) {
|
||||||
|
String nowItemContent = dto.get("iterms_conditions").toString();
|
||||||
|
BeanUtils.copyProperties(datas.get(num-1), dto);
|
||||||
|
dto.put("iterms_conditions", nowItemContent);
|
||||||
|
}
|
||||||
|
if (org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_num").toString())) {
|
||||||
|
errorMsg += "条款号不能为空;";
|
||||||
|
countError++;
|
||||||
|
} else {
|
||||||
|
if (dto.get("items_num").toString().length()>100) {
|
||||||
|
errorMsg += "条款号不能超过100个字符;";
|
||||||
|
countError++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (org.apache.commons.lang.StringUtils.isEmpty(dto.get("items_name").toString())) {
|
||||||
|
errorMsg += "条款名称不能为空;";
|
||||||
|
countError++;
|
||||||
|
} else {
|
||||||
|
if (dto.get("items_name").toString().length()>100) {
|
||||||
|
errorMsg += "条款名称不能超过100个字符;";
|
||||||
|
countError++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (countError > 0) {
|
||||||
|
stringMessage.add(errorMsg);
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
Map map = new HashMap();
|
||||||
|
if (stringMessage.isEmpty()) {
|
||||||
|
map.put("result", true);
|
||||||
|
map.put("resultList", datas);
|
||||||
|
map.put("message", "");
|
||||||
|
} else {
|
||||||
|
map.put("result", false);
|
||||||
|
String html = "";
|
||||||
|
for (String message : stringMessage) {
|
||||||
|
html += message + "</br>";
|
||||||
|
}
|
||||||
|
map.put("message", html);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createItemsInfo(Map<String, Object> sarFileSplitItemsEO, String menuId, String infoId){
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
String userId = sysUser.getId();
|
||||||
|
//创建菜单
|
||||||
|
// SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
|
||||||
|
// sarFileSplitMenuEO.setInfoId(infoId);
|
||||||
|
// sarFileSplitMenuEO.setName(sarFileSplitItemsEO.getItemsNum());
|
||||||
|
// sarFileSplitMenuEO.setItemName(sarFileSplitItemsEO.getItemsName());
|
||||||
|
// sarFileSplitMenuEO.setPId(parentId);
|
||||||
|
// sarFileSplitMenuEO.setDisplaySeq(countNum+1L);
|
||||||
|
// sarFileSplitMenuEO.setCreationUser(userId);
|
||||||
|
// sarFileSplitMenuEO.setModifyUser(userId);
|
||||||
|
// String menuId = sarFileSplitMenuEOService.addMenuForImport(sarFileSplitMenuEO);
|
||||||
|
//添加items表数据
|
||||||
|
// String itemsId = UUIDUtils.randomUUID20();
|
||||||
|
// sarFileSplitItemsEO.setId(itemsId);
|
||||||
|
sarFileSplitItemsEO.put("menu_id", menuId);
|
||||||
|
|
||||||
|
//添加val表数据
|
||||||
|
List<SarFileSplitItemsValEO> getValList = (List<SarFileSplitItemsValEO>) sarFileSplitItemsEO.get("itemValEOList"); // TODO
|
||||||
|
String itemConditions = "";
|
||||||
|
int ind = 1;
|
||||||
|
if (getValList != null && !getValList.isEmpty()) {
|
||||||
|
for (SarFileSplitItemsValEO valEO : getValList) {
|
||||||
|
// 当前段内容
|
||||||
|
String valContent = "";
|
||||||
|
if ("TEXT".equals(valEO.getType())) {
|
||||||
|
valContent += "<p>" + valEO.getItemContent() + "</p>";
|
||||||
|
} else if ("IMG".equals(valEO.getType())) {
|
||||||
|
// valContent += "<img class=\'wordImg\' src=\'"+ valEO.getItemContent() +"\'>";
|
||||||
|
valContent += valEO.getItemContent();
|
||||||
|
} else if ("TABLE".equals(valEO.getType())) {
|
||||||
|
valContent += valEO.getItemContent();
|
||||||
|
}
|
||||||
|
itemConditions += valContent;
|
||||||
|
// val表信息
|
||||||
|
valEO.setId(UUIDUtils.randomUUID20());
|
||||||
|
// valEO.setItemId(itemsId);
|
||||||
|
valEO.setItemId(sarFileSplitItemsEO.get("id").toString());
|
||||||
|
valEO.setDisplaySeq(ind);
|
||||||
|
valEO.setValidFlag(0);
|
||||||
|
valEO.setCreationTime(new Date());
|
||||||
|
valEO.setModifyTime(new Date());
|
||||||
|
valEO.setCreationUser(userId);
|
||||||
|
valEO.setModifyUser(userId);
|
||||||
|
ind++;
|
||||||
|
}
|
||||||
|
sarFileSplitItemsValEOMapper.insertForeach(getValList);
|
||||||
|
sarFileSplitItemsEO.put("iterms_conditions", itemConditions);
|
||||||
|
}
|
||||||
|
String id = sarFileSplitItemsEO.get("id").toString();
|
||||||
|
sarFileSplitItemsEO.remove("id");
|
||||||
|
sarFileSplitItemsEO.remove("itemValEOList");
|
||||||
|
insertInfo(sarFileSplitItemsEO,id); // 添加条款
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SarFileSplitMenuTreeNode> buildTree(List<Map<String, Object>> addItemsEOList, Long treeListDisplay, String menuId){
|
||||||
|
//排序
|
||||||
|
Collections.sort(addItemsEOList, new Comparator<Map<String, Object>>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
||||||
|
return o1.get("items_num").toString().compareTo(o2.get("items_num").toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<SarFileSplitMenuTreeNode> treeNodeList = new ArrayList<>();
|
||||||
|
String regex = "^[0-9]{0}([0-9]|[.])+$"; //TODO 待优化:数字和点必须交替
|
||||||
|
for (Map<String, Object> itemEO : addItemsEOList) {
|
||||||
|
String itemNum = itemEO.get("items_num").toString();
|
||||||
|
if(itemNum.matches(regex) || itemNum.contains("附录")) {
|
||||||
|
SarFileSplitMenuTreeNode treeNode = new SarFileSplitMenuTreeNode();
|
||||||
|
treeNode.setId(UUIDUtils.randomUUID20());
|
||||||
|
treeNode.setName(itemNum);
|
||||||
|
if(itemNum.matches(regex)) {
|
||||||
|
//父级是 总目录时,不做处理
|
||||||
|
if(itemNum.contains(".")) {
|
||||||
|
String parentName = itemNum.substring(0, itemNum.lastIndexOf("."));
|
||||||
|
treeNode.setParentName(parentName);
|
||||||
|
List<SarFileSplitMenuTreeNode> p = treeNodeList.stream().filter(e -> e.getName().equals(parentName)).collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(p)) {
|
||||||
|
//其他节点
|
||||||
|
treeNode.setParentId(p.get(0).getId());
|
||||||
|
}else{
|
||||||
|
//一级节点
|
||||||
|
treeNode.setParentId(menuId);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
treeNode.setParentId(menuId);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
treeNode.setParentId(menuId);
|
||||||
|
}
|
||||||
|
++treeListDisplay;
|
||||||
|
treeNode.setOrderNum(treeListDisplay);
|
||||||
|
treeNode.setItemName(itemEO.get("items_name").toString());
|
||||||
|
treeNode.setItemId(itemEO.get("id").toString());
|
||||||
|
treeNodeList.add(treeNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//其他节点
|
||||||
|
/*for (SarFileSplitItemsEO itemEO : addItemsEOList) {
|
||||||
|
String itemNum = itemEO.getItemsNum();
|
||||||
|
if (itemNum.matches(regex)) {
|
||||||
|
SarFileSplitMenuTreeNode treeNode = new SarFileSplitMenuTreeNode();
|
||||||
|
String parentName = itemNum.substring(0, itemNum.lastIndexOf("."));
|
||||||
|
List<SarFileSplitMenuTreeNode> p = treeNodeList.stream().filter(e -> e.getName().equals(parentName)).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(p)) {
|
||||||
|
treeNode.setParentId(p.get(0).getId());
|
||||||
|
}
|
||||||
|
treeNode.setId(UUIDUtils.randomUUID20());
|
||||||
|
treeNode.setName(itemNum);
|
||||||
|
treeNode.setParentName(parentName);
|
||||||
|
//判断格式
|
||||||
|
if (itemNum.lastIndexOf(".") + 1 < itemNum.length()) {
|
||||||
|
// treeNode.setOrderNum(Long.valueOf(itemNum.substring(itemNum.lastIndexOf(".") + 1, itemNum.length())));
|
||||||
|
treeNode.setOrderNum(p.get(0).getOrderNum() + Long.valueOf(itemNum.substring(itemNum.lastIndexOf(".") + 1, itemNum.length())));
|
||||||
|
}
|
||||||
|
|
||||||
|
treeNode.setItemName(itemEO.getItemsName());
|
||||||
|
treeNode.setItemId(itemEO.getId());
|
||||||
|
treeNodeList.add(treeNode);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return treeNodeList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板下载
|
* 模板下载
|
||||||
@@ -1498,12 +2187,18 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl<FileSplitItemsEOMap
|
|||||||
return StringUtils.join(fieldForExport, ",").split(",");
|
return StringUtils.join(fieldForExport, ",").split(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByMenuIds(List<String> idList) {
|
||||||
|
return dao.deleteByMenuIds(idList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取导出文件的表头对应的数据库字段
|
* 获取导出文件的表头对应的数据库字段
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getFieldForExport() {
|
@Override
|
||||||
|
public String getFieldForExport() {
|
||||||
// 查询条款表所有字段
|
// 查询条款表所有字段
|
||||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.FILE_SPLIT_ITEMS.getValue());
|
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.FILE_SPLIT_ITEMS.getValue());
|
||||||
List<String> fields = fieldList.stream()
|
List<String> fields = fieldList.stream()
|
||||||
|
|||||||
+1
@@ -56,6 +56,7 @@ public class SarFileSplitInfoServiceImpl extends ServiceImpl<SarFileSplitInfoMap
|
|||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
String infoId = UUID.randomUUID().toString().replace("-", "");
|
String infoId = UUID.randomUUID().toString().replace("-", "");
|
||||||
sarFileSplitInfoEO.setId(infoId);
|
sarFileSplitInfoEO.setId(infoId);
|
||||||
|
sarFileSplitInfoEO.setSplitResult("成功"); // TODO 这块之后可能不会用到
|
||||||
sarFileSplitInfoEO.setCreateTime(now);
|
sarFileSplitInfoEO.setCreateTime(now);
|
||||||
sarFileSplitInfoEO.setUpdateTime(now);
|
sarFileSplitInfoEO.setUpdateTime(now);
|
||||||
save(sarFileSplitInfoEO);
|
save(sarFileSplitInfoEO);
|
||||||
|
|||||||
+1
-1
@@ -277,7 +277,7 @@ public class SarFileSplitMenuEOServiceImpl extends ServiceImpl<SarFileSplitMenuE
|
|||||||
// 删除条款
|
// 删除条款
|
||||||
sarFileSplitItemsValEOMapper.deleteValByMenuIds(menuIds);
|
sarFileSplitItemsValEOMapper.deleteValByMenuIds(menuIds);
|
||||||
sarFileSplitItemsTableEOMapper.deleteTableByMenuIds(menuIds);
|
sarFileSplitItemsTableEOMapper.deleteTableByMenuIds(menuIds);
|
||||||
sarFileSplitItemsEOMapper.deleteByMenuIds(menuIds);
|
fileSplitItemsEOService.deleteByMenuIds(menuIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int copyMenu (SarFileSplitMenuEO sarMenuEO) {
|
public int copyMenu (SarFileSplitMenuEO sarMenuEO) {
|
||||||
|
|||||||
Reference in New Issue
Block a user