From 6b7dfddb2325267574e84b375b9147a8b2c2bc02 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 16 Sep 2021 15:56:17 +0800
Subject: [PATCH] 新增考试缴费凭证批量上传

---
 src/main/java/org/springblade/common/config/FileConfig.java                       |   43 ++++
 src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml                |    2 
 src/main/java/org/springblade/modules/system/mapper/UserMapper.xml                |    7 
 src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java |   11 +
 src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java          |  125 +++++++++++++
 src/main/java/org/springblade/modules/apply/mapper/ExamPaymentMapper.xml          |   10 
 src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml    |    2 
 pom.xml                                                                           |   12 +
 src/main/java/org/springblade/common/utils/FileUtils.java                         |  187 ++++++++++++++++++++
 src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java    |   12 +
 src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java            |    7 
 src/main/java/org/springblade/modules/apply/vo/ExamPaymentVO.java                 |   11 +
 src/main/java/org/springblade/modules/exam/service/ExamPaperService.java          |    8 
 src/main/resources/application-dev.yml                                            |    9 +
 src/main/java/org/springblade/modules/apply/controller/ApplyController.java       |   11 -
 src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml             |   33 +++
 src/main/java/org/springblade/modules/apply/entity/Apply.java                     |    3 
 src/main/java/org/springblade/modules/system/mapper/UserMapper.java               |    8 
 src/main/java/org/springblade/modules/system/service/IUserService.java            |    7 
 src/main/resources/application.yml                                                |    2 
 20 files changed, 495 insertions(+), 15 deletions(-)

diff --git a/pom.xml b/pom.xml
index b6ae417..7bb6391 100644
--- a/pom.xml
+++ b/pom.xml
@@ -235,6 +235,18 @@
             <artifactId>javase</artifactId>
             <version>3.3.3</version>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j -->
+        <dependency>
+            <groupId>net.lingala.zip4j</groupId>
+            <artifactId>zip4j</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.springframework/spring-mock -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-mock</artifactId>
+            <version>2.0.8</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/src/main/java/org/springblade/common/config/FileConfig.java b/src/main/java/org/springblade/common/config/FileConfig.java
new file mode 100644
index 0000000..591bef9
--- /dev/null
+++ b/src/main/java/org/springblade/common/config/FileConfig.java
@@ -0,0 +1,43 @@
+package org.springblade.common.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+/**
+ *Jun 12, 2019
+ *
+ * FileConfig.java
+ */
+@ConfigurationProperties(prefix = "upload")
+@Component
+@Order
+public class FileConfig {
+
+	public static String localtion;
+	public static String maxFileSize;
+	public static String maxRequestSize;
+
+	/**
+	 * @param localtion the localtion to set
+	 */
+	public void setLocaltion(String localtion) {
+		FileConfig.localtion = localtion;
+	}
+
+	/**
+	 * @param maxFileSize the maxFileSize to set
+	 */
+	public void setMaxFileSize(String maxFileSize) {
+		FileConfig.maxFileSize = maxFileSize;
+	}
+
+	/**
+	 * @param maxRequestSize the maxRequestSize to set
+	 */
+	public void setMaxRequestSize(String maxRequestSize) {
+		FileConfig.maxRequestSize = maxRequestSize;
+	}
+
+
+}
diff --git a/src/main/java/org/springblade/common/utils/FileUtils.java b/src/main/java/org/springblade/common/utils/FileUtils.java
new file mode 100644
index 0000000..9fad9ad
--- /dev/null
+++ b/src/main/java/org/springblade/common/utils/FileUtils.java
@@ -0,0 +1,187 @@
+package org.springblade.common.utils;
+
+import net.lingala.zip4j.core.ZipFile;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.nio.channels.FileChannel;
+import java.util.List;
+
+public class FileUtils {
+
+	public static void clearFiles(String workspaceRootPath) {
+		File file = new File(workspaceRootPath);
+		deleteFile(file);
+	}
+
+	public static void deleteFile(File file) {
+		if (file.exists()) {
+			if (file.isDirectory()) {
+				File[] files = file.listFiles();
+				for (int i = 0; i < files.length; i++) {
+					deleteFile(files[i]);
+				}
+			}
+		}
+		file.delete();
+	}
+
+	public static void fileWrite(String str, String fileNamePath) throws IOException {
+		FileWriter writer = null;
+		try {
+			File file = new File(fileNamePath);
+			if (!file.getParentFile().exists()) {
+				file.getParentFile().mkdirs();
+				file.createNewFile();
+			}
+			writer = new FileWriter(file, true);
+			writer.write(str + System.getProperty("line.separator"));
+
+		} catch (IOException e) {
+		} finally {
+			if (writer != null) {
+				writer.close();
+			}
+		}
+	}
+
+
+	public static File mkFile(String fileName) {
+		File f = new File(fileName);
+		try {
+			if (f.exists()) {
+				f.delete();
+			}
+			f.createNewFile();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return f;
+	}
+
+
+	public static void copyDirAndFile(String oldPath, String newPath) throws IOException {
+		if (!(new File(newPath)).exists()) {
+			(new File(newPath)).mkdir();
+		}
+		File file = new File(oldPath);
+		//file name list
+		String[] filePaths = file.list();
+		for (String filePath : filePaths) {
+			String oldFullPath = oldPath + file.separator + filePath;
+			String newFullPath = newPath + file.separator + filePath;
+			File oldFile = new File(oldFullPath);
+			File newFile = new File(newFullPath);
+			if (oldFile.isDirectory()) {
+				copyDirAndFile(oldFullPath, newFullPath);
+			} else if (oldFile.isFile()) {
+				copyFile(oldFile, newFile);
+			}
+		}
+	}
+
+	public static void copyFile(File source, File dest) throws IOException {
+		FileChannel inputChannel = null;
+		FileChannel outputChannel = null;
+		try {
+			inputChannel = new FileInputStream(source).getChannel();
+			outputChannel = new FileOutputStream(dest).getChannel();
+			outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
+		} finally {
+			inputChannel.close();
+			outputChannel.close();
+		}
+	}
+
+	/**
+	 *
+	 * 解压zip 包
+	 * @author panchaoyuan
+	 * @param srcFile    Unzipped file
+	 * @param destDirPath   Unzipped destination folder
+	 * @throws RuntimeException
+	 * @throws IOException
+	 */
+	public static void unZip(MultipartFile  srcFile, String destDirPath,String savePath) throws RuntimeException, IOException {
+		File file = null;
+		InputStream ins = srcFile.getInputStream();
+		String savaPaths = savePath+srcFile.getOriginalFilename();
+		file=new File(savaPaths);
+		inputStreamToFile(ins, file);
+
+		if (!file.exists()) {
+			throw new RuntimeException(file.getPath() + ",file is not found");
+		}
+		ZipFile zipFile = null;
+		try {
+			zipFile = new ZipFile(file);
+//			zipFile.setFileNameCharset("utf-8");
+			zipFile.setFileNameCharset("gbk");
+			//解压到 destDirPath
+			zipFile.extractAll(destDirPath);
+		}catch(Exception e) {
+			throw new RuntimeException("unzip error from FileUtil", e);
+		}
+	}
+
+
+	/**
+	 * 输入流转换为文件
+	 * @author panchaoyuan
+	 * @return
+	 */
+	private static void inputStreamToFile(InputStream ins, File file) {
+		try {
+			OutputStream os = new FileOutputStream(file);
+			int bytesRead = 0;
+			byte[] buffer = new byte[8192];
+			while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
+				os.write(buffer, 0, bytesRead);
+			}
+			os.close();
+			ins.close();
+		}catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 获取解压出来的图片
+	 * @author arsn
+	 * @return
+	 */
+	public List<MultipartFile> getSubFiles(String  desFile,List<MultipartFile> fileList){
+		//取出图片数据遍历
+		File file = new File(desFile);
+		File[] files = file.listFiles();
+		for (File fileIndex : files) {
+			if (!fileIndex.exists()) {
+				throw new NullPointerException("Cannot find " + fileIndex);
+			} else if (fileIndex.isFile()) {
+				try {
+					//将 file 转换为 MultipartFile
+					File file1 = new File(desFile+File.separator + fileIndex.getName());
+					FileInputStream fileInputStream = new FileInputStream(file1);
+					MockMultipartFile mockMultipartFile = null;
+					try {
+						String name = fileIndex.getName();
+						mockMultipartFile = new MockMultipartFile(name,fileInputStream);
+					} catch (IOException e) {
+						e.printStackTrace();
+					}
+					fileList.add(mockMultipartFile);
+				} catch (FileNotFoundException e) {
+					e.printStackTrace();
+				}
+			} else {
+				if (fileIndex.isDirectory()) {
+					getSubFiles(fileIndex.getAbsolutePath(),fileList);
+				}
+			}
+		}
+		return fileList;
+	}
+
+
+}
diff --git a/src/main/java/org/springblade/modules/apply/controller/ApplyController.java b/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
index 2c15125..a42313f 100644
--- a/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
+++ b/src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -107,17 +107,6 @@
 	 */
 	@PostMapping("/submit")
 	public R submit(@RequestBody Apply apply) {
-		if (null==apply.getId()){
-			//去生成准考证号码
-			apply.setCandidateNo(getCandidateNo(apply));
-			//去生成考试编号
-			apply.setApplyCode(getApplyCode(apply));
-			//默认通过
-			apply.setApplyStatus(2);
-			//默认为未考试状态
-			apply.setIsExam(1);
-			apply.setApplyTime(new Date());
-		}
 		return R.status(applyService.saveOrUpdate(apply));
 	}
 
diff --git a/src/main/java/org/springblade/modules/apply/entity/Apply.java b/src/main/java/org/springblade/modules/apply/entity/Apply.java
index b07fa44..69d17b2 100644
--- a/src/main/java/org/springblade/modules/apply/entity/Apply.java
+++ b/src/main/java/org/springblade/modules/apply/entity/Apply.java
@@ -178,4 +178,7 @@
 	 */
 	@TableField("is_exam")
 	private Integer isExam;
+
+	@TableField("audit_status")
+	private Integer auditStatus;
 }
diff --git a/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml b/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
index 6f5b18d..ea19ee5 100644
--- a/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
+++ b/src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
@@ -6,7 +6,7 @@
     <select id="selectApplyPage" resultType="org.springblade.modules.apply.vo.ApplyVO">
         SELECT
         sa.id,sa.apply_status applyStatus,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
-        sa.examination_type examinationType,sa.examination_mx examinationMx,
+        sa.examination_type examinationType,sa.examination_mx examinationMx,sa.audit_status auditStatus,
         ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
         bu.real_name realName,bu.is_apply isApply,
         bd.dept_name deptName,bu.cardid idCardNo,"保安证" applyCard
diff --git a/src/main/java/org/springblade/modules/apply/mapper/ExamPaymentMapper.xml b/src/main/java/org/springblade/modules/apply/mapper/ExamPaymentMapper.xml
index dd346c7..c382785 100644
--- a/src/main/java/org/springblade/modules/apply/mapper/ExamPaymentMapper.xml
+++ b/src/main/java/org/springblade/modules/apply/mapper/ExamPaymentMapper.xml
@@ -7,7 +7,8 @@
         SELECT
         se.*,
         bu.real_name realName,bu.cardid idCardNo,bu.sex,bu.phone,
-        bd.dept_name deptName
+        bd.dept_name deptName,
+        sa.apply_time applyTime,"保安员证" as paperType
         FROM
         sys_exam_payment se
         left join
@@ -18,8 +19,13 @@
         blade_dept bd
         on
         bd.id = bu.dept_id
+        left join
+        sys_apply sa
+        on
+        sa.user_id = se.worker_id
         WHERE
-        type = 1
+        1=1
+        and sa.apply_status = 2
         <if test="examPayment.workerId!=null and  examPayment.workerId!=''">
             and se.worker_id like concat('%', #{examPayment.workerId},'%')
         </if>
diff --git a/src/main/java/org/springblade/modules/apply/vo/ExamPaymentVO.java b/src/main/java/org/springblade/modules/apply/vo/ExamPaymentVO.java
index d07bc24..653dc4e 100644
--- a/src/main/java/org/springblade/modules/apply/vo/ExamPaymentVO.java
+++ b/src/main/java/org/springblade/modules/apply/vo/ExamPaymentVO.java
@@ -22,6 +22,7 @@
 import org.springblade.modules.apply.entity.ExamPayment;
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * 考试缴费实体类
@@ -64,4 +65,14 @@
 	 */
 	private String phone;
 
+	/**
+	 * 报名时间
+	 */
+	private Date applyTime;
+
+	/**
+	 * 考试证件类型
+	 */
+	private String paperType;
+
 }
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
index f0280b0..84b00a1 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
@@ -19,6 +19,7 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.springblade.modules.apply.entity.Apply;
 import org.springblade.modules.exam.entity.ExamPaper;
 import org.springblade.modules.exam.vo.ExamPaperSubjectVO;
 import org.springblade.modules.exam.vo.ExamPaperVO;
@@ -47,4 +48,10 @@
 	List<ExamPaper> selectExamPaperPageTree(@Param("paper") ExamPaper examPaper);
 
 	boolean UnbindSubject(String paperid, String subjectid);
+	/**
+	 * 根据用户id查询报名信息
+	 * @param userId 用户id
+	 * @return
+	 */
+	List<Apply> getApplyDetail(@Param("userId")String userId);
 }
diff --git a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
index 614c318..c2f675f 100644
--- a/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
+++ b/src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -99,4 +99,37 @@
        delete from exam_examination_subject where examination_id = #{paperid} and subject_id = #{subjectid}
     </delete>
 
+    <!--根据用户id查询报名信息-->
+    <select id="getApplyDetail" resultType="org.springblade.modules.apply.entity.Apply">
+        (select
+            sa.id as id
+        from
+            sys_apply sa
+        left join
+            blade_user bu
+        on
+            bu.id = sa.user_id
+        where sa.user_id = #{userId}
+        and is_apply = 1
+        and is_exam = 1
+        and sa.apply_status = 2
+        )
+
+        union all
+
+        (select
+            str.id as id
+        from
+            sys_training_registration str
+        left join
+            blade_user bu
+        on
+            bu.id = str.user_id
+        where str.user_id = #{userId}
+        and bu.is_train = 1
+        and is_exam = 1
+        and str.cancel = 1
+        )
+    </select>
+
 </mapper>
diff --git a/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java b/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
index edf0146..f9647fd 100644
--- a/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
+++ b/src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
@@ -18,6 +18,7 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.modules.apply.entity.Apply;
 import org.springblade.modules.exam.entity.ExamPaper;
 import org.springblade.modules.exam.vo.ExamPaperSubjectVO;
 import org.springblade.modules.exam.vo.ExamPaperVO;
@@ -54,4 +55,11 @@
 	 * 解除试卷和题目的绑定
 	 */
 	boolean UnbindSubject(String paperid,String subjectid);
+
+	/**
+	 * 根据用户id查询报名信息
+	 * @param userId 用户id
+	 * @return
+	 */
+	List<Apply> getApplyDetail(String userId);
 }
diff --git a/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java b/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
index 83fa6c1..504dc7e 100644
--- a/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
@@ -18,6 +18,7 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.apply.entity.Apply;
 import org.springblade.modules.exam.entity.ExamPaper;
 import org.springblade.modules.exam.mapper.ExamPaperMapper;
 import org.springblade.modules.exam.service.ExamPaperService;
@@ -69,4 +70,14 @@
 		return baseMapper.UnbindSubject(paperid,subjectid);
 	}
 
+	/**
+	 * 根据用户id查询报名信息
+	 * @param userId 用户id
+	 * @return
+	 */
+	@Override
+	public List<Apply> getApplyDetail(String userId) {
+		return baseMapper.getApplyDetail(userId);
+	}
+
 }
diff --git a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
index c28d6e5..7967fe8 100644
--- a/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
+++ b/src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -1856,7 +1856,7 @@
         on
         si.jurisdiction = sj.id
         where 1=1
-        and (stats = 2 or stats = 4)
+        and (stats = 0 or stats = 1 or stats = 2 or stats = 4)
         <if test="information.jurisdiction!=null and information.jurisdiction!=''">
             and (sj.id = #{information.jurisdiction} or sj.parent_id =  #{information.jurisdiction})
         </if>
diff --git a/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java b/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
index 8746724..600920d 100644
--- a/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
+++ b/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -16,9 +16,12 @@
  */
 package org.springblade.modules.resource.endpoint;
 
+import io.minio.*;
 import io.swagger.annotations.Api;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
+import org.springblade.common.config.FileConfig;
+import org.springblade.common.utils.FileUtils;
 import org.springblade.core.launch.constant.AppConstant;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.oss.model.OssFile;
@@ -28,11 +31,27 @@
 import org.springblade.core.tool.constant.RoleConstant;
 import org.springblade.core.tool.utils.FileUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.FTP.FtpUtil;
+import org.springblade.modules.apply.entity.Apply;
+import org.springblade.modules.apply.entity.ExamPayment;
+import org.springblade.modules.apply.service.ExamPaymentService;
+import org.springblade.modules.exam.service.ExamPaperService;
 import org.springblade.modules.resource.builder.oss.OssBuilder;
 import org.springblade.modules.resource.entity.Attach;
 import org.springblade.modules.resource.service.IAttachService;
+import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IUserService;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Pattern;
+
+import static org.springblade.common.constant.FtpConstant.*;
+import static org.springblade.common.constant.FtpConstant.ftpPath;
 
 /**
  * 对象存储端点
@@ -55,6 +74,13 @@
 	 * 附件表服务
 	 */
 	private final IAttachService attachService;
+
+	private final IUserService userService;
+
+
+	private final ExamPaperService examPaperService;
+
+	private final ExamPaymentService examPaymentService;
 
 	/**
 	 * 创建存储桶
@@ -249,4 +275,103 @@
 		return R.success("操作成功");
 	}
 
+
+	/**
+	 * 文件上传,zip , 缴费凭证
+	 *
+	 * @param file 图片对象
+	 */
+	@PostMapping("put-file-exam-payment-zip")
+	public R putFileExamPaymentZip(@RequestParam MultipartFile file) throws Exception {
+		Map<String, Object> map = new HashMap<>(1);
+		//填写你文件上传的地址以及相应信息
+		String url = "http://223.82.109.183:2081";
+		String access = "zhbaadmin";
+		String secret = "zhbapassword";
+		String bucket = "zhba";
+		MinioClient minioClient =
+			MinioClient.builder()
+				.endpoint(url)
+				.credentials(access, secret)
+				.build();
+		// 检查存储桶是否已经存在
+		boolean isExist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucket).build());
+		if (!isExist) {
+			// 创建一个名为zip的存储桶,用于zip文件。
+			minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucket).build());
+			minioClient.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).build());
+		}
+		String fileName = file.getOriginalFilename();
+		String namePath = fileName.substring(0,fileName.lastIndexOf("."));
+		String fileType = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(Locale.US);
+		//判断文件是不是zip类型
+		if(!fileType.equals("zip")){
+			map.put("data","上传文件类型不符!");
+			return R.data(map);
+		}
+		//FileConfig.localtion是配置文件和config类生产的,测试demo可以直接把FileConfig.localtion替换成D:/test
+		String uuid = UUID.randomUUID().toString();
+		String desPath = FileConfig.localtion + File.separator + uuid.replaceAll("-", "");
+		//遗漏了这个代码,在本地测试环境不会出问题,在服务器上一定会报没有找到文件的错误
+		String savePath = FileConfig.localtion + File.separator;
+		FileUtils fileUtil = new FileUtils();
+		//解压zip文件
+		FileUtils.unZip(file, desPath,savePath);
+
+		List<MultipartFile> fileList = new ArrayList<>();
+		//获取图片文件
+		fileList = fileUtil.getSubFiles(desPath+File.separator+namePath,fileList);
+		for (MultipartFile multipartFile : fileList){
+			if(multipartFile.getName().toLowerCase().endsWith(".png") || multipartFile.getName().toLowerCase().endsWith(".jpg")) {
+				String newName = "upload/picture/" + UUID.randomUUID().toString().replaceAll("-", "") + multipartFile.getName().substring(multipartFile.getName().lastIndexOf("."));
+				InputStream in = multipartFile.getInputStream();
+				String[] split = newName.split("/");
+				//创建头部信息
+				Map<String, String> headers = new HashMap<>(1 << 2);
+				//添加自定义内容类型
+				headers.put("Content-Type", "application/octet-stream");
+				//上传
+				minioClient.putObject(
+					PutObjectArgs.builder().bucket(bucket).object(newName).stream(
+						in, in.available(), -1)
+						.headers(headers)
+						.build());
+
+				String urls = "http://223.82.109.183:2081/zhba/" + newName;
+
+				//取出身份证号,查询用户信息,更新用户信息
+				String pictrueName = multipartFile.getName().substring(0, multipartFile.getName().lastIndexOf("."));
+//				String regex ="([1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx])|([1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3})";
+				String regex ="[\u4e00-\u9fa5]";
+				Pattern compile = Pattern.compile(regex);
+				String idCardNo = compile.matcher(pictrueName).replaceAll("");
+				User user = userService.getUserInfoByIdCardNo(idCardNo);
+				//设置用户头像url
+				if (null!=user){
+					ExamPayment examPayment = new ExamPayment();
+					examPayment.setWorkerId(user.getId().toString());
+					examPayment.setCertificateUrl(urls);
+					examPayment.setType(1L);
+					examPayment.setPaymentStatus(1);
+					examPayment.setPaymentTime(new Date());
+					//查询当前人员的报名信息
+					List<Apply> applyList = examPaperService.getApplyDetail(user.getId().toString());
+					//有且只有一条信息
+					if (applyList.size()==1){
+						examPayment.setApplyCode(applyList.get(0).getId().toString());
+					}
+					//新增
+					examPaymentService.save(examPayment);
+				}
+			}
+		}
+		//最后要删除文件
+		FileUtils.clearFiles(FileConfig.localtion + File.separator + file.getOriginalFilename());
+		FileUtils.clearFiles(desPath);
+		//数据封装
+		map.put("data", "上传成功!");
+		//返回
+		return R.data(map);
+	}
+
 }
diff --git a/src/main/java/org/springblade/modules/system/mapper/UserMapper.java b/src/main/java/org/springblade/modules/system/mapper/UserMapper.java
index 5b9fb97..fa34f18 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.java
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -99,4 +99,12 @@
 	 * @return
 	 */
     UserVO getUserInfoBySecurityNumber(@Param("securityNumber") String securityNumber);
+
+
+	/**
+	 * 通过 身份证号查询用户信息
+	 * @param idCardNo 身份证号
+	 * @return
+	 */
+	User getUserInfoByIdCardNo(String idCardNo);
 }
diff --git a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
index 6e83a77..f22d648 100644
--- a/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -317,4 +317,11 @@
         where securitynumber = #{securityNumber}
     </select>
 
+    <!--通过 身份证号查询用户信息-->
+    <select id="getUserInfoByIdCardNo" resultType="org.springblade.modules.system.entity.User">
+        SELECT id, name, real_name RealName
+        FROM blade_user
+        where cardid = #{param1}
+    </select>
+
 </mapper>
diff --git a/src/main/java/org/springblade/modules/system/service/IUserService.java b/src/main/java/org/springblade/modules/system/service/IUserService.java
index fc500b5..eb46f17 100644
--- a/src/main/java/org/springblade/modules/system/service/IUserService.java
+++ b/src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -239,4 +239,11 @@
 	 * @return
 	 */
     UserVO getUserInfoBySecurityNumber(String securityNumber);
+
+	/**
+	 * 根据身份证号查询用户信息
+	 * @param idCardNo
+	 * @return
+	 */
+	User getUserInfoByIdCardNo(String idCardNo);
 }
diff --git a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
index f7d0e48..b6e9c08 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -474,4 +474,16 @@
 	public UserVO getUserInfoBySecurityNumber(String securityNumber) {
 		return baseMapper.getUserInfoBySecurityNumber(securityNumber);
 	}
+
+
+	/**
+	 * 通过 身份证号查询用户信息
+	 *
+	 * @param idCardNo 身份证号
+	 * @return
+	 */
+	@Override
+	public User getUserInfoByIdCardNo(String idCardNo) {
+		return baseMapper.getUserInfoByIdCardNo(idCardNo);
+	}
 }
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index f276099..73cbffc 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -27,6 +27,15 @@
 #    username: root
 #    password: zhba0728
 
+#图片批量上传zip
+upload:
+  #服务器地址
+#  localtion: ${UPLOAD_DIR:/home/zhongsong/anbao}
+  # 本地地址
+  localtion: ${UPLOAD_DIR:D:/test}
+  maxFileSize: 10240KB
+  maxRequestSize: 102400KB
+
     # PostgreSQL
     #url: jdbc:postgresql://127.0.0.1:5432/bladex_boot
     #username: postgres
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index cd67429..ffd2079 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -189,6 +189,7 @@
     skip-url:
       - /blade-chat/weixin
       - /blade-desk/notice/submit
+
   #安全框架配置
   secure:
     #接口放行
@@ -203,6 +204,7 @@
       - /examPayment/**
       - /apply/**
       - /investigate/**
+      - /blade-resource/oss/endpoint/put-file-exam-payment-zip
     #授权认证配置
     auth:
       - method: ALL

--
Gitblit v1.9.3