刘光辉
4 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
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
package jnpf.dmsService.impl;
 
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import jnpf.dmsEntity.DmsDanganCundangShenqingDanganheEntity;
import jnpf.dmsEntity.form.DmsDanganCundangDanganhePrintCallbackForm;
import jnpf.dmsMapper.DmsDanganCundangShenqingDanganheMapper;
import jnpf.dmsService.DmsDanganCundangDanganhePrintCallbackService;
import jnpf.exception.DataException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
 
@Service
@RequiredArgsConstructor
public class DmsDanganCundangDanganhePrintCallbackServiceImpl
        implements DmsDanganCundangDanganhePrintCallbackService {
 
    private final DmsDanganCundangShenqingDanganheMapper danganheMapper;
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void markPrinted(List<DmsDanganCundangDanganhePrintCallbackForm> danganheList)
            throws DataException {
        Set<String> danganheIds = resolveDanganheIds(danganheList);
        LambdaUpdateWrapper<DmsDanganCundangShenqingDanganheEntity> update = new LambdaUpdateWrapper<>();
        update.in(DmsDanganCundangShenqingDanganheEntity::getId, danganheIds)
                .isNull(DmsDanganCundangShenqingDanganheEntity::getDeleteMark)
                .set(DmsDanganCundangShenqingDanganheEntity::getShifouYidayin, "yes");
        danganheMapper.update(null, update);
    }
 
    private Set<String> resolveDanganheIds(
            List<DmsDanganCundangDanganhePrintCallbackForm> danganheList) throws DataException {
        if (danganheList == null || danganheList.isEmpty()) {
            throw new DataException("档案盒打印回调参数不能为空");
        }
        Set<String> ids = new LinkedHashSet<>();
        for (DmsDanganCundangDanganhePrintCallbackForm danganhe : danganheList) {
            if (danganhe == null || trimToEmpty(danganhe.getFId()).isEmpty()) {
                throw new DataException("档案盒打印回调中的f_id不能为空");
            }
            ids.add(danganhe.getFId().trim());
        }
        return ids;
    }
 
    private String trimToEmpty(String value) {
        return value == null ? "" : value.trim();
    }
}