Explorar o código

更改数据源切换问题

Administrator %!s(int64=2) %!d(string=hai) anos
pai
achega
a8986d43e2

+ 5 - 0
src/main/java/com/persagy/apm/alarmservice/group/alarmrule/service/impl/GroupAlarmRuleServiceImpl.java

@@ -402,9 +402,11 @@ public class GroupAlarmRuleServiceImpl extends ServiceImpl<GroupAlarmRuleMapper,
 		alarmConditionService.deleteAlarmCondition(deleteGroupAlarmRuleDTO.getAlarmConditionId());
 		// 异步删除项目上的报警规则
 		PoemsContextContent context = PoemsContext.getContext();
+		String requestUri=request.getRequestURI();
 		executor.execute(() -> {
 			PoemsContext.setContext(context);
 			try {
+				dynamicDataSourceHandler.resetDataSource(requestUri);
 				projectAlarmRuleService.deleteBatchByGroupRule(groupAlarmRule);
 				String condition = deleteGroupAlarmRuleDTO.getCondition();
 				String classCode = deleteGroupAlarmRuleDTO.getClassCode();
@@ -521,9 +523,12 @@ public class GroupAlarmRuleServiceImpl extends ServiceImpl<GroupAlarmRuleMapper,
 		String projectId = PoemsContext.getContext().getProjectId();
 		String pd = PoemsContext.getContext().getPd();
 		String loginDevice = PoemsContext.getContext().getLoginDevice();
+		String resquestUri = request.getRequestURI();
 		executor.execute(() -> {
+			
 			// 切换线程需要重新设置线程中的通用变量
 			PoemsContext.setContext(userId, loginDevice, pd, groupCode, projectId);
+			dynamicDataSourceHandler.resetDataSource(resquestUri);
 			projectAlarmRuleService.addProjectAlarmRulesPM(addGroupAlarmRuleDTO);
 		});