package digital.laboratory.platform.entrustment.convert;

import cn.hutool.core.util.StrUtil;
import digital.laboratory.platform.entrustment.dto.EntrustMaterialCheckoutResultDTO;
import digital.laboratory.platform.entrustment.entity.EntrustMaterialCheckoutResult;
import digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO;

import java.util.stream.Collectors;

/**
 * 托检材--检出定性定量结果信息 转换类
 */
public class EntrustMaterialCheckoutResultConvert {

    public static EntrustMaterialCheckoutResult dtoToEntity(EntrustMaterialCheckoutResultDTO dto) {
        if (dto == null) return null;
        EntrustMaterialCheckoutResult entrustMaterialCheckoutResult = new EntrustMaterialCheckoutResult();
        entrustMaterialCheckoutResult.setQualitativeResult(dto.getQualitativeResult());
        entrustMaterialCheckoutResult.setQuantitativeResult(dto.getQuantitativeResult().stream().collect(Collectors.joining("、")));
        entrustMaterialCheckoutResult.setOtherResult(dto.getOtherResult());
        entrustMaterialCheckoutResult.setCheckoutRemark(dto.getCheckoutRemark());
        return entrustMaterialCheckoutResult;

    }

    public static EntrustMaterialCheckoutResultVO entityToVO(EntrustMaterialCheckoutResult entity) {
        if (entity == null) return new EntrustMaterialCheckoutResultVO();
        EntrustMaterialCheckoutResultVO vo = new EntrustMaterialCheckoutResultVO();
        vo.setId(entity.getId());
        vo.setQualitativeResult(entity.getQualitativeResult());
        vo.setQuantitativeResult(StrUtil.split(entity.getQuantitativeResult(), "、"));
        vo.setOtherResult(entity.getOtherResult());
        vo.setCheckoutRemark(entity.getCheckoutRemark());
        return vo;
    }

}
