package com.ruoyi.web.controller.system;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.vo.UrPatentValidStaticVo;
import com.ruoyi.system.domain.vo.UrPatentValidVo;
import com.ruoyi.system.service.IUrYearValidDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.ResponseData;

import java.util.Calendar;
import java.util.List;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.UrPatentValid;
import com.ruoyi.system.service.IUrPatentValidService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report.service.IRzlViewStatisticsInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 有效专利Controller
 * 
 * @author dm
 * @date 2023-02-10
 */
@Api(value = "有效专利",tags = "有效专利")
@ApiSupport(author = "dm",order = 10)
@RestController
@RequestMapping("/system/urPatentValid")
public class UrPatentValidController extends BaseController {
    @Autowired
    private IUrPatentValidService urPatentValidService;

    @Autowired
    private IUrYearValidDataService iUrYearValidDataService;
    @Autowired
    private IRzlViewStatisticsInfoService rzlViewStatisticsInfoService;
    /**
     * 查询有效专利列表
     */
    @ApiOperation(value = "查询有效专利列表", notes = "查询有效专利列表")
    @ApiOperationSupport(order = 10)
    @GetMapping("/list")
    public AjaxResult list(UrPatentValidVo urPatentValid) {
        List<UrPatentValidStaticVo> list = urPatentValidService.selectList(urPatentValid);
        return AjaxResult.success(list);
    }

    /**
     * 获取动态表头
     */
    @GetMapping("/getHeader")
    public AjaxResult getHeader(String year) {
        UrPatentValidVo vo = new UrPatentValidVo();
        if(StringUtils.isNotBlank(year)) {
            vo.setEndDate(year);
            int intYear = Integer.parseInt(year);
            vo.setStartDate(String.valueOf(intYear - 9));
        }
        List<UrPatentValid> list = urPatentValidService.selectHeaderList(vo);
        return AjaxResult.success(list);
    }

    /**
     * 获取查询年列表
     */
    @GetMapping("/getYearList")
    public AjaxResult getYearList() {
//        List<String> list = iUrYearValidDataService.selectYearList();
    	
    	 Calendar c = Calendar.getInstance();
         int year = c.get(Calendar.YEAR);
         year = year - 10;
         List<String> list = rzlViewStatisticsInfoService.selectYearList(year);
         
        return AjaxResult.success(list);
    }

}
