Commit 5ae1c658 authored by luzhuang's avatar luzhuang

积分小组选择部门

parent b1da7d55
......@@ -10,6 +10,7 @@ import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Set;
/**
* Created with on 2019-11-13 13:28:38.
......@@ -68,7 +69,7 @@ public interface BReleaseValueRepository extends BaseMapper<BReleaseValue> {
@Delete("<script><foreach collection=\"userId\" item=\"item\" separator=\";\">" +
" delete from b_release_value_son where user_id = #{item}" +
"</foreach></script>")
int deleteSonForUserId(@Param("userId") String[] userId);
int deleteSonForUserId(@Param("userId") Set<String> userId);
/**
* 根据releaseId删除子表中相关数据
......
......@@ -24,4 +24,7 @@ public class BReleaseValueDto {
@ApiModelProperty(value = "用户ids(用 , 隔开)")
private String userIds;
@ApiModelProperty(value = "部门ids(用 , 隔开)")
private String deptIds;
}
......@@ -71,7 +71,7 @@ public class BReleaseValueServiceImpl implements BReleaseValueService {
// 删除子表中的相关记录
bReleaseValueRepository.deleteSonForReleaseId(bReleaseValueDto.getBusinessId());
if(StringUtils.isNotEmpty(bReleaseValueDto.getUserIds())){
this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValueDto.getBusinessId());
this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValueDto.getDeptIds(),bReleaseValueDto.getBusinessId());
}
return new PersistModel(line);
}
......@@ -84,8 +84,8 @@ public class BReleaseValueServiceImpl implements BReleaseValueService {
bReleaseValue.setLessonValue(bReleaseValueDto.getLessonValue());
UserUtil.setCurrentPersistOperation(bReleaseValue);
if(StringUtils.isNotEmpty(bReleaseValueDto.getUserIds())){
this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValue.getBusinessId());
if(StringUtils.isNotEmpty(bReleaseValueDto.getUserIds()) || StringUtils.isNotEmpty(bReleaseValueDto.getDeptIds())){
this.splitUser(bReleaseValueDto.getUserIds(),bReleaseValueDto.getDeptIds(),bReleaseValue.getBusinessId());
}
int line = bReleaseValueRepository.insert(bReleaseValue);
return new PersistModel(line);
......@@ -283,17 +283,27 @@ public class BReleaseValueServiceImpl implements BReleaseValueService {
/**
* 去掉子表中已有用户信息,插入新的数据
* @param userIds
* @param deptIds
* @param businessId
*/
public void splitUser(String userIds , String businessId){
String [] ids = userIds.split(",");
public void splitUser(String userIds ,String deptIds , String businessId){
List<String> ids = new ArrayList<>();
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<>();
if(ids.length > 0){
for (String id : ids){
if(idSet.size() > 0){
for (String id : idSet){
BReleaseValueSon bReleaseValueSon = new BReleaseValueSon();
bReleaseValueSon.setBusinessId(IdGen.uuid());
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