From d39cf3da8798043a28c270f970d93f4d8fe7afd3 Mon Sep 17 00:00:00 2001 From: shanao Date: Sat, 14 Sep 2024 21:15:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E7=9B=B8?= =?UTF-8?q?=E5=B7=AE8=E5=B0=8F=E6=97=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/accident/AccidentRecords.java | 4 +-- .../impl/AccidentRecordsServiceImpl.java | 27 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/zcloud/entity/accident/AccidentRecords.java b/src/main/java/com/zcloud/entity/accident/AccidentRecords.java index 3fc18cc2..f44e8ca1 100644 --- a/src/main/java/com/zcloud/entity/accident/AccidentRecords.java +++ b/src/main/java/com/zcloud/entity/accident/AccidentRecords.java @@ -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; /** * 创建人 diff --git a/src/main/java/com/zcloud/service/accident/impl/AccidentRecordsServiceImpl.java b/src/main/java/com/zcloud/service/accident/impl/AccidentRecordsServiceImpl.java index 493cf2d5..b9e08329 100644 --- a/src/main/java/com/zcloud/service/accident/impl/AccidentRecordsServiceImpl.java +++ b/src/main/java/com/zcloud/service/accident/impl/AccidentRecordsServiceImpl.java @@ -2,6 +2,7 @@ package com.zcloud.service.accident.impl; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.lang.Assert; @@ -26,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.lang.reflect.Field; -import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -63,12 +63,6 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { AccidentRecords accidentRecords = new AccidentRecords(); accidentRecords.setId(IdUtil.fastSimpleUUID()); 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); 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.setIncidentLevel(pageData.getString("incidentLevel")); 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.setInjured(Convert.toInt(pageData.get("injured"))); accidentRecords.setSeriouslyInjured(Convert.toInt(pageData.get("seriouslyInjured"))); @@ -88,7 +87,7 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { accidentRecords.setSuggestions(pageData.getString("suggestions")); accidentRecords.setMeasures(pageData.getString("measures")); accidentRecords.setCreator(pageData.getString("creator")); - accidentRecords.setReportDate(pageData.getString("reportDate")); + accidentRecords.setPhotos(pageData.getString("photos")); Assert.isTrue(accidentRecordsMapper.save(accidentRecords) == 1, "新增事故记录失败"); } @@ -102,7 +101,12 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { accidentRecords.setIncidentType(pageData.getString("incidentType")); accidentRecords.setIncidentLevel(pageData.getString("incidentLevel")); 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.setInjured(Convert.toInt(pageData.get("injured"))); accidentRecords.setSeriouslyInjured(Convert.toInt(pageData.get("seriouslyInjured"))); @@ -112,9 +116,10 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { accidentRecords.setSuggestions(pageData.getString("suggestions")); accidentRecords.setMeasures(pageData.getString("measures")); accidentRecords.setCreator(pageData.getString("creator")); - accidentRecords.setReportDate(pageData.getString("reportDate")); + accidentRecords.setPhotos(pageData.getString("creator")); accidentRecords.setUpdatedBy(Jurisdiction.getUsername()); 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(); accidentRecords.setCorpinfoId(corpinfoId); Assert.isTrue(accidentRecordsMapper.updateById(accidentRecords) == 1, "更新事故记录失败");