刘光辉
3 小时以前 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
package jnpf.dmsService;
 
import jnpf.dmsEntity.fenfa.DmsWenjianChongdaFasong;
import jnpf.dmsEntity.fenfa.form.DmsWenjianChongdaForm;
import jnpf.exception.DataException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.UUID;
import java.io.IOException;
 
/** 转换/计页在副本事务之外执行,避免长时间占用记录锁。 */
@Service
@RequiredArgsConstructor
public class DmsWenjianChongdaPlanService {
    private final DmsWenjianChongdaService reprints;
    private final DmsFilePageCountService pageCounts;
 
    public DmsWenjianChongdaFasong plan(DmsWenjianChongdaForm form) throws DataException {
        var attempt = reprints.status(form);
        if (!"OPEN".equals(attempt.getState()) || attempt.getPageCount() != null) return attempt;
        try {
            var counted = pageCounts.getPageCount(UUID.fromString(attempt.getFileVersionId()));
            if (counted == null || !UUID.fromString(attempt.getFileVersionId()).equals(counted.getFileVersionId()))
                throw new DataException("文件完整页数查询结果不匹配");
            return reprints.plan(form, attempt.getFileVersionId(), counted.getPageCount());
        } catch (IOException e) {
            throw new DataException("文件完整页数读取失败,请稍后恢复原任务");
        }
    }
}