package xin.glue.ui.B.B01; import xin.glue.ui.B.B02.MutilConditionFind; import com.posdata.glue.biz.activity.PosActivity; import com.posdata.glue.biz.constants.PosBizControlConstants; import com.posdata.glue.context.PosContext; import com.posdata.glue.dao.PosGenericDao; import com.posdata.glue.dao.vo.PosParameter; import com.posdata.glue.dao.vo.PosRow; import com.posdata.glue.dao.vo.PosRowSet; /** * * @Description 材质现况查询,材质代码需要动态生成{界面ID:UIB010120} * @author 梅贵平{meiguiping} * @date 2008-11-20 下午05:31:09 * @JDK Version jdk1.4.2 */ public class FindQltyState extends PosActivity { public String runActivity(PosContext context) { PosGenericDao dao = this.getDao("mesdao"); PosParameter param= null; PosRowSet qltyRow = null; //存储所查询的客户或标准的材质代码信息 PosRowSet rowset = null; String[] SelectRadio= (String[])context.get("SelectRadio");//查询先觉条件(客户或者标准信息查询) String[] CustCD = (String[])context.get("CompID");//客户公司代码 String[] SpecAbbsym = (String[])context.get("SA");//标准号 String[] SpecStlGrd = (String[])context.get("SpecStlGrd");//标准钢号 if(SelectRadio==null) return PosBizControlConstants.SUCCESS; String first = ""; String end = ""; String temp = "";//用于获取动态SQL部分 String qMark = ""; MutilConditionFind mcf = new MutilConditionFind(); /* * 首先获得满足条件(客户公司代码或标准号)的材质代码,然后取出查询出来的材质代码,再动态生成最终的SQL * */ if("1".equals(SelectRadio[0]))//查询客户材质信息 { param = new PosParameter(); qMark = CustCD[0]; param.setWhereClauseParameter(0, qMark); qltyRow = dao.find("UIB010120_01.SELECT", param); first = " SELECT CUST_SPEC_NO "; end = mcf.getQuerySql("UIB010120_CUST.END").toString(); } else if("2".equals(SelectRadio[0]))//查询标准材质信息 { param = new PosParameter(); qMark = SpecAbbsym[0]; param.setWhereClauseParameter(0, qMark); param.setWhereClauseParameter(1, SpecStlGrd[0]); qltyRow = dao.find("UIB010120_02.SELECT", param); first = mcf.getQuerySql("UIB010120_SPEC.START").toString(); end = mcf.getQuerySql("UIB010120_SPEC.END").toString(); } context.put("QltyNM", qltyRow); temp = mcf.getQuerySql("UIB010120.MID").toString(); PosRow row = null; String mid = null;//用于存储每一小步循环 StringBuffer sql = new StringBuffer(2000);//用于存储最终的循环部分 int j = 1;//用于循环增加,如max1,max2,max3等 if(qltyRow!=null && qltyRow.count()>0) //若查询出有材质代码的记录 { while(qltyRow.hasNext()) { row = qltyRow.next(); mid = temp.replaceAll("[{]+[0]+[}]+", row.getAttribute("QLTY_CD").toString()); mid = mid.replaceAll("[{]+[1]+[}]+" , new Integer(j++).toString()); sql = sql.append(mid); } } if(sql.length()>0 && "2".equals(SelectRadio[0]))//说明查询中有材质代码记录 { param = new PosParameter(); param.setWhereClauseParameter(0, qMark); param.setWhereClauseParameter(1, SpecStlGrd[0]); rowset = dao.findByQueryStatement(first+"\n"+sql+"\n"+end, param); context.put("QltyResult", rowset); } else if(sql.length()>0 && "1".equals(SelectRadio[0])) { param = new PosParameter(); param.setWhereClauseParameter(0, CustCD[0]); rowset = dao.findByQueryStatement(first+"\n"+sql+"\n"+end, param); context.put("QltyResult", rowset); } return PosBizControlConstants.SUCCESS; } }