From b98d1d16f81efb2a7795f1b8753e10a3fa98968f Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期二, 16 八月 2022 17:32:55 +0800 Subject: [PATCH] 应急第一个图 --- emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java | 90 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 83 insertions(+), 7 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 dc637b0..ee0cac2 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,10 +1,11 @@ package com.gkhy.safePlatform.emergency.service.impl; 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.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.*; @@ -14,20 +15,41 @@ import com.gkhy.safePlatform.emergency.model.dto.resp.*; 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; @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; @Override @@ -42,6 +64,24 @@ } List<EmergencySuppliesInfoPageDO> emergencySuppliesListDoInfoList = emergencySuppliesInfoService.selectEmergencySuppliesList(page,emergencySuppliesDBQuery); List<EmergencySuppliesPageRespDTO> respList = BeanCopyUtils.copyBeanList(emergencySuppliesListDoInfoList, EmergencySuppliesPageRespDTO.class); + + Map<Long, String> depPool = new HashMap<>(); + + respList.forEach(AccidentExpressPageRespDTO ->{ + // 设置部门名称 + if (!depPool.containsKey(AccidentExpressPageRespDTO.getDepartmentId())) { + ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(AccidentExpressPageRespDTO.getDepartmentId()); + if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) { + if (rpcResult.getData() != null) { + DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData(); + + depPool.put(dep.getDepId(), dep.getDepName()); + } + }} + + String depName = depPool.get(AccidentExpressPageRespDTO.getDepartmentId()); + AccidentExpressPageRespDTO.setDeptName(depName); + }); return new SearchResultVO<>( true, @@ -76,6 +116,36 @@ 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); } } @@ -99,13 +169,13 @@ } @Override - public ResultVO batchDeleteEmergencySupplies(String ids) { - if (StringUtils.isBlank(ids)) { + public ResultVO batchDeleteEmergencySupplies( Long[] ids) { + + if (ids == null || ids.length==0){ throw new EmergencyException(EmergencyResultCodes.SUPPLIES_NULL); - } else { - String[] idArr = ids.split(","); - for (String id : idArr) { - deleteEmergencySupplies(Long.valueOf(id)); + }else{ + for (Long id : ids){ + deleteEmergencySupplies(id); } return new ResultVO(ResultCodes.OK); } @@ -119,6 +189,12 @@ }else{ Long SuppliesId = emergencySuppliesInfoDetailDO.getId(); emergencySuppliesInfoService.deleteEmergencySupplies(SuppliesId); + + // 删除保养记录 + emergencySuppliesMaintainInfoService.deleteBySuppliesId(id); + // 删除检查记录 + emergencySuppliesInspectInfoService.deleteBySuppliesId(id); + } } } -- Gitblit v1.9.2