package com.ruoyi.web.controller.projectV2;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.projectV2.ZsyzSbbzb;
import com.ruoyi.system.domain.projectV2.ZsyzShqxPz;
import com.ruoyi.system.service.projectV2.IZsyzSbbzbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 招商引资_申报_首谈信息_主Controller
 * 
 * @author boman
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/projectV2/sbbzb")
public class ZsyzSbbzbController extends BaseController
{
    @Autowired
    private IZsyzSbbzbService zsyzSbbzbService;

    /**
     * 查询招商引资_申报_首谈信息_主列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZsyzSbbzb zsyzSbbzb)
    {
        startPage();
        List<ZsyzSbbzb> list = zsyzSbbzbService.selectZsyzSbbzbList(zsyzSbbzb);
        return getDataTable(list);
    }

    /**
     * 查询招商引资_申报_首谈信息_主列表_招商引资单位单独列表
     */
    @GetMapping("/listYz")
    public TableDataInfo listYz(ZsyzSbbzb zsyzSbbzb)
    {
        startPage();
        List<ZsyzSbbzb> list = zsyzSbbzbService.selectZsyzSbbzbListYz(zsyzSbbzb);
        return getDataTable(list);
    }

    /**
     * 领导批示列表
     */
    @GetMapping("/ldps/list")
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:ldps:list')")
    public TableDataInfo ldpsList(ZsyzSbbzb zsyzSbbzb)
    {
        startPage();
        List<ZsyzSbbzb> list = zsyzSbbzbService.ldpsList(zsyzSbbzb);
        return getDataTable(list);
    }

    /**
     * 导出招商引资_申报_首谈信息_主列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:export')")
    @Log(title = "招商引资_申报_首谈信息_主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZsyzSbbzb zsyzSbbzb)
    {
        List<ZsyzSbbzb> list = zsyzSbbzbService.selectZsyzSbbzbListDc(zsyzSbbzb);
        ExcelUtil<ZsyzSbbzb> util = new ExcelUtil<ZsyzSbbzb>(ZsyzSbbzb.class);
        if ("1".equals(zsyzSbbzb.getExportType())) {
            // 不显示用户ID（单个）
            util.hideColumn("sbdw","tbrq","zszxfzr","yzdqName","yzssName","ntze","xmlb","czpt","tzzt","gtzzrsfzhm","qytzrxyzdm","tzfjj",
                    "sndxse","sndnse","tzrxm","tzrzw","tzrdh","xmjj","phone","zw","progress","xmStatus","meetRemark","zsyzQyxx","zsyzKgxx","zsyzTcxx");
        }
        util.exportExcel(response, list, "招商引资_项目信息");

    }

    /**
     * 获取招商引资_申报_首谈信息_主详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zsyzSbbzbService.selectZsyzSbbzbById(id));
    }

    /**
     * 新增招商引资_申报_首谈信息_主
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:add')")
    @Log(title = "招商引资_申报_首谈信息_主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZsyzSbbzb zsyzSbbzb)
    {
        return toAjax(zsyzSbbzbService.insertZsyzSbbzb(zsyzSbbzb));
    }

    /**
     * 修改招商引资_申报_首谈信息_主
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:edit')")
    @Log(title = "招商引资_申报_首谈信息_主", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ZsyzSbbzb zsyzSbbzb)
    {
        return toAjax(zsyzSbbzbService.updateZsyzSbbzb(zsyzSbbzb));
    }



    /**
     *招商引资_申报_首谈信息_主 是否需要会议支持(专班跟进)
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:meet')")
    @Log(title = "招商引资_申报_首谈信息_主", businessType = BusinessType.UPDATE)
    @PostMapping("/meet")
    public AjaxResult meet(@RequestBody ZsyzSbbzb zsyzSbbzb)
    {
        return toAjax(zsyzSbbzbService.updateZsyzSbbzbMeet(zsyzSbbzb));
    }

    /**
     * 删除招商引资_申报_首谈信息_主
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:remove')")
    @Log(title = "招商引资_申报_首谈信息_主", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zsyzSbbzbService.deleteZsyzSbbzbByIds(ids));
    }

    /**
     * 删除招商引资_申报_首谈信息_主
     */
    @PreAuthorize("@ss.hasPermi('projectV2:sbbzb:remove')")
    @Log(title = "招商引资_申报_首谈信息_主", businessType = BusinessType.DELETE)
    @GetMapping("/delete")
    public AjaxResult Delete(Long id)
    {
        return toAjax(zsyzSbbzbService.deleteZsyzSbbzbById(id));
    }

    /**
     * 通过企查查,查询企业信息
     *
     * @param searchKey
     * @return
     */
    @GetMapping("/qichachaSearch/{searchKey}")
    public AjaxResult qichachaSearch(@PathVariable("searchKey") String searchKey) {
        if (StringUtils.isNotBlank(searchKey)){
            return zsyzSbbzbService.qichachaSearch(searchKey);
        }
        return AjaxResult.success();
    }
}
