Browse Source

更新计划

xueyiming 8 months ago
parent
commit
e355f7ea6e

+ 10 - 8
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/impl/CoreServiceImpl.java

@@ -97,13 +97,6 @@ public class CoreServiceImpl implements CoreService {
                 }
             }
             for (LongArticleSystemPlanAccount account : longArticleSystemPlan.getAccountList()) {
-                PlanAccountExample example = new PlanAccountExample();
-                example.createCriteria().andAccountIdEqualTo(account.getId()).andPlanIdEqualTo(longArticleSystemPlan.getId())
-                        .andCreateTimeGreaterThan(DateUtil.getThatDayDate());
-                long l = planAccountMapper.countByExample(example);
-                if (l > 0) {
-                    continue;
-                }
                 PlanAccount planAccount = new PlanAccount();
                 String accountId = account.getId();
                 planAccount.setPlanId(longArticleSystemPlan.getId());
@@ -132,7 +125,16 @@ public class CoreServiceImpl implements CoreService {
                     planAccount.setSortStrategy(sortStgMap.get(accountId));
                 }
                 planAccount.setPushType(longArticleSystemPlan.getPushType());
-                planAccountMapper.insertSelective(planAccount);
+                PlanAccountExample example = new PlanAccountExample();
+                example.createCriteria().andAccountIdEqualTo(account.getId()).andPlanIdEqualTo(longArticleSystemPlan.getId())
+                        .andCreateTimeGreaterThan(DateUtil.getThatDayDate());
+                List<PlanAccount> planAccounts = planAccountMapper.selectByExample(example);
+                if (CollectionUtils.isEmpty(planAccounts)) {
+                    planAccountMapper.insertSelective(planAccount);
+                } else {
+                    planAccount.setId(planAccounts.get(0).getId());
+                    planAccountMapper.updateByPrimaryKeySelective(planAccount);
+                }
             }
         }
     }