优化批量导入功能。

This commit is contained in:
Renpc-kilig 2021-06-08 11:09:52 +08:00
parent c95b02bd5c
commit 94d7387ab1
6 changed files with 50 additions and 19 deletions

View File

@ -120,14 +120,17 @@ public class ApplyStudentsNewAppController extends DefaultBaseController {
@ApiOperation(value = "分页列表", notes = "分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get-grade")
public List<ApplyStudentsNewDTO> getGrade(@RequestHeader("token") String token) {
public SuccessResultList<List<ApplyStudentsNewDTO>> getGrade(@RequestHeader("token") String token, ListPage page) {
Map<String, Object> params = requestParams();
params.put("token", token);
return applyStudentsNewService.getGrade(params);
page.setParams(params);
return applyStudentsNewService.getGrade(page);
}
}

View File

@ -197,8 +197,8 @@ public interface IApplyStudentsNewService {
/**
* 获取考试成绩
* @param params
* @param page
* @return
*/
List<ApplyStudentsNewDTO> getGrade(Map<String, Object> params);
SuccessResultList<List<ApplyStudentsNewDTO>> getGrade(ListPage page);
}

View File

@ -286,7 +286,9 @@ public class ApplyStudentsNewServiceImpl extends DefaultBaseService implements I
}
@Override
public List<ApplyStudentsNewDTO> getGrade(Map<String, Object> params) {
public SuccessResultList<List<ApplyStudentsNewDTO>> getGrade(ListPage page) {
Map<String, Object> params = page.getParams();
PageHelper.startPage(page.getPage(), page.getRows());
String token = params.get("token").toString();
AppTokenUser appTokenUser = this.getAppTokenUser(token);
params.put("userId", appTokenUser.getId());
@ -297,10 +299,6 @@ public class ApplyStudentsNewServiceImpl extends DefaultBaseService implements I
ApplyStudentsNewDTO applyStudentsNewDTO = applyStudentsNewDTOIterator.next();
ClassPlanDTO classPlanDTO = classPlanService.get(applyStudentsNewDTO.getClassPlanId());
applyStudentsNewDTO.setClassPlanDTO(classPlanDTO);
/*WorkTypeDTO workTypeDTO = workTypeService.get(applyStudentsNewDTO.getApplyWorkTypeId());
if(null != workTypeDTO) {
applyStudentsNewDTO.setApplyWorkTypeName(workTypeDTO.getWorkTypeName());
}*/
params.put("examId", applyStudentsNewDTO.getClassPlanId());
ExamApplyDTO examApplyDTO = examApplyService.get(params);
if(null != examApplyDTO) {
@ -311,7 +309,8 @@ public class ApplyStudentsNewServiceImpl extends DefaultBaseService implements I
}else {
list = new ArrayList<>();
}
return list;
PageInfo<ApplyStudentsNewDTO> pageInfo = new PageInfo<>(list);
return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal());
}
public List<ClassPlanDTO> listClassPlan(Map<String, Object> params) {

View File

@ -3,6 +3,7 @@ package cn.com.tenlion.service.handleimportexcel.impl;
import cn.com.tenlion.dao.applystudents.IApplyStudentsDao;
import cn.com.tenlion.dao.applystudentsnew.IApplyStudentsNewDao;
import cn.com.tenlion.dao.classplan.IClassPlanDao;
import cn.com.tenlion.pojo.dtos.applystudentsnew.ApplyStudentsNewDTO;
import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO;
import cn.com.tenlion.pojo.dtos.excel.ImportFailDto;
import cn.com.tenlion.pojo.dtos.excel.ImportResultDto;
@ -90,8 +91,18 @@ public class HandleImportExcelServiceImpl extends DefaultBaseService implements
applyStudentsNewVO.setClassPlanId(applyStudentsNewModel.getClassPlanId());
applyStudentsNewVO.setOrgId(applyStudentsNewModel.getOrgId());
applyStudentsNewVO.setOrgName(applyStudentsNewModel.getOrgName());
applyStudentsNewVO.setUserId(applyStudentsNewModel.getUserId());
applyStudentsNewVO.setCardType(applyStudentsNewModel.getCardType());
applyStudentsNewService.save(applyStudentsNewVO);
params.put("cardNumber", applyStudentsNewModel.getCardNumber());
params.put("classPlanId", applyStudentsNewModel.getClassPlanId());
ApplyStudentsNewDTO applyStudentsNewDTO = applyStudentsNewService.get(params);
if(null == applyStudentsNewDTO) {
applyStudentsNewService.save(applyStudentsNewVO);
}else {
ImportFailDto importFailDto = new ImportFailDto(applyStudentsNewModel, "该考试下的考生记录已经存在");
importFailDtoList.add(importFailDto);
}
}
}
}

View File

@ -6,6 +6,8 @@ import cn.com.tenlion.pojo.model.ApplyStudentsModel;
import cn.com.tenlion.pojo.model.ApplyStudentsNewModel;
import cn.com.tenlion.service.classplan.IClassPlanService;
import cn.com.tenlion.service.handleimportexcel.IHandleImportExcelService;
import cn.com.tenlion.staff.dao.basicstaffinfo.IBasicStaffInfoDao;
import cn.com.tenlion.staff.pojo.dtos.basicstaffinfo.BasicStaffInfoDTO;
import com.alibaba.excel.context.AnalysisContext;
import ink.wgink.exceptions.SaveException;
import org.apache.commons.lang3.StringUtils;
@ -13,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -26,10 +29,15 @@ public class ImportExcelHelper {
@Autowired
private IHandleImportExcelService handleImportExcelService;
private static IClassPlanService classPlanService;
private static IBasicStaffInfoDao basicStaffInfoDao;
@Autowired
public void init(IClassPlanService classPlanService) {
ImportExcelHelper.classPlanService = classPlanService;
}
@Autowired
public void init(IBasicStaffInfoDao basicStaffInfoDao) {
ImportExcelHelper.basicStaffInfoDao = basicStaffInfoDao;
}
/**
@ -176,11 +184,12 @@ public class ImportExcelHelper {
applyStudentsNewModel.setOrgId(classPlanDTO.getOrgId());
applyStudentsNewModel.setOrgName(classPlanDTO.getOrgName());
}
/*private String userId;
private String cardType;
private String examOrgId;
private String examPointId;
private String handsPointId;*/
param.put("keywords", applyStudentsNewModel.getCardNumber());
List<BasicStaffInfoDTO> basicStaffInfoDTOList = basicStaffInfoDao.list(param);
if(null != basicStaffInfoDTOList && basicStaffInfoDTOList.size() > 0) {
applyStudentsNewModel.setUserId(basicStaffInfoDTOList.get(0).getBindUserAccount());
applyStudentsNewModel.setCardType(basicStaffInfoDTOList.get(0).getCardType());
}
}
}

View File

@ -306,8 +306,17 @@
WHERE
t1.is_delete = 0
<if test="applyStudentsNewId != null and applyStudentsNewId != ''">
AND
t1.apply_students_new_id = #{applyStudentsNewId}
AND
t1.apply_students_new_id = #{applyStudentsNewId}
</if>
<if test="cardNumber != null and cardNumber != ''">
AND
t1.card_number = #{cardNumber}
</if>
<if test="classPlanId != null and classPlanId != ''">
AND
t1.class_plan_id = #{classPlanId}
LIMIT 0, 1
</if>
</select>