package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.fire.service.BscEnterpriseAutonomyService;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * <p>
 * 企业自主管理大屏统计（全部） 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-10-09
 */
@RestController
@RequestMapping("/bscEnterpriseAutonomy")
public class BscEnterpriseAutonomyController {

    @Autowired
    private BscEnterpriseAutonomyService bscEnterpriseAutonomyService;

    /**
     * 企业自主管理大屏统计-全部单位数据查询
     *
     * @param moduleType 模块类型
     * @param dataType   数据类型
     * @return
     */
    @GetMapping("enterpriseAutonomy")
    public ApiResult<Object> enterpriseAutonomy(@RequestParam(value = "dataType") String dataType,
                                                @RequestParam(value = "moduleType") String moduleType,
                                                @RequestParam(value = "streetTown", required = false) String streetTown) {
        return ApiResult.success(bscEnterpriseAutonomyService.enterprise(moduleType, dataType, streetTown));
    }


    /**
     * 企业自主管理大屏统计(全部)-手动生成数据
     *
     * @return
     */
    @GetMapping("streetCompany")
    public ApiResult<Void> streetCompany() {
//        bscEnterpriseAutonomyService.patrolInspection();
        bscEnterpriseAutonomyService.enterpriseAutonomyTask();
        return ApiResult.success();
    }


    /**
     * 企业自主管理-企业经营情况-数据查询
     *
     * @param companyId 单位ID
     * @return
     */
    @GetMapping("erpData")
    public ApiResult<List<Map<String, Object>>> erpData(@RequestParam(value = "companyId", defaultValue = "2DB679350A0F4023B74C4261539AA031") String companyId) {
        return ApiResult.success(bscEnterpriseAutonomyService.erpData(companyId));
    }


    /**
     * 企业自主管理-物联网处置情况查询
     *
     * @param streetTown 街镇
     * @param startDate  开始时间
     * @param endDate    结束时间
     * @return
     */
    @GetMapping("iotDisposal")
    public ApiResult<Map<String, Object>> iotDisposal(@RequestParam(value = "streetTown", required = false) String streetTown,
                                                      @RequestParam(value = "startDate", required = false) String startDate,
                                                      @RequestParam(value = "endDate", required = false) String endDate) {
        return ApiResult.success(bscEnterpriseAutonomyService.iotDisposal(streetTown, startDate, endDate));
    }

    /**
     * 企业自主管理-各街镇物联动态
     *
     * @return
     */
    @GetMapping("streetDynamic")
    public ApiResult<List<Map<String, Object>>> streetDynamic() {
        return ApiResult.success(bscEnterpriseAutonomyService.streetDynamic());
    }

    /**
     * 企业自主管理-重点单位撒点-数据查询
     *
     * @param companyId 单位ID
     * @return
     */
    @GetMapping("scatterData")
    public ApiResult<List<Map<String, Object>>> scatterData(@RequestParam(value = "companyId", required = false) String companyId) {
        return ApiResult.success(bscEnterpriseAutonomyService.scatterData(companyId));
    }
}

