设备监控:模板下载、离线数据导入、解析列表接口开发(只是预留口子)
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
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.pojo.param.WlRecordTemplete;
|
||||
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||
import com.njcn.csdevice.service.IPortableOfflLogService;
|
||||
import com.njcn.csdevice.utils.ExcelStyleUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 便携式基础数据导入 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-07-03
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/portableOfflLog")
|
||||
@Api(tags = " 出厂设备")
|
||||
@AllArgsConstructor
|
||||
public class PortableOfflLogController extends BaseController {
|
||||
|
||||
private final IPortableOfflLogService iPortableOfflLogService;
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("导出设备基础数据模板")
|
||||
@GetMapping(value = "getExcelTemplate")
|
||||
public HttpResult<String> getExcelTemplate(HttpServletResponse response) {
|
||||
ExportParams exportParams = new ExportParams("批量导入模板(请严格按照模板标准填入数据,带*表示必填)", "便携式终端基础数据录入信息");
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, WlRecordTemplete.class, new ArrayList<WlRecordTemplete>());
|
||||
//ExcelUtil.selectList(workbook, 2, 2, Stream.of("直连设备","网关设备").collect(Collectors.toList()).toArray(new String[]{}));
|
||||
//ExcelUtil.selectList(workbook, 4, 4, Stream.of("MQTT","CLD").collect(Collectors.toList()).toArray(new String[]{}));
|
||||
String fileName = "便携式设备模板.xlsx";
|
||||
PoiUtil.exportFileByWorkbook(workbook, fileName, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryPage")
|
||||
@ApiOperation("便携式设备解析列表")
|
||||
@ApiImplicitParam(name = "baseParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PortableOfflLog>> queryPage(@RequestBody BaseParam baseParam){
|
||||
String methodDescribe = getMethodDescribe("queryPage");
|
||||
Page<PortableOfflLog> list = iPortableOfflLogService.queryPage(baseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("批量导入便携式设备信息")
|
||||
@PostMapping(value = "importEquipment")
|
||||
public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importEquipment");
|
||||
iPortableOfflLogService.importEquipment(file, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user