diff --git a/arknights_mower/command.py b/arknights_mower/command.py index 41fb2885a..f20db1d2c 100644 --- a/arknights_mower/command.py +++ b/arknights_mower/command.py @@ -2,7 +2,6 @@ from . import __version__ from .solvers import * -from .solvers.report import ReportSolver from .utils import config from .utils.device import Device from .utils.log import logger diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index d39df46ec..598d99c7a 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -13,12 +13,11 @@ from email.mime.multipart import MIMEMultipart from .skland import SKLand -from ..command import recruit, daily_report, mail +from ..command import recruit, mail from ..data import agent_list, base_room_list, ocr_error from ..utils import character_recognize, detector, segment from ..utils.digit_reader import DigitReader from ..utils.operators import Operators, Operator, Dormitory -from ..utils.recruit import filter_result from ..utils.scheduler_task import SchedulerTask, scheduling, find_next_task, TaskTypes from ..utils import typealias as tp from ..utils.device import Device @@ -2267,8 +2266,5 @@ def recruit_plan_solver(self): recruit([], self.send_message_config, self.recruit_config) self.recruit_config['last_execution'] = datetime.now() - def read_report(self): - return daily_report() - def mail_plan_solver(self): mail([]) diff --git a/arknights_mower/solvers/report.py b/arknights_mower/solvers/report.py deleted file mode 100644 index ceea6a33a..000000000 --- a/arknights_mower/solvers/report.py +++ /dev/null @@ -1,171 +0,0 @@ -import csv -import datetime -import os -import re - -import cv2 - -from arknights_mower.utils import rapidocr -from arknights_mower.utils.device import Device -from arknights_mower.utils.image import cropimg -from arknights_mower.utils.log import logger -from arknights_mower.utils.recognize import Recognizer, RecognizeError -from arknights_mower.utils.scene import Scene -from arknights_mower.utils.solver import BaseSolver -from arknights_mower.data import __rootdir__ -from ..utils.path import get_path - - -class ReportSolver(BaseSolver): - def __init__(self, device: Device = None, recog: Recognizer = None) -> None: - super().__init__(device, recog) - self.low_range_blue = (0, 120, 100) - self.high_range_blue = (100, 255, 255) - self.low_range_gray = (100, 100, 100) - self.high_range_gray = (255, 255, 255) - self.record_path = get_path('@app/tmp/record.csv') - # 结算数据 - self.report_res = { - } - self.riic_key_str = { - 'riic_date': "日期", - - 'riic_exp': "作战录像", - 'riic_iron': "生产赤金价值", - 'riic_iron_number': "生产赤金数量", - - 'riic_trade_iron': "贸易站龙门币收入", - 'riic_iron_order': "贸易站赤金订单", - - 'riic_trade_orundum': "贸易站合成玉收入", - 'riic_orundum_order': "贸易站合成玉订单", - } - - - def run(self) -> bool: - if self.is_today_recorded(): - return True - try: - super().run() - return self.record_report() - except TypeError: - logger.error("基报识别失败 润!") - except PermissionError: - logger.error("基报记录访问失败") - return False - - def is_today_recorded(self) -> bool: - if os.path.exists(self.record_path) is not True: - return False - try: - now = datetime.datetime.now() - report_date = now - datetime.timedelta(days=1) - - with open(self.record_path, 'r+') as f: - csv_reader = csv.reader(f) - next(csv_reader) - for line in csv_reader: - if len(line) > 0: - record_date = datetime.datetime.strptime(line[0], "%m.%d") - if record_date.month == report_date.month and record_date.day == report_date.day: - return True - return False - except RuntimeError: - logger.error("查询基建报告记录失败") - - def transition(self) -> bool: - if self.scene() == Scene.INDEX: - self.tap_themed_element('index_infrastructure') - elif self.scene() == Scene.INFRA_MAIN: - self.tap_element('control_central') - elif self.scene() == Scene.CTRLCENTER_ASSISTANT: - self.tap_element('control_central_assistants') - elif self.scene() == Scene.RIIC_REPORT: - self.read_report() - return True - elif self.scene() == Scene.LOADING: - self.sleep(3) - elif self.scene() == Scene.CONNECTING: - self.sleep(3) - elif self.get_navigation(): - self.tap_element('nav_infrastructure') - elif self.scene() != Scene.UNKNOWN: - self.back_to_index() - else: - raise RecognizeError('Unknown scene') - - def read_report(self): - logger.info("读取基建报告") - # 制造作战记录 - threshold_blue = cv2.inRange(self.recog.img, self.low_range_blue, self.high_range_blue) - threshold_gray = cv2.inRange(self.recog.img, self.low_range_gray, self.high_range_gray) - - date_res = rapidocr.engine( - self.recog.img[15:60, 1550:1680], - use_det=False, use_cls=False, use_rec=True)[0][0][0] - self.report_res['riic_date'] = re.sub("\D{2}.\D{2}", "", date_res) - - riic_exp = self.find('riic_exp') - self.report_res['riic_exp'] = rapidocr.engine( - threshold_blue[riic_exp[0][1]:riic_exp[1][1], riic_exp[1][0]:riic_exp[1][0] + 100], - use_det=False, use_cls=False, use_rec=True)[0][0][0] - # 制造赤金 - riic_iron = self.find('riic_lmb') - self.report_res['riic_iron'] = rapidocr.engine( - threshold_blue[riic_iron[0][1]:riic_iron[1][1], riic_iron[1][0]:riic_iron[1][0] + 100], - use_det=False, use_cls=False, use_rec=True)[0][0][0] - - # 贸易赤金 - riic_trade_iron = self.find('riic_lmb_2') - self.report_res['riic_trade_iron'] = rapidocr.engine( - threshold_blue[riic_trade_iron[0][1]:riic_trade_iron[1][1], - riic_trade_iron[1][0]:riic_trade_iron[1][0] + 100], - use_det=False, use_cls=False, use_rec=True)[0][0][0] - - # 贸易站赤金单数 - iron_threshold_gray = threshold_gray[riic_trade_iron[0][1]:riic_trade_iron[1][1], 1810:1860] - iron_padded_img = cv2.resize(iron_threshold_gray, - [iron_threshold_gray.shape[0] * 2, iron_threshold_gray.shape[1] * 2]) - self.report_res['riic_iron_order'] = rapidocr.engine(iron_padded_img, - use_det=False, use_cls=False, use_rec=True)[0][0][0] - - # 贸易站合成玉 - riic_trade_orundum = self.find('riic_orundum') - self.report_res['riic_trade_orundum'] = rapidocr.engine( - threshold_blue[riic_trade_orundum[0][1]:riic_trade_orundum[1][1], - riic_trade_orundum[1][0]:riic_trade_orundum[1][0] + 100], - use_det=False, use_cls=False, - use_rec=True)[0][0][0] - # 贸易站合成玉单数 - orundum_threshold_gray = threshold_gray[riic_trade_orundum[0][1]:riic_trade_orundum[1][1], 1810:1860] - orundum_padded_img = cv2.resize(orundum_threshold_gray, - [orundum_threshold_gray.shape[0] * 2, orundum_threshold_gray.shape[1] * 2]) - self.report_res['riic_orundum_order'] = rapidocr.engine(orundum_padded_img, - use_det=False, use_cls=False, use_rec=True)[0][0][0] - - # 整理数据 - for item in self.report_res: - if self.report_res[item] == 'o' or self.report_res[item] == 'O' or self.report_res[item] == 'Q': - self.report_res[item] = '0' - if item != 'riic_date': - res = re.sub("\D", "", self.report_res[item]) - if str(res).isdigit(): - self.report_res[item] = res - - self.report_res['riic_iron_number'] = int(int(self.report_res['riic_iron']) / 500) - - - def record_report(self): - logger.debug(f"存入数据{self.report_res}") - write_header = True - if os.path.exists(self.record_path): - write_header = False - file = open(self.record_path, 'a+', newline='') - - csv_writer = csv.DictWriter(file, fieldnames=list(self.riic_key_str.keys())) - if write_header: - csv_writer.writerow(self.riic_key_str) - csv_writer.writerow(self.report_res) - file.close() - logger.info("{}的基报记录完成".format(self.report_res['riic_date'])) - return True diff --git a/arknights_mower/utils/recognize.py b/arknights_mower/utils/recognize.py index 78a552ff8..e237c0f0a 100644 --- a/arknights_mower/utils/recognize.py +++ b/arknights_mower/utils/recognize.py @@ -125,8 +125,6 @@ def get_scene(self) -> int: self.scene = Scene.FRIEND_LIST_ON elif self.find('credit_visiting') is not None: self.scene = Scene.FRIEND_VISITING - elif self.find('riic_report_title') is not None: - self.scene = Scene.RIIC_REPORT elif self.find('control_central_assistants') is not None: self.scene = Scene.CTRLCENTER_ASSISTANT elif self.find('infra_overview') is not None: diff --git a/arknights_mower/utils/recruit.py b/arknights_mower/utils/recruit.py deleted file mode 100644 index daa07430a..000000000 --- a/arknights_mower/utils/recruit.py +++ /dev/null @@ -1,37 +0,0 @@ -#!Environment yolov8_Env -# -*- coding: UTF-8 -*- -""" -@Project :arknights-mower -@File :recruit.py -@Author :EightyDollars -@Date :2023/8/13 19:12 -""" -from arknights_mower.utils.log import logger - - -def filter_result(tag_list, result_list, type=0): - """ - temp_list - {"tags": tag, - "level":item['level'], - "opers":item['opers']} - """ - temp_list = [] - for tag in tag_list: - logger.debug(tag) - for result_dict in result_list: - for item in result_dict["result"]: - '''高资''' - if type == 0: - if tag == result_dict['tags'] and item['level'] == result_dict['level']: - temp_list.append(item) - elif type == 1: - if tag == item['tags']: - temp_list.append( - {"tags": tag, - "level": item['level'], - "opers": item['opers']}) - - # 筛选好干员和对应tag存入返回用于后续jinja传输 - # logger.debug(temp_list) - return temp_list diff --git a/arknights_mower/utils/solver.py b/arknights_mower/utils/solver.py index 6b8255912..c373f3f86 100644 --- a/arknights_mower/utils/solver.py +++ b/arknights_mower/utils/solver.py @@ -296,9 +296,6 @@ def back_to_index(self): try: if self.get_navigation(): self.tap_element('nav_index') - elif self.scene() == Scene.RIIC_REPORT: - #self.tap_element('riic_return') - self.tap((130, 60)) elif self.scene() == Scene.CLOSE_MINE: self.tap_element('close_mine') elif self.scene() == Scene.CHECK_IN: