From 130306caa0b0538d67f64426b2b1ac8b1d5befef Mon Sep 17 00:00:00 2001 From: ly19960718 <1622779752@qq.com> Date: Tue, 4 May 2021 15:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=90=8D=E5=AE=A1=E6=A0=B8=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8A=A5=E5=90=8D=E8=AE=A1=E5=88=92=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/api/apply/ApplyController.java | 14 +- .../app/api/apply/ApplyAppController.java | 23 +++ .../pojo/dtos/apply/ApplyClassPlanDTO.java | 35 ++++ .../tenlion/service/apply/IApplyService.java | 15 ++ .../service/apply/impl/ApplyServiceImpl.java | 150 +++++++++++++++--- 5 files changed, 203 insertions(+), 34 deletions(-) create mode 100644 src/main/java/cn/com/tenlion/pojo/dtos/apply/ApplyClassPlanDTO.java diff --git a/src/main/java/cn/com/tenlion/controller/api/apply/ApplyController.java b/src/main/java/cn/com/tenlion/controller/api/apply/ApplyController.java index 67d312c..416720a 100644 --- a/src/main/java/cn/com/tenlion/controller/api/apply/ApplyController.java +++ b/src/main/java/cn/com/tenlion/controller/api/apply/ApplyController.java @@ -1,6 +1,8 @@ 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.service.classplan.IClassPlanService; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.exceptions.SearchException; @@ -80,17 +82,7 @@ public class ApplyController extends DefaultBaseController { @PutMapping("updateAuditStateAudit") @CheckRequestBodyAnnotation public SuccessResult updateAuditStateAudit(@RequestBody ApplyAuditVO applyAuditVO) { - ApplyDTO applyDTO = applyService.get(applyAuditVO.getApplyId()); - if(applyDTO == null){ - throw new SearchException("未获取到报名信息"); - } - if(applyDTO.getApplyAuditState() == 1){ - throw new SearchException("用户已撤回报名"); - } - if(applyDTO.getApplyAuditState() != 0){ - throw new SearchException("报名信息已审核"); - } - applyService.updateAuditState(null,applyAuditVO); + applyService.audit(null,applyAuditVO); return new SuccessResult(); } diff --git a/src/main/java/cn/com/tenlion/controller/app/api/apply/ApplyAppController.java b/src/main/java/cn/com/tenlion/controller/app/api/apply/ApplyAppController.java index ec27107..aed3dca 100644 --- a/src/main/java/cn/com/tenlion/controller/app/api/apply/ApplyAppController.java +++ b/src/main/java/cn/com/tenlion/controller/app/api/apply/ApplyAppController.java @@ -1,5 +1,6 @@ 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 ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; @@ -37,6 +38,28 @@ public class ApplyAppController extends DefaultBaseController { 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> listPageApplyClassPlan(@RequestHeader("token") String token, ListPage page) throws Exception{ + Map params = requestParams(); + page.setParams(params); + return applyService.listPageApplyClassPlan(page); + } + + + @ApiOperation(value = "报名信息撤回", notes = "报名信息撤回接口") @ApiImplicitParams({ @ApiImplicitParam(name = "applyId", value = "报名信息ID", paramType = "path"), diff --git a/src/main/java/cn/com/tenlion/pojo/dtos/apply/ApplyClassPlanDTO.java b/src/main/java/cn/com/tenlion/pojo/dtos/apply/ApplyClassPlanDTO.java new file mode 100644 index 0000000..4cd30c5 --- /dev/null +++ b/src/main/java/cn/com/tenlion/pojo/dtos/apply/ApplyClassPlanDTO.java @@ -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; + } +} diff --git a/src/main/java/cn/com/tenlion/service/apply/IApplyService.java b/src/main/java/cn/com/tenlion/service/apply/IApplyService.java index 1aef066..2679e5c 100644 --- a/src/main/java/cn/com/tenlion/service/apply/IApplyService.java +++ b/src/main/java/cn/com/tenlion/service/apply/IApplyService.java @@ -1,5 +1,6 @@ package cn.com.tenlion.service.apply; +import cn.com.tenlion.pojo.dtos.apply.ApplyClassPlanDTO; import cn.com.tenlion.pojo.vos.apply.ApplyAuditVO; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.SuccessResultList; @@ -20,6 +21,20 @@ import java.util.Map; **/ public interface IApplyService { + /** + * 报名信息审核 + * @param applyAuditVO + */ + void audit(String token,ApplyAuditVO applyAuditVO); + + /** + * 获取报名计划列表 + * @param page + * @return + * @throws Exception + */ + SuccessResultList> listPageApplyClassPlan(ListPage page) throws Exception; + /** * 获取班级报名人员列表 diff --git a/src/main/java/cn/com/tenlion/service/apply/impl/ApplyServiceImpl.java b/src/main/java/cn/com/tenlion/service/apply/impl/ApplyServiceImpl.java index 1ac0d0b..256a81c 100644 --- a/src/main/java/cn/com/tenlion/service/apply/impl/ApplyServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/apply/impl/ApplyServiceImpl.java @@ -1,32 +1,38 @@ package cn.com.tenlion.service.apply.impl; -import cn.com.tenlion.dao.apply.IApplyDao; -import cn.com.tenlion.pojo.bos.apply.ApplyBO; -import cn.com.tenlion.pojo.dtos.apply.ApplyDTO; -import cn.com.tenlion.pojo.pos.apply.ApplyPO; +import cn.com.tenlion.pojo.dtos.apply.ApplyClassPlanDTO; +import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO; 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.traininginstitutionuser.InstitutionUserVO; -import cn.com.tenlion.service.apply.IApplyService; import cn.com.tenlion.service.applyauditlog.IApplyAuditLogService; -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; +import cn.com.tenlion.service.classplan.IClassPlanService; import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.ParamsException; import ink.wgink.exceptions.SaveException; import ink.wgink.exceptions.SearchException; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.result.SuccessResult; 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.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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; /** * @ClassName: ApplyServiceImpl @@ -42,6 +48,58 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic private IApplyDao applyDao; @Autowired 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> listPageApplyClassPlan(ListPage page) throws Exception{ + List 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 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 pageInfo = new PageInfo<>(list); + return new SuccessResultList<>(list, pageInfo.getPageNum(), pageInfo.getTotal()); + } public List listByClassId(String classId){ @@ -52,7 +110,7 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic applyAuditStates.add(3); Map params = new HashMap<>(); params.put("applyClassId",classId); - params.put("applyAuditStates",classId); + params.put("applyAuditStates",applyAuditStates); return this.list(params); } @@ -75,10 +133,8 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic @Override public String saveReturnId(String token, ApplyVO applyVO) { - //检查数据 + //检查报名数据 checkSaveData(applyVO.getApplyCardNumber(),applyVO.getApplyClassId()); - //检查时间范围 - //待增加 String applyId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(applyVO); params.put("applyId", applyId); @@ -99,6 +155,41 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic 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 public void remove(List 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 params = new HashMap<>(); params.put("applyCardNumber",applyCardNumber); params.put("applyClassId",applyClassId); @@ -228,15 +319,28 @@ public class ApplyServiceImpl extends DefaultBaseService implements IApplyServic applyAuditStates.add("0"); applyAuditStates.add("2"); applyAuditStates.add("3"); - applyAuditStates.add("4"); applyAuditStates.add("-1"); params.put("applyAuditStates",applyAuditStates); - if(count(params) != 0){ - throw new SaveException("您以报名过该项目"); - } + return count(params); } + /** + * 统计计划报名人数(不包括审核未通过,撤回状态) + */ + public Integer countApplyClassNumber(String applyClassId){ + Map params = new HashMap<>(); + params.put("applyClassId",applyClassId); + List applyAuditStates = new ArrayList<>(); + applyAuditStates.add("0"); + applyAuditStates.add("2"); + applyAuditStates.add("3"); + params.put("applyAuditStates",applyAuditStates); + return count(params); + } + + + @Override public Integer count(Map params) {