From a3e0493b2f597e8c49ee80a0c7ab92bc30dc60a3 Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期四, 10 四月 2025 11:13:36 +0800 Subject: [PATCH] 检验任务,进货检验车间文件选择去掉后缀 --- basic-server/src/main/java/com/ruoyi/basic/service/impl/WorkShopFileServiceImpl.java | 71 +++++++++++++++++++++++++++++++---- 1 files changed, 63 insertions(+), 8 deletions(-) diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/impl/WorkShopFileServiceImpl.java b/basic-server/src/main/java/com/ruoyi/basic/service/impl/WorkShopFileServiceImpl.java index 0b4801d..06869c3 100644 --- a/basic-server/src/main/java/com/ruoyi/basic/service/impl/WorkShopFileServiceImpl.java +++ b/basic-server/src/main/java/com/ruoyi/basic/service/impl/WorkShopFileServiceImpl.java @@ -1,15 +1,19 @@ package com.ruoyi.basic.service.impl; - +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.basic.mapper.WorkShopFileMapper; -import com.ruoyi.basic.pojo.WorkShopFile; +import com.ruoyi.basic.mapper.*; +import com.ruoyi.basic.pojo.*; import com.ruoyi.basic.service.WorkShopFileService; +import com.ruoyi.common.config.MinioConfig; import com.ruoyi.common.utils.file.MinioUtils; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.List; /** * @description 閽堝琛ㄣ�恮ork_shop_file(杞﹂棿闄勪欢鍚嶇О)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇 @@ -22,10 +26,21 @@ private WorkShopFileMapper workShopFileMapper; @Resource + private ProductPartMapper productPartMapper; + + @Resource + private ProductMapper productMapper; + @Resource + private StructureTestObjectPartMapper structureTestObjectPartMapper; + + @Resource + private StructureTestObjectMapper structureTestObjectMapper; + + @Resource private MinioUtils minioUtils; - @Value("${minio.bucketName}") - private String bucketName; + @Autowired + private MinioConfig minioConfig; @Override public int delFile(Integer id) { @@ -38,9 +53,9 @@ WorkShopFile file = workShopFileMapper.selectById(id); if (file != null && file.getFileUrl() != null) { // 妫�鏌� MinIO 涓枃浠舵槸鍚﹀瓨鍦� - if (minioUtils.objectExists(bucketName, file.getFileUrl())) { + if (minioUtils.objectExists(minioConfig.getBucketName(), file.getFileUrl())) { // 鍏堝垹闄� MinIO 涓殑瀵硅薄 - minioUtils.removeObjectsResult(bucketName, file.getFileUrl()); + minioUtils.removeObjectsResult(minioConfig.getBucketName(), file.getFileUrl()); } } // 鎵ц鏁版嵁搴撳垹闄ゆ搷浣� @@ -52,6 +67,46 @@ return 0; } } + + @Override + public IPage<WorkShopFile> partFileList(Page page, String partNo) { + StructureTestObject structureTestObject = findStructureTestObjectByPartNo(partNo); + if (structureTestObject != null && structureTestObject.getWorkShopId() != null) { + return workShopFileMapper.selectPage(page, new LambdaQueryWrapper<WorkShopFile>().eq(WorkShopFile::getWorkShopId, structureTestObject.getWorkShopId())); + } + return null; + } + + @Override + public List<WorkShopFile> fileListById(Integer workShopId) { + List<WorkShopFile> workShopFiles = workShopFileMapper.selectList(new LambdaQueryWrapper<WorkShopFile>().eq(WorkShopFile::getWorkShopId, workShopId)); + return removeSuffixFromList(workShopFiles); + } + + public static List<WorkShopFile> removeSuffixFromList(List<WorkShopFile> list) { + for (WorkShopFile file : list) { + int dotIndex = file.getFileName().lastIndexOf('.'); + if (dotIndex != -1) { + file.setFileName(file.getFileName().substring(0, dotIndex)); + } + } + return list; + } + + private StructureTestObject findStructureTestObjectByPartNo(String partNo) { + ProductPart productPart = productPartMapper.selectOne(new LambdaQueryWrapper<ProductPart>().eq(ProductPart::getPartNo, partNo)); + if (productPart != null) { + Product product = productMapper.selectById(productPart.getProductId()); + if (product != null) { + return structureTestObjectMapper.selectById(product.getObjectId()); + } + } + StructureTestObjectPart structureTestObjectPart = structureTestObjectPartMapper.selectOne(new LambdaQueryWrapper<StructureTestObjectPart>().eq(StructureTestObjectPart::getPartNo, partNo)); + if (structureTestObjectPart != null) { + return structureTestObjectMapper.selectById(structureTestObjectPart.getTestObjectId()); + } + return null; + } } -- Gitblit v1.9.3