diff --git a/app/__pycache__/__init__.cpython-313.pyc b/app/__pycache__/__init__.cpython-313.pyc index 8433b70..db0426a 100644 Binary files a/app/__pycache__/__init__.cpython-313.pyc and b/app/__pycache__/__init__.cpython-313.pyc differ diff --git a/app/models/__pycache__/manhole_domestic_chamber_model.cpython-313.pyc b/app/models/__pycache__/manhole_domestic_chamber_model.cpython-313.pyc index 9229432..de81f18 100644 Binary files a/app/models/__pycache__/manhole_domestic_chamber_model.cpython-313.pyc and b/app/models/__pycache__/manhole_domestic_chamber_model.cpython-313.pyc differ diff --git a/app/models/__pycache__/manhole_excavation_model.cpython-313.pyc b/app/models/__pycache__/manhole_excavation_model.cpython-313.pyc index fcfaf27..7166b84 100644 Binary files a/app/models/__pycache__/manhole_excavation_model.cpython-313.pyc and b/app/models/__pycache__/manhole_excavation_model.cpython-313.pyc differ diff --git a/app/models/__pycache__/mh_dc_client_model.cpython-313.pyc b/app/models/__pycache__/mh_dc_client_model.cpython-313.pyc index 6559105..a8b983c 100644 Binary files a/app/models/__pycache__/mh_dc_client_model.cpython-313.pyc and b/app/models/__pycache__/mh_dc_client_model.cpython-313.pyc differ diff --git a/app/models/__pycache__/mh_ex_client_model.cpython-313.pyc b/app/models/__pycache__/mh_ex_client_model.cpython-313.pyc index 1ea928a..f3f6da3 100644 Binary files a/app/models/__pycache__/mh_ex_client_model.cpython-313.pyc and b/app/models/__pycache__/mh_ex_client_model.cpython-313.pyc differ diff --git a/app/models/__pycache__/subcontractor_model.cpython-313.pyc b/app/models/__pycache__/subcontractor_model.cpython-313.pyc index 12ec43f..a27c0c1 100644 Binary files a/app/models/__pycache__/subcontractor_model.cpython-313.pyc and b/app/models/__pycache__/subcontractor_model.cpython-313.pyc differ diff --git a/app/models/__pycache__/tr_ex_client_model.cpython-313.pyc b/app/models/__pycache__/tr_ex_client_model.cpython-313.pyc index 741f451..4f26f93 100644 Binary files a/app/models/__pycache__/tr_ex_client_model.cpython-313.pyc and b/app/models/__pycache__/tr_ex_client_model.cpython-313.pyc differ diff --git a/app/models/__pycache__/trench_excavation_model.cpython-313.pyc b/app/models/__pycache__/trench_excavation_model.cpython-313.pyc index 35e6b01..ffaab80 100644 Binary files a/app/models/__pycache__/trench_excavation_model.cpython-313.pyc and b/app/models/__pycache__/trench_excavation_model.cpython-313.pyc differ diff --git a/app/models/manhole_domestic_chamber_model.py b/app/models/manhole_domestic_chamber_model.py index f5ce492..e84526a 100644 --- a/app/models/manhole_domestic_chamber_model.py +++ b/app/models/manhole_domestic_chamber_model.py @@ -39,7 +39,7 @@ class ManholeDomesticChamber(db.Model): Domestic_Chambers = db.Column(db.Float) - created_at = db.Column(db.DateTime, default=datetime.utcnow) + created_at = db.Column(db.DateTime, default=datetime.today) def __repr__(self): return f"" diff --git a/app/models/manhole_excavation_model.py b/app/models/manhole_excavation_model.py index 7bd6c1d..f096b15 100644 --- a/app/models/manhole_excavation_model.py +++ b/app/models/manhole_excavation_model.py @@ -57,7 +57,7 @@ class ManholeExcavation(db.Model): Remarks = db.Column(db.String(500)) Total = db.Column(db.Float) - created_at = db.Column(db.DateTime, default=datetime.utcnow) + created_at = db.Column(db.DateTime, default=datetime.today) def __repr__(self): return f"" diff --git a/app/models/mh_dc_client_model.py b/app/models/mh_dc_client_model.py index 7ad73d1..63fcc4d 100644 --- a/app/models/mh_dc_client_model.py +++ b/app/models/mh_dc_client_model.py @@ -35,7 +35,7 @@ class ManholeDomesticChamberClient(db.Model): Domestic_Chambers = db.Column(db.Float) - created_at = db.Column(db.DateTime, default=datetime.utcnow) + created_at = db.Column(db.DateTime, default=datetime.today) def __repr__(self): return f"" diff --git a/app/models/mh_ex_client_model.py b/app/models/mh_ex_client_model.py index 84d3fd6..a67f5c0 100644 --- a/app/models/mh_ex_client_model.py +++ b/app/models/mh_ex_client_model.py @@ -73,7 +73,7 @@ class ManholeExcavationClient(db.Model): Remarks = db.Column(db.String(500)) Total = db.Column(db.Float) - created_at = db.Column(db.DateTime, default=datetime.utcnow) + created_at = db.Column(db.DateTime, default=datetime.today) def __repr__(self): return f"" diff --git a/app/models/subcontractor_model.py b/app/models/subcontractor_model.py index 598e274..22aed97 100644 --- a/app/models/subcontractor_model.py +++ b/app/models/subcontractor_model.py @@ -14,7 +14,7 @@ class Subcontractor(db.Model): email_id = db.Column(db.String(150)) contact_person = db.Column(db.String(150)) status = db.Column(db.String(20), default="Active") - created_at = db.Column(db.DateTime, default=datetime.utcnow) + created_at = db.Column(db.DateTime, default=datetime.today) def __repr__(self): return f"" diff --git a/app/models/tr_ex_client_model.py b/app/models/tr_ex_client_model.py index 6438a0b..ae79d7f 100644 --- a/app/models/tr_ex_client_model.py +++ b/app/models/tr_ex_client_model.py @@ -78,7 +78,7 @@ class TrenchExcavationClient(db.Model): Remarks = db.Column(db.String(500)) Total = db.Column(db.Float) - created_at = db.Column(db.DateTime, default=datetime.utcnow) + created_at = db.Column(db.DateTime, default=datetime.today) def __repr__(self): return f"" diff --git a/app/models/trench_excavation_model.py b/app/models/trench_excavation_model.py index c8de958..1c98d57 100644 --- a/app/models/trench_excavation_model.py +++ b/app/models/trench_excavation_model.py @@ -68,7 +68,7 @@ class TrenchExcavation(db.Model): Remarks = db.Column(db.String(500)) Total = db.Column(db.Float) - created_at = db.Column(db.DateTime, default=datetime.utcnow) + created_at = db.Column(db.DateTime, default=datetime.today) def __repr__(self): return f"" diff --git a/app/routes/__pycache__/file_import.cpython-313.pyc b/app/routes/__pycache__/file_import.cpython-313.pyc index 433feb3..d7c6bae 100644 Binary files a/app/routes/__pycache__/file_import.cpython-313.pyc and b/app/routes/__pycache__/file_import.cpython-313.pyc differ diff --git a/app/routes/__pycache__/generate_comparison_report.cpython-313.pyc b/app/routes/__pycache__/generate_comparison_report.cpython-313.pyc index 28093d3..4353aa1 100644 Binary files a/app/routes/__pycache__/generate_comparison_report.cpython-313.pyc and b/app/routes/__pycache__/generate_comparison_report.cpython-313.pyc differ diff --git a/app/routes/file_import.py b/app/routes/file_import.py index e85809e..85ffddf 100644 --- a/app/routes/file_import.py +++ b/app/routes/file_import.py @@ -4,6 +4,7 @@ from app.models.subcontractor_model import Subcontractor file_import_bp = Blueprint("file_import", __name__, url_prefix="/file") +# this route import Subcontractor files @file_import_bp.route("/import", methods=["GET", "POST"]) def import_file(): subcontractors = Subcontractor.query.all() @@ -11,16 +12,18 @@ def import_file(): if request.method == "POST": file = request.files.get("file") subcontractor_id = request.form.get("subcontractor_id") - file_type = request.form.get("file_type") + # file_type = request.form.get("file_type") service = FileService() - success, msg = service.handle_file_upload(file, subcontractor_id, file_type) + # success, msg = service.handle_file_upload(file, subcontractor_id, file_type) + success, msg = service.handle_file_upload(file, subcontractor_id) flash(msg, "success" if success else "danger") return render_template("file_import.html", title="Sub-cont. File Import", subcontractors=subcontractors) +# this route import client files @file_import_bp.route("/import_client", methods=["GET", "POST"]) def client_import_file(): subcontractors = Subcontractor.query.all() diff --git a/app/routes/generate_comparison_report.py b/app/routes/generate_comparison_report.py index 5990800..d29eb30 100644 --- a/app/routes/generate_comparison_report.py +++ b/app/routes/generate_comparison_report.py @@ -1,6 +1,10 @@ from flask import Blueprint, render_template, request, send_file, flash +from app import db +import pandas as pd +import io from app.models.subcontractor_model import Subcontractor + from app.models.trench_excavation_model import TrenchExcavation from app.models.tr_ex_client_model import TrenchExcavationClient from app.models.manhole_excavation_model import ManholeExcavation @@ -8,11 +12,6 @@ from app.models.mh_ex_client_model import ManholeExcavationClient from app.models.manhole_domestic_chamber_model import ManholeDomesticChamber from app.models.mh_dc_client_model import ManholeDomesticChamberClient -from app import db - -import pandas as pd -import io - generate_report_bp = Blueprint("generate_report", __name__, url_prefix="/report") diff --git a/app/services/__pycache__/file_service.cpython-313.pyc b/app/services/__pycache__/file_service.cpython-313.pyc index a478f17..24ad08c 100644 Binary files a/app/services/__pycache__/file_service.cpython-313.pyc and b/app/services/__pycache__/file_service.cpython-313.pyc differ diff --git a/app/services/file_service.py b/app/services/file_service.py index 628e205..c7192fd 100644 --- a/app/services/file_service.py +++ b/app/services/file_service.py @@ -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." diff --git a/app/templates/file_import.html b/app/templates/file_import.html index e6bfbda..71556d0 100644 --- a/app/templates/file_import.html +++ b/app/templates/file_import.html @@ -18,7 +18,7 @@ - + @@ -36,4 +36,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %}