b528bce9b18c73c8e884c2c99d89736cab0c13e6.svn-base 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  1. package com.kingdee.eas.custom.utils;
  2. import java.math.BigDecimal;
  3. import java.math.RoundingMode;
  4. import java.sql.SQLException;
  5. import java.sql.Timestamp;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Arrays;
  9. import java.util.Calendar;
  10. import java.util.Date;
  11. import java.util.HashMap;
  12. import java.util.HashSet;
  13. import java.util.Iterator;
  14. import java.util.List;
  15. import java.util.Map;
  16. import java.util.Map.Entry;
  17. import java.util.Set;
  18. import org.apache.axis.utils.StringUtils;
  19. import org.slf4j.Logger;
  20. import org.slf4j.LoggerFactory;
  21. import com.kingdee.bos.BOSException;
  22. import com.kingdee.bos.Context;
  23. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  24. import com.kingdee.bos.util.BOSUuid;
  25. import com.kingdee.eas.basedata.org.AdminOrgUnitFactory;
  26. import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
  27. import com.kingdee.eas.basedata.person.PersonInfo;
  28. import com.kingdee.eas.common.EASBizException;
  29. import com.kingdee.eas.custom.ats.AtsLeaveBillDetailSameInfo;
  30. import com.kingdee.eas.framework.CoreBaseCollection;
  31. import com.kingdee.eas.hr.ats.AtsHolidayFileFactory;
  32. import com.kingdee.eas.hr.ats.AtsHolidayFileHisCollection;
  33. import com.kingdee.eas.hr.ats.AtsHolidayFileHisFactory;
  34. import com.kingdee.eas.hr.ats.AtsHolidayFileHisInfo;
  35. import com.kingdee.eas.hr.ats.AtsHolidayFileInfo;
  36. import com.kingdee.eas.hr.ats.AtsLeaveBillDetailFactory;
  37. import com.kingdee.eas.hr.ats.AtsLeaveBillDetailInfo;
  38. import com.kingdee.eas.hr.ats.AtsLeaveBillEntryCollection;
  39. import com.kingdee.eas.hr.ats.AtsLeaveBillEntryFactory;
  40. import com.kingdee.eas.hr.ats.AtsLeaveBillEntryInfo;
  41. import com.kingdee.eas.hr.ats.AtsLeaveBillFactory;
  42. import com.kingdee.eas.hr.ats.AtsLeaveBillInfo;
  43. import com.kingdee.eas.hr.ats.AtsLeaveBillResEnum;
  44. import com.kingdee.eas.hr.ats.AtsShiftCollection;
  45. import com.kingdee.eas.hr.ats.AtsShiftFactory;
  46. import com.kingdee.eas.hr.ats.AtsShiftInfo;
  47. import com.kingdee.eas.hr.ats.AtsShiftItemCollection;
  48. import com.kingdee.eas.hr.ats.AtsShiftItemFactory;
  49. import com.kingdee.eas.hr.ats.AtsShiftItemInfo;
  50. import com.kingdee.eas.hr.ats.AttencePolicyFactory;
  51. import com.kingdee.eas.hr.ats.AttencePolicyInfo;
  52. import com.kingdee.eas.hr.ats.AttendanceFileCollection;
  53. import com.kingdee.eas.hr.ats.AttendanceFileHISInfo;
  54. import com.kingdee.eas.hr.ats.AttendanceFileInfo;
  55. import com.kingdee.eas.hr.ats.AttendanceTypeEnum;
  56. import com.kingdee.eas.hr.ats.BreastFeedingTypeCollection;
  57. import com.kingdee.eas.hr.ats.BreastFeedingTypeFactory;
  58. import com.kingdee.eas.hr.ats.BreastFeedingTypeInfo;
  59. import com.kingdee.eas.hr.ats.DayTypeEnum;
  60. import com.kingdee.eas.hr.ats.HolidayPolicyFactory;
  61. import com.kingdee.eas.hr.ats.HolidayPolicyInfo;
  62. import com.kingdee.eas.hr.ats.HolidayPolicySetFactory;
  63. import com.kingdee.eas.hr.ats.HolidayPolicySetInfo;
  64. import com.kingdee.eas.hr.ats.HolidayTypeUnitEnum;
  65. import com.kingdee.eas.hr.ats.IAtsLeaveBillDetail;
  66. import com.kingdee.eas.hr.ats.ScheduleShiftFactory;
  67. import com.kingdee.eas.hr.ats.ScheduleShiftInfo;
  68. import com.kingdee.eas.hr.ats.ScheduleShiftItemCollection;
  69. import com.kingdee.eas.hr.ats.ScheduleShiftItemFactory;
  70. import com.kingdee.eas.hr.ats.ScheduleShiftItemInfo;
  71. import com.kingdee.eas.hr.ats.WorkCalendarFactory;
  72. import com.kingdee.eas.hr.ats.WorkCalendarInfo;
  73. import com.kingdee.eas.hr.ats.WorkCalendarItemCollection;
  74. import com.kingdee.eas.hr.ats.WorkCalendarItemFactory;
  75. import com.kingdee.eas.hr.ats.WorkCalendarItemInfo;
  76. import com.kingdee.eas.hr.ats.biz.util.AtsLeaveBillUtil;
  77. import com.kingdee.eas.hr.ats.calculate.AtsCacheUtil;
  78. import com.kingdee.eas.hr.ats.calcutePrepareData.AtsPrepareDataHelper;
  79. import com.kingdee.eas.hr.ats.decimalPlace.util.DecimalPlaceUtil;
  80. import com.kingdee.eas.hr.ats.lightapp.util.HRTimeWebUtils;
  81. import com.kingdee.eas.hr.ats.util.AtsDateUtils;
  82. import com.kingdee.eas.hr.ats.util.AtsLeaveBillUtils;
  83. import com.kingdee.eas.hr.ats.util.AtsScheduleShiftUtil;
  84. import com.kingdee.eas.hr.ats.util.AtsServerUtils;
  85. import com.kingdee.eas.hr.ats.util.SHRBillServerUtil;
  86. import com.kingdee.eas.hr.ats.util.common.AtsCollectionUtile;
  87. import com.kingdee.eas.hr.ats.util.common.MLUtile;
  88. import com.kingdee.eas.hr.emp.PersonPositionInfo;
  89. import com.kingdee.eas.util.app.DbUtil;
  90. import com.kingdee.jdbc.rowset.IRowSet;
  91. import com.kingdee.util.UuidException;
  92. public class SplitLeaveUtils {
  93. private AtsLeaveBillInfo billInfo;
  94. private AtsLeaveBillEntryInfo atsLeaveBillEntryInfo;
  95. private Context ctx;
  96. private String personId;
  97. private Boolean isIncludeLegal;
  98. private Boolean isIncludeRest;
  99. private HolidayPolicyInfo holidayPolicyInfo;
  100. private BigDecimal sourceLen = new BigDecimal(0);
  101. private BigDecimal defaultStandardHour = BigDecimal.valueOf(24L);
  102. private int decimalPlaceValue = 2;
  103. private static final Logger logger = LoggerFactory.getLogger(SplitLeaveUtils.class);
  104. public SplitLeaveUtils(Context ctx, BOSUuid billId) throws EASBizException, BOSException {
  105. this.billInfo = AtsLeaveBillFactory.getLocalInstance(ctx)
  106. .getAtsLeaveBillInfo(new ObjectUuidPK(billId.toString()));
  107. AtsLeaveBillEntryCollection billEntryColl = AtsLeaveBillEntryFactory.getLocalInstance(ctx)
  108. .getAtsLeaveBillEntryCollection(" where bill='" + this.billInfo.getId().toString() + "'");
  109. this.atsLeaveBillEntryInfo = billEntryColl.get(0);
  110. this.ctx = ctx;
  111. this.personId = this.atsLeaveBillEntryInfo.getPerson().getId().toString();
  112. this.holidayPolicyInfo = HolidayPolicyFactory.getLocalInstance(ctx)
  113. .getHolidayPolicyInfo(" where id='" + this.atsLeaveBillEntryInfo.getPolicy().getId().toString() + "'");
  114. this.isIncludeLegal = this.holidayPolicyInfo.isIsIncludeLegal();
  115. this.isIncludeRest = this.holidayPolicyInfo.isIsIncludeRest();
  116. this.decimalPlaceValue = DecimalPlaceUtil.getDecimalPlaceSystem(ctx);
  117. }
  118. public SplitLeaveUtils(Context ctx, AtsLeaveBillInfo billInfo, AtsLeaveBillEntryInfo atsLeaveBillEntryInfo)
  119. throws EASBizException, BOSException {
  120. this.billInfo = billInfo;
  121. this.atsLeaveBillEntryInfo = atsLeaveBillEntryInfo;
  122. this.ctx = ctx;
  123. this.personId = atsLeaveBillEntryInfo.getPerson().getId().toString();
  124. this.holidayPolicyInfo = HolidayPolicyFactory.getLocalInstance(ctx)
  125. .getHolidayPolicyInfo(" where id='" + atsLeaveBillEntryInfo.getPolicy().getId().toString() + "'");
  126. this.isIncludeLegal = this.holidayPolicyInfo.isIsIncludeLegal();
  127. this.isIncludeRest = this.holidayPolicyInfo.isIsIncludeRest();
  128. }
  129. public List<Map<String, Object>> getSplitLeaveBill() throws EASBizException, BOSException {
  130. logger.info("AtsLeaveBillSameSplitHelper....splitLeaveBill....start");
  131. logger.info(MLUtile.getRes(AtsLeaveBillResEnum.StartSplitLeaveBill, this.ctx) + "...");
  132. Timestamp beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
  133. Timestamp endTime = this.atsLeaveBillEntryInfo.getRealEndTime();
  134. List<Date> dateList = this.getLeaveDateColl(beginTime, endTime);
  135. List<Date> dateListAfter = this.dealDateNew(dateList);
  136. String oql = " select holidayPolicySet.isHalfDayOff,holidayPolicySet.isHalfDayOff,holidayPolicySet.amStartWorkTime,holidayPolicySet.amEndWorkTime,holidayPolicySet.pmStartWorkTime,holidayPolicySet.pmEndWorkTime where proposer.id='"
  137. + this.personId + "' and attendFileState='1' ";
  138. AtsHolidayFileInfo holidayFileInfo = AtsHolidayFileFactory.getLocalInstance(this.ctx)
  139. .getAtsHolidayFileInfo(oql);
  140. Map<String, Object> dateLenMap = null;
  141. HolidayPolicySetInfo holidayPolicySetInfo = holidayFileInfo.getHolidayPolicySet();
  142. if (null != this.holidayPolicyInfo && null != this.holidayPolicyInfo.getHolidayType()
  143. && this.holidayPolicyInfo.getHolidayType().getId().toString().equals("8r0AAAAMhrv9LVKY")
  144. && null != this.atsLeaveBillEntryInfo.getBfType()
  145. && !this.atsLeaveBillEntryInfo.getBfType().getId().toString().equals("8r0AAAA09p9IT3K3")) {
  146. dateLenMap = this.calRealLeaveLengthOfBF(dateListAfter, beginTime, endTime,
  147. this.atsLeaveBillEntryInfo.getRealUnit(), holidayFileInfo, holidayPolicySetInfo,
  148. this.holidayPolicyInfo);
  149. } else if (null != this.holidayPolicyInfo && this.holidayPolicyInfo.isIsHalfDayOff()) {
  150. dateLenMap = this.calRealLeaveLengthOfDay(dateListAfter, beginTime, endTime,
  151. this.atsLeaveBillEntryInfo.getRealUnit(), holidayFileInfo, holidayPolicySetInfo,
  152. this.holidayPolicyInfo);
  153. } else {
  154. dateLenMap = this.calRealLeaveLengthInfo(dateListAfter, beginTime, endTime,
  155. this.atsLeaveBillEntryInfo.getRealUnit(), holidayFileInfo, this.holidayPolicyInfo);
  156. }
  157. List<Map<String, Object>> leaveDetailList = this.getLeaveBillDetail(dateLenMap);
  158. return leaveDetailList;
  159. }
  160. private List<Map<String, Object>> getLeaveBillDetail(Map<String, Object> dateLenMap) throws BOSException, EASBizException {
  161. logger.info("AtsLeaveBillSameSplitHelper....insertleaveBillDetail....start");
  162. HolidayTypeUnitEnum holidayTypeUnit = this.atsLeaveBillEntryInfo.getRealUnit();
  163. Object[] key = dateLenMap.keySet().toArray();
  164. Arrays.sort(key);
  165. BigDecimal leavelen = this.atsLeaveBillEntryInfo.getRealLeaveLength();
  166. Object map = new HashMap();
  167. List<Map<String, Object>> leaveDetailList = new ArrayList<>();
  168. try {
  169. AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
  170. HRTimeWebUtils.stringShortToTimestamp(key[0].toString()),
  171. HRTimeWebUtils.stringShortToTimestamp(key[key.length - 1].toString()), this.personId,
  172. (String) null);
  173. AtsHolidayFileHisCollection atsHolidayFileHisCollection = null;
  174. AtsHolidayFileHisInfo atsHolidayFileHisInfo = null;
  175. atsHolidayFileHisCollection = AtsHolidayFileHisFactory.getLocalInstance(this.ctx)
  176. .getAtsHolidayFileHisCollection("where proposer.id='" + this.personId + "' order by effdt asc");
  177. if (null != atsHolidayFileHisCollection && atsHolidayFileHisCollection.size() > 0) {
  178. for (int i = 0; i < atsHolidayFileHisCollection.size(); ++i) {
  179. AtsHolidayFileHisInfo atsHolidayFileHis = atsHolidayFileHisCollection.get(i);
  180. if (HRTimeWebUtils.stringShortToTimestamp(key[0].toString()).getTime() >= atsHolidayFileHis
  181. .getEFFDT().getTime()
  182. && HRTimeWebUtils.stringShortToTimestamp(key[key.length - 1].toString())
  183. .getTime() <= atsHolidayFileHis.getLEFFDT().getTime()) {
  184. atsHolidayFileHisInfo = atsHolidayFileHisCollection.get(i);
  185. }
  186. }
  187. }
  188. map = getWorkCalendarItemInfoByDate(this.ctx, key[0].toString(),
  189. key[key.length - 1].toString(),attendanceFileHisInfo,atsHolidayFileHisInfo);
  190. } catch (Exception var21) {
  191. var21.printStackTrace();
  192. }
  193. int len = key.length;
  194. for (int i = 0; i < len; ++i) {
  195. ScheduleShiftInfo scheduleShiftInfo = AtsScheduleShiftUtil.getScheduleShiftByPriority(this.ctx,
  196. this.personId, new Date(HRTimeWebUtils.stringToTimestamp(key[i] + " 00:00:00").getTime()));
  197. if (scheduleShiftInfo == null) {
  198. String keyStr = key[i].toString().substring(0, 10);
  199. WorkCalendarItemInfo workCalendarItemInfo = (WorkCalendarItemInfo) ((Map) map).get(keyStr);
  200. if (workCalendarItemInfo == null || workCalendarItemInfo.getDayType() == null
  201. || !this.holidayPolicyInfo.isIsIncludeRest() && (null == workCalendarItemInfo
  202. || workCalendarItemInfo.getDayType() == DayTypeEnum.restDay
  203. || workCalendarItemInfo.getDayType() == DayTypeEnum.legalHoliday)) {
  204. continue;
  205. }
  206. }
  207. Map<String, Double> dateMap = (Map) dateLenMap.get(key[i]);
  208. new BigDecimal(0);
  209. BigDecimal tempLen;
  210. if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
  211. tempLen = BigDecimal.valueOf((Double) dateMap.get("calDay"));
  212. if (this.holidayPolicyInfo.isIsRoundSum()) {
  213. tempLen = BigDecimal.valueOf(this.getValueByMinLeaveLength(this.holidayPolicyInfo, tempLen));
  214. }
  215. if (leavelen.compareTo(tempLen) > 0 && i != len - 1) {
  216. leavelen = leavelen.subtract(tempLen);
  217. } else {
  218. tempLen = leavelen;
  219. }
  220. } else {
  221. tempLen = BigDecimal.valueOf((Double) dateMap.get("calHour"));
  222. if (this.holidayPolicyInfo.isIsRoundSum()) {
  223. tempLen = BigDecimal.valueOf(this.getValueByMinLeaveLength(this.holidayPolicyInfo, tempLen));
  224. }
  225. if (leavelen.compareTo(tempLen) > 0 && i != len - 1) {
  226. leavelen = leavelen.subtract(tempLen);
  227. } else {
  228. tempLen = leavelen;
  229. }
  230. }
  231. if (leavelen.compareTo(BigDecimal.valueOf(0L)) == 0) {
  232. break;
  233. }
  234. List<Map<String, Object>> dateList = this.getLeaveSuchScheduleDetal(
  235. HRTimeWebUtils.stringToTimestamp(key[i].toString().substring(0, 10) + " 00:00:00"), this.personId,
  236. tempLen);
  237. Date currDate = AtsDateUtils.stringToShortDate((String) key[i]);
  238. for(int j=0;j<dateList.size();j++) {
  239. Map<String, Object> detailMap = dateList.get(j);
  240. detailMap.put("personId", this.personId);
  241. detailMap.put("currDate", currDate);
  242. leaveDetailList.add(detailMap);
  243. }
  244. }
  245. return leaveDetailList;
  246. }
  247. public static Map<String, WorkCalendarItemInfo> getWorkCalendarItemInfoByDate(Context ctx, String beginDate, String endDate, AttendanceFileHISInfo attendanceFileHisInfo, AtsHolidayFileHisInfo atsHolidayFileHisInfo) throws BOSException, UuidException, SQLException {
  248. Map<String, WorkCalendarItemInfo> infoMap = new HashMap();
  249. WorkCalendarItemCollection itemColl = null;
  250. String itemCollKey;
  251. String oql;
  252. if (attendanceFileHisInfo != null && attendanceFileHisInfo.getCalendar().getId() != null) {
  253. itemCollKey = attendanceFileHisInfo.getCalendar().getId().toString();
  254. oql = " where date >='" + beginDate + "' and date <='" + endDate + "' and calendargroup.id = '" + itemCollKey + "'";
  255. itemColl = WorkCalendarItemFactory.getLocalInstance(ctx).getWorkCalendarItemCollection(oql);
  256. } else if (atsHolidayFileHisInfo != null && atsHolidayFileHisInfo.getCalendar().getId() != null) {
  257. itemCollKey = atsHolidayFileHisInfo.getCalendar().getId().toString();
  258. oql = " where date >='" + beginDate + "' and date <='" + endDate + "' and calendargroup.id = '" + itemCollKey + "'";
  259. itemColl = WorkCalendarItemFactory.getLocalInstance(ctx).getWorkCalendarItemCollection(oql);
  260. } else {
  261. itemCollKey = "workCalendarItem_" + beginDate + "_" + endDate;
  262. itemColl = (WorkCalendarItemCollection)AtsCacheUtil.get(itemCollKey);
  263. }
  264. for(int i = 0; i < itemColl.size(); ++i) {
  265. WorkCalendarItemInfo itemInfo = itemColl.get(i);
  266. String datestr = AtsDateUtils.dateShortToString(itemInfo.getDate());
  267. infoMap.put(datestr, itemInfo);
  268. }
  269. return infoMap;
  270. }
  271. private List<Map<String, Object>> getLeaveSuchScheduleDetal(Timestamp date, String personId, BigDecimal dataLen)
  272. throws BOSException {
  273. List<Map<String, Object>> list = new ArrayList();
  274. AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx, date, date,
  275. personId, (String) null);
  276. ScheduleShiftInfo scheduleShiftInfo = null;
  277. new HashMap();
  278. AtsShiftItemCollection shiftItemColl = new AtsShiftItemCollection();
  279. try {
  280. HashMap<String, Object> dateMap = AtsLeaveBillUtils.getScheduleShiftItemCollByDate(this.ctx, personId, date,
  281. this.holidayPolicyInfo.isIsFixOTAllowLeave());
  282. ScheduleShiftItemCollection scheduleShiftItemColl = (ScheduleShiftItemCollection) dateMap
  283. .get("scheduleShiftItemColl");
  284. int i;
  285. AtsShiftItemInfo info;
  286. if (null != scheduleShiftItemColl && scheduleShiftItemColl.size() != 0) {
  287. this.defaultStandardHour = (BigDecimal) dateMap.get("standardHour");
  288. for (i = 0; i < scheduleShiftItemColl.size(); ++i) {
  289. info = null;
  290. AtsShiftItemInfo shiftItemInfo = null;
  291. ScheduleShiftItemInfo info1 = scheduleShiftItemColl.get(i);
  292. ScheduleShiftItemCollection scheduleShiftItemcolls = ScheduleShiftItemFactory
  293. .getLocalInstance(this.ctx)
  294. .getScheduleShiftItemCollection(" where id = '" + info1.getId().toString() + "'");
  295. AdminOrgUnitInfo attAdminOrgUnit;
  296. if (AtsCollectionUtile.isEmpty(scheduleShiftItemcolls)) {
  297. attAdminOrgUnit = attendanceFileHisInfo.getAttAdminOrgUnit();
  298. shiftItemInfo = AtsShiftItemFactory.getLocalInstance(this.ctx)
  299. .getAtsShiftItemInfo(new ObjectUuidPK(info1.getShiftItem().getId().toString()));
  300. } else {
  301. ScheduleShiftItemInfo newinfo = ScheduleShiftItemFactory.getLocalInstance(this.ctx)
  302. .getScheduleShiftItemInfo(new ObjectUuidPK(info1.getId().toString()));
  303. shiftItemInfo = this.createScheduleShiftItemToAtsShiftItem(this.ctx, newinfo);
  304. attAdminOrgUnit = newinfo.getAttAdminOrgUnit();
  305. }
  306. shiftItemInfo.setString("adminOrgUnit", attAdminOrgUnit.getId().toString());
  307. String groupId = info1.getGroup().getId().toString();
  308. scheduleShiftInfo = ScheduleShiftFactory.getLocalInstance(this.ctx)
  309. .getScheduleShiftInfo(new ObjectUuidPK(groupId));
  310. shiftItemInfo.getGroup().setIsElastic(scheduleShiftInfo.isIsElastic());
  311. shiftItemColl.add(shiftItemInfo);
  312. }
  313. } else {
  314. HashMap<String, Object> defaultItemMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx,
  315. attendanceFileHisInfo, this.holidayPolicyInfo);
  316. shiftItemColl = (AtsShiftItemCollection) defaultItemMap.get("scheduleShiftItemColl");
  317. for (i = 0; i < shiftItemColl.size(); ++i) {
  318. info = shiftItemColl.get(i);
  319. info.setString("adminOrgUnit", attendanceFileHisInfo.getAttAdminOrgUnit().getId().toString());
  320. }
  321. }
  322. Timestamp beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
  323. Timestamp endTime = this.atsLeaveBillEntryInfo.getEndTime();
  324. if (shiftItemColl.size() <= 0 && scheduleShiftItemColl.size() <= 0) {
  325. Map<String, Object> dataSpiltMap = new HashMap();
  326. dataSpiltMap.put("beginTime", "00:00");
  327. dataSpiltMap.put("endTime", "23:59");
  328. dataSpiltMap.put("leaveLength", dataLen);
  329. dataSpiltMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
  330. ((List) list).add(dataSpiltMap);
  331. return (List) list;
  332. }
  333. shiftItemColl.sort("segment");
  334. String curDate = HRTimeWebUtils.timestampToString(date);
  335. String dateBeginTime = HRTimeWebUtils.timestampToString(beginTime);
  336. String dateEndTime = HRTimeWebUtils.timestampToString(endTime);
  337. Map<String, Object> res = this.getIsCtrlHalfDayOff(this.ctx);
  338. boolean isHalfDayOff = (Boolean) res.get("isHalfDayOff");
  339. AtsShiftItemInfo shiftItemInfo;
  340. String curBeginTime;
  341. Timestamp shiftItemEndTime;
  342. if (curDate.equals(dateBeginTime.substring(0, 10) + " 00:00:00")) {
  343. if (isHalfDayOff) {
  344. beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
  345. endTime = HRTimeWebUtils
  346. .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("pmEndTime") + ":00");
  347. } else {
  348. shiftItemInfo = shiftItemColl.get(0);
  349. curBeginTime = this.getCurDate(shiftItemInfo.getPreTimeDayType().getValue(), curDate);
  350. shiftItemEndTime = HRTimeWebUtils
  351. .stringToTimestamp(curBeginTime + " " + shiftItemInfo.getPreTime() + ":00");
  352. if (shiftItemEndTime.getTime() > beginTime.getTime()) {
  353. beginTime = shiftItemEndTime;
  354. }
  355. shiftItemInfo = shiftItemColl.get(shiftItemColl.size() - 1);
  356. if (!dateBeginTime.substring(0, 10).equals(dateEndTime.substring(0, 10))) {
  357. String nextTime = this.getCurDate(shiftItemInfo.getNextTimeDayType().getValue(), curDate);
  358. endTime = HRTimeWebUtils
  359. .stringToTimestamp(nextTime + " " + shiftItemInfo.getNextTime() + ":00");
  360. }
  361. }
  362. }
  363. if (curDate.equals(dateEndTime.substring(0, 10) + " 00:00:00")) {
  364. if (isHalfDayOff) {
  365. if (!curDate.equals(dateBeginTime.substring(0, 10) + " 00:00:00")) {
  366. beginTime = HRTimeWebUtils
  367. .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("amBeginTime") + ":00");
  368. }
  369. endTime = this.atsLeaveBillEntryInfo.getRealEndTime();
  370. } else {
  371. shiftItemInfo = shiftItemColl.get(0);
  372. if (!dateBeginTime.substring(0, 10).equals(dateEndTime.substring(0, 10))) {
  373. curBeginTime = this.getCurDate(shiftItemInfo.getPreTimeDayType().getValue(),
  374. curDate.substring(0, 10));
  375. beginTime = HRTimeWebUtils
  376. .stringToTimestamp(curBeginTime + " " + shiftItemInfo.getPreTime() + ":00");
  377. }
  378. shiftItemInfo = shiftItemColl.get(shiftItemColl.size() - 1);
  379. curBeginTime = this.getCurDate(shiftItemInfo.getNextTimeDayType().getValue(),
  380. dateEndTime.substring(0, 10));
  381. shiftItemEndTime = HRTimeWebUtils.stringToTimestamp(
  382. curBeginTime.substring(0, 10) + " " + shiftItemInfo.getNextTime() + ":00");
  383. boolean elasticCalLen = scheduleShiftInfo != null && scheduleShiftInfo.isIsElastic()
  384. && this.atsLeaveBillEntryInfo.isIsElasticCalLen();
  385. if (shiftItemEndTime.getTime() < endTime.getTime() && !elasticCalLen) {
  386. endTime = shiftItemEndTime;
  387. }
  388. }
  389. }
  390. if (!curDate.substring(0, 10).equals(dateEndTime.substring(0, 10))
  391. && !curDate.substring(0, 10).equals(dateBeginTime.substring(0, 10))) {
  392. if (isHalfDayOff) {
  393. beginTime = HRTimeWebUtils
  394. .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("amBeginTime") + ":00");
  395. endTime = HRTimeWebUtils
  396. .stringToTimestamp(curDate.substring(0, 10) + " " + res.get("pmEndTime") + ":00");
  397. } else {
  398. shiftItemInfo = shiftItemColl.get(0);
  399. curBeginTime = this.getCurDate(shiftItemInfo.getPreTimeDayType().getValue(),
  400. curDate.substring(0, 10));
  401. beginTime = HRTimeWebUtils
  402. .stringToTimestamp(curBeginTime + " " + shiftItemInfo.getPreTime() + ":00");
  403. if (beginTime.getTime() <= this.atsLeaveBillEntryInfo.getRealBeginTime().getTime()) {
  404. beginTime = this.atsLeaveBillEntryInfo.getRealBeginTime();
  405. }
  406. shiftItemInfo = shiftItemColl.get(shiftItemColl.size() - 1);
  407. String curEndTime = this.getCurDate(shiftItemInfo.getNextTimeDayType().getValue(),
  408. curDate.substring(0, 10));
  409. endTime = HRTimeWebUtils
  410. .stringToTimestamp(curEndTime.substring(0, 10) + " " + shiftItemInfo.getNextTime() + ":00");
  411. }
  412. }
  413. list = this.getSpiltDate(beginTime, endTime, shiftItemColl, dataLen, curDate.substring(0, 10));
  414. } catch (EASBizException var22) {
  415. var22.printStackTrace();
  416. }
  417. return (List) list;
  418. }
  419. private List<Map<String, Object>> getSpiltDate(Timestamp beginDate, Timestamp endDate,
  420. AtsShiftItemCollection shiftItemColl, BigDecimal dataLen, String curDate) {
  421. List<Map<String, Object>> dataList = new ArrayList();
  422. AtsShiftItemCollection collection = new AtsShiftItemCollection();
  423. AtsShiftItemCollection overTimecoll = new AtsShiftItemCollection();
  424. for (int i = 0; i < shiftItemColl.size(); ++i) {
  425. AtsShiftItemInfo info = shiftItemColl.get(i);
  426. String preDay = this.getCurDate(info.getPreTimeDayType().getValue(), curDate);
  427. Timestamp perTime = HRTimeWebUtils.stringToTimestamp(preDay + " " + info.getPreTime() + ":00");
  428. String nextDay = this.getCurDate(info.getNextTimeDayType().getValue(), curDate);
  429. Timestamp nextTime = HRTimeWebUtils.stringToTimestamp(nextDay + " " + info.getNextTime() + ":00");
  430. if (beginDate.getTime() <= nextTime.getTime() && perTime.getTime() <= endDate.getTime()
  431. || info.getGroup().isIsElastic() && this.atsLeaveBillEntryInfo.isIsElasticCalLen()) {
  432. if (!this.holidayPolicyInfo.isIsFixOTAllowLeave()) {
  433. if (info.getAttendanceType() == AttendanceTypeEnum.normalAttance
  434. || info.getAttendanceType() == AttendanceTypeEnum.normalAttanceExcludExcep) {
  435. collection.add(info);
  436. }
  437. } else if (info.getAttendanceType() != AttendanceTypeEnum.normalAttance
  438. && info.getAttendanceType() != AttendanceTypeEnum.normalAttanceExcludExcep) {
  439. overTimecoll.add(info);
  440. } else {
  441. collection.add(info);
  442. }
  443. }
  444. }
  445. BigDecimal billTime = this.defaultStandardHour.multiply(new BigDecimal(3600000));
  446. this.sourceLen = dataLen.setScale(this.decimalPlaceValue, RoundingMode.HALF_UP);
  447. Map<String, Object> res = this.getIsCtrlHalfDayOff(this.ctx);
  448. boolean isHalfDayOff = (Boolean) res.get("isHalfDayOff");
  449. if (isHalfDayOff) {
  450. HashMap amMap;
  451. if (beginDate.getTime() == HRTimeWebUtils.stringToTimestamp(curDate + " " + res.get("amBeginTime") + ":00")
  452. .getTime()
  453. && endDate.getTime() == HRTimeWebUtils
  454. .stringToTimestamp(curDate + " " + res.get("pmEndTime") + ":00").getTime()) {
  455. amMap = new HashMap();
  456. amMap.put("leaveLength", new BigDecimal(1));
  457. amMap.put("beginTime", res.get("amBeginTime"));
  458. amMap.put("endTime", res.get("pmEndTime"));
  459. amMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
  460. ((List) dataList).add(amMap);
  461. } else if ((beginDate.getTime() != HRTimeWebUtils
  462. .stringToTimestamp(curDate + " " + res.get("amBeginTime") + ":00").getTime()
  463. || endDate.getTime() != HRTimeWebUtils
  464. .stringToTimestamp(curDate + " " + res.get("amEndTime") + ":00").getTime())
  465. && endDate.getTime() != HRTimeWebUtils
  466. .stringToTimestamp(curDate + " " + res.get("pmBeginTime") + ":00").getTime()) {
  467. amMap = new HashMap();
  468. amMap.put("leaveLength", this.sourceLen);
  469. amMap.put("beginTime", res.get("pmBeginTime"));
  470. amMap.put("endTime", res.get("pmEndTime"));
  471. amMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
  472. ((List) dataList).add(amMap);
  473. } else {
  474. amMap = new HashMap();
  475. amMap.put("leaveLength", this.sourceLen);
  476. amMap.put("beginTime", res.get("amBeginTime"));
  477. amMap.put("endTime", res.get("amEndTime"));
  478. amMap.put("attAdminOrgUnit", this.billInfo.getAdminOrg().getId().toString());
  479. ((List) dataList).add(amMap);
  480. }
  481. } else {
  482. dataList = this.getDataSpiltMap((List) dataList, collection, curDate, beginDate, endDate, billTime,
  483. this.defaultStandardHour);
  484. if (overTimecoll.size() > 0) {
  485. dataList = this.getDataSpiltMap((List) dataList, overTimecoll, curDate, beginDate, endDate, billTime,
  486. this.defaultStandardHour);
  487. }
  488. if (this.sourceLen.compareTo(new BigDecimal(0)) == 1) {
  489. Map<String, Object> dataSpiltMap = (Map) ((List) dataList).get(((List) dataList).size() - 1);
  490. BigDecimal leaveLength = this.sourceLen.add((BigDecimal) dataSpiltMap.get("leaveLength"));
  491. ((Map) ((List) dataList).get(((List) dataList).size() - 1)).put("leaveLength", leaveLength);
  492. }
  493. }
  494. return (List) dataList;
  495. }
  496. private List<Map<String, Object>> getDataSpiltMap(List<Map<String, Object>> dataList,
  497. AtsShiftItemCollection collection, String curDate, Timestamp beginDate, Timestamp endDate,
  498. BigDecimal billTime, BigDecimal defaultHour) {
  499. for (int i = 0; i < collection.size(); ++i) {
  500. if (this.sourceLen.compareTo(new BigDecimal(0)) == 1) {
  501. Map<String, Object> dataSpiltMap = new HashMap();
  502. AtsShiftItemInfo info = collection.get(i);
  503. String beginTime = this.getCurDate(info.getPreTimeDayType().getValue(), curDate);
  504. Timestamp perTime = HRTimeWebUtils.stringToTimestamp(beginTime + " " + info.getPreTime() + ":00");
  505. String endTime = this.getCurDate(info.getNextTimeDayType().getValue(), curDate);
  506. Timestamp nextTime = HRTimeWebUtils.stringToTimestamp(endTime + " " + info.getNextTime() + ":00");
  507. BigDecimal time;
  508. BigDecimal item;
  509. if (i == 0) {
  510. new BigDecimal(0);
  511. if (nextTime.getTime() >= endDate.getTime()) {
  512. if (beginDate.getTime() <= perTime.getTime()) {
  513. beginDate = perTime;
  514. }
  515. item = new BigDecimal(endDate.getTime() - beginDate.getTime());
  516. if (item.compareTo(BigDecimal.ZERO) <= 0) {
  517. continue;
  518. }
  519. time = item.divide(billTime, this.decimalPlaceValue, 4);
  520. dataSpiltMap.put("beginTime", HRTimeWebUtils.timestampToString(beginDate).substring(11, 16));
  521. dataSpiltMap.put("endTime", HRTimeWebUtils.timestampToString(endDate).substring(11, 16));
  522. } else {
  523. item = new BigDecimal(nextTime.getTime() - beginDate.getTime());
  524. if (item.compareTo(BigDecimal.ZERO) <= 0) {
  525. continue;
  526. }
  527. time = item.divide(billTime, this.decimalPlaceValue, 4);
  528. dataSpiltMap.put("beginTime", HRTimeWebUtils.timestampToString(beginDate).substring(11, 16));
  529. dataSpiltMap.put("endTime", info.getNextTime());
  530. }
  531. this.sourceLen = this.getBigDecimal(defaultHour, dataSpiltMap, time);
  532. } else if (i != collection.size() - 1 && endDate.getTime() > nextTime.getTime()) {
  533. time = new BigDecimal(nextTime.getTime() - perTime.getTime());
  534. if (time.compareTo(BigDecimal.ZERO) <= 0) {
  535. continue;
  536. }
  537. item = time.divide(billTime, this.decimalPlaceValue, 4);
  538. dataSpiltMap.put("beginTime", info.getPreTime());
  539. dataSpiltMap.put("endTime", info.getNextTime());
  540. this.sourceLen = this.getBigDecimal(defaultHour, dataSpiltMap, item);
  541. } else {
  542. if (endDate.getTime() >= nextTime.getTime()) {
  543. endDate = nextTime;
  544. }
  545. time = new BigDecimal(endDate.getTime() - perTime.getTime());
  546. if (time.compareTo(BigDecimal.ZERO) <= 0) {
  547. continue;
  548. }
  549. item = time.divide(billTime, this.decimalPlaceValue, 4);
  550. dataSpiltMap.put("beginTime", info.getPreTime());
  551. dataSpiltMap.put("endTime", HRTimeWebUtils.timestampToString(endDate).substring(11, 16));
  552. this.sourceLen = this.getBigDecimal(defaultHour, dataSpiltMap, item);
  553. }
  554. dataSpiltMap.put("attAdminOrgUnit", info.getString("adminOrgUnit"));
  555. dataList.add(dataSpiltMap);
  556. }
  557. }
  558. return dataList;
  559. }
  560. private String getCurDate(int dateType, String curDate) {
  561. Date date = HRTimeWebUtils.stringToShortDate(curDate);
  562. Calendar calendar = Calendar.getInstance();
  563. calendar.setTime(date);
  564. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  565. if (dateType == 0) {
  566. calendar.add(5, -1);
  567. } else if (dateType == 2) {
  568. calendar.add(5, 1);
  569. }
  570. return simpleDateFormat.format(calendar.getTime());
  571. }
  572. private BigDecimal getBigDecimal(BigDecimal defaultHour, Map<String, Object> dataSpiltMap, BigDecimal time) {
  573. new BigDecimal(0);
  574. BigDecimal value;
  575. if (this.holidayPolicyInfo.getUnit().getValue() == 1) {
  576. value = time;
  577. } else {
  578. value = defaultHour.multiply(time).setScale(this.decimalPlaceValue, 4);
  579. }
  580. if (this.sourceLen.compareTo(value) == 1) {
  581. dataSpiltMap.put("leaveLength", value);
  582. this.sourceLen = this.sourceLen.subtract(value);
  583. } else {
  584. dataSpiltMap.put("leaveLength", this.sourceLen);
  585. this.sourceLen = new BigDecimal(0);
  586. }
  587. return this.sourceLen;
  588. }
  589. private double getValueByMinLeaveLength(HolidayPolicyInfo holidayPolicyInfo, BigDecimal realLengthBigDecimal) {
  590. int saveLength = this.getSaveLength(this.ctx, holidayPolicyInfo);
  591. double length = realLengthBigDecimal.setScale(saveLength, 4).doubleValue();
  592. if (holidayPolicyInfo != null && holidayPolicyInfo.isEnableLeaveLength()) {
  593. double M = holidayPolicyInfo.getMinLeaveLength().doubleValue();
  594. int minLeaveLengthMtd = holidayPolicyInfo.getMinLeaveLengthVMtd().getValue();
  595. int ZNum = (int) (length / M);
  596. double XSNum = length % M;
  597. if (minLeaveLengthMtd == 1) {
  598. length = ((double) ZNum + Math.floor(XSNum / M)) * M;
  599. } else if (minLeaveLengthMtd == 2) {
  600. length = ((double) ZNum + Math.ceil(XSNum / M)) * M;
  601. } else if (minLeaveLengthMtd == 3) {
  602. length = (double) ((long) ZNum + Math.round(XSNum / M)) * M;
  603. }
  604. }
  605. return length;
  606. }
  607. public int getSaveLength(Context ctx, HolidayPolicyInfo holidayPolicyInfo) {
  608. int saveLength;
  609. if (holidayPolicyInfo != null && holidayPolicyInfo.isEnableLeaveLength()) {
  610. Double MinLeaveLength = holidayPolicyInfo.getMinLeaveLength().stripTrailingZeros().doubleValue();
  611. saveLength = getNumberDecimalDigits(MinLeaveLength);
  612. } else {
  613. saveLength = DecimalPlaceUtil.getDecimalPlaceSystem(ctx);
  614. }
  615. return saveLength;
  616. }
  617. public static int getNumberDecimalDigits(double number) {
  618. if (number == (double) ((long) number)) {
  619. return 0;
  620. } else {
  621. int i = 0;
  622. do {
  623. ++i;
  624. } while (number * Math.pow(10.0D, (double) i) % 1.0D != 0.0D);
  625. return i;
  626. }
  627. }
  628. private List dealDateNew(List<Date> dateList) throws EASBizException, BOSException {
  629. int length = dateList.size();
  630. String beginDate = AtsDateUtils.dateShortToString((Date) dateList.get(0));
  631. String endDate = AtsDateUtils.dateShortToString((Date) dateList.get(length - 1));
  632. String personIds = "'" + this.personId + "'";
  633. Map<String, ScheduleShiftInfo> scheduleShiftMap = AtsScheduleShiftUtil.getScheduleShiftByPriority(this.ctx,
  634. personIds, beginDate, endDate);
  635. Map<String, AttendanceFileInfo> attendanceFileMap = AtsServerUtils.getAttendanceFileInfoByPersonId(this.ctx,
  636. personIds, beginDate, endDate);
  637. int i;
  638. if (AtsCollectionUtile.isEmpty(attendanceFileMap)) {
  639. HolidayPolicySetInfo holidayPolicySetInfo = HolidayPolicySetFactory.getLocalInstance(this.ctx)
  640. .getHolidayPolicySetInfo("select workCalendar.id where id = '"
  641. + this.holidayPolicyInfo.getHolidayPolicySet().getId().toString() + "'");
  642. WorkCalendarItemCollection workCalendarItemColl = WorkCalendarItemFactory.getLocalInstance(this.ctx)
  643. .getWorkCalendarItemCollection(" where calendarGroup='"
  644. + holidayPolicySetInfo.getWorkCalendar().getId().toString() + "' and date>={ts'" + beginDate
  645. + "'} and date <={ts'" + endDate + "'} order by date asc ");
  646. if (this.holidayPolicyInfo.getHolidayPolicySet() != null) {
  647. for (i = 0; i < dateList.size(); ++i) {
  648. if (workCalendarItemColl.get(i) != null && workCalendarItemColl.get(i).getDayType() != null) {
  649. int dayType = workCalendarItemColl.get(i).getDayType().getValue();
  650. if (!this.isIncludeLegal && dayType == 2) {
  651. dateList.remove(i);
  652. workCalendarItemColl.remove(workCalendarItemColl.get(i));
  653. --i;
  654. } else if (!this.isIncludeRest && dayType == 1) {
  655. dateList.remove(i);
  656. workCalendarItemColl.remove(workCalendarItemColl.get(i));
  657. --i;
  658. }
  659. }
  660. }
  661. }
  662. } else {
  663. Set<String> unScheduleDateSet = new HashSet();
  664. Iterator var19 = dateList.iterator();
  665. label90 : while (true) {
  666. String scheduleShiftKey;
  667. Date date;
  668. do {
  669. if (!var19.hasNext()) {
  670. Map<String, Map> workCalendarItemMap = null;
  671. if (unScheduleDateSet.size() > 0) {
  672. workCalendarItemMap = this.getWorkCalendarItembyID(attendanceFileMap, unScheduleDateSet);
  673. }
  674. for (i = 0; i < dateList.size(); ++i) {
  675. Date currentDate = (Date) dateList.get(i);
  676. int dayType = 0;
  677. String scheduleShiftKey1 = this.personId + "_" + AtsDateUtils.dateShortToString(currentDate);
  678. if (scheduleShiftMap != null && scheduleShiftMap.get(scheduleShiftKey1) != null) {
  679. ScheduleShiftInfo scheduleShiftInfo = (ScheduleShiftInfo) scheduleShiftMap
  680. .get(scheduleShiftKey1);
  681. if (scheduleShiftInfo.getDayType() != null) {
  682. dayType = scheduleShiftInfo.getDayType().getValue();
  683. }
  684. } else {
  685. AttendanceFileInfo attendanceFileInfo = (AttendanceFileInfo) attendanceFileMap
  686. .get(scheduleShiftKey1);
  687. if (attendanceFileInfo != null && attendanceFileInfo.getAttencePolicy() != null
  688. && attendanceFileInfo.getAttencePolicy().getWorkCalendar() != null) {
  689. String workCalendarId = ((AttendanceFileInfo) attendanceFileMap
  690. .get(scheduleShiftKey1)).getAttencePolicy().getWorkCalendar().getId()
  691. .toString();
  692. if (workCalendarItemMap != null) {
  693. Map<String, WorkCalendarItemInfo> infoMap = (Map) workCalendarItemMap
  694. .get(workCalendarId);
  695. if (infoMap != null) {
  696. WorkCalendarItemInfo info = (WorkCalendarItemInfo) infoMap
  697. .get(AtsDateUtils.dateShortToString(currentDate));
  698. if (info != null && info.getDayType() != null) {
  699. dayType = info.getDayType().getValue();
  700. }
  701. }
  702. }
  703. }
  704. }
  705. if (!this.isIncludeLegal && dayType == 2) {
  706. dateList.remove(i);
  707. --i;
  708. } else if (!this.isIncludeRest && dayType == 1) {
  709. dateList.remove(i);
  710. --i;
  711. }
  712. }
  713. break label90;
  714. }
  715. date = (Date) var19.next();
  716. scheduleShiftKey = this.personId + "_" + AtsDateUtils.dateShortToString(date);
  717. } while (scheduleShiftMap != null && scheduleShiftMap.size() != 0
  718. && scheduleShiftMap.get(scheduleShiftKey) != null);
  719. unScheduleDateSet.add(AtsDateUtils.dateShortToString(date));
  720. }
  721. }
  722. return dateList;
  723. }
  724. private Map<String, Map> getWorkCalendarItembyID(Map<String, AttendanceFileInfo> attendanceFileMap,
  725. Set<String> unScheduleDateSet) throws BOSException {
  726. Map<String, Map> result = new HashMap();
  727. Set<String> workCalendarIds = new HashSet();
  728. Iterator var5 = attendanceFileMap.entrySet().iterator();
  729. while (var5.hasNext()) {
  730. Entry<String, AttendanceFileInfo> entry = (Entry) var5.next();
  731. if (entry.getValue() != null && ((AttendanceFileInfo) entry.getValue()).getCalendar() != null) {
  732. workCalendarIds.add(((AttendanceFileInfo) entry.getValue()).getCalendar().getId().toString());
  733. }
  734. }
  735. String workCalendarIdStr = AtsCollectionUtile.joinForSql(workCalendarIds);
  736. System.out.println("splitHelperError:" + convertSetToString(unScheduleDateSet));
  737. StringBuffer buffer = new StringBuffer();
  738. buffer.append("select FDayType,fid,FDate,FCalendarGroupID ").append(" from T_HR_ATS_WorkCalendarItem ")
  739. .append(" where FCalendarGroupID in (").append(workCalendarIdStr).append(") ").append(" and FDate in(")
  740. .append(convertSetToString(unScheduleDateSet)).append(") ");
  741. WorkCalendarItemCollection workCalendarItemColl = new WorkCalendarItemCollection();
  742. try {
  743. IRowSet row = DbUtil.executeQuery(this.ctx, buffer.toString());
  744. while (row.next()) {
  745. WorkCalendarItemInfo info = new WorkCalendarItemInfo();
  746. WorkCalendarInfo dar = new WorkCalendarInfo();
  747. info.setDayType(DayTypeEnum.getEnum(row.getInt("FDayType")));
  748. info.setId(BOSUuid.read(row.getString("fid")));
  749. dar.setId(BOSUuid.read(row.getString("FCalendarGroupID")));
  750. info.setCalendarGroup(dar);
  751. info.setDate(row.getDate("FDate"));
  752. workCalendarItemColl.add(info);
  753. }
  754. } catch (SQLException var14) {
  755. var14.printStackTrace();
  756. }
  757. Iterator var17 = workCalendarIds.iterator();
  758. while (var17.hasNext()) {
  759. String workCalendarId = (String) var17.next();
  760. Map<String, WorkCalendarItemInfo> workCalendarMap = new HashMap();
  761. Iterator var11 = unScheduleDateSet.iterator();
  762. while (var11.hasNext()) {
  763. String dateStr = (String) var11.next();
  764. for (int j = 0; j < workCalendarItemColl.size(); ++j) {
  765. if (workCalendarItemColl.get(j).getCalendarGroup().getId().toString().equals(workCalendarId)
  766. && workCalendarItemColl.get(j).getDate().toString().equals(dateStr)) {
  767. workCalendarMap.put(dateStr, workCalendarItemColl.get(j));
  768. }
  769. }
  770. }
  771. result.put(workCalendarId, workCalendarMap);
  772. }
  773. return result;
  774. }
  775. public static String convertSetToString(Set set) {
  776. if (set != null && set.size() > 0) {
  777. Iterator iter = set.iterator();
  778. StringBuffer sql = new StringBuffer();
  779. while (iter.hasNext()) {
  780. String date = iter.next().toString();
  781. if (date.length() > 0) {
  782. date = date.substring(0, 10);
  783. }
  784. sql.append("{ts'");
  785. sql.append(date);
  786. sql.append("'},");
  787. }
  788. sql.deleteCharAt(sql.length() - 1);
  789. return sql.toString();
  790. } else {
  791. return "''";
  792. }
  793. }
  794. private List getLeaveDateColl(Timestamp beginTime, Timestamp endTime) throws EASBizException, BOSException {
  795. List<Date> dateList = new ArrayList();
  796. Date beginDate = AtsDateUtils.stringToShortDate(AtsDateUtils.dateLongToString(beginTime));
  797. Date endDate = AtsDateUtils.stringToShortDate(AtsDateUtils.dateLongToString(endTime));
  798. Calendar beginCal = Calendar.getInstance();
  799. beginCal.setTime(beginDate);
  800. Calendar endCal = Calendar.getInstance();
  801. endCal.setTime(endDate);
  802. int temp = (int) ((endDate.getTime() - beginDate.getTime()) / 86400000L + 1L);
  803. for (int i = 0; i < temp; ++i) {
  804. int year = beginCal.get(1);
  805. int month = beginCal.get(2);
  806. int day = beginCal.get(5);
  807. Date tempDate = new Date(year - 1900, month, day);
  808. dateList.add(tempDate);
  809. beginCal.add(5, 1);
  810. }
  811. return dateList;
  812. }
  813. public Map<String, Object> calRealLeaveLengthInfo(List<Date> afterDealDateList, Date beginTimeCount,
  814. Date endTimeCount, HolidayTypeUnitEnum holidayTypeUnit, AtsHolidayFileInfo holidayFileInfo,
  815. HolidayPolicyInfo holidayPolicyInfo) {
  816. int tempAfterDealDateListSize = afterDealDateList.size();
  817. new AtsShiftItemCollection();
  818. Timestamp beginTimeCountTs = AtsDateUtils.dateToTimestamp(beginTimeCount);
  819. Timestamp endTimeCountTs = AtsDateUtils.dateToTimestamp(endTimeCount);
  820. HashMap defaultItemMap = new HashMap();
  821. try {
  822. AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
  823. beginTimeCountTs, endTimeCountTs, this.personId, (String) null);
  824. defaultItemMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx, attendanceFileHisInfo,
  825. holidayPolicyInfo);
  826. } catch (BOSException var23) {
  827. var23.printStackTrace();
  828. }
  829. AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) defaultItemMap
  830. .get("scheduleShiftItemColl");
  831. this.defaultStandardHour = (BigDecimal) defaultItemMap.get("standardHour");
  832. String beginDate = AtsDateUtils.dateLongToString(beginTimeCount).substring(0, 10);
  833. String endDate = AtsDateUtils.dateLongToString(endTimeCount).substring(0, 10);
  834. AtsHolidayFileHisCollection atsHolidayFileHisCollection = null;
  835. BigDecimal standardHour = new BigDecimal(0);
  836. try {
  837. atsHolidayFileHisCollection = AtsHolidayFileHisFactory.getLocalInstance(this.ctx)
  838. .getAtsHolidayFileHisCollection("where proposer.id='" + this.personId + "' order by effdt asc");
  839. if (null != atsHolidayFileHisCollection && atsHolidayFileHisCollection.size() > 0) {
  840. for (int i = 0; i < atsHolidayFileHisCollection.size(); ++i) {
  841. AtsHolidayFileHisInfo atsHolidayFileHisInfo = atsHolidayFileHisCollection.get(i);
  842. if (beginTimeCount.getTime() >= atsHolidayFileHisInfo.getEFFDT().getTime()
  843. && endTimeCount.getTime() <= atsHolidayFileHisInfo.getLEFFDT().getTime()) {
  844. String id = atsHolidayFileHisInfo.getHolidayPolicySet().getId().toString();
  845. HolidayPolicySetInfo holidayPolicyInfo_1 = HolidayPolicySetFactory.getLocalInstance(this.ctx)
  846. .getHolidayPolicySetInfo(" where id = '" + id + "'");
  847. standardHour = holidayPolicyInfo_1.getDefaultStandardHour();
  848. }
  849. }
  850. }
  851. } catch (Exception var24) {
  852. var24.printStackTrace();
  853. }
  854. Map<String, Object> paramMap = new HashMap();
  855. paramMap.put("personId", this.personId);
  856. paramMap.put("beginDate", beginDate);
  857. paramMap.put("endDate", endDate);
  858. paramMap.put("endTimeCount", endTimeCount);
  859. paramMap.put("beginTimeCount", beginTimeCount);
  860. paramMap.put("defaultStandardHour", this.defaultStandardHour);
  861. paramMap.put("holidayTypeUnit", holidayTypeUnit);
  862. paramMap.put("isFixOTAllowLeave", holidayPolicyInfo.isIsFixOTAllowLeave());
  863. paramMap.put("afterDealDateList", afterDealDateList);
  864. paramMap.put("defaultAtsShiftItemCollection", defaultAtsShiftItemCollection);
  865. paramMap.put("dayStandardHour", standardHour);
  866. Map<String, Object> DateLeaveLenMap = new HashMap();
  867. Date nowDate;
  868. String nowDateStr;
  869. if (tempAfterDealDateListSize != 0) {
  870. if (afterDealDateList.size() == 1
  871. && afterDealDateList
  872. .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()))
  873. && afterDealDateList
  874. .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()))) {
  875. paramMap.put("curDate", beginDate);
  876. paramMap.put("index", "index");
  877. this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
  878. } else {
  879. boolean isContainBeginDate = afterDealDateList
  880. .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()));
  881. boolean isContainEndDate = afterDealDateList
  882. .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()));
  883. if (isContainBeginDate) {
  884. paramMap.put("curDate", beginDate);
  885. afterDealDateList
  886. .remove(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()));
  887. this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
  888. }
  889. if (isContainEndDate) {
  890. paramMap.put("curDate", endDate);
  891. afterDealDateList.remove(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()));
  892. this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
  893. }
  894. if (tempAfterDealDateListSize >= 3) {
  895. nowDate = AtsDateUtils.getPreDay(AtsDateUtils.stringToShortDate(endDate));
  896. nowDateStr = AtsDateUtils.dateShortToString(nowDate);
  897. boolean isPreEndDate = afterDealDateList
  898. .contains(new Date(AtsDateUtils.stringToTimestamp(nowDateStr + " 00:00:00").getTime()));
  899. if (isPreEndDate) {
  900. paramMap.put("curDate", nowDateStr);
  901. paramMap.put("nowDate", nowDate);
  902. paramMap.put("index", "calPreEndDate");
  903. afterDealDateList
  904. .remove(new Date(AtsDateUtils.stringToTimestamp(nowDateStr + " 00:00:00").getTime()));
  905. this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
  906. }
  907. }
  908. this.getMidleDateLength(this.ctx, paramMap, DateLeaveLenMap);
  909. }
  910. }
  911. Date nowDate1 = AtsDateUtils.getPreDay(AtsDateUtils.stringToShortDate(beginDate));
  912. String nowDateStr1 = AtsDateUtils.dateShortToString(nowDate1);
  913. paramMap.put("curDate", nowDateStr1);
  914. paramMap.put("nowDate", nowDate1);
  915. paramMap.put("index", "calPrebeginDate");
  916. this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
  917. nowDate1 = AtsDateUtils.getNextDay(AtsDateUtils.stringToShortDate(endDate));
  918. nowDateStr1 = AtsDateUtils.dateShortToString(nowDate1);
  919. paramMap.put("curDate", nowDateStr1);
  920. paramMap.put("nowDate", nowDate1);
  921. paramMap.put("index", "calNextendDate");
  922. this.getBeginDateOrEndDateLength(this.ctx, paramMap, DateLeaveLenMap);
  923. return DateLeaveLenMap;
  924. }
  925. public void getMidleDateLength(Context ctx, Map<String, Object> paramMap, Map<String, Object> DateLeaveLenMap) {
  926. HolidayTypeUnitEnum holidayTypeUnit = (HolidayTypeUnitEnum) paramMap.get("holidayTypeUnit");
  927. List<Date> afterDealDateList = (List) paramMap.get("afterDealDateList");
  928. AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) paramMap
  929. .get("defaultAtsShiftItemCollection");
  930. String personId = (String) paramMap.get("personId");
  931. String beginDate = (String) paramMap.get("beginDate");
  932. String endDate = (String) paramMap.get("endDate");
  933. Boolean isFixOTAllowLeave = (Boolean) paramMap.get("isFixOTAllowLeave");
  934. BigDecimal defaultStandardHour = (BigDecimal) paramMap.get("defaultStandardHour");
  935. BigDecimal dayStandardHour = (BigDecimal) paramMap.get("dayStandardHour");
  936. new BigDecimal(0);
  937. if (afterDealDateList.size() > 0) {
  938. HashMap curDateMap;
  939. if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
  940. for (int i = 0; i < afterDealDateList.size(); ++i) {
  941. boolean isHalfDay = AtsLeaveBillUtils.isHalfDay(ctx, personId, (Date) afterDealDateList.get(i));
  942. String curDate = AtsDateUtils.dateShortToString((Date) afterDealDateList.get(i));
  943. curDateMap = new HashMap();
  944. if (isHalfDay) {
  945. curDateMap.put("calDay", 0.5D);
  946. } else {
  947. curDateMap.put("calDay", 1.0D);
  948. }
  949. curDateMap.put("calHour", 0.0D);
  950. DateLeaveLenMap.put(curDate, curDateMap);
  951. }
  952. } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
  953. try {
  954. Map<String, ScheduleShiftInfo> scheduleShiftInfoMap = AtsScheduleShiftUtil
  955. .getScheduleShiftByPriority(ctx, personId, beginDate, endDate);
  956. ScheduleShiftInfo scheduleShiftInfo = null;
  957. for (int i = 0; i < afterDealDateList.size(); ++i) {
  958. curDateMap = new HashMap();
  959. Date currentDate = (Date) afterDealDateList.get(i);
  960. String curDate = AtsDateUtils.dateShortToString(currentDate);
  961. curDateMap.put("calDay", 0.0D);
  962. String key = personId + "_" + AtsDateUtils.dateShortToString(currentDate);
  963. DateLeaveLenMap.put(curDate, curDateMap);
  964. if (null != scheduleShiftInfoMap) {
  965. scheduleShiftInfo = (ScheduleShiftInfo) scheduleShiftInfoMap.get(key);
  966. }
  967. if (scheduleShiftInfo != null) {
  968. BigDecimal standardHour = scheduleShiftInfo.getStandardHour();
  969. curDateMap.put("calHour", standardHour.doubleValue());
  970. if (isFixOTAllowLeave) {
  971. curDateMap.put("calHour", standardHour.doubleValue()
  972. + this.getFixOTSegHour(scheduleShiftInfo.getItems()));
  973. }
  974. } else if (defaultAtsShiftItemCollection.size() != 0) {
  975. curDateMap.put("calHour", defaultStandardHour.doubleValue());
  976. if (isFixOTAllowLeave) {
  977. curDateMap.put("calHour", defaultStandardHour.doubleValue()
  978. + this.getFixOTSegHour(defaultAtsShiftItemCollection));
  979. }
  980. } else {
  981. curDateMap.put("calHour", dayStandardHour.doubleValue());
  982. }
  983. }
  984. } catch (Exception var21) {
  985. var21.printStackTrace();
  986. }
  987. }
  988. }
  989. }
  990. public double getFixOTSegHour(ScheduleShiftItemCollection item) {
  991. double otSegHour = 0.0D;
  992. ScheduleShiftItemInfo info = null;
  993. int i = 0;
  994. for (int len = item.size(); i < len; ++i) {
  995. info = item.get(i);
  996. if (info.getAttendanceType().equals(AttendanceTypeEnum.fixedOverTime)) {
  997. otSegHour += (double) ((info.getNextDateTime().getTime() - info.getPreDateTime().getTime()) / 3600000L);
  998. }
  999. }
  1000. return otSegHour;
  1001. }
  1002. public double getFixOTSegHour(AtsShiftItemCollection item) {
  1003. double otSegHour = 0.0D;
  1004. AtsShiftItemInfo info = null;
  1005. int i = 0;
  1006. for (int len = item.size(); i < len; ++i) {
  1007. info = item.get(i);
  1008. if (info.getAttendanceType().equals(AttendanceTypeEnum.fixedOverTime)) {
  1009. String preTime = info.getPreTime() + ":00";
  1010. String nextTime = info.getNextTime() + ":00";
  1011. if (preTime.compareTo(nextTime) > 0) {
  1012. preTime = "1900-01-01 " + preTime;
  1013. nextTime = "1900-01-02 " + nextTime;
  1014. } else {
  1015. preTime = "1900-01-01 " + preTime;
  1016. nextTime = "1900-01-01 " + nextTime;
  1017. }
  1018. otSegHour += (double) ((HRTimeWebUtils.stringToTimestamp(nextTime).getTime()
  1019. - HRTimeWebUtils.stringToTimestamp(preTime).getTime()) / 3600000L);
  1020. }
  1021. }
  1022. return otSegHour;
  1023. }
  1024. public void getBeginDateOrEndDateLength(Context ctx, Map<String, Object> paramMap,
  1025. Map<String, Object> DateLeaveLenMap) {
  1026. HolidayTypeUnitEnum holidayTypeUnit = (HolidayTypeUnitEnum) paramMap.get("holidayTypeUnit");
  1027. AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) paramMap
  1028. .get("defaultAtsShiftItemCollection");
  1029. String personId = (String) paramMap.get("personId");
  1030. String beginDate = (String) paramMap.get("beginDate");
  1031. String endDate = (String) paramMap.get("endDate");
  1032. String curDate = (String) paramMap.get("curDate");
  1033. Boolean isFixOTAllowLeave = (Boolean) paramMap.get("isFixOTAllowLeave");
  1034. Timestamp beginTimeCount = (Timestamp) paramMap.get("beginTimeCount");
  1035. Timestamp endTimeCount = (Timestamp) paramMap.get("endTimeCount");
  1036. BigDecimal defaultStandardHour = (BigDecimal) paramMap.get("defaultStandardHour");
  1037. BigDecimal standardHour = (BigDecimal) paramMap.get("dayStandardHour");
  1038. long leaveLength = 0L;
  1039. try {
  1040. HashMap<String, Object> dateMap = AtsLeaveBillUtils.getScheduleShiftItemCollByDate(ctx, personId,
  1041. new Date(AtsDateUtils.stringToTimestamp(curDate + " 00:00:00").getTime()), isFixOTAllowLeave);
  1042. ScheduleShiftItemCollection scheduleShiftItemColl = (ScheduleShiftItemCollection) dateMap
  1043. .get("scheduleShiftItemColl");
  1044. if (scheduleShiftItemColl.size() == 0 && defaultAtsShiftItemCollection.size() == 0) {
  1045. standardHour = new BigDecimal(24);
  1046. String index = (String) paramMap.get("index");
  1047. if (!StringUtils.isEmpty(index) && index.equals("index")) {
  1048. leaveLength = endTimeCount.getTime() - beginTimeCount.getTime();
  1049. } else if (curDate.equals(endDate)) {
  1050. leaveLength = leaveLength + endTimeCount.getTime()
  1051. - AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime();
  1052. } else if (curDate.equals(beginDate)) {
  1053. leaveLength = leaveLength + AtsDateUtils.stringToTimestamp(beginDate + " 23:59:59").getTime()
  1054. - beginTimeCount.getTime();
  1055. } else if (!StringUtils.isEmpty(index) && index.equals("calPreEndDate")) {
  1056. leaveLength = (long) ((double) standardHour.longValue() * 60.0D * 60.0D * 1000.0D);
  1057. }
  1058. } else {
  1059. List<HashMap<String, Object>> shift = null;
  1060. if (scheduleShiftItemColl.size() != 0) {
  1061. standardHour = (BigDecimal) dateMap.get("standardHour");
  1062. shift = AtsLeaveBillUtils.getShiftItemInfos(scheduleShiftItemColl, curDate,
  1063. this.atsLeaveBillEntryInfo == null ? null : this.atsLeaveBillEntryInfo.isIsElasticCalLen());
  1064. } else {
  1065. standardHour = defaultStandardHour;
  1066. shift = AtsLeaveBillUtils.getShiftItemInfos(defaultAtsShiftItemCollection, curDate,
  1067. this.atsLeaveBillEntryInfo == null ? null : this.atsLeaveBillEntryInfo.isIsElasticCalLen());
  1068. }
  1069. Map<String, Object> res = AtsLeaveBillUtils.calSegmentLength(ctx, shift, beginTimeCount, endTimeCount,
  1070. leaveLength, this.holidayPolicyInfo, standardHour);
  1071. leaveLength = (Long) res.get("realLen");
  1072. }
  1073. } catch (EASBizException var21) {
  1074. var21.printStackTrace();
  1075. } catch (BOSException var22) {
  1076. var22.printStackTrace();
  1077. }
  1078. Map<String, Double> curDateMap = new HashMap();
  1079. if (leaveLength > 0L) {
  1080. if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
  1081. boolean isHalfDay = AtsLeaveBillUtils.isHalfDay(ctx, personId,
  1082. HRTimeWebUtils.stringToShortDate(curDate));
  1083. if (isHalfDay) {
  1084. curDateMap.put("calDay",
  1085. (double) leaveLength / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D * 2.0D) > 0.5D
  1086. ? 0.5D
  1087. : (double) leaveLength
  1088. / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D * 2.0D));
  1089. } else {
  1090. curDateMap.put("calDay",
  1091. (double) leaveLength / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D) > 1.0D
  1092. ? 1.0D
  1093. : (double) leaveLength / (standardHour.doubleValue() * 60.0D * 60.0D * 1000.0D));
  1094. }
  1095. } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
  1096. curDateMap.put("calHour",
  1097. (double) leaveLength / 3600000.0D > standardHour.doubleValue()
  1098. ? standardHour.doubleValue()
  1099. : (double) leaveLength / 3600000.0D);
  1100. }
  1101. DateLeaveLenMap.put(curDate, curDateMap);
  1102. }
  1103. }
  1104. public Map<String, Object> calRealLeaveLengthOfDay(List<Date> afterDealDateList, Date beginTimeCount,
  1105. Date endTimeCount, HolidayTypeUnitEnum holidayTypeUnit, AtsHolidayFileInfo holidayFileInfo,
  1106. HolidayPolicySetInfo holidayPolicySetInfo, HolidayPolicyInfo holidayPolicyInfo)
  1107. throws BOSException, EASBizException {
  1108. Map<String, Object> retMap = new HashMap();
  1109. if (afterDealDateList.size() == 0) {
  1110. return retMap;
  1111. } else {
  1112. Timestamp beginTimeCountTs = AtsDateUtils.dateToTimestamp(beginTimeCount);
  1113. Timestamp endTimeCountTs = AtsDateUtils.dateToTimestamp(endTimeCount);
  1114. AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
  1115. beginTimeCountTs, endTimeCountTs, this.personId, (String) null);
  1116. HashMap<String, Object> defaultItemMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx,
  1117. attendanceFileHisInfo, holidayPolicyInfo);
  1118. AtsShiftItemCollection defaultAtsShiftItemCollection = (AtsShiftItemCollection) defaultItemMap
  1119. .get("scheduleShiftItemColl");
  1120. BigDecimal defaultStandardHour = (BigDecimal) defaultItemMap.get("standardHour");
  1121. new BigDecimal(8);
  1122. String beginDate = AtsDateUtils.dateLongToString(beginTimeCount).substring(0, 10);
  1123. String endDate = AtsDateUtils.dateLongToString(endTimeCount).substring(0, 10);
  1124. String amStartTime = holidayPolicySetInfo.getAmStartWorkTime();
  1125. String amEndTime = holidayPolicySetInfo.getAmEndWorkTime();
  1126. String pmStartTime = holidayPolicySetInfo.getPmStartWorkTime();
  1127. String pmEndTime = holidayPolicySetInfo.getPmEndWorkTime();
  1128. HolidayTypeUnitEnum holidayUnit = holidayPolicyInfo.getUnit();
  1129. Boolean isFixOTAllowLeave = holidayPolicyInfo.isIsFixOTAllowLeave();
  1130. double realLength = 0.0D;
  1131. double leaveLengthDay = 0.0D;
  1132. double leaveLengthHour = 0.0D;
  1133. BigDecimal standardHour;
  1134. boolean isHalfDay;
  1135. String amEndTimeTemp;
  1136. if (afterDealDateList.size() == 1
  1137. && afterDealDateList
  1138. .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()))
  1139. && afterDealDateList
  1140. .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()))) {
  1141. isHalfDay = AtsLeaveBillUtils.isHalfDay(this.ctx, this.personId,
  1142. HRTimeWebUtils.stringToShortDate(beginDate));
  1143. amEndTimeTemp = AtsDateUtils.dateLongToString(beginTimeCount).substring(11, 16);
  1144. String endTimeTemp = AtsDateUtils.dateLongToString(endTimeCount).substring(11, 16);
  1145. if ((!amEndTimeTemp.equals(amStartTime) || !endTimeTemp.equals(amEndTime))
  1146. && (!amEndTimeTemp.equals(pmStartTime) || !endTimeTemp.equals(pmEndTime))
  1147. && (!amEndTimeTemp.equals(amStartTime) || !endTimeTemp.equals(pmStartTime))
  1148. && (!amEndTimeTemp.equals(amEndTime) || !endTimeTemp.equals(pmEndTime))) {
  1149. if (amEndTimeTemp.equals(amStartTime) && endTimeTemp.equals(pmEndTime)) {
  1150. realLength = 1.0D;
  1151. } else {
  1152. realLength = 0.0D;
  1153. }
  1154. } else {
  1155. realLength = 0.5D;
  1156. }
  1157. if (realLength > 0.0D) {
  1158. Map<String, Double> curDateMap = new HashMap();
  1159. if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
  1160. if (isHalfDay) {
  1161. leaveLengthDay = 0.5D;
  1162. } else {
  1163. leaveLengthDay = realLength;
  1164. }
  1165. curDateMap.put("calDay", leaveLengthDay);
  1166. curDateMap.put("calHour", 0.0D);
  1167. } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
  1168. standardHour = this.getStandardHourOfDay(this.ctx, this.personId, beginDate,
  1169. defaultAtsShiftItemCollection, defaultStandardHour,
  1170. holidayPolicyInfo.isIsFixOTAllowLeave());
  1171. leaveLengthHour = realLength * standardHour.doubleValue();
  1172. curDateMap.put("calDay", 0.0D);
  1173. curDateMap.put("calHour", leaveLengthHour);
  1174. }
  1175. retMap.put(beginDate, curDateMap);
  1176. }
  1177. } else {
  1178. HashMap curDateMap;
  1179. if (afterDealDateList
  1180. .contains(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()))) {
  1181. isHalfDay = AtsLeaveBillUtils.isHalfDay(this.ctx, this.personId,
  1182. HRTimeWebUtils.stringToShortDate(beginDate));
  1183. amEndTimeTemp = AtsDateUtils.dateLongToString(beginTimeCount).substring(11, 16);
  1184. afterDealDateList
  1185. .remove(new Date(AtsDateUtils.stringToTimestamp(beginDate + " 00:00:00").getTime()));
  1186. if (amEndTimeTemp.equals(amStartTime)) {
  1187. realLength = 1.0D;
  1188. } else if (amEndTimeTemp.equals(pmStartTime)) {
  1189. realLength = 0.5D;
  1190. } else {
  1191. realLength = 0.0D;
  1192. }
  1193. if (realLength > 0.0D) {
  1194. curDateMap = new HashMap();
  1195. if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
  1196. if (isHalfDay) {
  1197. leaveLengthDay = 0.5D;
  1198. } else {
  1199. leaveLengthDay = realLength;
  1200. }
  1201. curDateMap.put("calDay", leaveLengthDay);
  1202. curDateMap.put("calHour", 0.0D);
  1203. } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
  1204. standardHour = this.getStandardHourOfDay(this.ctx, this.personId, beginDate,
  1205. defaultAtsShiftItemCollection, defaultStandardHour,
  1206. holidayPolicyInfo.isIsFixOTAllowLeave());
  1207. leaveLengthHour = realLength * standardHour.doubleValue();
  1208. curDateMap.put("calDay", 0.0D);
  1209. curDateMap.put("calHour", leaveLengthHour);
  1210. }
  1211. retMap.put(beginDate, curDateMap);
  1212. }
  1213. }
  1214. if (afterDealDateList
  1215. .contains(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()))) {
  1216. isHalfDay = AtsLeaveBillUtils.isHalfDay(this.ctx, this.personId,
  1217. HRTimeWebUtils.stringToShortDate(endDate));
  1218. afterDealDateList.remove(new Date(AtsDateUtils.stringToTimestamp(endDate + " 00:00:00").getTime()));
  1219. amEndTimeTemp = AtsDateUtils.dateLongToString(endTimeCount).substring(11, 16);
  1220. realLength = 0.0D;
  1221. if (!amEndTimeTemp.equals(amEndTime) && !amEndTimeTemp.equals(pmStartTime)) {
  1222. if (amEndTimeTemp.equals(pmEndTime)) {
  1223. realLength = 1.0D;
  1224. } else {
  1225. realLength = 0.0D;
  1226. }
  1227. } else {
  1228. realLength = 0.5D;
  1229. }
  1230. if (realLength > 0.0D) {
  1231. curDateMap = new HashMap();
  1232. if (holidayTypeUnit == HolidayTypeUnitEnum.day) {
  1233. if (isHalfDay) {
  1234. leaveLengthDay = 0.5D;
  1235. } else {
  1236. leaveLengthDay = realLength;
  1237. }
  1238. curDateMap.put("calDay", leaveLengthDay);
  1239. curDateMap.put("calHour", 0.0D);
  1240. } else if (holidayTypeUnit == HolidayTypeUnitEnum.hour) {
  1241. standardHour = this.getStandardHourOfDay(this.ctx, this.personId, endDate,
  1242. defaultAtsShiftItemCollection, defaultStandardHour,
  1243. holidayPolicyInfo.isIsFixOTAllowLeave());
  1244. leaveLengthHour = realLength * standardHour.doubleValue();
  1245. curDateMap.put("calDay", 0.0D);
  1246. curDateMap.put("calHour", leaveLengthHour);
  1247. }
  1248. retMap.put(endDate, curDateMap);
  1249. }
  1250. }
  1251. if (afterDealDateList.size() > 0) {
  1252. Map<String, Object> paramMap = new HashMap();
  1253. paramMap.put("leaveLengthDay", leaveLengthDay);
  1254. paramMap.put("leaveLengthHour", leaveLengthHour);
  1255. paramMap.put("personId", this.personId);
  1256. paramMap.put("beginDate", beginDate);
  1257. paramMap.put("endDate", endDate);
  1258. paramMap.put("defaultStandardHour", defaultStandardHour);
  1259. paramMap.put("holidayTypeUnit", holidayUnit);
  1260. paramMap.put("isFixOTAllowLeave", isFixOTAllowLeave);
  1261. paramMap.put("afterDealDateList", afterDealDateList);
  1262. paramMap.put("defaultAtsShiftItemCollection", defaultAtsShiftItemCollection);
  1263. paramMap.put("dayStandardHour", new BigDecimal(8));
  1264. this.getMidleDateLength(this.ctx, paramMap, retMap);
  1265. }
  1266. }
  1267. return retMap;
  1268. }
  1269. }
  1270. public BigDecimal getStandardHourOfDay(Context ctx, String personId, String curDate,
  1271. AtsShiftItemCollection defaultAtsShiftItemCollection, BigDecimal defaultStandardHour,
  1272. Boolean isFixOTAllowLeave) {
  1273. BigDecimal standardHour = new BigDecimal(8);
  1274. try {
  1275. HashMap<String, Object> dateMap = AtsLeaveBillUtils.getScheduleShiftItemCollByDate(ctx, personId,
  1276. new Date(AtsDateUtils.stringToShortDate(curDate).getTime()), isFixOTAllowLeave);
  1277. ScheduleShiftItemCollection scheduleShiftItemColl = (ScheduleShiftItemCollection) dateMap
  1278. .get("scheduleShiftItemColl");
  1279. if (scheduleShiftItemColl.size() != 0 || defaultAtsShiftItemCollection.size() != 0) {
  1280. if (scheduleShiftItemColl.size() != 0) {
  1281. standardHour = (BigDecimal) dateMap.get("standardHour");
  1282. } else {
  1283. standardHour = defaultStandardHour;
  1284. }
  1285. }
  1286. } catch (EASBizException var10) {
  1287. var10.printStackTrace();
  1288. } catch (BOSException var11) {
  1289. var11.printStackTrace();
  1290. }
  1291. return standardHour;
  1292. }
  1293. public Map<String, Object> calRealLeaveLengthOfBF(List<Date> afterDealDateList, Date beginTimeCount,
  1294. Date endTimeCount, HolidayTypeUnitEnum holidayTypeUnit, AtsHolidayFileInfo holidayFileInfo,
  1295. HolidayPolicySetInfo holidayPolicySetInfo, HolidayPolicyInfo holidayPolicyInfo)
  1296. throws BOSException, EASBizException {
  1297. Map<String, Object> DateLeaveLenMap = new HashMap();
  1298. if (this.atsLeaveBillEntryInfo.getBfType() == null) {
  1299. return DateLeaveLenMap;
  1300. } else {
  1301. String bfTypeId = this.atsLeaveBillEntryInfo.getBfType().getId().toString();
  1302. BreastFeedingTypeCollection bfTypeColl = BreastFeedingTypeFactory.getLocalInstance(this.ctx)
  1303. .getBreastFeedingTypeCollection("where id = '" + bfTypeId + "'");
  1304. double leaveLengthOfSplit = 1.0D;
  1305. if (bfTypeColl.size() > 0) {
  1306. BreastFeedingTypeInfo bfTypeInfo = bfTypeColl.get(0);
  1307. leaveLengthOfSplit = bfTypeInfo.getLeaveLength().multiply(new BigDecimal(bfTypeInfo.getFetusNum()))
  1308. .doubleValue();
  1309. }
  1310. Map<String, List<ScheduleShiftInfo>> scheduleShiftMap = null;
  1311. HashMap curDateMap;
  1312. String curDate;
  1313. if (holidayTypeUnit.getValue() == 1) {
  1314. Timestamp beginTimeCountTs = AtsDateUtils.dateToTimestamp(beginTimeCount);
  1315. Timestamp endTimeCountTs = AtsDateUtils.dateToTimestamp(endTimeCount);
  1316. curDateMap = new HashMap();
  1317. try {
  1318. AttendanceFileHISInfo attendanceFileHisInfo = AtsLeaveBillUtil.getAttendanceFileHisInfo(this.ctx,
  1319. beginTimeCountTs, endTimeCountTs, this.personId, (String) null);
  1320. curDateMap = AtsLeaveBillUtils.getdefaultShiftItemByHis(this.ctx, attendanceFileHisInfo,
  1321. holidayPolicyInfo);
  1322. } catch (BOSException var23) {
  1323. var23.printStackTrace();
  1324. }
  1325. this.defaultStandardHour = (BigDecimal) curDateMap.get("standardHour");
  1326. curDate = AtsDateUtils.dateLongToString(beginTimeCount).substring(0, 10);
  1327. String endDate = AtsDateUtils.dateLongToString(endTimeCount).substring(0, 10);
  1328. Map<String, Object> fileInfoRenturn = AtsPrepareDataHelper.getAttendanceFileInfoByPersonId(this.ctx,
  1329. "'" + this.personId + "'", curDate, endDate, (String) null);
  1330. Map<String, AttendanceFileInfo> fileInfoObject = (Map) fileInfoRenturn.get("fileInfoMap");
  1331. scheduleShiftMap = AtsScheduleShiftUtil.getScheduleShiftMapByPriority(this.ctx, fileInfoObject,
  1332. this.personId, curDate, endDate);
  1333. }
  1334. if (afterDealDateList.size() == 0) {
  1335. return DateLeaveLenMap;
  1336. } else {
  1337. Iterator var25 = afterDealDateList.iterator();
  1338. while (var25.hasNext()) {
  1339. Date date = (Date) var25.next();
  1340. curDateMap = new HashMap();
  1341. if (holidayTypeUnit.getValue() == 1) {
  1342. new BigDecimal(0);
  1343. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  1344. String ds = sdf.format(date);
  1345. String key = this.personId + "_" + ds;
  1346. List<ScheduleShiftInfo> scheduleShiftList = null == scheduleShiftMap
  1347. ? null
  1348. : (List) scheduleShiftMap.get(key);
  1349. BigDecimal standardhour;
  1350. if (scheduleShiftList != null && scheduleShiftList.size() > 0) {
  1351. standardhour = (BigDecimal) ((ScheduleShiftInfo) scheduleShiftList.get(0))
  1352. .get("standardhour");
  1353. } else {
  1354. standardhour = this.defaultStandardHour;
  1355. }
  1356. BigDecimal dayRealLength = BigDecimal.valueOf(leaveLengthOfSplit).divide(standardhour, 8,
  1357. RoundingMode.HALF_UP);
  1358. curDateMap.put("calDay", dayRealLength.doubleValue());
  1359. curDateMap.put("calHour", 0.0D);
  1360. } else {
  1361. curDateMap.put("calDay", 0.0D);
  1362. curDateMap.put("calHour", leaveLengthOfSplit);
  1363. }
  1364. curDate = AtsDateUtils.dateLongToString(date);
  1365. DateLeaveLenMap.put(curDate, curDateMap);
  1366. }
  1367. return DateLeaveLenMap;
  1368. }
  1369. }
  1370. }
  1371. public Map<String, Object> getIsCtrlHalfDayOff(Context ctx) {
  1372. HashMap res = new HashMap();
  1373. try {
  1374. HolidayPolicySetInfo holidayPolicySetInfo = HolidayPolicySetFactory.getLocalInstance(ctx)
  1375. .getHolidayPolicySetInfo(
  1376. " where id='" + this.holidayPolicyInfo.getHolidayPolicySet().getId().toString() + "' ");
  1377. res.put("amBeginTime", holidayPolicySetInfo.getAmStartWorkTime());
  1378. res.put("amEndTime", holidayPolicySetInfo.getAmEndWorkTime());
  1379. res.put("pmBeginTime", holidayPolicySetInfo.getPmStartWorkTime());
  1380. res.put("pmEndTime", holidayPolicySetInfo.getPmEndWorkTime());
  1381. res.put("isHalfDayOff", this.holidayPolicyInfo.isIsHalfDayOff());
  1382. } catch (Exception var4) {
  1383. ;
  1384. }
  1385. return res;
  1386. }
  1387. private AtsShiftItemInfo createScheduleShiftItemToAtsShiftItem(Context ctx,
  1388. ScheduleShiftItemInfo scheduleShiftItemInfo) {
  1389. AtsShiftItemInfo info = new AtsShiftItemInfo();
  1390. info.setPreTime(scheduleShiftItemInfo.getPreTime());
  1391. info.setNextTime(scheduleShiftItemInfo.getNextTime());
  1392. info.setPreIsPunchCard(scheduleShiftItemInfo.getPreIsPunchCard());
  1393. info.setNextIsPunchCard(scheduleShiftItemInfo.getNextIsPunchCard());
  1394. info.setPreTimeDayType(scheduleShiftItemInfo.getPreTimeDayType());
  1395. info.setNextTimeDayType(scheduleShiftItemInfo.getNextTimeDayType());
  1396. info.setSegment(scheduleShiftItemInfo.getSegment());
  1397. info.setPreFloatAdjusted(scheduleShiftItemInfo.getPreFloatAdjusted());
  1398. info.setNextFloatAdjusted(scheduleShiftItemInfo.getNextFloatAdjusted());
  1399. info.setRestPreTime(scheduleShiftItemInfo.getRestPreTime());
  1400. info.setRestNextTime(scheduleShiftItemInfo.getRestNextTime());
  1401. info.setSegmentInRest(scheduleShiftItemInfo.getSegmentInRest());
  1402. info.setAttendanceType(scheduleShiftItemInfo.getAttendanceType());
  1403. info.setGroup(new AtsShiftInfo());
  1404. return info;
  1405. }
  1406. }