Commit 57520671 authored by Administrator's avatar Administrator

赛事列表报名数逻辑修改

parent 94b77fab
...@@ -158,6 +158,7 @@ ...@@ -158,6 +158,7 @@
select a.cmpt_id, select a.cmpt_id,
a.cmpt_name as cmptName, a.cmpt_name as cmptName,
a.logo, a.logo,
b.gCmptId,
date_format(start_time,'%Y-%m-%d') startTime, date_format(start_time,'%Y-%m-%d') startTime,
date_format(end_time,'%Y-%m-%d') endTime, date_format(end_time,'%Y-%m-%d') endTime,
date_format(a.start_time,'%Y-%m-%d %H:%i:%s') as startTimeStr, date_format(a.start_time,'%Y-%m-%d %H:%i:%s') as startTimeStr,
......
...@@ -23,6 +23,7 @@ public class Cmpt extends JaapRecord<Cmpt> { ...@@ -23,6 +23,7 @@ public class Cmpt extends JaapRecord<Cmpt> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer cmptId; // 赛事id private Integer cmptId; // 赛事id
private Integer gCmptId; // 报名官网cmptId
@ApiModelProperty(value = "赛事名字", notes = "赛事名字") @ApiModelProperty(value = "赛事名字", notes = "赛事名字")
private String cmptName; // 赛事名字 private String cmptName; // 赛事名字
@ApiModelProperty(value = "赛事LOGO", notes = "赛事LOGO") @ApiModelProperty(value = "赛事LOGO", notes = "赛事LOGO")
......
...@@ -9,6 +9,7 @@ import com.dlbridge.jadp.plugins.cmpt.utils.PageFactory; ...@@ -9,6 +9,7 @@ import com.dlbridge.jadp.plugins.cmpt.utils.PageFactory;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -40,6 +41,14 @@ public class CmptService { ...@@ -40,6 +41,14 @@ public class CmptService {
@Resource @Resource
private ValueOperations valueOperations; private ValueOperations valueOperations;
@Resource
private HashOperations hashOperations;
/**
* 赛事下已报名集合
*/
public final static String CMPT_ENROLLED = "cmpt:enrolled:";
public Cmpt queryCmptBycmptId(Integer cmptId) { public Cmpt queryCmptBycmptId(Integer cmptId) {
try { try {
Cmpt cmpt = remoteService.getCmptByCmptId(cmptId); Cmpt cmpt = remoteService.getCmptByCmptId(cmptId);
...@@ -233,7 +242,16 @@ public class CmptService { ...@@ -233,7 +242,16 @@ public class CmptService {
if (countStr != null) { if (countStr != null) {
cmpt.setEnroll(Integer.valueOf(countStr.toString())); cmpt.setEnroll(Integer.valueOf(countStr.toString()));
} else { } else {
// 查询计时名单人数
int cmptEnrollCount = remoteService.getCmptEnrollCount(cmpt.getCmptId()); int cmptEnrollCount = remoteService.getCmptEnrollCount(cmpt.getCmptId());
// 查询线上报名人数
Map<Object, Object> cmptEnrolledMap = hashOperations.entries(CMPT_ENROLLED + cmpt.getGCmptId());
int enrollCountOnline = cmptEnrolledMap == null ? 0 : cmptEnrolledMap.size();
// log.info("===赛事[{}]线上报名人数:{},计时名单人数:{}", cmpt.getGCmptId(), enrollCountOnline, cmptEnrollCount);
// 哪个人数多显示哪个
if(enrollCountOnline > cmptEnrollCount){
cmptEnrollCount = enrollCountOnline;
}
cmpt.setEnroll(cmptEnrollCount); cmpt.setEnroll(cmptEnrollCount);
valueOperations.set("count:cmptid:" + cmpt.getCmptId(), cmptEnrollCount + "", 30, TimeUnit.MINUTES); valueOperations.set("count:cmptid:" + cmpt.getCmptId(), cmptEnrollCount + "", 30, TimeUnit.MINUTES);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment