package com.kingdee.eas.custom.ot.util; import com.google.common.collect.Maps; import com.kingdee.bos.BOSException; import com.kingdee.bos.Context; import com.kingdee.bos.dao.ObjectNotFoundException; import com.kingdee.bos.dao.ormapping.ObjectUuidPK; import com.kingdee.bos.metadata.entity.SelectorItemCollection; import com.kingdee.bos.metadata.entity.SelectorItemInfo; import com.kingdee.bos.util.BOSUuid; import com.kingdee.eas.base.permission.UserInfo; import com.kingdee.eas.common.EASBizException; import com.kingdee.eas.framework.CoreBaseCollection; import com.kingdee.eas.hr.ats.*; import com.kingdee.eas.hr.ats.dataLog.util.DataLogsRecordUtil; import com.kingdee.eas.hr.ats.takeWorkLimit.impl.GenerateTakeWorkLimit; import com.kingdee.eas.hr.ats.thread.ExecutorService.TaskPool; import com.kingdee.eas.hr.ats.thread.executor.Callable; import com.kingdee.eas.hr.ats.util.AtsDateUtils; import com.kingdee.eas.hr.ats.util.AtsServerCalUtils; import com.kingdee.eas.hr.ats.util.SHRBillServerUtil; import com.kingdee.eas.hr.ats.util.common.MLUtile; import com.kingdee.eas.util.app.DbUtil; import com.kingdee.jdbc.rowset.IRowSet; import com.kingdee.shr.ats.bill.util.AtsBillSourceTypeUtil; import com.kingdee.shr.ats.service.result.AttendCalculateParent; import com.kingdee.shr.ats.service.vo.AtsOverTimeVo; import com.kingdee.shr.base.syssetting.app.osf.OSFAppUtil; import com.kingdee.shr.base.syssetting.exception.SHRWebException; import com.kingdee.shr.base.syssetting.exception.ShrWebBizException; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.ThreadPoolExecutor; /** * 加班单 * 反审批 * * @ lhbj */ public class OverTimeAgainstApproveUtil { private static Logger logger = Logger.getLogger(OverTimeAgainstApproveUtil.class); public String getBillIds(HttpServletRequest request) throws ShrWebBizException { String billId = (String) request.getAttribute("billId"); if (StringUtils.isEmpty(billId)) { billId = request.getParameter("billId"); } if (StringUtils.isEmpty(billId)) { billId = request.getParameter("billID"); } if (StringUtils.isEmpty(billId)) { billId = (String) request.getAttribute("billID"); } if (StringUtils.isEmpty(billId)) { throw new ShrWebBizException(new AtsCommonBizException(AtsCommonBizException.NULLBILLID)); } else { return billId; } } /** * 取消核通过的单据分录变更 * @param ctx * @param billId * @param entryId * @return * @throws SHRWebException */ public Map unChangeOTEntry(Context ctx, String billId, String entryId) throws BOSException { Map res = Maps.newHashMap(); // IAtsOverTimeBill iBill = AtsOverTimeBillFactory.getLocalInstance(ctx); // IAtsOverTimeBillEntry iBillEntry = AtsOverTimeBillEntryFactory.getLocalInstance(ctx); //删除新单据分录 String updEntry2 = "delete from T_HR_ATS_OverTimeBillEntry where fid=?"; DbUtil.execute(ctx, updEntry2, new String[]{entryId.toString()}); //新单据 // String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?"; // DbUtil.execute(ctx, delNewBill, new String[]{billId.toString()}); return res; } /** * 变更审批通过的分录 * 第一步:生成一样数据进行 * * @param ctx * @param billId * @param entryId * @return */ public Map changeOTEntry(Context ctx, String billId, String entryId) throws BOSException { System.out.println("changeOTEntry"); Map res = Maps.newHashMap(); IAtsOverTimeBill iBill = AtsOverTimeBillFactory.getLocalInstance(ctx); IAtsOverTimeBillEntry iBillEntry = AtsOverTimeBillEntryFactory.getLocalInstance(ctx); //更新id BOSUuid newId = null; BOSUuid newEntryId = null; res.put("code", "err"); res.put("msg", "失败"); try { System.out.println("changeOTEntry:" + billId + "-" + entryId); SelectorItemCollection selectorItemCollection = new SelectorItemCollection(); selectorItemCollection.add(new SelectorItemInfo("*")); //获取原单分录 AtsOverTimeBillEntryInfo oldEntryInfo = iBillEntry.getAtsOverTimeBillEntryInfo(new ObjectUuidPK(entryId), selectorItemCollection); //获取原单 AtsOverTimeBillInfo oldBillInfo = iBill.getAtsOverTimeBillInfo(new ObjectUuidPK(billId), selectorItemCollection); System.out.println("changeOTEntry"); //创建新单 AtsOverTimeBillInfo newBillInfo = (AtsOverTimeBillInfo) oldBillInfo.clone(); newBillInfo.setSourceBillId(newBillInfo.getId().toString()); //更新为单人编辑界面 newBillInfo.setBillSubmitType(BillSubmitTypeEnum.common); System.out.println("changeOTEntry"); //更新id newId = BOSUuid.create(oldBillInfo.getBOSType()); newBillInfo.setId(newId); //创建新单分录集合 AtsOverTimeBillEntryCollection newEntryCollection = new AtsOverTimeBillEntryCollection(); //添加待变更分录 AtsOverTimeBillEntryInfo newEntryInfo = (AtsOverTimeBillEntryInfo) oldEntryInfo.clone(); //变更分录id newEntryId = BOSUuid.create(oldEntryInfo.getBOSType()); newEntryInfo.setId(newEntryId); newEntryInfo.setBill(newBillInfo); newEntryCollection.add(newEntryInfo); newBillInfo.put("entries", newEntryCollection); System.out.println("changeOTEntry4" + newBillInfo); iBill.addnew(new ObjectUuidPK(newId), newBillInfo); //更新新单为审批通过 String updBill = "update T_HR_ATS_OverTimeBill set FBillState=3 where fid=?"; DbUtil.execute(ctx, updBill, new String[]{newId.toString()}); System.out.println("changeOTEntry5" + newId.toString()); //反审批校验 Map bres = this.beforeAgainstApproveAction(ctx, newId.toString()); System.out.println("changeOTEntry6" + bres.toString()); res.putAll(bres); String errorMsgList = (String) bres.get("errorMsgList"); if (StringUtils.isNotBlank(errorMsgList)) { //校验失败 res.put("code", "err"); res.put("msg", errorMsgList); } else { //更新新单为未提交状态 String updBill2 = "update T_HR_ATS_OverTimeBill set FBillState=0 where fid=?"; DbUtil.execute(ctx, updBill2, new String[]{newId.toString()}); res.put("msg", "成功"); res.put("billID", newId.toString()); res.put("entryId", newEntryId.toString()); res.put("oldBillID", billId.toString()); res.put("oldEntryId", entryId.toString()); res.put("code", "ses"); } //反审批失败处理 if ("err".equals(res.get("code"))) { //删除新单据分录 String updEntry2 = "delete from T_HR_ATS_OverTimeBillEntry where fid=?"; DbUtil.execute(ctx, updEntry2, new String[]{newEntryId.toString()}); //新单据 String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?"; DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()}); } else { //需要等待专员变更后处理 } } catch (Exception e) { e.printStackTrace(); res.put("msg", e.getMessage()); //删除新单据分录 String updEntry2 = "delete from T_HR_ATS_OverTimeBillEntry where fid=?"; DbUtil.execute(ctx, updEntry2, new String[]{newEntryId.toString()}); //新单据 String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?"; DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()}); logger.error(e); } finally { System.out.println("deleteOTEntry.finally:" + res); } return res; } /** * 删除审批通过的分录 * * @param ctx * @param billId * @param entryId * @return */ public Map deleteOTEntry(Context ctx, String billId, String entryId) throws BOSException, EASBizException { System.out.println("deleteOTEntry"); Map res = Maps.newHashMap(); IAtsOverTimeBill iBill = AtsOverTimeBillFactory.getLocalInstance(ctx); IAtsOverTimeBillEntry iBillEntry = AtsOverTimeBillEntryFactory.getLocalInstance(ctx); //更新id BOSUuid newId = null; res.put("code", "err"); res.put("msg", "失败"); try { System.out.println("deleteOTEntry:" + billId + "-" + entryId); SelectorItemCollection selectorItemCollection = new SelectorItemCollection(); selectorItemCollection.add(new SelectorItemInfo("*")); //获取原单分录 AtsOverTimeBillEntryInfo oldEntryInfo = iBillEntry.getAtsOverTimeBillEntryInfo(new ObjectUuidPK(entryId), selectorItemCollection); //获取原单 AtsOverTimeBillInfo oldBillInfo = iBill.getAtsOverTimeBillInfo(new ObjectUuidPK(billId), selectorItemCollection); System.out.println("deleteOTEntry1"); //创建新单 AtsOverTimeBillInfo newBillInfo = (AtsOverTimeBillInfo) oldBillInfo.clone(); newBillInfo.setSourceBillId(newBillInfo.getId().toString()); System.out.println("deleteOTEntry2"); //更新id newId = BOSUuid.create(oldBillInfo.getBOSType()); newBillInfo.setId(newId); //创建新单分录集合 AtsOverTimeBillEntryCollection newEntryCollection = new AtsOverTimeBillEntryCollection(); //添加待删除分录 newBillInfo.put("entries", newEntryCollection); System.out.println("deleteOTEntry4" + newBillInfo); iBill.addnew(new ObjectUuidPK(newId), newBillInfo); //更新原单分录为新单据分录 String updEntry = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?"; DbUtil.execute(ctx, updEntry, new String[]{newId.toString(), entryId}); System.out.println("deleteOTEntry3"); //更新新单为审批通过 String updBill = "update T_HR_ATS_OverTimeBill set FBillState=3 where fid=?"; DbUtil.execute(ctx, updBill, new String[]{newId.toString()}); System.out.println("deleteOTEntry5" + newId.toString()); //反审批校验 Map bres = this.beforeAgainstApproveAction(ctx, newId.toString()); System.out.println("deleteOTEntry6" + bres.toString()); res.putAll(bres); String errorMsgList = (String) bres.get("errorMsgList"); if (StringUtils.isNotBlank(errorMsgList)) { //校验失败 res.put("code", "err"); res.put("msg", errorMsgList); } else { Map ares = this.againstApproveAction(ctx, "删除分录", newId.toString()); res.putAll(ares); Set successIds = (Set) ares.get("successIds"); if (1 != successIds.size()) { //反审批失败 res.put("code", "err"); } else { res.put("code", "ses"); } } //反审批失败处理 if ("err".equals(res.get("code"))) { //更新新单据分录为原单分录 String updEntry2 = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?"; DbUtil.execute(ctx, updEntry2, new String[]{billId, entryId}); //新单据 String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?"; DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()}); } else { //新单据 String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?"; DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()}); //新单据 String delNewEntry = "delete from T_HR_ATS_OverTimeBillEntry where fid=?"; DbUtil.execute(ctx, delNewEntry, new String[]{entryId.toString()}); } } catch (Exception e) { e.printStackTrace(); res.put("msg", e.getMessage()); //更新新单据分录为原单分录 String updEntry2 = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?"; DbUtil.execute(ctx, updEntry2, new String[]{billId, entryId}); logger.error(e); } finally { System.out.println("deleteOTEntry.finally:" + res); String delNewBill = "delete from T_HR_ATS_OverTimeBill where fid=?"; DbUtil.execute(ctx, delNewBill, new String[]{newId.toString()}); } return res; } /** * 反审批前校验 * * @param ctx * @param billIds * @return {"turned":15,"errorMsgList":"[贺加贝]的选中记录中存在加班单参与了加班转调休计算,反审批后调休额度的剩余额度小于0且假期制度不允许超额请假,请先将请假单反审批再操作!","turnedInfos":"[刘光辉 2025-07-01]、[Mike 2025-07-01]、[王斌 2025-07-01]、[周芳 2025-07-01]、[刘浔 2025-07-01]、[simone 2025-07-01]、[曹浪 2025-07-01]、[唐建强 2025-07-01]、[田文立 2025-07-01]、[张晗 2025-07-01]、[张大利 2025-07-01]、[Vincent 2025-07-01]、[高爽 2025-07-01]、[贺加贝 2025-07-01]、[张三01 2025-07-01]"} * @throws SHRWebException * @throws BOSException * @throws EASBizException */ public Map beforeAgainstApproveAction(Context ctx, String billIds) throws SHRWebException, BOSException, EASBizException { Map res = new HashMap(); String flag = "true"; if (StringUtils.isBlank(billIds)) { throw new ShrWebBizException(new AtsCommonBizException(AtsCommonBizException.ILLEGALID)); } else { IAtsOverTimeBill iAtsOverTimeInfo = AtsOverTimeBillFactory.getRemoteInstance(); String[] ids = billIds.split(","); Map limitDeductMap = new HashMap(); if (ids != null && ids.length > 0) { for (int i = 0; i < ids.length; ++i) { String billId = ids[i]; if ("true".equals(flag)) { StringBuffer checkSB = new StringBuffer(""); checkSB.append("select sum.fid from T_HR_ATS_AttendanceResultSum sum inner join T_HR_ATS_OverTimeBillEntry lbe on lbe.fpersonId = sum.fproposerId and lbe.fadminOrgUnitId = sum.fadminOrgUnitId and sum.FSalaryStatus = 1 "); checkSB.append("inner join T_HR_ATS_OverTimeBill lb on lb.fid = lbe.FBillID inner join T_HR_ATS_AttendancePeriod ap on ap.fid = sum.FAttendancePeriodID and lbe.FRealEndTime < DATEADD(DAY,1,ap.FEndDate) "); checkSB.append(" where lb.fid = '" + billId + "' "); IRowSet row = DbUtil.executeQuery(ctx, checkSB.toString()); if (row.size() > 0) { throw new ShrWebBizException(new AtsAgainstApprove(AtsAgainstApprove.EXCEPTIONOVER)); } } AtsOverTimeBillInfo billInfo = iAtsOverTimeInfo.getAtsOverTimeBillInfo(new ObjectUuidPK(billId)); if (billInfo.getBillState().getValue() != 3) { throw new ShrWebBizException(new AtsOTBizException(AtsOTBizException.CANCERAUDITNOTMATHAUDIT)); } this.isTurned(ctx, billInfo, res, limitDeductMap); } String turnedInfos = (String) res.get("turnedInfos"); if (turnedInfos != null && turnedInfos.length() > 0) { turnedInfos = turnedInfos.substring(0, turnedInfos.length() - 1); res.put("turnedInfos", turnedInfos); } } return res; } } public void isTurned(Context ctx, AtsOverTimeBillInfo billInfo, Map res, Map limitDeductMap) { Map toTakeWorkDetailMap = new HashMap(); AtsOverTimeBillEntryCollection entries = billInfo.getEntries(); Map otDates = new HashMap(); Set entryPersonIds = new HashSet(); Map detailInfosMap = new HashMap(); if (entries != null && entries.size() > 0) { for (int i = 0; i < entries.size(); ++i) { String personId = entries.get(i).getPerson().getId().toString(); entryPersonIds.add(personId); otDates.put(personId, entries.get(i).getOtDate()); try { OTtoTakeWorkDetailCollection detailInfos = OTtoTakeWorkDetailFactory.getLocalInstance(ctx).getOTtoTakeWorkDetailCollection("select id, proposer.id,proposer.name,proposer.number,limit,limitValue where sourceBillID = '" + entries.get(i).getId() + "' and state = 0 "); if (detailInfos != null && detailInfos.size() > 0) { toTakeWorkDetailMap.put(personId, detailInfos.get(0)); String limitId = detailInfos.get(0).getLimit(); if (limitDeductMap.get(limitId) == null) { limitDeductMap.put(limitId, detailInfos.get(0).getLimitValue()); } else { limitDeductMap.put(limitId, ((BigDecimal) limitDeductMap.get(limitId)).add(detailInfos.get(0).getLimitValue())); } } else { AttendanceResultCollection results = AttendanceResultFactory.getLocalInstance(ctx).getAttendanceResultCollection("select id where attenceDate = '" + entries.get(i).getOtDate() + "' and proposer.id = '" + entries.get(i).getPerson().getId().toString() + "'"); if (results.size() > 0) { detailInfos = OTtoTakeWorkDetailFactory.getLocalInstance(ctx).getOTtoTakeWorkDetailCollection("select id, proposer.id,proposer.name,proposer.number,limit,limitValue where sourceBillID = '" + results.get(0).getId() + "' and state = 0 "); if (detailInfos.size() > 0) { toTakeWorkDetailMap.put(personId, detailInfos.get(0)); if (detailInfosMap.get(detailInfos.get(0).getId().toString()) == null) { String limitId = detailInfos.get(0).getLimit(); detailInfosMap.put(detailInfos.get(0).getId().toString(), detailInfos.get(0).getLimitValue()); if (limitDeductMap.get(limitId) == null) { limitDeductMap.put(limitId, detailInfos.get(0).getLimitValue()); } else { limitDeductMap.put(limitId, ((BigDecimal) limitDeductMap.get(limitId)).add(detailInfos.get(0).getLimitValue())); } } } } } } catch (ObjectNotFoundException e) { e.printStackTrace(); } catch (BOSException e) { e.printStackTrace(); } } } int turned = res.get("turned") == null ? 0 : (Integer) res.get("turned"); String turnedInfos = res.get("turnedInfos") == null ? "" : (String) res.get("turnedInfos"); if (!toTakeWorkDetailMap.isEmpty()) { for (String key : toTakeWorkDetailMap.keySet()) { ++turned; turnedInfos = turnedInfos + "[" + ((OTtoTakeWorkDetailInfo) toTakeWorkDetailMap.get(key)).getProposer().getName() + " " + AtsDateUtils.dateShortToString((Date) otDates.get(key)) + "]、"; } this.checkRemainLimit(ctx, res, limitDeductMap); } res.put("turned", turned); res.put("turnedInfos", turnedInfos); } private void checkRemainLimit(Context ctx, Map res, Map limitDeductMap) { StringBuffer sb = new StringBuffer(); try { IRowSet rs = DbUtil.executeQuery(ctx, "SELECT LI.FREMAINLIMIT,LI.FID ,PO.FIsOver, PERSON.FNAME" + MLUtile.getMlFlag(ctx) + " AS personName FROM T_HR_ATS_HOLIDAYLIMIT LI INNER JOIN T_HR_ATS_HolidayPolicy PO ON LI.FHOLIDAYPOLICYID = PO.FID INNER JOIN T_BD_PERSON PERSON ON PERSON.FID = LI.FPROPOSERID WHERE LI.FID IN (" + AtsUtil.convertSetToString(limitDeductMap.keySet()) + ")"); while (rs.next()) { String limitId = rs.getString("FID"); BigDecimal remainLimit = rs.getBigDecimal("FREMAINLIMIT"); int isOver = rs.getInt("FIsOver"); BigDecimal deductLimit = (BigDecimal) limitDeductMap.get(limitId); if (deductLimit != null && isOver == 0 && remainLimit.subtract(deductLimit).compareTo(BigDecimal.ZERO) < 0) { sb.append("[" + rs.getString("personName") + "]"); } } } catch (Exception e) { e.printStackTrace(); } if (StringUtils.isNotEmpty(sb.toString())) { res.put("errorMsgList", MLUtile.getRes(AtsOverTimeBillResEnum.existsOTDetailAndRemainLimitLessThanZero, ctx, new Object[]{sb.toString()})); } } public String doAgainApprove(Context ctx, String billId, String aiReason) throws EASBizException, BOSException, SHRWebException { IAtsOverTimeBill iAtsOverTimeInfo = AtsOverTimeBillFactory.getRemoteInstance(); AtsOverTimeBillInfo billInfo = iAtsOverTimeInfo.getAtsOverTimeBillInfo(new ObjectUuidPK(billId)); CoreBaseCollection detailColl = new CoreBaseCollection(); AtsOverTimeBillEntryCollection entries = billInfo.getEntries(); boolean isCreateTagISAuto = false; if (entries != null && entries.size() > 0) { for (int i = 0; i < entries.size(); ++i) { OverTimeCreateTag createTag = entries.get(i).getCreateTag(); entries.get(i).setCreateTag(OverTimeCreateTag.userCreate); if (null != createTag && createTag.getValue() == 3) { isCreateTagISAuto = true; } if (null != createTag && createTag.getValue() == 2) { isCreateTagISAuto = true; } OTtoTakeWorkDetailInfo detailInfo = null; try { detailInfo = OTtoTakeWorkDetailFactory.getLocalInstance(ctx).getOTtoTakeWorkDetailInfo(" where sourceBillID = '" + entries.get(i).getId().toString() + "' and state = 0 "); } catch (ObjectNotFoundException e) { e.printStackTrace(); } if (detailInfo != null) { detailInfo.setState(OTtoTakeWorkDetailStatus.invalid); detailColl.add(detailInfo); } } } OTtoTakeWorkDetailFactory.getLocalInstance(ctx).save(detailColl); if (SHRBillServerUtil.overTimeControl(ctx, billInfo.getHrOrgUnit().getId().toString()) && !isCreateTagISAuto) { try { String serviceName = "calculatePersonOTLimit"; Map param = new HashMap(); param.put("billId", billId); param.put("operator", "against"); OSFAppUtil.callService(ctx, serviceName, (HashMap) param); } catch (Exception e) { e.printStackTrace(); } } String successId = this.callOverTimeBillAgainstApproveJob(ctx, billInfo, aiReason); AtsBillSourceTypeUtil.uptBillSourceTypeWithBack(ctx, billId); DataLogsRecordUtil.processListObjectsLog(billInfo, OperActionEnum.againstApprove, ctx); return successId; } private String callOverTimeBillAgainstApproveJob(Context ctx, AtsOverTimeBillInfo billInfo, String aiReason) throws EASBizException, BOSException { AtsOverTimeBillEntryCollection entrysInfo = billInfo.getEntries(); IAtsOverTimeBillEntry iAtsOverTimeBillEntry = AtsOverTimeBillEntryFactory.getRemoteInstance(); CoreBaseCollection colls = new CoreBaseCollection(); List personIds = new ArrayList(); Date minOtDate = null; Date maxOtDate = null; for (int i = 0; i < entrysInfo.size(); ++i) { AtsOverTimeBillEntryInfo entryInfo = entrysInfo.get(i); entryInfo.setCalculateState(false); entryInfo.setHolidayLimit((HolidayLimitInfo) null); entryInfo.setLastUpdateUser((UserInfo) ctx.get("UserInfo")); entryInfo.setLastUpdateTime(AtsDateUtils.dateToTimestamp(new Date())); colls.add(entryInfo); personIds.add(entryInfo.getPerson().getId().toString()); if (null == minOtDate) { minOtDate = entryInfo.getOtDate(); maxOtDate = entryInfo.getOtDate(); } else { if (entryInfo.getOtDate().compareTo(minOtDate) < 0) { minOtDate = entryInfo.getOtDate(); } if (entryInfo.getOtDate().compareTo(maxOtDate) > 0) { maxOtDate = entryInfo.getOtDate(); } } } if (!colls.isEmpty()) { iAtsOverTimeBillEntry.update(colls); } String billId = billInfo.getId().toString(); String sql = " update t_hr_ats_overTimeBill set fbillstate = 0,faireason=? ,fLastUpdateTime=?,fLastUpdateUserId=? where fid = ?"; Object[] params = new Object[]{aiReason, new Timestamp(System.currentTimeMillis()), ctx.getCaller().toString(), billId}; DbUtil.execute(ctx, sql, params); AtsOverTimeVo atsOverTimeVo = new AtsOverTimeVo(); atsOverTimeVo.setMaxOtDate(maxOtDate); atsOverTimeVo.setMinOtDate(minOtDate); atsOverTimeVo.setPersonIds(personIds); atsOverTimeVo.setEntrysInfo(entrysInfo); try { ThreadPoolExecutor pool = TaskPool.getFixedInstance("updateHolidayLimit", 1, 10L); pool.submit((Callable) (new Callable() { public Object call() throws Exception { AtsOverTimeVo overTimeVo = (AtsOverTimeVo) this.getDependency(); AttendCalculateParent cal = new AttendCalculateParent(); String personIdsStr = AtsServerCalUtils.getPersonIdsNoQuote(overTimeVo.getPersonIds()); cal.calAttendResultByAdminOrgPersonAndDate(this.ctx, overTimeVo.getMinOtDate(), overTimeVo.getMaxOtDate(), 1, (String) null, personIdsStr, 0, "", 1); AtsOverTimeBillEntryCollection entrysInfo = overTimeVo.getEntrysInfo(); for (int i = 0; i < entrysInfo.size(); ++i) { Map param = new HashMap(); param.put("adminOrgUnitNum", ""); param.put("personNum", entrysInfo.get(i).getPerson().getId().toString()); param.put("cycleDate", AtsDateUtils.dateShortToString(entrysInfo.get(i).getOtDate())); GenerateTakeWorkLimit service = new GenerateTakeWorkLimit(this.ctx); service.generateTakeWorkLimitBackGround(this.ctx, param); } return null; } }).setDependency(atsOverTimeVo).setCtx(ctx)); } catch (Exception e) { e.printStackTrace(); } return billId; } /** * 反审批 * * @param ctx * @param aiReason * @param billIds * @return * @throws SHRWebException * @throws BOSException * @throws EASBizException */ public Map againstApproveAction(Context ctx, String aiReason, String billIds) throws SHRWebException, BOSException, EASBizException { List atsInfoIds = new ArrayList(); Map res = new HashMap(); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); aiReason = sf.format(new Date()) + "," + ctx.getUserName() + ":" + aiReason; Set successIds = new HashSet(); res.put("successIds", successIds); String[] ids = billIds.split(","); if (ids != null && ids.length > 0) { for (int t = 0; t < ids.length; ++t) { String billId = ids[t].trim(); if (!atsInfoIds.contains(billId)) { atsInfoIds.add(billId); successIds.add(this.doAgainApprove(ctx, billId, aiReason)); } } } res.put("msg", MLUtile.getRes(AtsOverTimeBillResEnum.againstApproveSuccess, ctx)); return res; } }