报名审核逻辑修改,新增获取报名计划接口

This commit is contained in:
ly19960718 2021-05-04 15:00:10 +08:00
parent 418a4975e2
commit 130306caa0
5 changed files with 203 additions and 34 deletions

View File

@ -1,6 +1,8 @@
package cn.com.tenlion.controller.api.apply; package cn.com.tenlion.controller.api.apply;
import cn.com.tenlion.pojo.dtos.apply.ApplyClassPlanDTO;
import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO; import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO;
import cn.com.tenlion.service.classplan.IClassPlanService;
import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController; import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.SearchException; import ink.wgink.exceptions.SearchException;
@ -80,17 +82,7 @@ public class ApplyController extends DefaultBaseController {
@PutMapping("updateAuditStateAudit") @PutMapping("updateAuditStateAudit")
@CheckRequestBodyAnnotation @CheckRequestBodyAnnotation
public SuccessResult updateAuditStateAudit(@RequestBody ApplyAuditVO applyAuditVO) { public SuccessResult updateAuditStateAudit(@RequestBody ApplyAuditVO applyAuditVO) {
ApplyDTO applyDTO = applyService.get(applyAuditVO.getApplyId()); applyService.audit(null,applyAuditVO);
if(applyDTO == null){
throw new SearchException("未获取到报名信息");
}
if(applyDTO.getApplyAuditState() == 1){
throw new SearchException("用户已撤回报名");
}
if(applyDTO.getApplyAuditState() != 0){
throw new SearchException("报名信息已审核");
}
applyService.updateAuditState(null,applyAuditVO);
return new SuccessResult(); return new SuccessResult();
} }

View File

@ -1,5 +1,6 @@
package cn.com.tenlion.controller.app.api.apply; package cn.com.tenlion.controller.app.api.apply;
import cn.com.tenlion.pojo.dtos.apply.ApplyClassPlanDTO;
import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO; import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO;
import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController; import ink.wgink.common.base.DefaultBaseController;
@ -37,6 +38,28 @@ public class ApplyAppController extends DefaultBaseController {
private IApplyService applyService; private IApplyService applyService;
@ApiOperation(value = "报名计划分页列表", notes = "报名计划分页列表接口")
@ApiImplicitParams({
@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"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "applyCardNumber", value = "报名证件号", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "projectCatalogId", value = "报名工种", paramType = "query", dataType = "String"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listPageApplyClassPlan")
public SuccessResultList<List<ApplyClassPlanDTO>> listPageApplyClassPlan(@RequestHeader("token") String token, ListPage page) throws Exception{
Map<String, Object> params = requestParams();
page.setParams(params);
return applyService.listPageApplyClassPlan(page);
}
@ApiOperation(value = "报名信息撤回", notes = "报名信息撤回接口") @ApiOperation(value = "报名信息撤回", notes = "报名信息撤回接口")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "applyId", value = "报名信息ID", paramType = "path"), @ApiImplicitParam(name = "applyId", value = "报名信息ID", paramType = "path"),

View File

@ -0,0 +1,35 @@
package cn.com.tenlion.pojo.dtos.apply;
import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 报名计划列表
*/
@ApiModel
public class ApplyClassPlanDTO extends ClassPlanDTO {
@ApiModelProperty(name="applyClassPlanState",value="当前人员计划报名状态 0未报名 1已报名")
private int applyClassPlanState;
@ApiModelProperty(name="applyClassPlanUserNumber",value="计划报名人数")
private int applyClassPlanUserNumber;
public int getApplyClassPlanState() {
return applyClassPlanState;
}
public void setApplyClassPlanState(int applyClassPlanState) {
this.applyClassPlanState = applyClassPlanState;
}
public int getApplyClassPlanUserNumber() {
return applyClassPlanUserNumber;
}
public void setApplyClassPlanUserNumber(int applyClassPlanUserNumber) {
this.applyClassPlanUserNumber = applyClassPlanUserNumber;
}
}

View File

@ -1,5 +1,6 @@
package cn.com.tenlion.service.apply; package cn.com.tenlion.service.apply;
import cn.com.tenlion.pojo.dtos.apply.ApplyClassPlanDTO;
import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO; import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO;
import ink.wgink.pojo.ListPage; import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.result.SuccessResultList;
@ -20,6 +21,20 @@ import java.util.Map;
**/ **/
public interface IApplyService { public interface IApplyService {
/**
* 报名信息审核
* @param applyAuditVO
*/
void audit(String token,ApplyAuditVO applyAuditVO);
/**
* 获取报名计划列表
* @param page
* @return
* @throws Exception
*/
SuccessResultList<List<ApplyClassPlanDTO>> listPageApplyClassPlan(ListPage page) throws Exception;
/** /**
* 获取班级报名人员列表 * 获取班级报名人员列表

View File

@ -1,32 +1,38 @@
package cn.com.tenlion.service.apply.impl; package cn.com.tenlion.service.apply.impl;
import cn.com.tenlion.dao.apply.IApplyDao; import cn.com.tenlion.pojo.dtos.apply.ApplyClassPlanDTO;
import cn.com.tenlion.pojo.bos.apply.ApplyBO; import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO;
import cn.com.tenlion.pojo.dtos.apply.ApplyDTO;
import cn.com.tenlion.pojo.pos.apply.ApplyPO;
import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO; import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO;
import cn.com.tenlion.pojo.vos.apply.ApplyVO;
import cn.com.tenlion.pojo.vos.applyauditlog.ApplyAuditLogVO; import cn.com.tenlion.pojo.vos.applyauditlog.ApplyAuditLogVO;
import cn.com.tenlion.pojo.vos.traininginstitutionuser.InstitutionUserVO; import cn.com.tenlion.pojo.vos.traininginstitutionuser.InstitutionUserVO;
import cn.com.tenlion.service.apply.IApplyService;
import cn.com.tenlion.service.applyauditlog.IApplyAuditLogService; import cn.com.tenlion.service.applyauditlog.IApplyAuditLogService;
import com.github.pagehelper.PageHelper; import cn.com.tenlion.service.classplan.IClassPlanService;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService; import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.exceptions.SaveException; import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException; import ink.wgink.exceptions.SearchException;
import ink.wgink.pojo.ListPage; import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.util.UUIDUtil; import ink.wgink.util.date.DateUtil;
import ink.wgink.util.map.HashMapUtil; import ink.wgink.util.map.HashMapUtil;
import ink.wgink.util.UUIDUtil;
import cn.com.tenlion.dao.apply.IApplyDao;
import cn.com.tenlion.pojo.dtos.apply.ApplyDTO;
import cn.com.tenlion.pojo.vos.apply.ApplyVO;
import cn.com.tenlion.pojo.bos.apply.ApplyBO;
import cn.com.tenlion.pojo.pos.apply.ApplyPO;
import cn.com.tenlion.service.apply.IApplyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.text.ParseException;
import java.util.HashMap; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
/** /**
* @ClassName: ApplyServiceImpl * @ClassName: ApplyServiceImpl
@ -42,6 +48,58 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic
private IApplyDao applyDao; private IApplyDao applyDao;
@Autowired @Autowired
private IApplyAuditLogService applyAuditLogService; private IApplyAuditLogService applyAuditLogService;
@Autowired
private IClassPlanService classPlanService;
public void audit(String token,ApplyAuditVO applyAuditVO){
ApplyDTO applyDTO = this.get(applyAuditVO.getApplyId());
if(applyDTO == null){
throw new SearchException("未获取到报名信息");
}
if(applyDTO.getApplyAuditState() == 1){
throw new SearchException("用户已撤回报名");
}
if(applyDTO.getApplyAuditState() != 0){
throw new SearchException("报名信息已审核");
}
ClassPlanDTO classPlanDTO = classPlanService.get(applyAuditVO.getApplyId());
if(classPlanDTO == null){
throw new ParamsException("未查询到计划信息");
}
int planPersonNum = classPlanDTO.getPlanPersonNum();//计划人数
int applyClassNumber = countApplyClassNumber(applyAuditVO.getApplyId());//以报名人数
if(applyClassNumber+1 > planPersonNum ){
throw new ParamsException("该计划报名人数已满");
}
updateAuditState(token,applyAuditVO);
}
public SuccessResultList<List<ApplyClassPlanDTO>> listPageApplyClassPlan(ListPage page) throws Exception{
List<ApplyClassPlanDTO> list= new ArrayList<>();
String applyCardNumber = page.getParams().get("applyCardNumber").toString();
String projectCatalogId = page.getParams().get("projectCatalogId").toString();
if(StringUtils.isBlank(applyCardNumber)){
throw new ParamsException("请填写证件号");
}
if(StringUtils.isBlank(projectCatalogId)){
throw new ParamsException("请选择报考工种");
}
PageHelper.startPage(page.getPage(), page.getRows());
List<ClassPlanDTO> classPlanDTOList = classPlanService.list(page.getParams());
for (ClassPlanDTO classPlanDTO : classPlanDTOList) {
ApplyClassPlanDTO applyClassPlanDTO = new ApplyClassPlanDTO();
int applyClassPlanState = countApplyCardNumber(applyCardNumber,classPlanDTO.getClassPlanId());
applyClassPlanDTO.setApplyClassPlanState(applyClassPlanState == 0 ? 0:1);
applyClassPlanDTO.setApplyClassPlanUserNumber(countApplyClassNumber(classPlanDTO.getClassPlanId()));
BeanUtils.copyProperties(applyClassPlanDTO,classPlanDTO);
list.add(applyClassPlanDTO);
}
PageInfo<ApplyClassPlanDTO> pageInfo = new PageInfo<>(list);
return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal());
}
public List<ApplyDTO> listByClassId(String classId){ public List<ApplyDTO> listByClassId(String classId){
@ -52,7 +110,7 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic
applyAuditStates.add(3); applyAuditStates.add(3);
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("applyClassId",classId); params.put("applyClassId",classId);
params.put("applyAuditStates",classId); params.put("applyAuditStates",applyAuditStates);
return this.list(params); return this.list(params);
} }
@ -75,10 +133,8 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic
@Override @Override
public String saveReturnId(String token, ApplyVO applyVO) { public String saveReturnId(String token, ApplyVO applyVO) {
//检查数据 //检查报名数据
checkSaveData(applyVO.getApplyCardNumber(),applyVO.getApplyClassId()); checkSaveData(applyVO.getApplyCardNumber(),applyVO.getApplyClassId());
//检查时间范围
//待增加
String applyId = UUIDUtil.getUUID(); String applyId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(applyVO); Map<String, Object> params = HashMapUtil.beanToMap(applyVO);
params.put("applyId", applyId); params.put("applyId", applyId);
@ -99,6 +155,41 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic
return applyId; return applyId;
} }
public void checkSaveData(String applyCardNumber,String ApplyClassId){
if(countApplyCardNumber(applyCardNumber,ApplyClassId) != 0){
throw new SaveException("您以报名过该项目");
}
ClassPlanDTO classPlanDTO = classPlanService.get(ApplyClassId);
if(classPlanDTO == null){
throw new ParamsException("未查询到计划信息");
}
int planPersonNum = classPlanDTO.getPlanPersonNum();//计划人数
String planStartTime = classPlanDTO.getPlanStartTime();//计划开始时间
String planEndTime = classPlanDTO.getPlanEndTime();//计划结束时间
int applyClassNumber = countApplyClassNumber(ApplyClassId);//以报名人数
if(applyClassNumber+1 > planPersonNum ){
throw new ParamsException("该计划报名人数已满");
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar date = Calendar.getInstance();
Calendar begin = Calendar.getInstance();
Calendar end = Calendar.getInstance();
try {
date.setTime(df.parse(DateUtil.getTime()));
begin.setTime(df.parse(planStartTime));
end.setTime(df.parse(planEndTime));
if (!(date.after(begin) && date.before(end))) {
throw new ParamsException("该计划已截止报名");
}
} catch (ParseException e) {
e.printStackTrace();
}
}
@Override @Override
public void remove(List<String> ids) { public void remove(List<String> ids) {
remove(null, ids); remove(null, ids);
@ -218,9 +309,9 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic
} }
/** /**
* 效验报名新增信息 * 统计证件号码 报名培训计划的次数不包括撤回
*/ */
public void checkSaveData(String applyCardNumber,String applyClassId){ public Integer countApplyCardNumber(String applyCardNumber,String applyClassId){
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("applyCardNumber",applyCardNumber); params.put("applyCardNumber",applyCardNumber);
params.put("applyClassId",applyClassId); params.put("applyClassId",applyClassId);
@ -228,15 +319,28 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic
applyAuditStates.add("0"); applyAuditStates.add("0");
applyAuditStates.add("2"); applyAuditStates.add("2");
applyAuditStates.add("3"); applyAuditStates.add("3");
applyAuditStates.add("4");
applyAuditStates.add("-1"); applyAuditStates.add("-1");
params.put("applyAuditStates",applyAuditStates); params.put("applyAuditStates",applyAuditStates);
if(count(params) != 0){ return count(params);
throw new SaveException("您以报名过该项目");
}
} }
/**
* 统计计划报名人数不包括审核未通过撤回状态
*/
public Integer countApplyClassNumber(String applyClassId){
Map<String, Object> params = new HashMap<>();
params.put("applyClassId",applyClassId);
List<String> applyAuditStates = new ArrayList<>();
applyAuditStates.add("0");
applyAuditStates.add("2");
applyAuditStates.add("3");
params.put("applyAuditStates",applyAuditStates);
return count(params);
}
@Override @Override
public Integer count(Map<String, Object> params) { public Integer count(Map<String, Object> params) {