From 13cec6586bff554f847b8422ff25e114a8665317 Mon Sep 17 00:00:00 2001 From: qinjie <463333974@qq.com> Date: Mon, 25 Nov 2024 01:04:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DeviceController.java | 106 ++++++++++++++++++ .../controller/GasWellController.java | 10 -- .../com/isu/gaswellwatch/dao/DeviceDao.java | 23 ++++ .../com/isu/gaswellwatch/dao/GasWellDao.java | 4 + .../isu/gaswellwatch/dto/DeviceCreateDTO.java | 54 +++++++++ .../isu/gaswellwatch/dto/DeviceEditDTO.java | 40 +++++++ .../com/isu/gaswellwatch/entity/Device.java | 56 +++++++++ .../gaswellwatch/service/DeviceService.java | 29 +++++ .../gaswellwatch/service/GasWellService.java | 10 ++ .../service/impl/DeviceServiceImpl.java | 102 +++++++++++++++++ .../service/impl/GasWellServiceImpl.java | 11 ++ src/main/resources/mapper/DeviceDao.xml | 48 ++++++++ src/main/resources/mapper/GasWellMapper.xml | 8 ++ 13 files changed, 491 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/isu/gaswellwatch/controller/DeviceController.java create mode 100644 src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java create mode 100644 src/main/java/com/isu/gaswellwatch/dto/DeviceCreateDTO.java create mode 100644 src/main/java/com/isu/gaswellwatch/dto/DeviceEditDTO.java create mode 100644 src/main/java/com/isu/gaswellwatch/entity/Device.java create mode 100644 src/main/java/com/isu/gaswellwatch/service/DeviceService.java create mode 100644 src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java create mode 100644 src/main/resources/mapper/DeviceDao.xml diff --git a/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java b/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java new file mode 100644 index 0000000..75b268a --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/controller/DeviceController.java @@ -0,0 +1,106 @@ +package com.isu.gaswellwatch.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.isu.gaswellwatch.annotation.OperationLog; +import com.isu.gaswellwatch.dto.DeviceCreateDTO; +import com.isu.gaswellwatch.dto.DeviceEditDTO; +import com.isu.gaswellwatch.entity.Device; +import com.isu.gaswellwatch.entity.Response; +import com.isu.gaswellwatch.enums.LogType; +import com.isu.gaswellwatch.service.DeviceService; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + * 设备管理 + * + * @author scwsl + * @date 2024-11-17 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/device") +public class DeviceController { + + private final DeviceService deviceService; + + /** + * 查询设备列表 + */ + @GetMapping(value = "/page") + public Response> page(@RequestParam(defaultValue = "1") Integer currentPage, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String gasWellName, + @RequestParam(required = false) String gasStationName, + @RequestParam Long deviceTypeId) { + return Response.succeed(deviceService.page(currentPage, pageSize, gasWellName,gasStationName,deviceTypeId)); + } + + /** + * 获取设备基础信息 + */ + @GetMapping(value = "/getDevice") + public Response getDevice(@RequestParam Long id) { + return Response.succeed(deviceService.getDevice(id)); + } + + /** + *新增设备 + */ + @PostMapping(value = "/add") + @OperationLog(description = "新增设备", type = LogType.ADD) + public Response add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) { + deviceService.add(deviceCreateDTO); + return Response.succeed(); + } + + /** + * 修改设备 + */ + @PostMapping("/edit") + @OperationLog(description = "修改设备", type = LogType.UPDATE) + public Response edit(@RequestBody @Valid DeviceEditDTO deviceEditDTO) { + deviceService.edit(deviceEditDTO); + return Response.succeed(); + } + + /** + * 删除设备 + */ + @GetMapping("/delete") + @OperationLog(description = "删除设备", type = LogType.DELETE) + public Response delete(@RequestParam Long id) { + deviceService.delete(id); + return Response.succeed(); + } + + /** + * 获取设备控制数据 + */ + @GetMapping("/getDeviceControlData") + public Response getDeviceControlData(@RequestParam Long id) { + deviceService.getDeviceControlData(id); + return Response.succeed(); + } + + /** + * 获取设备历史数据 + */ + @GetMapping("/getDeviceHistoryData") + public Response getDeviceHistoryData(@RequestParam Long id) { + deviceService.getDeviceHistoryData(id); + return Response.succeed(); + } + + /** + * 获取设备日志数据 + */ + @GetMapping("/getDeviceLogData") + public Response getDeviceLogData(@RequestParam Long id) { + deviceService.getDeviceLogData(id); + return Response.succeed(); + } + + +} diff --git a/src/main/java/com/isu/gaswellwatch/controller/GasWellController.java b/src/main/java/com/isu/gaswellwatch/controller/GasWellController.java index 0ac8ffe..7e247e9 100644 --- a/src/main/java/com/isu/gaswellwatch/controller/GasWellController.java +++ b/src/main/java/com/isu/gaswellwatch/controller/GasWellController.java @@ -1,16 +1,8 @@ package com.isu.gaswellwatch.controller; -import java.util.Collection; -import java.util.List; - -import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -19,11 +11,9 @@ import com.isu.gaswellwatch.entity.Response; import com.isu.gaswellwatch.enums.LogType; import com.isu.gaswellwatch.dto.GasWellCreateRequest; import com.isu.gaswellwatch.dto.GasWellEditRequest; -import com.isu.gaswellwatch.vo.GasWellPageQuery; import com.isu.gaswellwatch.vo.GasWellVO; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.isu.gaswellwatch.annotation.OperationLog; -import jakarta.annotation.Resource; import jakarta.validation.Valid; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java b/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java new file mode 100644 index 0000000..8f62837 --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/dao/DeviceDao.java @@ -0,0 +1,23 @@ +package com.isu.gaswellwatch.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.isu.gaswellwatch.entity.Department; +import com.isu.gaswellwatch.entity.Device; +import com.isu.gaswellwatch.vo.DepartmentVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +@Mapper +@Repository +public interface DeviceDao extends BaseMapper { + + Page page(Page page, + @Param("gasWellName") String gasWellName, + @Param("gasStationName") String gasStationName, + @Param("deviceTypeId") Long deviceTypeId); + + +} + diff --git a/src/main/java/com/isu/gaswellwatch/dao/GasWellDao.java b/src/main/java/com/isu/gaswellwatch/dao/GasWellDao.java index 1a97add..ec5069c 100644 --- a/src/main/java/com/isu/gaswellwatch/dao/GasWellDao.java +++ b/src/main/java/com/isu/gaswellwatch/dao/GasWellDao.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.isu.gaswellwatch.vo.GasWellVO; @@ -74,4 +75,7 @@ public interface GasWellDao extends BaseMapper { */ int deleteGasWellByIds(Collection ids); + void bindDevice(@Param("gasWellId")Long gasWellId,@Param("deviceId") Long deviceId); + + void unbindDevice(Long id); } diff --git a/src/main/java/com/isu/gaswellwatch/dto/DeviceCreateDTO.java b/src/main/java/com/isu/gaswellwatch/dto/DeviceCreateDTO.java new file mode 100644 index 0000000..b94c62a --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/dto/DeviceCreateDTO.java @@ -0,0 +1,54 @@ +package com.isu.gaswellwatch.dto; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 设备对象 Device + * + * @author scwsl + * @date 2024-11-17 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeviceCreateDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** 设备类型 */ + @NotNull(message = "设备类型不能为空") + private Long deviceType; + + /** 设备编号 */ + @NotBlank(message = "设备编号不能为空") + private String code; + + /** 集气站 */ + private String gasStation; + + /** 设备品牌 */ + @NotNull(message = "设备品牌不能为空") + private Long product; + + /** 网关通讯地址 */ + @NotBlank(message = "网关通讯地址不能为空") + private String gatewaySn; + + /** 描述 */ + private String details; + + /** 所属气井 */ + @NotNull(message = "所属气井不能为空") + private Long gasWell; + + + +} diff --git a/src/main/java/com/isu/gaswellwatch/dto/DeviceEditDTO.java b/src/main/java/com/isu/gaswellwatch/dto/DeviceEditDTO.java new file mode 100644 index 0000000..ea7d69d --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/dto/DeviceEditDTO.java @@ -0,0 +1,40 @@ +package com.isu.gaswellwatch.dto; + +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 设备对象 Device + * + * @author scwsl + * @date 2024-11-17 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class DeviceEditDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** 主键 */ + @NotNull(message = "设备ID不能为空") + private Long id; + + /** 集气站 */ + private String gasStation; + + /** 网关通讯地址 */ + private String gatewaySn; + + /** 描述 */ + private String details; + + + +} diff --git a/src/main/java/com/isu/gaswellwatch/entity/Device.java b/src/main/java/com/isu/gaswellwatch/entity/Device.java new file mode 100644 index 0000000..ffaee17 --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/entity/Device.java @@ -0,0 +1,56 @@ +package com.isu.gaswellwatch.entity; + +import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.isu.gaswellwatch.vo.DepartmentVO; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 设备对象 Device + * + * @author scwsl + * @date 2024-11-17 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Device extends Model { + + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 设备类型 */ + private Dictionary deviceType; + + /** 设备编号 */ + private String code; + + /** 集气站 */ + private String gasStation; + + /** 设备品牌 */ + private Dictionary product; + + /** 网关通讯地址 */ + private String gatewaySn; + + /** 描述 */ + private String details; + + /** 所属气井 */ + private GasWell gasWell; + + /** 创建时间 */ + private String createTime; + + /** 更新时间 */ + private String updateTime; + + + +} diff --git a/src/main/java/com/isu/gaswellwatch/service/DeviceService.java b/src/main/java/com/isu/gaswellwatch/service/DeviceService.java new file mode 100644 index 0000000..3633c9f --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/service/DeviceService.java @@ -0,0 +1,29 @@ +package com.isu.gaswellwatch.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.isu.gaswellwatch.dto.DepartmentDTO; +import com.isu.gaswellwatch.dto.DepartmentEditDTO; +import com.isu.gaswellwatch.dto.DeviceCreateDTO; +import com.isu.gaswellwatch.dto.DeviceEditDTO; +import com.isu.gaswellwatch.entity.Device; + +public interface DeviceService extends IService { + + Page page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId); + + void add(DeviceCreateDTO deviceCreateDTO); + + void edit(DeviceEditDTO deviceEditDTO); + + void delete(Long id); + + Device getDevice(Long id); + + void getDeviceControlData(Long id); + + void getDeviceHistoryData(Long id); + + void getDeviceLogData(Long id); +} + diff --git a/src/main/java/com/isu/gaswellwatch/service/GasWellService.java b/src/main/java/com/isu/gaswellwatch/service/GasWellService.java index 3c8a484..dd16b32 100644 --- a/src/main/java/com/isu/gaswellwatch/service/GasWellService.java +++ b/src/main/java/com/isu/gaswellwatch/service/GasWellService.java @@ -72,4 +72,14 @@ public interface GasWellService extends IService { */ int deleteGasWellByIds(Collection ids); + /** + * 绑定气井设备 + * + * @param gasWellId 气井主键 + * @param deviceId 设备主键 + * @return 结果 + */ + void bindDevice(Long gasWellId, Long deviceId); + + void unbindDevice(Long id); } diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java new file mode 100644 index 0000000..1b57036 --- /dev/null +++ b/src/main/java/com/isu/gaswellwatch/service/impl/DeviceServiceImpl.java @@ -0,0 +1,102 @@ +package com.isu.gaswellwatch.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.isu.gaswellwatch.config.SnowflakeConfig; +import com.isu.gaswellwatch.dao.DepartmentDao; +import com.isu.gaswellwatch.dao.DeviceDao; +import com.isu.gaswellwatch.dto.DepartmentDTO; +import com.isu.gaswellwatch.dto.DepartmentEditDTO; +import com.isu.gaswellwatch.dto.DeviceCreateDTO; +import com.isu.gaswellwatch.dto.DeviceEditDTO; +import com.isu.gaswellwatch.entity.BlockDepartment; +import com.isu.gaswellwatch.entity.Department; +import com.isu.gaswellwatch.entity.Device; +import com.isu.gaswellwatch.exception.BusinessException; +import com.isu.gaswellwatch.service.BlockDepartmentService; +import com.isu.gaswellwatch.service.DepartmentService; +import com.isu.gaswellwatch.service.DeviceService; +import com.isu.gaswellwatch.service.GasWellService; +import com.isu.gaswellwatch.utils.ConverterUtil; +import com.isu.gaswellwatch.vo.DepartmentVO; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service("deviceService") +@Transactional(rollbackFor = Exception.class) +public class DeviceServiceImpl extends ServiceImpl implements DeviceService { + + @Resource + private SnowflakeConfig snowflakeConfig; + + @Resource + private DeviceDao deviceDao; + @Resource + private GasWellService gasWellService; + + @Override + public Page page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName,Long deviceTypeId){ + Page page = deviceDao.page(new Page<>(currentPage, pageSize),gasWellName,gasStationName,deviceTypeId); + + //TODO 从Redis获取设备数据 + + return ConverterUtil.convertPage(page, Device.class); + } + + @Override + public void add(DeviceCreateDTO deviceCreateDTO){ + //查重 + List list = list(new LambdaQueryWrapper().eq(Device::getId, deviceCreateDTO.getCode())); + if(CollectionUtil.isNotEmpty(list)) { + throw new BusinessException("已有相同设备编码,请重新输入"); + } + Device device = ConverterUtil.convert(deviceCreateDTO, Device.class); + //code必须为整形,用于在缓存中查询设备的上报数据 + device.setId(Long.valueOf(deviceCreateDTO.getCode())); + save(device); + + //在气井中绑定设备 + gasWellService.bindDevice(deviceCreateDTO.getGasWell(),device.getId()); + } + + @Override + public void edit(DeviceEditDTO deviceEditDTO){ + updateById(ConverterUtil.convert(deviceEditDTO, Device.class)); + } + + @Override + public void delete(Long id){ + //删除设备 + removeById(id); + //解绑气井 + gasWellService.unbindDevice(id); + } + + @Override + public Device getDevice(Long id) { + return null; + } + + @Override + public void getDeviceControlData(Long id) { + + } + + @Override + public void getDeviceHistoryData(Long id) { + + } + + @Override + public void getDeviceLogData(Long id) { + + } + + +} + diff --git a/src/main/java/com/isu/gaswellwatch/service/impl/GasWellServiceImpl.java b/src/main/java/com/isu/gaswellwatch/service/impl/GasWellServiceImpl.java index dfb287d..50e425e 100644 --- a/src/main/java/com/isu/gaswellwatch/service/impl/GasWellServiceImpl.java +++ b/src/main/java/com/isu/gaswellwatch/service/impl/GasWellServiceImpl.java @@ -134,4 +134,15 @@ public class GasWellServiceImpl extends ServiceImpl implem return gasWellDao.deleteGasWellByIds(ids); } + @Override + public void bindDevice(Long gasWellId, Long deviceId) { + gasWellDao.bindDevice(gasWellId,deviceId); + } + + @Override + public void unbindDevice(Long id) { + gasWellDao.unbindDevice(id); + } + + } diff --git a/src/main/resources/mapper/DeviceDao.xml b/src/main/resources/mapper/DeviceDao.xml new file mode 100644 index 0000000..236dd43 --- /dev/null +++ b/src/main/resources/mapper/DeviceDao.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/GasWellMapper.xml b/src/main/resources/mapper/GasWellMapper.xml index a1d5bdb..1382237 100644 --- a/src/main/resources/mapper/GasWellMapper.xml +++ b/src/main/resources/mapper/GasWellMapper.xml @@ -65,6 +65,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update gas_well set device_id = #{deviceId} where id = #{gasWellId} + + + + update gas_well set device_id = null where id = #{gasWellId} + + delete from gas_well where id = #{id} From 2235da935251dc5ada61c95246b5ff95fd787a43 Mon Sep 17 00:00:00 2001 From: qinjie <463333974@qq.com> Date: Mon, 25 Nov 2024 01:43:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=A1=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/gaswellwatch.sql | 100 ++++++++++++++-------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/src/main/resources/gaswellwatch.sql b/src/main/resources/gaswellwatch.sql index 3776e57..577d954 100644 --- a/src/main/resources/gaswellwatch.sql +++ b/src/main/resources/gaswellwatch.sql @@ -11,7 +11,7 @@ Target Server Version : 80034 File Encoding : 65001 - Date: 23/11/2024 18:48:09 + Date: 25/11/2024 01:42:17 */ SET NAMES utf8mb4; @@ -25,8 +25,8 @@ CREATE TABLE `block` ( `id` bigint NOT NULL COMMENT '主键', `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '名称', `details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='区块管理'; @@ -131,6 +131,31 @@ INSERT INTO `department` (`id`, `name`, `description`, `create_time`, `update_ti INSERT INTO `department` (`id`, `name`, `description`, `create_time`, `update_time`, `code`) VALUES (1859299142728155136, 'dasd', '2', '2024-11-21 02:13:54', '2024-11-21 02:13:54', '2'); COMMIT; +-- ---------------------------- +-- Table structure for device +-- ---------------------------- +DROP TABLE IF EXISTS `device`; +CREATE TABLE `device` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键(取真实设备id)', + `device_type` bigint NOT NULL COMMENT '设备类型', + `code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编号', + `gas_station` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '集气站', + `product` bigint DEFAULT NULL COMMENT '设备品牌', + `gateway_sn` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '网关通讯地址', + `gas_well` bigint DEFAULT NULL COMMENT '气井ID', + `details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE, + KEY `gas_well_index` (`gas_well`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备列表'; + +-- ---------------------------- +-- Records of device +-- ---------------------------- +BEGIN; +COMMIT; + -- ---------------------------- -- Table structure for device_types -- ---------------------------- @@ -147,38 +172,6 @@ CREATE TABLE `device_types` ( BEGIN; COMMIT; --- ---------------------------- --- Table structure for devices --- ---------------------------- -DROP TABLE IF EXISTS `devices`; -CREATE TABLE `devices` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `device_type_id` bigint NOT NULL COMMENT '设备类型', - `code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '设备编号', - `group_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '分组名称', - `product_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '设备品牌', - `address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '通讯地址', - `collection_flag` bit(1) NOT NULL COMMENT '是否采集标志', - `collection_frequency` int NOT NULL DEFAULT '30' COMMENT '采集频率,默认30秒。', - `control_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '控制类型', - `running_mode` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '生产模式,计时器;间开电压', - `status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '状态', - `status_time` datetime NOT NULL COMMENT '状态时间', - `details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已删除', - `create_by` bigint NOT NULL COMMENT '创建人', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_by` bigint NOT NULL COMMENT '更新人', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='设备列表'; - --- ---------------------------- --- Records of devices --- ---------------------------- -BEGIN; -COMMIT; - -- ---------------------------- -- Table structure for dictionary -- ---------------------------- @@ -201,31 +194,36 @@ CREATE TABLE `dictionary` ( -- Records of dictionary -- ---------------------------- BEGIN; -INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (1859896918377758720, 'testType', 'code1', 'name1', '1', 1, '2024-11-22 17:49:15', '2024-11-22 17:49:15'); -INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (1859897057574125568, 'testType', 'code2', 'name2', '2', 2, '2024-11-22 17:49:48', '2024-11-22 17:49:48'); -INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (1859897370766999552, 'testType1', 'code1', 'name1', '1', 1, '2024-11-22 17:51:03', '2024-11-22 17:51:03'); +INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (1, 'deviceType', 'zsqj', '柱塞气举', '1', 1, '2024-11-24 17:31:24', '2024-11-24 17:31:24'); +INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (2, 'deviceType', 'zdjk', '自动间开', '2', 2, '2024-11-24 17:32:23', '2024-11-24 17:32:23'); +INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (3, 'deviceType', 'znpp', '智能泡排', '3', 3, '2024-11-24 17:32:48', '2024-11-24 17:32:48'); +INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (4, 'deviceProduct', 'knpc', 'KNPC', '1', 1, '2024-11-24 17:39:52', '2024-11-24 17:39:52'); +INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (5, 'deviceProduct', 'etc', 'ETC', '2', 2, '2024-11-24 17:40:32', '2024-11-24 17:40:32'); +INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`) VALUES (6, 'deviceProduct', 'scss', '四川双晟', '3', 3, '2024-11-24 17:41:41', '2024-11-24 17:41:41'); COMMIT; -- ---------------------------- --- Table structure for gas_wells +-- Table structure for gas_well -- ---------------------------- -DROP TABLE IF EXISTS `gas_wells`; -CREATE TABLE `gas_wells` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `company_id` bigint DEFAULT NULL COMMENT '关联公司', - `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '气井名称', - `details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述', - `create_by` bigint NOT NULL COMMENT '创建人', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_by` bigint NOT NULL COMMENT '更新人', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - PRIMARY KEY (`id`) USING BTREE +DROP TABLE IF EXISTS `gas_well`; +CREATE TABLE `gas_well` ( + `id` bigint NOT NULL COMMENT '主键', + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '气井名称', + `device_id` bigint DEFAULT NULL COMMENT '关联设备', + `block_id` bigint DEFAULT NULL COMMENT '所属区块ID', + `details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '描述', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='气井管理'; -- ---------------------------- --- Records of gas_wells +-- Records of gas_well -- ---------------------------- BEGIN; +INSERT INTO `gas_well` (`id`, `name`, `device_id`, `block_id`, `details`, `create_time`, `update_time`) VALUES (1860586124699762688, '桃43', NULL, 1860217436825976832, '测试123', '2024-11-24 15:28:01', '2024-11-24 15:28:01'); +INSERT INTO `gas_well` (`id`, `name`, `device_id`, `block_id`, `details`, `create_time`, `update_time`) VALUES (1860588309223309312, '桃47', NULL, 1860217436825976832, '测试13323', '2024-11-24 15:36:35', '2024-11-24 15:36:35'); +INSERT INTO `gas_well` (`id`, `name`, `device_id`, `block_id`, `details`, `create_time`, `update_time`) VALUES (1860592296991391744, '苏64', NULL, 1860217990331498496, 'ceshi', '2024-11-24 15:52:26', '2024-11-24 15:52:26'); COMMIT; -- ----------------------------