Merge pull request 'feat(资源库) 区块链相关' (#918) from liuhuazhong/microservices:feat_chievements_dev into master

This commit is contained in:
wanjia9506 2025-06-24 09:05:53 +08:00
commit 3b17e0c729
53 changed files with 2774 additions and 147 deletions

View File

@ -86,6 +86,13 @@ public class AchievementsController extends BaseController {
return toAjax(achievementsService.deleteAchievementsByIds(ids)); return toAjax(achievementsService.deleteAchievementsByIds(ids));
} }
@ApiOperation("删除成果数据")
@DeleteMapping("/deleteById")
public AjaxResult deleteById(Long id) {
return toAjax(achievementsService.deleteAchievementsById(id));
}
/** /**
* 获取精选成果 * 获取精选成果
* *
@ -215,12 +222,29 @@ public class AchievementsController extends BaseController {
return success(achievementsService.get7AddClickById(id,clickType)); return success(achievementsService.get7AddClickById(id,clickType));
} }
@ApiOperation("根据专家id获取近7日成果点击数量折线图")
@GetMapping("/getExpert7AddClickById")
public AjaxResult getExpert7AddClickById(String id,@RequestParam(value = "clickType",required = false, defaultValue = "Experts")
String clickType) {
return success(achievementsService.get7AddClickById(id,clickType));
}
@ApiOperation("根据成果ID,获取成果的相关行为数据统计(点击量、搜索量、附件下载量、收藏、关注)") @ApiOperation("根据成果ID,获取成果的相关行为数据统计(点击量、搜索量、附件下载量、收藏、关注)")
@GetMapping("/getActDataStatisticById") @GetMapping("/getActDataStatisticById")
public AjaxResult getActDataStatisticById(Long id) { public AjaxResult getActDataStatisticById(Long id) {
return success(achievementsService.getActDataStatisticById(id)); return success(achievementsService.getActDataStatisticById(id));
} }
@ApiOperation("根据领域来源、领域分类名称,获取领域相关数据")
@GetMapping("/getAllAreas")
public AjaxResult getAllAreas(String areaName) {
return success(achievementsService.getAllAreas(areaName));
}
@ApiOperation("根据领域,将成果数据进行分类") @ApiOperation("根据领域,将成果数据进行分类")
@GetMapping("/getAreaStatistic") @GetMapping("/getAreaStatistic")
public AjaxResult getAreaStatistic(String areaKey) public AjaxResult getAreaStatistic(String areaKey)
@ -228,6 +252,14 @@ public class AchievementsController extends BaseController {
return success(achievementsService.getAreaStatistic(areaKey)); return success(achievementsService.getAreaStatistic(areaKey));
} }
@ApiOperation("根据领域获取领域详情")
@GetMapping("/getAreaDetail")
public AjaxResult getAreaDetail(String areaKey,String kyxmSum,String source)
{
return success(achievementsService.getAreaDetail(areaKey,kyxmSum,source));
}
/** /**
* 获取开源项目的相关成果 * 获取开源项目的相关成果
*/ */
@ -274,4 +306,5 @@ public class AchievementsController extends BaseController {
{ {
return success(achievementsService.getSearchResult(achName,userId)); return success(achievementsService.getSearchResult(achName,userId));
} }
} }

View File

@ -1,31 +1,116 @@
package com.microservices.dms.achievementLibrary.controller; package com.microservices.dms.achievementLibrary.controller;
import com.microservices.common.core.web.controller.BaseController; import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.page.TableDataInfo; import com.microservices.common.core.web.page.TableDataInfo;
import com.microservices.dms.achievementLibrary.domain.BlockchainListQueryVo;
import com.microservices.dms.achievementLibrary.domain.TokenListVo; import com.microservices.dms.achievementLibrary.domain.TokenListVo;
import com.microservices.dms.achievementLibrary.service.IAchievementsService; import com.microservices.dms.achievementLibrary.domain.blockchain.InBlockchainData;
import com.microservices.dms.achievementLibrary.domain.blockchain.InLinkProjectVo;
import com.microservices.dms.achievementLibrary.domain.blockchain.UserVo;
import com.microservices.dms.achievementLibrary.service.BlockChainService;
import com.microservices.dms.achievementLibrary.service.InBlockchainDataServiceImpl;
import com.microservices.dms.common.vo.UserCreateVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("/blockChain") @RequestMapping("/blockChain")
@Api(tags = "数据产权子系统") @Api(tags = "数据管理体系-数据产权子系统")
public class BlockChainController extends BaseController { public class BlockChainController extends BaseController {
@Autowired @Autowired
private IAchievementsService achievementsService; private BlockChainService blockChainService;
@Autowired
private InBlockchainDataServiceImpl inBlockchainDataService;
@GetMapping("/projectTokenList")
@ApiOperation(value = "项目token列表")
public TableDataInfo projectTokenList(String projectName) {
startPage();
List<TokenListVo> list = blockChainService.projectTokenList(projectName);
return getDataTable(list);
}
@GetMapping("/projectTokenDistribute")
@ApiOperation(value = "项目token分配、点击token分配按钮弹出框展示相关数据项目名称、分配token、被分配人")
public AjaxResult projectTokenDistribute(InLinkProjectVo projectVo) {
return blockChainService.projectTokenDistribute(projectVo);
}
@GetMapping("/issueDataList")
@ApiOperation(value = "入链issue列表")
public TableDataInfo issueDataList(BlockchainListQueryVo queryVo) {
startPage();
List<Map<String, Object>> list = blockChainService.issueDataList(queryVo);
return getDataTable(list);
}
@GetMapping("/commitDataList")
@ApiOperation(value = "入链commit列表")
public TableDataInfo commitDataList(BlockchainListQueryVo queryVo) {
startPage();
List<Map<String, Object>> list = blockChainService.commitDataList(queryVo);
return getDataTable(list);
}
@GetMapping("/prDataList")
@ApiOperation(value = "入链PR列表")
public TableDataInfo prDataList(BlockchainListQueryVo queryVo) {
startPage();
List<Map<String, Object>> list = blockChainService.prDataList(queryVo);
return getDataTable(list);
}
@GetMapping("/userDataList")
@ApiOperation(value = "入链user列表")
public TableDataInfo userDataList(BlockchainListQueryVo queryVo) {
startPage();
List<Map> list = blockChainService.userDataList(queryVo);
return getDataTable(list);
}
@GetMapping("/userList")
@ApiOperation(value = "用户列表列表")
public TableDataInfo userList(UserVo userVo) {
startPage();
List<UserVo> list = blockChainService.userList(userVo);
return getDataTable(list);
}
@GetMapping("/InBlockchainDataList")
@ApiOperation(value = "查询区块链数据入链列表")
public TableDataInfo list(InBlockchainData inBlockchainData) {
startPage();
List<InBlockchainData> list = inBlockchainDataService.selectInBlockchainDataList(inBlockchainData);
return getDataTable(list);
}
@ApiOperation("提供入链项目信息查询")
@GetMapping("/queryBlockInfo")
public AjaxResult queryBlockInfo (String type,String typeId) {
return blockChainService.queryBlockInfo(type,typeId);
}
@ApiOperation("根据项目id获取用户对应的token")
@GetMapping("/getUserTokenByProjectId")
public AjaxResult getUserTokenByProjectId (String type,String userName,String tokenName) {
return blockChainService.getUserTokenByProjectId(type,userName,tokenName);
}
@ApiOperation("获取用户对应的所有项目token")
@GetMapping("/getUserAllProjectToken")
public AjaxResult getUserAllProjectToken (String userName) {
return blockChainService.getUserAllProjectToken(userName);
}
// @GetMapping("/projectTokenList")
// @ApiOperation(value = "项目token列表")
// public TableDataInfo projectTokenList() {
// startPage();
// List<TokenListVo> list = achievementsService.projectTokenList();
// return getDataTable(list);
// }
} }

View File

@ -0,0 +1,51 @@
package com.microservices.dms.achievementLibrary.controller;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.dms.achievementLibrary.service.BlockChainService;
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("/blockFisco")
@Api(tags = "数据管理体系-数据产权入链交易")
public class BlockFiscoController {
@Autowired
private BlockChainService blockChainService;
@GetMapping("/getTransactionByHash")
@ApiOperation(value = "通过交易哈希获取交易详情")
public AjaxResult getTransactionByHash(String txHash) {
return AjaxResult.success(blockChainService.getTransactionByHash(txHash));
}
@ApiOperation(value = "交易哈希获取交易回执")
@GetMapping("/getTransactionReceipt")
public AjaxResult getTransactionReceipt(String txHash) {
return AjaxResult.success(blockChainService.getTransactionReceipt(txHash));
}
@ApiOperation(value = "获取最新区块号")
@GetMapping("/blockNumber")
public AjaxResult getBlockNumber() {
return AjaxResult.success(blockChainService.getBlockNumber());
}
@ApiOperation(value = "获取区块链总交易数")
@GetMapping("/getTotalTransactionCount")
public AjaxResult getTotalTransactionCount() {
return AjaxResult.success(blockChainService.getTotalTransactionCount());
}
}

View File

@ -0,0 +1,15 @@
package com.microservices.dms.achievementLibrary.domain;
import lombok.Data;
import java.util.List;
@Data
public class AchDetailVo {
private List<Achievements> achievementsList;
private long clickSum;
private long dockSum;
private long favoriteSum;
private long watcherSum;
private String remark;
}

View File

@ -176,9 +176,18 @@ public class Achievements extends BaseEntity {
@Excel(name = "成果附件") @Excel(name = "成果附件")
private String attachments; private String attachments;
//成果小类
private String ext1;
//成果状态
private String ext2;
//成果团队名称
private String ext3;
private Long clickSum; private Long clickSum;
private Long watcherSum; private Long watcherSum;
private Long favoriteSum; private Long favoriteSum;
private Long dockSum;
private String filedDesc;
private Float hotRank; private Float hotRank;
private Long attachmentCount; private Long attachmentCount;
private Integer isExpertAudit; private Integer isExpertAudit;
@ -188,6 +197,30 @@ public class Achievements extends BaseEntity {
private String userLogin; private String userLogin;
private List<Map<String,Object>> dockingUserInfo; private List<Map<String,Object>> dockingUserInfo;
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2;
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3;
}
public List<Map<String, Object>> getDockingUserInfo() { public List<Map<String, Object>> getDockingUserInfo() {
return dockingUserInfo; return dockingUserInfo;
} }
@ -196,6 +229,22 @@ public class Achievements extends BaseEntity {
this.dockingUserInfo = dockingUserInfo; this.dockingUserInfo = dockingUserInfo;
} }
public String getFiledDesc() {
return filedDesc;
}
public void setFiledDesc(String filedDesc) {
this.filedDesc = filedDesc;
}
public Long getDockSum() {
return dockSum;
}
public void setDockSum(Long dockSum) {
this.dockSum = dockSum;
}
public String getShowAchievementName() { public String getShowAchievementName() {
return showAchievementName; return showAchievementName;
} }

View File

@ -15,6 +15,15 @@ public class AreaStatisticVo {
private Long kfjsSum; private Long kfjsSum;
//校企成果汇总 //校企成果汇总
private Long xqcgSum; private Long xqcgSum;
private String source;
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getAreaName() { public String getAreaName() {
return areaName; return areaName;

View File

@ -0,0 +1,12 @@
package com.microservices.dms.achievementLibrary.domain;
import lombok.Data;
@Data
public class BlockchainListQueryVo {
private String projectName;
private String issueName;
private String prName;
private String userName;
private Long userId;
}

View File

@ -146,8 +146,8 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
/** /**
* 成果审核时间 * 成果审核时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "成果审核时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "成果审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date reviewDate; private Date reviewDate;
/** /**

View File

@ -3,16 +3,22 @@ package com.microservices.dms.achievementLibrary.domain;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import java.util.Date;
@Data @Data
public class TokenListVo { public class TokenListVo {
private Long id; // 项目ID private Long id; // 项目ID
private String name; // 项目名称 private String name; // 项目名称
private String userId;//用户id
private Long totalToken; // 项目总Token private Long totalToken; // 项目总Token
private String createBy; // 创建人 private String createBy; // 创建人
private Long issueToken;//issueToken
private Long currentToken; // 当前Token private Long currentToken; // 当前Token
private String repositoryName; // 仓库名称 private String repositoryName; // 仓库名称
private Long repositoryId; // 仓库名称 private Long repositoryId; // 仓库名称
private Long applyToken;//已分配token
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Data createdOn; // 项目创建时间以毫秒为单位 private Date createdOn; // 项目创建时间
private Long ableApplyToken;//责任人可分配token
} }

View File

@ -0,0 +1,81 @@
package com.microservices.dms.achievementLibrary.domain.blockchain;
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;
/**
* 区块链数据入链对象 in_blockchain_data
*
* @author microservices
* @date 2025-05-27
*/
public class InBlockchainData extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 数据类型pr、issue、commit */
@Excel(name = "数据类型pr、issue、commit")
private String type;
/** 关联类型的唯一标识符 */
@Excel(name = "关联类型的唯一标识符")
private String typeId;
/** 交易哈希值 */
@Excel(name = "交易哈希值")
private String txHash;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setTypeId(String typeId)
{
this.typeId = typeId;
}
public String getTypeId()
{
return typeId;
}
public void setTxHash(String txHash)
{
this.txHash = txHash;
}
public String getTxHash()
{
return txHash;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("type", getType())
.append("typeId", getTypeId())
.append("txHash", getTxHash())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.toString();
}
}

View File

@ -0,0 +1,35 @@
package com.microservices.dms.achievementLibrary.domain.blockchain;
import java.io.Serializable;
public class InLinkProjectVo implements Serializable {
private Long amount;
private String projectId;
private String userId;
public Long getAmount() {
return this.amount;
}
public void setAmount(Long amount) {
this.amount = amount;
}
public String getProjectId() {
return this.projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}

View File

@ -0,0 +1,152 @@
package com.microservices.dms.achievementLibrary.domain.blockchain;
import java.math.BigDecimal;
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;
/**
* 用户/项目转账信息记录对象 user_project_transfer_records
*
* @author microservices
* @date 2025-05-27
*/
public class UserProjectTransferRecords extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 唯一标识每条记录 */
private Long id;
/** 付款方ID */
@Excel(name = "付款方ID")
private String payerId;
/** 项目ID */
@Excel(name = "项目ID")
private String projectId;
/** 转账金额,支持高精度数值 */
@Excel(name = "转账金额,支持高精度数值")
private BigDecimal token;
/** 收款方ID */
@Excel(name = "收款方ID")
private String payeeId;
/** 交易哈希值,确保每一笔交易唯一 */
@Excel(name = "交易哈希值,确保每一笔交易唯一")
private String txHash;
/** 转账类型project、user */
@Excel(name = "转账类型project、user")
private String type;
/** 备用字段1 */
@Excel(name = "备用字段1")
private String reserve1;
/** 备用字段2 */
@Excel(name = "备用字段2")
private String reserve2;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setPayerId(String payerId)
{
this.payerId = payerId;
}
public String getPayerId()
{
return payerId;
}
public void setProjectId(String projectId)
{
this.projectId = projectId;
}
public String getProjectId()
{
return projectId;
}
public void setToken(BigDecimal token)
{
this.token = token;
}
public BigDecimal getToken()
{
return token;
}
public void setPayeeId(String payeeId)
{
this.payeeId = payeeId;
}
public String getPayeeId()
{
return payeeId;
}
public void setTxHash(String txHash)
{
this.txHash = txHash;
}
public String getTxHash()
{
return txHash;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setReserve1(String reserve1)
{
this.reserve1 = reserve1;
}
public String getReserve1()
{
return reserve1;
}
public void setReserve2(String reserve2)
{
this.reserve2 = reserve2;
}
public String getReserve2()
{
return reserve2;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("payerId", getPayerId())
.append("projectId", getProjectId())
.append("token", getToken())
.append("payeeId", getPayeeId())
.append("txHash", getTxHash())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("type", getType())
.append("reserve1", getReserve1())
.append("reserve2", getReserve2())
.toString();
}
}

View File

@ -0,0 +1,22 @@
package com.microservices.dms.achievementLibrary.domain.blockchain;
public class UserVo {
private Long id;
private String nickname;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
}

View File

@ -12,6 +12,7 @@ import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.PropertyValues;
/** /**
* 成果Mapper接口 * 成果Mapper接口
@ -124,7 +125,7 @@ public interface AchievementsMapper {
List<Long> getAllId(); List<Long> getAllId();
List<AreaStatisticVo> getAreaStatistic(@Param("areaKey") String areaKey); List<AreaStatisticVo> getAreaStatistic(@Param("source")String source,@Param("areaKey") String areaKey);
List<AchRelatedVo> getRelatedAch(@Param("id")Long id, @Param("sourceId") List<Long> sourceId, @Param("paramYear")String paramYear); List<AchRelatedVo> getRelatedAch(@Param("id")Long id, @Param("sourceId") List<Long> sourceId, @Param("paramYear")String paramYear);
@ -158,4 +159,16 @@ public interface AchievementsMapper {
List<KeyValueVo> getAchievementActDataF(@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); List<Map<String, Object>> getDockingUserInfo(@Param("id") Long id);
List<Achievements> selectAchievementsByArea(AchQueryVo achQueryVo);
List<KeyValVo<String, Long>> getExperts(@Param("s") Date s, @Param("e") Date e);
List<KeyValueVo> getAllAreas(@Param("areaName") String areaName);
void updateRelationAchievements(@Param("source") String source,@Param("sourceId") Long sourceId);
List<Map<String, Object>> getDockingUserInfoList(@Param("id") Long id);
String getField1RemarkByParam(@Param("source")String source,@Param("areaKey") String areaKey);
} }

View File

@ -0,0 +1,82 @@
package com.microservices.dms.achievementLibrary.mapper;
import java.util.List;
import java.util.Map;
import com.microservices.common.datasource.annotation.Slave;
import com.microservices.dms.achievementLibrary.domain.BlockchainListQueryVo;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import com.microservices.dms.achievementLibrary.domain.blockchain.InBlockchainData;
import com.microservices.dms.common.vo.CommitCreateVo;
import com.microservices.dms.common.vo.CommitResultVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 区块链数据入链Mapper接口
*
* @author microservices
* @date 2025-05-27
*/
@Mapper
@Slave
public interface InBlockchainDataMapper
{
/**
* 查询区块链数据入链
*
* @param id 区块链数据入链主键
* @return 区块链数据入链
*/
public InBlockchainData selectInBlockchainDataById(Long id);
/**
* 查询区块链数据入链列表
*
* @param inBlockchainData 区块链数据入链
* @return 区块链数据入链集合
*/
public List<InBlockchainData> selectInBlockchainDataList(InBlockchainData inBlockchainData);
/**
* 新增区块链数据入链
*
* @param inBlockchainData 区块链数据入链
* @return 结果
*/
public int insertInBlockchainData(InBlockchainData inBlockchainData);
/**
* 修改区块链数据入链
*
* @param inBlockchainData 区块链数据入链
* @return 结果
*/
public int updateInBlockchainData(InBlockchainData inBlockchainData);
/**
* 删除区块链数据入链
*
* @param id 区块链数据入链主键
* @return 结果
*/
public int deleteInBlockchainDataById(Long id);
/**
* 批量删除区块链数据入链
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteInBlockchainDataByIds(Long[] ids);
List<Map<String, Object>> issueDataList(BlockchainListQueryVo queryVo);
List<Map<String, Object>> commitDataList(BlockchainListQueryVo queryVo);
List<Map<String, Object>> prDataList(BlockchainListQueryVo queryVo);
List<String> getNeedToBlockCommitList();
List<CommitResultVo> getCommitListById(@Param("projectId") String projectId);
}

View File

@ -0,0 +1,73 @@
package com.microservices.dms.achievementLibrary.mapper;
import java.util.List;
import java.util.Map;
import com.microservices.common.datasource.annotation.Slave;
import com.microservices.dms.achievementLibrary.domain.BlockchainListQueryVo;
import com.microservices.dms.achievementLibrary.domain.blockchain.UserProjectTransferRecords;
import com.microservices.dms.achievementLibrary.domain.blockchain.UserVo;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户/项目转账信息记录Mapper接口
*
* @author microservices
* @date 2025-05-27
*/
@Mapper
@Slave
public interface UserProjectTransferRecordsMapper
{
/**
* 查询用户/项目转账信息记录
*
* @param id 用户/项目转账信息记录主键
* @return 用户/项目转账信息记录
*/
public UserProjectTransferRecords selectUserProjectTransferRecordsById(Long id);
/**
* 查询用户/项目转账信息记录列表
*
* @param userProjectTransferRecords 用户/项目转账信息记录
* @return 用户/项目转账信息记录集合
*/
public List<UserProjectTransferRecords> selectUserProjectTransferRecordsList(UserProjectTransferRecords userProjectTransferRecords);
/**
* 新增用户/项目转账信息记录
*
* @param userProjectTransferRecords 用户/项目转账信息记录
* @return 结果
*/
public int insertUserProjectTransferRecords(UserProjectTransferRecords userProjectTransferRecords);
/**
* 修改用户/项目转账信息记录
*
* @param userProjectTransferRecords 用户/项目转账信息记录
* @return 结果
*/
public int updateUserProjectTransferRecords(UserProjectTransferRecords userProjectTransferRecords);
/**
* 删除用户/项目转账信息记录
*
* @param id 用户/项目转账信息记录主键
* @return 结果
*/
public int deleteUserProjectTransferRecordsById(Long id);
/**
* 批量删除用户/项目转账信息记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteUserProjectTransferRecordsByIds(Long[] ids);
List<Map> userDataList(BlockchainListQueryVo queryVo);
List<UserVo> userList(UserVo userVo);
}

View File

@ -21,14 +21,17 @@ public class BigScreenStatisticService {
private final CompetitionResourceLibraryMapper competitionResourceLibraryMapper; private final CompetitionResourceLibraryMapper competitionResourceLibraryMapper;
public Map<String, Object> getAchievementTopStatistic(String source) { public Map<String, Object> getAchievementTopStatistic(String source) {
//获取本周近7天)的数据
Date[] days = DateUtil.getDays(0, 6); Date[] days = DateUtil.getDays(0, 6);
Map<String, Long> m = achievementsMapper.getAchievement(days[0], days[1], source) Map<String, Long> m = achievementsMapper.getAchievement(days[0], days[1], source)
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV)); .stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]); List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
//获取上周7-14天前的数据
Date[] lastDays = DateUtil.getDays(7, 13); Date[] lastDays = DateUtil.getDays(7, 13);
long lastSum = Optional.ofNullable(achievementsMapper.countAchievementBySource(lastDays[0], lastDays[1], source)).orElse(0L); long lastSum = Optional.ofNullable(achievementsMapper.countAchievementBySource(lastDays[0], lastDays[1], source)).orElse(0L);
long sum = Optional.ofNullable(achievementsMapper.countAchievementBySource(null, null, source)).orElse(0L); long sum = Optional.ofNullable(achievementsMapper.countAchievementBySource(null, null, source)).orElse(0L);
long cSum = m.values().stream().mapToLong(Long::longValue).sum(); long cSum = m.values().stream().mapToLong(Long::longValue).sum();
//计算本周/上周增长%
double rate; double rate;
if (lastSum == 0) rate = 100D; if (lastSum == 0) rate = 100D;
else { else {
@ -183,6 +186,7 @@ public class BigScreenStatisticService {
return competitionResourceLibraryMapper.getCompetitionHot(); return competitionResourceLibraryMapper.getCompetitionHot();
} }
public List<KeyValVo<String, Long>> getCompetitionYearlyPaperAdd() { public List<KeyValVo<String, Long>> getCompetitionYearlyPaperAdd() {
Date[] currentYear = DateUtil.getLast12Months(); Date[] currentYear = DateUtil.getLast12Months();

View File

@ -0,0 +1,595 @@
package com.microservices.dms.achievementLibrary.service;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.exception.ServiceException;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.httpClient.service.HttpAPIService;
import com.microservices.common.security.utils.SecurityUtils;
import com.microservices.dms.achievementLibrary.domain.Achievements;
import com.microservices.dms.achievementLibrary.domain.BlockchainListQueryVo;
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
import com.microservices.dms.achievementLibrary.domain.TokenListVo;
import com.microservices.dms.achievementLibrary.domain.blockchain.InBlockchainData;
import com.microservices.dms.achievementLibrary.domain.blockchain.InLinkProjectVo;
import com.microservices.dms.achievementLibrary.domain.blockchain.UserProjectTransferRecords;
import com.microservices.dms.achievementLibrary.domain.blockchain.UserVo;
import com.microservices.dms.achievementLibrary.mapper.InBlockchainDataMapper;
import com.microservices.dms.achievementLibrary.mapper.UserProjectTransferRecordsMapper;
import com.microservices.dms.behaviorImage.domain.AchievementImageVo;
import com.microservices.dms.common.vo.*;
import com.microservices.dms.referral.mapper.TalentReferralMapper;
import com.microservices.dms.resourceLibrary.mapper.ProjectResourceLibraryMapper;
import com.microservices.dms.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
//import org.fisco.bcos.sdk.client.Client;
//import org.fisco.bcos.sdk.client.protocol.request.Transaction;
//import org.fisco.bcos.sdk.client.protocol.response.BcosTransaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import static com.microservices.common.core.utils.DateUtils.YYYY_MM_DD_HH_MM_SS;
import static com.microservices.dms.constant.BlockChainFunConstants.*;
import static com.microservices.dms.utils.DateUtil.formatLocalDateTimePlusH;
@Service
@Slf4j
public class BlockChainService {
@Autowired
private ProjectResourceLibraryMapper projectResourceLibraryMapper;
@Value("${gitlink.fiscobcosUrl:localhost}")
public String fiscobcosUrl;
@Autowired
private HttpAPIService httpAPIService;
@Autowired
private InBlockchainDataMapper inBlockchainDataMapper;
@Autowired
private UserProjectTransferRecordsMapper userProjectTransferRecordsMapper;
@Autowired
private TalentReferralMapper talentReferralMapper;
public List<TokenListVo> projectTokenList(String projectName) {
List<TokenListVo> list = projectResourceLibraryMapper.selectProjectInfos(projectName);
for (TokenListVo v : list) {
JSONObject param = queryProjectInfo(v);
if(param != null) {
Long issueTokenSum = projectResourceLibraryMapper.sumProjectIssueToken(v.getId());
v.setIssueToken(issueTokenSum);
long totalToken = Long.parseLong(param.getString("total_supply"));//总token
v.setTotalToken(totalToken);
//根据创建人login获取对应的用户id
String userName = v.getUserId();
//根据创建人项目Id,获取创建人拥有token
String tokenName = param.getString("token_name");
Long applyToken= getUserBlanaceProjectId("userSingleInfo",userName,tokenName);
v.setApplyToken(applyToken);
v.setCurrentToken(totalToken - applyToken);
}
v.setCreatedOn(DateUtil.plusHours(v.getCreatedOn(), 8));
}
return list;
}
public Long getUserBlanaceProjectId(String type,String userName,String tokenName) {
JSONObject params = new JSONObject();
if(type.equals(USER_SINGLE_INFO)){
params.put(REQUEST_TYPE, USER_SINGLE_REPO);
params.put("token_name", tokenName);
params.put("username", userName);
}else if(type.equals(USER_ALL_INFO)){
params.put(REQUEST_TYPE, USER_ALL_REPOS);
params.put("username", userName);
}
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
return Long.parseLong(rsp.getString("balance"));
}
return -1L;
}
private JSONObject queryProjectInfo(TokenListVo v) {
JSONObject param = new JSONObject();
param.put(REQUEST_TYPE, QUERY_REPO);
param.put("token_name", String.valueOf(v.getId()));
JSONObject jsonObject = queryFiscobcos(param);
if (jsonObject != null) {
return jsonObject;
}
return null;
}
private JSONObject queryFiscobcos(JSONObject param) {
try {
// Map<String,String> p = convertParams(param);
// JSONObject from = JSONObject.from(p);
JSONObject reps = httpAPIService.doPost(fiscobcosUrl, param);
// if (result.getCode() != 200) {
// return null;
// }
// JSONObject reps = JSONObject.parseObject(result.getContent());
if (reps.containsKey(RESP_STATUS) && reps.getString(RESP_STATUS).equals("0")) {
return reps;
}
} catch (Exception e) {
log.error("区块链接口请求失败", e);
return null;
}
return null;
}
private Map<String, String> convertParams(JSONObject param) {
Set<String> keys = param.keySet();
Map<String, String> r = new HashMap<>();
// 遍历 key 集合并获取对应的 value
for (String key : keys) {
Object o = param.get(key);
if (o != null) {
if (o instanceof String || o instanceof Integer || o instanceof Long || o instanceof BigDecimal || o instanceof Double) {
r.put(key, param.getString(key));
} else if (o instanceof LocalDateTime) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String format = formatter.format(LocalDateTime.parse(o.toString(), formatter));
r.put(key, format);
} else if (o instanceof Date) {
String s = DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, (Date) o);
r.put(key, s);
} else if (o instanceof List || o instanceof Map) {
String jsonString = JSONObject.toJSONString(o);
r.put(key, jsonString);
}else {
r.put(key, o.toString());
}
}else {
r.put(key, null);
}
}
return r;
}
public AjaxResult projectTokenDistribute(InLinkProjectVo vo) {
//根据项目ID获取用户ID
//根据项目id获取项目创建人
String userId = projectResourceLibraryMapper.getProjectUserIdById(vo.getProjectId());
validTokenCount(vo.getProjectId(), vo.getAmount(),userId);
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, TRANSFER_AMOUNT);
params.put("token_name", vo.getProjectId());
params.put("amount", vo.getAmount());
params.put("payee", vo.getUserId());
params.put("payer", userId);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
String txHash = rsp.getString(TX_HASH);
// insert to db 4将3入链成功的数据存入表 用户/项目转账信息记录表 type:project payer_idusername)
if (StringUtils.isNotEmpty(txHash)) {
UserProjectTransferRecords records = new UserProjectTransferRecords();
records.setPayerId(params.getString("payer"));//转账人
records.setPayeeId(params.getString("payee"));//收款人
records.setProjectId(vo.getProjectId());
records.setToken(BigDecimal.valueOf(vo.getAmount()));
records.setType("projectApply");//项目分配
records.setCreateTime(DateUtils.getNowDate());
records.setTxHash(txHash);
records.setCreateBy(SecurityUtils.getUsername());
userProjectTransferRecordsMapper.insertUserProjectTransferRecords(records);
}
return AjaxResult.success();
}
return AjaxResult.error();
}
public AjaxResult userCreate(UserCreateVo userCreateVo) {
//根据项目id获取项目创建人
String userId = projectResourceLibraryMapper.getUserIdBYLogin(userCreateVo.getPayee());//收款人ID
userCreateVo.setPayee(userId);
String payerId = projectResourceLibraryMapper.getUserIdBYLogin(userCreateVo.getPayer());//转账人ID
userCreateVo.setPayer(payerId);
//转账人token充足
validUserTokenCount(userCreateVo);
//进行转账
JSONObject params = JSONObject.from(userCreateVo);
params.put(REQUEST_TYPE, TRANSFER_AMOUNT);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
String txHash = rsp.getString(TX_HASH);
// insert to db 将2入链成功的数据新增到用户/项目转账信息记录表 type:user payer_idpayer)
if (StringUtils.isNotEmpty(txHash)) {
UserProjectTransferRecords records = new UserProjectTransferRecords();
records.setPayerId(params.getString("payer"));
records.setPayeeId(params.getString("payee"));
records.setProjectId(params.getString("token_name"));
records.setToken(params.getBigDecimal("amount"));
records.setType("userTransfer");//用户转账
records.setTxHash(txHash);
records.setCreateTime(DateUtils.getNowDate());
records.setCreateBy(SecurityUtils.getUsername());
userProjectTransferRecordsMapper.insertUserProjectTransferRecords(records);
return AjaxResult.success(rsp);
}
}
return AjaxResult.error();
}
//判断用户当前项目剩余token是否还支持分配
private void validUserTokenCount(UserCreateVo userCreateVo) {
//现根据用户id,以及项目名称查询对应用户拥有的token
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, USER_SINGLE_REPO);
params.put("token_name", userCreateVo.getToken_name());
params.put("username", userCreateVo.getPayer());
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
if(rsp != null) {
long curToken = Long.parseLong(rsp.getString("balance"));
Long amount = userCreateVo.getAmount();
if (curToken <amount) {
throw new ServiceException("token数量不足");
}
}
}
//判断项目剩余token是否还支持分配
private void validTokenCount(String tokenName, Long amount,String userName) {
TokenListVo v = new TokenListVo();
if(StringUtils.isEmpty(tokenName)) {
throw new ServiceException("项目ID不能为空");
}
v.setId(Long.parseLong(Optional.ofNullable(tokenName).orElse("-1")));
Long issueTokenSum = projectResourceLibraryMapper.sumProjectIssueToken(v.getId());
v.setIssueToken(issueTokenSum);
//根据创建人项目Id,获取创建人拥有token
Long applyToken= getUserBlanaceProjectId("userSingleInfo",userName,tokenName);
v.setApplyToken(applyToken);
long curToken = applyToken - issueTokenSum;
if (curToken < amount) {
throw new ServiceException("token数量不足");
}
}
private Long queryTotalToken(TokenListVo v) {
if(v.getName().equals("区块链测试")){
System.out.println("zzz");
}
JSONObject param = new JSONObject();
param.put(REQUEST_TYPE, QUERY_REPO);
param.put("token_name", String.valueOf(v.getId()));
JSONObject jsonObject = queryFiscobcos(param);
if (jsonObject != null) {
return jsonObject.getLong("total_supply");
}
return -1L;
}
public AjaxResult prCreate(PrCreateVo prCreateVo) {
Map<String, Object> res = projectResourceLibraryMapper.selectPrInfo(prCreateVo.getPr_id());
if (res != null) {
JSONObject params = JSONObject.from(res);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
params.put("updated_at", DataUtilsStr());
params.put("pull_request_number", params.getLong("pull_request_number"));
params.put(REQUEST_TYPE, CREATE_PR);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
String txHash = rsp.getString(TX_HASH);
//将对应的token todo
// insert to db 新增表pr入链关联id,type,type_id,tx_hash,create_time (type:pr,type_id:"pull_request_id)
if (StringUtils.isNotEmpty(txHash)) {
InBlockchainData inBlockchainData = new InBlockchainData();
inBlockchainData.setType("pr");
inBlockchainData.setTxHash(txHash);
inBlockchainData.setTypeId(prCreateVo.getPr_id());
inBlockchainData.setCreateTime(DateUtils.getNowDate());
inBlockchainData.setCreateBy(SecurityUtils.getUsername());
inBlockchainDataMapper.insertInBlockchainData(inBlockchainData);
return AjaxResult.success(rsp);
}
}
}
return AjaxResult.error();
}
private String DataUtilsStr() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(DateUtils.getNowDate());
}
public AjaxResult issueCreateUpdate(IssueCreateVo issueCreateVo) {
Map<String, Object> res = projectResourceLibraryMapper.selectIssueInfo(issueCreateVo.getIssue_id());
if (res != null) {
JSONObject params = JSONObject.from(res);
params.put(REQUEST_TYPE, CREATE_UPDATE_ISSUE);
params.put("updated_at", DataUtilsStr());
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
String txHash = rsp.getString(TX_HASH);
// insert to db 4 数据入链表id,type,type_id,tx_hash,create_time (type:issue,type_id:issue_id)
if (StringUtils.isNotEmpty(txHash)) {
InBlockchainData inBlockchainData = new InBlockchainData();
inBlockchainData.setType("issue");
inBlockchainData.setTxHash(txHash);
inBlockchainData.setTypeId(issueCreateVo.getIssue_id());
inBlockchainData.setCreateTime(DateUtils.getNowDate());
inBlockchainData.setCreateBy(SecurityUtils.getUsername());
inBlockchainDataMapper.insertInBlockchainData(inBlockchainData);
return AjaxResult.success(rsp);
}
}
}
return AjaxResult.error();
}
public List<Map<String, Object>> issueDataList(BlockchainListQueryVo queryVo) {
List<Map<String, Object>> maps = inBlockchainDataMapper.issueDataList(queryVo);
handleForgeDate(maps);
return maps;
}
private void handleForgeDate(List<Map<String, Object>> maps){
for (Map<String, Object> m : maps) {
LocalDateTime updatedAt = (LocalDateTime) m.get("updated_at");
LocalDateTime createdAt = (LocalDateTime) m.get("created_at");
m.put("updated_at",formatLocalDateTimePlusH(updatedAt,8));
m.put("created_at",formatLocalDateTimePlusH(createdAt,8));
if (m.containsKey("committer_time")) {
LocalDateTime committer_time = (LocalDateTime) m.get("committer_time");
m.put("committer_time",formatLocalDateTimePlusH(committer_time,8));
}
}
}
//定时任务将commit数据入链
// @Scheduled(cron = "${cron.commitPushBlock}")
public void commitPushBlock() {
//先查询需要入链的数据
List<String> commitIdList = inBlockchainDataMapper.getNeedToBlockCommitList();
if(commitIdList!=null && commitIdList.size()>0) {
//遍历数据入区块链
for(String commitId : commitIdList) {
CommitCreateVo commitCreateVo = new CommitCreateVo();
commitCreateVo.setCommit_id(commitId);
commitCreate(commitCreateVo);
}
}
}
public AjaxResult commitCreate(CommitCreateVo commitCreateVo) {
List<CommitResultVo> CommitCreateVoList = new ArrayList<>();
if(StringUtils.isEmpty(commitCreateVo.getCommit_id())) {
String projectId = commitCreateVo.getProject_id();
if (StringUtils.isNotEmpty(projectId)) {
CommitCreateVoList = inBlockchainDataMapper.getCommitListById(projectId);
}
}else{
CommitResultVo resultVo = new CommitResultVo();
resultVo.setCommitId(commitCreateVo.getCommit_id());
resultVo.setCommitDiff(commitCreateVo.getCommit_diff());
CommitCreateVoList.add(resultVo);
}
if(CommitCreateVoList!=null && CommitCreateVoList.size()>0) {
for(CommitResultVo commit : CommitCreateVoList) {
commitDataTnBlock(commit);
}
}
return AjaxResult.success();
}
private AjaxResult commitDataTnBlock(CommitResultVo commitCreateVo) {
String commitId = commitCreateVo.getCommitId();
//根据项目id,查询对应的需要入链的commit
Map<String, Object> res = projectResourceLibraryMapper.selectCommitInfo(commitId,commitCreateVo.getCommitDiff());
JSONObject params = JSONObject.from(res);
params.put(REQUEST_TYPE, CREATE_COMMIT);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
String txHash = rsp.getString(TX_HASH);
// insert to db 4 数据入链表id,type,type_id,tx_hash,create_time (type:issue,type_id:issue_id)
if (StringUtils.isNotEmpty(txHash)) {
InBlockchainData inBlockchainData = new InBlockchainData();
inBlockchainData.setType("commit");
inBlockchainData.setTxHash(txHash);
inBlockchainData.setTypeId(commitId);
inBlockchainData.setCreateTime(DateUtils.getNowDate());
inBlockchainData.setCreateBy(SecurityUtils.getUsername());
inBlockchainDataMapper.insertInBlockchainData(inBlockchainData);
return AjaxResult.success(rsp);
}
}
return AjaxResult.error();
}
public List<Map<String, Object>> commitDataList(BlockchainListQueryVo queryVo) {
List<Map<String, Object>> maps = inBlockchainDataMapper.commitDataList(queryVo);
handleForgeDate(maps);
return maps;
}
public List<Map<String, Object>> prDataList(BlockchainListQueryVo queryVo) {
List<Map<String, Object>> maps = inBlockchainDataMapper.prDataList(queryVo);
handleForgeDate(maps);
return maps;
}
//产权转让
public List<Map> userDataList(BlockchainListQueryVo queryVo) {
Long gitlinkUserId = SecurityUtils.getGitlinkUserId();
Map<String, Object> stringObjectMap = Optional.ofNullable(talentReferralMapper.selectUsersById(gitlinkUserId)).orElse(new HashMap<>());
if (!Objects.equals(stringObjectMap.get("admin"), "1")) {
queryVo.setUserId(gitlinkUserId);
}
return userProjectTransferRecordsMapper.userDataList(queryVo);
}
public List<UserVo> userList(UserVo userVo) {
return userProjectTransferRecordsMapper.userList(userVo);
}
public AjaxResult projectCreate(ProjectCreateVo projectCreateVo) {
//先根据项目id(token_name)判断项目是否存在存在才入链
String tokenName = projectCreateVo.getToken_name();
int num = talentReferralMapper.selectProjectById(tokenName);
if(num>0) {
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, CREATE_REPO);
params.put("owner", projectCreateVo.getOwner());
params.put("token_name", projectCreateVo.getToken_name());
// params.put("cur_supply", projectCreateVo.getCur_supply());
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
params.put("total_supply", projectCreateVo.getTotal_supply());
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
String txHash = rsp.getString(TX_HASH);
// insert to db 4 数据入链表id,type,type_id,tx_hash,create_time (type:issue,type_id:issue_id)
if (StringUtils.isNotEmpty(txHash)) {
InBlockchainData inBlockchainData = new InBlockchainData();
inBlockchainData.setType("project");
inBlockchainData.setTxHash(txHash);
inBlockchainData.setTypeId(projectCreateVo.getToken_name());
inBlockchainData.setCreateTime(DateUtils.getNowDate());
inBlockchainData.setCreateBy(SecurityUtils.getUsername());
inBlockchainDataMapper.insertInBlockchainData(inBlockchainData);
return AjaxResult.success(rsp);
}
}
}
return AjaxResult.error();
}
public AjaxResult queryBlockInfo(String type,String typeId) {
JSONObject params = paramsQuery(type,typeId);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
return AjaxResult.success(rsp);
}
private JSONObject paramsQuery(String type, String typeId) {
JSONObject params = new JSONObject();
if(type.equals(PROJECT_INFO)){
params.put(REQUEST_TYPE, QUERY_REPO);
params.put("token_name", typeId);
}else if(type.equals(COMMIT_INTO)){
params.put(REQUEST_TYPE, QUERY_COMMIT);
params.put("commit_hash", typeId);
}else if(type.equals(PR_LATEST_INFO)){
params.put(REQUEST_TYPE, QUERY_PR_LATEST);
params.put("pull_request_id", typeId);
}else if(type.equals(PR_ALL_INFO)){
params.put(REQUEST_TYPE, QUERY_PR_ALL);
params.put("pull_request_id", typeId);
}else if(type.equals(ISSUE_LATEST_INFO)){
params.put(REQUEST_TYPE, QUERY_ISSUE_LATEST);
params.put("issue_id", typeId);
}else if(type.equals(ISSUE_ALL_INFO)){
params.put(REQUEST_TYPE, QUERY_ISSUE_ALL);
params.put("issue_id", typeId);
}
return params;
}
public AjaxResult getTransactionByHash(String txHash) {
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, GET_TRANSACTION_BYHASH);
params.put("tx_hash", txHash);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
return AjaxResult.success(rsp);
}
public AjaxResult getTransactionReceipt(String txHash) {
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, GET_TRANSACTION_RECEIPT);
params.put("tx_hash", txHash);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
return AjaxResult.success(rsp);
}
public AjaxResult getTotalTransactionCount() {
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, GET_TOTAL_TRANSACTION_COUNTT);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
return AjaxResult.success(rsp);
}
public AjaxResult getBlockNumber() {
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, GET_BLOCK_NUM);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
return AjaxResult.success(rsp);
}
return AjaxResult.error();
}
public AjaxResult getUserTokenByProjectId(String type,String userName,String tokenName) {
JSONObject params = new JSONObject();
if(type.equals(USER_SINGLE_INFO)){
params.put(REQUEST_TYPE, USER_SINGLE_REPO);
params.put("token_name", tokenName);
params.put("username", userName);
}else if(type.equals(USER_ALL_INFO)){
params.put(REQUEST_TYPE, USER_ALL_REPOS);
params.put("username", userName);
}
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
return AjaxResult.success(rsp);
}
return AjaxResult.error();
}
//
public AjaxResult getUserAllProjectToken(String userName) {
JSONObject params = new JSONObject();
params.put(REQUEST_TYPE, USER_ALL_REPOS);
params.put("username", userName);
Map<String, String> p = convertParams(params);
params = JSONObject.from(p);
JSONObject rsp = queryFiscobcos(params);
if (rsp != null) {
return AjaxResult.success(rsp);
}
return AjaxResult.error();
}
}

View File

@ -117,4 +117,11 @@ public interface IAchievementsService {
List<TaskResourceLibrary> getRelatedAchTaskOfExpert(Long id); List<TaskResourceLibrary> getRelatedAchTaskOfExpert(Long id);
List<CompetitionResourceLibrary> getRelatedAchCompetitionOfExpert(Long id); List<CompetitionResourceLibrary> getRelatedAchCompetitionOfExpert(Long id);
AchDetailVo getAreaDetail(String areaKey,String kyxmSum, String source);
List<KeyValVo<String, Long>> get7DayAddExport(AchQueryVo achQueryVo);
List<KeyValueVo> getAllAreas(String areaName);
} }

View File

@ -0,0 +1,95 @@
package com.microservices.dms.achievementLibrary.service;
import java.util.List;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.dms.achievementLibrary.domain.blockchain.InBlockchainData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.microservices.dms.achievementLibrary.mapper.InBlockchainDataMapper;
/**
* 区块链数据入链Service业务层处理
*
* @author microservices
* @date 2025-05-27
*/
@Service
public class InBlockchainDataServiceImpl
{
@Autowired
private InBlockchainDataMapper inBlockchainDataMapper;
/**
* 查询区块链数据入链
*
* @param id 区块链数据入链主键
* @return 区块链数据入链
*/
public InBlockchainData selectInBlockchainDataById(Long id)
{
return inBlockchainDataMapper.selectInBlockchainDataById(id);
}
/**
* 查询区块链数据入链列表
*
* @param inBlockchainData 区块链数据入链
* @return 区块链数据入链
*/
public List<InBlockchainData> selectInBlockchainDataList(InBlockchainData inBlockchainData)
{
return inBlockchainDataMapper.selectInBlockchainDataList(inBlockchainData);
}
/**
* 新增区块链数据入链
*
* @param inBlockchainData 区块链数据入链
* @return 结果
*/
public int insertInBlockchainData(InBlockchainData inBlockchainData)
{
inBlockchainData.setCreateTime(DateUtils.getNowDate());
return inBlockchainDataMapper.insertInBlockchainData(inBlockchainData);
}
/**
* 修改区块链数据入链
*
* @param inBlockchainData 区块链数据入链
* @return 结果
*/
public int updateInBlockchainData(InBlockchainData inBlockchainData)
{
return inBlockchainDataMapper.updateInBlockchainData(inBlockchainData);
}
/**
* 批量删除区块链数据入链
*
* @param ids 需要删除的区块链数据入链主键
* @return 结果
*/
public int deleteInBlockchainDataByIds(Long[] ids)
{
return inBlockchainDataMapper.deleteInBlockchainDataByIds(ids);
}
/**
* 删除区块链数据入链信息
*
* @param id 区块链数据入链主键
* @return 结果
*/
public int deleteInBlockchainDataById(Long id)
{
return inBlockchainDataMapper.deleteInBlockchainDataById(id);
}
}

View File

@ -59,9 +59,11 @@ public class MemoDashboardService {
* @return * @return
*/ */
public List<KeyValueVo> getAddMemoStatistic() { public List<KeyValueVo> getAddMemoStatistic() {
return memoResourceLibraryMapper.getAddMemoStatistic(); Date[] currentYear = DateUtil.getLast12Months();
return memoResourceLibraryMapper.getAddMemoStatistic(currentYear[0],currentYear[1]);
} }
/** /**
* 本年帖子热度top5论坛评论点击点赞 * 本年帖子热度top5论坛评论点击点赞
* @return * @return

View File

@ -0,0 +1,88 @@
package com.microservices.dms.achievementLibrary.service;
import java.util.List;
import com.microservices.common.core.utils.DateUtils;
import com.microservices.dms.achievementLibrary.domain.blockchain.UserProjectTransferRecords;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.microservices.dms.achievementLibrary.mapper.UserProjectTransferRecordsMapper;
/**
* 用户/项目转账信息记录Service业务层处理
*
* @author microservices
* @date 2025-05-27
*/
@Service
public class UserProjectTransferRecordsServiceImpl
{
@Autowired
private UserProjectTransferRecordsMapper userProjectTransferRecordsMapper;
/**
* 查询用户/项目转账信息记录
*
* @param id 用户/项目转账信息记录主键
* @return 用户/项目转账信息记录
*/
public UserProjectTransferRecords selectUserProjectTransferRecordsById(Long id)
{
return userProjectTransferRecordsMapper.selectUserProjectTransferRecordsById(id);
}
/**
* 查询用户/项目转账信息记录列表
*
* @param userProjectTransferRecords 用户/项目转账信息记录
* @return 用户/项目转账信息记录
*/
public List<UserProjectTransferRecords> selectUserProjectTransferRecordsList(UserProjectTransferRecords userProjectTransferRecords)
{
return userProjectTransferRecordsMapper.selectUserProjectTransferRecordsList(userProjectTransferRecords);
}
/**
* 新增用户/项目转账信息记录
*
* @param userProjectTransferRecords 用户/项目转账信息记录
* @return 结果
*/
public int insertUserProjectTransferRecords(UserProjectTransferRecords userProjectTransferRecords)
{
userProjectTransferRecords.setCreateTime(DateUtils.getNowDate());
return userProjectTransferRecordsMapper.insertUserProjectTransferRecords(userProjectTransferRecords);
}
/**
* 修改用户/项目转账信息记录
*
* @param userProjectTransferRecords 用户/项目转账信息记录
* @return 结果
*/
public int updateUserProjectTransferRecords(UserProjectTransferRecords userProjectTransferRecords)
{
return userProjectTransferRecordsMapper.updateUserProjectTransferRecords(userProjectTransferRecords);
}
/**
* 批量删除用户/项目转账信息记录
*
* @param ids 需要删除的用户/项目转账信息记录主键
* @return 结果
*/
public int deleteUserProjectTransferRecordsByIds(Long[] ids)
{
return userProjectTransferRecordsMapper.deleteUserProjectTransferRecordsByIds(ids);
}
/**
* 删除用户/项目转账信息记录信息
*
* @param id 用户/项目转账信息记录主键
* @return 结果
*/
public int deleteUserProjectTransferRecordsById(Long id)
{
return userProjectTransferRecordsMapper.deleteUserProjectTransferRecordsById(id);
}
}

View File

@ -11,6 +11,7 @@ import com.microservices.common.core.utils.StringUtils;
import com.microservices.common.httpClient.service.HttpAPIService; import com.microservices.common.httpClient.service.HttpAPIService;
import com.microservices.common.security.utils.SecurityUtils; import com.microservices.common.security.utils.SecurityUtils;
import com.microservices.dms.achievementLibrary.domain.*; import com.microservices.dms.achievementLibrary.domain.*;
import com.microservices.dms.achievementLibrary.mapper.SchoolEnterpriseAchievementsMapper;
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo; import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
import com.microservices.dms.behaviorImage.domain.AchievementImageVo; import com.microservices.dms.behaviorImage.domain.AchievementImageVo;
import com.microservices.dms.behaviorImage.service.IBehaviorImageService; import com.microservices.dms.behaviorImage.service.IBehaviorImageService;
@ -19,11 +20,13 @@ import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.Searcher; import com.microservices.dms.resourceLibrary.domain.Searcher;
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary; import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo; import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import com.microservices.dms.resourceLibrary.mapper.CompetitionResourceLibraryMapper;
import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper; import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper;
import com.microservices.dms.resourceLibrary.mapper.ProjectResourceLibraryMapper; import com.microservices.dms.resourceLibrary.mapper.ProjectResourceLibraryMapper;
import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper; import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper;
import com.microservices.dms.utils.DateUtil; import com.microservices.dms.utils.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.K;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -52,6 +55,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
@Autowired @Autowired
private ExpertResourceLibraryMapper expertResourceLibraryMapper; private ExpertResourceLibraryMapper expertResourceLibraryMapper;
@Autowired @Autowired
private IBehaviorImageService behaviorImageService; private IBehaviorImageService behaviorImageService;
@ -125,7 +129,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource())); a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource()));
//拼接对接的用户信息 //拼接对接的用户信息
List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfo(a.getId()); List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfoList(a.getId());
a.setDockingUserInfo(dockingUserInfo); a.setDockingUserInfo(dockingUserInfo);
} }
return list; return list;
@ -188,6 +192,14 @@ public class AchievementsServiceImpl implements IAchievementsService {
*/ */
@Override @Override
public int deleteAchievementsById(Long id) { public int deleteAchievementsById(Long id) {
//根据id获取数据仓库该数据信息
Achievements achievements = achievementsMapper.selectAchievementsById(id);
if(achievements != null){
String source = achievements.getSource();
if(StringUtils.isNotEmpty(source)) {
achievementsMapper.updateRelationAchievements(source,achievements.getSourceId());
}
}
return achievementsMapper.deleteAchievementsById(id); return achievementsMapper.deleteAchievementsById(id);
} }
@ -334,6 +346,24 @@ public class AchievementsServiceImpl implements IAchievementsService {
return res; return res;
} }
@Override
public List<KeyValVo<String, Long>> get7DayAddExport(AchQueryVo achQueryVo) {
Date[] days = DateUtil.getDays(0, 6);
Map<String, Long> w = achievementsMapper.getExperts(days[0], days[1])
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
List<KeyValVo<String, Long>> res = new ArrayList<>();
for (String s : dateStr) {
Long a = w.getOrDefault(s, 0L);
KeyValVo<String, Long> k1 = new KeyValVo<>();
k1.setK(s);
k1.setV(a);
res.add(k1);
}
return res;
}
@Override @Override
public Map<String, Long> indexProjectStatistic() { public Map<String, Long> indexProjectStatistic() {
Map<String, Long> res = achievementsMapper.indexProjectStatistic(); Map<String, Long> res = achievementsMapper.indexProjectStatistic();
@ -440,7 +470,19 @@ public class AchievementsServiceImpl implements IAchievementsService {
@Override @Override
public List<AreaStatisticVo> getAreaStatistic(String areaKey) { public List<AreaStatisticVo> getAreaStatistic(String areaKey) {
return achievementsMapper.getAreaStatistic(areaKey); List<AreaStatisticVo> areaStatisticVoList = new ArrayList<>();
if(StringUtils.isNotEmpty(areaKey)) {
//根据逗号进行分割
String[] res =areaKey.split(",");
for (String s : res) {
String[] ss = s.split("_");
List<AreaStatisticVo> tmpList = achievementsMapper.getAreaStatistic(ss[1],ss[0]);
areaStatisticVoList.addAll(tmpList);
}
return areaStatisticVoList;
}else{
return achievementsMapper.getAreaStatistic(null,areaKey);
}
} }
@Override @Override
@ -548,4 +590,37 @@ public class AchievementsServiceImpl implements IAchievementsService {
public List<String> getExpertAreasByName(String areaName) { public List<String> getExpertAreasByName(String areaName) {
return achievementsMapper.getExpertAreasByName(areaName); return achievementsMapper.getExpertAreasByName(areaName);
} }
@Override
public AchDetailVo getAreaDetail(String areaKey,String kyxmSum, String source) {
AchDetailVo achDetailVo = new AchDetailVo();
AchQueryVo achQueryVo = new AchQueryVo();
achQueryVo.setAreaQuery(areaKey);
achQueryVo.setSource(source);
//根据kye,和source,查询领域描述
String remark = achievementsMapper.getField1RemarkByParam(source,areaKey);
achDetailVo.setRemark(remark);
List<Achievements> achievementsList = achievementsMapper.selectAchievementsByArea(achQueryVo);
if(achievementsList!=null && achievementsList.size()>0) {
achDetailVo.setAchievementsList(achievementsList);
long clickSum = achievementsList.stream().mapToLong(Achievements::getClickSum).sum();
achDetailVo.setClickSum(clickSum);
long dockSum = achievementsList.stream().mapToLong(Achievements::getDockSum).sum();
achDetailVo.setDockSum(dockSum);
long favoriteSum = achievementsList.stream().mapToLong(Achievements::getFavoriteSum).sum();
achDetailVo.setFavoriteSum(favoriteSum);
long watcherSum = achievementsList.stream().mapToLong(Achievements::getWatcherSum).sum();
achDetailVo.setWatcherSum(watcherSum);
}
return achDetailVo;
}
@Override
public List<KeyValueVo> getAllAreas(String areaName) {
List<KeyValueVo> resultVal = achievementsMapper.getAllAreas(areaName);
return resultVal;
}
} }

View File

@ -120,6 +120,13 @@ public class SchoolEnterpriseAchievementsServiceImpl implements ISchoolEnterpris
public int updateSchoolEnterpriseAchievements(SchoolEnterpriseAchievements schoolEnterpriseAchievements) public int updateSchoolEnterpriseAchievements(SchoolEnterpriseAchievements schoolEnterpriseAchievements)
{ {
schoolEnterpriseAchievements.setUpdateTime(DateUtils.getNowDate()); schoolEnterpriseAchievements.setUpdateTime(DateUtils.getNowDate());
String status = schoolEnterpriseAchievements.getStatus();
if(StringUtils.isNotEmpty(status)){
schoolEnterpriseAchievements.setReviewDate(DateUtils.getNowDate());
if (SecurityUtils.getLoginUser() != null) {
schoolEnterpriseAchievements.setReviewer(SecurityUtils.getLoginUser().getUsername());
}
}
return schoolEnterpriseAchievementsMapper.updateSchoolEnterpriseAchievements(schoolEnterpriseAchievements); return schoolEnterpriseAchievementsMapper.updateSchoolEnterpriseAchievements(schoolEnterpriseAchievements);
} }

View File

@ -4,28 +4,23 @@ import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult; import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.page.TableDataInfo; import com.microservices.common.core.web.page.TableDataInfo;
import com.microservices.dms.achievementLibrary.domain.AchQueryVo; import com.microservices.dms.achievementLibrary.domain.AchQueryVo;
import com.microservices.dms.achievementLibrary.service.BlockChainService;
import com.microservices.dms.achievementLibrary.service.IAchievementsService; import com.microservices.dms.achievementLibrary.service.IAchievementsService;
import com.microservices.dms.common.vo.*;
import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary; import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary;
import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService; import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
@ -45,6 +40,9 @@ public class OpenController extends BaseController {
@Autowired @Autowired
private IExpertResourceLibraryService expertResourceLibraryService; private IExpertResourceLibraryService expertResourceLibraryService;
@Autowired
private BlockChainService blockChainService;
/** /**
* 获取精选成果 * 获取精选成果
* *
@ -127,6 +125,11 @@ public class OpenController extends BaseController {
return success(achievementsService.get7DayAdd(achQueryVo)); return success(achievementsService.get7DayAdd(achQueryVo));
} }
@ApiOperation("七日新增专家")
@GetMapping("/achievements/get7DayAddExpert")
public AjaxResult get7DayAddExport(AchQueryVo achQueryVo) {
return success(achievementsService.get7DayAddExport(achQueryVo));
}
@ApiOperation("首页项目统计") @ApiOperation("首页项目统计")
@GetMapping("/achievements/indexProjectStatistic") @GetMapping("/achievements/indexProjectStatistic")
@ -188,4 +191,33 @@ public class OpenController extends BaseController {
.body(resource); .body(resource);
} }
// @ApiOperation("提供给开源项目那边新建项目并且use_blockchain='1'的项目数据")
// @PostMapping("/blockChain/projectCreate")
// public AjaxResult projectCreate (@RequestBody ProjectCreateVo projectCreateVo) {
// return blockChainService.projectCreate(projectCreateVo);
// }
@ApiOperation("提供给开源项目那边新建issue、更新issue时调用调用方法时传入相关数据(项目入链并且悬赏金额不为空的issue数据才调用封装方法)")
@PostMapping("/blockChain/issueCreateUpdate")
public AjaxResult issueCreateUpdate (@RequestBody IssueCreateVo issueCreateVo) {
return blockChainService.issueCreateUpdate(issueCreateVo);
}
@ApiOperation("提供给开源项目那边提交commit调用调用方法时传入相关数据(入链项目提交commit才调用)")
@PostMapping("/blockChain/commitCreate")
public AjaxResult commitCreate(@RequestBody CommitCreateVo commitCreateVo) {
return blockChainService.commitCreate(commitCreateVo);
}
@ApiOperation("提供给开源项目那边新建pr时调用调用方法时传入相关数据(入链项目pr_合并代码才调用))")
@PostMapping("/blockChain/prCreate")
public AjaxResult prCreate(@RequestBody PrCreateVo prCreateVo) {
return blockChainService.prCreate(prCreateVo);
}
@ApiOperation("封装方法userCreate入链项目2519用户1向用户2转帐10个金币")
@PostMapping("/blockChain/userCreate")
public AjaxResult userCreate(@RequestBody UserCreateVo userCreateVo) {
return blockChainService.userCreate(userCreateVo);
}
} }

View File

@ -0,0 +1,12 @@
package com.microservices.dms.common.vo;
import lombok.Data;
@Data
public class CommitCreateVo {
private String commit_id;
private String project_id;
private String commit_diff;
}

View File

@ -0,0 +1,10 @@
package com.microservices.dms.common.vo;
import lombok.Data;
@Data
public class CommitResultVo {
private String commitId;
private String commitDiff;
}

View File

@ -0,0 +1,14 @@
package com.microservices.dms.common.vo;
public class IssueCreateVo {
public String getIssue_id() {
return issue_id;
}
public void setIssue_id(String issue_id) {
this.issue_id = issue_id;
}
private String issue_id;
}

View File

@ -0,0 +1,137 @@
package com.microservices.dms.common.vo;
import lombok.Data;
public class PrCreateQueryVo {
private String merge_user;
private String target_branch;
private String created_at;
private String title;
private String pull_request_id;
private String content;
private String source_branch;
private String reponame;
private String updated_at;
private String repo_id;
private Long pull_request_number;
private String action;
private String username;
public String getMerge_user() {
return merge_user;
}
public void setMerge_user(String merge_user) {
this.merge_user = merge_user;
}
public String getTarget_branch() {
return target_branch;
}
public void setTarget_branch(String target_branch) {
this.target_branch = target_branch;
}
public String getCreated_at() {
return created_at;
}
public void setCreated_at(String created_at) {
this.created_at = created_at;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPull_request_id() {
return pull_request_id;
}
public void setPull_request_id(String pull_request_id) {
this.pull_request_id = pull_request_id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getSource_branch() {
return source_branch;
}
public void setSource_branch(String source_branch) {
this.source_branch = source_branch;
}
public String getReponame() {
return reponame;
}
public void setReponame(String reponame) {
this.reponame = reponame;
}
public String getUpdated_at() {
return updated_at;
}
public void setUpdated_at(String updated_at) {
this.updated_at = updated_at;
}
public String getRepo_id() {
return repo_id;
}
public void setRepo_id(String repo_id) {
this.repo_id = repo_id;
}
public Long getPull_request_number() {
return pull_request_number;
}
public void setPull_request_number(Long pull_request_number) {
this.pull_request_number = pull_request_number;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}

View File

@ -0,0 +1,13 @@
package com.microservices.dms.common.vo;
public class PrCreateVo {
private String pr_id;
public String getPr_id() {
return pr_id;
}
public void setPr_id(String pr_id) {
this.pr_id = pr_id;
}
}

View File

@ -0,0 +1,11 @@
package com.microservices.dms.common.vo;
import lombok.Data;
@Data
public class ProjectCreateVo {
private String owner;//项目创建者nickname
private String token_name;//项目id
private Long cur_supply;//项目创建者的初始token
private Long total_supply;
}

View File

@ -0,0 +1,64 @@
package com.microservices.dms.common.vo;
public class UserCreateVo {
private String payee;
private Long amount;
private String token_name;
private String payer;
private String actionType;
private String typeId;
public String getPayee() {
return this.payee;
}
public void setPayee(String payee) {
this.payee = payee;
}
public Long getAmount() {
return this.amount;
}
public void setAmount(Long amount) {
this.amount = amount;
}
public String getToken_name() {
return this.token_name;
}
public void setToken_name(String token_name) {
this.token_name = token_name;
}
public String getPayer() {
return this.payer;
}
public void setPayer(String payer) {
this.payer = payer;
}
public String getActionType() {
return actionType;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
public String getTypeId() {
return typeId;
}
public void setTypeId(String typeId) {
this.typeId = typeId;
}
}

View File

@ -16,7 +16,7 @@ public class BlockChainFunConstants {
public static final String QUERY_PR_LATEST = "query pull request latest 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 QUERY_PR_ALL = "query pull request all info"; //单个pr最后一次入链信息
public static final String CREATE_upDATE_issue = "upload issue info"; //Issue新增修改入链 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_LATEST = "query issue latest info"; //单个Issue最后一次入链信息
public static final String QUERY_ISSUE_ALL = "query issue all info"; //单个Issue入链所有信息 public static final String QUERY_ISSUE_ALL = "query issue all info"; //单个Issue入链所有信息
@ -24,4 +24,27 @@ public class BlockChainFunConstants {
public static final String MINUS_USER_BALANCE = "minus 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分配给本项目中的其他用户 public static final String LOCK_USER_BALANCE = "lock user balance"; //用户转账token-将自己token分配给本项目中的其他用户
public static final String TRANSFER_AMOUNT = "transfer amount";
public static final String REQUEST_TYPE = "request-type";
public static final String TX_HASH = "tx_hash";
public static final String RESP_STATUS = "status";
public static final String GET_BLOCK_NUM = "getBlockNum";
public static final String GET_TOTAL_TRANSACTION_COUNTT = "getTotalTransactionCountT";
public static final String GET_TRANSACTION_BYHASH = "getTransactionByHash";
public static final String GET_TRANSACTION_RECEIPT = "getTransactionReceipt";
public static final String PROJECT_INFO = "projectInfo";
public static final String COMMIT_INTO = "commitInfo";
public static final String PR_LATEST_INFO = "prLatestInfo";
public static final String PR_ALL_INFO = "prAllInfo";
public static final String ISSUE_LATEST_INFO = "issueLatestInfo";
public static final String ISSUE_ALL_INFO = "issueAllInfo";
public static final String USER_SINGLE_INFO = "userSingleInfo";
public static final String USER_ALL_INFO = "userAllInfo";
} }

View File

@ -46,4 +46,5 @@ public interface TalentReferralMapper {
PrInfoVo selectPRInfoById(@Param("id") Integer id); PrInfoVo selectPRInfoById(@Param("id") Integer id);
int selectProjectById(@Param("tokenName") String tokenName);
} }

View File

@ -24,6 +24,8 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.microservices.dms.constant.TaskConstant.*;
/** /**
* 人才推荐服务 * 人才推荐服务
*/ */
@ -46,7 +48,7 @@ public class TalentReferralService {
// 获取项目贡献者数量 // 获取项目贡献者数量
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("id")).filter(StringUtils::isNotBlank).mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
} catch (ServiceException e) { } catch (ServiceException e) {
logger.error("【{}】获取项目贡献者数量失败:{}", projectFullName, e.getMessage()); logger.error("【{}】获取项目贡献者数量失败:{}", projectFullName, e.getMessage());
@ -91,7 +93,7 @@ public class TalentReferralService {
return collaborators; return collaborators;
} }
public List<Map<String, Object>> doIssueTalentReferral(Long issueId , Long projectId) { public List<Map<String, Object>> doIssueTalentReferral(Long issueId, Long projectId) {
List<Map.Entry<Long, Double>> entries = issueTalentReferral(projectId, issueId); List<Map.Entry<Long, Double>> entries = issueTalentReferral(projectId, issueId);
return entries.stream().limit(3).map(s -> { return entries.stream().limit(3).map(s -> {
Map<String, Object> mm = talentReferralMapper.selectUsersById(s.getKey()); Map<String, Object> mm = talentReferralMapper.selectUsersById(s.getKey());
@ -108,12 +110,13 @@ public class TalentReferralService {
List<Long> curIssueAssigners = talentReferralMapper.selectIssuesAssigners(curIssue.getId()); List<Long> curIssueAssigners = talentReferralMapper.selectIssuesAssigners(curIssue.getId());
if (!curIssueAssigners.isEmpty()) { if (!curIssueAssigners.isEmpty()) {
// return new ArrayList<>(); // return new ArrayList<>();
} }
IssuesVo vo = new IssuesVo(); IssuesVo vo = new IssuesVo();
vo.setProjectId(projectId); vo.setProjectId(projectId);
vo.setStatusIds(Lists.newArrayList(ReferralConstant.ISSUE_CLOSED,ReferralConstant.ISSUE_RESOLVED)); vo.setStatusIds(Lists.newArrayList(ReferralConstant.ISSUE_CLOSED, ReferralConstant.ISSUE_RESOLVED));
vo.setIssueClassify("issue");
List<IssuesVo> issuesVos = talentReferralMapper.selectIssuesCondition(vo); List<IssuesVo> issuesVos = talentReferralMapper.selectIssuesCondition(vo);
Map<Long, Double> userFractionMap = new HashMap<>(); Map<Long, Double> userFractionMap = new HashMap<>();
// 计算与解决issue的相似度 标题+描述 // 计算与解决issue的相似度 标题+描述
@ -151,7 +154,7 @@ public class TalentReferralService {
Map<String, Double> userNameFractionMap = new HashMap<>(); Map<String, Double> userNameFractionMap = new HashMap<>();
Map<String, Set<String>> PRFilesMap = new HashMap<>(); Map<String, Set<String>> PRFilesMap = new HashMap<>();
List<IssueDto> closedPullRequests = getPullRequests(projectId, "11").stream() List<IssueDto> closedPullRequests = getPullRequests(projectId, "11").stream()
.filter(e->StringUtils.isNotBlank(e.getAssignUserLogin())).collect(Collectors.toList()); .filter(e -> StringUtils.isNotBlank(e.getAssignUserLogin())).collect(Collectors.toList());
for (IssueDto pr : prs) { for (IssueDto pr : prs) {
PrInfoVo curPrInfoVo = talentReferralMapper.selectPRInfoById(pr.getPullRequestId()); PrInfoVo curPrInfoVo = talentReferralMapper.selectPRInfoById(pr.getPullRequestId());
@ -268,7 +271,7 @@ public class TalentReferralService {
public List<Achievements> taskAchievementTalentReferral(Long taskId) { public List<Achievements> taskAchievementTalentReferral(Long taskId) {
TaskVo task = talentReferralMapper.selectTaskById(taskId); TaskVo task = talentReferralMapper.selectTaskById(taskId);
Achievements tCond = new Achievements(); Achievements tCond = new Achievements();
tCond.setSourceId(taskId); // tCond.setSourceId(taskId);
tCond.setSource("2"); tCond.setSource("2");
tCond.setStatus("1"); tCond.setStatus("1");
List<Achievements> taskAchievements = achievementsMapper.selectAchievementsList(tCond); List<Achievements> taskAchievements = achievementsMapper.selectAchievementsList(tCond);
@ -294,7 +297,7 @@ public class TalentReferralService {
} }
step1Map.forEach((k, v) -> step2Map.merge(k, v, Double::sum)); step1Map.forEach((k, v) -> step2Map.merge(k, v, Double::sum));
step2Map.keySet().removeIf(step -> Double.compare(step2Map.get(step), 0.0D) > 0); step2Map.keySet().removeIf(step -> Double.compare(step2Map.get(step), 0.0D) <= 0.0D);
List<Map.Entry<Long, Double>> entryList = new ArrayList<>(step2Map.entrySet()); List<Map.Entry<Long, Double>> entryList = new ArrayList<>(step2Map.entrySet());
entryList.sort((entry1, entry2) -> Double.compare(entry2.getValue(), entry1.getValue())); entryList.sort((entry1, entry2) -> Double.compare(entry2.getValue(), entry1.getValue()));
@ -313,7 +316,7 @@ public class TalentReferralService {
public Object taskExpertTalentReferral(Long taskId) { public Object taskExpertTalentReferral(Long taskId) {
TaskVo task = talentReferralMapper.selectTaskById(taskId); TaskVo task = talentReferralMapper.selectTaskById(taskId);
List<KeyValueVo> categories = achievementsMapper.getAreasByName(null); List<KeyValueVo> categories = achievementsMapper.getAreasByName(null);
List<TaskVo> completedTasks = talentReferralMapper.selectTaskByStatus(Lists.newArrayList(TaskConstant.TASK_COMPLETE_STATUS)); List<TaskVo> completedTasks = talentReferralMapper.selectTaskByStatus(Lists.newArrayList(TASK_COMPLETE_STATUS,TASK_PAPER_CHOOSING_STATUS,TASK_RESULT_PROOF_STATUS,TASK_SIGNING_STATUS,TASK_PAYING_STATUS));
List<ExpertVo> allExperts = talentReferralMapper.selectExpertsBy(new ExpertVo()); List<ExpertVo> allExperts = talentReferralMapper.selectExpertsBy(new ExpertVo());
List<Long> expertIds = doTaskExpertTalentReferral(task, categories, completedTasks, allExperts); List<Long> expertIds = doTaskExpertTalentReferral(task, categories, completedTasks, allExperts);
@ -328,8 +331,15 @@ public class TalentReferralService {
Map<Long, Double> step1Map = new TreeMap<>(); Map<Long, Double> step1Map = new TreeMap<>();
Map<Long, Double> step2Map = new TreeMap<>(); Map<Long, Double> step2Map = new TreeMap<>();
for (ExpertVo t1 : allExperts) { for (ExpertVo t1 : allExperts) {
if (Objects.equals(taskDomain, t1.getReviewAreaOne()) || Objects.equals(taskDomain, t1.getReviewAreaTwo()) || Objects.equals(taskDomain, t1.getReviewAreaThree())) { if (Objects.equals(taskDomain, t1.getReviewAreaOne())) {
step1Map.put(t1.getId(), 50.0D); step1Map.merge(t1.getId(), 50.0D, Double::sum);
}
if (Objects.equals(taskDomain, t1.getReviewAreaTwo())) {
step1Map.merge(t1.getId(), 50.0D, Double::sum);
}
if (Objects.equals(taskDomain, t1.getReviewAreaThree())) {
step1Map.merge(t1.getId(), 50.0D, Double::sum);
} }
} }

View File

@ -13,4 +13,5 @@ public class IssuesVo {
private Long statusId; private Long statusId;
private List<Long> statusIds; private List<Long> statusIds;
private Long num; private Long num;
private String issueClassify;
} }

View File

@ -6,6 +6,7 @@ import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.common.core.web.page.TableDataInfo; import com.microservices.common.core.web.page.TableDataInfo;
import com.microservices.common.log.annotation.Log; import com.microservices.common.log.annotation.Log;
import com.microservices.common.log.enums.BusinessType; import com.microservices.common.log.enums.BusinessType;
import com.microservices.dms.achievementLibrary.domain.AchQueryVo;
import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary; import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary;
import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService; import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -138,4 +139,5 @@ public class ExpertResourceLibraryController extends BaseController
public AjaxResult getActDataStatisticById(Long id) { public AjaxResult getActDataStatisticById(Long id) {
return success(expertResourceLibraryService.getActDataStatisticById(id)); return success(expertResourceLibraryService.getActDataStatisticById(id));
} }
} }

View File

@ -1,10 +1,14 @@
package com.microservices.dms.resourceLibrary.domain; package com.microservices.dms.resourceLibrary.domain;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.microservices.common.core.annotation.Excel; import com.microservices.common.core.annotation.Excel;
import com.microservices.common.core.web.domain.BaseEntity; import com.microservices.common.core.web.domain.BaseEntity;
import java.util.ArrayList;
import java.util.List;
/** /**
* 专家资源库对象 expert_resource_library * 专家资源库对象 expert_resource_library
* *
@ -48,7 +52,7 @@ public class ExpertResourceLibrary extends BaseEntity {
private String expertDomain; private String expertDomain;
private String titleRank; private String titleRank;
//准入状态
private Long status; private Long status;
//评审领域1 //评审领域1
private String reviewAreaOne; private String reviewAreaOne;
@ -78,6 +82,26 @@ public class ExpertResourceLibrary extends BaseEntity {
private String userNickName; private String userNickName;
private String otherAttachments; private String otherAttachments;
private String fullFileIds;
private List<KeyValVo<String, String>> attachmentList = new ArrayList<>();
public List<KeyValVo<String, String>> getAttachmentList() {
return attachmentList;
}
public void setAttachmentList(List<KeyValVo<String, String>> attachmentList) {
this.attachmentList = attachmentList;
}
public String getFullFileIds() {
return fullFileIds;
}
public void setFullFileIds(String fullFileIds) {
this.fullFileIds = fullFileIds;
}
public String getOtherAttachments() { public String getOtherAttachments() {
return otherAttachments; return otherAttachments;
} }

View File

@ -14,6 +14,7 @@ import com.microservices.dms.resourceLibrary.domain.vo.ExpertAttachmentVo;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo; import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.PropertyValues;
/** /**
* 专家资源库Mapper接口 * 专家资源库Mapper接口
@ -118,7 +119,7 @@ public interface ExpertResourceLibraryMapper
List<KeyValueVo> getForumSectionStatistic(); List<KeyValueVo> getForumSectionStatistic();
List<KeyValueVo> getAddMemoStatistic(); // List<KeyValueVo> getAddMemoStatistic();
List<MemoTotalVo> getTop5Memos(); List<MemoTotalVo> getTop5Memos();
@ -127,4 +128,8 @@ public interface ExpertResourceLibraryMapper
ExpertAttachmentVo getExpertInfoById(@Param("expertId") Long expertId); ExpertAttachmentVo getExpertInfoById(@Param("expertId") Long expertId);
Map<String, Object> getAttachmentInfo(@Param("id") Long id); Map<String, Object> getAttachmentInfo(@Param("id") Long id);
List<KeyValueVo> getAddMemoStatistic(@Param("s") Date s, @Param("e") Date e);
List<KeyValVo<String, String>> getAttachments(@Param("fullFileIds") String fullFileIds);
} }

View File

@ -2,6 +2,7 @@ package com.microservices.dms.resourceLibrary.mapper;
import com.microservices.common.datasource.annotation.Slave; import com.microservices.common.datasource.annotation.Slave;
import com.microservices.dms.achievementLibrary.domain.TokenListVo; import com.microservices.dms.achievementLibrary.domain.TokenListVo;
import com.microservices.dms.common.vo.PrCreateQueryVo;
import com.microservices.dms.resourceLibrary.domain.ProjectResourceLibrary; import com.microservices.dms.resourceLibrary.domain.ProjectResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo; import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import com.microservices.dms.resourceLibrary.domain.vo.ProjectListVo; import com.microservices.dms.resourceLibrary.domain.vo.ProjectListVo;
@ -10,6 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
@Mapper @Mapper
@Slave @Slave
@ -53,7 +55,19 @@ public interface ProjectResourceLibraryMapper {
String getProjectDomainNameByKey(@Param("projectDomain") String projectDomain ); String getProjectDomainNameByKey(@Param("projectDomain") String projectDomain );
List<TokenListVo> selectProjectInfos(); List<TokenListVo> selectProjectInfos(@Param("name") String projectName);
Long sumProjectIssueToken(@Param("id") Long id); Long sumProjectIssueToken(@Param("id") Long id);
Map<String, Object> selectCommitInfo(@Param("commitId") String commitId,@Param("commitDiff") String commitDiff);
Map<String, Object> selectPrInfo(@Param("prId") String prId);
Map<String, Object> selectIssueInfo(@Param("issueId") String issueId);
String getProjectUserIdById(@Param("tokenName")String tokenName);
Long getUsedApplyToken(@Param("tokenName")String tokenName,@Param("userName") String userName);
String getUserIdBYLogin(@Param("userId")String userId);
} }

View File

@ -10,6 +10,7 @@ import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import com.microservices.dms.resourceLibrary.mapper.CompetitionResourceLibraryMapper; import com.microservices.dms.resourceLibrary.mapper.CompetitionResourceLibraryMapper;
import com.microservices.dms.resourceLibrary.domain.vo.UserActionDataVo; import com.microservices.dms.resourceLibrary.domain.vo.UserActionDataVo;
import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper; import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper;
import com.microservices.dms.utils.DateUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -71,6 +72,7 @@ public class CompetitionResourceLibraryService {
a.setV(String.format(PROJECT_DOWNLOAD_API, gitLinkUrl, v)); a.setV(String.format(PROJECT_DOWNLOAD_API, gitLinkUrl, v));
} }
l.setAttachmentList(attachments); l.setAttachmentList(attachments);
l.setSubmissionTime(DateUtil.plusHours(l.getSubmissionTime(), 8));
} }
} }
return list; return list;

View File

@ -6,6 +6,7 @@ import com.microservices.common.core.utils.StringUtils;
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo; import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary; import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary;
import com.microservices.dms.resourceLibrary.domain.vo.ExpertAttachmentVo; import com.microservices.dms.resourceLibrary.domain.vo.ExpertAttachmentVo;
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper; import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper;
import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService; import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -17,6 +18,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import static com.microservices.dms.constant.TaskConstant.MARKER_SPACE_DOWNLOAD_API_BY_ID; import static com.microservices.dms.constant.TaskConstant.MARKER_SPACE_DOWNLOAD_API_BY_ID;
import static com.microservices.dms.constant.TaskConstant.PROJECT_DOWNLOAD_API;
import static com.microservices.dms.utils.UrlUtil.getUrlPath;
/** /**
* 专家资源库Service业务层处理 * 专家资源库Service业务层处理
@ -78,6 +81,8 @@ public class ExpertResourceLibraryServiceImpl implements IExpertResourceLibraryS
} }
} }
@Value("${http.gitLinkUrl}")
public String gitLinkUrl;
/** /**
* 查询专家资源库列表 * 查询专家资源库列表
* *
@ -88,6 +93,31 @@ public class ExpertResourceLibraryServiceImpl implements IExpertResourceLibraryS
public List<ExpertResourceLibrary> selectExpertResourceLibraryList(ExpertResourceLibrary expertResourceLibrary) { public List<ExpertResourceLibrary> selectExpertResourceLibraryList(ExpertResourceLibrary expertResourceLibrary) {
List<ExpertResourceLibrary> expertResourceLibraryList = expertResourceLibraryMapper.selectExpertResourceLibraryList(expertResourceLibrary); List<ExpertResourceLibrary> expertResourceLibraryList = expertResourceLibraryMapper.selectExpertResourceLibraryList(expertResourceLibrary);
for (ExpertResourceLibrary a : expertResourceLibraryList) { for (ExpertResourceLibrary a : expertResourceLibraryList) {
//附件组装
String fullFileIds = a.getFullFileIds();
if(StringUtils.isNotEmpty(fullFileIds)){
List<KeyValVo<String, String>> attachments = expertResourceLibraryMapper.getAttachments(fullFileIds);
for (KeyValVo<String, String> f: attachments) {
String v = String.valueOf(f.getV());
if (StringUtils.isNotEmpty(v)) {
if (v.startsWith("http")) {
String urlPath = getUrlPath(v);
if (StringUtils.isNotEmpty(urlPath)) {
if (urlPath.startsWith("/api")) {
f.setV(gitLinkUrl + urlPath);
}else {
f.setV(gitLinkUrl +"/api"+ urlPath);
}
}
} else {
f.setV(String.format(MARKER_SPACE_DOWNLOAD_API_BY_ID, gitLinkUrl, v));
}
}
}
a.setAttachmentList(attachments);
a.setAttachments(JSON.toJSONString(attachments));
}
//头像组装
String gender = a.getGender(); String gender = a.getGender();
String img = "images/avatars/User/boy.jpg"; String img = "images/avatars/User/boy.jpg";
if(StringUtils.isNotEmpty(gender) && gender.equals("1")){ if(StringUtils.isNotEmpty(gender) && gender.equals("1")){

View File

@ -112,4 +112,28 @@ public class DateUtil {
LocalDateTime s = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); LocalDateTime s = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
return Date.from(s.plusHours(plusHours).atZone(ZoneId.systemDefault()).toInstant()); return Date.from(s.plusHours(plusHours).atZone(ZoneId.systemDefault()).toInstant());
} }
public static String formatLocalDateTimePlusH(LocalDateTime dateTime,long h) {
if (dateTime == null) {return null;}
LocalDateTime localDateTime8 = dateTime.plusHours(h);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return formatter.format(localDateTime8);
}
public Date addHoursToDate(Date date, int hours) {
if (date == null) {return null;}
// 转换为LocalDateTime
LocalDateTime localDateTime = date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
// 增加小时
localDateTime = localDateTime.plusHours(hours);
// 转回Date
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
} }

View File

@ -38,10 +38,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="attachmentCount" column="attachment_count" /> <result property="attachmentCount" column="attachment_count" />
<result property="isExpertAudit" column="is_expert_audit" /> <result property="isExpertAudit" column="is_expert_audit" />
<result property="hotRank" column="hot_rank" /> <result property="hotRank" column="hot_rank" />
<result property="ext1" column="ext1" />
<result property="ext2" column="ext2" />
<result property="ext3" column="ext3" />
</resultMap> </resultMap>
<sql id="selectAchievementsVo"> <sql id="selectAchievementsVo">
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 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,ext1,ext2,ext3 from achievements
</sql> </sql>
<select id="selectAchievementsList" parameterType="Achievements" resultMap="AchievementsResult"> <select id="selectAchievementsList" parameterType="Achievements" resultMap="AchievementsResult">
@ -79,7 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectAchievementsById" parameterType="Long" resultType="com.microservices.dms.achievementLibrary.domain.Achievements"> <select id="selectAchievementsById" parameterType="Long" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
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 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,a.ext1,a.ext2,a.ext3
,u.login as "userLogin",IFNULL(u.nickname,owner_name) as "userNickName",ue.gender as "gender", ,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.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 a.reviewer,a.review_date,a.review_comments, a.images,a.attachments,a.create_by,a.create_time,a.update_by,a.update_time
@ -132,6 +139,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attachmentCount != null">attachment_count,</if> <if test="attachmentCount != null">attachment_count,</if>
<if test="isExpertAudit != null">is_expert_audit,</if> <if test="isExpertAudit != null">is_expert_audit,</if>
<if test="hotRank != null">hot_rank,</if> <if test="hotRank != null">hot_rank,</if>
<if test="ext1 != null">ext1,</if>
<if test="ext2 != null">ext2,</if>
<if test="ext3 != null">ext3,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="showAchievementName != null">#{showAchievementName},</if> <if test="showAchievementName != null">#{showAchievementName},</if>
@ -166,6 +176,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attachmentCount != null">#{attachmentCount},</if> <if test="attachmentCount != null">#{attachmentCount},</if>
<if test="isExpertAudit != null">#{isExpertAudit},</if> <if test="isExpertAudit != null">#{isExpertAudit},</if>
<if test="hotRank != null">#{hotRank},</if> <if test="hotRank != null">#{hotRank},</if>
<if test="ext1 != null">#{ext1},</if>
<if test="ext2 != null">#{ext2},</if>
<if test="ext3 != null">#{ext3},</if>
</trim> </trim>
</insert> </insert>
@ -204,6 +217,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attachmentCount != null">attachment_count = #{attachmentCount},</if> <if test="attachmentCount != null">attachment_count = #{attachmentCount},</if>
<if test="isExpertAudit != null">is_expert_audit = #{isExpertAudit},</if> <if test="isExpertAudit != null">is_expert_audit = #{isExpertAudit},</if>
<if test="hotRank != null">hot_rank = #{hotRank},</if> <if test="hotRank != null">hot_rank = #{hotRank},</if>
<if test="ext3 != null">ext3 = #{ext3},</if>
<if test="ext2 != null">ext2 = #{ext2},</if>
<if test="ext1 != null">ext1 = #{ext1},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
@ -235,22 +251,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="getTjByAreas" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo"> <select id="getTjByAreas" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select c.id as "key", c.name as "name", f.value as "value" select r.name as "name",count(1) as "value" from (
from (select a.domain_value as "name", sum(a.countResult) as "value" select c.name,a.source, a.field_1,c.remark
from (select 'field_1' as domain_type, field_1 as domain_value, count(field_1) as countResult from achievements a
from achievements left join project_categories c on a.field_1 = c.id
group by field_1 where a.source='1' and a.status='1' and a.field_1 is not null and a.field_1 !=""
union all union all
select 'field_2' as domain_type, field_2 as domain_value, count(field_2) as countResult select c.name, a.source, a.field_1, c.remark
from achievements from achievements a
group by field_2 left join categories c on a.field_1 = c.id
union all where a.source in ('2','3','4') and a.status='1' and a.field_1 is not null and a.field_1 !=""
select 'field_3' as domain_type, field_3 as domain_value, count(field_3) as countResult )r
from achievements group by r.name
group by field_3) a order by count(1) desc
group by a.domain_value
order by sum(a.countResult) desc) f
right join categories c on c.id = f.name
limit 0,5 limit 0,5
</select> </select>
@ -325,20 +338,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getaWatcher" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo"> <select id="getaWatcher" 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, '%m-%d') as 'k', count(*) as 'v'
from watchers from watchers w
inner join achievements a on w.watchable_id = a.id
where created_at &gt;= #{s} where created_at &gt;= #{s}
and created_at &lt;= #{e} and created_at &lt;= #{e}
and watchable_type = #{t} and watchable_type = #{t}
and a.status='1'
group by DATE_FORMAT(created_at, '%m-%d') group by DATE_FORMAT(created_at, '%m-%d')
order by DATE_FORMAT(created_at, '%m-%d') order by DATE_FORMAT(created_at, '%m-%d')
</select> </select>
<select id="getFavorite" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo"> <select id="getFavorite" 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, '%m-%d') as 'k', count(*) as 'v'
from favorites from favorites f
inner join achievements a on f.favorite_id = a.id
where created_at &gt;= #{s} where created_at &gt;= #{s}
and created_at &lt;= #{e} and created_at &lt;= #{e}
and favorite_type = #{t} and favorite_type = #{t}
and a.status='1'
group by DATE_FORMAT(created_at, '%m-%d') group by DATE_FORMAT(created_at, '%m-%d')
order by DATE_FORMAT(created_at, '%m-%d') order by DATE_FORMAT(created_at, '%m-%d')
</select> </select>
@ -367,7 +384,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from achievements from achievements
where create_time &gt;= #{s} where create_time &gt;= #{s}
and create_time &lt;= #{e} and create_time &lt;= #{e}
and source = #{t} and source = #{t} and status='1'
group by DATE_FORMAT(create_time, '%m-%d')
order by DATE_FORMAT(create_time, '%m-%d')
</select>
<select id="getExperts" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select DATE_FORMAT(create_time, '%m-%d') as 'k', count(*) as 'v'
from expert_resource_library
where create_time &gt;= #{s}
and create_time &lt;= #{e} and status='1'
group by DATE_FORMAT(create_time, '%m-%d') group by DATE_FORMAT(create_time, '%m-%d')
order by DATE_FORMAT(create_time, '%m-%d') order by DATE_FORMAT(create_time, '%m-%d')
</select> </select>
@ -375,8 +402,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="indexProjectStatistic" resultType="java.util.Map"> <select id="indexProjectStatistic" resultType="java.util.Map">
select COUNT(*) as projectAchievementCount, select COUNT(*) as projectAchievementCount,
IFNULL(SUM(attachment_count), 0) as attachmentCount, 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' and a.status=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 (select count(distinct a.source_id) from achievements a join project_resource_library prl on a.source_id = prl.id where a.source='1' and a.status='1') as projectCount
from achievements from achievements
where source = '1' and status='1' where source = '1' and status='1'
</select> </select>
@ -507,23 +534,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="getAchievementDomain" resultType="java.util.Map"> <select id="getAchievementDomain" resultType="java.util.Map">
select c.id as "key", c.name as "name", f.value as "value" select r.name as "name",count(1) as "value" from (
from (select a.domain_value as "name", sum(a.countResult) as "value" select
from (select 'field_1' as domain_type, field_1 as domain_value, count(field_1) as countResult c.name,a.source, a.field_1,c.remark
from achievements from achievements a
group by field_1 left join project_categories c on a.field_1 = c.id
union all where a.source='1' and a.field_1 is not null and a.field_1 !=""
select 'field_2' as domain_type, field_2 as domain_value, count(field_2) as countResult union all
from achievements select
group by field_2 c.name, a.source, a.field_1, c.remark
union all from achievements a
select 'field_3' as domain_type, field_3 as domain_value, count(field_3) as countResult left join categories c on a.field_1 = c.id
from achievements where a.source in ('2','3','4') and a.field_1 is not null and a.field_1 !=""
group by field_3) a )r
group by a.domain_value group by r.name
order by sum(a.countResult) desc) f
right join categories c on c.id = f.name where f.value is not null
</select> </select>
<select id="getAchievementAddYearly" resultType="java.util.Map"> <select id="getAchievementAddYearly" resultType="java.util.Map">
@ -533,7 +557,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by DATE_FORMAT(create_time, '%Y') order by DATE_FORMAT(create_time, '%Y')
</select> </select>
<select id="getAchievementHotRank" resultType="java.util.Map"> <select id="getAchievementHotRank" resultType="java.util.Map">
select achievement_name as name, create_time as reelaseTime, hot_rank from achievements select IFNULL(show_ach_name,achievement_name) as name, create_time as reelaseTime, hot_rank from achievements
order by hot_rank desc order by hot_rank desc
</select> </select>
@ -542,43 +566,117 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="getAreaStatistic" resultType="com.microservices.dms.achievementLibrary.domain.AreaStatisticVo"> <select id="getAreaStatistic" resultType="com.microservices.dms.achievementLibrary.domain.AreaStatisticVo">
select <if test="source == '' or source == null">
z.name as "areaName", select
z.field_1 as "areaKey", z.name as "areaName",
z.remark as "remark", z.field_1 as "areaKey",
sum(z.kyxm) as "kyxmSum", z.remark as "remark",
sum(z.ckrw) as "ckrwSum", z.source as "source",
sum(z.kfjs) as "kfjsSum", sum(z.kyxm) as "kyxmSum",
sum(z.xqcg) as "xqcgSum" sum(z.ckrw) as "ckrwSum",
from ( sum(z.kfjs) as "kfjsSum",
select r.name, sum(z.xqcg) as "xqcgSum"
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 ( from (
select t.name,t.source,count(1) as "tmp",t.field_1,t.remark select
r.name,
r.field_1,
r.remark,
r.sorceType as "source",
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 ( from (
select c.name,a.source, a.field_1,c.remark select
t.name,t.source,count(1) as "tmp",t.field_1,t.remark,t.sorceType
from (
select c.name,a.source, a.field_1,c.remark,"1" as sorceType
from achievements a
left join project_categories c on a.field_1 = c.id where a.source='1' and c.name is not null
union all
select c.name, a.source, a.field_1, c.remark,"2" as sorceType
from achievements a
left join categories c on a.field_1 = c.id where a.source in ('2','3','4') and c.name is not null
)t
where t.field_1 is not null and t.field_1 !=""
group by t.name, t.source, t.field_1, t.remark,t.sorceType
) r
) z
<where>
<if test="areaKey != null and areaKey != ''">
and z.field_1 = #{areaKey}
</if>
</where>
group by z.name, z.field_1, z.remark, z.source
</if>
<if test='source=="1"'>
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",
"1" as source
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, a.field_1,c.remark,count(1) as "tmp"
from achievements a from achievements a
left join project_categories c on a.field_1 = c.id where a.source='1' left join project_categories c on a.field_1 = c.id
union all where a.source='1' and a.field_1 is not null and a.field_1 !=""
select c.name, a.source, a.field_1, c.remark group by c.name, a.source, a.field_1, c.remark
from achievements a ) r
left join categories c on a.field_1 = c.id where a.source in ('2','3','4') ) z
)t <where>
where t.field_1 is not null and t.field_1 !="" <if test="areaKey != null and areaKey != ''">
group by t.name, t.source, t.field_1, t.remark and z.field_1 = #{areaKey}
) r </if>
) z </where>
<where> group by z.name, z.field_1, z.remark
<if test="areaKey != null and areaKey != ''"> </if>
and z.field_1 = #{areaKey} <if test='source=="2" or source=="3" or source=="4" '>
</if> select
</where> z.name as "areaName",
group by z.name, z.field_1, z.remark 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",
"2" as source
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, a.field_1, c.remark,count(1) as tmp
from achievements a
left join categories c on a.field_1 = c.id
where a.source in ('2','3','4') and a.field_1 is not null and a.field_1 !=""
group by c.name, a.source, a.field_1, c.remark
) r
) z
<where>
<if test="areaKey != null and areaKey != ''">
and z.field_1 = #{areaKey}
</if>
</where>
group by z.name, z.field_1, z.remark
</if>
</select> </select>
<select id="getAllSourceId" resultType="java.lang.Long"> <select id="getAllSourceId" resultType="java.lang.Long">
@ -687,6 +785,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</select> </select>
<select id="getField1RemarkByParam" resultType="String">
<if test='source != null and source == "1"'>
select remark from project_categories where id=#{areaKey}
</if>
<if test='source != null and source == "2"'>
select remark from categories where id =#{areaKey}
</if>
</select>
<select id="getAchievementAddYearlyData" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo"> <select id="getAchievementAddYearlyData" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select DATE_FORMAT(create_time, '%Y-%m') as 'k', count(*) as 'v' select DATE_FORMAT(create_time, '%Y-%m') as 'k', count(*) as 'v'
from achievements from achievements
@ -722,15 +829,103 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from users u from users u
inner join entities e on u.id = e.user_id inner join entities e on u.id = e.user_id
inner join personalities p on e.id = p.entity_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 inner join (select created_at, user_id from clickers where click_id = #{id} and click_type ='userDocking' ) c on u.id = c.user_id
where u.authentication='1' where u.authentication='1'
union all 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 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 from users u
inner join entities e on u.id = e.user_id inner join entities e on u.id = e.user_id
inner join enterprises en on e.id = en.entity_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 inner join (select created_at,user_id from clickers where click_id = #{id} and click_type ='userDocking') c on u.id = c.user_id
where u.enterprise_certification='1') t where u.enterprise_certification='1') t
order by t.created_at order by t.created_at
</select> </select>
<select id="selectAchievementsByArea" parameterType="com.microservices.dms.achievementLibrary.domain.AchQueryVo" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
<if test='source=="2"'>
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",c.remark as "filedDesc",
(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,
(select IFNULL(count(*), 0) from clickers where click_type = 'Achievements' and click_id = a.id) as clickSum,
(select IFNULL(count(*), 0) from clickers where click_type = 'userDocking' and click_id = a.id) as dockSum
from achievements a
left join users u on a.owner_name = u.login
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' and a.source !='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='areaQuery != null and areaQuery != "" '>
and (a.field_1 = #{areaQuery} or a.field_2 = #{areaQuery} or a.field_3 = #{areaQuery})
</if>
</where>
order by a.create_time desc
</if>
<if test='source=="1"'>
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",c.remark as "filedDesc",
(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,
(select IFNULL(count(*), 0) from clickers where click_type = 'Achievements' and click_id = a.id) as clickSum,
(select IFNULL(count(*), 0) from clickers where click_type = 'userDocking' and click_id = a.id) as dockSum
from achievements a
left join users u on a.owner_name = u.login
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})
</if>
</where>
order by create_time desc
</if>
</select>
<select id="getAllAreas" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select r.name as "name",GROUP_CONCAT( r.source SEPARATOR ',') as "result"
from (
select name,CONCAT(id, '_', '2')as source from categories
union all
select name,CONCAT(id, '_', '1') as source from project_categories
)r
<where>
<if test="areaName != null and areaName != ''">and r.name = #{areaName}</if></where>
GROUP BY r.name
</select>
<update id="updateRelationAchievements">
<if test='source != null and source == "1"'>
update project_resource_library set is_transferred_to_achievement='0' ,transfer_date=null where id = #{sourceId}
</if>
<if test='source != null and source == "2"'>
update task_resource_library set is_transferred_to_results_library='0' ,transfer_to_results_date=null where id = #{sourceId}
</if>
<if test='source != null and source == "3"'>
update competition_resource_library set is_transferred_to_result_library='0' ,transferred_to_result_library_time=null where id = #{sourceId}
</if>
<if test='source != null and source == "4"'>
update school_enterprise_achievements set status=null ,review_comments=null,review_date=null,reviewer=null where id = #{sourceId}
</if>
</update>
<select id="getDockingUserInfoList" resultType="java.util.Map">
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(ck.created_at,'%Y-%m-%d %H:%i:%s') as created_at
from clickers ck
inner join users u on ck.user_id = u.id
left join entities e on u.id = e.user_id
left join personalities p on e.id = p.entity_id
where click_type='userDocking' and click_id = #{id}
</select>
</mapper> </mapper>

View File

@ -139,7 +139,7 @@
</where> </where>
</select> </select>
<select id="selectActivityUserLibraryListAll" resultType="com.microservices.dms.behaviorImage.domain.ActivityUserLibrary"> <select id="selectActivityUserLibraryListAll" resultType="com.microservices.dms.behaviorImage.domain.ActivityUserLibrary" parameterType="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 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 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) as "value" from tasks where is_delete='0' and status between 3 and 8 and user_id =u.id) as "relatedTask",
@ -156,7 +156,8 @@
INNER JOIN `team_users` ON `team_users`.`team_id` = `teams`.`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 WHERE `projects`.`id` != 0 AND `team_users`.`user_id` =u.id) as p3
from users u) res from users u) res
where res.relatedCompetition >0 or res.relatedTask >0 or res.p1+res.p2+res.p3>0 where (res.relatedCompetition >0 or res.relatedTask >0 or res.p1+res.p2+res.p3>0)
<if test="userName != null and userName != ''"> and res.userName like concat('%', #{userName}, '%')</if>
</select> </select>
<select id="getrelatedProjectCount" resultType="long"> <select id="getrelatedProjectCount" resultType="long">

View File

@ -130,7 +130,7 @@
ci.status as competition_status, ci.status as competition_status,
cu.works_name as competition_submission_name, cu.works_name as competition_submission_name,
cu.created_at as submission_time, cu.created_at as submission_time,
cu.leader as submitter, IFNULL(cu.leader,us.nickname) as submitter,
submission_type, submission_type,
cu.org_name as submitting_unit, cu.org_name as submitting_unit,
IFNULL(crl.submission_summary,cu.sub_item) as submission_summary, IFNULL(crl.submission_summary,cu.sub_item) as submission_summary,
@ -151,6 +151,7 @@
ci.is_expert_audit ci.is_expert_audit
from competition_infos ci from competition_infos ci
join (select * from competition_users where `status` = 3) cu on ci.id = cu.competition_info_id join (select * from competition_users where `status` = 3) cu on ci.id = cu.competition_info_id
inner join users us on cu.user_id=us.id
left join competition_resource_library crl on crl.competition_user_id = cu.id left join competition_resource_library crl on crl.competition_user_id = cu.id
<where> <where>
<if test="openCompetitionId != null ">and open_competition_id = #{openCompetitionId}</if> <if test="openCompetitionId != null ">and open_competition_id = #{openCompetitionId}</if>
@ -189,7 +190,7 @@
<if test="image != null and image != ''">and image = #{image}</if> <if test="image != null and image != ''">and image = #{image}</if>
<if test="attachment != null and attachment != ''">and attachment = #{attachment}</if> <if test="attachment != null and attachment != ''">and attachment = #{attachment}</if>
</where> </where>
order by is_transferred_to_result_library order by is_transferred_to_result_library,create_time desc,submission_time desc
</select> </select>
<select id="selectCompetitionResourceLibraryById" parameterType="Long" resultMap="CompetitionResourceLibraryResult"> <select id="selectCompetitionResourceLibraryById" parameterType="Long" resultMap="CompetitionResourceLibraryResult">
@ -253,9 +254,9 @@
</select> </select>
<select id="getCompetitionTransferCount" resultType="java.lang.Long"> <select id="getCompetitionTransferCount" resultType="java.lang.Long">
select COUNT(*) select count(1) from competition_users cu
from achievements inner join competition_infos ci on cu.competition_info_id = ci.id
where source = '3' inner join attachments at on cu.id=at.container_id
</select> </select>
<select id="getCompetitionNeedAuditCount" resultType="java.lang.Long"> <select id="getCompetitionNeedAuditCount" resultType="java.lang.Long">
@ -274,11 +275,12 @@
select t.title as name, achievementCount, enrollCount, paperCount, t.id as `id`,(achievementCount+enrollCount+paperCount) as total select t.title as name, achievementCount, enrollCount, paperCount, t.id as `id`,(achievementCount+enrollCount+paperCount) as total
from (select c.title, from (select c.title,
c.id, c.id,
c.updated_at,
(select count(*) from achievements a where source='3' and a.source_id = c.id ) as achievementCount, (select count(*) from achievements a where source='3' and a.source_id = c.id ) as achievementCount,
(select count(*) from competition_users cu where cu.competition_info_id = c.id) as enrollCount, (select count(*) from competition_users cu where cu.competition_info_id = c.id) as enrollCount,
(select count(*) from (select * from competition_users) cu inner join attachments on container_type = 'CompetitionUser' and container_id=cu.id where cu.competition_info_id=c.id) as paperCount (select count(*) from (select * from competition_users) cu inner join attachments on container_type = 'CompetitionUser' and container_id=cu.id where cu.competition_info_id=c.id) as paperCount
from competition_infos c ) as t from competition_infos c ) as t
order by total desc order by total desc,updated_at desc
limit 0,10 limit 0,10
</select> </select>

View File

@ -75,6 +75,7 @@
u.nickname as "userNickName", IFNULL(erl.gender, ue.gender) as "gender", u.nickname as "userNickName", IFNULL(erl.gender, ue.gender) as "gender",
e.id_number,images, attachments, e.id_number,images, attachments,
e.major, e.workplace, e.phone, e.major, e.workplace, e.phone,
CONCAT_WS(',',resume, title_certificate,academic_achievements,honors) AS fullFileIds,
e.workplace_type, e.expert_email, erl.expert_summary, erl.expert_detail, e.professional_title, e.expert_type, e.workplace_type, e.expert_email, erl.expert_summary, erl.expert_detail, e.professional_title, e.expert_type,
expert_domain,u.authentication as expertAuth, 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, e.title_rank, erl.status, e.review_area_one, e.review_area_two, e.review_area_three, e.is_delete, erl.create_by,
@ -136,6 +137,7 @@
left join users u on e.user_id = u.id left join users u on e.user_id = u.id
left join user_extensions ue on u.id = ue.user_id left join user_extensions ue on u.id = ue.user_id
<where> <where>
and erl.status ='1'
<if test="userId != null ">and user_id = #{userId}</if> <if test="userId != null ">and user_id = #{userId}</if>
<if test="expertName != null and expertName != ''">and erl.expert_name like concat('%', #{expertName}, '%') <if test="expertName != null and expertName != ''">and erl.expert_name like concat('%', #{expertName}, '%')
</if> </if>
@ -161,6 +163,7 @@
</if> </if>
<if test="isDelete != null ">and erl.is_delete = #{isDelete}</if> <if test="isDelete != null ">and erl.is_delete = #{isDelete}</if>
</where> </where>
order by erl.sort_no
</select> </select>
<select id="selectExpertResourceLibraryById" parameterType="Long" resultMap="ExpertResourceLibraryResult"> <select id="selectExpertResourceLibraryById" parameterType="Long" resultMap="ExpertResourceLibraryResult">
@ -427,14 +430,14 @@
tmp.taskAuditCount as "taskAuditSum", tmp.taskAuditCount as "taskAuditSum",
tmp.competitionAuditCount as "competitionAuditSum", tmp.competitionAuditCount as "competitionAuditSum",
(tmp.taskAuditCount + tmp.competitionAuditCount) as "total" (tmp.taskAuditCount + tmp.competitionAuditCount) as "total"
from (select e.expert_name, from (select e.expert_name,e.created_on,
(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 = 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 from experts e
left join users u on e.user_id = u.id left join users u on e.user_id = u.id
where e.is_delete = '0' where e.is_delete = '0'
and e.status = 1) tmp and e.status = 1) tmp
order by (tmp.taskAuditCount + tmp.competitionAuditCount) desc order by (tmp.taskAuditCount + tmp.competitionAuditCount) desc,tmp.created_on desc
limit 0,12 limit 0,12
</select> </select>
@ -510,15 +513,17 @@
<select id="getAddMemoStatistic" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo"> <select id="getAddMemoStatistic" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
select a.currentMonth as "name", a.tag_id as "key", sum(a.countTag) as "value" select a.currentMonth as "name", a.tag_id as "key", sum(a.countTag) as "value"
from (select DATE_FORMAT(published_at, '%m') as "currentMonth", tag_id, count(1) as "countTag" from (select DATE_FORMAT(published_at, '%Y-%m') as "currentMonth", tag_id, count(1) as "countTag"
from memos from memos
where DATE_FORMAT(published_at, '%Y') = YEAR (NOW()) and destroy_status is null and hidden=0 and published_at is not null where destroy_status is null and hidden=0 and published_at is not null
group by DATE_FORMAT(published_at, '%m'), tag_id and published_at &gt;= #{s} and published_at &lt;= #{e}
) a group by DATE_FORMAT(published_at, '%Y-%m'), tag_id
) a
group by a.currentMonth, a.tag_id group by a.currentMonth, a.tag_id
order by a.tag_id, a.currentMonth asc order by a.tag_id, a.currentMonth asc
</select> </select>
<select id="getTop5Memos" resultType="com.microservices.dms.achievementLibrary.domain.MemoTotalVo"> <select id="getTop5Memos" resultType="com.microservices.dms.achievementLibrary.domain.MemoTotalVo">
select id as "id",subject as "subject",published_at as "publishedAt",viewed_count as "viewedCount",praises_count as "praisesCount",replies_count as "repliesCount",(viewed_count+praises_count+replies_count) as "behavioreSum" select id as "id",subject as "subject",published_at as "publishedAt",viewed_count as "viewedCount",praises_count as "praisesCount",replies_count as "repliesCount",(viewed_count+praises_count+replies_count) as "behavioreSum"
from memos where destroy_status is null and hidden=0 and published_at is not null and DATE_FORMAT(published_at, '%Y') = YEAR (NOW()) from memos where destroy_status is null and hidden=0 and published_at is not null and DATE_FORMAT(published_at, '%Y') = YEAR (NOW())
@ -545,4 +550,9 @@
<select id="getAttachmentInfo" resultType="java.util.Map"> <select id="getAttachmentInfo" resultType="java.util.Map">
select file_name,id,unique_file_name from busi_attachments where id = #{id} limit 1 select file_name,id,unique_file_name from busi_attachments where id = #{id} limit 1
</select> </select>
<select id="getAttachments" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
select id as v, file_name as k from busi_attachments where FIND_IN_SET (id,#{fullFileIds})
</select>
</mapper> </mapper>

View File

@ -0,0 +1,169 @@
<?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.InBlockchainDataMapper">
<resultMap type="InBlockchainData" id="InBlockchainDataResult">
<result property="id" column="id" />
<result property="type" column="type" />
<result property="typeId" column="type_id" />
<result property="txHash" column="tx_hash" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
</resultMap>
<sql id="selectInBlockchainDataVo">
select id, type, type_id, tx_hash, create_time, create_by from in_blockchain_data
</sql>
<select id="selectInBlockchainDataList" parameterType="InBlockchainData" resultMap="InBlockchainDataResult">
<include refid="selectInBlockchainDataVo"/>
<where>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="typeId != null and typeId != ''"> and type_id = #{typeId}</if>
<if test="txHash != null and txHash != ''"> and tx_hash = #{txHash}</if>
</where>
</select>
<select id="selectInBlockchainDataById" parameterType="Long" resultMap="InBlockchainDataResult">
<include refid="selectInBlockchainDataVo"/>
where id = #{id}
</select>
<select id="issueDataList" resultType="java.util.Map">
select i.id as "issue_id",
i.project_issues_index as "issue_number",
i.status_id as "action",
it.name as "issueStatusName",
i.subject as "title",
i.subject as "issueName",
i.project_id,
r.id as "repo_id",
p.name as "projectName",
r.identifier as "reponame",
i.created_on as "created_at",
i.updated_on as "updated_at",
i.description as "content",
i.author_id as "author_id",
i.blockchain_token_num as "blockchain_token_num",
(select IFNULL(NULLIF(nickname,'') ,login) from users where id = i.author_id) as "createBy",
i.due_date,
(select GROUP_CONCAT(assigner_id SEPARATOR ', ')
from issue_assigners
where issue_id = i.id) as "ownername"
from issues i
inner join issue_statuses it on i.status_id = it.id
inner join projects p on i.project_id = p.id
inner join repositories r on p.id = r.project_id
where p.use_blockchain='1' and i.project_issues_index is not null
<if test="projectName != null and projectName != ''">and p.name like concat('%', #{projectName}, '%')</if>
<if test="issueName != null and issueName != ''">and i.subject like concat('%', #{issueName}, '%')</if>
</select>
<select id="commitDataList" resultType="java.util.Map">
select cl.commit_id as "commit_id",
re.id as "repo_id",
cl.user_id as "committer",
(select IFNULL(NULLIF(nickname, ''),login) from users where id = cl.user_id) as "createBy",
cl.project_id,p.name as "project_name",
cl.message as "content",
cl.created_at as "committer_time",
cl.message as "content",
re.user_id as "author",
ibd.tx_hash as "commitHash",
cl.ref as "commit_diff"
from commit_logs cl
inner join projects p on cl.project_id = p.id
inner join repositories re on p.id = re.project_id
inner join in_blockchain_data ibd on cl.commit_id = ibd.type_id
where p.use_blockchain = '1'
<if test="projectName != null and projectName != ''">and p.name like concat('%', #{projectName}, '%')</if>
order by ibd.create_time desc,cl.created_at desc
</select>
<select id="prDataList" resultType="java.util.Map">
select pr.id as "pull_request_id",
pr.gitea_number as "pull_request_number",
pr.status as "prStatus",
pr.project_id,
source.id as "repo_id",
source.url as "reponame",
pr.user_id as "username",
pr.title as "title",
pr.body as "content",
pr.head "source_branch",
pr.base as "target_branch",
target.id as "target_repo_id",
pr.created_at,
pr.updated_at,p.name as "projectName",(select IFNULL(NULLIF(nickname, ''),login) from users where id = pr.user_id) as "createBy"
from pull_requests pr
inner join projects p on pr.project_id = p.id
inner join repositories source on p.id = source.project_id
left join repositories target on pr.fork_project_id = target.project_id
where p.use_blockchain = '1'
<if test="projectName != null and projectName != ''">and p.name like concat('%', #{projectName}, '%')</if>
<if test="prName != null and prName != ''">and pr.title like concat('%', #{prName}, '%')</if>
</select>
<insert id="insertInBlockchainData" parameterType="InBlockchainData" useGeneratedKeys="true" keyProperty="id">
insert into in_blockchain_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="type != null and type != ''">type,</if>
<if test="typeId != null and typeId != ''">type_id,</if>
<if test="txHash != null and txHash != ''">tx_hash,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null and type != ''">#{type},</if>
<if test="typeId != null and typeId != ''">#{typeId},</if>
<if test="txHash != null and txHash != ''">#{txHash},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
</trim>
</insert>
<update id="updateInBlockchainData" parameterType="InBlockchainData">
update in_blockchain_data
<trim prefix="SET" suffixOverrides=",">
<if test="type != null and type != ''">type = #{type},</if>
<if test="typeId != null and typeId != ''">type_id = #{typeId},</if>
<if test="txHash != null and txHash != ''">tx_hash = #{txHash},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInBlockchainDataById" parameterType="Long">
delete from in_blockchain_data where id = #{id}
</delete>
<delete id="deleteInBlockchainDataByIds" parameterType="String">
delete from in_blockchain_data where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getNeedToBlockCommitList" resultType="String">
select
cl.commit_id as "commit_id"
from commit_logs cl
inner join projects p on cl.project_id = p.id
left join repositories re on cl.repository_id = re.id
left join in_blockchain_data ibd on cl.commit_id = ibd.type_id
where p.use_blockchain = '1' and ibd.tx_hash is null
</select>
<select id="getCommitListById" resultType="com.microservices.dms.common.vo.CommitResultVo">
select
cl.commit_id as "commit_id",cl.ref as "commit_diff"
from commit_logs cl
inner join projects p on cl.project_id = p.id
left join in_blockchain_data ibd on cl.commit_id = ibd.type_id
where p.use_blockchain = '1' and ibd.tx_hash is null and p.id = #{projectId}
</select>
</mapper>

View File

@ -216,7 +216,7 @@
<if test="attachments != null and attachments != ''">and attachments = #{attachments}</if> <if test="attachments != null and attachments != ''">and attachments = #{attachments}</if>
<if test="projectDomain != null and projectDomain != ''">and project_domain = #{projectDomain}</if> <if test="projectDomain != null and projectDomain != ''">and project_domain = #{projectDomain}</if>
</where> </where>
order by is_transferred_to_achievement order by is_transferred_to_achievement,create_time desc,release_date desc
</select> </select>
<select id="selectProjectResourceLibraryById" parameterType="Long" resultMap="ProjectResourceLibraryResult"> <select id="selectProjectResourceLibraryById" parameterType="Long" resultMap="ProjectResourceLibraryResult">
@ -370,15 +370,95 @@
</select> </select>
<select id="selectProjectInfos" resultType="com.microservices.dms.achievementLibrary.domain.TokenListVo"> <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 select p.id, p.name, created_on createdOn, r.identifier repositoryName, r.id as repositoryId,p.user_id as "userId",
join repositories r on p.id = r.project_id where p.use_blockchain = 1 (select IFNULL(NULLIF(nickname,''),login) from users where id = p.user_id) as createBy
from projects p
join repositories r on p.id = r.project_id
where p.use_blockchain = 1
<if test="name != null and name != ''">and p.name like concat('%', #{name}, '%')</if>
</select> </select>
<select id="sumProjectIssueToken" resultType="java.lang.Long"> <select id="sumProjectIssueToken" resultType="java.lang.Long">
select IFNULL(sum(i.blockchain_token_num),0) select IFNULL(sum(i.blockchain_token_num),0)
from issues i from issues i
inner join projects p on i.project_id = p.id inner join projects p on i.project_id = p.id
where p.id=#{id} where p.id=#{id}
</select> </select>
<select id="selectCommitInfo" resultType="java.util.Map">
select cl.commit_id as "commit_hash",
cl.repository_id as "repo_id",
cl.user_id as "committer",
cl.project_id,
cl.message as "content",
cl.created_at as "committer_time",
cl.message as "content",
re.user_id as "author",
'' as "committer_time",
cl.ref as "commit_diff"
from commit_logs cl
inner join projects p on cl.project_id = p.id
left join repositories re on cl.repository_id = re.id
where p.use_blockchain = '1'
and cl.commit_id = #{commitId} and cl.ref = #{commitDiff}
</select>
<select id="selectPrInfo" resultType="java.util.Map">
select pr.id as "pull_request_id",
pr.gitea_number as "pull_request_number",
pr.status as "action",
source.id as "repo_id",
source.url as "reponame",
pr.user_id as "username",
pr.title as "title",
pr.body as "content",
pr.head "source_branch",
pr.base as "target_branch",
pr.issue_id as "issue_id",
target.id as "target_repo_id",
pr.created_at,
pr.updated_at,
'' as "merge_user"
from pull_requests pr
inner join projects p on pr.project_id = p.id
inner join repositories source on p.id = source.project_id
left join repositories target on pr.fork_project_id = target.project_id
where p.use_blockchain = '1'
and pr.id = #{prId}
</select>
<select id="selectIssueInfo" resultType="java.util.Map">
select i.id as "issue_id",
i.status_id as "action",
i.subject as "title",
i.project_id,
r.id as "repo_id",
r.identifier as "reponame",
i.created_on as "created_at",
i.updated_on as "updated_at",
i.description as "content",
i.author_id as "username",
i.due_date,
(select GROUP_CONCAT(assigner_id SEPARATOR ', ')
from issue_assigners
where issue_id = i.id) as "ownername"
from issues i
inner join projects p on i.project_id = p.id
inner join repositories r on p.id = r.project_id
where p.use_blockchain='1' and i.id = #{issueId}
</select>
<select id="getProjectUserIdById" resultType="String">
select u.id from projects p
inner join users u on p.user_id=u.id
where p.id = #{tokenName}
</select>
<select id="getUsedApplyToken" resultType="Long">
select IFNULL(sum(token),0) as "totalSum" from user_project_transfer_records where project_id =#{tokenName} and payee_id !=#{userName}
</select>
<select id="getUserIdBYLogin" resultType="String">
select id from users where login=#{userId}
</select>
</mapper> </mapper>

View File

@ -81,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="achievementLittleType != null and achievementLittleType != ''"> and achievement_little_type = #{achievementLittleType}</if> <if test="achievementLittleType != null and achievementLittleType != ''"> and achievement_little_type = #{achievementLittleType}</if>
<if test="teamName != null and teamName != ''"> and team_name = #{teamName}</if> <if test="teamName != null and teamName != ''"> and team_name = #{teamName}</if>
</where> </where>
order by status desc,create_time desc
</select> </select>
<select id="selectSchoolEnterpriseAchievementsById" parameterType="Long" resultMap="SchoolEnterpriseAchievementsResult"> <select id="selectSchoolEnterpriseAchievementsById" parameterType="Long" resultMap="SchoolEnterpriseAchievementsResult">

View File

@ -8,7 +8,8 @@
<where> <where>
<if test="id != null ">and id = #{id}</if> <if test="id != null ">and id = #{id}</if>
<if test="projectId != null ">and project_id = #{projectId}</if> <if test="projectId != null ">and project_id = #{projectId}</if>
<if test="subject != null ">and `subject` = #{subject}</if> <if test="subject != null and subject != ''">and `subject` = #{subject}</if>
<if test="issueClassify != null and issueClassify != ''">and `issue_classify` = #{issueClassify}</if>
<if test="statusIds != null and statusIds.size() > 0">and status_id in <if test="statusIds != null and statusIds.size() > 0">and status_id in
<foreach item="item" collection="statusIds" open="(" separator="," close=")"> <foreach item="item" collection="statusIds" open="(" separator="," close=")">
#{item} #{item}
@ -77,7 +78,7 @@
</select> </select>
<select id="selectUsersById" resultType="java.util.Map"> <select id="selectUsersById" resultType="java.util.Map">
select id,login,nickname from users where id = #{id} select id,login,nickname,admin from users where id = #{id}
</select> </select>
<select id="selectTaskById" resultType="com.microservices.dms.referral.vo.TaskVo"> <select id="selectTaskById" resultType="com.microservices.dms.referral.vo.TaskVo">
@ -93,9 +94,10 @@
review_area_one, review_area_one,
review_area_two, review_area_two,
review_area_three, review_area_three,
(select IFNULL(nickname,login) from users u where u.id = e.user_id) as nickname (select IFNULL(nickname,login) from users u where u.id = e.user_id) as nickname,
expert_name
from experts e from experts e
where is_delete = 0 where is_delete = 0 and status = 1
</select> </select>
<select id="allTaskWithExpertIds" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo"> <select id="allTaskWithExpertIds" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
@ -120,4 +122,8 @@
from pull_requests pr from pull_requests pr
where pr.id= #{id} where pr.id= #{id}
</select> </select>
<select id="selectProjectById" resultType="int">
select count(1) from projects where id = #{tokenName}
</select>
</mapper> </mapper>

View File

@ -42,10 +42,12 @@
</trim> </trim>
</insert> </insert>
<select id="countClicker" resultType="java.lang.Long"> <select id="countClicker" resultType="java.lang.Long">
select count(*) from clickers c inner join achievements a ON a.id = c.click_id select count(*) from clickers c
inner join achievements a ON a.id = c.click_id
<where> <where>
and a.status='1'
<if test="null != clickType and '' != clickType"> <if test="null != clickType and '' != clickType">
c.click_type = #{clickType} and c.click_type = #{clickType}
</if> </if>
and a.source='4' and a.source='4'
</where> </where>
@ -500,7 +502,7 @@
<if test="imageUrl != null and imageUrl != ''">and image_url = #{imageUrl}</if> <if test="imageUrl != null and imageUrl != ''">and image_url = #{imageUrl}</if>
<if test="attachmentUrl != null and attachmentUrl != ''">and attachment_url = #{attachmentUrl}</if> <if test="attachmentUrl != null and attachmentUrl != ''">and attachment_url = #{attachmentUrl}</if>
</where> </where>
order by is_transferred_to_results_library order by is_transferred_to_results_library,create_time desc,submission_date desc
</select> </select>
<select id="selectTaskResourceLibraryById" parameterType="Long" resultMap="TaskResourceLibraryResult"> <select id="selectTaskResourceLibraryById" parameterType="Long" resultMap="TaskResourceLibraryResult">

View File

@ -0,0 +1,141 @@
<?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.UserProjectTransferRecordsMapper">
<resultMap type="UserProjectTransferRecords" id="UserProjectTransferRecordsResult">
<result property="id" column="id"/>
<result property="payerId" column="payer_id"/>
<result property="projectId" column="project_id"/>
<result property="token" column="token"/>
<result property="payeeId" column="payee_id"/>
<result property="txHash" column="tx_hash"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="type" column="type"/>
<result property="reserve1" column="reserve_1"/>
<result property="reserve2" column="reserve_2"/>
</resultMap>
<sql id="selectUserProjectTransferRecordsVo">
select id,
payer_id,
project_id,
token,
payee_id,
tx_hash,
create_time,
create_by,
type,
reserve_1,
reserve_2
from user_project_transfer_records
</sql>
<select id="selectUserProjectTransferRecordsList" parameterType="UserProjectTransferRecords"
resultMap="UserProjectTransferRecordsResult">
<include refid="selectUserProjectTransferRecordsVo"/>
<where>
<if test="payerId != null and payerId != ''">and payer_id = #{payerId}</if>
<if test="projectId != null and projectId != ''">and project_id = #{projectId}</if>
<if test="token != null ">and token = #{token}</if>
<if test="payeeId != null and payeeId != ''">and payee_id = #{payeeId}</if>
<if test="txHash != null and txHash != ''">and tx_hash = #{txHash}</if>
<if test="type != null and type != ''">and type = #{type}</if>
<if test="reserve1 != null and reserve1 != ''">and reserve_1 = #{reserve1}</if>
<if test="reserve2 != null and reserve2 != ''">and reserve_2 = #{reserve2}</if>
</where>
</select>
<select id="selectUserProjectTransferRecordsById" parameterType="Long" resultMap="UserProjectTransferRecordsResult">
<include refid="selectUserProjectTransferRecordsVo"/>
where id = #{id}
</select>
<select id="userDataList" resultType="java.util.Map">
select * from ( select p.name projectName,payer_id,payee_id,uptr.token,uptr.tx_hash,uptr.type,
(select IFNULL(lastname,login) from users where id = uptr.payer_id) as "payerName" ,
(select IFNULL(lastname,login) from users where id = uptr.payee_id) as "payeeName"
from user_project_transfer_records uptr join projects p on uptr.project_id = p.id)tmp
<where>
<if test="projectName != null and projectName != ''">and tmp.projectName like concat('%', #{projectName}, '%')
</if>
<if test="userName != null and userName != ''">and (tmp.payerName like concat('%', #{userName}, '%') OR
tmp.payeeName like concat('%', #{userName}, '%'))
</if>
<if test="userId != null ">and (tmp.payer_id = #{userId} OR
tmp.payee_id = #{userId})
</if>
</where>
</select>
<select id="userList" resultType="com.microservices.dms.achievementLibrary.domain.blockchain.UserVo">
select * from (select id,IFNULL(nickname,login) as "nickname" from users where status=1) tmp
<where>
<if test="nickname != null and nickname != ''">
and tmp.nickname like concat('%', #{nickname}, '%'))
</if>
</where>
</select>
<insert id="insertUserProjectTransferRecords" parameterType="UserProjectTransferRecords" useGeneratedKeys="true"
keyProperty="id">
insert into user_project_transfer_records
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="payerId != null and payerId != ''">payer_id,</if>
<if test="projectId != null and projectId != ''">project_id,</if>
<if test="token != null">token,</if>
<if test="payeeId != null and payeeId != ''">payee_id,</if>
<if test="txHash != null and txHash != ''">tx_hash,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="type != null">type,</if>
<if test="reserve1 != null">reserve_1,</if>
<if test="reserve2 != null">reserve_2,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="payerId != null and payerId != ''">#{payerId},</if>
<if test="projectId != null and projectId != ''">#{projectId},</if>
<if test="token != null">#{token},</if>
<if test="payeeId != null and payeeId != ''">#{payeeId},</if>
<if test="txHash != null and txHash != ''">#{txHash},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="type != null">#{type},</if>
<if test="reserve1 != null">#{reserve1},</if>
<if test="reserve2 != null">#{reserve2},</if>
</trim>
</insert>
<update id="updateUserProjectTransferRecords" parameterType="UserProjectTransferRecords">
update user_project_transfer_records
<trim prefix="SET" suffixOverrides=",">
<if test="payerId != null and payerId != ''">payer_id = #{payerId},</if>
<if test="projectId != null and projectId != ''">project_id = #{projectId},</if>
<if test="token != null">token = #{token},</if>
<if test="payeeId != null and payeeId != ''">payee_id = #{payeeId},</if>
<if test="txHash != null and txHash != ''">tx_hash = #{txHash},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="type != null">type = #{type},</if>
<if test="reserve1 != null">reserve_1 = #{reserve1},</if>
<if test="reserve2 != null">reserve_2 = #{reserve2},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteUserProjectTransferRecordsById" parameterType="Long">
delete
from user_project_transfer_records
where id = #{id}
</delete>
<delete id="deleteUserProjectTransferRecordsByIds" parameterType="String">
delete from user_project_transfer_records where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>