设备监控:模板下载、离线数据导入、解析列表接口开发(只是预留口子)
This commit is contained in:
@@ -0,0 +1,121 @@
|
|||||||
|
package com.njcn.csdevice.pojo.param;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 方案、测试项表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2024-04-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WlRecordTemplete extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试项名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "测试项名称", width = 15)
|
||||||
|
private String itemName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "*名称", width = 15)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置网关识别码
|
||||||
|
*/
|
||||||
|
@Excel(name = "*装置网关识别码", width = 15)
|
||||||
|
private String ndid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点id
|
||||||
|
*/
|
||||||
|
@Excel(name = "*监测点编号", width = 15)
|
||||||
|
private String lineId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计间隔
|
||||||
|
*/
|
||||||
|
@Excel(name = "*统计间隔", width = 15)
|
||||||
|
private String statisticalInterval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PT变比
|
||||||
|
*/
|
||||||
|
@Excel(name = "*PT变比", width = 15)
|
||||||
|
private String pt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CT变比
|
||||||
|
*/
|
||||||
|
@Excel(name = "*CT变比", width = 15)
|
||||||
|
private Integer ct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电压等级
|
||||||
|
*/
|
||||||
|
@Excel(name = "*电压等级", width = 15)
|
||||||
|
private String voltageLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基准短路容量(MVA)
|
||||||
|
*/
|
||||||
|
@Excel(name = "*基准短路容量(MVA)", width = 15)
|
||||||
|
private String capacitySscb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最小短路容量(MVA)
|
||||||
|
*/
|
||||||
|
@Excel(name = "*最小短路容量(MVA)", width = 15)
|
||||||
|
private String capacitySscmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供电设备容量(MVA)
|
||||||
|
*/
|
||||||
|
@Excel(name = "*供电设备容量(MVA)", width = 15)
|
||||||
|
private String capacitySt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户协议容量(MVA)
|
||||||
|
*/
|
||||||
|
@Excel(name = "*用户协议容量(MVA)", width = 15)
|
||||||
|
private String capacitySi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电压接线方式(星型、角型、V型)
|
||||||
|
*/
|
||||||
|
@Excel(name = "*电压接线方式(星型、角型、V型)", width = 15)
|
||||||
|
private String volConType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电流接线方式(正常、合成IB、合成IC)
|
||||||
|
*/
|
||||||
|
@Excel(name = "*电流接线方式(正常、合成IB、合成IC)", width = 15)
|
||||||
|
private String curConSel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试起始时间
|
||||||
|
*/
|
||||||
|
@Excel(name = "*测试起始时间", width = 15)
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试结束时间
|
||||||
|
*/
|
||||||
|
@Excel(name = "*测试结束时间", width = 15)
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试项监测位置
|
||||||
|
*/
|
||||||
|
@Excel(name = "测试项监测位置", width = 15)
|
||||||
|
private String location;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.njcn.csdevice.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author guofeihu
|
||||||
|
* @since 2024-07-03
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("portable_offl_log")
|
||||||
|
public class PortableOfflLog extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String logsIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
*/
|
||||||
|
private String dataPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0-未解析 1-解析成功 2-解析失败 3-文件不存在
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总条数
|
||||||
|
*/
|
||||||
|
private Integer allCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库条数
|
||||||
|
*/
|
||||||
|
private Integer realCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建用户
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.njcn.csdevice.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||||
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 便携式基础数据导入 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author guofeihu
|
||||||
|
* @since 2024-07-03
|
||||||
|
*/
|
||||||
|
public interface PortableOfflLogMapper extends BaseMapper<PortableOfflLog> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 便携式设备解析列表
|
||||||
|
*/
|
||||||
|
Page<PortableOfflLog> queryPage(Page<PortableOfflLog> returnpage, @Param("baseParam") BaseParam baseParam);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.csdevice.mapper.PortableOfflLogMapper">
|
||||||
|
<select id="queryPage" resultType="com.njcn.csdevice.pojo.po.PortableOfflLog">
|
||||||
|
select * from portable_offl_log where 1 = 1
|
||||||
|
<if test="baseParam.searchBeginTime!=null and baseParam.searchEndTime != null
|
||||||
|
and baseParam.searchBeginTime != '' and baseParam.searchEndTime != ''">
|
||||||
|
and create_Time between #{baseParam.searchBeginTime} and #{baseParam.searchEndTime}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.njcn.csdevice.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||||
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 便携式基础数据导入 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author guofeihu
|
||||||
|
* @since 2024-07-03
|
||||||
|
*/
|
||||||
|
public interface IPortableOfflLogService extends IService<PortableOfflLog> {
|
||||||
|
|
||||||
|
Page<PortableOfflLog> queryPage(BaseParam baseParam);
|
||||||
|
|
||||||
|
void importEquipment(MultipartFile file, HttpServletResponse response);
|
||||||
|
}
|
||||||
@@ -359,8 +359,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//暂降幅值
|
//暂降幅值
|
||||||
//List<RmpEventDetailPO> eventDetails = eventDetailFeignClient.getEventDetailByIdsList(Arrays.asList(temp.getEventId())).getData();
|
List<RmpEventDetailPO> eventDetails = eventDetailFeignClient.getEventDetailByIdsList(Arrays.asList(temp.getEventId())).getData();
|
||||||
//if(eventDetails !=null && !eventDetails.isEmpty()) temp.setAmplitude(PubUtils.floatRound(2, eventDetails.get(0).getFeatureAmplitude().floatValue()));
|
if(eventDetails !=null && !eventDetails.isEmpty()) temp.setAmplitude(PubUtils.floatRound(2, eventDetails.get(0).getFeatureAmplitude().floatValue()));
|
||||||
});
|
});
|
||||||
return returnpage;
|
return returnpage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.njcn.csdevice.service.impl;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||||
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||||
|
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.csdevice.mapper.PortableOfflLogMapper;
|
||||||
|
import com.njcn.csdevice.pojo.param.DeviceExcelTemplete;
|
||||||
|
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||||
|
import com.njcn.csdevice.service.IPortableOfflLogService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 便携式基础数据导入 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author guofeihu
|
||||||
|
* @since 2024-07-03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMapper, PortableOfflLog> implements IPortableOfflLogService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
|
||||||
|
Page<PortableOfflLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
|
||||||
|
if(baseParam.getSearchBeginTime()!=null) baseParam.setSearchBeginTime(baseParam.getSearchBeginTime()+" 00:00:00");
|
||||||
|
if(baseParam.getSearchEndTime()!=null) baseParam.setSearchEndTime(baseParam.getSearchEndTime()+" 23:59:59");
|
||||||
|
returnpage = this.getBaseMapper().queryPage(returnpage,baseParam);
|
||||||
|
return returnpage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importEquipment(MultipartFile file, HttpServletResponse response) {
|
||||||
|
ImportParams params = new ImportParams ( );
|
||||||
|
params.setHeadRows(1);
|
||||||
|
params.setTitleRows(1);
|
||||||
|
//第一个sheet为台账信息
|
||||||
|
params.setStartSheetIndex(0);
|
||||||
|
params.setSheetNum(1);
|
||||||
|
try {
|
||||||
|
ExcelImportResult<DeviceExcelTemplete> terminalBaseList = ExcelImportUtil.importExcelMore (file.getInputStream ( ), DeviceExcelTemplete.class, params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
//记录导入信息
|
||||||
|
PortableOfflLog portableOfflLog = new PortableOfflLog();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user