LeaveAllowanceFacadeControllerBean.java 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. package com.kingdee.eas.custom.facade.leave;
  2. import com.google.common.collect.Maps;
  3. import com.grapecity.documents.excel.D;
  4. import com.kingdee.bos.dao.IObjectPK;
  5. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  6. import com.kingdee.bos.metadata.entity.SelectorItemCollection;
  7. import com.kingdee.bos.metadata.entity.SelectorItemInfo;
  8. import com.kingdee.bos.util.BOSUuid;
  9. import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
  10. import com.kingdee.eas.basedata.org.CtrlUnitInfo;
  11. import com.kingdee.eas.basedata.org.HROrgUnitInfo;
  12. import com.kingdee.eas.basedata.org.PositionInfo;
  13. import com.kingdee.eas.basedata.person.PersonInfo;
  14. import com.kingdee.eas.custom.bd.param.ParamCollection;
  15. import com.kingdee.eas.custom.bd.param.ParamFactory;
  16. import com.kingdee.eas.hr.ats.*;
  17. import com.kingdee.eas.util.app.ContextUtil;
  18. import com.kingdee.shr.base.syssetting.app.osf.OSFAppUtil;
  19. import com.kingdee.util.DateTimeUtils;
  20. import org.apache.commons.lang3.StringUtils;
  21. import org.apache.log4j.Logger;
  22. import java.math.BigDecimal;
  23. import java.math.RoundingMode;
  24. import java.sql.SQLException;
  25. import java.sql.Timestamp;
  26. import java.text.ParseException;
  27. import java.text.SimpleDateFormat;
  28. import java.util.*;
  29. import com.kingdee.bos.*;
  30. //import com.kingdee.bos.metadata.entity.EntityViewInfo;
  31. //import com.kingdee.bos.dao.IObjectPK;
  32. import com.kingdee.eas.common.EASBizException;
  33. import com.kingdee.eas.framework.CoreBaseCollection;
  34. import com.kingdee.eas.util.app.DbUtil;
  35. import com.kingdee.jdbc.rowset.IRowSet;
  36. /**
  37. * 假期额度相关后台事务类
  38. *
  39. * @author xiaoxin
  40. */
  41. public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFacadeControllerBean {
  42. private static Logger logger =
  43. Logger.getLogger("com.kingdee.eas.custom.facade.leave.LeaveAllowanceFacadeControllerBean");
  44. // 员工类别 General Administrative Staff
  45. private static final String WC_General_Administrative_Staff = "General Administrative Staff";
  46. // 员工类别 Professional Supervisory Staff
  47. private static final String WC_Professional_Supervisory_Staff = "Professional Supervisory Staff";
  48. // 员工类别 Senior Administrative Staff
  49. private static final String WC_Senior_Administrative_Staff = "Senior Administrative Staff";
  50. private static final String WC_Academic_Staff = "Academic Staff";
  51. private static final String WC_Others = "Others";
  52. // 年假初始值 General_Administrative_Staff
  53. private static final int IV_General_Administrative_Staff = 12;
  54. // 年假初始值 Professional_Supervisory_Staff
  55. private static final int IV_Professional_Supervisory_Staff = 15;
  56. // 年假初始值 Senior_Administrative_Staff
  57. private static final int IV_Senior_Administrative_Staff = 18;
  58. private static final int IV_Year = 2;
  59. private static final int IV_YearAddValue = 1;
  60. private static final int IV_MAXADD = 8;
  61. private static final int MONTH_NUM_12 = 12;
  62. // 年假折算方式
  63. private static final String PARAM_ANNUALLEAVE_CONVERSIONMETHOD = "param_001";
  64. // 年假取整方式
  65. private static final String PARAM_ANNUALLEAVE_INTEGERMETHOD = "param_002";
  66. // 年假取整精度
  67. private static final String PARAM_ANNUALLEAVE_INTEGERPERCISION = "param_003";
  68. // 年假结转日期
  69. private static final String PARAM_ANNUALLEAVE_CONVERTDATE = "param_004";
  70. // 生成下年度额度日期
  71. private static final String PARAM_ANNUALLEAVE_GENERATEDAY = "param_005";
  72. // 护理假额度
  73. private static final String PARAM_NURSINGLEAVE_LIMIT = "param_006";
  74. // 育儿假额度
  75. private static final String PARAM_PARENTALLEAVE_LIMIT = "param_007";
  76. // 护理育儿折算方式
  77. private static final String PARAM_NURSINGANDPARENTALLEAVE_CONVERSIONMETHOD = "param_008";
  78. // 护理育儿取整方式
  79. private static final String PARAM_NURSINGANDPARENTALLEAVE_INTEGERMETHOD = "param_009";
  80. // 护理育儿取整精度
  81. private static final String PARAM_NURSINGANDPARENTALLEAVE_INTEGERPERCISION = "param_010";
  82. // 育儿护理多段统计是否更新视图脚本
  83. private static final String PARAM_NURSINGANDPARENTALLEAVE_UPDATESQL = "param_011";
  84. // 折算方式 按日
  85. private static final String CONVERSIONMETHOD_BYDAY = "D";
  86. // 折算方式 按月
  87. private static final String CONVERSIONMETHOD_BYMONTH = "M";
  88. // 取整方式 向上
  89. private static final String INTEGERMETHOD_UP = "U";
  90. // 取整方式 向下
  91. private static final String INTEGERMETHOD_DOWN = "D";
  92. // 取整精度 0.5
  93. private static final double INTEGERPERCISION_HALF = 0.5;
  94. // 取整精度 1
  95. private static final double INTEGERPERCISION_ONE = 1;
  96. // 年假折算
  97. private static String annualLeaveConversionMethod;
  98. // 年假取整
  99. private static String annualLeaveIntegerMethod;
  100. // 年假取整精度
  101. private static double annualLeaveIntegerPrecision;
  102. // 结转日期
  103. private static String annualLeaveConvertDate;
  104. // 下年度额度生成
  105. private static String annualLeaveGenerateDay;
  106. // 育儿假额度
  107. private static int nursingLeaveLimit;
  108. // 护理假额度
  109. private static int parentalLeaveLimit;
  110. // 护理育儿折算
  111. private static String nursingAndParentalLeaveConversionMethod;
  112. // 护理育儿取整
  113. private static String nursingAndParentalLeaveIntegerMethod;
  114. // 护理育儿取整精度
  115. private static double nursingAndParentalLeaveIntegerPrecision;
  116. // 育儿护理多段统计是否更新视图脚本
  117. private static String nursingAndParentalLeaveUpdateSql;
  118. /**
  119. * 年假额度生成 JQLX000001Y
  120. */
  121. @Override
  122. protected void _createAnnualLeave(Context ctx, int year, String personNum) throws BOSException {
  123. try {
  124. // 初始化公共变量
  125. initialGlobalParam(ctx);
  126. // 是否生成下年年假额度
  127. Boolean isGenerateNextYearAnnualLeave = false;
  128. // 当前时间
  129. Date currentDate = new Date();
  130. if (year != 0) {
  131. currentDate = DateTimeUtils.parseDate(year + "-12-31");
  132. } else {
  133. year = DateTimeUtils.getYear(currentDate);
  134. Date annualLeaveGenerateDay = DateTimeUtils.parseDate(year + "-" + LeaveAllowanceFacadeControllerBean.annualLeaveGenerateDay);
  135. if (currentDate.getTime() >= annualLeaveGenerateDay.getTime()) {
  136. isGenerateNextYearAnnualLeave = true;
  137. }
  138. }
  139. // 年假额度生成
  140. // generateAnnualLeave(ctx, year, personNum, currentDate);
  141. Map<String,String> param = Maps.newHashMap();
  142. param.put("year",String.valueOf(year));
  143. param.put("personNum",personNum);
  144. param.put("currentDate",DateTimeUtils.formatDate(currentDate));
  145. OSFAppUtil.callService(ctx,"leaveAllowanceService",param);
  146. // 下年年假额度生成
  147. if (isGenerateNextYearAnnualLeave) {
  148. int nextYear = year + 1;
  149. Date nextYearCurrentDay = DateTimeUtils.addYear(currentDate, 1);
  150. // generateAnnualLeave(ctx, nextYear, personNum, nextYearCurrentDay);
  151. Map<String,String> nextParam = Maps.newHashMap();
  152. nextParam.put("year",String.valueOf(nextYear));
  153. nextParam.put("personNum",personNum);
  154. nextParam.put("currentDate",DateTimeUtils.formatDate(currentDate));
  155. OSFAppUtil.callService(ctx,"leaveAllowanceService",nextParam);
  156. }
  157. } catch (ParseException | EASBizException e) {
  158. throw new BOSException(e);
  159. }
  160. }
  161. /**
  162. * 年假额度生成
  163. *
  164. * @param ctx
  165. * @param year
  166. * @param personNum
  167. * @throws BOSException
  168. */
  169. private void generateAnnualLeave(Context ctx, int year, String personNum, Date currentDate) throws BOSException {
  170. try {
  171. String updateHolidaypolicy = "/*dialect*/MERGE INTO T_HR_ATS_HolidayLimit AS hl \n" +
  172. " USING ( \n" +
  173. " select\n" +
  174. " hl.fid,\n" +
  175. " af.fproposerid, hpf.fid AS holiday_policy_id \n" +
  176. " from \n" +
  177. " T_HR_ATS_AtsHolidayFile af \n" +
  178. " left JOIN T_HR_ATS_HolidayPolicy hpf ON hpf.fholidaypolicysetid = af.fholidaypolicysetid \n" +
  179. " left JOIN T_HR_ATS_HolidayType ht ON ht.FID = hpf.fholidaytypeid \n" +
  180. " left join T_HR_ATS_HolidayLimit hl on af.FPROPOSERID =hl.fproposerid \n" +
  181. " where ht.FNUMBER = 'JQLX000001Y' and hl.fholidaypolicyid in( \n" +
  182. " select hp.fid from T_HR_ATS_HolidayPolicy hp \n" +
  183. " inner JOIN T_HR_ATS_HolidayType ht ON ht.FID = hp.fholidaytypeid \n" +
  184. " where ht.FNUMBER = 'JQLX000001Y' \n" +
  185. " ) \n" +
  186. " and to_char(hl.fcyclebegindate,'yyyy')='"+year+"' \n"+
  187. " ) AS src ON hl.fid = src.fid and to_char(hl.fcyclebegindate,'yyyy') ='"+year+"' \n" +
  188. " WHEN MATCHED THEN \n" +
  189. " UPDATE SET hl.fname_l3=hl.fholidaypolicyid,hl.fholidaypolicyid = src.holiday_policy_id";
  190. DbUtil.execute(ctx,updateHolidaypolicy);
  191. Date nowDate = new Date();
  192. // 考勤制度和年假id对应
  193. Map<String, String> holidayPolicyMap = new HashMap<String, String>();
  194. String holidayPolicySql = "select hps.FNUMBER, hp.fid from T_HR_ATS_HolidayPolicy hp left join T_HR_ATS_HolidayPolicySet hps on hp.FHOLIDAYPOLICYSETID = hps.fid where FHOLIDAYTYPEID = (select fid from T_HR_ATS_HolidayType where FNUMBER = 'JQLX000001Y')";
  195. IRowSet holidayPolicyRowSet = DbUtil.executeQuery(ctx, holidayPolicySql);
  196. while (holidayPolicyRowSet.next()) {
  197. holidayPolicyMap.put(holidayPolicyRowSet.getString("FNUMBER"), holidayPolicyRowSet.getString("fid"));
  198. }
  199. String currentDateStr = DateTimeUtils.format(currentDate, "yyyy-MM-dd");
  200. // 当前年份第一天
  201. Date yearFirstDay = DateTimeUtils.parseDate(DateTimeUtils.getYear(currentDate) + "-01-01");
  202. // 当前年份最后一天
  203. Date yearLastDay = DateTimeUtils.parseDate(DateTimeUtils.getYear(currentDate) + "-12-31");
  204. List<String> personNumberList = new ArrayList<String>();
  205. CoreBaseCollection addList = new CoreBaseCollection();
  206. CoreBaseCollection updateList = new CoreBaseCollection();
  207. List<String> deleteList = new ArrayList<>();
  208. // 重算列表
  209. List<Map<String, Object>> reCalList = new ArrayList<>();
  210. String personNumStr = "";
  211. if (StringUtils.isNotEmpty(personNum)) {
  212. String[] personNumArr = personNum.split(",");
  213. for (int i = 0; i < personNumArr.length; i++) {
  214. personNumberList.add("'" + personNumArr[i] + "'");
  215. }
  216. personNumStr = String.join(",", personNumberList);
  217. }
  218. String dbType = ContextUtil.getDbType(ctx);
  219. String sql = " /*dialect*/select * from (select row_number() over (partition by p.fid order by p.fid,eo.feffdt desc,l.fid) as rn,p.fid,p.fnumber," +
  220. "eo.FADMINORGID,eo.FHRORGUNITID,eo.FPOSITIONID,p.cfftorptid fullOrPartId,fp.fnumber fullOrPartNumber, p.cffae annualleavelimit," +
  221. "case when rbe.fid is null then eo.cfworkercategoryid else rbe.CFWcategoryID end workercategoryid,wc.fname_l2 workercategoryname," +
  222. "p.fhiredate, (to_char(to_date('" + currentDateStr + "','yyyy-MM-dd'),'yyyy') - to_char(p.fhiredate,'yyyy')+1)joinDateYear," +
  223. "case when rbe.fid is null then null else rbe.FBIZDATE end leaveDate,l.fid limitId,coalesce(l.FADDORSUBLIMIT,0) FADDORSUBLIMIT," +
  224. "coalesce(l.FUSEDLIMIT,0) FUSEDLIMIT,coalesce(l.FREEZELIMIT,0) FREEZELIMIT,coalesce(l.cflastcarryforward,0) cflastcarryforward," +
  225. "coalesce(l.cfcarryforward,0) cfcarryforward,coalesce(l.CFEntitlementLimit,0) CFEntitlementLimit,coalesce(l.CFInitializedLimit,0) CFInitializedLimit, " +
  226. "ebe.FPROBATION,ebe.FPLANFORMALDATE,hp.fid holidayPolicyId,l.fisleftconvert isleftconvert " +
  227. " from T_HR_ATS_AtsHolidayFile f " +
  228. " left join T_BD_Person p on f.fproposerid = p.fid " +
  229. " left join T_HR_EmpOrgRelation eo on p.fid = eo.fpersonid and eo.fleffdt='2199-12-31 00:00:00' " +
  230. " left join CT_MP_Fullorpart fp on fp.fid = p.cfftorptid " +
  231. //" left join T_HR_ATS_HolidayPolicySet hps on f.fholidaypolicysetid = hps.fid " +
  232. //" left join T_HR_ATS_HolidayPolicy hp on hp.FHOLIDAYPOLICYSETID = hps.fid " +
  233. " left join T_HR_ATS_HolidayType ht on ht.FNUMBER = 'JQLX000001Y' " +
  234. " left join T_HR_ATS_HolidayPolicy hp on ht.FID =hp.fholidaytypeid " +
  235. " and f.fholidaypolicysetid = hp.fholidaypolicysetid " +
  236. " left join T_HR_ATS_HolidayLimit l on hp.fid = l.FHOLIDAYPOLICYID and l.FPROPOSERID = p.fid and l.FCYCLEBEGINDATE >= p.fhiredate and l.FCYCLEBEGINDATE <= p.FLEFFDT and l.fyear = " + year +
  237. // " left join T_HR_EmpEnrollBizBillEntry ebe on ebe.FPERSONID = p.fid and ebe.FBIZDATE = p.fhiredate " +
  238. // " left join T_HR_EmpEnrollBizBill eb on ebe.FBILLID = eb.FID and eb.FBILLSTATE = 3 " +
  239. // " left join T_HR_ResignBizBillEntry rbe on rbe.FPERSONID = p.fid and p.fhiredate = rbe.FENTERDATE " +
  240. // " left join T_HR_ResignBizBill rb on rb.fid = rbe.FBILLID and rb.FBILLSTATE = 3 " +
  241. " left join ( " +
  242. " select rownum rownumber,ebe.FPERSONID, " +
  243. " ebe.FPROBATION,ebe.FPLANFORMALDATE, ebe.FBIZDATE " +
  244. " from T_HR_EmpEnrollBizBillEntry ebe " +
  245. " inner join (select re1.fpersonid,max(re1.fbizdate) fbizdate,count(fid) from T_HR_EmpEnrollBizBillEntry re1 " +
  246. " group by re1.fpersonid) re1 on ebe.fpersonid=re1.fpersonid and re1.fbizdate=ebe.fbizdate " +
  247. " left join T_HR_EmpEnrollBizBill eb on ebe.FBILLID = eb.FID " +
  248. " where eb.FBILLSTATE = 3 " +
  249. " order by ebe.fbizdate desc) ebe " +
  250. " on ebe.FPERSONID = p.fid " +
  251. " and ebe.FBIZDATE = p.fhiredate " +
  252. " left join( " +
  253. " select rownum rownumber,rbe.fid, rbe.FPERSONID, " +
  254. " rbe.FENTERDATE, rbe.CFWcategoryID, rbe.FBIZDATE " +
  255. " from T_HR_ResignBizBillEntry rbe " +
  256. " inner join (select re1.fpersonid,max(re1.fbizdate) fbizdate,count(fid) from T_HR_ResignBizBillEntry re1 " +
  257. " group by re1.fpersonid) re1 on rbe.fpersonid=re1.fpersonid and re1.fbizdate=rbe.fbizdate " +
  258. " left join T_HR_ResignBizBill rb on rb.fid = rbe.FBILLID " +
  259. " where rb.FBILLSTATE = 3 order by rbe.fbizdate desc " +
  260. " ) rbe on rbe.FPERSONID = p.fid " +
  261. " and p.fhiredate = rbe.FENTERDATE " +
  262. " left join CT_MP_WorkerCategory wc on (wc.fid = eo.cfworkercategoryid or wc.fid = rbe.CFWcategoryID) " +
  263. " where f.fattendfilestate in( 1,2) and ht.FNUMBER = 'JQLX000001Y' and fp.fnumber = 'FULL' and eo.fassigntype = 1 and eo.feffdt <= to_date('" + currentDateStr + "','yyyy-MM-dd') and to_char(p.fhiredate, 'yyyy')<=" + year + " and to_char(p.FLEFFDT,'yyyy')>=" + year + " ";
  264. if (StringUtils.isNotEmpty(personNumStr)) {
  265. sql += " and p.fnumber in (" + personNumStr + ") ";
  266. }
  267. sql += " order by l.fid ) temp where temp.rn = 1 ";
  268. IRowSet iRowSet = DbUtil.executeQuery(ctx, sql);
  269. while (iRowSet.next()) {
  270. String holidayPolicyId = iRowSet.getString("holidayPolicyId");
  271. if (StringUtils.isEmpty(holidayPolicyId)) {
  272. holidayPolicyId = holidayPolicyMap.values().stream().findFirst().get();
  273. continue;
  274. }
  275. String limitId = iRowSet.getString("limitId");
  276. // 教师年假额度
  277. int annualleavelimit = iRowSet.getInt("annualleavelimit");
  278. // 员工类别
  279. String workercategoryname = iRowSet.getString("workercategoryname");
  280. // 司龄
  281. int joinDateYear = iRowSet.getInt("joinDateYear");
  282. // 入职日期
  283. Date joinDate = iRowSet.getDate("fhiredate");
  284. Date fplanformaldate = iRowSet.getDate("FPLANFORMALDATE");
  285. // 离职日期
  286. Date leaveDate = iRowSet.getDate("leaveDate");
  287. // 标准额度=额度规则(折算额度)+初始化额度+从去年结转-结转到明年
  288. BigDecimal standardLimit = BigDecimal.ZERO;
  289. // 折算标准额度
  290. BigDecimal convertedLimit = BigDecimal.ZERO;
  291. // 未折算标准额度
  292. BigDecimal entitlementLimit = BigDecimal.ZERO;
  293. //是否离职折算过
  294. int isLeave = 0;
  295. // 实际额度
  296. BigDecimal realLimit = BigDecimal.ZERO;
  297. // 剩余额度
  298. BigDecimal remainLimit = BigDecimal.ZERO;
  299. // 未折算标准额度
  300. BigDecimal entitlementLimitOld = iRowSet.getBigDecimal("CFEntitlementLimit");
  301. // 初始化额度
  302. BigDecimal initializedLimit = iRowSet.getBigDecimal("CFInitializedLimit");
  303. // 从去年结转额度
  304. BigDecimal lastCarryforward = iRowSet.getBigDecimal("CFLastCarryforward");
  305. // 结转到明年
  306. BigDecimal carryforward = iRowSet.getBigDecimal("CFCarryforward");
  307. // 增减额度
  308. BigDecimal addOrSubLimit = iRowSet.getBigDecimal("FADDORSUBLIMIT");
  309. // 已用额度
  310. BigDecimal usedLimit = iRowSet.getBigDecimal("FUSEDLIMIT");
  311. // 在途额度
  312. BigDecimal freezeLimit = iRowSet.getBigDecimal("FreezeLimit");
  313. //是否离职折算
  314. int isleftconvert = iRowSet.getInt("isleftconvert");
  315. // 全职行政人员额度规则
  316. if (StringUtils.equalsIgnoreCase(workercategoryname, WC_General_Administrative_Staff)
  317. || StringUtils.equalsIgnoreCase(workercategoryname, WC_Professional_Supervisory_Staff)
  318. || StringUtils.equalsIgnoreCase(workercategoryname, WC_Senior_Administrative_Staff)) {
  319. if (annualleavelimit > 0) {
  320. // 如果员工信息-教师年假额度中数值>0,则取值员工信息-教师年假额度值,司龄每满两年加一天,最多加八天(最大值30天)
  321. convertedLimit = BigDecimal.valueOf(annualleavelimit + (joinDateYear - 1) / IV_Year * IV_YearAddValue);
  322. if (convertedLimit.compareTo(BigDecimal.valueOf(30)) > 0) {
  323. convertedLimit = BigDecimal.valueOf(30);
  324. }
  325. } else {
  326. // 员工类别=General Administrative Staff,则初始值为12,司龄每满两年加一天,最多加八天;
  327. if (StringUtils.equalsIgnoreCase(workercategoryname, WC_General_Administrative_Staff)) {
  328. convertedLimit = BigDecimal.valueOf(IV_General_Administrative_Staff + (joinDateYear - 1) / IV_Year * IV_YearAddValue);
  329. if (convertedLimit.compareTo(BigDecimal.valueOf(IV_General_Administrative_Staff + IV_MAXADD)) > 0) {
  330. convertedLimit = BigDecimal.valueOf(IV_General_Administrative_Staff + IV_MAXADD);
  331. }
  332. }
  333. // 员工类别=Professional Supervisory Staff,则初始值为15,司龄每满两年加一天,最多加八天;
  334. if (StringUtils.equalsIgnoreCase(workercategoryname, WC_Professional_Supervisory_Staff)) {
  335. convertedLimit = BigDecimal.valueOf(IV_Professional_Supervisory_Staff + (joinDateYear - 1) / IV_Year * IV_YearAddValue);
  336. if (convertedLimit.compareTo(BigDecimal.valueOf(IV_Professional_Supervisory_Staff + IV_MAXADD)) > 0) {
  337. convertedLimit = BigDecimal.valueOf(IV_Professional_Supervisory_Staff + IV_MAXADD);
  338. }
  339. }
  340. // 员工类别=Senior Administrative Staff,则初始值为18,司龄每满两年加一天,最多加八天;
  341. if (StringUtils.equalsIgnoreCase(workercategoryname, WC_Senior_Administrative_Staff)) {
  342. convertedLimit = BigDecimal.valueOf(IV_Senior_Administrative_Staff + (joinDateYear - 1) / IV_Year * IV_YearAddValue);
  343. if (convertedLimit.compareTo(BigDecimal.valueOf(IV_Senior_Administrative_Staff + IV_MAXADD)) > 0) {
  344. convertedLimit = BigDecimal.valueOf(IV_Senior_Administrative_Staff + IV_MAXADD);
  345. }
  346. }
  347. }
  348. } else if (StringUtils.equalsIgnoreCase(workercategoryname, WC_Academic_Staff)
  349. || StringUtils.equalsIgnoreCase(workercategoryname, WC_Others)) {
  350. // 全职学术人员和全职其他人员
  351. // 取值员工信息-教师年假额度字段
  352. convertedLimit = BigDecimal.valueOf(annualleavelimit);
  353. }
  354. // 未折算标准额度
  355. entitlementLimit = convertedLimit;
  356. // 离职折算
  357. if (leaveDate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(leaveDate) && (joinDate.compareTo(leaveDate) < 0)) {
  358. if (StringUtils.equals(CONVERSIONMETHOD_BYDAY, annualLeaveConversionMethod)) {
  359. // TODO 暂时使按月折算的逻辑
  360. if (DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(joinDate)) {
  361. convertedLimit = convertedLimit.multiply(BigDecimal.valueOf(DateTimeUtils.getMonth(leaveDate) - DateTimeUtils.getMonth(joinDate) + 1)).divide(BigDecimal.valueOf(MONTH_NUM_12), 10, BigDecimal.ROUND_HALF_UP);
  362. } else {
  363. convertedLimit = convertedLimit.multiply(BigDecimal.valueOf(DateTimeUtils.getMonth(leaveDate))).divide(BigDecimal.valueOf(MONTH_NUM_12), 10, BigDecimal.ROUND_HALF_UP);
  364. }
  365. } else {
  366. if (DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(joinDate)) {
  367. convertedLimit = convertedLimit.multiply(BigDecimal.valueOf(DateTimeUtils.getMonth(leaveDate) - DateTimeUtils.getMonth(joinDate) + 1)).divide(BigDecimal.valueOf(MONTH_NUM_12), 10, BigDecimal.ROUND_HALF_UP);
  368. } else {
  369. convertedLimit = convertedLimit.multiply(BigDecimal.valueOf(DateTimeUtils.getMonth(leaveDate))).divide(BigDecimal.valueOf(MONTH_NUM_12), 10, BigDecimal.ROUND_HALF_UP);
  370. }
  371. }
  372. } else {
  373. // 入职折算,是当前年入职的,且离职日期小于入职日期
  374. if (DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(joinDate)) {
  375. if (StringUtils.equals(CONVERSIONMETHOD_BYDAY, annualLeaveConversionMethod)) {
  376. // TODO 暂时使用按月折算的逻辑
  377. convertedLimit = convertedLimit.multiply(BigDecimal.valueOf(MONTH_NUM_12 - DateTimeUtils.getMonth(joinDate) + 1)).divide(BigDecimal.valueOf(MONTH_NUM_12), 10, BigDecimal.ROUND_HALF_UP);
  378. } else {
  379. convertedLimit = convertedLimit.multiply(BigDecimal.valueOf(MONTH_NUM_12 - DateTimeUtils.getMonth(joinDate) + 1)).divide(BigDecimal.valueOf(MONTH_NUM_12), 10, BigDecimal.ROUND_HALF_UP);
  380. }
  381. }
  382. }
  383. // 年假取整
  384. // 整数部分
  385. BigDecimal standardLimitInteger = convertedLimit.setScale(0, RoundingMode.FLOOR);
  386. // 小数部分
  387. BigDecimal standardLimitDecimal = convertedLimit.subtract(standardLimitInteger);
  388. if (Double.doubleToLongBits(INTEGERPERCISION_HALF) == Double.doubleToLongBits(annualLeaveIntegerPrecision)) {
  389. if (StringUtils.equals(INTEGERMETHOD_UP, annualLeaveIntegerMethod)) {
  390. if (standardLimitDecimal.compareTo(BigDecimal.valueOf(0.5)) > 0) {
  391. convertedLimit = convertedLimit.setScale(0, RoundingMode.CEILING);
  392. } else if (standardLimitDecimal.compareTo(BigDecimal.ZERO) > 0) {
  393. convertedLimit = standardLimitInteger.add(BigDecimal.valueOf(0.5));
  394. } else {
  395. convertedLimit = standardLimitInteger;
  396. }
  397. } else {
  398. if (standardLimitDecimal.compareTo(BigDecimal.valueOf(0.5)) > 0) {
  399. convertedLimit = standardLimitInteger.add(BigDecimal.valueOf(0.5));
  400. } else {
  401. convertedLimit = convertedLimit.setScale(0, RoundingMode.FLOOR);
  402. }
  403. }
  404. } else {
  405. if (StringUtils.equals(INTEGERMETHOD_UP, annualLeaveIntegerMethod)) {
  406. convertedLimit = convertedLimit.setScale(0, RoundingMode.CEILING);
  407. } else {
  408. convertedLimit = convertedLimit.setScale(0, RoundingMode.FLOOR);
  409. }
  410. }
  411. // 未折算标准额度
  412. if (entitlementLimit.compareTo(entitlementLimitOld) != 0 && year <= DateTimeUtils.getYear(nowDate)) {
  413. lastCarryforward = BigDecimal.ZERO;
  414. Map<String, Object> param = new HashMap<>();
  415. param.put("year", year);
  416. param.put("personNum", iRowSet.getString("fnumber"));
  417. reCalList.add(param);
  418. }
  419. // 标准额度 = 额度规则(折算额度)+初始化额度+从去年结转-结转到明年
  420. standardLimit = convertedLimit.add(initializedLimit).add(lastCarryforward).subtract(carryforward);
  421. // 实际额度 = 标准额度+增减额度
  422. realLimit = standardLimit.add(addOrSubLimit);
  423. // 剩余额度 = 实际额度-已用额度-在途额度
  424. remainLimit = realLimit.subtract(usedLimit).subtract(freezeLimit);
  425. BigDecimal addOrSub=BigDecimal.ZERO;
  426. if(remainLimit.compareTo(BigDecimal.valueOf(30))>0){
  427. addOrSub = BigDecimal.valueOf(30).subtract(remainLimit);
  428. }
  429. if (StringUtils.isNotEmpty(limitId)) {
  430. HolidayLimitInfo holidayLimitInfo = new HolidayLimitInfo();
  431. holidayLimitInfo.setId(BOSUuid.read(limitId));
  432. // 标准额度
  433. holidayLimitInfo.setStandardLimit(standardLimit);
  434. //增减
  435. addOrSubLimit=addOrSubLimit.add(addOrSub);
  436. holidayLimitInfo.setAddOrSubLimit(addOrSubLimit);
  437. // 折算标准额度
  438. holidayLimitInfo.setBigDecimal("convertedLimit", convertedLimit);
  439. // 未折算标准额度
  440. holidayLimitInfo.setBigDecimal("entitlementLimit", entitlementLimit);
  441. holidayLimitInfo.setRealLimit(realLimit);
  442. holidayLimitInfo.setRemainLimit(remainLimit);
  443. holidayLimitInfo.setBigDecimal("lastCarryforward", lastCarryforward);
  444. holidayLimitInfo.setBigDecimal("Carryforward", carryforward);
  445. // 默认值
  446. // holidayLimitInfo.setCycleBeginDate(yearFirstDay);
  447. // holidayLimitInfo.setCycleEndDate(yearLastDay);
  448. // holidayLimitInfo.setEffectDate(yearFirstDay);
  449. // holidayLimitInfo.setDelayDate(yearLastDay);
  450. // 离职情况
  451. if (leaveDate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(leaveDate) && joinDate.compareTo(leaveDate) < 0) {
  452. holidayLimitInfo.setCycleEndDate(leaveDate);
  453. holidayLimitInfo.setDelayDate(leaveDate);
  454. holidayLimitInfo.setIsLeftConvert(true);
  455. }else {
  456. // 入职情况
  457. if (DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(joinDate)) {
  458. holidayLimitInfo.setCycleBeginDate(joinDate);
  459. int fprobation = iRowSet.getInt("FPROBATION");
  460. if (fprobation > 0) {
  461. holidayLimitInfo.setEffectDate(iRowSet.getDate("FPLANFORMALDATE"));
  462. } else {
  463. holidayLimitInfo.setEffectDate(holidayLimitInfo.getCycleBeginDate());
  464. }
  465. }
  466. holidayLimitInfo.setIsLeftConvert(false);
  467. // else if ((fplanformaldate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(fplanformaldate))) {
  468. // int fprobation = iRowSet.getInt("FPROBATION");
  469. // if (fprobation > 0) {
  470. // holidayLimitInfo.setEffectDate(iRowSet.getDate("FPLANFORMALDATE"));
  471. // } else {
  472. // holidayLimitInfo.setEffectDate(holidayLimitInfo.getCycleBeginDate());
  473. // }
  474. // }
  475. }
  476. if (StringUtils.isNotEmpty(iRowSet.getString("FADMINORGID"))) {
  477. AdminOrgUnitInfo adminOrgUnitInfo = new AdminOrgUnitInfo();
  478. adminOrgUnitInfo.setId(BOSUuid.read(iRowSet.getString("FADMINORGID")));
  479. holidayLimitInfo.setAdminOrgUnit(adminOrgUnitInfo);
  480. }
  481. if (StringUtils.isNotEmpty(iRowSet.getString("FPOSITIONID"))) {
  482. PositionInfo positionInfo = new PositionInfo();
  483. positionInfo.setId(BOSUuid.read(iRowSet.getString("FPOSITIONID")));
  484. holidayLimitInfo.setPosition(positionInfo);
  485. }
  486. holidayLimitInfo.setLastUpdateUser(ContextUtil.getCurrentUserInfo(ctx));
  487. holidayLimitInfo.setLastUpdateTime(new Timestamp(nowDate.getTime()));
  488. // 如果假期额度在离职日期之后,且是离职折算后的,不生成
  489. if (leaveDate != null && 1 == isleftconvert && leaveDate.getTime() <= holidayLimitInfo.getCycleEndDate().getTime()) {
  490. //deleteList.add(limitId);
  491. continue;
  492. }else {
  493. updateList.add(holidayLimitInfo);
  494. }
  495. } else {
  496. HolidayLimitInfo holidayLimitInfo = new HolidayLimitInfo();
  497. holidayLimitInfo.setStandardLimit(standardLimit);
  498. holidayLimitInfo.setBigDecimal("convertedLimit", convertedLimit);
  499. holidayLimitInfo.setBigDecimal("entitlementLimit", entitlementLimit);
  500. holidayLimitInfo.setRealLimit(realLimit);
  501. holidayLimitInfo.setRemainLimit(remainLimit);
  502. holidayLimitInfo.setFreezeLimit(BigDecimal.ZERO);
  503. holidayLimitInfo.setUsedLimit(BigDecimal.ZERO);
  504. holidayLimitInfo.setAddOrSubLimit(addOrSub);
  505. holidayLimitInfo.setPreOverdraftLimit(BigDecimal.ZERO);
  506. if (DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(joinDate)) {
  507. holidayLimitInfo.setCycleBeginDate(joinDate);
  508. int fprobation = iRowSet.getInt("FPROBATION");
  509. if (fprobation > 0) {
  510. holidayLimitInfo.setEffectDate(iRowSet.getDate("FPLANFORMALDATE"));
  511. } else {
  512. holidayLimitInfo.setEffectDate(holidayLimitInfo.getCycleBeginDate());
  513. }
  514. } else if ((fplanformaldate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(fplanformaldate))) {
  515. holidayLimitInfo.setCycleBeginDate(yearFirstDay);
  516. int fprobation = iRowSet.getInt("FPROBATION");
  517. if (fprobation > 0) {
  518. holidayLimitInfo.setEffectDate(iRowSet.getDate("FPLANFORMALDATE"));
  519. } else {
  520. holidayLimitInfo.setEffectDate(holidayLimitInfo.getCycleBeginDate());
  521. }
  522. } else {
  523. holidayLimitInfo.setCycleBeginDate(yearFirstDay);
  524. holidayLimitInfo.setEffectDate(holidayLimitInfo.getCycleBeginDate());
  525. }
  526. // 离职情况
  527. if (leaveDate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(leaveDate)) {
  528. holidayLimitInfo.setCycleEndDate(leaveDate);
  529. holidayLimitInfo.setDelayDate(leaveDate);
  530. holidayLimitInfo.setIsLeftConvert(true);
  531. } else {
  532. holidayLimitInfo.setCycleEndDate(yearLastDay);
  533. holidayLimitInfo.setDelayDate(yearLastDay);
  534. }
  535. holidayLimitInfo.setYear(DateTimeUtils.getYear(yearFirstDay));
  536. HolidayPolicyInfo holidayPolicyInfo = new HolidayPolicyInfo();
  537. holidayPolicyInfo.setId(BOSUuid.read(holidayPolicyId));
  538. holidayLimitInfo.setHolidayPolicy(holidayPolicyInfo);
  539. holidayLimitInfo.setHolidayUnit(HolidayTypeUnitEnum.day);
  540. holidayLimitInfo.setEnableCycle(true);
  541. PersonInfo personInfo = new PersonInfo();
  542. personInfo.setId(BOSUuid.read(iRowSet.getString("fid")));
  543. holidayLimitInfo.setProposer(personInfo);
  544. holidayLimitInfo.setStatus(HolidayLimitStatus.audited);
  545. if (StringUtils.isNotEmpty(iRowSet.getString("FADMINORGID"))) {
  546. AdminOrgUnitInfo adminOrgUnitInfo = new AdminOrgUnitInfo();
  547. adminOrgUnitInfo.setId(BOSUuid.read(iRowSet.getString("FADMINORGID")));
  548. holidayLimitInfo.setAdminOrgUnit(adminOrgUnitInfo);
  549. }
  550. if (StringUtils.isNotEmpty(iRowSet.getString("FHRORGUNITID"))) {
  551. HROrgUnitInfo hrOrgUnitInfo = new HROrgUnitInfo();
  552. hrOrgUnitInfo.setId(BOSUuid.read(iRowSet.getString("FHRORGUNITID")));
  553. holidayLimitInfo.setHrOrgUnit(hrOrgUnitInfo);
  554. }
  555. if (StringUtils.isNotEmpty(iRowSet.getString("FPOSITIONID"))) {
  556. PositionInfo positionInfo = new PositionInfo();
  557. positionInfo.setId(BOSUuid.read(iRowSet.getString("FPOSITIONID")));
  558. holidayLimitInfo.setPosition(positionInfo);
  559. }
  560. CtrlUnitInfo ctrlUnitInfo = new CtrlUnitInfo();
  561. ctrlUnitInfo.setId(BOSUuid.read("00000000-0000-0000-0000-000000000000CCE7AED4"));
  562. holidayLimitInfo.setCU(ctrlUnitInfo);
  563. holidayLimitInfo.setCycleDate(yearLastDay);
  564. holidayLimitInfo.setCreator(ContextUtil.getCurrentUserInfo(ctx));
  565. holidayLimitInfo.setCreateTime(new Timestamp(nowDate.getTime()));
  566. holidayLimitInfo.setLastUpdateUser(ContextUtil.getCurrentUserInfo(ctx));
  567. holidayLimitInfo.setLastUpdateTime(new Timestamp(nowDate.getTime()));
  568. // 如果假期额度在离职日期之后,不生成
  569. if (leaveDate != null && 1 == isleftconvert && leaveDate.getTime() <= holidayLimitInfo.getCycleEndDate().getTime()) {
  570. continue;
  571. }else {
  572. addList.add(holidayLimitInfo);
  573. }
  574. }
  575. }
  576. if (addList.size() > 0) {
  577. HolidayLimitFactory.getLocalInstance(ctx).addnewBatchData(addList);
  578. }
  579. if (updateList.size() > 0) {
  580. HolidayLimitFactory.getLocalInstance(ctx).updateBatchData(updateList);
  581. }
  582. if (deleteList.size() > 0) {
  583. IObjectPK[] iObjectPKS = new IObjectPK[deleteList.size()];
  584. for (int i = 0; i < deleteList.size(); i++) {
  585. iObjectPKS[i] = new ObjectUuidPK(deleteList.get(i));
  586. }
  587. HolidayLimitFactory.getLocalInstance(ctx).deleteBatchData(iObjectPKS);
  588. }
  589. if (reCalList.size() > 0) {
  590. for (int i = 0; i < reCalList.size(); i++) {
  591. int yearP = (int) reCalList.get(i).get("year");
  592. String personNumP = (String) reCalList.get(i).get("personNum");
  593. String lastYearSql = "/*dialect*/select p.fid,l.fid limitId,l.FSTANDARDLIMIT,l.FADDORSUBLIMIT,l.FUSEDLIMIT,l.FREEZELIMIT, coalesce(l.CFInitializedLimit, 0) CFInitializedLimit,coalesce(l.CFConvertedLimit, 0) CFConvertedLimit, coalesce(l.cflastcarryforward,0) cflastcarryforward,coalesce(l.cfcarryforward,0) cfcarryforward from t_bd_person p\n" +
  594. " left join T_HR_ATS_AtsHolidayFile f on f.fproposerid = p.fid \n" +
  595. " left join T_HR_ATS_HolidayPolicySet hps on f.fholidaypolicysetid = hps.fid \n" +
  596. " left join T_HR_ATS_HolidayPolicy hp on hps.fid = hp.fholidaypolicysetid \n" +
  597. " left join T_HR_ATS_HolidayType ht on ht.FNUMBER = 'JQLX000001Y' and ht.fid = hp.FHOLIDAYTYPEID \n" +
  598. " left join T_HR_ATS_HolidayLimit l on hp.fid = l.FHOLIDAYPOLICYID and l.FPROPOSERID = p.fid and l.FCYCLEBEGINDATE >= p.fhiredate and l.FCYCLEBEGINDATE <= p.FLEFFDT and l.fyear = " + (yearP - 1) + "\n" +
  599. " where f.fattendfilestate = 1 and p.fnumber = '" + personNumP + "' and l.fid is not null and ht.FNUMBER = 'JQLX000001Y' ";
  600. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  601. lastYearSql = "/*dialect*/select p.fid,l.fid limitId,l.FSTANDARDLIMIT,l.FADDORSUBLIMIT,l.FUSEDLIMIT,l.FREEZELIMIT, isnull(l.CFInitializedLimit, 0) CFInitializedLimit,isnull(l.CFConvertedLimit, 0) CFConvertedLimit, isnull(l.cflastcarryforward,0) cflastcarryforward,isnull(l.cfcarryforward,0) cfcarryforward from t_bd_person p\n" +
  602. " left join T_HR_ATS_AtsHolidayFile f on f.fproposerid = p.fid \n" +
  603. " left join T_HR_ATS_HolidayPolicySet hps on f.fholidaypolicysetid = hps.fid \n" +
  604. " left join T_HR_ATS_HolidayPolicy hp on hps.fid = hp.fholidaypolicysetid \n" +
  605. " left join T_HR_ATS_HolidayType ht on ht.FNUMBER = 'JQLX000001Y' and ht.fid = hp.FHOLIDAYTYPEID \n" +
  606. " left join T_HR_ATS_HolidayLimit l on hp.fid = l.FHOLIDAYPOLICYID and l.FPROPOSERID = p.fid and l.FCYCLEBEGINDATE >= p.fhiredate and l.FCYCLEBEGINDATE <= p.FLEFFDT and l.fyear = " + (yearP - 1) + "\n" +
  607. " where f.fattendfilestate = 1 and p.fnumber = '" + personNumP + "' and l.fid is not null and ht.FNUMBER = 'JQLX000001Y' ";
  608. }
  609. IRowSet lastYearRowSet = DbUtil.executeQuery(ctx, lastYearSql);
  610. if (lastYearRowSet.next()) {
  611. HolidayLimitInfo lastYearHolidayLimitInfo = new HolidayLimitInfo();
  612. // 标准额度 = 额度规则(折算额度)+初始化额度+从去年结转-结转到明年
  613. BigDecimal lastYearConvertedLimit = lastYearRowSet.getBigDecimal("CFConvertedLimit");
  614. BigDecimal lastYearInitializedLimit = lastYearRowSet.getBigDecimal("CFInitializedLimit");
  615. BigDecimal lastYearLastCarryforward = lastYearRowSet.getBigDecimal("CFLastCarryforward");
  616. BigDecimal lastYearCarryforward = BigDecimal.ZERO;
  617. BigDecimal lastYearStandardLimit = lastYearConvertedLimit.add(lastYearInitializedLimit).add(lastYearLastCarryforward).subtract(lastYearCarryforward);
  618. lastYearHolidayLimitInfo.setId(BOSUuid.read(lastYearRowSet.getString("limitId")));
  619. //lastYearHolidayLimitInfo.setStandardLimit(lastYearStandardLimit);
  620. //lastYearHolidayLimitInfo.setRealLimit(lastYearHolidayLimitInfo.getStandardLimit().add(lastYearRowSet.getBigDecimal("FADDORSUBLIMIT")));
  621. //lastYearHolidayLimitInfo.setRemainLimit(lastYearHolidayLimitInfo.getRealLimit().subtract(lastYearRowSet.getBigDecimal("FUSEDLIMIT")).subtract(lastYearRowSet.getBigDecimal("FreezeLimit")));
  622. lastYearHolidayLimitInfo.setBigDecimal("Carryforward", lastYearCarryforward);
  623. lastYearHolidayLimitInfo.setLastUpdateUser(ContextUtil.getCurrentUserInfo(ctx));
  624. lastYearHolidayLimitInfo.setLastUpdateTime(new Timestamp(nowDate.getTime()));
  625. //todo 历史额度不能变
  626. //HolidayLimitFactory.getLocalInstance(ctx).updatePartial(new ObjectUuidPK(lastYearHolidayLimitInfo.getId()), lastYearHolidayLimitInfo);
  627. LeaveAllowanceFacadeFactory.getLocalInstance(ctx).carryForwardLeave(yearP, true, personNumP);
  628. }
  629. }
  630. }
  631. } catch (SQLException e) {
  632. throw new BOSException(e);
  633. } catch (ParseException e) {
  634. throw new BOSException(e);
  635. } catch (EASBizException e) {
  636. throw new BOSException(e);
  637. }
  638. }
  639. private void initialGlobalParam(Context ctx) throws BOSException {
  640. // 全局变量
  641. Map<String, String> param = new HashMap<String, String>();
  642. ParamCollection paramCollection = ParamFactory.getLocalInstance(ctx).getParamCollection();
  643. for (int i = 0; i < paramCollection.size(); i++) {
  644. param.put(paramCollection.get(i).getNumber(), paramCollection.get(i).getValue());
  645. }
  646. // 年假折算
  647. annualLeaveConversionMethod = param.get(PARAM_ANNUALLEAVE_CONVERSIONMETHOD);
  648. // 年假取整
  649. annualLeaveIntegerMethod = param.get(PARAM_ANNUALLEAVE_INTEGERMETHOD);
  650. // 年假取整精度
  651. annualLeaveIntegerPrecision = Double.valueOf(param.get(PARAM_ANNUALLEAVE_INTEGERPERCISION));
  652. // 结转日期
  653. annualLeaveConvertDate = param.get(PARAM_ANNUALLEAVE_CONVERTDATE);
  654. // 下年度额度生成
  655. annualLeaveGenerateDay = param.get(PARAM_ANNUALLEAVE_GENERATEDAY);
  656. // 育儿假额度
  657. nursingLeaveLimit = Integer.parseInt(param.get(PARAM_NURSINGLEAVE_LIMIT));
  658. // 护理假额度
  659. parentalLeaveLimit = Integer.parseInt(param.get(PARAM_PARENTALLEAVE_LIMIT));
  660. // 护理育儿折算
  661. nursingAndParentalLeaveConversionMethod = param.get(PARAM_NURSINGANDPARENTALLEAVE_CONVERSIONMETHOD);
  662. // 护理育儿取整
  663. nursingAndParentalLeaveIntegerMethod = param.get(PARAM_NURSINGANDPARENTALLEAVE_INTEGERMETHOD);
  664. // 护理育儿取整精度
  665. nursingAndParentalLeaveIntegerPrecision = Double.valueOf(param.get(PARAM_NURSINGANDPARENTALLEAVE_INTEGERPERCISION));
  666. // 育儿护理多段统计是否更新视图脚本
  667. nursingAndParentalLeaveUpdateSql = param.get(PARAM_NURSINGANDPARENTALLEAVE_UPDATESQL);
  668. }
  669. /**
  670. * 设置司龄
  671. */
  672. @Override
  673. public void setSeniority(Context ctx) throws BOSException, EASBizException {
  674. String hisSql = "update T_HR_PersonPositionHis set FJOINCOMPANYYEARS=CEILING(FJOINCOMPANYYEARS) where year(FJOINDATE)<year(now())";
  675. logger.error("设置司龄SQL(HIS):" + hisSql);
  676. DbUtil.execute(ctx, hisSql);
  677. String sql = "update T_HR_PersonPosition set FJOINCOMPANYYEARS=CEILING(FJOINCOMPANYYEARS) where year(FJOINDATE)<year(now())";
  678. logger.error("设置司龄SQL:" + sql);
  679. DbUtil.execute(ctx, sql);
  680. }
  681. /**
  682. * 年假结转
  683. */
  684. @Override
  685. protected void _carryForwardLeave(Context ctx, int year, boolean isExecute, String personNum) throws BOSException, EASBizException {
  686. try {
  687. if (!isExecute) {
  688. return;
  689. }
  690. // 初始化公共变量
  691. initialGlobalParam(ctx);
  692. // 当前时间
  693. Date nowDate = new Date();
  694. Date currentDate = new Date();
  695. if (year != 0) {
  696. currentDate = DateTimeUtils.parseDate(year + "-12-31");
  697. } else {
  698. year = DateTimeUtils.getYear(currentDate);
  699. }
  700. List<String> personNumberList = new ArrayList<String>();
  701. CoreBaseCollection lastYearList = new CoreBaseCollection();
  702. CoreBaseCollection thisYearList = new CoreBaseCollection();
  703. String personNumStr = "";
  704. if (StringUtils.isNotEmpty(personNum)) {
  705. String[] personNumArr = personNum.split(",");
  706. for (int i = 0; i < personNumArr.length; i++) {
  707. personNumberList.add("'" + personNumArr[i] + "'");
  708. }
  709. personNumStr = String.join(",", personNumberList);
  710. }
  711. Date annualLeaveConvertDate = DateTimeUtils.parseDate(year + "-" + LeaveAllowanceFacadeControllerBean.annualLeaveConvertDate);
  712. if (currentDate.getTime() >= annualLeaveConvertDate.getTime()) {
  713. String sql = " /*dialect*/select thisL.fid thisLFid, lastL.fid lastLfID,thisL.FSTANDARDLIMIT, lastL.FREMAINLIMIT,ht.FNUMBER, " +
  714. " case when lastL.FREMAINLIMIT + thisL.CFEntitlementLimit <= 30 then coalesce(lastL.FREMAINLIMIT,0) else coalesce(30 - thisL.CFEntitlementLimit,0) end lastnextForward, " +
  715. " case when lastL.FREMAINLIMIT + thisL.CFEntitlementLimit <= 30 then coalesce(lastL.FREMAINLIMIT,0) else coalesce(30 - thisL.CFEntitlementLimit,0) end thislastforward, " +
  716. " lastL.FStandardLimit lFStandardLimit,coalesce(lastL.cfinitializedlimit,0) lcfinitializedlimit,coalesce(lastL.cfconvertedlimit,0) lcfconvertedlimit,lastL.FADDORSUBLIMIT lFADDORSUBLIMIT,lastL.FUSEDLIMIT lFUSEDLIMIT,lastL.FREEZELIMIT lFREEZELIMIT,coalesce(lastL.cflastcarryforward,0) lcflastcarryforward,coalesce(lastL.cfcarryforward,0) lcfcarryforward, " +
  717. " thisL.FStandardLimit tFStandardLimit,coalesce(thisL.cfinitializedlimit,0) tcfinitializedlimit,coalesce(thisL.cfconvertedlimit,0) tcfconvertedlimit,thisL.FADDORSUBLIMIT tFADDORSUBLIMIT,thisL.FUSEDLIMIT tFUSEDLIMIT,thisL.FREEZELIMIT tFREEZELIMIT,coalesce(thisL.cflastcarryforward,0) tcflastcarryforward,coalesce(thisL.cfcarryforward,0) tcfcarryforward " +
  718. " from t_bd_person p " +
  719. " left join T_HR_ATS_HolidayLimit lastL on p.fid = lastL.FPROPOSERID and lastL.FCYCLEBEGINDATE >= p.fhiredate and lastL.FCYCLEBEGINDATE <= p.FLEFFDT " +
  720. " left join T_HR_ATS_HolidayLimit thisL on thisL.FHOLIDAYPOLICYID = lastL.FHOLIDAYPOLICYID and thisL.FPROPOSERID = lastL.FPROPOSERID and thisL.FCYCLEBEGINDATE >= p.fhiredate and thisL.FCYCLEBEGINDATE <= p.FLEFFDT " +
  721. " left join T_HR_ATS_AtsHolidayFile hf on hf.fproposerid = p.fid " +
  722. " left join T_HR_ATS_HolidayPolicySet hps on hf.fholidaypolicysetid = hps.fid " +
  723. " left join T_HR_ATS_HolidayPolicy hp on hps.fid = hp.fholidaypolicysetid and thisL.FHOLIDAYPOLICYID = hp.fid " +
  724. " left join T_HR_ATS_HolidayType ht on ht.fid = hp.FHOLIDAYTYPEID and ht.FNUMBER = 'JQLX000001Y' " +
  725. " where hf.fattendfilestate = 1 and ht.FNUMBER = 'JQLX000001Y' and (lastL.cfcarryforward is null or lastL.cfcarryforward = 0) and thisL.FYEAR = " + year + " and lastL.fyear = " + (year - 1) + "";
  726. String dbType = ContextUtil.getDbType(ctx);
  727. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  728. sql = " /*dialect*/select thisL.fid thisLFid, lastL.fid lastLfID,thisL.FSTANDARDLIMIT, lastL.FREMAINLIMIT,ht.FNUMBER, " +
  729. " case when lastL.FREMAINLIMIT + thisL.CFEntitlementLimit <= 30 then isnull(lastL.FREMAINLIMIT,0) else isnull(30 - thisL.CFEntitlementLimit,0) end lastnextForward, " +
  730. " case when lastL.FREMAINLIMIT + thisL.CFEntitlementLimit <= 30 then isnull(lastL.FREMAINLIMIT,0) else isnull(30 - thisL.CFEntitlementLimit,0) end thislastforward, " +
  731. " lastL.FStandardLimit lFStandardLimit,isnull(lastL.cfinitializedlimit,0) lcfinitializedlimit,isnull(lastL.cfconvertedlimit,0) lcfconvertedlimit,lastL.FADDORSUBLIMIT lFADDORSUBLIMIT,lastL.FUSEDLIMIT lFUSEDLIMIT,lastL.FREEZELIMIT lFREEZELIMIT,isnull(lastL.cflastcarryforward,0) lcflastcarryforward,isnull(lastL.cfcarryforward,0) lcfcarryforward, " +
  732. " thisL.FStandardLimit tFStandardLimit,isnull(thisL.cfinitializedlimit,0) tcfinitializedlimit,isnull(thisL.cfconvertedlimit,0) tcfconvertedlimit,thisL.FADDORSUBLIMIT tFADDORSUBLIMIT,thisL.FUSEDLIMIT tFUSEDLIMIT,thisL.FREEZELIMIT tFREEZELIMIT,isnull(thisL.cflastcarryforward,0) tcflastcarryforward,isnull(thisL.cfcarryforward,0) tcfcarryforward " +
  733. " from t_bd_person p " +
  734. " left join T_HR_ATS_HolidayLimit lastL on p.fid = lastL.FPROPOSERID and lastL.FCYCLEBEGINDATE >= p.fhiredate and lastL.FCYCLEBEGINDATE <= p.FLEFFDT " +
  735. " left join T_HR_ATS_HolidayLimit thisL on thisL.FHOLIDAYPOLICYID = lastL.FHOLIDAYPOLICYID and thisL.FPROPOSERID = lastL.FPROPOSERID and thisL.FCYCLEBEGINDATE >= p.fhiredate and thisL.FCYCLEBEGINDATE <= p.FLEFFDT " +
  736. " left join T_HR_ATS_AtsHolidayFile hf on hf.fproposerid = p.fid " +
  737. " left join T_HR_ATS_HolidayPolicySet hps on hf.fholidaypolicysetid = hps.fid " +
  738. " left join T_HR_ATS_HolidayPolicy hp on hps.fid = hp.fholidaypolicysetid and thisL.FHOLIDAYPOLICYID = hp.fid " +
  739. " left join T_HR_ATS_HolidayType ht on ht.fid = hp.FHOLIDAYTYPEID and ht.FNUMBER = 'JQLX000001Y' " +
  740. " where hf.fattendfilestate = 1 and ht.FNUMBER = 'JQLX000001Y' and (lastL.cfcarryforward is null or lastL.cfcarryforward = 0) and thisL.FYEAR = " + year + " and lastL.fyear = " + (year - 1) + "";
  741. }
  742. if (StringUtils.isNotEmpty(personNumStr)) {
  743. sql += " and p.fnumber in (" + personNumStr + ") ";
  744. }
  745. IRowSet rowSet = DbUtil.executeQuery(ctx, sql);
  746. while (rowSet.next()) {
  747. HolidayLimitInfo lastYearHolidayLimitInfo = new HolidayLimitInfo();
  748. lastYearHolidayLimitInfo.setId(BOSUuid.read(rowSet.getString("lastLfID")));
  749. //今年结转额度
  750. lastYearHolidayLimitInfo.setBigDecimal("Carryforward", rowSet.getBigDecimal("lastnextForward"));
  751. // 去年 折算标准额度
  752. BigDecimal lastYearConvertedLimit = rowSet.getBigDecimal("lcfconvertedlimit");
  753. // 去年 初始化额度
  754. BigDecimal lastYearInitializedLimit = rowSet.getBigDecimal("lCFInitializedLimit");
  755. // 去年 从去年结转额度
  756. BigDecimal lastYearLastCarryforward = rowSet.getBigDecimal("lCFLastCarryforward");
  757. // 去年 标准额度 = 额度规则(折算额度)+初始化额度+从去年结转-结转到明年
  758. //去年 折算标准额度 + 去年 初始化额度 + 去年 从去年结转额度
  759. BigDecimal lastYearStandardLimit = lastYearConvertedLimit.add(lastYearInitializedLimit).add(lastYearLastCarryforward).subtract(lastYearHolidayLimitInfo.getBigDecimal("Carryforward"));
  760. // lastYearHolidayLimitInfo.setStandardLimit(lastYearStandardLimit);
  761. // lastYearHolidayLimitInfo.setRealLimit(lastYearHolidayLimitInfo.getStandardLimit().add(rowSet.getBigDecimal("LFADDORSUBLIMIT")));
  762. // lastYearHolidayLimitInfo.setRemainLimit(lastYearHolidayLimitInfo.getRealLimit().subtract(rowSet.getBigDecimal("LFUSEDLIMIT")).subtract(rowSet.getBigDecimal("lFreezeLimit")));
  763. // lastYearHolidayLimitInfo.setLastUpdateUser(ContextUtil.getCurrentUserInfo(ctx));
  764. // lastYearHolidayLimitInfo.setLastUpdateTime(new Timestamp(nowDate.getTime()));
  765. lastYearList.add(lastYearHolidayLimitInfo);
  766. HolidayLimitInfo thisYearHolidayLimitInfo = new HolidayLimitInfo();
  767. thisYearHolidayLimitInfo.setId(BOSUuid.read(rowSet.getString("thisLFid")));
  768. //上年转入额度
  769. thisYearHolidayLimitInfo.setBigDecimal("LastCarryforward", rowSet.getBigDecimal("thislastforward"));
  770. // 今年 折算标准额度
  771. BigDecimal thisYearConvertedLimit = rowSet.getBigDecimal("tcfconvertedlimit");
  772. // 今年 初始化额度
  773. BigDecimal thisYearInitializedLimit = rowSet.getBigDecimal("tCFInitializedLimit");
  774. // 今年 从去年结转额度 TODO xxx
  775. BigDecimal thisYearCarryforward = rowSet.getBigDecimal("tCFCarryforward");
  776. // 今年 标准额度 = 额度规则(折算额度)+初始化额度+从去年结转-结转到明年
  777. // 标准额度 =折算标准额度 + 今年初始化额度 + 上年转入额度 - 去年结转额度 ;
  778. BigDecimal thisYearStandardLimit = thisYearConvertedLimit.add(thisYearInitializedLimit).add(thisYearHolidayLimitInfo.getBigDecimal("LastCarryforward")).subtract(thisYearCarryforward);
  779. thisYearHolidayLimitInfo.setStandardLimit(thisYearStandardLimit);
  780. // 今年标准额度 + 增减额度 14 +0 =14
  781. thisYearHolidayLimitInfo.setRealLimit(thisYearHolidayLimitInfo.getStandardLimit().add(rowSet.getBigDecimal("tFADDORSUBLIMIT")));
  782. thisYearHolidayLimitInfo.setRemainLimit(thisYearHolidayLimitInfo.getRealLimit().subtract(rowSet.getBigDecimal("tFUSEDLIMIT")).subtract(rowSet.getBigDecimal("tFreezeLimit")));
  783. thisYearHolidayLimitInfo.setLastUpdateUser(ContextUtil.getCurrentUserInfo(ctx));
  784. thisYearHolidayLimitInfo.setLastUpdateTime(new Timestamp(nowDate.getTime()));
  785. thisYearList.add(thisYearHolidayLimitInfo);
  786. }
  787. }
  788. if (lastYearList.size() > 0) {
  789. SelectorItemCollection sc = new SelectorItemCollection();
  790. sc.add(new SelectorItemInfo("Carryforward"));
  791. sc.add(new SelectorItemInfo("LastCarryforward"));
  792. HolidayLimitFactory.getLocalInstance(ctx).updatePartialBatchData(lastYearList, sc);
  793. }
  794. if (thisYearList.size() > 0) {
  795. SelectorItemCollection sc = new SelectorItemCollection();
  796. sc.add(new SelectorItemInfo("Carryforward"));
  797. sc.add(new SelectorItemInfo("LastCarryforward"));
  798. sc.add(new SelectorItemInfo("standardLimit"));
  799. sc.add(new SelectorItemInfo("realLimit"));
  800. sc.add(new SelectorItemInfo("remainLimit"));
  801. sc.add(new SelectorItemInfo("lastUpdateUser"));
  802. sc.add(new SelectorItemInfo("lastUpdateTime"));
  803. HolidayLimitFactory.getLocalInstance(ctx).updateBatchData(thisYearList);
  804. }
  805. } catch (ParseException e) {
  806. throw new BOSException(e);
  807. } catch (SQLException e) {
  808. throw new BOSException(e);
  809. }
  810. }
  811. /**
  812. * 护理假额度生成 JQLX000016Y
  813. */
  814. @Override
  815. protected void _creareNursingLeave(Context ctx, int year, String personNum) throws BOSException {
  816. try{
  817. Map<String,String> nextParam = Maps.newHashMap();
  818. nextParam.put("year",String.valueOf(year));
  819. nextParam.put("personNum",personNum);
  820. nextParam.put("mack","NursingLeave");
  821. OSFAppUtil.callService(ctx,"leaveAllowanceService",nextParam);
  822. } catch (EASBizException e) {
  823. throw new BOSException(e);
  824. }
  825. //createNursingOrParentalLeave(ctx, year, personNum, "JQLX000016Y", nursingLeaveLimit, "P");
  826. }
  827. /**
  828. * 育儿假额度生成 JQLX000015Y
  829. */
  830. @Override
  831. protected void _creareParentalLeave(Context ctx, int year, String personNum) throws BOSException {
  832. //createNursingOrParentalLeave(ctx, year, personNum, "JQLX000015Y", parentalLeaveLimit, "C");
  833. try{
  834. Map<String,String> nextParam = Maps.newHashMap();
  835. nextParam.put("year",String.valueOf(year));
  836. nextParam.put("personNum",personNum);
  837. nextParam.put("mack","ParentalLeave");
  838. OSFAppUtil.callService(ctx,"leaveAllowanceService",nextParam);
  839. } catch (EASBizException e) {
  840. throw new BOSException(e);
  841. }
  842. }
  843. private void createNursingOrParentalLeave(Context ctx, int year, String personNum, String policyNumber, int initialLimit, String cnLeave) throws BOSException {
  844. try {
  845. initialGlobalParam(ctx);
  846. String personFamilyTempTable = createPersonFamilyTempTable(ctx, cnLeave);
  847. // 当前时间
  848. Date nowDate = new Date();
  849. Date currentDate = new Date();
  850. if (year != 0) {
  851. currentDate = DateTimeUtils.parseDate(year + "-12-31");
  852. } else {
  853. year = DateTimeUtils.getYear(currentDate);
  854. }
  855. // 当前年份第一天
  856. String yearFirstDayStr = DateTimeUtils.getYear(currentDate) + "-01-01";
  857. Date yearFirstDay = DateTimeUtils.parseDate(yearFirstDayStr);
  858. // 当前年份最后一天
  859. String yearLastDayStr = DateTimeUtils.getYear(currentDate) + "-12-31";
  860. Date yearLastDay = DateTimeUtils.parseDate(yearLastDayStr);
  861. List<String> personNumberList = new ArrayList<String>();
  862. CoreBaseCollection addList = new CoreBaseCollection();
  863. CoreBaseCollection updateList = new CoreBaseCollection();
  864. String personNumStr = "";
  865. if (StringUtils.isNotEmpty(personNum)) {
  866. String[] personNumArr = personNum.split(",");
  867. for (int i = 0; i < personNumArr.length; i++) {
  868. personNumberList.add("'" + personNumArr[i] + "'");
  869. }
  870. personNumStr = String.join(",", personNumberList);
  871. }
  872. // 置空相关的假期额度
  873. String clearQuotaSql = " update T_HR_ATS_HolidayLimit set FStandardLimit = 0, FRealLimit = FAddOrSubLimit,FRemainLimit = FAddOrSubLimit-FUsedLimit-FreezeLimit where fid in ( " +
  874. " select l.fid from T_HR_ATS_HolidayLimit l " +
  875. " left join T_HR_ATS_HolidayPolicy hp on hp.fid = l.FHOLIDAYPOLICYID " +
  876. " left join T_HR_ATS_HolidayType ht on hp.FHOLIDAYTYPEID = ht.fid " +
  877. " left join t_bd_person p on p.fid = l.FPROPOSERID " +
  878. " where ht.FNUMBER = '" + policyNumber + "' and l.FYEAR = " + year + " and l.FCYCLEBEGINDATE >= p.fhiredate and l.FCYCLEBEGINDATE <= p.FLEFFDT ";
  879. if (StringUtils.isNotEmpty(personNumStr)) {
  880. clearQuotaSql += " and p.fnumber in (" + personNumStr + ")) ";
  881. } else {
  882. clearQuotaSql += " ) ";
  883. }
  884. DbUtil.execute(ctx, clearQuotaSql);
  885. // 清理空数据
  886. String deleteZeroQuotaSql = "delete from T_HR_ATS_HolidayLimit where FHOLIDAYPOLICYID in (select hp.fid from T_HR_ATS_HolidayPolicy hp " +
  887. "left join T_HR_ATS_HolidayType ht on hp.FHOLIDAYTYPEID = ht.fid where ht.FNUMBER = '" + policyNumber + "') and FYEAR = " + year + " and FStandardLimit = 0 and FRealLimit = 0 and FAddOrSubLimit = 0 and FRemainLimit = 0 and FUsedLimit = 0 and FreezeLimit = 0 ";
  888. if (StringUtils.isNotEmpty(personNumStr)) {
  889. deleteZeroQuotaSql += " and FProposerID in (select fid from t_bd_person where fnumber in (" + personNumStr + ") ) ";
  890. }
  891. DbUtil.execute(ctx, deleteZeroQuotaSql);
  892. String sql = "/*dialect*/select f.FPERSONID,p.fnumber, case when to_char(f.CFStartTime,'yyyy') < " + year + " then to_date('" + year + "-01-01','yyyy-MM-dd') else f.CFStartTime end CFStartTime," +
  893. " case when f.CFEndTime is null or to_char(f.CFEndTime,'yyyy') > " + year + " then to_date('" + year + "-12-31','yyyy-MM-dd') else f.CFEndTime end CFEndTime ," +
  894. " case when rbe.fid is null then null else rbe.FBIZDATE end leaveDate,p.fhiredate,hf.FADMINORGUNITID, hf.FHRORGUNITID ,hf.FPOSITIONID, l.fid limitId,ebe.FPROBATION," +
  895. " ebe.FPLANFORMALDATE,hp.fid holidayPolicyId,l.FADDORSUBLIMIT,l.FUSEDLIMIT,l.FREEZELIMIT,l.FCYCLEBEGINDATE,l.FCYCLEENDDATE from " + personFamilyTempTable + " f " +
  896. " left join t_bd_person p on p.fid = f.FPERSONID " +
  897. " left join T_HR_ATS_AtsHolidayFile hf on hf.fproposerid = f.FPERSONID " +
  898. " left join T_HR_ATS_HolidayPolicySet hps on hf.fholidaypolicysetid = hps.fid " +
  899. " left join T_HR_ATS_HolidayPolicy hp on hps.fid = hp.fholidaypolicysetid" +
  900. " left join T_HR_ATS_HolidayType ht on ht.FNUMBER = '" + policyNumber + "' and ht.fid = hp.FHOLIDAYTYPEID " +
  901. " left join T_HR_ATS_HolidayLimit l on hp.fid = l.FHOLIDAYPOLICYID and l.FPROPOSERID = f.FPERSONID and l.FYEAR = " + year + " and f.CFStartTime<=l.FCYCLEBEGINDATE and f.CFEndTime>=l.FCYCLEBEGINDATE and l.FCYCLEBEGINDATE >= p.fhiredate and l.FCYCLEENDDATE >= p.fhiredate " +
  902. // " left join T_HR_EmpEnrollBizBillEntry ebe on ebe.FPERSONID = f.FPERSONID and ebe.FBIZDATE = p.fhiredate " +
  903. // " left join T_HR_EmpEnrollBizBill eb on ebe.FBILLID = eb.FID and eb.FBILLSTATE = 3 " +
  904. // " left join T_HR_ResignBizBillEntry rbe on rbe.FPERSONID = f.FPERSONID and (p.fhiredate<=rbe.FBIZDATE or rbe.FBIZDATE is null)" +
  905. // " left join T_HR_ResignBizBill rb on rb.fid = rbe.FBILLID and rb.FBILLSTATE = 3 " +
  906. " left join ( " +
  907. " select rownum rownumber,ebe.FPERSONID, " +
  908. " ebe.FPROBATION,ebe.FPLANFORMALDATE, ebe.FBIZDATE " +
  909. " from T_HR_EmpEnrollBizBillEntry ebe " +
  910. " inner join (select re1.fpersonid,max(re1.fbizdate) fbizdate,count(fid) from T_HR_EmpEnrollBizBillEntry re1 " +
  911. " group by re1.fpersonid) re1 on ebe.fpersonid=re1.fpersonid and re1.fbizdate=ebe.fbizdate " +
  912. " left join T_HR_EmpEnrollBizBill eb on ebe.FBILLID = eb.FID " +
  913. " and eb.FBILLSTATE = 3 " +
  914. " order by ebe.fbizdate desc) ebe " +
  915. " on ebe.FPERSONID = p.fid " +
  916. " and ebe.FBIZDATE = p.fhiredate " +
  917. " left join( " +
  918. " select rownum rownumber,rbe.fid, rbe.FPERSONID, " +
  919. " rbe.FENTERDATE, rbe.CFWcategoryID, rbe.FBIZDATE " +
  920. " from T_HR_ResignBizBillEntry rbe " +
  921. " inner join (select re1.fpersonid,max(re1.fbizdate) fbizdate,count(fid) from T_HR_ResignBizBillEntry re1 " +
  922. " group by re1.fpersonid) re1 on rbe.fpersonid=re1.fpersonid and re1.fbizdate=rbe.fbizdate " +
  923. " left join T_HR_ResignBizBill rb on rb.fid = rbe.FBILLID " +
  924. " and rb.FBILLSTATE = 3 order by rbe.fbizdate desc " +
  925. " ) rbe on rbe.FPERSONID = p.fid " +
  926. " and p.fhiredate = rbe.FENTERDATE " +
  927. " where ht.FNUMBER = '" + policyNumber + "' and hf.fattendfilestate = 1 and f.CFStartTime <= to_date('" + yearLastDayStr + "','yyyy-MM-dd') and (f.CFEndTime >= to_date('" + yearFirstDayStr + "','yyyy-MM-dd') or f.CFEndTime is null) and to_char(p.fhiredate,'yyyy')<=" + year + " and to_char(p.FLEFFDT,'yyyy')>=" + year;
  928. if (StringUtils.isNotEmpty(personNumStr)) {
  929. sql += " and p.fnumber in (" + personNumStr + ") ";
  930. }
  931. IRowSet iRowSet = DbUtil.executeQuery(ctx, sql);
  932. while (iRowSet.next()) {
  933. String holidayPolicyId = iRowSet.getString("holidayPolicyId");
  934. if (StringUtils.isEmpty(holidayPolicyId)) {
  935. continue;
  936. }
  937. BigDecimal standardLimit = BigDecimal.valueOf(initialLimit);
  938. String limitId = iRowSet.getString("limitId");
  939. // 入职日期
  940. java.sql.Date joinDate = iRowSet.getDate("fhiredate");
  941. java.sql.Date fplanformaldate = iRowSet.getDate("FPLANFORMALDATE");
  942. // 离职日期
  943. java.sql.Date leaveDate = iRowSet.getDate("leaveDate");
  944. // 开始日期
  945. java.sql.Date cfStartTime = iRowSet.getDate("CFStartTime");
  946. // 生效日期
  947. java.sql.Date effectDate = iRowSet.getDate("CFStartTime");
  948. // 结束日期
  949. java.sql.Date cfEndTime = iRowSet.getDate("CFEndTime");
  950. // 入职折算
  951. if (DateTimeUtils.getYear(joinDate) == DateTimeUtils.getYear(cfStartTime) && joinDate.getTime() > cfStartTime.getTime()) {
  952. cfStartTime = joinDate;
  953. effectDate = iRowSet.getDate("FPLANFORMALDATE") != null ? iRowSet.getDate("FPLANFORMALDATE") : joinDate;
  954. } else if (fplanformaldate != null && DateTimeUtils.getYear(fplanformaldate) == DateTimeUtils.getYear(cfStartTime) && fplanformaldate.getTime() > cfStartTime.getTime()) {
  955. effectDate = fplanformaldate;
  956. }
  957. // 离职折算
  958. if (leaveDate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(leaveDate)) {
  959. if (DateTimeUtils.getYear(leaveDate) == DateTimeUtils.getYear(cfEndTime) && cfEndTime.getTime() > leaveDate.getTime()) {
  960. cfEndTime = leaveDate;
  961. }
  962. }
  963. // 开始时间必须小于或等于结束日期
  964. if (cfStartTime.getTime() > cfEndTime.getTime()) {
  965. continue;
  966. }
  967. standardLimit = standardLimit.multiply(BigDecimal.valueOf(DateTimeUtils.getMonth(cfEndTime) - DateTimeUtils.getMonth(cfStartTime) + 1)).divide(BigDecimal.valueOf(MONTH_NUM_12), 10, BigDecimal.ROUND_HALF_UP);
  968. // 年假取整
  969. // 整数部分
  970. BigDecimal standardLimitInteger = standardLimit.setScale(0, RoundingMode.FLOOR);
  971. // 小数部分
  972. BigDecimal standardLimitDecimal = standardLimit.subtract(standardLimitInteger);
  973. if (Double.doubleToLongBits(INTEGERPERCISION_HALF) == Double.doubleToLongBits(nursingAndParentalLeaveIntegerPrecision)) {
  974. if (StringUtils.equals(INTEGERMETHOD_UP, nursingAndParentalLeaveIntegerMethod)) {
  975. if (standardLimitDecimal.compareTo(BigDecimal.valueOf(0.5)) > 0) {
  976. standardLimit = standardLimit.setScale(0, RoundingMode.CEILING);
  977. } else if (standardLimitDecimal.compareTo(BigDecimal.ZERO) > 0) {
  978. standardLimit = standardLimitInteger.add(BigDecimal.valueOf(0.5));
  979. } else {
  980. standardLimit = standardLimitInteger;
  981. }
  982. } else {
  983. if (standardLimitDecimal.compareTo(BigDecimal.valueOf(0.5)) > 0) {
  984. standardLimit = standardLimitInteger.add(BigDecimal.valueOf(0.5));
  985. } else {
  986. standardLimit = standardLimit.setScale(0, RoundingMode.FLOOR);
  987. }
  988. }
  989. } else {
  990. if (StringUtils.equals(INTEGERMETHOD_UP, nursingAndParentalLeaveIntegerMethod)) {
  991. standardLimit = standardLimit.setScale(0, RoundingMode.CEILING);
  992. } else {
  993. standardLimit = standardLimit.setScale(0, RoundingMode.FLOOR);
  994. }
  995. }
  996. if (StringUtils.isNotEmpty(limitId)) {
  997. HolidayLimitInfo holidayLimitInfo = new HolidayLimitInfo();
  998. holidayLimitInfo.setId(BOSUuid.read(limitId));
  999. // 标准额度
  1000. holidayLimitInfo.setStandardLimit(standardLimit);
  1001. holidayLimitInfo.setRealLimit(standardLimit.add(iRowSet.getBigDecimal("FADDORSUBLIMIT")));
  1002. holidayLimitInfo.setRemainLimit(standardLimit.add(iRowSet.getBigDecimal("FADDORSUBLIMIT")).subtract(iRowSet.getBigDecimal("FUSEDLIMIT")).subtract(iRowSet.getBigDecimal("FreezeLimit")));
  1003. holidayLimitInfo.setCycleBeginDate(cfStartTime);
  1004. holidayLimitInfo.setCycleEndDate(cfEndTime);
  1005. holidayLimitInfo.setEffectDate(effectDate);
  1006. holidayLimitInfo.setDelayDate(yearLastDay);
  1007. if (leaveDate != null && leaveDate.getTime() == cfEndTime.getTime()) {
  1008. holidayLimitInfo.setDelayDate(cfEndTime);
  1009. }
  1010. if (StringUtils.isNotEmpty(iRowSet.getString("FADMINORGUNITID"))) {
  1011. AdminOrgUnitInfo adminOrgUnitInfo = new AdminOrgUnitInfo();
  1012. adminOrgUnitInfo.setId(BOSUuid.read(iRowSet.getString("FADMINORGUNITID")));
  1013. holidayLimitInfo.setAdminOrgUnit(adminOrgUnitInfo);
  1014. }
  1015. if (StringUtils.isNotEmpty(iRowSet.getString("FHRORGUNITID"))) {
  1016. HROrgUnitInfo hrOrgUnitInfo = new HROrgUnitInfo();
  1017. hrOrgUnitInfo.setId(BOSUuid.read(iRowSet.getString("FHRORGUNITID")));
  1018. holidayLimitInfo.setHrOrgUnit(hrOrgUnitInfo);
  1019. }
  1020. if (StringUtils.isNotEmpty(iRowSet.getString("FPOSITIONID"))) {
  1021. PositionInfo positionInfo = new PositionInfo();
  1022. positionInfo.setId(BOSUuid.read(iRowSet.getString("FPOSITIONID")));
  1023. holidayLimitInfo.setPosition(positionInfo);
  1024. }
  1025. holidayLimitInfo.setLastUpdateUser(ContextUtil.getCurrentUserInfo(ctx));
  1026. holidayLimitInfo.setLastUpdateTime(new Timestamp(nowDate.getTime()));
  1027. updateList.add(holidayLimitInfo);
  1028. } else {
  1029. HolidayLimitInfo holidayLimitInfo = new HolidayLimitInfo();
  1030. holidayLimitInfo.setStandardLimit(standardLimit);
  1031. holidayLimitInfo.setRealLimit(standardLimit);
  1032. holidayLimitInfo.setRemainLimit(standardLimit);
  1033. holidayLimitInfo.setFreezeLimit(BigDecimal.ZERO);
  1034. holidayLimitInfo.setUsedLimit(BigDecimal.ZERO);
  1035. holidayLimitInfo.setAddOrSubLimit(BigDecimal.ZERO);
  1036. holidayLimitInfo.setPreOverdraftLimit(BigDecimal.ZERO);
  1037. holidayLimitInfo.setCycleBeginDate(cfStartTime);
  1038. holidayLimitInfo.setCycleEndDate(cfEndTime);
  1039. holidayLimitInfo.setEffectDate(effectDate);
  1040. holidayLimitInfo.setDelayDate(yearLastDay);
  1041. if (leaveDate != null && leaveDate.getTime() == cfEndTime.getTime()) {
  1042. holidayLimitInfo.setDelayDate(cfEndTime);
  1043. }
  1044. holidayLimitInfo.setYear(DateTimeUtils.getYear(yearFirstDay));
  1045. HolidayPolicyInfo holidayPolicyInfo = new HolidayPolicyInfo();
  1046. holidayPolicyInfo.setId(BOSUuid.read(holidayPolicyId));
  1047. holidayLimitInfo.setHolidayPolicy(holidayPolicyInfo);
  1048. holidayLimitInfo.setHolidayUnit(HolidayTypeUnitEnum.day);
  1049. holidayLimitInfo.setEnableCycle(true);
  1050. PersonInfo personInfo = new PersonInfo();
  1051. personInfo.setId(BOSUuid.read(iRowSet.getString("FPERSONID")));
  1052. holidayLimitInfo.setProposer(personInfo);
  1053. holidayLimitInfo.setStatus(HolidayLimitStatus.audited);
  1054. if (StringUtils.isNotEmpty(iRowSet.getString("FADMINORGUNITID"))) {
  1055. AdminOrgUnitInfo adminOrgUnitInfo = new AdminOrgUnitInfo();
  1056. adminOrgUnitInfo.setId(BOSUuid.read(iRowSet.getString("FADMINORGUNITID")));
  1057. holidayLimitInfo.setAdminOrgUnit(adminOrgUnitInfo);
  1058. }
  1059. if (StringUtils.isNotEmpty(iRowSet.getString("FHRORGUNITID"))) {
  1060. HROrgUnitInfo hrOrgUnitInfo = new HROrgUnitInfo();
  1061. hrOrgUnitInfo.setId(BOSUuid.read(iRowSet.getString("FHRORGUNITID")));
  1062. holidayLimitInfo.setHrOrgUnit(hrOrgUnitInfo);
  1063. }
  1064. if (StringUtils.isNotEmpty(iRowSet.getString("FPOSITIONID"))) {
  1065. PositionInfo positionInfo = new PositionInfo();
  1066. positionInfo.setId(BOSUuid.read(iRowSet.getString("FPOSITIONID")));
  1067. holidayLimitInfo.setPosition(positionInfo);
  1068. }
  1069. CtrlUnitInfo ctrlUnitInfo = new CtrlUnitInfo();
  1070. ctrlUnitInfo.setId(BOSUuid.read("00000000-0000-0000-0000-000000000000CCE7AED4"));
  1071. holidayLimitInfo.setCU(ctrlUnitInfo);
  1072. holidayLimitInfo.setCycleDate(yearLastDay);
  1073. holidayLimitInfo.setCreator(ContextUtil.getCurrentUserInfo(ctx));
  1074. holidayLimitInfo.setCreateTime(new Timestamp(nowDate.getTime()));
  1075. holidayLimitInfo.setLastUpdateUser(ContextUtil.getCurrentUserInfo(ctx));
  1076. holidayLimitInfo.setLastUpdateTime(new Timestamp(nowDate.getTime()));
  1077. addList.add(holidayLimitInfo);
  1078. }
  1079. }
  1080. if (addList.size() > 0) {
  1081. HolidayLimitFactory.getLocalInstance(ctx).addnewBatchData(addList);
  1082. }
  1083. if (updateList.size() > 0) {
  1084. HolidayLimitFactory.getLocalInstance(ctx).updateBatchData(updateList);
  1085. }
  1086. } catch (ParseException | SQLException e) {
  1087. throw new BOSException(e);
  1088. } catch (EASBizException e) {
  1089. throw new BOSException(e);
  1090. }
  1091. }
  1092. /**
  1093. * 创建社会关系临时表 处理日期区间合并数据
  1094. *
  1095. * @param ctx
  1096. * @param cnLeave
  1097. * @return
  1098. * @throws BOSException
  1099. */
  1100. private String createPersonFamilyTempTable(Context ctx, String cnLeave) throws BOSException {
  1101. String dbType = ContextUtil.getDbType(ctx);
  1102. String view_pf_PersonFamilyTempTable = "";
  1103. // 育儿护理多段统计是否更新视图脚本
  1104. if (StringUtils.equalsIgnoreCase(nursingAndParentalLeaveUpdateSql, "Y")) {
  1105. // 删除视图
  1106. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  1107. String dropView = " IF EXISTS (SELECT * FROM sys.views WHERE name = 'view_pf_DateRanges_" + cnLeave + "') " +
  1108. " DROP VIEW view_pf_DateRanges_" + cnLeave;
  1109. DbUtil.execute(ctx, dropView);
  1110. dropView = " IF EXISTS (SELECT * FROM sys.views WHERE name = 'view_pf_CTE_" + cnLeave + "') " +
  1111. " DROP VIEW view_pf_CTE_" + cnLeave;
  1112. DbUtil.execute(ctx, dropView);
  1113. dropView = " IF EXISTS (SELECT * FROM sys.views WHERE name = 'view_pf_MergedRanges_" + cnLeave + "') " +
  1114. " DROP VIEW view_pf_MergedRanges_" + cnLeave;
  1115. DbUtil.execute(ctx, dropView);
  1116. dropView = " IF EXISTS (SELECT * FROM sys.views WHERE name = 'view_pf_GroupedRanges_" + cnLeave + "') " +
  1117. " DROP VIEW view_pf_GroupedRanges_" + cnLeave;
  1118. DbUtil.execute(ctx, dropView);
  1119. }
  1120. // 创建视图
  1121. String createView = " /*dialect*/create or replace view view_pf_DateRanges_" + cnLeave + " as ( " +
  1122. " select CFStartTime StartDate,CFEndTime EndDate,FPERSONID PersonID from t_hr_personfamily where CFCnleave = '" + cnLeave + "' " +
  1123. " ) ";
  1124. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  1125. createView = " /*dialect*/create view view_pf_DateRanges_" + cnLeave + " as ( " +
  1126. " select CFStartTime StartDate,CFEndTime EndDate,FPERSONID PersonID from t_hr_personfamily where CFCnleave = '" + cnLeave + "' " +
  1127. " ) ";
  1128. }
  1129. DbUtil.execute(ctx, createView);
  1130. createView = " /*dialect*/create or replace view view_pf_CTE_" + cnLeave + " AS ( " +
  1131. " SELECT PersonID,StartDate, EndDate,LAG(EndDate) OVER (PARTITION BY PersonID ORDER BY StartDate) AS prev_end_date FROM view_pf_DateRanges_" + cnLeave +
  1132. ") ";
  1133. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  1134. createView = " /*dialect*/create view view_pf_CTE_" + cnLeave + " AS ( " +
  1135. " SELECT PersonID,StartDate, EndDate,LAG(EndDate) OVER (PARTITION BY PersonID ORDER BY StartDate) AS prev_end_date FROM view_pf_DateRanges_" + cnLeave +
  1136. ") ";
  1137. }
  1138. DbUtil.execute(ctx, createView);
  1139. createView = " /*dialect*/create or replace view view_pf_MergedRanges_" + cnLeave + " AS ( " +
  1140. " SELECT PersonID,StartDate,EndDate,CASE WHEN StartDate <= prev_end_date + INTERVAL '1 day' THEN 0 ELSE 1 END AS is_overlap FROM view_pf_CTE_" + cnLeave +
  1141. ") ";
  1142. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  1143. createView = " /*dialect*/create view view_pf_MergedRanges_" + cnLeave + " AS ( " +
  1144. " SELECT PersonID,StartDate,EndDate,CASE WHEN StartDate <= DATEADD(day, 1, prev_end_date) THEN 0 ELSE 1 END AS is_overlap FROM view_pf_CTE_" + cnLeave +
  1145. ") ";
  1146. }
  1147. DbUtil.execute(ctx, createView);
  1148. createView = " /*dialect*/create or replace view view_pf_GroupedRanges_" + cnLeave + " AS ( " +
  1149. " SELECT PersonID,StartDate,EndDate,SUM(is_overlap) OVER (PARTITION BY PersonID ORDER BY StartDate) AS grp FROM view_pf_MergedRanges_" + cnLeave +
  1150. ") ";
  1151. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  1152. createView = " /*dialect*/create view view_pf_GroupedRanges_" + cnLeave + " AS ( " +
  1153. " SELECT PersonID,StartDate,EndDate,SUM(is_overlap) OVER (PARTITION BY PersonID ORDER BY StartDate) AS grp FROM view_pf_MergedRanges_" + cnLeave +
  1154. ") ";
  1155. }
  1156. DbUtil.execute(ctx, createView);
  1157. }
  1158. view_pf_PersonFamilyTempTable = " (SELECT PersonID fpersonid,MIN(StartDate) AS CFStartTime,MAX(EndDate) AS CFEndTime FROM view_pf_GroupedRanges_" + cnLeave + " GROUP BY PersonID, grp ORDER BY PersonID, CFStartTime) ";
  1159. if (StringUtils.equalsIgnoreCase("MS SQL Server", dbType)) {
  1160. view_pf_PersonFamilyTempTable = " (SELECT top 100 percent PersonID fpersonid,MIN(StartDate) AS CFStartTime,MAX(EndDate) AS CFEndTime FROM view_pf_GroupedRanges_" + cnLeave + " GROUP BY PersonID, grp ORDER BY PersonID, CFStartTime) ";
  1161. }
  1162. return view_pf_PersonFamilyTempTable;
  1163. }
  1164. /**
  1165. * 员工列表
  1166. *
  1167. * @param ctx
  1168. * @param
  1169. * @return
  1170. * @throws BOSException
  1171. * @throws SQLException
  1172. */
  1173. private List<String> getPersonData(Context ctx, String leaveNumber, int year) throws BOSException, SQLException {
  1174. String nursingSql = " SELECT a.FPROPOSERID FROM T_HR_ATS_HolidayLimit as a ,T_HR_ATS_HolidayPolicy as b , T_HR_ATS_HolidayType c " +
  1175. " where a.FHOLIDAYPOLICYID = b.FID and b.FHOLIDAYTYPEID = c.FID and c.FNUMBER = '" + leaveNumber + "' and FYear = " + year + " ";
  1176. IRowSet rs = DbUtil.executeQuery(ctx, nursingSql);
  1177. List<String> personList = new ArrayList<String>();
  1178. while (rs.next()) {
  1179. personList.add(rs.getString("FPROPOSERID"));
  1180. }
  1181. return personList;
  1182. }
  1183. /**
  1184. * 开始时间
  1185. *
  1186. * @param
  1187. * @return
  1188. */
  1189. private static Date getStartDate(Date startDate) {
  1190. Calendar calendar = Calendar.getInstance();
  1191. int year = calendar.get(Calendar.YEAR);
  1192. calendar.clear();
  1193. calendar.set(Calendar.YEAR, year);
  1194. calendar.add(Calendar.MONTH, 1);
  1195. calendar.set(Calendar.DAY_OF_MONTH, 0);
  1196. if (startDate.before(calendar.getTime())) {
  1197. startDate = calendar.getTime();
  1198. }
  1199. return startDate;
  1200. }
  1201. /**
  1202. * 结束时间
  1203. *
  1204. * @param
  1205. * @return
  1206. */
  1207. private static Date getEndDate(Date endDate) {
  1208. Calendar calendar = Calendar.getInstance();
  1209. int year = calendar.get(Calendar.YEAR);
  1210. calendar.set(Calendar.YEAR, year);
  1211. calendar.roll(Calendar.DAY_OF_YEAR, -1);
  1212. calendar.set(Calendar.MONTH, 11);
  1213. calendar.set(Calendar.DAY_OF_MONTH, 1);
  1214. if (endDate.after(calendar.getTime())) {
  1215. endDate = calendar.getTime();
  1216. }
  1217. return endDate;
  1218. }
  1219. /**
  1220. * 返回休假天数
  1221. *
  1222. * @param day
  1223. * @param month
  1224. * @return
  1225. */
  1226. public double getLeaveDay(double day, int month) {
  1227. double leaveDay = day / 12.0 * month;
  1228. int floorInt = (int) leaveDay;
  1229. double decimals = leaveDay - floorInt;
  1230. if (decimals < 0.5) {
  1231. System.out.print("可休假额度:" + floorInt);
  1232. return floorInt;
  1233. } else {
  1234. System.out.print("可休假额度:" + floorInt + 0.5);
  1235. return (floorInt + 0.5);
  1236. }
  1237. }
  1238. /**
  1239. * 获取假期类型为对应的假期制度id集合
  1240. *
  1241. * @param ctx
  1242. * @param holidayNumber
  1243. * @return
  1244. */
  1245. public String getHolidayPolicyIds(Context ctx, String holidayNumber) {
  1246. StringBuffer holidayPolicyIds = new StringBuffer();
  1247. try {
  1248. HolidayTypeCollection holidayTypeCollection = HolidayTypeFactory.getLocalInstance(ctx).getHolidayTypeCollection("where number = '" + holidayNumber + "'");
  1249. if (holidayTypeCollection != null && holidayTypeCollection.size() > 0) {
  1250. HolidayPolicyCollection holidayPolicyCollection = HolidayPolicyFactory.getLocalInstance(ctx).getHolidayPolicyCollection("where holidayType = '" + holidayTypeCollection.get(0).getId().toString() + "'");
  1251. for (int i = 0; i < holidayPolicyCollection.size(); i++) {
  1252. holidayPolicyIds.append("'" + holidayPolicyCollection.get(i).getId().toString() + "',");
  1253. }
  1254. if (holidayPolicyIds.length() > 0) {
  1255. holidayPolicyIds = holidayPolicyIds.deleteCharAt(holidayPolicyIds.length() - 1);
  1256. }
  1257. }
  1258. } catch (BOSException e) {
  1259. e.printStackTrace();
  1260. }
  1261. return holidayPolicyIds.toString();
  1262. }
  1263. /**
  1264. * 根据假期额度名称获取id
  1265. * @param ctx
  1266. * @param holidayName
  1267. * @return
  1268. */
  1269. // public String getHolidayPolicyID(Context ctx, String holidayNumber) {
  1270. // try {
  1271. // HolidayTypeCollection holidayTypeCollection = HolidayTypeFactory.getLocalInstance(ctx).getHolidayTypeCollection("where number = '"+holidayNumber+"'");
  1272. // if(holidayTypeCollection!=null && holidayTypeCollection.size()>0) {
  1273. // HolidayPolicyCollection holidayPolicyCollection = HolidayPolicyFactory.getLocalInstance(ctx).getHolidayPolicyCollection("where holidayType = '"+holidayTypeCollection.get(0).getId().toString()+"'");
  1274. // if(holidayPolicyCollection != null && holidayPolicyCollection.size()>0) {
  1275. // return holidayPolicyCollection.get(0).getId().toString();
  1276. // }
  1277. // }
  1278. // } catch (BOSException e) {
  1279. // e.printStackTrace();
  1280. // }
  1281. // return "";
  1282. // }
  1283. }