package com.bonus.sgzb.app.controller;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.PhoneUtil;
import com.bonus.sgzb.app.domain.*;
import com.bonus.sgzb.app.service.LeaseApplyDetailsService;
import com.bonus.sgzb.app.service.LeaseApplyInfoService;
import com.bonus.sgzb.app.service.LeaseUserBookService;
import com.bonus.sgzb.app.service.TmTaskService;
import com.bonus.sgzb.base.service.ITypeService;
import com.bonus.sgzb.common.core.utils.ListPagingUtil;
import com.bonus.sgzb.common.core.utils.ServletUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

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

import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_NUM;
import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE;

/**
 * 任务表(tm_task)表控制层
 *
 * @author 阮世耀
 */
@RestController
@RequestMapping("/base/tm_task")
public class TmTaskController extends BaseController {

    /**
     * 任务表Service
     */
    @Resource
    private TmTaskService tmTaskService;

    /**
     * 领料申请信息表service
     */
    @Resource
    private LeaseApplyInfoService leaseApplyInfoService;

    @Resource
    private LeaseApplyDetailsService leaseApplyDetailsService;

    @Autowired
    private LeaseUserBookService leaseUserBookService;

    @Resource
    private ITypeService iTypeService;


    /**
     * 领料审核通过，分公司，分管，机具分公司统一接口
     *
     * @param task 审核信息
     * @return 结果
     */
    @Log(title = "宁夏领料审核通过", businessType = BusinessType.UPDATE)
    @PostMapping("auditLeaseByCompany")
    public AjaxResult auditLeaseByCompany(@RequestBody TmTask task) {
        return toAjax(tmTaskService.updateLeaseTaskAuditInfo(task));
    }

    /**
     * 领料审核通过，分公司，分管，机具分公司统一接口
     *
     * @param task 审核信息
     * @return 结果
     */
    @Log(title = "重庆领料审核通过", businessType = BusinessType.UPDATE)
    @PostMapping("auditLeaseByCompanyCq")
    public AjaxResult auditLeaseByCompanyCq(@RequestBody TmTask task) {
        return toAjax(tmTaskService.updateLeaseTaskAuditInfoCq(task));
    }

    @Log(title = "重庆领料确认通过接口", businessType = BusinessType.UPDATE)
    @PostMapping("updateLeaseTaskStatusConfirmByCq")
    public AjaxResult updateLeaseTaskStatusConfirmByCq(@RequestBody TmTask tmTask) {
        return toAjax(tmTaskService.updateLeaseTaskStatusConfirmByCq(tmTask));
    }

    /**
     * 领料审核驳回，分公司，分管，机具分公司统一接口
     *
     * @param task 任务信息
     * @return
     */
    @Log(title = "宁夏领料审核驳回", businessType = BusinessType.UPDATE)
    @PostMapping("rejectLeaseByCompany")
    public AjaxResult rejectLeaseByCompany(@RequestBody TmTask task) {
        return toAjax(tmTaskService.updateLeaseTaskRejectInfo(task));
    }

    /**
     * 领料审核驳回，分公司，分管，机具分公司统一接口
     *
     * @param task 任务信息表
     * @return 结果
     */
    @Log(title = "重庆领料审核驳回", businessType = BusinessType.UPDATE)
    @PostMapping("rejectLeaseByCompanyCq")
    public AjaxResult rejectLeaseByCompanyCq(@RequestBody TmTask task) {
        return toAjax(tmTaskService.updateLeaseTaskRejectInfoCq(task));
    }

    /**
     * 根据任务id删除任务表及任务信息
     */
    @Log(title = "删除任务", businessType = BusinessType.DELETE)
    @DeleteMapping("/{taskId}")
    public AjaxResult deleteTaskInfoByTaskId(@PathVariable String taskId) {
        if (StringUtils.isEmpty(taskId)) {
            return AjaxResult.error("参数错误，删除失败!");
        }
        return tmTaskService.deleteByPrimaryKey(taskId);
    }

    /**
     * 根据id删除领料明细表
     */
    @Log(title = "删除领料任务明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/deleteDetailsByTaskId/{id}")
    public AjaxResult deleteDetailsByTaskId(@PathVariable String id) {
        if (StringUtils.isEmpty(id)) {
            return AjaxResult.error("参数错误，删除失败!");
        }
        return toAjax(tmTaskService.deleteDetailsByTaskId(id));
    }


    /**
     * 创建领料申请任务 --- New 审批流
     */
    @Log(title = "创建领料申请任务", businessType = BusinessType.INSERT)
    @PostMapping("createFlowLeaseApply")
    public AjaxResult createFlowLeaseApply(@RequestBody TmTask task) {
        // ------参数校验---------
        if (StringUtils.isNull(task) || StringUtils.isNull(task.getCompanyId())) {
            return AjaxResult.error("参数错误,请求参数为空或申请人组织ID为空，请重试");
        }
        if (StringUtils.isNull(task.getLeaseApplyInfo())) {
            return AjaxResult.error("领料任务信息为空，请重试");
        }
        if (CollUtil.isEmpty(task.getLeaseApplyDetails())) {
            return AjaxResult.error("领料设备明细为空，请重新选择后上传!");
        }
        // ------校验结束--执行service-------
        return tmTaskService.createFlowLeaseApply(task);
    }

    /**
     * 往来单位提交工程领用机具信息
     *
     * @return 结果
     */
    @Log(title = "往来单位提交领料申请", businessType = BusinessType.INSERT)
    @PostMapping("submitLeaseApply")
    @Transactional
    public AjaxResult submitLeaseApply(@RequestBody TmTask task) {
        if (StringUtils.isNull(task)) {
            return AjaxResult.error("参数错误");
        }
        if (StringUtils.isNotBlank(task.getLeaseApplyInfo().getPhone())) {
            String phone = task.getLeaseApplyInfo().getPhone();
            if (!PhoneUtil.isMobile(phone)) {
                logger.error("手机号格式错误 :{}", phone);
                return AjaxResult.error("手机号格式错误");
            }
        }
        try {
            String code = tmTaskService.genderLeaseCode();
            if (StringUtils.isEmpty(code)) {
                return AjaxResult.error("后台生成CODE编号异常，请重试!");
            }
            task.setCode(code);
            // 创建任务
            boolean addTaskResult = tmTaskService.insertSelective(task) > 0;

            //任务与协议建立关联关系
            boolean i = tmTaskService.insertAgreement(task) > 0;

            if (addTaskResult && task.getLeaseApplyInfo() != null) {
                if (CollUtil.isEmpty(task.getLeaseApplyDetails())) {
                    return AjaxResult.error("领料设备明细为空，请重新选择后上传!");
                }
                if (StringUtils.isNull(task.getLeaseApplyInfo())) {
                    return AjaxResult.error("领料任务信息为空，请重新选择后上传!");
                }

                // 获取任务编号
                String taskId = task.getId();
                // 根据设备所属分公司拆分集合
                List<List<LeaseApplyDetails>> deviceByCompanyList = CollUtil.groupByField(task.getLeaseApplyDetails(), "companyId");

                // 对拆分后的集合进行each遍历
                for (List<LeaseApplyDetails> leaseApplyDetailsList : deviceByCompanyList) {
                    // 判断拆分后的集合内是否有数据
                    if (CollUtil.isNotEmpty(leaseApplyDetailsList)) {
                        // 对领料任务表的对象做数据处理
                        LeaseApplyInfo leaseApplyInfo = task.getLeaseApplyInfo();
                        leaseApplyInfo.setCode(code); // 创建领料单号
                        leaseApplyInfo.setTaskId(Integer.valueOf(taskId)); // 设置任务ID
                        leaseApplyInfo.setCompanyId(leaseApplyDetailsList.get(0).getCompanyId()); // 设置设备所属分公司,用于交给哪家审核
                        leaseApplyInfo.setType("2"); // 设置审批层级，先固定2层，后期根据接口传入Type区分来源设定
                        leaseApplyInfo.setLeaseType(task.getLeaseType());
                        leaseApplyInfo.setEstimateLeaseTime(task.getEstimateLeaseTime());
                        leaseApplyInfo.setCostBearingParty(task.getCostBearingParty());

                        // 创建领料任务，返回领料任务编号
                        boolean addLeaseTaskResult = leaseApplyInfoService.genderLeaseCode(leaseApplyInfo) > 0;
                        // 领料任务创建完成，进行领料任务明细插入
                        if (addLeaseTaskResult) {
                            // 领料任务编号
                            Integer leaseTaskId = leaseApplyInfo.getId();
                            ArrayList<Integer> ids = new ArrayList();
                            if (StringUtils.isNotNull(leaseTaskId)) {
                                for (LeaseApplyDetails leaseApplyDetails : leaseApplyDetailsList) {
                                    leaseApplyDetails.setParenntId(leaseTaskId); // 设置领料任务ID
                                    ids.add(leaseApplyDetails.getId());
                                }
                                // 插入领料任务明细
                                boolean addLeaseTaskDetailsResult = leaseApplyDetailsService.batchInsert(leaseApplyDetailsList) > 0;
                                if (addLeaseTaskDetailsResult) {
                                    System.out.println("领料任务创建成功");
                                    leaseUserBookService.batchDel(ids);
                                } else {
                                    logger.error("领料任务创建成功，但领料任务明细插入失败");
                                }
                            } else {
                                return AjaxResult.error("领料任务编号为空");
                            }
                        } else {
                            return AjaxResult.error("创建领料任务失败,或领料明细为空");
                        }
                    }
                }
                //修改库存
               /* List<LeaseApplyDetails> leaseApplyDetailsList = task.getLeaseApplyDetails();
                MaType maType = new MaType();
                for (LeaseApplyDetails leaseApplyDetails : leaseApplyDetailsList) {
                    maType.setTypeId(Long.valueOf(leaseApplyDetails.getTypeId()));
                    maType.setNum(BigDecimal.valueOf(leaseApplyDetails.getNum()-leaseApplyDetails.getPreNum()));
                    iTypeService.updateMaType(maType);
                }
*/
                if (StringUtils.isEmpty(taskId)) {
                    return AjaxResult.error("任务编号为空,创建失败");
                }
            } else {
                return AjaxResult.error("创建任务失败");
            }
            return AjaxResult.success("任务创建成功");
        } catch (Exception e) {
            return AjaxResult.error("创建任务失败," + e.getCause().toString() + "," + e.getMessage());
        }
    }


    /**
     * 机具分公司直接创建领料申请
     *
     * @param task 任务信息
     * @return 结果
     */
    @Log(title = "机具分公司创建领料申请", businessType = BusinessType.INSERT)
    @PostMapping("directLeaseApply")
    public AjaxResult directLeaseApply(@RequestBody TmTask task) {
        if (StringUtils.isNull(task)) {
            return AjaxResult.error("参数错误");
        }
        try {
            String code = tmTaskService.genderLeaseCode();
            task.setCode(code);
            // 创建任务
            boolean addTaskResult = tmTaskService.insertSelective(task) > 0;
            if (addTaskResult && task.getLeaseApplyInfo() != null) {
                if (CollUtil.isNotEmpty(task.getLeaseApplyDetails())) {
                    return AjaxResult.error("领料设备明细为空，请重新选择后上传!");
                }
                if (StringUtils.isNull(task.getLeaseApplyInfo())) {
                    return AjaxResult.error("领料任务信息为空，请重新选择后上传!");
                }

                // 获取任务编号
                String taskId = task.getId();
                // 根据设备所属分公司拆分集合
                // List<List<LeaseApplyDetails>> deviceByCompanyList = CollUtil.group(task.getLeaseApplyDetails(), LeaseApplyDetails::getCompanyId);
                List<List<LeaseApplyDetails>> deviceByCompanyList = CollUtil.groupByField(task.getLeaseApplyDetails(), "companyId");

                // 对拆分后的集合进行遍历
                for (List<LeaseApplyDetails> leaseApplyDetailsList : deviceByCompanyList) {
                    // 判断拆分后的集合内是否有数据
                    if (CollUtil.isNotEmpty(leaseApplyDetailsList)) {
                        // 对领料任务表的对象做数据处理
                        LeaseApplyInfo leaseApplyInfo = task.getLeaseApplyInfo();
                        leaseApplyInfo.setCode(code); // 创建领料单号
                        leaseApplyInfo.setTaskId(Integer.valueOf(taskId)); // 设置任务ID
                        leaseApplyInfo.setCompanyId(leaseApplyDetailsList.get(0).getCompanyId()); // 设置设备所属分公司,用于交给哪家审核
                        leaseApplyInfo.setType("1"); // 设置审批层级，先固定2层，后期根据接口传入Type区分来源设定

                        // 创建领料任务，返回领料任务编号
                        boolean addLeaseTaskResult = leaseApplyInfoService.genderLeaseCode(leaseApplyInfo) > 0;
                        // 领料任务创建完成，进行领料任务明细插入
                        if (addLeaseTaskResult) {
                            // 领料任务编号
                            Integer leaseTaskId = leaseApplyInfo.getId();
                            if (StringUtils.isNotNull(leaseTaskId)) {
                                // 插入领料任务明细
                                boolean addLeaseTaskDetailsResult = leaseApplyDetailsService.batchInsert(leaseApplyDetailsList) > 0;
                                if (addLeaseTaskDetailsResult) {
                                    System.out.println("领料任务创建成功");
                                } else {
                                    System.out.println("领料任务创建成功，但领料任务明细插入失败");
                                }
                            }
                        } else {
                            return AjaxResult.error("创建领料任务失败,或领料明细为空");
                        }
                    }
                }
                if (StringUtils.isEmpty(taskId)) {
                    return AjaxResult.error("任务编号为空,创建失败");
                }
            } else {
                return AjaxResult.error("创建任务失败");
            }
            return AjaxResult.success("任务创建成功,已完成");
        } catch (Exception e) {
            return AjaxResult.error("创建任务失败," + e.getMessage());
        }
    }


    /**
     * 查询机具领料申请列表（个人）
     *
     * @param task    筛选条件
     * @param souceBy app为1   web为0
     * @return 列表
     */
    @Log(title = "查询机具领料申请列表", businessType = BusinessType.QUERY)
    @GetMapping(value = "getLeaseAuditListAll")
    public AjaxResult getLeaseAuditListAll(TmTask task, Integer souceBy) {
        if (StringUtils.isNull(task)) {
            return AjaxResult.error("参数错误");
        }
        List<TmTask> leaseAuditList;
        if (souceBy != null && souceBy == 1) {
            leaseAuditList = tmTaskService.getLeaseAuditList(task);
            return AjaxResult.success(leaseAuditList);
        } else {
            startPage();
            leaseAuditList = tmTaskService.getLeaseAuditList(task);
            return AjaxResult.success(getDataTable(leaseAuditList));
        }
    }

    /**
     * 查询机具领料管理列表
     *
     * @param task    筛选条件
     * @param souceBy app为1   web为0
     * @return 列表
     */
    @Log(title = "宁夏查询机具领料管理列表", businessType = BusinessType.QUERY)
    @GetMapping(value = "getLeaseManageListAll")
    public AjaxResult getLeaseManageListAll(TmTask task, Integer souceBy) {
        if (StringUtils.isNull(task)) {
            return AjaxResult.error("参数错误");
        }
        List<TmTask> leaseAuditList;
        if (souceBy != null && souceBy == 1) {
            leaseAuditList = tmTaskService.getLeaseAuditManageList(task);
            return AjaxResult.success(leaseAuditList);
        }
//        startPage();
        leaseAuditList = tmTaskService.getLeaseAuditManageList(task);
        Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
        return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, leaseAuditList));
    }

    /**
     * 查询机具领料管理列表
     *
     * @param task     筛选条件
     * @param sourceBy app为1   web为0
     * @return 列表
     */
    @Log(title = "重庆查询机具领料管理列表", businessType = BusinessType.QUERY)
    @GetMapping(value = "getLeaseManageListAllCq")
    public AjaxResult getLeaseManageListAllCq(TmTask task, Integer sourceBy) {
        if (StringUtils.isNull(task)) {
            return AjaxResult.error("参数错误");
        }
        List<TmTask> leaseAuditList;
        if (sourceBy != null && sourceBy == 1) {
            leaseAuditList = tmTaskService.getLeaseAuditManageListCq(task);
            return AjaxResult.success(leaseAuditList);
        }
//        startPage();
        leaseAuditList = tmTaskService.getLeaseAuditManageListCq(task);
        Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
        return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, leaseAuditList));
    }


    /**
     * 领料申请导出
     * 注意：备注字段到时要换
     */
    @ApiOperation("领料申请/管理导出")
    @Log(title = "领料申请/管理导出", businessType = BusinessType.EXPORT)
    @PostMapping("/applyExport")
    public void applyExport(HttpServletResponse response, TmTask task) {
        List<TmTask> leaseAuditList = new ArrayList<>();
        // 领料申请导出
        if (task.getTypes() == 1) {
            leaseAuditList = tmTaskService.getLeaseAuditList(task);
            ExcelUtil<TmTask> util = new ExcelUtil<TmTask>(TmTask.class);
            util.exportExcel(response, leaseAuditList, "领料申请数据");
        } else {
            //领料管理导出
            List<TmTask> leaseAuditManageList = tmTaskService.getLeaseAuditManageList(task);
            List<TmTaskVo> tmTaskDtos = Convert.toList(TmTaskVo.class, leaseAuditManageList);
            ExcelUtil<TmTaskVo> util = new ExcelUtil<TmTaskVo>(TmTaskVo.class);
            util.exportExcel(response, tmTaskDtos, "领料管理数据");
        }
    }


    /**
     * 查询机具领料出库列表
     *
     * @param task 筛选条件
     * @return 列表
     */
    @Log(title = "查询机具领料出库列表- app/web", businessType = BusinessType.QUERY)
    @GetMapping(value = "getLeaseAuditList")
    public AjaxResult getLeaseAuditList(TmTask task) {
        if (StringUtils.isNull(task)) {
            return AjaxResult.error("参数错误");
        }
        if (SecurityUtils.getLoginUser() != null) {
            Long userid = SecurityUtils.getLoginUser().getUserid();
            task.setUserId(String.valueOf(userid));
        }
        if (task.getFlag() == 1) {
            startPage();
            List<TmTask> leaseAuditList = tmTaskService.getLeaseOutListByUser(task);
            return AjaxResult.success(getDataTable(leaseAuditList));
        } else {
            List<TmTask> leaseAuditList = tmTaskService.getLeaseOutListByUser(task);
            return AjaxResult.success(getDataTable(leaseAuditList));
        }
    }

    /**
     * 查询单个领料出库详情
     *
     * @param task 筛选条件
     * @return 列表
     */
    @Log(title = "查询单个领料出库详情- app/web", businessType = BusinessType.QUERY)
    @GetMapping(value = "getLeaseAuditListDetail")
    public AjaxResult getLeaseAuditListDetail(TmTask task) {
        if (StringUtils.isNull(task)) {
            return AjaxResult.error("参数错误");
        }
        if (SecurityUtils.getLoginUser() != null) {
            Long userid = SecurityUtils.getLoginUser().getSysUser().getUserId();
            task.setUserId(String.valueOf(userid));
        }
        // app端传1
        if (task.getSouceBy() == 1) {
            List<TmTask> leaseAuditList = tmTaskService.getLeaseAuditListByOne(task);
            return AjaxResult.success(leaseAuditList);
        } else {
            startPage();
            List<TmTask> leaseAuditList = tmTaskService.getLeaseAuditListByOne(task);
            return AjaxResult.success(getDataTable(leaseAuditList));
        }
    }

    /**
     * 导出领料出库列表
     *
     * @param task 筛选条件
     * @return 列表
     */
    @Log(title = "导出领料出库列表", businessType = BusinessType.QUERY)
    @PostMapping(value = "export")
    public void export(HttpServletResponse response, TmTask task) {

        if (SecurityUtils.getLoginUser() != null) {
            Long userid = SecurityUtils.getLoginUser().getUserid();
            task.setUserId(String.valueOf(userid));
        }

        List<TmTask> leaseAuditList = tmTaskService.getLeaseOutListByUser(task);
        List<TmTaskDto> tmTaskDtos = Convert.toList(TmTaskDto.class, leaseAuditList);
        ExcelUtil<TmTaskDto> util = new ExcelUtil<TmTaskDto>(TmTaskDto.class);
        util.exportExcel(response, tmTaskDtos, "领料出库数据");
    }

    /**
     * 宁夏修改任务信息
     */
    @Log(title = "宁夏修改任务信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody TmTask task) {
        try {
            if (StringUtils.isNull(task)) {
                return AjaxResult.error("参数错误,传入信息为空!");
            }
            tmTaskService.edit(task);
            return AjaxResult.success("修改成功");
        } catch (Exception e) {
            return AjaxResult.error("修改失败");
        }

    }

    /**
     * 重庆修改任务信息
     */
    @Log(title = "重庆修改任务信息", businessType = BusinessType.UPDATE)
    @PostMapping("/editCq")
    public AjaxResult editCq(@RequestBody TmTask task) {
        try {
            if (StringUtils.isNull(task)) {
                return AjaxResult.error("参数错误,传入信息为空!");
            }
            tmTaskService.editCq(task);
            return AjaxResult.success("修改成功");
        } catch (Exception e) {
            return AjaxResult.error("修改失败");
        }

    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TmTask selectOne(Integer id) {
        return tmTaskService.selectByPrimaryKey(Long.valueOf(id));
    }


    @Log(title = "宁夏获取领料管理-详情列表", businessType = BusinessType.QUERY)
    @GetMapping("/getLeaseListAll")
    public TableDataInfo getLeaseListAll(@RequestParam(value = "taskId", required = false, defaultValue = "") String taskId) {
        TmTask task = new TmTask();
        task.setTaskId(Long.parseLong(taskId));
        List<TmTask> leaseAuditList = tmTaskService.getLeaseListAll(task);
        return getDataTable(leaseAuditList);
    }

    @Log(title = "重庆获取领料管理-详情列表", businessType = BusinessType.QUERY)
    @GetMapping("/getLeaseListAllCq")
    public TableDataInfo getLeaseListAllCq(@RequestParam(value = "taskId", required = false, defaultValue = "") String taskId) {
        TmTask task = new TmTask();
        task.setTaskId(Long.parseLong(taskId));
        List<TmTask> leaseAuditList = tmTaskService.getLeaseListAllCq(task);
        return getDataTable(leaseAuditList);
    }

    @Log(title = "获取领料申请-查看/编辑列表", businessType = BusinessType.QUERY)
    @GetMapping("/getLeaseApplyListAll")
    public TableDataInfo getLeaseApplyListAll(@RequestParam(value = "taskId", required = false, defaultValue = "") String taskId) {
        TmTask task = new TmTask();
        task.setTaskId(Long.parseLong(taskId));
        task.setFlag(1);
        List<TmTask> leaseAuditList = tmTaskService.getLeaseApplyListAll(task);
        return getDataTable(leaseAuditList);
    }

    @Log(title = "获取领料申请-驳回提交数据", businessType = BusinessType.QUERY)
    @GetMapping("/getLeaseApplyAuditListAll")
    public TableDataInfo getLeaseApplyAuditListAll(@RequestParam(value = "taskId", required = false, defaultValue = "") String taskId) {
        TmTask task = new TmTask();
        task.setTaskId(Long.parseLong(taskId));
        task.setFlag(0);
        List<TmTask> leaseAuditList = tmTaskService.getLeaseApplyListAll(task);
        return getDataTable(leaseAuditList);
    }


}
