package com.zd.chemical.controller;

import com.zd.chemical.domain.HxpChemical;
import com.zd.chemical.domain.HxpStock;
import com.zd.chemical.domain.vo.*;
import com.zd.chemical.service.IHxpAlarmRecordService;
import com.zd.chemical.service.IHxpChemicalService;
import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.web.domain.ResultData;
import com.zd.common.core.web.page.TableDataInfo;
import com.zd.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 化学品信息Controller
 *
 * @author liubo
 * @date 2022-06-16
 */
@RestController
@Api(tags = "【化学品信息】")
@RequestMapping("/hxpHomePage")
public class HxpHomePageStatisticsController extends BaseController {
    @Autowired
    private IHxpChemicalService hxpChemicalService;

    @Autowired
    private IHxpAlarmRecordService hxpAlarmRecordService;

    /**
     * 化学品数量统计查询
     */
    @PreAuthorize(hasPermi = PerPrefix.HPX_HOMEPAGE+ PerFun.LIST)
    @GetMapping("/chemicalUsageCount")
    @ApiOperation(value = "查询化学品信息列表")
    public ResultData chemicalUsageCount(HxpChemical hxpChemical) {
        HxpHomeChemicalVo hxpHomeChemicalVo = hxpChemicalService.chemicalUsageCount(hxpChemical);
        return ResultData.success(hxpHomeChemicalVo);
    }


    /**
     * 化学品特别提示
     */
    @PreAuthorize(hasPermi = PerPrefix.HPX_HOMEPAGE+ PerFun.LIST)
    @GetMapping("/chemicalUnusualCount")
    @ApiOperation(value = "查询化学品信息列表")
    public ResultData chemicalUnusualCount(HxpChemical hxpChemical) {
        HxpHomeChemicalUnusualVo hxpHomeChemicalVo = hxpChemicalService.chemicalUnusualCount(hxpChemical);
        return ResultData.success(hxpHomeChemicalVo);
    }


    /**
     * 化学品使用量top6
     */
    @PreAuthorize(hasPermi = PerPrefix.HPX_HOMEPAGE+ PerFun.LIST)
    @GetMapping("/chemicalUsagesCount")
    @ApiOperation(value = "查询化学品信息列表")
    public ResultData chemicalUsagesCount(HxpChemical hxpChemical) {
        List<HxpHomeChemicalUsagesVo> hxpHomeChemicalVo = hxpChemicalService.chemicalUsagesCount(hxpChemical);
        return ResultData.success(hxpHomeChemicalVo);
    }


    /**
     * 化学品分类占比
     */
    @PreAuthorize(hasPermi = PerPrefix.HPX_HOMEPAGE+ PerFun.LIST)
    @GetMapping("/chemicalClassifyMix")
    @ApiOperation(value = "化学品分类占比列表")
    public ResultData chemicalClassifyMix(HxpChemical hxpChemical) {
        List<LinkedHashMap <String,String>> hxpHomeChemicalVo = hxpChemicalService.chemicalClassifyMix(hxpChemical);
        return ResultData.success(hxpHomeChemicalVo);
    }

    /**
     * 库存总量
     */
    @PreAuthorize(hasPermi = PerPrefix.HPX_HOMEPAGE+ PerFun.LIST)
    @GetMapping("/stockTotal")
    @ApiOperation(value = "化学品分类占比列表")
    public ResultData stockTotal(HxpChemical hxpChemical) {
        return ResultData.success(hxpChemicalService.stockTotal(hxpChemical));
    }


    /**
     * 出入库统计
     */
    @PreAuthorize(hasPermi = PerPrefix.HPX_HOMEPAGE+ PerFun.LIST)
    @GetMapping("/joinOutCount")
    @ApiOperation(value = "化学品分类占比列表")
    public ResultData joinOutCount(HxpStock hxpStock) {
        List<LinkedHashMap <String,String>> hxpHomeChemicalVo = hxpChemicalService.joinOutCount(hxpStock);
        return ResultData.success(hxpHomeChemicalVo);
    }

    /**
     * 查询化学品报警记录列表
     */
    @PreAuthorize(hasPermi = PerPrefix.HPX_HOMEPAGE+ PerFun.LIST)
    @GetMapping("/alarmRecordList")
    @ApiOperation(value = "查询化学品报警记录列表")
    public TableDataInfo <HxpAlarmRecordVo> alarmRecordList(HxpAlarmRecordSearch hxpAlarmRecordSearch) {
        startPage();
        List<HxpAlarmRecordVo> list = hxpAlarmRecordService.selectHxpAlarmRecordList(hxpAlarmRecordSearch);
        return getDataTable(list);
    }
}
