Forráskód Böngészése

1、解决空字符串问题

rayson 7 hónapja
szülő
commit
56b7e777eb

+ 14 - 11
menduner/menduner-system-biz/src/main/java/com/citu/module/menduner/system/service/enterprise/EnterpriseServiceImpl.java

@@ -6,7 +6,6 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.citu.framework.common.pojo.PageParam;
 import com.citu.framework.common.pojo.PageResult;
 import com.citu.framework.common.util.object.BeanUtils;
-import com.citu.framework.common.util.object.ObjectUtils;
 import com.citu.framework.datapermission.core.annotation.DataPermission;
 import com.citu.framework.dict.core.DictFrameworkUtils;
 import com.citu.module.menduner.common.dto.TimeRangeBaseReqVO;
@@ -39,6 +38,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
@@ -151,7 +151,7 @@ public class EnterpriseServiceImpl implements EnterpriseService {
         PageResult<EnterpriseDetailRespVO> result = enterpriseMapper.page(pageReqVO);
         result.getList().forEach(item -> {
             List<EnterpriseAddressDO> addressList = addressService.getEnterpriseAddressList(item.getId());
-            if(ObjectUtil.isNotEmpty(addressList)) {
+            if (ObjectUtil.isNotEmpty(addressList)) {
                 item.setAddressList(BeanUtils.toBean(addressList, EnterpriseAddressRespVO.class));
             }
         });
@@ -297,22 +297,25 @@ public class EnterpriseServiceImpl implements EnterpriseService {
     @Override
     public List<AppEnterpriseDetailRespVO> getEnterpriseDetails(String ids) {
         List<AppEnterpriseDetailRespVO> appEnterpriseDetailRespVOS = new ArrayList<>();
-        List<Long> enterprideIds = Arrays.asList(ids.split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
-        if (enterprideIds.isEmpty()) {
+        List<Long> enterpriseIds =  Arrays.stream(ids.split(","))
+                .filter(StringUtils::hasText)
+                .map(Long::parseLong)
+                .collect(Collectors.toList());
+        if (enterpriseIds.isEmpty()) {
             return new ArrayList<>();
         }
-        List<EnterpriseDO> enterprise = enterpriseMapper.selectBatchIds(enterprideIds);
-        List<EnterpriseBusinessDO> business = enterpriseBusinessMapper.selectByEnterpriseIds(enterprideIds);
-        List<EnterpriseAddressDO> addresseList = enterpriseAddressMapper.selectByEnterpriseId(enterprideIds);
+        List<EnterpriseDO> enterprise = enterpriseMapper.selectBatchIds(enterpriseIds);
+        List<EnterpriseBusinessDO> business = enterpriseBusinessMapper.selectByEnterpriseIds(enterpriseIds);
+        List<EnterpriseAddressDO> addresseList = enterpriseAddressMapper.selectByEnterpriseId(enterpriseIds);
         Map<Long, EnterpriseBusinessDO> enterpriseBusinessDOMap = business.stream()
-                .collect(Collectors.toMap(item -> item.getEnterpriseId(), item -> item));
+                .collect(Collectors.toMap(EnterpriseBusinessDO::getEnterpriseId, item -> item));
         Map<Long, List<EnterpriseAddressDO>> addresseListMap = new HashMap<>();
         for (EnterpriseAddressDO enterpriseAddressDO : addresseList) {
             List<EnterpriseAddressDO> orDefault = addresseListMap.getOrDefault(enterpriseAddressDO.getEnterpriseId(), new ArrayList<>());
             orDefault.add(enterpriseAddressDO);
             addresseListMap.put(enterpriseAddressDO.getEnterpriseId(), orDefault);
         }
-        Set<Long> industrysIds = new HashSet<>();
+        Set<Long> industryIds = new HashSet<>();
         for (EnterpriseDO enterpriseDO : enterprise) {
             AppEnterpriseDetailRespVO respVO = new AppEnterpriseDetailRespVO();
             respVO.setEnterprise(EnterpriseConvert.INSTANCE.convert3(enterpriseDO));
@@ -321,10 +324,10 @@ public class EnterpriseServiceImpl implements EnterpriseService {
             if (null != respVO.getEnterprise().getScale()) {
                 respVO.getEnterprise().setScaleName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.MENDUNER_SCALE, respVO.getEnterprise().getScale()));
             }
-            industrysIds.add(enterpriseDO.getIndustryId());
+            industryIds.add(enterpriseDO.getIndustryId());
             appEnterpriseDetailRespVOS.add(respVO);
         }
-        Map<Long, String> map = industryService.getIndustryTitleByIds(industrysIds);
+        Map<Long, String> map = industryService.getIndustryTitleByIds(industryIds);
         appEnterpriseDetailRespVOS.forEach(item -> item.getEnterprise().setIndustryName(map.get(item.getEnterprise().getIndustryId())));
 
         return appEnterpriseDetailRespVOS;