Browse Source

考试记录增加查询页面

zhongwei
ty 10 months ago
parent
commit
146f751f1a
  1. 8
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestDTO.java
  2. 1
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java
  3. 12
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestScoreEntity.java
  4. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java
  5. 9
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java
  6. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestScoreService.java
  7. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestService.java
  8. 37
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
  9. 42
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java

8
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestDTO.java

@ -1,20 +1,26 @@
package com.hnac.hzims.safeproduct.dto;
import com.hnac.hzims.safeproduct.entity.TestEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Size;
/**
* @author liwen
* @date 2023-12-25
*/
@Data
@ApiModel(value = "考试记录DTO类")
public class TestDTO {
public class TestDTO extends TestEntity {
@ApiModelProperty("考试记录id")
private Long id;
@ApiModelProperty("考试记录名称")
private String testName;
@ApiModelProperty("参考人员Id,以,分隔")
private String peopleId;
}

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

@ -67,6 +67,7 @@ public class TestEntity extends BaseEntity {
@ApiModelProperty("参考人员")
private String peopleName;
@Size(max = 1000, message = "考试图片字段长度不能超过1000")
@ApiModelProperty("考试图片")
private String imgPath;

12
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestScoreEntity.java

@ -29,6 +29,18 @@ public class TestScoreEntity extends BaseEntity {
@ApiModelProperty("姓名")
private String name;
@Size(max = 50, message = "姓名字段长度不能超过50")
@ApiModelProperty("姓名")
private String userId;
@Size(max = 50, message = "姓名字段长度不能超过50")
@ApiModelProperty("机构名称")
private String deptName;
@Size(max = 50, message = "姓名字段长度不能超过50")
@ApiModelProperty("机构Id")
private String deptId;
@NotNull
@Min(value = 0, message = "成绩必须大于等于0")
@Max(value = 100, message = "成绩必须小于等于100")

3
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java

@ -24,6 +24,9 @@ public class TestScoreVO {
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("姓名")
private String userId;
@ApiModelProperty("成绩")
private Integer score;
}

9
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java

@ -6,6 +6,7 @@ import com.hnac.hzims.safeproduct.dto.TestDTO;
import com.hnac.hzims.safeproduct.dto.TestScoreDTO;
import com.hnac.hzims.safeproduct.dto.TrainRecordDTO;
import com.hnac.hzims.safeproduct.entity.TestEntity;
import com.hnac.hzims.safeproduct.entity.TestScoreEntity;
import com.hnac.hzims.safeproduct.entity.TrainPlanEntity;
import com.hnac.hzims.safeproduct.entity.TrainRecordEntity;
import com.hnac.hzims.safeproduct.service.ITestScoreService;
@ -142,14 +143,14 @@ public class TrainController extends BladeController {
@PostMapping("/saveTest")
@ApiOperation(value = "新增考试")
@ApiOperationSupport(order = 12)
public R saveTest(@Valid @RequestBody TestEntity testEntity) {
public R saveTest(@Valid @RequestBody TestDTO testEntity) {
return testService.saveTest(testEntity);
}
@PostMapping("/updateTest")
@ApiOperation(value = "修改考试")
@ApiOperationSupport(order = 13)
public R updateTest(@Valid @RequestBody TestEntity testEntity) {
public R updateTest(@Valid @RequestBody TestDTO testEntity) {
return R.status(testService.updateTest(testEntity));
}
@ -192,8 +193,8 @@ public class TrainController extends BladeController {
@GetMapping("/testScoreList")
@ApiOperation(value = "考试成绩列表")
@ApiOperationSupport(order = 18)
public R<List<TestScoreVO>> testScoreList(@RequestParam Long testId, String name) {
List<TestScoreVO> list = testScoreService.testScoreList(testId, name);
public R<List<TestScoreEntity>> testScoreList(@RequestParam Long testId, String name) {
List<TestScoreEntity> list = testScoreService.testScoreList(testId, name);
return R.data(list);
}
@GetMapping("/testScoreSum")

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestScoreService.java

@ -22,7 +22,7 @@ public interface ITestScoreService extends IService<TestScoreEntity> {
* @param name 姓名
* @return 考试成绩列表
*/
List<TestScoreVO> testScoreList(Long testId, String name);
List<TestScoreEntity> testScoreList(Long testId, String name);
/**
* 批量填写分数

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestService.java

@ -23,7 +23,7 @@ public interface ITestService extends IService<TestEntity> {
* @param testEntity 考试记录实体类
* @return 返回结果封装类
*/
R saveTest(TestEntity testEntity);
R saveTest(TestDTO testEntity);
/**
* 根据编码查询考试记录
@ -65,7 +65,7 @@ public interface ITestService extends IService<TestEntity> {
* @param testEntity 考试记录实体类
* @return true-成功false-失败
*/
boolean updateTest(TestEntity testEntity);
boolean updateTest(TestDTO testEntity);
/**
* 考试记录分页

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

@ -1,6 +1,7 @@
package com.hnac.hzims.safeproduct.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.dto.TestScoreDTO;
import com.hnac.hzims.safeproduct.entity.TestEntity;
@ -10,8 +11,14 @@ import com.hnac.hzims.safeproduct.mapper.TestScoreMapper;
import com.hnac.hzims.safeproduct.service.ITestScoreService;
import com.hnac.hzims.safeproduct.vo.TestScoreSumVO;
import com.hnac.hzims.safeproduct.vo.TestScoreVO;
import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -27,15 +34,19 @@ import java.util.stream.Collectors;
* @date 2023-12-25
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScoreEntity> implements ITestScoreService {
private final ISysClient sysClient;
@Resource
TestMapper testMapper;
/**
* 查询考试成绩列表
*/
@Override
public List<TestScoreVO> testScoreList(Long testId, String name) {
return baseMapper.testScoreList(testId, name);
public List<TestScoreEntity> testScoreList(Long testId, String name) {
return baseMapper.selectList(Wrappers.<TestScoreEntity>lambdaQuery().eq(TestScoreEntity::getTestId, testId));
}
/**
@ -43,15 +54,27 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
*/
@Override
public boolean updateBatchScore(TestScoreDTO testScoreDTO) {
boolean b = this.removeRelativeTestScore(testScoreDTO.getTestId());
if (b) {
List<TestScoreVO> scoreList = testScoreDTO.getScoreList();
List<TestScoreEntity> testScoreEntities = new ArrayList<>();
scoreList.forEach(score -> {
TestScoreEntity testScoreEntity = new TestScoreEntity();
BeanUtils.copyProperties(score, testScoreEntity);
testScoreEntity.setTestId(testScoreDTO.getTestId());
if (!"^".equals(score.getUserId())&&ObjectUtil.isNotEmpty(score.getDept())) {
R<String> deptNameR = sysClient.getDeptName(score.getDept());
if (deptNameR.isSuccess()&&StringUtils.isNotBlank(deptNameR.getData())){
testScoreEntity.setDeptName(deptNameR.getData());
}
}else {
testScoreEntity.setUserId("");
}
testScoreEntities.add(testScoreEntity);
});
return this.updateBatchById(testScoreEntities);
return this.saveOrUpdateBatch(testScoreEntities);
}
return false;
}
/**
@ -87,16 +110,16 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
TestScoreSumVO testScoreSumVO = new TestScoreSumVO();
TestEntity testEntity = testMapper.selectById(testId);
String peopleName = testEntity.getPeopleName();
if (StringUtils.isNotBlank(peopleName)){
if (StringUtils.isNotBlank(peopleName)) {
String[] split = peopleName.split(",");
testScoreSumVO.setPeopleNum( split.length);
testScoreSumVO.setPeopleNum(split.length);
}
QueryWrapper<TestScoreEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(TestScoreEntity::getTestId, testId);
List<TestScoreEntity> list = this.list(queryWrapper);
if (CollectionUtils.isNotEmpty(list)){
testScoreSumVO.setPeopleNum( list.size());
if (CollectionUtils.isNotEmpty(list)) {
testScoreSumVO.setPeopleNum(list.size());
List<TestScoreEntity> collect = list.stream().filter(s -> s.getScore() > 60).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
testScoreSumVO.setPercentage(new Double(collect.size() / list.size()));

42
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java

@ -1,6 +1,7 @@
package com.hnac.hzims.safeproduct.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.util.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -16,8 +17,14 @@ import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper;
import com.hnac.hzims.safeproduct.service.ITestScoreService;
import com.hnac.hzims.safeproduct.service.ITestService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -36,8 +43,9 @@ import java.util.stream.Collectors;
* @date 2023-12-25
*/
@Service
@RequiredArgsConstructor
public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> implements ITestService {
private final ISysClient sysClient;
@Autowired
ITestScoreService testScoreService;
@ -49,7 +57,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
*/
@Transactional(rollbackFor = Exception.class)
@Override
public R saveTest(TestEntity testEntity) {
public R saveTest(TestDTO testEntity) {
// 判断培训计划是否需要考试,若不需要,则无法新增考试记录
TrainPlanEntity trainPlanEntity = trainPlanMapper.selectById(testEntity.getTrainPlanId());
if (trainPlanEntity.getIsTest().equals(SafeProductConstant.TRAIN_PLAN_HAS_NO_TEST)) {
@ -69,10 +77,12 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
// 查询考试记录
TestEntity test = getTestByCode(testEntity.getCode());
// 获取姓名数组
String people = test.getPeopleName();
String people = testEntity.getPeopleName();
String peopleId = testEntity.getPeopleId();
String[] person = people.split(",");
String[] peopleIds = peopleId.split(",");
// 新增参考人员成绩数据
List<TestScoreEntity> scoreList = getReferenceTestScore(test, person);
List<TestScoreEntity> scoreList = getReferenceTestScore(test, person,peopleIds);
return R.status(testScoreService.saveBatch(scoreList));
}
return R.fail("新增考试记录失败");
@ -153,7 +163,7 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateTest(TestEntity testEntity) {
public boolean updateTest(TestDTO testEntity) {
// 判断考试人员是否有变化
TestEntity oldTest = getTestByCode(testEntity.getCode());
// 更新考试记录
@ -170,8 +180,9 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
// 若删除成功,新增新的考试成绩数据
if (removeByIds) {
String[] person = testEntity.getPeopleName().split(",");
String[] personId = testEntity.getPeopleId().split(",");
// 新增参考人员成绩数据
List<TestScoreEntity> scoreList = getReferenceTestScore(testEntity, person);
List<TestScoreEntity> scoreList = getReferenceTestScore(testEntity, person,personId);
return testScoreService.saveBatch(scoreList);
}
}
@ -193,12 +204,25 @@ public class TestServiceImpl extends ServiceImpl<TestMapper, TestEntity> impleme
* @param person 参考人员
* @return 成绩列表
*/
private List<TestScoreEntity> getReferenceTestScore(TestEntity testEntity, String[] person) {
private List<TestScoreEntity> getReferenceTestScore(TestEntity testEntity, String[] person,String[] personId) {
List<TestScoreEntity> res = new ArrayList<>();
for (String name : person) {
for (int i = 0; i < person.length; i++) {
TestScoreEntity testScoreEntity = new TestScoreEntity();
testScoreEntity.setTestId(testEntity.getId());
testScoreEntity.setName(name);
testScoreEntity.setName(person[i]);
if (!"^".equals(personId[i])) {
testScoreEntity.setUserId(personId[i]);
User user = UserCache.getUser(Long.valueOf(personId[i]));
if (ObjectUtil.isNotEmpty(user)) {
testScoreEntity.setDeptId(user.getDeptId());
R<String> deptNameR = sysClient.getDeptName(Long.valueOf(personId[i]));
if (deptNameR.isSuccess() && StringUtils.isNotBlank(deptNameR.getData())) {
testScoreEntity.setDeptName(deptNameR.getData());
}
}
}else {
testScoreEntity.setUserId("");
}
res.add(testScoreEntity);
}
return res;

Loading…
Cancel
Save