NC 5系自定义显示公式

时间:2022-05-22 17:26:16

1、继承NcInnerFunction(nc.vo.pub.formulaset.function.NcInnerFunction)

在方法中引用父类方法function,并在里面写方法

@Override
public Object function(List param) throws ParseException {
if(param==null&&param.size()!=1)
throw new ParseException("参数不正确!"); String id = (String) param.get(0); IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class);
String sql = " select h.vbillno,h.invoiceno,h.invoicestatus,h.pk_buleid,h.invoicetype from XXXXt " +
" inner join XXXX h on t.pk_vatinvoice = h.pk_vatinvoice " +
"where nvl(h.dr,0)=0 and t.pk_detail='"+id+"' ";
if(getInvoiceType()==1){
sql+=" t.ispenal ='N' ";
}else if(getInvoiceType()==2){
sql+=" t.ispenal ='Y' ";
}
try {
System.out.println(sql);
List resList = (List) bs.executeQuery(sql, new MapListProcessor());
if(resList.isEmpty())
return null; StringBuffer sb = new StringBuffer();
for (int i=0;i<resList.size();i++) {
Map<String, Object> linMap = (Map<String, Object>)resList.get(i);
String no = (String)linMap.get("invoiceno");
String billno = (String)linMap.get("vbillno"); sb.append(no==null?billno:no);
Integer st = (Integer)linMap.get("invoicestatus");
Integer type = (Integer)linMap.get("invoicetype");
String ty = "";
if(InvoiceType.VATCOM.getType() == type)
ty = "XX";
if(InvoiceType.VATPRO.getType() == type)
ty = "XX";
if(InvoiceType.VATELCOM.getType() == type)
ty = "XX";
// End if(st==InvoiceStatus.OUTED.getStatus()){
if(linMap.get("pk_buleid")!=null){
sb.append("(").append(ty+",").append("XX").append(")");
}else{
sb.append("(").append(InvoiceStatus.OUTED.getName()).append(")");
}
} // else if(st==InvoiceStatus.OUTING.getStatus()){
// sb.append("(").append(InvoiceStatus.OUTING.getName()).append(")");
// }
else if(st==InvoiceStatus.CANCEL.getStatus()){
sb.append("(").append(ty+",").append(InvoiceStatus.CANCEL.getName()).append(")");
}else if(st==InvoiceStatus.RCW.getStatus()){
sb.append("(").append(ty+",").append(InvoiceStatus.RCW.getName()).append(")");
}else{
sb.append("(").append(ty+",").append(InvoiceStatus.UNOUT.getName()).append(")");
}
if(i<resList.size()-1)
sb.append(",");
}
if(sb.length()>0)
return sb.toString();
} catch (BusinessException e) {
e.printStackTrace();
} return null;
}

返回描述为:

@Override
public String getFunctionDesc() {
return "invoiceall(String):传入XX主键,返回全部XX信息";
}

引入到配置文件中:

<?xml version="1.0" encoding="gb2312"?>
<formula-array>
<formula>
<customType>9</customType>
<functionName>invoiceall</functionName>
<functionClass>xx.xx.xx.InvoiceAll</functionClass>
</formula>
</formula-array>

配置文件放在nchome 下 resources/formulaconfig/custfunction/xx.xml


效果为:NC 5系自定义显示公式