提交 246c607a 编写于 作者: minghao.wu's avatar minghao.wu

feature: 在轮列表中加入本期状态和获奖人的信息

上级 7f89021e
......@@ -138,7 +138,7 @@
<dependency>
<groupId>com.pica.cloud.online.exam</groupId>
<artifactId>pica-cloud-analysis-common</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<scope>compile</scope>
</dependency>
......
......@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -597,11 +598,23 @@ public class AnalysisController {
*/
roundExamTitleV2Dto.setAnalysisId(roundExamTitleDto.getAnalysisId());
roundExamTitleV2Dto.setRoundId(roundExamTitleDto.getRoundId());
roundExamTitleV2Dto.setStartTime(roundExamTitleV2Dto.getStartTime());
roundExamTitleV2Dto.setEndTime(roundExamTitleV2Dto.getEndTime());
roundExamTitleV2Dto.setStartTime(roundExamTitleDto.getStartTime());
roundExamTitleV2Dto.setEndTime(roundExamTitleDto.getEndTime());
roundExamTitleV2Dto.setTotalCount(roundExamTitleDto.getTotalCount());
roundExamTitleV2Dto.setPublished(roundExamTitleDto.getPublished());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if ((new Date()).getTime() > sdf.parse(roundExamTitleDto.getEndTime()).getTime()) {
roundExamTitleV2Dto.setIsFinished(1);
roundExamTitleV2Dto.setElectedStarCount(analysisService.getElectedStarCountByRoundId(roundId));
Integer doctorId = analysisService.getElectedDoctorIdByRoundId(roundId);
roundExamTitleV2Dto.setElectedDoctor(doctorService.getDoctorDtoById(doctorId));
} else {
roundExamTitleV2Dto.setIsFinished(0);
roundExamTitleV2Dto.setElectedDoctor(new DoctorDto());
}
List<ExamTitleDto> examTitleDtoList = analysisService.getExamTitleListByRoundId(roundId);
roundExamTitleV2Dto.setExamTitleList(examTitleDtoList);
builder.setData(roundExamTitleV2Dto);
......
......@@ -38,4 +38,18 @@ public interface ReplyMapper {
* @return
*/
List<Reply> selectFiveHottestReplyList(Integer analysisRoundExamTitleId);
/**
* 根据话题id获取当选的票数
* @param examTitleIds
* @return
*/
Integer selectElectedStarCountByExamTitleIdList(List<Integer> examTitleIds);
/**
* 根据话题id获取当选的医生id
* @param examTitleIds
* @return
*/
Integer selectElectedDoctorIdByExamTitleIdList(List<Integer> examTitleIds);
}
\ No newline at end of file
......@@ -170,4 +170,18 @@ public interface CHCAnalysisService {
* @return
*/
List<AnalysisRoundDto> getCHCHistoryRound();
/**
* 获取某一轮的最多得票数
* @param roundId
* @return
*/
Integer getElectedStarCountByRoundId(Integer roundId);
/**
* 获取被选中的医生id
* @param roundId
* @return
*/
Integer getElectedDoctorIdByRoundId(Integer roundId);
}
package com.pica.cloud.online.exam.analysis.server.service;
import com.pica.cloud.online.exam.analysis.common.dto.DoctorDto;
import com.pica.cloud.online.exam.analysis.server.entity.Doctor;
/**
......@@ -14,6 +15,12 @@ public interface DoctorService {
*/
Doctor getDoctorById(Integer doctorId);
/**
* 根据医生id获取医生dtp
* @return
*/
DoctorDto getDoctorDtoById(Integer doctorId);
/**
* 根据医生的id获取医生的权限
* @param doctorId
......
......@@ -59,7 +59,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
CHCAnalysisDto analysisDto = new CHCAnalysisDto();
analysisDto.setId(analysis.getId());
......@@ -84,7 +84,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
CHCAnalysisDto analysisDto = new CHCAnalysisDto();
analysisDto.setId(analysis.getId());
......@@ -118,7 +118,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
}
List<AnalysisRoundDto> roundDtoList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (AnalysisRound round : roundList) {
AnalysisRoundDto roundDto = new AnalysisRoundDto();
......@@ -153,7 +153,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
RoundExamTitleDto roundExamTitleDto = new RoundExamTitleDto();
......@@ -255,7 +255,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
List<Reply> replyList = getReplyList(analysisRoundExamTitleId);
List<ReplyDto> replyDtoList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (Reply reply : replyList) {
try {
......@@ -303,8 +302,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
@Override
public ReplyDto getReplyDtoByReply(Reply reply, Integer userId) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
ReplyDto replyDto = new ReplyDto();
Doctor doctor = doctorMapper.selectByPrimaryKey(reply.getUserId());
......@@ -527,7 +524,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
roundList = analysisRoundMapper.selectHistoryRoundListById(1);
List<AnalysisRoundDto> roundDtoList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (AnalysisRound round : roundList) {
AnalysisRoundDto roundDto = new AnalysisRoundDto();
......@@ -554,4 +551,24 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return roundDtoList;
}
@Override
public Integer getElectedStarCountByRoundId(Integer roundId) {
List<AnalysisRoundExamTitle> examTitleList = analysisRoundExamTitleMapper.selectExamTitleListByRoundId(roundId);
List<Integer> examTitleIdList = new ArrayList<>();
for (AnalysisRoundExamTitle examTitle : examTitleList) {
examTitleIdList.add(examTitle.getId());
}
return replyMapper.selectElectedStarCountByExamTitleIdList(examTitleIdList);
}
@Override
public Integer getElectedDoctorIdByRoundId(Integer roundId) {
List<AnalysisRoundExamTitle> examTitleList = analysisRoundExamTitleMapper.selectExamTitleListByRoundId(roundId);
List<Integer> examTitleIdList = new ArrayList<>();
for (AnalysisRoundExamTitle examTitle : examTitleList) {
examTitleIdList.add(examTitle.getId());
}
return replyMapper.selectElectedDoctorIdByExamTitleIdList(examTitleIdList);
}
}
package com.pica.cloud.online.exam.analysis.server.service.impl;
import com.pica.cloud.online.exam.analysis.common.dto.DoctorDto;
import com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration;
import com.pica.cloud.online.exam.analysis.server.entity.Doctor;
import com.pica.cloud.online.exam.analysis.server.mapper.DoctorMapper;
import com.pica.cloud.online.exam.analysis.server.service.DoctorService;
......@@ -15,11 +17,30 @@ public class DoctorServiceImpl implements DoctorService {
@Autowired
DoctorMapper doctorMapper;
@Autowired
private PropertiesConfiguration properties;
@Override
public Doctor getDoctorById(Integer doctorId) {
return doctorMapper.selectByPrimaryKey(doctorId);
}
@Override
public DoctorDto getDoctorDtoById(Integer doctorId) {
Doctor doctor = doctorMapper.selectByPrimaryKey(doctorId);
DoctorDto doctorDto = new DoctorDto();
doctorDto.setId(doctor.getId());
doctorDto.setName(doctor.getName());
doctorDto.setHospital(doctor.getHospital());
doctorDto.setTitle(doctor.getTitle());
doctorDto.setAvatarImageUrl(doctor.getAvatarImageUrl() != null
? properties.getFileUrl() + doctor.getAvatarImageUrl().trim()
: properties.getFileUrl() + "/File/doctor_default.png");
return doctorDto;
}
@Override
public boolean isAuth(Integer doctorId) {
return doctorMapper.selectAuthByDoctorId(doctorId) > 0 ||
......
......@@ -82,6 +82,34 @@
limit 5
</select>
<select id="selectElectedStarCountByExamTitleIdList" resultType="java.lang.Integer">
select
sum(star_count) as star
from p_reply
where analysis_round_exam_title_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and is_deleted = 0
group by user_id
order by star desc, created_time
limit 1
</select>
<select id="selectElectedDoctorIdByExamTitleIdList" resultType="java.lang.Integer">
select
user_id
from p_reply
where analysis_round_exam_title_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
and is_deleted = 0
group by user_id
order by sum(star_count) desc, created_time
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from p_reply
where id = #{id,jdbcType=INTEGER}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册