FullOrgUnitInfo m = (FullOrgUnitInfo) iter.next();
boolean isBizUnit = false;
if (m.isIsLeaf()) {
isBizUnit = true;
}
CostCenterOrgUnitInfo parentCostCenter = new CostCenterOrgUnitInfo();
parentCostCenter.setId(m.getParent().getId());
AdminOrgUnitInfo parentAdmin = new AdminOrgUnitInfo();
parentAdmin.setId(m.getParent().getId());
parentAdmin.setCU(m.getParent().getCU());
// CompanyOrgUnitInfo companyInfo = DbDataSyncBean.getTopCompany(ctx);
// m.setOrgTypeStr(m.getOrgTypeStr() + ";CostCenter;");
BizParentAndDelegateInfo delValue = new BizParentAndDelegateInfo();
delValue.setParentOrg(OrgType.CostCenter, parentCostCenter);
OrgUnitRelationCollection delegateCol = delValue.getDelegateCollection();
if (m.getParent() != null) {
OrgUnitRelationInfo costDelegateFIInfo = new OrgUnitRelationInfo();
costDelegateFIInfo.setFromUnit(m);
costDelegateFIInfo.setToUnit(m.getParent());
costDelegateFIInfo.put("fromType", OrgType.CostCenter);
costDelegateFIInfo.put("toType", OrgType.Company);
delegateCol.add(costDelegateFIInfo);
}
delValue.setParentOrg(OrgType.Admin, parentAdmin);
if (m.getParent() != null) {
OrgUnitRelationInfo adminDelegateFIInfo = new OrgUnitRelationInfo();
adminDelegateFIInfo.setFromUnit(m);
adminDelegateFIInfo.setToUnit(m.getParent());
adminDelegateFIInfo.put("fromType", OrgType.Admin);
adminDelegateFIInfo.put("toType", OrgType.Company);
delegateCol.add(adminDelegateFIInfo);
}
if (m.isIsCompanyOrgUnit()) {
CompanyOrgUnitInfo parentCompany = new CompanyOrgUnitInfo();
parentCompany.setId(m.getParent().getId());
delValue.setParentOrg(OrgType.Company, parentCompany);
}
m.put(BizParentAndDelegateInfo.KEY, delValue);
// 补充保存成本中心
OUPartCostCenterInfo existCc = m.getPartCostCenter();
if (existCc == null) {
if (m.get("costCenter") == null) {
// 新增记录时,设置成本中心打勾
m.setIsCostOrgUnit(true);
CostCenterOrgUnitInfo ccInfo = new CostCenterOrgUnitInfo();
// 辅助生产部门
ccInfo.setCostCenterType(CostCenterType.AssistantProdDept);
// 上级成本中心
ccInfo.setParent(parentCostCenter);
// 实体成本中心
ccInfo.setIsBizUnit(true);
if (isBizUnit) {
// 需要设置记账委托财务组织 bizPromptCostDelegateFI
// ccInfo.setCostCenterType(item)
}
m.put("costCenter", ccInfo);
}
OUPartCostCenterInfo partInfo = new OUPartCostCenterInfo();
// 辅助生产部门
partInfo.setCostCenterType(CostCenterType.AssistantProdDept);
// 上级成本中心
// partInfo.setParent(parentCostCenter);
// 实体成本中心
partInfo.setIsBizUnit(isBizUnit);
partInfo.setUnit(m.getParent());
m.put("partCostCenter", partInfo);
} else if (isBizUnit && existCc.getUnit() == null) {
// 设置记账委托财务组织
existCc.setIsBizUnit(isBizUnit);
existCc.setUnit(m.getParent());
}
// 补充保存成本中心
OUPartAdminInfo existAdmin = m.getPartAdmin();
if (existAdmin == null) {
} else if (existAdmin.getUnit() == null) {
// 设置记账委托财务组织
existAdmin.setUnit(m.getParent());
}
FullOrgUnitFactory.getLocalInstance(ctx).submit(m);