|
|
|
@ -1,24 +1,26 @@
|
|
|
|
|
package org.dromara.qms.service.impl;
|
|
|
|
|
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
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.QcInspectionMain;
|
|
|
|
|
import org.dromara.qms.domain.QcInspectionResult;
|
|
|
|
|
import org.dromara.qms.domain.bo.QcInspectionResultBo;
|
|
|
|
|
import org.dromara.qms.domain.vo.QcInspectionResultVo;
|
|
|
|
|
import org.dromara.qms.domain.QcInspectionResult;
|
|
|
|
|
import org.dromara.qms.mapper.QcInspectionMainMapper;
|
|
|
|
|
import org.dromara.qms.mapper.QcInspectionResultMapper;
|
|
|
|
|
import org.dromara.qms.service.IQcInspectionResultService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 质检结果子表Service业务层处理
|
|
|
|
@ -32,6 +34,8 @@ public class QcInspectionResultServiceImpl implements IQcInspectionResultService
|
|
|
|
|
|
|
|
|
|
private final QcInspectionResultMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
private final QcInspectionMainMapper inspectionMainMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询质检结果子表
|
|
|
|
|
*
|
|
|
|
@ -110,12 +114,16 @@ public class QcInspectionResultServiceImpl implements IQcInspectionResultService
|
|
|
|
|
* @return 是否新增成功
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean insertByBo(QcInspectionResultBo bo) {
|
|
|
|
|
QcInspectionResult add = MapstructUtils.convert(bo, QcInspectionResult.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setResultId(add.getResultId());
|
|
|
|
|
|
|
|
|
|
// 同步主表状态
|
|
|
|
|
syncMainInspectionResult(add.getInspectionId());
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
@ -127,10 +135,45 @@ public class QcInspectionResultServiceImpl implements IQcInspectionResultService
|
|
|
|
|
* @return 是否修改成功
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean updateByBo(QcInspectionResultBo bo) {
|
|
|
|
|
QcInspectionResult update = MapstructUtils.convert(bo, QcInspectionResult.class);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
|
|
|
|
|
// 更新子表记录
|
|
|
|
|
boolean result = baseMapper.updateById(update) > 0;
|
|
|
|
|
if (result) {
|
|
|
|
|
syncMainInspectionResult(update.getInspectionId());
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同步主表质检结果状态
|
|
|
|
|
* 根据子表中所有检测项的结果来确定主表的最终结果
|
|
|
|
|
*
|
|
|
|
|
* @param inspectionId 质检任务ID
|
|
|
|
|
*/
|
|
|
|
|
private void syncMainInspectionResult(Long inspectionId) {
|
|
|
|
|
// 检查参数
|
|
|
|
|
if (inspectionId == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询该质检任务下是否有不合格的检测项
|
|
|
|
|
MPJLambdaWrapper<QcInspectionResult> wrapper = JoinWrappers.lambda(QcInspectionResult.class)
|
|
|
|
|
.eq(QcInspectionResult::getInspectionId, inspectionId)
|
|
|
|
|
.eq(QcInspectionResult::getDetectResult, "1"); // 检测结果(0合格,1不合格,2未判定)
|
|
|
|
|
|
|
|
|
|
Long unqualifiedCount = baseMapper.selectCount(wrapper);
|
|
|
|
|
|
|
|
|
|
// 更新主表状态
|
|
|
|
|
QcInspectionMain main = new QcInspectionMain();
|
|
|
|
|
main.setInspectionId(inspectionId);
|
|
|
|
|
// 如果存在不合格项,则主表为不合格,否则为合格
|
|
|
|
|
main.setResult(unqualifiedCount > 0 ? "1" : "0");//质检结果(0合格/1不合格)
|
|
|
|
|
|
|
|
|
|
inspectionMainMapper.updateById(main);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|