Merge pull request 'feat(运维监控模块): 新增接口:获取微服务应用功能列表' (#919) from otto/microservices:dev_monitoring into dev_monitoring

This commit is contained in:
otto 2025-06-26 11:13:44 +08:00
commit 13d5e7aa46
133 changed files with 5018 additions and 514 deletions

View File

@ -0,0 +1,36 @@
## 系统模块
~~~
com.microservices
├── microservices-ui // 前端框架
├── microservices-gateway // 网关模块
├── microservices-auth // 认证中心
├── microservices-api // 接口模块
│ └── microservices-api-system // 系统接口
├── microservices-common // 通用模块
│ └── microservices-common-async // 异步线程池配置
│ └── microservices-common-core // 核心模块
│ └── microservices-common-datascope // 权限范围
│ └── microservices-common-datasource // 多数据源
│ └── microservices-common-httpClient // http调用
│ └── microservices-common-log // 日志记录
│ └── microservices-common-redis // 缓存服务
│ └── microservices-common-seata // seata分布式事务
│ └── microservices-common-security // 安全模块
│ └── microservices-common-swagger // 系统接口
├── microservices-modules // 业务模块
│ └── microservices-cms // 内容管理模块
│ └── microservices-dms // 数据管理体系模块
│ └── microservices-dss // 数据统计系统模块
│ └── microservices-file // 文件服务
│ └── microservices-gen // 代码生成
│ └── microservices-job // 定时任务
│ └── microservices-pms // 项目管理系统模块
│ └── microservices-system // 系统模块
│ └── microservices-wiki // Wiki模块
│ └── microservices-zone // 特色专区系统模块
├── microservices-visual // 图形化管理模块
│ └── microservices-visual-monitor // 监控中心
├──pom.xml // 公共依赖
~~~

View File

@ -5,6 +5,7 @@ import com.microservices.common.core.constant.SecurityConstants;
import com.microservices.common.core.constant.ServiceNameConstants;
import com.microservices.common.core.constant.TokenConstants;
import com.microservices.system.api.factory.RemoteGatewayFallbackFactory;
import com.microservices.system.api.model.GraphqlQueryVo;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
@ -63,4 +64,17 @@ public interface RemoteGatewayService {
@RequestParam("start") Long start,
@RequestParam("end") Long end,
@RequestHeader(TokenConstants.AUTHENTICATION) String token);
@PostMapping("/skywalking/graphql")
JSONObject executeSkywalkingGql(@RequestBody GraphqlQueryVo gqlBody);
@GetMapping("/sentinel/app/briefinfos.json")
JSONObject getSentinelAppList(@RequestHeader(TokenConstants.AUTHENTICATION) String token);
@GetMapping("/nacos/v1/ns/catalog/services?pageNo=1&pageSize=999")
JSONObject getNacosServiceList(@RequestParam("serviceNameParam") String serviceNameParam,@RequestHeader(TokenConstants.AUTHENTICATION) String token);
@GetMapping("/nacos/v1/cs/configs?types=yaml&search=blur&group=&pageNo=1&pageSize=10")
JSONObject getNacosConfigList(@RequestParam("dataId") String dataId,@RequestHeader(TokenConstants.AUTHENTICATION) String token);
}

View File

@ -2,6 +2,7 @@ package com.microservices.system.api.factory;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.system.api.RemoteGatewayService;
import com.microservices.system.api.model.GraphqlQueryVo;
import feign.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,6 +54,26 @@ public class RemoteGatewayFallbackFactory implements FallbackFactory<RemoteGatew
public JSONObject getPrometheusQueryRangeRes(String query, Long step, Long start, Long end, String token) {
return null;
}
@Override
public JSONObject executeSkywalkingGql(GraphqlQueryVo gqlBody) {
return null;
}
@Override
public JSONObject getSentinelAppList(String token) {
return null;
}
@Override
public JSONObject getNacosServiceList(String serviceNameParam, String token) {
return null;
}
@Override
public JSONObject getNacosConfigList(String dataId, String token) {
return null;
}
};
}
}

View File

@ -0,0 +1,11 @@
package com.microservices.system.api.model;
import com.alibaba.fastjson2.JSONObject;
import lombok.Data;
@Data
public class GraphqlQueryVo {
String operationName;
String query;
JSONObject variables;
}

View File

@ -59,6 +59,8 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
public String rancherPassword;
@Value("${thirdPartyTools.portainer.endpoints:}")
public Integer portainerEndpoints;
@Value("${thirdPartyTools.retryTimes:1}")
public Integer retryTimes;
ThreadPoolExecutor threadPoolExecutor = CustomExecutorFactory.threadPoolExecutor;
@Lazy
@Autowired
@ -87,22 +89,31 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
if (redisService.hasKey(CacheConstants.SENTINEL_TOKEN)) {
sentinelCookie = redisService.getCacheObject(CacheConstants.SENTINEL_TOKEN);
} else {
// 网关采用异步架构所以此处需要通过异步请求获取Sentinel Token
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginSentinel(sentinelUsername, sentinelPassword));
try {
Response response = future.get(1, TimeUnit.SECONDS);
Map<String, Collection<String>> header = response.headers();
if (header != null && header.containsKey("set-cookie")) {
sentinelCookie = header.get("set-cookie").iterator().next();
//Sentinel登录状态默认30分钟失效将Sentinel Token缓存过期时间调整为28分钟
redisService.setCacheObject(CacheConstants.SENTINEL_TOKEN, sentinelCookie, 28L, TimeUnit.MINUTES);
for (int i = 0; i < retryTimes; i++) {
// 网关采用异步架构所以此处需要通过异步请求获取Sentinel Token
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginSentinel(sentinelUsername, sentinelPassword));
try {
Response response = future.get(1, TimeUnit.SECONDS);
Map<String, Collection<String>> header = response.headers();
if (header != null && header.containsKey("set-cookie")) {
sentinelCookie = header.get("set-cookie").iterator().next();
//Sentinel登录状态默认30分钟失效将Sentinel Token缓存过期时间调整为28分钟
redisService.setCacheObject(CacheConstants.SENTINEL_TOKEN, sentinelCookie, 28L, TimeUnit.MINUTES);
}
} catch (TimeoutException e) {
log.error("获取Sentinel Token超时");
} catch (InterruptedException | ExecutionException e) {
log.error("获取Sentinel Token失败{}", e.getMessage());
}
} catch (TimeoutException e) {
log.error("获取Sentinel Token超时");
} catch (InterruptedException | ExecutionException e) {
log.error("获取Sentinel Token失败{}", e.getMessage());
if (StringUtils.isNotEmpty(sentinelCookie)) {
break;
}
log.warn("获取Sentinel Token失败进行第{}次重试中", i + 1);
}
}
if (StringUtils.isNotEmpty(sentinelCookie)) {
ServletUtils.removeHeader(mutate, TokenConstants.Cookie);
mutate.header(TokenConstants.Cookie, String.format("%s;%s;", cookie, sentinelCookie));
@ -117,28 +128,35 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
if (redisService.hasKey(CacheConstants.RANCHER_TOKEN)) {
rancherToken = redisService.getCacheObject(CacheConstants.RANCHER_TOKEN);
} else {
JSONObject loginRancherBody = new JSONObject();
loginRancherBody.put("description", "api session");
loginRancherBody.put("responseType", "cookie");
loginRancherBody.put("username", rancherUsername);
loginRancherBody.put("password", rancherPassword);
for (int i = 0; i < retryTimes; i++) {
JSONObject loginRancherBody = new JSONObject();
loginRancherBody.put("description", "api session");
loginRancherBody.put("responseType", "cookie");
loginRancherBody.put("username", rancherUsername);
loginRancherBody.put("password", rancherPassword);
// 网关采用异步架构所以此处需要通过异步请求获取Sentinel Token
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginRancher(loginRancherBody));
try {
Response response = future.get(1, TimeUnit.SECONDS);
Map<String, Collection<String>> header = response.headers();
if (header != null && header.containsKey("set-cookie")) {
String rancherCookie = header.get("set-cookie").iterator().next();
rancherToken = getValueByCookieKey(rancherCookie,TokenConstants.Rancher_Cookie_Token_Key);
//Rancher登录状态默认15小时失效将Rancher Token缓存过期时间调整为14分钟
redisService.setCacheObject(CacheConstants.RANCHER_TOKEN, rancherToken, 14L, TimeUnit.HOURS);
// 网关采用异步架构所以此处需要通过异步请求获取Sentinel Token
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginRancher(loginRancherBody));
try {
Response response = future.get(1, TimeUnit.SECONDS);
Map<String, Collection<String>> header = response.headers();
if (header != null && header.containsKey("set-cookie")) {
String rancherCookie = header.get("set-cookie").iterator().next();
rancherToken = getValueByCookieKey(rancherCookie, TokenConstants.Rancher_Cookie_Token_Key);
//Rancher登录状态默认15小时失效将Rancher Token缓存过期时间调整为14分钟
redisService.setCacheObject(CacheConstants.RANCHER_TOKEN, rancherToken, 14L, TimeUnit.HOURS);
}
} catch (TimeoutException e) {
log.error("获取Rancher Token超时");
} catch (InterruptedException | ExecutionException e) {
log.error("获取Rancher Token失败{}", e.getMessage());
}
} catch (TimeoutException e) {
log.error("获取Rancher Token超时");
} catch (InterruptedException | ExecutionException e) {
log.error("获取Rancher Token失败{}", e.getMessage());
if (StringUtils.isNotEmpty(rancherToken)) {
break;
}
log.warn("获取Rancher Token失败进行第{}次重试中", i + 1);
}
}
if (StringUtils.isNotEmpty(rancherToken)) {
@ -154,32 +172,38 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
if (redisService.hasKey(CacheConstants.NACOS_TOKEN)) {
nacosToken = redisService.getCacheObject(CacheConstants.NACOS_TOKEN);
} else {
Map<String, String> nacosMap = new HashMap<>();
nacosMap.put("username", nacosUsername);
nacosMap.put("password", nacosPassword);
// 网关采用异步架构所以此处需要通过异步请求获取Nacos Token
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginNacos(nacosMap));
try {
Response res = future.get(1, TimeUnit.SECONDS);
StringWriter writer = new StringWriter();
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
String str = writer.toString();
if (!JSON.isValid(str)) {
return exceptionResponse(exchange, str, res.status());
for (int i = 0; i < retryTimes; i++) {
Map<String, String> nacosMap = new HashMap<>();
nacosMap.put("username", nacosUsername);
nacosMap.put("password", nacosPassword);
// 网关采用异步架构所以此处需要通过异步请求获取Nacos Token
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginNacos(nacosMap));
try {
Response res = future.get(1, TimeUnit.SECONDS);
StringWriter writer = new StringWriter();
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
String str = writer.toString();
if (!JSON.isValid(str)) {
return exceptionResponse(exchange, str, res.status());
}
JSONObject resJsonObject = JSONObject.parseObject(str);
if (resJsonObject == null) {
return exceptionResponse(exchange, str, res.status());
}
nacosToken = resJsonObject.getString("accessToken");
Long tokenTtl = resJsonObject.getLong("tokenTtl");
if (nacosToken != null && tokenTtl != null) {
redisService.setCacheObject(CacheConstants.NACOS_TOKEN, nacosToken, tokenTtl - 10, TimeUnit.SECONDS);
}
} catch (TimeoutException e) {
log.error("获取Nacos Token超时");
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
log.error("获取Nacos Token失败{}", e.getMessage());
}
JSONObject resJsonObject = JSONObject.parseObject(str);
if (resJsonObject == null) {
return exceptionResponse(exchange, str, res.status());
if (StringUtils.isNotEmpty(nacosToken)) {
break;
}
nacosToken = resJsonObject.getString("accessToken");
Long tokenTtl = resJsonObject.getLong("tokenTtl");
if (nacosToken != null && tokenTtl != null) {
redisService.setCacheObject(CacheConstants.NACOS_TOKEN, nacosToken, tokenTtl - 10, TimeUnit.SECONDS);
}
} catch (TimeoutException e) {
log.error("获取Nacos Token超时");
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
log.error("获取Nacos Token失败{}", e.getMessage());
log.warn("获取Nacos Token失败进行第{}次重试中", i + 1);
}
}
if (StringUtils.isNotEmpty(nacosToken)) {
@ -220,38 +244,44 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
if (redisService.hasKey(CacheConstants.PORTAINER_TOKEN)) {
portainerToken = redisService.getCacheObject(CacheConstants.PORTAINER_TOKEN);
} else {
// 网关采用异步架构所以此处需要通过异步请求获取Portainer Token
JSONObject loginPortainerBody = new JSONObject();
loginPortainerBody.put("username", portainerUsername);
loginPortainerBody.put("password", portainerPassword);
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginPortainer(loginPortainerBody));
try {
Response res = future.get(1, TimeUnit.SECONDS);
StringWriter writer = new StringWriter();
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
String str = writer.toString();
if (!JSON.isValid(str)) {
return exceptionResponse(exchange, str, res.status());
}
JSONObject resJsonObject = JSONObject.parseObject(str);
portainerToken = resJsonObject.getString("jwt");
if (portainerToken == null) {
return exceptionResponse(exchange, str, res.status());
}
String[] tokenSplit = portainerToken.split("\\.");
String tokenBodyStr = new String(Base64.getDecoder().decode(tokenSplit[1]), StandardCharsets.UTF_8);
JSONObject tokenBody = JSONObject.parseObject(tokenBodyStr);
Long expiration = tokenBody.getLong("exp");
Long now = new Date().getTime() / 1000;
for (int i = 0; i < 5; i++) {
// 网关采用异步架构所以此处需要通过异步请求获取Portainer Token
JSONObject loginPortainerBody = new JSONObject();
loginPortainerBody.put("username", portainerUsername);
loginPortainerBody.put("password", portainerPassword);
Future<Response> future = threadPoolExecutor.submit(() -> remoteGatewayService.loginPortainer(loginPortainerBody));
try {
Response res = future.get(1, TimeUnit.SECONDS);
StringWriter writer = new StringWriter();
IOUtils.copy(res.body().asInputStream(), writer, StandardCharsets.UTF_8.name());
String str = writer.toString();
if (!JSON.isValid(str)) {
return exceptionResponse(exchange, str, res.status());
}
JSONObject resJsonObject = JSONObject.parseObject(str);
portainerToken = resJsonObject.getString("jwt");
if (portainerToken == null) {
return exceptionResponse(exchange, str, res.status());
}
String[] tokenSplit = portainerToken.split("\\.");
String tokenBodyStr = new String(Base64.getDecoder().decode(tokenSplit[1]), StandardCharsets.UTF_8);
JSONObject tokenBody = JSONObject.parseObject(tokenBodyStr);
Long expiration = tokenBody.getLong("exp");
Long now = new Date().getTime() / 1000;
long portainerTokenTtl = expiration - now;
if (portainerTokenTtl > 20) {
redisService.setCacheObject(CacheConstants.PORTAINER_TOKEN, portainerToken, portainerTokenTtl - 10, TimeUnit.SECONDS);
long portainerTokenTtl = expiration - now;
if (portainerTokenTtl > 20) {
redisService.setCacheObject(CacheConstants.PORTAINER_TOKEN, portainerToken, portainerTokenTtl - 10, TimeUnit.SECONDS);
}
} catch (TimeoutException e) {
log.error("获取Portainer Token超时");
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
log.error("获取Portainer Token失败{}", e.getMessage());
}
} catch (TimeoutException e) {
log.error("获取Portainer Token超时");
} catch (InterruptedException | ExecutionException | IOException | NullPointerException e) {
log.error("获取Portainer Token失败{}", e.getMessage());
if (StringUtils.isNotEmpty(portainerToken)) {
break;
}
log.warn("获取Portainer Token失败进行第{}次重试中", i + 1);
}
}
if (StringUtils.isNotEmpty(portainerToken)) {
@ -280,7 +310,7 @@ public class ThirdPartyToolServiceImpl implements ThirdPartyToolService {
String[] cookies = StringUtils.split(cookie, ';');
for (String cookieItem : cookies) {
if (cookieItem.contains(key)) {
String token = StringUtils.remove(cookieItem, key+"=");
String token = StringUtils.remove(cookieItem, key + "=");
return StringUtils.remove(token, " ");
}
}

View File

@ -0,0 +1,125 @@
package com.microservices.dms.achievementLibrary.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import com.microservices.system.api.domain.SysDictData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.dms.achievementLibrary.domain.AchievementDictData;
import com.microservices.dms.achievementLibrary.service.IAchievementDictDataService;
import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.utils.poi.ExcelUtil;
import com.microservices.common.core.web.page.TableDataInfo;
/**
* 成果相关字典Controller
*
* @author microservices
* @date 2025-05-23
*/
@Api(tags = "数据管理体系-成果字典管理")
@RestController
@RequestMapping("/achDict")
public class AchievementDictDataController extends BaseController
{
@Autowired
private IAchievementDictDataService achievementDictDataService;
/**
* 查询成果相关字典列表
*/
@GetMapping("/list")
public TableDataInfo list(AchievementDictData achievementDictData)
{
startPage();
List<AchievementDictData> list = achievementDictDataService.selectAchievementDictDataList(achievementDictData);
return getDataTable(list);
}
/**
* 导出成果相关字典列表
*/
@Log(title = "成果相关字典", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AchievementDictData achievementDictData)
{
List<AchievementDictData> list = achievementDictDataService.selectAchievementDictDataList(achievementDictData);
ExcelUtil<AchievementDictData> util = new ExcelUtil<AchievementDictData>(AchievementDictData.class);
util.exportExcel(response, list, "成果相关字典数据");
}
/**
* 获取成果相关字典详细信息
*/
@GetMapping(value = "/{dictCode}")
public AjaxResult getInfo(@PathVariable("dictCode") Long dictCode)
{
return success(achievementDictDataService.selectAchievementDictDataByDictCode(dictCode));
}
/**
* 新增成果相关字典
*/
@Log(title = "成果相关字典", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AchievementDictData achievementDictData)
{
return toAjax(achievementDictDataService.insertAchievementDictData(achievementDictData));
}
/**
* 修改成果相关字典
*/
@Log(title = "成果相关字典", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AchievementDictData achievementDictData)
{
return toAjax(achievementDictDataService.updateAchievementDictData(achievementDictData));
}
/**
* 删除成果相关字典
*/
@Log(title = "成果相关字典", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes)
{
return toAjax(achievementDictDataService.deleteAchievementDictDataByDictCodes(dictCodes));
}
/**
* 根据字典类型查询字典数据信息
*/
@ApiOperation("根据成果字典分类查询成果值")
@GetMapping(value = "/getDictDateByType")
public AjaxResult getDictDateByType(String dictType)
{
List<KeyValueVo> data = achievementDictDataService.selectDictDataByType(dictType);
return success(data);
}
@ApiOperation("根据成果字典分类")
@GetMapping(value = "/getDictTypes")
public AjaxResult getDictTypes()
{
List<String> data = achievementDictDataService.getDictTypes();
return success(data);
}
}

View File

@ -210,8 +210,9 @@ public class AchievementsController extends BaseController {
}
@ApiOperation("根据成果ID获取近7日成果点击数量折线图")
@GetMapping("/get7AddClickById")
public AjaxResult get7AddClickById(String id) {
return success(achievementsService.get7AddClickById(id));
public AjaxResult get7AddClickById(String id,@RequestParam(value = "clickType",required = false, defaultValue = "Achievements")
String clickType) {
return success(achievementsService.get7AddClickById(id,clickType));
}
@ApiOperation("根据成果ID,获取成果的相关行为数据统计(点击量、搜索量、附件下载量、收藏、关注)")
@ -219,10 +220,8 @@ public class AchievementsController extends BaseController {
public AjaxResult getActDataStatisticById(Long id) {
return success(achievementsService.getActDataStatisticById(id));
}
/**
* 根据领域将成果数据进行分类
*
*/
@ApiOperation("根据领域,将成果数据进行分类")
@GetMapping("/getAreaStatistic")
public AjaxResult getAreaStatistic(String areaKey)
{
@ -239,6 +238,36 @@ public class AchievementsController extends BaseController {
return success(achievementsService.getRelatedAch(id,sourceId));
}
@ApiOperation(value = "获取开源竞赛的相关成果")
@GetMapping("/getRelatedAchCompetition")
public AjaxResult getRelatedAchCompetition(Long id,Long sourceId)
{
return success(achievementsService.getRelatedAchCompetition(id,sourceId));
}
@ApiOperation(value = "获取创客任务的相关成果")
@GetMapping("/getRelatedAchTask")
public AjaxResult getRelatedAchTask(Long id,Long sourceId)
{
return success(achievementsService.getRelatedAchTask(id,sourceId));
}
@ApiOperation(value = "获取专家-创客任务的相关成果")
@GetMapping("/getRelatedAchTaskOfExpert")
public AjaxResult getRelatedAchTaskOfExpert(Long expertId)
{
return success(achievementsService.getRelatedAchTaskOfExpert(expertId));
}
@ApiOperation(value = "获取专家-开源竞赛的相关成果")
@GetMapping("/getRelatedAchCompetitionOfExpert")
public AjaxResult getRelatedAchCompetitionOfExpert(Long expertId)
{
return success(achievementsService.getRelatedAchCompetitionOfExpert(expertId));
}
@ApiOperation(value = "搜索行为数据记录")
@GetMapping("/getSearchResult")
public AjaxResult getSearchResult(String achName,Long userId)

View File

@ -0,0 +1,31 @@
package com.microservices.dms.achievementLibrary.controller;
import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.page.TableDataInfo;
import com.microservices.dms.achievementLibrary.domain.TokenListVo;
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/blockChain")
@Api(tags = "数据产权子系统")
public class BlockChainController extends BaseController {
@Autowired
private IAchievementsService achievementsService;
// @GetMapping("/projectTokenList")
// @ApiOperation(value = "项目token列表")
// public TableDataInfo projectTokenList() {
// startPage();
// List<TokenListVo> list = achievementsService.projectTokenList();
// return getDataTable(list);
// }
}

View File

@ -37,7 +37,7 @@ public class ExpertDashboardController {
}
@GetMapping(value = "getExpertAduit")
@ApiOperation(value = "近一年专家评审作品数")
@ApiOperation(value = "专家评审作品数排序")
public AjaxResult getExpertAduit() {
return AjaxResult.success(expertDashboardService.getExpertAduit());
}

View File

@ -36,25 +36,25 @@ public class MemoDashboardController {
return AjaxResult.success(memoDashboardService.getMemoTotalByYear());
}
@GetMapping(value = "getForumSectionStatistic(")
@GetMapping(value = "getForumSectionStatistic")
@ApiOperation(value = "帖子分类")
public AjaxResult getForumSectionStatistic() {
return AjaxResult.success(memoDashboardService.getForumSectionStatistic());
}
@GetMapping(value = "getAddMemoStatistic(")
@GetMapping(value = "getAddMemoStatistic")
@ApiOperation(value = "近一年新增帖子数")
public AjaxResult getAddMemoStatistic() {
return AjaxResult.success(memoDashboardService.getAddMemoStatistic());
}
@GetMapping(value = "getTop5Memos(")
@GetMapping(value = "getTop5Memos")
@ApiOperation(value = "年度帖子热度top5")
public AjaxResult getTop5Memos() {
return AjaxResult.success(memoDashboardService.getTop5Memos());
}
@GetMapping(value = "get7DayPaise(")
@GetMapping(value = "get7DayPaise")
@ApiOperation(value = "近7日帖子点赞数")
public AjaxResult get7DayPaise() {
return AjaxResult.success(memoDashboardService.get7DayPaise());

View File

@ -43,6 +43,17 @@ public class SchoolEnterpriseAchievementsController extends BaseController
return getDataTable(list);
}
/**
* 查询校企成果列表
*/
@GetMapping("/listFront")
public TableDataInfo listFront(SchoolEnterpriseAchievements schoolEnterpriseAchievements)
{
startPage();
List<SchoolEnterpriseAchievements> list = schoolEnterpriseAchievementsService.listFront(schoolEnterpriseAchievements);
return getDataTable(list);
}
/**
* 导出校企成果列表
*/

View File

@ -6,6 +6,7 @@ public class AchQueryVo {
private String source;//来源
private String achievementName;//名称
private Long userId;
private String showAchievementName;
public String getAreaQuery() {
return areaQuery;
}
@ -29,4 +30,20 @@ public class AchQueryVo {
public void setAchievementName(String achievementName) {
this.achievementName = achievementName;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getShowAchievementName() {
return showAchievementName;
}
public void setShowAchievementName(String showAchievementName) {
this.showAchievementName = showAchievementName;
}
}

View File

@ -9,6 +9,7 @@ public class AchRelatedVo {
private String source;
private Long sourceId;
private String achRelateName;
private String showAchievementName;
public Long getId() {
return id;
@ -73,4 +74,12 @@ public class AchRelatedVo {
public void setAchRelateName(String achRelateName) {
this.achRelateName = achRelateName;
}
public String getShowAchievementName() {
return showAchievementName;
}
public void setShowAchievementName(String showAchievementName) {
this.showAchievementName = showAchievementName;
}
}

View File

@ -0,0 +1,112 @@
package com.microservices.dms.achievementLibrary.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.microservices.common.core.annotation.Excel;
import com.microservices.common.core.web.domain.BaseEntity;
/**
* 成果相关字典对象 achievement_dict_data
*
* @author microservices
* @date 2025-05-23
*/
public class AchievementDictData extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 字典编码 */
private Long dictCode;
/** 字典排序 */
@Excel(name = "字典排序")
private Integer dictSort;
/** 字典标签 */
@Excel(name = "字典标签")
private String dictLabel;
/** 字典键值 */
@Excel(name = "字典键值")
private String dictValue;
/** 字典类型 */
@Excel(name = "字典类型")
private String dictType;
/** 状态0正常 1停用 */
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status;
public void setDictCode(Long dictCode)
{
this.dictCode = dictCode;
}
public Long getDictCode()
{
return dictCode;
}
public void setDictSort(Integer dictSort)
{
this.dictSort = dictSort;
}
public Integer getDictSort()
{
return dictSort;
}
public void setDictLabel(String dictLabel)
{
this.dictLabel = dictLabel;
}
public String getDictLabel()
{
return dictLabel;
}
public void setDictValue(String dictValue)
{
this.dictValue = dictValue;
}
public String getDictValue()
{
return dictValue;
}
public void setDictType(String dictType)
{
this.dictType = dictType;
}
public String getDictType()
{
return dictType;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("dictCode", getDictCode())
.append("dictSort", getDictSort())
.append("dictLabel", getDictLabel())
.append("dictValue", getDictValue())
.append("dictType", getDictType())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -2,6 +2,7 @@ package com.microservices.dms.achievementLibrary.domain;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
@ -29,6 +30,10 @@ public class Achievements extends BaseEntity {
*/
@Excel(name = "成果名称")
private String achievementName;
/**
* 成果展示名称
*/
private String showAchievementName;
/**
* 成果领域1
@ -181,6 +186,23 @@ public class Achievements extends BaseEntity {
private String userNickName;
public String gender;
private String userLogin;
private List<Map<String,Object>> dockingUserInfo;
public List<Map<String, Object>> getDockingUserInfo() {
return dockingUserInfo;
}
public void setDockingUserInfo(List<Map<String, Object>> dockingUserInfo) {
this.dockingUserInfo = dockingUserInfo;
}
public String getShowAchievementName() {
return showAchievementName;
}
public void setShowAchievementName(String showAchievementName) {
this.showAchievementName = showAchievementName;
}
public String getUserImg() {
return userImg;
@ -480,38 +502,4 @@ public class Achievements extends BaseEntity {
return attachments;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("achievementName", getAchievementName())
.append("field1", getField1())
.append("field2", getField2())
.append("field3", getField3())
.append("achievementType", getAchievementType())
.append("source", getSource())
.append("sourceId", getSourceId())
.append("sourceLink", getSourceLink())
.append("tags", getTags())
.append("summary", getSummary())
.append("publishingUnit", getPublishingUnit())
.append("address", getAddress())
.append("isFeatured", getIsFeatured())
.append("contactPerson", getContactPerson())
.append("contactNumber", getContactNumber())
.append("ownerId", getOwnerId())
.append("ownerName", getOwnerName())
.append("status", getStatus())
.append("details", getDetails())
.append("reviewer", getReviewer())
.append("reviewDate", getReviewDate())
.append("reviewComments", getReviewComments())
.append("images", getImages())
.append("attachments", getAttachments())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,95 @@
package com.microservices.dms.achievementLibrary.domain;
public class HotAchVo {
private int watcher;
private int faviter;
private int total;
private String gender;
private String name;
private String showAchievementName;
private Long id;
private String userNickName;
private String userName;
private String userImg;
public String getUserImg() {
return userImg;
}
public void setUserImg(String userImg) {
this.userImg = userImg;
}
public int getWatcher() {
return watcher;
}
public void setWatcher(int watcher) {
this.watcher = watcher;
}
public int getFaviter() {
return faviter;
}
public void setFaviter(int faviter) {
this.faviter = faviter;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUserNickName() {
return userNickName;
}
public void setUserNickName(String userNickName) {
this.userNickName = userNickName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getShowAchievementName() {
return showAchievementName;
}
public void setShowAchievementName(String showAchievementName) {
this.showAchievementName = showAchievementName;
}
}

View File

@ -1,6 +1,7 @@
package com.microservices.dms.achievementLibrary.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -167,6 +168,46 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
@Excel(name = "成果附件")
private String attachments;
private Integer achievementStatus;
//成果小类型
private String achievementLittleType;
//成果状态
private String achievementCurStatus;
//团队名称
private String teamName;
private List<AchievementTeam> teamList;
public List<AchievementTeam> getTeamList() {
return teamList;
}
public void setTeamList(List<AchievementTeam> teamList) {
this.teamList = teamList;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
public String getAchievementLittleType() {
return achievementLittleType;
}
public void setAchievementLittleType(String achievementLittleType) {
this.achievementLittleType = achievementLittleType;
}
public String getAchievementCurStatus() {
return achievementCurStatus;
}
public void setAchievementCurStatus(String achievementCurStatus) {
this.achievementCurStatus = achievementCurStatus;
}
public Integer getAchievementStatus() {
return achievementStatus;

View File

@ -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; // 项目创建时间以毫秒为单位
}

View File

@ -0,0 +1,74 @@
package com.microservices.dms.achievementLibrary.mapper;
import java.util.List;
import com.microservices.common.datasource.annotation.Slave;
import com.microservices.dms.achievementLibrary.domain.AchievementDictData;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 成果相关字典Mapper接口
*
* @author microservices
* @date 2025-05-23
*/
@Mapper
@Slave
public interface AchievementDictDataMapper
{
/**
* 查询成果相关字典
*
* @param dictCode 成果相关字典主键
* @return 成果相关字典
*/
public AchievementDictData selectAchievementDictDataByDictCode(Long dictCode);
/**
* 查询成果相关字典列表
*
* @param achievementDictData 成果相关字典
* @return 成果相关字典集合
*/
public List<AchievementDictData> selectAchievementDictDataList(AchievementDictData achievementDictData);
/**
* 新增成果相关字典
*
* @param achievementDictData 成果相关字典
* @return 结果
*/
public int insertAchievementDictData(AchievementDictData achievementDictData);
/**
* 修改成果相关字典
*
* @param achievementDictData 成果相关字典
* @return 结果
*/
public int updateAchievementDictData(AchievementDictData achievementDictData);
/**
* 删除成果相关字典
*
* @param dictCode 成果相关字典主键
* @return 结果
*/
public int deleteAchievementDictDataByDictCode(Long dictCode);
/**
* 批量删除成果相关字典
*
* @param dictCodes 需要删除的数据主键集合
* @return 结果
*/
public int deleteAchievementDictDataByDictCodes(Long[] dictCodes);
List<KeyValueVo> selectDictDataByType(@Param("dictType") String dictType);
int selectDictDataByLabel(@Param("label") String label,@Param("type") String type);
List<String> getDictTypes();
}

View File

@ -66,4 +66,6 @@ public interface AchievementTeamMapper
public int deleteAchievementTeamByIds(Long[] ids);
void deleteAchievementTeamByAId(@Param("aid") Long aid);
List<AchievementTeam> selectAchievementTeamByAchId(@Param("achId") Long achId);
}

View File

@ -1,14 +1,13 @@
package com.microservices.dms.achievementLibrary.mapper;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import com.microservices.common.datasource.annotation.Master;
import com.microservices.common.datasource.annotation.Slave;
import com.microservices.dms.achievementLibrary.domain.*;
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
@ -91,7 +90,7 @@ public interface AchievementsMapper {
List<KeyValVo<String, Long>> getAchievement(@Param("s") Date s, @Param("e") Date e, @Param("t") String source);
List<Map<String, String>> getHotAchievement();
List<HotAchVo> getHotAchievement();
Map<String, Long> indexProjectStatistic();
@ -115,7 +114,7 @@ public interface AchievementsMapper {
List<Map<String, Object>> getAchievementType();
List<KeyValueVo> getAchievementActData();
List<KeyValueVo> getAchievementActData(@Param("s") Date s, @Param("e") Date e);
List<Map<String, Object>> getAchievementDomain();
@ -140,4 +139,23 @@ public interface AchievementsMapper {
List<String> getExpertAreasByName(@Param("areaName") String areaName);
List<Long> getAllSourceId(@Param("id")Long id, @Param("sourceId")Long sourceId);
List<Long> getAllSourceIdCompetition(@Param("id")Long id, @Param("sourceId")Long sourceId);
List<Long> getAllSourceIdTask(@Param("id")Long id, @Param("sourceId")Long sourceId);
List<TaskResourceLibrary> getRelatedAchTaskOfExpert(@Param("id")Long id);
List<CompetitionResourceLibrary> getRelatedAchCompetitionOfExpert(@Param("id")Long id);
List<KeyValVo<String,Long>> getAchievementAddYearlyData(@Param("s") Date s, @Param("e") Date e);
List<KeyValueVo> getAchievementActDataW(@Param("s") Date s, @Param("e") Date e);
List<KeyValueVo> getAchievementActDataC(@Param("s") Date s, @Param("e") Date e);
List<KeyValueVo> getAchievementActDataD(@Param("s") Date s, @Param("e") Date e);
List<KeyValueVo> getAchievementActDataF(@Param("s") Date s, @Param("e") Date e);
List<Map<String, Object>> getDockingUserInfo(@Param("id") Long id);
}

View File

@ -1,5 +1,6 @@
package com.microservices.dms.achievementLibrary.service;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import com.microservices.dms.achievementLibrary.mapper.AchievementsMapper;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
@ -23,7 +24,7 @@ public class BigScreenStatisticService {
Date[] days = DateUtil.getDays(0, 6);
Map<String, Long> m = achievementsMapper.getAchievement(days[0], days[1], source)
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrYYYYMMDD(days[0], days[1]);
List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
Date[] lastDays = DateUtil.getDays(7, 13);
long lastSum = Optional.ofNullable(achievementsMapper.countAchievementBySource(lastDays[0], lastDays[1], source)).orElse(0L);
long sum = Optional.ofNullable(achievementsMapper.countAchievementBySource(null, null, source)).orElse(0L);
@ -58,18 +59,99 @@ public class BigScreenStatisticService {
return achievementsMapper.getAchievementType();
}
public Map<String, List<KeyValueVo>> getAchievementActData() {
List<KeyValueVo> list = achievementsMapper.getAchievementActData();
Map<String, List<KeyValueVo>> res = list.stream().collect(Collectors.groupingBy(KeyValueVo::getKey));
return res;
public List<Map<String,Object>> getAchievementActData() {
Date[] days = DateUtil.getDays(0, 6);
Map<String, Long> wlist = achievementsMapper.getAchievementActDataW(days[0], days[1]).stream().collect(Collectors.toMap(KeyValueVo::getName, KeyValueVo::getValue));
Map<String, Long> clist = achievementsMapper.getAchievementActDataC(days[0], days[1]).stream().collect(Collectors.toMap(KeyValueVo::getName, KeyValueVo::getValue));
Map<String, Long> dlist = achievementsMapper.getAchievementActDataD(days[0], days[1]).stream().collect(Collectors.toMap(KeyValueVo::getName, KeyValueVo::getValue));
Map<String, Long> flist = achievementsMapper.getAchievementActDataF(days[0], days[1]).stream().collect(Collectors.toMap(KeyValueVo::getName, KeyValueVo::getValue));
List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
List<KeyValueVo> wres = new ArrayList<>();
List<KeyValueVo> cres = new ArrayList<>();
List<KeyValueVo> dres = new ArrayList<>();
List<KeyValueVo> fres = new ArrayList<>();
for (String s : dateStr) {
Long a = wlist.getOrDefault(s, 0L);
KeyValueVo k1 = new KeyValueVo();
k1.setKey(s);
k1.setValue(a);
k1.setName("关注");
wres.add(k1);
}
for (String s : dateStr) {
Long a = clist.getOrDefault(s, 0L);
KeyValueVo k1 = new KeyValueVo();
k1.setKey(s);
k1.setValue(a);
k1.setName("浏览");
cres.add(k1);
}
for (String s : dateStr) {
Long a = dlist.getOrDefault(s, 0L);
KeyValueVo k1 = new KeyValueVo();
k1.setKey(s);
k1.setValue(a);
k1.setName("下载");
dres.add(k1);
}
for (String s : dateStr) {
Long a = flist.getOrDefault(s, 0L);
KeyValueVo k1 = new KeyValueVo();
k1.setKey(s);
k1.setValue(a);
k1.setName("收藏");
fres.add(k1);
}
List<Map<String, Object>> r = new ArrayList<>();
Map<String, Object> w = new HashMap<>();
w.put("key", "关注");
w.put("value", wres);
Map<String, Object> c = new HashMap<>();
c.put("key","浏览");
c.put("value", cres);
Map<String, Object> d = new HashMap<>();
d.put("key","下载");
d.put("value", dres);
Map<String, Object> f = new HashMap<>();
f.put("key", "收藏");
f.put("value", fres);
r.add(w);
r.add(c);
r.add(d);
r.add(f);
return r;
}
public List<Map<String, Object>> getAchievementDomain() {
return achievementsMapper.getAchievementDomain();
}
public List<Map<String, Object>> getAchievementAddYearly() {
return achievementsMapper.getAchievementAddYearly();
public Object getAchievementAddYearly() {
Date[] currentYear = DateUtil.getLast12Months();
Map<String, Long> m = achievementsMapper.getAchievementAddYearlyData(currentYear[0],currentYear[1])
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrYYYYMM(currentYear[0], currentYear[1]);
List<KeyValVo<String, Long>> res = new ArrayList<>();
for (String s : dateStr) {
Long a = m.getOrDefault(s, 0L);
KeyValVo<String, Long> k1 = new KeyValVo<>();
k1.setK(s);
k1.setV(a);
res.add(k1);
}
return res;
}
public List<Map<String, Object>> getAchievementHotRank() {
@ -102,11 +184,11 @@ public class BigScreenStatisticService {
}
public List<KeyValVo<String, Long>> getCompetitionYearlyPaperAdd() {
Date[] currentYear = DateUtil.getCurrentYear();
Date[] currentYear = DateUtil.getLast12Months();
Map<String, Long> m = competitionResourceLibraryMapper.getCompetitionYearlyPaperAdd(currentYear[0],currentYear[1])
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrMMDD(currentYear[0], currentYear[1]);
List<String> dateStr = DateUtil.getDateStrYYYYMM(currentYear[0], currentYear[1]);
List<KeyValVo<String, Long>> res = new ArrayList<>();
for (String s : dateStr) {
Long a = m.getOrDefault(s, 0L);
@ -119,12 +201,11 @@ public class BigScreenStatisticService {
}
public List<KeyValVo<String, Long>> getCompetitionYearlyFinish() {
Date[] currentYear = DateUtil.getCurrentYear();
Date[] YearEndOfCur = DateUtil.getCurrentYearEndOf(LocalDate.now());
Date[] currentYear = DateUtil.getLast12Months();
Map<String, Long> m = competitionResourceLibraryMapper.getCompetitionYearlyFinish(YearEndOfCur[0],YearEndOfCur[1])
Map<String, Long> m = competitionResourceLibraryMapper.getCompetitionYearlyFinish(currentYear[0],currentYear[1])
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrMMDD(currentYear[0], currentYear[1]);
List<String> dateStr = DateUtil.getDateStrYYYYMM(currentYear[0], currentYear[1]);
List<KeyValVo<String, Long>> res = new ArrayList<>();
for (String s : dateStr) {
Long a = m.getOrDefault(s, 0L);

View File

@ -0,0 +1,67 @@
package com.microservices.dms.achievementLibrary.service;
import java.util.List;
import com.microservices.dms.achievementLibrary.domain.AchievementDictData;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import org.apache.ibatis.annotations.Param;
/**
* 成果相关字典Service接口
*
* @author microservices
* @date 2025-05-23
*/
public interface IAchievementDictDataService
{
/**
* 查询成果相关字典
*
* @param dictCode 成果相关字典主键
* @return 成果相关字典
*/
public AchievementDictData selectAchievementDictDataByDictCode(Long dictCode);
/**
* 查询成果相关字典列表
*
* @param achievementDictData 成果相关字典
* @return 成果相关字典集合
*/
public List<AchievementDictData> selectAchievementDictDataList(AchievementDictData achievementDictData);
/**
* 新增成果相关字典
*
* @param achievementDictData 成果相关字典
* @return 结果
*/
public int insertAchievementDictData(AchievementDictData achievementDictData);
/**
* 修改成果相关字典
*
* @param achievementDictData 成果相关字典
* @return 结果
*/
public int updateAchievementDictData(AchievementDictData achievementDictData);
/**
* 批量删除成果相关字典
*
* @param dictCodes 需要删除的成果相关字典主键集合
* @return 结果
*/
public int deleteAchievementDictDataByDictCodes(Long[] dictCodes);
/**
* 删除成果相关字典信息
*
* @param dictCode 成果相关字典主键
* @return 结果
*/
public int deleteAchievementDictDataByDictCode(Long dictCode);
List<KeyValueVo> selectDictDataByType(String dictType);
List<String> getDictTypes();
}

View File

@ -5,6 +5,8 @@ import java.util.Map;
import com.microservices.dms.achievementLibrary.domain.*;
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
/**
@ -76,7 +78,7 @@ public interface IAchievementsService {
Map<String, Object> getUerActionData();
List<Map<String, String>> getHotAchievement();
List<HotAchVo> getHotAchievement();
List<KeyValVo<String, Long>> get7DayAdd(AchQueryVo achQueryVo);
@ -94,7 +96,7 @@ public interface IAchievementsService {
AchievementBehaviorSumVo getActDataStatisticById(Long id);
List<KeyValVo<String, Long>> get7AddClickById(String id);
List<KeyValVo<String, Long>> get7AddClickById(String id, String clickType);
AchievementBehaviorSumVo getWatchFavoriteStatusById(Long id, Long userId);
@ -107,4 +109,12 @@ public interface IAchievementsService {
List<KeyValueVo> getProjectAreasByName(String areaName);
List<String> getExpertAreasByName(String areaName);
List<AchRelatedResult> getRelatedAchCompetition(Long id, Long sourceId);
List<AchRelatedResult> getRelatedAchTask(Long id, Long sourceId);
List<TaskResourceLibrary> getRelatedAchTaskOfExpert(Long id);
List<CompetitionResourceLibrary> getRelatedAchCompetitionOfExpert(Long id);
}

View File

@ -60,4 +60,6 @@ public interface ISchoolEnterpriseAchievementsService
public int deleteSchoolEnterpriseAchievementsById(Long id);
Long topStatistic(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
List<SchoolEnterpriseAchievements> listFront(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
}

View File

@ -1,5 +1,6 @@
package com.microservices.dms.achievementLibrary.service;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.dms.achievementLibrary.domain.AchQueryVo;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import com.microservices.dms.achievementLibrary.domain.MemoTotalVo;
@ -33,7 +34,7 @@ public class MemoDashboardService {
* 原创非原创
* @return
*/
public KeyValueVo getIsOriginalStatistic() {
public List<KeyValueVo> getIsOriginalStatistic() {
return memoResourceLibraryMapper.getIsOriginalStatistic();
}
@ -74,7 +75,7 @@ public class MemoDashboardService {
* @return
*/
public List<KeyValVo<String, Long>> get7DayPaise() {
Date[] days = DateUtil.getDays(1, 7);
Date[] days = DateUtil.getDays(0, 6);
Map<String, Long> w = memoResourceLibraryMapper.get7DayPaise(days[0], days[1])
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));

View File

@ -0,0 +1,116 @@
package com.microservices.dms.achievementLibrary.service.impl;
import java.util.Collections;
import java.util.List;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.microservices.dms.achievementLibrary.mapper.AchievementDictDataMapper;
import com.microservices.dms.achievementLibrary.domain.AchievementDictData;
import com.microservices.dms.achievementLibrary.service.IAchievementDictDataService;
/**
* 成果相关字典Service业务层处理
*
* @author microservices
* @date 2025-05-23
*/
@Service
public class AchievementDictDataServiceImpl implements IAchievementDictDataService
{
@Autowired
private AchievementDictDataMapper achievementDictDataMapper;
/**
* 查询成果相关字典
*
* @param dictCode 成果相关字典主键
* @return 成果相关字典
*/
@Override
public AchievementDictData selectAchievementDictDataByDictCode(Long dictCode)
{
return achievementDictDataMapper.selectAchievementDictDataByDictCode(dictCode);
}
/**
* 查询成果相关字典列表
*
* @param achievementDictData 成果相关字典
* @return 成果相关字典
*/
@Override
public List<AchievementDictData> selectAchievementDictDataList(AchievementDictData achievementDictData)
{
return achievementDictDataMapper.selectAchievementDictDataList(achievementDictData);
}
/**
* 新增成果相关字典
*
* @param achievementDictData 成果相关字典
* @return 结果
*/
@Override
public int insertAchievementDictData(AchievementDictData achievementDictData)
{
//判断字典是否存在存在则不管不存在则新增
String label = achievementDictData.getDictLabel();
String type = achievementDictData.getDictType();
int num = achievementDictDataMapper.selectDictDataByLabel(label,type);
if (num > 0){
return 0;
}else{
achievementDictData.setCreateTime(DateUtils.getNowDate());
return achievementDictDataMapper.insertAchievementDictData(achievementDictData);
}
}
/**
* 修改成果相关字典
*
* @param achievementDictData 成果相关字典
* @return 结果
*/
@Override
public int updateAchievementDictData(AchievementDictData achievementDictData)
{
achievementDictData.setUpdateTime(DateUtils.getNowDate());
return achievementDictDataMapper.updateAchievementDictData(achievementDictData);
}
/**
* 批量删除成果相关字典
*
* @param dictCodes 需要删除的成果相关字典主键
* @return 结果
*/
@Override
public int deleteAchievementDictDataByDictCodes(Long[] dictCodes)
{
return achievementDictDataMapper.deleteAchievementDictDataByDictCodes(dictCodes);
}
/**
* 删除成果相关字典信息
*
* @param dictCode 成果相关字典主键
* @return 结果
*/
@Override
public int deleteAchievementDictDataByDictCode(Long dictCode)
{
return achievementDictDataMapper.deleteAchievementDictDataByDictCode(dictCode);
}
@Override
public List<KeyValueVo> selectDictDataByType(String dictType) {
return achievementDictDataMapper.selectDictDataByType(dictType);
}
@Override
public List<String> getDictTypes() {
return achievementDictDataMapper.getDictTypes();
}
}

View File

@ -5,20 +5,25 @@ 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;
import com.microservices.dms.behaviorImage.domain.AchievementImageVo;
import com.microservices.dms.behaviorImage.service.IBehaviorImageService;
import com.microservices.dms.resourceLibrary.domain.Clicker;
import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.Searcher;
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
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;
@ -26,6 +31,7 @@ import org.springframework.stereotype.Service;
import com.microservices.dms.achievementLibrary.mapper.AchievementsMapper;
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
import static com.microservices.dms.constant.BlockChainFunConstants.QUERY_REPO;
import static com.microservices.dms.utils.UrlUtil.getUrlPath;
/**
@ -35,6 +41,7 @@ import static com.microservices.dms.utils.UrlUtil.getUrlPath;
* @date 2025-04-02
*/
@Service
@Slf4j
public class AchievementsServiceImpl implements IAchievementsService {
@Autowired
private AchievementsMapper achievementsMapper;
@ -45,9 +52,6 @@ public class AchievementsServiceImpl implements IAchievementsService {
@Autowired
private ExpertResourceLibraryMapper expertResourceLibraryMapper;
@Autowired
private ProjectResourceLibraryMapper projectResourceLibraryMapper;
@Autowired
private IBehaviorImageService behaviorImageService;
@ -60,7 +64,6 @@ public class AchievementsServiceImpl implements IAchievementsService {
@Value("${http.gatewayUrl}")
public String gatewayUrl;
/**
* 查询成果
*
@ -70,20 +73,25 @@ public class AchievementsServiceImpl implements IAchievementsService {
@Override
public Achievements selectAchievementsById(Long id) {
Achievements a = achievementsMapper.selectAchievementsById(id);
if(StringUtils.isNotNull(a)){
if (StringUtils.isNotNull(a)) {
String gender = a.getGender();
String img = "images/avatars/User/boy.jpg";
if(StringUtils.isNotEmpty(gender) && gender.equals("1")){
String img = "";
if (StringUtils.isNotEmpty(gender) && gender.equals("1")) {
img = "images/avatars/User/girl.jpg";
} else if (StringUtils.isNotEmpty(gender) && gender.equals("0")) {
img = "images/avatars/User/boy.jpg";
}
a.setUserImg(img);
if(StringUtils.isNotEmpty(a.getField1())) {
if (StringUtils.isNotEmpty(a.getField1())) {
String field1Name = achievementsMapper.getField1NameByParam(a.getSource(), a.getId());
if (StringUtils.isNotNull(field1Name)) {
a.setField1Name(field1Name);
}
}
a.setUserImg(img);
a.setImages(buildFileInfoByIdents(a.getImages(), a.getSource()));
a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource()));
}
return a;
}
@ -99,13 +107,15 @@ public class AchievementsServiceImpl implements IAchievementsService {
List<Achievements> list = achievementsMapper.selectAchievementsList(achievements);
for (Achievements a : list) {
String gender = a.getGender();
String img = "images/avatars/User/boy.jpg";
if(StringUtils.isNotEmpty(gender) && gender.equals("1")){
String img = "";
if (StringUtils.isNotEmpty(gender) && gender.equals("1")) {
img = "images/avatars/User/girl.jpg";
} else if (StringUtils.isNotEmpty(gender) && gender.equals("0")) {
img = "images/avatars/User/boy.jpg";
}
a.setUserImg(img);
//根据id获取领域名称
if(StringUtils.isNotEmpty(a.getField1())) {
if (StringUtils.isNotEmpty(a.getField1())) {
String field1Name = achievementsMapper.getField1NameByParam(a.getSource(), a.getId());
if (StringUtils.isNotNull(field1Name)) {
a.setField1Name(field1Name);
@ -113,6 +123,10 @@ public class AchievementsServiceImpl implements IAchievementsService {
}
a.setImages(buildFileInfoByIdents(a.getImages(), a.getSource()));
a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource()));
//拼接对接的用户信息
List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfo(a.getId());
a.setDockingUserInfo(dockingUserInfo);
}
return list;
}
@ -183,25 +197,26 @@ 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);
concatUrl(list, gitLinkUrl);
}
if (Objects.equals(source, "2")) {
concatUrl(list,markerSpaceUrl);
concatUrl(list, markerSpaceUrl);
}
if (Objects.equals(source, "4")) {
concatUrl(list,gatewayUrl);
concatUrl(list, gatewayUrl);
}
return JSON.toJSONString(list);
}
private void concatUrl(List<Map<String, String>> list, String url) {
for (Map<String,String> map : list) {
for (Map<String, String> map : list) {
String v = map.getOrDefault("v", "");
String urlPath = getUrlPath(v);
map.put("v", url + urlPath);
@ -231,13 +246,15 @@ public class AchievementsServiceImpl implements IAchievementsService {
//遍历成果数据获取对应成果的点击数
for (Achievements a : list) {
String gender = a.getGender();
String img = "images/avatars/User/boy.jpg";
if(StringUtils.isNotEmpty(gender) && gender.equals("1")){
String img = "";
if (StringUtils.isNotEmpty(gender) && gender.equals("1")) {
img = "images/avatars/User/girl.jpg";
} else if (StringUtils.isNotEmpty(gender) && gender.equals("0")) {
img = "images/avatars/User/boy.jpg";
}
a.setUserImg(img);
//根据id获取领域名称
if(StringUtils.isEmpty(achQueryVo.getSource()) && StringUtils.isNotEmpty(a.getField1())) {
if (StringUtils.isEmpty(achQueryVo.getSource()) && StringUtils.isNotEmpty(a.getField1())) {
String field1Name = achievementsMapper.getField1NameByParam(a.getSource(), a.getId());
if (StringUtils.isNotNull(field1Name)) {
a.setField1Name(field1Name);
@ -281,8 +298,21 @@ public class AchievementsServiceImpl implements IAchievementsService {
}
@Override
public List<Map<String, String>> getHotAchievement() {
return achievementsMapper.getHotAchievement();
public List<HotAchVo> getHotAchievement() {
//根据查询条件获取所有的成果数据
List<HotAchVo> resultList = achievementsMapper.getHotAchievement();
//遍历成果数据获取对应成果的点击数
for (HotAchVo a : resultList) {
String gender = a.getGender();
String img = "";
if (StringUtils.isNotEmpty(gender) && gender.equals("1")) {
img = "images/avatars/User/girl.jpg";
} else if (StringUtils.isNotEmpty(gender) && gender.equals("0")) {
img = "images/avatars/User/boy.jpg";
}
a.setUserImg(img);
}
return resultList;
}
@Override
@ -313,7 +343,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
@Override
public Map<String, Object> indexTaskStatistic() {
Map<String, Object> res = achievementsMapper.indexTaskStatistic();
double convertedTaskAmount = taskResourceLibraryMapper.getConvertedTaskAmount();
double convertedTaskAmount = taskResourceLibraryMapper.getConvertedTaskAmount2();
res.put("convertedTaskAmount", convertedTaskAmount);
return res;
}
@ -367,10 +397,13 @@ public class AchievementsServiceImpl implements IAchievementsService {
}
@Override
public List<KeyValVo<String, Long>> get7AddClickById(String id) {
public List<KeyValVo<String, Long>> get7AddClickById(String id, String clickType) {
if (StringUtils.isEmpty(clickType)) {
clickType = "Achievements";
}
Date[] days = DateUtil.getDays(0, 6);
Map<String, Long> w = achievementsMapper.get7AddClickById(days[0], days[1], "Achievements", id)
Map<String, Long> w = achievementsMapper.get7AddClickById(days[0], days[1], clickType, id)
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
@ -429,6 +462,55 @@ public class AchievementsServiceImpl implements IAchievementsService {
return relatedResultList;
}
@Override
public List<AchRelatedResult> getRelatedAchCompetition(Long id, Long sourceId) {
List<AchRelatedResult> relatedResultList = new ArrayList<>();
//想根据开源项目id获取对应的年度信息
List<Long> allSourceId = achievementsMapper.getAllSourceIdCompetition(id, sourceId);
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
if (StringUtils.isNotNull(allYear)) {
//遍历年度信息获取年度成果数据
for (String paramYear : allYear) {
AchRelatedResult relatedResult = new AchRelatedResult();
relatedResult.setYear(paramYear);
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
relatedResult.setAchRelatedVoList(tmpList);
relatedResultList.add(relatedResult);
}
}
return relatedResultList;
}
@Override
public List<AchRelatedResult> getRelatedAchTask(Long id, Long sourceId) {
List<AchRelatedResult> relatedResultList = new ArrayList<>();
//想根据开源项目id获取对应的年度信息
List<Long> allSourceId = achievementsMapper.getAllSourceIdTask(id, sourceId);
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
if (StringUtils.isNotNull(allYear)) {
//遍历年度信息获取年度成果数据
for (String paramYear : allYear) {
AchRelatedResult relatedResult = new AchRelatedResult();
relatedResult.setYear(paramYear);
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
relatedResult.setAchRelatedVoList(tmpList);
relatedResultList.add(relatedResult);
}
}
return relatedResultList;
}
@Override
public List<TaskResourceLibrary> getRelatedAchTaskOfExpert(Long id) {
return achievementsMapper.getRelatedAchTaskOfExpert(id);
}
@Override
public List<CompetitionResourceLibrary> getRelatedAchCompetitionOfExpert(Long id) {
return achievementsMapper.getRelatedAchCompetitionOfExpert(id);
}
/**
* 根据查询内容调用搜索行为接口
*

View File

@ -1,14 +1,13 @@
package com.microservices.dms.achievementLibrary.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.common.security.utils.SecurityUtils;
import com.microservices.dms.achievementLibrary.domain.AchievementTeam;
import com.microservices.dms.achievementLibrary.domain.Achievements;
import com.microservices.dms.achievementLibrary.mapper.AchievementTeamMapper;
import com.microservices.dms.achievementLibrary.mapper.AchievementsMapper;
@ -49,7 +48,15 @@ public class SchoolEnterpriseAchievementsServiceImpl implements ISchoolEnterpris
@Override
public SchoolEnterpriseAchievements selectSchoolEnterpriseAchievementsById(Long id)
{
return schoolEnterpriseAchievementsMapper.selectSchoolEnterpriseAchievementsById(id);
SchoolEnterpriseAchievements sAchievements = schoolEnterpriseAchievementsMapper.selectSchoolEnterpriseAchievementsById(id);
if(StringUtils.isNotNull(sAchievements)){
Long achId = sAchievements.getId();
List<AchievementTeam> teamList = achievementTeamMapper.selectAchievementTeamByAchId(achId);
if(StringUtils.isNotNull(teamList) && teamList.size() > 0){
sAchievements.setTeamList(teamList);
}
}
return sAchievements;
}
/**
@ -74,6 +81,16 @@ public class SchoolEnterpriseAchievementsServiceImpl implements ISchoolEnterpris
return list;
}
@Override
public List<SchoolEnterpriseAchievements> listFront(SchoolEnterpriseAchievements schoolEnterpriseAchievements) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
String username = loginUser.getUsername();
schoolEnterpriseAchievements.setCreateBy(username);
}
return selectSchoolEnterpriseAchievementsList(schoolEnterpriseAchievements);
}
/**
* 新增校企成果
*

View File

@ -116,9 +116,8 @@ public class BehaviorImageController extends BaseController {
List<ActivityUserLibrary> list = behaviorImageService.selectActivityUserLibraryList(activityUserLibrary);
return getDataTable(list);
}
/**
* 根据用户ID,获取用户对应的成果汇总
*/
@ApiOperation("/根据用户ID,获取用户对应的成果汇总")
@GetMapping(value = "/getUserTypeStatistic")
public AjaxResult getUserTypeStatistic(@PathVariable("userId") Long userId)
{
@ -171,4 +170,12 @@ public class BehaviorImageController extends BaseController {
{
return AjaxResult.success(behaviorImageService.getActivityStatistic());
}
@GetMapping(value = "/getUserBehaviorSum")
@ApiOperation("获取用户的所有关注、点赞数")
public AjaxResult getUserBehaviorSum(Long userId)
{
return AjaxResult.success(behaviorImageService.getUserBehaviorSum(userId));
}
}

View File

@ -11,6 +11,16 @@ public class AchievementBehaviorSumVo {
private Long favoriteSum;
//下载量
private Long downloadSum;
//成果用户对接
private Long userDockingSum;
public Long getUserDockingSum() {
return userDockingSum;
}
public void setUserDockingSum(Long userDockingSum) {
this.userDockingSum = userDockingSum;
}
public Long getClickSum() {
return clickSum;

View File

@ -0,0 +1,36 @@
package com.microservices.dms.behaviorImage.domain;
import lombok.Data;
public class ActivityUserTotal {
//活跃用户
private Long totalUser;
//活跃用户专家数
private Long totalExpert;
//活跃用户实名认证
private Long authTotal;
public Long getTotalUser() {
return totalUser;
}
public void setTotalUser(Long totalUser) {
this.totalUser = totalUser;
}
public Long getTotalExpert() {
return totalExpert;
}
public void setTotalExpert(Long totalExpert) {
this.totalExpert = totalExpert;
}
public Long getAuthTotal() {
return authTotal;
}
public void setAuthTotal(Long authTotal) {
this.authTotal = authTotal;
}
}

View File

@ -2,10 +2,7 @@ package com.microservices.dms.behaviorImage.mapper;
import com.microservices.common.datasource.annotation.Slave;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
import com.microservices.dms.behaviorImage.domain.ActivityUserLibrary;
import com.microservices.dms.behaviorImage.domain.BehaviorImageWeight;
import com.microservices.dms.behaviorImage.domain.UserTypeTotalVo;
import com.microservices.dms.behaviorImage.domain.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -98,5 +95,9 @@ public interface BehaviorImageMapper {
List<UserTypeTotalVo> getUserTypeStatistic(@Param("userId")Long userId);
List<KeyValueVo> getActivityStatistic();
ActivityUserTotal getActivityStatistic();
List<ActivityUserLibrary> selectActivityUserLibraryListAll(ActivityUserLibrary activityUserLibrary);
UserTypeTotalVo getUserBehaviorSum(@Param("userId")Long userId);
}

View File

@ -75,5 +75,7 @@ public interface IBehaviorImageService {
UserExpertTotalVo getUserExpertStatistic(Long userId);
List<KeyValueVo> getActivityStatistic();
ActivityUserTotal getActivityStatistic();
UserTypeTotalVo getUserBehaviorSum(Long userId);
}

View File

@ -309,7 +309,7 @@ public class BehaviorImageServiceImpl implements IBehaviorImageService {
}
@Override
public List<KeyValueVo> getActivityStatistic() {
public ActivityUserTotal getActivityStatistic() {
return behaviorImageMapper.getActivityStatistic();
}
@ -318,19 +318,30 @@ public class BehaviorImageServiceImpl implements IBehaviorImageService {
* @param activityUserLibrary 活跃用户资源库
* @return
*/
// @Override
// public List<ActivityUserLibrary> selectActivityUserLibraryList(ActivityUserLibrary activityUserLibrary) {
// List<ActivityUserLibrary> list = behaviorImageMapper.selectActivityUserLibraryList(activityUserLibrary);
// for (ActivityUserLibrary a : list) {
// Long relatedProject= behaviorImageMapper.getrelatedProjectCount(a.getUserId());
// a.setRelatedProject(relatedProject);
// Long relatedTask= behaviorImageMapper.getrelatedTaskCount(a.getUserId());
// a.setRelatedTask(relatedTask);
// Long relatedCompetition= behaviorImageMapper.getrelatedCompetitionCount(a.getUserId());
// a.setRelatedCompetition(relatedCompetition);
// Long relatedMemo= behaviorImageMapper.getrelatedMemoCount(a.getUserId());
// a.setRelatedMemo(relatedMemo);
// }
// return list;
// }
@Override
public List<ActivityUserLibrary> selectActivityUserLibraryList(ActivityUserLibrary activityUserLibrary) {
List<ActivityUserLibrary> list = behaviorImageMapper.selectActivityUserLibraryList(activityUserLibrary);
for (ActivityUserLibrary a : list) {
Long relatedProject= behaviorImageMapper.getrelatedProjectCount(a.getUserId());
a.setRelatedProject(relatedProject);
Long relatedTask= behaviorImageMapper.getrelatedTaskCount(a.getUserId());
a.setRelatedTask(relatedTask);
Long relatedCompetition= behaviorImageMapper.getrelatedCompetitionCount(a.getUserId());
a.setRelatedCompetition(relatedCompetition);
Long relatedMemo= behaviorImageMapper.getrelatedMemoCount(a.getUserId());
a.setRelatedMemo(relatedMemo);
}
List<ActivityUserLibrary> list = behaviorImageMapper.selectActivityUserLibraryListAll(activityUserLibrary);
return list;
}
@Override
public UserTypeTotalVo getUserBehaviorSum(Long userId) {
return behaviorImageMapper.getUserBehaviorSum(userId);
}
}

View File

@ -11,10 +11,23 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
@ -157,4 +170,22 @@ public class OpenController extends BaseController {
return getDataTable(list);
}
@GetMapping("/downloadAch")
@ApiOperation("成果征集信息下载")
public ResponseEntity<Resource> downloadAch() throws IOException {
String fileName = "红山开源优秀科研成果信息征集.zip";
Resource resource = new ClassPathResource(fileName);
if (!resource.exists()) {
throw new RuntimeException("文件不存在: " + fileName);
}
String encodedFileName = URLEncoder.encode(fileName, String.valueOf(StandardCharsets.UTF_8))
.replace("+", "%20");
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename*=UTF-8''" + encodedFileName)
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(resource);
}
}

View File

@ -0,0 +1,27 @@
package com.microservices.dms.constant;
/**
* 区块链方法常量
*/
public class BlockChainFunConstants {
public static final String CREATE_REPO = "create repo"; //项目入链
public static final String QUERY_REPO = "query repo basic info"; //项目入链信息查询
public static final String USER_SINGLE_REPO = "query user balance of single repo"; //单个项目某个用户token
public static final String USER_ALL_REPOS = "query user balance of all repos"; //某个用户所有项目token
public static final String CREATE_COMMIT = "upload commit info"; //Commit新增入链
public static final String QUERY_COMMIT = "query commit info"; //Commit入链信息查询
public static final String CREATE_PR = "upload pull request info"; //Pr新增入链
public static final String QUERY_PR_LATEST = "query pull request latest info"; //单个pr入链所有信息
public static final String QUERY_PR_ALL = "query pull request all info"; //单个pr最后一次入链信息
public static final String CREATE_upDATE_issue = "upload issue info"; //Issue新增修改入链
public static final String QUERY_ISSUE_LATEST = "query issue latest info"; //单个Issue最后一次入链信息
public static final String QUERY_ISSUE_ALL = "query issue all info"; //单个Issue入链所有信息
public static final String ADD_USER_BALANCE = "add user balance"; //项目分配token用户token新增
public static final String MINUS_USER_BALANCE = "minus user balance"; //项目分配token-用户token减少
public static final String LOCK_USER_BALANCE = "lock user balance"; //用户转账token-将自己token分配给本项目中的其他用户
}

View File

@ -2,7 +2,8 @@ package com.microservices.dms.constant;
public class TaskConstant {
private TaskConstant() {}
private TaskConstant() {
}
public static final String TASK_TYPE_WATCHERS = "MakerTask";
public static final String TASK_TYPE_JOURNALS = "makerSpaceTask";
@ -22,4 +23,16 @@ public class TaskConstant {
public static final String EXPERTS = "Experts";
public static final String ACHIEVEMENTS = "Achievements";
// task status dict
public static final int DRAFT_STATUS = 0; //草稿状态
public static final int TO_BE_REVIEWED_STATUS = 1; //待审核状态
public static final int REFUSED_STATUS = 2; //已拒绝状态
public static final int TASK_PAPER_COLLECTING_STATUS = 3; //成果征集中状态
public static final int TASK_PAPER_CHOOSING_STATUS = 4; //成果评选中状态
public static final int TASK_RESULT_PROOF_STATUS = 5; //公示中状态
public static final int TASK_SIGNING_STATUS = 6; //协议签定中状态
public static final int TASK_PAYING_STATUS = 7; //支付中状态
public static final int TASK_COMPLETE_STATUS = 8; //任务完成状态
public static final int TASK_TO_BE_REPAIRED_STATUS = 9; //待修缮状态
}

View File

@ -4,13 +4,17 @@ import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.dms.referral.service.TalentReferralService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "数据管理体系-人才推荐接口")
@Data
@Api(tags = "数据管理体系-推荐接口")
@RestController
@RequestMapping("/talentReferral")
@RequiredArgsConstructor
@ -21,12 +25,33 @@ public class TalentReferralController {
@GetMapping("/issueTalentReferral")
@ApiOperation(value = "疑修人才推荐")
public AjaxResult issueTalentReferral(@RequestParam("issueId") Long issueId, @RequestParam("projectId") Long projectId) {
return AjaxResult.success(talentReferralService.issueTalentReferral(issueId, projectId));
return AjaxResult.success(talentReferralService.doIssueTalentReferral(issueId, projectId));
}
@GetMapping("/pullRequestTalentReferral")
@ApiOperation(value = "PR人才推荐")
public AjaxResult pullRequestTalentReferral(@RequestParam("prId") Long prId, @RequestParam("projectId") Long projectId) {
return AjaxResult.success(talentReferralService.PRTalentReferral(prId, projectId));
return AjaxResult.success(talentReferralService.doPRTalentReferral(prId, projectId));
}
@GetMapping("/taskAchievementTalentReferral")
@ApiOperation(value = "任务成果推荐")
public AjaxResult taskAchievementTalentReferral(@RequestParam("taskId") Long taskId) {
return AjaxResult.success(talentReferralService.taskAchievementTalentReferral(taskId));
}
@GetMapping("/taskExpertTalentReferral")
@ApiOperation(value = "任务专家推荐")
public AjaxResult taskExpertTalentReferral(@RequestParam("taskId") Long taskId) {
return AjaxResult.success(talentReferralService.taskExpertTalentReferral(taskId));
}
@GetMapping("/competitionExpertTalentReferral")
@ApiOperation(value = "竞赛专家推荐")
public AjaxResult competitionExpertTalentReferral(@RequestParam("competitionId") Long competitionId) {
return AjaxResult.success(talentReferralService.competitionExpertTalentReferral(competitionId));
}
}

View File

@ -1,12 +1,14 @@
package com.microservices.dms.referral.mapper;
import com.microservices.common.datasource.annotation.Slave;
import com.microservices.dms.referral.vo.IssuesVo;
import com.microservices.dms.referral.vo.PullRequestVo;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
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;
import java.util.List;
import java.util.Map;
@Mapper
@Slave
@ -27,4 +29,21 @@ public interface TalentReferralMapper {
String selectRepositoriesUrl(@Param("id") Long id);
Long selectIdByLogin(@Param("login") String login);
List<TaskVo> selectTaskByStatus(@Param("statusIds") List<Integer> statusIds);
Map<String, Object> selectUsersById(@Param("id") Long id);
TaskVo selectTaskById(@Param("id") Long id);
List<ExpertVo> selectExpertsBy(ExpertVo expertVo);
List<KeyValVo<Long,String>> allTaskWithExpertIds(@Param("type") String type);
TaskVo selectCompetitionById(Long competitionId);
List<TaskVo> selectCompetitionIdByStatus();
PrInfoVo selectPRInfoById(@Param("id") Integer id);
}

View File

@ -2,14 +2,17 @@ package com.microservices.dms.referral.service;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Lists;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
import com.microservices.dms.achievementLibrary.domain.Achievements;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
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.IssueDto;
import com.microservices.dms.referral.vo.IssuesVo;
import com.microservices.dms.referral.vo.PullRequestVo;
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;
import com.microservices.dms.utils.SimilarityService;
@ -33,15 +36,17 @@ public class TalentReferralService {
@Autowired
private DmsRequestHelper dmsRequestHelper;
@Autowired
private AchievementsMapper achievementsMapper;
private static final Logger logger = LoggerFactory.getLogger(TalentReferralService.class);
public Set<Long> getContributors(String projectFullName) {
try {
// 获取项目贡献者数量
JSONArray contributorsArray = dmsRequestHelper.getAllDataByPage(DmsGitLinkRequestUrl.CONTRIBUTORS(projectFullName), "list","total_count");
JSONArray contributorsArray = dmsRequestHelper.getAllDataByPage(DmsGitLinkRequestUrl.CONTRIBUTORS(projectFullName), "list", "total_count");
return contributorsArray.stream().map(o -> (JSONObject) o).map(s -> s.getString("contributions")).filter(StringUtils::isNotBlank)
.mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
return contributorsArray.stream().map(o -> (JSONObject) o).map(s -> s.getString("contributions")).filter(StringUtils::isNotBlank).mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
} catch (ServiceException e) {
logger.error("【{}】获取项目贡献者数量失败:{}", projectFullName, e.getMessage());
@ -52,10 +57,9 @@ public class TalentReferralService {
public Set<Long> getCollaborators(String projectFullName) {
try {
// 获取项目成员者数量
JSONArray contributorsArray = dmsRequestHelper.getAllDataByPage(DmsGitLinkRequestUrl.QUERY_USER_FROM_PROJECT(projectFullName), "members","total_count");
JSONArray contributorsArray = dmsRequestHelper.getAllDataByPage(DmsGitLinkRequestUrl.QUERY_USER_FROM_PROJECT(projectFullName), "members", "total_count");
return contributorsArray.stream().map(o -> (JSONObject) o).map(s -> s.getString("id"))
.filter(StringUtils::isNotBlank).mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
return contributorsArray.stream().map(o -> (JSONObject) o).map(s -> s.getString("id")).filter(StringUtils::isNotBlank).mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
} catch (ServiceException e) {
logger.error("【{}】获取项目成员者数量失败:{}", projectFullName, e.getMessage());
@ -87,6 +91,14 @@ public class TalentReferralService {
return collaborators;
}
public List<Map<String, Object>> doIssueTalentReferral(Long issueId , Long projectId) {
List<Map.Entry<Long, Double>> entries = issueTalentReferral(projectId, issueId);
return entries.stream().limit(3).map(s -> {
Map<String, Object> mm = talentReferralMapper.selectUsersById(s.getKey());
return mm;
}).collect(Collectors.toList());
}
public List<Map.Entry<Long, Double>> issueTalentReferral(Long projectId, Long issueId) {
IssuesVo curIssue = talentReferralMapper.selectIssuesById(issueId);
@ -96,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的相似度 标题+描述
@ -138,37 +150,41 @@ 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) {
Set<String> prFiles = getPRFiles(projectId, dto.getPullRequestNumber());
PRFilesMap.merge(reviewer, prFiles, (a, b) -> {
HashSet<String> set = new HashSet<>();
set.addAll(a);
set.addAll(b);
return set;
});
}
String reviewer = dto.getAssignUserLogin();
Set<String> prFiles = getPRFiles(projectId, dto.getPullRequestNumber());
PRFilesMap.merge(reviewer, prFiles, (a, b) -> {
HashSet<String> set = new HashSet<>();
set.addAll(a);
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) -> {
@ -210,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());
@ -218,25 +234,172 @@ public class TalentReferralService {
return new HashSet<>();
}
public List<Map<String, Object>> doPRTalentReferral(Long prId, Long projectId) {
List<Map.Entry<Long, Double>> entries = PRTalentReferral(projectId, prId);
return entries.stream().limit(3).map(s -> {
Map<String, Object> mm = talentReferralMapper.selectUsersById(s.getKey());
return mm;
}).collect(Collectors.toList());
}
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);
}
//定时统计
public void projectsStatistic(){
public void projectsStatistic() {
}
/**
* 1先查找任务状态为成果征集中成果评选中的数据新增存储到数据表中
* 2获取系统中的任务领域和数据仓库中的领域是一样 50%
* 3根据1中任务标题和任务正文 与数据仓库中名称和简介详情比较 取前10获取对比计算分值大于0的结果
* 4将2和3的结果相加取前5个成果进行推荐
*/
public List<Achievements> taskAchievementTalentReferral(Long taskId) {
TaskVo task = talentReferralMapper.selectTaskById(taskId);
Achievements tCond = new Achievements();
tCond.setSourceId(taskId);
tCond.setSource("2");
tCond.setStatus("1");
List<Achievements> taskAchievements = achievementsMapper.selectAchievementsList(tCond);
List<Achievements> result;
List<Long> trTaskIds = doTaskTalentReferral(task, taskAchievements);
result = trTaskIds.stream().map(s -> taskAchievements.stream().filter(e -> e.getId().equals(s)).findFirst().orElse(null)).filter(Objects::nonNull).limit(5).collect(Collectors.toList());
return result;
}
private List<Long> doTaskTalentReferral(TaskVo task, List<Achievements> taskVos) {
Long taskDomain = task.getCategoryId();
Map<Long, Double> step1Map = new TreeMap<>();
Map<Long, Double> step2Map = new TreeMap<>();
for (Achievements t1 : taskVos) {
if (Objects.equals(String.valueOf(taskDomain), t1.getField1())) {
step1Map.put(t1.getId(), 50.0D);
}
double subjectFraction = SimilarityService.sentence(task.getName(), t1.getAchievementName());
double descFraction = SimilarityService.text(t1.getSummary(), task.getDescription());
step2Map.put(t1.getId(), (subjectFraction + descFraction) * 50.0D);
}
step1Map.forEach((k, v) -> step2Map.merge(k, v, Double::sum));
step2Map.keySet().removeIf(step -> Double.compare(step2Map.get(step), 0.0D) > 0);
List<Map.Entry<Long, Double>> entryList = new ArrayList<>(step2Map.entrySet());
entryList.sort((entry1, entry2) -> Double.compare(entry2.getValue(), entry1.getValue()));
return entryList.stream().map(Map.Entry::getKey).collect(Collectors.toList());
}
/**
* 创客任务评审专家推荐
* 1先查找创客任务状态未结束并且已加入评审的数据新增存储到数据表中
* 2技术匹配度系统中专家领域 任务是一样的领域 20%
* 3根据1中任务标题和任务描述 与专家简介进行比较 匹配结果分数取前1030%
* 4根据1中任务标题和任务描述 与已完成的任务标题与任务描述比较匹配结果分数取前3 前3个竞赛中对应的专家 分数*50%
*/
public Object taskExpertTalentReferral(Long taskId) {
TaskVo task = talentReferralMapper.selectTaskById(taskId);
List<KeyValueVo> categories = achievementsMapper.getAreasByName(null);
List<TaskVo> completedTasks = talentReferralMapper.selectTaskByStatus(Lists.newArrayList(TaskConstant.TASK_COMPLETE_STATUS));
List<ExpertVo> allExperts = talentReferralMapper.selectExpertsBy(new ExpertVo());
List<Long> expertIds = doTaskExpertTalentReferral(task, categories, completedTasks, allExperts);
return expertIds.stream().map(s -> allExperts.stream().filter(e -> e.getId().equals(s)).findFirst().orElse(null)).filter(Objects::nonNull).limit(3).collect(Collectors.toList());
}
private List<Long> doTaskExpertTalentReferral(TaskVo task, List<KeyValueVo> categories, List<TaskVo> completedTasks, List<ExpertVo> allExperts) {
Map<Long, String> v2k = categories.stream().collect(Collectors.toMap(KeyValueVo::getValue, KeyValueVo::getKey, (o, n) -> n));
String taskDomain = v2k.get(task.getCategoryId());
Map<Long, Double> step1Map = new TreeMap<>();
Map<Long, Double> step2Map = new TreeMap<>();
for (ExpertVo t1 : allExperts) {
if (Objects.equals(taskDomain, t1.getReviewAreaOne()) || Objects.equals(taskDomain, t1.getReviewAreaTwo()) || Objects.equals(taskDomain, t1.getReviewAreaThree())) {
step1Map.put(t1.getId(), 50.0D);
}
}
List<KeyValVo<Long, String>> allTaskWithExpertIds = talentReferralMapper.allTaskWithExpertIds("1");
Map<Long, String> t2e = allTaskWithExpertIds.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV, (o, n) -> n));
for (TaskVo t2 : completedTasks) {
double subjectFraction = SimilarityService.sentence(task.getName(), t2.getName());
double descFraction = SimilarityService.text(t2.getDescription(), task.getDescription());
String[] split = t2e.getOrDefault(t2.getId(), "").split(",");
for (String s : split) {
if (StringUtils.isNotBlank(s)) {
step2Map.put(Long.parseLong(s), (subjectFraction + descFraction) * 50.0D);
}
}
}
step1Map.forEach((k, v) -> step2Map.merge(k, v, Double::sum));
List<Map.Entry<Long, Double>> entryList = new ArrayList<>(step2Map.entrySet());
entryList.sort((entry1, entry2) -> Double.compare(entry2.getValue(), entry1.getValue()));
return entryList.stream().map(Map.Entry::getKey).collect(Collectors.toList());
}
/**
* 开源竞赛评审专家推荐
* 1先查找开放竞赛状态未结束并且已提交评审的数据新增存储到数据表中
* 2技术匹配度系统中专家领域 竞赛是一样的领域 20%
* 3根据1中竞赛标题和竞赛描述 与专家简介进行比较 匹配结果分数取前1030%
* 4根据1中竞赛标题和竞赛描述 与已完成的竞赛标题与竞赛描述比较匹配结果分数取前3 前3个竞赛中对应的专家*50%
*/
public Object competitionExpertTalentReferral(Long competitionId) {
TaskVo task = talentReferralMapper.selectCompetitionById(competitionId);
List<KeyValueVo> categories = new ArrayList<>();
List<TaskVo> completedTasks = talentReferralMapper.selectCompetitionIdByStatus();
List<ExpertVo> allExperts = talentReferralMapper.selectExpertsBy(new ExpertVo());
List<Long> expertIds = doCompetitionExpertTalentReferral(task, categories, completedTasks, allExperts);
return expertIds.stream().map(s -> allExperts.stream().filter(e -> e.getId().equals(s)).findFirst().orElse(null)).filter(Objects::nonNull).limit(3).collect(Collectors.toList());
}
private List<Long> doCompetitionExpertTalentReferral(TaskVo task, List<KeyValueVo> categories, List<TaskVo> completedTasks, List<ExpertVo> allExperts) {
Map<Long, Double> step1Map = new TreeMap<>();
Map<Long, Double> step2Map = new TreeMap<>();
List<KeyValVo<Long, String>> allTaskWithExpertIds = talentReferralMapper.allTaskWithExpertIds("2");
Map<Long, String> t2e = allTaskWithExpertIds.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV, (o, n) -> n));
for (TaskVo t2 : completedTasks) {
double subjectFraction = SimilarityService.sentence(task.getName(), t2.getName());
double descFraction = SimilarityService.text(t2.getDescription(), task.getDescription());
String[] split = t2e.getOrDefault(t2.getId(), "").split(",");
for (String s : split) {
if (StringUtils.isNotBlank(s)) {
step2Map.put(Long.parseLong(s), (subjectFraction + descFraction) * 100.0D);
}
}
}
step1Map.forEach((k, v) -> step2Map.merge(k, v, Double::sum));
List<Map.Entry<Long, Double>> entryList = new ArrayList<>(step2Map.entrySet());
entryList.sort((entry1, entry2) -> Double.compare(entry2.getValue(), entry1.getValue()));
return entryList.stream().map(Map.Entry::getKey).collect(Collectors.toList());
}
}

View File

@ -0,0 +1,15 @@
package com.microservices.dms.referral.vo;
import lombok.Data;
@Data
public class ExpertVo {
Long id;
Long userId;
String expertName;
String nickname;
String reviewAreaOne;
String reviewAreaTwo;
String reviewAreaThree;
Integer status;
}

View File

@ -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;
}

View File

@ -0,0 +1,13 @@
package com.microservices.dms.referral.vo;
import lombok.Data;
@Data
public class TaskVo {
private Long id;
private Long taskId;
private String name;
private String description;
private Long categoryId;
private String identifier;
}

View File

@ -21,7 +21,7 @@ public class CollectUserActDataController {
@PostMapping("/addClicker")
@ApiImplicitParams({
@ApiImplicitParam(name = "clickType", value = "点击类型(任务makerSpaceTask、竞赛CompetitionInfo、项目Project、成果Achievements、专家Experts,校企schoolEnterprise)", paramType = "query", dataTypeClass = String.class),
@ApiImplicitParam(name = "clickType", value = "点击类型(任务makerSpaceTask、竞赛CompetitionInfo、项目Project、成果Achievements、专家Experts,校企schoolEnterprise,成果用户对接userDocking)", paramType = "query", dataTypeClass = String.class),
@ApiImplicitParam(name = "clickId", value = "点击对象ID", paramType = "query", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "extInfo", value = "补充信息", paramType = "query", dataTypeClass = String.class)

View File

@ -33,7 +33,7 @@ public class CompetitionResourceLibrary extends BaseEntity {
*/
private String competitionField;
/**
* 竞赛状态 0进行中 1已结束
* 竞赛状态 status: 0 未上架 1上架
*/
private String competitionStatus;
/**

View File

@ -112,7 +112,7 @@ public interface ExpertResourceLibraryMapper
List<KeyValueVo> getMemoAduit();
KeyValueVo getIsOriginalStatistic();
List<KeyValueVo> getIsOriginalStatistic();
List<KeyValueVo> getMemoTotalByYear();

View File

@ -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);
}

View File

@ -108,4 +108,6 @@ public interface TaskResourceLibraryMapper {
int delFavorite(Favorite favorite);
int delWatcher(Watcher watcher);
double getConvertedTaskAmount2();
}

View File

@ -83,7 +83,7 @@ public class ProjectResourceLibraryService {
if (v.startsWith("http")) {
String urlPath = getUrlPath(v);
if (StringUtils.isNotEmpty(urlPath)) {
if (urlPath.startsWith("/")) {
if (urlPath.startsWith("/api")) {
a.setV(gitLinkUrl + urlPath);
}else {
a.setV(gitLinkUrl +"/api"+ urlPath);

View File

@ -122,6 +122,8 @@ public class TaskResourceLibraryService {
public int updateTaskResourceLibrary(TaskResourceLibrary taskResourceLibrary) {
taskResourceLibrary.setUpdateTime(DateUtils.getNowDate());
taskResourceLibrary.setUpdateBy(SecurityUtils.getUsername());
return taskResourceLibraryMapper.updateTaskResourceLibrary(taskResourceLibrary);
}

View File

@ -42,6 +42,20 @@ public class DateUtil {
};
}
public static Date[] getLast12Months() {
LocalDate endDate = LocalDate.now();
LocalDate startDate = endDate.minusMonths(11);
LocalDateTime startDateTime = LocalDateTime.of(startDate.getYear(),startDate.getMonth(),1,0,0,0);
LocalDateTime endDateTime = endDate.atTime(23, 59, 59);
return new Date[]{
Date.from(startDateTime.atZone(ZoneId.systemDefault()).toInstant()),
Date.from(endDateTime.atZone(ZoneId.systemDefault()).toInstant())
};
}
public static Date[] getCurrentYearEndOf(LocalDate endDate) {
Year year = Year.now();
@ -68,6 +82,19 @@ public class DateUtil {
.collect(Collectors.toList());
}
public static List<String> getDateStrYYYYMM(Date start, Date end) {
LocalDate s = start.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().toLocalDate();
LocalDate e = end.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().toLocalDate();
String pattern = "yyyy-MM";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
return LongStream.range(0, s.until(e).getMonths() + 1)
.mapToObj(s::plusMonths)
.map(formatter::format)
.collect(Collectors.toList());
}
public static List<String> getDateStrYYYYMMDD(Date start, Date end) {
LocalDate s = start.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().toLocalDate();
LocalDate e = end.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().toLocalDate();

View File

@ -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));
}

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.microservices.dms.achievementLibrary.mapper.AchievementDictDataMapper">
<resultMap type="AchievementDictData" id="AchievementDictDataResult">
<result property="dictCode" column="dict_code" />
<result property="dictSort" column="dict_sort" />
<result property="dictLabel" column="dict_label" />
<result property="dictValue" column="dict_value" />
<result property="dictType" column="dict_type" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectAchievementDictDataVo">
select dict_code, dict_sort, dict_label, dict_value, dict_type, status, create_by, create_time, update_by, update_time, remark from achievement_dict_data
</sql>
<select id="selectAchievementDictDataList" parameterType="AchievementDictData" resultMap="AchievementDictDataResult">
<include refid="selectAchievementDictDataVo"/>
<where>
<if test="dictSort != null "> and dict_sort = #{dictSort}</if>
<if test="dictLabel != null and dictLabel != ''"> and dict_label = #{dictLabel}</if>
<if test="dictValue != null and dictValue != ''"> and dict_value = #{dictValue}</if>
<if test="dictType != null and dictType != ''"> and dict_type = #{dictType}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectAchievementDictDataByDictCode" parameterType="Long" resultMap="AchievementDictDataResult">
<include refid="selectAchievementDictDataVo"/>
where dict_code = #{dictCode}
</select>
<insert id="insertAchievementDictData" parameterType="AchievementDictData" useGeneratedKeys="true" keyProperty="dictCode">
insert into achievement_dict_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dictSort != null">dict_sort,</if>
<if test="dictLabel != null">dict_label,</if>
<if test="dictValue != null">dict_value,</if>
<if test="dictType != null">dict_type,</if>
<if test="status != null">status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dictSort != null">#{dictSort},</if>
<if test="dictLabel != null">#{dictLabel},</if>
<if test="dictValue != null">#{dictValue},</if>
<if test="dictType != null">#{dictType},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateAchievementDictData" parameterType="AchievementDictData">
update achievement_dict_data
<trim prefix="SET" suffixOverrides=",">
<if test="dictSort != null">dict_sort = #{dictSort},</if>
<if test="dictLabel != null">dict_label = #{dictLabel},</if>
<if test="dictValue != null">dict_value = #{dictValue},</if>
<if test="dictType != null">dict_type = #{dictType},</if>
<if test="status != null">status = #{status},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where dict_code = #{dictCode}
</update>
<delete id="deleteAchievementDictDataByDictCode" parameterType="Long">
delete from achievement_dict_data where dict_code = #{dictCode}
</delete>
<delete id="deleteAchievementDictDataByDictCodes" parameterType="String">
delete from achievement_dict_data where dict_code in
<foreach item="dictCode" collection="array" open="(" separator="," close=")">
#{dictCode}
</foreach>
</delete>
<select id="selectDictDataByType" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select dict_code as "key",dict_label as "name" from achievement_dict_data where dict_type = #{dictType}
</select>
<select id="selectDictDataByLabel" resultType="int">
select count(1) from achievement_dict_data where dict_type = #{type} and dict_label = #{label}
</select>
<select id="getDictTypes" resultType="String">
select distinct dict_type from achievement_dict_data
</select>
</mapper>

View File

@ -125,4 +125,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from achievement_team
where achievement_id = #{aid}
</delete>
<select id="selectAchievementTeamByAchId" resultMap="AchievementTeamResult">
<include refid="selectAchievementTeamVo"/>
where achievement_id = #{achId}
</select>
</mapper>

View File

@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="Achievements" id="AchievementsResult">
<result property="id" column="id" />
<result property="showAchievementName" column="showAchievementName" />
<result property="achievementName" column="achievement_name" />
<result property="field1" column="field_1" />
<result property="field2" column="field_2" />
@ -40,12 +41,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectAchievementsVo">
select id, achievement_name,hot_rank, field_1, field_2, field_3, attachment_count,is_expert_audit,achievement_type, source, source_id, source_link, tags, summary, publishing_unit, address, is_featured, contact_person, contact_number, owner_id, owner_name, status, details, reviewer, review_date, review_comments, images, attachments, create_by, create_time, update_by, update_time from achievements
select id, IFNULL(show_ach_name,achievement_name) as "showAchievementName", achievement_name,hot_rank, field_1, field_2, field_3, attachment_count,is_expert_audit,achievement_type, source, source_id, source_link, tags, summary, publishing_unit, address, is_featured, contact_person, contact_number, owner_id, owner_name, status, details, reviewer, review_date, review_comments, images, attachments, create_by, create_time, update_by, update_time from achievements
</sql>
<select id="selectAchievementsList" parameterType="Achievements" resultMap="AchievementsResult">
<include refid="selectAchievementsVo"/>
<where>
<if test="showAchievementName != null and showAchievementName != ''"> and show_ach_name like concat('%', #{showAchievementName}, '%')</if>
<if test="achievementName != null and achievementName != ''"> and achievement_name like concat('%', #{achievementName}, '%')</if>
<if test="field1 != null and field1 != ''"> and field_1 = #{field1}</if>
<if test="field2 != null and field2 != ''"> and field_2 = #{field2}</if>
@ -73,10 +75,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="hotRank != null and hotRank != ''"> and hot_rank = #{hotRank}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
</where>
order by create_time desc
</select>
<select id="selectAchievementsById" parameterType="Long" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
select a.id,a.achievement_name,a.hot_rank,a.field_1,a.field_2,a.field_3,a.attachment_count,a.is_expert_audit,a.achievement_type,a.source,a.source_id
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName",a.achievement_name,a.hot_rank,a.field_1,a.field_2,a.field_3,a.attachment_count,a.is_expert_audit,a.achievement_type,a.source,a.source_id
,u.login as "userLogin",IFNULL(u.nickname,owner_name) as "userNickName",ue.gender as "gender",
a.source_link,a.tags,a.summary,a.publishing_unit,a.address,a.is_featured,a.contact_person,a.contact_number,a.owner_id,a.owner_name, a.status,a.details,
a.reviewer,a.review_date,a.review_comments, a.images,a.attachments,a.create_by,a.create_time,a.update_by,a.update_time
@ -97,6 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertAchievements" parameterType="Achievements" useGeneratedKeys="true" keyProperty="id">
insert into achievements
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="showAchievementName != null">show_ach_name,</if>
<if test="achievementName != null">achievement_name,</if>
<if test="field1 != null">field_1,</if>
<if test="field2 != null">field_2,</if>
@ -130,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="hotRank != null">hot_rank,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="showAchievementName != null">#{showAchievementName},</if>
<if test="achievementName != null">#{achievementName},</if>
<if test="field1 != null">#{field1},</if>
<if test="field2 != null">#{field2},</if>
@ -167,6 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateAchievements" parameterType="Achievements">
update achievements
<trim prefix="SET" suffixOverrides=",">
<if test="showAchievementName != null">show_ach_name = #{showAchievementName},</if>
<if test="achievementName != null">achievement_name = #{achievementName},</if>
<if test="field1 != null">field_1 = #{field1},</if>
<if test="field2 != null">field_2 = #{field2},</if>
@ -214,7 +220,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="getChoiceImport" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
select id, achievement_name,images,field_1,field_2,field_3,source,source_id
select id,IFNULL(show_ach_name,achievement_name) as "showAchievementName",achievement_name,images,field_1,field_2,field_3,summary,source,source_id
from achievements
where is_featured ='1'
order by update_time desc
@ -224,6 +230,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getTjBySources" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select sum(1) as "value",source as "key"
from achievements
where status='1'
group by source
</select>
@ -249,21 +256,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAchievementsByParam" parameterType="com.microservices.dms.achievementLibrary.domain.AchQueryVo" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
<if test="source == '' or source == null">
select a.id, a.achievement_name,a.summary,a.create_time,a.owner_name,a.tags,a.field_1,a.field_2,a.field_3,a.source,a.source_id,
u.login as "userLogin",u.nickname as "userNickName",ue.gender as "gender",
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName",a.achievement_name,a.summary,a.create_time,a.owner_name,a.tags,a.field_1,a.field_2,a.field_3,a.source,a.source_id,
u.login as "userLogin",
IFNULL(u.nickname,a.owner_name) as "userNickName",
ue.gender as "gender",
(select IFNULL(count(*), 0) from favorites where favorite_type = 'Achievements' and favorite_id = id) as watcherSum,
(select IFNULL(count(*), 0) from watchers where watchable_type = 'Achievements' and watchable_id = id) as favoriteSum
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>
and a.status='1'
<if test="achievementName != null and achievementName != ''"> and a.achievement_name like concat('%', #{achievementName}, '%')</if>
<if test="showAchievementName != null and showAchievementName != ''"> and a.show_ach_name like concat('%', #{showAchievementName}, '%')</if>
</where>
order by a.create_time desc
</if>
<if test='source=="1"'>
select a.id, a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,
c.name as "field1Name",u.login as "userLogin",u.nickname as "userNickName",ue.gender as "gender",
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,
c.name as "field1Name",u.login as "userLogin",
IFNULL(u.nickname,a.owner_name) as "userNickName",
ue.gender as "gender",
(select IFNULL(count(*), 0) from favorites where favorite_type = 'Achievements' and favorite_id = a.id) as watcherSum,
(select IFNULL(count(*), 0) from watchers where watchable_type = 'Achievements' and watchable_id = a.id) as favoriteSum
from achievements a
@ -271,7 +284,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join user_extensions ue on u.id = ue.user_id
left join project_categories c on a.field_1 = c.id
<where>
and a.status='1'
<if test="achievementName != null and achievementName != ''"> and a.achievement_name like concat('%', #{achievementName}, '%')</if>
<if test="showAchievementName != null and showAchievementName != ''"> and a.show_ach_name like concat('%', #{showAchievementName}, '%')</if>
<if test="source != null and source != ''"> and a.source = #{source}</if>
<if test='areaQuery != null and areaQuery != "" '>
and (a.field_1 = #{areaQuery} or a.field_2 = #{areaQuery} or a.field_3 = #{areaQuery})
@ -280,8 +295,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by create_time desc
</if>
<if test='source=="2" or source=="3" or source=="4" '>
select a.id, a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,
c.name as "field1Name",u.login as "userLogin",u.nickname as "userNickName",ue.gender as "gender",
select a.id, IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,
c.name as "field1Name",u.login as "userLogin",
IFNULL(u.nickname,a.owner_name) as "userNickName",
ue.gender as "gender",
(select IFNULL(count(*), 0) from favorites where favorite_type = 'Achievements' and favorite_id = a.id) as watcherSum,
(select IFNULL(count(*), 0) from watchers where watchable_type = 'Achievements' and watchable_id = a.id) as favoriteSum
from achievements a
@ -289,7 +306,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join user_extensions ue on u.id = ue.user_id
left join categories c on a.field_1 = c.id
<where>
and a.status='1'
<if test="achievementName != null and achievementName != ''"> and a.achievement_name like concat('%', #{achievementName}, '%')</if>
<if test="showAchievementName != null and showAchievementName != ''"> and a.show_ach_name like concat('%', #{showAchievementName}, '%')</if>
<if test="source != null and source != ''"> and a.source = #{source}</if>
<if test='areaQuery != null and areaQuery != "" '>
and (a.field_1 = #{areaQuery} or a.field_2 = #{areaQuery} or a.field_3 = #{areaQuery})
@ -324,14 +343,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by DATE_FORMAT(created_at, '%m-%d')
</select>
<select id="getHotAchievement" resultType="java.util.Map">
select t.achievement_name as name, t.w as watcher, t.f as faviter, (t.w + t.f) as total, t.id as `id`,t.owner_name
as userName
<select id="getHotAchievement" resultType="com.microservices.dms.achievementLibrary.domain.HotAchVo">
select t.show_ach_name as "showAchievementName",t.achievement_name as name, t.w as watcher, t.f as faviter, (t.w + t.f) as total, t.id as `id`,t.owner_name
as userName,t.gender,t.userNickName
from (select a.achievement_name,
IFNULL(a.show_ach_name,a.achievement_name) as "show_ach_name",
a.id,a.owner_name,
IFNULL(u.nickname,a.owner_name) as "userNickName",
ue.gender as "gender",
(select IFNULL(count(*), 0) from favorites where favorite_type = 'Achievements' and favorite_id = a.id) as f,
(select IFNULL(count(*), 0) from watchers where watchable_type = 'Achievements' and watchable_id = a.id) as w
from achievements a) as t
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
</select>
@ -349,33 +375,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="indexProjectStatistic" resultType="java.util.Map">
select COUNT(*) as projectAchievementCount,
IFNULL(SUM(attachment_count), 0) as attachmentCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='1') as clickCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='1' and a.status=1) as clickCount,
(select COUNT(distinct project_id) from project_resource_library) as projectCount
from achievements
where source = '1'
where source = '1' and status='1'
</select>
<select id="indexTaskStatistic" resultType="java.util.Map">
select (select count(distinct trl.task_id) from achievements a join task_resource_library trl on a.source_id = trl.id where a.source='2') as taskCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='2') as clickCount,
select (select count(distinct trl.task_id) from achievements a join task_resource_library trl on a.source_id = trl.id where a.source='2' and a.status=1) as taskCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='2' and a.status=1) as clickCount,
COUNT(*) as expertAuditCount
from achievements
where source = '2'
where source = '2' and status=1
</select>
<select id="indexCompetitionStatistic" resultType="java.util.Map">
select COUNT(*) as CompetitionCountAchievementCount,
IFNULL(SUM(is_expert_audit), 0) as expertAuditCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='3') as clickCount,
(select COUNT(distinct open_competition_id) from competition_resource_library) as CompetitionCount
(select COUNT(distinct crl.open_competition_id) from achievements a join competition_resource_library crl
on a.source_id = crl.id where source = '3' and a.is_expert_audit = 1 and a.status='1') as expertAuditCount,
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='3' and a.status='1') as clickCount,
(select COUNT(distinct open_competition_id) from competition_resource_library crl inner join achievements a on a.source_id=crl.id where a.status='1') as CompetitionCount
from achievements
where source = '3'
where source = '3' and status='1'
</select>
<select id="indexSchoolEnterpriseStatistic" resultType="java.lang.Long">
select COUNT(*)
from achievements a
where source = #{s}
and tags = #{t}
and a.status = '1'
<if test="t != null and t != ''">
and tags = #{t}
</if>
</select>
<select id="getAreasByName" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
@ -406,6 +436,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
union all
select review_area_one as "domainName" from experts
)a
where a.domainName is not null and a.domainName !=""
</select>
<select id="getActDataStatisticById"
@ -432,10 +463,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getWatchFavoriteStatusById" resultType="com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo">
select b.watchSum, d.favoriteSum
select b.watchSum, d.favoriteSum,c.userDockingSum
from (
(select count(1) as watchSum from watchers where watchable_type = 'Achievements' and watchable_id = #{id} and user_id=#{userId}) b,
(select count(1) as favoriteSum from favorites where favorite_type = 'Achievements' and favorite_id = #{id} and user_id=#{userId}) d
(select count(1) as favoriteSum from favorites where favorite_type = 'Achievements' and favorite_id = #{id} and user_id=#{userId}) d,
(select count(1) as userDockingSum from clickers where click_type = 'userDocking' and click_id = #{id} and user_id=#{userId}) c
)
</select>
@ -443,7 +475,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(*)
from achievements
<where>
<if test="source != null and source != ''">and `source` = #{source}</if>
<if test="t != null and t != ''">and `source` = #{t}</if>
<if test="s != null">and create_time &gt;= #{s}</if>
<if test="e != null">and create_time &lt;= #{e}</if>
</where>
@ -458,19 +490,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getAchievementType" resultType="java.util.Map">
select achievement_type as 'k', count(*) as 'v'
from achievements
from achievements where achievement_type is not null
group by achievement_type
</select>
<select id="getAchievementActData" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select * from (
select 'w' as `key`, DATE_FORMAT(created_at, '%Y') as name ,COUNT(*) as value from watchers where watchable_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y')
select '关注' as `key`, DATE_FORMAT(created_at, '%m-%d') as name ,COUNT(*) as value from watchers where watchable_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d')
union all
select 'c' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from clickers where click_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y')
select '浏览' as `key`, DATE_FORMAT(created_at, '%m-%d') as name,COUNT(*) as value from clickers where click_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d')
union all
select 'd' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from downloads where download_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y')
select '下载' as `key`, DATE_FORMAT(created_at, '%m-%d') as name,COUNT(*) as value from downloads where download_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d')
union all
select 'f' as `key`, DATE_FORMAT(created_at, '%Y') as name,COUNT(*) as value from favorites where favorite_type = 'Achievements' group by DATE_FORMAT(created_at, '%Y'))t
select '收藏' as `key`, DATE_FORMAT(created_at, '%m-%d') as name,COUNT(*) as value from favorites where favorite_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d'))t
order by t.name
</select>
@ -490,7 +522,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by field_3) a
group by a.domain_value
order by sum(a.countResult) desc) f
right join categories c on c.id = f.name
right join categories c on c.id = f.name where f.value is not null
</select>
@ -510,24 +542,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getAreaStatistic" resultType="com.microservices.dms.achievementLibrary.domain.AreaStatisticVo">
select z.name as "areaName",
z.field_1 as "areaKey",
z.remark as "remark",
sum(z.kyxm) as "kyxmSum",
sum(z.ckrw) as "ckrwSum",
sum(z.kfjs) as "kfjsSum",
sum(z.xqcg) as "xqcgSum"
from (select r.name,
r.field_1,
r.remark,
case when r.source = 1 then tmp else 0 end as "kyxm",
case when r.source = 2 then tmp else 0 end as "ckrw",
case when r.source = 3 then tmp else 0 end as "kfjs",
case when r.source = 4 then tmp else 0 end as "xqcg"
from (select c.name, a.source, count(1) as "tmp", a.field_1, c.remark
from achievements a
inner join categories c on a.field_1 = c.id
group by c.name, a.source, a.field_1, c.remark) r) z
select
z.name as "areaName",
z.field_1 as "areaKey",
z.remark as "remark",
sum(z.kyxm) as "kyxmSum",
sum(z.ckrw) as "ckrwSum",
sum(z.kfjs) as "kfjsSum",
sum(z.xqcg) as "xqcgSum"
from (
select r.name,
r.field_1,
r.remark,
case when r.source = 1 then tmp else 0 end as "kyxm",
case when r.source = 2 then tmp else 0 end as "ckrw",
case when r.source = 3 then tmp else 0 end as "kfjs",
case when r.source = 4 then tmp else 0 end as "xqcg"
from (
select t.name,t.source,count(1) as "tmp",t.field_1,t.remark
from (
select c.name,a.source, a.field_1,c.remark
from achievements a
left join project_categories c on a.field_1 = c.id where a.source='1'
union all
select c.name, a.source, a.field_1, c.remark
from achievements a
left join categories c on a.field_1 = c.id where a.source in ('2','3','4')
)t
where t.field_1 is not null and t.field_1 !=""
group by t.name, t.source, t.field_1, t.remark
) r
) z
<where>
<if test="areaKey != null and areaKey != ''">
and z.field_1 = #{areaKey}
@ -542,6 +587,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where project_id = (select project_id from project_resource_library where id = #{sourceId})
</select>
<select id="getAllSourceIdCompetition" resultType="java.lang.Long">
select id
from competition_resource_library
where open_competition_id = (select open_competition_id from competition_resource_library where id = #{sourceId})
</select>
<select id="getAllSourceIdTask" resultType="java.lang.Long">
select id
from task_resource_library
where task_id = (select task_id from task_resource_library where id = #{sourceId})
</select>
<select id="getDistinctYear" resultType="String">
select distinct DATE_FORMAT(create_time, '%Y')
from achievements
@ -561,6 +616,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
source as "source",
source_id as "sourceId" ,
achievement_name as "achRelateName",
show_ach_name as "showAchievementName",
#{paramYear} as resultYear
from achievements
where source_id in
@ -570,6 +626,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and DATE_FORMAT(create_time, '%Y') = #{paramYear}
order by DATE_FORMAT(create_time, '%m-%d')
</select>
<select id="getRelatedAchTaskOfExpert"
resultType="com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary">
select *
from task_resource_library erl
join
(select container_id
from task_expert
where container_type = 1
and `status` in (1, 2) and expert_id = #{id}
group by container_id
having count(*) > 0) as tmp
on erl.task_id = tmp.container_id
</select>
<select id="getRelatedAchCompetitionOfExpert"
resultType="com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary">
select *
from competition_resource_library erl
join
(select container_id
from task_expert
where container_type = 2
and `status` in (1, 2) and expert_id = #{id}
group by container_id
having count(*) > 0) as tmp
on erl.open_competition_id = tmp.container_id
</select>
<select id="selectAchievementsByName" resultType="Long">
select id
from achievements
@ -600,4 +686,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where a.id=#{id}
</if>
</select>
<select id="getAchievementAddYearlyData" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select DATE_FORMAT(create_time, '%Y-%m') as 'k', count(*) as 'v'
from achievements
where create_time &gt;= #{s}
and create_time &lt;= #{e}
group by DATE_FORMAT(create_time, '%Y-%m')
order by DATE_FORMAT(create_time, '%Y-%m')
</select>
<select id="getAchievementActDataW"
resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select '关注' as `key`, DATE_FORMAT(created_at, '%m-%d') as name ,COUNT(*) as value from watchers where watchable_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d')
</select>
<select id="getAchievementActDataC"
resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select '浏览' as `key`, DATE_FORMAT(created_at, '%m-%d') as name,COUNT(*) as value from clickers where click_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d')
</select>
<select id="getAchievementActDataD"
resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select '下载' as `key`, DATE_FORMAT(created_at, '%m-%d') as name,COUNT(*) as value from downloads where download_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d')
</select>
<select id="getAchievementActDataF"
resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select '收藏' as `key`, DATE_FORMAT(created_at, '%m-%d') as name,COUNT(*) as value from favorites where favorite_type = 'Achievements' and created_at &gt;= #{s} and created_at &lt;= #{e} group by DATE_FORMAT(created_at, '%m-%d')
</select>
<select id="getDockingUserInfo" resultType="java.util.Map">
select * from (
select u.id,u.login,u.nickname,p.name as "lastname,",u.phone,u.company_name,u.mail,p.card as "idNumber",e.entity_type,DATE_FORMAT(c.created_at,'%Y-%m-%d %H:%i:%s') as created_at
from users u
inner join entities e on u.id = e.user_id
inner join personalities p on e.id = p.entity_id
inner join (select created_at, user_id from clickers where click_id = #{id} and click_type ='userDocking' order by created_at desc limit 1) c on u.id = c.user_id
where u.authentication='1'
union all
select u.id,u.login,u.nickname,u.lastname,u.phone,en.name as "company_name",u.mail,en.credit_code as "idNumber",e.entity_type,DATE_FORMAT(c.created_at,'%Y-%m-%d %H:%i:%s') as created_at
from users u
inner join entities e on u.id = e.user_id
inner join enterprises en on e.id = en.entity_id
inner join (select created_at,user_id from clickers where click_id = #{id} and click_type ='userDocking' order by created_at desc limit 1) c on u.id = c.user_id
where u.enterprise_certification='1') t
order by t.created_at
</select>
</mapper>

View File

@ -139,21 +139,41 @@
</where>
</select>
<select id="selectActivityUserLibraryListAll" resultType="com.microservices.dms.behaviorImage.domain.ActivityUserLibrary">
select res.userId,res.loginName,res.userName,res.isExpert,res.isAuth,res.relatedCompetition,res.relatedTask,res.p1+res.p2+res.p3 as "relatedProject" from (
select u.id as "userId",u.login as "loginName",u.nickname as "userName",u.is_expert as "isExpert",u.authentication as "isAuth",
(select count(1) as "value" from tasks where is_delete='0' and status between 3 and 8 and user_id =u.id) as "relatedTask",
(select count(1) from competition_infos ci inner join competition_users cu on ci.id = cu.competition_info_id where cu.user_id =u.id) as "relatedCompetition",
(SELECT count(1) as "pCount" FROM `projects` WHERE id != 0 AND user_id =u.id) as p1,
( SELECT count(1) as "pCount"
FROM `projects`
INNER JOIN `members` ON `members`.`project_id` = `projects`.`id`
WHERE `projects`.`id` != 0 AND `projects`.`user_id` !=u.id AND `members`.`user_id` =u.id) as p2,
(SELECT count(1) as "pCount"
FROM `projects`
INNER JOIN `team_projects` ON `team_projects`.`project_id` = `projects`.`id`
INNER JOIN `teams` ON `teams`.`id` = `team_projects`.`team_id`
INNER JOIN `team_users` ON `team_users`.`team_id` = `teams`.`id`
WHERE `projects`.`id` != 0 AND `team_users`.`user_id` =u.id) as p3
from users u) res
where res.relatedCompetition >0 or res.relatedTask >0 or res.p1+res.p2+res.p3>0
</select>
<select id="getrelatedProjectCount" resultType="long">
select sum(r.pCount) from (
SELECT count(1) as "pCount" FROM `projects` WHERE id != 0 AND user_id = 1
SELECT count(1) as "pCount" FROM `projects` WHERE id != 0 AND user_id = #{userId}
union all
SELECT count(1) as "pCount"
FROM `projects`
INNER JOIN `members` ON `members`.`project_id` = `projects`.`id`
WHERE `projects`.`id` != 0 AND `projects`.`user_id` != 1 AND `members`.`user_id` = 1
WHERE `projects`.`id` != 0 AND `projects`.`user_id` != #{userId} AND `members`.`user_id` = #{userId}
union all
SELECT count(1) as "pCount"
FROM `projects`
INNER JOIN `team_projects` ON `team_projects`.`project_id` = `projects`.`id`
INNER JOIN `teams` ON `teams`.`id` = `team_projects`.`team_id`
INNER JOIN `team_users` ON `team_users`.`team_id` = `teams`.`id`
WHERE `projects`.`id` != 0 AND `team_users`.`user_id` = 1
WHERE `projects`.`id` != 0 AND `team_users`.`user_id` = #{userId}
)r
</select>
@ -286,13 +306,32 @@
)t group by t.resultType
</select>
<select id="getActivityStatistic" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select 'totalUser' as `key`, count(1) as " value" from users
union all
select'authTotal' as `key`,sum(u.authentication) as "value" from users u
union all
select 'totalexpert' as `key`, count(1) as " value"from users u
inner join experts e on u.id = e.user_id
where e.is_delete='0' and e.status = 1
<select id="getActivityStatistic" resultType="com.microservices.dms.behaviorImage.domain.ActivityUserTotal">
select count(1) as "totalUser",sum(r.isExpert) as "totalExpert",sum(r.enterprise_certification+r.authentication) as "authTotal" from (
select res.userId,res.loginName,res.userName,res.isExpert,res.authentication,res.enterprise_certification,res.relatedCompetition,res.relatedTask,res.p1+res.p2+res.p3 as "relatedProject" from (
select u.id as "userId",u.login as "loginName",u.nickname as "userName",u.is_expert as "isExpert",u.authentication,u.enterprise_certification,
(select count(1) as "value" from tasks where is_delete='0' and status between 3 and 8 and user_id =u.id) as "relatedTask",
(select count(1) from competition_infos ci inner join competition_users cu on ci.id = cu.competition_info_id where cu.user_id =u.id) as "relatedCompetition",
(SELECT count(1) as "pCount" FROM `projects` WHERE id != 0 AND user_id =u.id) as p1,
( SELECT count(1) as "pCount"
FROM `projects` INNER JOIN `members` ON `members`.`project_id` = `projects`.`id`
WHERE `projects`.`id` != 0 AND `projects`.`user_id` !=u.id AND `members`.`user_id` =u.id) as p2,
(SELECT count(1) as "pCount"
FROM `projects`
INNER JOIN `team_projects` ON `team_projects`.`project_id` = `projects`.`id`
INNER JOIN `teams` ON `teams`.`id` = `team_projects`.`team_id`
INNER JOIN `team_users` ON `team_users`.`team_id` = `teams`.`id`
WHERE `projects`.`id` != 0 AND `team_users`.`user_id` =u.id) as p3
from users u) res
where res.relatedCompetition >0 or res.relatedTask >0 or res.p1+res.p2+res.p3>0 )r
</select>
<select id="getUserBehaviorSum" resultType="com.microservices.dms.behaviorImage.domain.UserTypeTotalVo">
select
(select count(1) as "resultCount" from watchers where user_id = u.id ) as "watchSum",
(select count(1) as "resultCount" from favorites where user_id = u.id ) as "favoriteSum",
(select count(1) as "resultCount" from praise_treads where user_id = u.id ) as "praiseSum"
from users u
where u.id = #{userId}
</select>
</mapper>

View File

@ -284,21 +284,21 @@
<select id="getCompetitionYearlyPaperAdd"
resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select DATE_FORMAT(created_at, '%m-%d') as 'k', count(*) as 'v'
select DATE_FORMAT(created_at, '%Y-%m') as 'k', count(*) as 'v'
from competition_infos
where created_at &gt;= #{s}
and created_at &lt;= #{e}
group by DATE_FORMAT(created_at, '%m-%d')
order by DATE_FORMAT(created_at, '%m-%d')
group by DATE_FORMAT(created_at, '%Y-%m')
order by DATE_FORMAT(created_at, '%Y-%m')
</select>
<select id="getCompetitionYearlyFinish"
resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select DATE_FORMAT(upload_date, '%m-%d') as 'k', count(*) as 'v'
select DATE_FORMAT(upload_date, '%Y-%m') as 'k', count(*) as 'v'
from competition_infos
where upload_date &gt;= #{s}
and upload_date &lt;= #{e}
group by DATE_FORMAT(upload_date, '%m-%d')
order by DATE_FORMAT(upload_date, '%m-%d')
group by DATE_FORMAT(upload_date, '%Y-%m')
order by DATE_FORMAT(upload_date, '%Y-%m')
</select>
<insert id="insertCompetitionResourceLibrary" parameterType="CompetitionResourceLibrary" useGeneratedKeys="true"

View File

@ -72,15 +72,15 @@
<select id="selectExpertResourceLibraryList" parameterType="ExpertResourceLibrary"
resultType="com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary">
select * from ( select erl.id, e.id as expert_id,e.user_id, e.expert_name, e.highest_degree, e.graduated_from,
u.nickname as "userNickName",ue.gender as "gender",
u.nickname as "userNickName", IFNULL(erl.gender, ue.gender) as "gender",
e.id_number,images, attachments,
e.major, e.workplace, e.phone,
e.workplace_type, e.expert_email, erl.expert_summary, erl.expert_detail, e.professional_title, e.expert_type,
expert_domain,u.authentication as expertAuth,
e.title_rank, erl.status, e.review_area_one, e.review_area_two, e.review_area_three, e.is_delete, erl.create_by,
erl.create_time,
(select COUNT(*) from task_expert where expert_id = e.id and container_type = 1 and `status` in (1,2)) as taskAuditCount,
(select COUNT(*) from task_expert where expert_id = e.id and container_type = 2 and `status` in (1,2)) as competitionAuditCount,
(select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 1 and `status` in (1,2)) as taskAuditCount,
(select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 2 and `status` in (1,2)) as competitionAuditCount,
erl.update_by, erl.update_time,erl.sort_no
from experts e
inner join users u on e.user_id = u.id
@ -121,7 +121,7 @@
<select id="selectExpertResourceLibraryList2" parameterType="ExpertResourceLibrary"
resultMap="ExpertResourceLibraryResult">
select erl.id, e.id as expert_id,e.user_id, e.expert_name, e.highest_degree, e.graduated_from, e.id_number,
e.major, e.workplace, e.phone,
e.major, e.workplace, e.phone,u.nickname as "userNickName", IFNULL(erl.gender, ue.gender) as "gender",
e.workplace_type, e.expert_email, erl.expert_summary, erl.expert_detail, e.professional_title, e.expert_type,
expert_domain,images, attachments,
e.title_rank, erl.status, e.review_area_one, e.review_area_two, e.review_area_three, e.is_delete, erl.create_by,
@ -131,7 +131,10 @@
(select count(*) as watchSum from watchers where watchable_type = 'Experts' and watchable_id = erl.id) as watcherSum,
(select count(*) as favoriteSum from favorites where favorite_type = 'Experts' and favorite_id = erl.id) as favoriteSum,
erl.update_by, erl.update_time,erl.sort_no
from expert_resource_library erl left join experts e on e.id = erl.expert_id
from expert_resource_library erl
left join experts e on e.id = erl.expert_id
left join users u on e.user_id = u.id
left join user_extensions ue on u.id = ue.user_id
<where>
<if test="userId != null ">and user_id = #{userId}</if>
<if test="expertName != null and expertName != ''">and erl.expert_name like concat('%', #{expertName}, '%')
@ -179,15 +182,15 @@
<select id="competitionAuditCount" resultType="java.lang.Long">
select IFNULL(SUM(competitionAuditCount), 0)
from (select (select COUNT(distinct container_id)
from task_expert
where expert_id = e.id and container_type = 2 and `status` in (1,2)) as competitionAuditCount
from experts e) tmp
from (select COUNT(distinct container_id) as competitionAuditCount
from task_expert te
join experts e on e.id = te.expert_id and te.container_type = 2 and te.`status` in (1, 2)) tmp
</select>
<select id="taskAuditCount" resultType="java.lang.Long">
select IFNULL(SUM(taskAuditCount), 0)
from (select (select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 1 and `status` in (1,2)) as taskAuditCount
from experts e) tmp
from (select COUNT(distinct container_id) as taskAuditCount
from task_expert te
join experts e on e.id = te.expert_id and te.container_type = 1 and te.`status` in (1, 2)) tmp
</select>
<select id="auditCompetitionAuditExpertCount" resultType="java.lang.Long">
select count(*)
@ -367,12 +370,12 @@
select b.expertTotal as "total", d.expertAuth as "value"
from (
(select count(1) as "expertTotal" from experts where is_delete = '0' and status = 1) b,
(select count(1) as "expertAuth"
from experts e
inner join users u on e.user_id = u.id
where e.is_delete = '0'
and e.status = 1
and u.authentication = true) d
(select count(1) as "expertAuth"
from experts e
inner join users u on e.user_id = u.id
where e.is_delete = '0'
and e.status = 1
and (u.authentication = true or u.enterprise_certification='1')) d
)
</select>
@ -415,6 +418,8 @@
and review_area_three is not null
and review_area_three != '') a
group by a.domain_value
order by count(a.domain_value) desc
limit 0,9
</select>
<select id="getExpertAduit" resultType="com.microservices.dms.achievementLibrary.domain.ExpertTotallVo">
@ -424,17 +429,13 @@
(tmp.taskAuditCount + tmp.competitionAuditCount) as "total"
from (select e.expert_name,
(select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 1 and `status` in (1,2)) as taskAuditCount,
(select COUNT(distinct container_id)
from task_expert
where expert_id = e.id
and container_type = 2 and `status` in (1,2)) as competitionAuditCount
(select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 2 and `status` in (1,2)) as competitionAuditCount
from experts e
inner join users u on e.user_id = u.id
left join expert_resource_library erl on e.id = erl.user_id
left join users u on e.user_id = u.id
where e.is_delete = '0'
and e.status = 1) tmp
order by (tmp.taskAuditCount + tmp.competitionAuditCount) desc
limit 0,9
order by (tmp.taskAuditCount + tmp.competitionAuditCount) desc
limit 0,12
</select>
@ -451,10 +452,11 @@
</select>
<select id="getWatchFavoriteStatusById" resultType="com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo">
select b.watchSum, d.favoriteSum
select b.watchSum, d.favoriteSum,c.userDockingSum
from (
(select count(1) as watchSum from watchers where watchable_type = 'Experts' and watchable_id = #{id} and user_id=#{userId}) b,
(select count(1) as favoriteSum from favorites where favorite_type = 'Experts' and favorite_id = #{id} and user_id=#{userId}) d
(select count(1) as favoriteSum from favorites where favorite_type = 'Experts' and favorite_id = #{id} and user_id=#{userId}) d,
(select count(1) as userDockingSum from clickers where click_type = 'userDocking' and click_id = #{id} and user_id=#{userId}) c
)
</select>
@ -494,14 +496,15 @@
<select id="getForumSectionStatistic" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select a.ancestry as "key", fs.title as "name", a.tmp as "value"
from (select f.ancestry, count(1) as "tmp"
from memos m
left join forum_sections f on m.forum_section_id = f.id
where m.destroy_status is null
and m.hidden = 0
and m.published_at is not null
group by f.ancestry) a
left join forum_sections fs on fs.id = a.ancestry
from (
select IFNULL(f.ancestry, m.forum_section_id) as"ancestry",count(1) as "tmp" from memos m
inner join forum_sections f on m.forum_section_id = f.id
where m.destroy_status is null
and m.hidden = 0
and m.published_at is not null
group by IFNULL(f.ancestry, m.forum_section_id)
) a
left join forum_sections fs on fs.id = a.ancestry
ORDER BY a.ancestry DESC
</select>
@ -524,13 +527,13 @@
</select>
<select id="get7DayPaise" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select DATE_FORMAT(created_at, '%Y-%m-%d') as 'k', count(*) as 'v'
select DATE_FORMAT(created_at, '%m-%d') as 'k', count(*) as 'v'
from praise_treads
where praise_tread_object_type='Memo'
and created_at &gt;= #{s}
and created_at &lt;= #{e}
group by DATE_FORMAT(created_at, '%Y-%m-%d')
order by DATE_FORMAT(created_at, '%Y-%m-%d')
group by DATE_FORMAT(created_at, '%m-%d')
order by DATE_FORMAT(created_at, '%m-%d')
</select>
<select id="getExpertInfoById" resultType="com.microservices.dms.resourceLibrary.domain.vo.ExpertAttachmentVo">

View File

@ -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>

View File

@ -35,10 +35,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="achievementStatus" column="achievement_status" />
<result property="achievementLittleType" column="achievement_little_type" />
<result property="achievementCurStatus" column="achievement_cur_status" />
<result property="teamName" column="team_name" />
</resultMap>
<sql id="selectSchoolEnterpriseAchievementsVo">
select id, achievement_name, achievement_status,field_1, field_2, field_3, achievement_type, source, source_id, source_link, tags, summary, publishing_unit, address, is_featured, contact_person, contact_number, owner_id, owner_name, status, details, reviewer, review_date, review_comments, images, attachments, create_by, create_time, update_by, update_time from school_enterprise_achievements
select id, achievement_name, achievement_status,field_1, field_2, field_3,
achievement_type, source, source_id, source_link, tags, summary, publishing_unit,
address, is_featured, contact_person, contact_number, owner_id, owner_name, status, achievement_little_type,
details, reviewer, review_date, review_comments, images, attachments, create_by, create_time, achievement_cur_status,team_name,
update_by, update_time from school_enterprise_achievements
</sql>
<select id="selectSchoolEnterpriseAchievementsList" parameterType="SchoolEnterpriseAchievements" resultMap="SchoolEnterpriseAchievementsResult">
@ -70,6 +77,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="images != null and images != ''"> and images = #{images}</if>
<if test="attachments != null and attachments != ''"> and attachments = #{attachments}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="achievementCurStatus != null and achievementCurStatus != ''"> and achievement_cur_status = #{achievementCurStatus}</if>
<if test="achievementLittleType != null and achievementLittleType != ''"> and achievement_little_type = #{achievementLittleType}</if>
<if test="teamName != null and teamName != ''"> and team_name = #{teamName}</if>
</where>
</select>
@ -105,6 +115,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="reviewComments != null and reviewComments != ''"> and review_comments = #{reviewComments}</if>
<if test="images != null and images != ''"> and images = #{images}</if>
<if test="attachments != null and attachments != ''"> and attachments = #{attachments}</if>
<if test="achievementCurStatus != null and achievementCurStatus != ''"> and achievement_cur_status = #{achievementCurStatus}</if>
<if test="achievementLittleType != null and achievementLittleType != ''"> and achievement_little_type = #{achievementLittleType}</if>
<if test="teamName != null and teamName != ''"> and team_name = #{teamName}</if>
</where>
</select>
@ -140,6 +153,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="achievementStatus != null">achievement_status,</if>
<if test="achievementCurStatus != null">achievement_cur_status,</if>
<if test="achievementLittleType != null">achievement_little_type,</if>
<if test="teamName != null">team_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="achievementName != null">#{achievementName},</if>
@ -171,6 +187,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="achievementStatus != null">#{achievementStatus},</if>
<if test="achievementCurStatus != null">#{achievementCurStatus},</if>
<if test="achievementLittleType != null">#{achievementLittleType},</if>
<if test="teamName != null">#{teamName},</if>
</trim>
</insert>
@ -206,6 +225,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="achievementStatus != null">achievement_status = #{achievementStatus},</if>
<if test="achievementCurStatus != null">achievement_cur_status = #{achievementCurStatus},</if>
<if test="achievementLittleType != null">achievement_little_type = #{achievementLittleType},</if>
<if test="teamName != null">team_name = #{teamName},</if>
</trim>
where id = #{id}
</update>

View File

@ -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>
@ -66,5 +66,58 @@
select id from users where login = #{login} limit 1
</select>
<select id="selectTaskByStatus" resultType="com.microservices.dms.referral.vo.TaskVo">
select t.id,td.task_id, name, status, category_id, description
from tasks t
join task_details td on t.id = td.task_id
where status in
<foreach collection="statusIds" item="item" close=")" index="idx" open="(" separator=",">
#{item}
</foreach>
</select>
<select id="selectUsersById" resultType="java.util.Map">
select id,login,nickname from users where id = #{id}
</select>
<select id="selectTaskById" resultType="com.microservices.dms.referral.vo.TaskVo">
select t.id,td.task_id, name, status, category_id, description
from tasks t
join task_details td on t.id = td.task_id
where t.id =#{id}
</select>
<select id="selectExpertsBy" resultType="com.microservices.dms.referral.vo.ExpertVo">
select id,
user_id,
review_area_one,
review_area_two,
review_area_three,
(select IFNULL(nickname,login) from users u where u.id = e.user_id) as nickname
from experts e
where is_delete = 0
</select>
<select id="allTaskWithExpertIds" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select container_id as 'k', group_concat(expert_id) as v from task_expert where container_type = #{type}
group by container_id
</select>
<select id="selectCompetitionById" resultType="com.microservices.dms.referral.vo.TaskVo">
select t.id, title as name, status, description
from competition_infos t
where t.id =#{id}
</select>
<select id="selectCompetitionIdByStatus" resultType="com.microservices.dms.referral.vo.TaskVo">
select t.id, title as name, status, description,identifier
from competition_infos t
where upload_date &lt; 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>

View File

@ -522,11 +522,22 @@
</select>
<select id="getConvertedTaskAmount" resultType="java.lang.Double">
select IFNULL(sum(t.bounty), 0)
from tasks t
join (select distinct task_id from papers where status = 2) p on t.id = p.task_id
join task_resource_library on t.id = task_resource_library.task_id
where is_transferred_to_results_library = 1
select IFNULL(SUM(bounty), 0)
from (select distinct t.id, t.bounty
from tasks t
join (select distinct task_id from papers where status = 2) p on t.id = p.task_id
join task_resource_library on t.id = task_resource_library.task_id
where is_transferred_to_results_library = 1) tmp
</select>
<select id="getConvertedTaskAmount2" resultType="java.lang.Double">
select IFNULL(SUM(bounty), 0)
from (select distinct t.id, t.bounty
from tasks t
join (select task_id from papers where status = 2) p on t.id = p.task_id
join task_resource_library on t.id = task_resource_library.task_id
join achievements a on a.source_id = task_resource_library.id and a.source='2' and a.status= '1'
where is_transferred_to_results_library = 1) tmp
</select>
<select id="getConvertedTasksCount" resultType="java.lang.Long">

View File

@ -142,7 +142,7 @@ public class CommonController extends BaseController {
@ApiOperation("通用上传请求")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件实体", paramType = "form", dataType = "_file"),
@ApiImplicitParam(name = "type", value = "文件类型zone-identifier专区下支持文件标识的附件cms内容管理resource专区资源pms项目管理pms-gitlink项目管理gitlink附件gitlinkgitlink附件", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "type", value = "文件类型zone-identifier专区下支持文件标识的附件dms资源库cms内容管理resource专区资源pms项目管理pms-gitlink项目管理gitlink附件gitlinkgitlink附件", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "hierarchy", value = "层级结构eg: pms项目管理中{enterpriseIdentifier}/products,{enterpriseIdentifier}/projects,{enterpriseIdentifier}/docs/{projectId}", paramType = "query", dataType = "String")
})
public AjaxResult uploadFile(@RequestPart("file") MultipartFile file, String type, String hierarchy) {
@ -168,7 +168,7 @@ public class CommonController extends BaseController {
@DeleteMapping("/byIdentifier/{fileIdentifier}")
@ApiOperation("通用删除请求")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "文件类型cms内容管理resource专区资源pms项目管理pms-gitlink项目管理gitlink附件", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "type", value = "文件类型cms内容管理dms资源库resource专区资源pms项目管理pms-gitlink项目管理gitlink附件", paramType = "query", dataType = "String")
})
public AjaxResult deleteFile(@PathVariable("fileIdentifier") String fileIdentifier, @RequestParam("type") String type) {
return toAjax(sysFileInfoService.deleteFile(fileIdentifier, type));

View File

@ -13,14 +13,12 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
@RestController
@RequestMapping("dashboard")
@Api(tags = "微服务大屏")
public class K8sDashboardController extends BaseController {
@Autowired
private IK8sDashboardService k8sNamespaceService;
private IK8sDashboardService k8sDashboardService;
/**
* 获取命名空间列表
@ -28,48 +26,54 @@ public class K8sDashboardController extends BaseController {
@ApiOperation(value = "获取命名空间列表")
@GetMapping("/namespace/list")
public GenericsTableDataInfo<K8sNamespace> namespaceList() {
return new GenericsTableDataInfo<>(k8sNamespaceService.getNamespaceDetailList(true));
return new GenericsTableDataInfo<>(k8sDashboardService.getNamespaceDetailList(true));
}
@ApiOperation(value = "获取集群节点列表")
@GetMapping("/cluster/Nodelist")
public GenericsTableDataInfo<K8sClusterNode> clusterNodeList() {
return new GenericsTableDataInfo<>(k8sNamespaceService.getClusterNodeList());
return new GenericsTableDataInfo<>(k8sDashboardService.getClusterNodeList());
}
@ApiOperation(value = "获取应用Pod Ip列表")
@GetMapping("/application/{kind}/{namespace}/{applicationName}/podIdList")
public GenericsTableDataInfo<String> applicationPodIdList(@PathVariable("kind") String kind, @PathVariable("namespace") String namespace, @PathVariable("applicationName") String applicationName) {
return new GenericsTableDataInfo<>(k8sNamespaceService.getApplicationPodIdList(kind, namespace, applicationName));
return new GenericsTableDataInfo<>(k8sDashboardService.getApplicationPodIdList(kind, namespace, applicationName));
}
@ApiOperation(value = "获取集群状态数据")
@GetMapping("/cluster/status")
public GenericsAjaxResult<K8sClusterStatus> clusterStatus() {
return GenericsAjaxResult.success(k8sNamespaceService.getClusterStatus());
return GenericsAjaxResult.success(k8sDashboardService.getClusterStatus());
}
@ApiOperation(value = "集群每秒请求率QPS")
@GetMapping("/cluster/qps")
public GenericsTableDataInfo<MetricCommonData> clusterQps() {
return new GenericsTableDataInfo<>(k8sNamespaceService.getClusterQps());
return new GenericsTableDataInfo<>(k8sDashboardService.getClusterQps());
}
@ApiOperation(value = "最近24小时应用接口请求次数")
@GetMapping("/cluster/applicationRequestCount")
public GenericsTableDataInfo<ApplicationRequestCountData> applicationRequestCount() {
return new GenericsTableDataInfo<>(k8sNamespaceService.getApplicationRequestCount());
return new GenericsTableDataInfo<>(k8sDashboardService.getApplicationRequestCount());
}
@ApiOperation(value = "获取Pod容器状态")
@GetMapping("/cluster/podContainerStatus/{containerID}")
public GenericsAjaxResult<K8sPodContainerStatus> podContainerStatus(@PathVariable("containerID") String containerID) {
return GenericsAjaxResult.success(k8sNamespaceService.getPodContainerStatus(containerID));
return GenericsAjaxResult.success(k8sDashboardService.getPodContainerStatus(containerID));
}
@ApiOperation(value = "获取服务器节点状态")
@GetMapping("/cluster/nodeStatus/{nodeIp}")
public GenericsAjaxResult<K8sNodeStatus> nodeStatus(@PathVariable("nodeIp") String nodeIp) {
return GenericsAjaxResult.success(k8sNamespaceService.getNodeStatus(nodeIp));
return GenericsAjaxResult.success(k8sDashboardService.getNodeStatus(nodeIp));
}
@ApiOperation(value = "获取微服务应用功能列表")
@GetMapping("/applicationFunction/{kind}/{namespace}/{applicationName}")
public GenericsTableDataInfo<ApplicationFunction> applicationFunction(@PathVariable("kind") String kind, @PathVariable("namespace") String namespace, @PathVariable("applicationName") String applicationName) {
return new GenericsTableDataInfo<>(k8sDashboardService.getApplicationFunction(kind,namespace,applicationName));
}
}

View File

@ -0,0 +1,22 @@
package com.microservices.mon.k8s.domain;
import com.alibaba.fastjson2.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("应用功能")
public class ApplicationFunction {
@ApiModelProperty(value = "应用功能标识")
private String key;
@ApiModelProperty(value = "应用功能名称")
private String name;
@ApiModelProperty(value = "应用功能访问所需参数")
private JSONObject variables;
public void setKeyAndName(ApplicationFunctionType applicationFunctionType) {
this.key = applicationFunctionType.getKey();
this.name = applicationFunctionType.getName();
}
}

View File

@ -0,0 +1,41 @@
package com.microservices.mon.k8s.domain;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.StringUtils;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
/**
* @author OTTO
*/
@Getter
public enum ApplicationFunctionType {
LINK_TRACKING("LinkTracking", "链路追踪", "mon-skywalking-key"),
FLOW_CONTROL("FlowControl", "流量控制", "mon-sentinel-key"),
CONFIGURATION_MANAGEMENT("ConfigurationManagement", "配置管理", ""),
REGISTRATION_CENTER("RegistrationCenter", "注册中心", "mon-nacos-key"),
GATEWAY_MANAGEMENT("GatewayManagement", "网关管理", "mon-gateway-key"),
START_AND_STOP_MANAGEMENT("StartAndStopManagement", "启停管理", "");
private final String key;
private final String name;
private final String k8sLabel;
ApplicationFunctionType(String key, String name, String k8sLabel) {
this.key = key;
this.name = name;
this.k8sLabel = k8sLabel;
}
public static ApplicationFunctionType getByLabelsKey(String k8sLabel) {
if (StringUtils.isNotEmpty(k8sLabel)) {
for (ApplicationFunctionType type : ApplicationFunctionType.values()) {
if (type.getK8sLabel().equals(k8sLabel)) {
return type;
}
}
}
return null;
}
}

View File

@ -2,7 +2,6 @@ package com.microservices.mon.k8s.service;
import com.microservices.mon.k8s.domain.*;
import java.util.HashMap;
import java.util.List;
public interface IK8sDashboardService {
@ -21,4 +20,6 @@ public interface IK8sDashboardService {
K8sPodContainerStatus getPodContainerStatus(String containerID);
K8sNodeStatus getNodeStatus(String nodeIp);
List<ApplicationFunction> getApplicationFunction(String kind, String namespace, String applicationName);
}

View File

@ -10,4 +10,7 @@ public abstract class CommonService {
@Value("${rancher.nginxApplicationId}")
public String nginxApplicationId;
@Value("${skywalking.group}")
public String skywalkingGroup;
}

View File

@ -10,8 +10,10 @@ import com.microservices.mon.k8s.domain.vo.*;
import com.microservices.mon.k8s.service.IK8sDashboardService;
import com.microservices.mon.k8s.service.IMonCommonAsyncService;
import com.microservices.mon.k8s.utils.PromQLConstant;
import com.microservices.mon.k8s.utils.SkywalkingGQLConstant;
import com.microservices.system.api.RemoteGatewayService;
import com.microservices.system.api.RemoteRancherService;
import com.microservices.system.api.model.GraphqlQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -126,6 +128,7 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
List<MetricCommonData> metricCommonDataList = new ArrayList<>();
Date now = DateUtils.getNowDate();
long endTime = now.getTime() / 1000;
// 开始时间为当前时间减去1小时
Long startTime = now.getTime() / 1000 - 60 * 60;
JSONObject nodeCountJson = remoteGatewayService.getPrometheusQueryRangeRes(PromQLConstant.CLUSTER_QPS, 14L, startTime, endTime, SecurityContextHolder.getUserKey());
if (nodeCountJson != null && nodeCountJson.containsKey("data")) {
@ -137,7 +140,7 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
JSONArray value = prometheusResultVo.getValues().getJSONArray(i);
MetricCommonData metricCommonData = new MetricCommonData();
metricCommonData.setDate(new Date(value.getLong(0) * 1000));
String valueStr=String.format("%.2f",value.getFloatValue(1));
String valueStr = String.format("%.2f", value.getFloatValue(1));
metricCommonData.setValue(Float.parseFloat(valueStr));
metricCommonDataList.add(metricCommonData);
}
@ -238,6 +241,111 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
return k8sNodeStatus;
}
@Override
public List<ApplicationFunction> getApplicationFunction(String kind, String namespace, String applicationName) {
List<ApplicationFunction> applicationFunctionsList = new ArrayList<>();
JSONObject applicationJson = remoteRancherService.getK8sApplicationDetail(cluster_id, K8sApplication.getApplicationFullKind(kind), namespace, applicationName, SecurityContextHolder.getUserKey());
RancherApplicationVo rancherApplicationVo = applicationJson.toJavaObject(RancherApplicationVo.class);
if (rancherApplicationVo != null && rancherApplicationVo.getMetadata() != null && rancherApplicationVo.getMetadata().getLabels() != null) {
// 所有应用添加启停管理功能
ApplicationFunction applicationFunction = new ApplicationFunction();
applicationFunction.setKeyAndName(ApplicationFunctionType.START_AND_STOP_MANAGEMENT);
// 使用命名空间和应用名称作为搜索条件
JSONObject functionVariables = new JSONObject();
functionVariables.put("namespace", namespace);
functionVariables.put("applicationName", applicationName);
applicationFunction.setVariables(functionVariables);
applicationFunctionsList.add(applicationFunction);
JSONObject LabelsJson = rancherApplicationVo.getMetadata().getLabels();
for (String key : LabelsJson.keySet()) {
String k8sLabelValue = LabelsJson.getString(key);
ApplicationFunctionType applicationFunctionType = ApplicationFunctionType.getByLabelsKey(key);
if (applicationFunctionType != null) {
switch (applicationFunctionType) {
case LINK_TRACKING:
// 处理应用链路追踪功能相关逻辑
GraphqlQueryVo gqlQueryVo = SkywalkingGQLConstant.getAllServicesByGroup(skywalkingGroup);
JSONObject skywalkingServices = remoteGatewayService.executeSkywalkingGql(gqlQueryVo);
if (skywalkingServices != null
&& skywalkingServices.getJSONObject("data") != null
&& skywalkingServices.getJSONObject("data").getJSONArray(gqlQueryVo.getOperationName()) != null) {
JSONArray skywalkingServicesArray = skywalkingServices.getJSONObject("data").getJSONArray(gqlQueryVo.getOperationName());
for (int i = 0; i < skywalkingServicesArray.size(); i++) {
JSONObject skywalkingService = skywalkingServicesArray.getJSONObject(i);
if (k8sLabelValue.equals(skywalkingService.getString("shortName"))) {
applicationFunction = new ApplicationFunction();
applicationFunction.setKeyAndName(applicationFunctionType);
functionVariables = new JSONObject();
functionVariables.put("serviceId", skywalkingService.getString("id"));
applicationFunction.setVariables(functionVariables);
applicationFunctionsList.add(applicationFunction);
}
}
}
break;
case FLOW_CONTROL:
// 处理应用流量控制功能相关逻辑
JSONObject sentinelAppList = remoteGatewayService.getSentinelAppList(SecurityContextHolder.getUserKey());
if (sentinelAppList != null && sentinelAppList.getBoolean("success") && sentinelAppList.getJSONArray("data") != null && !sentinelAppList.getJSONArray("data").isEmpty()) {
JSONArray sentinelAppListArray = sentinelAppList.getJSONArray("data");
for (int i = 0; i < sentinelAppListArray.size(); i++) {
JSONObject sentinelApp = sentinelAppListArray.getJSONObject(i);
if (k8sLabelValue.equals(sentinelApp.getString("app"))) {
applicationFunction = new ApplicationFunction();
applicationFunction.setKeyAndName(applicationFunctionType);
functionVariables = new JSONObject();
functionVariables.put("app", k8sLabelValue);
functionVariables.put("appType", sentinelApp.getLongValue("appType"));
applicationFunction.setVariables(functionVariables);
applicationFunctionsList.add(applicationFunction);
}
}
}
break;
case REGISTRATION_CENTER:
// 处理应用注册中心功能相关逻辑
JSONObject nacosServiceList = remoteGatewayService.getNacosServiceList(k8sLabelValue, SecurityContextHolder.getUserKey());
if (nacosServiceList != null && nacosServiceList.getJSONArray("serviceList") != null && !nacosServiceList.getJSONArray("serviceList").isEmpty()) {
JSONArray nacosServiceListArray = nacosServiceList.getJSONArray("serviceList");
for (int i = 0; i < nacosServiceListArray.size(); i++) {
JSONObject nacosService = nacosServiceListArray.getJSONObject(i);
if (k8sLabelValue.equals(nacosService.getString("name"))) {
applicationFunction = new ApplicationFunction();
applicationFunction.setKeyAndName(applicationFunctionType);
functionVariables = new JSONObject();
functionVariables.put("name", k8sLabelValue);
applicationFunction.setVariables(functionVariables);
applicationFunctionsList.add(applicationFunction);
}
}
}
break;
case GATEWAY_MANAGEMENT:
// 处理应用网关管理功能相关逻辑
JSONObject nacosConfigList = remoteGatewayService.getNacosConfigList(String.format("*%s*", k8sLabelValue), SecurityContextHolder.getUserKey());
if (nacosConfigList != null && nacosConfigList.getJSONArray("pageItems") != null && !nacosConfigList.getJSONArray("pageItems").isEmpty()) {
JSONArray nacosConfigListJSONArray = nacosConfigList.getJSONArray("pageItems");
for (int i = 0; i < nacosConfigListJSONArray.size(); i++) {
JSONObject nacosService = nacosConfigListJSONArray.getJSONObject(i);
String dataId = nacosService.getString("dataId");
if (StringUtils.isNotEmpty(dataId) && dataId.contains(k8sLabelValue)) {
applicationFunction = new ApplicationFunction();
applicationFunction.setKeyAndName(applicationFunctionType);
functionVariables = new JSONObject();
functionVariables.put("dataId", dataId);
applicationFunction.setVariables(functionVariables);
applicationFunctionsList.add(applicationFunction);
}
}
}
break;
}
}
}
}
return applicationFunctionsList;
}
private List<K8sNamespace> getK8sNamespaceList() {
List<K8sNamespace> k8sNamespaceList = new ArrayList<>();
List<RancherNamespaceVo> rancherNamespaceVoList;

View File

@ -6,51 +6,67 @@ import java.util.List;
* Prometheus查询常量
*/
public class PromQLConstant {
// 集群可用节点数:sum(kube_node_info)
public static String CLUSTER_NODE_COUNT(String clusterId) {
return String.format("sum(kube_node_info{cluster=~\"%s\"})", clusterId);
}
// 集群不可用节点数:sum(kube_node_spec_unschedulable)
public static String CLUSTER_UNAVAILABLE_NODE_COUNT(String clusterId) {
return String.format("sum(kube_node_spec_unschedulable{cluster=~\"%s\"})", clusterId);
}
// 集群cpu使用率:(sum(kube_pod_container_resource_requests{resource="cpu"})/ sum(kube_node_status_allocatable{resource="cpu"}))*100
public static String CLUSTER_CPU_USAGE(String clusterId) {
return String.format("(sum(kube_pod_container_resource_requests{cluster=~\"%s\",resource=\"cpu\"})/ sum(kube_node_status_allocatable{cluster=~\"%s\",resource=\"cpu\"}))*100", clusterId, clusterId);
}
// 集群POD使用率:(sum(kube_pod_info) / sum(kube_node_status_allocatable{resource="pods"}))*100
public static String CLUSTER_POD_USAGE(String clusterId) {
return String.format("(sum(kube_pod_info{cluster=~\"%s\"}) / sum(kube_node_status_allocatable{cluster=~\"%s\",resource=\"pods\"}))*100", clusterId, clusterId);
}
// 集群内存使用率:(sum(kube_pod_container_resource_requests{resource="memory"}) / sum(kube_node_status_allocatable{resource="memory"}))*100
public static String CLUSTER_MEMORY_USAGE(String clusterId) {
return String.format("(sum(kube_pod_container_resource_requests{cluster=~\"%s\",resource=\"memory\"}) / sum(kube_node_status_allocatable{cluster=~\"%s\",resource=\"memory\"}))*100", clusterId, clusterId);
}
// 集群最近24小时请求总数:sum(increase(nginx_http_response_count_total[1d]))
public static final String TOTAL_REQUEST_COUNT_TODAY = "round(sum(increase(nginx_http_response_count_total[1d])))";
// 集群最近24小时平均处理时间:sum(rate(nginx_http_response_time_seconds_sum[1d]))*1000
public static final String AVERAGE_REQUEST_PROCESSING_TIME_TODAY = "sum(rate(nginx_http_response_time_seconds_sum[1d]))*1000";
// 集群最近24小时请求成功率:(sum(nginx_http_response_count_total{status=~"2.*|3.*"})/sum(nginx_http_response_count_total))*100
public static final String REQUEST_SUCCESS_RATE_TODAY = "(sum(nginx_http_response_count_total{status=~\"2.*|3.*\"})/sum(nginx_http_response_count_total))*100";
// 集群最近24小时微服务重启次数:sum(increase(kube_pod_container_status_restarts_total{namespace=~"base-service|data|forgeplus|microservices|portal"}[1d]))
public static String MICROSERVICE_RESTART_COUNT_TODAY(String clusterId, List<String> namespaceNameList) {
return String.format("sum(increase(kube_pod_container_status_restarts_total{cluster=~\"%s\",namespace=~\"%s\"}[1d]))", clusterId, String.join("|", namespaceNameList));
}
// POD运行状态:sum(kube_pod_status_phase{namespace=~"base-service|data|forgeplus|microservices|portal", phase!="Unknown"}) by (phase)
public static String POD_STATUS(String clusterId, List<String> namespaceNameList) {
return String.format("sum(kube_pod_status_phase{cluster=~\"%s\",namespace=~\"%s\", phase!=\"Unknown\"}) by (phase)", clusterId, String.join("|", namespaceNameList));
}
// 应用最近24小时请求数:sort_desc(round(sum(increase(nginx_http_response_count_total[1d])) by (server_port)))
public static String APPLICATION_REQUEST_COUNT = "sort_desc(round(sum(increase(nginx_http_response_count_total[1d])) by (server_port)))";
public static String CLUSTER_QPS = "sum(rate(nginx_http_response_time_seconds_count[10m])) ";
// 集群QPS:sum(rate(nginx_http_response_time_seconds_count[10m]))
public static String CLUSTER_QPS = "sum(rate(nginx_http_response_time_seconds_count[10m]))";
// 容器CPU使用率:sum without (dc,from,id) (irate(container_cpu_user_seconds_total{container_label_io_kubernetes_sandbox_id="xxxxxxx"}[5m]) * 100)
public static String POD_CPU_USAGE(String containerId) {
return String.format("sum without (dc,from,id) (irate(container_cpu_user_seconds_total{container_label_io_kubernetes_sandbox_id=\"%s\"}[5m]) * 100)", containerId);
}
// 容器内存使用率:sum without (dc,from,id) (container_memory_usage_bytes{container_label_io_kubernetes_sandbox_id="xxxxxxx"} - container_memory_cache{container_label_io_kubernetes_sandbox_id="xxxxxxx"})
public static String POD_MEMORY_USAGE(String containerId) {
return String.format("sum without (dc,from,id) (container_memory_usage_bytes{container_label_io_kubernetes_sandbox_id=\"%s\"} - container_memory_cache{container_label_io_kubernetes_sandbox_id=\"%s\"})", containerId, containerId);
}
// 节点CPU使用率:(sum by(instance) (irate(node_cpu_seconds_total{ip="xxxxxxx",mode!="idle"}[1m])) / on(instance) group_left sum by (instance)((irate(node_cpu_seconds_total{ip="xxxxxxx"}[1m])))) * 100
public static String NODE_CPU_USAGE(String nodeIp) {
return String.format("(sum by(instance) (irate(node_cpu_seconds_total{ip=\"%s\",mode!=\"idle\"}[1m])) / on(instance) group_left sum by (instance)((irate(node_cpu_seconds_total{ip=\"%s\"}[1m])))) * 100", nodeIp, nodeIp);
}
// 节点内存使用率:100 - ((node_memory_MemAvailable_bytes{ip="xxxxxxx"} * 100) / node_memory_MemTotal_bytes{ip="xxxxxxx"})
public static String NODE_MEMORY_USAGE(String nodeIp) {
return String.format("100 - ((node_memory_MemAvailable_bytes{ip=\"%s\"} * 100) / node_memory_MemTotal_bytes{ip=\"%s\"})", nodeIp, nodeIp);
}

View File

@ -0,0 +1,36 @@
package com.microservices.mon.k8s.utils;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.system.api.model.GraphqlQueryVo;
import java.util.Date;
/**
* Prometheus查询常量
*/
public class SkywalkingGQLConstant {
public static GraphqlQueryVo getAllServicesByGroup(String skywalkingGroup) {
GraphqlQueryVo graphqlQueryVo = new GraphqlQueryVo();
graphqlQueryVo.setOperationName("getAllServices");
graphqlQueryVo.setQuery("query getAllServices($group:String!,$duration:Duration!){\n" +
" getAllServices(group:$group,duration:$duration ){\n" +
" id,\n" +
" shortName\n" +
" }\n" +
"}");
JSONObject variables = new JSONObject();
variables.put("group",skywalkingGroup);
JSONObject duration = new JSONObject();
Date endDate=DateUtils.getNowDate();
Date startDate=DateUtils.addDays(endDate,-1);
String dateFormat="yyyy-MM-dd";
duration.put("start",DateUtils.parseDateToStr(dateFormat,startDate));
duration.put("end",DateUtils.parseDateToStr(dateFormat,endDate));
duration.put("step","HOUR");
variables.put("duration",duration);
graphqlQueryVo.setVariables(variables);
return graphqlQueryVo;
}
}

View File

@ -121,6 +121,12 @@
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<!-- Apache POI for Word processing -->
<!-- <dependency>-->
<!-- <groupId>org.apache.poi</groupId>-->
<!-- <artifactId>poi-ooxml</artifactId>-->
<!-- <version>5.4.0</version>-->
<!-- </dependency>-->
<!-- 自然语言处理,用于自动提取文章概要 -->
<dependency>
<groupId>com.hankcs</groupId>
@ -139,6 +145,12 @@
<version>0.4.8</version>
<scope>compile</scope>
</dependency>
<!-- 文件导入、导出库 -->
<!-- <dependency>-->
<!-- <groupId>com.github.ben-manes.caffeine</groupId>-->
<!-- <artifactId>Java2Word</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </dependency>-->
</dependencies>
<build>

View File

@ -39,6 +39,7 @@ public class OpenController extends BaseController {
@GetMapping("/loginUrl")
@ApiOperation(value = "获取登录地址")
public AjaxResult loginUrl() {
logger.info("调用接口:获取登录地址");
return success(
(Object) EscapeUtil.removeExtraSlashOfUrl(gitLinkUrl + "/login")
);

View File

@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -172,6 +173,12 @@ public class PmsDashboardController extends BaseController {
}
todoProjectIssuesSearchVo.setPmProjectIds(StringUtils.join(projectList.stream().map(PmsProject::getId).toArray(), ","));
JSONObject result = pmsProjectIssuesService.selectMyTodoPmsProjectIssuesList(todoProjectIssuesSearchVo);
// 判断projectList中是否存在projectAssigneeId和当前用户id相等
Long currentUserId = SecurityUtils.getGitlinkUserId();
boolean isProjectAssigner = projectList.stream()
.anyMatch(project -> currentUserId != null && currentUserId.equals(project.getProjectAssigneeId()));
result.put("isProjectAssigner", isProjectAssigner);
return success(result);
}

View File

@ -20,7 +20,7 @@ import java.util.List;
/**
* 项目管理-文档库Controller
*
*
* @author wanjia
* @date 2024-01-08
*/
@ -30,8 +30,7 @@ import java.util.List;
@ApiImplicitParams({
@ApiImplicitParam(name = "enterpriseIdentifier", value = "企业标识", paramType = "path", dataType = "String")
})
public class PmsDocumentController extends BaseController
{
public class PmsDocumentController extends BaseController {
@Autowired
private IPmsDocumentService pmsDocumentService;
@ -46,8 +45,7 @@ public class PmsDocumentController extends BaseController
@ApiImplicitParam(name = "orderByColumn", value = "排序列更新时间updateTime创建时间createTime", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "isAsc", value = "排序的方向desc或者asc,默认asc", paramType = "query", dataType = "String")
})
public GenericsTableDataInfo<PmsDocumentVo> list( @Validated PmsDocumentSearchVo pmsDocumentSearchVo)
{
public GenericsTableDataInfo<PmsDocumentVo> list(@Validated PmsDocumentSearchVo pmsDocumentSearchVo) {
return pmsDocumentService.selectPmsDocumentVoList(pmsDocumentSearchVo);
}
@ -58,8 +56,7 @@ public class PmsDocumentController extends BaseController
@Log(title = "项目管理-文档库", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ApiOperation(value = "导出项目管理-文档库列表", hidden = true)
public void export(HttpServletResponse response, PmsDocument pmsDocument)
{
public void export(HttpServletResponse response, PmsDocument pmsDocument) {
List<PmsDocument> list = pmsDocumentService.selectPmsDocumentList(pmsDocument);
ExcelUtil<PmsDocument> util = new ExcelUtil<PmsDocument>(PmsDocument.class);
util.exportExcel(response, list, "项目管理-文档库数据");
@ -71,8 +68,7 @@ public class PmsDocumentController extends BaseController
// @RequiresPermissions("pms:document:query")
@GetMapping(value = "/{id}")
@ApiOperation(value = "获取项目管理-文档库详细信息")
public AjaxResult getInfo(@PathVariable("id") Long id, @ApiParam("企业id") @RequestParam(name = "enterpriseId") Long enterpriseId)
{
public AjaxResult getInfo(@PathVariable("id") Long id, @ApiParam("企业id") @RequestParam(name = "enterpriseId") Long enterpriseId) {
return success(pmsDocumentService.selectPmsDocumentDetailVoByIdAndEnterpriseId(id, enterpriseId));
}
@ -83,8 +79,7 @@ public class PmsDocumentController extends BaseController
@Log(title = "项目管理-文档库", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation(value = "新增项目管理-文档库")
public AjaxResult add(@RequestBody @Validated PmsDocumentInputVo pmsDocumentInputVo)
{
public AjaxResult add(@RequestBody @Validated PmsDocumentInputVo pmsDocumentInputVo) {
return toAjax(pmsDocumentService.insertPmsDocument(pmsDocumentInputVo.toPmsDocument()));
}
@ -95,8 +90,7 @@ public class PmsDocumentController extends BaseController
@Log(title = "新增附件类型文档", businessType = BusinessType.INSERT)
@PostMapping("/fileType")
@ApiOperation(value = "新增附件类型文档")
public AjaxResult addFileTypeDoc(@RequestBody @Validated PmsFileTypeDocumentInputVo pmsFileTypeDocumentInputVo)
{
public AjaxResult addFileTypeDoc(@RequestBody @Validated PmsFileTypeDocumentInputVo pmsFileTypeDocumentInputVo) {
return toAjax(pmsDocumentService.insertPmsFileTypeDocument(pmsFileTypeDocumentInputVo));
}
@ -107,8 +101,7 @@ public class PmsDocumentController extends BaseController
@Log(title = "项目管理-文档库", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation(value = "修改项目管理-文档库")
public AjaxResult edit(@RequestBody PmsDocumentUpdateVo pmsDocumentUpdateVo)
{
public AjaxResult edit(@RequestBody PmsDocumentUpdateVo pmsDocumentUpdateVo) {
return toAjax(pmsDocumentService.updatePmsDocument(pmsDocumentUpdateVo.toPmsDocument()));
}
@ -117,12 +110,11 @@ public class PmsDocumentController extends BaseController
*/
// @RequiresPermissions("pms:document:remove")
@Log(title = "项目管理-文档库", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@DeleteMapping("/{ids}")
@ApiOperation(value = "删除项目管理-文档库")
public AjaxResult remove(@PathVariable Long[] ids,
@ApiParam("企业id") @RequestParam(name = "enterpriseId") Long enterpriseId,
@ApiParam("项目id") @RequestParam(name = "pmsProjectId", defaultValue = "0") Long pmsProjectId)
{
@ApiParam("项目id") @RequestParam(name = "pmsProjectId", defaultValue = "0") Long pmsProjectId) {
return toAjax(pmsDocumentService.deletePmsDocumentByIds(ids, enterpriseId, pmsProjectId));
}
@ -131,8 +123,16 @@ public class PmsDocumentController extends BaseController
*/
@GetMapping(value = "/optionalWikiRepoList")
@ApiOperation(value = "导入wiki时可选的仓库列表")
public AjaxResult getOptionalWikiRepoList(@Validated OptionalWikiReposSearchVo optionalWikiReposSearchVo)
{
public AjaxResult getOptionalWikiRepoList(@Validated OptionalWikiReposSearchVo optionalWikiReposSearchVo) {
return success(pmsDocumentService.getOptionalWikiRepoList(optionalWikiReposSearchVo));
}
/**
* 下载文档类型文件
*/
@GetMapping(value = "/downloadDoc/{docId}")
@ApiOperation(value = "下载文档类型文件")
public void downloadDoc(@PathVariable String enterpriseIdentifier, @PathVariable Long docId, HttpServletResponse response) {
pmsDocumentService.downloadDoc(response, enterpriseIdentifier, docId);
}
}

View File

@ -5,6 +5,7 @@ import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.pms.document.domain.PmsDocument;
import com.microservices.pms.document.domain.vo.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -93,4 +94,6 @@ public interface IPmsDocumentService
* @return
*/
JSONObject getOptionalWikiRepoList(OptionalWikiReposSearchVo optionalWikiReposSearchVo);
void downloadDoc(HttpServletResponse response, String enterpriseIdentifier, Long docId);
}

View File

@ -5,6 +5,7 @@ import com.microservices.common.core.constant.HttpStatus;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.common.core.utils.file.FileUtils;
import com.microservices.common.core.web.page.Breadcrumb;
import com.microservices.common.core.web.page.GenericsTableDataInfo;
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
@ -21,6 +22,7 @@ import com.microservices.pms.enums.PmsDocumentType;
import com.microservices.pms.project.mapper.PmsProjectRepositoryMapper;
import com.microservices.pms.project.service.IPmsProjectService;
import com.microservices.pms.utils.PmsGitLinkRequestUrl;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@ -28,7 +30,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
@ -38,13 +45,13 @@ import static com.microservices.common.httpClient.constant.GitLinkConstants.DATA
/**
* 项目管理-文档库Service业务层处理
*
*
* @author wanjia
* @date 2024-01-08
*/
@Slf4j
@Service
public class PmsDocumentServiceImpl implements IPmsDocumentService
{
public class PmsDocumentServiceImpl implements IPmsDocumentService {
private static final Logger logger = LoggerFactory.getLogger(PmsDocumentServiceImpl.class);
@Resource
private PmsDocumentMapper pmsDocumentMapper;
@ -69,13 +76,12 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
/**
* 查询项目管理-文档库
*
*
* @param id 项目管理-文档库主键
* @return 项目管理-文档库
*/
@Override
public PmsDocument selectPmsDocumentByIdAndEnterpriseId(Long id, Long enterpriseId)
{
public PmsDocument selectPmsDocumentByIdAndEnterpriseId(Long id, Long enterpriseId) {
boolean isEnterpriseAdmin = pmsCommonService.hasDocsManageRole(enterpriseId);
return pmsDocumentMapper.selectPmsDocumentByIdAndEnterpriseId(id, enterpriseId, isEnterpriseAdmin, SecurityUtils.getUsername());
}
@ -97,13 +103,12 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
/**
* 查询项目管理-文档库列表
*
*
* @param pmsDocument 项目管理-文档库
* @return 项目管理-文档库
*/
@Override
public List<PmsDocument> selectPmsDocumentList(PmsDocument pmsDocument)
{
public List<PmsDocument> selectPmsDocumentList(PmsDocument pmsDocument) {
checkAuthAndReturnAdminStatus(pmsDocument.getPmsEnterpriseId());
return pmsDocumentMapper.selectPmsDocumentList(pmsDocument);
}
@ -116,7 +121,7 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
pmsDocumentSearchVo.setCurrentUserName(currentUserName);
startPage();
List<PmsDocument> pmsDocumentList = pmsDocumentMapper.selectPmsDocumentListBySearchInput(pmsDocumentSearchVo);
GenericsTableDataInfo<PmsDocumentVo> page = toPage(pmsDocumentList,this::buildPmsDocumentVo);
GenericsTableDataInfo<PmsDocumentVo> page = toPage(pmsDocumentList, this::buildPmsDocumentVo);
//构建面包屑列表
if (pmsDocumentSearchVo.getParentId() != 0) {
List<Breadcrumb> breadcrumbs = buildBreadcrumbs(pmsDocumentSearchVo.getParentId());
@ -132,21 +137,53 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseById(enterpriseId);
Map<String, String> queryParams = buildRepoListQueryParams(optionalWikiReposSearchVo);
try {
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ORGANIZATION_REPO_LIST(pmsEnterprise.getEnterpriseIdentifier(), queryParams));
return gitLinkRequestHelper.doGet(PmsGitLinkRequestUrl.GET_ORGANIZATION_REPO_LIST(pmsEnterprise.getEnterpriseIdentifier(), queryParams));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
@Override
public void downloadDoc(HttpServletResponse response, String enterpriseIdentifier, Long docId) {
PmsEnterprise enterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(enterpriseIdentifier);
PmsDocument pmsDocument = selectPmsDocumentByIdAndEnterpriseId(docId, enterprise.getId());
if (!pmsDocument.getDocType().equals(PmsDocumentType.DOCUMENT.getKey())) {
throw new ServiceException("当前接口仅允许下载文档类型");
}
Path tempFilePath = null;
try {
String docFileName = pmsDocument.getName() + ".md";
FileUtils.setAttachmentResponseHeader(response, docFileName);
// 创建临时文件
tempFilePath = Files.createTempFile(pmsDocument.getName(), ".md");
String content = "";
if (pmsDocument.getContent() != null) {
content = pmsDocument.getContent();
}
Files.write(tempFilePath, content.getBytes(StandardCharsets.UTF_8));
FileUtils.writeBytes(tempFilePath.toString(), response.getOutputStream());
} catch (IOException e) {
log.error("文档下载失败:{}", e.getMessage());
throw new ServiceException("文档下载失败");
} finally {
if (tempFilePath != null) {
try {
Files.deleteIfExists(tempFilePath);
} catch (IOException e) {
log.error("删除临时文件失败:{}", e.getMessage());
}
}
}
}
/**
* 新增项目管理-文档库
*
*
* @param pmsDocument 项目管理-文档库
* @return 结果
*/
@Override
public int insertPmsDocument(PmsDocument pmsDocument)
{
public int insertPmsDocument(PmsDocument pmsDocument) {
checkPmsProjectById(pmsDocument.getPmsProjectId());
checkAuthAndReturnAdminStatus(pmsDocument.getPmsEnterpriseId());
String currentUserName = SecurityUtils.getUsername();
@ -169,13 +206,12 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
/**
* 修改项目管理-文档库
*
*
* @param pmsDocument 项目管理-文档库
* @return 结果
*/
@Override
public int updatePmsDocument(PmsDocument pmsDocument)
{
public int updatePmsDocument(PmsDocument pmsDocument) {
checkPmsProjectById(pmsDocument.getPmsProjectId());
String currentUserName = SecurityUtils.getUsername();
boolean isEnterpriseAdmin = checkAuthAndReturnAdminStatus(pmsDocument.getPmsEnterpriseId());
@ -195,8 +231,7 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
* @return 结果
*/
@Override
public int deletePmsDocumentByIds(Long[] ids, Long enterpriseId, Long projectId)
{
public int deletePmsDocumentByIds(Long[] ids, Long enterpriseId, Long projectId) {
checkPmsProjectById(projectId);
String currentUserName = SecurityUtils.getUsername();
boolean isEnterpriseAdmin = checkAuthAndReturnAdminStatus(enterpriseId);
@ -207,13 +242,12 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
/**
* 删除项目管理-文档库信息
*
*
* @param id 项目管理-文档库主键
* @return 结果
*/
@Override
public int deletePmsDocumentById(Long id, Long enterpriseId, Long projectId)
{
public int deletePmsDocumentById(Long id, Long enterpriseId, Long projectId) {
checkPmsProjectById(projectId);
String currentUserName = SecurityUtils.getUsername();
boolean isEnterpriseAdmin = checkAuthAndReturnAdminStatus(enterpriseId);
@ -306,7 +340,7 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
throw new ServiceException("文件类型的文档名称个数与文件标识个数不匹配");
}
List<PmsDocument> pmsDocumentList = new ArrayList<>();
for (int i=0; i < names.length; i++) {
for (int i = 0; i < names.length; i++) {
PmsDocument pmsDocument = new PmsDocument();
BeanUtils.copyProperties(pmsFileTypeDocumentInputVo, pmsDocument);
pmsDocument.setName(names[i]);
@ -376,7 +410,7 @@ public class PmsDocumentServiceImpl implements IPmsDocumentService
queryParams.put("pm_project_repository_ids", unlinkedRepoIdsString);
}
queryParams.put("search", optionalWikiReposSearchVo.getSearch());
queryParams.put("page" , String.valueOf(optionalWikiReposSearchVo.getPage()));
queryParams.put("page", String.valueOf(optionalWikiReposSearchVo.getPage()));
queryParams.put("limit", String.valueOf(optionalWikiReposSearchVo.getLimit()));
queryParams.put("sort_by", optionalWikiReposSearchVo.getSortBy());
queryParams.put("sort_direction", "desc");

View File

@ -118,7 +118,8 @@ public class ProductReqSpecsController extends BaseController {
@Log(title = "需求", businessType = BusinessType.UPDATE)
@PutMapping("/activePlan")
@ApiOperation(value = "需求纳入计划")
public AjaxResult activePlan(@RequestBody @Validated ProductReqSpecsActivePlanVo productReqSpecsActivePlanVo) {
public AjaxResult activePlan(@PathVariable String enterpriseIdentifier, @RequestBody @Validated ProductReqSpecsActivePlanVo productReqSpecsActivePlanVo) {
productReqSpecsActivePlanVo.setEnterpriseIdentifier(enterpriseIdentifier);
return toAjax(pmsProductRequirementService.activePlan(productReqSpecsActivePlanVo));
}

View File

@ -31,8 +31,12 @@ public class ProductReqSpecsActivePlanVo {
@NotNull
private Long projectId;
@ApiModelProperty(value = "企业标识", hidden = true)
private String enterpriseIdentifier;
public PmsProjectIssuesInputVo toPmsProjectIssuesInputVo(PmsProductRequirement reqSpecs, List<String> forgeFileIdentifierList) {
PmsProjectIssuesInputVo issue = new PmsProjectIssuesInputVo();
issue.setEnterpriseIdentifier(enterpriseIdentifier);
issue.setSubject(reqSpecs.getTitle());
issue.setPmProjectId(projectId);
issue.setStatusId(ProjectIssueStatus.RESOLVING.getId());

View File

@ -67,6 +67,15 @@ public interface IPmsProductModuleService
*/
List<TreeSelect> selectPmsProductModuleTreeList(PmsProductModule pmsProductModule, int type);
/**
* 构建模块的树状结构
*
* @param projectid 模块搜索条件
* @param type 模块类型1产品模块 2测试用例模块, 3测试单实际取测试用例模块
* @return 模块树状结构
*/
List<TreeSelect> getPmsProductModuleTreeList(Long projectid, int type);
/**
* 查询模块及模块子级ID列表
* @param parentModuleId 父级模块ID

View File

@ -351,6 +351,63 @@ public class PmsProductModuleServiceImpl implements IPmsProductModuleService
return buildModuleTreeSelect(moduleList);
}
@Override
public List<TreeSelect> getPmsProductModuleTreeList(Long projectId, int type) {
List<PmsProductModule> moduleList;
PmsProductModule pmsProductModule = new PmsProductModule();
pmsProductModule.setPmsProjectId(projectId);
//模块类型1产品模块 2测试用例模块, 3测试单实际取测试用例模块
if (PmsConstants.TESTSHEET_TAG_AND_MODULE_TYPE.equals(type)) {
pmsProductModule.setType(PmsConstants.TESTCASE_TAG_AND_MODULE_TYPE);
moduleList = pmsProductModuleMapper.selectPmsProductModuleForTestsheetList(pmsProductModule);
} else {
pmsProductModule.setType(type);
moduleList = pmsProductModuleMapper.selectPmsProductModuleList(pmsProductModule);
}
Integer allNodeDataCount;
Integer noModuleNodeDataCount;
String allNodeName = "全部模块";
if (type == PmsConstants.PRODUCT_TAG_AND_MODULE_TYPE) {
// 设置各节点数量为需求数量
moduleList.forEach(x -> x.setNodeDataCount(x.getRequirementCount()));
} else if (type == PmsConstants.TESTSHEET_TAG_AND_MODULE_TYPE) {
// 设置各节点数量为测试单执行用例数量
moduleList.forEach(x -> x.setNodeDataCount(x.getTestsheetCasesCount()));
// 排除0测试单执行用例数据
moduleList = moduleList.stream().filter(e -> e.getTestsheetCasesCount() > 0).collect(Collectors.toList());
} else {
// 设置各节点数量为测试用例数量
moduleList.forEach(x -> x.setNodeDataCount(x.getTestCaseCount()));
}
// 父级需求数需包含子级需求数
aggregateCounts(moduleList, 0L);
// 构建顶级模块全部需求
PmsProductModule allPmsProductModule=new PmsProductModule();
allPmsProductModule.setPmsProductIdentifier(pmsProductModule.getPmsProductIdentifier());
allPmsProductModule.setId(0L);
allPmsProductModule.setModuleName(allNodeName);
allPmsProductModule.setIsFixedModule(true);
moduleList.add(allPmsProductModule);
// 模块根据id排序
moduleList = moduleList.stream()
.sorted(Comparator.comparing(PmsProductModule::getId))
.sorted(Comparator.comparing(PmsProductModule::getIsFixedModule))
.collect(Collectors.toList());
// 构建无所属模块
PmsProductModule noPmsProductModule = new PmsProductModule();
noPmsProductModule.setPmsProductIdentifier(pmsProductModule.getPmsProductIdentifier());
noPmsProductModule.setId(-1L);
noPmsProductModule.setModuleName(NO_MODULE(type));
noPmsProductModule.setParentId(0L);
noPmsProductModule.setIsFixedModule(true);
moduleList.add(noPmsProductModule);
return buildModuleTreeSelect(moduleList);
}
@Override
public List<Long> selectChildrenPmsProductModuleIdList(Long parentModuleId) {
List<PmsProductModule> pmsProductModuleList=new ArrayList<>();

View File

@ -32,7 +32,7 @@ import java.util.List;
* @date 2024-06-20
*/
@Service
public class PmsProductLibraryRepositoriesServiceImpl implements IPmsProductLibraryRepositoriesService {
public class PmsProductLibraryRepositoriesServiceImpl extends ProductLibraryCommonService implements IPmsProductLibraryRepositoriesService {
@Autowired
private PmsProductLibraryRepositoriesMapper pmsProductLibraryRepositoriesMapper;
@Autowired
@ -328,7 +328,15 @@ public class PmsProductLibraryRepositoriesServiceImpl implements IPmsProductLibr
pmsProductLibraryRepositoriesSearch.setPmsEnterpriseIdentifier(enterpriseIdentifier);
return PageUtils.toPage(
pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesList(pmsProductLibraryRepositoriesSearch),
PmsProductLibraryRepositories::toPmsProductLibraryRepositoriesSimpleVo);
this::toPmsProductLibraryRepositoriesSimpleVo);
}
private PmsProductLibraryRepositoriesSimpleVo toPmsProductLibraryRepositoriesSimpleVo(PmsProductLibraryRepositories productLibraryRepositories) {
PmsProductLibraryRepositoriesSimpleVo target = productLibraryRepositories.toPmsProductLibraryRepositoriesSimpleVo();
if (StringUtils.isNotEmpty(externalUrl)) {
target.setUrl(target.getUrl().replace(nexusUrl, externalUrl));
}
return target;
}
@Override

View File

@ -43,6 +43,7 @@ import com.microservices.system.api.utils.FeignUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -60,7 +61,7 @@ import java.util.stream.Collectors;
* @author OTTO
*/
@Service
public class PmsProductLibraryServiceImpl implements IPmsProductLibraryService {
public class PmsProductLibraryServiceImpl extends ProductLibraryCommonService implements IPmsProductLibraryService {
private static final Logger log = LoggerFactory.getLogger(PmsProductLibraryServiceImpl.class);
@Autowired
@ -158,6 +159,9 @@ public class PmsProductLibraryServiceImpl implements IPmsProductLibraryService {
)
);
}
if (StringUtils.isNotEmpty(externalUrl)) {
pmsProductLibrarySimpleVo.setUrl(pmsProductLibrarySimpleVo.getUrl().replace(nexusUrl, externalUrl));
}
return pmsProductLibrarySimpleVo;
}

View File

@ -0,0 +1,11 @@
package com.microservices.pms.productLibrary.service.impl;
import org.springframework.beans.factory.annotation.Value;
public abstract class ProductLibraryCommonService {
@Value("${nexus.proxy.externalUrl:}")
public String externalUrl;
@Value("${nexus.proxy.targetAddr:}")
public String nexusUrl;
}

View File

@ -44,7 +44,8 @@ public class PmsProjectIssuesController extends BaseController {
@RequiresPermissions(value = {"pms:pmsProject:show", "pms:pmsProject:showMe", "pms:pmsProjectTestsheet:edit"}, logical = Logical.OR)
@GetMapping("/list")
@ApiOperation(value = "项目工作项列表")
public AjaxResult list(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
public AjaxResult list(@PathVariable String enterpriseIdentifier, PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
pmsProjectIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssuesList(pmsProjectIssuesSearchVo);
return success(result);
}
@ -384,4 +385,15 @@ public class PmsProjectIssuesController extends BaseController {
public void exportIssues(HttpServletResponse response, @ApiParam("项目Id") @RequestParam(name = "pmProjectId") Long pmProjectId) {
pmsProjectIssuesService.exportIssues(response, pmProjectId);
}
/**
* 同步更新issue企业标识
* 说明旧issues数据直接通过pmProjectId与pms建立关联新需求要与企业建立关联故需要同步更新issue企业标识
*/
@PutMapping("/updateIssueEnterpriseIdentifier")
@ApiOperation(value = "同步更新issue企业标识")
public AjaxResult updateIssueEnterpriseIdentifier() {
boolean result = pmsProjectIssuesService.updateIssueEnterpriseIdentifier();
return success(result);
}
}

View File

@ -9,15 +9,20 @@ import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType;
import com.microservices.common.security.annotation.Logical;
import com.microservices.common.security.annotation.RequiresPermissions;
import com.microservices.pms.product.domain.vo.TreeSelect;
import com.microservices.pms.product.service.IPmsProductModuleService;
import com.microservices.pms.project.domain.PmsProjectTestcase;
import com.microservices.pms.project.domain.vo.*;
import com.microservices.pms.project.service.IPmsProjectTestcaseService;
import com.microservices.pms.utils.PmsConstants;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
@ -132,4 +137,40 @@ public class PmsProjectTestcaseController extends BaseController {
@RequestBody JSONObject batchUpdateVo) {
return toAjax(pmsProjectTestcaseService.batchUpdatePmsProjectTestcase(batchUpdateVo));
}
/**
* 批量下载测试用例
*/
@ApiOperation(value = "批量下载测试用例")
@GetMapping("/{projectId}/download")
public void download(@PathVariable("projectId") Long projectId, HttpServletResponse response)throws IOException {
PmsProjectTestcaseModuleSearchVo pmsProjectTestcaseModuleSearchVo = new PmsProjectTestcaseModuleSearchVo();
pmsProjectTestcaseModuleSearchVo.setPmsProjectId(projectId);
List<TreeSelect> treeSelects = pmsProductModuleService.getPmsProductModuleTreeList(projectId, PmsConstants.TESTCASE_TAG_AND_MODULE_TYPE);
pmsProjectTestcaseService.generateWord(treeSelects, projectId, response);
}
/**
* 批量导入测试用例
*/
@ApiOperation(value = "批量导入测试用例")
@PostMapping("/{projectId}/upload")
public AjaxResult upload(@RequestPart("file") MultipartFile file, @PathVariable("projectId") Long projectId) throws IOException {
if (file.isEmpty()) {
return error("上传的文件为空,请选择有效的文件");
}
String fileName = file.getOriginalFilename();
if (fileName == null) {
return error("无法获取文件名,请检查上传的文件");
}
if (fileName.endsWith(".docx")) {
pmsProjectTestcaseService.testcaseImport(projectId, file);
return success("上传的文件是 docx 格式");
} else {
return error("上传的文件不是 docx 格式,请上传 docx 文件");
}
}
}

View File

@ -2,8 +2,8 @@ package com.microservices.pms.project.controller;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.pms.project.domain.vo.PmsProjectIssuesInputVo;
import com.microservices.pms.project.domain.vo.PmsProjectIssuesSearchVo;
import com.microservices.pms.project.domain.vo.*;
import com.microservices.pms.project.service.IPmsIssueCompletionService;
import com.microservices.pms.project.service.PmsProjectIssuesService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
@ -28,27 +28,70 @@ public class PmsProjectWeeklyReportController {
@Autowired
private PmsProjectIssuesService pmsProjectIssuesService;
@Autowired
private IPmsIssueCompletionService pmsIssueCompletionService;
/**
* 查询项目周报列表
*/
@GetMapping("/list")
@ApiOperation(value = "项目周报列表")
public AjaxResult list(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo)
public AjaxResult list(@PathVariable String enterpriseIdentifier, PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo)
{
pmsProjectIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssuesList(pmsProjectIssuesSearchVo);
return success(result);
}
/**
* 查询周报-个人工作项统计
*/
@GetMapping("/personal")
@ApiOperation(value = "周报-个人工作项统计")
public AjaxResult getPersonalWeeklyReport(@PathVariable String enterpriseIdentifier, PmsPersonalWeeklyReportSearchVo pmsPersonalWeeklyReportSearchVo)
{
JSONObject result = pmsProjectIssuesService.getPersonalIssuesStatistics(enterpriseIdentifier, pmsPersonalWeeklyReportSearchVo);
return success(result);
}
@GetMapping("/personalIssueList")
@ApiOperation(value = "周报-个人工作项列表")
public AjaxResult getPersonalIssueList(@PathVariable String enterpriseIdentifier, PmsPersonalWeeklyIssuesSearchVo pmsPersonalWeeklyIssuesSearchVo)
{
pmsPersonalWeeklyIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.getPersonalIssueList(pmsPersonalWeeklyIssuesSearchVo);
return success(result);
}
/**
* 查询周报-项目组工作项统计
*/
@GetMapping("/projectTeam")
@ApiOperation(value = "周报-项目组工作项统计")
public AjaxResult getProjectTeamWeeklyReport(@PathVariable String enterpriseIdentifier)
{
JSONObject result = pmsProjectIssuesService.getProjectTeamIssuesStatistics(enterpriseIdentifier);
return success(result);
}
@GetMapping("/projectIssueList")
@ApiOperation(value = "周报-项目组工作项列表")
public AjaxResult getProjectIssueList(@PathVariable String enterpriseIdentifier, PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo)
{
pmsProjectIssuesSearchVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.getProjectIssueList(pmsProjectIssuesSearchVo);
return success(result);
}
/**
* 新增项目项目周报
*/
@PostMapping("/add")
@ApiOperation(value = "新增项目周报")
public AjaxResult add(@RequestBody PmsProjectIssuesInputVo pmsProjectIssuesInputVo)
public AjaxResult add(@PathVariable String enterpriseIdentifier, @RequestBody PmsProjectIssuesInputVo pmsProjectIssuesInputVo)
{
JSONObject result = pmsProjectIssuesService.insertPmsProjectIssues(pmsProjectIssuesInputVo);
pmsProjectIssuesInputVo.setEnterpriseIdentifier(enterpriseIdentifier);
JSONObject result = pmsProjectIssuesService.insertPmsProjectWeeklyReportIssues(pmsProjectIssuesInputVo);
return success(result);
}
@ -59,18 +102,19 @@ public class PmsProjectWeeklyReportController {
@ApiOperation(value = "编辑项目周报")
public AjaxResult edit(@PathVariable("id") Long id, @RequestBody PmsProjectIssuesInputVo pmsProjectIssuesInputVo)
{
JSONObject result = pmsProjectIssuesService.updatePmsProjectIssues(id, pmsProjectIssuesInputVo);
JSONObject result = pmsProjectIssuesService.updatePmsProjectWeeklyReportIssues(id, pmsProjectIssuesInputVo);
return success(result);
}
/**
* 删除项目周报
*/
@DeleteMapping("/{ids}")
public AjaxResult remove(@ApiParam( "周报id数组为-1时删除全部")@PathVariable Long[] ids, @ApiParam( "项目Id")@RequestParam(name = "pmProjectId") Long pmProjectId)
@DeleteMapping("/{id}")
@ApiOperation(value = "删除项目周报")
public AjaxResult remove(@ApiParam( "周报id")@PathVariable Long id)
{
JSONObject result = pmsProjectIssuesService.deletePmsProjectIssueByIds(ids, pmProjectId);
JSONObject result = pmsProjectIssuesService.deletePmsProjectWeeklyReportIssueByIds(id);
return success(result);
}
@ -78,10 +122,21 @@ public class PmsProjectWeeklyReportController {
* 查看项目周报
*/
@GetMapping("/{id}")
public AjaxResult query(@PathVariable("id") Long id, @ApiParam( "项目Id")@RequestParam(name = "pmProjectId") Long pmProjectId)
@ApiOperation(value = "查看项目周报")
public AjaxResult query(@PathVariable String enterpriseIdentifier, @PathVariable("id") Long id)
{
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssueById(id, pmProjectId);
JSONObject result = pmsProjectIssuesService.selectPmsProjectIssueByIdAndEnterPrise(id, enterpriseIdentifier);
return success(result);
}
/**
* 更新工作项完成情况
*/
@PutMapping("/issueCompletion")
@ApiOperation(value = "更新工作项完成情况")
public AjaxResult issueCompletion(@RequestBody PmsProjectIssuesCompletionInputVo pmsProjectIssuesCompletionInputVo)
{
return success(pmsIssueCompletionService.saveOrUpdateCompletion(pmsProjectIssuesCompletionInputVo));
}
}

View File

@ -0,0 +1,88 @@
package com.microservices.pms.project.domain;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class ForgeIssues {
private Integer id;
private Integer trackerId;
private Integer projectId;
private String subject;
private Date dueDate;
private Integer categoryId;
private Integer statusId;
private Integer assignedToId;
private Integer priorityId;
private Integer fixedVersionId;
private Integer authorId;
private Date createdOn;
private Date updatedOn;
private Date startDate;
private Integer doneRatio;
private Float estimatedHours;
private Integer parentId;
private Integer rootId;
private Integer lft;
private Integer rgt;
private Boolean isPrivate;
private Date closedOn;
private Integer projectIssuesIndex;
private String issueType;
private Integer token;
private String issueTagsValue;
private Boolean isLock;
private String issueClassify;
private String refName;
private String branchName;
private String description;
private Integer blockchainTokenNum;
private Long pmProjectId;
private Long pmSprintId;
private Integer pmIssueType;
private BigDecimal timeScale;
private Integer childCount;
private Long changerId;
private Integer fakeId;
private String enterpriseIdentifier;
}

View File

@ -0,0 +1,27 @@
package com.microservices.pms.project.domain;
import lombok.Data;
import java.util.Date;
@Data
public class PmsIssueCompletion {
private Integer id;
private String gitlinkIssueId;
private String gitlinkUserId;
private String description;
/**
* 类型 1个人 2项目组
*/
private String type;
private Date createTime;
private Date updateTime;
}

View File

@ -126,29 +126,35 @@ public class PmsProjectTestcase extends BaseEntity {
private List<PmsProjectTestcaseStep> testcaseStepList;
/**
* 预留字段1
* 测试用例描述
*/
@JsonIgnore
private String reservedField1;
@ApiModelProperty(value = "测试用例描述")
private String description;
/**
* 预留字段2
* 测试方法
*/
@JsonIgnore
private String reservedField2;
@ApiModelProperty(value = "测试方法")
private String testMethod;
/**
* 预留字段3
* 测试终止条件
*/
@JsonIgnore
private String reservedField3;
@ApiModelProperty(value = "测试终止条件")
private String terminationConditions;
@ApiModelProperty(value = "测试用例标识")
private String identifier;
@ApiModelProperty(value = "测试追踪")
private String testTracking;
@ApiModelProperty(value = "产品需求id")
private Long productReqSpecsId;
@ApiModelProperty(value = "是否导入")
private Long isImport;
public PmsProjectTestcaseDataVo toPmsProjectTestcaseDataVo() {
PmsProjectTestcaseDataVo target = new PmsProjectTestcaseDataVo();
BeanUtils.copyProperties(this, target);

View File

@ -0,0 +1,68 @@
package com.microservices.pms.project.domain.vo;
import lombok.Data;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@Data
public class PendingOutputDataVo {
private Long id;
private Long pms_projiect_id;
private String title;
private Long type_id;
private String tag_ids;
private List<String> content_list;
private List<String> expected_result;
private String update_by;
private LocalDate update_time;
private String create_by;
private LocalDate create_time;
private String test_type;
private String description;
private String test_method;
private String termination_conditions;
private String identifier;
private String preconditions;
public PendingOutputDataVo() {
content_list = new ArrayList<>();
expected_result = new ArrayList<>();
}
// 添加元素的方法
public void addToContent(String item) {
content_list.add(item);
}
public void addToExpected(String item) {
expected_result.add(item);
}
public void addContent(String item) {
this.content_list.add(item);
}
public void addExpected(String item) {
this.expected_result.add(item);
}
}

View File

@ -0,0 +1,52 @@
package com.microservices.pms.project.domain.vo;
import com.microservices.common.core.utils.ServletUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@ApiModel("个人周报工作项搜索对象")
public class PmsPersonalWeeklyIssuesSearchVo {
@ApiModelProperty(value = "用户gitlink用户id")
private Long userId;
@ApiModelProperty(value = "企业标识", hidden = true)
private String enterpriseIdentifier;
@ApiModelProperty(value = "工作项名称搜索关键词")
private String keyword;
@ApiModelProperty(value = "状态值,可多个状态逗号隔开")
private String statusIds;
@ApiModelProperty(value = "排序方式: issues.updated_on 更新时间 issues.created_on 创建时间 issue_priorities.position 优先级")
private String sortBy;
@ApiModelProperty(value = "排序方向:asc 正序 desc 倒序")
private String sortDirection;
@ApiModelProperty(value = "本周工作项页码")
private String thisWeekPage;
@ApiModelProperty(value = "分页数")
private String thisWeekLimit;
@ApiModelProperty(value = "本周工作项页码")
private String nextWeekPage;
@ApiModelProperty(value = "分页数")
private String nextWeekLimit;
@ApiModelProperty(value = "周工作项统计开始时间")
private String weeklyBeginDate;
@ApiModelProperty(value = "周工作项统计结束时间")
private String weeklyEndDate;
public void setKeyword(String keyword) {
this.keyword = ServletUtils.urlDecode(keyword);
}
}

View File

@ -0,0 +1,17 @@
package com.microservices.pms.project.domain.vo;
import com.microservices.common.core.utils.ServletUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("个人周报工作项统计对象")
public class PmsPersonalWeeklyReportSearchVo {
@ApiModelProperty(value = "用户gitlink用户id")
private Long userId;
@ApiModelProperty(value = "企业标识", hidden = true)
private String enterpriseIdentifier;
}

View File

@ -0,0 +1,23 @@
package com.microservices.pms.project.domain.vo;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.utils.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
@Data
@ApiModel("项目工作项完成情况输入对象")
public class PmsProjectIssuesCompletionInputVo {
@ApiModelProperty(value = "工作项Id")
private String gitlinkIssueId;
@ApiModelProperty(value = "完成情况")
private String description;
}

View File

@ -9,7 +9,10 @@ import lombok.Data;
@ApiModel("项目工作项搜索对象")
public class PmsProjectIssuesSearchVo {
@ApiModelProperty(value = "项目id", required = true)
@ApiModelProperty(value = "企业标识", hidden = true)
private String enterpriseIdentifier;
@ApiModelProperty(value = "项目id")
private String pmProjectId;
@ApiModelProperty(value = "项目迭代id")
@ -90,6 +93,12 @@ public class PmsProjectIssuesSearchVo {
@ApiModelProperty(value = "与用户ID相关(gitlinkUserId)")
private String participatorId;
@ApiModelProperty(value = "周工作项统计开始时间")
private String weeklyBeginDate;
@ApiModelProperty(value = "周工作项统计结束时间")
private String weeklyEndDate;
public void setKeyword(String keyword) {
this.keyword = ServletUtils.urlDecode(keyword);
}

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Size;
import java.util.List;
/**
@ -35,6 +36,27 @@ public class PmsProjectTestcaseDetailVo extends PmsProjectTestcaseDataVo {
@ApiModelProperty(value = "备注")
private String remark;
/**
* 测试用例描述
*/
@ApiModelProperty(value = "测试用例描述")
@Size(max = 500, message = "长度需要小于500")
private String description;
/**
* 测试方法
*/
@ApiModelProperty(value = "测试方法")
@Size(max = 255, message = "长度需要小于255")
private String testMethod;
/**
* 测试终止条件
*/
@ApiModelProperty(value = "测试终止条件")
@Size(max = 500, message = "长度需要小于500")
private String terminationConditions;
/**
* 测试步骤列表
*/

View File

@ -84,6 +84,35 @@ public class PmsProjectTestcaseInputVo {
@Size(max = 500, message = "长度需要小于500")
private String remark;
/**
* 测试用例描述
*/
@ApiModelProperty(value = "测试用例描述")
@Size(max = 500, message = "长度需要小于500")
private String description;
/**
* 测试方法
*/
@ApiModelProperty(value = "测试方法")
@Size(max = 255, message = "长度需要小于255")
private String testMethod;
/**
* 测试终止条件
*/
@ApiModelProperty(value = "测试终止条件")
@Size(max = 500, message = "长度需要小于500")
private String terminationConditions;
@ApiModelProperty(value = "测试用例标识")
@Size(max = 255, message = "长度需要小于500")
private String identifier;
@ApiModelProperty(value = "测试追踪")
@Size(max = 255, message = "长度需要小于500")
private String testTracking;
/**
* 测试步骤列表
*/

View File

@ -0,0 +1,17 @@
package com.microservices.pms.project.domain.vo;
import lombok.Data;
@Data
public class PmsProjectTestcaseStepVo {
private Long index;
private String content;
private String expectedResult;
private String updateBy;
private String createBy;
}

Some files were not shown because too many files have changed in this diff Show More