refactor: 删除渲染机管理相关代码

- 移除 RenderWorkerController、RenderWorkerMapper、RenderWorkerEntity、RenderWorkerService 等类
- 删除相关的 XML 配置文件
- 清理数据库表结构
This commit is contained in:
2025-09-08 00:11:38 +08:00
parent 502eca10f6
commit 4ee79b5db8
7 changed files with 0 additions and 418 deletions

View File

@@ -1,61 +0,0 @@
package com.ycwl.basic.controller.pc;
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
import com.ycwl.basic.service.pc.RenderWorkerService;
import com.ycwl.basic.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Author:longbinbin
* @Date:2024/12/3 14:59
*/
@RestController
@RequestMapping("/api/renderWorker/v1")
// 渲染机管理
public class RenderWorkerController {
@Autowired
private RenderWorkerService renderWorkerService;
// 分页查询渲染机
@PostMapping("/page")
public ApiResponse pageQuery(@RequestBody RenderWorkerReqQuery renderWorkerReqQuery){
return renderWorkerService.pageQuery(renderWorkerReqQuery);
}
// 渲染机列表查询
@PostMapping("/list")
public ApiResponse list(@RequestBody RenderWorkerReqQuery renderWorkerReqQuery){
return renderWorkerService.list(renderWorkerReqQuery);
}
// 渲染机详情查询
@GetMapping("/detail/{id}")
public ApiResponse detail(@PathVariable Long id){
return renderWorkerService.detail(id);
}
// 渲染机新增
@PostMapping("/add")
public ApiResponse add(@RequestBody RenderWorkerEntity renderWorker){
return renderWorkerService.add(renderWorker);
}
// 渲染机删除
@DeleteMapping("/delete/{id}")
public ApiResponse deleteById(@PathVariable Long id){
return renderWorkerService.deleteById(id);
}
// 渲染机修改
@PostMapping("/update")
public ApiResponse update(@RequestBody RenderWorkerEntity renderWorker){
return renderWorkerService.update(renderWorker);
}
// 渲染机修改状态
@PutMapping("/updateStatus/{id}")
public ApiResponse updateStatus(@PathVariable Long id) {
return renderWorkerService.updateStatus(id);
}
}

View File

@@ -1,22 +0,0 @@
package com.ycwl.basic.mapper;
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author:longbinbin
* @Date:2024/11/29 17:22
* 渲染机管理表
*/
@Mapper
public interface RenderWorkerMapper {
List<RenderWorkerEntity> list(RenderWorkerReqQuery renderWorkerReqQuery);
int add(RenderWorkerEntity renderWorker);
int deleteById(Long id);
int update(RenderWorkerEntity renderWorker);
int updateStatus(Long id);
}

View File

@@ -14,9 +14,7 @@ import java.util.Date;
* 渲染机管理表 * 渲染机管理表
*/ */
@Data @Data
@TableName("render_worker")
public class RenderWorkerEntity { public class RenderWorkerEntity {
@TableId
private Long id; private Long id;
/** /**
* 渲染机名称 * 渲染机名称

View File

@@ -1,23 +0,0 @@
package com.ycwl.basic.service.pc;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
import com.ycwl.basic.model.pc.renderWorker.resp.RenderWorkerRespVO;
import com.ycwl.basic.utils.ApiResponse;
import java.util.List;
/**
* @Author:longbinbin
* @Date:2024/12/3 15:07
*/
public interface RenderWorkerService {
ApiResponse<PageInfo<RenderWorkerRespVO>> pageQuery(RenderWorkerReqQuery renderWorkerReqQuery);
ApiResponse<List<RenderWorkerRespVO>> list(RenderWorkerReqQuery renderWorkerReqQuery);
ApiResponse<RenderWorkerRespVO> detail(Long id);
ApiResponse<Integer> add(RenderWorkerEntity renderWorker);
ApiResponse<Integer> deleteById(Long id);
ApiResponse<Integer> update(RenderWorkerEntity renderWorker);
ApiResponse<Integer> updateStatus(Long id);
}

View File

@@ -1,161 +0,0 @@
package com.ycwl.basic.service.pc.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.mapper.RenderWorkerMapper;
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
import com.ycwl.basic.model.pc.renderWorker.req.RenderWorkerReqQuery;
import com.ycwl.basic.model.pc.renderWorker.resp.RenderWorkerRespVO;
import com.ycwl.basic.model.task.req.ClientStatusReqVo;
import com.ycwl.basic.repository.RenderWorkerRepository;
import com.ycwl.basic.service.pc.RenderWorkerService;
import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.SnowFlakeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
* @Author:longbinbin
* @Date:2024/12/3 15:09
*/
@Service
public class RenderWorkerServiceImpl implements RenderWorkerService {
@Autowired
private RenderWorkerMapper renderWorkerMapper;
@Autowired
private RenderWorkerRepository renderWorkerRepository;
@Override
public ApiResponse<PageInfo<RenderWorkerRespVO>> pageQuery(RenderWorkerReqQuery renderWorkerReqQuery) {
PageHelper.startPage(renderWorkerReqQuery.getPageNum(), renderWorkerReqQuery.getPageSize());
List<RenderWorkerEntity> list = renderWorkerMapper.list(renderWorkerReqQuery);
List<RenderWorkerRespVO> workerList = list.stream().map(worker -> {
RenderWorkerRespVO resp = new RenderWorkerRespVO();
resp.setId(worker.getId());
resp.setName(worker.getName());
resp.setAccessKey(worker.getAccessKey());
resp.setStatus(worker.getStatus());
resp.setCreateAt(worker.getCreateAt());
resp.setUpdateAt(worker.getUpdateAt());
ClientStatusReqVo clientStatus = renderWorkerRepository.getWorkerHostStatus(worker.getId());
if (clientStatus == null) {
return resp;
}
resp.setCpuCount(clientStatus.getCpu_count());
resp.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
resp.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
resp.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
resp.setPlatform(clientStatus.getPlatform());
resp.setRuntimeVersion(clientStatus.getRuntime_version());
resp.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
resp.setVersion(clientStatus.getVersion());
resp.setUpdateAt(clientStatus.getUpdateAt());
return resp;
}).toList();
PageInfo<RenderWorkerRespVO> pageInfo = new PageInfo<>(workerList);
return ApiResponse.success(pageInfo);
}
@Override
public ApiResponse<List<RenderWorkerRespVO>> list(RenderWorkerReqQuery renderWorkerReqQuery) {
List<RenderWorkerEntity> list = renderWorkerMapper.list(renderWorkerReqQuery);
List<RenderWorkerRespVO> workerList = list.stream().map(worker -> {
RenderWorkerRespVO resp = new RenderWorkerRespVO();
resp.setId(worker.getId());
resp.setName(worker.getName());
resp.setAccessKey(worker.getAccessKey());
resp.setStatus(worker.getStatus());
resp.setCreateAt(worker.getCreateAt());
resp.setUpdateAt(worker.getUpdateAt());
ClientStatusReqVo clientStatus = renderWorkerRepository.getWorkerHostStatus(worker.getId());
if (clientStatus == null) {
return resp;
}
resp.setCpuCount(clientStatus.getCpu_count());
resp.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
resp.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
resp.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
resp.setPlatform(clientStatus.getPlatform());
resp.setRuntimeVersion(clientStatus.getRuntime_version());
resp.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
resp.setVersion(clientStatus.getVersion());
resp.setUpdateAt(clientStatus.getUpdateAt());
return resp;
}).toList();
return ApiResponse.success(workerList);
}
@Override
public ApiResponse<RenderWorkerRespVO> detail(Long id) {
RenderWorkerEntity worker = renderWorkerRepository.getWorker(id);
RenderWorkerRespVO resp = new RenderWorkerRespVO();
resp.setId(worker.getId());
resp.setName(worker.getName());
resp.setAccessKey(worker.getAccessKey());
resp.setStatus(worker.getStatus());
resp.setCreateAt(worker.getCreateAt());
resp.setUpdateAt(worker.getUpdateAt());
ClientStatusReqVo clientStatus = renderWorkerRepository.getWorkerHostStatus(worker.getId());
if (clientStatus != null) {
resp.setCpuCount(clientStatus.getCpu_count());
resp.setCpuUsage(clientStatus.getCpu_usage());
// 上报的是字节,存储的是兆
resp.setMemoryAvailable(clientStatus.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
resp.setMemoryTotal(clientStatus.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
resp.setPlatform(clientStatus.getPlatform());
resp.setRuntimeVersion(clientStatus.getRuntime_version());
resp.setSupportFeature(String.join(",", clientStatus.getSupport_feature()));
resp.setVersion(clientStatus.getVersion());
resp.setUpdateAt(clientStatus.getUpdateAt());
}
return ApiResponse.success(resp);
}
@Override
public ApiResponse<Integer> add(RenderWorkerEntity renderWorker) {
renderWorker.setId(SnowFlakeUtil.getLongId());
if (StringUtils.isEmpty(renderWorker.getAccessKey())) {
renderWorker.setAccessKey(SnowFlakeUtil.getId());
}
renderWorker.setStatus(0);
int add = renderWorkerMapper.add(renderWorker);
if (add == 0) {
return ApiResponse.fail("渲染机添加失败");
}else {
return ApiResponse.success(add);
}
}
@Override
public ApiResponse<Integer> deleteById(Long id) {
return ApiResponse.success(renderWorkerMapper.deleteById(id));
}
@Override
public ApiResponse<Integer> update(RenderWorkerEntity renderWorker) {
int update = renderWorkerMapper.update(renderWorker);
if (update == 0) {
return ApiResponse.fail("渲染机修改失败");
}else {
return ApiResponse.success(update);
}
}
@Override
public ApiResponse<Integer> updateStatus(Long id) {
return ApiResponse.success(renderWorkerMapper.updateStatus(id));
}
}

View File

@@ -1,142 +0,0 @@
<?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.ycwl.basic.mapper.RenderWorkerMapper">
<insert id="add">
insert into render_worker(id, `name`, platform, runtime_version, version, access_key,
cpu_count, cpu_usage, memory_total, memory_available, support_feature, scenic_only, test_only, `online`, `status`)
VALUES (#{id}, #{name}, #{platform}, #{runtimeVersion}, #{version}, #{accessKey},
#{cpuCount}, #{cpuUsage}, #{memoryTotal}, #{memoryAvailable}, #{supportFeature}, #{scenicOnly}, #{testOnly}, #{online}, #{status})
</insert>
<update id="update">
update render_worker
<set>
<if test="name!= null and name!= ''">
name = #{name},
</if>
<if test="platform!= null and platform!= ''">
platform = #{platform},
</if>
<if test="runtimeVersion!= null and runtimeVersion!= ''">
runtime_version = #{runtimeVersion},
</if>
<if test="version!= null and version!= ''">
version = #{version},
</if>
<if test="accessKey!= null and accessKey!= ''">
access_key = #{accessKey},
</if>
<if test="cpuCount!= null">
cpu_count = #{cpuCount},
</if>
<if test="cpuUsage!= null">
cpu_usage = #{cpuUsage},
</if>
<if test="memoryTotal!= null">
memory_total = #{memoryTotal},
</if>
<if test="memoryAvailable!= null">
memory_available = #{memoryAvailable},
</if>
<if test="supportFeature!= null">
support_feature = #{supportFeature},
</if>
<if test="scenicOnly!= null">
scenic_only = #{scenicOnly},
</if>
<if test="testOnly!= null">
test_only = #{testOnly},
</if>
<if test="online!= null">
`online` = #{online},
</if>
</set>
where id = #{id}
</update>
<update id="updateStatus">
update render_worker
set status = (CASE
status
WHEN 1 THEN
0
WHEN 0 THEN
1
ELSE null
END)
where id = #{id}
</update>
<update id="updateHost">
update render_worker
set platform = #{status.platform},
runtime_version = #{status.runtimeVersion},
version = #{status.version},
cpu_count = #{status.cpuCount},
cpu_usage = #{status.cpuUsage},
memory_total = #{status.memoryTotal},
memory_available = #{status.memoryAvailable},
support_feature = #{status.supportFeature},
update_at = #{status.updateAt}
where id = #{id}
</update>
<delete id="deleteById">
delete from render_worker where id = #{id}
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity">
select id, `name`, platform, runtime_version, version, access_key,
cpu_count, cpu_usage, memory_total, memory_available, support_feature, scenic_only, test_only, `online`, `status`, create_at, update_at
from render_worker
<where>
<if test="name!= null and name!= ''">
and `name` like concat('%', #{name}, '%')
</if>
<if test="platform!= null and platform!= ''">
and platform like concat('%', #{platform}, '%')
</if>
<if test="runtimeVersion!= null and runtimeVersion!= ''">
and runtime_version like concat('%', #{runtimeVersion}, '%')
</if>
<if test="version!= null and version!= ''">
and version like concat('%', #{version}, '%')
</if>
<if test="cpuCount!= null">
and cpu_count = #{cpuCount}
</if>
<if test="cpuUsage!= null">
and cpu_usage = #{cpuUsage}
</if>
<if test="supportFeature!= null">
and support_feature like concat('%',#{supportFeature},'%')
</if>
<if test="scenicOnly!= null">
and scenic_only = #{scenicOnly}
</if>
<if test="testOnly!= null">
and test_only = #{testOnly}
</if>
<if test="online!= null">
and `online` = #{online}
</if>
<if test="status!= null">
and `status` = #{status}
</if>
<if test="startTime!=null">
and create_at >= #{startTime}
</if>
<if test="endTime!=null">
and create_at &lt;= #{endTime}
</if>
</where>
</select>
<select id="getById" resultType="com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity">
select id, `name`, platform, runtime_version, version, access_key,
cpu_count, cpu_usage, memory_total, memory_available, support_feature, scenic_only, test_only, `online`, `status`, create_at, update_at
from render_worker
where id = #{id}
</select>
<select id="findByAccessKey" resultType="com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity">
select id, `name`, scenic_only, test_only, `online`, `status`, create_at, update_at, store_type, store_config_json
from render_worker
where access_key = #{accessKey} and status = 1
</select>
</mapper>

View File

@@ -84,13 +84,6 @@
from task from task
where status = 0 where status = 0
and worker_id is null and worker_id is null
and NOT EXISTS (
SELECT 1
FROM render_worker rw
WHERE
rw.status = 1
AND FIND_IN_SET(task.scenic_id, rw.scenic_only) > 0 -- 检查scenic_id是否在逗号分隔的字符串中
)
limit 1 limit 1
</select> </select>
<select id="selectAllNotRunning" resultType="com.ycwl.basic.model.pc.task.entity.TaskEntity"> <select id="selectAllNotRunning" resultType="com.ycwl.basic.model.pc.task.entity.TaskEntity">