lyh
2 天以前 82c1b82a6d46620a5ae493353c37d40da691f716
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.ProductInfo;
import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
import org.jeecg.modules.dnc.mapper.ProductInfoMapper;
import org.jeecg.modules.dnc.service.DataPackageStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service
public class ProductPackageStrategy implements DataPackageStrategy {
    @Autowired
    private ProductInfoMapper productInfoMapper;
    @Autowired
    private DeviceTypeMapper deviceTypeMapper;
    @Autowired
    private FullHierarchyTraceService traceService;
    @Autowired
    private DocRelativeMapper docRelativeMapper;
 
    @Override
    public TransferPackage packageData(String relativeId) {
        DocRelative docRelative=docRelativeMapper.selectById(relativeId);
        ProductInfo productInfo=productInfoMapper.selectById(docRelative.getAttributionId());
        if (productInfo == null) {
            throw new IllegalArgumentException("对应的产品不存在: " + docRelative.getAttributionId());
        }
        return TransferPackage.builder()
                .dataType(TransferPackage.DataType.PRODUCT)
                .docRelative(docRelative)
                .traceChain(traceService.traceFromProduct(docRelative))
                .build();
    }
}