Browse Source

新增新增定时任务组接口

develop
zhaoxianglong 4 months ago
parent
commit
08757b5cab
  1. 16
      zc-business/src/main/java/com/zc/business/controller/DcBatchFunctionsJobGroupController.java
  2. 5
      zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java
  3. 2
      zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java
  4. 28
      zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java

16
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)); 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));
}
/** /**
* 修改 * 修改
* *

5
zc-business/src/main/java/com/zc/business/domain/DcBatchFunctionsJobGroup.java

@ -1,12 +1,15 @@
package com.zc.business.domain; package com.zc.business.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
@ApiModel(value = "DcBatchFunctionsJobGroup", description = "定时任务组实体") @ApiModel(value = "DcBatchFunctionsJobGroup", description = "定时任务组实体")
@ -30,4 +33,6 @@ public class DcBatchFunctionsJobGroup {
private Date updateBy; private Date updateBy;
@ApiModelProperty("修改时间") @ApiModelProperty("修改时间")
private Date updateTime; private Date updateTime;
@TableField(exist = false)
private List<DcBatchFunctionsJob> dcBatchFunctionsJobList;
} }

2
zc-business/src/main/java/com/zc/business/service/IDcBatchFunctionsJobGroupService.java

@ -50,4 +50,6 @@ public interface IDcBatchFunctionsJobGroupService extends IService<DcBatchFuncti
List<DcBatchFunctionsJobGroup> listDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup); List<DcBatchFunctionsJobGroup> listDcBatchFunctionsJobGroup(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup);
boolean changeStatus(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException; boolean changeStatus(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException;
DcBatchFunctionsJobGroup adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException;
} }

28
zc-business/src/main/java/com/zc/business/service/impl/DcBatchFunctionsJobGroupServiceImpl.java

@ -1,5 +1,6 @@
package com.zc.business.service.impl; package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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 com.zc.business.service.IDcBatchFunctionsJobService;
import org.quartz.SchedulerException; import org.quartz.SchedulerException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 定时任务组Service业务层处理 * 定时任务组Service业务层处理
@ -49,9 +53,9 @@ public class DcBatchFunctionsJobGroupServiceImpl extends ServiceImpl<DcBatchFunc
boolean update = updateById(dcBatchFunctionsJobGroup); boolean update = updateById(dcBatchFunctionsJobGroup);
if (update) { if (update) {
LambdaQueryWrapper<DcBatchFunctionsJob> dcBatchFunctionsJobLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DcBatchFunctionsJob> dcBatchFunctionsJobLambdaQueryWrapper = new LambdaQueryWrapper<>();
dcBatchFunctionsJobLambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobGroup,dcBatchFunctionsJobGroup.getId()); dcBatchFunctionsJobLambdaQueryWrapper.eq(DcBatchFunctionsJob::getJobGroup, dcBatchFunctionsJobGroup.getId());
List<DcBatchFunctionsJob> list = dcBatchFunctionsJobService.list(dcBatchFunctionsJobLambdaQueryWrapper); List<DcBatchFunctionsJob> list = dcBatchFunctionsJobService.list(dcBatchFunctionsJobLambdaQueryWrapper);
list.forEach(item->{ list.forEach(item -> {
try { try {
dcBatchFunctionsJobService.editDcBatchFunctionsJob(item); dcBatchFunctionsJobService.editDcBatchFunctionsJob(item);
} catch (SchedulerException e) { } catch (SchedulerException e) {
@ -134,5 +138,25 @@ public class DcBatchFunctionsJobGroupServiceImpl extends ServiceImpl<DcBatchFunc
DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup1 = editDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup); DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup1 = editDcBatchFunctionsJobGroup(dcBatchFunctionsJobGroup);
return dcBatchFunctionsJobGroup1 != null; return dcBatchFunctionsJobGroup1 != null;
} }
@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public DcBatchFunctionsJobGroup adddcBatchFunctionsJobGroupAnddcBatchFunctionsJob(DcBatchFunctionsJobGroup dcBatchFunctionsJobGroup) throws SchedulerException, TaskException {
List<DcBatchFunctionsJob> 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;
}
} }

Loading…
Cancel
Save