package com.yinet.web.controller.dsj;


import com.yinet.common.core.controller.BaseController;
import com.yinet.common.utils.StringUtils;
import com.yinet.system.service.TouchScreenHaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * @author Administrator
 */
@Controller
@RequestMapping("/dsj")
public class DsjBaseController extends BaseController {
    static String touchIndex = "dsj/";

    @Autowired
    private TouchScreenHaoService touchScreenHaoService;

    @GetMapping("echars")
    public String echars(ModelMap mmap) {
        Map<String, Integer> pieNum = touchScreenHaoService.selectPieNum();
        mmap.addAttribute("pieNum", pieNum);
        return touchIndex+"echars";
    }
    @GetMapping("canvasbg")
    public String canvasbg() {
        return touchIndex+"canvasbg";
    }
    @GetMapping("line")
    public String line() {
        return touchIndex+"line";
    }
    @GetMapping("mone")
    public String mone() {
        return touchIndex+"mone";
    }

     /**
     * 实时叫号
      */
    @GetMapping("/index")
    public String viewRTC(ModelMap mmap) {
        Map<String, Integer> pieNum = touchScreenHaoService.selectPieNum();
        Map<String, Integer> callNum = touchScreenHaoService.selectNum();
        Integer haoCount = touchScreenHaoService.selectCount();
        mmap.addAttribute("pieNum", pieNum);
        if (StringUtils.isNotEmpty(callNum)) {
            Integer today = callNum.get("today");
            Integer blz = callNum.get("blz");
            Integer deng = callNum.get("deng");
            Integer month=callNum.get("month");
            Integer week=callNum.get("week");
            Integer yb = today - blz - deng;
            mmap.addAttribute("today", today);
            mmap.addAttribute("blz", blz);
            mmap.addAttribute("deng", deng);
            mmap.addAttribute("yb", yb < 0 ? 0 : yb);
            mmap.addAttribute("month",month);
            mmap.addAttribute("week",week);
        } else {
            mmap.addAttribute("today", 0);
            mmap.addAttribute("blz", 0);
            mmap.addAttribute("deng", 0);
            mmap.addAttribute("yb", 0);
            mmap.addAttribute("month",0);
            mmap.addAttribute("week",0);
        }
        mmap.addAttribute("zong", haoCount);
        return touchIndex+"index";
    }



}
