|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
package com.xxl.job.admin.controller;
|
|
|
|
|
|
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobGroup;
|
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobRegistry;
|
|
|
|
|
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
|
|
|
|
|
import com.xxl.job.admin.core.util.I18nUtil;
|
|
|
|
|
import com.xxl.job.admin.dao.XxlJobGroupDao;
|
|
|
|
|
import com.xxl.job.admin.dao.XxlJobInfoDao;
|
|
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
|
|
import com.xxl.job.core.enums.RegistryConfig;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
@ -12,6 +16,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -80,7 +87,17 @@ public class JobGroupController {
|
|
|
|
|
if (xxlJobGroup.getTitle()==null || StringUtils.isBlank(xxlJobGroup.getTitle())) {
|
|
|
|
|
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobgroup_field_title")) );
|
|
|
|
|
}
|
|
|
|
|
if (xxlJobGroup.getAddressType()!=0) {
|
|
|
|
|
if (xxlJobGroup.getAddressType() == 0) {
|
|
|
|
|
// 0=自动注册
|
|
|
|
|
List<String> registryList = findRegistryByAppName(xxlJobGroup.getAppName());
|
|
|
|
|
String addressListStr = null;
|
|
|
|
|
if (CollectionUtils.isNotEmpty(registryList)) {
|
|
|
|
|
Collections.sort(registryList);
|
|
|
|
|
addressListStr = StringUtils.join(registryList, ",");
|
|
|
|
|
}
|
|
|
|
|
xxlJobGroup.setAddressList(addressListStr);
|
|
|
|
|
} else {
|
|
|
|
|
// 1=手动录入
|
|
|
|
|
if (StringUtils.isBlank(xxlJobGroup.getAddressList())) {
|
|
|
|
|
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_addressType_limit") );
|
|
|
|
|
}
|
|
|
|
@ -96,6 +113,28 @@ public class JobGroupController {
|
|
|
|
|
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> findRegistryByAppName(String appNameParam){
|
|
|
|
|
HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
|
|
|
|
|
List<XxlJobRegistry> list = XxlJobDynamicScheduler.xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT);
|
|
|
|
|
if (list != null) {
|
|
|
|
|
for (XxlJobRegistry item: list) {
|
|
|
|
|
if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
|
|
|
|
|
String appName = item.getRegistryKey();
|
|
|
|
|
List<String> registryList = appAddressMap.get(appName);
|
|
|
|
|
if (registryList == null) {
|
|
|
|
|
registryList = new ArrayList<String>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!registryList.contains(item.getRegistryValue())) {
|
|
|
|
|
registryList.add(item.getRegistryValue());
|
|
|
|
|
}
|
|
|
|
|
appAddressMap.put(appName, registryList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return appAddressMap.get(appNameParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/remove")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ReturnT<String> remove(int id){
|
|
|
|
|