EmployeeListHandlerEx.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package com.kingdee.eas.custom.synctask.handler;
  2. import com.kingdee.bos.BOSException;
  3. import com.kingdee.bos.Context;
  4. import com.kingdee.eas.basedata.person.IPerson;
  5. import com.kingdee.eas.basedata.person.PersonCollection;
  6. import com.kingdee.eas.basedata.person.PersonFactory;
  7. import com.kingdee.eas.basedata.person.PersonInfo;
  8. import com.kingdee.eas.common.EASBizException;
  9. import com.kingdee.eas.custom.synctask.SyncTranForOAFacadeFactory;
  10. import com.kingdee.eas.framework.ICoreBase;
  11. import com.kingdee.eas.hr.ats.AtsUtil;
  12. import com.kingdee.eas.hr.emp.web.handler.EmployeeListHandler;
  13. import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsBody;
  14. import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsHeader;
  15. import com.kingdee.shr.base.syssetting.context.SHRContext;
  16. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  17. import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
  18. import com.kingdee.shr.base.syssetting.ml.SHRWebResource;
  19. import com.kingdee.util.StringUtils;
  20. import org.apache.log4j.Logger;
  21. import org.springframework.ui.ModelMap;
  22. import javax.servlet.http.HttpServletRequest;
  23. import javax.servlet.http.HttpServletResponse;
  24. import java.util.Enumeration;
  25. import java.util.Map;
  26. /**
  27. * @author qingwu
  28. * @date 2024/10/24
  29. * @apiNote 员工信息维护扩展
  30. */
  31. public class EmployeeListHandlerEx extends EmployeeListHandler {
  32. public static Logger logger = Logger.getLogger(EmployeeListHandlerEx.class);
  33. private Context ctx = SHRContext.getInstance().getContext();
  34. public void syncPersonToOAAction(HttpServletRequest request,
  35. HttpServletResponse response,
  36. ModelMap modelMap) throws BOSException, EASBizException, SHRWebException {
  37. Enumeration<String> headerNames = request.getHeaderNames();
  38. while (headerNames.hasMoreElements()) {
  39. String headerName = headerNames.nextElement();
  40. String headerValue = request.getHeader(headerName);
  41. logger.error("----headerNames------key【" + headerName + "】-value【 " + headerValue + "】");
  42. }
  43. Enumeration enu = request.getParameterNames();
  44. while (enu.hasMoreElements()) {
  45. String paraName = (String) enu.nextElement();
  46. logger.error("----ParameterNames------key【" + paraName + "】-value【 " + request.getParameter(paraName) + "】");
  47. }
  48. //String billId = request.getParameter("billId[]");
  49. ////}
  50. //if (StringUtils.isEmpty(billId)) {
  51. // billId = (String) request.getAttribute("billId[]");
  52. //}
  53. //if (StringUtils.isEmpty(billId)) {
  54. // billId = request.getParameter("billIds[]");
  55. //}
  56. //if (StringUtils.isEmpty(billId)) {
  57. // billId = (String) request.getAttribute("billIds[]");
  58. //}
  59. //logger.error("----headerNames------billId----" + billId);
  60. this.handleEnableWithTips(request, "");
  61. }
  62. protected void handleEnableWithTips(HttpServletRequest request, String methodName) throws SHRWebException {
  63. //String billId = this.getBillId(request);
  64. //if (StringUtils.isEmpty(billId)) {
  65. String billId = request.getParameter("billId");
  66. //}
  67. if (StringUtils.isEmpty(billId)) {
  68. billId = (String) request.getAttribute("billId");
  69. }
  70. if (StringUtils.isEmpty(billId)) {
  71. billId = request.getParameter("billIds[]");
  72. }
  73. if (StringUtils.isEmpty(billId)) {
  74. billId = (String) request.getAttribute("billId[]");
  75. }
  76. try {
  77. IPerson iPerson = PersonFactory.getLocalInstance(ctx);
  78. if (StringUtils.isEmpty(billId)) {
  79. PersonCollection personCollection = iPerson.getPersonCollection("select id");
  80. StringBuilder sb = new StringBuilder();
  81. for (int i = 0; i < personCollection.size(); i++) {
  82. String personId = personCollection.get(i).getId().toString();
  83. sb.append(personId).append(",");
  84. }
  85. sb.deleteCharAt(sb.lastIndexOf(","));
  86. }
  87. Map<String, Map<String, String>> resultMap = SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(billId, null);
  88. logger.error("handleEnableWithTips----- resultMap----" + resultMap);
  89. if (resultMap != null && !resultMap.isEmpty()) {
  90. logger.error("handleEnableWithTips----- start ");
  91. PersonCollection personCollection = iPerson.getPersonCollection("select id,number where id in (" + AtsUtil.getStrFromString(billId) + ")");
  92. int sucess = 0;
  93. int failure = 0;
  94. BatchMessageTipsHeader batchMessageTipsHeader = new BatchMessageTipsHeader();
  95. for (int i = 0; i < personCollection.size(); i++) {
  96. BatchMessageTipsBody body = new BatchMessageTipsBody();
  97. PersonInfo personInfo = personCollection.get(i);
  98. body.setId(personInfo.getId().toString());
  99. String personNumber = personInfo.getNumber();
  100. Map<String, String> map = resultMap.get(personNumber);
  101. if ("success".equals(map.get("state"))) {
  102. ++sucess;
  103. body.setMuitTipsState(Boolean.TRUE);
  104. body.setMuitTipsMessage(map.get("msg"));
  105. } else {
  106. ++failure;
  107. body.setMuitTipsState(Boolean.FALSE);
  108. body.setMuitTipsMessage(map.get("msg"));
  109. }
  110. batchMessageTipsHeader.addResult(body);
  111. }
  112. logger.error("handleEnableWithTips----- >> ");
  113. batchMessageTipsHeader.setBillId(billId);
  114. batchMessageTipsHeader.setFailureCount(failure);
  115. batchMessageTipsHeader.setSuccessCount(sucess);
  116. logger.error("batchMessageTipsHeader " + batchMessageTipsHeader.getSuccessCount());
  117. request.setAttribute("res_method_data", batchMessageTipsHeader);
  118. this.writeSuccessData(batchMessageTipsHeader);
  119. logger.error("handleEnableWithTips----- end ");
  120. }
  121. } catch (Exception e) {
  122. e.printStackTrace();
  123. throw new ShrWebBizException(e);
  124. }
  125. }
  126. }