package com.zcloud.personnel.positioning.web;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.personnel.positioning.api.PersonnelPositioningBiServiceI;
import com.zcloud.personnel.positioning.dto.BiAreaFenceQry;
import com.zcloud.personnel.positioning.dto.BiCompanyFenceQry;
import com.zcloud.personnel.positioning.dto.BiCompanyOnlinePersonQry;
import com.zcloud.personnel.positioning.dto.BiPersonLocationQry;
import com.zcloud.personnel.positioning.dto.BiPersonPositionQry;
import com.zcloud.personnel.positioning.dto.BiPersonTraceQry;
import com.zcloud.personnel.positioning.dto.clientobject.BiAreaFenceCO;
import com.zcloud.personnel.positioning.dto.clientobject.BiCompanyLocationCO;
import com.zcloud.personnel.positioning.dto.clientobject.BiCompanyOnlinePersonStatCO;
import com.zcloud.personnel.positioning.dto.clientobject.BiOverviewCO;
import com.zcloud.personnel.positioning.dto.clientobject.BiPersonLocationCO;
import com.zcloud.personnel.positioning.dto.clientobject.BiPersonPositionCO;
import com.zcloud.personnel.positioning.dto.clientobject.BiPersonTraceCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 人员定位BI接口
 *
 * @Author fangjiakai
 * @Date 2026-07-07
 */
@Api(tags = "人员定位BI")
@RequestMapping("/${application.gateway}/bi")
@RestController
@AllArgsConstructor
public class PersonnelPositioningBiController {
    private final PersonnelPositioningBiServiceI personnelPositioningBiService;

    @ApiOperation("BI概览")
    @GetMapping("/overview")
    public SingleResponse<BiOverviewCO> queryOverview() {
        return SingleResponse.of(personnelPositioningBiService.queryOverview());
    }

    @ApiOperation("公司定位点，可按港区过滤")
    @GetMapping("/companyLocation/list")
    public MultiResponse<BiCompanyLocationCO> listCompanyLocation(
            @RequestParam(value = "portArea", required = false) Integer portArea) {
        return MultiResponse.of(personnelPositioningBiService.listCompanyLocation(portArea));
    }

    @ApiOperation("公司围栏分页")
    @PostMapping("/companyFence/list")
    public PageResponse<BiAreaFenceCO> listCompanyFence(@RequestBody BiCompanyFenceQry qry) {
        return personnelPositioningBiService.listCompanyFence(qry);
    }

    @ApiOperation("人员实时定位")
    @PostMapping("/personLocation/list")
    public PageResponse<BiPersonLocationCO> listPersonLocation(@RequestBody BiPersonLocationQry qry) {
        return personnelPositioningBiService.listPersonLocation(qry);
    }




    @ApiOperation("人员轨迹")
    @PostMapping("/personTrace")
    public SingleResponse<BiPersonTraceCO> queryPersonTrace(@RequestBody BiPersonTraceQry qry) {
        return SingleResponse.of(personnelPositioningBiService.queryPersonTrace(qry));
    }

    @ApiOperation("区域/围栏分页")
    @PostMapping("/areaFence/list")
    public PageResponse<BiAreaFenceCO> listAreaFence(@RequestBody BiAreaFenceQry qry) {
        return personnelPositioningBiService.listAreaFence(qry);
    }

    @ApiOperation("区域/围栏全量")
    @GetMapping("/areaFence/listAll")
    public MultiResponse<BiAreaFenceCO> listAllAreaFence() {
        return MultiResponse.of(personnelPositioningBiService.listAllAreaFence());
    }

    @ApiOperation("区域/围栏详情")
    @GetMapping("/areaFence/{id}")
    public SingleResponse<BiAreaFenceCO> queryAreaFenceById(@PathVariable("id") Long id) {
        return SingleResponse.of(personnelPositioningBiService.queryAreaFenceById(id));
    }

        @ApiOperation("可视化大屏-企业在线人员统计")
    @PostMapping("/personLocation/companyOnlineStat")
    public SingleResponse<BiCompanyOnlinePersonStatCO> queryCompanyOnlinePersonStat(
            @RequestBody BiCompanyOnlinePersonQry qry) {
        return SingleResponse.of(personnelPositioningBiService.queryCompanyOnlinePersonStat(qry));
    }
        @ApiOperation("可视化大屏-人员定位列表")
    @PostMapping("/personLocation/positioning")
    public MultiResponse<BiPersonPositionCO> listPersonPosition(@RequestBody BiPersonPositionQry qry) {
        return MultiResponse.of(personnelPositioningBiService.listPersonPosition(qry));
    }
}
