提交 031101b5 authored 作者: liupengfei's avatar liupengfei

--no commit message

上级 69e8d0f5
...@@ -25,22 +25,22 @@ public class ExcelBookExportVo extends ImportVo{ ...@@ -25,22 +25,22 @@ public class ExcelBookExportVo extends ImportVo{
@ExcelResources(title="正丛书名",order=4) @ExcelResources(title="正丛书名",order=4)
private String bookSeries; private String bookSeries;
@ExcelResources(title="第一责任者及著作方式 ",order=5) @ExcelResources(title="第一责任者及著作方式",order=5)
private String executiveEditor; private String executiveEditor;
@ExcelResources(title="版次及其他版本形式 ",order=5) @ExcelResources(title="版次及其他版本形式",order=6)
private String revision; private String revision;
@ExcelResources(title="印次 ",order=5) @ExcelResources(title="印次",order=7)
private String printNo; private String printNo;
@ExcelResources(title="主题词",order=5) @ExcelResources(title="主题词",order=8)
private String keywords; private String keywords;
@ExcelResources(title="分类号",order=5) @ExcelResources(title="分类号",order=9)
private String midpicid; private String midpicid;
@ExcelResources(title="内容提要 ",order=5) @ExcelResources(title="内容提要",order=10)
private String synopsis; private String synopsis;
} }
...@@ -4,7 +4,9 @@ import javax.servlet.http.HttpServletRequest; ...@@ -4,7 +4,9 @@ import javax.servlet.http.HttpServletRequest;
import com.zrqx.core.client.vo.ImportLabelVo; import com.zrqx.core.client.vo.ImportLabelVo;
import com.zrqx.core.util.excelutil.ExcelUtil; import com.zrqx.core.util.excelutil.ExcelUtil;
import com.zrqx.core.util.excelutil.ImportUtil; import com.zrqx.core.util.excelutil.ImportUtil;
import com.zrqx.file.commons.model.AppVersionRecord;
import com.zrqx.file.commons.vo.ExcelBookExportVo; import com.zrqx.file.commons.vo.ExcelBookExportVo;
import com.zrqx.file.service.AppVersionService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -41,6 +43,9 @@ public class EpubController { ...@@ -41,6 +43,9 @@ public class EpubController {
@Autowired @Autowired
private ImportUtil importUtil; private ImportUtil importUtil;
@Autowired
private AppVersionService appVersionService;
private EpubVo ev = new EpubVo(); private EpubVo ev = new EpubVo();
@ApiOperation(value = "epub上传 返回token") @ApiOperation(value = "epub上传 返回token")
...@@ -59,7 +64,6 @@ public class EpubController { ...@@ -59,7 +64,6 @@ public class EpubController {
} catch (Exception e) { } catch (Exception e) {
throw new BaseException("epub上传失败"); throw new BaseException("epub上传失败");
} }
return token; return token;
} }
...@@ -87,7 +91,9 @@ public class EpubController { ...@@ -87,7 +91,9 @@ public class EpubController {
if(StringUtils.isNotBlank(f.getIsbn())){ if(StringUtils.isNotBlank(f.getIsbn())){
String isbn = f.getIsbn().trim(); String isbn = f.getIsbn().trim();
try { try {
String destUrl = "http://192.168.0.209/file/"+isbn+"/"+isbn+".epub"; String destUrl = "http://192.168.2.247/file/book/"+isbn+"/epub/"+isbn+".epub";
//String path = "E:\\epub\\"+s;
//testIO(destUrl,isbn+".epub",path);
HttpURLConnection httpUrl = (HttpURLConnection) new URL(destUrl).openConnection(); HttpURLConnection httpUrl = (HttpURLConnection) new URL(destUrl).openConnection();
httpUrl.connect(); httpUrl.connect();
File epubFile = inputStreamToFile(httpUrl.getInputStream(),isbn+".epub"); File epubFile = inputStreamToFile(httpUrl.getInputStream(),isbn+".epub");
...@@ -97,6 +103,10 @@ public class EpubController { ...@@ -97,6 +103,10 @@ public class EpubController {
tokenList.add(token); tokenList.add(token);
redis.set(token, ev); redis.set(token, ev);
} catch (Exception e) { } catch (Exception e) {
AppVersionRecord appVersionRecord = new AppVersionRecord();
appVersionRecord.setFilePath(f.getIsbn());
appVersionRecord.setDescription(f.getName());
appVersionService.insert(appVersionRecord);
logger.error("---------------------------------图书信息"+isbn); logger.error("---------------------------------图书信息"+isbn);
} }
} }
...@@ -104,6 +114,8 @@ public class EpubController { ...@@ -104,6 +114,8 @@ public class EpubController {
return tokenList; return tokenList;
} }
/** /**
* 工具类 * 工具类
* inputStream 转 File * inputStream 转 File
...@@ -124,6 +136,51 @@ public class EpubController { ...@@ -124,6 +136,51 @@ public class EpubController {
ins.close(); ins.close();
return file; return file;
} }
/**
* 从网络Url中下载文件
* @param urlStr 下载文件路径
* @param fileName 文件名称包含类型
* @param savePath 保存本地的路径
* @throws IOException
*/
public void testIO(String urlStr, String fileName, String savePath) throws IOException {
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
//设置超时间为5秒
conn.setConnectTimeout(5*1000);
//防止屏蔽程序抓取而返回403错误
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//得到输入流
InputStream inputStream = conn.getInputStream();
//创建保存路径
File saveDir = new File(savePath);
if(!saveDir.exists()) {
saveDir.mkdir();
}
//创建文件
File file = new File(saveDir+File.separator+fileName);
//使用内存输出流的方式
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//将输入流写入到内存输出流中
byte[] buff = new byte[4096];
int len = -1;
while ((len = inputStream.read(buff)) != -1) {
baos.write(buff,0,len);
}
byte[] getData = baos.toByteArray();
//文件输出流
FileOutputStream fout = new FileOutputStream(file);
//将内存输出流写入磁盘
fout.write(getData);
//关闭输出输入流
fout.close();
//这里可以关闭,也可以不关闭,因为ByteArrayOutputStream的close方法是一个空实现,所以关闭也没有意义。
baos.close();
inputStream.close();
System.out.println("info:"+url+" download success");
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论