Browse Source

代码整合

yaoyu 1 year ago
parent
commit
e4b7ac1a36

BIN
pu/META-INF/hutool-all-5.8.11.jar


+ 4 - 1
pu/pu/src/client/nc/pub/filesystem/newui/ThFileContentPanel.java

@@ -1852,13 +1852,16 @@ public class ThFileContentPanel extends JPanel {
 						 //由于删除太慢,改成自定义档案数据停用
 						 DefdocVO[] deletevos=QryDefdocvoInfo(filname[1]);
 						 IDefdocService idefservice = NCLocator.getInstance().lookup(IDefdocService.class);
+						
 						 try {
 					//		idefservice.deleteDefdocs(InvocationInfoProxy.getInstance().getGroupId(),deletevos);
 							 for (int i = 0; i < deletevos.length; i++) {
 								 DefdocVO defvo =deletevos[i];
 								 defvo.setAttributeValue("enablestate", 3);//停用
 								 idefservice.updateDefdocs(InvocationInfoProxy.getInstance().getGroupId(),new DefdocVO[] {deletevos[i]});
-							}
+								 //删除中间表数据
+								 ocrservice.deleteORC(defvo.getCode(), defvo.getName6(),0);
+							 }
 						} catch (Exception e1) {
 							// TODO 自动生成的 catch 块
 							e1.printStackTrace();

+ 76 - 59
pu/pu/src/client/nc/pub/filesystem/newui/ThOCRAction.java

@@ -6,7 +6,9 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import javax.swing.AbstractAction;
@@ -142,6 +144,8 @@ public class ThOCRAction extends AbstractNCAction{
 				MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
 						,"ocr返回数据校验:\n"+e.getMessage());
 			}
+			//发票的url地址
+			String url = JSONObject.parseObject(idjson).getJSONObject("data").getString("url");
 			JSONObject data = json.getJSONObject("data");
 			JSONArray infos = data.getJSONArray("infos");
 			for(int j = 0;j < infos.size();j++){
@@ -192,19 +196,33 @@ public class ThOCRAction extends AbstractNCAction{
 				}
 				
 				String amount = "";
-				String total = "";
-				String dtax = "";
+				String total = price.getString("total");//价税合计
+				String dtax = price.getString("dtax");//可抵扣税额
+				String ttax = "";
+				
 				//专票带税额,不是专票无税金额=价税合计
-				if(type.equals("1")||type.equals("28")||type.equals("32")){
+//				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
+//				}
+				
+				//如有可抵扣税额,无税金额等于无税金额,税额等于可抵扣税额,税率等于税率
+				//如没有可抵扣税额,无税金额等于无税金额+税额,税额等于0,税率等于0
+				if("0".equals(dtax)) {
+					//无税金额+税额 = 价税合计
+					amount = total;
+					ttax = "0";//税额
+					trate = "0";//税率
+				}else {
 					amount = price.getString("amount");//无税金额
-					total = price.getString("total");//价税合计
-					dtax = price.getString("dtax");//可抵扣税额
-				}
-				else{
-					amount = price.getString("total");//无税金额
-					total = amount;//价税合计
-					dtax = "0";//可抵扣税额
-					trate = "0";//非专票税率也为0
+					ttax = extobj.getString("ttax");//税额
 				}
 				JSONObject buyer = comm_info.getJSONObject("buyer");
 				String mnecode = buyer.getString("tcode");//购买方纳税人识别号
@@ -215,46 +233,42 @@ public class ThOCRAction extends AbstractNCAction{
 				
 				IDefdocService idefservice = NCLocator.getInstance().lookup(IDefdocService.class);
 				
-				DefdocVO[] updatevos=QryDefdocvoInfo(code);
-				if(updatevos.length>0){
-					//自定义档案存在这个编码,走修改
-					DefdocVO defvo =updatevos[0];
-					//赋值
-//					defvo.setAttributeValue("name", name);
-//					defvo.setAttributeValue("memo", memo);
-					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("pid", date);
-					defvo.setAttributeValue("shortname5", cname);
-					defvo.setAttributeValue("shortname6", trate);
-					defvo.setAttributeValue("enablestate", 2);
-					defvo.setAttributeValue("innercode", "0");
-					defvo.setAttributeValue("shortname4", kind);
-					defvo.setAttributeValue("modifier", codenumber);
-					
-					try {
-						idefservice.updateDefdocs(pk_group,updatevos);
-					} catch (BusinessException e1) {
-						MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
-								,"修改自定义档案数据:\n"+e1.getMessage());
-						return;
-					}
-				}else{
+//				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", ttax);
+//					defvo.setAttributeValue("pid", date);
+//					defvo.setAttributeValue("shortname5", cname);
+//					defvo.setAttributeValue("shortname6", trate);
+//					defvo.setAttributeValue("enablestate", 2);
+//					defvo.setAttributeValue("innercode", "0");
+//					defvo.setAttributeValue("shortname4", kind);
+//					defvo.setAttributeValue("modifier", codenumber);
+//					
+//					try {
+//						idefservice.updateDefdocs(pk_group,updatevos);
+//					} catch (BusinessException e1) {
+//						MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
+//								,"修改自定义档案数据:\n"+e1.getMessage());
+//						return;
+//					}
+//				}else{
 					DefdocVO[] vos = new DefdocVO[1];
 					DefdocVO defvo = new DefdocVO();
 					//赋值
 					defvo.setAttributeValue("code", code);
-//					defvo.setAttributeValue("name", name);
-//					defvo.setAttributeValue("memo", memo);
 					defvo.setAttributeValue("name", memo);
 					defvo.setAttributeValue("memo", name );
 					defvo.setAttributeValue("mnecode", mnecode);
@@ -265,31 +279,38 @@ public class ThOCRAction extends AbstractNCAction{
 					defvo.setAttributeValue("name6", vdef17);
 					defvo.setAttributeValue("pk_defdoclist", QryOCRPk());
 					defvo.setAttributeValue("pk_group", pk_group);
-				//	defvo.setAttributeValue("pk_org", pk_org);
 					defvo.setAttributeValue("pk_org", pk_group);
 					defvo.setAttributeValue("datatype", 1);
 					defvo.setAttributeValue("enablestate", 2);
 					defvo.setAttributeValue("shortname", amount);
 					defvo.setAttributeValue("shortname2", total);
-					defvo.setAttributeValue("shortname3", dtax);
+					defvo.setAttributeValue("shortname3", ttax);
 					defvo.setAttributeValue("pid", date);
 					defvo.setAttributeValue("shortname5", cname);
 					defvo.setAttributeValue("shortname6", trate);
-					defvo.setAttributeValue("innercode", "0");
+					defvo.setAttributeValue("dataoriginflag", 0);
 					defvo.setAttributeValue("shortname4", kind);
-					defvo.setAttributeValue("modifier", codenumber);
+					defvo.setAttributeValue("innercode", codenumber);
+					defvo.setAttributeValue("modifier", dtax);
 					vos[0] = defvo;
 					try {
-				//		idefservice.insertDefdocs(pk_org, vos);
 						idefservice.insertDefdocs(pk_group, vos);
-					} catch (BusinessException e) {
+						
+						Map<String,String> map = new HashMap<String,String>();
+						map.put("KYHSJE", "~");
+						map.put("KYWSJE", "~");
+						map.put("JYSE", "~");
+						map.put("FPXZ", url);
+						map.put("VDEF17",vdef17);
+						map.put("NUMBERID",code);
+						ocrservice.addORC(map);
+					} catch (Exception e) {
 						// TODO 自动生成的 catch 块
-						//ExceptionUtils.wrappBusinessException(e.getMessage());
 						MessageDialog.showErrorDlg(parentpanel, NCLangRes.getInstance().getStrByID("pc", "FileManageUI-000000")/*错误*/
 									,"保存自定义档案数据:\n"+e.getMessage());
 						return;
 					}
-				}
+				//}
 				newvo.setFiledesc("OCR已识别");
 				// 修改人
 				newvo.setModifier(InvocationInfoProxy.getInstance()
@@ -333,10 +354,6 @@ public class ThOCRAction extends AbstractNCAction{
 				}
 			}
 		}
-		
-/*		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, "提示","识别成功!");
 	}
 	

+ 2 - 1
pu/pu/src/client/nc/ui/pu/m25/action/processor/CopyActionProcessor.java

@@ -116,7 +116,7 @@ public class CopyActionProcessor implements ICopyActionProcessor<InvoiceVO> {
 				vo.setVbdef17(null);
 				vo.setVbdef20(null);
 				vo.setVbdef12(null);
-				
+				vo.setVbdef11(null);
 			}
 
 		}
@@ -153,6 +153,7 @@ public class CopyActionProcessor implements ICopyActionProcessor<InvoiceVO> {
 			header.setBinitial(UFBoolean.FALSE);
 			header.setDmakedate((UFDate) null);
 			header.setVdef17(null);
+			header.setVdef18(null);
 		}
 	}
 }

+ 0 - 49
pu/pu/src/client/nc/ui/pu/m25/editor/card/afteredit/body/Material.java

@@ -93,55 +93,6 @@ public IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS
     util.setPlanPrice();
     // 触发询价,劳务折扣类物料不参与询价!!
     price.handleQueryPrice();
-    
-   
-    
-    try {
-    	String vbdef20 = (String) event.getBillCardPanel().getBodyValueAt(event.getRow(), "vbdef20");
-	    if(vbdef20 != null) {
-	    	String sql = "select * from bd_defdoc where dr=0 and pk_defdoc = '"+vbdef20+"'";
-	    	DefdocVO defdocvo = (DefdocVO) iuap.executeQuery(sql, new BeanProcessor(DefdocVO.class));
-	    	String qryshuilv = "select pk_taxcode from bd_taxrate where nvl(dr,0) = 0 and pk_taxcode not in (select pk_taxcode from bd_taxcode where code = '0') and taxrate = '"+defdocvo.getShortname6()+"'";
-	    	Object shuilvpk = iuap.executeQuery(qryshuilv, new ColumnProcessor());
-	    	if(shuilvpk == null){
-				ExceptionUtils.wrappBusinessException("税率没有对应税码,请检查!");
-			}
-	    	
-	    	UFDouble SumAmount = UFDouble.ZERO_DBL;//不含税
-			UFDouble SumTotal = UFDouble.ZERO_DBL;//价税合计
-			UFDouble SumTax =UFDouble.ZERO_DBL;//税额
-			Object shortname = defdocvo.getShortname();
-			if(shortname != null && shortname.toString() != ""){
-				SumAmount = SumAmount.add(new UFDouble(shortname.toString()));
-			}
-			Object shortname2 = defdocvo.getShortname2();
-			if(shortname2 != null && shortname2.toString() != ""){
-				SumTotal = SumTotal.add(new UFDouble(shortname2.toString()));
-			}
-			Object shortname3 = defdocvo.getShortname3();
-			if(shortname3 != null && shortname3.toString() != ""){
-				SumTax = SumTax.add(new UFDouble(shortname3.toString()));
-			}
-			
-	    	event.getBillCardPanel().setBodyValueAt(defdocvo.getShortname6(), event.getRow(), "ntaxrate");//税率
-	    	event.getBillCardPanel().setBodyValueAt(shuilvpk, event.getRow(), "ctaxcodeid");//税码
-	    	event.getBillCardPanel().setBodyValueAt(SumAmount, event.getRow(), "nastorigprice");//无税单价
-	    	event.getBillCardPanel().setBodyValueAt(SumAmount, event.getRow(), "nastprice");//本币无税单价
-	    	event.getBillCardPanel().setBodyValueAt(SumAmount, event.getRow(), "nprice");//主本币无税单价
-	    	event.getBillCardPanel().setBodyValueAt(SumAmount, event.getRow(), "norigmny");//无税金额
-	    	event.getBillCardPanel().setBodyValueAt(SumAmount, event.getRow(), "nmny");//本币无税金额
-			event.getBillCardPanel().setBodyValueAt(SumAmount, event.getRow(), "ncalcostmny");//计成本金额
-			event.getBillCardPanel().setBodyValueAt(SumTotal, event.getRow(), "nastorigtaxprice");//含税单价
-			event.getBillCardPanel().setBodyValueAt(SumTotal, event.getRow(), "nasttaxprice");//本币含税单价
-			event.getBillCardPanel().setBodyValueAt(SumTotal, event.getRow(), "ntaxprice");//主本币含税单价
-			event.getBillCardPanel().setBodyValueAt(SumTotal, event.getRow(), "norigtaxmny");//价税合计
-			event.getBillCardPanel().setBodyValueAt(SumTotal, event.getRow(), "ntaxmny");//本币价税合计
-			event.getBillCardPanel().setBodyValueAt(SumTax, event.getRow(), "ntax");//税额
-			
-	    }
-	} catch (Exception e) {
-		ExceptionUtils.wrappBusinessException(e.getMessage());
-	}
     event.getBillCardPanel().getBillModel().setNeedCalculate(true);
    
   }

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

@@ -1,11 +1,13 @@
 package nc.ui.pu.m25.editor.card.afteredit.body;
 
 import java.util.Arrays;
+import java.util.Map;
 
 import nc.bs.framework.common.NCLocator;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.processor.BeanProcessor;
 import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.jdbc.framework.processor.MapProcessor;
 import nc.ui.pu.pub.editor.card.listener.ICardBodyAfterEditEventListener;
 import nc.ui.pub.beans.UIRefPane;
 import nc.ui.pub.beans.constenum.DefaultConstEnum;
@@ -21,50 +23,52 @@ public class OcrRefaft implements ICardBodyAfterEditEventListener{
 	public IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
 	@Override
 	public void afterEdit(CardBodyAfterEditEvent arg0) {
-		
-		UIRefPane ref=(UIRefPane) arg0.getBillCardPanel().getBodyItem("OCR").getComponent();
-		String[] pks = ref.getRefPKs();
-		StringBuffer sbf = new StringBuffer();
-		// 处理PK
-		if (pks == null || pks.length <= 0) {
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef15");//销售方公司
-		    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef17");//发票分类
-		    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntaxrate");//税率
-	 	    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ctaxcodeid");//税码
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastnum");//数量
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nnum");//主数量
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastorigprice");//无税单价
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastprice");//本币无税单价
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nprice");//主本币无税单价
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "norigmny");//无税金额
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nmny");//本币无税金额
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastorigtaxprice");//含税单价
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nasttaxprice");//本币含税单价
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntaxprice");//主本币含税单价
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "norigtaxmny");//价税合计
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntaxmny");//本币价税合计
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntax");//税额
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef20");//主键
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef16");//显示名称
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ncalcostmny");//计成本金额
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef13");//开票内容
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef14");//是否一致
-			arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef12");//显示名称
-			return;
-		}else {
-			for (int i = 0; i < pks.length; i++) {
-				sbf.append(pks[i]+",");
-			}	
-		}
-		
-		UFDouble SumAmount = UFDouble.ZERO_DBL;//不含税
-		UFDouble SumTotal = UFDouble.ZERO_DBL;//价税合计
-		UFDouble SumTax =UFDouble.ZERO_DBL;//税额
-		String shuilv = "";//记录第一条税率,和后面进行对比,若不同则报错不允许保存
-		String supplier = "";//记录第一条供应商,和后面进行对比,若不同则报错不允许保存
-		Object shuilvpk = "";
-		StringBuffer kind = new StringBuffer();
 		try {
+			UIRefPane ref=(UIRefPane) arg0.getBillCardPanel().getBodyItem("OCR").getComponent();
+			String[] pks = ref.getRefPKs();
+			StringBuffer sbf = new StringBuffer();
+			// 处理PK
+			if (pks == null || pks.length <= 0) {
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef15");//销售方公司
+			    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef17");//发票分类
+			    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntaxrate");//税率
+		 	    arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ctaxcodeid");//税码
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastnum");//数量
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nnum");//主数量
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastorigprice");//无税单价
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastprice");//本币无税单价
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nprice");//主本币无税单价
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "norigmny");//无税金额
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nmny");//本币无税金额
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nastorigtaxprice");//含税单价
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "nasttaxprice");//本币含税单价
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntaxprice");//主本币含税单价
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "norigtaxmny");//价税合计
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntaxmny");//本币价税合计
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ntax");//税额
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef20");//主键
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef16");//显示名称
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "ncalcostmny");//计成本金额
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef13");//开票内容
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef14");//是否一致
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef12");//显示名称
+				arg0.getBillCardPanel().setBodyValueAt(null, arg0.getRow(), "vbdef11");//发票地址
+				return;
+			}else {
+				for (int i = 0; i < pks.length; i++) {
+					sbf.append(pks[i]+",");
+				}	
+			}
+			
+			
+			UFDouble SumAmount = UFDouble.ZERO_DBL;//不含税
+			UFDouble SumTotal = UFDouble.ZERO_DBL;//价税合计
+			UFDouble SumTax =UFDouble.ZERO_DBL;//税额
+			String url = null;
+			String shuilv = "";//记录第一条税率,和后面进行对比,若不同则报错不允许保存
+			String supplier = "";//记录第一条供应商,和后面进行对比,若不同则报错不允许保存
+			Object shuilvpk = "";
+			StringBuffer kind = new StringBuffer();
 			if(pks.length > 1){
 				for(int j = 0;j < pks.length;j++){
 					String pk = pks[j];
@@ -95,6 +99,7 @@ public class OcrRefaft implements ICardBodyAfterEditEventListener{
 					}
 				}
 			}
+			//不会存在一行选择多张发票了,遵循运行没问题就不改动原则,不再做处理
 			for(int i = 0;i < pks.length;i++){
 				String pk = pks[i];
 				String qrysql = "select * from bd_defdoc where dr=0 and pk_defdoc = '"+pk+"'";
@@ -112,27 +117,44 @@ public class OcrRefaft implements ICardBodyAfterEditEventListener{
 						// TODO 自动生成的 catch 块
 						ExceptionUtils.wrappBusinessException(e1.getMessage());
 					}
-//					arg0.getBillCardPanel().setHeadItem("vbillcode", defdocvo.getName());//发票号
-//					arg0.getBillCardPanel().setHeadItem("vdef19", defdocvo.getName4());//开票方
-//					arg0.getBillCardPanel().setHeadItem("dbilldate", new UFDate(defdocvo.getPid()));//发票日期
 					arg0.getBillCardPanel().setBodyValueAt(defdocvo.getName4(), arg0.getRow(), "vbdef15");//销售方公司
 					arg0.getBillCardPanel().setBodyValueAt(defdocvo.getShortname5(), arg0.getRow(), "vbdef17");//发票分类
 					arg0.getBillCardPanel().setBodyValueAt(defdocvo.getShortname6(), arg0.getRow(), "ntaxrate");//税率
 					arg0.getBillCardPanel().setBodyValueAt(shuilvpk, arg0.getRow(), "ctaxcodeid");//税码
 					arg0.getBillCardPanel().setBodyValueAt(defdocvo.getCode(), arg0.getRow(), "vbdef16");//发票fid
-					Object shortname = defdocvo.getShortname();
-					if(shortname != null && shortname.toString() != ""){
-						SumAmount = SumAmount.add(new UFDouble(shortname.toString()));
-					}
-					Object shortname2 = defdocvo.getShortname2();
-					if(shortname2 != null && shortname2.toString() != ""){
-						SumTotal = SumTotal.add(new UFDouble(shortname2.toString()));
-					}
-					Object shortname3 = defdocvo.getShortname3();
-					if(shortname3 != null && shortname3.toString() != ""){
-						SumTax = SumTax.add(new UFDouble(shortname3.toString()));
+					
+					StringBuffer sql = new StringBuffer();
+					sql.append("SELECT");
+					sql.append(" * ");
+					sql.append(" FROM");
+					sql.append(" ocr_defdoc");
+					sql.append(" WHERE");
+					sql.append(" vdef17 = '"+defdocvo.getName6()+"' ");
+					sql.append(" AND numberid = '"+defdocvo.getCode()+"' ");
+					Map<String,String> mapdb = (Map<String, String>) iuap.executeQuery(sql.toString(), new MapProcessor());
+					//为null表示为发票上传数据,其次表示为发票云获取的
+					//发票上传的数据可直接使用。发票云获取的可能存在二次使用,取中间表的
+					if(mapdb.get("kyhsje") == null) {
+						Object shortname = defdocvo.getShortname();
+						if(shortname != null && shortname.toString() != ""){
+							SumAmount = SumAmount.add(new UFDouble(shortname.toString()));
+						}
+						Object shortname2 = defdocvo.getShortname2();
+						if(shortname2 != null && shortname2.toString() != ""){
+							SumTotal = SumTotal.add(new UFDouble(shortname2.toString()));
+						}
+						Object shortname3 = defdocvo.getShortname3();
+						if(shortname3 != null && shortname3.toString() != ""){
+							SumTax = SumTax.add(new UFDouble(shortname3.toString()));
+						}
+					}else {
+						SumAmount = SumAmount.add(new UFDouble(mapdb.get("kywsje")));
+						SumTotal = SumTotal.add(new UFDouble(mapdb.get("kyhsje")));
+						SumTax = SumTax.add(new UFDouble(mapdb.get("jyse")));
+						
 					}
 					
+					url = mapdb.get("fpxz");
 					kind.append(defdocvo.getShortname4()+",");
 			}
 			//销售方公司和供应商之间校验是否一致
@@ -155,7 +177,7 @@ public class OcrRefaft implements ICardBodyAfterEditEventListener{
 					arg0.getBillCardPanel().setBodyValueAt("不一致", arg0.getRow(), "vbdef14");
 				}
 			}
-				
+			arg0.getBillCardPanel().setBodyValueAt(url, arg0.getRow(), "vbdef11");//发票地址
 			arg0.getBillCardPanel().setBodyValueAt(1, arg0.getRow(), "nastnum");//数量
 			arg0.getBillCardPanel().setBodyValueAt(1, arg0.getRow(), "nnum");//主数量
 			arg0.getBillCardPanel().setBodyValueAt(SumAmount, arg0.getRow(), "nastorigprice");//无税单价
@@ -178,13 +200,13 @@ public class OcrRefaft implements ICardBodyAfterEditEventListener{
 			DefaultConstEnum refEnumxz = new DefaultConstEnum(sbf.toString().substring(0, sbf.toString().length()-1), ref.getRefShowName());
 			//DefaultConstEnum refEnum = new DefaultConstEnum("1001ZZ1000000097LQJ2", "发票信息已赋值");///默认值(发票信息已赋值)
 			//arg0.getBillCardPanel().setBodyValueAt(refEnum, arg0.getRow(), "OCR");//默认
-			String str = kind.toString();
+			String vbdef13 = kind.toString();
 			byte[] bytes = kind.toString().getBytes("UTF-8");
 			if (bytes.length > 101) {
 			    byte[] truncatedBytes = Arrays.copyOf(bytes, 101);
-			    str = new String(truncatedBytes, "UTF-8");
+			    vbdef13 = new String(truncatedBytes, "UTF-8");
 			}
-			arg0.getBillCardPanel().setBodyValueAt(str, arg0.getRow(), "vbdef13");//开票内容
+			arg0.getBillCardPanel().setBodyValueAt(vbdef13, arg0.getRow(), "vbdef13");//开票内容
 			arg0.getBillCardPanel().setBodyValueAt(sbf.toString().substring(0, sbf.toString().length()-1), arg0.getRow(), "vbdef20");//主键
 			arg0.getBillCardPanel().setBodyValueAt(refEnumxz, arg0.getRow(), "vbdef12");//显示名称
 		} catch (Exception e) {

+ 5 - 44
pu/pu/src/client/nc/ui/pu/m25/editor/card/afteredit/header/Supplier.java

@@ -110,11 +110,16 @@ public class Supplier implements ICardHeadTailAfterEditEventListener {
     price.handleQueryPrice();
     
     //比较表体销售方公司
+    String str = "一致";
     try {
     	int count=event.getBillCardPanel().getRowCount();
         for(int i=0;i<count;i++){
         	String headSupplier = (String) event.getBillCardPanel().getHeadItem("pk_supplier").getValueObject();//供应商
         	String vbdef15 = (String) event.getBillCardPanel().getBodyValueAt(i, "vbdef15"); 
+        	String vbdef20 = (String) event.getBillCardPanel().getBodyValueAt(i, "vbdef20"); 
+        	if(vbdef20 == null) {
+        		continue;
+        	}
     		if(vbdef15 == null && headSupplier == null) {
     			//一致
     			event.getBillCardPanel().setBodyValueAt("一致", i, "vbdef14");
@@ -132,50 +137,6 @@ public class Supplier implements ICardHeadTailAfterEditEventListener {
     				event.getBillCardPanel().setBodyValueAt("不一致", i, "vbdef14");
     			}
     		}
-    		
-    		
-    		String vbdef20 = (String) event.getBillCardPanel().getBodyValueAt(i, "vbdef20");
-    	    if(vbdef20 != null) {
-    	    	String sql = "select * from bd_defdoc where dr=0 and pk_defdoc = '"+vbdef20+"'";
-    	    	DefdocVO defdocvo = (DefdocVO) iuap.executeQuery(sql, new BeanProcessor(DefdocVO.class));
-    	    	String qryshuilv = "select pk_taxcode from bd_taxrate where nvl(dr,0) = 0 and pk_taxcode not in (select pk_taxcode from bd_taxcode where code = '0') and taxrate = '"+defdocvo.getShortname6()+"'";
-    	    	Object shuilvpk = iuap.executeQuery(qryshuilv, new ColumnProcessor());
-    	    	if(shuilvpk == null){
-    				ExceptionUtils.wrappBusinessException("税率没有对应税码,请检查!");
-    			}
-    	    	
-    	    	UFDouble SumAmount = UFDouble.ZERO_DBL;//不含税
-    			UFDouble SumTotal = UFDouble.ZERO_DBL;//价税合计
-    			UFDouble SumTax =UFDouble.ZERO_DBL;//税额
-    			Object shortname = defdocvo.getShortname();
-    			if(shortname != null && shortname.toString() != ""){
-    				SumAmount = SumAmount.add(new UFDouble(shortname.toString()));
-    			}
-    			Object shortname2 = defdocvo.getShortname2();
-    			if(shortname2 != null && shortname2.toString() != ""){
-    				SumTotal = SumTotal.add(new UFDouble(shortname2.toString()));
-    			}
-    			Object shortname3 = defdocvo.getShortname3();
-    			if(shortname3 != null && shortname3.toString() != ""){
-    				SumTax = SumTax.add(new UFDouble(shortname3.toString()));
-    			}
-    			
-    	    	event.getBillCardPanel().setBodyValueAt(defdocvo.getShortname6(), i, "ntaxrate");//税率
-    	    	event.getBillCardPanel().setBodyValueAt(shuilvpk, i, "ctaxcodeid");//税码
-    	    	event.getBillCardPanel().setBodyValueAt(SumAmount, i, "nastorigprice");//无税单价
-    	    	event.getBillCardPanel().setBodyValueAt(SumAmount, i, "nastprice");//本币无税单价
-    	    	event.getBillCardPanel().setBodyValueAt(SumAmount, i, "nprice");//主本币无税单价
-    	    	event.getBillCardPanel().setBodyValueAt(SumAmount, i, "norigmny");//无税金额
-    	    	event.getBillCardPanel().setBodyValueAt(SumAmount, i, "nmny");//本币无税金额
-    			event.getBillCardPanel().setBodyValueAt(SumAmount, i, "ncalcostmny");//计成本金额
-    			event.getBillCardPanel().setBodyValueAt(SumTotal, i, "nastorigtaxprice");//含税单价
-    			event.getBillCardPanel().setBodyValueAt(SumTotal, i, "nasttaxprice");//本币含税单价
-    			event.getBillCardPanel().setBodyValueAt(SumTotal, i, "ntaxprice");//主本币含税单价
-    			event.getBillCardPanel().setBodyValueAt(SumTotal, i, "norigtaxmny");//价税合计
-    			event.getBillCardPanel().setBodyValueAt(SumTotal, i, "ntaxmny");//本币价税合计
-    			event.getBillCardPanel().setBodyValueAt(SumTax, i, "ntax");//税额
-    			
-    	    }
         }
 	} catch (Exception e) {
 		ExceptionUtils.wrappBusinessException(e.getMessage());

File diff suppressed because it is too large
+ 8 - 2
pu/pu/src/client/nc/ui/pubapp/uif2app/actions/MultiSelectDialog.java


+ 100 - 106
pu/pu/src/private/nc/bs/ic/base/InvoiceAfterCheckEvent.java

@@ -8,6 +8,7 @@ import nc.bs.businessevent.IBusinessEvent;
 import nc.bs.businessevent.IBusinessListener;
 import nc.bs.framework.common.NCLocator;
 import nc.bs.pu.event.PUBusinessEvent;
+import nc.impl.pubapp.pattern.rule.IRule;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.processor.ColumnProcessor;
 import nc.jdbc.framework.processor.MapListProcessor;
@@ -26,7 +27,7 @@ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
  * 2023-05-25
  *
  */
-public class InvoiceAfterCheckEvent implements IBusinessListener{
+public class InvoiceAfterCheckEvent implements IRule<InvoiceVO>{
 	
 	
 	private IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class);
@@ -35,123 +36,116 @@ public class InvoiceAfterCheckEvent implements IBusinessListener{
 
 
 	@Override
-	public void doAction(IBusinessEvent event){
+	public void process(InvoiceVO[] vos) {
 		try {
-			if (event instanceof PUBusinessEvent) {
-				PUBusinessEvent busiEvent = (PUBusinessEvent)event;
-				Object[] obj = busiEvent.getObjs();
-				if (obj == null) {
-					 return;
+			if (vos instanceof InvoiceVO[]) {
+				InvoiceVO InvoiceVO = (InvoiceVO) vos[0];
+				InvoiceItemVO[] arrInvoiceItemVO = (InvoiceItemVO[]) InvoiceVO.getChildren(InvoiceItemVO.class);
+				//参照上游单据的信息和发票信息一致性校验(抬头、税率)
+				//发票金额不可超过采购合同/订单金额
+				//购买方发票抬头、税号准确性
+				//来源单据类型
+				String csourcetypecode = arrInvoiceItemVO[0].getCsourcetypecode();
+				//来源单据主键
+				String csourceid = arrInvoiceItemVO[0].getCsourceid();
+				List<Map<Object, Object>> listMap = new ArrayList<Map<Object, Object>>();
+				//来源单据是采购订单
+				if("21".equals(csourcetypecode)) {
+					StringBuffer sql = new StringBuffer();
+					sql.append("SELECT");
+					sql.append(" po_order_b.pk_order_b,");
+					sql.append(" po_order_b.norigtaxmny,");
+					sql.append(" po_order_b.ntaxrate ");
+					sql.append(" FROM");
+					sql.append(" po_order po_order");
+					sql.append(" LEFT JOIN po_order_b po_order_b ON po_order.pk_order = po_order_b.pk_order");
+					sql.append(" WHERE");
+					sql.append(" po_order.pk_order = '"+csourceid+"'");
+					listMap = (List<Map<Object, Object>>) bs.executeQuery(sql.toString(), new MapListProcessor());                
+				}else
+				//来源单据是入库单
+				if("45".equals(csourcetypecode)) {
+					StringBuffer sql = new StringBuffer();
+					sql.append("SELECT");
+					sql.append(" ic_purchasein_b.cgeneralbid,");
+					sql.append(" po_order_b.pk_order_b,");
+					sql.append(" po_order_b.norigtaxmny,");
+					sql.append(" po_order_b.ntaxrate");
+					sql.append(" FROM");
+					sql.append(" ic_purchasein_h ic_purchasein_h");
+					sql.append(" LEFT JOIN ic_purchasein_b ic_purchasein_b ON ic_purchasein_h.cgeneralhid = ic_purchasein_b.cgeneralhid");
+					sql.append(" LEFT JOIN po_order_b po_order_b ON ic_purchasein_b.csourcebillbid = po_order_b.pk_order_b");
+					sql.append(" WHERE");
+					sql.append(" ic_purchasein_h.cgeneralhid = '"+csourceid+"'");
+					listMap = (List<Map<Object, Object>>) bs.executeQuery(sql.toString(), new MapListProcessor());
 				}
-				
-				if (obj instanceof InvoiceVO[]) {
-					InvoiceVO InvoiceVO = (InvoiceVO) obj[0];
-					InvoiceItemVO[] arrInvoiceItemVO = (InvoiceItemVO[]) InvoiceVO.getChildren(InvoiceItemVO.class);
-					//参照上游单据的信息和发票信息一致性校验(抬头、税率)
-					//发票金额不可超过采购合同/订单金额
-					//购买方发票抬头、税号准确性
-					//来源单据类型
-					String csourcetypecode = arrInvoiceItemVO[0].getCsourcetypecode();
-					//来源单据主键
-					String csourceid = arrInvoiceItemVO[0].getCsourceid();
-					List<Map<Object, Object>> listMap = new ArrayList<Map<Object, Object>>();
-					//来源单据是采购订单
-					if("21".equals(csourcetypecode)) {
-						StringBuffer sql = new StringBuffer();
-						sql.append("SELECT");
-						sql.append(" po_order_b.pk_order_b,");
-						sql.append(" po_order_b.norigtaxmny,");
-						sql.append(" po_order_b.ntaxrate ");
-						sql.append(" FROM");
-						sql.append(" po_order po_order");
-						sql.append(" LEFT JOIN po_order_b po_order_b ON po_order.pk_order = po_order_b.pk_order");
-						sql.append(" WHERE");
-						sql.append(" po_order.pk_order = '"+csourceid+"'");
-						listMap = (List<Map<Object, Object>>) bs.executeQuery(sql.toString(), new MapListProcessor());                
-					}else
-					//来源单据是入库单
-					if("45".equals(csourcetypecode)) {
-						StringBuffer sql = new StringBuffer();
-						sql.append("SELECT");
-						sql.append(" ic_purchasein_b.cgeneralbid,");
-						sql.append(" po_order_b.pk_order_b,");
-						sql.append(" po_order_b.norigtaxmny,");
-						sql.append(" po_order_b.ntaxrate");
-						sql.append(" FROM");
-						sql.append(" ic_purchasein_h ic_purchasein_h");
-						sql.append(" LEFT JOIN ic_purchasein_b ic_purchasein_b ON ic_purchasein_h.cgeneralhid = ic_purchasein_b.cgeneralhid");
-						sql.append(" LEFT JOIN po_order_b po_order_b ON ic_purchasein_b.csourcebillbid = po_order_b.pk_order_b");
-						sql.append(" WHERE");
-						sql.append(" ic_purchasein_h.cgeneralhid = '"+csourceid+"'");
-						listMap = (List<Map<Object, Object>>) bs.executeQuery(sql.toString(), new MapListProcessor());
-					}
-//					else {
-//						//只有来源是采购订单或者采购入库单的才进行保存校验
-//						return;
-//					}
-						for (InvoiceItemVO invoiceItemVO : arrInvoiceItemVO) {
-						//没传发票不比较日期、抬头、纳税人识别号
-						if(invoiceItemVO.getVbdef20() != null && !"".equals(invoiceItemVO.getVbdef20())) {
-							String[] arrVbdef20 = invoiceItemVO.getVbdef20().split(",");
-							for(String Vbdef20 : arrVbdef20) {
-								DefdocVO defdocVO = (DefdocVO) service.queryBillOfNCObjectByPKWithDR(DefdocVO.class, Vbdef20, true).getContainmentObject();
-								UFDate date = new UFDate(System.currentTimeMillis());
-								UFDate date2 = new UFDate(defdocVO.getPid());
-								//当年只能报销当年的控制
-								if(date.getYear() != date2.getYear()) {
-									ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"不能跨年报销发票!");
+//				else {
+//					//只有来源是采购订单或者采购入库单的才进行保存校验
+//					return;
+//				}
+					for (InvoiceItemVO invoiceItemVO : arrInvoiceItemVO) {
+					//没传发票不比较日期、抬头、纳税人识别号
+					if(invoiceItemVO.getVbdef20() != null && !"".equals(invoiceItemVO.getVbdef20())) {
+						String[] arrVbdef20 = invoiceItemVO.getVbdef20().split(",");
+						for(String Vbdef20 : arrVbdef20) {
+							DefdocVO defdocVO = (DefdocVO) service.queryBillOfNCObjectByPKWithDR(DefdocVO.class, Vbdef20, true).getContainmentObject();
+							UFDate date = new UFDate(System.currentTimeMillis());
+							UFDate date2 = new UFDate(defdocVO.getPid());
+							//当年只能报销当年的控制
+							if(date.getYear() != date2.getYear()) {
+								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()+"发票抬头不正确!");
 								}
-								
-								//特殊发票不存在抬头与纳税人识别号可不做校验
-								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()+"纳税人识别号不正确!");
-									}
+								//比较纳税人识别号
+								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()+"纳税人识别号不正确!");
 								}
 							}
 						}
-						for (Map<Object, Object> map : listMap) {//
-							//自增没有来源不比较
-							if(invoiceItemVO.getCsourcebid() == null) {
-								continue;
+					}
+					for (Map<Object, Object> map : listMap) {//
+						//自增没有来源不比较
+						if(invoiceItemVO.getCsourcebid() == null) {
+							continue;
+						}
+						//来源可能是采购订单,采购入库单
+						if (invoiceItemVO.getCsourcebid().equals(map.get("pk_order_b")) || invoiceItemVO.getCsourcebid().equals(map.get("cgeneralbid"))) { 
+							UFDouble norigtaxmny1 = invoiceItemVO.getNorigtaxmny();
+							UFDouble norigtaxmny2 = new UFDouble(map.get("norigtaxmny").toString());
+							 //比较价税合计							 
+							if(norigtaxmny1.compareTo(norigtaxmny2) == 1) {
+								ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"不可超过采购订单价税合计金额!");
 							}
-							//来源可能是采购订单,采购入库单
-							if (invoiceItemVO.getCsourcebid().equals(map.get("pk_order_b")) || invoiceItemVO.getCsourcebid().equals(map.get("cgeneralbid"))) { 
-								UFDouble norigtaxmny1 = invoiceItemVO.getNorigtaxmny();
-								UFDouble norigtaxmny2 = new UFDouble(map.get("norigtaxmny").toString());
-								 //比较价税合计							 
-								if(norigtaxmny1.compareTo(norigtaxmny2) == 1) {
-									ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"不可超过采购订单价税合计金额!");
-								}
-								 //比较税率
-								UFDouble ntaxrate1 = invoiceItemVO.getNtaxrate();
-								UFDouble ntaxrate2 = new UFDouble(map.get("ntaxrate").toString());
-								if(ntaxrate1.compareTo(ntaxrate2) != 0) {
-									ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"与采购订单税率不同!");
-								}
-								break;
+							 //比较税率
+							UFDouble ntaxrate1 = invoiceItemVO.getNtaxrate();
+							UFDouble ntaxrate2 = new UFDouble(map.get("ntaxrate").toString());
+							if(ntaxrate1.compareTo(ntaxrate2) != 0) {
+								ExceptionUtils.wrappBusinessException("行:"+invoiceItemVO.getCrowno()+"与采购订单税率不同!");
 							}
+							break;
 						}
 					}
 				}
 			}
+			
 		} catch (Exception e) {
 			ExceptionUtils.wrappBusinessException(""+e.getMessage());
 		}

+ 8 - 1
pu/pu/src/private/nc/bs/ic/base/InvoiceAfterDeleteEvent.java

@@ -1,5 +1,6 @@
 package nc.bs.ic.base;
 
+import nc.bs.dao.BaseDAO;
 import nc.bs.framework.common.NCLocator;
 import nc.impl.pubapp.pattern.rule.IRule;
 import nc.itf.uap.IVOPersistence;
@@ -25,6 +26,7 @@ public class InvoiceAfterDeleteEvent implements IRule<InvoiceVO>{
 				String vdef17 = (String) InvoiceVO.getParent().getAttributeValue("vdef17");
 				if(vdef17 != null && !"".equals(vdef17) ) {
 					DeleteDOC(vdef17);
+					deleteORC(vdef17);
 				}
 		} catch (Exception e) {
 			ExceptionUtils.wrappBusinessException("ɾ³ýʧ°Ü!");
@@ -38,7 +40,12 @@ public class InvoiceAfterDeleteEvent implements IRule<InvoiceVO>{
     	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());
     }
-	
+	private void deleteORC(String vdef17)throws Exception {
+		SqlBuilder sql = new  SqlBuilder();
+		sql.append( " DELETE FROM ocr_defdoc");
+		sql.append( " WHERE vdef17 = '"+vdef17+"'");
+		new BaseDAO().executeUpdate(sql.toString());
+	}
 
 
 

+ 82 - 0
pu/pu/src/private/nc/impl/pu/m25/action/InvoiceInsertAction.java

@@ -0,0 +1,82 @@
+/**
+ * $文件说明$
+ * 
+ * @author zhaoyha
+ * @version 6.0
+ * @see
+ * @since 6.0
+ * @time 2010-2-26 上午10:57:28
+ */
+package nc.impl.pu.m25.action;
+
+import nc.bs.ic.base.InvoiceAfterCheckEvent;
+import nc.bs.pu.m25.maintain.InvoiceSaveBP;
+import nc.bs.pu.m25.plugin.InvoicePluginPoint;
+import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
+import nc.vo.pu.m25.entity.InvoiceItemVO;
+import nc.vo.pu.m25.entity.InvoiceVO;
+import nc.vo.pu.m25.env.InvoiceUIToBSEnv;
+import nc.vo.pu.m25.rule.ParaValidityChkRule;
+
+/**
+ * <p>
+ * <b>本类主要完成以下功能:</b>
+ * <ul>
+ * <li>发票新增动作
+ * </ul>
+ * <p>
+ * <p>
+ * 
+ * @version 6.0
+ * @since 6.0
+ * @author zhaoyha
+ * @time 2010-2-26 上午10:57:28
+ */
+public class InvoiceInsertAction {
+
+  public InvoiceVO[] insert(InvoiceVO[] invoiceVOs, InvoiceUIToBSEnv env) {
+	  
+	  
+	
+    InvoiceVO[] vos = invoiceVOs;
+    
+   
+    //是否一致数据处理
+    //2023-07-2 
+    String str = "一致";
+    Boolean boo = false;
+    InvoiceItemVO[] invoiceItems = vos[0].getChildrenVO();
+    for (int i = 0; i < invoiceItems.length; i++) {
+    	InvoiceItemVO invoiceItemVO = invoiceItems[i];
+    	String vbdef14 = invoiceItemVO.getVbdef14();
+    	String vbdef20 = invoiceItemVO.getVbdef20();
+    	
+    	if("不一致".equals(vbdef14)) {
+    		str = "不一致";
+    	}
+    	if(vbdef20 != null) {
+    		boo = true;
+    	}
+	}
+    if(boo) {
+		 vos[0].getParentVO().setVdef18(str);
+	}
+    // BillTransferTool<InvoiceVO> tool = new BillTransferTool<InvoiceVO>(vos);
+    // v61 根据协议接口调用者传入的一定是全VO
+    // vos = tool.getClientFullInfoBill(); // 前台过来的是修改过的行,这里补充为完成VO
+    CompareAroundProcesser<InvoiceVO> processer =
+        new CompareAroundProcesser<InvoiceVO>(InvoicePluginPoint.UI_INSERT);
+    this.addRule(processer);
+    processer.before(vos, null);
+    InvoiceVO[] savedVos = new InvoiceSaveBP(env).save(vos, null, null);
+    processer.after(savedVos, null);
+    return savedVos;
+  }
+
+  private void addRule(CompareAroundProcesser<InvoiceVO> processer) {
+    processer.addBeforeFinalRule(new ParaValidityChkRule());// 参数正确性检查
+    processer.addAfterFinalRule(new InvoiceAfterCheckEvent());
+    // processer.addAfterRule(new WriteSysLogRule());// 写系统日志
+  }
+
+}

+ 80 - 0
pu/pu/src/private/nc/impl/pu/m25/action/InvoiceUpdateAction.java

@@ -0,0 +1,80 @@
+/**
+ * $文件说明$
+ * 
+ * @author zhaoyha
+ * @version 6.0
+ * @see
+ * @since 6.0
+ * @time 2010-2-26 上午10:59:05
+ */
+package nc.impl.pu.m25.action;
+
+import nc.bs.ic.base.InvoiceAfterCheckEvent;
+import nc.bs.pu.m25.maintain.InvoiceSaveBP;
+import nc.bs.pu.m25.plugin.InvoicePluginPoint;
+import nc.impl.pubapp.pattern.data.bill.tool.BillTransferTool;
+import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
+import nc.vo.pu.m25.entity.InvoiceItemVO;
+import nc.vo.pu.m25.entity.InvoiceVO;
+import nc.vo.pu.m25.env.InvoiceUIToBSEnv;
+import nc.vo.pu.m25.rule.ParaValidityChkRule;
+
+/**
+ * <p>
+ * <b>本类主要完成以下功能:</b>
+ * <ul>
+ * <li>发票修改动作
+ * </ul>
+ * <p>
+ * <p>
+ * 
+ * @version 6.0
+ * @since 6.0
+ * @author zhaoyha
+ * @time 2010-2-26 上午10:59:05
+ */
+public class InvoiceUpdateAction {
+
+  public InvoiceVO[] update(InvoiceVO[] invoiceVOs, InvoiceUIToBSEnv env) {
+    InvoiceVO[] vos = invoiceVOs;
+    //是否一致数据处理
+    //2023-07-2 
+    String str = "一致";
+    Boolean boo = false;
+    InvoiceItemVO[] invoiceItems = vos[0].getChildrenVO();
+    for (int i = 0; i < invoiceItems.length; i++) {
+    	InvoiceItemVO invoiceItemVO = invoiceItems[i];
+    	String vbdef14 = invoiceItemVO.getVbdef14();
+    	String vbdef20 = invoiceItemVO.getVbdef20();
+    	
+    	if("不一致".equals(vbdef14)) {
+    		str = "不一致";
+    	}
+    	if(vbdef20 != null) {
+    		boo = true;
+    	}
+	}
+    if(boo) {
+		 vos[0].getParentVO().setVdef18(str);
+	}
+    vos[0].getParentVO().setVdef18(str);
+    BillTransferTool<InvoiceVO> tool = new BillTransferTool<InvoiceVO>(vos);
+    InvoiceVO[] orgVos = tool.getOriginBills();
+    // v61 根据协议接口调用者传入的一定是全VO
+    // vos = tool.getClientFullInfoBill(); // 前台过来的是修改过的行,这里补充为完成VO
+    CompareAroundProcesser<InvoiceVO> processer =
+        new CompareAroundProcesser<InvoiceVO>(InvoicePluginPoint.UI_UPDATE);
+    this.addRule(processer);
+    processer.before(vos, orgVos);
+    InvoiceVO[] savedVos = new InvoiceSaveBP(env).save(null, vos, orgVos);
+    processer.after(savedVos, orgVos);
+    return savedVos;
+  }
+
+  private void addRule(CompareAroundProcesser<InvoiceVO> processer) {
+    processer.addBeforeFinalRule(new ParaValidityChkRule());// 参数正确性检查
+    processer.addAfterFinalRule(new InvoiceAfterCheckEvent());
+    // processer.addAfterRule(new WriteSysLogRule());// 写系统日志
+  }
+
+}

+ 58 - 7
pu/pu/src/private/nc/impl/th/ThOcrServiceImpl.java

@@ -21,6 +21,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.io.FileOutputStream;
+
+import nc.bs.dao.BaseDAO;
 import nc.bs.dao.DAOException;
 import nc.bs.framework.common.InvocationInfoProxy;
 import nc.bs.framework.common.NCLocator;
@@ -54,6 +56,7 @@ import nc.pub.toolkits.Toolkits;
 import nc.th.redistoken.RedisTokenManager;
 import nc.vo.pub.filesystem.NCFileNode;
 import nc.vo.pub.lang.UFDouble;
+import nc.vo.pubapp.pattern.pub.SqlBuilder;
 import nc.vo.th.ocr.OCRInvoiceVO;
 import weaver.fna.invoice.utils.InvoiceCloudAESUtil;
 /**
@@ -749,7 +752,6 @@ public class ThOcrServiceImpl implements IThOcrService{
 							    	//查询该发票已使用价税合计,无税金额,税额
 									StringBuffer sql = new StringBuffer();
 									sql.append("SELECT");
-									//sql.append(" LISTAGG(po_invoice.vbillcode, ',') WITHIN GROUP (ORDER BY po_invoice.vbillcode) AS vbillcode,");
 									sql.append(" SUM( po_invoice_b.norigtaxmny ) as norigtaxmny,");
 									sql.append(" SUM( po_invoice_b.norigmny ) as norigmny,");
 									sql.append(" SUM( po_invoice_b.ntax ) as ntax");
@@ -771,18 +773,14 @@ public class ThOcrServiceImpl implements IThOcrService{
 									UFDouble sumNorigtaxmny = new UFDouble(objectNorigtaxmny == null ? 0.00 : Double.valueOf(objectNorigtaxmny.toString()));
 									UFDouble sumNorigmny = new UFDouble(objectNorigmny == null ? 0.00 : Double.valueOf(objectNorigmny.toString()));
 									UFDouble sumNtax = new UFDouble(objectNtax == null ? 0.00 : Double.valueOf(objectNtax.toString()));
-									//我有预感会要具体的提示,先不放出来避免他得寸进尺!!!!!
 									if(sumNorigtaxmny.add(norigtaxmny).compareTo(shortname2)>0) {
-										// throw new Exception("行:"+invoiceItemVO.getCrowno()+"发票可用余额不足!关联单据"+mappo.get("vbillcode"));
 										 throw new Exception("行:"+invoiceItemVO.getCrowno()+"发票可用余额不足!差:"+(sumNorigtaxmny.add(norigtaxmny)).sub(shortname2));
 									}
 									if(sumNorigmny.add(norigmny).compareTo(shortname)>0) {
-										 //throw new Exception("行:"+invoiceItemVO.getCrowno()+"无税金额大于发票金额!关联单据"+mappo.get("vbillcode"));
-										 throw new Exception("行:"+invoiceItemVO.getCrowno()+"无税金额大于发票金额!差:"+(sumNorigmny.add(norigmny)).sub(shortname));
+										 throw new Exception("行:"+invoiceItemVO.getCrowno()+"无税金额大于发票可用金额!差:"+(sumNorigmny.add(norigmny)).sub(shortname));
 									}
 									if(sumNtax.add(ntax).compareTo(shortname3)>0) {
-										 throw new Exception("行:"+invoiceItemVO.getCrowno()+"税额大于发票税额!差:"+(sumNtax.add(ntax)).sub(shortname3));
-										 //throw new Exception("行:"+invoiceItemVO.getCrowno()+"税额大于发票税额!关联单据"+mappo.get("vbillcode"));
+										 throw new Exception("行:"+invoiceItemVO.getCrowno()+"税额大于发票可用税额!差:"+(sumNtax.add(ntax)).sub(shortname3));
 									}
 								}
 								StringBuffer sql2 = new StringBuffer();
@@ -889,6 +887,59 @@ public class ThOcrServiceImpl implements IThOcrService{
 	        
 		}
 		
+		/**
+		 *  将发票数据存储关联表
+		 */
+		@Override
+		public void addORC(Map<String,String> map) throws Exception {
+			// 组装新增SQL语句
+			InvocationInfoProxy.getInstance().getUserDataSource();
+			StringBuilder insertSQL = new StringBuilder("INSERT INTO ocr_defdoc VALUES (");
+			insertSQL.append("'").append(map.get("KYHSJE")).append("', ");
+			insertSQL.append("'").append(map.get("KYWSJE")).append("', ");
+			insertSQL.append("'").append(map.get("JYSE")).append("', ");
+			insertSQL.append("'").append(map.get("FPXZ")).append("', ");
+			insertSQL.append("'").append(map.get("NUMBERID")).append("', ");
+			insertSQL.append("'").append(map.get("VDEF17")).append("') ");
+			new BaseDAO().executeUpdate(insertSQL.toString());
+			
+		}
+		
+		/**
+		 * 删除发票关联表数据
+		 * 
+		 */
+		@Override
+		public void deleteORC(String number,String vdef17,int type) throws Exception {
+			String[] arrNumber = number.split(",");
+			StringBuilder deleteSQL = new StringBuilder("DELETE FROM ocr_defdoc");
+			deleteSQL.append(" WHERE");
+			deleteSQL.append(" vdef17 = '"+vdef17+"'");
+			//注意发票识别的信息number没有时间戳,发票云获取的信息有时间戳
+			//0本地上传  1发票获取
+			if(type == 1) {
+				if(arrNumber.length == 1) {
+					deleteSQL.append(" AND SUBSTR(NUMBERID, 1, INSTR(NUMBERID, '—')-1) = '"+arrNumber[0].toString()+"'");
+		    	}else {
+		    		SqlBuilder sqlb = new SqlBuilder();
+					sqlb.append("SUBSTR(NUMBERID, 1, INSTR(NUMBERID, '—')-1)", arrNumber);
+					deleteSQL.append(" AND  "+sqlb.toString());
+		    	}
+			}else {
+				if(arrNumber.length == 1) {
+					deleteSQL.append(" AND NUMBERID = '"+arrNumber[0].toString()+"'");
+		    	}else {
+		    		SqlBuilder sqlb = new SqlBuilder();
+					sqlb.append("NUMBERID", arrNumber);
+					deleteSQL.append(" AND  "+sqlb.toString());
+		    	}	
+			}
+			
+			
+			
+			new BaseDAO().executeUpdate(deleteSQL.toString());
+		}
+		
 		
 		private Map<String,String> QueryOAUserid(String cuserid) throws Exception {
 			StringBuffer sql = new StringBuffer();

+ 12 - 0
pu/pu/src/public/nc/itf/th/IThOcrService.java

@@ -6,6 +6,7 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.httpclient.HttpException;
 
@@ -98,4 +99,15 @@ public interface IThOcrService {
 	 */
 	public JSONObject SelectORCInvoice(String token) throws Exception;
 	
+	
+	/**
+	 * ½«·¢Æ±Êý¾Ý´æ´¢¹ØÁª±í
+	 * @param object
+	 * @throws Exception
+	 */
+	public void addORC(Map<String,String> map) throws Exception;
+	
+	
+	public void deleteORC(String number,String vdef17,int type)throws Exception;
+	
 }

+ 3 - 2
pu/pu/src/public/nc/ui/bd/ref/model/StorDocReportRefModel.java

@@ -32,8 +32,8 @@ public class StorDocReportRefModel extends AbstractRefModel{
 	@Override
 	public void reset() {
         this.setFieldCode(new String[] {
-        		DefdocVO.SHORTNAME5,DefdocVO.SHORTNAME,"shortname3",DefdocVO.SHORTNAME6,"shortname2",
-        		"modifier", DefdocVO.NAME, DefdocVO.MEMO, DefdocVO.MNECODE,DefdocVO.NAME2,DefdocVO.NAME3,DefdocVO.NAME4,
+        		DefdocVO.SHORTNAME5,DefdocVO.SHORTNAME,"shortname3","modifier",DefdocVO.SHORTNAME6,"shortname2",
+        		"innercode", DefdocVO.NAME, DefdocVO.MEMO, DefdocVO.MNECODE,DefdocVO.NAME2,DefdocVO.NAME3,DefdocVO.NAME4,
         		DefdocVO.PID,
         		DefdocVO.SHORTNAME4
             });
@@ -41,6 +41,7 @@ public class StorDocReportRefModel extends AbstractRefModel{
             		"发票类型",
             		"发票金额",
             		"税额",
+            		"可抵扣税额",
             		"税率",
             		"价税合计",
             		"发票代码",

Some files were not shown because too many files changed in this diff