|
|
@@ -2,9 +2,9 @@ package com.xjrsoft.module.student.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.alibaba.excel.EasyExcel;
|
|
|
-import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
@@ -13,7 +13,6 @@ import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
|
|
|
import com.xjrsoft.module.student.dto.UpdateBaseNewStudentDto;
|
|
|
import com.xjrsoft.module.student.entity.BaseNewStudent;
|
|
|
import com.xjrsoft.module.student.service.IBaseNewStudentService;
|
|
|
-import com.xjrsoft.module.student.vo.BaseNewStudentExcelVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseNewStudentPageVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseNewStudentTreeVo;
|
|
|
import com.xjrsoft.module.student.vo.BaseNewStudentVo;
|
|
|
@@ -22,7 +21,6 @@ import com.xjrsoft.module.student.vo.EnrollmentPlanTreeVo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
@@ -34,10 +32,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -139,40 +136,31 @@ public class BaseNewStudentController {
|
|
|
}
|
|
|
@PostMapping("/import")
|
|
|
@ApiOperation(value = "导入")
|
|
|
- public ResponseEntity<byte[]> importData(@RequestParam Long treeId, @RequestParam MultipartFile file) throws IOException {
|
|
|
+ public RT<List<Map<String, String>>> importData(@RequestParam Long treeId, @RequestParam MultipartFile file) throws IOException {
|
|
|
List<Map<Integer, Object>> errorList = baseNewStudentService.importData(treeId, file);
|
|
|
- List<BaseNewStudentExcelVo> result = new ArrayList<>();
|
|
|
+ List<Map<String, String>> result = new ArrayList<>();
|
|
|
+
|
|
|
for (Map<Integer, Object> objectMap : errorList) {
|
|
|
- result.add(
|
|
|
- new BaseNewStudentExcelVo(){{
|
|
|
- setGraduateSchool(objectMap.get(0).toString());
|
|
|
- setName(objectMap.get(1).toString());
|
|
|
- setGender(objectMap.get(2).toString());
|
|
|
- setCredentialNumber(objectMap.get(3).toString());
|
|
|
- setHeight(BigDecimal.valueOf(Double.parseDouble(objectMap.get(4).toString())));
|
|
|
- setWeight(BigDecimal.valueOf(Double.parseDouble(objectMap.get(5).toString())));
|
|
|
- if(objectMap.get(6) != null){
|
|
|
- setGraduateClass(objectMap.get(6).toString());
|
|
|
- }
|
|
|
- setSource(objectMap.get(7).toString());
|
|
|
- setStduyStatus(objectMap.get(8).toString());
|
|
|
- setMobile(objectMap.get(9).toString());
|
|
|
- setFirstAmbition(objectMap.get(10).toString());
|
|
|
- setSecondAmbition(objectMap.get(11).toString());
|
|
|
- setIsAdjust(objectMap.get(12).toString());
|
|
|
- if(objectMap.get(13) != null){
|
|
|
- setFamilyMobile(objectMap.get(13).toString());
|
|
|
- }
|
|
|
- if(objectMap.get(14) != null){
|
|
|
- setFamilyAddress(objectMap.get(14).toString());
|
|
|
- }
|
|
|
- setErrorMsg(objectMap.get(15).toString());
|
|
|
- }}
|
|
|
- );
|
|
|
+ Map<String, String> object = new HashMap<>();
|
|
|
+ object.put("毕业学校", objectMap.get(0)==null?"":objectMap.get(0).toString());
|
|
|
+ object.put("学生姓名", objectMap.get(1)==null?"":objectMap.get(1).toString());
|
|
|
+ object.put("性别", objectMap.get(2)==null?"":objectMap.get(2).toString());
|
|
|
+ object.put("身份证号", objectMap.get(3)==null?"":objectMap.get(3).toString());
|
|
|
+ object.put("身高(cm)", objectMap.get(4)==null?"":objectMap.get(4).toString());
|
|
|
+ object.put("体重(kg)", objectMap.get(5)==null?"":objectMap.get(5).toString());
|
|
|
+ object.put("毕业班级", objectMap.get(6)==null?"":objectMap.get(6).toString());
|
|
|
+ object.put("学生来源", objectMap.get(7)==null?"":objectMap.get(7).toString());
|
|
|
+ object.put("住宿类型", objectMap.get(8)==null?"":objectMap.get(8).toString());
|
|
|
+ object.put("手机号", objectMap.get(9)==null?"":objectMap.get(9).toString());
|
|
|
+ object.put("第一志愿", objectMap.get(10)==null?"":objectMap.get(10).toString());
|
|
|
+ object.put("第二志愿", objectMap.get(11)==null?"":objectMap.get(11).toString());
|
|
|
+ object.put("是否可调配", objectMap.get(12)==null?"":objectMap.get(12).toString());
|
|
|
+ object.put("家庭电话", objectMap.get(13)==null?"":objectMap.get(13).toString());
|
|
|
+ object.put("家庭地址", objectMap.get(14)==null?"":objectMap.get(14).toString());
|
|
|
+ object.put("错误信息", objectMap.get(15)==null?"":objectMap.get(15).toString());
|
|
|
+ result.add(object);
|
|
|
}
|
|
|
- ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
- EasyExcel.write(bot, BaseNewStudentExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(result);
|
|
|
- return RT.fileStream(bot.toByteArray(), "未导入数据" + ExcelTypeEnum.XLSX.getValue());
|
|
|
+ return RT.ok(result);
|
|
|
}
|
|
|
|
|
|
}
|