|
|
@@ -39,6 +39,7 @@ import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
|
import org.springblade.manager.feign.ProjectAssignmentUserClient;
|
|
|
+import org.springblade.manager.feign.SaveUserInfoByProjectClient;
|
|
|
import org.springblade.manager.vo.PrivateTreeVO;
|
|
|
import org.springblade.manager.vo.PrivateTreeVO2;
|
|
|
import org.springblade.manager.vo.WbsTreeContractLazyQueryInfoVO;
|
|
|
@@ -129,6 +130,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
StringRedisTemplate redisTemplate;
|
|
|
+ @Autowired
|
|
|
+ private SaveUserInfoByProjectClient saveUserInfoByProjectClient;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -2797,20 +2800,96 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
- //不是新增的项目 但是是新增的合同段
|
|
|
-
|
|
|
- //不是新增的项目 但是新增了合同段其中的老合同段
|
|
|
+ // 现在已经存在的contractIds
|
|
|
+ List<String> existContractIds = projectAssignmentUsers.stream().map(p -> p.getContractId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 本次模板导入的contractIds
|
|
|
+ String contractId = userImporterNew.getContractId();
|
|
|
+ List<String> contractIds = Arrays.asList(contractId.split(","));
|
|
|
+
|
|
|
+ // 处理逗号分隔的contractId,去除空格并过滤空值
|
|
|
+ List<String> processedContractIds = contractIds.stream()
|
|
|
+ .map(String::trim)
|
|
|
+ .filter(id -> !id.isEmpty())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 转换existContractIds为Set以提高查找效率
|
|
|
+ Set<String> existContractIdSet = existContractIds.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(String::trim)
|
|
|
+ .filter(id -> !id.isEmpty())
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ // 1. 本次模板导入的contractIds和existContractIds完全一模一样的情况
|
|
|
+ boolean isExactlySame = processedContractIds.size() == existContractIdSet.size()
|
|
|
+ && processedContractIds.stream().allMatch(existContractIdSet::contains);
|
|
|
+ if(isExactlySame){
|
|
|
+ //修改角色
|
|
|
+ user.setRoleId(user.getRoleId()+","+userImporterNew.getRoleId());
|
|
|
+ user.setStatus("是".equals(userImporterNew.getStatus()) ? 1 : 0);
|
|
|
+ updateUserList.add(user);
|
|
|
+ for (SaveUserInfoByProjectDTO dto : projectAssignmentUsers) {
|
|
|
+ dto.setRoleId(user.getRoleId());
|
|
|
+ updateUserInfoByProjectList.add(dto);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ user.setRoleId(user.getRoleId()+","+userImporterNew.getRoleId());
|
|
|
+ user.setStatus("是".equals(userImporterNew.getStatus()) ? 1 : 0);
|
|
|
+ updateUserList.add(user);
|
|
|
+ // 2. 本次导入的contractIds和existContractIds相对比 新增的部分 (存在新增的情况下)
|
|
|
+ List<String> newContractIds = processedContractIds.stream()
|
|
|
+ .filter(id -> !existContractIdSet.contains(id))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(!newContractIds.isEmpty()){
|
|
|
+ for (String cId : newContractIds) {
|
|
|
+ SaveUserInfoByProjectDTO dto = new SaveUserInfoByProjectDTO();
|
|
|
+ dto.setId(SnowFlakeUtil.getId());
|
|
|
+ dto.setProjectId(userImporterNew.getProjectId());
|
|
|
+ dto.setContractId(cId);
|
|
|
+ dto.setRoleId(user.getRoleId());
|
|
|
+ dto.setUserId(user.getId()+"");
|
|
|
+ dto.setStatus(1);
|
|
|
+ insertUserInfoByProjectList.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 3. 本次导入的contractIds和existContractIds相对比 相同的部分 (存在相同的情况下)
|
|
|
+ List<String> sameContractIds = processedContractIds.stream()
|
|
|
+ .filter(existContractIdSet::contains)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(!sameContractIds.isEmpty()){
|
|
|
+ for (String sameContractId : sameContractIds) {
|
|
|
+ for (SaveUserInfoByProjectDTO dto : projectAssignmentUsers) {
|
|
|
+ if(dto.getContractId().equals(sameContractId)){
|
|
|
+ dto.setRoleId(user.getRoleId());
|
|
|
+ updateUserInfoByProjectList.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //不是新增的项目 也没有新增的合同段
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ if(!insertUserList.isEmpty()){
|
|
|
+ this.saveBatch(insertUserList);
|
|
|
+ }
|
|
|
+ if(!insertUserDeptList.isEmpty()){
|
|
|
+ userDeptService.saveBatch(insertUserDeptList);
|
|
|
+ }
|
|
|
+ if(!insertUserInfoByProjectList.isEmpty()){
|
|
|
+ saveUserInfoByProjectClient.insertUserInfoBatch(insertUserInfoByProjectList);
|
|
|
+ }
|
|
|
+ if(!updateUserList.isEmpty()){
|
|
|
+ this.updateBatchById(updateUserList);
|
|
|
+ }
|
|
|
+ if(!updateUserInfoByProjectList.isEmpty()){
|
|
|
+ saveUserInfoByProjectClient.updateUserInfoBatch(updateUserInfoByProjectList);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return R.fail("导入失败:" + e.getMessage());
|