package com.casic.missiles.modular.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.casic.missiles.core.application.context.AbstractPermissionContext;
import com.casic.missiles.core.base.controller.BaseController;
import com.casic.missiles.core.common.annotion.BussinessLog;
import com.casic.missiles.core.datascope.DataScope;
import com.casic.missiles.core.page.PageFactory;
import com.casic.missiles.model.response.ResponseData;
import com.casic.missiles.model.response.SuccessResponseData;
import com.casic.missiles.modular.system.dict.BusConfigDict;
import com.casic.missiles.modular.system.dto.BusConfigDTO;
import com.casic.missiles.modular.system.dto.DeviceTypeEnum;
import com.casic.missiles.modular.system.service.IBusConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * 控制器
 *
 * @author dev
 * @Date 2019-05-16 15:55:07
 */
@Controller
@RequestMapping("/busConfig")
public class BusConfigController extends BaseController {


    @Qualifier("busConfigServiceImpl")
    @Autowired
    private IBusConfigService busConfigService;

    @Qualifier("busMethaneConfigServiceImpl")
    @Autowired
    private IBusConfigService busMethaneConfigService;

    @Qualifier("busTubeConfigServiceImpl")
    @Autowired
    private IBusConfigService busTubeConfigService;

    @Qualifier("busWasteGasConfigServiceImpl")
    @Autowired
    private IBusConfigService busWasteGasConfigService;

    @Qualifier("busTempHumiConfigServiceImpl")
    @Autowired
    private IBusConfigService busTempHumiConfigService;


    @Qualifier("busDigConfigServiceImpl")
    @Autowired
    private IBusConfigService busDigConfigService;

    @Qualifier("busNoiseConfigServiceImpl")
    @Autowired
    private IBusConfigService busNoiseConfigService;

    @Qualifier("busGasLiquidConfigServiceImpl")
    @Autowired
    private IBusConfigService busGasLiquidConfigService;

    @Resource
    private AbstractPermissionContext service;

    /**
     * 液位获取配置列表
     */
    @RequestMapping(value = "/liquidConfig/list")
    @ResponseBody
    public Object liquidConfigList(@RequestParam(required = false) String keywords,
                                   @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Liquid.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }

    /**
     * 有害获取配置列表
     */
    @RequestMapping(value = "/harmfulConfig/list")
    @ResponseBody
    public Object wasteGasConfigList(@RequestParam(required = false) String keywords,
                                     @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busWasteGasConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.WasteGas.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }

    /**
     * 燃气获取配置列表
     */
    @RequestMapping(value = "/gasConfig/list")
    @ResponseBody
    public Object methaneConfigList(@RequestParam(required = false) String keywords,
                                    @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busMethaneConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Methane.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }


    /**
     * 燃气获取配置列表
     */
    @RequestMapping(value = "/tubeConfig/list")
    @ResponseBody
    public Object tubeConfigList(@RequestParam(required = false) String keywords,
                                 @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busTubeConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Tube.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }

    /**
     * 温湿度获取配置列表
     */
    @RequestMapping(value = "/tempConfig/list")
    @ResponseBody
    public Object tempHumiConfigList(@RequestParam(required = false) String keywords,
                                     @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busTempHumiConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.TempHumi.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }

    /**
     * 开挖获取配置列表
     */
    @RequestMapping(value = "/digConfig/list")
    @ResponseBody
    public Object digConfigList(@RequestParam(required = false) String keywords,
                                @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busDigConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Dig.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }

    /**
     * 噪声获取配置列表
     */
    @RequestMapping(value = "/noiseConfig/list")
    @ResponseBody
    public Object noiseConfigList(@RequestParam(required = false) String keywords,
                                  @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busNoiseConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Noise.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }

    /**
     * 液位新增配置
     */
    @RequestMapping(value = "/liquidConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增配置", key = "deviceId,percent,installHeight,retryTimes," +
            "attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addLiquid(BusConfigDTO busConfigDTO) {
        try {
            busConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }

    /**
     * 新增燃气配置
     */
    @RequestMapping(value = "/gasConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增燃气配置", key = "deviceId,uploadPeriod,collectInterval,retryTimes,attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addMethane(BusConfigDTO busConfigDTO) {
        try {
            busMethaneConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }


    /**
     * 新增管盯配置
     */
    @RequestMapping(value = "/tubeConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增管盯配置", key = "deviceId,uploadPeriod,collectInterval,retryTimes,attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addTube(BusConfigDTO busConfigDTO) {
        try {
            busTubeConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }

    /**
     * 新增有害配置
     */
    @RequestMapping(value = "/harmfulConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增有害配置", key = "deviceId,uploadPeriod,attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addWasteGas(BusConfigDTO busConfigDTO) {
        try {
            busWasteGasConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }

    /**
     * 新增温湿度配置
     */
    @RequestMapping(value = "/tempConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增温湿度配置", key = "deviceId,collectInterval,collectTime,collectCount,retryTimes,attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addTempHumi(BusConfigDTO busConfigDTO) {
        try {
            busTempHumiConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }

    /**
     * 新增开挖配置
     */
    @RequestMapping(value = "/digConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增开挖配置", key = "deviceId,uploadPeriod,collectInterval,retryTimes,sleepStartTime,threshold,attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addDig(BusConfigDTO busConfigDTO) {
        try {
            busDigConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }


    /**
     * 新增噪声配置
     */
    @RequestMapping(value = "/noiseConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增噪声配置", key = "deviceId,collectTime,collectInterval,collectCount,retryTimes,attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addDNoise(BusConfigDTO busConfigDTO) {
        try {
            busNoiseConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{busConfigId}")
    @ResponseBody
    public Object detail(@PathVariable("busConfigId") String busConfigId) {
        SuccessResponseData resultData = new SuccessResponseData();
        resultData.setCode(200);
        resultData.setMessage("查询详情成功");
        resultData.setData(busConfigService.getById(busConfigId));
        return resultData;
    }


    /****
     * 液位配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/liquidConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadLiquidConfig(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busConfigService.imp(uploadFile);
        return resultData;
    }

    /****
     * 燃气配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/gasConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadMethaneConfig(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busMethaneConfigService.imp(uploadFile);
        return resultData;
    }

    /****
     * 管盯配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/tubeConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadTubeConfig(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busTubeConfigService.imp(uploadFile);
        return resultData;
    }


    /****
     * 有害配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/harmfulConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadWasteGas(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busWasteGasConfigService.imp(uploadFile);
        return resultData;
    }


    /****
     * 温湿度配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/tempConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadTempHumi(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busTempHumiConfigService.imp(uploadFile);
        return resultData;
    }

    /****
     * 开挖配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/digConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadDig(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busNoiseConfigService.imp(uploadFile);
        return resultData;
    }

    /****
     * 噪声配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/noiseConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object uploadNoise(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busNoiseConfigService.imp(uploadFile);
        return resultData;
    }

    /***
     * 液位配置导出
     * @param keywords
     * @param deptid
     * @param response
     */
//    @ApiOperation("液位配置列表导出")
    @RequestMapping(value = "/liquidConfig/batchExport")
    @ResponseBody
    public void export(@RequestParam(required = false) String keywords,
                       @RequestParam(required = false) String deptid,
                       HttpServletResponse response) {
        try {
            //page使用
            Page<BusConfigDTO> page = PageFactory.defaultPage();
            page.setCurrent(1);
            page.setSearchCount(false);
            page.setSize(Integer.MAX_VALUE);
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Liquid.getIndex()), dataScope);
            busConfigService.exp(busConfigDTOList, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***
     * 有害配置导出
     * @param keywords
     * @param deptid
     * @param response
     */
//    @ApiOperation("有害配置列表导出")
    @RequestMapping(value = "/harmfulConfig/batchExport")
    @ResponseBody
    public void exportHarmful(@RequestParam(required = false) String keywords,
                              @RequestParam(required = false) String deptid,
                              HttpServletResponse response) {
        try {
            //page使用
            Page<BusConfigDTO> page = PageFactory.defaultPage();
            page.setCurrent(1);
            page.setSearchCount(false);
            page.setSize(Integer.MAX_VALUE);
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busWasteGasConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.WasteGas.getIndex()), dataScope);
            busWasteGasConfigService.exp(busConfigDTOList, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***
     * 燃气配置导出
     * @param keywords
     * @param deptid
     * @param response
     */
//    @ApiOperation("燃气配置列表导出")
    @RequestMapping(value = "/gasConfig/batchExport")
    @ResponseBody
    public void exportGas(@RequestParam(required = false) String keywords,
                          @RequestParam(required = false) String deptid,
                          HttpServletResponse response) {
        try {
            //page使用
            Page<BusConfigDTO> page = PageFactory.defaultPage();
            page.setCurrent(1);
            page.setSearchCount(false);
            page.setSize(Integer.MAX_VALUE);
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busMethaneConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Methane.getIndex()), dataScope);
            busMethaneConfigService.exp(busConfigDTOList, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***
     * 温湿度配置导出
     * @param keywords
     * @param deptid
     * @param response
     */
    @RequestMapping(value = "/tempConfig/batchExport")
    @ResponseBody
    public void exportTemp(@RequestParam(required = false) String keywords,
                           @RequestParam(required = false) String deptid,
                           HttpServletResponse response) {
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();
            page.setCurrent(1);
            page.setSearchCount(false);
            page.setSize(Integer.MAX_VALUE);
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busTempHumiConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.TempHumi.getIndex()), dataScope);
            busTempHumiConfigService.exp(busConfigDTOList, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***
     * 开挖配置导出
     * @param keywords
     * @param deptid
     * @param response
     */
    @RequestMapping(value = "/digConfig/batchExport")
    @ResponseBody
    public void exportDig(@RequestParam(required = false) String keywords,
                          @RequestParam(required = false) String deptid,
                          HttpServletResponse response) {
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();
            page.setCurrent(1);
            page.setSearchCount(false);
            page.setSize(Integer.MAX_VALUE);
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busDigConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Dig.getIndex()), dataScope);
            busDigConfigService.exp(busConfigDTOList, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***
     * 噪声配置导出
     * @param keywords
     * @param deptid
     * @param response
     */
    @RequestMapping(value = "/noiseConfig/batchExport")
    @ResponseBody
    public void exportNoise(@RequestParam(required = false) String keywords,
                            @RequestParam(required = false) String deptid,
                            HttpServletResponse response) {
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();
            page.setCurrent(1);
            page.setSearchCount(false);
            page.setSize(Integer.MAX_VALUE);
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busNoiseConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.Noise.getIndex()), dataScope);
            busNoiseConfigService.exp(busConfigDTOList, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 燃气液位一体化获取配置列表
     */
    @RequestMapping(value = "/liquidGasConfig/list")
    @ResponseBody
    public Object liquidGasConfigList(@RequestParam(required = false) String keywords,
                                      @RequestParam(required = false) String deptid) {
        SuccessResponseData successResult = new SuccessResponseData();
        try {
            Page<BusConfigDTO> page = PageFactory.defaultPage();//page使用
            DataScope dataScope = service.getAuthService().getLoginUserDataScope();
            List<BusConfigDTO> busConfigDTOList = busGasLiquidConfigService.getConfigList(page, keywords,
                    deptid, Long.valueOf(DeviceTypeEnum.LG.getIndex()), dataScope);
            page.setRecords(busConfigDTOList);
            successResult.setData(super.packForBT(page));
            successResult.setMessage("success");
        } catch (Exception e) {
            e.printStackTrace();
            successResult.setCode(500);
            successResult.setMessage("false");
        }
        return successResult;
    }


    /**
     * 新增燃气液位一体化配置
     */
    @RequestMapping(value = "/liquidGasConfig/config")
    @ResponseBody
    @BussinessLog(value = "新增燃气液位一体化配置", key = "deviceId,uploadPeriod,collectInterval,retryTimes,attemptsMax,ip,port", dict = BusConfigDict.class)
    public Object addGasLiquid(BusConfigDTO busConfigDTO) {
        try {
            busGasLiquidConfigService.addConfig(busConfigDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.error(ResponseData.DEFAULT_ERROR_CODE, "配置失败");
        }
        return ResponseData.success();
    }

    /****
     * 燃气液位配置批量导入
     * @param uploadFile
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/gasLiquidConfig/batchImport", method = RequestMethod.POST)
    @ResponseBody
    public Object gasLiuqidConfig(@RequestParam("file") MultipartFile uploadFile) throws Exception {
        SuccessResponseData resultData = new SuccessResponseData();
        if (null == uploadFile) {
            resultData.setCode(400);
            resultData.setMessage("上传失败，无法找到文件！");
            return resultData;
        }
        resultData = busGasLiquidConfigService.imp(uploadFile);
        return resultData;
    }
}
