2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[業務効率] 💥案件の進捗をカウントしたい💥

Last updated at Posted at 2024-09-08

ちょこっと業務を簡略化したい

 この記事では、ちょこっと効率化させたいことをプログラミングやツールをつかって解決していきます
ちょこっと削減した時間を、もっと人生楽しくなることに使いましょう!

本日のお題

💥案件の進捗をカウントしたい💥

🧔 BOSS「案件の進捗状況の報告書作成してほしい」
↑こんな場面ないでしょうか? 

社内システムにデータがある場合、各システムによって違いはありますが、こんなシステム使っているところありますでしょうか?
1案件ごとファイルにまとめられているので集計するために、「ファイル開く→案件数や完了数、案件の差し戻し回数、リジェクトした数をカウント→集計→表にする」を何回も繰り返す。
10件ぐらいなら1件1件手作業で確認できますが、100 件、200件あった場合 それだけで業務終わりますよね。

pythonデスクトップアプリで解決してみた

 WEBアプリのインストール、作成も社内規定でできない、スクレイピングも禁止されている環境を想定して作りました。
その場合、デスクトップで完結するtkinterを使って作る方法がおすすめです。

※デスクトップイメージ図
"cases", "return", "reject", "completion", "other" を選択して「+」「-」を押せば、カウントできます。

image.png

※「データ保存」後の df

スクリーンショット 2024-09-08 23.45.17.png

VScodeでtkinter(python)共有コード

test.py
    import tkinter as tk
    import pandas as pd

    class CounterApp:
    def __init__(self, root):
        self.root = root
        self.root.title("カウントボタンアプリ")

        # ボタンのカウントを保存するリスト
        self.counts = [0] * 5
        self.selected_index = 0

        # カウント表示ラベル
        self.count_label = tk.Label(root, text="")
        self.count_label.grid(row=0, column=0, columnspan=5, padx=5, pady=5)

        # 増加ボタン
        self.inc_btn = tk.Button(root, text="", command=self.increment)
        self.inc_btn.grid(row=1, column=0, padx=5, pady=5)

        # 減少ボタン
        self.dec_btn = tk.Button(root, text="", command=self.decrement)
        self.dec_btn.grid(row=1, column=1, padx=5, pady=5)

        # ボタン選択用のラベル
        tk.Label(root, text="選択するカウント:").grid(row=2, column=0, padx=5, pady=5)

        # ボタン選択用のボタンを作成(ラベルを変更)
        self.select_buttons = []
        labels = ["cases", "return", "reject", "completion", "other"]
        for i, label in enumerate(labels):
            btn = tk.Button(root, text=label, command=lambda i=i: self.select_index(i))
            btn.grid(row=3, column=i, padx=5, pady=5)
            self.select_buttons.append(btn)

        # 保存ボタン
        self.save_btn = tk.Button(root, text="データ保存", command=self.save_data)
        self.save_btn.grid(row=4, column=0, columnspan=5, padx=5, pady=5)

        # ウィジェットの列幅を自動調整する
        root.grid_columnconfigure(1, weight=1)

        # 初期状態としてカウント表示を更新
        self.update_label()

    def increment(self):
        # 現在選択されているカウントを増加させる
        self.counts[self.selected_index] += 1
        self.update_label()

    def decrement(self):
        # 現在選択されているカウントを減少させる
        self.counts[self.selected_index] -= 1
        self.update_label()

    def select_index(self, index):
        # ボタンで選択されたカウントを表示
        self.selected_index = index
        self.update_label()

    def update_label(self):
        # カウント表示ラベルを更新する
        self.count_label.config(text=f"カウント ({self.select_buttons[self.selected_index].cget('text')}): {self.counts[self.selected_index]}")

    def save_data(self):
        # データフレームを作成し、コンソールに表示する
        df = pd.DataFrame({
            'カウントラベル': [btn.cget('text') for btn in self.select_buttons],
            'カウント値': self.counts
        })
        print(df)  # コンソールにデータフレームを表示
        # データフレームをCSVファイルとして保存したい場合は、以下のコメントを外してファイルパスを指定してください
        # df.to_csv('count_data.csv', index=False)

        # データ保存後にすべてをリセットする
        self.reset_all()

    def reset_all(self):
        # カウントをリセット
        self.counts = [0] * 5
        self.selected_index = 0
        self.update_label()  # カウント表示ラベルをリセット

    def main():
        root = tk.Tk()
        app = CounterApp(root)
        root.mainloop()

    if __name__ == "__main__":
        main()

chatGPTフル活用です😂

🧡最後に

これをExcel等でまとめれば、表にして報告書作成できます。
業務中に、毎回カウントしていけば報告書作成の時に、ちょっとは効率化できるでしょう!

今後、このようにちょっとした効率化のための情報を載せます。あなたの業務でも役立つこと願っています💓

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?