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