package com.uas.finance.service.Impl;

import com.uas.finance.dao.ProductMixDao;
import com.uas.finance.model.ProductMix;
import com.uas.finance.service.ProductMixService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 经营情况接口实现类
 * created by shicr on 2017/12/21
 **/
@Service
public class ProductMixServiceImpl implements ProductMixService {

    @Autowired
    private ProductMixDao productMixDao;

    /**
     * 保存经营情况
     *
     * @param productMix
     * @return
     */
    @Override
    public ProductMix save(ProductMix productMix) {
        return productMixDao.save(productMix);
    }

    /**
     * 更新经营情况表
     *
     * @param productMixList
     */
    @Override
    public List<Map<String, Long>> update(List<ProductMix> productMixList) {
        List<Map<String, Long>> list = new ArrayList<Map<String, Long>>();
        for (ProductMix productMix : productMixList) {
            Map<String, Long> map = new HashMap<String, Long>();
            ProductMix productMix1 = productMixDao.save(productMix);
            map.put("id", productMix1.getId());
            map.put("pm_id", productMix1.getErpId());
            list.add(map);
        }
        return list;
    }
}
