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());