企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 组件源码 ``` /** * <b>方法描述:</b> 除 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-11 11:50:09 <br/> * * @param amt1 * 入参|被除数|{@link Object} * @param amt2 * 入参|除数|{@link Object} * @param scale * 入参|小数精度(默认2)|{@link java.lang.Integer} * @param round * 入参|舍入(默认四舍五入)|{@link java.lang.Integer} * @param amt3 * 出参|商|{@link java.lang.String} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "除", style = "判断型", type = "同步组件", comment = "除法计算。除非指定,否则小数默认保留两位,舍入模式使用四舍五入: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:50:09") @InParams(param = {@Param(name = "amt1", comment = "被除数", type = Object.class), @Param(name = "amt2", comment = "除数", type = Object.class), @Param(name = "scale", comment = "小数精度(默认2)", type = java.lang.Integer.class), @Param(name = "round", comment = "舍入(默认四舍五入)", type = java.lang.Integer.class)}) @OutParams(param = {@Param(name = "amt3", comment = "商", type = java.lang.String.class)}) @Returns(returns = {@Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) public static ResultBase P_divide(Object amt1, Object amt2, Integer scale, Integer round) { if (scale == null) scale = 2; if (round == null) round = BigDecimal.ROUND_HALF_UP; BigDecimal d1 = transform(amt1); BigDecimal d2 = transform(amt2); if (d1 != null && d2 != null) { BigDecimal d3 = d1.divide(d2); d3 = d3.setScale(scale, round); return ResultBase.newSuccessResult(d3.toString()); } return ResultBase.newFailureResult("TPTA0012", "输入计算金额数据不是合法数据,输入值1=" + amt1 + ",值2=" + amt2); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/d9/c8/d9c8b2b6d24692d47380e43dfea5526e_1871x868.png) # 参数说明及示例 ## 入口参数 被除数:输入一个数值类型或者字符串类型的数值,示例: `"2,000"` 除数:输入一个数值类型或者字符串类型的数值,示例: `25` 小数精度(默认为2):设置小数精度,示例: `2` 舍入(默认四舍五入):设置舍入模式,详情查看组件注释,示例: `5` ## 出口参数 商:两个金额的商,示例: `__INNER__["result"]`