优化属性类型

master
chenxiwang 2024-08-06 11:20:12 +08:00
parent 86cbae223a
commit a2624d4510
2 changed files with 8 additions and 3 deletions

View File

@ -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<ForecastProject> saveHumanForecastResults(@RequestBody @Validated ForecastProject forecastProject) {
public R<ForecastProject> saveHumanForecastResults(@RequestBody @Validated ForecastProject forecastProject) throws ParseException {
if (CollectionUtils.isEmpty(forecastProject.getVoList())) {
throw new IllegalArgumentException("数据格式不正确");
}

View File

@ -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<ForecastProjectMapper, ForecastProject>
{
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<ForecastProjectMapper, F
* @auther: cxw
* @date: 2024-08-06, , 10:06:40
*/
public Boolean saveForecastResults(ForecastProject forecastProject) {
public Boolean saveForecastResults(ForecastProject forecastProject) throws ParseException {
List<ForecastResults> retList = new ArrayList<>();
List<ForecastResultVo> 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());