|
@@ -1,16 +1,101 @@
|
|
|
package org.springblade.archive.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.archive.config.sqliteConfig;
|
|
|
+import org.springblade.archive.dto.ArchivesAutoDTO;
|
|
|
import org.springblade.archive.entity.ArchiveOfflineVersionInfo;
|
|
|
+import org.springblade.archive.entity.ArchivesAuto;
|
|
|
import org.springblade.archive.mapper.ArchiveOfflineVersionInfoMapper;
|
|
|
+import org.springblade.archive.mapper.ArchivesAutoMapper;
|
|
|
import org.springblade.archive.service.IArchiveOfflineVersionInfoService;
|
|
|
+import org.springblade.archive.service.IArchivesAutoService;
|
|
|
+import org.springblade.archive.utils.FileUtils;
|
|
|
+import org.springblade.business.entity.ArchiveFile;
|
|
|
+import org.springblade.business.feign.ArchiveFileClient;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @Param
|
|
|
* @Author wangwl
|
|
|
* @Date 2023/3/31 10:09
|
|
|
**/
|
|
|
@Service
|
|
|
+@AllArgsConstructor
|
|
|
public class ArchiveOfflineVersionInfoServiceImpl extends BaseServiceImpl<ArchiveOfflineVersionInfoMapper, ArchiveOfflineVersionInfo> implements IArchiveOfflineVersionInfoService {
|
|
|
+ private final sqliteConfig data;
|
|
|
+ private final ArchivesAutoMapper autoMapper;
|
|
|
+ private final ArchiveFileClient fileClient;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void packData(Long projectId) {
|
|
|
+ List<ArchivesAutoDTO> list = autoMapper.getListByProjectId(projectId);
|
|
|
+ String localUrl = "D:\\develop\\aliyun\\";
|
|
|
+ //拼接档案里文件的pdf设置allPdf
|
|
|
+ for (ArchivesAutoDTO dto : list) {
|
|
|
+ List<ArchiveFile> files = fileClient.getArchiveFileByArchivesId(dto.getId()+"","");
|
|
|
+ if (files != null && files.size() >0){
|
|
|
+ List<String> urlList = new ArrayList<>();
|
|
|
+ for (ArchiveFile file : files) {
|
|
|
+ if (StringUtil.isNotBlank(file.getPdfFileUrl())){
|
|
|
+ urlList.add(file.getPdfFileUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (urlList.size() > 0){
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ FileUtils.mergePdfPublicMethods(urlList,localUrl+id+".pdf");
|
|
|
+ dto.setAllFilePdf(localUrl+id+".pdf");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Connection conn = data.dataSource().getConnection();
|
|
|
+ //获取执行对象
|
|
|
+ String sql = "INSERT INTO u_archives_auto (id, project_id, name, file_number, unit,storage_time, is_archive,node_id, status, is_deleted,create_time,all_file_pdf)" +
|
|
|
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
+ PreparedStatement pstm = conn.prepareStatement(sql);
|
|
|
+ //pstm 绑定数据
|
|
|
+ int i=0;
|
|
|
+ for (ArchivesAutoDTO auto : list) {
|
|
|
+ i++;
|
|
|
+ pstm.setLong(1,auto.getId());
|
|
|
+ pstm.setLong(2,auto.getProjectId());
|
|
|
+ pstm.setString(3,auto.getName());
|
|
|
+ pstm.setString(4,auto.getFileNumber());
|
|
|
+ pstm.setString(5,auto.getUnit());
|
|
|
+ pstm.setString(6,auto.getStorageTime());
|
|
|
+ pstm.setInt(7,auto.getIsArchive()==null?0:1);
|
|
|
+ pstm.setLong(8,auto.getNodeId());
|
|
|
+ pstm.setInt(9,auto.getStatus());
|
|
|
+ pstm.setInt(10,auto.getIsDeleted());
|
|
|
+ pstm.setString(11, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(auto.getCreateTime()));
|
|
|
+ pstm.setString(12,auto.getAllFilePdf()==null?"":auto.getAllFilePdf());
|
|
|
+
|
|
|
+ //添加批处理
|
|
|
+ pstm.addBatch();
|
|
|
+ if (i % 1000 == 0) {
|
|
|
+ pstm.executeBatch();
|
|
|
+ pstm.clearBatch();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //将批处理余下的语句执行完毕
|
|
|
+ pstm.executeBatch();
|
|
|
+ //释放资源
|
|
|
+ pstm.close();
|
|
|
+ conn.close();
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|