From a2624d4510a1f32cf754d6e91bf1811a9f753449 Mon Sep 17 00:00:00 2001 From: chenxiwang <1520264117@qq.com> Date: Tue, 6 Aug 2024 11:20:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B1=9E=E6=80=A7=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/xyt/controller/ForecastProjectController.java | 3 ++- .../project/xyt/service/ForecastProjectService.java | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gunshi/project/xyt/controller/ForecastProjectController.java b/src/main/java/com/gunshi/project/xyt/controller/ForecastProjectController.java index 015740c..78954ab 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/ForecastProjectController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/ForecastProjectController.java @@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.io.Serializable; +import java.text.ParseException; import java.util.List; import java.util.Objects; @@ -102,7 +103,7 @@ public class ForecastProjectController { @Operation(summary = "保存人工交互洪水预报结果") @PostMapping("/saveHumanForecastResults") - public R saveHumanForecastResults(@RequestBody @Validated ForecastProject forecastProject) { + public R saveHumanForecastResults(@RequestBody @Validated ForecastProject forecastProject) throws ParseException { if (CollectionUtils.isEmpty(forecastProject.getVoList())) { throw new IllegalArgumentException("数据格式不正确"); } diff --git a/src/main/java/com/gunshi/project/xyt/service/ForecastProjectService.java b/src/main/java/com/gunshi/project/xyt/service/ForecastProjectService.java index 5f5b7ff..bf9e4ed 100644 --- a/src/main/java/com/gunshi/project/xyt/service/ForecastProjectService.java +++ b/src/main/java/com/gunshi/project/xyt/service/ForecastProjectService.java @@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; @@ -25,6 +27,8 @@ import java.util.List; public class ForecastProjectService extends ServiceImpl { + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + @Autowired private ForecastResultsService forecastResultsService; @@ -35,13 +39,13 @@ public class ForecastProjectService extends ServiceImpl retList = new ArrayList<>(); List voList = forecastProject.getVoList(); for (ForecastResultVo vo : voList) { ForecastResults forecastResults = new ForecastResults(); forecastResults.setId(IdWorker.getId()); - forecastResults.setTm(vo.getTm()); + forecastResults.setTm(sdf.parse(vo.getTm())); forecastResults.setYcRkQValue(vo.getYcRkQValue()); forecastResults.setRealRkQValue(vo.getRealRkQValue()); forecastResults.setYcCkQValue(vo.getYcCkQValue());