Bläddra i källkod

2024-01-05 修改03

luguang 2 veckor sedan
förälder
incheckning
8fc44b2c49
1 ändrade filer med 39 tillägg och 33 borttagningar
  1. 39 33
      src/main/java/com/sy/coinage/workshop/component/ScreenComponent.java

+ 39 - 33
src/main/java/com/sy/coinage/workshop/component/ScreenComponent.java

@@ -223,51 +223,57 @@ public class ScreenComponent {
         List<ScreenWareVO> list = new ArrayList<>();
         // 取手动管理的大屏数据
         List<ScreenWareVO> screenDataList = this.listScreenData();
+        List<String> securities = null;
         if (stockList != null && stockList.size() > 0) {
-            for (Stock stock : stockList) {
+            securities = stockList.stream().map(item -> item.getSecurities()).distinct().collect(Collectors.toList());
+        }
+        if (stockList != null && stockList.size() > 0) {
+            for (String str : securities) {
                 ScreenWareVO vo = new ScreenWareVO();
-                vo.setSecurities(stock.getSecurities());
+                vo.setSecurities(str);
                 vo.setDayInQty(0);
                 vo.setDayOutQty(0);
-                Product p = this.productService.getByCache(stock.getSecuritiesId());
-                vo.setQty((stock.getBoxNum() == null ? 0 : stock.getBoxNum()) + (stock.getRacketNum() == null ? 0 : stock.getRacketNum()) * p.getBoxAmount());
-                if (accountListIn != null && accountListIn.size() > 0) {
-                    Integer totalQty = accountListIn.stream().filter(item -> item.getSecuritiesId().intValue() == stock.getSecuritiesId().intValue()).collect(Collectors.toList()).stream().mapToInt(item -> item.getIncomeQty()).sum();
-                    vo.setDayInQty(totalQty / p.getAmountPerBox());
-                }
-                if (accountListOut != null && accountListOut.size() > 0) {
-                    Integer totalQty = accountListOut.stream().filter(item -> item.getSecuritiesId().intValue() == stock.getSecuritiesId().intValue()).collect(Collectors.toList()).stream().mapToInt(item -> item.getPayQty()).sum();
-                    vo.setDayOutQty(totalQty / p.getAmountPerBox());
-                }
-                if (screenDataList != null && screenDataList.size() > 0) {
-                    for (int i = screenDataList.size() - 1; i >= 0; i--) {
-                        ScreenWareVO screenWareVO = screenDataList.get(i);
-                        if (vo.getSecurities().equals(screenWareVO.getSecurities())) {
-                            vo.setQty(vo.getQty() + (screenWareVO.getQty() == null ? 0 : screenWareVO.getQty()));
-                            vo.setDayInQty(vo.getDayInQty() + (screenWareVO.getDayInQty() == null ? 0 : screenWareVO.getDayInQty()));
-                            vo.setDayOutQty(vo.getDayOutQty() + (screenWareVO.getDayOutQty() == null ? 0 : screenWareVO.getDayOutQty()));
-                            screenDataList.remove(i);
+                for (Stock stock : stockList) {
+                    Product p = this.productService.getByCache(stock.getSecuritiesId());
+                    vo.setQty((stock.getBoxNum() == null ? 0 : stock.getBoxNum()) + (stock.getRacketNum() == null ? 0 : stock.getRacketNum()) * p.getBoxAmount());
+                    if (accountListIn != null && accountListIn.size() > 0) {
+                        Integer totalQty = accountListIn.stream().filter(item -> item.getSecuritiesId().intValue() == stock.getSecuritiesId().intValue()).collect(Collectors.toList()).stream().mapToInt(item -> item.getIncomeQty()).sum();
+                        vo.setDayInQty(totalQty / p.getAmountPerBox());
+                    }
+                    if (accountListOut != null && accountListOut.size() > 0) {
+                        Integer totalQty = accountListOut.stream().filter(item -> item.getSecuritiesId().intValue() == stock.getSecuritiesId().intValue()).collect(Collectors.toList()).stream().mapToInt(item -> item.getPayQty()).sum();
+                        vo.setDayOutQty(totalQty / p.getAmountPerBox());
+                    }
+                    if (screenDataList != null && screenDataList.size() > 0) {
+                        for (int i = screenDataList.size() - 1; i >= 0; i--) {
+                            ScreenWareVO screenWareVO = screenDataList.get(i);
+                            if (vo.getSecurities().equals(screenWareVO.getSecurities())) {
+                                vo.setQty(vo.getQty() + (screenWareVO.getQty() == null ? 0 : screenWareVO.getQty()));
+                                vo.setDayInQty(vo.getDayInQty() + (screenWareVO.getDayInQty() == null ? 0 : screenWareVO.getDayInQty()));
+                                vo.setDayOutQty(vo.getDayOutQty() + (screenWareVO.getDayOutQty() == null ? 0 : screenWareVO.getDayOutQty()));
+                                screenDataList.remove(i);
+                            }
                         }
                     }
-                }
-                if (vo.getQty() + vo.getDayInQty() + vo.getDayOutQty() > 0) {
-                    list.add(vo);
-                }
-            }
-            if (screenDataList != null && screenDataList.size() > 0) {
-                for (int i = screenDataList.size() - 1; i >= 0; i--) {
-                    ScreenWareVO screenWareVO = screenDataList.get(i);
-                    ScreenWareVO vo = new ScreenWareVO();
-                    vo.setSecurities(screenWareVO.getSecurities());
-                    vo.setQty((screenWareVO.getQty() == null ? 0 : screenWareVO.getQty()));
-                    vo.setDayInQty((screenWareVO.getDayInQty() == null ? 0 : screenWareVO.getDayInQty()));
-                    vo.setDayOutQty((screenWareVO.getDayOutQty() == null ? 0 : screenWareVO.getDayOutQty()));
                     if (vo.getQty() + vo.getDayInQty() + vo.getDayOutQty() > 0) {
                         list.add(vo);
                     }
                 }
             }
         }
+        if (screenDataList != null && screenDataList.size() > 0) {
+            for (int i = screenDataList.size() - 1; i >= 0; i--) {
+                ScreenWareVO screenWareVO = screenDataList.get(i);
+                ScreenWareVO vo = new ScreenWareVO();
+                vo.setSecurities(screenWareVO.getSecurities());
+                vo.setQty((screenWareVO.getQty() == null ? 0 : screenWareVO.getQty()));
+                vo.setDayInQty((screenWareVO.getDayInQty() == null ? 0 : screenWareVO.getDayInQty()));
+                vo.setDayOutQty((screenWareVO.getDayOutQty() == null ? 0 : screenWareVO.getDayOutQty()));
+                if (vo.getQty() + vo.getDayInQty() + vo.getDayOutQty() > 0) {
+                    list.add(vo);
+                }
+            }
+        }
         // 取手动管理的大屏数据
 //        List<ScreenWareVO> screenDataList = this.listScreenData();
 //        if (screenDataList != null && screenDataList.size() > 0) {