package com.jsowell.pile.service.impl;

import java.util.List;

import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.util.DateUtils;
import com.jsowell.pile.dto.ThirdPartySnRelationDTO;
import com.jsowell.pile.vo.web.ThirdPartySnRelationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jsowell.pile.mapper.ThirdpartySnRelationMapper;
import com.jsowell.pile.domain.ThirdpartySnRelation;
import com.jsowell.pile.service.IThirdpartySnRelationService;

/**
 * 万车充--第三方平台桩编号对应关系Service业务层处理
 *
 * @author jsowell
 * @date 2024-03-09
 */
@Service
public class ThirdpartySnRelationServiceImpl implements IThirdpartySnRelationService {
    @Autowired
    private ThirdpartySnRelationMapper thirdpartySnRelationMapper;

    /**
     * 查询万车充--第三方平台桩编号对应关系
     *
     * @param id 万车充--第三方平台桩编号对应关系主键
     * @return 万车充--第三方平台桩编号对应关系
     */
    @Override
    public ThirdpartySnRelation selectThirdpartySnRelationById(Long id) {
        return thirdpartySnRelationMapper.selectThirdpartySnRelationById(id);
    }

    /**
     * 查询万车充--第三方平台桩编号对应关系列表
     *
     * @param thirdpartySnRelation 万车充--第三方平台桩编号对应关系
     * @return 万车充--第三方平台桩编号对应关系
     */
    @Override
    public List<ThirdpartySnRelation> selectThirdpartySnRelationList(ThirdpartySnRelation thirdpartySnRelation) {
        return thirdpartySnRelationMapper.selectThirdpartySnRelationList(thirdpartySnRelation);
    }

    @Override
    public List<ThirdPartySnRelationVO> selectSnRelationListByParams(String stationId, String pileSn, List<Long> pileIds) {
        return thirdpartySnRelationMapper.selectSnRelationListByParams(stationId, pileSn, pileIds);
    }

    /**
     * 新增万车充--第三方平台桩编号对应关系
     *
     * @param thirdpartySnRelation 万车充--第三方平台桩编号对应关系
     * @return 结果
     */
    @Override
    public int insertThirdpartySnRelation(ThirdpartySnRelation thirdpartySnRelation) {
        thirdpartySnRelation.setCreateTime(DateUtils.getNowDate());
        return thirdpartySnRelationMapper.insertThirdpartySnRelation(thirdpartySnRelation);
    }

    /**
     * 修改万车充--第三方平台桩编号对应关系
     *
     * @param thirdpartySnRelation 万车充--第三方平台桩编号对应关系
     * @return 结果
     */
    @Override
    public int updateThirdpartySnRelation(ThirdpartySnRelation thirdpartySnRelation) {
        thirdpartySnRelation.setUpdateTime(DateUtils.getNowDate());
        return thirdpartySnRelationMapper.updateThirdpartySnRelation(thirdpartySnRelation);
    }

    /**
     * 批量删除万车充--第三方平台桩编号对应关系
     *
     * @param ids 需要删除的万车充--第三方平台桩编号对应关系主键
     * @return 结果
     */
    @Override
    public int deleteThirdpartySnRelationByIds(Long[] ids) {
        return thirdpartySnRelationMapper.deleteThirdpartySnRelationByIds(ids);
    }

    /**
     * 删除万车充--第三方平台桩编号对应关系信息
     *
     * @param id 万车充--第三方平台桩编号对应关系主键
     * @return 结果
     */
    @Override
    public int deleteThirdpartySnRelationById(Long id) {
        return thirdpartySnRelationMapper.deleteThirdpartySnRelationById(id);
    }

    /**
     * 查询第三方平台桩编号对应的列表
     * @param dto
     * @return
     */
    @Override
    public List<ThirdPartySnRelationVO> getRelationVOList(ThirdPartySnRelationDTO dto) {
        List<ThirdPartySnRelationVO> list = thirdpartySnRelationMapper.getRelationVOList(dto);
        for (ThirdPartySnRelationVO thirdPartySnRelationVO : list) {
            // 将第三方平台类型中文名称查询出来
            String thirdPartyType = thirdPartySnRelationVO.getThirdPartyType();
            String label = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(thirdPartyType);
            thirdPartySnRelationVO.setThirdPartyName(label);
        }
        return list;
    }

    /**
     * 修改第三方平台对应编号
     * @param dto
     * @return
     */
    @Override
    public int updateThirdPartySnRelation(ThirdPartySnRelationDTO dto) {
        return thirdpartySnRelationMapper.updateThirdPartySnRelation(dto);
    }
}
