ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> 金额舍入 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-11 11:49:39 <br/> * * @param amt * 入参|金额|{@link Object} * @param scale * 入参|小数|{@link int} * @param model * 入参|舍入模式|{@link int} * @param amt * 出参|j金额|{@link java.lang.String} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "金额舍入", style = "判断型", type = "同步组件", comment = "将输入金额按照指定舍入模式进行取舍计算。舍入模式使用BigDecimal 的舍入模式:0->ROUND_UP(直接入);1->ROUND_DOWN(直接舍);2->ROUND_CEILING(正入负舍);3->ROUND_FLOOR(正舍负入);4->ROUND_HALF_UP(四舍五入);5->ROUND_HALF_DOWN(五舍六入);6->ROUND_HALF_EVEN(银行家舍入)", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-11 11:49:39") @InParams(param = {@Param(name = "amt", comment = "金额", type = Object.class), @Param(name = "scale", comment = "保留小数", type = int.class), @Param(name = "model", comment = "舍入模式", type = int.class)}) @OutParams(param = {@Param(name = "amt", comment = "金额", type = java.lang.String.class)}) @Returns(returns = {@Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) public static ResultBase P_setScale(Object amt, int scale, int model) { BigDecimal d = transform(amt); if (d != null) return ResultBase.newSuccessResult(d.setScale(scale, model).toString()); return ResultBase.newFailureResult("TPTA0007", "输入不是合法金额数据,输入数据:" + amt); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/d0/62/d0623b737ea7d325812cac21d8993413_1866x897.png) # 参数说明及示例 ## 入口参数 金额:输入一个数值型或者字符串型的数值,示例: `"1,123.1756"` 保留小数:设置保留几位小数,示例: `2` 舍入模式:设置小数舍入模式,详情查看组件的组件注释,示例: `5` ## 出口参数 金额:根据舍入和小数位数得出的结果,示例: `__INNER__["result"]`