浏览代码

MRP运算跟新

zthwr 1 年之前
父节点
当前提交
9f6241b401
共有 1 个文件被更改,包括 201 次插入175 次删除
  1. 201 175
      mm/mm/src/client/u8c/ui/mm/action/YsAction.java

+ 201 - 175
mm/mm/src/client/u8c/ui/mm/action/YsAction.java

@@ -83,6 +83,7 @@ public class YsAction extends YsQuseryAction{
 			String butype = dialog.getButype();//业务类型下拉--- 家装\工装
 			String xmname = dialog.getXmname();//项目主键
 			String xmcode = dialog.getXmcode();//工单号
+			String chfl=dialog.getChfl();//存货分类
 			/**
 			 * 
 			 * 查询生产总订单和材料采购单数据生成
@@ -1091,130 +1092,163 @@ public class YsAction extends YsQuseryAction{
 				String pk_operation=ivo.insertVO(opmainvo);
 				
 				//需求页签
-				String sqlaqkc2="select *  from  ic_safetystock where isnull(dr,0)=0;";
+				String sqlaqkc2="select ic.*  from  ic_safetystock ic inner join  bd_invmandoc  bdin on bdin.pk_invmandoc=ic.cmaterialcode "
+						+ "inner join  bd_invbasdoc  bdv  on bdv.pk_invbasdoc =bdin.pk_invbasdoc "
+						+ "inner join  bd_invcl  invcl on invcl.pk_invcl =bdv.pk_invcl "
+						+ "where isnull(ic.dr,0)=0  and isnull(bdin.dr,0)=0 "
+						+ "and isnull(bdv.dr,0)=0  and isnull(invcl.dr,0)=0 and  invcl.pk_invcl='" + chfl + "' ";
+			
 				List<SafetystockVO> lisobs2=(List<SafetystockVO>) iuap.executeQuery(sqlaqkc2, new BeanListProcessor(SafetystockVO.class));
 				
 				List<OperationDemandVO> demandvos=new ArrayList<OperationDemandVO>();
 				
-				for(int i=0;i<lisobs2.size();i++) {
-					OperationDemandVO  operdemandvo=new OperationDemandVO();
-					SafetystockVO styvo=lisobs2.get(i);
-					operdemandvo.setAlloy(styvo.getAlloy());
-					operdemandvo.setColor(styvo.getColor());
-					operdemandvo.setPk_operation(pk_operation);
-					operdemandvo.setNum(new UFDouble(styvo.getVdef1()));
-					operdemandvo.setDemandtyoe("安全库存");
-					operdemandvo.setDemanddate(PubEnv.getLoginDate().toString());
-//					operdemandvo.setWarehouse(getstordocpk("JZ002"));//仓库
-//					operdemandvo.setCmaterialcode(getCmangchid(styvo.getCmaterialcode()));//存货编码
-//					operdemandvo.setCmaterialname(styvo.getCmaterialname());//存货名称
-					String cmaterpk=styvo.getCmaterialcode();
-					operdemandvo.setCmaterialcode(getCmangcodename(cmaterpk,"invcode"));//存货编码
-					operdemandvo.setCmaterialname(getCmangcodename(cmaterpk,"invname"));//存货名称
-					operdemandvo.setSpec(styvo.getSpec());
-					operdemandvo.setModel(styvo.getModel());
-//					operdemandvo.setColor(styvo.getColor());
-//					operdemandvo.setSizing(styvo.getSizing());
-//					operdemandvo.setAlloy(styvo.getAlloy());
-//					operdemandvo.setStandard(styvo.getStandard());
-					operdemandvo.setColor(getdefdocid(styvo.getColor(),"YS(颜色)"));
-					operdemandvo.setSizing(getdefdocid(styvo.getSizing(),"DC(定尺)"));
-					operdemandvo.setAlloy(getdefdocid(styvo.getAlloy(),"HI(合金)"));
-					operdemandvo.setStandard(getdefdocid(styvo.getStandard(),"BZ(标准)"));
-					demandvos.add(operdemandvo);
-				}
-				ivo.insertVOList(demandvos);
-				
-				// 存货主键:cmaterialcode  color : 颜色   sizing;尺寸  alloy :合金   standard : 标准   VDEF1:起订点
-				List<String> lisvos=(List<String>) iuap.executeQuery("select cmaterialcode from  ic_safetystock where isnull(dr,0)=0;", new ColumnListProcessor());
-				
-				//查询现存量
-				SqlBuilder sqlbuild=new SqlBuilder();
-				String sqlonhandnum="select  vlot,cwarehouseid,cinventoryid,cinvbasid,vfree1,vfree2,vfree3,vfree4,nonhandnum "
-						+ "from  ic_onhandnum  where cwarehouseid= (select pk_stordoc  from  bd_stordoc "
-						+ "where storcode='JZ002') and  nonhandnum>0  and  ";
-				sqlbuild.append(sqlonhandnum);
-				sqlbuild.append("cinventoryid", lisvos.toArray(new String[lisvos.size()]));
-				
-				List<OnhandunmUAPVO> lisonhandnums_gg= (List<OnhandunmUAPVO>) iuap.executeQuery(sqlbuild.toString(), new BeanListProcessor(OnhandunmUAPVO.class));
-				List<OperationSupplyVO> supplyvos=new ArrayList<OperationSupplyVO>();
-				for(OnhandunmUAPVO vo:lisonhandnums_gg) {
-					OperationSupplyVO opernsupplyvo=new  OperationSupplyVO();
-					opernsupplyvo.setSupplytype("库存量_家装库");//供应类型
-	//				opernsupplyvo.setVbatchcode(vo.getVlot());//批次
-					opernsupplyvo.setCmaterialcode(getInvbasdocValue(vo.getCinvbasid(),"invcode"));//物料编码
-					opernsupplyvo.setCmaterialname(getInvbasdocValue(vo.getCinvbasid(),"invname"));//物料名称
-					opernsupplyvo.setSpec(getInvbasdocValue(vo.getCinvbasid(),"invspec"));//规格
-					opernsupplyvo.setModel(getInvbasdocValue(vo.getCinvbasid(),"invtype"));//型号
-					opernsupplyvo.setColor(vo.getVfree1());//颜色
-					opernsupplyvo.setSizing(vo.getVfree3());//定尺
-					opernsupplyvo.setAlloy(vo.getVfree2());//合金
-					opernsupplyvo.setStandard(vo.getVfree4());//标准
-					opernsupplyvo.setNum(new UFDouble(vo.getNonhandnum()));//数量
-					opernsupplyvo.setVdef1(getStordocValue(vo.getCwarehouseid(),"storname"));//仓库名称
-					opernsupplyvo.setPk_operation(pk_operation);//主表主键
-					supplyvos.add(opernsupplyvo);
-				}
-				
-				ivo.insertVOList(supplyvos);
-				
-				
-				
-				//供需平衡结果
-				List<OperationBalanceVO> bancevos=new ArrayList<OperationBalanceVO>();
-				List<OperationBalanceVO> bancevoscg=new ArrayList<OperationBalanceVO>();//采购
-				//查询需求页签数据
-			    String sqlxq="select * from mm_operation_demand where pk_operation='"+pk_operation+"' and isnull(dr,0)=0 ";
-				List<OperationDemandVO> lisopens=(List<OperationDemandVO>) iuap.executeQuery(sqlxq, new BeanListProcessor(OperationDemandVO.class));
-				for(OperationDemandVO vo:lisopens) {
-					OperationBalanceVO bancevo=new OperationBalanceVO();
-					for(String name : bancevo.getAttributeNames()) {
-						if("ts".equals(name)) {
-							continue;
-						}else if("demandtype".equals(name)) {
-							bancevo.setDemandtype("安全库存");//需求类型
-						}else {
-							bancevo.setAttributeValue(name, vo.getAttributeValue(name));
-						}
-						
+				if(null!=lisobs2&&lisobs2.size()>0) {
+					for(int i=0;i<lisobs2.size();i++) {
+						OperationDemandVO  operdemandvo=new OperationDemandVO();
+						SafetystockVO styvo=lisobs2.get(i);
+						operdemandvo.setAlloy(styvo.getAlloy());
+						operdemandvo.setColor(styvo.getColor());
+						operdemandvo.setPk_operation(pk_operation);
+						operdemandvo.setNum(new UFDouble(styvo.getVdef1()));
+						operdemandvo.setDemandtyoe("安全库存");
+						operdemandvo.setDemanddate(PubEnv.getLoginDate().toString());
+//						operdemandvo.setWarehouse(getstordocpk("JZ002"));//仓库
+//						operdemandvo.setCmaterialcode(getCmangchid(styvo.getCmaterialcode()));//存货编码
+//						operdemandvo.setCmaterialname(styvo.getCmaterialname());//存货名称
+						String cmaterpk=styvo.getCmaterialcode();
+						operdemandvo.setCmaterialcode(getCmangcodename(cmaterpk,"invcode"));//存货编码
+						operdemandvo.setCmaterialname(getCmangcodename(cmaterpk,"invname"));//存货名称
+						operdemandvo.setSpec(styvo.getSpec());
+						operdemandvo.setModel(styvo.getModel());
+//						operdemandvo.setColor(styvo.getColor());
+//						operdemandvo.setSizing(styvo.getSizing());
+//						operdemandvo.setAlloy(styvo.getAlloy());
+//						operdemandvo.setStandard(styvo.getStandard());
+						operdemandvo.setColor(getdefdocid(styvo.getColor(),"YS(颜色)"));
+						operdemandvo.setSizing(getdefdocid(styvo.getSizing(),"DC(定尺)"));
+						operdemandvo.setAlloy(getdefdocid(styvo.getAlloy(),"HI(合金)"));
+						operdemandvo.setStandard(getdefdocid(styvo.getStandard(),"BZ(标准)"));
+						demandvos.add(operdemandvo);
 					}
-				
-					bancevos.add(bancevo);
+					ivo.insertVOList(demandvos);
 					
-					//供应数据--查询供应页签数据库数据
-					StringBuffer sbf=new StringBuffer();
-					String gysqlw="select * from mm_operation_supply where pk_operation='"+pk_operation+"' and isnull(dr,0)=0 "
-							+ "and cmaterialcode='"+bancevo.getCmaterialcode()+"' ";
-					sbf.append(gysqlw);		
-					if(null!=vo.getColor() && !"".equals(vo.getColor())) {
-						sbf.append( " and color='"+vo.getColor()+"' ");
-					}
-					if(null!=vo.getSizing() && !"".equals(vo.getSizing())) {
-						sbf.append( " and  sizing='"+vo.getSizing()+"' ");
-					}
-					if(null!=vo.getAlloy() && !"".equals(vo.getAlloy())) {
-						sbf.append( " and alloy='"+vo.getAlloy()+"' ");
-					}
-					if(null!=vo.getStandard() && !"".equals(vo.getStandard())) {
-						sbf.append( " and standard='"+vo.getStandard()+"' ");
+					// 存货主键:cmaterialcode  color : 颜色   sizing;尺寸  alloy :合金   standard : 标准   VDEF1:起订点
+					List<String> lisvos=(List<String>) iuap.executeQuery("select cmaterialcode from  ic_safetystock where isnull(dr,0)=0;", new ColumnListProcessor());
+					
+					//查询现存量
+					SqlBuilder sqlbuild=new SqlBuilder();
+					String sqlonhandnum="select  vlot,cwarehouseid,cinventoryid,cinvbasid,vfree1,vfree2,vfree3,vfree4,nonhandnum "
+							+ "from  ic_onhandnum  where cwarehouseid= (select pk_stordoc  from  bd_stordoc "
+							+ "where storcode='JZ002') and  nonhandnum>0  and  ";
+					sqlbuild.append(sqlonhandnum);
+					sqlbuild.append("cinventoryid", lisvos.toArray(new String[lisvos.size()]));
+					
+					List<OnhandunmUAPVO> lisonhandnums_gg= (List<OnhandunmUAPVO>) iuap.executeQuery(sqlbuild.toString(), new BeanListProcessor(OnhandunmUAPVO.class));
+					List<OperationSupplyVO> supplyvos=new ArrayList<OperationSupplyVO>();
+					for(OnhandunmUAPVO vo:lisonhandnums_gg) {
+						OperationSupplyVO opernsupplyvo=new  OperationSupplyVO();
+						opernsupplyvo.setSupplytype("库存量_家装库");//供应类型
+		//				opernsupplyvo.setVbatchcode(vo.getVlot());//批次
+						opernsupplyvo.setCmaterialcode(getInvbasdocValue(vo.getCinvbasid(),"invcode"));//物料编码
+						opernsupplyvo.setCmaterialname(getInvbasdocValue(vo.getCinvbasid(),"invname"));//物料名称
+						opernsupplyvo.setSpec(getInvbasdocValue(vo.getCinvbasid(),"invspec"));//规格
+						opernsupplyvo.setModel(getInvbasdocValue(vo.getCinvbasid(),"invtype"));//型号
+						opernsupplyvo.setColor(vo.getVfree1());//颜色
+						opernsupplyvo.setSizing(vo.getVfree3());//定尺
+						opernsupplyvo.setAlloy(vo.getVfree2());//合金
+						opernsupplyvo.setStandard(vo.getVfree4());//标准
+						opernsupplyvo.setNum(new UFDouble(vo.getNonhandnum()));//数量
+						opernsupplyvo.setVdef1(getStordocValue(vo.getCwarehouseid(),"storname"));//仓库名称
+						opernsupplyvo.setPk_operation(pk_operation);//主表主键
+						supplyvos.add(opernsupplyvo);
 					}
-				   //查询供应页签--现存量
-					List<OperationSupplyVO> lissupplyvos=(List<OperationSupplyVO>) iuap.executeQuery(sbf.toString(), new BeanListProcessor(OperationSupplyVO.class));
-					if(null!=lissupplyvos && lissupplyvos.size()>0) {
-						UFDouble toalnum= UFDouble.ZERO_DBL;//现存量总数量
-						for(OperationSupplyVO  supiyvo:lissupplyvos) {
-							UFDouble num=supiyvo.getNum();
-							toalnum=toalnum.add(num);
+					
+					ivo.insertVOList(supplyvos);
+					
+					
+					
+					//供需平衡结果
+					List<OperationBalanceVO> bancevos=new ArrayList<OperationBalanceVO>();
+					List<OperationBalanceVO> bancevoscg=new ArrayList<OperationBalanceVO>();//采购
+					//查询需求页签数据
+				    String sqlxq="select * from mm_operation_demand where pk_operation='"+pk_operation+"' and isnull(dr,0)=0 ";
+					List<OperationDemandVO> lisopens=(List<OperationDemandVO>) iuap.executeQuery(sqlxq, new BeanListProcessor(OperationDemandVO.class));
+					for(OperationDemandVO vo:lisopens) {
+						OperationBalanceVO bancevo=new OperationBalanceVO();
+						for(String name : bancevo.getAttributeNames()) {
+							if("ts".equals(name)) {
+								continue;
+							}else if("demandtype".equals(name)) {
+								bancevo.setDemandtype("安全库存");//需求类型
+							}else {
+								bancevo.setAttributeValue(name, vo.getAttributeValue(name));
+							}
+							
 						}
+					
+						bancevos.add(bancevo);
 						
-						//安全库存起订点大于等于现存量,需要采购
-						if(new UFDouble(vo.getNum()).compareTo(toalnum)>=0) {
+						//供应数据--查询供应页签数据库数据
+						StringBuffer sbf=new StringBuffer();
+						String gysqlw="select * from mm_operation_supply where pk_operation='"+pk_operation+"' and isnull(dr,0)=0 "
+								+ "and cmaterialcode='"+bancevo.getCmaterialcode()+"' ";
+						sbf.append(gysqlw);		
+						if(null!=vo.getColor() && !"".equals(vo.getColor())) {
+							sbf.append( " and color='"+vo.getColor()+"' ");
+						}
+						if(null!=vo.getSizing() && !"".equals(vo.getSizing())) {
+							sbf.append( " and  sizing='"+vo.getSizing()+"' ");
+						}
+						if(null!=vo.getAlloy() && !"".equals(vo.getAlloy())) {
+							sbf.append( " and alloy='"+vo.getAlloy()+"' ");
+						}
+						if(null!=vo.getStandard() && !"".equals(vo.getStandard())) {
+							sbf.append( " and standard='"+vo.getStandard()+"' ");
+						}
+					   //查询供应页签--现存量
+						List<OperationSupplyVO> lissupplyvos=(List<OperationSupplyVO>) iuap.executeQuery(sbf.toString(), new BeanListProcessor(OperationSupplyVO.class));
+						if(null!=lissupplyvos && lissupplyvos.size()>0) {
+							UFDouble toalnum= UFDouble.ZERO_DBL;//现存量总数量
+							for(OperationSupplyVO  supiyvo:lissupplyvos) {
+								UFDouble num=supiyvo.getNum();
+								toalnum=toalnum.add(num);
+							}
+							
+							//安全库存起订点大于等于现存量,需要采购
+							if(new UFDouble(vo.getNum()).compareTo(toalnum)>=0) {
+								OperationBalanceVO bancevo1=new OperationBalanceVO();
+								bancevo1.setSupplytype("库存量_家装库");//供应类型
+								bancevo1.setWarehouse("家装库");//仓库
+								bancevo1.setProexecutenum(new UFDouble(vo.getNum()).sub(toalnum).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//建议执行数量
+								bancevo1.setMatchnum(new UFDouble(vo.getNum()).sub(toalnum).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//已匹配主数量
+								bancevo1.setSurdenum(UFDouble.ZERO_DBL.setScale(2,UFDouble.ROUND_HALF_UP ).toString());//剩余需求主数量
+								bancevo1.setPk_operation(pk_operation);
+								bancevo1.setCmaterialcode(bancevo.getCmaterialcode());//存货编码
+								bancevo1.setCmaterialname(bancevo.getCmaterialname());//存货名称
+								bancevo1.setSpec(bancevo.getSpec());//规格
+								bancevo1.setModel(bancevo.getModel());//型号
+								bancevo1.setColor(bancevo.getColor());//颜色
+								bancevo1.setSizing(bancevo.getSizing());//定尺
+								bancevo1.setAlloy(bancevo.getAlloy());//合金
+								bancevo1.setStandard(bancevo.getStandard());//标准
+								bancevo1.setWeight(bancevo.getWeight());//米重
+								bancevo1.setUnitid(bancevo.getUnitid());//计量单位
+								bancevo1.setProexecute("采购");//建议执行
+								bancevos.add(bancevo1);
+								bancevo1.setVdef23(toalnum.setScale(2, UFDouble.ROUND_HALF_UP).toString());//现存量
+								bancevo1.setVdef22(vo.getNum().setScale(2, UFDouble.ROUND_HALF_UP).toString());//起订点
+								bancevoscg.add(bancevo1);
+								
+							}
+							
+							
+						}else {
 							OperationBalanceVO bancevo1=new OperationBalanceVO();
 							bancevo1.setSupplytype("库存量_家装库");//供应类型
 							bancevo1.setWarehouse("家装库");//仓库
-							bancevo1.setProexecutenum(new UFDouble(vo.getNum()).sub(toalnum).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//建议执行数量
-							bancevo1.setMatchnum(new UFDouble(vo.getNum()).sub(toalnum).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//已匹配主数量
-							bancevo1.setSurdenum(UFDouble.ZERO_DBL.setScale(2,UFDouble.ROUND_HALF_UP ).toString());//剩余需求主数量
+							bancevo1.setProexecutenum(new UFDouble(vo.getNum()).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//建议执行数量
+							bancevo1.setMatchnum(new UFDouble(vo.getNum()).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//已匹配主数量
+							bancevo1.setSurdenum(UFDouble.ZERO_DBL.toString());//剩余需求主数量
 							bancevo1.setPk_operation(pk_operation);
 							bancevo1.setCmaterialcode(bancevo.getCmaterialcode());//存货编码
 							bancevo1.setCmaterialname(bancevo.getCmaterialname());//存货名称
@@ -1227,76 +1261,68 @@ public class YsAction extends YsQuseryAction{
 							bancevo1.setWeight(bancevo.getWeight());//米重
 							bancevo1.setUnitid(bancevo.getUnitid());//计量单位
 							bancevo1.setProexecute("采购");//建议执行
-							bancevoscg.add(bancevo1);
 							bancevos.add(bancevo1);
+							bancevo1.setVdef23(UFDouble.ZERO_DBL.setScale(2, UFDouble.ROUND_HALF_UP).toString());//现存量
+							bancevo1.setVdef22(vo.getNum().setScale(2, UFDouble.ROUND_HALF_UP).toString());//起订点
+							bancevoscg.add(bancevo1);
+							
 						}
-						
-						
-					}else {
-						OperationBalanceVO bancevo1=new OperationBalanceVO();
-						bancevo1.setSupplytype("库存量_家装库");//供应类型
-						bancevo1.setWarehouse("家装库");//仓库
-						bancevo1.setProexecutenum(new UFDouble(vo.getNum()).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//建议执行数量
-						bancevo1.setMatchnum(new UFDouble(vo.getNum()).setScale(2,UFDouble.ROUND_HALF_UP ).toString());//已匹配主数量
-						bancevo1.setSurdenum(UFDouble.ZERO_DBL.toString());//剩余需求主数量
-						bancevo1.setPk_operation(pk_operation);
-						bancevo1.setCmaterialcode(bancevo.getCmaterialcode());//存货编码
-						bancevo1.setCmaterialname(bancevo.getCmaterialname());//存货名称
-						bancevo1.setSpec(bancevo.getSpec());//规格
-						bancevo1.setModel(bancevo.getModel());//型号
-						bancevo1.setColor(bancevo.getColor());//颜色
-						bancevo1.setSizing(bancevo.getSizing());//定尺
-						bancevo1.setAlloy(bancevo.getAlloy());//合金
-						bancevo1.setStandard(bancevo.getStandard());//标准
-						bancevo1.setWeight(bancevo.getWeight());//米重
-						bancevo1.setUnitid(bancevo.getUnitid());//计量单位
-						bancevo1.setProexecute("采购");//建议执行
-						bancevos.add(bancevo1);
-						bancevoscg.add(bancevo1);
-						
+					
 					}
-				
-				}
-				
-				ivo.insertVOList(bancevos);
-				
-				
-				// 采购需求  
-				if(null!=bancevoscg && bancevoscg.size()>0) {
-					OperationPurchaseVO[] purchasevos=new OperationPurchaseVO[bancevoscg.size()];
-					int flg=0;
-					for(OperationBalanceVO cgdd : bancevoscg) {
-						OperationPurchaseVO vo=new OperationPurchaseVO();
-						vo.setPrjcode(cgdd.getPrjcode());
-						vo.setPrjname(cgdd.getPrjname());
-						vo.setPrjtypecode(cgdd.getPrjtypecode());
-						vo.setPrjtypename(cgdd.getPrjtypename());
-						vo.setVbatchcode(cgdd.getVbatchcode());
-						vo.setWarehouse(cgdd.getWarehouse());
-						vo.setCmaterialcode(cgdd.getCmaterialcode());
-						vo.setCmaterialname(cgdd.getCmaterialname());
-						vo.setSpec(cgdd.getSpec());
-						vo.setModel(cgdd.getModel());
-						vo.setColor(cgdd.getColor());
-						vo.setSizing(cgdd.getSizing());
-						vo.setAlloy(cgdd.getAlloy());
-						vo.setStandard(cgdd.getStandard());
-						vo.setWeight(cgdd.getWeight());
-						vo.setNum(new UFDouble(cgdd.getProexecutenum()));
-						vo.setNprice(cgdd.getNprice());
-						vo.setNmny(cgdd.getNmny());
-						vo.setPk_operation(pk_operation);
-						purchasevos[flg]=vo;
-						flg+=1;
+					
+					ivo.insertVOList(bancevos);
+					
+					
+					// 采购需求  
+					if(null!=bancevoscg && bancevoscg.size()>0) {
+						OperationPurchaseVO[] purchasevos=new OperationPurchaseVO[bancevoscg.size()];
+						int flg=0;
+						for(OperationBalanceVO cgdd : bancevoscg) {
+							OperationPurchaseVO vo=new OperationPurchaseVO();
+							vo.setPrjcode(cgdd.getPrjcode());
+							vo.setPrjname(cgdd.getPrjname());
+							vo.setPrjtypecode(cgdd.getPrjtypecode());
+							vo.setPrjtypename(cgdd.getPrjtypename());
+							vo.setVbatchcode(cgdd.getVbatchcode());
+							vo.setWarehouse(cgdd.getWarehouse());
+							vo.setCmaterialcode(cgdd.getCmaterialcode());
+							vo.setCmaterialname(cgdd.getCmaterialname());
+							vo.setSpec(cgdd.getSpec());
+							vo.setModel(cgdd.getModel());
+							vo.setColor(cgdd.getColor());
+							vo.setSizing(cgdd.getSizing());
+							vo.setAlloy(cgdd.getAlloy());
+							vo.setStandard(cgdd.getStandard());
+							vo.setWeight(cgdd.getWeight());
+							
+							vo.setNprice(cgdd.getNprice());
+							vo.setNmny(cgdd.getNmny());
+							vo.setPk_operation(pk_operation);
+							vo.setVdef23(cgdd.getVdef23());//现存量
+							vo.setVdef22(cgdd.getVdef22());//最大库存起订点
+							//查询采购订单
+							String sql="select sum (po_order_b.nordernum) nordernum  from po_order_b  inner join  bd_invbasdoc  on  po_order_b.cbaseid = bd_invbasdoc .pk_invbasdoc "
+									+ "and po_order_b.vproducenum ='家装' and  isnull(po_order_b.dr,0)=0   and  isnull(bd_invbasdoc.dr,0)=0 and  bd_invbasdoc.invcode ='"+cgdd.getCmaterialcode()+"'";
+							
+							Object num=iuap.executeQuery(sql, new ColumnProcessor());
+							
+							vo.setVdef24(num==null?"0.00":new UFDouble(num.toString()).setScale(2, UFDouble.ROUND_HALF_UP).toString());//家装在途数量
+							UFDouble zxcl=new UFDouble(cgdd.getProexecutenum()).sub(num==null?UFDouble.ZERO_DBL:new UFDouble(num.toString()).setScale(2, UFDouble.ROUND_HALF_UP));
+							vo.setNum(zxcl);//建议执行数量
+							vo.setVdef26(zxcl.setScale(2, UFDouble.ROUND_HALF_UP).toString());
+							vo.setPk_operation(pk_operation);
+							purchasevos[flg]=vo;
+							flg+=1;
+						}
+						ivo.insertVOArray(purchasevos);
+						
 					}
-					ivo.insertVOArray(purchasevos);
+				}else {
 					
+					throw new ValidationException("没有符合条件的安全库存数据!");
 				}
 				
-				
-				getDataModel().setExtraCondition(" and pk_corp = '" + Global.getCorpPK() + "'"+" and pk_operation=  '" + pk_operation + "'"   );
-				
-				
+				getDataModel().setExtraCondition(" and pk_corp = '" + Global.getCorpPK() + "'"+" and pk_operation=  '" + pk_operation + "'"   );				
 			}