1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549 |
- package com.kingdee.eas.custom.utils;
- import java.math.BigDecimal;
- import java.math.RoundingMode;
- import java.sql.SQLException;
- import java.sql.Timestamp;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.Map.Entry;
- import java.util.Set;
- import org.apache.axis.utils.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import com.kingdee.bos.BOSException;
- import com.kingdee.bos.Context;
- import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
- import com.kingdee.bos.util.BOSUuid;
- import com.kingdee.eas.basedata.org.AdminOrgUnitFactory;
- import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
- import com.kingdee.eas.basedata.person.PersonInfo;
- import com.kingdee.eas.common.EASBizException;
- import com.kingdee.eas.custom.ats.AtsLeaveBillDetailSameInfo;
- import com.kingdee.eas.framework.CoreBaseCollection;
- import com.kingdee.eas.hr.ats.AtsHolidayFileFactory;
- import com.kingdee.eas.hr.ats.AtsHolidayFileHisCollection;
- import com.kingdee.eas.hr.ats.AtsHolidayFileHisFactory;
- import com.kingdee.eas.hr.ats.AtsHolidayFileHisInfo;
- import com.kingdee.eas.hr.ats.AtsHolidayFileInfo;
- import com.kingdee.eas.hr.ats.AtsLeaveBillDetailFactory;
- import com.kingdee.eas.hr.ats.AtsLeaveBillDetailInfo;
- import com.kingdee.eas.hr.ats.AtsLeaveBillEntryCollection;
- import com.kingdee.eas.hr.ats.AtsLeaveBillEntryFactory;
- import com.kingdee.eas.hr.ats.AtsLeaveBillEntryInfo;
- import com.kingdee.eas.hr.ats.AtsLeaveBillFactory;
- import com.kingdee.eas.hr.ats.AtsLeaveBillInfo;
- import com.kingdee.eas.hr.ats.AtsLeaveBillResEnum;
- import com.kingdee.eas.hr.ats.AtsShiftCollection;
- import com.kingdee.eas.hr.ats.AtsShiftFactory;
- import com.kingdee.eas.hr.ats.AtsShiftInfo;
- import com.kingdee.eas.hr.ats.AtsShiftItemCollection;
- import com.kingdee.eas.hr.ats.AtsShiftItemFactory;
- import com.kingdee.eas.hr.ats.AtsShiftItemInfo;
- import com.kingdee.eas.hr.ats.AttencePolicyFactory;
- import com.kingdee.eas.hr.ats.AttencePolicyInfo;
- import com.kingdee.eas.hr.ats.AttendanceFileCollection;
- import com.kingdee.eas.hr.ats.AttendanceFileHISInfo;
- import com.kingdee.eas.hr.ats.AttendanceFileInfo;
- import com.kingdee.eas.hr.ats.AttendanceTypeEnum;
- import com.kingdee.eas.hr.ats.BreastFeedingTypeCollection;
- import com.kingdee.eas.hr.ats.BreastFeedingTypeFactory;
- import com.kingdee.eas.hr.ats.BreastFeedingTypeInfo;
- import com.kingdee.eas.hr.ats.DayTypeEnum;
- import com.kingdee.eas.hr.ats.HolidayPolicyFactory;
- import com.kingdee.eas.hr.ats.HolidayPolicyInfo;
- import com.kingdee.eas.hr.ats.HolidayPolicySetFactory;
- import com.kingdee.eas.hr.ats.HolidayPolicySetInfo;
- import com.kingdee.eas.hr.ats.HolidayTypeUnitEnum;
- import com.kingdee.eas.hr.ats.IAtsLeaveBillDetail;
- import com.kingdee.eas.hr.ats.ScheduleShiftFactory;
- import com.kingdee.eas.hr.ats.ScheduleShiftInfo;
- import com.kingdee.eas.hr.ats.ScheduleShiftItemCollection;
- import com.kingdee.eas.hr.ats.ScheduleShiftItemFactory;
- import com.kingdee.eas.hr.ats.ScheduleShiftItemInfo;
- import com.kingdee.eas.hr.ats.WorkCalendarFactory;
- import com.kingdee.eas.hr.ats.WorkCalendarInfo;
- import com.kingdee.eas.hr.ats.WorkCalendarItemCollection;
- import com.kingdee.eas.hr.ats.WorkCalendarItemFactory;
- import com.kingdee.eas.hr.ats.WorkCalendarItemInfo;
- import com.kingdee.eas.hr.ats.biz.util.AtsLeaveBillUtil;
- import com.kingdee.eas.hr.ats.calculate.AtsCacheUtil;
- import com.kingdee.eas.hr.ats.calcutePrepareData.AtsPrepareDataHelper;
- import com.kingdee.eas.hr.ats.decimalPlace.util.DecimalPlaceUtil;
- import com.kingdee.eas.hr.ats.lightapp.util.HRTimeWebUtils;
- import com.kingdee.eas.hr.ats.util.AtsDateUtils;
- import com.kingdee.eas.hr.ats.util.AtsLeaveBillUtils;
- import com.kingdee.eas.hr.ats.util.AtsScheduleShiftUtil;
- import com.kingdee.eas.hr.ats.util.AtsServerUtils;
- import com.kingdee.eas.hr.ats.util.SHRBillServerUtil;
- import com.kingdee.eas.hr.ats.util.common.AtsCollectionUtile;
- import com.kingdee.eas.hr.ats.util.common.MLUtile;
- import com.kingdee.eas.hr.emp.PersonPositionInfo;
- import com.kingdee.eas.util.app.DbUtil;
- import com.kingdee.jdbc.rowset.IRowSet;
- import com.kingdee.util.UuidException;
- public class SplitLeaveUtils {
- private AtsLeaveBillInfo billInfo;
- private AtsLeaveBillEntryInfo atsLeaveBillEntryInfo;
- private Context ctx;
- private String personId;
- private Boolean isIncludeLegal;
- private Boolean isIncludeRest;
- private HolidayPolicyInfo holidayPolicyInfo;
- private BigDecimal sourceLen = new BigDecimal(0);
- private BigDecimal defaultStandardHour = BigDecimal.valueOf(24L);
- private int decimalPlaceValue = 2;
- private static final Logger logger = LoggerFactory.getLogger(SplitLeaveUtils.class);
- public SplitLeaveUtils(Context ctx, BOSUuid billId) throws EASBizException, BOSException {
- this.billInfo = AtsLeaveBillFactory.getLocalInstance(ctx)
- .getAtsLeaveBillInfo(new ObjectUuidPK(billId.toString()));
- AtsLeaveBillEntryCollection billEntryColl = AtsLeaveBillEntryFactory.getLocalInstance(ctx)
- .getAtsLeaveBillEntryCollection(" where bill='" + this.billInfo.getId().toString() + "'");
- this.atsLeaveBillEntryInfo = billEntryColl.get(0);
- this.ctx = ctx;
- this.personId = this.atsLeaveBillEntryInfo.getPerson().getId().toString();
- this.holidayPolicyInfo = HolidayPolicyFactory.getLocalInstance(ctx)
- .getHolidayPolicyInfo(" where id='" + this.atsLeaveBillEntryInfo.getPolicy().getId().toString() + "'");
- this.isIncludeLegal = this.holidayPolicyInfo.isIsIncludeLegal();
- this.isIncludeRest = this.holidayPolicyInfo.isIsIncludeRest();
- this.decimalPlaceValue = DecimalPlaceUtil.getDecimalPlaceSystem(ctx);
- }
- public SplitLeaveUtils(Context ctx, AtsLeaveBillInfo billInfo, AtsLeaveBillEntryInfo atsLeaveBillEntryInfo)
- throws EASBizException, BOSException {
- this.billInfo = billInfo;
- this.atsLeaveBillEntryInfo = atsLeaveBillEntryInfo;
- this.ctx = ctx;
- this.personId = atsLeaveBillEntryInfo.getPerson().getId().toString();
- this.holidayPolicyInfo = HolidayPolicyFactory.getLocalInstance(ctx)
- .getHolidayPolicyInfo(" where id='" + atsLeaveBillEntryInfo.getPolicy().getId().toString() + "'");
- this.isIncludeLegal = this.holidayPolicyInfo.isIsIncludeLegal();
- this.isIncludeRest = this.holidayPolicyInfo.isIsIncludeRest();
- }
- public List<Map<String, Object>> getSplitLeaveBill() throws EASBizException, BOSException {
- logger.info("AtsLeaveBillSameSplitHelper....splitLeaveBill....start");
- logger.info(MLUtile.getRes(AtsLeaveBillResEnum.StartSplitLeaveBill, this.ctx) + "...");
- Timestamp beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
- Timestamp endTime = this.atsLeaveBillEntryInfo.getRealEndTime();
- List<Date> dateList = this.getLeaveDateColl(beginTime, endTime);
- List<Date> dateListAfter = this.dealDateNew(dateList);
- String oql = " select holidayPolicySet.isHalfDayOff,holidayPolicySet.isHalfDayOff,holidayPolicySet.amStartWorkTime,holidayPolicySet.amEndWorkTime,holidayPolicySet.pmStartWorkTime,holidayPolicySet.pmEndWorkTime where proposer.id='"
- + this.personId + "' and attendFileState='1' ";
- AtsHolidayFileInfo holidayFileInfo = AtsHolidayFileFactory.getLocalInstance(this.ctx)
- .getAtsHolidayFileInfo(oql);
- Map<String, Object> dateLenMap = null;
- HolidayPolicySetInfo holidayPolicySetInfo = holidayFileInfo.getHolidayPolicySet();
- if (null != this.holidayPolicyInfo && null != this.holidayPolicyInfo.getHolidayType()
- && this.holidayPolicyInfo.getHolidayType().getId().toString().equals("8r0AAAAMhrv9LVKY")
- && null != this.atsLeaveBillEntryInfo.getBfType()
- && !this.atsLeaveBillEntryInfo.getBfType().getId().toString().equals("8r0AAAA09p9IT3K3")) {
- dateLenMap = this.calRealLeaveLengthOfBF(dateListAfter, beginTime, endTime,
- this.atsLeaveBillEntryInfo.getRealUnit(), holidayFileInfo, holidayPolicySetInfo,
- this.holidayPolicyInfo);
- } else if (null != this.holidayPolicyInfo && this.holidayPolicyInfo.isIsHalfDayOff()) {
- dateLenMap = this.calRealLeaveLengthOfDay(dateListAfter, beginTime, endTime,
- this.atsLeaveBillEntryInfo.getRealUnit(), holidayFileInfo, holidayPolicySetInfo,
- this.holidayPolicyInfo);
- } else {
- dateLenMap = this.calRealLeaveLengthInfo(dateListAfter, beginTime, endTime,
- this.atsLeaveBillEntryInfo.getRealUnit(), holidayFileInfo, this.holidayPolicyInfo);
- }
- List<Map<String, Object>> leaveDetailList = this.getLeaveBillDetail(dateLenMap);
- return leaveDetailList;
- }
- private List<Map<String, Object>> getLeaveBillDetail(Map<String, Object> dateLenMap) throws BOSException, EASBizException {
- logger.info("AtsLeaveBillSameSplitHelper....insertleaveBillDetail....start");
- HolidayTypeUnitEnum holidayTypeUnit = this.atsLeaveBillEntryInfo.getRealUnit();
- Object[] key = dateLenMap.keySet().toArray();
- Arrays.sort(key);
- BigDecimal leavelen = this.atsLeaveBillEntryInfo.getRealLeaveLength();
- Object map = new HashMap();
- List<Map<String, Object>> leaveDetailList = new ArrayList<>();
- try {
- AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
- HRTimeWebUtils.stringShortToTimestamp(key[0].toString()),
- HRTimeWebUtils.stringShortToTimestamp(key[key.length - 1].toString()), this.personId,
- (String) null);
- AtsHolidayFileHisCollection atsHolidayFileHisCollection = null;
- AtsHolidayFileHisInfo atsHolidayFileHisInfo = null;
- atsHolidayFileHisCollection = AtsHolidayFileHisFactory.getLocalInstance(this.ctx)
- .getAtsHolidayFileHisCollection("where proposer.id='" + this.personId + "' order by effdt asc");
- if (null != atsHolidayFileHisCollection && atsHolidayFileHisCollection.size() > 0) {
- for (int i = 0; i < atsHolidayFileHisCollection.size(); ++i) {
- AtsHolidayFileHisInfo atsHolidayFileHis = atsHolidayFileHisCollection.get(i);
- if (HRTimeWebUtils.stringShortToTimestamp(key[0].toString()).getTime() >= atsHolidayFileHis
- .getEFFDT().getTime()
- && HRTimeWebUtils.stringShortToTimestamp(key[key.length - 1].toString())
- .getTime() <= atsHolidayFileHis.getLEFFDT().getTime()) {
- atsHolidayFileHisInfo = atsHolidayFileHisCollection.get(i);
- }
- }
- }
- map = getWorkCalendarItemInfoByDate(this.ctx, key[0].toString(),
- key[key.length - 1].toString(),attendanceFileHisInfo,atsHolidayFileHisInfo);
- } catch (Exception var21) {
- var21.printStackTrace();
- }
- int len = key.length;
- for (int i = 0; i < len; ++i) {
- ScheduleShiftInfo scheduleShiftInfo = AtsScheduleShiftUtil.getScheduleShiftByPriority(this.ctx,
- this.personId, new Date(HRTimeWebUtils.stringToTimestamp(key[i] + " 00:00:00").getTime()));
- if (scheduleShiftInfo == null) {
- String keyStr = key[i].toString().substring(0, 10);
- WorkCalendarItemInfo workCalendarItemInfo = (WorkCalendarItemInfo) ((Map) map).get(keyStr);
- if (workCalendarItemInfo == null || workCalendarItemInfo.getDayType() == null
- || !this.holidayPolicyInfo.isIsIncludeRest() && (null == workCalendarItemInfo
- || workCalendarItemInfo.getDayType() == DayTypeEnum.restDay
- || workCalendarItemInfo.getDayType() == DayTypeEnum.legalHoliday)) {
- continue;
- }
- }
- Map<String, Double> dateMap = (Map) dateLenMap.get(key[i]);
- new BigDecimal(0);
- BigDecimal tempLen;
- if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
- tempLen = BigDecimal.valueOf((Double) dateMap.get("calDay"));
- if (this.holidayPolicyInfo.isIsRoundSum()) {
- tempLen = BigDecimal.valueOf(this.getValueByMinLeaveLength(this.holidayPolicyInfo, tempLen));
- }
- if (leavelen.compareTo(tempLen) > 0 && i != len - 1) {
- leavelen = leavelen.subtract(tempLen);
- } else {
- tempLen = leavelen;
- }
- } else {
- tempLen = BigDecimal.valueOf((Double) dateMap.get("calHour"));
- if (this.holidayPolicyInfo.isIsRoundSum()) {
- tempLen = BigDecimal.valueOf(this.getValueByMinLeaveLength(this.holidayPolicyInfo, tempLen));
- }
- if (leavelen.compareTo(tempLen) > 0 && i != len - 1) {
- leavelen = leavelen.subtract(tempLen);
- } else {
- tempLen = leavelen;
- }
- }
-
- if (leavelen.compareTo(BigDecimal.valueOf(0L)) == 0) {
- break;
- }
- List<Map<String, Object>> dateList = this.getLeaveSuchScheduleDetal(
- HRTimeWebUtils.stringToTimestamp(key[i].toString().substring(0, 10) + " 00:00:00"), this.personId,
- tempLen);
- Date currDate = AtsDateUtils.stringToShortDate((String) key[i]);
- for(int j=0;j<dateList.size();j++) {
- Map<String, Object> detailMap = dateList.get(j);
- detailMap.put("personId", this.personId);
- detailMap.put("currDate", currDate);
- leaveDetailList.add(detailMap);
- }
- }
- return leaveDetailList;
- }
-
- public static Map<String, WorkCalendarItemInfo> getWorkCalendarItemInfoByDate(Context ctx, String beginDate, String endDate, AttendanceFileHISInfo attendanceFileHisInfo, AtsHolidayFileHisInfo atsHolidayFileHisInfo) throws BOSException, UuidException, SQLException {
- Map<String, WorkCalendarItemInfo> infoMap = new HashMap();
- WorkCalendarItemCollection itemColl = null;
- String itemCollKey;
- String oql;
- if (attendanceFileHisInfo != null && attendanceFileHisInfo.getCalendar().getId() != null) {
- itemCollKey = attendanceFileHisInfo.getCalendar().getId().toString();
- oql = " where date >='" + beginDate + "' and date <='" + endDate + "' and calendargroup.id = '" + itemCollKey + "'";
- itemColl = WorkCalendarItemFactory.getLocalInstance(ctx).getWorkCalendarItemCollection(oql);
- } else if (atsHolidayFileHisInfo != null && atsHolidayFileHisInfo.getCalendar().getId() != null) {
- itemCollKey = atsHolidayFileHisInfo.getCalendar().getId().toString();
- oql = " where date >='" + beginDate + "' and date <='" + endDate + "' and calendargroup.id = '" + itemCollKey + "'";
- itemColl = WorkCalendarItemFactory.getLocalInstance(ctx).getWorkCalendarItemCollection(oql);
- } else {
- itemCollKey = "workCalendarItem_" + beginDate + "_" + endDate;
- itemColl = (WorkCalendarItemCollection)AtsCacheUtil.get(itemCollKey);
- }
- for(int i = 0; i < itemColl.size(); ++i) {
- WorkCalendarItemInfo itemInfo = itemColl.get(i);
- String datestr = AtsDateUtils.dateShortToString(itemInfo.getDate());
- infoMap.put(datestr, itemInfo);
- }
- return infoMap;
- }
- private List<Map<String, Object>> getLeaveSuchScheduleDetal(Timestamp date, String personId, BigDecimal dataLen)
- throws BOSException {
- List<Map<String, Object>> list = new ArrayList();
- AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx, date, date,
- personId, (String) null);
- ScheduleShiftInfo scheduleShiftInfo = null;
- new HashMap();
- AtsShiftItemCollection shiftItemColl = new AtsShiftItemCollection();
- try {
- HashMap<String, Object> dateMap = AtsLeaveBillUtils.getScheduleShiftItemCollByDate(this.ctx, personId, date,
- this.holidayPolicyInfo.isIsFixOTAllowLeave());
- ScheduleShiftItemCollection scheduleShiftItemColl = (ScheduleShiftItemCollection) dateMap
- .get("scheduleShiftItemColl");
- int i;
- AtsShiftItemInfo info;
- if (null != scheduleShiftItemColl && scheduleShiftItemColl.size() != 0) {
- this.defaultStandardHour = (BigDecimal) dateMap.get("standardHour");
- for (i = 0; i < scheduleShiftItemColl.size(); ++i) {
- info = null;
- AtsShiftItemInfo shiftItemInfo = null;
- ScheduleShiftItemInfo info1 = scheduleShiftItemColl.get(i);
- ScheduleShiftItemCollection scheduleShiftItemcolls = ScheduleShiftItemFactory
- .getLocalInstance(this.ctx)
- .getScheduleShiftItemCollection(" where id = '" + info1.getId().toString() + "'");
- AdminOrgUnitInfo attAdminOrgUnit;
- if (AtsCollectionUtile.isEmpty(scheduleShiftItemcolls)) {
- attAdminOrgUnit = attendanceFileHisInfo.getAttAdminOrgUnit();
- shiftItemInfo = AtsShiftItemFactory.getLocalInstance(this.ctx)
- .getAtsShiftItemInfo(new ObjectUuidPK(info1.getShiftItem().getId().toString()));
- } else {
- ScheduleShiftItemInfo newinfo = ScheduleShiftItemFactory.getLocalInstance(this.ctx)
- .getScheduleShiftItemInfo(new ObjectUuidPK(info1.getId().toString()));
- shiftItemInfo = this.createScheduleShiftItemToAtsShiftItem(this.ctx, newinfo);
- attAdminOrgUnit = newinfo.getAttAdminOrgUnit();
- }
- shiftItemInfo.setString("adminOrgUnit", attAdminOrgUnit.getId().toString());
- String groupId = info1.getGroup().getId().toString();
- scheduleShiftInfo = ScheduleShiftFactory.getLocalInstance(this.ctx)
- .getScheduleShiftInfo(new ObjectUuidPK(groupId));
- shiftItemInfo.getGroup().setIsElastic(scheduleShiftInfo.isIsElastic());
- shiftItemColl.add(shiftItemInfo);
- }
- } else {
- HashMap<String, Object> defaultItemMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx,
- attendanceFileHisInfo, this.holidayPolicyInfo);
- shiftItemColl = (AtsShiftItemCollection) defaultItemMap.get("scheduleShiftItemColl");
- for (i = 0; i < shiftItemColl.size(); ++i) {
- info = shiftItemColl.get(i);
- info.setString("adminOrgUnit", attendanceFileHisInfo.getAttAdminOrgUnit().getId().toString());
- }
- }
- Timestamp beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
- Timestamp endTime = this.atsLeaveBillEntryInfo.getEndTime();
- if (shiftItemColl.size() <= 0 && scheduleShiftItemColl.size() <= 0) {
- Map<String, Object> dataSpiltMap = new HashMap();
- dataSpiltMap.put("beginTime", "00:00");
- dataSpiltMap.put("endTime", "23:59");
- dataSpiltMap.put("leaveLength", dataLen);
- dataSpiltMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
- ((List) list).add(dataSpiltMap);
- return (List) list;
- }
- shiftItemColl.sort("segment");
- String curDate = HRTimeWebUtils.timestampToString(date);
- String dateBeginTime = HRTimeWebUtils.timestampToString(beginTime);
- String dateEndTime = HRTimeWebUtils.timestampToString(endTime);
- Map<String, Object> res = this.getIsCtrlHalfDayOff(this.ctx);
- boolean isHalfDayOff = (Boolean) res.get("isHalfDayOff");
- AtsShiftItemInfo shiftItemInfo;
- String curBeginTime;
- Timestamp shiftItemEndTime;
- if (curDate.equals(dateBeginTime.substring(0, 10) + " 00:00:00")) {
- if (isHalfDayOff) {
- beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
- endTime = HRTimeWebUtils
- .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("pmEndTime") + ":00");
- } else {
- shiftItemInfo = shiftItemColl.get(0);
- curBeginTime = this.getCurDate(shiftItemInfo.getPreTimeDayType().getValue(), curDate);
- shiftItemEndTime = HRTimeWebUtils
- .stringToTimestamp(curBeginTime + " " + shiftItemInfo.getPreTime() + ":00");
- if (shiftItemEndTime.getTime() > beginTime.getTime()) {
- beginTime = shiftItemEndTime;
- }
- shiftItemInfo = shiftItemColl.get(shiftItemColl.size() - 1);
- if (!dateBeginTime.substring(0, 10).equals(dateEndTime.substring(0, 10))) {
- String nextTime = this.getCurDate(shiftItemInfo.getNextTimeDayType().getValue(), curDate);
- endTime = HRTimeWebUtils
- .stringToTimestamp(nextTime + " " + shiftItemInfo.getNextTime() + ":00");
- }
- }
- }
- if (curDate.equals(dateEndTime.substring(0, 10) + " 00:00:00")) {
- if (isHalfDayOff) {
- if (!curDate.equals(dateBeginTime.substring(0, 10) + " 00:00:00")) {
- beginTime = HRTimeWebUtils
- .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("amBeginTime") + ":00");
- }
- endTime = this.atsLeaveBillEntryInfo.getRealEndTime();
- } else {
- shiftItemInfo = shiftItemColl.get(0);
- if (!dateBeginTime.substring(0, 10).equals(dateEndTime.substring(0, 10))) {
- curBeginTime = this.getCurDate(shiftItemInfo.getPreTimeDayType().getValue(),
- curDate.substring(0, 10));
- beginTime = HRTimeWebUtils
- .stringToTimestamp(curBeginTime + " " + shiftItemInfo.getPreTime() + ":00");
- }
- shiftItemInfo = shiftItemColl.get(shiftItemColl.size() - 1);
- curBeginTime = this.getCurDate(shiftItemInfo.getNextTimeDayType().getValue(),
- dateEndTime.substring(0, 10));
- shiftItemEndTime = HRTimeWebUtils.stringToTimestamp(
- curBeginTime.substring(0, 10) + " " + shiftItemInfo.getNextTime() + ":00");
- boolean elasticCalLen = scheduleShiftInfo != null && scheduleShiftInfo.isIsElastic()
- && this.atsLeaveBillEntryInfo.isIsElasticCalLen();
- if (shiftItemEndTime.getTime() < endTime.getTime() && !elasticCalLen) {
- endTime = shiftItemEndTime;
- }
- }
- }
- if (!curDate.substring(0, 10).equals(dateEndTime.substring(0, 10))
- && !curDate.substring(0, 10).equals(dateBeginTime.substring(0, 10))) {
- if (isHalfDayOff) {
- beginTime = HRTimeWebUtils
- .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("amBeginTime") + ":00");
- endTime = HRTimeWebUtils
- .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("pmEndTime") + ":00");
- } else {
- shiftItemInfo = shiftItemColl.get(0);
- curBeginTime = this.getCurDate(shiftItemInfo.getPreTimeDayType().getValue(),
- curDate.substring(0, 10));
- beginTime = HRTimeWebUtils
- .stringToTimestamp(curBeginTime + " " + shiftItemInfo.getPreTime() + ":00");
- if (beginTime.getTime() <= this.atsLeaveBillEntryInfo.getRealBeginTime().getTime()) {
- beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
- }
- shiftItemInfo = shiftItemColl.get(shiftItemColl.size() - 1);
- String curEndTime = this.getCurDate(shiftItemInfo.getNextTimeDayType().getValue(),
- curDate.substring(0, 10));
- endTime = HRTimeWebUtils
- .stringToTimestamp(curEndTime.substring(0, 10) + " " + shiftItemInfo.getNextTime() + ":00");
- }
- }
- list = this.getSpiltDate(beginTime, endTime, shiftItemColl, dataLen, curDate.substring(0, 10));
- } catch (EASBizException var22) {
- var22.printStackTrace();
- }
- return (List) list;
- }
- private List<Map<String, Object>> getSpiltDate(Timestamp beginDate, Timestamp endDate,
- AtsShiftItemCollection shiftItemColl, BigDecimal dataLen, String curDate) {
- List<Map<String, Object>> dataList = new ArrayList();
- AtsShiftItemCollection collection = new AtsShiftItemCollection();
- AtsShiftItemCollection overTimecoll = new AtsShiftItemCollection();
- for (int i = 0; i < shiftItemColl.size(); ++i) {
- AtsShiftItemInfo info = shiftItemColl.get(i);
- String preDay = this.getCurDate(info.getPreTimeDayType().getValue(), curDate);
- Timestamp perTime = HRTimeWebUtils.stringToTimestamp(preDay + " " + info.getPreTime() + ":00");
- String nextDay = this.getCurDate(info.getNextTimeDayType().getValue(), curDate);
- Timestamp nextTime = HRTimeWebUtils.stringToTimestamp(nextDay + " " + info.getNextTime() + ":00");
- if (beginDate.getTime() <= nextTime.getTime() && perTime.getTime() <= endDate.getTime()
- || info.getGroup().isIsElastic() && this.atsLeaveBillEntryInfo.isIsElasticCalLen()) {
- if (!this.holidayPolicyInfo.isIsFixOTAllowLeave()) {
- if (info.getAttendanceType() == AttendanceTypeEnum.normalAttance
- || info.getAttendanceType() == AttendanceTypeEnum.normalAttanceExcludExcep) {
- collection.add(info);
- }
- } else if (info.getAttendanceType() != AttendanceTypeEnum.normalAttance
- && info.getAttendanceType() != AttendanceTypeEnum.normalAttanceExcludExcep) {
- overTimecoll.add(info);
- } else {
- collection.add(info);
- }
- }
- }
- BigDecimal billTime = this.defaultStandardHour.multiply(new BigDecimal(3600000));
- this.sourceLen = dataLen.setScale(this.decimalPlaceValue, RoundingMode.HALF_UP);
- Map<String, Object> res = this.getIsCtrlHalfDayOff(this.ctx);
- boolean isHalfDayOff = (Boolean) res.get("isHalfDayOff");
- if (isHalfDayOff) {
- HashMap amMap;
- if (beginDate.getTime() == HRTimeWebUtils.stringToTimestamp(curDate + " " + res.get("amBeginTime") + ":00")
- .getTime()
- && endDate.getTime() == HRTimeWebUtils
- .stringToTimestamp(curDate + " " + res.get("pmEndTime") + ":00").getTime()) {
- amMap = new HashMap();
- amMap.put("leaveLength", new BigDecimal(1));
- amMap.put("beginTime", res.get("amBeginTime"));
- amMap.put("endTime", res.get("pmEndTime"));
- amMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
- ((List) dataList).add(amMap);
- } else if ((beginDate.getTime() != HRTimeWebUtils
- .stringToTimestamp(curDate + " " + res.get("amBeginTime") + ":00").getTime()
- || endDate.getTime() != HRTimeWebUtils
- .stringToTimestamp(curDate + " " + res.get("amEndTime") + ":00").getTime())
- && endDate.getTime() != HRTimeWebUtils
- .stringToTimestamp(curDate + " " + res.get("pmBeginTime") + ":00").getTime()) {
- amMap = new HashMap();
- amMap.put("leaveLength", this.sourceLen);
- amMap.put("beginTime", res.get("pmBeginTime"));
- amMap.put("endTime", res.get("pmEndTime"));
- amMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
- ((List) dataList).add(amMap);
- } else {
- amMap = new HashMap();
- amMap.put("leaveLength", this.sourceLen);
- amMap.put("beginTime", res.get("amBeginTime"));
- amMap.put("endTime", res.get("amEndTime"));
- amMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
- ((List) dataList).add(amMap);
- }
- } else {
- dataList = this.getDataSpiltMap((List) dataList, collection, curDate, beginDate, endDate, billTime,
- this.defaultStandardHour);
- if (overTimecoll.size() > 0) {
- dataList = this.getDataSpiltMap((List) dataList, overTimecoll, curDate, beginDate, endDate, billTime,
- this.defaultStandardHour);
- }
- if (this.sourceLen.compareTo(new BigDecimal(0)) == 1) {
- Map<String, Object> dataSpiltMap = (Map) ((List) dataList).get(((List) dataList).size() - 1);
- BigDecimal leaveLength = this.sourceLen.add((BigDecimal) dataSpiltMap.get("leaveLength"));
- ((Map) ((List) dataList).get(((List) dataList).size() - 1)).put("leaveLength", leaveLength);
- }
- }
- return (List) dataList;
- }
- private List<Map<String, Object>> getDataSpiltMap(List<Map<String, Object>> dataList,
- AtsShiftItemCollection collection, String curDate, Timestamp beginDate, Timestamp endDate,
- BigDecimal billTime, BigDecimal defaultHour) {
- for (int i = 0; i < collection.size(); ++i) {
- if (this.sourceLen.compareTo(new BigDecimal(0)) == 1) {
- Map<String, Object> dataSpiltMap = new HashMap();
- AtsShiftItemInfo info = collection.get(i);
- String beginTime = this.getCurDate(info.getPreTimeDayType().getValue(), curDate);
- Timestamp perTime = HRTimeWebUtils.stringToTimestamp(beginTime + " " + info.getPreTime() + ":00");
- String endTime = this.getCurDate(info.getNextTimeDayType().getValue(), curDate);
- Timestamp nextTime = HRTimeWebUtils.stringToTimestamp(endTime + " " + info.getNextTime() + ":00");
- BigDecimal time;
- BigDecimal item;
- if (i == 0) {
- new BigDecimal(0);
- if (nextTime.getTime() >= endDate.getTime()) {
- if (beginDate.getTime() <= perTime.getTime()) {
- beginDate = perTime;
- }
- item = new BigDecimal(endDate.getTime() - beginDate.getTime());
- if (item.compareTo(BigDecimal.ZERO) <= 0) {
- continue;
- }
- time = item.divide(billTime, this.decimalPlaceValue, 4);
- dataSpiltMap.put("beginTime", HRTimeWebUtils.timestampToString(beginDate).substring(11, 16));
- dataSpiltMap.put("endTime", HRTimeWebUtils.timestampToString(endDate).substring(11, 16));
- } else {
- item = new BigDecimal(nextTime.getTime() - beginDate.getTime());
- if (item.compareTo(BigDecimal.ZERO) <= 0) {
- continue;
- }
- time = item.divide(billTime, this.decimalPlaceValue, 4);
- dataSpiltMap.put("beginTime", HRTimeWebUtils.timestampToString(beginDate).substring(11, 16));
- dataSpiltMap.put("endTime", info.getNextTime());
- }
- this.sourceLen = this.getBigDecimal(defaultHour, dataSpiltMap, time);
- } else if (i != collection.size() - 1 && endDate.getTime() > nextTime.getTime()) {
- time = new BigDecimal(nextTime.getTime() - perTime.getTime());
- if (time.compareTo(BigDecimal.ZERO) <= 0) {
- continue;
- }
- item = time.divide(billTime, this.decimalPlaceValue, 4);
- dataSpiltMap.put("beginTime", info.getPreTime());
- dataSpiltMap.put("endTime", info.getNextTime());
- this.sourceLen = this.getBigDecimal(defaultHour, dataSpiltMap, item);
- } else {
- if (endDate.getTime() >= nextTime.getTime()) {
- endDate = nextTime;
- }
- time = new BigDecimal(endDate.getTime() - perTime.getTime());
- if (time.compareTo(BigDecimal.ZERO) <= 0) {
- continue;
- }
- item = time.divide(billTime, this.decimalPlaceValue, 4);
- dataSpiltMap.put("beginTime", info.getPreTime());
- dataSpiltMap.put("endTime", HRTimeWebUtils.timestampToString(endDate).substring(11, 16));
- this.sourceLen = this.getBigDecimal(defaultHour, dataSpiltMap, item);
- }
- dataSpiltMap.put("attAdminOrgUnit", info.getString("adminOrgUnit"));
- dataList.add(dataSpiltMap);
- }
- }
- return dataList;
- }
- private String getCurDate(int dateType, String curDate) {
- Date date = HRTimeWebUtils.stringToShortDate(curDate);
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- if (dateType == 0) {
- calendar.add(5, -1);
- } else if (dateType == 2) {
- calendar.add(5, 1);
- }
- return simpleDateFormat.format(calendar.getTime());
- }
- private BigDecimal getBigDecimal(BigDecimal defaultHour, Map<String, Object> dataSpiltMap, BigDecimal time) {
- new BigDecimal(0);
- BigDecimal value;
- if (this.holidayPolicyInfo.getUnit().getValue() == 1) {
- value = time;
- } else {
- value = defaultHour.multiply(time).setScale(this.decimalPlaceValue, 4);
- }
- if (this.sourceLen.compareTo(value) == 1) {
- dataSpiltMap.put("leaveLength", value);
- this.sourceLen = this.sourceLen.subtract(value);
- } else {
- dataSpiltMap.put("leaveLength", this.sourceLen);
- this.sourceLen = new BigDecimal(0);
- }
- return this.sourceLen;
- }
- private double getValueByMinLeaveLength(HolidayPolicyInfo holidayPolicyInfo, BigDecimal realLengthBigDecimal) {
- int saveLength = this.getSaveLength(this.ctx, holidayPolicyInfo);
- double length = realLengthBigDecimal.setScale(saveLength, 4).doubleValue();
- if (holidayPolicyInfo != null && holidayPolicyInfo.isEnableLeaveLength()) {
- double M = holidayPolicyInfo.getMinLeaveLength().doubleValue();
- int minLeaveLengthMtd = holidayPolicyInfo.getMinLeaveLengthVMtd().getValue();
- int ZNum = (int) (length / M);
- double XSNum = length % M;
- if (minLeaveLengthMtd == 1) {
- length = ((double) ZNum + Math.floor(XSNum / M)) * M;
- } else if (minLeaveLengthMtd == 2) {
- length = ((double) ZNum + Math.ceil(XSNum / M)) * M;
- } else if (minLeaveLengthMtd == 3) {
- length = (double) ((long) ZNum + Math.round(XSNum / M)) * M;
- }
- }
- return length;
- }
- public int getSaveLength(Context ctx, HolidayPolicyInfo holidayPolicyInfo) {
- int saveLength;
- if (holidayPolicyInfo != null && holidayPolicyInfo.isEnableLeaveLength()) {
- Double MinLeaveLength = holidayPolicyInfo.getMinLeaveLength().stripTrailingZeros().doubleValue();
- saveLength = getNumberDecimalDigits(MinLeaveLength);
- } else {
- saveLength = DecimalPlaceUtil.getDecimalPlaceSystem(ctx);
- }
- return saveLength;
- }
- public static int getNumberDecimalDigits(double number) {
- if (number == (double) ((long) number)) {
- return 0;
- } else {
- int i = 0;
- do {
- ++i;
- } while (number * Math.pow(10.0D, (double) i) % 1.0D != 0.0D);
- return i;
- }
- }
- private List dealDateNew(List<Date> dateList) throws EASBizException, BOSException {
- int length = dateList.size();
- String beginDate = AtsDateUtils.dateShortToString((Date) dateList.get(0));
- String endDate = AtsDateUtils.dateShortToString((Date) dateList.get(length - 1));
- String personIds = "'" + this.personId + "'";
- Map<String, ScheduleShiftInfo> scheduleShiftMap = AtsScheduleShiftUtil.getScheduleShiftByPriority(this.ctx,
- personIds, beginDate, endDate);
- Map<String, AttendanceFileInfo> attendanceFileMap = AtsServerUtils.getAttendanceFileInfoByPersonId(this.ctx,
- personIds, beginDate, endDate);
- int i;
- if (AtsCollectionUtile.isEmpty(attendanceFileMap)) {
- HolidayPolicySetInfo holidayPolicySetInfo = HolidayPolicySetFactory.getLocalInstance(this.ctx)
- .getHolidayPolicySetInfo("select workCalendar.id where id = '"
- + this.holidayPolicyInfo.getHolidayPolicySet().getId().toString() + "'");
- WorkCalendarItemCollection workCalendarItemColl = WorkCalendarItemFactory.getLocalInstance(this.ctx)
- .getWorkCalendarItemCollection(" where calendarGroup='"
- + holidayPolicySetInfo.getWorkCalendar().getId().toString() + "' and date>={ts'" + beginDate
- + "'} and date <={ts'" + endDate + "'} order by date asc ");
- if (this.holidayPolicyInfo.getHolidayPolicySet() != null) {
- for (i = 0; i < dateList.size(); ++i) {
- if (workCalendarItemColl.get(i) != null && workCalendarItemColl.get(i).getDayType() != null) {
- int dayType = workCalendarItemColl.get(i).getDayType().getValue();
- if (!this.isIncludeLegal && dayType == 2) {
- dateList.remove(i);
- workCalendarItemColl.remove(workCalendarItemColl.get(i));
- --i;
- } else if (!this.isIncludeRest && dayType == 1) {
- dateList.remove(i);
- workCalendarItemColl.remove(workCalendarItemColl.get(i));
- --i;
- }
- }
- }
- }
- } else {
- Set<String> unScheduleDateSet = new HashSet();
- Iterator var19 = dateList.iterator();
- label90 : while (true) {
- String scheduleShiftKey;
- Date date;
- do {
- if (!var19.hasNext()) {
- Map<String, Map> workCalendarItemMap = null;
- if (unScheduleDateSet.size() > 0) {
- workCalendarItemMap = this.getWorkCalendarItembyID(attendanceFileMap, unScheduleDateSet);
- }
- for (i = 0; i < dateList.size(); ++i) {
- Date currentDate = (Date) dateList.get(i);
- int dayType = 0;
- String scheduleShiftKey1 = this.personId + "_" + AtsDateUtils.dateShortToString(currentDate);
- if (scheduleShiftMap != null && scheduleShiftMap.get(scheduleShiftKey1) != null) {
- ScheduleShiftInfo scheduleShiftInfo = (ScheduleShiftInfo) scheduleShiftMap
- .get(scheduleShiftKey1);
- if (scheduleShiftInfo.getDayType() != null) {
- dayType = scheduleShiftInfo.getDayType().getValue();
- }
- } else {
- AttendanceFileInfo attendanceFileInfo = (AttendanceFileInfo) attendanceFileMap
- .get(scheduleShiftKey1);
- if (attendanceFileInfo != null && attendanceFileInfo.getAttencePolicy() != null
- && attendanceFileInfo.getAttencePolicy().getWorkCalendar() != null) {
- String workCalendarId = ((AttendanceFileInfo) attendanceFileMap
- .get(scheduleShiftKey1)).getAttencePolicy().getWorkCalendar().getId()
- .toString();
- if (workCalendarItemMap != null) {
- Map<String, WorkCalendarItemInfo> infoMap = (Map) workCalendarItemMap
- .get(workCalendarId);
- if (infoMap != null) {
- WorkCalendarItemInfo info = (WorkCalendarItemInfo) infoMap
- .get(AtsDateUtils.dateShortToString(currentDate));
- if (info != null && info.getDayType() != null) {
- dayType = info.getDayType().getValue();
- }
- }
- }
- }
- }
- if (!this.isIncludeLegal && dayType == 2) {
- dateList.remove(i);
- --i;
- } else if (!this.isIncludeRest && dayType == 1) {
- dateList.remove(i);
- --i;
- }
- }
- break label90;
- }
- date = (Date) var19.next();
- scheduleShiftKey = this.personId + "_" + AtsDateUtils.dateShortToString(date);
- } while (scheduleShiftMap != null && scheduleShiftMap.size() != 0
- && scheduleShiftMap.get(scheduleShiftKey) != null);
- unScheduleDateSet.add(AtsDateUtils.dateShortToString(date));
- }
- }
- return dateList;
- }
- private Map<String, Map> getWorkCalendarItembyID(Map<String, AttendanceFileInfo> attendanceFileMap,
- Set<String> unScheduleDateSet) throws BOSException {
- Map<String, Map> result = new HashMap();
- Set<String> workCalendarIds = new HashSet();
- Iterator var5 = attendanceFileMap.entrySet().iterator();
- while (var5.hasNext()) {
- Entry<String, AttendanceFileInfo> entry = (Entry) var5.next();
- if (entry.getValue() != null && ((AttendanceFileInfo) entry.getValue()).getCalendar() != null) {
- workCalendarIds.add(((AttendanceFileInfo) entry.getValue()).getCalendar().getId().toString());
- }
- }
- String workCalendarIdStr = AtsCollectionUtile.joinForSql(workCalendarIds);
- System.out.println("splitHelperError:" + convertSetToString(unScheduleDateSet));
- StringBuffer buffer = new StringBuffer();
- buffer.append("select FDayType,fid,FDate,FCalendarGroupID ").append(" from T_HR_ATS_WorkCalendarItem ")
- .append(" where FCalendarGroupID in (").append(workCalendarIdStr).append(") ").append(" and FDate in(")
- .append(convertSetToString(unScheduleDateSet)).append(") ");
- WorkCalendarItemCollection workCalendarItemColl = new WorkCalendarItemCollection();
- try {
- IRowSet row = DbUtil.executeQuery(this.ctx, buffer.toString());
- while (row.next()) {
- WorkCalendarItemInfo info = new WorkCalendarItemInfo();
- WorkCalendarInfo dar = new WorkCalendarInfo();
- info.setDayType(DayTypeEnum.getEnum(row.getInt("FDayType")));
- info.setId(BOSUuid.read(row.getString("fid")));
- dar.setId(BOSUuid.read(row.getString("FCalendarGroupID")));
- info.setCalendarGroup(dar);
- info.setDate(row.getDate("FDate"));
- workCalendarItemColl.add(info);
- }
- } catch (SQLException var14) {
- var14.printStackTrace();
- }
- Iterator var17 = workCalendarIds.iterator();
- while (var17.hasNext()) {
- String workCalendarId = (String) var17.next();
- Map<String, WorkCalendarItemInfo> workCalendarMap = new HashMap();
- Iterator var11 = unScheduleDateSet.iterator();
- while (var11.hasNext()) {
- String dateStr = (String) var11.next();
- for (int j = 0; j < workCalendarItemColl.size(); ++j) {
- if (workCalendarItemColl.get(j).getCalendarGroup().getId().toString().equals(workCalendarId)
- && workCalendarItemColl.get(j).getDate().toString().equals(dateStr)) {
- workCalendarMap.put(dateStr, workCalendarItemColl.get(j));
- }
- }
- }
- result.put(workCalendarId, workCalendarMap);
- }
- return result;
- }
- public static String convertSetToString(Set set) {
- if (set != null && set.size() > 0) {
- Iterator iter = set.iterator();
- StringBuffer sql = new StringBuffer();
- while (iter.hasNext()) {
- String date = iter.next().toString();
- if (date.length() > 0) {
- date = date.substring(0, 10);
- }
- sql.append("{ts'");
- sql.append(date);
- sql.append("'},");
- }
- sql.deleteCharAt(sql.length() - 1);
- return sql.toString();
- } else {
- return "''";
- }
- }
- private List getLeaveDateColl(Timestamp beginTime, Timestamp endTime) throws EASBizException, BOSException {
- List<Date> dateList = new ArrayList();
- Date beginDate = AtsDateUtils.stringToShortDate(AtsDateUtils.dateLongToString(beginTime));
- Date endDate = AtsDateUtils.stringToShortDate(AtsDateUtils.dateLongToString(endTime));
- Calendar beginCal = Calendar.getInstance();
- beginCal.setTime(beginDate);
- Calendar endCal = Calendar.getInstance();
- endCal.setTime(endDate);
- int temp = (int) ((endDate.getTime() - beginDate.getTime()) / 86400000L + 1L);
- for (int i = 0; i < temp; ++i) {
- int year = beginCal.get(1);
- int month = beginCal.get(2);
- int day = beginCal.get(5);
- Date tempDate = new Date(year - 1900, month, day);
- dateList.add(tempDate);
- beginCal.add(5, 1);
- }
- return dateList;
- }
- public Map<String, Object> calRealLeaveLengthInfo(List<Date> afterDealDateList, Date beginTimeCount,
- Date endTimeCount, HolidayTypeUnitEnum holidayTypeUnit, AtsHolidayFileInfo holidayFileInfo,
- HolidayPolicyInfo holidayPolicyInfo) {
- int tempAfterDealDateListSize = afterDealDateList.size();
- new AtsShiftItemCollection();
- Timestamp beginTimeCountTs = AtsDateUtils.dateToTimestamp(beginTimeCount);
- Timestamp endTimeCountTs = AtsDateUtils.dateToTimestamp(endTimeCount);
- HashMap defaultItemMap = new HashMap();
- try {
- AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
- beginTimeCountTs, endTimeCountTs, this.personId, (String) null);
- defaultItemMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx, attendanceFileHisInfo,
- holidayPolicyInfo);
- } catch (BOSException var23) {
- var23.printStackTrace();
- }
- AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) defaultItemMap
- .get("scheduleShiftItemColl");
- this.defaultStandardHour = (BigDecimal) defaultItemMap.get("standardHour");
- String beginDate = AtsDateUtils.dateLongToString(beginTimeCount).substring(0, 10);
- String endDate = AtsDateUtils.dateLongToString(endTimeCount).substring(0, 10);
- AtsHolidayFileHisCollection atsHolidayFileHisCollection = null;
- BigDecimal standardHour = new BigDecimal(0);
- try {
- atsHolidayFileHisCollection = AtsHolidayFileHisFactory.getLocalInstance(this.ctx)
- .getAtsHolidayFileHisCollection("where proposer.id='" + this.personId + "' order by effdt asc");
- if (null != atsHolidayFileHisCollection && atsHolidayFileHisCollection.size() > 0) {
- for (int i = 0; i < atsHolidayFileHisCollection.size(); ++i) {
- AtsHolidayFileHisInfo atsHolidayFileHisInfo = atsHolidayFileHisCollection.get(i);
- if (beginTimeCount.getTime() >= atsHolidayFileHisInfo.getEFFDT().getTime()
- && endTimeCount.getTime() <= atsHolidayFileHisInfo.getLEFFDT().getTime()) {
- String id = atsHolidayFileHisInfo.getHolidayPolicySet().getId().toString();
- HolidayPolicySetInfo holidayPolicyInfo_1 = HolidayPolicySetFactory.getLocalInstance(this.ctx)
- .getHolidayPolicySetInfo(" where id = '" + id + "'");
- standardHour = holidayPolicyInfo_1.getDefaultStandardHour();
- }
- }
- }
- } catch (Exception var24) {
- var24.printStackTrace();
- }
- Map<String, Object> paramMap = new HashMap();
- paramMap.put("personId", this.personId);
- paramMap.put("beginDate", beginDate);
- paramMap.put("endDate", endDate);
- paramMap.put("endTimeCount", endTimeCount);
- paramMap.put("beginTimeCount", beginTimeCount);
- paramMap.put("defaultStandardHour", this.defaultStandardHour);
- paramMap.put("holidayTypeUnit", holidayTypeUnit);
- paramMap.put("isFixOTAllowLeave", holidayPolicyInfo.isIsFixOTAllowLeave());
- paramMap.put("afterDealDateList", afterDealDateList);
- paramMap.put("defaultAtsShiftItemCollection", defaultAtsShiftItemCollection);
- paramMap.put("dayStandardHour", standardHour);
- Map<String, Object> DateLeaveLenMap = new HashMap();
- Date nowDate;
- String nowDateStr;
- if (tempAfterDealDateListSize != 0) {
- if (afterDealDateList.size() == 1
- && afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()))
- && afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()))) {
- paramMap.put("curDate", beginDate);
- paramMap.put("index", "index");
- this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
- } else {
- boolean isContainBeginDate = afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()));
- boolean isContainEndDate = afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()));
- if (isContainBeginDate) {
- paramMap.put("curDate", beginDate);
- afterDealDateList
- .remove(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()));
- this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
- }
- if (isContainEndDate) {
- paramMap.put("curDate", endDate);
- afterDealDateList.remove(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()));
- this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
- }
- if (tempAfterDealDateListSize >= 3) {
- nowDate = AtsDateUtils.getPreDay(AtsDateUtils.stringToShortDate(endDate));
- nowDateStr = AtsDateUtils.dateShortToString(nowDate);
- boolean isPreEndDate = afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(nowDateStr + " 00:00:00").getTime()));
- if (isPreEndDate) {
- paramMap.put("curDate", nowDateStr);
- paramMap.put("nowDate", nowDate);
- paramMap.put("index", "calPreEndDate");
- afterDealDateList
- .remove(new Date(AtsDateUtils.stringToTimestamp(nowDateStr + " 00:00:00").getTime()));
- this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
- }
- }
- this.getMidleDateLength(this.ctx, paramMap, DateLeaveLenMap);
- }
- }
- Date nowDate1 = AtsDateUtils.getPreDay(AtsDateUtils.stringToShortDate(beginDate));
- String nowDateStr1 = AtsDateUtils.dateShortToString(nowDate1);
- paramMap.put("curDate", nowDateStr1);
- paramMap.put("nowDate", nowDate1);
- paramMap.put("index", "calPrebeginDate");
- this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
- nowDate1 = AtsDateUtils.getNextDay(AtsDateUtils.stringToShortDate(endDate));
- nowDateStr1 = AtsDateUtils.dateShortToString(nowDate1);
- paramMap.put("curDate", nowDateStr1);
- paramMap.put("nowDate", nowDate1);
- paramMap.put("index", "calNextendDate");
- this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
- return DateLeaveLenMap;
- }
- public void getMidleDateLength(Context ctx, Map<String, Object> paramMap, Map<String, Object> DateLeaveLenMap) {
- HolidayTypeUnitEnum holidayTypeUnit = (HolidayTypeUnitEnum) paramMap.get("holidayTypeUnit");
- List<Date> afterDealDateList = (List) paramMap.get("afterDealDateList");
- AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) paramMap
- .get("defaultAtsShiftItemCollection");
- String personId = (String) paramMap.get("personId");
- String beginDate = (String) paramMap.get("beginDate");
- String endDate = (String) paramMap.get("endDate");
- Boolean isFixOTAllowLeave = (Boolean) paramMap.get("isFixOTAllowLeave");
- BigDecimal defaultStandardHour = (BigDecimal) paramMap.get("defaultStandardHour");
- BigDecimal dayStandardHour = (BigDecimal) paramMap.get("dayStandardHour");
- new BigDecimal(0);
- if (afterDealDateList.size() > 0) {
- HashMap curDateMap;
- if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
- for (int i = 0; i < afterDealDateList.size(); ++i) {
- boolean isHalfDay = AtsLeaveBillUtils.isHalfDay(ctx, personId, (Date) afterDealDateList.get(i));
- String curDate = AtsDateUtils.dateShortToString((Date) afterDealDateList.get(i));
- curDateMap = new HashMap();
- if (isHalfDay) {
- curDateMap.put("calDay", 0.5D);
- } else {
- curDateMap.put("calDay", 1.0D);
- }
- curDateMap.put("calHour", 0.0D);
- DateLeaveLenMap.put(curDate, curDateMap);
- }
- } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
- try {
- Map<String, ScheduleShiftInfo> scheduleShiftInfoMap = AtsScheduleShiftUtil
- .getScheduleShiftByPriority(ctx, personId, beginDate, endDate);
- ScheduleShiftInfo scheduleShiftInfo = null;
- for (int i = 0; i < afterDealDateList.size(); ++i) {
- curDateMap = new HashMap();
- Date currentDate = (Date) afterDealDateList.get(i);
- String curDate = AtsDateUtils.dateShortToString(currentDate);
- curDateMap.put("calDay", 0.0D);
- String key = personId + "_" + AtsDateUtils.dateShortToString(currentDate);
- DateLeaveLenMap.put(curDate, curDateMap);
- if (null != scheduleShiftInfoMap) {
- scheduleShiftInfo = (ScheduleShiftInfo) scheduleShiftInfoMap.get(key);
- }
- if (scheduleShiftInfo != null) {
- BigDecimal standardHour = scheduleShiftInfo.getStandardHour();
- curDateMap.put("calHour", standardHour.doubleValue());
- if (isFixOTAllowLeave) {
- curDateMap.put("calHour", standardHour.doubleValue()
- + this.getFixOTSegHour(scheduleShiftInfo.getItems()));
- }
- } else if (defaultAtsShiftItemCollection.size() != 0) {
- curDateMap.put("calHour", defaultStandardHour.doubleValue());
- if (isFixOTAllowLeave) {
- curDateMap.put("calHour", defaultStandardHour.doubleValue()
- + this.getFixOTSegHour(defaultAtsShiftItemCollection));
- }
- } else {
- curDateMap.put("calHour", dayStandardHour.doubleValue());
- }
- }
- } catch (Exception var21) {
- var21.printStackTrace();
- }
- }
- }
- }
- public double getFixOTSegHour(ScheduleShiftItemCollection item) {
- double otSegHour = 0.0D;
- ScheduleShiftItemInfo info = null;
- int i = 0;
- for (int len = item.size(); i < len; ++i) {
- info = item.get(i);
- if (info.getAttendanceType().equals(AttendanceTypeEnum.fixedOverTime)) {
- otSegHour += (double) ((info.getNextDateTime().getTime() - info.getPreDateTime().getTime()) / 3600000L);
- }
- }
- return otSegHour;
- }
- public double getFixOTSegHour(AtsShiftItemCollection item) {
- double otSegHour = 0.0D;
- AtsShiftItemInfo info = null;
- int i = 0;
- for (int len = item.size(); i < len; ++i) {
- info = item.get(i);
- if (info.getAttendanceType().equals(AttendanceTypeEnum.fixedOverTime)) {
- String preTime = info.getPreTime() + ":00";
- String nextTime = info.getNextTime() + ":00";
- if (preTime.compareTo(nextTime) > 0) {
- preTime = "1900-01-01 " + preTime;
- nextTime = "1900-01-02 " + nextTime;
- } else {
- preTime = "1900-01-01 " + preTime;
- nextTime = "1900-01-01 " + nextTime;
- }
- otSegHour += (double) ((HRTimeWebUtils.stringToTimestamp(nextTime).getTime()
- - HRTimeWebUtils.stringToTimestamp(preTime).getTime()) / 3600000L);
- }
- }
- return otSegHour;
- }
- public void getBeginDateOrEndDateLength(Context ctx, Map<String, Object> paramMap,
- Map<String, Object> DateLeaveLenMap) {
- HolidayTypeUnitEnum holidayTypeUnit = (HolidayTypeUnitEnum) paramMap.get("holidayTypeUnit");
- AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) paramMap
- .get("defaultAtsShiftItemCollection");
- String personId = (String) paramMap.get("personId");
- String beginDate = (String) paramMap.get("beginDate");
- String endDate = (String) paramMap.get("endDate");
- String curDate = (String) paramMap.get("curDate");
- Boolean isFixOTAllowLeave = (Boolean) paramMap.get("isFixOTAllowLeave");
- Timestamp beginTimeCount = (Timestamp) paramMap.get("beginTimeCount");
- Timestamp endTimeCount = (Timestamp) paramMap.get("endTimeCount");
- BigDecimal defaultStandardHour = (BigDecimal) paramMap.get("defaultStandardHour");
- BigDecimal standardHour = (BigDecimal) paramMap.get("dayStandardHour");
- long leaveLength = 0L;
- try {
- HashMap<String, Object> dateMap = AtsLeaveBillUtils.getScheduleShiftItemCollByDate(ctx, personId,
- new Date(AtsDateUtils.stringToTimestamp(curDate + " 00:00:00").getTime()), isFixOTAllowLeave);
- ScheduleShiftItemCollection scheduleShiftItemColl = (ScheduleShiftItemCollection) dateMap
- .get("scheduleShiftItemColl");
- if (scheduleShiftItemColl.size() == 0 && defaultAtsShiftItemCollection.size() == 0) {
- standardHour = new BigDecimal(24);
- String index = (String) paramMap.get("index");
- if (!StringUtils.isEmpty(index) && index.equals("index")) {
- leaveLength = endTimeCount.getTime() - beginTimeCount.getTime();
- } else if (curDate.equals(endDate)) {
- leaveLength = leaveLength + endTimeCount.getTime()
- - AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime();
- } else if (curDate.equals(beginDate)) {
- leaveLength = leaveLength + AtsDateUtils.stringToTimestamp(beginDate + " 23:59:59").getTime()
- - beginTimeCount.getTime();
- } else if (!StringUtils.isEmpty(index) && index.equals("calPreEndDate")) {
- leaveLength = (long) ((double) standardHour.longValue() * 60.0D * 60.0D * 1000.0D);
- }
- } else {
- List<HashMap<String, Object>> shift = null;
- if (scheduleShiftItemColl.size() != 0) {
- standardHour = (BigDecimal) dateMap.get("standardHour");
- shift = AtsLeaveBillUtils.getShiftItemInfos(scheduleShiftItemColl, curDate,
- this.atsLeaveBillEntryInfo == null ? null : this.atsLeaveBillEntryInfo.isIsElasticCalLen());
- } else {
- standardHour = defaultStandardHour;
- shift = AtsLeaveBillUtils.getShiftItemInfos(defaultAtsShiftItemCollection, curDate,
- this.atsLeaveBillEntryInfo == null ? null : this.atsLeaveBillEntryInfo.isIsElasticCalLen());
- }
- Map<String, Object> res = AtsLeaveBillUtils.calSegmentLength(ctx, shift, beginTimeCount, endTimeCount,
- leaveLength, this.holidayPolicyInfo, standardHour);
- leaveLength = (Long) res.get("realLen");
- }
- } catch (EASBizException var21) {
- var21.printStackTrace();
- } catch (BOSException var22) {
- var22.printStackTrace();
- }
- Map<String, Double> curDateMap = new HashMap();
- if (leaveLength > 0L) {
- if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
- boolean isHalfDay = AtsLeaveBillUtils.isHalfDay(ctx, personId,
- HRTimeWebUtils.stringToShortDate(curDate));
- if (isHalfDay) {
- curDateMap.put("calDay",
- (double) leaveLength / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D * 2.0D) > 0.5D
- ? 0.5D
- : (double) leaveLength
- / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D * 2.0D));
- } else {
- curDateMap.put("calDay",
- (double) leaveLength / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D) > 1.0D
- ? 1.0D
- : (double) leaveLength / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D));
- }
- } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
- curDateMap.put("calHour",
- (double) leaveLength / 3600000.0D > standardHour.doubleValue()
- ? standardHour.doubleValue()
- : (double) leaveLength / 3600000.0D);
- }
- DateLeaveLenMap.put(curDate, curDateMap);
- }
- }
- public Map<String, Object> calRealLeaveLengthOfDay(List<Date> afterDealDateList, Date beginTimeCount,
- Date endTimeCount, HolidayTypeUnitEnum holidayTypeUnit, AtsHolidayFileInfo holidayFileInfo,
- HolidayPolicySetInfo holidayPolicySetInfo, HolidayPolicyInfo holidayPolicyInfo)
- throws BOSException, EASBizException {
- Map<String, Object> retMap = new HashMap();
- if (afterDealDateList.size() == 0) {
- return retMap;
- } else {
- Timestamp beginTimeCountTs = AtsDateUtils.dateToTimestamp(beginTimeCount);
- Timestamp endTimeCountTs = AtsDateUtils.dateToTimestamp(endTimeCount);
- AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
- beginTimeCountTs, endTimeCountTs, this.personId, (String) null);
- HashMap<String, Object> defaultItemMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx,
- attendanceFileHisInfo, holidayPolicyInfo);
- AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) defaultItemMap
- .get("scheduleShiftItemColl");
- BigDecimal defaultStandardHour = (BigDecimal) defaultItemMap.get("standardHour");
- new BigDecimal(8);
- String beginDate = AtsDateUtils.dateLongToString(beginTimeCount).substring(0, 10);
- String endDate = AtsDateUtils.dateLongToString(endTimeCount).substring(0, 10);
- String amStartTime = holidayPolicySetInfo.getAmStartWorkTime();
- String amEndTime = holidayPolicySetInfo.getAmEndWorkTime();
- String pmStartTime = holidayPolicySetInfo.getPmStartWorkTime();
- String pmEndTime = holidayPolicySetInfo.getPmEndWorkTime();
- HolidayTypeUnitEnum holidayUnit = holidayPolicyInfo.getUnit();
- Boolean isFixOTAllowLeave = holidayPolicyInfo.isIsFixOTAllowLeave();
- double realLength = 0.0D;
- double leaveLengthDay = 0.0D;
- double leaveLengthHour = 0.0D;
- BigDecimal standardHour;
- boolean isHalfDay;
- String amEndTimeTemp;
- if (afterDealDateList.size() == 1
- && afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()))
- && afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()))) {
- isHalfDay = AtsLeaveBillUtils.isHalfDay(this.ctx, this.personId,
- HRTimeWebUtils.stringToShortDate(beginDate));
- amEndTimeTemp = AtsDateUtils.dateLongToString(beginTimeCount).substring(11, 16);
- String endTimeTemp = AtsDateUtils.dateLongToString(endTimeCount).substring(11, 16);
- if ((!amEndTimeTemp.equals(amStartTime) || !endTimeTemp.equals(amEndTime))
- && (!amEndTimeTemp.equals(pmStartTime) || !endTimeTemp.equals(pmEndTime))
- && (!amEndTimeTemp.equals(amStartTime) || !endTimeTemp.equals(pmStartTime))
- && (!amEndTimeTemp.equals(amEndTime) || !endTimeTemp.equals(pmEndTime))) {
- if (amEndTimeTemp.equals(amStartTime) && endTimeTemp.equals(pmEndTime)) {
- realLength = 1.0D;
- } else {
- realLength = 0.0D;
- }
- } else {
- realLength = 0.5D;
- }
- if (realLength > 0.0D) {
- Map<String, Double> curDateMap = new HashMap();
- if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
- if (isHalfDay) {
- leaveLengthDay = 0.5D;
- } else {
- leaveLengthDay = realLength;
- }
- curDateMap.put("calDay", leaveLengthDay);
- curDateMap.put("calHour", 0.0D);
- } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
- standardHour = this.getStandardHourOfDay(this.ctx, this.personId, beginDate,
- defaultAtsShiftItemCollection, defaultStandardHour,
- holidayPolicyInfo.isIsFixOTAllowLeave());
- leaveLengthHour = realLength * standardHour.doubleValue();
- curDateMap.put("calDay", 0.0D);
- curDateMap.put("calHour", leaveLengthHour);
- }
- retMap.put(beginDate, curDateMap);
- }
- } else {
- HashMap curDateMap;
- if (afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()))) {
- isHalfDay = AtsLeaveBillUtils.isHalfDay(this.ctx, this.personId,
- HRTimeWebUtils.stringToShortDate(beginDate));
- amEndTimeTemp = AtsDateUtils.dateLongToString(beginTimeCount).substring(11, 16);
- afterDealDateList
- .remove(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()));
- if (amEndTimeTemp.equals(amStartTime)) {
- realLength = 1.0D;
- } else if (amEndTimeTemp.equals(pmStartTime)) {
- realLength = 0.5D;
- } else {
- realLength = 0.0D;
- }
- if (realLength > 0.0D) {
- curDateMap = new HashMap();
- if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
- if (isHalfDay) {
- leaveLengthDay = 0.5D;
- } else {
- leaveLengthDay = realLength;
- }
- curDateMap.put("calDay", leaveLengthDay);
- curDateMap.put("calHour", 0.0D);
- } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
- standardHour = this.getStandardHourOfDay(this.ctx, this.personId, beginDate,
- defaultAtsShiftItemCollection, defaultStandardHour,
- holidayPolicyInfo.isIsFixOTAllowLeave());
- leaveLengthHour = realLength * standardHour.doubleValue();
- curDateMap.put("calDay", 0.0D);
- curDateMap.put("calHour", leaveLengthHour);
- }
- retMap.put(beginDate, curDateMap);
- }
- }
- if (afterDealDateList
- .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()))) {
- isHalfDay = AtsLeaveBillUtils.isHalfDay(this.ctx, this.personId,
- HRTimeWebUtils.stringToShortDate(endDate));
- afterDealDateList.remove(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()));
- amEndTimeTemp = AtsDateUtils.dateLongToString(endTimeCount).substring(11, 16);
- realLength = 0.0D;
- if (!amEndTimeTemp.equals(amEndTime) && !amEndTimeTemp.equals(pmStartTime)) {
- if (amEndTimeTemp.equals(pmEndTime)) {
- realLength = 1.0D;
- } else {
- realLength = 0.0D;
- }
- } else {
- realLength = 0.5D;
- }
- if (realLength > 0.0D) {
- curDateMap = new HashMap();
- if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
- if (isHalfDay) {
- leaveLengthDay = 0.5D;
- } else {
- leaveLengthDay = realLength;
- }
- curDateMap.put("calDay", leaveLengthDay);
- curDateMap.put("calHour", 0.0D);
- } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
- standardHour = this.getStandardHourOfDay(this.ctx, this.personId, endDate,
- defaultAtsShiftItemCollection, defaultStandardHour,
- holidayPolicyInfo.isIsFixOTAllowLeave());
- leaveLengthHour = realLength * standardHour.doubleValue();
- curDateMap.put("calDay", 0.0D);
- curDateMap.put("calHour", leaveLengthHour);
- }
- retMap.put(endDate, curDateMap);
- }
- }
- if (afterDealDateList.size() > 0) {
- Map<String, Object> paramMap = new HashMap();
- paramMap.put("leaveLengthDay", leaveLengthDay);
- paramMap.put("leaveLengthHour", leaveLengthHour);
- paramMap.put("personId", this.personId);
- paramMap.put("beginDate", beginDate);
- paramMap.put("endDate", endDate);
- paramMap.put("defaultStandardHour", defaultStandardHour);
- paramMap.put("holidayTypeUnit", holidayUnit);
- paramMap.put("isFixOTAllowLeave", isFixOTAllowLeave);
- paramMap.put("afterDealDateList", afterDealDateList);
- paramMap.put("defaultAtsShiftItemCollection", defaultAtsShiftItemCollection);
- paramMap.put("dayStandardHour", new BigDecimal(8));
- this.getMidleDateLength(this.ctx, paramMap, retMap);
- }
- }
- return retMap;
- }
- }
- public BigDecimal getStandardHourOfDay(Context ctx, String personId, String curDate,
- AtsShiftItemCollection defaultAtsShiftItemCollection, BigDecimal defaultStandardHour,
- Boolean isFixOTAllowLeave) {
- BigDecimal standardHour = new BigDecimal(8);
- try {
- HashMap<String, Object> dateMap = AtsLeaveBillUtils.getScheduleShiftItemCollByDate(ctx, personId,
- new Date(AtsDateUtils.stringToShortDate(curDate).getTime()), isFixOTAllowLeave);
- ScheduleShiftItemCollection scheduleShiftItemColl = (ScheduleShiftItemCollection) dateMap
- .get("scheduleShiftItemColl");
- if (scheduleShiftItemColl.size() != 0 || defaultAtsShiftItemCollection.size() != 0) {
- if (scheduleShiftItemColl.size() != 0) {
- standardHour = (BigDecimal) dateMap.get("standardHour");
- } else {
- standardHour = defaultStandardHour;
- }
- }
- } catch (EASBizException var10) {
- var10.printStackTrace();
- } catch (BOSException var11) {
- var11.printStackTrace();
- }
- return standardHour;
- }
- public Map<String, Object> calRealLeaveLengthOfBF(List<Date> afterDealDateList, Date beginTimeCount,
- Date endTimeCount, HolidayTypeUnitEnum holidayTypeUnit, AtsHolidayFileInfo holidayFileInfo,
- HolidayPolicySetInfo holidayPolicySetInfo, HolidayPolicyInfo holidayPolicyInfo)
- throws BOSException, EASBizException {
- Map<String, Object> DateLeaveLenMap = new HashMap();
- if (this.atsLeaveBillEntryInfo.getBfType() == null) {
- return DateLeaveLenMap;
- } else {
- String bfTypeId = this.atsLeaveBillEntryInfo.getBfType().getId().toString();
- BreastFeedingTypeCollection bfTypeColl = BreastFeedingTypeFactory.getLocalInstance(this.ctx)
- .getBreastFeedingTypeCollection("where id = '" + bfTypeId + "'");
- double leaveLengthOfSplit = 1.0D;
- if (bfTypeColl.size() > 0) {
- BreastFeedingTypeInfo bfTypeInfo = bfTypeColl.get(0);
- leaveLengthOfSplit = bfTypeInfo.getLeaveLength().multiply(new BigDecimal(bfTypeInfo.getFetusNum()))
- .doubleValue();
- }
- Map<String, List<ScheduleShiftInfo>> scheduleShiftMap = null;
- HashMap curDateMap;
- String curDate;
- if (holidayTypeUnit.getValue() == 1) {
- Timestamp beginTimeCountTs = AtsDateUtils.dateToTimestamp(beginTimeCount);
- Timestamp endTimeCountTs = AtsDateUtils.dateToTimestamp(endTimeCount);
- curDateMap = new HashMap();
- try {
- AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
- beginTimeCountTs, endTimeCountTs, this.personId, (String) null);
- curDateMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx, attendanceFileHisInfo,
- holidayPolicyInfo);
- } catch (BOSException var23) {
- var23.printStackTrace();
- }
- this.defaultStandardHour = (BigDecimal) curDateMap.get("standardHour");
- curDate = AtsDateUtils.dateLongToString(beginTimeCount).substring(0, 10);
- String endDate = AtsDateUtils.dateLongToString(endTimeCount).substring(0, 10);
- Map<String, Object> fileInfoRenturn = AtsPrepareDataHelper.getAttendanceFileInfoByPersonId(this.ctx,
- "'" + this.personId + "'", curDate, endDate, (String) null);
- Map<String, AttendanceFileInfo> fileInfoObject = (Map) fileInfoRenturn.get("fileInfoMap");
- scheduleShiftMap = AtsScheduleShiftUtil.getScheduleShiftMapByPriority(this.ctx, fileInfoObject,
- this.personId, curDate, endDate);
- }
- if (afterDealDateList.size() == 0) {
- return DateLeaveLenMap;
- } else {
- Iterator var25 = afterDealDateList.iterator();
- while (var25.hasNext()) {
- Date date = (Date) var25.next();
- curDateMap = new HashMap();
- if (holidayTypeUnit.getValue() == 1) {
- new BigDecimal(0);
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- String ds = sdf.format(date);
- String key = this.personId + "_" + ds;
- List<ScheduleShiftInfo> scheduleShiftList = null == scheduleShiftMap
- ? null
- : (List) scheduleShiftMap.get(key);
- BigDecimal standardhour;
- if (scheduleShiftList != null && scheduleShiftList.size() > 0) {
- standardhour = (BigDecimal) ((ScheduleShiftInfo) scheduleShiftList.get(0))
- .get("standardhour");
- } else {
- standardhour = this.defaultStandardHour;
- }
- BigDecimal dayRealLength = BigDecimal.valueOf(leaveLengthOfSplit).divide(standardhour, 8,
- RoundingMode.HALF_UP);
- curDateMap.put("calDay", dayRealLength.doubleValue());
- curDateMap.put("calHour", 0.0D);
- } else {
- curDateMap.put("calDay", 0.0D);
- curDateMap.put("calHour", leaveLengthOfSplit);
- }
- curDate = AtsDateUtils.dateLongToString(date);
- DateLeaveLenMap.put(curDate, curDateMap);
- }
- return DateLeaveLenMap;
- }
- }
- }
- public Map<String, Object> getIsCtrlHalfDayOff(Context ctx) {
- HashMap res = new HashMap();
- try {
- HolidayPolicySetInfo holidayPolicySetInfo = HolidayPolicySetFactory.getLocalInstance(ctx)
- .getHolidayPolicySetInfo(
- " where id='" + this.holidayPolicyInfo.getHolidayPolicySet().getId().toString() + "' ");
- res.put("amBeginTime", holidayPolicySetInfo.getAmStartWorkTime());
- res.put("amEndTime", holidayPolicySetInfo.getAmEndWorkTime());
- res.put("pmBeginTime", holidayPolicySetInfo.getPmStartWorkTime());
- res.put("pmEndTime", holidayPolicySetInfo.getPmEndWorkTime());
- res.put("isHalfDayOff", this.holidayPolicyInfo.isIsHalfDayOff());
- } catch (Exception var4) {
- ;
- }
- return res;
- }
- private AtsShiftItemInfo createScheduleShiftItemToAtsShiftItem(Context ctx,
- ScheduleShiftItemInfo scheduleShiftItemInfo) {
- AtsShiftItemInfo info = new AtsShiftItemInfo();
- info.setPreTime(scheduleShiftItemInfo.getPreTime());
- info.setNextTime(scheduleShiftItemInfo.getNextTime());
- info.setPreIsPunchCard(scheduleShiftItemInfo.getPreIsPunchCard());
- info.setNextIsPunchCard(scheduleShiftItemInfo.getNextIsPunchCard());
- info.setPreTimeDayType(scheduleShiftItemInfo.getPreTimeDayType());
- info.setNextTimeDayType(scheduleShiftItemInfo.getNextTimeDayType());
- info.setSegment(scheduleShiftItemInfo.getSegment());
- info.setPreFloatAdjusted(scheduleShiftItemInfo.getPreFloatAdjusted());
- info.setNextFloatAdjusted(scheduleShiftItemInfo.getNextFloatAdjusted());
- info.setRestPreTime(scheduleShiftItemInfo.getRestPreTime());
- info.setRestNextTime(scheduleShiftItemInfo.getRestNextTime());
- info.setSegmentInRest(scheduleShiftItemInfo.getSegmentInRest());
- info.setAttendanceType(scheduleShiftItemInfo.getAttendanceType());
- info.setGroup(new AtsShiftInfo());
- return info;
- }
- }
|