Quellcode durchsuchen

Merge branch 'master' of http://47.110.251.215:3000/java_org/bladex

# Conflicts:
#	blade-service/blade-archive/src/main/java/org/springblade/archive/utils/FileUtils.java
huangtf vor 2 Jahren
Ursprung
Commit
aea64a7f37

+ 27 - 0
blade-common/src/main/java/org/springblade/common/utils/FileUtils.java

@@ -1,10 +1,16 @@
 package org.springblade.common.utils;
 
+import lombok.SneakyThrows;
+import org.springblade.common.vo.FileSize;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Objects;
 
 public class FileUtils  {
@@ -31,4 +37,25 @@ public class FileUtils  {
         return convertFile;
     }
 
+    //获取文件大小
+    public static List<FileSize> getOssFileSize(List<String> fileList){
+        List<FileSize> reData =new ArrayList<>();
+        if(fileList!=null){
+            for(String fileUrl:fileList){
+                FileSize file =new FileSize();
+                file.setFileUrl(fileUrl);
+                try {
+                    URLConnection  openConnection = new URL(fileUrl).openConnection();
+                    int contentLength = openConnection.getContentLength();
+                    Double fileLength = Double.parseDouble(contentLength+"");
+                    file.setFileSize(Math.ceil(fileLength/1024));
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+                reData.add(file);
+            }
+        }
+        return  reData;
+    }
+
 }

+ 11 - 0
blade-common/src/main/java/org/springblade/common/vo/FileSize.java

@@ -0,0 +1,11 @@
+package org.springblade.common.vo;
+
+import lombok.Data;
+
+@Data
+public class FileSize {
+
+    private String fileUrl;
+
+    private double fileSize;
+}

+ 21 - 0
blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/vo/ArchivesAutoVO.java

@@ -59,12 +59,16 @@ public class ArchivesAutoVO extends ArchivesAuto {
 	@ApiModelProperty("年")
 	private String year;
 
+	private List<String> years;
+
 	/**
 	 * 年
 	 */
 	@ApiModelProperty("月")
 	private String month;
 
+	private List<String> months;
+
 	/**
 	 * 输入框查询条件
 	 */
@@ -84,11 +88,26 @@ public class ArchivesAutoVO extends ArchivesAuto {
 	 */
 	private String secretLevelValue;
 
+	/**
+	 * 搜索密级集合
+	 */
+	private List<String> secretLevels;
+
 	/**
 	 * 保管期限(单位/年)
 	 */
 	private String storageTimeValue;
 
+	/**
+	 * 搜索期限集合
+	 */
+	private List<String> storageTimes;
+
+	/**
+	 * 搜索类别集合
+	 */
+	private List<String> carrierTypes;
+
 	@ApiModelProperty("批量保存")
 	private List<ArchivesAutoVO> list;
 	/**
@@ -152,5 +171,7 @@ public class ArchivesAutoVO extends ArchivesAuto {
 		 * 责任者
 		 */
 		private String dutyUser;
+
+		private  String archiveId;
 	}
 }

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ExcelEditCallback.java

@@ -15,7 +15,7 @@ public class ExcelEditCallback {
     private Integer status;
 
     // excel 的唯一标识
-    private Long key;
+    private String key;
 
     // 返回码
     private Integer error;

+ 2 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.java

@@ -56,4 +56,6 @@ public interface ArchivesAutoMapper extends BaseMapper<ArchivesAuto> {
 	 *  根据项目id获取所有档案
 	 */
 	List<ArchivesAutoDTO> getListByProjectId(@Param("projectId") Long projectId);
+
+    List<ArchivesAuto> pageByArchivesAuto(IPage page, @Param("vo") ArchivesAutoVO vo);
 }

+ 55 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="org.springblade.archive.mapper.ArchivesAutoMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="archivesAutoResultMap" type="org.springblade.archive.entity.ArchivesAuto">
+    <resultMap id="archivesAutoResultMap" type="org.springblade.archive.vo.ArchivesAutoVO">
         <result column="id" property="id"/>
         <result column="create_user" property="createUser"/>
         <result column="create_dept" property="createDept"/>
@@ -47,8 +47,18 @@
         <result column="is_auto_file" property="isAutoFile"/>
         <result column="auto_file_sort" property="autoFileSort"/>
         <result column="filing_unit" property="filingUnit"/>
+        <collection property="approvalFileList" javaType="java.util.List"
+                    select="approvalFile"
+                    column="{archiveId=id}">
+        </collection>
     </resultMap>
 
+    <select id="approvalFile" resultType="org.springblade.archive.vo.ArchivesAutoVO$ApprovalFile">
+        <if test="archiveId!=null">
+            select * from u_archive_file where archive_id = #{archiveId}
+        </if>
+    </select>
+
 
     <select id="selectArchivesAutoPage" resultMap="archivesAutoResultMap">
         select * from u_archives_auto where is_deleted = 0
@@ -124,6 +134,50 @@
         from u_archives_auto
         where project_id=#{projectId};
     </select>
+    <select id="pageByArchivesAuto" resultMap="archivesAutoResultMap">
+        select uaa.* from u_archives_auto uaa left join u_archive_file uaf on uaa.id = uaf.archive_id
+        where uaa.is_deleted = 0
+        <if test="vo.projectId != null and vo.projectId != ''">
+            and uaa.project_id = #{vo.projectId}
+        </if>
+        <if test="vo.searchType == 1 and vo.queryValue != null and vo.queryValue != ''">
+            and uaa.name like concat('%',#{vo.queryValue},'%')
+        </if>
+        <if test="vo.searchType == 2 and vo.queryValue != null and vo.queryValue != ''">
+            and uaf.file_name like concat('%',#{vo.queryValue},'%')
+        </if>
+        <if test="vo.storageTimes != null and vo.storageTimes != ''">
+            and uaa.storage_time in
+            <foreach collection="vo.storageTimes" item="storageTime" open="(" separator="," close=")">
+                #{storageTime}
+            </foreach>
+        </if>
+        <if test="vo.secretLevels != null and vo.secretLevels != ''">
+            and uaa.secret_level in
+            <foreach collection="vo.secretLevels" item="secretLevel" open="(" separator="," close=")">
+                #{secretLevel}
+            </foreach>
+        </if>
+        <if test="vo.carrierTypes != null and vo.carrierTypes != ''">
+            and uaa.carrier_type in
+            <foreach collection="vo.carrierTypes" item="carrierType" open="(" separator="," close=")">
+                #{carrierType}
+            </foreach>
+        </if>
+        <if test="vo.years != null and vo.years != ''">
+            and
+            <foreach collection="vo.years" item="year" separator=" or" open="(" close=")" >
+                #{year} BETWEEN  DATE_FORMAT(uaa.start_date,'%Y') and DATE_FORMAT(uaa.end_date ,'%Y')
+            </foreach>
+        </if>
+        <if test="vo.months != null and vo.months != ''">
+            and
+            <foreach collection="vo.months" item="month" separator=" or" open="(" close=")">
+                #{month} BETWEEN  DATE_FORMAT(uaa.start_date,'%c') and DATE_FORMAT(uaa.end_date ,'%c')
+            </foreach>
+        </if>
+        GROUP BY uaa.id
+    </select>
 
 
 </mapper>

+ 15 - 56
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -69,64 +69,23 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 
 	@Override
 	public IPage<ArchivesAuto> pageByArchivesAuto(ArchivesAutoVO vo) {
-		IPage<ArchivesAuto> page = new Page<>(vo.getCurrent(),vo.getSize());
-		LambdaQueryWrapper<ArchivesAuto> lqw = new LambdaQueryWrapper<>();
-		lqw.eq(ArchivesAuto::getProjectId,vo.getProjectId());
-		//过滤日期
-		if (StringUtils.isNotBlank(vo.getYear())){
-			if (StringUtils.isNotBlank(vo.getMonth())){
-				int day;
-				if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(vo.getMonth())){
-					day = 31;
-				}else if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(vo.getMonth())){
-					day = 30;
-				}else {
-					if (Integer.parseInt(vo.getYear()) % 4 == 0){
-						day = 29;
-					}else {
-						day = 28;
-					}
-				}
-				lqw.ge(ArchivesAuto::getStartDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), Integer.parseInt(vo.getMonth()), 1, 0, 0, 0));
-				lqw.le(ArchivesAuto::getEndDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), Integer.parseInt(vo.getMonth()), day, 0, 0, 0));
-			}else {
-				lqw.ge(ArchivesAuto::getStartDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), 1, 1, 0, 0, 0));
-				lqw.ge(ArchivesAuto::getEndDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), 12, 31, 0, 0, 0));
-			}
-		}else if (StringUtils.isNotBlank(vo.getMonth())){
-			throw new RuntimeException("请选择年");
+		IPage<ArchivesAuto> page = new Page<>();
+		if (StringUtils.isNotBlank(vo.getStorageTime())) {
+			vo.setStorageTimes(Arrays.asList(vo.getStorageTime().split(",")));
 		}
-		lqw.eq(StringUtils.isNotBlank(vo.getStorageTime()),ArchivesAuto::getStorageTime,vo.getStorageTime())
-				.eq(StringUtils.isNotBlank(vo.getSecretLevel()),ArchivesAuto::getSecretLevel,vo.getSecretLevel())
-					.eq(StringUtils.isNotBlank(vo.getCarrierType()),ArchivesAuto::getCarrierType,vo.getCarrierType());
-		//按案卷搜索完成,判断是否按文件搜索
-		if (vo.getSearchType() == 1){
-			lqw.like(StringUtils.isNotBlank(vo.getQueryValue()),ArchivesAuto::getName,vo.getQueryValue());
-			this.page(page,lqw);
-			return page;
-		}else {
-			List<ArchivesAuto> list = this.list(lqw);
-			list = list.stream().filter(auto -> {
-				List<ArchiveFile> files = archiveFileClient.getArchiveFileByArchivesId(auto.getId() + "", "");
-				if (files != null && files.size() > 0){
-					files = files.stream().filter(file->file.getFileName().contains(vo.getQueryValue())).collect(Collectors.toList());
-				}
-				if (files != null && files.size() > 0){
-					return true;
-				}else {
-					return false;
-				}
-			}).collect(Collectors.toList());
-			if (list != null && list.size() > 0){
-				List<Long> ids = list.stream().map(l -> l.getId()).collect(Collectors.toList());
-				this.page(page,new LambdaQueryWrapper<ArchivesAuto>().in(ArchivesAuto::getId,ids));
-				return page;
-			}else {
-				return  null;
-			}
-
+		if (StringUtils.isNotBlank(vo.getSecretLevel())){
+			vo.setSecretLevels(Arrays.asList(vo.getSecretLevel().split(",")));
 		}
-
+		if (StringUtils.isNotBlank(vo.getCarrierType())) {
+			vo.setCarrierTypes(Arrays.asList(vo.getCarrierType().split(",")));
+		}
+		if (StringUtils.isNotBlank(vo.getYear())) {
+			vo.setYears(Arrays.asList(vo.getYear().split(",")));
+		}
+		if (StringUtils.isNotBlank(vo.getMonth())) {
+			vo.setMonths(Arrays.asList(vo.getMonth().split(",")));
+		}
+		return page.setRecords(baseMapper.pageByArchivesAuto(page,vo));
 	}
 
 	@Override

+ 5 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArTreeContractInitServiceImpl.java

@@ -629,6 +629,11 @@ public class ArTreeContractInitServiceImpl {
      */
     public void getMap(List<ArchiveTreeContractVO2> vos,List<ArchiveTreeContract> addList,Map<Long,ArchiveTreeContractVO2> vo2Map){
 
+        if(vo2Map==null){
+            vo2Map=new HashMap<>();
+        }
+
+
         for (ArchiveTreeContractVO2 ar:vos) {
             vo2Map.put(ar.getId(),ar);
         }

+ 20 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -68,6 +68,7 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
 
 import java.io.*;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.*;
@@ -516,28 +517,41 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             try {
                 //获取onlyOffice缓存中的文件流
                 URL url = new URL(downloadUri);
+                String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                String filecode = SnowFlakeUtil.getId() + "";
+                String dataUrl=file_path + "/excel/" + filecode + ".pdf";
                 java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
+                connection.setRequestMethod("GET");
+                connection.setConnectTimeout(5 * 1000);
                 InputStream inputStream = connection.getInputStream();
                 if (inputStream == null) {
                     throw new Exception("文件为空");
                 }
-                Long tabId = callback.getKey();
+                String tabId = callback.getKey();
                 if (tabId == null) {
                     throw new Exception("excel为空");
+                }else{
+                    tabId = tabId.substring(0,tabId.lastIndexOf("_"));
                 }
                 //获取数据库信息
-                ExcelTab excelTab = baseMapper.selectById(tabId);
+                ExcelTab excelTab = baseMapper.selectById(Long.parseLong(tabId));
                 //上传新文件到文件服务器
                 byte[] officeByte = IoUtil.readToByteArray(inputStream);
-                BladeFile bladeFile = this.newIOSSClient.updateFile(officeByte, excelTab.getExtension());
-                //修改本地数据信息
-                excelTab.setFileUrl(bladeFile.getLink());
+
+                FileOutputStream fs = new FileOutputStream(dataUrl);
+                fs.write(officeByte);
+                fs.flush();
+                BladeFile bladeFile = newIOSSClient.uploadFile(excelTab.getExtension(), dataUrl);
                 //获取文件大小
                 int size = connection.getContentLength() / 1024 / 1024; //单位M
                 excelTab.setAttachSize(Long.parseLong(size + ""));
                 excelTab.setStatus(3);
+                excelTab.setFileUrl(bladeFile.getLink());
                 baseMapper.updateById(excelTab);
-                connection.disconnect();
+                File file = new File(dataUrl);
+                if(file.exists()){
+                    file.delete();
+                }
                 System.out.println("123456");
             } catch (Exception e) {
                 editCallback.setError(1);