|
|
@@ -1,5 +1,6 @@
|
|
|
package com.kingdee.eas.custom.facade.leave;
|
|
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
import com.grapecity.documents.excel.D;
|
|
|
import com.kingdee.bos.dao.IObjectPK;
|
|
|
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
|
|
|
@@ -15,6 +16,7 @@ import com.kingdee.eas.custom.bd.param.ParamCollection;
|
|
|
import com.kingdee.eas.custom.bd.param.ParamFactory;
|
|
|
import com.kingdee.eas.hr.ats.*;
|
|
|
import com.kingdee.eas.util.app.ContextUtil;
|
|
|
+import com.kingdee.shr.base.syssetting.app.osf.OSFAppUtil;
|
|
|
import com.kingdee.util.DateTimeUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.log4j.Logger;
|
|
|
@@ -147,15 +149,24 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
}
|
|
|
|
|
|
// 年假额度生成
|
|
|
- generateAnnualLeave(ctx, year, personNum, currentDate);
|
|
|
-
|
|
|
+ // generateAnnualLeave(ctx, year, personNum, currentDate);
|
|
|
+ Map<String,String> param = Maps.newHashMap();
|
|
|
+ param.put("year",String.valueOf(year));
|
|
|
+ param.put("personNum",personNum);
|
|
|
+ param.put("currentDate",DateTimeUtils.formatDate(currentDate));
|
|
|
+ OSFAppUtil.callService(ctx,"leaveAllowanceService",param);
|
|
|
// 下年年假额度生成
|
|
|
if (isGenerateNextYearAnnualLeave) {
|
|
|
int nextYear = year + 1;
|
|
|
Date nextYearCurrentDay = DateTimeUtils.addYear(currentDate, 1);
|
|
|
- generateAnnualLeave(ctx, nextYear, personNum, nextYearCurrentDay);
|
|
|
+ // generateAnnualLeave(ctx, nextYear, personNum, nextYearCurrentDay);
|
|
|
+ Map<String,String> nextParam = Maps.newHashMap();
|
|
|
+ nextParam.put("year",String.valueOf(nextYear));
|
|
|
+ nextParam.put("personNum",personNum);
|
|
|
+ nextParam.put("currentDate",DateTimeUtils.formatDate(currentDate));
|
|
|
+ OSFAppUtil.callService(ctx,"leaveAllowanceService",nextParam);
|
|
|
}
|
|
|
- } catch (ParseException e) {
|
|
|
+ } catch (ParseException | EASBizException e) {
|
|
|
throw new BOSException(e);
|
|
|
}
|
|
|
|
|
|
@@ -171,6 +182,27 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
*/
|
|
|
private void generateAnnualLeave(Context ctx, int year, String personNum, Date currentDate) throws BOSException {
|
|
|
try {
|
|
|
+ String updateHolidaypolicy = "/*dialect*/MERGE INTO T_HR_ATS_HolidayLimit AS hl \n" +
|
|
|
+ " USING ( \n" +
|
|
|
+
|
|
|
+ " select\n" +
|
|
|
+ " hl.fid,\n" +
|
|
|
+ " af.fproposerid, hpf.fid AS holiday_policy_id \n" +
|
|
|
+ " from \n" +
|
|
|
+ " T_HR_ATS_AtsHolidayFile af \n" +
|
|
|
+ " left JOIN T_HR_ATS_HolidayPolicy hpf ON hpf.fholidaypolicysetid = af.fholidaypolicysetid \n" +
|
|
|
+ " left JOIN T_HR_ATS_HolidayType ht ON ht.FID = hpf.fholidaytypeid \n" +
|
|
|
+ " left join T_HR_ATS_HolidayLimit hl on af.FPROPOSERID =hl.fproposerid \n" +
|
|
|
+ " where ht.FNUMBER = 'JQLX000001Y' and hl.fholidaypolicyid in( \n" +
|
|
|
+ " select hp.fid from T_HR_ATS_HolidayPolicy hp \n" +
|
|
|
+ " inner JOIN T_HR_ATS_HolidayType ht ON ht.FID = hp.fholidaytypeid \n" +
|
|
|
+ " where ht.FNUMBER = 'JQLX000001Y' \n" +
|
|
|
+ " ) \n" +
|
|
|
+ " and to_char(hl.fcyclebegindate,'yyyy')='"+year+"' \n"+
|
|
|
+ " ) AS src ON hl.fid = src.fid and to_char(hl.fcyclebegindate,'yyyy') ='"+year+"' \n" +
|
|
|
+ " WHEN MATCHED THEN \n" +
|
|
|
+ " UPDATE SET hl.fname_l3=hl.fholidaypolicyid,hl.fholidaypolicyid = src.holiday_policy_id";
|
|
|
+ DbUtil.execute(ctx,updateHolidaypolicy);
|
|
|
Date nowDate = new Date();
|
|
|
// 考勤制度和年假id对应
|
|
|
Map<String, String> holidayPolicyMap = new HashMap<String, String>();
|
|
|
@@ -209,17 +241,17 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
"coalesce(l.FUSEDLIMIT,0) FUSEDLIMIT,coalesce(l.FREEZELIMIT,0) FREEZELIMIT,coalesce(l.cflastcarryforward,0) cflastcarryforward," +
|
|
|
"coalesce(l.cfcarryforward,0) cfcarryforward,coalesce(l.CFEntitlementLimit,0) CFEntitlementLimit,coalesce(l.CFInitializedLimit,0) CFInitializedLimit, " +
|
|
|
"ebe.FPROBATION,ebe.FPLANFORMALDATE,hp.fid holidayPolicyId,l.fisleftconvert isleftconvert " +
|
|
|
- " from T_BD_Person p " +
|
|
|
+ " from T_HR_ATS_AtsHolidayFile f " +
|
|
|
+ " left join T_BD_Person p on f.fproposerid = p.fid " +
|
|
|
" left join T_HR_EmpOrgRelation eo on p.fid = eo.fpersonid and eo.fleffdt='2199-12-31 00:00:00' " +
|
|
|
" left join CT_MP_Fullorpart fp on fp.fid = p.cfftorptid " +
|
|
|
- " left join T_HR_ATS_AtsHolidayFile f on f.fproposerid = p.fid " +
|
|
|
|
|
|
//" left join T_HR_ATS_HolidayPolicySet hps on f.fholidaypolicysetid = hps.fid " +
|
|
|
//" left join T_HR_ATS_HolidayPolicy hp on hp.FHOLIDAYPOLICYSETID = hps.fid " +
|
|
|
" left join T_HR_ATS_HolidayType ht on ht.FNUMBER = 'JQLX000001Y' " +
|
|
|
" left join T_HR_ATS_HolidayPolicy hp on ht.FID =hp.fholidaytypeid " +
|
|
|
-// " and hps.fid = hp.fholidaypolicysetid " +
|
|
|
- " 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 +
|
|
|
+ " and f.fholidaypolicysetid = hp.fholidaypolicysetid " +
|
|
|
+ " 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 +
|
|
|
// " left join T_HR_EmpEnrollBizBillEntry ebe on ebe.FPERSONID = p.fid and ebe.FBIZDATE = p.fhiredate " +
|
|
|
// " left join T_HR_EmpEnrollBizBill eb on ebe.FBILLID = eb.FID and eb.FBILLSTATE = 3 " +
|
|
|
// " left join T_HR_ResignBizBillEntry rbe on rbe.FPERSONID = p.fid and p.fhiredate = rbe.FENTERDATE " +
|
|
|
@@ -271,9 +303,9 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
int joinDateYear = iRowSet.getInt("joinDateYear");
|
|
|
// 入职日期
|
|
|
Date joinDate = iRowSet.getDate("fhiredate");
|
|
|
- java.sql.Date fplanformaldate = iRowSet.getDate("FPLANFORMALDATE");
|
|
|
+ Date fplanformaldate = iRowSet.getDate("FPLANFORMALDATE");
|
|
|
// 离职日期
|
|
|
- java.sql.Date leaveDate = iRowSet.getDate("leaveDate");
|
|
|
+ Date leaveDate = iRowSet.getDate("leaveDate");
|
|
|
// 标准额度=额度规则(折算额度)+初始化额度+从去年结转-结转到明年
|
|
|
BigDecimal standardLimit = BigDecimal.ZERO;
|
|
|
// 折算标准额度
|
|
|
@@ -418,12 +450,19 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
realLimit = standardLimit.add(addOrSubLimit);
|
|
|
// 剩余额度 = 实际额度-已用额度-在途额度
|
|
|
remainLimit = realLimit.subtract(usedLimit).subtract(freezeLimit);
|
|
|
+ BigDecimal addOrSub=BigDecimal.ZERO;
|
|
|
+ if(remainLimit.compareTo(BigDecimal.valueOf(30))>0){
|
|
|
+ addOrSub = BigDecimal.valueOf(30).subtract(remainLimit);
|
|
|
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(limitId)) {
|
|
|
HolidayLimitInfo holidayLimitInfo = new HolidayLimitInfo();
|
|
|
holidayLimitInfo.setId(BOSUuid.read(limitId));
|
|
|
// 标准额度
|
|
|
holidayLimitInfo.setStandardLimit(standardLimit);
|
|
|
+ //增减
|
|
|
+ addOrSubLimit=addOrSubLimit.add(addOrSub);
|
|
|
+ holidayLimitInfo.setAddOrSubLimit(addOrSubLimit);
|
|
|
// 折算标准额度
|
|
|
holidayLimitInfo.setBigDecimal("convertedLimit", convertedLimit);
|
|
|
// 未折算标准额度
|
|
|
@@ -433,10 +472,10 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
holidayLimitInfo.setBigDecimal("lastCarryforward", lastCarryforward);
|
|
|
holidayLimitInfo.setBigDecimal("Carryforward", carryforward);
|
|
|
// 默认值
|
|
|
- holidayLimitInfo.setCycleBeginDate(yearFirstDay);
|
|
|
- holidayLimitInfo.setCycleEndDate(yearLastDay);
|
|
|
- holidayLimitInfo.setEffectDate(yearFirstDay);
|
|
|
- holidayLimitInfo.setDelayDate(yearLastDay);
|
|
|
+// holidayLimitInfo.setCycleBeginDate(yearFirstDay);
|
|
|
+// holidayLimitInfo.setCycleEndDate(yearLastDay);
|
|
|
+// holidayLimitInfo.setEffectDate(yearFirstDay);
|
|
|
+// holidayLimitInfo.setDelayDate(yearLastDay);
|
|
|
|
|
|
// 离职情况
|
|
|
if (leaveDate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(leaveDate) && joinDate.compareTo(leaveDate) < 0) {
|
|
|
@@ -480,18 +519,21 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
if (leaveDate != null && 1 == isleftconvert && leaveDate.getTime() <= holidayLimitInfo.getCycleEndDate().getTime()) {
|
|
|
//deleteList.add(limitId);
|
|
|
continue;
|
|
|
+ }else {
|
|
|
+
|
|
|
+ updateList.add(holidayLimitInfo);
|
|
|
}
|
|
|
- updateList.add(holidayLimitInfo);
|
|
|
} else {
|
|
|
HolidayLimitInfo holidayLimitInfo = new HolidayLimitInfo();
|
|
|
holidayLimitInfo.setStandardLimit(standardLimit);
|
|
|
holidayLimitInfo.setBigDecimal("convertedLimit", convertedLimit);
|
|
|
holidayLimitInfo.setBigDecimal("entitlementLimit", entitlementLimit);
|
|
|
+
|
|
|
holidayLimitInfo.setRealLimit(realLimit);
|
|
|
holidayLimitInfo.setRemainLimit(remainLimit);
|
|
|
holidayLimitInfo.setFreezeLimit(BigDecimal.ZERO);
|
|
|
holidayLimitInfo.setUsedLimit(BigDecimal.ZERO);
|
|
|
- holidayLimitInfo.setAddOrSubLimit(BigDecimal.ZERO);
|
|
|
+ holidayLimitInfo.setAddOrSubLimit(addOrSub);
|
|
|
holidayLimitInfo.setPreOverdraftLimit(BigDecimal.ZERO);
|
|
|
if (DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(joinDate)) {
|
|
|
holidayLimitInfo.setCycleBeginDate(joinDate);
|
|
|
@@ -517,6 +559,7 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
if (leaveDate != null && DateTimeUtils.getYear(currentDate) == DateTimeUtils.getYear(leaveDate)) {
|
|
|
holidayLimitInfo.setCycleEndDate(leaveDate);
|
|
|
holidayLimitInfo.setDelayDate(leaveDate);
|
|
|
+ holidayLimitInfo.setIsLeftConvert(true);
|
|
|
} else {
|
|
|
holidayLimitInfo.setCycleEndDate(yearLastDay);
|
|
|
holidayLimitInfo.setDelayDate(yearLastDay);
|
|
|
@@ -560,8 +603,10 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
// 如果假期额度在离职日期之后,不生成
|
|
|
if (leaveDate != null && 1 == isleftconvert && leaveDate.getTime() <= holidayLimitInfo.getCycleEndDate().getTime()) {
|
|
|
continue;
|
|
|
+ }else {
|
|
|
+
|
|
|
+ addList.add(holidayLimitInfo);
|
|
|
}
|
|
|
- addList.add(holidayLimitInfo);
|
|
|
}
|
|
|
}
|
|
|
if (addList.size() > 0) {
|
|
|
@@ -795,9 +840,18 @@ public class LeaveAllowanceFacadeControllerBean extends AbstractLeaveAllowanceFa
|
|
|
if (lastYearList.size() > 0) {
|
|
|
SelectorItemCollection sc = new SelectorItemCollection();
|
|
|
sc.add(new SelectorItemInfo("Carryforward"));
|
|
|
+ sc.add(new SelectorItemInfo("LastCarryforward"));
|
|
|
HolidayLimitFactory.getLocalInstance(ctx).updatePartialBatchData(lastYearList, sc);
|
|
|
}
|
|
|
if (thisYearList.size() > 0) {
|
|
|
+ SelectorItemCollection sc = new SelectorItemCollection();
|
|
|
+ sc.add(new SelectorItemInfo("Carryforward"));
|
|
|
+ sc.add(new SelectorItemInfo("LastCarryforward"));
|
|
|
+ sc.add(new SelectorItemInfo("standardLimit"));
|
|
|
+ sc.add(new SelectorItemInfo("realLimit"));
|
|
|
+ sc.add(new SelectorItemInfo("remainLimit"));
|
|
|
+ sc.add(new SelectorItemInfo("lastUpdateUser"));
|
|
|
+ sc.add(new SelectorItemInfo("lastUpdateTime"));
|
|
|
HolidayLimitFactory.getLocalInstance(ctx).updateBatchData(thisYearList);
|
|
|
}
|
|
|
|