diff --git a/src/com/engine/kq/biz/KQChildrenComInfo.java b/src/com/engine/kq/biz/KQChildrenComInfo.java new file mode 100644 index 0000000..b83815d --- /dev/null +++ b/src/com/engine/kq/biz/KQChildrenComInfo.java @@ -0,0 +1,81 @@ +package com.engine.kq.biz; + +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; + +/** + * 假期规则缓存类 + */ +public class KQChildrenComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "hrmfamilyinfo"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " WhetherChildren=1 "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = " id "; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 出生日期 + */ + @CacheColumn(name = "birthday") + protected static int birthday; + /** + * 姓名 + */ + @CacheColumn(name = "member") + protected static int member; + /** + * 家长id + */ + @CacheColumn(name = "resourceid") + protected static int resourceid; + + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getChildrenName() { + return (String)getRowValue(member); + } + + public String getChildrenName(String key){ + return (String) getValue(member,key); + } + + public String getBirthday() { + return (String)getRowValue(birthday); + } + + public String getBirthday(String key){ + return (String) getValue(birthday,key); + } + + public String getResourceid() { + return (String)getRowValue(resourceid); + } + + public String getResourceid(String key){ + return (String) getValue(resourceid,key); + } + + @Override + public void removeCache() { + super.removeCache(); + } +} diff --git a/src/com/engine/kq/biz/KQLeaveRulesBiz.java b/src/com/engine/kq/biz/KQLeaveRulesBiz.java new file mode 100644 index 0000000..b0c4b4c --- /dev/null +++ b/src/com/engine/kq/biz/KQLeaveRulesBiz.java @@ -0,0 +1,1307 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSONObject; +import com.api.hrm.util.ServiceUtil; +import com.engine.kq.entity.KQBalanceOfLeaveEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQTransMethod; +import com.weaver.general.TimeUtil; +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.StringUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.common.Tools; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class KQLeaveRulesBiz { + + public static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>(); + + + /** + * 记录日志 + */ + private static KQLog logger = new KQLog(); + + /** + * 根据假期规则ID获取假期规则名称 + * + * @param ruleId 假期规则的ID + * @return + */ + public static String getLeaveName(String ruleId) { + String leaveName = ""; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + leaveName = kqLeaveRulesComInfo.getLeaveName(ruleId); + return leaveName; + } + + /** + * 判断是否具有假期余额 + * + * @param ruleId + * @return + */ + public static boolean getBalanceEnable(String ruleId) { + int balanceEnable = 0; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + balanceEnable = Util.getIntValue(kqLeaveRulesComInfo.getBalanceEnable(ruleId), 0); + if (balanceEnable == 1) { + return true; + } else { + return false; + } + } + /** + * 判断优先假期类型id字符串 + * + * @param ruleId + * @return + */ + public static String getLeaveids(String ruleId) { + int schevacationON = 0; + String schevacation = "-1"; + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + schevacationON = Util.getIntValue(kqLeaveRulesComInfo.getSchevacationON(ruleId), 0); + if (schevacationON == 1) { + schevacation=Util.null2s(kqLeaveRulesComInfo.getSchevacation(ruleId), "-1"); + } + return schevacation; + + } + + /** + * 判断人员的假期类型id字符串 + * + * @param scheLeaveids + * @param resourceId + * @return + */ + public static String getusedLeaveids(String scheLeaveids, String resourceId) { + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcompanyId = resourceComInfo.getSubCompanyID(resourceId); + String departmentId = resourceComInfo.getDepartmentID(resourceId); + + List scheLeaveidsList = Util.splitString2List(scheLeaveids, ","); + + /** + * 加载应用范围为总部的以及应用范围为分部(但是范围中包含了所属分部ID)的假期规则 + */ + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_LeaveRules "; + String sqlWhere = " where (isDelete is null or isDelete <>1) and isEnable=1 and balanceEnable=1 "; + /*如果找不到人员所在分部,则只返回应用范围为总部的假期规则*/ + if (!resourceId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere += " and ( (scopeType=3 and ','+scopeValue+',' like '%," + resourceId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " and ( (scopeType=3 and concat(',',scopeValue,',') like '%," + resourceId + ",%') "; + } else { + sqlWhere += " and ( (scopeType=3 and ','||scopeValue||',' like '%," + resourceId + ",%') "; + } + } + if (!departmentId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere += " or (scopeType=2 and ','+scopeValue+',' like '%," + departmentId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " or (scopeType=2 and concat(',',scopeValue,',') like '%," + departmentId + ",%') "; + } else { + sqlWhere += " or (scopeType=2 and ','||scopeValue||',' like '%," + departmentId + ",%') "; + } + } + if (!subcompanyId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere += " or (scopeType=1 and ','+scopeValue+',' like '%," + subcompanyId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere += " or (scopeType=1 and concat(',',scopeValue,',') like '%," + subcompanyId + ",%') "; + } else { + sqlWhere += " or (scopeType=1 and ','||scopeValue||',' like '%," + subcompanyId + ",%') "; + } + } + + sqlWhere += " or scopeType=0 )"; + sql = sql + sqlWhere + " order by showOrder,id "; + scheLeaveids = ""; + List remleaveidsList = new ArrayList<>(); + recordSet.executeQuery(sql); + /*如果指定人员所在分部下面单独设置过假期规则,则取分部下面的假期规则*/ + while (recordSet.next()) { + String leaveid = recordSet.getString("id");//假期类型id + remleaveidsList.add(leaveid); + } + + for (String id : scheLeaveidsList) { + if (remleaveidsList.contains(id)) { + if (scheLeaveids.equals("")) { + scheLeaveids = id; + } else { + scheLeaveids += "," + id; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return scheLeaveids; + + } + /** + * 获取最小请假单位 + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * 其他:无效数据 + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static int getMinimumUnit(String ruleId) { + int minimumUnit = -1;//最小请假单位 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + minimumUnit = Util.getIntValue(kqLeaveRulesComInfo.getMinimumUnit(ruleId), -1); + return minimumUnit; + } + + /** + * 获取请假时长计算方式 + * 1-按照工作日计算请假时长 + * 2-按照自然日计算请假时长 + * 其他:无效数据 + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static int getComputingMode(String ruleId) { + int computingMode = -1;//计算请假时长方式 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + computingMode = Util.getIntValue(kqLeaveRulesComInfo.getComputingMode(ruleId), -1); + return computingMode; + } + + /** + * 按照自然日计算请假时长排除节假日、休息日 + * 0-不排除 + * 1-排除节假日 + * 2-排除休息日 + * 1,2-排除节假日和休息日 + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static String getFilterHolidays(String ruleId) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String filterHolidays = Util.null2s(kqLeaveRulesComInfo.getFilterHolidays(ruleId), "0"); + return filterHolidays; + } + + /** + * 获取日折算时长(多少小时算一天) + * + * @param ruleId 指定的假期规则ID + * @return + */ + public static String getHoursToDay(String ruleId) { + double hoursToDay = -1;//日折算时长 + int computingMode = -1;//计算请假时长方式 + int minimumUnit = -1;//最小请假单位 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + hoursToDay = Util.getDoubleValue(kqLeaveRulesComInfo.getHoursToDay(ruleId), -1); + computingMode = Util.getIntValue(kqLeaveRulesComInfo.getComputingMode(ruleId), -1); + minimumUnit = Util.getIntValue(kqLeaveRulesComInfo.getMinimumUnit(ruleId), -1); + if (computingMode != 2) { + hoursToDay = -1; + } + return String.format("%.2f", hoursToDay); + } + + /** + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * + * @param minimumUnit + * @param lan + * @return + */ + public static String getMinimumUnitName(String minimumUnit, int lan) { + String minimumUnitName = ""; + switch (minimumUnit) { + case "1": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + case "2": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + case "3": + case "5": + case "6": + minimumUnitName = SystemEnv.getHtmlLabelName(391, lan); + break; + case "4": + minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan); + break; + default: + break; + } + return minimumUnitName; + } + + /** + * 获取所有的假期规则 + * unitType:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假、-1:数据异常,无效数据 + * + * @return + */ + public static List> getAllLeaveRules() { + Map ruleMap = new HashMap(); + List> ruleList = new ArrayList>(); + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + kqLeaveRulesComInfo.setTofirstRow(); + while (kqLeaveRulesComInfo.next()) { + if (kqLeaveRulesComInfo.getIsEnable().equals("1")) { + ruleMap = new HashMap(); + ruleMap.put("id", kqLeaveRulesComInfo.getId()); + ruleMap.put("name", kqLeaveRulesComInfo.getLeaveName()); + ruleMap.put("unitType", kqLeaveRulesComInfo.getMinimumUnit()); + ruleMap.put("proportion", kqLeaveRulesComInfo.getProportion()); + ruleMap.put("scopeType",kqLeaveRulesComInfo.getScopeType()); + ruleMap.put("scopeValue",kqLeaveRulesComInfo.getScopeValue()); + ruleList.add(ruleMap); + } + } + return ruleList; + } + + /** + * 根据人员ID获取其可见的所有假期类型 + * + * @param resourceId 指定人员ID + * @return + */ + public static String getAllLeaveRulesByUserId(String resourceId, String languageId) { + String resultStr = ""; + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcomId = resourceComInfo.getSubCompanyID(resourceId); + String deptId = resourceComInfo.getDepartmentID(resourceId); + + List tempList = new ArrayList(); + + Map itemMap = new HashMap(); + List itemList = new ArrayList(); + + String sql = "select * from kq_leaveRules where 1=1 and (isDelete is null or isDelete <>1) and isEnable=1"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String scopeType = recordSet.getString("scopeType"); + String scopeValue = recordSet.getString("scopeValue"); + String leaveName = recordSet.getString("leaveName"); + String id = recordSet.getString("id"); + + if (scopeType.equals("1")) { + tempList = Util.TokenizerString(scopeValue, ","); + if (!tempList.contains(subcomId)) { + continue; + } + } + + itemMap = new HashMap(); + itemMap.put("name", Util.formatMultiLang(leaveName, languageId)); + itemMap.put("id", id); + itemList.add(itemMap); + } + resultStr = JSONObject.toJSONString(itemList); + } catch (Exception e) { + e.printStackTrace(); + } + return resultStr; + } + public static boolean filterSubLeaveRule(KQLeaveRulesComInfo kqLeaveRulesComInfo, User user, String leaveId) { + return filterSubLeaveRule(Util.null2String(user.getUID()), kqLeaveRulesComInfo.getScopeType(leaveId), kqLeaveRulesComInfo.getScopeValue(leaveId), Util.null2String(user.getUserSubCompany1()),Util.null2String(user.getUserDepartment())); + } + public static boolean filterSubLeaveRule(String userId, String scopeType, String scopeValue, String subCompany, String deptId) { + boolean isAdmin = ServiceUtil.isAdmin(userId); + if (isAdmin) { + return false; + } + if ("1".equals(scopeType)) { + if (scopeValue.indexOf(",") > 0) { + String[] split = scopeValue.split(","); + for (String v : split) { + if (!StringUtil.isEmpty(v) && v.equals(subCompany)) { + return false; + } + } + return true; + } else { + return !scopeValue.equals(subCompany); + } + }else if("2".equals(scopeType)){ + if (scopeValue.indexOf(",") > 0) { + String[] split = scopeValue.split(","); + for (String v : split) { + if (!StringUtil.isEmpty(v) && v.equals(deptId)) { + return false; + } + } + return true; + } else { + return !scopeValue.equals(deptId); + } + }else if("3".equals(scopeType)){ + if (scopeValue.indexOf(",") > 0) { + String[] split = scopeValue.split(","); + for (String v : split) { + if (!StringUtil.isEmpty(v) && v.equals(userId)) { + return false; + } + } + return true; + } else { + return !scopeValue.equals(userId); + } + } + return false; + } + /** + * 初始化年假 + * + * @param ruleId + * @return + */ + public static boolean initAnnualLeave(int ruleId) { + boolean isInitSuccess = false; + try { + /*判断年假是否初始化过*/ + RecordSet recordSet = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='年假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=1," + + "isDelete=0,isEnable=1,leaveCode='annualLeave' where id=" + ruleId; + isInitSuccess = recordSet.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + + String deleteDetailSql = "delete from kq_LeaveRulesDetail where scopeType=0 and ruleId=" + ruleId; + recordSet.executeUpdate(deleteDetailSql); + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('年假-总部规则'," + ruleId + ",0,'',3,0,1,0,'','',0,0,0,0)"; + isInitSuccess = recordSet.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'年假-初始化',0,'',1,8,1,1,0,1,'annualLeave')"; + isInitSuccess = recordSet.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('年假-总部规则'," + nextId + ",0,'',3,0,1,0,'','',0,0,0,0)"; + isInitSuccess = recordSet.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set annualLeave=" + nextId + " where id=1"; + isInitSuccess = recordSet.executeUpdate(historySql); + + ruleId = nextId; + } + + String detailId = ""; + sql = "select * from kq_LeaveRulesDetail where scopeType=0 and ruleId=" + ruleId; + recordSet.executeQuery(sql); + if (recordSet.next()) { + detailId = recordSet.getString("id"); + } + if (detailId.equals("")) { + return false; + } + + /*先删除原来的明细记录,在插入新的明细记录*/ + String detailSql = "delete from kq_WorkingAgeToLeave where leaveRulesId=" + detailId; + isInitSuccess = recordSet.executeUpdate(detailSql); + if (!isInitSuccess) { + sql = "delete from kq_LeaveRules where leaveRulesId=" + detailId; + recordSet.executeUpdate(sql); + return false; + } + + /*插入明细记录*/ + detailSql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 0, 1, 0); + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 1, 10, 5); + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 10, 20, 10); + isInitSuccess = recordSet.executeUpdate(detailSql, detailId, 20, 9999, 15); + } catch (Exception e) { + logger.info(e.getMessage()); + } + return isInitSuccess; + } + + /** + * 初始化带薪事假 + * + * @param ruleId + * @return + */ + public static boolean initPaidCompassionateLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='带薪事假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='paidCompassionateLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'带薪事假-初始化',0,'',1,8,1,0,0,1,'paidCompassionateLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set paidCompassionateLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化带薪病假 + * + * @param ruleId + * @return + */ + public static boolean initPaidSickLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='带薪病假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='paidSickLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'带薪病假-初始化',0,'',1,8,1,0,0,1,'paidSickLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set paidSickLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化调休 + * + * @param ruleId + * @return + */ + public static boolean initVacationLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='调休-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=1," + + "isDelete=0,isEnable=1,leaveCode='vacationLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + + String deleteDetailSql = "delete from kq_LeaveRulesDetail where scopeType=0 and ruleId=" + ruleId; + rs.executeUpdate(deleteDetailSql); + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('调休-总部规则'," + ruleId + ",0,'',5,0,1,0,'','',0,0,0,0)"; + isInitSuccess = rs.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + } else { + /*判断系统中是否已经存在调休了,如果已存在,则不允许新建新的调休假期*/ + sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)"; + rs.executeQuery(sql); + if (rs.getCounts() > 0) { + return false; + } + + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'调休-初始化',0,'',1,8,1,1,0,1,'vacationLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String insertDetailSql = "insert into kq_LeaveRulesDetail(ruleName,ruleId,scopeType,scopeValue,distributionMode,annualAmount,priority,validityRule,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod)" + + "values('调休-总部规则'," + nextId + ",0,'',5,0,1,0,'','',0,0,0,0)"; + isInitSuccess = rs.executeUpdate(insertDetailSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set vacationLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化事假 + * + * @param ruleId + * @return + */ + public static boolean initCompassionateLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='事假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='compassionateLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'事假-初始化',0,'',1,8,1,0,0,1,'compassionateLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set compassionateLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化病假 + * + * @param ruleId + * @return + */ + public static boolean initSickLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='病假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='sickLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'病假-初始化',0,'',1,8,1,0,0,1,'sickLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set sickLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化产假 + * + * @param ruleId + * @return + */ + public static boolean initMaternityLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='产假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=2,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='maternityLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'产假-初始化',0,'',1,8,2,0,0,1,'maternityLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set maternityLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化陪产假 + * + * @param ruleId + * @return + */ + public static boolean initPaternityLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (recordSet.next()) { + String updateSql = "update kq_LeaveRules set leaveName='陪产假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=2,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='paternityLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'陪产假-初始化',0,'',1,8,2,0,0,1,'paternityLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set paternityLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化婚假 + * + * @param ruleId + * @return + */ + public static boolean initMarriageLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='婚假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=2,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='marriageLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'婚假-初始化',0,'',1,8,2,0,0,1,'marriageLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set marriageLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化丧假 + * + * @param ruleId + * @return + */ + public static boolean initFuneralLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='丧假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='funeralLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'丧假-初始化',0,'',1,8,1,0,0,1,'funeralLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set funeralLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 初始化哺乳假 + * + * @param ruleId + * @return + */ + public static boolean initBreastfeedingLeave(int ruleId) { + /*判断是否初始化过*/ + RecordSet recordSet = new RecordSet(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id=" + ruleId; + recordSet.executeQuery(sql); + boolean initialized = recordSet.getCounts() > 0; + + /*没有初始化过就新建,已经初始化过就更新*/ + boolean isInitSuccess = false; + if (initialized) { + String updateSql = "update kq_LeaveRules set leaveName='哺乳假-初始化',scopeType=0,scopeValue='',minimumUnit=1,hoursToDay=8,computingMode=1,balanceEnable=0," + + "isDelete=0,isEnable=1,leaveCode='breastfeedingLeave' where id=" + ruleId; + isInitSuccess = rs.executeUpdate(updateSql); + if (!isInitSuccess) { + return false; + } + } else { + KQTransMethod kqTransMethod = new KQTransMethod(); + int nextId = kqTransMethod.getNextId(); + + String insertSql = "insert into kq_LeaveRules(id,leaveName,scopeType,scopeValue,minimumUnit,hoursToDay,computingMode,balanceEnable,isDelete,isEnable,leaveCode)" + + "values(" + nextId + ",'哺乳假-初始化',0,'',1,8,1,0,0,1,'breastfeedingLeave')"; + isInitSuccess = rs.executeUpdate(insertSql); + if (!isInitSuccess) { + return false; + } + + String historySql = "update kq_initHistory set breastfeedingLeave=" + nextId + " where id=1"; + isInitSuccess = rs.executeUpdate(historySql); + } + return isInitSuccess; + } + + /** + * 根据人员ID以及名称获取对应的假期规则ID(主要对于对接小E) + * + * @param resourceId 人员ID + * @param leaveName 假期规则名称 + * @return + */ + public static List getLeaveRuleIdByName(String resourceId, String leaveName) { + List dataList = new ArrayList(); + try { + ResourceComInfo resourceComInfo = new ResourceComInfo(); + String subcomId = resourceComInfo.getSubCompanyID(resourceId); + + Map dataMap = new HashMap(); + + String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete <>1) and isEnable=1 and leaveName like '%" + leaveName + "%'"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + while (recordSet.next()) { + int scopeType = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValue = Util.null2String(recordSet.getString("scopeValue")); + + if (scopeType == 1) { + List tempList = Util.TokenizerString(scopeValue, ","); + if (!tempList.contains(subcomId)) { + continue; + } + } + + dataMap = new HashMap(); + dataMap.put("ruleId", recordSet.getString("id")); + dataMap.put("name", Util.formatMultiLang(recordSet.getString("leaveName"), "7")); + dataList.add(dataMap); + } + } catch (Exception e) { + e.printStackTrace(); + } + return dataList; + } + + /** + * 判断此请假类型是否是由 法定年假+福利年假 组合而成的混合模式 + * + * @param ruleId 指定的请假类型的id(对应于kq_LeaveRules表的主键ID) + * @return true--是混合模式、false--不是 + */ + public static boolean isMixMode(String ruleId) { + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=6 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + flag = true; + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + + /** + * 获取请假类型的颜色(随机生成) + * + * @return + */ + public static String getColor() { + String color = ""; + try { + StringBuffer result = new StringBuffer(); + for (int i = 0; i < 6; i++) { + //随机生成0-15的数值并转换成16进制 + result.append(Integer.toHexString(new Random().nextInt(16))); + } + color = "#" + result.toString().toUpperCase(); + } catch (Exception e) { + System.out.println("获取16进制字符串异常,返回默认..."); + color = "#00CCCC"; + } + return color; + } + + public static String getChildName(String balanceofleaveid){ + String name = ""; + try { + String sql = "select childId from kq_balanceOfLeave where id=?"; + RecordSet recordSet = new RecordSet(); + KQChildrenComInfo kqChildrenComInfo = new KQChildrenComInfo(); + recordSet.executeQuery(sql, balanceofleaveid); + if (recordSet.next()) { + String chlid = Util.null2s(recordSet.getString("childId"), ""); + if(StringUtils.isNotBlank(chlid)){ + name= kqChildrenComInfo.getChildrenName(chlid); + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return name; + } + /** + * 是否是调休 + * @param ruleId + * @return + */ + public static boolean isTiaoXiu(String ruleId){ + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + flag = true; + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + + public static boolean isTiaoXiu(String ruleId, String subCompanyId, String departmentId, String resourceId) { + boolean flag = false; + RecordSet recordSet = new RecordSet(); + try { + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + recordSet.writeLog("isTiaoXiu>>1=" +ruleId+";2="+ subCompanyId+";3="+ departmentId+";4="+ resourceId ); + int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(ruleId, subCompanyId, departmentId, resourceId), 1); + if (distributionMode == 5) { + flag = true; + } + recordSet.writeLog("isTiaoXiu>>distributionMode=" +distributionMode); +// if (!flag) { + if (true) { + + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) " + + "and distributionMode=5 and ruleId=? "; + String sqlWhere = ""; + if (!resourceId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=3 and ','+scopeValue+',' like '%," + resourceId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=3 and concat(',',scopeValue,',') like '%," + resourceId + ",%') "; + } else { + sqlWhere = " and (scopeType=3 and ','||scopeValue||',' like '%," + resourceId + ",%') "; + } + recordSet.writeLog("isTiaoXiu>>sql1=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } else if (!departmentId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=2 and ','+scopeValue+',' like '%," + departmentId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=2 and concat(',',scopeValue,',') like '%," + departmentId + ",%') "; + } else { + sqlWhere = " and (scopeType=2 and ','||scopeValue||',' like '%," + departmentId + ",%') "; + } + recordSet.writeLog("isTiaoXiu>>sql2=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } else if (!subCompanyId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=1 and ','+scopeValue+',' like '%," + subCompanyId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=1 and concat(',',scopeValue,',') like '%," + subCompanyId + ",%') "; + } else { + sqlWhere = " and (scopeType=1 and ','||scopeValue||',' like '%," + subCompanyId + ",%') "; + } + recordSet.writeLog("isTiaoXiu>>sql3=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } else { + sqlWhere = " and scopeType=0 "; + recordSet.writeLog("isTiaoXiu>>sql4=" + sql + sqlWhere); + recordSet.executeQuery(sql + sqlWhere, ruleId); + if (recordSet.next()) { + return true; + } + } + } + + recordSet.writeLog("isTiaoXiu>>flag=" + flag); + } catch (Exception e) { + recordSet.writeLog(e.getMessage()); + recordSet.writeLog(e); + } + return flag; + } + + public static int getTiaoXiu(String subCompanyId, String departmentId, String resourceId) { + int ruleid = 0; + RecordSet recordSet = new RecordSet(); + try { + + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) " + + "and distributionMode=5 "; + String sqlWhere = ""; + if (!resourceId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=3 and ','+scopeValue+',' like '%," + resourceId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=3 and concat(',',scopeValue,',') like '%," + resourceId + ",%') "; + } else { + sqlWhere = " and (scopeType=3 and ','||scopeValue||',' like '%," + resourceId + ",%') "; + } + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + } + if (!departmentId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=2 and ','+scopeValue+',' like '%," + departmentId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=2 and concat(',',scopeValue,',') like '%," + departmentId + ",%') "; + } else { + sqlWhere = " and (scopeType=2 and ','||scopeValue||',' like '%," + departmentId + ",%') "; + } + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + } + if (!subCompanyId.equals("")) { + if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) { + sqlWhere = " and (scopeType=1 and ','+scopeValue+',' like '%," + subCompanyId + ",%') "; + } else if (recordSet.getDBType().equalsIgnoreCase("mysql")) { + sqlWhere = " and (scopeType=1 and concat(',',scopeValue,',') like '%," + subCompanyId + ",%') "; + } else { + sqlWhere = " and (scopeType=1 and ','||scopeValue||',' like '%," + subCompanyId + ",%') "; + } + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + } + + sqlWhere = " and scopeType=0 "; + + recordSet.executeQuery(sql + sqlWhere); + while (recordSet.next()) { + ruleid = recordSet.getInt("ruleId"); + return ruleid; + } + + } catch (Exception e) { + recordSet.writeLog(e.getMessage()); + recordSet.writeLog(e); + } + return ruleid; + } + + public static Map isRepeat(String ruleid,int scopeType,String scopeValue,User user,String ruleDetailId){ + Map result = new HashMap<>(); + result.put("flag","0");//0=未重复,1=重复了不让保存 +// String sql = "select id,ruleid,scopetype,scopevalue,distributionmode from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5 "; + String sql = "select id,ruleid,scopetype,scopevalue,distributionmode from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) "; + RecordSet recordSet = new RecordSet(); + recordSet.writeLog("ruleid="+ruleid+",scopeType="+scopeType+",scopeValue="+scopeValue); + recordSet.executeQuery(sql); + while (recordSet.next()) { + String tmp_id = Util.null2String(recordSet.getString("id")); + String tmp_ruleid = Util.null2String(recordSet.getString("ruleid")); + String tmp_scopetype = Util.null2String(recordSet.getString("scopetype")); + String tmp_scopevalue = Util.null2String(recordSet.getString("scopevalue")); + String tmp_distributionmode = Util.null2String(recordSet.getString("distributionmode")); + recordSet.writeLog("tmp_id="+tmp_id+",tmp_ruleid="+tmp_ruleid+",tmp_scopetype="+tmp_scopetype+",tmp_scopevalue="+tmp_scopevalue); + if(tmp_ruleid.equals(ruleid) && ("".equals(ruleDetailId) || !tmp_id.equals(ruleDetailId))){ + //同一个假期类型,不能同时设置为【加班自动计入调休】和其他的规则,比如按工龄自动发放 + if(!tmp_distributionmode.equals("5")){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546798, user.getLanguage())); + return result; + } + } + + if(tmp_distributionmode.equals("5") && tmp_scopetype.equals(Util.null2String(scopeType)) && ("".equals(ruleDetailId) || !tmp_id.equals(ruleDetailId))){ + //总部级别的范围单独处理下,因为存在之前是分部级别,维护了分部id,这个时候即便是scopytype=0,但是scopevalue依然有值了,所以总部级别不用进行scopevalue的比对 + if("0".equals(tmp_scopetype)){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546797, user.getLanguage())); + return result; + } + if(null != scopeValue && scopeValue.indexOf(",")>-1){ + String[] values = scopeValue.split(","); + for (String value : values) { + if((","+tmp_scopevalue+",").indexOf(","+value+",")>-1){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546797, user.getLanguage())); + return result; + } + } + }else { + if((","+tmp_scopevalue+",").indexOf(","+scopeValue+",")>-1){ + result.put("flag","1"); + result.put("msg", SystemEnv.getHtmlLabelName(546797, user.getLanguage())); + return result; + } + } + } + } + + return result; + } + + /** + * 是否是育儿假,且不开启叠加 + * @param ruleId + * @return + */ + public static boolean isLeaveOfParental(String ruleId){ + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=8 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + String severalChildren = Util.null2s(recordSet.getString("severalChildren"), "0"); + if(severalChildren.equals("0")){ + flag = true; + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + /** + * 是否是育儿假且开启了叠加 + * @param ruleId + * @return + */ + public static boolean isLeaveOfParentalNum(String ruleId){ + boolean flag = false; + try { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=8 and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + String severalChildren = Util.null2s(recordSet.getString("severalChildren"), "0"); + if(severalChildren.equals("1")){ + flag = true; + } + } + } catch (Exception e) { + logger.info(e.getMessage()); + } + return flag; + } + + /** + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + * @param ruleId + * @return + */ + public static int getTimeselection(String ruleId) { + int timeselection = 1;//最小请假单位 + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + timeselection = Util.getIntValue(kqLeaveRulesComInfo.getTimeSelection(ruleId), 1); + return timeselection; + } + + public void updateChildLeaveDate(int scopeType,String scopeValue,int validityRule,String ruleId){ + RecordSet rs = new RecordSet(); + try { + // 查询当年育儿假数据 + String sql = "select * from kq_balanceOfLeave where (isDelete is null or isDelete<>1) and leaveRulesId = "+ruleId ; + + if (scopeType == 1 ) { + sql += " and resourceid in (select id from hrmresource where subCompanyId1 in (" + scopeValue + ") )"; + }else if (scopeType == 2 ) { + sql += " and resourceid in (select id from hrmresource where departmentId in (" + scopeValue + ") )"; + }else if (scopeType == 3) { + sql += " and (" + Tools.getOracleSQLIn(scopeValue, "resourceid") + ") "; + } + KQBalanceOfLeaveEntity balanceEntity = null; + ArrayList balanceEntities = new ArrayList<>(); + rs.executeQuery(sql); + while (rs.next()) { + int id = rs.getInt("id"); + String childId = Util.null2s(rs.getString("childId"), ""); + if(StringUtils.isNotBlank(childId)){ + String expirationDate = Util.null2s(rs.getString("expirationDate"), ""); + String effectiveDate = Util.null2s(rs.getString("effectiveDate"), ""); + balanceEntity = new KQBalanceOfLeaveEntity(); + balanceEntity.setId(id); + balanceEntity.setExpirationDate(expirationDate); + balanceEntity.setEffectiveDate(effectiveDate); + balanceEntities.add(balanceEntity); + } + } + sql = " update kq_balanceOfLeave set expirationDate =? where id= ? "; + for (int i = 0; balanceEntities != null && i < balanceEntities.size(); i++) { + KQBalanceOfLeaveEntity balance = balanceEntities.get(i); + String uid = Util.null2String(balance.getId()); + String effectiveDate = Util.null2String(balance.getEffectiveDate()); + String expirationDate = "2222-12-31"; + if (validityRule != 0) { + expirationDate = TimeUtil.dateAdd(TimeUtil.yearAdd(effectiveDate, 1), -1); + } + rs.executeUpdate(sql, expirationDate,uid); + } + + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + } +} diff --git a/src/com/engine/kq/biz/KQLeaveRulesComInfo.java b/src/com/engine/kq/biz/KQLeaveRulesComInfo.java new file mode 100644 index 0000000..3790b34 --- /dev/null +++ b/src/com/engine/kq/biz/KQLeaveRulesComInfo.java @@ -0,0 +1,319 @@ +package com.engine.kq.biz; + +import com.engine.kq.wfset.util.KQAttFlowCheckUtil; +import weaver.cache.CacheBase; +import weaver.cache.CacheColumn; +import weaver.cache.CacheColumnType; +import weaver.cache.PKColumn; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +/** + * 假期规则缓存类 + */ +public class KQLeaveRulesComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_leaveRules"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " (isDelete is null or isDelete !=1) "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = " showOrder,id "; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 假期规则名称 + */ + @CacheColumn(name = "leaveName") + protected static int leaveName; + + @CacheColumn(name = "SchevacationON") + protected static int SchevacationON; + + @CacheColumn(name = "Schevacation") + protected static int Schevacation; + + /** + * 是否禁用:0-未禁用、1-已禁用 + */ + @CacheColumn(name = "isEnable") + protected static int isEnable; + + /** + * 应用范围:0-总部、1-分部 + */ + @CacheColumn(name = "scopeType") + protected static int scopeType; + + /** + * 分部ID(当应用范围为分部时选择的分部ID) + */ + @CacheColumn(name = "scopeValue") + protected static int scopeValue; + + /** + * 最小请假单位 + * 1-按天请假 + * 2-按半天请假 + * 3-按小时请假 + * 4-按整天请假 + * 其他:无效数据 + */ + @CacheColumn(name = "minimumUnit") + protected static int minimumUnit; + + /** + * 余额单位变更时的换算比例 + * XX小时=1天 + */ + @CacheColumn(name = "proportion") + protected static int proportion; + + /** + * 日折算时长(1天=XX小时) + */ + @CacheColumn(name = "hoursToDay") + protected static int hoursToDay; + + /** + * 按自然日计算请假时长,0-不排除,1-排除节假日,2-排除休息日,3-排除节假日和休息日 + */ + @CacheColumn(name = "filterHolidays") + protected static int filterHolidays; + + /** + * 计算请假时长方式: + * 1-按工作日计算请假时长 + * 2-按自然日计算请假时长 + */ + @CacheColumn(name = "computingMode") + protected static int computingMode; + + /** + * 启用假期余额: + * 0-不启用 + * 1-启用 + */ + @CacheColumn(name = "balanceEnable") + protected static int balanceEnable; + + /** + * 假期类型标识 + */ + @CacheColumn(name = "leaveCode") + protected static int leaveCode; + + /** + * 半天单位 时间选择方式:1-下拉框选择 、2-具体时间 + */ + @CacheColumn(name = "timeselection") + protected static int timeselection; + + /** + * 折算方式 1是四舍五入 2是向上取整 3是向下取整 + */ + @CacheColumn(name = "conversion") + protected static int conversion; + + /** + * 流程重复时段 1是重复 0是不重复,默认不重复 + */ + @CacheColumn(name = "repeat_time") + protected static int repeatTime; + + public String getId(){ + return (String)getRowValue(PK_INDEX); + } + + public String getLeaveName() { + return (String)getRowValue(leaveName); + } + + public String getLeaveName(String key){ + return (String) getValue(leaveName,key); + } + + public String getSchevacationON() { + return (String)getRowValue(SchevacationON); + } + + public String getSchevacationON(String key){ + return (String) getValue(SchevacationON,key); + } + + public String getSchevacation() { + return (String)getRowValue(Schevacation); + } + + public String getSchevacation(String key){ + return (String) getValue(Schevacation,key); + } + + public String getIsEnable() { + return (String)getRowValue(isEnable); + } + + public String getIsEnable(String key){ + return (String) getValue(isEnable,key); + } + + public String getScopeType() { + return (String)getRowValue(scopeType); + } + + public String getScopeType(String key){ + return (String) getValue(scopeType,key); + } + + public String getScopeValue() { + return (String)getRowValue(scopeValue); + } + + public String getScopeValue(String key){ + return (String) getValue(scopeValue,key); + } + + public String getMinimumUnit() { + return (String)getRowValue(minimumUnit); + } + + public String getMinimumUnit(String key){ + return (String)getValue(minimumUnit,key); + } + + public String getProportion() { + return (String)getRowValue(proportion); + } + + public String getProportion(String key){ + return (String)getValue(proportion,key); + } + + public String getHoursToDay() { + return (String)getRowValue(hoursToDay); + } + + public String getHoursToDay(String key){ + return (String)getValue(hoursToDay,key); + } + public String getFilterHolidays() { + return (String)getRowValue(filterHolidays); + } + + public String getFilterHolidays(String key){ + return (String)getValue(filterHolidays,key); + } + + public String getComputingMode() { + return (String)getRowValue(computingMode); + } + + public String getComputingMode(String key){ + return (String)getValue(computingMode,key); + } + + public String getBalanceEnable() { + return (String)getRowValue(balanceEnable); + } + + public String getBalanceEnable(String key){ + return (String)getValue(balanceEnable,key); + } + + public String getLeaveCode() { + return (String)getRowValue(leaveCode); + } + + public String getLeaveCode(String key){ + return (String)getValue(leaveCode,key); + } + + public String getTimeSelection() { + String value = (String) getRowValue(timeselection); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } + + public String getTimeSelection(String key) { + String value = (String) getValue(timeselection, key); + if (value == null || value.equals("")) { + value = "1"; + } + return value; + } + + public String getConversion() { + return (String)getRowValue(conversion); + } + + public String getConversion(String key){ + return (String)getValue(conversion,key); + } + + public String getRepeatTime() { + return (String)getRowValue(repeatTime); + } + + public String getRepeatTime(String key){ + return (String)getValue(repeatTime,key); + } + + public String getUnitName(int language){ + String unitName = "";//单位名称,天/小时 + int minimumUnit = Util.getIntValue(getMinimumUnit(),1); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, language);//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, language);//(小时) + } + return unitName; + } + + public String getUnitName(String key,int language){ + String unitName = "";//单位名称,天/小时 + int minimumUnit = Util.getIntValue(getMinimumUnit(key),1); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, language);//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, language);//(小时) + } + +// KQTransMethod method = new KQTransMethod(); +// unitName = "("+method.getMinimumUnitName4Browser(""+minimumUnit, ""+language)+")"; + return unitName; + } + + public String getUnitNameNew(String key,int language){ + String unitName = "";//单位名称,天/小时 + int minimumUnit = Util.getIntValue(getMinimumUnit(key),1); + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(389325, language);//(天) + } else { + unitName = SystemEnv.getHtmlLabelName(389326, language);//(小时) + } + return unitName; + } + + + + @Override + public void removeCache() { + super.removeCache(); + KQAttFlowCheckUtil kqAttFlowCheckUtil = new KQAttFlowCheckUtil(); + kqAttFlowCheckUtil.initLeaveUnit(); + } + +} diff --git a/src/com/engine/kq/biz/KQLeaveRulesDetailComInfo.java b/src/com/engine/kq/biz/KQLeaveRulesDetailComInfo.java new file mode 100644 index 0000000..b7398ec --- /dev/null +++ b/src/com/engine/kq/biz/KQLeaveRulesDetailComInfo.java @@ -0,0 +1,1329 @@ +package com.engine.kq.biz; + +import weaver.cache.*; +import weaver.common.StringUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; + +/** + * @Auther: Administrator + * @Date: 2019-03-08 16:23 + * @Description: + */ +public class KQLeaveRulesDetailComInfo extends CacheBase { + + /** + * 数据来源 + */ + protected static String TABLE_NAME = "kq_leaveRulesDetail"; + /** + * sql中的where信息,不要以where开始 + */ + protected static String TABLE_WHERE = " (isDelete is null or isDelete !=1) "; + /** + * sql中的order by信息,不要以order by开始 + */ + protected static String TABLE_ORDER = "id"; + + /** + * 主键 + */ + @PKColumn(type = CacheColumnType.NUMBER) + protected static String PK_NAME = "id"; + + /** + * 假期规则的ID + */ + @CacheColumn(name = "id") + protected static int id; + + /** + * 假期类型的ID + */ + @CacheColumn(name = "ruleId") + protected static int ruleId; + + /** + * 假期规则名称 + */ + @CacheColumn(name = "ruleName") + protected static int ruleName; + + /** + * 应用范围:0-总部、1-分部 + */ + @CacheColumn(name = "scopeType") + protected static int scopeType; + + /** + * 分部ID(当应用范围为分部时选择的分部ID) + */ + @CacheColumn(name = "scopeValue") + protected static int scopeValue; + + /** + * 余额发放方式: + * 1-手动发放 + * 2-按司龄自动发放 + * 3-按工龄自动发放 + * 4-每年自动发放固定天数 + * 5-加班时长自动计入余额 + * 6-按司龄+工龄自动发放 + */ + @CacheColumn(name = "distributionMode") + protected static int distributionMode; + + /** + * 每人发放小时(天)数 + * 注:当余额发放方式为"4-每年自动发放固定天数"时有效 + */ + @CacheColumn(name = "annualAmount") + protected static int annualAmount; + + /** + * 法定年假的规则:(当【余额发放方式】选择【6-按司龄+工龄自动发放】才有效) + * 0-工龄(默认) + * 1-司龄 + * 2-司龄+工龄 + */ + @CacheColumn(name = "legalKey") + protected static int legalKey; + + /** + * 福利年假的规则:(当【余额发放方式】选择【6-按司龄+工龄自动发放】才有效) + * 0-工龄 + * 1-司龄(默认) + * 2-司龄+工龄 + */ + @CacheColumn(name = "welfareKey") + protected static int welfareKey; + + /** + * 扣减优先级:(当【余额发放方式】选择【6-按司龄+工龄自动发放】才有效) + * 1-法定年假 + * 2-福利年假 + */ + @CacheColumn(name = "priority") + protected static int priority; + + /** + * 计算方式 + */ + @CacheColumn(name = "calcMethod") + protected static int calcMethod; + + /** + * //假期基数的发放日期 + * //1--每年的1月1号 + * //2--入职日期 + * //3--参加工作日期 + */ + @CacheColumn(name = "baseAmountReleaseDate") + protected static int baseAmountReleaseDate; + + /** + * //假期基数的变动日期 + * //1--每年的1月1号 + * //2--入职日期 + * //3--参加工作日期 + */ + @CacheColumn(name = "baseAmountChangeDate") + protected static int baseAmountChangeDate; + + /** + * 假期基数折算方式 + * 0--不折算 + * 1--四舍五入 + * 2--向上取整 + * 3--向下取整 + * 4--向上取0.5的倍数 + * 5--向下取0.5的倍数 + */ + @CacheColumn(name = "convertMode") + protected static int convertMode; + + /** + * 折算后保留的小数点位数 + */ + @CacheColumn(name = "decimalDigit") + protected static int decimalDigit; + + /** + * 有效期规则 + * 0-永久有效 + * 1-按自然年(1月1日-12月31日) + * 2-按入职日期起12个月 + * 3-自定义次年失效日期 + * 4-按天数失效 + * 5-按季度失效 + * 6-按月数失效 + */ + @CacheColumn(name = "validityRule") + protected static int validityRule; + + /** + * 失效日期-月 + */ + @CacheColumn(name = "expirationMonth") + protected static int expirationMonth; + + /** + * 失效日期-日 + */ + @CacheColumn(name = "expirationDay") + protected static int expirationDay; + + /** + * 有效天数 + */ + @CacheColumn(name = "effectiveDays") + protected static int effectiveDays; + + /** + * 有效月数 + */ + @CacheColumn(name = "effectiveMonths") + protected static int effectiveMonths; + + /** + * 是否允许延长有效期 + * 0-不允许 + * 1-允许 + */ + @CacheColumn(name = "extensionEnable") + protected static int extensionEnable; + + /** + * 允许延长的有效期天数 + */ + @CacheColumn(name = "extendedDays") + protected static int extendedDays; + + /** + * 释放规则 + * 0-不限制 + * 1-按天释放 + * 2-按月释放 + */ + @CacheColumn(name = "releaseRule") + protected static int releaseRule; + + /** + * 假期类型 + */ + @CacheColumn(name = "leaveCode") + protected static int leaveCode; + + /** + * 是否需要排除次账号 + * 0--不排除,即次账号正常享受年假 + * 1--排除,即次账号不能享受年假 + */ + @CacheColumn(name = "excludeSubAccount") + protected static int excludeSubAccount; + + /** + * 转正之前是否允许发放假期余额 + * 0--不允许 + * 1--允许 + */ + @CacheColumn(name = "beforeFormal") + protected static int beforeFormal; + + /** + * 多孩叠加开关 + * 0--不 + * 1--开 + */ + @CacheColumn(name = "severalChildren") + protected static int severalChildren; + + /** + * 孩子多少周岁前发放。 + */ + @CacheColumn(name = "yearsOld") + protected static int yearsOld; + + /** + *是否按照省份发放育儿假。1否,2是 + */ + @CacheColumn(name = "isprovince") + protected static int isprovince; + + /** + *是否按照省份发放育儿假。1否,2是 + */ + @CacheColumn(name = "carryOver") + protected static int carryOver; + + private static final String[] SCOPE_TYPES = {"3", "2", "1"}; + @Override + public CacheMap initCache() throws Exception { + CacheMap localData = super.createCacheMap(); + RecordSet rs = new RecordSet(); + String sql = "select * from kq_leaveRulesDetail where (isDelete is null or isDelete<>1) order by id"; + rs.executeQuery(sql); + while (rs.next()) { + String _id = rs.getString("id"); + String _ruleId = rs.getString("ruleId");//假期类型的ID + String _ruleName = rs.getString("ruleName");//假期类型的ID + String _scopeType = rs.getString("scopeType");//假期类型的流程可见范围 + String _scopeValue = rs.getString("scopeValue");//流程可见范围为分部时勾选的分部ID + String _distributionMode = rs.getString("distributionMode"); + String _annualAmount = rs.getString("annualAmount"); + String _legalKey = rs.getString("legalKey"); + String _welfareKey = rs.getString("welfareKey"); + String _priority = rs.getString("priority"); + String _calcMethod = rs.getString("calcMethod"); + String _baseAmountReleaseDate = rs.getString("baseAmountReleaseDate"); + String _baseAmountChangeDate = rs.getString("baseAmountChangeDate"); + String _convertMode = rs.getString("convertMode"); + String _decimalDigit = rs.getString("decimalDigit"); + String _validityRule = rs.getString("validityRule"); + String _expirationMonth = rs.getString("expirationMonth"); + String _expirationDay = rs.getString("expirationDay"); + String _effectiveDays = rs.getString("effectiveDays"); + String _effectiveMonths = rs.getString("effectiveMonths"); + String _extensionEnable = rs.getString("extensionEnable"); + String _extendedDays = rs.getString("extendedDays"); + String _releaseRule = rs.getString("releaseRule"); + String _leaveCode = rs.getString("leaveCode"); + String _excludeSubAccount = rs.getString("excludeSubAccount"); + String _beforeFormal = rs.getString("beforeFormal"); + String _severalChildren = rs.getString("severalChildren"); + String _yearsOld = rs.getString("yearsOld"); + String _isprovince = rs.getString("isprovince"); + String _carryOver = rs.getString("carryOver"); + if (_scopeType.equals("1") || _scopeType.equals("2") || _scopeType.equals("3")) { + String[] scopeValueArr = _scopeValue.split(","); + for (int i = 0; i < scopeValueArr.length; i++) { + String PK = _ruleId + "|" + _scopeType + "|" + scopeValueArr[i]; + + + CacheItem row = createCacheItem(); + row.set(PK_INDEX, PK); + row.set(id, _id); + row.set(ruleId, _ruleId); + row.set(ruleName, _ruleName); + row.set(scopeType, _scopeType); + row.set(scopeValue, _scopeValue); + row.set(distributionMode, _distributionMode); + row.set(annualAmount, _annualAmount); + row.set(legalKey, _legalKey); + row.set(welfareKey, _welfareKey); + row.set(priority, _priority); + row.set(calcMethod, _calcMethod); + row.set(baseAmountReleaseDate, _baseAmountReleaseDate); + row.set(baseAmountChangeDate, _baseAmountChangeDate); + row.set(convertMode, _convertMode); + row.set(decimalDigit, _decimalDigit); + row.set(validityRule, _validityRule); + row.set(expirationMonth, _expirationMonth); + row.set(expirationDay, _expirationDay); + row.set(effectiveDays, _effectiveDays); + row.set(effectiveMonths, _effectiveMonths); + row.set(extensionEnable, _extensionEnable); + row.set(extendedDays, _extendedDays); + row.set(releaseRule, _releaseRule); + row.set(leaveCode, _leaveCode); + row.set(excludeSubAccount, _excludeSubAccount); + row.set(beforeFormal, _beforeFormal); + row.set(severalChildren, _severalChildren); + row.set(yearsOld, _yearsOld); + row.set(isprovince, _isprovince); + row.set(carryOver, _carryOver); + modifyCacheItem(PK, row); + localData.put(PK, row); + } + } else { + String PK = ruleId + "|" + scopeType; + + CacheItem row = createCacheItem(); + row.set(PK_INDEX, PK); + row.set(id, _id); + row.set(ruleId, _ruleId); + row.set(ruleName, _ruleName); + row.set(scopeType, _scopeType); + row.set(scopeValue, _scopeValue); + row.set(distributionMode, _distributionMode); + row.set(annualAmount, _annualAmount); + row.set(legalKey, _legalKey); + row.set(welfareKey, _welfareKey); + row.set(priority, _priority); + row.set(calcMethod, _calcMethod); + row.set(baseAmountReleaseDate, _baseAmountReleaseDate); + row.set(baseAmountChangeDate, _baseAmountChangeDate); + row.set(convertMode, _convertMode); + row.set(decimalDigit, _decimalDigit); + row.set(validityRule, _validityRule); + row.set(expirationMonth, _expirationMonth); + row.set(expirationDay, _expirationDay); + row.set(effectiveDays, _effectiveDays); + row.set(effectiveMonths, _effectiveMonths); + row.set(extensionEnable, _extensionEnable); + row.set(extendedDays, _extendedDays); + row.set(releaseRule, _releaseRule); + row.set(leaveCode, _leaveCode); + row.set(excludeSubAccount, _excludeSubAccount); + row.set(beforeFormal, _beforeFormal); + row.set(severalChildren, _severalChildren); + row.set(yearsOld, _yearsOld); + row.set(isprovince, _isprovince); + row.set(carryOver, _carryOver); + modifyCacheItem(PK, row); + localData.put(PK, row); + } + } + return localData; + } + + @Override + public CacheItem initCache(String key) { + if (key == null || "".equals(key.trim())) { + return null; + } + + String ruleIdTemp = "";//假期类型的ID + String scopeTypeTemp = "";//假期类型的流程可见范围 + String scopeValueTemp = "";//流程可见范围为分部时勾选的分部ID + String PK = ""; + + String[] keyArr = key.split("\\|"); + String sql = ""; + RecordSet rs = new RecordSet(); + if (keyArr.length == 2) { + ruleIdTemp = keyArr[0]; + scopeTypeTemp = keyArr[1]; + PK = ruleIdTemp + "|0"; + + sql = "select * from kq_leaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=" + ruleIdTemp + " and scopeType=" + scopeTypeTemp + " order by id"; + } + if (keyArr.length == 3) { + ruleIdTemp = keyArr[0]; + scopeTypeTemp = keyArr[1]; + scopeValueTemp = keyArr[2]; + PK = ruleIdTemp + "|1|" + scopeValueTemp; + + sql = "select * from kq_leaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=" + ruleIdTemp + " and scopeType=" + scopeTypeTemp; + if (rs.getDBType().equalsIgnoreCase("sqlserver")) { + sql += " and ','+scopeValue+',' like '%," + scopeValueTemp + ",%'"; + } else if (rs.getDBType().equalsIgnoreCase("mysql")) { + sql += " and concat(',',scopeValue,',') like '%," + scopeValueTemp + ",%'"; + } else { + sql += " and ','||scopeValue||',' like '%," + scopeValueTemp + ",%'"; + } + sql += " order by id "; + } + rs.executeQuery(sql); + if (rs.next()) { + String _id = rs.getString("id"); + String _ruleId = rs.getString("ruleId");//假期类型的ID + String _ruleName = rs.getString("ruleName");//假期类型的ID + String _scopeType = rs.getString("scopeType");//假期类型的流程可见范围 + String _scopeValue = rs.getString("scopeValue");//流程可见范围为分部时勾选的分部ID + String _distributionMode = rs.getString("distributionMode"); + String _annualAmount = rs.getString("annualAmount"); + String _legalKey = rs.getString("legalKey"); + String _welfareKey = rs.getString("welfareKey"); + String _priority = rs.getString("priority"); + String _calcMethod = rs.getString("calcMethod"); + String _baseAmountReleaseDate = rs.getString("baseAmountReleaseDate"); + String _baseAmountChangeDate = rs.getString("baseAmountChangeDate"); + String _convertMode = rs.getString("convertMode"); + String _decimalDigit = rs.getString("decimalDigit"); + String _validityRule = rs.getString("validityRule"); + String _expirationMonth = rs.getString("expirationMonth"); + String _expirationDay = rs.getString("expirationDay"); + String _effectiveDays = rs.getString("effectiveDays"); + String _effectiveMonths = rs.getString("effectiveMonths"); + String _extensionEnable = rs.getString("extensionEnable"); + String _extendedDays = rs.getString("extendedDays"); + String _releaseRule = rs.getString("releaseRule"); + String _leaveCode = rs.getString("leaveCode"); + String _excludeSubAccount = rs.getString("excludeSubAccount"); + String _beforeFormal = rs.getString("beforeFormal"); + String _severalChildren = rs.getString("severalChildren"); + String _yearsOld = rs.getString("yearsOld"); + String _isprovince = rs.getString("isprovince"); + String _carryOver = rs.getString("carryOver"); + + CacheItem row = createCacheItem(); + row.set(PK_INDEX, PK); + row.set(id, _id); + row.set(ruleId, _ruleId); + row.set(ruleName, _ruleName); + row.set(scopeType, _scopeType); + row.set(scopeValue, _scopeValue); + row.set(distributionMode, _distributionMode); + row.set(annualAmount, _annualAmount); + row.set(legalKey, _legalKey); + row.set(welfareKey, _welfareKey); + row.set(priority, _priority); + row.set(calcMethod, _calcMethod); + row.set(baseAmountReleaseDate, _baseAmountReleaseDate); + row.set(baseAmountChangeDate, _baseAmountChangeDate); + row.set(convertMode, _convertMode); + row.set(decimalDigit, _decimalDigit); + row.set(validityRule, _validityRule); + row.set(expirationMonth, _expirationMonth); + row.set(expirationDay, _expirationDay); + row.set(effectiveDays, _effectiveDays); + row.set(effectiveMonths, _effectiveMonths); + row.set(extensionEnable, _extensionEnable); + row.set(extendedDays, _extendedDays); + row.set(releaseRule, _releaseRule); + row.set(leaveCode, _leaveCode); + row.set(excludeSubAccount, _excludeSubAccount); + row.set(beforeFormal, _beforeFormal); + row.set(severalChildren, _severalChildren); + row.set(yearsOld, _yearsOld); + row.set(isprovince, _isprovince); + row.set(carryOver, _carryOver); + modifyCacheItem(key, row); + return row; + } else { + CacheItem row = createCacheItem(); + modifyCacheItem(key, row); + return row; + } + } + + private String getId(String key) { + return (String) getValue(id, key); + } + +// public String getId(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String id = getId(PK); +// if (id == null || id == "") { +// PK = ruleId + "|0"; +// id = getId(PK); +// } +// return id; +// } + + private String getRuleId(String key) { + return (String) getValue(ruleId, key); + } + + private String getRuleName(String key) { + return (String) getValue(ruleName, key); + } + +// public String getRuleName(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String ruleName = getRuleName(PK); +// if (ruleName == null || ruleName == "") { +// PK = ruleId + "|0"; +// ruleName = getRuleName(PK); +// } +// return ruleName; +// } + + private String getScopeType(String key) { + return (String) getValue(scopeType, key); + } + +// public String getScopeType(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String scopeType = getScopeType(PK); +// if (scopeType == null || scopeType == "") { +// PK = ruleId + "|0"; +// scopeType = getScopeType(PK); +// } +// return scopeType; +// } + + private String getScopeValue(String key) { + return (String) getValue(scopeValue, key); + } + +// public String getScopeValue(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String scopeValue = getScopeValue(PK); +// if (scopeValue == null || scopeValue == "") { +// PK = ruleId + "|0"; +// scopeValue = getScopeValue(PK); +// } +// return scopeValue; +// } + + private String getDistributionMode(String key) { + return (String) getValue(distributionMode, key); + } + +// public String getDistributionMode(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String distributionMode = getDistributionMode(PK); +// if (distributionMode == null || distributionMode == "") { +// PK = ruleId + "|0"; +// distributionMode = getDistributionMode(PK); +// } +// return distributionMode; +// } + + private String getAnnualAmount(String key) { + return (String) getValue(annualAmount, key); + } + +// public String getAnnualAmount(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String annualAmount = getAnnualAmount(PK); +// if (annualAmount == null || annualAmount == "") { +// PK = ruleId + "|0"; +// annualAmount = getAnnualAmount(PK); +// } +// return annualAmount; +// } + + private String getLegalKey(String key) { + return (String) getValue(legalKey, key); + } + +// public String getLegalKey(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String legalKey = getLegalKey(PK); +// if (legalKey == null || legalKey == "") { +// PK = ruleId + "|0"; +// legalKey = getLegalKey(PK); +// } +// return legalKey; +// } + + private String getWelfareKey(String key) { + return (String) getValue(welfareKey, key); + } + +// public String getWelfareKey(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String welfareKey = getWelfareKey(PK); +// if (welfareKey == null || welfareKey == "") { +// PK = ruleId + "|0"; +// welfareKey = getWelfareKey(PK); +// } +// return welfareKey; +// } + + private String getPriority(String key) { + return (String) getValue(priority, key); + } + +// public String getPriority(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String priority = getPriority(PK); +// if (priority == null || priority == "") { +// PK = ruleId + "|0"; +// priority = getPriority(PK); +// } +// return priority; +// } + + private String getValidityRule(String key) { + return (String) getValue(validityRule, key); + } + +// public String getValidityRule(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String validityRule = getValidityRule(PK); +// if (validityRule == null || validityRule == "") { +// PK = ruleId + "|0"; +// validityRule = getValidityRule(PK); +// } +// return validityRule; +// } + + private String getExpirationMonth(String key) { + return (String) getValue(expirationMonth, key); + } + +// public String getExpirationMonth(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String expirationMonth = getExpirationMonth(PK); +// if (expirationMonth == null || expirationMonth == "") { +// PK = ruleId + "|0"; +// expirationMonth = getExpirationMonth(PK); +// } +// if (expirationMonth.length() == 1) { +// expirationMonth = "0" + expirationMonth; +// } +// return expirationMonth; +// } + + private String getExpirationDay(String key) { + return (String) getValue(expirationDay, key); + } + +// public String getExpirationDay(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String expirationDay = getExpirationDay(PK); +// if (expirationDay == null || expirationDay == "") { +// PK = ruleId + "|0"; +// expirationDay = getExpirationDay(PK); +// } +// if (expirationDay.length() == 1) { +// expirationDay = "0" + expirationDay; +// } +// return expirationDay; +// } + + private String getEffectiveDays(String key) { + return (String) getValue(effectiveDays, key); + } + +// public String getEffectiveDays(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String effectiveDays = getEffectiveDays(PK); +// if (effectiveDays == null || effectiveDays == "") { +// PK = ruleId + "|0"; +// effectiveDays = getEffectiveDays(PK); +// } +// if (Util.getIntValue(effectiveDays, 0) < 1) { +// effectiveDays = "1"; +// } +// return effectiveDays; +// } + + private String getEffectiveMonths(String key) { + return (String) getValue(effectiveMonths, key); + } + +// public String getEffectiveMonths(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String effectiveMonths = getEffectiveMonths(PK); +// if (effectiveMonths == null || effectiveMonths == "") { +// PK = ruleId + "|0"; +// effectiveMonths = getEffectiveMonths(PK); +// } +// if (Util.getIntValue(effectiveMonths, 0) < 1) { +// effectiveMonths = "1"; +// } +// return effectiveMonths; +// } + + private String getExtensionEnable(String key) { + return (String) getValue(extensionEnable, key); + } + +// public String getExtensionEnable(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String extensionEnable = getExtensionEnable(PK); +// if (extensionEnable == null || extensionEnable == "") { +// PK = ruleId + "|0"; +// extensionEnable = getExtensionEnable(PK); +// } +// return extensionEnable; +// } + + private String getExtendedDays(String key) { + return (String) getValue(extendedDays, key); + } + +// public String getExtendedDays(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String extendedDays = getExtendedDays(PK); +// if (extendedDays == null || extendedDays == "") { +// PK = ruleId + "|0"; +// extendedDays = getExtendedDays(PK); +// } +// return extendedDays; +// } + + private String getReleaseRule(String key) { + return (String) getValue(releaseRule, key); + } + +// public String getReleaseRule(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String releaseRule = getReleaseRule(PK); +// if (releaseRule == null || releaseRule == "") { +// PK = ruleId + "|0"; +// releaseRule = getReleaseRule(PK); +// } +// return releaseRule; +// } + + private String getLeaveCode(String key) { + return (String) getValue(leaveCode, key); + } + +// public String getLeaveCode(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String leaveCode = getLeaveCode(PK); +// if (leaveCode == null || leaveCode == "") { +// PK = ruleId + "|0"; +// leaveCode = getLeaveCode(PK); +// } +// return leaveCode; +// } + + private String getCalcMethod(String key) { + return (String) getValue(calcMethod, key); + } + +// public String getCalcMethod(String ruleId, String subcompanyId) { +// String PK = ruleId + "|1|" + subcompanyId; +// String calcMethod = getCalcMethod(PK); +// if (calcMethod == null || calcMethod == "") { +// PK = ruleId + "|0"; +// calcMethod = getCalcMethod(PK); +// } +// return calcMethod; +// } + + private String getBaseAmountReleaseDate(String key) { + return (String) getValue(baseAmountReleaseDate, key); + } + +// public String getBaseAmountReleaseDate(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String baseAmountReleaseDate = getBaseAmountReleaseDate(PK); +// if (baseAmountReleaseDate == null || baseAmountReleaseDate == "") { +// PK = ruleId + "|0"; +// baseAmountReleaseDate = getBaseAmountReleaseDate(PK); +// } +// return baseAmountReleaseDate; +// } + + private String getBaseAmountChangeDate(String key) { + return (String) getValue(baseAmountChangeDate, key); + } + +// public String getBaseAmountChangeDate(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String baseAmountChangeDate = getBaseAmountChangeDate(PK); +// if (baseAmountChangeDate == null || baseAmountChangeDate == "") { +// PK = ruleId + "|0"; +// baseAmountChangeDate = getBaseAmountChangeDate(PK); +// } +// return baseAmountChangeDate; +// } + + private String getConvertMode(String key) { + return (String) getValue(convertMode, key); + } + +// public String getConvertMode(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String convertMode = getConvertMode(PK); +// if (convertMode == null || convertMode == "") { +// PK = ruleId + "|0"; +// convertMode = getConvertMode(PK); +// } +// if (convertMode == null || convertMode.equals("")) { +// convertMode = "1"; +// } +// return convertMode; +// } + + private String getDecimalDigit(String key) { + return (String) getValue(decimalDigit, key); + } + +// public String getDecimalDigit(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String decimalDigit = getDecimalDigit(PK); +// if (decimalDigit == null || decimalDigit == "") { +// PK = ruleId + "|0"; +// decimalDigit = getDecimalDigit(PK); +// } +// if (decimalDigit == null || decimalDigit == "" || Util.getIntValue(decimalDigit, 0) < 2) { +// decimalDigit = "2"; +// } +// return decimalDigit; +// } + + private String getExcludeSubAccount(String key) { + return (String) getValue(excludeSubAccount, key); + } + +// public String getExcludeSubAccount(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String excludeSubAccount = getExcludeSubAccount(PK); +// if (excludeSubAccount == null || excludeSubAccount == "") { +// PK = ruleId + "|0"; +// excludeSubAccount = getExcludeSubAccount(PK); +// } +// return excludeSubAccount; +// } + + private String getBeforeFormal(String key) { + return (String) getValue(beforeFormal, key); + } + +// public String getBeforeFormal(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String beforeFormal = getBeforeFormal(PK); +// if (beforeFormal == null || beforeFormal == "") { +// PK = ruleId + "|0"; +// beforeFormal = getBeforeFormal(PK); +// } +// return beforeFormal; +// } + private String getSeveralChildren(String key) { + return (String) getValue(severalChildren, key); + } + +// public String getSeveralChildren(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String severalChildren = getSeveralChildren(PK); +// if (severalChildren == null || severalChildren == "") { +// PK = ruleId + "|0"; +// severalChildren = getSeveralChildren(PK); +// } +// return severalChildren; +// } + + private String getYearsOld(String key) { + return (String) getValue(yearsOld, key); + } + +// public String getYearsOld(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String yearsOld = getYearsOld(PK); +// if (yearsOld == null || yearsOld == "") { +// PK = ruleId + "|0"; +// yearsOld = getYearsOld(PK); +// } +// return yearsOld; +// } + private String getIsProvince(String key) { + return (String) getValue(isprovince, key); + } + + private String getCarryOver(String key) { + return (String) getValue(carryOver, key); + } + +// public String getIsProvince(String ruleId, String subcompanyId){ +// String PK = ruleId + "|1|" + subcompanyId; +// String isprovince = getIsProvince(PK); +// if (isprovince == null || isprovince == "") { +// PK = ruleId + "|0"; +// isprovince = getIsProvince(PK); +// } +// return isprovince; +// } + + + + public String getId(String ruleId, String subcompanyId, String departmentId, String resourceId) { + String value = ""; + String[] scopeValue = {resourceId, departmentId, subcompanyId}; + for(int i=0; i> { + + private SimpleBizLogger logger; + + public AddLeaveRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + String ruleId = Util.null2String(params.get("typeId")); + String ruleName = Util.null2String(params.get("ruleName")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%'"; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("rulename"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_EntryToLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo1.setSubSql(subSql1, "id"); + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo(); + String subSql2 = "select * from kq_WorkingAgeToLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo2.setSubSql(subSql2, "id"); + logger.addSubLogInfo(subLogInfo2); + + SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo(); + String subSql3 = "select * from kq_MixModeToLegalLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo3.setSubSql(subSql3, "id"); + logger.addSubLogInfo(subLogInfo3); + + SimpleBizLogger.SubLogInfo subLogInfo4 = logger.getNewSubLogInfo(); + String subSql4 = "select * from kq_MixModeToWelfareLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')"; + subLogInfo4.setSubSql(subSql4, "id"); + logger.addSubLogInfo(subLogInfo4); + + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canAdd = HrmUserVarify.checkUserRight("KQLeaveRulesAdd:Add", user);//是否具有新建权限 + if (!canAdd) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限 + return resultMap; + } + + /*假期规则对应的假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*假期规则名称*/ + String ruleName = Util.null2String(params.get("ruleName")); + + /*应用范围:0-总部、1-分部*/ + int scopeType = Util.getIntValue((String) params.get("scopeType")); + + /*应用范围为分部时,选择的分部ID*/ + String scopeValue = Util.null2String(params.get("scopeValue")); + String deductorder = Util.null2String(params.get("deductorder")); + + /*应用范围为部门时,选择的部门ID*/ + String scopeValueDepartment = Util.null2String(params.get("scopeValueDepartment")); + + /*应用范围为人员时,选择的人员ID*/ + String scopeValueMember = Util.null2String(params.get("scopeValueMember")); + + if(scopeType == 2) { + scopeValue = scopeValueDepartment; + } else if(scopeType == 3) { + scopeValue = scopeValueMember; + } + + /*余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按司龄+工龄自动发放*/ + int distributionMode = Util.getIntValue((String) params.get("distributionMode"), 1); + + /*每人发放小时(天)数(当余额发放方式为每年自动发放固定天数时有效)*/ + double annualAmount = Util.getDoubleValue((String) params.get("annualAmount"), 0); + + //法定年假规则:0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String legalKey = Util.null2s((String) params.get("legalKey"), "0"); + + //福利年假规则:0-工龄、1-工龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String welfareKey = Util.null2s((String) params.get("welfareKey"), "1"); + + /*扣减优先级:1-法定年假、2-福利年假*/ + int priority = Util.getIntValue((String) params.get("priority"), 1); + + /*有效期规则:0-不限制、1-按自然月(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4-自定义有效天数*/ + int validityRule = Util.getIntValue((String) params.get("validityRule"), 1); + + /*有效期天数:(当有效期天数选择按天数失效的时候有效)*/ + int effectiveDays = Util.getIntValue((String) params.get("effectiveDays"), 30); + + //有效月数(当有效期规则选择自定义有效月数时) + int effectiveMonths = Util.getIntValue((String) params.get("effectiveMonths"), 1); + + /*失效日期--月(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationMonth = Util.null2String(params.get("expirationMonth")); + + /*失效日期--日(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationDay = Util.null2String(params.get("expirationDay")); + + /*允许延长有效期:0-不允许、1-允许*/ + int extensionEnable = Util.getIntValue((String) params.get("extensionEnable"), 0); + + /*允许超过有效期天数*/ + int extendedDays = Util.getIntValue((String) params.get("extendedDays"), 0); + + /*释放规则:0-不限制、1-按天释放、2-按月释放*/ + int releaseRule = Util.getIntValue((String) params.get("releaseRule"), 0); + + /*假期基数计算方式:0-精确计算、1-按最少的假期余额计算、2-按最多的假期余额计算*/ + int calcMethod = Util.getIntValue((String) params.get("calcMethod"), 0); + + /*是否折算:0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、5-向下取0.5的倍数*/ + int convertMode = Util.getIntValue("" + params.get("convertMode"), 1); + + /*次账号是否发放假期余额:0-不发放、1-发放*/ + int excludeSubAccount = Util.getIntValue("" + params.get("excludeSubAccount"), 1); + + //多孩叠加开关。 + int severalChildren = Util.getIntValue("" + params.get("severalChildren"), 0); + + //孩子多少周岁前发放。 + int yearsOld = Util.getIntValue("" + params.get("yearsOld"), 3); + + //是否按照省份发放育儿假。 + int isprovince = Util.getIntValue("" + params.get("isprovince"), 1); + +// 2、在假期规则页面,增加开关控制是否开启。carryOver +// 3、增加输入框控制结转天数。 carryOverDays + int carryOver = Util.getIntValue("" + params.get("carryOver"), 0); + double carryOverDays = Util.getDoubleValue((String) params.get("carryOverDays"), 0); + + /*转正之前是否发放假期余额:0-不发放、1-发放*/ + int beforeFormal = Util.getIntValue("" + params.get("beforeFormal"), 1); + + if (scopeType != 0 && scopeValue.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + /*两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式*/ + if (distributionMode == 5) { + releaseRule = 0; + Map data = KQLeaveRulesBiz.isRepeat(ruleId,scopeType,scopeValue,user,""); + if(null != data && "1".equals(data.get("flag"))){ + resultMap.put("status", "-1"); + resultMap.put("message", data.get("msg"));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 + return resultMap; + } +// String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id<>? and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)"; +// RecordSet recordSet = new RecordSet(); +// recordSet.executeQuery(sql, ruleId); +// if (recordSet.next()) { +// resultMap.put("status", "-1"); +// resultMap.put("message", SystemEnv.getHtmlLabelName(505664, user.getLanguage()));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 +// return resultMap; +// } + if(null != deductorder && deductorder.length()>0){ + String[] orders = deductorder.split(","); + if(null != orders && orders.length != 3){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(547752, user.getLanguage())); + return resultMap; + } + } + } else if (distributionMode == 6) { + /*同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505665, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + } else if (distributionMode == 8) { + /*同一假期类型下 育儿假 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>8"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + int severalChildrenValue = Util.getIntValue(Util.null2s(recordSet.getString("severalChildren"), "0"), 0); + if(severalChildrenValue!=severalChildren){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546859, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + } + } else { + /*同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505666, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存 + return resultMap; + } + + //同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=5"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(510357, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + return resultMap; + } + //同一个假期类型下其他余额发放方式不能与 育儿假叠加 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage())); + return resultMap; + } + } + + String searchSql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(searchSql, ruleId); + while (recordSet.next()) { + int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValueTemp = recordSet.getString("scopeValue"); + + if (scopeType == 0 && scopeTypeTemp == 0) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505667, user.getLanguage()));//该假期类型下已经新建过总部的假期规则,请勿重复新建 + return resultMap; + } + if (scopeType == 1 && scopeTypeTemp == 1) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String subcomName = subCompanyComInfo.getSubCompanyname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505668, user.getLanguage()).replace("$", subcomName));//该假期类型下已经新建过分部的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 2 && scopeTypeTemp == 2) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + DepartmentComInfo comInfo = new DepartmentComInfo(); + String name = comInfo.getDepartmentname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534890, user.getLanguage()).replace("$", name));//该假期类型下已经新建过部门的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 3 && scopeTypeTemp == 3) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + ResourceComInfo comInfo = new ResourceComInfo(); + String name = comInfo.getLastname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534891, user.getLanguage()).replace("$", name));//该假期类型下已经新建过人员的假期规则,请勿重复新建 + return resultMap; + } + } + } + boolean flag = false;//数据是否插入成功 + String sql = "insert into kq_LeaveRulesDetail(ruleId,ruleName,scopeType,scopeValue," + + "distributionMode,annualAmount,legalKey,welfareKey,priority,validityRule,effectiveDays,effectiveMonths,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod,convertMode,excludeSubAccount,beforeFormal,severalChildren,yearsOld,isprovince,carryOver,carryOverDays,deductorder,isDelete) values(?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?,?,?,?,0)"; + flag = recordSet.executeUpdate(sql, ruleId, ruleName, scopeType, scopeValue, + distributionMode, annualAmount, legalKey, welfareKey, priority, validityRule, effectiveDays, effectiveMonths, expirationMonth, expirationDay, extensionEnable, extendedDays, releaseRule, calcMethod, convertMode, excludeSubAccount, beforeFormal,severalChildren,yearsOld,isprovince,carryOver,carryOverDays,deductorder); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + /*获取刚才插入的假期规则详情的ID*/ + int ruleDetailId = 0; + sql = "select max(id) maxId from kq_LeaveRulesDetail"; + recordSet.executeQuery(sql); + if (recordSet.next()) { + ruleDetailId = Util.getIntValue(recordSet.getString("maxId"), 0); + } + + if ((distributionMode == 2 || distributionMode == 7) && ruleDetailId != 0) { + int lowerLimit = 0;//司龄下限 + int upperLimit = 0;//司龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_EntryToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 3 && ruleDetailId != 0) { + int lowerLimit = 0;//工龄下限 + int upperLimit = 0;//工龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 6 && ruleDetailId != 0) { + String mixModeData = Util.null2String(params.get("legalRule")); + JSONArray jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double legalAmount = jsonObject.getDoubleValue("legalAmount"); + + sql = "insert into kq_MixModeToLegalLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, legalAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + + mixModeData = Util.null2String(params.get("welfareRule")); + jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double welfareAmount = jsonObject.getDoubleValue("welfareAmount"); + + sql = "insert into kq_MixModeToWelfareLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, welfareAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 8 && ruleDetailId != 0) { + int provinceidValue = 0;//省份id + int yearsOldValue = 0;//孩子周岁 + double amountValue = 0;//假期天数 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + provinceidValue = jsonObject.getIntValue("provinceid"); + yearsOldValue = jsonObject.getIntValue("yearsOld"); + amountValue = jsonObject.getDoubleValue("amount"); + + sql = "insert into kq_provinceToLeave(leaveRulesId,provinceid,yearsOld,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, provinceidValue, yearsOldValue, amountValue); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } + } catch (Exception e) { + writeLog(e); + } finally { + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + detailComInfo.removeCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/EditLeaveRulesCmd.java b/src/com/engine/kq/cmd/leaverules/EditLeaveRulesCmd.java new file mode 100644 index 0000000..0de627d --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/EditLeaveRulesCmd.java @@ -0,0 +1,489 @@ +package com.engine.kq.cmd.leaverules; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.SimpleBizLogger; +import com.engine.common.constant.BizLogSmallType4Hrm; +import com.engine.common.constant.BizLogType; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesDetailComInfo; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 假期规则--编辑 + */ +public class EditLeaveRulesCmd extends AbstractCommonCommand> { + + private SimpleBizLogger logger; + + public EditLeaveRulesCmd(Map params, User user) { + this.user = user; + this.params = params; + this.logger = new SimpleBizLogger(); + + int ruleDetailId = Util.getIntValue((String) params.get("ruleId")); + BizLogContext bizLogContext = new BizLogContext(); + bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型 + bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//所属大类型 + bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//当前小类型 + bizLogContext.setParams(params);//当前request请求参数 + logger.setUser(user);//当前操作人 + String mainSql = "select * from kq_LeaveRulesDetail where id=" + ruleDetailId; + logger.setMainSql(mainSql, "id");//主表sql + logger.setMainPrimarykey("id");//主日志表唯一key + logger.setMainTargetNameColumn("rulename"); + + SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo(); + String subSql1 = "select * from kq_EntryToLeave where leaveRulesId=" + ruleDetailId; + subLogInfo1.setSubSql(subSql1, "id"); + logger.addSubLogInfo(subLogInfo1); + + SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo(); + String subSql2 = "select * from kq_WorkingAgeToLeave where leaveRulesId=" + ruleDetailId; + subLogInfo2.setSubSql(subSql2, "id"); + logger.addSubLogInfo(subLogInfo2); + + SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo(); + String subSql3 = "select * from kq_MixModeToLegalLeave where leaveRulesId=" + ruleDetailId; + subLogInfo3.setSubSql(subSql3, "id"); + logger.addSubLogInfo(subLogInfo3); + + SimpleBizLogger.SubLogInfo subLogInfo4 = logger.getNewSubLogInfo(); + String subSql4 = "select * from kq_MixModeToLegalLeave where leaveRulesId=" + ruleDetailId; + subLogInfo4.setSubSql(subSql4, "id"); + logger.addSubLogInfo(subLogInfo4); + + logger.before(bizLogContext); + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public List getLogContexts() { + return logger.getBizLogContexts(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /*假期类型的ID*/ + int ruleId = Util.getIntValue((String) params.get("typeId")); + + /*假期规则详情的ID*/ + int ruleDetailId = Util.getIntValue((String) params.get("ruleId")); + + /*假期规则名称*/ + String ruleName = Util.null2String(params.get("ruleName")); + + /*应用范围:0-总部、1-分部*/ + int scopeType = Util.getIntValue((String) params.get("scopeType")); + + /*应用范围为分部时,选择的分部ID*/ + String scopeValue = Util.null2String(params.get("scopeValue")); + String deductorder = Util.null2String(params.get("deductorder")); + + /*应用范围为部门时,选择的部门ID*/ + String scopeValueDepartment = Util.null2String(params.get("scopeValueDepartment")); + + /*应用范围为人员时,选择的人员ID*/ + String scopeValueMember = Util.null2String(params.get("scopeValueMember")); + + if(scopeType == 2) { + scopeValue = scopeValueDepartment; + } else if(scopeType == 3) { + scopeValue = scopeValueMember; + } + + /*余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、 5-加班时长自动计入余额*/ + int distributionMode = Util.getIntValue((String) params.get("distributionMode"), 1); + + /*每人发放小时(天)数(当余额发放方式为每年自动发放固定天数时有效)*/ + double annualAmount = Util.getDoubleValue((String) params.get("annualAmount"), 0); + + /*扣减优先级:1-法定年假、2-福利年假*/ + int priority = Util.getIntValue((String) params.get("priority"), 1); + + //法定年假规则:0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String legalKey = Util.null2s((String) params.get("legalKey"), "0"); + + //福利年假规则:0-工龄、1-工龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String welfareKey = Util.null2s((String) params.get("welfareKey"), "1"); + + /*有效期规则:0-不限制、1-按自然月(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4-自定义有效天数*/ + int validityRule = Util.getIntValue((String) params.get("validityRule"), 1); + + /*有效期天数:(当有效期天数选择按天数失效的时候有效)*/ + int effectiveDays = Util.getIntValue((String) params.get("effectiveDays"), 30); + + //有效月数(当有效期规则选择自定义有效月数时) + int effectiveMonths = Util.getIntValue((String) params.get("effectiveMonths"), 1); + + /*失效日期--月(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationMonth = Util.null2String(params.get("expirationMonth")); + + /*失效日期--日(当有效期规则选择3-自定义次年失效日期时有效)*/ + String expirationDay = Util.null2String(params.get("expirationDay")); + + /*允许延长有效期:0-不允许、1-允许*/ + int extensionEnable = Util.getIntValue((String) params.get("extensionEnable"), 0); + + /*允许超过有效期天数*/ + int extendedDays = Util.getIntValue((String) params.get("extendedDays"), 0); + + /*释放规则:0-不限制、1-按天释放、2-按月释放*/ + int releaseRule = Util.getIntValue((String) params.get("releaseRule"), 0); + + /*假期基数计算方式:0-精确计算、1-按最少的假期余额计算、2-按最多的假期余额计算*/ + int calcMethod = Util.getIntValue((String) params.get("calcMethod"), 0); + + /*是否折算:0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、5-向下取0.5的倍数*/ + int convertMode = Util.getIntValue("" + params.get("convertMode"), 1); + + /*次账号是否发放假期余额:0-不发放、1-发放*/ + int excludeSubAccount = Util.getIntValue("" + params.get("excludeSubAccount"), 1); + + /*转正之前是否发放假期余额:0-不发放、1-发放*/ + int beforeFormal = Util.getIntValue("" + params.get("beforeFormal"), 1); + + //多孩叠加开关。 + int severalChildren = Util.getIntValue("" + params.get("severalChildren"), 0); + + //孩子多少周岁前发放。 + int yearsOld = Util.getIntValue("" + params.get("yearsOld"), 3); + + //是否按照省份发放育儿假。 + int isprovince = Util.getIntValue("" + params.get("isprovince"), 1); +// 2、在假期规则页面,增加开关控制是否开启。carryOver +// 3、增加输入框控制结转天数。 carryOverDays + + int carryOver = Util.getIntValue("" + params.get("carryOver"), 0); + double carryOverDays = Util.getDoubleValue((String) params.get("carryOverDays"), 0); + if (scopeType == 1 && scopeValue.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + if (distributionMode == 5) { + releaseRule = 0; + Map data = KQLeaveRulesBiz.isRepeat(Util.null2String(ruleId),scopeType,scopeValue,user,Util.null2String(ruleDetailId)); + if(null != data && "1".equals(data.get("flag"))){ + resultMap.put("status", "-1"); + resultMap.put("message", data.get("msg"));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 + return resultMap; + } + /*两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式*/ +// String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id<>? and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)"; +// RecordSet recordSet = new RecordSet(); +// recordSet.executeQuery(sql, ruleId); +// if (recordSet.next()) { +// resultMap.put("status", "-1"); +// resultMap.put("message", SystemEnv.getHtmlLabelName(505664, user.getLanguage()));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式 +// return resultMap; +// } + if(null != deductorder && deductorder.length()>0){ + String[] orders = deductorder.split(","); + if(null != orders && orders.length != 3){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(547752, user.getLanguage())); + return resultMap; + } + } + } else if (distributionMode == 6) { + /*同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505665, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + }else if (distributionMode == 8) { + /*同一假期类型下 育儿假 不能与其他余额发放方式共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>8"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8 and id<>?"; + recordSet.executeQuery(sql, ruleId,ruleDetailId); + if (recordSet.next()) { + int severalChildrenValue = Util.getIntValue(Util.null2s(recordSet.getString("severalChildren"), "0"), 0); + if(severalChildrenValue!=severalChildren){ + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546859, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存 + return resultMap; + } + } + } else { + /*同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存*/ + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=6"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505666, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存 + return resultMap; + } + + //同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=5"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(510357, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存 + return resultMap; + } + //同一个假期类型下其他余额发放方式不能与 育儿假叠加 共存 + sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=8"; + recordSet.executeQuery(sql, ruleId); + if (recordSet.next()) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(546858, user.getLanguage())); + return resultMap; + } + } + + String searchSql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and id<>?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(searchSql, ruleId, ruleDetailId); + while (recordSet.next()) { + int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValueTemp = recordSet.getString("scopeValue"); + + if (scopeType == 0 && scopeTypeTemp == 0) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505667, user.getLanguage()));//该假期类型下已经新建过总部的假期规则,请勿重复新建 + return resultMap; + } + if (scopeType == 1 && scopeTypeTemp == 1) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + String subcomName = subCompanyComInfo.getSubCompanyname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(505668, user.getLanguage()).replace("$", subcomName));//该假期类型下已经新建过分部的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 2 && scopeTypeTemp == 2) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + DepartmentComInfo comInfo = new DepartmentComInfo(); + String name = comInfo.getDepartmentname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534890, user.getLanguage()).replace("$", name));//该假期类型下已经新建过部门的假期规则,请勿重复新建 + return resultMap; + } + } + if (scopeType == 3 && scopeTypeTemp == 3) { + List scopeValueTempList = Util.TokenizerString(scopeValueTemp, ","); + List scopeValueList = Util.TokenizerString(scopeValue, ","); + for (String temp : scopeValueList) + if (scopeValueTempList.contains(temp)) { + ResourceComInfo comInfo = new ResourceComInfo(); + String name = comInfo.getLastname(temp); + + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(534891, user.getLanguage()).replace("$", name));//该假期类型下已经新建过人员的假期规则,请勿重复新建 + return resultMap; + } + } + } + boolean flag = false;//数据是否更新成功 + String sql = "update kq_LeaveRulesDetail set ruleId=?,ruleName=?,scopeType=?,scopeValue=?," + + "distributionMode=?,annualAmount=?,legalKey=?,welfareKey=?,priority=?,validityRule=?,effectiveDays=?,effectiveMonths=?,expirationMonth=?,expirationDay=?,extensionEnable=?,extendedDays=?,releaseRule=?,calcMethod=?,convertMode=?,excludeSubAccount=?,beforeFormal=?,severalChildren=?,yearsOld=?,isprovince=? ,carryOver=?,carryOverDays=?,deductorder=? where id=?"; + flag = recordSet.executeUpdate(sql, ruleId, ruleName, scopeType, scopeValue, + distributionMode, annualAmount, legalKey, welfareKey, priority, validityRule, effectiveDays, effectiveMonths, expirationMonth, expirationDay, extensionEnable, extendedDays, releaseRule, calcMethod, convertMode, excludeSubAccount, beforeFormal,severalChildren,yearsOld,isprovince,carryOver,carryOverDays,deductorder,ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + if ((distributionMode == 2 || distributionMode == 7) && ruleDetailId != 0) { + sql = "delete from kq_EntryToLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + int lowerLimit = 0;//司龄下限 + int upperLimit = 0;//司龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_EntryToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 3 && ruleDetailId != 0) { + sql = "delete from kq_WorkingAgeToLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + int lowerLimit = 0;//工龄下限 + int upperLimit = 0;//工龄上限 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int timePoint = jsonObject.getIntValue("timePoint"); + double amount = jsonObject.getDoubleValue("amount"); + + lowerLimit = i == 0 ? 0 : timePoint; + upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint"); + + sql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + + if (distributionMode == 6 && ruleDetailId != 0) { + sql = "delete from kq_MixModeToLegalLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + + sql = "delete from kq_MixModeToWelfareLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + String mixModeData = Util.null2String(params.get("legalRule")); + JSONArray jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double legalAmount = jsonObject.getDoubleValue("legalAmount"); + + sql = "insert into kq_MixModeToLegalLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, legalAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + + mixModeData = Util.null2String(params.get("welfareRule")); + jsonArray = JSONArray.parseArray(mixModeData); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + int workYear = jsonObject.getIntValue("workYear"); + int entryTime = jsonObject.getIntValue("entryTime"); + double welfareAmount = jsonObject.getDoubleValue("welfareAmount"); + + sql = "insert into kq_MixModeToWelfareLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, welfareAmount); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + if (distributionMode == 8 && ruleDetailId != 0) { + sql = "delete from kq_provinceToLeave where leaveRulesId=?"; + flag = recordSet.executeUpdate(sql, ruleDetailId); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + int provinceidValue = 0;//省份id + int yearsOldValue = 0;//孩子周岁 + double amountValue = 0;//假期天数 + String data = Util.null2String(params.get("detailRule")); + JSONArray jsonArray = JSONArray.parseArray(data); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + provinceidValue = jsonObject.getIntValue("provinceid"); + yearsOldValue = jsonObject.getIntValue("yearsOld"); + amountValue = jsonObject.getDoubleValue("amount"); + + sql = "insert into kq_provinceToLeave(leaveRulesId,provinceid,yearsOld,amount) values(?,?,?,?)"; + flag = recordSet.executeUpdate(sql, ruleDetailId, provinceidValue, yearsOldValue, amountValue); + if (!flag) { + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + return resultMap; + } + } + } + if (flag) { + resultMap.put("sign", "1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功 + } + } catch (Exception e) { + writeLog(e); + resultMap.put("sign", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败 + } finally { + KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo(); + detailComInfo.removeCache(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/leaverules/GetLeaveRulesFormCmd.java b/src/com/engine/kq/cmd/leaverules/GetLeaveRulesFormCmd.java new file mode 100644 index 0000000..72f325d --- /dev/null +++ b/src/com/engine/kq/cmd/leaverules/GetLeaveRulesFormCmd.java @@ -0,0 +1,1088 @@ +package com.engine.kq.cmd.leaverules; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SearchConditionOption; +import com.api.hrm.bean.HrmFieldBean; +import com.api.hrm.util.HrmFieldSearchConditionComInfo; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.conn.RecordSet; +import weaver.filter.XssUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.province.ProvinceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +/** + * 假期规则--获取新建编辑的表单 + */ +public class GetLeaveRulesFormCmd extends AbstractCommonCommand> { + + public GetLeaveRulesFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + if (!canEdit) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return resultMap; + } + /**假期类型的相关信息:*/ + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + + /*新建假期规则时选择完请假类型后会再次请求此表单接口*/ + /*规则对应的假期类型的ID*/ + String ruleId = Util.null2String(params.get("typeId")); + + /*是否启用:0-未启用、1-启用*/ + int isEnable = 1; + + /*最小请假单位:1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/ + int minimumUnit = 1; + + /******************************************************************************/ + + /**假期规则详情的相关信息:*/ + + /*是否是编辑*/ + boolean isEdit = false; + + /*假期规则详情的ID*/ + String ruleDetailId = Util.null2String(params.get("ruleId")); + + /*假期规则名称*/ + String ruleName = ""; + + /*应用范围:0-总部、1-分部*/ + int scopeType = 0; + + /*应用范围为分部时,选择的分部ID*/ + String scopeValue = ""; + + /*余额发放方式:1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按工龄+司龄自动发放*/ + int distributionMode = 1; + + //年假基数计算方式: + // 0(精确计算)-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、 + // 1(按最少的余额计算)-假期基数发放日期和假期基数变动日期均为每年的01月01号、 + // 2(按最多的余额计算)-假期基数发放日期发放日期为每年的01月01号,假期基数的变动日期为每年的 入职日期/参加工作日期 + int calcMethod = 1; + + //是否折算:0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、向下取0.5的倍数 + int convertMode = 1; + + //折算后的小数点位数 + int decimalDigit = 2; + + /*每人发放小时(天)数(当余额发放方式为是每年发放固定天数时有效)*/ + double annualAmount = 0; + + //法定年假规则:0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String legalKey = "0"; + + //福利年假规则:0-工龄、1司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效) + String welfareKey = "1"; + + /*扣减优先级:1-法定年假、2-福利年假(当余额发放方式为按工龄+司龄自动发放时有效)*/ + int priority = 1; + + //有效期规则:0-永久有效、1-按自然年(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4、按天数失效、5-按季度失效、6-按月数失效 + int validityRule = 0; + + /*失效日期--月(当有效期规则选择自定义次年失效日期时有效)*/ + String expirationMonth = "1"; + + /*失效日期--日(当有效期规则选择自定义次年失效日期时有效)*/ + String expirationDay = "1"; + + //有效天数(当有效期规则选择自定义有效天数时) + String effectiveDays = "30"; + + //有效月数(当有效期规则选择自定义有效月数时) + String effectiveMonths = "1"; + + /*允许延长有效期:0-不允许、1-允许*/ + int extensionEnable = 0; + + /*允许超过有效期天数*/ + int extendedDays = 90; + + /*释放规则:0-不限制、1-按天释放、2-按月释放*/ + int releaseRule = 0; + + //是否需要排除次账号:0--不排除,即次账号正常享受年假、1--排除,即次账号不能享受年假 + int excludeSubAccount = 1; + + //转正之前是否允许发放假期余额:0-不允许、1-允许 + int beforeFormal = 1; + + //多孩叠加开关。 + int severalChildren = 0; + + //孩子多少周岁前发放。 + int yearsOld = 3; + + //是否按照省份发放育儿假。1否,2是 + String isprovince = "1"; + +// 2、在假期规则页面,增加开关控制是否开启。carryOver +// 3、增加输入框控制结转天数。 carryOverDays + + int carryOver =0; + double carryOverDays = 0; + + String deductorder =""; + + /*入职时长--年假*/ + Map entryMap = new HashMap(); + List entryList = new ArrayList(); + + /*工龄--年假*/ + Map workingAgeMap = new HashMap(); + List workingAgeList = new ArrayList(); + + /*入职时长+工龄混合--年假*/ + Map mixedModeMap = new HashMap(); + List mixedModeList = new ArrayList(); + + if (!ruleDetailId.equals("")) { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete != 1) and id=" + ruleDetailId; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql); + if (recordSet.next()) { + isEdit = true; + + ruleName = recordSet.getString("ruleName"); + ruleId = recordSet.getString("ruleId"); + scopeType = recordSet.getInt("scopeType"); + scopeValue = recordSet.getString("scopeValue"); + deductorder = recordSet.getString("deductorder"); + distributionMode = Util.getIntValue(recordSet.getString("distributionMode"), 1); + annualAmount = Util.getDoubleValue(recordSet.getString("annualAmount"), 0); + legalKey = "" + Util.getIntValue(recordSet.getString("legalKey"), 0); + welfareKey = "" + Util.getIntValue(recordSet.getString("welfareKey"), 1); + priority = Util.getIntValue(recordSet.getString("priority"), 1); + validityRule = Util.getIntValue(recordSet.getString("validityRule"), 0); + effectiveDays = Util.null2s(recordSet.getString("effectiveDays"), "30"); + effectiveMonths = Util.null2s(recordSet.getString("effectiveMonths"),"1"); + expirationMonth = Util.null2s(recordSet.getString("expirationMonth"), "1"); + expirationDay = Util.null2s(recordSet.getString("expirationDay"), "1"); + extensionEnable = Util.getIntValue(recordSet.getString("extensionEnable"), 0); + extendedDays = Util.getIntValue(recordSet.getString("extendedDays"), 90); + releaseRule = Util.getIntValue(recordSet.getString("releaseRule"), 0); + calcMethod = Util.getIntValue(recordSet.getString("calcMethod"), 1); + convertMode = Util.getIntValue(recordSet.getString("convertMode"), 1); + excludeSubAccount = Util.getIntValue(recordSet.getString("excludeSubAccount"), 1); + beforeFormal = Util.getIntValue(recordSet.getString("beforeFormal"), 1); + severalChildren = Util.getIntValue(recordSet.getString("severalChildren"), 0); + yearsOld = Util.getIntValue(recordSet.getString("yearsOld"), 3); + isprovince = Util.null2s(recordSet.getString("isprovince"), "1"); + carryOver = Util.getIntValue(recordSet.getString("carryOver"), 0); + carryOverDays = Util.getDoubleValue(recordSet.getString("carryOverDays"), 0); + } + + if (distributionMode == 2 || distributionMode == 7) { + sql = "select * from kq_EntryToLeave where leaveRulesId = ? order by lowerLimit,upperLimit"; + recordSet.executeQuery(sql, ruleDetailId); + int lowerLimit = 0;//入职年限下限 + int upperLimit = 0;//入职年限上限 + double amount = 0;//假期天数 + while (recordSet.next()) { + lowerLimit = recordSet.getInt("lowerLimit"); + upperLimit = recordSet.getInt("upperLimit"); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + entryMap = new HashMap(); + entryMap.put("timePoint", lowerLimit); + entryMap.put("amount", String.format("%.2f", amount)); + entryList.add(entryMap); + } + resultMap.put("detailRule", entryList); + } + + if (distributionMode == 3) { + sql = "select * from kq_WorkingAgeToLeave where leaveRulesId = ? order by lowerLimit,upperLimit"; + recordSet.executeQuery(sql, ruleDetailId); + int lowerLimit = 0;//工龄下限 + int upperLimit = 0;//工龄上限 + double amount = 0;//假期天数 + while (recordSet.next()) { + lowerLimit = recordSet.getInt("lowerLimit"); + upperLimit = recordSet.getInt("upperLimit"); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + workingAgeMap = new HashMap(); + workingAgeMap.put("timePoint", lowerLimit); + workingAgeMap.put("amount", String.format("%.2f", amount)); + workingAgeList.add(workingAgeMap); + } + resultMap.put("detailRule", workingAgeList); + } + + if (distributionMode == 6) { + sql = "select * from kq_MixModeToLegalLeave where leaveRulesId=? order by id "; + recordSet.executeQuery(sql, ruleDetailId); + double limit1 = 0;//工龄下限 + double limit2 = 0;//司龄下限 + double amount = 0;//法定年假天数or福利年假天数 + while (recordSet.next()) { + limit1 = Util.getDoubleValue(recordSet.getString("limit1"), 0); + limit2 = Util.getDoubleValue(recordSet.getString("limit2"), 0); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + mixedModeMap = new HashMap(); + if (legalKey.equals("0") || legalKey.equals("2")) { + mixedModeMap.put("workYear", limit1); + } + if (legalKey.equals("1") || legalKey.equals("2")) { + mixedModeMap.put("entryTime", limit2); + } + mixedModeMap.put("legalAmount", String.format("%.2f", amount)); + mixedModeList.add(mixedModeMap); + } + resultMap.put("legalRule", mixedModeList); + resultMap.put("legalKey", legalKey); + + mixedModeList = new ArrayList(); + sql = "select * from kq_MixModeToWelfareLeave where leaveRulesId=? order by id "; + recordSet.executeQuery(sql, ruleDetailId); + while (recordSet.next()) { + limit1 = Util.getDoubleValue(recordSet.getString("limit1"), 0); + limit2 = Util.getDoubleValue(recordSet.getString("limit2"), 0); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + + mixedModeMap = new HashMap(); + if (welfareKey.equals("0") || welfareKey.equals("2")) { + mixedModeMap.put("workYear", limit1); + } + if (welfareKey.equals("1") || welfareKey.equals("2")) { + mixedModeMap.put("entryTime", limit2); + } + mixedModeMap.put("welfareAmount", String.format("%.2f", amount)); + mixedModeList.add(mixedModeMap); + } + resultMap.put("welfareRule", mixedModeList); + resultMap.put("welfareKey", welfareKey); + } + if (distributionMode == 8) { + sql = "select * from kq_provinceToLeave where leaveRulesId = ? order by id "; + recordSet.executeQuery(sql, ruleDetailId); + int provinceid = 0;//省份id + int yearsOldValue = 0;//孩子周岁 + int id = 0;//id + double amount = 0;//假期天数 + String provincename = ""; + ProvinceComInfo coun = new ProvinceComInfo(); + while (recordSet.next()) { + id = recordSet.getInt("id"); + provinceid = recordSet.getInt("provinceid"); + yearsOldValue = recordSet.getInt("yearsOld"); + amount = Util.getDoubleValue(recordSet.getString("amount"), 0); + provincename = coun.getProvincename(provinceid + ""); + workingAgeMap = new HashMap(); + workingAgeMap.put("id", id); + workingAgeMap.put("provinceid", provinceid); + workingAgeMap.put("provincename", provincename); + workingAgeMap.put("yearsOld", yearsOldValue); + workingAgeMap.put("amount", String.format("%.2f", amount)); + workingAgeList.add(workingAgeMap); + } + resultMap.put("detailRule", workingAgeList); + } + } + + if (isEdit) { + isEnable = Util.getIntValue(rulesComInfo.getIsEnable(ruleId), 1); + } + + List> groupList = new ArrayList>(); + Map groupItem = new HashMap(); + List itemList = new ArrayList(); + HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo(); + SearchConditionItem searchConditionItem = null; + HrmFieldBean hrmFieldBean = null; + + /****************************************************基本信息****************************************************/ + + groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("typeId");//假期类型 + hrmFieldBean.setFieldlabel("129811"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(ruleId); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 || isEdit ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList = new ArrayList(); + if (!isEdit) { + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (!rulesComInfo.getIsEnable().equals("1") || !rulesComInfo.getBalanceEnable().equals("1")) { + continue; + } + optionsList.add(new SearchConditionOption(rulesComInfo.getId(), Util.formatMultiLang(rulesComInfo.getLeaveName(), "" + user.getLanguage()), ruleId.equals(rulesComInfo.getId()))); + } + } else { + optionsList.add(new SearchConditionOption(ruleId, Util.formatMultiLang(rulesComInfo.getLeaveName(ruleId), "" + user.getLanguage()), true)); + } + searchConditionItem.setOptions(optionsList); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(505298, user.getLanguage()));//只能选择启用状态下开启了假期余额的假期类型,并且编辑假期规则时不能变更假期类型 + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("ruleName");//规则名称 + hrmFieldBean.setFieldlabel("19829"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(ruleName); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + /*应用范围是否能够选择总部,如果已经新建过总部的假期规则,则无法新建总部的假期规则*/ + boolean canSelectCom = true; + /*已经新建过某分部的假期规则,则无法继续新建该分部的假期规则*/ + String selectedSubcomIds = "", selectedDepartmentIds = "", selectedMemberIds = ""; + /*新建假期规则的时候选择完假期类型后重亲请求了此接口*/ + if (!ruleId.equals("") && !isEdit) { + String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeQuery(sql, ruleId); + while (recordSet.next()) { + int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0); + String scopeValueTemp = recordSet.getString("scopeValue"); + + if (scopeTypeTemp == 0) { + canSelectCom = false; + } else if (scopeTypeTemp == 1) { + selectedSubcomIds += "," + scopeValueTemp; + } else if (scopeTypeTemp == 2) { + selectedDepartmentIds += "," + scopeValueTemp; + } else if (scopeTypeTemp == 3) { + selectedMemberIds += "," + scopeValueTemp; + } + } + } + selectedSubcomIds = selectedSubcomIds.length() > 0 ? selectedSubcomIds.substring(1) : ""; + selectedDepartmentIds = selectedDepartmentIds.length() > 0 ? selectedDepartmentIds.substring(1) : ""; + selectedMemberIds = selectedMemberIds.length() > 0 ? selectedMemberIds.substring(1) : ""; + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeType");//此规则适用范围 + hrmFieldBean.setFieldlabel("19374"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 || !canSelectCom ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(140, user.getLanguage()), scopeType == 0 || !canSelectCom)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(33553, user.getLanguage()), scopeType == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(124, user.getLanguage()), scopeType == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(1867, user.getLanguage()), scopeType == 3)); + searchConditionItem.setOptions(optionsList); + //对于一个请假类型,各分部能够且仅能够设置一个属于本分部的假期规则,如果未设置本分部的假期规则,默认取总部的假期规则,如果总部也未设置,则假期基数视作0.00 + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(534889, user.getLanguage())); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValue");//分部 + hrmFieldBean.setFieldlabel("33553"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("170"); + hrmFieldBean.setFieldvalue(scopeType == 1 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "KQLeaveRulesAdd:Add"); + if (selectedSubcomIds.length() > 0) { + XssUtil xssUtil = new XssUtil(); + String sqlWhere = " id not in (" + selectedSubcomIds + ") "; + searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getDestDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + } + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValueDepartment");//部门 + hrmFieldBean.setFieldlabel("124"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("168"); + hrmFieldBean.setFieldvalue(scopeType == 2 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + if (selectedDepartmentIds.length() > 0) { + XssUtil xssUtil = new XssUtil(); + String sqlWhere = " id not in (" + selectedDepartmentIds + ") "; + searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getDestDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + } + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("scopeValueMember");//人员 + hrmFieldBean.setFieldlabel("1867"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("166"); + hrmFieldBean.setFieldvalue(scopeType == 3 ? scopeValue : ""); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add"); + if (selectedMemberIds.length() > 0) { + XssUtil xssUtil = new XssUtil(); + String sqlWhere = " id not in (" + selectedMemberIds + ") "; + searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlWhere", xssUtil.put(sqlWhere)); + searchConditionItem.getBrowserConditionParam().getDestDataParams().put("sqlWhere", xssUtil.put(sqlWhere)); + } + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + + + // todo 美之高二开新加人员安全级别 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("personLeavel"); + hrmFieldBean.setFieldlabel("-114855"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + + hrmFieldBean.setFieldvalue("2"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List optionsList1 = new ArrayList<>(); + + // 建模表构建人员级别下拉框 + optionsList1.add(new SearchConditionOption("1", "集团领导", true)); + optionsList1.add(new SearchConditionOption("2","高管级", true)); + optionsList1.add(new SearchConditionOption("3", "职员级", true)); + + searchConditionItem.setOptions(optionsList1); + searchConditionItem.setRules("required|string"); + itemList.add(searchConditionItem); + + /****************************************************发放规则****************************************************/ + + groupItem = new HashMap(); + itemList = new ArrayList(); + groupItem.put("title", SystemEnv.getHtmlLabelName(508539, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("distributionMode");//余额发放方式 + hrmFieldBean.setFieldlabel("388946"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr((isEnable == 0 || (isEdit && distributionMode == 6)) ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388947, user.getLanguage()), distributionMode == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(390374, user.getLanguage()), distributionMode == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(388949, user.getLanguage()), distributionMode == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(390323, user.getLanguage()), distributionMode == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(388951, user.getLanguage()), distributionMode == 5)); + SearchConditionOption searchConditionOption = new SearchConditionOption("6", SystemEnv.getHtmlLabelName(390822, user.getLanguage()), distributionMode == 6); + searchConditionOption.setDisabled((isEdit && distributionMode != 6) ? true : false); + optionsList.add(searchConditionOption); + optionsList.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(514025, user.getLanguage()), distributionMode == 7)); + optionsList.add(new SearchConditionOption("8", SystemEnv.getHtmlLabelName(536880, user.getLanguage()), distributionMode == 8)); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setHelpfulTip("★" + SystemEnv.getHtmlLabelName(10000815,user.getLanguage()) + "★" + SystemEnv.getHtmlLabelName(501107, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + List distributionModeTips = new ArrayList(); + distributionModeTips.add(SystemEnv.getHtmlLabelName(389735, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(500952, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(500953, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511046, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(389736, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(389737, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(500954, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511046, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(514026, user.getLanguage()) + " " + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + ""); + distributionModeTips.add(SystemEnv.getHtmlLabelName(536881, user.getLanguage())); + resultMap.put("distributionMode", distributionModeTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("calcMethod");//假期基数计算方式 + hrmFieldBean.setFieldlabel("501121"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(505302, user.getLanguage()), calcMethod == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(505303, user.getLanguage()), calcMethod == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(505304, user.getLanguage()), calcMethod == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + List calcMethodTips = new ArrayList(); + //以入职日期(或参加工作日期)为分隔点将一年划分为上半年和下半年,全年可用假期天数=上半年天数/全年总天数*上半年司龄(或工龄)对应的假期天数+下半年天数/全年总天数*下半年司龄(或工龄)对应的假期天数。每年1月1日自动发放假期天数。 + calcMethodTips.add(SystemEnv.getHtmlLabelName(505305, user.getLanguage())); + //每年1月1日计算员工的司龄(或工龄),取对应的假期天数,于1月1日自动发放。 + calcMethodTips.add(SystemEnv.getHtmlLabelName(505306, user.getLanguage())); + //每年1月1日计算员工的司龄(或工龄),取对应的假期天数,于1月1日自动发放。若一年中员工司龄(或工龄)增加后,对应的假期天数也随之增加,则自动补发增加的假期天数。 + calcMethodTips.add(SystemEnv.getHtmlLabelName(505307, user.getLanguage())); + resultMap.put("calcMethod", calcMethodTips); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("priority");//扣减优先级 + hrmFieldBean.setFieldlabel("2093"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(129819, user.getLanguage()), priority == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(132046, user.getLanguage()), priority == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("annualAmount");//每人发放小时数 + hrmFieldBean.setFieldlabel("503237"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(annualAmount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + searchConditionItem.setMin("0"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("carryOver"); + hrmFieldBean.setFieldlabel("546921"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(carryOver); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + Map otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(547604, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("carryOverDays"); + hrmFieldBean.setFieldlabel("546922"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(carryOverDays); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|numeric"); + searchConditionItem.setPrecision(2); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + //育儿假多孩叠加 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("severalChildren"); + hrmFieldBean.setFieldlabel("546788"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(severalChildren); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + //育儿假孩子多少周岁 + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("yearsOld"); + hrmFieldBean.setFieldlabel("546789"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(yearsOld); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + //育儿假是否按照省份发放 +// hrmFieldBean = new HrmFieldBean(); +// hrmFieldBean.setFieldname("isprovince"); +// hrmFieldBean.setFieldlabel("546790"); +// hrmFieldBean.setFieldhtmltype("4"); +// hrmFieldBean.setType("1"); +// hrmFieldBean.setFieldvalue(isprovince); +// hrmFieldBean.setIsFormField(true); +// hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); +// searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); +// otherParamsMap = new HashMap(); +// otherParamsMap.put("display", "switch"); +// searchConditionItem.setOtherParams(otherParamsMap); +// if (hrmFieldBean.getViewAttr() == 1) { +// Map OtherParamsMap = new HashMap(); +// OtherParamsMap.put("hasBorder", true); +// searchConditionItem.setOtherParams(OtherParamsMap); +// } +// itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("isprovince"); + hrmFieldBean.setFieldlabel("546825"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(isprovince); + List options = new ArrayList(); + options.add(new SearchConditionOption("1",SystemEnv.getHtmlLabelName(546827, user.getLanguage())+yearsOld+ + SystemEnv.getHtmlLabelName(546828, user.getLanguage())+annualAmount, + isprovince.equals("1"))); + options.add(new SearchConditionOption("2",SystemEnv.getHtmlLabelName(546790, user.getLanguage()),isprovince.equals("2"))); + hrmFieldBean.setSelectOption(options); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("convertMode");//是否折算 + hrmFieldBean.setFieldlabel("508419"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(508423, user.getLanguage()), convertMode == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389654, user.getLanguage()), convertMode == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(508424, user.getLanguage()), convertMode == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(508425, user.getLanguage()), convertMode == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(508426, user.getLanguage()), convertMode == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(508427, user.getLanguage()), convertMode == 5)); + searchConditionItem.setOptions(optionsList); + //当假期基数计算方式选择【精确计算】时,不能选择【不折算】 + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(510491, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + List convertModeTips = new ArrayList(); + //指不考虑是否是入职当年还是初始获得年(即年初01月01日的时候计算工龄或者司龄,得出对应的假期基数为0。但是当这一年的工龄或者司龄增加后,对应的假期基数就不再是0了,这样的年份称作初始获得年),通过工龄或司龄计算出对应的假期基数,不做任何扣减折算 + convertModeTips.add(SystemEnv.getHtmlLabelName(510131, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后四舍五入保留两位小数 + convertModeTips.add(SystemEnv.getHtmlLabelName(510132, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取整,例如:折算后的基数为3.21,取整后为4.0 + convertModeTips.add(SystemEnv.getHtmlLabelName(510133, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取整,例如:折算后的基数为3.21,取整后为3.0 + convertModeTips.add(SystemEnv.getHtmlLabelName(510134, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取0.5的倍数,例如:折算后的基数为3.21,最终为3.5 + convertModeTips.add(SystemEnv.getHtmlLabelName(510135, user.getLanguage())); + //通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后的数值取0.5的倍数,例如:折算后的基数为3.21,最终后为3.0 + convertModeTips.add(SystemEnv.getHtmlLabelName(510136, user.getLanguage())); + resultMap.put("convertModeTips", convertModeTips); + + groupItem.put("items", itemList); + groupList.add(groupItem); + + /****************************************************有效期****************************************************/ + + groupItem = new HashMap(); + itemList = new ArrayList(); + groupItem.put("title", SystemEnv.getHtmlLabelName(15030, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("validityRule");//有效期规则 + hrmFieldBean.setFieldlabel("388952"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(22135, user.getLanguage()), validityRule == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388953, user.getLanguage()), validityRule == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388954, user.getLanguage()), validityRule == 2)); + optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(389739, user.getLanguage()), validityRule == 3)); + optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(508428, user.getLanguage()), validityRule == 4)); + optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(513525, user.getLanguage()), validityRule == 5)); + optionsList.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(515135, user.getLanguage()), validityRule == 6)); + optionsList.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(536941, user.getLanguage()), validityRule == 7)); + searchConditionItem.setOptions(optionsList); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(515354, user.getLanguage())); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("effectiveDays");//有效月数 + hrmFieldBean.setFieldlabel("132356"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(effectiveDays); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("1"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("effectiveMonths");//有效月数 + hrmFieldBean.setFieldlabel("515174"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(effectiveMonths); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + searchConditionItem.setMin("1"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("expirationMonth");//失效日期--月 + hrmFieldBean.setFieldlabel("390103"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(expirationMonth); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + for (int i = 1; i <= 12; i++) { + if(user.getLanguage()==8){ + optionsList.add(new SearchConditionOption("" + i, i+"", Util.getIntValue(expirationMonth, 1) == i)); + }else { + optionsList.add(new SearchConditionOption("" + i, i + SystemEnv.getHtmlLabelName(383373, user.getLanguage()), Util.getIntValue(expirationMonth, 1) == i)); + } + } + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("expirationDay");//失效日期--日 + hrmFieldBean.setFieldlabel("390103"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(expirationDay); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + for (int i = 1; i <= 31; i++) { + if(user.getLanguage()==8){ + optionsList.add(new SearchConditionOption("" + i, i+"", Util.getIntValue(expirationMonth, 1) == i)); + }else { + optionsList.add(new SearchConditionOption("" + i, i + SystemEnv.getHtmlLabelName(390, user.getLanguage()), Util.getIntValue(expirationDay, 1) == i)); + } + } + searchConditionItem.setOptions(optionsList); + searchConditionItem.setRules("required|string"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("extensionEnable");//允许延长有效期 + hrmFieldBean.setFieldlabel("388955"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(extensionEnable); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("extendedDays");//允许延长的天数 + hrmFieldBean.setFieldlabel("389198"); + hrmFieldBean.setFieldhtmltype("1"); + hrmFieldBean.setType("2"); + hrmFieldBean.setFieldvalue(extendedDays); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + searchConditionItem.setRules("required|integer"); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + groupItem.put("items", itemList); + groupList.add(groupItem); + + /****************************************************其他设置****************************************************/ + + groupItem = new HashMap(); + itemList = new ArrayList(); + groupItem.put("title", SystemEnv.getHtmlLabelName(20824, user.getLanguage())); + groupItem.put("defaultshow", true); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("releaseRule");//释放规则 + hrmFieldBean.setFieldlabel("389093"); + hrmFieldBean.setFieldhtmltype("5"); + hrmFieldBean.setType("1"); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + optionsList = new ArrayList(); + optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(32499, user.getLanguage()), releaseRule == 0)); + optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(127263, user.getLanguage()), releaseRule == 1)); + optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(127262, user.getLanguage()), releaseRule == 2)); + searchConditionItem.setOptions(optionsList); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(510129, user.getLanguage())); + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("excludeSubAccount");//次账号发放假期余额 + hrmFieldBean.setFieldlabel("510174"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(excludeSubAccount); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("beforeFormal");//转正之前发放假期余额 + hrmFieldBean.setFieldlabel("510175"); + hrmFieldBean.setFieldhtmltype("4"); + hrmFieldBean.setType("1"); + hrmFieldBean.setFieldvalue(beforeFormal); + hrmFieldBean.setIsFormField(true); + hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + otherParamsMap = new HashMap(); + otherParamsMap.put("display", "switch"); + searchConditionItem.setOtherParams(otherParamsMap); + if (hrmFieldBean.getViewAttr() == 1) { + Map OtherParamsMap = new HashMap(); + OtherParamsMap.put("hasBorder", true); + searchConditionItem.setOtherParams(OtherParamsMap); + } + itemList.add(searchConditionItem); + + + /** + *调休扣减顺序 + */ + hrmFieldBean = new HrmFieldBean(); + hrmFieldBean.setFieldname("deductorder"); + hrmFieldBean.setFieldlabel("547670"); + hrmFieldBean.setFieldhtmltype("3"); + hrmFieldBean.setType("391"); + hrmFieldBean.setFieldvalue(deductorder); + hrmFieldBean.setIsFormField(true); + searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user); + List> replaceDatas = new ArrayList>(); + Map datas = new HashMap(); + if(null != deductorder){ + String[] leaveidArr = deductorder.split(","); +// Collections.sort(leaveidArr, Comparator.comparingInt(Util::getIntValue)); + if(null != leaveidArr && leaveidArr.length>0){ + for (int i = 0; i < leaveidArr.length; i++) { + String leaveid = leaveidArr[i]; + datas = new HashMap(); + datas.put("id", leaveid); + datas.put("name", "1".equals(leaveid)?"节假日":("2".equals(leaveid)?"工作日":"休息日")); + replaceDatas.add(datas); + } + } + } + searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas); + Map dataMap = new HashMap(); + Map completeMap = new HashMap(); + XssUtil xssUtil = new XssUtil(); + dataMap.put("sqlWhere", xssUtil.put(" id not in (" + deductorder + ")")); + completeMap.put("sqlWhere", xssUtil.put(" id not in (" + deductorder+ ")") ); + searchConditionItem.getBrowserConditionParam().setDataParams(dataMap); + searchConditionItem.getBrowserConditionParam().setCompleteParams(completeMap); + searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(547671, user.getLanguage())); + itemList.add(searchConditionItem); + + + + groupItem.put("items", itemList); + groupList.add(groupItem); + resultMap.put("condition", groupList); + resultMap.put("isEnable", "" + isEnable); + if (isEdit) { + minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId), 1); + + String unitName = "";//单位名称,天/小时 + if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) { + unitName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());//天 + } else { + unitName = SystemEnv.getHtmlLabelName(391, user.getLanguage());//小时 + } + resultMap.put("unitName", unitName); + } + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/entity/KQBalanceOfLeaveEntity.java b/src/com/engine/kq/entity/KQBalanceOfLeaveEntity.java new file mode 100644 index 0000000..3d6144d --- /dev/null +++ b/src/com/engine/kq/entity/KQBalanceOfLeaveEntity.java @@ -0,0 +1,234 @@ +package com.engine.kq.entity; + +/** + * 假期余额 + */ +public class KQBalanceOfLeaveEntity { + /** + * 主键ID + */ + int id; + /** + * 假期规则ID + */ + int leaveRulesId; + /** + * 人员ID + */ + int resourceId; + /** + * 所属年份 + * 数据格式:yyyy + */ + String belongYear; + /** + * 假期余额基数 + * 混合模式下为法定年假的基数 + */ + double baseAmount = 0.00; + /** + * 已用的假期余额 + * 混合模式下为已用的法定年假的数量 + */ + double usedAmount = 0.00; + /** + * 额外的假期余额 + * 混合模式下为额外的法定年假的数量 + */ + double extraAmount = 0.00; + /** + * 仅用于混合模式下的福利年假的基数 + */ + double baseAmount2 = 0.00; + /** + * 仅用于混合模式下的已用的福利年假的数量 + */ + double usedAmount2 = 0.00; + /** + * 仅用于混合模式下的额外的福利年假的数量 + */ + double extraAmount2 = 0.00; + /** + * 是有有效:0-有效、1-无效 + */ + int status; + /** + * 失效日期 + */ + String expirationDate; + /** + * 生效日期 + */ + String effectiveDate; + /** + * 最小请假单位 + */ + int minimumUnit; + + public KQBalanceOfLeaveEntity() { + } + + public KQBalanceOfLeaveEntity(int id, int leaveRulesId, int resourceId, String belongYear, double baseAmount, double usedAmount, double extraAmount, double baseAmount2, double usedAmount2, double extraAmount2, int status, String expirationDate) { + this.id = id; + this.leaveRulesId = leaveRulesId; + this.resourceId = resourceId; + this.belongYear = belongYear; + this.baseAmount = baseAmount; + this.usedAmount = usedAmount; + this.extraAmount = extraAmount; + this.baseAmount2 = baseAmount2; + this.usedAmount2 = usedAmount2; + this.extraAmount2 = extraAmount2; + this.status = status; + this.expirationDate = expirationDate; + } + public KQBalanceOfLeaveEntity(int id, int leaveRulesId, int resourceId, String belongYear, double baseAmount, double usedAmount, double extraAmount, double baseAmount2, double usedAmount2, double extraAmount2, int status, String expirationDate ,String effectiveDate) { + this.id = id; + this.leaveRulesId = leaveRulesId; + this.resourceId = resourceId; + this.belongYear = belongYear; + this.baseAmount = baseAmount; + this.usedAmount = usedAmount; + this.extraAmount = extraAmount; + this.baseAmount2 = baseAmount2; + this.usedAmount2 = usedAmount2; + this.extraAmount2 = extraAmount2; + this.status = status; + this.expirationDate = expirationDate; + this.effectiveDate = effectiveDate; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getLeaveRulesId() { + return leaveRulesId; + } + + public void setLeaveRulesId(int leaveRulesId) { + this.leaveRulesId = leaveRulesId; + } + + public int getResourceId() { + return resourceId; + } + + public void setResourceId(int resourceId) { + this.resourceId = resourceId; + } + + public String getBelongYear() { + return belongYear; + } + + public void setBelongYear(String belongYear) { + this.belongYear = belongYear; + } + + public double getBaseAmount() { + return baseAmount; + } + + public void setBaseAmount(double baseAmount) { + this.baseAmount = baseAmount; + } + + public double getUsedAmount() { + return usedAmount; + } + + public void setUsedAmount(double usedAmount) { + this.usedAmount = usedAmount; + } + + public double getExtraAmount() { + return extraAmount; + } + + public void setExtraAmount(double extraAmount) { + this.extraAmount = extraAmount; + } + + public double getBaseAmount2() { + return baseAmount2; + } + + public void setBaseAmount2(double baseAmount2) { + this.baseAmount2 = baseAmount2; + } + + public double getUsedAmount2() { + return usedAmount2; + } + + public void setUsedAmount2(double usedAmount2) { + this.usedAmount2 = usedAmount2; + } + + public double getExtraAmount2() { + return extraAmount2; + } + + public void setExtraAmount2(double extraAmount2) { + this.extraAmount2 = extraAmount2; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(String expirationDate) { + this.expirationDate = expirationDate; + } + + public String getEffectiveDate() { + return effectiveDate; + } + + public void setEffectiveDate(String effectiveDate) { + this.effectiveDate = effectiveDate; + } + + public int getMinimumUnit() { + return minimumUnit; + } + + public void setMinimumUnit(int minimumUnit) { + this.minimumUnit = minimumUnit; + } + + public boolean equals(KQBalanceOfLeaveEntity entity) { + if (this.baseAmount != entity.getBaseAmount() + || this.extraAmount != entity.getExtraAmount() + || this.usedAmount != entity.getUsedAmount() + || this.baseAmount2 != entity.getBaseAmount2() + || this.extraAmount2 != entity.getExtraAmount2() + || this.usedAmount2 != entity.getUsedAmount2()) { + return false; + } else { + return true; + } + } + + public boolean equalsByBaseAmount(KQBalanceOfLeaveEntity entity) { + if (this.baseAmount != entity.getBaseAmount() + || this.baseAmount2 != entity.getBaseAmount2()) { + return false; + } else { + return true; + } + } +}