边带设备

This commit is contained in:
cwchen 2024-03-20 17:54:12 +08:00
parent f4534302e2
commit 4bf3a6191e
13 changed files with 513 additions and 3 deletions

View File

@ -0,0 +1,20 @@
package com.securitycontrol.entity.background.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @authorcwchen
* @date2024-03-20-14:12
* @version1.0
* @description边带设备-vo
*/
@Data
public class DeviceBdDto {
@ApiModelProperty(value = "关键字")
private String keyWord;
@ApiModelProperty(value = "边带ID")
private String id;
}

View File

@ -0,0 +1,93 @@
package com.securitycontrol.entity.background.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @authorcwchen
* @date2024-03-20-14:12
* @version1.0
* @description边带设备-vo
*/
@Data
public class DeviceBdVo {
@ApiModelProperty(value = "边带ID")
private String id;
@ApiModelProperty(value = "边带名称")
@NotBlank(message = "边带名称不能为空", groups = {Query.class})
@Length(max = 50, message = "边带名称字符长度不能超过50", groups = {Query.class})
private String bdName;
@ApiModelProperty(value = "边带编码")
@NotBlank(message = "边带编码不能为空", groups = {Query.class})
@Length(max = 50, message = "边带编码字符长度不能超过50", groups = {Query.class})
private String bdCode;
@ApiModelProperty(value = "边带ip")
@NotBlank(message = "边带ip不能为空", groups = {Query.class})
@Length(max = 50, message = "边带ip字符长度不能超过50", groups = {Query.class})
@Pattern(regexp = "((0|1\\d{0,2}|2[0-4]\\d|25[0-5])\\.){3}(0|1\\d{0,2}|2[0-4]\\d|25[0-5])",message = "ip格式不正确",groups = {Query.class})
private String bdIp;
@ApiModelProperty(value = "边带型号")
@NotBlank(message = "边带型号不能为空", groups = {Query.class})
@Length(max = 80, message = "边带型号字符长度不能超过80", groups = {Query.class})
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String bdType;
@ApiModelProperty(value = "边带型号名称")
private String bdTypeName;
@ApiModelProperty(value = "设备类型编码")
@NotBlank(message = "设备类型编码不能为空", groups = {Query.class})
@Length(max = 11, message = "设备类型编码字符长度不能超过11", groups = {Query.class})
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String typeCode;
@ApiModelProperty(value = "设备类型名称")
private String typeCodeName;
@ApiModelProperty(value = "杆塔id")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String gtId;
@ApiModelProperty(value = "杆塔id")
private String gtName;
@ApiModelProperty(value = "标段编码")
@NotBlank(message = "标段编码不能为空", groups = {Query.class})
@Length(max = 80, message = "标段编码字符长度不能超过80", groups = {Query.class})
private String bidCode;
@ApiModelProperty(value = "工程名称")
private String proName;
@ApiModelProperty(value = "创建时间")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String createTime;
@ApiModelProperty(value = "修改时间")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String updateTime;
@ApiModelProperty(value = "绑定时间")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String bindTime;
@ApiModelProperty(value = "1.新增 2.修改")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Integer type;
/**
* 查询条件限制
*/
public interface Query {
}
}

View File

@ -32,4 +32,8 @@ public class SelectVo {
@ApiModelProperty(value = "班组长手机号")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String teamLeaderPhone;
@ApiModelProperty(value = "工程类型")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String proType;
}

View File

@ -1,10 +1,18 @@
package com.securitycontrol.background.controller;
import com.securitycontrol.background.service.IDeviceOfBdService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.securitycontrol.common.core.web.controller.BaseController;
import com.securitycontrol.common.core.web.domain.AjaxResult;
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.DeviceBdVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @authorcwchen
@ -14,8 +22,44 @@ import javax.annotation.Resource;
*/
@RestController
@RequestMapping("/back/deviceBd/")
public class DeviceOfBdController {
public class DeviceOfBdController extends BaseController {
@Resource(name = "IDeviceOfBdService")
private IDeviceOfBdService service;
@ApiOperation(value = "获取边带设备列表")
@GetMapping("getDeviceBdList")
@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 = "新增边带设备")
@PostMapping("addDeviceBd")
@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 = "业务日志")
public AjaxResult editDeviceBd(@RequestBody DeviceBdVo vo) {
return service.addOrUpdateDeviceBd(vo);
}
@ApiOperation(value = "边带设备详情")
@GetMapping("getDeviceBdById")
public AjaxResult getDeviceBdById(DeviceBdDto dto) {
return service.getDeviceBdById(dto);
}
@ApiOperation(value = "删除边带设备")
@PostMapping("delDeviceBdById")
public AjaxResult delDeviceBdById(@RequestBody DeviceBdDto dto) {
return service.delDeviceBdById(dto);
}
}

View File

@ -1,7 +1,11 @@
package com.securitycontrol.background.mapper;
import com.securitycontrol.entity.background.dto.DeviceBdDto;
import com.securitycontrol.entity.background.vo.DeviceBdVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @authorcwchen
* @date2024-03-20-13:12
@ -10,4 +14,66 @@ import org.springframework.stereotype.Repository;
*/
@Repository(value = "IDeviceOfBdMapper")
public interface IDeviceOfBdMapper {
/**
* 获取边带设备列表
*
* @param dto
* @return List<DeviceBdVo>
* @description
* @author cwchen
* @date 2024/3/20 14:23
*/
List<DeviceBdVo> getDeviceBdList(DeviceBdDto dto);
/**
* 新增/修改边带设备
*
* @param vo
* @description
* @author cwchen
* @date 2024/3/20 15:15
*/
void addOrUpdateDeviceBd(DeviceBdVo vo);
/**
* 边带编码是否重复
*
* @param vo
* @return int
* @description
* @author cwchen
* @date 2024/3/20 16:46
*/
int isBdCodeExist(DeviceBdVo vo);
/**
* 边带设备详情
*
* @param dto
* @return DeviceBdVo
* @description
* @author cwchen
* @date 2024/3/20 17:11
*/
DeviceBdVo getDeviceBdById(DeviceBdDto dto);
/**
* 边带设备是否包含子设备
*
* @param dto
* @return int
* @description
* @author cwchen
* @date 2024/3/20 17:24
*/
int isHasChildDeviceBd(DeviceBdDto dto);
/**
* 删除边带设备
* @param dto
* @description
* @author cwchen
* @date 2024/3/20 17:36
*/
void delDeviceBdById(DeviceBdDto dto);
}

View File

@ -1,5 +1,12 @@
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.DeviceBdVo;
import java.util.List;
/**
* @authorcwchen
* @date2024-03-20-13:11
@ -7,4 +14,46 @@ package com.securitycontrol.background.service;
* @description边带设备-业务层
*/
public interface IDeviceOfBdService {
/**
* 获取边带设备列表
*
* @param dto
* @return List<DeviceBdVo>
* @description
* @author cwchen
* @date 2024/3/20 14:18
*/
List<DeviceBdVo> getDeviceBdList(DeviceBdDto dto);
/**
* 新增/修改边带设备
*
* @param vo
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 15:11
*/
AjaxResult addOrUpdateDeviceBd(DeviceBdVo vo);
/**
* 边带设备详情
*
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 17:10
*/
AjaxResult getDeviceBdById(DeviceBdDto dto);
/**
* 删除边带设备
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 17:21
*/
AjaxResult delDeviceBdById(DeviceBdDto dto);
}

View File

@ -1,10 +1,27 @@
package com.securitycontrol.background.service.impl;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.securitycontrol.background.mapper.IDeviceOfBdMapper;
import com.securitycontrol.background.service.IDeviceOfBdService;
import com.securitycontrol.common.core.utils.StringUtils;
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
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.DeviceBdVo;
import com.securitycontrol.entity.system.base.vo.ProVo;
import com.securitycontrol.entity.system.vo.ResourceFileVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @authorcwchen
@ -13,8 +30,77 @@ import javax.annotation.Resource;
* @description边带设备-业务逻辑层
*/
@Service(value = "IDeviceOfBdService")
@Slf4j
public class DeviceOfBdServiceImpl implements IDeviceOfBdService {
@Resource(name = "IDeviceOfBdMapper")
private IDeviceOfBdMapper mapper;
@Resource(name = "ValidatorsUtils")
private ValidatorsUtils validatorsUtils;
@Override
public List<DeviceBdVo> getDeviceBdList(DeviceBdDto dto) {
List<DeviceBdVo> list = new ArrayList<>();
list = mapper.getDeviceBdList(dto);
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult addOrUpdateDeviceBd(DeviceBdVo vo) {
try {
String validResult = validatorsUtils.valid(vo, DeviceBdVo.Query.class);
if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult);
}
int result = mapper.isBdCodeExist(vo);
if(result > 0){
return AjaxResult.error("边带编码不能重复");
}
if (StringUtils.isEmpty(vo.getId())) {
String bdId = UUID.randomUUID().toString().replace("-", "");
vo.setId(bdId);
vo.setType(1);
vo.setCreateTime(DateTimeHelper.getNowTime());
vo.setUpdateTime(DateTimeHelper.getNowTime());
vo.setBindTime(DateTimeHelper.getNowTime());
} else {
vo.setType(2);
}
mapper.addOrUpdateDeviceBd(vo);
} catch (Exception e) {
log.error("新增/修改边带设备", e);
return AjaxResult.error();
}
return AjaxResult.success();
}
@Override
public AjaxResult getDeviceBdById(DeviceBdDto dto) {
DeviceBdVo vo = new DeviceBdVo();
vo = mapper.getDeviceBdById(dto);
return AjaxResult.success(vo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult delDeviceBdById(DeviceBdDto dto) {
try {
if (StringUtils.isEmpty(dto.getId())) {
return AjaxResult.error("参数不完整");
}
int num = mapper.isHasChildDeviceBd(dto);
if (num > 0) {
return AjaxResult.error("边带设备包含子边带设备");
}
mapper.delDeviceBdById(dto);
} catch (Exception e) {
log.error("删除边带设备", e);
//手动回滚异常
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error();
}
return AjaxResult.success();
}
}

View File

@ -1,5 +1,110 @@
<?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
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="bdName != null and bdName!=''">bd_name,</if>
<if test="bdCode != null and bdCode!=''">bd_code,</if>
<if test="bdIp != null and bdIp!=''">bd_ip,</if>
<if test="bdType != null and bdType!=''">bd_type,</if>
<if test="typeCode != null and typeCode!=''">type_code,</if>
<if test="gtId != null and gtId!=''">gt_id,</if>
<if test="bidCode != null and bidCode!=''">bid_code,</if>
del_flag,
<if test="updateTime != null and updateTime!=''">update_time,</if>
<if test="createTime != null and createTime!=''">create_time,</if>
<if test="bindTime != null and bindTime!=''">bind_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="bdName != null and bdName!=''">#{bdName},</if>
<if test="bdCode != null and bdCode!=''">#{bdCode},</if>
<if test="bdIp != null and bdIp!=''">#{bdIp},</if>
<if test="bdType != null and bdType != ''">#{bdType},</if>
<if test="typeCode != null and typeCode!=''">#{typeCode},</if>
<if test="gtId != null and gtId!=''">#{gtId},</if>
<if test="bidCode != null and bidCode!=''">#{bidCode},</if>
0,
<if test="updateTime != null and updateTime!=''">#{updateTime},</if>
<if test="createTime != null and createTime!=''">#{createTime},</if>
<if test="bindTime != null and bindTime!=''">#{bindTime},</if>
</trim>
</if>
<if test="type == 2">
UPDATE tb_pro_bd
<set>
<if test="bdName != null and bdName != ''">bd_name = #{bdName},</if>
<if test="bdCode != null and bdCode != ''">bd_code = #{bdCode},</if>
<if test="bdIp != null and bdIp != ''">bd_ip = #{bdIp},</if>
<if test="bdType != null and bdType != ''">bd_type = #{bdType},</if>
<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>
</set>
WHERE id = #{id}
</if>
</insert>
<!--删除边带设备-->
<delete id="delDeviceBdById">
DELETE FROM tb_pro_bd WHERE id = #{id}
</delete>
<!--获取边带设备列表-->
<select id="getDeviceBdList" resultType="com.securitycontrol.entity.background.vo.DeviceBdVo">
SELECT tpb.id,
tpb.bd_name AS bdName,
tpb.bd_code AS bdCode,
tpb.bd_ip AS bdIp,
sd.dict_name AS bdTypeName,
sd2.dict_name AS typeCodeName,
tp.pro_name AS proName,
tpg.gt_name AS gtName,
tpb.bind_time AS bindTime,
tpb.bid_code AS bidCode
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
LEFT JOIN tb_project tp ON tp.bid_code = tpb.bid_code
LEFT JOIN t_pro_gt tpg ON tpg.gt_id = tpb.gt_id
<where>
<if test="keyWord!=null and keyWord!=''">
AND (
INSTR(tpb.bd_name,#{keyWord}) > 0 OR
INSTR(tpb.bd_code,#{keyWord}) > 0 OR
INSTR(tp.pro_name,#{keyWord}) > 0 OR
INSTR(tpg.gt_name,#{keyWord}) > 0
)
</if>
</where>
</select>
<!--边带编码是否重复-->
<select id="isBdCodeExist" resultType="java.lang.Integer">
<if test="id == null or id == ''">
SELECT COUNT(*) FROM tb_pro_bd tpb WHERE bd_code = #{bdCode}
</if>
<if test="id != null and id != ''">
SELECT COUNT(*) FROM tb_pro_bd tpb WHERE bd_code = #{bdCode} AND id != #{id}
</if>
</select>
<!--边带设备详情-->
<select id="getDeviceBdById" resultType="com.securitycontrol.entity.background.vo.DeviceBdVo">
SELECT tpb.id,
tpb.bd_name AS bdName,
tpb.bd_code AS bdCode,
tpb.bd_ip AS bdIp,
tpb.bid_code AS bidCode,
tpb.type_code AS typeCode,
tpb.bd_type AS bdType,
tpb.gt_id AS gtId
FROM tb_pro_bd tpb
WHERE id = #{id}
</select>
<!--边带设备是否包含子设备-->
<select id="isHasChildDeviceBd" resultType="java.lang.Integer">
SELECT COUNT(*) FROM tb_bd_device WHERE bd_id = #{id}
</select>
</mapper>

View File

@ -73,4 +73,11 @@ public class SelectController extends BaseController {
public AjaxResult getTeamLists(SelectDto dto){
return service.getTeamLists(dto);
}
@ApiOperation(value = "工程下拉选")
@GetMapping("getProLists")
public AjaxResult getProLists(SelectDto dto){
return service.getProLists(dto);
}
}

View File

@ -90,6 +90,7 @@ public interface ISelectMapper {
/**
* 班组下拉选
*
* @param dto
* @return List<SelectVo>
* @description
@ -97,4 +98,14 @@ public interface ISelectMapper {
* @date 2024/3/18 13:26
*/
List<SelectVo> getTeamLists(SelectDto dto);
/**
* 工程下拉选
* @param dto
* @return List<SelectVo>
* @description
* @author cwchen
* @date 2024/3/20 16:16
*/
List<SelectVo> getProLists(SelectDto dto);
}

View File

@ -86,6 +86,7 @@ public interface ISelectService {
/**
* 班组下拉选
*
* @param dto
* @return AjaxResult
* @description
@ -93,4 +94,14 @@ public interface ISelectService {
* @date 2024/3/18 13:26
*/
AjaxResult getTeamLists(SelectDto dto);
/**
* 工程下拉选
* @param dto
* @return AjaxResult
* @description
* @author cwchen
* @date 2024/3/20 16:15
*/
AjaxResult getProLists(SelectDto dto);
}

View File

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

View File

@ -80,4 +80,11 @@
bid_code = #{param}
</if>
</select>
<!--工程下拉选-->
<select id="getProLists" resultType="com.securitycontrol.entity.system.vo.SelectVo">
SELECT bid_code AS id,
pro_name AS name,
pro_type AS proType
FROM tb_project
</select>
</mapper>