123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- package com.kingdee.eas.custom.synctask.handler;
- import com.kingdee.bos.BOSException;
- import com.kingdee.bos.Context;
- import com.kingdee.eas.basedata.person.IPerson;
- import com.kingdee.eas.basedata.person.PersonCollection;
- import com.kingdee.eas.basedata.person.PersonFactory;
- import com.kingdee.eas.basedata.person.PersonInfo;
- import com.kingdee.eas.common.EASBizException;
- import com.kingdee.eas.custom.synctask.SyncTranForOAFacadeFactory;
- import com.kingdee.eas.framework.ICoreBase;
- import com.kingdee.eas.hr.ats.AtsUtil;
- import com.kingdee.eas.hr.emp.web.handler.EmployeeListHandler;
- import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsBody;
- import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsHeader;
- import com.kingdee.shr.base.syssetting.context.SHRContext;
- import com.kingdee.shr.base.syssetting.exception.SHRWebException;
- import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
- import com.kingdee.shr.base.syssetting.ml.SHRWebResource;
- import com.kingdee.util.StringUtils;
- import org.apache.log4j.Logger;
- import org.springframework.ui.ModelMap;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.util.Enumeration;
- import java.util.Map;
- /**
- * @author qingwu
- * @date 2024/10/24
- * @apiNote 员工信息维护扩展
- */
- public class EmployeeListHandlerEx extends EmployeeListHandler {
- public static Logger logger = Logger.getLogger(EmployeeListHandlerEx.class);
- private Context ctx = SHRContext.getInstance().getContext();
- public void syncPersonToOAAction(HttpServletRequest request,
- HttpServletResponse response,
- ModelMap modelMap) throws BOSException, EASBizException, SHRWebException {
- Enumeration<String> headerNames = request.getHeaderNames();
- while (headerNames.hasMoreElements()) {
- String headerName = headerNames.nextElement();
- String headerValue = request.getHeader(headerName);
- logger.error("----headerNames------key【" + headerName + "】-value【 " + headerValue + "】");
- }
- Enumeration enu = request.getParameterNames();
- while (enu.hasMoreElements()) {
- String paraName = (String) enu.nextElement();
- logger.error("----ParameterNames------key【" + paraName + "】-value【 " + request.getParameter(paraName) + "】");
- }
- //String billId = request.getParameter("billId[]");
- ////}
- //if (StringUtils.isEmpty(billId)) {
- // billId = (String) request.getAttribute("billId[]");
- //}
- //if (StringUtils.isEmpty(billId)) {
- // billId = request.getParameter("billIds[]");
- //}
- //if (StringUtils.isEmpty(billId)) {
- // billId = (String) request.getAttribute("billIds[]");
- //}
- //logger.error("----headerNames------billId----" + billId);
- this.handleEnableWithTips(request, "");
- }
- protected void handleEnableWithTips(HttpServletRequest request, String methodName) throws SHRWebException {
- //String billId = this.getBillId(request);
- //if (StringUtils.isEmpty(billId)) {
- String billId = request.getParameter("billId");
- //}
- if (StringUtils.isEmpty(billId)) {
- billId = (String) request.getAttribute("billId");
- }
- if (StringUtils.isEmpty(billId)) {
- billId = request.getParameter("billIds[]");
- }
- if (StringUtils.isEmpty(billId)) {
- billId = (String) request.getAttribute("billId[]");
- }
- try {
- IPerson iPerson = PersonFactory.getLocalInstance(ctx);
- if (StringUtils.isEmpty(billId)) {
- PersonCollection personCollection = iPerson.getPersonCollection("select id");
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < personCollection.size(); i++) {
- String personId = personCollection.get(i).getId().toString();
- sb.append(personId).append(",");
- }
- sb.deleteCharAt(sb.lastIndexOf(","));
- }
- Map<String, Map<String, String>> resultMap = SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(billId, null);
- logger.error("handleEnableWithTips----- resultMap----" + resultMap);
- if (resultMap != null && !resultMap.isEmpty()) {
- logger.error("handleEnableWithTips----- start ");
- PersonCollection personCollection = iPerson.getPersonCollection("select id,number where id in (" + AtsUtil.getStrFromString(billId) + ")");
- int sucess = 0;
- int failure = 0;
- BatchMessageTipsHeader batchMessageTipsHeader = new BatchMessageTipsHeader();
- for (int i = 0; i < personCollection.size(); i++) {
- BatchMessageTipsBody body = new BatchMessageTipsBody();
- PersonInfo personInfo = personCollection.get(i);
- body.setId(personInfo.getId().toString());
- String personNumber = personInfo.getNumber();
- Map<String, String> map = resultMap.get(personNumber);
- if ("success".equals(map.get("state"))) {
- ++sucess;
- body.setMuitTipsState(Boolean.TRUE);
- body.setMuitTipsMessage(map.get("msg"));
- } else {
- ++failure;
- body.setMuitTipsState(Boolean.FALSE);
- body.setMuitTipsMessage(map.get("msg"));
- }
- batchMessageTipsHeader.addResult(body);
- }
- logger.error("handleEnableWithTips----- >> ");
- batchMessageTipsHeader.setBillId(billId);
- batchMessageTipsHeader.setFailureCount(failure);
- batchMessageTipsHeader.setSuccessCount(sucess);
- logger.error("batchMessageTipsHeader " + batchMessageTipsHeader.getSuccessCount());
- request.setAttribute("res_method_data", batchMessageTipsHeader);
- this.writeSuccessData(batchMessageTipsHeader);
- logger.error("handleEnableWithTips----- end ");
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new ShrWebBizException(e);
- }
- }
- }
|