|
@@ -3,6 +3,19 @@ package nckd.jimin.jyyy.fi.business;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Collection;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.Comparator;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
+import java.util.stream.Collectors;
|
|
import kd.bos.dataentity.RefObject;
|
|
import kd.bos.dataentity.RefObject;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
@@ -21,20 +34,19 @@ import kd.fi.er.business.trip.exception.TripSyncLogParam;
|
|
import kd.fi.er.business.trip.model.TripSyncDataMappingModel;
|
|
import kd.fi.er.business.trip.model.TripSyncDataMappingModel;
|
|
import kd.fi.er.business.trip.service.function.AbstractUserInvoke;
|
|
import kd.fi.er.business.trip.service.function.AbstractUserInvoke;
|
|
import kd.fi.er.business.trip.supplier.Supplier;
|
|
import kd.fi.er.business.trip.supplier.Supplier;
|
|
-import kd.fi.er.business.trip.supplier.didi.invoke.DiDiTripUserInvoke;
|
|
|
|
import kd.fi.er.business.trip.supplier.didi.systemexternal.DiDiOrgAndUserInvokeUtil;
|
|
import kd.fi.er.business.trip.supplier.didi.systemexternal.DiDiOrgAndUserInvokeUtil;
|
|
import kd.fi.er.business.trip.supplier.didi.systemexternal.DiDiServiceUtil;
|
|
import kd.fi.er.business.trip.supplier.didi.systemexternal.DiDiServiceUtil;
|
|
-import kd.fi.er.business.trip.util.*;
|
|
|
|
|
|
+import kd.fi.er.business.trip.util.SyncUserTypeEnum;
|
|
|
|
+import kd.fi.er.business.trip.util.TripCommonUtil;
|
|
|
|
+import kd.fi.er.business.trip.util.TripSyncConfigUtil;
|
|
|
|
+import kd.fi.er.business.trip.util.TripSyncDataMappingUtil;
|
|
|
|
+import kd.fi.er.business.trip.util.UserHelper;
|
|
import kd.fi.er.business.utils.ErCommonUtils;
|
|
import kd.fi.er.business.utils.ErCommonUtils;
|
|
import kd.fi.er.business.utils.ErCostCenterUtil;
|
|
import kd.fi.er.business.utils.ErCostCenterUtil;
|
|
import kd.fi.er.business.utils.TripUserGrantUtils;
|
|
import kd.fi.er.business.utils.TripUserGrantUtils;
|
|
import kd.fi.er.common.ExternalConstants;
|
|
import kd.fi.er.common.ExternalConstants;
|
|
import kd.hrmp.hrpi.business.infrastructure.utils.QFilterUtil;
|
|
import kd.hrmp.hrpi.business.infrastructure.utils.QFilterUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
-import java.util.*;
|
|
|
|
-import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
-import java.util.stream.Collector;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 滴滴人员同步
|
|
* 滴滴人员同步
|
|
@@ -120,7 +132,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
String signKey = (String)supplierMap.get("reservedfield1");
|
|
String signKey = (String)supplierMap.get("reservedfield1");
|
|
String access_token = DiDiServiceUtil.getCacheToken(new Date());
|
|
String access_token = DiDiServiceUtil.getCacheToken(new Date());
|
|
if (access_token == null) {
|
|
if (access_token == null) {
|
|
- this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,获取滴滴token为空,请检查配置!", "DiDiTripUserInvoke_1", "fi-er-business", new Object[0]));
|
|
|
|
|
|
+ this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,获取滴滴Token为空,请检查配置。", "DiDiTripUserInvoke_1", "fi-er-business", new Object[0]));
|
|
this.tripSyncLogParam.setStatus("B");
|
|
this.tripSyncLogParam.setStatus("B");
|
|
return null;
|
|
return null;
|
|
} else {
|
|
} else {
|
|
@@ -139,7 +151,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
} else {
|
|
} else {
|
|
SyncUserTypeEnum userTypeEnum = UserHelper.getSyncType(map);
|
|
SyncUserTypeEnum userTypeEnum = UserHelper.getSyncType(map);
|
|
if (pageIndex == 1 && userTypeEnum != SyncUserTypeEnum.SYNC_BY_USER) {
|
|
if (pageIndex == 1 && userTypeEnum != SyncUserTypeEnum.SYNC_BY_USER) {
|
|
- this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,全量更新,人员为空,请检查人员信息!", "DiDiTripUserInvoke_0", "fi-er-business", new Object[0]));
|
|
|
|
|
|
+ this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,全量更新,人员为空,请检查人员信息。", "DiDiTripUserInvoke_0", "fi-er-business", new Object[0]));
|
|
}
|
|
}
|
|
|
|
|
|
return null;
|
|
return null;
|
|
@@ -157,6 +169,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
userDataJsonObject.put("realname", name);
|
|
userDataJsonObject.put("realname", name);
|
|
userDataJsonObject.put("employee_number", number);
|
|
userDataJsonObject.put("employee_number", number);
|
|
|
|
|
|
|
|
+ //二开逻辑,增加base地
|
|
String baseCity = getBaseCity(number.toString());
|
|
String baseCity = getBaseCity(number.toString());
|
|
userDataJsonObject.put("residentsname", baseCity);
|
|
userDataJsonObject.put("residentsname", baseCity);
|
|
|
|
|
|
@@ -190,6 +203,10 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
|
|
|
|
JSONObject extJson = new JSONObject();
|
|
JSONObject extJson = new JSONObject();
|
|
extJson.put("deptId", dptId);
|
|
extJson.put("deptId", dptId);
|
|
|
|
+
|
|
|
|
+ //二开逻辑,增加参数【客户部门CODE】
|
|
|
|
+ extJson.put("out_budget_id", dptId);
|
|
|
|
+
|
|
if (null != companyId) {
|
|
if (null != companyId) {
|
|
extJson.put("companyId", companyId);
|
|
extJson.put("companyId", companyId);
|
|
}
|
|
}
|
|
@@ -259,6 +276,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
userDataJsonObject.put("realname", name);
|
|
userDataJsonObject.put("realname", name);
|
|
userDataJsonObject.put("employee_number", number);
|
|
userDataJsonObject.put("employee_number", number);
|
|
|
|
|
|
|
|
+ //二开逻辑,增加base地
|
|
String baseCity = getBaseCity(number.toString());
|
|
String baseCity = getBaseCity(number.toString());
|
|
userDataJsonObject.put("residentsname", baseCity);
|
|
userDataJsonObject.put("residentsname", baseCity);
|
|
|
|
|
|
@@ -294,48 +312,6 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
delUserList.add(delUserObj);
|
|
delUserList.add(delUserObj);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取base地
|
|
|
|
- * @param employeeNumber
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private String getBaseCity(Object employeeNumber){
|
|
|
|
- String baseCity = "";
|
|
|
|
-
|
|
|
|
- if (employeeNumber != null) {
|
|
|
|
- QFilter statusFilter = QFilterUtil.getCurrentQf();
|
|
|
|
- statusFilter.and(QFilterUtil.getDataStatusFilter());
|
|
|
|
-
|
|
|
|
- QFilter qFilter = new QFilter("number", "=", employeeNumber);
|
|
|
|
- qFilter.and(statusFilter);
|
|
|
|
-
|
|
|
|
- DynamicObject hrPerson = BusinessDataServiceHelper.loadSingleFromCache("hrpi_person", "id", qFilter.toArray());
|
|
|
|
- if (hrPerson == null) {
|
|
|
|
- logger.info("根据员工number未获取到HR人员基本信息{}", employeeNumber);
|
|
|
|
- return "";
|
|
|
|
- }
|
|
|
|
- if(hrPerson != null){
|
|
|
|
- DynamicObject baseLocation = QueryServiceHelper.queryOne("hrpi_baselocation", "location.city.id", new QFilter[]{
|
|
|
|
- new QFilter("person", QCP.equals, hrPerson.getLong("id")),
|
|
|
|
- new QFilter("iscurrentversion", QCP.equals, Boolean.TRUE)
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- if(baseLocation != null){
|
|
|
|
- Long cityId = baseLocation.getLong("location.city.id");
|
|
|
|
- DynamicObject admind = QueryServiceHelper.queryOne("bd_admindivision", "name",
|
|
|
|
- new QFilter("id", QCP.equals, cityId).toArray());
|
|
|
|
- // 查询行政区划名称
|
|
|
|
- if(admind != null) {
|
|
|
|
- baseCity = admind.getString("name");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- logger.info("未获取到员工{}", employeeNumber);
|
|
|
|
- }
|
|
|
|
- return baseCity;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private Map<String, JSONArray> getChangedUserMap(String changeTime, Integer pageIndex, Integer pageSize, Map<Object, Object> dataOrgMappingMap, Map<String, Object> map) {
|
|
private Map<String, JSONArray> getChangedUserMap(String changeTime, Integer pageIndex, Integer pageSize, Map<Object, Object> dataOrgMappingMap, Map<String, Object> map) {
|
|
Date changeDate = TripCommonUtil.convertToDate(changeTime);
|
|
Date changeDate = TripCommonUtil.convertToDate(changeTime);
|
|
List<Map<String, Object>> userChangeInfos = UserHelper.getUserInfosByTimeNew(pageIndex, pageSize, changeDate, map);
|
|
List<Map<String, Object>> userChangeInfos = UserHelper.getUserInfosByTimeNew(pageIndex, pageSize, changeDate, map);
|
|
@@ -392,6 +368,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ new ArrayList();
|
|
JSONArray delUserList = new JSONArray();
|
|
JSONArray delUserList = new JSONArray();
|
|
List<Map<String, Object>> delUserChangeInfos = (List)maxTimeUserChangeInfos.stream().filter((userChangeDO) -> {
|
|
List<Map<String, Object>> delUserChangeInfos = (List)maxTimeUserChangeInfos.stream().filter((userChangeDO) -> {
|
|
return userChangeDO.get("number") != null && (null != userChangeDO.get("enable") && "0".equals(userChangeDO.get("enable").toString()) || null != userChangeDO.get("isforbidden") && "true".equals(userChangeDO.get("isforbidden").toString()));
|
|
return userChangeDO.get("number") != null && (null != userChangeDO.get("enable") && "0".equals(userChangeDO.get("enable").toString()) || null != userChangeDO.get("isforbidden") && "true".equals(userChangeDO.get("isforbidden").toString()));
|
|
@@ -440,7 +417,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
return postUserMap;
|
|
return postUserMap;
|
|
} else {
|
|
} else {
|
|
if (pageIndex == 1) {
|
|
if (pageIndex == 1) {
|
|
- this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空!", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
|
|
|
|
|
|
+ this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空。", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
|
|
}
|
|
}
|
|
|
|
|
|
return null;
|
|
return null;
|
|
@@ -460,7 +437,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
String url = "";
|
|
String url = "";
|
|
switch (syncKey) {
|
|
switch (syncKey) {
|
|
case "add":
|
|
case "add":
|
|
- url = (String) ExternalConstants.DIDIURLMAP.get("memberSingleKey");
|
|
|
|
|
|
+ url = (String)ExternalConstants.DIDIURLMAP.get("memberSingleKey");
|
|
break;
|
|
break;
|
|
case "edit":
|
|
case "edit":
|
|
url = (String)ExternalConstants.DIDIURLMAP.get("memberEditKey");
|
|
url = (String)ExternalConstants.DIDIURLMAP.get("memberEditKey");
|
|
@@ -498,7 +475,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
code = "300";
|
|
code = "300";
|
|
}
|
|
}
|
|
|
|
|
|
- this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空!", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
|
|
|
|
|
|
+ this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空。", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
|
|
return code;
|
|
return code;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -514,34 +491,46 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
switch (paramValue) {
|
|
switch (paramValue) {
|
|
case 0:
|
|
case 0:
|
|
case 2:
|
|
case 2:
|
|
- budgetCenterId = dataOrgMappingMap.get(dptId);
|
|
|
|
|
|
+ budgetCenterId = dataOrgMappingMap.get(Long.parseLong(dptId.toString()));
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
- DynamicObject userInfo = BusinessDataServiceHelper.loadSingle("bos_user", "id,number,entryentity.dpt,entryentity.ispartjob,entryentity.id", new QFilter[]{new QFilter("id", "=", Long.parseLong(userId.toString()))});
|
|
|
|
- if (userInfo != null) {
|
|
|
|
- DynamicObjectCollection entryEntity = userInfo.getDynamicObjectCollection("entryentity");
|
|
|
|
- int size = entryEntity.size();
|
|
|
|
-
|
|
|
|
- for(int i = 0; i < size; ++i) {
|
|
|
|
- DynamicObject dynamicObject = (DynamicObject)entryEntity.get(i);
|
|
|
|
- boolean ispartjob = dynamicObject.getBoolean("ispartjob");
|
|
|
|
- if (!ispartjob) {
|
|
|
|
- Long id = ErCommonUtils.getPk(dynamicObject.get("dpt"));
|
|
|
|
- Long companyId = CoreBaseBillServiceHelper.initCompanyByDept(id);
|
|
|
|
- budgetCenterId = dataOrgMappingMap.get(companyId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ budgetCenterId = defaultDeal(dataOrgMappingMap, userId, budgetCenterId);
|
|
break;
|
|
break;
|
|
case 3:
|
|
case 3:
|
|
Long accountOrgId = CoreBaseBillServiceHelper.getAccountOrgId(Long.parseLong(dptId.toString()));
|
|
Long accountOrgId = CoreBaseBillServiceHelper.getAccountOrgId(Long.parseLong(dptId.toString()));
|
|
- budgetCenterId = dataOrgMappingMap.get(accountOrgId);
|
|
|
|
|
|
+ if (accountOrgId == null) {
|
|
|
|
+ defaultDeal(dataOrgMappingMap, userId, budgetCenterId);
|
|
|
|
+ } else {
|
|
|
|
+ budgetCenterId = dataOrgMappingMap.get(accountOrgId);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
userDataJsonObject.put("budget_center_id", budgetCenterId);
|
|
userDataJsonObject.put("budget_center_id", budgetCenterId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static Object defaultDeal(Map<Object, Object> dataOrgMappingMap, Object userId, Object budgetCenterId) {
|
|
|
|
+ DynamicObject userInfo = BusinessDataServiceHelper.loadSingle("bos_user", "id,number,entryentity.dpt,entryentity.ispartjob,entryentity.id", new QFilter[]{new QFilter("id", "=", Long.parseLong(userId.toString()))});
|
|
|
|
+ if (userInfo == null) {
|
|
|
|
+ return budgetCenterId;
|
|
|
|
+ } else {
|
|
|
|
+ DynamicObjectCollection entryEntity = userInfo.getDynamicObjectCollection("entryentity");
|
|
|
|
+ int size = entryEntity.size();
|
|
|
|
+
|
|
|
|
+ for(int i = 0; i < size; ++i) {
|
|
|
|
+ DynamicObject dynamicObject = (DynamicObject)entryEntity.get(i);
|
|
|
|
+ boolean ispartjob = dynamicObject.getBoolean("ispartjob");
|
|
|
|
+ if (!ispartjob) {
|
|
|
|
+ Long id = ErCommonUtils.getPk(dynamicObject.get("dpt"));
|
|
|
|
+ Long companyId = CoreBaseBillServiceHelper.initCompanyByDept(id);
|
|
|
|
+ budgetCenterId = dataOrgMappingMap.get(companyId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return budgetCenterId;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private Integer getUseCompanyMoney() {
|
|
private Integer getUseCompanyMoney() {
|
|
return TripSyncConfigUtil.getBoolean("dtrip_use_company_money") ? 1 : 0;
|
|
return TripSyncConfigUtil.getBoolean("dtrip_use_company_money") ? 1 : 0;
|
|
}
|
|
}
|
|
@@ -591,5 +580,47 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取base地,二开方法
|
|
|
|
+ * @param employeeNumber
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String getBaseCity(Object employeeNumber){
|
|
|
|
+ String baseCity = "";
|
|
|
|
+
|
|
|
|
+ if (employeeNumber != null) {
|
|
|
|
+ QFilter statusFilter = QFilterUtil.getCurrentQf();
|
|
|
|
+ statusFilter.and(QFilterUtil.getDataStatusFilter());
|
|
|
|
+
|
|
|
|
+ QFilter qFilter = new QFilter("number", "=", employeeNumber);
|
|
|
|
+ qFilter.and(statusFilter);
|
|
|
|
+
|
|
|
|
+ DynamicObject hrPerson = BusinessDataServiceHelper.loadSingleFromCache("hrpi_person", "id", qFilter.toArray());
|
|
|
|
+ if (hrPerson == null) {
|
|
|
|
+ logger.info("根据员工number未获取到HR人员基本信息{}", employeeNumber);
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ if(hrPerson != null){
|
|
|
|
+ DynamicObject baseLocation = QueryServiceHelper.queryOne("hrpi_baselocation", "location.city.id", new QFilter[]{
|
|
|
|
+ new QFilter("person", QCP.equals, hrPerson.getLong("id")),
|
|
|
|
+ new QFilter("iscurrentversion", QCP.equals, Boolean.TRUE)
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if(baseLocation != null){
|
|
|
|
+ Long cityId = baseLocation.getLong("location.city.id");
|
|
|
|
+ DynamicObject admind = QueryServiceHelper.queryOne("bd_admindivision", "name",
|
|
|
|
+ new QFilter("id", QCP.equals, cityId).toArray());
|
|
|
|
+ // 查询行政区划名称
|
|
|
|
+ if(admind != null) {
|
|
|
|
+ baseCity = admind.getString("name");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ logger.info("未获取到员工{}", employeeNumber);
|
|
|
|
+ }
|
|
|
|
+ return baseCity;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|