|
@@ -1,18 +1,26 @@
|
|
package com.fjhx.service.example.impl;
|
|
package com.fjhx.service.example.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
-import com.fjhx.utils.WrapperUtil;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.fjhx.constants.FlowConstant;
|
|
|
|
+import com.fjhx.constants.FlowExplainConstant;
|
|
|
|
+import com.fjhx.constants.StatusConstant;
|
|
import com.fjhx.entity.example.ExampleInfo;
|
|
import com.fjhx.entity.example.ExampleInfo;
|
|
-import com.fjhx.params.example.ExampleInfoVo;
|
|
|
|
|
|
+import com.fjhx.entity.process.ProcessInfo;
|
|
|
|
+import com.fjhx.entity.process.ProcessNodeButton;
|
|
|
|
+import com.fjhx.entity.process.ProcessTenant;
|
|
import com.fjhx.mapper.example.ExampleInfoMapper;
|
|
import com.fjhx.mapper.example.ExampleInfoMapper;
|
|
import com.fjhx.service.example.ExampleInfoService;
|
|
import com.fjhx.service.example.ExampleInfoService;
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
+import com.fjhx.service.process.ProcessInfoService;
|
|
|
|
+import com.fjhx.service.process.ProcessNodeButtonService;
|
|
|
|
+import com.fjhx.service.process.ProcessTenantService;
|
|
|
|
+import com.fjhx.utils.Assert;
|
|
|
|
+import com.fjhx.utils.ExampleAbstract;
|
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Map;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 流程实例 服务实现类
|
|
* 流程实例 服务实现类
|
|
@@ -24,5 +32,77 @@ import java.util.Map;
|
|
@Service
|
|
@Service
|
|
public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, ExampleInfo> implements ExampleInfoService {
|
|
public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, ExampleInfo> implements ExampleInfoService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProcessTenantService processTenantService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProcessInfoService processInfoService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProcessNodeButtonService processNodeButtonService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ExampleInfo create(Long businessId, ExampleAbstract exampleAbstract) {
|
|
|
|
+
|
|
|
|
+ // 查看流程是否已发起
|
|
|
|
+ Assert.notEmpty(
|
|
|
|
+ getOne(Wrappers.<ExampleInfo>lambdaQuery()
|
|
|
|
+ .eq(ExampleInfo::getBusinessId, businessId).eq(ExampleInfo::getComplete, StatusConstant.No)),
|
|
|
|
+ FlowExplainConstant.EXPLAIN_NOT_EXIST);
|
|
|
|
+
|
|
|
|
+ // 获取流程编码
|
|
|
|
+ String code = exampleAbstract.getCode();
|
|
|
|
+
|
|
|
|
+ // 查找通用流程
|
|
|
|
+ ProcessInfo processInfo = processInfoService.getOne(ProcessInfo::getCode, code);
|
|
|
|
+ Assert.notEmpty(processInfo, String.format(FlowExplainConstant.PROCESS_NOT_EXIST, code));
|
|
|
|
+ Long processInfoId = processInfo.getId();
|
|
|
|
+
|
|
|
|
+ // 获取租户流程
|
|
|
|
+ ProcessTenant processTenant = processTenantService.getOne(Wrappers.<ProcessTenant>lambdaQuery()
|
|
|
|
+ .eq(ProcessTenant::getProcessInfoId, processInfoId)
|
|
|
|
+ .eq(ProcessTenant::getBindingTenantId, AuthUtil.getTenantId())
|
|
|
|
+ .eq(ProcessTenant::getCurrentVersion, StatusConstant.YES)
|
|
|
|
+ .last("limit 1"));
|
|
|
|
+
|
|
|
|
+ ExampleInfo exampleInfo = new ExampleInfo();
|
|
|
|
+ exampleInfo.setProcessInfoId(processInfoId);
|
|
|
|
+ exampleInfo.setBusinessId(businessId);
|
|
|
|
+ exampleInfo.setCacheData(exampleAbstract.getCacheData());
|
|
|
|
+
|
|
|
|
+ // 如果租户流程为空,直接结束流程
|
|
|
|
+ if (ObjectUtil.isEmpty(processTenant)) {
|
|
|
|
+ exampleInfo.setProcessNodeId(FlowConstant.OVER_PROCESS_FLAG);
|
|
|
|
+ exampleInfo.setComplete(StatusConstant.YES);
|
|
|
|
+
|
|
|
|
+ // 执行流程结束方法
|
|
|
|
+ exampleAbstract.end();
|
|
|
|
+ } else {
|
|
|
|
+ Long processTenantId = processTenant.getId();
|
|
|
|
+ exampleInfo.setProcessTenantId(processTenantId);
|
|
|
|
+
|
|
|
|
+ ProcessNodeButton processNodeButton = processNodeButtonService.getOne(
|
|
|
|
+ Wrappers.<ProcessNodeButton>lambdaQuery()
|
|
|
|
+ .eq(ProcessNodeButton::getProcessTenantId, processTenantId)
|
|
|
|
+ .eq(ProcessNodeButton::getProcessNodeCode, FlowConstant.START_CODE));
|
|
|
|
+
|
|
|
|
+ Long jumpNodeId = processNodeButton.getJumpNodeId();
|
|
|
|
+
|
|
|
|
+ // 如果跳转id为空,则走到分支
|
|
|
|
+ if (jumpNodeId == null) {
|
|
|
|
+ String circulation = exampleAbstract.circulation(processNodeButton.getProcessNodeCode());
|
|
|
|
+ Assert.notEmpty(circulation, FlowExplainConstant.SPECIFY_BRANCH_EMPTY);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ save(exampleInfo);
|
|
|
|
|
|
|
|
+ return exampleInfo;
|
|
|
|
+ }
|
|
}
|
|
}
|