From f433dfcf55dc97c392a6767c5c0d3a01b2481b24 Mon Sep 17 00:00:00 2001
From: zhangyh <zhangyahui@wealthgrow.cn>
Date: Wed, 24 Feb 2021 19:51:07 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E9=87=91=E8=AF=A6=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../feign/user/FeignClientForFatools.java     | 42 +++++++++++++
 .../fund/feign/user/FeignbackForFatools.java  | 63 +++++++++++++++++++
 .../fund/service/impl/ProductServiceImpl.java | 32 +++++++++-
 3 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 src/main/java/com/tanpu/fund/feign/user/FeignClientForFatools.java
 create mode 100644 src/main/java/com/tanpu/fund/feign/user/FeignbackForFatools.java

diff --git a/src/main/java/com/tanpu/fund/feign/user/FeignClientForFatools.java b/src/main/java/com/tanpu/fund/feign/user/FeignClientForFatools.java
new file mode 100644
index 0000000..2d1f182
--- /dev/null
+++ b/src/main/java/com/tanpu/fund/feign/user/FeignClientForFatools.java
@@ -0,0 +1,42 @@
+package com.tanpu.fund.feign.user;
+
+import com.tanpu.common.model.product.resp.ProductLabel;
+import com.tanpu.common.model.product.resp.UserInfoVo;
+import com.tanpu.common.model.user.resp.ColumnVO;
+import com.tanpu.common.model.user.resp.SysConstantResp;
+import com.tanpu.common.resp.CommonResp;
+import feign.Headers;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotEmpty;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+//@FeignClient(value = "fatools", fallbackFactory = FeignbackForFatools.class, url = "http://127.0.0.1:8189/fatools")
+@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
+public interface FeignClientForFatools {
+
+    @PostMapping(value = "/h6/userinfo/queryinfos")
+    @Headers({"Content-Type: application/json"})
+    CommonResp<ArrayList<UserInfoVo>> queryUsersList(List<String> userIds);
+
+    @GetMapping(value = "/h5/tag/querybyrelid", produces = {"application/json"})
+    CommonResp<List<ProductLabel>> querytagbyrelid(@RequestParam("relId") String relId);
+
+    @GetMapping(value = "/h5/sysconstant/queryByconstantGroup", produces = {"application/json"})
+    CommonResp<List<SysConstantResp>> queryLabels(@RequestParam("constantGroup") String constantGroup);
+
+    @GetMapping("/column")
+    CommonResp<List<ColumnVO>> getColumnInfo(@RequestParam("id") String id);
+
+    @ApiOperation("批量查询标签信息")
+    @GetMapping("/batch/get/label")
+    CommonResp<Map<String, List<ProductLabel>>> batchGetLabelByIdInfo(@RequestParam("list")@Valid @NotEmpty List<String> list);
+
+}
diff --git a/src/main/java/com/tanpu/fund/feign/user/FeignbackForFatools.java b/src/main/java/com/tanpu/fund/feign/user/FeignbackForFatools.java
new file mode 100644
index 0000000..9d46133
--- /dev/null
+++ b/src/main/java/com/tanpu/fund/feign/user/FeignbackForFatools.java
@@ -0,0 +1,63 @@
+package com.tanpu.fund.feign.user;
+
+import com.alibaba.fastjson.JSON;
+import com.tanpu.common.model.product.resp.ProductLabel;
+import com.tanpu.common.model.product.resp.UserInfoVo;
+import com.tanpu.common.model.user.resp.ColumnVO;
+import com.tanpu.common.model.user.resp.SysConstantResp;
+import com.tanpu.common.resp.CommonResp;
+import feign.hystrix.FallbackFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotEmpty;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Component
+public class FeignbackForFatools implements FallbackFactory<FeignClientForFatools> {
+
+    @Override
+    public FeignClientForFatools create(Throwable throwable) {
+        return new FeignClientForFatools() {
+            @Override
+            public CommonResp<ArrayList<UserInfoVo>> queryUsersList(List<String> userIds) {
+                log.error("请求信息", throwable);
+                log.error("FeignClientForUser.queryUsersList用户信息查询失败");
+                return null;
+            }
+
+            @Override
+            public CommonResp<List<ProductLabel>> querytagbyrelid(String relId) {
+                log.error("请求信息", throwable);
+                log.error("FeignClientForUser.querytagbyrelid 查询标签失败 relId:{}", relId);
+                return null;
+            }
+
+            @Override
+            public CommonResp<List<SysConstantResp>> queryLabels(String constantGroup) {
+                log.error("请求信息", throwable);
+                log.error("FeignClientForUser.queryLabels 查询标签失败 constantGroup:{}", constantGroup);
+                return null;
+            }
+
+            @Override
+            public CommonResp<List<ColumnVO>> getColumnInfo(String id) {
+                log.error("请求信息", throwable);
+                log.error("FeignClientForUser.getColumnInfo 查询栏目失败 id:{}", id);
+                return null;
+            }
+
+            @Override
+            public CommonResp<Map<String, List<ProductLabel>>> batchGetLabelByIdInfo(@Valid @NotEmpty List<String> list) {
+                log.error("请求信息", throwable);
+                log.error("FeignClientForUser.getColumnInfo 查询栏目失败 id:{}", JSON.toJSONString(list));
+                return null;
+            }
+        };
+    }
+
+}
diff --git a/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java b/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java
index 7450f8b..30cf0fc 100644
--- a/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java
+++ b/src/main/java/com/tanpu/fund/service/impl/ProductServiceImpl.java
@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
 import com.tanpu.common.auth.UserInfoThreadLocalHolder;
 import com.tanpu.common.enums.BizEnums;
 import com.tanpu.common.enums.Constant;
+import com.tanpu.common.enums.SysConstEnums;
 import com.tanpu.common.model.Page;
 import com.tanpu.common.model.Pageable;
 import com.tanpu.common.model.product.FundInfoVO;
@@ -14,10 +15,13 @@ import com.tanpu.common.model.product.req.NetReq;
 import com.tanpu.common.model.product.req.ProductInfoReq;
 import com.tanpu.common.model.product.req.ProductListReq;
 import com.tanpu.common.model.product.resp.*;
+import com.tanpu.common.model.user.resp.SysConstantResp;
+import com.tanpu.common.resp.CommonResp;
 import com.tanpu.common.utils.BigDecimalUtil;
 import com.tanpu.fund.entity.generator.*;
 import com.tanpu.fund.enums.FilterTypeEnum;
 import com.tanpu.fund.enums.ProStrategyEnums;
+import com.tanpu.fund.feign.user.FeignClientForFatools;
 import com.tanpu.fund.mapper.generator.*;
 import com.tanpu.fund.mapper.generator.custom.FundInfoCustomMapper;
 import com.tanpu.fund.service.ProductCommonService;
@@ -95,6 +99,9 @@ public class ProductServiceImpl implements ProductService, Constant {
     @Resource
     private ProductCommonService productCommonService;
 
+    @Resource
+    private FeignClientForFatools fatools;
+
     @Override
     public Page<ProductInfoVO> getProductList(ProductInfoReq req) {
 
@@ -179,6 +186,17 @@ public class ProductServiceImpl implements ProductService, Constant {
             vo.setManagerName(fundManagerVO.getManagerName());
         }
 
+        //子策略名称
+        if (vo.getSubstrategy() != null) {
+            CommonResp<List<SysConstantResp>> listCommonResp = this.fatools.queryLabels(SysConstEnums.TAMPSUBSTRATEGY.getConstantGroup());
+            if (listCommonResp.isSuccess()) {
+                SysConstantResp sysConstantResp = listCommonResp.getAttributes().stream().filter(item -> StringUtils.equals(String.valueOf(vo.getSubstrategy()), item.getConstantCode())).findFirst().orElse(null);
+                if (sysConstantResp != null) {
+                    vo.setStrategyName(sysConstantResp.getConstantName());
+                }
+            }
+        }
+
         return vo;
     }
 
@@ -1197,7 +1215,8 @@ public class ProductServiceImpl implements ProductService, Constant {
 
         if (CollectionUtils.isNotEmpty(navs)) {
             net.setNetDate(navs.get(0).getPriceDate().getTime());
-            net.setNetValue(BigDecimalUtil.toString(navs.get(0).getCumulativeNav(), 4));
+            net.setNetValue(BigDecimalUtil.toString(navs.get(0).getNav(), 4));
+            net.setCumulativeNav(BigDecimalUtil.toString(navs.get(0).getCumulativeNav(), 4));
         }
         return net;
     }
@@ -1353,6 +1372,17 @@ public class ProductServiceImpl implements ProductService, Constant {
                     .netValue(BigDecimalUtil.toString(fundCountList.get(0).getNetNav())).build());
         }
 
+        //子策略名称
+        if (detailResp.getSubstrategy() != null) {
+            CommonResp<List<SysConstantResp>> listCommonResp = this.fatools.queryLabels(SysConstEnums.TAMPSUBSTRATEGY.getConstantGroup());
+            if (listCommonResp.isSuccess()) {
+                SysConstantResp sysConstantResp = listCommonResp.getAttributes().stream().filter(item -> StringUtils.equals(String.valueOf(detailResp.getSubstrategy()), item.getConstantCode())).findFirst().orElse(null);
+                if (sysConstantResp != null) {
+                    detailResp.setStrategyName(sysConstantResp.getConstantName());
+                }
+            }
+        }
+
         return detailResp;
     }
 
-- 
2.18.1