智慧保安后台管理-外网项目备份
zhongrj
2022-08-18 f288ed575764a898bb8df1eb06c9b3cba55f3e17
src/main/java/org/springblade/modules/licetuser/controller/LicetuserController.java
@@ -23,9 +23,12 @@
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.apache.commons.lang3.StringUtils;
import org.springblade.common.config.FileConfig;
import org.springblade.common.config.FtpConfig;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@@ -200,7 +203,9 @@
    * @return
    */
   @PostMapping("/liceUpload")
   public R liceUpload(@RequestParam MultipartFile file, String licetId, String ptype, String cardid) throws IOException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, ServerException, ErrorResponseException, XmlParserException, InsufficientDataException, InternalException {
   public R liceUpload(@RequestParam MultipartFile file, String licetId, String ptype, String cardid, HttpServletRequest request) throws IOException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, ServerException, ErrorResponseException, XmlParserException, InsufficientDataException, InternalException {
      String fieldNames = request.getHeader("_fieldNames");
      System.out.println("fieldNames = " + fieldNames);
      //文件上传
      String urls = putFile(file);
      String link = urls.split(",")[0];
@@ -211,39 +216,17 @@
      Licet licet = new Licet();
      licet.setPtype(ptype);
      //查看当前模板是第几个
      List<Licet> list = licetService.list(Condition.getQueryWrapper(licet));
      Integer index = 0;
      if (list.size()>0){
         for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getId().equals(Integer.parseInt(licetId))){
               index = i;
            }
         }
      }
      licetuser.setUserid(cardid);
      //查询上传的材料信息
      Licetuser licetuser1 = licetuserService.getOne(Condition.getQueryWrapper(licetuser));
      if (null==licetuser1){
         licetuser.setLicetId(licetId);
         licetuser.setTemplateid(licetId);
         licetuser.setLinks(link);
         //设置下标
         licetuser.setTemplateid(index.toString());
         //新增
         licetuserService.save(licetuser);
         //数据同步
//         String s1 =
//            "insert into sys_licetuser(id,userid,ptype,templateid,links,licet_id) " +
//               "values(" + "'" + licetuser.getId() + "'" + "," +
//               "'" + licetuser.getUserid() + "'" + "," +
//               "'" + licetuser.getPtype() + "'" + "," +
//               "'" + licetuser.getTemplateid() + "'" + "," +
//               "'" + inlink + "'" + "," +
//               "'" + licetuser.getLicetId() + "'" + ")";
//         FtpUtil.sqlFileUpload(s1);
         String s1 =
            "insert into sys_licetuser(id,userid,ptype,templateid,links) " +
               "values(" + "'" + licetuser.getId() + "'" + "," +
@@ -254,7 +237,7 @@
         FtpUtil.sqlFileUpload(s1);
      }else {
         //判断是否是重复上传
         List<String> asList = Arrays.asList(licetuser1.getLicetId().split(","));
         List<String> asList = Arrays.asList(licetuser1.getTemplateid().split(","));
         List<String> linksList = Arrays.asList(licetuser1.getLinks().split(","));
         boolean status = asList.contains(licetId);
         if(status) {
@@ -270,8 +253,7 @@
            licetuser1.setLinks(StringUtils.join(linksList.toArray(), ","));
         }else {
            //替换 下标集合,id集合,links
            licetuser1.setTemplateid(licetuser1.getTemplateid()+","+index);
            licetuser1.setLicetId(licetuser1.getLicetId()+","+licetId);
            licetuser1.setTemplateid(licetuser1.getTemplateid()+","+licetId);
            licetuser1.setLinks(licetuser1.getLinks()+","+link);
         }
         //修改
@@ -288,13 +270,6 @@
         String inlinks = url.substring(0, url.length() - 1);
         //同步数据
//         String s1 = "update sys_licetuser set userid = " + "'" + licetuser1.getUserid() + "'" +
//            ",ptype = " + "'" + licetuser1.getPtype() + "'" +
//            ",templateid = " + "'" + licetuser1.getTemplateid() + "'" +
//            ",links = " + "'" + inlinks + "'" +
//            ",licet_id = " + "'" + licetuser1.getLicetId() + "'" +
//            " " + "where id = " + "'" + licetuser1.getId() + "'";
//         FtpUtil.sqlFileUpload(s1);
         String s1 = "update sys_licetuser set userid = " + "'" + licetuser1.getUserid() + "'" +
            ",ptype = " + "'" + licetuser1.getPtype() + "'" +
            ",templateid = " + "'" + licetuser1.getTemplateid() + "'" +
@@ -310,10 +285,10 @@
    * @param file
    */
   private String putFile(MultipartFile file) throws IOException, InvalidKeyException, InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException, ServerException, InternalException, XmlParserException, ErrorResponseException {
      String url = "http://223.82.109.183:2081";
      String access = "zhbaadmin";
      String secret = "zhbapassword";
      String bucket = "zhba";
      String url = FileConfig.url;
      String access = FileConfig.access;
      String secret = FileConfig.secret;
      String bucket = FileConfig.bucket;
      MinioClient minioClient =
         MinioClient.builder()
            .endpoint(url)
@@ -344,7 +319,7 @@
      InputStream inputStream = file.getInputStream();
      FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream);
      in.close();
      String urls = "http://223.82.109.183:2081/zhba/" + newName;
      String urls = "http://61.131.136.25/zhba/" + newName;
      //内网
      String inUrl = FtpConfig.ip + "/zhba/" + newName;
      //返回url