|
@@ -1,9 +1,13 @@
|
|
|
package thyyxxk.webserver.service.technologyArchives;
|
|
|
|
|
|
+import cn.hutool.core.io.file.FileNameUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.technologyArchives.TechnologyArchives10Dao;
|
|
|
import thyyxxk.webserver.dao.his.technologyArchives.TechnologyArchives11Dao;
|
|
@@ -50,12 +54,12 @@ import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
import thyyxxk.webserver.utils.StringUtil;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -271,6 +275,47 @@ public class TechnologyArchivesService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //职称证书图片
|
|
|
+ @Value("${is-prod}")
|
|
|
+ private boolean isProd;
|
|
|
+
|
|
|
+ public ResultVo<JSONObject> putCertificateImage(MultipartFile file, String socialNo) {
|
|
|
+
|
|
|
+ String uploadDir;
|
|
|
+ if (isProd) {
|
|
|
+ uploadDir = "/home/certificateImage";
|
|
|
+ } else {
|
|
|
+ uploadDir = "E:\\certificateImage";
|
|
|
+ }
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+
|
|
|
+ String name = file.getOriginalFilename();
|
|
|
+ String fileName = null;
|
|
|
+ if (name != null) {
|
|
|
+ String newName = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
+ fileName = newName.substring(0,5)+name.substring(name.lastIndexOf("."));
|
|
|
+ }
|
|
|
+ Path uploadPath = Paths.get(uploadDir);
|
|
|
+
|
|
|
+ try {
|
|
|
+ Files.createDirectories(uploadPath);
|
|
|
+ Path filePath = null;
|
|
|
+ if (fileName != null) {
|
|
|
+ filePath = uploadPath.resolve(fileName);
|
|
|
+ }
|
|
|
+ Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
+ log.info("文件:{}, socialNo:{}", file.getName(), socialNo);
|
|
|
+ String url = "http://172.16.30.8:8077/certificateImage/" + fileName;
|
|
|
+ int num =firstDao.updateCertificateImage(socialNo,url);
|
|
|
+ js.put("url", url);
|
|
|
+ js.put("name", fileName);
|
|
|
+ return ResultVoUtil.success(js);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("上传错误:{}", e.getMessage());
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "上传错误请重新上传。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Description 根据身份证号,批准时间删除专业技术职称晋升情况
|
|
|
* @Author hsh
|
|
@@ -345,6 +390,44 @@ public class TechnologyArchivesService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //其他证书图片
|
|
|
+ public ResultVo<JSONObject> putProImage(MultipartFile file, String socialNo) {
|
|
|
+
|
|
|
+ String uploadDir;
|
|
|
+ if (isProd) {
|
|
|
+ uploadDir = "/home/proImage";
|
|
|
+ } else {
|
|
|
+ uploadDir = "E:\\proImage";
|
|
|
+ }
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+
|
|
|
+ String name = file.getOriginalFilename();
|
|
|
+ String fileName = null;
|
|
|
+ if (name != null) {
|
|
|
+ String newName = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
+ fileName = newName.substring(0,5)+name.substring(name.lastIndexOf("."));
|
|
|
+ }
|
|
|
+ Path uploadPath = Paths.get(uploadDir);
|
|
|
+
|
|
|
+ try {
|
|
|
+ Files.createDirectories(uploadPath);
|
|
|
+ Path filePath = null;
|
|
|
+ if (fileName != null) {
|
|
|
+ filePath = uploadPath.resolve(fileName);
|
|
|
+ }
|
|
|
+ Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
+ log.info("文件:{}, socialNo:{}", file.getName(), socialNo);
|
|
|
+ String url = "http://172.16.30.8:8077/proImage/" + fileName;
|
|
|
+ int num =secondDao.updateProImage(socialNo,url);
|
|
|
+ js.put("url", url);
|
|
|
+ js.put("name", fileName);
|
|
|
+ return ResultVoUtil.success(js);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("上传错误:{}", e.getMessage());
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "上传错误请重新上传。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Description 根据身份证号,序号删除其它资格证书取得情况
|
|
|
* @Author hsh
|