Commit 5ae1c658 authored by luzhuang's avatar luzhuang

积分小组选择部门

parent b1da7d55
...@@ -10,6 +10,7 @@ import org.springframework.stereotype.Repository; ...@@ -10,6 +10,7 @@ import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* Created with on 2019-11-13 13:28:38. * Created with on 2019-11-13 13:28:38.
...@@ -68,7 +69,7 @@ public interface BReleaseValueRepository extends BaseMapper<BReleaseValue> { ...@@ -68,7 +69,7 @@ public interface BReleaseValueRepository extends BaseMapper<BReleaseValue> {
@Delete("<script><foreach collection=\"userId\" item=\"item\" separator=\";\">" + @Delete("<script><foreach collection=\"userId\" item=\"item\" separator=\";\">" +
" delete from b_release_value_son where user_id = #{item}" + " delete from b_release_value_son where user_id = #{item}" +
"</foreach></script>") "</foreach></script>")
int deleteSonForUserId(@Param("userId") String[] userId); int deleteSonForUserId(@Param("userId") Set<String> userId);
/** /**
* 根据releaseId删除子表中相关数据 * 根据releaseId删除子表中相关数据
......
...@@ -24,4 +24,7 @@ public class BReleaseValueDto { ...@@ -24,4 +24,7 @@ public class BReleaseValueDto {
@ApiModelProperty(value = "用户ids(用 , 隔开)") @ApiModelProperty(value = "用户ids(用 , 隔开)")
private String userIds; private String userIds;
@ApiModelProperty(value = "部门ids(用 , 隔开)")
private String deptIds;
} }
...@@ -71,7 +71,7 @@ public class BReleaseValueServiceImpl implements BReleaseValueService { ...@@ -71,7 +71,7 @@ public class BReleaseValueServiceImpl implements BReleaseValueService {
// 删除子表中的相关记录 // 删除子表中的相关记录
bReleaseValueRepository.deleteSonForReleaseId(bReleaseValueDto.getBusinessId()); bReleaseValueRepository.deleteSonForReleaseId(bReleaseValueDto.getBusinessId());
if(StringUtils.isNotEmpty(bReleaseValueDto.getUserIds())){ if(StringUtils.isNotEmpty(bReleaseValueDto.getUserIds())){
this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValueDto.getBusinessId()); this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValueDto.getDeptIds(),bReleaseValueDto.getBusinessId());
} }
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -84,8 +84,8 @@ public class BReleaseValueServiceImpl implements BReleaseValueService { ...@@ -84,8 +84,8 @@ public class BReleaseValueServiceImpl implements BReleaseValueService {
bReleaseValue.setLessonValue(bReleaseValueDto.getLessonValue()); bReleaseValue.setLessonValue(bReleaseValueDto.getLessonValue());
UserUtil.setCurrentPersistOperation(bReleaseValue); UserUtil.setCurrentPersistOperation(bReleaseValue);
if(StringUtils.isNotEmpty(bReleaseValueDto.getUserIds())){ if(StringUtils.isNotEmpty(bReleaseValueDto.getUserIds()) || StringUtils.isNotEmpty(bReleaseValueDto.getDeptIds())){
this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValue.getBusinessId()); this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValueDto.getDeptIds(),bReleaseValue.getBusinessId());
} }
int line = bReleaseValueRepository.insert(bReleaseValue); int line = bReleaseValueRepository.insert(bReleaseValue);
return new PersistModel(line); return new PersistModel(line);
...@@ -283,17 +283,27 @@ public class BReleaseValueServiceImpl implements BReleaseValueService { ...@@ -283,17 +283,27 @@ public class BReleaseValueServiceImpl implements BReleaseValueService {
/** /**
* 去掉子表中已有用户信息,插入新的数据 * 去掉子表中已有用户信息,插入新的数据
* @param userIds * @param userIds
* @param deptIds
* @param businessId * @param businessId
*/ */
public void splitUser(String userIds , String businessId){ public void splitUser(String userIds ,String deptIds , String businessId){
List<String> ids = new ArrayList<>();
String [] ids = userIds.split(","); if(StringUtils.isNotEmpty(userIds)){
ids.addAll(Arrays.asList(userIds.split(",")));
}
if(StringUtils.isNotEmpty(deptIds)){
List<String> deptList = Arrays.asList(deptIds.split(","));
Set<String> deptSets = new HashSet<>(deptList);
List<String> data = mtCotactApiRequestClient.getSubUserIdsByDeptIds(UserUtil.getCurUser().getCorpId(), deptSets);
ids.addAll(data);
}
Set<String> idSet = new HashSet<>(ids);
// 删除子表中与当前选中用户相关的信息 // 删除子表中与当前选中用户相关的信息
bReleaseValueRepository.deleteSonForUserId(ids); bReleaseValueRepository.deleteSonForUserId(idSet);
//将关联信息插入子表 //将关联信息插入子表
List<BReleaseValueSon> list = new ArrayList<>(); List<BReleaseValueSon> list = new ArrayList<>();
if(ids.length > 0){ if(idSet.size() > 0){
for (String id : ids){ for (String id : idSet){
BReleaseValueSon bReleaseValueSon = new BReleaseValueSon(); BReleaseValueSon bReleaseValueSon = new BReleaseValueSon();
bReleaseValueSon.setBusinessId(IdGen.uuid()); bReleaseValueSon.setBusinessId(IdGen.uuid());
bReleaseValueSon.setReleaseId(businessId); bReleaseValueSon.setReleaseId(businessId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment