package com.njcn.csdevice.controller.equipment;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.enums.DeviceOperate;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.csdevice.service.CsDevModelRelationService;
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
import com.njcn.csdevice.service.IMqttUserService;
import com.njcn.csdevice.utils.ExcelStyleUtil;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.poi.util.PoiUtil;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.web.advice.DeviceLog;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2023/3/27  15:31【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/EquipmentDelivery")
@Api(tags = " 出厂设备")
@AllArgsConstructor
public class EquipmentDeliveryController extends BaseController {
    private final CsEquipmentDeliveryService csEquipmentDeliveryService;
    private final IMqttUserService mqttUserService;
    private final CsDevModelRelationService csDevModelRelationService;
    private final DictTreeFeignClient dictTreeFeignClient;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addEquipmentDelivery")
    @ApiOperation("新增出厂设备")
    @ApiImplicitParam(name = "csEquipmentDeliveryAddParm", value = "新增项目参数", required = true)
    @DeviceLog(operateType = DeviceOperate.ADD)
    public HttpResult<CsEquipmentDeliveryPO> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
        String methodDescribe = getMethodDescribe("addEquipmentDelivery");
        CsEquipmentDeliveryPO po = csEquipmentDeliveryService.save(csEquipmentDeliveryAddParm);
        if (Objects.nonNull(po)) {
            //查询mqtt用户名和密码是否存在
            boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAddParm.getNdid());
            if (result) {
                //初始化装置mqtt连接信息(使用sha256加密)
                mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid());
            }
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/AuditEquipmentDelivery")
    @ApiOperation("删除出厂设备")
    @DeviceLog(operateType = DeviceOperate.DELETE)
    public HttpResult<Boolean> AuditEquipmentDelivery(@RequestParam("id") String id) {
        String methodDescribe = getMethodDescribe("AuditEquipmentDelivery");
        Boolean flag = csEquipmentDeliveryService.AuditEquipmentDelivery(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateEquipmentDelivery")
    @ApiOperation("修改出厂设备")
    @DeviceLog(operateType = DeviceOperate.UPDATE)
    @ApiImplicitParam(name = "csEquipmentDeliveryAuditParm", value = "新增项目参数", required = true)
    public HttpResult<Boolean> updateEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) {
        String methodDescribe = getMethodDescribe("updateEquipmentDelivery");
        Boolean flag = csEquipmentDeliveryService.updateEquipmentDelivery(csEquipmentDeliveryAuditParm);
        if (flag) {
            //查询mqtt用户名和密码是否存在
            boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAuditParm.getNdid());
            if (result) {
                //初始化装置mqtt连接信息(使用sha256加密)
                mqttUserService.insertMqttUser(csEquipmentDeliveryAuditParm.getNdid());
            }
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryEquipmentByndid")
    @ApiOperation("通过ndid查询出厂设备")
    @ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
    public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid") String ndid) {
        String methodDescribe = getMethodDescribe("queryEquipmentByndid");
        CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentByndid(ndid);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryVO, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryEquipmentByProject")
    @ApiOperation("通过项目查询出厂设备")
    @ApiImplicitParam(name = "projectEquipmentQueryParm", value = "项目信息", required = true)
    public HttpResult<IPage<ProjectEquipmentVO>> queryEquipmentByProject(@RequestBody ProjectEquipmentQueryParm projectEquipmentQueryParm) {
        String methodDescribe = getMethodDescribe("queryEquipmentByProject");
        IPage<ProjectEquipmentVO> projectEquipmentVos = csEquipmentDeliveryService.queryEquipmentByProject(projectEquipmentQueryParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, projectEquipmentVos, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateStatusBynDid")
    @ApiOperation("根据网关id调整设备接入状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nDId", value = "网关id", required = true),
            @ApiImplicitParam(name = "status", value = "状态", required = true)
    })
    @DeviceLog(operateType = DeviceOperate.UPDATESTATUSBYNDID)
    public HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid, @RequestParam("status") Integer status) {
        String methodDescribe = getMethodDescribe("updateStatusBynDid");
        csEquipmentDeliveryService.updateStatusBynDid(nDid, status);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryEquipmentById")
    @ApiOperation("设备查询通过id获取")
    @ApiImplicitParam(name = "ids", value = "设备id集合", required = true)
    public HttpResult<List<CsEquipmentDeliveryDTO>> queryEquipmentById(@RequestParam List<String> ids) {
        String methodDescribe = getMethodDescribe("queryEquipmentById");
        if (CollectionUtil.isEmpty(ids)) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        }
        List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(ids);
        List<CsEquipmentDeliveryDTO> collect = csEquipmentDeliveryPOS.stream().map(temp -> {
            CsEquipmentDeliveryDTO csEquipmentDeliveryDTO = new CsEquipmentDeliveryDTO();
            BeanUtils.copyProperties(temp, csEquipmentDeliveryDTO);
            String versionByDevId = csDevModelRelationService.getVersionByDevId(temp.getId());
            csEquipmentDeliveryDTO.setProgramVersionName(versionByDevId);
            return csEquipmentDeliveryDTO;
        }).collect(Collectors.toList());
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, collect, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/list")
    @ApiOperation("出厂设备列表")
    @ApiImplicitParam(name = "param", value = "查询参数", required = true)
    public HttpResult<Page<CsEquipmentDeliveryVO>> list(@RequestBody CsEquipmentDeliveryQueryParm param) {
        String methodDescribe = getMethodDescribe("list");
        Page<CsEquipmentDeliveryVO> page = csEquipmentDeliveryService.list(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/deviceData")
    @ApiOperation("装置基础数据和模板数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceId", value = "装置id", required = true),
            @ApiImplicitParam(name = "type", value = "类型", required = true),
            @ApiImplicitParam(name = "lineId", value = "监测点id", required = false)
    })
    public HttpResult<DeviceManagerVO> getDeviceData(@RequestParam String deviceId, @RequestParam String type, @RequestParam String lineId) {
        String methodDescribe = getMethodDescribe("getDeviceData");
        DeviceManagerVO vo = csEquipmentDeliveryService.getDeviceData(deviceId, type, lineId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateSoftInfoBynDid")
    @ApiOperation("根据网关id调整软件信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nDId", value = "网关id", required = true),
            @ApiImplicitParam(name = "id", value = "软件信息id", required = true),
            @ApiImplicitParam(name = "module", value = "模块个数", required = true)
    })
    @Deprecated
    public HttpResult<Boolean> updateSoftInfoBynDid(@RequestParam("nDId") String nDid, @RequestParam("id") String id, @RequestParam("module") Integer module) {
        String methodDescribe = getMethodDescribe("updateSoftInfoBynDid");
        csEquipmentDeliveryService.updateSoftInfoBynDid(nDid, id, module);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/findDevByNDid")
    @ApiOperation("通过nDid查询设备信息")
    @ApiImplicitParam(name = "nDid", value = "网关识别码", required = true)
    public HttpResult<CsEquipmentDeliveryPO> findDevByNDid(@RequestParam("nDid") String nDid) {
        String methodDescribe = getMethodDescribe("findDevByNDid");
        CsEquipmentDeliveryPO po = csEquipmentDeliveryService.findDevByNDid(nDid);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
    }

    @ResponseBody
    @ApiOperation("导出设备模板")
    @GetMapping(value = "getExcelTemplate")
    public HttpResult<String> getExcelTemplate(HttpServletResponse response) {
        String methodDescribe = getMethodDescribe("getExcelTemplate");
        ExportParams exportParams = new ExportParams("批量导入模板（请严格按照模板标准填入数据）", "终端入网检测录入信息");
        exportParams.setStyle(ExcelStyleUtil.class);
        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceExcelTemplete.class, new ArrayList<DeviceExcelTemplete>());
        List<SysDicTreePO> deviceType = dictTreeFeignClient.queryByCodeList(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData();
        if (!CollectionUtils.isEmpty(deviceType)) {
            List<String> collect = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getName).collect(Collectors.toList());
            ExcelUtil.selectList(workbook, 2, 2, collect.toArray(new String[]{}));
            List<String> collect2 = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getChildren).flatMap(Collection::stream).map(SysDicTreePO::getName).collect(Collectors.toList());
            ExcelUtil.selectList(workbook, 3, 3, collect2.toArray(new String[]{}));
        }
        ExcelUtil.selectList(workbook, 4, 4, Stream.of("MQTT", "CLD").collect(Collectors.toList()).toArray(new String[]{}));
        String fileName = "设备模板.xlsx";
        ExportParams exportExcel = new ExportParams("设备模板", "设备模板");
        PoiUtil.exportFileByWorkbook(workbook, fileName, response);
        return null;
    }

    @ResponseBody
    @ApiOperation("excel批量导入设备信息")
    @PostMapping(value = "importEquipment")
    public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
        String methodDescribe = getMethodDescribe("importEquipment");
        List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.importEquipment(file, response);
        if (!CollectionUtils.isEmpty(csEquipmentDeliveryPOS)) {
            csEquipmentDeliveryPOS.forEach(temp -> {
                //查询mqtt用户名和密码是否存在
                boolean result = mqttUserService.findMqttUser(temp.getNdid());
                if (result) {
                    //初始化装置mqtt连接信息(使用sha256加密)
                    mqttUserService.insertMqttUser(temp.getNdid());
                }
            });
        }
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @ResponseBody
    @ApiOperation("联调完成")
    @PostMapping(value = "testcompletion")
    public HttpResult<String> testCompletion(@RequestParam("deviceId") String deviceId, @RequestParam("type") Integer type, @RequestParam("remark") String remark) {
        String methodDescribe = getMethodDescribe("testCompletion");
        csEquipmentDeliveryService.testCompletion(deviceId, type, remark);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @ResponseBody
    @ApiOperation("取消联调")
    @PostMapping(value = "deleteTest")
    public HttpResult<String> deleteTest(@RequestParam("deviceId") String deviceId, @RequestParam("type") Integer type, @RequestParam("remark") String remark) {
        String methodDescribe = getMethodDescribe("deleteTest");
        csEquipmentDeliveryService.deleteTest(deviceId, type, remark);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateSoftInfo")
    @ApiOperation("更新设备软件信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nDid", value = "网络设备码", required = true),
            @ApiImplicitParam(name = "id", value = "软件信息id", required = true)
    })
    @ApiIgnore
    public HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid, @RequestParam("id") String id) {
        String methodDescribe = getMethodDescribe("updateSoftInfo");
        csEquipmentDeliveryService.updateSoftInfo(nDid, id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateModuleNumber")
    @ApiOperation("更新设备模块个数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nDid", value = "网络设备码", required = true),
            @ApiImplicitParam(name = "number", value = "模块个数", required = true)
    })
    @ApiIgnore
    public HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid, @RequestParam("number") Integer number) {
        String methodDescribe = getMethodDescribe("updateModuleNumber");
        csEquipmentDeliveryService.updateModuleNumber(nDid, number);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/rebootDevice")
    @ApiOperation("重启设备")
    @ApiImplicitParam(name = "nDid", value = "nDid", required = true)
    public HttpResult<String> rebootDevice(@RequestParam("nDid") String nDid) {
        String methodDescribe = getMethodDescribe("rebootDevice");
        boolean result = csEquipmentDeliveryService.rebootDevice(nDid);
        if (result) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        } else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getAll")
    @ApiOperation("获取所有装置")
    public HttpResult<List<CsEquipmentDeliveryPO>> getAll() {
        String methodDescribe = getMethodDescribe("getAll");
        List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getAll();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/judgeDevModel")
    @ApiOperation("判断设备型号")
    public HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid) {
        String methodDescribe = getMethodDescribe("judgeDevModel");
        boolean result = csEquipmentDeliveryService.judgeDevModel(nDid);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getDevByLineId")
    @ApiOperation("根据监测点id查询装置信息")
    public HttpResult<CsEquipmentDeliveryPO> getDevByLineId(@RequestParam("lineId") String lineId) {
        String methodDescribe = getMethodDescribe("getDevByLineId");
        CsEquipmentDeliveryPO po = csEquipmentDeliveryService.getDevByLineId(lineId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addCldDev")
    @ApiOperation("新增云前置设备")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    @DeviceLog(operateType = DeviceOperate.ADD)
    public HttpResult<CsEquipmentDeliveryPO> addCldDev(@RequestBody @Validated CsEquipmentDeliveryAddParm param) {
        String methodDescribe = getMethodDescribe("addCldDev");
        CsEquipmentDeliveryPO po = csEquipmentDeliveryService.saveCld(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/delCldDev")
    @ApiOperation("删除云前置设备")
    @ApiImplicitParam(name = "id", value = "id", required = true)
    @DeviceLog(operateType = DeviceOperate.DELETE)
    public HttpResult<Boolean> delCldDev(@RequestParam("id") String id) {
        String methodDescribe = getMethodDescribe("delCldDev");
        boolean result = csEquipmentDeliveryService.delCldDev(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateCldDev")
    @ApiOperation("修改云前置设备")
    @ApiImplicitParam(name = "param", value = "参数", required = true)
    @DeviceLog(operateType = DeviceOperate.UPDATE)
    public HttpResult<Boolean> updateCldDev(@RequestBody @Validated CsEquipmentDeliveryAuditParm param) {
        String methodDescribe = getMethodDescribe("updateCldDev");
        boolean result = csEquipmentDeliveryService.updateCldDev(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateCldDevStatus")
    @ApiOperation("云前置心跳丢失切换设备状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "nodeId", value = "前置服务器id", required = true),
            @ApiImplicitParam(name = "processNo", value = "进程号", required = true)
    })
    @ApiIgnore
    public HttpResult<Boolean> updateCldDevStatus(@RequestParam("nodeId") String nodeId, @RequestParam("processNo") Integer processNo) {
        String methodDescribe = getMethodDescribe("updateCldDevStatus");
        csEquipmentDeliveryService.updateCldDevStatus(nodeId, processNo);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/flipCldDevStatus")
    @ApiOperation("云前置设备状态翻转")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "date", value = "时间", required = true),
            @ApiImplicitParam(name = "devId", value = "设备id", required = true),
            @ApiImplicitParam(name = "status", value = "状态", required = true)
    })
    @ApiIgnore
    public HttpResult<Boolean> flipCldDevStatus(@RequestParam("date") String date, @RequestParam("devId") String devId, @RequestParam("status") Integer status) {
        String methodDescribe = getMethodDescribe("flipCldDevStatus");
        csEquipmentDeliveryService.flipCldDevStatus(date, devId, status);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getRunPortableDev")
    @ApiOperation("获取用户未绑定的在运的便携式设备")
    @ApiImplicitParam(name = "userId", value = "用户id", required = true)
    public HttpResult<List<CsEquipmentDeliveryPO>> getRunPortableDev(@RequestParam("userId") String userId) {
        String methodDescribe = getMethodDescribe("getRunPortableDev");
        List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getRunPortableDev(userId);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/version/page")
    @ApiOperation("查询设备版本信息")
    @ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
    public HttpResult<IPage<DevVersionVO>> versionPage(@RequestBody CsEquipmentDeliveryQueryParm baseParam) {
        String methodDescribe = getMethodDescribe("versionPage");

        IPage<DevVersionVO> list = csEquipmentDeliveryService.versionPage(baseParam);

        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }
}