@@ -34,7 +34,10 @@ import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDetailDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDetailDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientParameterDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementParameterDataDO ;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementProjectDataDO ;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayParameterDataMapper ;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayParameterDataMapper ;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayProjectDataMapper ;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayProjectDataMapper ;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDataMapper ;
import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDataMapper ;
@@ -597,6 +600,244 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService {
}
}
return list ;
return list ;
}
}
@Override
@Transactional ( rollbackFor = Exception . class )
public void saveBatchSmpleAndQcAnalysis ( BusinessAssayTaskAnalysisSampleAndQcProjectRespVO vo ) {
BusinessAssayTaskDO businessAssayTaskDO = businessAssayTaskMapper . selectById ( vo . getBusinessAssayTaskId ( ) ) ;
businessAssayTaskDO . setFormValue ( vo . getFormValue ( ) ) ;
businessAssayTaskDO . setAssayTime ( vo . getAssayTime ( ) ) ;
businessAssayTaskDO . setTaskAssayStatus ( QmsCommonConstant . SAVED ) ;
//赋值数据集id
if ( vo . getDataCollectionId ( ) = = null ) {
ConfigAssayMethodDO configAssayMethodDO = configAssayMethodMapper . selectById ( businessAssayTaskDO . getConfigAssayMethodId ( ) ) ;
DataCollectionDO dataCollectionDO = dataCollectionService . getLatestDataCollectionByKey ( configAssayMethodDO . getDataCollectionKey ( ) ) ;
businessAssayTaskDO . setFormDataCollectionId ( dataCollectionDO . getId ( ) ) ;
} else {
businessAssayTaskDO . setFormDataCollectionId ( vo . getDataCollectionId ( ) ) ;
}
List < BusinessAssayTaskAnalysisDataRespVO > assayTaskAnalysisDataList = vo . getAssayTaskAnalysisDataList ( ) ;
for ( BusinessAssayTaskAnalysisDataRespVO businessAssayTaskAnalysisDataRespVO : assayTaskAnalysisDataList ) {
if ( " analysis " . equals ( businessAssayTaskAnalysisDataRespVO . getAnalysisType ( ) ) ) {
List < BusinessAssayTaskDataDO > businessAssayTaskDataList = businessAssayTaskDataMapper . selectList ( new LambdaQueryWrapperX < BusinessAssayTaskDataDO > ( ) . eq ( BusinessAssayTaskDataDO : : getBusinessAssayTaskId , vo . getBusinessAssayTaskId ( ) ) . eq ( BusinessAssayTaskDataDO : : getConfigAssayMethodId , businessAssayTaskDO . getConfigAssayMethodId ( ) ) ) ;
List < Long > businessAssayTaskDataIdList = businessAssayTaskDataList . stream ( ) . map ( m - > m . getId ( ) ) . collect ( Collectors . toList ( ) ) ;
List < BusinessAssayProjectDataDO > businessAssayProjectDataList = businessAssayProjectDataMapper . selectList ( new LambdaQueryWrapperX < BusinessAssayProjectDataDO > ( ) . in ( BusinessAssayProjectDataDO : : getBusinessAssayTaskDataId , businessAssayTaskDataIdList ) ) ;
List < Long > businessAssayProjectDataIdList = businessAssayProjectDataList . stream ( ) . map ( m - > m . getId ( ) ) . collect ( Collectors . toList ( ) ) ;
List < BusinessAssayParameterDataDO > businessAssayParameterDataList = businessAssayParameterDataMapper . selectList ( new LambdaQueryWrapperX < BusinessAssayParameterDataDO > ( ) . in ( BusinessAssayParameterDataDO : : getBusinessAssayProjectDataId , businessAssayProjectDataIdList ) ) ;
List < Map < String , Object > > datas = businessAssayTaskAnalysisDataRespVO . getDatas ( ) ;
for ( Map < String , Object > map : datas ) {
List < BusinessAssayProjectAndParameterRespVO > listBusinessAssayProjectAndParameter = new ArrayList < > ( ) ;
for ( Map . Entry < String , Object > entry : map . entrySet ( ) ) {
Object val = entry . getValue ( ) ;
if ( val instanceof String ) {
continue ;
}
BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameter = JSON . parseObject ( JSON . toJSONString ( val ) , BusinessAssayProjectAndParameterRespVO . class ) ;
listBusinessAssayProjectAndParameter . add ( businessAssayProjectAndParameter ) ;
}
for ( BusinessAssayProjectAndParameterRespVO pap : listBusinessAssayProjectAndParameter ) {
if ( " project " . equals ( pap . getType ( ) ) ) {
BusinessAssayProjectDataDO businessAssayProjectDataDO = businessAssayProjectDataList . stream ( ) . filter ( f - > f . getId ( ) . equals ( pap . getId ( ) ) ) . findFirst ( ) . orElse ( null ) ;
if ( StringUtils . isNotBlank ( pap . getValue ( ) ) ) {
String dataType = pap . getDataType ( ) ; //string-字符串, int-整数, decimal-小数,date-日期, datetime-时间
switch ( dataType ) {
case " int " :
case " date " :
case " datetime " :
case " string " :
businessAssayProjectDataDO . setValue ( pap . getValue ( ) ) ;
businessAssayProjectDataDO . setRemark ( pap . getShowName ( ) + " : " + pap . getValue ( ) ) ;
break ;
case " decimal " :
BigDecimal value = new BigDecimal ( pap . getValue ( ) ) ;
value = value . setScale ( pap . getDecimalPosition ( ) , RoundingMode . HALF_EVEN ) ;
businessAssayProjectDataDO . setValue ( value . toPlainString ( ) ) ;
businessAssayProjectDataDO . setRemark ( pap . getShowName ( ) + " : " + value . toPlainString ( ) ) ;
break ;
default :
throw new IllegalArgumentException ( " Unexpected value: " + dataType ) ;
}
} else {
businessAssayProjectDataDO . setValue ( null ) ;
}
} else if ( " parameter " . equals ( pap . getType ( ) ) ) {
BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataList . stream ( ) . filter ( f - > f . getId ( ) . equals ( pap . getId ( ) ) ) . findFirst ( ) . orElse ( null ) ;
if ( StringUtils . isNotBlank ( pap . getValue ( ) ) ) {
String dataType = pap . getDataType ( ) ; //string-字符串, int-整数, decimal-小数,date-日期, datetime-时间
switch ( dataType ) {
case " int " :
case " date " :
case " datetime " :
case " string " :
businessAssayParameterDataDO . setValue ( pap . getValue ( ) ) ;
businessAssayParameterDataDO . setRemark ( pap . getShowName ( ) + " : " + pap . getValue ( ) ) ;
break ;
case " decimal " :
BigDecimal value = new BigDecimal ( pap . getValue ( ) ) ;
value = value . setScale ( pap . getDecimalPosition ( ) , RoundingMode . HALF_EVEN ) ;
businessAssayParameterDataDO . setValue ( value . toPlainString ( ) ) ;
businessAssayParameterDataDO . setRemark ( pap . getShowName ( ) + " : " + value . toPlainString ( ) ) ;
break ;
default :
throw new IllegalArgumentException ( " Unexpected value: " + dataType ) ;
}
} else {
businessAssayParameterDataDO . setValue ( null ) ;
}
}
}
}
businessAssayProjectDataMapper . updateBatch ( businessAssayProjectDataList ) ;
if ( CollUtil . isNotEmpty ( businessAssayParameterDataList ) ) {
businessAssayParameterDataMapper . updateBatch ( businessAssayParameterDataList ) ;
}
} else if ( " zky " . equals ( businessAssayTaskAnalysisDataRespVO . getAnalysisType ( ) ) ) {
List < BusinessQCManagementDataDO > BusinessQCManagementDataList = businessQCManagementDataMapper . selectByBusinessAssayTaskId ( businessAssayTaskDO . getId ( ) ) ;
List < Long > businessQCManagementDataIdList = BusinessQCManagementDataList . stream ( ) . map ( m - > m . getId ( ) ) . collect ( Collectors . toList ( ) ) ;
List < BusinessQCManagementProjectDataDO > businessQCManagementProjectDataList = businessQCManagementProjectDataMapper . selectByBusinessQCManagementDataIds ( businessQCManagementDataIdList ) ;
List < Long > businessQCManagementProjectDataIdList = businessQCManagementProjectDataList . stream ( ) . map ( m - > m . getId ( ) ) . collect ( Collectors . toList ( ) ) ;
List < BusinessQCManagementParameterDataDO > businessQCManagementParameterDataList = businessQCManagementParameterDataMapper . selectByBusinessQCManagementProjectDataIds ( businessQCManagementProjectDataIdList ) ;
List < Map < String , Object > > datas = businessAssayTaskAnalysisDataRespVO . getDatas ( ) ;
for ( Map < String , Object > map : datas ) {
List < BusinessAssayProjectAndParameterRespVO > listBusinessAssayProjectAndParameter = new ArrayList < > ( ) ;
for ( Map . Entry < String , Object > entry : map . entrySet ( ) ) {
Object val = entry . getValue ( ) ;
if ( val instanceof String ) {
continue ;
}
BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameter = JSON . parseObject ( JSON . toJSONString ( val ) , BusinessAssayProjectAndParameterRespVO . class ) ;
listBusinessAssayProjectAndParameter . add ( businessAssayProjectAndParameter ) ;
}
for ( BusinessAssayProjectAndParameterRespVO pap : listBusinessAssayProjectAndParameter ) {
if ( " project " . equals ( pap . getType ( ) ) ) {
BusinessQCManagementProjectDataDO businessQCManagementProjectDataDO = businessQCManagementProjectDataList . stream ( ) . filter ( f - > f . getId ( ) . equals ( pap . getId ( ) ) ) . findFirst ( ) . orElse ( null ) ;
if ( StringUtils . isNotBlank ( pap . getValue ( ) ) ) {
String dataType = pap . getDataType ( ) ; //string-字符串, int-整数, decimal-小数,date-日期, datetime-时间
switch ( dataType ) {
case " int " :
case " date " :
case " datetime " :
case " string " :
businessQCManagementProjectDataDO . setValue ( pap . getValue ( ) ) ;
businessQCManagementProjectDataDO . setRemark ( pap . getShowName ( ) + " : " + pap . getValue ( ) ) ;
break ;
case " decimal " :
BigDecimal value = new BigDecimal ( pap . getValue ( ) ) ;
value = value . setScale ( pap . getDecimalPosition ( ) , RoundingMode . HALF_EVEN ) ;
businessQCManagementProjectDataDO . setValue ( value . toPlainString ( ) ) ;
businessQCManagementProjectDataDO . setRemark ( pap . getShowName ( ) + " : " + value . toPlainString ( ) ) ;
break ;
default :
throw new IllegalArgumentException ( " Unexpected value: " + dataType ) ;
}
} else {
businessQCManagementProjectDataDO . setValue ( null ) ;
}
} else if ( " parameter " . equals ( pap . getType ( ) ) ) {
BusinessQCManagementParameterDataDO businessQCManagementParameterDataDO = businessQCManagementParameterDataList . stream ( ) . filter ( f - > f . getId ( ) . equals ( pap . getId ( ) ) ) . findFirst ( ) . orElse ( null ) ;
if ( StringUtils . isNotBlank ( pap . getValue ( ) ) ) {
String dataType = pap . getDataType ( ) ; //string-字符串, int-整数, decimal-小数,date-日期, datetime-时间
switch ( dataType ) {
case " int " :
case " date " :
case " datetime " :
case " string " :
businessQCManagementParameterDataDO . setValue ( pap . getValue ( ) ) ;
businessQCManagementParameterDataDO . setRemark ( pap . getShowName ( ) + " : " + pap . getValue ( ) ) ;
break ;
case " decimal " :
BigDecimal value = new BigDecimal ( pap . getValue ( ) ) ;
value = value . setScale ( pap . getDecimalPosition ( ) , RoundingMode . HALF_EVEN ) ;
businessQCManagementParameterDataDO . setValue ( value . toPlainString ( ) ) ;
businessQCManagementParameterDataDO . setRemark ( pap . getShowName ( ) + " : " + value . toPlainString ( ) ) ;
break ;
default :
throw new IllegalArgumentException ( " Unexpected value: " + dataType ) ;
}
} else {
businessQCManagementParameterDataDO . setValue ( null ) ;
}
}
}
}
businessQCManagementProjectDataMapper . updateBatch ( businessQCManagementProjectDataList ) ;
if ( CollUtil . isNotEmpty ( businessQCManagementParameterDataList ) ) {
businessQCManagementParameterDataMapper . updateBatch ( businessQCManagementParameterDataList ) ;
}
} else {
List < BusinessQCCoefficientDataDO > businessQCCoefficientDataList = businessQCCoefficientDataMapper . selectByBusinessAssayTaskId ( businessAssayTaskDO . getId ( ) ) ;
List < Long > businessQCCoefficientDataIdList = businessQCCoefficientDataList . stream ( ) . map ( m - > m . getId ( ) ) . collect ( Collectors . toList ( ) ) ;
List < BusinessQCCoefficientParameterDataDO > businessQCCoefficientParameterDataList = businessQCCoefficientParameterDataMapper . selectByBusinessQCCoefficientDataIds ( businessQCCoefficientDataIdList ) ;
List < Map < String , Object > > datas = businessAssayTaskAnalysisDataRespVO . getDatas ( ) ;
for ( Map < String , Object > map : datas ) {
List < BusinessAssayProjectAndParameterRespVO > listBusinessAssayProjectAndParameter = new ArrayList < > ( ) ;
for ( Map . Entry < String , Object > entry : map . entrySet ( ) ) {
Object val = entry . getValue ( ) ;
if ( val instanceof String ) {
continue ;
}
BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameter = JSON . parseObject ( JSON . toJSONString ( val ) , BusinessAssayProjectAndParameterRespVO . class ) ;
listBusinessAssayProjectAndParameter . add ( businessAssayProjectAndParameter ) ;
}
for ( BusinessAssayProjectAndParameterRespVO pap : listBusinessAssayProjectAndParameter ) {
if ( " parameter " . equals ( pap . getType ( ) ) ) {
BusinessQCCoefficientParameterDataDO businessQCCoefficientParameterDataDO = businessQCCoefficientParameterDataList . stream ( ) . filter ( f - > f . getId ( ) . equals ( pap . getId ( ) ) ) . findFirst ( ) . orElse ( null ) ;
if ( StringUtils . isNotBlank ( pap . getValue ( ) ) ) {
String dataType = pap . getDataType ( ) ; //string-字符串, int-整数, decimal-小数,date-日期, datetime-时间
switch ( dataType ) {
case " int " :
case " date " :
case " datetime " :
case " string " :
businessQCCoefficientParameterDataDO . setValue ( pap . getValue ( ) ) ;
businessQCCoefficientParameterDataDO . setRemark ( pap . getShowName ( ) + " : " + pap . getValue ( ) ) ;
break ;
case " decimal " :
BigDecimal value = new BigDecimal ( pap . getValue ( ) ) ;
value = value . setScale ( pap . getDecimalPosition ( ) , RoundingMode . HALF_EVEN ) ;
businessQCCoefficientParameterDataDO . setValue ( value . toPlainString ( ) ) ;
businessQCCoefficientParameterDataDO . setRemark ( pap . getShowName ( ) + " : " + value . toPlainString ( ) ) ;
break ;
default :
throw new IllegalArgumentException ( " Unexpected value: " + dataType ) ;
}
} else {
businessQCCoefficientParameterDataDO . setValue ( null ) ;
}
}
}
}
businessQCCoefficientParameterDataMapper . updateBatch ( businessQCCoefficientParameterDataList ) ;
}
}
businessAssayTaskMapper . updateById ( businessAssayTaskDO ) ;
}
@Override
@Override