提交 4e3d9710 编写于 作者: minghao.wu's avatar minghao.wu

feature: 在记录列表中增加剩余时间

上级 24e9ecd0
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
<dependency> <dependency>
<groupId>com.pica.cloud.online.exam</groupId> <groupId>com.pica.cloud.online.exam</groupId>
<artifactId>pica-cloud-analysis-common</artifactId> <artifactId>pica-cloud-analysis-common</artifactId>
<version>1.0.6</version> <version>1.0.7</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
......
...@@ -16,6 +16,7 @@ import com.pica.cloud.online.exam.analysis.server.service.AntiSpamService; ...@@ -16,6 +16,7 @@ import com.pica.cloud.online.exam.analysis.server.service.AntiSpamService;
import com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService; import com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService;
import com.pica.cloud.online.exam.analysis.server.service.CHCRankingListService; import com.pica.cloud.online.exam.analysis.server.service.CHCRankingListService;
import com.pica.cloud.online.exam.analysis.server.service.DoctorService; import com.pica.cloud.online.exam.analysis.server.service.DoctorService;
import com.pica.cloud.online.exam.analysis.server.utils.DateUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import javassist.bytecode.ExceptionsAttribute; import javassist.bytecode.ExceptionsAttribute;
...@@ -656,11 +657,11 @@ public class AnalysisController { ...@@ -656,11 +657,11 @@ public class AnalysisController {
myStarDto.setRoundList(roundDtoList); myStarDto.setRoundList(roundDtoList);
} }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM:dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy.M.d");
AnalysisRound analysisRound = analysisService.getRoundInfoById(roundId); AnalysisRound analysisRound = analysisService.getRoundInfoById(roundId);
myStarDto.setStartTime(sdf.format(analysisRound.getStartTime())); myStarDto.setStartTime(sdf.format(analysisRound.getStartTime()));
myStarDto.setEndTime(sdf.format(analysisRound.getEndTime())); myStarDto.setEndTime(sdf.format(analysisRound.getEndTime()));
myStarDto.setRemainingTime(DateUtils.remainingTime(analysisRound.getEndTime()));
/** /**
* 设置结束状态 * 设置结束状态
*/ */
......
...@@ -36,4 +36,25 @@ public class DateUtils { ...@@ -36,4 +36,25 @@ public class DateUtils {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date); return sdf.format(date);
} }
public static String remainingTime(Date date) {
long time = date.getTime() / 1000;
long now = (new Date()).getTime() / 1000;
long interval = now - time;
if (interval < 0)
return "";
if (interval <= ONE_MINITE) {
return "1分钟";
} else if (interval <= ONE_HOUR) {
return interval / ONE_MINITE + "分钟";
} else if (interval <= ONE_DAY) {
return interval / ONE_HOUR + "小时" + interval % ONE_HOUR + "分钟";
} else {
return interval / ONE_DAY + "天" +
(interval % ONE_DAY) / ONE_HOUR + "小时" +
(interval % ONE_DAY) % ONE_HOUR + "分钟";
}
}
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册