package cn.hnthyy.thmz.service.impl.his;

import cn.hnthyy.thmz.entity.his.YpZdDict;
import cn.hnthyy.thmz.enums.UnitTypeEnum;
import cn.hnthyy.thmz.mapper.his.YpZdDictMapper;
import cn.hnthyy.thmz.service.his.YpZdDictService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class YpZdDictServiceImpl implements YpZdDictService {
    @SuppressWarnings("all")
    @Autowired
    private YpZdDictMapper ypZdDictMapper;
    @Override
    public YpZdDict queryYpZdDictByCodeAndSerial(String code,String serial) {
        YpZdDict ypZdDict= ypZdDictMapper.selectYpZdDictByCodeAndSerial(code,serial);
        if(ypZdDict==null){
            return ypZdDict;
        }
        if(StringUtils.isNotBlank(ypZdDict.getWeighUnit())){
            ypZdDict.setWeighUnitDesc(UnitTypeEnum.getUnitTypeByCode(ypZdDict.getWeighUnit()).name);
        }
        if(StringUtils.isNotBlank(ypZdDict.getVolUnit())){
            ypZdDict.setVolUnitDesc(UnitTypeEnum.getUnitTypeByCode(ypZdDict.getVolUnit()).name);
        }
        if(StringUtils.isNotBlank(ypZdDict.getPackUnit())){
            ypZdDict.setPackUnitDesc(UnitTypeEnum.getUnitTypeByCode(ypZdDict.getPackUnit()).name);
        }
        if(StringUtils.isNotBlank(ypZdDict.getMiniUnit())){
            ypZdDict.setMiniUnitDesc(UnitTypeEnum.getUnitTypeByCode(ypZdDict.getMiniUnit()).name);
        }
        return ypZdDict;
    }

    @Override
    public List<YpZdDict> queryYpZdDictByCodeList(String codes) {
        return ypZdDictMapper.selectYpZdDictByCodeList(codes);
    }

    @Override
    public List<YpZdDict> queryYpZdDictByCode(String code) {
        return ypZdDictMapper.selectYpZdDictByCode(code);
    }

    @Override
    public List<YpZdDict> queryYpBySearchText(String searchTextDrug) {
        return ypZdDictMapper.selectYpBySearchText(searchTextDrug);
    }
}
