yaoyu 2 gadi atpakaļ
vecāks
revīzija
51662a0cab

+ 61 - 4
pu/pu/src/client/nc/pub/filesystem/newui/ThOCRAction.java

@@ -4,12 +4,14 @@ import java.awt.event.ActionEvent;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.UUID;
 
 import javax.swing.AbstractAction;
 import javax.swing.Action;
-
+import nc.vo.pub.filesystem.NCFileVO;
 import org.apache.commons.httpclient.HttpException;
 
 import com.alibaba.fastjson.JSONArray;
@@ -18,6 +20,7 @@ import com.alibaba.fastjson.JSONObject;
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
 import nc.bs.framework.common.RuntimeEnv;
+import nc.bs.pub.filesystem.IFileSystemService;
 import nc.funcnode.ui.action.AbstractNCAction;
 import nc.itf.bd.defdoc.IDefdocService;
 import nc.itf.th.IThOcrService;
@@ -96,6 +99,14 @@ public class ThOCRAction extends AbstractNCAction{
 		StringBuffer sb2=new StringBuffer();
 		StringBuffer sb3=new StringBuffer();
 		for(int i=0;i<filewjlis.size();i++){
+			NCFileVO oldvo = (NCFileVO) parentpanel.getfiletablemodel()
+					.getVO(i);
+			NCFileVO newvo = oldvo.clone();
+			//已识别的发票不需要再次查询
+			String filedesc = newvo.getFiledesc();
+			if(filedesc != null && "OCR已识别".equals(filedesc)) {
+				continue;
+			}
 		//	File file=new File(filepath+File.separator+filewjlis.get(i));
 			//发票上传
 			String idjson="";
@@ -139,13 +150,18 @@ public class ThOCRAction extends AbstractNCAction{
 				String name = filewjlis.get(i);
 				String memo = info.getString("number");//发票号
 				String code = info.getString("number");//发票代码
+				String fid = info.getString("fid");
+				//特殊发票发票号和发票代码不存在
+				if(code == null || "".equals(code)) {
+					memo = "特殊发票"+fid;
+					code = fid;
+				}
 				if(!"0".equals(ret)) {
 					String message = infos.getJSONObject(j).getString("message");
 					MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
 							,"ocr返回数据校验:\n"+"发票:"+name+":"+message);
-					return;
+					//return;
 				}
-				String fid = info.getString("fid");
 				String ext = info.getString("ext");
 				JSONObject extobj = JSONObject.parseObject(ext);
 				String trate = extobj.getString("trate");//税率
@@ -210,6 +226,8 @@ public class ThOCRAction extends AbstractNCAction{
 					defvo.setAttributeValue("shortname5", cname);
 					defvo.setAttributeValue("shortname6", trate);
 					defvo.setAttributeValue("enablestate", 2);
+					defvo.setAttributeValue("innercode", "0");
+					
 					try {
 						idefservice.updateDefdocs(pk_group,updatevos);
 					} catch (BusinessException e1) {
@@ -244,6 +262,7 @@ public class ThOCRAction extends AbstractNCAction{
 					defvo.setAttributeValue("shortname4", date);
 					defvo.setAttributeValue("shortname5", cname);
 					defvo.setAttributeValue("shortname6", trate);
+					defvo.setAttributeValue("innercode", "0");
 					vos[0] = defvo;
 					try {
 				//		idefservice.insertDefdocs(pk_org, vos);
@@ -256,10 +275,48 @@ public class ThOCRAction extends AbstractNCAction{
 						return;
 					}
 				}
+				newvo.setFiledesc("OCR已识别");
+				// 修改人
+				newvo.setModifier(InvocationInfoProxy.getInstance()
+						.getUserId());
+				// 修改的时间
+				Date date2 = new Date();
+				newvo.setModifytime(date2.getTime());
+				// 保存
+				IFileSystemService service = NCLocator.getInstance()
+						.lookup(IFileSystemService.class);
 				
+				try {
+					boolean b = service.updateFileAttribute(newvo, oldvo
+							.getFullPath());
+					if (b) {
+						// 更新table
+						oldvo.setFiledesc("OCR已识别");
+						oldvo.setModifier(newvo.getModifier());
+						oldvo.setModifytime(newvo.getModifytime());
+						parentpanel.getfiletablemodel().clearTable();
+						parentpanel.getfiletablemodel().addVO(
+								parentpanel.getTreenodefilecacheMap().get(
+										"root").toArray(new NCFileVO[0]));
+						parentpanel.getfiletablemodel().refreshTable();
+					} else {
+						MessageDialog.showErrorDlg(parentpanel, NCLangRes
+								.getInstance().getStrByID("sftemp",
+										"PasteAttachAction-0001")/* 错误 */,
+								NCLangRes.getInstance().getStrByID(
+										"sftemp",
+										"FilePatchAttrDialog-0000")/*
+																	 * 文件名重复!
+																	 */);
+					}
+
+				} catch (BusinessException e1) {
+					MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
+							,"识别标识:\n"+e1.getMessage());
+				   return;				
 
+				}
 			}
-			
 		}
 		
 /*		MessageDialog.showHintDlg(parentpanel, "提示","发票上传json:\n"+sb.toString());

+ 92 - 106
pu/pu/src/client/nc/pub/filesystem/newui/ThSelectAction.java

@@ -2,13 +2,12 @@ package nc.pub.filesystem.newui;
 
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
-
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-
+import nc.itf.uap.IVOPersistence;
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
 import nc.funcnode.ui.action.AbstractNCAction;
@@ -21,9 +20,16 @@ import nc.ui.ml.NCLangRes;
 import nc.ui.pub.beans.MessageDialog;
 import nc.vo.bd.defdoc.DefdocVO;
 import nc.vo.pub.BusinessException;
+import nc.vo.pubapp.pattern.pub.SqlBuilder;
 
+/**
+ * 获取发票云发票
+ * @author y1456
+ * 
+ */
 public class ThSelectAction extends AbstractNCAction{
-
+	
+	private IVOPersistence IVOPersistence = (IVOPersistence) NCLocator.getInstance().lookup(IVOPersistence.class);
 	private ThFileContentPanel parentpanel;
 	private IUAPQueryBS iuap= (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
 	
@@ -37,10 +43,10 @@ public class ThSelectAction extends AbstractNCAction{
 	public void actionPerformed(ActionEvent actionevent) {
 		MessageDialog.showHintDlg(parentpanel, "提示","开始发票获取!");
 		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 billmaker = InvocationInfoProxy.getInstance().getUserId();
 		IThOcrService  ocrservice=(IThOcrService) NCLocator.getInstance().lookup(IThOcrService.class.getName());
+		
 		//获取token
 		String token="";
 		JSONObject json = null;
@@ -58,82 +64,63 @@ public class ThSelectAction extends AbstractNCAction{
 			MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
 					,"获取发票云发票:\n"+e.getMessage());
 		}
+		try {
+			//将该单据对应的老数据删除,赋值新数据
+			DeleteDOC(vdef17);
 			JSONObject data = json.getJSONObject("data");
 			JSONArray infos = data.getJSONArray("infos");
-			for(int j = 0;j < infos.size();j++){
-				JSONObject info = infos.getJSONObject(j);
-				String memo = info.getString("number");//发票号
-				String code = info.getString("number");//发票代码
-				String fid = info.getString("fid");
-				String ext = info.getString("ext");
-				JSONObject extobj = JSONObject.parseObject(ext);
-				String trate = extobj.getString("trate");//税率
-				JSONObject modify_info = info.getJSONObject("modify_info");
-				String name = modify_info.getString("fname");
-				JSONObject comm_info = info.getJSONObject("comm_info");
-				JSONObject pro = comm_info.getJSONObject("pro");
-				String date = pro.getString("date");//发票日期
-				String type = pro.getString("type");//发票类型
-				String cname = pro.getString("cname");//发票类型名称
-				JSONObject price = comm_info.getJSONObject("price");
-				String amount = "";
-				String total = "";
-				String dtax = "";
-				//专票带税额,不是专票无税金额=价税合计
-				if(type.equals("1")||type.equals("28")||type.equals("32")){
-					amount = price.getString("amount");//无税金额
-					total = price.getString("total");//价税合计
-					dtax = price.getString("dtax");//可抵扣税额
-				}
-				else{
-					amount = price.getString("total");//无税金额
-					total = amount;//价税合计
-					dtax = "0";//可抵扣税额
-					trate = "0";//非专票税率也为0
-				}
-				JSONObject buyer = comm_info.getJSONObject("buyer");
-				String mnecode = buyer.getString("tcode");//购买方纳税人识别号
-				String name2 = buyer.getString("company");//购买方公司名称
-				JSONObject payer = comm_info.getJSONObject("payer");
-				String name3 = payer.getString("tcode");//销售方纳税人识别号
-				String name4 = payer.getString("company");//购买方公司名称
-				
-				IDefdocService idefservice = NCLocator.getInstance().lookup(IDefdocService.class);
-				
-				DefdocVO[] updatevos=QryDefdocvoInfo(code);
-				
-				if(updatevos.length>0){
-					//自定义档案存在这个编码,走修改
-					DefdocVO defvo =updatevos[0];
-					//赋值
-					defvo.setAttributeValue("name", memo);
-					defvo.setAttributeValue("memo", name);
-					defvo.setAttributeValue("mnecode", mnecode);
-					defvo.setAttributeValue("name2", name2);
-					defvo.setAttributeValue("name3", name3);
-					defvo.setAttributeValue("name4", name4);
-					defvo.setAttributeValue("name5", fid);
-					defvo.setAttributeValue("name6", vdef17);
-					defvo.setAttributeValue("shortname", amount);
-					defvo.setAttributeValue("shortname2", total);
-					defvo.setAttributeValue("shortname3", dtax);
-					defvo.setAttributeValue("shortname4", date);
-					defvo.setAttributeValue("shortname5", cname);
-					defvo.setAttributeValue("shortname6", trate);
-					defvo.setAttributeValue("enablestate", 2);
-					try {
-						idefservice.updateDefdocs(pk_group,updatevos);
-					} catch (BusinessException e1) {
-						MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
-								,"修改自定义档案数据:\n"+e1.getMessage());
-						return;
+			//票夹不存在发票
+			if(infos != null) {
+				for(int j = 0;j < infos.size();j++){
+					JSONObject info = infos.getJSONObject(j);
+					String memo = info.getString("number");//发票号
+					String code = info.getString("number");//发票代码
+					String fid = info.getString("fid");
+					//特殊发票发票号和发票代码不存在
+					if(code == null || "".equals(code)) {
+						memo = "特殊发票"+fid;
+						code = fid;
+					}
+					String ext = info.getString("ext");
+					JSONObject extobj = JSONObject.parseObject(ext);
+					String trate = extobj.getString("trate");//税率
+					JSONObject modify_info = info.getJSONObject("modify_info");
+					String name = modify_info.getString("fname");
+					JSONObject comm_info = info.getJSONObject("comm_info");
+					JSONObject pro = comm_info.getJSONObject("pro");
+					String date = pro.getString("date");//发票日期
+					String type = pro.getString("type");//发票类型
+					String cname = pro.getString("cname");//发票类型名称
+					JSONObject price = comm_info.getJSONObject("price");
+					String amount = "";
+					String total = "";
+					String dtax = "";
+					//专票带税额,不是专票无税金额=价税合计
+					if(type.equals("1")||type.equals("28")||type.equals("32")){
+						amount = price.getString("amount");//无税金额
+						total = price.getString("total");//价税合计
+						dtax = price.getString("dtax");//可抵扣税额
 					}
-				}else{
+					else{
+						amount = price.getString("total");//无税金额
+						total = amount;//价税合计
+						dtax = "0";//可抵扣税额
+						trate = "0";//非专票税率也为0
+					}
+					JSONObject buyer = comm_info.getJSONObject("buyer");
+					String mnecode = buyer.getString("tcode");//购买方纳税人识别号
+					String name2 = buyer.getString("company");//购买方公司名称
+					JSONObject payer = comm_info.getJSONObject("payer");
+					String name3 = payer.getString("tcode");//销售方纳税人识别号
+					String name4 = payer.getString("company");//购买方公司名称
+					
+					IDefdocService idefservice = NCLocator.getInstance().lookup(IDefdocService.class);
 					DefdocVO[] vos = new DefdocVO[1];
 					DefdocVO defvo = new DefdocVO();
 					//赋值
-					defvo.setAttributeValue("code", code);
-					defvo.setAttributeValue("name", memo);
+					//为避免自定义档案code,name重复,加上后缀作为区别,仅限发票云获取发票使用
+					defvo.setAttributeValue("code", code+"-"+System.currentTimeMillis());
+					defvo.setAttributeValue("name", memo+"-"+System.currentTimeMillis());
 					defvo.setAttributeValue("memo", name );
 					defvo.setAttributeValue("mnecode", mnecode);
 					defvo.setAttributeValue("name2", name2);
@@ -152,56 +139,55 @@ public class ThSelectAction extends AbstractNCAction{
 					defvo.setAttributeValue("shortname4", date);
 					defvo.setAttributeValue("shortname5", cname);
 					defvo.setAttributeValue("shortname6", trate);
+					defvo.setAttributeValue("enablestate", 2);
+					defvo.setAttributeValue("innercode", "1");
 					vos[0] = defvo;
-					try {
-						idefservice.insertDefdocs(pk_group, vos);
-					} catch (BusinessException e) {
-						// TODO 自动生成的 catch 块
-						MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
-									,"保存自定义档案数据:\n"+e.getMessage());
-						return;
+					idefservice.insertDefdocs(pk_group, vos);
 					}
-					
-					MessageDialog.showHintDlg(parentpanel, "提示","获取成功!");
 				}
+			} catch (Exception e) {
+				// TODO 自动生成的 catch 块
+				MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
+						,"保存自定义档案数据:\n"+e.getMessage());
+				return;
 			}
+		MessageDialog.showHintDlg(parentpanel, "提示","获取成功!");
 	}
 	
     @SuppressWarnings("unchecked")
-	private DefdocVO[]  QryDefdocvoInfo(String code){
-        	String sql = "select * from  bd_defdoc where  nvl(dr, 0) = 0 and pk_defdoclist="
-        			+ "(select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0) and code='" + code + "' ";
-        	ArrayList<Object> arrayvos=null;
-        	try {
-				arrayvos=(ArrayList<Object>) iuap.executeQuery(sql, new BeanListProcessor(DefdocVO.class));
-			} catch (BusinessException e) {
-				// TODO 自动生成的 catch 块
-				e.printStackTrace();
-			}
+	private DefdocVO[]  QryDefdocvoInfo(String code) throws Exception{
+        String sql = "select * from  bd_defdoc where  nvl(dr, 0) = 0 and pk_defdoclist="
+        		+ "(select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0) and code='" + code + "' ";
+        ArrayList<Object> arrayvos=null;
+			arrayvos=(ArrayList<Object>) iuap.executeQuery(sql, new BeanListProcessor(DefdocVO.class));
         	
-        	if (arrayvos==null||arrayvos.size()==0) {
-      			return new DefdocVO[0];
-      		}else {
-      			return arrayvos.toArray(new DefdocVO[0]);
-      		}
-        	
-        } 
+        if (arrayvos==null||arrayvos.size()==0) {
+      		return new DefdocVO[0];
+      	}else {
+      		return arrayvos.toArray(new DefdocVO[0]);
+      	}
+    } 
     
     //查询自定义档案的pk
-    private String QryOCRPk(){
+    private String QryOCRPk() throws Exception{
     	String sql = "select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0";
     	Object object = null;
-		try {
 			object = iuap.executeQuery(sql, new ColumnProcessor());
-		} catch (BusinessException e) {
-			// TODO 自动生成的 catch 块
-			e.printStackTrace();
-		}
 		if (object==null) {
 			return null;
 		}else {
 			return object.toString();
 		}
     }
+    
+    
+    //将老数据删除
+    private void DeleteDOC(String vdef17) throws Exception {
+    	SqlBuilder sql = new  SqlBuilder();
+    	sql.append(" name6 = '"+vdef17+"'");
+    	sql.append(" AND innercode = '1'");
+    	sql.append(" AND pk_defdoclist = ( SELECT pk_defdoclist FROM bd_defdoclist WHERE code = 'OCRTHNC' AND nvl( dr, 0 ) = 0 )");
+    	IVOPersistence.deleteByClause(DefdocVO.class, sql.toString());
+    }
 
 }

+ 1 - 1
pu/pu/src/client/nc/ui/pu/m25/editor/card/afteredit/body/OcrRefaft.java

@@ -26,7 +26,7 @@ public class OcrRefaft implements ICardBodyAfterEditEventListener{
 		// 处理PK
 		if (pks == null || pks.length <= 0) {
 			arg0.getBillCardPanel().setHeadItem("vdef19", null);//开票方
-			arg0.getBillCardPanel().setHeadItem("dbilldate", null);//发票日期
+			//arg0.getBillCardPanel().setHeadItem("dbilldate", null);//发票日期
 		    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef17");//发票分类
 		    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntaxrate");//税率
 	 	    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ctaxcodeid");//税码

+ 23 - 19
pu/pu/src/private/nc/bs/ic/base/InvoiceAfterCheckEvent.java

@@ -101,25 +101,29 @@ public class InvoiceAfterCheckEvent implements IBusinessListener{
 								if(date.getYear() != date2.getYear()) {
 									ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"不能跨年报销发票!");
 								}
-								//比较抬头
-								String sql1 = "select name from org_financeorg_v where pk_vid ='"+InvoiceVO.getParent().getAttributeValue("pk_org_v")+"'";
-								String orgname = (String) bs.executeQuery(sql1, new ColumnProcessor());
-								if(!orgname.equals(defdocVO.getName2())) {
-									ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"发票抬头不正确!");
-								}
-								//比较纳税人识别号
-								StringBuffer sql2 = new StringBuffer();
-								sql2.append("SELECT");
-								sql2.append(" name");
-								sql2.append(" FROM");
-								sql2.append(" bd_defdoc ");
-								sql2.append(" WHERE");
-								sql2.append(" pk_defdoclist = ( SELECT pk_defdoclist FROM bd_defdoclist WHERE code = 'CORPYS04' ) ");
-								sql2.append(" AND memo = '"+orgname+"' ");
-								sql2.append(" AND enablestate = 2");
-								String tcode = (String) bs.executeQuery(sql2.toString(), new ColumnProcessor());
-								if(!defdocVO.getMnecode().equals(tcode)) {
-									ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"纳税人识别号不正确!");
+								
+								//特殊发票不存在抬头与纳税人识别号可不做校验
+								if(defdocVO.getName2() != null && !"".equals(defdocVO.getName2())) {
+									//比较抬头
+									String sql1 = "select name from org_financeorg_v where pk_vid ='"+InvoiceVO.getParent().getAttributeValue("pk_org_v")+"'";
+									String orgname = (String) bs.executeQuery(sql1, new ColumnProcessor());
+									if(!orgname.equals(defdocVO.getName2())) {
+										ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"发票抬头不正确!");
+									}
+									//比较纳税人识别号
+									StringBuffer sql2 = new StringBuffer();
+									sql2.append("SELECT");
+									sql2.append(" name");
+									sql2.append(" FROM");
+									sql2.append(" bd_defdoc ");
+									sql2.append(" WHERE");
+									sql2.append(" pk_defdoclist = ( SELECT pk_defdoclist FROM bd_defdoclist WHERE code = 'CORPYS04' ) ");
+									sql2.append(" AND memo = '"+orgname+"' ");
+									sql2.append(" AND enablestate = 2");
+									String tcode = (String) bs.executeQuery(sql2.toString(), new ColumnProcessor());
+									if(!defdocVO.getMnecode().equals(tcode)) {
+										ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"纳税人识别号不正确!");
+									}
 								}
 							}
 						}

+ 63 - 60
pu/pu/src/private/nc/impl/th/ThOcrServiceImpl.java

@@ -705,69 +705,72 @@ public class ThOcrServiceImpl implements IThOcrService{
 		public void UpdateInvoiceStatus(String status, InvoiceVO[] vos) throws Exception {
 			NcLog.info("=======锁定发票、修改开始=======");
 			for (InvoiceVO invoiceVO : vos) {
-				int vostatus = invoiceVO.getParentVO().getStatus();
-				Map<String,String> oamap = QueryOAUserid(invoiceVO.getParent().getAttributeValue("billmaker").toString());
-				//审批结果Y2代表通过 N0代表不通过 R0代表驳回T1报销中
-				InvoiceItemVO[] arrInvoiceItemVO = (InvoiceItemVO[]) invoiceVO.getChildren(InvoiceItemVO.class);
-				List<Map<Object, Object>> listMapVbdef20 = new ArrayList<Map<Object, Object>>();
-				List<String> listVbdef20 = new ArrayList<String>();
-				for (InvoiceItemVO invoiceItemVO : arrInvoiceItemVO) {
-					if(invoiceItemVO.getVbdef20() != null && !"".equals(invoiceItemVO.getVbdef20())) {
-						String[] arrVbdef20 = invoiceItemVO.getVbdef20().split(",");
-						for(String Vbdef20 : arrVbdef20) {
-							StringBuffer sql = new StringBuffer();
-							sql.append("SELECT");
-							sql.append(" shortname2,");
-							sql.append(" name5");
-							sql.append(" FROM");
-							sql.append(" bd_defdoc ");
-							sql.append(" WHERE");
-							sql.append(" pk_defdoc = '"+Vbdef20+"'");
-							Map<Object, Object> mapdoc =  (Map<Object, Object>) iuap.executeQuery(sql.toString(), new MapProcessor());
-							listMapVbdef20.add(mapdoc);
-							listVbdef20.add(mapdoc.get("name5").toString());
+				int vostatus = invoiceVO.getParentVO().getFbillstatus();
+				//只有自由,审批成功,审批不通过才需要修改发票云发票状态
+				if(vostatus == 0 || vostatus == 3 || vostatus == 4){
+					Map<String,String> oamap = QueryOAUserid(invoiceVO.getParent().getAttributeValue("billmaker").toString());
+					//审批结果Y2代表通过 N0代表不通过 R0代表驳回T1报销中
+					InvoiceItemVO[] arrInvoiceItemVO = (InvoiceItemVO[]) invoiceVO.getChildren(InvoiceItemVO.class);
+					List<Map<Object, Object>> listMapVbdef20 = new ArrayList<Map<Object, Object>>();
+					List<String> listVbdef20 = new ArrayList<String>();
+					for (InvoiceItemVO invoiceItemVO : arrInvoiceItemVO) {
+						if(invoiceItemVO.getVbdef20() != null && !"".equals(invoiceItemVO.getVbdef20())) {
+							String[] arrVbdef20 = invoiceItemVO.getVbdef20().split(",");
+							for(String Vbdef20 : arrVbdef20) {
+								StringBuffer sql = new StringBuffer();
+								sql.append("SELECT");
+								sql.append(" shortname2,");
+								sql.append(" name5");
+								sql.append(" FROM");
+								sql.append(" bd_defdoc ");
+								sql.append(" WHERE");
+								sql.append(" pk_defdoc = '"+Vbdef20+"'");
+								Map<Object, Object> mapdoc =  (Map<Object, Object>) iuap.executeQuery(sql.toString(), new MapProcessor());
+								listMapVbdef20.add(mapdoc);
+								listVbdef20.add(mapdoc.get("name5").toString());
+							}
 						}
 					}
-				}
-				if(listMapVbdef20.size() > 0) {
-					JSONObject bodyJson = new JSONObject();
-					//发票云团队id
-					bodyJson.put("cid", cid);
-					//userId报销人id(OA)
-					bodyJson.put("userId", oamap.get("id"));
-					//userId报销人id(OA)
-					bodyJson.put("flag", "3");
-					//发票云发票ID数组
-					bodyJson.put("fids", listVbdef20.toArray());
-					NcLog.info("发票锁定返回json:"+UpdateInvoiceOCR(bodyJson.toString()));
-					//0 未报销 1 报销中 2已报销
-					String  sreim = "0";
-					if("Y".equals(status)) {
-						sreim = "2";
-					}else if("T".equals(status)) {
-						sreim = "1";
-					}
-					JSONObject bodyJson1 = new JSONObject();
-					bodyJson1.put("cid", cid);
-					bodyJson1.put("userId", oamap.get("id"));
-					bodyJson1.put("flag", "2");
-					bodyJson1.put("sreim",sreim);
-					JSONArray arrinfos = new JSONArray();
-					for (Map<Object, Object> map : listMapVbdef20) {
-						long date = System.currentTimeMillis()/ 1000;
-						JSONObject bodyJson2 = new JSONObject();
-						bodyJson2.put("dataid", invoiceVO.getParent().getAttributeValue("pk_invoice"));
-						bodyJson2.put("number", invoiceVO.getParent().getAttributeValue("pk_invoice"));
-						bodyJson2.put("amount", "0".equals(sreim) ? "0.00" : map.get("shortname2"));
-						bodyJson2.put("uid", oamap.get("id"));
-						bodyJson2.put("date",Long.toString(date));
-						bodyJson2.put("name", invoiceVO.getParent().getAttributeValue("pk_invoice"));
-						bodyJson2.put("fid", map.get("name5"));
-						bodyJson2.put("cid", cid);
-						arrinfos.add(bodyJson2);
+					if(listMapVbdef20.size() > 0) {
+						JSONObject bodyJson = new JSONObject();
+						//发票云团队id
+						bodyJson.put("cid", cid);
+						//userId报销人id(OA)
+						bodyJson.put("userId", oamap.get("id"));
+						//userId报销人id(OA)
+						bodyJson.put("flag", "3");
+						//发票云发票ID数组
+						bodyJson.put("fids", listVbdef20.toArray());
+						NcLog.info("发票锁定返回json:"+UpdateInvoiceOCR(bodyJson.toString()));
+						//0 未报销 1 报销中 2已报销
+						String  sreim = "0";
+						if("Y".equals(status)) {
+							sreim = "2";
+						}else if("T".equals(status)) {
+							sreim = "1";
+						}
+						JSONObject bodyJson1 = new JSONObject();
+						bodyJson1.put("cid", cid);
+						bodyJson1.put("userId", oamap.get("id"));
+						bodyJson1.put("flag", "2");
+						bodyJson1.put("sreim",sreim);
+						JSONArray arrinfos = new JSONArray();
+						for (Map<Object, Object> map : listMapVbdef20) {
+							long date = System.currentTimeMillis()/ 1000;
+							JSONObject bodyJson2 = new JSONObject();
+							bodyJson2.put("dataid", invoiceVO.getParent().getAttributeValue("pk_invoice"));
+							bodyJson2.put("number", invoiceVO.getParent().getAttributeValue("pk_invoice"));
+							bodyJson2.put("amount", "0".equals(sreim) ? "0.00" : map.get("shortname2"));
+							bodyJson2.put("uid", oamap.get("id"));
+							bodyJson2.put("date",Long.toString(date));
+							bodyJson2.put("name", invoiceVO.getParent().getAttributeValue("pk_invoice"));
+							bodyJson2.put("fid", map.get("name5"));
+							bodyJson2.put("cid", cid);
+							arrinfos.add(bodyJson2);
+						}
+						bodyJson1.put("infos", arrinfos);
+						NcLog.info("发票锁定修改返回json:"+UpdateInvoiceOCR(bodyJson1.toString()));
 					}
-					bodyJson1.put("infos", arrinfos);
-					NcLog.info("发票锁定修改返回json:"+UpdateInvoiceOCR(bodyJson1.toString()));
 				}
 			}
 		}

+ 172 - 171
pu/pu/src/public/nc/ui/bd/ref/model/StorDocReportRefModel.java

@@ -1,171 +1,172 @@
-package nc.ui.bd.ref.model;
-
-import nc.itf.bd.pub.IBDResourceIDConst;
-import nc.ui.bd.ref.AbstractRefModel;
-import nc.ui.bd.ref.IRefDocEdit;
-import nc.ui.bd.ref.IRefMaintenanceHandler;
-import nc.ui.pub.beans.ValueChangedEvent;
-import nc.vo.bd.stordoc.StordocVO;
-import nc.vo.bd.defdoc.DefdocVO ;      
-import nc.vo.ml.NCLangRes4VoTransl;
-
-/**
- * OCR发票识别参照
- */
-public class StorDocReportRefModel extends AbstractRefModel{
-	 private DefdocDefaultModelUtil util = new DefdocDefaultModelUtil();
-	public StorDocReportRefModel() {
-		super();
-		getRefQueryVO();
-	}
-	
-	 @Override
-	    public void filterValueChanged(ValueChangedEvent changedValue) {
-	        super.filterValueChanged(changedValue);
-	        util.filterValueChanged(this, changedValue);
-	    }
-
-	  
-	 
-	 
-	
-	@Override
-	public void reset() {
-        this.setFieldCode(new String[] {
-                DefdocVO.CODE, DefdocVO.NAME, DefdocVO.MEMO, DefdocVO.MNECODE,DefdocVO.NAME2,DefdocVO.NAME3,DefdocVO.NAME4,
-                DefdocVO.SHORTNAME2,DefdocVO.SHORTNAME5,DefdocVO.SHORTNAME4
-            });
-            this.setFieldName(new String[] {
-            		"发票代码",
-            		"发票号",
-            		"发票名称",
-            		"购买方纳税人识别号",
-            		"购买方公司名称", 
-            		"销售方纳税人识别号",
-            		"销售方公司名称",
-            		"价税合计",
-            		"发票类型",
-            		"发票时间"
-            });
-            this.setHiddenFieldCode(new String[] {
-                DefdocVO.PK_DEFDOC
-            });
-            this.setRefCodeField(DefdocVO.CODE);
-            this.setRefNameField(DefdocVO.NAME);
-            this.setPkFieldCode(DefdocVO.PK_DEFDOC);
-            this.setTableName(this.getPara2());
-            this.setMnecode(new String[] {
-                DefdocVO.MNECODE
-            });
-            this.setOrderPart(DefdocVO.CODE);
-            // 设置数据权限
-            this.setResourceID(this.getResourceCode());
-            final String[] funcodes = util.getFuncode(this.getPara1());
-            // 设置默认不显示停用
-            this.setAddEnableStateWherePart(true);
-            if (util.isContainBuData(this.getPara1())) {
-                this.setFilterRefNodeName(new String[] {
-                    "业务单元" /* -=notranslate=- */
-                });
-            }
-            // 维护
- /*           setRefMaintenanceHandler(new IRefMaintenanceHandler() {
-
-                @Override
-                public String[] getFucCodes() {
-                    return funcodes;
-                }
-
-                @Override
-                public IRefDocEdit getRefDocEdit() {
-                    return null;
-                }
-            });*/
-            this.resetFieldName();
-        }
-
-	/**
-	 * 参照标题 创建日期:(01-4-4 0:57:23)
-	 *
-	 * @return java.lang.String
-	 */
-	public String getRefTitle() {
-		return "OCR识别参照";
-	}
-	
-	
-	public Object getValue(String field) {
-		Object[] values = getValues(field);
-
-		Object value = null;
-		String strValue = "";
-		if (values != null && values.length > 1) {
-			for (Object pkobj : values) {
-				strValue += pkobj + ",";
-			}
-			strValue = strValue.substring(0, strValue.lastIndexOf(","));
-			value = strValue;
-			
-		}else if(values != null && values.length > 0){
-			value = values[0];
-		}
-
-		return value;
-	}
-
-	/**
-	 * 设置不显示参照
-	 */
-	public String[] getHiddenFieldCode() {
-		return new String[] { "pk_defdoc" };
-	}
-
-	/**
-	 * 设置参照表名
-	 */
-	public String getTableName() {
-		return "bd_defdoc";
-	}
-
-	/**
-	 * 设置参照查询规则
-	 * 
-	 */
-	public String getWherePart(){
-		return " isnull(dr, 0) = 0 and pk_defdoclist="
-				+ "(select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0) ";
-	}
-
-	public boolean isMatchPkWithWherePart() {
-		return true;
-	}
-
-	/**
-	 * 获取主键字段,必要
-	 */
-	public String getPkFieldCode() {
-		return DefdocVO.PK_DEFDOC;
-	}
-	
-	private String getResourceCode() {
-        return util.getResourceCode(this.getRefNodeName());
-    }
-	
-//	  /**
-//     * 重写数据权限缓存Key值
-//     */
-//    @Override
-//    protected String getDataPowerSqlKey(String strTableName,
-//            String dataPowerField) {
-//        String pk_org = null;
-//        String tableName = strTableName;
-//        if (strTableName != null) {
-//            tableName = strTableName.trim();
-//        }
-//        String dataPowerKey =
-//                tableName + this.getPara1() + "_" + dataPowerField
-//                        + getDataPowerOperation_code() + pk_org;
-//        return dataPowerKey;
-//    }
-
-}
+package nc.ui.bd.ref.model;
+
+import nc.itf.bd.pub.IBDResourceIDConst;
+import nc.ui.bd.ref.AbstractRefModel;
+import nc.ui.bd.ref.IRefDocEdit;
+import nc.ui.bd.ref.IRefMaintenanceHandler;
+import nc.ui.pub.beans.ValueChangedEvent;
+import nc.vo.bd.stordoc.StordocVO;
+import nc.vo.bd.defdoc.DefdocVO ;      
+import nc.vo.ml.NCLangRes4VoTransl;
+
+/**
+ * OCR发票识别参照
+ */
+public class StorDocReportRefModel extends AbstractRefModel{
+	 private DefdocDefaultModelUtil util = new DefdocDefaultModelUtil();
+	public StorDocReportRefModel() {
+		super();
+		getRefQueryVO();
+	}
+	
+	 @Override
+	    public void filterValueChanged(ValueChangedEvent changedValue) {
+	        super.filterValueChanged(changedValue);
+	        util.filterValueChanged(this, changedValue);
+	    }
+
+	  
+	 
+	 
+	
+	@Override
+	public void reset() {
+        this.setFieldCode(new String[] {
+        		DefdocVO.SHORTNAME5,DefdocVO.SHORTNAME6,DefdocVO.CODE, DefdocVO.NAME, DefdocVO.MEMO, DefdocVO.MNECODE,DefdocVO.NAME2,DefdocVO.NAME3,DefdocVO.NAME4,
+                DefdocVO.SHORTNAME2,DefdocVO.SHORTNAME4
+            });
+            this.setFieldName(new String[] {
+            		"发票类型",
+            		"税率",
+            		"发票代码",
+            		"发票号",
+            		"发票名称",
+            		"购买方纳税人识别号",
+            		"购买方公司名称", 
+            		"销售方纳税人识别号",
+            		"销售方公司名称",
+            		"价税合计",
+            		"发票时间"
+            });
+            this.setHiddenFieldCode(new String[] {
+                DefdocVO.PK_DEFDOC
+            });
+            this.setRefCodeField(DefdocVO.CODE);
+            this.setRefNameField(DefdocVO.NAME);
+            this.setPkFieldCode(DefdocVO.PK_DEFDOC);
+            this.setTableName(this.getPara2());
+            this.setMnecode(new String[] {
+                DefdocVO.MNECODE
+            });
+            this.setOrderPart(DefdocVO.CODE);
+            // 设置数据权限
+            this.setResourceID(this.getResourceCode());
+            final String[] funcodes = util.getFuncode(this.getPara1());
+            // 设置默认不显示停用
+            this.setAddEnableStateWherePart(true);
+            if (util.isContainBuData(this.getPara1())) {
+                this.setFilterRefNodeName(new String[] {
+                    "业务单元" /* -=notranslate=- */
+                });
+            }
+            // 维护
+ /*           setRefMaintenanceHandler(new IRefMaintenanceHandler() {
+
+                @Override
+                public String[] getFucCodes() {
+                    return funcodes;
+                }
+
+                @Override
+                public IRefDocEdit getRefDocEdit() {
+                    return null;
+                }
+            });*/
+            this.resetFieldName();
+        }
+
+	/**
+	 * 参照标题 创建日期:(01-4-4 0:57:23)
+	 *
+	 * @return java.lang.String
+	 */
+	public String getRefTitle() {
+		return "OCR识别参照";
+	}
+	
+	
+	public Object getValue(String field) {
+		Object[] values = getValues(field);
+
+		Object value = null;
+		String strValue = "";
+		if (values != null && values.length > 1) {
+			for (Object pkobj : values) {
+				strValue += pkobj + ",";
+			}
+			strValue = strValue.substring(0, strValue.lastIndexOf(","));
+			value = strValue;
+			
+		}else if(values != null && values.length > 0){
+			value = values[0];
+		}
+
+		return value;
+	}
+
+	/**
+	 * 设置不显示参照
+	 */
+	public String[] getHiddenFieldCode() {
+		return new String[] { "pk_defdoc" };
+	}
+
+	/**
+	 * 设置参照表名
+	 */
+	public String getTableName() {
+		return "bd_defdoc";
+	}
+
+	/**
+	 * 设置参照查询规则
+	 * 
+	 */
+	public String getWherePart(){
+		return " isnull(dr, 0) = 0 and pk_defdoclist="
+				+ "(select pk_defdoclist from bd_defdoclist where code='OCRTHNC' and nvl(dr,0)=0) ";
+	}
+
+	public boolean isMatchPkWithWherePart() {
+		return true;
+	}
+
+	/**
+	 * 获取主键字段,必要
+	 */
+	public String getPkFieldCode() {
+		return DefdocVO.PK_DEFDOC;
+	}
+	
+	private String getResourceCode() {
+        return util.getResourceCode(this.getRefNodeName());
+    }
+	
+//	  /**
+//     * 重写数据权限缓存Key值
+//     */
+//    @Override
+//    protected String getDataPowerSqlKey(String strTableName,
+//            String dataPowerField) {
+//        String pk_org = null;
+//        String tableName = strTableName;
+//        if (strTableName != null) {
+//            tableName = strTableName.trim();
+//        }
+//        String dataPowerKey =
+//                tableName + this.getPara1() + "_" + dataPowerField
+//                        + getDataPowerOperation_code() + pk_org;
+//        return dataPowerKey;
+//    }
+
+}