rain
2024-06-03 28f661933ffdeb1f65ecee52f8f4b7a3b373da9b
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
package com.dji.sample.patches.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dji.sample.common.model.Pagination;
import com.dji.sample.common.model.PaginationData;
import com.dji.sample.media.dao.IFileMapper;
import com.dji.sample.media.model.MediaFileEntity;
import com.dji.sample.patches.dao.GetPatchesMapper;
import com.dji.sample.patches.model.Param.PatchesParam;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.service.GetPatchesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
@Service
public class GetPatchesServiceImpl implements GetPatchesService {
    @Autowired
    private GetPatchesMapper mapper;
    @Autowired
    private IFileMapper fileMapper;
 
    /**
     * 分页获取数据的接口实现。
     *
     * @param param 包含分页信息和查询条件的工作空间ID。
     * @return 返回一个包含查询结果和分页信息的PaginationData对象。
     */
    @Override
    public PaginationData<LotInfo> limitGet(PatchesParam param) {
        if (param.getIsPlan() != null) {
            Page<LotInfo> page = mapper.selectPage(new Page<LotInfo>(param.getPage(), param.getPageSize()),
                    new LambdaQueryWrapper<LotInfo>()
                            .eq(LotInfo::getWorkspaceId, param.getWorkspaceId())
                            .like(LotInfo::getDkbh, param.getDkbh())
                            .like(LotInfo::getXzqdm, param.getXzqdm())
                            .eq(LotInfo::getIsPlan, param.getIsPlan()));
            List<LotInfo> records = page.getRecords()
                    .stream()
                    .collect(Collectors.toList());
            return new PaginationData<LotInfo>(records, new Pagination(page));
        } else {
            Page<LotInfo> page = mapper.selectPage(new Page<LotInfo>(param.getPage(), param.getPageSize()),
                    new LambdaQueryWrapper<LotInfo>()
                            .eq(LotInfo::getWorkspaceId, param.getWorkspaceId())
                            .like(LotInfo::getDkbh, param.getDkbh())
                            .like(LotInfo::getXzqdm, param.getXzqdm()));
            List<LotInfo> records = page.getRecords()
                    .stream()
                    .collect(Collectors.toList());
            return new PaginationData<LotInfo>(records, new Pagination(page));
        }
    }
 
    @Override
    public void delPatches() {
        mapper.delete(null);
    }
 
    /**
     * 根据条件获取照片的分页数据
     *
     * @param param 包含分页信息和查询条件的参数对象
     * @param dkbh  查询条件中带有地块编号关键字,用于文件名的模糊搜索
     * @return 返回照片的分页数据,包括分页信息和照片实体列表
     */
    @Override
    public PaginationData<MediaFileEntity> getPhoto(PatchesParam param, String dkbh) {
        Page<MediaFileEntity> page = fileMapper.selectPage(new Page<MediaFileEntity>(param.getPage(), param.getPageSize()),
                new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "~" + "%"));
        List<MediaFileEntity> records = page.getRecords()
                .stream()
                .collect(Collectors.toList());
        return new PaginationData<MediaFileEntity>(records, new Pagination(page));
    }
 
    /**
     * 根据条件获取照片的分页数据
     *
     * @param workspaceId 工作空间的ID,用于指定查询的工作空间
     * @param dkbh        查询条件中带有地块编号关键字,用于文件名的模糊搜索
     * @return 返回照片的分页数据,包括分页信息和照片实体列表
     */
    public List<MediaFileEntity> listPohto(String dkbh, String workspaceId) {
        return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%")
                .eq(MediaFileEntity::getWorkspaceId, workspaceId));
    }
 
    /**
     * 根据地块编号和工作空间ID获取地块信息。
     *
     * @param dkbh        地块编号,用于查询特定定单的地块信息。
     * @param workspaceId 工作空间ID,用于查询属于特定工作空间的地块信息。
     * @return 返回匹配给定地块编号和工作空间ID的地块信息对象。如果找不到匹配的记录,则返回null。
     */
    public LotInfo getLotinfo(String dkbh, String workspaceId) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)
                .eq(LotInfo::getWorkspaceId, workspaceId));
    }
 
    public LotInfo getLotinfoToDb(String dkbh) {
        return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh));
    }
 
    public List<LotInfo> listLotinfo() {
        return mapper.selectList(null);
    }
 
    @Override
    public void insertLotinfo(List<LotInfo> list) {
        for (int i = 0; i < list.size(); i++) {
            mapper.insert(list.get(i));
        }
    }
}