gongdecai 3 lat temu
rodzic
commit
14b9025dc1

+ 1 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/GeneratorCodeByTables.java

@@ -53,7 +53,7 @@ public class GeneratorCodeByTables {
     }
 
     public static void main(String[] args) throws IOException {
-        generateByTables("Gongdc", "com.yh.saas.plugin.yiliangyiyun","customer_info");
+        generateByTables("Gongdc", "com.yh.saas.plugin.yiliangyiyun","identity_authentication_info");
     }
 
     /**

+ 2 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/exception/YExceptionEnum.java

@@ -27,7 +27,8 @@ public enum YExceptionEnum {
 	PAYEE_NUMBER_ERROR("ERROR", "收款人身份证号重复,不可添加!"),
 	INTERVER_WORKFLOW_ERROR("INTERVIEW-001", "出入库任务审核没有可以进行的工作流!"),
 	FAILED_TO_EXAMINE("ERROR","该身份认证还未通过审核,无法更换手机号"),
-	AUTHENTICATION_INFORMATION_CHANGE_FAILED("ERROR","身份认证状态审核中或已通过审核,无法更改身份认证信息")
+	AUTHENTICATION_INFORMATION_CHANGE_FAILED("ERROR","身份认证状态审核中或已通过审核,无法更改身份认证信息"),
+	PURCHASE_ORDER_ERROR("PURCHASE-001", "采购订单审核没有可以进行的工作流!"),
 	;
 	@Getter
 	private String value;

+ 30 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/PurchaseOrderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
 
+import com.winsea.svc.base.workflow.entity.Workflow;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
 import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
@@ -9,6 +10,8 @@ import com.yh.saas.plugin.yiliangyiyun.entity.*;
 import com.yh.saas.plugin.yiliangyiyun.exception.AppServiceException;
 import com.yh.saas.plugin.yiliangyiyun.exception.ExceptionDefinition;
 import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
+import com.yh.saas.plugin.yiliangyiyun.exception.YException;
+import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
 import com.yh.saas.plugin.yiliangyiyun.mapper.PurchaseOrderMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.IPriceChangeRecordService;
 import com.yh.saas.plugin.yiliangyiyun.entity.PurchaseOrder;
@@ -20,6 +23,7 @@ import com.yh.saas.plugin.yiliangyiyun.service.IPurchaseOrderService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import com.yh.saas.plugin.yiliangyiyun.service.ITransactionRecordService;
 import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseInOutInfoService;
+import com.yh.saas.toolkit.workflow.service.IWorkflowService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -48,7 +52,8 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
     private IPriceChangeRecordService priceChangeRecordService;
     @Autowired
     private IWarehouseInOutInfoService warehouseInOutInfoService;
-
+    @Autowired
+    private IWorkflowService workflowService;
     /**
      * 成交
      */
@@ -305,6 +310,30 @@ public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper, P
         purchaseOrder.setId(IdGenerator.generateUUID());
         // 操作主表数据
         boolean one = this.insert(purchaseOrder);
+        boolean isStartWorkflow = StringUtils.isBlank(purchaseOrder.getWorkflowId());
+        // 不是退回的单子
+        if (isStartWorkflow) {
+            Workflow workflow = workflowService
+                    .findLatestWorkflowByBusinessCode("PURCHASE-ORDER-APPROVE");
+            // 没配置审核流程,直接结束并处理信息
+            if (workflow == null) {
+                throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+            }
+            // 开启审核流
+            else {
+
+                // 设置状态 已提交审核
+                purchaseOrder.setWorkflowId(workflow.getId());
+                this.updateById(purchaseOrder);
+                workflowService.startInstance(workflow.getId(), purchaseOrder.getId());
+            }
+        }
+        // 退回的单子 再启用
+        else {
+
+            this.updateById(purchaseOrder);
+            workflowService.activateInstance(purchaseOrder.getWorkflowId(), purchaseOrder.getId());
+        }
         if (one) {
             return "OK";
         }else{