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


import com.sw.mes.core.base.BaseServiceImpl;
import com.sw.mes.production.dao.FormulaProductSchemeDetailDao;
import com.sw.mes.production.dto.FormulaProductSchemeDetailDto;
import com.sw.mes.production.dto.FormulaProductSchemeDto;
import com.sw.mes.production.entity.FormulaProductScheme;
import com.sw.mes.production.entity.FormulaProductSchemeDetail;
import com.sw.mes.production.service.FormulaProductSchemeDetailService;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


/**
* @Author
* @Description：
* @Date: Create in
* @Modified By:
*/
@Service
@Transactional
public class FormulaProductSchemeDetailServiceImpl extends BaseServiceImpl<FormulaProductSchemeDetail> implements FormulaProductSchemeDetailService {
    FormulaProductSchemeDetailDao dao;

    @Autowired
    ModelMapper modelMapper;

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

    @Override
    public List<FormulaProductSchemeDetail> getListByFpsId(Long fpsId) {
       return dao.findByFormulaProductSchemeIdOrderByAgainNumAsc(fpsId);
    }

    @Override
    public List<FormulaProductSchemeDetail> getListByFpsIdAndWsId(Long fpsId, Long wsId) {
        return dao.findByFpsIdAndWsId(fpsId, wsId);
    }

    @Override
    public void deleteByFpsId(Long fpsId) {
        dao.deleteAllByFormulaProductSchemeId(fpsId);
    }

    @Override
    public FormulaProductSchemeDetail findByFpsIdAndAgainNum(Long fpsId, Integer againNum) {
        return dao.findByFpsIdAndAgainNum(fpsId, againNum);
    }

    @Override
    public FormulaProductSchemeDetail findByFpsIdAndWsIdAndAgainNum(Long fpsId, Long wsId, Integer againNum) {
        return dao.findByFpsIdAndWsIdAndAgainNum(fpsId, wsId, againNum);
    }

}
