feat(calendar): 接收集团安全月历数据并批量保存

main
zhaokai 2026-07-02 17:19:35 +08:00
parent 4549f18637
commit b427c30582
31 changed files with 552 additions and 941 deletions

View File

@ -71,3 +71,5 @@ sg:
message:
code:
forward: MS000116
file:
url: http://192.168.192.201:8991/file/uploadFiles2/

View File

@ -71,3 +71,5 @@ sg:
message:
code:
forward: MS000145
file:
url: https://jpfz.qhdsafety.com/gbsFileTest/

View File

@ -4,7 +4,8 @@ import com.alibaba.fastjson.JSON;
import com.zcloud.safety.api.SgCalendarServiceI;
import com.zcloud.safety.domain.utils.EncryptAndDecryptUtil;
import com.zcloud.safety.domain.utils.Result;
import com.zcloud.safety.dto.receive.SgCalendarAuditDTO;
import com.zcloud.safety.dto.receive.SgCalendarReceiveBodyDTO;
import com.zcloud.safety.dto.receive.SgCalendarReceiveNoticeDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
@ -38,56 +39,64 @@ public class BusCalendarController {
private final SgCalendarServiceI sgCalendarService;
/**
*
*
*/
@PostMapping("/release")
@ApiOperation(value = "接收数港安全月历审核结果", notes = "用于接收数港统计审核后的状态回传")
@ApiOperation(value = "接收数港安全月历", notes = "用于接收集团下发的安全月历数据")
@ApiResponses({
@ApiResponse(code = 0, message = "成功"),
@ApiResponse(code = 500, message = "服务器内部错误"),
})
public Result release(@RequestParam(value = "key") String key,
@RequestParam(value = "value") String value) throws Exception {
@RequestParam(value = "value") String value) {
try {
log.info("开始接收数港安全月历审核结果,key={},value={}", key,value);
log.info("开始接收数港安全月历key长度{}value长度{}", key == null ? 0 : key.length(), value == null ? 0 : value.length());
if (!StringUtils.hasText(key) || !StringUtils.hasText(value)) {
log.warn("接收数港安全月历审核结果失败请求参数缺失key是否为空{}value是否为空{}", !StringUtils.hasText(key), !StringUtils.hasText(value));
log.warn("接收数港安全月历失败请求参数缺失key是否为空{}value是否为空{}", !StringUtils.hasText(key), !StringUtils.hasText(value));
return new Result(400, "请求参数不能为空", null);
}
String decryptValue = EncryptAndDecryptUtil.decryptSm4(EncryptAndDecryptUtil.decryptSm2(key), value);
log.info("接收数港安全月历审核结果成功,解密报文{}", decryptValue);
SgCalendarAuditDTO auditDTO = JSON.parseObject(decryptValue, SgCalendarAuditDTO.class);
String validateMessage = validateAudit(auditDTO);
log.info("数港安全月历报文解密成功,解密后内容{}", decryptValue);
SgCalendarReceiveBodyDTO receiveBodyDTO = JSON.parseObject(decryptValue, SgCalendarReceiveBodyDTO.class);
String validateMessage = validateReceiveBody(receiveBodyDTO);
if (validateMessage != null) {
log.warn("接收数港安全月历审核结果失败,报文校验未通过,原因:{},解密报文:{}", validateMessage, decryptValue);
log.warn("接收数港安全月历失败,报文校验未通过,原因:{},解密报文:{}", validateMessage, decryptValue);
return new Result(400, validateMessage, null);
}
log.info("开始接收数港安全月历审核结果,本地主键:{},审核状态:{}", auditDTO.getNoticeId(), auditDTO.getAuditType());
sgCalendarService.receiveAudit(auditDTO);
log.info("接收数港安全月历审核结果成功,本地主键:{},审核状态:{}", auditDTO.getNoticeId(), auditDTO.getAuditType());
sgCalendarService.receiveBatch(receiveBodyDTO);
log.info("接收数港安全月历成功,保存数量:{}", receiveBodyDTO.getNoticeList().size());
return Result.ok("成功");
} catch (Exception e) {
log.error("接收数港安全月历审核结果失败key长度{}", key == null ? 0 : key.length(), e);
log.error("接收数港安全月历失败key长度{}", key == null ? 0 : key.length(), e);
return new Result(500, "数据传输失败", null);
}
}
private String validateAudit(SgCalendarAuditDTO auditDTO) {
if (auditDTO == null) {
return "安全月历审核报文不能为空";
private String validateReceiveBody(SgCalendarReceiveBodyDTO receiveBodyDTO) {
if (receiveBodyDTO == null) {
return "安全月历报文不能为空";
}
if (auditDTO.getNoticeId() == null) {
return "通知id不能为空";
if (receiveBodyDTO.getNoticeList() == null || receiveBodyDTO.getNoticeList().isEmpty()) {
return "安全月历数据列表不能为空";
}
if (!StringUtils.hasText(auditDTO.getAuditType())) {
return "审核状态不能为空";
}
if (!"1".equals(auditDTO.getAuditType()) && !"2".equals(auditDTO.getAuditType())) {
return "审核状态不正确";
for (SgCalendarReceiveNoticeDTO notice : receiveBodyDTO.getNoticeList()) {
String validateMessage = validateNotice(notice);
if (validateMessage != null) {
return validateMessage;
}
}
return null;
}
private String validateNotice(SgCalendarReceiveNoticeDTO notice) {
if (notice == null) {
return "安全月历数据不能为空";
}
if (notice.getId() == null) {
return "安全月历id不能为空";
}
return null;
}
}

View File

@ -53,13 +53,13 @@ public class ImgFilesController {
}
@ApiOperation("详情")
@GetMapping("/{id}")
@GetMapping("/getInfoById/{id}")
public SingleResponse<ImgFilesCO> getInfoById(@PathVariable("id") Long id) {
return SingleResponse.of(new ImgFilesCO());
}
@ApiOperation("删除")
@DeleteMapping("/{id}")
@GetMapping("/remove/{id}")
public Response remove(@PathVariable("id") Long id) {
imgFilesService.remove(id);
return SingleResponse.buildSuccess();

View File

@ -1,17 +1,13 @@
package com.zcloud.safety.web;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.safety.api.SgCalendarServiceI;
import com.zcloud.safety.dto.SgCalendarAddCmd;
import com.zcloud.safety.dto.SgCalendarPageQry;
import com.zcloud.safety.dto.SgCalendarUpdateCmd;
import com.zcloud.safety.dto.clientobject.SgCalendarCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
@ -25,12 +21,6 @@ public class SgCalendarController {
private final SgCalendarServiceI sgCalendarService;
@ApiOperation("新增")
@PostMapping("/save")
public SingleResponse<SgCalendarCO> add(@Validated SgCalendarAddCmd cmd) {
return sgCalendarService.add(cmd);
}
@ApiOperation("分页")
@PostMapping("/list")
public PageResponse<SgCalendarCO> page(@RequestBody SgCalendarPageQry qry) {
@ -42,25 +32,4 @@ public class SgCalendarController {
public SingleResponse<SgCalendarCO> getInfoById(@PathVariable("id") Long id) {
return sgCalendarService.getInfoById(id);
}
@ApiOperation("删除")
@PostMapping("/{id}")
public Response remove(@PathVariable("id") Long id) {
sgCalendarService.remove(id);
return SingleResponse.buildSuccess();
}
/*
@ApiOperation("删除多个")
@DeleteMapping("/ids")
public Response removeBatch(@RequestParam Long[] ids) {
sgCalendarService.removeBatch(ids);
return SingleResponse.buildSuccess();
}*/
@ApiOperation("修改")
@PostMapping("/edit")
public SingleResponse<SgCalendarCO> edit(@Validated SgCalendarUpdateCmd cmd) {
sgCalendarService.edit(cmd);
return SingleResponse.buildSuccess();
}
}

View File

@ -1,20 +1,37 @@
package com.zcloud.safety.command;
import com.alibaba.cola.exception.BizException;
import com.zcloud.safety.config.FileUrlConfig;
import com.zcloud.safety.domain.config.SgProperties;
import com.zcloud.safety.domain.enums.PushOperationTypeEnum;
import com.zcloud.safety.domain.enums.PushSourceEnum;
import com.zcloud.safety.domain.utils.TokenUtils;
import com.zcloud.safety.persistence.dataobject.ImgFilesDO;
import com.zcloud.safety.persistence.dataobject.SgAccidentDO;
import com.zcloud.safety.persistence.repository.ImgFilesRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StreamUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
@ -28,9 +45,36 @@ public class SgAccidentPushSupport {
private static final PushSourceEnum DEFAULT_SOURCE = PushSourceEnum.QINGANG_GUFEN;
private final SgProperties sgProperties;
private final ImgFilesRepository imgFilesRepository;
private final FileUrlConfig fileUrlConfig;
/**
* 使
*
*/
public void pushAccident(SgAccidentDO sgAccidentDO, PushOperationTypeEnum operationType) {
if (sgAccidentDO == null || sgAccidentDO.getId() == null) {
throw new BizException("事故上报数据不存在,无法推送数港");
}
if (operationType == null) {
throw new BizException("事故上报推送操作类型不能为空");
}
try {
List<ImgFilesDO> imgFilesDOList = imgFilesRepository.listByForeignKey(sgAccidentDO.getAccidentId());
MultipartFile[] pushFiles = buildPushFiles(imgFilesDOList);
Map<String, Object> requestData = buildRequestData(sgAccidentDO, operationType);
doPush(sgAccidentDO, operationType, requestData, pushFiles);
} catch (BizException e) {
throw e;
} catch (Exception e) {
log.error("推送事故上报到数港失败,操作类型:{}-{},本地主键:{}",
operationType.getCode(), operationType.getValue(), sgAccidentDO.getId(), e);
throw new BizException("推送数港失败");
}
}
/**
* 使
*/
public void pushAccident(SgAccidentDO sgAccidentDO, PushOperationTypeEnum operationType, MultipartFile... files) {
if (sgAccidentDO == null || sgAccidentDO.getId() == null) {
@ -41,18 +85,9 @@ public class SgAccidentPushSupport {
}
try {
String token = resolveToken();
MultipartFile[] pushFiles = sanitizeFiles(files);
Map<String, Object> requestData = buildRequestData(sgAccidentDO, operationType);
log.info("开始推送事故上报到数港,操作类型:{}-{},来源:{}-{},本地主键:{},请求数据:{}",
operationType.getCode(), operationType.getValue(), DEFAULT_SOURCE.getCode(), DEFAULT_SOURCE.getValue(), sgAccidentDO.getId(), requestData);
if (sgProperties.getEnabled() == null || !sgProperties.getEnabled()) {
log.info("模拟真实推送事故上报到数港,操作类型:{}-{},来源:{}-{},本地主键:{}url{},附件数量:{}",
operationType.getCode(), operationType.getValue(), DEFAULT_SOURCE.getCode(), DEFAULT_SOURCE.getValue(), sgAccidentDO.getId(), sgProperties.getAccidentUrl(), files == null ? 0 : files.length);
} else {
TokenUtils.sendDataToThirdParty(sgProperties.getAccidentUrl(), requestData, token, files);
}
log.info("推送事故上报到数港成功,操作类型:{}-{},本地主键:{}",
operationType.getCode(), operationType.getValue(), sgAccidentDO.getId());
doPush(sgAccidentDO, operationType, requestData, pushFiles);
} catch (BizException e) {
throw e;
} catch (Exception e) {
@ -62,6 +97,23 @@ public class SgAccidentPushSupport {
}
}
private void doPush(SgAccidentDO sgAccidentDO, PushOperationTypeEnum operationType,
Map<String, Object> requestData, MultipartFile[] pushFiles) throws Exception {
String token = resolveToken();
log.info("开始推送事故上报到数港,操作类型:{}-{},来源:{}-{},本地主键:{},附件数量:{},请求数据:{}",
operationType.getCode(), operationType.getValue(), DEFAULT_SOURCE.getCode(), DEFAULT_SOURCE.getValue(),
sgAccidentDO.getId(), pushFiles.length, requestData);
if (sgProperties.getEnabled() == null || !sgProperties.getEnabled()) {
log.info("模拟真实推送事故上报到数港,操作类型:{}-{},来源:{}-{},本地主键:{}url{},附件数量:{}",
operationType.getCode(), operationType.getValue(), DEFAULT_SOURCE.getCode(), DEFAULT_SOURCE.getValue(),
sgAccidentDO.getId(), sgProperties.getAccidentUrl(), pushFiles.length);
} else {
TokenUtils.sendDataToThirdParty(sgProperties.getAccidentUrl(), requestData, token, pushFiles);
}
log.info("推送事故上报到数港成功,操作类型:{}-{},本地主键:{}",
operationType.getCode(), operationType.getValue(), sgAccidentDO.getId());
}
private String resolveToken() throws Exception {
String token;
if (sgProperties.getEnabled() == null || !sgProperties.getEnabled()) {
@ -69,7 +121,7 @@ public class SgAccidentPushSupport {
} else {
token = TokenUtils.getTokenFromThirdParty(sgProperties.getTokenUrl());
}
if (token == null || token.isEmpty()) {
if (!StringUtils.hasText(token)) {
throw new BizException("获取数港token失败");
}
return token;
@ -89,11 +141,82 @@ public class SgAccidentPushSupport {
return requestData;
}
/**
* 访使 file.url file_path
*/
private MultipartFile[] buildPushFiles(List<ImgFilesDO> imgFilesDOList) throws IOException {
if (imgFilesDOList == null || imgFilesDOList.isEmpty()) {
return new MultipartFile[0];
}
List<MultipartFile> multipartFileList = new ArrayList<>();
for (ImgFilesDO imgFilesDO : imgFilesDOList) {
if (imgFilesDO == null || !StringUtils.hasText(imgFilesDO.getFilePath()) || !StringUtils.hasText(imgFilesDO.getFileName())) {
continue;
}
String accessPath = buildAccessPath(imgFilesDO.getFilePath());
byte[] fileBytes = readFileBytes(accessPath);
multipartFileList.add(new StoredMultipartFile(imgFilesDO.getFileName(), fileBytes));
}
return multipartFileList.toArray(new MultipartFile[0]);
}
private MultipartFile[] sanitizeFiles(MultipartFile[] files) {
if (files == null || files.length == 0) {
return new MultipartFile[0];
}
List<MultipartFile> result = new ArrayList<>();
for (MultipartFile file : files) {
if (file != null && !file.isEmpty()) {
result.add(file);
}
}
return result.toArray(new MultipartFile[0]);
}
private String buildAccessPath(String filePath) {
if (!StringUtils.hasText(filePath)) {
return filePath;
}
String trimFilePath = filePath.trim();
if (trimFilePath.startsWith("http://") || trimFilePath.startsWith("https://")) {
return trimFilePath;
}
String prefixUrl = fileUrlConfig.getPrefixUrl();
if (!StringUtils.hasText(prefixUrl)) {
return trimFilePath;
}
if (prefixUrl.endsWith("/") && trimFilePath.startsWith("/")) {
return prefixUrl + trimFilePath.substring(1);
}
if (!prefixUrl.endsWith("/") && !trimFilePath.startsWith("/")) {
return prefixUrl + "/" + trimFilePath;
}
return prefixUrl + trimFilePath;
}
private byte[] readFileBytes(String accessPath) throws IOException {
try {
Path localPath = Paths.get(accessPath);
if (Files.exists(localPath)) {
return Files.readAllBytes(localPath);
}
} catch (Exception e) {
log.debug("事故上报附件路径不是本地文件,尝试按远程地址读取,路径:{}", accessPath);
}
try (InputStream inputStream = new URL(accessPath).openStream()) {
return StreamUtils.copyToByteArray(inputStream);
} catch (Exception e) {
throw new BizException("读取事故上报附件失败,路径:" + accessPath);
}
}
private String resolveCreateBy(SgAccidentDO sgAccidentDO) {
if (sgAccidentDO.getCreateName() != null && !sgAccidentDO.getCreateName().isEmpty()) {
if (StringUtils.hasText(sgAccidentDO.getCreateName())) {
return sgAccidentDO.getCreateName();
}
if (sgAccidentDO.getUpdateName() != null && !sgAccidentDO.getUpdateName().isEmpty()) {
if (StringUtils.hasText(sgAccidentDO.getUpdateName())) {
return sgAccidentDO.getUpdateName();
}
return "系统";
@ -107,4 +230,58 @@ public class SgAccidentPushSupport {
private String defaultString(String value) {
return value == null ? "" : value;
}
/**
* 使
*/
private static class StoredMultipartFile implements MultipartFile {
private final String originalFilename;
private final byte[] bytes;
private StoredMultipartFile(String originalFilename, byte[] bytes) {
this.originalFilename = originalFilename;
this.bytes = bytes == null ? new byte[0] : bytes;
}
@Override
public String getName() {
return "file";
}
@Override
public String getOriginalFilename() {
return originalFilename;
}
@Override
public String getContentType() {
return URLConnection.guessContentTypeFromName(originalFilename);
}
@Override
public boolean isEmpty() {
return bytes.length == 0;
}
@Override
public long getSize() {
return bytes.length;
}
@Override
public byte[] getBytes() {
return bytes;
}
@Override
public InputStream getInputStream() {
return new ByteArrayInputStream(bytes);
}
@Override
public void transferTo(File dest) throws IOException {
Files.write(dest.toPath(), bytes);
}
}
}

View File

@ -13,7 +13,6 @@ import com.zcloud.safety.persistence.repository.ImgFilesRepository;
import com.zcloud.safety.persistence.repository.SgAccidentRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
@ -50,6 +49,9 @@ public class SgAccidentUpdateExe {
try {
SgAccidentE sgAccidentE = new SgAccidentE();
if (cmd.getAccidentTime() != null && cmd.getAccidentTime().length() == 10) {
cmd.setAccidentTime(cmd.getAccidentTime() + " 00:00:00");
}
BeanUtils.copyProperties(cmd, sgAccidentE);
boolean res = sgAccidentGateway.update(sgAccidentE);
@ -57,14 +59,16 @@ public class SgAccidentUpdateExe {
throw new BizException("修改失败");
}
replaceAccidentFiles(cmd.getAccidentId(), cmd.getFiles());
// 修改时附件仅做新增补充,不再先删后增。
saveAccidentFiles(cmd.getAccidentId(), cmd.getFiles());
SgAccidentDO latestAccident = sgAccidentRepository.getById(cmd.getId());
if (latestAccident == null) {
throw new BizException("修改后未查询到事故上报数据");
}
sgAccidentPushSupport.pushAccident(latestAccident, PushOperationTypeEnum.UPDATE, cmd.getFiles());
log.info("事故上报修改完成,本地主键:{},附件数量:{}", cmd.getId(), cmd.getFiles() == null ? 0 : cmd.getFiles().length);
// 推送前统一按业务外键回查当前有效附件,保证页面先删图再编辑时也能推送最新附件集合。
sgAccidentPushSupport.pushAccident(latestAccident, PushOperationTypeEnum.UPDATE);
log.info("事故上报修改完成,本地主键:{},本次新增附件数量:{}", cmd.getId(), countValidFiles(cmd.getFiles()));
} catch (BizException e) {
log.error("修改事故上报失败,主键:{},原因:{}", cmd.getId(), e.getMessage(), e);
throw e;
@ -75,36 +79,49 @@ public class SgAccidentUpdateExe {
}
/**
*
*
*/
private void replaceAccidentFiles(String accidentId, MultipartFile[] files) throws Exception {
private void saveAccidentFiles(String accidentId, MultipartFile[] files) throws Exception {
if (files == null || files.length == 0) {
return;
}
imgFilesRepository.deletedImgFilesByForeignId(accidentId);
saveAccidentFiles(accidentId, files);
}
private void saveAccidentFiles(String accidentId, MultipartFile[] files) throws Exception {
List<ImgFilesDO> imgFilesDOList = new ArrayList<>();
for (MultipartFile file : files) {
if (file == null || file.isEmpty()) {
continue;
}
String fileName = Tools.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
String originalFilename = file.getOriginalFilename();
if (originalFilename == null || !originalFilename.contains(".")) {
throw new BizException("附件名称不合法");
}
String fileName = Tools.get32UUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
String filePath = zcloudImgFilesFacade.saveFileNoCorpinfoId(file.getBytes(), fileName, "accident");
ImgFilesDO imgFilesDO = new ImgFilesDO();
imgFilesDO.setImgFilesId(Tools.get32UUID());
imgFilesDO.setFilePath(filePath);
imgFilesDO.setForeignKey(accidentId);
imgFilesDO.setFileName(file.getOriginalFilename());
imgFilesDO.setFileName(originalFilename);
imgFilesDO.setType(ACCIDENT_FILE_TYPE);
imgFilesDOList.add(imgFilesDO);
}
if (!imgFilesDOList.isEmpty()) {
imgFilesRepository.saveBatch(imgFilesDOList);
log.info("事故上报附件保存完成,本地主键:{}附件数量:{}", accidentId, imgFilesDOList.size());
log.info("事故上报附件追加保存完成,业务外键:{},新增附件数量:{}", accidentId, imgFilesDOList.size());
}
}
private int countValidFiles(MultipartFile[] files) {
if (files == null || files.length == 0) {
return 0;
}
int count = 0;
for (MultipartFile file : files) {
if (file != null && !file.isEmpty()) {
count++;
}
}
return count;
}
}

View File

@ -1,107 +0,0 @@
package com.zcloud.safety.command;
import com.alibaba.cola.exception.BizException;
import com.zcloud.gbscommon.utils.Tools;
import com.zcloud.gbscommon.zcloudimgfiles.facade.ZcloudImgFilesFacade;
import com.zcloud.safety.domain.enums.PushOperationTypeEnum;
import com.zcloud.safety.domain.gateway.SgCalendarGateway;
import com.zcloud.safety.domain.model.SgCalendarE;
import com.zcloud.safety.dto.SgCalendarAddCmd;
import com.zcloud.safety.persistence.dataobject.ImgFilesDO;
import com.zcloud.safety.persistence.dataobject.SgCalendarDO;
import com.zcloud.safety.persistence.repository.ImgFilesRepository;
import com.zcloud.safety.persistence.repository.SgCalendarRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
@Slf4j
@Component
@AllArgsConstructor
public class SgCalendarAddExe {
private static final String PENDING_AUDIT_TYPE = "0";
private static final int CALENDAR_FILE_TYPE = 4;
private final SgCalendarGateway sgCalendarGateway;
private final SgCalendarRepository sgCalendarRepository;
private final ImgFilesRepository imgFilesRepository;
private final SgCalendarPushSupport sgCalendarPushSupport;
@DubboReference
private ZcloudImgFilesFacade zcloudImgFilesFacade;
@Transactional(rollbackFor = Exception.class)
public boolean execute(SgCalendarAddCmd cmd) {
SgCalendarE sgCalendarE = new SgCalendarE();
BeanUtils.copyProperties(cmd, sgCalendarE);
initAuditStatus(sgCalendarE);
try {
boolean res = sgCalendarGateway.add(sgCalendarE);
if (!res) {
throw new BizException("保存失败");
}
if (sgCalendarE.getId() == null) {
throw new BizException("新增安全月历后未获取到主键");
}
saveCalendarFiles(sgCalendarE.getCalendarId(), cmd.getFiles());
SgCalendarDO latestCalendar = sgCalendarRepository.getById(sgCalendarE.getId());
if (latestCalendar == null) {
throw new BizException("新增安全月历后未查询到数据");
}
sgCalendarPushSupport.pushCalendar(latestCalendar, PushOperationTypeEnum.ADD, cmd.getFiles());
return true;
} catch (BizException e) {
log.error("新增安全月历失败,原因:{}", e.getMessage(), e);
throw e;
} catch (Exception e) {
log.error("新增安全月历失败", e);
throw new BizException("保存失败");
}
}
private void initAuditStatus(SgCalendarE sgCalendarE) {
sgCalendarE.setAuditType(PENDING_AUDIT_TYPE);
sgCalendarE.setAuditContent("");
}
private void saveCalendarFiles(String calendarId, MultipartFile[] files) throws Exception {
if (files == null || files.length == 0) {
return;
}
List<ImgFilesDO> imgFilesDOList = new ArrayList<>();
for (MultipartFile file : files) {
if (file == null || file.isEmpty()) {
continue;
}
String fileName = Tools.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
String filePath = zcloudImgFilesFacade.saveFileNoCorpinfoId(file.getBytes(), fileName, "calendar");
ImgFilesDO imgFilesDO = new ImgFilesDO();
imgFilesDO.setImgFilesId(Tools.get32UUID());
imgFilesDO.setFilePath(filePath);
imgFilesDO.setForeignKey(calendarId);
imgFilesDO.setFileName(file.getOriginalFilename());
imgFilesDO.setType(CALENDAR_FILE_TYPE);
imgFilesDOList.add(imgFilesDO);
}
if (!imgFilesDOList.isEmpty()) {
imgFilesRepository.saveBatch(imgFilesDOList);
log.info("安全月历附件保存完成,本地主键:{},附件数量:{}", calendarId, imgFilesDOList.size());
}
}
}

View File

@ -1,103 +0,0 @@
package com.zcloud.safety.command;
import com.alibaba.cola.exception.BizException;
import com.zcloud.safety.domain.config.SgProperties;
import com.zcloud.safety.domain.enums.PushOperationTypeEnum;
import com.zcloud.safety.domain.enums.PushSourceEnum;
import com.zcloud.safety.domain.utils.TokenUtils;
import com.zcloud.safety.persistence.dataobject.SgCalendarDO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
@Slf4j
@Component
@AllArgsConstructor
public class SgCalendarPushSupport {
private static final PushSourceEnum DEFAULT_SOURCE = PushSourceEnum.QINGANG_GUFEN;
private final SgProperties sgProperties;
/**
* 便
*/
public void pushCalendar(SgCalendarDO sgCalendarDO, PushOperationTypeEnum operationType, MultipartFile... files) {
if (sgCalendarDO == null || sgCalendarDO.getId() == null) {
throw new BizException("安全月历数据不存在,无法推送数港");
}
if (operationType == null) {
throw new BizException("安全月历推送操作类型不能为空");
}
try {
String token = resolveToken();
Map<String, Object> requestData = buildRequestData(sgCalendarDO, operationType);
log.info("开始推送安全月历到数港,操作类型:{}-{},来源:{}-{},本地主键:{},请求数据:{}",
operationType.getCode(), operationType.getValue(), DEFAULT_SOURCE.getCode(), DEFAULT_SOURCE.getValue(), sgCalendarDO.getId(), requestData);
if (sgProperties.getEnabled() == null || !sgProperties.getEnabled()) {
log.info("模拟真实推送安全月历到数港,操作类型:{}-{},来源:{}-{},本地主键:{}url{},请求数据:{}",
operationType.getCode(), operationType.getValue(), DEFAULT_SOURCE.getCode(), DEFAULT_SOURCE.getValue(), sgCalendarDO.getId(), sgProperties.getCalendarUrl(), requestData);
} else {
TokenUtils.sendDataToThirdParty(sgProperties.getCalendarUrl(), requestData, token, files);
}
log.info("推送安全月历到数港成功,操作类型:{}-{},本地主键:{}",
operationType.getCode(), operationType.getValue(), sgCalendarDO.getId());
} catch (BizException e) {
throw e;
} catch (Exception e) {
log.error("推送安全月历到数港失败,操作类型:{}-{},本地主键:{}",
operationType.getCode(), operationType.getValue(), sgCalendarDO.getId(), e);
throw new BizException("推送数港失败");
}
}
private String resolveToken() throws Exception {
String token;
if (sgProperties.getEnabled() == null || !sgProperties.getEnabled()) {
token = "tokenAAAA";
} else {
token = TokenUtils.getTokenFromThirdParty(sgProperties.getTokenUrl());
}
if (token == null || token.isEmpty()) {
throw new BizException("获取数港token失败");
}
return token;
}
private Map<String, Object> buildRequestData(SgCalendarDO sgCalendarDO, PushOperationTypeEnum operationType) {
Map<String, Object> requestData = new HashMap<>();
requestData.put("operationType", operationType.getCode());
requestData.put("noticeId", sgCalendarDO.getId());
requestData.put("noticeTitle", defaultString(sgCalendarDO.getNoticeTitle()));
requestData.put("noticeType", defaultString(sgCalendarDO.getNoticeType()));
requestData.put("noticeContent", defaultString(sgCalendarDO.getNoticeContent()));
requestData.put("noticeDate", defaultString(sgCalendarDO.getNoticeDate()));
requestData.put("companyId", defaultString(sgCalendarDO.getCompanyId()));
requestData.put("companyName", defaultString(sgCalendarDO.getCompanyName()));
requestData.put("source", DEFAULT_SOURCE.getCode());
requestData.put("createBy", resolveCreateBy(sgCalendarDO));
return requestData;
}
private String resolveCreateBy(SgCalendarDO sgCalendarDO) {
if (sgCalendarDO.getCreateName() != null && !sgCalendarDO.getCreateName().isEmpty()) {
return sgCalendarDO.getCreateName();
}
if (sgCalendarDO.getUpdateName() != null && !sgCalendarDO.getUpdateName().isEmpty()) {
return sgCalendarDO.getUpdateName();
}
return "系统";
}
private String defaultString(String value) {
return value == null ? "" : value;
}
}

View File

@ -0,0 +1,76 @@
package com.zcloud.safety.command;
import com.alibaba.cola.exception.BizException;
import com.zcloud.safety.dto.receive.SgCalendarReceiveNoticeDTO;
import com.zcloud.safety.persistence.dataobject.SgCalendarDO;
import com.zcloud.safety.persistence.repository.SgCalendarRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
/**
*
*/
@Slf4j
@Component
@AllArgsConstructor
public class SgCalendarReceiveExe {
private final SgCalendarRepository sgCalendarRepository;
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public void execute(List<SgCalendarReceiveNoticeDTO> noticeList, String token) {
if (CollectionUtils.isEmpty(noticeList)) {
log.warn("接收安全月历批量数据为空未执行保存token长度{}", token == null ? 0 : token.length());
return;
}
log.info("开始批量保存安全月历,数量:{}token长度{}", noticeList.size(), token == null ? 0 : token.length());
for (SgCalendarReceiveNoticeDTO notice : noticeList) {
saveOrUpdate(notice);
}
log.info("批量保存安全月历完成,数量:{}", noticeList.size());
}
private void saveOrUpdate(SgCalendarReceiveNoticeDTO notice) {
if (notice == null || notice.getId() == null) {
throw new BizException("安全月历id不能为空");
}
SgCalendarDO calendarDO = sgCalendarRepository.getById(notice.getId());
boolean isNew = calendarDO == null;
if (isNew) {
calendarDO = new SgCalendarDO();
calendarDO.setId(notice.getId());
}
calendarDO.setCalendarId(String.valueOf(notice.getId()));
calendarDO.setAccidentTime(trim(notice.getAccidentTime()));
calendarDO.setAccidentUnit(trim(notice.getAccidentUnit()));
calendarDO.setAccidentProject(trim(notice.getAccidentProject()));
calendarDO.setAccidentDescription(trim(notice.getAccidentDescription()));
calendarDO.setAccidentLost(trim(notice.getAccidentLost()));
calendarDO.setAccidentLevel(trim(notice.getAccidentLevel()));
if (isNew) {
sgCalendarRepository.save(calendarDO);
log.info("新增安全月历成功id{}", notice.getId());
return;
}
sgCalendarRepository.updateById(calendarDO);
log.info("更新安全月历成功id{}", notice.getId());
}
private String trim(String value) {
return StringUtils.hasText(value) ? value.trim() : value;
}
}

View File

@ -1,52 +0,0 @@
package com.zcloud.safety.command;
import com.alibaba.cola.exception.BizException;
import com.zcloud.safety.domain.enums.PushOperationTypeEnum;
import com.zcloud.safety.domain.gateway.SgCalendarGateway;
import com.zcloud.safety.persistence.dataobject.SgCalendarDO;
import com.zcloud.safety.persistence.repository.ImgFilesRepository;
import com.zcloud.safety.persistence.repository.SgCalendarRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
/**
*
*/
@Slf4j
@Component
@AllArgsConstructor
public class SgCalendarRemoveExe {
private final SgCalendarGateway sgCalendarGateway;
private final SgCalendarRepository sgCalendarRepository;
private final ImgFilesRepository imgFilesRepository;
private final SgCalendarPushSupport sgCalendarPushSupport;
@Transactional(rollbackFor = Exception.class)
public boolean execute(Long id) {
SgCalendarDO sgCalendarDO = sgCalendarRepository.getById(id);
if (sgCalendarDO == null) {
throw new BizException("该数据不存在");
}
boolean res = sgCalendarGateway.deletedSgCalendarById(id);
if (!res) {
throw new BizException("删除失败");
}
imgFilesRepository.deletedImgFilesByForeignId(String.valueOf(id));
sgCalendarPushSupport.pushCalendar(sgCalendarDO, PushOperationTypeEnum.DELETE);
return true;
}
@Transactional(rollbackFor = Exception.class)
public boolean execute(Long[] ids) {
boolean res = sgCalendarGateway.deletedSgCalendarByIds(ids);
if (!res) {
throw new BizException("删除失败");
}
return true;
}
}

View File

@ -1,137 +0,0 @@
package com.zcloud.safety.command;
import com.alibaba.cola.exception.BizException;
import com.zcloud.gbscommon.utils.Tools;
import com.zcloud.gbscommon.zcloudimgfiles.facade.ZcloudImgFilesFacade;
import com.zcloud.safety.domain.enums.PushOperationTypeEnum;
import com.zcloud.safety.domain.gateway.SgCalendarGateway;
import com.zcloud.safety.domain.model.SgCalendarE;
import com.zcloud.safety.dto.SgCalendarUpdateCmd;
import com.zcloud.safety.dto.receive.SgCalendarAuditDTO;
import com.zcloud.safety.persistence.dataobject.ImgFilesDO;
import com.zcloud.safety.persistence.dataobject.SgCalendarDO;
import com.zcloud.safety.persistence.repository.ImgFilesRepository;
import com.zcloud.safety.persistence.repository.SgCalendarRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
@Slf4j
@Component
@AllArgsConstructor
public class SgCalendarUpdateExe {
private static final int CALENDAR_FILE_TYPE = 4;
private final SgCalendarGateway sgCalendarGateway;
private final SgCalendarRepository sgCalendarRepository;
private final ImgFilesRepository imgFilesRepository;
private final SgCalendarPushSupport sgCalendarPushSupport;
@DubboReference
private ZcloudImgFilesFacade zcloudImgFilesFacade;
@Transactional(rollbackFor = Exception.class)
public void execute(SgCalendarUpdateCmd cmd) {
SgCalendarDO oldCalendar = sgCalendarRepository.getById(cmd.getId());
if (oldCalendar == null) {
throw new BizException("该数据不存在");
}
try {
SgCalendarE sgCalendarE = new SgCalendarE();
BeanUtils.copyProperties(cmd, sgCalendarE);
if ((sgCalendarE.getCalendarId() == null || sgCalendarE.getCalendarId().isEmpty())
&& oldCalendar.getCalendarId() != null && !oldCalendar.getCalendarId().isEmpty()) {
sgCalendarE.setCalendarId(oldCalendar.getCalendarId());
}
boolean res = sgCalendarGateway.update(sgCalendarE);
if (!res) {
throw new BizException("修改失败");
}
replaceCalendarFiles(cmd.getCalendarId(), cmd.getFiles());
SgCalendarDO latestCalendar = sgCalendarRepository.getById(cmd.getId());
if (latestCalendar == null) {
throw new BizException("修改后未查询到安全月历数据");
}
sgCalendarPushSupport.pushCalendar(latestCalendar, PushOperationTypeEnum.UPDATE, cmd.getFiles());
} catch (BizException e) {
log.error("修改安全月历失败,主键:{},原因:{}", cmd.getId(), e.getMessage(), e);
throw e;
} catch (Exception e) {
log.error("修改安全月历失败,主键:{}", cmd.getId(), e);
throw new BizException("修改失败");
}
}
@Transactional(rollbackFor = Exception.class)
public void receiveAudit(SgCalendarAuditDTO auditDTO) {
SgCalendarDO oldCalendar = sgCalendarRepository.getById(auditDTO.getNoticeId());
if (oldCalendar == null) {
throw new BizException("该数据不存在");
}
try {
SgCalendarE sgCalendarE = new SgCalendarE();
sgCalendarE.setId(auditDTO.getNoticeId());
sgCalendarE.setNoticeDate(auditDTO.getNoticeDate());
sgCalendarE.setAuditType(auditDTO.getAuditType());
sgCalendarE.setAuditContent(auditDTO.getAuditContent());
boolean res = sgCalendarGateway.update(sgCalendarE);
if (!res) {
throw new BizException("审核状态更新失败");
}
log.info("接收数港安全月历审核结果完成,本地主键:{},审核状态:{}", auditDTO.getNoticeId(), auditDTO.getAuditType());
} catch (BizException e) {
log.error("接收数港安全月历审核结果失败,主键:{},原因:{}", auditDTO.getNoticeId(), e.getMessage(), e);
throw e;
} catch (Exception e) {
log.error("接收数港安全月历审核结果失败,主键:{}", auditDTO.getNoticeId(), e);
throw new BizException("审核状态更新失败");
}
}
private void replaceCalendarFiles(String calendarId, MultipartFile[] files) throws Exception {
if (files == null || files.length == 0) {
return;
}
imgFilesRepository.deletedImgFilesByForeignId(calendarId);
saveCalendarFiles(calendarId, files);
}
private void saveCalendarFiles(String calendarId, MultipartFile[] files) throws Exception {
List<ImgFilesDO> imgFilesDOList = new ArrayList<>();
for (MultipartFile file : files) {
if (file == null || file.isEmpty()) {
continue;
}
String fileName = Tools.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
String filePath = zcloudImgFilesFacade.saveFileNoCorpinfoId(file.getBytes(), fileName, "calendar");
ImgFilesDO imgFilesDO = new ImgFilesDO();
imgFilesDO.setImgFilesId(Tools.get32UUID());
imgFilesDO.setFilePath(filePath);
imgFilesDO.setForeignKey(calendarId);
imgFilesDO.setFileName(file.getOriginalFilename());
imgFilesDO.setType(CALENDAR_FILE_TYPE);
imgFilesDOList.add(imgFilesDO);
}
if (!imgFilesDOList.isEmpty()) {
imgFilesRepository.saveBatch(imgFilesDOList);
log.info("安全月历附件保存完成,本地主键:{},附件数量:{}", calendarId, imgFilesDOList.size());
}
}
}

View File

@ -1,6 +1,7 @@
package com.zcloud.safety.command;
import com.alibaba.cola.exception.BizException;
import com.zcloud.safety.config.FileUrlConfig;
import com.zcloud.safety.domain.config.SgProperties;
import com.zcloud.safety.domain.enums.PushOperationTypeEnum;
import com.zcloud.safety.domain.enums.PushSourceEnum;
@ -45,6 +46,7 @@ public class SgReferencePushSupport {
private final SgProperties sgProperties;
private final ImgFilesRepository imgFilesRepository;
private final FileUrlConfig fileUrlConfig;
/**
*
@ -72,9 +74,7 @@ public class SgReferencePushSupport {
}
/**
* 使
*
* files
* 使
*/
public void pushReference(SgReferenceDO sgReferenceDO, PushOperationTypeEnum operationType, MultipartFile[] files) {
if (sgReferenceDO == null || sgReferenceDO.getId() == null) {
@ -138,6 +138,9 @@ public class SgReferencePushSupport {
return requestData;
}
/**
* 访使 file.url file_path
*/
private MultipartFile[] buildPushFiles(List<ImgFilesDO> imgFilesDOList) throws IOException {
if (imgFilesDOList == null || imgFilesDOList.isEmpty()) {
return new MultipartFile[0];
@ -148,7 +151,8 @@ public class SgReferencePushSupport {
if (imgFilesDO == null || !StringUtils.hasText(imgFilesDO.getFilePath()) || !StringUtils.hasText(imgFilesDO.getFileName())) {
continue;
}
byte[] fileBytes = readFileBytes(imgFilesDO.getFilePath());
String accessPath = buildAccessPath(imgFilesDO.getFilePath());
byte[] fileBytes = readFileBytes(accessPath);
multipartFileList.add(new StoredMultipartFile(imgFilesDO.getFileName(), fileBytes));
}
return multipartFileList.toArray(new MultipartFile[0]);
@ -167,20 +171,41 @@ public class SgReferencePushSupport {
return result.toArray(new MultipartFile[0]);
}
private byte[] readFileBytes(String filePath) throws IOException {
private String buildAccessPath(String filePath) {
if (!StringUtils.hasText(filePath)) {
return filePath;
}
String trimFilePath = filePath.trim();
if (trimFilePath.startsWith("http://") || trimFilePath.startsWith("https://")) {
return trimFilePath;
}
String prefixUrl = fileUrlConfig.getPrefixUrl();
if (!StringUtils.hasText(prefixUrl)) {
return trimFilePath;
}
if (prefixUrl.endsWith("/") && trimFilePath.startsWith("/")) {
return prefixUrl + trimFilePath.substring(1);
}
if (!prefixUrl.endsWith("/") && !trimFilePath.startsWith("/")) {
return prefixUrl + "/" + trimFilePath;
}
return prefixUrl + trimFilePath;
}
private byte[] readFileBytes(String accessPath) throws IOException {
try {
Path localPath = Paths.get(filePath);
Path localPath = Paths.get(accessPath);
if (Files.exists(localPath)) {
return Files.readAllBytes(localPath);
}
} catch (Exception e) {
log.debug("互学互鉴附件路径不是本地文件,尝试按远程地址读取,路径:{}", filePath);
log.debug("互学互鉴附件路径不是本地文件,尝试按远程地址读取,路径:{}", accessPath);
}
try (InputStream inputStream = new URL(filePath).openStream()) {
try (InputStream inputStream = new URL(accessPath).openStream()) {
return StreamUtils.copyToByteArray(inputStream);
} catch (Exception e) {
throw new BizException("读取互学互鉴附件失败,路径:" + filePath);
throw new BizException("读取互学互鉴附件失败,路径:" + accessPath);
}
}
@ -228,7 +253,7 @@ public class SgReferencePushSupport {
}
/**
* 使
* 使
*/
private static class StoredMultipartFile implements MultipartFile {

View File

@ -13,7 +13,6 @@ import com.zcloud.safety.persistence.repository.ImgFilesRepository;
import com.zcloud.safety.persistence.repository.SgReferenceRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
@ -56,19 +55,16 @@ public class SgReferenceUpdateExe {
throw new BizException("修改失败");
}
replaceReferenceFiles(cmd.getReferenceId(), cmd.getFiles());
// 修改时附件仅做新增补充,不再先删后增;页面删除由图片删除接口单独维护。
saveReferenceFiles(cmd.getReferenceId(), cmd.getFiles());
SgReferenceDO latestReference = sgReferenceRepository.getById(cmd.getId());
if (latestReference == null) {
throw new BizException("修改后未查询到互学互鉴数据");
}
// 修改时如果前端没传新附件,则不改附件,也不给三方传附件;有新附件时直接用本次附件推送。
if (cmd.getFiles() != null && cmd.getFiles().length > 0) {
sgReferencePushSupport.pushReference(latestReference, PushOperationTypeEnum.UPDATE, cmd.getFiles());
} else {
sgReferencePushSupport.pushReference(latestReference, PushOperationTypeEnum.UPDATE, null);
}
log.info("互学互鉴修改完成,本地主键:{},附件数量:{}", cmd.getId(), cmd.getFiles() == null ? 0 : cmd.getFiles().length);
// 推送前统一按业务外键回查当前有效附件,保证页面删图后再次编辑时三方接收到最新附件集合。
sgReferencePushSupport.pushReference(latestReference, PushOperationTypeEnum.UPDATE);
log.info("互学互鉴修改完成,本地主键:{},本次新增附件数量:{}", cmd.getId(), countValidFiles(cmd.getFiles()));
} catch (BizException e) {
log.error("修改互学互鉴失败,主键:{},原因:{}", cmd.getId(), e.getMessage(), e);
throw e;
@ -78,35 +74,50 @@ public class SgReferenceUpdateExe {
}
}
/**
*
*
*/
private void replaceReferenceFiles(String referenceId, MultipartFile[] files) throws Exception {
private void saveReferenceFiles(String referenceId, MultipartFile[] files) throws Exception {
if (files == null || files.length == 0) {
return;
}
imgFilesRepository.deletedImgFilesByForeignId(referenceId);
List<ImgFilesDO> imgFilesDOList = new ArrayList<>();
for (MultipartFile file : files) {
if (file == null || file.isEmpty()) {
continue;
}
String fileName = Tools.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
String originalFilename = file.getOriginalFilename();
if (originalFilename == null || !originalFilename.contains(".")) {
throw new BizException("附件名称不合法");
}
String fileName = Tools.get32UUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
String filePath = zcloudImgFilesFacade.saveFileNoCorpinfoId(file.getBytes(), fileName, "reference");
ImgFilesDO imgFilesDO = new ImgFilesDO();
imgFilesDO.setImgFilesId(Tools.get32UUID());
imgFilesDO.setFilePath(filePath);
imgFilesDO.setForeignKey(referenceId);
imgFilesDO.setFileName(file.getOriginalFilename());
imgFilesDO.setFileName(originalFilename);
imgFilesDO.setType(REFERENCE_FILE_TYPE);
imgFilesDOList.add(imgFilesDO);
}
if (!imgFilesDOList.isEmpty()) {
imgFilesRepository.saveBatch(imgFilesDOList);
log.info("互学互鉴附件保存完成,本地主键:{}附件数量:{}", referenceId, imgFilesDOList.size());
log.info("互学互鉴附件追加保存完成,业务外键:{},新增附件数量:{}", referenceId, imgFilesDOList.size());
}
}
private int countValidFiles(MultipartFile[] files) {
if (files == null || files.length == 0) {
return 0;
}
int count = 0;
for (MultipartFile file : files) {
if (file != null && !file.isEmpty()) {
count++;
}
}
return count;
}
}

View File

@ -2,19 +2,14 @@ package com.zcloud.safety.command.query;
import com.alibaba.cola.dto.PageResponse;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.safety.command.convertor.ImgFilesCoConvertor;
import com.zcloud.safety.command.convertor.SgCalendarCoConvertor;
import com.zcloud.safety.dto.SgCalendarPageQry;
import com.zcloud.safety.dto.clientobject.ImgFilesCO;
import com.zcloud.safety.dto.clientobject.SgCalendarCO;
import com.zcloud.safety.persistence.dataobject.ImgFilesDO;
import com.zcloud.safety.persistence.dataobject.SgCalendarDO;
import com.zcloud.safety.persistence.repository.ImgFilesRepository;
import com.zcloud.safety.persistence.repository.SgCalendarRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -26,9 +21,7 @@ import java.util.Map;
public class SgCalendarQueryExe {
private final SgCalendarRepository sgCalendarRepository;
private final ImgFilesRepository imgFilesRepository;
private final SgCalendarCoConvertor sgCalendarCoConvertor;
private final ImgFilesCoConvertor imgFilesCoConvertor;
/**
*
@ -41,23 +34,13 @@ public class SgCalendarQueryExe {
}
/**
*
*
*/
public SgCalendarCO getInfoById(Long id) {
SgCalendarDO sgCalendarDO = sgCalendarRepository.getInfoById(id);
if (sgCalendarDO == null) {
return null;
}
SgCalendarCO sgCalendarCO = sgCalendarCoConvertor.converDOToCO(sgCalendarDO);
List<ImgFilesDO> imgFilesDOList = imgFilesRepository.listByForeignKey(String.valueOf(sgCalendarDO.getId()));
if (imgFilesDOList == null || imgFilesDOList.isEmpty()) {
sgCalendarCO.setImgFilesList(Collections.emptyList());
return sgCalendarCO;
}
List<ImgFilesCO> imgFilesCOList = imgFilesCoConvertor.converDOsToCOs(imgFilesDOList);
sgCalendarCO.setImgFilesList(imgFilesCOList);
return sgCalendarCO;
return sgCalendarCoConvertor.converDOToCO(sgCalendarDO);
}
}

View File

@ -3,15 +3,11 @@ package com.zcloud.safety.service;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.safety.api.SgCalendarServiceI;
import com.zcloud.safety.command.SgCalendarAddExe;
import com.zcloud.safety.command.SgCalendarRemoveExe;
import com.zcloud.safety.command.SgCalendarUpdateExe;
import com.zcloud.safety.command.SgCalendarReceiveExe;
import com.zcloud.safety.command.query.SgCalendarQueryExe;
import com.zcloud.safety.dto.SgCalendarAddCmd;
import com.zcloud.safety.dto.SgCalendarPageQry;
import com.zcloud.safety.dto.SgCalendarUpdateCmd;
import com.zcloud.safety.dto.clientobject.SgCalendarCO;
import com.zcloud.safety.dto.receive.SgCalendarAuditDTO;
import com.zcloud.safety.dto.receive.SgCalendarReceiveBodyDTO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@ -22,9 +18,7 @@ import org.springframework.stereotype.Service;
@AllArgsConstructor
public class SgCalendarServiceImpl implements SgCalendarServiceI {
private final SgCalendarAddExe sgCalendarAddExe;
private final SgCalendarUpdateExe sgCalendarUpdateExe;
private final SgCalendarRemoveExe sgCalendarRemoveExe;
private final SgCalendarReceiveExe sgCalendarReceiveExe;
private final SgCalendarQueryExe sgCalendarQueryExe;
@Override
@ -38,28 +32,7 @@ public class SgCalendarServiceImpl implements SgCalendarServiceI {
}
@Override
public SingleResponse<SgCalendarCO> add(SgCalendarAddCmd cmd) {
sgCalendarAddExe.execute(cmd);
return SingleResponse.buildSuccess();
}
@Override
public void edit(SgCalendarUpdateCmd cmd) {
sgCalendarUpdateExe.execute(cmd);
}
@Override
public void remove(Long id) {
sgCalendarRemoveExe.execute(id);
}
@Override
public void removeBatch(Long[] ids) {
sgCalendarRemoveExe.execute(ids);
}
@Override
public void receiveAudit(SgCalendarAuditDTO auditDTO) {
sgCalendarUpdateExe.receiveAudit(auditDTO);
public void receiveBatch(SgCalendarReceiveBodyDTO receiveBodyDTO) {
sgCalendarReceiveExe.execute(receiveBodyDTO.getNoticeList(), receiveBodyDTO.getToken());
}
}

View File

@ -2,27 +2,18 @@ package com.zcloud.safety.api;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.safety.dto.SgCalendarAddCmd;
import com.zcloud.safety.dto.SgCalendarPageQry;
import com.zcloud.safety.dto.SgCalendarUpdateCmd;
import com.zcloud.safety.dto.clientobject.SgCalendarCO;
import com.zcloud.safety.dto.receive.SgCalendarAuditDTO;
import com.zcloud.safety.dto.receive.SgCalendarReceiveBodyDTO;
/**
*
*/
public interface SgCalendarServiceI {
PageResponse<SgCalendarCO> listPage(SgCalendarPageQry qry);
SingleResponse<SgCalendarCO> getInfoById(Long id);
SingleResponse<SgCalendarCO> add(SgCalendarAddCmd cmd);
void edit(SgCalendarUpdateCmd cmd);
void remove(Long id);
void removeBatch(Long[] ids);
void receiveAudit(SgCalendarAuditDTO auditDTO);
void receiveBatch(SgCalendarReceiveBodyDTO receiveBodyDTO);
}

View File

@ -0,0 +1,22 @@
package com.zcloud.safety.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* @author zhangyue
* @date 2026/2/11 10:05
*/
@Configuration
public class FileUrlConfig {
private String prefixUrl;
@Value("${file.url}")
public void setPrefixUrl(String prefixUrlProperties) {
prefixUrl = prefixUrlProperties;
}
public String getPrefixUrl() {
// 正式环境
// return "http://192.168.192.201:8991/file/uploadFiles2/";
return prefixUrl;
}
}

View File

@ -1,48 +0,0 @@
package com.zcloud.safety.dto;
import com.alibaba.cola.dto.Command;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotEmpty;
/**
*
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SgCalendarAddCmd extends Command {
@ApiModelProperty(value = "通知标题", name = "noticeTitle", required = true)
@NotEmpty(message = "通知标题不能为空")
private String noticeTitle;
@ApiModelProperty(value = "通知类型1 注意事项2 巡视检查", name = "noticeType", required = true)
@NotEmpty(message = "通知类型不能为空")
private String noticeType;
@ApiModelProperty(value = "通知内容", name = "noticeContent", required = true)
@NotEmpty(message = "通知内容不能为空")
private String noticeContent;
@ApiModelProperty(value = "通知时间,格式 yyyy-MM-dd", name = "noticeDate", required = true)
@NotEmpty(message = "通知时间不能为空")
private String noticeDate;
@ApiModelProperty(value = "公司id", name = "companyId", required = true)
@NotEmpty(message = "公司id不能为空")
private String companyId;
@ApiModelProperty(value = "公司名称", name = "companyName", required = true)
@NotEmpty(message = "公司名称不能为空")
private String companyName;
@ApiModelProperty(value = "附件", name = "files")
private MultipartFile[] files;
}

View File

@ -10,15 +10,15 @@ import lombok.Data;
@Data
public class SgCalendarPageQry extends PageQuery {
@ApiModelProperty(value = "通知标题", name = "noticeTitle")
private String noticeTitle;
@ApiModelProperty(value = "事故发生单位", name = "accidentUnit")
private String accidentUnit;
@ApiModelProperty(value = "通知类型", name = "noticeType")
private String noticeType;
@ApiModelProperty(value = "事故类型", name = "accidentProject")
private String accidentProject;
@ApiModelProperty(value = "开始通知时间", name = "startNoticeDate")
private String startNoticeDate;
@ApiModelProperty(value = "开始事故发生时间", name = "startAccidentTime")
private String startAccidentTime;
@ApiModelProperty(value = "结束通知时间", name = "endNoticeDate")
private String endNoticeDate;
@ApiModelProperty(value = "结束事故发生时间", name = "endAccidentTime")
private String endAccidentTime;
}

View File

@ -1,56 +0,0 @@
package com.zcloud.safety.dto;
import com.alibaba.cola.dto.Command;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
*
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SgCalendarUpdateCmd extends Command {
@ApiModelProperty(value = "主键", name = "id", required = true)
@NotNull(message = "主键不能为空")
private Long id;
@ApiModelProperty(value = "业务主键id", name = "calendarId")
private String calendarId;
@ApiModelProperty(value = "通知标题", name = "noticeTitle", required = true)
@NotEmpty(message = "通知标题不能为空")
private String noticeTitle;
@ApiModelProperty(value = "通知类型1 注意事项2 巡视检查", name = "noticeType", required = true)
@NotEmpty(message = "通知类型不能为空")
private String noticeType;
@ApiModelProperty(value = "通知内容", name = "noticeContent", required = true)
@NotEmpty(message = "通知内容不能为空")
private String noticeContent;
@ApiModelProperty(value = "通知时间,格式 yyyy-MM-dd", name = "noticeDate", required = true)
@NotEmpty(message = "通知时间不能为空")
private String noticeDate;
@ApiModelProperty(value = "公司id", name = "companyId", required = true)
@NotEmpty(message = "公司id不能为空")
private String companyId;
@ApiModelProperty(value = "公司名称", name = "companyName", required = true)
@NotEmpty(message = "公司名称不能为空")
private String companyName;
@ApiModelProperty(value = "附件", name = "files")
private MultipartFile[] files;
}

View File

@ -1,13 +1,9 @@
package com.zcloud.safety.dto.clientobject;
import com.alibaba.cola.dto.ClientObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
*
*/
@ -20,68 +16,21 @@ public class SgCalendarCO extends ClientObject {
@ApiModelProperty(value = "业务主键id")
private String calendarId;
@ApiModelProperty(value = "通知标题")
private String noticeTitle;
@ApiModelProperty(value = "事故发生时间")
private String accidentTime;
@ApiModelProperty(value = "通知类型1 注意事项2 巡视检查")
private String noticeType;
@ApiModelProperty(value = "事故发生单位")
private String accidentUnit;
@ApiModelProperty(value = "通知内容")
private String noticeContent;
@ApiModelProperty(value = "事故类型")
private String accidentProject;
@ApiModelProperty(value = "通知时间")
private String noticeDate;
@ApiModelProperty(value = "事故经过简要描述")
private String accidentDescription;
@ApiModelProperty(value = "公司id")
private String companyId;
@ApiModelProperty(value = "死亡人数(事故直接经济损失)")
private String accidentLost;
@ApiModelProperty(value = "公司名称")
private String companyName;
@ApiModelProperty(value = "审核状态")
private String auditType;
@ApiModelProperty(value = "审核意见")
private String auditContent;
@ApiModelProperty(value = "乐观锁")
private Integer version;
@ApiModelProperty(value = "创建人")
private Long createId;
@ApiModelProperty(value = "创建人姓名")
private String createName;
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新人")
private Long updateId;
@ApiModelProperty(value = "修改人名称")
private String updateName;
@ApiModelProperty(value = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
@ApiModelProperty(value = "描述")
private String remarks;
@ApiModelProperty(value = "是否删除")
private String deleteEnum;
@ApiModelProperty(value = "租户ID")
private Long tenantId;
@ApiModelProperty(value = "机构ID")
private Long orgId;
@ApiModelProperty(value = "环境")
private String env;
@ApiModelProperty(value = "附件列表")
private List<ImgFilesCO> imgFilesList;
@ApiModelProperty(value = "事故等级")
private String accidentLevel;
}

View File

@ -1,23 +0,0 @@
package com.zcloud.safety.dto.receive;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*/
@Data
public class SgCalendarAuditDTO {
@ApiModelProperty(value = "通知id", name = "noticeId")
private Long noticeId;
@ApiModelProperty(value = "通知时间", name = "noticeDate")
private String noticeDate;
@ApiModelProperty(value = "审核状态1 同意2 不同意", name = "auditType")
private String auditType;
@ApiModelProperty(value = "审核意见", name = "auditContent")
private String auditContent;
}

View File

@ -0,0 +1,20 @@
package com.zcloud.safety.dto.receive;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
*
*/
@Data
public class SgCalendarReceiveBodyDTO implements Serializable {
@ApiModelProperty(value = "下发的安全月历数据", name = "noticeList")
private List<SgCalendarReceiveNoticeDTO> noticeList;
@ApiModelProperty(value = "各港区 token", name = "token")
private String token;
}

View File

@ -0,0 +1,34 @@
package com.zcloud.safety.dto.receive;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
*
*/
@Data
public class SgCalendarReceiveNoticeDTO implements Serializable {
@ApiModelProperty(value = "安全月历id", name = "id")
private Long id;
@ApiModelProperty(value = "事故发生时间格式yyyy-MM-dd", name = "accidentTime")
private String accidentTime;
@ApiModelProperty(value = "事故发生单位", name = "accidentUnit")
private String accidentUnit;
@ApiModelProperty(value = "事故类型", name = "accidentProject")
private String accidentProject;
@ApiModelProperty(value = "事故经过简要描述", name = "accidentDescription")
private String accidentDescription;
@ApiModelProperty(value = "死亡人数(事故直接经济损失)", name = "accidentLost")
private String accidentLost;
@ApiModelProperty(value = "事故等级", name = "accidentLevel")
private String accidentLevel;
}

View File

@ -1,30 +0,0 @@
package com.zcloud.safety.domain.gateway;
import com.zcloud.safety.domain.model.SgCalendarE;
/**
* web-domain
*
* @Author zhaokai
* @Date 2026-06-02 08:43:20
*/
public interface SgCalendarGateway {
/**
*
*/
Boolean add(SgCalendarE sgCalendarE);
/**
*
*/
Boolean update(SgCalendarE sgCalendarE);
/**
*
*/
Boolean deletedSgCalendarById(Long id);
Boolean deletedSgCalendarByIds(Long[] id);
}

View File

@ -6,56 +6,29 @@ import lombok.Data;
import java.time.LocalDateTime;
/**
* web-domain
*
* @Author zhaokai
* @Date 2026-06-02 08:43:20
*
*/
@Data
public class SgCalendarE extends BaseE {
//主键
private Long id;
//业务主键id
private String calendarId;
//通知标题
private String noticeTitle;
//通知类型| 1 注意事项, 2 巡视检查
private String noticeType;
//通知内容
private String noticeContent;
//通知时间
private String noticeDate;
//公司id
private String companyId;
//公司名称
private String companyName;
//审核状态 | 1 同意 2 不同意
private String auditType;
//审核意见
private String auditContent;
//乐观锁
private String accidentTime;
private String accidentUnit;
private String accidentProject;
private String accidentDescription;
private String accidentLost;
private String accidentLevel;
private Integer version;
//创建人
private Long createId;
//创建人姓名
private String createName;
//创建时间
private LocalDateTime createTime;
//更新人
private Long updateId;
//修改人名称
private String updateName;
//更新时间
private LocalDateTime updateTime;
//描述
private String remarks;
//是否删除
private String deleteEnum;
//租户ID
private Long tenantId;
//机构ID
private Long orgId;
//环境
private String env;
}

View File

@ -21,17 +21,17 @@ public class EncryptTestUtil {
private static final String PRIVATE_KEY = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgHnH3HOprVgU8ipdM6Mxp5Oyx87BlHva96f2CVCkVOBygCgYIKoEcz1UBgi2hRANCAASbjGgPBnqF4zSPMcY0esBBcJo6zRvDHk383M4D+gbKu+ZM+GQFyb50gCEIPEQgYRGNEwp8pH8jKCSBbwrhINGs";
public static void main(String[] args) {
// 测试数据(对应 SgCalendarAuditDTO 的 JSON 格式)
// 测试数据
//公告
// String jsonData = "{\"noticeTitle\":\"测试标题\",\"noticeContent\":\"测试后没人内容\",\"createBy\":\"张三\",\"createTime\":\"2026-06-03 15:00:00\"}";
String jsonData = "{\"noticeTitle\":\"测试标题\",\"noticeContent\":\"测试后没人内容\",\"createBy\":\"张三\",\"createTime\":\"2026-06-03 15:00:00\"}";
//通知
// String jsonData = "{\"informTitle\":\"测试通知标题\",\"informContent\":\"测试通知内容\",\"createBy\":\"张三1\",\"createTime\":\"2026-06-05 10:00:00\"}";
//督办
// String jsonData = "{\"superviseId\":123,\"superviseTitle\":\"测试督办标题\",\"superviseContent\":\"测试督办内容\",\"superviseStartTime\":\"2026-06-05 10:00:00\",\"superviseFinishTime\":\"2026-06-10 10:00:00\",\"createBy\":\"张三1\",\"createTime\":\"2026-06-05 10:00:00\"}";
//安全月历
// String jsonData = "{\"noticeId\":2062779670919237633,\"auditType\":\"1\",\"auditContent\":\"同意了吧\",\"noticeDate\":\"2026-06-05 10:00:00\"}";
// String jsonData = "{\"token\":\"tokenAAAA\",\"noticeList\":[{\"id\":2062779670919237633,\"accidentTime\":\"2026-06-05\",\"accidentUnit\":\"测试单位\",\"accidentProject\":\"火灾\",\"accidentDescription\":\"测试描述\",\"accidentLost\":\"1人\",\"accidentLevel\":\"一级\"}]}";
//互学互鉴
String jsonData = "{\"accidentId\":1122,\"title\":\"标题虎穴\",\"fileName\":\"同意了吧\",\"createBy\":\"张三1\",\"createTime\":\"2026-06-05 15:00:00\"}";
// String jsonData = "{\"accidentId\":1122,\"title\":\"标题虎穴\",\"fileName\":\"同意了吧\",\"createBy\":\"张三1\",\"createTime\":\"2026-06-05 15:00:00\"}";
// 1. 生成随机 SM4 密钥16字节
byte[] sm4Key = generateRandomSM4Key();
System.out.println("SM4密钥(十六进制): " + bytesToHex(sm4Key));

View File

@ -1,53 +0,0 @@
package com.zcloud.safety.gatewayimpl;
import com.zcloud.safety.domain.gateway.SgCalendarGateway;
import com.zcloud.safety.domain.model.SgCalendarE;
import com.zcloud.safety.persistence.dataobject.SgCalendarDO;
import com.zcloud.safety.persistence.repository.SgCalendarRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.Arrays;
/**
*
*/
@Service
@AllArgsConstructor
public class SgCalendarGatewayImpl implements SgCalendarGateway {
private final SgCalendarRepository sgCalendarRepository;
@Override
public Boolean add(SgCalendarE sgCalendarE) {
SgCalendarDO d = new SgCalendarDO();
BeanUtils.copyProperties(sgCalendarE, d);
sgCalendarRepository.save(d);
sgCalendarE.setId(d.getId());
if (d.getId() != null && (d.getCalendarId() == null || d.getCalendarId().isEmpty())) {
d.setCalendarId(String.valueOf(d.getId()));
sgCalendarRepository.updateById(d);
sgCalendarE.setCalendarId(d.getCalendarId());
}
return true;
}
@Override
public Boolean update(SgCalendarE sgCalendarE) {
SgCalendarDO d = new SgCalendarDO();
BeanUtils.copyProperties(sgCalendarE, d);
sgCalendarRepository.updateById(d);
return true;
}
@Override
public Boolean deletedSgCalendarById(Long id) {
return sgCalendarRepository.removeById(id);
}
@Override
public Boolean deletedSgCalendarByIds(Long[] ids) {
return sgCalendarRepository.removeByIds(Arrays.asList(ids));
}
}

View File

@ -8,47 +8,36 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* web-infrastructure
*
* @Author zhaokai
* @Date 2026-06-02 08:43:20
*
*/
@Data
@TableName("sg_calendar")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class SgCalendarDO extends BaseDO {
//业务主键id
@ApiModelProperty(value = "业务主键id")
private String calendarId;
//通知标题
@ApiModelProperty(value = "通知标题")
private String noticeTitle;
//通知类型| 1 注意事项, 2 巡视检查
@ApiModelProperty(value = "通知类型| 1 注意事项, 2 巡视检查")
private String noticeType;
//通知内容
@ApiModelProperty(value = "通知内容")
private String noticeContent;
//通知时间
@ApiModelProperty(value = "通知时间")
private String noticeDate;
//公司id
@ApiModelProperty(value = "公司id")
private String companyId;
//公司名称
@ApiModelProperty(value = "公司名称")
private String companyName;
//审核状态 | 1 同意 2 不同意
@ApiModelProperty(value = "审核状态 | 1 同意 2 不同意")
private String auditType;
//审核意见
@ApiModelProperty(value = "审核意见")
private String auditContent;
@ApiModelProperty(value = "事故发生时间")
private String accidentTime;
@ApiModelProperty(value = "事故发生单位")
private String accidentUnit;
@ApiModelProperty(value = "事故类型")
private String accidentProject;
@ApiModelProperty(value = "事故经过简要描述")
private String accidentDescription;
@ApiModelProperty(value = "死亡人数(事故直接经济损失)")
private String accidentLost;
@ApiModelProperty(value = "事故等级")
private String accidentLevel;
public SgCalendarDO(String calendarId) {
this.calendarId = calendarId;
}
}

View File

@ -7,14 +7,12 @@
<sql id="BaseColumnList">
id,
calendar_id AS calendarId,
notice_title AS noticeTitle,
notice_type AS noticeType,
notice_content AS noticeContent,
notice_date AS noticeDate,
company_id AS companyId,
company_name AS companyName,
audit_type AS auditType,
audit_content AS auditContent,
accident_time AS accidentTime,
accident_unit AS accidentUnit,
accident_project AS accidentProject,
accident_description AS accidentDescription,
accident_lost AS accidentLost,
accident_level AS accidentLevel,
version,
create_id AS createId,
create_name AS createName,
@ -35,20 +33,20 @@
FROM sg_calendar
<where>
delete_enum = 'FALSE'
<if test="params.noticeTitle != null and params.noticeTitle != ''">
AND notice_title LIKE CONCAT('%', #{params.noticeTitle}, '%')
<if test="params.accidentUnit != null and params.accidentUnit != ''">
AND accident_unit LIKE CONCAT('%', #{params.accidentUnit}, '%')
</if>
<if test="params.noticeType != null and params.noticeType != ''">
AND notice_type = #{params.noticeType}
<if test="params.accidentProject != null and params.accidentProject != ''">
AND accident_project = #{params.accidentProject}
</if>
<if test="params.startNoticeDate != null and params.startNoticeDate != ''">
AND notice_date &gt;= #{params.startNoticeDate}
<if test="params.startAccidentTime != null and params.startAccidentTime != ''">
AND accident_time &gt;= #{params.startAccidentTime}
</if>
<if test="params.endNoticeDate != null and params.endNoticeDate != ''">
AND notice_date &lt;= #{params.endNoticeDate}
<if test="params.endAccidentTime != null and params.endAccidentTime != ''">
AND accident_time &lt;= #{params.endAccidentTime}
</if>
</where>
ORDER BY create_time DESC
ORDER BY accident_time DESC, id DESC
</select>
<select id="getInfoById" resultType="com.zcloud.safety.persistence.dataobject.SgCalendarDO">