package com.zjsgfa.project.zjsgfa.controller;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zjsgfa.project.zjsgfa.domain.SjSggyZjzhcs;
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.zjsgfa.framework.aspectj.lang.annotation.Log;
import com.zjsgfa.framework.aspectj.lang.enums.BusinessType;
import com.zjsgfa.project.zjsgfa.domain.SjZsjqk;
import com.zjsgfa.project.zjsgfa.service.ISjZsjqkService;
import com.zjsgfa.framework.web.controller.BaseController;
import com.zjsgfa.framework.web.domain.AjaxResult;
import com.zjsgfa.common.utils.poi.ExcelUtil;
import com.zjsgfa.framework.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 设计-注水井情况Controller
 * 
 * @author ruoyi
 * @date 2026-02-04
 */
@RestController
@RequestMapping("/system/sjZsjqk")
public class SjZsjqkController extends BaseController
{
    @Autowired
    private ISjZsjqkService sjZsjqkService;

    /**
     * 查询设计-注水井情况列表
     */
    //@PreAuthorize("@ss.hasPermi('system:sjZsjqk:list')")
    @GetMapping("/list")
    public TableDataInfo list(SjZsjqk sjZsjqk)
    {
        startPage();
        List<SjZsjqk> list = sjZsjqkService.selectSjZsjqkList(sjZsjqk);
        return getDataTable(list);
    }

    /**
     * 导出设计-注水井情况列表
     */
    //@PreAuthorize("@ss.hasPermi('system:sjZsjqk:export')")
    @Log(title = "设计-注水井情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SjZsjqk sjZsjqk)
    {
//        List<SjZsjqk> list = sjZsjqkService.selectSjZsjqkList(sjZsjqk);
        List<SjZsjqk> list = new ArrayList<>();
        ExcelUtil<SjZsjqk> util = new ExcelUtil<SjZsjqk>(SjZsjqk.class);
        util.exportExcel(response, list, "设计-注水井情况数据");
    }

    /**
     * 获取设计-注水井情况详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:sjZsjqk:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sjZsjqkService.selectSjZsjqkById(id));
    }

    /**
     * 新增设计-注水井情况
     */
    //@PreAuthorize("@ss.hasPermi('system:sjZsjqk:add')")
    @Log(title = "设计-注水井情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SjZsjqk sjZsjqk)
    {
        return toAjax(sjZsjqkService.insertSjZsjqk(sjZsjqk));
    }

    /**
     * 修改设计-注水井情况
     */
    //@PreAuthorize("@ss.hasPermi('system:sjZsjqk:edit')")
    @Log(title = "设计-注水井情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SjZsjqk sjZsjqk)
    {
        return toAjax(sjZsjqkService.updateSjZsjqk(sjZsjqk));
    }

    /**
     * 删除设计-注水井情况
     */
    //@PreAuthorize("@ss.hasPermi('system:sjZsjqk:remove')")
    @Log(title = "设计-注水井情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sjZsjqkService.deleteSjZsjqkByIds(ids));
    }



    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, String jh) throws Exception
    {
        ExcelUtil<SjZsjqk> util = new ExcelUtil<SjZsjqk>(SjZsjqk.class);
        List<SjZsjqk> sjZsjqkList = util.importExcel(file.getInputStream());
        sjZsjqkList.forEach(sjFdfx -> sjFdfx.setJh(jh));
        if(sjZsjqkList.size()>0){
            sjZsjqkService.insertSjZsjqkBatch(sjZsjqkList);
        }
        return success("导入成功！");
    }

}
