package com.njcn.prepare.harmonic.service.mysql.Impl.area;

import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.harmonic.pojo.po.PmsMonitorPO;
import com.njcn.harmonic.pojo.po.ROperatingIndexDPO;
import com.njcn.harmonic.pojo.po.RStatAbnormalDPO;
import com.njcn.prepare.harmonic.mapper.mysql.area.RStatAbnormalDPOMapper;
import com.njcn.prepare.harmonic.pojo.oracle.PqLinedetailPO;
import com.njcn.prepare.harmonic.pojo.param.PrimaryGridParam;
import com.njcn.prepare.harmonic.service.mysql.area.PmsMonitorPOService;
import com.njcn.prepare.harmonic.service.mysql.area.RStatAbnormalDPOService;
import com.njcn.prepare.harmonic.service.oracle.PqLinedetailPOService;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 *
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2022/11/28  19:31【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Service
public class RStatAbnormalDPOServiceImpl extends MppServiceImpl<RStatAbnormalDPOMapper, RStatAbnormalDPO> implements RStatAbnormalDPOService {


/*

    private @Autowired
    RStatAbnormalDPOMapper rStatAbnormalDPOMapper;

    private @Autowired
    PmsMonitorPOService pmsMonitorPOService;


    private @Autowired
    PqLinedetailPOService pqLinedetailPOService;
*/

    /**
     * @param primaryGridParam
     * @Description: rStatAbnormalDDataHanlder
     * @Param: [primaryGridParam]
     * @return: void
     * @Author: clam
     * @Date: 2022/11/28
     */
    @Override
    @Async("asyncExecutor")
    public void rStatAbnormalDDataHanlder(PrimaryGridParam primaryGridParam) {
        if (Objects.equals (primaryGridParam.getDataSource ( ), 0)) {
            //this.hanlderOracleData (primaryGridParam);
        } else if (Objects.equals (primaryGridParam.getDataSource ( ), 1)) {
            this.hanlderInfludxbData (primaryGridParam);
        }
    }
    /**
     * @Description: 处理influxdb数据 todo 本次不做处理
     * @Param: [primaryGridParam]
     * @return: void
     * @Author: clam
     * @Date: 2022/11/25
     */
    private void hanlderInfludxbData(PrimaryGridParam primaryGridParam) {
    }

    /**
     * @Description: 处理Oracle数据目前只有日表数据处理
     * @Param: [primaryGridParam]
     * @return: void
     * @Author: clam
     * @Date: 2022/11/25
     */
/*    @SneakyThrows
    private void hanlderOracleData(PrimaryGridParam primaryGridParam) {

        List<String> orgIdList = primaryGridParam.getOrgIdList ( );
        String dataDate = primaryGridParam.getDataDate ( );
        List<ROperatingIndexDPO> rOperatingIndexDPOList = new ArrayList<> ( );

        final Date tempDate = new SimpleDateFormat ("yyyy-MM-dd ").parse(dataDate);

        orgIdList.forEach (orgid -> {

            *//*measurement_run_points:在运监测点个数*//*
            *//*measurement_run_points:在运监测点个数*//*
            List<PmsMonitorPO> pmsMonitorPOS = pmsMonitorPOService.qurymeasurementRunPoints (orgid);
            *//*获取mysql与Oracle监测点id对应关系*//*
            List<String> mysqlIndexList = pmsMonitorPOS.stream ( ).map (PmsMonitorPO::getId).collect (Collectors.toList ( ));

            List<PqLinedetailPO> pqLinedetailPOS = pqLinedetailPOService.queryOracleIndexIdByMysqlIndexId (mysqlIndexList);
            List<Integer> oracleIndexlist = pqLinedetailPOS.stream ( ).map (PqLinedetailPO::getLineIndex).collect (Collectors.toList ( ));



        });


    }*/
}
