Browse Source

2024-11-05 修改04

luguang 2 weeks ago
parent
commit
e40dfed5ea
1 changed files with 13 additions and 6 deletions
  1. 13 6
      src/main/java/com/sy/coinage/workshop/component/ScreenComponent.java

+ 13 - 6
src/main/java/com/sy/coinage/workshop/component/ScreenComponent.java

@@ -262,13 +262,20 @@ public class ScreenComponent {
             }
         }
         if (screenDataList != null && screenDataList.size() > 0) {
-            for (int i = screenDataList.size() - 1; i >= 0; i--) {
-                ScreenWareVO screenWareVO = screenDataList.get(i);
+            List<String> securities1 = screenDataList.stream().map(item -> item.getSecurities()).distinct().collect(Collectors.toList());
+            for (String str : securities1) {
                 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()));
+                vo.setSecurities(str);
+                vo.setDayInQty(0);
+                vo.setDayOutQty(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()));
+                    }
+                }
                 if (vo.getQty() + vo.getDayInQty() + vo.getDayOutQty() > 0) {
                     list.add(vo);
                 }