This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). ## Getting Started First, run the development server: ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. ## Learn More To learn more about Next.js, take a look at the following resources: - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! ## Deploy on Vercel The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. # 定时脚本 sudo crontab -l 0 */6 * * * curl http://localhost:3000/api/dingding/corn >> /var/log/cron_dingding.log 2>&1 每六个小时执行一次脚本将数据注入到数据库 # 通用Excel导入接口 项目提供了一个通用的Excel数据导入接口,可以用于向不同的数据表导入数据。 ## 接口地址 ``` POST /api/utils/genericImport?table= ``` ## 支持的表名 - project (项目立项数据) - purchase_contract_order_management (采购合同订单管理数据) - purchase_contract_execution_maintenance (采购合同履约数据) - expense_reimbursement (费用报销数据) - actual_payment (实际支付数据) ## 使用方法 发送POST请求到上述接口地址,将Excel文件作为请求体上传,同时在查询参数中指定要导入的表名。 示例(使用curl): ```bash # 导入项目立项数据 curl -X POST -F "file=@project_data.xlsx" "http://localhost:3000/api/utils/genericImport?table=project" # 导入采购合同订单管理数据 curl -X POST -F "file=@purchase_contract_order.xlsx" "http://localhost:3000/api/utils/genericImport?table=purchase_contract_order_management" ``` ## Excel文件格式要求 Excel文件应包含与目标数据表对应的列,第一行为列标题。其中必须包含"数据id"列作为唯一标识。 ## 注意事项 1. 接口在插入数据前会查询数据库中已存在的记录,自动过滤掉重复的数据(基于数据id字段),只插入新数据 2. 导入完成后会返回具体插入的新数据条数 3. 导入过程中如遇到错误,会返回500状态码及错误信息 4. 请确保Excel文件格式正确,列名与模板一致 ## 金融数据计算库 https://mikemcl.github.io/bignumber.js/ https://www.npmjs.com/package/bignumber.js 用例 1:浮点数精度误差(最常见问题) 用例 2:大整数精度丢失 用例 3:toFixed()方法的舍入异常