lyh
3 天以前 b1e37337ac05917ad6989177bc639acc2c065600
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
package org.jeecg.modules.dnc.service.impl;
 
import org.jeecg.modules.dnc.dto.TransferPackage;
import org.jeecg.modules.dnc.entity.DocRelative;
import org.jeecg.modules.dnc.entity.PartsInfo;
import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
import org.jeecg.modules.dnc.mapper.PartsInfoMapper;
import org.jeecg.modules.dnc.service.DataPackageStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service
public class PartsPackageStrategy implements DataPackageStrategy {
    @Autowired
    private PartsInfoMapper partsInfoMapper;
    @Autowired
    private DeviceTypeMapper deviceTypeMapper;
    @Autowired
    private FullHierarchyTraceService traceService;
    @Autowired
    private DocRelativeMapper docRelativeMapper;
 
    @Override
    public TransferPackage packageData(String relativeId) {
        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
        PartsInfo partsInfo=partsInfoMapper.selectById(docRelative.getAttributionId());
        if (partsInfo == null) {
            throw new IllegalArgumentException("对应的零件不存在: " + docRelative.getAttributionId());
        }
        return TransferPackage.builder()
                .dataType(TransferPackage.DataType.PARTS)
                .docRelative(docRelative)
                .traceChain(traceService.traceFromParts(docRelative))
                .build();
    }
}