| | |
| | | @Transactional |
| | | public Boolean checkOrder(CheckBo bo) |
| | | { |
| | | if (StringUtils.isNotEmpty(bo.getIds())){ |
| | | throw new BaseException("请选择要审批的单据!"); |
| | | } |
| | | switch (bo.getCheckType()) |
| | | { |
| | | case 1: |
| | | SysCompany company = companyService.getById(bo.getId()); |
| | | if (company==null) { |
| | | throw new BaseException("没有找到对应数据,请检查审核类型!"); |
| | | } |
| | | SysCompanyBo companyBo = new SysCompanyBo(); |
| | | companyBo.setCompanyId(company.getCompanyId()); |
| | | if (bo.getCheckStatus()== -1){ |
| | | company.setCheckStatus(-1); |
| | | companyBo.setCompanyStatus(1); |
| | | } else { |
| | | company.setCheckStatus(2); |
| | | companyBo.setCompanyStatus(0); |
| | | } |
| | | addCheckLog(company, bo); |
| | | company.setCheckReason(bo.getCheckReason()); |
| | | companyService.updStatus(companyBo); |
| | | return companyService.updateById(company); |
| | | case 2: |
| | | EnforceOrder order = orderService.getById(bo.getId()); |
| | | if (order==null) { |
| | | throw new BaseException("没有找到对应数据,请检查审核类型!"); |
| | | } |
| | | addCheckLog(order, bo); |
| | | if (bo.getCheckStatus()==-1){ |
| | | order.setCheckStatus(-1); |
| | | //审批拒绝,给申请人发送短信,如果通知企业也给企业发送短信 |
| | | smsService.sendCheckMsg(order.getApplyPhone(), order.getCheckStatus()); |
| | | } else { |
| | | List<String> phones = orderService.getCheckPhones(order.getCheckLevel()+1, order.getApplyDeptId()); |
| | | if (StringUtils.isNotEmpty(phones)){ |
| | | order.setCheckStatus(1); |
| | | //给下一级审批人发送短信 |
| | | smsService.sendApplyMsg(phones, order.getApplyUser()); |
| | | String checkPhones = StringUtils.join(phones, ","); |
| | | orderService.update(orderService.lu().set(EnforceOrder::getCheckIds, checkPhones).eq(EnforceOrder::getOrderId, order.getOrderId())); |
| | | } else { |
| | | order.setCheckStatus(2); |
| | | order.setOrderStatus(2); |
| | | //审批通过,给申请人发送短信,如果通知企业也给企业发送短信 |
| | | smsService.sendCheckMsg(order.getApplyPhone(), order.getCheckStatus()); |
| | | if (order.getIsNoticeCompany()==1){ |
| | | smsService.sendCompanyMsg(order.getCompanyPhone(), order.getApplyDeptName(), order.getPlanTime()); |
| | | } |
| | | for (Long id : bo.getIds()) { |
| | | SysCompany company = companyService.getById(id); |
| | | if (company==null) { |
| | | throw new BaseException("没有找到对应数据,请检查审核类型!"); |
| | | } |
| | | //审批等级加1 |
| | | order.setCheckLevel(order.getCheckLevel()+1); |
| | | SysCompanyBo companyBo = new SysCompanyBo(); |
| | | companyBo.setCompanyId(company.getCompanyId()); |
| | | if (bo.getCheckStatus()== -1){ |
| | | company.setCheckStatus(-1); |
| | | companyBo.setCompanyStatus(1); |
| | | } else { |
| | | company.setCheckStatus(2); |
| | | companyBo.setCompanyStatus(0); |
| | | } |
| | | addCheckLog(company, bo); |
| | | company.setCheckReason(bo.getCheckReason()); |
| | | companyService.updStatus(companyBo); |
| | | companyService.updateById(company); |
| | | } |
| | | order.setCheckReason(bo.getCheckReason()); |
| | | return orderService.updateById(order); |
| | | return true; |
| | | case 2: |
| | | for (Long id : bo.getIds()) { |
| | | EnforceOrder order = orderService.getById(id); |
| | | if (order==null) { |
| | | throw new BaseException("没有找到对应数据,请检查审核类型!"); |
| | | } |
| | | addCheckLog(order, bo); |
| | | if (bo.getCheckStatus()==-1){ |
| | | order.setCheckStatus(-1); |
| | | //审批拒绝,给申请人发送短信,如果通知企业也给企业发送短信 |
| | | smsService.sendCheckMsg(order.getApplyPhone(), order.getCheckStatus()); |
| | | } else { |
| | | List<String> phones = orderService.getCheckPhones(order.getCheckLevel()+1, order.getApplyDeptId()); |
| | | if (StringUtils.isNotEmpty(phones)){ |
| | | order.setCheckStatus(1); |
| | | //给下一级审批人发送短信 |
| | | smsService.sendApplyMsg(phones, order.getApplyUser()); |
| | | String checkPhones = StringUtils.join(phones, ","); |
| | | orderService.update(orderService.lu().set(EnforceOrder::getCheckIds, checkPhones).eq(EnforceOrder::getOrderId, order.getOrderId())); |
| | | } else { |
| | | order.setCheckStatus(2); |
| | | order.setOrderStatus(2); |
| | | //审批通过,给申请人发送短信,如果通知企业也给企业发送短信 |
| | | smsService.sendCheckMsg(order.getApplyPhone(), order.getCheckStatus()); |
| | | if (order.getIsNoticeCompany()==1){ |
| | | smsService.sendCompanyMsg(order.getCompanyPhone(), order.getApplyDeptName(), order.getPlanTime()); |
| | | } |
| | | } |
| | | //审批等级加1 |
| | | order.setCheckLevel(order.getCheckLevel()+1); |
| | | order.setCheckReason(bo.getCheckReason()); |
| | | orderService.updateById(order); |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |