Browse Source

除去yinhe.ac 奈飞账号 同步奈飞账号状态

zoujiajian 1 year ago
parent
commit
0770666eb8

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/AccountMapper.java

@@ -36,4 +36,6 @@ public interface AccountMapper extends BaseMapper<Account> {
 	List<Account> selectYinhelxComAccount();
 
 	List<Account> selectAccountDonw();
+
+	List<Account> selectAc();
 }

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/AccountNetflixState.java

@@ -20,4 +20,9 @@ public class AccountNetflixState extends BaseEntity{
 
 	//0正在执行中 1是账号正常 2是登录失败 3是被封号
 	private Integer state;
+
+	/**
+	 * 备注
+	 */
+	private String remark;
 }

+ 11 - 0
netflix-dao/src/main/resources/mapper/AccountMapper.xml

@@ -227,4 +227,15 @@
           and gt.status = 'down'
           and not exists(select 1 from account_netflix_state ans where ans.account = a.account and ans.state = 3)
     </select>
+
+    <select id="selectAc" resultType="com.cyksj.model.entity.Account">
+        select *
+        from account
+        where goods_id = 1
+          and a.account not like '%yinhe.ac.cn'
+          and not exists(select 1
+                         from account_netflix_state ans
+                         where ans.account = a.account
+                           and ans.created_time > '2024-11-28 14:22:00')
+    </select>
 </mapper>

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/mange/AccountCommonService.java

@@ -10,4 +10,6 @@ public interface AccountCommonService {
 	Boolean checkIsDupAccount(Long goodsId, String account);
 
 	void syncDonwNF();
+
+	void syncAc();
 }

+ 45 - 0
netflix-service/src/main/java/com/cyksj/service/mange/account/AccountCommonServiceImpl.java

@@ -90,4 +90,49 @@ public class AccountCommonServiceImpl implements AccountCommonService {
 			}
 		});
 	}
+
+	/**
+	 * 除去yinhe.ac 奈飞账号 同步奈飞账号状态
+	 */
+	@Override
+	public void syncAc() {
+		List<Account> accounts = accountMapper.selectAc();
+		if (CollUtil.isEmpty(accounts)) {
+			throw BusinessRuntimeException.getInstance("已同步完成");
+		}
+		accounts.forEach(account -> {
+			try {
+				AccountNetflixState exist = accountNetflixStateMapper.selectOne(Wrappers.lambdaQuery(AccountNetflixState.class)
+						.eq(AccountNetflixState::getAccount, account.getAccount())
+						.lt(AccountNetflixState::getCreatedTime, DateUtil.parse("2024-11-28 14:22:00"))
+						.last("limit 1"));
+				if (exist != null) {
+					accountNetflixStateMapper.deleteById(exist.getId());
+				}
+				String taskId = groupsRelationNetflixService.createNetflixAccountStatusTask(account);
+				log.info("任务taskId:{}", taskId);
+				AccountNetflixState accountNetflixState = new AccountNetflixState();
+				accountNetflixState.setAccount(account.getAccount());
+				accountNetflixState.setPassword(account.getPassword());
+				accountNetflixState.setState(0);
+				accountNetflixState.setTaskId(taskId);
+				accountNetflixState.setRemark("28号");
+				accountNetflixStateMapper.insert(accountNetflixState);
+
+				Integer status = groupsRelationNetflixService.checkNetflixAccountState(accountNetflixState);
+				while (status == 0) {
+					Thread.sleep(2000);
+					try {
+						status = groupsRelationNetflixService.checkNetflixAccountState(accountNetflixState);
+					} catch (Exception e) {
+						break;
+					}
+				}
+				accountNetflixState.setState(status);
+				accountNetflixStateMapper.updateById(accountNetflixState);
+			} catch (Exception e) {
+				log.error("创建检测奈飞账号状态任务失败:{}", StringUtil.getErrorText(e));
+			}
+		});
+	}
 }

+ 9 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/AccountTempController.java

@@ -593,4 +593,13 @@ public class AccountTempController {
 		accountCommonService.syncDonwNF();
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
+
+	/**
+	 * 除去yinhe.ac 奈飞账号 同步奈飞账号状态
+	 */
+	@GetMapping("/sync/nf/a")
+	public Result<String> syncAc() {
+		accountCommonService.syncAc();
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
 }