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