fix:定时任务
parent
918370e054
commit
1884459744
|
@ -62,7 +62,6 @@ public class TbTaskInfo {
|
||||||
@ApiModelProperty(value = "任务输出")
|
@ApiModelProperty(value = "任务输出")
|
||||||
@AutoMapping(ignore = true)
|
@AutoMapping(ignore = true)
|
||||||
@ReverseAutoMapping(ignore = true)
|
@ReverseAutoMapping(ignore = true)
|
||||||
|
|
||||||
private String actions;
|
private String actions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
*/
|
*/
|
||||||
package cc.iotkit.data.service;
|
package cc.iotkit.data.service;
|
||||||
|
|
||||||
|
import cc.iotkit.common.utils.JsonUtils;
|
||||||
import cc.iotkit.common.utils.MapstructUtils;
|
import cc.iotkit.common.utils.MapstructUtils;
|
||||||
import cc.iotkit.data.dao.IJPACommData;
|
import cc.iotkit.data.dao.IJPACommData;
|
||||||
import cc.iotkit.data.manager.ITaskInfoData;
|
import cc.iotkit.data.manager.ITaskInfoData;
|
||||||
import cc.iotkit.data.dao.TaskInfoRepository;
|
import cc.iotkit.data.dao.TaskInfoRepository;
|
||||||
import cc.iotkit.data.model.TbTaskInfo;
|
import cc.iotkit.data.model.TbTaskInfo;
|
||||||
import cc.iotkit.common.api.Paging;
|
import cc.iotkit.common.api.Paging;
|
||||||
|
import cc.iotkit.model.rule.RuleAction;
|
||||||
import cc.iotkit.model.rule.TaskInfo;
|
import cc.iotkit.model.rule.TaskInfo;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -27,6 +29,7 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Primary
|
@Primary
|
||||||
@Service
|
@Service
|
||||||
|
@ -38,7 +41,8 @@ public class TaskInfoDataImpl implements ITaskInfoData, IJPACommData<TaskInfo, S
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskInfo> findByUid(String uid) {
|
public List<TaskInfo> findByUid(String uid) {
|
||||||
return MapstructUtils.convert(taskInfoRepository.findByUid(uid), TaskInfo.class);
|
return taskInfoRepository.findByUid(uid).stream().map(this::to)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,7 +50,9 @@ public class TaskInfoDataImpl implements ITaskInfoData, IJPACommData<TaskInfo, S
|
||||||
Page<TbTaskInfo> paged = taskInfoRepository.findByUid(uid,
|
Page<TbTaskInfo> paged = taskInfoRepository.findByUid(uid,
|
||||||
Pageable.ofSize(size).withPage(page - 1));
|
Pageable.ofSize(size).withPage(page - 1));
|
||||||
return new Paging<>(paged.getTotalElements(),
|
return new Paging<>(paged.getTotalElements(),
|
||||||
MapstructUtils.convert(paged.getContent(), TaskInfo.class));
|
paged.getContent().stream().map(this::to)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,23 +77,31 @@ public class TaskInfoDataImpl implements ITaskInfoData, IJPACommData<TaskInfo, S
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskInfo findById(String s) {
|
public TaskInfo findById(String s) {
|
||||||
return MapstructUtils.convert(taskInfoRepository.findById(s).orElse(null), TaskInfo.class);
|
return to(taskInfoRepository.findById(s).orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskInfo save(TaskInfo data) {
|
public TaskInfo save(TaskInfo data) {
|
||||||
if (StringUtils.isBlank(data.getId())) {
|
if (StringUtils.isBlank(data.getId())) {
|
||||||
data.setId(UUID.randomUUID().toString());
|
data.setId(UUID.randomUUID().toString());
|
||||||
data.setCreateAt(System.currentTimeMillis());
|
data.setCreateAt(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
taskInfoRepository.save(MapstructUtils.convert(data, TbTaskInfo.class));
|
taskInfoRepository.save(to(data));
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TaskInfo to(TbTaskInfo tb) {
|
||||||
|
TaskInfo convert = MapstructUtils.convert(tb, TaskInfo.class);
|
||||||
|
assert convert != null;
|
||||||
|
convert.setActions(JsonUtils.parseArray(tb.getActions(), RuleAction.class));
|
||||||
|
return convert;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TbTaskInfo to(TaskInfo t) {
|
||||||
|
TbTaskInfo convert = MapstructUtils.convert(t, TbTaskInfo.class);
|
||||||
|
assert convert != null;
|
||||||
|
convert.setActions(JsonUtils.toJsonString(t.getActions()));
|
||||||
|
return convert;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,17 @@
|
||||||
package cc.iotkit.manager.dto.bo.taskinfo;
|
package cc.iotkit.manager.dto.bo.taskinfo;
|
||||||
|
|
||||||
|
import cc.iotkit.common.api.BaseDto;
|
||||||
|
import cc.iotkit.model.rule.RuleAction;
|
||||||
import cc.iotkit.model.rule.TaskInfo;
|
import cc.iotkit.model.rule.TaskInfo;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapping;
|
|
||||||
import io.github.linpeilie.annotations.ReverseAutoMapping;
|
|
||||||
import jakarta.validation.constraints.Size;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import cc.iotkit.common.api.BaseDto;
|
|
||||||
import cc.iotkit.common.validate.AddGroup;
|
|
||||||
import cc.iotkit.common.validate.EditGroup;
|
|
||||||
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@ApiModel(value = "TaskInfoBo")
|
@ApiModel(value = "TaskInfoBo")
|
||||||
@Data
|
@Data
|
||||||
|
@ -37,10 +25,7 @@ public class TaskInfoBo extends BaseDto {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "任务输出")
|
@ApiModelProperty(value = "任务输出")
|
||||||
@Size(max = 65535, message = "任务输出长度不正确")
|
private List<RuleAction> actions;
|
||||||
@AutoMapping(ignore = true)
|
|
||||||
@ReverseAutoMapping(ignore = true)
|
|
||||||
private String actions;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private Long createAt;
|
private Long createAt;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cc.iotkit.manager.dto.vo.taskinfo;
|
package cc.iotkit.manager.dto.vo.taskinfo;
|
||||||
|
|
||||||
|
import cc.iotkit.model.rule.RuleAction;
|
||||||
import cc.iotkit.model.rule.TaskInfo;
|
import cc.iotkit.model.rule.TaskInfo;
|
||||||
import io.github.linpeilie.annotations.AutoMapping;
|
import io.github.linpeilie.annotations.AutoMapping;
|
||||||
import io.github.linpeilie.annotations.ReverseAutoMapping;
|
import io.github.linpeilie.annotations.ReverseAutoMapping;
|
||||||
|
@ -11,6 +12,7 @@ import lombok.ToString;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
@ -22,7 +24,6 @@ import io.github.linpeilie.annotations.AutoMapper;
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
@AutoMapper(target = TaskInfo.class)
|
@AutoMapper(target = TaskInfo.class)
|
||||||
|
|
||||||
public class TaskInfoVo implements Serializable {
|
public class TaskInfoVo implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1L;
|
private static final long serialVersionUID = -1L;
|
||||||
|
@ -33,9 +34,7 @@ public class TaskInfoVo implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(value = "任务输出")
|
@ApiModelProperty(value = "任务输出")
|
||||||
@ExcelProperty(value = "任务输出")
|
@ExcelProperty(value = "任务输出")
|
||||||
@AutoMapping(ignore = true)
|
private List<RuleAction> actions;
|
||||||
@ReverseAutoMapping(ignore = true)
|
|
||||||
private String actions;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
@ExcelProperty(value = "创建时间")
|
@ExcelProperty(value = "创建时间")
|
||||||
|
|
Loading…
Reference in New Issue