package com.yanzhu.jh.project.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.SysRoleEnum;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ExcelUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDeptService;
import com.yanzhu.jh.project.domain.SurProject;
import com.yanzhu.jh.project.domain.vo.ProjectViewExport;
import com.yanzhu.jh.project.domain.vo.ProjectViewJlExport;
import com.yanzhu.jh.project.service.IProjectViewService;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * ProjectViewController
 * 项目统计
 * @author JiangYuQi
 * @date 2023-07-29
 */
@RestController
@RequestMapping("/statistics/project")
public class ProjectViewController extends BaseBuildNodeController{

    @Autowired
    private ISysDeptService sysDeptService;

    @Autowired
    IProjectViewService projectViewService;

    @PreAuthorize("@ss.hasPermi('statistics:project:list')")
    @GetMapping("/selectStatisticsProjectList")
    public TableDataInfo selectStatisticsProjectList(SurProject surProject)
    {
        surProject.setNowRole(Convert.toStr(getUserFirstRole()));
        if(SysRoleEnum.ZGS.getCode().equals(surProject.getNowRole())){
            surProject.setDeptId(sysDeptService.getZGSDeptId(getDeptId()));
        }
        List<ProjectViewExport> list = projectViewService.selectStatisticsProjectList(surProject);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('statistics:project:export')")
    @Log(title = "项目数据汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/exportView")
    public void exportView(HttpServletResponse response, @RequestBody SurProject surProject)
    {
        surProject.setNowRole(Convert.toStr(getUserFirstRole()));
        if(SysRoleEnum.ZGS.getCode().equals(surProject.getNowRole())){
            surProject.setDeptId(sysDeptService.getZGSDeptId(getDeptId()));
        }
        OutputStream outputStream = null;
        List<ProjectViewExport> list = projectViewService.selectStatisticsProjectList(surProject);
        try {
            response.reset();// 清空输出流
            response.setContentType("application/octet-stream;charset=UTF-8");
            String fileName = "项目数据汇总_"+DateUtils.getDate() + ".xlsx";
            fileName = new String(fileName.getBytes(StandardCharsets.UTF_8));
            response.addHeader("Content-disposition", "attachment;filename=" + fileName);
            response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
            response.addHeader("Pargam", "no-cache");
            response.addHeader("Cache-Control", "no-cache");
            response.addHeader("Access-Control-Allow-Origin", "*");
            SXSSFWorkbook wb = new SXSSFWorkbook(500);
            Sheet sheet = wb.createSheet("项目数据汇总");
            CellStyle titleStyle = ExcelUtils.myCreateTitleCellStyle(wb);
            CellStyle headerStyle = ExcelUtils.createHeadCellStyle(wb);
            CellStyle contentStyle = ExcelUtils.createContentCellStyle(wb);

            // 行号
            Row tempRow = null;
            Cell tempCell = null;
            int rowNum = 0;
            // 创建第一页的第一行，索引从0开始
            tempRow = sheet.createRow(rowNum++);
            tempRow.setHeight((short) 500);// 设置行高

            String title = "泾河新城产发集团项目数据汇总";
            tempCell = tempRow.createCell(0);
            tempCell.setCellValue(title);
            tempCell.setCellStyle(titleStyle);

            //合计行
            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 30));//单元格合并

            tempRow = sheet.createRow(rowNum++);
            tempRow.setHeight((short) 400);// 设置行高
            tempCell = tempRow.createCell(0);
            tempCell.setCellValue("项目名称");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(1);
            tempCell.setCellValue("参建单位");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(2);
            tempCell.setCellValue("项目详情");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(3);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(4);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(5);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(6);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(7);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(8);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(9);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, 9));//单元格合并

            tempCell = tempRow.createCell(10);
            tempCell.setCellValue("安全管理");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(11);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(12);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(13);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(14);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(15);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(16);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(17);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 10, 17));//单元格合并

            tempCell = tempRow.createCell(18);
            tempCell.setCellValue("质量管理");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(19);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(20);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(21);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(22);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(23);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(24);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 18, 24));//单元格合并

            tempCell = tempRow.createCell(25);
            tempCell.setCellValue("视频管理");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(26);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(27);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 25, 27));//单元格合并

            tempCell = tempRow.createCell(28);
            tempCell.setCellValue("工程管理");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(29);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(30);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 28, 30));//单元格合并

            //合计行
            sheet.setColumnWidth(0, 400 * 20 + 323);
            sheet.setColumnWidth(1, 350 * 20 + 323);
            sheet.setColumnWidth(2, 150 * 20 + 323);
            sheet.setColumnWidth(3, 150 * 20 + 323);
            sheet.setColumnWidth(4, 150 * 20 + 323);
            sheet.setColumnWidth(5, 150 * 20 + 323);
            sheet.setColumnWidth(6, 150 * 20 + 323);
            sheet.setColumnWidth(7, 150 * 20 + 323);
            sheet.setColumnWidth(8, 150 * 20 + 323);
            sheet.setColumnWidth(9, 150 * 20 + 323);
            sheet.setColumnWidth(10, 150 * 20 + 323);
            sheet.setColumnWidth(11, 150 * 20 + 323);
            sheet.setColumnWidth(12, 150 * 20 + 323);
            sheet.setColumnWidth(13, 150 * 20 + 323);
            sheet.setColumnWidth(14, 150 * 20 + 323);
            sheet.setColumnWidth(15, 150 * 20 + 323);
            sheet.setColumnWidth(16, 150 * 20 + 323);
            sheet.setColumnWidth(17, 150 * 20 + 323);
            sheet.setColumnWidth(18, 150 * 20 + 323);
            sheet.setColumnWidth(19, 150 * 20 + 323);
            sheet.setColumnWidth(20, 150 * 20 + 323);
            sheet.setColumnWidth(21, 150 * 20 + 323);
            sheet.setColumnWidth(22, 150 * 20 + 323);
            sheet.setColumnWidth(23, 150 * 20 + 323);
            sheet.setColumnWidth(24, 150 * 20 + 323);
            sheet.setColumnWidth(25, 150 * 20 + 323);
            sheet.setColumnWidth(26, 150 * 20 + 323);
            sheet.setColumnWidth(27, 150 * 20 + 323);
            sheet.setColumnWidth(28, 150 * 20 + 323);
            sheet.setColumnWidth(29, 150 * 20 + 323);
            sheet.setColumnWidth(30, 150 * 20 + 323);

            tempRow = sheet.createRow(rowNum++);
            tempRow.setHeight((short) 400);// 设置行高
            tempCell = tempRow.createCell(0);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(1);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(2);
            tempCell.setCellValue("劳务实名制");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(3);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, 3));//单元格合并

            tempCell = tempRow.createCell(4);
            tempCell.setCellValue("节点预警");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(5);
            tempCell.setCellValue("环境检测");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(6);
            tempCell.setCellValue("项目预警");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(7);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(8);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(9);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 6, 9));//单元格合并

            tempCell = tempRow.createCell(10);
            tempCell.setCellValue("安责险");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(11);
            tempCell.setCellValue("一切险");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(12);
            tempCell.setCellValue("安全隐患排查");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(13);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(14);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 12, 14));//单元格合并

            tempCell = tempRow.createCell(15);
            tempCell.setCellValue("特种人员");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(16);
            tempCell.setCellValue("应急演练");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(17);
            tempCell.setCellValue("教育培训");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(18);
            tempCell.setCellValue("质量隐患排查");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(19);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(20);
            tempCell.setCellValue("");
            tempCell.setCellStyle(headerStyle);

            sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 18, 20));//单元格合并

            tempCell = tempRow.createCell(21);
            tempCell.setCellValue("材料取样复试");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(22);
            tempCell.setCellValue("材料封样");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(23);
            tempCell.setCellValue("实测实量");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(24);
            tempCell.setCellValue("举牌验收");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(25);
            tempCell.setCellValue("视频监控");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(26);
            tempCell.setCellValue("AI监控");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(27);
            tempCell.setCellValue("项目全景");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(28);
            tempCell.setCellValue("项目标准化");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(29);
            tempCell.setCellValue("审批进行中");
            tempCell.setCellStyle(headerStyle);

            tempCell = tempRow.createCell(30);
            tempCell.setCellValue("审批已完成");
            tempCell.setCellStyle(headerStyle);

            List<String> headArrays = new ArrayList<>();
            headArrays.add("");
            headArrays.add("");
            headArrays.add("劳务人员");
            headArrays.add("实名制接入");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("AI预警");
            headArrays.add("安全预警");
            headArrays.add("质量预警");
            headArrays.add("环境预警");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("甲方经理");
            headArrays.add("监理单位");
            headArrays.add("总包单位");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("甲方经理");
            headArrays.add("监理单位");
            headArrays.add("总包单位");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");
            headArrays.add("");

            tempRow = sheet.createRow(rowNum++);
            tempRow.setHeight((short) 400);// 设置行高

            for (int i = 0; i < headArrays.size(); i++) {
                tempCell = tempRow.createCell(i);
                tempCell.setCellValue(headArrays.get(i));
                tempCell.setCellStyle(headerStyle);
                if(i<2){
                    sheet.addMergedRegion(new CellRangeAddress(rowNum-3, rowNum - 1, i, i));//单元格合并
                }
                if((i>3 && i<6) || (i>9 && i<12) || (i>14 && i<18) || i>20){
                    sheet.addMergedRegion(new CellRangeAddress(rowNum-2, rowNum - 1, i, i));//单元格合并
                }
            }

            Integer trindex = 0;
            for(int i=0;i<list.size();i++){

                ProjectViewExport view = list.get(i);
                tempRow = sheet.createRow(rowNum++);
                tempRow.setHeight((short) 500);// 设置行高
                tempCell = tempRow.createCell(0);
                tempCell.setCellValue(view.getProjectName());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(1);
                tempCell.setCellValue(view.getUnitName());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(2);
                tempCell.setCellValue(view.getLwry());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(3);
                tempCell.setCellValue(view.getLwsm().equals("0")?"未接入":"已接入");
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(4);
                tempCell.setCellValue(view.getJdyj()==null?"":(view.getJdyj().equals("1")?"正常":"滞后"));
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(5);
                tempCell.setCellValue(view.getHjjc().equals("0")?"未接入":"已接入");
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(6);
                tempCell.setCellValue(view.getAiyjs());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(7);
                tempCell.setCellValue(view.getAqyjs());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(8);
                tempCell.setCellValue(view.getZlyjs());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(9);
                tempCell.setCellValue(view.getHjyjs());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(10);
                tempCell.setCellValue(view.getAzx().equals("0")?"未办理":"已办理");
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(11);
                tempCell.setCellValue(view.getYqx().equals("0")?"未办理":"已办理");
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(12);
                tempCell.setCellValue(view.getAqyhpc_jfdb());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(13);
                tempCell.setCellValue(view.getAqyhpc_jldw());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(14);
                tempCell.setCellValue(view.getAqyhpc_zbdw());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(15);
                tempCell.setCellValue(view.getTzry());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(16);
                tempCell.setCellValue(view.getYjyl());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(17);
                tempCell.setCellValue(view.getZxpx());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(18);
                tempCell.setCellValue(view.getZlyhpc_jfdb());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(19);
                tempCell.setCellValue(view.getZlyhpc_jldw());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(20);
                tempCell.setCellValue(view.getZlyhpc_zbdw());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(21);
                tempCell.setCellValue(view.getClqyfs());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(22);
                tempCell.setCellValue(view.getClfy());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(23);
                tempCell.setCellValue(view.getCscl());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(24);
                tempCell.setCellValue(view.getJpys());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(25);
                tempCell.setCellValue(view.getSsjk().equals("0")?"未接入":"已接入");
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(26);
                tempCell.setCellValue(view.getAijk().equals("0")?"未接入":"已接入");
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(27);
                tempCell.setCellValue(view.getYssys());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(28);
                tempCell.setCellValue(view.getBzh());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(29);
                tempCell.setCellValue(view.getGcsq());
                tempCell.setCellStyle(contentStyle);

                tempCell = tempRow.createCell(30);
                tempCell.setCellValue(view.getGcsp());
                tempCell.setCellStyle(contentStyle);

                if(i==list.size()-1 || !view.getProjectId().equals(list.get(i+1).getProjectId())){
                    if(trindex>0){
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 0, 0));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 4, 4));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 7, 7));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 8, 8));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 12, 12));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 13, 13));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 18, 18));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 19, 19));//单元格合并
                        sheet.addMergedRegion(new CellRangeAddress(rowNum-(1+trindex), rowNum - 1, 27, 27));//单元格合并
                    }
                    trindex=0;
                }else{
                    trindex++;
                }
            }

            try {
                outputStream =new BufferedOutputStream(response.getOutputStream());
                wb.write(outputStream);
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                outputStream.flush();
                outputStream.close();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * 监理单位项目数据汇总
     */
    @PreAuthorize("@ss.hasPermi('statistics:project:list')")
    @GetMapping("/selectStatisticsJlProjectList")
    public TableDataInfo selectStatisticsJlProjectList(SurProject surProject)
    {
        surProject.setNowRole(Convert.toStr(getUserFirstRole()));
        if(SysRoleEnum.ZGS.getCode().equals(surProject.getNowRole())){
            surProject.setDeptId(sysDeptService.getZGSDeptId(getDeptId()));
        }
        List<ProjectViewJlExport> list = projectViewService.selectStatisticsJlProjectList(surProject);
        return getDataTable(list);
    }

    /**
     * 监理单位项目数据汇总
     */
    @PreAuthorize("@ss.hasPermi('statistics:project:export')")
    @Log(title = "监理数据汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/exportviewJl")
    public void exportviewJl(HttpServletResponse response, SurProject surProject)
    {
        surProject.setNowRole(Convert.toStr(getUserFirstRole()));
        if(SysRoleEnum.ZGS.getCode().equals(surProject.getNowRole())){
            surProject.setDeptId(sysDeptService.getZGSDeptId(getDeptId()));
        }
        List<ProjectViewJlExport> list = projectViewService.selectStatisticsJlProjectList(surProject);
        ExcelUtil<ProjectViewJlExport> util = new ExcelUtil<ProjectViewJlExport>(ProjectViewJlExport.class);
        util.exportExcel(response, list, "监理数据汇总");
    }

}
