NC 5、6代码开发报表方法:
继承类:import nc.pub.fa.report.base.FAReportCodeProcess;
public class AccountLockInfoReport extends FAReportCodeProcess {
public AccountLockInfoReport(CodeProcessor processor) {
super(processor);
}
public static DataSet getAccLockDataSet() {
int headColumn = 4;// 表头列数
语义模型调用:
DataSet dataSet=hz.report.account.lockinfo.AccountLockInfoReport.getAccLockDataSet();
/**
* 添加表头
*
* @param name
* @param text
* @return
*/
private static Field addhead(String name, String text) {
Field newfield = new Field();
MultiLangText newtext = new MultiLangText();
newfield.setFldname(name);
newtext.setText(text);
newfield.setMultiLangText(newtext);
return newfield;
}
// 添加表头 {
DataSet lockDataSet = new DataSet();
Field newfields[] = new Field[headColumn];
MetaData newmetaData = new MetaData();
newfields[0] = (Field) addhead("user_code", "用户编码").clone();// 用户编码
newfields[1] = (Field) addhead("user_name", "用户名").clone();// 用户名
newfields[2] = (Field) addhead("org_book_name", "账簿名称").clone();// 账簿名称
newfields[3] = (Field) addhead("org_book_code", "账簿编码").clone();// 账簿编码
newmetaData.addField(newfields);
lockDataSet.setMetaData(newmetaData);
// 添加表头 }
// 遍历用户信息,封装数据集
// 添加表体 {
Object[][] badyObj = new Object[lockNum][headColumn];// 返回dataset时的表体数据
lockDataSet.setDatas(badyObj);
// 添加表体 }
核心代码:
int headColumn = 3;
nc.itf.uap.LockableVO[] tc = nc.bs.uap.lock.PKLock.getInstance()
.getUserLockVOs("10011210000000000009",
nc.bs.framework.common.InvocationInfoProxy.getInstance()
.getUserDataSource());
// 添加表头 {
DataSet newds = new DataSet();
Field[] newfields = new Field[headColumn];
MetaData newmetaData = new MetaData();
Field newfield1 = new Field();
nc.vo.pub.lang.MultiLangText newtext1 = new nc.vo.pub.lang.MultiLangText();
newtext1.setText("用户名称");
newfield1.setFldname("username");
newfield1.setMultiLangText(newtext1);
newfields[0] = newfield1;
Field newfield2 = new Field();
nc.vo.pub.lang.MultiLangText newtext2 = new nc.vo.pub.lang.MultiLangText();
newtext2.setText("账簿编码");
newfield2.setFldname("acccode");
newfield2.setMultiLangText(newtext2);
newfields[1] = newfield2;
Field newfield3 = new Field();
nc.vo.pub.lang.MultiLangText newtext3 = new nc.vo.pub.lang.MultiLangText();
newtext3.setText("账簿名称");
newfield3.setFldname("accname");
newfield3.setMultiLangText(newtext3);
newfields[2] = newfield3;
newmetaData.addField(newfields);
newds.setMetaData(newmetaData);
// 添加表头 }
//添加表体 {
Object[][] obj = new Object[tc.length][headColumn]; // 返回dataset时的表体数据
//遍历查询出的结果集,在此加工处理
for (int a = tc.length - 1; a >= 0; a--) {
obj[a][0] = tc[a].getLockable(); //账簿pk
obj[a][1] = tc[a].getUserID(); //用户id
obj[a][2] = tc[a].getLockable(); //账簿pk
}
newds.setDatas(obj);
//添加表体 }
setDataSet(newds);
xms自己写的数据加工:
IUAPQueryBS iuapQueryBS = NCLocator.getInstance()
.lookup(IUAPQueryBS.class);
//总账节点主键
String pk_account_table = "000112100000001RVOIW";
StringBuffer pk_user_inAccount = new StringBuffer();
StringBuffer user_sql = new StringBuffer();
user_sql.append(
"select sm_user.cuserid from sm_user sm_user where nvl(sm_user.dr,0)=0; ");
//查出nc所有用户信息
ArrayList<String> pk_users = new ArrayList<String>();
try {
pk_users = (ArrayList<String>) iuapQueryBS.executeQuery(user_sql.toString(),
new ColumnListProcessor());
} catch (BusinessException e) {
e.printStackTrace();
}
//遍历用户信息,看有哪个用户登录总账节点
if (pk_users.size() > 0) {
for (String pk_user : pk_users) {
LockableVO[] lockablevos = PKLock.getInstance()
.getUserLockVOs(pk_user,
InvocationInfoProxy.getInstance().getUserDataSource());
if ((lockablevos != null) && (lockablevos.length > 0)) {
for (LockableVO lockablevo : lockablevos) {
if (pk_account_table.equals(lockablevo.getLockable())) {
pk_user_inAccount.append("'" +
lockablevo.getUserID() + "'" + ",");
}
}
}
}
}
if (pk_user_inAccount.length() > 0) {
pk_user_inAccount.substring(pk_user_inAccount.length() - 1);
} else {
pk_user_inAccount.append("''");
}
//查询总账节点锁住用户信息
StringBuffer user_inAccount_sql = new StringBuffer();
user_inAccount_sql.append(
"select sm_user.user_name, sm_user.user_code ");
user_inAccount_sql.append(" from sm_user sm_user ");
user_inAccount_sql.append(" where nvl(sm_user.dr, 0) = 0 ");
user_inAccount_sql.append(" and sm_user.cuserid in (" +
pk_user_inAccount.toString() + "); ");
//测试用户:tc
LockableVO[] tc = PKLock.getInstance()
.getUserLockVOs("10011210000000000009",
InvocationInfoProxy.getInstance().getUserDataSource());
String str = null;
if ((tc != null) && (tc.length > 0)) {
str = tc[0].getLockable();
}
setResultSQL(user_inAccount_sql.toString());
数据加工配置:
String sql = hz.report.account.lockinfo.AccountLockInfoReport.getAccLockSql();
setResultSQL(sql);
DataSet dataSet = hz.report.account.lockinfo.AccountLockInfoReport.getAccLockDataSet();
setDataSet(dataSet); 保利总账登录账簿锁表查看锁表用户及账簿信息报表170111_v2
0020063-0002 0020063-0002 1001A6100000001E1TXDsettling account