单据分页的实现
1. AceWzcgfkjtMaintainProxy.java
package nc.ui.jych.wzcgfkjt.ace.serviceproxy;
import nc.bs.framework.common.NCLocator;
import nc.itf.jych.IWzcgfkjtMaintain;
import nc.ui.uif2.components.pagination.IPaginationQueryService;
import nc.vo.jych.wzcgfkjt.AggWzcgfkjtVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
/**
* 示例单据的操作代理
*
* @author author
* @version tempProject version
*/
public class AceWzcgfkjtMaintainProxy implements IPaginationQueryService {
@Override
public Object[] queryObjectByPks(String[] pks)
throws BusinessException {
// TODO 自动生成的方法存根
AggWzcgfkjtVO[] aggvo = null;
IWzcgfkjtMaintain query = NCLocator.getInstance().lookup(IWzcgfkjtMaintain.class);
try {
aggvo = query.queryBillByPK(pks);
} catch (Exception e) {
ExceptionUtils.wrappException(e);
}
return aggvo;
}
}
2. Wzcgfkjt_config.xml
<!--分页新增这三个bean-->
<bean id="maintainProxy" class="nc.ui.jych.wzcgfkjt.ace.serviceproxy.AceWzcgfkjtMaintainProxy" />
<bean id="paginationModel" class="nc.ui.pubapp.uif2app.model.pagination.PubPaginationModel"
init-method="init">
<property name="paginationQueryService" ref="maintainProxy" />
</bean>
<bean id="paginationBar" class="nc.ui.uif2.components.pagination.PaginationBar" init-method="onStructChanged">
<property name="paginationModel" ref="paginationModel" />
</bean>
<!-- 应用服务类,负责进行模型操作的处理 -->
<bean id="bmModelModelService" class="nc.ui.jych.wzcgfkjt.ace.serviceproxy.AceWzcgfkjtMaintainProxy"/>
<!--分页新增这二个bean-->
<bean id="bmModelModelDataManager" class="nc.ui.pubapp.uif2app.model.pagination.PaginationModelDataManager">
<property name="model" ref="bmModel"></property>
<property name="paginationModel" ref="paginationModel" />
<property name="pageQueryService" ref="pageQueryService" />
</bean>
<bean id="pageQueryService" class="nc.ui.pubapp.uif2app.model.pagination.UIPageQueryService">
<property name="allPagePkQueryServiceMethod" value="nc.itf.jych.IWzcgfkjtMaintain.queryPKs"></property>
<property name="dataOfPksQueryServiceMethod" value="nc.itf.jych.IWzcgfkjtMaintain.queryBillByPK"></property>
</bean>
<!--分页新增这个property-->
<property name="paginationBar" ref="paginationBar" />
3. AceWzcgfkjtPubServiceImpl.java
package nc.impl.pub.ace;
import java.util.ArrayList;
import java.util.List;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.impl.pubapp.pattern.data.bill.BillQuery;
import nc.impl.pubapp.pattern.database.DataAccessUtils;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ArrayListProcessor;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.jych.wzcgfkjt.AggWzcgfkjtVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.bill.pagination.util.PaginationUtils;
import nc.vo.pubapp.pattern.data.IRowSet;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.pub.SqlBuilder;
import nc.vo.pubapp.query2.sql.process.QuerySchemeProcessor;
import nc.vo.zkch.utils.NullValueUtils;
public abstract class AceWzcgfkjtPubServiceImpl {
//分页查询方法,根据PK查单据
public AggWzcgfkjtVO[] pubquerybillbypkbills(String[] pks) {
AggWzcgfkjtVO[] bills = null;
BillQuery<AggWzcgfkjtVO> query =
new BillQuery<AggWzcgfkjtVO>(AggWzcgfkjtVO.class);
bills = query.query(pks);
return PaginationUtils.filterNotExistBills(bills, pks);
}
//分页查询方法,查询所有PK
public String[] pubquerypkbills(IQueryScheme queryScheme) {
// String beanId=(String) queryScheme.get(QueryConstants.BEAN_ID);
StringBuffer sql = new StringBuffer();
QuerySchemeProcessor processor = new QuerySchemeProcessor(queryScheme);
String mainAlias = processor.getMainTableAlias();
sql.append(" select distinct ");
sql.append(mainAlias);
sql.append(".");
sql.append("pk_wzcgfkjt");
sql.append(processor.getFinalFromWhere());
//系统当前登录用户
String userId = InvocationInfoProxy.getInstance().getUserId();
//根据登录用户id查询对应的人员id
IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class);
String sql1 =
"select psndoc.pk_psndoc from bd_psndoc psndoc left join sm_user smuser on smuser.pk_psndoc = psndoc.pk_psndoc where smuser.cuserid = '"
+ userId + "' and nvl(psndoc.dr,0) = 0 and nvl(smuser.dr,0) = 0";
String pk_psndoc = "";
List<String> yhlist = new ArrayList<String>();
List<String> rylist = new ArrayList<String>();
try {
pk_psndoc = NullValueUtils.getNullStringValue(bs.executeQuery(sql1, new ColumnProcessor()));
if(!pk_psndoc.equals("")) {
SqlBuilder sqlBuilder = new SqlBuilder();
sqlBuilder.append(" select distinct ry.pk_psndoc, yh.cuserid ");
sqlBuilder.append(" from sm_user yh ");
sqlBuilder.append(" inner join bd_psndoc ry ");
sqlBuilder.append(" on yh.pk_psndoc = ry.pk_psndoc ");
sqlBuilder.append(" and nvl(ry.dr, 0) = 0 ");
sqlBuilder.append(" where ry.def9 = '"+pk_psndoc+"' ");
List<Object[]> list = (List<Object[]>) bs.executeQuery(sqlBuilder.toString(), new ArrayListProcessor());
if(list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Object[] objs = list.get(i);
yhlist.add(NullValueUtils.getNullStringValue(objs[1]));
rylist.add(NullValueUtils.getNullStringValue(objs[0]));
}
}
}
} catch (BusinessException e) {
ExceptionUtils.wrappBusinessException(e.getMessage());
}
yhlist.add(userId);
rylist.add(pk_psndoc);
SqlBuilder rytj = new SqlBuilder();
rytj.append(" "+mainAlias+".pk_psndoc ",rylist.toArray(new String[0]));
SqlBuilder yhtj = new SqlBuilder();
yhtj.append(" "+mainAlias+".creator ",yhlist.toArray(new String[0]));
//查询出制单人为当前登录人的记录(当前跟踪人为空)。
// sql.append(" and ( " +yhtj.toString()+" ) ");
DataAccessUtils dao = new DataAccessUtils();
IRowSet rowset = dao.query(sql.toString());
String[] keys = rowset.toOneDimensionStringArray();
return keys;
}
}
4. WzcgfkjtMaintainImpl.java
package nc.impl.jych;
import java.util.Arrays;
import java.util.List;
import nc.impl.pub.ace.AceWzcgfkjtPubServiceImpl;
import nc.itf.jych.IWzcgfkjtMaintain;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.jych.wzcgfkjt.AggWzcgfkjtVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.IVOMeta;
public class WzcgfkjtMaintainImpl extends AceWzcgfkjtPubServiceImpl
implements IWzcgfkjtMaintain {
@Override
public AggWzcgfkjtVO[] queryBillByPK(String[] pks) throws BusinessException {
AggWzcgfkjtVO[] pubquerybillbypkbills = super.pubquerybillbypkbills(pks);
if (pubquerybillbypkbills != null && pubquerybillbypkbills.length > 0) {
for (AggWzcgfkjtVO aggVO : pubquerybillbypkbills) {
IVOMeta[] children = aggVO.getMetaData().getChildren();
if (children != null && children.length != 0) {
for (IVOMeta item : children) {
CircularlyAccessibleValueObject[] childrenVO = (CircularlyAccessibleValueObject[]) aggVO
.getChildren(item);
// @SuppressWarnings("unchecked")
List<CircularlyAccessibleValueObject> asList = Arrays.asList(childrenVO);
// asList.sort((x, y) -> Double.compare(
// x.getAttributeValue("rowno") == null ? 0
// : new Double(x.getAttributeValue("rowno").toString()),
// y.getAttributeValue("rowno") == null ? 0
// : new Double(y.getAttributeValue("rowno").toString())));
}
}
}
}
return super.pubquerybillbypkbills(pks);
}
@Override
public String[] queryPKs(IQueryScheme queryScheme) throws BusinessException {
return super.pubquerypkbills(queryScheme);
}
}