当前位置:文档之家› NC数据加工做语义模型(DOC)

NC数据加工做语义模型(DOC)

报表语义模型(数据加工:返回结果集方式)数据加工方式:1.返回查询SQL ; 2.返回结果集DataSet;3.返回数据表。

实现方式基本一致,可以参照系统原有报表语义模型一、新建报表查询入口类,初始化报表字段1.数据加工查询业务处理接口的定义:package nc.itf.fbm.paperbill.query;import nc.pub.smart.data.DataSet;import nc.vo.pub.BusinessException;import com.ufida.dataset.IContext;/**票据信息查询/票据池额度查询接口** @author 温燕荣WYR* @date 2014-04-15*/public interface IFbmQueryPaperBillService {/*** 票据信息查询* @param context* @return* @throws BusinessException*/public DataSet queryPaperBillInfo(IContext context) throws Exception;/*** 票据池额度查询接口* @param context* @return* @throws BusinessException*/public DataSet queryPaperBillPoolLimit(IContext context) throws Exception;}2.数据加工入口类,初始化报表字段package nc.itf.fbm.paperbill.query;import java.util.ArrayList;import java.util.List;import mon.NCLocator;import nc.pub.smart.data.DataSet;import nc.pub.smart.metadata.DataTypeConstant;import nc.pub.smart.metadata.Field;import nc.pub.smart.metadata.MetaData;import nc.vo.obm.paperbill.query.PaperBillPoolVO;import com.ufida.dataset.IContext;/**票据池额度查询入口类** @author 温燕荣WYR* @date 2014-04-15*/public class QueryPaperPoolLimitService {private static final MetaData metaData;public QueryPaperPoolLimitService(){super();}/*** 获得结果集** @param context 报表界面查询传进来的参数(查询条件=值,系统一些默认参数等)* @return*/public static DataSet queryPJCAmt(IContext context)throws Exception {//调用报表查询业务处理接口,IFbmQueryPaperBillService gatherservice=(IFbmQueryPaperBillService) NCLocator.getInstance().lookup(IFbmQueryPaperBillService.class.getName());DataSet resultDataSet = gatherservice.queryPaperBillPoolLimit(context);setPrecision(resultDataSet);return resultDataSet;}//初始化报表要显示的字段,包括查询条件字段也在内static {metaData = new MetaData();List<Field> fields =makeList();//报表显示字段Field f = new Field();f.setFldname(NAME);f.setCaption("财务组织名称");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.ACCTNAME);f.setCaption("机构名称");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.ACCTNO);f.setCaption("账号");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.PJCNO);f.setCaption("票据池编号");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.PJCKAMT);f.setCaption("票据池可开票额度");f.setPrecision(17);f.setDataType(DataTypeConstant.BIGDECIMAL);f.setScale(4);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.CUSKAMT);f.setCaption("客户剩余可开票额度");f.setPrecision(17);f.setDataType(DataTypeConstant.BIGDECIMAL);f.setScale(4);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.CUSEAMT);f.setCaption("客户有效开票额度");f.setPrecision(17);f.setDataType(DataTypeConstant.BIGDECIMAL);f.setScale(4);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.CORNAME);f.setCaption("分支机构名称");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.CORKAMT);f.setCaption("分支机构剩余可开票额度");f.setPrecision(17);f.setDataType(DataTypeConstant.BIGDECIMAL);f.setScale(4);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.REQRESERVED1);f.setCaption("请求备用字段1");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.REQRESERVED2);f.setCaption("请求备用字段2");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.REPRESERVED3);f.setCaption("响应备用字段3");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.REPRESERVED4);f.setCaption("响应备用字段4");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);//查询字段f = new Field();f.setFldname(PaperBillPoolVO.PK_ORG);f.setCaption("财务组织PK");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.QUERY_ACCTNO);f.setCaption("账号-查询");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.QUERY_PJCNO);f.setCaption("票据池编号-查询");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.MFLAG);f.setCaption("是否票据池主申请账号-查询");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING); fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.NEXTTAG);f.setCaption("下页标识-查询");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.REQRESERVED1);f.setCaption("请求备用字段1-查询");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING);fields.add(f);f = new Field();f.setFldname(PaperBillPoolVO.REQRESERVED1);f.setCaption("请求备用字段2-查询");f.setPrecision(200);f.setDataType(DataTypeConstant.STRING);fields.add(f);metaData.addField(fields.toArray(new Field[] {}));}/*** 构造list** @param <T>* @return*/public static <T> List<T> makeList() {return new ArrayList<T>();}//字符串类型字段统一设置字段长度private static void setPrecision(DataSet resultDataSet) { for (Field f : resultDataSet.getMetaData().getFields()) { if (f.getDataType() == DataTypeConstant.STRING) {f.setPrecision(300);}}}/*** 获得票据池额度元数据(相当于代码写一个元数据)** @return*/public static MetaData getPJCAmtrMetaData(){return metaData;}}二、数据加工业务处理//注意:我这个是(银企直联)NC在线查询银行数据的代码,不用完全参照//我这里就举例(票据池额度查询)package nc.impl.fbm.paperbill.query;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import nc.bs.fbm.paperbill.PaperBillService;import mon.NCLocator;import nc.itf.fbm.paperbill.query.IFbmQueryPaperBillService;import nc.itf.fbm.paperbill.query.QueryPaperBillInfoService;import nc.itf.fbm.paperbill.query.QueryPaperPoolLimitService;import nc.itf.obm.paperbill.query.IObmQueryPaperBillService;import nc.pub.smart.data.DataSet;import nc.pub.smart.metadata.Field;import nc.pub.smart.metadata.MetaData;import nc.vo.fbm.paperbill.constant.PaperBillFbmOrderType;import nc.vo.obm.paperbill.constant.PaperBillObmConstant;import nc.vo.obm.paperbill.query.PaperBillInfoVO;import nc.vo.obm.paperbill.query.PaperBillPoolVO;import nc.vo.pub.BusinessException;import nc.vo.pub.query.ConditionVO;import com.ufida.dataset.IContext;import com.ufida.report.anareport.FreeReportContextKey;/**票据信息查询/票据池额度查询接口实现类** @author 温燕荣WYR* @date 2014-04-15*/public class FbmQueryPaperBillServiceImpl extends PaperBillService implements IFbmQueryPaperBillService{private IObmQueryPaperBillService iObmQueryPaperBillService;//这一步可以不需要去理解,当不存在就可以了private static String billfunc= PaperBillObmConstant.PAPERQUERY;/*** 票据池额度查询* @param context* @return* @throws BusinessException*/@Overridepublic DataSet queryPaperBillPoolLimit(IContext context) throws Exception {//获取查询条件值ConditionVO[] conditionvos=(ConditionVO[]) context.getAttribute(FreeReportContextKey.KEY_REPORT_QUERYCONDITIONVOS);DataSet resultDataSet = new DataSet();HashMap<String,String> hashmap=new HashMap<String, String>();//获取查询条件(key,值)对应if(conditionvos!=null&&conditionvos.length>0){//执行了查询for(ConditionVO conditionvo:conditionvos){hashmap.put(conditionvo.getFieldCode(), conditionvo.getValue());}//这一步可以不需要去理解,当不存在就可以了Stringbanktype=getbanktype(hashmap.get(PaperBillPoolVO.QUERY_ACCTNO));//这一步可以不需要去理解,当不存在就可以了//根据当前界面VO获取银行的信息类createBankInfoClass(banktype,billfunc,PaperBillFbmOrderType.QUERYBILLPOOLLIMIT) ;/**这一步是获取查询条件值组装成查询vo(自己新建一个VO【PaperBillPoolVO】,记得加*上必须字段pk_org和orgname,前者是PK查询使用,后者是显示名称,初始化字段类里*面也必须有),我这里是按照不同银行动态调用各个handler*///组装发送指令VOPaperBillPoolVOpoolvo=(PaperBillPoolVO)abstractBankInfo.getQueryBankHandlerClass(abstractBankInfo).chan geQueryPaperBillPoolVO(hashmap);//查询条件值可能要先暂存,待返回数据集再把对应查询条件值设值回去,不然查不出数据//也就是查询条件是什么值,最终结果集对应的查询字段值也必须是什么值//看需求,报表字段有的时候需要建两种,一种是查询,一种是显示结果,进行分开//这一步是报表数据逻辑处理//发送查询指令业务接口PaperBillPoolVO[] paperBillPoolVOs = null;paperBillPoolVOs=getiObmQueryPaperBillService().queryPaperBillPoolLimit(new PaperBillPoolVO[]{poolvo});//获取报表查询条件之后经过一些业务处理后返回的最终结果数据//接收发送指令返回数据,进行数据转换,返回报表界面//把处理好的结果,可以是返回ArrayList或者对象数组PaperBillPoolVO[]resultDataSet =getPjcAmtRstProcessData(paperBillPoolVOs); //结果转换成DataSet }else{//没有执行查询MetaData metaData = QueryPaperPoolLimitService.getPJCAmtrMetaData();resultDataSet.setMetaData(metaData);}return resultDataSet;}//下面就是把转换成报表显示数据DataSet格式,这里是固定的换个VO就能用/*** 票据池额度查询* 银行返回的指令VO数据*转换成报表显示数据DataSet*@author 温燕荣WYR*@date 2014-4-17*@param paperBillPoolVOs*@return* @throws BusinessException*/public DataSet getPjcAmtRstProcessData(PaperBillPoolVO[] paperBillPoolVOs)throws BusinessException{DataSet resultDataSet = new DataSet();MetaData metaData = QueryPaperPoolLimitService.getPJCAmtrMetaData();resultDataSet.setMetaData(metaData);if (paperBillPoolVOs == null || paperBillPoolVOs.length== 0) {return resultDataSet;}Field[] fields = metaData.getFields();List<Object[]> reportList = new ArrayList<Object[]>();for (PaperBillPoolVO vo : paperBillPoolVOs) {if(vo==null){continue;}Object[] rowData = new Object[fields.length];for (int k = 0; k < fields.length; k++) {String fldName = fields[k].getFldname();rowData[k] = vo.getAttributeValue(fldName);}reportList.add(rowData);}resultDataSet.setDatas(reportList.toArray(new Object[0][fields.length]));return resultDataSet;}//从这里到最后面的代码不用去理会了/*** @param iObmQueryPaperBillService 要设置的iObmQueryPaperBillService*/public void setiObmQueryPaperBillService(IObmQueryPaperBillService iObmQueryPaperBillService) {this.iObmQueryPaperBillService = iObmQueryPaperBillService;}/*** @return iObmQueryPaperBillService*/public IObmQueryPaperBillService getiObmQueryPaperBillService() {if(iObmQueryPaperBillService==null){iObmQueryPaperBillService=NCLocator.getInstance().lookup(IObmQueryPaperBillService. class);}return iObmQueryPaperBillService;}//根据银行账户子户PK获取银行代码,如:工商银行00015 icbcpublic String getbanktype (String banktype) throws BusinessException{String nbanktype=banktype;if(nbanktype!=null){if(nbanktype.indexOf(",")!=-1){throw new BusinessException("[账号]不能多选!");}nbanktype=getPaperBillHandler().getNetbankinftpCodeByAccount(nbanktype);return nbanktype;}return null;}}三、语义模型-XX(预置、集团、全局)设置1.新建一个语义模型文件,来到【语义模型设计器】界面,第一步“选择表”。

相关主题