dev
parent
533c69f06d
commit
9c8557803e
|
|
@ -99,9 +99,14 @@ public class CustomerContractTemplateService extends BaseService {
|
|||
String fileName = "";
|
||||
boolean ret;
|
||||
try {
|
||||
String key = "attachment/" + DateTimeUtil.yMd.get().format(new Date()) + "/" + StrKit.getRandomUUID();
|
||||
file = uploadFile.getFile();
|
||||
String htmlStr = Word2HtmlStr.conver(file);
|
||||
if (htmlStr == null) {
|
||||
return Result.failed(fileName + "转html字符串失败");
|
||||
}
|
||||
model.setHtmlstr(htmlStr);
|
||||
|
||||
String key = "attachment/" + DateTimeUtil.yMd.get().format(new Date()) + "/" + StrKit.getRandomUUID();
|
||||
fileName = file.getName();
|
||||
String suffix = fileName.substring(fileName.lastIndexOf("."), fileName.length()).toLowerCase();
|
||||
OSSKit.putObject("ssjygl-xsx-static", key + suffix, file);
|
||||
|
|
@ -110,11 +115,6 @@ public class CustomerContractTemplateService extends BaseService {
|
|||
r.set("ossKey", key + suffix);
|
||||
r.set("tm", DateTimeUtil.sdfhms.get().format(new Date(file.lastModified())));
|
||||
model.setAttachment(r.toJson());
|
||||
String htmlStr = Word2HtmlStr.conver(file);
|
||||
if (htmlStr == null) {
|
||||
return Result.failed(fileName + "转html字符串失败");
|
||||
}
|
||||
model.setHtmlstr(htmlStr);
|
||||
try {
|
||||
ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ import java.io.*;
|
|||
public class Word2HtmlStr {
|
||||
public static String ENCODING = "utf-8";
|
||||
|
||||
public static String conver(File file) throws Exception {
|
||||
public static String conver(File file) {
|
||||
|
||||
return conver(file, ENCODING);
|
||||
}
|
||||
|
||||
public static String conver(File file, String encoding) throws Exception {
|
||||
public static String conver(File file, String encoding) {
|
||||
if( file == null || !file.exists() || file.isDirectory() ){
|
||||
return null;
|
||||
}
|
||||
|
|
@ -30,12 +30,12 @@ public class Word2HtmlStr {
|
|||
String fileName = file.getName();
|
||||
String type = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
||||
|
||||
if( "doc".equals(type) || "wps".equals(type) ){
|
||||
if( "doc".equals(type)){
|
||||
return doc2Html(file, encoding);
|
||||
}else if( "docx".equals(type) ){
|
||||
} else if ( "docx".equals(type) ){
|
||||
return docx2Html(file);
|
||||
}else{
|
||||
throw new Exception(type + ",格式不正确!");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue