EnterpriseInfoController.java 6.24 KB
package com.lhcredit.project.business.enterpriseInfo.controller;


import com.github.pagehelper.PageHelper;
import com.lhcredit.common.utils.poi.ExcelUtil;
import com.lhcredit.framework.aspectj.lang.annotation.Log;
import com.lhcredit.framework.aspectj.lang.enums.BusinessType;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;
import com.lhcredit.framework.web.page.TableDataInfo;
import com.lhcredit.project.business.enterpriseInfo.domain.EnterpriseInfo;
import com.lhcredit.project.business.enterpriseInfo.service.IEnterpriseInfoService;
import com.lhcredit.project.business.frontUser.domain.FrontUserMon;
import com.lhcredit.project.business.searchLog.service.ISearchLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 企业信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-25
 */
@RestController
@RequestMapping("/business/info")
public class EnterpriseInfoController extends BaseController
{
    @Autowired
    private IEnterpriseInfoService enterpriseInfoService;

    @Autowired
    private ISearchLogService searchLogService;

    /**
     * 查询企业信息列表
     */
    @PostMapping("/getEnterpriseList")
    public TableDataInfo getEnterpriseList(EnterpriseInfo enterpriseInfo)
    {
        //设置当前登陆人
        FrontUserMon loginUser=getUserInfo();
        enterpriseInfo.setCreateBy(loginUser.getUserName());
        //记录 搜索日志,当搜索名称为空时, 不统计
        if (StringUtils.isNotEmpty(enterpriseInfo.getEname()))
            searchLogService.setSearchLogs(enterpriseInfo);

        startPage();
        List<EnterpriseInfo> list = enterpriseInfoService.selectEnterpriseInfoList(enterpriseInfo);
        return getDataTable(list);
    }

    /**
     * 根据统一社会信用代码查询 企业标签
     * @param creditCode
     * @return
     */
    @GetMapping("/getEnterpriseInfoByEcdoe")
    public AjaxResult getEnterpriseInfoByEcdoe(String creditCode){

        if (StringUtils.isEmpty(creditCode))
            return AjaxResult.error("企业统一社会信用代码必传");
        EnterpriseInfo enterpriseInfo = EnterpriseInfo.builder().creditCode(creditCode).build();

        return AjaxResult.success(enterpriseInfoService.getEnterpriseInfoByEcdoe(enterpriseInfo));

    }


    /**
     * 导出企业信息列表 (默认导出1000条)
     */
//    @PreAuthorize("@ss.hasPermi('business:info:export')")
    @Log(title = "企业信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response,EnterpriseInfo enterpriseInfo) throws Exception
    {
        //默认导出1000条
        PageHelper.startPage(1,1000);
        List<EnterpriseInfo> list = enterpriseInfoService.selectEnterpriseInfoList(enterpriseInfo);
        // 设置响应头,修改下载文件名
        String fileName = "企业信息.xlsx";
        String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
        response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedFileName + "\"; filename*=UTF-8''" + encodedFileName);
//        response.setHeader("Content-Disposition", "attachment; filename=\"555.xlsx\"");
        ExcelUtil<EnterpriseInfo> util = new ExcelUtil<EnterpriseInfo>(EnterpriseInfo.class);
        util.exportExcel( list, "企业信息数据",response);
    }

    /**
     * 获取企业信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(enterpriseInfoService.selectEnterpriseInfoById(id));
    }



    /**
     * 新增企业信息
     */
    @Log(title = "企业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnterpriseInfo enterpriseInfo)
    {
        return toAjax(enterpriseInfoService.insertEnterpriseInfo(enterpriseInfo));
    }

    /**
     * 修改企业信息
     */
    @Log(title = "企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnterpriseInfo enterpriseInfo)
    {
        return toAjax(enterpriseInfoService.updateEnterpriseInfo(enterpriseInfo));
    }

    /**
     * 删除企业信息
     */
    @Log(title = "企业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(enterpriseInfoService.deleteEnterpriseInfoByIds(ids));
    }


    /**
     * 查询 各个类型的企业 数量
     * @return
     */
    @GetMapping("/getEnterpriseCount")
    public AjaxResult getEnterpriseCount(){
        return success(enterpriseInfoService.getEnterpriseCount());
    }


    /**
     * 查询企业数量变化趋势 图
     * @param enterpriseInfo
     * @return
     */
    @PostMapping("/getEnterpriseCountTrend")
    public AjaxResult getEnterpriseCountTrend(EnterpriseInfo enterpriseInfo){

        return AjaxResult.success(enterpriseInfoService.getEnterpriseCountTrend(enterpriseInfo));
    }

    /**
     * 企业吊销/注销数量变化趋势 图
     * @param enterpriseInfo
     * @return
     */
    @PostMapping("/getEnterpriseRegCountTrend")
    public AjaxResult getEnterpriseRegCountTrend(EnterpriseInfo enterpriseInfo) {
        return AjaxResult.success(enterpriseInfoService.getEnterpriseRegCountTrend(enterpriseInfo));
    }


    /**
     * 企业地区数量占比分布情况 / 企业信用评级占比分布情况
     * @param enterpriseInfo
     * @return
     */
    @PostMapping("/getEnterpriseCountByType")
    public AjaxResult getEnterpriseCountByType(EnterpriseInfo enterpriseInfo){
        return AjaxResult.success(enterpriseInfoService.getEnterpriseCountByType(enterpriseInfo));
    }

    /**
     *企业注册资本规模占比分布情况 图
     * @param enterpriseInfo
     * @return
     */
    @PostMapping("/getEnterpriseCountRegCapTrend")
    public AjaxResult getEnterpriseCountRegCapTrend(EnterpriseInfo enterpriseInfo){
        return AjaxResult.success(enterpriseInfoService.getEnterpriseCountRegCapTrend(enterpriseInfo));
    }

}