Browse Source

修改例外设置更新

xueyiming 5 months ago
parent
commit
24de76dee0

+ 23 - 61
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java

@@ -231,72 +231,14 @@ public class CoreServiceImpl implements CoreService {
                         planAccountService.saveOrUpdatePlanAccount(planAccount);
                         continue;
                     }
-                    planAccount.setPushType(accountSpecialSettings.getPushType());
-                    if (PublishGzhPushTypeEnum.manual_push.getVal().equals(accountSpecialSettings.getPushType())) {
-                        planAccount.setPublishWindowStart(accountSpecialSettings.getPublishPushTime());
-                        planAccount.setPublishWindowEnd("23:00:00");
-                    } else {
-                        planAccount.setPublishPushTime(accountSpecialSettings.getPublishPushTime());
-                    }
-                    planAccount.setPublishPreNum(accountSpecialSettings.getPublishNum());
-                    planAccount.setPublishNum(accountSpecialSettings.getPublishNum());
-                    int size = 0;
-                    if (StringUtils.isNotEmpty(accountSpecialSettings.getExcludeContentIndex())) {
-                        size = JSONArray.parseArray(accountSpecialSettings.getExcludeContentIndex(), Integer.class).size();
-                    }
-                    if (planAccount.getPublishPreMinNum() > accountSpecialSettings.getPublishNum() - size) {
-                        planAccount.setPublishPreMinNum(accountSpecialSettings.getPublishNum() - size);
-                    }
-                    planAccount.setExcludeContentIndex(accountSpecialSettings.getExcludeContentIndex());
+                    updateAccountSetting(accountSpecialSettings, planAccount);
                     planAccountService.saveOrUpdatePlanAccount(planAccount);
                 }
             } else {
                 if (normalPlanAccounts.size() == 1) {
-                    boolean upadte = false;
                     PlanAccount planAccount = normalPlanAccounts.get(0);
-                    if (!Objects.equals(planAccount.getPushType(), accountSpecialSettings.getPushType())) {
-                        planAccount.setPushType(accountSpecialSettings.getPushType());
-                        upadte = true;
-                    }
-                    if (PublishGzhPushTypeEnum.manual_push.getVal().equals(accountSpecialSettings.getPushType())) {
-                        if (!Objects.equals(planAccount.getPublishWindowStart(), accountSpecialSettings.getPublishPushTime())) {
-                            planAccount.setPublishWindowStart(accountSpecialSettings.getPublishPushTime());
-                            upadte = true;
-                        }
-                        String endTime = "23:00:00";
-                        if (!Objects.equals(planAccount.getPublishWindowEnd(), endTime)) {
-                            planAccount.setPublishWindowEnd(endTime);
-                            upadte = true;
-                        }
-                    } else {
-                        if (!Objects.equals(planAccount.getPublishPushTime(), accountSpecialSettings.getPublishPushTime())) {
-                            planAccount.setPublishPushTime(accountSpecialSettings.getPublishPushTime());
-                            upadte = true;
-                        }
-                    }
-                    if (!Objects.equals(planAccount.getPublishNum(), accountSpecialSettings.getPublishNum())) {
-                        planAccount.setPublishNum(accountSpecialSettings.getPublishNum());
-                        upadte = true;
-                    }
-                    if (!Objects.equals(planAccount.getPublishPreNum(), accountSpecialSettings.getPublishNum())) {
-                        planAccount.setPublishPreNum(accountSpecialSettings.getPublishNum());
-                        upadte = true;
-                    }
-                    int size = 0;
-                    if (StringUtils.isNotEmpty(accountSpecialSettings.getExcludeContentIndex())) {
-                        size = JSONArray.parseArray(accountSpecialSettings.getExcludeContentIndex(), Integer.class).size();
-                    }
-                    if (planAccount.getPublishPreMinNum() > accountSpecialSettings.getPublishNum() - size) {
-                        planAccount.setPublishPreMinNum(accountSpecialSettings.getPublishNum() - size);
-                        upadte = true;
-                    }
-                    if (!Objects.equals(planAccount.getExcludeContentIndex(), accountSpecialSettings.getExcludeContentIndex())) {
-                        planAccount.setExcludeContentIndex(accountSpecialSettings.getExcludeContentIndex());
-                        upadte = true;
-                    }
-                    if (upadte) {
-                        planAccountService.saveOrUpdatePlanAccount(planAccount);
-                    }
+                    updateAccountSetting(accountSpecialSettings, planAccount);
+                    planAccountService.saveOrUpdatePlanAccount(planAccount);
                 } else {
                     LarkRobotUtil.sendMessage("存在多个例外计划,accountId=" + accountId);
                     for (PlanAccount planAccount : planAccounts) {
@@ -308,6 +250,26 @@ public class CoreServiceImpl implements CoreService {
         }
     }
 
+    private void updateAccountSetting(AccountSpecialSettings accountSpecialSettings, PlanAccount planAccount) {
+        planAccount.setPushType(accountSpecialSettings.getPushType());
+        if (PublishGzhPushTypeEnum.manual_push.getVal().equals(accountSpecialSettings.getPushType())) {
+            planAccount.setPublishWindowStart(accountSpecialSettings.getPublishPushTime());
+            planAccount.setPublishWindowEnd("23:00:00");
+        } else {
+            planAccount.setPublishPushTime(accountSpecialSettings.getPublishPushTime());
+        }
+        planAccount.setPublishPreNum(accountSpecialSettings.getPublishNum());
+        planAccount.setPublishNum(accountSpecialSettings.getPublishNum());
+        int size = 0;
+        if (StringUtils.isNotEmpty(accountSpecialSettings.getExcludeContentIndex())) {
+            size = JSONArray.parseArray(accountSpecialSettings.getExcludeContentIndex(), Integer.class).size();
+        }
+        if (planAccount.getPublishPreMinNum() > accountSpecialSettings.getPublishNum() - size) {
+            planAccount.setPublishPreMinNum(accountSpecialSettings.getPublishNum() - size);
+        }
+        planAccount.setExcludeContentIndex(accountSpecialSettings.getExcludeContentIndex());
+    }
+
 
     private Plan createPlan(LongArticleSystemPlan longArticleSystemPlan) {
         Plan plan = new Plan();