├── .gitignore ├── LICENSE ├── README.md ├── account.png ├── app.py ├── card.png ├── demo.png ├── hallticket.png ├── main.py ├── requirements.txt ├── requirements_st.txt └── st_page.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # User data 2 | result.png 3 | test.py 4 | report.md 5 | data.json 6 | config.json 7 | 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | build/ 19 | develop-eggs/ 20 | dist/ 21 | downloads/ 22 | eggs/ 23 | .eggs/ 24 | lib/ 25 | lib64/ 26 | parts/ 27 | sdist/ 28 | var/ 29 | wheels/ 30 | share/python-wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | MANIFEST 35 | 36 | # PyInstaller 37 | # Usually these files are written by a python script from a template 38 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 39 | *.manifest 40 | *.spec 41 | 42 | # Installer logs 43 | pip-log.txt 44 | pip-delete-this-directory.txt 45 | 46 | # Unit test / coverage reports 47 | htmlcov/ 48 | .tox/ 49 | .nox/ 50 | .coverage 51 | .coverage.* 52 | .cache 53 | nosetests.xml 54 | coverage.xml 55 | *.cover 56 | *.py,cover 57 | .hypothesis/ 58 | .pytest_cache/ 59 | cover/ 60 | 61 | # Translations 62 | *.mo 63 | *.pot 64 | 65 | # Django stuff: 66 | *.log 67 | local_settings.py 68 | db.sqlite3 69 | db.sqlite3-journal 70 | 71 | # Flask stuff: 72 | instance/ 73 | .webassets-cache 74 | 75 | # Scrapy stuff: 76 | .scrapy 77 | 78 | # Sphinx documentation 79 | docs/_build/ 80 | 81 | # PyBuilder 82 | .pybuilder/ 83 | target/ 84 | 85 | # Jupyter Notebook 86 | .ipynb_checkpoints 87 | 88 | # IPython 89 | profile_default/ 90 | ipython_config.py 91 | 92 | # pyenv 93 | # For a library or package, you might want to ignore these files since the code is 94 | # intended to run in multiple environments; otherwise, check them in: 95 | # .python-version 96 | 97 | # pipenv 98 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 99 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 100 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 101 | # install all needed dependencies. 102 | #Pipfile.lock 103 | 104 | # UV 105 | # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. 106 | # This is especially recommended for binary packages to ensure reproducibility, and is more 107 | # commonly ignored for libraries. 108 | #uv.lock 109 | 110 | # poetry 111 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 112 | # This is especially recommended for binary packages to ensure reproducibility, and is more 113 | # commonly ignored for libraries. 114 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 115 | #poetry.lock 116 | 117 | # pdm 118 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 119 | #pdm.lock 120 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 121 | # in version control. 122 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control 123 | .pdm.toml 124 | .pdm-python 125 | .pdm-build/ 126 | 127 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 128 | __pypackages__/ 129 | 130 | # Celery stuff 131 | celerybeat-schedule 132 | celerybeat.pid 133 | 134 | # SageMath parsed files 135 | *.sage.py 136 | 137 | # Environments 138 | .env 139 | .venv 140 | env/ 141 | venv/ 142 | ENV/ 143 | env.bak/ 144 | venv.bak/ 145 | 146 | # Spyder project settings 147 | .spyderproject 148 | .spyproject 149 | 150 | # Rope project settings 151 | .ropeproject 152 | 153 | # mkdocs documentation 154 | /site 155 | 156 | # mypy 157 | .mypy_cache/ 158 | .dmypy.json 159 | dmypy.json 160 | 161 | # Pyre type checker 162 | .pyre/ 163 | 164 | # pytype static type analyzer 165 | .pytype/ 166 | 167 | # Cython debug symbols 168 | cython_debug/ 169 | 170 | # PyCharm 171 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 172 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 173 | # and can be added to the global gitignore or merged into this file. For a more nuclear 174 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 175 | .idea/ 176 | 177 | # PyPI configuration file 178 | .pypirc 179 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 58 | Public License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-NonCommercial-ShareAlike 4.0 International Public License 63 | ("Public License"). To the extent this Public License may be 64 | interpreted as a contract, You are granted the Licensed Rights in 65 | consideration of Your acceptance of these terms and conditions, and the 66 | Licensor grants You such rights in consideration of benefits the 67 | Licensor receives from making the Licensed Material available under 68 | these terms and conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-NC-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution, NonCommercial, and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. NonCommercial means not primarily intended for or directed towards 126 | commercial advantage or monetary compensation. For purposes of 127 | this Public License, the exchange of the Licensed Material for 128 | other material subject to Copyright and Similar Rights by digital 129 | file-sharing or similar means is NonCommercial provided there is 130 | no payment of monetary compensation in connection with the 131 | exchange. 132 | 133 | l. Share means to provide material to the public by any means or 134 | process that requires permission under the Licensed Rights, such 135 | as reproduction, public display, public performance, distribution, 136 | dissemination, communication, or importation, and to make material 137 | available to the public including in ways that members of the 138 | public may access the material from a place and at a time 139 | individually chosen by them. 140 | 141 | m. Sui Generis Database Rights means rights other than copyright 142 | resulting from Directive 96/9/EC of the European Parliament and of 143 | the Council of 11 March 1996 on the legal protection of databases, 144 | as amended and/or succeeded, as well as other essentially 145 | equivalent rights anywhere in the world. 146 | 147 | n. You means the individual or entity exercising the Licensed Rights 148 | under this Public License. Your has a corresponding meaning. 149 | 150 | 151 | Section 2 -- Scope. 152 | 153 | a. License grant. 154 | 155 | 1. Subject to the terms and conditions of this Public License, 156 | the Licensor hereby grants You a worldwide, royalty-free, 157 | non-sublicensable, non-exclusive, irrevocable license to 158 | exercise the Licensed Rights in the Licensed Material to: 159 | 160 | a. reproduce and Share the Licensed Material, in whole or 161 | in part, for NonCommercial purposes only; and 162 | 163 | b. produce, reproduce, and Share Adapted Material for 164 | NonCommercial purposes only. 165 | 166 | 2. Exceptions and Limitations. For the avoidance of doubt, where 167 | Exceptions and Limitations apply to Your use, this Public 168 | License does not apply, and You do not need to comply with 169 | its terms and conditions. 170 | 171 | 3. Term. The term of this Public License is specified in Section 172 | 6(a). 173 | 174 | 4. Media and formats; technical modifications allowed. The 175 | Licensor authorizes You to exercise the Licensed Rights in 176 | all media and formats whether now known or hereafter created, 177 | and to make technical modifications necessary to do so. The 178 | Licensor waives and/or agrees not to assert any right or 179 | authority to forbid You from making technical modifications 180 | necessary to exercise the Licensed Rights, including 181 | technical modifications necessary to circumvent Effective 182 | Technological Measures. For purposes of this Public License, 183 | simply making modifications authorized by this Section 2(a) 184 | (4) never produces Adapted Material. 185 | 186 | 5. Downstream recipients. 187 | 188 | a. Offer from the Licensor -- Licensed Material. Every 189 | recipient of the Licensed Material automatically 190 | receives an offer from the Licensor to exercise the 191 | Licensed Rights under the terms and conditions of this 192 | Public License. 193 | 194 | b. Additional offer from the Licensor -- Adapted Material. 195 | Every recipient of Adapted Material from You 196 | automatically receives an offer from the Licensor to 197 | exercise the Licensed Rights in the Adapted Material 198 | under the conditions of the Adapter's License You apply. 199 | 200 | c. No downstream restrictions. You may not offer or impose 201 | any additional or different terms or conditions on, or 202 | apply any Effective Technological Measures to, the 203 | Licensed Material if doing so restricts exercise of the 204 | Licensed Rights by any recipient of the Licensed 205 | Material. 206 | 207 | 6. No endorsement. Nothing in this Public License constitutes or 208 | may be construed as permission to assert or imply that You 209 | are, or that Your use of the Licensed Material is, connected 210 | with, or sponsored, endorsed, or granted official status by, 211 | the Licensor or others designated to receive attribution as 212 | provided in Section 3(a)(1)(A)(i). 213 | 214 | b. Other rights. 215 | 216 | 1. Moral rights, such as the right of integrity, are not 217 | licensed under this Public License, nor are publicity, 218 | privacy, and/or other similar personality rights; however, to 219 | the extent possible, the Licensor waives and/or agrees not to 220 | assert any such rights held by the Licensor to the limited 221 | extent necessary to allow You to exercise the Licensed 222 | Rights, but not otherwise. 223 | 224 | 2. Patent and trademark rights are not licensed under this 225 | Public License. 226 | 227 | 3. To the extent possible, the Licensor waives any right to 228 | collect royalties from You for the exercise of the Licensed 229 | Rights, whether directly or through a collecting society 230 | under any voluntary or waivable statutory or compulsory 231 | licensing scheme. In all other cases the Licensor expressly 232 | reserves any right to collect such royalties, including when 233 | the Licensed Material is used other than for NonCommercial 234 | purposes. 235 | 236 | 237 | Section 3 -- License Conditions. 238 | 239 | Your exercise of the Licensed Rights is expressly made subject to the 240 | following conditions. 241 | 242 | a. Attribution. 243 | 244 | 1. If You Share the Licensed Material (including in modified 245 | form), You must: 246 | 247 | a. retain the following if it is supplied by the Licensor 248 | with the Licensed Material: 249 | 250 | i. identification of the creator(s) of the Licensed 251 | Material and any others designated to receive 252 | attribution, in any reasonable manner requested by 253 | the Licensor (including by pseudonym if 254 | designated); 255 | 256 | ii. a copyright notice; 257 | 258 | iii. a notice that refers to this Public License; 259 | 260 | iv. a notice that refers to the disclaimer of 261 | warranties; 262 | 263 | v. a URI or hyperlink to the Licensed Material to the 264 | extent reasonably practicable; 265 | 266 | b. indicate if You modified the Licensed Material and 267 | retain an indication of any previous modifications; and 268 | 269 | c. indicate the Licensed Material is licensed under this 270 | Public License, and include the text of, or the URI or 271 | hyperlink to, this Public License. 272 | 273 | 2. You may satisfy the conditions in Section 3(a)(1) in any 274 | reasonable manner based on the medium, means, and context in 275 | which You Share the Licensed Material. For example, it may be 276 | reasonable to satisfy the conditions by providing a URI or 277 | hyperlink to a resource that includes the required 278 | information. 279 | 3. If requested by the Licensor, You must remove any of the 280 | information required by Section 3(a)(1)(A) to the extent 281 | reasonably practicable. 282 | 283 | b. ShareAlike. 284 | 285 | In addition to the conditions in Section 3(a), if You Share 286 | Adapted Material You produce, the following conditions also apply. 287 | 288 | 1. The Adapter's License You apply must be a Creative Commons 289 | license with the same License Elements, this version or 290 | later, or a BY-NC-SA Compatible License. 291 | 292 | 2. You must include the text of, or the URI or hyperlink to, the 293 | Adapter's License You apply. You may satisfy this condition 294 | in any reasonable manner based on the medium, means, and 295 | context in which You Share Adapted Material. 296 | 297 | 3. You may not offer or impose any additional or different terms 298 | or conditions on, or apply any Effective Technological 299 | Measures to, Adapted Material that restrict exercise of the 300 | rights granted under the Adapter's License You apply. 301 | 302 | 303 | Section 4 -- Sui Generis Database Rights. 304 | 305 | Where the Licensed Rights include Sui Generis Database Rights that 306 | apply to Your use of the Licensed Material: 307 | 308 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 309 | to extract, reuse, reproduce, and Share all or a substantial 310 | portion of the contents of the database for NonCommercial purposes 311 | only; 312 | 313 | b. if You include all or a substantial portion of the database 314 | contents in a database in which You have Sui Generis Database 315 | Rights, then the database in which You have Sui Generis Database 316 | Rights (but not its individual contents) is Adapted Material, 317 | including for purposes of Section 3(b); and 318 | 319 | c. You must comply with the conditions in Section 3(a) if You Share 320 | all or a substantial portion of the contents of the database. 321 | 322 | For the avoidance of doubt, this Section 4 supplements and does not 323 | replace Your obligations under this Public License where the Licensed 324 | Rights include other Copyright and Similar Rights. 325 | 326 | 327 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 328 | 329 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 330 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 331 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 332 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 333 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 334 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 335 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 336 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 337 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 338 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 339 | 340 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 341 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 342 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 343 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 344 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 345 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 346 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 347 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 348 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 349 | 350 | c. The disclaimer of warranties and limitation of liability provided 351 | above shall be interpreted in a manner that, to the extent 352 | possible, most closely approximates an absolute disclaimer and 353 | waiver of all liability. 354 | 355 | 356 | Section 6 -- Term and Termination. 357 | 358 | a. This Public License applies for the term of the Copyright and 359 | Similar Rights licensed here. However, if You fail to comply with 360 | this Public License, then Your rights under this Public License 361 | terminate automatically. 362 | 363 | b. Where Your right to use the Licensed Material has terminated under 364 | Section 6(a), it reinstates: 365 | 366 | 1. automatically as of the date the violation is cured, provided 367 | it is cured within 30 days of Your discovery of the 368 | violation; or 369 | 370 | 2. upon express reinstatement by the Licensor. 371 | 372 | For the avoidance of doubt, this Section 6(b) does not affect any 373 | right the Licensor may have to seek remedies for Your violations 374 | of this Public License. 375 | 376 | c. For the avoidance of doubt, the Licensor may also offer the 377 | Licensed Material under separate terms or conditions or stop 378 | distributing the Licensed Material at any time; however, doing so 379 | will not terminate this Public License. 380 | 381 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 382 | License. 383 | 384 | 385 | Section 7 -- Other Terms and Conditions. 386 | 387 | a. The Licensor shall not be bound by any additional or different 388 | terms or conditions communicated by You unless expressly agreed. 389 | 390 | b. Any arrangements, understandings, or agreements regarding the 391 | Licensed Material not stated herein are separate from and 392 | independent of the terms and conditions of this Public License. 393 | 394 | 395 | Section 8 -- Interpretation. 396 | 397 | a. For the avoidance of doubt, this Public License does not, and 398 | shall not be interpreted to, reduce, limit, restrict, or impose 399 | conditions on any use of the Licensed Material that could lawfully 400 | be made without permission under this Public License. 401 | 402 | b. To the extent possible, if any provision of this Public License is 403 | deemed unenforceable, it shall be automatically reformed to the 404 | minimum extent necessary to make it enforceable. If the provision 405 | cannot be reformed, it shall be severed from this Public License 406 | without affecting the enforceability of the remaining terms and 407 | conditions. 408 | 409 | c. No term or condition of this Public License will be waived and no 410 | failure to comply consented to unless expressly agreed to by the 411 | Licensor. 412 | 413 | d. Nothing in this Public License constitutes or may be interpreted 414 | as a limitation upon, or waiver of, any privileges and immunities 415 | that apply to the Licensor or You, including from the legal 416 | processes of any jurisdiction or authority. 417 | 418 | ======================================================================= 419 | 420 | Creative Commons is not a party to its public 421 | licenses. Notwithstanding, Creative Commons may elect to apply one of 422 | its public licenses to material it publishes and in those instances 423 | will be considered the “Licensor.” The text of the Creative Commons 424 | public licenses is dedicated to the public domain under the CC0 Public 425 | Domain Dedication. Except for the limited purpose of indicating that 426 | material is shared under a Creative Commons public license or as 427 | otherwise permitted by the Creative Commons policies published at 428 | creativecommons.org/policies, Creative Commons does not authorize the 429 | use of the trademark "Creative Commons" or any other trademark or logo 430 | of Creative Commons without its prior written consent including, 431 | without limitation, in connection with any unauthorized modifications 432 | to any of its public licenses or any other arrangements, 433 | understandings, or agreements concerning use of licensed material. For 434 | the avoidance of doubt, this paragraph does not form part of the 435 | public licenses. 436 | 437 | Creative Commons may be contacted at creativecommons.org. 438 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XJTU-Annual-Eat 2 | 3 | 一年过去了,你在洗脚食堂里花的钱都花在哪儿了? 4 | 5 | ## 项目简介 6 | 7 | > 项目的 idea 来源于 [Rose-max111](https://github.com/Rose-max111)。 8 | > 9 | 10 | 本项目是一个用于统计洗脚大学学生校园卡消费情况的脚本。通过模拟登录大学校园卡网站,获取学生的校园卡消费记录,并通过数据可视化的方式展示。 11 | 12 | 本项目参考[THU-Annual-Eat](https://github.com/leverimmy/THU-Annual-Eat),[PKU-Annual-Eat](https://github.com/zhuohaoyu/PKU-Annual-Eat),感谢原作者的贡献。 13 | 14 | ![demo](./demo.png) 15 | 16 | ## 使用方法 17 | 18 | 首先,登录校园卡账号后,在[洗脚大学校园卡网站](http://card.xjtu.edu.cn/User/User)获取你的`account`和`hallticket`。登录后界面如下,主要使用`个人中心`和`我的账单`两个功能。 19 | 20 | 21 | 22 | ![card](./card.png) 23 | 24 | ### 获取account 25 | 26 | 27 | 主页进入[个人中心](http://card.xjtu.edu.cn/),点击`账号管理`,在弹出的页面中找到`账号`,复制其值。 28 | 29 | ![account](./account.png) 30 | 31 | ### 获取hallticket 32 | 33 | 在`我的账单`页按`F12` 或者右键检查,打开开发者工具,切换到`Network`标签页,然后`Ctrl+R`刷新页面,找到 `GetMyBill` 这个请求,进入`Cookies`选项卡,复制其中`hallticket`字段的**value**,后面会用到。 34 | 35 | ![hallticket](./hallticket.png) 36 | 37 | 为方便大家使用,在服务器上部署了一个网页端供大伙点击即用:[洗脚大学食堂消费情况](http://39.100.102.17:8501/) 38 | 39 | 如果要独立运行,参考以下两种方式 40 | 41 | ### 网页模式 42 | 43 | 基于streamlit实现的网页可视化,推荐 python 版本:`>=3.10` 44 | 45 | #### 1. 安装依赖 46 | 47 | ```shell 48 | pip install -r requirements_st.txt 49 | ``` 50 | 51 | #### 2. 运行页面 52 | 53 | ```shell 54 | streamlit run app.py 55 | ``` 56 | 57 | #### 3. 填写个人信息生成报告 58 | 59 | 在侧边栏填入前面获取到的`account`和`hallticket`,点击生成报告按钮生成。 60 | ![](./st_page.jpg) 61 | 62 | ### 本地模式 63 | 64 | #### 1. 安装依赖 65 | 66 | 本项目依赖于 `requests`、`matplotlib`,请确保你的 Python 环境中已经安装了这些库。 67 | 68 | ```bash 69 | pip install -r requirements.txt 70 | ``` 71 | 72 | #### 2. 修改配置 73 | 74 | 项目根目录下新建 `config.json` 文件,内容如下,主要修改`account`或者`hallticket`,以及计算的起始和截止时间。 75 | 76 | ```json 77 | { 78 | "account": "******", 79 | "hallticket": "*********", 80 | "sdate": "2024-01-01", 81 | "edate": "2024-12-31" 82 | } 83 | ``` 84 | 85 | #### 3. 运行脚本 86 | 87 | ```bash 88 | python main.py 89 | ``` 90 | 91 | #### 4. 查看结果 92 | 在result.png中显示了消费情况图,report.md中显示了较详细的消费统计报告(也可以在输出中查看)。 93 | python运行时的图可能出现字体重叠和图片大小不合适的问题,建议直接看导出的result.png。 94 | 95 | ## LICENSE 96 | 97 | 除非另有说明,本仓库的内容采用 [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) 许可协议。在遵守许可协议的前提下,您可以自由地分享、修改本文档的内容,但不得用于商业目的。 98 | 99 | 如果您认为文档的部分内容侵犯了您的合法权益,请联系项目维护者,我们会尽快删除相关内容。 100 | -------------------------------------------------------------------------------- /account.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangerforcs/XJTU-Annual-Eat/0d14bd7d8a7d7fd07ebe349b5fee2d21dba1645e/account.png -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import json 2 | import matplotlib.pyplot as plt 3 | import requests 4 | import platform 5 | from datetime import datetime, timedelta 6 | import seaborn as sns 7 | import streamlit as st 8 | import plotly.graph_objects as go 9 | import plotly.express as px 10 | 11 | # 使用streamlit来呈现上面的图表和数据 12 | st.set_page_config(page_title="洗脚大学食堂消费情况", page_icon="🍚", layout="wide") 13 | st.title("洗脚大学食堂消费情况") 14 | st.write("数据来源:洗脚大学食堂") 15 | 16 | # 使用cookie存储account和hallticket 17 | if "account" not in st.session_state: 18 | st.session_state["account"] = "" 19 | 20 | if "hallticket" not in st.session_state: 21 | st.session_state["hallticket"] = "" 22 | 23 | if "sdate" not in st.session_state: 24 | st.session_state["sdate"] = "2024-01-01" 25 | 26 | if "edate" not in st.session_state: 27 | st.session_state["edate"] = "2024-12-31" 28 | 29 | def generate_report(account, hallticket, sdate, edate): 30 | all_data = dict() 31 | week_data = dict() 32 | day_data = dict() 33 | url = f"http://card.xjtu.edu.cn/Report/GetMyBill" 34 | cookie = { 35 | "hallticket": hallticket, 36 | } 37 | post_data = { 38 | "sdate": sdate, 39 | "edate": edate, 40 | "account": account, 41 | "page": "1", 42 | "rows": "9000", 43 | } 44 | response = requests.post(url, cookies=cookie, data=post_data) 45 | try: 46 | data = json.loads(response.text)["rows"] 47 | except: 48 | st.error("消费数据获取失败,请检查账户信息是否正确") 49 | return 50 | 51 | # 保存到文件 52 | # with open("data.json", "w", encoding='utf-8') as f: 53 | # json.dump(data, f, indent=4) 54 | 55 | max_consumption = {'MERCNAME': '', 'TRANAMT': 0} 56 | min_consumption = {'MERCNAME': '', 'TRANAMT': float('inf')} 57 | earliest_consumption = {'OCCTIME': '2024-01-01 23:59:59', 'MERCNAME': '', 'TRANAMT': float('inf')} 58 | latest_consumption = {'OCCTIME': '2024-01-01 00:00:00', 'MERCNAME': '', 'TRANAMT': 0} 59 | weekdays_consumption = {i: 0 for i in range(7)} # 0: 周一, 6: 周日 60 | bre_lun_din = {"breakfast_count": 0, "breakfast_cost": 0, "lunch_count": 0, "lunch_cost": 0, "dinner_count": 0, "dinner_cost": 0} 61 | 62 | # 整理数据 63 | # MERNAME: 商户名称 TRANNUM: 交易方式 TRANAMT: 交易金额 64 | pre_bre_day = "" 65 | for item in data: 66 | try: 67 | if(item["TRANAMT"] < 0): 68 | tranamt = abs(item["TRANAMT"]) 69 | 70 | if item["MERCNAME"].strip() in all_data: 71 | all_data[item["MERCNAME"].strip()] += tranamt 72 | else: 73 | all_data[item["MERCNAME"].strip()] = tranamt 74 | 75 | time = datetime.strptime(item["OCCTIME"], "%Y-%m-%d %H:%M:%S") 76 | if time.time() < datetime.strptime("9:50:00", "%H:%M:%S").time(): 77 | if pre_bre_day != time.strftime('%Y-%m-%d'): 78 | bre_lun_din["breakfast_count"] += 1 79 | pre_bre_day = time.strftime('%Y-%m-%d') 80 | bre_lun_din["breakfast_cost"] += tranamt 81 | elif time.time() < datetime.strptime("14:00:00", "%H:%M:%S").time(): 82 | bre_lun_din["lunch_count"] += 1 83 | bre_lun_din["lunch_cost"] += tranamt 84 | else: 85 | bre_lun_din["dinner_count"] += 1 86 | bre_lun_din["dinner_cost"] += tranamt 87 | aligned_time_day = time.strftime('%Y-%m-%d') 88 | if aligned_time_day in day_data: 89 | day_data[aligned_time_day] += tranamt 90 | else: 91 | day_data[aligned_time_day] = tranamt 92 | 93 | aligned_time = time - timedelta(days=time.weekday()) 94 | aligned_time_day = aligned_time.strftime('%Y-%m-%d') 95 | if aligned_time_day in week_data: 96 | week_data[aligned_time_day] += tranamt 97 | else: 98 | week_data[aligned_time_day] = tranamt 99 | 100 | item["TRANAMT"] = abs(item["TRANAMT"]) 101 | if tranamt > max_consumption['TRANAMT']: 102 | max_consumption = item 103 | if tranamt < min_consumption['TRANAMT']: 104 | min_consumption = item 105 | 106 | occtime = datetime.strptime(item["OCCTIME"], "%Y-%m-%d %H:%M:%S") 107 | earliest_occtime = datetime.strptime(earliest_consumption["OCCTIME"], "%Y-%m-%d %H:%M:%S") 108 | latest_occtime = datetime.strptime(latest_consumption["OCCTIME"], "%Y-%m-%d %H:%M:%S") 109 | if occtime.time() < earliest_occtime.time(): 110 | earliest_consumption = item 111 | if occtime.time() > latest_occtime.time(): 112 | latest_consumption = item 113 | 114 | weekday = datetime.strptime(item["EFFECTDATE"], "%Y-%m-%d %H:%M:%S").weekday() 115 | weekdays_consumption[weekday] += tranamt 116 | except Exception as e: 117 | print(e) 118 | pass 119 | all_data = {k: round(v, 2) for k, v in all_data.items()} 120 | summary = f"统计总种类数:{len(all_data)}\n总消费次数:{len(data)}\n总消费金额:{round(sum(all_data.values()), 1)}" 121 | 122 | # 输出结果 123 | all_data = dict(sorted(all_data.items(), key=lambda x: x[1], reverse=True)) 124 | 125 | st.write(f"总种类数:{len(all_data)}, 总消费次数:{len(data)}, 总消费金额:{round(sum(all_data.values()), 1)}元") 126 | 127 | col1, col2, col3, col4 = st.columns(4) 128 | with col1: 129 | st.write(f""" 130 | ### 最高消费 131 | - 商户:{max_consumption['MERCNAME']} 132 | - 金额: {round(max_consumption['TRANAMT'], 1)}元 133 | ### 最低消费 134 | - 商户:{min_consumption['MERCNAME']} 135 | - 金额: {round(min_consumption['TRANAMT'], 1)}元 136 | """) 137 | 138 | with col2: 139 | st.write(f""" 140 | ### 最高天消费 141 | - 日期:{max(day_data, key=day_data.get)} 142 | - 金额:{round(max(day_data.values()), 1)}元 143 | ### 最低天消费 144 | - 日期:{min(day_data, key=day_data.get)} 145 | - 金额:{round(min(day_data.values()), 1)}元 146 | """) 147 | 148 | with col3: 149 | st.write(f""" 150 | ### 最高周消费 151 | - 周一日期:{max(week_data, key=week_data.get)} 152 | - 金额:{round(max(week_data.values()), 1)}元 153 | ### 最低周消费 154 | - 周一日期:{min(week_data, key=week_data.get)} 155 | - 金额:{round(min(week_data.values()), 1)}元 156 | """) 157 | 158 | with col4: 159 | st.write(f""" 160 | ### 最早消费 161 | - 时间:{earliest_consumption['OCCTIME']} {earliest_consumption['MERCNAME']} 162 | - 金额:{earliest_consumption['TRANAMT']}元 163 | ### 最晚消费 164 | - 时间:{latest_consumption['OCCTIME']} {latest_consumption['MERCNAME']} 165 | - 金额:{latest_consumption['TRANAMT']}元 166 | """) 167 | 168 | if platform.system() == "Darwin": 169 | plt.rcParams['font.sans-serif'] = ['Arial Unicode MS'] 170 | else: 171 | plt.rcParams['font.sans-serif'] = ['SimHei'] 172 | 173 | gc1, gc2 = st.columns(2) 174 | # 绘制图表 175 | with gc1: 176 | fig = plt.figure(figsize=(12, len(all_data) / 66 * 18)) 177 | sns.barplot(x=list(all_data.values()), y=list(all_data.keys()), hue=list(all_data.keys())) 178 | # plt.barh(list(all_data.keys()), list(all_data.values())) 179 | for index, value in enumerate(list(all_data.values())): 180 | plt.text(value + 0.01 * max(all_data.values() or [0]), 181 | index, 182 | str(value), 183 | va='center') 184 | 185 | # plt.tight_layout() 186 | plt.xlim(0, 1.2 * max(all_data.values() or [0])) 187 | plt.title(f"洗脚大学食堂消费情况\n({post_data['sdate']} 至 {post_data['edate']})") 188 | plt.xlabel("消费金额(元)") 189 | plt.text(0.8, 0.1, summary, ha='center', va='center', transform=plt.gca().transAxes) 190 | st.pyplot(fig) 191 | 192 | with gc2: 193 | 194 | c1, c2 = st.columns(2) 195 | colors = ['gold', 'mediumturquoise', 'darkorange'] 196 | with c1: 197 | # 使用plotly绘制三餐消费次数饼图 198 | pie_fig = px.pie(values=[bre_lun_din["breakfast_count"], bre_lun_din["lunch_count"], bre_lun_din["dinner_count"]], 199 | names=["早餐", "午餐", "晚餐"], 200 | title=f"三餐消费次数\n({post_data['sdate']} 至 {post_data['edate']})",) 201 | pie_fig.update_traces(textinfo='label+percent', insidetextorientation='radial', 202 | marker=dict(colors=colors, line=dict(color='#000000', width=2))) 203 | st.plotly_chart(pie_fig) 204 | with c2: 205 | # 使用plotly绘制三餐消费金额饼图 206 | pie_fig = px.pie(values=[bre_lun_din["breakfast_cost"], bre_lun_din["lunch_cost"], bre_lun_din["dinner_cost"]], 207 | names=["早餐", "午餐", "晚餐"], 208 | title=f"三餐消费金额(元)\n({post_data['sdate']} 至 {post_data['edate']})") 209 | pie_fig.update_traces(textinfo='label+percent', insidetextorientation='radial', 210 | marker=dict(colors=colors, line=dict(color='#000000', width=2))) 211 | st.plotly_chart(pie_fig) 212 | 213 | # 绘制周消费折线柱状图 214 | bar_colors = [ 215 | '#A6CEE3', # 浅蓝色 216 | '#FDBF6F', # 浅橙色 217 | '#B2DF8A', # 浅绿色 218 | '#FB9A99', # 浅红色 219 | '#CAB2D6', # 浅紫色 220 | '#FDD9B5', # 浅棕色 221 | '#FCCDE5' # 浅粉色 222 | ] 223 | days = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"] 224 | values = list(weekdays_consumption.values()) 225 | fig = go.Figure(data=[go.Bar(x=days, y=values, marker_color=bar_colors)]) 226 | fig.add_trace(go.Scatter(x=days, y=values, name='消费趋势', mode='lines+markers', 227 | line=dict(color='#ff7f0e', width=3), # 橙色线条 228 | marker=dict(size=8, color='#ff7f0e'))) # 橙色数据点 229 | fig.update_layout(title_text=f"周消费统计\n({post_data['sdate']} 至 {post_data['edate']})") 230 | st.plotly_chart(fig) 231 | 232 | def update_info(account, hallticket, sdate, edate): 233 | st.session_state.account = account 234 | st.session_state.hallticket = hallticket 235 | st.session_state.sdate = sdate 236 | st.session_state.edate = edate 237 | st.info("个人账户信息已更新") 238 | 239 | 240 | with st.sidebar: 241 | st.write(" account 和 hallticket 获取方法:https://github.com/wangerforcs/XJTU-Annual-Eat") 242 | account = st.text_input("请输入account", value=st.session_state.account) 243 | hallticket = st.text_input("请输入hallticket", value=st.session_state.hallticket) 244 | sdate = st.text_input("请输入起始日期", value=st.session_state.sdate) 245 | edate = st.text_input("请输入结束日期", value=st.session_state.edate) 246 | st.button("生成报告", on_click=update_info, args=(account, hallticket, sdate, edate)) 247 | 248 | 249 | account = st.session_state.account 250 | hallticket = st.session_state.hallticket 251 | sdate = st.session_state.sdate 252 | edate = st.session_state.edate 253 | 254 | if account == "" or hallticket == "" or sdate == "" or edate == "": 255 | st.warning("请填写个人账户信息") 256 | st.stop() 257 | else: 258 | generate_report(account, hallticket, sdate, edate) 259 | -------------------------------------------------------------------------------- /card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangerforcs/XJTU-Annual-Eat/0d14bd7d8a7d7fd07ebe349b5fee2d21dba1645e/card.png -------------------------------------------------------------------------------- /demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangerforcs/XJTU-Annual-Eat/0d14bd7d8a7d7fd07ebe349b5fee2d21dba1645e/demo.png -------------------------------------------------------------------------------- /hallticket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangerforcs/XJTU-Annual-Eat/0d14bd7d8a7d7fd07ebe349b5fee2d21dba1645e/hallticket.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import json 2 | import matplotlib.pyplot as plt 3 | import requests 4 | import platform 5 | from datetime import datetime, timedelta 6 | import seaborn as sns 7 | 8 | account = "" 9 | hallticket = "" 10 | sdate = "2024-01-01" 11 | edate = "2024-12-31" 12 | all_data = dict() 13 | week_data = dict() 14 | day_data = dict() 15 | 16 | if __name__ == "__main__": 17 | # 读入账户信息 18 | try: 19 | with open("config.json", "r", encoding='utf-8') as f: 20 | config = json.load(f) 21 | account = config["account"] 22 | hallticket = config["hallticket"] 23 | sdate = config.get("sdate", '2024-01-01') 24 | edate = config.get("edate", '2024-12-31') 25 | except Exception as e: 26 | print("账户信息读取失败,请重新输入") 27 | account = input("请输入account: ") 28 | hallticket = input("请输入hallticket: ") 29 | with open("config.json", "w", encoding='utf-8') as f: 30 | json.dump({"account": account, "hallticket": hallticket, 'sdate': '2024-01-01', 'edate': '2024-12-31'}, f, indent=4) 31 | 32 | def is_valid_date(date_str): 33 | """检查日期是否符合YYYY-MM-DD格式且为有效日期""" 34 | try: 35 | datetime.strptime(date_str, "%Y-%m-%d") 36 | return True 37 | except ValueError: 38 | return False 39 | def format_date(date_str): 40 | """确保日期始终以两位数显示月份和日期""" 41 | date_obj = datetime.strptime(date_str, "%Y-%m-%d") 42 | return date_obj.strftime("%Y-%m-%d") # 格式化为YYYY-MM-DD 43 | 44 | url = f"http://card.xjtu.edu.cn/Report/GetMyBill" 45 | cookie = { 46 | "hallticket": hallticket, 47 | } 48 | post_data = { 49 | "sdate": sdate, 50 | "edate": edate, 51 | "account": account, 52 | "page": "1", 53 | "rows": "9000", 54 | } 55 | response = requests.post(url, cookies=cookie, data=post_data) 56 | 57 | data = json.loads(response.text)["rows"] 58 | 59 | # 保存到文件 60 | # with open("data.json", "w", encoding='utf-8') as f: 61 | # json.dump(data, f, indent=4) 62 | 63 | max_consumption = {'MERCNAME': '', 'TRANAMT': 0} 64 | min_consumption = {'MERCNAME': '', 'TRANAMT': float('inf')} 65 | earliest_consumption = {'OCCTIME': '2024-01-01 23:59:59', 'MERCNAME': '', 'TRANAMT': float('inf')} 66 | latest_consumption = {'OCCTIME': '2024-01-01 00:00:00', 'MERCNAME': '', 'TRANAMT': 0} 67 | weekdays_consumption = {i: 0 for i in range(7)} # 0: 周一, 6: 周日 68 | bre_lun_din = {"breakfast_count": 0, "breakfast_cost": 0, "lunch_count": 0, "lunch_cost": 0, "dinner_count": 0, "dinner_cost": 0} 69 | 70 | # 整理数据 71 | # MERNAME: 商户名称 TRANNUM: 交易方式 TRANAMT: 交易金额 72 | pre_bre_day = "" 73 | for item in data: 74 | try: 75 | if(item["TRANAMT"] < 0): 76 | tranamt = abs(item["TRANAMT"]) 77 | 78 | if item["MERCNAME"].strip() in all_data: 79 | all_data[item["MERCNAME"].strip()] += tranamt 80 | else: 81 | all_data[item["MERCNAME"].strip()] = tranamt 82 | 83 | time = datetime.strptime(item["OCCTIME"], "%Y-%m-%d %H:%M:%S") 84 | # 修改早餐判定逻辑,卡掉第一节下课后却又在10:00之前吃上饭的,比如我:) 85 | # 另外考虑到早餐可能多次刷卡,将同一天的早餐消费合并为1次 86 | # 然后发现吃早饭的天数为个位数(: 87 | if time.time() < datetime.strptime("9:50:00", "%H:%M:%S").time(): 88 | print(pre_bre_day, time.strftime('%Y-%m-%d'),tranamt) 89 | if pre_bre_day != time.strftime('%Y-%m-%d'): 90 | bre_lun_din["breakfast_count"] += 1 91 | pre_bre_day = time.strftime('%Y-%m-%d') 92 | bre_lun_din["breakfast_cost"] += tranamt 93 | elif time.time() < datetime.strptime("14:00:00", "%H:%M:%S").time(): 94 | bre_lun_din["lunch_count"] += 1 95 | bre_lun_din["lunch_cost"] += tranamt 96 | else: 97 | bre_lun_din["dinner_count"] += 1 98 | bre_lun_din["dinner_cost"] += tranamt 99 | aligned_time_day = time.strftime('%Y-%m-%d') 100 | if aligned_time_day in day_data: 101 | day_data[aligned_time_day] += tranamt 102 | else: 103 | day_data[aligned_time_day] = tranamt 104 | 105 | aligned_time = time - timedelta(days=time.weekday()) 106 | aligned_time_day = aligned_time.strftime('%Y-%m-%d') 107 | if aligned_time_day in week_data: 108 | week_data[aligned_time_day] += tranamt 109 | else: 110 | week_data[aligned_time_day] = tranamt 111 | 112 | item["TRANAMT"] = abs(item["TRANAMT"]) 113 | if tranamt > max_consumption['TRANAMT']: 114 | max_consumption = item 115 | if tranamt < min_consumption['TRANAMT']: 116 | min_consumption = item 117 | 118 | occtime = datetime.strptime(item["OCCTIME"], "%Y-%m-%d %H:%M:%S") 119 | earliest_occtime = datetime.strptime(earliest_consumption["OCCTIME"], "%Y-%m-%d %H:%M:%S") 120 | latest_occtime = datetime.strptime(latest_consumption["OCCTIME"], "%Y-%m-%d %H:%M:%S") 121 | if occtime.time() < earliest_occtime.time(): 122 | earliest_consumption = item 123 | if occtime.time() > latest_occtime.time(): 124 | latest_consumption = item 125 | 126 | weekday = datetime.strptime(item["EFFECTDATE"], "%Y-%m-%d %H:%M:%S").weekday() 127 | weekdays_consumption[weekday] += tranamt 128 | except Exception as e: 129 | print(e) 130 | pass 131 | all_data = {k: round(v, 2) for k, v in all_data.items()} 132 | summary = f"统计总种类数:{len(all_data)}\n总消费次数:{len(data)}\n总消费金额:{round(sum(all_data.values()), 1)}" 133 | 134 | # 输出结果 135 | all_data = dict(sorted(all_data.items(), key=lambda x: x[1], reverse=True)) 136 | # if len(all_data) > 50: 137 | # # Get top 40 and bottom 10 138 | # bottom_10 = dict(list(all_data.items())[:10]) 139 | # top_40 = dict(list(all_data.items())[-40:]) 140 | # # Add a separator between top and bottom groups 141 | # middle_values = list(all_data.values())[10:-40] 142 | # separator = {"中间部分消费总额": round(sum(middle_values), 2)} # Sum of middle values 143 | # all_data = {**bottom_10, **separator, **top_40} 144 | 145 | if platform.system() == "Darwin": 146 | plt.rcParams['font.sans-serif'] = ['Arial Unicode MS'] 147 | # elif platform.system() == "Linux": 148 | # plt.rcParams['font.family'] = ['Droid Sans Fallback', 'DejaVu Sans'] 149 | else: 150 | plt.rcParams['font.sans-serif'] = ['SimHei'] 151 | 152 | plt.figure(figsize=(12, len(all_data) / 66 * 18)) 153 | sns.barplot(x=list(all_data.values()), y=list(all_data.keys()), hue=list(all_data.keys())) 154 | # plt.barh(list(all_data.keys()), list(all_data.values())) 155 | for index, value in enumerate(list(all_data.values())): 156 | plt.text(value + 0.01 * max(all_data.values() or [0]), 157 | index, 158 | str(value), 159 | va='center') 160 | 161 | # plt.tight_layout() 162 | plt.xlim(0, 1.2 * max(all_data.values() or [0])) 163 | plt.title(f"洗脚大学食堂消费情况\n({post_data['sdate']} 至 {post_data['edate']})") 164 | plt.xlabel("消费金额(元)") 165 | plt.text(0.8, 0.1, summary, ha='center', va='center', transform=plt.gca().transAxes) 166 | plt.savefig("result.png",bbox_inches='tight',dpi=300) 167 | plt.show() 168 | 169 | 170 | 171 | # 创建Markdown文件 172 | markdown_content = f""" 173 | # 消费统计报告 174 | 175 | ## 消费概况 176 | - 总种类数:{len(all_data)} 177 | - 总消费次数:{len(data)} 178 | - 总消费金额:{round(sum(all_data.values()), 1)}元 179 | 180 | ## 消费分布 181 | - 早餐次数:{bre_lun_din["breakfast_count"]}次 182 | - 早餐消费:{round(bre_lun_din["breakfast_cost"], 1)}元 183 | - 午餐次数:{bre_lun_din["lunch_count"]}次 184 | - 午餐消费:{round(bre_lun_din["lunch_cost"], 1)}元 185 | - 晚餐次数:{bre_lun_din["dinner_count"]}次 186 | - 晚餐消费:{round(bre_lun_din["dinner_cost"], 1)}元 187 | 188 | ## 最高消费 189 | - 商户:{max_consumption['MERCNAME']} 190 | - 金额: {round(max_consumption['TRANAMT'], 1)}元 191 | 192 | ## 最低消费 193 | - 商户:{min_consumption['MERCNAME']} 194 | - 金额: {round(min_consumption['TRANAMT'], 1)}元 195 | 196 | ## 最高天消费 197 | - 日期:{max(day_data, key=day_data.get)} 198 | - 金额:{round(max(day_data.values()), 1)}元 199 | 200 | ## 最低天消费 201 | - 日期:{min(day_data, key=day_data.get)} 202 | - 金额:{round(min(day_data.values()), 1)}元 203 | 204 | ## 最高周消费 205 | - 周一日期:{max(week_data, key=week_data.get)} 206 | - 金额:{round(max(week_data.values()), 1)}元 207 | 208 | ## 最低周消费 209 | - 周一日期:{min(week_data, key=week_data.get)} 210 | - 金额:{round(min(week_data.values()), 1)}元 211 | 212 | ## 最早消费 213 | - 时间:{earliest_consumption['OCCTIME']} 214 | - 商户:{earliest_consumption['MERCNAME']} 215 | - 金额:{earliest_consumption['TRANAMT']}元 216 | 217 | ## 最晚消费 218 | - 时间:{latest_consumption['OCCTIME']} 219 | - 商户:{latest_consumption['MERCNAME']} 220 | - 金额:{latest_consumption['TRANAMT']}元 221 | 222 | ## 周消费统计 223 | | 星期 | 消费金额(元) | 224 | | ---- | ------------ | 225 | """ 226 | for i, amount in weekdays_consumption.items(): 227 | markdown_content += f"| 周{i+1} | {round(amount, 1)} |\n" 228 | 229 | print(markdown_content) 230 | 231 | markdown_content += "\n![消费情况图](result.png)" 232 | 233 | # 写入Markdown文件 234 | with open("report.md", "w", encoding='utf-8') as f: 235 | f.write(markdown_content) 236 | 237 | 238 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib 2 | requests 3 | seaborn==0.13.2 -------------------------------------------------------------------------------- /requirements_st.txt: -------------------------------------------------------------------------------- 1 | matplotlib 2 | requests 3 | seaborn==0.13.2 4 | plotly==5.24.1 5 | streamlit==1.39.0 -------------------------------------------------------------------------------- /st_page.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangerforcs/XJTU-Annual-Eat/0d14bd7d8a7d7fd07ebe349b5fee2d21dba1645e/st_page.jpg --------------------------------------------------------------------------------