diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/WlRecordTemplete.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/WlRecordTemplete.java new file mode 100644 index 0000000..d3f5123 --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/WlRecordTemplete.java @@ -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; + +/** + *

+ * 方案、测试项表 + *

+ * + * @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; + +} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/PortableOfflLog.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/PortableOfflLog.java new file mode 100644 index 0000000..c6ea5b7 --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/PortableOfflLog.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + + +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/PortableOfflLogController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/PortableOfflLogController.java new file mode 100644 index 0000000..df9eab5 --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/PortableOfflLogController.java @@ -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; + +/** + *

+ * 便携式基础数据导入 前端控制器 + *

+ * + * @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 getExcelTemplate(HttpServletResponse response) { + ExportParams exportParams = new ExportParams("批量导入模板(请严格按照模板标准填入数据,带*表示必填)", "便携式终端基础数据录入信息"); + exportParams.setStyle(ExcelStyleUtil.class); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, WlRecordTemplete.class, new ArrayList()); + //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> queryPage(@RequestBody BaseParam baseParam){ + String methodDescribe = getMethodDescribe("queryPage"); + Page list = iPortableOfflLogService.queryPage(baseParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } + + @ResponseBody + @ApiOperation("批量导入便携式设备信息") + @PostMapping(value = "importEquipment") + public HttpResult 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); + } + +} + diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/PortableOfflLogMapper.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/PortableOfflLogMapper.java new file mode 100644 index 0000000..076eb61 --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/PortableOfflLogMapper.java @@ -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; + +/** + *

+ * 便携式基础数据导入 Mapper 接口 + *

+ * + * @author guofeihu + * @since 2024-07-03 + */ +public interface PortableOfflLogMapper extends BaseMapper { + + /** + * 便携式设备解析列表 + */ + Page queryPage(Page returnpage, @Param("baseParam") BaseParam baseParam); + +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/PortableOfflLogMapper.xml b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/PortableOfflLogMapper.xml new file mode 100644 index 0000000..995b79d --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/PortableOfflLogMapper.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IPortableOfflLogService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IPortableOfflLogService.java new file mode 100644 index 0000000..a4a930b --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IPortableOfflLogService.java @@ -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; + +/** + *

+ * 便携式基础数据导入 服务类 + *

+ * + * @author guofeihu + * @since 2024-07-03 + */ +public interface IPortableOfflLogService extends IService { + + Page queryPage(BaseParam baseParam); + + void importEquipment(MultipartFile file, HttpServletResponse response); +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java index a49ba09..e3b540f 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java @@ -359,8 +359,8 @@ public class CsGroupServiceImpl extends ServiceImpl impl } } //暂降幅值 - //List eventDetails = eventDetailFeignClient.getEventDetailByIdsList(Arrays.asList(temp.getEventId())).getData(); - //if(eventDetails !=null && !eventDetails.isEmpty()) temp.setAmplitude(PubUtils.floatRound(2, eventDetails.get(0).getFeatureAmplitude().floatValue())); + List eventDetails = eventDetailFeignClient.getEventDetailByIdsList(Arrays.asList(temp.getEventId())).getData(); + if(eventDetails !=null && !eventDetails.isEmpty()) temp.setAmplitude(PubUtils.floatRound(2, eventDetails.get(0).getFeatureAmplitude().floatValue())); }); return returnpage; } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/PortableOfflLogServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/PortableOfflLogServiceImpl.java new file mode 100644 index 0000000..ff3d97a --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/PortableOfflLogServiceImpl.java @@ -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; + +/** + *

+ * 便携式基础数据导入 服务实现类 + *

+ * + * @author guofeihu + * @since 2024-07-03 + */ +@Service +public class PortableOfflLogServiceImpl extends ServiceImpl implements IPortableOfflLogService { + + @Override + public Page queryPage(BaseParam baseParam) { + Page 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 terminalBaseList = ExcelImportUtil.importExcelMore (file.getInputStream ( ), DeviceExcelTemplete.class, params); + } catch (Exception e) { + e.printStackTrace(); + } + //记录导入信息 + PortableOfflLog portableOfflLog = new PortableOfflLog(); + } +}