39 测试

This commit is contained in:
gaojiabao
2023-06-15 15:04:57 +08:00
parent 812d2533f0
commit 61c5225319
@@ -29,6 +29,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFSheet;
@@ -75,7 +82,6 @@ public class SarStandardsInfoController extends BaseController<SarStandardsInfo>
@Autowired
private ISarStandFileService sarStandFileService;
@Value("${file.path}")
private String filePath;
@@ -1047,4 +1053,78 @@ public class SarStandardsInfoController extends BaseController<SarStandardsInfo>
public ResponseMessage fileNameTranslation (){
return sarStandardsInfoEOService.fileNameTranslation();
}
@ApiOperation(value = "|SarStandardsInfoEO|编号+名称组合为唯一标识(国内海外)")
@PostMapping("/ceshi")
public ResponseMessage ceshi (String docx,String urlInfo){
String e7FAFC9C22A8 = onlyofficePdfUtil("E7FAFC9C22A8", "1111111.pdf", docx,urlInfo);
return Result.success(e7FAFC9C22A8);
}
private String onlyofficePdfUtil(String key,String title,String urlFile,String urlInfo){
HttpClient client = HttpClients.createDefault();
Map<String, Object> cmd = new HashMap<>();
cmd.put("async",false);
cmd.put("filetype","docx");
cmd.put("key",key);
cmd.put("title",title);
cmd.put("url",urlFile);
//http://47.92.92.38:8103/7.2.1-34/ConvertService.ashx
//https://example.com/url-to-example-document.docx
//String url = "http://47.92.92.38:8103/url-to-example-document.docx";
// String url = "http://47.92.92.38:8103/7.2.1-34/downloadas";
String url = "";
if(urlInfo.equals("1")){
url = "http://47.92.92.38:8103/7.2.1-34/ConvertService.ashx";
}
if(urlInfo.equals("11")){
url = "https://47.92.92.38:8103/7.2.1-34/ConvertService.ashx";
}
if(urlInfo.equals("2")){
url = "http://47.92.92.38:8103/url-to-example-document.docx";
}
if(urlInfo.equals("22")){
url = "http://47.92.92.38:8103/7.2.1-34/url-to-example-document.docx";
}
if(urlInfo.equals("222")){
url = "https://47.92.92.38:8103/url-to-example-document.docx";
}
if(urlInfo.equals("2222")){
url = "https://47.92.92.38:8103/7.2.1-34/url-to-example-document.docx";
}
if(urlInfo.equals("3")){
url = "https://example.com/url-to-example-document.docx";
}
if(urlInfo.equals("33")){
url = "http://example.com/url-to-example-document.docx";
}
if(urlInfo.equals("333")){
url = "http://example.com/7.2.1-34/url-to-example-document.docx";
}
if(urlInfo.equals("3333")){
url = "https://example.com/7.2.1-34/url-to-example-document.docx";
}
//HttpGet httpGet=new HttpGet(url);
HttpPost httpPost=new HttpPost(url);
JSONObject jsonObject = null;
try {
httpPost.setHeader("Accept","application/json");
httpPost.setHeader("Content-Type","Content-Type");
HttpResponse res = client.execute(httpPost);
if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 返回json格式:
final String s = EntityUtils.toString(res.getEntity());
jsonObject = JSONObject.parseObject(EntityUtils.toString(res.getEntity()));
jsonObject.get("fileUrl");
System.out.println(jsonObject);
}else {
jsonObject.put("fileUrl","失败!!!!!!");
}
} catch (Exception e) {
System.out.println("服务间接口调用出错!");
e.printStackTrace();
}
return jsonObject.toJSONString();
}
}