Browse Source

增加专家履职记录

tags/24080901
WendyYang 4 months ago
parent
commit
1d33b2655e
5 changed files with 207 additions and 41 deletions
  1. +9
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/expert/service/IExpertUserFullInfoService.java
  2. +21
    -17
      hz-pm-api/src/main/java/com/hz/pm/api/open/controller/OpenApiMeetingExpertInfoController.java
  3. +77
    -24
      hz-pm-api/src/main/java/com/hz/pm/api/open/manage/OpenApiMeetingExpertManage.java
  4. +32
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/open/model/po/PageExpertJudgePO.java
  5. +68
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/open/model/vo/ExpertJudgeToMhVO.java

+ 9
- 0
hz-pm-api/src/main/java/com/hz/pm/api/expert/service/IExpertUserFullInfoService.java View File

@@ -1,8 +1,10 @@
package com.hz.pm.api.expert.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.expert.entity.ExpertUserFullInfo;
import com.ningdatech.basic.util.CollUtils;

@@ -44,4 +46,11 @@ public interface IExpertUserFullInfoService extends IService<ExpertUserFullInfo>
return CollUtils.fieldList(list(query), ExpertUserFullInfo::getCompanyUniqCode);
}

default ExpertUserFullInfo getByMhExpertId(String mhExpertId){
Wrapper<ExpertUserFullInfo> query = Wrappers.lambdaQuery(ExpertUserFullInfo.class)
.eq(ExpertUserFullInfo::getMhExpertId, mhExpertId)
.last(BizConst.LIMIT_1);
return getOne(query);
}

}

+ 21
- 17
hz-pm-api/src/main/java/com/hz/pm/api/open/controller/OpenApiMeetingExpertInfoController.java View File

@@ -1,31 +1,28 @@
package com.hz.pm.api.open.controller;


import java.util.List;

import javax.validation.Valid;

import com.hz.pm.api.open.model.po.ReqMeetingExpertSignPO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hz.pm.api.open.manage.OpenApiMeetingExpertInfoManage;
import com.hz.pm.api.open.manage.OpenApiMeetingExpertManage;
import com.hz.pm.api.open.model.po.PageExpertJudgePO;
import com.hz.pm.api.open.model.po.ReqMeetingExpertInfoPO;
import com.hz.pm.api.open.model.po.ReqMeetingExpertSignPO;
import com.hz.pm.api.open.model.vo.ExpertJudgeToMhVO;
import com.hz.pm.api.open.model.vo.MeetingExpertToMhDTO;

import com.ningdatech.basic.model.PageVo;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
* <p>
* 会议专家信息外部调用接口
* </p>
* @author CMM
*
* @author CMM
*/
@Slf4j
@Validated
@@ -34,17 +31,24 @@ import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor
public class OpenApiMeetingExpertInfoController {

private final OpenApiMeetingExpertInfoManage openMeetingExpertInfoManage;
private final OpenApiMeetingExpertManage openMeetingExpertManage;

@PostMapping("/list")
@ApiOperation("获取已抽取完成会议确定参加会议且未签到的专家信息列表")
public List<MeetingExpertToMhDTO> infoList(@Valid @RequestBody ReqMeetingExpertInfoPO po) {
return openMeetingExpertInfoManage.infoList(po);
return openMeetingExpertManage.infoList(po);
}

@PostMapping("/sign")
@ApiOperation("获取已抽取完成会议确定参加会议且未签到的专家信息列表")
public String sign(@Valid @RequestBody ReqMeetingExpertSignPO po) {
return openMeetingExpertInfoManage.sign(po);
return openMeetingExpertManage.sign(po);
}

@GetMapping("/pageExpertJudges")
@ApiOperation("获取专家评价列表")
public PageVo<ExpertJudgeToMhVO> pageExpertJudges(@Valid PageExpertJudgePO po) {
return openMeetingExpertManage.pageExpertJudges(po);
}

}

hz-pm-api/src/main/java/com/hz/pm/api/open/manage/OpenApiMeetingExpertInfoManage.java → hz-pm-api/src/main/java/com/hz/pm/api/open/manage/OpenApiMeetingExpertManage.java View File

@@ -7,15 +7,23 @@ import java.util.*;
import java.util.stream.Collectors;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hz.pm.api.expert.entity.ExpertUserFullInfo;
import com.hz.pm.api.expert.model.dto.DictionaryVO;
import com.hz.pm.api.expert.service.IExpertUserFullInfoService;
import com.hz.pm.api.meeting.entity.domain.MeetingExpertJudge;
import com.hz.pm.api.meeting.entity.enumeration.ExpertAttendStatusEnum;
import com.hz.pm.api.meeting.entity.enumeration.MeetingStatusEnum;
import com.hz.pm.api.meeting.service.IMeetingExpertJudgeService;
import com.hz.pm.api.meta.model.dto.DictionaryDTO;
import com.hz.pm.api.open.model.po.PageExpertJudgePO;
import com.hz.pm.api.open.model.po.ReqMeetingExpertSignPO;
import com.hz.pm.api.open.model.vo.ExpertJudgeToMhVO;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.ningdatech.basic.model.PageVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@@ -49,7 +57,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
@RequiredArgsConstructor
public class OpenApiMeetingExpertInfoManage {
public class OpenApiMeetingExpertManage {

@Value("${hz-pm.interfaceKey}")
private String meetingExpertInfoKey;
@@ -61,17 +69,17 @@ public class OpenApiMeetingExpertInfoManage {
private final IExpertDictionaryService iExpertDictionaryService;
private final DictionaryCache dictionaryCache;
private final IExpertUserFullInfoService expertUserFullInfoService;
private final IMeetingExpertJudgeService meetingExpertJudgeService;

public List<MeetingExpertToMhDTO> infoList(ReqMeetingExpertInfoPO po) {
String key = po.getKey();
// 校验传入的签名
if (!checkSign(key)){
throw new BizException("签名错误!");
}
checkSign(key);
// 获取已经抽取(指定)完成 确认参加会议并且未签到的专家信息
List<Meeting> meetingList = meetingService.list(Wrappers.lambdaQuery(Meeting.class)
.eq(Meeting::getConfirmedRoster, Boolean.TRUE)
.ne(Meeting::getStatus, MeetingStatusEnum.CANCEL.getCode()));
if(CollUtil.isEmpty(meetingList)){
if (CollUtil.isEmpty(meetingList)) {
return Collections.emptyList();
}
List<MeetingExpertToMhDTO> result = Lists.newArrayList();
@@ -97,7 +105,7 @@ public class OpenApiMeetingExpertInfoManage {
List<Long> userIdList = new ArrayList<>(userIds);
List<ExpertUserFullInfo> expertUserFullInfos = expertUserFullInfoService.listByUserIds(userIdList);
Map<Long, ExpertUserFullInfo> userFullInfoMap = MapUtil.newHashMap();
if(CollUtil.isNotEmpty(expertUserFullInfos)){
if (CollUtil.isNotEmpty(expertUserFullInfos)) {
userFullInfoMap = expertUserFullInfos.stream().collect(Collectors.toMap(ExpertUserFullInfo::getUserId, v -> v));
}
Set<String> employeeSet = Sets.newHashSet();
@@ -108,15 +116,15 @@ public class OpenApiMeetingExpertInfoManage {
Map<Long, UserFullInfoDTO> infoMap = userFullInfos.stream().collect(Collectors.toMap(UserFullInfoDTO::getUserId, v -> v));

List<ExpertDictionary> expertDictionaryList = iExpertDictionaryService.list(Wrappers.lambdaQuery(ExpertDictionary.class)
.eq(ExpertDictionary::getExpertInfoField, ExpertDictTypeEnum.EXPERT_TYPE.getKey())
.in(ExpertDictionary::getUserId, userIdSet));
.eq(ExpertDictionary::getExpertInfoField, ExpertDictTypeEnum.EXPERT_TYPE.getKey())
.in(ExpertDictionary::getUserId, userIdSet));
Map<Long, List<ExpertDictionary>> dictMap = expertDictionaryList.stream().collect(Collectors.groupingBy(ExpertDictionary::getUserId));

for (Map.Entry<Long, List<MeetingExpert>> entry : meetingExpertMap.entrySet()) {
MeetingExpertToMhDTO vo = new MeetingExpertToMhDTO();
Long meetingId = entry.getKey();
Meeting meeting = meetingMap.get(meetingId);
if (Objects.nonNull(meeting)){
if (Objects.nonNull(meeting)) {
vo.setMeetingId(meeting.getId());
vo.setStartTime(meeting.getStartTime());
vo.setEndTime(meeting.getEndTime());
@@ -126,10 +134,10 @@ public class OpenApiMeetingExpertInfoManage {
vo.setContact(meeting.getContact());
}
List<MeetingExpert> meetingExperts = entry.getValue();
if (CollUtil.isNotEmpty(meetingExperts)){
if (CollUtil.isNotEmpty(meetingExperts)) {
// 获取未签到的专家信息
List<MeetingExpert> expertUserList = meetingExperts.stream().filter(m -> Boolean.FALSE.equals(m.getSignStatus())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(expertUserList)){
if (CollUtil.isNotEmpty(expertUserList)) {
Map<Long, ExpertUserFullInfo> finalUserFullInfoMap = userFullInfoMap;
List<ExpertInfoVO> expertInfoVOList = expertUserList.stream().map(m -> {
ExpertInfoVO expertInfoVO = new ExpertInfoVO();
@@ -137,16 +145,16 @@ public class OpenApiMeetingExpertInfoManage {
expertInfoVO.setName(m.getExpertName());
expertInfoVO.setPhoneNo(m.getMobile());
UserFullInfoDTO userFullInfoDTO = infoMap.get(m.getExpertId());
if (Objects.nonNull(userFullInfoDTO)){
if (Objects.nonNull(userFullInfoDTO)) {
expertInfoVO.setMhUnitId(userFullInfoDTO.getMhUnitId());
expertInfoVO.setMhUnitName(userFullInfoDTO.getMhUnitName());
}
ExpertUserFullInfo expertUserFullInfo = finalUserFullInfoMap.get(m.getExpertId());
if (Objects.nonNull(expertUserFullInfo)){
if (Objects.nonNull(expertUserFullInfo)) {
expertInfoVO.setExpertId(expertUserFullInfo.getId());
}
List<ExpertDictionary> dictionaries = dictMap.get(m.getExpertId());
if (CollUtil.isNotEmpty(dictionaries)){
if (CollUtil.isNotEmpty(dictionaries)) {
List<DictionaryVO> dictionaryFieldInfos = dictionaries.stream().map(r -> {
DictionaryVO dictionary = new DictionaryVO();
dictionary.setDictionaryType(r.getExpertInfoField());
@@ -167,7 +175,10 @@ public class OpenApiMeetingExpertInfoManage {
return result;
}

private Boolean checkSign(String key) {
private void checkSign(String key) {
if (StrUtil.isBlank(key)) {
throw new BizException("签名错误");
}
StringBuilder sb = new StringBuilder();
sb.append("key=").append(meetingExpertInfoKey);
// 使用SHA-256进行加密
@@ -177,13 +188,12 @@ public class OpenApiMeetingExpertInfoManage {
byte[] bytes = md.digest(sb.toString().getBytes());
sign = bytesToHexString(bytes);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
log.error("签名校验错误:", e);
}
if (sign == null || sign.length() <= 8) {
return false;
if (sign != null && sign.length() <= 8 && StrUtil.startWith(sign, key)) {
return;
}
String signStr = sign.substring(sign.length() - 8);
return signStr.equals(key);
throw new BizException("签名错误");
}

/**
@@ -207,9 +217,7 @@ public class OpenApiMeetingExpertInfoManage {
public String sign(ReqMeetingExpertSignPO po) {
String key = po.getKey();
// 校验传入的签名
if (!checkSign(key)){
throw new BizException("签名错误!");
}
checkSign(key);
Long meetingId = po.getMeetingId();
Long userId = po.getUserId();
LocalDateTime signTime = po.getSignTime();
@@ -217,7 +225,7 @@ public class OpenApiMeetingExpertInfoManage {
// 获取会议专家信息
MeetingExpert meetingExpert = meetingExpertService.getByMeetingIdAndExpertId(meetingId, userId);
// 更新专家签到信息
if (Objects.nonNull(meetingExpert)){
if (Objects.nonNull(meetingExpert)) {
meetingExpert.setSignStatus(true);
meetingExpert.setSignTime(signTime);
meetingExpert.setSignAddress(signAddress);
@@ -226,4 +234,49 @@ public class OpenApiMeetingExpertInfoManage {
}
return "fail";
}

public PageVo<ExpertJudgeToMhVO> pageExpertJudges(PageExpertJudgePO po) {
checkSign(po.getKey());
LambdaQueryWrapper<MeetingExpertJudge> query = Wrappers.lambdaQuery(MeetingExpertJudge.class)
.eq(po.getMeetingId() != null, MeetingExpertJudge::getMeetingId, po.getMeetingId())
.orderByDesc(MeetingExpertJudge::getCreateOn);
Map<Long, ExpertUserFullInfo> expertUserMap = new HashMap<>();
if (StrUtil.isNotBlank(po.getMhExpertId())) {
ExpertUserFullInfo expertUser = expertUserFullInfoService.getByMhExpertId(po.getMhExpertId());
if (expertUser == null) {
return PageVo.empty();
}
query.eq(MeetingExpertJudge::getExpertId, expertUser.getUserId());
expertUserMap.put(expertUser.getUserId(), expertUser);
}
Page<MeetingExpertJudge> page = meetingExpertJudgeService.page(po.page(), query);
if (page.getTotal() == 0) {
return PageVo.empty();
}
if (StrUtil.isBlank(po.getMhExpertId())) {
List<Long> expertIds = CollUtils.fieldList(page.getRecords(), MeetingExpertJudge::getExpertId);
List<ExpertUserFullInfo> expertUsers = expertUserFullInfoService.listByUserIds(expertIds);
for (ExpertUserFullInfo expertUser : expertUsers) {
expertUserMap.put(expertUser.getUserId(), expertUser);
}
}
List<ExpertJudgeToMhVO> data = page.getRecords().stream().map(w -> {
ExpertUserFullInfo expertUser = expertUserMap.get(w.getExpertId());
return ExpertJudgeToMhVO.builder()
.mhExpertId(expertUser.getMhExpertId())
.meetingId(w.getMeetingId())
.userId(w.getExpertId())
.attended(w.getAttended())
.performance(w.getPerformance())
.advised(w.getAdvised())
.leaveEarly(w.getLeaveEarly())
.brokeRule(w.getBrokeRule())
.brokeRuleContent(w.getBrokeRuleContent())
.createOn(w.getCreateOn())
.score(w.getScore())
.build();
}).collect(Collectors.toList());
return PageVo.of(data, page.getTotal());
}

}

+ 32
- 0
hz-pm-api/src/main/java/com/hz/pm/api/open/model/po/PageExpertJudgePO.java View File

@@ -0,0 +1,32 @@
package com.hz.pm.api.open.model.po;

import com.ningdatech.basic.model.PagePo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;

/**
* <p>
* PageExpertJudgeReq
* </p>
*
* @author WendyYang
* @since 16:13 2024/6/17
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class PageExpertJudgePO extends PagePo {

@ApiModelProperty("会议ID")
private Long meetingId;

@ApiModelProperty("信创专家ID")
private String mhExpertId;

@ApiModelProperty("校验公钥")
@NotBlank(message = "秘钥不能为空")
private String key;

}

+ 68
- 0
hz-pm-api/src/main/java/com/hz/pm/api/open/model/vo/ExpertJudgeToMhVO.java View File

@@ -0,0 +1,68 @@
package com.hz.pm.api.open.model.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.hz.pm.api.meeting.entity.enumeration.ExpertJudgeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Tolerate;

import java.time.LocalDateTime;

/**
* <p>
* ExpertJudgeToMhVO
* </p>
*
* @author WendyYang
* @since 16:01 2024/6/17
*/
@Data
@Builder
public class ExpertJudgeToMhVO {

@Tolerate
public ExpertJudgeToMhVO() {
// 默认构造方法
}

@ApiModelProperty("会议ID")
private Long meetingId;

@ApiModelProperty("信创专家ID")
private String mhExpertId;

@ApiModelProperty("专家id")
private Long userId;

@ApiModelProperty("评分(0~5)")
private Double score;

/**
* @see ExpertJudgeEnum.AttendStatus
*/
@ApiModelProperty("是否参加:1 准时、2 迟到、3 缺席")
private Integer attended;

/**
* @see ExpertJudgeEnum.Performance
*/
@ApiModelProperty("参与程度:1 积极、2 消极")
private Integer performance;

@ApiModelProperty("是否提出建议:true 是、false 否")
private Boolean advised;

@ApiModelProperty("是否早退:true 早退、false 未早退")
private Boolean leaveEarly;

@ApiModelProperty("是否违规:true 是、false 否")
private Boolean brokeRule;

@ApiModelProperty("违规内容")
private String brokeRuleContent;

@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createOn;

}

Loading…
Cancel
Save