起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 5611|回复: 4

[结贴] 如何在KSQL自定义字段中使用toChineseMoney()函数?

[复制链接]

17

主题

56

帖子

300

积分

中级会员

Rank: 3Rank: 3

积分
300
发表于 2017-5-19 17:47:42 | 显示全部楼层 |阅读模式
版本: 小版本号:
数据库: 服务器操作系统: 应用服务器:
客户端操作系统: 浏览器:
select orderMain.*,Supplier,Supplier.fSupplierCode as fSupplierCode,Supplier.fSupplierName as fSupplierName,Supplier.fFindCode as fFindCode,Supplier.fFullName as fFullName,Supplier.fAreaCode as fAreaCode,Supplier.fContactor as fContactor,Supplier.fPhone as fPhone,Supplier.fFax as fFax,Supplier.fAddress as fAddress,Supplier.fPostCode as fPostCode,Supplier.fBank as fBank,Supplier.fBankId as fBankId,Supplier.fTaxId as fTaxId,Supplier.fEmail as fEmail,Supplier.fUrl as fUrl,Supplier.fMobilePhone as fMobilePhone,Supplier.fMemo as fMemo,Supplier.fFirstPay as fFirstPay,Supplier.fPrePay as fPrePay,Supplier.fPayable as fPayable,Supplier.fIsSent as fIsSent,Supplier.fSupplyGoods as fSupplyGoods,Supplier.fLicenseNo as fLicenseNo,Supplier.fRemark as fRemark,Customer.fCustomerCode as fCustomerCode,Customer.fCustomerName as fCustomerName,Customer.fFullName as fFullName1,(:toChineseMoney( orderMain.fTotalAmount )) as fChineseMoney
    from orderMain orderMain
     optional  join Supplier Supplier on orderMain.fSupplierId = Supplier
     optional  join Customer Customer on orderMain.fSupplierId = Customer
    where orderMain =

在报表的KSQL中自定义字段(:toChineseMoney( orderMain.fTotalAmount )) as fChineseMoney 出错,不能获取数据 。谁有报表用这个函数的案例吗?toChineseMoney

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35942
发表于 2017-5-22 08:58:54 | 显示全部楼层
内存函数不能在select部分用,执行的时候先执行内存函数,然后执行sql,执行内存函数的时是取不到关系的值的,可以用SQL.调用数据库函数实现
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

17

主题

56

帖子

300

积分

中级会员

Rank: 3Rank: 3

积分
300
 楼主| 发表于 2017-5-22 17:51:18 | 显示全部楼层

import org.dom4j.*;

import com.justep.message.CommonMessages;
import com.justep.model.ModelUtils;
import com.justep.system.data.*;
import com.justep.system.util.BizUtils;
import com.justep.util.Utils;
import com.justep.system.util.CommonUtils;

public class TccOptics {


        public static void ksqlOrderMain(String ksql,Map variables,String dataModel,String fnModel){
                Utils.check(Utils.isNotEmptyString(ksql) && Utils.isNotEmptyString(dataModel),
                                CommonMessages.class, CommonMessages.PARAM_NULL1, "ksql, dataModel");
                Table table = KSQL.select(ksql, variables, dataModel, Utils.isEmptyString(fnModel) ? null : ModelUtils.getModel(fnModel));
                //拿到所有记录数组
                Iterator<Row> rows=table.iterator();
                while (rows.hasNext()){
                        Row row=rows.next();
                        //给fToChineseMoney字段赋值
                        row.setString("fToChineseMoney", String CommonUtils.toChineseMoney(row.getValue("fTotalAmount")));
          
                }
                return table;
        }
}

以上 action 代码执行出错

warning: [options] bootstrap class path not set in conjunction with -source 1.5
warning: [options] source value 1.5 is obsolete and will be removed in a future release
warning: [options] target value 1.5 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
E:\BeX5_V3.6\model\BIZ\a2016\TccOptics\logic\code\dsrc\TccOptics.java:26: error: ')' expected
                        row.setString("fToChineseMoney", String CommonUtils.toChineseMoney(row.getValue("fTotalAmount")));
                                                               ^
E:\BeX5_V3.6\model\BIZ\a2016\TccOptics\logic\code\dsrc\TccOptics.java:26: error: illegal start of expression
                        row.setString("fToChineseMoney", String CommonUtils.toChineseMoney(row.getValue("fTotalAmount")));
                                                                           ^
E:\BeX5_V3.6\model\BIZ\a2016\TccOptics\logic\code\dsrc\TccOptics.java:26: error: ';' expected
                        row.setString("fToChineseMoney", String CommonUtils.toChineseMoney(row.getValue("fTotalAmount")));
                                                                                          ^
E:\BeX5_V3.6\model\BIZ\a2016\TccOptics\logic\code\dsrc\TccOptics.java:26: error: ';' expected
                        row.setString("fToChineseMoney", String CommonUtils.toChineseMoney(row.getValue("fTotalAmount")));
                                                                                                                       ^
4 errors
4 warnings

        at com.justep.report.controller.DataController.a(Unknown Source)
        at com.justep.report.controller.DataController.a(Unknown Source)
        ... 20 more
Caused by: java.lang.Exception
        ... 22 more
回复 支持 反对

使用道具 举报

91

主题

13万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
35942
发表于 2017-5-23 08:53:19 | 显示全部楼层
String CommonUtils.toChineseMoney(row.getValue("fTotalAmount")这个改为定义变量的方式看看
远程的联系方法QQ1392416607,添加好友时,需在备注里注明其论坛名字及ID,公司等信息
发远程时同时也发一下帖子地址,方便了解要解决的问题  WeX5教程  WeX5下载



如按照该方法解决,请及时跟帖,便于版主结贴
回复 支持 反对

使用道具 举报

17

主题

56

帖子

300

积分

中级会员

Rank: 3Rank: 3

积分
300
 楼主| 发表于 2017-5-23 14:23:49 | 显示全部楼层
改成以下代码,已经OK啦,谢谢jishuang老师。可以结贴。

public static Table ksqlOrderMain(String ksql,Map<String, Object> variables,String dataModel,String fnModel){
                               
                        Utils.check(Utils.isNotEmptyString(ksql) && Utils.isNotEmptyString(dataModel),
                                        CommonMessages.class, CommonMessages.PARAM_NULL1, "ksql, dataModel");
                        Table table= KSQL.select(ksql, variables, dataModel, Utils.isEmptyString(fnModel) ? null : ModelUtils.getModel(fnModel));
                        Iterator<Row> rows = table.iterator();
                         while (rows.hasNext()) {
                                Row row = rows.next();
                                //给fToChineseMoney字段赋值
                                Number number= (Number) row.getValue("fTotalAmount");
                               
                row.setString("fToChineseMoney", "总计金额(大写,人民币):"+CommonUtils.toChineseMoney(number));
                         }
                       
                        return table ;
        }
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-5-18 21:02 , Processed in 0.138228 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表