xiatian 6 жил өмнө
parent
commit
6d8e19a313

+ 3 - 0
examcloud-core-reports-api-provider/src/main/java/cn/com/qmth/examcloud/core/reports/api/provider/ExamStudentCountCloudServiceProvider.java

@@ -39,6 +39,9 @@ public class ExamStudentCountCloudServiceProvider extends ControllerSupport impl
 		if (req.getExamId() == null) {
 			throw new StatusException("1000003", "examId不能为空");
 		}
+		if(req.getBatchTime()==null) {
+			throw new StatusException("1000004", "batchTime不能为空");
+		}
 		examStudentCountService.addOrUpdateCount(req);
 		return new AddOrUpdateExamStudentCountResp();
 	}

+ 3 - 0
examcloud-core-reports-api-provider/src/main/java/cn/com/qmth/examcloud/core/reports/api/provider/StudentCountCloudServiceProvider.java

@@ -38,6 +38,9 @@ public class StudentCountCloudServiceProvider extends ControllerSupport implemen
 		if(req.getOrgId()==null) {
 			throw new StatusException("1000002", "orgId不能为空");
 		}
+		if(req.getBatchTime()==null) {
+			throw new StatusException("1000003", "batchTime不能为空");
+		}
 		studentCountService.addOrUpdateCount(req);
 		return new AddOrUpdateStudentCountResp();
 	}

+ 3 - 0
examcloud-core-reports-api-provider/src/main/java/cn/com/qmth/examcloud/core/reports/api/provider/UserCountCloudServiceProvider.java

@@ -37,6 +37,9 @@ public class UserCountCloudServiceProvider extends ControllerSupport implements
 		if(req.getOrgId()==null) {
 			throw new StatusException("1000002", "orgId不能为空");
 		}
+		if(req.getBatchTime()==null) {
+			throw new StatusException("1000003", "batchTime不能为空");
+		}
 		userCountService.addOrUpdateCount(req);
 		return new AddOrUpdateUserCountResp();
 	}

+ 11 - 1
examcloud-core-reports-dao/src/main/java/cn/com/qmth/examcloud/core/reports/dao/entity/ExamStudentCountEntity.java

@@ -13,7 +13,8 @@ import cn.com.qmth.examcloud.core.reports.dao.entity.share.IdEntity;
 		@Index(name = "IDX_R_EXAM_STUDENT_COUNT_01", columnList = "rootOrgId,orgId,examId", unique = true),
 		@Index(name = "IDX_R_EXAM_STUDENT_COUNT_02", columnList = "rootOrgId", unique = false),
 		@Index(name = "IDX_R_EXAM_STUDENT_COUNT_03", columnList = "orgId", unique = false),
-		@Index(name = "IDX_R_EXAM_STUDENT_COUNT_04", columnList = "examId", unique = false)})
+		@Index(name = "IDX_R_EXAM_STUDENT_COUNT_04", columnList = "examId", unique = false),
+		@Index(name = "IDX_R_EXAM_STUDENT_COUNT_05", columnList = "batchTime", unique = false)})
 public class ExamStudentCountEntity extends IdEntity {
 
 
@@ -22,6 +23,8 @@ public class ExamStudentCountEntity extends IdEntity {
 	 */
 	private static final long serialVersionUID = 8818247713349613850L;
 	@NotNull
+    private Long batchTime;
+	@NotNull
     private Long rootOrgId;
     @NotNull
     private Long orgId;
@@ -59,4 +62,11 @@ public class ExamStudentCountEntity extends IdEntity {
 	public void setExamId(Long examId) {
 		this.examId = examId;
 	}
+	public Long getBatchTime() {
+		return batchTime;
+	}
+	public void setBatchTime(Long batchTime) {
+		this.batchTime = batchTime;
+	}
+	
 }

+ 10 - 1
examcloud-core-reports-dao/src/main/java/cn/com/qmth/examcloud/core/reports/dao/entity/StudentCountEntity.java

@@ -10,7 +10,8 @@ import cn.com.qmth.examcloud.core.reports.dao.entity.share.IdEntity;
 
 @Entity
 @Table(name = "ec_r_student_count",indexes = {
-		@Index(name = "IDX_R_STUDENT_COUNT_01", columnList = "rootOrgId,orgId", unique = true)})
+		@Index(name = "IDX_R_STUDENT_COUNT_01", columnList = "rootOrgId,orgId", unique = true),
+		@Index(name = "IDX_R_STUDENT_COUNT_02", columnList = "batchTime", unique = false)})
 public class StudentCountEntity extends IdEntity {
 
     /**
@@ -18,6 +19,8 @@ public class StudentCountEntity extends IdEntity {
 	 */
 	private static final long serialVersionUID = 6732497600896224190L;
 	@NotNull
+    private Long batchTime;
+	@NotNull
     private Long rootOrgId;
     @NotNull
     private Long orgId;
@@ -47,5 +50,11 @@ public class StudentCountEntity extends IdEntity {
 	public void setOnlineCount(Integer onlineCount) {
 		this.onlineCount = onlineCount;
 	}
+	public Long getBatchTime() {
+		return batchTime;
+	}
+	public void setBatchTime(Long batchTime) {
+		this.batchTime = batchTime;
+	}
     
 }

+ 10 - 3
examcloud-core-reports-dao/src/main/java/cn/com/qmth/examcloud/core/reports/dao/entity/UserCountEntity.java

@@ -10,7 +10,8 @@ import cn.com.qmth.examcloud.core.reports.dao.entity.share.IdEntity;
 
 @Entity
 @Table(name = "ec_r_user_count",indexes = {
-		@Index(name = "IDX_R_USER_COUNT_01", columnList = "rootOrgId,orgId", unique = true)})
+		@Index(name = "IDX_R_USER_COUNT_01", columnList = "rootOrgId,orgId", unique = true),
+		@Index(name = "IDX_R_USER_COUNT_02", columnList = "batchTime", unique = false)})
 public class UserCountEntity extends IdEntity {
 
 
@@ -19,8 +20,8 @@ public class UserCountEntity extends IdEntity {
 	 * 
 	 */
 	private static final long serialVersionUID = -6420107706111319346L;
-
-
+	@NotNull
+    private Long batchTime;
     @NotNull
     private Long rootOrgId;
     @NotNull
@@ -51,5 +52,11 @@ public class UserCountEntity extends IdEntity {
 	public void setOnlineCount(Integer onlineCount) {
 		this.onlineCount = onlineCount;
 	}
+	public Long getBatchTime() {
+		return batchTime;
+	}
+	public void setBatchTime(Long batchTime) {
+		this.batchTime = batchTime;
+	}
     
 }

+ 3 - 1
examcloud-core-reports-service/src/main/java/cn/com/qmth/examcloud/core/reports/service/impl/ExamStudentCountServiceImpl.java

@@ -26,6 +26,7 @@ public class ExamStudentCountServiceImpl implements ExamStudentCountService {
 			e.setOrgId(req.getOrgId());
 			e.setExamId(req.getExamId());
 		}
+		e.setBatchTime(req.getBatchTime());
 		e.setOnlineCount(req.getOnlineCount());
 		examStudentCountRepo.save(e);
 	}
@@ -33,7 +34,8 @@ public class ExamStudentCountServiceImpl implements ExamStudentCountService {
 	@Override
 	public Long getOnlineCount(Long rootOrgId, Long orgId, Long examId) {
 		StringBuffer sb = new StringBuffer();
-		sb.append(" select sum(t.online_count) from ec_r_exam_student_count t where t.root_orgId=").append(rootOrgId);
+		sb.append(" select sum(t.online_count) from ec_r_exam_student_count t where t.root_org_id=").append(rootOrgId);
+		sb.append(" and t.batch_time=(select f.batch_time from ec_r_exam_student_count f order by f.batch_time desc limit 1) ");
 		if (orgId != null) {
 			sb.append(" and t.org_id=").append(orgId);
 		}

+ 3 - 1
examcloud-core-reports-service/src/main/java/cn/com/qmth/examcloud/core/reports/service/impl/StudentCountServiceImpl.java

@@ -24,6 +24,7 @@ public class StudentCountServiceImpl implements StudentCountService {
 			e.setRootOrgId(req.getRootOrgId());
 			e.setOrgId(req.getOrgId());
 		}
+		e.setBatchTime(req.getBatchTime());
 		e.setOnlineCount(req.getOnlineCount());
 		studentCountRepo.save(e);
 	}
@@ -31,7 +32,8 @@ public class StudentCountServiceImpl implements StudentCountService {
 	@Override
 	public Long getOnlineCount(Long rootOrgId, Long orgId) {
 		StringBuffer sb = new StringBuffer();
-		sb.append(" select sum(t.online_count) from ec_r_student_count t where t.root_orgId=").append(rootOrgId);
+		sb.append(" select sum(t.online_count) from ec_r_student_count t where t.root_org_id=").append(rootOrgId);
+		sb.append(" and t.batch_time=(select f.batch_time from ec_r_student_count f order by f.batch_time desc limit 1) ");
 		if (orgId != null) {
 			sb.append(" and t.org_id=").append(orgId);
 		}

+ 3 - 1
examcloud-core-reports-service/src/main/java/cn/com/qmth/examcloud/core/reports/service/impl/UserCountServiceImpl.java

@@ -23,6 +23,7 @@ public class UserCountServiceImpl implements UserCountService {
 			e.setRootOrgId(req.getRootOrgId());
 			e.setOrgId(req.getOrgId());
 		}
+		e.setBatchTime(req.getBatchTime());
 		e.setOnlineCount(req.getOnlineCount());
 		userCountRepo.save(e);
 	}
@@ -30,7 +31,8 @@ public class UserCountServiceImpl implements UserCountService {
 	@Override
 	public Long getOnlineCount(Long rootOrgId, Long orgId) {
 		StringBuffer sb=new StringBuffer();
-		sb.append(" select sum(t.online_count) from ec_r_user_count t where t.root_orgId=").append(rootOrgId);
+		sb.append(" select sum(t.online_count) from ec_r_user_count t where t.root_org_id=").append(rootOrgId);
+		sb.append(" and t.batch_time=(select f.batch_time from ec_r_user_count f order by f.batch_time desc limit 1) ");
 		if(orgId!=null) {
 			sb.append(" and t.org_id=").append(orgId);
 		}