package org.jeecg.modules.dnc.service.impl;
|
|
import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
|
import org.jeecg.modules.dnc.dto.TransferPackage;
|
import org.jeecg.modules.dnc.entity.DeviceType;
|
import org.jeecg.modules.dnc.entity.DocRelative;
|
import org.jeecg.modules.dnc.entity.ProcessStream;
|
import org.jeecg.modules.dnc.mapper.DeviceTypeMapper;
|
import org.jeecg.modules.dnc.mapper.DocRelativeMapper;
|
import org.jeecg.modules.dnc.mapper.ProcessStreamMapper;
|
import org.jeecg.modules.dnc.service.DataPackageStrategy;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
@Service
|
public class ProcessPackageStrategy implements DataPackageStrategy {
|
@Autowired
|
private ProcessStreamMapper processMapper;
|
@Autowired
|
private DeviceTypeMapper deviceTypeMapper;
|
@Autowired
|
private FullHierarchyTraceService traceService;
|
@Autowired
|
private DocRelativeMapper docRelativeMapper;
|
|
@Override
|
public TransferPackage packageData(String relativeId) {
|
DocRelative docRelative=docRelativeMapper.selectById(relativeId);
|
DeviceType deviceType=deviceTypeMapper.selectById(docRelative.getAttributionId());
|
if (deviceType!=null&&deviceType.getAttributionType().equals(DocAttributionTypeEnum.PROCESS.getCode())) {
|
ProcessStream process = processMapper.selectById(deviceType.getAttributionId());
|
if (process == null) {
|
throw new IllegalArgumentException("设备类对应的工序不存在: " + deviceType.getDeviceManagementId());
|
}
|
}
|
return TransferPackage.builder()
|
.dataType(TransferPackage.DataType.PROCESS)
|
.docRelative(docRelative)
|
.traceChain(traceService.traceFromProcess(docRelative))
|
.build();
|
}
|
}
|