From 36aadb3c1c689312b37c0500f4b458fec04f99f3 Mon Sep 17 00:00:00 2001 From: zhangyeguang Date: Tue, 10 Sep 2024 15:03:45 +0800 Subject: [PATCH] ams social modlue test --- .../ams/controller/JobController.java | 7 ++++--- .../ams/model/request/JobStatusRequest.java | 19 +++++++++++++++++++ .../jiagutech/ams/service/JobServiceImpl.java | 7 ++++++- web/src/main/resources/application.yml | 1 + 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 social/src/main/java/com/jiagutech/ams/model/request/JobStatusRequest.java diff --git a/social/src/main/java/com/jiagutech/ams/controller/JobController.java b/social/src/main/java/com/jiagutech/ams/controller/JobController.java index 9f6f81d..2d8a5d3 100644 --- a/social/src/main/java/com/jiagutech/ams/controller/JobController.java +++ b/social/src/main/java/com/jiagutech/ams/controller/JobController.java @@ -12,6 +12,7 @@ import com.jiagutech.ams.model.dto.JobTypeDTO; import com.jiagutech.ams.model.dto.TrackImageDTO; import com.jiagutech.ams.model.request.JobCreateRequest; import com.jiagutech.ams.model.request.JobPageRequest; +import com.jiagutech.ams.model.request.JobStatusRequest; import com.jiagutech.ams.model.response.JobCreateResponse; import com.jiagutech.ams.model.response.JobItem; import com.jiagutech.ams.model.response.JobTypeItem; @@ -53,9 +54,9 @@ public class JobController { @Operation(summary = "更新作业状态") @SaCheckRole(value = {"machinist", "admin"}, mode = SaMode.OR) - @PutMapping("/status") - public R updateJobStatus(@RequestParam("jobId") String jobId, @RequestParam("status") Integer status) { - jobService.updateJobStatus(Long.parseLong(jobId), status); + @PutMapping(value = "/status", consumes = "application/json") + public R updateJobStatus(@RequestBody JobStatusRequest request) { + jobService.updateJobStatus(Long.parseLong(request.getJobId()), request.getStatus()); return R.ok(); } diff --git a/social/src/main/java/com/jiagutech/ams/model/request/JobStatusRequest.java b/social/src/main/java/com/jiagutech/ams/model/request/JobStatusRequest.java new file mode 100644 index 0000000..1eaebd1 --- /dev/null +++ b/social/src/main/java/com/jiagutech/ams/model/request/JobStatusRequest.java @@ -0,0 +1,19 @@ +package com.jiagutech.ams.model.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.jiagutech.ams.utils.StringToLongDeserializer; +import lombok.Data; + +/** + * @ClassName JobPageRequest + * @author: zhangyeguang + * @create: 2024-09-02 15:18 + * @Version 1.0 + * @description: + **/ +@Data +public class JobStatusRequest { + private String jobId; + private Integer status; + +} diff --git a/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java b/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java index d8bec23..aa09bc0 100644 --- a/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java +++ b/social/src/main/java/com/jiagutech/ams/service/JobServiceImpl.java @@ -29,6 +29,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -136,7 +137,11 @@ public class JobServiceImpl implements JobService { List trackItems = new ArrayList<>(locusList.size()); for (Locus locus : locusList) { TrackItem trackItem = TrackMapping.INSTANCE.convertToTrackItemByLocus(locus); - trackItem.setImageUrl(trackImageDTOS.stream().filter(t -> t.getTs() == locus.getTimestamp()).findFirst().map(t -> t.getImageUrl()).orElse(null)); + Optional imageDTOOptional = trackImageDTOS.stream().filter(t -> t.getTs() .equals( locus.getTimestamp())).findFirst(); + if (imageDTOOptional.isPresent()) { + trackItem.setImageUrl(imageDTOOptional.get().getImageUrl()); + + } trackItems.add(trackItem); } return trackItems; diff --git a/web/src/main/resources/application.yml b/web/src/main/resources/application.yml index fe88ed2..4480cb8 100644 --- a/web/src/main/resources/application.yml +++ b/web/src/main/resources/application.yml @@ -24,6 +24,7 @@ spring: maxLifetime: 1800000 # 多久检查一次连接的活性 keepaliveTime: 30000 + connection-test-query: SELECT 1 data: redis: timeout: 10s