增加agent联调,获取最新策略应答功能

This commit is contained in:
gaoyutao
2025-10-22 17:54:46 +08:00
parent 4fdaadee65
commit 31d8114c05
45 changed files with 1686 additions and 341 deletions
@@ -22,10 +22,13 @@
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="fileMd5" column="file_md5" />
<result property="clientId" column="client_id" />
<result property="deployDevice" column="deploy_device" />
</resultMap>
<sql id="selectRmAgentManagementVo">
select id, hardware_sn, resource_name, internal_ip, status, agent_version, method, scheduled_update_time, file_url_type, file_url, file_directory, last_update_result, last_update_time, create_time, update_time, create_by, update_by from rm_agent_management
select id, hardware_sn, resource_name, internal_ip, status, agent_version, method, scheduled_update_time, file_url_type, file_url, file_directory, last_update_result, last_update_time, create_time, update_time, create_by, update_by, file_md5, client_id, deploy_device from rm_agent_management
</sql>
<select id="selectRmAgentManagementList" parameterType="RmAgentManagement" resultMap="RmAgentManagementResult">
@@ -43,6 +46,9 @@
<if test="fileDirectory != null and fileDirectory != ''"> and file_directory = #{fileDirectory}</if>
<if test="lastUpdateResult != null and lastUpdateResult != ''"> and last_update_result = #{lastUpdateResult}</if>
<if test="lastUpdateTime != null "> and last_update_time = #{lastUpdateTime}</if>
<if test="fileMd5 != null and fileMd5 != ''"> and file_md5 = #{fileMd5}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="deployDevice != null and deployDevice != ''"> and deploy_device = #{deployDevice}</if>
<if test="queryName != null and queryName != '' "> and (resource_name like concat('%', #{resourceName}, '%') or internal_ip = #{internalIp})</if>
</where>
</select>
@@ -71,6 +77,9 @@
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="fileMd5 != null">file_md5,</if>
<if test="clientId != null">client_id,</if>
<if test="deployDevice != null">deploy_device,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="hardwareSn != null and hardwareSn != ''">#{hardwareSn},</if>
@@ -89,6 +98,9 @@
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="fileMd5 != null">#{fileMd5},</if>
<if test="clientId != null">#{clientId},</if>
<if test="deployDevice != null">#{deployDevice},</if>
</trim>
</insert>
@@ -111,31 +123,12 @@
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="fileMd5 != null">file_md5 = #{fileMd5},</if>
<if test="clientId != null">client_id = #{clientId},</if>
<if test="deployDevice != null">deploy_device = #{deployDevice},</if>
</trim>
where id = #{id}
</update>
<update id="updateRmAgentManagementBySn" parameterType="RmAgentManagement">
update rm_agent_management
<trim prefix="SET" suffixOverrides=",">
<if test="resourceName != null and resourceName != ''">resource_name = #{resourceName},</if>
<if test="internalIp != null">internal_ip = #{internalIp},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="agentVersion != null">agent_version = #{agentVersion},</if>
<if test="method != null">method = #{method},</if>
<if test="scheduledUpdateTime != null">scheduled_update_time = #{scheduledUpdateTime},</if>
<if test="fileUrlType != null">file_url_type = #{fileUrlType},</if>
<if test="fileUrl != null">file_url = #{fileUrl},</if>
<if test="fileDirectory != null">file_directory = #{fileDirectory},</if>
<if test="lastUpdateResult != null">last_update_result = #{lastUpdateResult},</if>
<if test="lastUpdateTime != null">last_update_time = #{lastUpdateTime},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where hardware_sn = #{hardwareSn}
</update>
<delete id="deleteRmAgentManagementById" parameterType="Long">
delete from rm_agent_management where id = #{id}
@@ -23,10 +23,17 @@
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="scriptName" column="script_name" />
<result property="scriptPath" column="script_path" />
<result property="defaultParams" column="default_params" />
<result property="deployDevice" column="deploy_device" />
</resultMap>
<sql id="selectRmDeploymentPolicyVo">
select id, policy_name, description, resource_group_id, included_devices_id, source_file_path_type, source_file_path, target_directory, command_content, execution_method, scheduled_time, policy_status, deploy_time, script_type, create_time, update_time, create_by, update_by from rm_deployment_policy
select id, policy_name, description, resource_group_id, included_devices_id, source_file_path_type,
source_file_path, target_directory, command_content, execution_method, scheduled_time, policy_status,
deploy_time, script_type, create_time, update_time, create_by, update_by, script_name, script_path,
default_params, deploy_device from rm_deployment_policy
</sql>
<select id="selectRmDeploymentPolicyList" parameterType="RmDeploymentPolicy" resultMap="RmDeploymentPolicyResult">
@@ -45,6 +52,9 @@
<if test="policyStatus != null and policyStatus != ''"> and policy_status = #{policyStatus}</if>
<if test="deployTime != null "> and deploy_time = #{deployTime}</if>
<if test="scriptType != null and scriptType != ''"> and script_type = #{scriptType}</if>
<if test="scriptName != null and scriptName != ''"> and script_name = #{scriptName}</if>
<if test="scriptPath != null and scriptPath != ''"> and script_path = #{scriptPath}</if>
<if test="defaultParams != null and defaultParams != ''"> and default_params = #{defaultParams}</if>
</where>
</select>
@@ -73,6 +83,10 @@
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="scriptName != null">script_name,</if>
<if test="scriptPath != null">script_path,</if>
<if test="defaultParams != null">default_params,</if>
<if test="deployDevice != null">deploy_device,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="policyName != null and policyName != ''">#{policyName},</if>
@@ -92,6 +106,10 @@
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="scriptName != null">#{scriptName},</if>
<if test="scriptPath != null">#{scriptPath},</if>
<if test="defaultParams != null">#{defaultParams},</if>
<if test="deployDevice != null">#{deployDevice},</if>
</trim>
</insert>
@@ -116,6 +134,10 @@
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="scriptName != null">script_name = #{scriptName},</if>
<if test="scriptPath != null">script_path = #{scriptPath},</if>
<if test="defaultParams != null">default_params = #{defaultParams},</if>
<if test="deployDevice != null">deploy_device = #{deployDevice},</if>
</trim>
where id = #{id}
</update>
@@ -130,4 +152,13 @@
#{id}
</foreach>
</delete>
<select id="selectRmDeploymentPolicyByClientId" parameterType="RmDeploymentPolicy" resultMap="RmDeploymentPolicyResult">
<include refid="selectRmDeploymentPolicyVo"/>
<where>
<if test="policyStatus != null and policyStatus != ''"> and policy_status = #{policyStatus}</if>
<if test="deployDevice != null ">
FIND_IN_SET(#{deployDevice}, REPLACE(deploy_device, '\n', ',')) > 0
</if>
</where>
</select>
</mapper>
@@ -0,0 +1,97 @@
<?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.ruoyi.rocketmq.mapper.RmFileInfoMapper">
<resultMap type="RmFileInfo" id="RmFileInfoResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="type" column="type" />
<result property="description" column="description" />
<result property="fileSize" column="file_size" />
<result property="md5" column="md5" />
<result property="path" column="path" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectRmFileInfoVo">
select id, name, type, description, file_size, md5, path, create_time, update_time, create_by, update_by from rm_file_info
</sql>
<select id="selectRmFileInfoList" parameterType="RmFileInfo" resultMap="RmFileInfoResult">
<include refid="selectRmFileInfoVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="fileSize != null "> and file_size = #{fileSize}</if>
<if test="md5 != null and md5 != ''"> and md5 = #{md5}</if>
<if test="path != null and path != ''"> and path = #{path}</if>
</where>
</select>
<select id="selectRmFileInfoById" parameterType="Long" resultMap="RmFileInfoResult">
<include refid="selectRmFileInfoVo"/>
where id = #{id}
</select>
<insert id="insertRmFileInfo" parameterType="RmFileInfo" useGeneratedKeys="true" keyProperty="id">
insert into rm_file_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="type != null and type != ''">type,</if>
<if test="description != null">description,</if>
<if test="fileSize != null">file_size,</if>
<if test="md5 != null and md5 != ''">md5,</if>
<if test="path != null and path != ''">path,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="description != null">#{description},</if>
<if test="fileSize != null">#{fileSize},</if>
<if test="md5 != null and md5 != ''">#{md5},</if>
<if test="path != null and path != ''">#{path},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateRmFileInfo" parameterType="RmFileInfo">
update rm_file_info
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="type != null and type != ''">type = #{type},</if>
<if test="description != null">description = #{description},</if>
<if test="fileSize != null">file_size = #{fileSize},</if>
<if test="md5 != null and md5 != ''">md5 = #{md5},</if>
<if test="path != null and path != ''">path = #{path},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteRmFileInfoById" parameterType="Long">
delete from rm_file_info where id = #{id}
</delete>
<delete id="deleteRmFileInfoByIds" parameterType="String">
delete from rm_file_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
@@ -0,0 +1,99 @@
<?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.ruoyi.rocketmq.mapper.RmPolicyDeviceDetailsMapper">
<resultMap type="RmPolicyDeviceDetails" id="RmPolicyDeviceDetailsResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="policyId" column="policy_id" />
<result property="scriptId" column="script_id" />
<result property="versionId" column="version_id" />
<result property="policyStatus" column="policy_status" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectRmPolicyDeviceDetailsVo">
select id, client_id, policy_id, script_id, version_id, policy_status, create_time, update_time, create_by, update_by from rm_policy_device_details
</sql>
<select id="selectRmPolicyDeviceDetailsList" parameterType="RmPolicyDeviceDetails" resultMap="RmPolicyDeviceDetailsResult">
<include refid="selectRmPolicyDeviceDetailsVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="policyId != null and policyId != ''"> and policy_id = #{policyId}</if>
<if test="scriptId != null and scriptId != ''"> and script_id = #{scriptId}</if>
<if test="versionId != null and versionId != ''"> and version_id = #{versionId}</if>
<if test="policyStatus != null and policyStatus != ''"> and policy_status = #{policyStatus}</if>
</where>
</select>
<select id="selectRmPolicyDeviceDetailsById" parameterType="Long" resultMap="RmPolicyDeviceDetailsResult">
<include refid="selectRmPolicyDeviceDetailsVo"/>
where id = #{id}
</select>
<insert id="insertRmPolicyDeviceDetails" parameterType="RmPolicyDeviceDetails" useGeneratedKeys="true" keyProperty="id">
insert into rm_policy_device_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="policyId != null and policyId != ''">policy_id,</if>
<if test="scriptId != null">script_id,</if>
<if test="versionId != null">version_id,</if>
<if test="policyStatus != null and policyStatus != ''">policy_status,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="policyId != null and policyId != ''">#{policyId},</if>
<if test="scriptId != null">#{scriptId},</if>
<if test="versionId != null">#{versionId},</if>
<if test="policyStatus != null and policyStatus != ''">#{policyStatus},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateRmPolicyDeviceDetails" parameterType="RmPolicyDeviceDetails">
update rm_policy_device_details
<trim prefix="SET" suffixOverrides=",">
<if test="policyStatus != null and policyStatus != ''">policy_status = #{policyStatus},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where
<choose>
<when test="id != null">
id = #{id}
</when>
<when test="policyId != null and policyId != '' and clientId != null and clientId != ''">
policy_id = #{policyId} and client_id = #{clientId}
</when>
<otherwise>
1=0 <!-- 如果没有提供任何条件,则不更新任何记录 -->
</otherwise>
</choose>
</update>
<delete id="deleteRmPolicyDeviceDetailsById" parameterType="Long">
delete from rm_policy_device_details where id = #{id}
</delete>
<delete id="deleteRmPolicyDeviceDetailsByIds" parameterType="String">
delete from rm_policy_device_details where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>