lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java
@@ -146,7 +146,7 @@ if (sysParams ==null){ throw new JeecgBootException("æªé ç½®å¯¼å ¥NCä¸çµåå¾çæ¯å¦è§¦åå®¡ç¾æµç¨ï¼è¯·è系管çå"); }else { if (saveBool&&sysParams.getSettingValue().equals("1")&&uploadRequest.getDocClassCode().equals("NC")){ if (saveBool&&sysParams.getSettingValue().equals("1")){ //触åå®¡ç¾ DispatchFile dispatchFile = new DispatchFile(); dispatchFile.setDocId(docInfo.getDocId()); lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java
@@ -490,7 +490,7 @@ queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ProcessSpecVersion::getProcessSpecVersionCode, treeInfoRequest.getTreeName()); queryWrapper.orderByDesc(ProcessSpecVersion::getCreateTime); List<ProcessSpecVersion> list = super.list(queryWrapper); if (list == null || list.isEmpty()){ if (list == null || list.isEmpty() || StrUtil.isNotBlank(treeInfoRequest.getStructureType())){ return new ArrayList<>(); }else { String ids=list.stream().map(ProcessSpecVersion::getId).collect(Collectors.joining(",")); lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java
@@ -85,6 +85,7 @@ @Autowired private IProductMixService productMixService; @Autowired @Lazy private IDocInfoService docInfoService; @Override @@ -1038,9 +1039,11 @@ // ç®åæ¡ä»¶å¤æ queryWrapper.like(StrUtil.isNotBlank(treeInfoRequest.getTreeCode()), ProductInfo::getProductNo, treeInfoRequest.getTreeCode()) .like(StrUtil.isNotBlank(treeInfoRequest.getTreeName()), ProductInfo::getProductName, treeInfoRequest.getTreeName()); List<ProductInfo> productInfoList = super.list(queryWrapper); List<DocInfo> docInfos = new ArrayList<>(); if (StrUtil.isNotBlank(treeInfoRequest.getStructureType())){ productInfoList=new ArrayList<>(); } if (CollectionUtil.isNotEmpty(productInfoList)) { // 使ç¨IDå表èéæ¼æ¥å符串 List<String> productIds = productInfoList.stream() lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/AssignFileStreamAdapter.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,52 @@ package org.jeecg.modules.dncFlow.adapter; import org.jeecg.modules.dncFlow.entity.AssignFileStream; import org.jeecg.modules.dncFlow.service.StreamTarget; public class AssignFileStreamAdapter implements StreamTarget { private final AssignFileStream stream; public AssignFileStreamAdapter(AssignFileStream stream) { this.stream = stream; } @Override public void setProductId(String productId) { stream.setProductId(productId); } @Override public void setComponentId(String componentId) { stream.setComponentId(componentId); } @Override public void setPartsId(String partsId) { stream.setPartsId(partsId); } @Override public void setProcessId(String processId) { stream.setProcessId(processId); } @Override public void setPsvId(String psvId) { stream.setPsvId(psvId); } @Override public void setStepId(String stepId) { stream.setStepId(stepId); } @Override public void setDeviceTypeId(String deviceTypeId) { stream.setDeviceTypeId(deviceTypeId); } @Override public String getAttributionId() { return stream.getAttributionId(); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/adapter/DispatchFileAdapter.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,53 @@ package org.jeecg.modules.dncFlow.adapter; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.service.StreamTarget; public class DispatchFileAdapter implements StreamTarget { private final DispatchFile file; public DispatchFileAdapter(DispatchFile file) { this.file = file; } @Override public void setProductId(String productId) { file.setProductId(productId); } @Override public void setComponentId(String componentId) { file.setComponentId(componentId); } @Override public void setPartsId(String partsId) { file.setPartsId(partsId); } @Override public void setProcessId(String processId) { file.setProcessId(processId); } @Override public void setPsvId(String psvId) { file.setPsvId(psvId); } @Override public void setStepId(String stepId) { file.setStepId(stepId); } @Override public void setDeviceTypeId(String deviceTypeId) { file.setDeviceTypeId(deviceTypeId); } @Override public String getAttributionId() { return file.getAttributionId(); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/entity/AssignFileStream.java
@@ -55,6 +55,14 @@ @TableField(value = "status") @Dict(dicCode = "dnc_assign_stream_status") private Integer status; /**ææ´¾è®¾å¤ä¸ç¨-æå±ID*/ @TableField(value = "attribution_id") private String attributionId; /**ææ´¾è®¾å¤ä¸ç¨-æå±type*/ @TableField(value = "attribution_type") private String attributionType; @JsonIgnore @TableField(value = "create_time", select = false, fill = FieldFill.INSERT) private Date createTime; @@ -71,10 +79,4 @@ @TableLogic @TableField(value = "delete_flag", select = false) private Integer deleteFlag = 0; /**ææ´¾è®¾å¤ä¸ç¨-æå±ID*/ private transient String attributionId; /**ææ´¾è®¾å¤ä¸ç¨-æå±type*/ private transient String attributionType; } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/handler/ComponentHandler.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,35 @@ package org.jeecg.modules.dncFlow.handler; import org.jeecg.modules.dnc.entity.ComponentInfo; import org.jeecg.modules.dnc.service.IComponentInfoService; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class ComponentHandler implements PermissionHandler<ComponentInfo> { @Autowired private IComponentInfoService componentInfoService; @Override public ComponentInfo loadEntity(String id) { return componentInfoService.getById(id); } @Override public String getBusinessId(ComponentInfo entity) { return entity.getComponentId(); } @Override public String getTypeCode() { return "2"; } @Override public void setRelations(ComponentInfo entity, StreamTarget target) { target.setProductId(entity.getProductId()); target.setComponentId(entity.getComponentId()); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/handler/PartsHandler.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,35 @@ package org.jeecg.modules.dncFlow.handler; import org.jeecg.modules.dnc.entity.PartsInfo; import org.jeecg.modules.dnc.service.IPartsInfoService; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class PartsHandler implements PermissionHandler<PartsInfo> { @Autowired private IPartsInfoService partsInfoService; @Override public PartsInfo loadEntity(String id) { return partsInfoService.getById(id); } @Override public String getBusinessId(PartsInfo entity) { return entity.getPartsId(); } @Override public String getTypeCode() { return "3"; } @Override public void setRelations(PartsInfo entity, StreamTarget target) { target.setProductId(entity.getProductId()); target.setComponentId(entity.getComponentId()); target.setPartsId(entity.getPartsId()); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/handler/PermissionProcessor.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,56 @@ package org.jeecg.modules.dncFlow.handler; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.dnc.entity.PermissionStreamNew; import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.response.CommonCode; import org.jeecg.modules.dnc.service.IDeviceTypeService; import org.jeecg.modules.dnc.service.IPermissionStreamNewService; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Optional; @Component public class PermissionProcessor { @Autowired private IDeviceTypeService deviceTypeService; @Autowired private IPermissionStreamNewService permissionStreamNewService; public <T> PermissionStreamNew process( String attributionId, LoginUser user, StreamTarget target, PermissionHandler<T> handler ) { // 1. å è½½ä¸å¡å®ä½ T entity = handler.loadEntity(attributionId); if (entity == null) { ExceptionCast.cast(CommonCode.INVALID_PARAM); } // 2. è®¾ç½®å ³èå ³ç³» handler.setRelations(entity, target); // 3. 设置设å¤ç±»å setupDeviceType(target); // 4. è·åæéæµ return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId( handler.getBusinessId(entity), user.getId(), handler.getTypeCode() ); } private void setupDeviceType(StreamTarget target) { Optional.ofNullable(deviceTypeService.getById(target.getAttributionId())) .ifPresent(device -> target.setDeviceTypeId(device.getId()) ); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/handler/ProcessHandle.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,39 @@ package org.jeecg.modules.dncFlow.handler; import org.jeecg.modules.dnc.entity.ProcessStream; import org.jeecg.modules.dnc.service.IProcessStreamService; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class ProcessHandle implements PermissionHandler<ProcessStream> { @Autowired private IProcessStreamService ProcessStreamService; @Override public ProcessStream loadEntity(String id) { return ProcessStreamService.getById(id); } @Override public String getBusinessId(ProcessStream entity) { return entity.getProcessId(); } @Override public String getTypeCode() { return "5"; } @Override public void setRelations(ProcessStream entity, StreamTarget target) { target.setProductId(entity.getProductId()); target.setComponentId(entity.getComponentId()); target.setPartsId(entity.getPartsId()); target.setPsvId(entity.getPsvId()); target.setProcessId(entity.getProcessId()); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/handler/ProcessSpecVersionHandle.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,37 @@ package org.jeecg.modules.dncFlow.handler; import org.jeecg.modules.dnc.entity.ProcessSpecVersion; import org.jeecg.modules.dnc.service.IProcessSpecVersionService; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class ProcessSpecVersionHandle implements PermissionHandler<ProcessSpecVersion> { @Autowired private IProcessSpecVersionService processSpecVersionService; @Override public ProcessSpecVersion loadEntity(String id) { return processSpecVersionService.getById(id); } @Override public String getBusinessId(ProcessSpecVersion entity) { return entity.getId(); } @Override public String getTypeCode() { return "4"; } @Override public void setRelations(ProcessSpecVersion entity, StreamTarget target) { target.setProductId(entity.getProductId()); target.setComponentId(entity.getComponentId()); target.setPartsId(entity.getPartsId()); target.setPsvId(entity.getId()); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/handler/ProductHandler.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,36 @@ package org.jeecg.modules.dncFlow.handler; import org.jeecg.modules.dnc.entity.ProductInfo; import org.jeecg.modules.dnc.service.IProductInfoService; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; // 产åçç¥ @Component public class ProductHandler implements PermissionHandler<ProductInfo> { @Autowired private IProductInfoService productInfoService; @Override public ProductInfo loadEntity(String id) { return productInfoService.getById(id); } @Override public String getBusinessId(ProductInfo entity) { return entity.getProductId(); } @Override public String getTypeCode() { return "1"; } @Override public void setRelations(ProductInfo entity, StreamTarget target) { target.setProductId(entity.getProductId()); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/handler/WorkStepHandle.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,40 @@ package org.jeecg.modules.dncFlow.handler; import org.jeecg.modules.dnc.entity.WorkStep; import org.jeecg.modules.dnc.service.IWorkStepService; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class WorkStepHandle implements PermissionHandler<WorkStep> { @Autowired private IWorkStepService WorkStepService; @Override public WorkStep loadEntity(String id) { return WorkStepService.getById(id); } @Override public String getBusinessId(WorkStep entity) { return entity.getId(); } @Override public String getTypeCode() { return "6"; } @Override public void setRelations(WorkStep entity, StreamTarget target) { target.setProductId(entity.getProductId()); target.setComponentId(entity.getComponentId()); target.setPartsId(entity.getPartsId()); target.setPsvId(entity.getPsvId()); target.setProcessId(entity.getProcessId()); target.setStepId(entity.getId()); } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/PermissionHandler.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,8 @@ package org.jeecg.modules.dncFlow.service; public interface PermissionHandler<T> { T loadEntity(String id); String getBusinessId(T entity); String getTypeCode(); void setRelations(T entity, StreamTarget target); } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/StreamTarget.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,12 @@ package org.jeecg.modules.dncFlow.service; public interface StreamTarget { void setProductId(String productId); void setComponentId(String componentId); void setPartsId(String partsId); void setProcessId(String processId); void setPsvId(String psvId); void setStepId(String stepId); void setDeviceTypeId(String deviceTypeId); String getAttributionId(); } lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
@@ -44,7 +44,6 @@ import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -75,10 +74,6 @@ @Autowired private IProcessStreamService processStreamService; @Autowired private IWorkStepService workStepService; @Autowired private IPermissionStreamNewService permissionStreamNewService; @Autowired private IDocClassificationService classificationService; @Autowired private IToEquipmentTaskService equipmentTaskService; @@ -105,9 +100,9 @@ @Autowired private IFlowTaskService flowTaskService; @Autowired private IDeviceTypeService deviceTypeService; @Autowired private IFlowMyBusinessService flowMyBusinessService; @Autowired private PermissionService permissionService; @Value("${securedoc.whether}") private String whether; @@ -332,15 +327,9 @@ if(!b) ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); if(up.getStatus() == 2) { DocInfo docInfo; //åææä½ if (StrUtil.isNotEmpty(en.getStepId())){ //å·¥æ¥ä¸è®¾å¤ç±»ææ´¾ docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), 6, en.getDeviceTypeId()); }else { docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), 5, en.getDeviceTypeId()); } if(docInfo == null || docInfo.getDocStatus() == 3) DocInfo docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), Integer.valueOf(en.getAttributionType()), en.getAttributionId()); if(docInfo == null ) ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR); MdcEquipment mdcEquipment = iMdcEquipmentService.getById(en.getDeviceId()); if(mdcEquipment == null) @@ -593,69 +582,12 @@ } private PermissionStreamNew getPermissionStreams(AssignFileStream stream) { LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); DeviceType deviceType = deviceTypeService.getById(stream.getAttributionId()); String attributionId = deviceType != null ? deviceType.getAttributionId() : stream.getAttributionId(); PermissionStreamNew permissionStreams; if (stream.getAttributionType().equals("5")) { // å·¥åº permissionStreams = handleProcess(stream, attributionId, user); } else { // å·¥æ¥ permissionStreams = handleWorkStep(stream, attributionId, user); } if (permissionStreams == null) { PermissionStreamNew permissionStreamNew = permissionService.getPermissionStreams(stream); if (permissionStreamNew == null) { ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE); } return permissionStreams; return permissionStreamNew ; } private PermissionStreamNew handleProcess(AssignFileStream stream, String attributionId, LoginUser user) { ProcessStream processStream = processStreamService.getById(attributionId); if (processStream == null) { ExceptionCast.cast(CommonCode.INVALID_PARAM); } stream.setProductId(processStream.getProductId()); stream.setComponentId(processStream.getComponentId()); stream.setPartsId(processStream.getPartsId()); stream.setProcessId(processStream.getProcessId()); if (deviceTypeService.getById(stream.getAttributionId()) != null) { stream.setDeviceTypeId(deviceTypeService.getById(stream.getAttributionId()).getId()); } return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processStream.getProcessId(), user.getId(), "5"); } private PermissionStreamNew handleWorkStep(AssignFileStream stream, String attributionId, LoginUser user) { WorkStep workStep = workStepService.getById(attributionId); if (workStep == null) { ExceptionCast.cast(CommonCode.INVALID_PARAM); } stream.setProductId(workStep.getProductId()); stream.setComponentId(workStep.getComponentId()); stream.setPartsId(workStep.getPartsId()); stream.setProcessId(workStep.getProcessId()); stream.setStepId(workStep.getId()); if (deviceTypeService.getById(stream.getAttributionId()) != null) { stream.setDeviceTypeId(deviceTypeService.getById(stream.getAttributionId()).getId()); } return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(), user.getId(), "6"); } //è·åé¨é¨ä¿¡æ¯ //todo ä¿®æ¹ private List<String> getDepartIds(List<PermissionStream> permissionStreams, String userId) { Map<String, MdcProduction> map = iMdcProductionService.getUserAssignedDepart(userId); List<String> departIds = permissionStreams.stream() .filter(item -> map.containsKey(item.getDepartId())) .map(PermissionStream::getDepartId) .collect(Collectors.toList()); if (departIds.isEmpty()) { ExceptionCast.cast(ActivitiCode.ACT_USER_NOT_PERM); } return departIds; } //å°è£ æ°æ® private void saveBusinessObject(AssignFileStream stream, String userId) { lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java
@@ -12,14 +12,15 @@ 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; @@ -53,20 +54,12 @@ @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 @@ -75,6 +68,8 @@ private DocInfoMapper docInfoMapper; @Autowired private ISysUserRoleService sysUserRoleService; @Autowired private PermissionService permissionService; /** * æµç¨å¯å¨,ä¿å对åºçæ°æ® * @param dispatchFile @@ -424,67 +419,12 @@ 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 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/PermissionService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,88 @@ package org.jeecg.modules.dncFlow.service.impl; import org.apache.shiro.SecurityUtils; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.dnc.entity.DeviceType; import org.jeecg.modules.dnc.entity.PermissionStreamNew; import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.response.ActivitiCode; import org.jeecg.modules.dnc.service.IDeviceTypeService; import org.jeecg.modules.dncFlow.adapter.AssignFileStreamAdapter; import org.jeecg.modules.dncFlow.adapter.DispatchFileAdapter; import org.jeecg.modules.dncFlow.entity.AssignFileStream; import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.handler.*; import org.jeecg.modules.dncFlow.service.PermissionHandler; import org.jeecg.modules.dncFlow.service.StreamTarget; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class PermissionService { @Autowired private PermissionProcessor processor; @Autowired private ProductHandler productHandler; @Autowired private ComponentHandler componentHandler; @Autowired private PartsHandler partsHandler; @Autowired private ProcessSpecVersionHandle processSpecVersionHandler; @Autowired private ProcessHandle processHandler; @Autowired private WorkStepHandle workStepHandler; @Autowired private IDeviceTypeService deviceTypeService; public PermissionStreamNew getPermissionStreams(DispatchFile file) { return processInternal(new DispatchFileAdapter(file), file.getAttributionType()); } public PermissionStreamNew getPermissionStreams(AssignFileStream stream) { return processInternal(new AssignFileStreamAdapter(stream), stream.getAttributionType()); } private PermissionStreamNew processInternal(StreamTarget target, String attributionType) { LoginUser user = getCurrentUser(); String resolvedId = resolveAttributionId(target.getAttributionId()); PermissionHandler<?> handler = resolveHandler(attributionType); return processor.process(resolvedId, user, target, handler); } private String resolveAttributionId(String AttributionId) { DeviceType deviceType = deviceTypeService.getById(AttributionId); if (deviceType == null) { return AttributionId; }else { return deviceType.getAttributionId(); } } private PermissionHandler<?> resolveHandler(String type) { switch (type) { case "1": return productHandler; case "2": return componentHandler; case "3": return partsHandler; case "4": return processSpecVersionHandler; case "5": return processHandler; case "6": return workStepHandler; default: ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE); return null; // å®é ä¸ä¼æ§è¡ } } private LoginUser getCurrentUser() { return (LoginUser) SecurityUtils.getSubject().getPrincipal(); } }