package com.dhcc.finance.util; import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import com.dhcc.finance.constant.FinanceDictConsts; /** * 功能描述:财务公共工具类 * * @author dml * @date 2019年5月23日 上午11:36:52 * @修改日志: */ @Slf4j public class FinancePublicUtil { /** * 功能描述:根据字段名获取字段值 * * @param t 实体类 * @param fieldName 字段名 * @return * @throws Exception Object * @author dml * @date 2019年5月23日 上午11:45:56 * @修改日志: */ public static Object getMethodValueNoexc(T t, String fieldName) { Object methodValue; try { methodValue = getMethodValue(t, fieldName); } catch (Exception e) { log.error(fieldName + "获取字段转换值失败>>>>>>>>>", e); throw new RuntimeException(); } return methodValue; } /** * 功能描述:根据字段名获取字段值 * * @param t 实体类 * @param fieldName 字段名 * @return * @throws Exception Object * @author dml * @date 2019年5月23日 上午11:45:56 * @修改日志: */ public static Object getMethodValue(T t, String fieldName) throws Exception { StringBuilder sb = new StringBuilder(); String camelName = camelName(fieldName); //获取get方法 sb.append(camelName); // 为空是返回null if ("".contentEquals(sb)) { return ""; } if (Character.isLowerCase(sb.charAt(0))) { if (sb.length() == 1 || !Character.isUpperCase(sb.charAt(1))) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); } } sb.insert(0, "get"); Class classz = t.getClass(); Method method = classz.getMethod(sb.toString()); return method.invoke(t); } /** * 功能描述:将下划线大写方式命名的字符串转换为驼峰式 * 例如 DML_TEST -> dmlTest * * @param name * @return String * @author dml * @date 2019年7月29日 下午2:20:29 * @修改日志: */ public static String camelName(String name) { StringBuilder result = new StringBuilder(); // 快速检查 if (name == null || name.isEmpty()) { // 没必要转换 return ""; } else if (!name.contains("_")) { // 不含下划线,首字母小写则原样返回,大些则全部转换为小写 if (Character.isLowerCase(name.charAt(0))) { return name; } return name.toLowerCase(); } // 用下划线将原始字符串分割 String camels[] = name.split("_"); for (String camel : camels) { // 跳过原始字符串中开头、结尾的下换线或双重下划线 if (camel.isEmpty()) { continue; } // 处理真正的驼峰片段 if (result.length() == 0) { // 第一个驼峰片段,全部字母都小写 result.append(camel.toLowerCase()); } else { // 其他的驼峰片段,首字母大写 result.append(camel.substring(0, 1).toUpperCase()); result.append(camel.substring(1).toLowerCase()); } } return result.toString(); } /** * 功能描述:查询是否为特殊情况,是则返回对应值,否返回null * * @param tradeCode 交易码 * @param direction true正向关系 false反向关系 * @return String * @author dml * @date 2019年8月15日 上午10:41:50 * @修改日志: */ public static String getSpecialCases(String tradeCode, boolean direction) { if (tradeCode == null) { return null; } if (direction) { switch (tradeCode) { case "CJ1014":// 季度结息受益人费用收益计提 return "CJ1015"; case "CJ1016":// 季度结息受益人费用收益兑付 return "CJ1017"; case "CJ1019"://销户费用和受益人 return "CJ1020"; default: return null; } } else { switch (tradeCode) { case "CJ1015":// 季度结息受益人费用收益计提 return "CJ1014"; case "CJ1017":// 季度结息受益人费用收益兑付 return "CJ1016"; case "CJ1020"://销户费用和受益人 return "CJ1019"; default: return null; } } } /** * 功能描述:判断费用类型 * @param fylx * @return List * @author likai * @date 2020年6月11日 上午10:38:11 * @修改日志: */ public static List getFylx(String fylx){ List list = new ArrayList(); // 固定报酬 管理费 if (FinanceDictConsts.FYLX.GDBC.equals(fylx) || FinanceDictConsts.FYLX.GLF.equals(fylx) ) { list.add("220601"); } // 浮动报酬 if (FinanceDictConsts.FYLX.FDBC.equals(fylx)) { list.add("220602"); } // 托管费 if (FinanceDictConsts.FYLX.TGF.equals(fylx)) { list.add("2207"); } // 财务顾问费 if (FinanceDictConsts.FYLX.GWF.equals(fylx)) { list.add("224129"); } // 销售服务费 if (FinanceDictConsts.FYLX.XSFWF.equals(fylx)) { list.add("2208"); } // 增值税 if (FinanceDictConsts.FYLX.ZZS.equals(fylx)) { list.add("22210401"); list.add("222102"); list.add("222103"); list.add("222108"); } // 承销费 if (FinanceDictConsts.FYLX.CXF.equals(fylx)) { list.add("2208"); } // 律师费 if (FinanceDictConsts.FYLX.LSF.equals(fylx)) { list.add("224199"); } // 贷款管理费 if (FinanceDictConsts.FYLX.DKGLF.equals(fylx)) { list.add("224150"); } // 会计师费 if (FinanceDictConsts.FYLX.KJSF.equals(fylx)) { list.add("224199"); } // 登记服务费 if (FinanceDictConsts.FYLX.DJFWF.equals(fylx)) { list.add("224199"); } // 建档服务费 if (FinanceDictConsts.FYLX.JDFWF.equals(fylx)) { list.add("224199"); } // 付息兑付费 if (FinanceDictConsts.FYLX.FXDFF.equals(fylx)) { list.add("224199"); } // 资产服务费 if (FinanceDictConsts.FYLX.ZCFWF.equals(fylx)) { list.add("224196"); } // 审计评级费 if (FinanceDictConsts.FYLX.SJPZF.equals(fylx)) { list.add("224199"); } // 公正费 if (FinanceDictConsts.FYLX.GZF.equals(fylx)) { list.add("224199"); } // 资产评估费 if (FinanceDictConsts.FYLX.ZCPGF.equals(fylx)) { list.add("224197"); } // 咨询费 if (FinanceDictConsts.FYLX.ZXF.equals(fylx)) { list.add("224199"); } // 银行结算费 if (FinanceDictConsts.FYLX.YHZJF.equals(fylx)) { list.add("224199"); } // 项目监管费 if (FinanceDictConsts.FYLX.XMGLF.equals(fylx)) { list.add("224187"); } // 银行监管费 if (FinanceDictConsts.FYLX.YHJGF.equals(fylx)) { list.add("224199"); } // 债券交易手续费 if (FinanceDictConsts.FYLX.JYSXF.equals(fylx)) { list.add("224172"); } // 债券回购手续费 if (FinanceDictConsts.FYLX.HGSXF.equals(fylx)) { list.add("224199"); } // 交易费用 if (FinanceDictConsts.FYLX.JYFY.equals(fylx)) { list.add("224199"); } // 其他费用 if (FinanceDictConsts.FYLX.QTFY.equals(fylx)) { list.add("224199"); } // 资产处置费 if (FinanceDictConsts.FYLX.ZCCZF.equals(fylx)) { list.add("224199"); } return list; } }