|
@@ -28,10 +28,6 @@ import com.kingdee.eas.custom.log.app.SyncStatusEnum;
|
|
|
import com.kingdee.eas.custom.synctask.entity.AdminOrg;
|
|
|
import com.kingdee.eas.custom.synctask.entity.PersonEntity;
|
|
|
import com.kingdee.eas.custom.synctask.entity.PositionEntity;
|
|
|
-import com.kingdee.eas.hr.affair.EmpEnrollBizBillEntryCollection;
|
|
|
-import com.kingdee.eas.hr.affair.EmpEnrollBizBillEntryFactory;
|
|
|
-import com.kingdee.eas.hr.affair.EmpEnrollBizBillEntryInfo;
|
|
|
-import com.kingdee.eas.hr.affair.IEmpEnrollBizBillEntry;
|
|
|
import com.kingdee.eas.hr.ats.AtsUtil;
|
|
|
import com.kingdee.eas.hr.base.EmployeeTypeInfo;
|
|
|
import com.kingdee.eas.hr.emp.IPersonPosition;
|
|
@@ -88,7 +84,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
* @throws BOSException
|
|
|
*/
|
|
|
@Override
|
|
|
- protected void _syncOrgUnitToOA(Context ctx, String billds, ActionTypeEnum action) throws BOSException, EASBizException {
|
|
|
+ protected Map _syncOrgUnitToOA(Context ctx, String billds, ActionTypeEnum action)
|
|
|
+ throws BOSException, EASBizException {
|
|
|
ISyncLog iSyncLog = SyncLogFactory.getLocalInstance(ctx);
|
|
|
SyncLogInfo syncLogInfo = new SyncLogInfo();
|
|
|
syncLogInfo.setEntityName(SyncEntityNameEnum.adminOrg);
|
|
@@ -113,6 +110,14 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
sic.add("parent.number");
|
|
|
sic.add("responPosition.name");
|
|
|
sic.add("responPosition.number");
|
|
|
+ sic.add("bmfzr.number");
|
|
|
+ sic.add("bmfzr.name");
|
|
|
+ sic.add("bmjl.name");
|
|
|
+ sic.add("bmjl.number");
|
|
|
+ sic.add("zj.name");
|
|
|
+ sic.add("zj.number");
|
|
|
+ sic.add("fz.name");
|
|
|
+ sic.add("fz.number");
|
|
|
EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
|
|
|
AdminOrgUnitCollection adminOrgUnitCollection = iAdminOrgUnit.getAdminOrgUnitCollection(entityViewInfo);
|
|
|
for (int i = 0; i < adminOrgUnitCollection.size(); i++) {
|
|
@@ -120,12 +125,17 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
String orgName = adminOrgUnitInfo.getName();
|
|
|
AdminOrg adminOrg = new AdminOrg();
|
|
|
boolean isSealUp = adminOrgUnitInfo.isIsSealUp();
|
|
|
- if (isSealUp) {
|
|
|
+ if (action == ActionTypeEnum.DELETE) {
|
|
|
+ logger.error("_syncOrgUnitToOA---action--" + action.getValue());
|
|
|
adminOrg.setAction("delete");
|
|
|
- adminOrg.setCanceled("0");
|
|
|
} else {
|
|
|
adminOrg.setAction("add");
|
|
|
}
|
|
|
+ if (isSealUp) {
|
|
|
+ adminOrg.setCanceled("0");
|
|
|
+ } else {
|
|
|
+ adminOrg.setCanceled("1");
|
|
|
+ }
|
|
|
adminOrg.setCode(adminOrgUnitInfo.getNumber());
|
|
|
adminOrg.setShortname(orgName);
|
|
|
adminOrg.setFullname(orgName);
|
|
@@ -137,42 +147,22 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
}
|
|
|
Map map = new HashMap();
|
|
|
//部门负责人
|
|
|
- PositionInfo responPosition = adminOrgUnitInfo.getResponPosition();
|
|
|
- if (responPosition != null) {
|
|
|
- String responPositionId = responPosition.getId().toString();
|
|
|
- PersonPositionInfo personPositionInfo = getOAIDbyPostitonId(ctx, responPositionId);
|
|
|
- if (personPositionInfo != null && personPositionInfo.getPerson() != null) {
|
|
|
- map.put("bmfzr", personPositionInfo.getPerson().getName());
|
|
|
- }
|
|
|
- }
|
|
|
- //经理 总监 副总
|
|
|
- IPosition iPosition = PositionFactory.getLocalInstance(ctx);
|
|
|
- PositionCollection positionCollection = iPosition.getPositionCollection("where adminOrgUnit = '" + adminOrgUnitInfo.getId() + "'");
|
|
|
- for (int j = 0; j < positionCollection.size(); j++) {
|
|
|
- PositionInfo positionInfo = positionCollection.get(j);
|
|
|
- String positionName = positionInfo.getName();
|
|
|
- logger.error("_syncOrgUnitToOA---positionName---" + positionName);
|
|
|
- if ("经理".equals(positionName) || "总监".equals(positionName) || "副总经理".equals(positionName)) {
|
|
|
- PersonPositionInfo oaiDbyPostiton = getOAIDbyPostitonId(ctx, positionInfo.getId().toString());
|
|
|
- if (oaiDbyPostiton != null) {
|
|
|
- String personName = oaiDbyPostiton.getPerson().getName();
|
|
|
- if ("经理".equals(positionName)) {
|
|
|
- map.put("bmjl", personName);
|
|
|
- }
|
|
|
- if ("总监".equals(positionName)) {
|
|
|
- map.put("jl", personName);
|
|
|
- }
|
|
|
- if ("副总经理".equals(positionName)) {
|
|
|
- map.put("fz", personName);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- adminOrg.setCustomData(map);
|
|
|
- }
|
|
|
+ IObjectValue bmfzr = (IObjectValue) adminOrgUnitInfo.get("bmfzr");
|
|
|
+ map.put("bmfzr", bmfzr == null ? "" : bmfzr.get("name"));
|
|
|
+ //经理
|
|
|
+ IObjectValue bmjl = (IObjectValue) adminOrgUnitInfo.get("bmjl");
|
|
|
+ map.put("bmjl", bmjl == null ? "" : bmjl.get("name"));
|
|
|
+ //总监
|
|
|
+ IObjectValue zj = (IObjectValue) adminOrgUnitInfo.get("zj");
|
|
|
+ map.put("zj", zj == null ? "" : zj.get("name"));
|
|
|
+ //副总
|
|
|
+ IObjectValue fz = (IObjectValue) adminOrgUnitInfo.get("fz");
|
|
|
+ map.put("fz", fz == null ? "" : fz.get("name"));
|
|
|
+ adminOrg.setCustomData(map);
|
|
|
dataList.add(adminOrg);
|
|
|
}
|
|
|
//执行同步组织到OA
|
|
|
- executeSyncOrgUnitToOA(ctx, dataList, syncLogInfo);
|
|
|
+ return executeSyncOrgUnitToOA(ctx, dataList, syncLogInfo);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
syncLogInfo.setSyncStatus(SyncStatusEnum.ERROR);
|
|
@@ -205,7 +195,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
* @param dataList
|
|
|
* @return
|
|
|
*/
|
|
|
- public void executeSyncOrgUnitToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws
|
|
|
+ public Map executeSyncOrgUnitToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws
|
|
|
IOException, BOSException, EASBizException {
|
|
|
if (dataList != null && dataList.size() > 0) {
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
@@ -234,8 +224,9 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
.build();
|
|
|
Response response = client.newCall(request).execute();
|
|
|
//处理响应结果,写入日志
|
|
|
- handlerResponse(ctx, response, syncLogInfo);
|
|
|
+ return handlerResponse(ctx, response, syncLogInfo);
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -248,12 +239,14 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
* @throws BOSException
|
|
|
* @throws EASBizException
|
|
|
*/
|
|
|
- private void handlerResponse(Context ctx, Response response, SyncLogInfo syncLogInfo)
|
|
|
+ private Map<String, Map<String, String>> handlerResponse(Context ctx, Response response, SyncLogInfo syncLogInfo)
|
|
|
throws IOException, BOSException, EASBizException {
|
|
|
if (syncLogInfo == null) {
|
|
|
- return;
|
|
|
+ return null;
|
|
|
}
|
|
|
ISyncLog iSyncLog = SyncLogFactory.getLocalInstance(ctx);
|
|
|
+ Map<String, Map<String, String>> resultMap = new HashMap<String, Map<String, String>>();
|
|
|
+ String errorMsg = null;//错误信息
|
|
|
if (response != null) {
|
|
|
int success = 0;
|
|
|
int fail = 0;
|
|
@@ -263,37 +256,51 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
if (response.isSuccessful()) {
|
|
|
String code = respMap.getString("code");
|
|
|
if ("1".equals(code)) {
|
|
|
- JSONObject result = respMap.getJSONObject("result");
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
+ JSONObject result = respMap.getJSONObject("result");
|
|
|
for (String orgNumber : result.keySet()) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
JSONObject jsonObject = result.getJSONObject(orgNumber);
|
|
|
msg.append("[").append(orgNumber).append("]");
|
|
|
if ("1".equals(jsonObject.getString("code"))) {
|
|
|
success++;
|
|
|
+ map.put("state", "success");
|
|
|
+ map.put("msg", "同步成功");
|
|
|
msg.append("同步成功\n");
|
|
|
} else {
|
|
|
fail++;
|
|
|
+ map.put("state", "fail");
|
|
|
+ map.put("msg", jsonObject.getString("msg"));
|
|
|
msg.append("同步失败,").append(jsonObject.getString("msg")).append("\n");
|
|
|
}
|
|
|
+ resultMap.put(orgNumber, map);
|
|
|
}
|
|
|
+ int total = fail + success;
|
|
|
syncLogInfo.setSyncStatus(SyncStatusEnum.SUCCESS);
|
|
|
- syncLogInfo.setSyncCount(fail + success);
|
|
|
+ syncLogInfo.setSyncCount(total);
|
|
|
syncLogInfo.setSuccessNum(success);
|
|
|
syncLogInfo.setFailNum(fail);
|
|
|
syncLogInfo.setSyncResult(msg.toString());
|
|
|
} else {
|
|
|
syncLogInfo.setSyncStatus(SyncStatusEnum.FAIL);
|
|
|
- syncLogInfo.setSyncResult(respMap.getString("msg"));
|
|
|
+ errorMsg = respMap.getString("msg");
|
|
|
+ syncLogInfo.setSyncResult(errorMsg);
|
|
|
}
|
|
|
} else {
|
|
|
syncLogInfo.setSyncStatus(SyncStatusEnum.FAIL);
|
|
|
syncLogInfo.setSyncResult("请求超时");
|
|
|
+ errorMsg = "请求超时";
|
|
|
}
|
|
|
} else {
|
|
|
syncLogInfo.setSyncStatus(SyncStatusEnum.FAIL);
|
|
|
syncLogInfo.setSyncResult("同步数据为空");
|
|
|
+ errorMsg = "同步数据为空";
|
|
|
}
|
|
|
iSyncLog.save(syncLogInfo);
|
|
|
+ if (!StringUtils.isEmpty(errorMsg)) {
|
|
|
+ throw new BOSException(errorMsg);
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -326,7 +333,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
* @throws BOSException
|
|
|
*/
|
|
|
@Override
|
|
|
- protected void _syncPositionToOA(Context ctx, String billds, ActionTypeEnum action) throws
|
|
|
+ protected Map _syncPositionToOA(Context ctx, String billds, ActionTypeEnum action) throws
|
|
|
BOSException, EASBizException {
|
|
|
ISyncLog iSyncLog = SyncLogFactory.getLocalInstance(ctx);
|
|
|
SyncLogInfo syncLogInfo = new SyncLogInfo();
|
|
@@ -338,7 +345,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
logger.error("_syncPositionToOA---billds: " + billds);
|
|
|
String data = getPositionColData(ctx, billds);
|
|
|
String syncPositionApiUrl = this.propt.getProperty("syncPositionApiUrl");
|
|
|
- synScyRequest(ctx, data, syncPositionApiUrl, syncLogInfo);
|
|
|
+ return synScyRequest(ctx, data, syncPositionApiUrl, syncLogInfo);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
syncLogInfo.setSyncStatus(SyncStatusEnum.ERROR);
|
|
@@ -346,8 +353,6 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
iSyncLog.save(syncLogInfo);
|
|
|
throw new BOSException(e.getMessage());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -402,7 +407,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public void synScyRequest(Context ctx, String param, String aipUrl, SyncLogInfo syncLogInfo) throws
|
|
|
+ public Map synScyRequest(Context ctx, String param, String aipUrl, SyncLogInfo syncLogInfo) throws
|
|
|
IOException, BOSException, EASBizException {
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
@@ -421,7 +426,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
.build();
|
|
|
//处理响应结果,写入日志
|
|
|
Response response = client.newCall(request).execute();
|
|
|
- handlerResponse(ctx, response, syncLogInfo);
|
|
|
+ return handlerResponse(ctx, response, syncLogInfo);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -434,7 +439,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
* @throws BOSException
|
|
|
*/
|
|
|
@Override
|
|
|
- protected void _syncPersonToOA(Context ctx, String billds, ActionTypeEnum action)
|
|
|
+ protected Map _syncPersonToOA(Context ctx, String billds, ActionTypeEnum action)
|
|
|
throws BOSException, EASBizException {
|
|
|
super._syncPersonToOA(ctx, billds, action);
|
|
|
logger.error("_syncpersonToOA----------------------start");
|
|
@@ -459,6 +464,9 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
sic.add("person.number");
|
|
|
sic.add("person.name");
|
|
|
sic.add("person.id");
|
|
|
+ sic.add("person.securityLe.id");
|
|
|
+ sic.add("person.securityLe.name");
|
|
|
+ sic.add("person.securityLe.number");
|
|
|
sic.add("person.workPlace.name");
|
|
|
sic.add("person.personnelCa.name");
|
|
|
sic.add("person.immediateSu.oAid");
|
|
@@ -484,14 +492,14 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
logger.error("_syncpersonToOA------------------dataList----- " + mapper.writeValueAsString(dataList));
|
|
|
//调用执行人员组织到OA
|
|
|
- executeSyncPersonToOA(ctx, dataList, syncLogInfo);
|
|
|
+ return executeSyncPersonToOA(ctx, dataList, syncLogInfo);
|
|
|
//_syncPersonFromOAById(ctx, billds);
|
|
|
- } catch (IOException e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
syncLogInfo.setSyncStatus(SyncStatusEnum.ERROR);
|
|
|
syncLogInfo.setSyncResult(e.getMessage());
|
|
|
iSyncLog.save(syncLogInfo);
|
|
|
- throw new RuntimeException(e);
|
|
|
+ throw new BOSException(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -500,7 +508,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
*
|
|
|
* @param dataList
|
|
|
*/
|
|
|
- public void executeSyncPersonToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws
|
|
|
+ public Map executeSyncPersonToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws
|
|
|
IOException, BOSException, EASBizException {
|
|
|
if (dataList != null && dataList.size() > 0) {
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
@@ -529,9 +537,9 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
.build();
|
|
|
Response response = client.newCall(request).execute();
|
|
|
//处理响应结果,写入日志
|
|
|
- handlerResponse(ctx, response, syncLogInfo);
|
|
|
-
|
|
|
+ return handlerResponse(ctx, response, syncLogInfo);
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -578,7 +586,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
person.setLocationid((String) workPlace.get("name"));
|
|
|
}
|
|
|
//移动电话
|
|
|
- person.setMobile(personInfo.getCell());
|
|
|
+ person.setMobile(personInfo.getNCell());
|
|
|
//办公室电话
|
|
|
person.setTelephone(personInfo.getOfficePhone());
|
|
|
//电子邮件
|
|
@@ -587,6 +595,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
Date enterDate = personPositionInfo.getEnterDate();
|
|
|
if (enterDate != null) {
|
|
|
person.setCompanystartdate(originalFormat.format(enterDate));
|
|
|
+ } else {
|
|
|
+ throw new BOSException("同步人员【" + personInfo.getName() + "】 入职日期不可为空!");
|
|
|
}
|
|
|
//参加工作日期
|
|
|
Date jobStartDate = personPositionInfo.getJobStartDate();
|
|
@@ -598,13 +608,16 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
|
|
|
//明文密码,会转密文 默认:Scy$1234
|
|
|
person.setPassword("Scy$1234");
|
|
|
//安全级别
|
|
|
- person.setSeclevel("3");
|
|
|
+ IObjectValue securityLe = (IObjectValue) personInfo.get("securityLe");
|
|
|
+ if (securityLe != null) {
|
|
|
+ person.setSeclevel(securityLe.get("name").toString());
|
|
|
+ }
|
|
|
//人员类别
|
|
|
IObjectValue personnelCa = (IObjectValue) personInfo.get("personnelCa");
|
|
|
if (personnelCa != null) {
|
|
|
Map customMap = new HashMap();
|
|
|
- customMap.put("field", personnelCa.get("name"));
|
|
|
- person.setWorkCustomData(customMap);
|
|
|
+ customMap.put("field6", personnelCa.get("name"));
|
|
|
+ person.setBaseCustomData(customMap);
|
|
|
}
|
|
|
//职级
|
|
|
JobLevelInfo jobLevel = personPositionInfo.getJobLevel();
|