From 08757b5cabc6611282bfea233c7eac3b809adec8 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Mon, 15 Jul 2024 16:23:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=B0=E5=A2=9E=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=BB=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcBatchFunctionsJobGroupController.java | 16 +++++++++++ .../domain/DcBatchFunctionsJobGroup.java | 5 ++++ .../IDcBatchFunctionsJobGroupService.java | 2 ++ .../DcBatchFunctionsJobGroupServiceImpl.java | 28 +++++++++++++++++-- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java b/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java index e4b043a9..f3835775 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java @@ -86,6 +86,22 @@ public class DcBatchFunctionsJobGroupController extends BaseController { return AjaxResult.success(dcBatchFunctionsJobGroupService.addDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup)); } + + + /** + * 新增 + * + * @param dcBatchFunctionsJobGroup 新增参数 + * @return 新增操作结果 + */ + @ApiOperation("新增") + //@PreAuthorize("@ss.hasPermi('iot:facility:add')") + @Log(title = "新增", businessType = BusinessType.INSERT) + @PostMapping("/add") + public AjaxResult adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(@Valid @RequestBody DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException { + return AjaxResult.success(dcBatchFunctionsJobGroupService.adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(dcBatchFunctionsJobGroup)); + } + /** * 修改 * diff --git a/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java b/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java index 1945506a..b1e67209 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java @@ -1,12 +1,15 @@ package com.zc.business.domain; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.ArrayList; import java.util.Date; +import java.util.List; @Data @ApiModel(value = "DcBatchFunctionsJobGroup", description = "定时任务组实体") @@ -30,4 +33,6 @@ public class DcBatchFunctionsJobGroup { private Date updateBy; @ApiModelProperty("修改时间") private Date updateTime; + @TableField(exist = false) + private List dcBatchFunctionsJobList; } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java b/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java index 9dda4855..701bc6d7 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java @@ -50,4 +50,6 @@ public interface IDcBatchFunctionsJobGroupService extends IService listDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup); boolean changeStatus(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException; + + DcBatchFunctionsJobGroup adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException; } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java index a9f91a3b..c0412f2d 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java @@ -1,5 +1,6 @@ package com.zc.business.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -13,11 +14,14 @@ import com.zc.business.service.IDcBatchFunctionsJobGroupService; import com.zc.business.service.IDcBatchFunctionsJobService; import org.quartz.SchedulerException; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Objects; /** * 定时任务组Service业务层处理 @@ -49,9 +53,9 @@ public class DcBatchFunctionsJobGroupServiceImpl extends ServiceImpl dcBatchFunctionsJobLambdaQueryWrapper = new LambdaQueryWrapper<>(); - dcBatchFunctionsJobLambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobGroup,dcBatchFunctionsJobGroup.getId()); + dcBatchFunctionsJobLambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobGroup, dcBatchFunctionsJobGroup.getId()); List list = dcBatchFunctionsJobService.list(dcBatchFunctionsJobLambdaQueryWrapper); - list.forEach(item->{ + list.forEach(item -> { try { dcBatchFunctionsJobService.editDcBatchFunctionsJob(item); } catch (SchedulerException e) { @@ -134,5 +138,25 @@ public class DcBatchFunctionsJobGroupServiceImpl extends ServiceImpl dcBatchFunctionsJobList = dcBatchFunctionsJobGroup.getDcBatchFunctionsJobList(); + DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup1 = addDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup); + if (dcBatchFunctionsJobGroup1 == null) { + throw new NullPointerException(); + } + for (DcBatchFunctionsJob job : dcBatchFunctionsJobList) { + + job.setJobGroup(String.valueOf(dcBatchFunctionsJobGroup1.getId())); + + DcBatchFunctionsJob dcBatchFunctionsJob = dcBatchFunctionsJobService.addDcBatchFunctionsJob(job); + if (dcBatchFunctionsJob == null) { + throw new NullPointerException(); + } + } + return dcBatchFunctionsJobGroup1; + } }