在开发NC5系列的单据时,当我们要根据表体的字段进行查询时,查询报 sql异常,这个是NC5系列单据的一个BUg ,处理的方法就是重写查询方法,主要的思路就是把表头表体关联起来,参考代码如下:
@Override
protected void onBoQuery() throws Exception {
// TODO Auto-generated method stub
//add by QIU 2013年4月17日9:52:16 重写查询方法,增加表体作为查询条件
//super.onBoQuery();
UIDialog querydialog = getQueryUI();
if (querydialog.showModal() != UIDialog.ID_OK)
return;
INormalQuery query = (INormalQuery) querydialog;
String strWhere = query.getWhereSql();
if (strWhere == null || strWhere.trim().length()==0)
strWhere = "1=1";
if (getHeadCondition() != null)
strWhere = strWhere + " and shht_jsbill_h." + getHeadCondition();
StringBuffer sqlwhere = new StringBuffer();
//自己进行拼接查询语句
sqlwhere.append("select distinct shht_jsbill_h.* from shht_jsbill_h shht_jsbill_h , shht_jsbill_b shht_jsbill_b , shht_jstype shht_jstype ," +
"bd_deptdoc bd_deptdoc where shht_jsbill_h.pk_jsbill_h = shht_jsbill_b.pk_jsbill_h and shht_jstype.pk_jstype = shht_jsbill_b.pk_jstype " +
"and bd_deptdoc.pk_deptdoc = shht_jsbill_b.pk_deptdoc and ");
// sqlwhere.append("select shht_jsbill_h.* from shht_jsbill_h shht_jsbill_h " +
// "inner join shht_jsbill_b shht_jsbill_b on shht_jsbill_h.pk_jsbill_h = shht_jsbill_b.pk_jsbill_h " +
// "inner join shht_jstype shht_jstype on shht_jstype.pk_jstype = shht_jsbill_b.pk_jstype " +
// "inner join bd_deptdoc bd_deptdoc on bd_deptdoc.pk_deptdoc = shht_jsbill_b.pk_deptdoc where ");
sqlwhere.append(strWhere.toString());
sqlwhere.append("and nvl(shht_jsbill_h.dr,0) = 0 and nvl(shht_jsbill_b.dr,0) = 0 and nvl(shht_jstype.dr,0) = 0 and nvl(bd_deptdoc.dr,0) = 0 order by shht_jsbill_h.billno ");
ArrayList result=(ArrayList) SHHTProxy.getIUAPQueryBS().executeQuery(sqlwhere.toString(),
new BeanListProcessor(JsBillHVO.class));
JsBillHVO[] jsbillhvo = null;
if (result != null && result.size() > 0) {
jsbillhvo = (JsBillHVO[]) result.toArray(new JsBillHVO[result
.size()]);
}
getBufferData().clear();
// 增加数据到Buffer
addDataToBuffer(jsbillhvo);
updateBuffer();
//end by QIU
}