|
@@ -2,16 +2,28 @@ 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.util.StringUtils;
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.IOException;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @author qingwu
|
|
@@ -22,11 +34,56 @@ 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 {
|
|
|
- String billIds = request.getParameter("billIds");
|
|
|
- //ͬ²½ÈËÔ±µ½OA
|
|
|
- SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(billIds, null);
|
|
|
+ public void syncPersonToOAAction(HttpServletRequest request,
|
|
|
+ HttpServletResponse response,
|
|
|
+ ModelMap modelMap) throws BOSException, EASBizException, SHRWebException {
|
|
|
+ this.handleEnableWithTips(request, "");
|
|
|
}
|
|
|
|
|
|
|
|
|
+ protected void handleEnableWithTips(HttpServletRequest request, String methodName) throws SHRWebException {
|
|
|
+ String billId = this.getBillId(request);
|
|
|
+ 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);
|
|
|
+ if (resultMap != null && resultMap.isEmpty()) {
|
|
|
+ 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;
|
|
|
+ } else {
|
|
|
+ ++failure;
|
|
|
+ body.setMuitTipsState(Boolean.FALSE);
|
|
|
+ body.setMuitTipsMessage(map.get("msg"));
|
|
|
+ }
|
|
|
+ batchMessageTipsHeader.addResult(body);
|
|
|
+ }
|
|
|
+ batchMessageTipsHeader.setBillId(billId);
|
|
|
+ batchMessageTipsHeader.setFailureCount(failure);
|
|
|
+ batchMessageTipsHeader.setSuccessCount(sucess);
|
|
|
+ request.setAttribute("res_method_data", batchMessageTipsHeader);
|
|
|
+ this.writeSuccessData(batchMessageTipsHeader);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ShrWebBizException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|