| | |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.entity.*; |
| | | import org.jeecg.modules.dnc.entity.DocInfo; |
| | | import org.jeecg.modules.dnc.entity.PermissionStreamNew; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.mapper.DocInfoMapper; |
| | | import org.jeecg.modules.dnc.request.DocInfoQueryRequest; |
| | | import org.jeecg.modules.dnc.response.ActivitiCode; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.response.UcenterCode; |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.dncFlow.entity.DispatchFile; |
| | | import org.jeecg.modules.dncFlow.mapper.DispatchFileMapper; |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private IDocInfoService docInfoService; |
| | | @Autowired |
| | | private IProcessStreamService processStreamService; |
| | | @Autowired |
| | | private IWorkStepService workStepService; |
| | | @Autowired |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | @Autowired |
| | | private IFlowTaskService flowTaskService; |
| | | @Autowired |
| | | private IDeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | |
| | | private DocInfoMapper docInfoMapper; |
| | | @Autowired |
| | | private ISysUserRoleService sysUserRoleService; |
| | | @Autowired |
| | | private PermissionService permissionService; |
| | | /** |
| | | * 流程启动,保存对应的数据 |
| | | * @param dispatchFile |
| | |
| | | return true; |
| | | } |
| | | |
| | | //获取文件信息 |
| | | private DocInfo getDocInfo(DispatchFile dispatchFile) { |
| | | DocInfo docInfo = docInfoService.getByDocAttrAndDocId(dispatchFile.getDocId(), |
| | | Integer.parseInt(dispatchFile.getAttributionType()), dispatchFile.getAttributionId()); |
| | | if (docInfo == null || docInfo.getDocStatus() == 3) { |
| | | ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR); |
| | | } |
| | | return docInfo; |
| | | } |
| | | |
| | | |
| | | private PermissionStreamNew getPermissionStreams(DispatchFile dispatchFile) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | DeviceType deviceType = deviceTypeService.getById(dispatchFile.getAttributionId()); |
| | | String attributionId = deviceType != null ? deviceType.getAttributionId() : dispatchFile.getAttributionId(); |
| | | |
| | | PermissionStreamNew permissionStreams; |
| | | if (dispatchFile.getAttributionType().equals("5")) { |
| | | // 工序 |
| | | permissionStreams = handleProcess(dispatchFile, attributionId, user); |
| | | } else { |
| | | // 工步 |
| | | permissionStreams = handleWorkStep(dispatchFile, attributionId, user); |
| | | } |
| | | if (permissionStreams == null) { |
| | | PermissionStreamNew permissionStreamNew = permissionService.getPermissionStreams(dispatchFile); |
| | | if (permissionStreamNew == null) { |
| | | ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE); |
| | | } |
| | | return permissionStreams; |
| | | } |
| | | |
| | | private PermissionStreamNew handleProcess(DispatchFile dispatchFile, String attributionId, LoginUser user) { |
| | | ProcessStream processStream = processStreamService.getById(attributionId); |
| | | if (processStream == null) { |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | } |
| | | dispatchFile.setProductId(processStream.getProductId()); |
| | | dispatchFile.setComponentId(processStream.getComponentId()); |
| | | dispatchFile.setPartsId(processStream.getPartsId()); |
| | | dispatchFile.setPsvId(processStream.getPsvId()); |
| | | dispatchFile.setProcessId(processStream.getProcessId()); |
| | | if (deviceTypeService.getById(dispatchFile.getAttributionId()) != null) { |
| | | dispatchFile.setDeviceTypeId(deviceTypeService.getById(dispatchFile.getAttributionId()).getId()); |
| | | } |
| | | return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processStream.getProcessId(), user.getId(), "5"); |
| | | } |
| | | |
| | | private PermissionStreamNew handleWorkStep(DispatchFile dispatchFile, String attributionId, LoginUser user) { |
| | | WorkStep workStep = workStepService.getById(attributionId); |
| | | if (workStep == null) { |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | } |
| | | dispatchFile.setProductId(workStep.getProductId()); |
| | | dispatchFile.setComponentId(workStep.getComponentId()); |
| | | dispatchFile.setPartsId(workStep.getPartsId()); |
| | | dispatchFile.setPsvId(workStep.getPsvId()); |
| | | dispatchFile.setProcessId(workStep.getProcessId()); |
| | | dispatchFile.setStepId(workStep.getId()); |
| | | if (deviceTypeService.getById(dispatchFile.getAttributionId()) != null) { |
| | | dispatchFile.setDeviceTypeId(deviceTypeService.getById(dispatchFile.getAttributionId()).getId()); |
| | | } |
| | | return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(), user.getId(), "6"); |
| | | return permissionStreamNew; |
| | | } |
| | | |
| | | @Override |