Sfoglia il codice sorgente

feat:净值导入优化

chenjianhua 1 mese fa
parent
commit
87cf3eef11

+ 2 - 0
service-base/src/main/java/com/simuwang/base/mapper/daq/FundInfoMapper.java

@@ -60,4 +60,6 @@ public interface FundInfoMapper {
     List<FundDeletionBaseInfoDO> getHasFrequencyFundInfo();
 
     List<FundInfoDO> searchFundInfoListByFundIdList(@Param("fundIdList")List<String> fundIdList);
+
+    List<FundInfoDO> searchFundInfoListByFundNameList(@Param("fundNameList")List<String> fundNameList);
 }

+ 7 - 0
service-base/src/main/resources/mapper/daq/FundInfoMapper.xml

@@ -298,4 +298,11 @@
             #{fundId}
         </foreach>
     </select>
+    <select id="searchFundInfoListByFundNameList" resultMap="BaseResultMap">
+        select info.fund_id,info.fund_name from PPW_EMAIL.pvn_fund_info info where isvalid=1
+        and info.fund_name in
+        <foreach collection="fundNameList" index="index" item="fundName" separator="," open="(" close=")">
+            #{fundName}
+        </foreach>
+    </select>
 </mapper>

+ 3 - 0
service-manage/src/main/java/com/simuwang/manage/service/ChannelService.java

@@ -1,6 +1,7 @@
 package com.simuwang.manage.service;
 
 import com.simuwang.base.common.support.MybatisPage;
+import com.simuwang.base.pojo.dos.ChannelInfoDO;
 import com.simuwang.base.pojo.dto.GetByIdQuery;
 import com.simuwang.base.pojo.dto.query.ChannelIdPageQuery;
 import com.simuwang.base.pojo.dto.query.ChannelPageQuery;
@@ -30,4 +31,6 @@ public interface ChannelService {
     boolean existsChannel(String channelId);
 
     ResultVo saveChannelResponsibility(ChannelResponsibilityInfoVO channelResponsibilityInfoVO);
+
+    List<ChannelInfoDO> selectChannelInfolist(List<String> list);
 }

+ 5 - 0
service-manage/src/main/java/com/simuwang/manage/service/impl/ChannelServiceImpl.java

@@ -178,4 +178,9 @@ public class ChannelServiceImpl implements ChannelService {
         }
         return vo;
     }
+
+    @Override
+    public List<ChannelInfoDO> selectChannelInfolist(List<String> list) {
+        return channelMapper.selectBatchIds(list);
+    }
 }

+ 42 - 10
service-manage/src/main/java/com/simuwang/manage/service/impl/FundNavAssetServiceImpl.java

@@ -10,9 +10,7 @@ import com.simuwang.base.common.util.DateUtils;
 import com.simuwang.base.common.util.StringUtil;
 import com.simuwang.base.components.UserAuthService;
 import com.simuwang.base.mapper.daq.*;
-import com.simuwang.base.pojo.dos.AssetDO;
-import com.simuwang.base.pojo.dos.FundNavAssetDO;
-import com.simuwang.base.pojo.dos.NavDO;
+import com.simuwang.base.pojo.dos.*;
 import com.simuwang.base.pojo.dto.NavAssetExcelData;
 import com.simuwang.base.pojo.dto.query.FundNavAssetPageQuery;
 import com.simuwang.base.pojo.vo.*;
@@ -32,10 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.io.InputStream;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -169,6 +164,33 @@ public class FundNavAssetServiceImpl implements FundNavAssetService {
         int startRow = 3;
         List<ExcelNavAssetSuccessDataVO> successDataVOList = new ArrayList<>();
         List<ExcelNavAssetFailDataVO> excelFailDataVOList = new ArrayList<>();
+        Map<String,String> fundInfoMap = new HashMap<>();
+        Map<String,String> channelInfoMap = new HashMap<>();
+        try{
+            List<NavAssetExcelData> fundIdNotNullList = list.stream().filter(e -> StringUtil.isNotEmpty(e.getFundId())).collect(Collectors.toList());
+            Map<String,List<NavAssetExcelData>> fundIdMap = fundIdNotNullList.stream().collect(Collectors.groupingBy(NavAssetExcelData::getFundId));
+            List<NavAssetExcelData> fundNameNotNullList = list.stream().filter(e -> StringUtil.isNotEmpty(e.getFundName())).collect(Collectors.toList());
+            Map<String,List<NavAssetExcelData>> fundNameMap = fundNameNotNullList.stream().collect(Collectors.groupingBy(NavAssetExcelData::getFundName));
+            List<NavAssetExcelData> channelIdNotNullList = list.stream().filter(e -> StringUtil.isNotEmpty(e.getChannelId())).collect(Collectors.toList());
+            Map<String,List<NavAssetExcelData>> channelIdMap = channelIdNotNullList.stream().collect(Collectors.groupingBy(NavAssetExcelData::getChannelId));
+            if(!fundIdMap.isEmpty()){
+                Set<String> fundIdList = fundIdMap.keySet();
+                List<FundInfoDO> fundIdDOList = fundInfoMapper.searchFundInfoListByFundIdList(fundIdList.stream().toList());
+                fundIdDOList.forEach(fundInfoDO -> fundInfoMap.put(fundInfoDO.getFundId(),fundInfoDO.getFundName()));
+            }
+            if(!channelIdMap.isEmpty()){
+                Set<String> channelIdList = channelIdMap.keySet();
+                List<ChannelInfoDO> channelInfoList = channelService.selectChannelInfolist(channelIdList.stream().toList());
+                channelInfoList.forEach(channelInfoDO -> channelInfoMap.put(String.valueOf(channelInfoDO.getId()),channelInfoDO.getChannelName()));
+            }
+            if(!fundNameMap.isEmpty()){
+                Set<String> fundNameList = fundNameMap.keySet();
+                List<FundInfoDO> fundNameDOList = fundInfoMapper.searchFundInfoListByFundNameList(fundNameList.stream().toList());
+                fundNameDOList.forEach(fundInfoDO -> fundInfoMap.put(fundInfoDO.getFundName(),fundInfoDO.getFundId()));
+            }
+        }catch (Exception e){
+            logger.error(e.getMessage(),e);
+        }
         for(int dataIdx=1;dataIdx<list.size(); dataIdx++){
             NavAssetExcelData excelData = list.get(dataIdx);
             try{
@@ -183,13 +205,18 @@ public class FundNavAssetServiceImpl implements FundNavAssetService {
                     excelFailDataVOList.add(failDataVO);
                     continue;
                 }
-                if(channelService.existsChannel(excelData.getChannelId())){
+                if(channelInfoMap.get(excelData.getChannelId()) == null){
                     ExcelNavAssetFailDataVO failDataVO = toExcelFailDataVO(excelData,ExcelConst.REQUIRE_FIELD,dataIdx+startRow);
                     excelFailDataVOList.add(failDataVO);
                     continue;
                 }
                 if(StringUtil.isNotEmpty(excelData.getFundId())){
-                    String fundName = fundInfoMapper.getFundNameByFundId(excelData.getFundId());
+                    String fundName = null;
+                    if(!fundInfoMap.isEmpty()){
+                        fundName = fundInfoMap.get(excelData.getFundId());
+                    }else{
+                        fundName = fundInfoMapper.getFundNameByFundId(excelData.getFundId());
+                    }
                     if(StringUtil.isEmpty(excelData.getFundName())){
                         excelData.setFundName(fundName);
                     }
@@ -199,7 +226,12 @@ public class FundNavAssetServiceImpl implements FundNavAssetService {
                         continue;
                     }
                 }else{
-                    String fundId = fundInfoMapper.queryFundIdByName(excelData.getFundName());
+                    String fundId = null;
+                    if(!fundInfoMap.isEmpty()){
+                        fundId = fundInfoMap.get(excelData.getFundName());
+                    }else{
+                        fundInfoMapper.queryFundIdByName(excelData.getFundName());
+                    }
                     if(StringUtil.isEmpty(fundId)){
                         ExcelNavAssetFailDataVO failDataVO = toExcelFailDataVO(excelData,ExcelConst.NOT_MAPPING_FUND,dataIdx+startRow);
                         excelFailDataVOList.add(failDataVO);