basic
parent
6619fac199
commit
25e0de824b
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.qinan.safetyeval.app.convertor;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.qinan.safetyeval.domain.entity.OrgEquipmentEntity;
|
||||||
|
import org.qinan.safetyeval.domain.entity.QualFilingEquipmentEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装备信息转换器
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface OrgEquipmentConvertor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业装备转备案装备快照
|
||||||
|
*/
|
||||||
|
@Mapping(target = "id", ignore = true)
|
||||||
|
@Mapping(target = "sourceEquipmentId", source = "source.id")
|
||||||
|
@Mapping(target = "filingId", source = "filingId")
|
||||||
|
@Mapping(target = "instrumentTypeCode", ignore = true)
|
||||||
|
@Mapping(target = "calibrationReportUrl", ignore = true)
|
||||||
|
@Mapping(target = "tenantId", ignore = true)
|
||||||
|
@Mapping(target = "orgId", ignore = true)
|
||||||
|
QualFilingEquipmentEntity toFilingEquipment(Long filingId, OrgEquipmentEntity source);
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.qinan.safetyeval.app.support;
|
package org.qinan.safetyeval.app.support;
|
||||||
|
|
||||||
|
import org.qinan.safetyeval.app.convertor.OrgEquipmentConvertor;
|
||||||
import org.qinan.safetyeval.domain.entity.OrgEquipmentEntity;
|
import org.qinan.safetyeval.domain.entity.OrgEquipmentEntity;
|
||||||
import org.qinan.safetyeval.domain.entity.QualFilingEquipmentEntity;
|
import org.qinan.safetyeval.domain.entity.QualFilingEquipmentEntity;
|
||||||
import org.qinan.safetyeval.domain.exception.BizException;
|
import org.qinan.safetyeval.domain.exception.BizException;
|
||||||
|
|
@ -25,6 +26,9 @@ public class QualFilingOrgEquipmentImporter {
|
||||||
@Resource
|
@Resource
|
||||||
private QualFilingEquipmentGateway qualFilingEquipmentGateway;
|
private QualFilingEquipmentGateway qualFilingEquipmentGateway;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrgEquipmentConvertor orgEquipmentConvertor;
|
||||||
|
|
||||||
public int importFromOrg(Long filingId, List<Long> sourceEquipmentIds) {
|
public int importFromOrg(Long filingId, List<Long> sourceEquipmentIds) {
|
||||||
if (sourceEquipmentIds == null || sourceEquipmentIds.isEmpty()) {
|
if (sourceEquipmentIds == null || sourceEquipmentIds.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -44,31 +48,9 @@ public class QualFilingOrgEquipmentImporter {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
throw new BizException(ErrorCode.ORG_EQUIPMENT_NOT_FOUND);
|
throw new BizException(ErrorCode.ORG_EQUIPMENT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
qualFilingEquipmentGateway.save(toFilingEquipment(filingId, source));
|
qualFilingEquipmentGateway.save(orgEquipmentConvertor.toFilingEquipment(filingId, source));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private QualFilingEquipmentEntity toFilingEquipment(Long filingId, OrgEquipmentEntity source) {
|
|
||||||
QualFilingEquipmentEntity entity = new QualFilingEquipmentEntity();
|
|
||||||
entity.setFilingId(filingId);
|
|
||||||
entity.setSourceEquipmentId(source.getId());
|
|
||||||
entity.setDeviceName(source.getDeviceName());
|
|
||||||
entity.setDeviceModel(source.getDeviceModel());
|
|
||||||
entity.setInstrumentTypeCode(source.getInstrumentTypeCode());
|
|
||||||
entity.setInstrumentTypeName(source.getInstrumentTypeName());
|
|
||||||
entity.setDeviceTypeCode(source.getDeviceTypeCode());
|
|
||||||
entity.setDeviceTypeName(source.getDeviceTypeName());
|
|
||||||
entity.setManufacturer(source.getManufacturer());
|
|
||||||
entity.setFlowDesc(source.getFlowDesc());
|
|
||||||
entity.setMinFlow(source.getMinFlow());
|
|
||||||
entity.setMaxFlow(source.getMaxFlow());
|
|
||||||
entity.setCalibrationUnit(source.getCalibrationUnit());
|
|
||||||
entity.setCalibrationInitValue(source.getCalibrationInitValue());
|
|
||||||
entity.setFieldCalibrationTypeCode(source.getFieldCalibrationTypeCode());
|
|
||||||
entity.setFieldCalibrationTypeName(source.getFieldCalibrationTypeName());
|
|
||||||
entity.setDualChannelFlag(source.getDualChannelFlag());
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue