浏览代码

1、bug修复,针对根据行业id查询。

jessie 5 年之前
父节点
当前提交
a06c7a59e0

+ 1 - 1
src/main/java/com/pavis/ai/app/fda/service/HisService.java

@@ -17,7 +17,7 @@ public interface HisService {
      * @param ids
      * @return
      */
-    IndustryDetailsInfo hisFind(List<String> ids);
+    // IndustryDetailsInfo hisFind(List<String> ids);
 
 
 }

+ 1 - 0
src/main/java/com/pavis/ai/app/fda/service/NewsService.java

@@ -49,4 +49,5 @@ public interface NewsService {
      */
     void searchCount(String plateId, String plateName);
 
+    List<NewsList> getNewsByPlateId(String plateId);
 }

+ 89 - 89
src/main/java/com/pavis/ai/app/fda/service/impl/HisServiceImpl.java

@@ -40,95 +40,95 @@ public class HisServiceImpl implements HisService {
     @Autowired
     private NewsService newsService;
 
-    @Override
-    public IndustryDetailsInfo hisFind(List<String> ids) {
-        IndustryDetailsInfo industryDetailsInfo = new IndustryDetailsInfo();
-        List<IndustryDetailsInfo> industryDetailsInfos = new ArrayList<>();
-        for (String id : ids) {
-            // 新闻数据。
-            List<NewsList> newsLists = newsService.newsDetails(SearchInfo.builder().searchParam(id).build());
-            QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
-            industryInfoQueryWrapper.lambda()
-                    .eq(IndustryInfo::getPlateId,id);
-            List<IndustryInfo> industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
-            for (IndustryInfo industryInfo : industryInfos) {
-                QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
-                industryPlateQueryWrapper.lambda()
-                        .eq(IndustryPlate::getPlateId,industryInfo.getPlateId());
-                List<IndustryPlate> industryPlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
-                IndustryDetail industryDetail;
-                List<IndustryDetail> industryDetails = new ArrayList<>();
-                for (IndustryPlate industryPlate : industryPlates) {
-                    // 需要替换成数据库的字段,目前随机生成的。
-                    industryDetail = TestCommon.toInitIndustryDetail(industryPlate.getPlateId(),industryPlate.getPlateDate(),
-                            TestCommon.toInitFloat(),TestCommon.toInitFloat());
-                    industryDetails.add(industryDetail);
-                }
-                industryDetailsInfo = IndustryDetailsInfo.builder()
-                        .actuals(industryDetails)
-                        .news(newsLists)
-                        .tag(true)
-                        .build();
-                industryDetailsInfos.add(industryDetailsInfo);
-            }
-        }
-        return industryDetailsInfo;
-        
-        // IndustryInfo industryInfos = new ArrayList<>();
-        // IndustryInfo industryInfo;
-        // for (String id : ids) {
-        //     QueryWrapper queryWrapper = new QueryWrapper();
-        //     queryWrapper.eq("plate_id",id);
-        //     List<StockInfo> stockInfos = stockInfoMapper.selectList(queryWrapper);
-        //     for (StockInfo stockInfo : stockInfos) {
-        //         industryInfo = new IndustryInfo();
-        //         BeanUtils.copyProperties(stockInfo, industryInfo);
-        //         industryInfo.setClose(Float.valueOf(stockInfo.getClose()));
-        //         industryInfo.setPred(Float.valueOf(stockInfo.getPred()));
-        //         industryInfos.add(industryInfo);
-        //     }
-        //
-        //
-        // }
-        // return industryInfos;
-
-
-        // List<IndustryDetail> industryDetails = new ArrayList<>();
-        // SearchInfo searchInfo = SearchInfo.builder()
-        //         .searchParam(ids.get(0))
-        //         .build();
-        // List<NewsList> newsLists = newsService.newsDetails(searchInfo);
-        // if (ids.size() > 0){
-        //
-        //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-10",
-        //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
-        //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-15",
-        //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
-        //     industryDetails.add(TestCommon.toInitIndustryDetail("BK450","2020-05-15",
-        //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
-        //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0734","2020-04-15",
-        //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
-        //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0471","2020-03-15",
-        //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
-        //     IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
-        //             .actuals(industryDetails)
-        //             .news(newsLists)
-        //             .tag(true)
-        //             .build();
-        //     return industryInfo;
-        // }else {
-        //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-15",
-        //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
-        //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-24",
-        //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
-        //     IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
-        //             .actuals(industryDetails)
-        //             .news(newsLists)
-        //             .tag(true)
-        //             .build();
-        //     return industryInfo;
-        // }
-    }
+    // @Override
+    // public IndustryDetailsInfo hisFind(List<String> ids) {
+    //     IndustryDetailsInfo industryDetailsInfo = new IndustryDetailsInfo();
+    //     List<IndustryDetailsInfo> industryDetailsInfos = new ArrayList<>();
+    //     for (String id : ids) {
+    //         // 新闻数据。
+    //         List<NewsList> newsLists = newsService.newsDetails(SearchInfo.builder().searchParam(id).build());
+    //         QueryWrapper<IndustryInfo> industryInfoQueryWrapper = new QueryWrapper<>();
+    //         industryInfoQueryWrapper.lambda()
+    //                 .eq(IndustryInfo::getPlateId,id);
+    //         List<IndustryInfo> industryInfos = industryInfoMapper.selectList(industryInfoQueryWrapper);
+    //         for (IndustryInfo industryInfo : industryInfos) {
+    //             QueryWrapper<IndustryPlate> industryPlateQueryWrapper = new QueryWrapper<>();
+    //             industryPlateQueryWrapper.lambda()
+    //                     .eq(IndustryPlate::getPlateId,industryInfo.getPlateId());
+    //             List<IndustryPlate> industryPlates = industryPlateMapper.selectList(industryPlateQueryWrapper);
+    //             IndustryDetail industryDetail;
+    //             List<IndustryDetail> industryDetails = new ArrayList<>();
+    //             for (IndustryPlate industryPlate : industryPlates) {
+    //                 // 需要替换成数据库的字段,目前随机生成的。
+    //                 industryDetail = TestCommon.toInitIndustryDetail(industryPlate.getPlateId(),industryPlate.getPlateDate(),
+    //                         TestCommon.toInitFloat(),TestCommon.toInitFloat());
+    //                 industryDetails.add(industryDetail);
+    //             }
+    //             industryDetailsInfo = IndustryDetailsInfo.builder()
+    //                     .actuals(industryDetails)
+    //                     .news(newsLists)
+    //                     .tag(true)
+    //                     .build();
+    //             industryDetailsInfos.add(industryDetailsInfo);
+    //         }
+    //     }
+    //     return industryDetailsInfo;
+    //
+    //     // IndustryInfo industryInfos = new ArrayList<>();
+    //     // IndustryInfo industryInfo;
+    //     // for (String id : ids) {
+    //     //     QueryWrapper queryWrapper = new QueryWrapper();
+    //     //     queryWrapper.eq("plate_id",id);
+    //     //     List<StockInfo> stockInfos = stockInfoMapper.selectList(queryWrapper);
+    //     //     for (StockInfo stockInfo : stockInfos) {
+    //     //         industryInfo = new IndustryInfo();
+    //     //         BeanUtils.copyProperties(stockInfo, industryInfo);
+    //     //         industryInfo.setClose(Float.valueOf(stockInfo.getClose()));
+    //     //         industryInfo.setPred(Float.valueOf(stockInfo.getPred()));
+    //     //         industryInfos.add(industryInfo);
+    //     //     }
+    //     //
+    //     //
+    //     // }
+    //     // return industryInfos;
+    //
+    //
+    //     // List<IndustryDetail> industryDetails = new ArrayList<>();
+    //     // SearchInfo searchInfo = SearchInfo.builder()
+    //     //         .searchParam(ids.get(0))
+    //     //         .build();
+    //     // List<NewsList> newsLists = newsService.newsDetails(searchInfo);
+    //     // if (ids.size() > 0){
+    //     //
+    //     //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-10",
+    //     //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
+    //     //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-15",
+    //     //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
+    //     //     industryDetails.add(TestCommon.toInitIndustryDetail("BK450","2020-05-15",
+    //     //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
+    //     //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0734","2020-04-15",
+    //     //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
+    //     //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0471","2020-03-15",
+    //     //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
+    //     //     IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
+    //     //             .actuals(industryDetails)
+    //     //             .news(newsLists)
+    //     //             .tag(true)
+    //     //             .build();
+    //     //     return industryInfo;
+    //     // }else {
+    //     //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0422","2020-07-15",
+    //     //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
+    //     //     industryDetails.add(TestCommon.toInitIndustryDetail("BK0738","2020-06-24",
+    //     //             TestCommon.toInitFloat(),TestCommon.toInitFloat()));
+    //     //     IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
+    //     //             .actuals(industryDetails)
+    //     //             .news(newsLists)
+    //     //             .tag(true)
+    //     //             .build();
+    //     //     return industryInfo;
+    //     // }
+    // }
 
 
 

+ 33 - 16
src/main/java/com/pavis/ai/app/fda/service/impl/NewsServiceImpl.java

@@ -68,23 +68,10 @@ public class NewsServiceImpl implements NewsService {
         queryWrapper.eq("news_id", searchInfo.getSearchParam());
         queryWrapper.orderByDesc("news_date");
         List<NewsInfo> newsInfos = newsInfoMapper.selectList(queryWrapper);
-
-        List<NewsList> newsLists = new ArrayList<>();
-        NewsList newsList;
-        for (NewsInfo newsInfo : newsInfos) {
-            // NewsDetail newsDetail = JSONObject.parseObject(JSON.toJSONString(find), NewsDetail.class);
-            newsList = new NewsList();
-            BeanUtils.copyProperties(newsInfo, newsList);
-            newsList.setNewsUrl(dealUrl(newsInfo.getNewsUrl()));
-            newsList.setNewsContent(newsInfo.getNewsContent());
-            newsLists.add(newsList);
-        }
-        List<NewsList> newsSortList = newsLists.stream()
-                .sorted(Comparator.comparing(NewsList::getNewsDate).reversed())
-                .collect(Collectors.toList());
-        return newsSortList;
+        return getNesList(newsInfos);
     }
 
+
     @Override
     public List<NewsInfo> createNews(NewsList newsList) {
         NewsInfo newsInfo = toInitNewsInfo(newsList.getNewsId(),newsList.getNewsToEnterpriseId(), JSON.toJSONString(
@@ -156,7 +143,16 @@ public class NewsServiceImpl implements NewsService {
 
     }
 
-
+    @Override
+    public List<NewsList> getNewsByPlateId(String plateId) {
+        // 注意是哪个id
+        QueryWrapper<NewsInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda()
+                .eq(NewsInfo::getNewsToEnterpriseId,plateId)
+                .orderByDesc(NewsInfo::getNewsDate);
+        List<NewsInfo> newsInfos = newsInfoMapper.selectList(queryWrapper);
+        return getNesList(newsInfos);
+    }
 
 
     /**
@@ -205,4 +201,25 @@ public class NewsServiceImpl implements NewsService {
     }
 
 
+    /**
+     * 创建新闻列表。
+     * @param newsInfos
+     * @return
+     */
+    public List<NewsList> getNesList(List<NewsInfo> newsInfos){
+        List<NewsList> newsLists = new ArrayList<>();
+        NewsList newsList;
+        for (NewsInfo newsInfo : newsInfos) {
+            // NewsDetail newsDetail = JSONObject.parseObject(JSON.toJSONString(find), NewsDetail.class);
+            newsList = new NewsList();
+            BeanUtils.copyProperties(newsInfo, newsList);
+            newsList.setNewsUrl(dealUrl(newsInfo.getNewsUrl()));
+            newsList.setNewsContent(newsInfo.getNewsContent());
+            newsLists.add(newsList);
+        }
+        List<NewsList> newsSortList = newsLists.stream()
+                .sorted(Comparator.comparing(NewsList::getNewsDate).reversed())
+                .collect(Collectors.toList());
+        return newsSortList;
+    }
 }

+ 48 - 40
src/main/java/com/pavis/ai/app/fda/service/impl/SearchServiceImpl.java

@@ -114,15 +114,15 @@ public class SearchServiceImpl implements SearchService {
 
     @Override
     public IndustryDetailsInfo hisFind(List<String> ids) {
-        // return toDetailsByPlateId(ids, false);
-        return toFindDetailsByPlateId(ids, false);
+        return toDetailsByPlateId(ids, false);
+        // return toFindDetailsByPlateId(ids, false);
     }
 
 
     @Override
     public IndustryDetailsInfo predictFind(List<String> ids) {
-        // return toDetailsByPlateId(ids, true);
-        return toFindDetailsByPlateId(ids, true);
+        return toDetailsByPlateId(ids, true);
+        // return toFindDetailsByPlateId(ids, true);
 
         // List<IndustryDetail> industryDetails = new ArrayList<>();
         //
@@ -276,7 +276,8 @@ public class SearchServiceImpl implements SearchService {
         SearchInfo searchInfo = SearchInfo.builder()
                 .searchParam(ids.get(0))
                 .build();
-        List<NewsList> newsLists = newsService.newsDetails(searchInfo);
+        // todo 需要修改接口。
+        List<NewsList> newsLists = newsService.getNewsByPlateId(searchInfo.getSearchParam());
 
         IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
                 .actuals(industryDetails)
@@ -802,14 +803,14 @@ public class SearchServiceImpl implements SearchService {
             // 涨幅。
             plateResList = toActualIncOrDec(incOrDec,friday,lastFriday);
             // 3、返回数据创建。
-            List<IncInfo> incInfos = toBackIncInfos(true,false,plateResList);
+            List<IncInfo> incInfos = toBackActualIncInfos(plateResList);
             List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
                     .collect(Collectors.toList());
             return finalIncInfos;
         }else {
             plateResList = toActualIncOrDec(incOrDec,friday,lastFriday);
             // 3、返回数据创建。
-            List<IncInfo> incInfos = toBackIncInfos(false,false,plateResList);
+            List<IncInfo> incInfos = toBackActualIncInfos(plateResList);
             List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
                     .collect(Collectors.toList());
             return finalIncInfos;
@@ -888,64 +889,71 @@ public class SearchServiceImpl implements SearchService {
             // 上周预测。
             Map<String, Object> map = DateUtils.getFridayOrLastFriday(date);
             plates = toPredLastOrNext(incOrDec,map.get("friday").toString(),map.get("lastFriday").toString());
-            if (incOrDec.equals(true)){
-                // 3、创建返回值。
-                List<IncInfo> incInfos = toBackIncInfos(true,true,plates);
-                List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
-                        .collect(Collectors.toList());
-                return finalIncInfos;
-            }else {
-                List<IncInfo> incInfos = toBackIncInfos(false,true,plates);
-                List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
-                        .collect(Collectors.toList());
-                return finalIncInfos;
-            }
 
         }else {
             Map<String, Object> map = DateUtils.getEverydayOfNexWeek(date);
             plates = toPredLastOrNext(incOrDec,map.get("friday").toString(),map.get("nextFriday").toString());
+        }
+        // 3、创建返回值。
+        if (incOrDec.equals(true)){
             // 3、创建返回值。
-            if (incOrDec.equals(true)){
-                // 3、创建返回值。
-                List<IncInfo> incInfos = toBackIncInfos(incOrDec,true,plates);
-                List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
-                        .collect(Collectors.toList());
-                return finalIncInfos;
-            }else {
-                List<IncInfo> incInfos = toBackIncInfos(incOrDec,true,plates);
-                List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
-                        .collect(Collectors.toList());
-                return finalIncInfos;
-            }
-
+            List<IncInfo> incInfos = toBackPredIncInfos(plates);
+            List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() > 0.0F)
+                    .collect(Collectors.toList());
+            return finalIncInfos;
+        }else {
+            List<IncInfo> incInfos = toBackPredIncInfos(plates);
+            List<IncInfo> finalIncInfos = incInfos.stream().filter(s->s.getIndustryValue() < 0.0F)
+                    .collect(Collectors.toList());
+            return finalIncInfos;
         }
     }
 
     /**
-     * 返回信息创建接口。
+     * 返回信息创建实际榜接口。
      // * @param incOrDec 涨幅跌幅
-     * @param actualOrPred 实际or预测
      * @param plates 列表。
      * @return
      */
-    public List<IncInfo> toBackIncInfos(Boolean incOrDec,Boolean actualOrPred,List<IndustryPlateRes> plates){
+    public List<IncInfo> toBackActualIncInfos(List<IndustryPlateRes> plates){
         // 3、返回数据创建。
         IncInfo incInfo;
         List<IncInfo> incInfos = new ArrayList<>();
         for (IndustryPlateRes industryPlateRes : plates) {
             Float actualVal = null != industryPlateRes.getPlateCloseUp() ?
                     industryPlateRes.getPlateCloseUp() : 0.0F;
+            Boolean industryTag = actualVal > 0.0F ? true : false;
+            incInfo = IncInfo.builder()
+                    .industryId(industryPlateRes.getPlateId())
+                    // .industryName(plate.getPlateName())
+                    .industryName(industryPlateRes.getPlateName())
+                    .industryValue(actualVal)
+                    .industryTag(industryTag)
+                    .build();
+            incInfos.add(incInfo);
+        }
+        return incInfos;
+    }
+    /**
+     * 返回信息创建预测榜接口。
+     * @param plates 列表。
+     * @return
+     */
+    public List<IncInfo> toBackPredIncInfos(List<IndustryPlateRes> plates){
+        // 3、返回数据创建。
+        IncInfo incInfo;
+        List<IncInfo> incInfos = new ArrayList<>();
+        for (IndustryPlateRes industryPlateRes : plates) {
             Float predVal = null != industryPlateRes.getPlateClosePredUp() ?
                     industryPlateRes.getPlateClosePredUp() : 0.0F;
-            Float value = actualOrPred.equals(true) ? actualVal : predVal;
-            Boolean industryTag = value > 0.0F ? true : false;
+            Boolean industryTag = predVal > 0.0F ? true : false;
             incInfo = IncInfo.builder()
                     .industryId(industryPlateRes.getPlateId())
                     // .industryName(plate.getPlateName())
                     // todo 后期需要修改。
                     .industryName(industryPlateRes.getPlateName())
-                    .industryValue(value)
-                    .industryTag(incOrDec.equals(true) ? true : false)
+                    .industryValue(predVal)
+                    .industryTag(industryTag)
                     .build();
             incInfos.add(incInfo);
         }
@@ -1257,7 +1265,7 @@ public class SearchServiceImpl implements SearchService {
         SearchInfo searchInfo = SearchInfo.builder()
                 .searchParam(ids.get(0))
                 .build();
-        List<NewsList> newsLists = newsService.newsDetails(searchInfo);
+        List<NewsList> newsLists = newsService.getNewsByPlateId(searchInfo.getSearchParam());
 
         IndustryDetailsInfo industryInfo = IndustryDetailsInfo.builder()
                 .actuals(industryDetails)

+ 2 - 2
src/main/resources/application-dev.yml

@@ -1,7 +1,7 @@
 spring:
   datasource:
-#    url: jdbc:mysql://192.168.1.73/fda_test?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
-    url: jdbc:mysql://192.168.1.73/fda?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
+    url: jdbc:mysql://192.168.1.73/fda_test?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
+#    url: jdbc:mysql://192.168.1.73/fda?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
 #    url: jdbc:mysql://192.168.1.60/fda?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
     driver-class-name: com.mysql.cj.jdbc.Driver
     username: root