| 
						
						
						
					 | 
					 | 
					@ -1,32 +1,65 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package com.hnac.hzims.ticket.repair.service.impl; | 
					 | 
					 | 
					 | 
					package com.hnac.hzims.ticket.repair.service.impl; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.alibaba.fastjson.JSONObject; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.alibaba.fastjson.TypeReference; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; | 
					 | 
					 | 
					 | 
					import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity; | 
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.entity.WorkTaskEntity; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.mapper.WorkTaskMapper; | 
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.mapper.WorkTaskMapper; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.service.IWorkTaskService; | 
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.service.IWorkTaskService; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.vo.WorkTaskVO; | 
					 | 
					 | 
					 | 
					import com.hnac.hzims.ticket.repair.vo.WorkTaskVO; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import lombok.RequiredArgsConstructor; | 
					 | 
					 | 
					 | 
					import lombok.RequiredArgsConstructor; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.core.log.exception.ServiceException; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springblade.core.mp.base.BaseServiceImpl; | 
					 | 
					 | 
					 | 
					import org.springblade.core.mp.base.BaseServiceImpl; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.core.secure.utils.AuthUtil; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.core.tool.api.R; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.core.tool.utils.DateUtil; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.flow.core.entity.BladeFlow; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.flow.core.feign.IFlowClient; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.flow.core.utils.FlowUtil; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import org.springblade.flow.core.utils.TaskUtil; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.springframework.stereotype.Service; | 
					 | 
					 | 
					 | 
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.util.Map; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					/** | 
					 | 
					 | 
					 | 
					/** | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 * @author ysj | 
					 | 
					 | 
					 | 
					 * @author ysj | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 */ | 
					 | 
					 | 
					 | 
					 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					@Slf4j | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					@Service | 
					 | 
					 | 
					 | 
					@Service | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					@RequiredArgsConstructor | 
					 | 
					 | 
					 | 
					@RequiredArgsConstructor | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTaskEntity> implements IWorkTaskService { | 
					 | 
					 | 
					 | 
					public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTaskEntity> implements IWorkTaskService { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    private final IFlowClient flowClient; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * 工作任务单-开启流程 | 
					 | 
					 | 
					 | 
					     * 工作任务单-开启流程 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param workTask | 
					 | 
					 | 
					 | 
					     * @param workTask | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return | 
					 | 
					 | 
					 | 
					     * @return | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */ | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public boolean startProcess(WorkTaskVO workTask) { | 
					 | 
					 | 
					 | 
					    public boolean start(WorkTaskVO workTask) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        // 步骤1.保存工作任务单
 | 
					 | 
					 | 
					 | 
					        // 步骤1.保存工作任务单
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        this.saveWorkTask(workTask); | 
					 | 
					 | 
					 | 
					        this.saveWorkTask(workTask); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return false; | 
					 | 
					 | 
					 | 
					        // 步骤2.开启检修计划流程
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        this.startProcess(workTask); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return true; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    private void startProcess(WorkTaskVO workTask) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        Map<String, Object> variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(workTask, DateUtil.PATTERN_DATETIME), Map.class); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey("work_task", FlowUtil.getBusinessKey("work_task_v4",String.valueOf(workTask.getId())), workTask.getCode(), variables); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        log.error("work_task_start_process_result :{}",result); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 更新任务流程Id
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (result.isSuccess()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            BladeFlow flow = result.getData(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            workTask.setProcessInstanceId(flow.getProcessInstanceId()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            this.updateById(workTask); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            throw new ServiceException("开启检修计划流程失败,code=" + result.getCode()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -34,6 +67,7 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param workTask | 
					 | 
					 | 
					 | 
					     * @param workTask | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */ | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private void saveWorkTask(WorkTaskVO workTask) { | 
					 | 
					 | 
					 | 
					    private void saveWorkTask(WorkTaskVO workTask) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        this.save(workTask); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -43,6 +77,15 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */ | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) { | 
					 | 
					 | 
					 | 
					    public boolean listener(ProcessWorkFlowResponse processWorkFlowResponse) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        Map<String, Object> variables = (Map<String, Object>) processWorkFlowResponse.getVariables(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        WorkTaskVO entity = JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference<WorkTaskVO>(){}); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 当前流程名称
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        entity.setTaskName(processWorkFlowResponse.getTaskName()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 流程阶段执行人员名称
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        // 更新工作任务单信息
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        this.updateById(entity); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return false; | 
					 | 
					 | 
					 | 
					        return false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} |