|
|
@@ -13,20 +13,41 @@ import com.kingdee.eas.custom.beisen.utils.Helper;
|
|
|
import com.kingdee.eas.util.app.DbUtil;
|
|
|
import com.kingdee.jdbc.rowset.IRowSet;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URISyntaxException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.sql.SQLException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+/**
|
|
|
+ * 编制同步
|
|
|
+ * description: SynchronousPosOSFService <br>
|
|
|
+ * date: 2025/7/11 17:46 <br>
|
|
|
+ * author: lhbj <br>
|
|
|
+ * version: 1.0 <br>
|
|
|
+ */
|
|
|
public class SyncStaffManageOSFService implements IHRMsfService {
|
|
|
|
|
|
|
|
|
+ public Map<String,List<Map<String,Object>>> orgProcess(Context context,List<Map<String,Object>> orgListMap) throws IOException, URISyntaxException {
|
|
|
+ return new StaffManageProcess().orgProcess(context,orgListMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String,List<Map<String,Object>>> posProcess(Context context,List<Map<String,Object>> posListMap) throws IOException, URISyntaxException {
|
|
|
+ return new StaffManageProcess().posProcess(context,posListMap);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Object process(Context context, Map<String, Object> map) throws EASBizException, BOSException {
|
|
|
+ String mack = (String) map.get("mack");
|
|
|
+
|
|
|
Map<String,List<Map<String,Object>>> result = Maps.newHashMap();
|
|
|
List<Map<String,Object>> list = Lists.newArrayList();
|
|
|
List<Map<String,Object>> listMap = Lists.newArrayList();
|
|
|
+ List<Map<String,Object>> orgListMap = Lists.newArrayList();
|
|
|
+ List<Map<String,Object>> posListMap = Lists.newArrayList();
|
|
|
result.put("list",list);
|
|
|
result.put("listMap",listMap);
|
|
|
String posPath = (String) map.get("posPath");
|
|
|
@@ -43,8 +64,6 @@ public class SyncStaffManageOSFService implements IHRMsfService {
|
|
|
sql.append(" and FChannel = 1 ");
|
|
|
IRowSet rs = DbUtil.executeQuery(context, sql.toString());
|
|
|
try{
|
|
|
- BeiSenUtils b = new BeiSenUtils(context);
|
|
|
- Helper helper = b.helper;
|
|
|
BeisenParamByPropertiesUtil posUtil = new BeisenParamByPropertiesUtil(posPath);
|
|
|
Map<String,String> poskeyMap = posUtil.getConfig();
|
|
|
BeisenParamByPropertiesUtil orgUtil = new BeisenParamByPropertiesUtil(orgPath);
|
|
|
@@ -55,28 +74,30 @@ public class SyncStaffManageOSFService implements IHRMsfService {
|
|
|
String FYear = rs.getString("FYear");
|
|
|
StringBuilder selSql = new StringBuilder();
|
|
|
selSql.append(" select * from ( ");
|
|
|
- selSql.append(" select 'org' orgpos,org.fid posId,org.fname_l2 orgPosName,org.FDisplayName_L2 staffName, ");
|
|
|
+ selSql.append(" select 'org' orgpos,org.fid posId,org.Fnumber orgOriginalId,org.FParentID,org.fname_l2 orgPosName,org.FDisplayName_L2 staffName, ");
|
|
|
selSql.append(" org.fid CFOriginalId,(case when staff.FControlWay=0 then 3 when staff.FControlWay=1 then 2 else 1 end) FControlWay, ");
|
|
|
selSql.append(" staff.FPersonCount,staff.FStaffYear,staff.FYearActualStart, ");
|
|
|
selSql.append(" staff.FOnWayAddCount,staff.FOnWaySubCount, ");
|
|
|
selSql.append(" (staff.FStaffYear-staff.FOnWayAddCount+staff.FOnWaySubCount-staff.FPersonCount) FStaffYearUsable, ");
|
|
|
- selSql.append(" (staff.FState+1) FState,staff.FContainSub ");
|
|
|
+ selSql.append(" (staff.FState+1) FState,staff.FContainSub, ");
|
|
|
+ selSql.append(" 1 orgPosStatus ");
|
|
|
selSql.append(" from ");
|
|
|
selSql.append(" "+FTableName+" staff ");
|
|
|
selSql.append(" left join t_org_admin org on org.fid=staff.FAdminOrgID ");
|
|
|
selSql.append(" left join t_org_position pos on pos.fid = staff.FpositionID ");
|
|
|
selSql.append(" where pos.fid is null and org.FReserveFieldFirst is not null ");
|
|
|
selSql.append(" UNION all ");
|
|
|
- selSql.append(" select 'pos' orgpos,pos.fid posId,pos.fname_l2 orgPosName,org.FDisplayName_L2 staffName,pos.CFOriginalId, ");
|
|
|
+ selSql.append(" select 'pos' orgpos,pos.fid posId,org.FreserveFieldFirst orgOriginalId,pos.FParentID,pos.fname_l2 orgPosName,org.FDisplayName_L2 staffName,pos.CFOriginalId, ");
|
|
|
selSql.append(" (case when staff.FControlWay=0 then 3 when staff.FControlWay=1 then 2 else 1 end) FControlWay, ");
|
|
|
selSql.append(" staff.FPersonCount,staff.FStaffYear,staff.FYearActualStart, ");
|
|
|
selSql.append(" staff.FOnWayAddCount,staff.FOnWaySubCount, ");
|
|
|
selSql.append(" (staff.FStaffYear-staff.FOnWayAddCount+staff.FOnWaySubCount-staff.FPersonCount) FStaffYearUsable, ");
|
|
|
- selSql.append(" (staff.FState+1) FState,staff.FContainSub ");
|
|
|
+ selSql.append(" (staff.FState+1) FState,staff.FContainSub, ");
|
|
|
+ selSql.append(" (case when pos.FDELETEDSTATUS=2 then 0 else 1 end) orgPosStatus ");
|
|
|
selSql.append(" from ");
|
|
|
selSql.append(" "+FTableName+" staff ");
|
|
|
- selSql.append(" left join t_org_admin org on org.fid=staff.FAdminOrgID ");
|
|
|
selSql.append(" left join t_org_position pos on pos.fid = staff.FpositionID ");
|
|
|
+ selSql.append(" left join t_org_admin org on org.fid=pos.FADMINORGUNITID ");
|
|
|
selSql.append(" where pos.fid is not null and pos.CFOriginalId is not null ");
|
|
|
selSql.append(" ) t order by t.FContainSub desc ");
|
|
|
IRowSet rsSel = DbUtil.executeQuery(context, selSql.toString());
|
|
|
@@ -84,57 +105,38 @@ public class SyncStaffManageOSFService implements IHRMsfService {
|
|
|
|
|
|
while (rsSel.next()){
|
|
|
String orgpos= rsSel.getString("orgpos");
|
|
|
-
|
|
|
- String token = b.getAccessToken();
|
|
|
if("org".equals(orgpos)){
|
|
|
Map<String, Object> pos = this.getPostData(orgkeyMap,rsSel);
|
|
|
-
|
|
|
if(null!=pos){
|
|
|
- // 若访问令牌不为空且开始时间和结束时间不为空
|
|
|
- if (!com.kingdee.util.StringUtils.isEmpty(token)) {
|
|
|
- // 创建请求头的 Map
|
|
|
- Map<String, String> header = new HashMap<String, String>();
|
|
|
- // 设置请求头的 Content-Type
|
|
|
- header.put("Content-Type", "application/json");
|
|
|
- // 设置请求头的 Authorization
|
|
|
- header.put("Authorization", "Bearer " + token);
|
|
|
- String url = "https://openapi.italent.cn/UserFrameworkApiV3/api/v1/departments/Put?originalId="+ URLEncoder.encode((String) pos.get("id"),"UTF-8");
|
|
|
-
|
|
|
- JSONObject requestBody = new JSONObject(pos);
|
|
|
- System.out.println("url:"+url);
|
|
|
- System.out.println("requestBody:"+requestBody);
|
|
|
- JSONObject responseJson = helper.getURL(url,header, requestBody, "PUT",requestBody.getString("posId"),"更新","北森");
|
|
|
- System.out.println("responseJson:"+responseJson);
|
|
|
- listMap.add(responseJson);
|
|
|
- list.add(pos);
|
|
|
- }
|
|
|
+ orgListMap.add(pos);
|
|
|
}
|
|
|
}else if ("pos".equals(orgpos)){
|
|
|
Map<String, Object> pos = this.getPostData(poskeyMap,rsSel);
|
|
|
if(null!=pos){
|
|
|
- // 若访问令牌不为空且开始时间和结束时间不为空
|
|
|
- if (!com.kingdee.util.StringUtils.isEmpty(token)) {
|
|
|
- // 创建请求头的 Map
|
|
|
- Map<String, String> header = new HashMap<String, String>();
|
|
|
- // 设置请求头的 Content-Type
|
|
|
- header.put("Content-Type", "application/json");
|
|
|
- // 设置请求头的 Authorization
|
|
|
- header.put("Authorization", "Bearer " + token);
|
|
|
- String url = "https://openapi.italent.cn/RecruitV6/api/v1/RecruitOnBoarding/UpdatePost";
|
|
|
- JSONObject requestBody = new JSONObject(pos);
|
|
|
- System.out.println("url:"+url);
|
|
|
- System.out.println("requestBody:"+requestBody);
|
|
|
- JSONObject responseJson = helper.getURL(url,header, requestBody, "PUT",requestBody.getString("posId"),"更新","北森");
|
|
|
- System.out.println("responseJson:"+responseJson);
|
|
|
- listMap.add(responseJson);
|
|
|
- list.add(pos);
|
|
|
- }
|
|
|
+ posListMap.add(pos);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if("org".equals(mack)||"pos".equals(mack)){
|
|
|
+ //Map<String,List<Map<String,Object>>> resultOrg = this.orgProcess(context,orgListMap);
|
|
|
+ result.put("orgListMap",orgListMap);
|
|
|
+ result.put("posListMap",posListMap);
|
|
|
+ } else {
|
|
|
+ result.put("orgListMap",orgListMap);
|
|
|
+ result.put("posListMap",posListMap);
|
|
|
+ Map<String,List<Map<String,Object>>> resultOrg = this.orgProcess(context,orgListMap);
|
|
|
+ Map<String,List<Map<String,Object>>> resultPos = this.posProcess(context,posListMap);
|
|
|
+ list.addAll(resultOrg.get("list"));
|
|
|
+ listMap.addAll(resultOrg.get("listMap"));
|
|
|
+ list.addAll(resultPos.get("list"));
|
|
|
+ listMap.addAll(resultPos.get("listMap"));
|
|
|
+ result.put("orgListMap",orgListMap);
|
|
|
+ result.put("posListMap",posListMap);
|
|
|
+ }
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
+ throw new BOSException(e);
|
|
|
}finally {
|
|
|
|
|
|
}
|
|
|
@@ -240,4 +242,6 @@ public class SyncStaffManageOSFService implements IHRMsfService {
|
|
|
}
|
|
|
return pos;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|