|
@@ -39,6 +39,7 @@ import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.function.BiConsumer;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -431,11 +432,19 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
//报名人数
|
|
|
int totalUserNum = userStrList.size();
|
|
|
BigDecimal applyNum = new BigDecimal(totalUserNum + "");
|
|
|
+ //修改修改关系表 imGroup
|
|
|
+ BiConsumer<String, List<String>> updateGroup = (groupId, list) -> tempLittleArtistTrainingCampUserRelationService.update(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaUpdate()
|
|
|
+ .set(TempLittleArtistTrainingCampUserRelation::getImGroupId, groupId)
|
|
|
+ .eq(TempLittleArtistTrainingCampUserRelation::getActivityId, camp.getId())
|
|
|
+ .in(TempLittleArtistTrainingCampUserRelation::getUserId, list)
|
|
|
+ .isNull(TempLittleArtistTrainingCampUserRelation::getImGroupId));
|
|
|
//如果人数小于最大人数 则直接分组
|
|
|
if (maxUserNum.intValue() >= applyNum.intValue()) {
|
|
|
//分组
|
|
|
String groupId = imGroupService.createGroup(userStrList, camp.getName() + "-1群", groupType);
|
|
|
imGroupIds.add(groupId);
|
|
|
+ //修改关系表
|
|
|
+ updateGroup.accept(groupId, userStrList);
|
|
|
} else {
|
|
|
//分组数 ->报名人数 ➗ 每组最大人数 有小数就向上取整 1.01 -> 2
|
|
|
BigDecimal groupNum = applyNum.divide(maxUserNum, 0, RoundingMode.UP);
|
|
@@ -447,12 +456,8 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
AtomicInteger i = new AtomicInteger(1);
|
|
|
partition.forEach(list -> {
|
|
|
String groupId = imGroupService.createGroup(list, camp.getName() + "-" + i.get() + "群", groupType);
|
|
|
- //修改
|
|
|
- tempLittleArtistTrainingCampUserRelationService.update(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaUpdate()
|
|
|
- .set(TempLittleArtistTrainingCampUserRelation::getImGroupId, groupId)
|
|
|
- .eq(TempLittleArtistTrainingCampUserRelation::getActivityId, camp.getId())
|
|
|
- .in(TempLittleArtistTrainingCampUserRelation::getUserId, list)
|
|
|
- .isNull(TempLittleArtistTrainingCampUserRelation::getImGroupId));
|
|
|
+ updateGroup.accept(groupId, list);
|
|
|
+ //修改关系表
|
|
|
imGroupIds.add(groupId);
|
|
|
i.getAndIncrement();
|
|
|
});
|
|
@@ -471,12 +476,12 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
|
|
|
public void pushStartTrain() {
|
|
|
//查询学员id 对应的训练营名称
|
|
|
List<BaseVo> baseVos = baseMapper.queryStartTrainInfo(LocalDate.now().toString());
|
|
|
- if(CollectionUtils.isEmpty(baseVos)){
|
|
|
+ if (CollectionUtils.isEmpty(baseVos)) {
|
|
|
return;
|
|
|
}
|
|
|
Map<String, List<BaseVo>> pushUserList = WrapperUtil.groupList(baseVos, BaseVo::getName);
|
|
|
pushUserList.forEach((imGroupName, list) -> {
|
|
|
- Map<Integer, String> push= new HashMap<>();
|
|
|
+ Map<Integer, String> push = new HashMap<>();
|
|
|
for (BaseVo obj : list) {
|
|
|
push.put(obj.getId(), obj.getId().toString());
|
|
|
}
|