From 307f89c8244015cdec5aa3f3798ae781881b21e4 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Sat, 19 Jun 2021 11:04:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=8F=AD=E8=AE=A1=E5=88=92=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E5=92=8C=E8=80=83=E8=AF=95=E7=94=B3=E8=AF=B7=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=94=B9=E4=B8=BA=E4=B8=89=E7=BA=A7=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tenlion/dao/plancheck/IPlanCheckDao.java | 17 ++ .../examapply/impl/ExamApplyServiceImpl.java | 25 ++- .../examcheck/impl/ExamCheckServiceImpl.java | 84 +++---- .../service/plancheck/IPlanCheckService.java | 5 + .../plancheck/impl/PlanCheckServiceImpl.java | 206 ++++++++++++++++++ .../plan-check-mapper.xml | 33 +++ .../static/route/examapply/list-check.html | 2 +- .../static/route/examcheck/list.html | 6 +- .../static/route/examcheck/update.html | 5 +- 9 files changed, 320 insertions(+), 63 deletions(-) rename src/main/resources/mybatis/mapper/{planCheck => plancheck}/plan-check-mapper.xml (54%) diff --git a/src/main/java/cn/com/tenlion/dao/plancheck/IPlanCheckDao.java b/src/main/java/cn/com/tenlion/dao/plancheck/IPlanCheckDao.java index 9f9a42e..4df1c38 100644 --- a/src/main/java/cn/com/tenlion/dao/plancheck/IPlanCheckDao.java +++ b/src/main/java/cn/com/tenlion/dao/plancheck/IPlanCheckDao.java @@ -1,8 +1,11 @@ package cn.com.tenlion.dao.plancheck; import ink.wgink.exceptions.SaveException; +import ink.wgink.pojo.dtos.position.PositionDTO; +import ink.wgink.pojo.dtos.position.PositionUserDTO; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Map; /** @@ -23,4 +26,18 @@ public interface IPlanCheckDao { */ void save(Map params) throws SaveException; + /** + * 获取职位管理列表 + * @return + * @throws SaveException + */ + List getPositionList() throws SaveException; + + /** + * 通过职位ID获取当前职位下的用户列表 + * @param params + * @return + * @throws SaveException + */ + List getPositionUserList(Map params) throws SaveException; } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/service/examapply/impl/ExamApplyServiceImpl.java b/src/main/java/cn/com/tenlion/service/examapply/impl/ExamApplyServiceImpl.java index 7733da9..4ff8a22 100644 --- a/src/main/java/cn/com/tenlion/service/examapply/impl/ExamApplyServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/examapply/impl/ExamApplyServiceImpl.java @@ -8,9 +8,11 @@ import cn.com.tenlion.pojo.dtos.classplan.ClassPlanDTO; import cn.com.tenlion.pojo.dtos.examapply.ExamApplyDTO; import cn.com.tenlion.pojo.pos.examapply.ExamApplyPO; import cn.com.tenlion.pojo.vos.examapply.ExamApplyVO; +import cn.com.tenlion.pojo.vos.plancheck.PlanCheckVO; import cn.com.tenlion.service.classplan.IClassPlanService; import cn.com.tenlion.service.examapply.IExamApplyService; import cn.com.tenlion.service.examination.distribution.IDistributionService; +import cn.com.tenlion.service.plancheck.IPlanCheckService; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.SuccessResultList; @@ -42,6 +44,8 @@ public class ExamApplyServiceImpl extends DefaultBaseService implements IExamApp private IInstitutionService iInstitutionService; @Autowired private IClassPlanService classPlanService; + @Autowired + private IPlanCheckService planCheckService; @Override public void save(ExamApplyVO examApplyVO) { @@ -65,7 +69,7 @@ public class ExamApplyServiceImpl extends DefaultBaseService implements IExamApp examApplyVO.setStatus(0); // 监考老师分配状态。0:未分配,1:已分配 examApplyVO.setUserStatus(0); - // 考试申请审核状态。0:未审核,1:审核通过,2:审核驳回 + // 考试申请审核状态。0:未审核,1:审核通过,-1:审核驳回 examApplyVO.setCheckStatus(0); // 获取当前时间戳 Long startTs = System.currentTimeMillis(); @@ -129,14 +133,19 @@ public class ExamApplyServiceImpl extends DefaultBaseService implements IExamApp @Override public void update(String token, String examApplyId, ExamApplyVO examApplyVO) { - Map params = HashMapUtil.beanToMap(examApplyVO); - params.put("examApplyId", examApplyId); - if (StringUtils.isBlank(token)) { - setUpdateInfo(params); - } else { - setAppUpdateInfo(token, params); + PlanCheckVO planCheckVO = null; + Boolean canUpdate = planCheckService.canUpdate(null, examApplyVO, planCheckVO); + if(canUpdate) { + planCheckService.save(planCheckVO); + Map params = HashMapUtil.beanToMap(examApplyVO); + params.put("examApplyId", examApplyId); + if (StringUtils.isBlank(token)) { + setUpdateInfo(params); + } else { + setAppUpdateInfo(token, params); + } + examApplyDao.update(params); } - examApplyDao.update(params); } @Override diff --git a/src/main/java/cn/com/tenlion/service/examcheck/impl/ExamCheckServiceImpl.java b/src/main/java/cn/com/tenlion/service/examcheck/impl/ExamCheckServiceImpl.java index a0153db..981af71 100644 --- a/src/main/java/cn/com/tenlion/service/examcheck/impl/ExamCheckServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/examcheck/impl/ExamCheckServiceImpl.java @@ -9,24 +9,33 @@ import cn.com.tenlion.pojo.dtos.examcheck.ExamCheckDTO; import cn.com.tenlion.pojo.pos.examcheck.ExamCheckPO; import cn.com.tenlion.pojo.vos.classplan.ClassPlanVO; import cn.com.tenlion.pojo.vos.examcheck.ExamCheckVO; +import cn.com.tenlion.pojo.vos.plancheck.PlanCheckVO; import cn.com.tenlion.service.applystudents.IApplyStudentsService; import cn.com.tenlion.service.classplan.IClassPlanService; import cn.com.tenlion.service.examapply.IExamApplyService; import cn.com.tenlion.service.examcheck.IExamCheckService; +import cn.com.tenlion.service.plancheck.IPlanCheckService; import com.sun.org.apache.xpath.internal.operations.Bool; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.exceptions.UpdateException; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.bos.UserInfoBO; import ink.wgink.pojo.dtos.position.PositionDTO; +import ink.wgink.pojo.dtos.position.PositionUserDTO; +import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.vos.IdsVO; import ink.wgink.service.position.service.IPositionService; +import ink.wgink.service.position.service.IPositionUserService; +import ink.wgink.service.user.service.IUserService; +import ink.wgink.util.date.DateUtil; import ink.wgink.util.map.HashMapUtil; import ink.wgink.util.UUIDUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import java.util.*; @@ -44,15 +53,13 @@ public class ExamCheckServiceImpl extends DefaultBaseService implements IExamChe @Autowired private IExamCheckDao examCheckDao; @Autowired - private IExamApplyService examApplyService; - @Autowired private IClassPlanService classPlanService; @Autowired private IInstitutionService iInstitutionService; @Autowired private IApplyStudentsService applyStudentsService; @Autowired - private IPositionService positionService; + private IPlanCheckService planCheckService; @Override public void save(ExamCheckVO examCheckVO) { @@ -83,8 +90,6 @@ public class ExamCheckServiceImpl extends DefaultBaseService implements IExamChe return examCheckId; } - - @Override public void remove(List ids) { remove(null, ids); @@ -124,53 +129,36 @@ public class ExamCheckServiceImpl extends DefaultBaseService implements IExamChe @Override public void update(String token, String examCheckId, ExamCheckVO examCheckVO) { - String point = examCheckVO.getPoint(); - Boolean hasUser = false; - String positionId = null; - if(StringUtils.isEmpty(point)) { - throw new UpdateException("缺少节点信息"); - } - - List positionIds = new ArrayList<>(); - positionIds.add("0"); - List positionDTOList = positionService.list(positionIds); - if(null != positionDTOList && positionDTOList.size() > 0) { - for(PositionDTO positionDTO: positionDTOList) { - if(point.equals(positionDTO.getPositionName())) { - hasUser = true; - positionId = positionDTO.getPositionId(); + PlanCheckVO planCheckVO = new PlanCheckVO(); + Boolean canUpdate = planCheckService.canUpdate(examCheckVO, null, planCheckVO); + if(canUpdate) { + planCheckService.save(planCheckVO); + Map params = HashMapUtil.beanToMap(examCheckVO); + params.put("examCheckId", examCheckId); + if (StringUtils.isBlank(token)) { + setUpdateInfo(params); + } else { + setAppUpdateInfo(token, params); + } + examCheckDao.update(params); + ExamCheckDTO examCheckDTO = get(examCheckId); + // 开班计划审核通过以后,调用机构接口,删除机构相关信息 + if(1 == examCheckVO.getCheckStatus()) { + try { + applyStudentsService.saveCopeApply(examCheckDTO.getOrgId(), examCheckDTO.getWorkTypeId(), examCheckDTO.getPlanId()); + }catch (Exception e) { + e.printStackTrace(); } } + // 信息回传到培训机构,返回审核状态等信息 + /*String classPlanId = examCheckVO.getPlanId(); + ClassPlanVO classPlanVO = new ClassPlanVO(); + classPlanVO.setReportType(examCheckVO.getCheckStatus().toString()); + classPlanVO.setReportReason(examCheckVO.getReason()); + classPlanService.update(classPlanId, classPlanVO);*/ }else { - throw new UpdateException("请先配置职位管理信息"); + throw new UpdateException("当前用户暂无审核权限"); } - // 如果不存在职位管理信息,则抛出异常 - /*if() { - - }*/ - Map params = HashMapUtil.beanToMap(examCheckVO); - params.put("examCheckId", examCheckId); - if (StringUtils.isBlank(token)) { - setUpdateInfo(params); - } else { - setAppUpdateInfo(token, params); - } - examCheckDao.update(params); - ExamCheckDTO examCheckDTO = get(examCheckId); - // 开班计划审核通过以后,调用机构接口,删除机构相关信息 - if(1 == examCheckVO.getCheckStatus()) { - try { - applyStudentsService.saveCopeApply(examCheckDTO.getOrgId(), examCheckDTO.getWorkTypeId(), examCheckDTO.getPlanId()); - }catch (Exception e) { - e.printStackTrace(); - } - } - // 信息回传到培训机构,返回审核状态等信息 - /*String classPlanId = examCheckVO.getPlanId(); - ClassPlanVO classPlanVO = new ClassPlanVO(); - classPlanVO.setReportType(examCheckVO.getCheckStatus().toString()); - classPlanVO.setReportReason(examCheckVO.getReason()); - classPlanService.update(classPlanId, classPlanVO);*/ } @Override diff --git a/src/main/java/cn/com/tenlion/service/plancheck/IPlanCheckService.java b/src/main/java/cn/com/tenlion/service/plancheck/IPlanCheckService.java index e3f3bf1..3028eac 100644 --- a/src/main/java/cn/com/tenlion/service/plancheck/IPlanCheckService.java +++ b/src/main/java/cn/com/tenlion/service/plancheck/IPlanCheckService.java @@ -1,5 +1,8 @@ package cn.com.tenlion.service.plancheck; +import cn.com.tenlion.pojo.dtos.examapply.ExamApplyDTO; +import cn.com.tenlion.pojo.vos.examapply.ExamApplyVO; +import cn.com.tenlion.pojo.vos.examcheck.ExamCheckVO; import cn.com.tenlion.pojo.vos.plancheck.PlanCheckVO; /** @@ -19,4 +22,6 @@ public interface IPlanCheckService { */ void save(PlanCheckVO planCheckVO); + Boolean canUpdate(ExamCheckVO examCheckVO, ExamApplyVO examApplyVO, PlanCheckVO planCheckVO); + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/service/plancheck/impl/PlanCheckServiceImpl.java b/src/main/java/cn/com/tenlion/service/plancheck/impl/PlanCheckServiceImpl.java index 4d836dc..aaa2ddd 100644 --- a/src/main/java/cn/com/tenlion/service/plancheck/impl/PlanCheckServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/plancheck/impl/PlanCheckServiceImpl.java @@ -1,14 +1,29 @@ package cn.com.tenlion.service.plancheck.impl; import cn.com.tenlion.dao.plancheck.IPlanCheckDao; +import cn.com.tenlion.pojo.vos.examapply.ExamApplyVO; +import cn.com.tenlion.pojo.vos.examcheck.ExamCheckVO; import cn.com.tenlion.pojo.vos.plancheck.PlanCheckVO; import cn.com.tenlion.service.plancheck.IPlanCheckService; import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.UpdateException; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.bos.UserInfoBO; +import ink.wgink.pojo.dtos.ZTreeDTO; +import ink.wgink.pojo.dtos.position.PositionDTO; +import ink.wgink.pojo.dtos.position.PositionUserDTO; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.service.position.service.IPositionService; +import ink.wgink.service.position.service.IPositionUserService; import ink.wgink.util.UUIDUtil; +import ink.wgink.util.date.DateUtil; import ink.wgink.util.map.HashMapUtil; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.List; import java.util.Map; @Service @@ -16,6 +31,10 @@ public class PlanCheckServiceImpl extends DefaultBaseService implements IPlanChe @Autowired private IPlanCheckDao planCheckDao; + @Autowired + private IPositionService positionService; + @Autowired + private IPositionUserService positionUserService; @Override public void save(PlanCheckVO planCheckVO) { @@ -25,4 +44,191 @@ public class PlanCheckServiceImpl extends DefaultBaseService implements IPlanChe setSaveInfo(params); planCheckDao.save(params); } + + @Override + public Boolean canUpdate(ExamCheckVO examCheckVO, ExamApplyVO examApplyVO, PlanCheckVO planCheckVO) { + // 用于最后的结果返回 + Boolean can = false; + // 当前审核节点的对象角色 + String point = null; + if(null != examCheckVO) { + point = examCheckVO.getPoint(); + planCheckVO.setPlanId(examCheckVO.getPlanId()); + } + if(null != examApplyVO) { + point = examApplyVO.getPoint(); + planCheckVO.setPlanId(examApplyVO.getExamId()); + } + if(StringUtils.isEmpty(point)) { + throw new UpdateException("缺少节点信息"); + } + // 查找职位信息 + List positionDTOList = getPositionList(); + // 获取职位ID + String positionId = hasPointMsg(positionDTOList, point); + // 通过职位ID获取档前职位下的用户列表并判断当前登录用户是否有审核权限 + // 获取当前登录i用户的userId + String userId = getUserMsg(planCheckVO); + Boolean hasUser = getPositionUserList(positionId, userId); + if(hasUser) { + can = true; + } + planCheckVO.setCheckTime(DateUtil.getTime()); + if(can) { + setCheckMsg(point, examCheckVO, examApplyVO, planCheckVO); + } + return can; + } + + /** + * 获取当前角色下的所有用户信息 + * @return + */ + private List getPositionList() { + List positionList = planCheckDao.getPositionList(); + if(null == positionList || positionList.size() == 0) { + throw new UpdateException("请先配置职位信息"); + } + return positionList; + } + + /** + * 判断是否存在职位信息 + * @param positionDTOList + * @param point + * @return + */ + private String hasPointMsg(List positionDTOList, String point) { + Boolean hasPoint = false; + String pointId = null; + for(PositionDTO positionDTO: positionDTOList) { + if(point.equals(positionDTO.getPositionName())) { + hasPoint = true; + pointId = positionDTO.getPositionId(); + } + } + if(!hasPoint) { + throw new UpdateException("暂无" + point + "的职位信息,请添加"); + } + return pointId; + } + + /** + * 通过职位ID获取当前职位下的用户列表 + * @param positionId + * @return + */ + private Boolean getPositionUserList(String positionId, String userId) { + Map params = new HashMap<>(); + Boolean hasUser = false; + params.put("positionId", positionId); + List positionUserDTOList = planCheckDao.getPositionUserList(params); + if(null != positionUserDTOList && positionUserDTOList.size() > 0) { + for(String s: positionUserDTOList) { + if(s.equals(userId)) { + hasUser = true; + } + } + } + if(!hasUser) { + throw new UpdateException("当前用户暂无审核权限"); + } + return true; + } + + /** + * 获取当前登陆人的用户信息 + * @param planCheckVO + */ + private String getUserMsg(PlanCheckVO planCheckVO) { + UserInfoBO userInfoBO = securityComponent.getCurrentUser(); + String userId = null; + if(null != userInfoBO) { + userId = userInfoBO.getUserId(); + planCheckVO.setUserId(userId); + planCheckVO.setUserName(userInfoBO.getUserUsername()); + }else { + throw new UpdateException("系统错误"); + } + return userId; + } + + /** + * 三级审核逻辑方法 + * @param point + * @param examCheckVO + * @param examApplyVO + * @param planCheckVO + */ + private void setCheckMsg(String point, ExamCheckVO examCheckVO, ExamApplyVO examApplyVO, PlanCheckVO planCheckVO) { + Integer checkStatus = null; + String reason = null; + if(null != examCheckVO) { + checkStatus = examCheckVO.getCheckStatus(); + reason = examCheckVO.getReason(); + examCheckVO.setPoint(point); + examCheckVO.setCheckStatus(checkStatus); + examCheckVO.setReason(reason); + } + if(null != examApplyVO) { + checkStatus = examApplyVO.getCheckStatus(); + reason = examApplyVO.getReason(); + examApplyVO.setPoint(point); + examApplyVO.setCheckStatus(checkStatus); + examApplyVO.setReason(reason); + } + // 保存节点信息 + planCheckVO.setCheckStatus(checkStatus.toString()); + planCheckVO.setReason(reason); + /** + * 如果当前审核节点角色为科员 + * 审核通过,则到下一节点(科长)审核 + * 审核退回,则审核失败 + */ + if(1 == checkStatus && "科员".equals(point)) { + checkStatus = 0; + point = "科长"; + } + /** + * 如果当前审核节点角色为科长 + * 审核通过,则到下一节点(分管领导)审核 + * 审核退回,则审核节点退回到科员审核 + */ + if(1 == checkStatus && "科长".equals(point)) { + checkStatus = 0; + reason = ""; + point = "分管领导"; + } + if(-1 == checkStatus && "科长".equals(point)) { + checkStatus = 0; + reason = ""; + point = "科员"; + } + /** + * 如果当前审核节点角色为分管领导 + * 审核通过,则审核流程结束,设置审核状态为通过 + * 审核退回,则审核节点退回到科员审核 + */ + if(1 == checkStatus && "分管领导".equals(point)) { + checkStatus = 1; + reason = ""; + point = "分管领导"; + } + if(-1 == checkStatus && "分管领导".equals(point)) { + checkStatus = 0; + reason = ""; + point = "科员"; + } + + if(null != examCheckVO) { + examCheckVO.setPoint(point); + examCheckVO.setCheckStatus(checkStatus); + examCheckVO.setReason(reason); + } + if(null != examApplyVO) { + examApplyVO.setPoint(point); + examApplyVO.setCheckStatus(checkStatus); + examApplyVO.setReason(reason); + } + } } diff --git a/src/main/resources/mybatis/mapper/planCheck/plan-check-mapper.xml b/src/main/resources/mybatis/mapper/plancheck/plan-check-mapper.xml similarity index 54% rename from src/main/resources/mybatis/mapper/planCheck/plan-check-mapper.xml rename to src/main/resources/mybatis/mapper/plancheck/plan-check-mapper.xml index 02b8a3f..d998c26 100644 --- a/src/main/resources/mybatis/mapper/planCheck/plan-check-mapper.xml +++ b/src/main/resources/mybatis/mapper/plancheck/plan-check-mapper.xml @@ -12,6 +12,16 @@ + + + + + + + + + + INSERT INTO e_exam_check( @@ -43,4 +53,27 @@ ) + + + + \ No newline at end of file diff --git a/src/main/resources/static/route/examapply/list-check.html b/src/main/resources/static/route/examapply/list-check.html index da2978c..a55326a 100644 --- a/src/main/resources/static/route/examapply/list-check.html +++ b/src/main/resources/static/route/examapply/list-check.html @@ -143,7 +143,7 @@ var nextTime = new Date(); nextTime.setDate(nextTime.getDate() + $('#nextCommitTime').val()); formData.field.nextCommitTime = nextTime.format("yyyy-MM-dd hh:mm:ss"); - formData.field.checkStatus = '2'; + formData.field.checkStatus = '-1'; top.restAjax.put(top.restAjax.path('api/examapply/update-more/{examApplyId}', [ids]), formData.field, null, function(code, data) { if('200' == code) { top.dialog.msg('退回成功'); diff --git a/src/main/resources/static/route/examcheck/list.html b/src/main/resources/static/route/examcheck/list.html index b0521c2..b6e3e65 100644 --- a/src/main/resources/static/route/examcheck/list.html +++ b/src/main/resources/static/route/examcheck/list.html @@ -129,7 +129,7 @@ var ids = $('#examIds').val(); var nextTime = new Date(); nextTime.setDate(nextTime.getDate() + $('#nextCommitTime').val()); - formData.field.checkStatus = '3'; + formData.field.checkStatus = '-1'; formData.field.nextCommitTime = nextTime.format("yyyy-MM-dd hh:mm:ss"); top.restAjax.put(top.restAjax.path('api/examcheck/update-more/{ids}', [ids]), formData.field, null, function(code, data) { if('200' == code) { @@ -277,10 +277,10 @@ if('0' == rowData) { rowData = '待审核'; } - if('2' == rowData) { + if('1' == rowData) { rowData = '审核通过'; } - if('3' == rowData) { + if('-1' == rowData) { rowData = '审核驳回'; } return rowData; diff --git a/src/main/resources/static/route/examcheck/update.html b/src/main/resources/static/route/examcheck/update.html index 4518cf4..df81cd9 100644 --- a/src/main/resources/static/route/examcheck/update.html +++ b/src/main/resources/static/route/examcheck/update.html @@ -143,8 +143,8 @@
- - + +