/*
 * @Author: Kane
 * @Date: 2023-03-14 16:38:06
 * @LastEditors: Kane
 * @FilePath: /desktop_archievement_backend/src/main/java/com/cpic/xim/web/controllers/archievement/ArchievementQueryController.java
 * @Description: 
 * 业绩查询控制器：
 * 1、queryDepartmentArchievement响应部门业绩查询；
 * 2、
 * 
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 */

package com.cpic.xim.web.controllers.archievement;

import java.util.Vector;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestBody;
import java.sql.SQLException;

import com.cpic.xim.utils.archievement.DepartmentArchievement;

@Controller
@RequestMapping( "/archievement" )
public class ArchievementQueryController
{
    /**
     * 查询坐席业绩
     */
    @PostMapping( "/query_caller_archievement.do" )
    public void queryCallerArchievement()
    {

    }

    /**
     * 查询部门业绩
     * @param request DepartmentArchievementQueryRequest 类型的部门参数。
     * @return 返回 DepartmentArchievementQueryResult 对象。
     */
    @PostMapping( "/query_department_archievement.do" )
    @ResponseBody
    public DepartmentArchievementQueryResult queryDepartmentArchievement(
            @RequestBody DepartmentArchievementQueryRequest request )
    {
        DepartmentArchievementQueryResult result = new DepartmentArchievementQueryResult();
        DepartmentArchievement departmentArch = null;

        try
        {
            // 查询业绩
            departmentArch = DepartmentArchievement
                    .queryDepartmentArchievement( request.getDepartmentCode() );

            result.setTotalArchievement( departmentArch.getTotalArchievement() );
            result.setInsuranceRenewalRate( departmentArch.getInsuranceRenewalRate() );
            result.setAttachingRate( departmentArch.getAttachingRate() );
            result.addAdvanceRewardGainer( "沈群" );
            result.addLeadingRewardGainer( "王鸿津" );
            result.addLeadingRewardGainer( "林宗泽" );
            result.addBackwardStaff( "王炜" );
            result.setMensualArchievementList( departmentArch.getMensualArchievementList() );
        }
        catch ( SQLException error )
        {

        }
        catch ( ClassNotFoundException error )
        {

        }

        result.setSuccess( true );
        result.setMessage( "成功" );

        return result;
    }
}
