S-HR常用源码
1.public static String getUserId(Context ctx) {
UserInfo userInfo = ContextUtil.getCurrentUserInfo(ctx);
String userId = (userInfo != null) ? userInfo.getId().toString()
: (String) ctx.get("userID");
return userId;
}
重点关注ContextUtil
2.重点关注HRManagerUtil
public static String getLocal(Context ctx) {String local = (ctx.getLocale() != null) ? ctx.getLocale().toString(): "l2";return local;}
-----
参考HREmpFacadeControllerBean中的getEmpTopicStructure
public static String rate(double d1, double d2) {
if (d2 != 0.0D) {
BigDecimal b1 = new BigDecimal(d1);
BigDecimal b2 = new BigDecimal(d2);
double result = b1.divide(b2, 4, 4).doubleValue();
return round(mul(result, 100.0D), 2) + "%";
}
return "0%";
}
public static void getPercent(List<Map> list, int headcount) {
getPercent(list, headcount, "count");
}
public static void getPercent(List<Map> list, int headcount,
String calculateName) {
int i = 0;
for (int size = list.size(); i < size; ++i) {
Map map = (Map) list.get(i);
int count = ((Integer) map.get(calculateName)).intValue();
String percent = rate(count, headcount);
map.put("percent", percent);
}
}
阅读即可
------
3.临时表名
public static String getTempTableName(Context ctx) throws Exception {
TempTablePool pool = TempTablePool.getInstance(ctx);
String tempTableName = pool.createTempTableName();
return tempTableName;
}
Context ctx=ContextUtils.getConextfromSession()
动态列表设置:select * from t_bd_dynamiclistsetting
视图配置的表 select * from s_bs_uiview