Browse Source

update: 考试记录添加及格分设置

zhongwei
liwen 6 months ago
parent
commit
722e178b65
  1. 9
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java
  2. 8
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java
  3. 5
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
  4. 4
      hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

9
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java

@ -9,6 +9,8 @@ import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
@ -59,6 +61,12 @@ public class TestEntity extends BaseEntity {
private Date testEndTime;
@NotNull
@Min(value = 0, message = "及格分必须大于等于0")
@Max(value = 100, message = "及格分必须小于等于100")
@ApiModelProperty("及格分")
private Integer passingScore;
@NotNull
@Size(max = 255, message = "考试地点字段长度不能超过255")
@ApiModelProperty("考试地点")
private String location;
@ -77,7 +85,6 @@ public class TestEntity extends BaseEntity {
@ApiModelProperty("参考人员")
private String peopleName;
@Size(max = 1000, message = "考试图片字段长度不能超过1000")
@ApiModelProperty("考试图片")
private String imgPath;

8
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java

@ -13,12 +13,14 @@ import lombok.Data;
public class TestScoreSumVO {
@ApiModelProperty("应考人数")
private Integer peopleNum=0;
private Integer peopleNum = 0;
@ApiModelProperty("实考人数")
private Integer actualPeopleNum=0;
private Integer actualPeopleNum = 0;
@ApiModelProperty("及格率")
private Double percentage=0.0;
private Double percentage = 0.0;
@ApiModelProperty("及格分")
private Integer passingScore;
}

5
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java

@ -126,6 +126,7 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
public TestScoreSumVO testScoreSum(Long testId, String name) {
TestScoreSumVO testScoreSumVO = new TestScoreSumVO();
TestEntity testEntity = testMapper.selectById(testId);
testScoreSumVO.setPassingScore(testEntity.getPassingScore());
String peopleName = testEntity.getPeopleName();
if (StringUtils.isNotBlank(peopleName)) {
String[] split = peopleName.split(",");
@ -137,11 +138,11 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
list= list.stream().filter(s -> s.getScore() != null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
testScoreSumVO.setActualPeopleNum(list.size());
List<TestScoreEntity> passCollect = list.stream().filter(s -> s.getScore() > 60).collect(Collectors.toList());
List<TestScoreEntity> passCollect = list.stream().filter(s -> s.getScore() > testEntity.getPassingScore()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) {
double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue();
testScoreSumVO.setPercentage(result);
}else {
} else {
testScoreSumVO.setPercentage(0.0);
}
}

4
hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

@ -41,3 +41,7 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` (
`is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='卫生自查模板详情表';
-- 添加考试及格分字段
ALTER TABLE hzims_test
ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分';
Loading…
Cancel
Save