Jelajahi Sumber

环境监测集成modbus

王先生 3 tahun lalu
induk
melakukan
38f9df8ac4
40 mengubah file dengan 2760 tambahan dan 0 penghapusan
  1. 105 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/domain/DmModbusChannel.java
  2. 28 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/repository/DmModbusChannelRepository.java
  3. 87 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/rest/DmModbusChannelController.java
  4. 83 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/DmModbusChannelService.java
  5. 75 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/dto/DmModbusChannelDto.java
  6. 49 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/dto/DmModbusChannelQueryCriteria.java
  7. 120 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/impl/DmModbusChannelServiceImpl.java
  8. 32 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/mapstruct/DmModbusChannelMapper.java
  9. 97 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/domain/DmModbusData.java
  10. 28 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/repository/DmModbusDataRepository.java
  11. 87 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/rest/DmModbusDataController.java
  12. 83 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/DmModbusDataService.java
  13. 72 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/dto/DmModbusDataDto.java
  14. 45 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/dto/DmModbusDataQueryCriteria.java
  15. 121 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/impl/DmModbusDataServiceImpl.java
  16. 32 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/mapstruct/DmModbusDataMapper.java
  17. 125 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/domain/DmModbusDevice.java
  18. 28 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/repository/DmModbusDeviceRepository.java
  19. 87 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/rest/DmModbusDeviceController.java
  20. 83 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/DmModbusDeviceService.java
  21. 92 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/dto/DmModbusDeviceDto.java
  22. 45 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/dto/DmModbusDeviceQueryCriteria.java
  23. 124 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/impl/DmModbusDeviceServiceImpl.java
  24. 32 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/mapstruct/DmModbusDeviceMapper.java
  25. 72 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/domain/DmModbusDrive.java
  26. 28 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/repository/DmModbusDriveRepository.java
  27. 87 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/rest/DmModbusDriveController.java
  28. 83 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/DmModbusDriveService.java
  29. 52 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/dto/DmModbusDriveDto.java
  30. 29 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/dto/DmModbusDriveQueryCriteria.java
  31. 114 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/impl/DmModbusDriveServiceImpl.java
  32. 32 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/mapstruct/DmModbusDriveMapper.java
  33. 70 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/domain/DmModbusGroup.java
  34. 28 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/repository/DmModbusGroupRepository.java
  35. 87 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/rest/DmModbusGroupController.java
  36. 83 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/DmModbusGroupService.java
  37. 53 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/dto/DmModbusGroupDto.java
  38. 37 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/dto/DmModbusGroupQueryCriteria.java
  39. 113 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/impl/DmModbusGroupServiceImpl.java
  40. 32 0
      eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/mapstruct/DmModbusGroupMapper.java

+ 105 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/domain/DmModbusChannel.java

@@ -0,0 +1,105 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import javax.persistence.*;
+import javax.persistence.CascadeType;
+import javax.validation.constraints.*;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import me.zhengjie.base.BaseEntity;
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import me.zhengjie.modules.dm.modbus.drive.domain.DmModbusDrive;
+import org.hibernate.annotations.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wanglongda
+* @date 2022-05-20
+**/
+@Entity
+@Data
+@Table(name="dm_modbus_channel")
+public class DmModbusChannel extends BaseEntity implements Serializable {
+
+    @Id
+    @Column(name = "channel_id")
+    @ApiModelProperty(value = "信道id")
+    private Long channelId;
+
+    @Column(name = "channel_name",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "通道名称")
+    private String channelName;
+
+    @Column(name = "serial_port",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "串口参数")
+    private String serialPort;
+
+    @Column(name = "baud_rate",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "波特率")
+    private Long baudRate;
+
+    @Column(name = "data_bits",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "数据位")
+    private String dataBits;
+
+    @Column(name = "stop_bits",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "停止位")
+    private String stopBits;
+
+    @Column(name = "verify_bits",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "校验位")
+    private String verifyBits;
+
+    @Column(name = "stream_control",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "流控制")
+    private String streamControl;
+
+    @Column(name = "timeout",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "超时时间")
+    private Long timeout;
+
+    @Column(name = "drive_id",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "驱动id")
+    private Long driveId;
+
+    @ApiModelProperty(value = "关联的驱动channel_id")
+    @OneToMany(fetch = FetchType.LAZY,cascade = {CascadeType.REFRESH})
+    @JoinColumn(name = "channel_id")
+    private List<DmModbusDevice> dmModbusDevice;
+
+    public void copy(DmModbusChannel source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}

+ 28 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/repository/DmModbusChannelRepository.java

@@ -0,0 +1,28 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.repository;
+
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://el-admin.vip
+* @author wanglongda
+* @date 2022-05-20
+**/
+public interface DmModbusChannelRepository extends JpaRepository<DmModbusChannel, Long>, JpaSpecificationExecutor<DmModbusChannel> {
+}

+ 87 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/rest/DmModbusChannelController.java

@@ -0,0 +1,87 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import me.zhengjie.modules.dm.modbus.channel.service.DmModbusChannelService;
+import me.zhengjie.modules.dm.modbus.channel.service.dto.DmModbusChannelQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @author wanglongda
+* @date 2022-05-20
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "modbus通道管理管理")
+@RequestMapping("/api/dmModbusChannel")
+public class DmModbusChannelController {
+
+    private final DmModbusChannelService dmModbusChannelService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('dmModbusChannel:list')")
+    public void download(HttpServletResponse response, DmModbusChannelQueryCriteria criteria) throws IOException {
+        dmModbusChannelService.download(dmModbusChannelService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询modbus通道管理")
+    @ApiOperation("查询modbus通道管理")
+    @PreAuthorize("@el.check('dmModbusChannel:list')")
+    public ResponseEntity<Object> query(DmModbusChannelQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(dmModbusChannelService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增modbus通道管理")
+    @ApiOperation("新增modbus通道管理")
+    @PreAuthorize("@el.check('dmModbusChannel:add')")
+    public ResponseEntity<Object> create(@Validated @RequestBody DmModbusChannel resources){
+        return new ResponseEntity<>(dmModbusChannelService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改modbus通道管理")
+    @ApiOperation("修改modbus通道管理")
+    @PreAuthorize("@el.check('dmModbusChannel:edit')")
+    public ResponseEntity<Object> update(@Validated @RequestBody DmModbusChannel resources){
+        dmModbusChannelService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @Log("删除modbus通道管理")
+    @ApiOperation("删除modbus通道管理")
+    @PreAuthorize("@el.check('dmModbusChannel:del')")
+    @DeleteMapping
+    public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
+        dmModbusChannelService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}

+ 83 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/DmModbusChannelService.java

@@ -0,0 +1,83 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.service;
+
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import me.zhengjie.modules.dm.modbus.channel.service.dto.DmModbusChannelDto;
+import me.zhengjie.modules.dm.modbus.channel.service.dto.DmModbusChannelQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @description 服务接口
+* @author wanglongda
+* @date 2022-05-20
+**/
+public interface DmModbusChannelService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(DmModbusChannelQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<DmModbusChannelDto>
+    */
+    List<DmModbusChannelDto> queryAll(DmModbusChannelQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param channelId ID
+     * @return DmModbusChannelDto
+     */
+    DmModbusChannelDto findById(Long channelId);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return DmModbusChannelDto
+    */
+    DmModbusChannelDto create(DmModbusChannel resources);
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(DmModbusChannel resources);
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<DmModbusChannelDto> all, HttpServletResponse response) throws IOException;
+}

+ 75 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/dto/DmModbusChannelDto.java

@@ -0,0 +1,75 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.ToStringSerializer;
+import me.zhengjie.base.BaseDTO;
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import me.zhengjie.modules.dm.modbus.drive.domain.DmModbusDrive;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wanglongda
+* @date 2022-05-20
+**/
+@Data
+public class DmModbusChannelDto extends BaseDTO implements Serializable {
+
+    /** 信道id */
+    /** 防止精度丢失 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long channelId;
+
+    /** 通道名称 */
+    private String channelName;
+
+    /** 串口参数 */
+    private String serialPort;
+
+    /** 波特率 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long baudRate;
+
+    /** 数据位 */
+    private String dataBits;
+
+    /** 停止位 */
+    private String stopBits;
+
+    /** 校验位 */
+    private String verifyBits;
+
+    /** 流控制 */
+    private String streamControl;
+
+    /** 超时时间 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long timeout;
+
+    /** 驱动id */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long driveId;
+
+    /** 关联设备id */
+    private List<DmModbusDevice> dmModbusDevice;
+}

+ 49 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/dto/DmModbusChannelQueryCriteria.java

@@ -0,0 +1,49 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://el-admin.vip
+* @author wanglongda
+* @date 2022-05-20
+**/
+@Data
+public class DmModbusChannelQueryCriteria{
+
+    /** 精确 */
+    @Query
+    private Long channelId;
+
+    /** 模糊 */
+    @Query(type = Query.Type.INNER_LIKE)
+    private String channelName;
+
+    /** 精确 */
+    @Query
+    private Long baudRate;
+
+    /** 精确 */
+    @Query(propName = "drive_id",type = Query.Type.EQUAL,joinName = "dmModbusDrive")
+    private Long driveId;
+    /** BETWEEN */
+    @Query(type = Query.Type.BETWEEN)
+    private List<Timestamp> updateTime;
+}

+ 120 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/impl/DmModbusChannelServiceImpl.java

@@ -0,0 +1,120 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.service.impl;
+
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.dm.modbus.channel.repository.DmModbusChannelRepository;
+import me.zhengjie.modules.dm.modbus.channel.service.DmModbusChannelService;
+import me.zhengjie.modules.dm.modbus.channel.service.dto.DmModbusChannelDto;
+import me.zhengjie.modules.dm.modbus.channel.service.dto.DmModbusChannelQueryCriteria;
+import me.zhengjie.modules.dm.modbus.channel.service.mapstruct.DmModbusChannelMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://el-admin.vip
+* @description 服务实现
+* @author wanglongda
+* @date 2022-05-20
+**/
+@Service
+@RequiredArgsConstructor
+public class DmModbusChannelServiceImpl implements DmModbusChannelService {
+
+    private final DmModbusChannelRepository dmModbusChannelRepository;
+    private final DmModbusChannelMapper dmModbusChannelMapper;
+
+    @Override
+    public Map<String,Object> queryAll(DmModbusChannelQueryCriteria criteria, Pageable pageable){
+        Page<DmModbusChannel> page = dmModbusChannelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(dmModbusChannelMapper::toDto));
+    }
+
+    @Override
+    public List<DmModbusChannelDto> queryAll(DmModbusChannelQueryCriteria criteria){
+        return dmModbusChannelMapper.toDto(dmModbusChannelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public DmModbusChannelDto findById(Long channelId) {
+        DmModbusChannel dmModbusChannel = dmModbusChannelRepository.findById(channelId).orElseGet(DmModbusChannel::new);
+        ValidationUtil.isNull(dmModbusChannel.getChannelId(),"DmModbusChannel","channelId",channelId);
+        return dmModbusChannelMapper.toDto(dmModbusChannel);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DmModbusChannelDto create(DmModbusChannel resources) {
+        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
+        resources.setChannelId(snowflake.nextId()); 
+        return dmModbusChannelMapper.toDto(dmModbusChannelRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(DmModbusChannel resources) {
+        DmModbusChannel dmModbusChannel = dmModbusChannelRepository.findById(resources.getChannelId()).orElseGet(DmModbusChannel::new);
+        ValidationUtil.isNull( dmModbusChannel.getChannelId(),"DmModbusChannel","id",resources.getChannelId());
+        dmModbusChannel.copy(resources);
+        dmModbusChannelRepository.save(dmModbusChannel);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long channelId : ids) {
+            dmModbusChannelRepository.deleteById(channelId);
+        }
+    }
+
+    @Override
+    public void download(List<DmModbusChannelDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (DmModbusChannelDto dmModbusChannel : all) {
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("通道名称", dmModbusChannel.getChannelName());
+            map.put("串口参数", dmModbusChannel.getSerialPort());
+            map.put("波特率", dmModbusChannel.getBaudRate());
+            map.put("数据位", dmModbusChannel.getDataBits());
+            map.put("停止位", dmModbusChannel.getStopBits());
+            map.put("校验位", dmModbusChannel.getVerifyBits());
+            map.put("流控制", dmModbusChannel.getStreamControl());
+            map.put("超时时间", dmModbusChannel.getTimeout());
+            map.put("关联驱动id", dmModbusChannel.getDriveId());
+            map.put("创建人", dmModbusChannel.getCreateBy());
+            map.put("更新人", dmModbusChannel.getUpdateBy());
+            map.put("创建时间", dmModbusChannel.getCreateTime());
+            map.put("更新时间", dmModbusChannel.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}

+ 32 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/channel/service/mapstruct/DmModbusChannelMapper.java

@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.channel.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import me.zhengjie.modules.dm.modbus.channel.service.dto.DmModbusChannelDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://el-admin.vip
+* @author wanglongda
+* @date 2022-05-20
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface DmModbusChannelMapper extends BaseMapper<DmModbusChannelDto, DmModbusChannel> {
+
+}

+ 97 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/domain/DmModbusData.java

@@ -0,0 +1,97 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import me.zhengjie.base.BaseEntity;
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+
+import javax.persistence.*;
+import javax.validation.constraints.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-21
+**/
+@Entity
+@Data
+@Table(name="dm_modbus_data")
+public class DmModbusData extends BaseEntity implements Serializable {
+
+    @Id
+    @Column(name = "data_id")
+    @ApiModelProperty(value = "数据id")
+    private Long dataId;
+
+    @Column(name = "call_the_roll",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "采集端(硬件)点名")
+    private String callTheRoll;
+
+    @Column(name = "describe")
+    @ApiModelProperty(value = "采集端描述")
+    private String describe;
+
+    @Column(name = "data_type",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "采集端数据类型")
+    private String dataType;
+
+    @Column(name = "hardware_register_type",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "采集端寄存器类型")
+    private String hardwareRegisterType;
+
+    @Column(name = "hardware_register_address",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "采集端寄存器地址")
+    private String hardwareRegisterAddress;
+
+    @Column(name = "is_fetch_bit")
+    @ApiModelProperty(value = "采集端启用取位用逗号分隔")
+    private String isFetchBit;
+
+    @Column(name = "linear_conversion_id")
+    @ApiModelProperty(value = "采集端关联线性转换id")
+    private Long linearConversionId;
+
+    @Column(name = "software_register_type",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "转发端(软件)寄存器类型")
+    private String softwareRegisterType;
+
+    @Column(name = "software_register_address",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "转发端(软件)寄存器地址")
+    private String softwareRegisterAddress;
+
+    @Column(name = "group_id",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "转发端(软件)寄存器地址")
+    private Long groupId;
+
+    public void copy(DmModbusData source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}

+ 28 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/repository/DmModbusDataRepository.java

@@ -0,0 +1,28 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.repository;
+
+import me.zhengjie.modules.dm.modbus.data.domain.DmModbusData;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+public interface DmModbusDataRepository extends JpaRepository<DmModbusData, Long>, JpaSpecificationExecutor<DmModbusData> {
+}

+ 87 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/rest/DmModbusDataController.java

@@ -0,0 +1,87 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.dm.modbus.data.domain.DmModbusData;
+import me.zhengjie.modules.dm.modbus.data.service.DmModbusDataService;
+import me.zhengjie.modules.dm.modbus.data.service.dto.DmModbusDataQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "分组下的数据管理管理")
+@RequestMapping("/api/dmModbusData")
+public class DmModbusDataController {
+
+    private final DmModbusDataService dmModbusDataService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('dmModbusData:list')")
+    public void download(HttpServletResponse response, DmModbusDataQueryCriteria criteria) throws IOException {
+        dmModbusDataService.download(dmModbusDataService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询分组下的数据管理")
+    @ApiOperation("查询分组下的数据管理")
+    @PreAuthorize("@el.check('dmModbusData:list')")
+    public ResponseEntity<Object> query(DmModbusDataQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(dmModbusDataService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增分组下的数据管理")
+    @ApiOperation("新增分组下的数据管理")
+    @PreAuthorize("@el.check('dmModbusData:add')")
+    public ResponseEntity<Object> create(@Validated @RequestBody DmModbusData resources){
+        return new ResponseEntity<>(dmModbusDataService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改分组下的数据管理")
+    @ApiOperation("修改分组下的数据管理")
+    @PreAuthorize("@el.check('dmModbusData:edit')")
+    public ResponseEntity<Object> update(@Validated @RequestBody DmModbusData resources){
+        dmModbusDataService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @Log("删除分组下的数据管理")
+    @ApiOperation("删除分组下的数据管理")
+    @PreAuthorize("@el.check('dmModbusData:del')")
+    @DeleteMapping
+    public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
+        dmModbusDataService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}

+ 83 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/DmModbusDataService.java

@@ -0,0 +1,83 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.service;
+
+import me.zhengjie.modules.dm.modbus.data.domain.DmModbusData;
+import me.zhengjie.modules.dm.modbus.data.service.dto.DmModbusDataDto;
+import me.zhengjie.modules.dm.modbus.data.service.dto.DmModbusDataQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @description 服务接口
+* @author wld
+* @date 2022-05-21
+**/
+public interface DmModbusDataService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(DmModbusDataQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<DmModbusDataDto>
+    */
+    List<DmModbusDataDto> queryAll(DmModbusDataQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param dataId ID
+     * @return DmModbusDataDto
+     */
+    DmModbusDataDto findById(Long dataId);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return DmModbusDataDto
+    */
+    DmModbusDataDto create(DmModbusData resources);
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(DmModbusData resources);
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<DmModbusDataDto> all, HttpServletResponse response) throws IOException;
+}

+ 72 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/dto/DmModbusDataDto.java

@@ -0,0 +1,72 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.ToStringSerializer;
+import me.zhengjie.base.BaseDTO;
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-21
+**/
+@Data
+public class DmModbusDataDto extends BaseDTO implements Serializable {
+
+    /** 数据id */
+    /** 防止精度丢失 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long dataId;
+
+    /** 采集端(硬件)点名 */
+    private String callTheRoll;
+
+    /** 采集端描述 */
+    private String describe;
+
+    /** 采集端数据类型 */
+    private String dataType;
+
+    /** 采集端寄存器类型 */
+    private String hardwareRegisterType;
+
+    /** 采集端寄存器地址 */
+    private String hardwareRegisterAddress;
+
+    /** 采集端启用取位用逗号分隔 */
+    private String isFetchBit;
+
+    /** 采集端关联线性转换id */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long linearConversionId;
+
+    /** 转发端(软件)寄存器类型 */
+    private String softwareRegisterType;
+
+    /** 转发端(软件)寄存器地址 */
+    private String softwareRegisterAddress;
+
+    /** 关联分组id */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long groupId;
+
+}

+ 45 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/dto/DmModbusDataQueryCriteria.java

@@ -0,0 +1,45 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+@Data
+public class DmModbusDataQueryCriteria{
+
+    /** 精确 */
+    @Query
+    private Long dataId;
+
+    /** 模糊 */
+    @Query(type = Query.Type.INNER_LIKE)
+    private String callTheRoll;
+
+    /** 精确 */
+    @Query
+    private Long groupId;
+    /** BETWEEN */
+    @Query(type = Query.Type.BETWEEN)
+    private List<Timestamp> updateTime;
+}

+ 121 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/impl/DmModbusDataServiceImpl.java

@@ -0,0 +1,121 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.service.impl;
+
+import me.zhengjie.modules.dm.modbus.data.domain.DmModbusData;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.dm.modbus.data.repository.DmModbusDataRepository;
+import me.zhengjie.modules.dm.modbus.data.service.DmModbusDataService;
+import me.zhengjie.modules.dm.modbus.data.service.dto.DmModbusDataDto;
+import me.zhengjie.modules.dm.modbus.data.service.dto.DmModbusDataQueryCriteria;
+import me.zhengjie.modules.dm.modbus.data.service.mapstruct.DmModbusDataMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://el-admin.vip
+* @description 服务实现
+* @author wld
+* @date 2022-05-21
+**/
+@Service
+@RequiredArgsConstructor
+public class DmModbusDataServiceImpl implements DmModbusDataService {
+
+    private final DmModbusDataRepository dmModbusDataRepository;
+    private final DmModbusDataMapper dmModbusDataMapper;
+
+    @Override
+    public Map<String,Object> queryAll(DmModbusDataQueryCriteria criteria, Pageable pageable){
+        Page<DmModbusData> page = dmModbusDataRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(dmModbusDataMapper::toDto));
+    }
+
+    @Override
+    public List<DmModbusDataDto> queryAll(DmModbusDataQueryCriteria criteria){
+        return dmModbusDataMapper.toDto(dmModbusDataRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public DmModbusDataDto findById(Long dataId) {
+        DmModbusData dmModbusData = dmModbusDataRepository.findById(dataId).orElseGet(DmModbusData::new);
+        ValidationUtil.isNull(dmModbusData.getDataId(),"DmModbusData","dataId",dataId);
+        return dmModbusDataMapper.toDto(dmModbusData);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DmModbusDataDto create(DmModbusData resources) {
+        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
+        resources.setDataId(snowflake.nextId()); 
+        return dmModbusDataMapper.toDto(dmModbusDataRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(DmModbusData resources) {
+        DmModbusData dmModbusData = dmModbusDataRepository.findById(resources.getDataId()).orElseGet(DmModbusData::new);
+        ValidationUtil.isNull( dmModbusData.getDataId(),"DmModbusData","id",resources.getDataId());
+        dmModbusData.copy(resources);
+        dmModbusDataRepository.save(dmModbusData);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long dataId : ids) {
+            dmModbusDataRepository.deleteById(dataId);
+        }
+    }
+
+    @Override
+    public void download(List<DmModbusDataDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (DmModbusDataDto dmModbusData : all) {
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("采集端(硬件)点名", dmModbusData.getCallTheRoll());
+            map.put("采集端描述", dmModbusData.getDescribe());
+            map.put("采集端数据类型", dmModbusData.getDataType());
+            map.put("采集端寄存器类型", dmModbusData.getHardwareRegisterType());
+            map.put("采集端寄存器地址", dmModbusData.getHardwareRegisterAddress());
+            map.put("采集端启用取位用逗号分隔", dmModbusData.getIsFetchBit());
+            map.put("采集端关联线性转换id", dmModbusData.getLinearConversionId());
+            map.put("转发端(软件)寄存器类型", dmModbusData.getSoftwareRegisterType());
+            map.put("转发端(软件)寄存器地址", dmModbusData.getSoftwareRegisterAddress());
+            map.put("创建人", dmModbusData.getCreateBy());
+            map.put("更新人", dmModbusData.getUpdateBy());
+            map.put("创建时间", dmModbusData.getCreateTime());
+            map.put("更新时间", dmModbusData.getUpdateTime());
+            map.put("关联分组id", dmModbusData.getGroupId());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}

+ 32 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/data/service/mapstruct/DmModbusDataMapper.java

@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.data.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.dm.modbus.data.domain.DmModbusData;
+import me.zhengjie.modules.dm.modbus.data.service.dto.DmModbusDataDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface DmModbusDataMapper extends BaseMapper<DmModbusDataDto, DmModbusData> {
+
+}

+ 125 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/domain/DmModbusDevice.java

@@ -0,0 +1,125 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import javax.persistence.*;
+import javax.persistence.CascadeType;
+import javax.validation.constraints.*;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import me.zhengjie.base.BaseEntity;
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+import org.hibernate.annotations.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-20
+**/
+@Entity
+@Data
+@Table(name="dm_modbus_device")
+public class DmModbusDevice extends BaseEntity implements Serializable {
+
+    @Id
+    @Column(name = "device_id")
+    @ApiModelProperty(value = "设备id")
+    private Long deviceId;
+
+    @Column(name = "device_name",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+
+    @Column(name = "salve_station_number",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "从站站号")
+    private Long salveStationNumber;
+
+    @Column(name = "station_number",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "采集通讯站号")
+    private Long stationNumber;
+
+    @Column(name = "Request_frame_interval",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "采集通讯请求帧间隔(毫秒)")
+    private Long requestFrameInterval;
+
+    @Column(name = "write_value_refresh_interval",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "采集通讯写值刷新间隔(毫秒)")
+    private Long writeValueRefreshInterval;
+
+    @Column(name = "two_byte_int_order",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "采集通讯2字节整数顺序")
+    private String twoByteIntOrder;
+
+    @Column(name = "four_byte_int_order",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "采集通讯4字节整数顺序")
+    private String fourByteIntOrder;
+
+    @Column(name = "float_order",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "单精度浮点数顺序")
+    private String floatOrder;
+
+    @Column(name = "analog_quantity_group_packet_interval",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "批量传输模拟量组包间隔")
+    private String analogQuantityGroupPacketInterval;
+
+    @Column(name = "analog_quantity_group_packet_max_length",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "批量传输模拟量组包最大长度")
+    private Long analogQuantityGroupPacketMaxlength;
+
+    @Column(name = "digital_quantity_group_packet_interval",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "批量传输数字量组包间隔")
+    private Long digitalQuantityGroupPacketInterval;
+
+    @Column(name = "digital_quantity_group_packet_max_length",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "批量传输数字量组包最大长度")
+    private Long digitalQuantityGroupPacketMaxlength;
+
+    @Column(name = "channel_id",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "信道id")
+    private Long channelId;
+
+    @ApiModelProperty(value = "关联的分组")
+    @OneToMany(fetch = FetchType.LAZY,cascade = {CascadeType.REFRESH})
+    @JoinColumn(name = "device_id")
+    private List<DmModbusGroup> dmModbusGroup;
+
+    public void copy(DmModbusDevice source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}

+ 28 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/repository/DmModbusDeviceRepository.java

@@ -0,0 +1,28 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.repository;
+
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+public interface DmModbusDeviceRepository extends JpaRepository<DmModbusDevice, Long>, JpaSpecificationExecutor<DmModbusDevice> {
+}

+ 87 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/rest/DmModbusDeviceController.java

@@ -0,0 +1,87 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import me.zhengjie.modules.dm.modbus.device.service.DmModbusDeviceService;
+import me.zhengjie.modules.dm.modbus.device.service.dto.DmModbusDeviceQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "通道下的设备管理管理")
+@RequestMapping("/api/dmModbusDevice")
+public class DmModbusDeviceController {
+
+    private final DmModbusDeviceService dmModbusDeviceService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('dmModbusDevice:list')")
+    public void download(HttpServletResponse response, DmModbusDeviceQueryCriteria criteria) throws IOException {
+        dmModbusDeviceService.download(dmModbusDeviceService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询通道下的设备管理")
+    @ApiOperation("查询通道下的设备管理")
+    @PreAuthorize("@el.check('dmModbusDevice:list')")
+    public ResponseEntity<Object> query(DmModbusDeviceQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(dmModbusDeviceService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增通道下的设备管理")
+    @ApiOperation("新增通道下的设备管理")
+    @PreAuthorize("@el.check('dmModbusDevice:add')")
+    public ResponseEntity<Object> create(@Validated @RequestBody DmModbusDevice resources){
+        return new ResponseEntity<>(dmModbusDeviceService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改通道下的设备管理")
+    @ApiOperation("修改通道下的设备管理")
+    @PreAuthorize("@el.check('dmModbusDevice:edit')")
+    public ResponseEntity<Object> update(@Validated @RequestBody DmModbusDevice resources){
+        dmModbusDeviceService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @Log("删除通道下的设备管理")
+    @ApiOperation("删除通道下的设备管理")
+    @PreAuthorize("@el.check('dmModbusDevice:del')")
+    @DeleteMapping
+    public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
+        dmModbusDeviceService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}

+ 83 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/DmModbusDeviceService.java

@@ -0,0 +1,83 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.service;
+
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import me.zhengjie.modules.dm.modbus.device.service.dto.DmModbusDeviceDto;
+import me.zhengjie.modules.dm.modbus.device.service.dto.DmModbusDeviceQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @description 服务接口
+* @author wld
+* @date 2022-05-20
+**/
+public interface DmModbusDeviceService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(DmModbusDeviceQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<DmModbusDeviceDto>
+    */
+    List<DmModbusDeviceDto> queryAll(DmModbusDeviceQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param deviceId ID
+     * @return DmModbusDeviceDto
+     */
+    DmModbusDeviceDto findById(Long deviceId);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return DmModbusDeviceDto
+    */
+    DmModbusDeviceDto create(DmModbusDevice resources);
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(DmModbusDevice resources);
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<DmModbusDeviceDto> all, HttpServletResponse response) throws IOException;
+}

+ 92 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/dto/DmModbusDeviceDto.java

@@ -0,0 +1,92 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.ToStringSerializer;
+import me.zhengjie.base.BaseDTO;
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-20
+**/
+@Data
+public class DmModbusDeviceDto extends BaseDTO implements Serializable {
+
+    /** 设备id */
+    /** 防止精度丢失 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long deviceId;
+
+    /** 设备名称 */
+    private String deviceName;
+
+    /** 从站站号 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long salveStationNumber;
+
+    /** 采集通讯站号 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long stationNumber;
+
+    /** 采集通讯请求帧间隔(毫秒) */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long requestFrameInterval;
+
+    /** 采集通讯写值刷新间隔(毫秒) */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long writeValueRefreshInterval;
+
+    /** 采集通讯2字节整数顺序 */
+    private String twoByteIntOrder;
+
+    /** 采集通讯4字节整数顺序 */
+    private String fourByteIntOrder;
+
+    /** 单精度浮点数顺序 */
+    private String floatOrder;
+
+    /** 批量传输模拟量组包间隔 */
+    private String analogQuantityGroupPacketInterval;
+
+    /** 批量传输模拟量组包最大长度 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long analogQuantityGroupPacketMaxlength;
+
+    /** 批量传输数字量组包间隔 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long digitalQuantityGroupPacketInterval;
+
+    /** 批量传输数字量组包最大长度 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long digitalQuantityGroupPacketMaxlength;
+
+    /** 信道id */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long channelId;
+
+    /** 关联的分组 */
+    private List<DmModbusGroup> dmModbusGroup;
+}

+ 45 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/dto/DmModbusDeviceQueryCriteria.java

@@ -0,0 +1,45 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+@Data
+public class DmModbusDeviceQueryCriteria{
+
+    /** 精确 */
+    @Query
+    private Long deviceId;
+
+    /** 模糊 */
+    @Query(type = Query.Type.INNER_LIKE)
+    private String deviceName;
+
+    /** 精确 */
+    @Query
+    private Long salveStationNumber;
+    /** BETWEEN */
+    @Query(type = Query.Type.BETWEEN)
+    private List<Timestamp> updateTime;
+}

+ 124 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/impl/DmModbusDeviceServiceImpl.java

@@ -0,0 +1,124 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.service.impl;
+
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.dm.modbus.device.repository.DmModbusDeviceRepository;
+import me.zhengjie.modules.dm.modbus.device.service.DmModbusDeviceService;
+import me.zhengjie.modules.dm.modbus.device.service.dto.DmModbusDeviceDto;
+import me.zhengjie.modules.dm.modbus.device.service.dto.DmModbusDeviceQueryCriteria;
+import me.zhengjie.modules.dm.modbus.device.service.mapstruct.DmModbusDeviceMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://el-admin.vip
+* @description 服务实现
+* @author wld
+* @date 2022-05-20
+**/
+@Service
+@RequiredArgsConstructor
+public class DmModbusDeviceServiceImpl implements DmModbusDeviceService {
+
+    private final DmModbusDeviceRepository dmModbusDeviceRepository;
+    private final DmModbusDeviceMapper dmModbusDeviceMapper;
+
+    @Override
+    public Map<String,Object> queryAll(DmModbusDeviceQueryCriteria criteria, Pageable pageable){
+        Page<DmModbusDevice> page = dmModbusDeviceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(dmModbusDeviceMapper::toDto));
+    }
+
+    @Override
+    public List<DmModbusDeviceDto> queryAll(DmModbusDeviceQueryCriteria criteria){
+        return dmModbusDeviceMapper.toDto(dmModbusDeviceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public DmModbusDeviceDto findById(Long deviceId) {
+        DmModbusDevice dmModbusDevice = dmModbusDeviceRepository.findById(deviceId).orElseGet(DmModbusDevice::new);
+        ValidationUtil.isNull(dmModbusDevice.getDeviceId(),"DmModbusDevice","deviceId",deviceId);
+        return dmModbusDeviceMapper.toDto(dmModbusDevice);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DmModbusDeviceDto create(DmModbusDevice resources) {
+        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
+        resources.setDeviceId(snowflake.nextId()); 
+        return dmModbusDeviceMapper.toDto(dmModbusDeviceRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(DmModbusDevice resources) {
+        DmModbusDevice dmModbusDevice = dmModbusDeviceRepository.findById(resources.getDeviceId()).orElseGet(DmModbusDevice::new);
+        ValidationUtil.isNull( dmModbusDevice.getDeviceId(),"DmModbusDevice","id",resources.getDeviceId());
+        dmModbusDevice.copy(resources);
+        dmModbusDeviceRepository.save(dmModbusDevice);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long deviceId : ids) {
+            dmModbusDeviceRepository.deleteById(deviceId);
+        }
+    }
+
+    @Override
+    public void download(List<DmModbusDeviceDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (DmModbusDeviceDto dmModbusDevice : all) {
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("设备名称", dmModbusDevice.getDeviceName());
+            map.put("从站站号", dmModbusDevice.getSalveStationNumber());
+            map.put("采集通讯站号", dmModbusDevice.getStationNumber());
+            map.put("采集通讯请求帧间隔(毫秒)", dmModbusDevice.getRequestFrameInterval());
+            map.put("采集通讯写值刷新间隔(毫秒)", dmModbusDevice.getWriteValueRefreshInterval());
+            map.put("采集通讯2字节整数顺序", dmModbusDevice.getTwoByteIntOrder());
+            map.put("采集通讯4字节整数顺序", dmModbusDevice.getFourByteIntOrder());
+            map.put("单精度浮点数顺序", dmModbusDevice.getFloatOrder());
+            map.put("批量传输模拟量组包间隔", dmModbusDevice.getAnalogQuantityGroupPacketInterval());
+            map.put("批量传输模拟量组包最大长度", dmModbusDevice.getAnalogQuantityGroupPacketMaxlength());
+            map.put("批量传输数字量组包间隔", dmModbusDevice.getDigitalQuantityGroupPacketInterval());
+            map.put("批量传输数字量组包最大长度", dmModbusDevice.getDigitalQuantityGroupPacketMaxlength());
+            map.put("关联的通道channel_id", dmModbusDevice.getChannelId());
+            map.put("创建人", dmModbusDevice.getCreateBy());
+            map.put("更新人", dmModbusDevice.getUpdateBy());
+            map.put("创建时间", dmModbusDevice.getCreateTime());
+            map.put("更新时间", dmModbusDevice.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}

+ 32 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/device/service/mapstruct/DmModbusDeviceMapper.java

@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.device.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import me.zhengjie.modules.dm.modbus.device.service.dto.DmModbusDeviceDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface DmModbusDeviceMapper extends BaseMapper<DmModbusDeviceDto, DmModbusDevice> {
+
+}

+ 72 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/domain/DmModbusDrive.java

@@ -0,0 +1,72 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import javax.persistence.*;
+import javax.validation.constraints.*;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import me.zhengjie.base.BaseEntity;
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+import org.hibernate.annotations.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-20
+**/
+@Entity
+@Data
+@Table(name="dm_modbus_drive")
+public class DmModbusDrive extends BaseEntity implements Serializable {
+
+    @Id
+    @Column(name = "drive_id")
+    @ApiModelProperty(value = "驱动id")
+    private Long driveId;
+
+    @Column(name = "drive_name",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "驱动名称")
+    private String driveName;
+
+    @Column(name = "name",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "名称")
+    private String name;
+
+    @Column(name = "poll_time",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "轮询时间(毫秒)")
+    private Long pollTime;
+
+    @OneToMany(fetch = FetchType.LAZY)
+    @JoinColumn(name = "drive_id")
+    private List<DmModbusChannel> channels;
+
+    public void copy(DmModbusDrive source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}

+ 28 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/repository/DmModbusDriveRepository.java

@@ -0,0 +1,28 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.repository;
+
+import me.zhengjie.modules.dm.modbus.drive.domain.DmModbusDrive;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+public interface DmModbusDriveRepository extends JpaRepository<DmModbusDrive, Long>, JpaSpecificationExecutor<DmModbusDrive> {
+}

+ 87 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/rest/DmModbusDriveController.java

@@ -0,0 +1,87 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.dm.modbus.drive.domain.DmModbusDrive;
+import me.zhengjie.modules.dm.modbus.drive.service.DmModbusDriveService;
+import me.zhengjie.modules.dm.modbus.drive.service.dto.DmModbusDriveQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "modbus驱动管理管理")
+@RequestMapping("/api/dmModbusDrive")
+public class DmModbusDriveController {
+
+    private final DmModbusDriveService dmModbusDriveService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('dmModbusDrive:list')")
+    public void download(HttpServletResponse response, DmModbusDriveQueryCriteria criteria) throws IOException {
+        dmModbusDriveService.download(dmModbusDriveService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询modbus驱动管理")
+    @ApiOperation("查询modbus驱动管理")
+    @PreAuthorize("@el.check('dmModbusDrive:list')")
+    public ResponseEntity<Object> query(DmModbusDriveQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(dmModbusDriveService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增modbus驱动管理")
+    @ApiOperation("新增modbus驱动管理")
+    @PreAuthorize("@el.check('dmModbusDrive:add')")
+    public ResponseEntity<Object> create(@Validated @RequestBody DmModbusDrive resources){
+        return new ResponseEntity<>(dmModbusDriveService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改modbus驱动管理")
+    @ApiOperation("修改modbus驱动管理")
+    @PreAuthorize("@el.check('dmModbusDrive:edit')")
+    public ResponseEntity<Object> update(@Validated @RequestBody DmModbusDrive resources){
+        dmModbusDriveService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @Log("删除modbus驱动管理")
+    @ApiOperation("删除modbus驱动管理")
+    @PreAuthorize("@el.check('dmModbusDrive:del')")
+    @DeleteMapping
+    public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
+        dmModbusDriveService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}

+ 83 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/DmModbusDriveService.java

@@ -0,0 +1,83 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.service;
+
+import me.zhengjie.modules.dm.modbus.drive.domain.DmModbusDrive;
+import me.zhengjie.modules.dm.modbus.drive.service.dto.DmModbusDriveDto;
+import me.zhengjie.modules.dm.modbus.drive.service.dto.DmModbusDriveQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @description 服务接口
+* @author wld
+* @date 2022-05-20
+**/
+public interface DmModbusDriveService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(DmModbusDriveQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<DmModbusDriveDto>
+    */
+    List<DmModbusDriveDto> queryAll(DmModbusDriveQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param driveId ID
+     * @return DmModbusDriveDto
+     */
+    DmModbusDriveDto findById(Long driveId);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return DmModbusDriveDto
+    */
+    DmModbusDriveDto create(DmModbusDrive resources);
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(DmModbusDrive resources);
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<DmModbusDriveDto> all, HttpServletResponse response) throws IOException;
+}

+ 52 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/dto/DmModbusDriveDto.java

@@ -0,0 +1,52 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.ToStringSerializer;
+import me.zhengjie.base.BaseDTO;
+import me.zhengjie.modules.dm.modbus.channel.domain.DmModbusChannel;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-20
+**/
+@Data
+public class DmModbusDriveDto extends BaseDTO implements Serializable {
+
+    /** 驱动id */
+    /** 防止精度丢失 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long driveId;
+
+    /** 驱动名称 */
+    private String driveName;
+
+    /** 名称 */
+    private String name;
+
+    /** 轮询时间(毫秒) */
+    private Long pollTime;
+    /** 关联的信道  */
+    private List<DmModbusChannel> channels;
+}

+ 29 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/dto/DmModbusDriveQueryCriteria.java

@@ -0,0 +1,29 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.service.dto;
+
+import lombok.Data;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+@Data
+public class DmModbusDriveQueryCriteria{
+}

+ 114 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/impl/DmModbusDriveServiceImpl.java

@@ -0,0 +1,114 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.service.impl;
+
+import me.zhengjie.modules.dm.modbus.drive.domain.DmModbusDrive;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.dm.modbus.drive.repository.DmModbusDriveRepository;
+import me.zhengjie.modules.dm.modbus.drive.service.DmModbusDriveService;
+import me.zhengjie.modules.dm.modbus.drive.service.dto.DmModbusDriveDto;
+import me.zhengjie.modules.dm.modbus.drive.service.dto.DmModbusDriveQueryCriteria;
+import me.zhengjie.modules.dm.modbus.drive.service.mapstruct.DmModbusDriveMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://el-admin.vip
+* @description 服务实现
+* @author wld
+* @date 2022-05-20
+**/
+@Service
+@RequiredArgsConstructor
+public class DmModbusDriveServiceImpl implements DmModbusDriveService {
+
+    private final DmModbusDriveRepository dmModbusDriveRepository;
+    private final DmModbusDriveMapper dmModbusDriveMapper;
+
+    @Override
+    public Map<String,Object> queryAll(DmModbusDriveQueryCriteria criteria, Pageable pageable){
+        Page<DmModbusDrive> page = dmModbusDriveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(dmModbusDriveMapper::toDto));
+    }
+
+    @Override
+    public List<DmModbusDriveDto> queryAll(DmModbusDriveQueryCriteria criteria){
+        return dmModbusDriveMapper.toDto(dmModbusDriveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public DmModbusDriveDto findById(Long driveId) {
+        DmModbusDrive dmModbusDrive = dmModbusDriveRepository.findById(driveId).orElseGet(DmModbusDrive::new);
+        ValidationUtil.isNull(dmModbusDrive.getDriveId(),"DmModbusDrive","driveId",driveId);
+        return dmModbusDriveMapper.toDto(dmModbusDrive);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DmModbusDriveDto create(DmModbusDrive resources) {
+        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
+        resources.setDriveId(snowflake.nextId()); 
+        return dmModbusDriveMapper.toDto(dmModbusDriveRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(DmModbusDrive resources) {
+        DmModbusDrive dmModbusDrive = dmModbusDriveRepository.findById(resources.getDriveId()).orElseGet(DmModbusDrive::new);
+        ValidationUtil.isNull( dmModbusDrive.getDriveId(),"DmModbusDrive","id",resources.getDriveId());
+        dmModbusDrive.copy(resources);
+        dmModbusDriveRepository.save(dmModbusDrive);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long driveId : ids) {
+            dmModbusDriveRepository.deleteById(driveId);
+        }
+    }
+
+    @Override
+    public void download(List<DmModbusDriveDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (DmModbusDriveDto dmModbusDrive : all) {
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("驱动名称", dmModbusDrive.getDriveName());
+            map.put("名称", dmModbusDrive.getName());
+            map.put("轮询时间(毫秒)", dmModbusDrive.getPollTime());
+            map.put("创建人", dmModbusDrive.getCreateBy());
+            map.put("更新人", dmModbusDrive.getUpdateBy());
+            map.put("创建时间", dmModbusDrive.getCreateTime());
+            map.put("更新时间", dmModbusDrive.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}

+ 32 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/drive/service/mapstruct/DmModbusDriveMapper.java

@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.drive.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.dm.modbus.drive.domain.DmModbusDrive;
+import me.zhengjie.modules.dm.modbus.drive.service.dto.DmModbusDriveDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-20
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface DmModbusDriveMapper extends BaseMapper<DmModbusDriveDto, DmModbusDrive> {
+
+}

+ 70 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/domain/DmModbusGroup.java

@@ -0,0 +1,70 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import javax.persistence.*;
+import javax.persistence.CascadeType;
+import javax.validation.constraints.*;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import me.zhengjie.base.BaseEntity;
+import me.zhengjie.modules.dm.modbus.data.domain.DmModbusData;
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+import org.hibernate.annotations.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-21
+**/
+@Entity
+@Data
+@Table(name="dm_modbus_group")
+public class DmModbusGroup extends BaseEntity implements Serializable {
+
+    @Id
+    @Column(name = "group_id")
+    @ApiModelProperty(value = "组id")
+    private Long groupId;
+
+    @Column(name = "group_name",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "组名称")
+    private String groupName;
+
+    @Column(name = "device_id",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "设备关联id")
+    private Long deviceId;
+
+    @ApiModelProperty(value = "通过分组id关联数据")
+    @OneToMany(fetch = FetchType.LAZY,cascade = {CascadeType.REFRESH})
+    @JoinColumn(name = "group_id")
+    private List<DmModbusData> dmModbusData;
+
+    public void copy(DmModbusGroup source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}

+ 28 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/repository/DmModbusGroupRepository.java

@@ -0,0 +1,28 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.repository;
+
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+public interface DmModbusGroupRepository extends JpaRepository<DmModbusGroup, Long>, JpaSpecificationExecutor<DmModbusGroup> {
+}

+ 87 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/rest/DmModbusGroupController.java

@@ -0,0 +1,87 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+import me.zhengjie.modules.dm.modbus.group.service.DmModbusGroupService;
+import me.zhengjie.modules.dm.modbus.group.service.dto.DmModbusGroupQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "分组管理管理")
+@RequestMapping("/api/dmModbusGroup")
+public class DmModbusGroupController {
+
+    private final DmModbusGroupService dmModbusGroupService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('dmModbusGroup:list')")
+    public void download(HttpServletResponse response, DmModbusGroupQueryCriteria criteria) throws IOException {
+        dmModbusGroupService.download(dmModbusGroupService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询分组管理")
+    @ApiOperation("查询分组管理")
+    @PreAuthorize("@el.check('dmModbusGroup:list')")
+    public ResponseEntity<Object> query(DmModbusGroupQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(dmModbusGroupService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增分组管理")
+    @ApiOperation("新增分组管理")
+    @PreAuthorize("@el.check('dmModbusGroup:add')")
+    public ResponseEntity<Object> create(@Validated @RequestBody DmModbusGroup resources){
+        return new ResponseEntity<>(dmModbusGroupService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改分组管理")
+    @ApiOperation("修改分组管理")
+    @PreAuthorize("@el.check('dmModbusGroup:edit')")
+    public ResponseEntity<Object> update(@Validated @RequestBody DmModbusGroup resources){
+        dmModbusGroupService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @Log("删除分组管理")
+    @ApiOperation("删除分组管理")
+    @PreAuthorize("@el.check('dmModbusGroup:del')")
+    @DeleteMapping
+    public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
+        dmModbusGroupService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}

+ 83 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/DmModbusGroupService.java

@@ -0,0 +1,83 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.service;
+
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+import me.zhengjie.modules.dm.modbus.group.service.dto.DmModbusGroupDto;
+import me.zhengjie.modules.dm.modbus.group.service.dto.DmModbusGroupQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://el-admin.vip
+* @description 服务接口
+* @author wld
+* @date 2022-05-21
+**/
+public interface DmModbusGroupService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(DmModbusGroupQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<DmModbusGroupDto>
+    */
+    List<DmModbusGroupDto> queryAll(DmModbusGroupQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param groupId ID
+     * @return DmModbusGroupDto
+     */
+    DmModbusGroupDto findById(Long groupId);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return DmModbusGroupDto
+    */
+    DmModbusGroupDto create(DmModbusGroup resources);
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(DmModbusGroup resources);
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<DmModbusGroupDto> all, HttpServletResponse response) throws IOException;
+}

+ 53 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/dto/DmModbusGroupDto.java

@@ -0,0 +1,53 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.alibaba.fastjson.serializer.ToStringSerializer;
+import me.zhengjie.base.BaseDTO;
+import me.zhengjie.modules.dm.modbus.data.domain.DmModbusData;
+import me.zhengjie.modules.dm.modbus.device.domain.DmModbusDevice;
+
+/**
+* @website https://el-admin.vip
+* @description /
+* @author wld
+* @date 2022-05-21
+**/
+@Data
+public class DmModbusGroupDto extends BaseDTO implements Serializable {
+
+    /** 组id */
+    /** 防止精度丢失 */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long groupId;
+
+    /** 组名称 */
+    private String groupName;
+
+    /** 设备id */
+    @JSONField(serializeUsing = ToStringSerializer.class)
+    private Long deviceId;
+
+    /** 通过分组id关联数据 */
+    private List<DmModbusData> dmModbusData;
+
+}

+ 37 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/dto/DmModbusGroupQueryCriteria.java

@@ -0,0 +1,37 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.service.dto;
+
+import lombok.Data;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+@Data
+public class DmModbusGroupQueryCriteria{
+
+    /** 模糊 */
+    @Query(type = Query.Type.INNER_LIKE)
+    private String groupName;
+
+    /** 精确 */
+    @Query
+    private Long deviceId;
+}

+ 113 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/impl/DmModbusGroupServiceImpl.java

@@ -0,0 +1,113 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.service.impl;
+
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.dm.modbus.group.repository.DmModbusGroupRepository;
+import me.zhengjie.modules.dm.modbus.group.service.DmModbusGroupService;
+import me.zhengjie.modules.dm.modbus.group.service.dto.DmModbusGroupDto;
+import me.zhengjie.modules.dm.modbus.group.service.dto.DmModbusGroupQueryCriteria;
+import me.zhengjie.modules.dm.modbus.group.service.mapstruct.DmModbusGroupMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://el-admin.vip
+* @description 服务实现
+* @author wld
+* @date 2022-05-21
+**/
+@Service
+@RequiredArgsConstructor
+public class DmModbusGroupServiceImpl implements DmModbusGroupService {
+
+    private final DmModbusGroupRepository dmModbusGroupRepository;
+    private final DmModbusGroupMapper dmModbusGroupMapper;
+
+    @Override
+    public Map<String,Object> queryAll(DmModbusGroupQueryCriteria criteria, Pageable pageable){
+        Page<DmModbusGroup> page = dmModbusGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(dmModbusGroupMapper::toDto));
+    }
+
+    @Override
+    public List<DmModbusGroupDto> queryAll(DmModbusGroupQueryCriteria criteria){
+        return dmModbusGroupMapper.toDto(dmModbusGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public DmModbusGroupDto findById(Long groupId) {
+        DmModbusGroup dmModbusGroup = dmModbusGroupRepository.findById(groupId).orElseGet(DmModbusGroup::new);
+        ValidationUtil.isNull(dmModbusGroup.getGroupId(),"DmModbusGroup","groupId",groupId);
+        return dmModbusGroupMapper.toDto(dmModbusGroup);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public DmModbusGroupDto create(DmModbusGroup resources) {
+        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
+        resources.setGroupId(snowflake.nextId()); 
+        return dmModbusGroupMapper.toDto(dmModbusGroupRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(DmModbusGroup resources) {
+        DmModbusGroup dmModbusGroup = dmModbusGroupRepository.findById(resources.getGroupId()).orElseGet(DmModbusGroup::new);
+        ValidationUtil.isNull( dmModbusGroup.getGroupId(),"DmModbusGroup","id",resources.getGroupId());
+        dmModbusGroup.copy(resources);
+        dmModbusGroupRepository.save(dmModbusGroup);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long groupId : ids) {
+            dmModbusGroupRepository.deleteById(groupId);
+        }
+    }
+
+    @Override
+    public void download(List<DmModbusGroupDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (DmModbusGroupDto dmModbusGroup : all) {
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("组名称", dmModbusGroup.getGroupName());
+            map.put("关联设备id", dmModbusGroup.getDeviceId());
+            map.put("创建人", dmModbusGroup.getCreateBy());
+            map.put("更新人", dmModbusGroup.getUpdateBy());
+            map.put("创建时间", dmModbusGroup.getCreateTime());
+            map.put("更新时间", dmModbusGroup.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}

+ 32 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/modbus/group/service/mapstruct/DmModbusGroupMapper.java

@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.dm.modbus.group.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.dm.modbus.group.domain.DmModbusGroup;
+import me.zhengjie.modules.dm.modbus.group.service.dto.DmModbusGroupDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://el-admin.vip
+* @author wld
+* @date 2022-05-21
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface DmModbusGroupMapper extends BaseMapper<DmModbusGroupDto, DmModbusGroup> {
+
+}