package com.sw.mes.yb.production.service.impl;


import com.sw.mes.core.base.BaseServiceImpl;
import com.sw.mes.yb.production.dao.ProductionCircleDosingListDao;
import com.sw.mes.yb.production.entity.ProductionCircleDosingList;
import com.sw.mes.yb.production.service.ProductionCircleDosingListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;


@Service
@Transactional
public class ProductionCircleDosingListServiceImpl extends BaseServiceImpl<ProductionCircleDosingList> implements ProductionCircleDosingListService {
    ProductionCircleDosingListDao dao;
	@Autowired
    public void setDao(ProductionCircleDosingListDao dao) {
        super.setBaseDao(dao);
        this.dao=dao;
    }

    @Override
    public void updateStatus(Long id, Integer status) {
        if (status == 0){
            dao.updateStatus(id,1);
        }else {
            dao.updateStatus(id,0);
        }
    }

    @Override
    public List<ProductionCircleDosingList> getObjectByRecipeOId(Long id) {
        return dao.getObjectByRecipeOId(id);
    }

    @Override
    public List<String> getAllProductName() {
        return dao.getAllProductName();
    }

	@Override
	public ProductionCircleDosingList getProductName(String matnr) {
		List<ProductionCircleDosingList> list = dao.findByProductName(matnr);
		if(list.size()>0) {
			return list.get(0);
		}
		return null;
	}

	@Override
	public void deleteDel(Long id) {
		dao.updateDel(id, 1);
	}
}
