@ -4,6 +4,7 @@ import com.gaotao.common.exception.XJException;
import com.gaotao.modules.pms.data.* ;
import com.gaotao.modules.pms.data.* ;
import com.gaotao.modules.pms.mapper.QcMapper ;
import com.gaotao.modules.pms.mapper.QcMapper ;
import com.gaotao.modules.pms.service.EquipmentDataImportService ;
import com.gaotao.modules.pms.service.EquipmentDataImportService ;
import com.gaotao.modules.pms.util.PmsI18nHelper ;
import com.gaotao.modules.reader.entity.EquipmentDataDetail ;
import com.gaotao.modules.reader.entity.EquipmentDataDetail ;
import lombok.extern.slf4j.Slf4j ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
@ -28,6 +29,9 @@ public class EquipmentDataImportServiceImpl implements EquipmentDataImportServic
@Autowired
@Autowired
private QcMapper qcMapper ;
private QcMapper qcMapper ;
@Autowired
private PmsI18nHelper pmsI18nHelper ;
@Override
@Override
public void importAll ( QcFAIRecordData data ) {
public void importAll ( QcFAIRecordData data ) {
importInternal ( data , null ) ;
importInternal ( data , null ) ;
@ -36,7 +40,7 @@ public class EquipmentDataImportServiceImpl implements EquipmentDataImportServic
@Override
@Override
public void importByItem ( QcFAIRecordData data ) {
public void importByItem ( QcFAIRecordData data ) {
if ( StringUtils . isBlank ( data . getItemNo ( ) ) ) {
if ( StringUtils . isBlank ( data . getItemNo ( ) ) ) {
throw new XJException ( "数据采集失败(未指定检验项目)!" , 400 ) ;
throw new RuntimeException ( pmsI18nHelper . text ( "pms.error.collect.itemNo.empty" , null , "数据采集失败(未指定检验项目)!" ) ) ;
}
}
importInternal ( data , data . getItemNo ( ) ) ;
importInternal ( data , data . getItemNo ( ) ) ;
}
}
@ -44,18 +48,18 @@ public class EquipmentDataImportServiceImpl implements EquipmentDataImportServic
private void importInternal ( QcFAIRecordData data , String itemNoFilter ) {
private void importInternal ( QcFAIRecordData data , String itemNoFilter ) {
String partNo = qcMapper . getInspectionPartNo ( data ) ;
String partNo = qcMapper . getInspectionPartNo ( data ) ;
if ( StringUtils . isBlank ( partNo ) ) {
if ( StringUtils . isBlank ( partNo ) ) {
throw new XJException ( "数据采集失败(未获取到检验单物料编码)!" , 400 ) ;
throw new RuntimeException ( pmsI18nHelper . text ( "pms.error.collect.partNo.empty" , null , "数据采集失败(未获取到检验单物料编码)!" ) ) ;
}
}
Map < String , EquipmentDataAcquisitionData > acquisitionByItem = loadAcquisitionByItem ( data , itemNoFilter ) ;
Map < String , EquipmentDataAcquisitionData > acquisitionByItem = loadAcquisitionByItem ( data , itemNoFilter ) ;
if ( CollectionUtils . isEmpty ( acquisitionByItem ) ) {
if ( CollectionUtils . isEmpty ( acquisitionByItem ) ) {
throw new XJ Exception( "数据采集失败(未找到检验单所选设备,请先开始检验并选择设备)!" , 400 ) ;
throw new Runtime Exception( pmsI18nHelper . text ( "pms.error.equipment.notFound" , null , "数据采集失败(未找到检验单所选设备,请先开始检验并选择设备)!" ) ) ;
}
}
List < String > inspectionItems ;
List < String > inspectionItems ;
if ( itemNoFilter ! = null ) {
if ( itemNoFilter ! = null ) {
if ( ! acquisitionByItem . containsKey ( itemNoFilter ) ) {
if ( ! acquisitionByItem . containsKey ( itemNoFilter ) ) {
throw new XJ Exception( "数据采集失败(未找到该项目所选设备,请先开始检验并选择设备)!" , 400 ) ;
throw new Runtime Exception( pmsI18nHelper . text ( "pms.error.equipment.notFound" , null , "数据采集失败(未找到该项目所选设备,请先开始检验并选择设备)!" ) ) ;
}
}
inspectionItems = Collections . singletonList ( itemNoFilter ) ;
inspectionItems = Collections . singletonList ( itemNoFilter ) ;
} else {
} else {
@ -64,7 +68,7 @@ public class EquipmentDataImportServiceImpl implements EquipmentDataImportServic
List < ItemImportTarget > targets = resolveImportTargets ( data , inspectionItems , acquisitionByItem ) ;
List < ItemImportTarget > targets = resolveImportTargets ( data , inspectionItems , acquisitionByItem ) ;
if ( targets . isEmpty ( ) ) {
if ( targets . isEmpty ( ) ) {
throw new XJException ( "当前项目未配置关联设备。" , 400 ) ;
throw new RuntimeException ( pmsI18nHelper . text ( "pms.error.item.noEquipment" , null , "当前项目未配置关联设备。" ) ) ;
}
}
boolean imported = false ;
boolean imported = false ;
@ -96,7 +100,7 @@ public class EquipmentDataImportServiceImpl implements EquipmentDataImportServic
List < EquipmentDataDetail > parsedRows = qcMapper . listLatestEquipmentDataDetail (
List < EquipmentDataDetail > parsedRows = qcMapper . listLatestEquipmentDataDetail (
data . getSite ( ) , data . getBuNo ( ) , target . getEquipmentNo ( ) ) ;
data . getSite ( ) , data . getBuNo ( ) , target . getEquipmentNo ( ) ) ;
if ( CollectionUtils . isEmpty ( parsedRows ) ) {
if ( CollectionUtils . isEmpty ( parsedRows ) ) {
throw new XJException ( "未获取到检测设备数据,请检查设备!" , 400 ) ;
throw new RuntimeException ( pmsI18nHelper . text ( "pms.error.equipment.dataNotFound" , null , "未获取到检测设备数据,请检查设备!" ) ) ;
}
}
int fileMaxColumn = resolveFileMaxColumn ( parsedRows ) ;
int fileMaxColumn = resolveFileMaxColumn ( parsedRows ) ;
@ -110,9 +114,9 @@ public class EquipmentDataImportServiceImpl implements EquipmentDataImportServic
if ( ! imported ) {
if ( ! imported ) {
if ( hasFileModeTarget & & ! hasMappingConfig ) {
if ( hasFileModeTarget & & ! hasMappingConfig ) {
throw new XJException ( "当前物料及设备未配置文件列映射关系。" , 400 ) ;
throw new RuntimeException ( pmsI18nHelper . text ( "pms.error.fileMapping.notConfigured" , null , "当前物料及设备未配置文件列映射关系。" ) ) ;
}
}
throw new XJException ( "未获取到检测设备数据,请检查设备!" , 400 ) ;
throw new RuntimeException ( pmsI18nHelper . text ( "pms.error.equipment.dataNotFound" , null , "未获取到检测设备数据,请检查设备!" ) ) ;
}
}
}
}