|
@@ -37,29 +37,35 @@ import com.xjrsoft.module.organization.service.IUserService;
|
|
|
import com.xjrsoft.module.organization.service.IWeChatService;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionMobilePageDto;
|
|
|
import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionPageDto;
|
|
|
+import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
|
|
|
import com.xjrsoft.module.student.dto.CalssQuantitativeAssessmentPageDto;
|
|
|
+import com.xjrsoft.module.student.dto.ImportBaseStudentAssessmentInspectionDto;
|
|
|
import com.xjrsoft.module.student.dto.QuantitativeAssessmentExcelDto;
|
|
|
import com.xjrsoft.module.student.dto.QuantitativeAssessmentSingleScoreDto;
|
|
|
import com.xjrsoft.module.student.entity.BaseClassMajorSet;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentCategory;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentClassRelation;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentInspection;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentAssessmentItem;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentProject;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentCategoryMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentClassRelationMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentInspectionMapper;
|
|
|
+import com.xjrsoft.module.student.mapper.BaseStudentAssessmentItemMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentProjectMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentAssessmentStudentRelationMapper;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
|
|
|
import com.xjrsoft.module.student.service.IBaseStudentAssessmentInspectionService;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentService;
|
|
|
import com.xjrsoft.module.student.service.IQuotaFormulaRuleService;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentAssessmentClassListVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionMobilePageVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionMobileVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionPageVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionVo;
|
|
|
+import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
|
|
|
import com.xjrsoft.module.student.vo.CalssQuantitativeAssessmentPageVo;
|
|
|
import com.xjrsoft.module.student.vo.QuantitativeAssessmentSingleScoreVo;
|
|
|
import com.xjrsoft.module.student.vo.QuantitativeAssessmentSubTableExcelVo;
|
|
@@ -93,11 +99,15 @@ import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -137,6 +147,10 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
|
|
|
|
|
|
private final CommonPropertiesConfig commonPropertiesConfig;
|
|
|
|
|
|
+ private final IBaseStudentService studentService;
|
|
|
+
|
|
|
+ private final BaseStudentAssessmentItemMapper itemMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<BaseStudentAssessmentInspectionPageVo> getPage(Page<BaseStudentAssessmentInspectionPageDto> page, BaseStudentAssessmentInspectionPageDto dto) {
|
|
|
Page<BaseStudentAssessmentInspectionPageVo> result = assessmentInspectionMapper.getPage(page, dto);
|
|
@@ -963,6 +977,146 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
|
|
|
return bot.toByteArray();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean importData(List<ImportBaseStudentAssessmentInspectionDto> savedDataList) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ Set<String> classNames = savedDataList.stream().map(ImportBaseStudentAssessmentInspectionDto::getClassName).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ Set<String> categorys = savedDataList.stream().map(ImportBaseStudentAssessmentInspectionDto::getAssessmentCategory).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ Set<String> projects = savedDataList.stream().map(ImportBaseStudentAssessmentInspectionDto::getAssessmentProject).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ Set<String> items = savedDataList.stream().map(ImportBaseStudentAssessmentInspectionDto::getAssessmentItem).collect(Collectors.toSet());
|
|
|
+
|
|
|
+
|
|
|
+ Set<String> credentialNumbers = savedDataList.stream().map(ImportBaseStudentAssessmentInspectionDto::getCredentialNumber).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ List<BaseClass> classList = baseClassMapper.selectList(
|
|
|
+ new QueryWrapper<BaseClass>().lambda()
|
|
|
+ .in(BaseClass::getName, classNames)
|
|
|
+ );
|
|
|
+ Map<String, Long> classMap = classList.stream().collect(Collectors.toMap(BaseClass::getName, BaseClass::getId));
|
|
|
+ Set<String> checkClassNames = new HashSet<>(classNames);
|
|
|
+ checkClassNames.removeAll(classMap.keySet());
|
|
|
+ if(!checkClassNames.isEmpty()){
|
|
|
+ throw new MyException("导入表格中的班级:" + checkClassNames.toString() + " 在系统中不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<BaseStudentAssessmentProject> projectList = projectMapper.selectList(
|
|
|
+ new QueryWrapper<BaseStudentAssessmentProject>().lambda()
|
|
|
+ .eq(BaseStudentAssessmentProject::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(BaseStudentAssessmentProject::getEnabledMark, EnabledMark.ENABLED.getCode())
|
|
|
+ );
|
|
|
+ Map<Long, Map<String, Long>> projectMap = projectList.stream().collect(
|
|
|
+ Collectors.groupingBy(
|
|
|
+ BaseStudentAssessmentProject::getBaseStudentAssessmentCategoryId,
|
|
|
+ Collectors.toMap(BaseStudentAssessmentProject::getName, BaseStudentAssessmentProject::getId)
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ Map<String, Long> categoryMap = categoryMapper.selectList(
|
|
|
+ new QueryWrapper<BaseStudentAssessmentCategory>().lambda()
|
|
|
+ .eq(BaseStudentAssessmentCategory::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(BaseStudentAssessmentCategory::getEnabledMark, EnabledMark.ENABLED.getCode())
|
|
|
+ )
|
|
|
+ .stream().collect(Collectors.toMap(BaseStudentAssessmentCategory::getName, BaseStudentAssessmentCategory::getId));
|
|
|
+
|
|
|
+ Set<String> checkCategorys = new HashSet<>(categorys);
|
|
|
+ checkCategorys.removeAll(categoryMap.keySet());
|
|
|
+ if(!checkCategorys.isEmpty()){
|
|
|
+ throw new MyException("导入表格中的考核类别:" + checkCategorys.toString() + " 在系统中不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<BaseStudentAssessmentItem> itemList = itemMapper.selectList(
|
|
|
+ new QueryWrapper<BaseStudentAssessmentItem>().lambda()
|
|
|
+ .eq(BaseStudentAssessmentItem::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(BaseStudentAssessmentItem::getEnabledMark, EnabledMark.ENABLED.getCode())
|
|
|
+ );
|
|
|
+ Map<Long, Map<String, Long>> itemMap = itemList.stream().collect(
|
|
|
+ Collectors.groupingBy(
|
|
|
+ BaseStudentAssessmentItem::getBaseStudentAssessmentCategoryId,
|
|
|
+ Collectors.toMap(BaseStudentAssessmentItem::getName, BaseStudentAssessmentItem::getId)
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ List<BaseStudentUserPageVo> studentList = studentService.getStudentList(new BaseStudentUserPageDto() {{
|
|
|
+ setCredentialNumbers(new ArrayList<>(credentialNumbers));
|
|
|
+ }});
|
|
|
+ Map<String, String> studentMap = studentList.stream().collect(Collectors.toMap(BaseStudentUserPageVo::getCredentialNumber, BaseStudentUserPageVo::getId));
|
|
|
+
|
|
|
+ Set<String> checkStudents = new HashSet<>();
|
|
|
+ Set<String> checkProjects = new HashSet<>();
|
|
|
+ Set<String> checkItems = new HashSet<>();
|
|
|
+
|
|
|
+ List<BaseStudentAssessmentInspection> insertList = new ArrayList<>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+ for (ImportBaseStudentAssessmentInspectionDto dto : savedDataList) {
|
|
|
+
|
|
|
+ BaseStudentAssessmentInspection data = new BaseStudentAssessmentInspection();
|
|
|
+
|
|
|
+ data.setEnabledMark(EnabledMark.ENABLED.getCode());
|
|
|
+ data.setDeleteMark(DeleteMark.NODELETE.getCode());
|
|
|
+ data.setCreateDate(new Date());
|
|
|
+ data.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ if("班级".equals(dto.getAssessmentType())){
|
|
|
+ data.setAssessmentType("class");
|
|
|
+ }else if("个人".equals(dto.getAssessmentType())){
|
|
|
+ data.setAssessmentType("personal");
|
|
|
+ if(!studentMap.containsKey(dto.getCredentialNumber())){
|
|
|
+ checkStudents.add(dto.getStudentName());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ data.setPersonalStudentUserIds(studentMap.get(dto.getCredentialNumber()));
|
|
|
+ }
|
|
|
+ data.setClassIds(classMap.get(dto.getClassName()).toString());
|
|
|
+ data.setBaseStudentAssessmentCategoryId(categoryMap.get(dto.getAssessmentCategory()));
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Long> itemGroup = itemMap.get(data.getBaseStudentAssessmentCategoryId());
|
|
|
+ if(itemGroup == null || !itemGroup.containsKey(dto.getAssessmentItem())){
|
|
|
+ checkItems.add("考核类别“" + dto.getAssessmentCategory() + "”中不存在考核项“" + dto.getAssessmentItem() + "”" ) ;
|
|
|
+ }
|
|
|
+ data.setBaseStudentAssessmentItemId(itemGroup.get(dto.getAssessmentItem()));
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Long> projectGroup = projectMap.get(data.getBaseStudentAssessmentItemId());
|
|
|
+ if(projectGroup == null || !projectGroup.containsKey(dto.getAssessmentProject())){
|
|
|
+ checkProjects.add("考核项目“" + dto.getAssessmentItem() + "”中不存在考核项“" + dto.getAssessmentProject() + "”" ) ;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ data.setBaseStudentAssessmentProjectId(projectGroup.get(dto.getAssessmentProject()));
|
|
|
+
|
|
|
+ data.setReason(dto.getReason());
|
|
|
+ data.setAssessmentUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ data.setAssessmentDate(sdf.parse(dto.getAssessmentDate()));
|
|
|
+
|
|
|
+ insertList.add(data);
|
|
|
+ }
|
|
|
+ if(!checkStudents.isEmpty()){
|
|
|
+ throw new MyException("导入表格中的学生:" + checkStudents.toString() + " 在系统中不存在");
|
|
|
+ }
|
|
|
+ if(!checkProjects.isEmpty()){
|
|
|
+ throw new MyException(checkProjects.toString().replace("[", "").replace("]", ""));
|
|
|
+ }
|
|
|
+ if(!checkItems.isEmpty()){
|
|
|
+ throw new MyException(checkItems.toString().replace("[", "").replace("]", ""));
|
|
|
+ }
|
|
|
+ if(!insertList.isEmpty()){
|
|
|
+ this.saveBatch(insertList);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ Log.error(e.getMessage(), e);
|
|
|
+ if(e.getClass().equals(MyException.class)){
|
|
|
+ throw new MyException(e.getMessage());
|
|
|
+ }else{
|
|
|
+ throw new MyException("导入报错,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
void createFirstTitle(Workbook workbook, Sheet sheet) {
|
|
|
int rowNumber = 0;
|
|
|
Font font = workbook.createFont();
|