package com.fs.hospital.service.impl;

import java.util.List;

import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.domain.R;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.DateUtils;
import com.fs.common.utils.StringUtils;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.hospital.param.HospitalExamOrderParam;
import com.fs.hospital.vo.HospitalExamOrderVO;
import com.fs.voice.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import com.fs.hospital.mapper.HospitalExamOrderMapper;
import com.fs.hospital.domain.HospitalExamOrder;
import com.fs.hospital.service.IHospitalExamOrderService;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * 检验单Service业务层处理
 *
 * @author fs
 * @date 2024-03-26
 */
@Service
public class HospitalExamOrderServiceImpl implements IHospitalExamOrderService
{
    @Autowired
    private HospitalExamOrderMapper hospitalExamOrderMapper;

    /**
     * 查询检验单
     *
     * @param orderId 检验单主键
     * @return 检验单
     */
    @Override
    public R selectHospitalExamOrderVOByOrderId(Long orderId)
    {
        HospitalExamOrderVO hospitalExamOrderVO = hospitalExamOrderMapper.selectHospitalExamOrderVOByOrderId(orderId);
        return R.ok().put("order",hospitalExamOrderVO);
    }


    /**
     * 查询检验单列表
     *
     * @param param 检验单参数
     * @return 检验单
     */
    @Override
    public List<HospitalExamOrderVO> selectHospitalExamOrderListVO(HospitalExamOrderParam param)
    {
        return hospitalExamOrderMapper.selectHospitalExamOrderListVO(param);
    }

    /**
     * 修改检验单
     *
     * @param hospitalExamOrder 检验单
     * @return 结果
     */
    @Override
    public int updateHospitalExamOrder(HospitalExamOrder hospitalExamOrder)
    {
        hospitalExamOrder.setUpdateTime(DateUtils.getNowDate());
        hospitalExamOrder.setStatus(2);
        //当图片地址为""时，制为null。
        if (StringUtil.strIsNullOrEmpty(hospitalExamOrder.getImages())){
            hospitalExamOrder.setImages(null);
        }
        return hospitalExamOrderMapper.updateHospitalExamOrder(hospitalExamOrder);
    }

}
