modification of datatime() new added entry created

This commit is contained in:
2025-12-18 10:41:54 +05:30
parent dc7acc7592
commit fe89d5e2eb
22 changed files with 62 additions and 43 deletions

View File

@@ -20,12 +20,13 @@ class FileService:
def allowed_file(self, filename):
return "." in filename and filename.rsplit(".", 1)[1].lower() in Config.ALLOWED_EXTENSIONS
def handle_file_upload(self, file, subcontractor_id, file_type):
# def handle_file_upload(self, file, subcontractor_id, file_type):
def handle_file_upload(self, file, subcontractor_id):
if not subcontractor_id:
return False, "Please select subcontractor."
if not file_type:
return False, "Please select file type."
# if not file_type:
# return False, "Please select file type."
if not file or file.filename == "":
return False, "No file selected."
if not self.allowed_file(file.filename):
@@ -40,36 +41,52 @@ class FileService:
filepath = os.path.join(folder, filename)
file.save(filepath)
print("name::::",filename)
try:
df = pd.read_csv(filepath) if filename.endswith(".csv") else pd.read_excel(filepath)
# df = pd.read_csv(filepath) if filename.endswith(".csv") else pd.read_excel(filepath)
df = pd.read_excel(filepath, sheet_name ="Tr.Ex.", header=0)
df1 = pd.read_excel(filepath, sheet_name="MH Ex.", header=0)
df2 = pd.read_excel(filepath, sheet_name="MH & DC", header=0)
print("\n=== Uploaded File Preview ===")
print(df.head())
print(" file name h:",df)
print("=============================\n")
print(" file name h1:",df1)
# print(df.head())
print("=============================\n")
print(" file name h1:",df2)
self.process_trench_excavation(df,subcontractor_id)
self.process_manhole_excavation(df1,subcontractor_id)
self.process_manhole_domestic_chamber(df2, subcontractor_id)
# Trench Excavation save (subcontractor)
if file_type == "trench_excavation":
return self.process_trench_excavation(df, subcontractor_id)
# Manhole Excavation save (subcontractor)
if file_type == "manhole_excavation":
return self.process_manhole_excavation(df, subcontractor_id)
# Manhole and Domestic Chamber Construction save (subcontractor)
if file_type == "manhole_domestic_chamber":
return self.process_manhole_domestic_chamber(df, subcontractor_id)
# Tr Ex save (client)
if file_type =="tr_ex_client":
return self.client_trench_excavation(df, subcontractor_id)
# df = pd.read_csv(filepath) if filename.endswith(".csv") else pd.read_excel(filepath)
# Mh Ex save (client)
if file_type =="mh_ex_client":
return self.client_manhole_excavation(df, subcontractor_id)
# # Trench Excavation save (subcontractor)
# if file_type == "trench_excavation":
# return self.process_trench_excavation(df, subcontractor_id)
# # Manhole Excavation save (subcontractor)
# if file_type == "manhole_excavation":
# return self.process_manhole_excavation(df, subcontractor_id)
# # Manhole and Domestic Chamber Construction save (subcontractor)
# if file_type == "manhole_domestic_chamber":
# return self.process_manhole_domestic_chamber(df, subcontractor_id)
# # Tr Ex save (client)
# if file_type =="tr_ex_client":
# return self.client_trench_excavation(df, subcontractor_id)
# Mh and Dc save (client)
if file_type == "mh_dc_client":
return self.client_manhole_domestic_chamber(df, subcontractor_id)
# # Mh Ex save (client)
# if file_type =="mh_ex_client":
# return self.client_manhole_excavation(df, subcontractor_id)
# # Mh and Dc save (client)
# if file_type == "mh_dc_client":
# return self.client_manhole_domestic_chamber(df, subcontractor_id)
return True, "File uploaded successfully."