优化批量导入功能。

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 = "分页列表接口") @ApiOperation(value = "分页列表", notes = "分页列表接口")
@ApiImplicitParams({ @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)}) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get-grade") @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(); Map<String, Object> params = requestParams();
params.put("token", token); 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 * @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 @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(); String token = params.get("token").toString();
AppTokenUser appTokenUser = this.getAppTokenUser(token); AppTokenUser appTokenUser = this.getAppTokenUser(token);
params.put("userId", appTokenUser.getId()); params.put("userId", appTokenUser.getId());
@ -297,10 +299,6 @@ public class ApplyStudentsNewServiceImpl extends DefaultBaseService implements I
ApplyStudentsNewDTO applyStudentsNewDTO = applyStudentsNewDTOIterator.next(); ApplyStudentsNewDTO applyStudentsNewDTO = applyStudentsNewDTOIterator.next();
ClassPlanDTO classPlanDTO = classPlanService.get(applyStudentsNewDTO.getClassPlanId()); ClassPlanDTO classPlanDTO = classPlanService.get(applyStudentsNewDTO.getClassPlanId());
applyStudentsNewDTO.setClassPlanDTO(classPlanDTO); applyStudentsNewDTO.setClassPlanDTO(classPlanDTO);
/*WorkTypeDTO workTypeDTO = workTypeService.get(applyStudentsNewDTO.getApplyWorkTypeId());
if(null != workTypeDTO) {
applyStudentsNewDTO.setApplyWorkTypeName(workTypeDTO.getWorkTypeName());
}*/
params.put("examId", applyStudentsNewDTO.getClassPlanId()); params.put("examId", applyStudentsNewDTO.getClassPlanId());
ExamApplyDTO examApplyDTO = examApplyService.get(params); ExamApplyDTO examApplyDTO = examApplyService.get(params);
if(null != examApplyDTO) { if(null != examApplyDTO) {
@ -311,7 +309,8 @@ public class ApplyStudentsNewServiceImpl extends DefaultBaseService implements I
}else { }else {
list = new ArrayList<>(); 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) { 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.applystudents.IApplyStudentsDao;
import cn.com.tenlion.dao.applystudentsnew.IApplyStudentsNewDao; import cn.com.tenlion.dao.applystudentsnew.IApplyStudentsNewDao;
import cn.com.tenlion.dao.classplan.IClassPlanDao; 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.classplan.ClassPlanDTO;
import cn.com.tenlion.pojo.dtos.excel.ImportFailDto; import cn.com.tenlion.pojo.dtos.excel.ImportFailDto;
import cn.com.tenlion.pojo.dtos.excel.ImportResultDto; import cn.com.tenlion.pojo.dtos.excel.ImportResultDto;
@ -90,8 +91,18 @@ public class HandleImportExcelServiceImpl extends DefaultBaseService implements
applyStudentsNewVO.setClassPlanId(applyStudentsNewModel.getClassPlanId()); applyStudentsNewVO.setClassPlanId(applyStudentsNewModel.getClassPlanId());
applyStudentsNewVO.setOrgId(applyStudentsNewModel.getOrgId()); applyStudentsNewVO.setOrgId(applyStudentsNewModel.getOrgId());
applyStudentsNewVO.setOrgName(applyStudentsNewModel.getOrgName()); 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.pojo.model.ApplyStudentsNewModel;
import cn.com.tenlion.service.classplan.IClassPlanService; import cn.com.tenlion.service.classplan.IClassPlanService;
import cn.com.tenlion.service.handleimportexcel.IHandleImportExcelService; 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 com.alibaba.excel.context.AnalysisContext;
import ink.wgink.exceptions.SaveException; import ink.wgink.exceptions.SaveException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -13,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@ -26,10 +29,15 @@ public class ImportExcelHelper {
@Autowired @Autowired
private IHandleImportExcelService handleImportExcelService; private IHandleImportExcelService handleImportExcelService;
private static IClassPlanService classPlanService; private static IClassPlanService classPlanService;
private static IBasicStaffInfoDao basicStaffInfoDao;
@Autowired @Autowired
public void init(IClassPlanService classPlanService) { public void init(IClassPlanService classPlanService) {
ImportExcelHelper.classPlanService = 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.setOrgId(classPlanDTO.getOrgId());
applyStudentsNewModel.setOrgName(classPlanDTO.getOrgName()); applyStudentsNewModel.setOrgName(classPlanDTO.getOrgName());
} }
/*private String userId; param.put("keywords", applyStudentsNewModel.getCardNumber());
private String cardType; List<BasicStaffInfoDTO> basicStaffInfoDTOList = basicStaffInfoDao.list(param);
private String examOrgId; if(null != basicStaffInfoDTOList && basicStaffInfoDTOList.size() > 0) {
private String examPointId; applyStudentsNewModel.setUserId(basicStaffInfoDTOList.get(0).getBindUserAccount());
private String handsPointId;*/ applyStudentsNewModel.setCardType(basicStaffInfoDTOList.get(0).getCardType());
}
} }
} }

View File

@ -306,8 +306,17 @@
WHERE WHERE
t1.is_delete = 0 t1.is_delete = 0
<if test="applyStudentsNewId != null and applyStudentsNewId != ''"> <if test="applyStudentsNewId != null and applyStudentsNewId != ''">
AND AND
t1.apply_students_new_id = #{applyStudentsNewId} 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> </if>
</select> </select>