| | |
| | | Page<OrderInfo> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize()); |
| | | |
| | | // 基于workFlowType查询流程实例ID集合 |
| | | List<String> workFlowIds = fetchWorkflowProcessInstanceIds( |
| | | List<Object> workFlowsList = fetchWorkflowProcessInstanceIds( |
| | | queryDTO.getWorkFlowType(), |
| | | queryDTO.getUserId(), |
| | | queryDTO.getDepartmentId(), |
| | |
| | | ); |
| | | |
| | | // 如果没有任何流程ID,直接返回空分页 |
| | | if (workFlowIds == null || workFlowIds.isEmpty()) { |
| | | if (workFlowsList == null || workFlowsList.isEmpty()) { |
| | | return new PageResult<OrderDetailVO>( |
| | | java.util.Collections.emptyList(), |
| | | 0L, |
| | |
| | | 0L |
| | | ); |
| | | } |
| | | |
| | | List<String> workFlowIds = workFlowsList.stream() |
| | | .filter(item -> item instanceof Map) |
| | | .map(item -> (Map<?, ?>) item) |
| | | .map(m -> m.get("processInstanceId")) |
| | | .filter(Objects::nonNull) |
| | | .map(Object::toString) |
| | | .collect(Collectors.toList()); |
| | | |
| | | Map<String,String> workFlowIdAndTaskIdMap = workFlowsList.stream() |
| | | .filter(item -> item instanceof Map) |
| | | .map(item -> (Map<?, ?>) item).collect(Collectors.toMap(m -> m.get("processInstanceId").toString(), m -> m.get("taskId").toString(),(k1,k2) -> k2)); |
| | | |
| | | // 执行分页查询 |
| | | IPage<OrderInfo> result = baseMapper.selectPendingApprovalOrderPage( |
| | |
| | | return item; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | vo.setOrderDetails(items); |
| | | vo.setTaskId(workFlowIdAndTaskIdMap.get(vo.getWorkflowId())); |
| | | return vo; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<OrderInfo> getPendingApprovalOrderPageWithProductConditions(OrderQueryDTO queryDTO) { |
| | | public PageResult<OrderDetailVO> getPendingApprovalOrderPageWithProductConditions(OrderQueryDTO queryDTO) { |
| | | // 根据产品条件查询产品ID列表 |
| | | List<String> productIds = null; |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || StringUtils.hasText(queryDTO.getUnitProjectId()) || |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || queryDTO.getUnitProjectId() != null || |
| | | StringUtils.hasText(queryDTO.getProductTypeId()) || StringUtils.hasText(queryDTO.getProductSubTypeId())) { |
| | | productIds = reportResultSubmissionMapper.selectProductIdsByConditions( |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), queryDTO.getImportantDistrictId(), |
| | | queryDTO.getProductTypeId(), queryDTO.getProductSubTypeId() |
| | | ); |
| | | |
| | | // 如果没有找到匹配的产品,直接返回空结果 |
| | | if (CollectionUtils.isEmpty(productIds)) { |
| | | return new PageResult<OrderInfo>( |
| | | return new PageResult<OrderDetailVO>( |
| | | java.util.Collections.emptyList(), |
| | | 0L, |
| | | queryDTO.getPageNum().longValue(), |
| | |
| | | |
| | | // 执行分页查询 |
| | | // 基于workFlowType查询流程实例ID集合 |
| | | List<String> workFlowIds = fetchWorkflowProcessInstanceIds( |
| | | List<?> workFlowList = fetchWorkflowProcessInstanceIds( |
| | | queryDTO.getWorkFlowType(), |
| | | queryDTO.getUserId(), |
| | | queryDTO.getDepartmentId(), |
| | |
| | | queryDTO.getPageNum(), |
| | | queryDTO.getPageSize() |
| | | ); |
| | | |
| | | // 如果没有任何流程ID,直接返回空分页 |
| | | if (workFlowIds == null || workFlowIds.isEmpty()) { |
| | | return new PageResult<OrderInfo>( |
| | | java.util.Collections.emptyList(), |
| | | 0L, |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | 0L |
| | | if (workFlowList == null || workFlowList.isEmpty()) { |
| | | return new PageResult<OrderDetailVO>( |
| | | java.util.Collections.emptyList(), |
| | | 0L, |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | | 0L |
| | | ); |
| | | } |
| | | |
| | | List<String> workFlowIds = workFlowList.stream() |
| | | .filter(item -> item instanceof Map) |
| | | .map(item -> (Map<?, ?>) item) |
| | | .map(m -> m.get("processInstanceId")) |
| | | .filter(Objects::nonNull) |
| | | .map(Object::toString) |
| | | .collect(Collectors.toList()); |
| | | |
| | | Map<String,String> workFlowIdAndTaskIdMap = workFlowList.stream() |
| | | .filter(item -> item instanceof Map) |
| | | .map(item -> (Map<?, ?>) item).collect(Collectors.toMap(m -> m.get("processInstanceId").toString(), m -> m.get("taskId").toString(),(k1,k2) -> k2)); |
| | | |
| | | |
| | | IPage<OrderInfo> result = baseMapper.selectPendingApprovalOrderPageWithProductConditions( |
| | | page, queryDTO.getOrderStatus(), queryDTO.getProductName(), queryDTO.getProviderName(), |
| | |
| | | queryDTO.getApplyTimeEnd() != null ? queryDTO.getApplyTimeEnd().toString() : null, |
| | | queryDTO.getOrderBy(), queryDTO.getOrderDirection(), productIds, workFlowIds |
| | | ); |
| | | // 将订单与详情联表封装到VO |
| | | List<OrderDetailVO> voList = result.getRecords().stream().map(order -> { |
| | | OrderDetailVO vo = new OrderDetailVO(); |
| | | BeanUtils.copyProperties(order, vo); |
| | | List<OrderDetail> details = orderDetailMapper.selectByOrderId(order.getOrderId()); |
| | | List<OrderDetailItemVO> items = details.stream().map(d -> { |
| | | OrderDetailItemVO item = new OrderDetailItemVO(); |
| | | BeanUtils.copyProperties(d, item); |
| | | return item; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | vo.setOrderDetails(items); |
| | | vo.setTaskId(workFlowIdAndTaskIdMap.get(vo.getWorkflowId())); |
| | | return vo; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | |
| | | // 构建返回结果 |
| | | return new PageResult<OrderInfo>( |
| | | result.getRecords(), |
| | | return new PageResult<OrderDetailVO>( |
| | | voList, |
| | | result.getTotal(), |
| | | queryDTO.getPageNum().longValue(), |
| | | queryDTO.getPageSize().longValue(), |
| | |
| | | |
| | | // 根据产品条件查询产品ID列表 |
| | | List<String> productIds = null; |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || StringUtils.hasText(queryDTO.getUnitProjectId()) || |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || queryDTO.getUnitProjectId() != null || |
| | | StringUtils.hasText(queryDTO.getProductTypeId()) || StringUtils.hasText(queryDTO.getProductSubTypeId())) { |
| | | productIds = reportResultSubmissionMapper.selectProductIdsByConditions( |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), queryDTO.getImportantDistrictId(), |
| | | queryDTO.getProductTypeId(), queryDTO.getProductSubTypeId() |
| | | ); |
| | | |
| | |
| | | |
| | | // 根据产品条件查询产品ID列表 |
| | | List<String> productIds = null; |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || StringUtils.hasText(queryDTO.getUnitProjectId()) || |
| | | if (StringUtils.hasText(queryDTO.getIndustryId()) || queryDTO.getUnitProjectId()!= null || |
| | | StringUtils.hasText(queryDTO.getProductTypeId()) || StringUtils.hasText(queryDTO.getProductSubTypeId())) { |
| | | productIds = reportResultSubmissionMapper.selectProductIdsByConditions( |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), |
| | | queryDTO.getIndustryId(), queryDTO.getUnitProjectId(), queryDTO.getImportantDistrictId(), |
| | | queryDTO.getProductTypeId(), queryDTO.getProductSubTypeId() |
| | | ); |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long uploadOrderAttachment(String orderId, String fileName, String originalName, |
| | | String fileType, Long fileSize, String fileUrl, |
| | | String bucketName, String objectName, Long uploadUserId, |
| | | String bucketName, String objectName, String uploadUserId, |
| | | String uploadUserName, String attachmentType, String description) { |
| | | // 参数校验 |
| | | if (!StringUtils.hasText(orderId)) { |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addOrderEvaluation(String orderId, Long evaluatorId, String evaluatorName, |
| | | public boolean addOrderEvaluation(String orderId, String evaluatorId, String evaluatorName, |
| | | String evaluatorType, String content, Integer rating, |
| | | Integer serviceRating, Integer qualityRating, Integer deliveryRating, |
| | | Boolean isAnonymous) { |
| | |
| | | // 根据审批结果调用提交或驳回接口 |
| | | String comment = orderApprovalDTO.getApprovalResult().contains("驳回") ? "审核驳回" : "审核通过"; |
| | | if ("审核驳回".equals(comment)) { |
| | | rejectWorkflowTask(orderInfo.getTaskId(), String.valueOf(orderApprovalDTO.getApproverId()), comment); |
| | | rejectWorkflowTask(orderApprovalDTO.getTaskId(), String.valueOf(orderApprovalDTO.getApproverId()), orderApprovalDTO.getApprovalOpinion()); |
| | | } else { |
| | | completeWorkflowTask(orderInfo.getTaskId(), String.valueOf(orderApprovalDTO.getApproverId()), comment); |
| | | completeWorkflowTask(orderApprovalDTO.getTaskId(), String.valueOf(orderApprovalDTO.getApproverId()), orderApprovalDTO.getApprovalOpinion()); |
| | | } |
| | | |
| | | log.info("审批记录添加成功,订单ID: {}, 审批类型: {}, 审批结果: {}, 审批人: {}, 审批意见: {}", |
| | |
| | | try { |
| | | // 1. 删除订单附件(包括MinIO文件和数据库记录) |
| | | log.info("开始删除订单附件,订单ID: {}", orderId); |
| | | List<OrderAttachment> attachments = orderAttachmentMapper.selectByOrderId(orderId); |
| | | for (OrderAttachment attachment : attachments) { |
| | | try { |
| | | // 删除MinIO中的文件 |
| | | if (StringUtils.hasText(attachment.getObjectName())) { |
| | | log.info("删除MinIO文件,对象名称: {}", attachment.getObjectName()); |
| | | minioService.deleteFile(attachment.getObjectName()); |
| | | } |
| | | // 删除数据库记录 |
| | | orderAttachmentMapper.deleteById(attachment.getId()); |
| | | log.info("删除附件记录成功,附件ID: {}", attachment.getId()); |
| | | } catch (Exception e) { |
| | | log.error("删除附件失败,附件ID: {}, 错误: {}", attachment.getId(), e.getMessage()); |
| | | // 继续删除其他附件,不中断整个流程 |
| | | } |
| | | } |
| | | // List<OrderAttachment> attachments = orderAttachmentMapper.selectByOrderId(orderId); |
| | | // for (OrderAttachment attachment : attachments) { |
| | | // try { |
| | | // // 删除MinIO中的文件 |
| | | // if (StringUtils.hasText(attachment.getObjectName())) { |
| | | // log.info("删除MinIO文件,对象名称: {}", attachment.getObjectName()); |
| | | // minioService.deleteFile(attachment.getObjectName()); |
| | | // } |
| | | // // 删除数据库记录 |
| | | // orderAttachmentMapper.deleteById(attachment.getId()); |
| | | // log.info("删除附件记录成功,附件ID: {}", attachment.getId()); |
| | | // } catch (Exception e) { |
| | | // log.error("删除附件失败,附件ID: {}, 错误: {}", attachment.getId(), e.getMessage()); |
| | | // // 继续删除其他附件,不中断整个流程 |
| | | // } |
| | | // } |
| | | |
| | | // 2. 逻辑删除订单详情 |
| | | log.info("开始逻辑删除订单详情,订单ID: {}", orderId); |
| | | // log.info("开始逻辑删除订单详情,订单ID: {}", orderId); |
| | | // 先查询订单详情列表,然后逐个逻辑删除 |
| | | List<OrderDetail> orderDetails = orderDetailMapper.selectByOrderId(orderId); |
| | | int detailDeleted = 0; |
| | | for (OrderDetail detail : orderDetails) { |
| | | int result = orderDetailMapper.deleteById(detail.getId()); |
| | | if (result > 0) { |
| | | detailDeleted++; |
| | | } |
| | | } |
| | | log.info("逻辑删除订单详情完成,影响行数: {}", detailDeleted); |
| | | // List<OrderDetail> orderDetails = orderDetailMapper.selectByOrderId(orderId); |
| | | // int detailDeleted = 0; |
| | | // for (OrderDetail detail : orderDetails) { |
| | | // int result = orderDetailMapper.deleteById(detail.getId()); |
| | | // if (result > 0) { |
| | | // detailDeleted++; |
| | | // } |
| | | // } |
| | | // log.info("逻辑删除订单详情完成,影响行数: {}", detailDeleted); |
| | | |
| | | // 3. 删除订单信息(逻辑删除) |
| | | log.info("开始删除订单信息,订单ID: {}", orderId); |
| | | int orderDeleted = this.baseMapper.deleteById(orderId); |
| | | log.info("删除订单信息完成,影响行数: {}", orderDeleted); |
| | | // log.info("开始删除订单信息,订单ID: {}", orderId); |
| | | // int orderDeleted = this.baseMapper.deleteById(orderId); |
| | | // log.info("删除订单信息完成,影响行数: {}", orderDeleted); |
| | | // 更新订单状态为已完成 |
| | | orderInfo.setOrderStatus("已取消"); |
| | | orderInfo.setUpdatedAt(LocalDateTime.now()); |
| | | int orderDeleted = this.baseMapper.updateById(orderInfo); |
| | | |
| | | if (orderDeleted > 0) { |
| | | log.info("订单取消成功,订单ID: {}", orderId); |
| | | return true; |
| | | } else { |
| | | log.error("删除订单信息失败,影响行数为0,订单ID: {}", orderId); |
| | | log.error("更新订单信息失败,影响行数为0,订单ID: {}", orderId); |
| | | throw new BusinessException("删除订单信息失败"); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | * 按照workFlowType查询流程实例ID集合 |
| | | * workFlowType: 0=代办,1=已办 |
| | | */ |
| | | private List<String> fetchWorkflowProcessInstanceIds(Integer workFlowType, String userId, String depId,String businessKey,Integer pageIndex, Integer pageSize) { |
| | | private List<Object> fetchWorkflowProcessInstanceIds(Integer workFlowType, String userId, String depId,String businessKey,Integer pageIndex, Integer pageSize) { |
| | | try { |
| | | if (workFlowType == null) { |
| | | return java.util.Collections.emptyList(); |
| | |
| | | if (!(dataObj instanceof java.util.List)) { |
| | | return java.util.Collections.emptyList(); |
| | | } |
| | | java.util.List<?> list = (java.util.List<?>) dataObj; |
| | | return list.stream() |
| | | .filter(item -> item instanceof Map) |
| | | .map(item -> (Map<?, ?>) item) |
| | | .map(m -> m.get("processInstanceId")) |
| | | .filter(Objects::nonNull) |
| | | .map(Object::toString) |
| | | .collect(Collectors.toList()); |
| | | java.util.List<Object> list = (java.util.List<Object>) dataObj; |
| | | return list; |
| | | // list.stream() |
| | | // .filter(item -> item instanceof Map) |
| | | // .map(item -> (Map<?, ?>) item) |
| | | // .map(m -> m.get("processInstanceId")) |
| | | // .filter(Objects::nonNull) |
| | | // .map(Object::toString) |
| | | // .collect(Collectors.toList()); |
| | | }else { |
| | | if (!(dataObj instanceof Map)) { |
| | | return java.util.Collections.emptyList(); |
| | | } |
| | | Map<?,?> map = (Map<?,?>) dataObj; |
| | | Object dataObj1 = ((Map<?, ?>) dataObj).get("list"); |
| | | java.util.List<?> list = (java.util.List<?>) dataObj1; |
| | | return list.stream() |
| | | .filter(item -> item instanceof Map) |
| | | .map(item -> (Map<?, ?>) item) |
| | | .map(m -> m.get("processInstanceId")) |
| | | .filter(Objects::nonNull) |
| | | .map(Object::toString) |
| | | .collect(Collectors.toList()); |
| | | java.util.List<Object> list = (java.util.List<Object>) dataObj1; |
| | | return list; |
| | | // list.stream() |
| | | // .filter(item -> item instanceof Map) |
| | | // .map(item -> (Map<?, ?>) item) |
| | | // .map(m -> m.get("processInstanceId")) |
| | | // .filter(Objects::nonNull) |
| | | // .map(Object::toString) |
| | | // .collect(Collectors.toList()); |
| | | } |
| | | |
| | | } catch (Exception e) { |