| | |
| | | package com.qianwen.smartman.modules.dnc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.mp.base.BaseServiceImpl; |
| | | import com.qianwen.core.mp.support.Condition; |
| | |
| | | import com.qianwen.core.oss.model.OssFile; |
| | | import com.qianwen.core.secure.utils.AuthUtil; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.constant.CommonConstant; |
| | | import com.qianwen.smartman.common.utils.MessageUtils; |
| | | import com.qianwen.smartman.modules.dnc.convert.DncFactoryFileConvert; |
| | | import com.qianwen.smartman.modules.dnc.dto.DncOperationLogDto; |
| | | import com.qianwen.smartman.modules.dnc.entity.DncFactoryFile; |
| | |
| | | import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder; |
| | | import com.qianwen.smartman.modules.system.entity.User; |
| | | import com.qianwen.smartman.modules.system.service.IUserService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/dnc/service/impl/DncFactoryFileServiceImpl.class */ |
| | |
| | | private final IObsFileService obsFileService; |
| | | private final OssBuilder ossBuilder; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case 98245393: |
| | | if (implMethodName.equals("getId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 537556537: |
| | | if (implMethodName.equals("getIsCurrent")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 804592199: |
| | | if (implMethodName.equals("getSuffix")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 1071464927: |
| | | if (implMethodName.equals("getCreateTime")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 1343131517: |
| | | if (implMethodName.equals("getFilename")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 1388468386: |
| | | if (implMethodName.equals("getVersion")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | switch (z) { |
| | | case false: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getVersion(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getSuffix(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/util/Date;")) { |
| | | return (v0) -> { |
| | | return v0.getCreateTime(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getFilename(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getFilename(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getFilename(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getFilename(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getFilename(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/dnc/entity/DncFactoryFile") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) { |
| | | return (v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }; |
| | | } |
| | | break; |
| | | case RegionCache.VILLAGE_LEVEL /* 5 */: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getId(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public DncFactoryFileServiceImpl(final IUserService userService, final IDncOperationLogService dncOperationLogService, final IObsFileService obsFileService, final OssBuilder ossBuilder) { |
| | | this.userService = userService; |
| | |
| | | public DncFactoryFileVO addFactoryFile(DncFactoryFileVO dncFactoryFileVO) { |
| | | DncFactoryFile dncFactoryFile = DncFactoryFileConvert.INSTANCE.convert(dncFactoryFileVO); |
| | | String filename = dncFactoryFileVO.getFilename(); |
| | | |
| | | DncFactoryFile oldFile = getOne(Wrappers.<DncFactoryFile>lambdaQuery() |
| | | .eq(DncFactoryFile::getFilename, filename) |
| | | .eq(DncFactoryFile::getIsCurrent, DncEnums.CurrentVersion.YES.getCode())); |
| | | /* |
| | | DncFactoryFile oldFile = (DncFactoryFile) getOne((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getFilename(); |
| | | }, filename)).eq((v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }, DncEnums.CurrentVersion.YES.getCode())); |
| | | }, DncEnums.CurrentVersion.YES.getCode()));*/ |
| | | OssFile ossFile = this.ossBuilder.template().statFile(dncFactoryFile.getObjectKey()); |
| | | String hash = ossFile.getHash(); |
| | | if (Func.isNull(oldFile)) { |
| | |
| | | dncFactoryFile.setVersion(CommonConstant.VERSION_NUM); |
| | | saveFactoryFile(dncFactoryFileVO, dncFactoryFile, filename); |
| | | } else if (!hash.equals(oldFile.getContentMd5())) { |
| | | update(Wrappers.<DncFactoryFile>lambdaUpdate() |
| | | .eq(DncFactoryFile::getFilename, filename) |
| | | .set(DncFactoryFile::getIsCurrent, DncEnums.CurrentVersion.NO.getCode())); |
| | | /* |
| | | update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().eq((v0) -> { |
| | | return v0.getFilename(); |
| | | }, filename)).set((v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }, DncEnums.CurrentVersion.NO.getCode())); |
| | | }, DncEnums.CurrentVersion.NO.getCode()));*/ |
| | | dncFactoryFile.setContentMd5(hash); |
| | | dncFactoryFile.setVersion(Integer.valueOf((oldFile.getVersion() != null ? oldFile.getVersion() : CommonConstant.VERSION_NUM).intValue() + CommonConstant.VERSION_NUM.intValue())); |
| | | saveFactoryFile(dncFactoryFileVO, dncFactoryFile, filename); |
| | |
| | | |
| | | @Override // org.springblade.modules.dnc.service.IDncFactoryFileService |
| | | public Boolean verifyFileName(String fileName, String objectKey) { |
| | | DncFactoryFile one = getOne(Wrappers.<DncFactoryFile>lambdaQuery().eq(DncFactoryFile::getFilename, fileName) |
| | | .eq(DncFactoryFile::getIsCurrent, DncEnums.CurrentVersion.YES.getCode())); |
| | | /* |
| | | DncFactoryFile one = (DncFactoryFile) getOne((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getFilename(); |
| | | }, fileName)).eq((v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }, DncEnums.CurrentVersion.YES.getCode())); |
| | | }, DncEnums.CurrentVersion.YES.getCode()));*/ |
| | | if (one != null) { |
| | | boolean result = this.obsFileService.verifyFileContent(objectKey, one.getContentMd5()); |
| | | if (result) { |
| | |
| | | |
| | | @Override // org.springblade.modules.dnc.service.IDncFactoryFileService |
| | | public IPage<DncFactoryFileVO> listPages(String keywords, Query query) { |
| | | Map<Long, User> userMap = (Map) this.userService.list().stream().collect(Collectors.toMap((v0) -> { |
| | | Map<Long, User> userMap = this.userService.list().stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getId(); |
| | | }, Function.identity())); |
| | | |
| | | IPage<DncFactoryFile> pages = page(Condition.getPage(query), Wrappers.<DncFactoryFile>lambdaQuery() |
| | | .eq(DncFactoryFile::getIsCurrent, DncEnums.CurrentVersion.YES.getCode()) |
| | | .and(Func.isNotEmpty(keywords), i -> i.likeRight(DncFactoryFile::getFilename, keywords).or().likeRight(DncFactoryFile::getSuffix, keywords)) |
| | | |
| | | .orderByDesc(DncFactoryFile::getCreateTime)); |
| | | /* |
| | | IPage<DncFactoryFile> pages = page(Condition.getPage(query), (Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }, DncEnums.CurrentVersion.YES.getCode())).and(Func.isNotEmpty(keywords), i -> { |
| | |
| | | }, keywords); |
| | | }).orderByDesc((v0) -> { |
| | | return v0.getCreateTime(); |
| | | })); |
| | | }));*/ |
| | | IPage<DncFactoryFileVO> convert = DncFactoryFileConvert.INSTANCE.convert(pages); |
| | | convert.getRecords().forEach(s -> { |
| | | User upUser = (User) userMap.get(s.getUpdateUser()); |
| | |
| | | |
| | | @Override // org.springblade.modules.dnc.service.IDncFactoryFileService |
| | | public List<FileHistoryVO> getFactoryFileHistory(String fileId) { |
| | | Map<Long, User> userMap = (Map) this.userService.list().stream().collect(Collectors.toMap((v0) -> { |
| | | Map<Long, User> userMap = this.userService.list().stream().collect(Collectors.toMap((v0) -> { |
| | | return v0.getId(); |
| | | }, Function.identity())); |
| | | DncFactoryFile dncFactoryFile = (DncFactoryFile) getById(fileId); |
| | | if (dncFactoryFile == null) { |
| | | throw new ServiceException(MessageUtils.message("dnc.file.is.not.exists", new Object[0])); |
| | | } |
| | | List<DncFactoryFile> list = list(Wrappers.<DncFactoryFile>lambdaQuery() |
| | | .eq(DncFactoryFile::getFilename, dncFactoryFile.getFilename()) |
| | | .orderByDesc(DncFactoryFile::getVersion)); |
| | | /* |
| | | List<DncFactoryFile> list = list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getFilename(); |
| | | }, dncFactoryFile.getFilename())).orderByDesc((v0) -> { |
| | | return v0.getVersion(); |
| | | })); |
| | | }));*/ |
| | | if (Func.isNotEmpty(list)) { |
| | | return (List) list.stream().map(s -> { |
| | | return list.stream().map(s -> { |
| | | return FileHistoryVO.builder().id(s.getId()).createTime(s.getCreateTime()).filename(s.getFilename()).objectKey(s.getObjectKey()).isCurrent(s.getIsCurrent()).link(s.getLink()).contentMd5(s.getContentMd5()).contentLength(s.getContentLength()).contentType(s.getContentType()).suffix(s.getSuffix()).createUser(((User) userMap.get(s.getCreateUser())).getAccount()).updateUser(((User) userMap.get(s.getUpdateUser())).getAccount()).updateTime(s.getUpdateTime()).version(s.getVersion() != null ? String.valueOf(s.getVersion()) : "1").versionDesc(s.getVersion() != null ? s.getVersion() + CommonConstant.FILE_SUFFIX : CommonConstant.VERSION_NUM + CommonConstant.FILE_SUFFIX).build(); |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | return new ArrayList(); |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.dnc.service.IDncFactoryFileService |
| | |
| | | if (file == null || !DncEnums.CurrentVersion.YES.getCode().equals(file.getIsCurrent())) { |
| | | throw new ServiceException(MessageUtils.message("dnc.workstation.file.is.not.exist.or.is.not.current.version", new Object[0])); |
| | | } |
| | | boolean updateSwitch = update(Wrappers.<DncFactoryFile>lambdaUpdate().set(DncFactoryFile::getIsCurrent, DncEnums.CurrentVersion.YES.getCode()).eq(DncFactoryFile::getId, fileVersionSwitchVO.getSwitchFileId())); |
| | | boolean updateCurrent = update(Wrappers.<DncFactoryFile>lambdaUpdate().set(DncFactoryFile::getIsCurrent, DncEnums.CurrentVersion.NO.getCode()).eq(DncFactoryFile::getId, fileVersionSwitchVO.getCurrentFileId())); |
| | | /* |
| | | boolean updateSwitch = update((Wrapper) ((LambdaUpdateWrapper) Wrappers.lambdaUpdate().set((v0) -> { |
| | | return v0.getIsCurrent(); |
| | | }, DncEnums.CurrentVersion.YES.getCode())).eq((v0) -> { |
| | |
| | | return v0.getIsCurrent(); |
| | | }, DncEnums.CurrentVersion.NO.getCode())).eq((v0) -> { |
| | | return v0.getId(); |
| | | }, fileVersionSwitchVO.getCurrentFileId())); |
| | | }, fileVersionSwitchVO.getCurrentFileId()));*/ |
| | | if (updateSwitch && updateCurrent) { |
| | | result = true; |
| | | } |