feat: 收票登记增加往来户供应商代码字段与手选结算组织金蝶组织派生
This commit is contained in:
+28
-2
@@ -968,6 +968,25 @@ public class KingdeeApBillSyncSupport {
|
||||
return this.kingdeeOrgNumber(contract.getProjectId(), context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 金蝶组织编码:指定部门沿部门树向上反查唯一平台公司(是否平台公司=是),取该平台公司的金蝶组织编码。
|
||||
* 先票后款链路收票登记不挂合同/项目,结算组织由页面手选部门派生(A303-2 org_number)
|
||||
*
|
||||
* @param deptId 手选部门id(收票登记 deptId)
|
||||
* @param context 金蝶同步上下文(缓存载体)
|
||||
* @return 组织编码
|
||||
*/
|
||||
public String kingdeeOrgNumberByDept(Long deptId, KingdeeSyncContext context) {
|
||||
if (deptId == null) {
|
||||
throw new ServiceException("推送金蝶失败,收票登记未选择结算组织,无法确定金蝶组织编码");
|
||||
}
|
||||
Dept dept = SysCache.getDept(deptId);
|
||||
if (dept == null) {
|
||||
throw new ServiceException("推送金蝶失败,所选结算组织[" + deptId + "]不存在,无法确定金蝶组织编码");
|
||||
}
|
||||
return this.platformCompanyOrgNumber(dept, dept.getDeptName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 金蝶组织编码:项目业务部门沿部门树向上反查唯一平台公司(是否平台公司=是),取该平台公司的金蝶组织编码;
|
||||
* 项目未关联/未维护业务部门/业务部门未归属平台公司/平台公司未维护金蝶组织编码时拦截
|
||||
@@ -978,8 +997,15 @@ public class KingdeeApBillSyncSupport {
|
||||
*/
|
||||
public String kingdeeOrgNumber(Long projectId, KingdeeSyncContext context) {
|
||||
ProjectApply project = this.requireOrgProject(projectId, context);
|
||||
// 沿部门树向上反查平台公司,上限 20 级防脏数据成环死循环
|
||||
Dept dept = SysCache.getDept(project.getBusinessDeptId());
|
||||
if (dept == null) {
|
||||
throw new ServiceException("推送金蝶失败,项目[" + Func.toStr(project.getProjectName()) + "]业务部门不存在,无法确定金蝶组织编码");
|
||||
}
|
||||
return this.platformCompanyOrgNumber(dept, project.getBusinessDeptName());
|
||||
}
|
||||
|
||||
/** 部门树向上反查平台公司金蝶组织编码(上限 20 级防脏数据成环死循环),未归属平台公司时拦截 */
|
||||
private String platformCompanyOrgNumber(Dept dept, String startDeptName) {
|
||||
for (int depth = 0; dept != null && depth < 20; depth++) {
|
||||
if (Objects.equals(dept.getIsPlatformCompany(), 1)) {
|
||||
if (Func.isBlank(dept.getKingdeeDeptCode())) {
|
||||
@@ -989,7 +1015,7 @@ public class KingdeeApBillSyncSupport {
|
||||
}
|
||||
dept = dept.getParentId() == null ? null : SysCache.getDept(dept.getParentId());
|
||||
}
|
||||
throw new ServiceException("推送金蝶失败,项目业务部门[" + Func.toStr(project.getBusinessDeptName()) + "]未归属平台公司,无法确定金蝶组织编码");
|
||||
throw new ServiceException("推送金蝶失败,部门[" + Func.toStr(startDeptName) + "]未归属平台公司,无法确定金蝶组织编码");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user