|
|
@ -9,6 +9,7 @@ import com.ruoyi.common.utils.PageUtils; |
|
|
|
import com.ruoyi.common.utils.spring.SpringUtils; |
|
|
|
import com.zc.business.domain.DcBatchFunctionsJob; |
|
|
|
import com.zc.business.domain.DcBatchFunctionsJobGroup; |
|
|
|
import com.zc.business.enums.UniversalEnum; |
|
|
|
import com.zc.business.mapper.DcBatchFunctionsJobMapper; |
|
|
|
import com.zc.business.service.IDcBatchFunctionsJobGroupService; |
|
|
|
import com.zc.business.service.IDcBatchFunctionsJobService; |
|
|
@ -55,8 +56,18 @@ public class DcBatchFunctionsJobServiceImpl extends ServiceImpl<DcBatchFunctions |
|
|
|
JSONArray jsonArray = JSONObject.parseArray(dcBatchFunctionsJobGroup.getDetailedConfiguration()); |
|
|
|
for (Object o : jsonArray) { |
|
|
|
String time = ((JSONObject) o).getString("time"); |
|
|
|
String[] times = time.split(":"); |
|
|
|
String cron = times[2] + " " + times[1] + " " + times[0] + " " + " * * ?"; |
|
|
|
String[] times = time.split(UniversalEnum.IN_THE_COLON.getValue()); |
|
|
|
String cron = times[UniversalEnum.TWO.getNumber()] |
|
|
|
+ UniversalEnum.BLANK_SPACE.getValue() |
|
|
|
+ times[UniversalEnum.ONE.getNumber()] |
|
|
|
+ UniversalEnum.BLANK_SPACE.getValue() |
|
|
|
+ times[UniversalEnum.ZERO.getNumber()] |
|
|
|
+ UniversalEnum.BLANK_SPACE.getValue() |
|
|
|
+ UniversalEnum.ASTERISK_ASTERISK.getValue() |
|
|
|
+ UniversalEnum.BLANK_SPACE.getValue() |
|
|
|
+ UniversalEnum.ASTERISK_ASTERISK.getValue() |
|
|
|
+ UniversalEnum.BLANK_SPACE.getValue() |
|
|
|
+ UniversalEnum.QUESTION_MARK.getValue(); |
|
|
|
JSONArray tasks = ((JSONObject) o).getJSONArray("tasks"); |
|
|
|
for (Object task : tasks) { |
|
|
|
if (Objects.equals(String.valueOf(job.getJobId()), String.valueOf(task))) { |
|
|
@ -79,12 +90,15 @@ public class DcBatchFunctionsJobServiceImpl extends ServiceImpl<DcBatchFunctions |
|
|
|
if (time == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
if (detailedConfigurations==null) { |
|
|
|
detailedConfigurations = new JSONArray(); |
|
|
|
} |
|
|
|
List<Object> detaileds = detailedConfigurations.stream().filter(detailed -> |
|
|
|
Objects.equals((String) ((JSONObject) detailed).get("time"), time) |
|
|
|
).collect(Collectors.toList()); |
|
|
|
Integer id = ThreadLocalRandom.current().nextInt(0, 999999999); |
|
|
|
if (detaileds.size() > 0) { |
|
|
|
JSONObject detailed = (JSONObject) detaileds.get(0); |
|
|
|
Integer id = ThreadLocalRandom.current().nextInt(UniversalEnum.ZERO.getNumber(), UniversalEnum.NINE_HUNDRED_AND_NINETY_NINE_HUNDRED_AND_NINETY_NINE_HUNDRED_AND_NINETY_NINE.getNumber()); |
|
|
|
if (detaileds.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
JSONObject detailed = (JSONObject) detaileds.get(UniversalEnum.ZERO.getNumber()); |
|
|
|
JSONArray tasks = detailed.getJSONArray("tasks"); |
|
|
|
tasks.add(id); |
|
|
|
detailed.put("tasks", tasks); |
|
|
@ -152,10 +166,10 @@ public class DcBatchFunctionsJobServiceImpl extends ServiceImpl<DcBatchFunctions |
|
|
|
DcBatchFunctionsJob job = new DcBatchFunctionsJob(); |
|
|
|
job.setJobId(Long.valueOf(id)); |
|
|
|
List<DcBatchFunctionsJob> dcBatchFunctionsJobs = listDcBatchFunctionsJob(job); |
|
|
|
if (dcBatchFunctionsJobs.size() == 0) { |
|
|
|
if (dcBatchFunctionsJobs.size() == UniversalEnum.ZERO.getNumber()) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
DcBatchFunctionsJob dcBatchFunctionsJob = dcBatchFunctionsJobs.get(0); |
|
|
|
DcBatchFunctionsJob dcBatchFunctionsJob = dcBatchFunctionsJobs.get(UniversalEnum.ZERO.getNumber()); |
|
|
|
ScheduleUtils.deleteJob(scheduler, dcBatchFunctionsJob); |
|
|
|
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup = dcBatchFunctionsJobGroupService.getById(dcBatchFunctionsJob.getJobGroup()); |
|
|
|
if (dcBatchFunctionsJobGroup == null) { |
|
|
@ -177,8 +191,8 @@ public class DcBatchFunctionsJobServiceImpl extends ServiceImpl<DcBatchFunctions |
|
|
|
return result; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
System.out.println(detaileds); |
|
|
|
if (detaileds.size() > 0) { |
|
|
|
JSONObject detailed = (JSONObject) detaileds.get(0); |
|
|
|
if (detaileds.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
JSONObject detailed = (JSONObject) detaileds.get(UniversalEnum.ZERO.getNumber()); |
|
|
|
JSONArray tasks = detailed.getJSONArray("tasks"); |
|
|
|
|
|
|
|
tasks = tasks.stream() |
|
|
@ -223,7 +237,7 @@ public class DcBatchFunctionsJobServiceImpl extends ServiceImpl<DcBatchFunctions |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean changeStatus(DcBatchFunctionsJob dcBatchFunctionsJob, String status) throws SchedulerException, TaskException { |
|
|
|
if (Objects.equals(status, "0")) { |
|
|
|
if (Objects.equals(status, UniversalEnum.ZERO.getValue())) { |
|
|
|
scheduler.resumeJob(ScheduleUtils.getJobKey(Long.valueOf(dcBatchFunctionsJob.getJobId()), String.valueOf(dcBatchFunctionsJob.getJobGroup()))); |
|
|
|
} else { |
|
|
|
scheduler.pauseJob(ScheduleUtils.getJobKey(Long.valueOf(dcBatchFunctionsJob.getJobId()), String.valueOf(dcBatchFunctionsJob.getJobGroup()))); |
|
|
|