package com.nantian.cloud.dbcapp.service.impl;


import com.nantian.cloud.dbcapp.mapper.record.CollectionMapper;
import com.nantian.cloud.dbcapp.service.CollectionService;
import com.nantian.cloud.dbcapp.service.EnergyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;


/**
 * <p>
 * 采集点 服务实现类
 * </p>
 *
 * @author zfw
 * @since 2020-08-05
 */
@Service("collectionService")
public class CollectionServiceImpl implements CollectionService {

    @Autowired
    private CollectionMapper collectionMapper;

    @Autowired
    private EnergyService energyService;


    @Override
    public float  getTotal(String area ,String industry,String time) {

        //截取时间
        String startTime=time.split("&")[0];
        String endTime=time.split("&")[1];
        startTime=startTime.substring(0,7);
        endTime=endTime.substring(0,7);
        Integer timetir=Integer.valueOf(startTime.trim().substring(0,4));
        Integer total=0;
        HashMap<String, String> areaAndIndustryCode = energyService.getAreaAndIndustryCode( area, industry);
        String areaCode = (area.trim().equals("53") || area.trim().equals("云南")) ? "53" : areaAndIndustryCode.get("地区");
        String industryCode = industry.trim().equals("全部") ? null : areaAndIndustryCode.get("行业");

       /* if(timetir >=2020){ //2020年*/
            total=   collectionMapper.getTotal2020(areaCode,industryCode,startTime,endTime);
        /*}else{
            total=   collectionMapper.getTotal(code,inde1,startTime,endTime);
        }*/
        return total;
    }
}

