Browse Source

修改确认参加接口

tags/24080901
WendyYang 1 year ago
parent
commit
7a2fa84220
10 changed files with 94 additions and 30 deletions
  1. +2
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/controller/MeetingController.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/AppointInviteRuleDTO.java
  3. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/BatchAppointExpertsReq.java
  4. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/ExpertConfirmReq.java
  5. +1
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertInviteHelper.java
  6. +6
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java
  7. +37
    -14
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java
  8. +24
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IExpertInviteRuleService.java
  9. +13
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/ExpertInviteRuleServiceImpl.java
  10. +6
    -4
      pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java

+ 2
- 3
pmapi/src/main/java/com/ningdatech/pmapi/meeting/controller/MeetingController.java View File

@@ -123,8 +123,8 @@ public class MeetingController {
return meetingManage.expertInvitationDetail(meetingId, expertId); return meetingManage.expertInvitationDetail(meetingId, expertId);
} }


@ApiOperation("批量补充专家")
@PostMapping("batchAppointExperts")
@ApiOperation("补充专家(指定抽取)")
@PostMapping("/expert/batchAppoint")
@WebLog(value = "批量补充专家") @WebLog(value = "批量补充专家")
public void batchAppointExperts(@Valid @RequestBody BatchAppointExpertsReq po) { public void batchAppointExperts(@Valid @RequestBody BatchAppointExpertsReq po) {
meetingManage.batchAppointExperts(po); meetingManage.batchAppointExperts(po);
@@ -158,5 +158,4 @@ public class MeetingController {
meetingManage.confirmedRoster(req.getMeetingId()); meetingManage.confirmedRoster(req.getMeetingId());
} }



} }

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/AppointInviteRuleDTO.java View File

@@ -29,6 +29,6 @@ public class AppointInviteRuleDTO extends AbstractInviteRule {


@NotEmpty(message = "专家ID不能为空", groups = {RuleSave.class, CountCheck.class}) @NotEmpty(message = "专家ID不能为空", groups = {RuleSave.class, CountCheck.class})
@ApiModelProperty("专家ID") @ApiModelProperty("专家ID")
private List<Long> expertIds;
private List<Long> expertIdList;


} }

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/BatchAppointExpertsReq.java View File

@@ -22,7 +22,7 @@ public class BatchAppointExpertsReq {


@NotEmpty(message = "专家ID不能为空") @NotEmpty(message = "专家ID不能为空")
@ApiModelProperty("专家ID") @ApiModelProperty("专家ID")
private List<Long> expertIds;
private List<Long> expertIdList;


@NotNull(message = "会议ID不能为空") @NotNull(message = "会议ID不能为空")
@ApiModelProperty("会议ID") @ApiModelProperty("会议ID")


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/ExpertConfirmReq.java View File

@@ -26,4 +26,7 @@ public class ExpertConfirmReq {
@ApiModelProperty("专家会议ID") @ApiModelProperty("专家会议ID")
private Long expertMeetingId; private Long expertMeetingId;


@ApiModelProperty("是否确认参加会议")
private Boolean agreed;

} }

+ 1
- 2
pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertInviteHelper.java View File

@@ -13,7 +13,6 @@ import com.ningdatech.pmapi.meeting.entity.dto.AbstractInviteRule;
import com.ningdatech.pmapi.meeting.entity.dto.AppointInviteRuleDTO; import com.ningdatech.pmapi.meeting.entity.dto.AppointInviteRuleDTO;
import com.ningdatech.pmapi.meeting.entity.dto.AvoidInfoDTO; import com.ningdatech.pmapi.meeting.entity.dto.AvoidInfoDTO;
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum;
import com.ningdatech.pmapi.meeting.entity.enumeration.MeetingStatusEnum;
import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; import com.ningdatech.pmapi.meeting.service.IMeetingExpertService;
import com.ningdatech.pmapi.meeting.service.IMeetingService; import com.ningdatech.pmapi.meeting.service.IMeetingService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -85,7 +84,7 @@ public class ExpertInviteHelper {
if (appointRule == null) { if (appointRule == null) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
List<ExpertUserFullInfo> expertInfos = expertUserFullInfoService.listByUserId(appointRule.getExpertIds());
List<ExpertUserFullInfo> expertInfos = expertUserFullInfoService.listByUserId(appointRule.getExpertIdList());
return CollUtils.listToMap(expertInfos, ExpertUserFullInfo::getUserId); return CollUtils.listToMap(expertInfos, ExpertUserFullInfo::getUserId);
} }




+ 6
- 4
pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java View File

@@ -28,7 +28,10 @@ import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;


import java.util.*;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;


/** /**
* <p> * <p>
@@ -157,13 +160,12 @@ public class MeetingManageHelper {
public List<ExpertUserFullInfo> appointExpertCheck(Long meetingId, List<Long> expertIds) { public List<ExpertUserFullInfo> appointExpertCheck(Long meetingId, List<Long> expertIds) {
List<ExpertUserFullInfo> experts = expertUserFullInfoService.listByUserId(expertIds); List<ExpertUserFullInfo> experts = expertUserFullInfoService.listByUserId(expertIds);
AvoidInfoDTO avoidRule = getAvoidInfoDto(meetingId); AvoidInfoDTO avoidRule = getAvoidInfoDto(meetingId);
Map<String, Integer> countMap = new HashMap<>(16);
experts.forEach(expert -> { experts.forEach(expert -> {
if (avoidRule.getAvoidUnitIdList().contains(expert.getCompany())) { if (avoidRule.getAvoidUnitIdList().contains(expert.getCompany())) {
throw BizException.wrap("回避单位的专家不可出现在指定邀请名单中");
throw BizException.wrap("请移除已回避单位的专家");
} }
if (CollectionUtils.isNotEmpty(avoidRule.getExpertIds()) && avoidRule.getExpertIds().contains(expert.getUserId())) { if (CollectionUtils.isNotEmpty(avoidRule.getExpertIds()) && avoidRule.getExpertIds().contains(expert.getUserId())) {
throw BizException.wrap("已回避的专家不可被指定邀请");
throw BizException.wrap("请移除已回避的专家");
} }
// 校验专家状态 // 校验专家状态
ExpertAccountStatusEnum accountStatus = ExpertAccountStatusEnum.of(expert.getExpertAccountStatus()); ExpertAccountStatusEnum accountStatus = ExpertAccountStatusEnum.of(expert.getExpertAccountStatus());


+ 37
- 14
pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java View File

@@ -102,6 +102,7 @@ public class MeetingManage {
throw BizException.wrap("会议正在创建中"); throw BizException.wrap("会议正在创建中");
} }
try { try {
ExpertInviteReq inviteRule = req.getExpertInviteRule();
// 保存会议基本信息 // 保存会议基本信息
Meeting meeting = BeanUtil.copyProperties(meetingBasic, Meeting.class); Meeting meeting = BeanUtil.copyProperties(meetingBasic, Meeting.class);
meeting.setStatus(MeetingStatusEnum.NORMAL.getCode()); meeting.setStatus(MeetingStatusEnum.NORMAL.getCode());
@@ -112,6 +113,7 @@ public class MeetingManage {
meeting.setCreator(userDetail.getUsername()); meeting.setCreator(userDetail.getUsername());
meeting.setInviteStopped(Boolean.FALSE); meeting.setInviteStopped(Boolean.FALSE);
meeting.setConfirmedRoster(Boolean.FALSE); meeting.setConfirmedRoster(Boolean.FALSE);
meeting.setInviteType(inviteRule.getInviteType());
meetingService.save(meeting); meetingService.save(meeting);
if (meetingBasic.getIsInnerProject()) { if (meetingBasic.getIsInnerProject()) {
List<MeetingInnerProject> projects = meetingBasic.getProjectIdList().stream().map(w -> { List<MeetingInnerProject> projects = meetingBasic.getProjectIdList().stream().map(w -> {
@@ -131,7 +133,7 @@ public class MeetingManage {
} }
// 抽取专家 // 抽取专家
req.getExpertInviteRule().setMeetingId(meeting.getId()); req.getExpertInviteRule().setMeetingId(meeting.getId());
expertInviteByCreate(req.getExpertInviteRule());
expertInviteByCreate(inviteRule);
return IdVo.of(meeting.getId()); return IdVo.of(meeting.getId());
} finally { } finally {
distributedLock.releaseLock(key); distributedLock.releaseLock(key);
@@ -187,7 +189,7 @@ public class MeetingManage {
ExpertInviteRule appoint = getExpertInviteRule(appointRule, meeting.getId()); ExpertInviteRule appoint = getExpertInviteRule(appointRule, meeting.getId());
inviteRuleService.save(appoint); inviteRuleService.save(appoint);
Long ruleId = appoint.getId(); Long ruleId = appoint.getId();
List<MeetingExpert> experts = appointRule.getExpertIds().stream().map(w -> {
List<MeetingExpert> experts = appointRule.getExpertIdList().stream().map(w -> {
ExpertUserFullInfo info = usersMap.get(w); ExpertUserFullInfo info = usersMap.get(w);
MeetingExpert expert = ExpertInviteBuilder.getExpertByAppoint(meeting.getId(), info, ruleId); MeetingExpert expert = ExpertInviteBuilder.getExpertByAppoint(meeting.getId(), info, ruleId);
expert.setStatus(ExpertAttendStatusEnum.NOTICING.getCode()); expert.setStatus(ExpertAttendStatusEnum.NOTICING.getCode());
@@ -472,7 +474,7 @@ public class MeetingManage {
AppointInviteRuleDTO appointRule = JSON.parseObject(appoint.getInviteRule(), AppointInviteRuleDTO.class); AppointInviteRuleDTO appointRule = JSON.parseObject(appoint.getInviteRule(), AppointInviteRuleDTO.class);
AppointRuleVO vo = new AppointRuleVO(); AppointRuleVO vo = new AppointRuleVO();
vo.setInviteDesc(appointRule.getInviteDesc()); vo.setInviteDesc(appointRule.getInviteDesc());
vo.setExperts(new ArrayList<>(meetingManageHelper.getExpertBasicInfo(appointRule.getExpertIds()).values()));
vo.setExperts(new ArrayList<>(meetingManageHelper.getExpertBasicInfo(appointRule.getExpertIdList()).values()));
result.setAppointRule(vo); result.setAppointRule(vo);
} }
return result; return result;
@@ -547,14 +549,34 @@ public class MeetingManage {
// yxtCallOrSmsHelper.sendSms(context); // yxtCallOrSmsHelper.sendSms(context);
} }


public void batchAppointExperts(BatchAppointExpertsReq po) {
List<ExpertUserFullInfo> userInfos = meetingManageHelper.appointExpertCheck(po.getMeetingId(), po.getExpertIds());
List<MeetingExpert> expertList = CollUtils.convert(userInfos, w -> {
MeetingExpert me = ExpertInviteBuilder.getExpertByAppoint(po.getMeetingId(), w, 0L);
me.setStatus(ExpertAttendStatusEnum.NOTICING.getCode());
return me;
});
meetingExpertService.saveBatch(expertList);
public void batchAppointExperts(BatchAppointExpertsReq req) {
Long meetingId = req.getMeetingId();
String key = "BATCH_APPOINT_EXPERT:" + meetingId;
if (!distributedLock.lock(key, RETRY_TIMES)) {
throw BizException.wrap("补充专家中,请勿重复点击");
}
try {
Meeting meeting = meetingService.getById(meetingId);
if (!ExpertInviteTypeEnum.APPOINT.eq(meeting.getInviteType())) {
throw BizException.wrap("该会议不能指定邀请专家");
}
if (meeting.getConfirmedRoster()) {
throw BizException.wrap("补充专家失败,已确认过专家名单");
}
if (!MeetingStatusEnum.NORMAL.eq(meeting.getStatus())) {
throw BizException.wrap("补充专家失败");
}
AppointInviteRuleDTO rule = inviteRuleService.appointRuleByMeetingId(meetingId);
List<ExpertUserFullInfo> userInfos = meetingManageHelper.appointExpertCheck(meetingId, req.getExpertIdList());
List<MeetingExpert> expertList = CollUtils.convert(userInfos, w -> {
MeetingExpert me = ExpertInviteBuilder.getExpertByAppoint(meetingId, w, rule.getId());
me.setStatus(ExpertAttendStatusEnum.NOTICING.getCode());
return me;
});
meetingExpertService.saveBatch(expertList);
} finally {
distributedLock.releaseLock(key);
}
} }


public void stopRandomInvite(Long meetingId) { public void stopRandomInvite(Long meetingId) {
@@ -620,16 +642,17 @@ public class MeetingManage {


public void confirmAttendByManager(ExpertConfirmReq req) { public void confirmAttendByManager(ExpertConfirmReq req) {
String key = "CONFIRM_ATTEND:" + req.getExpertMeetingId(); String key = "CONFIRM_ATTEND:" + req.getExpertMeetingId();
String msgPrefix = req.getAgreed() ? "确认参加" : "拒绝参加";
if (!distributedLock.lock(key, RETRY_TIMES)) { if (!distributedLock.lock(key, RETRY_TIMES)) {
throw BizException.wrap("确认参加失败,请重试!");
throw BizException.wrap("%s失败,请重试!", msgPrefix);
} }
try { try {
MeetingExpert me = meetingExpertService.getById(req.getExpertMeetingId()); MeetingExpert me = meetingExpertService.getById(req.getExpertMeetingId());
if (!ExpertAttendStatusEnum.NOTICING.eq(me.getStatus())) { if (!ExpertAttendStatusEnum.NOTICING.eq(me.getStatus())) {
throw BizException.wrap("确认参加失败,请重试!");
throw BizException.wrap("%s失败,请重试!", msgPrefix);
} }
LambdaUpdateWrapper<MeetingExpert> update = Wrappers.lambdaUpdate(MeetingExpert.class) LambdaUpdateWrapper<MeetingExpert> update = Wrappers.lambdaUpdate(MeetingExpert.class)
.set(MeetingExpert::getStatus, ExpertAttendStatusEnum.AGREED.getCode())
.set(MeetingExpert::getStatus, (req.getAgreed() ? ExpertAttendStatusEnum.AGREED : ExpertAttendStatusEnum.REFUSED).getCode())
.eq(MeetingExpert::getId, req.getExpertMeetingId()); .eq(MeetingExpert::getId, req.getExpertMeetingId());
meetingExpertService.update(update); meetingExpertService.update(update);
} finally { } finally {


+ 24
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IExpertInviteRuleService.java View File

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.meeting.service;


import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule;
import com.ningdatech.pmapi.meeting.entity.dto.AppointInviteRuleDTO;
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO;


import java.util.List; import java.util.List;
@@ -17,8 +18,31 @@ import java.util.Map;
*/ */
public interface IExpertInviteRuleService extends IService<ExpertInviteRule> { public interface IExpertInviteRuleService extends IService<ExpertInviteRule> {


/**
* 查询会议所有的邀请规则
*
* @param meetingId 会议ID
* @return 抽取规则集合
* @author WendyYang
**/
List<ExpertInviteRule> listByMeetingId(Long meetingId); List<ExpertInviteRule> listByMeetingId(Long meetingId);


/**
* 查询会议所有的随机邀请规则
*
* @param meetingId 会议ID
* @return 随机邀请规则
* @author WendyYang
**/
Map<Long, RandomInviteRuleDTO> randomRuleByMeetingId(Long meetingId); Map<Long, RandomInviteRuleDTO> randomRuleByMeetingId(Long meetingId);


/**
* 查询会议的指定邀请规则
*
* @param meetingId 会议ID
* @return 指定邀请规则
* @author WendyYang
**/
AppointInviteRuleDTO appointRuleByMeetingId(Long meetingId);

} }

+ 13
- 1
pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/ExpertInviteRuleServiceImpl.java View File

@@ -1,10 +1,12 @@
package com.ningdatech.pmapi.meeting.service.impl; package com.ningdatech.pmapi.meeting.service.impl;


import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule;
import com.ningdatech.pmapi.meeting.entity.dto.AppointInviteRuleDTO;
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO;
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum;
import com.ningdatech.pmapi.meeting.mapper.ExpertInviteRuleMapper; import com.ningdatech.pmapi.meeting.mapper.ExpertInviteRuleMapper;
@@ -41,7 +43,17 @@ public class ExpertInviteRuleServiceImpl extends ServiceImpl<ExpertInviteRuleMap
.eq(ExpertInviteRule::getInviteType, ExpertInviteTypeEnum.RANDOM.getCode()); .eq(ExpertInviteRule::getInviteType, ExpertInviteTypeEnum.RANDOM.getCode());
List<ExpertInviteRule> inviteRules = baseMapper.selectList(query); List<ExpertInviteRule> inviteRules = baseMapper.selectList(query);
return inviteRules.stream().collect(Collectors.toMap(ExpertInviteRule::getId, return inviteRules.stream().collect(Collectors.toMap(ExpertInviteRule::getId,
w -> JSONObject.parseObject(w.getInviteRule(), RandomInviteRuleDTO.class)));
w -> JSONUtil.toBean(w.getInviteRule(), RandomInviteRuleDTO.class)));
}

@Override
public AppointInviteRuleDTO appointRuleByMeetingId(Long meetingId) {
LambdaQueryWrapper<ExpertInviteRule> query = wrapperByMeetingId(meetingId)
.eq(ExpertInviteRule::getInviteType, ExpertInviteTypeEnum.APPOINT.getCode());
ExpertInviteRule inviteRule = baseMapper.selectOne(query);
AppointInviteRuleDTO rule = JSONUtil.toBean(inviteRule.getInviteRule(), AppointInviteRuleDTO.class);
rule.setId(inviteRule.getId());
return rule;
} }


} }

+ 6
- 4
pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java View File

@@ -1,9 +1,11 @@
package com.ningdatech.pmapi.sys.service; package com.ningdatech.pmapi.sys.service;


import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.db.Db; import cn.hutool.db.Db;
import cn.hutool.db.Entity; import cn.hutool.db.Entity;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.sys.model.entity.Menu; import com.ningdatech.pmapi.sys.model.entity.Menu;
@@ -70,12 +72,12 @@ class IMenuServiceTest extends AppTests {


@Test @Test
public void initMenu() { public void initMenu() {
// menuService.remove(null);
menuService.remove(null);
roleMenuService.remove(Wrappers.lambdaQuery(RoleMenu.class) roleMenuService.remove(Wrappers.lambdaQuery(RoleMenu.class)
.eq(RoleMenu::getRoleId, 1)); .eq(RoleMenu::getRoleId, 1));
// String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8");
// List<JSONObject> obj = JSONUtil.toList(str, JSONObject.class);
// save(obj, 0);
String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8");
List<JSONObject> obj = JSONUtil.toList(str, JSONObject.class);
save(obj, 0);
menuService.list().forEach(w -> { menuService.list().forEach(w -> {
roleMenuService.save(new RoleMenu() {{ roleMenuService.save(new RoleMenu() {{
setRoleId(1L); setRoleId(1L);


Loading…
Cancel
Save