using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App.FormModule;
using OpenAuth.App.Request;
using OpenAuth.App.ServiceApp;
using OpenAuth.App.ServiceApp.DroneCaseInfo;
using OpenAuth.App.ServiceApp.DroneCaseInfo.Request;
using OpenAuth.App.ServiceApp.DroneCaseInfo.Response;
using OpenAuth.App.ServiceApp.Response;
using OpenAuth.Repository.Domain;

namespace OpenAuth.WebApi.Controllers.ServiceControllers
{
    /// <summary>
    /// 非粮化专题
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    class DroneCaseInfoFLHController : ControllerBase
    {
        readonly DroneCaseInfoFLHApp _app;

        public DroneCaseInfoFLHController(DroneCaseInfoFLHApp app)
        {
            _app = app;
        }

        /// <summary>
        /// 案件详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<DroneCaseInfoFLH>> GetCaseInfoById(string id)
        {
            var response = new Response<DroneCaseInfoFLH>();
            try
            {
                return await _app.GetCaseInfoById(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        /// <summary>
        /// 查询案件信息统计数据
        /// </summary>
        /// <param name="year">年份</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<dynamic>>> LoadDroneCaseInfoCount(int year)
        {
            return await _app.LoadDroneCaseInfoCount(year);
        }

        /// <summary>
        /// 接收办理
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadTasklList([FromQuery] TaskListReq req)
        {
            return await _app.LoadTaskList(req);
        }

        /// <summary>
        /// 查询待办任务统计数据 第一层接口 填报审核/整改审核
        /// </summary>
        /// <param name="year">年份</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<dynamic>>> LoadTaskCount(int year, string tubanlaiyuan, string picihao,
            int illegal)
        {
            return await _app.LoadTaskCount(year, tubanlaiyuan, picihao, illegal);
        }

        /// <summary>
        /// 查询任务列表数据（原审核监督第二层接口） 填报审核
        /// </summary>
        /// <param name="areaid">区域id</param>
        /// <param name="level">等级</param>
        /// <param name="year">年</param>
        /// <param name="is_build_complete">标注类型</param>
        /// <param name="geomid">图斑号</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadTaskDetailList([FromQuery] TaskDetailReq req)
        {
            return await _app.LoadTaskDetailList(req);
        }

        /// <summary>
        /// 整改审核
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadTaskIllegalDetailList([FromQuery] TaskDetailReq req)
        {
            return await _app.LoadTaskIllegalDetailList(req);
        }

        /// <summary>
        /// 图斑列表
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadCaseInfoTuBanList([FromQuery] CaseInfoTuBanReq req)
        {
            return await _app.LoadCaseInfoTuBanList(req);
        }


        [HttpGet]
        public async Task<Response<Dictionary<string, object>>> LoadCaseInfoTuBanListApp([FromQuery] CaseInfoTuBanReq req)
        {
            return await _app.LoadCaseInfoTuBanListApp(req);
        }

        /// <summary>
        /// 导出案件shp文件
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ExportCaseInfoShapefile([FromQuery] CaseInfoTuBanReq req)
        {
            try
            {
                string shpFilePath = Path.Combine(Path.GetTempPath(), $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.shp");
                string shpFilePathzip = Path.Combine(Path.GetTempPath(), $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.zip");
                _app.ExportCaseInfoShapefile(req, shpFilePath, shpFilePathzip);
                byte[] fileBytes = System.IO.File.ReadAllBytes(shpFilePathzip);
                return File(fileBytes, "application/octet-stream", $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.zip");
            }
            catch (Exception ex)
            {
                return StatusCode(500, $"Internal server error: {ex.Message}");
            }
        }

        /// <summary>
        /// 导出EXCLE
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ExportCaseInfoTuBanList([FromQuery] CaseInfoTuBanReq req)
        {
            var res = new Response();
            //获取列表数
            Response<List<CaseInfoTubanExport>> response = _app.ExprotLoadCaseInfoTuBanList(req);
            //获取模板数据
            List<ModuleColumn> headers = new List<ModuleColumn>();


            ModuleColumn m01 = new ModuleColumn();
            m01.key = "xuhao";
            m01.value = "序号";
            headers.Add(m01);
            ModuleColumn m1 = new ModuleColumn();
            m1.key = "tubanlaiyuan";
            m1.value = "图斑来源";
            headers.Add(m1);
            ModuleColumn m2 = new ModuleColumn();
            m2.key = "countyname";
            m2.value = "区县";
            headers.Add(m2);
            ModuleColumn m3 = new ModuleColumn();
            m3.key = "streetname";
            m3.value = "乡镇";
            headers.Add(m3);
            ModuleColumn m31 = new ModuleColumn();
            m31.key = "communityname";
            m31.value = "社区/村";
            headers.Add(m31);
            ModuleColumn m4 = new ModuleColumn();
            m4.key = "caseNo";
            m4.value = "图斑编号";
            headers.Add(m4);
            ModuleColumn m41 = new ModuleColumn();
            m41.key = "typename";
            m41.value = "图斑类型";
            headers.Add(m41);
            ModuleColumn m5 = new ModuleColumn();
            m5.key = "identificationTime";
            m5.value = "下发时间";
            headers.Add(m5);
            ModuleColumn m6 = new ModuleColumn();
            m6.key = "area";
            m6.value = "图斑面积";
            headers.Add(m6);

            ModuleColumn m64 = new ModuleColumn();
            m64.key = "nongyongdiarea";
            m64.value = "农用地面积";
            headers.Add(m64);
            ModuleColumn m7 = new ModuleColumn();
            m7.key = "gengdiArea";
            m7.value = "耕地面积";
            headers.Add(m7);
            ModuleColumn m71 = new ModuleColumn();
            m71.key = "yongjiujibennongtianarea";
            m71.value = "永农面积";
            headers.Add(m71);
            ModuleColumn m72 = new ModuleColumn();
            m72.key = "shengtaibaohuhongxianarea";
            m72.value = "生态保护红线面积";
            headers.Add(m72);

            ModuleColumn m8 = new ModuleColumn();
            m8.key = "isillegal";
            m8.value = "判定结果";
            headers.Add(m8);
            ModuleColumn m9 = new ModuleColumn();
            m9.key = "handleStatusName";
            m9.value = "当前状态";
            headers.Add(m9);
            ModuleColumn m111 = new ModuleColumn();
            m111.key = "jieshou_people";
            m111.value = "接收人";
            headers.Add(m111);
            ModuleColumn m121 = new ModuleColumn();
            m121.key = "jieshou_time";
            m121.value = "接收时间";
            headers.Add(m121);
            ModuleColumn m11 = new ModuleColumn();
            m11.key = "xiangmumc";
            m11.value = "项目名称";
            headers.Add(m11);
            ModuleColumn m12 = new ModuleColumn();
            m12.key = "xiangmuzhuti";
            m12.value = "项目主体";
            headers.Add(m12);
            ModuleColumn m13 = new ModuleColumn();
            m13.key = "actualUseTo";
            m13.value = "实际用途";
            headers.Add(m13);
            ModuleColumn m14 = new ModuleColumn();
            m14.key = "weifaleixing";
            m14.value = "违法类型";
            headers.Add(m14);
            ModuleColumn m221 = new ModuleColumn();
            m221.key = "pandingyijushuoming";
            m221.value = "现场情况";
            headers.Add(m221);
            ModuleColumn m131 = new ModuleColumn();
            m131.key = "examiner_name";
            m131.value = "填报人";
            headers.Add(m131);
            ModuleColumn m141 = new ModuleColumn();
            m141.key = "examine_time";
            m141.value = "填报时间";
            headers.Add(m141);
            ModuleColumn m10 = new ModuleColumn();
            m10.key = "measureName";
            m10.value = "整改措施";
            headers.Add(m10);
            ModuleColumn m15 = new ModuleColumn();
            m15.key = "transactor_name";
            m15.value = "办理人";
            headers.Add(m15);
            ModuleColumn m151 = new ModuleColumn();
            m151.key = "transact_time";
            m151.value = "办理时间";
            headers.Add(m151);
            ModuleColumn m23 = new ModuleColumn();
            m23.key = "xjshenhejieguo";
            m23.value = "县级审核结果";
            headers.Add(m23);
            ModuleColumn m24 = new ModuleColumn();
            m24.key = "xianjiyijian";
            m24.value = "县级审核意见";
            headers.Add(m24);
            ModuleColumn m25 = new ModuleColumn();
            m25.key = "verifyuser";
            m25.value = "县级审核人";
            headers.Add(m25);
            ModuleColumn m26 = new ModuleColumn();
            m26.key = "verifytime";
            m26.value = "县级审核时间";
            headers.Add(m26);
            ModuleColumn m27 = new ModuleColumn();
            m27.key = "sjshenhejieguo";
            m27.value = "市级审核结果";
            headers.Add(m27);
            ModuleColumn m28 = new ModuleColumn();
            m28.key = "shijiyijian";
            m28.value = "市级审核意见";
            headers.Add(m28);
            ModuleColumn m29 = new ModuleColumn();
            m29.key = "hexiaoren";
            m29.value = "市级审核人";
            headers.Add(m29);
            ModuleColumn m30 = new ModuleColumn();
            m30.key = "hexiaotime";
            m30.value = "市级审核时间";
            headers.Add(m30);
            ModuleColumn m301 = new ModuleColumn();
            m301.key = "case_description";
            m301.value = "图斑描述";
            headers.Add(m301);
            var excelRes = _app.ListToExcelTuban(response.Result, headers);
            if (excelRes.Code == 200)
            {
                return File(excelRes.Result.ToArray(),
                    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                    "数据导出" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
            }
            else
            {
                res.Code = excelRes.Code;
                res.Message = "导出失败";
            }

            return Ok(res);
        }

        /// <summary>
        /// 非粮化接收办理
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadFLHTaskList([FromQuery] TaskListReq req)
        {
            return await _app.LoadFLHTaskList(req);
        }


        [HttpGet]
        public async Task<Response<PageInfo<List<DroneCaseFavorite>>>> GetFavoriteList(int page = 1, int limit = 10)
        {
            return await _app.GetFavoriteList(page, limit);
        }
        
        /// <summary>
        /// 收藏
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> AddFLHTaskFavorite([FromBody] DroneTaskFavorite model)
        {
            Response<bool> response = new Response<bool>();
            try
            {
                response = await _app.AddTaskFavorite(model);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }


        [HttpPost]
        public async Task<Response<bool>> DeleteFLHTaskCase([FromBody] string id)
        {
            Response<bool> response = new Response<bool>();
            try
            {
                response = await _app.DeleteTaskFavoriteCase(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        [HttpPost]
        public Response<string> UpdateDroneCaseInfo(DronCaseSingleCityUpdateReq req)
        {
            Response<string> response = new Response<string>();
            try
            {
                _app.UpdateDroneCaseInfo(req);
                response.Result = "修改成功";
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        /// <summary>
        /// 案件分宗
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<string>> CaseSplit([FromBody] CaseSplitReq req)
        {
            return await _app.CaseSplit(req);
        }

        /// <summary>
        /// 案件还原合并
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<string>> CaseRecover([FromBody] CaseRecoverReq req)
        {
            Response<string> response = new Response<string>();
            try
            {
                return await _app.CaseRecover(req);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        [HttpGet]
        public async Task<Response<Dictionary<string, object>>> LoadMyUncompletedFLHTask(
            [FromQuery] TaskUncompletReq req)
        {
            return await _app.LoadMyUncompletedFLHTask(req);
        }

        #region 案件关闭--耕地非量化

        /// <summary>
        /// 案件关闭-耕地非粮化
        /// </summary>
        /// <param name="id">案件id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Response<bool>> CloseCaseInfoFLH(CloseCaseInfoReq req)
        {
            Response<bool> response = new Response<bool>();
            try
            {
                response = await _app.CloseCaseInfoFLH(req.id, req.closereason);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        #endregion

        /// <summary>
        /// 案件信息列表
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadCaseInfoCheckTuBanList(
            [FromQuery] CaseInfoTypeName req)
        {
            return await _app.LoadCaseInfoCheckTuBanList(req);
        }

        /// <summary>
        /// 案件详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<AddOrUpdateDroneCaseInfoReqExtCurrent>> GetCaseInfo(string id)
        {
            var response = new Response<AddOrUpdateDroneCaseInfoReqExtCurrent>();
            try
            {
                return await _app.GetCaseInfo(id);
            }
            catch (Exception ex)
            {
                response.Code = 500;
                response.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return response;
        }

        /// <summary>
        /// 填报审核/整改审核（新）
        /// </summary>
        /// <param name="year">年份</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<List<CaseInfoStatisticResp>>> LoadTaskCountV1(int year, string tubanlaiyuan,
            string picihao,
            int illegal)
        {
            return await _app.LoadTaskCountV1(year, tubanlaiyuan, picihao, illegal);
        }

        /// <summary>
        ///填报审核（新）
        /// </summary>
        /// <param name="areaid">区域id</param>
        /// <param name="level">等级</param>
        /// <param name="year">年</param>
        /// <param name="is_build_complete">标注类型</param>
        /// <param name="geomid">图斑号</param>
        /// <param name="tianbaoleixing">填报类型</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadTaskDetailListV1([FromQuery] TaskDetailReq req)
        {
            return await _app.LoadTaskDetailListV1(req);
        }

        /// <summary>
        /// 整改审核（新）
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadTaskIllegalDetailListV1([FromQuery] TaskDetailReq req)
        {
            return await _app.LoadTaskIllegalDetailListV1(req);
        }

        /// <summary>
        /// 图斑列表
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Response<PageInfo<List<dynamic>>>> LoadCaseInfoTuBanListV1([FromQuery] CaseInfoTuBanReq req)
        {
            return await _app.LoadCaseInfoTuBanListV1(req);
        }

        /// <summary>
        /// 导出案件shp文件
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ExportCaseInfoShapefileV1([FromQuery] CaseInfoTuBanReq req)
        {
            try
            {
                string shpFilePath = Path.Combine(Path.GetTempPath(), $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.shp");
                string shpFilePathzip = Path.Combine(Path.GetTempPath(), $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.zip");
                _app.ExportCaseInfoShapefileV1(req, shpFilePath, shpFilePathzip);
                byte[] fileBytes = System.IO.File.ReadAllBytes(shpFilePathzip);
                return File(fileBytes, "application/octet-stream", $"图斑信息{DateTime.Now:yyyyMMddHHmmss}.zip");
            }
            catch (Exception ex)
            {
                return StatusCode(500, $"Internal server error: {ex.Message}");
            }
        }


        /// <summary>
        /// 导出EXCLE
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ExportCaseInfoTuBanListV1([FromQuery] CaseInfoTuBanReq req)
        {
            var res = new Response();
            //获取列表数
            Response<List<CaseInfoTubanExport>> response = _app.ExportLoadCaseInfoTuBanListV1(req);
            //获取模板数据
            List<ModuleColumn> headers = new List<ModuleColumn>();
            ModuleColumn m01 = new ModuleColumn();
            m01.key = "xuhao";
            m01.value = "序号";
            headers.Add(m01);
            ModuleColumn m1 = new ModuleColumn();
            m1.key = "tubanlaiyuan";
            m1.value = "图斑来源";
            headers.Add(m1);
            ModuleColumn m2 = new ModuleColumn();
            m2.key = "countyname";
            m2.value = "区县";
            headers.Add(m2);
            ModuleColumn m3 = new ModuleColumn();
            m3.key = "streetname";
            m3.value = "乡镇";
            headers.Add(m3);
            ModuleColumn m31 = new ModuleColumn();
            m31.key = "communityname";
            m31.value = "社区/村";
            headers.Add(m31);
            ModuleColumn m4 = new ModuleColumn();
            m4.key = "caseNo";
            m4.value = "图斑编号";
            headers.Add(m4);
            ModuleColumn m41 = new ModuleColumn();
            m41.key = "typename";
            m41.value = "图斑类型";
            headers.Add(m41);

            ModuleColumn m301 = new ModuleColumn();
            m301.key = "case_description";
            m301.value = "图斑描述";
            headers.Add(m301);

            ModuleColumn m5 = new ModuleColumn();
            m5.key = "identificationTime";
            m5.value = "下发时间";
            headers.Add(m5);
            ModuleColumn m6 = new ModuleColumn();
            m6.key = "area";
            m6.value = "图斑面积";
            headers.Add(m6);

            ModuleColumn m64 = new ModuleColumn();
            m64.key = "nongyongdiarea";
            m64.value = "农用地面积";
            headers.Add(m64);
            ModuleColumn m7 = new ModuleColumn();
            m7.key = "gengdiArea";
            m7.value = "耕地面积";
            headers.Add(m7);
            ModuleColumn m71 = new ModuleColumn();
            m71.key = "yongjiujibennongtianarea";
            m71.value = "永农面积";
            headers.Add(m71);
            ModuleColumn m9 = new ModuleColumn();
            m9.key = "handleStatusName";
            m9.value = "当前状态";
            headers.Add(m9);
            ModuleColumn m111 = new ModuleColumn();
            m111.key = "jieshou_people";
            m111.value = "接收人";
            headers.Add(m111);
            ModuleColumn m121 = new ModuleColumn();
            m121.key = "jieshou_time";
            m121.value = "接收时间";

            ModuleColumn m302 = new ModuleColumn();
            m302.key = "fashengshijian";
            m302.value = "发生时间";
            headers.Add(m302);

            ModuleColumn m303 = new ModuleColumn();
            m303.key = "tianbaoleixingname";
            m303.value = "填报类型";
            headers.Add(m303);

            headers.Add(m121);
            ModuleColumn m221 = new ModuleColumn();
            m221.key = "pandingyijushuoming";
            m221.value = "现场情况";
            headers.Add(m221);
            ModuleColumn m131 = new ModuleColumn();
            m131.key = "examiner_name";
            m131.value = "填报人";
            headers.Add(m131);
            ModuleColumn m141 = new ModuleColumn();
            m141.key = "examine_time";
            m141.value = "填报时间";
            headers.Add(m141);

            ModuleColumn m23 = new ModuleColumn();
            m23.key = "xjshenhejieguo";
            m23.value = "县级审核结果";
            headers.Add(m23);
            ModuleColumn m24 = new ModuleColumn();
            m24.key = "xianjiyijian";
            m24.value = "县级审核意见";
            headers.Add(m24);
            ModuleColumn m25 = new ModuleColumn();
            m25.key = "verifyuser";
            m25.value = "县级审核人";
            headers.Add(m25);
            ModuleColumn m26 = new ModuleColumn();
            m26.key = "verifytime";
            m26.value = "县级审核时间";
            headers.Add(m26);
            ModuleColumn m27 = new ModuleColumn();
            m27.key = "sjshenhejieguo";
            m27.value = "市级审核结果";
            headers.Add(m27);
            ModuleColumn m28 = new ModuleColumn();
            m28.key = "shijiyijian";
            m28.value = "市级审核意见";
            headers.Add(m28);
            ModuleColumn m29 = new ModuleColumn();
            m29.key = "hexiaoren";
            m29.value = "市级审核人";
            headers.Add(m29);
            ModuleColumn m30 = new ModuleColumn();
            m30.key = "hexiaotime";
            m30.value = "市级审核时间";
            headers.Add(m30);

            ModuleColumn m10 = new ModuleColumn();
            m10.key = "measureName";
            m10.value = "整改措施";
            headers.Add(m10);
            ModuleColumn m15 = new ModuleColumn();
            m15.key = "transactor_name";
            m15.value = "办理人";
            headers.Add(m15);
            ModuleColumn m151 = new ModuleColumn();
            m151.key = "transact_time";
            m151.value = "办理时间";
            headers.Add(m151);
            
            //整改县级审核结果	整改县级审核意见	县级审核人	县级审核时间	整改市级审核结果	整改市级审核意见	市级审核人	市级审核时间
            //zg_xjshenhejieguo	zg_xianjiyijian	zg_xianjiren	zg_xjshenheshijian	zg_sjshenhejieguo	zg_shijiyijian	zg_shijiren	zg_sjshenheshijian
            ModuleColumn m152 = new ModuleColumn();
            m152.key = "zg_xjshenhejieguo";
            m152.value = "整改县级审核结果";
            headers.Add(m152);
            
            ModuleColumn m153 = new ModuleColumn();
            m153.key = "zg_xianjiyijian";
            m153.value = "整改县级审核意见";
            headers.Add(m153);
            
            ModuleColumn m154 = new ModuleColumn();
            m154.key = "zg_xianjiren";
            m154.value = "县级审核人";
            headers.Add(m154);
            
            
            ModuleColumn m155 = new ModuleColumn();
            m155.key = "zg_xjshenheshijian";
            m155.value = "县级审核时间";
            headers.Add(m155);
            
            ModuleColumn m156 = new ModuleColumn();
            m156.key = "zg_sjshenhejieguo";
            m156.value = "整改市级审核结果";
            headers.Add(m156);
            
            ModuleColumn m157 = new ModuleColumn();
            m157.key = "zg_shijiyijian";
            m157.value = "整改市级审核意见";
            headers.Add(m157);
            
            ModuleColumn m158 = new ModuleColumn();
            m158.key = "zg_shijiren";
            m158.value = "市级审核人";
            headers.Add(m158);
            
            ModuleColumn m159= new ModuleColumn();
            m159.key = "zg_sjshenheshijian";
            m159.value = "市级审核时间";
            headers.Add(m159);
            
            var excelRes = _app.ListToExcelTuban(response.Result, headers);
            if (excelRes.Code == 200)
            {
                return File(excelRes.Result.ToArray(),
                    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                    "数据导出" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
            }
            else
            {
                res.Code = excelRes.Code;
                res.Message = "导出失败";
            }

            return Ok(res);
        }
    }
}