合格率空指针异常,已修改

This commit is contained in:
LiWeiJie 2024-01-09 17:09:02 +08:00
parent 02f4c6560f
commit 300efbd0b7
2 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package com.god.qcfgjIndustrialVision.service.impl;
import com.god.common.utils.StringUtils;
import com.god.common.utils.uuid.IdUtils;
import com.god.qcfgjIndustrialVision.domain.QcfgjComprehensiveQualityStatistics;
import com.god.qcfgjIndustrialVision.domain.QcfgjQualificationRateStatistics;
@ -54,8 +55,8 @@ public class QcfgjComprehensiveQualityStatisticsServiceImpl implements IQcfgjCom
@Override
public int insertQcfgjComprehensiveQualityStatistics(QcfgjComprehensiveQualityStatistics qcfgjComprehensiveQualityStatistics)
{
qcfgjComprehensiveQualityStatistics=computePassRate(qcfgjComprehensiveQualityStatistics);
qcfgjComprehensiveQualityStatistics.setId(IdUtils.fastSimpleUUID());
qcfgjComprehensiveQualityStatistics=computePassRate(qcfgjComprehensiveQualityStatistics);
return qcfgjComprehensiveQualityStatisticsMapper.insertQcfgjComprehensiveQualityStatistics(qcfgjComprehensiveQualityStatistics);
}
@ -79,7 +80,7 @@ public class QcfgjComprehensiveQualityStatisticsServiceImpl implements IQcfgjCom
*/
private QcfgjComprehensiveQualityStatistics computePassRate(QcfgjComprehensiveQualityStatistics qcfgjComprehensiveQualityStatistics){
//用于自动填充合格率,并且保存2位小数
if (!qcfgjComprehensiveQualityStatistics.getTotalTestCount().isEmpty() && !qcfgjComprehensiveQualityStatistics.getUnqualifiedQuantity().isEmpty()){
if (!StringUtils.isEmpty(qcfgjComprehensiveQualityStatistics.getTotalTestCount()) && !StringUtils.isEmpty(qcfgjComprehensiveQualityStatistics.getUnqualifiedQuantity())){
Double totalTestCount = new Double(qcfgjComprehensiveQualityStatistics.getTotalTestCount());
Double unqualifiedQuantity = new Double(qcfgjComprehensiveQualityStatistics.getUnqualifiedQuantity());
double QualifiedRate = (totalTestCount-unqualifiedQuantity) / totalTestCount * 100;

View File

@ -1,5 +1,6 @@
package com.god.qcfgjIndustrialVision.service.impl;
import com.god.common.utils.StringUtils;
import com.god.common.utils.uuid.IdUtils;
import com.god.qcfgjIndustrialVision.domain.QcfgjQualificationRateStatistics;
import com.god.qcfgjIndustrialVision.mapper.QcfgjQualificationRateStatisticsMapper;
@ -53,8 +54,8 @@ public class QcfgjQualificationRateStatisticsServiceImpl implements IQcfgjQualif
@Override
public int insertQcfgjQualificationRateStatistics(QcfgjQualificationRateStatistics qcfgjQualificationRateStatistics)
{
qcfgjQualificationRateStatistics=computePassRate(qcfgjQualificationRateStatistics);
qcfgjQualificationRateStatistics.setId(IdUtils.fastSimpleUUID());
qcfgjQualificationRateStatistics=computePassRate(qcfgjQualificationRateStatistics);
return qcfgjQualificationRateStatisticsMapper.insertQcfgjQualificationRateStatistics(qcfgjQualificationRateStatistics);
}
@ -78,7 +79,7 @@ public class QcfgjQualificationRateStatisticsServiceImpl implements IQcfgjQualif
*/
private QcfgjQualificationRateStatistics computePassRate(QcfgjQualificationRateStatistics qcfgjQualificationRateStatistics){
//用于自动填充合格率,并且保存2位小数
if (!qcfgjQualificationRateStatistics.getInspectionQuantity().isEmpty() && !qcfgjQualificationRateStatistics.getUnqualifiedQuantity().isEmpty()){
if (!StringUtils.isEmpty(qcfgjQualificationRateStatistics.getInspectionQuantity()) && !StringUtils.isEmpty(qcfgjQualificationRateStatistics.getUnqualifiedQuantity())){
Double inspectionQuantity = new Double(qcfgjQualificationRateStatistics.getInspectionQuantity());
Double unqualifiedQuantity = new Double(qcfgjQualificationRateStatistics.getUnqualifiedQuantity());
double QualifiedRate = (inspectionQuantity-unqualifiedQuantity) / inspectionQuantity * 100;