|
|
|
|
@ -8,6 +8,7 @@ import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
import org.dromara.qms.domain.QcInspectionItem;
|
|
|
|
|
import org.dromara.qms.domain.QcInspectionMain;
|
|
|
|
|
import org.dromara.qms.domain.QcInspectionResult;
|
|
|
|
|
import org.dromara.qms.domain.bo.QcInspectionResultBo;
|
|
|
|
|
@ -77,6 +78,11 @@ public class QcInspectionResultServiceImpl implements IQcInspectionResultService
|
|
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
|
MPJLambdaWrapper<QcInspectionResult> lqw = JoinWrappers.lambda(QcInspectionResult.class)
|
|
|
|
|
.selectAll(QcInspectionResult.class)
|
|
|
|
|
|
|
|
|
|
//关联查询检测项定义
|
|
|
|
|
.select(QcInspectionItem::getMethod, QcInspectionItem::getItemCode, QcInspectionItem::getItemName, QcInspectionItem::getInspectionPosition)
|
|
|
|
|
.leftJoin(QcInspectionItem.class, QcInspectionItem::getItemId,QcInspectionResult::getItemId)
|
|
|
|
|
|
|
|
|
|
.eq(bo.getResultId() != null, QcInspectionResult::getResultId, bo.getResultId())
|
|
|
|
|
.eq(bo.getInspectionId() != null, QcInspectionResult::getInspectionId, bo.getInspectionId())
|
|
|
|
|
.eq(bo.getItemId() != null, QcInspectionResult::getItemId, bo.getItemId())
|
|
|
|
|
@ -151,6 +157,7 @@ public class QcInspectionResultServiceImpl implements IQcInspectionResultService
|
|
|
|
|
/**
|
|
|
|
|
* 同步主表质检结果状态
|
|
|
|
|
* 根据子表中所有检测项的结果来确定主表的最终结果
|
|
|
|
|
* 只有当所有检测项都已判定(无未判定项)时才更新主表结果
|
|
|
|
|
*
|
|
|
|
|
* @param inspectionId 质检任务ID
|
|
|
|
|
*/
|
|
|
|
|
@ -160,18 +167,33 @@ public class QcInspectionResultServiceImpl implements IQcInspectionResultService
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询该质检任务下是否有不合格的检测项
|
|
|
|
|
MPJLambdaWrapper<QcInspectionResult> wrapper = JoinWrappers.lambda(QcInspectionResult.class)
|
|
|
|
|
// 首先检查是否还有未判定的检测项
|
|
|
|
|
MPJLambdaWrapper<QcInspectionResult> undeterminedWrapper = JoinWrappers.lambda(QcInspectionResult.class)
|
|
|
|
|
.eq(QcInspectionResult::getInspectionId, inspectionId)
|
|
|
|
|
.eq(QcInspectionResult::getDetectResult, "1"); // 检测结果(0合格,1不合格,2未判定)
|
|
|
|
|
.eq(QcInspectionResult::getDetectResult, "2"); // 检测结果(0合格,1不合格,2未判定)
|
|
|
|
|
|
|
|
|
|
Long unqualifiedCount = baseMapper.selectCount(wrapper);
|
|
|
|
|
Long undeterminedCount = baseMapper.selectCount(undeterminedWrapper);
|
|
|
|
|
|
|
|
|
|
// 更新主表状态
|
|
|
|
|
QcInspectionMain main = new QcInspectionMain();
|
|
|
|
|
main.setInspectionId(inspectionId);
|
|
|
|
|
|
|
|
|
|
// 如果存在未判定的检测项,主表结果设为未判定
|
|
|
|
|
if (undeterminedCount > 0) {
|
|
|
|
|
main.setResult("2"); // 质检结果(0合格/1不合格/2未判定)
|
|
|
|
|
inspectionMainMapper.updateById(main);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 所有检测项都已判定,查询是否有不合格的检测项
|
|
|
|
|
MPJLambdaWrapper<QcInspectionResult> unqualifiedWrapper = JoinWrappers.lambda(QcInspectionResult.class)
|
|
|
|
|
.eq(QcInspectionResult::getInspectionId, inspectionId)
|
|
|
|
|
.eq(QcInspectionResult::getDetectResult, "1"); // 检测结果(0合格,1不合格,2未判定)
|
|
|
|
|
|
|
|
|
|
Long unqualifiedCount = baseMapper.selectCount(unqualifiedWrapper);
|
|
|
|
|
|
|
|
|
|
// 如果存在不合格项,则主表为不合格,否则为合格
|
|
|
|
|
main.setResult(unqualifiedCount > 0 ? "1" : "0");//质检结果(0合格/1不合格)
|
|
|
|
|
main.setResult(unqualifiedCount > 0 ? "1" : "0"); // 质检结果(0合格/1不合格/2未判定)
|
|
|
|
|
|
|
|
|
|
inspectionMainMapper.updateById(main);
|
|
|
|
|
}
|
|
|
|
|
|