package com.foreverwin.mesnac.common.controller;

import com.foreverwin.mesnac.common.mapper.BoardMapper;
import com.foreverwin.mesnac.common.service.BoardService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.R;
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.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/BOARD")
public class BoardController {
    @Autowired
    public BoardService boardService;
    @Autowired
    public BoardMapper boardMapper;

    /**
     * 设备运行状态
     */
    @GetMapping("/resourceRunData")
    public R resourceRunData(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceRunData(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 设备运行状态参数
     */
    @GetMapping("/resourceRunParamData")
    public R resourceRunParamData(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceRunParamData(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 设备故障描述
     */
    @GetMapping("/resourceFaultDescription")
    public R resourceFaultDescription(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceFaultDescription(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 车间计划完成数
     */
    @GetMapping("/monthPlanCompleteData")
    public R monthPlanCompleteData(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.monthPlanCompleteData(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 车间月完成数
     */
    @GetMapping("/monthCompleteData")
    public R monthCompleteData(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.monthCompleteData(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     * 月计划完成数和月完成数
     */
    @GetMapping("/monthCompleteAndPlanCompleteData")
    public R monthCompleteAndPlanCompleteData(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.monthCompleteAndPlanCompleteData(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 车间合格率
     */
    @GetMapping("/percentOfPass")
    public R percentOfPass(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.percentOfPass(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 车间设备近三天运行数
     */
    @GetMapping("/resourceRunDataThreeDay")
    public R resourceRunDataThreeDay(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceRunDataThreeDay(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 车间设备近三天运行数
     */
    @GetMapping("/onceEspecially")
    public R onceEspecially(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.onceEspecially(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 完工进度
     */
    @GetMapping("/scheduleOfCompletion")
    public R scheduleOfCompletion(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.scheduleOfCompletion(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 异常处理情况
     */
    @GetMapping("/abnormalResolveData")
    public R abnormalResolveData(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.abnormalResolveData(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 异常响应情况
     */
    @GetMapping("/abnormalContent")
    public R abnormalContent(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.abnormalContent(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 焊接车间计划数
     */
    @GetMapping("/planDataFSW")
    public R planDataFSW(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.planDataFSW(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     *
     */
    @GetMapping("/completeDataFSW")
    public R completeDataFSW(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.completeDataFSW(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     *
     */
    @GetMapping("/planAndCompleteDataFSW")
    public R planAndCompleteDataFSW(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.planAndCompleteDataFSW(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     *
     */
    @GetMapping("/resourceStatusQty")
    public R resourceStatusQty(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceStatusQty(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     *
     */
    @GetMapping("/resourceAbnormalInfo")
    public R resourceAbnormalInfo(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceAbnormalInfo(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     *
     */
    @GetMapping("/resourceFaultThree")
    public R resourceFaultThree(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceFaultThree(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     *
     */
    @GetMapping("/completeRate")
    public R completeRate(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.completeRate(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     *
     */
    @GetMapping("/resourceRunQtyAll")
    public R resourceRunQtyAll(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceRunQtyAll(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     *
     */
    @GetMapping("/resourceQtyRun")
    public R resourceQtyRun(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceQtyRun(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     *
     */
    @GetMapping("/resourceQtyFree")
    public R resourceQtyFree(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceQtyFree(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }
    /**
     *
     */
    @GetMapping("/resourceQtyDow")
    public R resourceQtyDow(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceQtyDow(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     *
     */
    @GetMapping("/resourceQtyAll")
    public R resourceQtyAll(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.resourceQtyAll(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 异常类型数量
     */
    @GetMapping("/abnormalTypeQty")
    public R abnormalTypeQty(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.abnormalTypeQty(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }

    /**
     * 异常详情
     */
    @GetMapping("/abnormalDataDetails")
    public R abnormalDataDetails(@RequestParam(required = false) Map paramMap) {
        try {
            paramMap.put("site", CommonMethods.getSite());
            List<Map<String, Object>> result = boardMapper.abnormalDataDetails(paramMap);
            return R.ok(result);
        } catch (Exception e) {
            return R.failed(e.getMessage());
        }
    }


}
