Browse Source

批量保存课程数值接口

xiatian 6 years ago
parent
commit
a1e9698aef

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

@@ -0,0 +1,42 @@
+package cn.com.qmth.examcloud.core.reports.api.provider;
+
+import org.examcloud.core.reports.api.CourseDataReportCloudService;
+import org.examcloud.core.reports.api.request.SaveCourseDataReportListReq;
+import org.examcloud.core.reports.api.response.SaveCourseDataReportListResp;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.reports.service.CourseDataReportService;
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@RestController
+@Api(tags = "课程数值接口")
+@RequestMapping("${$rmp.cloud.reports}"+"courseDataReport")
+public class CourseDataReportCloudServiceProvider extends ControllerSupport implements CourseDataReportCloudService {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -2138703572207468208L;
+	
+	@Autowired
+	private CourseDataReportService courseDataReportService;
+
+	@ApiOperation(value = "批量保存")
+    @PostMapping("/saveList")
+	@Override
+	public SaveCourseDataReportListResp saveCourseDataReportList(@RequestBody SaveCourseDataReportListReq req) {
+		if(req.getBeans()==null||req.getBeans().size()==0) {
+			throw new StatusException("1000001", "数据为空");
+		}
+		courseDataReportService.saveCourseDataReportList(req.getBeans());
+		return new SaveCourseDataReportListResp();
+	}
+
+}

+ 10 - 0
examcloud-core-reports-dao/src/main/java/cn/com/qmth/examcloud/core/reports/dao/CourseDataReportRepo.java

@@ -0,0 +1,10 @@
+package cn.com.qmth.examcloud.core.reports.dao;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+import cn.com.qmth.examcloud.core.reports.dao.entity.CourseDataReportEntity;
+
+public interface CourseDataReportRepo extends JpaRepository<CourseDataReportEntity, Long>,
+		JpaSpecificationExecutor<CourseDataReportEntity> {
+}

+ 89 - 45
examcloud-core-reports-dao/src/main/java/cn/com/qmth/examcloud/core/reports/dao/entity/CourseDataReportEntity.java

@@ -20,38 +20,52 @@ public class CourseDataReportEntity extends IdEntity {
 	/**
 	 * 
 	 */
-	private static final long serialVersionUID = 8626023407766283369L;
-
+	private static final long serialVersionUID = 2036489171078448842L;
 	//项目id
 	@NotNull
     private Long projectId;
 	//rootOrgId
     @NotNull
     private Long rootOrgId;
-    //考试id
+    //课程id
+    @NotNull
+    private Long courseId;
+    //课程名称
+    @NotNull
+    private String courseName;
+    //课程code
+    @NotNull
+    private String courseCode;
+    //满分
     @NotNull
-    private Long examId;
-    //考试名称
+    private Double totalScore;
+    //最高分
     @NotNull
-    private String examName;
-    //考试code
+    private Double maxScore;
+    //最低分
     @NotNull
-    private String examCode;
-    //中心id
+    private Double minScore;
+    //平均分
     @NotNull
-    private Long orgId;
-    //中心名称
+    private Double avgScore;
+    //标准差
     @NotNull
-    private String orgName;
-    //中心code
+    private Double std;
+    //平均调卷难度
     @NotNull
-    private String orgCode;
-    //报名人
+    private Double avgDifficultyDegree;
+    //差异系
     @NotNull
-    private Long signCount;
-    //考人数
+    private Double cdi;
+    //考人数
     @NotNull
     private Long participantCount;
+    //满分人数
+    @NotNull
+    private Long fullCount;
+    //零分人数
+    @NotNull
+    private Long zeroCount;
     //及格人数
     @NotNull
     private Long passCount;
@@ -70,47 +84,65 @@ public class CourseDataReportEntity extends IdEntity {
 	public void setRootOrgId(Long rootOrgId) {
 		this.rootOrgId = rootOrgId;
 	}
-	public Long getExamId() {
-		return examId;
+	public Long getCourseId() {
+		return courseId;
+	}
+	public void setCourseId(Long courseId) {
+		this.courseId = courseId;
+	}
+	public String getCourseName() {
+		return courseName;
 	}
-	public void setExamId(Long examId) {
-		this.examId = examId;
+	public void setCourseName(String courseName) {
+		this.courseName = courseName;
 	}
-	public String getExamName() {
-		return examName;
+	public String getCourseCode() {
+		return courseCode;
 	}
-	public void setExamName(String examName) {
-		this.examName = examName;
+	public void setCourseCode(String courseCode) {
+		this.courseCode = courseCode;
 	}
-	public String getExamCode() {
-		return examCode;
+	public Double getTotalScore() {
+		return totalScore;
 	}
-	public void setExamCode(String examCode) {
-		this.examCode = examCode;
+	public void setTotalScore(Double totalScore) {
+		this.totalScore = totalScore;
 	}
-	public Long getOrgId() {
-		return orgId;
+	public Double getMaxScore() {
+		return maxScore;
 	}
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
+	public void setMaxScore(Double maxScore) {
+		this.maxScore = maxScore;
 	}
-	public String getOrgName() {
-		return orgName;
+	public Double getMinScore() {
+		return minScore;
 	}
-	public void setOrgName(String orgName) {
-		this.orgName = orgName;
+	public void setMinScore(Double minScore) {
+		this.minScore = minScore;
 	}
-	public String getOrgCode() {
-		return orgCode;
+	public Double getAvgScore() {
+		return avgScore;
 	}
-	public void setOrgCode(String orgCode) {
-		this.orgCode = orgCode;
+	public void setAvgScore(Double avgScore) {
+		this.avgScore = avgScore;
 	}
-	public Long getSignCount() {
-		return signCount;
+	public Double getStd() {
+		return std;
 	}
-	public void setSignCount(Long signCount) {
-		this.signCount = signCount;
+	public void setStd(Double std) {
+		this.std = std;
+	}
+	public Double getAvgDifficultyDegree() {
+		return avgDifficultyDegree;
+	}
+	public void setAvgDifficultyDegree(Double avgDifficultyDegree) {
+		this.avgDifficultyDegree = avgDifficultyDegree;
+	}
+	public Double getCdi() {
+		return cdi;
+	}
+	public void setCdi(Double cdi) {
+		this.cdi = cdi;
 	}
 	public Long getParticipantCount() {
 		return participantCount;
@@ -118,6 +150,18 @@ public class CourseDataReportEntity extends IdEntity {
 	public void setParticipantCount(Long participantCount) {
 		this.participantCount = participantCount;
 	}
+	public Long getFullCount() {
+		return fullCount;
+	}
+	public void setFullCount(Long fullCount) {
+		this.fullCount = fullCount;
+	}
+	public Long getZeroCount() {
+		return zeroCount;
+	}
+	public void setZeroCount(Long zeroCount) {
+		this.zeroCount = zeroCount;
+	}
 	public Long getPassCount() {
 		return passCount;
 	}

+ 10 - 0
examcloud-core-reports-service/src/main/java/cn/com/qmth/examcloud/core/reports/service/CourseDataReportService.java

@@ -0,0 +1,10 @@
+package cn.com.qmth.examcloud.core.reports.service;
+
+import java.util.List;
+
+import org.examcloud.core.reports.api.bean.CourseDataReportBean;
+
+public interface CourseDataReportService {
+
+	public void saveCourseDataReportList(List<CourseDataReportBean> beans);
+}

+ 36 - 0
examcloud-core-reports-service/src/main/java/cn/com/qmth/examcloud/core/reports/service/impl/CourseDataReportServiceImpl.java

@@ -0,0 +1,36 @@
+package cn.com.qmth.examcloud.core.reports.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.examcloud.core.reports.api.bean.CourseDataReportBean;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import cn.com.qmth.examcloud.core.reports.dao.CourseDataReportRepo;
+import cn.com.qmth.examcloud.core.reports.dao.entity.CourseDataReportEntity;
+import cn.com.qmth.examcloud.core.reports.service.CourseDataReportService;
+
+@Service
+public class CourseDataReportServiceImpl implements CourseDataReportService {
+	@Autowired
+	private CourseDataReportRepo courseDataReportRepo;
+
+	@Transactional
+	@Override
+	public void saveCourseDataReportList(List<CourseDataReportBean> beans) {
+		List<CourseDataReportEntity> list=new ArrayList<CourseDataReportEntity>();
+		for(CourseDataReportBean bean:beans) {
+			CourseDataReportEntity e=new CourseDataReportEntity();
+			BeanUtils.copyProperties(bean, e);
+			e.setPartitionData(StringUtils.join(bean.getPartitionData().toArray(), ","));
+			list.add(e);
+		}
+		courseDataReportRepo.saveAll(list);
+	}
+
+
+}