From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 25 六月 2025 11:51:38 +0800 Subject: [PATCH] Merge branch 'mdc_hyjs_master' --- lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/service/FlowCommonService.java | 87 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 deletions(-) diff --git a/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/service/FlowCommonService.java b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/service/FlowCommonService.java new file mode 100644 index 0000000..90af8d8 --- /dev/null +++ b/lxzn-module-flowable/src/main/java/org/jeecg/modules/flowable/apithird/service/FlowCommonService.java @@ -0,0 +1,87 @@ +package org.jeecg.modules.flowable.apithird.service; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; +import org.jeecg.modules.flowable.apithird.common.exception.CustomException; +import org.jeecg.modules.flowable.service.impl.FlowInstanceServiceImpl; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + *涓氬姟妯″潡璋冪敤API鐨勯泦鍚� + *@author PanMeiCheng + *@date 2021/11/22 + *@version 1.0 + */ +@Service +public class FlowCommonService { + @Resource + FlowMyBusinessServiceImpl flowMyBusinessService; + @Resource + FlowInstanceServiceImpl flowInstanceService; + /** + * 鍒濆鐢熸垚鎴栦慨鏀逛笟鍔′笌娴佺▼鐨勫叧鑱斾俊鎭�<br/> + * 褰撲笟鍔℃ā鍧楁柊澧炰竴鏉℃暟鎹悗璋冪敤锛屾鏃朵笟鍔℃暟鎹叧鑱斾竴涓祦绋嬪畾涔夛紝浠ュ鍚庣画娴佺▼浣跨敤 + * @return 鏄惁鎴愬姛 + * @param title 蹇呭~銆傛祦绋嬩笟鍔$畝瑕佹弿杩般�備緥锛�2021骞�11鏈�26鏃xxxx鐢宠 + * @param dataId 蹇呭~銆備笟鍔℃暟鎹甀d锛屽鏋滄槸涓�瀵瑰涓氬姟鍏崇郴锛屼紶鍏ヤ富琛ㄧ殑鏁版嵁Id + * @param serviceImplName 蹇呭~銆備笟鍔ervice娉ㄥ叆spring瀹瑰櫒鐨勫悕绉般�� +* 渚嬪锛欯Service("demoService")鍒欎紶鍏� demoService + * @param processDefinitionKey 蹇呭~銆傛祦绋嬪畾涔塊ey锛屼紶鍏ユ鍊硷紝鏈潵鍚姩鐨勪細鏄绫绘祦绋嬬殑鏈�鏂颁竴涓増鏈� + * @param processDefinitionId 閫夊~銆傛祦绋嬪畾涔塈d锛屼紶鍏ユ鍊硷紝鏈潵鍚姩鐨勪负鎸囧畾鐗堟湰鐨勬祦绋� + */ + public boolean initActBusiness(String title,String dataId, String serviceImplName, String processDefinitionKey, String processDefinitionId){ + boolean hasBlank = StrUtil.hasBlank(title,dataId, serviceImplName, processDefinitionKey); + if (hasBlank) throw new CustomException("娴佺▼鍏抽敭鍙傛暟鏈~瀹屽叏锛乨ataId, serviceImplName, processDefinitionKey"); + LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>(); + flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId, dataId) + ; + FlowMyBusiness flowMyBusiness = new FlowMyBusiness(); + FlowMyBusiness business = flowMyBusinessService.getOne(flowMyBusinessLambdaQueryWrapper); + if (business!=null){ + flowMyBusiness = business; + } else { + flowMyBusiness.setId(IdUtil.fastSimpleUUID()); + } + if (processDefinitionId==null){ + // 浠ヤ究鏇存柊娴佺▼ + processDefinitionId = ""; + } + flowMyBusiness.setTitle(title) + .setDataId(dataId) + .setServiceImplName(serviceImplName) + .setProcessDefinitionKey(processDefinitionKey) + .setProcessDefinitionId(processDefinitionId) + ; + if (business!=null){ + return flowMyBusinessService.updateById(flowMyBusiness); + } else { + return flowMyBusinessService.save(flowMyBusiness); + } + } + + /** + * 鍒犻櫎娴佺▼ + * @param dataId + * @return + */ + public boolean delActBusiness(String dataId){ + boolean hasBlank = StrUtil.hasBlank(dataId); + if (hasBlank) throw new CustomException("娴佺▼鍏抽敭鍙傛暟鏈~瀹屽叏锛乨ataId"); + LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessQueryWrapper = new LambdaQueryWrapper<>(); + flowMyBusinessQueryWrapper.eq(FlowMyBusiness::getDataId,dataId); + FlowMyBusiness one = flowMyBusinessService.getOne(flowMyBusinessQueryWrapper); + if (one.getProcessInstanceId()!=null){ + try { + flowInstanceService.delete(one.getProcessInstanceId(),"鍒犻櫎娴佺▼"); + } catch (Exception e) { + e.printStackTrace(); + } + } + return flowMyBusinessService.remove(flowMyBusinessQueryWrapper); + } +} -- Gitblit v1.9.3