|
@@ -57,22 +57,24 @@ public class ThOCRAction extends AbstractNCAction{
|
|
|
String vdef17 =(String) parentpanel.editor_.getBillCardPanel().getHeadItem("vdef17").getValueObject();//附件id
|
|
|
String pk_org = (String) parentpanel.editor_.getBillCardPanel().getHeadItem("pk_org").getValueObject();
|
|
|
String pk_group = (String) parentpanel.editor_.getBillCardPanel().getHeadItem("pk_group").getValueObject();
|
|
|
- String filepath = RuntimeEnv.getInstance().getNCHome()
|
|
|
- +File.separator +"uploadfile" + File.separator+ vdef17; // 文件保存的路径
|
|
|
-
|
|
|
- List<String> filewjlis=getFileNames(filepath);
|
|
|
-
|
|
|
- if(null==filewjlis||filewjlis.size()==0){
|
|
|
- MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
|
- ,"请先上传发票,再进行OCR识别!");
|
|
|
- return;
|
|
|
- }
|
|
|
|
|
|
IThOcrService ocrservice=(IThOcrService) NCLocator.getInstance().lookup(IThOcrService.class.getName());
|
|
|
|
|
|
// IInvoiceOCRMaintain iInvoiceOCRMaintain = (IInvoiceOCRMaintain) NCLocator.getInstance().lookup(IInvoiceOCRMaintain.class.getName());
|
|
|
|
|
|
+// String filepath = RuntimeEnv.getInstance().getNCHome()
|
|
|
+// +File.separator +"uploadfile" + File.separator+ vdef17; // 文件保存的路径
|
|
|
+// List<String> filewjlis=getFileNames(filepath);
|
|
|
|
|
|
+ List<String> filewjlis=ocrservice.getInvoiceInfo(vdef17);//获取"+vdef17+"文件夹下所有发票名
|
|
|
+
|
|
|
+ if(null==filewjlis||filewjlis.size()==0){
|
|
|
+ MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
|
+ ,"请先上传发票,再进行OCR识别!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//获取token
|
|
|
String token="";
|
|
|
try {
|
|
@@ -92,16 +94,17 @@ public class ThOCRAction extends AbstractNCAction{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- MessageDialog.showHintDlg(parentpanel, "提示","token:"+token);
|
|
|
+// MessageDialog.showHintDlg(parentpanel, "提示","token:"+token);
|
|
|
StringBuffer sb=new StringBuffer();
|
|
|
StringBuffer sb2=new StringBuffer();
|
|
|
StringBuffer sb3=new StringBuffer();
|
|
|
for(int i=0;i<filewjlis.size();i++){
|
|
|
- File file=new File(filepath+File.separator+filewjlis.get(i));
|
|
|
+ // File file=new File(filepath+File.separator+filewjlis.get(i));
|
|
|
//发票上传
|
|
|
String idjson="";
|
|
|
try {
|
|
|
- idjson=ocrservice.uploadInvoice(upurl,token, file);
|
|
|
+// idjson=ocrservice.uploadInvoice(upurl,token, file);
|
|
|
+ idjson=ocrservice.uploadInvoice(upurl,token, vdef17,filewjlis.get(i));
|
|
|
} catch (Exception e) {
|
|
|
MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
|
|
|
,"发票上传:\n"+e.getMessage());
|
|
@@ -247,9 +250,9 @@ public class ThOCRAction extends AbstractNCAction{
|
|
|
|
|
|
}
|
|
|
|
|
|
- MessageDialog.showHintDlg(parentpanel, "提示","发票上传json:\n"+sb.toString());
|
|
|
+/* MessageDialog.showHintDlg(parentpanel, "提示","发票上传json:\n"+sb.toString());
|
|
|
MessageDialog.showHintDlg(parentpanel, "提示","ocr识别json:\n"+sb2.toString());
|
|
|
-// MessageDialog.showHintDlg(parentpanel, "提示","ocr识别YY:\n"+sb3.toString());
|
|
|
+// MessageDialog.showHintDlg(parentpanel, "提示","ocr识别YY:\n"+sb3.toString());*/
|
|
|
MessageDialog.showHintDlg(parentpanel, "提示","识别成功!");
|
|
|
}
|
|
|
|
|
@@ -260,14 +263,14 @@ public class ThOCRAction extends AbstractNCAction{
|
|
|
* @param path 路径
|
|
|
* @return {@link List}<{@link String}>
|
|
|
*/
|
|
|
- private List<String> getFileNames(String path) {
|
|
|
+ /* private List<String> getFileNames(String path) {
|
|
|
File file = new File(path);
|
|
|
if (!file.exists()) {
|
|
|
return null;
|
|
|
}
|
|
|
List<String> fileNames = new ArrayList<String>();
|
|
|
return getFileNames(file, fileNames);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
* 得到文件名称
|
|
@@ -276,7 +279,7 @@ public class ThOCRAction extends AbstractNCAction{
|
|
|
* @param fileNames 文件名
|
|
|
* @return {@link List}<{@link String}>
|
|
|
*/
|
|
|
- private List<String> getFileNames(File file, List<String> fileNames) {
|
|
|
+/* private List<String> getFileNames(File file, List<String> fileNames) {
|
|
|
File[] files = file.listFiles();
|
|
|
for (File f : files) {
|
|
|
if (f.isDirectory()) {
|
|
@@ -286,7 +289,7 @@ public class ThOCRAction extends AbstractNCAction{
|
|
|
}
|
|
|
}
|
|
|
return fileNames;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
private String checkJson(JSONObject json) throws Exception {
|
|
|
|