package com.boman.web.core.controller;
import com.boman.common.core.utils.poi.ExcelUtil;

import com.boman.common.core.web.controller.BaseController;
import com.boman.common.log.annotation.Log;
import com.boman.common.log.enums.BusinessType;
import com.boman.common.security.annotation.PreAuthorize;
import com.boman.domain.Czrk;
import com.boman.domain.TableDataInfo;
import com.boman.domain.dto.AjaxResult;
import com.boman.web.core.domain.AccountingData;
import com.boman.web.core.domain.ToQianshanPersonner;
import com.boman.web.core.domain.vo.AccountingDataVo;
import com.boman.web.core.service.TaskService;
import com.boman.web.core.service.accounting.IAccountingDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 潜山核酸数据Controller
 *
 * @author ruoyi
 * @date 2022-01-14
 */
@RestController
@RequestMapping("/core/account")
@Slf4j
public class AccountingDataController extends BaseController {

    @Resource
    private IAccountingDataService accountingDataService;

    @Resource
    private TaskService taskService;

    /***
     *  潜山核酸数据列表页(根据户籍地)
     * @return
     */
    @GetMapping("/nucleicAcid/hj")
    public TableDataInfo nucleicAcidHj( AccountingDataVo accountingData) {
        List<AccountingDataVo> list = accountingDataService.nucleicAcidHJList(accountingData);
        return getDataTable(list);
    }

    /***
     *  潜山核酸数据列表页(根据居住地址)
     * @return
     */
    @GetMapping("/nucleicAcid/jzdz")
    public TableDataInfo nucleicAcidJzdz( AccountingDataVo accountingData) {
        List<AccountingDataVo> list = accountingDataService.nucleicAcidJzdzList(accountingData);
        return getDataTable(list);
    }


    /**
     *  核酸数据导出(户籍)
     * @param response
     * @param accountingData
     * @throws IOException
     */
    @Log(title = "核酸数据", businessType = BusinessType.EXPORT)
    @PreAuthorize(hasPermi = "system:accountingData:exportHj")
    @PostMapping("/exportHj")
    public void exportHj(HttpServletResponse response, @RequestBody AccountingDataVo accountingData) throws IOException
    {
        List<AccountingDataVo> accountingDataList = accountingDataService.getExportHj(accountingData);
        ExcelUtil<AccountingDataVo> util = new ExcelUtil<>(AccountingDataVo.class);
        util.exportExcel(response, accountingDataList, "核酸数据");
    }

    /**
     *  核酸数据导出(常住)
     * @param response
     * @param accountingData
     * @throws IOException
     */
    @Log(title = "核酸数据", businessType = BusinessType.EXPORT)
    @PreAuthorize(hasPermi = "system:accountingData:exportCz")
    @PostMapping("/exportCz")
    public void exportCz(HttpServletResponse response, @RequestBody AccountingDataVo accountingData) throws IOException
    {
        List<AccountingDataVo> accountingDataList = accountingDataService.exportCz(accountingData);
        ExcelUtil<AccountingDataVo> util = new ExcelUtil<>(AccountingDataVo.class);
        util.exportExcel(response, accountingDataList, "核酸数据");
    }

    @GetMapping("/nucleicAcid/zz")
    public void nucleicAci() {
        taskService.insertAccountingData();
    }

}
