소스 검색

fix: 别名匹配错误数据恢复调整

chenjianhua 7 달 전
부모
커밋
d2c4ded68f

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

@@ -21,4 +21,6 @@ public interface AssetMapper {
     void deleteAsset(@Param("fundId") String fundId, @Param("priceDate") String priceDate,@Param("updaterId")Integer userId);
 
     List<AssetDO> selectAssetByFundId(@Param("fundId")String fundId);
+
+    void batchDeleteAsset(@Param("fundId")String sourceFundId,@Param("priceDateList") List<String> priceDateList);
 }

+ 3 - 0
service-base/src/main/java/com/simuwang/base/mapper/EmailFundAssetMapper.java

@@ -1,6 +1,7 @@
 package com.simuwang.base.mapper;
 
 import com.simuwang.base.pojo.dos.EmailFundAssetDO;
+import com.simuwang.base.pojo.dos.EmailFundNavDO;
 import com.simuwang.base.pojo.dos.EmailParseDetailDO;
 import com.simuwang.base.pojo.dto.query.ParseDetailPageQuery;
 import org.apache.ibatis.annotations.Mapper;
@@ -26,4 +27,6 @@ public interface EmailFundAssetMapper {
     void batchUpdate(@Param("itemDoList")List<EmailFundAssetDO> fundAssetDOList);
 
     List<EmailParseDetailDO> selectFundAssetByFielId(@Param("fileId") Integer fileId, @Param("priceDate") String priceDate);
+
+    List<EmailFundAssetDO> selectAssetByFundId(@Param("fundId") String sourceFundId);
 }

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

@@ -31,4 +31,6 @@ public interface EmailFundNavMapper {
     String getMaxPriceDate(@Param("fundName")String sourceFundName);
 
     List<EmailParseDetailDO> selectFundNavByFielId(@Param("fileId") Integer fileId, @Param("priceDate") String priceDate);
+
+    List<EmailFundNavDO> selectNavByFundId(@Param("fundId") String sourceFundId);
 }

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

@@ -26,4 +26,6 @@ public interface NavMapper {
     List<String> getAllFundId();
 
     List<NavDO> selectNavByFundId(@Param("fundId")String fundId);
+
+    void batchDeleteNav(@Param("fundId")String sourceFundId, @Param("priceDateList")List<String> priceDateList);
 }

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

@@ -40,6 +40,13 @@
     <delete id="deleteAsset">
         update PPW_EMAIL.asset set isvalid =0,updatetime=sysdate(),updaterid=#{updaterId} where fund_id=#{fundId} and price_date=#{priceDate} and isvalid=1
     </delete>
+    <delete id="batchDeleteAsset">
+        delete from  PPW_EMAIL.asset where fund_id=#{FundId} and isvalid=1
+        and price_date in
+        <foreach collection="priceDateList" index="index" item="priceDate" separator="," open="(" close=")">
+            #{priceDate}
+        </foreach>
+    </delete>
 
     <select id="queryFundNavByDate" resultType="java.lang.String">
         select price_date

+ 5 - 0
service-base/src/main/resources/mapper/EmailFundAssetMapper.xml

@@ -222,6 +222,11 @@
         WHERE efi.isvalid = 1
           AND efi.id = #{fileId} and asset.price_date=#{priceDate}
     </select>
+    <select id="selectAssetByFundId" resultMap="BaseResultMap">
+        select id,file_id, fund_id, fund_name,register_number,price_date,asset_net,asset_share,is_stored,exception_status,
+               isvalid, creatorid, createtime, updaterid, updatetime
+        from PPW_EMAIL.email_fund_asset where isvalid=1 and fund_id=#{fundId}
+    </select>
 
     <delete id="deleteByFileId">
         update PPW_EMAIL.email_fund_asset

+ 20 - 0
service-base/src/main/resources/mapper/EmailFundNavMapper.xml

@@ -252,6 +252,26 @@
         WHERE efi.isvalid = 1
           AND efi.id = #{fileId} and nav.price_date=#{priceDate}
     </select>
+    <select id="selectNavByFundId" resultMap="BaseResultMap">
+        select nav.id,
+               nav.file_id,
+               nav.fund_id,
+               nav.fund_name,
+               nav.register_number,
+               nav.price_date,
+               nav.nav,
+               nav.cumulative_nav_withdrawal,
+               nav.exception_status,
+               nav.is_stored,
+               nav.isvalid,
+               nav.creatorid,
+               nav.updaterid,
+               nav.updatetime,
+               nav.createtime
+        from PPW_EMAIL.email_fund_nav nav
+        where nav.isvalid =1 and nav.exception_status=1
+        and nav.fund_id = #{fundId}
+    </select>
 
 
 </mapper>

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

@@ -56,6 +56,13 @@
         where isvalid = 1
         and id=#{id}
     </update>
+    <update id="batchDeleteNav">
+        delete from PPW_EMAIL.nav where fund_id=#{fundId} and isvalid=1
+        and price_date in
+        <foreach collection="priceDateList" index="index" item="priceDate" separator="," open="(" close=")">
+            #{priceDate}
+        </foreach>
+    </update>
     <delete id="deleteNav">
         update PPW_EMAIL.nav set isvalid =0,updatetime=sysdate(),updaterid=#{updaterId} where fund_id=#{fundId} and price_date=#{priceDate} and isvalid =1
     </delete>

+ 1 - 1
service-manage/src/main/java/com/simuwang/manage/service/EmailFundAssetService.java

@@ -7,5 +7,5 @@ package com.simuwang.manage.service;
  * Description: ${DESCRIPTION}
  */
 public interface EmailFundAssetService {
-    void reparseFileAsset(String sourceFundName,String registerNumber, String targetFundId);
+    void reparseFileAsset(String sourceFundName,String registerNumber, String targetFundId,String sourceFundId);
 }

+ 1 - 1
service-manage/src/main/java/com/simuwang/manage/service/EmailFundNavService.java

@@ -7,5 +7,5 @@ package com.simuwang.manage.service;
  * Description: ${DESCRIPTION}
  */
 public interface EmailFundNavService {
-    void reparseFileNav(String sourceFundName,String registerNumber, String targetFundId);
+    void reparseFileNav(String sourceFundName,String registerNumber, String targetFundId,String sourceFundId);
 }

+ 22 - 1
service-manage/src/main/java/com/simuwang/manage/service/impl/EmailFundAssetServiceImpl.java

@@ -3,6 +3,8 @@ package com.simuwang.manage.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.simuwang.base.common.util.DateUtils;
+import com.simuwang.base.common.util.StringUtil;
+import com.simuwang.base.mapper.AssetMapper;
 import com.simuwang.base.mapper.EmailFundAssetMapper;
 import com.simuwang.base.pojo.dos.AssetDO;
 import com.simuwang.base.pojo.dos.EmailFundAssetDO;
@@ -34,8 +36,11 @@ public class EmailFundAssetServiceImpl implements EmailFundAssetService {
     @Autowired
     private EmailParseService emailParseService;
 
+    @Autowired
+    private AssetMapper assetMapper;
+
     @Override
-    public void reparseFileAsset(String sourceFundName,String registerNumber, String targetFundId) {
+    public void reparseFileAsset(String sourceFundName,String registerNumber, String targetFundId,String sourceFundId) {
         List<EmailFundAssetDO> fundAssetDOList = emailFundAssetMapper.selectNotMappingAsset(sourceFundName,registerNumber);
         Map<String,List<EmailFundAssetDO>> fundAssetDOGroup = fundAssetDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getPriceDate(),DateUtils.YYYY_MM_DD)));
         List<EmailFundAssetDO> dataList = new ArrayList<>();
@@ -59,6 +64,22 @@ public class EmailFundAssetServiceImpl implements EmailFundAssetService {
             List<AssetDO> assetDOList = dataList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
                     .map(e -> BeanUtil.copyProperties(e, AssetDO.class)).collect(Collectors.toList());
             emailParseService.saveAssetDo(assetDOList);
+
+            if(StringUtil.isNotEmpty(sourceFundId)){
+                List<String> priceDateList = new ArrayList<>();
+                for(EmailFundAssetDO fundAssetDO : fundAssetDOList){
+                    priceDateList.add(DateUtils.format(fundAssetDO.getPriceDate(),DateUtils.YYYY_MM_DD));
+                }
+                //将匹配错的数据置为无效
+                assetMapper.batchDeleteAsset(sourceFundId,priceDateList);
+                //从解析库把原来的规模数据重新写入到sourceFundId对应的基金上
+                List<EmailFundAssetDO> sourceAssetList = emailFundAssetMapper.selectAssetByFundId(sourceFundId);
+                List<AssetDO> sourceAssetDOList = sourceAssetList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
+                        .map(e -> BeanUtil.copyProperties(e, AssetDO.class)).collect(Collectors.toList());
+                sourceAssetDOList.forEach(e -> e.setUpdateTime(DateUtils.getNowDate()));
+                emailParseService.saveAssetDo(sourceAssetDOList);
+            }
+
         }
     }
 }

+ 21 - 3
service-manage/src/main/java/com/simuwang/manage/service/impl/EmailFundNavServiceImpl.java

@@ -3,7 +3,9 @@ package com.simuwang.manage.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.simuwang.base.common.util.DateUtils;
+import com.simuwang.base.common.util.StringUtil;
 import com.simuwang.base.mapper.EmailFundNavMapper;
+import com.simuwang.base.mapper.NavMapper;
 import com.simuwang.base.pojo.dos.CompanyEmailSendHistoryDO;
 import com.simuwang.base.pojo.dos.EmailFundNavDO;
 import com.simuwang.base.pojo.dos.NavDO;
@@ -33,8 +35,11 @@ public class EmailFundNavServiceImpl implements EmailFundNavService {
     @Autowired
     private EmailParseService emailParseService;
 
+    @Autowired
+    private NavMapper navMapper;
+
     @Override
-    public void reparseFileNav(String sourceFundName,String registerNumber, String targetFundId) {
+    public void reparseFileNav(String sourceFundName,String registerNumber, String targetFundId,String sourceFundId) {
         List<EmailFundNavDO> fundNavDOList = emailFundNavMapper.selectNotMappingNav(sourceFundName,registerNumber);
         Map<String,List<EmailFundNavDO>> fundNavDOGroup = fundNavDOList.stream().collect(Collectors.groupingBy(e -> DateUtils.format(e.getPriceDate(),DateUtils.YYYY_MM_DD)));
         List<EmailFundNavDO> dataList = new ArrayList<>();
@@ -57,8 +62,21 @@ public class EmailFundNavServiceImpl implements EmailFundNavService {
                     .map(e -> BeanUtil.copyProperties(e, NavDO.class)).collect(Collectors.toList());
             navDOList.forEach(e -> e.setUpdateTime(DateUtils.getNowDate()));
             emailParseService.saveNavDo(navDOList);
-
-
+            //还原历史基金的净值数据
+            if(StringUtil.isNotEmpty(sourceFundId)){
+                List<String> priceDateList = new ArrayList<>();
+                for(EmailFundNavDO fundNavDO : fundNavDOList){
+                    priceDateList.add(DateUtils.format(fundNavDO.getPriceDate(),DateUtils.YYYY_MM_DD));
+                }
+                //将匹配错的数据删除
+                navMapper.batchDeleteNav(sourceFundId,priceDateList);
+                //从解析库把原来的净值数据重新写入到sourceFundId对应的基金上
+                List<EmailFundNavDO> sourceNavList = emailFundNavMapper.selectNavByFundId(sourceFundId);
+                List<NavDO> sourcenavDOList = sourceNavList.stream().filter(e -> StrUtil.isNotBlank(e.getFundId()))
+                        .map(e -> BeanUtil.copyProperties(e, NavDO.class)).collect(Collectors.toList());
+                sourcenavDOList.forEach(e -> e.setUpdateTime(DateUtils.getNowDate()));
+                emailParseService.saveNavDo(sourcenavDOList);
+            }
         }
     }
 }

+ 5 - 2
service-manage/src/main/java/com/simuwang/manage/service/impl/FundAliasServiceImpl.java

@@ -92,11 +92,14 @@ public class FundAliasServiceImpl implements FundAliasService {
         fundAliasDO.setUpdaterId(UserUtils.getLoginUser().getUserId());
         fundAliasDO.setCreatorId(UserUtils.getLoginUser().getUserId());
         fundAliasDO.setUpdateTime(new Date());
+
+        FundAliasDO oldFundAliasDO = fundAliasMapper.searchFundAliasById(fundAliasVO.getId());
+        String oldFundId = oldFundAliasDO.getTargetFundId();
         fundAliasMapper.saveFundAlias(fundAliasDO);
         //将采集的净值数据匹配之后重新入库
-        emailFileNavService.reparseFileNav(fundAliasVO.getSourceFundName(),fundAliasVO.getSourceRegisterNumber(),fundAliasVO.getTargetFundId());
+        emailFileNavService.reparseFileNav(fundAliasVO.getSourceFundName(),fundAliasVO.getSourceRegisterNumber(),fundAliasVO.getTargetFundId(),oldFundId);
         //将采集的规模数据匹配之后重新入库
-        emailFundAssetService.reparseFileAsset(fundAliasVO.getSourceFundName(),fundAliasVO.getSourceRegisterNumber(),fundAliasVO.getTargetFundId());
+        emailFundAssetService.reparseFileAsset(fundAliasVO.getSourceFundName(),fundAliasVO.getSourceRegisterNumber(),fundAliasVO.getTargetFundId(),oldFundId);
         //处理采集数据,将采集的数据入库
         emailFundInfoService.reparseValuationFile(fundAliasVO.getSourceFundName(),fundAliasVO.getSourceRegisterNumber());
     }