多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 组件源码 ``` /** * <b>方法描述:</b> BCD解码 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-11 11:51:44 <br/> * * @param bcdstr * 入参|BCD字符串|{@link java.lang.String} * @param charset * 入参|转字符串编码|{@link java.lang.String} * @param outstr * 出参|输出字符串|{@link java.lang.String} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "BCD解码", style = "判断型", type = "同步组件", comment = "BCD字符串转字符串", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-11 11:51:44") @InParams(param = { @Param(name = "bcdstr", comment = "BCD字符串", type = java.lang.String.class), @Param(name = "charset", comment = "转字符串编码", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "outstr", comment = "输出字符串", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_bcdDec(String bcdstr, String charset) { if (charset == null || !Charset.isSupported(charset)) { return ResultBase.newFailureResult("TPTC0006", "bcdDec-编码方式输入错误:"+charset); } if (bcdstr == null || bcdstr == "") { return ResultBase.newSuccessResult(""); } try { int maxLen = bcdstr.length(); byte[] bytes = new byte[maxLen / 2]; bcdstr = bcdstr + " "; int i = 0, j = 0; for (; i < maxLen; i++) { if (bcdstr.charAt(i) == ' ') continue; if (bcdstr.charAt(i + 1) == ' ') { bytes[j] = (byte) Character.digit(bcdstr.charAt(i), 16); } else { bytes[j] = (byte) ((Character.digit(bcdstr.charAt(i), 16) << 4) + Character .digit(bcdstr.charAt(i + 1), 16)); } i++; j++; } byte[] retbytes = new byte[j]; System.arraycopy(bytes, 0, retbytes, 0, j); return ResultBase.newSuccessResult(new String(retbytes, charset)); } catch (Exception ex) { AppLog.error(ex); return ResultBase.newExceptionResult("TPTC0007", "bcdDec-编码方式转换异常:" + AppLog.errorMsg(ex)); } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/f0/82/f082bda35b566af473386209d5598339_1866x866.png) # 参数说明及示例 ## 入口参数 BCD 字符串:输入一个 BCD 字符串参数,示例: `"61 62 63"` 转字符串编码:设置字符串的编码格式,示例: `utf8` ## 出口参数 输出字符串:把 BCD 字符串转换成字符串,示例: `__INNER__["result"]`