| | |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * ERP 采购订单 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | /** |
| | | * BPM 采购订单审批分类编码 |
| | | */ |
| | | private static final String PURCHASE_ORDER_APPROVE_CATEGORY_CODE = "purchase_request_approve"; |
| | | private static final String PURCHASE_ORDER_APPROVE_CATEGORY_CODE = "purchase_order_approve"; |
| | | /** |
| | | * BPM 采购订单审批流程定义 Key(创建订单后自动提交到协同办公审批) |
| | | */ |
| | | private static final String PURCHASE_ORDER_APPROVE_PROCESS_DEFINITION_KEY = "purchase_order_approve"; |
| | | |
| | | @Resource |
| | | private ErpPurchaseOrderMapper purchaseOrderMapper; |
| | |
| | | // 2.3 绑定附件 |
| | | storageAttachmentApi.bindAttachments("file", "erp_purchase_order", |
| | | purchaseOrder.getId(), createReqVO.getBlobIds()); |
| | | |
| | | // 3. 创建后自动提交审批到协同办公(审批在协同办公完成,不在本页面审批) |
| | | submitPurchaseOrder(purchaseOrder.getId(), PURCHASE_ORDER_APPROVE_PROCESS_DEFINITION_KEY, getLoginUserId()); |
| | | |
| | | return purchaseOrder.getId(); |
| | | } |
| | | |
| | |
| | | if (BpmTaskStatusEnum.APPROVE.getStatus().equals(bpmResult)) { |
| | | return ErpAuditStatus.APPROVE.getStatus(); |
| | | } else if (BpmTaskStatusEnum.REJECT.getStatus().equals(bpmResult)) { |
| | | return ErpAuditStatus.PROCESS.getStatus(); |
| | | return ErpAuditStatus.REJECT.getStatus(); |
| | | } else if (BpmTaskStatusEnum.CANCEL.getStatus().equals(bpmResult)) { |
| | | return ErpAuditStatus.CANCEL.getStatus(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ErpPurchaseOrderDO getPurchaseOrderByProcessInstanceId(String processInstanceId) { |
| | | return purchaseOrderMapper.selectByProcessInstanceId(processInstanceId); |
| | | } |
| | | |
| | | @Override |
| | | public ErpPurchaseOrderDO validatePurchaseOrder(Long id) { |
| | | ErpPurchaseOrderDO purchaseOrder = validatePurchaseOrderExists(id); |
| | | if (ObjectUtil.notEqual(purchaseOrder.getStatus(), ErpAuditStatus.APPROVE.getStatus())) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ErpPurchaseOrderDO> getPurchaseOrderListBySource(Integer sourceType, Long sourceId) { |
| | | if (sourceType == null || sourceId == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return purchaseOrderMapper.selectListBySource(sourceType, sourceId); |
| | | } |
| | | |
| | | @Override |
| | | public void updatePurchaseOrderInStatus(Long orderId) { |
| | | // 1. 获取采购订单 |
| | | ErpPurchaseOrderDO order = validatePurchaseOrderExists(orderId); |