AtsLeaveBillEditHandlerEx.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package com.kingdee.shr.ats.web.handler;
  2. import java.sql.SQLException;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import org.slf4j.Logger;
  8. import org.slf4j.LoggerFactory;
  9. import org.springframework.ui.ModelMap;
  10. import com.kingdee.bos.BOSException;
  11. import com.kingdee.bos.Context;
  12. import com.kingdee.bos.dao.IObjectPK;
  13. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  14. import com.kingdee.eas.common.EASBizException;
  15. import com.kingdee.eas.custom.ats.AtsLeaveBillDetailSameFactory;
  16. import com.kingdee.eas.custom.ats.AtsLeaveBillDetailSameInfo;
  17. import com.kingdee.eas.framework.CoreBaseInfo;
  18. import com.kingdee.eas.hr.ats.AtsLeaveBillCollection;
  19. import com.kingdee.eas.hr.ats.AtsLeaveBillFactory;
  20. import com.kingdee.eas.hr.ats.AtsLeaveBillInfo;
  21. import com.kingdee.eas.hr.ats.HolidayPolicyFactory;
  22. import com.kingdee.eas.hr.ats.HolidayPolicyInfo;
  23. import com.kingdee.eas.hr.ats.HolidayTypeFactory;
  24. import com.kingdee.eas.hr.ats.HolidayTypeInfo;
  25. import com.kingdee.eas.hr.ats.HolidayTypeUnitEnum;
  26. import com.kingdee.eas.util.app.DbUtil;
  27. import com.kingdee.jdbc.rowset.IRowSet;
  28. import com.kingdee.shr.ats.web.handler.util.AtsLeaveBillOperationUtil;
  29. import com.kingdee.shr.base.syssetting.context.SHRContext;
  30. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  31. import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
  32. public class AtsLeaveBillEditHandlerEx extends AtsLeaveBillEditHandler {
  33. private static final Logger logger = LoggerFactory.getLogger(AtsLeaveBillEditHandlerEx.class);
  34. /**
  35. * 获取假期信息(根据假期制度)
  36. * @param request
  37. * @param response
  38. * @param modelMap
  39. * @throws EASBizException
  40. * @throws BOSException
  41. * @throws SHRWebException
  42. */
  43. public void getLeaveDataAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws EASBizException, BOSException, SHRWebException {
  44. Context ctx = SHRContext.getInstance().getContext();
  45. String policyId = request.getParameter("policyId");
  46. HolidayPolicyInfo policyInfo = HolidayPolicyFactory.getLocalInstance(ctx).getHolidayPolicyInfo(new ObjectUuidPK(policyId));
  47. HolidayTypeInfo holidayInfo = null;
  48. if(policyInfo != null && policyInfo.getHolidayType() != null) {
  49. String holidayTypeId = policyInfo.getHolidayType().getId().toString();
  50. holidayInfo = HolidayTypeFactory.getLocalInstance(ctx).getHolidayTypeInfo(new ObjectUuidPK(holidayTypeId));
  51. }
  52. JSONUtils.writeJson(response, holidayInfo);
  53. }
  54. /**
  55. * 根据假期制度获取假期类型单位
  56. * @param request
  57. * @param response
  58. * @param modelMap
  59. * @throws EASBizException
  60. * @throws BOSException
  61. * @throws SHRWebException
  62. */
  63. public void getLeaveUnitAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws EASBizException, BOSException, SHRWebException {
  64. Context ctx = SHRContext.getInstance().getContext();
  65. String policyId = request.getParameter("policyId");
  66. HolidayPolicyInfo policyInfo = HolidayPolicyFactory.getLocalInstance(ctx).getHolidayPolicyInfo(new ObjectUuidPK(policyId));
  67. HolidayTypeUnitEnum unit = policyInfo.getUnit();
  68. modelMap.put("leaveUnit", unit.getValue());
  69. JSONUtils.writeJson(response, modelMap);
  70. }
  71. /**
  72. * 获取假期信息(根据假期类型)
  73. * @param request
  74. * @param response
  75. * @param modelMap
  76. * @throws EASBizException
  77. * @throws BOSException
  78. * @throws SHRWebException
  79. */
  80. public void getLeaveDataByTypeAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws EASBizException, BOSException, SHRWebException {
  81. Context ctx = SHRContext.getInstance().getContext();
  82. String policyId = request.getParameter("policyId");
  83. System.out.print("获取假期信息(根据假期类型):" + policyId);
  84. HolidayTypeInfo holidayInfo = HolidayTypeFactory.getLocalInstance(ctx).getHolidayTypeInfo(new ObjectUuidPK(policyId));
  85. JSONUtils.writeJson(response, holidayInfo);
  86. }
  87. /**
  88. * 校验参数查询
  89. * @param request
  90. * @param response
  91. * @param modelMap
  92. * @throws EASBizException
  93. * @throws BOSException
  94. * @throws SQLException
  95. * @throws SHRWebException
  96. */
  97. public void customerCheckParamAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SQLException, SHRWebException, EASBizException {
  98. Context ctx = SHRContext.getInstance().getContext();
  99. String personId = request.getParameter("personId");
  100. Map<String,String> returnMap = new HashMap<String,String>();
  101. // String personSql = "SELECT b.fnumber FROM t_bd_person a " +
  102. // " left join CT_MP_WorkerCategory b on a.CFWorkercategoryID = b.fid " +
  103. // " where a.fid = '" + personId + "'";
  104. String personSql = "SELECT e.fnumber FROM T_BD_Person a "
  105. + "left join (select b.fpersonid,c.CFWorkercategoryID from (SELECT FPERSONID,max(FEFFDT) as maxDate FROM T_HR_EmpOrgRelation where fassignType = '1' group by FPERSONID) b "
  106. + "left join T_HR_EmpOrgRelation c on b.fpersonid = c.fpersonid and b.maxdate=c.FEFFDT and c.fassignType = '1') d on a.fid=d.fpersonid "
  107. + "left join CT_MP_WorkerCategory e on e.fid=d.CFWorkercategoryID "
  108. + "where a.fid='"+personId+"'";
  109. System.out.print("员工类别查询:" + personSql);
  110. IRowSet rs = DbUtil.executeQuery(ctx, personSql);
  111. if(rs.next()) {
  112. returnMap.put("personType", rs.getString("fnumber"));
  113. }
  114. JSONUtils.writeJson(response, returnMap);
  115. }
  116. /**
  117. * 请假单提交工作流保存数据至新建的拆分表
  118. */
  119. @Override
  120. protected void afterSubmit(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model)
  121. throws SHRWebException {
  122. logger.info("AtsLeaveBillEditHandlerEx.....afterSubmit...start");
  123. // TODO 自动生成的方法存根
  124. super.afterSubmit(request, response, model);
  125. try {
  126. Context ctx = SHRContext.getInstance().getContext();
  127. AtsLeaveBillInfo info=(AtsLeaveBillInfo)model;
  128. logger.info("AtsLeaveBillEditHandlerEx.....number...",info.getNumber());
  129. logger.info("AtsLeaveBillEditHandlerEx.....BillID...",info.getId().toString());
  130. //先删除拆分数据
  131. if(info.getId()!=null ) {
  132. String billFormatter = "('" + info.getId().toString() + "')";
  133. AtsLeaveBillOperationUtil.deleteInfo(ctx, billFormatter);
  134. }
  135. //审批中的数据存入拆分表
  136. AtsLeaveBillOperationUtil.saveInfo(ctx, info);
  137. logger.info("AtsLeaveBillEditHandlerEx.....afterSubmit...end");
  138. }catch(Exception e) {
  139. }
  140. }
  141. }