package com.ruoyi.predict.service.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.predict.domain.Windplantproject;
import com.ruoyi.predict.mapper.WindplantprojectMapper;
import com.ruoyi.predict.service.IWindplantprojectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * WindplantprojectService业务层处理
 *
 * @author hlf
 * @date 2021-08-02
 */
@Service
public class WindplantprojectServiceImpl implements IWindplantprojectService {
    @Autowired(required = false)
    private WindplantprojectMapper windplantprojectMapper;

    /**
     * 查询Windplantproject
     *
     * @param projectNo WindplantprojectID
     * @return Windplantproject
     */
    @Override
    public Windplantproject selectWindplantprojectById(Long projectNo) {
        return windplantprojectMapper.selectWindplantprojectById(projectNo);
    }

    /**
     * 查询Windplantproject列表
     *
     * @param windplantproject Windplantproject
     * @return Windplantproject
     */
    @Override
    public List<Windplantproject> selectWindplantprojectList(Windplantproject windplantproject) {
        return windplantprojectMapper.selectWindplantprojectList(windplantproject);
    }

    /**
     * 新增Windplantproject
     *
     * @param windplantproject Windplantproject
     * @return 结果
     */
    @Override
    public int insertWindplantproject(Windplantproject windplantproject) {
        return windplantprojectMapper.insertWindplantproject(windplantproject);
    }

    /**
     * 修改Windplantproject
     *
     * @param windplantproject Windplantproject
     * @return 结果
     */
    @Override
    public int updateWindplantproject(Windplantproject windplantproject) {
        return windplantprojectMapper.updateWindplantproject(windplantproject);
    }

    /**
     * 删除Windplantproject信息
     *
     * @param projectNo WindplantprojectID
     * @return 结果
     */
    @Override
    public int deleteWindplantprojectById(Long projectNo) {
        return windplantprojectMapper.deleteWindplantprojectById(projectNo);
    }

    /**
     * 删除Windplantproject对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWindplantprojectByIds(String ids) {
        return windplantprojectMapper.deleteWindplantprojectByIds(Convert.toStrArray(ids));
    }

    @Override
    public List<Windplantproject> selectWindplantprojectByWindplantNo(Long windplantNo) {
        return windplantprojectMapper.selectWindplantprojectByWindplantNo(windplantNo);
    }

    @Override
    public Windplantproject selectWindplantprojectByWpNoProjectNo(Long windplantNo, Long projectNo) {
        return windplantprojectMapper.selectWindplantprojectByWpNoProjectNo(windplantNo, projectNo);
    }

    @Override
    public Windplantproject checkProjectNoUnique(Long projectNo) {
        return windplantprojectMapper.checkProjectNoUnique(projectNo);
    }

    @Override
    public Windplantproject checkAnalogNoUnique(Long analogNo) {
        return windplantprojectMapper.checkAnalogNoUnique(analogNo);
    }

    @Override
    public Long selectNewData() {
        return windplantprojectMapper.selectNewData();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertWindplantprojectList(List<Windplantproject> windplantprojectList) {
        return windplantprojectMapper.insertWindplantprojectList(windplantprojectList);
    }

    @Override
    public int deleteWindplantprojectByWindplantNo(Long windplantNo) {
        return windplantprojectMapper.deleteWindplantprojectByWindplantNo(windplantNo);
    }

    @Override
    public String checkBcrNoUnique(Long bcrNo) {
        int count = windplantprojectMapper.checkBcrNoUnique(bcrNo);
        if (count > 0)
        {
            return UserConstants.USER_NAME_NOT_UNIQUE;
        }
        return UserConstants.USER_NAME_UNIQUE;
    }

    @Override
    public String checkMonthBcrNoUnique(Long monthBcrNo) {
        int count = windplantprojectMapper.checkMonthBcrNoUnique(monthBcrNo);
        if (count > 0)
        {
            return UserConstants.USER_NAME_NOT_UNIQUE;
        }
        return UserConstants.USER_NAME_UNIQUE;
    }

    @Override
    public String checkYearBcrNoUnique(Long yearBcrNo) {
        int count = windplantprojectMapper.checkYearBcrNoUnique(yearBcrNo);
        if (count > 0)
        {
            return UserConstants.USER_NAME_NOT_UNIQUE;
        }
        return UserConstants.USER_NAME_UNIQUE;
    }

    @Override
    public Windplantproject selectWindplantprojectByProjectIssue(String projectIssue) {
        return windplantprojectMapper.selectWindplantprojectByProjectIssue(projectIssue);
    }
}
