diff --git a/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java b/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java index defdc70a..f46e4dab 100644 --- a/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java +++ b/src/main/java/com/zcloud/controller/accident/AccidentRecordsController.java @@ -1,7 +1,6 @@ package com.zcloud.controller.accident; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.zcloud.controller.base.BaseController; @@ -56,7 +55,7 @@ public class AccidentRecordsController extends BaseController { */ @ResponseBody @RequestMapping("/{id}") - public Map getById(@PathVariable("id") Long id) { + public Map getById(@PathVariable("id") String id) { Map result = new HashMap<>(); result.put("result", "success"); result.put("info", accidentRecordsService.getById(Optional.of(id).orElseThrow(() -> new RuntimeException("id不能为空")))); @@ -109,7 +108,7 @@ public class AccidentRecordsController extends BaseController { if (StrUtil.isEmpty(values)) { throw new RuntimeException("id不能为空"); } - List ids = Arrays.stream(values.split(",")).map(Convert::toLong).filter(ObjectUtil::isNotEmpty) + List ids = Arrays.stream(values.split(",")).filter(ObjectUtil::isNotEmpty) .collect(Collectors.toList()); accidentRecordsService.delete(ids); Map result = new HashMap<>(); diff --git a/src/main/java/com/zcloud/entity/accident/AccidentRecords.java b/src/main/java/com/zcloud/entity/accident/AccidentRecords.java index 8810b955..f44e8ca1 100644 --- a/src/main/java/com/zcloud/entity/accident/AccidentRecords.java +++ b/src/main/java/com/zcloud/entity/accident/AccidentRecords.java @@ -21,7 +21,7 @@ public class AccidentRecords implements Serializable { * 主键ID */ @NotNull(message = "主键ID不能为null") - private Long id; + private String id; /** * 事故案号 diff --git a/src/main/java/com/zcloud/entity/accident/dto/AccidentRecordsExcel.java b/src/main/java/com/zcloud/entity/accident/dto/AccidentRecordsExcel.java index 1fb330fd..3ce42a56 100644 --- a/src/main/java/com/zcloud/entity/accident/dto/AccidentRecordsExcel.java +++ b/src/main/java/com/zcloud/entity/accident/dto/AccidentRecordsExcel.java @@ -1,9 +1,11 @@ package com.zcloud.entity.accident.dto; +import cn.hutool.core.date.DateUtil; import com.zcloud.entity.accident.ExcelValue; import lombok.Data; import java.io.Serializable; +import java.util.Date; @Data public class AccidentRecordsExcel implements Serializable { @@ -38,11 +40,11 @@ public class AccidentRecordsExcel implements Serializable { @ExcelValue(value = "事故级别") private String incidentLevel; - /** - * 事故性质 - */ - @ExcelValue(value = "事故性质") - private String incidentNature; +// /** +// * 事故性质 +// */ +// @ExcelValue(value = "事故性质") +// private String incidentNature; /** * 事故发生地点 @@ -121,4 +123,13 @@ public class AccidentRecordsExcel implements Serializable { */ @ExcelValue(value = "报出日期") private String reportDate; + + + public void setIncidentDate(Date incidentDate) { + this.incidentDate = DateUtil.format(incidentDate, "yyyy年MM月dd日HH时mm分ss秒"); + } + + public void setReportDate(Date reportDate) { + this.reportDate = DateUtil.format(reportDate, "yyyy年MM月dd日HH时mm分ss秒"); + } } diff --git a/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java b/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java index adf3e2ae..aa9012fd 100644 --- a/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java +++ b/src/main/java/com/zcloud/mapper/datasource/accident/AccidentRecordsMapper.java @@ -25,7 +25,7 @@ public interface AccidentRecordsMapper { * @param id id * @return 结果 */ - PageData getById(Long id); + PageData getById(String id); /** * 新增 @@ -49,7 +49,7 @@ public interface AccidentRecordsMapper { * @param ids 主键数组 * @return 受影响的行数 */ - int delete(@Param("ids") List ids); + int delete(@Param("ids") List ids); /** * 导出excel diff --git a/src/main/java/com/zcloud/service/accident/AccidentRecordsService.java b/src/main/java/com/zcloud/service/accident/AccidentRecordsService.java index dc897d5f..8ed30d49 100644 --- a/src/main/java/com/zcloud/service/accident/AccidentRecordsService.java +++ b/src/main/java/com/zcloud/service/accident/AccidentRecordsService.java @@ -24,7 +24,7 @@ public interface AccidentRecordsService { * @param id 主键 * @return 查询结果 */ - PageData getById(Long id); + PageData getById(String id); /** * 新增 @@ -45,7 +45,7 @@ public interface AccidentRecordsService { * * @param ids 主键数组 */ - void delete(List ids); + void delete(List ids); /** * 导出Excel 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 bb3c35c2..f3777606 100644 --- a/src/main/java/com/zcloud/service/accident/impl/AccidentRecordsServiceImpl.java +++ b/src/main/java/com/zcloud/service/accident/impl/AccidentRecordsServiceImpl.java @@ -1,5 +1,8 @@ package com.zcloud.service.accident.impl; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ReflectUtil; @@ -12,17 +15,17 @@ import com.zcloud.entity.accident.dto.AccidentRecordsExcel; import com.zcloud.mapper.datasource.accident.AccidentRecordsMapper; import com.zcloud.service.accident.AccidentRecordsService; import com.zcloud.service.bus.ImgFilesService; -import com.zcloud.util.*; +import com.zcloud.util.Const; +import com.zcloud.util.Jurisdiction; +import com.zcloud.util.Smb; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FilenameUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.lang.reflect.Field; -import java.time.LocalDateTime; -import java.time.ZoneOffset; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -49,17 +52,22 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { } @Override - public PageData getById(Long id) { + public PageData getById(String id) { return accidentRecordsMapper.getById(id); } @Override @Transactional(rollbackFor = Exception.class) public void save(AccidentRecords accidentRecords) { - accidentRecords.setId(IdUtil.getSnowflake(1, 1).nextId()); + accidentRecords.setId(IdUtil.fastSimpleUUID()); accidentRecords.setCreatedBy(Jurisdiction.getUsername()); - Date date = Date.from(LocalDateTime.now().toInstant(ZoneOffset.of("+08:00"))); - accidentRecords.setCreatedTime(date); + 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(); accidentRecords.setCorpinfoId(corpinfoId); @@ -70,8 +78,7 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { @Transactional(rollbackFor = Exception.class) public void update(AccidentRecords accidentRecords) { accidentRecords.setUpdatedBy(Jurisdiction.getUsername()); - Date date = Date.from(LocalDateTime.now().toInstant(ZoneOffset.of("+08:00"))); - accidentRecords.setUpdatedTime(date); + accidentRecords.setUpdatedTime(new Date()); String corpinfoId = StrUtil.isEmpty(accidentRecords.getCorpinfoId()) ? Jurisdiction.getCORPINFO_ID() : accidentRecords.getCorpinfoId(); accidentRecords.setCorpinfoId(corpinfoId); Assert.isTrue(accidentRecordsMapper.updateById(accidentRecords) == 1, "更新事故记录失败"); @@ -79,7 +86,7 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { @Override @Transactional(rollbackFor = Exception.class) - public void delete(List ids) { + public void delete(List ids) { Assert.isTrue(accidentRecordsMapper.delete(ids) == ids.size(), "删除事故记录失败"); } @@ -152,13 +159,13 @@ public class AccidentRecordsServiceImpl implements AccidentRecordsService { @Override public String importPhotos(MultipartFile file) { - String fileName = UuidUtil.get32UUID() + "." + FilenameUtils.getExtension(file.getOriginalFilename()); + String fileName = IdUtil.fastSimpleUUID() + "." + FileUtil.extName(file.getOriginalFilename()); PageData pd = new PageData(); - pd.put("IMGFILES_ID", UuidUtil.get32UUID()); - pd.put("FOREIGN_KEY", UuidUtil.get32UUID()); + pd.put("IMGFILES_ID", IdUtil.fastSimpleUUID()); + pd.put("FOREIGN_KEY", IdUtil.fastSimpleUUID()); pd.put("TYPE", 117); try { - String path = Const.FILEPATHFILE + UuidUtil.get32UUID() + "/" + DateUtil.getDays(); + String path = Const.FILEPATHFILE + IdUtil.fastSimpleUUID() + "/" + DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN); Smb.sshSftp(file, fileName, path); pd.put("FILEPATH", path + "/" + fileName); imgFilesService.save(pd); diff --git a/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml b/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml index 7886d92e..fcfd5164 100644 --- a/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml +++ b/src/main/resources/mybatis/datasource/accident/AccidentRecordsMapper.xml @@ -3,143 +3,143 @@ - insert into accident_records + insert into bus_accident - accident_id, + ACCIDENT_ID, - incident_number, + INCIDENT_NUMBER, - incident_name, + INCIDENT_NAME, - incident_type, + INCIDENT_TYPE, - corpinfo_id, + CORPINFO_ID, - incident_level, + INCIDENT_LEVEL, - incident_nature, + INCIDENT_NATURE, - location, + LOCATION, - incident_date, + INCIDENT_DATE, - direct_loss, + DIRECT_LOSS, - injured, + INJURED, - fatalities, + FATALITIES, - seriously_injured, + SERIOUSLY_INJURED, - cause, + CAUSE, - summary, + SUMMARY, - photos, + PHOTOS, - analysis, + ANALYSIS, - suggestions, + SUGGESTIONS, - measures, + MEASURES, - creator, + CREATOR, - report_date, + REPORT_DATE, - created_by, + CREATED_BY, - created_time, + CREATED_TIME, - updated_by, + UPDATED_BY, - updated_time, + UPDATED_TIME, - is_deleted + IS_DELETED values @@ -226,7 +226,7 @@ - UPDATE accident_records + UPDATE bus_accident incident_number = #{incidentNumber}, incident_name = #{incidentName}, @@ -258,7 +258,7 @@ - update accident_records + update bus_accident set is_deleted = 1 where accident_id IN @@ -268,32 +268,31 @@