Commit 4dd5e69e7588c52902e34b3f3156a239c4a41178
1 parent
3231a48a
fix: fix ReportFormConfig and SysJob bug
Showing
7 changed files
with
42 additions
and
12 deletions
@@ -55,7 +55,6 @@ public class SysJobController extends BaseController { | @@ -55,7 +55,6 @@ public class SysJobController extends BaseController { | ||
55 | 55 | ||
56 | HashMap<String, Object> queryMap = new HashMap<>(); | 56 | HashMap<String, Object> queryMap = new HashMap<>(); |
57 | boolean isPtAdmin = getCurrentUser().isPtAdmin(); | 57 | boolean isPtAdmin = getCurrentUser().isPtAdmin(); |
58 | - String tenantId = isPtAdmin ? null : getCurrentUser().getCurrentTenantId(); | ||
59 | queryMap.put(PAGE_SIZE, pageSize); | 58 | queryMap.put(PAGE_SIZE, pageSize); |
60 | queryMap.put(PAGE, page); | 59 | queryMap.put(PAGE, page); |
61 | queryMap.put(ORDER_FILED, orderBy); | 60 | queryMap.put(ORDER_FILED, orderBy); |
@@ -65,7 +64,7 @@ public class SysJobController extends BaseController { | @@ -65,7 +64,7 @@ public class SysJobController extends BaseController { | ||
65 | queryMap.put("jobName", jobName); | 64 | queryMap.put("jobName", jobName); |
66 | queryMap.put("jobGroup", jobGroup); | 65 | queryMap.put("jobGroup", jobGroup); |
67 | queryMap.put("status", status); | 66 | queryMap.put("status", status); |
68 | - return jobService.sysJobPage(queryMap, tenantId); | 67 | + return jobService.sysJobPage(queryMap); |
69 | } | 68 | } |
70 | 69 | ||
71 | @DeleteMapping | 70 | @DeleteMapping |
@@ -144,8 +143,7 @@ public class SysJobController extends BaseController { | @@ -144,8 +143,7 @@ public class SysJobController extends BaseController { | ||
144 | } | 143 | } |
145 | 144 | ||
146 | private ResponseResult<SysJobDTO> saveOrUpdate(SysJobDTO job) | 145 | private ResponseResult<SysJobDTO> saveOrUpdate(SysJobDTO job) |
147 | - throws SchedulerException, ThingsboardException { | ||
148 | - job.setTenantId(getCurrentUser().getCurrentTenantId()); | 146 | + throws SchedulerException{ |
149 | String message = StringUtils.isEmpty(job.getId()) ? "新增任务'" : "修改任务'"; | 147 | String message = StringUtils.isEmpty(job.getId()) ? "新增任务'" : "修改任务'"; |
150 | if (!CronUtils.isValid(job.getCronExpression())) { | 148 | if (!CronUtils.isValid(job.getCronExpression())) { |
151 | throw new YtDataValidationException(message + job.getJobName() + "'失败,Cron表达式不正确"); | 149 | throw new YtDataValidationException(message + job.getJobName() + "'失败,Cron表达式不正确"); |
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; | @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; | ||
5 | import lombok.Data; | 5 | import lombok.Data; |
6 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
7 | import org.thingsboard.server.common.data.yunteng.common.AddGroup; | 7 | import org.thingsboard.server.common.data.yunteng.common.AddGroup; |
8 | +import org.thingsboard.server.common.data.yunteng.dto.report.CycleParameterDTO; | ||
8 | import org.thingsboard.server.common.data.yunteng.dto.request.ExecuteAttributesDTO; | 9 | import org.thingsboard.server.common.data.yunteng.dto.request.ExecuteAttributesDTO; |
9 | import org.thingsboard.server.common.data.yunteng.dto.request.QueryConditionDTO; | 10 | import org.thingsboard.server.common.data.yunteng.dto.request.QueryConditionDTO; |
10 | import javax.validation.constraints.NotEmpty; | 11 | import javax.validation.constraints.NotEmpty; |
@@ -34,6 +35,9 @@ public class ReportFormConfigDTO extends TenantDTO { | @@ -34,6 +35,9 @@ public class ReportFormConfigDTO extends TenantDTO { | ||
34 | @NotNull(message = "执行方式不能为空", groups = AddGroup.class) | 35 | @NotNull(message = "执行方式不能为空", groups = AddGroup.class) |
35 | private Integer executeWay; | 36 | private Integer executeWay; |
36 | 37 | ||
38 | + @ApiModelProperty(value = "周期参数", required = true) | ||
39 | + private CycleParameterDTO cycle; | ||
40 | + | ||
37 | /** cron表达式:执行方式 1 生效 */ | 41 | /** cron表达式:执行方式 1 生效 */ |
38 | private String executeContent; | 42 | private String executeContent; |
39 | 43 |
1 | +package org.thingsboard.server.common.data.yunteng.dto.report; | ||
2 | + | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
4 | +import lombok.Data; | ||
5 | + | ||
6 | +/** 报表配置:周期参数 */ | ||
7 | +@Data | ||
8 | +public class CycleParameterDTO { | ||
9 | + @ApiModelProperty(value = "周期类型:0每日 1每周 2每月",required = true) | ||
10 | + private Integer cycleType; | ||
11 | + | ||
12 | + @ApiModelProperty(value = "当前周期") | ||
13 | + private String currentCycle; | ||
14 | + | ||
15 | + @ApiModelProperty(value = "时间",required = true) | ||
16 | + private String cycleTime; | ||
17 | +} |
@@ -29,6 +29,10 @@ public class ReportFormConfig extends TenantBaseEntity { | @@ -29,6 +29,10 @@ public class ReportFormConfig extends TenantBaseEntity { | ||
29 | @TableField(updateStrategy = FieldStrategy.IGNORED) | 29 | @TableField(updateStrategy = FieldStrategy.IGNORED) |
30 | private String executeContent; | 30 | private String executeContent; |
31 | 31 | ||
32 | + /** 周期参数:json数组格式 */ | ||
33 | + @TableField(typeHandler = JacksonTypeHandler.class) | ||
34 | + private JsonNode cycle; | ||
35 | + | ||
32 | /** 执行设备及属性:json数组格式 */ | 36 | /** 执行设备及属性:json数组格式 */ |
33 | @TableField(typeHandler = JacksonTypeHandler.class) | 37 | @TableField(typeHandler = JacksonTypeHandler.class) |
34 | private JsonNode executeAttributes; | 38 | private JsonNode executeAttributes; |
@@ -42,7 +42,7 @@ public class SysJobServiceImpl extends AbstractBaseService<SysJobMapper, SysJob> | @@ -42,7 +42,7 @@ public class SysJobServiceImpl extends AbstractBaseService<SysJobMapper, SysJob> | ||
42 | } | 42 | } |
43 | 43 | ||
44 | @Override | 44 | @Override |
45 | - public YtPageData<SysJobDTO> sysJobPage(Map<String, Object> queryMap, String tenantId) { | 45 | + public YtPageData<SysJobDTO> sysJobPage(Map<String, Object> queryMap) { |
46 | String jobGroup = queryMap.get("jobGroup") != null ? queryMap.get("jobGroup").toString() : null; | 46 | String jobGroup = queryMap.get("jobGroup") != null ? queryMap.get("jobGroup").toString() : null; |
47 | String jobName = queryMap.get("jobName") != null ? queryMap.get("jobName").toString() : null; | 47 | String jobName = queryMap.get("jobName") != null ? queryMap.get("jobName").toString() : null; |
48 | Integer status = | 48 | Integer status = |
@@ -51,7 +51,6 @@ public class SysJobServiceImpl extends AbstractBaseService<SysJobMapper, SysJob> | @@ -51,7 +51,6 @@ public class SysJobServiceImpl extends AbstractBaseService<SysJobMapper, SysJob> | ||
51 | baseMapper.selectPage( | 51 | baseMapper.selectPage( |
52 | getPage(queryMap, "create_time", false), | 52 | getPage(queryMap, "create_time", false), |
53 | new LambdaQueryWrapper<SysJob>() | 53 | new LambdaQueryWrapper<SysJob>() |
54 | - .eq(SysJob::getTenantId, tenantId) | ||
55 | .like(StringUtils.isNotEmpty(jobName), SysJob::getJobName, jobName) | 54 | .like(StringUtils.isNotEmpty(jobName), SysJob::getJobName, jobName) |
56 | .eq(StringUtils.isNotEmpty(jobGroup), SysJob::getJobGroup, jobGroup) | 55 | .eq(StringUtils.isNotEmpty(jobGroup), SysJob::getJobGroup, jobGroup) |
57 | .eq(null != status, SysJob::getStatus, status)); | 56 | .eq(null != status, SysJob::getStatus, status)); |
@@ -204,6 +203,7 @@ public class SysJobServiceImpl extends AbstractBaseService<SysJobMapper, SysJob> | @@ -204,6 +203,7 @@ public class SysJobServiceImpl extends AbstractBaseService<SysJobMapper, SysJob> | ||
204 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | 203 | throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
205 | } | 204 | } |
206 | newJob.setSourceId(job.getSourceId()); | 205 | newJob.setSourceId(job.getSourceId()); |
206 | + newJob.setTenantId(job.getTenantId()); | ||
207 | baseMapper.updateById(newJob); | 207 | baseMapper.updateById(newJob); |
208 | updateSchedulerJob(newJob, job.getJobGroup()); | 208 | updateSchedulerJob(newJob, job.getJobGroup()); |
209 | } | 209 | } |
@@ -13,6 +13,7 @@ import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | @@ -13,6 +13,7 @@ import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | ||
13 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; | 13 | import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException; |
14 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; | 14 | import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage; |
15 | import org.thingsboard.server.common.data.yunteng.dto.*; | 15 | import org.thingsboard.server.common.data.yunteng.dto.*; |
16 | +import org.thingsboard.server.common.data.yunteng.dto.report.CycleParameterDTO; | ||
16 | import org.thingsboard.server.common.data.yunteng.dto.request.ExecuteAttributesDTO; | 17 | import org.thingsboard.server.common.data.yunteng.dto.request.ExecuteAttributesDTO; |
17 | import org.thingsboard.server.common.data.yunteng.dto.request.QueryConditionDTO; | 18 | import org.thingsboard.server.common.data.yunteng.dto.request.QueryConditionDTO; |
18 | import org.thingsboard.server.common.data.yunteng.enums.JobGroupEnum; | 19 | import org.thingsboard.server.common.data.yunteng.enums.JobGroupEnum; |
@@ -37,8 +38,9 @@ public class YtReportFromConfigServiceImpl | @@ -37,8 +38,9 @@ public class YtReportFromConfigServiceImpl | ||
37 | private final YtSysJobService ytSysJobService; | 38 | private final YtSysJobService ytSysJobService; |
38 | private final YtReportGenerateRecordService ytReportGenerateRecordService; | 39 | private final YtReportGenerateRecordService ytReportGenerateRecordService; |
39 | private final UserOrganizationMappingService userOrganizationMappingService; | 40 | private final UserOrganizationMappingService userOrganizationMappingService; |
41 | + | ||
40 | @Override | 42 | @Override |
41 | - public YtPageData<ReportFormConfigDTO> page(Map<String, Object> queryMap,boolean tenantAdmin) { | 43 | + public YtPageData<ReportFormConfigDTO> page(Map<String, Object> queryMap, boolean tenantAdmin) { |
42 | String tenantId = | 44 | String tenantId = |
43 | Optional.ofNullable(queryMap.get("tenantId")).map(Object::toString).orElse(null); | 45 | Optional.ofNullable(queryMap.get("tenantId")).map(Object::toString).orElse(null); |
44 | List<String> organizationIds = | 46 | List<String> organizationIds = |
@@ -56,9 +58,11 @@ public class YtReportFromConfigServiceImpl | @@ -56,9 +58,11 @@ public class YtReportFromConfigServiceImpl | ||
56 | return null; | 58 | return null; |
57 | }) | 59 | }) |
58 | .orElse(null); | 60 | .orElse(null); |
59 | - if(!tenantAdmin && null != queryMap.get("userId")){ | 61 | + if (!tenantAdmin && null != queryMap.get("userId")) { |
60 | String userId = queryMap.get("userId").toString(); | 62 | String userId = queryMap.get("userId").toString(); |
61 | - organizationIds = userOrganizationMappingService.compareOrganizationIdsByCustomerId(organizationIds,userId); | 63 | + organizationIds = |
64 | + userOrganizationMappingService.compareOrganizationIdsByCustomerId( | ||
65 | + organizationIds, userId); | ||
62 | } | 66 | } |
63 | queryMap.put("organizationIds", organizationIds); | 67 | queryMap.put("organizationIds", organizationIds); |
64 | IPage<ReportFormConfigDTO> page = | 68 | IPage<ReportFormConfigDTO> page = |
@@ -88,7 +92,9 @@ public class YtReportFromConfigServiceImpl | @@ -88,7 +92,9 @@ public class YtReportFromConfigServiceImpl | ||
88 | } | 92 | } |
89 | }); | 93 | }); |
90 | } | 94 | } |
91 | - | 95 | + if (null != report.getCycle()) { |
96 | + reportFormConfig.setCycle(JacksonUtil.convertValue(report.getCycle(), JsonNode.class)); | ||
97 | + } | ||
92 | reportFormConfig.setExecuteAttributes( | 98 | reportFormConfig.setExecuteAttributes( |
93 | JacksonUtil.convertValue(report.getExecuteAttributes(), JsonNode.class)); | 99 | JacksonUtil.convertValue(report.getExecuteAttributes(), JsonNode.class)); |
94 | reportFormConfig.setQueryCondition( | 100 | reportFormConfig.setQueryCondition( |
@@ -280,6 +286,8 @@ public class YtReportFromConfigServiceImpl | @@ -280,6 +286,8 @@ public class YtReportFromConfigServiceImpl | ||
280 | getExecuteConditionAndAttribute(jsonNode, list); | 286 | getExecuteConditionAndAttribute(jsonNode, list); |
281 | QueryConditionDTO queryCondition = | 287 | QueryConditionDTO queryCondition = |
282 | JacksonUtil.convertValue(obj.getQueryCondition(), QueryConditionDTO.class); | 288 | JacksonUtil.convertValue(obj.getQueryCondition(), QueryConditionDTO.class); |
289 | + CycleParameterDTO cycle = JacksonUtil.convertValue(obj.getCycle(), CycleParameterDTO.class); | ||
290 | + dto.setCycle(cycle); | ||
283 | dto.setExecuteAttributes(list); | 291 | dto.setExecuteAttributes(list); |
284 | dto.setQueryCondition(queryCondition); | 292 | dto.setQueryCondition(queryCondition); |
285 | return dto; | 293 | return dto; |
@@ -14,10 +14,9 @@ public interface YtSysJobService | @@ -14,10 +14,9 @@ public interface YtSysJobService | ||
14 | * 获取quartz调度器的计划任务 | 14 | * 获取quartz调度器的计划任务 |
15 | * | 15 | * |
16 | * @param queryMap 查询参数 | 16 | * @param queryMap 查询参数 |
17 | - * @param tenantId 租户ID | ||
18 | * @return 分页数据 | 17 | * @return 分页数据 |
19 | */ | 18 | */ |
20 | - YtPageData<SysJobDTO> sysJobPage(Map<String, Object> queryMap, String tenantId); | 19 | + YtPageData<SysJobDTO> sysJobPage(Map<String, Object> queryMap); |
21 | 20 | ||
22 | /** | 21 | /** |
23 | * 通过调度任务ID查询调度信息 | 22 | * 通过调度任务ID查询调度信息 |