From cd02923a7ce1ffa004b3abbb7af67ab6173dd99d Mon Sep 17 00:00:00 2001
From: zf <1603559716@qq.com>
Date: 星期一, 25 三月 2024 10:59:40 +0800
Subject: [PATCH] Merge branch 'master' of https://sinanoaq.cn:8888/r/safePlatform-out into zf
---
emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java | 144 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 139 insertions(+), 5 deletions(-)
diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java
index b95c086..c7ac66d 100644
--- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java
+++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java
@@ -1,38 +1,56 @@
package com.gkhy.safePlatform.emergency.service.impl;
+import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO;
+import com.gkhy.safePlatform.commons.co.ContextCacheUser;
+import com.gkhy.safePlatform.commons.enums.E;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
-import com.gkhy.safePlatform.commons.utils.StringUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.emergency.entity.*;
import com.gkhy.safePlatform.emergency.enums.EmergencyResultCodes;
+import com.gkhy.safePlatform.emergency.enums.EmergencySuppliesClassificationEnum;
+import com.gkhy.safePlatform.emergency.enums.EmergencySuppliesStatusEnum;
import com.gkhy.safePlatform.emergency.excepiton.EmergencyException;
import com.gkhy.safePlatform.emergency.model.dto.req.*;
import com.gkhy.safePlatform.emergency.model.dto.resp.*;
+import com.gkhy.safePlatform.emergency.query.EmergencySuppliesCountQuery;
import com.gkhy.safePlatform.emergency.query.EmergencySuppliesQuery;
import com.gkhy.safePlatform.emergency.query.db.EmergencySuppliesDBQuery;
+import com.gkhy.safePlatform.emergency.service.EmergencySuppliesMaintainService;
import com.gkhy.safePlatform.emergency.service.EmergencySuppliesService;
import com.gkhy.safePlatform.emergency.service.baseService.*;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
@Service("emergencySuppliesService")
public class EmergencySuppliesServiceImpl implements EmergencySuppliesService {
@Autowired
private EmergencySuppliesInfoService emergencySuppliesInfoService;
+
+ @Autowired
+ private EmergencySuppliesInspectInfoService emergencySuppliesInspectInfoService;
+
+ @Autowired
+ private EmergencySuppliesInspectUserInfoService emergencySuppliesInspectUserInfoService;
+
+ @Autowired
+ private EmergencySuppliesMaintainInfoService emergencySuppliesMaintainInfoService;
+
+ @Autowired
+ private EmergencySuppliesMaintainUserInfoService emergencySuppliesMaintainUserInfoService;
+
@DubboReference(check = false)
private AccountDepartmentService accountDepartmentService;
@@ -81,6 +99,12 @@
@Override
public ResultVO addEmergencySupplies(Long uid, EmergencySuppliesReqDTO emergencySuppliesReqDTO) {
+
+ // 验证必填
+ checkRequired(emergencySuppliesReqDTO);
+ //验证枚举
+ checkEnum(emergencySuppliesReqDTO);
+
Date nowDate = new Date();
// 新增应急物资
EmergencySuppliesInfo emergencySuppliesInfo = new EmergencySuppliesInfo();
@@ -102,12 +126,47 @@
throw new EmergencyException(EmergencyResultCodes.SUPPLIES_NOT_EXIST);
}else{
BeanUtils.copyProperties(emergencySuppliesInfoDetailDO,emergencySuppliesDetailRespDTO);
+
+ // 查找检查记录
+ List<EmergencySuppliesInspectInfoDetailDO> inspectDetailDOList = emergencySuppliesInspectInfoService.selectEmergencySuppliesInspectBySuppliesId(emergencySuppliesDetailRespDTO.getId());
+ if (!CollectionUtils.isEmpty(inspectDetailDOList)){
+ List<EmergencySuppliesInspectDetailRespDTO> inspectList = BeanCopyUtils.copyBeanList(inspectDetailDOList,EmergencySuppliesInspectDetailRespDTO.class);
+ // 创建人
+ for (EmergencySuppliesInspectDetailRespDTO emergencySuppliesInspectDetailRespDTO :inspectList){
+ List<EmergencySuppliesInspectUserInfoDO> inspectUserDOList = emergencySuppliesInspectUserInfoService.selectEmergencySuppliesInspectUserBySuppliesInspectId(emergencySuppliesInspectDetailRespDTO.getId());
+ if (!CollectionUtils.isEmpty(inspectUserDOList)){
+ List<EmergencySuppliesInspectUserRespDTO> inspectUserList = BeanCopyUtils.copyBeanList(inspectUserDOList,EmergencySuppliesInspectUserRespDTO.class);
+ emergencySuppliesInspectDetailRespDTO.setUserList(inspectUserList);
+ }
+ }
+ emergencySuppliesDetailRespDTO.setInspectList(inspectList);
+ }
+ // 查找保养记录
+ List<EmergencySuppliesMaintainInfoDetailDO> maintainDetailDOList = emergencySuppliesMaintainInfoService.selectEmergencySuppliesMaintainBySuppliesId(emergencySuppliesDetailRespDTO.getId());
+ if (!CollectionUtils.isEmpty(maintainDetailDOList)){
+ List<EmergencySuppliesMaintainDetailRespDTO> maintainList = BeanCopyUtils.copyBeanList(maintainDetailDOList,EmergencySuppliesMaintainDetailRespDTO.class);
+ // 创建人
+ for (EmergencySuppliesMaintainDetailRespDTO emergencySuppliesMaintainDetailRespDTO :maintainList){
+ List<EmergencySuppliesMaintainUserInfoDO> maintainUserDOList = emergencySuppliesMaintainUserInfoService.selectEmergencySuppliesMaintainUserBySuppliesMaintainId(emergencySuppliesMaintainDetailRespDTO.getId());
+ if (!CollectionUtils.isEmpty(maintainUserDOList)){
+ List<EmergencySuppliesMaintainUserRespDTO> maintainUserList = BeanCopyUtils.copyBeanList(maintainUserDOList,EmergencySuppliesMaintainUserRespDTO.class);
+ emergencySuppliesMaintainDetailRespDTO.setUserList(maintainUserList);
+ }
+ }
+ emergencySuppliesDetailRespDTO.setMaintainList(maintainList);
+ }
+
return new ResultVO<>(ResultCodes.OK,emergencySuppliesDetailRespDTO);
}
}
@Override
public ResultVO updateEmergencySupplies(Long uid, EmergencySuppliesReqDTO emergencySuppliesReqDTO) {
+ // 验证必填
+ checkRequired(emergencySuppliesReqDTO);
+ //验证枚举
+ checkEnum(emergencySuppliesReqDTO);
+
Date nowDate = new Date();
// 查询是否存在
EmergencySuppliesInfoDetailDO emergencySuppliesInfoDetailDO = emergencySuppliesInfoService.selectEmergencySuppliesById(emergencySuppliesReqDTO.getId());
@@ -137,6 +196,50 @@
}
}
+ /**
+ * 按照物资类型分类获取列表
+ * @param currentUser
+ * @return
+ */
+ @Override
+ public List<EmergencySuppliesTypeRespDTO> emergencySuppliesList(ContextCacheUser currentUser) {
+
+ List<EmergencySuppliesInfo> emergencySuppliesInfoList = emergencySuppliesInfoService.listByNoConditions();
+ List<EmergencySuppliesTypeRespDTO> typeRespDTOList = new ArrayList<>();
+ for (EmergencySuppliesClassificationEnum teamLevelEnum : EmergencySuppliesClassificationEnum.values()) {
+ EmergencySuppliesTypeRespDTO typeRespDTO = new EmergencySuppliesTypeRespDTO();
+ typeRespDTO.setMaterialType(teamLevelEnum.getCode());
+ typeRespDTO.setMaterialTypeName(teamLevelEnum.getValue());
+ List<EmergencySuppliesRespDTO> respDTOList = new ArrayList<>();
+ List<EmergencySuppliesInfo> collect = emergencySuppliesInfoList.stream().filter(item -> item.getClassification().equals(teamLevelEnum.getCode())).collect(Collectors.toList());
+ if(!CollectionUtils.isEmpty(collect)){
+ for (EmergencySuppliesInfo info : collect) {
+ EmergencySuppliesRespDTO respDTO = new EmergencySuppliesRespDTO();
+ BeanUtils.copyProperties(info,respDTO);
+ respDTO.setMaterialType(info.getClassification());
+ respDTO.setMaterialTypeName(teamLevelEnum.getValue());
+ respDTOList.add(respDTO);
+ }
+ }
+ typeRespDTO.setList(respDTOList);
+ typeRespDTOList.add(typeRespDTO);
+ }
+ return typeRespDTOList;
+ }
+
+ @Override
+ public List<EmergencySuppliesRespDTO> listCountByIds(ContextCacheUser currentUser, List<Long> ids) {
+ if(null == ids || ids.size() == 0 ){
+ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL);
+ }
+ List<EmergencySuppliesInfo> emergencySuppliesInfos = emergencySuppliesInfoService.listCountByIds(ids);
+ List<EmergencySuppliesRespDTO> respDTOList = new ArrayList<>();
+ if(!CollectionUtils.isEmpty(emergencySuppliesInfos)){
+ respDTOList = BeanCopyUtils.copyBeanList(emergencySuppliesInfos,EmergencySuppliesRespDTO.class);
+ }
+ return respDTOList;
+ }
+
private void deleteEmergencySupplies(Long id) {
//查询是否存在
EmergencySuppliesInfoDetailDO emergencySuppliesInfoDetailDO = emergencySuppliesInfoService.selectEmergencySuppliesById(id);
@@ -145,6 +248,37 @@
}else{
Long SuppliesId = emergencySuppliesInfoDetailDO.getId();
emergencySuppliesInfoService.deleteEmergencySupplies(SuppliesId);
+
+ // 删除保养记录
+ emergencySuppliesMaintainInfoService.deleteBySuppliesId(id);
+ // 删除检查记录
+ emergencySuppliesInspectInfoService.deleteBySuppliesId(id);
+
+ }
+ }
+
+
+
+ /**
+ * 验证必填项
+ * @return
+ */
+ private void checkRequired(EmergencySuppliesReqDTO emergencySuppliesReqDTO) {
+ //名称
+ if (StringUtils.isBlank(emergencySuppliesReqDTO.getName())) {
+ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_NAME_NOT_EXIST);
+ }
+ }
+
+ /**
+ * 验证枚举
+ */
+ private void checkEnum(EmergencySuppliesReqDTO emergencySuppliesReqDTO){
+ if (EmergencySuppliesClassificationEnum.getByCode(emergencySuppliesReqDTO.getClassification())==null){
+ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_ENUM_CLASSIFICATION_NOT_EXIST);
+ }
+ if (EmergencySuppliesStatusEnum.getByCode(emergencySuppliesReqDTO.getStatus())==null){
+ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_ENUM_STATUS_NOT_EXIST);
}
}
}
--
Gitblit v1.9.2