¶Ô±ÈÐÂÎļþ |
| | |
| | | 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æ¥xxxxxç³è¯· |
| | | * @param dataId å¿
å¡«ãä¸å¡æ°æ®Idï¼å¦ææ¯ä¸å¯¹å¤ä¸å¡å
³ç³»ï¼ä¼ å
¥ä¸»è¡¨çæ°æ®Id |
| | | * @param serviceImplName å¿
å¡«ãä¸å¡service注å
¥spring容å¨çåç§°ã |
| | | * ä¾å¦ï¼@Service("demoService")åä¼ å
¥ demoService |
| | | * @param processDefinitionKey å¿
å¡«ãæµç¨å®ä¹Keyï¼ä¼ å
¥æ¤å¼ï¼æªæ¥å¯å¨ç伿¯è¯¥ç±»æµç¨çææ°ä¸ä¸ªçæ¬ |
| | | * @param processDefinitionId éå¡«ãæµç¨å®ä¹Idï¼ä¼ å
¥æ¤å¼ï¼æªæ¥å¯å¨ç为æå®çæ¬çæµç¨ |
| | | */ |
| | | 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("æµç¨å
³é®åæ°æªå¡«å®å
¨ï¼dataId, 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("æµç¨å
³é®åæ°æªå¡«å®å
¨ï¼dataId"); |
| | | 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); |
| | | } |
| | | } |