package com.sw.mes.fb.product.service.impl;

import com.sw.mes.core.base.BaseServiceImpl;
import com.sw.mes.fb.product.dao.ProductModelViewDao;
import com.sw.mes.fb.product.entity.ProductModelView;
import com.sw.mes.fb.product.service.ProductModelViewService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;


@Service
@Transactional
public class ProductModelViewServiceImpl extends BaseServiceImpl<ProductModelView> implements ProductModelViewService {


    ProductModelViewDao dao;
    @Autowired
    public void setDao(ProductModelViewDao dao) {
        super.setBaseDao(dao);
        this.dao=dao;
    }

    @Override
    public ProductModelView automationGetProductModel(String productTypeName, String productLevel, String productLevelExperiment,
                                                      String conductiveType, BigDecimal length){

        List<ProductModelView> list;
        if (StringUtils.isNotBlank(productLevelExperiment)) {
            list = dao.automationGetProductModel(productTypeName, productLevel, productLevelExperiment, conductiveType, length);
        } else {
            list = dao.automationGetProductModel(productTypeName, productLevel, conductiveType, length);
        }
        if (list != null && list.size() > 0) {
            return list.get(0);
        }
        return null;
    }
}
