zss
2023-08-22 8c37d903a2fe25d5857c4555c791d552bec60cb8
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java
@@ -10,8 +10,10 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * <p>
@@ -76,19 +78,22 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String check(Integer id, String value) {
        //如果检验值不为空
        if (StringUtils.isNotBlank(value)) {
            InspectionProduct inspectionProduct = inspectionProductMapper.selectById(id);
            //判断检测值是否满足标准值和内控值的要求,如果不满足则检验结论为不合格0
            String required = inspectionProduct.getRequired();//标准值
            String internal = inspectionProduct.getInternal();//内控值
            inspectionProduct.setTestValue(value);
            inspectionProduct.setTestState(checkValues(required, internal, value));
            inspectionProductMapper.updateById(inspectionProduct);
        List<Integer> list = Arrays.stream(value.split(",")).map(s -> {
            int values = checkValues(required, internal, s);
            return values;
        }).collect(Collectors.toList());
        if (list.contains(0)) {
            //如果其中一个检验值不合格则该项目检验不合格
            inspectionProduct.setTestState(0);
        } else {
            //如果检验值为空,将原有的检验结论覆盖为null
            inspectionProductMapper.upda(id);
            inspectionProduct.setTestState(1);
        }
        inspectionProductMapper.updateById(inspectionProduct);
        return "提交成功!";
    }