From 410eed616ce86a76ecfbd272be0a4463ac54a517 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期五, 29 三月 2024 19:37:31 +0800
Subject: [PATCH] 刀具模块错误修改

---
 smart-man-boot/src/main/java/com/qianwen/smartman/modules/dnc/service/impl/DncFactoryFileServiceImpl.java |  202 +++++++++++---------------------------------------
 1 files changed, 44 insertions(+), 158 deletions(-)

diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/dnc/service/impl/DncFactoryFileServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/dnc/service/impl/DncFactoryFileServiceImpl.java
index accfb49..b0946e5 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/dnc/service/impl/DncFactoryFileServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/dnc/service/impl/DncFactoryFileServiceImpl.java
@@ -1,20 +1,17 @@
 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;
@@ -22,6 +19,8 @@
 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;
@@ -36,8 +35,6 @@
 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 */
@@ -47,143 +44,6 @@
     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;
@@ -196,11 +56,16 @@
     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)) {
@@ -208,11 +73,15 @@
             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);
@@ -237,11 +106,14 @@
 
     @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) {
@@ -253,9 +125,16 @@
 
     @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 -> {
@@ -266,7 +145,7 @@
             }, keywords);
         }).orderByDesc((v0) -> {
             return v0.getCreateTime();
-        }));
+        }));*/
         IPage<DncFactoryFileVO> convert = DncFactoryFileConvert.INSTANCE.convert(pages);
         convert.getRecords().forEach(s -> {
             User upUser = (User) userMap.get(s.getUpdateUser());
@@ -280,24 +159,28 @@
 
     @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
@@ -309,6 +192,9 @@
             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) -> {
@@ -318,7 +204,7 @@
                 return v0.getIsCurrent();
             }, DncEnums.CurrentVersion.NO.getCode())).eq((v0) -> {
                 return v0.getId();
-            }, fileVersionSwitchVO.getCurrentFileId()));
+            }, fileVersionSwitchVO.getCurrentFileId()));*/
             if (updateSwitch && updateCurrent) {
                 result = true;
             }

--
Gitblit v1.9.3