Commit 1aff7e0f authored by vaisakh.nair's avatar vaisakh.nair 🎯

create_report_v3 latest code changes

parent f045dfa4
......@@ -37,7 +37,7 @@ class DailyReportGenerator:
def map_packer_name(self, camera_name):
packer_mapping = {
'jk': 'Packer 1',
'camera_41': 'Packer 1',
'camera_42': 'Packer 2',
'camera_44': 'Packer 4',
'camera_45': 'Packer 5',
......@@ -83,17 +83,17 @@ class DailyReportGenerator:
# Define the shifts and their respective time ranges
shifts = {
'Shift A': (datetime(current_time.year, current_time.month, current_time.day, 6, 0, 0),
datetime(current_time.year, current_time.month, current_time.day, 14, 0, 0)),
'Shift B': (datetime(current_time.year, current_time.month, current_time.day, 14, 0, 0),
datetime(current_time.year, current_time.month, current_time.day, 22, 0, 0)),
'Shift C': (datetime(current_time.year, current_time.month, current_time.day - 1, 22, 0, 0),
'Shift A': (datetime(current_time.year, current_time.month, current_time.day -1 , 6, 0, 0),
datetime(current_time.year, current_time.month, current_time.day -1, 14, 0, 0)),
'Shift B': (datetime(current_time.year, current_time.month, current_time.day -1, 14, 0, 0),
datetime(current_time.year, current_time.month, current_time.day -1, 22, 0, 0)),
'Shift C': (datetime(current_time.year, current_time.month, current_time.day- 1, 22, 0, 0),
datetime(current_time.year, current_time.month, current_time.day, 6, 0, 0))
}
# Start filling details from row 8
row = 7
for camera_name in ['jk', 'camera_42', 'camera_44', 'camera_45', 'camera_46', 'camera_47']:
for camera_name in ['camera_41', 'camera_42', 'camera_44', 'camera_45', 'camera_46', 'camera_47']:
for shift, (start_time, end_time) in shifts.items():
packer_name = self.map_packer_name(camera_name)
count = self.get_count(start_time, end_time, camera_name)
......@@ -115,48 +115,6 @@ class DailyReportGenerator:
file_path = os.path.abspath(report_file)
return file_path
# def create_excel_report(self):
# report_file = 'daily_report.xlsx'
# current_time = datetime.now()
# report_date = current_time.strftime("%Y-%m-%d")
# report_file = f"daily_report_{report_date}.xlsx"
# start_time = datetime(current_time.year, current_time.month, current_time.day - 1, 6, 0, 0)
# end_time = datetime(current_time.year, current_time.month, current_time.day, 23, 59, 0)
# wb = load_workbook(self.template_file)
# sheet = wb.active
# # Set report date
# sheet['L6'] = report_date
# serial_number = 1
# # Start filling details from row 8
# row = 7
# for camera_name in ['jk', 'camera_42', 'camera_44', 'camera_45', 'camera_46', 'camera_47']:
# shift_name = self.get_shift_name(start_time)
# packer_name = self.map_packer_name(camera_name)
# count = self.get_count(start_time, end_time, camera_name)
# # Fill in the data in respective cells
# sheet[f'A{row}'] = serial_number
# sheet[f'B{row}'] = end_time.date()
# sheet[f'C{row}'] = shift_name
# sheet[f'D{row}'] = packer_name
# sheet[f'E{row}'] = count
# row += 1
# serial_number += 1
# # Save the report file
# wb.save(report_file)
# # Return the absolute path of the generated report file
# file_path = os.path.abspath(report_file)
# return file_path
# Create an instance of DailyReportGenerator
report_generator = DailyReportGenerator()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment