feige
7 天以前 4581db487ca237dca8eb31415135e800b9982929
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package com.ruoyi.service.impl;
 
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ArchiveRecords;
import com.ruoyi.domain.Archiverecordstouser;
import com.ruoyi.mapper.ArchiveRecordsMapper;
import com.ruoyi.mapper.ArchiverecordstouserMapper;
import com.ruoyi.service.IArchiveRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
/**
 * 档案记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-12
 */
 
@Service
public class ArchiveRecordsServiceImpl extends ServiceImpl<ArchiveRecordsMapper, ArchiveRecords>  implements IArchiveRecordsService
{
//    @Autowired
//    private ArchiveRecordsMapper archiveRecordsMapper;
 
    @Autowired
    private ArchiverecordstouserMapper archiverecordstouserMapper;
 
 
 
    private LambdaQueryWrapper<ArchiveRecords> buildCondition(ArchiveRecords archiveRecords){
        LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>();
 
        lqw.like(!StringUtils.isEmpty(archiveRecords.getProjectName()), ArchiveRecords::getProjectName, archiveRecords.getProjectName())
                .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber())
                .like(!StringUtils.isEmpty(archiveRecords.getArchiveRoomNumber()), ArchiveRecords::getArchiveRoomNumber, archiveRecords.getArchiveRoomNumber())
                        .like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId());
        //                .like(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation())
//                .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder())
//                .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress())
//                .like(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark())
//                .eq(zfProperty.getFamilyId()!=null,ZfProperty::getFamilyId,zfProperty.getFamilyId())
//                .in(ZfProperty::getFamilyId,familyIdList)
//                .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime())
//                .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime());
//        lqw.orderByDesc(ZfProperty::getCreateTime);
       // lqw.orderByDesc(ArchiveRecords::isOwnData);
     //   lqw.orderByDesc(ArchiveRecords::getCreateTime);
        lqw.orderByDesc(ArchiveRecords::getCreateTime);
        System.out.println("ssssssssssssddd0000000000000000");
        return lqw;
 
    }
 
    @Override
    public Long getMaxId() {
        //return this.
        return baseMapper.findMaxId();
    }
 
    @Override
    public AjaxResult selectDataList(ArchiveRecords archiveRecords, Integer pageNum, Integer pageSize) {
 
        LambdaQueryWrapper<ArchiveRecords> lqw = buildCondition(archiveRecords);
 
        System.out.println("-------------");
        System.out.println(pageNum);
 
 
 
 
        Page<ArchiveRecords> page = new Page<>(pageNum, pageSize);
    
    // 使用自定义的分页查询方法,先连接再分页
    Page<ArchiveRecords> pageResult = this.baseMapper.selectJoinUserPage(page, lqw);
 
 
            //selectJoinUserPage(page, lqw);
    
  
 
        List<ArchiveRecords> beanRecords = pageResult.getRecords();//得到查询出来的数据
      //  List<ArchiveRecords> beanRecords = list(lqw);
     //   log.info("从数据库中查到的为:{}", beanRecords);
    //    return markOwnData(familyId, fatherFaId, motherFaId, beanRecords);
        //拿到当前用户的id
        // 获取当前用户ID
        Long userid = SecurityUtils.getUserId();
 
        beanRecords.forEach(record ->{
            if(record.isArchiveRecordsId()!=null&&record.getUserId()==userid)
            {
                    record.setOwnData(true);
            }
            else
                record.setOwnData(false);
        });
 
     //   Collections.sort(beanRecords, Comparator.comparing(ArchiveRecords::isOwnData));
        HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
//        System.out.println(data.get("data"));
//        System.out.println(data.get("pageNum"));
//        System.out.println(data.get("total"));
 
        return AjaxResult.success(data);
    }
 
    /**
     * 查询档案记录
     * 
     * @param id 档案记录主键
     * @return 档案记录
     */
    @Override
    public ArchiveRecords selectArchiveRecordsById(Long id)
    {
        System.out.println(id);
        System.out.println("-------------ssssssssssssssssss");
        LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>();
        lqw.eq(id!=null, ArchiveRecords::getId, id);
        List<ArchiveRecords> records = list(lqw);
        if(!records.isEmpty())
            return records.get(0);
        else
            return null;
    }
 
    /**
     * 查询档案记录列表
     * 
     * @param archiveRecords 档案记录
     * @return 档案记录
     */
    @Override
    public List<ArchiveRecords> selectArchiveRecordsList(ArchiveRecords archiveRecords)
    {
        LambdaQueryWrapper<ArchiveRecords> lambdaQueryWrapper = buildCondition(archiveRecords);
        List<ArchiveRecords> beanRecords = list(lambdaQueryWrapper);
 
        return beanRecords;
    }
 
    /**
     * 新增档案记录
     * 
     * @param archiveRecords 档案记录
     * @return 结果
     */
    @Override
    public int insertArchiveRecords(ArchiveRecords archiveRecords)
    {
        LocalDateTime time = LocalDateTime.now();
 
        Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
        archiveRecords.setCreateTime(date);
        boolean res = this.save(archiveRecords);
        if(res)
            return 1;
        else
            return 0;
    }
 
    /**
     * 修改档案记录
     * 
     * @param archiveRecords 档案记录
     * @return 结果
     */
    @Override
    public int updateArchiveRecords(ArchiveRecords archiveRecords)
    {
        boolean result = updateById(archiveRecords);
        if(result)
        return 1;
        else
            return 0;
    }
 
    /**
     * 批量删除档案记录
     * 
     * @param ids 需要删除的档案记录主键
     * @return 结果
     */
    @Override
    public int deleteArchiveRecordsByIds(Long[] ids)
    {
        if (this.removeByIds(Arrays.asList(ids))) {
            return 1;
        }
        else
            return 0;
    }
 
    /**
     * 删除档案记录信息
     * 
     * @param id 档案记录主键
     * @return 结果
     */
    @Override
    public int deleteArchiveRecordsById(Long id)
    {
        return 0;
    }
}