| | |
| | | package org.springblade.mdm.flow.excution; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.AllArgsConstructor; |
| | | import org.flowable.common.engine.impl.identity.Authentication; |
| | | import org.flowable.engine.IdentityService; |
| | | import org.flowable.engine.runtime.ProcessInstance; |
| | |
| | | import org.springblade.flow.core.pojo.entity.BladeFlow; |
| | | import org.springblade.flow.core.utils.TaskUtil; |
| | | import org.springblade.mdm.flow.vo.TaskAssignVO; |
| | | import org.springblade.mdm.program.entity.NcProgram; |
| | | import org.springblade.mdm.program.entity.ProcessProgRef; |
| | | import org.springblade.mdm.program.service.NcProgramService; |
| | | import org.springblade.mdm.program.service.ProcessProgRefService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.flowable.engine.RuntimeService; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @AllArgsConstructor |
| | | @Service("startDispatcher") |
| | | public class StartDispatcher { |
| | | |
| | | @Autowired |
| | | private RuntimeService runtimeService; |
| | | @Autowired |
| | | private AutoAssignUsersService autoAssignUsersService; |
| | | @Autowired |
| | | private IdentityService identityService; |
| | | private static final String PROCESS_KEY = "dispatch"; |
| | | private final RuntimeService runtimeService; |
| | | private final AutoAssignUsersService autoAssignUsersService; |
| | | |
| | | private final IdentityService identityService; |
| | | private final ProcessProgRefService processProgRefService; |
| | | private final NcProgramService ncProgramService; |
| | | |
| | | public static final String PROCESS_KEY = "dispatch"; |
| | | |
| | | /** |
| | | * 启动派工流程 |
| | | * @param startVO |
| | | */ |
| | | public void start(TaskAssignVO startVO){ |
| | | |
| | | Map<String,Object> preAssignee = autoAssignUsersService.autoAssignUsers(startVO.getProducePlanId()); |
| | | Map<String,Object> preAssignee = autoAssignUsersService.autoAssignUsers(startVO); |
| | | Map<String, Object> vars = new HashMap<>(preAssignee); |
| | | |
| | | vars.put("machineCode",startVO.getMachineCode()); |
| | |
| | | vars.put("drawingNo",startVO.getDrawingNo()); |
| | | vars.put("drawingNoEdition",startVO.getDrawingNoEdition()); |
| | | vars.put("planLockDays",startVO.getPlanLockDays()); |
| | | vars.put("productModel",startVO.getProductModel()); |
| | | |
| | | //vars.put("producePlanId",startVO.getCraftEdition()); |
| | | |
| | | List<NcProgram> curedNcPrograms = ncProgramService.getCuredNcProgram(startVO.getDrawingNo(),startVO.getMachineCode()); |
| | | //设置是否有固化程序标记 |
| | | vars.put("hasCuredProgram",!curedNcPrograms.isEmpty() ? "Y":"N"); |
| | | |
| | | |
| | | String businessKey = "0";//业务表key |
| | |
| | | identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//设置流程发起人 |
| | | ProcessInstance pinst = runtimeService.startProcessInstanceByKey(PROCESS_KEY,businessKey,vars); |
| | | |
| | | int a=1; |
| | | a =2; |
| | | //如果有已固化程序,则将程序id插入流畅关联表 |
| | | for(NcProgram ncProgram : curedNcPrograms){ |
| | | ProcessProgRef ref = new ProcessProgRef(); |
| | | ref.setProcessInstanceId(pinst.getId()); |
| | | ref.setNcProgramId(ncProgram.getId()); |
| | | ref.setProcessDefinitionKey(pinst.getProcessDefinitionKey()); |
| | | processProgRefService.save(ref); |
| | | } |
| | | |
| | | //log.info() |
| | | } |
| | | |
| | | /** |
| | | * 生成零组件编号 |
| | | * 图号、图号版次、工序号、工序名称、工艺版次、工序版次 组合起来获得零组件号 |
| | | * @param startVO |
| | | * @return |
| | | */ |
| | | /* |
| | | String generatePartNo(TaskAssignVO startVO){ |
| | | //TODO 这个格式未确定,需要确认 |
| | | return String.format("%s-%s-%s-%s-%s-%s", |
| | | startVO.getPartNo(), |
| | | startVO.getPartNoEdition(), |
| | | startVO.getProcessNo(), |
| | | startVO.getProcessName(), |
| | | startVO.getCraftEdition(), |
| | | startVO.getProcessEdition()); |
| | | }*/ |
| | | } |