修复时间相差8小时的问题

hyx_2024-10-12_xgfPerson
shanao 2024-09-14 21:15:25 +08:00
parent 39f19b3526
commit d39cf3da87
2 changed files with 18 additions and 13 deletions

View File

@ -67,7 +67,7 @@ public class AccidentRecords implements Serializable {
/** /**
* *
*/ */
private String incidentDate; private Date incidentDate;
/** /**
* *
@ -130,7 +130,7 @@ public class AccidentRecords implements Serializable {
/** /**
* *
*/ */
private String reportDate; private Date reportDate;
/** /**
* *

View File

@ -2,6 +2,7 @@ package com.zcloud.service.accident.impl;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
@ -26,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -63,12 +63,6 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService {
AccidentRecords accidentRecords = new AccidentRecords(); AccidentRecords accidentRecords = new AccidentRecords();
accidentRecords.setId(IdUtil.fastSimpleUUID()); accidentRecords.setId(IdUtil.fastSimpleUUID());
accidentRecords.setCreatedBy(Jurisdiction.getUsername()); accidentRecords.setCreatedBy(Jurisdiction.getUsername());
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);
// 设置成东八区时间
dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
DateUtil.parse(dateFormat.format(date), DatePattern.NORM_DATETIME_PATTERN);
accidentRecords.setIsDeleted(0); accidentRecords.setIsDeleted(0);
String corpinfoId = StrUtil.isEmpty(accidentRecords.getCorpinfoId()) ? Jurisdiction.getCORPINFO_ID() : accidentRecords.getCorpinfoId(); String corpinfoId = StrUtil.isEmpty(accidentRecords.getCorpinfoId()) ? Jurisdiction.getCORPINFO_ID() : accidentRecords.getCorpinfoId();
@ -78,7 +72,12 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService {
accidentRecords.setIncidentType(pageData.getString("incidentType")); accidentRecords.setIncidentType(pageData.getString("incidentType"));
accidentRecords.setIncidentLevel(pageData.getString("incidentLevel")); accidentRecords.setIncidentLevel(pageData.getString("incidentLevel"));
accidentRecords.setLocation(pageData.getString("location")); accidentRecords.setLocation(pageData.getString("location"));
accidentRecords.setIncidentDate(pageData.getString("incidentDate"));
DateTime time = DateUtil.parse(pageData.getString("incidentDate"), "yyyy-MM-dd HH:mm:ss");
accidentRecords.setIncidentDate(time);
DateTime time1 = DateUtil.parse(pageData.getString("incidentDate"), "yyyy-MM-dd HH:mm:ss");
accidentRecords.setReportDate(time1);
accidentRecords.setDirectLoss(Convert.toInt(pageData.get("directLoss"))); accidentRecords.setDirectLoss(Convert.toInt(pageData.get("directLoss")));
accidentRecords.setInjured(Convert.toInt(pageData.get("injured"))); accidentRecords.setInjured(Convert.toInt(pageData.get("injured")));
accidentRecords.setSeriouslyInjured(Convert.toInt(pageData.get("seriouslyInjured"))); accidentRecords.setSeriouslyInjured(Convert.toInt(pageData.get("seriouslyInjured")));
@ -88,7 +87,7 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService {
accidentRecords.setSuggestions(pageData.getString("suggestions")); accidentRecords.setSuggestions(pageData.getString("suggestions"));
accidentRecords.setMeasures(pageData.getString("measures")); accidentRecords.setMeasures(pageData.getString("measures"));
accidentRecords.setCreator(pageData.getString("creator")); accidentRecords.setCreator(pageData.getString("creator"));
accidentRecords.setReportDate(pageData.getString("reportDate")); accidentRecords.setPhotos(pageData.getString("photos"));
Assert.isTrue(accidentRecordsMapper.save(accidentRecords) == 1, "新增事故记录失败"); Assert.isTrue(accidentRecordsMapper.save(accidentRecords) == 1, "新增事故记录失败");
} }
@ -102,7 +101,12 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService {
accidentRecords.setIncidentType(pageData.getString("incidentType")); accidentRecords.setIncidentType(pageData.getString("incidentType"));
accidentRecords.setIncidentLevel(pageData.getString("incidentLevel")); accidentRecords.setIncidentLevel(pageData.getString("incidentLevel"));
accidentRecords.setLocation(pageData.getString("location")); accidentRecords.setLocation(pageData.getString("location"));
accidentRecords.setIncidentDate(pageData.getString("incidentDate"));
DateTime time = DateUtil.parse(pageData.getString("incidentDate"), "yyyy-MM-dd HH:mm:ss");
accidentRecords.setIncidentDate(time);
DateTime time1 = DateUtil.parse(pageData.getString("incidentDate"), "yyyy-MM-dd HH:mm:ss");
accidentRecords.setReportDate(time1);
accidentRecords.setDirectLoss(Convert.toInt(pageData.get("directLoss"))); accidentRecords.setDirectLoss(Convert.toInt(pageData.get("directLoss")));
accidentRecords.setInjured(Convert.toInt(pageData.get("injured"))); accidentRecords.setInjured(Convert.toInt(pageData.get("injured")));
accidentRecords.setSeriouslyInjured(Convert.toInt(pageData.get("seriouslyInjured"))); accidentRecords.setSeriouslyInjured(Convert.toInt(pageData.get("seriouslyInjured")));
@ -112,9 +116,10 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService {
accidentRecords.setSuggestions(pageData.getString("suggestions")); accidentRecords.setSuggestions(pageData.getString("suggestions"));
accidentRecords.setMeasures(pageData.getString("measures")); accidentRecords.setMeasures(pageData.getString("measures"));
accidentRecords.setCreator(pageData.getString("creator")); accidentRecords.setCreator(pageData.getString("creator"));
accidentRecords.setReportDate(pageData.getString("reportDate")); accidentRecords.setPhotos(pageData.getString("creator"));
accidentRecords.setUpdatedBy(Jurisdiction.getUsername()); accidentRecords.setUpdatedBy(Jurisdiction.getUsername());
accidentRecords.setUpdatedTime(new Date()); accidentRecords.setUpdatedTime(new Date());
accidentRecords.setPhotos(pageData.getString("photos") == null ? null : pageData.getString("photos"));
String corpinfoId = StrUtil.isEmpty(accidentRecords.getCorpinfoId()) ? Jurisdiction.getCORPINFO_ID() : accidentRecords.getCorpinfoId(); String corpinfoId = StrUtil.isEmpty(accidentRecords.getCorpinfoId()) ? Jurisdiction.getCORPINFO_ID() : accidentRecords.getCorpinfoId();
accidentRecords.setCorpinfoId(corpinfoId); accidentRecords.setCorpinfoId(corpinfoId);
Assert.isTrue(accidentRecordsMapper.updateById(accidentRecords) == 1, "更新事故记录失败"); Assert.isTrue(accidentRecordsMapper.updateById(accidentRecords) == 1, "更新事故记录失败");