package com.kingdee.eas.custom.ot.handler; import com.kingdee.bos.BOSException; import com.kingdee.bos.Context; import com.kingdee.bos.util.BOSUuid; import com.kingdee.eas.common.EASBizException; import com.kingdee.eas.custom.ot.util.OverTimeAgainstApproveUtil; import com.kingdee.eas.framework.CoreBaseInfo; import com.kingdee.eas.hr.ats.AtsOverTimeBillInfo; import com.kingdee.eas.util.app.DbUtil; import com.kingdee.shr.ats.web.handler.AtsOverTimeBillEditHandler; import com.kingdee.shr.base.syssetting.context.SHRContext; import com.kingdee.shr.base.syssetting.exception.SHRWebException; import org.springframework.ui.ModelMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Map; /** * 多人加班单审核通过的单据分录变更后保存新增单据的实现 * @author lhbj */ public class AtsOverTimeBillEditHandlerEx extends AtsOverTimeBillEditHandler { protected void beforeSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException { //处理原单分录,以跳过标准校验 AtsOverTimeBillInfo billInfo = (AtsOverTimeBillInfo)model; Context ctx = SHRContext.getInstance().getContext(); String oldEntryId = request.getParameter("oldEntryId"); String oldBillID = request.getParameter("oldBillID"); String updEntry = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?"; String newId = String.valueOf(BOSUuid.create(billInfo.getBOSType())); try { DbUtil.execute(ctx, updEntry, new String[]{newId.toString(), oldEntryId}); } catch (BOSException e) { throw new RuntimeException(e); } super.beforeSave(request, response, model); } protected void afterSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException { super.afterSave(request, response, model); //处理原单分录,以跳过标准校验 AtsOverTimeBillInfo billInfo = (AtsOverTimeBillInfo)model; Context ctx = SHRContext.getInstance().getContext(); String oldEntryId = request.getParameter("oldEntryId"); String oldBillID = request.getParameter("oldBillID"); String newId = billInfo.getId().toString(); try { String updBill = "update T_HR_ATS_OverTimeBill set FBillState=3 where fid=?"; DbUtil.execute(ctx, updBill, new String[]{newId}); String updEntry = "update T_HR_ATS_OverTimeBillEntry set fbillid=? where fid=?"; DbUtil.execute(ctx, updEntry, new String[]{oldBillID, oldEntryId}); //生成新单据完成后,删除原单据分录数据,然后触发计算 OverTimeAgainstApproveUtil u = new OverTimeAgainstApproveUtil(); Map map = u.deleteOTEntry(ctx, oldBillID, oldEntryId); System.out.println("afterSave:"+map); } catch (BOSException e) { throw new RuntimeException(e); } catch (EASBizException e) { throw new RuntimeException(e); } } public String saveAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException { return super.saveAction(request, response, modelMap); } }