package com.boco.nbd.wios.flow.controller;

import com.boco.nbd.framework.common.ResponseMessage2;
import com.boco.nbd.wios.flow.entity.vo.VisualManagementNodeFlagCountVO;
import com.boco.nbd.wios.flow.service.IVisualManagementService;
import com.boco.nbd.wios.flow.util.ProcessUtil;
import com.ihidea.core.support.session.SessionInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @Description: TODO
 * @Author: ZQY
 * @Date: 2022/10/26
 **/
@RestController
@Slf4j
@RequestMapping("VisualManagement")
@Api(tags = "目视化管理")
public class VisualManagementController {

    @Autowired
    private IVisualManagementService visualManagementService;




    @ApiOperation(value = "根据区域查询节点工单统计")
    @GetMapping( value = "/getNodeFlagByArea")
    public ResponseMessage2 getNodeFlagByArea(String startTime,String endTime){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getNodeFlagByArea(startTime,endTime,user.getUserId()));
    }

    @ApiOperation(value = "根据安装服务商查询节点工单统计")
    @GetMapping( value = "/getNodeFlagByInstallSupplierl")
    public ResponseMessage2 getNodeFlagByInstallSupplierl(String startTime,String endTime,String areaId){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getNodeFlagByInstallSupplierl(startTime,endTime,areaId,user.getUserId()));
    }

    @ApiOperation(value = "根据区域查询工单节点超时统计")
    @GetMapping( value = "/getOvertimeNodeFlagByAreaCount")
    public ResponseMessage2 getOvertimeNodeFlagByAreaCount (String startTime,String endTime){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getOvertimeNodeFlagByAreaCount(startTime,endTime,user.getUserId()));
    }


    @ApiOperation(value = "根据安装服务商查询工单节点超时统计")
    @GetMapping( value = "/getOvertimeNodeFlagByInstallSupplierl")
    public ResponseMessage2 getOvertimeNodeFlagByInstallSupplierl(String startTime,String endTime){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getOvertimeNodeFlagByInstallSupplierl(startTime,endTime,user.getUserId()));
    }

    @ApiOperation(value = "客户首联情况")
    @GetMapping( value = "/getCustomerNode101ByArea")
    public ResponseMessage2 getCustomerNode101ByArea(String startTime,String endTime){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getCustomerNode101ByArea(startTime,endTime,user.getUserId()));
    }

    @ApiOperation(value = "服务商接单情况")
    @GetMapping( value = "/getOrderReceivingBySupplierl")
    public ResponseMessage2 getOrderReceivingBySupplierl(String startTime,String endTime,String id){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getOrderReceivingBySupplierl(startTime,endTime,id,user.getUserId()));
    }


    @ApiOperation(value = "根据服务商ID查询区域接单情况")
    @GetMapping( value = "/getOrderReceivingByAreaAndSupplierlId")
    public ResponseMessage2 getOrderReceivingByAreaAndSupplierlId(String startTime,String endTime,String installSupplierId){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getOrderReceivingByAreaAndSupplierlId(startTime,endTime,installSupplierId,user.getUserId()));
    }

    @ApiOperation(value = "服务商订单结算情况")
    @GetMapping( value = "/getOrderSettlementBySupplierl")
    public ResponseMessage2 getOrderSettlementBySupplierl(String startTime,String endTime,String id){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getOrderSettlementBySupplierl(startTime,endTime,id,user.getUserId()));
    }


    @ApiOperation(value = "根据服务商ID查询区域结算情况")
    @GetMapping( value = "/getOrderSettlementByAreaAndSupplierlId")
    public ResponseMessage2 getOrderSettlementByAreaAndSupplierlId(String startTime,String endTime,String installSupplierId){
        SessionInfo user = ProcessUtil.getUserInfo();
        return ResponseMessage2.Success2(visualManagementService.getOrderSettlementByAreaAndSupplierlId(startTime,endTime,installSupplierId,user.getUserId()));
    }



    @ApiOperation(value = "根据区域查询订单实际情况")
    @GetMapping( value = "/getOrderSituationArea")
    public ResponseMessage2 getOrderSituationArea(String startTime,String endTime){
        SessionInfo user = ProcessUtil.getUserInfo();
        Map<String, List<VisualManagementNodeFlagCountVO>> map = new HashMap(3);
        map.put("order",visualManagementService.getNodeFlagByArea(startTime,endTime,user.getUserId()));
        map.put("orderOverTime",visualManagementService.getOvertimeNodeFlagByAreaCount(startTime,endTime,user.getUserId()));
        map.put("orderAboutOverTime",visualManagementService.getAboutOvertimeNodeFlagByAreaCount(startTime,endTime,user.getUserId()));
        return ResponseMessage2.Success2(map);
    }


    @ApiOperation(value = "根据服务商查询订单实际情况")
    @GetMapping( value = "/getOrderSituationSupplierl")
    public ResponseMessage2 getOrderSituationSupplierl(String startTime,String endTime){
        SessionInfo user = ProcessUtil.getUserInfo();
        Map<String, List<VisualManagementNodeFlagCountVO>> map = new HashMap(3);
        map.put("order",visualManagementService.getNodeFlagByInstallSupplierl(startTime,endTime,"",user.getUserId()));
        map.put("orderOverTime",visualManagementService.getOvertimeNodeFlagByInstallSupplierl(startTime,endTime,user.getUserId()));
        map.put("orderAboutOverTime",visualManagementService.getAboutOvertimeNodeFlagByInstallSupplierl(startTime,endTime,user.getUserId()));
        return ResponseMessage2.Success2(map);
    }







}