| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.project.common.core.domain.entity.SysUser; |
| | | import com.project.common.exception.base.BaseException; |
| | | import com.project.common.utils.DateUtils; |
| | | import com.project.common.utils.SecurityUtils; |
| | | import com.project.common.utils.StringUtils; |
| | | import com.project.enforce.domain.EnforceCheckLog; |
| | |
| | | import com.project.system.domain.bo.editBo.CheckBo; |
| | | import com.project.system.domain.bo.editBo.SysCompanyBo; |
| | | import com.project.system.service.ISysCompanyService; |
| | | import com.project.system.service.ISysUserService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | public class CheckServiceImpl implements ICheckService |
| | | { |
| | | |
| | | private final ISysUserService userService; |
| | | private final ISysCompanyService companyService; |
| | | private final IEnforceOrderService orderService; |
| | | private final IEnforceCheckLogService checkLogService; |
| | |
| | | @Transactional |
| | | public Boolean checkOrder(CheckBo bo) |
| | | { |
| | | if (StringUtils.isEmpty(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(), order.getApplyDeptId()); |
| | | if (StringUtils.isNotEmpty(phones)){ |
| | | order.setCheckStatus(1); |
| | | //给下一级审批人发送短信 |
| | | smsService.sendApplyMsg(phones, order.getApplyUser()); |
| | | for (Long id : bo.getIds()) { |
| | | SysCompany company = companyService.getById(id); |
| | | if (company==null) { |
| | | throw new BaseException("没有找到对应数据,请检查审核类型!"); |
| | | } |
| | | SysCompanyBo companyBo = new SysCompanyBo(); |
| | | companyBo.setCompanyId(company.getCompanyId()); |
| | | if (company.getCheckStatus()!=0){ |
| | | throw new BaseException("该企业已审批!"); |
| | | } |
| | | if (bo.getCheckStatus()== -1){ |
| | | company.setCheckStatus(-1); |
| | | companyBo.setCompanyStatus(1); |
| | | smsService.sendCompanyCheckMsg(company.getCompanyPhone(), -1); |
| | | } else { |
| | | order.setCheckStatus(2); |
| | | order.setOrderStatus(2); |
| | | //审批通过,给申请人发送短信,如果通知企业也给企业发送短信 |
| | | company.setCheckStatus(2); |
| | | companyBo.setCompanyStatus(0); |
| | | smsService.sendCompanyCheckMsg(company.getCompanyPhone(), 2); |
| | | } |
| | | addCheckLog(company, bo); |
| | | company.setCheckReason(bo.getCheckReason()); |
| | | companyService.updStatus(companyBo); |
| | | companyService.updateById(company); |
| | | } |
| | | return true; |
| | | case 2: |
| | | for (Long id : bo.getIds()) { |
| | | EnforceOrder order = orderService.getById(id); |
| | | if (order==null) { |
| | | throw new BaseException("没有找到对应数据,请检查审核类型!"); |
| | | } |
| | | if (order.getOrderStatus()!=1){ |
| | | throw new BaseException("该执法单已审批"); |
| | | } |
| | | addCheckLog(order, bo); |
| | | if (bo.getCheckStatus()==-1){ |
| | | order.setOrderStatus(-1); |
| | | order.setCheckStatus(-1); |
| | | //审批拒绝,给申请人发送短信,如果通知企业也给企业发送短信 |
| | | smsService.sendCheckMsg(order.getApplyPhone(), order.getCheckStatus()); |
| | | if (order.getIsNoticeCompany()==1){ |
| | | smsService.sendCompanyMsg(order.getCompanyPhone(), order.getApplyDeptName(), order.getPlanTime()); |
| | | orderService.updateById(order); |
| | | } else { |
| | | List<String> phones = orderService.getCheckPhones(order.getCheckLevel()+1, order.getApplyDeptId()); |
| | | if (StringUtils.isNotEmpty(phones)){ |
| | | int checkLevel = Integer.parseInt(phones.get(0)); |
| | | order.setCheckLevel(checkLevel); |
| | | phones.remove(0); |
| | | order.setCheckStatus(1); |
| | | //给下一级审批人发送短信 |
| | | smsService.sendApplyMsg(phones, order.getApplyUser()); |
| | | String checkPhones = StringUtils.join(phones, ","); |
| | | order.setCheckIds(checkPhones); |
| | | order.setCheckReason(bo.getCheckReason()); |
| | | |
| | | return orderService.updateById(order); |
| | | } else { |
| | | order.setCheckStatus(2); |
| | | order.setOrderStatus(2); |
| | | //审批通过,给申请人发送短信,如果通知企业也给企业发送短信 |
| | | smsService.sendCheckMsg(order.getApplyPhone(), order.getCheckStatus()); |
| | | |
| | | if (StringUtils.isEmpty(order.getCompanyCode())){ |
| | | order.setOrderStatus(3); |
| | | order.setInTime(DateUtils.getNowDate()); |
| | | order.setExecuteDeptId(order.getApplyDeptId()); |
| | | order.setExecuteDeptName(order.getApplyDeptName()); |
| | | order.setExecuteUser(order.getApplyUser()); |
| | | order.setExecutePhone(order.getApplyPhone()); |
| | | order.setExecuteId(order.getApplyId()); |
| | | } |
| | | if (order.getIsNoticeCompany()==1 && StringUtils.isNotEmpty(order.getCompanyPhone())){ |
| | | smsService.sendCompanyMsg(order.getCompanyPhone(), order.getApplyDeptName(), order.getPlanTime()); |
| | | } |
| | | |
| | | //审批等级加1 |
| | | order.setCheckLevel(order.getCheckLevel()+1); |
| | | order.setCheckReason(bo.getCheckReason()); |
| | | return orderService.updateById(order); |
| | | } |
| | | } |
| | | //审批等级加1 |
| | | order.setCheckLevel(order.getCheckLevel()+1); |
| | | |
| | | } |
| | | order.setCheckReason(bo.getCheckReason()); |
| | | return orderService.updateById(order); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | |
| | | { |
| | | EnforceCheckLog checkLog = Convert.convert(EnforceCheckLog.class, obj); |
| | | checkLog.setCheckType(bo.getCheckType()); |
| | | SysUser loginUser = SecurityUtils.getLoginUser().getUser(); |
| | | SysUser loginUser = userService.selectUserById(SecurityUtils.getUserId()); |
| | | checkLog.setCheckId(loginUser.getUserId()); |
| | | checkLog.setCheckUser(loginUser.getUserName()); |
| | | checkLog.setCheckUser(loginUser.getNickName()); |
| | | checkLog.setCheckPhone(loginUser.getPhonenumber()); |
| | | checkLog.setCheckStatus(bo.getCheckStatus()); |
| | | checkLog.setCheckStatus(bo.getCheckStatus()>0?1:-1); |
| | | checkLog.setCheckTime(DateUtils.getNowDate()); |
| | | checkLog.setCheckReason(bo.getCheckReason()); |
| | | boolean save = checkLogService.save(checkLog); |
| | | if (!save) { |