From 7a2fa84220b90968d7edefe4c848ad4977617f79 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 7 Mar 2023 14:54:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A1=AE=E8=AE=A4=E5=8F=82?= =?UTF-8?q?=E5=8A=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meeting/controller/MeetingController.java | 5 +-- .../meeting/entity/dto/AppointInviteRuleDTO.java | 2 +- .../meeting/entity/req/BatchAppointExpertsReq.java | 2 +- .../pmapi/meeting/entity/req/ExpertConfirmReq.java | 3 ++ .../pmapi/meeting/helper/ExpertInviteHelper.java | 3 +- .../pmapi/meeting/helper/MeetingManageHelper.java | 10 +++-- .../pmapi/meeting/manage/MeetingManage.java | 51 ++++++++++++++++------ .../meeting/service/IExpertInviteRuleService.java | 24 ++++++++++ .../service/impl/ExpertInviteRuleServiceImpl.java | 14 +++++- .../pmapi/sys/service/IMenuServiceTest.java | 10 +++-- 10 files changed, 94 insertions(+), 30 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/controller/MeetingController.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/controller/MeetingController.java index d370ed8..7a49a53 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/controller/MeetingController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/controller/MeetingController.java @@ -123,8 +123,8 @@ public class MeetingController { return meetingManage.expertInvitationDetail(meetingId, expertId); } - @ApiOperation("批量补充专家") - @PostMapping("batchAppointExperts") + @ApiOperation("补充专家(指定抽取)") + @PostMapping("/expert/batchAppoint") @WebLog(value = "批量补充专家") public void batchAppointExperts(@Valid @RequestBody BatchAppointExpertsReq po) { meetingManage.batchAppointExperts(po); @@ -158,5 +158,4 @@ public class MeetingController { meetingManage.confirmedRoster(req.getMeetingId()); } - } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/AppointInviteRuleDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/AppointInviteRuleDTO.java index f322835..d860c51 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/AppointInviteRuleDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/AppointInviteRuleDTO.java @@ -29,6 +29,6 @@ public class AppointInviteRuleDTO extends AbstractInviteRule { @NotEmpty(message = "专家ID不能为空", groups = {RuleSave.class, CountCheck.class}) @ApiModelProperty("专家ID") - private List expertIds; + private List expertIdList; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/BatchAppointExpertsReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/BatchAppointExpertsReq.java index 155c4cb..97eb763 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/BatchAppointExpertsReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/BatchAppointExpertsReq.java @@ -22,7 +22,7 @@ public class BatchAppointExpertsReq { @NotEmpty(message = "专家ID不能为空") @ApiModelProperty("专家ID") - private List expertIds; + private List expertIdList; @NotNull(message = "会议ID不能为空") @ApiModelProperty("会议ID") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/ExpertConfirmReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/ExpertConfirmReq.java index 245eb1e..712d189 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/ExpertConfirmReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/req/ExpertConfirmReq.java @@ -26,4 +26,7 @@ public class ExpertConfirmReq { @ApiModelProperty("专家会议ID") private Long expertMeetingId; + @ApiModelProperty("是否确认参加会议") + private Boolean agreed; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertInviteHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertInviteHelper.java index 45b7ebc..ad6dc68 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertInviteHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertInviteHelper.java @@ -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.AvoidInfoDTO; 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.IMeetingService; import lombok.AllArgsConstructor; @@ -85,7 +84,7 @@ public class ExpertInviteHelper { if (appointRule == null) { return Collections.emptyMap(); } - List expertInfos = expertUserFullInfoService.listByUserId(appointRule.getExpertIds()); + List expertInfos = expertUserFullInfoService.listByUserId(appointRule.getExpertIdList()); return CollUtils.listToMap(expertInfos, ExpertUserFullInfo::getUserId); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java index fcaf5d6..78f7d33 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/MeetingManageHelper.java @@ -28,7 +28,10 @@ import lombok.AllArgsConstructor; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Component; -import java.util.*; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Map; /** *

@@ -157,13 +160,12 @@ public class MeetingManageHelper { public List appointExpertCheck(Long meetingId, List expertIds) { List experts = expertUserFullInfoService.listByUserId(expertIds); AvoidInfoDTO avoidRule = getAvoidInfoDto(meetingId); - Map countMap = new HashMap<>(16); experts.forEach(expert -> { if (avoidRule.getAvoidUnitIdList().contains(expert.getCompany())) { - throw BizException.wrap("回避单位的专家不可出现在指定邀请名单中"); + throw BizException.wrap("请移除已回避单位的专家"); } if (CollectionUtils.isNotEmpty(avoidRule.getExpertIds()) && avoidRule.getExpertIds().contains(expert.getUserId())) { - throw BizException.wrap("已回避的专家不可被指定邀请"); + throw BizException.wrap("请移除已回避的专家"); } // 校验专家状态 ExpertAccountStatusEnum accountStatus = ExpertAccountStatusEnum.of(expert.getExpertAccountStatus()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java index cf37e8e..0fd10eb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/MeetingManage.java @@ -102,6 +102,7 @@ public class MeetingManage { throw BizException.wrap("会议正在创建中"); } try { + ExpertInviteReq inviteRule = req.getExpertInviteRule(); // 保存会议基本信息 Meeting meeting = BeanUtil.copyProperties(meetingBasic, Meeting.class); meeting.setStatus(MeetingStatusEnum.NORMAL.getCode()); @@ -112,6 +113,7 @@ public class MeetingManage { meeting.setCreator(userDetail.getUsername()); meeting.setInviteStopped(Boolean.FALSE); meeting.setConfirmedRoster(Boolean.FALSE); + meeting.setInviteType(inviteRule.getInviteType()); meetingService.save(meeting); if (meetingBasic.getIsInnerProject()) { List projects = meetingBasic.getProjectIdList().stream().map(w -> { @@ -131,7 +133,7 @@ public class MeetingManage { } // 抽取专家 req.getExpertInviteRule().setMeetingId(meeting.getId()); - expertInviteByCreate(req.getExpertInviteRule()); + expertInviteByCreate(inviteRule); return IdVo.of(meeting.getId()); } finally { distributedLock.releaseLock(key); @@ -187,7 +189,7 @@ public class MeetingManage { ExpertInviteRule appoint = getExpertInviteRule(appointRule, meeting.getId()); inviteRuleService.save(appoint); Long ruleId = appoint.getId(); - List experts = appointRule.getExpertIds().stream().map(w -> { + List experts = appointRule.getExpertIdList().stream().map(w -> { ExpertUserFullInfo info = usersMap.get(w); MeetingExpert expert = ExpertInviteBuilder.getExpertByAppoint(meeting.getId(), info, ruleId); expert.setStatus(ExpertAttendStatusEnum.NOTICING.getCode()); @@ -472,7 +474,7 @@ public class MeetingManage { AppointInviteRuleDTO appointRule = JSON.parseObject(appoint.getInviteRule(), AppointInviteRuleDTO.class); AppointRuleVO vo = new AppointRuleVO(); 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); } return result; @@ -547,14 +549,34 @@ public class MeetingManage { // yxtCallOrSmsHelper.sendSms(context); } - public void batchAppointExperts(BatchAppointExpertsReq po) { - List userInfos = meetingManageHelper.appointExpertCheck(po.getMeetingId(), po.getExpertIds()); - List 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 userInfos = meetingManageHelper.appointExpertCheck(meetingId, req.getExpertIdList()); + List 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) { @@ -620,16 +642,17 @@ public class MeetingManage { public void confirmAttendByManager(ExpertConfirmReq req) { String key = "CONFIRM_ATTEND:" + req.getExpertMeetingId(); + String msgPrefix = req.getAgreed() ? "确认参加" : "拒绝参加"; if (!distributedLock.lock(key, RETRY_TIMES)) { - throw BizException.wrap("确认参加失败,请重试!"); + throw BizException.wrap("%s失败,请重试!", msgPrefix); } try { MeetingExpert me = meetingExpertService.getById(req.getExpertMeetingId()); if (!ExpertAttendStatusEnum.NOTICING.eq(me.getStatus())) { - throw BizException.wrap("确认参加失败,请重试!"); + throw BizException.wrap("%s失败,请重试!", msgPrefix); } LambdaUpdateWrapper 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()); meetingExpertService.update(update); } finally { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IExpertInviteRuleService.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IExpertInviteRuleService.java index 94502ec..75f6063 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IExpertInviteRuleService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IExpertInviteRuleService.java @@ -2,6 +2,7 @@ package com.ningdatech.pmapi.meeting.service; import com.baomidou.mybatisplus.extension.service.IService; 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 java.util.List; @@ -17,8 +18,31 @@ import java.util.Map; */ public interface IExpertInviteRuleService extends IService { + /** + * 查询会议所有的邀请规则 + * + * @param meetingId 会议ID + * @return 抽取规则集合 + * @author WendyYang + **/ List listByMeetingId(Long meetingId); + /** + * 查询会议所有的随机邀请规则 + * + * @param meetingId 会议ID + * @return 随机邀请规则 + * @author WendyYang + **/ Map randomRuleByMeetingId(Long meetingId); + /** + * 查询会议的指定邀请规则 + * + * @param meetingId 会议ID + * @return 指定邀请规则 + * @author WendyYang + **/ + AppointInviteRuleDTO appointRuleByMeetingId(Long meetingId); + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/ExpertInviteRuleServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/ExpertInviteRuleServiceImpl.java index 8584d11..dd33547 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/ExpertInviteRuleServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/ExpertInviteRuleServiceImpl.java @@ -1,10 +1,12 @@ package com.ningdatech.pmapi.meeting.service.impl; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.enumeration.ExpertInviteTypeEnum; import com.ningdatech.pmapi.meeting.mapper.ExpertInviteRuleMapper; @@ -41,7 +43,17 @@ public class ExpertInviteRuleServiceImpl extends ServiceImpl inviteRules = baseMapper.selectList(query); 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 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; } } diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java b/pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java index 7d9a566..149f4e1 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java @@ -1,9 +1,11 @@ package com.ningdatech.pmapi.sys.service; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.io.FileUtil; import cn.hutool.db.Db; import cn.hutool.db.Entity; import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.sys.model.entity.Menu; @@ -70,12 +72,12 @@ class IMenuServiceTest extends AppTests { @Test public void initMenu() { - // menuService.remove(null); + menuService.remove(null); roleMenuService.remove(Wrappers.lambdaQuery(RoleMenu.class) .eq(RoleMenu::getRoleId, 1)); - // String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8"); - // List 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 obj = JSONUtil.toList(str, JSONObject.class); + save(obj, 0); menuService.list().forEach(w -> { roleMenuService.save(new RoleMenu() {{ setRoleId(1L);