package com.shkj.wms.controller.report;

import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.wms.bo.SysReportStockQueryBo;
import com.shkj.wms.domain.BasePoint;
import com.shkj.wms.domain.BusinAgvRealRedisInfo;
import com.shkj.wms.domain.BusinPlcStatus;
import com.shkj.wms.service.IBasePointService;
import com.shkj.wms.service.IBusinDataTaskService;
import com.shkj.wms.service.ISysStockService;
import com.shkj.wms.service.IWcsDeviceService;
import com.shkj.wms.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

/**
 * @author Comair
 * @date 2023年10月24日 22:03
 */
@RestController
@RequestMapping("/dataScreen/stock")
public class SysReportStockController extends BaseController {

    @Resource
    private IBasePointService iBasePointService;

    @Resource
    private ISysStockService sysStockService;

    @Autowired
    private IWcsDeviceService iWcsDeviceService;

    @Autowired
    private IBusinDataTaskService iBusinDataTaskService;

    /**
     * 保险杠立库仓库管理看板
     * @author zjx
     * @date 2024/04/07
     * @param bo
     * @return
     */
    @GetMapping("/stockList")
    public Result<List<SysStockNumVo>> stockList(SysReportStockQueryBo bo) {
        startPage();
        List<SysStockNumVo> list = sysStockService.queryStockList(bo);
        return Result.ok().data(list);
    }

    @PostMapping("/listExport")
    public List<SysStockNumVo> listExport(SysReportStockQueryBo bo) {
        List<SysStockNumVo> list = sysStockService.queryStockList(bo);
        return list;
    }

    /**
     * 车型颜色库存图表
     * @param bo
     * @return
     */

    @GetMapping("/vehicheColorList")
    public Result<Map<String, List<SysStockVehicheColorVo>>> vehicheColorList(SysReportStockQueryBo bo) {
        Map<String, List<SysStockVehicheColorVo>> list= sysStockService.vehicheColorList(bo);
        return Result.ok().data(list);
    }


    /**
     * 车型颜色库存图表
     * @param bo
     * @return
     */

    @GetMapping("/vehicheColorLocationList")
    public Result<Map<String, List<SysStockVCLocationVo>>> vehicheColorLocationList(SysReportStockQueryBo bo) {
        Map<String, List<SysStockVCLocationVo>> list= sysStockService.vehicheColorLocationList(bo);
        return Result.ok().data(list);
    }


    /**
     * 码头状态 pointGroup=6 -> 6代表翻修码头，7代表异常码头
     * @param bo
     * @return
     */

    @GetMapping("/getPointStatus")
    public Result<List<BasePoint>> getPointStatus(BasePoint bo) {
        List<BasePoint> list = iBasePointService.selectBasePointList(bo);
        return Result.ok().data(list);
    }


    /**
     * 获取堆垛机的状态
     */

    @GetMapping("/getStkDevtatus")
    public Result<List<BusinPlcStatus>> getStkDevtatus()
    {
        return Result.ok().data(iWcsDeviceService.getStkStatusFromRedis());
    }



    /**
     * 获取AGV设备状态信息
     */

    @GetMapping("/getAGVRealStatesInfo")
    public Result<List<BusinAgvRealRedisInfo>> getAGVRealStatesInfo()
    {
        return  Result.ok().data(iWcsDeviceService.getAGVRealStatesInfo());
    }

    /**
     * 当前任务统计
     */

    @GetMapping("/getCurDateTaskQty")
    public Result<List<DataScreeTaskqtyVo>> getCurDateTaskQty()
    {
        return  Result.ok().data(iBusinDataTaskService.getCurDateTaskQty());
    }


    /**
     * 大屏立库看板-车型颜色及车型细分
     * @return
     */

    @GetMapping("/getVehicheStockList")
    public Result<Map<String, List<SysStockVehicheVo>>> getVehicheStockList() {
        Map<String, List<SysStockVehicheVo>> list= sysStockService.getVehicheStockList();
        return Result.ok().data(list);
    }

}
