派假逻辑调整

main
seaon 2 months ago
parent a327327ebb
commit 4c49592b99

@ -542,9 +542,13 @@ public class PersongroupCommonUtil {
for (Map<String,Object> personGroup:personGroupList){
//明细类型人员群组明细记录过滤人员的方式0人员清单1条件清单2SQL查询
String list_type = Util.null2String(personGroup.get("list_type"));
//人员清单过滤条件是当前行记录对应的人员ID值
String empid = Util.null2String(personGroup.get("empid"));
//条件清单过滤条件时,用来过滤人员的员工信息字段及过滤值
String filters = Util.null2String(personGroup.get("filters"));
String list_type = Util.null2String(personGroup.get("list_type"));
//SQL条件时用来查询员工ID集合的SQL脚本
String sqltj = Util.null2String(personGroup.get("sqltj"));
if (PersonGroupListTypeEnum.PERSON.getKey().equals(list_type) && !"".equals(empid)){
@ -557,7 +561,23 @@ public class PersongroupCommonUtil {
//条件清单
sql = "select id,seclevel from hrmresource where 1=1 ";
if (filters.contains("field")){
sql = "select a.id,a.seclevel from hrmresource a left join cus_fielddata b on a.id=b.id where scope='HrmCustomFieldByInfoType' and "+filters;
String sql_select = "select a.*";
String sql_join = " from hrmresource a";
sql = "SELECT DISTINCT SCOPEID FROM CUS_FORMFIELD WHERE SCOPE = 'HrmCustomFieldByInfoType'";
List<Map<String,Object>> listscopeids = DbTools.getSqlToList(sql);
for (Map<String,Object> dataMap :listscopeids){
String str_scopeId = Util.null2String(dataMap.get("scopeid"));
int int_scopeId = Util.getIntValue(str_scopeId)+100;
sql_join = sql_join + " left join cus_fielddata t" + int_scopeId + " on a.id = t" + int_scopeId + ".id and t" + int_scopeId + ".scope='HrmCustomFieldByInfoType' and t" + int_scopeId + ".scopeid = " + str_scopeId;
}
sql = "SELECT 't'||(SCOPEID+100)||'.field'||fieldid colname FROM CUS_FORMFIELD WHERE SCOPE = 'HrmCustomFieldByInfoType'";
List<Map<String,Object>> listcolnames = DbTools.getSqlToList(sql);
for (Map<String,Object> dataMap :listcolnames){
String colname = Util.null2String(dataMap.get("colname"));
sql_select = sql_select + "," + colname;
}
sql = "select id,seclevel from (" + sql_select + sql_join +") TA where 1=1 and " + filters;
//sql = "select a.id,a.seclevel from hrmresource a left join cus_fielddata b on a.id=b.id where scope='HrmCustomFieldByInfoType' and "+filters;
}else {
sql = sql+ " and "+filters;
}
@ -582,6 +602,79 @@ public class PersongroupCommonUtil {
}
return resultMap;
}
/**
*
* ID
* @return
*/
public static Map<String,List<Map<String,Object>>> getAllpersonBelongGroup(String pEmpId){
String sql = "select a.list_type,a.userfor,b.mainid,b.empid,b.filters,b.bdate,b.edate,b.sqltj from uf_ryqz a left join uf_ryqz_dt1 b on a.id=b.mainid";
Map<String,List<Map<String,Object>>> resultMap = Maps.newHashMap();
List<Map<String,Object>> personGroupList = DbTools.getSqlToList(sql);
for (Map<String,Object> personGroup:personGroupList){
//明细类型人员群组明细记录过滤人员的方式0人员清单1条件清单2SQL查询
String list_type = Util.null2String(personGroup.get("list_type"));
//人员清单过滤条件是当前行记录对应的人员ID值
String empid = Util.null2String(personGroup.get("empid"));
//条件清单过滤条件时,用来过滤人员的员工信息字段及过滤值
String filters = Util.null2String(personGroup.get("filters"));
//SQL条件时用来查询员工ID集合的SQL脚本
String sqltj = Util.null2String(personGroup.get("sqltj"));
if (PersonGroupListTypeEnum.PERSON.getKey().equals(list_type) && !"".equals(empid)){
//人员清单
addpersonBelongGroup(resultMap,pEmpId,personGroup,null);
}else if (PersonGroupListTypeEnum.CONDITION.getKey().equals(list_type) && !"".equals(filters)){
filters = filters.replace("","and");
filters = filters.replace("","or");
//条件清单
sql = "select id,seclevel from hrmresource where 1=1 ";
if (filters.contains("field")){
String sql_select = "select a.*";
String sql_join = " from hrmresource a";
sql = "SELECT DISTINCT SCOPEID FROM CUS_FORMFIELD WHERE SCOPE = 'HrmCustomFieldByInfoType'";
List<Map<String,Object>> listscopeids = DbTools.getSqlToList(sql);
for (Map<String,Object> dataMap :listscopeids){
String str_scopeId = Util.null2String(dataMap.get("scopeid"));
int int_scopeId = Util.getIntValue(str_scopeId)+100;
sql_join = sql_join + " left join cus_fielddata t" + int_scopeId + " on a.id = t" + int_scopeId + ".id and t" + int_scopeId + ".scope='HrmCustomFieldByInfoType' and t" + int_scopeId + ".scopeid = " + str_scopeId;
}
sql = "SELECT 't'||(SCOPEID+100)||'.field'||fieldid colname FROM CUS_FORMFIELD WHERE SCOPE = 'HrmCustomFieldByInfoType'";
List<Map<String,Object>> listcolnames = DbTools.getSqlToList(sql);
for (Map<String,Object> dataMap :listcolnames){
String colname = Util.null2String(dataMap.get("colname"));
sql_select = sql_select + "," + colname;
}
sql = "select id,seclevel from (" + sql_select + sql_join +") TA where 1=1 and " + filters;
//sql = "select a.id,a.seclevel from hrmresource a left join cus_fielddata b on a.id=b.id where scope='HrmCustomFieldByInfoType' and "+filters;
}else {
sql = sql+ " and "+filters;
}
sql = sql+ " and id = " + pEmpId;
log.debug("getPersonnelGroupingByPerson filter sql : {}",sql);
List<Map<String,Object>> dataList = DbTools.getSqlToList(sql);
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
String seclevel = Util.null2String(dataMap.get("seclevel"));
addpersonBelongGroup(resultMap,hrmId,personGroup,seclevel);
}
}else if (PersonGroupListTypeEnum.SQLCONDITION.getKey().equals(list_type) && !"".equals(sqltj)){
sqltj = "select id from hrmresource where id in (" + Utils.converSQL(sqltj) + ") and id = " + pEmpId;
log.info("getAllpersonBelongGroup sqltj : [{}]",sqltj);
List<Map<String,Object>> dataList = DbTools.getSqlToList(sqltj);
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
addpersonBelongGroup(resultMap,hrmId,personGroup,null);
}
}
}
return resultMap;
}
public static void addpersonBelongGroup(Map<String,List<Map<String,Object>>> resultMap,String empid,Map<String,Object> personGroup,String seclevel){
List<Map<String,Object>> personGroups = resultMap.get(empid);
if (personGroups == null){

@ -8,7 +8,8 @@ public enum RemainderHandleEnum implements BaseEnum {
DOWN_ZERO_POINT_FIVE("2","向下取0.5的倍数"),
UP_ZERO_POINT_FIVE("3","向上取0.5的倍数"),
ROUND_DOWN("4","向下取整"),
ROUND_UP("5","向上取整");
ROUND_UP("5","向上取整"),
FOURHOURS_DOWN("6","向下取4的倍数");
private String key;
private String value;

@ -119,7 +119,8 @@ public class HandleOverdueVocationCmd extends AbstractCommonCommand<Map<String,O
DbTools.update(updateSql,key.split("&")[0],key.split("&")[1],key.split("&")[2]);
}
}
sql = "DELETE FROM UF_JCL_KQ_JQYE WHERE jqid IN (101,102) AND ygid IN (SELECT id FROM CUS_FIELDDATA WHERE SCOPE = 'HrmCustomFieldByInfoType' AND SCOPEID = -1 AND Field21 != 'R' AND Field21 != 'E')";
DbTools.update(sql);
return null;
}

@ -6,10 +6,12 @@ import com.engine.jucailinkq.attendance.enums.QuotaChangeMethodEnum;
import com.engine.jucailinkq.attendance.enums.StartingUnitEnum;
import com.engine.jucailinkq.attendance.vacation.util.VocationCommonUtil;
import com.engine.jucailinkq.common.util.DateUtil;
import com.engine.jucailinkq.common.util.DbTools;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import weaver.general.Util;
import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
@ -36,6 +38,8 @@ public class BySchedulePaymentWay implements HolidayGenerationWay{
releaseDate = DateUtil.getCurrentTime();
}
List<Map<String,Object>> vocationList = (List<Map<String,Object>>)data.get("vocationList");
//当前派假假别
String pjjb = Util.null2String(vocationList.get(0).get("jb"));
//起算日期
String qsrq = Util.null2String(vocationList.get(0).get("qsrqValue"));
//额度有效期间
@ -82,6 +86,9 @@ public class BySchedulePaymentWay implements HolidayGenerationWay{
return Maps.newHashMap();
}
//执行日期
Map<String, Object> insertHoliDayParam = VocationCommonUtil.getInsertHoliDayParam(vocationList.get(0), userId, qsrq, releaseDate);
//相差天数
int betweenDays = DateUtil.getBetWeenDays(qsrq, releaseDate.split(" ")[0]);
//相差月份
@ -90,12 +97,15 @@ public class BySchedulePaymentWay implements HolidayGenerationWay{
int allWorkDays = Double.valueOf(ljcrglyfslwz).intValue() * 30 + betweenDays;
//总月数
int allMonths = betweenMonth + Double.valueOf(ljcrglyfslwz).intValue();
//如果工龄直接取工龄字段值
if ("2".equals(jgscsf)){
allMonths = (int)(Double.valueOf(ljcrglyfslwz)*12);
if (allMonths == 0){
//return insertHoliDayParam;
}
}
//执行日期
Map<String, Object> insertHoliDayParam = VocationCommonUtil.getInsertHoliDayParam(vocationList.get(0), userId, qsrq, releaseDate);
List<Map<String,Object>> dataList = VocationCommonUtil.ifexist("uf_jcl_kq_jqye", insertHoliDayParam);
@ -183,6 +193,20 @@ public class BySchedulePaymentWay implements HolidayGenerationWay{
restTime=0;
}
}
restTime = VocationCommonUtil.handleRestDays(restTime,wscl);
if("102".equals(pjjb)){
String sql = "UPDATE UF_JCL_KQ_JQYE SET KTSC = 120 - " + restTime + " WHERE JQID = 101 AND KTSC + " + restTime + " > 120 AND YGID = " + userId + " AND sxrq = '" + sxrq + "'";
DbTools.update(sql);
}
if("101".equals(pjjb)){
String sql = "SELECT KTSC FROM UF_JCL_KQ_JQYE ujkj WHERE JQID = 102 AND ygid = " + userId + " AND sxrq = '" + sxrq + "'";
Map<String,Object> tmpres = DbTools.getSqlToMap(sql);
if (tmpres.size()>0) {
double restTime0 = Double.valueOf(tmpres.get("ktsc").toString());
if (restTime0 + restTime > 120)
restTime = 120 - restTime0;
}
}
insertHoliDayParam.put("ktsc",restTime);
//离职日期
@ -241,7 +265,7 @@ public class BySchedulePaymentWay implements HolidayGenerationWay{
endYear = beginYear+1;
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
double divdemonths = Double.valueOf(ljcrglyfslwz) - Double.valueOf(ljcrglyfslwz).intValue();
divideTime = DateUtil.nextMonth(sxrq,(int)Math.ceil(divdemonths*12),dateTimeFormatter);
divideTime = DateUtil.nextMonth(sxrq,12-(int)Math.ceil(divdemonths*12),dateTimeFormatter);
}else {
int beginYearMonth = DateUtil.getBetWeenMonths(qsrq, sxrq);
if (beginYearMonth < 0) {

@ -7,10 +7,13 @@ import com.engine.jucailinkq.attendance.enums.StartingUnitEnum;
import com.engine.jucailinkq.attendance.vacation.util.VocationCommonUtil;
import com.engine.jucailinkq.common.exception.AttendanceRunTimeException;
import com.engine.jucailinkq.common.util.DateUtil;
import com.engine.jucailinkq.common.util.DbTools;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import weaver.general.Util;
import javax.swing.text.DateFormatter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.List;
@ -39,6 +42,8 @@ public class SinglePaymentInFullWay implements HolidayGenerationWay {
releaseDate = DateUtil.getCurrentTime();
}
List<Map<String, Object>> vocationList = (List<Map<String, Object>>) data.get("vocationList");
//当前派假假别
String pjjb = Util.null2String(vocationList.get(0).get("jb"));
//起算日期
String qsrq = Util.null2String(vocationList.get(0).get("qsrqValue"));
//截止日期
@ -69,6 +74,8 @@ public class SinglePaymentInFullWay implements HolidayGenerationWay {
String schdedkzsxrq = Util.null2String(vocationList.get(0).get("schdedkzsxrq"));
//间隔时长算法
String jgscsf = Util.null2String(vocationList.get(0).get("jgsc"));
//累计时长单位01
String ljgldw = Util.null2String(vocationList.get(0).get("lsgldw"));
if ("".equals(qsrq)){
return Maps.newHashMap();
@ -84,6 +91,9 @@ public class SinglePaymentInFullWay implements HolidayGenerationWay {
return Maps.newHashMap();
}
Map<String, Object> insertHoliDayParam = VocationCommonUtil.getInsertHoliDayParam(vocationList.get(0), userId, qsrq, releaseDate);
//相差天数
int betweenDays = DateUtil.getBetWeenDays(qsrq, releaseDate.split(" ")[0]);
//相差月份
@ -92,12 +102,15 @@ public class SinglePaymentInFullWay implements HolidayGenerationWay {
int allWorkDays = Double.valueOf(ljcrglyfslwz).intValue() * 30 + betweenDays;
//总月数
int allMonths = betweenMonth + Double.valueOf(ljcrglyfslwz).intValue();
Map<String, Object> insertHoliDayParam = VocationCommonUtil.getInsertHoliDayParam(vocationList.get(0), userId, qsrq, releaseDate);
//如果工龄直接取工龄字段值
if ("2".equals(jgscsf)){
allMonths = (int)(Double.valueOf(ljcrglyfslwz)*12);
if (allMonths == 0){
//return insertHoliDayParam;
}
}
List<Map<String,Object>> dataList = VocationCommonUtil.ifexist("uf_jcl_kq_jqye", insertHoliDayParam);
// List<Map<String,Object>> dataList = new ArrayList<>();
// List<Map<String,Object>> dataList = new ArrayList<>();
//已存在数据且不覆盖
if (dataList.size()>0 && !"1".equals(cover)) {
@ -216,6 +229,20 @@ public class SinglePaymentInFullWay implements HolidayGenerationWay {
Map<String, Object> vocationMap = VocationCommonUtil.getVocationMap(vocationList, allWorkDays, yjzd,userId);
restTime = vocationMap.size()>0?Double.valueOf(vocationMap.get("edktsc").toString()):0;
}
restTime = VocationCommonUtil.handleRestDays(restTime,wscl);
if("102".equals(pjjb)){
String sql = "UPDATE UF_JCL_KQ_JQYE SET KTSC = 120 - " + restTime + " WHERE JQID = 101 AND KTSC + " + restTime + " > 120 AND YGID = " + userId + " AND sxrq = '" + sxrq + "'";
DbTools.update(sql);
}
if("101".equals(pjjb)){
String sql = "SELECT KTSC FROM UF_JCL_KQ_JQYE ujkj WHERE JQID = 102 AND ygid = " + userId + " AND sxrq = '" + sxrq + "'";
Map<String,Object> tmpres = DbTools.getSqlToMap(sql);
if (tmpres.size()>0) {
double restTime0 = Double.valueOf(tmpres.get("ktsc").toString());
if (restTime0 + restTime > 120)
restTime = 120 - restTime0;
}
}
insertHoliDayParam.put("ktsc", restTime);
if (!"1".equals(isOneTime)){
@ -248,43 +275,44 @@ public class SinglePaymentInFullWay implements HolidayGenerationWay {
String wscl = Util.null2String(vocationList.get(0).get("wscl"));
//间隔时长算法
String jgscsf = Util.null2String(vocationList.get(0).get("jgsc"));
int seniority = "".equals(ljcrglyfslwz)?0:Double.valueOf(ljcrglyfslwz).intValue();
//累计工龄数或者直取工龄数
int seniority = 0;
//累计时长单位01
String ljgldw = Util.null2String(vocationList.get(0).get("lsgldw"));
if(!"2".equals(jgscsf)) {
//间隔时长不为直取工龄时,进行取整处理 todo:实际上累计工龄为年时 基本上都是有小数的 ,都不应该取整 ,这里的逻辑有待优化
seniority = "".equals(ljcrglyfslwz) ? 0 : Double.valueOf(ljcrglyfslwz).intValue();
}
double restTime=0.0;
//折算
if (changeMethodEnum == QuotaChangeMethodEnum.CONVERT){
int beginYearMonth = DateUtil.getBetWeenMonths(qsrq,sxrq);
if (beginYearMonth < 0){
beginYearMonth = 0;
}
beginYearMonth = beginYearMonth+seniority;
int endYearMonth = DateUtil.getBetWeenMonths(qsrq,nextSxrq);
endYearMonth = endYearMonth+seniority;
int beginYear = beginYearMonth/12;
int endYear = endYearMonth/12;
//残年分割日期
String divideTime = DateUtil.beforeMonth(qsrq,seniority);
//divideTime = sxrq.split("-")[0]+"-"+divideTime.split("-")[1]+"-"+divideTime.split("-")[2];
divideTime = DateUtil.nextYear(divideTime,endYear,DateUtil.yyyyMMdd);
if (jgscsf.equals("2")){
int beginYear = 0;
int endYear = 0;
String divideTime = "";
if("2".equals(jgscsf)) {
//直接取工龄字段
beginYear = seniority/12;
beginYear = Double.valueOf(ljcrglyfslwz).intValue();
endYear = beginYear+1;
//分割日期
int month = DateUtil.getBetWeenMonths(qsrq,sxrq);
if (month < 0){
month = 0;
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
double divdemonths = Double.valueOf(ljcrglyfslwz) - Double.valueOf(ljcrglyfslwz).intValue();
divideTime = DateUtil.nextMonth(sxrq,12-(int)Math.ceil(divdemonths*12),dateTimeFormatter);
//LocalDateTime localDateTime = DateUtil.getTime(sxrq);
//localDateTime = localDateTime.plusMonths((int)Math.ceil(divdemonths*12));
//divideTime = localDateTime.format(dateTimeFormatter);
}else {
int beginYearMonth = DateUtil.getBetWeenMonths(qsrq, sxrq);
if (beginYearMonth < 0) {
beginYearMonth = 0;
}
int historySeniority = seniority-month<0?0:seniority-month;
divideTime = DateUtil.beforeMonth(qsrq,historySeniority);
beginYearMonth = beginYearMonth + seniority;
int endYearMonth = DateUtil.getBetWeenMonths(qsrq, nextSxrq);
endYearMonth = endYearMonth + seniority;
beginYear = beginYearMonth / 12;
endYear = endYearMonth / 12;
//残年分割日期
divideTime = DateUtil.beforeMonth(qsrq,seniority);
divideTime = sxrq.split("-")[0]+"-"+divideTime.split("-")[1]+"-"+divideTime.split("-")[2];
}
Map<String,Object> beginYearmap = VocationCommonUtil.getVocationMap(vocationList, beginYear, yjzd,userId);
Map<String,Object> endYearmap = VocationCommonUtil.getVocationMap(vocationList, endYear, yjzd,userId);
double beginEdktsc = Double.valueOf(beginYearmap.get("edktsc") == null? "0" :Util.null2String(beginYearmap.get("edktsc")));
@ -324,13 +352,12 @@ public class SinglePaymentInFullWay implements HolidayGenerationWay {
restTime = VocationCommonUtil.handleRestDays(beforeRestTime+afterRestTime,wscl);
}
}
}else {
//不折算
int beginYear = 0;
if (jgscsf.equals("2")){
//直接取工龄字段
beginYear = seniority/12;
beginYear = Double.valueOf(ljcrglyfslwz).intValue();
}else {
//起算日期与当前日期间隔+工龄字段
int beginYearMonth = DateUtil.getBetWeenMonths(qsrq,sxrq);

@ -30,13 +30,25 @@ public class VocationServiceImpl extends Service implements VocationService {
@Override
public void generateVocation(Map<String, Object> params) {
String modeId = Util.null2String(params.get("modeId"));
String empId = "";
String leavetype = "";
Map<String,Object> param = Maps.newHashMap();
param.put("modeId",modeId);
if (params.containsKey("empid")) {
empId = Util.null2String(params.get("empid"));
param.put("empid", empId);
}
if (params.containsKey("leavetype"))
leavetype = Util.null2String(params.get("leavetype"));
Map<String,Object> result = commandExecutor.execute(new GetPersonVocationBySuitOrganzation(param));
String sql = "select a.id userid,a.*,b.* from hrmresource a left join cus_fielddata b on a.id=b.id where a.status <> '5' and a.status <> '4' and a.status <> '7' and a.id in (";
String queryDepartEmployeeSql = "select resourceid ,changedate,type_n from HRMSTATUSHISTORY where changedate is not null";
if (params.containsKey("empid")) {
queryDepartEmployeeSql = queryDepartEmployeeSql + " and resourceid = " + empId;
sql = "select a.id userid,a.*,b.* from hrmresource a left join cus_fielddata b on a.id=b.id where a.status <> '5' and a.status <> '4' and a.status <> '7' and a.id = "+ Util.null2String(params.get("empid")) +" and a.id in (";
}
//获取离职日期
List<Map<String,Object>> departEmployeeList = DbTools.getSqlToList(queryDepartEmployeeSql);
Map<String,Object> departEmployeeMap = CommonUtil.getDepartEmployeeMap(departEmployeeList);
@ -70,6 +82,7 @@ public class VocationServiceImpl extends Service implements VocationService {
Map<String,List<Map<String,Object>>> itemGroup = attendanceItems.stream().collect(Collectors.groupingBy(e->e.get("key").toString()));
Map<String, Object> needGenerateVocationMap = Maps.newHashMap();
for (Map<String,Object> map : attendanceItems){
if (leavetype != "" && !leavetype.equals(map.get("key"))) continue;
if (vocationMap.get(map.get("key")) != null){
needGenerateVocationMap.put(Util.null2String(map.get("key")),vocationMap.get(map.get("key")));
}

@ -256,8 +256,10 @@ public class VocationCommonUtil {
result = dayBig.multiply(ratedRestTimeBig).divide(yearDayBig,0,BigDecimal.ROUND_DOWN).doubleValue();
}else if (RemainderHandleEnum.ROUND_UP.getKey().equals(wscl)){
result = dayBig.multiply(ratedRestTimeBig).divide(yearDayBig,0,BigDecimal.ROUND_UP).doubleValue();
}else if (RemainderHandleEnum.FOURHOURS_DOWN.getKey().equals(wscl)){
result = dayBig.multiply(ratedRestTimeBig).divide(yearDayBig,0,BigDecimal.ROUND_DOWN).doubleValue();
result = Math.floor(result / 4) * 4;
}
return result;
}
public static double computeRestDays(int day,int yearDay,double ratedRestTime){
@ -283,6 +285,9 @@ public class VocationCommonUtil {
result = new BigDecimal(value).setScale(0,BigDecimal.ROUND_DOWN).doubleValue();
}else if (RemainderHandleEnum.ROUND_UP.getKey().equals(wscl)){
result = new BigDecimal(value).setScale(0,BigDecimal.ROUND_UP).doubleValue();
}else if (RemainderHandleEnum.FOURHOURS_DOWN.getKey().equals(wscl)){
result = new BigDecimal(value).setScale(0,BigDecimal.ROUND_DOWN).doubleValue();
result = Math.floor(result / 4) * 4;
}
return result;
}
@ -336,6 +341,7 @@ public class VocationCommonUtil {
}else if (edyxq.equals(StartingUnitEnum.STARTING_YEAR.getKey())){
String startTime = ffsj.split("-")[0]+"-"+qsrq.split("-")[1]+"-"+qsrq.split("-")[2];
startTime = DateUtil.getFormatLocalDate(DateUtil.getTime(startTime));
String beforeStartTime = DateUtil.beforeYear(startTime,1,DateUtil.yyyyMMdd);
String beforeEndTime = DateUtil.beforeDay(startTime,1);
String endTime = DateUtil.nextYear(beforeEndTime,1,DateUtil.yyyyMMdd);
@ -376,6 +382,7 @@ public class VocationCommonUtil {
}else if (edyxq.equals(StartingUnitEnum.STARTING_MONTH.getKey())){
String sxrq = ffsj.split("-")[0]+"-"+ffsj.split("-")[1]+"-"+qsrq.split("-")[2];
sxrq = DateUtil.getFormatLocalDate(DateUtil.getTime(sxrq));
String beforeEndTime = DateUtil.beforeDay(sxrq,1);
String beforeSxrq = DateUtil.beforeMonth(sxrq,1);
String beforeJzrq = DateUtil.nextMonth(beforeEndTime,edyxqsz-1,DateUtil.yyyyMMdd);

@ -1,5 +1,10 @@
package com.engine.jucailinkq.attendance.workflow.service.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.jucailinkq.attendance.workflow.service.EnterpriseCalendarService;
import com.engine.core.impl.Service;
import com.engine.jucailinkq.common.util.*;
@ -46,7 +51,95 @@ public class EnterpriseCalendarServiceImpl extends Service implements Enterprise
String transContinue= Util.null2String(dataMain.get("asynjx"));
//是否使用农历且带入农历节气信息
String lunarFlag= Util.null2String(dataMain.get("jqdrmc"));
Map<String,Map<String,Object>> holidayMap = DealDetail(calendarId, yearStr, lunarFlag);
//国家信息
String countrycode="";
if (dataMain.containsKey("gj")){
sql = "SELECT bm FROM uf_jcl_kq_tycjsj WHERE id = " + Util.null2String(dataMain.get("gj"));
Map<String,Object> datagj = DbTools.getSqlToMap(sql);
if (datagj.size() > 0) {
countrycode = Util.null2String(datagj.get("bm"));
}
}
//接口调用
String conInterface = "0";
if (dataMain.containsKey("jkdy"))
conInterface = Util.null2String(dataMain.get("jkdy"));
//接口优先
String interfaceFirst = "0";
if (dataMain.containsKey("jkyx"))
interfaceFirst = Util.null2String(dataMain.get("jkyx"));
//农历名称
String lunarName = "0";
if (dataMain.containsKey("nl"))
lunarName = Util.null2String(dataMain.get("nl"));
if ("1".equals(conInterface)) {
//=======自动添加日历明细记录===只针对非中国大陆之外的国家或地区执行===========
/*获取token*/
String url = "https://api.marcopayroll.com/api:benKoCK8/api/auth/login?email=tigers@tigermedgrp.com&password=mgkH6TsOyCXybl8H";
String requestStr = "";
int TIMEOUT = 60000;
HttpRequest req = HttpUtil.createPost(url).timeout(TIMEOUT).body(requestStr);
HttpResponse resp = req.execute();
JSONObject returnJson = JSONObject.parseObject(resp.body());
String auth_token = returnJson.get("auth_token").toString();
/*获取指定国家指定日期区间内的节假日信息*/
url = "https://api.marcopayroll.com/api:benKoCK8/api/public-holiday?country=" + countrycode + "&customer_id=3&start_date=" + yearStr + "/01/01&end_date=" + yearStr + "/12/31";
req = HttpUtil.createGet(url).timeout(TIMEOUT).body(requestStr).header("Authorization", auth_token);
resp = req.execute();
returnJson = JSONObject.parseObject(resp.body());
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(returnJson.get("public_holiday").toString()).get("items").toString());
JSONObject holidayitem;
String start_date, end_date;
String holidayname_zh = "";
String holidayname_en = "";
JSONArray dictionary;
List<Map<String, Object>> holidayInfoList = new ArrayList<>();
Map<String, Object> holidayInfo = new HashMap<>();
String condition = " mainid = " + calendarId + " and glrq between '" + yearStr + "-01-01' and '" + yearStr + "-12-31'";
List<String> dbitems = CommonUtil.getUniqueItems("uf_jcl_kq_rlmc_dt1","glrq",condition);
for (int i = 0; i < jsonArray.size(); i++) {
holidayitem = jsonArray.getJSONObject(i);
start_date = holidayitem.get("start_date").toString();
end_date = holidayitem.get("end_date").toString();
dictionary = JSONArray.parseArray(holidayitem.get("dictionary").toString());
for (int j = 0; j < dictionary.size(); j++) {
if (!"".equals(dictionary.getJSONObject(j).get("value"))) {
switch (dictionary.getJSONObject(j).get("lang").toString()) {
case "ZH":
holidayname_zh = dictionary.getJSONObject(j).get("value").toString();
break;
case "EN":
holidayname_en = dictionary.getJSONObject(j).get("value").toString();
break;
default:
break;
}
}
}
if (start_date.equals(end_date)) {
if (!dbitems.contains(start_date)) {
holidayInfo = createHolidayInfo(calendarId, start_date, holidayname_zh, holidayname_en);
holidayInfoList.add(holidayInfo);
dbitems.add(start_date);
}
} else {
int m = DateUtil.getBetWeenDays(start_date, end_date);
for (int n = 0; n < m; n++) {
String tmpdate = DateUtil.AfterDay(start_date, n);
if (!dbitems.contains(tmpdate)) {
holidayInfo = createHolidayInfo(calendarId, tmpdate, holidayname_zh, holidayname_en);
holidayInfoList.add(holidayInfo);
dbitems.add(tmpdate);
}
}
}
}
boolean insertSign = CommonUtil.insertBatch(holidayInfoList, "uf_jcl_kq_rlmc_dt1");
bs.writeLog("insertholidaydetail : " + insertSign);
//=======自动添加日历明细记录==============
}
Map<String,Map<String,Object>> holidayMap = DealDetail(calendarId, yearStr, lunarFlag, lunarName);
//在单双周轮换时,判断第一周的休息日情况
boolean doubleRestSign = true;
if (restDaySetting.equals("1")) {
@ -55,7 +148,6 @@ public class EnterpriseCalendarServiceImpl extends Service implements Enterprise
doubleRestSign = checkFirstWeekRest(year, calendarId, doubleRestSign);
}
}
//查询formmodeid
Map<String,String> formModeIdMap = Utils.getFormmodeIdMap();
String formModeId = formModeIdMap.get("uf_jcl_kq_rlxx");
@ -68,7 +160,7 @@ public class EnterpriseCalendarServiceImpl extends Service implements Enterprise
for (int day = 0; day < daysInMonth; day++) {
dateInfo = new HashMap<>();
dateInfo = createDateInfo(calendar, lunarFlag);
dateInfo = createDateInfo(calendar, lunarFlag, lunarName);
dateInfo.put("formmodeid",formModeId);
dateInfo.put("modeuuid", UUID.randomUUID().toString());
dateInfo.put("modedatacreater","1");
@ -99,15 +191,23 @@ public class EnterpriseCalendarServiceImpl extends Service implements Enterprise
doubleRestSign = !doubleRestSign;
}
}
dateInfo.put("rqlx", "0");
dateInfo.put("bz", "");
dateInfo.put("mc", "");
if (holidayMap.containsKey(dateInfo.get("rq"))){
dateInfo.put("mc", holidayMap.get(dateInfo.get("rq")).get("mc"));
dateInfo.put("rqlx", holidayMap.get(dateInfo.get("rq")).get("rqlx"));
dateInfo.put("bz", holidayMap.get(dateInfo.get("rq")).get("bz"));
dateInfo.put("mc", holidayMap.get(dateInfo.get("rq")).get("mc"));
}
if (holidayMap.containsKey(dateInfo.get("nlrq")) && !holidayMap.containsKey("闰"+dateInfo.get("nlrq"))){
dateInfo.put("mc", holidayMap.get(dateInfo.get("nlrq")).get("mc"));
if (holidayMap.containsKey(dateInfo.get("nlrq"))){
dateInfo.put("rqlx", holidayMap.get(dateInfo.get("nlrq")).get("rqlx"));
dateInfo.put("bz", holidayMap.get(dateInfo.get("nlrq")).get("bz"));
dateInfo.put("mc", holidayMap.get(dateInfo.get("nlrq")).get("mc"));
}
if (holidayMap.containsKey(dateInfo.get("mc"))){
dateInfo.put("rqlx", holidayMap.get(dateInfo.get("mc")).get("rqlx"));
dateInfo.put("bz", holidayMap.get(dateInfo.get("mc")).get("bz"));
dateInfo.put("mc", holidayMap.get(dateInfo.get("mc")).get("mc"));
}
dateInfoList.add(dateInfo);
calendar.add(Calendar.DAY_OF_MONTH, 1);
@ -172,75 +272,117 @@ public class EnterpriseCalendarServiceImpl extends Service implements Enterprise
* @param pLunarFlag
* @return
*/
private Map<String,Map<String,Object>> DealDetail(String pCalendarId, String pYearStr, String pLunarFlag){
String sql = "SELECT * FROM UF_JCL_KQ_RLMC_DT1 WHERE MAINID = " + pCalendarId;
List<Map<String,Object>> dataDetail = DbTools.getSqlToList(sql);
private Map<String,Map<String,Object>> DealDetail(String pCalendarId, String pYearStr, String pLunarFlag, String pLunarName) {
String sql = "SELECT * FROM UF_JCL_KQ_RLMC_DT1 WHERE MAINID = " + pCalendarId + " AND ((lx = 0 AND ((rqczz = '0' AND glrq LIKE '" + pYearStr + "%') OR rqczz != '0')) OR lx = 1) order by sjly";
List<Map<String, Object>> dataDetail = DbTools.getSqlToList(sql);
String row_mc = "";//名称
String row_rqlx = "";//日期类型0工作日1节假日2公休日3调休日4调班日
String row_bzsm = "";//备注说明
String row_lx = "";//类型:0:公历1农历
String row_glrq = "";//公历日期
String row_nlrq = "";//农历日期
int row_yf = 0;//月份
String row_rqczz = "";//日期参照值0年-月-日1月-日2月-周
String row_dydjr = "";//当月第几日
String row_sjly = "";//数据来源
int row_dydjr = 0;//当月第几日
int row_dydjz = 0;//当月第几周
int row_dzxqj = 0;//当周星期几
int row_jq=0;//节气
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
Map<String,Object> row_data = new HashMap<>();
Map<String,Map<String,Object>> rows = new HashMap<>();
for (Map<String,Object> holidayMap :dataDetail) {
Map<String, Object> row_data = new HashMap<>();
Map<String, Map<String, Object>> rows = new HashMap<>();
for (Map<String, Object> holidayMap : dataDetail) {
row_glrq = Util.null2String(holidayMap.get("glrq"));//公历日期
row_mc = holidayMap.get("mc").toString();
row_lx = holidayMap.get("lx").toString();
row_rqlx = holidayMap.get("rqlx").toString();
row_mc = holidayMap.get("mc").toString();
row_lx = holidayMap.get("lx").toString();
row_rqlx = holidayMap.get("rqlx").toString();
row_bzsm = Util.null2String(holidayMap.get("bzsm"));
row_nlrq = Util.null2String(holidayMap.get("nlrq"));
row_rqczz = Util.null2String(holidayMap.get("rqczz"));
row_data = new HashMap<>();
row_data.put("mc", row_mc);
row_data.put("rqlx", row_rqlx);
row_data.put("bz", row_bzsm);
if (row_lx.equals("0")){
//公历
switch (row_rqczz) {
case "0":
//年-月-日
break;
case "1":
//月-日 2024-12-13
calendar = Calendar.getInstance();
calendar.set(Integer.parseInt(pYearStr),Integer.parseInt(Util.null2String(holidayMap.get("glrq")).substring(5,7))-1,Integer.parseInt(holidayMap.get("dydjr").toString()));
row_sjly = Util.null2String(holidayMap.get("sjly"));
switch (row_rqczz) {
case "0":
//年-月-日 ***************农历不支持此逻辑
break;
case "1":
//月-日 2024-12-13
row_yf = Integer.parseInt(holidayMap.get("yf").toString());
row_dydjr = Integer.parseInt(holidayMap.get("dydjr").toString());
calendar = Calendar.getInstance();
if (row_lx.equals("0")) {
//公历处理逻辑
if (row_dydjr > 0) {
calendar.set(Integer.parseInt(pYearStr), row_yf, row_dydjr);
} else {
calendar.set(Integer.parseInt(pYearStr), row_yf, 1);
calendar.add(Calendar.MONTH, 1);
calendar.add(Calendar.DATE, row_dydjr);
}
row_glrq = sdf.format(calendar.getTime());
break;
case "2":
//月-周
calendar = Calendar.getInstance();
calendar.set(Integer.parseInt(pYearStr),Integer.parseInt(Util.null2String(holidayMap.get("glrq")).substring(5,7))-1,1);
int dayOfWeek = Integer.parseInt(getWeek(calendar));//周一-周日为0-6
row_dydjz = Integer.parseInt(holidayMap.get("dydjz").toString());
row_dzxqj = Integer.parseInt(holidayMap.get("dzxqj").toString());
if (row_dzxqj>dayOfWeek) {
calendar.add(Calendar.DATE, row_dzxqj - dayOfWeek);
} else {
//农历处理逻辑
//考虑到只有目前除夕是特殊的,取腊月的最后一天,所以对除夕做特殊处理
if (row_dydjr > 0) {
row_glrq = sdf.format(LunarCalendar.chineseMonthNumber[row_yf]+LunarCalendar.getChinaDayString(row_dydjr));
}else{
calendar.add(Calendar.DATE, row_dzxqj + 7 - dayOfWeek);
calendar.set(Integer.parseInt(pYearStr), 1,1);
LunarCalendar lunarCalendar = new LunarCalendar(calendar);
int monthDays = LunarCalendar.monthDays(lunarCalendar.getYear(), 12);
row_glrq = LunarCalendar.chineseMonthNumber[row_yf] + "月" + LunarCalendar.getChinaDayString(monthDays+1+row_dydjr);
}
calendar.add(Calendar.DATE, (row_dydjz-1)*7);
row_glrq = sdf.format(calendar.getTime());
break;
default:
break;
}
}else{
row_glrq = row_nlrq;
}
break;
case "2":
//月-周 ***************农历不支持此逻辑
calendar = Calendar.getInstance();
row_yf = Integer.parseInt(holidayMap.get("yf").toString());
calendar.set(Integer.parseInt(pYearStr), row_yf, 1);
int dayOfWeek = Integer.parseInt(getWeek(calendar));//周一-周日为0-6
row_dydjz = Integer.parseInt(holidayMap.get("dydjz").toString());
row_dzxqj = Integer.parseInt(holidayMap.get("dzxqj").toString());
if (row_dzxqj > dayOfWeek) {
calendar.add(Calendar.DATE, row_dzxqj - dayOfWeek);
} else {
calendar.add(Calendar.DATE, row_dzxqj + 7 - dayOfWeek);
}
calendar.add(Calendar.DATE, (row_dydjz - 1) * 7);
row_glrq = sdf.format(calendar.getTime());
break;
case "3":
row_jq = Integer.parseInt(holidayMap.get("nlrq").toString());
String[] principleTermNames = {"立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至","小寒","大寒"};
row_glrq = principleTermNames[row_jq];
break;
default:
break;
}
row_data.put("rq", row_glrq);
rows.put(row_glrq,row_data);
row_data = new HashMap<>();
row_data.put("mc", row_mc);//名称
row_data.put("rqlx", row_rqlx);//日期类型
row_data.put("bz", row_bzsm);//备注
row_data.put("rq", row_glrq);//公历日期
row_data.put("sjly", row_sjly);//数据来源
rows.put(row_glrq, row_data);
}
return rows;
}
private Map<String, Object> createDateInfo(Calendar calendar, String lunarFlag) {
private Map<String, Object> createHolidayInfo(String calendarid, String date, String zh_name, String en_name) {
Map<String, Object> holidayInfo = new HashMap<>();
holidayInfo.put("mainid",calendarid);
holidayInfo.put("lx",0);//日历类型0公历1农历
holidayInfo.put("rqczz",0);//日期参照值0年-月-日1月-日2月-周
holidayInfo.put("rqlx",1);//日期类型0工作日1节假日2公休日3调休日4调班日
holidayInfo.put("glrq",date);
holidayInfo.put("mc",zh_name);//名称
holidayInfo.put("sjly","0");//名称
//holidayInfo.put("nlrq","");//农历日期文本
//holidayInfo.put("dydjr","");//当月第几日
//holidayInfo.put("dydjz","");//当月第几周
//holidayInfo.put("dzxqj",calendarId);//当周星期几0星期一1星期二2星期三6星期日
return holidayInfo;
}
private Map<String, Object> createDateInfo(Calendar calendar, String solarTerms, String lunarName) {
Map<String, Object> dateInfo = new HashMap<>();
// 获取阳历年-月-日
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@ -259,6 +401,7 @@ public class EnterpriseCalendarServiceImpl extends Service implements Enterprise
if (!termInfo.equals("")) {
specialDay = termInfo.replace(" ", "");
}
/*
//判断日期是否为节日
String holidayInfo = getHolidayInfo(calendar, lunarCalendar);
if (!holidayInfo.equals("")) {
@ -266,15 +409,19 @@ public class EnterpriseCalendarServiceImpl extends Service implements Enterprise
}
//判断日期类型
String dayType = getDayType(weekIndex, specialDay);
*/
dateInfo.put("rq", solarDate);
if (lunarFlag.equals("1")) {
dateInfo.put("nlrq", lunarDate);
//依据是否节气信息,设置日期名称
if (solarTerms.equals("1")) {
dateInfo.put("mc", specialDay.equals("") ? null : specialDay);
dateInfo.put("rqlx", dayType);
}else{
dateInfo.put("nlrq", "");
dateInfo.put("mc", "");
dateInfo.put("rqlx", "0");
}
//依据是否农历日期,设置农历日期字段值
if (lunarName.equals("1")) {
dateInfo.put("nlrq", lunarDate);
}else{
dateInfo.put("nlrq", "");
}
dateInfo.put("xq", weekIndex);
dateInfo.put("bz", "");

@ -38,7 +38,8 @@ public class EnterpriseCalendarApi {
@POST
@Path("/initCalendar")
@Produces(MediaType.TEXT_PLAIN)
public String initCalendar(@Context HttpServletRequest request, @Context HttpServletResponse response) {
public String
initCalendar(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<String, Object>();
User user = HrmUserVarify.getUser(request, response);
apidatas = getEnterpriseCalendarService(user).initCalendar(ParamUtil.request2Map(request));

@ -12,10 +12,7 @@ import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import weaver.general.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -36,10 +33,12 @@ public class GetPersonVocationBySuitOrganzation extends AbstractCommonCommand<Ma
@Override
public Map<String, Object> execute(CommandContext commandContext) {
String modeId = Util.null2String(params.get("modeId"));
//查询所有假期额度的作用范围对象
String sql = "select dxlx,aqjb,dataid,dx from uf_jcl_syzz where modeid=?";
//假期额度适用组织所有值集合
List<Map<String,Object>> organzationList = DbTools.getSqlToList(sql,modeId);
sql = "select a.id dataid,b.id detailid,a.*,b.* from uf_jcl_kq_jqed a left join uf_jcl_kq_jqed_dt1 b on a.id=b.mainid where (gzzt is null or gzzt <> '1')";
//查询所有假期额度规则及明细信息
sql = "select a.id dataid,b.id detailid,a.*,b.* from uf_jcl_kq_jqed a left join uf_jcl_kq_jqed_dt1 b on a.id=b.mainid where (gzzt is null or gzzt <> '1') ORDER BY a.JB DESC ,b.ID";
//所有假期额度生成规则值
List<Map<String,Object>> vacationList = DbTools.getSqlToList(sql);
//人力资源id假别规则id
@ -54,17 +53,26 @@ public class GetPersonVocationBySuitOrganzation extends AbstractCommonCommand<Ma
//以假期额度生成规则id分割的假期额度生成规则值集合
Map<String,String> vacationMap = Maps.newHashMap();
for (Map<String,Object> vocation:vacationList){
vacationMap.put(vocation.get("dataid").toString(),vocation.get("jb").toString());
vocation.put("zyzValue",getUserIds(vocation));
String empid = "";
if (params.containsKey("empid")){
empid = Util.null2String(params.get("empid"));
for (Map<String, Object> vocation : vacationList) {
vacationMap.put(vocation.get("dataid").toString(), vocation.get("jb").toString());
vocation.put("zyzValue", getUserIds(vocation,empid));
}
}else {
for (Map<String, Object> vocation : vacationList) {
vacationMap.put(vocation.get("dataid").toString(), vocation.get("jb").toString());
vocation.put("zyzValue", getUserIds(vocation));
}
}
Map<String,List<Map<String,Object>>> vacationGroupByDataIdMap = vacationList.stream().collect(Collectors.groupingBy(e->e.get("dataid").toString()));
Set<String> personOrganzationIds = Sets.newHashSet();
Set<String> departMentIds = Sets.newHashSet();
Set<String> subCompanyIds = Sets.newHashSet();
//遍历所有适用范围信息
for (Map<String,Object> organzation:organzationList){
String dx = Util.null2String(organzation.get("dx")).split("-")[0];
String dataid = Util.null2String(organzation.get("dataid"));
@ -109,13 +117,16 @@ public class GetPersonVocationBySuitOrganzation extends AbstractCommonCommand<Ma
if (departMentIds.size() > 0){
sql = sql+ " and departmentid in ("+String.join(",",departMentIds)+")";
}
if (subCompanyIds .size() >0 && departMentIds.size() > 0){
if (subCompanyIds.size() >0 && departMentIds.size() > 0){
sql = "select id,departmentid,subcompanyid1,seclevel from hrmresource where status <> '5' and status <> '4' and status <> '7' ";
sql = sql+ " and (departmentid in ("+String.join(",",departMentIds)+")"+ " or subcompanyid1 in ("+String.join(",",subCompanyIds)+"))";
}else if (subCompanyIds .size() >0 && departMentIds.size() == 0){
sql = sql+ " and subcompanyid1 in ("+String.join(",",subCompanyIds)+")";
}
sql += " and (belongto is null or belongto='-1') ";
if (params.containsKey("empid")){
sql += " and id = " + empid;
}
List<Map<String,Object>> hrmListByDepartAndSubCompanyIds = DbTools.getSqlToList(sql);
//部门id-人员id集合
@ -127,7 +138,12 @@ public class GetPersonVocationBySuitOrganzation extends AbstractCommonCommand<Ma
//人员分组id-人员id集合
if (personOrganzationIds.size() >0){
//人员分组id-假别假期规则id
Map<String,Set<String>> personGroupUserIds = getPersonGroupUserIds(personOrganzationIds);
Map<String,Set<String>> personGroupUserIds = Maps.newHashMap();
if (!empid.equals("")) {
personGroupUserIds = getPersonGroupUserIds(personOrganzationIds,empid);
}else{
personGroupUserIds = getPersonGroupUserIds(personOrganzationIds);
}
log.info("personGroupUserIds : [{}]",personGroupUserIds);
log.info("personOrganzationMap : [{}]",personOrganzationMap);
for (Map.Entry<String,Object> entry : personOrganzationMap.entrySet()){
@ -154,7 +170,9 @@ public class GetPersonVocationBySuitOrganzation extends AbstractCommonCommand<Ma
}
}
}
if (!empid.equals("")){
sql = "select * from (" + sql + ") where id = " + empid;
}
log.debug("before personMap : [{}]",personMap);
//部门id
log.debug("departMentMap : [{}]",departMentMap);
@ -226,6 +244,67 @@ public class GetPersonVocationBySuitOrganzation extends AbstractCommonCommand<Ma
return newpersonMap;
}
/**
*
* @param personOrganzationIds
* @returnid-id
*/
public Map<String,Set<String>> getPersonGroupUserIds(Set<String> personOrganzationIds, String pEmpId){
String sql = "select b.mainid,b.empid,b.filters,b.sqltj,b.bdate,b.edate,a.list_type from uf_ryqz a left join uf_ryqz_dt1 b on a.id=b.mainid where mainid in ("+String.join(",",personOrganzationIds)+")";
List<Map<String,Object>> personGroupDataList = DbTools.getSqlToList(sql);
Map<String,Set<String>> personGroupUserIds = Maps.newHashMap();
for (Map<String,Object> personGroupData :personGroupDataList){
String id = Util.null2String(personGroupData.get("mainid"));
String empid = Util.null2String(personGroupData.get("empid"));
String filters = Util.null2String(personGroupData.get("filters"));
String list_type = Util.null2String(personGroupData.get("list_type"));
String sqltj = Util.null2String(personGroupData.get("sqltj"));
Set<String> userIds = personGroupUserIds.get(id);
if (userIds == null){
userIds = Sets.newHashSet();
personGroupUserIds.put(id,userIds);
}
if ("0".equals(list_type) && !"".equals(empid)){
//人员清单
if (empid.equals(pEmpId))
userIds.add(empid);
}else if ("1".equals(list_type) && !"".equals(filters)){
//条件清单
sql = "select id,seclevel from hrmresource where status <> '5' and status <> '4' and status <> '7' ";
filters = filters.replace("","and");
filters = filters.replace("","or");
if (filters.contains("field")){
sql = "select a.id,a.seclevel from hrmresource a left join cus_fielddata b on a.id=b.id where scope='HrmCustomFieldByInfoType' and a.status <> '5' and a.status <> '4' and a.status <> '7' and "+filters;
}else {
sql = sql+ " and "+filters;
}
sql = "select * from (" + sql + ") where id = " + pEmpId;
log.info("getPersonnelGroupingByPerson filter sql : {}",sql);
List<Map<String,Object>> dataList = DbTools.getSqlToList(sql);
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
String seclevel = Util.null2String(dataMap.get("seclevel"));
userIds.add(hrmId);
}
}else if ("2".equals(list_type) && !"".equals(sqltj)){
sqltj = Utils.converSQL(sqltj);
sqltj = "select * from (" + sqltj + ") where id = " + pEmpId;
log.debug("getPersonnelGroupingByPerson sqltj : [{}]",sqltj);
List<Map<String,Object>> dataList = DbTools.getSqlToList(sqltj);
for (Map<String,Object> dataMap :dataList){
String hrmId = Util.null2String(dataMap.get("id"));
userIds.add(hrmId);
}
}
}
return personGroupUserIds;
}
/**
*
* @param personOrganzationIds
@ -301,4 +380,22 @@ public class GetPersonVocationBySuitOrganzation extends AbstractCommonCommand<Ma
}
return userIds;
}
/**
*
* @param vocation
* @param pEmpId
* @return
*/
public List<String> getUserIds(Map<String,Object> vocation, String pEmpId){
List<String> userIds = Lists.newArrayList();
String edyj = Util.null2String(vocation.get("edyj"));
if (edyj.equals("3") || edyj.equals("4")){
String zyz = "select ID from ("+Util.null2String(vocation.get("zyz"))+") where id = " + pEmpId;
zyz = Utils.converSQL(zyz);
List<Map<String,Object>> dataList = DbTools.getSqlToList(zyz);
userIds = dataList.stream().map(e->Util.null2String(e.get("id"))).collect(Collectors.toList());
}
return userIds;
}
}

@ -87,6 +87,8 @@ public class CommonUtil {
* @return
*/
public static boolean insertBatch(List<Map<String,Object>> dataList, String tableName){
if (dataList.size() == 0)
return true;
String sql = "insert into "+tableName;
String key = "(";
String value = "(";
@ -479,6 +481,25 @@ public class CommonUtil {
return tableName;
}
/**
*
* @param tableName
* @param columnName
* @param condition
* @return
*/
public static List<String> getUniqueItems(String tableName,String columnName,String condition) {
List<String> itemList = new ArrayList<>();
String sql = "select distinct " + columnName + " from " + tableName;
if (!"".equals(condition))
sql = sql + " where " + condition;
List<Map<String,Object>> dataDetail = DbTools.getSqlToList(sql);
for (Map<String,Object> dataMap :dataDetail) {
itemList.add(dataMap.get(columnName).toString());
}
return itemList;
}
/**
* iddataIdmodeId
* @param dataId
@ -1079,6 +1100,7 @@ public class CommonUtil {
*
*/
public static void initExtensionClassHolder(){
//查询业务代码集成表
String sql = "select id,jkdzlwj,jkdzsxlx,zt,zhsx,jkdzdybc from uf_jcl_kq_ywdmjc where zt=0";
List<Map<String,Object>> dataList = DbTools.getSqlToList(sql);
sql = "select a.id,b.csmc,b.csz from uf_jcl_kq_ywdmjc a left join uf_jcl_kq_ywdmjc_dt1 b on a.id=b.mainid where a.zt=0";
@ -1130,6 +1152,62 @@ public class CommonUtil {
}
/**
*
* id
*/
public static void initExtensionClassHolder(String pEmpId){
String sql = "select id,jkdzlwj,jkdzsxlx,zt,zhsx,jkdzdybc from uf_jcl_kq_ywdmjc where zt=0";
List<Map<String,Object>> dataList = DbTools.getSqlToList(sql);
sql = "select a.id,b.csmc,b.csz from uf_jcl_kq_ywdmjc a left join uf_jcl_kq_ywdmjc_dt1 b on a.id=b.mainid where a.zt=0";
Map<String,List<Map<String,Object>>> detailDataGroupMap = DbTools.getSqlToList(sql).stream().collect(Collectors.groupingBy(e->e.get("id").toString()));
try {
/**
*
*/
List<AbstractAdjustClockPointAction> adjustClockPointAction = Lists.newArrayList();
List<Map<String,Object>> adjustClockPointActionResultList = dataList.stream().filter(e->"0".equals(e.get("jkdzsxlx"))).sorted(Comparator.comparing(e->Integer.valueOf(e.get("zhsx").toString()))).collect(Collectors.toList());
for (Map<String,Object> adjustClockPointActionMap:adjustClockPointActionResultList){
String classPath = adjustClockPointActionMap.get("jkdzlwj").toString();
AbstractAdjustClockPointAction action = (AbstractAdjustClockPointAction)Class.forName(classPath).newInstance();
action.setApplyClasses(Util.null2String(adjustClockPointActionMap.get("jkdzdybc")));
List<Map<String,Object>> detailDataList = detailDataGroupMap.get(adjustClockPointActionMap.get("id"));
if (detailDataList != null && detailDataList.size() > 0){
Map<String,String> paramMap = Maps.newHashMap();
for (Map<String,Object> detailData:detailDataList){
paramMap.put(Util.null2String(detailData.get("csmc")),Util.null2String(detailData.get("csz")));
}
action.setParams(paramMap);
}
adjustClockPointAction.add(action);
}
ExtensionClassHolder.setAdjustClockPointAction(adjustClockPointAction);
/**
*
*/
sql = "select csm id,csz name from uf_jcl_kq_globalset where zt=0";
Map<String,Object> globalMap = DbTools.getSqlToMapList(sql);
ExtensionClassHolder.setGlobalSetMap(globalMap);
/**
*
*/
ExtensionClassHolder.setPersonBelongGroupThreadLocal(PersongroupCommonUtil.getAllpersonBelongGroup(pEmpId));
/**
*
*/
initPersonInfromation(pEmpId);
}catch (Exception e){
log.error("initExtensionClassHolder fail");
throw new AttendanceRunTimeException("初始化扩展类失败");
}
}
/**
*
*/
@ -1163,6 +1241,40 @@ public class CommonUtil {
}
}
/**
*
* ID
*/
public static void initPersonInfromation(String pEmpId){
/**
*
*/
try {
String sql = "select id,departmentid,subcompanyid1 from hrmresource where id = " + pEmpId;
List<Map<String,Object>> hrmresourceList = DbTools.getSqlToList(sql);
Map<String,Map<String,Object>> hrmresourceInformationMap = Maps.newHashMap();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
Map<String,String> departInfo = Maps.newHashMap();
for (Map<String,Object> map :hrmresourceList){
String pdeptids = departInfo.get(Util.null2String(map.get("departmentid")));
if (pdeptids == null || pdeptids.equals("")){
pdeptids="";
pdeptids = departmentComInfo.getAllParentDepartId(Util.null2String(map.get("departmentid")), pdeptids);
pdeptids = Util.null2String(map.get("departmentid")) + pdeptids;
departInfo.put(Util.null2String(map.get("departmentid")),pdeptids);
}
map.put("pdeptids",pdeptids);
hrmresourceInformationMap.put(map.get("id").toString(),map);
}
ExtensionClassHolder.setPersonInformationThreadLocal(hrmresourceInformationMap);
ExtensionClassHolder.setPetDepartMentThreadLocal(departInfo);
}catch (Exception e){
log.error("initPersonInfromation fail");
throw new AttendanceRunTimeException("初始化人员信息失败");
}
}
/**
*

@ -237,11 +237,20 @@ public class DateUtil {
* @return
*/
public static int getBetWeenDays(String startTime,String endTime){
LocalDate startDate = LocalDate.parse(startTime);
LocalDate endDate = LocalDate.parse(endTime);
long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
return Math.toIntExact(daysBetween);
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date bdate = dateFormat.parse(startTime);
LocalDateTime localBDate = bdate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
LocalDate startDate = localBDate.toLocalDate();
Date edate = dateFormat.parse(endTime);
LocalDateTime localEDate = edate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
LocalDate endDate = localEDate.toLocalDate();
long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
return Math.toIntExact(daysBetween);
} catch (ParseException e) {
e.printStackTrace();
return 0;
}
}
/**
*

@ -20,7 +20,12 @@ public class LunarCalendar {
/**
*
*/
final static String chineseNumber[] = { "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊" };
final public static String chineseMonthNumber[] = { "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊" };
/**
*
*/
final static String chineseDateNumber[] = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" };
/**
*
*/
@ -223,21 +228,26 @@ public class LunarCalendar {
if (day > 30) {
return "";
}
if (day == 10) {
return "初十";
} else {
return chineseTen[day / 10] + chineseNumber[n];
switch (day){
case 10:
return "初十";
case 20:
return "二十";
case 30:
return "三十";
default:
return chineseTen[day / 10] + chineseDateNumber[n];
}
}
@Override
public String toString() {
return year + "年" + (leap ? "闰" : "") + chineseNumber[month - 1] + "月" + getChinaDayString(day);
return year + "年" + (leap ? "闰" : "") + chineseMonthNumber[month - 1] + "月" + getChinaDayString(day);
}
final public String traditionLunarDay() {
//return cyclical() + animalsYear() + "年" + (leap ? "闰" : "") + chineseNumber[month - 1] + "月" + getChinaDayString(day);
return (leap ? "闰" : "") + chineseNumber[month - 1] + "月" + getChinaDayString(day);//暂时移除农历年的显示
return (leap ? "闰" : "") + chineseMonthNumber[month - 1] + "月" + getChinaDayString(day);//暂时移除农历年的显示
}
public int getYear() {

Loading…
Cancel
Save