浏览代码

应付单接口

yaoyu 1 年之前
父节点
当前提交
85dc3d4abc

+ 8 - 0
arap/META-INF/service.upm

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding='gb2312'?>
+<module name="arap">
+    <public>
+ 	   <component name="PayableBilladd" accessProtected="false"  remote="true" singleton="true" tx="NONE" supportAlias="true">
+       <implementation>nc.bs.arap.impl.PayableBillImpl</implementation>
+ 	   </component>
+    </public>
+</module>

+ 514 - 0
arap/arap/src/private/nc/bs/arap/impl/PayableBillImpl.java

@@ -0,0 +1,514 @@
+package nc.bs.arap.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import nc.bs.arap.plugin.GetDataUtil;
+import nc.bs.framework.adaptor.IHttpServletAdaptor;
+import nc.bs.framework.common.InvocationInfoProxy;
+import nc.bs.framework.common.NCLocator;
+import nc.bs.framework.server.ISecurityTokenCallback;
+import nc.bs.servlet.service.BaseServlet;
+import nc.itf.uap.pf.IPFBusiAction;
+import nc.log.NcLog;
+import nc.vo.arap.payable.AggPayableBillVO;
+import nc.vo.arap.payable.PayableBillItemVO;
+import nc.vo.arap.payable.PayableBillVO;
+import nc.vo.org.FinanceOrgVO;
+import nc.vo.pu.m25.entity.InvoiceItemVO;
+import nc.vo.pub.lang.UFBoolean;
+import nc.vo.pub.lang.UFDate;
+import nc.vo.pub.lang.UFDateTime;
+import nc.vo.pub.lang.UFDouble;
+import nc.vo.pub.workflownote.WorkflownoteVO;
+
+public class PayableBillImpl extends BaseServlet implements IHttpServletAdaptor{
+
+	@Override
+	public void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+		String billno = "";
+		try {
+			NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(),"pfxx".getBytes());
+			String createStr = buildJson(req, resp, this.getClass().getName());
+			JSONObject json = JSON.parseObject(createStr);
+			NcLog.info(json.toString());
+			billno = json.getString("billno");
+			InvocationInfoProxy.getInstance().setUserDataSource("NC6337");
+			GetDataUtil.getBillno(billno);
+			checkJson(json);
+			AggPayableBillVO aggPayableBillVO = new AggPayableBillVO ();
+			PayableBillVO payableBillVO = new PayableBillVO();
+			String userPK = GetDataUtil.getUserPK(json.getString("billmaker"));
+			String pk_group = GetDataUtil.getGroupPK(json.getString("pk_group"));
+
+			InvocationInfoProxy.getInstance().setUserId(userPK);//用户主键
+			InvocationInfoProxy.getInstance().setGroupId(pk_group);//指定集团pk
+			//集团
+			payableBillVO.setPk_group(pk_group);
+			String pk_tradetype = json.getString("pk_tradetype");
+			//应付单类型编码
+			payableBillVO.setPk_tradetype(pk_tradetype);
+			String pk_billtypeid = GetDataUtil.getBilltypePK(pk_tradetype,pk_group);
+			//应付类型
+			payableBillVO.setPk_tradetypeid(pk_billtypeid);
+			FinanceOrgVO financeOrgVO = GetDataUtil.getFinanceOrgVO(json.getString("pk_org"));
+			//财务组织
+			payableBillVO.setPk_fiorg(financeOrgVO.getPk_financeorg());
+			//废弃财务组织版本 
+			payableBillVO.setPk_fiorg_v(financeOrgVO.getPk_vid());
+			//应付财务组织
+			payableBillVO.setPk_org(financeOrgVO.getPk_financeorg());
+			//应付财务组织版本
+			payableBillVO.setPk_org_v(financeOrgVO.getPk_vid());
+			//结算财务组织
+			payableBillVO.setSett_org(financeOrgVO.getPk_financeorg());
+			//结算财务组织版本
+			payableBillVO.setSett_org_v(financeOrgVO.getPk_vid());
+			//业务组织
+			payableBillVO.setPu_org(financeOrgVO.getPk_financeorg());
+			//业务组织版本
+			payableBillVO.setPu_org_v(financeOrgVO.getPk_vid());
+			//单据号
+			payableBillVO.setBillno(json.getString("billno"));
+			//单据日期
+			payableBillVO.setBilldate(new UFDate(json.getString("billdate")));
+			if("F1-0xx-01".equals(pk_tradetype)) {
+				//起算日期
+				payableBillVO.setBusidate(new UFDate(json.getString("busidate")));	
+			}else {
+				//起算日期
+				payableBillVO.setBusidate(new UFDate(json.getString("billdate")));	
+			}
+						
+			//制单人
+			payableBillVO.setBillmaker(userPK);
+			//创建人
+			payableBillVO.setCreator(userPK);
+			//创建时间
+			payableBillVO.setCreationtime(new UFDateTime(json.getString("billdate")));
+			String pk_dept = GetDataUtil.getDeptPK(json.getString("pk_deptid"));
+			//费用使用部门
+			payableBillVO.setPk_deptid(pk_dept);
+			//业务部门
+			payableBillVO.setPu_deptid(pk_dept);	
+			String pk_vid = GetDataUtil.getDeptVPK(json.getString("pk_deptid_v"));
+			if(pk_vid == null) {
+				pk_vid = GetDataUtil.getDeptVPK(json.getString("pk_deptid"));
+			}
+			//部门版本信息
+			payableBillVO.setPk_deptid_v(pk_vid);
+			//业务部门版本
+			payableBillVO.setPu_deptid_v(pk_vid);
+					
+			//对方单位名称
+			payableBillVO.setSupplier(GetDataUtil.getSupplierPK(json.getString("supplier")));
+			//组织本币金额
+			payableBillVO.setLocal_money(new UFDouble(json.getString("local_money")));
+			//原币金额
+			payableBillVO.setMoney(new UFDouble(json.getString("local_money")));
+			String recaccount = GetDataUtil.getBankaccsubPK(json.getString("recaccount"));
+			//对方单位银行账户
+			payableBillVO.setRecaccount(recaccount);
+			//发票张数
+			payableBillVO.setAccessorynum(Integer.parseInt(json.getString("accessorynum")));
+			//业务流程
+			payableBillVO.setPk_busitype(GetDataUtil.getBusitypePK(json.getString("pk_busitype")));
+			//单据会计年度
+			payableBillVO.setBillyear(json.getString("billyear"));
+			//单据会计期间
+			payableBillVO.setBillperiod(json.getString("billperiod"));
+			String payaccount = GetDataUtil.getBankaccsubPK(json.getString("payaccount"));
+			//付款银行账户
+			payableBillVO.setPayaccount(payaccount);   
+			String pk_currtype = GetDataUtil.getCurrtypePK(json.getString("pk_currtype"));
+			//币种
+			payableBillVO.setPk_currtype(pk_currtype);
+			String pk_psndoc = GetDataUtil.getPsndocPK(json.getString("pk_psndoc"));
+			//业务员
+			payableBillVO.setPk_psndoc(pk_psndoc);
+			//业务人员
+			payableBillVO.setPu_psndoc(pk_psndoc);
+			//单据来源系统 默认来源采购系统
+			payableBillVO.setSrc_syscode(Integer.parseInt(json.getString("src_syscode")));	
+
+			//是否打印备注
+			payableBillVO.setDef1(GetDataUtil.getDefdocPK(json.getString("def1"), "19", "是否打印备注"));
+			//建议付款日期
+			payableBillVO.setDef3(json.getString("def3"));	
+			//组长审批
+			payableBillVO.setDef4(GetDataUtil.getPsndocPK(json.getString("def4")));
+			//费用承担部门
+			payableBillVO.setDef5(GetDataUtil.getDeptPK(json.getString("def5")));
+			//分包类型
+			payableBillVO.setDef10(GetDataUtil.getDefdocPK(json.getString("def10"), "13", "分包类型"));
+			//员工编号
+			payableBillVO.setDef13(json.getString("def13"));
+			//来源单号
+			payableBillVO.setDef15(json.getString("15"));
+			//预算所在部门
+			payableBillVO.setDef20(GetDataUtil.getDeptPK(json.getString("def20")));
+			//应付单非项目——是否公司费用
+			//预付核销非项目——待核销的预付单号
+			//是否公司费用
+			payableBillVO.setDef21(json.getString("def21"));
+			//对方单位开户行
+			payableBillVO.setDef25(json.getString("def25"));
+			//是否一致
+			payableBillVO.setDef33(json.getString("def33"));			
+			//单据类型编码
+			payableBillVO.setPk_billtype("F1");
+			//单据大类
+			payableBillVO.setBillclass("yf");
+			//国家地区 默认CN
+			String pk_country = GetDataUtil.getCountryzonePK("CN");
+			payableBillVO.setRececountryid(pk_country);
+			//报税国 默认CN
+			payableBillVO.setTaxcountryid(pk_country);
+			//单据所属系统 默认所属应付系统
+			payableBillVO.setSyscode(1);			
+			//结算方式 取表体第一行赋给表头
+			payableBillVO.setPk_balatype(GetDataUtil.getBalatypePK(json.getJSONArray("childrenVO").getJSONObject(0).getString("pk_balatype")));
+			//往来对象  取表体第一行赋给表头
+			payableBillVO.setObjtype(Integer.parseInt(json.getJSONArray("childrenVO").getJSONObject(0).getString("pk_balatype")));
+			payableBillVO.setBillstatus(-1);
+			payableBillVO.setStatus(2);		
+			//是否红冲过
+			payableBillVO.setIsreded(UFBoolean.FALSE);
+			//是否流程单据
+			payableBillVO.setIsflowbill(UFBoolean.FALSE);
+			aggPayableBillVO.setParentVO(payableBillVO);
+			List<PayableBillItemVO> listPayableBillItemVO = new ArrayList<PayableBillItemVO>();
+			JSONArray josns = json.getJSONArray("childrenVO");
+			for (int i = 0; i < josns.size(); i++) {
+				PayableBillItemVO payableBillItemVO = new PayableBillItemVO();
+				JSONObject item = josns.getJSONObject(i);
+				//预算编号
+				payableBillItemVO.setDef1(item.getString("pk_subjcode"));
+				//预算名称
+				payableBillItemVO.setPk_subjcode(GetDataUtil.getInoutbusiclassPK(item.getString("pk_subjcode")));
+				/**
+				 * 应付单非项目——备注
+					应付单项目——备注
+					预付核销非项目——备注
+					预付核销项目——备注
+
+				 */
+				//备注
+				payableBillItemVO.setDef2(item.getString("def2"));
+				//票据/保理申请编号
+				payableBillItemVO.setDef5(item.getString("def5"));
+				//专业
+				payableBillItemVO.setDef6(GetDataUtil.getDefdocPK(item.getString("def6"), "HR016", "专业"));
+				//费用事项
+				payableBillItemVO.setDef7(GetDataUtil.getDefdocPK(item.getString("def7"), "88", "费用事项"));
+				/**
+				 * 内部应付单——备注
+				 */
+				//备注
+				payableBillItemVO.setDef10(item.getString("def10"));
+				//发票号
+				payableBillItemVO.setDef12(item.getString("def12"));
+				//应付单非项目def13参照的自定义档案
+				//预付核销非项目def参照的客户基础档案
+				
+				if("F1-Cxx-04".equals(pk_tradetype)) {
+					//客户
+					payableBillItemVO.setDef13(GetDataUtil.getCustomerPK(item.getString("def13")));	
+				}else {
+					//客户
+					payableBillItemVO.setDef13(GetDataUtil.getDefdocPK(item.getString("def13"), "CUST", "客户"));
+				}
+				
+				//经营合同名称
+				payableBillItemVO.setDef15(GetDataUtil.getDefdocPK(item.getString("def15"), "01", "分包合同"));
+				//原发票日期
+				payableBillItemVO.setDef17(item.getString("def17"));	
+				//项目名称
+				payableBillItemVO.setProject(GetDataUtil.getprojectPK(item.getString("project")));
+				//项目编码
+				payableBillItemVO.setDef18(item.getString("project"));
+				//分包合同名称
+				payableBillItemVO.setDef20(GetDataUtil.getDefdocPK(item.getString("def20"), "01", "分包合同"));
+				//汇款附言
+				payableBillItemVO.setDef21(item.getString("def21"));
+				/**
+				 * 应付单非项目——客户层级
+				 * 应付单项目——成本归属部门
+					预付核销非项目——客户层级
+					预付核销项目——成本归属部门
+
+				 */
+				if("F1-Cxx-02".equals(pk_tradetype) || "F1-Cxx-05".equals(pk_tradetype) || "F1-Cxx-03".equals(pk_tradetype)) {
+					//成本归属部门
+					payableBillItemVO.setDef22(GetDataUtil.getDeptPK(item.getString("def22")));
+
+				}else {
+					//客户层级
+					payableBillItemVO.setDef22(item.getString("def22"));
+				}
+				
+				//应付单非项目使用的自定义23    成本归属部门
+				payableBillItemVO.setDef23(GetDataUtil.getDeptPK(item.getString("def23")));
+				//摘要
+				payableBillItemVO.setDef25(GetDataUtil.getDefdocPK(item.getString("def25"), "999", "摘要"));
+				/**
+				 * 应付单非项目——民航发展基金
+					应付单项目——民航发展基金
+					预付核销非项目——民航发展基金
+					预付核销项目——民航发展基金
+					内部应付单——付款业务性质
+				 */
+				if("F1-0xx-01".equals(pk_tradetype)) {
+					//付款业务性质
+					payableBillItemVO.setDef29(GetDataUtil.getDefdocPK(item.getString("def29"), "YS001", "付款业务性质"));
+				}else {
+					//民航发展基金
+					payableBillItemVO.setDef29(item.getString("def29"));
+				}
+				
+				//费用归属
+				payableBillItemVO.setDef30(GetDataUtil.getDefdocPK(item.getString("def30"), "05", "费用归属"));
+				//人员
+				payableBillItemVO.setDef40(GetDataUtil.getPsndocPK(item.getString("def40")));
+				//发票查看
+				payableBillItemVO.setDef41(item.getString("def41"));				
+				//物料
+				payableBillItemVO.setMaterial(GetDataUtil.getMaterialPK(item.getString("material")));
+				//贷方数量
+				payableBillItemVO.setQuantity_cr("".equals(item.getString("quantity_cr")) ? null : new UFDouble(item.getString("quantity_cr")));
+				//数量余额
+				payableBillItemVO.setQuantity_bal("".equals(item.getString("quantity_cr")) ? null : new UFDouble(item.getString("quantity_cr")));
+				//结算方式
+				payableBillItemVO.setPk_balatype(GetDataUtil.getBalatypePK(item.getString("pk_balatype")));
+				//税码
+				payableBillItemVO.setTaxcodeid(GetDataUtil.getTaxcodePK(item.getString("taxcodeid")));
+				//税率
+				payableBillItemVO.setTaxrate(new UFDouble(item.getString("taxrate")));
+				//单价
+				payableBillItemVO.setPrice("".equals(item.getString("price")) ? null : new UFDouble(item.getString("price")));
+				//本币单价 
+				payableBillItemVO.setLocal_price("".equals(item.getString("price")) ? null : new UFDouble(item.getString("price")));
+				//含税单价
+				payableBillItemVO.setTaxprice("".equals(item.getString("taxprice")) ? null : new UFDouble(item.getString("taxprice")));
+				//本币含税单价
+				payableBillItemVO.setLocal_taxprice("".equals(item.getString("taxprice")) ? null : new UFDouble(item.getString("taxprice")));
+				//组织本币无税金额
+				payableBillItemVO.setLocal_notax_cr(new UFDouble(item.getString("local_notax_cr")));
+				//贷方原币无税金额
+				payableBillItemVO.setNotax_cr(new UFDouble(item.getString("local_notax_cr")));
+				//计税金额
+				payableBillItemVO.setCaltaxmny(new UFDouble(item.getString("local_notax_cr")));
+				//税额
+				payableBillItemVO.setLocal_tax_cr(new UFDouble(item.getString("local_tax_cr")));
+				//组织本币余额
+				payableBillItemVO.setLocal_money_bal(new UFDouble(item.getString("local_money_cr")));
+				//预占用原币余额
+				payableBillItemVO.setOccupationmny(new UFDouble(item.getString("local_money_cr")));
+				//原币余额
+				payableBillItemVO.setMoney_bal(new UFDouble(item.getString("local_money_cr")));
+				//贷方原币金额 
+				payableBillItemVO.setMoney_cr(new UFDouble(item.getString("local_money_cr")));
+				//组织本币金额
+				payableBillItemVO.setLocal_money_cr(new UFDouble(item.getString("local_money_cr")));
+				//往来对象
+				payableBillItemVO.setObjtype(Integer.parseInt(item.getString("objtype")));
+				//对方单位名称
+				payableBillItemVO.setSupplier(GetDataUtil.getSupplierPK(item.getString("supplier")));
+				//付款部门
+				payableBillItemVO.setPk_deptid("".equals(item.getString("pk_deptid")) ? pk_dept : GetDataUtil.getDeptPK(item.getString("pk_deptid")));
+				//部门版本
+				payableBillItemVO.setPk_deptid_v(pk_vid);
+				//行号
+				payableBillItemVO.setRowno(Integer.parseInt(item.getString("rowno")));
+				//发票号
+				String invoiceno = item.getString("invoiceno");
+				InvoiceItemVO invoiceItemVO = GetDataUtil.getInvoice(invoiceno, item.getString("invoicenorowno"));
+				//上层单据主键
+				payableBillItemVO.setTop_billid("".equals(invoiceno) ? null : invoiceItemVO.getPk_invoice());
+				//上层单据类型
+				payableBillItemVO.setTop_billtype(item.getString("top_billtype"));
+				//上层单据行主键
+				payableBillItemVO.setTop_itemid("".equals(invoiceno) ? null : invoiceItemVO.getPk_invoice_b());
+				//上层交易类型 
+				payableBillItemVO.setTop_tradetype(item.getString("top_tradetype"));
+				//购销类型
+				payableBillItemVO.setBuysellflag(Integer.parseInt(item.getString("buysellflag")));
+				//扣税类别
+				payableBillItemVO.setTaxtype(Integer.parseInt(item.getString("taxtype")));
+				//是否逆向征税
+				payableBillItemVO.setOpptaxflag(UFBoolean.FALSE);
+				//单据大类
+				payableBillItemVO.setBillclass("yf");
+				//单据日期
+				payableBillItemVO.setBilldate(new UFDate(json.getString("billdate")));
+				//单据号
+				payableBillItemVO.setBillno(json.getString("billno"));
+				if("F1-0xx-01".equals(pk_tradetype)) {
+					//起算日期
+					payableBillItemVO.setBusidate(new UFDate(json.getString("busidate")));	
+				}else {
+					//起算日期
+					payableBillItemVO.setBusidate(new UFDate(json.getString("billdate")));	
+				}
+				//方向 默认贷方
+				payableBillItemVO.setDirection(-1);
+				payableBillItemVO.setInvoiceno(invoiceno);
+				//不可抵扣税率
+				payableBillItemVO.setNosubtaxrate(new UFDouble(0));
+				//不可抵扣税额
+				payableBillItemVO.setNosubtax(new UFDouble(0));
+				//单据类型编码
+				payableBillItemVO.setPk_billtype("F1");
+				//币种
+				payableBillItemVO.setPk_currtype(pk_currtype);
+				//废弃财务组织
+				payableBillItemVO.setPk_fiorg(financeOrgVO.getPk_financeorg());
+				//废弃财务组织版本 
+				payableBillItemVO.setPk_fiorg_v(financeOrgVO.getPk_vid());
+				//所属集团
+				payableBillItemVO.setPk_group(pk_group);
+				//应付财务组织
+				payableBillItemVO.setPk_org(financeOrgVO.getPk_financeorg());
+				//结算财务组织
+				payableBillItemVO.setSett_org(financeOrgVO.getPk_financeorg());
+				//结算财务组织版本 
+				payableBillItemVO.setSett_org_v(financeOrgVO.getPk_vid());
+				//应付财务组织版本
+				payableBillItemVO.setPk_org_v(financeOrgVO.getPk_vid());
+				//应付类型code
+				payableBillItemVO.setPk_tradetype(pk_tradetype);
+				//应付类型
+				payableBillItemVO.setPk_tradetypeid(pk_billtypeid);
+				//rate组织本币汇率 
+				payableBillItemVO.setRate(new UFDouble(1));
+				//收款银行账户
+				payableBillItemVO.setRecaccount(recaccount);
+				//付款银行账户
+				payableBillItemVO.setPayaccount(payaccount);
+				//行类型
+				payableBillItemVO.setRowtype(0);
+				//发货国
+				payableBillItemVO.setSendcountryid(pk_country);
+				//业务员
+				payableBillItemVO.setPk_psndoc(pk_psndoc);
+				//业务人员
+				payableBillItemVO.setPu_psndoc(pk_psndoc);
+				//业务部门
+				payableBillItemVO.setPu_deptid(pk_dept);
+				//业务部门版本
+				payableBillItemVO.setPu_deptid_v(pk_vid);
+				//业务组织
+				payableBillItemVO.setPu_org(financeOrgVO.getPk_financeorg());
+				//业务组织版本
+				payableBillItemVO.setPu_org_v(financeOrgVO.getPk_vid());
+				payableBillItemVO.setStatus(2);
+				listPayableBillItemVO.add(payableBillItemVO);
+			}
+			aggPayableBillVO.setChildrenVO(listPayableBillItemVO.toArray(new PayableBillItemVO[listPayableBillItemVO.size()]));
+			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+			Object dateTimeString  = payableBillVO.getBilldate();
+			if(dateTimeString != null) {
+			    Date date = format.parse(dateTimeString.toString());
+			    long timestamp = date.getTime();
+			    InvocationInfoProxy.getInstance().setBizDateTime(timestamp);
+			 }
+			
+			
+			WorkflownoteVO Workflownote = new WorkflownoteVO();
+			IPFBusiAction ipf = NCLocator.getInstance().lookup(IPFBusiAction.class);
+			ipf.processAction("SAVE", "F1", Workflownote, aggPayableBillVO, null, null);
+			resp.getWriter().write(formatRSJsonData("成功", "", billno).toString());
+		} catch (Exception e) {
+			resp.getWriter().write(formatRSJsonData("失败",e.getMessage() == null ? "" : e.getMessage(),billno).toString());
+			StringWriter stringWriter = new StringWriter();
+			e.printStackTrace(new PrintWriter(stringWriter));
+			//获取详细信息
+			String msg=stringWriter.getBuffer().toString();
+			NcLog.info(msg);
+		}
+	}
+		
+	private void checkJson(JSONObject json) throws Exception {
+		
+		StringBuffer mags = new StringBuffer();
+		Boolean empty = true;
+		
+		String pk_group = "pk_group";
+		String pk_tradetype = "pk_tradetype";
+		String pk_org = "pk_org";
+		String billno = "billno";
+		String billdate = "billdate";
+		String billmaker = "billmaker";
+		String local_money = "local_money";
+		String accessorynum = "accessorynum";
+		String pk_busitype = "pk_busitype";
+		String billyear = "billyear";
+		String billperiod = "billperiod";
+		String pk_currtype = "pk_currtype";
+		String src_syscode = "src_syscode";
+	
+		String body = "childrenVO";//表体
+		String[] HeadKey = {pk_group,pk_tradetype,pk_org,billno,billdate,billmaker,local_money,accessorynum,
+				pk_busitype,billyear,billperiod,pk_currtype,src_syscode};
+		
+		for (String as : HeadKey) {
+
+			if (json.getString(as).isEmpty()) {
+				empty = false;
+				mags.append("'" + as + "'");
+			}
+		}
+		if (json.getJSONArray(body)==null) {
+			empty = false;
+			mags.append("表体不存在! ");
+		}
+		
+		JSONArray childrenVO = json.getJSONArray("childrenVO");
+		
+		if (childrenVO == null || childrenVO.size() == 0) {
+			throw new Exception("表体内容不可为空!");
+		}
+		
+		String taxcodeid = "taxcodeid";
+		String taxrate = "taxrate";
+		String local_notax_cr = "local_notax_cr";
+		String local_tax_cr = "local_tax_cr";
+		String local_money_cr = "local_money_cr";
+		String objtype = "objtype";
+		String rowno = "rowno";
+		String buysellflag = "buysellflag";
+		String taxtype = "taxtype";
+		for(int i = 0; i < childrenVO.size(); i++) {
+			
+			JSONObject oprepJsonObjectB = childrenVO.getJSONObject(i);
+			String[] BodyKey = {taxcodeid,taxrate,local_notax_cr,local_tax_cr,local_money_cr,
+					objtype,rowno,buysellflag,taxtype};
+			int num = i+1;
+			
+			mags.append("第"+num+"块表体:{");
+			for (String as : BodyKey) {
+				if (oprepJsonObjectB.getString(as).isEmpty()) {
+					empty = false;
+					mags.append("'" + as + "' ");
+				}
+			}
+			mags.append("}");
+		}
+		if (!empty) {
+			throw new Exception("以下字段不可为空:"+mags);
+		}
+	}
+}

+ 259 - 0
arap/arap/src/private/nc/bs/arap/plugin/GetDataUtil.java

@@ -0,0 +1,259 @@
+package nc.bs.arap.plugin;
+
+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.vo.org.DeptVO;
+import nc.vo.org.FinanceOrgVO;
+import nc.vo.pu.m25.entity.InvoiceItemVO;
+
+public class GetDataUtil {
+
+	private static IUAPQueryBS iuap = (IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+	
+	public static void getBillno(String billno)throws Exception {
+		String sql = "select pk_payablebill from ap_payablebill where billno = '"+billno+"' and nvl(dr,0) = 0";
+		String pk_payablebill = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_payablebill != null) {
+			throw new Exception("应付单单据号已存在!");
+		}
+	}
+	
+	// 用户 
+	public static String getUserPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select cuserid from sm_user where  cuserid = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String cuserid = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (cuserid == null) {
+			throw new Exception("获取用户信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return cuserid;
+	}
+	
+	// 部门 
+	public static String getDeptPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_dept from org_dept where  code = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_dept = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_dept == null) {
+			throw new Exception("获取部门信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_dept;
+	}
+	
+	// 部门版本
+	public static String getDeptVPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_vid from org_dept_v where  code = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_vid = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_vid == null) {
+			throw new Exception("获取部门信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_vid;
+	}	
+	
+	
+	// 人员
+	public static String getPsndocPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_psndoc from sm_user where  cuserid = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_psndoc = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_psndoc == null) {
+			throw new Exception("获取人员信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_psndoc;
+	}
+	
+	
+	// 业务流程
+	public static String getBusitypePK(String code) throws Exception {
+		String sql = "select pk_busitype from bd_busitype where  busicode = '"+code+"' and validity = '1' and nvl(dr,0) = 0";
+		String pk_busitype = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_busitype == null) {
+			throw new Exception("获取业务流程信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_busitype;
+	}
+	
+	// 币种
+	public static String getCurrtypePK(String code) throws Exception {
+		String sql = "select pk_currtype from bd_currtype where  code = '"+code+"'and nvl(dr,0) = 0";
+		String pk_currtype = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_currtype == null) {
+			throw new Exception("获取币种信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_currtype;
+	}
+	//组织_业务单元_财务组织
+	public static FinanceOrgVO getFinanceOrgVO(String code) throws Exception {
+		String sql = "select * from org_financeorg where  code = '"+code+"'and nvl(dr,0) = 0";
+		FinanceOrgVO financeOrgVO = (FinanceOrgVO) iuap.executeQuery(sql, new BeanProcessor(FinanceOrgVO.class));
+		if (financeOrgVO == null) {
+			throw new Exception("获取组织_业务单元_财务组织信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return financeOrgVO;
+	}
+	//组织_集团
+	public static String getGroupPK(String code) throws Exception {
+		String sql = "select pk_group from org_group where  code = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_group = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_group == null) {
+			throw new Exception("获取组织_集团信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_group;
+	}
+	//单据类型
+	public static String getBilltypePK(String code,String pk_group) throws Exception {
+		String sql = "select pk_billtypeid from bd_billtype where  pk_billtypecode = '"+code+"' and pk_group = '"+pk_group+"' and nvl(dr,0) = 0";
+		String pk_billtypeid = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_billtypeid == null) {
+			throw new Exception("获取单据类型信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_billtypeid;
+	}
+	
+	
+	//国家地区
+	public static String getCountryzonePK(String code) throws Exception {
+		String sql = "select pk_country from bd_countryzone where  code  = '"+code+"' and nvl(dr,0) = 0";
+		String pk_country = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_country == null) {
+			throw new Exception("获取国家地区信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_country;
+	}
+	//物料
+	public static String getMaterialPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_material from bd_material where  code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_material = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_material == null) {
+			throw new Exception("获取物料信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_material;
+	}
+	//收支项目
+	public static String getInoutbusiclassPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_inoutbusiclass from bd_inoutbusiclass where  code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_inoutbusiclass = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_inoutbusiclass == null) {
+			throw new Exception("获取收支项目信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_inoutbusiclass;
+	}
+	
+	
+	
+	//自定义档案
+	public static String getDefdocPK(String code,String defdoclistcode,String name) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_defdoc from bd_defdoc where pk_defdoclist = (select pk_defdoclist from bd_defdoclist where code = '"+defdoclistcode+"' and nvl(dr,0) = 0) and code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_defdoc = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_defdoc == null) {
+			throw new Exception("获取"+name+"信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_defdoc;
+	}
+	
+	//供应商
+	public static String getSupplierPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_supplier from bd_supplier where  code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_supplier = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_supplier == null) {
+			throw new Exception("获取供应商信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_supplier;
+	}
+	
+	//银行账户
+	public static String getBankaccsubPK(String accnum) throws Exception {
+		if("".equals(accnum)) {
+			return null;
+		}
+		String sql = "select pk_bankaccsub from bd_bankaccsub where  accnum  = '"+accnum+"' and nvl(dr,0) = 0";
+		String pk_bankaccsub = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_bankaccsub == null) {
+			throw new Exception("获取银行账户信息失败,未找到与参数" + accnum + "有关的数据!");
+		}
+		return pk_bankaccsub;
+	}	
+	
+	//结算方式
+	public static String getBalatypePK(String code) throws Exception {
+		String sql = "select pk_balatype from bd_balatype where  code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_balatype = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_balatype == null) {
+			throw new Exception("获取结算方式信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_balatype;
+	}
+	
+	//增值税税码税率
+	public static String getTaxcodePK(String code) throws Exception {
+		String sql = "select pk_taxcode from bd_taxcode where  code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_taxcode = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_taxcode == null) {
+			throw new Exception("获取税码信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_taxcode;
+	}
+	//客户
+	public static String getCustomerPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_customer from bd_customer where  code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_customer = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_customer == null) {
+			throw new Exception("获取客户信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_customer;
+	}	
+	
+	//项目
+	public static String getprojectPK(String code) throws Exception {
+		if("".equals(code)) {
+			return null;
+		}
+		String sql = "select pk_project from bd_project where  project_code  = '"+code+"' and enablestate = '2' and nvl(dr,0) = 0";
+		String pk_project = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_project == null) {
+			throw new Exception("获取项目信息失败,未找到与参数" + code + "有关的数据!");
+		}
+		return pk_project;
+	}	
+		
+	//采购发票子表数据
+	public static InvoiceItemVO getInvoice(String vbillcode,String crowno)throws Exception {
+		if("".equals(vbillcode)) {
+			return null;
+		}
+		String sql = "select * from po_invoice_b where pk_invoice = (select pk_invoice from po_invoice where vbillcode = '"+vbillcode+"' and nvl(dr,0) = 0) and crowno = '"+crowno+"' and nvl(dr,0) = 0";
+		InvoiceItemVO invoiceItemVO = (InvoiceItemVO) iuap.executeQuery(sql, new BeanProcessor(InvoiceItemVO.class));
+		if (invoiceItemVO == null) {
+			throw new Exception("获取采购发票信息失败,未找到与参数" + vbillcode + ","+crowno+"有关的数据!");
+		}
+		return invoiceItemVO;
+	}
+	
+	
+}

+ 4 - 3
pu/META-INF/ocritf.upm

@@ -1,13 +1,14 @@
 <?xml version="1.0" encoding="gbk"?>
-<module name="th">
+<module name="pu">
 	<public>
 		    <!-- ½Ó¿Ú -->
 		    <component priority="0" singleton="true" remote="true" tx="CMT" supportAlias="true">
 	      <interface>nc.itf.th.IThOcrService</interface>
 	      <implementation>nc.impl.th.ThOcrServiceImpl</implementation>
 	    </component>
-	    
-	    <component name="invoiceadd" accessProtected="false"  remote="true" singleton="true" tx="NONE" supportAlias="true">
+	 
+        
+        <component name="invoiceadd" accessProtected="false"  remote="true" singleton="true" tx="CMT" supportAlias="true">
           <implementation>nc.impl.th.InvoiceAddImpl</implementation>
         </component>
 	</public>