| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.mapper.ProcessStreamMapper; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.response.ComponentInfoCode; |
| | | import org.jeecg.modules.dnc.response.DeviceCode; |
| | | import org.jeecg.modules.dnc.response.ProcessInfoCode; |
| | | import org.jeecg.modules.dnc.response.*; |
| | | |
| | | import org.jeecg.modules.dnc.service.*; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | |
| | | private IDeviceInfoService deviceInfoService; |
| | | @Autowired |
| | | private INcLogInfoService iNcLogInfoService; |
| | | @Autowired |
| | | private IPermissionStreamService permissionStreamService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | ExceptionCast.cast(ProcessInfoCode.PROCESS_NAME_NONE); |
| | | if(!ValidateUtil.validateString(stream.getProcessCode())) |
| | | ExceptionCast.cast(ProcessInfoCode.PROCESS_CODE_NONE); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | if(!ValidateUtil.validateString(userId)) |
| | | ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); |
| | | if(ValidateUtil.validateString(stream.getPartsId())) { |
| | | PartsInfo partsInfo = partsInfoService.getById(stream.getPartsId()); |
| | | if(partsInfo == null) |
| | |
| | | boolean b = super.save(stream); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | ProcessInfo processInfo = new ProcessInfo(); |
| | | processInfo.setProcessName(stream.getProcessName()); |
| | | processInfo.setDescription(stream.getDescription()); |
| | | return processInfoService.addOrEdit(processInfo); |
| | | // ProcessInfo processInfo = new ProcessInfo(); |
| | | // processInfo.setProcessName(stream.getProcessName()); |
| | | // processInfo.setDescription(stream.getDescription()); |
| | | // boolean processInfoB= processInfoService.addOrEdit(processInfo); |
| | | // if(!processInfoB) |
| | | // ExceptionCast.cast(CommonCode.FAIL); |
| | | //添加权限验证 |
| | | PermissionStream permissionStream = new PermissionStream(); |
| | | permissionStream.setUserId(userId); |
| | | permissionStream.setProductId(stream.getProductId()); |
| | | permissionStream.setComponentId(stream.getComponentId()); |
| | | if (StrUtil.isNotEmpty(stream.getPartsId())){ |
| | | permissionStream.setPartsId(stream.getPartsId()); |
| | | } |
| | | permissionStream.setProcessId(stream.getProcessId()); |
| | | return permissionStreamService.save(permissionStream); |
| | | } |
| | | |
| | | @Override |
| | |
| | | ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<ProcessStream> getByuserPerms(String userId){ |
| | | if(!ValidateUtil.validateString(userId)) |
| | | return Collections.emptyList(); |
| | | return super.getBaseMapper().getByUserPerms(userId); |
| | | } |
| | | |
| | | @Override |
| | | public List<ProcessStream> getByuserPerms(String userId,String queryParam){ |
| | | if(!ValidateUtil.validateString(userId)) |
| | | return Collections.emptyList(); |
| | | if(!ValidateUtil.validateString(queryParam)) |
| | | return Collections.emptyList(); |
| | | LambdaQueryWrapper<ProcessStream> queryWrapper = Wrappers.lambdaQuery(); |
| | | if(ValidateUtil.validateString(queryParam)) { |
| | | queryWrapper.and(wrapper->wrapper.like(ProcessStream::getProcessName, queryParam) |
| | | .or() |
| | | .like(ProcessStream::getProcessName, queryParam)); |
| | | } |
| | | queryWrapper.orderByAsc(ProcessStream::getCreateTime); |
| | | return super.list(queryWrapper); |
| | | } |
| | | } |