package com.njcn.prepare.harmonic.service.oracle.Impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.prepare.harmonic.mapper.oracle.PqLinedetailPOMapper;
import com.njcn.prepare.harmonic.pojo.oracle.PqLinedetailPO;
import com.njcn.prepare.harmonic.service.oracle.PqLinedetailPOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2022/11/29  11:20【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
@DS("oracle")
public class PqLinedetailPOServiceImpl extends ServiceImpl<PqLinedetailPOMapper, PqLinedetailPO> implements PqLinedetailPOService{

    private @Autowired
    PqLinedetailPOMapper pqLinedetailPOMapper;
    /**
     * @param mysqlIndexs
     * @Description: 通过mysql监测点id查询Oracle监测点Id
     * @Param: [mysqlIndexs]
     * @return: com.njcn.prepare.harmonic.pojo.oracle.PqLinedetailPO
     * @Author: clam
     * @Date: 2022/11/29
     */
    @Override
    public List<PqLinedetailPO> queryOracleIndexIdByMysqlIndexId(List<String> mysqlIndexs) {

        List<PqLinedetailPO> pqLinedetailPOS = new ArrayList<> ();
        if(CollectionUtils.isEmpty (mysqlIndexs)){
            return pqLinedetailPOS;
        }
        LambdaQueryWrapper<PqLinedetailPO> monitorPOLambdaQueryWrapper = new LambdaQueryWrapper ( );
        monitorPOLambdaQueryWrapper.select (PqLinedetailPO::getMonitorId,PqLinedetailPO::getLineIndex).
                in (PqLinedetailPO::getMonitorId,mysqlIndexs);
        pqLinedetailPOS = pqLinedetailPOMapper.selectList (monitorPOLambdaQueryWrapper);

        return pqLinedetailPOS;
    }

    /**
     * 根据mysql监测点取oracle监测点信息
     * @author qijian
     * @date 2022/12/01
     */
    @Override
    public PqLinedetailPO getOracleIndexIdByMonitorId(String lineId) {
        LambdaQueryWrapper<PqLinedetailPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(PqLinedetailPO::getMonitorId, lineId);
        PqLinedetailPO pqLinedetailPO = pqLinedetailPOMapper.selectOne(lambdaQueryWrapper);
        return pqLinedetailPO;
    }
}
