liding
3 天以前 bcbff529977768c5c80714f45d52b4f36629d236
1.生产加工 2.文件上传
已修改10个文件
120 ■■■■ 文件已修改
main-business/src/main/java/com/ruoyi/business/controller/ArchiveController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/dto/ArchiveDto.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/entity/ProductionInventory.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/ArchiveService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/InspectionTaskServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/basic/service/StorageAttachmentService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/basic/service/impl/StorageAttachmentServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/enums/StorageAttachmentRecordType.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main-business/src/main/java/com/ruoyi/business/controller/ArchiveController.java
@@ -43,6 +43,14 @@
    }
    /**
     * 根据id查询文件列表
     */
    @GetMapping("/fileList")
    public R fileList(ArchiveDto archiveDto) {
        return R.ok( archiveService.fileList(archiveDto));
    }
    /**
     * 档案信息表删除
     */
    @DeleteMapping("/delArchive")
main-business/src/main/java/com/ruoyi/business/dto/ArchiveDto.java
@@ -1,10 +1,15 @@
package com.ruoyi.business.dto;
import com.ruoyi.basic.entity.StorageAttachment;
import com.ruoyi.business.entity.Archive;
import lombok.Data;
import java.util.List;
@Data
public class ArchiveDto extends Archive {
    private Long treeId;
    private List<StorageAttachment> attachments;
}
main-business/src/main/java/com/ruoyi/business/entity/ProductionInventory.java
@@ -46,4 +46,11 @@
     */
    @TableField(value = "used_quantity")
    private Integer usedQuantity;
    /**
     * 正式库id
     */
    @TableField(value = "official_id")
    private Long officialId;
}
main-business/src/main/java/com/ruoyi/business/service/ArchiveService.java
@@ -2,9 +2,12 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.entity.StorageAttachment;
import com.ruoyi.business.dto.ArchiveDto;
import com.ruoyi.business.entity.Archive;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
 * <p>
@@ -21,4 +24,6 @@
    int addOrEditArchive(ArchiveDto archiveDto);
    int delByIds(Long[] ids);
    List<StorageAttachment> fileList(ArchiveDto archiveDto);
}
main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java
@@ -5,6 +5,8 @@
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.entity.StorageAttachment;
import com.ruoyi.basic.service.StorageAttachmentService;
import com.ruoyi.business.dto.ArchiveDto;
import com.ruoyi.business.entity.Archive;
import com.ruoyi.business.mapper.ArchiveMapper;
@@ -13,7 +15,12 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import static com.ruoyi.common.constant.StorageAttachmentConstants.StorageAttachmentFile;
import static com.ruoyi.common.enums.StorageAttachmentRecordType.Archives;
/**
 * <p>
@@ -29,6 +36,10 @@
    private final ArchiveMapper archiveMapper;
    private final StorageAttachmentService storageAttachmentService;
    @Override
    public IPage<Archive> selectArchiveList(Page page, ArchiveDto archiveDto) {
        LambdaQueryWrapper<Archive> queryWrapper = new LambdaQueryWrapper<>();
@@ -40,12 +51,14 @@
    public int addOrEditArchive(ArchiveDto archiveDto) {
        Archive archive = new Archive();
        BeanUtils.copyProperties(archiveDto, archive);
        int i ;
        if (Objects.isNull(archiveDto.getId())) {
            return archiveMapper.insert(archive);
            i= archiveMapper.insert(archive);
        } else {
            return archiveMapper.updateById(archive);
            i= archiveMapper.updateById(archive);
        }
        storageAttachmentService.saveStorageAttachment(archiveDto.getAttachments(), archive.getId(),Archives,StorageAttachmentFile);
        return i;
    }
    @Override
@@ -61,4 +74,10 @@
        // 执行批量逻辑删除
        return archiveMapper.update(null, updateWrapper);
    }
    @Override
    public List<StorageAttachment> fileList(ArchiveDto archiveDto) {
        storageAttachmentService.selectStorageAttachments(archiveDto.getId(), Archives, StorageAttachmentFile);
        return null;
    }
}
main-business/src/main/java/com/ruoyi/business/service/impl/InspectionTaskServiceImpl.java
@@ -2,21 +2,21 @@
import com.ruoyi.business.entity.InspectionTask;
import com.ruoyi.business.mapper.InspectionTaskMapper;
    import com.ruoyi.business.service.InspectionTaskService;
import com.ruoyi.business.service.InspectionTaskService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
/**
* <p>
    * 巡检任务表 服务实现类
    * </p>
*
* @author ld
* @since 2025-06-14
*/
 * <p>
 * 巡检任务表 服务实现类
 * </p>
 *
 * @author ld
 * @since 2025-06-14
 */
@Service
@RequiredArgsConstructor
    public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper, InspectionTask> implements InspectionTaskService {
public class InspectionTaskServiceImpl extends ServiceImpl<InspectionTaskMapper, InspectionTask> implements InspectionTaskService {
    }
}
main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.dto.ProductionMasterDto;
import com.ruoyi.business.entity.OfficialInventory;
import com.ruoyi.business.entity.Production;
import com.ruoyi.business.entity.ProductionInventory;
import com.ruoyi.business.entity.ProductionMaster;
@@ -13,6 +14,7 @@
import com.ruoyi.business.mapper.ProductionMapper;
import com.ruoyi.business.mapper.ProductionMasterMapper;
import com.ruoyi.business.service.ProductionMasterService;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.bean.BeanUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -122,7 +124,7 @@
        BigDecimal totalTotalCost = BigDecimal.ZERO;
        BigDecimal totalEquipmentDepreciation = BigDecimal.ZERO;
        int totalProductionQuantity = 0;
        StringBuilder coalBuilder = new StringBuilder("["); // 优化字符串拼接
        StringBuilder coalBuilder = new StringBuilder();
        for (Production production : productionMasterDto.getProductionList()) {
            totalPurchasePrice = totalPurchasePrice.add(production.getPurchasePrice());
@@ -131,12 +133,12 @@
            totalTotalCost = totalTotalCost.add(production.getTotalCost());
            totalEquipmentDepreciation = totalEquipmentDepreciation.add(production.getEquipmentDepreciation());
            totalProductionQuantity += production.getProductionQuantity();
            coalBuilder.append(production.getCoal()).append(",");
            if (coalBuilder.length() > 0) {
                coalBuilder.append(","); // 在元素之间添加逗号
            }
            coalBuilder.append(production.getCoal());
        }
        // 处理coal字符串拼接
        String coalStr = coalBuilder.length() > 1 ?
                coalBuilder.deleteCharAt(coalBuilder.length()-1).append("]").toString() : "[]";
        String coalStr = coalBuilder.toString(); // 直接获取拼接结果
        // 2. 创建主表对象
        ProductionMaster productionMaster = new ProductionMaster();
@@ -155,7 +157,7 @@
            productionMasterMapper.insert(productionMaster);
            masterId = productionMaster.getId(); // 获取新生成的ID
        } else {
            // 删除关联子表数据(使用更高效的in删除)
            // 删除关联子表数据
            productionMapper.delete(new LambdaQueryWrapper<Production>()
                    .eq(Production::getProductionMasterId, masterId));
@@ -164,7 +166,17 @@
            productionMasterMapper.updateById(productionMaster);
        }
        //库存更新
        for (ProductionInventory productionInventory : productionMasterDto.getProductionInventoryList()) {
            OfficialInventory officialInventory = officialInventoryMapper.selectById(productionInventory.getOfficialId());
            BigDecimal subtract = officialInventory.getInventoryQuantity().subtract(new BigDecimal(productionInventory.getUsedQuantity()));
            if (subtract.compareTo(BigDecimal.ZERO) < 0) {
                throw new BaseException("库存不足");
            }
            officialInventory.setInventoryQuantity(subtract);
            officialInventoryMapper.updateById(officialInventory);
        }
        // 4. 批量插入子表数据
        batchInsertProductions(masterId, productionMasterDto.getProductionList());
        batchInsertInventories(masterId, productionMasterDto.getProductionInventoryList());
ruoyi-common/src/main/java/com/ruoyi/basic/service/StorageAttachmentService.java
@@ -1,8 +1,7 @@
package com.ruoyi.basic.service;
import com.ruoyi.basic.entity.StorageAttachment;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.constant.StorageAttachmentConstants;
import com.ruoyi.basic.entity.StorageAttachment;
import com.ruoyi.common.enums.StorageAttachmentRecordType;
import java.util.List;
@@ -23,7 +22,7 @@
     * @param fileType 文件类型
     * @return 文件信息列表
     */
    List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType);
    List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, String fileType);
    /**
     * 保存通用文件上传的附件信息
@@ -32,7 +31,7 @@
     * @param recordType 关联记录类型
     * @param fileType 文件类型
     */
    public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType);
    public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, String fileType);
    /**
     * 删除通用文件上传的附件信息
ruoyi-common/src/main/java/com/ruoyi/basic/service/impl/StorageAttachmentServiceImpl.java
@@ -1,22 +1,20 @@
package com.ruoyi.basic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.entity.StorageAttachment;
import com.ruoyi.basic.entity.StorageBlob;
import com.ruoyi.basic.entity.dto.StorageBlobDTO;
import com.ruoyi.basic.mapper.StorageAttachmentMapper;
import com.ruoyi.basic.mapper.StorageBlobMapper;
import com.ruoyi.basic.service.StorageAttachmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.service.StorageBlobService;
import com.ruoyi.common.constant.StorageAttachmentConstants;
import com.ruoyi.common.enums.StorageAttachmentRecordType;
import com.ruoyi.common.utils.file.MinioUtils;
import io.minio.MinioClient;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import java.util.List;
@@ -44,7 +42,7 @@
    private MinioUtils minioUtils;
    @Override
    public List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType) {
    public List<StorageAttachment> selectStorageAttachments(Long recordId, StorageAttachmentRecordType recordType, String fileType) {
        List<StorageAttachment> storageAttachments = storageAttachmentMapper.selectList(new LambdaQueryWrapper<StorageAttachment>()
                .eq(StorageAttachment::getRecordId, recordId)
                .eq(StorageAttachment::getRecordType, recordType.ordinal())
@@ -63,9 +61,9 @@
    }
    @Override
    public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, StorageAttachmentConstants fileType) {
    public void saveStorageAttachment(List<StorageAttachment> attachments, Long recordId, StorageAttachmentRecordType recordType, String fileType) {
        // 删除旧图
        deleteStorageAttachment(new StorageAttachment(fileType.toString(), (long) recordType.ordinal(), recordId));
         deleteStorageAttachment(new StorageAttachment(fileType.toString(), (long) recordType.ordinal(), recordId));
        for (StorageAttachment attachment : attachments) {
            // 获取关联记录
            StorageBlob storageBlob = attachment.getStorageBlobDTO();
ruoyi-common/src/main/java/com/ruoyi/common/enums/StorageAttachmentRecordType.java
@@ -9,7 +9,8 @@
@AllArgsConstructor
public enum StorageAttachmentRecordType {
    // 例子 实际开发请删除
    Template("Template","范例");
    Template("Template","范例"),
    Archives("Archives","文档管理");
    private final String code;