Browse Source

生产总订单材料出库更新

zthwr 1 year ago
parent
commit
b4cf08b918

+ 443 - 56
mmpac/mmpac/src/client/u8c/ui/mmpac/action/ToMaterialOutDialog.java

@@ -24,6 +24,7 @@ import nc.hr.utils.PubEnv;
 import nc.itf.uap.IUAPQueryBS;
 import nc.jdbc.framework.processor.BeanListProcessor;
 import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.jdbc.framework.processor.MapProcessor;
 import nc.ui.pub.ClientEnvironment;
 import nc.ui.pub.beans.MessageDialog;
 import nc.ui.pub.beans.UIButton;
@@ -76,6 +77,7 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 	private OrderIssueVO[] issueArrays = null;
 	private HRAggVO aggvo;
 	IMaterialOutMaintainAPI imaterapi=(IMaterialOutMaintainAPI) NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class.getName());
+	private IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
 	IOrderTotalInfo iorder = NCLocator.getInstance().lookup(IOrderTotalInfo.class);
 	public ToMaterialOutDialog(HRAggVO aggvo) {
 		super();
@@ -145,18 +147,33 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 				//执行完的表体在生单界面不展示
 				OrderIssueVO issuevo = (OrderIssueVO) vo;
 				UFDouble num = issuevo.getNum() == null ? UFDouble.ZERO_DBL : issuevo.getNum();
+				UFDouble nastnum=issuevo.getNastnum() == null ? UFDouble.ZERO_DBL : issuevo.getNastnum();//辅数量
+				
+				
 				UFDouble execnum = issuevo.getExecnum() == null ? UFDouble.ZERO_DBL : issuevo.getExecnum();
-				if(num.sub(execnum).compareTo(UFDouble.ZERO_DBL)==0){
+				UFDouble exenastnum = issuevo.getExecnastnum() == null ? UFDouble.ZERO_DBL : issuevo.getExecnastnum();//已执行辅数量
+				
+				if(num.sub(execnum).compareTo(UFDouble.ZERO_DBL)==0 && num.compareTo(UFDouble.ZERO_DBL)>0){
 					continue;
 				}
-				issuevo.setBdef5(num.sub(execnum).setScale(2, UFDouble.ROUND_HALF_UP).toString());//本次执行数量
+				
+				if(num.compareTo(UFDouble.ZERO_DBL)==0) {
+					issuevo.setBdef5(null);//本次执行数量
+				}else {
+					issuevo.setBdef5(num.sub(execnum).setScale(2, UFDouble.ROUND_HALF_UP).toString());//本次执行数量
+				}
+				
+				//没有辅数量
+				if(nastnum.compareTo(UFDouble.ZERO_DBL)!=0 ) {
+					issuevo.setBdef8(nastnum.sub(exenastnum).setScale(2, UFDouble.ROUND_HALF_UP).toString());//本次执行辅数量
+				}
+				
 				//查询入库颜色,显示入库颜色,生成材料出库以入库颜色为准
 				String rkcolur=issuevo.getBdef4();
 				if(!StringUtils.isEmpty(rkcolur)) {
 					issuevo.setColor(rkcolur);
 				}
 				
-				
 				issuevos.add(issuevo);
 			}
 			
@@ -168,11 +185,20 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 					//执行完的表体在生单界面不展示
 					OrderIssueVO issuevo = (OrderIssueVO) vo;
 					UFDouble num = issuevo.getNum() == null ? UFDouble.ZERO_DBL : issuevo.getNum();
+					UFDouble nastnum=issuevo.getNastnum() == null ? UFDouble.ZERO_DBL : issuevo.getNastnum();//辅数量
 					UFDouble execnum = issuevo.getExecnum() == null ? UFDouble.ZERO_DBL : issuevo.getExecnum();
-					if(num.sub(execnum).compareTo(UFDouble.ZERO_DBL)==0){
+					UFDouble exenastnum = issuevo.getExecnastnum() == null ? UFDouble.ZERO_DBL : issuevo.getExecnastnum();//已执行辅数量
+					if(num.sub(execnum).compareTo(UFDouble.ZERO_DBL)==0  && num.compareTo(UFDouble.ZERO_DBL)>0){
 						continue;
 					}
-					issuevo.setBdef5(num.sub(execnum).setScale(2, UFDouble.ROUND_HALF_UP).toString());
+					
+					if(num.compareTo(UFDouble.ZERO_DBL)==0) {
+						issuevo.setBdef5(null);//本次执行数量
+					}else {
+						issuevo.setBdef5(num.sub(execnum).setScale(2, UFDouble.ROUND_HALF_UP).toString());//本次执行数量
+					}
+					
+					issuevo.setBdef8(nastnum.sub(exenastnum).setScale(2, UFDouble.ROUND_HALF_UP).toString());//本次执行辅数量
 					issuevos.add(issuevo);
 				}
 			}
@@ -265,14 +291,79 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 		case 1:
 			int jfRowCount = getJlcardPanel().getRowCount();
 			if (jfRowCount > 0) {
+			String storcode = "";	
+				if(flag) {
+					//获取当前单据的业务类型
+					String pk_order=(String) getJlcardPanel().getBillModel().getValueAt(0, "pk_order");//生产总订单主键
+					String sql="select busitype from mmpac_order_main where  pk_order='"+pk_order+"' ";
+					String billtype = null;
+					try {
+						billtype = (String) iuap.executeQuery(sql.toString(), new ColumnProcessor());
+					} catch (BusinessException e1) {
+						MessageDialog.showErrorDlg(mainpanel, "错误", "业务类型获取失败!");
+						return;
+					}
+					if("工装".equals(billtype.trim())) {
+						storcode ="GZ001";
+					}else if("家装".equals(billtype.trim())) {
+						storcode= "JZ002";
+					}
+				}
+				
+				
 				for (int row = 0; row < jfRowCount; row++) {
+					if(flag) {
+						String cmaterialcode=(String) getJlcardPanel().getBillModel().getValueAt(row, "cmaterialcode");//存货编码
+						String vbatchcode=(String) getJlcardPanel().getBillModel().getValueAt(row, "vbatchcode");//批次号
+						String color=(String) getJlcardPanel().getBillModel().getValueAt(row, "color");//颜色
+						String sizing=(String) getJlcardPanel().getBillModel().getValueAt(row, "sizing");
+						String alloy=(String) getJlcardPanel().getBillModel().getValueAt(row, "alloy");
+						String standard=(String) getJlcardPanel().getBillModel().getValueAt(row, "standard");
+						Object objnastnum=getJlcardPanel().getBillModel().getValueAt(row, "nastnum");//辅数量
+						
+						UFDouble nastnum=objnastnum==null? UFDouble.ZERO_DBL:new UFDouble(objnastnum.toString());//辅数量
+						
+						if(cmaterialcode.startsWith("MA") && nastnum.compareTo(UFDouble.ZERO_DBL)>0 ) {
+							try {
+								//型材没有换算率
+//								String storcode = "";
+//								if("工装".equals(billtype.trim())) {
+//									storcode ="GZ001";
+//								}else if("家装".equals(billtype.trim())) {
+//									storcode= "JZ002";
+//								}
+								InvbasdocVO  invbasvo = GetBaseDAOUtil.getInvVO(cmaterialcode);
+							    String pk_invbasdoc = invbasvo.getPrimaryKey();
+							    Object objbdef6 =getHandNum("1001", storcode, pk_invbasdoc, vbatchcode, color, sizing, alloy, standard);//现存量换算率
+							    
+							    if(null==objbdef6 || "".equals(objbdef6.toString())) {
+									MessageDialog.showErrorDlg(mainpanel, "错误", "请检查换算率不能为空!");
+									return;
+								}
+							    String value=(String) getJlcardPanel().getBillModel().getValueAt(row, "bdef8");//本次执行辅数量 
+							    UFDouble  ufbdef8=new UFDouble(value).multiply(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+							    //主数量
+								UFDouble  num=new UFDouble((String) getJlcardPanel().getBillModel().getValueAt(row, "nastnum").toString())
+										.multiply(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+							    getJlcardPanel().getBillModel().setValueAt(ufbdef8, row, "bdef5");//本次执行主数量
+							    getJlcardPanel().getBillModel().setValueAt(objbdef6, row, "bdef6");//换算率
+							    getJlcardPanel().getBillModel().setValueAt(num, row, "num");//主数量
+							} catch (Exception e) {
+								MessageDialog.showErrorDlg(mainpanel, "错误", "存货:"+cmaterialcode+",未查询到对应现存量,主数量计算失败!");
+								return;
+							}
+							
+						}
+						
+					}
+					
 					getJlcardPanel().getBillModel().setValueAt(flag, row, "bdef4");
 				}
 				
-			}
-			break;
+			 }
+			         break;
 
-		}
+		  }
 	}
 	
 	
@@ -355,7 +446,201 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 	
 	@Override
 	public void afterEdit(BillEditEvent arg0) {
-		// TODO Auto-generated method stub
+		//获取当前单据的业务类型
+		String pk_order=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "pk_order");//生产总订单主键
+		String sql="select busitype from mmpac_order_main where  pk_order='"+pk_order+"' ";
+		
+		Object  objnastnum= this.jlcardPanel.getBodyValueAt(arg0.getRow(), "nastnum")  ;//辅数量
+		
+		UFDouble nastnum=objnastnum==null?UFDouble.ZERO_DBL:new UFDouble(objnastnum.toString());
+		
+		String cmaterialcode=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "cmaterialcode");//存货编码
+		
+		if(!cmaterialcode.startsWith("MA")) {
+			//没有辅数量
+			if(nastnum.compareTo(UFDouble.ZERO_DBL)==0 ) {
+				return;
+			}
+		}
+		
+		
+		String billtype = null;
+		try {
+			billtype = (String) iuap.executeQuery(sql.toString(), new ColumnProcessor());
+		} catch (BusinessException e1) {
+			MessageDialog.showErrorDlg(mainpanel, "错误", "业务类型获取失败!");
+			//this.jlcardPanel.setBodyValueAt(null, arg0.getRow(), "bdef6");
+			return;
+		}
+		
+		String storcode = "";
+		if("工装".equals(billtype.trim())) {
+			storcode ="GZ001";
+		}else if("家装".equals(billtype.trim())) {
+			storcode= "JZ002";
+		}
+		
+		//本次执行主数量
+		if("bdef5".equals(arg0.getKey())) {
+			String value=arg0.getValue().toString();//填写的主数量
+			
+			cmaterialcode=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "cmaterialcode");//存货编码
+			String vbatchcode=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "vbatchcode");//批次号
+			String color=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "color");//颜色
+			String sizing=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "sizing");
+			String alloy=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "alloy");
+			String standard=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "standard");
+			Object objbdef6=null;//换算率
+			if(cmaterialcode.startsWith("MA")) {
+				try {
+					//型材没有换算率
+//					String storcode = "";
+//					if("工装".equals(billtype.trim())) {
+//						storcode ="GZ001";
+//					}else if("家装".equals(billtype.trim())) {
+//						storcode= "JZ002";
+//					}
+					InvbasdocVO  invbasvo = GetBaseDAOUtil.getInvVO(cmaterialcode);
+				    String pk_invbasdoc = invbasvo.getPrimaryKey();
+				    objbdef6 =getHandNum("1001", storcode, pk_invbasdoc, vbatchcode, color, sizing, alloy, standard);//现存量换算率
+				} catch (Exception e) {
+					MessageDialog.showErrorDlg(mainpanel, "错误", "存货:"+cmaterialcode+",未查询到对应现存量,主数量计算失败!");
+					this.jlcardPanel.setBodyValueAt(null, arg0.getRow(), "bdef5");
+					return;
+				}
+				
+			}else {
+				objbdef6=this.jlcardPanel.getBodyValueAt(arg0.getRow(), "bdef6");//换算率
+			}
+			
+			if(null==objbdef6 || "".equals(objbdef6.toString())) {
+				MessageDialog.showErrorDlg(mainpanel, "错误", "请检查换算率不能为空或者MA开头的现存量未查询到!");
+				this.jlcardPanel.setBodyValueAt(null, arg0.getRow(), "bdef5");
+				return;
+			}
+			
+			UFDouble  ufbdef8=new UFDouble(value).div(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+			
+			if(cmaterialcode.startsWith("MA")) {
+			  //主数量
+			  UFDouble  num=new UFDouble(this.jlcardPanel.getBodyValueAt(arg0.getRow(), "nastnum").toString())
+					.multiply(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+			  this.jlcardPanel.setBodyValueAt(num, arg0.getRow(), "num");//主数量
+		   }
+			
+			this.jlcardPanel.setBodyValueAt(ufbdef8, arg0.getRow(), "bdef8");//本次执行辅数量
+			this.jlcardPanel.setBodyValueAt(objbdef6, arg0.getRow(), "bdef6");//换算率
+			
+		}
+		
+		//本次执行辅数量
+		if("bdef8".equals(arg0.getKey())) {
+			
+            String value=arg0.getValue().toString();//填写的辅数量
+			
+            cmaterialcode=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "cmaterialcode");//存货编码
+			String vbatchcode=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "vbatchcode");//批次号
+			String color=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "color");//颜色
+			String sizing=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "sizing");
+			String alloy=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "alloy");
+			String standard=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "standard");
+			Object objbdef6=null;//换算率
+			if(cmaterialcode.startsWith("MA")) {
+				try {
+					//型材没有换算率
+//					String storcode = "";
+//					if("工装".equals(billtype.trim())) {
+//						storcode ="GZ001";
+//					}else if("家装".equals(billtype.trim())) {
+//						storcode= "JZ002";
+//					}
+					InvbasdocVO  invbasvo = GetBaseDAOUtil.getInvVO(cmaterialcode);
+				    String pk_invbasdoc = invbasvo.getPrimaryKey();
+				    objbdef6 =getHandNum("1001", storcode, pk_invbasdoc, vbatchcode, color, sizing, alloy, standard);//现存量换算率
+				} catch (Exception e) {
+					MessageDialog.showErrorDlg(mainpanel, "错误", "存货:"+cmaterialcode+",未查询到对应现存量,主数量计算失败!");
+					this.jlcardPanel.setBodyValueAt(null, arg0.getRow(), "bdef8");
+					return;
+				}
+				
+			}else {
+				objbdef6=this.jlcardPanel.getBodyValueAt(arg0.getRow(), "bdef6");//换算率
+			}
+			
+			if(null==objbdef6 || "".equals(objbdef6.toString())) {
+				MessageDialog.showErrorDlg(mainpanel, "错误", "请检查换算率不能为空或者MA开头的现存量未查询到!");
+				this.jlcardPanel.setBodyValueAt(null, arg0.getRow(), "bdef5");
+				return;
+			}
+			
+			UFDouble  ufbdef8=new UFDouble(value).multiply(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+			
+			if(cmaterialcode.startsWith("MA")) {
+			  //主数量
+			  UFDouble  num=new UFDouble(this.jlcardPanel.getBodyValueAt(arg0.getRow(), "nastnum").toString())
+					.multiply(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+			  this.jlcardPanel.setBodyValueAt(num, arg0.getRow(), "num");//主数量
+		   }
+			
+			
+			this.jlcardPanel.setBodyValueAt(ufbdef8, arg0.getRow(), "bdef5");
+			this.jlcardPanel.setBodyValueAt(objbdef6, arg0.getRow(), "bdef6");//换算率
+		}
+		
+		//勾选
+		if("bdef4".equals(arg0.getKey())) {
+			
+			String value=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "bdef8");//填写的辅数量
+		    cmaterialcode=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "cmaterialcode");//存货编码
+			String vbatchcode=(String) this.jlcardPanel.getBodyValueAt(arg0.getRow(), "vbatchcode");//批次号
+			String color=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "color");//颜色
+			String sizing=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "sizing");
+			String alloy=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "alloy");
+			String standard=(String) getJlcardPanel().getBillModel().getValueAt(arg0.getRow(), "standard");
+			Object objbdef6=null;//换算率
+			if(cmaterialcode.startsWith("MA")) {
+				try {
+					//型材没有换算率
+//					String storcode = "";
+//					if("工装".equals(billtype.trim())) {
+//						storcode ="GZ001";
+//					}else if("家装".equals(billtype.trim())) {
+//						storcode= "JZ002";
+//					}
+					InvbasdocVO  invbasvo = GetBaseDAOUtil.getInvVO(cmaterialcode);
+				    String pk_invbasdoc = invbasvo.getPrimaryKey();
+				    objbdef6 =getHandNum("1001", storcode, pk_invbasdoc, vbatchcode, color, sizing, alloy, standard);//现存量换算率
+				} catch (Exception e) {
+					MessageDialog.showErrorDlg(mainpanel, "错误", "存货:"+cmaterialcode+",未查询到对应现存量,主数量计算失败!");
+				//	this.jlcardPanel.setBodyValueAt(null, arg0.getRow(), "bdef8");
+					this.jlcardPanel.setBodyValueAt(false, arg0.getRow(), "bdef4");
+					return;
+				}
+				
+			}else {
+				objbdef6=this.jlcardPanel.getBodyValueAt(arg0.getRow(), "bdef6");//换算率
+			}
+			
+			if(null==objbdef6 || "".equals(objbdef6.toString())) {
+				MessageDialog.showErrorDlg(mainpanel, "错误", "请检查换算率不能为空或者MA开头的现存量未查询到!");
+				this.jlcardPanel.setBodyValueAt(null, arg0.getRow(), "bdef8");
+				return;
+			}
+			
+			UFDouble  ufbdef8=new UFDouble(value).multiply(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+			
+			if(cmaterialcode.startsWith("MA")) {
+			//主数量
+			UFDouble  num=new UFDouble(this.jlcardPanel.getBodyValueAt(arg0.getRow(), "nastnum").toString())
+					.multiply(new UFDouble(objbdef6.toString())).setScale(2, UFDouble.ROUND_HALF_UP);
+			 this.jlcardPanel.setBodyValueAt(num, arg0.getRow(), "num");//主数量
+		   }
+			
+			this.jlcardPanel.setBodyValueAt(ufbdef8, arg0.getRow(), "bdef5");//本次执行主数量
+			this.jlcardPanel.setBodyValueAt(objbdef6, arg0.getRow(), "bdef6");//换算率
+			
+			
+		}
 		
 	}
 
@@ -388,9 +673,9 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 						}
 						execsize = execsize + 1;
 						UFDouble execnum = new UFDouble(vector.get(1).toString());//本次执行数量
-						UFDouble nnum = new UFDouble(vector.get(21).toString());//主数量
-						UFDouble usednum = vector.get(29) == null?new UFDouble(0):new UFDouble(vector.get(29).toString());//已执行主数量
-						if(execnum.compareTo(nnum.sub(usednum)) > 0) {
+						UFDouble nnum =  vector.get(22) == null?new UFDouble(0):new UFDouble(vector.get(22).toString());//主数量
+						UFDouble usednum = vector.get(30) == null?new UFDouble(0):new UFDouble(vector.get(30).toString());//已执行主数量
+						if(execnum.compareTo(nnum.sub(usednum)) > 0 && nnum.compareTo(UFDouble.ZERO_DBL)>0) {
 							errmsg.append("第"+(i+1)+"行本次执行数量超过订单剩余数量!");
 						}
 					}
@@ -419,29 +704,44 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 				icheadvo.setPk_calbody(GetBaseDAOUtil.getcalpk(pk_corp));
 				icheadvo.setDbilldate(dbilldate);
 				icheadvo.setCoperatorid(PubEnv.getPk_user());
+//				//项目编码 pk_defdoc9
+//				icheadvo.setAttributeValue("pk_defdoc9", prjcode);
+//				//项目名称pk_defdoc10
+//				icheadvo.setAttributeValue("pk_defdoc10", prjcode);
+//				//加工单号pk_defdoc2
+//				icheadvo.setAttributeValue("pk_defdoc2", headvo.getDef1());
+//				//收发类别
+//				icheadvo.setCdispatcherid(getpkrdcl("03"));
+//				//业务类型
+//				icheadvo.setAttributeValue("pk_defdoc8", billtype);
+				
+				
+				//项目编码 pk_defdoc9
+	////			icheadvo.setAttributeValue("vuserdef9", prjcode);
+				//项目名称pk_defdoc10
+	////			icheadvo.setAttributeValue("vuserdef10", prjcode);
+				
+				Map<String,String> mapcodename=getprojectmap(prjcode);
+				//项目编码 
+				icheadvo.setAttributeValue("vuserdef9",mapcodename.get("jobcode") );
 				//项目编码 pk_defdoc9
 				icheadvo.setAttributeValue("pk_defdoc9", prjcode);
+				//项目名称
+				icheadvo.setAttributeValue("vuserdef10", mapcodename.get("jobname"));
 				//项目名称pk_defdoc10
-				icheadvo.setAttributeValue("pk_defdoc10", prjcode);
-				//加工单号pk_defdoc2
-				icheadvo.setAttributeValue("pk_defdoc2", headvo.getDef1());
+				icheadvo.setAttributeValue("pk_defdoc10", prjcode);						
+				//加工单号
+				icheadvo.setAttributeValue("vuserdef1", headvo.getDef1());
 				//收发类别
 				icheadvo.setCdispatcherid(getpkrdcl("03"));
 				//业务类型
-				icheadvo.setAttributeValue("pk_defdoc8", billtype);
+				icheadvo.setAttributeValue("vuserdef7", billtype.trim());
 				
-//				icheadvo.setCdispatchername("");
-				//仓库ID
-//				if("工装".equals(billtype)) {
-//				//	icheadvo.setCwarehouseid("1001V51000000000039Z");//仓库必填
-//					icheadvo.setCwarehouseid("1001F81000000000025M");//仓库必填新环境
-//				}else if("家装".equals(billtype)) {
-//				//	icheadvo.setCwarehouseid("1001V5100000000003A0");//仓库必填
-//					icheadvo.setCwarehouseid("1001F810000000000DW1");//仓库必填新环境
-//				}
-				if("工装".equals(billtype)) {
+				icheadvo.setAttributeValue("pk_defdoc7",getpkdefdoc(billtype.trim()));
+				
+				if("工装".equals(billtype.trim())) {
 					icheadvo.setCwarehouseid(GetBaseDAOUtil.getstordocpk("GZ001"));//仓库必填
-				}else if("家装".equals(billtype)) {
+				}else if("家装".equals(billtype.trim())) {
 					icheadvo.setCwarehouseid(GetBaseDAOUtil.getstordocpk("JZ002"));//仓库必填
 				}
 				icheadvo.setBoutretflag(UFBoolean.FALSE);//是否退回 
@@ -450,15 +750,15 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 				icheadvo.setCbilltypecode("4D");
 				aggvo.setParentVO(icheadvo);
 				GeneralBillItemVO[] itemvos = new GeneralBillItemVO[execsize];
-				Map<String, UFDouble> updatemap = new HashMap<>();
-				
+				Map<String, UFDouble> updatemap = new HashMap<>();//回写已执行主数量
+				Map<String, UFDouble> updatfzemap = 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();
-						String cmaterialcode = vector.get(7).toString();
+						String cmaterialcode = vector.get(8).toString();
 						String pk_invbasdoc = "";//存货pk
 						if(cmaterialcode.startsWith("0001")) {
 							pk_invbasdoc = cmaterialcode;
@@ -510,10 +810,10 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 						itemvo.setFlargess(UFBoolean.FALSE);
 						itemvo.setIsok(UFBoolean.FALSE);
 						itemvo.setNbarcodenum(new UFDouble(0));//条码数量
-						UFDouble ninnum = vector.get(1) == null ? null : new UFDouble(vector.get(1).toString());
+						UFDouble ninnum = vector.get(1) == null ? null : new UFDouble(vector.get(1).toString());//本次执主数量
 						itemvo.setNoutnum(ninnum);//实出数量 
 						itemvo.setNshouldoutnum(ninnum);//应出数量 
-						UFDouble Hsl = vector.get(45) == null ? null : new UFDouble(vector.get(45).toString());
+						UFDouble Hsl = vector.get(47) == null ? null : new UFDouble(vector.get(47).toString());//换算率
 						//换算率						
 						itemvo.setHsl(Hsl);
 						//没有换算率则辅数量为空
@@ -525,36 +825,66 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 					
 						itemvo.setAttributeValue("processcost", new UFDouble(vector.get(24)==null?"0":vector.get(24).toString()));
 						itemvo.setPk_calbody(GetBaseDAOUtil.getcalpk(pk_corp));
-						itemvo.setVbatchcode(vector.get(6)==null?"":vector.get(6).toString());
-						Object fzdw=vector.get(27);
+						itemvo.setVbatchcode(vector.get(7)==null?"":vector.get(7).toString());//批次号
+						Object fzdw=vector.get(28);//辅计量单位
 						String castunitid=getpk(fzdw==null?"":fzdw.toString());
 						itemvo.setCastunitid(castunitid);//辅计量单位ID 
 						itemvo.setCastunitname(fzdw==null?"":fzdw.toString());//辅计量单位名称
 						itemvo.setVfirstbillcode(headvo.getVbillno());
-						itemvo.setVfree1(vector.get(11)==null?null:vector.get(11).toString());
-						itemvo.setVfree2(vector.get(13)==null?null:vector.get(13).toString());
-						itemvo.setVfree3(vector.get(12)==null?null:vector.get(12).toString());
-						itemvo.setVfree4(vector.get(14)==null?null:vector.get(14).toString());
+						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.setVsourcebillcode(headvo.getVbillno());
-						itemvo.setAttributeValue("pk_defdoc1", vector.get(33)==null?null:vector.get(33).toString());//楼号楼层
-						itemvo.setAttributeValue("pk_defdoc2", vector.get(34)==null?null:vector.get(34).toString());//樘数(数量)
-						itemvo.setAttributeValue("pk_defdoc3", vector.get(35)==null?null:vector.get(35).toString());//框统计
-						itemvo.setAttributeValue("pk_defdoc4", vector.get(36)==null?null:vector.get(36).toString());//扇统计
-						itemvo.setAttributeValue("pk_defdoc5", vector.get(37)==null?null:vector.get(37).toString());//半成品分类
-						itemvo.setAttributeValue("pk_defdoc6", vector.get(38)==null?null:vector.get(38).toString());//面积
-						itemvo.setAttributeValue("pk_defdoc7", vector.get(39)==null?null:vector.get(39).toString());//切割长度
-						itemvo.setAttributeValue("pk_defdoc8", vector.get(40)==null?null:vector.get(40).toString());//切割角度左下
-						itemvo.setAttributeValue("pk_defdoc9", vector.get(41)==null?null:vector.get(41).toString());//切割角度右上
-						itemvo.setAttributeValue("pk_defdoc10",vector.get(42)==null?null:vector.get(42).toString());//备注
-						itemvo.setAttributeValue("pk_defdoc11",vector.get(18)==null?null:vector.get(18).toString());//宽度
-						itemvo.setAttributeValue("pk_defdoc12",vector.get(19)==null?null:vector.get(19).toString());//高度
-						itemvo.setAttributeValue("pk_defdoc13",vector.get(43)==null?null:vector.get(43).toString());//系列
-						itemvo.setAttributeValue("pk_defdoc14",vector.get(44)==null?null:vector.get(44).toString());//玻璃编号
+//						itemvo.setAttributeValue("pk_defdoc1", vector.get(34)==null?null:vector.get(34).toString());//楼号楼层
+//						itemvo.setAttributeValue("pk_defdoc2", vector.get(35)==null?null:vector.get(35).toString());//樘数(数量)
+//						itemvo.setAttributeValue("pk_defdoc3", vector.get(36)==null?null:vector.get(36).toString());//框统计
+//						itemvo.setAttributeValue("pk_defdoc4", vector.get(37)==null?null:vector.get(37).toString());//扇统计
+//						itemvo.setAttributeValue("pk_defdoc5", vector.get(38)==null?null:vector.get(38).toString());//半成品分类
+//						itemvo.setAttributeValue("pk_defdoc6", vector.get(39)==null?null:vector.get(39).toString());//面积
+//						itemvo.setAttributeValue("pk_defdoc7", vector.get(40)==null?null:vector.get(40).toString());//切割长度
+//						itemvo.setAttributeValue("pk_defdoc8", vector.get(41)==null?null:vector.get(41).toString());//切割角度左下
+//						itemvo.setAttributeValue("pk_defdoc9", vector.get(42)==null?null:vector.get(42).toString());//切割角度右上
+//						itemvo.setAttributeValue("pk_defdoc10",vector.get(43)==null?null:vector.get(43).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(44)==null?null:vector.get(44).toString());//系列
+//						itemvo.setAttributeValue("pk_defdoc14",vector.get(45)==null?null:vector.get(45).toString());//玻璃编号
+						
+						
+						
+						itemvo.setAttributeValue("vuserdef1", vector.get(34)==null?null:vector.get(34).toString());//楼号楼层
+						itemvo.setAttributeValue("vuserdef2", vector.get(35)==null?null:vector.get(35).toString());//樘数(数量)
+						itemvo.setAttributeValue("vuserdef3", vector.get(36)==null?null:vector.get(36).toString());//框统计
+						itemvo.setAttributeValue("vuserdef4", vector.get(37)==null?null:vector.get(37).toString());//扇统计
+						itemvo.setAttributeValue("vuserdef5", vector.get(38)==null?null:vector.get(38).toString());//半成品分类
+						itemvo.setAttributeValue("vuserdef6", vector.get(39)==null?null:vector.get(39).toString());//面积
+						itemvo.setAttributeValue("vuserdef7", vector.get(40)==null?null:vector.get(40).toString());//切割长度
+						itemvo.setAttributeValue("vuserdef8", vector.get(41)==null?null:vector.get(41).toString());//切割角度左下
+						itemvo.setAttributeValue("vuserdef9", vector.get(42)==null?null:vector.get(42).toString());//切割角度右上
+						itemvo.setAttributeValue("vuserdef10",vector.get(43)==null?null:vector.get(43).toString());//备注
+						itemvo.setAttributeValue("vuserdef11",vector.get(19)==null?null:vector.get(19).toString());//宽度
+						itemvo.setAttributeValue("vuserdef12",vector.get(20)==null?null:vector.get(20).toString());//高度
+						itemvo.setAttributeValue("vuserdef13",vector.get(44)==null?null:vector.get(44).toString());//系列
+						itemvo.setAttributeValue("vuserdef14",vector.get(45)==null?null:vector.get(45).toString());//玻璃编号
+											
+//						itemvo.setAttributeValue("vuserdef15",vector.get()==null?null:vector.get().toString());//开票类型
+						itemvo.setAttributeValue("vuserdef17",vector.get(18)==null?null:vector.get(18).toString());//窗号
+						itemvo.setAttributeValue("vuserdef18",vector.get(16)==null?null:vector.get(16).toString());//米重
+						itemvo.setAttributeValue("vuserdef19",vector.get(17)==null?null:vector.get(17).toString());//装饰面周长
+			//			itemvo.setAttributeValue("vuserdef20",vector.get(5)==null?null:vector.get(5).toString());//专用区
+						
 						
 						
 						//回写数量
-						UFDouble updatenum =  new UFDouble(vector.get(29)==null?"0":vector.get(29).toString()).add(new UFDouble(vector.get(1)==null?"0":vector.get(1).toString()));
+						UFDouble updatenum =  new UFDouble(vector.get(30)==null?"0":vector.get(30).toString())
+								.add(new UFDouble(vector.get(1)==null?"0":vector.get(1).toString()));//已执行主数量+本次执行主数量
+						
+						UFDouble updatexenum= new UFDouble(vector.get(31)==null?"0":vector.get(31).toString())
+								.add(new UFDouble(vector.get(2)==null?"0":vector.get(1).toString()));//已执行辅数量+本次执行辅数量
+						
 						updatemap.put(vector.get(51).toString(), updatenum);
+						updatfzemap.put(vector.get(51).toString(), updatexenum);
 						itemvos[k]=itemvo;
 						k = k + 1;
 					}
@@ -564,6 +894,7 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 				GeneralBillVO[] res = imaterapi.insertMaterialOuts(aggvos);
 				GeneralBillVO resvo = res[0];
 				Boolean updateres = iorder.UpdateIssueExecNum(updatemap);
+				Boolean updatfzeres = iorder.UpdatefzExecNum(updatfzemap);
 //				MessageDialog.showHintDlg(mainpanel, "成功", "材料出库单"+resvo.getVBillCode()+"新增成功!");
 				MessageDialog.showHintDlg(mainpanel, "成功", "材料出库单新增成功!");
 				this.closeCancel();
@@ -597,11 +928,11 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 			ti.setUserid(ce.getUser().getPrimaryKey());
 			ti.setCurrentCorpPk(ce.getCorporation().getPrimaryKey());
 			//功能节点默人模板分配后查询SELECT * from  pub_systemplate order by  ts desc
-			ti.setFunNode("40H204");
+			ti.setFunNode("40H206");
 			ti.setNodekey("qt");
 			QueryConditionDLG d=new QueryConditionDLG(this,ti,"材料明细");
 			Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
-			d.setSize(dimension.width-1000,dimension.height-650);
+		//	d.setSize(dimension.width-1000,dimension.height-650);
 			d.setLocation(500, 300);
 			if(d.showModal() != UIDialog.ID_OK){
 				return;
@@ -661,7 +992,6 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 	//收发类别
 	private String getpkrdcl(String rdcode ) throws BusinessException {
 	  String sql="select pk_rdcl from bd_rdcl where rdcode='"+rdcode+"'  ";
-	  IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
 	  
 	  String pk_rdcl = (String) iuap.executeQuery(sql, new ColumnProcessor());
       if (pk_rdcl == null) {
@@ -671,6 +1001,63 @@ public class ToMaterialOutDialog extends UIDialog implements ActionListener,Bill
 		
 	}
 	
+    //项目管理档案-编码和名称
+    public  Map<String,String> getprojectmap(String pk_jobmngfil ) throws Exception {
+        String sql = "select jobcode,jobname  from   bd_jobbasfil where  "
+        		+ "pk_jobbasfil = (select pk_jobbasfil from bd_jobmngfil where pk_jobmngfil ='"+pk_jobmngfil+"' and dr = 0) "
+        		+ "and dr=0";
+        Map<String,String> map = (Map<String, String>) iuap.executeQuery(sql, new MapProcessor());
+        if (map == null || map.size()==0) {
+        	throw new Exception("项目管理档案"+pk_jobmngfil+"未查到,请检查"); 
+        }
+        return map;
+    }
+	
+	//业务类型自定义档案查询
+	private String getpkdefdoc(String docname ) throws Exception {
+	  String sql="select pk_defdoc from bd_defdoc  where pk_defdoclist = "
+	  		+ "(select pk_defdoclist from bd_defdef where defname = '业务类型' and dr=0 ) and dr=0 "
+	  		+ "and docname='"+docname+"'";
+	  
+	  Object pkdefdoc =  iuap.executeQuery(sql, new ColumnProcessor());
+	  if(pkdefdoc == null ||  "".equals(pkdefdoc)) {
+  		throw new Exception("业务类型【"+docname+"】未查到,请检查");
+  	  }
+
+      return pkdefdoc.toString();
+		
+	}
+	
+	
+	/**
+	 * 查询现存量物料换算率
+	 * @param pk_corp
+	 * @param storcode
+	 * @param cinvbasid
+	 * @param vbatchcode
+	 * @param color    颜色
+	 * @param sizing   定尺
+	 * @param alloy    合金
+	 * @param standard 标准
+	 * @return
+	 * @throws Exception
+	 */
+   	public  Object  getHandNum(String pk_corp,String storcode,String cinvbasid,String vbatchcode, String color ,String sizing,String alloy,String standard)throws Exception {
+   		StringBuffer sql = new StringBuffer();
+   		sql.append("SELECT ");
+   		sql.append(" nonhandnum/nonhandastnum as hsl");
+   		sql.append(" FROM");
+   		sql.append(" ic_onhandnum");
+   		sql.append(" WHERE");
+   		sql.append(" pk_corp = '"+pk_corp+"'");
+   		sql.append(" AND cwarehouseid = ( SELECT pk_stordoc FROM bd_stordoc WHERE storcode = '"+storcode+"' and sealflag = 'N' and dr = 0)");
+   		sql.append(" AND cinvbasid = '"+cinvbasid+"' AND vfree1='"+color+"' AND vfree2='"+alloy+"' AND vfree3='"+sizing+"' AND vfree4='"+standard+"' ");
+   		if(vbatchcode != null) {
+   			sql.append(" AND vlot = '"+vbatchcode+"'");
+   		}
+   		return  iuap.executeQuery(sql.toString(), new ColumnProcessor());
+   	}
+	
 
 }
 

+ 26 - 0
mmpac/mmpac/src/private/u8c/impl/mmpac/mmpac/OrderTotalInfoImpl.java

@@ -69,6 +69,32 @@ public class OrderTotalInfoImpl implements IOrderTotalInfo {
 		return false;
 	}
 	
+	
+	public boolean UpdatefzExecNum(Map<String, UFDouble> updatemap) throws BusinessException {
+		List<OrderIssueVO> updatevos = new ArrayList<>();
+		OrderTotalInfoDAO dao = new OrderTotalInfoDAO();
+		Boolean res = false;
+		Iterator it = updatemap.keySet().iterator();
+		try {
+			while(it.hasNext()) {
+				Object key = it.next();
+				Object val = updatemap.get(key);
+				OrderIssueVO issuevo = GetBaseDAOUtil.getissuevo(key.toString());
+				issuevo.setExecnastnum(new UFDouble(val.toString()));
+				updatevos.add(issuevo);
+			}
+			for(int i = 0;i < updatevos.size();i++) {
+				dao.UpdateIssueExecNum(updatevos.get(i), new String[]{OrderIssueVO.EXECNASTNUM});
+			}
+			return true;
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		return false;
+	}
+	
 	@Override
 	public boolean UpdateInExecNum(Map<String, UFDouble> updatemap) throws BusinessException {
 		// TODO Auto-generated method stub

+ 2 - 0
mmpac/mmpac/src/public/u8c/itf/mmpac/mmpac/IOrderTotalInfo.java

@@ -19,6 +19,8 @@ public interface IOrderTotalInfo {
 	
 	public abstract void insertProduct(GeneralBillVO[] aggvo,Map<String,UFDouble> updatemap) throws Exception;
 	
+	public abstract boolean UpdatefzExecNum(Map<String,UFDouble> updatemap) throws BusinessException;
+	
 	//生单形成的单据删除后回写数量
 	public abstract void updateExecnum(String sql) throws BusinessException;
 }