|
@@ -1,164 +1,163 @@
|
|
-package nc.pub.filesystem.newui;
|
|
+package nc.pub.filesystem.newui;
|
|
-
|
|
+
|
|
-import java.awt.event.ActionEvent;
|
|
+import java.awt.event.ActionEvent;
|
|
-import java.io.BufferedInputStream;
|
|
+import java.io.BufferedInputStream;
|
|
-import java.io.ByteArrayOutputStream;
|
|
+import java.io.ByteArrayOutputStream;
|
|
-import java.io.File;
|
|
+import java.io.File;
|
|
-import java.io.FileInputStream;
|
|
+import java.io.FileInputStream;
|
|
-import java.io.FileOutputStream;
|
|
+import java.io.FileOutputStream;
|
|
-import nc.itf.th.IThOcrService;
|
|
+import nc.itf.th.IThOcrService;
|
|
-import nc.bs.framework.common.RuntimeEnv;
|
|
+import nc.bs.framework.common.RuntimeEnv;
|
|
-import javax.swing.AbstractAction;
|
|
+import javax.swing.AbstractAction;
|
|
-import javax.swing.Action;
|
|
+import javax.swing.Action;
|
|
-import javax.swing.JFileChooser;
|
|
+import javax.swing.JFileChooser;
|
|
-import javax.swing.tree.DefaultMutableTreeNode;
|
|
+import javax.swing.tree.DefaultMutableTreeNode;
|
|
-import javax.swing.tree.TreePath;
|
|
+import javax.swing.tree.TreePath;
|
|
-
|
|
+
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
-
|
|
+
|
|
-import nc.bs.framework.common.NCLocator;
|
|
+import nc.bs.framework.common.NCLocator;
|
|
-import nc.bs.logging.Logger;
|
|
+import nc.bs.logging.Logger;
|
|
-import nc.desktop.ui.WorkbenchEnvironment;
|
|
+import nc.desktop.ui.WorkbenchEnvironment;
|
|
-import nc.funcnode.ui.action.AbstractNCAction;
|
|
+import nc.funcnode.ui.action.AbstractNCAction;
|
|
-import nc.itf.pu.service.IInvoiceOCRMaintain;
|
|
+import nc.log.NcLog;
|
|
-import nc.log.NcLog;
|
|
+import nc.ui.ml.NCLangRes;
|
|
-import nc.ui.ml.NCLangRes;
|
|
+import nc.ui.pub.beans.MessageDialog;
|
|
-import nc.ui.pub.beans.MessageDialog;
|
|
+import nc.ui.pub.bill.BillCardPanel;
|
|
-import nc.ui.pub.bill.BillCardPanel;
|
|
+import nc.ui.pub.filesystem.FileManageServletClient;
|
|
-import nc.ui.pub.filesystem.FileManageServletClient;
|
|
+import nc.vo.pub.filesystem.NCFileNode;
|
|
-import nc.vo.pub.filesystem.NCFileNode;
|
|
+import nc.vo.pub.lang.UFDate;
|
|
-import nc.vo.pub.lang.UFDate;
|
|
+import nc.vo.pub.lang.UFDouble;
|
|
-import nc.vo.pub.lang.UFDouble;
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+public class ThUploadAction extends AbstractNCAction {
|
|
-public class ThUploadAction extends AbstractNCAction {
|
|
+
|
|
-
|
|
+ *
|
|
- *
|
|
+ */
|
|
- */
|
|
+ private static final long serialVersionUID = 1L;
|
|
- private static final long serialVersionUID = 1L;
|
|
+ private ThFileContentPanel parentpanel ;
|
|
- private ThFileContentPanel parentpanel ;
|
|
+ public ThUploadAction(ThFileContentPanel para){
|
|
- public ThUploadAction(ThFileContentPanel para){
|
|
+ parentpanel = para;
|
|
- parentpanel = para;
|
|
+ this.putValue(AbstractAction.NAME,NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0000"));
|
|
- this.putValue(AbstractAction.NAME,NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0000"));
|
|
+ this.putValue(Action.SHORT_DESCRIPTION, NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0000"));
|
|
- this.putValue(Action.SHORT_DESCRIPTION, NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0000"));
|
|
+
|
|
-
|
|
+ }
|
|
- }
|
|
+
|
|
-
|
|
+ @Override
|
|
- @Override
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
- public void actionPerformed(ActionEvent e) {
|
|
+ if (parentpanel.rootNode == null) {
|
|
- if (parentpanel.rootNode == null) {
|
|
+ return;
|
|
- return;
|
|
+ }
|
|
- }
|
|
+ TreePath path = parentpanel.getPatchTree().getSelectionPath();
|
|
- TreePath path = parentpanel.getPatchTree().getSelectionPath();
|
|
+ if (path == null) {
|
|
- if (path == null) {
|
|
+ path = new TreePath(parentpanel.rootNode.getPath());
|
|
- path = new TreePath(parentpanel.rootNode.getPath());
|
|
+ }
|
|
- }
|
|
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
|
|
- DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
|
|
+
|
|
-
|
|
+ JFileChooser chooser = new JFileChooser();
|
|
- JFileChooser chooser = new JFileChooser();
|
|
+
|
|
-
|
|
+ chooser.setMultiSelectionEnabled(true);
|
|
- chooser.setMultiSelectionEnabled(true);
|
|
+ if (chooser.showOpenDialog(parentpanel) == JFileChooser.APPROVE_OPTION) {
|
|
- if (chooser.showOpenDialog(parentpanel) == JFileChooser.APPROVE_OPTION) {
|
|
+ String pPath = "";
|
|
- String pPath = "";
|
|
+ if (node instanceof NCFileNode) {
|
|
- if (node instanceof NCFileNode) {
|
|
+ pPath = ((NCFileNode) node).getFullPath();
|
|
- pPath = ((NCFileNode) node).getFullPath();
|
|
+ }
|
|
- }
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+ File[] arrfiles = chooser.getSelectedFiles();
|
|
- File[] arrfiles = chooser.getSelectedFiles();
|
|
+ if(arrfiles==null ||arrfiles.length==0){
|
|
- if(arrfiles==null ||arrfiles.length==0){
|
|
+
|
|
-
|
|
+ return;
|
|
- return;
|
|
+ }
|
|
- }
|
|
+
|
|
-
|
|
+ String dsName = WorkbenchEnvironment.getInstance().getLoginBusiCenter().getDataSourceName();
|
|
- String dsName = WorkbenchEnvironment.getInstance().getLoginBusiCenter().getDataSourceName();
|
|
+
|
|
-
|
|
+ String creator = WorkbenchEnvironment.getInstance().getLoginUser().getCuserid();
|
|
- String creator = WorkbenchEnvironment.getInstance().getLoginUser().getCuserid();
|
|
+ FileInputStream input = null;
|
|
- FileInputStream input = null;
|
|
+ FileInputStream testinput = null;
|
|
- FileInputStream testinput = null;
|
|
+
|
|
-
|
|
+ IThOcrService ocrservice=(IThOcrService) NCLocator.getInstance().lookup(IThOcrService.class.getName());
|
|
- IThOcrService ocrservice=(IThOcrService) NCLocator.getInstance().lookup(IThOcrService.class.getName());
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+ try {
|
|
- try {
|
|
+ for(File file :arrfiles){
|
|
- for(File file :arrfiles){
|
|
+ String fileName = file.getName();
|
|
- String fileName = file.getName();
|
|
+
|
|
-
|
|
+ if(parentpanel.CheckTheSameFileName((NCFileNode)node, fileName)){
|
|
- if(parentpanel.CheckTheSameFileName((NCFileNode)node, fileName)){
|
|
+ continue ;
|
|
- continue ;
|
|
+ }
|
|
- }
|
|
+
|
|
-
|
|
+ long size =(long)FileBroseConst.getfilelimit()*1024L*1024L;
|
|
- long size =(long)FileBroseConst.getfilelimit()*1024L*1024L;
|
|
+ if(size<file.length()){
|
|
- if(size<file.length()){
|
|
+ MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0001"), NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0002", null, new String[]{fileName}));
|
|
- MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0001"), NCLangRes.getInstance().getStrByID("sftemp", "UploadAction-0002", null, new String[]{fileName}));
|
|
+ continue ;
|
|
- continue ;
|
|
+ }
|
|
- }
|
|
+ input = new FileInputStream(file);
|
|
- input = new FileInputStream(file);
|
|
+ testinput = new FileInputStream(file);
|
|
- testinput = new FileInputStream(file);
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+ BillCardPanel cpanel=parentpanel.editor_.getBillCardPanel();
|
|
- BillCardPanel cpanel=parentpanel.editor_.getBillCardPanel();
|
|
+ String vdef17 = (String) cpanel.getHeadItem("vdef17").getValueObject();
|
|
- String vdef17 = (String) cpanel.getHeadItem("vdef17").getValueObject();
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+ NCFileNode newNode = FileManageServletClient.uploadFile(dsName, pPath, fileName, testinput, creator, file.length());
|
|
- NCFileNode newNode = FileManageServletClient.uploadFile(dsName, pPath, fileName, testinput, creator, file.length());
|
|
+ if (newNode != null) {
|
|
- if (newNode != null) {
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+ parentpanel.nodeToFileVO((NCFileNode)node, newNode);
|
|
- parentpanel.nodeToFileVO((NCFileNode)node, newNode);
|
|
+ }
|
|
- }
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+ BufferedInputStream bis=new BufferedInputStream(input);
|
|
- BufferedInputStream bis=new BufferedInputStream(input);
|
|
+ ByteArrayOutputStream bos=new ByteArrayOutputStream();
|
|
- ByteArrayOutputStream bos=new ByteArrayOutputStream();
|
|
+ int date=-1;
|
|
- int date=-1;
|
|
+ while ((date = bis.read()) != -1) {
|
|
- while ((date = bis.read()) != -1) {
|
|
+ bos.write(date);
|
|
- bos.write(date);
|
|
+ }
|
|
- }
|
|
+ byte[] bytes= bos.toByteArray();
|
|
- byte[] bytes= bos.toByteArray();
|
|
+
|
|
-
|
|
+ String patch=ocrservice.saveUploadFile(vdef17, fileName, bytes);
|
|
- String patch=ocrservice.saveUploadFile(vdef17, fileName, bytes);
|
|
+
|
|
-
|
|
+ }
|
|
- }
|
|
+ } catch (Exception ex) {
|
|
- } catch (Exception ex) {
|
|
+ Logger.error(ex.getMessage(), ex);
|
|
- Logger.error(ex.getMessage(), ex);
|
|
+ MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000"),ex.getMessage());
|
|
- MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000"),ex.getMessage());
|
|
+
|
|
-
|
|
+ } finally {
|
|
- } finally {
|
|
+ try {
|
|
- try {
|
|
+ if (input != null) {
|
|
- if (input != null) {
|
|
+ input.close();
|
|
- input.close();
|
|
+ }
|
|
- }
|
|
+ } catch (Exception e2) {
|
|
- } catch (Exception e2) {
|
|
+ }
|
|
- }
|
|
+ }
|
|
- }
|
|
+ }
|
|
- }
|
|
+
|
|
-
|
|
+ }
|
|
- }
|
|
+}
|
|
-}
|
|
|