package com.uas.finance.service.Impl;

import com.uas.finance.dao.ChangesInstructionDao;
import com.uas.finance.model.ChangesInstruction;
import com.uas.finance.service.ChangesInstructionService;
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/20
 **/
@Service
public class ChangesInstructionServiceImpl implements ChangesInstructionService {

    @Autowired
    private ChangesInstructionDao dao;

    /**
     * 变更资料保存
     *
     * @param changesInstruction
     * @return
     */
    public ChangesInstruction save(ChangesInstruction changesInstruction) {
        return dao.save(changesInstruction);
    }

    /**
     * 变更资料更新
     *
     * @param instructionList
     */
    public List<Map<String, Long>> update(List<ChangesInstruction> instructionList) {
        List<Map<String, Long>> list = new ArrayList<Map<String, Long>>();
        for (ChangesInstruction instruction : instructionList) {
            Map<String, Long> map = new HashMap<String, Long>();
            ChangesInstruction instruction1 = dao.save(instruction);
            map.put("id", instruction1.getId());
            map.put("cs_id", instruction1.getErpId());
            list.add(map);
        }
        return list;
    }
}
