|
@@ -56,15 +56,28 @@ public class ApisaveDemoPlugin implements ApiSavePlugin {
|
|
|
String orgNumber = orgControlInfo.getString("nckd_org_number");
|
|
|
|
|
|
if (orgId.equals(deptId)) {
|
|
|
- // 如果组织 ID 和部门 ID 相同,则都设置为组织编号
|
|
|
- org.put("id", getOrg(orgNumber));
|
|
|
- dept.put("id", getOrg(orgNumber));
|
|
|
+ // 行政组织id
|
|
|
+ Long id = getOrg(orgNumber);
|
|
|
+ Long fromorgId = getRelation(id);
|
|
|
+ if (id != null) {
|
|
|
+ dept.put("id", id);
|
|
|
+ }
|
|
|
+ if (fromorgId != null) {
|
|
|
+ org.put("id", fromorgId);
|
|
|
+ }
|
|
|
} else if (orgControlInfo.getString("nckd_e_org").equals(orgId)) {
|
|
|
- // 如果当前控制信息的组织 ID 等于 orgId,更新组织 ID
|
|
|
- org.put("id", getOrg(orgNumber));
|
|
|
+ // 行政组织id
|
|
|
+ Long id = getOrg(orgNumber);
|
|
|
+ Long fromorgId = getRelation(id);
|
|
|
+ if (fromorgId != null) {
|
|
|
+ org.put("id", fromorgId);
|
|
|
+ }
|
|
|
} else {
|
|
|
// 否则更新部门 ID
|
|
|
- dept.put("id", getOrg(orgNumber));
|
|
|
+ Long id = getOrg(orgNumber);
|
|
|
+ if (id != null) {
|
|
|
+ dept.put("id", id);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -83,4 +96,23 @@ public class ApisaveDemoPlugin implements ApiSavePlugin {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description 查询业务单元id
|
|
|
+ * @param id
|
|
|
+ * @return Long
|
|
|
+ */
|
|
|
+ private Long getRelation(Long id) {
|
|
|
+
|
|
|
+ QFilter filter = new QFilter("toorg", QCP.equals,id);
|
|
|
+ DynamicObject[] org = BusinessDataServiceHelper.load("bos_org_orgrelation_dept","id",new QFilter[] {filter});
|
|
|
+ if (org.length > 0) {
|
|
|
+ DynamicObject orgInfo = BusinessDataServiceHelper.loadSingle(org[0].getPkValue(), org[0].getDynamicObjectType().getName());
|
|
|
+ DynamicObject ywdyOrg = orgInfo.getDynamicObject("fromorg");
|
|
|
+ if (ywdyOrg != null) {
|
|
|
+ return ywdyOrg.getLong("id");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|