|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
1.查询条件主子转换
public void onBoQuery() throws Exception{
StringBuffer strWhere = new StringBuffer();
if (askForQueryCondition(strWhere) == false)
return;// 用户放弃了查询
SuperVO[] queryVos = queryHeadVOs(convertSqlWhere(strWhere,"kyss_install_b",
new String[]{"kyss_install_b.vdebugid","kyss_install_b.vinstallid","kyss_install_b.dhd_spname"},
"pk_install"));
getBufferData().clear();
addDataToBuffer(queryVos);
updateBuffer();
}
/**
* 转换查询模板中的子表条件为主表条件,子表条件应与查询模板中一致
* @param strWhere
* @param tab_b 子表名
* @param fields 子表条件项
* @param refField 关联的主表pk
* @return
* @throws Exception
*/
public String convertSqlWhere(StringBuffer strWhere,String tab_b,String[] fields,String refField) throws Exception{
String str = "";
String newSql = strWhere.toString();
for (int i = 0; i < fields.length; i++) {
ConditionVO[] vo =
((HYQueryDLG) getQueryUI()).getConditionVOsByFieldCode(fields[i]);
if (!Toolkit.isEmpty(vo)) {
if (!Toolkit.isEmpty(vo[0].getValue())) {
str = vo[0].getValue();
}
if (!Toolkit.isEmpty(vo[0].getValue())) {
newSql = Toolkit.replaceAll(newSql, fields[i], "'1'");
newSql = Toolkit.replaceAll(newSql, str, "1");
newSql = newSql + " and "+refField+" in (";
newSql = newSql + " select pk_install from "+tab_b;
newSql = newSql + " where "+fields[i]+" = '" + str + "' and nvl(dr, 0) = 0)";
}
}
}
return newSql;
}
getBillCardPanel().getBillModel("costs").setValueAt(oVer,arow,"pver");
//修改行状态
bm.setRowState(arow, BillModel.MODIFICATION);
2.判断表体列不重复
public int uniqueCheck(BillModel bm,String[] code){
int res= -1;
HashMap hm=new HashMap();
for(int i=0;i<bm.getRowCount();i++){
String key="key";
for(int j=0;j<code.length;j++){
key+=bm.getValueAt(i,code[j])==null?"":bm.getValueAt(i,code[j]).toString();
}
if(hm.containsKey(key)){
return i+1;
}
hm.put(key, i+"");
}
return res;
}
public int uniqueCheck(CircularlyAccessibleValueObject[] cvos,String[] code){
int res= -1;
HashMap hm=new HashMap();
for(int i=0;i<cvos.length;i++){
String key="key";
for(int j=0;j<code.length;j++){
key += cvos[i].getAttributeValue(code[j]) == null? "" : cvos[i].getAttributeValue(code[j]).toString();
}
if(hm.containsKey(key)){
return i+1;
}
hm.put(key, i+"");
}
return res;
} |
|