| | |
| | | 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; |
| | |
| | | * @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]; |
| | |
| | | |
| | | 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() + "'" + "," + |
| | |
| | | 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) { |
| | |
| | | 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); |
| | | } |
| | | //修改 |
| | |
| | | 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() + "'" + |
| | |
| | | * @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) |
| | |
| | | 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 |