package com.xzzn.ems.service.impl;

import java.util.List;
import com.xzzn.common.utils.DateUtils;
import com.xzzn.ems.domain.EmsBatteryData;
import com.xzzn.ems.mapper.EmsBatteryDataMapper;
import com.xzzn.ems.service.IEmsBatteryDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 单体电池实时数据Service业务层处理
 *
 * @author xzzn
 * @date 2025-06-27
 */
@Service
public class EmsBatteryDataServiceImpl implements IEmsBatteryDataService
{
    @Autowired
    private EmsBatteryDataMapper emsBatteryDataMapper;

    /**
     * 查询单体电池实时数据
     *
     * @param id 单体电池实时数据主键
     * @return 单体电池实时数据
     */
    @Override
    public EmsBatteryData selectEmsBatteryDataById(Long id)
    {
        return emsBatteryDataMapper.selectEmsBatteryDataById(id);
    }

    /**
     * 查询单体电池实时数据列表
     *
     * @param emsBatteryData 单体电池实时数据
     * @return 单体电池实时数据
     */
    @Override
    public List<EmsBatteryData> selectEmsBatteryDataList(EmsBatteryData emsBatteryData)
    {
        return emsBatteryDataMapper.selectEmsBatteryDataList(emsBatteryData);
    }

    /**
     * 新增单体电池实时数据
     *
     * @param emsBatteryData 单体电池实时数据
     * @return 结果
     */
    @Override
    public int insertEmsBatteryData(EmsBatteryData emsBatteryData)
    {
        emsBatteryData.setCreateTime(DateUtils.getNowDate());
        return emsBatteryDataMapper.insertEmsBatteryData(emsBatteryData);
    }

    /**
     * 修改单体电池实时数据
     *
     * @param emsBatteryData 单体电池实时数据
     * @return 结果
     */
    @Override
    public int updateEmsBatteryData(EmsBatteryData emsBatteryData)
    {
        emsBatteryData.setUpdateTime(DateUtils.getNowDate());
        return emsBatteryDataMapper.updateEmsBatteryData(emsBatteryData);
    }

    /**
     * 批量删除单体电池实时数据
     *
     * @param ids 需要删除的单体电池实时数据主键
     * @return 结果
     */
    @Override
    public int deleteEmsBatteryDataByIds(Long[] ids)
    {
        return emsBatteryDataMapper.deleteEmsBatteryDataByIds(ids);
    }

    /**
     * 删除单体电池实时数据信息
     *
     * @param id 单体电池实时数据主键
     * @return 结果
     */
    @Override
    public int deleteEmsBatteryDataById(Long id)
    {
        return emsBatteryDataMapper.deleteEmsBatteryDataById(id);
    }

    @Override
    public int insertEmsBatteryDataList(List<EmsBatteryData> emsBatteryDataList) {
        for (EmsBatteryData data : emsBatteryDataList) {
            data.setCreateTime(DateUtils.getNowDate());
        }
        return emsBatteryDataMapper.insertEmsBatteryDataList(emsBatteryDataList);
    }
}
