|
@@ -18,6 +18,7 @@ package org.springblade.archive.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import io.swagger.annotations.*;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -46,6 +47,7 @@ import org.springblade.business.feign.ArchiveFileClient;
|
|
|
import org.springblade.business.vo.NeiYeLedgerVO1;
|
|
|
//import org.springblade.common.utils.DeepSeekClient;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
@@ -665,60 +667,36 @@ public class ArchivesAutoController extends BladeController {
|
|
|
if(archivesAutoList.size()<=1){
|
|
|
return R.fail("请选择多个案卷进行合并");
|
|
|
}
|
|
|
- //根据档号后缀排序 拿到第一个
|
|
|
- ArchivesAuto auto = archivesAutoList.get(0);
|
|
|
- archivesAutoList.sort(Comparator.comparingInt(a -> {
|
|
|
- String fileNumber = a.getFileNumber();
|
|
|
- if (fileNumber == null || fileNumber.isEmpty()) {
|
|
|
- return Integer.MAX_VALUE;
|
|
|
- }
|
|
|
- String[] parts;
|
|
|
- if (fileNumber.indexOf("_") > 0) {
|
|
|
- parts = fileNumber.split("_");
|
|
|
- } else if (fileNumber.indexOf("-") > 0) {
|
|
|
- parts = fileNumber.split("-");
|
|
|
- } else {
|
|
|
- return Integer.MAX_VALUE;
|
|
|
- }
|
|
|
- if (parts.length > 0) {
|
|
|
- try {
|
|
|
- return Integer.parseInt(parts[parts.length - 1]);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- return Integer.MAX_VALUE;
|
|
|
- }
|
|
|
- }
|
|
|
- return Integer.MAX_VALUE;
|
|
|
- }));
|
|
|
- //将除第一个以外的案卷文件archiveId 设置成第一个的id
|
|
|
- List<ArchiveFile>updateArchiveFileList=new ArrayList<>();
|
|
|
- //查出所有案卷文件
|
|
|
- List<ArchiveFile>archiveFileList=new ArrayList<>();
|
|
|
- List<Long> longList = Func.toLongList(ids);
|
|
|
- for (Long id : longList) {
|
|
|
- archiveFileList.addAll(archiveFileClient.getArchiveFileByArchiveIds(id+""));
|
|
|
- }
|
|
|
- int i=1;
|
|
|
- for (ArchiveFile file : archiveFileList) {
|
|
|
- if (!file.getArchiveId().equals(auto.getId())) {
|
|
|
- file.setArchiveId(auto.getId());
|
|
|
- }
|
|
|
- file.setArchiveSort(i++);
|
|
|
- updateArchiveFileList.add(file);
|
|
|
- }
|
|
|
- archiveFileClient.updateArchiveFile(updateArchiveFileList);
|
|
|
- auto.setName(name);
|
|
|
- auto.setFileN(archiveFileList.size());
|
|
|
- //删除其他案卷
|
|
|
- archivesAutoList.remove(auto);
|
|
|
- archivesAutoService.deleteLogic(archivesAutoList.stream().map(o->o.getId()).collect(Collectors.toList()));
|
|
|
+ checkAndUpdateArchiveAction(archivesAutoList,1);
|
|
|
//设置案卷页码和四要素
|
|
|
- archivesAutoService.reCreateArchiveAuto(auto, archiveFileList);
|
|
|
+ archivesAutoService.reCreateArchiveAuto2(archivesAutoList, ids, name);
|
|
|
return R.status(true);
|
|
|
}else {
|
|
|
+ List<ArchivesAuto> archivesAutoList=archivesAutoService.listByIds(Func.toLongList(ids));
|
|
|
+ if(archivesAutoList.isEmpty()){
|
|
|
+ return R.fail("选择的案卷不存在");
|
|
|
+ }
|
|
|
+ checkAndUpdateArchiveAction(archivesAutoList, 2);
|
|
|
archivesAutoService.reCreateArchiveAuto1(ids);
|
|
|
return R.success("正在重组,请稍后查看");
|
|
|
}
|
|
|
}
|
|
|
+ private void checkAndUpdateArchiveAction(List<ArchivesAuto> archivesAutoList, int type){
|
|
|
+ if (archivesAutoList == null || archivesAutoList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<ArchivesAuto> collect = archivesAutoList.stream().filter(item -> item.getActionType() != null && item.getActionType() != 0 && item.getActionType() != 3).collect(Collectors.toList());
|
|
|
+ if (!collect.isEmpty()) {
|
|
|
+ String names = collect.stream().map(ArchivesAuto::getName).collect(Collectors.joining(","));
|
|
|
+ throw new ServiceException("【" + names + "】案卷正在重组或者并卷,请稍后在进行相关操作");
|
|
|
+ }
|
|
|
+ Set<Long> ids = archivesAutoList.stream().map(ArchivesAuto::getId).collect(Collectors.toSet());
|
|
|
+ boolean update = archivesAutoService.update(Wrappers.<ArchivesAuto>lambdaUpdate().set(ArchivesAuto::getActionType, type).in(ArchivesAuto::getId, ids)
|
|
|
+ .and(item -> item.eq(ArchivesAuto::getActionType, 0).or().isNull(ArchivesAuto::getActionType)));
|
|
|
+ if (!update) {
|
|
|
+ throw new ServiceException("操作失败,案卷可能正在重组或者并卷,请稍后在进行相关操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@PostMapping("/creatFileNameFormAI")
|
|
|
@ApiOperationSupport(order = 10)
|
|
@@ -1229,4 +1207,99 @@ public class ArchivesAutoController extends BladeController {
|
|
|
return R.status(archivesAutoService.sortRule(projectId,type));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @PostMapping("/insertArchives")
|
|
|
+ @ApiOperationSupport(order = 43)
|
|
|
+ @ApiModelProperty(value = "插入案卷")
|
|
|
+ public R<Boolean> insertArchives(@RequestBody ArchivesAutoInsertVO vo){
|
|
|
+ // 校验
|
|
|
+ if (vo == null || vo.getTargetId() == null) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ if (vo.getTargetId().equals(vo.getSourceId())) {
|
|
|
+ return R.fail("自己不能选择自己");
|
|
|
+ }
|
|
|
+ String archiveFileIds = vo.getSourceArchiveFileIds();
|
|
|
+ if (StringUtils.isBlank(archiveFileIds)) {
|
|
|
+ return R.fail("请选择要插入的文件");
|
|
|
+ }
|
|
|
+ String[] split = archiveFileIds.split(",");
|
|
|
+ List<String> sourceFileIds = new ArrayList<>();
|
|
|
+ for (String s : split) {
|
|
|
+ if (StringUtils.isNumeric(s)) {
|
|
|
+ sourceFileIds.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sourceFileIds.isEmpty()) {
|
|
|
+ return R.fail("请选择要插入的文件");
|
|
|
+ }
|
|
|
+ ArchivesAuto target = archivesAutoService.getById(vo.getTargetId());
|
|
|
+ ArchivesAuto source = archivesAutoService.getById(vo.getSourceId());
|
|
|
+ if (target == null || source == null) {
|
|
|
+ return R.fail("插入或选择的案卷不存在");
|
|
|
+ }
|
|
|
+ List<ArchiveFile> sourceArchiveFileList = archiveFileClient.getAllArchiveFileByIds(sourceFileIds);
|
|
|
+ if (sourceArchiveFileList == null || sourceArchiveFileList.isEmpty()) {
|
|
|
+ return R.fail("请择要插入的文件不存在");
|
|
|
+ }
|
|
|
+ for (ArchiveFile archiveFile : sourceArchiveFileList) {
|
|
|
+ if (!vo.getSourceId().equals(archiveFile.getArchiveId())) {
|
|
|
+ return R.fail("文件【" + archiveFile.getFileName() + "】不属于【" + source.getName() + "】案卷,请重新选择");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((vo.getTargetIndexFileId() == null || vo.getTargetIndexFileId() <= 0) && (vo.getSortFileList() == null || vo.getSortFileList().isEmpty())) {
|
|
|
+ return R.fail("请选择要插入的位置");
|
|
|
+ }
|
|
|
+ List<ArchiveFile> targetArchiveFileList = archiveFileClient.getArchiveFileByArchiveIds(vo.getTargetId() + "");
|
|
|
+ targetArchiveFileList.sort(Comparator.comparingInt(ArchiveFile::getArchiveSort));
|
|
|
+ List<ArchiveFile> updateArchiveFileList = new ArrayList<>();
|
|
|
+ int sort = 0;
|
|
|
+ if (vo.getTargetIndexFileId() != null && vo.getTargetIndexFileId() > 0) {
|
|
|
+ for (ArchiveFile archiveFile : targetArchiveFileList) {
|
|
|
+ if (archiveFile.getId().equals(vo.getTargetIndexFileId())) {
|
|
|
+ sort = archiveFile.getArchiveSort();
|
|
|
+ ArchiveFile file = new ArchiveFile();
|
|
|
+ file.setId(archiveFile.getId());
|
|
|
+ file.setArchiveId(archiveFile.getArchiveId());
|
|
|
+ sourceArchiveFileList.sort(Comparator.comparingInt(ArchiveFile::getArchiveSort));
|
|
|
+ if (vo.getType() == null || vo.getType() == 0) {
|
|
|
+ updateArchiveFileList.add(file);
|
|
|
+ for (ArchiveFile file1 : sourceArchiveFileList) {
|
|
|
+ ArchiveFile file2 = new ArchiveFile();
|
|
|
+ file2.setId(file1.getId());
|
|
|
+ file2.setArchiveId(archiveFile.getArchiveId());
|
|
|
+ file2.setPageNum("");
|
|
|
+ updateArchiveFileList.add(file2);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (ArchiveFile file1 : sourceArchiveFileList) {
|
|
|
+ ArchiveFile file2 = new ArchiveFile();
|
|
|
+ file2.setId(file1.getId());
|
|
|
+ file2.setArchiveId(archiveFile.getArchiveId());
|
|
|
+ file2.setPageNum("");
|
|
|
+ updateArchiveFileList.add(file2);
|
|
|
+ }
|
|
|
+ updateArchiveFileList.add(file);
|
|
|
+ }
|
|
|
+ } else if (!updateArchiveFileList.isEmpty()) {
|
|
|
+ ArchiveFile file = new ArchiveFile();
|
|
|
+ file.setId(archiveFile.getId());
|
|
|
+ updateArchiveFileList.add(file);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return R.fail("暂不支持");
|
|
|
+ }
|
|
|
+ // 修改排序
|
|
|
+ // 修改标识
|
|
|
+ for (ArchiveFile archiveFile : updateArchiveFileList) {
|
|
|
+ archiveFile.setArchiveSort(sort);
|
|
|
+ archiveFile.setArchiveId(vo.getTargetId());
|
|
|
+ sort++;
|
|
|
+ }
|
|
|
+ archiveFileClient.updateArchiveFile(updateArchiveFileList);
|
|
|
+ archivesAutoService.update(Wrappers.<ArchivesAuto>lambdaUpdate().in(ArchivesAuto::getId,vo.getTargetId(), vo.getSourceId()).set(ArchivesAuto::getActionType, 3));
|
|
|
+ return R.status(true);
|
|
|
+ }
|
|
|
+
|
|
|
}
|