智慧保安后台管理-外网
Administrator
2021-11-17 7293f04d18fb2e882e152f962c3aa1d8fcb1f93e
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -19,13 +19,13 @@
import io.minio.*;
import io.minio.errors.*;
import io.swagger.annotations.Api;
import javafx.scene.Parent;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springblade.common.config.FileConfig;
import org.springblade.common.constant.FtpConstant;
import org.springblade.common.config.FtpConfig;
import org.springblade.common.utils.FileUtil;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.oss.model.OssFile;
import org.springblade.core.secure.annotation.PreAuth;
@@ -55,8 +55,7 @@
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;
import static org.springblade.common.constant.FtpConstant.*;
import static org.springblade.common.config.FtpConfig.*;
/**
 * 对象存储端点
@@ -222,7 +221,7 @@
            .headers(headers)
            .build());
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://223.82.109.183:2081/zhba/" + newName;
      return R.data(urls);
@@ -269,7 +268,7 @@
            .headers(headers)
            .build());
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://223.82.109.183:2081/zhba/" + newName;
      //数据封装
@@ -311,8 +310,9 @@
      String fileType = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(Locale.US);
      //判断文件是不是zip类型
      if(!fileType.equals("zip")){
         map.put("data","上传文件类型不符!");
         return R.data(map);
//         map.put("data","上传文件类型不符!");
//         return R.data(map);
         throw new ServiceException("上传文件类型不符!必须是 zip 压缩文件格式!");
      }
      //FileConfig.localtion是配置文件和config类生产的,测试demo可以直接把FileConfig.localtion替换成D:/test
      String uuid = UUID.randomUUID().toString();
@@ -327,7 +327,8 @@
      List<MultipartFile> fileList = new ArrayList<>();
      //获取图片文件
      fileList = fileUtil.getSubFiles(desPath+File.separator+namePath,fileList);
//      fileList = fileUtil.getSubFiles(desPath+File.separator+namePath,fileList);
      fileList = fileUtil.getSubFiles(desPath,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("."));
@@ -346,7 +347,7 @@
            String urls = "http://223.82.109.183:2081/zhba/" + newName;
            //内网
            String inUrl = ip + newName;
            String inUrl = FtpConfig.ip + "/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})";
@@ -367,7 +368,7 @@
               //文件推送
               InputStream inputStream = multipartFile.getInputStream();
               FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
               FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
               in.close();
            }
         }
@@ -412,8 +413,9 @@
      String fileType = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(Locale.US);
      //判断文件是不是zip类型
      if(!fileType.equals("zip")){
         map.put("data","上传文件类型不符!");
         return R.data(map);
//         map.put("data","上传文件类型不符!");
//         return R.data(map);
         throw new ServiceException("上传文件类型不符!必须是 zip 压缩文件格式!");
      }
      //FileConfig.localtion是配置文件和config类生产的,测试demo可以直接把FileConfig.localtion替换成D:/test
      String uuid = UUID.randomUUID().toString();
@@ -427,7 +429,7 @@
      List<MultipartFile> fileList = new ArrayList<>();
      //获取图片文件
      fileList = fileUtil.getSubFiles(desPath+File.separator+namePath,fileList);
      fileList = fileUtil.getSubFiles(desPath,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("."));
@@ -446,7 +448,7 @@
            String urls = "http://223.82.109.183:2081/zhba/" + newName;
            //内网
            String inUrl = ip + newName;
            String inUrl = FtpConfig.ip +"/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})";
@@ -458,6 +460,7 @@
            if (null!=user){
               ExamPayment examPayment = new ExamPayment();
               examPayment.setWorkerId(user.getId().toString());
               examPayment.setPaymentStatus(3);
               examPayment.setCertificateUrl(urls);
               examPayment.setType(1);
               examPayment.setPaymentTime(new Date());
@@ -472,18 +475,18 @@
               //数据推送
               String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(examPayment.getPaymentTime());
               String s = "insert into sys_apply(id,type,payment_time,worker_id,apply_code,certificate_url) " +
               String s = "insert into sys_exam_payment(id,type,payment_time,worker_id,payment_status,certificate_url) " +
                  "values(" + "'" + examPayment.getId() + "'" +
                  "," + "'" + examPayment.getType() + "'" +
                  "," + "'" + formatStr + "'" +
                  "," + "'" + examPayment.getWorkerId() + "'" +
                  "," + "'" + examPayment.getApplyCode() + "'" +
                  "," +"'" + examPayment.getCertificateUrl() + "'" + ")";
                  "," + "'" + examPayment.getPaymentStatus() + "'" +
                  "," +"'" + inUrl + "'" + ")";
               FtpUtil.sqlFileUpload(s);
               //文件推送
               InputStream inputStream = multipartFile.getInputStream();
               FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
               FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
               in.close();
            }
         }
@@ -537,8 +540,10 @@
            in, in.available(), -1)
            .headers(headers)
            .build());
      //文件推送
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://223.82.109.183:2081/zhba/" + newName;
      //数据封装
@@ -623,15 +628,31 @@
      }
      attachService.save(attach);
      String[] split = bladeFile.getName().split("/");
      String ip = FtpConstant.ip+"/zhba/upload/picture/";
      String ip = FtpConfig.ip+"/zhba/upload/picture/";
      String imgurl = ip + split[2];
      FtpUtil.uploadFile(ftpHost_dev, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", split[2], in);
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], in);
      //数据同步
      String s1 =
         "insert into blade_attach(id,tenant_id,link,domain,name,original_name,extension,attach_size,create_user,deptid," +
            "create_time,update_user,update_time,status,is_deleted,type,cardid";
      if (noticeId != null) {
         s1 += ",notice_id";
         s1 += ",notice_id"+")" +"values(" + "'" + attach.getId() + "'" + "," +
            "'" + attach.getTenantId() + "'" + "," +
            "'" + imgurl + "'" + "," +
            "'" + ip + "'" + "," +
            "'" + split[2] + "'" + "," +
            "'" + attach.getOriginalName() + "'" + "," +
            "'" + attach.getExtension() + "'" + "," +
            "'" + attach.getAttachSize() + "'" + "," +
            "'" + attach.getCreateUser() + "'" + "," +
            "'" + attach.getDeptid() + "'" + "," +
            "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "'" + "," +
            "'" + attach.getUpdateUser() + "'" + "," +
            "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "'" + "," +
            "'" + attach.getStatus() + "'" + "," +
            "'" + attach.getIsDeleted() + "'" + "," +
            "'" + attach.getType() + "'" + "," +
            "'" + cardid + "'";
      } else {
         s1 += ") " +
            "values(" + "'" + attach.getId() + "'" + "," +
@@ -653,7 +674,7 @@
            "'" + cardid + "'";
      }
      if (noticeId != null) {
         s1 += "'" + noticeId + "'" + ")";
         s1 += ","+"'" + noticeId + "'" + ")";
      } else {
         s1 += ")";
      }