|
@@ -24,7 +24,9 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.ServletOutputStream;
|
|
@@ -52,19 +54,25 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
private TPRequirementService tpRequirementService;
|
|
|
|
|
|
@Override
|
|
|
- public List<MatrixDto> listMatrix(Long professionalId) {
|
|
|
+ public List<MatrixDto> getMatrix(Long professionalId) {
|
|
|
List<TPMatrix> tpMatrixList = this.baseMapper.listMatrix(professionalId);
|
|
|
if (CollectionUtils.isNotEmpty(tpMatrixList)) {
|
|
|
List<MatrixDto> matrixDtoList = new ArrayList<>();
|
|
|
- Map<Long, List<TPMatrix>> courseMap = tpMatrixList.stream().collect(Collectors.groupingBy(TPMatrix::getCourseId));
|
|
|
- courseMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(entry -> {
|
|
|
+ LinkedMultiValueMap<Long, TPMatrix> courseMap = new LinkedMultiValueMap<>();
|
|
|
+ for (TPMatrix tpMatrix : tpMatrixList) {
|
|
|
+ courseMap.add(tpMatrix.getCourseId(), tpMatrix);
|
|
|
+ }
|
|
|
+ courseMap.entrySet().stream().forEach(entry -> {
|
|
|
TPCourse tpCourse = tpCourseService.getById(entry.getKey());
|
|
|
MatrixDto matrixDto = new MatrixDto();
|
|
|
matrixDto.setCourseCode(tpCourse.getCourseCode());
|
|
|
matrixDto.setCourseName(tpCourse.getCourseName());
|
|
|
List<MatrixRequirementDto> matrixRequirementDtoList = new ArrayList<>();
|
|
|
- Map<Long, List<TPMatrix>> requirementMap = entry.getValue().stream().collect(Collectors.groupingBy(TPMatrix::getRequirementId));
|
|
|
- requirementMap.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(requirementEntry -> {
|
|
|
+ LinkedMultiValueMap<Long, TPMatrix> requirementMap = new LinkedMultiValueMap<>();
|
|
|
+ for (TPMatrix tpMatrix : entry.getValue()) {
|
|
|
+ requirementMap.add(tpMatrix.getRequirementId(), tpMatrix);
|
|
|
+ }
|
|
|
+ requirementMap.entrySet().stream().forEach(requirementEntry -> {
|
|
|
TPRequirement tpRequirement = tpRequirementService.getById(requirementEntry.getKey());
|
|
|
MatrixRequirementDto matrixRequirementDto = new MatrixRequirementDto();
|
|
|
matrixRequirementDto.setName(tpRequirement.getName());
|
|
@@ -72,7 +80,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
List<MatrixSubRequirementDto> matrixSubRequirementDtoList = requirementEntry.getValue().stream().map(tpMatrix -> {
|
|
|
MatrixSubRequirementDto matrixSubRequirementDto = new MatrixSubRequirementDto();
|
|
|
matrixSubRequirementDto.setId(tpMatrix.getId());
|
|
|
- matrixSubRequirementDto.setName(tpMatrix.getSubName());
|
|
|
+ matrixSubRequirementDto.setName(StringUtils.isNotBlank(tpMatrix.getSubName()) ? tpMatrix.getRequirementSortNum() + "-" + tpMatrix.getSubName() : tpMatrix.getSubName());
|
|
|
matrixSubRequirementDto.setContent(tpMatrix.getContent());
|
|
|
return matrixSubRequirementDto;
|
|
|
}).collect(Collectors.toList());
|
|
@@ -177,7 +185,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
|
|
|
tpMatrix.setCourseId(tpCourse.getId());
|
|
|
tpMatrix.setRequirementId(tpRequirement.getId());
|
|
|
- tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
|
|
|
+ tpMatrix.setSubName(String.valueOf(i));
|
|
|
tpMatrixAddList.add(tpMatrix);
|
|
|
}
|
|
|
}
|
|
@@ -205,7 +213,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
|
|
|
tpMatrix.setCourseId(tpCourse.getId());
|
|
|
tpMatrix.setRequirementId(tpRequirement.getId());
|
|
|
- tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
|
|
|
+ tpMatrix.setSubName(String.valueOf(i));
|
|
|
tpMatrixAddList.add(tpMatrix);
|
|
|
}
|
|
|
} else {
|
|
@@ -216,7 +224,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
|
|
|
tpMatrix.setCourseId(tpCourse.getId());
|
|
|
tpMatrix.setRequirementId(tpRequirement.getId());
|
|
|
- tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
|
|
|
+ tpMatrix.setSubName(String.valueOf(i));
|
|
|
tpMatrixAddList.add(tpMatrix);
|
|
|
}
|
|
|
} else if (tpRequirement.getNodeCount() < matrixList.size()) {
|
|
@@ -233,7 +241,7 @@ public class TPMatrixServiceImpl extends ServiceImpl<TPMatrixMapper, TPMatrix> i
|
|
|
tpMatrix.setProfessionalId(tpRequirement.getProfessionalId());
|
|
|
tpMatrix.setCourseId(tpCourse.getId());
|
|
|
tpMatrix.setRequirementId(tpRequirement.getId());
|
|
|
- tpMatrix.setSubName(tpRequirement.getSortNum() + "-" + i);
|
|
|
+ tpMatrix.setSubName(String.valueOf(i));
|
|
|
tpMatrixAddList.add(tpMatrix);
|
|
|
}
|
|
|
} else if (tpRequirement.getNodeCount() < matrixList.size()) {
|