| | |
| | | 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.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.List; |
| | | import java.util.Map; |
| | | |
| | | @AllArgsConstructor |
| | | @Service("startDispatcher") |
| | | public class StartDispatcher { |
| | | |
| | | @Autowired |
| | | private RuntimeService runtimeService; |
| | | @Autowired |
| | | private AutoAssignUsersService autoAssignUsersService; |
| | | @Autowired |
| | | private IdentityService identityService; |
| | | private final RuntimeService runtimeService; |
| | | private final AutoAssignUsersService autoAssignUsersService; |
| | | |
| | | @Autowired |
| | | private NcProgramService ncProgramService; |
| | | private static final String PROCESS_KEY = "dispatch"; |
| | | 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("craftEdition",startVO.getCraftEdition()); |
| | | vars.put("planStartTime",startVO.getPlanStartTime()); |
| | | vars.put("partNo",startVO.getPartNo()); |
| | | vars.put("partNoEdition",startVO.getPartNoEdition()); |
| | | vars.put("drawingNo",startVO.getDrawingNo()); |
| | | vars.put("drawingNoEdition",startVO.getDrawingNoEdition()); |
| | | vars.put("planLockDays",startVO.getPlanLockDays()); |
| | | vars.put("productModel",startVO.getProductModel()); |
| | | |
| | | //零组件代码 |
| | | String partNo = generatePartNo(startVO); |
| | | vars.put("partNo",partNo); |
| | | |
| | | List<NcProgram> curedNcProgram = ncProgramService.getCuredNcProgram(partNo,startVO.getMachineCode()); |
| | | //vars.put("curedNcProgram",curedNcProgram); |
| | | |
| | | List<NcProgram> curedNcPrograms = ncProgramService.getCuredNcProgram(startVO.getDrawingNo(),startVO.getMachineCode()); |
| | | //设置是否有固化程序标记 |
| | | vars.put("hasCuredProgram",!curedNcProgram.isEmpty() ? "Y":"N"); |
| | | 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; |
| | | //如果有已固化程序,则将程序id插入流畅关联表 |
| | | for(NcProgram ncProgram : curedNcPrograms){ |
| | | ProcessProgRef ref = new ProcessProgRef(); |
| | | ref.setProcessInstanceId(pinst.getId()); |
| | | ref.setNcProgramId(ncProgram.getId()); |
| | | |
| | | processProgRefService.save(ref); |
| | | } |
| | | |
| | | //log.info() |
| | | } |
| | | |
| | |
| | | * @param startVO |
| | | * @return |
| | | */ |
| | | /* |
| | | String generatePartNo(TaskAssignVO startVO){ |
| | | //TODO 这个格式未确定,需要确认 |
| | | return String.format("%s-%s-%s-%s-%s-%s", |
| | |
| | | startVO.getProcessName(), |
| | | startVO.getCraftEdition(), |
| | | startVO.getProcessEdition()); |
| | | } |
| | | }*/ |
| | | } |