Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
wangshilong 2024-11-25 14:50:13 +08:00
commit 2281749c14
14 changed files with 540 additions and 61 deletions

View File

@ -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<Device>> 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<Device> getDevice(@RequestParam Long id) {
return Response.succeed(deviceService.getDevice(id));
}
/**
*新增设备
*/
@PostMapping(value = "/add")
@OperationLog(description = "新增设备", type = LogType.ADD)
public Response<String> add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) {
deviceService.add(deviceCreateDTO);
return Response.succeed();
}
/**
* 修改设备
*/
@PostMapping("/edit")
@OperationLog(description = "修改设备", type = LogType.UPDATE)
public Response<String> edit(@RequestBody @Valid DeviceEditDTO deviceEditDTO) {
deviceService.edit(deviceEditDTO);
return Response.succeed();
}
/**
* 删除设备
*/
@GetMapping("/delete")
@OperationLog(description = "删除设备", type = LogType.DELETE)
public Response<String> delete(@RequestParam Long id) {
deviceService.delete(id);
return Response.succeed();
}
/**
* 获取设备控制数据
*/
@GetMapping("/getDeviceControlData")
public Response<String> getDeviceControlData(@RequestParam Long id) {
deviceService.getDeviceControlData(id);
return Response.succeed();
}
/**
* 获取设备历史数据
*/
@GetMapping("/getDeviceHistoryData")
public Response<String> getDeviceHistoryData(@RequestParam Long id) {
deviceService.getDeviceHistoryData(id);
return Response.succeed();
}
/**
* 获取设备日志数据
*/
@GetMapping("/getDeviceLogData")
public Response<String> getDeviceLogData(@RequestParam Long id) {
deviceService.getDeviceLogData(id);
return Response.succeed();
}
}

View File

@ -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.*;

View File

@ -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<Device> {
Page<Device> page(Page<Object> page,
@Param("gasWellName") String gasWellName,
@Param("gasStationName") String gasStationName,
@Param("deviceTypeId") Long deviceTypeId);
}

View File

@ -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<GasWell> {
*/
int deleteGasWellByIds(Collection<Long> ids);
void bindDevice(@Param("gasWellId")Long gasWellId,@Param("deviceId") Long deviceId);
void unbindDevice(Long id);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<Device> {
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;
}

View File

@ -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<Device> {
Page<Device> 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);
}

View File

@ -72,4 +72,14 @@ public interface GasWellService extends IService<GasWell> {
*/
int deleteGasWellByIds(Collection<Long> ids);
/**
* 绑定气井设备
*
* @param gasWellId 气井主键
* @param deviceId 设备主键
* @return 结果
*/
void bindDevice(Long gasWellId, Long deviceId);
void unbindDevice(Long id);
}

View File

@ -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<DeviceDao, Device> implements DeviceService {
@Resource
private SnowflakeConfig snowflakeConfig;
@Resource
private DeviceDao deviceDao;
@Resource
private GasWellService gasWellService;
@Override
public Page<Device> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName,Long deviceTypeId){
Page<Device> 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<Device> list = list(new LambdaQueryWrapper<Device>().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) {
}
}

View File

@ -134,4 +134,15 @@ public class GasWellServiceImpl extends ServiceImpl<GasWellDao, GasWell> 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);
}
}

View File

@ -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 '关联公司',
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_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 '更新时间',
`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;
-- ----------------------------

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.isu.gaswellwatch.dao.DepartmentDao">
<resultMap id="DeviceMap" type="com.isu.gaswellwatch.entity.Device">
<id column="id" property="id"/>
<result column="code" property="code"/>
<result column="gas_station" property="gasStation"/>
<result column="gateway_sn" property="gatewaySn"/>
<result column="details" property="details"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<association property="deviceType" javaType="com.isu.gaswellwatch.entity.Dictionary" select="getDic" column="device_type">
</association>
<association property="product" javaType="com.isu.gaswellwatch.entity.Dictionary" select="getDic" column="product">
</association>
<association property="gasWell" javaType="com.isu.gaswellwatch.entity.GasWell" >
<id column="gasWellId" property="id"/>
<result column="gasWellName" property="name"/>
</association>
</resultMap>
<select id="page" resultType="com.isu.gaswellwatch.entity.Device">
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
u.gas_well, u.details, u.create_time, u.update_time,g.name as gasWellName,g.id as gasWellId,
from device u left join gas_well g on u.gas_well = g.id
<where>
<if test="gasWellName!=null and gasWellName!='' ">
and g.name LIKE CONCAT('%',#{gasWellName},'%')
</if>
<if test="gasStationName!=null and gasStationName!='' ">
and u.gas_station LIKE CONCAT('%',#{gasStationName},'%')
</if>
<if test="deviceTypeId!=null and deviceTypeId!='' ">
and u.device_type = #{deviceTypeId}
</if>
</where>
order by u.id desc
</select>
<select id="getDic" parameterType="java.lang.Long" resultType="com.isu.gaswellwatch.entity.Dictionary">
SELECT d.*
FROM Dictionary d
where d.id=#{dicId}
</select>
</mapper>

View File

@ -65,6 +65,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<update id="bindDevice">
update gas_well set device_id = #{deviceId} where id = #{gasWellId}
</update>
<update id="unbindDevice">
update gas_well set device_id = null where id = #{gasWellId}
</update>
<delete id="deleteGasWellById" parameterType="Long">
delete from gas_well where id = #{id}
</delete>