| | |
| | | import com.ruoyi.approve.bean.vo.ApprovalInstanceVo; |
| | | import com.ruoyi.approve.mapper.ApprovalInstanceMapper; |
| | | import com.ruoyi.approve.mapper.ApprovalTemplateNodeApproverMapper; |
| | | import com.ruoyi.approve.mapper.FinReimbursementDetailMapper; |
| | | import com.ruoyi.approve.mapper.FinReimbursementMapper; |
| | | import com.ruoyi.approve.mapper.FinReimbursementTravelMapper; |
| | | import com.ruoyi.approve.pojo.*; |
| | | import com.ruoyi.approve.service.*; |
| | | import com.ruoyi.approve.utils.ApproveProcessConfigNodeUtils; |
| | |
| | | import com.ruoyi.collaborativeApproval.pojo.EnterpriseNewsScopeDept; |
| | | import com.ruoyi.collaborativeApproval.pojo.EnterpriseNewsScopeUser; |
| | | import com.ruoyi.common.enums.*; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | |
| | | private final EnterpriseNewsMapper enterpriseNewsMapper; |
| | | private final EnterpriseNewsScopeDeptMapper enterpriseNewsScopeDeptMapper; |
| | | private final ApprovalTemplateNodeApproverMapper approvalTemplateNodeApproverMapper; |
| | | private final FinReimbursementDetailMapper finReimbursementDetailMapper; |
| | | private final FinReimbursementTravelMapper finReimbursementTravelMapper; |
| | | |
| | | @Override |
| | | public R listPage(Page<ApprovalInstanceVo> page, ApprovalInstanceDto approvalInstanceDto) { |
| | |
| | | approvalInstanceDto.setInstanceNo(instanceNo); |
| | | approvalInstanceDto.setStatus("PENDING"); |
| | | approvalInstanceDto.setCurrentLevel(1); |
| | | // 如果前端传了 applicantId 但没传 applicantName,则从用户表查询姓名 |
| | | if (approvalInstanceDto.getApplicantId() != null && !StringUtils.hasText(approvalInstanceDto.getApplicantName())) { |
| | | SysUser applicantUser = sysUserMapper.selectUserById(approvalInstanceDto.getApplicantId()); |
| | | if (applicantUser != null) { |
| | | approvalInstanceDto.setApplicantName(applicantUser.getNickName()); |
| | | } |
| | | } |
| | | boolean saved = this.save(approvalInstanceDto); |
| | | if (!saved) { |
| | | return false; |
| | |
| | | if (approvalInstanceDto == null || approvalInstanceDto.getId() == null) { |
| | | return false; |
| | | } |
| | | // 判断是否有正在进行的审批任务,有则不允许修改 |
| | | long pendingTaskCount = approvalTaskService.count( |
| | | Wrappers.<ApprovalTask>lambdaQuery() |
| | | .eq(ApprovalTask::getInstanceId, approvalInstanceDto.getId()) |
| | | .eq(ApprovalTask::getTaskStatus, "PENDING") |
| | | .eq(ApprovalTask::getDeleted, 0) |
| | | ); |
| | | if (pendingTaskCount > 0) { |
| | | throw new ServiceException("该审批单有正在进行的审批任务,不允许修改"); |
| | | } |
| | | boolean updated = this.updateById(approvalInstanceDto); |
| | | if (!updated) { |
| | | return false; |
| | |
| | | if (ids == null || ids.isEmpty()) { |
| | | return false; |
| | | } |
| | | |
| | | // 删除关联的业务数据(报销单等) |
| | | List<Long> reimbursementIds = new ArrayList<>(); |
| | | List<ApprovalInstance> instances = approvalInstanceMapper.selectBatchIds(ids); |
| | | for (ApprovalInstance instance : instances) { |
| | | if (instance.getBusinessId() != null && instance.getBusinessType() != null) { |
| | | Long businessType = instance.getBusinessType(); |
| | | if (TypeEnums.TRAVEL_REIMBURSEMENT_APPROVAL.getCode().equals(businessType) |
| | | || TypeEnums.EXPENSE_APPROVAL.getCode().equals(businessType)) { |
| | | reimbursementIds.add(instance.getBusinessId()); |
| | | } |
| | | } |
| | | } |
| | | if (!reimbursementIds.isEmpty()) { |
| | | fileUtil.deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum.FILE, RecordTypeEnum.FIN_REIMBURSEMENT, reimbursementIds); |
| | | finReimbursementDetailMapper.delete(Wrappers.<FinReimbursementDetail>lambdaQuery().in(FinReimbursementDetail::getReimbursementId, reimbursementIds)); |
| | | finReimbursementTravelMapper.delete(Wrappers.<FinReimbursementTravel>lambdaQuery().in(FinReimbursementTravel::getReimbursementId, reimbursementIds)); |
| | | finReimbursementMapper.delete(Wrappers.<FinReimbursement>lambdaQuery().in(FinReimbursement::getId, reimbursementIds)); |
| | | } |
| | | |
| | | fileUtil.deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVAL_INSTANCE, ids); |
| | | |
| | | int instanceRows = approvalInstanceMapper.update( |
| | |
| | | |
| | | String title = StringUtils.hasText(instance.getTemplateName()) ? instance.getTemplateName() : "审批提醒"; |
| | | String message = "审批单号 " + instance.getInstanceNo() + " 需要您审批"; |
| | | String jumpPath = "/approvalInstance?id=" + instance.getId(); |
| | | String jumpPath = "/officeProcessAutomation/ApproveManage/approve-list?id=" + instance.getId(); |
| | | sysNoticeService.simpleNoticeByUser(title, message, approverIds, jumpPath); |
| | | } |
| | | |
| | |
| | | } |
| | | String title = "企业新闻"; |
| | | String message = "您有新的企业新闻《" + enterpriseNews.getTitle() + "》请及时查阅"; |
| | | String jumpPath = "/enterpriseNews?id=" + newsId; |
| | | String jumpPath = "/officeProcessAutomation/EnterpriseNews?id=" + newsId; |
| | | sysNoticeService.simpleNoticeByUser(title, message, userIds, jumpPath); |
| | | } |
| | | |