10 小时以前 de1d6cf24efebced674fbaa46123648bf50bd74a
feat(device): 添加物联网设备支持功能

- 在DeviceLedger实体类中新增isIotDevice和externalCode字段
- 在DeviceLedgerDto数据传输对象中添加相应属性
- 为Excel导入导出功能增加物联网设备相关字段映射
- 更新数据库查询映射文件以包含新字段并添加筛选条件
- 修改JclyController实现动态获取物联网设备列表功能
- 替换用户名显示为昵称在计量器具台账模块中
- 执行SQL脚本为设备台账表添加物联网设备相关字段及索引
已添加1个文件
已修改8个文件
122 ■■■■■ 文件已修改
sql/device_ledger_add_iot_fields.sql 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/execl/DeviceLedgerExeclDto.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/device/pojo/DeviceLedger.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/http/service/controller/JclyController.java 78 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/measuringinstrumentledger/controller/MeasuringInstrumentLedgerController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/collaborativeApproval/SealApplicationManagementMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/device/DeviceLedgerMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/device_ledger_add_iot_fields.sql
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,6 @@
ALTER TABLE `device_ledger`
    ADD COLUMN `is_iot_device` tinyint DEFAULT 0 COMMENT '是否为物联设备:0-否,1-是' AFTER `type`,
    ADD COLUMN `external_code` varchar(255) DEFAULT NULL COMMENT '外部编码' AFTER `is_iot_device`;
CREATE INDEX `idx_device_ledger_iot_external_code`
    ON `device_ledger` (`is_iot_device`, `external_code`);
src/main/java/com/ruoyi/device/dto/DeviceLedgerDto.java
@@ -94,4 +94,10 @@
    @ApiModelProperty("设备类型")
    private String type;
    @ApiModelProperty("是否为物联设备 0-否 1-是")
    private Integer isIotDevice;
    @ApiModelProperty("外部编码")
    private String externalCode;
}
src/main/java/com/ruoyi/device/execl/DeviceLedgerExeclDto.java
@@ -51,6 +51,12 @@
    @Excel(name = "设备区域", sort = 11)
    private String areaName;
    @Excel(name = "录入人", sort = 12)
    @Excel(name = "是否为物联设备", sort = 12, readConverterExp = "0=否,1=是")
    private Integer isIotDevice;
    @Excel(name = "外部编码", sort = 13)
    private String externalCode;
    @Excel(name = "录入人", sort = 14)
    private String createUser;
}
src/main/java/com/ruoyi/device/pojo/DeviceLedger.java
@@ -109,4 +109,10 @@
    @ApiModelProperty("设备类型")
    private String type;
    @ApiModelProperty("是否为物联设备 0-否 1-是")
    private Integer isIotDevice;
    @ApiModelProperty("外部编码")
    private String externalCode;
}
src/main/java/com/ruoyi/http/service/controller/JclyController.java
@@ -1,5 +1,9 @@
package com.ruoyi.http.service.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.device.pojo.DeviceLedger;
import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.http.service.impl.RealTimeEnergyConsumptionServiceImpl;
@@ -10,8 +14,11 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.naming.ldap.PagedResultsControl;
import java.util.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/iot")
@@ -21,55 +28,42 @@
    @Autowired
    private RealTimeEnergyConsumptionServiceImpl realTimeEnergyConsumptionService;
    private final String DEVICE_GUID = "90444196515214284663";
    private final String DEVICE_GUID_2 = "90187099059463151919";
    private final String DEVICE_GUID_3 = "90299548548536240693";
    private final String DEVICE_GUID_4 = "90558670647417764794";
    private final String DEVICE_GUID_5 = "90802100373808917949";
    private final String DEVICE_GUID_6 = "90878497978270816672";
    private final String DEVICE_GUID_7 = "90140305546502568592";
    private final String DEVICE_GUID_8 = "90169534185157152878";
    private final String DEVICE_GUID_9 = "90276104525436465283";
    private final String DEVICE_GUID_10 = "90543538108119559625";
    private final String DEVICE_GUID_11 = "90689981408895835872";
    private final String DEVICE_GUID_12 = "90943795336343088068";
    @Autowired
    private IDeviceLedgerService deviceLedgerService;
    /**
     * å®žæ—¶èŽ·å–æ¸©æ¹¿åº¦ï¼ŒäºŒæ°§åŒ–ç¢³æ•°æ®
     */
    @GetMapping("/getRealData")
    public AjaxResult getRealData() {
        List<Map<String,String>> maps = realTimeEnergyConsumptionService
                .getRealData(Arrays.
                        asList(
                                DEVICE_GUID,
                                DEVICE_GUID_2,
                                DEVICE_GUID_3,
                                DEVICE_GUID_4,
                                DEVICE_GUID_5,
                                DEVICE_GUID_6,
                                DEVICE_GUID_7,
                                DEVICE_GUID_8,
                                DEVICE_GUID_9,
                                DEVICE_GUID_10,
                                DEVICE_GUID_11,
                                DEVICE_GUID_12
        List<DeviceLedger> iotDevices = deviceLedgerService.list(new LambdaQueryWrapper<DeviceLedger>()
                .eq(DeviceLedger::getIsIotDevice, 1)
                .isNotNull(DeviceLedger::getExternalCode)
                .ne(DeviceLedger::getExternalCode, ""));
        Map<String, String> guidDeviceNameMap = iotDevices.stream()
                .filter(item -> StringUtils.isNotEmpty(item.getExternalCode()))
                .collect(Collectors.toMap(
                        item -> item.getExternalCode().trim(),
                        item -> StringUtils.isNotEmpty(item.getDeviceName()) ? item.getDeviceName().trim() : "",
                        (oldValue, newValue) -> StringUtils.isNotEmpty(oldValue) ? oldValue : newValue,
                        LinkedHashMap::new
                        ));
        List<String> guidList = new ArrayList<>(guidDeviceNameMap.keySet());
        List<Map<String, String>> maps = realTimeEnergyConsumptionService
                .getRealData(guidList);
        for (Map<String, String> item : maps) {
            String guid = item.get("guid");
            if (StringUtils.isNotEmpty(guid)) {
                String deviceName = guidDeviceNameMap.get(guid.trim());
                if (StringUtils.isNotEmpty(deviceName)) {
                    item.put("deviceName", deviceName);
                }
            }
        }
        return AjaxResult.success(maps);
    }
    /**
     * èŽ·å–åŽ†å²æ•°æ®
src/main/java/com/ruoyi/measuringinstrumentledger/controller/MeasuringInstrumentLedgerController.java
@@ -74,7 +74,7 @@
        if (sysUser == null) {
            return AjaxResult.error("用户不存在");
        }
        measuringInstrumentLedger.setUserName(sysUser.getUserName());
        measuringInstrumentLedger.setUserName(sysUser.getNickName());
        boolean update = measuringInstrumentLedgerService.updateById(measuringInstrumentLedger);
        if (update) {
            return AjaxResult.success();
src/main/java/com/ruoyi/measuringinstrumentledger/service/impl/MeasuringInstrumentLedgerServiceImpl.java
@@ -109,7 +109,7 @@
            measuringInstrumentLedgerRecord.setEntryDate(req.getEntryDate());
            measuringInstrumentLedgerRecord.setValid(req.getValid());
            measuringInstrumentLedgerRecord.setUserId(req.getUserId());
            measuringInstrumentLedgerRecord.setUserName(sysUser.getUserName());
            measuringInstrumentLedgerRecord.setUserName(sysUser.getNickName());
            measuringInstrumentLedgerRecordMapper.insert(measuringInstrumentLedgerRecord);
            // å°è´¦ç»‘定一次
//            if(!CollectionUtils.isEmpty(req.getTempFileIds())){
@@ -137,7 +137,7 @@
        if (sysUser == null) {
            return false;
        }
        measuringInstrumentLedger.setUserName(sysUser.getUserName());
        measuringInstrumentLedger.setUserName(sysUser.getNickName());
        measuringInstrumentLedgerMapper.insert(measuringInstrumentLedger);
        if(!CollectionUtils.isEmpty(measuringInstrumentLedger.getTempFileIds())){
            migrateTempFilesToFormal(measuringInstrumentLedger.getId(), measuringInstrumentLedger.getTempFileIds(), FileNameType.MEASURING.getValue());
src/main/resources/mapper/collaborativeApproval/SealApplicationManagementMapper.xml
@@ -4,7 +4,7 @@
    <select id="listPage" resultType="com.ruoyi.collaborativeApproval.dto.SealApplicationManagementDTO">
        select sam.*, su.user_name as create_user_name, d.dept_name as department,
        select sam.*, su.nick_name as create_user_name, d.dept_name as department,
        su1.nick_name as approveUserName
        from seal_application_management sam
        left join sys_user su on sam.create_user = su.user_id
src/main/resources/mapper/device/DeviceLedgerMapper.xml
@@ -33,7 +33,9 @@
            dl.tenant_id,
            dl.is_depr,
            dl.annual_depreciation_amount,
            dl.type
            dl.type,
            dl.is_iot_device AS isIotDevice,
            dl.external_code AS externalCode
        FROM device_ledger dl
                 LEFT JOIN sys_user su ON dl.create_user = su.user_id
                 LEFT JOIN device_area da ON dl.area_id = da.id
@@ -71,6 +73,12 @@
            <if test="deviceLedger.tenantId != null">
                AND dl.tenant_id = #{deviceLedger.tenantId}
            </if>
            <if test="deviceLedger.isIotDevice != null">
                AND dl.is_iot_device = #{deviceLedger.isIotDevice}
            </if>
            <if test="deviceLedger.externalCode != null and deviceLedger.externalCode != ''">
                AND dl.external_code LIKE CONCAT('%', #{deviceLedger.externalCode}, '%')
            </if>
        </where>
        ORDER BY dl.create_time DESC
    </select>