|
@@ -284,67 +284,68 @@ public class KuaiShouAccountCleanServiceImpl implements KuaiShouAccountCleanServ
|
|
|
List<KuaiShouAccountCleanTemplateInfo> templateListBystatus = kuaishouAccountCleanTemplateMapper.getTemplateListBystatus();
|
|
|
if (!templateListBystatus.isEmpty()) {
|
|
|
templateListBystatus.stream().forEach(ob -> {
|
|
|
- //获取各项优化目标
|
|
|
- List<String> optimizationObjectiveList = Arrays.asList(ob.getOptimizationObjective().split(";"));
|
|
|
- //获取清理时间范围
|
|
|
- String cleanTime = ob.getCleanTime();
|
|
|
- //计算最早清理时间
|
|
|
- Calendar calendar = Calendar.getInstance();//此时打印它获取的是系统当前时间
|
|
|
- calendar.add(Calendar.DATE, -Integer.parseInt(cleanTime));
|
|
|
- String startDate = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
|
|
|
- //查询符合模板规则的组
|
|
|
- List<String> groupMessage = kuaishouAccountCleanTemplateMapper.getGroupMessage(ob, optimizationObjectiveList, startDate);
|
|
|
- AtomicReference<Boolean> falg = new AtomicReference<>(true);
|
|
|
- if (!groupMessage.isEmpty()) {
|
|
|
- //获取Token
|
|
|
- CtopOauthToken ctopOauthToken = ctopOauthTokenMapper.selectByAccountId(Long.parseLong(ob.getAccountId()));
|
|
|
- if (ctopOauthToken != null) {
|
|
|
- groupMessage.stream().forEach(item -> {
|
|
|
- //修改广告组状态
|
|
|
- Map<String, Object> resultMap = iKuaiShouUpdateService.updateUnitStatus(ctopOauthToken.getAccessToken(), Long.parseLong(ob.getAccountId()), Long.parseLong(item), Integer.parseInt(ob.getPerformOperations()), null);
|
|
|
- Boolean resultFlag = (Boolean) resultMap.get("success");
|
|
|
- //判断有没有失败
|
|
|
- if (!resultFlag) {
|
|
|
- falg.set(false);
|
|
|
- }
|
|
|
- });
|
|
|
+ if(!ob.getAccountId().isEmpty()){
|
|
|
+ //获取各项优化目标
|
|
|
+ List<String> optimizationObjectiveList = Arrays.asList(ob.getOptimizationObjective().split(";"));
|
|
|
+ //获取清理时间范围
|
|
|
+ String cleanTime = ob.getCleanTime();
|
|
|
+ //计算最早清理时间
|
|
|
+ Calendar calendar = Calendar.getInstance();//此时打印它获取的是系统当前时间
|
|
|
+ calendar.add(Calendar.DATE, -Integer.parseInt(cleanTime));
|
|
|
+ String startDate = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
|
|
|
+ //查询符合模板规则的组
|
|
|
+ List<String> groupMessage = kuaishouAccountCleanTemplateMapper.getGroupMessage(ob, optimizationObjectiveList, startDate);
|
|
|
+ AtomicReference<Boolean> falg = new AtomicReference<>(true);
|
|
|
+ if (!groupMessage.isEmpty()) {
|
|
|
+ //获取Token
|
|
|
+ CtopOauthToken ctopOauthToken = ctopOauthTokenMapper.selectByAccountId(Long.parseLong(ob.getAccountId()));
|
|
|
+ if (ctopOauthToken != null) {
|
|
|
+ groupMessage.stream().forEach(item -> {
|
|
|
+ //修改广告组状态
|
|
|
+ Map<String, Object> resultMap = iKuaiShouUpdateService.updateUnitStatus(ctopOauthToken.getAccessToken(), Long.parseLong(ob.getAccountId()), Long.parseLong(item), Integer.parseInt(ob.getPerformOperations()), null);
|
|
|
+ Boolean resultFlag = (Boolean) resultMap.get("success");
|
|
|
+ //判断有没有失败
|
|
|
+ if (!resultFlag) {
|
|
|
+ falg.set(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (!groupMessage.isEmpty() && falg.get()) {
|
|
|
- //修改成功插入日志记录
|
|
|
- KuaiShouAccountCleanLogInfo kuaiShouAccountCleanLogInfo = new KuaiShouAccountCleanLogInfo();
|
|
|
- //设置账户id
|
|
|
- kuaiShouAccountCleanLogInfo.setAccountId(ob.getAccountId());
|
|
|
- // 1-投放、2-暂停、3-删除
|
|
|
- kuaiShouAccountCleanLogInfo.setOperationType(ob.getPerformOperations());
|
|
|
- //设置运营
|
|
|
- Map<String, String> map = kuaishouAccountCleanTemplateMapper.getUserNameByAccountId(ob.getAccountId());
|
|
|
- String authName = "";
|
|
|
- if (map != null) {
|
|
|
- kuaiShouAccountCleanLogInfo.setUserName(map.get("userName"));
|
|
|
- authName = map.get("authName");
|
|
|
- }
|
|
|
- //设置时间
|
|
|
- kuaiShouAccountCleanLogInfo.setCreateTime(sd.format(new Date()));
|
|
|
- StringBuilder unitIds = new StringBuilder();
|
|
|
- groupMessage.stream().forEach(unid -> {
|
|
|
- unitIds.append(unid).append(",");
|
|
|
- });
|
|
|
- //操作类型
|
|
|
- String operationType = null;
|
|
|
- if (ob.getPerformOperations().equals("2")) {
|
|
|
- operationType = "暂停";
|
|
|
- }
|
|
|
- if (ob.getPerformOperations().equals("3")) {
|
|
|
- operationType = "删除";
|
|
|
+ if (!groupMessage.isEmpty() && falg.get()) {
|
|
|
+ //修改成功插入日志记录
|
|
|
+ KuaiShouAccountCleanLogInfo kuaiShouAccountCleanLogInfo = new KuaiShouAccountCleanLogInfo();
|
|
|
+ //设置账户id
|
|
|
+ kuaiShouAccountCleanLogInfo.setAccountId(ob.getAccountId());
|
|
|
+ // 1-投放、2-暂停、3-删除
|
|
|
+ kuaiShouAccountCleanLogInfo.setOperationType(ob.getPerformOperations());
|
|
|
+ //设置运营
|
|
|
+ Map<String, String> map = kuaishouAccountCleanTemplateMapper.getUserNameByAccountId(ob.getAccountId());
|
|
|
+ String authName = "";
|
|
|
+ if (map != null) {
|
|
|
+ kuaiShouAccountCleanLogInfo.setUserName(map.get("userName"));
|
|
|
+ authName = map.get("authName");
|
|
|
+ }
|
|
|
+ //设置时间
|
|
|
+ kuaiShouAccountCleanLogInfo.setCreateTime(sd.format(new Date()));
|
|
|
+ StringBuilder unitIds = new StringBuilder();
|
|
|
+ groupMessage.stream().forEach(unid -> {
|
|
|
+ unitIds.append(unid).append(",");
|
|
|
+ });
|
|
|
+ //操作类型
|
|
|
+ String operationType = null;
|
|
|
+ if (ob.getPerformOperations().equals("2")) {
|
|
|
+ operationType = "暂停";
|
|
|
+ }
|
|
|
+ if (ob.getPerformOperations().equals("3")) {
|
|
|
+ operationType = "删除";
|
|
|
+ }
|
|
|
+ //执行信息
|
|
|
+ String textMessage = "清理规则执行: 账户:" + ob.getAccountId() + ", 授权名称: " + authName + ",推广组:" + unitIds + "已经被清理规则" + operationType;
|
|
|
+ kuaiShouAccountCleanLogInfo.setExecutiveInformation(textMessage);
|
|
|
+ kuaishouAccountCleanTemplateMapper.saveCleamLog(kuaiShouAccountCleanLogInfo);
|
|
|
}
|
|
|
- //执行信息
|
|
|
- String textMessage = "清理规则执行: 账户:" + ob.getAccountId() + ", 授权名称: " + authName + ",推广组:" + unitIds + "已经被清理规则" + operationType;
|
|
|
- kuaiShouAccountCleanLogInfo.setExecutiveInformation(textMessage);
|
|
|
- kuaishouAccountCleanTemplateMapper.saveCleamLog(kuaiShouAccountCleanLogInfo);
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|