提交 8c92f055 authored 作者: 李炎's avatar 李炎

改日志

上级 1f7db0f3
package org.jeecg.modules.iost.API.Util;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HlsUtil {
private String uuid;
private String originUrlpath;
private String preUrlPath;
private String rootPath;
private String fileName;
private String folderPath;
private int threadQuantity = 10;
public HlsUtil(String originUrlpath, String preUrlPath, String rootPath){
this.uuid = UUID.randomUUID().toString().replaceAll("-","");
this.originUrlpath = originUrlpath;
this.preUrlPath = preUrlPath;
this.rootPath = rootPath;
this.fileName = uuid+ ".mp4";
this.folderPath = rootPath + File.separator + uuid;
File file = new File(folderPath);
if(!file.exists()) file.mkdirs();
}
public static void main(String[] args) {
String originUrlpath = "http://localhost:8090/jintai/as/GetFile.m3u8";
// String originUrlpath ="http://127.0.0.1:8848/dsa/EZUIKit-JavaScript/adca19a95053481a836f23da28d3f55d-8498.m3u8";
System.out.println(originUrlpath);
String preUrlPath = originUrlpath.substring(0, originUrlpath.lastIndexOf("/")+1);
System.out.println(preUrlPath);
String rootPath = "E:\\Eip";
System.out.println(rootPath);
String fileName = "";
HlsUtil downLoader = new HlsUtil(originUrlpath, preUrlPath, rootPath);
// downLoader.setThreadQuantity(10);
try{
fileName = downLoader.download(true);
}
catch (Exception e) {
}
if(fileName.isEmpty()){
System.out.println("下载失败");
}else{
System.err.println("下载成功");
}
}
public String download(boolean isAsync) throws Exception {
String indexStr = getIndexFile();
System.out.println(indexStr);
List urlList = analysisIndex(indexStr);
System.out.println(urlList);
HashMap<Integer,String> keyFileMap = new HashMap<>();
// if(!isAsync){
// downLoadIndexFileAsync(urlList, keyFileMap);
//
// while (keyFileMap.size()<urlList.size()){
// //System.out.println("当前下载数量"+keyFileMap.size());
// Thread.sleep(3000);
// }
// }else{
keyFileMap = downLoadIndexFile(urlList);
// }
// System.out.println(keyFileMap);
// return composeFile(keyFileMap);
return "";
}
public String getIndexFile() throws Exception{
URL url = new URL(originUrlpath);
//下载资源
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));
String content = "" ;
String line;
while ((line = in.readLine()) != null) {
content += line + "\n";
}
in.close();
return content;
}
/* 解析索引文件 */
public List analysisIndex(String content) throws Exception{
Pattern pattern = Pattern.compile(".*ts");
Matcher ma = pattern.matcher(content);
List<String> list = new ArrayList<String>();
while(ma.find()){
list.add(ma.group());
}
return list;
}
/* 下载视频片段 */
public HashMap downLoadIndexFile(List<String> urlList) throws IOException {
HashMap<Integer,String> keyFileMap = new HashMap<>();
for(int i =0;i<urlList.size();i++){
String subUrlPath = urlList.get(i);
String fileOutPath = folderPath + File.separator + i + ".ts";
System.out.println("subUrlPath"+subUrlPath);
System.out.println("fileOutPath"+fileOutPath);
keyFileMap.put(i, fileOutPath);
try{
downloadNet(subUrlPath, fileOutPath);
System.out.println("成功:"+ (i + 1) +"/" + urlList.size());
}catch (Exception e){
System.err.println("失败:"+ (i + 1) +"/" + urlList.size());
}
}
return keyFileMap;
}
private void downloadNet(String fullUrlPath, String fileOutPath) throws Exception {
// 下载网络文件
int byteread = 0;
URL url = new URL(fullUrlPath);
URLConnection conn = url.openConnection();
InputStream inStream = conn.getInputStream();
FileOutputStream fs = new FileOutputStream(fileOutPath);
byte[] buffer = new byte[1204];
while ((byteread = inStream.read(buffer)) != -1) {
//bytesum += byteread;
fs.write(buffer, 0, byteread);
}
}
}
package org.jeecg.modules.iost.API.Util;
import java.util.Map;
public class OAUtil {
public static String MapToString(Map<String, Object> params) {
String apiUrl = "";
if (null != params && params.size() > 0) {
StringBuffer param = new StringBuffer();
int i = 0;
for (String key : params.keySet()) {
if (i == 0)
param.append("?");
else
param.append("&");
param.append(key).append("=").append(params.get(key));
i++;
}
apiUrl += param;
}
return apiUrl;
}
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.iost.API.ExternalInterface.BusinessTripInterfaceApi;
import org.jeecg.modules.iost.API.Util.OAUtil;
import org.jeecg.modules.iost.API.entity.BusinessTripDetails;
import org.jeecg.modules.iost.API.entity.LQKJ_t_IMSSyncDetails;
import org.jeecg.modules.iost.API.mapper.BusinessTripDetailsMapper;
......@@ -70,7 +71,7 @@ public class BusinessTripDetailsServiceImpl extends ServiceImpl<BusinessTripDeta
}};
String select = businessTripInterfaceApi.update(params);
System.out.println("废弃OA返回"+select);
oaUpdateJournalService.setOaUpdateJournal(key, select, 7);
oaUpdateJournalService.setOaUpdateJournal(OAUtil.MapToString(params), select, 7);
continue;
}
if (list.get("FDocumentStatus").toString().equals("C")) {//判断付款状态 -已付款
......@@ -81,7 +82,7 @@ public class BusinessTripDetailsServiceImpl extends ServiceImpl<BusinessTripDeta
}};
String select = businessTripInterfaceApi.update(params);
System.out.println("付款OA返回"+select);
oaUpdateJournalService.setOaUpdateJournal(key, select, 8);
oaUpdateJournalService.setOaUpdateJournal(OAUtil.MapToString(params), select, 8);
}
}
String kingdeeRequest = key;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.iost.API.ExternalInterface.LoanInterfaceApi;
import org.jeecg.modules.iost.API.Util.JsonUtil;
import org.jeecg.modules.iost.API.Util.OAUtil;
import org.jeecg.modules.iost.API.entity.LQKJ_t_IMSSyncDetails;
import org.jeecg.modules.iost.API.entity.LoanDiscardDetails;
import org.jeecg.modules.iost.API.mapper.LoanDiscardDetailsMapper;
......@@ -70,7 +71,7 @@ public class LoanDiscardDetailsServiceImpl extends ServiceImpl<LoanDiscardDetail
put("status", "废弃");
}};
String select = loanInterfaceApi.update(params);
oaUpdateJournalService.setOaUpdateJournal(key, select, 3);
oaUpdateJournalService.setOaUpdateJournal(OAUtil.MapToString(params), select, 3);
continue;
}
if (list.get("FDocumentStatus").toString().equals("C")) {//判断付款状态 -已付款
......@@ -80,7 +81,7 @@ public class LoanDiscardDetailsServiceImpl extends ServiceImpl<LoanDiscardDetail
put("status", "已付款");
}};
String select = loanInterfaceApi.update(params);
oaUpdateJournalService.setOaUpdateJournal(key, select, 4);
oaUpdateJournalService.setOaUpdateJournal(OAUtil.MapToString(params), select, 4);
}
}
String kingdeeRequest = key;
......
......@@ -3,6 +3,7 @@ package org.jeecg.modules.iost.API.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.iost.API.ExternalInterface.OtherReimbursementInterfaceApi;
import org.jeecg.modules.iost.API.Util.OAUtil;
import org.jeecg.modules.iost.API.entity.OtherReimbursementDetails;
import org.jeecg.modules.iost.API.entity.LQKJ_t_IMSSyncDetails;
import org.jeecg.modules.iost.API.mapper.OtherReimbursementDetailsMapper;
......@@ -66,7 +67,7 @@ public class OtherReimbursementDetailsServiceImpl extends ServiceImpl<OtherReimb
put("status", "废弃");
}};
String select = otherReimbursementInterfaceApi.update(params);
oaUpdateJournalService.setOaUpdateJournal(key, select, 11);
oaUpdateJournalService.setOaUpdateJournal(OAUtil.MapToString(params), select, 11);
continue;
}
if (list.get("FDocumentStatus").toString().equals("C")) {//判断付款状态 -已付款
......@@ -76,7 +77,7 @@ public class OtherReimbursementDetailsServiceImpl extends ServiceImpl<OtherReimb
put("status", "已付款");
}};
String select = otherReimbursementInterfaceApi.update(params);
oaUpdateJournalService.setOaUpdateJournal(key, select, 12);
oaUpdateJournalService.setOaUpdateJournal(OAUtil.MapToString(params), select, 12);
}
}
String kingdeeRequest = key;
......
......@@ -32,7 +32,8 @@ public class OaUpdateJournalServiceImpl extends ServiceImpl<OaUpdateJournalMappe
listOaRequest=JSONObject.parseObject(responsejson, OaRequest.class);
oaUpdateJournal.setCode(listOaRequest.getCode());
oaUpdateJournal.setMessage(listOaRequest.getMessage());
oaUpdateJournal.setResult(listOaRequest.getResult());
// oaUpdateJournal.setResult(listOaRequest.getResult());
oaUpdateJournal.setResult(responsejson);
oaUpdateJournal.setSynchronization("成功"!=listOaRequest.getMessage()?0:1);
}catch (Exception e){
oaUpdateJournal.setSynchronization(0);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论