fei
1 天以前 e899d2709f21b322232fb64778fef296233be3f0
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
package com.ruoyi.service.impl;
 
 
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.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ArchiveRecords;
import com.ruoyi.domain.Archiverecordstouser;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.DocumentMaterialsVo;
import com.ruoyi.mapper.DocumentMaterialsMapper;
import com.ruoyi.service.IArchiveCategoryService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.util.ErrorcodeExceptionextends;
import org.springframework.stereotype.Service;
 
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
 
@Service
public class DocumentMaterialsServiceImpl  extends ServiceImpl<DocumentMaterialsMapper, DocumentMaterials> implements IDocumentMaterialsService {
    private LambdaQueryWrapper<DocumentMaterials> buildCondition(DocumentMaterials documentMaterials){
        LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
 
        lqw.like(!StringUtils.isEmpty(documentMaterials.getCreator()), DocumentMaterials::getCreator, documentMaterials.getCreator())
                .like(!StringUtils.isEmpty(documentMaterials.getStage()), DocumentMaterials::getStage, documentMaterials.getStage())
                .like(!StringUtils.isEmpty(documentMaterials.getIsCanceled()), DocumentMaterials::getIsCanceled, documentMaterials.getIsCanceled())
                .like(!StringUtils.isEmpty(documentMaterials.getIsAttachment()), DocumentMaterials::getIsAttachment, documentMaterials.getIsAttachment())
                .like(!StringUtils.isEmpty(documentMaterials.getIsSensitive()), DocumentMaterials::getIsSensitive, documentMaterials.getIsSensitive())
                .like(!StringUtils.isEmpty(documentMaterials.getPublicity()), DocumentMaterials::getPublicity, documentMaterials.getPublicity())
                .like(!StringUtils.isEmpty(documentMaterials.getRetentionPeriod()), DocumentMaterials::getRetentionPeriod, documentMaterials.getRetentionPeriod())
                .like(!StringUtils.isEmpty(documentMaterials.getSecurityLevel()), DocumentMaterials::getSecurityLevel, documentMaterials.getSecurityLevel())
                .eq(documentMaterials.getDate()!=null, DocumentMaterials::getDate, documentMaterials.getDate())
                .eq(documentMaterials.getRecordId()!=null, DocumentMaterials::getRecordId, documentMaterials.getRecordId());
//                .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.orderByAsc(DocumentMaterials::getPageNumber);
 
        System.out.println("ssssssssssssddd0000000000000000");
        return lqw;
 
    }
    @Override
    public AjaxResult selectDataList(DocumentMaterials documentMaterials, Integer pageNum, Integer pageSize) {
        LambdaQueryWrapper<DocumentMaterials> lqw = buildCondition(documentMaterials);
 
 
        Page<DocumentMaterials> zfClanPage = new Page<>(pageNum, pageSize);
        Page<DocumentMaterials> pageResult = page(zfClanPage, lqw);
 
        List<DocumentMaterials> beanRecords = pageResult.getRecords();//得到查询出来的数据
 
        System.out.println(beanRecords);
//        beanRecords.forEach(record -> {
//            if (record.getUserId() != null) {
//                SysUser user = userMapper.selectUserById(record.getUserId());
//                record.setSysUser(user); // 假设Archiverecordstouser中有setUser方法
//            }
//        });
        //  List<ArchiveRecords> beanRecords = list(lqw);
        //   log.info("从数据库中查到的为:{}", beanRecords);
        //    return markOwnData(familyId, fatherFaId, motherFaId, beanRecords);
        HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
 
 
        return AjaxResult.success(data);    }
 
 
 
    @Override
    public DocumentMaterials selectDocumentMaterialsByMaterialId(String materialId) {
 
 
        LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
        lqw.eq(materialId!=null, DocumentMaterials::getMaterialId, materialId);
        List<DocumentMaterials> records = list(lqw);
        if(!records.isEmpty())
            return records.get(0);
        else
            return null;
    }
 
    @Override
    public List<DocumentMaterials> selectDocumentMaterialsList(DocumentMaterials documentMaterials) {
        LambdaQueryWrapper<DocumentMaterials> lambdaQueryWrapper = buildCondition(documentMaterials);
        List<DocumentMaterials> beanRecords = list(lambdaQueryWrapper);
        return beanRecords;
    }
 
    @Override
    public int insertDocumentMaterials(DocumentMaterials documentMaterials) {
        LocalDateTime time = LocalDateTime.now();
 
        Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
        documentMaterials.setCreatedAt(date);
        System.out.println(documentMaterials.getFileStyle());
        System.out.println(documentMaterials.getPageNumber());
//        if(documentMaterials.getPageNumber()==null)
//        {
//            documentMaterials.setPageNumber(-1L);
//        }
        boolean res = false;
        try {
             res = this.save(documentMaterials);
 
        } catch (Exception e) {
            System.out.println(e);
            throw new ErrorcodeExceptionextends(500, "同一个案卷内,不允许页码重复!");
        }
        if(res)
            return 1;
        else
            return 0;
    }
 
    @Override
    public int updateDocumentMaterials(DocumentMaterials documentMaterials) {
 
        boolean result = updateById(documentMaterials);
        if(result)
            return 1;
        else
            return 0;
    }
 
    @Override
    public int deleteDocumentMaterialsByMaterialIds(String[] materialIds) {
        if (this.removeByIds(Arrays.asList(materialIds))) {
            return 1;
        }
        else
            return 0;
    }
 
    @Override
    public int deleteDocumentMaterialsByMaterialId(String materialId) {
        return 0;
    }
 
    @Override
    public Long getFiNum(Long pageNumber) {
        return this.baseMapper.getFileNumber(pageNumber);
    }
 
    @Override
    public int updateByPageNumber(Long pageNumber, Long fileNumber, int width, int height, double fileSize, String url, String format) {
        //根据pageNumber拿到title,然后计算pageOrder
        LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>();
        lqw.eq(pageNumber!=null, DocumentMaterials::getPageNumber, pageNumber);
        List<DocumentMaterials> records = list(lqw);
 
        Long pageOrder = 1L;
        if(pageNumber.equals(1))
            pageOrder = 1L;
        else {
            Long maxPOrder = this.baseMapper.getMaxPageOrder(records.get(0).getTitle(), pageNumber, records.get(0).getStage());
            if (maxPOrder != null)
                pageOrder = maxPOrder + 1;
        }
 
        this.baseMapper.updateInfoByPageNumber(pageNumber, fileNumber,pageOrder, width, height, fileSize, url,format);
 
        return 0;
    }
 
    @Override
    public List<DocumentMaterialsVo> findArchMInfo(String recordId) {
        return this.baseMapper.getArchiveMatInfo(recordId);
    }
}