|
|
|
@ -549,7 +549,13 @@ public class CollectController { |
|
|
|
|
|
|
|
@ApiOperation("电子文件-目录上传") |
|
|
|
@PostMapping(value = "/catalogUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") |
|
|
|
public ApiResponse<Object> catalogUpload(@ApiParam(value = "文件流", required = true, allowMultiple = true) @RequestParam("file") MultipartFile file,Integer fondsId){ |
|
|
|
public ApiResponse<Object> catalogUpload( |
|
|
|
// @ApiParam(value = "文件流", required = true, allowMultiple = true) @RequestParam("file") MultipartFile file, |
|
|
|
String upfilePath, |
|
|
|
Integer fondsId |
|
|
|
){ |
|
|
|
Map<String,List<String>> failMap = new HashMap<>(); |
|
|
|
File file = new File(prefixPath+upfilePath); |
|
|
|
//当前登录用户 |
|
|
|
String username = SecurityUtils.getCurrentUsername(); |
|
|
|
String descDir = prefixPath+"//"+username+"//"; |
|
|
|
@ -560,7 +566,7 @@ public class CollectController { |
|
|
|
mountFile.setFondsId(fondsId); |
|
|
|
mountFile = collectService.editMountFile(mountFile); |
|
|
|
try { |
|
|
|
InputStream input = file.getInputStream(); |
|
|
|
InputStream input = new FileInputStream(file); |
|
|
|
ZipInputStream zipInputStream = new ZipInputStream(input, Charset.forName("GBK")); |
|
|
|
ZipEntry zipEntry; |
|
|
|
while ((zipEntry = zipInputStream.getNextEntry()) != null) { |
|
|
|
@ -616,6 +622,26 @@ public class CollectController { |
|
|
|
Map<String,Object> category = collectService.findCategoryById(categoryId); |
|
|
|
Map<String,Object> fileCategory = collectService.findCategoryByPidAndLevel(category.get("category_level")==null ? categoryId : category.get("pid")+"",4); |
|
|
|
|
|
|
|
//搜索不到门类 |
|
|
|
if(null == category || null == category.get("id")){ |
|
|
|
File deleteFile = new File(outPath); |
|
|
|
deleteFile.delete(); |
|
|
|
File deleteFoler = new File(descDir); |
|
|
|
deleteFoler(deleteFoler); |
|
|
|
deleteFoler.delete(); |
|
|
|
return ApiResponse.error(500,"未识别到正确的门类数据"); |
|
|
|
} |
|
|
|
|
|
|
|
//根据全宗号和门类id判断是否有权限 |
|
|
|
if(!collectService.isPowerByFondsIdAndCategoryId(fondsId,category.get("pid")+"")){ |
|
|
|
File deleteFile = new File(outPath); |
|
|
|
deleteFile.delete(); |
|
|
|
File deleteFoler = new File(descDir); |
|
|
|
deleteFoler(deleteFoler); |
|
|
|
deleteFoler.delete(); |
|
|
|
return ApiResponse.error(500,"当前账号暂无权限操作该档案门类数据"); |
|
|
|
} |
|
|
|
|
|
|
|
String categoryIdAs = collectService.getcategoryAllParentsId(category.get("id")+""); |
|
|
|
String[] categoryIds = categoryIdAs.split(","); |
|
|
|
String path = "/category/"; |
|
|
|
@ -623,9 +649,15 @@ public class CollectController { |
|
|
|
path += categoryIds[i] + "/"; |
|
|
|
} |
|
|
|
|
|
|
|
String failName = collectService.saveFileToCatalogUpload(mountFile.getId(),fileExtension,fileDpi,path,fileName,fileSize,array[array.length-2],fileCategory,filePath); |
|
|
|
String failName = collectService.saveFileToCatalogUpload(fondsId,mountFile.getId(),fileExtension,fileDpi,path,fileName,fileSize,array[array.length-2],fileCategory,filePath); |
|
|
|
if(!StringUtils.isEmpty(failName)){ |
|
|
|
failArchives.add(failName); |
|
|
|
List<String> failFileName = failMap.get(failName); |
|
|
|
if(null == failFileName){ |
|
|
|
failFileName = new ArrayList<>(); |
|
|
|
} |
|
|
|
failFileName.add(fileName); |
|
|
|
failMap.put(failName,failFileName); |
|
|
|
} |
|
|
|
ok++; |
|
|
|
} |
|
|
|
@ -645,7 +677,11 @@ public class CollectController { |
|
|
|
} |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("mountFile",mountFile); |
|
|
|
json.put("failArchives",failArchives); |
|
|
|
List<String> returnFailArchives = new ArrayList<>(); |
|
|
|
for(String key : failMap.keySet()){ |
|
|
|
returnFailArchives.add(key + ":" + failMap.get(key)); |
|
|
|
} |
|
|
|
json.put("failArchives",returnFailArchives); |
|
|
|
return ApiResponse.success(json); |
|
|
|
} |
|
|
|
|
|
|
|
@ -809,7 +845,8 @@ public class CollectController { |
|
|
|
@ApiOperation("批量挂接") |
|
|
|
@PostMapping(value = "/batchMount", consumes = "multipart/*", headers = "content-type=multipart/form-data") |
|
|
|
public ApiResponse<Object> batchMount( |
|
|
|
@ApiParam(value = "文件流", required = true, allowMultiple = true) @RequestParam("file") MultipartFile file, |
|
|
|
// @ApiParam(value = "文件流", required = true, allowMultiple = true) @RequestParam("file") MultipartFile file, |
|
|
|
@ApiParam(value = "文件路径,必填") String upfilePath, |
|
|
|
@ApiParam(value = "全宗id,必填") @RequestParam(required = false) @Validated Integer fondsId, |
|
|
|
@ApiParam(value = "门类id,必填") @RequestParam(required = false) @Validated String categoryId, |
|
|
|
@ApiParam(value = "挂接方式,必填") @RequestParam(required = false) @Validated Integer mountType, |
|
|
|
@ -820,11 +857,15 @@ public class CollectController { |
|
|
|
//当前登录用户 |
|
|
|
String username = SecurityUtils.getCurrentUsername(); |
|
|
|
String descDir = prefixPath+"//"+username+"//"; |
|
|
|
File file = new File(prefixPath+upfilePath); |
|
|
|
List<String> filePaths = new ArrayList<>(); |
|
|
|
if(!file.exists()){ |
|
|
|
return ApiResponse.error(500,"挂接失败,文件不存在"); |
|
|
|
} |
|
|
|
try { |
|
|
|
InputStream input = file.getInputStream(); |
|
|
|
InputStream input = new FileInputStream(file); |
|
|
|
ZipInputStream zipInputStream = new ZipInputStream(input, Charset.forName("GBK")); |
|
|
|
ZipEntry zipEntry; |
|
|
|
List<String> filePaths = new ArrayList<>(); |
|
|
|
while ((zipEntry = zipInputStream.getNextEntry()) != null) { |
|
|
|
String zipEntryNameStr = zipEntry.getName(); |
|
|
|
String zipEntryName = zipEntryNameStr; |
|
|
|
@ -850,7 +891,12 @@ public class CollectController { |
|
|
|
|
|
|
|
MountFile mountFile = collectService.batchMount(fondsId,categoryId,mountType,checkRepeatType,matchingMode,fields,filePaths); |
|
|
|
File deleteFile = new File(descDir); |
|
|
|
try { |
|
|
|
deleteFile.delete(); |
|
|
|
file.delete(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return ApiResponse.success(mountFile); |
|
|
|
}catch(Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
|