10.2新建设备编号,设备主键自动生成

dev
xiaohuo 9 months ago
parent d2d8003351
commit 4f01b21cdc
  1. 4
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java
  2. 6
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquManuController.java
  3. 2
      ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml
  4. 12
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquBase.java
  5. 2
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java
  6. 4
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java
  7. 1
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java
  8. 1
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java
  9. 36
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml

@ -125,10 +125,6 @@ public class EquBaseController extends BaseController
@GetMapping(value = "/queryimage/{id}")
@ApiOperation("查询单个设备图片")
public void getImage(@PathVariable String id, HttpServletResponse response) throws IOException {
if (id instanceof String) {
System.out.println("这是一个字符串");
}
byte[] imgBytes = equBaseService.selectEquBaseImageById(id).getEquImage();

@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
* @date 2025-08-01
*/
@RestController
@RequestMapping("/deviceManu")
@RequestMapping("/device/deviceManu")
public class EquManuController extends BaseController
{
@Autowired
@ -42,8 +42,8 @@ public class EquManuController extends BaseController
/**
* 查询设备厂商管理列表
*/
@PreAuthorize("@ss.hasPermi('device:deviceManu:queryByVO')")
@GetMapping("/queryByVO")
@PreAuthorize("@ss.hasPermi('device:deviceManu:query')")
@GetMapping("/query")
@ApiOperation("查询设备厂商管理列表")
public TableDataInfo list(EquManu equManu)
{

@ -6,7 +6,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/AIOps_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/aiops_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 1234
# 从库数据源

@ -15,7 +15,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* 设备基本信息对象 equ_base
*
* @author ruoyi
* @date 2025-09-19
* @date 2025-09-19F
*/
@Data
public class EquBase
@ -25,6 +25,9 @@ public class EquBase
/** 设备唯一标识(设备编号) */
private String id;
/** (设备编号) */
private String equNumber;
/** 设备名称 */
@Excel(name = "设备名称")
private String name;
@ -41,13 +44,6 @@ public class EquBase
@Excel(name = "设备厂商 id")
private String manufacture;
public EquManu getManufactureVO() {
return manufactureVO;
}
public void setManufactureVO(EquManu manufactureVO) {
this.manufactureVO = manufactureVO;
}
private EquManu manufactureVO;

@ -213,7 +213,7 @@ public class AlertLaunchServiceImpl implements IAlertLaunchService {
// 3. SQL:取每台设备最新记录和次新记录,比较该字段是否变化,并关联设备类型
String sql =
"SELECT g1.*, t.name AS equ_type,b.name AS equ_name" +
"SELECT g1.*, t.name AS equ_type,b.name AS equ_name,b.equ_number" +
"FROM equ_gather g1 " +
"JOIN equ_gather g2 ON g1.equ_id = g2.equ_id " +
"JOIN equ_base b ON g1.equ_id = b.id " +

@ -140,7 +140,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService
if ("equ_gather".equalsIgnoreCase(rule.getTableName())) {
// equ_gather 作为主表
sql.append("g.*, t.name AS equ_type ,b.name AS equ_name")
sql.append("g.*, t.name AS equ_type ,b.name AS equ_name,b.equ_number ")
.append("FROM equ_gather g ")
.append("JOIN equ_base b ON g.equ_id = b.id ")
.append("JOIN equ_type t ON b.equ_type = t.id ") // ★ 新增关联
@ -153,7 +153,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService
.append(buildConditionsSql(conditions));
} else {
// 其他表,需要连 equ_gather → equ_base → equ_type
sql.append("src.*, g.equ_id, t.name AS equ_type,b.name AS equ_name ")
sql.append("src.*, g.equ_id, t.name AS equ_type,b.name AS equ_name,b.equ_number ")
.append("FROM ").append(rule.getTableName()).append(" src ")
.append("JOIN equ_gather g ON src.equ_gather_id = g.id ")
.append("JOIN equ_base b ON g.equ_id = b.id ")

@ -160,6 +160,7 @@ public class EquBaseServiceImpl implements IEquBaseService
if (equBase.getCreateDate() == null) {
equBase.setCreateDate(new Date());
}
equBase.setId(UUID.randomUUID().toString());
equBase.setCreateBy(SecurityUtils.getLoginUser().getUserId());
return equBaseMapper.insertEquBase(equBase);
}

@ -95,7 +95,6 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService {
}
// 2. 执行新规则
//首先存入规则在执行
Date now = new Date();
Long userId = SecurityUtils.getLoginUser().getUserId();

@ -24,27 +24,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="supplierId" column="supplier_id" />
<result property="gatherFrequency" column="gather_frequency" />
<result property="equImage" column="equ_image" />
<result property="repairFrequency" column="repair_frequency" />
<result property="repairCost" column="repair_cost" />
<result property="fanSpeed" column="fan_speed"/>
<result property="cpuUtilization" column="cpu_utilization"/>
<result property="memoryUtilization" column="memory_utilization"/>
<result property="health" column="health"/>
<result property="contWorkPeriod" column="cont_work_period"/>
<result property="equNumber" column="equ_number" />
<association property="manufactureVO" columnPrefix="equ_manu_" autoMapping="true" />
<association property="equTypeVO" columnPrefix="equ_type_" autoMapping="true" />
<collection property="temperatureList" javaType="java.util.ArrayList" ofType="java.lang.Float">
<result column="temperature_value"/>
</collection>
<collection property="involtageList" javaType="java.util.ArrayList" ofType="java.lang.Float">
<result column="involtage_value"/>
</collection>
<collection property="outvoltageList" javaType="java.util.ArrayList" ofType="java.lang.Float">
<result column="outvoltage_value"/>
</collection>
<!-- <association property="manufacture" columnPrefix="equ_manu_" autoMapping="true" />-->
</resultMap>
<resultMap id="EquMonitorResult" type="com.alops.system.domain.vo.EquMonitorVO">
@ -57,19 +40,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="location" column="location" />
<result property="equType" column="equ_type" />
<result property="inCharge" column="in_charge" />
<result property="releaseDate" column="release_date" />
<result property="installDate" column="install_date" />
<result property="lifeCycle" column="life_cycle" />
<result property="serviceTime" column="service_time" />
<result property="warranty" column="warranty" />
<result property="createBy" column="create_by" />
<result property="createDate" column="create_date" />
<result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" />
<result property="status" column="status" />
<result property="failureFrequency" column="failure_frequency" />
<result property="repairFrequency" column="repair_frequency" />
<result property="repairCost" column="repair_cost" />
<result property="fanSpeed" column="fan_speed"/>
<result property="cpuUtilization" column="cpu_utilization"/>
<result property="memoryUtilization" column="memory_utilization"/>
@ -91,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectEquBaseVo">
select id, name, version, ip, manufacture, location, equ_type, in_charge, install_date, life_cycle, warranty, create_by, create_date, status, device_level, supplier_id from equ_base
select id,equ_number, name, version, ip, manufacture, location, equ_type, in_charge, install_date, life_cycle, warranty, create_by, create_date, status, device_level, supplier_id from equ_base
</sql>
@ -115,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 查询列 -->
<sql id="selectEquBaseVo2">
b.id AS id,
b.equ_number AS equNumber
b.name AS name,
b.version AS version,
b.ip AS ip,
@ -131,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.status AS status,
b.device_level AS deviceLevel,
g.health AS health
</sql>
<select id="selectEquBaseList" parameterType="equBaseQueryDto" resultType="com.alops.system.domain.vo.queryEquBaseVO">
@ -361,6 +343,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warranty != null">warranty,</if>
<if test="createBy != null">create_by,</if>
<if test="createDate != null">create_date,</if>
<if test="equNumber != null">equ_number,</if>
status,
<if test="equImage != null">equ_image,</if>
@ -383,7 +366,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="warranty != null">#{warranty},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createDate != null">#{createDate},</if>
<if test="equNumber != null">#{equNumber},</if>
COALESCE(#{status,jdbcType=INTEGER}, 0),
<if test="equImage != null">#{equImage,jdbcType=BLOB},</if>
COALESCE(#{failureFrequency,jdbcType=BIGINT}, 0),
@ -411,6 +394,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deviceLevel != null">device_level = #{deviceLevel},</if>
<if test="supplierId != null">supplier_id = #{supplierId},</if>
<if test="equImage != null">equ_image = #{equImage},</if>
<if test="equNumber != null">equ_number = #{equNumber},</if>
</trim>
where id = #{id}
</update>

Loading…
Cancel
Save