|
@@ -49,6 +49,7 @@ import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -622,11 +623,17 @@ public class SysDeptController {
|
|
|
return R.failed("deptIds必填");
|
|
|
}
|
|
|
|
|
|
- if (CollUtil.isEmpty(cmsUserIds)) {
|
|
|
- // 删除关联关系
|
|
|
- sysDeptCsmMapper.delete(Wrappers.<SysDeptCsm>lambdaUpdate()
|
|
|
- .in(SysDeptCsm::getDeptId, deptIds));
|
|
|
- } else {
|
|
|
+ Map<Integer, SysDeptCsm> deptCsmMap = new HashMap<>();
|
|
|
+ List<SysDeptCsm> sysDeptCsms = sysDeptCsmMapper.listDistinctUserCsm(cmsUserIds);
|
|
|
+ if (CollUtil.isNotEmpty(sysDeptCsms)) {
|
|
|
+ deptCsmMap.putAll(sysDeptCsms.stream().collect(Collectors.toMap(SysDeptCsm::getUserId, Function.identity())));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除关联关系
|
|
|
+ sysDeptCsmMapper.delete(Wrappers.<SysDeptCsm>lambdaUpdate()
|
|
|
+ .in(SysDeptCsm::getDeptId, deptIds));
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(cmsUserIds)) {
|
|
|
// 建立关联关系
|
|
|
deptIds.forEach(deptId -> {
|
|
|
cmsUserIds.forEach(userId -> {
|
|
@@ -639,8 +646,15 @@ public class SysDeptController {
|
|
|
insert.setDeptId(deptId);
|
|
|
insert.setUserId(userId);
|
|
|
insert.setCsmName(user.getRealname());
|
|
|
- insert.setQrCodeId(" ");
|
|
|
- insert.setCorpId(" ");
|
|
|
+ SysDeptCsm sysDeptCsm = deptCsmMap.get(userId);
|
|
|
+ if (sysDeptCsm == null) {
|
|
|
+ insert.setQrCodeId(" ");
|
|
|
+ insert.setCorpId(" ");
|
|
|
+ } else {
|
|
|
+ // 复制该csm的原有配置信息
|
|
|
+ insert.setQrCodeId(StrUtil.isNotBlank(sysDeptCsm.getQrCodeId()) ? sysDeptCsm.getQrCodeId() : " ");
|
|
|
+ insert.setCorpId(StrUtil.isNotBlank(sysDeptCsm.getCorpId()) ? sysDeptCsm.getQrCodeId() : " ");
|
|
|
+ }
|
|
|
sysDeptCsmMapper.insert(insert);
|
|
|
}
|
|
|
});
|