🐛 OA部门同步名称改用departmentmark,名称不一致时强制更新

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-21 13:57:32 +08:00
parent 46f79fce3a
commit 2ef110d5e4
2 changed files with 15 additions and 6 deletions
@@ -49,8 +49,8 @@ public interface DeptConvert {
@Mapping(source = "modified", target = "oaModified")
Dept baseConvert(OACompanyResponse company);
@Mapping(source = "departmentname", target = "deptName")
@Mapping(source = "departmentmark", target = "fullName")
@Mapping(source = "departmentmark", target = "deptName")
@Mapping(source = "departmentname", target = "fullName")
@Mapping(source = "supdepid", target = "parentCode")
@Mapping(source = "subcompanyid1", target = "belongCompanyCode")
@Mapping(source = "created", target = "createTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
@@ -761,7 +761,7 @@ public class OASyncServiceImpl implements IOASyncService {
.filter(oaDept -> syncAll
|| rootCompanyId == null
|| !rootCompanyId.equals(oaDept.getSubcompanyid1())
|| (OAConstant.ROOT_COMPANY_ID.equals(oaDept.getSupdepid()) && rootCompanyDeptNames.contains(oaDept.getDepartmentname())))
|| (OAConstant.ROOT_COMPANY_ID.equals(oaDept.getSupdepid()) && rootCompanyDeptNames.contains(oaDept.getDepartmentmark())))
.map(dept -> deptConvert.dept2dept(dept, companyByOaId))
.toList();
int filteredSkipCount = oaDepts.size() - allParam.size();
@@ -921,8 +921,9 @@ public class OASyncServiceImpl implements IOASyncService {
.eq(Dept::getDeptCategory, deptCategory.getCode())
.isNotNull(Dept::getOaId)
.ne(Dept::getOaId, "")
.select(Dept::getId, Dept::getDeptCode, Dept::getOaModified, Dept::getParentId,
Dept::getOaId, Dept::getBelongCompanyCode, Dept::getParentCode, Dept::getOaSupSubComId));
.select(Dept::getId, Dept::getDeptCode, Dept::getDeptName, Dept::getFullName,
Dept::getOaModified, Dept::getParentId, Dept::getOaId, Dept::getBelongCompanyCode,
Dept::getParentCode, Dept::getOaSupSubComId));
Map<String, Dept> byOaId = new HashMap<>();
for (Dept dept : deptList) {
if (StringUtils.isNotBlank(dept.getOaId())) {
@@ -1047,7 +1048,7 @@ public class OASyncServiceImpl implements IOASyncService {
/**
* oaModified 一致则跳过更新;任一侧为空无法确认一致,执行更新以补齐字段。
* 组织编码已按新规则重算、或父子挂载与库中不一致时,即使 modified 相同也要更新。
* 组织编码已按新规则重算、父子挂载不一致、或名称字段与当前映射不一致时,即使 modified 相同也要更新。
*/
private boolean shouldSkipOaUpdate(Dept existing, Dept incoming) {
if (existing == null) {
@@ -1066,6 +1067,14 @@ public class OASyncServiceImpl implements IOASyncService {
StringUtils.trimToEmpty(incoming.getParentCode()))) {
return false;
}
if (incoming != null && !StringUtils.equals(StringUtils.trimToEmpty(existing.getDeptName()),
StringUtils.trimToEmpty(incoming.getDeptName()))) {
return false;
}
if (incoming != null && !StringUtils.equals(StringUtils.trimToEmpty(existing.getFullName()),
StringUtils.trimToEmpty(incoming.getFullName()))) {
return false;
}
String localModified = StringUtils.trimToEmpty(existing.getOaModified());
String remoteModified = StringUtils.trimToEmpty(incoming == null ? null : incoming.getOaModified());
if (localModified.isEmpty() || remoteModified.isEmpty()) {