服务指令-给所有业务平台更新指令资源

This commit is contained in:
1378012178@qq.com 2025-07-17 09:38:18 +08:00
parent 8b720684f6
commit cc0d353b8b
1 changed files with 43 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.nu.modules.servicedirective.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -14,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
@ -28,6 +30,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -45,6 +48,8 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
private IConfigServiceDirectiveService configServiceDirectiveService;
@Autowired
private RabbitMQUtil rabbitMQUtil;
@Autowired
private ISysBaseAPI sysBaseAPI;
/**
* 分页列表查询
@ -261,8 +266,8 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
* @param dto
* @return
*/
@AutoLog(value = "服务指令-同步媒体资源给业务平台")
@ApiOperation(value = "服务指令-同步媒体资源给业务平台", notes = "服务指令-同步媒体资源给业务平台")
@AutoLog(value = "服务指令-同步媒体资源给服务指令对应的业务平台")
@ApiOperation(value = "服务指令-同步媒体资源给服务指令对应的业务平台", notes = "服务指令-同步媒体资源给服务指令对应的业务平台")
@RequestMapping(value = "/syncMediaForBiz", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<Map> syncMediaForBiz(@RequestBody ConfigServiceDirective dto) {
//处理媒体资源放在保存方法之前
@ -277,4 +282,40 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
rabbitMQUtil.sendToExchange("hldy.directive", dto.getSysOrgCode() + ".directive.createmedia", directiveAsyncMQDto);
return Result.OK(Maps.newHashMap());
}
@AutoLog(value = "服务指令-同步媒体资源给所有业务平台")
@ApiOperation(value = "服务指令-同步媒体资源给所有业务平台", notes = "服务指令-同步媒体资源给所有业务平台")
@RequestMapping(value = "/syncMediaForAllBiz", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<Map> syncMediaForAllBiz(@RequestBody ConfigServiceDirective dto) {
//处理媒体资源放在保存方法之前
configServiceDirectiveService.handleMediaFile(dto);
//保存
ConfigServiceDirective configServiceDirective = new ConfigServiceDirective();
BeanUtils.copyProperties(dto,configServiceDirective);
configServiceDirectiveService.updateById(configServiceDirective);
DirectiveAsyncMQDto directiveAsyncMQDto = new DirectiveAsyncMQDto();
BeanUtils.copyProperties(dto, directiveAsyncMQDto);
List<JSONObject> orgList = sysBaseAPI.queryOpeDept();
List<String> codes = orgList.stream()
.map(o -> o.getString("code"))
.collect(Collectors.toList());
//启动线程循环 codes 5 分钟通知一个平台
new Thread(() -> {
for (String code : codes) {
try {
rabbitMQUtil.sendToExchange("hldy.directive", code + ".directive.createmedia", directiveAsyncMQDto);
// 发送完后休眠 5 分钟
Thread.sleep(TimeUnit.MINUTES.toMillis(5));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
}).start();
return Result.OK(Maps.newHashMap());
}
}