Bladeren bron

监控设备与变量列表导出添加1

jichaobo 3 jaren geleden
bovenliggende
commit
3732c55532

+ 9 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/DeviceAnalogVariableListController.java

@@ -108,6 +108,7 @@ public class DeviceAnalogVariableListController {
 
     /**
      * 站点管理-变量列表-(监控设备为零)变量下拉框
+     *
      * @return
      */
     @GetMapping("variableListDroplist")
@@ -116,5 +117,13 @@ public class DeviceAnalogVariableListController {
         return ApiResult.success(deviceAnalogVariableListService.variableListDroplist());
     }
 
+
+    @GetMapping("variableListExport")
+    public ApiResult<String> variableListExport(@RequestParam Integer siteId,
+                                                @RequestParam(required = false) String variableName,
+                                                @RequestParam(value = "dataArea", required = false, defaultValue = "1") Integer dataArea) {
+        return ApiResult.success(deviceAnalogVariableListService.variableListExport(siteId,variableName,dataArea));
+    }
+
 }
 

+ 16 - 3
fiveep-controller/src/main/java/com/bizmatics/controller/web/DeviceController.java

@@ -183,11 +183,11 @@ public class DeviceController {
 
 
     /**
-     *
-     * @param type 1 新设备 2 已有设备
+     * 设备管理-通信设备-克隆
+     * @param type          1 新设备 2 已有设备
      * @param newDeviceCode 克隆设备对象
      * @param oldDeviceCode 设备编号
-     * @param deviceName 设备名称
+     * @param deviceName    设备名称
      * @return
      */
     @GetMapping("variableCloning")
@@ -199,5 +199,18 @@ public class DeviceController {
         deviceService.variableCloning(type, newDeviceCode, oldDeviceCode, deviceName);
         return ApiResult.success();
     }
+
+
+    /**
+     *  通信设备列表查询-无分页
+     * @param siteId 站点ID
+     * @param deviceType 1电力 2视频
+     * @return
+     */
+    @GetMapping("deviceListOne")
+    public ApiResult<List<Device>> deviceListOne(@RequestParam Integer siteId,
+                                                 @RequestParam (value = "deviceType", required = false, defaultValue = "1") Integer deviceType) {
+        return ApiResult.success(deviceService.deviceListOne(siteId,deviceType));
+    }
 }
 

+ 9 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/DeviceAnalogVariableListMapper.java

@@ -1,6 +1,9 @@
 package com.bizmatics.persistence.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.bizmatics.common.mvc.base.CrudMapper;
+import com.bizmatics.model.AlarmPower;
 import com.bizmatics.model.DeviceAnalogVariableList;
 import com.bizmatics.model.vo.DeviceAnalogVariableListOneVo;
 import org.apache.ibatis.annotations.Param;
@@ -22,7 +25,12 @@ public interface DeviceAnalogVariableListMapper extends CrudMapper<DeviceAnalogV
                                                      @Param("startCurrent") Integer startCurrent,
                                                      @Param("size") Integer size,
                                                      @Param("dataArea") Integer dataArea,
-                                                     @Param("monitoringEquipment")Integer monitoringEquipment);
+                                                     @Param("monitoringEquipment") Integer monitoringEquipment);
+
+    Page<DeviceAnalogVariableListOneVo> variableListExport(IPage<DeviceAnalogVariableListOneVo> page,
+                                                           @Param("siteId") Integer siteId,
+                                                           @Param("variableName") String variableName,
+                                                           @Param("dataArea") Integer dataArea);
 
 
 }

+ 25 - 0
fiveep-persistence/src/main/resources/mapper/mysql/DeviceAnalogVariableListMapper.xml

@@ -52,4 +52,29 @@
         </if>
     </select>
 
+    <select id="variableListExport" resultType="com.bizmatics.model.vo.DeviceAnalogVariableListOneVo">
+        SELECT
+        a.*, b.device_name,
+        c.monitor_device_name
+        FROM
+        device_analog_variable_list AS a
+        JOIN device AS b ON a.communication_equipment = b.id
+        JOIN device_attribute AS c ON a.monitoring_equipment = c.id
+        <where>
+            a. STATUS = 1
+            AND b. ENABLE = 1
+            AND c. STATUS = 1
+            <if test="siteId != null and siteId !=0">
+                and c.site_id = #{siteId}
+            </if>
+            <if test="dataArea != null and dataArea !=0">
+                and a.data_area = #{dataArea}
+            </if>
+            <if test="variableName != null and variableName !=''">
+                and a.variable_name LIKE CONCAT(CONCAT('%', #{variableName}), '%')
+            </if>
+        </where>
+        order by a.id desc
+    </select>
+
 </mapper>

+ 2 - 0
fiveep-service/src/main/java/com/bizmatics/service/DeviceAnalogVariableListService.java

@@ -29,5 +29,7 @@ public interface DeviceAnalogVariableListService extends CrudService<DeviceAnalo
 
     List<DeviceAnalogVariableList> variableListDroplist();
 
+    String variableListExport(Integer siteId, String variableName, Integer dataArea);
+
 
 }

+ 2 - 0
fiveep-service/src/main/java/com/bizmatics/service/DeviceService.java

@@ -56,4 +56,6 @@ public interface DeviceService extends CrudService<Device> {
     CommonPage<Device> videoMonitoringDeviceList(String deviceName, Integer deviceType, Integer siteId, Integer size, Integer current);
 
     void variableCloning(Integer type, String newDeviceCode, String oldDeviceCode, String deviceName);
+
+    List<Device> deviceListOne(Integer siteId,Integer deviceType);
 }

+ 49 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAnalogVariableListServiceImpl.java

@@ -1,20 +1,34 @@
 package com.bizmatics.service.impl;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.bizmatics.common.core.bean.CommonPage;
+import com.bizmatics.common.core.exception.BusinessException;
+import com.bizmatics.common.core.util.BeanMapperUtils;
+import com.bizmatics.common.core.util.FileUtils;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
+import com.bizmatics.common.spring.util.GlobalUtils;
+import com.bizmatics.model.AlarmPower;
 import com.bizmatics.model.DeviceAnalogVariableList;
+import com.bizmatics.model.DeviceAttribute;
 import com.bizmatics.model.system.SysUser;
 import com.bizmatics.model.vo.DeviceAnalogVariableListOneVo;
 import com.bizmatics.model.vo.DeviceAnalogVariableListVo;
 import com.bizmatics.persistence.mapper.DeviceAnalogVariableListMapper;
 import com.bizmatics.service.DeviceAnalogVariableListService;
 import com.bizmatics.service.util.SecurityUtils;
+import com.bizmatics.service.vo.DeviceAttributeExportVO;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -100,5 +114,40 @@ public class DeviceAnalogVariableListServiceImpl extends AbstractCrudService<Dev
         return DeviceAnalogVariableListDroplist;
     }
 
+    @Override
+    public String variableListExport( Integer siteId,String variableName,Integer dataArea) {
+        Workbook workbook = null;
+        File file = null;
+        try {
+            ExportParams params = new ExportParams(null, "变量列表");
+            workbook = ExcelExportUtil.exportBigExcel(params, DeviceAttributeExportVO.class,
+                    (o, i) -> {
+                        Page<DeviceAnalogVariableListOneVo> page = new Page<>(i, 30);
+                        page = baseMapper.variableListExport(page,siteId, variableName, dataArea);
+                        return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), DeviceAnalogVariableListOneVo.class, DeviceAttributeExportVO.class));
+                    }, null);
+            if (null != workbook) {
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "变量列表", System.currentTimeMillis() + ""));
+                FileUtils.createFile(file.getAbsolutePath());
+                FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
+                workbook.write(allListingFileOutputStream);
+            } else {
+                throw new BusinessException("表格数据为空");
+            }
+        } catch (Exception e) {
+            log.error("导出文件失败", e);
+            throw new BusinessException("导出文件失败");
+        } finally {
+            if (workbook != null) {
+                try {
+                    workbook.close();
+                } catch (IOException e) {
+                    log.error("===export spec=== 关闭workbook失败", e);
+                }
+            }
+        }
+        return file.getName();
+    }
+
 
 }

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAttributeServiceImpl.java

@@ -108,7 +108,7 @@ public class DeviceAttributeServiceImpl extends AbstractCrudService<DeviceAttrib
                             queryWrapper.eq(DeviceAttribute::getId, id);
                         }
                         page = this.page(page, queryWrapper);
-                        this.ToCommonPage(page);
+//                        this.ToCommonPage(page);
                         return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), DeviceAttribute.class, DeviceAttributeExportVO.class));
                     }, null);
             if (null != workbook) {

+ 9 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceServiceImpl.java

@@ -310,4 +310,13 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
         }
     }
 
+
+    @Override
+    public List<Device> deviceListOne(Integer siteId,Integer deviceType){
+        LambdaQueryWrapper<Device> queryWrapperTwo = Wrappers.lambdaQuery();
+        queryWrapperTwo.eq(Device::getEnable, 1).eq(Device::getSiteId, siteId).eq(Device::getDeviceType,deviceType);
+        List<Device> deviceListTwo = this.list(queryWrapperTwo);
+        return deviceListTwo;
+    }
+
 }

+ 80 - 0
fiveep-service/src/main/java/com/bizmatics/service/vo/DeviceAnalogVariableListExportVO.java

@@ -0,0 +1,80 @@
+package com.bizmatics.service.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author yq
+ * @date 2021/7/13 16:21
+ */
+@Data
+public class DeviceAnalogVariableListExportVO {
+    /**
+     * 变量列表id
+     */
+    private Integer id;
+
+    /**
+     * 设备编号
+     */
+    @Excel(name = "设备编号", height = 6, width = 20)
+    private String deviceCode;
+
+    /**
+     * 变量名
+     */
+    @Excel(name = "变量名", height = 6, width = 20)
+    private String variableName;
+
+    /**
+     * 变量编码
+     */
+    @Excel(name = "变量编码", height = 6, width = 20)
+    private String variableCoding;
+
+    /**
+     * 数据地址
+     */
+    @Excel(name = "数据地址", height = 6, width = 20)
+    private String dataAddress;
+
+    /**
+     * 数据类型
+     */
+    @Excel(name = "数据类型", height = 6, width = 20)
+    private String dataType;
+
+    /**
+     * 系数
+     */
+    @Excel(name = "系数", height = 6, width = 20)
+    private Float coefficient;
+
+    /**
+     * 存盘周期(分钟)
+     */
+    @Excel(name = "存盘周期(分钟)", height = 6, width = 20)
+    private Integer saveCycle;
+
+    /**
+     *  通信设备
+     */
+    @Excel(name = "通信设备", height = 6, width = 20)
+    private String deviceName;
+    /**
+     *  电力监控设备
+     */
+    @Excel(name = "监控设备", height = 6, width = 20)
+    private String monitorDeviceName;
+
+    /**
+     * 1.模拟量 2.状态量 3.参数量
+     */
+    @Excel(name = "变量类型", height = 6, width = 20)
+    private Integer dataArea;
+
+}