package com.tofly.xrtygis.custom.service.callCenter.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.xrtygis.custom.service.callCenter.RecordService;

import com.tofly.xrtygis.callCenterMapper.PltCalllist1000Mapper;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author FlashWJL
 * @date 2021/7/7 16:37
 */
@Service
@AllArgsConstructor
public class RecordServiceImpl implements RecordService {

    private final PltCalllist1000Mapper pltCalllist1000Mapper;

    /**
     * 获取录音条数
     *
     * @return list
     */
    @Override
    public Map<String, Integer> queryRecordNum(String crew, String start, String end) {
        Map<String, Integer> map = new HashMap<>(5);

        List<Map<String, Object>> pltCallInfo = pltCalllist1000Mapper.getPltCallInfo(crew, start, end);

        if(pltCallInfo == null || pltCallInfo.size() == 0){
            return map;
        }
        pltCallInfo.forEach(k->{
            String code = k.get("code").toString();
            Integer sumNum = 0;
            Object sumNum1 = k.get("sumNum");
            if(null!=sumNum1){
                sumNum = Integer.valueOf(sumNum1.toString());
            }

            map.put(code,sumNum);
        });

        return map;
    }

    /**
     * 获取未接来电
     *
     * @param emp 员工
     * @param tel 电话
     * @return page
     */
    @Override
    public Page<Map> missedCalls(Page page,String emp, String tel) {
        return pltCalllist1000Mapper.missedCall(page,emp, tel);
    }
}
