|
@@ -30,6 +30,10 @@ import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
|
import org.springblade.archive.dto.ArchiveWarningDTO;
|
|
|
import org.springblade.archive.dto.FindAndReplaceDto;
|
|
|
import org.springblade.archive.dto.SaveApplyDTO;
|
|
@@ -41,6 +45,7 @@ import org.springblade.archive.utils.CallBgrsjk;
|
|
|
import org.springblade.archive.vo.*;
|
|
|
import org.springblade.business.entity.ArchiveFile;
|
|
|
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.mp.support.Condition;
|
|
@@ -54,6 +59,11 @@ import org.springblade.manager.feign.ArchiveTreeContractClient;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
|
import org.springblade.manager.feign.ProjectClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.ByteArrayResource;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -65,7 +75,9 @@ import org.springblade.archive.service.IArchivesAutoService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -146,6 +158,53 @@ public class ArchivesAutoController extends BladeController {
|
|
|
return R.data(pages);
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
+ @PostMapping ("/downloadArchiveAutoExcel")
|
|
|
+ @ApiOperationSupport(order = 13)
|
|
|
+ @ApiOperation(value = "档案下载案卷excel")
|
|
|
+ public ResponseEntity<Resource> downloadArchiveAutoExcel(HttpServletResponse response,Long nodeId,Long projectId,Long contractId) throws IOException, InvalidFormatException {
|
|
|
+ List<ArchiveTreeContract> archiveTreeContracts = this.archiveTreeContractClient.queryAllChildByAncestors(nodeId+"",contractId);
|
|
|
+ List<String> ids=new ArrayList<>();
|
|
|
+ if(archiveTreeContracts != null && archiveTreeContracts.size() > 0){
|
|
|
+ ids = JSONArray.parseArray(JSONObject.toJSONString(archiveTreeContracts.stream().map(ArchiveTreeContract::getId).distinct().collect(Collectors.toList())), String.class);
|
|
|
+ ids.add(nodeId+"");
|
|
|
+ }
|
|
|
+ List<ArchivesAutoVO5> list= archivesAutoService.selectArchivesAutoFileFormDownload(projectId,contractId,ids);
|
|
|
+ //String templatePath="/mnt/sdc/Users/hongchuangyanfa/Desktop/excel/archiveTemplate.xlsx";
|
|
|
+ String templatePath="C:\\Users\\hc01\\Desktop\\archiveTemplate.xlsx";
|
|
|
+ InputStream templateStream = new FileInputStream(new File(templatePath));
|
|
|
+ org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(templateStream);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ // 3. 填充数据(假设数据从第2行开始填充)
|
|
|
+ int startRow = 1; // 第2行开始填充数据
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ Row row = sheet.createRow(startRow + i);
|
|
|
+ ArchivesAutoVO5 vo1 = list.get(i);
|
|
|
+ // 填充各列数据
|
|
|
+ row.createCell(0).setCellValue(i + 1); // 序号
|
|
|
+ row.createCell(1).setCellValue(StringUtils.isNotEmpty(vo1.getFileNumber())?vo1.getFileNumber():""); // 档号
|
|
|
+ row.createCell(2).setCellValue(StringUtils.isNotEmpty(vo1.getStorageTimeValue())?vo1.getStorageTimeValue():""); // 案卷题名
|
|
|
+ row.createCell(3).setCellValue(StringUtils.isNotEmpty(vo1.getStorageTimeValue())?vo1.getStorageTimeValue():""); // 保管期限
|
|
|
+ row.createCell(4).setCellValue(vo1.getPageN()+""); // 总页数
|
|
|
+ row.createCell(5).setCellValue(StringUtils.isNotEmpty(vo1.getUnit())?vo1.getUnit():""); // 立卷单位
|
|
|
+ row.createCell(6).setCellValue(StringUtils.isNotEmpty(vo1.getRemark())?vo1.getRemark():""); // 备注
|
|
|
+ }
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ workbook.write(outputStream);
|
|
|
+ workbook.close();
|
|
|
+ ByteArrayResource resource = new ByteArrayResource(outputStream.toByteArray());
|
|
|
+
|
|
|
+ String fileName = "案卷目录.xlsx";
|
|
|
+ String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString())
|
|
|
+ .replaceAll("\\+", "%20");
|
|
|
+ return ResponseEntity.ok()
|
|
|
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename*=UTF-8''" + encodedFileName)
|
|
|
+ .contentType(MediaType.APPLICATION_OCTET_STREAM)
|
|
|
+ .contentLength(resource.contentLength())
|
|
|
+ .body(resource);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/fileNumberFlush")
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "档号整理——按档号排序")
|