From 761bdc5b3f17df62aae1b424f2d2dabc11e844bc Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: Fri, 23 May 2025 09:33:44 +0800
Subject: [PATCH] 变动大幅度版本
---
src/main/java/com/gkhy/labRiskManage/application/experiment/service/impl/ExperimentAppServiceImpl.java | 202 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 184 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/gkhy/labRiskManage/application/experiment/service/impl/ExperimentAppServiceImpl.java b/src/main/java/com/gkhy/labRiskManage/application/experiment/service/impl/ExperimentAppServiceImpl.java
index df6ab53..3ac3d79 100644
--- a/src/main/java/com/gkhy/labRiskManage/application/experiment/service/impl/ExperimentAppServiceImpl.java
+++ b/src/main/java/com/gkhy/labRiskManage/application/experiment/service/impl/ExperimentAppServiceImpl.java
@@ -13,15 +13,15 @@
import com.gkhy.labRiskManage.commons.exception.BusinessException;
import com.gkhy.labRiskManage.commons.model.PageQuery;
import com.gkhy.labRiskManage.commons.utils.BeanCopyUtils;
+import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentAndType;
import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentAssessLog;
import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentInfo;
-import com.gkhy.labRiskManage.domain.experiment.enums.ExperimentStatusEnum;
-import com.gkhy.labRiskManage.domain.experiment.enums.ExperimentTagEnum;
+import com.gkhy.labRiskManage.domain.experiment.enums.*;
import com.gkhy.labRiskManage.domain.experiment.model.bo.*;
-import com.gkhy.labRiskManage.domain.experiment.enums.HazardousWasteEnum;
-import com.gkhy.labRiskManage.domain.experiment.enums.TimeoutEnum;
+import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentAndTypeDTO;
import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentInfoDTO;
import com.gkhy.labRiskManage.domain.experiment.service.*;
+import com.gkhy.labRiskManage.domain.riskReport.entity.ReportRiskAssessInfo;
import com.gkhy.labRiskManage.domain.riskReport.service.ReportRiskAssessInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -56,6 +56,8 @@
private ExperimentAppConverter experimentAppConverter;
@Autowired
private ExperimentAssessLogService experimentAssessLogService;
+ @Autowired
+ private ExperimentAndTypeService experimentAndTypeService;
@Transactional
@Override
public int save(Long currentUserId, ExperimentInsertReqBO experimentInsertReqBO) {
@@ -79,9 +81,14 @@
if(!CollectionUtils.isEmpty(experimentInsertReqBO.getSiteList())){
siteIds = experimentInsertReqBO.getSiteList().stream().map(ExperimentAndSiteInsertReqBO::getSiteId).collect(Collectors.toList());
}
+ //实验类型中间表
+ List<Long> typeIds = new ArrayList<>();
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getTypeList())){
+ typeIds = experimentInsertReqBO.getTypeList().stream().map(ExperimentAndTypeInsertReqBO::getTypeId).collect(Collectors.toList());
+ }
//危废中间表
List<ExperimentHazardousWasteAppInsertBO> hazardousWasteInsertBOList = new ArrayList<>();
- if(!CollectionUtils.isEmpty(experimentAppInsertBO.getHazardousWasteList())){
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getHazardousWasteList())){
hazardousWasteInsertBOList = experimentAppConverter.getHazardousWasteInsertBOList(experimentInsertReqBO.getHazardousWasteList(),experimentInfoDTO.getId());
}
//应急演练
@@ -89,10 +96,14 @@
if(!CollectionUtils.isEmpty(experimentInsertReqBO.getEmergencyList())){
experimentAndEmergencyAppInsertBOList = experimentAppConverter.getExperimentAndEmergencyAppInsertBOList(experimentInsertReqBO.getEmergencyList(), experimentInfoDTO.getId());
}
+ // 暂存清空了之前绑定数据
+ dealDelete(experimentInfoDTO.getId(),currentUserId);
+
experimentAndDeviceService.saveBatch(currentUserId,deviceAppInsertBOList);
experimentAndStuffService.saveBatch(currentUserId,stuffInsertBOList);
experimentAndPersonService.saveBatch(currentUserId,personIds,experimentInfoDTO.getId());
experimentAndSiteService.saveBatch(currentUserId, siteIds, experimentInfoDTO.getId());
+ experimentAndTypeService.saveBatch(currentUserId, typeIds, experimentInfoDTO.getId());
experimentHazardousWasteService.saveBatch(currentUserId,hazardousWasteInsertBOList);
experimentAndEmergencyService.saveBatch(currentUserId,experimentAndEmergencyAppInsertBOList);
Integer code = StatusEnum.SUCCESS.getCode();
@@ -101,6 +112,31 @@
}
return code;
}
+
+ @Override
+ @Transactional
+ public int temporary(Long currentUserId, ExperimentInsertReqBO experimentInsertReqBO) {
+
+// if(ExperimentStagingEnum.SAVE.getValue().equals(experimentInsertReqBO.getStagingTag())){
+// throw new BusinessException(this.getClass(),ResultCode.PARAM_ERROR_NULL.getCode(),"已保存数据不可操作暂存!");
+// }
+
+ //实验基础信息
+ ExperimentAppInsertBO experimentAppInsertBO = new ExperimentAppInsertBO();
+ BeanUtils.copyProperties(experimentInsertReqBO,experimentAppInsertBO);
+ ExperimentInfoDTO experimentInfoDTO = experimentInfoService.temporary(currentUserId,experimentAppInsertBO);
+
+ //删除业务数据
+ dealDelete(experimentInfoDTO.getId(),currentUserId);
+ temporary(currentUserId,experimentInsertReqBO,experimentInfoDTO.getId(),experimentAppInsertBO);
+
+ Integer code = StatusEnum.SUCCESS.getCode();
+ if(ObjectUtils.isEmpty(experimentInfoDTO)){
+ code = StatusEnum.FAIL.getCode();
+ }
+ return code;
+ }
+
@Transactional
@Override
public int developSave(Long currentUserId, ExperimentInsertReqBO experimentInsertReqBO) {
@@ -125,7 +161,7 @@
}
//危废中间表
List<ExperimentHazardousWasteAppInsertBO> hazardousWasteInsertBOList = new ArrayList<>();
- if(!CollectionUtils.isEmpty(experimentAppInsertBO.getHazardousWasteList())){
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getHazardousWasteList())){
hazardousWasteInsertBOList = experimentAppConverter.getHazardousWasteInsertBOList(experimentInsertReqBO.getHazardousWasteList(),experimentInfoDTO.getId());
}
//应急演练
@@ -133,11 +169,20 @@
if(!CollectionUtils.isEmpty(experimentInsertReqBO.getEmergencyList())){
experimentAndEmergencyAppInsertBOList = experimentAppConverter.getExperimentAndEmergencyAppInsertBOList(experimentInsertReqBO.getEmergencyList(), experimentInfoDTO.getId());
}
+ //实验类型中间表
+ List<Long> typeIds = new ArrayList<>();
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getTypeList())){
+ typeIds = experimentInsertReqBO.getTypeList().stream().map(ExperimentAndTypeInsertReqBO::getTypeId).collect(Collectors.toList());
+ }
+
+ // 暂存清空了之前绑定数据
+ dealDelete(experimentInfoDTO.getId(),currentUserId);
experimentAndDeviceService.saveBatch(currentUserId,deviceAppInsertBOList);
experimentAndStuffService.saveBatch(currentUserId,stuffInsertBOList);
experimentAndPersonService.saveBatch(currentUserId,personIds,experimentInfoDTO.getId());
experimentAndSiteService.saveBatch(currentUserId, siteIds, experimentInfoDTO.getId());
+ experimentAndTypeService.saveBatch(currentUserId, typeIds, experimentInfoDTO.getId());
experimentHazardousWasteService.saveBatch(currentUserId,hazardousWasteInsertBOList);
experimentAndEmergencyService.saveBatch(currentUserId,experimentAndEmergencyAppInsertBOList);
Integer code = StatusEnum.SUCCESS.getCode();
@@ -145,6 +190,88 @@
code = StatusEnum.FAIL.getCode();
}
return code;
+ }
+
+ @Override
+ @Transactional
+ public int developTemporary(Long currentUserId, ExperimentInsertReqBO experimentInsertReqBO) {
+ //实验基础信息
+ ExperimentAppInsertBO experimentAppInsertBO = new ExperimentAppInsertBO();
+ BeanUtils.copyProperties(experimentInsertReqBO,experimentAppInsertBO);
+ ExperimentInfoDTO experimentInfoDTO = experimentInfoService.developTemporary(currentUserId,experimentAppInsertBO);
+ //处理中间表数据
+ dealDelete(experimentInfoDTO.getId(),currentUserId);
+
+ temporary(currentUserId,experimentInsertReqBO,experimentInfoDTO.getId(),experimentAppInsertBO);
+
+
+ Integer code = StatusEnum.SUCCESS.getCode();
+ if(ObjectUtils.isEmpty(experimentInfoDTO)){
+ code = StatusEnum.FAIL.getCode();
+ }
+ return code;
+ }
+
+
+ /**
+ * 处理删除
+ * @param id
+ * @param currentUserId
+ */
+ private void dealDelete(Long id ,Long currentUserId){
+ experimentAndTypeService.deleteByExperimentId(id);
+ experimentAndDeviceService.deleteByExperimentId(id,currentUserId);
+ experimentHazardousWasteService.deleteByExperimentId(id,currentUserId);
+ experimentAndPersonService.deleteByExperimentId(id,currentUserId);
+ experimentAndStuffService.deleteByExperimentId(id,currentUserId);
+ experimentAndSiteService.deleteByExperimentId(id);
+ experimentAndEmergencyService.deleteByExperimentId(id);
+ }
+
+ /**
+ * 处理中间表数据
+ * @param currentUserId
+ * @param experimentInsertReqBO
+ * @param experimentAppInsertBO
+ */
+ private void temporary(Long currentUserId, ExperimentInsertReqBO experimentInsertReqBO,Long id ,ExperimentAppInsertBO experimentAppInsertBO) {
+ if (!CollectionUtils.isEmpty(experimentInsertReqBO.getDeviceList())){
+ //设备中间表
+ List<ExperimentAndDeviceAppInsertBO> deviceAppInsertBOList = experimentAppConverter.getDeviceInsertBOList(experimentInsertReqBO.getDeviceList(),id);
+ experimentAndDeviceService.saveBatch(currentUserId,deviceAppInsertBOList);
+ }
+
+ if (!CollectionUtils.isEmpty(experimentInsertReqBO.getStuffList())) {
+ //材料中间表
+ List<ExperimentAndStuffAppInsertBO> stuffInsertBOList = experimentAppConverter.getStuffInsertBOList(experimentInsertReqBO.getStuffList(), id);
+ experimentAndStuffService.saveBatch(currentUserId,stuffInsertBOList);
+ }
+ //实验人员
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getPersons())){
+ List<Long> personIds = experimentInsertReqBO.getPersons().stream().map(ExperimentAndPersonInsertReqBO::getPersonId).collect(Collectors.toList());
+ experimentAndPersonService.saveBatch(currentUserId,personIds,id);
+ }
+ //实验地点中间表
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getSiteList())){
+ List<Long> siteIds = experimentInsertReqBO.getSiteList().stream().map(ExperimentAndSiteInsertReqBO::getSiteId).collect(Collectors.toList());
+ experimentAndSiteService.saveBatch(currentUserId, siteIds, id);
+ }
+ //实验类型中间表
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getTypeList())){
+ List<Long> typeIds = experimentInsertReqBO.getTypeList().stream().map(ExperimentAndTypeInsertReqBO::getTypeId).collect(Collectors.toList());
+ experimentAndTypeService.saveBatch(currentUserId, typeIds, id);
+ }
+ //危废中间表
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getHazardousWasteList())){
+ List<ExperimentHazardousWasteAppInsertBO> hazardousWasteInsertBOList = experimentAppConverter.getHazardousWasteInsertBOList(experimentInsertReqBO.getHazardousWasteList(),id);
+ experimentHazardousWasteService.saveBatch(currentUserId,hazardousWasteInsertBOList);
+ }
+ //应急演练
+ if(!CollectionUtils.isEmpty(experimentInsertReqBO.getEmergencyList())){
+ List<ExperimentAndEmergencyAppInsertBO> experimentAndEmergencyAppInsertBOList = experimentAppConverter.getExperimentAndEmergencyAppInsertBOList(experimentInsertReqBO.getEmergencyList(), id);
+ experimentAndEmergencyService.saveBatch(currentUserId,experimentAndEmergencyAppInsertBOList);
+ }
+
}
@Transactional
@Override
@@ -176,14 +303,27 @@
BeanUtils.copyProperties(searchResult,result);
}
List<ExperimentInfoDTO> experimentInfoDTOS = (List<ExperimentInfoDTO>)searchResult.getData();
- for (ExperimentInfoDTO experimentInfo : experimentInfoDTOS) {
+ List<ExperimentInfoAppQueryDTO> experimentInfoAppQueryDTOS = BeanCopyUtils.copyBeanList(experimentInfoDTOS, ExperimentInfoAppQueryDTO.class);
+
+ for (ExperimentInfoAppQueryDTO experimentInfo : experimentInfoAppQueryDTOS) {
List<ExperimentAssessLog> assessLogs = experimentAssessLogService.getAssessLogs(experimentInfo.getExperimentCode());
if (assessLogs.size() > 0){
experimentInfo.setExperimentAssessLogs(assessLogs);
}
+ ReportRiskAssessInfo byExperimentId = reportRiskAssessInfoService.getByExperimentId(experimentInfo.getId());
+ if (!ObjectUtils.isEmpty(byExperimentId)){
+ experimentInfo.setAssessLevel(byExperimentId.getAssessLevel());
+ experimentInfo.setAssessTime(byExperimentId.getAssessTime());
+ experimentInfo.setReportId(byExperimentId.getId());
+ }
+ List<ExperimentAndTypeDTO> types = experimentInfo.getTypes();
+ if (!CollectionUtils.isEmpty(types)){
+ String collect = types.stream().map(type -> type.getTypeName()).collect(Collectors.joining(","));
+ experimentInfo.setExperimentTypeName(collect);
+ }
}
- result.setData(getExperimentInfoAppQueryDTO(experimentInfoDTOS));
+ result.setData(experimentInfoAppQueryDTOS);
//获取分页数据
return result;
}
@@ -198,6 +338,7 @@
@Transactional(rollbackFor = Exception.class)
@Override
public int deleteById(Long id, Long currentUserId) {
+
experimentInfoService.deleteById(id,currentUserId);
experimentAndDeviceService.deleteByExperimentId(id,currentUserId);
experimentHazardousWasteService.deleteByExperimentId(id,currentUserId);
@@ -205,6 +346,7 @@
experimentAndStuffService.deleteByExperimentId(id,currentUserId);
experimentAndSiteService.deleteByExperimentId(id);
experimentAndEmergencyService.deleteByExperimentId(id);
+ experimentAndTypeService.deleteByExperimentId(id);
return StatusEnum.SUCCESS.getCode();
}
@@ -268,14 +410,27 @@
}
List<ExperimentInfoDTO> experimentInfoDTOS = (List<ExperimentInfoDTO>)searchResult.getData();
- for (ExperimentInfoDTO experimentInfo : experimentInfoDTOS) {
+ List<ExperimentInfoAppQueryDTO> experimentInfoAppQueryDTOS = BeanCopyUtils.list2OtherList(experimentInfoDTOS, ExperimentInfoAppQueryDTO.class);
+
+ for (ExperimentInfoAppQueryDTO experimentInfo : experimentInfoAppQueryDTOS) {
List<ExperimentAssessLog> assessLogs = experimentAssessLogService.getAssessLogs(experimentInfo.getExperimentCode());
if (assessLogs.size() > 0){
experimentInfo.setExperimentAssessLogs(assessLogs);
}
+ ReportRiskAssessInfo byExperimentId = reportRiskAssessInfoService.getByExperimentId(experimentInfo.getId());
+ if (!ObjectUtils.isEmpty(byExperimentId)){
+ experimentInfo.setAssessLevel(byExperimentId.getAssessLevel());
+ experimentInfo.setAssessTime(byExperimentId.getAssessTime());
+ }
+ List<ExperimentAndTypeDTO> types = experimentInfo.getTypes();
+ if (!CollectionUtils.isEmpty(types)){
+ String collect = types.stream().map(type -> type.getTypeName()).collect(Collectors.joining(","));
+ experimentInfo.setExperimentTypeName(collect);
+ }
+
}
- result.setData(getExperimentInfoAppQueryDTO(experimentInfoDTOS));
+ result.setData(experimentInfoAppQueryDTOS);
//获取分页数据
return result;
}
@@ -297,15 +452,26 @@
BeanUtils.copyProperties(searchResult,result);
}
List<ExperimentInfoDTO> experimentInfoDTOS = (List<ExperimentInfoDTO>)searchResult.getData();
+ List<ExperimentInfoAppQueryDTO> experimentInfoAppQueryDTOS = BeanCopyUtils.list2OtherList(experimentInfoDTOS, ExperimentInfoAppQueryDTO.class);
- for (ExperimentInfoDTO experimentInfo : experimentInfoDTOS) {
+ for (ExperimentInfoAppQueryDTO experimentInfo : experimentInfoAppQueryDTOS) {
List<ExperimentAssessLog> assessLogs = experimentAssessLogService.getAssessLogs(experimentInfo.getExperimentCode());
if (assessLogs.size() > 0){
experimentInfo.setExperimentAssessLogs(assessLogs);
}
+ ReportRiskAssessInfo byExperimentId = reportRiskAssessInfoService.getByExperimentId(experimentInfo.getId());
+ if (!ObjectUtils.isEmpty(byExperimentId)){
+ experimentInfo.setAssessLevel(byExperimentId.getAssessLevel());
+ experimentInfo.setAssessTime(byExperimentId.getAssessTime());
+ }
+ List<ExperimentAndTypeDTO> types = experimentInfo.getTypes();
+ if (!CollectionUtils.isEmpty(types)){
+ String collect = types.stream().map(type -> type.getTypeName()).collect(Collectors.joining(","));
+ experimentInfo.setExperimentTypeName(collect);
+ }
}
- result.setData(getExperimentInfoAppQueryDTO(experimentInfoDTOS));
+ result.setData(experimentInfoAppQueryDTOS);
//获取分页数据
return result;
}
@@ -322,12 +488,12 @@
for (ExperimentInfoDTO experimentInfoDTO:experimentInfoDTOS){
ExperimentInfoAppQueryDTO experimentInfoAppQueryDTO = new ExperimentInfoAppQueryDTO();
BeanUtils.copyProperties(experimentInfoDTO,experimentInfoAppQueryDTO);
- //实验场所
- List<ExperimentAndSiteAppQueryDTO> siteAppQueryDTOs = new ArrayList<>();
- if(!ObjectUtils.isEmpty(experimentInfoDTO.getSites())){
- siteAppQueryDTOs = BeanCopyUtils.copyBeanList(experimentInfoDTO.getSites(),ExperimentAndSiteAppQueryDTO.class);
- }
- experimentInfoAppQueryDTO.setSites(siteAppQueryDTOs);
+// //实验场所
+// List<ExperimentAndSiteAppQueryDTO> siteAppQueryDTOs = new ArrayList<>();
+// if(!ObjectUtils.isEmpty(experimentInfoDTO.getSites())){
+// siteAppQueryDTOs = BeanCopyUtils.copyBeanList(experimentInfoDTO.getSites(),ExperimentAndSiteAppQueryDTO.class);
+// }
+// experimentInfoAppQueryDTO.setSites(siteAppQueryDTOs);
//人员
List<ExperimentAndPersonAppQueryDTO> personAppQueryDTOList = new ArrayList<>();
if(!ObjectUtils.isEmpty(experimentInfoDTO.getPersons())){
--
Gitblit v1.9.2