package com.fs.company.controller.qw;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.utils.StringUtils;
import com.fs.qw.dto.SopCompanyUserTaskDto;
import com.fs.qw.service.IFsSopCompanyUserTaskService;
import com.fs.qw.vo.SopCompanyUserTaskVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.fs.his.utils.PhoneUtil.decryptPhone;


/**
 * 销售sop任务统计Controller
 * 
 * @author fs
 * @date 2025-12-23
 */
@RestController
@RequestMapping("/qw/companyUserTaskStats")
public class FsSopCompanyUserTaskStatsController extends BaseController
{
    @Autowired
    private IFsSopCompanyUserTaskService fsSopCompanyUserTaskService;

    /**
     * 获取销售/医生sop任务统计
     */
    @GetMapping("/stats")
    @PreAuthorize("@ss.hasPermi('qw:companyUserTaskStats:stats')")
    public AjaxResult getTaskStatistics() {
        return AjaxResult.success(fsSopCompanyUserTaskService.getTaskStatistics());
    }

    @GetMapping("/trend/last7days")
    @PreAuthorize("@ss.hasPermi('qw:companyUserTaskStats:stats')")
    public AjaxResult getLast7DaysTrend() {
        return AjaxResult.success(fsSopCompanyUserTaskService.getTaskTrendLast7Days());
    }

    /**
     * 查询销售处理sop任务列表
     */
    @PreAuthorize("@ss.hasPermi('qw:companyUserTaskStatsOverview:list')")
    @GetMapping("/statsOverviewList")
    public TableDataInfo list(SopCompanyUserTaskDto queryDto)
    {
        startPage();
        List<SopCompanyUserTaskVo> list = fsSopCompanyUserTaskService.statsOverviewAllList(queryDto);
        return getDataTable(list);
    }
}
