package xin.glue.ui.B.B02; 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.PosJdbcDao; import com.posdata.glue.dao.manager.PosQueryDefinition; import com.posdata.glue.dao.manager.PosQueryManager; import com.posdata.glue.dao.vo.PosParameter; import com.posdata.glue.dao.vo.PosRow; import com.posdata.glue.dao.vo.PosRowSet; /** * * @Description 查询各样片号对应的实绩及实际的样片号{界面ID:ID:UIB020132} * @author 梅贵平{meiguiping} * @date 2008-12-13 上午09:42:03 * @JDK Version jdk1.4.2 */ public class FindSmpGrade extends PosActivity { public String runActivity(PosContext context) { ///ready MutilConditionFind mcf = new MutilConditionFind(); PosGenericDao dao = this.getDao("mesdao"); PosParameter param = null; PosRow row = null; ///get request data String[] P_SMPNO = (String[])context.get("SMPNO"); //样片号 String[] P_SMPCUTLOC= (String[])context.get("SMPCUTLOC");//位置 //查询某SMP_NO所对应的CONV_SMP_NO的CONV_SMP_NO_FLAG = 'Y'的相同材质的SMP_NO param = new PosParameter(); param.setWhereClauseParameter(0, P_SMPNO[0]); param.setWhereClauseParameter(1, P_SMPCUTLOC[0]); PosRowSet rowset = dao.find("UIB020132_04.SELECT", param); int j = 1; String select = ""; if("W".equals(P_SMPCUTLOC[0]))//若取样位置为W { select = mcf.getQuerySql("UIB020132_03_W.SELECT").toString(); } else//若取样位置非W { select = mcf.getQuerySql("UIB020132_03_BT.SELECT").toString(); } StringBuffer mid= new StringBuffer(300); String sql = ""; String temp = mcf.getQuerySql("UIB020132_03.LOOP").toString();//获取SQL的动态部分 StringBuffer sb = new StringBuffer(100); while(rowset.hasNext()) { row = rowset.next(); sql = temp.replaceAll("[{]+[0]+[}]+", row.getAttribute("SMP").toString()); sql = sql.replaceAll("[{]+[1]+[}]+", new Integer(j++).toString()); sb.append(", NULL"); mid.append(sql+"\n"); } param = new PosParameter(); param.setWhereClauseParameter(0, P_SMPNO[0]); param.setWhereClauseParameter(1, P_SMPNO[0]); String sss = select.replaceFirst("[{]+[1]+[}]+", mid.toString()).replaceFirst("[{]+[2]+[}]+", sb.toString()); PosRowSet rs = dao.findByQueryStatement(sss , param); context.put("GradeResult", rs); return PosBizControlConstants.SUCCESS; } }