|
@@ -1159,5 +1159,68 @@ public class GroupRelationController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("成功");
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private final AccountMapper accountMapper;
|
|
|
|
|
|
|
|
|
|
+ private final GroupsMapper groupsMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/excel")
|
|
|
|
|
+ public Result<String> excel(MultipartFile file) throws IOException {
|
|
|
|
|
+ AtomicInteger normal = new AtomicInteger(0);
|
|
|
|
|
+ AtomicInteger abNormal = new AtomicInteger(0);
|
|
|
|
|
+ EasyExcel.read(file.getInputStream(), ExcelAccountStateData.class, new AnalysisEventListener<ExcelAccountStateData>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void invoke(ExcelAccountStateData data, AnalysisContext analysisContext) {
|
|
|
|
|
+ String account = data.getAccount();
|
|
|
|
|
+ String password = data.getPassword();
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isEmpty(account) || StrUtil.isEmpty(password)) {
|
|
|
|
|
+ log.info("账号或密码为空");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer state = accountMapper.isNormal(account);
|
|
|
|
|
+
|
|
|
|
|
+ if (state == null) {
|
|
|
|
|
+ log.info("{}暂无iu同步", account);
|
|
|
|
|
+ groupRelationFrontService.syncExcelAccountState(account, password);
|
|
|
|
|
+ state = accountMapper.isNormal(account);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (state == 1) {
|
|
|
|
|
+ Account dbAccount = accountMapper.selectOne(Wrappers.lambdaQuery(Account.class)
|
|
|
|
|
+ .eq(Account::getAccount, account)
|
|
|
|
|
+ .eq(Account::getGoodsId, 1)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+
|
|
|
|
|
+ if (dbAccount != null) {
|
|
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class)
|
|
|
|
|
+ .eq(GroupsTrips::getAccountId, dbAccount.getId())
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (groupsTrips.getStatus() == GroupsTrips.Status.down) {
|
|
|
|
|
+ log.info("{}是否正常", account);
|
|
|
|
|
+// groupRelationFrontService.syncExcelAccountState(account, password);
|
|
|
|
|
+ state = accountMapper.isNormal(account);
|
|
|
|
|
+ if (state == 1) {
|
|
|
|
|
+ log.info("account:{} 正常", account);
|
|
|
|
|
+ groupsTrips.setStatus(GroupsTrips.Status.validity);
|
|
|
|
|
+ groupsMapper.updateById(groupsTrips);
|
|
|
|
|
+ normal.incrementAndGet();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ abNormal.incrementAndGet();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ abNormal.incrementAndGet();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }).sheet().doRead();
|
|
|
|
|
+ System.out.println("正:" + normal.get());
|
|
|
|
|
+ System.out.println("异常:" + abNormal.get());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("成功");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|