Browse Source

recover old related kanbans

sunyj 8 năm trước cách đây
mục cha
commit
5bca4d1366

+ 25 - 0
kanban-console/src/main/java/com/uas/kanban/service/impl/PanelInstanceServiceImpl.java

@@ -424,6 +424,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
         }
         panelInstance.initKanbanCodes(kanbans);
         recoverOldParameterValues(panelInstance, oldPanelInstance);
+        recoverOldKanbans(panelInstance, oldPanelInstance);
         panelInstanceDao.update(panelInstance);
         return getOne(panelInstance.codeNotEmpty());
     }
@@ -511,4 +512,28 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
         panelInstance.toParameters(parameters);
     }
 
+    /**
+     * 恢复旧的看板配置
+     *
+     * @param panelInstance    面板实例
+     * @param oldPanelInstance 旧的面板实例
+     */
+    private void recoverOldKanbans(@NotEmpty("panelInstance") PanelInstance panelInstance, @NotEmpty("oldPanelInstance") PanelInstance oldPanelInstance) {
+        List<PanelInstance.RelatedKanban> relatedKanbans = panelInstance.getRelatedKanbans();
+        List<PanelInstance.RelatedKanban> oldRelatedKanbans = oldPanelInstance.getRelatedKanbans();
+        relatedKanbans = relatedKanbans == null ? new ArrayList<PanelInstance.RelatedKanban>() : relatedKanbans;
+        oldRelatedKanbans = oldRelatedKanbans == null ? new ArrayList<PanelInstance.RelatedKanban>() : oldRelatedKanbans;
+        if (CollectionUtils.isEmpty(relatedKanbans) || CollectionUtils.isEmpty(oldRelatedKanbans)) {
+            return;
+        }
+        for (PanelInstance.RelatedKanban relatedKanban : relatedKanbans) {
+            for (PanelInstance.RelatedKanban oldRelatedKanban : oldRelatedKanbans) {
+                if (Objects.equals(relatedKanban.getCode(), oldRelatedKanban.getCode())) {
+                    relatedKanban.setEnabled(oldRelatedKanban.getEnabled());
+                }
+            }
+        }
+        panelInstance.setRelatedKanbans(relatedKanbans);
+    }
+
 }