浏览代码

销售出库重销售订单发起

zthwr 1 年之前
父节点
当前提交
ab5c293c4d
共有 1 个文件被更改,包括 211 次插入128 次删除
  1. 211 128
      mmpac/mmpac/src/client/u8c/ui/mmpac/action/ToSaleOutDialog.java

+ 211 - 128
mmpac/mmpac/src/client/u8c/ui/mmpac/action/ToSaleOutDialog.java

@@ -19,13 +19,21 @@ import javax.swing.BorderFactory;
 import javax.swing.JSplitPane;
 import javax.swing.border.BevelBorder;
 
+import cn.hutool.core.lang.UUID;
 import nc.bs.framework.common.NCLocator;
+import nc.bs.uap.oid.OidGenerator;
 import nc.hr.utils.PubEnv;
+import nc.itf.am.prv.ISale;
+import nc.itf.scm.so.so001.ISaleOrder;
 import nc.itf.uap.IUAPQueryBS;
 import nc.itf.uap.pf.IPFBusiAction;
 import nc.itf.uap.pf.IplatFormEntry;
+import nc.jdbc.framework.generator.IdGenerator;
+import nc.jdbc.framework.generator.SequenceGenerator;
 import nc.jdbc.framework.processor.BeanListProcessor;
 import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.md.data.access.NCObject;
+import nc.md.persist.framework.IMDPersistenceQueryService;
 import nc.ui.pub.ClientEnvironment;
 import nc.ui.pub.beans.MessageDialog;
 import nc.ui.pub.beans.UIButton;
@@ -36,23 +44,29 @@ import nc.ui.pub.bill.BillCardPanel;
 import nc.ui.pub.bill.BillEditEvent;
 import nc.ui.pub.bill.BillEditListener;
 import nc.ui.querytemplate.QueryConditionDLG;
+import nc.vo.am.sale.SaleBillVO;
+import nc.vo.am.sale.SaleHeadVO;
 import nc.vo.bd.invdoc.InvbasdocVO;
 import nc.vo.bd.invdoc.InvmandocVO;
 import nc.vo.hr.tools.pub.HRAggVO;
 import nc.vo.ic.pub.bill.GeneralBillHeaderVO;
-import nc.vo.ic.pub.bill.GeneralBillItemVO;
 import nc.vo.ic.pub.bill.GeneralBillVO;
 import nc.vo.pub.BusinessException;
 import nc.vo.pub.CircularlyAccessibleValueObject;
 import nc.vo.pub.VOStatus;
 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.pf.PfUtilWorkFlowVO;
 import nc.vo.pub.workflownote.WorkflownoteVO;
 import nc.vo.pubapp.pattern.pub.SqlBuilder;
 import nc.vo.querytemplate.TemplateInfo;
+import nc.vo.so.so001.SaleOrderVO;
+import nc.vo.so.so001.SaleorderBVO;
+import nc.vo.so.so001.SaleorderHVO;
 import u8c.bs.servlet.service.GetBaseDAOUtil;
+import u8c.bs.upifsp.pub.UpifsTool;
 import u8c.itf.mmpac.mmpac.IOrderTotalInfo;
 import u8c.pubitf.ic.out.ISaleOutMaintainAPI;
 import u8c.vo.OrderInVO;
@@ -77,11 +91,10 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 	private ClientEnvironment ce = ClientEnvironment.getInstance();
 	private HRAggVO aggvo;
 	private OrderInVO[] inArrays = null;
-	ISaleOutMaintainAPI isaleout = NCLocator.getInstance().lookup(ISaleOutMaintainAPI.class);
-	IOrderTotalInfo iorder = NCLocator.getInstance().lookup(IOrderTotalInfo.class);
-	IplatFormEntry iIplatFormEntry = NCLocator.getInstance().lookup(IplatFormEntry.class);
-	
-
+	private  ISaleOutMaintainAPI isaleout = NCLocator.getInstance().lookup(ISaleOutMaintainAPI.class);
+	private  ISaleOrder isoservice = (ISaleOrder) NCLocator.getInstance().lookup(ISaleOrder.class.getName());
+	private  IOrderTotalInfo iorder = NCLocator.getInstance().lookup(IOrderTotalInfo.class);
+	private IplatFormEntry iIplatFormEntry = NCLocator.getInstance().lookup(IplatFormEntry.class);
 	public ToSaleOutDialog(HRAggVO aggvo) {
 		super();
 		initialize(aggvo);
@@ -108,13 +121,14 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 		setName("saleoutdlg");
 		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
 		setTitle("生产总订单入库-销售出库");
-//		setSize(1000,360);
-		setSize(dimension.width-100,dimension.height-200);
+		setSize(dimension.width-150,dimension.height-350);
+		int width=dimension.width;
+		int height=dimension.height;
+		MessageDialog.showHintDlg(mainpanel, "成功", width+"功!"+height);
 		this.setResizable(true);
 		add(getUIPanel0(), BorderLayout.NORTH);
 		add(getUIPanel2(), BorderLayout.CENTER);
-//		setLocation((dimension.width-550)/2, (dimension.height-300)/2);
-		setLocation(100/2, 200/2);
+		setLocation(150/2, 350/2);
 //		setContentPane(getMainPanel());
 		addListenerEvent();
 		this.aggvo = aggvo;
@@ -177,7 +191,7 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 			mainpanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
 			mainpanel.setTopComponent(getJlcardPanel());
 			mainpanel.setBottomComponent(getJlbtnpanel());
-			mainpanel.setDividerLocation(750);//分割位置
+			mainpanel.setDividerLocation(550);//分割位置
 			mainpanel.setOneTouchExpandable(true);
 			mainpanel.setDividerSize(8);
 		}
@@ -412,54 +426,67 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 					MessageDialog.showHintDlg(mainpanel, "提示", "请勾选要生成销售出库的数据");
 					return;
 				}
+				
 				OrderMainVO headvo = (OrderMainVO) this.aggvo.getParentVO();
 				//业务类型
 				String billtype=headvo.getBusitype();
 				String pk_corp = headvo.getPk_corp();
 				String pk_order = headvo.getPk_order();
 				String prjcode = headvo.getProjectid();//项目管理主键
-				GeneralBillVO[] aggvos = new GeneralBillVO[1];
-				GeneralBillVO aggvo = new GeneralBillVO();
-				GeneralBillHeaderVO icheadvo = new GeneralBillHeaderVO();
-				icheadvo.setPk_corp(pk_corp);
-				icheadvo.setPk_calbody(GetBaseDAOUtil.getcalpk(pk_corp));
-				icheadvo.setDbilldate(PubEnv.getLoginDate());
-				icheadvo.setCoperatorid(PubEnv.getPk_user());
-				//收发类别
-				icheadvo.setCdispatcherid(getpkrdcl("02"));
-				//仓库ID
-				if("工装".equals(billtype)) {
-					icheadvo.setCwarehouseid(GetBaseDAOUtil.getstordocpk("GZ001"));//仓库必填
-				}else if("家装".equals(billtype)) {
-					icheadvo.setCwarehouseid(GetBaseDAOUtil.getstordocpk("JZ002"));//仓库必填
-				}
-				icheadvo.setBoutretflag(UFBoolean.FALSE);//是否退回 
-				icheadvo.setBsalecooppur(UFBoolean.FALSE); // 销售出是否已协同生成采购入 
-				icheadvo.setVnote("来源生产总订单");//备注
-				icheadvo.setCbilltypecode("4C");
-				icheadvo.setBassetcard(UFBoolean.FALSE);
-		//		icheadvo.setCbiztypeid("1001V51000000000002V");//业务流程
-		//		String def1 = GetBaseDAOUtil.getJobbasfilDef1("prjcode");
+				SaleOrderVO [] saleaggvos=new SaleOrderVO [1];
+				SaleOrderVO  saleaggvo=new SaleOrderVO();
+				SaleorderHVO saleheadvo =new  SaleorderHVO();
+				//项目编码 pk_defdoc9
+				saleheadvo.setAttributeValue("pk_defdoc9", prjcode);
+				//项目名称pk_defdoc10
+				saleheadvo.setAttributeValue("pk_defdoc10", prjcode);
+				//加工单号pk_defdoc2
+				saleheadvo.setAttributeValue("pk_defdoc2", headvo.getDef1());
+				saleheadvo.setVnote("来源生产总订单");//备注
+				saleheadvo.setAttributeValue("pk_defdoc8", billtype);//业务类型
+				saleheadvo.setAttributeValue("bcooptopo", "N");//是否已协同生成采购订单
+				saleheadvo.setBfreecustflag(UFBoolean.FALSE);//是否散户
+				saleheadvo.setBinitflag(UFBoolean.FALSE);//期初标志
+				saleheadvo.setBinvoicendflag(UFBoolean.FALSE);//开票关闭标记
+				saleheadvo.setBoutendflag(UFBoolean.FALSE);//出库关闭标记
+				saleheadvo.setBoverdate(UFBoolean.FALSE);//是否超帐期
+				saleheadvo.setAttributeValue("bpocooptome", "N");//是否由采购订单协同生成 
+				saleheadvo.setBreceiptendflag(UFBoolean.FALSE);//发货关闭标记 
+				saleheadvo.setBretinvflag(UFBoolean.FALSE);//退货标记
+				saleheadvo.setBtransendflag(UFBoolean.FALSE);//运输关闭标志
+				//capproveid 审批人   dapprovedate 审批日期  Daudittime  审批时间
+				saleheadvo.setCbiztype(getpkbustype("so02"));//业务类型
+				saleheadvo.setCcalbodyid(getvalue("pk_calbody", "bd_calbody", "bodycode", "1001"));// 库存组织
 				String def1 = GetBaseDAOUtil.getJobbasmngDef1(prjcode);
-				icheadvo.setCcustomerid(getpkcumdoc(def1));//客商管理档案
-				icheadvo.setPk_cubasdocC(def1);//客商基本
-				icheadvo.setCdptid(headvo.getPlandeptid());//部门
-				icheadvo.setFreplenishflag(UFBoolean.FALSE);
-//				icheadvo.setPk_cubasdocC(def1);//客户基本档案
-				icheadvo.setFbillflag(2);
-				icheadvo.setCoperatoridnow(PubEnv.getPk_user());//设置当前操作人
-	//			icheadvo.setAttributeValue("pk_defdoc1", vectors.get(0).get(2)==null?"":vectors.get(0).get(2).toString());//开票类型
-				aggvo.setParentVO(icheadvo);
-				GeneralBillItemVO[] itemvos = new GeneralBillItemVO[execsize];
+				String kh=getpkcumdoc(def1);
+				saleheadvo.setCcustomerid(kh);//客户ID 
+				saleheadvo.setCdeptid(getvalue("pk_deptdoc", "bd_deptdoc", "deptcode", "16")); //部门
+				saleheadvo.setCoperatorid(PubEnv.getPk_user());//制单人 
+				saleheadvo.setCreceiptcorpid(kh);//开票单位
+				saleheadvo.setCreceiptcustomerid(kh);//收货单位
+				saleheadvo.setCreceipttype("30");//单据类型
+				saleheadvo.setCsalecorpid(getvalue("csalestruid", "bd_salestru", "vsalestrucode", "10"));//销售组织
+				saleheadvo.setDbilldate(PubEnv.getLoginDate());//单据日期
+				saleheadvo.setDbilltime(PubEnv.getServerTime());//单据时间
+				saleheadvo.setDmakedate(PubEnv.getLoginDate());//制单日期
+				saleheadvo.setEditionNum("1.0"); ////修订版本号
+				saleheadvo.setFstatus(1);//状态
+				saleheadvo.setNdiscountrate(new UFDouble("100.000000")); // 整单折扣 
+				saleheadvo.setNevaluatecarriage(UFDouble.ZERO_DBL);//预估运费
+	////			saleheadvo.setNheadsummny(new UFDouble("0.88000000")); //金额合计=主数量*数量
+				saleheadvo.setPk_corp(pk_corp);//公司ID 
+	//			saleheadvo.setVreceiveaddress (pk_corp);//收货地址
+				saleaggvo.setParentVO(saleheadvo);
+				SaleorderBVO[]  salebodyvos=new SaleorderBVO[execsize];
 				Map<String, UFDouble> updatemap = new HashMap<>();
 				int k = 0;
 				for(int j = 0; j < vectors.size(); j++) {
 					Vector<Object> vector = (Vector<Object>)vectors.get(j);
 					//自定义项4为勾选按钮 :勾选为Y 没有勾选是null
 					if(null!=vector.get(0) &&  "Y".equals(vector.get(0).toString())){
-						GeneralBillItemVO itemvo = new GeneralBillItemVO();
+						SaleorderBVO sbvo = new SaleorderBVO();
 						String cmaterialcode = vector.get(8).toString();
-						String pk_invbasdoc = "";//存货pk
+						String pk_invbasdoc = "";//存货pk管理档案主键
 						if(cmaterialcode.startsWith("0001")) {
 							pk_invbasdoc = cmaterialcode;
 						}
@@ -467,111 +494,143 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 							InvbasdocVO invbasvo  = GetBaseDAOUtil.getInvVO(cmaterialcode);
 							pk_invbasdoc = invbasvo.getPrimaryKey();
 						}
-//						String prjcode = vector.get(3).toString();
-//						String cprojectid = "";
-//						if(prjcode.startsWith("1001")) {
-//							cprojectid = prjcode;
-//						}
-//						else {
-//							cprojectid = GetBaseDAOUtil.getprojectid(prjcode);
-//						}
+
 						String cprojectid=prjcode;
 						InvmandocVO invmanvo = GetBaseDAOUtil.getInvmanVO(pk_invbasdoc);
-						String pk_invmandoc = invmanvo.getPrimaryKey();
-						itemvo.setBbarcodeclose(UFBoolean.FALSE);
-						itemvo.setBreturnprofit(UFBoolean.FALSE);
-						itemvo.setBsafeprice(UFBoolean.FALSE);
-						itemvo.setBsourcelargess(UFBoolean.FALSE);
-						itemvo.setBtou8rm(UFBoolean.FALSE);
-						itemvo.setBtransasset(UFBoolean.FALSE);
-						itemvo.setBzgflag(UFBoolean.FALSE);
-						itemvo.setCbodybilltypecode("4C");
+						String pk_invmandoc = invmanvo.getPrimaryKey();//存货档案主键
+						
+						sbvo.setCrowno(j+1+"0");
+						sbvo.setBbindflag(UFBoolean.FALSE);
+						sbvo.setBdericttrans(UFBoolean.FALSE);
+						sbvo.setBlargessflag(UFBoolean.FALSE);
+						sbvo.setBoosflag(UFBoolean.FALSE);
+						sbvo.setBreturnprofit(UFBoolean.FALSE);
+						sbvo.setBsafeprice(UFBoolean.FALSE);
+						sbvo.setBsupplyflag(UFBoolean.FALSE);
+						sbvo.setCadvisecalbodyid(getvalue("pk_calbody", "bd_calbody", "bodycode", "1001"));//建议发货库存组织
+				
+						//仓库ID
 						if("工装".equals(billtype)) {
-							itemvo.setCbodywarehouseid(GetBaseDAOUtil.getstordocpk("GZ001"));//仓库必填
+							sbvo.setCbodywarehouseid(GetBaseDAOUtil.getstordocpk("GZ001"));//附表仓库
 						}else if("家装".equals(billtype)) {
-							itemvo.setCbodywarehouseid(GetBaseDAOUtil.getstordocpk("JZ002"));//仓库必填
+							sbvo.setCbodywarehouseid(GetBaseDAOUtil.getstordocpk("JZ002"));//附表仓库
 						}
-						itemvo.setCfirstbillhid(pk_order);
-						itemvo.setCfirstbillbid(vector.get(34).toString());
-//						itemvo.setCfirsttype("55A2");
-						itemvo.setCinvbasid(pk_invbasdoc);
-						itemvo.setCinventoryid(pk_invmandoc);
-//						icheadvo.setCinventoryid(pk_invmandoc);
-						itemvo.setCinventorycode(cmaterialcode);
-						itemvo.setCprojectid(cprojectid);
-						itemvo.setCreceieveid(def1);//收货单位基本档案
-						itemvo.setCrowno(Integer.toString((k+1)*10));
-						itemvo.setCsourcebillhid(pk_order);
-						itemvo.setCsourcebillbid(vector.get(34).toString());
-//						itemvo.setCsourcetype("55A2");
-						itemvo.setVsourcerowno("10");
-						itemvo.setDbizdate(PubEnv.getLoginDate());
-						itemvo.setDdeliverdate(PubEnv.getLoginDate());
-						itemvo.setFassertcardflag(UFBoolean.FALSE);
-						itemvo.setFchecked(0);
-						itemvo.setFlargess(UFBoolean.FALSE);
-						itemvo.setIsok(UFBoolean.FALSE);
-						itemvo.setNbarcodenum(new UFDouble(0));//条码数量
+						sbvo.setCcurrencytypeid("00010000000000000001");//原币
+						sbvo.setCinvbasdocid(pk_invbasdoc); //存货档案主键
+						sbvo.setCinventoryid(pk_invmandoc);//存货ID 
+						sbvo.setCinventoryid1(pk_invmandoc);//存货ID 
+						sbvo.setCprojectid(prjcode);//项目
+						
+						 //corder_bid 销售订单附表ID   creceipttype 来源单据类型
+						sbvo.setCquoteunitid(GetBaseDAOUtil.getMeasidByName(vector.get(21).toString()));//报价计量单位
+						sbvo.setCreceiptcorpid(kh); // 收货单位
+						sbvo.setCunitid(GetBaseDAOUtil.getMeasidByName(vector.get(21).toString()));  // 主计量单位
+						sbvo.setCpackunitid(vector.get(28) == null ? null : GetBaseDAOUtil.getMeasidByNames(vector.get(28).toString()));  // 辅单位
+						sbvo.setDconsigndate(PubEnv.getLoginDate());//发货日期 
+						sbvo.setDdeliverdate(PubEnv.getLoginDate()); //交货日期
 						UFDouble ninnum = vector.get(1) == null ? null : new UFDouble(vector.get(1).toString());
-						itemvo.setNoutnum(ninnum);//实出数量
-						itemvo.setNshouldoutnum(ninnum);//应出数量 
+						sbvo.setNnumber(ninnum);//数量
 						UFDouble Hsl = vector.get(49) == null ? null : new UFDouble(vector.get(49).toString());
-						//换算率						
-						itemvo.setHsl(Hsl);
 						//没有换算率则辅数量为空
 						UFDouble ninassistnum =UFDouble.ZERO_DBL;
 						if(Hsl != null) {
 							ninassistnum = new UFDouble(ninnum.div(Hsl).toString(),2);
-							itemvo.setNoutassistnum(new UFDouble(ninassistnum));//实出辅数量
-							itemvo.setNshouldoutassistnum(ninassistnum);//应入辅数量 
+							sbvo.setNpacknumber(new UFDouble(ninassistnum));//辅数量
 						}
-						//辅计量单位ID 
-						itemvo.setCastunitid(vector.get(28) == null ? null : GetBaseDAOUtil.getMeasidByNames(vector.get(28).toString()));	
+						sbvo.setNquoteunitnum(ninnum);//报价单位数量
+					
+						sbvo.setFbatchstatus(1); //批次状态 
+						sbvo.setIncoconfclose("N");
+						sbvo.setCbatchid(vector.get(7)==null?"":vector.get(7).toString());//批次
+						sbvo.setNdiscountrate(new UFDouble("100"));//整单折扣 
+						sbvo.setNexchangeotobrate(UFDouble.ONE_DBL);//折本汇率
+						sbvo.setNitemdiscountrate(new UFDouble("100"));//单品折扣率 
+						sbvo.setNtaxprice(UFDouble.ONE_DBL);//本币含税单价
+						sbvo.setNoriginalcurtaxprice(UFDouble.ONE_DBL);//原币含税单价
+						sbvo.setNprice(new UFDouble("0.88000000"));//本币无税单价
+						sbvo.setNoriginalcurprice(new UFDouble("0.88000000"));//原币无税单价
+						sbvo.setNorgqttaxprc(UFDouble.ONE_DBL);//报价单位含税单价 
+						sbvo.setNorgqtprc(new UFDouble("0.88000000"));//报价单位无税单价 
+						sbvo.setNnetprice(new UFDouble("0.88000000"));//本币无税净价
+						sbvo.setNorgqtnetprc(new UFDouble("0.88000000"));//报价单位无税净价
+						sbvo.setNorgqttaxnetprc(UFDouble.ONE_DBL);//报价单位含税净价
+						sbvo.setNoriginalcurdiscountmny(UFDouble.ZERO_DBL);//原币折扣额
+						sbvo.setNoriginalcurnetprice(new UFDouble("0.88000000"));//原币无税净价
+						sbvo.setNoriginalcurtaxnetprice(UFDouble.ONE_DBL);//原币含税净价
+						//不含税单价=含税单价/(1+13%)
+						UFDouble wsmny=new UFDouble(1/1.13).multiply(ninnum).setScale(2, UFDouble.ROUND_HALF_UP);
+						sbvo.setNmny(wsmny);//本币无税金额
+						sbvo.setNoriginalcurmny(wsmny);//原币无税金额
+						UFDouble noriginalcursummny=UFDouble.ONE_DBL.multiply(ninnum).setScale(2, UFDouble.ROUND_HALF_UP);
+						sbvo.setNoriginalcursummny(noriginalcursummny);//原币价税合计	
+						sbvo.setNsummny(noriginalcursummny);//本币价税合计
+						//税额=价税合计-无税金额
+						sbvo.setNoriginalcurtaxmny(noriginalcursummny.sub(wsmny));//原币税额
+						sbvo.setNtaxmny(new UFDouble(noriginalcursummny.sub(wsmny)));//本币税额
 						
-						itemvo.setPk_bodycalbody(GetBaseDAOUtil.getcalpk(pk_corp));
-						itemvo.setPk_calbody(GetBaseDAOUtil.getcalpk(pk_corp));
-						itemvo.setAttributeValue("pk_corp", pk_corp);
-						itemvo.setVbatchcode(vector.get(7)==null?"":vector.get(7).toString());
-						itemvo.setVfirstbillcode(headvo.getVbillno());
+						sbvo.setNqtnetprc(new UFDouble("0.88000000"));//报价单位本币无税净价
+						sbvo.setNqtprc(new UFDouble("0.88000000"));//报价单位本币无税单价
+						sbvo.setNqttaxnetprc(UFDouble.ONE_DBL);	//报价单位本币含税净价 
+						sbvo.setNqttaxprc(UFDouble.ONE_DBL);//报价单位本币含税单价
+						sbvo.setNquoteunitrate(UFDouble.ONE_DBL);//报价计量单位换算率
+						sbvo.setNreturntaxrate(UFDouble.ZERO_DBL);//出口退税率
+						sbvo.setNtaxrate(new UFDouble("13.000000"));//税率
+						sbvo.setNtaxnetprice(UFDouble.ONE_DBL);//本币含税净价
 						
-						itemvo.setVfree1(vector.get(12)==null?null:vector.get(12).toString());//颜色
-						itemvo.setVfree2(vector.get(14)==null?null:vector.get(14).toString());//合金
-						itemvo.setVfree3(vector.get(13)==null?null:vector.get(13).toString());//定尺
-						itemvo.setVfree4(vector.get(15)==null?null:vector.get(15).toString());//标准
-						
-						itemvo.setAttributeValue("cquoteunitid", GetBaseDAOUtil.getMeasidByName(vector.get(21).toString()));//报价计量单位
-						itemvo.setAttributeValue("cquotecurrency", "00010000000000000001");//报价币种
-						itemvo.setVsourcebillcode(headvo.getVbillno());
-						itemvo.setAttributeValue("pk_defdoc1", vector.get(37)==null?null:vector.get(37).toString());//楼号楼层
-						itemvo.setAttributeValue("pk_defdoc2", vector.get(38)==null?null:vector.get(38).toString());//樘数(数量)
-						itemvo.setAttributeValue("pk_defdoc3", vector.get(39)==null?null:vector.get(39).toString());//框统计
-						itemvo.setAttributeValue("pk_defdoc4", vector.get(40)==null?null:vector.get(40).toString());//扇统计
-						itemvo.setAttributeValue("pk_defdoc5", vector.get(41)==null?null:vector.get(41).toString());//半成品分类
-						itemvo.setAttributeValue("pk_defdoc6", vector.get(42)==null?null:vector.get(42).toString());//面积
-						itemvo.setAttributeValue("pk_defdoc7", vector.get(43)==null?null:vector.get(43).toString());//切割长度
-						itemvo.setAttributeValue("pk_defdoc8", vector.get(44)==null?null:vector.get(44).toString());//切割角度左下
-						itemvo.setAttributeValue("pk_defdoc9", vector.get(45)==null?null:vector.get(45).toString());//切割角度右上
-						itemvo.setAttributeValue("pk_defdoc10",vector.get(46)==null?null:vector.get(46).toString());//备注
-						itemvo.setAttributeValue("pk_defdoc11",vector.get(19)==null?null:vector.get(19).toString());//宽度
-						itemvo.setAttributeValue("pk_defdoc12",vector.get(20)==null?null:vector.get(20).toString());//高度
-						itemvo.setAttributeValue("pk_defdoc13",vector.get(47)==null?null:vector.get(47).toString());//系列
-						itemvo.setAttributeValue("pk_defdoc14",vector.get(48)==null?null:vector.get(48).toString());//玻璃编号
-						itemvo.setAttributeValue("pk_defdoc20",vector.get(36)==null?null:vector.get(36).toString());//开票类型
+						sbvo.setPk_corp(saleheadvo.getPk_corp());
+	//					sbvo.setRefundflag(UFBoolean.FALSE);
+						sbvo.setTconsigntime("00:00:00");//发货时间
+						sbvo.setTdelivertime("00:00:00");//到货时间
+		//				sbvo.setVreceiveaddress(pk_corp);	//收货地址
+						String bidpk=UUID.randomUUID().toString().substring(0, 19);
+						sbvo.setCorder_bid(bidpk);//主键
+						sbvo.setVfree1(vector.get(12)==null?null:vector.get(12).toString());//颜色
+						sbvo.setVfree2(vector.get(14)==null?null:vector.get(14).toString());//合金
+						sbvo.setVfree3(vector.get(13)==null?null:vector.get(13).toString());//定尺
+						sbvo.setVfree4(vector.get(15)==null?null:vector.get(15).toString());//标准
+						sbvo.setAttributeValue("pk_defdoc1", vector.get(37)==null?null:vector.get(37).toString());//楼号楼层
+						sbvo.setAttributeValue("pk_defdoc2", vector.get(38)==null?null:vector.get(38).toString());//樘数(数量)
+						sbvo.setAttributeValue("pk_defdoc3", vector.get(39)==null?null:vector.get(39).toString());//框统计
+						sbvo.setAttributeValue("pk_defdoc4", vector.get(40)==null?null:vector.get(40).toString());//扇统计
+						sbvo.setAttributeValue("pk_defdoc5", vector.get(41)==null?null:vector.get(41).toString());//半成品分类
+						sbvo.setAttributeValue("pk_defdoc6", vector.get(42)==null?null:vector.get(42).toString());//面积
+						sbvo.setAttributeValue("pk_defdoc7", vector.get(43)==null?null:vector.get(43).toString());//切割长度
+						sbvo.setAttributeValue("pk_defdoc8", vector.get(44)==null?null:vector.get(44).toString());//切割角度左下
+						sbvo.setAttributeValue("pk_defdoc9", vector.get(45)==null?null:vector.get(45).toString());//切割角度右上
+						sbvo.setAttributeValue("pk_defdoc10",vector.get(46)==null?null:vector.get(46).toString());//备注
+						sbvo.setAttributeValue("pk_defdoc11",vector.get(19)==null?null:vector.get(19).toString());//宽度
+						sbvo.setAttributeValue("pk_defdoc12",vector.get(20)==null?null:vector.get(20).toString());//高度
+						sbvo.setAttributeValue("pk_defdoc13",vector.get(47)==null?null:vector.get(47).toString());//系列
+						sbvo.setAttributeValue("pk_defdoc14",vector.get(48)==null?null:vector.get(48).toString());//玻璃编号
+						sbvo.setAttributeValue("pk_defdoc20",vector.get(36)==null?null:vector.get(36).toString());//开票类型
 						//回写数量
 						UFDouble updatenum =  new UFDouble(vector.get(51)==null?"0":vector.get(51).toString())
 								.add(new UFDouble(vector.get(1)==null?"0":vector.get(1).toString()));
 						updatemap.put(vector.get(34).toString(), updatenum);
-						itemvos[k]=itemvo;
+						salebodyvos[k]=sbvo;
 						k = k + 1;
 					}
 				}
-				aggvo.setChildrenVO(itemvos);
-				aggvo.setStatus(VOStatus.NEW);
-				aggvos[0] = aggvo;
-				GeneralBillVO[] res = isaleout.insertSaleOuts(aggvos);
-				GeneralBillVO resvo = res[0];
+				saleaggvo.setChildrenVO(salebodyvos);
+				ArrayList<String> als=isoservice.insert(saleaggvo);
+				SaleOrderVO inseaggvos=new SaleOrderVO();
+				SaleorderHVO inserhearvo=(SaleorderHVO) saleaggvo.getParentVO();
+				SaleorderBVO[] insersalebodyvos=(SaleorderBVO[]) saleaggvo.getChildrenVO();
+				SaleorderHVO newinserhearvo=(SaleorderHVO) inserhearvo.clone();
+				SaleorderBVO[] newinsersalebodyvos=insersalebodyvos.clone();
+				for(SaleorderBVO bvo:newinsersalebodyvos) {
+					bvo.setCsaleid(als.get(0));//主表主键
+				}
+				newinserhearvo.setCsaleid(als.get(0));
+				newinserhearvo.setVreceiptcode(als.get(1));
+				newinserhearvo.setCapproveid(PubEnv.getPk_user());
+				newinserhearvo.setCcurrencytypeid("00010000000000000001");//币种
+			//	newinserhearvo.setAttributeValue("salecorp", "上海欣畅门窗");
+				inseaggvos.setParentVO(newinserhearvo);
+				inseaggvos.setChildrenVO(newinsersalebodyvos);
+				IplatFormEntry iIplatFormEntry = (IplatFormEntry)NCLocator.getInstance().lookup(IplatFormEntry.class.getName());
+				iIplatFormEntry.processAction("APPROVE", "30", saleheadvo.getDbilldate().toString(), null, inseaggvos, null, null);	
 				Boolean updateres = iorder.UpdateInExecNum(updatemap);
-	//			MessageDialog.showHintDlg(mainpanel, "成功", "销售出库单"+resvo.getVBillCode()+"新增成功");
 				MessageDialog.showHintDlg(mainpanel, "成功", "销售出库单新增成功!");
 				this.closeCancel();
 			}  catch (Exception e1) {
@@ -678,7 +737,31 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 		
 	}
 	
+	//业务流程
 	
+	private String getpkbustype(String busicode ) throws BusinessException {
+		  String sql="select pk_busitype from bd_busitype where busicode='"+busicode+"' and pk_corp='1001'  ";
+		  IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+		  
+		  Object pk_busitype =  iuap.executeQuery(sql, new ColumnProcessor());
+	      if (pk_busitype == null) {
+	          return "";
+	      }
+	      return pk_busitype.toString();
+			
+		}
 	
+	//通用查询方法
+	private String getvalue(String value,String table,String where,String param ) throws BusinessException {
+		  String sql="select "+value+" from "+table+" where "+where+"='"+param+"'  ";
+		  IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+		  
+		  Object valueobj =  iuap.executeQuery(sql, new ColumnProcessor());
+	      if (valueobj == null) {
+	          return "";
+	      }
+	      return valueobj.toString();
+			
+		}
 
 }