Merge remote-tracking branch 'origin/feat_chievements_dev' into feat_chievements_dev
This commit is contained in:
commit
5ae151e360
|
@ -0,0 +1,18 @@
|
|||
package com.microservices.dms.achievementLibrary.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TokenListVo {
|
||||
|
||||
private Long id; // 项目ID
|
||||
private String name; // 项目名称
|
||||
private Long totalToken; // 项目总Token
|
||||
private String createBy; // 创建人
|
||||
private Long currentToken; // 当前Token
|
||||
private String repositoryName; // 仓库名称
|
||||
private Long repositoryId; // 仓库名称
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Data createdOn; // 项目创建时间(以毫秒为单位)
|
||||
}
|
|
@ -117,7 +117,7 @@ public class BigScreenStatisticService {
|
|||
c.put("key","浏览");
|
||||
c.put("value", cres);
|
||||
Map<String, Object> d = new HashMap<>();
|
||||
c.put("key","下载");
|
||||
d.put("key","下载");
|
||||
d.put("value", dres);
|
||||
Map<String, Object> f = new HashMap<>();
|
||||
f.put("key", "收藏");
|
||||
|
|
|
@ -117,4 +117,7 @@ public interface IAchievementsService {
|
|||
List<TaskResourceLibrary> getRelatedAchTaskOfExpert(Long id);
|
||||
|
||||
List<CompetitionResourceLibrary> getRelatedAchCompetitionOfExpert(Long id);
|
||||
|
||||
List<TokenListVo> projectTokenList();
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import java.util.stream.Collectors;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.httpClient.service.HttpAPIService;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.achievementLibrary.domain.*;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
|
||||
|
@ -21,6 +23,7 @@ import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper;
|
|||
import com.microservices.dms.resourceLibrary.mapper.ProjectResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper;
|
||||
import com.microservices.dms.utils.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
@ -37,6 +40,7 @@ import static com.microservices.dms.utils.UrlUtil.getUrlPath;
|
|||
* @date 2025-04-02
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AchievementsServiceImpl implements IAchievementsService {
|
||||
@Autowired
|
||||
private AchievementsMapper achievementsMapper;
|
||||
|
@ -62,6 +66,11 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
@Value("${http.gatewayUrl}")
|
||||
public String gatewayUrl;
|
||||
|
||||
@Value("${gitlink.fiscobcosUrl}")
|
||||
public String fiscobcosUrl;
|
||||
|
||||
@Autowired
|
||||
private HttpAPIService httpAPIService;
|
||||
|
||||
/**
|
||||
* 查询成果
|
||||
|
@ -192,7 +201,8 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
return aStr;
|
||||
}
|
||||
|
||||
List<Map<String,String>> list = JSON.parseObject(aStr,new TypeReference<List<Map<String,String>>>() {});
|
||||
List<Map<String, String>> list = JSON.parseObject(aStr, new TypeReference<List<Map<String, String>>>() {
|
||||
});
|
||||
|
||||
if (Objects.equals(source, "1") || Objects.equals(source, "3")) {
|
||||
concatUrl(list, gitLinkUrl);
|
||||
|
@ -504,6 +514,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
return achievementsMapper.getRelatedAchCompetitionOfExpert(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据查询内容,调用搜索行为接口
|
||||
*
|
||||
|
@ -541,4 +552,37 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
public List<String> getExpertAreasByName(String areaName) {
|
||||
return achievementsMapper.getExpertAreasByName(areaName);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TokenListVo> projectTokenList() {
|
||||
List<TokenListVo> list = projectResourceLibraryMapper.selectProjectInfos();
|
||||
for (TokenListVo v : list) {
|
||||
Long totalToken = queryTotalToken(v);
|
||||
Long issueTokenSum = projectResourceLibraryMapper.sumProjectIssueToken(v.getId());
|
||||
v.setCurrentToken(totalToken - issueTokenSum);
|
||||
v.setTotalToken(totalToken);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Long queryTotalToken(TokenListVo v) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("request-type","query repo basic info");
|
||||
param.put("token_name",v.getId());
|
||||
|
||||
try {
|
||||
JSONObject reps = httpAPIService.doPost(fiscobcosUrl,param);
|
||||
if (reps.containsKey("status") && reps.getString("status").equals("0")) {
|
||||
Long totalSupply = reps.getLong("total_supply");
|
||||
// Long curSupply = reps.getLong("cur_supply");
|
||||
return totalSupply;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("区块链信息查询失败", e);
|
||||
return -1L;
|
||||
}
|
||||
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@ package com.microservices.dms.referral.mapper;
|
|||
|
||||
import com.microservices.common.datasource.annotation.Slave;
|
||||
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
|
||||
import com.microservices.dms.referral.vo.ExpertVo;
|
||||
import com.microservices.dms.referral.vo.IssuesVo;
|
||||
import com.microservices.dms.referral.vo.PullRequestVo;
|
||||
import com.microservices.dms.referral.vo.TaskVo;
|
||||
import com.microservices.dms.referral.vo.*;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -46,4 +43,7 @@ public interface TalentReferralMapper {
|
|||
TaskVo selectCompetitionById(Long competitionId);
|
||||
|
||||
List<TaskVo> selectCompetitionIdByStatus();
|
||||
|
||||
PrInfoVo selectPRInfoById(@Param("id") Integer id);
|
||||
|
||||
}
|
||||
|
|
|
@ -11,10 +11,7 @@ import com.microservices.dms.achievementLibrary.mapper.AchievementsMapper;
|
|||
import com.microservices.dms.constant.ReferralConstant;
|
||||
import com.microservices.dms.constant.TaskConstant;
|
||||
import com.microservices.dms.referral.mapper.TalentReferralMapper;
|
||||
import com.microservices.dms.referral.vo.ExpertVo;
|
||||
import com.microservices.dms.referral.vo.IssueDto;
|
||||
import com.microservices.dms.referral.vo.IssuesVo;
|
||||
import com.microservices.dms.referral.vo.TaskVo;
|
||||
import com.microservices.dms.referral.vo.*;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import com.microservices.dms.utils.DmsGitLinkRequestUrl;
|
||||
import com.microservices.dms.utils.DmsRequestHelper;
|
||||
|
@ -94,9 +91,9 @@ public class TalentReferralService {
|
|||
return collaborators;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> doIssueTalentReferral(Long projectId, Long issueId) {
|
||||
public List<Map<String, Object>> doIssueTalentReferral(Long issueId , Long projectId) {
|
||||
List<Map.Entry<Long, Double>> entries = issueTalentReferral(projectId, issueId);
|
||||
return entries.stream().map(s -> {
|
||||
return entries.stream().limit(3).map(s -> {
|
||||
Map<String, Object> mm = talentReferralMapper.selectUsersById(s.getKey());
|
||||
return mm;
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -111,12 +108,12 @@ public class TalentReferralService {
|
|||
|
||||
List<Long> curIssueAssigners = talentReferralMapper.selectIssuesAssigners(curIssue.getId());
|
||||
if (!curIssueAssigners.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
// return new ArrayList<>();
|
||||
}
|
||||
|
||||
IssuesVo vo = new IssuesVo();
|
||||
vo.setProjectId(projectId);
|
||||
vo.setStatusIds(Collections.singletonList(ReferralConstant.ISSUE_CLOSED));
|
||||
vo.setStatusIds(Lists.newArrayList(ReferralConstant.ISSUE_CLOSED,ReferralConstant.ISSUE_RESOLVED));
|
||||
List<IssuesVo> issuesVos = talentReferralMapper.selectIssuesCondition(vo);
|
||||
Map<Long, Double> userFractionMap = new HashMap<>();
|
||||
// 计算与解决issue的相似度, 标题+描述
|
||||
|
@ -153,13 +150,14 @@ public class TalentReferralService {
|
|||
Map<Long, Double> userFractionMap = new HashMap<>();
|
||||
Map<String, Double> userNameFractionMap = new HashMap<>();
|
||||
Map<String, Set<String>> PRFilesMap = new HashMap<>();
|
||||
List<IssueDto> closedPullRequests = getPullRequests(projectId, "11");
|
||||
List<IssueDto> closedPullRequests = getPullRequests(projectId, "11").stream()
|
||||
.filter(e->StringUtils.isNotBlank(e.getAssignUserLogin())).collect(Collectors.toList());
|
||||
|
||||
for (IssueDto pr : prs) {
|
||||
PrInfoVo curPrInfoVo = talentReferralMapper.selectPRInfoById(pr.getPullRequestId());
|
||||
//关闭PR的对比
|
||||
for (IssueDto dto : closedPullRequests) {
|
||||
List<String> reviewers = dto.getReviewers();
|
||||
for (String reviewer : reviewers) {
|
||||
String reviewer = dto.getAssignUserLogin();
|
||||
Set<String> prFiles = getPRFiles(projectId, dto.getPullRequestNumber());
|
||||
PRFilesMap.merge(reviewer, prFiles, (a, b) -> {
|
||||
HashSet<String> set = new HashSet<>();
|
||||
|
@ -167,22 +165,26 @@ public class TalentReferralService {
|
|||
set.addAll(b);
|
||||
return set;
|
||||
});
|
||||
}
|
||||
|
||||
//标题、content匹配
|
||||
PrInfoVo prInfoVo = talentReferralMapper.selectPRInfoById(dto.getPullRequestId());
|
||||
double subjectFraction = SimilarityService.sentence(curPrInfoVo.getTitle(), prInfoVo.getTitle());
|
||||
double descFraction = SimilarityService.text(curPrInfoVo.getContent(), prInfoVo.getContent());
|
||||
//这个数据可以缓存下来
|
||||
userNameFractionMap.merge(dto.getAssignUserLogin(), (subjectFraction + descFraction) * 40.0D, Double::sum);
|
||||
}
|
||||
|
||||
Set<String> curPrFiles = getPRFiles(projectId, pr.getPullRequestNumber());
|
||||
for (String curPrFile : curPrFiles) {
|
||||
PRFilesMap.forEach((k, v) -> {
|
||||
if (v.contains(curPrFile)) {
|
||||
userNameFractionMap.merge(k, 60.0D, Double::sum);
|
||||
userNameFractionMap.merge(k, 30.0D, Double::sum);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 计算每个负责人关闭的 PR数量
|
||||
closedPullRequests.stream().map(IssueDto::getReviewers).flatMap(List::stream).forEach(s -> userNameFractionMap.merge(s, 40.0D, Double::sum));
|
||||
|
||||
|
||||
closedPullRequests.stream().map(IssueDto::getAssignUserLogin).forEach(s -> userNameFractionMap.merge(s, 30.0D, Double::sum));
|
||||
}
|
||||
|
||||
userNameFractionMap.forEach((k, v) -> {
|
||||
|
@ -224,7 +226,7 @@ public class TalentReferralService {
|
|||
}
|
||||
|
||||
try {
|
||||
JSONArray allDataByPage = dmsRequestHelper.getAllDataByPage(DmsGitLinkRequestUrl.GET_PR_FILES(projectFullName, PRNum), "issues", "files");
|
||||
JSONArray allDataByPage = dmsRequestHelper.getAllDataByPage(DmsGitLinkRequestUrl.GET_PR_FILES(projectFullName, PRNum), "files", "file_nums");
|
||||
return allDataByPage.stream().map(o -> (JSONObject) o).map(o -> (String) o.get("filename")).collect(Collectors.toSet());
|
||||
} catch (ServiceException e) {
|
||||
logger.error("【{}】获取PR文件失败:{}", projectFullName, e.getMessage());
|
||||
|
@ -232,9 +234,9 @@ public class TalentReferralService {
|
|||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> doPRTalentReferral(Long projectId, Long prId) {
|
||||
public List<Map<String, Object>> doPRTalentReferral(Long prId, Long projectId) {
|
||||
List<Map.Entry<Long, Double>> entries = PRTalentReferral(projectId, prId);
|
||||
return entries.stream().map(s -> {
|
||||
return entries.stream().limit(3).map(s -> {
|
||||
Map<String, Object> mm = talentReferralMapper.selectUsersById(s.getKey());
|
||||
return mm;
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -242,14 +244,14 @@ public class TalentReferralService {
|
|||
|
||||
public List<Map.Entry<Long, Double>> PRTalentReferral(Long projectId, Long prId) {
|
||||
List<IssueDto> openPullRequests = getPullRequests(projectId, "1");
|
||||
openPullRequests = openPullRequests.stream().filter(e -> e.getReviewers().isEmpty()).collect(Collectors.toList());
|
||||
openPullRequests = openPullRequests.stream().filter(e -> StringUtils.isEmpty(e.getAssignUserLogin())).collect(Collectors.toList());
|
||||
|
||||
if (prId != null) {
|
||||
openPullRequests = openPullRequests.stream().filter(e -> Objects.equals((long) (e.getId()), prId)).filter(e -> e.getReviewers().isEmpty()).collect(Collectors.toList());
|
||||
openPullRequests = openPullRequests.stream().filter(e -> Objects.equals((long) (e.getPullRequestId()), prId)).collect(Collectors.toList());
|
||||
return PRTalentReferral(projectId, prId, openPullRequests);
|
||||
}
|
||||
|
||||
return PRTalentReferral(projectId, prId, openPullRequests);
|
||||
return PRTalentReferral(projectId, null, openPullRequests);
|
||||
}
|
||||
|
||||
//定时统计
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.microservices.dms.referral.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PrInfoVo {
|
||||
private Long id;
|
||||
private String title;
|
||||
private String content;
|
||||
}
|
|
@ -33,7 +33,7 @@ public class CompetitionResourceLibrary extends BaseEntity {
|
|||
*/
|
||||
private String competitionField;
|
||||
/**
|
||||
* 竞赛状态 0进行中 1已结束
|
||||
* 竞赛状态 status: 0 未上架 1上架
|
||||
*/
|
||||
private String competitionStatus;
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.microservices.dms.resourceLibrary.mapper;
|
||||
|
||||
import com.microservices.common.datasource.annotation.Slave;
|
||||
import com.microservices.dms.achievementLibrary.domain.TokenListVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.ProjectResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.ProjectListVo;
|
||||
|
@ -51,4 +52,8 @@ public interface ProjectResourceLibraryMapper {
|
|||
List<KeyValVo<String,String>> getAttachments(@Param("containerId") Long containerId);
|
||||
|
||||
String getProjectDomainNameByKey(@Param("projectDomain") String projectDomain );
|
||||
|
||||
List<TokenListVo> selectProjectInfos();
|
||||
|
||||
Long sumProjectIssueToken(@Param("id") Long id);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DmsRequestHelper extends GitLinkRequestHelper {
|
|||
int pageNum = 1;
|
||||
// 循环分页获取gitlink组织下所有成员
|
||||
while (!isAllData) {
|
||||
JSONObject result = doGet(GitLinkRequestUrl.GET_LIST_BY_PAGES(url, pageNum, 50)
|
||||
JSONObject result = doGet(GET_LIST_BY_PAGES(url, pageNum, 50)
|
||||
);
|
||||
allList.addAll(result.getList(listKey, tClass));
|
||||
long total = result.getLong("search_count");
|
||||
|
@ -84,7 +84,7 @@ public class DmsRequestHelper extends GitLinkRequestHelper {
|
|||
|
||||
|
||||
public static GitLinkRequestUrl GET_LIST_BY_PAGES(String url, Integer page, Integer limit) {
|
||||
String p = url.contains("?")? "&page=%d&limit=%d": "%s?page=%d&limit=%d";
|
||||
String p = url.contains("?")? "%s&page=%s&limit=%s": "%s?page=%s&limit=%s";
|
||||
return getAdminGitLinkRequestUrl(String.format(p, url, page, limit));
|
||||
}
|
||||
|
||||
|
|
|
@ -355,6 +355,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from achievements a
|
||||
left join users u on a.owner_name = u.login
|
||||
left join user_extensions ue on u.id = ue.user_id
|
||||
where a.status = '1'
|
||||
) as t
|
||||
order by (f+w) desc
|
||||
limit 0,3
|
||||
|
|
|
@ -369,4 +369,16 @@
|
|||
select name from project_categories where id=#{projectDomain}
|
||||
</select>
|
||||
|
||||
<select id="selectProjectInfos" resultType="com.microservices.dms.achievementLibrary.domain.TokenListVo">
|
||||
select p.id ,p.name ,created_on, r.identifier repositoryName, r.id as repositoryId from projects p
|
||||
join repositories r on p.id = r.project_id where p.use_blockchain = 1
|
||||
</select>
|
||||
|
||||
<select id="sumProjectIssueToken" resultType="java.lang.Long">
|
||||
select IFNULL(sum(i.blockchain_token_num),0)
|
||||
from issues i
|
||||
inner join projects p on i.project_id = p.id
|
||||
where p.id=#{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<mapper namespace="com.microservices.dms.referral.mapper.TalentReferralMapper">
|
||||
|
||||
<select id="selectIssuesCondition" resultType="com.microservices.dms.referral.vo.IssuesVo">
|
||||
select project_id,`subject`,description,status_id from issues
|
||||
select id,project_id,`subject`,description,status_id from issues
|
||||
<where>
|
||||
<if test="id != null ">and id = #{id}</if>
|
||||
<if test="projectId != null ">and project_id = #{projectId}</if>
|
||||
|
@ -115,5 +115,9 @@
|
|||
where upload_date < now()
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectPRInfoById" resultType="com.microservices.dms.referral.vo.PrInfoVo">
|
||||
select pr.id,pr.title as "title",pr.body as "content"
|
||||
from pull_requests pr
|
||||
where pr.id= #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue