AtsLeaveBillSameSplitHelper.java 76 KB

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