package com.tofly.xrtygis.custom.controller.gs;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.service.NewHotlineService;
import com.tofly.xrtygis.entity.Rxgdbzinfo;
import com.tofly.xrtygis.entity.Rxgdzjlr;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 泡泡
 * 热线--新增改动接口
 */
@RestController
@AllArgsConstructor
@RequestMapping("/newHotline")
@Api(tags = "热线--新增改动接口")
public class NewHotlineController {

    private final NewHotlineService newHotlineService;

    @ApiOperation("获取联系人信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dto", value = "查询条件 为0：编码、姓名、地址、电话  为1：部门、姓名、电话", dataType = "string"),
            @ApiImplicitParam(name = "code", value = "0:客户信息查询，1：员工信息查询", required = true, dataType = "string")
    })
    @GetMapping("/getContactsInfo")
    public ResultRespone getContactsInfo(Page page, String dto, String code) {
        return ResultRespone.success(newHotlineService.getContactsInfo(page, dto, code));
    }

    @GetMapping("/callShiftQuery")
    @ApiOperation("呼叫转移-查询信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dept", value = "部门", dataType = "string"),
            @ApiImplicitParam(name = "dto", value = "姓名/电话", dataType = "string")
    })
    public ResultRespone callShiftQuery(String dept, String dto){
        return ResultRespone.success(newHotlineService.callShiftQuery(dept, dto));
    }

    @ApiOperation("获取工单登记人员信息")
    @GetMapping("/getCrewInfo")
    public ResultRespone getCrewInfo(){
        return ResultRespone.success(newHotlineService.getCrewInfo());
    }

    @ApiOperation("获取工单类型信息")
    @GetMapping("/getworkOrderType")
    public ResultRespone getworkOrderType(){
        return ResultRespone.success(newHotlineService.getworkOrderType());
    }


    @GetMapping("/getRecordGrade")
    @ApiOperation("录音统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "crew", value = "坐席人员", dataType = "string"),
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM", dataType = "string")
    })
    public ResultRespone recordingStatistics(Page page, String crew, String start, String end) {
        return ResultRespone.success(newHotlineService.recordingStatistics(page, crew, start, end));
    }

    @GetMapping("/getRecordInfo")
    @ApiOperation("查询或导出坐席人员详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "crew", value = "坐席人员", dataType = "string"),
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "code", value = "0：不导出  1：导出", required = true, dataType = "string")
    })
    public ResultRespone getRecordInfo(HttpServletResponse response, Page page, String crew, String start, String end, String code) {
        return ResultRespone.success(newHotlineService.getRecordInfo(response, page, crew, start, end, code));
    }

    @GetMapping("/workOrderStatistics")
    @ApiOperation("工单统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "gdlx", value = "工单类型", dataType = "string"),
            @ApiImplicitParam(name = "gdzt", value = "归档状态", dataType = "string"),
            @ApiImplicitParam(name = "djry", value = "登记人员", dataType = "string")
    })
    public ResultRespone workOrderStatistics(Page page, String start, String end,String gdlx,String gdzt,String djry) {
        return ResultRespone.success(newHotlineService.workOrderStatistics(page, start, end,gdlx,gdzt,djry));
    }

    @GetMapping("/workOrderInfo")
    @ApiOperation("查询或导出工单信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gdlx", value = "工单类型", required = true, dataType = "string"),
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "code", value = "0：不导出  1：导出", required = true, dataType = "string"),
            @ApiImplicitParam(name = "type", value = "0：接单/派单 1：已处理  2：终止  3：超时  4：未处理", required = true, dataType = "string"),
            @ApiImplicitParam(name = "gdzt", value = "归档状态", dataType = "string"),
            @ApiImplicitParam(name = "djry", value = "登记人员", dataType = "string")
    })
    public ResultRespone workOrderInfo(HttpServletResponse response, Page page, String gdlx, String start, String end, String type, String code,String gdzt,String djry) {
        return ResultRespone.success(newHotlineService.workOrderInfo(response, page, gdlx, start, end, type, code,gdzt,djry));
    }

    @GetMapping("/returnVisitInfo")
    @ApiOperation("回访工单详细信息查询或导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gdlx", value = "工单类型", required = true, dataType = "string"),
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "code", value = "0：不导出  1：导出", required = true, dataType = "string"),
            @ApiImplicitParam(name = "pass", value = "0：不满意 1：一般  2：满意  3：非常满意 ",dataType = "string")
    })
    public ResultRespone returnVisitInfo(HttpServletResponse response, Page page, String gdlx, String start, String end, String code, String pass,String gdzt,String djry){
        return ResultRespone.success(newHotlineService.returnVisitInfo(response, page, gdlx, start, end, code, pass,gdzt,djry));
    }

    @GetMapping("/returnVisitCount")
    @ApiOperation("回访统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "gdlx", value = "工单类型", dataType = "string"),
            @ApiImplicitParam(name = "gdzt", value = "归档状态", dataType = "string"),
            @ApiImplicitParam(name = "djry", value = "登记人员", dataType = "string")
    })
    public ResultRespone returnVisitCount(Page page, String start, String end,String gdlx,String gdzt,String djry){
        return ResultRespone.success(newHotlineService.returnVisitCount(page, start, end, gdlx, gdzt, djry));
    }

    @GetMapping("/clientInfo")
    @ApiOperation("查询客户信息")
    @ApiImplicitParam(name = "dto",value = "查询条件 编号、姓名、地址、电话",dataType = "string")
    public ResultRespone selectClientInfo(Page page,String dto){
        return ResultRespone.success(newHotlineService.selectClientInfo(page,dto));
    }

    @GetMapping("/orderQualityCount")
    @ApiOperation("工单质检统计查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "gdlx", value = "工单类型", dataType = "string"),
            @ApiImplicitParam(name = "gdzt", value = "归档状态", dataType = "string"),
            @ApiImplicitParam(name = "djry", value = "登记人员", dataType = "string")
    })
    public ResultRespone orderQualityCount(Page page, String start, String end,String gdlx,String gdzt,String djry){
        return ResultRespone.success(newHotlineService.orderQualityCount(page, start, end,gdlx,gdzt,djry));
    }

    @GetMapping("/notTheQuality")
    @ApiOperation("未质检热线工单查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "工单类型", required = true, dataType = "string"),
            @ApiImplicitParam(name = "start", value = "开始时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "end", value = "结束时间 yyyy-MM", dataType = "string"),
            @ApiImplicitParam(name = "gdzt", value = "归档状态", dataType = "string"),
            @ApiImplicitParam(name = "djry", value = "登记人员", dataType = "string"),
            @ApiImplicitParam(name = "code", value = "0:接单数 1:归档数 2:未归档数 3:终止数 4:质检数 5:非质检数")
    })
    public ResultRespone notTheQualityInfo(Page page, String type, String start, String end,String gdzt,String djry,String code){
        return ResultRespone.success(newHotlineService.notTheQualityInfo(page, type, start, end, gdzt, djry,code));
    }

    @PostMapping("/theQuality")
    @ApiOperation("热线工单质检")
    public ResultRespone  theQuality(@RequestBody Rxgdzjlr rxgdzjlr){
        return ResultRespone.success(newHotlineService.theQuality(rxgdzjlr));
    }

    @PostMapping("/insertOrderNote")
    @ApiOperation("热线工单添加备注")
    public ResultRespone insertOrderNote(@RequestBody Rxgdbzinfo rxgdbzinfo){
        return ResultRespone.success(newHotlineService.insertOrderNote(rxgdbzinfo));
    }

    @GetMapping("/getRoleInfo")
    @ApiOperation("获取当前登陆人角色信息")
    public ResultRespone getRoleInfo(){
        return ResultRespone.success(newHotlineService.getRoleInfo());
    }

    @GetMapping("/telGetInfo")
    @ApiOperation("通过电话获取用户信息")
    @ApiImplicitParam(name = "tel",value = "电话号码",required = true,dataType = "string")
    public ResultRespone telGetInfo(String tel){
        return ResultRespone.success(newHotlineService.telGetInfo(tel));
    }

    @GetMapping("/allocation")
    @ApiOperation("工单登记-客户选择")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "str",value = "客户编号、姓名、地址、电话",dataType = "string"),
            @ApiImplicitParam(name = "qydbm",value = "区段编码",dataType = "string"),
            @ApiImplicitParam(name = "qybm",value = "区域编码",dataType = "string")
    })
    public ResultRespone allocation(Page page, String str, String qybm, String qydbm){
        return ResultRespone.success(newHotlineService.allocation(page, str, qybm, qydbm));
    }

    @ApiOperation("id获取部门信息")
    @GetMapping("/getDeptNameById")
    public String getDeptNameById(Long deptId){
        return newHotlineService.getDeptNameById(deptId);
    }

    @ApiOperation("账号获取人员姓名")
    @GetMapping("/getRealNameById")
    public String getRealNameById(String empcode){
        return newHotlineService.getRealNameById(empcode);
    }

    @GetMapping("/getHisTable")
    @ApiOperation("获取生产运行部人员信息")
    public ResultRespone getHisTable(){
        return ResultRespone.success(newHotlineService.getHisTable());
    }
}
