边带设备

This commit is contained in:
cwchen 2024-03-21 09:21:09 +08:00
parent 768b2cdc4c
commit 73c89bcaff
14 changed files with 431 additions and 19 deletions

View File

@ -15,6 +15,6 @@ public class DeviceBdDto {
@ApiModelProperty(value = "关键字")
private String keyWord;
@ApiModelProperty(value = "边带ID")
@ApiModelProperty(value = "边带ID/边带设备ID")
private String id;
}

View File

@ -0,0 +1,63 @@
package com.securitycontrol.entity.background.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @authorcwchen
* @date2024-03-20-14:12
* @version1.0
* @description边带子设备-vo
*/
@Data
public class DeviceBdChildVo {
@ApiModelProperty(value = "设备id")
private String deviceId;
@ApiModelProperty(value = "设备编码")
private String deviceCode;
@ApiModelProperty(value = "设备类型")
private String deviceType;
@ApiModelProperty(value = "设备状态")
private String status;
@ApiModelProperty(value = "设备网络")
private String ip;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "更新时间")
private String createTime;
@ApiModelProperty(value = "创建时间/入场时间")
private String updateTime;
@ApiModelProperty(value = "设备信号")
private String deviceModel;
@ApiModelProperty(value = "边带ID")
private String bdId;
@ApiModelProperty(value = "边带名称")
private String bdName;
@ApiModelProperty(value = "1.新增 2.修改")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Integer type;
@ApiModelProperty(value = "区域ID")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String areaId;
@ApiModelProperty(value = "区域名称")
private String areaName;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -55,10 +55,9 @@ public class DeviceBdVo {
private String typeCodeName;
@ApiModelProperty(value = "杆塔id")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String gtId;
@ApiModelProperty(value = "杆塔id")
@ApiModelProperty(value = "杆塔名称")
private String gtName;
@ApiModelProperty(value = "标段编码")

View File

@ -18,4 +18,9 @@ public class SelectDto {
@ApiModelProperty(value = "1.变电 2线路")
private String proType;
@ApiModelProperty(value = "标段编码")
private String bidCode;
@ApiModelProperty(value = "gtId")
private String gtId;
}

View File

@ -7,6 +7,7 @@ import com.securitycontrol.common.core.web.page.TableDataInfo;
import com.securitycontrol.common.log.annotation.Log;
import com.securitycontrol.common.log.enums.OperationType;
import com.securitycontrol.entity.background.dto.DeviceBdDto;
import com.securitycontrol.entity.background.vo.DeviceBdChildVo;
import com.securitycontrol.entity.background.vo.DeviceBdVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@ -27,30 +28,30 @@ public class DeviceOfBdController extends BaseController {
@Resource(name = "IDeviceOfBdService")
private IDeviceOfBdService service;
@ApiOperation(value = "获取边带设备列表")
@ApiOperation(value = "获取边带列表")
@GetMapping("getDeviceBdList")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.QUERY_BUSINESS, details = "查询边带设备列表", type = "业务日志")
@Log(title = "设备管理", menu = "设备管理->边带管理", grade = OperationType.QUERY_BUSINESS, details = "查询边带列表", type = "业务日志")
public TableDataInfo getDeviceBdList(DeviceBdDto dto) {
startPage();
List<DeviceBdVo> list = service.getDeviceBdList(dto);
return getDataTable(list);
}
@ApiOperation(value = "新增边带设备")
@ApiOperation(value = "新增边带")
@PostMapping("addDeviceBd")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.ADD_BUSINESS, details = "新增边带设备", type = "业务日志")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.ADD_BUSINESS, details = "新增边带", type = "业务日志")
public AjaxResult addDeviceBd(@RequestBody DeviceBdVo vo) {
return service.addOrUpdateDeviceBd(vo);
}
@ApiOperation(value = "修改边带设备")
@PostMapping("editDeviceBd")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.UPDATE_BUSINESS, details = "修改边带设备", type = "业务日志")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.UPDATE_BUSINESS, details = "修改边带", type = "业务日志")
public AjaxResult editDeviceBd(@RequestBody DeviceBdVo vo) {
return service.addOrUpdateDeviceBd(vo);
}
@ApiOperation(value = "边带设备详情")
@ApiOperation(value = "边带详情")
@GetMapping("getDeviceBdById")
public AjaxResult getDeviceBdById(DeviceBdDto dto) {
return service.getDeviceBdById(dto);
@ -58,8 +59,44 @@ public class DeviceOfBdController extends BaseController {
@ApiOperation(value = "删除边带设备")
@PostMapping("delDeviceBdById")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.DELETE_BUSINESS, details = "删除边带设备", type = "业务日志")
public AjaxResult delDeviceBdById(@RequestBody DeviceBdDto dto) {
return service.delDeviceBdById(dto);
}
@ApiOperation(value = "获取边带子设备列表")
@GetMapping("getDeviceBdChildList")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.QUERY_BUSINESS, details = "查询边带子设备列表", type = "业务日志")
public TableDataInfo getDeviceBdChildList(DeviceBdDto dto) {
startPage();
List<DeviceBdChildVo> list = service.getDeviceBdChildList(dto);
return getDataTable(list);
}
@ApiOperation(value = "新增边带子设备")
@PostMapping("addDeviceBdChild")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.ADD_BUSINESS, details = "新增边带子设备", type = "业务日志")
public AjaxResult addDeviceBdChild(@RequestBody DeviceBdChildVo vo) {
return service.addOrUpdateDeviceBdChild(vo);
}
@ApiOperation(value = "修改边带子设备")
@PostMapping("editDeviceBdChild")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.UPDATE_BUSINESS, details = "修改边带子设备", type = "业务日志")
public AjaxResult editDeviceBdChild(@RequestBody DeviceBdChildVo vo) {
return service.addOrUpdateDeviceBdChild(vo);
}
@ApiOperation(value = "边带子设备详情")
@GetMapping("getDeviceBdChildById")
public AjaxResult getDeviceBdChildById(DeviceBdDto dto) {
return service.getDeviceBdChildById(dto);
}
@ApiOperation(value = "删除边带设备")
@PostMapping("delDeviceBdChildById")
@Log(title = "设备管理", menu = "设备管理->边带设备管理", grade = OperationType.DELETE_BUSINESS, details = "删除边带设备", type = "业务日志")
public AjaxResult delDeviceBdChildById(@RequestBody DeviceBdDto dto) {
return service.delDeviceBdChildById(dto);
}
}

View File

@ -1,6 +1,7 @@
package com.securitycontrol.background.mapper;
import com.securitycontrol.entity.background.dto.DeviceBdDto;
import com.securitycontrol.entity.background.vo.DeviceBdChildVo;
import com.securitycontrol.entity.background.vo.DeviceBdVo;
import org.springframework.stereotype.Repository;
@ -15,7 +16,7 @@ import java.util.List;
@Repository(value = "IDeviceOfBdMapper")
public interface IDeviceOfBdMapper {
/**
* 获取边带设备列表
* 获取边带列表
*
* @param dto
* @return List<DeviceBdVo>
@ -26,7 +27,7 @@ public interface IDeviceOfBdMapper {
List<DeviceBdVo> getDeviceBdList(DeviceBdDto dto);
/**
* 新增/修改边带设备
* 新增/修改边带
*
* @param vo
* @description
@ -47,7 +48,7 @@ public interface IDeviceOfBdMapper {
int isBdCodeExist(DeviceBdVo vo);
/**
* 边带设备详情
* 边带详情
*
* @param dto
* @return DeviceBdVo
@ -58,7 +59,7 @@ public interface IDeviceOfBdMapper {
DeviceBdVo getDeviceBdById(DeviceBdDto dto);
/**
* 边带设备是否包含子设备
* 边带是否包含边带子设备
*
* @param dto
* @return int
@ -69,11 +70,64 @@ public interface IDeviceOfBdMapper {
int isHasChildDeviceBd(DeviceBdDto dto);
/**
* 删除边带设备
* 删除边带
*
* @param dto
* @description
* @author cwchen
* @date 2024/3/20 17:36
*/
void delDeviceBdById(DeviceBdDto dto);
/**
* 获取边带子设备列表
*
* @param dto
* @return List<DeviceBdChildVo>
* @description
* @author cwchen
* @date 2024/3/20 18:09
*/
List<DeviceBdChildVo> getDeviceBdChildList(DeviceBdDto dto);
/**
* 新增/修改 边带子设备
*
* @param vo
* @description
* @author cwchen
* @date 2024/3/20 19:14
*/
void addOrUpdateDeviceBdChild(DeviceBdChildVo vo);
/**
* 边带设备编码是否重复
*
* @param vo
* @return int
* @description
* @author cwchen
* @date 2024/3/20 19:34
*/
int isDeviceCodeExist(DeviceBdChildVo vo);
/**
* 边带设备详情
*
* @param dto
* @return DeviceBdChildVo
* @description
* @author cwchen
* @date 2024/3/20 19:51
*/
DeviceBdChildVo getDeviceBdChildById(DeviceBdDto dto);
/**
* 删除边带设备
* @param dto
* @description
* @author cwchen
* @date 2024/3/20 19:52
*/
void delDeviceBdChildById(DeviceBdDto dto);
}

View File

@ -3,6 +3,7 @@ package com.securitycontrol.background.service;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.entity.background.dto.DeviceBdDto;
import com.securitycontrol.entity.background.vo.DeviceBdChildVo;
import com.securitycontrol.entity.background.vo.DeviceBdVo;
import java.util.List;
@ -49,6 +50,7 @@ public interface IDeviceOfBdService {
/**
* 删除边带设备
*
* @param dto
* @return AjaxResult
* @description
@ -56,4 +58,47 @@ public interface IDeviceOfBdService {
* @date 2024/3/20 17:21
*/
AjaxResult delDeviceBdById(DeviceBdDto dto);
/**
* 获取边带子设备列表
*
* @param dto
* @return List<DeviceBdChildVo>
* @description
* @author cwchen
* @date 2024/3/20 18:08
*/
List<DeviceBdChildVo> getDeviceBdChildList(DeviceBdDto dto);
/**
* 新增/修改边带子设备
*
* @param vo
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 19:12
*/
AjaxResult addOrUpdateDeviceBdChild(DeviceBdChildVo vo);
/**
* 边带子设备详情
*
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 19:49
*/
AjaxResult getDeviceBdChildById(DeviceBdDto dto);
/**
* 删除边带设备
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 19:50
*/
AjaxResult delDeviceBdChildById(DeviceBdDto dto);
}

View File

@ -9,6 +9,7 @@ import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.security.utils.SecurityUtils;
import com.securitycontrol.common.security.utils.ValidatorsUtils;
import com.securitycontrol.entity.background.dto.DeviceBdDto;
import com.securitycontrol.entity.background.vo.DeviceBdChildVo;
import com.securitycontrol.entity.background.vo.DeviceBdVo;
import com.securitycontrol.entity.system.base.vo.ProVo;
import com.securitycontrol.entity.system.vo.ResourceFileVo;
@ -67,10 +68,11 @@ public class DeviceOfBdServiceImpl implements IDeviceOfBdService {
vo.setBindTime(DateTimeHelper.getNowTime());
} else {
vo.setType(2);
vo.setBindTime(DateTimeHelper.getNowTime());
}
mapper.addOrUpdateDeviceBd(vo);
} catch (Exception e) {
log.error("新增/修改边带设备", e);
log.error("新增/修改边带", e);
return AjaxResult.error();
}
return AjaxResult.success();
@ -92,9 +94,70 @@ public class DeviceOfBdServiceImpl implements IDeviceOfBdService {
}
int num = mapper.isHasChildDeviceBd(dto);
if (num > 0) {
return AjaxResult.error("边带设备包含子边带设备");
return AjaxResult.error("边带包含子边带设备");
}
mapper.delDeviceBdById(dto);
} catch (Exception e) {
log.error("删除边带", e);
//手动回滚异常
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error();
}
return AjaxResult.success();
}
@Override
public List<DeviceBdChildVo> getDeviceBdChildList(DeviceBdDto dto) {
List<DeviceBdChildVo> list = new ArrayList<>();
list = mapper.getDeviceBdChildList(dto);
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult addOrUpdateDeviceBdChild(DeviceBdChildVo vo) {
try {
String validResult = validatorsUtils.valid(vo, DeviceBdChildVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult);
}
int result = mapper.isDeviceCodeExist(vo);
if(result > 0){
return AjaxResult.error("设备编码不能重复");
}
if (StringUtils.isEmpty(vo.getDeviceId())) {
String deviceId = UUID.randomUUID().toString().replace("-", "");
vo.setDeviceId(deviceId);
vo.setType(1);
vo.setCreateTime(DateTimeHelper.getNowTime());
vo.setUpdateTime(DateTimeHelper.getNowTime());
} else {
vo.setType(2);
vo.setUpdateTime(DateTimeHelper.getNowTime());
}
mapper.addOrUpdateDeviceBdChild(vo);
} catch (Exception e) {
log.error("新增/修改边带设备", e);
return AjaxResult.error();
}
return AjaxResult.success();
}
@Override
public AjaxResult getDeviceBdChildById(DeviceBdDto dto) {
DeviceBdChildVo vo = new DeviceBdChildVo();
vo = mapper.getDeviceBdChildById(dto);
return AjaxResult.success(vo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult delDeviceBdChildById(DeviceBdDto dto) {
try {
if (StringUtils.isEmpty(dto.getId())) {
return AjaxResult.error("参数不完整");
}
mapper.delDeviceBdChildById(dto);
} catch (Exception e) {
log.error("删除边带设备", e);
//手动回滚异常

View File

@ -1,7 +1,7 @@
<?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.securitycontrol.background.mapper.IDeviceOfBdMapper">
<!--新增/修改边带设备-->
<!--新增/修改边带-->
<insert id="addOrUpdateDeviceBd">
<if test="type == 1">
INSERT INTO tb_pro_bd
@ -44,16 +44,70 @@
<if test="typeCode != null and typeCode != ''">type_code = #{typeCode},</if>
<if test="gtId != null and gtId != ''">gt_id = #{gtId},</if>
<if test="bidCode != null and bidCode != ''">bid_code = #{bidCode},</if>
<if test="bindTime != null and bindTime != ''">bind_time = #{bindTime},</if>
</set>
WHERE id = #{id}
</if>
</insert>
<!--新增/修改 边带子设备-->
<insert id="addOrUpdateDeviceBdChild">
<if test="type == 1">
INSERT INTO tb_bd_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null and deviceId != ''">device_id,</if>
<if test="deviceCode != null and deviceCode!=''">device_code,</if>
<if test="deviceType != null and deviceType!=''">devic_type,</if>
<if test="status != null and status!=''">status,</if>
<if test="ip != null and ip!=''">ip,</if>
<if test="deviceName != null and deviceName!=''">device_name,</if>
<if test="createTime != null and createTime!=''">create_time,</if>
<if test="updateTime != null and updateTime!=''">update_time,</if>
del_flage,
<if test="updateTime != null and updateTime!=''">device_model,</if>
<if test="bdId != null and bdId!=''">bd_id,</if>
<if test="areaId != null and areaId!=''">area_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
<if test="deviceCode != null and deviceCode!=''">#{deviceCode},</if>
<if test="deviceType != null and deviceType!=''">#{deviceType},</if>
<if test="status != null and status!=''">#{status},</if>
<if test="ip != null and ip != ''">#{ip},</if>
<if test="deviceName != null and deviceName!=''">#{deviceName},</if>
<if test="createTime != null and createTime!=''">#{createTime},</if>
<if test="updateTime != null and updateTime!=''">#{updateTime},</if>
0,
<if test="deviceModel != null and deviceModel!=''">#{deviceModel},</if>
<if test="bdId != null and bdId!=''">#{bdId},</if>
<if test="areaId != null and areaId!=''">#{areaId},</if>
</trim>
</if>
<if test="type == 2">
UPDATE tb_bd_device
<set>
<if test="deviceCode != null and deviceCode != ''">device_code = #{deviceCode},</if>
<if test="deviceType != null and deviceType != ''">devic_type = #{deviceType},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="ip != null and ip != ''">ip = #{ip},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="updateTime != null and updateTime != ''">update_time = #{updateTime},</if>
<if test="deviceModel != null and deviceModel != ''">device_model = #{deviceModel},</if>
<if test="bdId != null and bdId != ''">bd_id = #{bdId},</if>
<if test="areaId != null and areaId != ''">area_id = #{areaId},</if>
</set>
WHERE device_id = #{deviceId}
</if>
</insert>
<!--删除边带设备-->
<delete id="delDeviceBdById">
DELETE FROM tb_pro_bd WHERE id = #{id}
</delete>
<!--删除边带设备-->
<delete id="delDeviceBdChildById">
DELETE FROM tb_bd_device WHERE device_id = #{id}
</delete>
<!--获取边带设备列表-->
<!--获取边带列表-->
<select id="getDeviceBdList" resultType="com.securitycontrol.entity.background.vo.DeviceBdVo">
SELECT tpb.id,
tpb.bd_name AS bdName,
@ -64,7 +118,8 @@
tp.pro_name AS proName,
tpg.gt_name AS gtName,
tpb.bind_time AS bindTime,
tpb.bid_code AS bidCode
tpb.bid_code AS bidCode,
tpb.gt_id AS gtId
FROM tb_pro_bd tpb
LEFT JOIN sys_dict sd ON sd.dict_code = tpb.bd_type
LEFT JOIN sys_dict sd2 ON sd2.dict_code = tpb.type_code
@ -107,4 +162,47 @@
<select id="isHasChildDeviceBd" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_bd_device WHERE bd_id = #{id}
</select>
<!--获取边带子设备列表-->
<select id="getDeviceBdChildList" resultType="com.securitycontrol.entity.background.vo.DeviceBdChildVo">
SELECT tbd.device_id AS deviceId,
tpb.bd_name AS bdName,
tbd.device_name AS deviceName,
tbd.update_time AS updateTime,
tbd.device_model AS deviceModel,
tbd.device_code AS deviceCode,
sd2.dict_name AS status,
tbd.ip,
sd.dict_name AS deviceType,
sa.area_name AS areaName,
tbd.bd_id AS bdId
FROM tb_bd_device tbd
LEFT JOIN tb_pro_bd tpb ON tbd.bd_id = tpb.id
LEFT JOIN sys_dict sd ON sd.dict_code = tbd.devic_type
LEFT JOIN sys_dict sd2 ON sd2.dict_code = tbd.status
LEFT JOIN sys_area sa ON tbd.area_id = sa.area_id
WHERE tbd.bd_id = #{id}
</select>
<!--边带设备编码是否重复-->
<select id="isDeviceCodeExist" resultType="java.lang.Integer">
<if test="deviceId == null or deviceId == ''">
SELECT COUNT(*) FROM tb_bd_device tbd WHERE device_code = #{deviceCode}
</if>
<if test="deviceId != null and deviceId != ''">
SELECT COUNT(*) FROM tb_bd_device tbd WHERE device_code = #{deviceCode} AND device_id != #{deviceId}
</if>
</select>
<!--边带设备详情-->
<select id="getDeviceBdChildById" resultType="com.securitycontrol.entity.background.vo.DeviceBdChildVo">
SELECT tbd.device_id AS deviceId,
tbd.device_name AS deviceName,
tbd.update_time AS updateTime,
tbd.device_model AS deviceModel,
tbd.device_code AS deviceCode,
tbd.ip,
tbd.bd_id AS bdId,
tbd.area_id AS areaId,
tbd.devic_type AS devicType
FROM tb_bd_device tbd
WHERE device_id = #{id}
</select>
</mapper>

View File

@ -80,4 +80,10 @@ public class SelectController extends BaseController {
return service.getProLists(dto);
}
@ApiOperation(value = "区域下拉选")
@GetMapping("getAreaLists")
public AjaxResult getAreaLists(SelectDto dto){
return service.getAreaLists(dto);
}
}

View File

@ -101,6 +101,7 @@ public interface ISelectMapper {
/**
* 工程下拉选
*
* @param dto
* @return List<SelectVo>
* @description
@ -108,4 +109,13 @@ public interface ISelectMapper {
* @date 2024/3/20 16:16
*/
List<SelectVo> getProLists(SelectDto dto);
/**
* @param dto
* @return List<SelectVo>
* @description
* @author cwchen
* @date 2024/3/20 20:02
*/
List<SelectVo> getAreaLists(SelectDto dto);
}

View File

@ -97,6 +97,7 @@ public interface ISelectService {
/**
* 工程下拉选
*
* @param dto
* @return AjaxResult
* @description
@ -104,4 +105,14 @@ public interface ISelectService {
* @date 2024/3/20 16:15
*/
AjaxResult getProLists(SelectDto dto);
/**
* 区域下拉选
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 20:01
*/
AjaxResult getAreaLists(SelectDto dto);
}

View File

@ -131,4 +131,11 @@ public class SelectServiceImpl implements ISelectService {
list = mapper.getProLists(dto);
return AjaxResult.success(list);
}
@Override
public AjaxResult getAreaLists(SelectDto dto) {
List<SelectVo> list = new ArrayList<>();
list = mapper.getAreaLists(dto);
return AjaxResult.success(list);
}
}

View File

@ -87,4 +87,18 @@
pro_type AS proType
FROM tb_project
</select>
<!--区域列表下拉选-->
<select id="getAreaLists" resultType="com.securitycontrol.entity.system.vo.SelectVo">
SELECT area_id AS id,
area_name AS name
FROM sys_area
<where>
<if test="bidCode !=null and bidCode!=''">
AND bid_code = #{bidCode}
</if>
<if test="gtId !=null and gtId!=''">
AND gt_id = #{gtId}
</if>
</where>
</select>
</mapper>