Xiajijian
2025-11-01 7af72fa3484e88caaf8ae94124179489af64f587
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.ard.route.service.impl;
 
import java.util.List;
import com.ard.common.utils.DateUtils;
import com.ard.common.utils.file.FileUtils;
import com.ard.common.utils.uuid.IdUtils;
import com.ard.oss.model.MinioUploadResult;
import com.ard.oss.service.impl.OssServiceContext;
import com.ard.route.domain.route.ArdRouteInformation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ard.route.mapper.ArdRouteInformationMapper;
import com.ard.route.service.IArdRouteInformationService;
import org.springframework.web.multipart.MultipartFile;
 
import static com.ard.route.util.ToolUtils.extractFilePath;
import static com.ard.route.util.ToolUtils.getFileNameWithoutExtension;
 
/**
 * 航线(kmz)Service业务层处理
 * 
 * @author xia
 * @date 2025-10-23
 */
@Service
public class ArdRouteInformationServiceImpl implements IArdRouteInformationService {
 
    @Autowired
    private ArdRouteInformationMapper ardRouteInformationMapper;
 
    @Autowired
    private OssServiceContext ossService;
 
    /**
     * 查询航线(kmz)
     * 
     * @param id 航线(kmz)主键
     * @return 航线(kmz)
     */
    @Override
    public ArdRouteInformation selectArdRouteInformationById(String id) {
        return ardRouteInformationMapper.selectArdRouteInformationById(id);
    }
 
    /**
     * 查询航线(kmz)列表
     * 
     * @param ardRouteInformation 航线(kmz)
     * @return 航线(kmz)
     */
    @Override
    public List<ArdRouteInformation> selectArdRouteInformationList(ArdRouteInformation ardRouteInformation) {
        return ardRouteInformationMapper.selectArdRouteInformationList(ardRouteInformation);
    }
 
    /**
     * 新增航线(kmz)
     * 
     * @param ardRouteInformation 航线(kmz)
     * @return 结果
     */
    @Override
    public int insertArdRouteInformation(ArdRouteInformation ardRouteInformation) {
        ardRouteInformation.setId(IdUtils.simpleUUID());
        ardRouteInformation.setCreateTime(DateUtils.getNowDate());
        return ardRouteInformationMapper.insertArdRouteInformation(ardRouteInformation);
    }
 
    /**
     * 修改航线(kmz)
     * 
     * @param ardRouteInformation 航线(kmz)
     * @return 结果
     */
    @Override
    public int updateArdRouteInformation(ArdRouteInformation ardRouteInformation) {
        ardRouteInformation.setUpdateTime(DateUtils.getNowDate());
        return ardRouteInformationMapper.updateArdRouteInformation(ardRouteInformation);
    }
 
    /**
     * 批量删除航线(kmz)
     * 
     * @param ids 需要删除的航线(kmz)主键
     * @return 结果
     */
    @Override
    public int deleteArdRouteInformationByIds(String[] ids) {
        // 删除航线(kmz)文件
        for (String id : ids) {
            ArdRouteInformation information = ardRouteInformationMapper.selectArdRouteInformationById(id);
            ossService.deleteObject("kmz", information.getMinioUpPath());
        }
        return ardRouteInformationMapper.deleteArdRouteInformationByIds(ids);
    }
 
    /**
     * 删除航线(kmz)信息
     * 
     * @param id 航线(kmz)主键
     * @return 结果
     */
    @Override
    public int deleteArdRouteInformationById(String id) {
        return ardRouteInformationMapper.deleteArdRouteInformationById(id);
    }
 
    /**
     * 导入航线(kmz)文件
     *
     * @param file 文件
     * @return 结果
     */
    @Override
    public MinioUploadResult uploadArdRouteInformation(MultipartFile file) {
        try {
            String url = ossService.upload("kmz",file);
            ArdRouteInformation information = new ArdRouteInformation();
            information.setFileName(file.getOriginalFilename());
            information.setFileNameNew(getFileNameWithoutExtension(url));
            information.setMinioUpPath(extractFilePath(url));
            information.setUpPath(url);
            information.setUpFileSize((double) file.getSize());
            insertArdRouteInformation(information);
            return MinioUploadResult.builder()
                    .url(url)
                    .newFileName(FileUtils.getName(url))
                    .originalFilename(file.getOriginalFilename())
                    .build();
        }catch (Exception e){
            return null;
        }
    }
 
    /**
     * 根据文件名称查询航线信息
     *
     * @param name 文件名称
     * @return 结果
     */
    @Override
    public ArdRouteInformation selectArdRouteInformationByName(String name) {
        return ardRouteInformationMapper.selectArdRouteInformationByName(name);
    }
 
}