package com.ruoyi.project.patrol.patrol.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.patrol.patrol.domain.TIndex;
import com.ruoyi.project.patrol.patrol.service.ITIndexService;
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 java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/patrol/index")
public class TIndexController extends BaseController {
    @Autowired
    private ITIndexService tIndexService;
    @GetMapping("/countNums")
    public AjaxResult getCountNums() {
        TIndex tIndex = new TIndex();
        tIndex.setCreateDate(new Date());
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        tIndex.setYear(String.valueOf(calendar.get(Calendar.YEAR)));
        tIndex.setMonth(String.valueOf(calendar.get(Calendar.MONTH) + 1));
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("devNum", tIndexService.getDevNumber());
        resultMap.put("uncheckPlanNum", tIndexService.getUncheckNumber(tIndex));
        resultMap.put("checkedPlanNum", tIndexService.getCheckNumber(tIndex));
        resultMap.put("issueNum", tIndexService.getIssueNumber(tIndex));
        return AjaxResult.success(resultMap);
    }
}
