package com.engine.attendance.vacation.cmd; import com.engine.attendance.component.persongroup.job.scheduling.tactics.RegularScheduling; import com.engine.attendance.vacation.job.holidaygeneration.tactics.HolidayGenerationWay; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.common.util.DbTools; import com.engine.common.util.Utils; import com.engine.core.interceptor.CommandContext; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import weaver.general.Util; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @Slf4j public class VocationCmd extends AbstractCommonCommand> { @Override public BizLogContext getLogContext() { return null; } public VocationCmd(Map params){ this.params=params; } private List rulers; { rulers = new Utils().getAllClassByInterface(HolidayGenerationWay.class); } @Override public Map execute(CommandContext commandContext) { List> vocationList = (List>)params.get("vocationList"); List> userList = (List>)params.get("userList"); List> userfilter = userList.stream().filter(e->"-1".equals(e.get("scopeid"))).collect(Collectors.toList()); Map userMap = userfilter.size()>0?userfilter.get(0):Maps.newHashMap(); for (Map vocation : vocationList){ log.debug("qsrq : [{}],yjzd : [{}]",vocation.get("qsrq"),vocation.get("yjzd")); String qsrq = Util.null2String(vocation.get("qsrq")).toLowerCase(); String yjzd = Util.null2String(vocation.get("yjzd")).toLowerCase(); String ljcrglyfslwz = Util.null2String(vocation.get("ljcrglyfslwz")); String qsrqValue = Util.null2String(userMap.get(qsrq)); String yjzdValue = Util.null2String(userMap.get(yjzd)); String ljcrglyfslwzValue = Util.null2String(userMap.get(ljcrglyfslwz)); if ("".equals(qsrqValue)){ for (Map map: userList){ qsrqValue = Util.null2String(map.get(qsrq)); if (!"".equals(qsrqValue)){ break; } } } if ("".equals(yjzdValue)){ for (Map map: userList){ yjzdValue = Util.null2String(map.get(yjzd)); if (!"".equals(yjzdValue)){ break; } } } if ("".equals(ljcrglyfslwzValue)){ for (Map map: userList){ ljcrglyfslwzValue = Util.null2String(map.get(ljcrglyfslwz)); if (!"".equals(ljcrglyfslwzValue)){ break; } } } vocation.put("qsrqValue",qsrqValue); vocation.put("yjzdValue",yjzdValue); vocation.put("ljcrglyfslwzValue",ljcrglyfslwzValue); vocation.put("zyzValue",getUserIds(vocation)); } log.info("VocationCmd params: [{}]",params); String edfffs = Util.null2String(vocationList.get(0).get("edfffs")); for (HolidayGenerationWay holidayGenerationWay :rulers){ if (holidayGenerationWay.support(Integer.valueOf(edfffs))){ holidayGenerationWay.compute(params); } } return null; } public List getUserIds(Map vocation){ List userIds = Lists.newArrayList(); String edyj = Util.null2String(vocation.get("edyj")); if (edyj.equals("3") || edyj.equals("4")){ String zyz = Util.null2String(vocation.get("zyz")); zyz = zyz.replace("and","and"); zyz = zyz.replace("or","or"); List> dataList = DbTools.getSqlToList(zyz); userIds = dataList.stream().map(e->Util.null2String(e.get("id"))).collect(Collectors.toList()); } return userIds; } }