Merge branch 'dev_New_pro' into dev_山西坤源化工
已添加110个文件
已重命名35个文件
已修改215个文件
已删除85个文件
| | |
| | | .gradle
|
| | | /build/
|
| | | !gradle/wrapper/gradle-wrapper.jar
|
| | |
|
| | | claude.md
|
| | | target/
|
| | | !.mvn/wrapper/maven-wrapper.jar
|
| | |
|
| | |
| | |
|
| | | !*/build/*.java
|
| | | !*/build/*.html
|
| | | !*/build/*.xml |
| | | !*/build/*.xml
|
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | ALTER TABLE `inspection_task` |
| | | ADD COLUMN `inspection_project` VARCHAR(100) NULL COMMENT 'å·¡æ£é¡¹ç®' AFTER `task_name`; |
| | | |
| | | ALTER TABLE `inspection_task` |
| | | ADD COLUMN `inspection_result` VARCHAR(1) NULL COMMENT 'å·¡æ£ç»æ 0å¼å¸¸ 1æ£å¸¸' AFTER `remarks`, |
| | | ADD COLUMN `abnormal_description` VARCHAR(500) NULL COMMENT 'å¼å¸¸æè¿°' AFTER `inspection_result`, |
| | | ADD COLUMN `device_repair_id` BIGINT NULL COMMENT 'å
³èç»´ä¿®åID' AFTER `abnormal_description`, |
| | | ADD COLUMN `acceptance_user_id` BIGINT NULL COMMENT 'éªæ¶äººID' AFTER `device_repair_id`, |
| | | ADD COLUMN `acceptance_name` VARCHAR(100) NULL COMMENT 'éªæ¶äºº' AFTER `acceptance_user_id`; |
| | | |
| | | ALTER TABLE `timing_task` |
| | | ADD COLUMN `inspection_project` VARCHAR(100) NULL COMMENT 'å·¡æ£é¡¹ç®' AFTER `task_name`, |
| | | ADD COLUMN `is_enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'æ¯å¦å¯ç¨ 0å¦ 1æ¯' AFTER `is_active`; |
| | | |
| | | CREATE INDEX `idx_inspection_task_device_repair_id` |
| | | ON `inspection_task` (`device_repair_id`); |
| | | |
| | | CREATE INDEX `idx_inspection_task_inspection_result` |
| | | ON `inspection_task` (`inspection_result`); |
| | | |
| | | CREATE INDEX `idx_timing_task_is_enabled` |
| | | ON `timing_task` (`is_enabled`); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # 设å¤å·¡æ£ä¸å®æ¶å·¡æ£å端èè°ææ¡£ï¼inspectiontaskï¼ |
| | | |
| | | > æ´æ°æ¥æï¼2026-05-15 |
| | | > éç¨æ¨¡åï¼è®¾å¤å·¡æ£ä»»å¡ `inspectiontask`ï¼`/inspectionTask`ï¼ä¸å®æ¶å·¡æ£ä»»å¡ï¼`/timingTask`ï¼ |
| | | |
| | | ## 1. æ¬æ¬¡æ¹å¨ |
| | | |
| | | 1. å·¡æ£ä»»å¡æ°å¢åæ®µï¼ |
| | | - `inspectionProject`ï¼å·¡æ£é¡¹ç®ï¼ |
| | | - `inspectionResult`ï¼å·¡æ£ç»æï¼`0`å¼å¸¸ / `1`æ£å¸¸ï¼å¿
å¡«ï¼ |
| | | - `abnormalDescription`ï¼å¼å¸¸æè¿°ï¼ |
| | | - `deviceRepairId`ï¼å
³èç»´ä¿®åIDï¼å¼å¸¸æ¶å端èªå¨åå¡«ï¼ |
| | | - `acceptanceUserId`ï¼éªæ¶äººIDï¼ |
| | | - `acceptanceName`ï¼éªæ¶äººï¼ |
| | | 2. å¼å¸¸æ ¡éªè§åï¼ |
| | | - `inspectionResult=1`ï¼æ£å¸¸ï¼ï¼ç
§çéå¿
å¡«ã |
| | | - `inspectionResult=0`ï¼å¼å¸¸ï¼ï¼å¿
é¡»æç
§çï¼ä¸å¿
须填å `abnormalDescription`ã |
| | | 3. å¼å¸¸èå¨è§åï¼ |
| | | - å¼å¸¸ä¿ååèªå¨çæ `device_repair` å¹¶åå¡« `deviceRepairId`ã |
| | | 4. 宿¶ä»»å¡æ°å¢åæ®µï¼ |
| | | - `inspectionProject`ï¼å·¡æ£é¡¹ç®ï¼ |
| | | - `isEnabled`ï¼æ¯å¦å¯ç¨ï¼`0`å¦ / `1`æ¯ï¼ |
| | | 5. 夿³¨å¸¦å
¥è§åï¼ |
| | | - 宿¶ä»»å¡èªå¨çæå·¡æ£è®°å½æ¶ï¼è¥å®æ¶ä»»å¡ `remarks` æå¼ï¼ä¼æ¼æ¥å°å·¡æ£è®°å½å¤æ³¨ä¸ã |
| | | |
| | | ## 2. æ°æ®åºåæ´ |
| | | |
| | | èè°åæ§è¡ SQLï¼ |
| | | |
| | | - [doc/20260515_device_maintenance_inspection_abnormal_acceptance.sql](/D:/ç马/åé/å端/product-inventory-management-after-jdk25/doc/20260515_device_maintenance_inspection_abnormal_acceptance.sql) |
| | | |
| | | > 说æï¼è¯¥èæ¬å½åä½ç¨äº `inspection_task` ä¸ `timing_task` ä¸¤å¼ è¡¨ï¼æä»¶ååå²ä¿çæªæ¹ã |
| | | |
| | | ## 3. å·¡æ£ä»»å¡æ¥å£ |
| | | |
| | | ### 3.1 ä¿åæ¥å£ |
| | | |
| | | `POST /inspectionTask/addOrEditInspectionTask` |
| | | |
| | | | åæ®µ | ç±»å | å¿
å¡« | 说æ | |
| | | |---|---|---|---| |
| | | | id | long | å¦ | æå¼=ä¿®æ¹ï¼æ å¼=æ°å¢ | |
| | | | taskId | int | 建议å¿
å¡« | 设å¤IDï¼ç¨äºå¼å¸¸èªå¨å»ºç»´ä¿®åï¼ | |
| | | | taskName | string | 建议å¿
å¡« | 设å¤åç§° | |
| | | | inspectionProject | string | å¦ | å·¡æ£é¡¹ç® | |
| | | | inspectorId | string | å¦ | å·¡æ£äººIDï¼æ¯æéå·åé | |
| | | | inspectionResult | string | æ¯ | `0`=å¼å¸¸ï¼`1`=æ£å¸¸ | |
| | | | abnormalDescription | string | æ¡ä»¶å¿
å¡« | å¼å¸¸æ¶å¿
å¡« | |
| | | | acceptanceUserId | long | å¦ | éªæ¶äººID | |
| | | | acceptanceName | string | å¦ | éªæ¶äººå§å | |
| | | | commonFileListDTO | array | æ¡ä»¶å¿
å¡« | éä»¶ç»1ï¼å¼å¸¸æ¶ä¸ç»è³å°ä¸ç»æå¾ï¼ | |
| | | | commonFileListAfterDTO | array | æ¡ä»¶å¿
å¡« | éä»¶ç»2ï¼å¼å¸¸æ¶ä¸ç»è³å°ä¸ç»æå¾ï¼ | |
| | | | commonFileListBeforeDTO | array | æ¡ä»¶å¿
å¡« | éä»¶ç»3ï¼å¼å¸¸æ¶ä¸ç»è³å°ä¸ç»æå¾ï¼ | |
| | | |
| | | å¼å¸¸ç¤ºä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "taskId": 1001, |
| | | "taskName": "ç©ºåæºA-01", |
| | | "inspectionProject": "润æ»ç³»ç»", |
| | | "inspectorId": "12", |
| | | "inspectionResult": "0", |
| | | "abnormalDescription": "çµæºå¼åï¼æ¸©ååé«", |
| | | "acceptanceUserId": 20, |
| | | "commonFileListDTO": [ |
| | | { |
| | | "id": 90001, |
| | | "application": "file" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | æ£å¸¸ç¤ºä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "taskId": 1001, |
| | | "taskName": "ç©ºåæºA-01", |
| | | "inspectionProject": "ç¹æ£", |
| | | "inspectorId": "12", |
| | | "inspectionResult": "1", |
| | | "acceptanceUserId": 20 |
| | | } |
| | | ``` |
| | | |
| | | ### 3.2 å表æ¥å£ |
| | | |
| | | `GET /inspectionTask/list` |
| | | |
| | | è¿åå
嫿°å¢åæ®µï¼ |
| | | |
| | | - `inspectionProject` |
| | | - `inspectionResult` |
| | | - `abnormalDescription` |
| | | - `deviceRepairId` |
| | | - `acceptanceUserId` |
| | | - `acceptanceName` |
| | | |
| | | ## 4. 宿¶ä»»å¡æ¥å£ |
| | | |
| | | ### 4.1 ä¿åæ¥å£ |
| | | |
| | | `POST /timingTask/addOrEditTimingTask` |
| | | |
| | | æ°å¢/æ´æ°åæ®µï¼ |
| | | |
| | | | åæ®µ | ç±»å | å¿
å¡« | 说æ | |
| | | |---|---|---|---| |
| | | | inspectionProject | string | å¦ | å·¡æ£é¡¹ç® | |
| | | | remarks | string | å¦ | 夿³¨ | |
| | | | isEnabled | int | å¦ | `0`=ç¦ç¨ï¼`1`=å¯ç¨ï¼ä¸ä¼ é»è®¤å¯ç¨ | |
| | | |
| | | 示ä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "taskName": "ç©ºåæºA-01宿¶å·¡æ£", |
| | | "inspectionProject": "æåº¦å·¡æ£", |
| | | "taskId": 1001, |
| | | "inspectorIds": "12,13", |
| | | "frequencyType": "DAILY", |
| | | "frequencyDetail": "09:00", |
| | | "remarks": "éç¹æ£æ¥è½´æ¿æ¸©åº¦", |
| | | "isEnabled": 1 |
| | | } |
| | | ``` |
| | | |
| | | ### 4.2 å¯ç¨ç¶æè¡ä¸º |
| | | |
| | | 1. `isEnabled=1`ï¼ä»»å¡è¿å
¥è°åº¦ï¼æé¢æ¬¡èªå¨çæå·¡æ£è®°å½ã |
| | | 2. `isEnabled=0`ï¼ä»»å¡ä¸è°åº¦ï¼å·²åå¨è°åº¦ä¼è¢«ç§»é¤ã |
| | | |
| | | ### 4.3 夿³¨å¸¦å
¥è§å |
| | | |
| | | 宿¶ä»»å¡èªå¨çæå·¡æ£è®°å½æ¶ï¼ |
| | | |
| | | 1. å·¡æ£è®°å½å¤æ³¨åºå®åç¼ï¼`èªå¨çæèªå®æ¶ä»»å¡ID: {id}` |
| | | 2. å½å®æ¶ä»»å¡ `remarks` é空æ¶ï¼æ¼æ¥ä¸ºï¼ |
| | | `èªå¨çæèªå®æ¶ä»»å¡ID: {id}ï¼{remarks}` |
| | | |
| | | ## 5. å¼å¸¸èªå¨å»ºç»´ä¿®åè§å |
| | | |
| | | å½å·¡æ£è®°å½ `inspectionResult=0` æ¶ï¼ |
| | | |
| | | 1. è¥ `deviceRepairId` 为空ï¼å端èªå¨å建 `device_repair`ï¼ |
| | | - `deviceLedgerId`ï¼æ¥èª `taskId` |
| | | - `deviceName`ï¼ä¼å
`taskName`ï¼å¦åå设å¤å°è´¦åç§° |
| | | - `remark`ï¼å¼å¸¸æè¿° |
| | | - `status`ï¼`0`ï¼å¾
ç»´ä¿®ï¼ |
| | | 2. è¥å·²æå
³èç»´ä¿®åï¼ä»
åæ¥æ´æ°ç»´ä¿®å `remark`ã |
| | | |
| | | ## 6. å端æ¹é 建议 |
| | | |
| | | 1. å·¡æ£è¡¨åæ°å¢ `inspectionProject` è¾å
¥æ¡ã |
| | | 2. å·¡æ£è¡¨åä¿çâæ£å¸¸/å¼å¸¸âè卿 ¡éªï¼ |
| | | - å¼å¸¸æ¶å¼ºå¶å¼å¸¸æè¿° + è³å°ä¸ç»å¾çã |
| | | 3. 宿¶ä»»å¡è¡¨åæ°å¢âæ¯å¦å¯ç¨âå¼å
³å¹¶æ å° `isEnabled`ã |
| | | 4. 宿¶ä»»å¡è¡¨åæ°å¢ `inspectionProject` ä¸ `remarks` è¾å
¥é¡¹ã |
| | | 5. å·¡æ£å表å±ç¤º `inspectionProject` å `deviceRepairId`ï¼æ¯æè·³è½¬ç»´ä¿®å详æ
ï¼ã |
| | | |
| | | ## 7. èè°éªæ¶æ¸
å |
| | | |
| | | 1. å·¡æ£æ°å¢/ä¿®æ¹å¯æ£ç¡®æäº¤ `inspectionProject` å¹¶å¨åè¡¨åæ¾ã |
| | | 2. å¼å¸¸å·¡æ£ï¼ææè¿°+æå¾ï¼ä¿åæåå¹¶åå¡« `deviceRepairId`ã |
| | | 3. å¼å¸¸å·¡æ£ç¼ºæè¿°æç¼ºå¾çæ¶è¢«æ¦æªã |
| | | 4. 宿¶ä»»å¡ `isEnabled=0` æ¶ä¸å触åèªå¨å·¡æ£è®°å½ã |
| | | 5. 宿¶ä»»å¡ `isEnabled=1` æ¶æé¢æ¬¡çæå·¡æ£è®°å½ã |
| | | 6. 宿¶ä»»å¡æ `remarks` æ¶ï¼èªå¨å·¡æ£è®°å½å¤æ³¨å¸¦ä¸è¯¥å
容ã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # å¶é æºè½å©æå端èè°ææ¡£ï¼`manufacturing-ai`ï¼ |
| | | |
| | | > æ´æ°æ¥æï¼2026-05-16 |
| | | > éç¨æ¨¡åï¼ç产ç°åºã计åãå·¥åã设å¤ãè´¨éãç©æãå¼å¸¸å¤ç |
| | | > è½åèå´ï¼æ¥ãé®ãåãé¢è¦ãåæ |
| | | |
| | | ## 1. æ¥å£æ»è§ |
| | | |
| | | 1. æµå¼å¯¹è¯ï¼`POST /manufacturing-ai/chat` |
| | | 2. ä¼è¯å表ï¼`GET /manufacturing-ai/history/sessions` |
| | | 3. ä¼è¯æ¶æ¯ï¼`GET /manufacturing-ai/history/messages/{memoryId}` |
| | | 4. å é¤ä¼è¯ï¼`DELETE /manufacturing-ai/history/{memoryId}` |
| | | |
| | | 说æï¼ |
| | | - `/chat` 为 **SSE/æµå¼ææ¬** è¿åï¼`text/stream;charset=utf-8`ï¼ã |
| | | - å½ä¸âæ¥/é¢è¦/åæ/åâå·¥å
·æ¶ï¼æµå¼æç»å
å®¹æ¯ **JSON å符串**ï¼ä¸æ¯ `AjaxResult`ï¼ã |
| | | - æªå½ä¸å·¥å
·æ¶ï¼è¿åæ®éèªç¶è¯è¨ææ¬ã |
| | | |
| | | ## 2. é´æä¸è¯·æ±å¤´ |
| | | |
| | | - ç»ä¸ä½¿ç¨ç³»ç»ç»å½æï¼`Authorization` ä¸ç°ææ¥å£ä¸è´ï¼ã |
| | | - `POST /manufacturing-ai/chat` 请æ±å¤´ï¼`Content-Type: application/json`ã |
| | | |
| | | ## 3. å¯¹è¯æ¥å£ |
| | | |
| | | ### 3.1 è¯·æ± |
| | | |
| | | ```http |
| | | POST /manufacturing-ai/chat |
| | | Content-Type: application/json |
| | | ``` |
| | | |
| | | ```json |
| | | { |
| | | "memoryId": "mfg-ai-001", |
| | | "message": "æ¥è®¾å¤è¥¿é¨ååé¢å¨çç»´ä¿®æ
åµ" |
| | | } |
| | | ``` |
| | | |
| | | åæ®µè¯´æï¼ |
| | | |
| | | | åæ®µ | ç±»å | å¿
å¡« | 说æ | |
| | | | --- | --- | --- | --- | |
| | | | memoryId | string | æ¯ | ä¼è¯ IDï¼å端çæå¹¶å¤ç¨ | |
| | | | message | string | æ¯ | ç¨æ·è¾å
¥ | |
| | | |
| | | ### 3.2 è¿åï¼æµå¼ï¼ |
| | | |
| | | ```http |
| | | Content-Type: text/stream;charset=utf-8 |
| | | ``` |
| | | |
| | | å端å¤çå»ºè®®ï¼ |
| | | 1. ææµæ¼æ¥å®æ´ææ¬ã |
| | | 2. å°è¯ `JSON.parse(fullText)`ï¼ |
| | | - æåï¼æç»æåç»ææ¸²æã |
| | | - å¤±è´¥ï¼ææ®éèå¤©ææ¬æ¸²æã |
| | | |
| | | ## 4. ç»æåååºåè®® |
| | | |
| | | ### 4.1 éç¨ç»æ |
| | | |
| | | ```json |
| | | { |
| | | "success": true, |
| | | "type": "manufacturing_device_repair_list", |
| | | "description": "å·²è¿å设å¤ç»´ä¿®è®°å½ã", |
| | | "summary": {}, |
| | | "data": {}, |
| | | "charts": {} |
| | | } |
| | | ``` |
| | | |
| | | ### 4.2 `type` æä¸¾ |
| | | |
| | | | type | åºæ¯ | |
| | | | --- | --- | |
| | | | manufacturing_site_snapshot | ç产ç°åºæ¦è§ | |
| | | | manufacturing_plan_list | çäº§è®¡åæ¥è¯¢ | |
| | | | manufacturing_workorder_list | å·¥åæ¥è¯¢ | |
| | | | manufacturing_device_list | 设å¤å°è´¦æ¥è¯¢ | |
| | | | manufacturing_device_repair_list | 设å¤ç»´ä¿®è®°å½æ¥è¯¢ | |
| | | | manufacturing_quality_list | è´¨éæ¥è¯¢ | |
| | | | manufacturing_material_list | ç©æåºåæ¥è¯¢ | |
| | | | manufacturing_exception_list | å¼å¸¸å¤çæ¥è¯¢ | |
| | | | manufacturing_warning | é¢è¦çæ¿ | |
| | | | manufacturing_analysis | ç»è¥åæ | |
| | | | manufacturing_action_plan | åç建议ï¼å¨ä½å¡ï¼ | |
| | | |
| | | ## 5. âæ¥âè½åèè°è¦ç¹ |
| | | |
| | | ### 5.1 设å¤ç¸å
³è·¯ç±è§åï¼å
³é®ï¼ |
| | | |
| | | - å½ç¨æ·è¾å
¥å
å« `ç»´ä¿®/æ¥ä¿®/æ£ä¿®/ç»´æ¤`ï¼è®¾å¤åä¼è¿å `manufacturing_device_repair_list`ï¼æ¥ `device_repair`ï¼ã |
| | | - æªå
å«ä»¥ä¸è¯æ¶ï¼è¿å `manufacturing_device_list`ï¼æ¥è®¾å¤å°è´¦ï¼ã |
| | | |
| | | 示ä¾ï¼ |
| | | - `æ¥è®¾å¤A-01` -> `manufacturing_device_list` |
| | | - `æ¥è®¾å¤A-01ç»´ä¿®æ
åµ` -> `manufacturing_device_repair_list` |
| | | |
| | | ### 5.2 ç»´ä¿®è®°å½æ¶é´è¿æ»¤è§åï¼å
³é®ï¼ |
| | | |
| | | - ç¨æ·æç¡®å¸¦æ¶é´æ¡ä»¶ï¼å¦âæ¬æ/ä¸å¨/è¿7天/2026-05-01 å° 2026-05-16âï¼æææ¶é´è¿æ»¤ç»´ä¿®è®°å½ã |
| | | - æªå¸¦æ¶é´æ¡ä»¶æ¶ï¼ä¸é»è®¤æè¿ 30 å¤©æªæï¼é¿å
åå²ç»´ä¿®è®°å½è¢«è¯¯è¿æ»¤ã |
| | | |
| | | ### 5.3 å
³é®è¯å¤çè§åï¼è®¾å¤/ç»´ä¿®ï¼ |
| | | |
| | | - ç³»ç»ä¼æ¸
æ´åªé³è¯ï¼`æ¥è¯¢/æ¥ç/请/设å¤/ç»´ä¿®æ
åµ/è®°å½/ä¿¡æ¯` çã |
| | | - åæ¶ä¼éè¿è®¾å¤å°è´¦å¹é
`deviceLedgerId` å
åºï¼ååæ¥ç»´ä¿®è®°å½ï¼éä½âææ°æ®ä½æ¥ä¸å°âçæ¦çã |
| | | |
| | | ### 5.4 åè¡¨ç»æçº¦å® |
| | | |
| | | - åè¡¨æ°æ®ç»ä¸å¨ `data.items` |
| | | - ç»è®¡æè¦å¨ `summary` |
| | | |
| | | 常ç¨åæ®µï¼ |
| | | |
| | | | type | 常ç¨å段 | |
| | | | --- | --- | |
| | | | manufacturing_plan_list | `mpsNo`, `requiredDate`, `status` | |
| | | | manufacturing_workorder_list | `workOrderNo`, `planStartTime`, `planEndTime`, `status` | |
| | | | manufacturing_device_list | `deviceName`, `deviceModel`, `pendingRepairCount` | |
| | | | manufacturing_device_repair_list | `deviceName`, `deviceModel`, `repairTime`, `repairName`, `maintenanceName`, `status`, `createTime` | |
| | | |
| | | ## 6. âé¢è¦âèè°è¦ç¹ |
| | | |
| | | - `type = manufacturing_warning` |
| | | - é¢è¦æç»å¨ `data.items`ï¼æ¯é¡¹å
å«ï¼ |
| | | - `level`ï¼`high` / `medium` |
| | | - `title` |
| | | - `count` |
| | | - `detail` |
| | | |
| | | ç¶æå£å¾ï¼ |
| | | - 设å¤âå¾
ç»´ä¿®âç»è®¡æ `status = 0` 计ç®ï¼ä¸åæå
¶ä»ç¶æè®¡å
¥å¾
ç»´ä¿®ï¼ã |
| | | |
| | | ## 7. âåæâèè°è¦ç¹ |
| | | |
| | | - `type = manufacturing_analysis` |
| | | - å
³é®ææ å¨ `summary` |
| | | - ææ å¡å¨ `data.coreMetrics` |
| | | - å¾è¡¨é
ç½®å¨ `charts`ï¼ |
| | | - `charts.domainBarOption` |
| | | - `charts.qualityPieOption` |
| | | |
| | | å¾è¡¨é
ç½®å¯ç´æ¥ç» ECharts 使ç¨ã |
| | | |
| | | ## 8. âåâè½åèè°è¦ç¹ |
| | | |
| | | å½åâåâ为 **åç建议模å¼**ï¼AI è¾åºå¨ä½å¡ï¼å端确认åè°ç¨ç®æ ä¸å¡æ¥å£ï¼ã |
| | | |
| | | - `type = manufacturing_action_plan` |
| | | - å¨ä½å¡æ°ç»ï¼`data.actionCards` |
| | | |
| | | å¨ä½å¡åæ®µï¼ |
| | | |
| | | | åæ®µ | 说æ | |
| | | | --- | --- | |
| | | | code | å¨ä½ç¼ç | |
| | | | name | å¨ä½åç§° | |
| | | | method | è¯·æ±æ¹æ³ | |
| | | | targetApi | ç®æ ä¸å¡æ¥å£ | |
| | | | requiredFields | å¿
å¡«åæ®µ | |
| | | | examplePayload | 示ä¾åæ° | |
| | | | description | 说æ | |
| | | |
| | | å
ç½®å¨ä½ç¤ºä¾ï¼ |
| | | 1. `POST /productionOperationTask/assign` |
| | | 2. `POST /device/repair` |
| | | 3. `POST /quality/qualityUnqualified/deal` |
| | | 4. `POST /stockInventory/addstockInventory` |
| | | 5. `POST /procurementExceptionRecord/add` |
| | | |
| | | ## 9. ä¼è¯ç®¡çæ¥å£ |
| | | |
| | | ### 9.1 ä¼è¯å表 |
| | | |
| | | ```http |
| | | GET /manufacturing-ai/history/sessions |
| | | ``` |
| | | |
| | | `AjaxResult.data` åæ®µï¼ |
| | | - `memoryId` |
| | | - `title` |
| | | - `lastMessage` |
| | | - `messageCount` |
| | | - `lastChatTime` |
| | | |
| | | ### 9.2 ä¼è¯æ¶æ¯ |
| | | |
| | | ```http |
| | | GET /manufacturing-ai/history/messages/{memoryId} |
| | | ``` |
| | | |
| | | `AjaxResult.data` åæ®µï¼ |
| | | - `role`ï¼`user` / `assistant` / `system` / `tool` |
| | | - `content` |
| | | - `filePaths` |
| | | |
| | | ### 9.3 å é¤ä¼è¯ |
| | | |
| | | ```http |
| | | DELETE /manufacturing-ai/history/{memoryId} |
| | | ``` |
| | | |
| | | è¿åæ å `AjaxResult`ã |
| | | |
| | | ## 10. é误ä¸è¾¹ç |
| | | |
| | | `/chat` 常è§è¿åææ¬ï¼ |
| | | - `memoryIdä¸è½ä¸ºç©º` |
| | | - `messageä¸è½ä¸ºç©º` |
| | | |
| | | 建议å端åéåå
åå¿
å¡«æ ¡éªã |
| | | |
| | | ## 11. å端èè°æµç¨å»ºè®® |
| | | |
| | | 1. ç»å½åå建并å¤ç¨ `memoryId`ã |
| | | 2. è°ç¨ `/manufacturing-ai/chat`ï¼æ SSE æ¼æ¥å®æ´ææ¬ã |
| | | 3. å
å°è¯ JSON è§£æï¼ |
| | | - æåï¼æ `type` è·¯ç±å°å¯¹åº UIï¼å表/é¢è¦/åæ/å¨ä½å¡ï¼ã |
| | | - å¤±è´¥ï¼ææ®éèå¤©æ¶æ¯å±ç¤ºã |
| | | 4. âåâåºæ¯ç±ç¨æ·ç¡®è®¤å¨ä½å¡åï¼å端è°ç¨ `targetApi` 宿ä¸å¡æäº¤ã |
| | | 5. éè¿å岿¥å£åä¼è¯åæ¾ä¸å é¤ã |
| | | |
| | | ## 12. å端éæçº¦æï¼æ¬æ¬¡è¡¥å
ï¼ |
| | | |
| | | ### 12.1 æºè½ä½æ°å¢ä¸å¼¹çªåæ¥è§åï¼å¼ºå¶ï¼ |
| | | |
| | | 1. å½ `src/views/aiIndustrialBrain/index.vue` æ°å¢æºè½ä½ï¼`agents`ï¼é»è¾æ¶ï¼å¿
é¡»åæ¥ç¡®è®¤å¼¹çªå©æå¯ç¨æ§ã |
| | | 2. å¼¹çªå©æç»ä¸ç± `src/components/AIChatSidebar/assistants/index.js` ç `assistantRegistry` 注åã |
| | | 3. æ°å¢æºè½ä½ç `key` è¥è¦å¨å¼¹çªä¸å¯ç¨ï¼å¿
é¡»å¨ `assistantRegistry` 䏿ä¾ååé
ç½®ã |
| | | 4. æªå¨ `assistantRegistry` 注åçæºè½ä½ï¼å¼¹çªæ¾ç¤ºä¸º `pending`ï¼å¼åä¸ï¼æã |
| | | |
| | | ### 12.2 çäº§å©ææ¥å
¥çº¦å® |
| | | |
| | | 1. çäº§å©æé
ç½®ä½äº `src/components/AIChatSidebar/assistants/productionAssistant.js`ï¼`apiBase = /manufacturing-ai`ã |
| | | 2. AI å·¥ä¸å¤§èä¸ç产æºè½ä½è¿å
¥å¼¹çªåï¼é»è®¤ä½¿ç¨ `production` 婿ã |
| | | 3. å
¨å±å³ä¾§å¯¹è¯æ¡å©æåæ¢å表已å
å«ï¼ |
| | | - `general`ï¼å¾
åå©çï¼ |
| | | - `purchase`ï¼éè´å©çï¼ |
| | | - `production`ï¼ç产å©çï¼ |
| | | |
| | | ### 12.3 åæ®µä¸æåå±ç¤ºè§å |
| | | |
| | | 1. é¢åä¸å¡ç¨æ·çåæ®µåãæ ç¾ãå¿
å¡«æç¤ºä¸ç´æ¥å±ç¤ºè±æ keyã |
| | | 2. `requiredFields`ã`missingFields` æç¤ºé转æ¢ä¸ºä¸æè·¯å¾æ ç¾ï¼ç¤ºä¾ï¼`缺å°å¿
å¡«åæ®µï¼å·¥åå·ã计åç»ææ¶é´`ï¼ã |
| | | 3. ç»æåå表ååãæè¦ææ ãå¨ä½å¡å段ä¼å
æ¾ç¤ºä¸æï¼è±æ key ä»
ç¨äºæ¥å£éä¿¡ä¸è°è¯ã |
| | | |
| | | ## 13. æ¬æ¬¡æ´æ°è®°å½ï¼2026-05-16ï¼ |
| | | |
| | | 1. æ°å¢è®¾å¤ç»´ä¿®è®°å½è¿åç±»åï¼`manufacturing_device_repair_list`ã |
| | | 2. ä¿®æ£è®¾å¤åæå¾åæµï¼`ç»´ä¿®/æ¥ä¿®/æ£ä¿®/ç»´æ¤` 走维修记å½ï¼ä¸å误走设å¤å表ã |
| | | 3. ä¿®æ£ç»´ä¿®è®°å½æ¶é´è¿æ»¤ï¼ä»
å¨ç¨æ·æç¡®æ¶é´æ¡ä»¶æ¶çæã |
| | | 4. ä¿®æ£å¾
ç»´ä¿®ç»è®¡å£å¾ï¼æ `status = 0` ç»è®¡ã |
| | | 5. æ°å¢ AI å·¥ä¸å¤§èæºè½ä½ä¸å¼¹çªåæ¥ç»´æ¤è§åï¼æ°å¢æºè½ä½å¿
é¡»åæ¥æ³¨åå¼¹çªå©æã |
| | | 6. çäº§å©æå·²æ¥å
¥å·¥ä¸å¤§èå¼¹çªä¸å
¨å±å³ä¾§å¯¹è¯æ¡å©æåæ¢ã |
| | | 7. å¢å åæ®µä¸æåå±ç¤ºçº¦æï¼é¿å
è±æåæ®µå¯¹ä¸å¡ç¨æ·ç´åºã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # éå®å©æå端èè°ææ¡£ï¼`/sales-ai`ï¼ |
| | | > æ´æ°æ¶é´ï¼2026-05-18 |
| | | > éç¨æ¨¡åï¼å®¢æ·æ¡£æ¡ï¼ç§æµ·/å
¬æµ·ï¼ãé宿¥ä»·ãéå®å°è´¦ãéå®éè´§ã客æ·å¾æ¥ãåè´§å°è´¦ãææ ç»è®¡ |
| | | > éç¹è½åï¼å®¢æ·æµå¤±é£é©åæã忬¾ä¸æ¥ä»·çç¥å»ºè®® |
| | | |
| | | ## 1. æ¥å£æ»è§ |
| | | |
| | | 1. æµå¼å¯¹è¯ï¼`POST /sales-ai/chat` |
| | | 2. ä¼è¯å表ï¼`GET /sales-ai/history/sessions` |
| | | 3. ä¼è¯æ¶æ¯ï¼`GET /sales-ai/history/messages/{memoryId}` |
| | | 4. å é¤ä¼è¯ï¼`DELETE /sales-ai/history/{memoryId}` |
| | | |
| | | 说æï¼ |
| | | - `/chat` è¿å `text/stream;charset=utf-8`ï¼SSE ææ¬æµï¼ã |
| | | - å½ä¸å·¥å
·æ¶ï¼æç»å
容为 **JSON å符串**ï¼é `AjaxResult`ï¼ã |
| | | - æªå½ä¸å·¥å
·æ¶ï¼è¿åæ®éä¸æææ¬ã |
| | | |
| | | ## 2. å¯¹è¯æ¥å£ |
| | | |
| | | ### 2.1 è¯·æ± |
| | | |
| | | ```http |
| | | POST /sales-ai/chat |
| | | Content-Type: application/json |
| | | ``` |
| | | |
| | | ```json |
| | | { |
| | | "memoryId": "sales-ai-001", |
| | | "message": "帮æåå®¢æ·æµå¤±é£é©åæï¼è¿90天ï¼å10æ¡" |
| | | } |
| | | ``` |
| | | |
| | | åæ®µè¯´æï¼ |
| | | |
| | | | åæ®µ | ç±»å | å¿
å¡« | 说æ | |
| | | | --- | --- | --- | --- | |
| | | | `memoryId` | string | æ¯ | ä¼è¯ IDï¼å端çæå¹¶å¤ç¨ | |
| | | | `message` | string | æ¯ | ç¨æ·è¾å
¥ | |
| | | |
| | | ### 2.2 è¿åå¤ç |
| | | |
| | | å端建议æµç¨ï¼ |
| | | 1. å
ææµæ¼æ¥å®æ´ææ¬ `fullText`ã |
| | | 2. å°è¯ `JSON.parse(fullText)`ï¼ |
| | | - æåï¼æ `type` è·¯ç±å°ç»æåç»ä»¶ã |
| | | - å¤±è´¥ï¼ææ®éèå¤©ææ¬å±ç¤ºã |
| | | |
| | | ## 3. ç»æåååºåè®® |
| | | |
| | | ### 3.1 éç¨ç»æ |
| | | |
| | | ```json |
| | | { |
| | | "success": true, |
| | | "type": "sales_dashboard", |
| | | "description": "å·²è¿åé宿æ ç»è®¡", |
| | | "summary": {}, |
| | | "data": {}, |
| | | "charts": {} |
| | | } |
| | | ``` |
| | | |
| | | ### 3.2 `type` æä¸¾ |
| | | |
| | | | type | åºæ¯ | |
| | | | --- | --- | |
| | | | `sales_customer_profile_list` | å®¢æ·æ¡£æ¡ï¼ç§æµ·/å
¬æµ·ï¼ | |
| | | | `sales_quotation_list` | é宿¥ä»· | |
| | | | `sales_ledger_list` | éå®å°è´¦ | |
| | | | `sales_return_list` | éå®éè´§ | |
| | | | `sales_customer_interaction_list` | 客æ·å¾æ¥ï¼åæ¬¾ï¼ | |
| | | | `sales_shipping_list` | åè´§å°è´¦ | |
| | | | `sales_dashboard` | ææ ç»è®¡ | |
| | | | `sales_customer_churn_risk` | å®¢æ·æµå¤±é£é©åæ | |
| | | | `sales_collection_quote_strategy` | 忬¾ä¸æ¥ä»·çç¥å»ºè®® | |
| | | |
| | | ## 4. èåè½åæ å°ï¼å¯¹åºè¥é管çï¼ |
| | | |
| | | 1. å®¢æ·æ¡£æ¡ï¼ç§æµ·ï¼ï¼ç¤ºä¾æé® `æ¥è¯¢ç§æµ·å®¢æ·æ¡£æ¡å10æ¡` |
| | | 2. å®¢æ·æ¡£æ¡ï¼å
¬æµ·ï¼ï¼ç¤ºä¾æé® `æ¥è¯¢å
¬æµ·å®¢æ·æ¡£æ¡` |
| | | 3. é宿¥ä»·ï¼ç¤ºä¾æé® `æ¥è¯¢æ¬æé宿¥ä»·` |
| | | 4. éå®å°è´¦ï¼ç¤ºä¾æé® `æ¥è¯¢æ¬æéå®å°è´¦` |
| | | 5. éå®éè´§ï¼ç¤ºä¾æé® `æ¥è¯¢è¿30天éå®éè´§` |
| | | 6. 客æ·å¾æ¥ï¼ç¤ºä¾æé® `æ¥è¯¢è¿30天客æ·åæ¬¾å¾æ¥` |
| | | 7. åè´§å°è´¦ï¼ç¤ºä¾æé® `æ¥è¯¢æ¬æåè´§å°è´¦` |
| | | 8. ææ ç»è®¡ï¼ç¤ºä¾æé® `æ¥çé宿æ ç»è®¡` |
| | | |
| | | ## 5. éç¹è½åèè° |
| | | |
| | | ### 5.1 å®¢æ·æµå¤±é£é©åæï¼`sales_customer_churn_risk`ï¼ |
| | | |
| | | æ°æ®ä½ç½®ï¼ |
| | | - å表ï¼`data.items` |
| | | - æ±æ»ï¼`summary.highRiskCount / mediumRiskCount / lowRiskCount` |
| | | - å¾è¡¨ï¼`charts.riskLevelPieOption`ã`charts.riskScoreBarOption` |
| | | |
| | | å项常ç¨åæ®µï¼ |
| | | - `customerName` |
| | | - `riskLevel`ï¼`high`/`medium`/`low`ï¼ |
| | | - `riskScore`ï¼0-100ï¼ |
| | | - `pendingAmount` |
| | | - `pendingRate` |
| | | - `daysSinceLastOrder` |
| | | - `riskReasons`ï¼å符串æ°ç»ï¼ |
| | | |
| | | ### 5.2 忬¾ä¸æ¥ä»·çç¥å»ºè®®ï¼`sales_collection_quote_strategy`ï¼ |
| | | |
| | | æ°æ®ä½ç½®ï¼ |
| | | - çç¥å¡ï¼`data.items` |
| | | - æ±æ»ï¼`summary.highPriorityCount / mediumPriorityCount / lowPriorityCount` |
| | | - å¾è¡¨ï¼`charts.pendingAmountBarOption`ã`charts.priorityPieOption` |
| | | |
| | | å项常ç¨åæ®µï¼ |
| | | - `customerName` |
| | | - `priority`ï¼`high`/`medium`/`low`ï¼ |
| | | - `pendingAmount` |
| | | - `quoteConversionRate` |
| | | - `collectionStrategy` |
| | | - `quotationStrategy` |
| | | - `nextAction` |
| | | |
| | | ## 6. ææ ç»è®¡èè°ï¼`sales_dashboard`ï¼ |
| | | |
| | | å
³é®åæ®µï¼ |
| | | - `summary.contractAmountTotal` |
| | | - `summary.receivedAmountTotal` |
| | | - `summary.pendingAmountTotal` |
| | | - `summary.shipRate` |
| | | |
| | | å¾è¡¨å段ï¼å¯ç´æ¥ç» EChartsï¼ï¼ |
| | | - `charts.amountBarOption` |
| | | - `charts.shippingPieOption` |
| | | - `charts.customerTopBarOption` |
| | | - `charts.contractTrendLineOption` |
| | | |
| | | éå æ°æ®ï¼ |
| | | - `data.topCustomers` |
| | | - `data.contractTrend` |
| | | |
| | | ## 7. ä¼è¯å岿¥å£ |
| | | |
| | | ### 7.1 ä¼è¯å表 |
| | | |
| | | ```http |
| | | GET /sales-ai/history/sessions |
| | | ``` |
| | | |
| | | è¿å `AjaxResult.data` åæ®µï¼ |
| | | - `memoryId` |
| | | - `title` |
| | | - `lastMessage` |
| | | - `messageCount` |
| | | - `lastChatTime` |
| | | |
| | | ### 7.2 ä¼è¯æ¶æ¯ |
| | | |
| | | ```http |
| | | GET /sales-ai/history/messages/{memoryId} |
| | | ``` |
| | | |
| | | è¿å `AjaxResult.data` åæ®µï¼ |
| | | - `role`ï¼`user` / `assistant` / `system` / `tool` |
| | | - `content` |
| | | - `filePaths`ï¼å½åéå®å©ææªä½¿ç¨æä»¶åæï¼å¯å¿½ç¥ï¼ |
| | | |
| | | ### 7.3 å é¤ä¼è¯ |
| | | |
| | | ```http |
| | | DELETE /sales-ai/history/{memoryId} |
| | | ``` |
| | | |
| | | è¿åæ å `AjaxResult`ã |
| | | |
| | | ## 8. å端æ¥å
¥çº¦æ |
| | | |
| | | 1. æ°å¢å©æé
ç½®æ¶ï¼`assistantRegistry` å¿
须注å `sales`ï¼æä½ æ¹çº¦å® keyï¼ï¼å¹¶æå `apiBase = /sales-ai`ã |
| | | 2. ç»æåæ¸²æå¿
é¡»åºäº `type` ååï¼ä¸è¦ä»
é å
³é®è¯ã |
| | | 3. è天渲æéä¿çâææ¬å
åºâï¼é¿å
JSON è§£æå¤±è´¥æ¶é¡µé¢ç©ºç½ã |
| | | 4. ä¸å¡å±ç¤ºåæ®µå»ºè®®ä¸æåï¼ä¸ç´æ¥å±ç¤ºè±æå段 keyã |
| | | |
| | | ## 9. èè°éªæ¶æ¸
å |
| | | |
| | | 1. è½æ£å¸¸æµå¼æ¥æ¶ `/sales-ai/chat` ååºå¹¶æ¼æ¥ææ¬ã |
| | | 2. è½æ `type` æ£ç¡®æ¸²æ 9 ç±»ç»æåç»æã |
| | | 3. è½æ£ç¡®å±ç¤ºâå®¢æ·æµå¤±é£é©åæâåâ忬¾ä¸æ¥ä»·çç¥å»ºè®®â两个éç¹åºæ¯ã |
| | | 4. ä¼è¯å表ãä¼è¯æ¶æ¯ãå é¤ä¼è¯å
¨é¾è·¯å¯ç¨ã |
| | | 5. `memoryId` å¤ç¨åå¯åçåå²ï¼ä¸ä¼ä¸²ä¼è¯ã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # é¦é¡µçäº§çæ¿å端èè°ææ¡£ |
| | | |
| | | æ´æ°æ¶é´ï¼2026-05-20 |
| | | 模åï¼`/home`ï¼é¦é¡µï¼ |
| | | |
| | | ## 1. æ¥å£æ¸
å |
| | | |
| | | 1. `GET /home/productionOverview`ï¼ç产æ»è§ |
| | | 2. `GET /home/productionRealtimeBoard`ï¼çäº§å®æ¶çæ¿ |
| | | 3. `GET /home/productionOrderProgress`ï¼ç产订åè¿åº¦ |
| | | 4. `GET /home/todayProductionPlan`ï¼ä»æ¥ç产计å |
| | | |
| | | æææ¥å£ç»ä¸è¿å `AjaxResult`ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "code": 200, |
| | | "msg": "æä½æå", |
| | | "data": {} |
| | | } |
| | | ``` |
| | | |
| | | ## 2. ç产æ»è§ |
| | | |
| | | ### 2.1 è¯·æ± |
| | | |
| | | ```http |
| | | GET /home/productionOverview |
| | | ``` |
| | | |
| | | ### 2.2 è¿å `data` |
| | | |
| | | ```json |
| | | { |
| | | "totalOutput": 1280.00, |
| | | "totalScrap": 25.00, |
| | | "yieldRate": 98.08 |
| | | } |
| | | ``` |
| | | |
| | | åæ®µè¯´æï¼ |
| | | |
| | | - `totalOutput`ï¼ç´¯è®¡äº§åºï¼ä»¶ï¼åæ ¼æ°ï¼ |
| | | - `totalScrap`ï¼ç´¯è®¡æ¥åºï¼ä»¶ï¼ |
| | | - `yieldRate`ï¼è¯çï¼0-100ï¼å端å±ç¤ºæ¶å¯æ¼æ¥ `%`ï¼ |
| | | |
| | | ## 3. çäº§å®æ¶çæ¿ |
| | | |
| | | ### 3.1 è¯·æ± |
| | | |
| | | ```http |
| | | GET /home/productionRealtimeBoard |
| | | ``` |
| | | |
| | | ### 3.2 è¿å `data` |
| | | |
| | | ```json |
| | | { |
| | | "deviceOee": { |
| | | "value": 74.00, |
| | | "compareYesterday": 2.50 |
| | | }, |
| | | "orderAchievementRate": { |
| | | "value": 81.30, |
| | | "compareYesterday": -1.20 |
| | | }, |
| | | "defectRate": { |
| | | "value": 1.40, |
| | | "compareYesterday": 0.30 |
| | | } |
| | | } |
| | | ``` |
| | | |
| | | åæ®µè¯´æï¼ |
| | | |
| | | - `value`ï¼å½æ¥ææ å¼ï¼0-100ï¼ |
| | | - `compareYesterday`ï¼è¾æ¨æ¥ååå¼ï¼å¯æ£å¯è´ï¼åç«¯ææ£è´å³å®ç®å¤´æ¹ååé¢è²ï¼ |
| | | |
| | | ## 4. ç产订åè¿åº¦ |
| | | |
| | | ### 4.1 è¯·æ± |
| | | |
| | | ```http |
| | | GET /home/productionOrderProgress?tab=all&pageNum=1&pageSize=10 |
| | | ``` |
| | | |
| | | åæ°ï¼ |
| | | |
| | | - `tab`ï¼`all` / `inProgress` / `completed` / `paused` |
| | | - `pageNum`ï¼é¡µç ï¼é»è®¤ `1`ï¼ |
| | | - `pageSize`ï¼æ¯é¡µæ¡æ°ï¼é»è®¤ `10`ï¼æå¤§ `50`ï¼ |
| | | |
| | | ### 4.2 è¿å `data` |
| | | |
| | | ```json |
| | | { |
| | | "tab": "all", |
| | | "total": 24, |
| | | "pageNum": 1, |
| | | "pageSize": 10, |
| | | "inProgressCount": 6, |
| | | "completedCount": 12, |
| | | "pausedCount": 2, |
| | | "records": [ |
| | | { |
| | | "orderNo": "MO-20260518-001", |
| | | "productName": "æºè½æ§å¶å¨", |
| | | "plannedQuantity": 1000.00, |
| | | "completedQuantity": 860.00, |
| | | "completionRate": 86.00, |
| | | "dueDate": "2026-05-20", |
| | | "status": 2, |
| | | "statusLabel": "è¿è¡ä¸" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | åæ®µè¯´æï¼ |
| | | |
| | | - `completionRate`ï¼å®æçï¼0-100ï¼ |
| | | - `status`ï¼åç«¯ç¶æç ï¼`1`å¾
å¼å§ï¼`2`è¿è¡ä¸ï¼`3`已宿ï¼`4`å·²æåï¼ |
| | | - `statusLabel`ï¼ç¶æä¸æå±ç¤ºå¼ |
| | | |
| | | ## 5. 仿¥ç产计å |
| | | |
| | | ### 5.1 è¯·æ± |
| | | |
| | | ```http |
| | | GET /home/todayProductionPlan?limit=4 |
| | | ``` |
| | | |
| | | åæ°ï¼ |
| | | |
| | | - `limit`ï¼è¿åæ¡æ°ï¼é»è®¤ `4`ï¼æå¤§ `20`ï¼ |
| | | |
| | | ### 5.2 è¿å `data` |
| | | |
| | | ```json |
| | | { |
| | | "total": 9, |
| | | "records": [ |
| | | { |
| | | "orderNo": "MO-20260518-004", |
| | | "productName": "ç»æä»¶A", |
| | | "plannedQuantity": 1200.00, |
| | | "dueDate": "2026-05-15", |
| | | "status": 2, |
| | | "statusLabel": "è¿è¡ä¸" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | ## 6. å端å±ç¤ºçº¦å® |
| | | |
| | | - ç¾åæ¯å段ç»ä¸æ¯æ°å¼ï¼å¦ `74.00`ï¼ï¼å端èªè¡æ¼æ¥ `%`ã |
| | | - æææ°å¼ä¿ç两ä½å°æ°ã |
| | | - `dueDate` å¯è½ä¸º `null`ï¼å端éå
åºå±ç¤ºï¼å¦ `--`ï¼ã |
| | | - `compareYesterday` æ£è´é½å¯è½åºç°ï¼å»ºè®®æ `>0` ä¸åã`<0` ä¸éã`=0` æå¹³å¤çã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # é¦é¡µçäº§çæ¿æ§è½ä¼ååç«¯åæ´ææ¡£ |
| | | |
| | | æ´æ°æ¶é´ï¼2026-05-20 |
| | | éç¨é¡µé¢ï¼é¦é¡µ |
| | | æ¶ååºåï¼ |
| | | |
| | | 1. ç产订åè¿åº¦ |
| | | 2. 仿¥ç产计å |
| | | |
| | | ## 1. æ¬æ¬¡ä¼åç®æ |
| | | |
| | | éå¯¹å¤§æ°æ®éåºæ¯ï¼è®¢åæ°éå¤ãç产åå²é¿ï¼ä¼åæ¥è¯¢æ§è½ï¼éä½é¦é¡µæ¥å£ååºæ¶é´åå
åå ç¨ã |
| | | |
| | | ## 2. æ¶åæ¥å£ |
| | | |
| | | 1. `GET /home/productionOrderProgress` |
| | | 2. `GET /home/todayProductionPlan` |
| | | |
| | | ## 3. å端æ¯å¦éè¦æ¹ä»£ç |
| | | |
| | | ç»è®ºï¼**æ å¼ºå¶æ¹å¨ï¼æ¥å£å
¥åä¸è¿åç»æä¿æå
¼å®¹**ã |
| | | ä½ ç°æé¡µé¢å¯ä»¥ç´æ¥èè°ï¼ä¸éè¦æ¹å段æ å°ã |
| | | |
| | | ## 4. æ¥å£è¯´æï¼ä¿æä¸åï¼ |
| | | |
| | | ### 4.1 ç产订åè¿åº¦ |
| | | |
| | | 请æ±ï¼ |
| | | |
| | | ```http |
| | | GET /home/productionOrderProgress?tab=all&pageNum=1&pageSize=10 |
| | | ``` |
| | | |
| | | åæ°ï¼ |
| | | |
| | | - `tab`ï¼`all` / `inProgress` / `completed` / `paused` |
| | | - `pageNum`ï¼é¡µç ï¼é»è®¤ `1` |
| | | - `pageSize`ï¼æ¯é¡µæ¡æ°ï¼é»è®¤ `10`ï¼æå¤§ `50` |
| | | |
| | | è¿å `data`ï¼ç»æä¸åï¼ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "tab": "all", |
| | | "total": 1200, |
| | | "pageNum": 1, |
| | | "pageSize": 10, |
| | | "inProgressCount": 180, |
| | | "completedCount": 900, |
| | | "pausedCount": 20, |
| | | "records": [ |
| | | { |
| | | "orderNo": "MO-20260518-001", |
| | | "productName": "æºè½æ§å¶å¨", |
| | | "plannedQuantity": 1000.00, |
| | | "completedQuantity": 860.00, |
| | | "completionRate": 86.00, |
| | | "dueDate": "2026-05-20", |
| | | "status": 2, |
| | | "statusLabel": "è¿è¡ä¸" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | ### 4.2 仿¥ç产计å |
| | | |
| | | 请æ±ï¼ |
| | | |
| | | ```http |
| | | GET /home/todayProductionPlan?limit=4 |
| | | ``` |
| | | |
| | | åæ°ï¼ |
| | | |
| | | - `limit`ï¼è¿åæ¡æ°ï¼é»è®¤ `4`ï¼æå¤§ `20` |
| | | |
| | | è¿å `data`ï¼ç»æä¸åï¼ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "total": 230, |
| | | "records": [ |
| | | { |
| | | "orderNo": "MO-20260518-004", |
| | | "productName": "ç»æä»¶A", |
| | | "plannedQuantity": 1200.00, |
| | | "dueDate": "2026-05-15", |
| | | "status": 2, |
| | | "statusLabel": "è¿è¡ä¸" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | ## 5. å端ä¼åç¹ï¼ä¾åç«¯ç¥æï¼ |
| | | |
| | | 1. 订åè¿åº¦ä¸ä»æ¥è®¡åæ¹ä¸ºè½»é SQLï¼ä»
æ¥è¯¢é¦é¡µå¿
éåæ®µã |
| | | 2. 廿äºé¦é¡µæ¥è¯¢è·¯å¾ä¸ä¸å¿
è¦ç大å
³èãå¾çå¡«å
å对象è£
é
ã |
| | | 3. ç¶æç»è®¡æ¹ä¸ºæ°æ®åºèå计æ°ï¼ä¸åéæ¡æå计ç®ã |
| | | 4. å页䏿¡æ°ä¸éä¿çï¼`pageSize <= 50`, `limit <= 20`ï¼ã |
| | | |
| | | ## 6. å端建议 |
| | | |
| | | 1. 忢 `tab` æ¶ä¿çç°æè°ç¨æ¹å¼å³å¯ã |
| | | 2. `dueDate` å¯è½ä¸ºç©ºï¼ç»§ç»æ `--` å
åºå±ç¤ºã |
| | | 3. ç¾åæ¯å段ä»ä¸ºæ°å¼ï¼å端继ç»è¿½å `%` å±ç¤ºã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # éè´æºè½ä½ä¼ååç«¯åæ´ææ¡£ |
| | | |
| | | ## 1. åæ´èæ¯ |
| | | |
| | | æ¬æ¬¡é对éè´æºè½ä½åäºå¯¹é½ä¼åï¼åèéå®/审æ¹/å¶é æºè½ä½ï¼ï¼ |
| | | |
| | | 1. æå `quickPrompts` å½ä¸ç¨³å®æ§ã |
| | | 2. å¢å¼ºç¸å¯¹æ¶é´è¯å«ï¼ä»å¤©/æ¨å¤©/æ¬å¨/ä¸å¨/æ¬æ/䏿/ä»å¹´/å»å¹´/è¿N天çï¼ã |
| | | 3. å¢å ä¸å¡æå¾æªè¯å«æ¶çç»æåå
åºååºï¼é¿å
ç¼é æ°æ®ã |
| | | 4. è¡¥å
å¾
仿¬¾æ¥è¯¢çæ±æ»å段ï¼ä¾¿äºåç«¯ç´æ¥æ¸²æç»è®¡å¡çã |
| | | |
| | | ## 2. æ¥å£å½±åæ¦è§ |
| | | |
| | | | æ¥å£ | æ¹æ³ | æ¯å¦æ¹è·¯å¾ | æ¯å¦æ¹å
¥å | æ¯å¦æ¹è¿åç»æ | |
| | | | --- | --- | --- | --- | --- | |
| | | | `/purchase-ai/chat` | POST(SSE) | å¦ | å¦ | æ¯ï¼æ°å¢å
åº JSON ç±»åï¼ | |
| | | | `/purchase-ai/analyze-files` | POST(SSE) | å¦ | å¦ | å¦ï¼ä»
å
é¨æç¤ºè¯å¢å¼ºï¼ | |
| | | |
| | | ## 3. æ°å¢å
åºååºï¼éç¹ï¼ |
| | | |
| | | å½ç¨æ·ææ¾å¨é®éè´ä¸å¡ï¼ä½æ¡ä»¶ä¸å
å䏿ªå½ä¸å¯æ§è¡æå¾æ¶ï¼`/purchase-ai/chat` ä¼ç´æ¥è¿åç»æå JSONï¼è䏿¯èªç±ææ¬ï¼ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "success": false, |
| | | "type": "purchase_intent_not_recognized", |
| | | "description": "æªè¯å«å°å¯æ§è¡çéè´æ¥è¯¢æ¡ä»¶ã为ä¿è¯ç»æåç¡®ï¼å½åä¸ä¼æ¨æµæç¼é æ°æ®ï¼è¯·è¡¥å
æç¡®æ¶é´èå´ãä¾åºåãéè´ååå·æç©æååæ¥è¯¢ã", |
| | | "summary": {}, |
| | | "data": { |
| | | "quickPrompts": [ |
| | | "æ¬æéè´é颿åååçç©ææåªäºï¼", |
| | | "åªäºéè´è®¢åè¿æªå
¥åºï¼", |
| | | "æè¿7天ä¾åºåå°è´§å¼å¸¸æåªäºï¼", |
| | | "帮æç»è®¡å¾
仿¬¾éè´åï¼", |
| | | "ååºæ¬æéè´éè´§æ
åµ" |
| | | ] |
| | | }, |
| | | "charts": {} |
| | | } |
| | | ``` |
| | | |
| | | å端å¤çå»ºè®®ï¼ |
| | | |
| | | 1. å½ `type === "purchase_intent_not_recognized"` æ¶ï¼å±ç¤º `description`ã |
| | | 2. 读å `data.quickPrompts` ä½ä¸ºå¿«æ·æé®æé®ï¼å¯ç´æ¥åå¡«è¾å
¥æ¡ï¼ã |
| | | |
| | | ## 4. å¾
仿¬¾è¿åæ°å¢æ±æ»å段 |
| | | |
| | | æ¥å£ç±»åï¼`type = "purchase_pending_payment_list"` |
| | | ä½ç½®ï¼`summary` |
| | | |
| | | æ°å¢åæ®µï¼ |
| | | |
| | | | åæ®µ | ç±»å | 说æ | |
| | | | --- | --- | --- | |
| | | | pendingOrderCount | number | å¾
仿¬¾è®¢åæ° | |
| | | | totalContractAmount | number | å¾
仿¬¾è®¢åååæ»é¢ | |
| | | | totalPaidAmount | number | 已仿¬¾æ»é¢ | |
| | | | totalPendingAmount | number | å¾
仿¬¾æ»é¢ | |
| | | |
| | | 说æï¼åæå段ä»ä¿çï¼å
¼å®¹ï¼ï¼æ¬æ¬¡ä¸ºå¢éåæ®µï¼ä¸ç ´åç°ææ¸²æã |
| | | |
| | | ## 5. æ¶é´å£å¾ä¼å |
| | | |
| | | éè´æºè½ä½ç°å¨ç»ä¸æä¸å½æ¶åºå¨ææ¥ææ¢ç®ç¸å¯¹æ¶é´ï¼æ¯æï¼ |
| | | |
| | | - ä»å¤©ãæ¨å¤© |
| | | - æ¬å¨ãä¸å¨ |
| | | - æ¬æã䏿 |
| | | - ä»å¹´ãå»å¹´ |
| | | - è¿N天/å¨/æ/å¹´ãè¿åå¹´ãè¿å个æ |
| | | |
| | | å端æ éæ¹ä¼ åï¼ä½å±ç¤ºæ¶é´èå´æ¶è¯·ä»¥å端è¿å `summary.startDate/endDate/timeRange` 为åã |
| | | |
| | | ## 6. å端èè°æ£æ¥æ¸
å |
| | | |
| | | 1. `chat` æµå¼ç»ææ¼æ¥åï¼ä¼å
æ JSON è§£æã |
| | | 2. è¦çæ°ç±»å `purchase_intent_not_recognized` ç UI å¤çã |
| | | 3. å¾
仿¬¾é¡µé¢è¯»åå¹¶å±ç¤º `summary.totalPendingAmount` çæ°å¢å段ã |
| | | 4. éªè¯ä»¥ä¸å¿«æ·é®é¢å¯ç¨³å®è¿åç»æåç»æï¼ |
| | | - æ¬æéè´é颿åååçç©ææåªäºï¼ |
| | | - åªäºéè´è®¢åè¿æªå
¥åºï¼ |
| | | - æè¿7天ä¾åºåå°è´§å¼å¸¸æåªäºï¼ |
| | | - 帮æç»è®¡å¾
仿¬¾éè´åï¼ |
| | | - ååºæ¬æéè´éè´§æ
åµ |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # é¦é¡µ HomeController æ¥å£å级åç«¯åæ´ææ¡£ |
| | | |
| | | æ´æ°æ¶é´ï¼2026-05-21 |
| | | éç¨æ¨¡åï¼é¦é¡µï¼`/home`ï¼ |
| | | |
| | | ## 1. åæ´æ¦è§ |
| | | |
| | | æ¬æ¬¡ä¸º **å
¼å®¹å¼å级**ï¼æ§è°ç¨æ¹å¼ä»å¯ç¨ã |
| | | éç¹æ¯ç»çäº§çæ¿æ¥å£å¢å æ´æç¡®ççéåæ°ï¼ä¾¿äºåç«¯ææ¥æåç¶ææ¥è¯¢ã |
| | | |
| | | æ¶åæ¥å£ï¼ |
| | | |
| | | 1. `GET /home/productionOrderProgress` |
| | | 2. `GET /home/todayProductionPlan` |
| | | |
| | | ## 2. åæ°åæ´ |
| | | |
| | | ### 2.1 ç产订åè¿åº¦ `GET /home/productionOrderProgress` |
| | | |
| | | æ§åæ°ï¼ä»å
¼å®¹ï¼ï¼ |
| | | |
| | | - `tab`ï¼`all` / `inProgress` / `completed` / `paused` |
| | | - `pageNum`ï¼é»è®¤ `1` |
| | | - `pageSize`ï¼é»è®¤ `10`ï¼æå¤§ `50` |
| | | |
| | | æ°å¢åæ°ï¼ |
| | | |
| | | - `status`ï¼å¯éï¼ï¼ç¶æçéï¼ä¼å
级é«äº `tab` |
| | | å¯éå¼ï¼`all` / `waiting` / `inProgress` / `completed` / `paused` / `1` / `2` / `3` / `4` |
| | | - `bizDate`ï¼å¯éï¼ï¼ä¸å¡æ¥æçéï¼æ ¼å¼ `yyyy-MM-dd`ï¼æè®¢åå建æ¶é´è¿æ»¤ï¼ |
| | | |
| | | åæ°ä¼å
çº§ï¼ |
| | | |
| | | 1. å¦æä¼ äº `status`ï¼å端ä¼å
æ `status` è§£æï¼ |
| | | 2. æªä¼ `status` æ¶ï¼æ²¿ç¨åæ `tab` è¡ä¸ºï¼ |
| | | 3. `status` æ `bizDate` æ ¼å¼é误æ¶è¿å失败信æ¯ã |
| | | |
| | | 请æ±ç¤ºä¾ï¼ |
| | | |
| | | ```http |
| | | GET /home/productionOrderProgress?status=completed&bizDate=2026-05-20&pageNum=1&pageSize=10 |
| | | ``` |
| | | |
| | | ### 2.2 仿¥ç产计å `GET /home/todayProductionPlan` |
| | | |
| | | æ§åæ°ï¼ä»å
¼å®¹ï¼ï¼ |
| | | |
| | | - `limit`ï¼é»è®¤ `4`ï¼æå¤§ `20` |
| | | |
| | | æ°å¢åæ°ï¼ |
| | | |
| | | - `planDate`ï¼å¯éï¼ï¼è®¡åæ¥æçéï¼æ ¼å¼ `yyyy-MM-dd`ï¼æ `plan_complete_time` è¿æ»¤ï¼ |
| | | |
| | | 请æ±ç¤ºä¾ï¼ |
| | | |
| | | ```http |
| | | GET /home/todayProductionPlan?limit=6&planDate=2026-05-21 |
| | | ``` |
| | | |
| | | ## 3. è¿åç»æåæ´ |
| | | |
| | | ### 3.1 `productionOrderProgress` è¿åæ°å¢å段 |
| | | |
| | | æ°å¢ï¼ |
| | | |
| | | - `status`ï¼æ ååç¶æåæ¾ï¼`all` / `waiting` / `inProgress` / `completed` / `paused`ï¼ |
| | | - `bizDate`ï¼æ¥æçéåæ¾ï¼æªä¼ æ¶ä¸º `null`ï¼ |
| | | - `waitingCount`ï¼å¾
å¼å§è®¢åæ°é |
| | | |
| | | å
¼å®¹ä¿çï¼ |
| | | |
| | | - `tab` åæ®µç»§ç»è¿åï¼è页颿 éæ¹å¨å¯ç»§ç»ä½¿ç¨ï¼ |
| | | |
| | | è¿å示ä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "tab": "completed", |
| | | "status": "completed", |
| | | "bizDate": "2026-05-20", |
| | | "total": 24, |
| | | "pageNum": 1, |
| | | "pageSize": 10, |
| | | "waitingCount": 3, |
| | | "inProgressCount": 6, |
| | | "completedCount": 12, |
| | | "pausedCount": 2, |
| | | "records": [] |
| | | } |
| | | ``` |
| | | |
| | | ### 3.2 `todayProductionPlan` è¿åæ°å¢å段 |
| | | |
| | | æ°å¢ï¼ |
| | | |
| | | - `planDate`ï¼æ¥æçéåæ¾ï¼æªä¼ æ¶ä¸º `null`ï¼ |
| | | |
| | | è¿å示ä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "planDate": "2026-05-21", |
| | | "total": 9, |
| | | "records": [] |
| | | } |
| | | ``` |
| | | |
| | | ## 4. å端æ¹é 建议 |
| | | |
| | | 1. æ°é¡µé¢å»ºè®®ä¼å
ä¼ `status`ï¼éæ¥æ¿ä»£ `tab`ã |
| | | 2. éè¦ææ¥æå¤ççæ¿æ¶ï¼ä½¿ç¨ `bizDate` / `planDate`ã |
| | | 3. è页é¢å¯ä¸æ¹ï¼ç»§ç»æ²¿ç¨ååæ°ä¹è½æ£å¸¸èè°ã |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # StockInRecord å表æºåå·å端èè°ææ¡£ |
| | | |
| | | æ´æ°æ¶é´ï¼2026-05-22 |
| | | éç¨æ¥å£ï¼`GET /stockInRecord/listPage` |
| | | |
| | | ## 1. åæ´è¯´æ |
| | | |
| | | æ¬æ¬¡å¯¹å
¥åºç®¡çå表æ¥å£å¢å è¿ååæ®µ `sourceOrderNo`ï¼æºåå·ï¼ï¼ç¨äºåææåºæ¯å±ç¤ºéè´æ¥æºåå·ã |
| | | |
| | | çææ¡ä»¶ï¼ |
| | | |
| | | - å½è¯·æ±åæ° `topParentProductId = 278` æ¶ï¼å端è¿å `sourceOrderNo`ã |
| | | - å
¶ä» `topParentProductId` åºæ¯ä¸ï¼è¯¥å段è¿å `null`ï¼æä¸å±ç¤ºï¼ã |
| | | |
| | | ## 2. åæ®µå®ä¹ |
| | | |
| | | æ°å¢åæ®µï¼ |
| | | |
| | | - `sourceOrderNo`ï¼`string`ï¼æºåå·ï¼éè´ååå·ï¼ã |
| | | |
| | | ## 3. åå¼è§å |
| | | |
| | | ä»
å¨ `topParentProductId = 278` æ¶æâæ¥æºâ计ç®ï¼ |
| | | |
| | | 1. æ¥æº = `éè´-å
¥åº`ï¼`recordType = 7`ï¼ |
| | | - å
æ `recordId` æ¥éè´äº§å表 `sales_ledger_product`ï¼`type=2`ï¼ï¼ |
| | | - åéè¿ `sales_ledger_product.sales_ledger_id` æ¥éè´å°è´¦è¡¨ `purchase_ledger`ï¼ |
| | | - è¿å `purchase_ledger.purchase_contract_number` ä½ä¸º `sourceOrderNo`ã |
| | | - å
¼å®¹å
åºï¼è¥æªå½ä¸éè´äº§åé¾è·¯ï¼åæ `recordId` ç´æ¥æ¥ `purchase_ledger.id` ååå·ã |
| | | |
| | | 2. æ¥æº = `éè´-è´¨æ£-åæ ¼å
¥åº`ï¼`recordType = 10`ï¼ |
| | | - å
æ `recordId` æ¥è´¨æ£è¡¨ `quality_inspect`ï¼ |
| | | - åéè¿ `quality_inspect.purchase_ledger_id` æ¥éè´å°è´¦è¡¨ `purchase_ledger`ï¼ |
| | | - è¿å `purchase_ledger.purchase_contract_number` ä½ä¸º `sourceOrderNo`ã |
| | | |
| | | ## 4. è¿åç¤ºä¾ |
| | | |
| | | ```json |
| | | { |
| | | "code": 200, |
| | | "msg": "æä½æå", |
| | | "data": { |
| | | "records": [ |
| | | { |
| | | "id": 1024, |
| | | "recordType": "7", |
| | | "productName": "éæ", |
| | | "model": "T2-30x3", |
| | | "sourceOrderNo": "CG-2026-00128" |
| | | }, |
| | | { |
| | | "id": 1025, |
| | | "recordType": "10", |
| | | "productName": "éæ", |
| | | "model": "T2-30x3", |
| | | "sourceOrderNo": "CG-2026-00131" |
| | | } |
| | | ], |
| | | "total": 2 |
| | | } |
| | | } |
| | | ``` |
| | | |
| | | ## 5. å端èè°å»ºè®® |
| | | |
| | | 1. åè¡¨åæ°å¢âæºåå·âï¼è¯»ååæ®µ `sourceOrderNo`ã |
| | | 2. 建议ä»
å¨ `topParentProductId = 278` ç页é¢/ç鿡件ä¸å±ç¤ºè¯¥åã |
| | | 3. å½ `sourceOrderNo` 为空æ¶å±ç¤º `--`ï¼é¿å
空ç½ã |
| | | |
| | | ## 6. å彿¸
å |
| | | |
| | | 1. `topParentProductId=278` + `recordType=7`ï¼åºè¿åéè´ååå·ã |
| | | 2. `topParentProductId=278` + `recordType=10`ï¼åºè¿åéè´ååå·ï¼ç»è´¨æ£é¾è·¯ï¼ã |
| | | 3. `topParentProductId!=278`ï¼`sourceOrderNo` åºä¸º `null` æå端ä¸å±ç¤ºã |
| | | 4. åæå段ï¼`productName/model/unit/createBy` çï¼ä¸åå½±åã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # StockInRecord å表æºåå·å端èè°ææ¡£ï¼`topParentProductId=276`è¡¥å
ï¼ |
| | | |
| | | æ´æ°æ¶é´ï¼2026-05-22 |
| | | éç¨æ¥å£ï¼`GET /stockInRecord/listPage` |
| | | |
| | | ## 1. åæ´è¯´æ |
| | | |
| | | å¨å·²æ `sourceOrderNo` åºç¡ä¸ï¼æ°å¢ `topParentProductId = 276` çæºåå·æº¯æºé»è¾ï¼ |
| | | |
| | | - æ ¹æ®âæ¥æºï¼recordTypeï¼+ recordIdâæº¯æºï¼ |
| | | - ä¼å
è¿åéå®åå·ï¼éå®ååå·ï¼ï¼ |
| | | - è¥éå®åå·ä¸ºç©ºï¼ååéè¿åç产订åå·ï¼ |
| | | - ä¸èèèªå®ä¹å
¥åºï¼`recordType=0/9`ï¼ã |
| | | |
| | | ## 2. è¿ååæ®µ |
| | | |
| | | åæ®µæ æ°å¢ï¼ç»§ç»ä½¿ç¨ï¼ |
| | | |
| | | - `sourceOrderNo`ï¼`string`ï¼æºåå·ã |
| | | |
| | | ## 3. 276 åºæ¯åå¼è§å |
| | | |
| | | 请æ±åæ°æ»¡è¶³ `topParentProductId = 276` æ¶ï¼ |
| | | |
| | | 1. `recordType = 14/15`ï¼éå®éè´§-åæ ¼/ä¸åæ ¼å
¥åºï¼ |
| | | - `stock_in_record.record_id -> return_sale_product.id -> return_management.shipping_id -> shipping_info.sales_ledger_id -> sales_ledger.sales_contract_no` |
| | | - è¿åéå®ååå·ã |
| | | |
| | | 2. `recordType = 2/5`ï¼ç产æ¥å·¥-å
¥åº/æ¥åºï¼ |
| | | - `stock_in_record.record_id -> production_product_main.id -> production_operation_task.production_order_id -> production_order` |
| | | - å
å该ç产订åå
³èéå®ååå·ï¼ç±ç产计åå
³èéå®å°è´¦èåï¼ï¼ |
| | | - éå®ååå·ä¸ºç©ºæ¶ï¼è¿å `production_order.nps_no`ã |
| | | |
| | | 3. `recordType = 6`ï¼è´¨æ£-åæ ¼å
¥åºï¼ |
| | | - `stock_in_record.record_id -> quality_inspect.id -> quality_inspect.product_main_id -> production_product_main -> production_operation_task -> production_order` |
| | | - å
åéå®ååå·ï¼ç©ºååé `production_order.nps_no`ã |
| | | |
| | | 4. `recordType = 4/11`ï¼ä¸åæ ¼å¤ç-æ¥åº/è®©æ¥æ¾è¡ï¼ |
| | | - `stock_in_record.record_id -> quality_unqualified.id -> quality_unqualified.inspect_id -> quality_inspect -> production_product_main -> production_operation_task -> production_order` |
| | | - å
åéå®ååå·ï¼ç©ºååé `production_order.nps_no`ã |
| | | |
| | | 5. `recordType = 20/22`ï¼é¢æéæ/ç产éæ-åæ ¼å
¥åºï¼ |
| | | - `stock_in_record.record_id -> production_order_pick.id -> production_order` |
| | | - å
åéå®ååå·ï¼ç©ºååé `production_order.nps_no`ã |
| | | |
| | | 6. `recordType = 0/9`ï¼èªå®ä¹å
¥åºï¼ |
| | | - ä¸å䏿º¯æºï¼`sourceOrderNo = null`ã |
| | | |
| | | ## 4. å
¶ä»åºæ¯è¯´æ |
| | | |
| | | - `topParentProductId = 278` çéè´é¾è·¯æºåå·é»è¾ä¿æä¸åã |
| | | - å
¶ä» `topParentProductId` ä¸è§¦åæ¬æ¬¡ 276 è§åï¼`sourceOrderNo` 为空ã |
| | | |
| | | ## 5. å端èè°å»ºè®® |
| | | |
| | | 1. å¨ `topParentProductId=276` çåè¡¨åºæ¯å±ç¤ºâæºåå·âåï¼è¯»å `sourceOrderNo`ã |
| | | 2. 建议空å¼ç»ä¸å±ç¤º `--`ã |
| | | 3. ä¸éè¦æ°å¢è¯·æ±åæ°ï¼æ²¿ç¨ç°æ `/stockInRecord/listPage`ã |
| | | |
| | | ## 6. å彿¸
å |
| | | |
| | | 1. `topParentProductId=276` + `recordType=14/15`ï¼åºè¿åéå®ååå·ã |
| | | 2. `topParentProductId=276` + `recordType=2/5/6/4/11/20/22`ï¼ä¼å
éå®ååå·ï¼ç¼ºå¤±æ¶è¿åç产订åå·ã |
| | | 3. `topParentProductId=276` + `recordType=0/9`ï¼`sourceOrderNo` 为空ã |
| | | 4. `topParentProductId=278`ï¼ä»æéè´é¾è·¯è¿åéè´ååå·ã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # è´¢å¡å©ææé®ä¼ååç«¯åæ´ææ¡£ |
| | | |
| | | æ´æ°æ¶é´ï¼2026-05-22 |
| | | éç¨æ¨¡åï¼è´¢å¡æºè½å©æï¼`/financial-ai`ï¼ |
| | | |
| | | ## 1. èæ¯ |
| | | |
| | | å½åé¦é¡µè´¢å¡å©æå¿«æ·æé®ä¸ºï¼ |
| | | |
| | | 1. `çææ¬å¨ç»è¥å¨æ¥` |
| | | 2. `为ä»ä¹å©æ¶¦ä¸é` |
| | | 3. `åªä¸ªå®¢æ·æèµé±` |
| | | |
| | | é®é¢ç¹ï¼ |
| | | |
| | | - 第 3 æ¡é®æ³å¨é¨ååºæ¯ä¸æå¾å½ä¸ä¸ç¨³å®ï¼å®¹æèµ°æ®éææ¬åçï¼å¯¼è´å¾è¡¨é¾æ¥ä»¥åå§ Markdown ææ¬å±ç¤ºï¼å¦ ``ï¼ã |
| | | - å¿«æ·æé®ç¼ºå°æ¶é´èå´ååæç®æ ï¼ç»æç¨³å®æ§ä¸å¯è§£éæ§è¾å¼±ã |
| | | |
| | | ## 2. åç«¯å¿«æ·æé®ææ¡ä¼åï¼å¿
æ¹ï¼ |
| | | |
| | | 建议å°é»è®¤ä¸æ¡å¿«æ·æé®è°æ´ä¸ºï¼ |
| | | |
| | | 1. `çææ¬å¨ç»è¥å¨æ¥ï¼å©æ¶¦ä¸ç°éæµï¼` |
| | | 2. `åææ¬æå©æ¶¦ä¸éåå ` |
| | | 3. `è¿30天åªä¸ªå®¢æ·å©æ¶¦è´¡ç®æé«` |
| | | |
| | | 说æï¼ |
| | | |
| | | - 䏿¡é®æ³å带æ¶é´èå´æåæç®æ ï¼å端å½ä¸æ´ç¨³å®ã |
| | | - 第 3 æ¡ä¸âæèµé±å®¢æ·âè¯ä¹ä¸è´ï¼ä½â婿¶¦è´¡ç®æé«âæ´æç¡®ï¼éåç´æ¥é©±å¨å©æ¶¦åæç»æé¡µã |
| | | |
| | | ## 3. ä¸å端è½åæ å° |
| | | |
| | | | å¿«æ·æé® | 颿å½ä¸è½å | 颿 `type` | |
| | | | --- | --- | --- | |
| | | | çææ¬å¨ç»è¥å¨æ¥ï¼å©æ¶¦ä¸ç°éæµï¼ | ç»è¥æ¥åçæ | `financial_operation_report` | |
| | | | åææ¬æå©æ¶¦ä¸éåå | 订å婿¶¦åæ | `financial_order_profit_analysis` | |
| | | | è¿30天åªä¸ªå®¢æ·å©æ¶¦è´¡ç®æé« | 订å婿¶¦åæ | `financial_order_profit_analysis` | |
| | | |
| | | åç«¯å·²åæ¥å¢å¼ºâæèµé±å®¢æ·/客æ·å©æ¶¦æé«/婿¶¦è´¡ç®æé«âçåä¹é®æ³è¯å«ï¼å端æä»¥ä¸ææ¡æ¹é åå¯ç´æ¥èè°ã |
| | | |
| | | ## 4. è天å
容渲æå
åºï¼å»ºè®®æ¹ï¼ |
| | | |
| | | é对è天è¿åææ¬ä¸åºç°çå¾è¡¨ Markdown 龿¥ï¼`https://local/generate_chart?options=...`ï¼ï¼å»ºè®®å端å¢å å
åºå¤çï¼ |
| | | |
| | | 1. è¯å« Markdown å¾çè¯æ³ä¸ç `local/generate_chart` 龿¥ã |
| | | 2. è§£æ `options` åæ°å¹¶è½¬æ¢ä¸º ECharts `option` 忏²æå¾è¡¨ç»ä»¶ã |
| | | 3. è§£æå¤±è´¥æ¶ä¸å±ç¤ºåå§é¿é¾æ¥ææ¬ï¼å±ç¤ºç»ä¸ç©ºææç¤ºã |
| | | |
| | | ## 5. èè°å彿¸
å |
| | | |
| | | 1. ç¹å»å¿«æ·æé® `çææ¬å¨ç»è¥å¨æ¥ï¼å©æ¶¦ä¸ç°éæµï¼` |
| | | - æ ¡éªè¿å `type=financial_operation_report`ï¼å¹¶æ£å¸¸æ¸²ææè¦/建议/å¾è¡¨ã |
| | | 2. ç¹å»å¿«æ·æé® `åææ¬æå©æ¶¦ä¸éåå ` |
| | | - æ ¡éªè¿å `type=financial_order_profit_analysis`ï¼å¹¶å±ç¤ºäºæè®¢åä¸å®¢æ·å©æ¶¦æè¡ã |
| | | 3. ç¹å»å¿«æ·æé® `è¿30天åªä¸ªå®¢æ·å©æ¶¦è´¡ç®æé«` |
| | | - æ ¡éªè¿å `type=financial_order_profit_analysis`ï¼`summary.topCustomerByProfit` æå¼ã |
| | | 4. æå·¥è¾å
¥ `åªä¸ªå®¢æ·æèµé±`ã`åªä¸ªå®¢æ·å©æ¶¦æé«` |
| | | - æ ¡éªä»å½ä¸ `financial_order_profit_analysis`ï¼ä¸ååºç°åå§å¾è¡¨ Markdown 龿¥ç´åºã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # è´¢å¡æ¨¡åå级å AI 模ååç«¯åæ´èè°ææ¡£ï¼éè´/éå®/ç产/å¾
åï¼ |
| | | |
| | | æ´æ°æ¥æï¼2026-05-22 |
| | | éç¨èå´ï¼`/sales-ai`ã`/purchase-ai`ã`/manufacturing-ai`ã`/xiaozhi`ï¼å®¡æ¹å¾
åï¼ |
| | | |
| | | ## 1. åæ´æ»è§ |
| | | |
| | | | 模å | 坹夿¥å£ | æ¯å¦éè¦å端æ¹é | ç»è®º | |
| | | | --- | --- | --- | --- | |
| | | | éå® AI | `POST /sales-ai/chat` | æ¯ | è´¢å¡å£å¾åæ¢å°æ°æ¶æ¬¾æ¨¡åï¼é¨å `type` çåæ®µè¯ä¹åå | |
| | | | éè´ AI | `POST /purchase-ai/chat` | æ¯ | 仿¬¾/å票/å¾
仿¬¾è®¡ç®åæ¢å°æ°è´¢å¡é¾è·¯ï¼ç»è®¡å¼ä»å 使¹ä¸ºçå®å¼ | |
| | | | ç产 AI | `POST /manufacturing-ai/chat` | å¦ | å·²æ ¸æ¥ï¼æ æ§è´¢å¡é»è¾ä¾èµï¼æ åæ®µåæ´ | |
| | | | å¾
å AI | `POST /xiaozhi/chat` | å¦ | å·²æ ¸æ¥ï¼æ æ§è´¢å¡é»è¾ä¾èµï¼æ åæ®µåæ´ | |
| | | |
| | | ## 2. éå® AI åæ´ï¼`/sales-ai/chat`ï¼ |
| | | |
| | | ### 2.1 `type = sales_return_list`ï¼éå®é款/忬¾è®°å½ï¼ |
| | | |
| | | å½åè¿åæ°æ®æ¥æºç»ä¸ä¸ºæ°è´¢å¡è¡¨ `account_sales_collection`ï¼ä¸åèµ°æ§æ¶æ¬¾éè´§é»è¾ã |
| | | |
| | | `data.items[]` å
³é®åæ®µï¼ |
| | | |
| | | | åæ®µ | ç±»å | 说æ | |
| | | | --- | --- | --- | |
| | | | id | number | æ¶æ¬¾è®°å½ID | |
| | | | refundId | string | æ å° `collectionNumber`ï¼å端å¯ç»§ç»ä½ä¸ºâ鿬¾/忬¾åå·âå±ç¤º | |
| | | | collectionNumber | string | æ¶æ¬¾åå· | |
| | | | paymentMethod | string | æ¶æ¬¾æ¹å¼ | |
| | | | actualAmount | number | æ¶æ¬¾éé¢ï¼ä¸ `collectionAmount` åå¼ï¼ | |
| | | | collectionAmount | number | æ¶æ¬¾éé¢ï¼æ¨è主å±ç¤ºåæ®µï¼ | |
| | | | customerId | number | 客æ·ID | |
| | | | remark | string | 夿³¨ | |
| | | | createTime | string | æ¶æ¬¾æ¥æï¼yyyy-MM-ddï¼ | |
| | | |
| | | `summary` å¢éå
³æ³¨ï¼ |
| | | - `returnAmount`ï¼æ¶é´èå´å
é颿±æ»ï¼æ `collectionAmount` ç»è®¡ï¼ |
| | | |
| | | ### 2.2 `type = sales_customer_interaction_list`ï¼å®¢æ·å¾æ¥ï¼ |
| | | |
| | | å½åè¿ååºäºæ°é¾è·¯ï¼ |
| | | `account_sales_collection.stock_out_record_ids -> stock_out_record(record_type=13) -> shipping_info -> sales_ledger` |
| | | |
| | | è¿å约å®ï¼ |
| | | - æ æ°æ®æ¶ï¼`description = "no_customer_interactions"` |
| | | - ææ°æ®æ¶ï¼`description = "ok"` |
| | | |
| | | `summary` å
³é®åæ®µï¼ |
| | | - `totalReceiptAmount` |
| | | - `customerCount` |
| | | |
| | | `data.items[]` å
³é®åæ®µï¼ |
| | | - `salesLedgerId` |
| | | - `salesContractNo` |
| | | - `customerName` |
| | | - `projectName` |
| | | - `receiptPaymentDate` |
| | | - `receiptPaymentAmount` |
| | | - `receiptPaymentType` |
| | | - `collectionNumber` |
| | | - `registrant` |
| | | - `remark` |
| | | |
| | | ### 2.3 `type = sales_ledger_list`ï¼éå®å°è´¦ï¼ |
| | | |
| | | åæ®µç»æä¸åï¼ä½éé¢å£å¾å·²åæ¢ï¼ |
| | | - `receivedAmount` ç±æ°æ¶æ¬¾æ¨¡åæ±æ»å¾å°ï¼ |
| | | - `pendingAmount = max(0, invoicedAmount - receivedAmount)`ï¼ |
| | | - è¥æ¶æ¬¾è®°å½æªæ¾å¼å
³èå°è´¦ï¼åæå®¢æ·ç»´åº¦å
åºå½éã |
| | | |
| | | å端æ¹é å»ºè®®ï¼ |
| | | - 䏿¹å段åï¼ |
| | | - éç¹åå½âå·²æ¶éé¢/å¾
忬¾éé¢âæ¯å¦ä¸è´¢å¡å°è´¦ä¸è´ã |
| | | |
| | | ## 3. éè´ AI åæ´ï¼`/purchase-ai/chat`ï¼ |
| | | |
| | | ### 3.1 `type = purchase_stats`ï¼éè´ç»è®¡ï¼ |
| | | |
| | | 以ä¸å段已ä»å ä½å¼æ¹ä¸ºçå®ç»è®¡å¼ï¼ |
| | | - `summary.paymentCount` |
| | | - `summary.invoiceCount` |
| | | - `summary.paymentAmount` |
| | | - `summary.invoiceAmount` |
| | | |
| | | å票éé¢å£å¾ï¼ |
| | | - ä¼å
`taxInclusivePrice` |
| | | - è¥ä¸ºç©º/0ï¼åä½¿ç¨ `taxExclusivelPrice + taxPrice` |
| | | |
| | | ### 3.2 `type = purchase_pending_payment_list`ï¼å¾
仿¬¾éè´åï¼ |
| | | |
| | | æ ¸å¿è®¡ç®å·²åæ¢å°æ°è´¢å¡é¾è·¯ï¼ |
| | | |
| | | `account_purchase_payment -> account_payment_application -> stock_in_record -> (purchase_ledger / quality_inspect) -> purchase_ledger_id` |
| | | |
| | | æ å°è§åï¼ |
| | | 1. `stock_in_record.record_type = 7`ï¼`record_id` ç´æ¥è§ä¸º `purchase_ledger_id` |
| | | 2. `stock_in_record.record_type = 10`ï¼éè¿ `quality_inspect.id = record_id` å `quality_inspect.purchase_ledger_id` |
| | | |
| | | éé¢å段å£å¾ï¼ |
| | | - `paidAmount`ï¼æ°é¾è·¯ç´¯è®¡å·²ä»æ¬¾éé¢ |
| | | - `pendingAmount = contractAmount - paidAmount`ï¼<=0 çè®°å½ä¸è¿åï¼ |
| | | |
| | | `summary` å
³é®å段ï¼å为çå®å¼ï¼ï¼ |
| | | - `pendingOrderCount` |
| | | - `totalContractAmount` |
| | | - `totalPaidAmount` |
| | | - `totalPendingAmount` |
| | | |
| | | ### 3.3 æ°æ®æ¸
æ´ä¿®å¤ |
| | | |
| | | å·²ä¿®å¤ `record_type` å¸¦ç©ºæ ¼å¯¼è´çæ å°ä¸¢å¤±é®é¢ï¼å端ç»ä¸ `trim()` åå夿 `7/10`ï¼ã |
| | | |
| | | ## 4. ç产 AI / å¾
å AI æ ¸æ¥ç»è®º |
| | | |
| | | å·²æ ¸æ¥ä»¥ä¸æ¨¡å代ç ï¼æªåç°æ§è´¢å¡é»è¾è¦åç¹ï¼ |
| | | - `ManufacturingAgentTools`ï¼çäº§ï¼ |
| | | - `ApproveTodoTools`ï¼å¾
å审æ¹ï¼ |
| | | |
| | | ç»è®ºï¼ |
| | | - å¯¹å¤ `type` ä¸åæ®µç»ææ åæ´ï¼ |
| | | - å端æ éåå
¼å®¹æ¹é ï¼ä»
éå䏿¬¡åå½éªè¯ã |
| | | |
| | | ## 5. å端èè°è¦ç¹ |
| | | |
| | | 1. `/sales-ai/chat`ã`/purchase-ai/chat` ç»§ç»æ SSE ææ¬æµæ¼æ¥åå JSON è§£æã |
| | | 2. æ `type` è·¯ç±æ¸²æï¼ä¸è¦ä»
ä¾èµ `description` ææ¡ã |
| | | 3. `sales_customer_interaction_list` éå
¼å®¹ `description` æä¸¾ï¼`ok` / `no_customer_interactions`ã |
| | | 4. `sales_return_list` éé¢å±ç¤ºç»ä¸ç¨ `collectionAmount`ï¼`actualAmount` ä¿çå
¼å®¹ï¼ã |
| | | 5. `purchase_pending_payment_list` çæ±æ»å¡çè¯·ç´æ¥è¯»å `summary.totalPendingAmount` çåæ®µï¼ä¸ååç«¯äºæ¬¡ä¼°ç®ã |
| | | |
| | | ## 6. å彿¸
åï¼å»ºè®®ï¼ |
| | | |
| | | ### éå® |
| | | 1. æé®ï¼âè¿30天åªä¸ªè®¢å忬¾æå°â |
| | | - æ ¡éª `sales_ledger_list` ç `receivedAmount/pendingAmount`ã |
| | | 2. æé®ï¼âæ¥è¯¢æ¬æéå®é款â |
| | | - æ ¡éª `sales_return_list` ç `collectionNumber/collectionAmount/returnAmount`ã |
| | | 3. æé®ï¼âæ¥è¯¢æ¬æå®¢æ·å¾æ¥â |
| | | - æ ¡éª `sales_customer_interaction_list` ç `totalReceiptAmount/customerCount`ã |
| | | |
| | | ### éè´ |
| | | 1. æé®ï¼âç»è®¡æ¬æéè´æ°æ®â |
| | | - æ ¡éª `purchase_stats` ç `paymentCount/invoiceCount/paymentAmount/invoiceAmount` éåºå®0ã |
| | | 2. æé®ï¼âååºå¾
仿¬¾éè´åâ |
| | | - æ ¡éª `purchase_pending_payment_list` ç `paidAmount/pendingAmount` ä¸è´¢å¡å®é
ä¸è´ã |
| | | |
| | | ### ç产/å¾
å |
| | | 1. ç产æé®ï¼âæ¥è¯¢æ¬å¨è®¾å¤ç»´ä¿®è®°å½â |
| | | 2. å¾
åæé®ï¼âæ¥è¯¢æçå¾
审æ¹å表â |
| | | - æ ¡éªè¿åç»æä¸å级åä¸è´ï¼æ åæ®µç ´åï¼ã |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # éè´å
¥åºç¶æå端èè°ææ¡£ |
| | | æ´æ°æ¶é´ï¼2026-05-22 |
| | | éç¨çæ¬ï¼æ¬æ¬¡åç«¯åæ´å |
| | | |
| | | ## 1. åæ´èå´ |
| | | |
| | | 1. `GET /purchaseLedger/listPage` |
| | | - æ°å¢æ¥è¯¢æ¡ä»¶ï¼`stockInStatus`ï¼å
¥åºç¶æï¼ |
| | | - æ°å¢è¿ååæ®µï¼`stockInStatus`ï¼å
¥åºç¶æï¼ |
| | | 2. `GET /salesLedgerProduct/list` |
| | | - æ°å¢è¿ååæ®µï¼`stockInApprovalStatus`ï¼æ¯ä¸ªäº§åçå
¥åºå®¡æ ¸ç¶æï¼ |
| | | |
| | | --- |
| | | |
| | | ## 2. å
¥åºç¶ææä¸¾ï¼ä¸¤æ¥å£ä¸è´ï¼ |
| | | |
| | | - `å¾
å
¥åº` |
| | | - `å
¥åºä¸` |
| | | - `å®å
¨å
¥åº` |
| | | |
| | | 说æï¼å端çéå¼è¯·ç´æ¥ä½¿ç¨ä»¥ä¸ä¸ææä¸¾å¼ã |
| | | |
| | | --- |
| | | |
| | | ## 3. æ¥å£ä¸ï¼`GET /purchaseLedger/listPage` |
| | | |
| | | ### 3.1 æ°å¢è¯·æ±åæ° |
| | | |
| | | - `stockInStatus`ï¼`string`ï¼å¯é |
| | | å¯ä¼ å¼ï¼`å¾
å
¥åº` / `å
¥åºä¸` / `å®å
¨å
¥åº` |
| | | |
| | | ### 3.2 æ°å¢è¿ååæ®µ |
| | | |
| | | - `stockInStatus`ï¼`string`ï¼éè´å°è´¦ç»´åº¦å
¥åºç¶æ |
| | | |
| | | ### 3.3 ç¶æè®¡ç®è§åï¼éè´å°è´¦ç»´åº¦ï¼ |
| | | |
| | | 以该éè´å°è´¦ä¸ `sales_ledger_product.type = 2` çéè´äº§å为计ç®èå´ï¼ |
| | | |
| | | 1. å
¨é¨äº§åé½è¾¾å°âå®å
¨å
¥åºâ => å°è´¦ç¶æ `å®å
¨å
¥åº` |
| | | 2. è³å°æä¸ä¸ªäº§ååå¨âå®¡æ ¸éè¿å
¥åºâï¼ä½æªå
¨é¨å®å
¨å
¥åº => å°è´¦ç¶æ `å
¥åºä¸` |
| | | 3. 没æä»»ä½äº§ååå¨âå®¡æ ¸éè¿å
¥åºâ => å°è´¦ç¶æ `å¾
å
¥åº` |
| | | |
| | | âå®¡æ ¸éè¿å
¥åºâç»è®¡å£å¾ï¼`stock_in_record.approval_status = 1`ï¼å¹¶æä»¥ä¸æ¥æºæº¯æºï¼ |
| | | - `record_type = 7`ï¼éè´-å
¥åºï¼ï¼æéè´å°è´¦+产åå
³èç»è®¡ |
| | | - `record_type = 10`ï¼éè´-è´¨æ£-åæ ¼å
¥åºï¼ï¼éè¿ `quality_inspect` åæº¯å°éè´å°è´¦+产åç»è®¡ |
| | | |
| | | ### 3.4 è¿å示ä¾ï¼èéï¼ |
| | | |
| | | ```json |
| | | { |
| | | "code": 200, |
| | | "msg": "æä½æå", |
| | | "data": { |
| | | "records": [ |
| | | { |
| | | "id": 1201, |
| | | "purchaseContractNumber": "CG20260522001", |
| | | "supplierName": "XXä¾åºå", |
| | | "stockInStatus": "å
¥åºä¸" |
| | | } |
| | | ], |
| | | "total": 1 |
| | | } |
| | | } |
| | | ``` |
| | | |
| | | --- |
| | | |
| | | ## 4. æ¥å£äºï¼`GET /salesLedgerProduct/list` |
| | | |
| | | ### 4.1 æ°å¢è¿ååæ®µ |
| | | |
| | | - `stockInApprovalStatus`ï¼`string`ï¼å½å产åè¡çå
¥åºå®¡æ ¸ç¶æ |
| | | |
| | | ### 4.2 ç¶æè®¡ç®è§åï¼äº§åç»´åº¦ï¼ |
| | | |
| | | ä»
å½äº§å `type = 2`ï¼éè´äº§åï¼æ¶è®¡ç®å¹¶è¿åï¼ |
| | | |
| | | 1. å®¡æ ¸éè¿å
¥åºæ°é `<= 0` => `å¾
å
¥åº` |
| | | 2. å®¡æ ¸éè¿å
¥åºæ°é `>= 产åéè´æ°é` => `å®å
¨å
¥åº` |
| | | 3. å
¶ä»æ
åµ => `å
¥åºä¸` |
| | | |
| | | å
¶ä¸âå®¡æ ¸éè¿å
¥åºæ°éâç»è®¡åæ ·åºäºï¼ |
| | | - `stock_in_record.approval_status = 1` |
| | | - æ¥æº `record_type = 7 / 10` çæº¯æºå
³èé»è¾ |
| | | |
| | | `type != 2` ç产åï¼è¯¥å段è¿å `null`ã |
| | | |
| | | ### 4.3 è¿å示ä¾ï¼èéï¼ |
| | | |
| | | ```json |
| | | { |
| | | "code": 200, |
| | | "msg": "æä½æå", |
| | | "data": [ |
| | | { |
| | | "id": 5566, |
| | | "type": 2, |
| | | "productCategory": "éæ", |
| | | "specificationModel": "T2-30x3", |
| | | "quantity": 100, |
| | | "stockInApprovalStatus": "å¾
å
¥åº" |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | --- |
| | | |
| | | ## 5. å端æ¹é 建议 |
| | | |
| | | 1. éè´å°è´¦å表æ°å¢âå
¥åºç¶æâçé项ï¼å¼åºå®ï¼`å¾
å
¥åº/å
¥åºä¸/å®å
¨å
¥åº`ã |
| | | 2. éè´å°è´¦å表æ°å¢âå
¥åºç¶æâåï¼å±ç¤º `stockInStatus`ã |
| | | 3. éè´äº§åå表æ°å¢âå
¥åºå®¡æ ¸ç¶æâåï¼å±ç¤º `stockInApprovalStatus`ã |
| | | 4. 空å¼ï¼å¦ `type != 2`ï¼å»ºè®®å±ç¤ºä¸º `--`ã |
| | | |
| | | --- |
| | | |
| | | ## 6. èè°æ£æ¥æ¸
å |
| | | |
| | | 1. `/purchaseLedger/listPage` ä¸ä¼ `stockInStatus`ï¼åºæ£å¸¸è¿åå
¨é¨æ°æ®ï¼å¹¶å¸¦ `stockInStatus`ã |
| | | 2. `/purchaseLedger/listPage?stockInStatus=å¾
å
¥åº`ï¼ä»
è¿åå¾
å
¥åºå°è´¦ã |
| | | 3. `/purchaseLedger/listPage?stockInStatus=å
¥åºä¸`ï¼ä»
è¿åå
¥åºä¸å°è´¦ã |
| | | 4. `/purchaseLedger/listPage?stockInStatus=å®å
¨å
¥åº`ï¼ä»
è¿åå®å
¨å
¥åºå°è´¦ã |
| | | 5. `/salesLedgerProduct/list` å¨éè´äº§åï¼`type=2`ï¼ä¸è¿å `stockInApprovalStatus`ã |
| | | 6. `/salesLedgerProduct/list` å¨ééè´äº§åï¼`type!=2`ï¼ä¸ `stockInApprovalStatus` 为 `null`ã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # é¦é¡µè´¢å¡æ¥å£å级åç«¯åæ´ææ¡£ |
| | | |
| | | æ´æ°æ¶é´ï¼2026-05-22 |
| | | éç¨æ¨¡åï¼é¦é¡µï¼`/home`ï¼ |
| | | |
| | | ## 1. åæ´æ¦è§ |
| | | |
| | | æ¬æ¬¡ä¸º **å
¼å®¹å¼å级**ï¼æ¥å£ URLã请æ±åæ°ãè¿ååæ®µä¿æä¸åã |
| | | 主è¦åæ´æ¯é¦é¡µè´¢å¡æ°æ®ä»å ä½/åæåé»è¾ï¼åæ¢ä¸ºæè´¢å¡ç宿°æ®å£å¾è®¡ç®ã |
| | | |
| | | æ¶åæ¥å£ï¼ |
| | | |
| | | 1. `GET /home/statisticsReceivablePayable` |
| | | 2. `GET /home/monthlyIncome` |
| | | 3. `GET /home/monthlyExpenditure` |
| | | |
| | | ## 2. åæ°è¯´æï¼æ æ°å¢ï¼ |
| | | |
| | | ### 2.1 `GET /home/statisticsReceivablePayable` |
| | | |
| | | - `type`ï¼`1` æ¬å¨ï¼`2` æ¬æï¼`3` æ¬å£åº¦ï¼é»è®¤ `1`ï¼ |
| | | |
| | | ### 2.2 `GET /home/monthlyIncome` |
| | | |
| | | - æ åæ° |
| | | |
| | | ### 2.3 `GET /home/monthlyExpenditure` |
| | | |
| | | - æ åæ° |
| | | |
| | | ## 3. è¿ååæ®µå£å¾åæ´ |
| | | |
| | | ### 3.1 åºæ¶åºä»ç»è®¡ `statisticsReceivablePayable` |
| | | |
| | | è¿ååæ®µä¸åï¼ |
| | | |
| | | - `receivableMoney` |
| | | - `payableMoney` |
| | | - `advanceMoney` |
| | | - `prepayMoney` |
| | | |
| | | æ°å£å¾ï¼ |
| | | |
| | | - `receivableMoney = max(éå®ååéé¢å计 - æ¶æ¬¾éé¢å计, 0)` |
| | | - `payableMoney = max(éè´ååéé¢å计 - 仿¬¾éé¢å计, 0)` |
| | | - `advanceMoney = æ¶æ¬¾éé¢å计` |
| | | - `prepayMoney = 仿¬¾éé¢å计` |
| | | |
| | | 以ä¸éé¢åæ `type` å¯¹åºæ¶é´èå´ç»è®¡ï¼ä¿ç两ä½å°æ°ã |
| | | |
| | | è¿å示ä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "receivableMoney": 128000.00, |
| | | "payableMoney": 76000.00, |
| | | "advanceMoney": 42000.00, |
| | | "prepayMoney": 31000.00 |
| | | } |
| | | ``` |
| | | |
| | | ### 3.2 æåº¦æ¶å
¥ `monthlyIncome` |
| | | |
| | | è¿ååæ®µä¸åï¼ |
| | | |
| | | - `monthlyIncome` |
| | | - `collectionRate` |
| | | - `overdueNum` |
| | | - `overdueRate` |
| | | |
| | | æ°å£å¾ï¼ |
| | | |
| | | - `monthlyIncome`ï¼å½ææ¶æ¬¾å计 |
| | | - `collectionRate`ï¼`å½ææ¶æ¬¾å计 / 彿éå®ååéé¢å计 * 100` |
| | | - `overdueNum`ï¼åå²åºæ¶å¯¹è´¦åï¼`account_statement.account_type=1`ï¼ä¸ï¼æ©äºå½æä¸ `closing_balance > 0` çæ°é |
| | | - `overdueRate`ï¼`overdueNum / åå²åºæ¶å¯¹è´¦åæ»æ° * 100` |
| | | |
| | | è¿å示ä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "monthlyIncome": 89500.00, |
| | | "collectionRate": "62.80", |
| | | "overdueNum": 4, |
| | | "overdueRate": "18.18" |
| | | } |
| | | ``` |
| | | |
| | | ### 3.3 æåº¦æ¯åº `monthlyExpenditure` |
| | | |
| | | è¿ååæ®µä¸åï¼ |
| | | |
| | | - `monthlyExpenditure` |
| | | - `paymentRate` |
| | | - `grossProfit` |
| | | - `profitMarginRate` |
| | | |
| | | æ°å£å¾ï¼ |
| | | |
| | | - `monthlyExpenditure`ï¼å½æä»æ¬¾å计 |
| | | - `paymentRate`ï¼`彿仿¬¾å计 / 彿éè´ååéé¢å计 * 100` |
| | | - `grossProfit`ï¼`å½ææ¶æ¬¾å计 - 彿仿¬¾å计` |
| | | - `profitMarginRate`ï¼`grossProfit / å½ææ¶æ¬¾å计 * 100` |
| | | |
| | | è¿å示ä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "monthlyExpenditure": 73400.00, |
| | | "paymentRate": "57.34", |
| | | "grossProfit": 16100.00, |
| | | "profitMarginRate": "17.99" |
| | | } |
| | | ``` |
| | | |
| | | ## 4. å端èè°è¯´æ |
| | | |
| | | 1. åç«¯åæ®µæ å°æ éè°æ´ï¼å¯ç´æ¥æ²¿ç¨ç°æè§£æé»è¾ã |
| | | 2. ç¾åæ¯å段ä»ä¸ºä¸å¸¦ `%` çå符串ï¼å端å¦éå±ç¤º `%` 请继ç»åç«¯æ¼æ¥ã |
| | | 3. æ¬æ¬¡å端è¿åå¼ç±çå®è´¢å¡æ°æ®é©±å¨ï¼å»ºè®®éç¹åå½å¡çæ±æ»ä¸è¶å¿å¾çæ°å¼èå¨ã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | ALTER TABLE approve_process |
| | | ADD COLUMN start_date_time datetime DEFAULT NULL COMMENT 'åºå·®å¼å§æ¶é´', |
| | | ADD COLUMN end_date_time datetime DEFAULT NULL COMMENT 'åºå·®ç»ææ¶é´'; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # è´¢å¡æºè½ä½å端èè°ææ¡£ |
| | | |
| | | ## 1. 模å说æ |
| | | |
| | | è´¢å¡æºè½ä½å端已æ°å¢ç»ä¸å
¥å£ `financial-ai`ï¼ç¨äºä¸è´¢ä¸ä½ååæï¼è¦çï¼ |
| | | |
| | | - æºè½ææ¬æ ¸ç® |
| | | - 订å婿¶¦åæ |
| | | - åºåèµéåæ |
| | | - åºæ¶åºä»ä¸ç°éæµé¢æµ |
| | | - ç»è¥å¼å¸¸é¢è¦ |
| | | - AI ç»è¥é©¾é©¶è± |
| | | - æ¥æ¥/卿¥èªå¨çæ |
| | | - è´¢å¡ç¥è¯æ£ç´¢ï¼è½»é RAG ä¸ä¸æï¼ |
| | | |
| | | æ¥å£éç¨ **SSE æµå¼è¾åº**ï¼å·¥å
·å½ä¸æ¶è¿åç»æå JSON å符串ã |
| | | |
| | | ## 2. æ¥å£æ¸
å |
| | | |
| | | ### 2.1 å¯¹è¯æ¥å£ï¼SSEï¼ |
| | | |
| | | - `POST /financial-ai/chat` |
| | | - `Content-Type: application/json` |
| | | - `Accept: text/stream;charset=utf-8` |
| | | |
| | | 请æ±ä½ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "memoryId": "finance-uuid-001", |
| | | "message": "æ¥è¯¢è¿30å¤©äºæè®¢å" |
| | | } |
| | | ``` |
| | | |
| | | åæ®µè¯´æï¼ |
| | | |
| | | - `memoryId`ï¼ä¼è¯å¯ä¸æ è¯ï¼åç«¯çæ UUIDï¼åä¼è¯å¤ç¨ï¼ |
| | | - `message`ï¼èªç¶è¯è¨é®é¢ |
| | | |
| | | --- |
| | | |
| | | ### 2.2 ä¼è¯å表 |
| | | |
| | | - `GET /financial-ai/history/sessions` |
| | | |
| | | --- |
| | | |
| | | ### 2.3 ä¼è¯æ¶æ¯ |
| | | |
| | | - `GET /financial-ai/history/messages/{memoryId}` |
| | | |
| | | --- |
| | | |
| | | ### 2.4 å é¤ä¼è¯ |
| | | |
| | | - `DELETE /financial-ai/history/{memoryId}` |
| | | |
| | | ## 3. SSE è¿åå¤çè§è |
| | | |
| | | ### 3.1 è¿åå½¢æ |
| | | |
| | | - æ®éé®çï¼æµå¼ææ¬ç段 |
| | | - å·¥å
·å½ä¸ï¼å®æ´ JSON å符串ï¼é叏䏿¬¡æ§è¾åºï¼ä¹å¯è½åçï¼ |
| | | |
| | | å端建议å¤çæµç¨ï¼ |
| | | |
| | | 1. å° SSE åçæé¡ºåºæ¼æ¥æ `rawText` |
| | | 2. 对 `rawText` å°è¯ `JSON.parse` |
| | | 3. è¥å¯è§£æï¼æ `type` å忏²æå¾è¡¨/è¡¨æ ¼ |
| | | 4. è¥ä¸å¯è§£æï¼ææ®éææ¬å±ç¤º |
| | | |
| | | ### 3.2 ç»æå JSON éç¨æ ¼å¼ |
| | | |
| | | ```json |
| | | { |
| | | "success": true, |
| | | "type": "financial_order_profit_analysis", |
| | | "description": "å·²å®æè®¢å婿¶¦åæ", |
| | | "summary": {}, |
| | | "data": {}, |
| | | "charts": {} |
| | | } |
| | | ``` |
| | | |
| | | åæ®µè¯´æï¼ |
| | | |
| | | - `type`ï¼ç»æç±»åï¼å端渲æååé®ï¼ |
| | | - `summary`ï¼å¤´é¨ææ |
| | | - `data`ï¼è¡¨æ ¼æç»/建议å表 |
| | | - `charts`ï¼ECharts `option` æ°æ® |
| | | |
| | | ## 4. type ä¸åç«¯é¡µé¢æ å° |
| | | |
| | | 建议æ `type` å»ºç«æ¸²æçç¥ï¼ |
| | | |
| | | - `financial_cost_accounting`ï¼ææ¬æ ¸ç®é¡µ |
| | | - `financial_order_profit_analysis`ï¼è®¢å婿¶¦é¡µ |
| | | - `financial_inventory_capital_analysis`ï¼åºåèµé页 |
| | | - `financial_cashflow_forecast`ï¼ç°éæµé¡µ |
| | | - `financial_business_anomaly_warning`ï¼é£é©é¢è¦é¡µ |
| | | - `financial_business_cockpit`ï¼ç»è¥é©¾é©¶è± |
| | | - `financial_operation_report`ï¼æ¥æ¥å¨æ¥é¡µ |
| | | - `financial_rag_knowledge`ï¼ç¥è¯æ£ç´¢/å£å¾è¯´æå¡ç |
| | | |
| | | ## 5. å
³é®æ°æ®å段ï¼èè°éç¹ï¼ |
| | | |
| | | ### 5.1 ææ¬/婿¶¦ç±» |
| | | |
| | | - `data.orders[]`ï¼ |
| | | - `salesContractNo` |
| | | - `customerName` |
| | | - `revenue` |
| | | - `materialCost` |
| | | - `laborCost` |
| | | - `depreciationCost` |
| | | - `scrapCost` |
| | | - `totalCost` |
| | | - `profit` |
| | | - `profitRate` |
| | | - `riskLevel` |
| | | - `reasons` |
| | | - `suggestion` |
| | | |
| | | ### 5.2 åºåèµéç±» |
| | | |
| | | - `data.items[]`ï¼ |
| | | - `productName` |
| | | - `model` |
| | | - `quantity` |
| | | - `inventoryValue` |
| | | - `stagnantDays` |
| | | - `overstock` |
| | | - `riskLevel` |
| | | |
| | | ### 5.3 ç°éæµç±» |
| | | |
| | | - `data.actualMonthly[]` / `data.forecastMonthly[]`ï¼ |
| | | - `month` |
| | | - `income` |
| | | - `expense` |
| | | - `netFlow` |
| | | - `data.receivableRiskTop[]` / `data.payablePressureTop[]` |
| | | |
| | | ### 5.4 å¼å¸¸é¢è¦ç±» |
| | | |
| | | - `data.items[]`ï¼ |
| | | - `riskLevel` |
| | | - `type` |
| | | - `message` |
| | | - `detail` |
| | | |
| | | ### 5.5 æ¥åç±» |
| | | |
| | | - `data.headline` |
| | | - `data.conclusions[]` |
| | | - `data.riskSuggestions[]` |
| | | - `data.orderProfitTop[]` |
| | | |
| | | ## 6. å¾è¡¨èè°è§è |
| | | |
| | | `charts` å
åæ®µå为 ECharts `option`ï¼å¯ç´æ¥åç»å¾è¡¨ç»ä»¶ã |
| | | |
| | | 常è§åæ®µï¼ |
| | | |
| | | - æ±ç¶å¾ï¼`orderProfitBarOption` / `processCostBarOption` / `inventoryValueTopOption` |
| | | - 饼å¾ï¼`costCompositionPieOption` / `inventoryAgingPieOption` / `anomalyLevelPieOption` |
| | | - è¶å¿å¾ï¼`cashFlowTrendOption` |
| | | - 仪表çï¼`fundGapGaugeOption` / `inventoryTurnoverGauge` |
| | | |
| | | ## 7. æ¨èå端é®å¥ï¼å彿µè¯ï¼ |
| | | |
| | | 1. `æ¥çæ¬æç»è¥é©¾é©¶è±` |
| | | 2. `æ¥è¯¢è¿30å¤©äºæè®¢å` |
| | | 3. `åæè¿30天åºåèµéå ç¨` |
| | | 4. `颿µæªæ¥3个æç°éæµ` |
| | | 5. `çææ¬å¨ç»è¥å¨æ¥` |
| | | 6. `为ä»ä¹å©æ¶¦ä¸é` |
| | | 7. `åªä¸ªå®¢æ·æèµé±` |
| | | 8. `åªä¸ªå·¥åºææ¬æé«` |
| | | |
| | | ## 8. å¼å¸¸ä¸å
åºå¤ç |
| | | |
| | | - `memoryId` 为空ï¼è¿åææ¬ `memoryIdä¸è½ä¸ºç©º` |
| | | - `message` 为空ï¼è¿åææ¬ `messageä¸è½ä¸ºç©º` |
| | | - æ æ°æ®åºæ¯ï¼`success=true` ä¸ `data.items=[]`ï¼å端æç©ºæå±ç¤º |
| | | - é JSON æµè¿åï¼ææ®éèå¤©ææ¬å±ç¤º |
| | | |
| | | ## 9. èè°å»ºè®® |
| | | |
| | | 1. å
å `type` ååå¨ï¼ä¿è¯ææç»æåç»æå¯è½å°ï¼ |
| | | 2. ååæè¦å¡çï¼`summary`ï¼+ è¡¨æ ¼ï¼`data`ï¼+ å¾è¡¨ï¼`charts`ï¼ |
| | | 3. æåè¡¥ä¼è¯åå²ä¸å é¤è½åï¼å½¢æå®æ´å¯¹è¯éç¯ |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # å端èè°ææ¡£ï¼è®¾å¤æ¥ä¿® / 设å¤ä¿å
»å®æ¶ä»»å¡ / è´¢å¡ç§ç®æ»è´¦ï¼ |
| | | |
| | | ## 1. åæ´èå´ |
| | | |
| | | æ¬æ¬¡èè°æ¶å 3 个模åï¼ |
| | | |
| | | 1. è´¢å¡æ¨¡åï¼ç§ç®æ»è´¦å»æåè¯åå·ãæè¦ï¼åªè¿å 1 æ¡åè®¡æ°æ®ã |
| | | 2. 设å¤ä¿å
»å®æ¶ä»»å¡ï¼æ°å¢ `ä¿å
»äºº` åæ®µï¼å®æ¶ä»»å¡çæä¿å
»è®°å½æ¶å¸¦å
¥ã |
| | | 3. è®¾å¤æ¥ä¿®ï¼ç¡®è®¤æ¥ä¿®åæ°å¢éªæ¶å®¡æ¹ï¼éªæ¶éè¿åæç®å®ç»ã |
| | | |
| | | --- |
| | | |
| | | ## 2. æ¥å£æ¸
å |
| | | |
| | | ### 2.1 è´¢å¡-ç§ç®æ»è´¦ |
| | | |
| | | - **GET** `/financial/ledger/general` |
| | | - 说æï¼è¿åç§ç®æ»è´¦å计ï¼ä»
1 æ¡è®°å½ã |
| | | |
| | | #### 请æ±åæ°ï¼Queryï¼ |
| | | |
| | | | åæ° | ç±»å | å¿
å¡« | 说æ | |
| | | |---|---|---|---| |
| | | | `subjectCode` | string | æ¯ | ç§ç®ç¼ç | |
| | | | `startMonth` | string | æ¯ | å¼å§æä»½ï¼æ ¼å¼ `YYYY-MM` | |
| | | | `endMonth` | string | æ¯ | ç»ææä»½ï¼æ ¼å¼ `YYYY-MM` | |
| | | |
| | | #### è¿åç»æ |
| | | |
| | | `R<List<FinLedgerRowVo>>` |
| | | |
| | | ```json |
| | | { |
| | | "code": 200, |
| | | "msg": "æä½æå", |
| | | "data": [ |
| | | { |
| | | "rowType": "yearly_total", |
| | | "date": "2026-05-31", |
| | | "debit": 12000.00, |
| | | "credit": 8000.00, |
| | | "direction": "å", |
| | | "balance": 4000.00 |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | #### èè°æ³¨æ |
| | | |
| | | 1. `data` åºå®åªæ 1 æ¡ï¼å计ï¼ã |
| | | 2. `voucherNo`ã`summary` ä¸è¿åï¼ä¸åå±ç¤ºåè¯åå·ãæè¦ï¼ã |
| | | |
| | | --- |
| | | |
| | | ### 2.2 设å¤ä¿å
»å®æ¶ä»»å¡ï¼æ°å¢ä¿å
»äººï¼ |
| | | |
| | | - åºç¡è·¯å¾ï¼`/deviceMaintenanceTask` |
| | | - ç¸å
³æ¥å£ï¼ |
| | | - **POST** `/add` |
| | | - **POST** `/update` |
| | | - **GET** `/listPage` |
| | | |
| | | #### æ°å¢å段 |
| | | |
| | | | åæ®µ | ç±»å | 说æ | |
| | | |---|---|---| |
| | | | `maintenancePerson` | string | ä¿å
»äºº | |
| | | |
| | | #### æ°å¢/æ´æ°è¯·æ±ç¤ºä¾ |
| | | |
| | | ```json |
| | | { |
| | | "id": 1, |
| | | "taskName": "ç©ºåæºä¿å
»ä»»å¡", |
| | | "taskId": 1001, |
| | | "maintenancePerson": "å¼ ä¸", |
| | | "frequencyType": "MONTHLY", |
| | | "frequencyDetail": "10,09:00", |
| | | "remarks": "æ¯æä¾è¡ä¿å
»" |
| | | } |
| | | ``` |
| | | |
| | | #### 宿¶ä»»å¡ä¸åè¡ä¸º |
| | | |
| | | 宿¶ä»»å¡æ§è¡åï¼ç³»ç»èªå¨å建ä¿å
»è®°å½ï¼`device_maintenance`ï¼æ¶ä¼åå
¥ï¼ |
| | | |
| | | - `maintenanceActuallyName = maintenancePerson` |
| | | |
| | | å³å端å¨å®æ¶ä»»å¡éç»´æ¤çä¿å
»äººï¼ä¼èªå¨å¸¦å
¥å°ä¿å
»è®°å½ã |
| | | |
| | | --- |
| | | |
| | | ### 2.3 è®¾å¤æ¥ä¿®ï¼ç¡®è®¤åéªæ¶å®¡æ¹ï¼ |
| | | |
| | | - åºç¡è·¯å¾ï¼`/device/repair` |
| | | |
| | | #### ç¶æå®ä¹ |
| | | |
| | | | ç¶æå¼ | å«ä¹ | |
| | | |---|---| |
| | | | `0` | å¾
ç»´ä¿® | |
| | | | `3` | å¾
éªæ¶ | |
| | | | `1` | å®ç» | |
| | | | `2` | 失败 | |
| | | |
| | | #### 2.3.1 维修确认ï¼å确认æ¥ä¿®ï¼ |
| | | |
| | | - **POST** `/device/repair/repair` |
| | | - 说æï¼æäº¤åç¶æä» `å¾
ç»´ä¿®(0)` è¿å
¥ `å¾
éªæ¶(3)`ï¼ä¸åç´æ¥å®ç»ã |
| | | |
| | | 请æ±ç¤ºä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "id": 10001, |
| | | "maintenanceName": "æå", |
| | | "maintenanceTime": "2026-05-14 10:30:00", |
| | | "maintenanceResult": "æ´æ¢è½´æ¿å¹¶è¯è¿è¡æ£å¸¸", |
| | | "sparePartsUseList": [ |
| | | { |
| | | "id": 501, |
| | | "quantity": 2 |
| | | } |
| | | ] |
| | | } |
| | | ``` |
| | | |
| | | 常è§å¤±è´¥æç¤ºï¼ç¨äºå端弹çªï¼ï¼ |
| | | |
| | | - `æ¥ä¿®è®°å½ä¸åå¨` |
| | | - `该æ¥ä¿®å·²å®ç»ï¼ä¸è½éå¤ç¡®è®¤ç»´ä¿®` |
| | | - `该æ¥ä¿®å·²æäº¤éªæ¶å®¡æ¹` |
| | | - `å¤ä»¶ xxx æ°éä¸è¶³` |
| | | |
| | | #### 2.3.2 éªæ¶å®¡æ¹ï¼æ°å¢ï¼ |
| | | |
| | | - **POST** `/device/repair/acceptance` |
| | | - 说æï¼ä»
`å¾
éªæ¶(3)` å¯å®¡æ¹ï¼å®¡æ¹éè¿åç¶ææ¹ä¸º `å®ç»(1)`ã |
| | | |
| | | 请æ±åæ°ï¼Bodyï¼ï¼ |
| | | |
| | | | åæ®µ | ç±»å | å¿
å¡« | 说æ | |
| | | |---|---|---|---| |
| | | | `id` | long | æ¯ | æ¥ä¿®è®°å½ID | |
| | | | `acceptanceName` | string | æ¯ | éªæ¶äºº | |
| | | | `acceptanceTime` | string | æ¯ | éªæ¶æ¶é´ï¼æ ¼å¼ `yyyy-MM-dd HH:mm:ss` | |
| | | | `acceptanceRemark` | string | æ¯ | éªæ¶å¤æ³¨ | |
| | | |
| | | 请æ±ç¤ºä¾ï¼ |
| | | |
| | | ```json |
| | | { |
| | | "id": 10001, |
| | | "acceptanceName": "çäº", |
| | | "acceptanceTime": "2026-05-14 11:00:00", |
| | | "acceptanceRemark": "ç»´ä¿®é¡¹æ ¸éªéè¿ï¼è®¾å¤è¿è¡æ£å¸¸" |
| | | } |
| | | ``` |
| | | |
| | | 常è§å¤±è´¥æç¤ºï¼ |
| | | |
| | | - `æ¥ä¿®è®°å½idä¸è½ä¸ºç©º` |
| | | - `æ¥ä¿®è®°å½ä¸åå¨` |
| | | - `该æ¥ä¿®æªè¿å
¥å¾
éªæ¶ç¶æï¼ä¸è½å®¡æ¹` |
| | | - `éªæ¶äººä¸è½ä¸ºç©º` |
| | | - `éªæ¶æ¶é´ä¸è½ä¸ºç©º` |
| | | - `éªæ¶å¤æ³¨ä¸è½ä¸ºç©º` |
| | | |
| | | #### 2.3.3 æ®éæ´æ°æ¥å£éå¶ |
| | | |
| | | - **PUT** `/device/repair` |
| | | - éå¶ï¼ä¸è½éè¿æ®éæ´æ°ç´æ¥æç¶ææ¹æ `å®ç»(1)`ï¼å¿
é¡»èµ°éªæ¶å®¡æ¹æ¥å£ï¼ã |
| | | - 失败æç¤ºï¼`请å
æäº¤éªæ¶å®¡æ¹ï¼éªæ¶éè¿åæå¯å®ç»` |
| | | |
| | | --- |
| | | |
| | | ## 3. è¿ååæ®µåæ´ï¼æ¥ä¿®å表/详æ
ï¼ |
| | | |
| | | 以䏿¥å£è¿åå·²æ°å¢éªæ¶åæ®µï¼ |
| | | |
| | | - **GET** `/device/repair/page` |
| | | - **GET** `/device/repair/{id}` |
| | | |
| | | æ°å¢è¿ååæ®µï¼ |
| | | |
| | | | åæ®µ | ç±»å | 说æ | |
| | | |---|---|---| |
| | | | `acceptanceName` | string | éªæ¶äºº | |
| | | | `acceptanceTime` | string | éªæ¶æ¶é´ | |
| | | | `acceptanceRemark` | string | éªæ¶å¤æ³¨ | |
| | | |
| | | --- |
| | | |
| | | ## 4. å端æ¹é 建议 |
| | | |
| | | 1. æ¥ä¿®å表å¢å ç¶æå¼ `3=å¾
éªæ¶` çå±ç¤ºææ¡ä¸çé项ã |
| | | 2. â确认维修âæé®è°ç¨ `/device/repair/repair`ï¼æååå·æ°ä¸ºå¾
éªæ¶ç¶æã |
| | | 3. æ°å¢âéªæ¶å®¡æ¹âå¼¹çªï¼å¿
å¡«ï¼ |
| | | - éªæ¶äºº |
| | | - éªæ¶æ¶é´ |
| | | - éªæ¶å¤æ³¨ |
| | | 4. ç¦æ¢å¨æ®éç¼è¾é¡µç´æ¥å°ç¶æç½®ä¸ºå®ç»ã |
| | | 5. 设å¤ä¿å
»å®æ¶ä»»å¡æ°å¢âä¿å
»äººâè¾å
¥é¡¹ï¼å¹¶å¨å表/详æ
å±ç¤ºã |
| | | 6. ç§ç®æ»è´¦é¡µé¢æåè¡å计渲æï¼ä¸åæ¾ç¤ºåè¯åå·ãæè¦åã |
| | | |
| | | --- |
| | | |
| | | ## 5. èè°æ£æ¥æ¸
å |
| | | |
| | | 1. ç§ç®æ»è´¦æ¥è¯¢è¿å `data.length === 1`ï¼ä¸æ `voucherNo/summary`ã |
| | | 2. æ°å¢ä¿å
»å®æ¶ä»»å¡æ¶ä¼ `maintenancePerson`ï¼å表è½åæ¾ã |
| | | 3. 宿¶ä»»å¡è§¦ååï¼çæçä¿å
»è®°å½ `maintenanceActuallyName` ä¸å®æ¶ä»»å¡ä¿å
»äººä¸è´ã |
| | | 4. æ¥ä¿®åæµç¨ï¼`0å¾
ç»´ä¿® -> 3å¾
éªæ¶ -> 1å®ç»`ã |
| | | 5. å¾
éªæ¶åæ®æªå¡«éªæ¶äºº/éªæ¶æ¶é´/éªæ¶å¤æ³¨æ¶ï¼å端è¿å对åºé误æç¤ºã |
| | | 6. å°è¯éè¿ `PUT /device/repair` ç´æ¥è®¾ä¸ºå®ç»æ¶ï¼å端è¿åæ¦æªæç¤ºã |
| | | |
| | | --- |
| | | |
| | | ## 6. æ°æ®åºåæ´ï¼èè°åç¡®è®¤ï¼ |
| | | |
| | | ```sql |
| | | ALTER TABLE maintenance_task |
| | | ADD COLUMN maintenance_person VARCHAR(100) NULL COMMENT 'ä¿å
»äºº'; |
| | | |
| | | ALTER TABLE device_repair |
| | | ADD COLUMN acceptance_name VARCHAR(100) NULL COMMENT 'éªæ¶äºº', |
| | | ADD COLUMN acceptance_time DATETIME NULL COMMENT 'éªæ¶æ¶é´', |
| | | ADD COLUMN acceptance_remark VARCHAR(500) NULL COMMENT 'éªæ¶å¤æ³¨'; |
| | | ``` |
| | | |
| | | > è¥æªæ§è¡ä»¥ä¸ SQLï¼ç¸å
³æ¥å£ä¼åºç°å段ä¸åå¨å¼å¸¸ã |
| | | |
| | |
| | | // æ¼ç¤ºä¾åï¼æ§è¡ main æ¹æ³æ§å¶å°è¾å
¥æ¨¡å表åå车èªå¨çæå¯¹åºé¡¹ç®ç®å½ä¸ |
| | | public class CodeGenerator { |
| | | |
| | | public static String database_url = "jdbc:mysql://localhost:3300/product-inventory-management-new-pro"; |
| | | public static String database_url = "jdbc:mysql://localhost:3306/product-inventory-management-new-pro"; |
| | | public static String database_username = "root"; |
| | | public static String database_password= "root"; |
| | | public static String database_password= "123456"; |
| | | public static String author = "è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸"; |
| | | public static String model = "sales"; // 模å |
| | | public static String model = "account"; // 模å |
| | | public static String setParent = "com.ruoyi."+ model; // å
è·¯å¾ |
| | | public static String tablePrefix = ""; // è®¾ç½®è¿æ»¤è¡¨åç¼ |
| | | public static void main(String[] args) { |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/ReportDateDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2026/1/16 16:57 |
| | | */ |
| | | |
| | | @Data |
| | | public class ReportDateDto { |
| | | @Schema(name = "AccountReportDto", description = "è´¢å¡æ¥è¡¨--æ¥æåæ°") |
| | | public class AccountReportDto { |
| | | |
| | | /** |
| | | * å¼å§æ¶é´ |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate entryDateEnd; |
| | | |
| | | /** |
| | | * å¼å§æä»½ |
| | | */ |
| | | private Integer startMonth; |
| | | |
| | | /** |
| | | * ç»ææä»½ |
| | | */ |
| | | private Integer endMonth; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "StatementAccountDto", description = "è´¢å¡ç®¡ç--çæå¯¹è´¦å(ä¼ å)") |
| | | public class StatementAccountDto { |
| | | |
| | | //ä¸å¡ç±»å(1åºæ¶å¯¹è´¦;2åºä»å¯¹è´¦) |
| | | @Schema(name = "accountType", description = "ä¸å¡ç±»å(1åºæ¶å¯¹è´¦;2åºä»å¯¹è´¦)") |
| | | private Integer accountType; |
| | | |
| | | //éæ©ç客æ·(åºæ¶æ¯å®¢æ·,åºä»æ¯ä¾åºåsupplierId) |
| | | @Schema(name = "customerId", description = "客æ·ID") |
| | | private Long customerId; |
| | | |
| | | //对账æä»½yyyy-MM |
| | | @Schema(name = "statementMonth", description = "对账æä»½") |
| | | private String statementMonth; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/AccountSubjectDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | package com.ruoyi.account.bean.dto.financial; |
| | | |
| | | import com.ruoyi.account.pojo.AccountSubject; |
| | | import com.ruoyi.account.pojo.financial.AccountSubject; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/AccountSubjectImportDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | package com.ruoyi.account.bean.dto.financial; |
| | | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | |
| | | package com.ruoyi.account.bean.dto.financial; |
| | | |
| | | import com.ruoyi.account.pojo.financial.FinVoucher; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | * åè¯æç»åå½ã |
| | | */ |
| | | private List<FinVoucherEntryDto> entries; |
| | | |
| | | private List<StorageBlobDTO> storageBlobDTOs; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.dto.purchase; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountPaymentApplicationDto", description = "è´¢å¡ç®¡ç--仿¬¾ç³è¯·å°è´¦(ä¼ å)") |
| | | public class AccountPaymentApplicationDto { |
| | | |
| | | @Schema(description = "ä¾åºåID") |
| | | private Integer supplierId; |
| | | |
| | | @Schema(description = "ç³è¯·åå·") |
| | | private String invoiceApplicationNo; |
| | | |
| | | @Schema(description = "å®¡æ ¸ç¶æ:0å¾
å®¡æ ¸1å®¡æ ¸éè¿2å®¡æ ¸ä¸éè¿") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.dto.purchase; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountPurchaseInvoiceDto", description = "è´¢å¡ç®¡ç--è¿é¡¹å票å°è´¦(ä¼ å)") |
| | | public class AccountPurchaseInvoiceDto { |
| | | |
| | | @Schema(description = "ä¾åºåID") |
| | | private Integer supplierId; |
| | | |
| | | @Schema(description = "å票å·ç ") |
| | | private String invoiceNumber; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | @Schema(description = "ç¶æ") |
| | | private Integer status; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.dto.purchase; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountPurchasePaymentDto", description = "è´¢å¡ç®¡ç--仿¬¾åå°è´¦(ä¼ å)") |
| | | public class AccountPurchasePaymentDto { |
| | | |
| | | @Schema(description = "ä¾åºåID") |
| | | private Integer supplierId; |
| | | |
| | | @Schema(description = "仿¬¾åå·") |
| | | private String paymentNumber; |
| | | |
| | | @Schema(description = "仿¬¾æ¹å¼") |
| | | private String paymentMethod; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/PurchaseInboundDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | package com.ruoyi.account.bean.dto.purchase; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "PurchaseInboundDto", description = "è´¢å¡ç®¡ç--éè´å
¥åºå°è´¦(ä¼ å)") |
| | |
| | | @Schema(description = "å
¥åºåå·") |
| | | private String inboundBatches; |
| | | |
| | | private Long supplierId; |
| | | |
| | | @Schema(description = "ä¾åºå") |
| | | private String supplierName; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date startDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/PurchaseReturnDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | package com.ruoyi.account.bean.dto.purchase; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "PurchaseReturnDto", description = "è´¢å¡ç®¡ç--éè´éè´§å°è´¦(ä¼ å)") |
| | |
| | | @Schema(description = "éè´§åå·") |
| | | private String returnNo; |
| | | |
| | | private Long supplierId; |
| | | |
| | | @Schema(description = "ä¾åºå") |
| | | private String supplierName; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date startDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.dto.sales; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountInvoiceApplicationDto", description = "è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯·å°è´¦(ä¼ å)") |
| | | public class AccountInvoiceApplicationDto { |
| | | |
| | | @Schema(description = "客æ·ID") |
| | | private Integer customerId; |
| | | |
| | | @Schema(description = "ç³è¯·åå·") |
| | | private String invoiceApplicationNo; |
| | | |
| | | @Schema(description = "å®¡æ ¸ç¶æ:0å¾
å®¡æ ¸1å®¡æ ¸éè¿2å®¡æ ¸ä¸éè¿") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.dto.sales; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountSalesCollectionDto", description = "è´¢å¡ç®¡ç--æ¶æ¬¾åå°è´¦(ä¼ å)") |
| | | public class AccountSalesCollectionDto { |
| | | |
| | | @Schema(description = "客æ·ID") |
| | | private Integer customerId; |
| | | |
| | | @Schema(description = "æ¶æ¬¾åå·") |
| | | private String collectionNumber; |
| | | |
| | | @Schema(description = "æ¶æ¬¾æ¹å¼") |
| | | private String collectionMethod; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.dto.sales; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountSalesInvoiceDto", description = "è´¢å¡ç®¡ç--é项å票å°è´¦(ä¼ å)") |
| | | public class AccountSalesInvoiceDto { |
| | | |
| | | @Schema(description = "客æ·ID") |
| | | private Integer customerId; |
| | | |
| | | @Schema(description = "å票å·ç ") |
| | | private String invoiceNumber; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | @Schema(description = "ç¶æ") |
| | | private Integer status; |
| | | |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/SalesOutboundDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | package com.ruoyi.account.bean.dto.sales; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "SalesOutboundDto", description = "è´¢å¡ç®¡ç--éå®åºåºå°è´¦(ä¼ å)") |
| | |
| | | @Schema(description = "åºåºåå·") |
| | | private String outboundBatches; |
| | | |
| | | private Long customerId; |
| | | |
| | | @Schema(description = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date startDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/SalesReturnDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.dto; |
| | | package com.ruoyi.account.bean.dto.sales; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "SalesReturnDto", description = "è´¢å¡ç®¡ç--éå®éè´§å°è´¦(ä¼ å)") |
| | |
| | | @Schema(description = "éè´§åå·") |
| | | private String returnNo; |
| | | |
| | | private Long customerId; |
| | | |
| | | @Schema(description = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date startDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Data |
| | | @Schema(name = "AccountReportVo", description = "è´¢å¡æ¥è¡¨--è¿ååæ°") |
| | | public class AccountReportVo { |
| | | |
| | | @Schema(description = "æ»è¥æ¶") |
| | | private BigDecimal totalIncome; |
| | | |
| | | @Schema(description = "æ»æ¯åº") |
| | | private BigDecimal totalExpense; |
| | | |
| | | @Schema(description = "åºæ¶è´¦æ¬¾") |
| | | private BigDecimal accountsReceivable; |
| | | |
| | | @Schema(description = "åºä»è´¦æ¬¾") |
| | | private BigDecimal accountsPayable; |
| | | |
| | | @Schema(description = "åæ¶å
¥") |
| | | private BigDecimal netRevenue; |
| | | |
| | | // --- æçº¿å¾ï¼æåº¦è¶å¿æ°æ® --- |
| | | @Schema(description = "æåº¦è¶å¿æ°æ®å表") |
| | | private List<MonthlyTrendVO> monthlyTrendList; |
| | | |
| | | // --- æ±ç¶å¾ï¼åºæ¶åºä»æåº¦æ°æ® --- |
| | | @Schema(description = "åºæ¶åºä»æåº¦æ°æ®å表") |
| | | private List<ReceivablePayableVO> receivablePayableList; |
| | | |
| | | @Data |
| | | @Schema(description = "æåº¦è¶å¿VOï¼æçº¿å¾ç¨ï¼") |
| | | public static class MonthlyTrendVO { |
| | | @Schema(description = "æä»½ï¼æ ¼å¼ï¼yyyy-MM") |
| | | private String month; |
| | | |
| | | @Schema(description = "å½æè¥æ¶") |
| | | private BigDecimal income; |
| | | |
| | | @Schema(description = "彿æ¯åº") |
| | | private BigDecimal expense; |
| | | |
| | | @Schema(description = "彿å婿¶¦") |
| | | private BigDecimal profit; |
| | | } |
| | | |
| | | @Data |
| | | @Schema(description = "åºæ¶åºä»æåº¦VOï¼æ±ç¶å¾ç¨ï¼") |
| | | public static class ReceivablePayableVO { |
| | | @Schema(description = "æä»½ï¼æ ¼å¼ï¼yyyy-MM") |
| | | private String month; |
| | | |
| | | @Schema(description = "åºæ¶è´¦æ¬¾éé¢") |
| | | private BigDecimal receivable; |
| | | |
| | | @Schema(description = "åºä»è´¦æ¬¾éé¢") |
| | | private BigDecimal payable; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.account.pojo.AccountStatement; |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @Schema(name = "StatementAccountVo", description = "è´¢å¡ç®¡ç--对账å详æ
(è¿å)") |
| | | @ExcelIgnoreUnannotated |
| | | public class StatementAccountVo extends AccountStatement { |
| | | |
| | | //客æ·åç§°(åºæ¶æ¯å®¢æ·,åºä»æ¯ä¾åºå) |
| | | @Schema(description = "客æ·åç§°") |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | //对账æç» |
| | | @Schema(description = "对账æç»") |
| | | private List<AccountStatementDetails> accountStatementDetails; |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/vo/AccountSubjectVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.vo; |
| | | package com.ruoyi.account.bean.vo.financial; |
| | | |
| | | import com.ruoyi.account.pojo.AccountSubject; |
| | | import com.ruoyi.account.pojo.financial.AccountSubject; |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | package com.ruoyi.account.bean.vo.financial; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | * ç§ç®è´¦è¡æ°æ®è¿å对象ã |
| | | */ |
| | | @Data |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | public class FinLedgerRowVo { |
| | | |
| | | /** |
| | |
| | | |
| | | import com.ruoyi.account.pojo.financial.FinVoucher; |
| | | import com.ruoyi.account.pojo.financial.FinVoucherEntry; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.dto.StorageBlobVO; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | |
| | | * åè¯åå½å表ã |
| | | */ |
| | | private List<FinVoucherEntry> entries; |
| | | private List<StorageBlobVO> storageBlobVOList; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo.purchase; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountPaymentApplicationVo", description = "è´¢å¡ç®¡ç--仿¬¾ç³è¯·å°è´¦(è¿å)") |
| | | @ExcelIgnoreUnannotated |
| | | public class AccountPaymentApplicationVo extends AccountPaymentApplication { |
| | | |
| | | @Schema(description = "ä¾åºååç§°") |
| | | @Excel(name = "ä¾åºååç§°") |
| | | private String supplierName; |
| | | |
| | | @Schema(description = "å
¥åºåå·") |
| | | @Excel(name = "å
¥åºåå·") |
| | | private String inboundBatches; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo.purchase; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchaseInvoice; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountPurchaseInvoiceVo", description = "è´¢å¡ç®¡ç--è¿é¡¹å票å°è´¦(è¿å)") |
| | | @ExcelIgnoreUnannotated |
| | | public class AccountPurchaseInvoiceVo extends AccountPurchaseInvoice { |
| | | |
| | | @Schema(description = "ä¾åºååç§°") |
| | | @Excel(name = "ä¾åºååç§°") |
| | | private String supplierName; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo.purchase; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountPurchasePaymentVo", description = "è´¢å¡ç®¡ç--仿¬¾åå°è´¦(è¿å)") |
| | | @ExcelIgnoreUnannotated |
| | | public class AccountPurchasePaymentVo extends AccountPurchasePayment { |
| | | |
| | | @Schema(description = "ä¾åºååç§°") |
| | | @Excel(name = "ä¾åºååç§°") |
| | | private String supplierName; |
| | | |
| | | @Schema(description = "仿¬¾ç³è¯·åå·") |
| | | @Excel(name = "仿¬¾ç³è¯·åå·") |
| | | private String invoiceApplicationNo; |
| | | |
| | | @Schema(description = "弿·è¡") |
| | | @Excel(name = "弿·è¡") |
| | | private String bankAccountName; |
| | | |
| | | @Schema(description = "é¶è¡è´¦å·") |
| | | @Excel(name = "é¶è¡è´¦å·") |
| | | private String bankAccountNum; |
| | | |
| | | @Schema(description = "æ¯å¦çæäºå¯¹è´¦å") |
| | | private boolean isAccountStatemen; |
| | | |
| | | |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/vo/PurchaseInboundVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.vo; |
| | | package com.ruoyi.account.bean.vo.purchase; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "PurchaseInboundVo", description = "è´¢å¡ç®¡ç--éè´å
¥åºå°è´¦(è¿å)") |
| | |
| | | @Schema(description = "å
¥åºæ¥æ") |
| | | @Excel(name = "å
¥åºæ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date InboundDate; |
| | | private LocalDate InboundDate; |
| | | |
| | | @Schema(description = "产ååç§°") |
| | | @Excel(name = "产ååç§°") |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/vo/PurchaseReturnVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.vo; |
| | | package com.ruoyi.account.bean.vo.purchase; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo.sales; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.account.pojo.sales.AccountInvoiceApplication; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountInvoiceApplicationVo", description = "è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯·å°è´¦(è¿å)") |
| | | @ExcelIgnoreUnannotated |
| | | public class AccountInvoiceApplicationVo extends AccountInvoiceApplication { |
| | | |
| | | @Schema(description = "客æ·åç§°") |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @Schema(description = "åºåºåå·") |
| | | @Excel(name = "åºåºåå·") |
| | | private String outboundBatches; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo.sales; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountSalesCollectionVo", description = "è´¢å¡ç®¡ç--æ¶æ¬¾åå°è´¦(è¿å)") |
| | | @ExcelIgnoreUnannotated |
| | | public class AccountSalesCollectionVo extends AccountSalesCollection { |
| | | |
| | | @Schema(description = "客æ·åç§°") |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @Schema(description = "åºåºåå·") |
| | | @Excel(name = "åºåºåå·") |
| | | private String outboundBatches; |
| | | |
| | | @Schema(description = "æ¯å¦çæäºå¯¹è´¦å") |
| | | private boolean isAccountStatemen; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.bean.vo.sales; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesInvoice; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @Schema(name = "AccountSalesInvoiceVo", description = "è´¢å¡ç®¡ç--é项å票å°è´¦(è¿å)") |
| | | @ExcelIgnoreUnannotated |
| | | public class AccountSalesInvoiceVo extends AccountSalesInvoice { |
| | | |
| | | @Schema(description = "客æ·åç§°") |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/vo/SalesOutboundVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.vo; |
| | | package com.ruoyi.account.bean.vo.sales; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "SalesOutboundVo", description = "è´¢å¡ç®¡ç--éå®åºåºå°è´¦(è¿å)") |
| | |
| | | @Schema(description = "åºåºæ¥æ") |
| | | @Excel(name = "åºåºæ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date shippingDate; |
| | | private LocalDate shippingDate; |
| | | |
| | | @Schema(description = "产ååç§°") |
| | | @Excel(name = "产ååç§°") |
| | |
| | | @Excel(name = "éé¢") |
| | | private BigDecimal outboundAmount; |
| | | |
| | | @Schema(description = "ç¨ç") |
| | | private BigDecimal taxRate; |
| | | |
| | | @Schema(description = "åè´§ç¼å·") |
| | | @Excel(name = "åè´§ç¼å·") |
| | | private String shippingNo; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/vo/SalesReturnVo.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.bean.vo; |
| | | package com.ruoyi.account.bean.vo.sales; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.StatementAccountDto; |
| | | import com.ruoyi.account.bean.vo.StatementAccountVo; |
| | | import com.ruoyi.account.service.AccountStatementService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 09:42:47 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/accountStatement") |
| | | @RequiredArgsConstructor |
| | | @Tag(name = "è´¢å¡ç®¡ç-对账å") |
| | | public class AccountStatementController { |
| | | |
| | | private final AccountStatementService accountStatementService; |
| | | |
| | | @GetMapping("/getAccountStatementDetailsByMonth") |
| | | @Log(title = "æ ¹æ®å®¢æ·åæä»½æ¥è¯¢å¯¹è´¦åæç»", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ ¹æ®å®¢æ·åæä»½æ¥è¯¢å¯¹è´¦åæç»") |
| | | public R getAccountStatementDetailsByMonth(StatementAccountDto statementAccountDto) { |
| | | return R.ok(accountStatementService.getAccountStatementDetailsByMonth(statementAccountDto)); |
| | | } |
| | | |
| | | @PostMapping("/addAccountStatement") |
| | | @Log(title = "æ°å¢å¯¹è´¦å", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ°å¢å¯¹è´¦å") |
| | | public R addAccountStatement(@RequestBody StatementAccountVo statementAccountVo) { |
| | | return R.ok(accountStatementService.addAccountStatement(statementAccountVo)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteAccountStatement") |
| | | @Log(title = "å é¤å¯¹è´¦å", businessType = BusinessType.DELETE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å é¤å¯¹è´¦å") |
| | | public R deleteAccountStatement(@RequestParam("ids") Long[] ids) { |
| | | return R.ok(accountStatementService.deleteAccountStatement(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @GetMapping("/listPageAccountStatement") |
| | | @Log(title = "对账åå°è´¦", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--对账åå°è´¦") |
| | | public R<IPage<StatementAccountVo>> listPageAccountStatement(Page page, StatementAccountDto statementAccountDto) { |
| | | IPage<StatementAccountVo> listPage = accountStatementService.listPageAccountStatement(page,statementAccountDto); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @PostMapping("/exportAccountStatement") |
| | | @Operation(summary = "导åºå¯¹è´¦åæä»¶") |
| | | @Log(title = "导åºå¯¹è´¦åæä»¶", businessType = BusinessType.EXPORT) |
| | | public void exportAccountStatement(HttpServletResponse response, StatementAccountDto statementAccountDto) { |
| | | accountStatementService.exportAccountStatement(response,statementAccountDto); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.service.impl.AccountingServiceImpl; |
| | | import com.ruoyi.account.bean.dto.AccountReportDto; |
| | | import com.ruoyi.account.service.AccountingService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.AllArgsConstructor; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | @Tag(name = "ä¼è®¡æ ¸ç®") |
| | | @RestController |
| | | @RequestMapping("/accounting") |
| | | @AllArgsConstructor |
| | | @RequiredArgsConstructor |
| | | public class AccountingController extends BaseController { |
| | | |
| | | |
| | | private AccountingServiceImpl accountingService; |
| | | private final AccountingService accountingService; |
| | | |
| | | @Operation(summary = "æ»è®¡") |
| | | @GetMapping("/total") |
| | |
| | | return accountingService.calculateDepreciation(page,year); |
| | | } |
| | | |
| | | /*****************************************è´¢å¡æ¥è¡¨******************************************************************************/ |
| | | |
| | | @GetMapping("/accountStatementDetailsByMonth") |
| | | @Log(title = "è´¢å¡æ¥è¡¨", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡æ¥è¡¨") |
| | | public R getAccountStatementDetailsByMonth(AccountReportDto accountReportDto) { |
| | | return R.ok(accountingService.getAccountStatementDetailsByMonth(accountReportDto)); |
| | | } |
| | | |
| | | |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/controller/AccountSubjectController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.controller; |
| | | package com.ruoyi.account.controller.financial; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.AccountSubjectDto; |
| | | import com.ruoyi.account.bean.vo.AccountSubjectVo; |
| | | import com.ruoyi.account.service.AccountSubjectService; |
| | | import com.ruoyi.account.bean.dto.financial.AccountSubjectDto; |
| | | import com.ruoyi.account.bean.vo.financial.AccountSubjectVo; |
| | | import com.ruoyi.account.service.purchase.AccountSubjectService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/controller/AccounPurchaseController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.controller; |
| | | package com.ruoyi.account.controller.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.vo.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.PurchaseReturnVo; |
| | | import com.ruoyi.account.service.AccountPurchaseService; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseReturnVo; |
| | | import com.ruoyi.account.service.financial.AccountPurchaseService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.controller.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPaymentApplicationDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPaymentApplicationVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import com.ruoyi.account.service.purchase.AccountPaymentApplicationService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾ç³è¯· å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:44:22 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/accountPaymentApplication") |
| | | @Tag(name = "è´¢å¡ç®¡ç--仿¬¾ç³è¯·") |
| | | @RequiredArgsConstructor |
| | | public class AccountPaymentApplicationController { |
| | | |
| | | private final AccountPaymentApplicationService accountPaymentApplicationService; |
| | | |
| | | @GetMapping("/listPageAccountPaymentApplication") |
| | | @Log(title = "仿¬¾ç³è¯·å°è´¦", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--仿¬¾ç³è¯·å°è´¦") |
| | | public R<IPage<AccountPaymentApplicationVo>> listPageAccountPaymentApplication(Page page, AccountPaymentApplicationDto accountPaymentApplicationDto) { |
| | | IPage<AccountPaymentApplicationVo> listPage = accountPaymentApplicationService.listPageAccountPaymentApplication(page,accountPaymentApplicationDto); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @GetMapping("/getInboundBatchesBySupplier") |
| | | @Log(title = "æ ¹æ®ä¾åºåæ¥è¯¢å
¥åºåå·(仿¬¾ç³è¯·)", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ ¹æ®ä¾åºåæ¥è¯¢å
¥åºåå·(仿¬¾ç³è¯·)") |
| | | public R getInboundBatchesBySupplier(Integer supplierId) { |
| | | return R.ok(accountPaymentApplicationService.getInboundBatchesBySupplier(supplierId)); |
| | | } |
| | | |
| | | @PostMapping("/addAccountPaymentApplication") |
| | | @Log(title = "æ°å¢ä»æ¬¾ç³è¯·", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ°å¢ä»æ¬¾ç³è¯·") |
| | | public R addAccountPaymentApplication(@RequestBody AccountPaymentApplication accountPaymentApplication) { |
| | | return R.ok(accountPaymentApplicationService.addAccountPaymentApplication(accountPaymentApplication)); |
| | | } |
| | | |
| | | @PutMapping("/updateAccountPaymentApplication") |
| | | @Log(title = "ä¿®æ¹ä»æ¬¾ç³è¯·", businessType = BusinessType.UPDATE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--ä¿®æ¹ä»æ¬¾ç³è¯·") |
| | | public R updateAccountPaymentApplication(@RequestBody AccountPaymentApplication accountPaymentApplication) { |
| | | return R.ok(accountPaymentApplicationService.updateById(accountPaymentApplication)); |
| | | } |
| | | |
| | | @PutMapping("/auditAccountPaymentApplication") |
| | | @Log(title = "å®¡æ ¸ä»æ¬¾ç³è¯·", businessType = BusinessType.UPDATE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å®¡æ ¸ä»æ¬¾ç³è¯·") |
| | | public R auditAccountPaymentApplication(@RequestBody AccountPaymentApplication accountPaymentApplication) { |
| | | return R.ok(accountPaymentApplicationService.updateById(accountPaymentApplication)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteAccountPaymentApplication") |
| | | @Log(title = "å é¤ä»æ¬¾ç³è¯·", businessType = BusinessType.DELETE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å é¤ä»æ¬¾ç³è¯·") |
| | | public R deleteAccountPaymentApplication(@RequestParam("ids") Long[] ids) { |
| | | return R.ok(accountPaymentApplicationService.deleteAccountPaymentApplication(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PostMapping("/exportAccountPaymentApplication") |
| | | @Operation(summary = "导åºä»æ¬¾ç³è¯·æä»¶") |
| | | @Log(title = "导åºä»æ¬¾ç³è¯·æä»¶", businessType = BusinessType.EXPORT) |
| | | public void exportAccountPaymentApplication(HttpServletResponse response, AccountPaymentApplicationDto accountPaymentApplicationDto) { |
| | | accountPaymentApplicationService.exportAccountPaymentApplication(response,accountPaymentApplicationDto); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.controller.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchaseInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchaseInvoiceVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchaseInvoice; |
| | | import com.ruoyi.account.service.purchase.AccountPurchaseInvoiceService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--è¿é¡¹å票 å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:06:17 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/accountPurchaseInvoice") |
| | | @Tag(name = "è´¢å¡ç®¡ç--è¿é¡¹å票") |
| | | @RequiredArgsConstructor |
| | | public class AccountPurchaseInvoiceController { |
| | | |
| | | private final AccountPurchaseInvoiceService accountPurchaseInvoiceService; |
| | | |
| | | @GetMapping("/listPageAccountPurchaseInvoice") |
| | | @Log(title = "è¿é¡¹å票å°è´¦", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--è¿é¡¹å票å°è´¦") |
| | | public R<IPage<AccountPurchaseInvoiceVo>> listPageAccountPurchaseInvoice(Page page, AccountPurchaseInvoiceDto accountPurchaseInvoiceDto) { |
| | | IPage<AccountPurchaseInvoiceVo> listPage = accountPurchaseInvoiceService.listPageAccountPurchaseInvoice(page,accountPurchaseInvoiceDto); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @GetMapping("/getInboundBatchesBySupplier") |
| | | @Log(title = "æ ¹æ®ä¾åºåæ¥è¯¢å
¥åºåå·(è¿é¡¹å票)", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ ¹æ®ä¾åºåæ¥è¯¢å
¥åºåå·(è¿é¡¹å票)") |
| | | public R getInboundBatchesBySupplier(Integer supplierId) { |
| | | return R.ok(accountPurchaseInvoiceService.getInboundBatchesBySupplier(supplierId)); |
| | | } |
| | | |
| | | @PostMapping("/addAccountPurchaseInvoice") |
| | | @Log(title = "æ°å¢è¿é¡¹å票", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ°å¢è¿é¡¹å票") |
| | | public R addAccountPurchaseInvoice(@RequestBody AccountPurchaseInvoice accountPurchaseInvoice) { |
| | | return R.ok(accountPurchaseInvoiceService.save(accountPurchaseInvoice)); |
| | | } |
| | | |
| | | @PutMapping("/cancelAccountPurchaseInvoice") |
| | | @Log(title = "ä½åºè¿é¡¹å票", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--ä½åºé项å票") |
| | | public R cancelAccountPurchaseInvoice(@RequestBody AccountPurchaseInvoice accountPurchaseInvoice) { |
| | | return R.ok(accountPurchaseInvoiceService.updateById(accountPurchaseInvoice)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteAccountPurchaseInvoice") |
| | | @Log(title = "å é¤è¿é¡¹å票", businessType = BusinessType.DELETE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å é¤è¿é¡¹å票") |
| | | public R deleteAccountPurchaseInvoice(@RequestParam("ids") Long[] ids) { |
| | | return R.ok(accountPurchaseInvoiceService.deleteAccountPurchaseInvoice(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PostMapping("/exportAccountPurchaseInvoice") |
| | | @Operation(summary = "导åºè¿é¡¹å票æä»¶") |
| | | @Log(title = "导åºè¿é¡¹å票æä»¶", businessType = BusinessType.EXPORT) |
| | | public void exportAccountPurchaseInvoice(HttpServletResponse response, AccountPurchaseInvoiceDto accountPurchaseInvoiceDto) { |
| | | accountPurchaseInvoiceService.exportAccountPurchaseInvoice(response,accountPurchaseInvoiceDto); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.controller.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchasePaymentDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchasePaymentVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.service.purchase.AccountPurchasePaymentService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾å å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 04:14:51 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/accountPurchasePayment") |
| | | @Tag(name = "è´¢å¡ç®¡ç--仿¬¾å") |
| | | @RequiredArgsConstructor |
| | | public class AccountPurchasePaymentController { |
| | | |
| | | private final AccountPurchasePaymentService accountPurchasePaymentService; |
| | | |
| | | @GetMapping("/listPageAccountPurchasePayment") |
| | | @Log(title = "仿¬¾åå°è´¦", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--仿¬¾åå°è´¦") |
| | | public R<IPage<AccountPurchasePaymentVo>> listPageAccountPurchasePayment(Page page, AccountPurchasePaymentDto accountPurchasePaymentDto) { |
| | | IPage<AccountPurchasePaymentVo> listPage = accountPurchasePaymentService.listPageAccountPurchasePayment(page,accountPurchasePaymentDto); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @PostMapping("/addAccountPurchasePayment") |
| | | @Log(title = "æ°å¢ä»æ¬¾å", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ°å¢ä»æ¬¾å") |
| | | public R addAccountPurchasePayment(@RequestBody AccountPurchasePayment accountPurchasePayment) { |
| | | return R.ok(accountPurchasePaymentService.addAccountPurchasePayment(accountPurchasePayment)); |
| | | } |
| | | |
| | | @PutMapping("/updateAccountPurchasePayment") |
| | | @Log(title = "ç¼è¾ä»æ¬¾å", businessType = BusinessType.UPDATE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--ç¼è¾ä»æ¬¾å") |
| | | public R updateAccountPurchasePayment(@RequestBody AccountPurchasePayment accountPurchasePayment) { |
| | | return R.ok(accountPurchasePaymentService.updateById(accountPurchasePayment)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteAccountPurchasePayment") |
| | | @Log(title = "å é¤ä»æ¬¾å", businessType = BusinessType.DELETE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å é¤ä»æ¬¾å") |
| | | public R deleteAccountPurchasePayment(@RequestParam("ids") Long[] ids) { |
| | | return R.ok(accountPurchasePaymentService.deleteAccountPurchasePayment(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PostMapping("/exportAccountPurchasePayment") |
| | | @Operation(summary = "导åºä»æ¬¾åæä»¶") |
| | | @Log(title = "导åºä»æ¬¾åæä»¶", businessType = BusinessType.EXPORT) |
| | | public void exportAccountPurchasePayment(HttpServletResponse response, AccountPurchasePaymentDto accountPurchasePaymentDto) { |
| | | accountPurchasePaymentService.exportAccountPurchasePayment(response,accountPurchasePaymentDto); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.controller.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountInvoiceApplicationDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountInvoiceApplicationVo; |
| | | import com.ruoyi.account.pojo.sales.AccountInvoiceApplication; |
| | | import com.ruoyi.account.service.sales.AccountInvoiceApplicationService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯· å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 01:38:32 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/accountInvoiceApplication") |
| | | @Tag(name = "è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯·") |
| | | @RequiredArgsConstructor |
| | | public class AccountInvoiceApplicationController { |
| | | |
| | | private final AccountInvoiceApplicationService accountInvoiceApplicationService; |
| | | |
| | | @GetMapping("/listPageAccountInvoiceApplication") |
| | | @Log(title = "å¼ç¥¨ç³è¯·å°è´¦", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯·å°è´¦") |
| | | public R<IPage<AccountInvoiceApplicationVo>> listPageAccountInvoiceApplication(Page page, AccountInvoiceApplicationDto accountInvoiceApplicationDto) { |
| | | IPage<AccountInvoiceApplicationVo> listPage = accountInvoiceApplicationService.listPageAccountInvoiceApplication(page,accountInvoiceApplicationDto); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @GetMapping("/getOutboundBatchesByCustomer") |
| | | @Log(title = "æ ¹æ®å®¢æ·æ¥è¯¢åºåºåå·(å¼ç¥¨ç³è¯·)", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ ¹æ®å®¢æ·æ¥è¯¢åºåºåå·(å¼ç¥¨ç³è¯·)") |
| | | public R getOutboundBatchesByCustomer(Integer customerId) { |
| | | return R.ok(accountInvoiceApplicationService.getOutboundBatchesByCustomer(customerId)); |
| | | } |
| | | |
| | | @PostMapping("/addAccountInvoiceApplication") |
| | | @Log(title = "æ°å¢å¼ç¥¨ç³è¯·", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ°å¢å¼ç¥¨ç³è¯·") |
| | | public R addAccountInvoiceApplication(@RequestBody AccountInvoiceApplication accountInvoiceApplication) { |
| | | return R.ok(accountInvoiceApplicationService.addAccountInvoiceApplication(accountInvoiceApplication)); |
| | | } |
| | | |
| | | @PutMapping("/updateAccountInvoiceApplication") |
| | | @Log(title = "ä¿®æ¹å¼ç¥¨ç³è¯·", businessType = BusinessType.UPDATE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--ä¿®æ¹å¼ç¥¨ç³è¯·") |
| | | public R updateAccountInvoiceApplication(@RequestBody AccountInvoiceApplication accountInvoiceApplication) { |
| | | return R.ok(accountInvoiceApplicationService.updateById(accountInvoiceApplication)); |
| | | } |
| | | |
| | | @PutMapping("/auditAccountInvoiceApplication") |
| | | @Log(title = "å®¡æ ¸å¼ç¥¨ç³è¯·", businessType = BusinessType.UPDATE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å®¡æ ¸å¼ç¥¨ç³è¯·") |
| | | public R auditAccountInvoiceApplication(@RequestBody AccountInvoiceApplication accountInvoiceApplication) { |
| | | return R.ok(accountInvoiceApplicationService.updateById(accountInvoiceApplication)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteAccountInvoiceApplication") |
| | | @Log(title = "å é¤å¼ç¥¨ç³è¯·", businessType = BusinessType.DELETE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å é¤å¼ç¥¨ç³è¯·") |
| | | public R deleteAccountInvoiceApplication(@RequestParam("ids") Long[] ids) { |
| | | return R.ok(accountInvoiceApplicationService.deleteAccountInvoiceApplication(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PostMapping("/exportAccountInvoiceApplication") |
| | | @Operation(summary = "导åºå¼ç¥¨ç³è¯·æä»¶") |
| | | @Log(title = "导åºå¼ç¥¨ç³è¯·æä»¶", businessType = BusinessType.EXPORT) |
| | | public void exportAccountInvoiceApplication(HttpServletResponse response, AccountInvoiceApplicationDto accountInvoiceApplicationDto) { |
| | | accountInvoiceApplicationService.exportAccountInvoiceApplication(response,accountInvoiceApplicationDto); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.controller.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesCollectionDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesCollectionVo; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.account.service.sales.AccountSalesCollectionService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--æ¶æ¬¾å å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:49:56 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/accountSalesCollection") |
| | | @Tag(name = "è´¢å¡ç®¡ç--æ¶æ¬¾å") |
| | | @RequiredArgsConstructor |
| | | public class AccountSalesCollectionController { |
| | | |
| | | private final AccountSalesCollectionService accountSalesCollectionService; |
| | | |
| | | @GetMapping("/listPageAccountSalesCollection") |
| | | @Log(title = "æ¶æ¬¾åå°è´¦", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ¶æ¬¾åå°è´¦") |
| | | public R<IPage<AccountSalesCollectionVo>> listPageAccountSalesCollection(Page page, AccountSalesCollectionDto accountSalesCollectionDto) { |
| | | IPage<AccountSalesCollectionVo> listPage = accountSalesCollectionService.listPageAccountSalesCollection(page,accountSalesCollectionDto); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @GetMapping("/getOutboundBatchesByCustomer") |
| | | @Log(title = "æ ¹æ®å®¢æ·æ¥è¯¢åºåºåå·(æ¶æ¬¾å)", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ ¹æ®å®¢æ·æ¥è¯¢åºåºåå·(æ¶æ¬¾å)") |
| | | public R getOutboundBatchesByCustomer(Integer customerId) { |
| | | return R.ok(accountSalesCollectionService.getOutboundBatchesByCustomer(customerId)); |
| | | } |
| | | |
| | | @PostMapping("/addAccountSalesCollection") |
| | | @Log(title = "æ°å¢æ¶æ¬¾å", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ°å¢æ¶æ¬¾å") |
| | | public R addAccountSalesCollection(@RequestBody AccountSalesCollection accountSalesCollection) { |
| | | return R.ok(accountSalesCollectionService.addAccountSalesCollection(accountSalesCollection)); |
| | | } |
| | | |
| | | @PutMapping("/updateAccountSalesCollection") |
| | | @Log(title = "ç¼è¾æ¶æ¬¾å", businessType = BusinessType.UPDATE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--ç¼è¾æ¶æ¬¾å") |
| | | public R updateAccountSalesCollection(@RequestBody AccountSalesCollection accountSalesCollection) { |
| | | return R.ok(accountSalesCollectionService.updateById(accountSalesCollection)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteAccountSalesCollection") |
| | | @Log(title = "å 餿¶æ¬¾å", businessType = BusinessType.DELETE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å 餿¶æ¬¾å") |
| | | public R deleteAccountSalesCollection(@RequestParam("ids") Long[] ids) { |
| | | return R.ok(accountSalesCollectionService.deleteAccountSalesCollection(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PostMapping("/exportAccountSalesCollection") |
| | | @Operation(summary = "å¯¼åºæ¶æ¬¾åæä»¶") |
| | | @Log(title = "å¯¼åºæ¶æ¬¾åæä»¶", businessType = BusinessType.EXPORT) |
| | | public void exportAccountSalesCollection(HttpServletResponse response, AccountSalesCollectionDto accountSalesCollectionDto) { |
| | | accountSalesCollectionService.exportAccountSalesCollection(response,accountSalesCollectionDto); |
| | | } |
| | | |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/controller/AccountSalesController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.controller; |
| | | package com.ruoyi.account.controller.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.SalesReturnVo; |
| | | import com.ruoyi.account.service.AccountSalesService; |
| | | import com.ruoyi.account.bean.dto.sales.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesReturnVo; |
| | | import com.ruoyi.account.service.sales.AccountSalesService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.controller.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesInvoiceVo; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesInvoice; |
| | | import com.ruoyi.account.service.sales.AccountSalesInvoiceService; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--é项å票 å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:10:20 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/accountSalesInvoice") |
| | | @Tag(name = "è´¢å¡ç®¡ç--é项å票") |
| | | @RequiredArgsConstructor |
| | | public class AccountSalesInvoiceController { |
| | | |
| | | private final AccountSalesInvoiceService accountSalesInvoiceService; |
| | | |
| | | @GetMapping("/listPageAccountSalesInvoice") |
| | | @Log(title = "é项å票å°è´¦", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--é项å票å°è´¦") |
| | | public R<IPage<AccountSalesInvoiceVo>> listPageAccountSalesInvoice(Page page, AccountSalesInvoiceDto accountSalesInvoiceDto) { |
| | | IPage<AccountSalesInvoiceVo> listPage = accountSalesInvoiceService.listPageAccountSalesInvoice(page,accountSalesInvoiceDto); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @PostMapping("/addAccountSalesInvoice") |
| | | @Log(title = "æ°å¢é项å票", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--æ°å¢é项å票") |
| | | public R addAccountSalesInvoice(@RequestBody AccountSalesInvoice accountSalesInvoice) { |
| | | return R.ok(accountSalesInvoiceService.save(accountSalesInvoice)); |
| | | } |
| | | |
| | | @PutMapping("/cancelAccountSalesInvoice") |
| | | @Log(title = "ä½åºé项å票", businessType = BusinessType.INSERT) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--ä½åºé项å票") |
| | | public R cancelAccountSalesInvoice(@RequestBody AccountSalesInvoice accountSalesInvoice) { |
| | | return R.ok(accountSalesInvoiceService.updateById(accountSalesInvoice)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteAccountSalesInvoice") |
| | | @Log(title = "å é¤é项å票", businessType = BusinessType.DELETE) |
| | | @Operation(summary = "è´¢å¡ç®¡ç--å é¤é项å票") |
| | | public R deleteAccountSalesInvoice(@RequestParam("ids") Long[] ids) { |
| | | return R.ok(accountSalesInvoiceService.deleteAccountSalesInvoice(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PostMapping("/exportAccountSalesInvoice") |
| | | @Operation(summary = "导åºé项å票æä»¶") |
| | | @Log(title = "导åºé项å票æä»¶", businessType = BusinessType.EXPORT) |
| | | public void exportAccountSalesInvoice(HttpServletResponse response, AccountSalesInvoiceDto accountSalesInvoiceDto) { |
| | | accountSalesInvoiceService.exportAccountSalesInvoice(response,accountSalesInvoiceDto); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--对账åæç» Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 10:12:42 |
| | | */ |
| | | @Mapper |
| | | public interface AccountStatementDetailsMapper extends BaseMapper<AccountStatementDetails> { |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.StatementAccountDto; |
| | | import com.ruoyi.account.bean.vo.StatementAccountVo; |
| | | import com.ruoyi.account.pojo.AccountStatement; |
| | | import com.ruoyi.purchase.dto.VatDto; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 09:42:47 |
| | | */ |
| | | @Mapper |
| | | public interface AccountStatementMapper extends BaseMapper<AccountStatement> { |
| | | |
| | | |
| | | IPage<StatementAccountVo> listPageAccountStatement(Page page, @Param("req") StatementAccountDto statementAccountDto); |
| | | |
| | | IPage<VatDto> selectVatDtoPage(Page page, @Param("month") String month); |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/mapper/AccountSubjectMapper.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.mapper; |
| | | package com.ruoyi.account.mapper.financial; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.account.pojo.AccountSubject; |
| | | import com.ruoyi.account.pojo.financial.AccountSubject; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPaymentApplicationDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPaymentApplicationVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾ç³è¯· Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:44:22 |
| | | */ |
| | | @Mapper |
| | | public interface AccountPaymentApplicationMapper extends BaseMapper<AccountPaymentApplication> { |
| | | |
| | | IPage<AccountPaymentApplicationVo> listPageAccountPaymentApplication(Page page, @Param("req") AccountPaymentApplicationDto accountPaymentApplicationDto); |
| | | |
| | | List<PurchaseInboundVo> getInboundBatchesBySupplier(@Param("supplierId") Integer supplierId); |
| | | |
| | | //å¤æè¯¥åºåºè®°å½æ¯å¦æå¼ç¥¨ç³è¯· |
| | | boolean existsByStockInRecordId(@Param("stockInRecordIds") List<Long> stockInRecordIds); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchaseInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchaseInvoiceVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchaseInvoice; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--è¿é¡¹å票 Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:06:17 |
| | | */ |
| | | @Mapper |
| | | public interface AccountPurchaseInvoiceMapper extends BaseMapper<AccountPurchaseInvoice> { |
| | | |
| | | IPage<AccountPurchaseInvoiceVo> listPageAccountPurchaseInvoice(Page page, @Param("req") AccountPurchaseInvoiceDto accountPurchaseInvoiceDto); |
| | | |
| | | List<PurchaseInboundVo> getInboundBatchesBySupplier(@Param("supplierId") Integer supplierId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchasePaymentDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchasePaymentVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.home.dto.IncomeExpenseAnalysisDto; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾å Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 04:14:51 |
| | | */ |
| | | @Mapper |
| | | public interface AccountPurchasePaymentMapper extends BaseMapper<AccountPurchasePayment> { |
| | | |
| | | IPage<AccountPurchasePaymentVo> listPageAccountPurchasePayment(Page page, @Param("req") AccountPurchasePaymentDto accountPurchasePaymentDto); |
| | | |
| | | List<IncomeExpenseAnalysisDto> selectPayment(@Param("startStr") String startStr, @Param("endStr") String endStr, @Param("dateFormat") String dateFormat); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountInvoiceApplicationDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountInvoiceApplicationVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.pojo.sales.AccountInvoiceApplication; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯· Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 01:38:32 |
| | | */ |
| | | @Mapper |
| | | public interface AccountInvoiceApplicationMapper extends BaseMapper<AccountInvoiceApplication> { |
| | | |
| | | IPage<AccountInvoiceApplicationVo> listPageAccountInvoiceApplication(Page page, @Param("req") AccountInvoiceApplicationDto accountInvoiceApplicationDto); |
| | | |
| | | List<SalesOutboundVo> getOutboundBatchesByCustomer(@Param("customerId") Integer customerId); |
| | | |
| | | //å¤æè¯¥åºåºè®°å½æ¯å¦æå¼ç¥¨ç³è¯· |
| | | boolean existsByStockOutRecordId(@Param("stockOutRecordIds") List<Long> stockOutRecordIds); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesCollectionDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesCollectionVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.home.dto.IncomeExpenseAnalysisDto; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--æ¶æ¬¾å Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:49:56 |
| | | */ |
| | | @Mapper |
| | | public interface AccountSalesCollectionMapper extends BaseMapper<AccountSalesCollection> { |
| | | |
| | | IPage<AccountSalesCollectionVo> listPageAccountSalesCollection(Page page, @Param("req") AccountSalesCollectionDto accountSalesCollectionDto); |
| | | |
| | | //å¤æè¯¥åºåºè®°å½æ¯å¦ææ¶æ¬¾å |
| | | boolean existsByStockOutRecordId(@Param("stockOutRecordIds") List<Long> stockOutRecordIds); |
| | | |
| | | List<SalesOutboundVo> getOutboundBatchesByCustomer(@Param("customerId") Integer customerId); |
| | | |
| | | List<IncomeExpenseAnalysisDto> selectIncomeStats(@Param("startStr") String startStr, @Param("endStr") String endStr, @Param("dateFormat") String dateFormat); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.mapper.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesInvoiceVo; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesInvoice; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--é项å票 Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:10:20 |
| | | */ |
| | | @Mapper |
| | | public interface AccountSalesInvoiceMapper extends BaseMapper<AccountSalesInvoice> { |
| | | |
| | | IPage<AccountSalesInvoiceVo> listPageAccountSalesInvoice(Page page, @Param("req") AccountSalesInvoiceDto accountSalesInvoiceDto); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 09:42:47 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_statement") |
| | | @ApiModel(value = "AccountStatement对象", description = "è´¢å¡ç®¡ç--对账å") |
| | | public class AccountStatement implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 客æ·id(åºæ¶æ¯å®¢æ·customer,åºä»æ¯ä¾åºåsupplier) |
| | | */ |
| | | @ApiModelProperty("客æ·id") |
| | | private Integer customerId; |
| | | |
| | | /** |
| | | * 对账æä»½(yyyy-MM) |
| | | */ |
| | | @ApiModelProperty("对账æä»½(yyyy-MM)") |
| | | @Excel(name = "对账æä»½") |
| | | private String statementMonth; |
| | | |
| | | /** |
| | | * ä¸å¡ç±»å(1åºæ¶å¯¹è´¦;2åºä»å¯¹è´¦) |
| | | */ |
| | | @ApiModelProperty("ä¸å¡ç±»å(1åºæ¶å¯¹è´¦;2åºä»å¯¹è´¦)") |
| | | @Excel(name = "ä¸å¡ç±»å",readConverterExp = "1=åºæ¶å¯¹è´¦,2=åºä»å¯¹è´¦") |
| | | private Integer accountType; |
| | | |
| | | /** |
| | | * 对账åå· |
| | | */ |
| | | @ApiModelProperty("对账åå·") |
| | | @Excel(name = "对账åå·") |
| | | private String statementNumber; |
| | | |
| | | /** |
| | | * æåä½é¢ |
| | | */ |
| | | @ApiModelProperty("æåä½é¢") |
| | | @Excel(name = "æåä½é¢") |
| | | private BigDecimal openingBalance; |
| | | |
| | | /** |
| | | * æ¬æåºæ¶/åºä» |
| | | */ |
| | | @ApiModelProperty("æ¬æåºæ¶/åºä»") |
| | | @Excel(name = "æ¬æåºæ¶/åºä»") |
| | | private BigDecimal currentPlan; |
| | | |
| | | /** |
| | | * æ¬ææ¶æ¬¾/仿¬¾ |
| | | */ |
| | | @ApiModelProperty("æ¬ææ¶æ¬¾/仿¬¾") |
| | | @Excel(name = "æ¬ææ¶æ¬¾/仿¬¾") |
| | | private BigDecimal currentActually; |
| | | |
| | | /** |
| | | * ææ«ä½é¢ |
| | | */ |
| | | @ApiModelProperty("ææ«ä½é¢") |
| | | @Excel(name = "ææ«ä½é¢") |
| | | private BigDecimal closingBalance; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--对账åæç» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 10:12:42 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_statement_details") |
| | | @ApiModel(value = "AccountStatementDetails对象", description = "è´¢å¡ç®¡ç--对账åæç»") |
| | | public class AccountStatementDetails implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * å
³è对账åid |
| | | */ |
| | | @ApiModelProperty("å
³è对账åid") |
| | | private Integer accountStatementId; |
| | | |
| | | /** |
| | | * æ°æ®æ¥æ |
| | | */ |
| | | @ApiModelProperty("æ°æ®æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate occurrenceDate; |
| | | |
| | | /** |
| | | * åæ®ç¼å· |
| | | */ |
| | | @ApiModelProperty("åæ®ç¼å·") |
| | | private String receiptNumber; |
| | | |
| | | /** |
| | | * æ°æ®ç±»å(1åºåº;2å
¥åº;3æ¶æ¬¾;4仿¬¾;5éè´§) |
| | | */ |
| | | @ApiModelProperty("æ°æ®ç±»å(1åºåº;2å
¥åº;3æ¶æ¬¾;4仿¬¾;5éè´§)") |
| | | private Integer type; |
| | | |
| | | /** |
| | | * éé¢ |
| | | */ |
| | | @ApiModelProperty("éé¢") |
| | | private BigDecimal amount; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/pojo/AccountSubject.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.pojo; |
| | | package com.ruoyi.account.pojo.financial; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private String createUser; |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private String updateUser; |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾ç³è¯· |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:44:22 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_payment_application") |
| | | @ApiModel(value = "AccountPaymentApplication对象", description = "è´¢å¡ç®¡ç--仿¬¾ç³è¯·") |
| | | public class AccountPaymentApplication implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ä¾åºåid |
| | | */ |
| | | @ApiModelProperty("ä¾åºåid") |
| | | private Integer supplierId; |
| | | |
| | | /** |
| | | * å
³èå
¥åºåid(å¤é) |
| | | */ |
| | | @ApiModelProperty("å
³èå
¥åºåid(å¤é)") |
| | | private String stockInRecordIds; |
| | | |
| | | /** |
| | | * 仿¬¾ç³è¯·åå· |
| | | */ |
| | | @ApiModelProperty("仿¬¾ç³è¯·åå·") |
| | | @Excel(name = "仿¬¾ç³è¯·åå·") |
| | | private String invoiceApplicationNo; |
| | | |
| | | /** |
| | | * 仿¬¾æ¹å¼ |
| | | */ |
| | | @ApiModelProperty("仿¬¾æ¹å¼") |
| | | @Excel(name = "仿¬¾æ¹å¼") |
| | | private String paymentMethod; |
| | | |
| | | /** |
| | | * 仿¬¾äºç± |
| | | */ |
| | | @ApiModelProperty("仿¬¾äºç±") |
| | | @Excel(name = "仿¬¾äºç±") |
| | | private String paymentContent; |
| | | |
| | | /** |
| | | * ç³è¯·æ¥æ |
| | | */ |
| | | @ApiModelProperty("ç³è¯·æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "ç³è¯·æ¥æ") |
| | | private LocalDate applyDate; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * å®¡æ ¸ç¶æ:0å¾
å®¡æ ¸1å®¡æ ¸éè¿2å®¡æ ¸ä¸éè¿ |
| | | */ |
| | | @ApiModelProperty("å®¡æ ¸ç¶æ:0å¾
å®¡æ ¸1å®¡æ ¸éè¿2å®¡æ ¸ä¸éè¿") |
| | | @Excel(name = "å®¡æ ¸ç¶æ",readConverterExp = "0=å¾
å®¡æ ¸,1=å®¡æ ¸éè¿,2=å®¡æ ¸ä¸éè¿") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 仿¬¾éé¢ |
| | | */ |
| | | @ApiModelProperty("仿¬¾éé¢") |
| | | @Excel(name = "仿¬¾éé¢") |
| | | private BigDecimal paymentAmount; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--è¿é¡¹å票 |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:06:17 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_purchase_invoice") |
| | | @ApiModel(value = "AccountPurchaseInvoice对象", description = "è´¢å¡ç®¡ç--è¿é¡¹å票") |
| | | public class AccountPurchaseInvoice implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * å票å·ç |
| | | */ |
| | | @ApiModelProperty("å票å·ç ") |
| | | @Excel(name = "å票å·ç ") |
| | | private String invoiceNumber; |
| | | |
| | | /** |
| | | * ç¨ç |
| | | */ |
| | | @ApiModelProperty("ç¨ç") |
| | | @Excel(name = "ç¨ç") |
| | | private Integer taxRate; |
| | | |
| | | /** |
| | | * å票类å |
| | | */ |
| | | @ApiModelProperty("å票类å") |
| | | @Excel(name = "å票类å") |
| | | private String invoiceType; |
| | | |
| | | /** |
| | | * å¼ç¥¨æ¥æ |
| | | */ |
| | | @ApiModelProperty("å¼ç¥¨æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "å¼ç¥¨æ¥æ") |
| | | private LocalDate issueDate; |
| | | |
| | | /** |
| | | * éé¢(ä¸å«ç¨) |
| | | */ |
| | | @ApiModelProperty("éé¢(ä¸å«ç¨)") |
| | | @Excel(name = "éé¢(ä¸å«ç¨)") |
| | | private BigDecimal taxExclusivelPrice; |
| | | |
| | | /** |
| | | * ç¨é¢ |
| | | */ |
| | | @ApiModelProperty("ç¨é¢") |
| | | @Excel(name = "ç¨é¢") |
| | | private BigDecimal taxPrice; |
| | | |
| | | /** |
| | | * ä»·ç¨å计 |
| | | */ |
| | | @ApiModelProperty("ä»·ç¨å计") |
| | | @Excel(name = "ä»·ç¨å计") |
| | | private BigDecimal taxInclusivePrice; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * å票å
容 |
| | | */ |
| | | @ApiModelProperty("å票å
容") |
| | | @Excel(name = "å票å
容") |
| | | private String invoiceContent; |
| | | |
| | | /** |
| | | * ä¾åºåid |
| | | */ |
| | | @ApiModelProperty("ä¾åºåid") |
| | | private Integer supplierId; |
| | | |
| | | /** |
| | | * å
³èä¸ä¼ çå票éä»¶id |
| | | */ |
| | | @ApiModelProperty("å
³èä¸ä¼ çå票éä»¶id") |
| | | private Integer storageAttachmentId; |
| | | |
| | | /** |
| | | * å
³èå
¥åºåid(å¤é) |
| | | */ |
| | | @ApiModelProperty("å
³èå
¥åºåid(å¤é)") |
| | | private String stockInRecordIds; |
| | | |
| | | /** |
| | | * ç¶æ 0å¯ç¨ 1ç¦ç¨ |
| | | */ |
| | | @ApiModelProperty("ç¶æ 0å¯ç¨ 1ç¦ç¨") |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=ä½åº") |
| | | private Integer status; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾å |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 04:14:51 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_purchase_payment") |
| | | @ApiModel(value = "AccountPurchasePayment对象", description = "è´¢å¡ç®¡ç--仿¬¾å") |
| | | public class AccountPurchasePayment implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * å
³è仿¬¾ç³è¯·id |
| | | */ |
| | | @ApiModelProperty("å
³è仿¬¾ç³è¯·id") |
| | | private Integer accountPaymentApplicationId; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * ä¾åºåid |
| | | */ |
| | | @ApiModelProperty("ä¾åºåid") |
| | | private Integer supplierId; |
| | | |
| | | /** |
| | | * 仿¬¾æ¥æ |
| | | */ |
| | | @ApiModelProperty("仿¬¾æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "仿¬¾æ¥æ") |
| | | private LocalDate paymentDate; |
| | | |
| | | /** |
| | | * 仿¬¾æ¹å¼ |
| | | */ |
| | | @ApiModelProperty("仿¬¾æ¹å¼") |
| | | @Excel(name = "仿¬¾æ¹å¼",dictType = "checkout_payment") |
| | | private String paymentMethod; |
| | | |
| | | /** |
| | | * 仿¬¾éé¢ |
| | | */ |
| | | @ApiModelProperty("仿¬¾éé¢") |
| | | @Excel(name = "仿¬¾éé¢") |
| | | private BigDecimal paymentAmount; |
| | | |
| | | /** |
| | | * 仿¬¾åå· |
| | | */ |
| | | @ApiModelProperty("仿¬¾åå·") |
| | | @Excel(name = "仿¬¾åå·") |
| | | private String paymentNumber; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo.sales; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯· |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 01:38:32 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_invoice_application") |
| | | @ApiModel(value = "AccountInvoiceApplication对象", description = "è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯·") |
| | | public class AccountInvoiceApplication implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 客æ·id |
| | | */ |
| | | @ApiModelProperty("客æ·id") |
| | | private Integer customerId; |
| | | |
| | | /** |
| | | * å
³èåºåºåid(å¤é) |
| | | */ |
| | | @ApiModelProperty("å
³èåºåºåid(å¤é)") |
| | | private String stockOutRecordIds; |
| | | |
| | | /** |
| | | * å¼ç¥¨ç³è¯·åå· |
| | | */ |
| | | @ApiModelProperty("å¼ç¥¨ç³è¯·åå·") |
| | | @Excel(name = "å¼ç¥¨ç³è¯·åå·") |
| | | private String invoiceApplicationNo; |
| | | |
| | | /** |
| | | * å票类å |
| | | */ |
| | | @ApiModelProperty("å票类å") |
| | | @Excel(name = "å票类å") |
| | | private String invoiceType; |
| | | |
| | | /** |
| | | * ç³è¯·æ¥æ |
| | | */ |
| | | @ApiModelProperty("ç³è¯·æ¥æ") |
| | | @Excel(name = "ç³è¯·æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate applyDate; |
| | | |
| | | /** |
| | | * å票å
容 |
| | | */ |
| | | @ApiModelProperty("å票å
容") |
| | | @Excel(name = "å票å
容") |
| | | private String invoiceContent; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * å®¡æ ¸ç¶æ:0å¾
å®¡æ ¸1å®¡æ ¸éè¿2å®¡æ ¸ä¸éè¿ |
| | | */ |
| | | @ApiModelProperty("å®¡æ ¸ç¶æ:0å¾
å®¡æ ¸1å®¡æ ¸éè¿2å®¡æ ¸ä¸éè¿") |
| | | @Excel(name = "å®¡æ ¸ç¶æ",readConverterExp = "0=å¾
å®¡æ ¸,1=å®¡æ ¸éè¿,2=å®¡æ ¸ä¸éè¿") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty("å¼ç¥¨éé¢") |
| | | @Excel(name = "å¼ç¥¨éé¢") |
| | | private BigDecimal invoiceAmount; |
| | | |
| | | @ApiModelProperty("ç¨ç") |
| | | @Excel(name = "ç¨ç") |
| | | private BigDecimal taxRate; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo.sales; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--æ¶æ¬¾å |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:49:56 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_sales_collection") |
| | | @ApiModel(value = "AccountSalesCollection对象", description = "è´¢å¡ç®¡ç--æ¶æ¬¾å") |
| | | public class AccountSalesCollection implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * å
³èåºåºåid(å¤é) |
| | | */ |
| | | @ApiModelProperty("å
³èåºåºåid(å¤é)") |
| | | private String stockOutRecordIds; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * 客æ·id |
| | | */ |
| | | @ApiModelProperty("客æ·id") |
| | | private Integer customerId; |
| | | |
| | | /** |
| | | * æ¶æ¬¾æ¥æ |
| | | */ |
| | | @ApiModelProperty("æ¶æ¬¾æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | @Excel(name = "æ¶æ¬¾æ¥æ") |
| | | private LocalDate collectionDate; |
| | | |
| | | /** |
| | | * æ¶æ¬¾éé¢ |
| | | */ |
| | | @ApiModelProperty("æ¶æ¬¾éé¢") |
| | | @Excel(name = "æ¶æ¬¾éé¢") |
| | | private BigDecimal collectionAmount; |
| | | |
| | | /** |
| | | * æ¶æ¬¾æ¹å¼ |
| | | */ |
| | | @ApiModelProperty("æ¶æ¬¾æ¹å¼") |
| | | @Excel(name = "æ¶æ¬¾æ¹å¼",dictType = "payment_methods") |
| | | private String collectionMethod; |
| | | |
| | | /** |
| | | * æ¶æ¬¾åå· |
| | | */ |
| | | @ApiModelProperty("æ¶æ¬¾åå·") |
| | | @Excel(name = "æ¶æ¬¾åå·") |
| | | private String collectionNumber; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.pojo.sales; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.ToString; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--é项å票 |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:10:20 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @ToString |
| | | @TableName("account_sales_invoice") |
| | | @ApiModel(value = "AccountSalesInvoice对象", description = "è´¢å¡ç®¡ç--é项å票") |
| | | public class AccountSalesInvoice implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * å
³èå¼ç¥¨ç³è¯·id |
| | | */ |
| | | @ApiModelProperty("å
³èå¼ç¥¨ç³è¯·id") |
| | | private Integer accountInvoiceApplicationId; |
| | | |
| | | /** |
| | | * å建人 |
| | | */ |
| | | @ApiModelProperty("å建人") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | /** |
| | | * å建æ¶é´ |
| | | */ |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äºº |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹äºº") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime updateTime; |
| | | |
| | | /** |
| | | * é¨é¨ID |
| | | */ |
| | | @ApiModelProperty("é¨é¨ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * å票å·ç |
| | | */ |
| | | @ApiModelProperty("å票å·ç ") |
| | | @Excel(name = "å票å·ç ") |
| | | private String invoiceNumber; |
| | | |
| | | /** |
| | | * ç¨ç |
| | | */ |
| | | @ApiModelProperty("ç¨ç") |
| | | @Excel(name = "ç¨ç") |
| | | private BigDecimal taxRate; |
| | | |
| | | /** |
| | | * å票类å |
| | | */ |
| | | @ApiModelProperty("å票类å") |
| | | @Excel(name = "å票类å") |
| | | private String invoiceType; |
| | | |
| | | /** |
| | | * å¼ç¥¨æ¥æ |
| | | */ |
| | | @ApiModelProperty("å¼ç¥¨æ¥æ") |
| | | @Excel(name = "å¼ç¥¨æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate issueDate; |
| | | |
| | | /** |
| | | * éé¢(ä¸å«ç¨) |
| | | */ |
| | | @ApiModelProperty("éé¢(ä¸å«ç¨)") |
| | | @Excel(name = "éé¢(ä¸å«ç¨)") |
| | | private BigDecimal taxExclusivelPrice; |
| | | |
| | | /** |
| | | * ç¨é¢ |
| | | */ |
| | | @ApiModelProperty("ç¨é¢") |
| | | @Excel(name = "ç¨é¢") |
| | | private BigDecimal taxPrice; |
| | | |
| | | /** |
| | | * ä»·ç¨å计 |
| | | */ |
| | | @ApiModelProperty("ä»·ç¨å计") |
| | | @Excel(name = "ä»·ç¨å计") |
| | | private BigDecimal taxInclusivePrice; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty("夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * å票å
容 |
| | | */ |
| | | @ApiModelProperty("å票å
容") |
| | | @Excel(name = "å票å
容") |
| | | private String invoiceContent; |
| | | |
| | | /** |
| | | * 客æ·id |
| | | */ |
| | | @ApiModelProperty("客æ·id") |
| | | private Integer customerId; |
| | | |
| | | /** |
| | | * å
³èä¸ä¼ çå票éä»¶id |
| | | */ |
| | | @ApiModelProperty("å
³èä¸ä¼ çå票éä»¶id") |
| | | private Integer storageAttachmentId; |
| | | |
| | | /** |
| | | * ç¶æ 0å¯ç¨ 1ç¦ç¨ |
| | | */ |
| | | @ApiModelProperty("ç¶æ 0å¯ç¨ 1ç¦ç¨") |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=æ£å¸¸,1=ä½åº") |
| | | private Integer status; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--对账åæç» æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 10:12:42 |
| | | */ |
| | | public interface AccountStatementDetailsService extends IService<AccountStatementDetails> { |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.bean.dto.StatementAccountDto; |
| | | import com.ruoyi.account.bean.vo.StatementAccountVo; |
| | | import com.ruoyi.account.pojo.AccountStatement; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 09:42:47 |
| | | */ |
| | | public interface AccountStatementService extends IService<AccountStatement> { |
| | | |
| | | StatementAccountVo getAccountStatementDetailsByMonth(StatementAccountDto statementAccountDto); |
| | | |
| | | boolean addAccountStatement(StatementAccountVo statementAccountVo); |
| | | |
| | | boolean deleteAccountStatement(List<Long> ids); |
| | | |
| | | IPage<StatementAccountVo> listPageAccountStatement(Page page, StatementAccountDto statementAccountDto); |
| | | |
| | | void exportAccountStatement(HttpServletResponse response, StatementAccountDto statementAccountDto); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.AccountReportDto; |
| | | import com.ruoyi.account.bean.vo.AccountReportVo; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | |
| | | public interface AccountingService { |
| | | |
| | | AjaxResult total(Integer year); |
| | | |
| | | AjaxResult deviceTypeDistribution(Integer year); |
| | | |
| | | AjaxResult calculateDepreciation(Page page, Integer year); |
| | | |
| | | AccountReportVo getAccountStatementDetailsByMonth(AccountReportDto accountReportDto); |
| | | |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/service/AccountPurchaseService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.service; |
| | | package com.ruoyi.account.service.financial; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.vo.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.PurchaseReturnVo; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseReturnVo; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.ruoyi.account.mapper.AccountStatementDetailsMapper; |
| | | import com.ruoyi.account.service.AccountStatementDetailsService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--对账åæç» æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 10:12:42 |
| | | */ |
| | | @Service |
| | | public class AccountStatementDetailsServiceImpl extends ServiceImpl<AccountStatementDetailsMapper, AccountStatementDetails> implements AccountStatementDetailsService { |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.StatementAccountDto; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.StatementAccountVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseReturnVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesReturnVo; |
| | | import com.ruoyi.account.mapper.AccountStatementDetailsMapper; |
| | | import com.ruoyi.account.mapper.AccountStatementMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.AccountStatement; |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.account.service.AccountStatementService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockOutRecordMapper; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.YearMonth; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 09:42:47 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class AccountStatementServiceImpl extends ServiceImpl<AccountStatementMapper, AccountStatement> implements AccountStatementService { |
| | | |
| | | private final AccountStatementMapper accountStatementMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final StockOutRecordMapper stockOutRecordMapper; |
| | | private final StockInRecordMapper stockInRecordMapper; |
| | | private final ReturnManagementMapper returnManagementMapper; |
| | | private final AccountStatementDetailsMapper accountStatementDetailsMapper; |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final PurchaseReturnOrdersMapper purchaseReturnOrdersMapper; |
| | | private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMdd"); |
| | | |
| | | @Override |
| | | public StatementAccountVo getAccountStatementDetailsByMonth(StatementAccountDto statementAccountDto) { |
| | | //对账æä»½è½¬æ¢æå¼å§æ¥æåç»ææ¥æåºé´ |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); |
| | | YearMonth yearMonth = YearMonth.parse(statementAccountDto.getStatementMonth(), formatter); |
| | | statementAccountDto.setStartDate(yearMonth.atDay(1)); |
| | | statementAccountDto.setEndDate(yearMonth.atEndOfMonth()); |
| | | if (statementAccountDto.getAccountType() == 1){ |
| | | //åºæ¶å¯¹è´¦--Customer |
| | | return getAccountStatementDetailsByCustomerAndMonth(statementAccountDto); |
| | | }else { |
| | | //åºä»å¯¹è´¦--SupplierManage |
| | | return getAccountStatementDetailsBySupplierAndMonth(statementAccountDto); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAccountStatement(StatementAccountVo statementAccountVo) { |
| | | //åä¸å®¢æ·æè
åä¸ä¾åºå,ä¸ä¸ªæä»½åªè½æä¸ä¸ªå¯¹è´¦å |
| | | List<AccountStatement> accountStatements = accountStatementMapper.selectList(Wrappers.<AccountStatement>lambdaQuery() |
| | | .eq(AccountStatement::getStatementMonth, statementAccountVo.getStatementMonth()) |
| | | .eq(AccountStatement::getAccountType, statementAccountVo.getAccountType()) |
| | | .eq(AccountStatement::getCustomerId, statementAccountVo.getCustomerId())); |
| | | if (CollectionUtils.isNotEmpty(accountStatements)){ |
| | | throw new ServiceException("åä¸å®¢æ·æè
åä¸ä¾åºå,ä¸ä¸ªæä»½åªè½æä¸ä¸ªå¯¹è´¦å"); |
| | | } |
| | | AccountStatement accountStatement = new AccountStatement(); |
| | | BeanUtils.copyProperties(statementAccountVo, accountStatement); |
| | | accountStatement.setStatementNumber(genStatementAccountNo()); |
| | | boolean save = save(accountStatement); |
| | | statementAccountVo.getAccountStatementDetails().stream().forEach(accountStatementDetails -> { |
| | | accountStatementDetails.setAccountStatementId(accountStatement.getId()); |
| | | //æ·»å 对账åæç» |
| | | accountStatementDetailsMapper.insert(accountStatementDetails); |
| | | }); |
| | | return save; |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAccountStatement(List<Long> ids) { |
| | | //å é¤å¯¹è´¦åæç» |
| | | accountStatementDetailsMapper.delete(Wrappers.<AccountStatementDetails>lambdaQuery().in(AccountStatementDetails::getAccountStatementId, ids)); |
| | | return removeByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<StatementAccountVo> listPageAccountStatement(Page page, StatementAccountDto statementAccountDto) { |
| | | return accountStatementMapper.listPageAccountStatement(page, statementAccountDto); |
| | | } |
| | | |
| | | @Override |
| | | public void exportAccountStatement(HttpServletResponse response, StatementAccountDto statementAccountDto) { |
| | | List<StatementAccountVo> list = accountStatementMapper.listPageAccountStatement(new Page(1,-1),statementAccountDto).getRecords(); |
| | | ExcelUtil<StatementAccountVo> util = new ExcelUtil<>(StatementAccountVo.class); |
| | | util.exportExcel(response, list , "对账å"); |
| | | } |
| | | |
| | | //æ ¹æ®å®¢æ·åæä»½è·å对账详æ
(éå®) |
| | | private StatementAccountVo getAccountStatementDetailsByCustomerAndMonth(StatementAccountDto statementAccountDto) { |
| | | StatementAccountVo statementAccountVo = new StatementAccountVo(); |
| | | statementAccountVo.setAccountType(1);//åºæ¶å¯¹è´¦ |
| | | List<AccountStatementDetails> accountStatementDetailsList = new ArrayList<>(); |
| | | /*æ¥è¯¢åºåºæç»*/ |
| | | SalesOutboundDto salesOutboundDto = new SalesOutboundDto(); |
| | | salesOutboundDto.setCustomerId(statementAccountDto.getCustomerId()); |
| | | salesOutboundDto.setStartDate(statementAccountDto.getStartDate()); |
| | | salesOutboundDto.setEndDate(statementAccountDto.getEndDate()); |
| | | List<SalesOutboundVo> salesOutboundVos = stockOutRecordMapper.listPageAccountSales(new Page(1, -1), salesOutboundDto).getRecords(); |
| | | salesOutboundVos.stream().forEach(salesOutboundVo -> { |
| | | AccountStatementDetails accountStatementDetails = new AccountStatementDetails(); |
| | | //æ°æ®æ¥æ=åºåºæ¥æ |
| | | accountStatementDetails.setOccurrenceDate(salesOutboundVo.getShippingDate()); |
| | | //åæ®ç¼å·=åºåºåå· |
| | | accountStatementDetails.setReceiptNumber(salesOutboundVo.getOutboundBatches()); |
| | | //ç±»å=åºåº |
| | | accountStatementDetails.setType(1); |
| | | //éé¢=åºåºéé¢ |
| | | accountStatementDetails.setAmount(salesOutboundVo.getOutboundAmount()); |
| | | //夿³¨ |
| | | accountStatementDetails.setRemark("产åéå®åºåºï¼äº§åï¼"+salesOutboundVo.getProductName()); |
| | | accountStatementDetailsList.add(accountStatementDetails); |
| | | }); |
| | | /*æ¥è¯¢æ¶æ¬¾æç»*/ |
| | | List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectList(Wrappers.<AccountSalesCollection>lambdaQuery() |
| | | .eq(AccountSalesCollection::getCustomerId, statementAccountDto.getCustomerId()) |
| | | .between(AccountSalesCollection::getCollectionDate, statementAccountDto.getStartDate(), statementAccountDto.getEndDate())); |
| | | accountSalesCollections.stream().forEach(accountSalesCollection -> { |
| | | AccountStatementDetails accountStatementDetails = new AccountStatementDetails(); |
| | | //æ°æ®æ¥æ=æ¶æ¬¾æ¥æ |
| | | accountStatementDetails.setOccurrenceDate(accountSalesCollection.getCollectionDate()); |
| | | //åæ®ç¼å·=æ¶æ¬¾åå· |
| | | accountStatementDetails.setReceiptNumber(accountSalesCollection.getCollectionNumber()); |
| | | //ç±»å=æ¶æ¬¾ |
| | | accountStatementDetails.setType(3); |
| | | //éé¢=æ¶æ¬¾éé¢ |
| | | accountStatementDetails.setAmount(accountSalesCollection.getCollectionAmount()); |
| | | //夿³¨ |
| | | accountStatementDetails.setRemark("客æ·å款ï¼å¤æ³¨ï¼"+accountSalesCollection.getRemark()); |
| | | accountStatementDetailsList.add(accountStatementDetails); |
| | | }); |
| | | /*æ¥è¯¢éè´§æç»*/ |
| | | SalesReturnDto salesReturnDto = new SalesReturnDto(); |
| | | salesReturnDto.setCustomerId(statementAccountDto.getCustomerId()); |
| | | salesReturnDto.setStartDate(statementAccountDto.getStartDate()); |
| | | salesReturnDto.setEndDate(statementAccountDto.getEndDate()); |
| | | List<SalesReturnVo> salesReturnVos = returnManagementMapper.listPageAccountSalesReturn(new Page(1, -1), salesReturnDto).getRecords(); |
| | | salesReturnVos.stream().forEach(salesReturnVo -> { |
| | | AccountStatementDetails accountStatementDetails = new AccountStatementDetails(); |
| | | //æ°æ®æ¥æ=éè´§æ¥æ |
| | | accountStatementDetails.setOccurrenceDate(salesReturnVo.getMakeTime().toLocalDate()); |
| | | //åæ®ç¼å·=éè´§åå· |
| | | accountStatementDetails.setReceiptNumber(salesReturnVo.getReturnNo()); |
| | | //ç±»å=éè´§ |
| | | accountStatementDetails.setType(5); |
| | | //éé¢=鿬¾éé¢ |
| | | accountStatementDetails.setAmount(salesReturnVo.getRefundAmount()); |
| | | //夿³¨ |
| | | accountStatementDetails.setRemark("产åéè´§ï¼åå ï¼"+salesReturnVo.getReturnReason()); |
| | | accountStatementDetailsList.add(accountStatementDetails); |
| | | }); |
| | | //æåä½é¢=ä¸ä¸ªæçææ«ä½é¢ |
| | | statementAccountVo.setOpeningBalance(BigDecimal.ZERO); |
| | | List<AccountStatement> accountStatements = accountStatementMapper.selectList(Wrappers.<AccountStatement>lambdaQuery() |
| | | .eq(AccountStatement::getAccountType, 1) |
| | | .eq(AccountStatement::getCustomerId, statementAccountDto.getCustomerId()) |
| | | .eq(AccountStatement::getStatementMonth, |
| | | YearMonth.parse(statementAccountDto.getStatementMonth()).minusMonths(1).toString())); |
| | | if (CollectionUtils.isNotEmpty(accountStatements)){ |
| | | statementAccountVo.setOpeningBalance(accountStatements.get(accountStatements.size() - 1).getClosingBalance()); |
| | | } |
| | | //æ¬æåºæ¶=åºåº-éè´§éé¢ç´¯è®¡ |
| | | statementAccountVo.setCurrentPlan(salesOutboundVos.stream().map(SalesOutboundVo::getOutboundAmount).reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | .subtract(salesReturnVos.stream().map(SalesReturnVo::getRefundAmount).reduce(BigDecimal.ZERO, BigDecimal::add))); |
| | | //æ¬ææ¶æ¬¾=æ¶æ¬¾éé¢ç´¯è®¡ |
| | | statementAccountVo.setCurrentActually(accountSalesCollections.stream().map(AccountSalesCollection::getCollectionAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | //ææ«ä½é¢=æå+åºæ¶-æ¶æ¬¾ |
| | | statementAccountVo.setClosingBalance(statementAccountVo.getOpeningBalance().add(statementAccountVo.getCurrentPlan()).subtract(statementAccountVo.getCurrentActually())); |
| | | statementAccountVo.setAccountStatementDetails(accountStatementDetailsList); |
| | | return statementAccountVo; |
| | | } |
| | | |
| | | //æ ¹æ®ä¾åºååæä»½è·å对账详æ
(éè´) |
| | | private StatementAccountVo getAccountStatementDetailsBySupplierAndMonth(StatementAccountDto statementAccountDto) { |
| | | StatementAccountVo statementAccountVo = new StatementAccountVo(); |
| | | statementAccountVo.setAccountType(2);//åºä»å¯¹è´¦ |
| | | List<AccountStatementDetails> accountStatementDetailsList = new ArrayList<>(); |
| | | /*æ¥è¯¢å
¥åºæç»*/ |
| | | PurchaseInboundDto purchaseInboundDto = new PurchaseInboundDto(); |
| | | purchaseInboundDto.setSupplierId(statementAccountDto.getCustomerId()); |
| | | purchaseInboundDto.setStartDate(statementAccountDto.getStartDate()); |
| | | purchaseInboundDto.setEndDate(statementAccountDto.getEndDate()); |
| | | List<PurchaseInboundVo> purchaseInboundVos = stockInRecordMapper.listPageAccountPurchase(new Page(1, -1), purchaseInboundDto).getRecords(); |
| | | purchaseInboundVos.stream().forEach(purchaseInboundVo -> { |
| | | AccountStatementDetails accountStatementDetails = new AccountStatementDetails(); |
| | | //æ°æ®æ¥æ=å
¥åºæ¥æ |
| | | accountStatementDetails.setOccurrenceDate(purchaseInboundVo.getInboundDate()); |
| | | //åæ®ç¼å·=å
¥åºåå· |
| | | accountStatementDetails.setReceiptNumber(purchaseInboundVo.getInboundBatches()); |
| | | //ç±»å=å
¥åº |
| | | accountStatementDetails.setType(2); |
| | | //éé¢=å
¥åºéé¢ |
| | | accountStatementDetails.setAmount(purchaseInboundVo.getInboundAmount()); |
| | | //夿³¨ |
| | | accountStatementDetails.setRemark("产åéè´å
¥åºï¼äº§åï¼"+purchaseInboundVo.getProductName()); |
| | | accountStatementDetailsList.add(accountStatementDetails); |
| | | }); |
| | | /*æ¥è¯¢ä»æ¬¾æç»*/ |
| | | List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery() |
| | | .eq(AccountPurchasePayment::getSupplierId, statementAccountDto.getCustomerId()) |
| | | .between(AccountPurchasePayment::getPaymentDate, statementAccountDto.getStartDate(), statementAccountDto.getEndDate())); |
| | | accountPurchasePayments.stream().forEach(accountPurchasePayment -> { |
| | | AccountStatementDetails accountStatementDetails = new AccountStatementDetails(); |
| | | //æ°æ®æ¥æ=仿¬¾æ¥æ |
| | | accountStatementDetails.setOccurrenceDate(accountPurchasePayment.getPaymentDate()); |
| | | //åæ®ç¼å·=仿¬¾åå· |
| | | accountStatementDetails.setReceiptNumber(accountPurchasePayment.getPaymentNumber()); |
| | | //ç±»å=仿¬¾ |
| | | accountStatementDetails.setType(4); |
| | | //éé¢=仿¬¾éé¢ |
| | | accountStatementDetails.setAmount(accountPurchasePayment.getPaymentAmount()); |
| | | //夿³¨ |
| | | accountStatementDetails.setRemark("æ¯ä»è´§æ¬¾ï¼å¤æ³¨ï¼"+accountPurchasePayment.getRemark()); |
| | | accountStatementDetailsList.add(accountStatementDetails); |
| | | }); |
| | | /*æ¥è¯¢éè´§æç»*/ |
| | | PurchaseReturnDto purchaseReturnDto = new PurchaseReturnDto(); |
| | | purchaseReturnDto.setSupplierId(statementAccountDto.getCustomerId()); |
| | | purchaseReturnDto.setStartDate(statementAccountDto.getStartDate()); |
| | | purchaseReturnDto.setEndDate(statementAccountDto.getEndDate()); |
| | | List<PurchaseReturnVo> purchaseReturnVos = purchaseReturnOrdersMapper.listPageAccountPurchaseReturn(new Page(1, -1), purchaseReturnDto).getRecords(); |
| | | purchaseReturnVos.stream().forEach(purchaseReturnVo -> { |
| | | AccountStatementDetails accountStatementDetails = new AccountStatementDetails(); |
| | | //æ°æ®æ¥æ=éè´§æ¥æ |
| | | accountStatementDetails.setOccurrenceDate(purchaseReturnVo.getPreparedAt().toLocalDate()); |
| | | //åæ®ç¼å·=éè´§åå· |
| | | accountStatementDetails.setReceiptNumber(purchaseReturnVo.getReturnNo()); |
| | | //ç±»å=éè´§ |
| | | accountStatementDetails.setType(5); |
| | | //éé¢=鿬¾éé¢ |
| | | accountStatementDetails.setAmount(purchaseReturnVo.getTotalAmount()); |
| | | //夿³¨ |
| | | accountStatementDetails.setRemark("产åéè´§ï¼éè´§æ¹å¼ï¼"+purchaseReturnVo.getReturnType()); |
| | | accountStatementDetailsList.add(accountStatementDetails); |
| | | }); |
| | | //æåä½é¢=ä¸ä¸ªæçææ«ä½é¢ |
| | | statementAccountVo.setOpeningBalance(BigDecimal.ZERO); |
| | | List<AccountStatement> accountStatements = accountStatementMapper.selectList(Wrappers.<AccountStatement>lambdaQuery() |
| | | .eq(AccountStatement::getAccountType, 2) |
| | | .eq(AccountStatement::getCustomerId, statementAccountDto.getCustomerId()) |
| | | .eq(AccountStatement::getStatementMonth, |
| | | YearMonth.parse(statementAccountDto.getStatementMonth()).minusMonths(1).toString())); |
| | | if (CollectionUtils.isNotEmpty(accountStatements)){ |
| | | statementAccountVo.setOpeningBalance(accountStatements.get(accountStatements.size() - 1).getClosingBalance()); |
| | | } |
| | | //æ¬æåºä»=å
¥åº-éè´§éé¢ç´¯è®¡ |
| | | statementAccountVo.setCurrentPlan(purchaseInboundVos.stream().map(PurchaseInboundVo::getInboundAmount).reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | .subtract(purchaseReturnVos.stream().map(PurchaseReturnVo::getTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add))); |
| | | //æ¬æä»æ¬¾=仿¬¾éé¢ç´¯è®¡ |
| | | statementAccountVo.setCurrentActually(accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | //ææ«ä½é¢=æå+åºæ¶-æ¶æ¬¾ |
| | | statementAccountVo.setClosingBalance(statementAccountVo.getOpeningBalance().add(statementAccountVo.getCurrentPlan()).subtract(statementAccountVo.getCurrentActually())); |
| | | statementAccountVo.setAccountStatementDetails(accountStatementDetailsList); |
| | | return statementAccountVo; |
| | | } |
| | | |
| | | private String genStatementAccountNo() { |
| | | return "DZ" + LocalDateTime.now().format(CODE_TIME_FORMATTER) + new Random().nextInt(10); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.AccountReportDto; |
| | | import com.ruoyi.account.bean.dto.DeviceTypeDetail; |
| | | import com.ruoyi.account.bean.dto.DeviceTypeDistributionVO; |
| | | import com.ruoyi.account.mapper.BorrowInfoMapper; |
| | | import com.ruoyi.account.pojo.BorrowInfo; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.AccountReportVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseReturnVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesReturnVo; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.account.service.AccountingService; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.mapper.CustomStorageMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper; |
| | | import com.ruoyi.procurementrecord.pojo.CustomStorage; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockOutRecordMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.Year; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Service |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | public class AccountingServiceImpl { |
| | | public class AccountingServiceImpl implements AccountingService { |
| | | |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | private final BorrowInfoMapper borrowInfoMapper; |
| | | private final CustomStorageMapper customStorageMapper; |
| | | private final ProcurementRecordMapper procurementRecordMapper; |
| | | private final ProcurementRecordOutMapper procurementRecordOutMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final StockOutRecordMapper stockOutRecordMapper; |
| | | private final ReturnManagementMapper returnManagementMapper; |
| | | private final StockInRecordMapper stockInRecordMapper; |
| | | private final PurchaseReturnOrdersMapper purchaseReturnOrdersMapper; |
| | | |
| | | |
| | | @Override |
| | | public AjaxResult total(Integer year) { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("deprAmount",0); // ææ§éé¢ |
| | |
| | | map.put("netValue",reduce.subtract(total)); |
| | | } |
| | | // è´åº |
| | | LambdaQueryWrapper<BorrowInfo> borrowInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | borrowInfoLambdaQueryWrapper.like(BorrowInfo::getCreateTime,year) |
| | | .eq(BorrowInfo::getStatus,1); |
| | | List<BorrowInfo> borrowInfos = borrowInfoMapper.selectList(borrowInfoLambdaQueryWrapper); |
| | | if(CollectionUtils.isNotEmpty(borrowInfos)){ |
| | | BigDecimal reduce = borrowInfos.stream() |
| | | .map(BorrowInfo::getBorrowAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | map.put("debt",reduce); |
| | | } |
| | | map.put("debt",BigDecimal.ZERO); |
| | | |
| | | // åºåèµäº§ |
| | | LambdaQueryWrapper<ProcurementRecordStorage> procurementRecordStorageLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | procurementRecordStorageLambdaQueryWrapper.like(ProcurementRecordStorage::getCreateTime,year); |
| | |
| | | return totalDepreciation.setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deviceTypeDistribution(Integer year) { |
| | | // 2. ç»è£
è¿åVO |
| | | DeviceTypeDistributionVO vo = new DeviceTypeDistributionVO(); |
| | |
| | | return AjaxResult.success(vo); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult calculateDepreciation(Page page, Integer year) { |
| | | LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | deviceLedgerLambdaQueryWrapper.like(DeviceLedger::getCreateTime,year) |
| | |
| | | } |
| | | return AjaxResult.success(deviceLedgerIPage); |
| | | } |
| | | |
| | | @Override |
| | | public AccountReportVo getAccountStatementDetailsByMonth(AccountReportDto accountReportDto) { |
| | | AccountReportVo accountReportVo = new AccountReportVo(); |
| | | LocalDate start = accountReportDto.getEntryDateStart(); |
| | | LocalDate end = accountReportDto.getEntryDateEnd(); |
| | | DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("yyyy-MM"); |
| | | |
| | | // ========== 1. é¡¶é¨å¡çæ°æ® ========== |
| | | // 1.1 æ»è¥æ¶ = æ¶æ¬¾åæ»éé¢ |
| | | List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectList( |
| | | Wrappers.<AccountSalesCollection>lambdaQuery() |
| | | .between(AccountSalesCollection::getCollectionDate, start, end) |
| | | ); |
| | | BigDecimal totalIncome = Optional.of( |
| | | accountSalesCollections.stream() |
| | | .map(AccountSalesCollection::getCollectionAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | accountReportVo.setTotalIncome(totalIncome); |
| | | // 1.2 æ»æ¯åº = 仿¬¾åæ»éé¢ |
| | | List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList( |
| | | Wrappers.<AccountPurchasePayment>lambdaQuery() |
| | | .between(AccountPurchasePayment::getPaymentDate, start, end) |
| | | ); |
| | | BigDecimal totalExpense = Optional.of( |
| | | accountPurchasePayments.stream() |
| | | .map(AccountPurchasePayment::getPaymentAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | accountReportVo.setTotalExpense(totalExpense); |
| | | // 1.3 åºæ¶è´¦æ¬¾ = éå®åºåºéé¢å计 - éå®éè´§éé¢å计 |
| | | SalesOutboundDto salesOutboundDto = new SalesOutboundDto(); |
| | | salesOutboundDto.setStartDate(accountReportDto.getEntryDateStart()); |
| | | salesOutboundDto.setEndDate(accountReportDto.getEntryDateEnd()); |
| | | List<SalesOutboundVo> salesOutboundVos = stockOutRecordMapper.listPageAccountSales(new Page(1, -1), salesOutboundDto).getRecords(); |
| | | BigDecimal salesOutAmount = Optional.of( |
| | | salesOutboundVos.stream() |
| | | .map(SalesOutboundVo::getOutboundAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | SalesReturnDto salesReturnDto = new SalesReturnDto(); |
| | | salesReturnDto.setStartDate(accountReportDto.getEntryDateStart()); |
| | | salesReturnDto.setEndDate(accountReportDto.getEntryDateEnd()); |
| | | List<SalesReturnVo> salesReturnVos = returnManagementMapper.listPageAccountSalesReturn(new Page(1, -1), salesReturnDto).getRecords(); |
| | | BigDecimal salesReturnAmount = Optional.of( |
| | | salesReturnVos.stream() |
| | | .map(SalesReturnVo::getRefundAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | accountReportVo.setAccountsReceivable(salesOutAmount.subtract(salesReturnAmount)); |
| | | // 1.4 åºä»è´¦æ¬¾ = éè´å
¥åºéé¢å计 - éè´éè´§éé¢å计 |
| | | PurchaseInboundDto purchaseInboundDto = new PurchaseInboundDto(); |
| | | purchaseInboundDto.setStartDate(accountReportDto.getEntryDateStart()); |
| | | purchaseInboundDto.setEndDate(accountReportDto.getEntryDateEnd()); |
| | | List<PurchaseInboundVo> purchaseInboundVos = stockInRecordMapper.listPageAccountPurchase(new Page(1, -1), purchaseInboundDto).getRecords(); |
| | | BigDecimal purchaseInAmount = Optional.of( |
| | | purchaseInboundVos.stream() |
| | | .map(PurchaseInboundVo::getInboundAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | PurchaseReturnDto purchaseReturnDto = new PurchaseReturnDto(); |
| | | purchaseReturnDto.setStartDate(accountReportDto.getEntryDateStart()); |
| | | purchaseReturnDto.setEndDate(accountReportDto.getEntryDateEnd()); |
| | | List<PurchaseReturnVo> purchaseReturnVos = purchaseReturnOrdersMapper.listPageAccountPurchaseReturn(new Page(1, -1), purchaseReturnDto).getRecords(); |
| | | BigDecimal purchaseReturnAmount = Optional.of( |
| | | purchaseReturnVos.stream() |
| | | .map(PurchaseReturnVo::getTotalAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | accountReportVo.setAccountsPayable(purchaseInAmount.subtract(purchaseReturnAmount)); |
| | | // 1.5 å婿¶¦ = æ»è¥æ¶ - æ»æ¯åº |
| | | BigDecimal netProfit = totalIncome.subtract(totalExpense); |
| | | accountReportVo.setNetRevenue(netProfit); |
| | | |
| | | // ========== 2. æçº¿å¾ï¼æåº¦è¥æ¶/æ¯åº/å婿¶¦è¶å¿ ========== |
| | | Map<String, BigDecimal> monthIncomeMap = new HashMap<>(); |
| | | Map<String, BigDecimal> monthExpenseMap = new HashMap<>(); |
| | | // æåº¦è¥æ¶ |
| | | accountSalesCollections.forEach(item -> { |
| | | String month = item.getCollectionDate().format(monthFormatter); |
| | | monthIncomeMap.put(month, monthIncomeMap.getOrDefault(month, BigDecimal.ZERO) |
| | | .add(Optional.ofNullable(item.getCollectionAmount()).orElse(BigDecimal.ZERO))); |
| | | }); |
| | | // æåº¦æ¯åº |
| | | accountPurchasePayments.forEach(item -> { |
| | | String month = item.getPaymentDate().format(monthFormatter); |
| | | monthExpenseMap.put(month, monthExpenseMap.getOrDefault(month, BigDecimal.ZERO) |
| | | .add(Optional.ofNullable(item.getPaymentAmount()).orElse(BigDecimal.ZERO))); |
| | | }); |
| | | // çæè¿ç»æä»½å表 |
| | | List<String> monthList = new ArrayList<>(); |
| | | LocalDate current = start.withDayOfMonth(1); |
| | | while (!current.isAfter(end.withDayOfMonth(1))) { |
| | | monthList.add(current.format(monthFormatter)); |
| | | current = current.plusMonths(1); |
| | | } |
| | | // ç»è£
è¶å¿æ°æ® |
| | | List<AccountReportVo.MonthlyTrendVO> trendList = new ArrayList<>(); |
| | | for (String month : monthList) { |
| | | BigDecimal income = monthIncomeMap.getOrDefault(month, BigDecimal.ZERO); |
| | | BigDecimal expense = monthExpenseMap.getOrDefault(month, BigDecimal.ZERO); |
| | | AccountReportVo.MonthlyTrendVO trend = new AccountReportVo.MonthlyTrendVO(); |
| | | trend.setMonth(month); |
| | | trend.setIncome(income); |
| | | trend.setExpense(expense); |
| | | trend.setProfit(income.subtract(expense)); |
| | | trendList.add(trend); |
| | | } |
| | | accountReportVo.setMonthlyTrendList(trendList); |
| | | |
| | | // ========== 3. æ±ç¶å¾ï¼æåº¦åºæ¶/åºä»æ°æ® ========== |
| | | Map<String, BigDecimal> monthReceivableMap = new HashMap<>(); |
| | | Map<String, BigDecimal> monthPayableMap = new HashMap<>(); |
| | | // æåº¦åºæ¶ï¼éå®åºåº-éè´§ï¼ |
| | | salesOutboundVos.forEach(item -> { |
| | | String month = item.getShippingDate().format(monthFormatter); |
| | | monthReceivableMap.put(month, monthReceivableMap.getOrDefault(month, BigDecimal.ZERO) |
| | | .add(Optional.ofNullable(item.getOutboundAmount()).orElse(BigDecimal.ZERO))); |
| | | }); |
| | | salesReturnVos.forEach(item -> { |
| | | String month = item.getMakeTime().format(monthFormatter); |
| | | monthReceivableMap.put(month, monthReceivableMap.getOrDefault(month, BigDecimal.ZERO) |
| | | .subtract(Optional.ofNullable(item.getRefundAmount()).orElse(BigDecimal.ZERO))); |
| | | }); |
| | | |
| | | // æåº¦åºä»ï¼éè´å
¥åº-éè´§ï¼ |
| | | purchaseInboundVos.forEach(item -> { |
| | | String month = item.getInboundDate().format(monthFormatter); |
| | | monthPayableMap.put(month, monthPayableMap.getOrDefault(month, BigDecimal.ZERO) |
| | | .add(Optional.ofNullable(item.getInboundAmount()).orElse(BigDecimal.ZERO))); |
| | | }); |
| | | purchaseReturnVos.forEach(item -> { |
| | | String month = item.getPreparedAt().format(monthFormatter); |
| | | monthPayableMap.put(month, monthPayableMap.getOrDefault(month, BigDecimal.ZERO) |
| | | .subtract(Optional.ofNullable(item.getTotalAmount()).orElse(BigDecimal.ZERO))); |
| | | }); |
| | | // ç»è£
åºæ¶åºä»æ°æ® |
| | | List<AccountReportVo.ReceivablePayableVO> rpList = new ArrayList<>(); |
| | | for (String month : monthList) { |
| | | AccountReportVo.ReceivablePayableVO rp = new AccountReportVo.ReceivablePayableVO(); |
| | | rp.setMonth(month); |
| | | rp.setReceivable(monthReceivableMap.getOrDefault(month, BigDecimal.ZERO)); |
| | | rp.setPayable(monthPayableMap.getOrDefault(month, BigDecimal.ZERO)); |
| | | rpList.add(rp); |
| | | } |
| | | accountReportVo.setReceivablePayableList(rpList); |
| | | return accountReportVo; |
| | | } |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/service/impl/AccountSubjectServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | package com.ruoyi.account.service.impl.financial; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.AccountSubjectDto; |
| | | import com.ruoyi.account.bean.dto.AccountSubjectImportDto; |
| | | import com.ruoyi.account.bean.vo.AccountSubjectVo; |
| | | import com.ruoyi.account.mapper.AccountSubjectMapper; |
| | | import com.ruoyi.account.pojo.AccountSubject; |
| | | import com.ruoyi.account.service.AccountSubjectService; |
| | | import com.ruoyi.account.bean.dto.financial.AccountSubjectDto; |
| | | import com.ruoyi.account.bean.dto.financial.AccountSubjectImportDto; |
| | | import com.ruoyi.account.bean.vo.financial.AccountSubjectVo; |
| | | import com.ruoyi.account.mapper.financial.AccountSubjectMapper; |
| | | import com.ruoyi.account.pojo.financial.AccountSubject; |
| | | import com.ruoyi.account.service.purchase.AccountSubjectService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | if (startMonth.isAfter(endMonth)) { |
| | | throw new ServiceException("å¼å§æä»½ä¸è½å¤§äºç»ææä»½"); |
| | | } |
| | | return buildLedgerRows(queryDto.getSubjectCode(), startMonth, endMonth, null, null); |
| | | return Collections.singletonList(buildGeneralLedgerTotalRow(queryDto.getSubjectCode(), startMonth, endMonth)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return rows; |
| | | } |
| | | |
| | | private FinLedgerRowVo buildGeneralLedgerTotalRow(String subjectCode, YearMonth startMonth, YearMonth endMonth) { |
| | | LocalDate startDate = startMonth.atDay(1); |
| | | LocalDate endDate = endMonth.atEndOfMonth(); |
| | | |
| | | List<FinLedgerEntryRecordVo> openingEntries = finVoucherEntryMapper.listPostedEntriesBefore( |
| | | subjectCode, startDate, null, null |
| | | ); |
| | | BigDecimal openingBalance = calculateBalance(openingEntries); |
| | | |
| | | List<FinLedgerEntryRecordVo> currentPeriodEntries = finVoucherEntryMapper.listPostedEntries( |
| | | subjectCode, startDate, endDate, null, null |
| | | ); |
| | | |
| | | BigDecimal totalDebit = ZERO; |
| | | BigDecimal totalCredit = ZERO; |
| | | for (FinLedgerEntryRecordVo entry : currentPeriodEntries) { |
| | | totalDebit = totalDebit.add(money(entry.getDebit())); |
| | | totalCredit = totalCredit.add(money(entry.getCredit())); |
| | | } |
| | | |
| | | BigDecimal endingBalance = openingBalance.add(totalDebit).subtract(totalCredit); |
| | | FinLedgerRowVo totalRow = new FinLedgerRowVo(); |
| | | totalRow.setRowType("yearly_total"); |
| | | totalRow.setDate(endDate); |
| | | totalRow.setDebit(money(totalDebit)); |
| | | totalRow.setCredit(money(totalCredit)); |
| | | totalRow.setBalance(money(endingBalance)); |
| | | totalRow.setDirection(resolveDirection(endingBalance)); |
| | | return totalRow; |
| | | } |
| | | |
| | | private Map<YearMonth, List<FinLedgerEntryRecordVo>> groupEntriesByMonth(List<FinLedgerEntryRecordVo> entries) { |
| | | Map<YearMonth, List<FinLedgerEntryRecordVo>> map = new LinkedHashMap<>(); |
| | | for (FinLedgerEntryRecordVo entry : entries) { |
| | |
| | | row.setRowType("yearly_total"); |
| | | row.setDate(date); |
| | | row.setVoucherNo("-"); |
| | | row.setSummary("æ¬å¹´ç´¯è®¡"); |
| | | row.setSummary("å计"); |
| | | row.setDebit(money(yearDebit)); |
| | | row.setCredit(money(yearCredit)); |
| | | row.setBalance(money(yearBalance)); |
| | |
| | | import com.ruoyi.account.bean.dto.financial.FinVoucherEntryDto; |
| | | import com.ruoyi.account.bean.dto.financial.FinVoucherPageDto; |
| | | import com.ruoyi.account.bean.vo.financial.FinVoucherDetailVo; |
| | | import com.ruoyi.account.mapper.AccountSubjectMapper; |
| | | import com.ruoyi.account.mapper.financial.AccountSubjectMapper; |
| | | import com.ruoyi.account.mapper.financial.FinVoucherEntryMapper; |
| | | import com.ruoyi.account.mapper.financial.FinVoucherMapper; |
| | | import com.ruoyi.account.pojo.AccountSubject; |
| | | import com.ruoyi.account.pojo.financial.AccountSubject; |
| | | import com.ruoyi.account.pojo.financial.FinVoucher; |
| | | import com.ruoyi.account.pojo.financial.FinVoucherEntry; |
| | | import com.ruoyi.account.service.financial.FinVoucherService; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | |
| | | private final FinVoucherEntryMapper finVoucherEntryMapper; |
| | | private final AccountSubjectMapper accountSubjectMapper; |
| | | private final FileUtil fileUtil; |
| | | |
| | | @Override |
| | | public IPage<FinVoucher> pageList(Page<FinVoucher> page, FinVoucherPageDto queryDto) { |
| | |
| | | } |
| | | save(voucher); |
| | | saveEntries(voucher.getId(), validEntries); |
| | | // 5. ä¿åéå®å°è´¦éä»¶ |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.FIN_VOUCHER, voucher.getId(), dto.getStorageBlobDTOs()); |
| | | return true; |
| | | } |
| | | |
| | |
| | | deleteWrapper.eq(FinVoucherEntry::getVoucherId, voucher.getId()); |
| | | finVoucherEntryMapper.delete(deleteWrapper); |
| | | saveEntries(voucher.getId(), validEntries); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.FIN_VOUCHER, voucher.getId(), dto.getStorageBlobDTOs()); |
| | | return true; |
| | | } |
| | | |
| | |
| | | FinVoucherDetailVo vo = new FinVoucherDetailVo(); |
| | | BeanUtils.copyProperties(voucher, vo); |
| | | vo.setEntries(entries); |
| | | vo.setStorageBlobVOList(fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(RecordTypeEnum.FIN_VOUCHER, id)); |
| | | return vo; |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPaymentApplicationDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPaymentApplicationVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.mapper.purchase.AccountPaymentApplicationMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.service.purchase.AccountPaymentApplicationService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾ç³è¯· æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:44:22 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AccountPaymentApplicationServiceImpl extends ServiceImpl<AccountPaymentApplicationMapper, AccountPaymentApplication> implements AccountPaymentApplicationService { |
| | | |
| | | private final AccountPaymentApplicationMapper accountPaymentApplicationMapper; |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss"); |
| | | |
| | | @Override |
| | | public IPage<AccountPaymentApplicationVo> listPageAccountPaymentApplication(Page page, AccountPaymentApplicationDto accountPaymentApplicationDto) { |
| | | return accountPaymentApplicationMapper.listPageAccountPaymentApplication(page, accountPaymentApplicationDto); |
| | | } |
| | | |
| | | @Override |
| | | public List<PurchaseInboundVo> getInboundBatchesBySupplier(Integer supplierId) { |
| | | return accountPaymentApplicationMapper.getInboundBatchesBySupplier(supplierId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAccountPaymentApplication(AccountPaymentApplication accountPaymentApplication) { |
| | | if (StringUtils.isEmpty(accountPaymentApplication.getInvoiceApplicationNo())) { |
| | | accountPaymentApplication.setInvoiceApplicationNo(genPaymentApplicationNo()); |
| | | } |
| | | String stockInRecordIds= accountPaymentApplication.getStockInRecordIds(); |
| | | if (stockInRecordIds != null && !stockInRecordIds.isEmpty()) { |
| | | List<Long> ids = Arrays.stream(stockInRecordIds.split(",")) |
| | | .map(Long::valueOf) |
| | | .toList(); |
| | | if (accountPaymentApplicationMapper.existsByStockInRecordId(ids)){ |
| | | throw new ServiceException("åå¨éå¤çå
¥åºå"); |
| | | } |
| | | } |
| | | return save(accountPaymentApplication); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAccountPaymentApplication(List<Long> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | throw new ServiceException("å é¤å¤±è´¥ï¼è¯·éæ©è¦å é¤çæ°æ®"); |
| | | } |
| | | //夿æ¯å¦å·²ç»æå¯¹åºç仿¬¾å,妿æåæ æ³å é¤ |
| | | List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery().in(AccountPurchasePayment::getAccountPaymentApplicationId, ids)); |
| | | if (CollectionUtils.isNotEmpty(accountPurchasePayments)){ |
| | | throw new ServiceException("å é¤å¤±è´¥ï¼å·²ç»æå
³èç仿¬¾å"); |
| | | } |
| | | //å é¤å¼ç¥¨ç³è¯· |
| | | return removeBatchByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void exportAccountPaymentApplication(HttpServletResponse response, AccountPaymentApplicationDto accountPaymentApplicationDto) { |
| | | List<AccountPaymentApplicationVo> list = accountPaymentApplicationMapper.listPageAccountPaymentApplication(new Page(1,-1),accountPaymentApplicationDto).getRecords(); |
| | | ExcelUtil<AccountPaymentApplicationVo> util = new ExcelUtil<>(AccountPaymentApplicationVo.class); |
| | | util.exportExcel(response, list , "仿¬¾ç³è¯·"); |
| | | } |
| | | |
| | | private String genPaymentApplicationNo() { |
| | | return "FK" + LocalDateTime.now().format(CODE_TIME_FORMATTER) + new Random().nextInt(10); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchaseInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchaseInvoiceVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchaseInvoiceMapper; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchaseInvoice; |
| | | import com.ruoyi.account.service.purchase.AccountPurchaseInvoiceService; |
| | | import com.ruoyi.basic.mapper.StorageAttachmentMapper; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--è¿é¡¹å票 æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:06:17 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AccountPurchaseInvoiceServiceImpl extends ServiceImpl<AccountPurchaseInvoiceMapper, AccountPurchaseInvoice> implements AccountPurchaseInvoiceService { |
| | | |
| | | private final AccountPurchaseInvoiceMapper accountPurchaseInvoiceMapper; |
| | | private final StorageAttachmentMapper storageAttachmentMapper; |
| | | |
| | | @Override |
| | | public IPage<AccountPurchaseInvoiceVo> listPageAccountPurchaseInvoice(Page page, AccountPurchaseInvoiceDto accountPurchaseInvoiceDto) { |
| | | return accountPurchaseInvoiceMapper.listPageAccountPurchaseInvoice(page, accountPurchaseInvoiceDto); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAccountPurchaseInvoice(List<Long> ids) { |
| | | List<AccountPurchaseInvoice> accountPurchaseInvoices = accountPurchaseInvoiceMapper.selectByIds(ids); |
| | | //å é¤éä»¶ |
| | | storageAttachmentMapper.deleteBatchIds(accountPurchaseInvoices.stream().map(AccountPurchaseInvoice::getStorageAttachmentId).toList()); |
| | | return removeBatchByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void exportAccountPurchaseInvoice(HttpServletResponse response, AccountPurchaseInvoiceDto accountPurchaseInvoiceDto) { |
| | | List<AccountPurchaseInvoiceVo> list = accountPurchaseInvoiceMapper.listPageAccountPurchaseInvoice(new Page(1,-1),accountPurchaseInvoiceDto).getRecords(); |
| | | ExcelUtil<AccountPurchaseInvoiceVo> util = new ExcelUtil<>(AccountPurchaseInvoiceVo.class); |
| | | util.exportExcel(response, list , "è¿é¡¹å票"); |
| | | } |
| | | |
| | | @Override |
| | | public List<PurchaseInboundVo> getInboundBatchesBySupplier(Integer supplierId) { |
| | | return accountPurchaseInvoiceMapper.getInboundBatchesBySupplier(supplierId); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchasePaymentDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchasePaymentVo; |
| | | import com.ruoyi.account.mapper.AccountStatementDetailsMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPaymentApplicationMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.service.purchase.AccountPurchasePaymentService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾å æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 04:14:51 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AccountPurchasePaymentServiceImpl extends ServiceImpl<AccountPurchasePaymentMapper, AccountPurchasePayment> implements AccountPurchasePaymentService { |
| | | |
| | | private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss"); |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final AccountStatementDetailsMapper accountStatementDetailsMapper; |
| | | private final AccountPaymentApplicationMapper accountPaymentApplicationMapper; |
| | | |
| | | @Override |
| | | public IPage<AccountPurchasePaymentVo> listPageAccountPurchasePayment(Page page, AccountPurchasePaymentDto accountPurchasePaymentDto) { |
| | | return accountPurchasePaymentMapper.listPageAccountPurchasePayment(page, accountPurchasePaymentDto); |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAccountPurchasePayment(AccountPurchasePayment accountPurchasePayment) { |
| | | if (StringUtils.isEmpty(accountPurchasePayment.getPaymentNumber())) { |
| | | accountPurchasePayment.setPaymentNumber(genAccountPurchasePaymentNo()); |
| | | } |
| | | //æ ¡éªç´¯è®¡ä»æ¬¾éé¢ä¸è½è¶
è¿ç³è¯·éé¢ |
| | | AccountPaymentApplication accountPaymentApplication = accountPaymentApplicationMapper.selectById(accountPurchasePayment.getAccountPaymentApplicationId()); |
| | | List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery().eq(AccountPurchasePayment::getAccountPaymentApplicationId, accountPurchasePayment.getAccountPaymentApplicationId())); |
| | | BigDecimal totalPaymentAmount = accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (accountPaymentApplication.getPaymentAmount().compareTo(totalPaymentAmount) < 0) { |
| | | throw new ServiceException("ç´¯è®¡ä»æ¬¾éé¢ä¸è½è¶
è¿ç³è¯·éé¢"); |
| | | } |
| | | return save(accountPurchasePayment); |
| | | } |
| | | |
| | | @Override |
| | | public void exportAccountPurchasePayment(HttpServletResponse response, AccountPurchasePaymentDto accountPurchasePaymentDto) { |
| | | List<AccountPurchasePaymentVo> list = accountPurchasePaymentMapper.listPageAccountPurchasePayment(new Page(1,-1),accountPurchasePaymentDto).getRecords(); |
| | | ExcelUtil<AccountPurchasePaymentVo> util = new ExcelUtil<>(AccountPurchasePaymentVo.class); |
| | | util.exportExcel(response, list , "仿¬¾å"); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAccountPurchasePayment(List<Long> ids) { |
| | | //å¦æè¯¥ä»æ¬¾åå·²ç»çæå¯¹è´¦ååæ æ³å é¤ |
| | | List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectByIds(ids); |
| | | List<String> strings = accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentNumber).toList(); |
| | | List<AccountStatementDetails> accountStatementDetails = accountStatementDetailsMapper.selectList(Wrappers.<AccountStatementDetails>lambdaQuery() |
| | | .in(AccountStatementDetails::getReceiptNumber, strings)); |
| | | if (CollectionUtils.isNotEmpty(accountStatementDetails)){ |
| | | throw new ServiceException("è¯¥ä»æ¬¾åå·²ç»çæå¯¹è´¦åï¼æ æ³å é¤"); |
| | | } |
| | | return removeByIds(ids); |
| | | } |
| | | |
| | | private String genAccountPurchasePaymentNo() { |
| | | return "SK" + LocalDateTime.now().format(CODE_TIME_FORMATTER) + new Random().nextInt(10); |
| | | } |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/service/impl/AccountPurchaseServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | package com.ruoyi.account.service.impl.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.vo.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.PurchaseReturnVo; |
| | | import com.ruoyi.account.service.AccountPurchaseService; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseReturnVo; |
| | | import com.ruoyi.account.service.financial.AccountPurchaseService; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.sales.AccountInvoiceApplicationDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountInvoiceApplicationVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.mapper.sales.AccountInvoiceApplicationMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesInvoiceMapper; |
| | | import com.ruoyi.account.pojo.sales.AccountInvoiceApplication; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesInvoice; |
| | | import com.ruoyi.account.service.sales.AccountInvoiceApplicationService; |
| | | import com.ruoyi.basic.mapper.StorageAttachmentMapper; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯· æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 01:38:32 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AccountInvoiceApplicationServiceImpl extends ServiceImpl<AccountInvoiceApplicationMapper, AccountInvoiceApplication> implements AccountInvoiceApplicationService { |
| | | |
| | | private final AccountInvoiceApplicationMapper accountInvoiceApplicationMapper; |
| | | private final AccountSalesInvoiceMapper accountSalesInvoiceMapper; |
| | | private final StorageAttachmentMapper storageAttachmentMapper; |
| | | private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss"); |
| | | |
| | | @Override |
| | | public IPage<AccountInvoiceApplicationVo> listPageAccountInvoiceApplication(Page page, AccountInvoiceApplicationDto accountInvoiceApplicationDto) { |
| | | return accountInvoiceApplicationMapper.listPageAccountInvoiceApplication(page, accountInvoiceApplicationDto); |
| | | } |
| | | |
| | | @Override |
| | | public List<SalesOutboundVo> getOutboundBatchesByCustomer(Integer customerId) { |
| | | return accountInvoiceApplicationMapper.getOutboundBatchesByCustomer(customerId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAccountInvoiceApplication(AccountInvoiceApplication accountInvoiceApplication) { |
| | | if (StringUtils.isEmpty(accountInvoiceApplication.getInvoiceApplicationNo())) { |
| | | accountInvoiceApplication.setInvoiceApplicationNo(genInvoiceApplicationNo()); |
| | | } |
| | | String stockOutRecordIds = accountInvoiceApplication.getStockOutRecordIds(); |
| | | if (stockOutRecordIds != null && !stockOutRecordIds.isEmpty()) { |
| | | List<Long> ids = Arrays.stream(stockOutRecordIds.split(",")) |
| | | .map(Long::valueOf) |
| | | .toList(); |
| | | if (accountInvoiceApplicationMapper.existsByStockOutRecordId(ids)){ |
| | | throw new ServiceException("åå¨éå¤çåºåºå"); |
| | | } |
| | | } |
| | | return save(accountInvoiceApplication); |
| | | } |
| | | |
| | | @Override |
| | | public void exportAccountInvoiceApplication(HttpServletResponse response, AccountInvoiceApplicationDto accountInvoiceApplicationDto) { |
| | | List<AccountInvoiceApplicationVo> list = accountInvoiceApplicationMapper.listPageAccountInvoiceApplication(new Page(1,-1),accountInvoiceApplicationDto).getRecords(); |
| | | ExcelUtil<AccountInvoiceApplicationVo> util = new ExcelUtil<>(AccountInvoiceApplicationVo.class); |
| | | util.exportExcel(response, list , "å¼ç¥¨ç³è¯·"); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAccountInvoiceApplication(List<Long> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | throw new ServiceException("å é¤å¤±è´¥ï¼è¯·éæ©è¦å é¤çæ°æ®"); |
| | | } |
| | | //å é¤ç¸å
³éä»¶ |
| | | List<AccountSalesInvoice> accountSalesInvoices = accountSalesInvoiceMapper.selectList(Wrappers.<AccountSalesInvoice>lambdaQuery().in(AccountSalesInvoice::getAccountInvoiceApplicationId,ids)); |
| | | storageAttachmentMapper.deleteBatchIds(accountSalesInvoices.stream().map(AccountSalesInvoice::getStorageAttachmentId).toList()); |
| | | //å é¤ç¸å
³çé项å票 |
| | | accountSalesInvoiceMapper.delete(Wrappers.<AccountSalesInvoice>lambdaQuery().in(AccountSalesInvoice::getAccountInvoiceApplicationId,ids)); |
| | | //å é¤å¼ç¥¨ç³è¯· |
| | | return removeBatchByIds(ids); |
| | | } |
| | | |
| | | private String genInvoiceApplicationNo() { |
| | | return "KP" + LocalDateTime.now().format(CODE_TIME_FORMATTER) + new Random().nextInt(10); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesCollectionDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesCollectionVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.mapper.AccountStatementDetailsMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.account.service.sales.AccountSalesCollectionService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--æ¶æ¬¾å æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:49:56 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AccountSalesCollectionServiceImpl extends ServiceImpl<AccountSalesCollectionMapper, AccountSalesCollection> implements AccountSalesCollectionService { |
| | | |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final AccountStatementDetailsMapper accountStatementDetailsMapper; |
| | | private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss"); |
| | | |
| | | |
| | | @Override |
| | | public IPage<AccountSalesCollectionVo> listPageAccountSalesCollection(Page page, AccountSalesCollectionDto accountSalesCollectionDto) { |
| | | return accountSalesCollectionMapper.listPageAccountSalesCollection(page, accountSalesCollectionDto); |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAccountSalesCollection(AccountSalesCollection accountSalesCollection) { |
| | | if (StringUtils.isEmpty(accountSalesCollection.getCollectionNumber())) { |
| | | accountSalesCollection.setCollectionNumber(genAccountSalesCollectionNo()); |
| | | } |
| | | String stockOutRecordIds = accountSalesCollection.getStockOutRecordIds(); |
| | | if (stockOutRecordIds != null && !stockOutRecordIds.isEmpty()) { |
| | | List<Long> ids = Arrays.stream(stockOutRecordIds.split(",")) |
| | | .map(Long::valueOf) |
| | | .toList(); |
| | | if (accountSalesCollectionMapper.existsByStockOutRecordId(ids)){ |
| | | throw new ServiceException("åå¨éå¤çåºåºå"); |
| | | } |
| | | } |
| | | return save(accountSalesCollection); |
| | | } |
| | | |
| | | @Override |
| | | public void exportAccountSalesCollection(HttpServletResponse response, AccountSalesCollectionDto accountSalesCollectionDto) { |
| | | List<AccountSalesCollectionVo> list = accountSalesCollectionMapper.listPageAccountSalesCollection(new Page(1,-1),accountSalesCollectionDto).getRecords(); |
| | | ExcelUtil<AccountSalesCollectionVo> util = new ExcelUtil<>(AccountSalesCollectionVo.class); |
| | | util.exportExcel(response, list , "æ¶æ¬¾å"); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAccountSalesCollection(List<Long> ids) { |
| | | //å¦æè¯¥æ¶æ¬¾åå·²ç»çæå¯¹è´¦ååæ æ³å é¤ |
| | | List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectByIds(ids); |
| | | List<String> strings = accountSalesCollections.stream().map(AccountSalesCollection::getCollectionNumber).toList(); |
| | | List<AccountStatementDetails> accountStatementDetails = accountStatementDetailsMapper.selectList(Wrappers.<AccountStatementDetails>lambdaQuery() |
| | | .in(AccountStatementDetails::getReceiptNumber, strings)); |
| | | if (CollectionUtils.isNotEmpty(accountStatementDetails)){ |
| | | throw new ServiceException("è¯¥æ¶æ¬¾åå·²ç»çæå¯¹è´¦åï¼æ æ³å é¤"); |
| | | } |
| | | return removeByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public List<SalesOutboundVo> getOutboundBatchesByCustomer(Integer customerId) { |
| | | return accountSalesCollectionMapper.getOutboundBatchesByCustomer(customerId); |
| | | } |
| | | |
| | | private String genAccountSalesCollectionNo() { |
| | | return "SK" + LocalDateTime.now().format(CODE_TIME_FORMATTER) + new Random().nextInt(10); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.impl.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesInvoiceVo; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesInvoiceMapper; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesInvoice; |
| | | import com.ruoyi.account.service.sales.AccountSalesInvoiceService; |
| | | import com.ruoyi.basic.mapper.StorageAttachmentMapper; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--é项å票 æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:10:20 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AccountSalesInvoiceServiceImpl extends ServiceImpl<AccountSalesInvoiceMapper, AccountSalesInvoice> implements AccountSalesInvoiceService { |
| | | |
| | | private final AccountSalesInvoiceMapper accountSalesInvoiceMapper; |
| | | private final StorageAttachmentMapper storageAttachmentMapper; |
| | | |
| | | @Override |
| | | public IPage<AccountSalesInvoiceVo> listPageAccountSalesInvoice(Page page, AccountSalesInvoiceDto accountSalesInvoiceDto) { |
| | | return accountSalesInvoiceMapper.listPageAccountSalesInvoice(page, accountSalesInvoiceDto); |
| | | } |
| | | |
| | | @Override |
| | | public void exportAccountSalesInvoice(HttpServletResponse response, AccountSalesInvoiceDto accountSalesInvoiceDto) { |
| | | List<AccountSalesInvoiceVo> list = accountSalesInvoiceMapper.listPageAccountSalesInvoice(new Page(1,-1),accountSalesInvoiceDto).getRecords(); |
| | | ExcelUtil<AccountSalesInvoiceVo> util = new ExcelUtil<>(AccountSalesInvoiceVo.class); |
| | | util.exportExcel(response, list , "é项å票"); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteAccountSalesInvoice(List<Long> ids) { |
| | | List<AccountSalesInvoice> accountSalesInvoices = accountSalesInvoiceMapper.selectByIds(ids); |
| | | //å é¤éä»¶ |
| | | storageAttachmentMapper.deleteBatchIds(accountSalesInvoices.stream().map(AccountSalesInvoice::getStorageAttachmentId).toList()); |
| | | return removeBatchByIds(ids); |
| | | } |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/service/impl/AccountSalesServiceImpl.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | package com.ruoyi.account.service.impl.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.SalesReturnVo; |
| | | import com.ruoyi.account.service.AccountSalesService; |
| | | import com.ruoyi.account.bean.dto.sales.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesReturnVo; |
| | | import com.ruoyi.account.service.sales.AccountSalesService; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper; |
| | | import com.ruoyi.stock.mapper.StockOutRecordMapper; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPaymentApplicationDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPaymentApplicationVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾ç³è¯· æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:44:22 |
| | | */ |
| | | public interface AccountPaymentApplicationService extends IService<AccountPaymentApplication> { |
| | | |
| | | IPage<AccountPaymentApplicationVo> listPageAccountPaymentApplication(Page page, AccountPaymentApplicationDto accountPaymentApplicationDto); |
| | | |
| | | List<PurchaseInboundVo> getInboundBatchesBySupplier(Integer supplierId); |
| | | |
| | | boolean addAccountPaymentApplication(AccountPaymentApplication accountPaymentApplication); |
| | | |
| | | boolean deleteAccountPaymentApplication(List<Long> ids); |
| | | |
| | | void exportAccountPaymentApplication(HttpServletResponse response, AccountPaymentApplicationDto accountPaymentApplicationDto); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchaseInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchaseInvoiceVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchaseInvoice; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--è¿é¡¹å票 æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 03:06:17 |
| | | */ |
| | | public interface AccountPurchaseInvoiceService extends IService<AccountPurchaseInvoice> { |
| | | |
| | | IPage<AccountPurchaseInvoiceVo> listPageAccountPurchaseInvoice(Page page, AccountPurchaseInvoiceDto accountPurchaseInvoiceDto); |
| | | |
| | | boolean deleteAccountPurchaseInvoice(List<Long> ids); |
| | | |
| | | void exportAccountPurchaseInvoice(HttpServletResponse response, AccountPurchaseInvoiceDto accountPurchaseInvoiceDto); |
| | | |
| | | List<PurchaseInboundVo> getInboundBatchesBySupplier(Integer supplierId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchasePaymentDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchasePaymentVo; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--仿¬¾å æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-19 04:14:51 |
| | | */ |
| | | public interface AccountPurchasePaymentService extends IService<AccountPurchasePayment> { |
| | | |
| | | IPage<AccountPurchasePaymentVo> listPageAccountPurchasePayment(Page page, AccountPurchasePaymentDto accountPurchasePaymentDto); |
| | | |
| | | boolean addAccountPurchasePayment(AccountPurchasePayment accountPurchasePayment); |
| | | |
| | | void exportAccountPurchasePayment(HttpServletResponse response, AccountPurchasePaymentDto accountPurchasePaymentDto); |
| | | |
| | | boolean deleteAccountPurchasePayment(List<Long> ids); |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/service/AccountSubjectService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.service; |
| | | package com.ruoyi.account.service.purchase; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.AccountSubjectDto; |
| | | import com.ruoyi.account.bean.vo.AccountSubjectVo; |
| | | import com.ruoyi.account.pojo.AccountSubject; |
| | | import com.ruoyi.account.bean.dto.financial.AccountSubjectDto; |
| | | import com.ruoyi.account.bean.vo.financial.AccountSubjectVo; |
| | | import com.ruoyi.account.pojo.financial.AccountSubject; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.bean.dto.sales.AccountInvoiceApplicationDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountInvoiceApplicationVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.pojo.sales.AccountInvoiceApplication; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--å¼ç¥¨ç³è¯· æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 01:38:32 |
| | | */ |
| | | public interface AccountInvoiceApplicationService extends IService<AccountInvoiceApplication> { |
| | | |
| | | IPage<AccountInvoiceApplicationVo> listPageAccountInvoiceApplication(Page page, AccountInvoiceApplicationDto accountInvoiceApplicationDto); |
| | | |
| | | List<SalesOutboundVo> getOutboundBatchesByCustomer(Integer customerId); |
| | | |
| | | boolean addAccountInvoiceApplication(AccountInvoiceApplication accountInvoiceApplication); |
| | | |
| | | void exportAccountInvoiceApplication(HttpServletResponse response, AccountInvoiceApplicationDto accountInvoiceApplicationDto); |
| | | |
| | | boolean deleteAccountInvoiceApplication(List<Long> ids); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesCollectionDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesCollectionVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--æ¶æ¬¾å æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:49:56 |
| | | */ |
| | | public interface AccountSalesCollectionService extends IService<AccountSalesCollection> { |
| | | |
| | | IPage<AccountSalesCollectionVo> listPageAccountSalesCollection(Page page, AccountSalesCollectionDto accountSalesCollectionDto); |
| | | |
| | | boolean addAccountSalesCollection(AccountSalesCollection accountSalesCollection); |
| | | |
| | | void exportAccountSalesCollection(HttpServletResponse response, AccountSalesCollectionDto accountSalesCollectionDto); |
| | | |
| | | boolean deleteAccountSalesCollection(List<Long> ids); |
| | | |
| | | List<SalesOutboundVo> getOutboundBatchesByCustomer(Integer customerId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.account.service.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.sales.AccountSalesInvoiceDto; |
| | | import com.ruoyi.account.bean.vo.sales.AccountSalesInvoiceVo; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesInvoice; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * è´¢å¡ç®¡ç--é项å票 æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-05-18 03:10:20 |
| | | */ |
| | | public interface AccountSalesInvoiceService extends IService<AccountSalesInvoice> { |
| | | |
| | | IPage<AccountSalesInvoiceVo> listPageAccountSalesInvoice(Page page, AccountSalesInvoiceDto accountSalesInvoiceDto); |
| | | |
| | | void exportAccountSalesInvoice(HttpServletResponse response, AccountSalesInvoiceDto accountSalesInvoiceDto); |
| | | |
| | | boolean deleteAccountSalesInvoice(List<Long> ids); |
| | | } |
| ÎļþÃû´Ó src/main/java/com/ruoyi/account/service/AccountSalesService.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.account.service; |
| | | package com.ruoyi.account.service.sales; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.SalesReturnVo; |
| | | import com.ruoyi.account.bean.dto.sales.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesReturnVo; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | |
| | | import dev.langchain4j.service.MemoryId; |
| | | import dev.langchain4j.service.SystemMessage; |
| | | import dev.langchain4j.service.UserMessage; |
| | | import dev.langchain4j.service.V; |
| | | import dev.langchain4j.service.spring.AiService; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | |
| | | public interface ApproveTodoAgent { |
| | | |
| | | @SystemMessage(fromResource = "approve-todo-agent-prompt.txt") |
| | | Flux<String> chat(@MemoryId String memoryId, @UserMessage String userMessage); |
| | | Flux<String> chat(@MemoryId String memoryId, @UserMessage String userMessage, @V("currentDate") String currentDate); |
| | | } |
| | |
| | | @Component |
| | | public class ApproveTodoIntentExecutor { |
| | | |
| | | private static final Pattern APPROVE_ID_PATTERN = Pattern.compile("\\b[A-Za-z]*\\d{8,}\\b"); |
| | | private static final Pattern LIMIT_PATTERN = Pattern.compile("(å|æè¿)?(\\d{1,2})æ¡"); |
| | | private static final Pattern APPROVE_ID_BY_LABEL_PATTERN = Pattern.compile("(æµç¨ç¼å·|æµç¨å·|æµç¨ID|审æ¹ç¼å·|ç¼å·)\\s*[:ï¼]?\\s*([A-Za-z0-9_-]{2,64})"); |
| | | private static final Pattern APPROVE_ID_PATTERN = Pattern.compile("\\b[A-Za-z]*\\d{6,}[A-Za-z0-9_-]*\\b"); |
| | | private static final Pattern LIMIT_PATTERN = Pattern.compile("(å|æè¿)?\\s*(\\d{1,2})\\s*æ¡"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})"); |
| | | private static final Pattern NUMBER_PATTERN = Pattern.compile("(\\d+(?:\\.\\d+)?)"); |
| | | private static final Pattern RECENT_RANGE_PATTERN = Pattern.compile("è¿\\d+(天|å¨|个æ|æ|å¹´)"); |
| | |
| | | } |
| | | |
| | | String text = message.trim(); |
| | | String quickPromptResponse = tryExecuteQuickPrompt(memoryId, text); |
| | | if (StringUtils.hasText(quickPromptResponse)) { |
| | | return quickPromptResponse; |
| | | } |
| | | |
| | | String approveId = extractApproveId(text); |
| | | boolean hasApproveId = StringUtils.hasText(approveId) && !isPlaceholderApproveId(approveId); |
| | | String startDate = extractStartDate(text); |
| | | String endDate = extractEndDate(text); |
| | | String timeRange = extractTimeRange(text); |
| | | |
| | | if (isStatsIntent(text)) { |
| | | return approveTodoTools.getTodoStats( |
| | | memoryId, |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | extractTimeRange(text) |
| | | startDate, |
| | | endDate, |
| | | timeRange |
| | | ); |
| | | } |
| | | if (containsAny(text, "æµè½¬", "è¿åº¦", "èç¹", "æ¥å¿", "å¡å¨", "å¡å°", "å½å审æ¹äºº", "å¤çè®°å½")) { |
| | | return StringUtils.hasText(approveId) |
| | | return hasApproveId |
| | | ? approveTodoTools.getTodoProgress(memoryId, approveId) |
| | | : missingApproveId("todo_progress", "æ¥è¯¢å®¡æ¹è¿åº¦éè¦æä¾æµç¨ç¼å·ã"); |
| | | } |
| | | if (containsAny(text, "详æ
", "æç»") && !containsAny(text, "å表")) { |
| | | return StringUtils.hasText(approveId) |
| | | return hasApproveId |
| | | ? approveTodoTools.getTodoDetail(memoryId, approveId) |
| | | : missingApproveId("todo_detail", "æ¥è¯¢å®¡æ¹è¯¦æ
éè¦æä¾æµç¨ç¼å·ã"); |
| | | } |
| | | if (containsAny(text, "åæ¶å®¡æ ¸", "æ¤éå®¡æ ¸", "åéå®¡æ ¸", "æ¤é审æ¹", "æ¤å审æ¹") |
| | | || (containsAny(text, "æ¤é", "æ¤å") && containsAny(text, "å®¡æ¹æä½", "å®¡æ ¸æä½"))) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.cancelReviewTodo(memoryId, approveId, firstNonBlank(extractTail(text, "åå "), extractTail(text, "夿³¨"))) |
| | | return hasApproveId |
| | | ? approveTodoTools.cancelReviewTodo(memoryId, approveId, extractRemark(text)) |
| | | : missingApproveId("cancel_review_action", "åæ¶å®¡æ ¸éè¦æä¾æµç¨ç¼å·ã"); |
| | | } |
| | | if (containsAny(text, "å é¤", "ç§»é¤")) { |
| | | return StringUtils.hasText(approveId) |
| | | return hasApproveId |
| | | ? approveTodoTools.deleteTodo(memoryId, approveId) |
| | | : missingApproveId("delete_action", "å é¤å®¡æ¹åéè¦æä¾æµç¨ç¼å·ã"); |
| | | } |
| | | if (containsAny(text, "驳å", "æç»")) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "reject", firstNonBlank(extractTail(text, "åå "), extractTail(text, "夿³¨"))) |
| | | return hasApproveId |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "reject", extractRemark(text)) |
| | | : missingApproveId("review_action", "驳å审æ¹éè¦æä¾æµç¨ç¼å·ã"); |
| | | } |
| | | if (containsAny(text, "å®¡æ ¸éè¿", "审æ¹éè¿", "éè¿å®¡æ¹", "åæå®¡æ¹", "审æ¹åæ")) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "approve", extractTail(text, "夿³¨")) |
| | | return hasApproveId |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "approve", extractRemark(text)) |
| | | : missingApproveId("review_action", "审æ¹éè¿éè¦æä¾æµç¨ç¼å·ã"); |
| | | } |
| | | if (StringUtils.hasText(approveId) |
| | | if (hasApproveId |
| | | && containsAny(text, "éè¿", "åæ") |
| | | && !containsAny(text, "æªéè¿", "éè¿ç", "审æ¹éè¿ç", "å®¡æ ¸éè¿ç")) { |
| | | return approveTodoTools.reviewTodo(memoryId, approveId, "approve", extractTail(text, "夿³¨")); |
| | | return approveTodoTools.reviewTodo(memoryId, approveId, "approve", extractRemark(text)); |
| | | } |
| | | if (containsAny(text, "ä¿®æ¹", "æ´æ°", "åæ´")) { |
| | | return StringUtils.hasText(approveId) |
| | | return hasApproveId |
| | | ? approveTodoTools.updateTodo( |
| | | memoryId, |
| | | approveId, |
| | |
| | | extractApproveType(text), |
| | | extractKeyword(text), |
| | | extractLimit(text), |
| | | extractScope(text)); |
| | | extractScope(text), |
| | | startDate, |
| | | endDate, |
| | | timeRange); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String tryExecuteQuickPrompt(String memoryId, String text) { |
| | | String normalized = normalizeForMatch(text); |
| | | String approveId = extractApproveId(text); |
| | | boolean hasApproveId = StringUtils.hasText(approveId) && !isPlaceholderApproveId(approveId); |
| | | |
| | | if ("æå½åæåªäºå®¡æ¹å¾
åéè¦å¤ç".equals(normalized)) { |
| | | return approveTodoTools.listTodos(memoryId, "pending", null, null, 10, "approver", null, null, null); |
| | | } |
| | | if ("帮æååºä»å¤©æ°å¢ç审æ¹å¾
å".equals(normalized)) { |
| | | return approveTodoTools.listTodos(memoryId, "all", null, null, 10, "related", null, null, "ä»å¤©"); |
| | | } |
| | | if ("å½åå¾
æå®¡æ¹çåæ®ææ¶é´ååºååºæ¥".equals(normalized)) { |
| | | return approveTodoTools.listTodos(memoryId, "pending", null, null, 10, "approver", null, null, null); |
| | | } |
| | | if ("æåèµ·ç审æ¹éåªäºè¿å¨å¤çä¸".equals(normalized)) { |
| | | return approveTodoTools.listTodos(memoryId, "processing", null, null, 10, "applicant", null, null, null); |
| | | } |
| | | if ("è¿7天æç审æ¹å¾
åç»è®¡æ
嵿乿 ·".equals(normalized)) { |
| | | return approveTodoTools.getTodoStats(memoryId, null, null, "è¿7天"); |
| | | } |
| | | if ("æ¬ææç审æ¹ä¸éè¿é©³åå¤çä¸åæå¤å°".equals(normalized)) { |
| | | return approveTodoTools.getTodoStats(memoryId, null, null, "æ¬æ"); |
| | | } |
| | | if ("è¿30天åç±»åå®¡æ¹æ°éå叿¯ä»ä¹".equals(normalized)) { |
| | | return approveTodoTools.getTodoStats(memoryId, null, null, "è¿30天"); |
| | | } |
| | | |
| | | if (normalized.startsWith("æ¥è¯¢æµç¨ç¼å·") && normalized.contains("审æ¹è¯¦æ
")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.getTodoDetail(memoryId, approveId) |
| | | : missingApproveId("todo_detail", "æ¥è¯¢å®¡æ¹è¯¦æ
éè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | if (normalized.startsWith("æµç¨ç¼å·") |
| | | && normalized.contains("å¡å¨åªä¸ªå®¡æ¹èç¹") |
| | | && normalized.contains("å½å审æ¹äººæ¯è°")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.getTodoProgress(memoryId, approveId) |
| | | : missingApproveId("todo_progress", "æ¥è¯¢å®¡æ¹è¿åº¦éè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | if (normalized.startsWith("å¸®ææ¥çæµç¨ç¼å·") && normalized.contains("å®¡æ¹æµè½¬è®°å½")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.getTodoProgress(memoryId, approveId) |
| | | : missingApproveId("todo_progress", "æ¥è¯¢å®¡æ¹æµè½¬è®°å½éè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | if (normalized.startsWith("帮æå®¡æ¹éè¿æµç¨ç¼å·")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "approve", extractRemark(text)) |
| | | : missingApproveId("review_action", "审æ¹éè¿éè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | if (normalized.startsWith("帮æé©³åæµç¨ç¼å·")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "reject", extractRemark(text)) |
| | | : missingApproveId("review_action", "驳å审æ¹éè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | if (normalized.startsWith("æ¤éæåå对æµç¨ç¼å·") && normalized.contains("å®¡æ¹æä½")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.cancelReviewTodo(memoryId, approveId, extractRemark(text)) |
| | | : missingApproveId("cancel_review_action", "æ¤éå®¡æ¹æä½éè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | if (normalized.startsWith("帮æä¿®æ¹æµç¨ç¼å·") && normalized.contains("夿³¨ä¸º")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.updateTodo(memoryId, approveId, null, null, null, null, null, null, extractRemark(text)) |
| | | : missingApproveId("update_action", "ä¿®æ¹å®¡æ¹åéè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | if (normalized.startsWith("å 餿åèµ·çæµç¨ç¼å·")) { |
| | | return hasApproveId |
| | | ? approveTodoTools.deleteTodo(memoryId, approveId) |
| | | : missingApproveId("delete_action", "å é¤å®¡æ¹åéè¦æä¾ç宿µç¨ç¼å·ã"); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | |
| | | private String extractApproveId(String text) { |
| | | Matcher keywordMatcher = APPROVE_ID_BY_LABEL_PATTERN.matcher(text); |
| | | if (keywordMatcher.find()) { |
| | | return keywordMatcher.group(2); |
| | | } |
| | | Matcher matcher = APPROVE_ID_PATTERN.matcher(text); |
| | | return matcher.find() ? matcher.group() : null; |
| | | } |
| | |
| | | .replace("åæ®", "") |
| | | .replace("å¾
å", "") |
| | | .replace("å表", "") |
| | | .replace("æµç¨ç¼å·", "") |
| | | .replace("æµç¨å·", "") |
| | | .replace("å10æ¡", "") |
| | | .replace("æè¿10æ¡", "") |
| | | .trim(); |
| | |
| | | } |
| | | |
| | | private String extractValue(String text, String fieldName) { |
| | | Pattern pattern = Pattern.compile(fieldName + "(æ¹ä¸º|ä¿®æ¹ä¸º|æ¯)[:ï¼]?[\\s]*([^,ï¼ãï¼;\\s]+)"); |
| | | Pattern pattern = Pattern.compile(fieldName + "(æ¹ä¸º|ä¿®æ¹ä¸º|为|æ¯)[:ï¼]?[\\s]*([^,ï¼ãï¼;\\s]+)"); |
| | | Matcher matcher = pattern.matcher(text); |
| | | return matcher.find() ? matcher.group(2) : null; |
| | | } |
| | |
| | | if (!text.contains(fieldName)) { |
| | | return null; |
| | | } |
| | | Matcher matcher = Pattern.compile(fieldName + "(æ¹ä¸º|ä¿®æ¹ä¸º|æ¯)[:ï¼]?[\\s]*(\\d{1,2})").matcher(text); |
| | | Matcher matcher = Pattern.compile(fieldName + "(æ¹ä¸º|ä¿®æ¹ä¸º|为|æ¯)[:ï¼]?[\\s]*(\\d{1,2})").matcher(text); |
| | | return matcher.find() ? Integer.parseInt(matcher.group(2)) : null; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private String extractTail(String text, String key) { |
| | | Pattern quotedPattern = Pattern.compile(key + "(æ¯|为)?[:ï¼]?[\\s]*[â\"]([^â\"]+)[â\"]"); |
| | | Matcher quotedMatcher = quotedPattern.matcher(text); |
| | | if (quotedMatcher.find()) { |
| | | return cleanContent(quotedMatcher.group(2)); |
| | | } |
| | | Pattern pattern = Pattern.compile(key + "(æ¯|为)?[:ï¼]?[\\s]*(.+)"); |
| | | Matcher matcher = pattern.matcher(text); |
| | | return matcher.find() ? matcher.group(2).trim() : null; |
| | | return matcher.find() ? cleanContent(matcher.group(2)) : null; |
| | | } |
| | | |
| | | private String extractScope(String text) { |
| | | if (containsAny(text, "æåèµ·", "ææäº¤", "æç³è¯·", "ç³è¯·äººæ¯æ")) { |
| | | return "applicant"; |
| | | } |
| | | if (containsAny(text, "å¾
æå®¡æ¹", "å¾
æå®¡æ ¸", "æå¤ç", "æå®¡æ¹", "å½åå¾
æ", "éè¦æå¤ç")) { |
| | | if (containsAny(text, "å¾
æå®¡æ¹", "å¾
æå®¡æ ¸", "æå¤ç", "æå®¡æ¹", "å½åå¾
æ", "éè¦æå¤ç", "éè¦å¤ç")) { |
| | | return "approver"; |
| | | } |
| | | return "related"; |
| | | } |
| | | |
| | | private String extractRemark(String text) { |
| | | return firstNonBlank(firstNonBlank(extractTail(text, "夿³¨"), extractTail(text, "åå ")), extractQuotedContent(text)); |
| | | } |
| | | |
| | | private String extractQuotedContent(String text) { |
| | | Matcher matcher = Pattern.compile("[â\"]([^â\"]+)[â\"]").matcher(text); |
| | | return matcher.find() ? cleanContent(matcher.group(1)) : null; |
| | | } |
| | | |
| | | private String normalizeForMatch(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return ""; |
| | | } |
| | | return text.replace("ï¼", "") |
| | | .replace(",", "") |
| | | .replace("ã", "") |
| | | .replace(".", "") |
| | | .replace("ï¼", "") |
| | | .replace("!", "") |
| | | .replace("ï¼", "") |
| | | .replace("?", "") |
| | | .replace("ï¼", "") |
| | | .replace(":", "") |
| | | .replace("ï¼", "") |
| | | .replace(";", "") |
| | | .replace("â", "") |
| | | .replace("â", "") |
| | | .replace("\"", "") |
| | | .replace(" ", "") |
| | | .trim(); |
| | | } |
| | | |
| | | private boolean isPlaceholderApproveId(String approveId) { |
| | | if (!StringUtils.hasText(approveId)) { |
| | | return true; |
| | | } |
| | | String value = approveId.trim(); |
| | | return "xxx".equalsIgnoreCase(value) |
| | | || value.matches("[xX]{2,}") |
| | | || "æµç¨ç¼å·".equals(value) |
| | | || "ç¼å·".equals(value) |
| | | || value.contains("示ä¾") |
| | | || value.contains("请è¾å
¥"); |
| | | } |
| | | |
| | | private String cleanContent(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return null; |
| | | } |
| | | return text.trim() |
| | | .replace("â", "") |
| | | .replace("â", "") |
| | | .replace("\"", "") |
| | | .replace("ã", "") |
| | | .replace("ï¼", "") |
| | | .replace(";", "") |
| | | .trim(); |
| | | } |
| | | |
| | | private String firstNonBlank(String first, String second) { |
| | | return StringUtils.hasText(first) ? first : second; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.assistant; |
| | | |
| | | import dev.langchain4j.service.MemoryId; |
| | | import dev.langchain4j.service.SystemMessage; |
| | | import dev.langchain4j.service.UserMessage; |
| | | import dev.langchain4j.service.V; |
| | | import dev.langchain4j.service.spring.AiService; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | | import static dev.langchain4j.service.spring.AiServiceWiringMode.EXPLICIT; |
| | | |
| | | @AiService( |
| | | wiringMode = EXPLICIT, |
| | | streamingChatModel = "qwenStreamingChatModel", |
| | | chatMemoryProvider = "chatMemoryProviderFinancial", |
| | | tools = "financialAgentTools" |
| | | ) |
| | | public interface FinancialAgent { |
| | | |
| | | @SystemMessage(fromResource = "financial-agent-prompt.txt") |
| | | Flux<String> chat(@MemoryId String memoryId, @UserMessage String userMessage, @V("currentDate") String currentDate); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.assistant; |
| | | |
| | | import com.ruoyi.ai.tools.FinancialAgentTools; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.YearMonth; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | @Component |
| | | public class FinancialIntentExecutor { |
| | | |
| | | private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final Pattern LIMIT_PATTERN = Pattern.compile("(å|æè¿)?\\s*(\\d{1,2})\\s*æ¡"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})"); |
| | | private static final Pattern RELATIVE_DAY_PATTERN = Pattern.compile("(è¿|æè¿)?\\s*(\\d{1,3})\\s*天"); |
| | | |
| | | private final FinancialAgentTools financialAgentTools; |
| | | |
| | | public FinancialIntentExecutor(FinancialAgentTools financialAgentTools) { |
| | | this.financialAgentTools = financialAgentTools; |
| | | } |
| | | |
| | | public String tryExecute(String memoryId, String message) { |
| | | if (!StringUtils.hasText(message)) { |
| | | return null; |
| | | } |
| | | String text = message.trim(); |
| | | |
| | | String quickPromptResponse = tryExecuteQuickPrompt(memoryId, text); |
| | | if (StringUtils.hasText(quickPromptResponse)) { |
| | | return quickPromptResponse; |
| | | } |
| | | |
| | | DateRange dateRange = extractDateRange(text); |
| | | Integer limit = extractLimit(text); |
| | | String keyword = extractKeyword(text); |
| | | String startDate = dateRange.startDate(); |
| | | String endDate = dateRange.endDate(); |
| | | String timeRange = dateRange.label(); |
| | | |
| | | if (containsAny(text, "ææ¬æ ¸ç®", "äº§åææ¬", "å·¥åºææ¬", "äººå·¥ææ¬", "ææ§", "æææè")) { |
| | | return financialAgentTools.calculateIntelligentCost(memoryId, startDate, endDate, timeRange, keyword, limit); |
| | | } |
| | | if (containsAny(text, "婿¶¦åæ", "订å婿¶¦", "äºæè®¢å", "ä½å©æ¶¦", |
| | | "æèµé±å®¢æ·", "åªä¸ªå®¢æ·æèµé±", "å®¢æ·æèµé±", "婿¶¦æé«å®¢æ·", "婿¶¦è´¡ç®æé«å®¢æ·", "婿¶¦ä¸é")) { |
| | | return financialAgentTools.analyzeOrderProfit(memoryId, startDate, endDate, timeRange, keyword, limit); |
| | | } |
| | | if (containsAny(text, "åºåèµé", "åºå积å", "åæ»åºå", "èµéå ç¨", "å¨è½¬ç", "åºåå¨è½¬")) { |
| | | return financialAgentTools.analyzeInventoryCapital(memoryId, startDate, endDate, timeRange, keyword, limit); |
| | | } |
| | | if (containsAny(text, "ç°éæµ", "忬¾é£é©", "仿¬¾åå", "èµé缺å£", "åºæ¶", "åºä»", "忬¾é¢æµ")) { |
| | | return financialAgentTools.forecastCashFlow(memoryId, startDate, endDate, timeRange, limit); |
| | | } |
| | | if (containsAny(text, "å¼å¸¸é¢è¦", "ç»è¥å¼å¸¸", "é£é©é¢è¦", "ææ¬å¼å¸¸", "婿¶¦å¼å¸¸", "忬¾å¼å¸¸", "订åé£é©")) { |
| | | return financialAgentTools.detectBusinessAnomalies(memoryId, startDate, endDate, timeRange, limit); |
| | | } |
| | | if (containsAny(text, "驾驶è±", "ç»è¥çæ¿", "ç»è¥æ»è§", "ç»è¥ä»ªè¡¨ç", "ç»è¥å¤§ç")) { |
| | | return financialAgentTools.getBusinessCockpit(memoryId, startDate, endDate, timeRange); |
| | | } |
| | | if (containsAny(text, "æ¥æ¥", "卿¥", "ç»è¥æ¥å", "åææ¥å")) { |
| | | return financialAgentTools.generateOperationReport(memoryId, startDate, endDate, timeRange, |
| | | containsAny(text, "卿¥") ? "weekly" : "daily"); |
| | | } |
| | | if (containsAny(text, "ä¸è´¢èå", "ä¸è´¢èå¨", "å£å¾", "ææ è§£é", "为ä»ä¹")) { |
| | | return financialAgentTools.retrieveFinancialKnowledge(memoryId, text); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String tryExecuteQuickPrompt(String memoryId, String text) { |
| | | String normalized = normalizeForMatch(text); |
| | | if ("æ¥çæ¬æç»è¥é©¾é©¶è±".equals(normalized) || "æ¥çç»è¥é©¾é©¶è±".equals(normalized)) { |
| | | DateRange range = monthRange(); |
| | | return financialAgentTools.getBusinessCockpit(memoryId, range.startDate(), range.endDate(), range.label()); |
| | | } |
| | | if ("æ¥è¯¢è¿30å¤©äºæè®¢å".equals(normalized) || "åªä¸ªè®¢åäºæ".equals(normalized)) { |
| | | DateRange range = recentDaysRange(30); |
| | | return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, 20); |
| | | } |
| | | if ("çææ¬å¨ç»è¥å¨æ¥".equals(normalized) || "çæå¨æ¥".equals(normalized)) { |
| | | DateRange range = weekRange(); |
| | | return financialAgentTools.generateOperationReport(memoryId, range.startDate(), range.endDate(), range.label(), "weekly"); |
| | | } |
| | | if ("为ä»ä¹å©æ¶¦ä¸é".equals(normalized)) { |
| | | DateRange range = monthRange(); |
| | | return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, 20); |
| | | } |
| | | if ("åªä¸ªå®¢æ·æèµé±".equals(normalized) |
| | | || "æè¿åªä¸ªå®¢æ·æèµé±".equals(normalized) |
| | | || "æ¬æåªä¸ªå®¢æ·æèµé±".equals(normalized) |
| | | || "è¿30天åªä¸ªå®¢æ·æèµé±".equals(normalized) |
| | | || "åªä¸ªå®¢æ·å©æ¶¦æé«".equals(normalized) |
| | | || "åªä¸ªå®¢æ·å©æ¶¦è´¡ç®æé«".equals(normalized)) { |
| | | DateRange range = extractDateRange(text); |
| | | return financialAgentTools.analyzeOrderProfit(memoryId, range.startDate(), range.endDate(), range.label(), null, 20); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private boolean containsAny(String text, String... keywords) { |
| | | for (String keyword : keywords) { |
| | | if (text.contains(keyword)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private Integer extractLimit(String text) { |
| | | Matcher matcher = LIMIT_PATTERN.matcher(text); |
| | | return matcher.find() ? Integer.parseInt(matcher.group(2)) : 10; |
| | | } |
| | | |
| | | private DateRange extractDateRange(String text) { |
| | | Matcher matcher = DATE_PATTERN.matcher(text); |
| | | if (matcher.find()) { |
| | | String first = matcher.group(1); |
| | | String second = matcher.find() ? matcher.group(1) : first; |
| | | return buildDateRange(first, second, first + "è³" + second); |
| | | } |
| | | if (text.contains("æ¬æ")) { |
| | | return monthRange(); |
| | | } |
| | | if (text.contains("䏿")) { |
| | | return lastMonthRange(); |
| | | } |
| | | if (text.contains("æ¬å¹´") || text.contains("ä»å¹´")) { |
| | | return yearRange(); |
| | | } |
| | | if (text.contains("æ¬å¨")) { |
| | | return weekRange(); |
| | | } |
| | | Matcher relativeDayMatcher = RELATIVE_DAY_PATTERN.matcher(text); |
| | | if (relativeDayMatcher.find()) { |
| | | int days = Integer.parseInt(relativeDayMatcher.group(2)); |
| | | return recentDaysRange(days); |
| | | } |
| | | return new DateRange(null, null, "è¿30天"); |
| | | } |
| | | |
| | | private DateRange buildDateRange(String start, String end, String label) { |
| | | LocalDate startDate = parseDate(start); |
| | | LocalDate endDate = parseDate(end); |
| | | if (startDate == null || endDate == null) { |
| | | return new DateRange(null, null, "è¿30天"); |
| | | } |
| | | if (startDate.isAfter(endDate)) { |
| | | LocalDate temp = startDate; |
| | | startDate = endDate; |
| | | endDate = temp; |
| | | } |
| | | return new DateRange(formatDate(startDate), formatDate(endDate), label); |
| | | } |
| | | |
| | | private DateRange recentDaysRange(int days) { |
| | | LocalDate end = LocalDate.now(); |
| | | int safeDays = Math.max(days, 1); |
| | | LocalDate start = end.minusDays(safeDays - 1L); |
| | | return new DateRange(formatDate(start), formatDate(end), "è¿" + safeDays + "天"); |
| | | } |
| | | |
| | | private DateRange monthRange() { |
| | | LocalDate today = LocalDate.now(); |
| | | return new DateRange(formatDate(today.withDayOfMonth(1)), formatDate(today), "æ¬æ"); |
| | | } |
| | | |
| | | private DateRange weekRange() { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate start = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | return new DateRange(formatDate(start), formatDate(today), "æ¬å¨"); |
| | | } |
| | | |
| | | private DateRange lastMonthRange() { |
| | | YearMonth lastMonth = YearMonth.now().minusMonths(1); |
| | | return new DateRange(formatDate(lastMonth.atDay(1)), formatDate(lastMonth.atEndOfMonth()), "䏿"); |
| | | } |
| | | |
| | | private DateRange yearRange() { |
| | | LocalDate today = LocalDate.now(); |
| | | return new DateRange(formatDate(today.withDayOfYear(1)), formatDate(today), "ä»å¹´"); |
| | | } |
| | | |
| | | private LocalDate parseDate(String text) { |
| | | try { |
| | | return LocalDate.parse(text, DATE_FMT); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private String formatDate(LocalDate date) { |
| | | return date == null ? null : date.format(DATE_FMT); |
| | | } |
| | | |
| | | private String normalizeForMatch(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return ""; |
| | | } |
| | | return text.replace("ï¼", "") |
| | | .replace(",", "") |
| | | .replace("ã", "") |
| | | .replace(".", "") |
| | | .replace("ï¼", "") |
| | | .replace("!", "") |
| | | .replace("ï¼", "") |
| | | .replace("?", "") |
| | | .replace("ï¼", "") |
| | | .replace(":", "") |
| | | .replace("ï¼", "") |
| | | .replace(";", "") |
| | | .replace(" ", "") |
| | | .trim(); |
| | | } |
| | | |
| | | private String extractKeyword(String text) { |
| | | String cleaned = text |
| | | .replace("æ¥è¯¢", "") |
| | | .replace("æ¥ç", "") |
| | | .replace("çä¸", "") |
| | | .replace("çç", "") |
| | | .replace("帮æ", "") |
| | | .replace("请", "") |
| | | .replace("ä¸ä¸", "") |
| | | .replace("为ä»ä¹", "") |
| | | .replace("åªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("æè¿åªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("æ¬æåªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("è¿30天åªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("æèµé±å®¢æ·", "") |
| | | .replace("å®¢æ·æèµé±", "") |
| | | .replace("åªä¸ªå®¢æ·å©æ¶¦æé«", "") |
| | | .replace("婿¶¦æé«å®¢æ·", "") |
| | | .replace("åªä¸ªå®¢æ·å©æ¶¦è´¡ç®æé«", "") |
| | | .replace("婿¶¦è´¡ç®æé«å®¢æ·", "") |
| | | .replace("æ¬æ", "") |
| | | .replace("æ¬å¨", "") |
| | | .replace("æ¬å¹´", "") |
| | | .replace("ä»å¹´", "") |
| | | .replace("䏿", "") |
| | | .replace("è¿30天", "") |
| | | .replace("è¿7天", "") |
| | | .replace("è¿90天", "") |
| | | .replace("å10æ¡", "") |
| | | .replace("æè¿10æ¡", "") |
| | | .replace("å20æ¡", "") |
| | | .replace("æè¿20æ¡", "") |
| | | .replace("订å婿¶¦åæ", "") |
| | | .replace("婿¶¦åæ", "") |
| | | .replace("åºåèµéåæ", "") |
| | | .replace("ç°éæµé¢æµ", "") |
| | | .replace("ç»è¥é©¾é©¶è±", "") |
| | | .replace("æ¥æ¥", "") |
| | | .replace("卿¥", "") |
| | | .replace("å¼å¸¸é¢è¦", "") |
| | | .replace("æ¡", "") |
| | | .trim(); |
| | | return cleaned.length() >= 2 ? cleaned : null; |
| | | } |
| | | |
| | | private record DateRange(String startDate, String endDate, String label) { |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.assistant; |
| | | |
| | | import dev.langchain4j.service.MemoryId; |
| | | import dev.langchain4j.service.SystemMessage; |
| | | import dev.langchain4j.service.UserMessage; |
| | | import dev.langchain4j.service.V; |
| | | import dev.langchain4j.service.spring.AiService; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | | import static dev.langchain4j.service.spring.AiServiceWiringMode.EXPLICIT; |
| | | |
| | | @AiService( |
| | | wiringMode = EXPLICIT, |
| | | streamingChatModel = "qwenStreamingChatModel", |
| | | chatMemoryProvider = "chatMemoryProviderManufacturing", |
| | | tools = "manufacturingAgentTools" |
| | | ) |
| | | public interface ManufacturingAgent { |
| | | |
| | | @SystemMessage(fromResource = "manufacturing-agent-prompt.txt") |
| | | Flux<String> chat(@MemoryId String memoryId, @UserMessage String userMessage, @V("currentDate") String currentDate); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.assistant; |
| | | |
| | | import com.ruoyi.ai.tools.ManufacturingAgentTools; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | @Component |
| | | public class ManufacturingIntentExecutor { |
| | | |
| | | private static final Pattern LIMIT_PATTERN = Pattern.compile("(å|æè¿)?(\\d{1,2})æ¡"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})"); |
| | | |
| | | private final ManufacturingAgentTools manufacturingAgentTools; |
| | | |
| | | public ManufacturingIntentExecutor(ManufacturingAgentTools manufacturingAgentTools) { |
| | | this.manufacturingAgentTools = manufacturingAgentTools; |
| | | } |
| | | |
| | | public String tryExecute(String memoryId, String message) { |
| | | if (!StringUtils.hasText(message)) { |
| | | return null; |
| | | } |
| | | String text = message.trim(); |
| | | String keyword = extractKeyword(text); |
| | | Integer limit = extractLimit(text); |
| | | String startDate = extractStartDate(text); |
| | | String endDate = extractEndDate(text); |
| | | |
| | | if (containsAny(text, "é¢è¦", "åè¦", "é£é©", "æé")) { |
| | | return manufacturingAgentTools.getWarningBoard(memoryId, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "åæ", "ç»è®¡", "è¶å¿", "çæ¿", "æ¥è¡¨", "æ»è§")) { |
| | | return manufacturingAgentTools.analyzeFactory(memoryId, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "å", "å¤ç", "派工", "宿", "éç¯", "è·è¿", "å¤ç½®")) { |
| | | return manufacturingAgentTools.planActions(memoryId, text); |
| | | } |
| | | |
| | | if (containsAny(text, "ç产ç°åº", "ç°åº", "车é´")) { |
| | | return manufacturingAgentTools.queryDomain(memoryId, "site", keyword, limit, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "计å", "æäº§", "mps")) { |
| | | return manufacturingAgentTools.queryDomain(memoryId, "plan", keyword, limit, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "å·¥å", "ä½ä¸å", "ä»»å¡å", "ä»»å¡")) { |
| | | return manufacturingAgentTools.queryDomain(memoryId, "workorder", keyword, limit, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "设å¤", "ç»´ä¿®", "ä¿å
»", "æ
é")) { |
| | | return manufacturingAgentTools.queryDomain(memoryId, "device", keyword, limit, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "è´¨é", "è´¨æ£", "ä¸åæ ¼", "æ£éª")) { |
| | | return manufacturingAgentTools.queryDomain(memoryId, "quality", keyword, limit, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "ç©æ", "åºå", "åºä½", "å
¥åº", "åºåº")) { |
| | | return manufacturingAgentTools.queryDomain(memoryId, "material", keyword, limit, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "å¼å¸¸", "ä¾å¤", "åå·®")) { |
| | | return manufacturingAgentTools.queryDomain(memoryId, "exception", keyword, limit, startDate, endDate, text); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private boolean containsAny(String text, String... keywords) { |
| | | for (String keyword : keywords) { |
| | | if (text.toLowerCase().contains(keyword.toLowerCase())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private Integer extractLimit(String text) { |
| | | Matcher matcher = LIMIT_PATTERN.matcher(text); |
| | | return matcher.find() ? Integer.parseInt(matcher.group(2)) : 10; |
| | | } |
| | | |
| | | private String extractStartDate(String text) { |
| | | Matcher matcher = DATE_PATTERN.matcher(text); |
| | | return matcher.find() ? matcher.group(1) : null; |
| | | } |
| | | |
| | | private String extractEndDate(String text) { |
| | | Matcher matcher = DATE_PATTERN.matcher(text); |
| | | if (!matcher.find()) { |
| | | return null; |
| | | } |
| | | return matcher.find() ? matcher.group(1) : null; |
| | | } |
| | | |
| | | private String extractKeyword(String text) { |
| | | String cleaned = text |
| | | .replace("æ¥è¯¢", "") |
| | | .replace("æ¥ç", "") |
| | | .replace("帮æ", "") |
| | | .replace("请", "") |
| | | .replace("ä¸ä¸", "") |
| | | .replace("ææ", "") |
| | | .replace("å
¨é¨", "") |
| | | .replace("ä»å¹´", "") |
| | | .replace("æ¬å¹´", "") |
| | | .replace("å»å¹´", "") |
| | | .replace("æ¬æ", "") |
| | | .replace("䏿", "") |
| | | .replace("æ¬å¨", "") |
| | | .replace("ä¸å¨", "") |
| | | .replace("ä»å¤©", "") |
| | | .replace("æ¨å¤©", "") |
| | | .replace("è¿30天", "") |
| | | .replace("è¿7天", "") |
| | | .replace("è¿15天", "") |
| | | .replace("è¿60天", "") |
| | | .replace("æè¿30天", "") |
| | | .replace("æè¿7天", "") |
| | | .replace("æè¿15天", "") |
| | | .replace("æè¿60天", "") |
| | | .replace("ç产ç°åº", "") |
| | | .replace("ç°åº", "") |
| | | .replace("ç产工å", "") |
| | | .replace("ç产", "") |
| | | .replace("计å", "") |
| | | .replace("æäº§", "") |
| | | .replace("å·¥å", "") |
| | | .replace("设å¤", "") |
| | | .replace("è´¨é", "") |
| | | .replace("ç©æ", "") |
| | | .replace("åºå", "") |
| | | .replace("å¼å¸¸", "") |
| | | .replace("å10æ¡", "") |
| | | .replace("æè¿10æ¡", "") |
| | | .trim(); |
| | | return cleaned.length() >= 2 ? cleaned : null; |
| | | } |
| | | } |
| | |
| | | import dev.langchain4j.service.MemoryId; |
| | | import dev.langchain4j.service.SystemMessage; |
| | | import dev.langchain4j.service.UserMessage; |
| | | import dev.langchain4j.service.V; |
| | | import dev.langchain4j.service.spring.AiService; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | |
| | | public interface PurchaseAgent { |
| | | |
| | | @SystemMessage(fromResource = "purchase-agent-prompt.txt") |
| | | Flux<String> chat(@MemoryId String memoryId, @UserMessage String userMessage); |
| | | Flux<String> chat(@MemoryId String memoryId, @UserMessage String userMessage, @V("currentDate") String currentDate); |
| | | } |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | |
| | | public class PurchaseIntentExecutor { |
| | | |
| | | private static final Pattern ID_PATTERN = Pattern.compile("\\b\\d{1,12}\\b"); |
| | | private static final Pattern LIMIT_PATTERN = Pattern.compile("(å|æè¿)?(\\d{1,2})æ¡"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("\\d{4}-\\d{2}-\\d{2}"); |
| | | private static final Pattern LIMIT_PATTERN = Pattern.compile("(å|æè¿)?\\s*(\\d{1,2})\\s*æ¡"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})"); |
| | | private static final Pattern RELATIVE_RANGE_PATTERN = Pattern.compile("(è¿|æè¿)\\s*(\\d{1,3})\\s*(天|å¨|个æ|æ|å¹´)"); |
| | | private static final Pattern HALF_RANGE_PATTERN = Pattern.compile("(æè¿|è¿)?å(个)?(æ|å¹´)"); |
| | | private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai"); |
| | | |
| | | private final PurchaseAgentTools purchaseAgentTools; |
| | | |
| | |
| | | return null; |
| | | } |
| | | String text = message.trim(); |
| | | String quickPromptResponse = tryExecuteQuickPrompt(memoryId, text); |
| | | if (StringUtils.hasText(quickPromptResponse)) { |
| | | return quickPromptResponse; |
| | | } |
| | | |
| | | if (containsAny(text, "æè¡", "æå", "åå ", "åäº", "åå") && containsAny(text, "ç©æ", "产å", "åææ", "éè´éé¢", "éé¢")) { |
| | | return purchaseAgentTools.rankPurchaseMaterials( |
| | | memoryId, |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | text, |
| | | extractLimit(text) |
| | | ); |
| | | String keyword = extractKeyword(text); |
| | | Integer limit = extractLimit(text); |
| | | DateRange dateRange = extractDateRange(text); |
| | | String startDate = dateRange.startDate(); |
| | | String endDate = dateRange.endDate(); |
| | | |
| | | if (containsAny(text, "æè¡", "æå", "åå ", "åäº", "åå") |
| | | && containsAny(text, "ç©æ", "产å", "åææ", "éè´éé¢", "éé¢")) { |
| | | return purchaseAgentTools.rankPurchaseMaterials(memoryId, startDate, endDate, text, limit); |
| | | } |
| | | if (containsAny(text, "æªå
¥åº", "å¾
å
¥åº", "没æå
¥åº", "è¿æªå
¥åº")) { |
| | | return purchaseAgentTools.listUnstockedPurchaseOrders( |
| | | memoryId, |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | extractKeyword(text), |
| | | extractLimit(text) |
| | | ); |
| | | return purchaseAgentTools.listUnstockedPurchaseOrders(memoryId, startDate, endDate, keyword, limit); |
| | | } |
| | | if (containsAny(text, "å°è´§å¼å¸¸", "å°è´§æå¼å¸¸", "å¼å¸¸å°è´§", "å°è´§é®é¢", "ä¾åºåå°è´§å¼å¸¸")) { |
| | | return purchaseAgentTools.listArrivalExceptions( |
| | | memoryId, |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | text, |
| | | extractLimit(text) |
| | | ); |
| | | return purchaseAgentTools.listArrivalExceptions(memoryId, startDate, endDate, text, limit); |
| | | } |
| | | if (containsAny(text, "å¾
仿¬¾", "æªä»æ¬¾", "æªä»æ¸
", "å¾
æ¯ä»", "åºä»")) { |
| | | return purchaseAgentTools.listPendingPaymentOrders( |
| | | memoryId, |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | extractKeyword(text), |
| | | extractLimit(text) |
| | | ); |
| | | return purchaseAgentTools.listPendingPaymentOrders(memoryId, startDate, endDate, keyword, limit); |
| | | } |
| | | if (containsAny(text, "éè´§", "éæ", "ææ¶")) { |
| | | return purchaseAgentTools.listPurchaseReturns( |
| | | memoryId, |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | extractKeyword(text), |
| | | extractLimit(text) |
| | | ); |
| | | return purchaseAgentTools.listPurchaseReturns(memoryId, startDate, endDate, keyword, limit); |
| | | } |
| | | if (isStatsIntent(text)) { |
| | | return purchaseAgentTools.getPurchaseStats( |
| | | memoryId, |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | text |
| | | ); |
| | | return purchaseAgentTools.getPurchaseStats(memoryId, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "详æ
", "æç»") && extractId(text) != null) { |
| | | return purchaseAgentTools.getPurchaseLedgerDetail(memoryId, extractId(text)); |
| | | |
| | | Long ledgerId = extractId(text); |
| | | if (containsAny(text, "详æ
", "æç»") && ledgerId != null) { |
| | | return purchaseAgentTools.getPurchaseLedgerDetail(memoryId, ledgerId); |
| | | } |
| | | if (containsAny(text, "å°è´¦", "éè´å", "éè´è®¢å", "订å", "åå", "å表", "æ¥è¯¢")) { |
| | | return purchaseAgentTools.listPurchaseLedgers( |
| | | memoryId, |
| | | extractKeyword(text), |
| | | extractStartDate(text), |
| | | extractEndDate(text), |
| | | extractLimit(text) |
| | | ); |
| | | return purchaseAgentTools.listPurchaseLedgers(memoryId, keyword, startDate, endDate, limit); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String tryExecuteQuickPrompt(String memoryId, String text) { |
| | | String normalized = normalizeForMatch(text); |
| | | if ("æ¬æéè´é颿åååçç©ææåªäº".equals(normalized)) { |
| | | return purchaseAgentTools.rankPurchaseMaterials(memoryId, null, null, "æ¬æ", 10); |
| | | } |
| | | if ("åªäºéè´è®¢åè¿æªå
¥åº".equals(normalized)) { |
| | | return purchaseAgentTools.listUnstockedPurchaseOrders(memoryId, null, null, null, 10); |
| | | } |
| | | if ("æè¿7天ä¾åºåå°è´§å¼å¸¸æåªäº".equals(normalized)) { |
| | | return purchaseAgentTools.listArrivalExceptions(memoryId, null, null, "æè¿7天", 10); |
| | | } |
| | | if ("帮æç»è®¡å¾
仿¬¾éè´å".equals(normalized)) { |
| | | return purchaseAgentTools.listPendingPaymentOrders(memoryId, null, null, null, 10); |
| | | } |
| | | if ("ååºæ¬æéè´éè´§æ
åµ".equals(normalized)) { |
| | | return purchaseAgentTools.listPurchaseReturns(memoryId, null, null, null, 10); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | boolean queryWord = containsAny(text, "æ¥è¯¢", "æ¥ç", "çä¸", "çç", "è·å"); |
| | | boolean dataWord = containsAny(text, "æ°æ®", "éé¢", "æ°é", "ååé¢", "仿¬¾é¢", "å票é¢"); |
| | | boolean timeWord = containsAny(text, "ä»å¤©", "æ¬å¨", "æ¬æ", "䏿", "ä»å¹´", "å»å¹´", "è¿åå¹´", "æè¿å个æ", "å个æ") |
| | | || DATE_PATTERN.matcher(text).find(); |
| | | boolean timeWord = containsAny(text, "ä»å¤©", "æ¨å¤©", "æ¬å¨", "ä¸å¨", "æ¬æ", "䏿", "ä»å¹´", "å»å¹´", "è¿åå¹´", "æè¿å个æ", "å个æ") |
| | | || DATE_PATTERN.matcher(text).find() |
| | | || RELATIVE_RANGE_PATTERN.matcher(text).find() |
| | | || HALF_RANGE_PATTERN.matcher(text).find(); |
| | | return queryWord && dataWord && timeWord; |
| | | } |
| | | |
| | |
| | | return matcher.find() ? Integer.parseInt(matcher.group(2)) : 10; |
| | | } |
| | | |
| | | private String extractStartDate(String text) { |
| | | private DateRange extractDateRange(String text) { |
| | | Matcher matcher = DATE_PATTERN.matcher(text); |
| | | return matcher.find() ? matcher.group() : null; |
| | | if (matcher.find()) { |
| | | String first = matcher.group(1); |
| | | String second = matcher.find() ? matcher.group(1) : first; |
| | | return buildDateRange(first, second); |
| | | } |
| | | |
| | | LocalDate today = LocalDate.now(CHINA_ZONE_ID); |
| | | if (text.contains("ä»å¤©")) { |
| | | return new DateRange(formatDate(today), formatDate(today)); |
| | | } |
| | | if (text.contains("æ¨å¤©")) { |
| | | LocalDate yesterday = today.minusDays(1); |
| | | return new DateRange(formatDate(yesterday), formatDate(yesterday)); |
| | | } |
| | | if (text.contains("æ¬å¨")) { |
| | | LocalDate start = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | return new DateRange(formatDate(start), formatDate(today)); |
| | | } |
| | | if (text.contains("ä¸å¨")) { |
| | | LocalDate thisWeekStart = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | LocalDate start = thisWeekStart.minusWeeks(1); |
| | | LocalDate end = start.plusDays(6); |
| | | return new DateRange(formatDate(start), formatDate(end)); |
| | | } |
| | | if (text.contains("æ¬æ")) { |
| | | return new DateRange(formatDate(today.withDayOfMonth(1)), formatDate(today)); |
| | | } |
| | | if (text.contains("䏿")) { |
| | | LocalDate start = today.minusMonths(1).withDayOfMonth(1); |
| | | return new DateRange(formatDate(start), formatDate(start.withDayOfMonth(start.lengthOfMonth()))); |
| | | } |
| | | if (text.contains("ä»å¹´") || text.contains("æ¬å¹´")) { |
| | | return new DateRange(formatDate(today.withDayOfYear(1)), formatDate(today)); |
| | | } |
| | | if (text.contains("å»å¹´")) { |
| | | LocalDate start = today.minusYears(1).withDayOfYear(1); |
| | | LocalDate end = start.withDayOfYear(start.lengthOfYear()); |
| | | return new DateRange(formatDate(start), formatDate(end)); |
| | | } |
| | | if (containsAny(text, "è¿åå¹´", "æè¿åå¹´")) { |
| | | return new DateRange(formatDate(today.minusMonths(6).plusDays(1)), formatDate(today)); |
| | | } |
| | | if (containsAny(text, "è¿å个æ", "æè¿å个æ", "å个æ")) { |
| | | return new DateRange(formatDate(today.minusDays(14)), formatDate(today)); |
| | | } |
| | | |
| | | Matcher relativeMatcher = RELATIVE_RANGE_PATTERN.matcher(text); |
| | | if (relativeMatcher.find()) { |
| | | int amount = Integer.parseInt(relativeMatcher.group(2)); |
| | | String unit = relativeMatcher.group(3); |
| | | LocalDate start = switch (unit) { |
| | | case "天" -> today.minusDays(Math.max(amount - 1L, 0)); |
| | | case "å¨" -> today.minusWeeks(Math.max(amount, 1)).plusDays(1); |
| | | case "个æ", "æ" -> today.minusMonths(Math.max(amount, 1)).plusDays(1); |
| | | case "å¹´" -> today.minusYears(Math.max(amount, 1)).plusDays(1); |
| | | default -> today.minusDays(29); |
| | | }; |
| | | return new DateRange(formatDate(start), formatDate(today)); |
| | | } |
| | | |
| | | return new DateRange(null, null); |
| | | } |
| | | |
| | | private String extractEndDate(String text) { |
| | | Matcher matcher = DATE_PATTERN.matcher(text); |
| | | if (!matcher.find()) { |
| | | private DateRange buildDateRange(String start, String end) { |
| | | LocalDate startDate = parseDate(start); |
| | | LocalDate endDate = parseDate(end); |
| | | if (startDate == null || endDate == null) { |
| | | return new DateRange(null, null); |
| | | } |
| | | if (startDate.isAfter(endDate)) { |
| | | LocalDate temp = startDate; |
| | | startDate = endDate; |
| | | endDate = temp; |
| | | } |
| | | return new DateRange(formatDate(startDate), formatDate(endDate)); |
| | | } |
| | | |
| | | private LocalDate parseDate(String text) { |
| | | try { |
| | | return LocalDate.parse(text, DATE_FMT); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | return matcher.find() ? matcher.group() : null; |
| | | } |
| | | |
| | | private String formatDate(LocalDate date) { |
| | | return date == null ? null : date.format(DATE_FMT); |
| | | } |
| | | |
| | | private String normalizeForMatch(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return ""; |
| | | } |
| | | return text.replace("ï¼", "") |
| | | .replace(",", "") |
| | | .replace("ã", "") |
| | | .replace(".", "") |
| | | .replace("ï¼", "") |
| | | .replace("!", "") |
| | | .replace("ï¼", "") |
| | | .replace("?", "") |
| | | .replace("ï¼", "") |
| | | .replace(":", "") |
| | | .replace("ï¼", "") |
| | | .replace(";", "") |
| | | .replace(" ", "") |
| | | .trim(); |
| | | } |
| | | |
| | | private String extractKeyword(String text) { |
| | | String cleaned = text |
| | | .replace("æ¥è¯¢", "") |
| | | .replace("æ¥ç", "") |
| | | .replace("çä¸", "") |
| | | .replace("çç", "") |
| | | .replace("请", "") |
| | | .replace("ä¸ä¸", "") |
| | | .replace("éè´", "") |
| | | .replace("éè´å", "") |
| | | .replace("éè´è®¢å", "") |
| | |
| | | .replace("åªäº", "") |
| | | .replace("ååº", "") |
| | | .replace("帮æ", "") |
| | | .replace("ç»è®¡", "") |
| | | .replace("åæ", "") |
| | | .replace("æ¬æ", "") |
| | | .replace("䏿", "") |
| | | .replace("æ¬å¹´", "") |
| | | .replace("ä»å¹´", "") |
| | | .replace("å»å¹´", "") |
| | | .replace("æ¬å¨", "") |
| | | .replace("ä¸å¨", "") |
| | | .replace("ä»å¤©", "") |
| | | .replace("æ¨å¤©", "") |
| | | .replace("è¿30天", "") |
| | | .replace("è¿7天", "") |
| | | .replace("è¿15天", "") |
| | | .replace("è¿60天", "") |
| | | .replace("æè¿30天", "") |
| | | .replace("æè¿7天", "") |
| | | .replace("æè¿15天", "") |
| | | .replace("æè¿60天", "") |
| | | .replace("æè¿10æ¡", "") |
| | | .replace("å10æ¡", "") |
| | | .replace("å20æ¡", "") |
| | | .replace("æè¿20æ¡", "") |
| | | .trim(); |
| | | return cleaned.length() >= 2 ? cleaned : null; |
| | | } |
| | | |
| | | private record DateRange(String startDate, String endDate) { |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.assistant; |
| | | |
| | | import dev.langchain4j.service.MemoryId; |
| | | import dev.langchain4j.service.SystemMessage; |
| | | import dev.langchain4j.service.UserMessage; |
| | | import dev.langchain4j.service.V; |
| | | import dev.langchain4j.service.spring.AiService; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | | import static dev.langchain4j.service.spring.AiServiceWiringMode.EXPLICIT; |
| | | |
| | | @AiService( |
| | | wiringMode = EXPLICIT, |
| | | streamingChatModel = "qwenStreamingChatModel", |
| | | chatMemoryProvider = "chatMemoryProviderSales", |
| | | tools = "salesAgentTools" |
| | | ) |
| | | public interface SalesAgent { |
| | | |
| | | @SystemMessage(fromResource = "sales-agent-prompt.txt") |
| | | Flux<String> chat(@MemoryId String memoryId, @UserMessage String userMessage, @V("currentDate") String currentDate); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.assistant; |
| | | |
| | | import com.ruoyi.ai.tools.SalesAgentTools; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.YearMonth; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | @Component |
| | | public class SalesIntentExecutor { |
| | | |
| | | private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final Pattern LIMIT_PATTERN = Pattern.compile("(å|æè¿)?\\s*(\\d{1,2})\\s*æ¡"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})"); |
| | | private static final Pattern RELATIVE_DAY_PATTERN = Pattern.compile("(è¿|æè¿)?\\s*(\\d{1,3})\\s*天"); |
| | | |
| | | private final SalesAgentTools salesAgentTools; |
| | | |
| | | public SalesIntentExecutor(SalesAgentTools salesAgentTools) { |
| | | this.salesAgentTools = salesAgentTools; |
| | | } |
| | | |
| | | public String tryExecute(String memoryId, String message) { |
| | | if (!StringUtils.hasText(message)) { |
| | | return null; |
| | | } |
| | | String text = message.trim(); |
| | | |
| | | String quickPromptResponse = tryExecuteQuickPrompt(memoryId, text); |
| | | if (StringUtils.hasText(quickPromptResponse)) { |
| | | return quickPromptResponse; |
| | | } |
| | | |
| | | String keyword = extractKeyword(text); |
| | | Integer limit = extractLimit(text); |
| | | DateRange dateRange = extractDateRange(text); |
| | | String startDate = dateRange.startDate(); |
| | | String endDate = dateRange.endDate(); |
| | | |
| | | if (containsAny(text, "æµå¤±", "æµå¤±é£é©", "å®¢æ·æµå¤±", "é£é©åæ")) { |
| | | return salesAgentTools.analyzeCustomerChurnRisk(memoryId, startDate, endDate, text, keyword, limit); |
| | | } |
| | | if (containsAny(text, "忬¾", "æ¶æ¬¾", "æ¥ä»·") |
| | | && containsAny(text, "建议", "çç¥", "ä¼å", "æ¹æ¡")) { |
| | | return salesAgentTools.suggestCollectionAndQuotationStrategy( |
| | | memoryId, startDate, endDate, text, keyword, limit, shouldPrioritizeHighRisk(text)); |
| | | } |
| | | if (containsAny(text, "ææ ", "ç»è®¡", "çæ¿", "æ»è§", "ç»è¥åæ")) { |
| | | return salesAgentTools.getSalesDashboard(memoryId, startDate, endDate, text); |
| | | } |
| | | if (containsAny(text, "å®¢æ·æ¡£æ¡", "ç§æµ·", "å
¬æµ·", "å®¢æ·æ± ")) { |
| | | return salesAgentTools.listCustomerProfiles(memoryId, extractSeaType(text), keyword, limit); |
| | | } |
| | | if (containsAny(text, "é宿¥ä»·", "æ¥ä»·å", "æ¥ä»·", "询价")) { |
| | | return salesAgentTools.listSalesQuotations(memoryId, keyword, startDate, endDate, limit); |
| | | } |
| | | if (containsAny(text, "éå®éè´§", "éè´§", "鿬¾")) { |
| | | return salesAgentTools.listSalesReturns(memoryId, startDate, endDate, keyword, limit); |
| | | } |
| | | if (containsAny(text, "客æ·å¾æ¥", "徿¥", "忬¾", "åºæ¶", "æ¥æ¬¾", "æ¶æ¬¾æç»")) { |
| | | return salesAgentTools.listCustomerInteractions(memoryId, keyword, startDate, endDate, limit); |
| | | } |
| | | if (containsAny(text, "åè´§å°è´¦", "åè´§", "ç©æµ", "å¿«é", "è¿è¾")) { |
| | | return salesAgentTools.listShippingLedgers(memoryId, keyword, startDate, endDate, limit); |
| | | } |
| | | if (containsAny(text, "éå®å°è´¦", "éå®åå", "éå®è®¢å", "ååå°è´¦", "订åå°è´¦")) { |
| | | return salesAgentTools.listSalesLedgers(memoryId, keyword, startDate, endDate, limit); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String tryExecuteQuickPrompt(String memoryId, String text) { |
| | | String normalized = normalizeForMatch(text); |
| | | if ("æ¥è¯¢ç§æµ·å®¢æ·æ¡£æ¡å10æ¡".equals(normalized)) { |
| | | return salesAgentTools.listCustomerProfiles(memoryId, "private", null, 10); |
| | | } |
| | | if ("æ¥è¯¢å
¬æµ·å®¢æ·æ¡£æ¡".equals(normalized)) { |
| | | return salesAgentTools.listCustomerProfiles(memoryId, "public", null, 10); |
| | | } |
| | | if ("æ¥è¯¢æ¬æé宿¥ä»·".equals(normalized)) { |
| | | DateRange range = monthRange(); |
| | | return salesAgentTools.listSalesQuotations(memoryId, null, range.startDate(), range.endDate(), 10); |
| | | } |
| | | if ("æ¥è¯¢æ¬æéå®å°è´¦".equals(normalized)) { |
| | | DateRange range = monthRange(); |
| | | return salesAgentTools.listSalesLedgers(memoryId, null, range.startDate(), range.endDate(), 10); |
| | | } |
| | | if ("æ¥è¯¢è¿30天éå®éè´§".equals(normalized)) { |
| | | DateRange range = recentDaysRange(30); |
| | | return salesAgentTools.listSalesReturns(memoryId, range.startDate(), range.endDate(), null, 10); |
| | | } |
| | | if ("æ¥è¯¢è¿30天客æ·åæ¬¾å¾æ¥".equals(normalized)) { |
| | | DateRange range = recentDaysRange(30); |
| | | return salesAgentTools.listCustomerInteractions(memoryId, null, range.startDate(), range.endDate(), 10); |
| | | } |
| | | if ("æ¥è¯¢æ¬æåè´§å°è´¦".equals(normalized)) { |
| | | DateRange range = monthRange(); |
| | | return salesAgentTools.listShippingLedgers(memoryId, null, range.startDate(), range.endDate(), 10); |
| | | } |
| | | if ("æ¥çé宿æ ç»è®¡".equals(normalized)) { |
| | | return salesAgentTools.getSalesDashboard(memoryId, null, null, "æ¬æ"); |
| | | } |
| | | if ("帮æåå®¢æ·æµå¤±é£é©åæè¿30天å20æ¡".equals(normalized)) { |
| | | DateRange range = recentDaysRange(30); |
| | | return salesAgentTools.analyzeCustomerChurnRisk(memoryId, range.startDate(), range.endDate(), "è¿30天", null, 20); |
| | | } |
| | | if ("çæåæ¬¾ä¸æ¥ä»·çç¥å»ºè®®ä¼å
é«é£é©å®¢æ·".equals(normalized)) { |
| | | DateRange range = recentDaysRange(30); |
| | | return salesAgentTools.suggestCollectionAndQuotationStrategy(memoryId, range.startDate(), range.endDate(), "è¿30天", null, 10, true); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private boolean containsAny(String text, String... keywords) { |
| | | for (String keyword : keywords) { |
| | | if (text.contains(keyword)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private String extractSeaType(String text) { |
| | | if (text.contains("å
¬æµ·")) { |
| | | return "public"; |
| | | } |
| | | if (text.contains("ç§æµ·")) { |
| | | return "private"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private Integer extractLimit(String text) { |
| | | Matcher matcher = LIMIT_PATTERN.matcher(text); |
| | | return matcher.find() ? Integer.parseInt(matcher.group(2)) : 10; |
| | | } |
| | | |
| | | private DateRange extractDateRange(String text) { |
| | | Matcher matcher = DATE_PATTERN.matcher(text); |
| | | if (matcher.find()) { |
| | | String first = matcher.group(1); |
| | | String second = matcher.find() ? matcher.group(1) : first; |
| | | return buildDateRange(first, second); |
| | | } |
| | | if (text.contains("æ¬æ")) { |
| | | return monthRange(); |
| | | } |
| | | if (text.contains("䏿")) { |
| | | return lastMonthRange(); |
| | | } |
| | | if (text.contains("æ¬å¹´") || text.contains("ä»å¹´")) { |
| | | return yearRange(); |
| | | } |
| | | Matcher relativeDayMatcher = RELATIVE_DAY_PATTERN.matcher(text); |
| | | if (relativeDayMatcher.find()) { |
| | | int days = Integer.parseInt(relativeDayMatcher.group(2)); |
| | | return recentDaysRange(days); |
| | | } |
| | | return new DateRange(null, null); |
| | | } |
| | | |
| | | private DateRange buildDateRange(String start, String end) { |
| | | LocalDate startDate = parseDate(start); |
| | | LocalDate endDate = parseDate(end); |
| | | if (startDate == null || endDate == null) { |
| | | return new DateRange(null, null); |
| | | } |
| | | if (startDate.isAfter(endDate)) { |
| | | LocalDate temp = startDate; |
| | | startDate = endDate; |
| | | endDate = temp; |
| | | } |
| | | return new DateRange(formatDate(startDate), formatDate(endDate)); |
| | | } |
| | | |
| | | private DateRange recentDaysRange(int days) { |
| | | LocalDate end = LocalDate.now(); |
| | | int safeDays = Math.max(days, 1); |
| | | LocalDate start = end.minusDays(safeDays - 1L); |
| | | return new DateRange(formatDate(start), formatDate(end)); |
| | | } |
| | | |
| | | private DateRange monthRange() { |
| | | LocalDate today = LocalDate.now(); |
| | | return new DateRange(formatDate(today.withDayOfMonth(1)), formatDate(today)); |
| | | } |
| | | |
| | | private DateRange lastMonthRange() { |
| | | YearMonth lastMonth = YearMonth.now().minusMonths(1); |
| | | return new DateRange(formatDate(lastMonth.atDay(1)), formatDate(lastMonth.atEndOfMonth())); |
| | | } |
| | | |
| | | private DateRange yearRange() { |
| | | LocalDate today = LocalDate.now(); |
| | | return new DateRange(formatDate(today.withDayOfYear(1)), formatDate(today)); |
| | | } |
| | | |
| | | private LocalDate parseDate(String text) { |
| | | try { |
| | | return LocalDate.parse(text, DATE_FMT); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private String formatDate(LocalDate date) { |
| | | return date == null ? null : date.format(DATE_FMT); |
| | | } |
| | | |
| | | private String normalizeForMatch(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return ""; |
| | | } |
| | | return text.replace("ï¼", "") |
| | | .replace(",", "") |
| | | .replace("ã", "") |
| | | .replace(".", "") |
| | | .replace("ï¼", "") |
| | | .replace("!", "") |
| | | .replace("ï¼", "") |
| | | .replace("?", "") |
| | | .replace("ï¼", "") |
| | | .replace(":", "") |
| | | .replace("ï¼", "") |
| | | .replace(";", "") |
| | | .replace(" ", "") |
| | | .trim(); |
| | | } |
| | | |
| | | private Boolean shouldPrioritizeHighRisk(String text) { |
| | | return containsAny(text, "ä¼å
é«é£é©", "é«é£é©å®¢æ·", "é«é£é©"); |
| | | } |
| | | |
| | | private String extractKeyword(String text) { |
| | | String cleaned = text |
| | | .replace("æ¥è¯¢", "") |
| | | .replace("æ¥ç", "") |
| | | .replace("çä¸", "") |
| | | .replace("çç", "") |
| | | .replace("帮æ", "") |
| | | .replace("请", "") |
| | | .replace("ä¸ä¸", "") |
| | | .replace("éå®", "") |
| | | .replace("å®¢æ·æ¡£æ¡", "") |
| | | .replace("æ¥ä»·å", "") |
| | | .replace("é宿¥ä»·", "") |
| | | .replace("éå®å°è´¦", "") |
| | | .replace("åè´§å°è´¦", "") |
| | | .replace("客æ·å¾æ¥", "") |
| | | .replace("éå®éè´§", "") |
| | | .replace("å10æ¡", "") |
| | | .replace("æè¿10æ¡", "") |
| | | .replace("å20æ¡", "") |
| | | .replace("æè¿20æ¡", "") |
| | | .replace("è¿30天", "") |
| | | .replace("æ¬æ", "") |
| | | .replace("æ¬å¹´", "") |
| | | .replace("ä»å¹´", "") |
| | | .replace("æ¡", "") |
| | | .trim(); |
| | | return cleaned.length() >= 2 ? cleaned : null; |
| | | } |
| | | |
| | | private record DateRange(String startDate, String endDate) { |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.config; |
| | | |
| | | import com.ruoyi.ai.store.MongoChatMemoryStore; |
| | | import dev.langchain4j.memory.chat.ChatMemoryProvider; |
| | | import dev.langchain4j.memory.chat.MessageWindowChatMemory; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class FinancialAgentConfig { |
| | | |
| | | @Bean |
| | | ChatMemoryProvider chatMemoryProviderFinancial(MongoChatMemoryStore mongoChatMemoryStore) { |
| | | return memoryId -> MessageWindowChatMemory.builder() |
| | | .id(memoryId) |
| | | .maxMessages(40) |
| | | .chatMemoryStore(mongoChatMemoryStore) |
| | | .build(); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.config; |
| | | |
| | | import com.ruoyi.ai.store.MongoChatMemoryStore; |
| | | import dev.langchain4j.memory.chat.ChatMemoryProvider; |
| | | import dev.langchain4j.memory.chat.MessageWindowChatMemory; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class ManufacturingAgentConfig { |
| | | |
| | | @Bean |
| | | ChatMemoryProvider chatMemoryProviderManufacturing(MongoChatMemoryStore mongoChatMemoryStore) { |
| | | return memoryId -> MessageWindowChatMemory.builder() |
| | | .id(memoryId) |
| | | .maxMessages(30) |
| | | .chatMemoryStore(mongoChatMemoryStore) |
| | | .build(); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.config; |
| | | |
| | | import com.ruoyi.ai.store.MongoChatMemoryStore; |
| | | import dev.langchain4j.memory.chat.ChatMemoryProvider; |
| | | import dev.langchain4j.memory.chat.MessageWindowChatMemory; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | public class SalesAgentConfig { |
| | | |
| | | @Bean |
| | | ChatMemoryProvider chatMemoryProviderSales(MongoChatMemoryStore mongoChatMemoryStore) { |
| | | return memoryId -> MessageWindowChatMemory.builder() |
| | | .id(memoryId) |
| | | .maxMessages(30) |
| | | .chatMemoryStore(mongoChatMemoryStore) |
| | | .build(); |
| | | } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.controller; |
| | | |
| | | import com.ruoyi.ai.assistant.FinancialAgent; |
| | | import com.ruoyi.ai.assistant.FinancialIntentExecutor; |
| | | import com.ruoyi.ai.bean.ChatForm; |
| | | import com.ruoyi.ai.context.AiSessionUserContext; |
| | | import com.ruoyi.ai.service.AiChatSessionService; |
| | | import com.ruoyi.ai.store.MongoChatMemoryStore; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import dev.langchain4j.data.message.AiMessage; |
| | | import dev.langchain4j.data.message.UserMessage; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | @Tag(name = "è´¢å¡æºè½ä½") |
| | | @RestController |
| | | @RequestMapping("/financial-ai") |
| | | public class FinancialAiController extends BaseController { |
| | | |
| | | private static final DateTimeFormatter CURRENT_DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai"); |
| | | |
| | | private final FinancialAgent financialAgent; |
| | | private final FinancialIntentExecutor financialIntentExecutor; |
| | | private final AiSessionUserContext aiSessionUserContext; |
| | | private final MongoChatMemoryStore mongoChatMemoryStore; |
| | | private final AiChatSessionService aiChatSessionService; |
| | | |
| | | public FinancialAiController(FinancialAgent financialAgent, |
| | | FinancialIntentExecutor financialIntentExecutor, |
| | | AiSessionUserContext aiSessionUserContext, |
| | | MongoChatMemoryStore mongoChatMemoryStore, |
| | | AiChatSessionService aiChatSessionService) { |
| | | this.financialAgent = financialAgent; |
| | | this.financialIntentExecutor = financialIntentExecutor; |
| | | this.aiSessionUserContext = aiSessionUserContext; |
| | | this.mongoChatMemoryStore = mongoChatMemoryStore; |
| | | this.aiChatSessionService = aiChatSessionService; |
| | | } |
| | | |
| | | @Operation(summary = "è´¢å¡æºè½ä½å¯¹è¯") |
| | | @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8") |
| | | public Flux<String> chat(@RequestBody ChatForm chatForm) { |
| | | if (!StringUtils.hasText(chatForm.getMemoryId())) { |
| | | return Flux.just("memoryIdä¸è½ä¸ºç©º"); |
| | | } |
| | | if (!StringUtils.hasText(chatForm.getMessage())) { |
| | | return Flux.just("messageä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String memoryId = chatForm.getMemoryId(); |
| | | String userMessage = chatForm.getMessage(); |
| | | |
| | | aiSessionUserContext.bind(memoryId, loginUser); |
| | | aiChatSessionService.touchSession(memoryId, loginUser, userMessage); |
| | | |
| | | String directResponse = financialIntentExecutor.tryExecute(memoryId, userMessage); |
| | | if (StringUtils.isNotEmpty(directResponse)) { |
| | | mongoChatMemoryStore.appendMessages( |
| | | memoryId, |
| | | List.of(UserMessage.from(userMessage), AiMessage.from(directResponse)) |
| | | ); |
| | | aiChatSessionService.refreshSessionStats(memoryId, loginUser); |
| | | return Flux.just(directResponse); |
| | | } |
| | | |
| | | return financialAgent.chat(memoryId, userMessage, currentDateForPrompt()) |
| | | .doOnComplete(() -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)) |
| | | .doOnError(ex -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)); |
| | | } |
| | | |
| | | @Operation(summary = "è´¢å¡æºè½ä½ä¼è¯å表") |
| | | @GetMapping("/history/sessions") |
| | | public AjaxResult listSessions() { |
| | | return success(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | @Operation(summary = "è´¢å¡æºè½ä½ä¼è¯æ¶æ¯") |
| | | @GetMapping("/history/messages/{memoryId}") |
| | | public AjaxResult listMessages(@PathVariable String memoryId) { |
| | | return success(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | @Operation(summary = "å é¤è´¢å¡æºè½ä½ä¼è¯") |
| | | @DeleteMapping("/history/{memoryId}") |
| | | public AjaxResult deleteSession(@PathVariable String memoryId) { |
| | | aiSessionUserContext.remove(memoryId); |
| | | return toAjax(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | private String currentDateForPrompt() { |
| | | return LocalDate.now(CHINA_ZONE_ID).format(CURRENT_DATE_FMT); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.controller; |
| | | |
| | | import com.ruoyi.ai.assistant.ManufacturingAgent; |
| | | import com.ruoyi.ai.assistant.ManufacturingIntentExecutor; |
| | | import com.ruoyi.ai.bean.ChatForm; |
| | | import com.ruoyi.ai.context.AiSessionUserContext; |
| | | import com.ruoyi.ai.service.AiChatSessionService; |
| | | import com.ruoyi.ai.store.MongoChatMemoryStore; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import dev.langchain4j.data.message.AiMessage; |
| | | import dev.langchain4j.data.message.UserMessage; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | @Tag(name = "å¶é æºè½å©æ") |
| | | @RestController |
| | | @RequestMapping("/manufacturing-ai") |
| | | public class ManufacturingAiController extends BaseController { |
| | | |
| | | private static final DateTimeFormatter CURRENT_DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai"); |
| | | |
| | | private final ManufacturingAgent manufacturingAgent; |
| | | private final ManufacturingIntentExecutor manufacturingIntentExecutor; |
| | | private final AiSessionUserContext aiSessionUserContext; |
| | | private final MongoChatMemoryStore mongoChatMemoryStore; |
| | | private final AiChatSessionService aiChatSessionService; |
| | | |
| | | public ManufacturingAiController(ManufacturingAgent manufacturingAgent, |
| | | ManufacturingIntentExecutor manufacturingIntentExecutor, |
| | | AiSessionUserContext aiSessionUserContext, |
| | | MongoChatMemoryStore mongoChatMemoryStore, |
| | | AiChatSessionService aiChatSessionService) { |
| | | this.manufacturingAgent = manufacturingAgent; |
| | | this.manufacturingIntentExecutor = manufacturingIntentExecutor; |
| | | this.aiSessionUserContext = aiSessionUserContext; |
| | | this.mongoChatMemoryStore = mongoChatMemoryStore; |
| | | this.aiChatSessionService = aiChatSessionService; |
| | | } |
| | | |
| | | @Operation(summary = "å¶é 对è¯") |
| | | @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8") |
| | | public Flux<String> chat(@RequestBody ChatForm chatForm) { |
| | | if (!StringUtils.hasText(chatForm.getMemoryId())) { |
| | | return Flux.just("memoryIdä¸è½ä¸ºç©º"); |
| | | } |
| | | if (!StringUtils.hasText(chatForm.getMessage())) { |
| | | return Flux.just("messageä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String memoryId = chatForm.getMemoryId(); |
| | | String userMessage = chatForm.getMessage(); |
| | | |
| | | aiSessionUserContext.bind(memoryId, loginUser); |
| | | aiChatSessionService.touchSession(memoryId, loginUser, userMessage); |
| | | |
| | | String directResponse = manufacturingIntentExecutor.tryExecute(memoryId, userMessage); |
| | | if (StringUtils.isNotEmpty(directResponse)) { |
| | | mongoChatMemoryStore.appendMessages( |
| | | memoryId, |
| | | List.of(UserMessage.from(userMessage), AiMessage.from(directResponse)) |
| | | ); |
| | | aiChatSessionService.refreshSessionStats(memoryId, loginUser); |
| | | return Flux.just(directResponse); |
| | | } |
| | | |
| | | return manufacturingAgent.chat(memoryId, userMessage, currentDateForPrompt()) |
| | | .doOnComplete(() -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)) |
| | | .doOnError(ex -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)); |
| | | } |
| | | |
| | | @Operation(summary = "å¶é ä¼è¯å表") |
| | | @GetMapping("/history/sessions") |
| | | public AjaxResult listSessions() { |
| | | return success(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | @Operation(summary = "å¶é ä¼è¯æ¶æ¯") |
| | | @GetMapping("/history/messages/{memoryId}") |
| | | public AjaxResult listMessages(@PathVariable String memoryId) { |
| | | return success(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | @Operation(summary = "å é¤å¶é ä¼è¯") |
| | | @DeleteMapping("/history/{memoryId}") |
| | | public AjaxResult deleteSession(@PathVariable String memoryId) { |
| | | aiSessionUserContext.remove(memoryId); |
| | | return toAjax(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | private String currentDateForPrompt() { |
| | | return LocalDate.now(CHINA_ZONE_ID).format(CURRENT_DATE_FMT); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.controller; |
| | | |
| | | import com.ruoyi.ai.assistant.SalesAgent; |
| | | import com.ruoyi.ai.assistant.SalesIntentExecutor; |
| | | import com.ruoyi.ai.bean.ChatForm; |
| | | import com.ruoyi.ai.context.AiSessionUserContext; |
| | | import com.ruoyi.ai.service.AiChatSessionService; |
| | | import com.ruoyi.ai.store.MongoChatMemoryStore; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import dev.langchain4j.data.message.AiMessage; |
| | | import dev.langchain4j.data.message.UserMessage; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import reactor.core.publisher.Flux; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | @Tag(name = "éå®å©ææºè½ä½") |
| | | @RestController |
| | | @RequestMapping("/sales-ai") |
| | | public class SalesAiController extends BaseController { |
| | | |
| | | private static final DateTimeFormatter CURRENT_DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai"); |
| | | |
| | | private final SalesAgent salesAgent; |
| | | private final SalesIntentExecutor salesIntentExecutor; |
| | | private final AiSessionUserContext aiSessionUserContext; |
| | | private final MongoChatMemoryStore mongoChatMemoryStore; |
| | | private final AiChatSessionService aiChatSessionService; |
| | | |
| | | public SalesAiController(SalesAgent salesAgent, |
| | | SalesIntentExecutor salesIntentExecutor, |
| | | AiSessionUserContext aiSessionUserContext, |
| | | MongoChatMemoryStore mongoChatMemoryStore, |
| | | AiChatSessionService aiChatSessionService) { |
| | | this.salesAgent = salesAgent; |
| | | this.salesIntentExecutor = salesIntentExecutor; |
| | | this.aiSessionUserContext = aiSessionUserContext; |
| | | this.mongoChatMemoryStore = mongoChatMemoryStore; |
| | | this.aiChatSessionService = aiChatSessionService; |
| | | } |
| | | |
| | | @Operation(summary = "éå®å©æå¯¹è¯") |
| | | @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8") |
| | | public Flux<String> chat(@RequestBody ChatForm chatForm) { |
| | | if (!StringUtils.hasText(chatForm.getMemoryId())) { |
| | | return Flux.just("memoryIdä¸è½ä¸ºç©º"); |
| | | } |
| | | if (!StringUtils.hasText(chatForm.getMessage())) { |
| | | return Flux.just("messageä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String memoryId = chatForm.getMemoryId(); |
| | | String userMessage = chatForm.getMessage(); |
| | | |
| | | aiSessionUserContext.bind(memoryId, loginUser); |
| | | aiChatSessionService.touchSession(memoryId, loginUser, userMessage); |
| | | |
| | | String directResponse = salesIntentExecutor.tryExecute(memoryId, userMessage); |
| | | if (StringUtils.isNotEmpty(directResponse)) { |
| | | mongoChatMemoryStore.appendMessages( |
| | | memoryId, |
| | | List.of(UserMessage.from(userMessage), AiMessage.from(directResponse)) |
| | | ); |
| | | aiChatSessionService.refreshSessionStats(memoryId, loginUser); |
| | | return Flux.just(directResponse); |
| | | } |
| | | |
| | | if (isBusinessDataIntent(userMessage)) { |
| | | String noGuessResponse = "æªè¯å«å°å¯æ§è¡çæ°æ®æ¥è¯¢æ¡ä»¶ã为ä¿è¯ç»æåç¡®ï¼å½åä¸ä¼æ¨æµæç¼é æ°æ®ï¼è¯·è¡¥å
æç¡®æ¶é´èå´ãå®¢æ·æåå·ååæ¥è¯¢ã"; |
| | | mongoChatMemoryStore.appendMessages( |
| | | memoryId, |
| | | List.of(UserMessage.from(userMessage), AiMessage.from(noGuessResponse)) |
| | | ); |
| | | aiChatSessionService.refreshSessionStats(memoryId, loginUser); |
| | | return Flux.just(noGuessResponse); |
| | | } |
| | | |
| | | return salesAgent.chat(memoryId, userMessage, currentDateForPrompt()) |
| | | .doOnComplete(() -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)) |
| | | .doOnError(ex -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)); |
| | | } |
| | | |
| | | @Operation(summary = "éå®å©æä¼è¯å表") |
| | | @GetMapping("/history/sessions") |
| | | public AjaxResult listSessions() { |
| | | return success(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | @Operation(summary = "éå®å©æä¼è¯æ¶æ¯") |
| | | @GetMapping("/history/messages/{memoryId}") |
| | | public AjaxResult listMessages(@PathVariable String memoryId) { |
| | | return success(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | @Operation(summary = "å é¤éå®å©æä¼è¯") |
| | | @DeleteMapping("/history/{memoryId}") |
| | | public AjaxResult deleteSession(@PathVariable String memoryId) { |
| | | aiSessionUserContext.remove(memoryId); |
| | | return toAjax(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | private boolean isBusinessDataIntent(String message) { |
| | | if (!StringUtils.hasText(message)) { |
| | | return false; |
| | | } |
| | | String text = message.trim(); |
| | | return containsAny(text, |
| | | "æ¥è¯¢", "æ¥ç", "ç»è®¡", "åæ", "建议", "å®¢æ·æ¡£æ¡", "ç§æµ·", "å
¬æµ·", |
| | | "é宿¥ä»·", "éå®å°è´¦", "éå®éè´§", "客æ·å¾æ¥", "åè´§å°è´¦", "忬¾", "æ¥ä»·", "é£é©"); |
| | | } |
| | | |
| | | private boolean containsAny(String text, String... keywords) { |
| | | for (String keyword : keywords) { |
| | | if (text.contains(keyword)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private String currentDateForPrompt() { |
| | | return LocalDate.now(CHINA_ZONE_ID).format(CURRENT_DATE_FMT); |
| | | } |
| | | } |
| | |
| | | import reactor.core.publisher.Flux; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | import java.util.NoSuchElementException; |
| | | import java.util.UUID; |
| | |
| | | public class XiaozhiController extends BaseController { |
| | | |
| | | private static final String FILE_ANALYZE_MEMORY_PREFIX = "file-analyze::"; |
| | | private static final DateTimeFormatter CURRENT_DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai"); |
| | | |
| | | private final ApproveTodoAgent approveTodoAgent; |
| | | private final ApproveTodoIntentExecutor approveTodoIntentExecutor; |
| | |
| | | return Flux.just(directResponse); |
| | | } |
| | | |
| | | return approveTodoAgent.chat(memoryId, userMessage) |
| | | if (isApproveTodoBusinessIntent(userMessage)) { |
| | | String noGuessResponse = "æªè¯å«å°å¯æ§è¡ç审æ¹å¾
åæä½æ¡ä»¶ã为ä¿è¯ç»æåç¡®ï¼å½åä¸ä¼æ¨æµæç¼é å®¡æ¹æ°æ®ï¼è¯·è¡¥å
æµç¨ç¼å·ãæ¶é´èå´ææç¡®æä½æä»¤ååè¯ã"; |
| | | mongoChatMemoryStore.appendMessages( |
| | | memoryId, |
| | | List.of(UserMessage.from(userMessage), AiMessage.from(noGuessResponse)) |
| | | ); |
| | | aiChatSessionService.refreshSessionStats(memoryId, loginUser); |
| | | return Flux.just(noGuessResponse); |
| | | } |
| | | |
| | | return approveTodoAgent.chat(memoryId, userMessage, currentDateForPrompt()) |
| | | .doOnComplete(() -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)) |
| | | .doOnError(ex -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)); |
| | | } |
| | |
| | | aiSessionUserContext.remove(memoryId); |
| | | return toAjax(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser())); |
| | | } |
| | | |
| | | private boolean isApproveTodoBusinessIntent(String message) { |
| | | if (!StringUtils.hasText(message)) { |
| | | return false; |
| | | } |
| | | String text = message.trim(); |
| | | boolean hasDomainWord = containsAny(text, |
| | | "审æ¹", "å¾
å", "æµç¨ç¼å·", "æµç¨å·", "å®¡æ¹æµè½¬", "审æ¹èç¹", "å½å审æ¹äºº", "驳å", "éè¿", "æ¤é", "å é¤"); |
| | | boolean hasIntentWord = containsAny(text, |
| | | "æ¥è¯¢", "æ¥ç", "ååº", "ç»è®¡", "åæ", "åå¸", "éè¿", "驳å", "æ¤é", "å é¤", "ä¿®æ¹", "æåªäº", "å¡å¨"); |
| | | return hasDomainWord && hasIntentWord; |
| | | } |
| | | |
| | | private boolean containsAny(String text, String... keywords) { |
| | | for (String keyword : keywords) { |
| | | if (text.contains(keyword)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private String currentDateForPrompt() { |
| | | return LocalDate.now(CHINA_ZONE_ID).format(CURRENT_DATE_FMT); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.ai.service; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.purchase.dto.PurchaseLedgerDto; |
| | | import com.ruoyi.purchase.dto.PurchaseReturnOrderDto; |
| | | import com.ruoyi.purchase.pojo.PaymentRegistration; |
| | | import com.ruoyi.purchase.service.IPaymentRegistrationService; |
| | | import com.ruoyi.purchase.service.IPurchaseLedgerService; |
| | | import com.ruoyi.purchase.service.PurchaseReturnOrdersService; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.Base64; |
| | | import java.util.Arrays; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | private static final int MAX_FILE_COUNT = 10; |
| | | private static final int MAX_SINGLE_FILE_TEXT_LENGTH = 8000; |
| | | private static final int MAX_TOTAL_FILE_TEXT_LENGTH = 30000; |
| | | private static final DateTimeFormatter CURRENT_DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai"); |
| | | |
| | | private final PurchaseAgent purchaseAgent; |
| | | private final PurchaseIntentExecutor purchaseIntentExecutor; |
| | |
| | | private final AiFileTextExtractor aiFileTextExtractor; |
| | | private final ObjectMapper objectMapper; |
| | | private final IPurchaseLedgerService purchaseLedgerService; |
| | | private final IPaymentRegistrationService paymentRegistrationService; |
| | | private final PurchaseReturnOrdersService purchaseReturnOrdersService; |
| | | private final StorageBlobService storageBlobService; |
| | | private final SupplierManageMapper supplierManageMapper; |
| | |
| | | AiFileTextExtractor aiFileTextExtractor, |
| | | ObjectMapper objectMapper, |
| | | IPurchaseLedgerService purchaseLedgerService, |
| | | IPaymentRegistrationService paymentRegistrationService, |
| | | PurchaseReturnOrdersService purchaseReturnOrdersService, |
| | | StorageBlobService storageBlobService, |
| | | SupplierManageMapper supplierManageMapper, |
| | |
| | | this.aiFileTextExtractor = aiFileTextExtractor; |
| | | this.objectMapper = objectMapper; |
| | | this.purchaseLedgerService = purchaseLedgerService; |
| | | this.paymentRegistrationService = paymentRegistrationService; |
| | | this.purchaseReturnOrdersService = purchaseReturnOrdersService; |
| | | this.storageBlobService = storageBlobService; |
| | | this.supplierManageMapper = supplierManageMapper; |
| | |
| | | return Flux.just(directResponse); |
| | | } |
| | | |
| | | return purchaseAgent.chat(memoryId, userMessage) |
| | | if (isPurchaseBusinessIntent(userMessage)) { |
| | | String noGuessResponse = buildNoGuessResponse(); |
| | | mongoChatMemoryStore.appendMessages( |
| | | memoryId, |
| | | List.of(UserMessage.from(userMessage), AiMessage.from(noGuessResponse)) |
| | | ); |
| | | aiChatSessionService.refreshSessionStats(memoryId, loginUser); |
| | | return Flux.just(noGuessResponse); |
| | | } |
| | | |
| | | return purchaseAgent.chat(memoryId, userMessage, currentDateForPrompt()) |
| | | .doOnComplete(() -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)) |
| | | .doOnError(ex -> aiChatSessionService.refreshSessionStats(memoryId, loginUser)); |
| | | } |
| | |
| | | .doOnError(ex -> aiChatSessionService.refreshSessionStats(finalMemoryId, loginUser)); |
| | | } |
| | | |
| | | return Flux.defer(() -> purchaseAgent.chat(finalMemoryId, userPrompt)) |
| | | return Flux.defer(() -> purchaseAgent.chat(finalMemoryId, userPrompt, currentDateForPrompt())) |
| | | .onErrorResume(NoSuchElementException.class, ex -> { |
| | | mongoChatMemoryStore.deleteMessages(finalMemoryId); |
| | | return purchaseAgent.chat(finalMemoryId, userPrompt); |
| | | return purchaseAgent.chat(finalMemoryId, userPrompt, currentDateForPrompt()); |
| | | }) |
| | | .doOnComplete(() -> aiChatSessionService.refreshSessionStats(finalMemoryId, loginUser)) |
| | | .doOnError(ex -> aiChatSessionService.refreshSessionStats(finalMemoryId, loginUser)); |
| | |
| | | String businessType = request.getBusinessType().trim(); |
| | | return switch (businessType) { |
| | | case "purchase_ledger" -> processPurchaseLedger(request.getPayload()); |
| | | case "payment_registration" -> processPaymentRegistration(request.getPayload()); |
| | | case "purchase_return_order" -> processPurchaseReturnOrder(request.getPayload()); |
| | | default -> AjaxResult.error("æä¸æ¯æè¯¥ä¸å¡ç±»å: " + businessType); |
| | | }; |
| | |
| | | }; |
| | | } |
| | | |
| | | private String currentDateForPrompt() { |
| | | return LocalDate.now(CHINA_ZONE_ID).format(CURRENT_DATE_FMT); |
| | | } |
| | | |
| | | private boolean isPurchaseBusinessIntent(String message) { |
| | | if (!StringUtils.hasText(message)) { |
| | | return false; |
| | | } |
| | | String text = message.trim(); |
| | | boolean hasDomainWord = containsAny(text, |
| | | "éè´", "éè´å°è´¦", "éè´å", "éè´è®¢å", "ä¾åºå", "ç©æ", "å
¥åº", "å°è´§", "å¾
仿¬¾", |
| | | "仿¬¾", "éè´§", "éæ", "å票", "åå"); |
| | | boolean hasIntentWord = containsAny(text, |
| | | "æ¥è¯¢", "æ¥ç", "ç»è®¡", "åæ", "æè¡", "æå", "ååº", "æåªäº", "æ
åµ", "æç»", "详æ
", "æ¥è¡¨"); |
| | | return hasDomainWord && hasIntentWord; |
| | | } |
| | | |
| | | private boolean containsAny(String text, String... keywords) { |
| | | for (String keyword : keywords) { |
| | | if (text.contains(keyword)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private String buildNoGuessResponse() { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("success", false); |
| | | result.put("type", "purchase_intent_not_recognized"); |
| | | result.put("description", "æªè¯å«å°å¯æ§è¡çéè´æ¥è¯¢æ¡ä»¶ã为ä¿è¯ç»æåç¡®ï¼å½åä¸ä¼æ¨æµæç¼é æ°æ®ï¼è¯·è¡¥å
æç¡®æ¶é´èå´ãä¾åºåãéè´ååå·æç©æååæ¥è¯¢ã"); |
| | | result.put("summary", Map.of()); |
| | | result.put("data", Map.of( |
| | | "quickPrompts", List.of( |
| | | "æ¬æéè´é颿åååçç©ææåªäºï¼", |
| | | "åªäºéè´è®¢åè¿æªå
¥åºï¼", |
| | | "æè¿7天ä¾åºåå°è´§å¼å¸¸æåªäºï¼", |
| | | "帮æç»è®¡å¾
仿¬¾éè´åï¼", |
| | | "ååºæ¬æéè´éè´§æ
åµ" |
| | | ) |
| | | )); |
| | | result.put("charts", Map.of()); |
| | | return JSON.toJSONString(result); |
| | | } |
| | | |
| | | private String buildPurchaseFileAnalyzePrompt(String message, String fileContent) { |
| | | return """ |
| | | ä½ æ¯éè´ä¸å¡æä»¶åæå©æãè¯·ä¸¥æ ¼æ ¹æ®ç¨æ·ä¸ä¼ çå¤ä¸ªæä»¶åç¨æ·è¦æ±æåéè´ä¸å¡æ°æ®ã |
| | |
| | | 1. åªè¾åºåæ³ JSONï¼ä¸è¦ Markdownï¼ä¸è¦é¢å¤è§£éã |
| | | 2. JSON é¡¶å±å段åºå®ä¸º: |
| | | - success: boolean |
| | | - businessType: purchase_ledger | payment_registration | purchase_return_order | unknown |
| | | - businessType: purchase_ledger | purchase_return_order | unknown |
| | | - action: confirm_required |
| | | - description: ä¸æè¯´æ |
| | | - confidence: 0å°1çå°æ° |
| | |
| | | entryDateStart, entryDateEnd, id, purchaseContractNumber, supplierId, supplierName, isWhite, recorderId, recorderName, salesContractNo, salesContractNoId, projectName, entryDate, executionDate, remarks, attachmentMaterials, createdAt, updatedAt, salesLedgerId, hasChildren, Type, productData, tempFileIds, SalesLedgerFiles, phoneNumber, businessPersonId, productId, productModelId, invoiceNumber, invoiceAmount, ticketRegistrationId, contractAmount, receiptPaymentAmount, unReceiptPaymentAmount, type, paymentMethod, approvalStatus, templateName |
| | | - productData æ¯æ¡äº§ååªä½¿ç¨è¿äº SalesLedgerProduct åæ®µå: |
| | | productCategory, specificationModel, unit, quantity, taxRate, taxInclusiveUnitPrice, taxInclusiveTotalPrice, taxExclusiveTotalPrice, invoiceType, productId, productModelId, isChecked, type |
| | | 4. 妿å¯å¤æä¸ºä»æ¬¾ç»è®°ï¼businessType ä½¿ç¨ payment_registrationï¼payload.records ä¸ºä»æ¬¾ç»è®°æ°ç»ï¼å段尽éå
å« purchaseLedgerIdãsalesLedgerProductIdãcurrentPaymentAmountãpaymentMethodãpaymentDateã |
| | | 4. 妿å¯å¤æä¸ºä»æ¬¾ç»è®°ï¼businessType ä½¿ç¨ payload.records ä¸ºä»æ¬¾ç»è®°æ°ç»ï¼å段尽éå
å« purchaseLedgerIdãsalesLedgerProductIdãcurrentPaymentAmountãpaymentMethodãpaymentDateã |
| | | 5. 妿å¯å¤æä¸ºéè´éè´§ï¼businessType ä½¿ç¨ purchase_return_orderï¼payload æ PurchaseReturnOrderDto ç»ç»ï¼æç»æ¾ purchaseReturnOrderProductsDtosã |
| | | 6. 缺å°ä¸å¡å¤çå¿
须忮µæ¶ï¼ä¸è¦ç¼é IDï¼æåæ®µæ¾å
¥ missingFieldsï¼å¹¶ä»è¿åå¯ç¡®è®¤çèç¨¿æ°æ®ã |
| | | 7. ææä¸æå
å®¹ç´æ¥ä¿çï¼ä¸è¦è½¬ä¹æ Unicodeã |
| | |
| | | } |
| | | dto.setSupplierId(supplier.getId()); |
| | | return null; |
| | | } |
| | | |
| | | private AjaxResult processPaymentRegistration(Map<String, Object> payload) { |
| | | Object recordsValue = payload.get("records"); |
| | | List<PaymentRegistration> records; |
| | | if (recordsValue == null) { |
| | | records = Collections.singletonList(objectMapper.convertValue(payload, PaymentRegistration.class)); |
| | | } else { |
| | | records = objectMapper.convertValue(recordsValue, new TypeReference<List<PaymentRegistration>>() { |
| | | }); |
| | | } |
| | | int result = paymentRegistrationService.insertPaymentRegistration(records); |
| | | return AjaxResult.success("仿¬¾ç»è®°å·²å¤ç", result); |
| | | } |
| | | |
| | | private AjaxResult processPurchaseReturnOrder(Map<String, Object> payload) { |
| | |
| | | @P(value = "审æ¹ç±»åç¼å·ï¼å¯ä¸ä¼ ", required = false) Integer approveType, |
| | | @P(value = "å
³é®åï¼å¯å¹é
æµç¨ç¼å·ãæ é¢ãç³è¯·äººãå½å审æ¹äºº", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§20", required = false) Integer limit, |
| | | @P(value = "æ¥è¯¢èå´ï¼å¯éå¼ï¼relatedãapplicantãapproverï¼related 表示å½åç¨æ·ç¸å
³ï¼applicant 表示æåèµ·çï¼approver 表示å¾
æå¤çç", required = false) String scope) { |
| | | @P(value = "æ¥è¯¢èå´ï¼å¯éå¼ï¼relatedãapplicantãapproverï¼related 表示å½åç¨æ·ç¸å
³ï¼applicant 表示æåèµ·çï¼approver 表示å¾
æå¤çç", required = false) String scope, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼ä¾å¦ ä»å¤©ãæ¬æãè¿30天ï¼å¯ä¸ä¼ ", required = false) String timeRange) { |
| | | |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | Long userId = loginUser.getUserId(); |
| | | Integer statusCode = parseStatus(status); |
| | | String normalizedScope = normalizeScope(scope); |
| | | boolean hasDateFilter = StringUtils.hasText(startDate) || StringUtils.hasText(endDate) || StringUtils.hasText(timeRange); |
| | | DateRange dateRange = hasDateFilter ? resolveDateRange(startDate, endDate, timeRange) : null; |
| | | |
| | | LambdaQueryWrapper<ApproveProcess> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ApproveProcess::getApproveDelete, 0); |
| | |
| | | } |
| | | } |
| | | |
| | | if (dateRange != null) { |
| | | wrapper.ge(ApproveProcess::getCreateTime, dateRange.start().atStartOfDay()) |
| | | .lt(ApproveProcess::getCreateTime, dateRange.end().plusDays(1).atStartOfDay()); |
| | | } |
| | | |
| | | wrapper.orderByDesc(ApproveProcess::getCreateTime) |
| | | .last("limit " + normalizeLimit(limit)); |
| | | |
| | |
| | | "statusFilter", StringUtils.hasText(status) ? status : "all", |
| | | "approveType", approveType == null ? "" : approveType, |
| | | "keyword", keyword == null ? "" : keyword, |
| | | "scope", normalizedScope |
| | | "scope", normalizedScope, |
| | | "timeRange", dateRange == null ? "all" : dateRange.label(), |
| | | "startDate", dateRange == null ? "" : dateRange.start().toString(), |
| | | "endDate", dateRange == null ? "" : dateRange.end().toString() |
| | | ), |
| | | Map.of("columns", todoColumns(), "items", items), |
| | | Map.of()); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.tools; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| | | import com.ruoyi.account.mapper.AccountStatementMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.AccountStatement; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.account.service.impl.AccountingServiceImpl; |
| | | import com.ruoyi.ai.context.AiSessionUserContext; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.mapper.SupplierManageMapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import com.ruoyi.production.mapper.ProductionAccountMapper; |
| | | import com.ruoyi.production.mapper.ProductionOperationTaskMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionPlanMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductOutputMapper; |
| | | import com.ruoyi.production.pojo.ProductionAccount; |
| | | import com.ruoyi.production.pojo.ProductionOperationTask; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | | import com.ruoyi.production.pojo.ProductionPlan; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.production.pojo.ProductionProductOutput; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import com.ruoyi.technology.mapper.TechnologyOperationMapper; |
| | | import com.ruoyi.technology.pojo.TechnologyOperation; |
| | | import dev.langchain4j.agent.tool.P; |
| | | import dev.langchain4j.agent.tool.Tool; |
| | | import dev.langchain4j.agent.tool.ToolMemoryId; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.YearMonth; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | public class FinancialAgentTools { |
| | | |
| | | private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final Pattern RELATIVE_PATTERN = Pattern.compile("(è¿|æè¿)?\\s*(\\d+)\\s*(天|å¨|个æ|æ|å¹´)"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})"); |
| | | private static final BigDecimal ONE_HUNDRED = new BigDecimal("100"); |
| | | private static final int DEFAULT_LIMIT = 10; |
| | | private static final int MAX_LIMIT = 50; |
| | | private static final BigDecimal DEFAULT_FALLBACK_MATERIAL_COST_RATE = new BigDecimal("0.65"); |
| | | |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final ProductionAccountMapper productionAccountMapper; |
| | | private final ProductionProductMainMapper productionProductMainMapper; |
| | | private final ProductionOperationTaskMapper productionOperationTaskMapper; |
| | | private final ProductionOrderMapper productionOrderMapper; |
| | | private final ProductionPlanMapper productionPlanMapper; |
| | | private final ProductionProductOutputMapper productionProductOutputMapper; |
| | | private final TechnologyOperationMapper technologyOperationMapper; |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | private final DeviceRepairMapper deviceRepairMapper; |
| | | private final ProcurementRecordMapper procurementRecordMapper; |
| | | private final ProcurementRecordOutMapper procurementRecordOutMapper; |
| | | private final StockInventoryMapper stockInventoryMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final AccountStatementMapper accountStatementMapper; |
| | | private final CustomerMapper customerMapper; |
| | | private final SupplierManageMapper supplierManageMapper; |
| | | private final ProductModelMapper productModelMapper; |
| | | private final ProductMapper productMapper; |
| | | private final AiSessionUserContext aiSessionUserContext; |
| | | |
| | | public FinancialAgentTools(SalesLedgerMapper salesLedgerMapper, |
| | | SalesLedgerProductMapper salesLedgerProductMapper, |
| | | ProductionAccountMapper productionAccountMapper, |
| | | ProductionProductMainMapper productionProductMainMapper, |
| | | ProductionOperationTaskMapper productionOperationTaskMapper, |
| | | ProductionOrderMapper productionOrderMapper, |
| | | ProductionPlanMapper productionPlanMapper, |
| | | ProductionProductOutputMapper productionProductOutputMapper, |
| | | TechnologyOperationMapper technologyOperationMapper, |
| | | DeviceLedgerMapper deviceLedgerMapper, |
| | | DeviceRepairMapper deviceRepairMapper, |
| | | ProcurementRecordMapper procurementRecordMapper, |
| | | ProcurementRecordOutMapper procurementRecordOutMapper, |
| | | StockInventoryMapper stockInventoryMapper, |
| | | AccountSalesCollectionMapper accountSalesCollectionMapper, |
| | | AccountPurchasePaymentMapper accountPurchasePaymentMapper, |
| | | AccountStatementMapper accountStatementMapper, |
| | | CustomerMapper customerMapper, |
| | | SupplierManageMapper supplierManageMapper, |
| | | ProductModelMapper productModelMapper, |
| | | ProductMapper productMapper, |
| | | AiSessionUserContext aiSessionUserContext) { |
| | | this.salesLedgerMapper = salesLedgerMapper; |
| | | this.salesLedgerProductMapper = salesLedgerProductMapper; |
| | | this.productionAccountMapper = productionAccountMapper; |
| | | this.productionProductMainMapper = productionProductMainMapper; |
| | | this.productionOperationTaskMapper = productionOperationTaskMapper; |
| | | this.productionOrderMapper = productionOrderMapper; |
| | | this.productionPlanMapper = productionPlanMapper; |
| | | this.productionProductOutputMapper = productionProductOutputMapper; |
| | | this.technologyOperationMapper = technologyOperationMapper; |
| | | this.deviceLedgerMapper = deviceLedgerMapper; |
| | | this.deviceRepairMapper = deviceRepairMapper; |
| | | this.procurementRecordMapper = procurementRecordMapper; |
| | | this.procurementRecordOutMapper = procurementRecordOutMapper; |
| | | this.stockInventoryMapper = stockInventoryMapper; |
| | | this.accountSalesCollectionMapper = accountSalesCollectionMapper; |
| | | this.accountPurchasePaymentMapper = accountPurchasePaymentMapper; |
| | | this.accountStatementMapper = accountStatementMapper; |
| | | this.customerMapper = customerMapper; |
| | | this.supplierManageMapper = supplierManageMapper; |
| | | this.productModelMapper = productModelMapper; |
| | | this.productMapper = productMapper; |
| | | this.aiSessionUserContext = aiSessionUserContext; |
| | | } |
| | | |
| | | @Tool(name = "è´¢å¡ç¥è¯æ£ç´¢", value = "æè´¢å¡ç»è¥é®é¢æ£ç´¢ä¸è´¢èåç¥è¯çæ®µä¸ææ å£å¾ï¼ä½ä¸ºRAGä¸ä¸æã") |
| | | public String retrieveFinancialKnowledge(@ToolMemoryId String memoryId, |
| | | @P(value = "é®é¢æå
³é®è¯ï¼ä¾å¦å©æ¶¦ä¸éãåºåå¨è½¬ãèµé缺å£") String question) { |
| | | List<KnowledgeDoc> knowledgeDocs = financeKnowledgeBase(); |
| | | String normalized = normalizeForMatch(question); |
| | | List<KnowledgeDoc> ranked = knowledgeDocs.stream() |
| | | .sorted(Comparator.comparingInt((KnowledgeDoc doc) -> keywordHitCount(doc.keywords(), normalized)).reversed()) |
| | | .filter(doc -> keywordHitCount(doc.keywords(), normalized) > 0 || !StringUtils.hasText(normalized)) |
| | | .limit(5) |
| | | .toList(); |
| | | |
| | | List<Map<String, Object>> items = ranked.stream().map(doc -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("topic", doc.topic()); |
| | | map.put("knowledge", doc.knowledge()); |
| | | map.put("relatedTables", doc.relatedTables()); |
| | | map.put("suggestedQuestions", doc.suggestedQuestions()); |
| | | return map; |
| | | }).toList(); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("question", safe(question)); |
| | | summary.put("hitCount", items.size()); |
| | | summary.put("retrievalMode", "keyword_rag"); |
| | | return jsonResponse(true, "financial_rag_knowledge", "å·²è¿åè´¢å¡ç¥è¯æ£ç´¢ç»æ", summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æºè½ææ¬æ ¸ç®", value = "èªå¨æ ¸ç®äº§åææ¬ãå·¥åºææ¬ãäººå·¥ææ¬ãè®¾å¤ææ§ãæææèä¸è®¢å婿¶¦ã") |
| | | public String calculateIntelligentCost(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦æ¬æãè¿30天", required = false) String timeRange, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
ååå·/客æ·/项ç®", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§50", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange, "è¿30天"); |
| | | AnalysisBundle bundle = buildOrderProfitBundle(loginUser, range, keyword, limit); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("orderCount", bundle.orderMetrics().size()); |
| | | summary.put("totalRevenue", bundle.totalRevenue()); |
| | | summary.put("totalMaterialCost", bundle.totalMaterialCost()); |
| | | summary.put("totalLaborCost", bundle.totalLaborCost()); |
| | | summary.put("totalDepreciationCost", bundle.totalDepreciationCost()); |
| | | summary.put("totalScrapCost", bundle.totalScrapCost()); |
| | | summary.put("totalCost", bundle.totalCost()); |
| | | summary.put("totalProfit", bundle.totalProfit()); |
| | | summary.put("profitRate", toPercent(rate(bundle.totalProfit(), bundle.totalRevenue()))); |
| | | |
| | | List<Map<String, Object>> orderItems = bundle.orderMetrics().stream() |
| | | .map(this::toOrderCostItem) |
| | | .toList(); |
| | | List<Map<String, Object>> processItems = bundle.processCostRanking().entrySet().stream() |
| | | .map(entry -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("processName", entry.getKey()); |
| | | map.put("cost", entry.getValue()); |
| | | return map; |
| | | }).toList(); |
| | | |
| | | List<Map<String, Object>> topCustomerItems = buildCustomerProfitTop(bundle.orderMetrics(), 5); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("costCompositionPieOption", |
| | | buildCostCompositionPie(bundle.totalMaterialCost(), bundle.totalLaborCost(), bundle.totalDepreciationCost(), bundle.totalScrapCost())); |
| | | charts.put("orderProfitBarOption", buildOrderProfitBar(bundle.orderMetrics())); |
| | | charts.put("processCostBarOption", buildProcessCostBar(bundle.processCostRanking())); |
| | | |
| | | return jsonResponse(true, "financial_cost_accounting", "已宿æºè½ææ¬æ ¸ç®", summary, |
| | | Map.of( |
| | | "orders", orderItems, |
| | | "processCostRanking", processItems, |
| | | "topCustomers", topCustomerItems |
| | | ), |
| | | charts |
| | | ); |
| | | } |
| | | |
| | | @Tool(name = "订å婿¶¦åæ", value = "è¯å«ä½å©æ¶¦/äºæè®¢åï¼è¾åºåå åæåä¼å建议ã") |
| | | public String analyzeOrderProfit(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦æ¬æãè¿30天", required = false) String timeRange, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
ååå·/客æ·/项ç®", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§50", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange, "è¿30天"); |
| | | AnalysisBundle bundle = buildOrderProfitBundle(loginUser, range, keyword, limit); |
| | | List<OrderProfitMetric> metrics = bundle.orderMetrics(); |
| | | |
| | | List<OrderProfitMetric> riskyOrders = metrics.stream() |
| | | .filter(item -> item.profit().compareTo(BigDecimal.ZERO) < 0 || item.profitRate().compareTo(new BigDecimal("0.08")) < 0) |
| | | .sorted(Comparator.comparing(OrderProfitMetric::profitRate) |
| | | .thenComparing(OrderProfitMetric::profit)) |
| | | .toList(); |
| | | |
| | | Map<String, BigDecimal> customerProfitMap = new LinkedHashMap<>(); |
| | | for (OrderProfitMetric metric : metrics) { |
| | | customerProfitMap.merge(metric.customerName(), metric.profit(), BigDecimal::add); |
| | | } |
| | | Map.Entry<String, BigDecimal> topCustomer = customerProfitMap.entrySet().stream() |
| | | .max(Map.Entry.comparingByValue()) |
| | | .orElse(Map.entry("ææ æ°æ®", BigDecimal.ZERO)); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("orderCount", metrics.size()); |
| | | summary.put("lossOrderCount", metrics.stream().filter(item -> item.profit().compareTo(BigDecimal.ZERO) < 0).count()); |
| | | summary.put("lowProfitOrderCount", riskyOrders.size()); |
| | | summary.put("avgProfitRate", toPercent(avgRate(metrics))); |
| | | summary.put("topCustomerByProfit", topCustomer.getKey()); |
| | | summary.put("topCustomerProfit", topCustomer.getValue()); |
| | | |
| | | List<Map<String, Object>> riskyItems = riskyOrders.stream() |
| | | .limit(normalizeLimit(limit)) |
| | | .map(this::toRiskOrderItem) |
| | | .toList(); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("profitDistributionOption", buildProfitDistributionBar(metrics)); |
| | | charts.put("lossOrderTrendOption", buildLossOrderTrendLine(metrics)); |
| | | charts.put("customerProfitTopOption", buildCustomerProfitBar(customerProfitMap)); |
| | | |
| | | return jsonResponse(true, "financial_order_profit_analysis", "å·²å®æè®¢å婿¶¦åæ", summary, |
| | | Map.of( |
| | | "riskOrders", riskyItems, |
| | | "allOrders", metrics.stream().map(this::toOrderCostItem).toList(), |
| | | "customerProfitTop", buildCustomerProfitTop(metrics, 10) |
| | | ), |
| | | charts |
| | | ); |
| | | } |
| | | |
| | | @Tool(name = "åºåèµéåæ", value = "åæåºå积åãåæ»åºåãèµéå ç¨ä¸å¨è½¬çã") |
| | | public String analyzeInventoryCapital(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦æ¬æãè¿30天", required = false) String timeRange, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
产ååç§°/åå·", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§50", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange, "è¿30天"); |
| | | int finalLimit = normalizeLimit(limit); |
| | | |
| | | List<StockInventory> inventoryRows = queryStockInventory(loginUser); |
| | | if (inventoryRows.isEmpty()) { |
| | | return jsonResponse(true, "financial_inventory_capital_analysis", "å½åæ åºåæ°æ®", |
| | | rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of()); |
| | | } |
| | | |
| | | Set<Long> modelIds = inventoryRows.stream() |
| | | .map(StockInventory::getProductModelId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Long, ProductModel> productModelMap = queryProductModels(modelIds); |
| | | Map<Long, Product> productMap = queryProducts(productModelMap.values()); |
| | | Map<Long, BigDecimal> avgUnitCostByModelId = queryAverageUnitCostByModel(loginUser, modelIds); |
| | | OutboundStats outboundStats = queryOutboundStats(loginUser, modelIds, range); |
| | | |
| | | List<InventoryMetric> metrics = buildInventoryMetrics(inventoryRows, productModelMap, productMap, avgUnitCostByModelId, outboundStats) |
| | | .stream() |
| | | .filter(metric -> matchInventoryKeyword(metric, keyword)) |
| | | .sorted(Comparator.comparing(InventoryMetric::inventoryValue).reversed()) |
| | | .toList(); |
| | | |
| | | BigDecimal totalInventoryValue = metrics.stream().map(InventoryMetric::inventoryValue).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal stagnantValue = metrics.stream() |
| | | .filter(metric -> metric.stagnantDays() >= 90) |
| | | .map(InventoryMetric::inventoryValue) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | long stagnantCount = metrics.stream().filter(metric -> metric.stagnantDays() >= 90).count(); |
| | | long overstockCount = metrics.stream().filter(InventoryMetric::overstock).count(); |
| | | BigDecimal totalOutboundCost = outboundStats.totalOutboundCost(); |
| | | BigDecimal turnoverDays = totalOutboundCost.compareTo(BigDecimal.ZERO) > 0 |
| | | ? totalInventoryValue.multiply(BigDecimal.valueOf(daysBetween(range.start(), range.end()) + 1L)) |
| | | .divide(totalOutboundCost, 2, RoundingMode.HALF_UP) |
| | | : BigDecimal.ZERO; |
| | | |
| | | List<Map<String, Object>> items = metrics.stream() |
| | | .limit(finalLimit) |
| | | .map(this::toInventoryItem) |
| | | .toList(); |
| | | |
| | | Map<String, Object> summary = rangeSummary(range, metrics.size(), keyword); |
| | | summary.put("totalInventoryValue", totalInventoryValue); |
| | | summary.put("stagnantValue", stagnantValue); |
| | | summary.put("stagnantCount", stagnantCount); |
| | | summary.put("overstockCount", overstockCount); |
| | | summary.put("turnoverDays", turnoverDays); |
| | | summary.put("capitalOccupation", totalInventoryValue); |
| | | summary.put("totalOutboundCost", totalOutboundCost); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("inventoryValueTopOption", buildInventoryTopBar(metrics)); |
| | | charts.put("inventoryAgingPieOption", buildInventoryAgingPie(metrics)); |
| | | charts.put("inventoryTurnoverGauge", buildTurnoverGauge(turnoverDays)); |
| | | |
| | | return jsonResponse(true, "financial_inventory_capital_analysis", "已宿åºåèµéåæ", summary, Map.of("items", items), charts); |
| | | } |
| | | |
| | | @Tool(name = "åºæ¶åºä»ä¸ç°éæµé¢æµ", value = "颿µæªæ¥ç°éæµã忬¾é£é©ã仿¬¾ååä¸èµé缺å£ã") |
| | | public String forecastCashFlow(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦è¿90å¤©ãæ¬å¹´", required = false) String timeRange, |
| | | @P(value = "颿µæä»½æ°ï¼é»è®¤3ï¼æå¤§6", required = false) Integer forecastMonths) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange, "è¿90天"); |
| | | int months = forecastMonths == null || forecastMonths <= 0 ? 3 : Math.min(forecastMonths, 6); |
| | | |
| | | List<AccountSalesCollection> collections = queryCollections(loginUser, range); |
| | | List<AccountPurchasePayment> payments = queryPayments(loginUser, range); |
| | | List<MonthlyCashFlow> monthlyActual = buildMonthlyCashFlow(range, collections, payments); |
| | | List<MonthlyCashFlow> monthlyForecast = forecastMonthlyCashFlow(monthlyActual, months); |
| | | |
| | | StatementSnapshot snapshot = buildStatementSnapshot(loginUser); |
| | | BigDecimal receivableTotal = snapshot.receivableTotal(); |
| | | BigDecimal payableTotal = snapshot.payableTotal(); |
| | | BigDecimal forecastNetSum = monthlyForecast.stream().map(MonthlyCashFlow::netFlow).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal coverage = receivableTotal.add(maxZero(forecastNetSum)); |
| | | BigDecimal fundGap = maxZero(payableTotal.subtract(coverage)); |
| | | |
| | | Map<String, String> customerNameMap = queryCustomerNameMap(snapshot.receivableTop().stream().map(StatementMetric::entityId).collect(Collectors.toSet())); |
| | | Map<String, String> supplierNameMap = querySupplierNameMap(snapshot.payableTop().stream().map(StatementMetric::entityId).collect(Collectors.toSet())); |
| | | |
| | | List<Map<String, Object>> receivableRiskItems = snapshot.receivableTop().stream().map(item -> toStatementRiskItem(item, customerNameMap, "customer")).toList(); |
| | | List<Map<String, Object>> payablePressureItems = snapshot.payableTop().stream().map(item -> toStatementRiskItem(item, supplierNameMap, "supplier")).toList(); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("actualIncomeTotal", collections.stream().map(AccountSalesCollection::getCollectionAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | summary.put("actualExpenseTotal", payments.stream().map(AccountPurchasePayment::getPaymentAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | summary.put("receivableBalance", receivableTotal); |
| | | summary.put("payableBalance", payableTotal); |
| | | summary.put("forecastNetSum", forecastNetSum); |
| | | summary.put("fundGap", fundGap); |
| | | summary.put("forecastMonths", months); |
| | | summary.put("collectionRiskLevel", riskLevelByAmount(receivableTotal)); |
| | | summary.put("paymentPressureLevel", riskLevelByAmount(payableTotal)); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("cashFlowTrendOption", buildCashflowTrend(monthlyActual, monthlyForecast)); |
| | | charts.put("receivablePayableBarOption", buildReceivablePayableBar(receivableTotal, payableTotal)); |
| | | charts.put("fundGapGaugeOption", buildFundGapGauge(fundGap)); |
| | | |
| | | return jsonResponse(true, "financial_cashflow_forecast", "å·²å®æåºæ¶åºä»ä¸ç°éæµé¢æµ", summary, |
| | | Map.of( |
| | | "actualMonthly", monthlyActual.stream().map(this::toMonthlyCashFlowItem).toList(), |
| | | "forecastMonthly", monthlyForecast.stream().map(this::toMonthlyCashFlowItem).toList(), |
| | | "receivableRiskTop", receivableRiskItems, |
| | | "payablePressureTop", payablePressureItems |
| | | ), |
| | | charts |
| | | ); |
| | | } |
| | | |
| | | @Tool(name = "ç»è¥å¼å¸¸é¢è¦", value = "è¯å«ææ¬å¼å¸¸ã婿¶¦å¼å¸¸ã忬¾å¼å¸¸ã订åé£é©ãåºåå¼å¸¸ã") |
| | | public String detectBusinessAnomalies(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦è¿30天", required = false) String timeRange, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§50", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange, "è¿30天"); |
| | | int finalLimit = normalizeLimit(limit); |
| | | |
| | | AnalysisBundle currentBundle = buildOrderProfitBundle(loginUser, range, null, Math.max(finalLimit, 30)); |
| | | DateRange prevRange = previousSameLengthRange(range); |
| | | AnalysisBundle prevBundle = buildOrderProfitBundle(loginUser, prevRange, null, 50); |
| | | |
| | | BigDecimal currentCostRate = rate(currentBundle.totalCost(), currentBundle.totalRevenue()); |
| | | BigDecimal prevCostRate = rate(prevBundle.totalCost(), prevBundle.totalRevenue()); |
| | | BigDecimal costRateDiff = currentCostRate.subtract(prevCostRate); |
| | | |
| | | StatementSnapshot snapshot = buildStatementSnapshot(loginUser); |
| | | List<InventoryMetric> inventoryMetrics = buildInventoryMetrics( |
| | | queryStockInventory(loginUser), |
| | | queryProductModels(Collections.emptySet()), |
| | | Map.of(), |
| | | queryAverageUnitCostByModel(loginUser, Collections.emptySet()), |
| | | queryOutboundStats(loginUser, Collections.emptySet(), range) |
| | | ); |
| | | |
| | | List<Map<String, Object>> anomalyItems = new ArrayList<>(); |
| | | if (costRateDiff.compareTo(new BigDecimal("0.10")) > 0) { |
| | | anomalyItems.add(anomalyItem("high", "ææ¬å¼å¸¸", "å使¶å
¥ææ¬çè¾ä¸å¨æä¸åè¶
è¿10%", Map.of( |
| | | "currentCostRate", toPercent(currentCostRate), |
| | | "previousCostRate", toPercent(prevCostRate), |
| | | "delta", toPercent(costRateDiff) |
| | | ))); |
| | | } |
| | | long lossCount = currentBundle.orderMetrics().stream().filter(item -> item.profit().compareTo(BigDecimal.ZERO) < 0).count(); |
| | | if (lossCount > 0) { |
| | | anomalyItems.add(anomalyItem("high", "婿¶¦å¼å¸¸", "æ£æµå°äºæè®¢å", Map.of("lossOrderCount", lossCount))); |
| | | } |
| | | if (snapshot.receivableTotal().compareTo(snapshot.payableTotal().multiply(new BigDecimal("1.2"))) > 0) { |
| | | anomalyItems.add(anomalyItem("medium", "忬¾å¼å¸¸", "åºæ¶ä½é¢æ¾èé«äºåºä»ï¼å款ååå大", Map.of( |
| | | "receivableBalance", snapshot.receivableTotal(), |
| | | "payableBalance", snapshot.payableTotal() |
| | | ))); |
| | | } |
| | | long overdueOrderCount = currentBundle.orderMetrics().stream() |
| | | .filter(item -> item.deliveryDate() != null && item.deliveryDate().isBefore(LocalDate.now()) && item.profitRate().compareTo(new BigDecimal("0.10")) < 0) |
| | | .count(); |
| | | if (overdueOrderCount > 0) { |
| | | anomalyItems.add(anomalyItem("medium", "订åé£é©", "åå¨ä½å©æ¶¦ä¸äº¤ä»å·²é¾æè®¢å", Map.of("overdueRiskOrderCount", overdueOrderCount))); |
| | | } |
| | | long stagnantCount = inventoryMetrics.stream().filter(item -> item.stagnantDays() >= 90).count(); |
| | | if (stagnantCount > 0) { |
| | | anomalyItems.add(anomalyItem("medium", "åºåå¼å¸¸", "åå¨è¶
è¿90天æªå¨è½¬åºå", Map.of("stagnantCount", stagnantCount))); |
| | | } |
| | | |
| | | List<Map<String, Object>> topAnomalies = anomalyItems.stream().limit(finalLimit).toList(); |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("anomalyCount", topAnomalies.size()); |
| | | summary.put("highRiskCount", topAnomalies.stream().filter(item -> "high".equals(item.get("riskLevel"))).count()); |
| | | summary.put("mediumRiskCount", topAnomalies.stream().filter(item -> "medium".equals(item.get("riskLevel"))).count()); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("anomalyLevelPieOption", buildAnomalyLevelPie(topAnomalies)); |
| | | charts.put("anomalyTypeBarOption", buildAnomalyTypeBar(topAnomalies)); |
| | | return jsonResponse(true, "financial_business_anomaly_warning", "已宿ç»è¥å¼å¸¸é¢è¦åæ", summary, |
| | | Map.of("items", topAnomalies), charts); |
| | | } |
| | | |
| | | @Tool(name = "AIç»è¥é©¾é©¶è±", value = "宿¶å±ç¤ºäº§å¼ã婿¶¦ãåºåã忬¾ã设å¤å©ç¨çã订å婿¶¦ççæ ¸å¿ç»è¥ææ ã") |
| | | public String getBusinessCockpit(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦æ¬æãè¿30天", required = false) String timeRange) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange, "æ¬æ"); |
| | | |
| | | AnalysisBundle profitBundle = buildOrderProfitBundle(loginUser, range, null, 30); |
| | | StatementSnapshot snapshot = buildStatementSnapshot(loginUser); |
| | | List<StockInventory> inventories = queryStockInventory(loginUser); |
| | | BigDecimal inventoryValue = estimateInventoryValue(loginUser, inventories); |
| | | |
| | | long deviceTotal = countDevices(loginUser); |
| | | long repairingCount = countRepairingDevices(loginUser); |
| | | BigDecimal deviceUtilization = deviceTotal > 0 |
| | | ? new BigDecimal(deviceTotal - repairingCount).multiply(ONE_HUNDRED).divide(new BigDecimal(deviceTotal), 2, RoundingMode.HALF_UP) |
| | | : BigDecimal.ZERO; |
| | | |
| | | BigDecimal outputValue = profitBundle.totalRevenue(); |
| | | BigDecimal profitRate = rate(profitBundle.totalProfit(), profitBundle.totalRevenue()); |
| | | BigDecimal collectionRate = snapshot.receivableTotal().compareTo(BigDecimal.ZERO) > 0 |
| | | ? ONE_HUNDRED.subtract(rate(snapshot.receivableTotal(), snapshot.receivableTotal().add(snapshot.payableTotal())).multiply(ONE_HUNDRED)) |
| | | : BigDecimal.ZERO; |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("outputValue", outputValue); |
| | | summary.put("profit", profitBundle.totalProfit()); |
| | | summary.put("profitRate", toPercent(profitRate)); |
| | | summary.put("inventoryValue", inventoryValue); |
| | | summary.put("receivableBalance", snapshot.receivableTotal()); |
| | | summary.put("payableBalance", snapshot.payableTotal()); |
| | | summary.put("collectionRate", toPercent(collectionRate.divide(ONE_HUNDRED, 4, RoundingMode.HALF_UP))); |
| | | summary.put("deviceUtilizationRate", deviceUtilization + "%"); |
| | | summary.put("orderProfitRate", toPercent(avgRate(profitBundle.orderMetrics()))); |
| | | |
| | | Map<String, Object> indicators = new LinkedHashMap<>(); |
| | | indicators.put("产å¼", outputValue); |
| | | indicators.put("婿¶¦", profitBundle.totalProfit()); |
| | | indicators.put("åºåèµéå ç¨", inventoryValue); |
| | | indicators.put("åºæ¶ä½é¢", snapshot.receivableTotal()); |
| | | indicators.put("设å¤å©ç¨ç", deviceUtilization + "%"); |
| | | indicators.put("订åå¹³å婿¶¦ç", toPercent(avgRate(profitBundle.orderMetrics()))); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("kpiCardData", indicators); |
| | | charts.put("profitTrendOption", buildOrderProfitBar(profitBundle.orderMetrics())); |
| | | charts.put("receivablePayableBarOption", buildReceivablePayableBar(snapshot.receivableTotal(), snapshot.payableTotal())); |
| | | charts.put("inventoryProfitGaugeOption", buildInventoryProfitGauge(inventoryValue, profitBundle.totalProfit())); |
| | | |
| | | return jsonResponse(true, "financial_business_cockpit", "å·²çæAIç»è¥é©¾é©¶è±æ°æ®", summary, |
| | | Map.of( |
| | | "orderProfitTop", profitBundle.orderMetrics().stream() |
| | | .sorted(Comparator.comparing(OrderProfitMetric::profit).reversed()) |
| | | .limit(10) |
| | | .map(this::toOrderCostItem) |
| | | .toList(), |
| | | "indicators", indicators |
| | | ), |
| | | charts |
| | | ); |
| | | } |
| | | |
| | | @Tool(name = "æ¥æ¥å¨æ¥èªå¨çæ", value = "èªå¨è¾åºç»è¥åææ¥æ¥/卿¥ä¸é£é©å»ºè®®ã") |
| | | public String generateOperationReport(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦ä»å¤©ãæ¬å¨", required = false) String timeRange, |
| | | @P(value = "æ¥åç±»å daily/weekly", required = false) String reportType) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange, |
| | | "weekly".equalsIgnoreCase(reportType) ? "æ¬å¨" : "ä»å¤©"); |
| | | String type = "weekly".equalsIgnoreCase(reportType) ? "weekly" : "daily"; |
| | | |
| | | AnalysisBundle bundle = buildOrderProfitBundle(loginUser, range, null, 30); |
| | | StatementSnapshot snapshot = buildStatementSnapshot(loginUser); |
| | | BigDecimal inventoryValue = estimateInventoryValue(loginUser, queryStockInventory(loginUser)); |
| | | long lossCount = bundle.orderMetrics().stream().filter(item -> item.profit().compareTo(BigDecimal.ZERO) < 0).count(); |
| | | |
| | | List<String> conclusions = new ArrayList<>(); |
| | | conclusions.add("è¥æ¶" + bundle.totalRevenue() + "ï¼å©æ¶¦" + bundle.totalProfit() + "ï¼å©æ¶¦ç" + toPercent(rate(bundle.totalProfit(), bundle.totalRevenue())) + "ã"); |
| | | conclusions.add("åºæ¶ä½é¢" + snapshot.receivableTotal() + "ï¼åºä»ä½é¢" + snapshot.payableTotal() + "ï¼åºåèµéå ç¨" + inventoryValue + "ã"); |
| | | if (lossCount > 0) { |
| | | conclusions.add("åç°äºæè®¢å" + lossCount + "个ï¼å»ºè®®ä¼å
夿 ¸æææèåå·¥åºäººå·¥æçã"); |
| | | } else { |
| | | conclusions.add("å½åæªåç°äºæè®¢åï¼å»ºè®®æç»è·è¸ªä½äº8%婿¶¦ç订åã"); |
| | | } |
| | | if (snapshot.receivableTotal().compareTo(snapshot.payableTotal()) > 0) { |
| | | conclusions.add("忬¾åååé«ï¼å»ºè®®é对é«åºæ¶å®¢æ·æ§è¡åå±å¬æ¶ä¸è´¦æä¼åã"); |
| | | } else { |
| | | conclusions.add("èµéåå坿§ï¼å»ºè®®ä¿æä»æ¬¾è®¡åä¸éè´èå¥èå¨ã"); |
| | | } |
| | | |
| | | List<Map<String, Object>> riskSuggestions = new ArrayList<>(); |
| | | if (lossCount > 0) { |
| | | riskSuggestions.add(riskSuggestion("婿¶¦é£é©", "é«", "夿 ¸äºæè®¢åBOMåå·¥åºå·¥èµå®é¢ï¼å¿
è¦æ¶è°æ´æ¥ä»·ä¸äº¤ä»èå¥ã")); |
| | | } |
| | | if (snapshot.receivableTotal().compareTo(new BigDecimal("1000000")) > 0) { |
| | | riskSuggestions.add(riskSuggestion("忬¾é£é©", "ä¸", "å¯¹åºæ¶TOP客æ·å»ºç«å¨åº¦å款计åï¼å¹¶è®¾ç½®é¢è¦éå¼ã")); |
| | | } |
| | | if (inventoryValue.compareTo(new BigDecimal("3000000")) > 0) { |
| | | riskSuggestions.add(riskSuggestion("åºåé£é©", "ä¸", "对é«éé¢åæ»åºåæ§è¡éä»·ãæ¿ä»£åç产æ¶èçç¥ã")); |
| | | } |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("reportType", type); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("orderCount", bundle.orderMetrics().size()); |
| | | summary.put("lossOrderCount", lossCount); |
| | | summary.put("riskSuggestionCount", riskSuggestions.size()); |
| | | |
| | | Map<String, Object> data = new LinkedHashMap<>(); |
| | | data.put("headline", "weekly".equals(type) ? "ç»è¥å¨æ¥" : "ç»è¥æ¥æ¥"); |
| | | data.put("conclusions", conclusions); |
| | | data.put("riskSuggestions", riskSuggestions); |
| | | data.put("orderProfitTop", bundle.orderMetrics().stream() |
| | | .sorted(Comparator.comparing(OrderProfitMetric::profitRate)) |
| | | .limit(10) |
| | | .map(this::toRiskOrderItem) |
| | | .toList()); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("reportProfitBarOption", buildOrderProfitBar(bundle.orderMetrics())); |
| | | charts.put("reportReceivablePayableOption", buildReceivablePayableBar(snapshot.receivableTotal(), snapshot.payableTotal())); |
| | | return jsonResponse(true, "financial_operation_report", "å·²èªå¨çæç»è¥åææ¥å", summary, data, charts); |
| | | } |
| | | |
| | | private AnalysisBundle buildOrderProfitBundle(LoginUser loginUser, DateRange range, String keyword, Integer limit) { |
| | | List<SalesLedger> ledgers = querySalesLedgers(loginUser, range, keyword, limit); |
| | | if (ledgers.isEmpty()) { |
| | | return AnalysisBundle.empty(); |
| | | } |
| | | |
| | | List<Long> ledgerIds = ledgers.stream().map(SalesLedger::getId).filter(Objects::nonNull).toList(); |
| | | List<SalesLedgerProduct> ledgerProducts = queryLedgerProducts(loginUser, ledgerIds); |
| | | Map<Long, List<SalesLedgerProduct>> productsByLedgerId = ledgerProducts.stream() |
| | | .collect(Collectors.groupingBy(SalesLedgerProduct::getSalesLedgerId)); |
| | | |
| | | MaterialCostResult materialCostResult = calculateMaterialCost(loginUser, range, ledgerProducts); |
| | | ProductionCostContext productionCostContext = calculateProductionCost(loginUser, range, ledgers, ledgerProducts, materialCostResult.avgUnitCostByModelId()); |
| | | BigDecimal totalDepreciation = calculateTotalDepreciation(loginUser); |
| | | |
| | | BigDecimal totalRevenue = ledgers.stream() |
| | | .map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | Map<Long, BigDecimal> depreciationCostByLedger = allocateDepreciation(ledgers, totalDepreciation, totalRevenue); |
| | | |
| | | List<OrderProfitMetric> metrics = new ArrayList<>(); |
| | | for (SalesLedger ledger : ledgers) { |
| | | BigDecimal revenue = defaultDecimal(ledger.getContractAmount()); |
| | | BigDecimal materialCost = materialCostResult.materialCostByLedgerId().getOrDefault(ledger.getId(), fallbackMaterialCost(productsByLedgerId.get(ledger.getId()), revenue)); |
| | | BigDecimal laborCost = productionCostContext.laborCostByLedgerId().getOrDefault(ledger.getId(), BigDecimal.ZERO); |
| | | BigDecimal scrapCost = productionCostContext.scrapCostByLedgerId().getOrDefault(ledger.getId(), BigDecimal.ZERO); |
| | | BigDecimal depreciationCost = depreciationCostByLedger.getOrDefault(ledger.getId(), BigDecimal.ZERO); |
| | | BigDecimal totalCost = materialCost.add(laborCost).add(scrapCost).add(depreciationCost); |
| | | BigDecimal profit = revenue.subtract(totalCost); |
| | | BigDecimal profitRate = rate(profit, revenue); |
| | | String riskLevel = profit.compareTo(BigDecimal.ZERO) < 0 |
| | | ? "high" |
| | | : (profitRate.compareTo(new BigDecimal("0.08")) < 0 ? "medium" : "low"); |
| | | List<String> reasons = buildProfitReasons(revenue, materialCost, laborCost, scrapCost, profit, profitRate); |
| | | String suggestion = buildProfitSuggestion(riskLevel, reasons); |
| | | |
| | | metrics.add(new OrderProfitMetric( |
| | | ledger.getId(), |
| | | safe(ledger.getSalesContractNo()), |
| | | safe(ledger.getCustomerName()), |
| | | safe(ledger.getProjectName()), |
| | | toLocalDate(ledger.getEntryDate()), |
| | | ledger.getDeliveryDate(), |
| | | revenue, |
| | | materialCost, |
| | | laborCost, |
| | | depreciationCost, |
| | | scrapCost, |
| | | totalCost, |
| | | profit, |
| | | profitRate, |
| | | riskLevel, |
| | | reasons, |
| | | suggestion |
| | | )); |
| | | } |
| | | |
| | | metrics.sort(Comparator.comparing(OrderProfitMetric::entryDate, Comparator.nullsLast(Comparator.reverseOrder())) |
| | | .thenComparing(OrderProfitMetric::ledgerId, Comparator.nullsLast(Comparator.reverseOrder()))); |
| | | BigDecimal totalMaterialCost = metrics.stream().map(OrderProfitMetric::materialCost).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalLaborCost = metrics.stream().map(OrderProfitMetric::laborCost).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalScrapCost = metrics.stream().map(OrderProfitMetric::scrapCost).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalDepreciationCost = metrics.stream().map(OrderProfitMetric::depreciationCost).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalCost = metrics.stream().map(OrderProfitMetric::totalCost).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalProfit = metrics.stream().map(OrderProfitMetric::profit).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | return new AnalysisBundle( |
| | | metrics, |
| | | productionCostContext.processCostRanking(), |
| | | totalRevenue, |
| | | totalMaterialCost, |
| | | totalLaborCost, |
| | | totalDepreciationCost, |
| | | totalScrapCost, |
| | | totalCost, |
| | | totalProfit |
| | | ); |
| | | } |
| | | |
| | | private MaterialCostResult calculateMaterialCost(LoginUser loginUser, DateRange range, List<SalesLedgerProduct> ledgerProducts) { |
| | | if (ledgerProducts.isEmpty()) { |
| | | return new MaterialCostResult(Map.of(), Map.of()); |
| | | } |
| | | List<Long> ledgerProductIds = ledgerProducts.stream().map(SalesLedgerProduct::getId).filter(Objects::nonNull).toList(); |
| | | Set<Long> productModelIds = ledgerProducts.stream().map(SalesLedgerProduct::getProductModelId).filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Map<Long, Long> productIdToLedgerId = ledgerProducts.stream() |
| | | .filter(item -> item.getId() != null && item.getSalesLedgerId() != null) |
| | | .collect(Collectors.toMap(SalesLedgerProduct::getId, SalesLedgerProduct::getSalesLedgerId, (a, b) -> a)); |
| | | |
| | | Map<Long, BigDecimal> avgUnitCostByModelId = queryAverageUnitCostByModel(loginUser, productModelIds); |
| | | LambdaQueryWrapper<ProcurementRecordOut> outWrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(outWrapper, loginUser.getTenantId(), ProcurementRecordOut::getTenantId); |
| | | applyDeptFilter(outWrapper, loginUser.getCurrentDeptId(), ProcurementRecordOut::getDeptId); |
| | | outWrapper.eq(ProcurementRecordOut::getType, 2) |
| | | .in(ProcurementRecordOut::getSalesLedgerProductId, ledgerProductIds) |
| | | .ge(ProcurementRecordOut::getCreateTime, range.start().atStartOfDay()) |
| | | .lt(ProcurementRecordOut::getCreateTime, range.end().plusDays(1).atStartOfDay()); |
| | | List<ProcurementRecordOut> outList = defaultList(procurementRecordOutMapper.selectList(outWrapper)); |
| | | |
| | | Set<Integer> storageIds = outList.stream() |
| | | .map(ProcurementRecordOut::getProcurementRecordStorageId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Integer, ProcurementRecordStorage> storageMap = storageIds.isEmpty() |
| | | ? Map.of() |
| | | : defaultList(procurementRecordMapper.selectBatchIds(storageIds)).stream() |
| | | .collect(Collectors.toMap(ProcurementRecordStorage::getId, item -> item, (a, b) -> a)); |
| | | |
| | | Map<Long, BigDecimal> materialCostByLedgerId = new HashMap<>(); |
| | | for (ProcurementRecordOut out : outList) { |
| | | Long ledgerId = productIdToLedgerId.get(out.getSalesLedgerProductId()); |
| | | if (ledgerId == null) { |
| | | continue; |
| | | } |
| | | ProcurementRecordStorage storage = storageMap.get(out.getProcurementRecordStorageId()); |
| | | BigDecimal unitPrice = storage == null ? BigDecimal.ZERO : defaultDecimal(storage.getUnitPrice()); |
| | | BigDecimal quantity = defaultDecimal(out.getInboundNum()); |
| | | BigDecimal cost = quantity.multiply(unitPrice); |
| | | materialCostByLedgerId.merge(ledgerId, cost, BigDecimal::add); |
| | | } |
| | | return new MaterialCostResult(materialCostByLedgerId, avgUnitCostByModelId); |
| | | } |
| | | |
| | | private ProductionCostContext calculateProductionCost(LoginUser loginUser, |
| | | DateRange range, |
| | | List<SalesLedger> ledgers, |
| | | List<SalesLedgerProduct> ledgerProducts, |
| | | Map<Long, BigDecimal> avgUnitCostByModelId) { |
| | | if (ledgers.isEmpty()) { |
| | | return ProductionCostContext.empty(); |
| | | } |
| | | |
| | | Set<Long> ledgerIds = ledgers.stream().map(SalesLedger::getId).filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Map<Long, Set<Long>> productModelToLedgerIds = new HashMap<>(); |
| | | for (SalesLedgerProduct product : ledgerProducts) { |
| | | if (product.getProductModelId() == null || product.getSalesLedgerId() == null) { |
| | | continue; |
| | | } |
| | | productModelToLedgerIds.computeIfAbsent(product.getProductModelId(), key -> new HashSet<>()).add(product.getSalesLedgerId()); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductionPlan> planWrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(planWrapper, loginUser.getCurrentDeptId(), ProductionPlan::getDeptId); |
| | | planWrapper.in(ProductionPlan::getSalesLedgerId, ledgerIds); |
| | | List<ProductionPlan> plans = defaultList(productionPlanMapper.selectList(planWrapper)); |
| | | Map<Long, Long> planIdToLedgerId = plans.stream() |
| | | .filter(item -> item.getId() != null && item.getSalesLedgerId() != null) |
| | | .collect(Collectors.toMap(ProductionPlan::getId, ProductionPlan::getSalesLedgerId, (a, b) -> a)); |
| | | |
| | | LambdaQueryWrapper<ProductionOrder> orderWrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(orderWrapper, loginUser.getCurrentDeptId(), ProductionOrder::getDeptId); |
| | | orderWrapper.ge(ProductionOrder::getCreateTime, range.start().atStartOfDay().minusMonths(2)) |
| | | .lt(ProductionOrder::getCreateTime, range.end().plusDays(1).atStartOfDay().plusMonths(1)); |
| | | List<ProductionOrder> orders = defaultList(productionOrderMapper.selectList(orderWrapper)); |
| | | |
| | | Map<Long, Set<Long>> orderIdToLedgerIds = new HashMap<>(); |
| | | for (ProductionOrder order : orders) { |
| | | Set<Long> orderLedgers = new HashSet<>(); |
| | | for (Long planId : parseIdList(order.getProductionPlanIds())) { |
| | | Long ledgerId = planIdToLedgerId.get(planId); |
| | | if (ledgerId != null) { |
| | | orderLedgers.add(ledgerId); |
| | | } |
| | | } |
| | | if (orderLedgers.isEmpty() && order.getProductModelId() != null) { |
| | | orderLedgers.addAll(productModelToLedgerIds.getOrDefault(order.getProductModelId(), Set.of())); |
| | | } |
| | | if (!orderLedgers.isEmpty()) { |
| | | orderIdToLedgerIds.put(order.getId(), orderLedgers); |
| | | } |
| | | } |
| | | if (orderIdToLedgerIds.isEmpty()) { |
| | | return ProductionCostContext.empty(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductionOperationTask> taskWrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(taskWrapper, loginUser.getCurrentDeptId(), ProductionOperationTask::getDeptId); |
| | | taskWrapper.in(ProductionOperationTask::getProductionOrderId, orderIdToLedgerIds.keySet()); |
| | | List<ProductionOperationTask> tasks = defaultList(productionOperationTaskMapper.selectList(taskWrapper)); |
| | | Map<Long, Long> taskIdToOrderId = tasks.stream() |
| | | .filter(item -> item.getId() != null && item.getProductionOrderId() != null) |
| | | .collect(Collectors.toMap(ProductionOperationTask::getId, ProductionOperationTask::getProductionOrderId, (a, b) -> a)); |
| | | if (taskIdToOrderId.isEmpty()) { |
| | | return ProductionCostContext.empty(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductionProductMain> mainWrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(mainWrapper, loginUser.getCurrentDeptId(), ProductionProductMain::getDeptId); |
| | | mainWrapper.in(ProductionProductMain::getProductionOperationTaskId, taskIdToOrderId.keySet()) |
| | | .ge(ProductionProductMain::getCreateTime, range.start().atStartOfDay().minusMonths(2)) |
| | | .lt(ProductionProductMain::getCreateTime, range.end().plusDays(1).atStartOfDay().plusMonths(1)); |
| | | List<ProductionProductMain> mainList = defaultList(productionProductMainMapper.selectList(mainWrapper)); |
| | | Map<Long, Set<Long>> mainIdToLedgers = new HashMap<>(); |
| | | for (ProductionProductMain main : mainList) { |
| | | Long orderId = taskIdToOrderId.get(main.getProductionOperationTaskId()); |
| | | if (orderId == null) { |
| | | continue; |
| | | } |
| | | Set<Long> ledgerSet = orderIdToLedgerIds.get(orderId); |
| | | if (ledgerSet == null || ledgerSet.isEmpty()) { |
| | | continue; |
| | | } |
| | | mainIdToLedgers.put(main.getId(), ledgerSet); |
| | | } |
| | | if (mainIdToLedgers.isEmpty()) { |
| | | return ProductionCostContext.empty(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductionAccount> accountWrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(accountWrapper, loginUser.getCurrentDeptId(), ProductionAccount::getDeptId); |
| | | accountWrapper.in(ProductionAccount::getProductionProductMainId, mainIdToLedgers.keySet()) |
| | | .ge(ProductionAccount::getSchedulingDate, range.start().atStartOfDay()) |
| | | .lt(ProductionAccount::getSchedulingDate, range.end().plusDays(1).atStartOfDay()); |
| | | List<ProductionAccount> accountList = defaultList(productionAccountMapper.selectList(accountWrapper)); |
| | | |
| | | Map<String, BigDecimal> salaryQuotaByOperation = defaultList(technologyOperationMapper.selectList(new LambdaQueryWrapper<TechnologyOperation>() |
| | | .select(TechnologyOperation::getName, TechnologyOperation::getSalaryQuota))) |
| | | .stream() |
| | | .filter(item -> StringUtils.hasText(item.getName())) |
| | | .collect(Collectors.toMap(TechnologyOperation::getName, item -> defaultDecimal(item.getSalaryQuota()), (a, b) -> a)); |
| | | |
| | | Map<Long, BigDecimal> laborCostByLedger = new HashMap<>(); |
| | | Map<String, BigDecimal> processCostMap = new HashMap<>(); |
| | | for (ProductionAccount account : accountList) { |
| | | Set<Long> ledgerSet = mainIdToLedgers.get(account.getProductionProductMainId()); |
| | | if (ledgerSet == null || ledgerSet.isEmpty()) { |
| | | continue; |
| | | } |
| | | BigDecimal cost = estimateLaborCost(account, salaryQuotaByOperation); |
| | | if (cost.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | BigDecimal split = cost.divide(new BigDecimal(ledgerSet.size()), 4, RoundingMode.HALF_UP); |
| | | for (Long ledgerId : ledgerSet) { |
| | | laborCostByLedger.merge(ledgerId, split, BigDecimal::add); |
| | | } |
| | | processCostMap.merge(safe(account.getTechnologyOperationName()), cost, BigDecimal::add); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductionProductOutput> outputWrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(outputWrapper, loginUser.getCurrentDeptId(), ProductionProductOutput::getDeptId); |
| | | outputWrapper.in(ProductionProductOutput::getProductionProductMainId, mainIdToLedgers.keySet()) |
| | | .ge(ProductionProductOutput::getCreateTime, range.start().atStartOfDay()) |
| | | .lt(ProductionProductOutput::getCreateTime, range.end().plusDays(1).atStartOfDay()); |
| | | List<ProductionProductOutput> outputList = defaultList(productionProductOutputMapper.selectList(outputWrapper)); |
| | | Map<Long, BigDecimal> scrapCostByLedger = new HashMap<>(); |
| | | for (ProductionProductOutput output : outputList) { |
| | | Set<Long> ledgerSet = mainIdToLedgers.get(output.getProductionProductMainId()); |
| | | if (ledgerSet == null || ledgerSet.isEmpty()) { |
| | | continue; |
| | | } |
| | | BigDecimal scrapQty = defaultDecimal(output.getScrapQty()); |
| | | if (scrapQty.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | BigDecimal unitCost = avgUnitCostByModelId.getOrDefault(output.getProductModelId(), BigDecimal.ZERO); |
| | | BigDecimal scrapCost = scrapQty.multiply(unitCost); |
| | | BigDecimal split = scrapCost.divide(new BigDecimal(ledgerSet.size()), 4, RoundingMode.HALF_UP); |
| | | for (Long ledgerId : ledgerSet) { |
| | | scrapCostByLedger.merge(ledgerId, split, BigDecimal::add); |
| | | } |
| | | } |
| | | |
| | | Map<String, BigDecimal> processCostRanking = processCostMap.entrySet().stream() |
| | | .sorted(Map.Entry.<String, BigDecimal>comparingByValue().reversed()) |
| | | .limit(10) |
| | | .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a, LinkedHashMap::new)); |
| | | |
| | | return new ProductionCostContext(laborCostByLedger, scrapCostByLedger, processCostRanking); |
| | | } |
| | | |
| | | private List<SalesLedger> querySalesLedgers(LoginUser loginUser, DateRange range, String keyword, Integer limit) { |
| | | LambdaQueryWrapper<SalesLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), SalesLedger::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), SalesLedger::getDeptId); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(SalesLedger::getSalesContractNo, keyword) |
| | | .or().like(SalesLedger::getCustomerContractNo, keyword) |
| | | .or().like(SalesLedger::getCustomerName, keyword) |
| | | .or().like(SalesLedger::getProjectName, keyword) |
| | | .or().like(SalesLedger::getSalesman, keyword)); |
| | | } |
| | | wrapper.ge(SalesLedger::getEntryDate, toDate(range.start())) |
| | | .lt(SalesLedger::getEntryDate, toExclusiveEndDate(range.end())) |
| | | .orderByDesc(SalesLedger::getEntryDate, SalesLedger::getId) |
| | | .last("limit " + normalizeLimit(limit)); |
| | | return defaultList(salesLedgerMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<SalesLedgerProduct> queryLedgerProducts(LoginUser loginUser, List<Long> ledgerIds) { |
| | | if (ledgerIds == null || ledgerIds.isEmpty()) { |
| | | return List.of(); |
| | | } |
| | | LambdaQueryWrapper<SalesLedgerProduct> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), SalesLedgerProduct::getDeptId); |
| | | wrapper.in(SalesLedgerProduct::getSalesLedgerId, ledgerIds) |
| | | .eq(SalesLedgerProduct::getType, 1); |
| | | return defaultList(salesLedgerProductMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<StockInventory> queryStockInventory(LoginUser loginUser) { |
| | | LambdaQueryWrapper<StockInventory> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), StockInventory::getDeptId); |
| | | return defaultList(stockInventoryMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private Map<Long, ProductModel> queryProductModels(Set<Long> modelIds) { |
| | | if (modelIds == null || modelIds.isEmpty()) { |
| | | return defaultList(productModelMapper.selectList(null)).stream() |
| | | .filter(item -> item.getId() != null) |
| | | .collect(Collectors.toMap(ProductModel::getId, item -> item, (a, b) -> a)); |
| | | } |
| | | LambdaQueryWrapper<ProductModel> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.in(ProductModel::getId, modelIds); |
| | | return defaultList(productModelMapper.selectList(wrapper)).stream() |
| | | .filter(item -> item.getId() != null) |
| | | .collect(Collectors.toMap(ProductModel::getId, item -> item, (a, b) -> a)); |
| | | } |
| | | |
| | | private Map<Long, Product> queryProducts(Collection<ProductModel> models) { |
| | | Set<Long> productIds = models == null ? Set.of() : models.stream() |
| | | .map(ProductModel::getProductId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | if (productIds.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.in(Product::getId, productIds); |
| | | return defaultList(productMapper.selectList(wrapper)).stream() |
| | | .filter(item -> item.getId() != null) |
| | | .collect(Collectors.toMap(Product::getId, item -> item, (a, b) -> a)); |
| | | } |
| | | |
| | | private Map<Long, BigDecimal> queryAverageUnitCostByModel(LoginUser loginUser, Set<Long> productModelIds) { |
| | | LambdaQueryWrapper<ProcurementRecordStorage> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), ProcurementRecordStorage::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProcurementRecordStorage::getDeptId); |
| | | wrapper.in(ProcurementRecordStorage::getType, List.of(1, 2)); |
| | | if (productModelIds != null && !productModelIds.isEmpty()) { |
| | | wrapper.in(ProcurementRecordStorage::getProductModelId, productModelIds); |
| | | } |
| | | List<ProcurementRecordStorage> rows = defaultList(procurementRecordMapper.selectList(wrapper)); |
| | | Map<Long, BigDecimal> amountByModel = new HashMap<>(); |
| | | Map<Long, BigDecimal> qtyByModel = new HashMap<>(); |
| | | for (ProcurementRecordStorage row : rows) { |
| | | if (row.getProductModelId() == null) { |
| | | continue; |
| | | } |
| | | BigDecimal qty = defaultDecimal(row.getInboundNum()); |
| | | if (qty.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | BigDecimal amount = defaultDecimal(row.getUnitPrice()).multiply(qty); |
| | | amountByModel.merge(row.getProductModelId(), amount, BigDecimal::add); |
| | | qtyByModel.merge(row.getProductModelId(), qty, BigDecimal::add); |
| | | } |
| | | Map<Long, BigDecimal> result = new HashMap<>(); |
| | | for (Map.Entry<Long, BigDecimal> entry : amountByModel.entrySet()) { |
| | | BigDecimal qty = qtyByModel.get(entry.getKey()); |
| | | if (qty == null || qty.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | result.put(entry.getKey(), entry.getValue().divide(qty, 6, RoundingMode.HALF_UP)); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private OutboundStats queryOutboundStats(LoginUser loginUser, Set<Long> productModelIds, DateRange range) { |
| | | LambdaQueryWrapper<ProcurementRecordOut> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), ProcurementRecordOut::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProcurementRecordOut::getDeptId); |
| | | if (productModelIds != null && !productModelIds.isEmpty()) { |
| | | wrapper.in(ProcurementRecordOut::getProductModelId, productModelIds); |
| | | } |
| | | wrapper.ge(ProcurementRecordOut::getCreateTime, range.start().atStartOfDay()) |
| | | .lt(ProcurementRecordOut::getCreateTime, range.end().plusDays(1).atStartOfDay()); |
| | | List<ProcurementRecordOut> outList = defaultList(procurementRecordOutMapper.selectList(wrapper)); |
| | | if (outList.isEmpty()) { |
| | | return OutboundStats.empty(); |
| | | } |
| | | Set<Integer> storageIds = outList.stream() |
| | | .map(ProcurementRecordOut::getProcurementRecordStorageId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Integer, ProcurementRecordStorage> storageMap = storageIds.isEmpty() |
| | | ? Map.of() |
| | | : defaultList(procurementRecordMapper.selectBatchIds(storageIds)).stream() |
| | | .collect(Collectors.toMap(ProcurementRecordStorage::getId, item -> item, (a, b) -> a)); |
| | | |
| | | Map<Long, BigDecimal> outboundQtyByModel = new HashMap<>(); |
| | | Map<Long, LocalDateTime> lastOutboundTimeByModel = new HashMap<>(); |
| | | BigDecimal totalOutboundCost = BigDecimal.ZERO; |
| | | for (ProcurementRecordOut out : outList) { |
| | | Long modelId = out.getProductModelId(); |
| | | if (modelId == null) { |
| | | continue; |
| | | } |
| | | BigDecimal qty = defaultDecimal(out.getInboundNum()); |
| | | outboundQtyByModel.merge(modelId, qty, BigDecimal::add); |
| | | if (out.getCreateTime() != null) { |
| | | LocalDateTime existing = lastOutboundTimeByModel.get(modelId); |
| | | if (existing == null || out.getCreateTime().isAfter(existing)) { |
| | | lastOutboundTimeByModel.put(modelId, out.getCreateTime()); |
| | | } |
| | | } |
| | | ProcurementRecordStorage storage = storageMap.get(out.getProcurementRecordStorageId()); |
| | | BigDecimal unitPrice = storage == null ? BigDecimal.ZERO : defaultDecimal(storage.getUnitPrice()); |
| | | totalOutboundCost = totalOutboundCost.add(unitPrice.multiply(qty)); |
| | | } |
| | | return new OutboundStats(outboundQtyByModel, lastOutboundTimeByModel, totalOutboundCost); |
| | | } |
| | | |
| | | private List<InventoryMetric> buildInventoryMetrics(List<StockInventory> inventoryRows, |
| | | Map<Long, ProductModel> productModelMap, |
| | | Map<Long, Product> productMap, |
| | | Map<Long, BigDecimal> avgUnitCostByModelId, |
| | | OutboundStats outboundStats) { |
| | | Map<Long, InventoryMetricBuilder> metricBuilderByModel = new HashMap<>(); |
| | | for (StockInventory row : inventoryRows) { |
| | | if (row.getProductModelId() == null) { |
| | | continue; |
| | | } |
| | | InventoryMetricBuilder builder = metricBuilderByModel.computeIfAbsent(row.getProductModelId(), InventoryMetricBuilder::new); |
| | | builder.addQuantity(maxZero(defaultDecimal(row.getQualitity()).subtract(defaultDecimal(row.getLockedQuantity())))); |
| | | builder.addLockedQuantity(defaultDecimal(row.getLockedQuantity())); |
| | | builder.addWarnNum(defaultDecimal(row.getWarnNum())); |
| | | if (row.getCreateTime() != null) { |
| | | builder.updateFirstInTime(row.getCreateTime()); |
| | | } |
| | | } |
| | | |
| | | List<InventoryMetric> result = new ArrayList<>(); |
| | | LocalDate today = LocalDate.now(); |
| | | for (InventoryMetricBuilder builder : metricBuilderByModel.values()) { |
| | | Long modelId = builder.modelId(); |
| | | ProductModel model = productModelMap.get(modelId); |
| | | Product product = model == null ? null : productMap.get(model.getProductId()); |
| | | BigDecimal unitCost = avgUnitCostByModelId.getOrDefault(modelId, BigDecimal.ZERO); |
| | | BigDecimal value = builder.quantity().multiply(unitCost); |
| | | LocalDateTime lastOutTime = outboundStats.lastOutboundTimeByModel().get(modelId); |
| | | long stagnantDays; |
| | | if (lastOutTime != null) { |
| | | stagnantDays = daysBetween(lastOutTime.toLocalDate(), today); |
| | | } else if (builder.firstInTime() != null) { |
| | | stagnantDays = daysBetween(builder.firstInTime().toLocalDate(), today); |
| | | } else { |
| | | stagnantDays = 0; |
| | | } |
| | | BigDecimal outQty = outboundStats.outboundQtyByModel().getOrDefault(modelId, BigDecimal.ZERO); |
| | | boolean overstock = builder.warnNum().compareTo(BigDecimal.ZERO) > 0 |
| | | && builder.quantity().compareTo(builder.warnNum().multiply(new BigDecimal("3"))) > 0; |
| | | result.add(new InventoryMetric( |
| | | modelId, |
| | | product == null ? "æªç¥äº§å" : safe(product.getProductName()), |
| | | model == null ? "æªç¥åå·" : safe(model.getModel()), |
| | | builder.quantity(), |
| | | builder.lockedQuantity(), |
| | | unitCost, |
| | | value, |
| | | outQty, |
| | | stagnantDays, |
| | | overstock |
| | | )); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private List<AccountSalesCollection> queryCollections(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<AccountSalesCollection> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountSalesCollection::getDeptId); |
| | | wrapper.ge(AccountSalesCollection::getCollectionDate, range.start()) |
| | | .le(AccountSalesCollection::getCollectionDate, range.end()) |
| | | .orderByAsc(AccountSalesCollection::getCollectionDate); |
| | | return defaultList(accountSalesCollectionMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<AccountPurchasePayment> queryPayments(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<AccountPurchasePayment> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountPurchasePayment::getDeptId); |
| | | wrapper.ge(AccountPurchasePayment::getPaymentDate, range.start()) |
| | | .le(AccountPurchasePayment::getPaymentDate, range.end()) |
| | | .orderByAsc(AccountPurchasePayment::getPaymentDate); |
| | | return defaultList(accountPurchasePaymentMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<MonthlyCashFlow> buildMonthlyCashFlow(DateRange range, |
| | | List<AccountSalesCollection> collections, |
| | | List<AccountPurchasePayment> payments) { |
| | | Map<YearMonth, BigDecimal> incomeByMonth = new LinkedHashMap<>(); |
| | | Map<YearMonth, BigDecimal> expenseByMonth = new LinkedHashMap<>(); |
| | | YearMonth startMonth = YearMonth.from(range.start()); |
| | | YearMonth endMonth = YearMonth.from(range.end()); |
| | | for (YearMonth month = startMonth; !month.isAfter(endMonth); month = month.plusMonths(1)) { |
| | | incomeByMonth.put(month, BigDecimal.ZERO); |
| | | expenseByMonth.put(month, BigDecimal.ZERO); |
| | | } |
| | | |
| | | for (AccountSalesCollection row : collections) { |
| | | if (row.getCollectionDate() == null) { |
| | | continue; |
| | | } |
| | | YearMonth month = YearMonth.from(row.getCollectionDate()); |
| | | if (incomeByMonth.containsKey(month)) { |
| | | incomeByMonth.put(month, incomeByMonth.get(month).add(defaultDecimal(row.getCollectionAmount()))); |
| | | } |
| | | } |
| | | for (AccountPurchasePayment row : payments) { |
| | | if (row.getPaymentDate() == null) { |
| | | continue; |
| | | } |
| | | YearMonth month = YearMonth.from(row.getPaymentDate()); |
| | | if (expenseByMonth.containsKey(month)) { |
| | | expenseByMonth.put(month, expenseByMonth.get(month).add(defaultDecimal(row.getPaymentAmount()))); |
| | | } |
| | | } |
| | | |
| | | List<MonthlyCashFlow> result = new ArrayList<>(); |
| | | for (YearMonth month : incomeByMonth.keySet()) { |
| | | BigDecimal income = incomeByMonth.get(month); |
| | | BigDecimal expense = expenseByMonth.getOrDefault(month, BigDecimal.ZERO); |
| | | result.add(new MonthlyCashFlow(month.toString(), income, expense, income.subtract(expense))); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private List<MonthlyCashFlow> forecastMonthlyCashFlow(List<MonthlyCashFlow> actual, int forecastMonths) { |
| | | if (actual.isEmpty()) { |
| | | List<MonthlyCashFlow> defaults = new ArrayList<>(); |
| | | YearMonth now = YearMonth.now(); |
| | | for (int i = 1; i <= forecastMonths; i++) { |
| | | YearMonth month = now.plusMonths(i); |
| | | defaults.add(new MonthlyCashFlow(month.toString(), BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO)); |
| | | } |
| | | return defaults; |
| | | } |
| | | List<BigDecimal> series = actual.stream().map(MonthlyCashFlow::netFlow).toList(); |
| | | BigDecimal avg = series.stream().reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | .divide(new BigDecimal(series.size()), 4, RoundingMode.HALF_UP); |
| | | BigDecimal slope = BigDecimal.ZERO; |
| | | if (series.size() > 1) { |
| | | slope = series.get(series.size() - 1).subtract(series.get(0)) |
| | | .divide(new BigDecimal(series.size() - 1), 4, RoundingMode.HALF_UP); |
| | | } |
| | | YearMonth lastMonth = YearMonth.parse(actual.get(actual.size() - 1).month()); |
| | | List<MonthlyCashFlow> forecast = new ArrayList<>(); |
| | | for (int i = 1; i <= forecastMonths; i++) { |
| | | YearMonth month = lastMonth.plusMonths(i); |
| | | BigDecimal net = avg.add(slope.multiply(new BigDecimal(i))).setScale(2, RoundingMode.HALF_UP); |
| | | BigDecimal income = net.compareTo(BigDecimal.ZERO) >= 0 ? net : BigDecimal.ZERO; |
| | | BigDecimal expense = net.compareTo(BigDecimal.ZERO) >= 0 ? BigDecimal.ZERO : net.abs(); |
| | | forecast.add(new MonthlyCashFlow(month.toString(), income, expense, net)); |
| | | } |
| | | return forecast; |
| | | } |
| | | |
| | | private StatementSnapshot buildStatementSnapshot(LoginUser loginUser) { |
| | | LambdaQueryWrapper<AccountStatement> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountStatement::getDeptId); |
| | | wrapper.orderByDesc(AccountStatement::getStatementMonth); |
| | | List<AccountStatement> rows = defaultList(accountStatementMapper.selectList(wrapper)); |
| | | if (rows.isEmpty()) { |
| | | return StatementSnapshot.empty(); |
| | | } |
| | | |
| | | Map<String, AccountStatement> latestByEntity = new HashMap<>(); |
| | | for (AccountStatement row : rows) { |
| | | if (row.getAccountType() == null || row.getCustomerId() == null || !StringUtils.hasText(row.getStatementMonth())) { |
| | | continue; |
| | | } |
| | | String key = row.getAccountType() + "::" + row.getCustomerId(); |
| | | AccountStatement existing = latestByEntity.get(key); |
| | | if (existing == null || row.getStatementMonth().compareTo(existing.getStatementMonth()) > 0) { |
| | | latestByEntity.put(key, row); |
| | | } |
| | | } |
| | | |
| | | BigDecimal receivableTotal = BigDecimal.ZERO; |
| | | BigDecimal payableTotal = BigDecimal.ZERO; |
| | | List<StatementMetric> receivableMetrics = new ArrayList<>(); |
| | | List<StatementMetric> payableMetrics = new ArrayList<>(); |
| | | for (AccountStatement row : latestByEntity.values()) { |
| | | BigDecimal closing = defaultDecimal(row.getClosingBalance()); |
| | | if (Objects.equals(row.getAccountType(), 1)) { |
| | | receivableTotal = receivableTotal.add(closing); |
| | | receivableMetrics.add(new StatementMetric(String.valueOf(row.getCustomerId()), closing, |
| | | defaultDecimal(row.getCurrentPlan()), defaultDecimal(row.getCurrentActually()), safe(row.getStatementMonth()))); |
| | | } else if (Objects.equals(row.getAccountType(), 2)) { |
| | | payableTotal = payableTotal.add(closing); |
| | | payableMetrics.add(new StatementMetric(String.valueOf(row.getCustomerId()), closing, |
| | | defaultDecimal(row.getCurrentPlan()), defaultDecimal(row.getCurrentActually()), safe(row.getStatementMonth()))); |
| | | } |
| | | } |
| | | receivableMetrics.sort(Comparator.comparing(StatementMetric::closingBalance).reversed()); |
| | | payableMetrics.sort(Comparator.comparing(StatementMetric::closingBalance).reversed()); |
| | | |
| | | return new StatementSnapshot( |
| | | receivableTotal, |
| | | payableTotal, |
| | | receivableMetrics.stream().limit(10).toList(), |
| | | payableMetrics.stream().limit(10).toList() |
| | | ); |
| | | } |
| | | |
| | | private BigDecimal calculateTotalDepreciation(LoginUser loginUser) { |
| | | LambdaQueryWrapper<DeviceLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceLedger::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), DeviceLedger::getDeptId); |
| | | wrapper.eq(DeviceLedger::getIsDepr, 1); |
| | | List<DeviceLedger> devices = defaultList(deviceLedgerMapper.selectList(wrapper)); |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | for (DeviceLedger device : devices) { |
| | | total = total.add(defaultDecimal(AccountingServiceImpl.calculatePreciseDepreciation(device))); |
| | | } |
| | | return total; |
| | | } |
| | | |
| | | private Map<Long, BigDecimal> allocateDepreciation(List<SalesLedger> ledgers, BigDecimal totalDepreciation, BigDecimal totalRevenue) { |
| | | if (ledgers.isEmpty() || totalDepreciation.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return Map.of(); |
| | | } |
| | | Map<Long, BigDecimal> result = new HashMap<>(); |
| | | if (totalRevenue.compareTo(BigDecimal.ZERO) <= 0) { |
| | | BigDecimal avg = totalDepreciation.divide(new BigDecimal(ledgers.size()), 4, RoundingMode.HALF_UP); |
| | | for (SalesLedger ledger : ledgers) { |
| | | result.put(ledger.getId(), avg); |
| | | } |
| | | return result; |
| | | } |
| | | for (SalesLedger ledger : ledgers) { |
| | | BigDecimal revenue = defaultDecimal(ledger.getContractAmount()); |
| | | BigDecimal ratio = revenue.divide(totalRevenue, 6, RoundingMode.HALF_UP); |
| | | result.put(ledger.getId(), totalDepreciation.multiply(ratio)); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private BigDecimal fallbackMaterialCost(List<SalesLedgerProduct> products, BigDecimal revenue) { |
| | | if (products != null && !products.isEmpty()) { |
| | | BigDecimal productAmount = products.stream() |
| | | .map(SalesLedgerProduct::getTaxExclusiveTotalPrice) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (productAmount.compareTo(BigDecimal.ZERO) > 0) { |
| | | return productAmount; |
| | | } |
| | | } |
| | | return revenue.multiply(DEFAULT_FALLBACK_MATERIAL_COST_RATE); |
| | | } |
| | | |
| | | private Map<String, String> queryCustomerNameMap(Set<String> idSet) { |
| | | if (idSet == null || idSet.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | Set<Long> ids = idSet.stream() |
| | | .map(this::toLongOrNull) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | if (ids.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | LambdaQueryWrapper<Customer> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.in(Customer::getId, ids); |
| | | return defaultList(customerMapper.selectList(wrapper)).stream() |
| | | .collect(Collectors.toMap(item -> String.valueOf(item.getId()), Customer::getCustomerName, (a, b) -> a)); |
| | | } |
| | | |
| | | private Map<String, String> querySupplierNameMap(Set<String> idSet) { |
| | | if (idSet == null || idSet.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | Set<Long> ids = idSet.stream() |
| | | .map(this::toLongOrNull) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | if (ids.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | LambdaQueryWrapper<SupplierManage> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.in(SupplierManage::getId, ids); |
| | | return defaultList(supplierManageMapper.selectList(wrapper)).stream() |
| | | .collect(Collectors.toMap(item -> String.valueOf(item.getId()), SupplierManage::getSupplierName, (a, b) -> a)); |
| | | } |
| | | |
| | | private String riskLevelByAmount(BigDecimal amount) { |
| | | if (amount.compareTo(new BigDecimal("5000000")) >= 0) { |
| | | return "high"; |
| | | } |
| | | if (amount.compareTo(new BigDecimal("1000000")) >= 0) { |
| | | return "medium"; |
| | | } |
| | | return "low"; |
| | | } |
| | | |
| | | private long countDevices(LoginUser loginUser) { |
| | | LambdaQueryWrapper<DeviceLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceLedger::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), DeviceLedger::getDeptId); |
| | | return deviceLedgerMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countRepairingDevices(LoginUser loginUser) { |
| | | LambdaQueryWrapper<DeviceRepair> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceRepair::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), DeviceRepair::getDeptId); |
| | | wrapper.in(DeviceRepair::getStatus, List.of(0, 3)); |
| | | return deviceRepairMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private BigDecimal estimateInventoryValue(LoginUser loginUser, List<StockInventory> inventories) { |
| | | if (inventories == null || inventories.isEmpty()) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | Set<Long> modelIds = inventories.stream().map(StockInventory::getProductModelId).filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | Map<Long, BigDecimal> costMap = queryAverageUnitCostByModel(loginUser, modelIds); |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | for (StockInventory inventory : inventories) { |
| | | BigDecimal qty = maxZero(defaultDecimal(inventory.getQualitity()).subtract(defaultDecimal(inventory.getLockedQuantity()))); |
| | | BigDecimal unit = costMap.getOrDefault(inventory.getProductModelId(), BigDecimal.ZERO); |
| | | total = total.add(qty.multiply(unit)); |
| | | } |
| | | return total; |
| | | } |
| | | |
| | | private DateRange previousSameLengthRange(DateRange range) { |
| | | long days = daysBetween(range.start(), range.end()) + 1L; |
| | | LocalDate prevEnd = range.start().minusDays(1); |
| | | LocalDate prevStart = prevEnd.minusDays(days - 1L); |
| | | return new DateRange(prevStart, prevEnd, prevStart + "è³" + prevEnd); |
| | | } |
| | | |
| | | private List<String> buildProfitReasons(BigDecimal revenue, |
| | | BigDecimal materialCost, |
| | | BigDecimal laborCost, |
| | | BigDecimal scrapCost, |
| | | BigDecimal profit, |
| | | BigDecimal profitRate) { |
| | | List<String> reasons = new ArrayList<>(); |
| | | BigDecimal materialRate = rate(materialCost, revenue); |
| | | if (materialRate.compareTo(new BigDecimal("0.70")) >= 0) { |
| | | reasons.add("ææææ¬å æ¯è¶
è¿70%"); |
| | | } else if (materialRate.compareTo(new BigDecimal("0.55")) >= 0) { |
| | | reasons.add("ææææ¬å æ¯åé«"); |
| | | } |
| | | BigDecimal laborRate = rate(laborCost, revenue); |
| | | if (laborRate.compareTo(new BigDecimal("0.20")) >= 0) { |
| | | reasons.add("äººå·¥ææ¬å æ¯è¶
è¿20%"); |
| | | } else if (laborRate.compareTo(new BigDecimal("0.12")) >= 0) { |
| | | reasons.add("äººå·¥ææ¬å¢é¿åå¿«"); |
| | | } |
| | | BigDecimal scrapRate = rate(scrapCost, revenue); |
| | | if (scrapRate.compareTo(new BigDecimal("0.05")) >= 0) { |
| | | reasons.add("æ¥åºæèå æ¯åé«"); |
| | | } |
| | | if (profit.compareTo(BigDecimal.ZERO) < 0) { |
| | | reasons.add("订åå¤äºäºæç¶æ"); |
| | | } else if (profitRate.compareTo(new BigDecimal("0.08")) < 0) { |
| | | reasons.add("婿¶¦çä½äº8%"); |
| | | } |
| | | if (reasons.isEmpty()) { |
| | | reasons.add("ææ¬ç»æå¤äºåçåºé´"); |
| | | } |
| | | return reasons; |
| | | } |
| | | |
| | | private String buildProfitSuggestion(String riskLevel, List<String> reasons) { |
| | | if ("high".equals(riskLevel)) { |
| | | return "ä¼å
夿 ¸BOMç¨éä¸å·¥åºå®é¢ï¼å¿
è¦æ¶è°æ´æ¥ä»·å仿¬¾æ¡æ¬¾ï¼å¹¶éå¶è¶
è´¦æäº¤ä»ã"; |
| | | } |
| | | if ("medium".equals(riskLevel)) { |
| | | return "建议ä¼åéè´æ¹æ¬¡åå·¥åºæäº§ï¼æå䏿¬¡åæ ¼ç并忥æ§è¡æ¯å©é¢è¦ã"; |
| | | } |
| | | if (reasons.stream().anyMatch(item -> item.contains("ææ"))) { |
| | | return "ä¿æææéè´ææ¬çæ¿ï¼æå¨è·è¸ªä¸»è¦ææåä»·æ³¢å¨ã"; |
| | | } |
| | | return "ç»´æå½åç»è¥èå¥ï¼ç»§ç»è·è¸ªè®¢å婿¶¦çå忬¾æçã"; |
| | | } |
| | | |
| | | private Map<String, Object> toOrderCostItem(OrderProfitMetric metric) { |
| | | Map<String, Object> item = new LinkedHashMap<>(); |
| | | item.put("ledgerId", metric.ledgerId()); |
| | | item.put("salesContractNo", metric.salesContractNo()); |
| | | item.put("customerName", metric.customerName()); |
| | | item.put("projectName", metric.projectName()); |
| | | item.put("entryDate", formatDate(metric.entryDate())); |
| | | item.put("deliveryDate", formatDate(metric.deliveryDate())); |
| | | item.put("revenue", metric.revenue()); |
| | | item.put("materialCost", metric.materialCost()); |
| | | item.put("laborCost", metric.laborCost()); |
| | | item.put("depreciationCost", metric.depreciationCost()); |
| | | item.put("scrapCost", metric.scrapCost()); |
| | | item.put("totalCost", metric.totalCost()); |
| | | item.put("profit", metric.profit()); |
| | | item.put("profitRate", toPercent(metric.profitRate())); |
| | | item.put("riskLevel", metric.riskLevel()); |
| | | item.put("reasons", metric.reasons()); |
| | | item.put("suggestion", metric.suggestion()); |
| | | return item; |
| | | } |
| | | |
| | | private Map<String, Object> toRiskOrderItem(OrderProfitMetric metric) { |
| | | Map<String, Object> map = toOrderCostItem(metric); |
| | | map.put("priority", "high".equals(metric.riskLevel()) ? "high" : ("medium".equals(metric.riskLevel()) ? "medium" : "low")); |
| | | return map; |
| | | } |
| | | |
| | | private List<Map<String, Object>> buildCustomerProfitTop(List<OrderProfitMetric> metrics, int topN) { |
| | | Map<String, BigDecimal> customerProfitMap = new HashMap<>(); |
| | | Map<String, BigDecimal> customerRevenueMap = new HashMap<>(); |
| | | for (OrderProfitMetric metric : metrics) { |
| | | customerProfitMap.merge(metric.customerName(), metric.profit(), BigDecimal::add); |
| | | customerRevenueMap.merge(metric.customerName(), metric.revenue(), BigDecimal::add); |
| | | } |
| | | return customerProfitMap.entrySet().stream() |
| | | .sorted(Map.Entry.<String, BigDecimal>comparingByValue().reversed()) |
| | | .limit(topN) |
| | | .map(entry -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | BigDecimal revenue = customerRevenueMap.getOrDefault(entry.getKey(), BigDecimal.ZERO); |
| | | map.put("customerName", entry.getKey()); |
| | | map.put("profit", entry.getValue()); |
| | | map.put("revenue", revenue); |
| | | map.put("profitRate", toPercent(rate(entry.getValue(), revenue))); |
| | | return map; |
| | | }) |
| | | .toList(); |
| | | } |
| | | |
| | | private Map<String, Object> toInventoryItem(InventoryMetric metric) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("productModelId", metric.modelId()); |
| | | map.put("productName", metric.productName()); |
| | | map.put("model", metric.modelName()); |
| | | map.put("quantity", metric.quantity()); |
| | | map.put("lockedQuantity", metric.lockedQuantity()); |
| | | map.put("avgUnitCost", metric.avgUnitCost()); |
| | | map.put("inventoryValue", metric.inventoryValue()); |
| | | map.put("outboundQuantity", metric.outboundQuantity()); |
| | | map.put("stagnantDays", metric.stagnantDays()); |
| | | map.put("overstock", metric.overstock()); |
| | | map.put("riskLevel", metric.stagnantDays() >= 90 ? "high" : (metric.stagnantDays() >= 30 ? "medium" : "low")); |
| | | return map; |
| | | } |
| | | |
| | | private boolean matchInventoryKeyword(InventoryMetric metric, String keyword) { |
| | | if (!StringUtils.hasText(keyword)) { |
| | | return true; |
| | | } |
| | | return metric.productName().contains(keyword.trim()) || metric.modelName().contains(keyword.trim()); |
| | | } |
| | | |
| | | private Map<String, Object> toMonthlyCashFlowItem(MonthlyCashFlow flow) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("month", flow.month()); |
| | | map.put("income", flow.income()); |
| | | map.put("expense", flow.expense()); |
| | | map.put("netFlow", flow.netFlow()); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toStatementRiskItem(StatementMetric metric, Map<String, String> nameMap, String type) { |
| | | BigDecimal actualRate = rate(metric.actualAmount(), metric.planAmount()); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put(type + "Id", metric.entityId()); |
| | | map.put(type + "Name", safe(nameMap.get(metric.entityId()))); |
| | | map.put("statementMonth", metric.statementMonth()); |
| | | map.put("closingBalance", metric.closingBalance()); |
| | | map.put("planAmount", metric.planAmount()); |
| | | map.put("actualAmount", metric.actualAmount()); |
| | | map.put("actualRate", toPercent(actualRate)); |
| | | map.put("riskLevel", metric.closingBalance().compareTo(new BigDecimal("1000000")) > 0 || actualRate.compareTo(new BigDecimal("0.50")) < 0 ? "high" : "medium"); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> anomalyItem(String level, String type, String message, Map<String, Object> detail) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("riskLevel", level); |
| | | map.put("type", type); |
| | | map.put("message", message); |
| | | map.put("detail", detail); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> riskSuggestion(String type, String level, String suggestion) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("type", type); |
| | | map.put("level", level); |
| | | map.put("suggestion", suggestion); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> buildCostCompositionPie(BigDecimal material, BigDecimal labor, BigDecimal depreciation, BigDecimal scrap) { |
| | | List<Map<String, Object>> data = List.of( |
| | | Map.of("name", "ææææ¬", "value", material), |
| | | Map.of("name", "äººå·¥ææ¬", "value", labor), |
| | | Map.of("name", "ææ§ææ¬", "value", depreciation), |
| | | Map.of("name", "æèææ¬", "value", scrap) |
| | | ); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "ææ¬ææ", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "item")); |
| | | option.put("series", List.of(Map.of("name", "ææ¬ææ", "type", "pie", "radius", "60%", "data", data))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildOrderProfitBar(List<OrderProfitMetric> metrics) { |
| | | List<OrderProfitMetric> top = metrics.stream() |
| | | .sorted(Comparator.comparing(OrderProfitMetric::profit)) |
| | | .limit(10) |
| | | .toList(); |
| | | List<String> xData = top.stream().map(OrderProfitMetric::salesContractNo).toList(); |
| | | List<BigDecimal> yData = top.stream().map(OrderProfitMetric::profit).toList(); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "订å婿¶¦åå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "婿¶¦", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildProcessCostBar(Map<String, BigDecimal> processCosts) { |
| | | List<String> xData = new ArrayList<>(processCosts.keySet()); |
| | | List<BigDecimal> yData = new ArrayList<>(processCosts.values()); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "å·¥åºææ¬æå", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "ææ¬", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildProfitDistributionBar(List<OrderProfitMetric> metrics) { |
| | | List<OrderProfitMetric> sorted = metrics.stream() |
| | | .sorted(Comparator.comparing(OrderProfitMetric::profitRate)) |
| | | .limit(15) |
| | | .toList(); |
| | | List<String> xData = sorted.stream().map(OrderProfitMetric::salesContractNo).toList(); |
| | | List<BigDecimal> yData = sorted.stream().map(metric -> metric.profitRate().multiply(ONE_HUNDRED).setScale(2, RoundingMode.HALF_UP)).toList(); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "订å婿¶¦çåå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value", "name", "%")); |
| | | option.put("series", List.of(Map.of("name", "婿¶¦ç", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildLossOrderTrendLine(List<OrderProfitMetric> metrics) { |
| | | Map<String, Long> lossByDate = new LinkedHashMap<>(); |
| | | List<OrderProfitMetric> sorted = metrics.stream() |
| | | .filter(metric -> metric.entryDate() != null) |
| | | .sorted(Comparator.comparing(OrderProfitMetric::entryDate)) |
| | | .toList(); |
| | | for (OrderProfitMetric metric : sorted) { |
| | | String day = formatDate(metric.entryDate()); |
| | | long inc = metric.profit().compareTo(BigDecimal.ZERO) < 0 ? 1L : 0L; |
| | | lossByDate.merge(day, inc, Long::sum); |
| | | } |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "äºæè®¢åè¶å¿", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", new ArrayList<>(lossByDate.keySet()))); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "äºæè®¢åæ°", "type", "line", "smooth", true, "data", new ArrayList<>(lossByDate.values())))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildCustomerProfitBar(Map<String, BigDecimal> customerProfitMap) { |
| | | List<Map.Entry<String, BigDecimal>> top = customerProfitMap.entrySet().stream() |
| | | .sorted(Map.Entry.<String, BigDecimal>comparingByValue().reversed()) |
| | | .limit(10) |
| | | .toList(); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "客æ·å©æ¶¦è´¡ç®TOP10", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", top.stream().map(Map.Entry::getKey).toList())); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "婿¶¦", "type", "bar", "data", top.stream().map(Map.Entry::getValue).toList()))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildInventoryTopBar(List<InventoryMetric> metrics) { |
| | | List<InventoryMetric> top = metrics.stream() |
| | | .sorted(Comparator.comparing(InventoryMetric::inventoryValue).reversed()) |
| | | .limit(10) |
| | | .toList(); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "åºåèµéå ç¨TOP10", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", top.stream().map(item -> item.productName() + "/" + item.modelName()).toList())); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "èµéå ç¨", "type", "bar", "data", top.stream().map(InventoryMetric::inventoryValue).toList()))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildInventoryAgingPie(List<InventoryMetric> metrics) { |
| | | long normal = metrics.stream().filter(item -> item.stagnantDays() < 30).count(); |
| | | long slow = metrics.stream().filter(item -> item.stagnantDays() >= 30 && item.stagnantDays() < 90).count(); |
| | | long stagnant = metrics.stream().filter(item -> item.stagnantDays() >= 90).count(); |
| | | List<Map<String, Object>> data = List.of( |
| | | Map.of("name", "æ£å¸¸", "value", normal), |
| | | Map.of("name", "ç¼æ
¢", "value", slow), |
| | | Map.of("name", "åæ»", "value", stagnant) |
| | | ); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "åºååºé¾åå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "item")); |
| | | option.put("series", List.of(Map.of("type", "pie", "radius", "60%", "data", data))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildTurnoverGauge(BigDecimal turnoverDays) { |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "åºåå¨è½¬å¤©æ°", "left", "center")); |
| | | option.put("series", List.of(Map.of( |
| | | "type", "gauge", |
| | | "min", 0, |
| | | "max", 180, |
| | | "detail", Map.of("formatter", "{value}天"), |
| | | "data", List.of(Map.of("value", turnoverDays, "name", "å¨è½¬å¤©æ°")) |
| | | ))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildCashflowTrend(List<MonthlyCashFlow> actual, List<MonthlyCashFlow> forecast) { |
| | | List<String> labels = new ArrayList<>(); |
| | | List<BigDecimal> netActual = new ArrayList<>(); |
| | | List<BigDecimal> netForecast = new ArrayList<>(); |
| | | for (MonthlyCashFlow point : actual) { |
| | | labels.add(point.month()); |
| | | netActual.add(point.netFlow()); |
| | | netForecast.add(null); |
| | | } |
| | | for (MonthlyCashFlow point : forecast) { |
| | | labels.add(point.month()); |
| | | netActual.add(null); |
| | | netForecast.add(point.netFlow()); |
| | | } |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "ç°éæµè¶å¿ï¼å®é
+颿µï¼", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", labels)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of( |
| | | Map.of("name", "å®é
åç°éæµ", "type", "line", "smooth", true, "data", netActual), |
| | | Map.of("name", "颿µåç°éæµ", "type", "line", "smooth", true, "data", netForecast) |
| | | )); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildReceivablePayableBar(BigDecimal receivable, BigDecimal payable) { |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "åºæ¶åºä»ä½é¢å¯¹æ¯", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", List.of("åºæ¶", "åºä»"))); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "ä½é¢", "type", "bar", "data", List.of(receivable, payable)))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildFundGapGauge(BigDecimal fundGap) { |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "èµé缺å£", "left", "center")); |
| | | option.put("series", List.of(Map.of( |
| | | "type", "gauge", |
| | | "min", 0, |
| | | "max", 10000000, |
| | | "detail", Map.of("formatter", "{value}"), |
| | | "data", List.of(Map.of("value", fundGap, "name", "èµé缺å£")) |
| | | ))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildAnomalyLevelPie(List<Map<String, Object>> anomalies) { |
| | | long high = anomalies.stream().filter(item -> "high".equals(item.get("riskLevel"))).count(); |
| | | long medium = anomalies.stream().filter(item -> "medium".equals(item.get("riskLevel"))).count(); |
| | | long low = anomalies.stream().filter(item -> "low".equals(item.get("riskLevel"))).count(); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "å¼å¸¸ç级åå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "item")); |
| | | option.put("series", List.of(Map.of("type", "pie", "radius", "60%", "data", List.of( |
| | | Map.of("name", "é«é£é©", "value", high), |
| | | Map.of("name", "ä¸é£é©", "value", medium), |
| | | Map.of("name", "ä½é£é©", "value", low) |
| | | )))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildAnomalyTypeBar(List<Map<String, Object>> anomalies) { |
| | | Map<String, Long> countByType = new LinkedHashMap<>(); |
| | | for (Map<String, Object> anomaly : anomalies) { |
| | | countByType.merge(String.valueOf(anomaly.get("type")), 1L, Long::sum); |
| | | } |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "å¼å¸¸ç±»ååå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", new ArrayList<>(countByType.keySet()))); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "å¼å¸¸æ°", "type", "bar", "data", new ArrayList<>(countByType.values())))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildInventoryProfitGauge(BigDecimal inventoryValue, BigDecimal profit) { |
| | | BigDecimal ratio = inventoryValue.compareTo(BigDecimal.ZERO) <= 0 |
| | | ? BigDecimal.ZERO |
| | | : profit.divide(inventoryValue, 4, RoundingMode.HALF_UP).multiply(ONE_HUNDRED); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "婿¶¦/åºåèµéæ¯", "left", "center")); |
| | | option.put("series", List.of(Map.of( |
| | | "type", "gauge", |
| | | "min", -100, |
| | | "max", 100, |
| | | "detail", Map.of("formatter", "{value}%"), |
| | | "data", List.of(Map.of("value", ratio.setScale(2, RoundingMode.HALF_UP), "name", "婿¶¦èµéæ¯")) |
| | | ))); |
| | | return option; |
| | | } |
| | | |
| | | private int normalizeLimit(Integer limit) { |
| | | if (limit == null || limit <= 0) { |
| | | return DEFAULT_LIMIT; |
| | | } |
| | | return Math.min(limit, MAX_LIMIT); |
| | | } |
| | | |
| | | private DateRange resolveDateRange(String startDate, String endDate, String timeRange, String defaultLabel) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate explicitStart = parseLocalDate(startDate); |
| | | LocalDate explicitEnd = parseLocalDate(endDate); |
| | | if (explicitStart != null || explicitEnd != null) { |
| | | LocalDate start = explicitStart != null ? explicitStart : explicitEnd; |
| | | LocalDate end = explicitEnd != null ? explicitEnd : explicitStart; |
| | | if (start.isAfter(end)) { |
| | | LocalDate temp = start; |
| | | start = end; |
| | | end = temp; |
| | | } |
| | | return new DateRange(start, end, start + "è³" + end); |
| | | } |
| | | |
| | | if (!StringUtils.hasText(timeRange)) { |
| | | if ("ä»å¤©".equals(defaultLabel)) { |
| | | return new DateRange(today, today, "ä»å¤©"); |
| | | } |
| | | if ("æ¬å¨".equals(defaultLabel)) { |
| | | LocalDate start = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | return new DateRange(start, today, "æ¬å¨"); |
| | | } |
| | | if ("æ¬æ".equals(defaultLabel)) { |
| | | return new DateRange(today.withDayOfMonth(1), today, "æ¬æ"); |
| | | } |
| | | if ("è¿90天".equals(defaultLabel)) { |
| | | return new DateRange(today.minusDays(89), today, "è¿90天"); |
| | | } |
| | | return new DateRange(today.minusDays(29), today, defaultLabel); |
| | | } |
| | | |
| | | String text = timeRange.trim(); |
| | | if (text.contains("ä»å¤©")) { |
| | | return new DateRange(today, today, "ä»å¤©"); |
| | | } |
| | | if (text.contains("æ¨å¤©") || text.contains("æ¨æ¥")) { |
| | | LocalDate day = today.minusDays(1); |
| | | return new DateRange(day, day, "æ¨å¤©"); |
| | | } |
| | | if (text.contains("æ¬å¨")) { |
| | | LocalDate start = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | return new DateRange(start, today, "æ¬å¨"); |
| | | } |
| | | if (text.contains("ä¸å¨")) { |
| | | LocalDate thisWeekStart = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | LocalDate start = thisWeekStart.minusWeeks(1); |
| | | LocalDate end = thisWeekStart.minusDays(1); |
| | | return new DateRange(start, end, "ä¸å¨"); |
| | | } |
| | | if (text.contains("æ¬æ")) { |
| | | return new DateRange(today.withDayOfMonth(1), today, "æ¬æ"); |
| | | } |
| | | if (text.contains("䏿")) { |
| | | YearMonth lastMonth = YearMonth.from(today).minusMonths(1); |
| | | return new DateRange(lastMonth.atDay(1), lastMonth.atEndOfMonth(), "䏿"); |
| | | } |
| | | if (text.contains("ä»å¹´") || text.contains("æ¬å¹´")) { |
| | | return new DateRange(today.withDayOfYear(1), today, "ä»å¹´"); |
| | | } |
| | | Matcher relativeMatcher = RELATIVE_PATTERN.matcher(text); |
| | | if (relativeMatcher.find()) { |
| | | int amount = Integer.parseInt(relativeMatcher.group(2)); |
| | | String unit = relativeMatcher.group(3); |
| | | LocalDate start = switch (unit) { |
| | | case "天" -> today.minusDays(Math.max(amount - 1L, 0)); |
| | | case "å¨" -> today.minusWeeks(Math.max(amount, 1)).plusDays(1); |
| | | case "个æ", "æ" -> today.minusMonths(Math.max(amount, 1)).plusDays(1); |
| | | case "å¹´" -> today.minusYears(Math.max(amount, 1)).plusDays(1); |
| | | default -> today.minusDays(29); |
| | | }; |
| | | return new DateRange(start, today, "è¿" + amount + unit); |
| | | } |
| | | Matcher dateMatcher = DATE_PATTERN.matcher(text); |
| | | if (dateMatcher.find()) { |
| | | LocalDate start = parseLocalDate(dateMatcher.group(1)); |
| | | LocalDate end = dateMatcher.find() ? parseLocalDate(dateMatcher.group(1)) : start; |
| | | if (start != null && end != null) { |
| | | if (start.isAfter(end)) { |
| | | LocalDate temp = start; |
| | | start = end; |
| | | end = temp; |
| | | } |
| | | return new DateRange(start, end, start + "è³" + end); |
| | | } |
| | | } |
| | | return new DateRange(today.minusDays(29), today, "è¿30天"); |
| | | } |
| | | |
| | | private LocalDate parseLocalDate(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return LocalDate.parse(text.trim(), DATE_FMT); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private Date toDate(LocalDate localDate) { |
| | | return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private Date toExclusiveEndDate(LocalDate localDate) { |
| | | return Date.from(localDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private LocalDate toLocalDate(Date date) { |
| | | if (date == null) { |
| | | return null; |
| | | } |
| | | return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | } |
| | | |
| | | private String formatDate(LocalDate date) { |
| | | return date == null ? "" : date.format(DATE_FMT); |
| | | } |
| | | |
| | | private long daysBetween(LocalDate start, LocalDate end) { |
| | | if (start == null || end == null || start.isAfter(end)) { |
| | | return 0; |
| | | } |
| | | return end.toEpochDay() - start.toEpochDay(); |
| | | } |
| | | |
| | | private BigDecimal defaultDecimal(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private BigDecimal maxZero(BigDecimal value) { |
| | | return value == null || value.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private BigDecimal rate(BigDecimal numerator, BigDecimal denominator) { |
| | | if (denominator == null || denominator.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | return defaultDecimal(numerator).divide(denominator, 6, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private String toPercent(BigDecimal decimal) { |
| | | if (decimal == null) { |
| | | return "0.00%"; |
| | | } |
| | | BigDecimal rate = decimal.multiply(ONE_HUNDRED).setScale(2, RoundingMode.HALF_UP); |
| | | return rate.toPlainString() + "%"; |
| | | } |
| | | |
| | | private BigDecimal avgRate(List<OrderProfitMetric> metrics) { |
| | | if (metrics == null || metrics.isEmpty()) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | BigDecimal sum = metrics.stream().map(OrderProfitMetric::profitRate).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | return sum.divide(new BigDecimal(metrics.size()), 6, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private BigDecimal estimateLaborCost(ProductionAccount account, Map<String, BigDecimal> salaryQuotaByOperation) { |
| | | BigDecimal salaryQuota = salaryQuotaByOperation.getOrDefault(safe(account.getTechnologyOperationName()), BigDecimal.ZERO); |
| | | BigDecimal finishedNum = defaultDecimal(account.getFinishedNum()); |
| | | BigDecimal workHours = defaultDecimal(account.getWorkHours()); |
| | | if (salaryQuota.compareTo(BigDecimal.ZERO) > 0 && finishedNum.compareTo(BigDecimal.ZERO) > 0) { |
| | | return finishedNum.multiply(salaryQuota); |
| | | } |
| | | if (salaryQuota.compareTo(BigDecimal.ZERO) > 0 && workHours.compareTo(BigDecimal.ZERO) > 0) { |
| | | return workHours.multiply(salaryQuota); |
| | | } |
| | | if (workHours.compareTo(BigDecimal.ZERO) > 0) { |
| | | return workHours; |
| | | } |
| | | return finishedNum; |
| | | } |
| | | |
| | | private List<Long> parseIdList(String raw) { |
| | | if (!StringUtils.hasText(raw)) { |
| | | return List.of(); |
| | | } |
| | | String text = raw.replace("[", "").replace("]", "").replace(" ", ""); |
| | | if (!StringUtils.hasText(text)) { |
| | | return List.of(); |
| | | } |
| | | List<Long> result = new ArrayList<>(); |
| | | for (String part : text.split(",")) { |
| | | if (!StringUtils.hasText(part)) { |
| | | continue; |
| | | } |
| | | try { |
| | | result.add(Long.parseLong(part.trim())); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private int keywordHitCount(List<String> keywords, String question) { |
| | | if (!StringUtils.hasText(question) || keywords == null) { |
| | | return 0; |
| | | } |
| | | int count = 0; |
| | | for (String keyword : keywords) { |
| | | if (question.contains(keyword)) { |
| | | count++; |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | private String normalizeForMatch(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return ""; |
| | | } |
| | | return text.replace("ï¼", "") |
| | | .replace(",", "") |
| | | .replace("ã", "") |
| | | .replace(".", "") |
| | | .replace("ï¼", "") |
| | | .replace("!", "") |
| | | .replace("ï¼", "") |
| | | .replace("?", "") |
| | | .replace("ï¼", "") |
| | | .replace(":", "") |
| | | .replace("ï¼", "") |
| | | .replace(";", "") |
| | | .replace(" ", "") |
| | | .trim(); |
| | | } |
| | | |
| | | private String safe(Object value) { |
| | | return value == null ? "" : String.valueOf(value).replace('\n', ' ').replace('\r', ' ').trim(); |
| | | } |
| | | |
| | | private LoginUser currentLoginUser(String memoryId) { |
| | | LoginUser loginUser = aiSessionUserContext.get(memoryId); |
| | | if (loginUser != null) { |
| | | return loginUser; |
| | | } |
| | | return SecurityUtils.getLoginUser(); |
| | | } |
| | | |
| | | private Map<String, Object> rangeSummary(DateRange range, int count, String keyword) { |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("count", count); |
| | | summary.put("keyword", safe(keyword)); |
| | | return summary; |
| | | } |
| | | |
| | | private Long toLongOrNull(String value) { |
| | | if (!StringUtils.hasText(value)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return Long.valueOf(value.trim()); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private <T> List<T> defaultList(List<T> list) { |
| | | return list == null ? List.of() : list; |
| | | } |
| | | |
| | | private <T> void applyTenantFilter(LambdaQueryWrapper<T> wrapper, Long tenantId, SFunction<T, Long> field) { |
| | | if (tenantId != null) { |
| | | wrapper.eq(field, tenantId); |
| | | } |
| | | } |
| | | |
| | | private <T> void applyDeptFilter(LambdaQueryWrapper<T> wrapper, Long deptId, SFunction<T, Long> field) { |
| | | if (deptId != null) { |
| | | wrapper.eq(field, deptId); |
| | | } |
| | | } |
| | | |
| | | private List<KnowledgeDoc> financeKnowledgeBase() { |
| | | return List.of( |
| | | new KnowledgeDoc( |
| | | "婿¶¦ä¸éåææ¡æ¶", |
| | | List.of("婿¶¦ä¸é", "äºæè®¢å", "æ¯å©ç", "åå©ç"), |
| | | "å
çæ¶å
¥ç«¯ï¼è®¢åç»æãåä»·ã交ä»å»¶è¿ï¼ï¼åçææ¬ç«¯ï¼ææãäººå·¥ãææ§ãæèï¼ï¼æåçç°é端ï¼å款ãè´¦æãåè´¦é£é©ï¼ã", |
| | | List.of("sales_ledger", "sales_ledger_product", "production_account", "device_ledger", "account_statement"), |
| | | List.of("为ä»ä¹æ¬æå©æ¶¦ä¸éï¼", "åªäºè®¢åäºææä¸¥éï¼", "ææ¬ä¸åæ¥èªåªä¸ªå·¥åºï¼") |
| | | ), |
| | | new KnowledgeDoc( |
| | | "åºåèµéå ç¨è¯æ", |
| | | List.of("åºå积å", "åæ»åºå", "å¨è½¬ç", "èµéå ç¨"), |
| | | "åºåèµéè¯æéç¹çï¼åºåä»·å¼ãè¿30天åºåºææ¬ã忻天æ°ãè¶
卿¯ä¾ï¼å½¢æå»åºåä¸éè´èå¥èå¨çç¥ã", |
| | | List.of("stock_inventory", "procurement_record_storage", "procurement_record_out"), |
| | | List.of("åªäºç©æèµéå ç¨æé«ï¼", "åªäºåºåè¶
è¿90天æªå¨è½¬ï¼", "åºåå¨è½¬å¤©æ°æ¯å¦å¼å¸¸ï¼") |
| | | ), |
| | | new KnowledgeDoc( |
| | | "ç°éæµä¸è´¦æ¬¾é£é©", |
| | | List.of("ç°éæµ", "åºæ¶", "åºä»", "忬¾", "èµé缺å£"), |
| | | "ç°éæµå¤æè¦ç»åæ¶æ¬¾ã仿¬¾ãåºæ¶åºä»ä½é¢ä¸é¢æµåæµéï¼éç¹å
³æ³¨é«ä½é¢å®¢æ·åé«éä¸ä»æ¬¾ä¾åºåã", |
| | | List.of("account_sales_collection", "account_purchase_payment", "account_statement"), |
| | | List.of("æªæ¥ä¸ä¸ªææ¯å¦æèµé缺å£ï¼", "åªä¸ªå®¢æ·å款é£é©æé«ï¼", "仿¬¾ååæå¤§çæ¯åªäºä¾åºåï¼") |
| | | ), |
| | | new KnowledgeDoc( |
| | | "ä¸è´¢ä¸ä½åå£å¾", |
| | | List.of("ä¸è´¢èå", "ä¸è´¢èå¨", "å£å¾", "驾驶è±"), |
| | | "订å婿¶¦å£å¾=é宿¶å
¥-ææææ¬-äººå·¥ææ¬-è®¾å¤ææ§-æèææ¬ï¼ç»è¥é©¾é©¶è±èå¨è®¢åãç产ãåºåã设å¤ãè´¦æ¬¾æ°æ®ã", |
| | | List.of("sales_ledger", "production_operation_task", "production_product_main", "device_ledger", "stock_inventory", "account_statement"), |
| | | List.of("订å婿¶¦çå¦ä½è®¡ç®ï¼", "ç»è¥é©¾é©¶è±æ ¸å¿ææ æåªäºï¼") |
| | | ) |
| | | ); |
| | | } |
| | | |
| | | private String jsonResponse(boolean success, |
| | | String type, |
| | | String description, |
| | | Map<String, Object> summary, |
| | | Map<String, Object> data, |
| | | Map<String, Object> charts) { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("success", success); |
| | | result.put("type", type); |
| | | result.put("description", description); |
| | | result.put("summary", summary == null ? Map.of() : summary); |
| | | result.put("data", data == null ? Map.of() : data); |
| | | result.put("charts", charts == null ? Map.of() : charts); |
| | | return JSON.toJSONString(result); |
| | | } |
| | | |
| | | private record DateRange(LocalDate start, LocalDate end, String label) { |
| | | } |
| | | |
| | | private record OrderProfitMetric(Long ledgerId, |
| | | String salesContractNo, |
| | | String customerName, |
| | | String projectName, |
| | | LocalDate entryDate, |
| | | LocalDate deliveryDate, |
| | | BigDecimal revenue, |
| | | BigDecimal materialCost, |
| | | BigDecimal laborCost, |
| | | BigDecimal depreciationCost, |
| | | BigDecimal scrapCost, |
| | | BigDecimal totalCost, |
| | | BigDecimal profit, |
| | | BigDecimal profitRate, |
| | | String riskLevel, |
| | | List<String> reasons, |
| | | String suggestion) { |
| | | } |
| | | |
| | | private record AnalysisBundle(List<OrderProfitMetric> orderMetrics, |
| | | Map<String, BigDecimal> processCostRanking, |
| | | BigDecimal totalRevenue, |
| | | BigDecimal totalMaterialCost, |
| | | BigDecimal totalLaborCost, |
| | | BigDecimal totalDepreciationCost, |
| | | BigDecimal totalScrapCost, |
| | | BigDecimal totalCost, |
| | | BigDecimal totalProfit) { |
| | | private static AnalysisBundle empty() { |
| | | return new AnalysisBundle(List.of(), Map.of(), BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, |
| | | BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO); |
| | | } |
| | | } |
| | | |
| | | private record MaterialCostResult(Map<Long, BigDecimal> materialCostByLedgerId, |
| | | Map<Long, BigDecimal> avgUnitCostByModelId) { |
| | | } |
| | | |
| | | private record ProductionCostContext(Map<Long, BigDecimal> laborCostByLedgerId, |
| | | Map<Long, BigDecimal> scrapCostByLedgerId, |
| | | Map<String, BigDecimal> processCostRanking) { |
| | | private static ProductionCostContext empty() { |
| | | return new ProductionCostContext(Map.of(), Map.of(), Map.of()); |
| | | } |
| | | } |
| | | |
| | | private record InventoryMetric(Long modelId, |
| | | String productName, |
| | | String modelName, |
| | | BigDecimal quantity, |
| | | BigDecimal lockedQuantity, |
| | | BigDecimal avgUnitCost, |
| | | BigDecimal inventoryValue, |
| | | BigDecimal outboundQuantity, |
| | | long stagnantDays, |
| | | boolean overstock) { |
| | | } |
| | | |
| | | private static class InventoryMetricBuilder { |
| | | private final Long modelId; |
| | | private BigDecimal quantity = BigDecimal.ZERO; |
| | | private BigDecimal lockedQuantity = BigDecimal.ZERO; |
| | | private BigDecimal warnNum = BigDecimal.ZERO; |
| | | private LocalDateTime firstInTime; |
| | | |
| | | private InventoryMetricBuilder(Long modelId) { |
| | | this.modelId = modelId; |
| | | } |
| | | |
| | | private void addQuantity(BigDecimal quantity) { |
| | | this.quantity = this.quantity.add(quantity); |
| | | } |
| | | |
| | | private void addLockedQuantity(BigDecimal lockedQuantity) { |
| | | this.lockedQuantity = this.lockedQuantity.add(lockedQuantity); |
| | | } |
| | | |
| | | private void addWarnNum(BigDecimal warnNum) { |
| | | this.warnNum = this.warnNum.max(warnNum); |
| | | } |
| | | |
| | | private void updateFirstInTime(LocalDateTime createTime) { |
| | | if (this.firstInTime == null || createTime.isBefore(this.firstInTime)) { |
| | | this.firstInTime = createTime; |
| | | } |
| | | } |
| | | |
| | | private Long modelId() { |
| | | return modelId; |
| | | } |
| | | |
| | | private BigDecimal quantity() { |
| | | return quantity; |
| | | } |
| | | |
| | | private BigDecimal lockedQuantity() { |
| | | return lockedQuantity; |
| | | } |
| | | |
| | | private BigDecimal warnNum() { |
| | | return warnNum; |
| | | } |
| | | |
| | | private LocalDateTime firstInTime() { |
| | | return firstInTime; |
| | | } |
| | | } |
| | | |
| | | private record OutboundStats(Map<Long, BigDecimal> outboundQtyByModel, |
| | | Map<Long, LocalDateTime> lastOutboundTimeByModel, |
| | | BigDecimal totalOutboundCost) { |
| | | private static OutboundStats empty() { |
| | | return new OutboundStats(Map.of(), Map.of(), BigDecimal.ZERO); |
| | | } |
| | | } |
| | | |
| | | private record MonthlyCashFlow(String month, BigDecimal income, BigDecimal expense, BigDecimal netFlow) { |
| | | } |
| | | |
| | | private record StatementMetric(String entityId, |
| | | BigDecimal closingBalance, |
| | | BigDecimal planAmount, |
| | | BigDecimal actualAmount, |
| | | String statementMonth) { |
| | | } |
| | | |
| | | private record StatementSnapshot(BigDecimal receivableTotal, |
| | | BigDecimal payableTotal, |
| | | List<StatementMetric> receivableTop, |
| | | List<StatementMetric> payableTop) { |
| | | private static StatementSnapshot empty() { |
| | | return new StatementSnapshot(BigDecimal.ZERO, BigDecimal.ZERO, List.of(), List.of()); |
| | | } |
| | | } |
| | | |
| | | private record KnowledgeDoc(String topic, |
| | | List<String> keywords, |
| | | String knowledge, |
| | | List<String> relatedTables, |
| | | List<String> suggestedQuestions) { |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.tools; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| | | import com.ruoyi.ai.context.AiSessionUserContext; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.device.mapper.DeviceDefectRecordMapper; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceDefectRecord; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementExceptionRecordMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementExceptionRecord; |
| | | import com.ruoyi.production.mapper.ProductionOperationTaskMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionPlanMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.ProductionOperationTask; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | | import com.ruoyi.production.pojo.ProductionPlan; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityUnqualifiedMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.quality.pojo.QualityUnqualified; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import dev.langchain4j.agent.tool.P; |
| | | import dev.langchain4j.agent.tool.Tool; |
| | | import dev.langchain4j.agent.tool.ToolMemoryId; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | public class ManufacturingAgentTools { |
| | | |
| | | private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final int DEFAULT_LIMIT = 10; |
| | | private static final int MAX_LIMIT = 30; |
| | | private static final int DEVICE_REPAIR_STATUS_PENDING = 0; |
| | | |
| | | private final ProductionPlanMapper productionPlanMapper; |
| | | private final ProductionOrderMapper productionOrderMapper; |
| | | private final ProductionOperationTaskMapper productionOperationTaskMapper; |
| | | private final ProductionProductMainMapper productionProductMainMapper; |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | private final DeviceRepairMapper deviceRepairMapper; |
| | | private final DeviceDefectRecordMapper deviceDefectRecordMapper; |
| | | private final QualityInspectMapper qualityInspectMapper; |
| | | private final QualityUnqualifiedMapper qualityUnqualifiedMapper; |
| | | private final StockInventoryMapper stockInventoryMapper; |
| | | private final ProcurementExceptionRecordMapper procurementExceptionRecordMapper; |
| | | private final AiSessionUserContext aiSessionUserContext; |
| | | |
| | | public ManufacturingAgentTools(ProductionPlanMapper productionPlanMapper, |
| | | ProductionOrderMapper productionOrderMapper, |
| | | ProductionOperationTaskMapper productionOperationTaskMapper, |
| | | ProductionProductMainMapper productionProductMainMapper, |
| | | DeviceLedgerMapper deviceLedgerMapper, |
| | | DeviceRepairMapper deviceRepairMapper, |
| | | DeviceDefectRecordMapper deviceDefectRecordMapper, |
| | | QualityInspectMapper qualityInspectMapper, |
| | | QualityUnqualifiedMapper qualityUnqualifiedMapper, |
| | | StockInventoryMapper stockInventoryMapper, |
| | | ProcurementExceptionRecordMapper procurementExceptionRecordMapper, |
| | | AiSessionUserContext aiSessionUserContext) { |
| | | this.productionPlanMapper = productionPlanMapper; |
| | | this.productionOrderMapper = productionOrderMapper; |
| | | this.productionOperationTaskMapper = productionOperationTaskMapper; |
| | | this.productionProductMainMapper = productionProductMainMapper; |
| | | this.deviceLedgerMapper = deviceLedgerMapper; |
| | | this.deviceRepairMapper = deviceRepairMapper; |
| | | this.deviceDefectRecordMapper = deviceDefectRecordMapper; |
| | | this.qualityInspectMapper = qualityInspectMapper; |
| | | this.qualityUnqualifiedMapper = qualityUnqualifiedMapper; |
| | | this.stockInventoryMapper = stockInventoryMapper; |
| | | this.procurementExceptionRecordMapper = procurementExceptionRecordMapper; |
| | | this.aiSessionUserContext = aiSessionUserContext; |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢å¶é ä¸å¡åæ°æ®", value = "æä¸å¡åæ¥è¯¢ç产ç°åºã计åãå·¥åã设å¤ãè´¨éãç©æãå¼å¸¸å¤çç¸å
³æ°æ®ã") |
| | | public String queryDomain(@ToolMemoryId String memoryId, |
| | | @P(value = "ä¸å¡åï¼site/plan/workorder/device/quality/material/exception") String domain, |
| | | @P(value = "å
³é®åï¼å¯ä¸ä¼ ", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼ä¾å¦ä»å¹´ãæ¬æãè¿30天", required = false) String timeRange) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | int finalLimit = normalizeLimit(limit); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange); |
| | | boolean hasTimeConstraint = hasTimeConstraint(startDate, endDate, timeRange); |
| | | String normalizedDomain = normalizeDomain(domain); |
| | | |
| | | return switch (normalizedDomain) { |
| | | case "site" -> siteSnapshot(loginUser, range); |
| | | case "plan" -> listProductionPlans(loginUser, keyword, finalLimit, range); |
| | | case "workorder" -> listWorkOrders(loginUser, keyword, finalLimit, range); |
| | | case "device" -> isRepairIntent(keyword, timeRange) |
| | | ? listDeviceRepairs(loginUser, normalizeDeviceQueryKeyword(keyword, timeRange), finalLimit, range, hasTimeConstraint) |
| | | : listDevices(loginUser, normalizeDeviceQueryKeyword(keyword, timeRange), finalLimit); |
| | | case "repair" -> listDeviceRepairs(loginUser, normalizeDeviceQueryKeyword(keyword, timeRange), finalLimit, range, hasTimeConstraint); |
| | | case "quality" -> listQualityIssues(loginUser, keyword, finalLimit, range); |
| | | case "material" -> listMaterialInventory(loginUser, keyword, finalLimit); |
| | | case "exception" -> listExceptions(loginUser, keyword, finalLimit, range); |
| | | default -> jsonResponse(false, "manufacturing_query", "䏿¯æçä¸å¡å: " + safe(domain), Map.of(), Map.of(), Map.of()); |
| | | }; |
| | | } |
| | | |
| | | @Tool(name = "å¶é é¢è¦çæ¿", value = "计ç®è®¡åãå·¥åã设å¤ãè´¨éãç©æãå¼å¸¸å¤ççé¢è¦ä¿¡æ¯ã") |
| | | public String getWarningBoard(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼ä¾å¦ä»å¤©ãæ¬å¨ãæ¬æãè¿30天", required = false) String timeRange) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange); |
| | | LocalDate today = LocalDate.now(); |
| | | |
| | | long overduePlanCount = countOverduePlans(loginUser, today); |
| | | long overdueWorkOrderCount = countOverdueWorkOrders(loginUser, today); |
| | | long pendingRepairCount = countPendingRepairs(loginUser); |
| | | long qualityOpenCount = countOpenQualityIssues(loginUser, range); |
| | | long lowStockCount = countLowStock(loginUser); |
| | | long exceptionCount = countExceptionRecords(loginUser, range); |
| | | |
| | | List<Map<String, Object>> warningItems = new ArrayList<>(); |
| | | if (overduePlanCount > 0) { |
| | | warningItems.add(warningItem("high", "计å龿", overduePlanCount, "æç产计åè¶
è¿éæ±æ¥æä»æªå®æ")); |
| | | } |
| | | if (overdueWorkOrderCount > 0) { |
| | | warningItems.add(warningItem("high", "å·¥å龿", overdueWorkOrderCount, "æå·¥å计åç»ææ¥æå·²è¿ä»æªå®å·¥")); |
| | | } |
| | | if (pendingRepairCount > 0) { |
| | | warningItems.add(warningItem("medium", "设å¤å¾
ç»´ä¿®", pendingRepairCount, "åå¨å¾
ç»´ä¿®/ç»´ä¿®ä¸ç设å¤")); |
| | | } |
| | | if (qualityOpenCount > 0) { |
| | | warningItems.add(warningItem("high", "è´¨éæªéç¯", qualityOpenCount, "å卿ªå¤ç宿çä¸åæ ¼è®°å½")); |
| | | } |
| | | if (lowStockCount > 0) { |
| | | warningItems.add(warningItem("medium", "ç©æä½åºå", lowStockCount, "åºåæ°éä½äºæçäºé¢è¦éå¼")); |
| | | } |
| | | if (exceptionCount > 0) { |
| | | warningItems.add(warningItem("medium", "å¼å¸¸è®°å½", exceptionCount, "æ¶é´èå´å
åå¨å¼å¸¸å¤çè®°å½")); |
| | | } |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("warningCount", warningItems.size()); |
| | | summary.put("overduePlanCount", overduePlanCount); |
| | | summary.put("overdueWorkOrderCount", overdueWorkOrderCount); |
| | | summary.put("pendingRepairCount", pendingRepairCount); |
| | | summary.put("qualityOpenCount", qualityOpenCount); |
| | | summary.put("lowStockCount", lowStockCount); |
| | | summary.put("exceptionCount", exceptionCount); |
| | | |
| | | return jsonResponse(true, "manufacturing_warning", "å·²è¿åå¶é é¢è¦çæ¿ã", summary, |
| | | Map.of("items", warningItems), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "å¶é ç»è¥åæ", value = "ææ¶é´èå´è¾åºå¶é å
³é®ææ ï¼æ¯ææ¥ãé®ãåæåºæ¯ã") |
| | | public String analyzeFactory(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-ddï¼å¯ä¸ä¼ ", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼ä¾å¦æ¬æãè¿30天", required = false) String timeRange) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange); |
| | | |
| | | long planTotal = countPlans(loginUser, range); |
| | | long planCompleted = countPlansByStatus(loginUser, range, 2); |
| | | long workOrderTotal = countWorkOrders(loginUser, range); |
| | | long workOrderCompleted = countWorkOrdersByStatus(loginUser, range, 2); |
| | | long workOrderInProgress = countWorkOrdersByStatus(loginUser, range, 1); |
| | | |
| | | long outputCount = countOutputs(loginUser, range); |
| | | long deviceTotal = countDevices(loginUser); |
| | | long pendingRepairCount = countPendingRepairs(loginUser); |
| | | long qualityInspectTotal = countQualityInspect(loginUser, range); |
| | | long qualityNgCount = countOpenQualityIssues(loginUser, range); |
| | | long materialSkuCount = countInventorySku(loginUser); |
| | | long lowStockCount = countLowStock(loginUser); |
| | | long exceptionCount = countExceptionRecords(loginUser, range); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("planTotal", planTotal); |
| | | summary.put("planCompleted", planCompleted); |
| | | summary.put("planCompletionRate", toRate(planCompleted, planTotal)); |
| | | summary.put("workOrderTotal", workOrderTotal); |
| | | summary.put("workOrderCompleted", workOrderCompleted); |
| | | summary.put("workOrderInProgress", workOrderInProgress); |
| | | summary.put("workOrderCompletionRate", toRate(workOrderCompleted, workOrderTotal)); |
| | | summary.put("outputCount", outputCount); |
| | | summary.put("deviceTotal", deviceTotal); |
| | | summary.put("pendingRepairCount", pendingRepairCount); |
| | | summary.put("qualityInspectTotal", qualityInspectTotal); |
| | | summary.put("qualityNgCount", qualityNgCount); |
| | | summary.put("qualityIssueRate", toRate(qualityNgCount, qualityInspectTotal)); |
| | | summary.put("materialSkuCount", materialSkuCount); |
| | | summary.put("lowStockCount", lowStockCount); |
| | | summary.put("exceptionCount", exceptionCount); |
| | | |
| | | List<Map<String, Object>> coreMetrics = List.of( |
| | | metric("计å宿ç", toRate(planCompleted, planTotal)), |
| | | metric("å·¥å宿ç", toRate(workOrderCompleted, workOrderTotal)), |
| | | metric("è´¨éå¼å¸¸ç", toRate(qualityNgCount, qualityInspectTotal)), |
| | | metric("ä½åºåå æ¯", toRate(lowStockCount, materialSkuCount)) |
| | | ); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("domainBarOption", buildDomainBarOption(summary)); |
| | | charts.put("qualityPieOption", buildQualityPieOption(qualityInspectTotal, qualityNgCount)); |
| | | |
| | | return jsonResponse(true, "manufacturing_analysis", "å·²è¿åå¶é åæç»æã", summary, |
| | | Map.of("coreMetrics", coreMetrics), charts); |
| | | } |
| | | |
| | | @Tool(name = "çæå¶é åç建议", value = "æ ¹æ®ç¨æ·é®é¢è¾åºå¯æ§è¡çåçå¨ä½å»ºè®®ï¼å
æ¬ç®æ ä¸å¡æ¥å£ãå¿
å¡«åæ®µå示ä¾ã") |
| | | public String planActions(@ToolMemoryId String memoryId, |
| | | @P("ç¨æ·è¯æ±åæ") String userQuery) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | List<Map<String, Object>> actionCards = new ArrayList<>(); |
| | | |
| | | if (!StringUtils.hasText(userQuery) || containsAny(userQuery, "å·¥å", "派工", "ä½ä¸")) { |
| | | actionCards.add(actionCard( |
| | | "workorder_assign", |
| | | "工忴¾å·¥", |
| | | "POST", |
| | | "/productionOperationTask/assign", |
| | | List.of("id", "userIds"), |
| | | Map.of("id", 10001, "userIds", "12,13"), |
| | | "å°å·¥ååé
ç»æå®äººåï¼éç¨äºç°åºè°åº¦ã")); |
| | | } |
| | | if (!StringUtils.hasText(userQuery) || containsAny(userQuery, "设å¤", "ç»´ä¿®", "æ
é")) { |
| | | actionCards.add(actionCard( |
| | | "device_repair_create", |
| | | "å建设å¤ç»´ä¿®å", |
| | | "POST", |
| | | "/device/repair", |
| | | List.of("deviceLedgerId", "deviceName", "repairName", "remark"), |
| | | Map.of("deviceLedgerId", 1001, "deviceName", "ç©ºåæºA-01", "repairName", "å¼ ä¸", "remark", "å¼å并伴鿏©å"), |
| | | "æ°å»ºç»´ä¿®åï¼è¿å
¥è®¾å¤å¼å¸¸å¤çéç¯ã")); |
| | | } |
| | | if (!StringUtils.hasText(userQuery) || containsAny(userQuery, "è´¨é", "ä¸åæ ¼", "éç¯")) { |
| | | actionCards.add(actionCard( |
| | | "quality_unqualified_deal", |
| | | "å¤çä¸åæ ¼å", |
| | | "POST", |
| | | "/quality/qualityUnqualified/deal", |
| | | List.of("id", "dealResult", "dealName"), |
| | | Map.of("id", 3001, "dealResult", "è¿å·¥å夿£", "dealName", "æå"), |
| | | "对ä¸åæ ¼è®°å½æ§è¡å¤ç½®å¹¶éç¯ã")); |
| | | } |
| | | if (!StringUtils.hasText(userQuery) || containsAny(userQuery, "ç©æ", "åºå", "è¡¥æ")) { |
| | | actionCards.add(actionCard( |
| | | "material_inbound", |
| | | "è¡¥å
åºå", |
| | | "POST", |
| | | "/stockInventory/addstockInventory", |
| | | List.of("productModelId", "batchNo", "qualitity"), |
| | | Map.of("productModelId", 5001, "batchNo", "B2026051601", "qualitity", 120), |
| | | "å½ä½åºåé¢è¦è§¦åæ¶ï¼å¢å åºåæ°éã")); |
| | | } |
| | | if (!StringUtils.hasText(userQuery) || containsAny(userQuery, "å¼å¸¸", "éè´å¼å¸¸", "æ¥æå¼å¸¸")) { |
| | | actionCards.add(actionCard( |
| | | "procurement_exception_add", |
| | | "ç»è®°å¼å¸¸è®°å½", |
| | | "POST", |
| | | "/procurementExceptionRecord/add", |
| | | List.of("purchaseLedgerId", "exceptionReason", "exceptionNum"), |
| | | Map.of("purchaseLedgerId", 888, "exceptionReason", "å°æç缺", "exceptionNum", 24), |
| | | "ç»è®°éè´/æ¥æå¼å¸¸ï¼ä¾¿äºåç»è¿½è¸ªååæã")); |
| | | } |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("actionCount", actionCards.size()); |
| | | summary.put("userId", loginUser.getUserId()); |
| | | summary.put("tenantId", loginUser.getTenantId()); |
| | | |
| | | return jsonResponse(true, "manufacturing_action_plan", "å·²çæåç建议ï¼è¯·å端å¼å¯¼ç¨æ·ç¡®è®¤åè°ç¨ç®æ ä¸å¡æ¥å£ã", |
| | | summary, Map.of("actionCards", actionCards), Map.of()); |
| | | } |
| | | |
| | | private String siteSnapshot(LoginUser loginUser, DateRange range) { |
| | | long planTotal = countPlans(loginUser, range); |
| | | long workOrderTotal = countWorkOrders(loginUser, range); |
| | | long outputCount = countOutputs(loginUser, range); |
| | | long deviceTotal = countDevices(loginUser); |
| | | long pendingRepairCount = countPendingRepairs(loginUser); |
| | | long qualityOpenCount = countOpenQualityIssues(loginUser, range); |
| | | long lowStockCount = countLowStock(loginUser); |
| | | long exceptionCount = countExceptionRecords(loginUser, range); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("planTotal", planTotal); |
| | | summary.put("workOrderTotal", workOrderTotal); |
| | | summary.put("outputCount", outputCount); |
| | | summary.put("deviceTotal", deviceTotal); |
| | | summary.put("pendingRepairCount", pendingRepairCount); |
| | | summary.put("qualityOpenCount", qualityOpenCount); |
| | | summary.put("lowStockCount", lowStockCount); |
| | | summary.put("exceptionCount", exceptionCount); |
| | | |
| | | return jsonResponse(true, "manufacturing_site_snapshot", "å·²è¿åç产ç°åºæ¦è§ã", summary, Map.of(), Map.of()); |
| | | } |
| | | |
| | | private String listProductionPlans(LoginUser loginUser, String keyword, int limit, DateRange range) { |
| | | LambdaQueryWrapper<ProductionPlan> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionPlan::getDeptId); |
| | | wrapper.ge(ProductionPlan::getRequiredDate, range.start()).le(ProductionPlan::getRequiredDate, range.end()); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(ProductionPlan::getMpsNo, keyword) |
| | | .or().like(ProductionPlan::getRemark, keyword) |
| | | .or().like(ProductionPlan::getSource, keyword)); |
| | | } |
| | | wrapper.orderByDesc(ProductionPlan::getRequiredDate, ProductionPlan::getId).last("limit " + limit); |
| | | |
| | | List<Map<String, Object>> items = defaultList(productionPlanMapper.selectList(wrapper)).stream() |
| | | .map(this::toPlanItem) |
| | | .collect(Collectors.toList()); |
| | | return jsonResponse(true, "manufacturing_plan_list", "å·²è¿åç产计åå表ã", |
| | | rangeSummary(range, items.size(), keyword), Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | private String listWorkOrders(LoginUser loginUser, String keyword, int limit, DateRange range) { |
| | | LambdaQueryWrapper<ProductionOperationTask> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionOperationTask::getDeptId); |
| | | wrapper.ge(ProductionOperationTask::getPlanStartTime, range.start()) |
| | | .le(ProductionOperationTask::getPlanEndTime, range.end()); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(ProductionOperationTask::getWorkOrderNo, keyword) |
| | | .or().like(ProductionOperationTask::getUserIds, keyword)); |
| | | } |
| | | wrapper.orderByDesc(ProductionOperationTask::getPlanEndTime, ProductionOperationTask::getId) |
| | | .last("limit " + limit); |
| | | |
| | | List<Map<String, Object>> items = defaultList(productionOperationTaskMapper.selectList(wrapper)).stream() |
| | | .map(this::toWorkOrderItem) |
| | | .collect(Collectors.toList()); |
| | | return jsonResponse(true, "manufacturing_workorder_list", "å·²è¿åå·¥åå表ã", |
| | | rangeSummary(range, items.size(), keyword), Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | private String listDevices(LoginUser loginUser, String keyword, int limit) { |
| | | LambdaQueryWrapper<DeviceLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceLedger::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), DeviceLedger::getDeptId); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(DeviceLedger::getDeviceName, keyword) |
| | | .or().like(DeviceLedger::getDeviceModel, keyword) |
| | | .or().like(DeviceLedger::getDeviceBrand, keyword)); |
| | | } |
| | | wrapper.orderByDesc(DeviceLedger::getId).last("limit " + limit); |
| | | |
| | | Map<Long, Long> pendingRepairMap = pendingRepairCountByDevice(loginUser); |
| | | List<Map<String, Object>> items = defaultList(deviceLedgerMapper.selectList(wrapper)).stream() |
| | | .map(item -> toDeviceItem(item, pendingRepairMap.getOrDefault(item.getId(), 0L))) |
| | | .collect(Collectors.toList()); |
| | | return jsonResponse(true, "manufacturing_device_list", "å·²è¿å设å¤å表ã", |
| | | Map.of("count", items.size(), "keyword", safe(keyword)), Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | private String listDeviceRepairs(LoginUser loginUser, String keyword, int limit, DateRange range, boolean hasTimeConstraint) { |
| | | LambdaQueryWrapper<DeviceRepair> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceRepair::getTenantId); |
| | | Long currentDeptId = loginUser.getCurrentDeptId(); |
| | | if (currentDeptId != null) { |
| | | wrapper.and(w -> w.eq(DeviceRepair::getDeptId, currentDeptId).or().isNull(DeviceRepair::getDeptId)); |
| | | } |
| | | if (hasTimeConstraint) { |
| | | wrapper.ge(DeviceRepair::getCreateTime, range.start().atStartOfDay()) |
| | | .lt(DeviceRepair::getCreateTime, range.end().plusDays(1).atStartOfDay()); |
| | | } |
| | | if (StringUtils.hasText(keyword)) { |
| | | List<Long> matchedDeviceIds = findDeviceLedgerIdsByKeyword(loginUser, keyword); |
| | | wrapper.and(w -> { |
| | | w.like(DeviceRepair::getDeviceName, keyword) |
| | | .or().like(DeviceRepair::getDeviceModel, keyword) |
| | | .or().like(DeviceRepair::getRemark, keyword) |
| | | .or().like(DeviceRepair::getRepairName, keyword) |
| | | .or().like(DeviceRepair::getMaintenanceName, keyword); |
| | | if (!matchedDeviceIds.isEmpty()) { |
| | | w.or().in(DeviceRepair::getDeviceLedgerId, matchedDeviceIds); |
| | | } |
| | | }); |
| | | } |
| | | wrapper.orderByDesc(DeviceRepair::getCreateTime, DeviceRepair::getId).last("limit " + limit); |
| | | |
| | | List<Map<String, Object>> items = defaultList(deviceRepairMapper.selectList(wrapper)).stream() |
| | | .map(this::toDeviceRepairItem) |
| | | .collect(Collectors.toList()); |
| | | return jsonResponse(true, "manufacturing_device_repair_list", "å·²è¿å设å¤ç»´ä¿®è®°å½ã", |
| | | rangeSummary(range, items.size(), keyword), Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | private String listQualityIssues(LoginUser loginUser, String keyword, int limit, DateRange range) { |
| | | LambdaQueryWrapper<QualityUnqualified> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), QualityUnqualified::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), QualityUnqualified::getDeptId); |
| | | wrapper.ge(QualityUnqualified::getCheckTime, toDate(range.start())) |
| | | .lt(QualityUnqualified::getCheckTime, toExclusiveEndDate(range.end())); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(QualityUnqualified::getProductName, keyword) |
| | | .or().like(QualityUnqualified::getDefectivePhenomena, keyword) |
| | | .or().like(QualityUnqualified::getDealResult, keyword)); |
| | | } |
| | | wrapper.orderByDesc(QualityUnqualified::getCheckTime, QualityUnqualified::getId).last("limit " + limit); |
| | | |
| | | List<Map<String, Object>> items = defaultList(qualityUnqualifiedMapper.selectList(wrapper)).stream() |
| | | .map(this::toQualityItem) |
| | | .collect(Collectors.toList()); |
| | | return jsonResponse(true, "manufacturing_quality_list", "å·²è¿åè´¨éå¼å¸¸å表ã", |
| | | rangeSummary(range, items.size(), keyword), Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | private String listMaterialInventory(LoginUser loginUser, String keyword, int limit) { |
| | | LambdaQueryWrapper<StockInventory> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), StockInventory::getDeptId); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(StockInventory::getBatchNo, keyword) |
| | | .or().like(StockInventory::getProductModelId, keyword)); |
| | | } |
| | | wrapper.orderByDesc(StockInventory::getId).last("limit " + limit); |
| | | |
| | | List<Map<String, Object>> items = defaultList(stockInventoryMapper.selectList(wrapper)).stream() |
| | | .map(this::toMaterialItem) |
| | | .collect(Collectors.toList()); |
| | | return jsonResponse(true, "manufacturing_material_list", "å·²è¿åç©æåºåå表ã", |
| | | Map.of("count", items.size(), "keyword", safe(keyword)), Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | private String listExceptions(LoginUser loginUser, String keyword, int limit, DateRange range) { |
| | | LambdaQueryWrapper<ProcurementExceptionRecord> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), ProcurementExceptionRecord::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProcurementExceptionRecord::getDeptId); |
| | | wrapper.ge(ProcurementExceptionRecord::getCreateTime, range.start().atStartOfDay()) |
| | | .lt(ProcurementExceptionRecord::getCreateTime, range.end().plusDays(1).atStartOfDay()); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.like(ProcurementExceptionRecord::getExceptionReason, keyword); |
| | | } |
| | | wrapper.orderByDesc(ProcurementExceptionRecord::getCreateTime, ProcurementExceptionRecord::getId) |
| | | .last("limit " + limit); |
| | | |
| | | List<Map<String, Object>> items = defaultList(procurementExceptionRecordMapper.selectList(wrapper)).stream() |
| | | .map(this::toExceptionItem) |
| | | .collect(Collectors.toList()); |
| | | return jsonResponse(true, "manufacturing_exception_list", "å·²è¿åå¼å¸¸å¤çå表ã", |
| | | rangeSummary(range, items.size(), keyword), Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | private long countPlans(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<ProductionPlan> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionPlan::getDeptId); |
| | | wrapper.ge(ProductionPlan::getRequiredDate, range.start()).le(ProductionPlan::getRequiredDate, range.end()); |
| | | return productionPlanMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countPlansByStatus(LoginUser loginUser, DateRange range, int status) { |
| | | LambdaQueryWrapper<ProductionPlan> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionPlan::getDeptId); |
| | | wrapper.ge(ProductionPlan::getRequiredDate, range.start()) |
| | | .le(ProductionPlan::getRequiredDate, range.end()) |
| | | .eq(ProductionPlan::getStatus, status); |
| | | return productionPlanMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countWorkOrders(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<ProductionOperationTask> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionOperationTask::getDeptId); |
| | | wrapper.ge(ProductionOperationTask::getPlanStartTime, range.start()) |
| | | .le(ProductionOperationTask::getPlanEndTime, range.end()); |
| | | return productionOperationTaskMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countWorkOrdersByStatus(LoginUser loginUser, DateRange range, int status) { |
| | | LambdaQueryWrapper<ProductionOperationTask> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionOperationTask::getDeptId); |
| | | wrapper.ge(ProductionOperationTask::getPlanStartTime, range.start()) |
| | | .le(ProductionOperationTask::getPlanEndTime, range.end()) |
| | | .eq(ProductionOperationTask::getStatus, status); |
| | | return productionOperationTaskMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countOutputs(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<ProductionProductMain> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionProductMain::getDeptId); |
| | | wrapper.ge(ProductionProductMain::getCreateTime, range.start().atStartOfDay()) |
| | | .lt(ProductionProductMain::getCreateTime, range.end().plusDays(1).atStartOfDay()); |
| | | return productionProductMainMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countDevices(LoginUser loginUser) { |
| | | LambdaQueryWrapper<DeviceLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceLedger::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), DeviceLedger::getDeptId); |
| | | return deviceLedgerMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countPendingRepairs(LoginUser loginUser) { |
| | | LambdaQueryWrapper<DeviceRepair> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceRepair::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), DeviceRepair::getDeptId); |
| | | wrapper.eq(DeviceRepair::getStatus, DEVICE_REPAIR_STATUS_PENDING); |
| | | return deviceRepairMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countQualityInspect(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<QualityInspect> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), QualityInspect::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), QualityInspect::getDeptId); |
| | | wrapper.ge(QualityInspect::getCheckTime, toDate(range.start())) |
| | | .lt(QualityInspect::getCheckTime, toExclusiveEndDate(range.end())); |
| | | return qualityInspectMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countOpenQualityIssues(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<QualityUnqualified> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), QualityUnqualified::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), QualityUnqualified::getDeptId); |
| | | wrapper.ge(QualityUnqualified::getCheckTime, toDate(range.start())) |
| | | .lt(QualityUnqualified::getCheckTime, toExclusiveEndDate(range.end())) |
| | | .ne(QualityUnqualified::getInspectState, 2); |
| | | return qualityUnqualifiedMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countInventorySku(LoginUser loginUser) { |
| | | LambdaQueryWrapper<StockInventory> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), StockInventory::getDeptId); |
| | | return stockInventoryMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countLowStock(LoginUser loginUser) { |
| | | LambdaQueryWrapper<StockInventory> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), StockInventory::getDeptId); |
| | | wrapper.isNotNull(StockInventory::getWarnNum); |
| | | List<StockInventory> stocks = defaultList(stockInventoryMapper.selectList(wrapper)); |
| | | return stocks.stream() |
| | | .filter(this::isLowStock) |
| | | .count(); |
| | | } |
| | | |
| | | private long countExceptionRecords(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<ProcurementExceptionRecord> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), ProcurementExceptionRecord::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProcurementExceptionRecord::getDeptId); |
| | | wrapper.ge(ProcurementExceptionRecord::getCreateTime, range.start().atStartOfDay()) |
| | | .lt(ProcurementExceptionRecord::getCreateTime, range.end().plusDays(1).atStartOfDay()); |
| | | return procurementExceptionRecordMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countOverduePlans(LoginUser loginUser, LocalDate today) { |
| | | LambdaQueryWrapper<ProductionPlan> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionPlan::getDeptId); |
| | | wrapper.lt(ProductionPlan::getRequiredDate, today).ne(ProductionPlan::getStatus, 2); |
| | | return productionPlanMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private long countOverdueWorkOrders(LoginUser loginUser, LocalDate today) { |
| | | LambdaQueryWrapper<ProductionOperationTask> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ProductionOperationTask::getDeptId); |
| | | wrapper.lt(ProductionOperationTask::getPlanEndTime, today).ne(ProductionOperationTask::getStatus, 2); |
| | | return productionOperationTaskMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | private Map<Long, Long> pendingRepairCountByDevice(LoginUser loginUser) { |
| | | LambdaQueryWrapper<DeviceRepair> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceRepair::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), DeviceRepair::getDeptId); |
| | | wrapper.eq(DeviceRepair::getStatus, DEVICE_REPAIR_STATUS_PENDING); |
| | | return defaultList(deviceRepairMapper.selectList(wrapper)).stream() |
| | | .filter(item -> item.getDeviceLedgerId() != null) |
| | | .collect(Collectors.groupingBy(DeviceRepair::getDeviceLedgerId, Collectors.counting())); |
| | | } |
| | | |
| | | private Map<String, Object> toPlanItem(ProductionPlan item) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("mpsNo", safe(item.getMpsNo())); |
| | | map.put("requiredDate", formatDate(item.getRequiredDate())); |
| | | map.put("promisedDeliveryDate", formatDate(item.getPromisedDeliveryDate())); |
| | | map.put("qtyRequired", item.getQtyRequired()); |
| | | map.put("quantityIssued", item.getQuantityIssued()); |
| | | map.put("status", item.getStatus()); |
| | | map.put("source", safe(item.getSource())); |
| | | map.put("remark", safe(item.getRemark())); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toWorkOrderItem(ProductionOperationTask item) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("workOrderNo", safe(item.getWorkOrderNo())); |
| | | map.put("productionOrderId", item.getProductionOrderId()); |
| | | map.put("planStartTime", formatDate(item.getPlanStartTime())); |
| | | map.put("planEndTime", formatDate(item.getPlanEndTime())); |
| | | map.put("actualStartTime", formatDate(item.getActualStartTime())); |
| | | map.put("actualEndTime", formatDate(item.getActualEndTime())); |
| | | map.put("planQuantity", item.getPlanQuantity()); |
| | | map.put("completeQuantity", item.getCompleteQuantity()); |
| | | map.put("status", item.getStatus()); |
| | | map.put("userIds", safe(item.getUserIds())); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toDeviceItem(DeviceLedger item, long pendingRepairCount) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("deviceName", safe(item.getDeviceName())); |
| | | map.put("deviceModel", safe(item.getDeviceModel())); |
| | | map.put("deviceBrand", safe(item.getDeviceBrand())); |
| | | map.put("status", safe(item.getStatus())); |
| | | map.put("storageLocation", safe(item.getStorageLocation())); |
| | | map.put("supplierName", safe(item.getSupplierName())); |
| | | map.put("pendingRepairCount", pendingRepairCount); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toDeviceRepairItem(DeviceRepair item) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("deviceLedgerId", item.getDeviceLedgerId()); |
| | | map.put("deviceName", safe(item.getDeviceName())); |
| | | map.put("deviceModel", safe(item.getDeviceModel())); |
| | | map.put("repairTime", formatDate(item.getRepairTime())); |
| | | map.put("repairName", safe(item.getRepairName())); |
| | | map.put("maintenanceName", safe(item.getMaintenanceName())); |
| | | map.put("maintenanceTime", formatDateTime(item.getMaintenanceTime())); |
| | | map.put("maintenanceResult", safe(item.getMaintenanceResult())); |
| | | map.put("acceptanceName", safe(item.getAcceptanceName())); |
| | | map.put("acceptanceTime", formatDateTime(item.getAcceptanceTime())); |
| | | map.put("status", item.getStatus()); |
| | | map.put("remark", safe(item.getRemark())); |
| | | map.put("createTime", formatDateTime(item.getCreateTime())); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toQualityItem(QualityUnqualified item) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("checkTime", formatDate(item.getCheckTime())); |
| | | map.put("inspectState", item.getInspectState()); |
| | | map.put("productId", item.getProductId()); |
| | | map.put("productName", safe(item.getProductName())); |
| | | map.put("model", safe(item.getModel())); |
| | | map.put("quantity", item.getQuantity()); |
| | | map.put("defectivePhenomena", safe(item.getDefectivePhenomena())); |
| | | map.put("dealResult", safe(item.getDealResult())); |
| | | map.put("dealName", safe(item.getDealName())); |
| | | map.put("dealTime", formatDate(item.getDealTime())); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toMaterialItem(StockInventory item) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("productModelId", item.getProductModelId()); |
| | | map.put("batchNo", safe(item.getBatchNo())); |
| | | map.put("qualitity", item.getQualitity()); |
| | | map.put("lockedQuantity", item.getLockedQuantity()); |
| | | map.put("warnNum", item.getWarnNum()); |
| | | map.put("lowStock", isLowStock(item)); |
| | | map.put("remark", safe(item.getRemark())); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toExceptionItem(ProcurementExceptionRecord item) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("purchaseLedgerId", item.getPurchaseLedgerId()); |
| | | map.put("exceptionReason", safe(item.getExceptionReason())); |
| | | map.put("exceptionNum", item.getExceptionNum()); |
| | | map.put("createTime", formatDateTime(item.getCreateTime())); |
| | | return map; |
| | | } |
| | | |
| | | private boolean isLowStock(StockInventory item) { |
| | | BigDecimal quantity = item.getQualitity(); |
| | | BigDecimal warnNum = item.getWarnNum(); |
| | | if (quantity == null || warnNum == null) { |
| | | return false; |
| | | } |
| | | return quantity.compareTo(warnNum) <= 0; |
| | | } |
| | | |
| | | private Map<String, Object> warningItem(String level, String title, long count, String detail) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("level", level); |
| | | map.put("title", title); |
| | | map.put("count", count); |
| | | map.put("detail", detail); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> actionCard(String code, |
| | | String name, |
| | | String method, |
| | | String targetApi, |
| | | List<String> requiredFields, |
| | | Map<String, Object> examplePayload, |
| | | String description) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("code", code); |
| | | map.put("name", name); |
| | | map.put("method", method); |
| | | map.put("targetApi", targetApi); |
| | | map.put("requiredFields", requiredFields); |
| | | map.put("examplePayload", examplePayload); |
| | | map.put("description", description); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> metric(String label, String value) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("label", label); |
| | | map.put("value", value); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> rangeSummary(DateRange range, int count, String keyword) { |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("count", count); |
| | | summary.put("keyword", safe(keyword)); |
| | | return summary; |
| | | } |
| | | |
| | | private Map<String, Object> buildDomainBarOption(Map<String, Object> summary) { |
| | | List<String> xData = List.of("计å", "å·¥å", "设å¤", "è´¨é", "ç©æ", "å¼å¸¸"); |
| | | List<Number> yData = List.of( |
| | | numberValue(summary.get("planTotal")), |
| | | numberValue(summary.get("workOrderTotal")), |
| | | numberValue(summary.get("deviceTotal")), |
| | | numberValue(summary.get("qualityNgCount")), |
| | | numberValue(summary.get("lowStockCount")), |
| | | numberValue(summary.get("exceptionCount")) |
| | | ); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "å¶é åå
³é®æ°é", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "æ°é", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildQualityPieOption(long inspectTotal, long ngCount) { |
| | | long passCount = Math.max(inspectTotal - ngCount, 0); |
| | | List<Map<String, Object>> data = List.of( |
| | | Map.of("name", "ä¸åæ ¼", "value", ngCount), |
| | | Map.of("name", "éä¸åæ ¼", "value", passCount) |
| | | ); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "è´¨éç»æåå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "item")); |
| | | option.put("series", List.of(Map.of("name", "è´¨é", "type", "pie", "radius", "60%", "data", data))); |
| | | return option; |
| | | } |
| | | |
| | | private int numberValue(Object value) { |
| | | if (value instanceof Number number) { |
| | | return number.intValue(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | private String toRate(long numerator, long denominator) { |
| | | if (denominator <= 0) { |
| | | return "0.00%"; |
| | | } |
| | | BigDecimal rate = new BigDecimal(numerator) |
| | | .multiply(new BigDecimal("100")) |
| | | .divide(new BigDecimal(denominator), 2, RoundingMode.HALF_UP); |
| | | return rate.toPlainString() + "%"; |
| | | } |
| | | |
| | | private String normalizeDomain(String domain) { |
| | | if (!StringUtils.hasText(domain)) { |
| | | return ""; |
| | | } |
| | | String value = domain.trim().toLowerCase(); |
| | | return switch (value) { |
| | | case "ç产ç°åº", "site", "factory", "workshop" -> "site"; |
| | | case "计å", "plan", "schedule" -> "plan"; |
| | | case "å·¥å", "workorder", "work_order", "task" -> "workorder"; |
| | | case "设å¤", "device", "equipment" -> "device"; |
| | | case "ç»´ä¿®", "repair", "maintenance" -> "repair"; |
| | | case "è´¨é", "quality", "qc" -> "quality"; |
| | | case "ç©æ", "material", "inventory", "stock" -> "material"; |
| | | case "å¼å¸¸", "exception", "abnormal" -> "exception"; |
| | | default -> value; |
| | | }; |
| | | } |
| | | |
| | | private boolean isRepairIntent(String keyword, String userQuery) { |
| | | String query = safe(userQuery); |
| | | return containsAny(safe(keyword), "ç»´ä¿®", "æ¥ä¿®", "æ£ä¿®", "ç»´æ¤") |
| | | || containsAny(query, "ç»´ä¿®", "æ¥ä¿®", "æ£ä¿®", "ç»´æ¤"); |
| | | } |
| | | |
| | | private String normalizeDeviceQueryKeyword(String keyword, String userQuery) { |
| | | String source = StringUtils.hasText(keyword) ? keyword : userQuery; |
| | | if (!StringUtils.hasText(source)) { |
| | | return null; |
| | | } |
| | | String cleaned = source |
| | | .replace("æ¥è¯¢", "") |
| | | .replace("æ¥ç", "") |
| | | .replace("帮æ", "") |
| | | .replace("请", "") |
| | | .replace("æ¥", "") |
| | | .replace("设å¤", "") |
| | | .replace("维修记å½", "") |
| | | .replace("ç»´ä¿®æ
åµ", "") |
| | | .replace("æ¥ä¿®è®°å½", "") |
| | | .replace("æ¥ä¿®æ
åµ", "") |
| | | .replace("ç»´ä¿®", "") |
| | | .replace("æ¥ä¿®", "") |
| | | .replace("æ
åµ", "") |
| | | .replace("è®°å½", "") |
| | | .replace("ä¿¡æ¯", "") |
| | | .replace("ç", "") |
| | | .replace("ä¸ä¸", "") |
| | | .trim(); |
| | | return cleaned.length() >= 2 ? cleaned : null; |
| | | } |
| | | |
| | | private List<Long> findDeviceLedgerIdsByKeyword(LoginUser loginUser, String keyword) { |
| | | if (!StringUtils.hasText(keyword)) { |
| | | return List.of(); |
| | | } |
| | | LambdaQueryWrapper<DeviceLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), DeviceLedger::getTenantId); |
| | | Long currentDeptId = loginUser.getCurrentDeptId(); |
| | | if (currentDeptId != null) { |
| | | wrapper.and(w -> w.eq(DeviceLedger::getDeptId, currentDeptId).or().isNull(DeviceLedger::getDeptId)); |
| | | } |
| | | wrapper.and(w -> w.like(DeviceLedger::getDeviceName, keyword) |
| | | .or().like(DeviceLedger::getDeviceModel, keyword) |
| | | .or().like(DeviceLedger::getDeviceBrand, keyword)); |
| | | wrapper.orderByDesc(DeviceLedger::getId).last("limit 200"); |
| | | return defaultList(deviceLedgerMapper.selectList(wrapper)).stream() |
| | | .map(DeviceLedger::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private boolean hasTimeConstraint(String startDate, String endDate, String userQuery) { |
| | | if (StringUtils.hasText(startDate) || StringUtils.hasText(endDate)) { |
| | | return true; |
| | | } |
| | | if (!StringUtils.hasText(userQuery)) { |
| | | return false; |
| | | } |
| | | String text = userQuery.trim(); |
| | | return containsAny(text, "ä»å¤©", "æ¨å¤©", "æ¬å¨", "ä¸å¨", "æ¬æ", "䏿", "ä»å¹´", "å»å¹´", "è¿", "æè¿"); |
| | | } |
| | | |
| | | private DateRange resolveDateRange(String startDate, String endDate, String timeRange) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate start = parseLocalDate(startDate); |
| | | LocalDate end = parseLocalDate(endDate); |
| | | if (start != null || end != null) { |
| | | LocalDate s = start != null ? start : end; |
| | | LocalDate e = end != null ? end : start; |
| | | if (s.isAfter(e)) { |
| | | LocalDate temp = s; |
| | | s = e; |
| | | e = temp; |
| | | } |
| | | return new DateRange(s, e, s + "è³" + e); |
| | | } |
| | | if (!StringUtils.hasText(timeRange)) { |
| | | return new DateRange(today.minusDays(29), today, "è¿30天"); |
| | | } |
| | | String text = timeRange.trim(); |
| | | if (text.contains("ä»å¤©")) { |
| | | return new DateRange(today, today, "ä»å¤©"); |
| | | } |
| | | if (text.contains("æ¬å¨")) { |
| | | LocalDate startOfWeek = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | return new DateRange(startOfWeek, today, "æ¬å¨"); |
| | | } |
| | | if (text.contains("æ¬æ")) { |
| | | return new DateRange(today.withDayOfMonth(1), today, "æ¬æ"); |
| | | } |
| | | if (text.contains("æ¬å¹´") || text.contains("ä»å¹´")) { |
| | | return new DateRange(today.withDayOfYear(1), today, "ä»å¹´"); |
| | | } |
| | | if (text.contains("å»å¹´")) { |
| | | LocalDate firstDay = today.minusYears(1).withDayOfYear(1); |
| | | LocalDate lastDay = today.minusYears(1).withMonth(12).withDayOfMonth(31); |
| | | return new DateRange(firstDay, lastDay, "å»å¹´"); |
| | | } |
| | | if (text.contains("䏿")) { |
| | | LocalDate startOfLastMonth = today.minusMonths(1).withDayOfMonth(1); |
| | | return new DateRange(startOfLastMonth, startOfLastMonth.withDayOfMonth(startOfLastMonth.lengthOfMonth()), "䏿"); |
| | | } |
| | | java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("(è¿|æè¿)(\\d+)(天|å¨|个æ|æ|å¹´)").matcher(text); |
| | | if (matcher.find()) { |
| | | int amount = Integer.parseInt(matcher.group(2)); |
| | | String unit = matcher.group(3); |
| | | LocalDate relativeStart = switch (unit) { |
| | | case "天" -> today.minusDays(Math.max(amount - 1L, 0)); |
| | | case "å¨" -> today.minusWeeks(Math.max(amount, 1)).plusDays(1); |
| | | case "个æ", "æ" -> today.minusMonths(Math.max(amount, 1)).plusDays(1); |
| | | case "å¹´" -> today.minusYears(Math.max(amount, 1)).plusDays(1); |
| | | default -> today.minusDays(29); |
| | | }; |
| | | return new DateRange(relativeStart, today, "è¿" + amount + unit); |
| | | } |
| | | return new DateRange(today.minusDays(29), today, "è¿30天"); |
| | | } |
| | | |
| | | private LocalDate parseLocalDate(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return null; |
| | | } |
| | | return LocalDate.parse(text.trim(), DATE_FMT); |
| | | } |
| | | |
| | | private Date toDate(LocalDate date) { |
| | | return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private Date toExclusiveEndDate(LocalDate date) { |
| | | return Date.from(date.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private String formatDate(LocalDate date) { |
| | | return date == null ? "" : DATE_FMT.format(date); |
| | | } |
| | | |
| | | private String formatDate(Date date) { |
| | | if (date == null) { |
| | | return ""; |
| | | } |
| | | return DATE_FMT.format(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); |
| | | } |
| | | |
| | | private String formatDateTime(LocalDateTime time) { |
| | | if (time == null) { |
| | | return ""; |
| | | } |
| | | return time.truncatedTo(ChronoUnit.SECONDS).toString().replace('T', ' '); |
| | | } |
| | | |
| | | private int normalizeLimit(Integer limit) { |
| | | if (limit == null || limit <= 0) { |
| | | return DEFAULT_LIMIT; |
| | | } |
| | | return Math.min(limit, MAX_LIMIT); |
| | | } |
| | | |
| | | private boolean containsAny(String text, String... values) { |
| | | for (String value : values) { |
| | | if (text.contains(value)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private <T> void applyTenantFilter(LambdaQueryWrapper<T> wrapper, Long tenantId, SFunction<T, Long> field) { |
| | | if (tenantId != null) { |
| | | wrapper.eq(field, tenantId); |
| | | } |
| | | } |
| | | |
| | | private <T> void applyDeptFilter(LambdaQueryWrapper<T> wrapper, Long deptId, SFunction<T, Long> field) { |
| | | if (deptId != null) { |
| | | wrapper.eq(field, deptId); |
| | | } |
| | | } |
| | | |
| | | private LoginUser currentLoginUser(String memoryId) { |
| | | LoginUser loginUser = aiSessionUserContext.get(memoryId); |
| | | if (loginUser != null) { |
| | | return loginUser; |
| | | } |
| | | return SecurityUtils.getLoginUser(); |
| | | } |
| | | |
| | | private String safe(Object value) { |
| | | return value == null ? "" : String.valueOf(value).replace('\n', ' ').replace('\r', ' '); |
| | | } |
| | | |
| | | private <T> List<T> defaultList(List<T> list) { |
| | | return list == null ? List.of() : list; |
| | | } |
| | | |
| | | private String jsonResponse(boolean success, |
| | | String type, |
| | | String description, |
| | | Map<String, Object> summary, |
| | | Map<String, Object> data, |
| | | Map<String, Object> charts) { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("success", success); |
| | | result.put("type", type); |
| | | result.put("description", description); |
| | | result.put("summary", summary == null ? Map.of() : summary); |
| | | result.put("data", data == null ? Map.of() : data); |
| | | result.put("charts", charts == null ? Map.of() : charts); |
| | | return JSON.toJSONString(result); |
| | | } |
| | | |
| | | private record DateRange(LocalDate start, LocalDate end, String label) { |
| | | } |
| | | } |
| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPaymentApplicationMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchaseInvoiceMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchaseInvoice; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.ai.context.AiSessionUserContext; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.purchase.mapper.InvoicePurchaseMapper; |
| | | import com.ruoyi.purchase.mapper.PaymentRegistrationMapper; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper; |
| | | import com.ruoyi.purchase.pojo.InvoicePurchase; |
| | | import com.ruoyi.purchase.pojo.PaymentRegistration; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.purchase.pojo.PurchaseReturnOrders; |
| | | import com.ruoyi.procurementrecord.mapper.InboundManagementMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.pojo.InboundManagement; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.purchase.pojo.PurchaseReturnOrders; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import dev.langchain4j.agent.tool.P; |
| | | import dev.langchain4j.agent.tool.Tool; |
| | | import dev.langchain4j.agent.tool.ToolMemoryId; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Comparator; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | public class PurchaseAgentTools { |
| | | |
| | | private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai"); |
| | | private static final int DEFAULT_LIMIT = 10; |
| | | private static final int MAX_LIMIT = 30; |
| | | |
| | | private final PurchaseLedgerMapper purchaseLedgerMapper; |
| | | private final PaymentRegistrationMapper paymentRegistrationMapper; |
| | | private final InvoicePurchaseMapper invoicePurchaseMapper; |
| | | private final PurchaseReturnOrdersMapper purchaseReturnOrdersMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final ProcurementRecordMapper procurementRecordMapper; |
| | | private final InboundManagementMapper inboundManagementMapper; |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final AccountPaymentApplicationMapper accountPaymentApplicationMapper; |
| | | private final AccountPurchaseInvoiceMapper accountPurchaseInvoiceMapper; |
| | | private final StockInRecordMapper stockInRecordMapper; |
| | | private final QualityInspectMapper qualityInspectMapper; |
| | | private final AiSessionUserContext aiSessionUserContext; |
| | | |
| | | public PurchaseAgentTools(PurchaseLedgerMapper purchaseLedgerMapper, |
| | | PaymentRegistrationMapper paymentRegistrationMapper, |
| | | InvoicePurchaseMapper invoicePurchaseMapper, |
| | | PurchaseReturnOrdersMapper purchaseReturnOrdersMapper, |
| | | SalesLedgerProductMapper salesLedgerProductMapper, |
| | | ProcurementRecordMapper procurementRecordMapper, |
| | | InboundManagementMapper inboundManagementMapper, |
| | | AccountPurchasePaymentMapper accountPurchasePaymentMapper, |
| | | AccountPaymentApplicationMapper accountPaymentApplicationMapper, |
| | | AccountPurchaseInvoiceMapper accountPurchaseInvoiceMapper, |
| | | StockInRecordMapper stockInRecordMapper, |
| | | QualityInspectMapper qualityInspectMapper, |
| | | AiSessionUserContext aiSessionUserContext) { |
| | | this.purchaseLedgerMapper = purchaseLedgerMapper; |
| | | this.paymentRegistrationMapper = paymentRegistrationMapper; |
| | | this.invoicePurchaseMapper = invoicePurchaseMapper; |
| | | this.purchaseReturnOrdersMapper = purchaseReturnOrdersMapper; |
| | | this.salesLedgerProductMapper = salesLedgerProductMapper; |
| | | this.procurementRecordMapper = procurementRecordMapper; |
| | | this.inboundManagementMapper = inboundManagementMapper; |
| | | this.accountPurchasePaymentMapper = accountPurchasePaymentMapper; |
| | | this.accountPaymentApplicationMapper = accountPaymentApplicationMapper; |
| | | this.accountPurchaseInvoiceMapper = accountPurchaseInvoiceMapper; |
| | | this.stockInRecordMapper = stockInRecordMapper; |
| | | this.qualityInspectMapper = qualityInspectMapper; |
| | | this.aiSessionUserContext = aiSessionUserContext; |
| | | } |
| | | |
| | |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange); |
| | | |
| | | List<PurchaseLedger> ledgers = queryLedgers(loginUser, range); |
| | | List<PaymentRegistration> payments = queryPayments(loginUser, range); |
| | | List<InvoicePurchase> invoices = queryInvoices(loginUser, range); |
| | | List<AccountPurchasePayment> payments = queryPayments(loginUser, range); |
| | | List<AccountPurchaseInvoice> invoices = queryInvoices(loginUser, range); |
| | | List<PurchaseReturnOrders> returns = queryReturns(loginUser, range); |
| | | |
| | | BigDecimal contractAmount = ledgers.stream() |
| | |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal paymentAmount = payments.stream() |
| | | .map(PaymentRegistration::getCurrentPaymentAmount) |
| | | .map(AccountPurchasePayment::getPaymentAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal invoiceAmount = invoices.stream() |
| | | .map(InvoicePurchase::getInvoiceAmount) |
| | | .map(this::invoiceAmountOf) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal returnAmount = returns.stream() |
| | |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, null); |
| | | List<Map<String, Object>> items = queryLedgers(loginUser, range).stream() |
| | | List<PurchaseLedger> matchedLedgers = queryLedgers(loginUser, range).stream() |
| | | .filter(ledger -> matchLedgerKeyword(ledger, keyword)) |
| | | .map(ledger -> toPendingPaymentItem(loginUser, ledger)) |
| | | .collect(Collectors.toList()); |
| | | Map<Long, BigDecimal> paidAmountByLedgerId = sumPaymentAmountByLedgerId(loginUser, matchedLedgers.stream() |
| | | .map(PurchaseLedger::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList())); |
| | | List<Map<String, Object>> items = matchedLedgers.stream() |
| | | .map(ledger -> toPendingPaymentItem(ledger, paidAmountByLedgerId.getOrDefault(ledger.getId(), BigDecimal.ZERO))) |
| | | .filter(Objects::nonNull) |
| | | .sorted(Comparator.comparing(item -> (BigDecimal) item.get("pendingAmount"), Comparator.reverseOrder())) |
| | | .limit(normalizeLimit(limit)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | BigDecimal totalContractAmount = items.stream() |
| | | .map(item -> asBigDecimal(item.get("contractAmount"))) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalPaidAmount = items.stream() |
| | | .map(item -> asBigDecimal(item.get("paidAmount"))) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal totalPendingAmount = items.stream() |
| | | .map(item -> asBigDecimal(item.get("pendingAmount"))) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | Map<String, Object> summary = rangeSummary(range, items.size()); |
| | | summary.put("pendingOrderCount", items.size()); |
| | | summary.put("totalContractAmount", totalContractAmount); |
| | | summary.put("totalPaidAmount", totalPaidAmount); |
| | | summary.put("totalPendingAmount", totalPendingAmount); |
| | | |
| | | return jsonResponse(true, "purchase_pending_payment_list", "å·²è¿åå¾
仿¬¾éè´åã", |
| | | rangeSummary(range, items.size()), Map.of("items", items), Map.of()); |
| | | summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢éè´éè´§æ
åµ", value = "ææ¶é´èå´æ¥è¯¢éè´éè´§åå表åéè´§éé¢ã") |
| | |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toPendingPaymentItem(LoginUser loginUser, PurchaseLedger ledger) { |
| | | private Map<String, Object> toPendingPaymentItem(PurchaseLedger ledger, BigDecimal paidAmount) { |
| | | BigDecimal contractAmount = defaultDecimal(ledger.getContractAmount()); |
| | | BigDecimal paidAmount = sumPaymentAmount(loginUser, ledger.getId()); |
| | | BigDecimal pendingAmount = contractAmount.subtract(paidAmount); |
| | | BigDecimal safePaidAmount = defaultDecimal(paidAmount); |
| | | BigDecimal pendingAmount = contractAmount.subtract(safePaidAmount); |
| | | if (pendingAmount.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return null; |
| | | } |
| | | Map<String, Object> item = toLedgerItem(ledger); |
| | | item.put("paidAmount", paidAmount); |
| | | item.put("paidAmount", safePaidAmount); |
| | | item.put("pendingAmount", pendingAmount); |
| | | return item; |
| | | } |
| | | |
| | | private BigDecimal sumPaymentAmount(LoginUser loginUser, Long purchaseLedgerId) { |
| | | LambdaQueryWrapper<PaymentRegistration> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), PaymentRegistration::getTenantId); |
| | | wrapper.eq(PaymentRegistration::getPurchaseLedgerId, purchaseLedgerId); |
| | | return defaultList(paymentRegistrationMapper.selectList(wrapper)).stream() |
| | | .map(PaymentRegistration::getCurrentPaymentAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | private Map<Long, BigDecimal> sumPaymentAmountByLedgerId(LoginUser loginUser, List<Long> purchaseLedgerIds) { |
| | | if (purchaseLedgerIds == null || purchaseLedgerIds.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | List<AccountPurchasePayment> payments = queryPayments(loginUser); |
| | | if (payments.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | |
| | | Map<Integer, AccountPaymentApplication> applicationById = queryPaymentApplications(payments); |
| | | if (applicationById.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | |
| | | Map<Long, StockInRecord> stockInRecordById = queryStockInRecords(applicationById.values()); |
| | | Map<Long, Long> purchaseLedgerIdByQualityInspectId = queryPurchaseLedgerIdByQualityInspectId(stockInRecordById.values()); |
| | | Set<Long> targetLedgerIdSet = new HashSet<>(purchaseLedgerIds); |
| | | Map<Long, BigDecimal> result = new HashMap<>(); |
| | | |
| | | for (AccountPurchasePayment payment : payments) { |
| | | if (payment.getAccountPaymentApplicationId() == null) { |
| | | continue; |
| | | } |
| | | AccountPaymentApplication application = applicationById.get(payment.getAccountPaymentApplicationId()); |
| | | if (application == null) { |
| | | continue; |
| | | } |
| | | Set<Long> ledgerIds = resolvePurchaseLedgerIds(application, stockInRecordById, purchaseLedgerIdByQualityInspectId); |
| | | if (ledgerIds.isEmpty()) { |
| | | continue; |
| | | } |
| | | BigDecimal amount = defaultDecimal(payment.getPaymentAmount()); |
| | | for (Long ledgerId : ledgerIds) { |
| | | if (targetLedgerIdSet.contains(ledgerId)) { |
| | | result.merge(ledgerId, amount, BigDecimal::add); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private Map<String, Object> toReturnItem(PurchaseReturnOrders item) { |
| | |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private List<PaymentRegistration> queryPayments(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<PaymentRegistration> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), PaymentRegistration::getTenantId); |
| | | wrapper.ge(PaymentRegistration::getPaymentDate, toDate(range.start())) |
| | | .lt(PaymentRegistration::getPaymentDate, toExclusiveEndDate(range.end())); |
| | | return defaultList(paymentRegistrationMapper.selectList(wrapper)); |
| | | private BigDecimal asBigDecimal(Object value) { |
| | | if (value == null) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | if (value instanceof BigDecimal decimal) { |
| | | return decimal; |
| | | } |
| | | if (value instanceof Number number) { |
| | | return new BigDecimal(String.valueOf(number)); |
| | | } |
| | | try { |
| | | return new BigDecimal(String.valueOf(value)); |
| | | } catch (Exception ignored) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | } |
| | | |
| | | private List<InvoicePurchase> queryInvoices(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<InvoicePurchase> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), InvoicePurchase::getTenantId); |
| | | wrapper.ge(InvoicePurchase::getIssueDate, range.start()) |
| | | .le(InvoicePurchase::getIssueDate, range.end()); |
| | | return defaultList(invoicePurchaseMapper.selectList(wrapper)); |
| | | private BigDecimal invoiceAmountOf(AccountPurchaseInvoice invoice) { |
| | | if (invoice == null) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | BigDecimal amount = defaultDecimal(invoice.getTaxInclusivePrice()); |
| | | if (amount.compareTo(BigDecimal.ZERO) > 0) { |
| | | return amount; |
| | | } |
| | | return defaultDecimal(invoice.getTaxExclusivelPrice()).add(defaultDecimal(invoice.getTaxPrice())); |
| | | } |
| | | |
| | | private List<AccountPurchasePayment> queryPayments(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<AccountPurchasePayment> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountPurchasePayment::getDeptId); |
| | | wrapper.ge(AccountPurchasePayment::getPaymentDate, range.start()) |
| | | .le(AccountPurchasePayment::getPaymentDate, range.end()) |
| | | .orderByDesc(AccountPurchasePayment::getPaymentDate, AccountPurchasePayment::getId); |
| | | return defaultList(accountPurchasePaymentMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<AccountPurchasePayment> queryPayments(LoginUser loginUser) { |
| | | LambdaQueryWrapper<AccountPurchasePayment> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountPurchasePayment::getDeptId); |
| | | return defaultList(accountPurchasePaymentMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<AccountPurchaseInvoice> queryInvoices(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<AccountPurchaseInvoice> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountPurchaseInvoice::getDeptId); |
| | | wrapper.ge(AccountPurchaseInvoice::getIssueDate, range.start()) |
| | | .le(AccountPurchaseInvoice::getIssueDate, range.end()) |
| | | .orderByDesc(AccountPurchaseInvoice::getIssueDate, AccountPurchaseInvoice::getId); |
| | | return defaultList(accountPurchaseInvoiceMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private Map<Integer, AccountPaymentApplication> queryPaymentApplications(List<AccountPurchasePayment> payments) { |
| | | List<Integer> ids = payments.stream() |
| | | .map(AccountPurchasePayment::getAccountPaymentApplicationId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (ids.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | return defaultList(accountPaymentApplicationMapper.selectBatchIds(ids)).stream() |
| | | .filter(item -> item.getId() != null) |
| | | .collect(Collectors.toMap(AccountPaymentApplication::getId, item -> item, (a, b) -> a)); |
| | | } |
| | | |
| | | private Map<Long, StockInRecord> queryStockInRecords(Collection<AccountPaymentApplication> applications) { |
| | | Set<Long> stockInRecordIds = new HashSet<>(); |
| | | for (AccountPaymentApplication application : applications) { |
| | | stockInRecordIds.addAll(parseLongIds(application.getStockInRecordIds())); |
| | | } |
| | | if (stockInRecordIds.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | return defaultList(stockInRecordMapper.selectBatchIds(stockInRecordIds)).stream() |
| | | .filter(item -> item.getId() != null) |
| | | .collect(Collectors.toMap(StockInRecord::getId, item -> item, (a, b) -> a)); |
| | | } |
| | | |
| | | private Map<Long, Long> queryPurchaseLedgerIdByQualityInspectId(Collection<StockInRecord> stockInRecords) { |
| | | Set<Long> qualityInspectIds = stockInRecords.stream() |
| | | .filter(Objects::nonNull) |
| | | .filter(item -> item.getRecordId() != null && "10".equals(safe(item.getRecordType()).trim())) |
| | | .map(StockInRecord::getRecordId) |
| | | .collect(Collectors.toSet()); |
| | | if (qualityInspectIds.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | return defaultList(qualityInspectMapper.selectBatchIds(qualityInspectIds)).stream() |
| | | .filter(item -> item.getId() != null && item.getPurchaseLedgerId() != null) |
| | | .collect(Collectors.toMap(QualityInspect::getId, QualityInspect::getPurchaseLedgerId, (a, b) -> a)); |
| | | } |
| | | |
| | | private Set<Long> resolvePurchaseLedgerIds(AccountPaymentApplication application, |
| | | Map<Long, StockInRecord> stockInRecordById, |
| | | Map<Long, Long> purchaseLedgerIdByQualityInspectId) { |
| | | Set<Long> result = new LinkedHashSet<>(); |
| | | for (Long stockInRecordId : parseLongIds(application.getStockInRecordIds())) { |
| | | StockInRecord stockInRecord = stockInRecordById.get(stockInRecordId); |
| | | if (stockInRecord == null || stockInRecord.getRecordId() == null) { |
| | | continue; |
| | | } |
| | | if (stockInRecord.getApprovalStatus() != null && stockInRecord.getApprovalStatus() != 1) { |
| | | continue; |
| | | } |
| | | String recordType = safe(stockInRecord.getRecordType()).trim(); |
| | | if ("7".equals(recordType)) { |
| | | result.add(stockInRecord.getRecordId()); |
| | | } else if ("10".equals(recordType)) { |
| | | Long purchaseLedgerId = purchaseLedgerIdByQualityInspectId.get(stockInRecord.getRecordId()); |
| | | if (purchaseLedgerId != null) { |
| | | result.add(purchaseLedgerId); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private List<Long> parseLongIds(String raw) { |
| | | if (!StringUtils.hasText(raw)) { |
| | | return List.of(); |
| | | } |
| | | List<Long> result = new ArrayList<>(); |
| | | for (String part : raw.split(",")) { |
| | | if (!StringUtils.hasText(part)) { |
| | | continue; |
| | | } |
| | | try { |
| | | result.add(Long.parseLong(part.trim())); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | private List<PurchaseReturnOrders> queryReturns(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<PurchaseReturnOrders> wrapper = new LambdaQueryWrapper<>(); |
| | |
| | | } |
| | | |
| | | private DateRange resolveDateRange(String startDate, String endDate, String timeRange) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate today = LocalDate.now(CHINA_ZONE_ID); |
| | | LocalDate start = parseLocalDate(startDate); |
| | | LocalDate end = parseLocalDate(endDate); |
| | | if (start != null || end != null) { |
| | |
| | | return new DateRange(today.minusDays(29), today, "è¿30天"); |
| | | } |
| | | String text = timeRange.trim(); |
| | | if (text.contains("ä»å¤©")) { |
| | | return new DateRange(today, today, "ä»å¤©"); |
| | | } |
| | | if (text.contains("æ¨å¤©")) { |
| | | LocalDate yesterday = today.minusDays(1); |
| | | return new DateRange(yesterday, yesterday, "æ¨å¤©"); |
| | | } |
| | | if (text.contains("æ¬å¨")) { |
| | | LocalDate startOfWeek = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | return new DateRange(startOfWeek, today, "æ¬å¨"); |
| | | } |
| | | if (text.contains("ä¸å¨")) { |
| | | LocalDate thisWeekStart = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | LocalDate startOfLastWeek = thisWeekStart.minusWeeks(1); |
| | | return new DateRange(startOfLastWeek, startOfLastWeek.plusDays(6), "ä¸å¨"); |
| | | } |
| | | if (text.contains("ä»å¹´") || text.contains("æ¬å¹´")) { |
| | | return new DateRange(today.withDayOfYear(1), today, "ä»å¹´"); |
| | | } |
| | |
| | | if (!StringUtils.hasText(text)) { |
| | | return null; |
| | | } |
| | | return LocalDate.parse(text.trim(), DATE_FMT); |
| | | try { |
| | | return LocalDate.parse(text.trim(), DATE_FMT); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private Date toDate(LocalDate localDate) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.ai.tools; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.ai.context.AiSessionUserContext; |
| | | import com.ruoyi.basic.dto.CustomerDto; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.vo.CustomerVo; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesQuotationMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesQuotation; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.stock.mapper.StockOutRecordMapper; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import dev.langchain4j.agent.tool.P; |
| | | import dev.langchain4j.agent.tool.Tool; |
| | | import dev.langchain4j.agent.tool.ToolMemoryId; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.YearMonth; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Component |
| | | public class SalesAgentTools { |
| | | |
| | | private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final int DEFAULT_LIMIT = 10; |
| | | private static final int MAX_LIMIT = 30; |
| | | private static final BigDecimal ONE_HUNDRED = new BigDecimal("100"); |
| | | private static final Pattern RELATIVE_PATTERN = Pattern.compile("(è¿|æè¿)?\\s*(\\d+)\\s*(天|å¨|个æ|æ|å¹´)"); |
| | | private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{4}-\\d{2}-\\d{2})"); |
| | | |
| | | private final CustomerMapper customerMapper; |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | private final SalesQuotationMapper salesQuotationMapper; |
| | | private final ShippingInfoMapper shippingInfoMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final StockOutRecordMapper stockOutRecordMapper; |
| | | private final AiSessionUserContext aiSessionUserContext; |
| | | |
| | | public SalesAgentTools(CustomerMapper customerMapper, |
| | | SalesLedgerMapper salesLedgerMapper, |
| | | SalesQuotationMapper salesQuotationMapper, |
| | | ShippingInfoMapper shippingInfoMapper, |
| | | AccountSalesCollectionMapper accountSalesCollectionMapper, |
| | | StockOutRecordMapper stockOutRecordMapper, |
| | | AiSessionUserContext aiSessionUserContext) { |
| | | this.customerMapper = customerMapper; |
| | | this.salesLedgerMapper = salesLedgerMapper; |
| | | this.salesQuotationMapper = salesQuotationMapper; |
| | | this.shippingInfoMapper = shippingInfoMapper; |
| | | this.accountSalesCollectionMapper = accountSalesCollectionMapper; |
| | | this.stockOutRecordMapper = stockOutRecordMapper; |
| | | this.aiSessionUserContext = aiSessionUserContext; |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢å®¢æ·æ¡£æ¡", value = "æç§æµ·/å
¬æµ·ç±»ååå
³é®è¯æ¥è¯¢å®¢æ·æ¡£æ¡å表") |
| | | public String listCustomerProfiles(@ToolMemoryId String memoryId, |
| | | @P(value = "å®¢æ·æ± ç±»åï¼å¯é private/public", required = false) String seaType, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
客æ·åç§°/è系人/çµè¯", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | CustomerDto customerDto = new CustomerDto(); |
| | | customerDto.setType(normalizeSeaType(seaType)); |
| | | customerDto.setUsageStatus(1L); |
| | | |
| | | List<CustomerVo> rows = defaultList(customerMapper.list(customerDto, loginUser.getUserId())); |
| | | List<CustomerVo> filtered = rows.stream() |
| | | .filter(item -> matchCustomerKeyword(item, keyword)) |
| | | .sorted(Comparator.comparing(CustomerVo::getId, Comparator.nullsLast(Comparator.reverseOrder()))) |
| | | .limit(normalizeLimit(limit)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<Map<String, Object>> items = filtered.stream().map(item -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("customerName", safe(item.getCustomerName())); |
| | | map.put("customerType", safe(item.getCustomerType())); |
| | | map.put("contactPerson", safe(item.getContactPerson())); |
| | | map.put("contactPhone", safe(item.getContactPhone())); |
| | | map.put("companyPhone", safe(item.getCompanyPhone())); |
| | | map.put("maintainer", safe(item.getMaintainer())); |
| | | map.put("maintenanceTime", formatDate(item.getMaintenanceTime())); |
| | | map.put("usageUserName", safe(item.getUsageUserName())); |
| | | map.put("seaType", customerSeaTypeName(item.getType())); |
| | | map.put("isAssigned", item.getIsAssigned()); |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("count", items.size()); |
| | | summary.put("seaType", seaType == null ? "all" : seaType); |
| | | summary.put("keyword", safe(keyword)); |
| | | summary.put("userId", loginUser.getUserId()); |
| | | |
| | | return jsonResponse(true, "sales_customer_profile_list", "å·²è¿åå®¢æ·æ¡£æ¡å表", summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢é宿¥ä»·", value = "æå
³é®è¯åæ¶é´èå´æ¥è¯¢é宿¥ä»·å") |
| | | public String listSalesQuotations(@ToolMemoryId String memoryId, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
æ¥ä»·åå·/客æ·/ä¸å¡å/ç¶æ", required = false) String keyword, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, null); |
| | | LambdaQueryWrapper<SalesQuotation> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), SalesQuotation::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), SalesQuotation::getDeptId); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(SalesQuotation::getQuotationNo, keyword) |
| | | .or().like(SalesQuotation::getCustomer, keyword) |
| | | .or().like(SalesQuotation::getSalesperson, keyword) |
| | | .or().like(SalesQuotation::getStatus, keyword)); |
| | | } |
| | | wrapper.ge(SalesQuotation::getQuotationDate, range.start()) |
| | | .le(SalesQuotation::getQuotationDate, range.end()) |
| | | .orderByDesc(SalesQuotation::getQuotationDate, SalesQuotation::getId) |
| | | .last("limit " + normalizeLimit(limit)); |
| | | |
| | | List<SalesQuotation> rows = defaultList(salesQuotationMapper.selectList(wrapper)); |
| | | BigDecimal quotationAmountTotal = rows.stream() |
| | | .map(SalesQuotation::getTotalAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | List<Map<String, Object>> items = rows.stream().map(item -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("quotationNo", safe(item.getQuotationNo())); |
| | | map.put("customer", safe(item.getCustomer())); |
| | | map.put("salesperson", safe(item.getSalesperson())); |
| | | map.put("quotationDate", formatDate(item.getQuotationDate())); |
| | | map.put("validDate", formatDate(item.getValidDate())); |
| | | map.put("status", safe(item.getStatus())); |
| | | map.put("paymentMethod", safe(item.getPaymentMethod())); |
| | | map.put("deliveryPeriod", safe(item.getDeliveryPeriod())); |
| | | map.put("totalAmount", item.getTotalAmount()); |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | Map<String, Object> summary = rangeSummary(range, items.size(), keyword); |
| | | summary.put("quotationAmountTotal", quotationAmountTotal); |
| | | return jsonResponse(true, "sales_quotation_list", "å·²è¿åé宿¥ä»·å表", summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢éå®å°è´¦", value = "æå
³é®è¯åæ¶é´èå´æ¥è¯¢éå®å°è´¦ï¼å¹¶è¿åå¼ç¥¨å款ä¸åè´§ç¶æ") |
| | | public String listSalesLedgers(@ToolMemoryId String memoryId, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
éå®ååå·/客æ·ååå·/客æ·/项ç®", required = false) String keyword, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, null); |
| | | LambdaQueryWrapper<SalesLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), SalesLedger::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), SalesLedger::getDeptId); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(SalesLedger::getSalesContractNo, keyword) |
| | | .or().like(SalesLedger::getCustomerContractNo, keyword) |
| | | .or().like(SalesLedger::getCustomerName, keyword) |
| | | .or().like(SalesLedger::getProjectName, keyword) |
| | | .or().like(SalesLedger::getSalesman, keyword)); |
| | | } |
| | | wrapper.ge(SalesLedger::getEntryDate, toDate(range.start())) |
| | | .lt(SalesLedger::getEntryDate, toExclusiveEndDate(range.end())) |
| | | .orderByDesc(SalesLedger::getEntryDate, SalesLedger::getId) |
| | | .last("limit " + normalizeLimit(limit)); |
| | | List<SalesLedger> rows = defaultList(salesLedgerMapper.selectList(wrapper)); |
| | | if (rows.isEmpty()) { |
| | | return jsonResponse(true, "sales_ledger_list", "æªæ¥è¯¢å°ç¬¦åæ¡ä»¶çéå®å°è´¦", rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of()); |
| | | } |
| | | |
| | | List<Long> ledgerIds = rows.stream().map(SalesLedger::getId).filter(Objects::nonNull).collect(Collectors.toList()); |
| | | Map<Long, BigDecimal> invoiceAmountByLedgerId = sumInvoiceAmounts(ledgerIds); |
| | | Map<Long, BigDecimal> receiptAmountByLedgerId = sumReceiptAmounts(loginUser, ledgerIds); |
| | | Map<Long, List<ShippingInfo>> shippingByLedgerId = queryShippingsByLedgerIds(loginUser, ledgerIds).stream() |
| | | .collect(Collectors.groupingBy(ShippingInfo::getSalesLedgerId)); |
| | | |
| | | BigDecimal contractAmountTotal = BigDecimal.ZERO; |
| | | BigDecimal invoicedAmountTotal = BigDecimal.ZERO; |
| | | BigDecimal receivedAmountTotal = BigDecimal.ZERO; |
| | | BigDecimal pendingAmountTotal = BigDecimal.ZERO; |
| | | |
| | | List<Map<String, Object>> items = new ArrayList<>(); |
| | | for (SalesLedger ledger : rows) { |
| | | BigDecimal contractAmount = defaultDecimal(ledger.getContractAmount()); |
| | | BigDecimal invoicedAmount = invoiceAmountByLedgerId.getOrDefault(ledger.getId(), BigDecimal.ZERO); |
| | | BigDecimal receivedAmount = receiptAmountByLedgerId.getOrDefault(ledger.getId(), BigDecimal.ZERO); |
| | | BigDecimal unbilledAmount = maxZero(contractAmount.subtract(invoicedAmount)); |
| | | BigDecimal pendingAmount = maxZero(invoicedAmount.subtract(receivedAmount)); |
| | | |
| | | contractAmountTotal = contractAmountTotal.add(contractAmount); |
| | | invoicedAmountTotal = invoicedAmountTotal.add(invoicedAmount); |
| | | receivedAmountTotal = receivedAmountTotal.add(receivedAmount); |
| | | pendingAmountTotal = pendingAmountTotal.add(pendingAmount); |
| | | |
| | | Map<String, Object> item = new LinkedHashMap<>(); |
| | | item.put("id", ledger.getId()); |
| | | item.put("salesContractNo", safe(ledger.getSalesContractNo())); |
| | | item.put("customerContractNo", safe(ledger.getCustomerContractNo())); |
| | | item.put("customerName", safe(ledger.getCustomerName())); |
| | | item.put("projectName", safe(ledger.getProjectName())); |
| | | item.put("salesman", safe(ledger.getSalesman())); |
| | | item.put("entryDate", formatDate(ledger.getEntryDate())); |
| | | item.put("executionDate", formatDate(ledger.getExecutionDate())); |
| | | item.put("deliveryDate", formatDate(ledger.getDeliveryDate())); |
| | | item.put("contractAmount", contractAmount); |
| | | item.put("invoicedAmount", invoicedAmount); |
| | | item.put("receivedAmount", receivedAmount); |
| | | item.put("unbilledAmount", unbilledAmount); |
| | | item.put("pendingAmount", pendingAmount); |
| | | item.put("shippingStatus", calcLedgerShippingStatus(shippingByLedgerId.get(ledger.getId()))); |
| | | items.add(item); |
| | | } |
| | | |
| | | Map<String, Object> summary = rangeSummary(range, items.size(), keyword); |
| | | summary.put("contractAmountTotal", contractAmountTotal); |
| | | summary.put("invoicedAmountTotal", invoicedAmountTotal); |
| | | summary.put("receivedAmountTotal", receivedAmountTotal); |
| | | summary.put("pendingAmountTotal", pendingAmountTotal); |
| | | return jsonResponse(true, "sales_ledger_list", "å·²è¿åéå®å°è´¦å表", summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢éå®éè´§", value = "ææ¶é´èå´åå
³é®è¯æ¥è¯¢éå®éè´§è®°å½") |
| | | public String listSalesReturns(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
鿬¾åå·/交æå·/仿¬¾è´¦æ·", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, null); |
| | | LambdaQueryWrapper<AccountSalesCollection> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountSalesCollection::getDeptId); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(AccountSalesCollection::getCollectionNumber, keyword) |
| | | .or().like(AccountSalesCollection::getCollectionMethod, keyword) |
| | | .or().like(AccountSalesCollection::getRemark, keyword)); |
| | | } |
| | | wrapper.ge(AccountSalesCollection::getCollectionDate, range.start()) |
| | | .le(AccountSalesCollection::getCollectionDate, range.end()) |
| | | .orderByDesc(AccountSalesCollection::getCollectionDate, AccountSalesCollection::getId) |
| | | .last("limit " + normalizeLimit(limit)); |
| | | List<AccountSalesCollection> rows = defaultList(accountSalesCollectionMapper.selectList(wrapper)); |
| | | |
| | | BigDecimal returnAmount = rows.stream() |
| | | .map(AccountSalesCollection::getCollectionAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | List<Map<String, Object>> items = rows.stream().map(item -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("refundId", safe(item.getCollectionNumber())); |
| | | map.put("collectionNumber", safe(item.getCollectionNumber())); |
| | | map.put("paymentMethod", safe(item.getCollectionMethod())); |
| | | map.put("actualAmount", item.getCollectionAmount()); |
| | | map.put("collectionAmount", item.getCollectionAmount()); |
| | | map.put("customerId", item.getCustomerId()); |
| | | map.put("remark", safe(item.getRemark())); |
| | | map.put("createTime", formatDate(item.getCollectionDate())); |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | Map<String, Object> summary = rangeSummary(range, items.size(), keyword); |
| | | summary.put("returnAmount", returnAmount); |
| | | return jsonResponse(true, "sales_return_list", "å·²è¿åéå®éè´§è®°å½", summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢å®¢æ·å¾æ¥", value = "ææ¶é´èå´åå
³é®è¯æ¥è¯¢å®¢æ·åæ¬¾å¾æ¥æç»") |
| | | public String listCustomerInteractions(@ToolMemoryId String memoryId, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
客æ·åç§°/éå®ååå·/项ç®å", required = false) String keyword, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, null); |
| | | List<AccountSalesCollection> collections = queryCollections(loginUser, range); |
| | | if (collections.isEmpty()) { |
| | | return jsonResponse(true, "sales_customer_interaction_list", "no_customer_interactions", rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of()); |
| | | } |
| | | |
| | | Map<Integer, Set<Long>> ledgerIdsByCollectionId = mapCollectionLedgerIds(loginUser, collections); |
| | | Set<Long> ledgerIds = ledgerIdsByCollectionId.values().stream() |
| | | .flatMap(Collection::stream) |
| | | .collect(Collectors.toSet()); |
| | | Map<Long, SalesLedger> ledgerMap = defaultList(salesLedgerMapper.selectBatchIds(ledgerIds)).stream() |
| | | .filter(ledger -> tenantMatched(ledger.getTenantId(), loginUser.getTenantId())) |
| | | .collect(Collectors.toMap(SalesLedger::getId, item -> item, (a, b) -> a, LinkedHashMap::new)); |
| | | |
| | | int finalLimit = normalizeLimit(limit); |
| | | List<Map<String, Object>> items = new ArrayList<>(); |
| | | for (AccountSalesCollection collection : collections) { |
| | | Set<Long> relatedLedgerIds = ledgerIdsByCollectionId.get(collection.getId()); |
| | | if (relatedLedgerIds == null || relatedLedgerIds.isEmpty()) { |
| | | if (!matchInteractionKeyword(collection, null, keyword)) { |
| | | continue; |
| | | } |
| | | items.add(toInteractionItem(collection, null)); |
| | | if (items.size() >= finalLimit) { |
| | | break; |
| | | } |
| | | continue; |
| | | } |
| | | for (Long ledgerId : relatedLedgerIds) { |
| | | SalesLedger ledger = ledgerMap.get(ledgerId); |
| | | if (ledger == null || !matchInteractionKeyword(collection, ledger, keyword)) { |
| | | continue; |
| | | } |
| | | items.add(toInteractionItem(collection, ledger)); |
| | | if (items.size() >= finalLimit) { |
| | | break; |
| | | } |
| | | } |
| | | if (items.size() >= finalLimit) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | BigDecimal totalReceiptAmount = items.stream() |
| | | .map(item -> asBigDecimal(item.get("receiptPaymentAmount"))) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | Map<String, Object> summary = rangeSummary(range, items.size(), keyword); |
| | | summary.put("totalReceiptAmount", totalReceiptAmount); |
| | | summary.put("customerCount", items.stream() |
| | | .map(item -> String.valueOf(item.get("customerName"))) |
| | | .filter(StringUtils::hasText) |
| | | .distinct() |
| | | .count()); |
| | | return jsonResponse(true, "sales_customer_interaction_list", "ok", summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢åè´§å°è´¦", value = "æå
³é®è¯åæ¶é´èå´æ¥è¯¢åè´§å°è´¦") |
| | | public String listShippingLedgers(@ToolMemoryId String memoryId, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
åè´§åå·/å¿«éåå·/ç©æµå
¬å¸/车çå·", required = false) String keyword, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, null); |
| | | LambdaQueryWrapper<ShippingInfo> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), ShippingInfo::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ShippingInfo::getDeptId); |
| | | if (StringUtils.hasText(keyword)) { |
| | | wrapper.and(w -> w.like(ShippingInfo::getShippingNo, keyword) |
| | | .or().like(ShippingInfo::getExpressNumber, keyword) |
| | | .or().like(ShippingInfo::getExpressCompany, keyword) |
| | | .or().like(ShippingInfo::getShippingCarNumber, keyword) |
| | | .or().like(ShippingInfo::getStatus, keyword)); |
| | | } |
| | | wrapper.ge(ShippingInfo::getShippingDate, toDate(range.start())) |
| | | .lt(ShippingInfo::getShippingDate, toExclusiveEndDate(range.end())) |
| | | .orderByDesc(ShippingInfo::getShippingDate, ShippingInfo::getId) |
| | | .last("limit " + normalizeLimit(limit)); |
| | | List<ShippingInfo> rows = defaultList(shippingInfoMapper.selectList(wrapper)); |
| | | if (rows.isEmpty()) { |
| | | return jsonResponse(true, "sales_shipping_list", "æªæ¥è¯¢å°åè´§å°è´¦è®°å½", rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of()); |
| | | } |
| | | |
| | | List<Long> ledgerIds = rows.stream().map(ShippingInfo::getSalesLedgerId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); |
| | | Map<Long, SalesLedger> ledgerMap = defaultList(salesLedgerMapper.selectBatchIds(ledgerIds)).stream() |
| | | .filter(ledger -> tenantMatched(ledger.getTenantId(), loginUser.getTenantId())) |
| | | .collect(Collectors.toMap(SalesLedger::getId, item -> item, (a, b) -> a, LinkedHashMap::new)); |
| | | |
| | | long shippedCount = rows.stream().filter(item -> isShippedStatus(item.getStatus())).count(); |
| | | List<Map<String, Object>> items = rows.stream().map(item -> { |
| | | SalesLedger ledger = ledgerMap.get(item.getSalesLedgerId()); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("salesLedgerId", item.getSalesLedgerId()); |
| | | map.put("salesContractNo", ledger == null ? "" : safe(ledger.getSalesContractNo())); |
| | | map.put("customerName", ledger == null ? "" : safe(ledger.getCustomerName())); |
| | | map.put("shippingNo", safe(item.getShippingNo())); |
| | | map.put("status", safe(item.getStatus())); |
| | | map.put("shippingDate", formatDate(item.getShippingDate())); |
| | | map.put("type", safe(item.getType())); |
| | | map.put("shippingCarNumber", safe(item.getShippingCarNumber())); |
| | | map.put("expressCompany", safe(item.getExpressCompany())); |
| | | map.put("expressNumber", safe(item.getExpressNumber())); |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | Map<String, Object> summary = rangeSummary(range, items.size(), keyword); |
| | | summary.put("shippingCount", rows.size()); |
| | | summary.put("shippedCount", shippedCount); |
| | | summary.put("pendingCount", Math.max(rows.size() - shippedCount, 0)); |
| | | return jsonResponse(true, "sales_shipping_list", "å·²è¿ååè´§å°è´¦è®°å½", summary, Map.of("items", items), Map.of()); |
| | | } |
| | | |
| | | @Tool(name = "æ¥è¯¢é宿æ ç»è®¡", value = "ææ¶é´èå´ç»è®¡éå®ååãæ¥ä»·ãåè´§ã忬¾çå
³é®ææ ") |
| | | public String getSalesDashboard(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦æ¬æãæ¬å¹´ãè¿30天", required = false) String timeRange) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, timeRange); |
| | | |
| | | List<SalesLedger> ledgers = querySalesLedgers(loginUser, range); |
| | | List<SalesQuotation> quotations = querySalesQuotations(loginUser, range); |
| | | List<ShippingInfo> shippings = queryShippings(loginUser, range); |
| | | |
| | | |
| | | BigDecimal contractAmountTotal = ledgers.stream() |
| | | .map(SalesLedger::getContractAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal quotationAmountTotal = quotations.stream() |
| | | .map(SalesQuotation::getTotalAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | long shippingCount = shippings.size(); |
| | | long shippedCount = shippings.stream().filter(item -> isShippedStatus(item.getStatus())).count(); |
| | | String shipRate = toRate(shippedCount, shippingCount); |
| | | |
| | | List<Map<String, Object>> topCustomers = buildTopCustomers(ledgers); |
| | | TrendData trendData = buildContractTrendData(ledgers, range); |
| | | |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("orderCount", ledgers.size()); |
| | | summary.put("quotationCount", quotations.size()); |
| | | summary.put("shippingCount", shippingCount); |
| | | summary.put("shippedCount", shippedCount); |
| | | summary.put("shipRate", shipRate); |
| | | summary.put("contractAmountTotal", contractAmountTotal); |
| | | summary.put("quotationAmountTotal", quotationAmountTotal); |
| | | summary.put("receivedAmountTotal", BigDecimal.ZERO); |
| | | summary.put("pendingAmountTotal", BigDecimal.ZERO); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | // charts.put("amountBarOption", buildAmountBarOption(contractAmountTotal, quotationAmountTotal, receivedAmountTotal, pendingAmountTotal)); |
| | | charts.put("amountBarOption", buildAmountBarOption(contractAmountTotal, quotationAmountTotal, BigDecimal.ONE, BigDecimal.ONE)); |
| | | charts.put("shippingPieOption", buildShippingPieOption(shippedCount, Math.max(shippingCount - shippedCount, 0))); |
| | | charts.put("customerTopBarOption", buildCustomerTopBarOption(topCustomers)); |
| | | charts.put("contractTrendLineOption", buildContractTrendLineOption(trendData.labels(), trendData.values())); |
| | | |
| | | Map<String, Object> data = new LinkedHashMap<>(); |
| | | data.put("topCustomers", topCustomers); |
| | | data.put("contractTrend", trendData.toItemList()); |
| | | |
| | | return jsonResponse(true, "sales_dashboard", "å·²è¿åé宿æ ç»è®¡", summary, data, charts); |
| | | } |
| | | |
| | | @Tool(name = "å®¢æ·æµå¤±é£é©åæ", value = "æå®¢æ·ç»´åº¦è¯ä¼°æµå¤±é£é©ï¼è¾åºé£é©å级ãåå å建议ä¼å
级") |
| | | public String analyzeCustomerChurnRisk(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦è¿90å¤©ãæ¬å¹´", required = false) String timeRange, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
客æ·åç§°", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, StringUtils.hasText(timeRange) ? timeRange : "è¿180天"); |
| | | List<CustomerRiskMetric> metrics = buildCustomerRiskMetrics(loginUser, range, keyword); |
| | | if (metrics.isEmpty()) { |
| | | return jsonResponse(true, "sales_customer_churn_risk", "å½åèå´å
æªæ¥è¯¢å°å¯åæçå®¢æ·æ°æ®", |
| | | rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of()); |
| | | } |
| | | |
| | | List<CustomerRiskMetric> sorted = metrics.stream() |
| | | .sorted(Comparator.comparing(CustomerRiskMetric::getRiskScore).reversed() |
| | | .thenComparing(CustomerRiskMetric::getPendingAmount, Comparator.reverseOrder())) |
| | | .limit(normalizeLimit(limit)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | long highCount = sorted.stream().filter(item -> "high".equals(item.getRiskLevel())).count(); |
| | | long mediumCount = sorted.stream().filter(item -> "medium".equals(item.getRiskLevel())).count(); |
| | | long lowCount = sorted.stream().filter(item -> "low".equals(item.getRiskLevel())).count(); |
| | | |
| | | List<Map<String, Object>> items = sorted.stream().map(this::toRiskItem).collect(Collectors.toList()); |
| | | Map<String, Object> summary = rangeSummary(range, items.size(), keyword); |
| | | summary.put("highRiskCount", highCount); |
| | | summary.put("mediumRiskCount", mediumCount); |
| | | summary.put("lowRiskCount", lowCount); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("riskLevelPieOption", buildRiskLevelPieOption(highCount, mediumCount, lowCount)); |
| | | charts.put("riskScoreBarOption", buildRiskScoreBarOption(sorted)); |
| | | |
| | | return jsonResponse(true, "sales_customer_churn_risk", "å·²å®æå®¢æ·æµå¤±é£é©åæ", summary, Map.of("items", items), charts); |
| | | } |
| | | |
| | | @Tool(name = "忬¾ä¸æ¥ä»·çç¥å»ºè®®", value = "åºäºå®¢æ·é£é©ã忬¾åæ¥ä»·æ
åµçæå¯æ§è¡çè·è¿çç¥") |
| | | public String suggestCollectionAndQuotationStrategy(@ToolMemoryId String memoryId, |
| | | @P(value = "å¼å§æ¥æ yyyy-MM-dd", required = false) String startDate, |
| | | @P(value = "ç»ææ¥æ yyyy-MM-dd", required = false) String endDate, |
| | | @P(value = "æ¶é´èå´æè¿°ï¼å¦è¿90å¤©ãæ¬æ", required = false) String timeRange, |
| | | @P(value = "å
³é®è¯ï¼å¯å¹é
客æ·åç§°", required = false) String keyword, |
| | | @P(value = "è¿åæ¡æ°ï¼é»è®¤10ï¼æå¤§30", required = false) Integer limit, |
| | | @P(value = "æ¯å¦ä¼å
é«é£é©å®¢æ·ï¼true 表示é«é£é©ä¼å
", required = false) Boolean prioritizeHighRisk) { |
| | | LoginUser loginUser = currentLoginUser(memoryId); |
| | | DateRange range = resolveDateRange(startDate, endDate, StringUtils.hasText(timeRange) ? timeRange : "è¿90天"); |
| | | List<CustomerRiskMetric> metrics = buildCustomerRiskMetrics(loginUser, range, keyword); |
| | | if (metrics.isEmpty()) { |
| | | return jsonResponse(true, "sales_collection_quote_strategy", "å½åèå´å
æªæ¥è¯¢å°å¯çæçç¥çå®¢æ·æ°æ®", |
| | | rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of()); |
| | | } |
| | | |
| | | boolean highRiskFirst = Boolean.TRUE.equals(prioritizeHighRisk); |
| | | Comparator<CustomerRiskMetric> sortComparator; |
| | | if (highRiskFirst) { |
| | | sortComparator = Comparator |
| | | .comparingInt((CustomerRiskMetric metric) -> riskLevelRank(metric.getRiskLevel())).reversed() |
| | | .thenComparing(CustomerRiskMetric::getRiskScore, Comparator.reverseOrder()) |
| | | .thenComparing(CustomerRiskMetric::getPendingAmount, Comparator.reverseOrder()); |
| | | } else { |
| | | sortComparator = Comparator |
| | | .comparing(CustomerRiskMetric::getPendingAmount, Comparator.reverseOrder()) |
| | | .thenComparing(CustomerRiskMetric::getRiskScore, Comparator.reverseOrder()); |
| | | } |
| | | |
| | | List<CustomerRiskMetric> sorted = metrics.stream() |
| | | .sorted(sortComparator) |
| | | .limit(normalizeLimit(limit)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<Map<String, Object>> items = sorted.stream().map(this::toStrategyItem).collect(Collectors.toList()); |
| | | long highPriorityCount = items.stream().filter(item -> "high".equals(item.get("priority"))).count(); |
| | | long mediumPriorityCount = items.stream().filter(item -> "medium".equals(item.get("priority"))).count(); |
| | | long lowPriorityCount = items.stream().filter(item -> "low".equals(item.get("priority"))).count(); |
| | | |
| | | Map<String, Object> summary = rangeSummary(range, items.size(), keyword); |
| | | summary.put("highPriorityCount", highPriorityCount); |
| | | summary.put("mediumPriorityCount", mediumPriorityCount); |
| | | summary.put("lowPriorityCount", lowPriorityCount); |
| | | summary.put("prioritizeHighRisk", highRiskFirst); |
| | | summary.put("priorityMode", highRiskFirst ? "high_risk_first" : "pending_amount_first"); |
| | | |
| | | Map<String, Object> charts = new LinkedHashMap<>(); |
| | | charts.put("pendingAmountBarOption", buildPendingAmountBarOption(sorted)); |
| | | charts.put("priorityPieOption", buildPriorityPieOption(highPriorityCount, mediumPriorityCount, lowPriorityCount)); |
| | | |
| | | return jsonResponse(true, "sales_collection_quote_strategy", "å·²çæåæ¬¾ä¸æ¥ä»·çç¥å»ºè®®", summary, Map.of("items", items), charts); |
| | | } |
| | | |
| | | private List<CustomerRiskMetric> buildCustomerRiskMetrics(LoginUser loginUser, DateRange range, String keyword) { |
| | | List<SalesLedger> ledgers = querySalesLedgers(loginUser, range).stream() |
| | | .filter(item -> matchLedgerCustomerKeyword(item, keyword)) |
| | | .collect(Collectors.toList()); |
| | | if (ledgers.isEmpty()) { |
| | | return List.of(); |
| | | } |
| | | |
| | | Map<String, CustomerRiskMetric> metricMap = new LinkedHashMap<>(); |
| | | for (SalesLedger ledger : ledgers) { |
| | | String customerName = StringUtils.hasText(ledger.getCustomerName()) ? ledger.getCustomerName().trim() : "æªç¥å®¢æ·"; |
| | | CustomerRiskMetric metric = metricMap.computeIfAbsent(customerName, CustomerRiskMetric::new); |
| | | metric.setOrderCount(metric.getOrderCount() + 1); |
| | | metric.setContractAmount(metric.getContractAmount().add(defaultDecimal(ledger.getContractAmount()))); |
| | | metric.setTopSingleOrderAmount(metric.getTopSingleOrderAmount().max(defaultDecimal(ledger.getContractAmount()))); |
| | | LocalDate entryDate = toLocalDate(ledger.getEntryDate()); |
| | | if (entryDate != null && (metric.getLastOrderDate() == null || entryDate.isAfter(metric.getLastOrderDate()))) { |
| | | metric.setLastOrderDate(entryDate); |
| | | } |
| | | if (ledger.getId() != null) { |
| | | metric.getLedgerIds().add(ledger.getId()); |
| | | if (ledger.getDeliveryDate() != null) { |
| | | metric.getDeliveryDateByLedgerId().put(ledger.getId(), ledger.getDeliveryDate()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<Long> allLedgerIds = metricMap.values().stream() |
| | | .flatMap(metric -> metric.getLedgerIds().stream()) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | Map<Long, BigDecimal> receiptAmountByLedgerId = sumReceiptAmounts(loginUser, allLedgerIds); |
| | | Map<Long, List<ShippingInfo>> shippingByLedgerId = queryShippingsByLedgerIds(loginUser, allLedgerIds).stream() |
| | | .collect(Collectors.groupingBy(ShippingInfo::getSalesLedgerId)); |
| | | |
| | | List<SalesQuotation> quotations = querySalesQuotations(loginUser, range); |
| | | for (SalesQuotation quotation : quotations) { |
| | | String customerName = safe(quotation.getCustomer()); |
| | | CustomerRiskMetric metric = metricMap.get(customerName); |
| | | if (metric == null) { |
| | | continue; |
| | | } |
| | | metric.setQuoteCount(metric.getQuoteCount() + 1); |
| | | metric.setQuoteAmount(metric.getQuoteAmount().add(defaultDecimal(quotation.getTotalAmount()))); |
| | | } |
| | | |
| | | LocalDate today = LocalDate.now(); |
| | | for (CustomerRiskMetric metric : metricMap.values()) { |
| | | BigDecimal receivedAmount = BigDecimal.ZERO; |
| | | long overdueDeliveryCount = 0; |
| | | for (Long ledgerId : metric.getLedgerIds()) { |
| | | receivedAmount = receivedAmount.add(receiptAmountByLedgerId.getOrDefault(ledgerId, BigDecimal.ZERO)); |
| | | LocalDate deliveryDate = metric.getDeliveryDateByLedgerId().get(ledgerId); |
| | | if (deliveryDate != null && deliveryDate.isBefore(today) && !isLedgerFullyShipped(ledgerId, shippingByLedgerId)) { |
| | | overdueDeliveryCount++; |
| | | } |
| | | } |
| | | metric.setReceivedAmount(receivedAmount); |
| | | metric.setPendingAmount(maxZero(metric.getContractAmount().subtract(receivedAmount))); |
| | | if (metric.getContractAmount().compareTo(BigDecimal.ZERO) > 0) { |
| | | metric.setPendingRate(metric.getPendingAmount() |
| | | .divide(metric.getContractAmount(), 4, RoundingMode.HALF_UP)); |
| | | } else { |
| | | metric.setPendingRate(BigDecimal.ZERO); |
| | | } |
| | | metric.setOverdueDeliveryCount(overdueDeliveryCount); |
| | | if (metric.getLastOrderDate() == null) { |
| | | metric.setDaysSinceLastOrder(999); |
| | | } else { |
| | | metric.setDaysSinceLastOrder(Math.max(today.toEpochDay() - metric.getLastOrderDate().toEpochDay(), 0)); |
| | | } |
| | | evaluateRiskMetric(metric); |
| | | } |
| | | return new ArrayList<>(metricMap.values()); |
| | | } |
| | | |
| | | private void evaluateRiskMetric(CustomerRiskMetric metric) { |
| | | int score = 0; |
| | | List<String> reasons = new ArrayList<>(); |
| | | if (metric.getDaysSinceLastOrder() >= 90) { |
| | | score += 35; |
| | | reasons.add("è¿90å¤©æ æ°å¢è®¢å"); |
| | | } else if (metric.getDaysSinceLastOrder() >= 60) { |
| | | score += 25; |
| | | reasons.add("è¿60å¤©è®¢åæ´»è·åº¦ä¸é"); |
| | | } else if (metric.getDaysSinceLastOrder() >= 30) { |
| | | score += 12; |
| | | reasons.add("è¿30å¤©è®¢åæ³¢å¨åå¼±"); |
| | | } |
| | | |
| | | if (metric.getPendingRate().compareTo(new BigDecimal("0.60")) >= 0) { |
| | | score += 30; |
| | | reasons.add("å¾
忬¾å æ¯é«äº60%"); |
| | | } else if (metric.getPendingRate().compareTo(new BigDecimal("0.30")) >= 0) { |
| | | score += 20; |
| | | reasons.add("å¾
忬¾å æ¯é«äº30%"); |
| | | } else if (metric.getPendingRate().compareTo(new BigDecimal("0.10")) >= 0) { |
| | | score += 10; |
| | | reasons.add("åå¨å¾
忬¾é£é©"); |
| | | } |
| | | |
| | | if (metric.getOverdueDeliveryCount() > 0) { |
| | | score += Math.min((int) metric.getOverdueDeliveryCount() * 6, 20); |
| | | reasons.add("åå¨äº¤æé¾æè®¢å"); |
| | | } |
| | | |
| | | if (metric.getOrderCount() <= 1) { |
| | | score += 8; |
| | | reasons.add("订ååºæ°åä½"); |
| | | } |
| | | |
| | | if (metric.getQuoteCount() > 0 && metric.getOrderCount() == 0) { |
| | | score += 10; |
| | | reasons.add("æ¥ä»·æªå½¢æè®¢å转å"); |
| | | } |
| | | |
| | | score = Math.min(score, 100); |
| | | metric.setRiskScore(score); |
| | | if (score >= 70) { |
| | | metric.setRiskLevel("high"); |
| | | } else if (score >= 40) { |
| | | metric.setRiskLevel("medium"); |
| | | } else { |
| | | metric.setRiskLevel("low"); |
| | | } |
| | | metric.setRiskReasons(reasons); |
| | | } |
| | | |
| | | private Map<String, Object> toRiskItem(CustomerRiskMetric metric) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("customerName", metric.getCustomerName()); |
| | | map.put("riskLevel", metric.getRiskLevel()); |
| | | map.put("riskScore", metric.getRiskScore()); |
| | | map.put("contractAmount", metric.getContractAmount()); |
| | | map.put("receivedAmount", metric.getReceivedAmount()); |
| | | map.put("pendingAmount", metric.getPendingAmount()); |
| | | map.put("pendingRate", toPercent(metric.getPendingRate())); |
| | | map.put("orderCount", metric.getOrderCount()); |
| | | map.put("quoteCount", metric.getQuoteCount()); |
| | | map.put("overdueDeliveryCount", metric.getOverdueDeliveryCount()); |
| | | map.put("daysSinceLastOrder", metric.getDaysSinceLastOrder()); |
| | | map.put("lastOrderDate", formatDate(metric.getLastOrderDate())); |
| | | map.put("riskReasons", metric.getRiskReasons()); |
| | | return map; |
| | | } |
| | | |
| | | private Map<String, Object> toStrategyItem(CustomerRiskMetric metric) { |
| | | String priority = strategyPriority(metric); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("customerName", metric.getCustomerName()); |
| | | map.put("riskLevel", metric.getRiskLevel()); |
| | | map.put("riskScore", metric.getRiskScore()); |
| | | map.put("priority", priority); |
| | | map.put("pendingAmount", metric.getPendingAmount()); |
| | | map.put("pendingRate", toPercent(metric.getPendingRate())); |
| | | map.put("quoteCount", metric.getQuoteCount()); |
| | | map.put("orderCount", metric.getOrderCount()); |
| | | map.put("quoteConversionRate", toRate(metric.getOrderCount(), Math.max(metric.getQuoteCount(), 1))); |
| | | map.put("collectionStrategy", buildCollectionStrategy(metric)); |
| | | map.put("quotationStrategy", buildQuotationStrategy(metric)); |
| | | map.put("nextAction", buildNextAction(priority)); |
| | | map.put("topSingleOrderAmount", metric.getTopSingleOrderAmount()); |
| | | return map; |
| | | } |
| | | |
| | | private String buildCollectionStrategy(CustomerRiskMetric metric) { |
| | | if (metric.getPendingAmount().compareTo(BigDecimal.ZERO) <= 0) { |
| | | return "ä¿ææ£å¸¸æåº¦å¯¹è´¦ä¸å款确认ï¼ç»´æå®¢æ·å款èå¥ã"; |
| | | } |
| | | if (metric.getPendingRate().compareTo(new BigDecimal("0.60")) >= 0) { |
| | | return "ä¼å
éå®å款计åï¼æå¨æå忬¾èç¹å¹¶ç»å®åè´§æ¡ä»¶ï¼é¿å
æ°å¢ä¿¡ç¨æå£ã"; |
| | | } |
| | | if (metric.getPendingRate().compareTo(new BigDecimal("0.30")) >= 0) { |
| | | return "建议æ§è¡åå¨å¬æ¶æºå¶ï¼åæ¥è´¢å¡ä¸ä¸å¡èåè·è¿éç¹ååã"; |
| | | } |
| | | return "ä¿ææ£å¸¸å¬æ¶èå¥ï¼æååèç¹æå3天æé客æ·ä»æ¬¾ã"; |
| | | } |
| | | |
| | | private String buildQuotationStrategy(CustomerRiskMetric metric) { |
| | | if ("high".equals(metric.getRiskLevel())) { |
| | | return "æ¥ä»·ä¼å
ä¿æ¯å©ä¸åæ¬¾æ¡æ¬¾ï¼åå°è¶
é¿è´¦æï¼å¿
è¦æ¶éç¨åé¶æ®µæ¥ä»·ã"; |
| | | } |
| | | if (metric.getQuoteCount() > 0 && metric.getOrderCount() < metric.getQuoteCount()) { |
| | | return "ä¼åæ¥ä»·ç»æï¼å»ºè®®æä¾åºç¡ç+å级çç»åæ¥ä»·ï¼æé«è½¬åçã"; |
| | | } |
| | | if (metric.getOrderCount() <= 1) { |
| | | return "å å¼ºéæ±ææï¼å´ç»å®¢æ·åºæ¯è¡¥å
å¢å¼é¡¹ä¸äº¤ä»ä¿éæ¡æ¬¾ã"; |
| | | } |
| | | return "ä¿æå½åæ¥ä»·çç¥ï¼éç¹å´ç»äº¤æåæå¡è½ååå·®å¼ååç°ã"; |
| | | } |
| | | |
| | | private String buildNextAction(String priority) { |
| | | return switch (priority) { |
| | | case "high" -> "48å°æ¶å
宿客æ·å访ï¼ç¡®è®¤å款计å并夿 ¸æ¥ä»·æææã"; |
| | | case "medium" -> "æ¬å¨å
宿客æ·éæ±å¤çï¼æ´æ°æ¥ä»·çæ¬å¹¶åæ¥å款èç¹ã"; |
| | | default -> "ä¿ææåº¦ä¾è¡è·è¿ï¼æç»è¿½è¸ªå®¢æ·éè´è®¡åååã"; |
| | | }; |
| | | } |
| | | |
| | | private String strategyPriority(CustomerRiskMetric metric) { |
| | | if ("high".equals(metric.getRiskLevel()) || metric.getPendingRate().compareTo(new BigDecimal("0.50")) >= 0) { |
| | | return "high"; |
| | | } |
| | | if ("medium".equals(metric.getRiskLevel()) || metric.getPendingRate().compareTo(new BigDecimal("0.30")) >= 0) { |
| | | return "medium"; |
| | | } |
| | | return "low"; |
| | | } |
| | | |
| | | private int riskLevelRank(String riskLevel) { |
| | | if ("high".equals(riskLevel)) { |
| | | return 3; |
| | | } |
| | | if ("medium".equals(riskLevel)) { |
| | | return 2; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | private List<Map<String, Object>> buildTopCustomers(List<SalesLedger> ledgers) { |
| | | Map<String, BigDecimal> grouped = new LinkedHashMap<>(); |
| | | for (SalesLedger ledger : ledgers) { |
| | | String customerName = StringUtils.hasText(ledger.getCustomerName()) ? ledger.getCustomerName().trim() : "æªç¥å®¢æ·"; |
| | | grouped.merge(customerName, defaultDecimal(ledger.getContractAmount()), BigDecimal::add); |
| | | } |
| | | return grouped.entrySet().stream() |
| | | .sorted(Map.Entry.<String, BigDecimal>comparingByValue().reversed()) |
| | | .limit(5) |
| | | .map(entry -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("customerName", entry.getKey()); |
| | | map.put("contractAmount", entry.getValue()); |
| | | return map; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private TrendData buildContractTrendData(List<SalesLedger> ledgers, DateRange range) { |
| | | Map<String, BigDecimal> amountByMonth = new LinkedHashMap<>(); |
| | | YearMonth startMonth = YearMonth.from(range.start()); |
| | | YearMonth endMonth = YearMonth.from(range.end()); |
| | | for (YearMonth month = startMonth; !month.isAfter(endMonth); month = month.plusMonths(1)) { |
| | | amountByMonth.put(month.toString(), BigDecimal.ZERO); |
| | | } |
| | | for (SalesLedger ledger : ledgers) { |
| | | LocalDate entryDate = toLocalDate(ledger.getEntryDate()); |
| | | if (entryDate == null) { |
| | | continue; |
| | | } |
| | | String monthKey = YearMonth.from(entryDate).toString(); |
| | | if (!amountByMonth.containsKey(monthKey)) { |
| | | continue; |
| | | } |
| | | amountByMonth.put(monthKey, amountByMonth.get(monthKey).add(defaultDecimal(ledger.getContractAmount()))); |
| | | } |
| | | return new TrendData(new ArrayList<>(amountByMonth.keySet()), new ArrayList<>(amountByMonth.values())); |
| | | } |
| | | |
| | | private List<SalesLedger> querySalesLedgers(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<SalesLedger> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), SalesLedger::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), SalesLedger::getDeptId); |
| | | if (range != null) { |
| | | wrapper.ge(SalesLedger::getEntryDate, toDate(range.start())) |
| | | .lt(SalesLedger::getEntryDate, toExclusiveEndDate(range.end())); |
| | | } |
| | | return defaultList(salesLedgerMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<SalesQuotation> querySalesQuotations(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<SalesQuotation> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), SalesQuotation::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), SalesQuotation::getDeptId); |
| | | if (range != null) { |
| | | wrapper.ge(SalesQuotation::getQuotationDate, range.start()) |
| | | .le(SalesQuotation::getQuotationDate, range.end()); |
| | | } |
| | | return defaultList(salesQuotationMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<ShippingInfo> queryShippings(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<ShippingInfo> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), ShippingInfo::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ShippingInfo::getDeptId); |
| | | if (range != null) { |
| | | wrapper.ge(ShippingInfo::getShippingDate, toDate(range.start())) |
| | | .lt(ShippingInfo::getShippingDate, toExclusiveEndDate(range.end())); |
| | | } |
| | | return defaultList(shippingInfoMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private List<ShippingInfo> queryShippingsByLedgerIds(LoginUser loginUser, List<Long> ledgerIds) { |
| | | if (ledgerIds == null || ledgerIds.isEmpty()) { |
| | | return List.of(); |
| | | } |
| | | LambdaQueryWrapper<ShippingInfo> wrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(wrapper, loginUser.getTenantId(), ShippingInfo::getTenantId); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ShippingInfo::getDeptId); |
| | | wrapper.in(ShippingInfo::getSalesLedgerId, ledgerIds); |
| | | return defaultList(shippingInfoMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private Map<Long, BigDecimal> sumInvoiceAmounts(List<Long> ledgerIds) { |
| | | if (ledgerIds == null || ledgerIds.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | Map<Long, BigDecimal> result = new HashMap<>(); |
| | | return result; |
| | | } |
| | | |
| | | private Map<Long, BigDecimal> sumReceiptAmounts(LoginUser loginUser, List<Long> ledgerIds) { |
| | | if (ledgerIds == null || ledgerIds.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | List<SalesLedger> ledgers = defaultList(salesLedgerMapper.selectBatchIds(ledgerIds)).stream() |
| | | .filter(ledger -> tenantMatched(ledger.getTenantId(), loginUser.getTenantId())) |
| | | .collect(Collectors.toList()); |
| | | if (ledgers.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | |
| | | Set<Integer> customerIds = ledgers.stream() |
| | | .map(SalesLedger::getCustomerId) |
| | | .filter(Objects::nonNull) |
| | | .map(Long::intValue) |
| | | .collect(Collectors.toSet()); |
| | | if (customerIds.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<AccountSalesCollection> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountSalesCollection::getDeptId); |
| | | wrapper.in(AccountSalesCollection::getCustomerId, customerIds); |
| | | List<AccountSalesCollection> collections = defaultList(accountSalesCollectionMapper.selectList(wrapper)); |
| | | if (collections.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | |
| | | Map<Integer, Set<Long>> ledgerIdsByCollectionId = mapCollectionLedgerIds(loginUser, collections); |
| | | Map<Long, List<Long>> ledgerIdsByCustomerId = ledgers.stream() |
| | | .filter(item -> item.getId() != null && item.getCustomerId() != null) |
| | | .collect(Collectors.groupingBy(item -> item.getCustomerId().longValue(), |
| | | Collectors.mapping(SalesLedger::getId, Collectors.toList()))); |
| | | Set<Long> targetLedgerIdSet = new HashSet<>(ledgerIds); |
| | | |
| | | Map<Long, BigDecimal> result = new HashMap<>(); |
| | | for (AccountSalesCollection collection : collections) { |
| | | BigDecimal amount = defaultDecimal(collection.getCollectionAmount()); |
| | | if (amount.compareTo(BigDecimal.ZERO) == 0) { |
| | | continue; |
| | | } |
| | | Set<Long> relatedLedgerIds = ledgerIdsByCollectionId.getOrDefault(collection.getId(), Set.of()); |
| | | if (!relatedLedgerIds.isEmpty()) { |
| | | for (Long ledgerId : relatedLedgerIds) { |
| | | if (targetLedgerIdSet.contains(ledgerId)) { |
| | | result.merge(ledgerId, amount, BigDecimal::add); |
| | | } |
| | | } |
| | | continue; |
| | | } |
| | | if (collection.getCustomerId() == null) { |
| | | continue; |
| | | } |
| | | List<Long> customerLedgerIds = ledgerIdsByCustomerId.get(collection.getCustomerId().longValue()); |
| | | if (customerLedgerIds == null || customerLedgerIds.isEmpty()) { |
| | | continue; |
| | | } |
| | | for (Long ledgerId : customerLedgerIds) { |
| | | if (targetLedgerIdSet.contains(ledgerId)) { |
| | | result.merge(ledgerId, amount, BigDecimal::add); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private List<AccountSalesCollection> queryCollections(LoginUser loginUser, DateRange range) { |
| | | LambdaQueryWrapper<AccountSalesCollection> wrapper = new LambdaQueryWrapper<>(); |
| | | applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), AccountSalesCollection::getDeptId); |
| | | if (range != null) { |
| | | wrapper.ge(AccountSalesCollection::getCollectionDate, range.start()) |
| | | .le(AccountSalesCollection::getCollectionDate, range.end()); |
| | | } |
| | | wrapper.orderByDesc(AccountSalesCollection::getCollectionDate, AccountSalesCollection::getId); |
| | | return defaultList(accountSalesCollectionMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | private Map<Integer, Set<Long>> mapCollectionLedgerIds(LoginUser loginUser, List<AccountSalesCollection> collections) { |
| | | Map<Integer, Set<Long>> result = new HashMap<>(); |
| | | if (collections == null || collections.isEmpty()) { |
| | | return result; |
| | | } |
| | | |
| | | Map<Integer, List<Long>> stockOutRecordIdsByCollection = new HashMap<>(); |
| | | Set<Long> allStockOutRecordIds = new HashSet<>(); |
| | | for (AccountSalesCollection collection : collections) { |
| | | if (collection.getId() == null) { |
| | | continue; |
| | | } |
| | | List<Long> stockOutRecordIds = parseLongIds(collection.getStockOutRecordIds()); |
| | | if (stockOutRecordIds.isEmpty()) { |
| | | continue; |
| | | } |
| | | stockOutRecordIdsByCollection.put(collection.getId(), stockOutRecordIds); |
| | | allStockOutRecordIds.addAll(stockOutRecordIds); |
| | | } |
| | | if (allStockOutRecordIds.isEmpty()) { |
| | | return result; |
| | | } |
| | | |
| | | List<StockOutRecord> stockOutRecords = defaultList(stockOutRecordMapper.selectList(new LambdaQueryWrapper<StockOutRecord>() |
| | | .in(StockOutRecord::getId, allStockOutRecordIds))); |
| | | if (stockOutRecords.isEmpty()) { |
| | | return result; |
| | | } |
| | | Map<Long, StockOutRecord> stockOutRecordMap = stockOutRecords.stream() |
| | | .filter(item -> item.getId() != null) |
| | | .collect(Collectors.toMap(StockOutRecord::getId, item -> item, (a, b) -> a)); |
| | | |
| | | Set<Long> shippingIds = stockOutRecords.stream() |
| | | .filter(this::isSalesOutboundRecord) |
| | | .map(StockOutRecord::getRecordId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | if (shippingIds.isEmpty()) { |
| | | return result; |
| | | } |
| | | |
| | | LambdaQueryWrapper<ShippingInfo> shippingWrapper = new LambdaQueryWrapper<>(); |
| | | applyTenantFilter(shippingWrapper, loginUser.getTenantId(), ShippingInfo::getTenantId); |
| | | applyDeptFilter(shippingWrapper, loginUser.getCurrentDeptId(), ShippingInfo::getDeptId); |
| | | shippingWrapper.in(ShippingInfo::getId, shippingIds); |
| | | Map<Long, Long> ledgerIdByShippingId = defaultList(shippingInfoMapper.selectList(shippingWrapper)).stream() |
| | | .filter(item -> item.getId() != null && item.getSalesLedgerId() != null) |
| | | .collect(Collectors.toMap(ShippingInfo::getId, ShippingInfo::getSalesLedgerId, (a, b) -> a)); |
| | | |
| | | for (Map.Entry<Integer, List<Long>> entry : stockOutRecordIdsByCollection.entrySet()) { |
| | | Set<Long> ledgerIds = new LinkedHashSet<>(); |
| | | for (Long stockOutRecordId : entry.getValue()) { |
| | | StockOutRecord stockOutRecord = stockOutRecordMap.get(stockOutRecordId); |
| | | if (!isSalesOutboundRecord(stockOutRecord)) { |
| | | continue; |
| | | } |
| | | Long ledgerId = ledgerIdByShippingId.get(stockOutRecord.getRecordId()); |
| | | if (ledgerId != null) { |
| | | ledgerIds.add(ledgerId); |
| | | } |
| | | } |
| | | if (!ledgerIds.isEmpty()) { |
| | | result.put(entry.getKey(), ledgerIds); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private boolean isSalesOutboundRecord(StockOutRecord stockOutRecord) { |
| | | if (stockOutRecord == null || !StringUtils.hasText(stockOutRecord.getRecordType())) { |
| | | return false; |
| | | } |
| | | if (stockOutRecord.getApprovalStatus() != null && stockOutRecord.getApprovalStatus() != 1) { |
| | | return false; |
| | | } |
| | | return "13".equals(stockOutRecord.getRecordType().trim()); |
| | | } |
| | | |
| | | private List<Long> parseLongIds(String raw) { |
| | | if (!StringUtils.hasText(raw)) { |
| | | return List.of(); |
| | | } |
| | | List<Long> result = new ArrayList<>(); |
| | | for (String part : raw.split(",")) { |
| | | if (!StringUtils.hasText(part)) { |
| | | continue; |
| | | } |
| | | try { |
| | | result.add(Long.parseLong(part.trim())); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private boolean matchInteractionKeyword(AccountSalesCollection collection, SalesLedger ledger, String keyword) { |
| | | if (!StringUtils.hasText(keyword)) { |
| | | return true; |
| | | } |
| | | String text = keyword.trim(); |
| | | if (safe(collection.getCollectionNumber()).contains(text) |
| | | || safe(collection.getCollectionMethod()).contains(text) |
| | | || safe(collection.getRemark()).contains(text)) { |
| | | return true; |
| | | } |
| | | if (ledger == null) { |
| | | return false; |
| | | } |
| | | return safe(ledger.getSalesContractNo()).contains(text) |
| | | || safe(ledger.getCustomerName()).contains(text) |
| | | || safe(ledger.getProjectName()).contains(text); |
| | | } |
| | | |
| | | private Map<String, Object> toInteractionItem(AccountSalesCollection collection, SalesLedger ledger) { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", collection.getId()); |
| | | map.put("salesLedgerId", ledger == null ? null : ledger.getId()); |
| | | map.put("salesContractNo", ledger == null ? "" : safe(ledger.getSalesContractNo())); |
| | | map.put("customerName", ledger == null ? "" : safe(ledger.getCustomerName())); |
| | | map.put("projectName", ledger == null ? "" : safe(ledger.getProjectName())); |
| | | map.put("receiptPaymentDate", formatDate(collection.getCollectionDate())); |
| | | map.put("receiptPaymentAmount", collection.getCollectionAmount()); |
| | | map.put("receiptPaymentType", safe(collection.getCollectionMethod())); |
| | | map.put("collectionNumber", safe(collection.getCollectionNumber())); |
| | | map.put("registrant", collection.getCreateUser()); |
| | | map.put("remark", safe(collection.getRemark())); |
| | | return map; |
| | | } |
| | | |
| | | private boolean isLedgerFullyShipped(Long ledgerId, Map<Long, List<ShippingInfo>> shippingByLedgerId) { |
| | | List<ShippingInfo> shippingInfos = shippingByLedgerId.get(ledgerId); |
| | | if (shippingInfos == null || shippingInfos.isEmpty()) { |
| | | return false; |
| | | } |
| | | return shippingInfos.stream().allMatch(item -> isShippedStatus(item.getStatus())); |
| | | } |
| | | |
| | | private String calcLedgerShippingStatus(List<ShippingInfo> shippingInfos) { |
| | | if (shippingInfos == null || shippingInfos.isEmpty()) { |
| | | return "æªåè´§"; |
| | | } |
| | | long shippedCount = shippingInfos.stream().filter(item -> isShippedStatus(item.getStatus())).count(); |
| | | if (shippedCount == 0) { |
| | | return "å¾
åè´§"; |
| | | } |
| | | if (shippedCount == shippingInfos.size()) { |
| | | return "å·²åè´§"; |
| | | } |
| | | return "é¨ååè´§"; |
| | | } |
| | | |
| | | private boolean isShippedStatus(String status) { |
| | | return StringUtils.hasText(status) && status.contains("å·²åè´§"); |
| | | } |
| | | |
| | | private boolean matchCustomerKeyword(CustomerVo customer, String keyword) { |
| | | if (!StringUtils.hasText(keyword)) { |
| | | return true; |
| | | } |
| | | String text = keyword.trim(); |
| | | return safe(customer.getCustomerName()).contains(text) |
| | | || safe(customer.getContactPerson()).contains(text) |
| | | || safe(customer.getContactPhone()).contains(text) |
| | | || safe(customer.getCompanyPhone()).contains(text) |
| | | || safe(customer.getUsageUserName()).contains(text); |
| | | } |
| | | |
| | | private boolean matchLedgerCustomerKeyword(SalesLedger ledger, String keyword) { |
| | | if (!StringUtils.hasText(keyword)) { |
| | | return true; |
| | | } |
| | | String text = keyword.trim(); |
| | | return safe(ledger.getCustomerName()).contains(text) |
| | | || safe(ledger.getSalesContractNo()).contains(text) |
| | | || safe(ledger.getProjectName()).contains(text); |
| | | } |
| | | |
| | | private Integer normalizeSeaType(String seaType) { |
| | | if (!StringUtils.hasText(seaType)) { |
| | | return null; |
| | | } |
| | | String value = seaType.trim().toLowerCase(Locale.ROOT); |
| | | return switch (value) { |
| | | case "private", "ç§æµ·", "0" -> 0; |
| | | case "public", "å
¬æµ·", "1" -> 1; |
| | | default -> null; |
| | | }; |
| | | } |
| | | |
| | | private String customerSeaTypeName(Integer type) { |
| | | if (type == null) { |
| | | return "æªç¥"; |
| | | } |
| | | return type == 1 ? "å
¬æµ·" : "ç§æµ·"; |
| | | } |
| | | |
| | | private int normalizeLimit(Integer limit) { |
| | | if (limit == null || limit <= 0) { |
| | | return DEFAULT_LIMIT; |
| | | } |
| | | return Math.min(limit, MAX_LIMIT); |
| | | } |
| | | |
| | | private boolean tenantMatched(Long dataTenantId, Long userTenantId) { |
| | | if (userTenantId == null) { |
| | | return true; |
| | | } |
| | | return Objects.equals(dataTenantId, userTenantId); |
| | | } |
| | | |
| | | private <T> void applyTenantFilter(LambdaQueryWrapper<T> wrapper, Long tenantId, SFunction<T, Long> field) { |
| | | if (tenantId != null) { |
| | | wrapper.eq(field, tenantId); |
| | | } |
| | | } |
| | | |
| | | private <T> void applyDeptFilter(LambdaQueryWrapper<T> wrapper, Long deptId, SFunction<T, Long> field) { |
| | | if (deptId != null) { |
| | | wrapper.eq(field, deptId); |
| | | } |
| | | } |
| | | |
| | | private LoginUser currentLoginUser(String memoryId) { |
| | | LoginUser loginUser = aiSessionUserContext.get(memoryId); |
| | | if (loginUser != null) { |
| | | return loginUser; |
| | | } |
| | | return SecurityUtils.getLoginUser(); |
| | | } |
| | | |
| | | private DateRange resolveDateRange(String startDate, String endDate, String timeRange) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate explicitStart = parseLocalDate(startDate); |
| | | LocalDate explicitEnd = parseLocalDate(endDate); |
| | | if (explicitStart != null || explicitEnd != null) { |
| | | LocalDate start = explicitStart != null ? explicitStart : explicitEnd; |
| | | LocalDate end = explicitEnd != null ? explicitEnd : explicitStart; |
| | | if (start.isAfter(end)) { |
| | | LocalDate temp = start; |
| | | start = end; |
| | | end = temp; |
| | | } |
| | | return new DateRange(start, end, start + "è³" + end); |
| | | } |
| | | if (!StringUtils.hasText(timeRange)) { |
| | | return new DateRange(today.minusDays(29), today, "è¿30天"); |
| | | } |
| | | String text = timeRange.trim(); |
| | | if (text.contains("ä»å¤©")) { |
| | | return new DateRange(today, today, "ä»å¤©"); |
| | | } |
| | | if (text.contains("æ¨å¤©") || text.contains("æ¨æ¥")) { |
| | | LocalDate day = today.minusDays(1); |
| | | return new DateRange(day, day, "æ¨å¤©"); |
| | | } |
| | | if (text.contains("æ¬å¨")) { |
| | | LocalDate start = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | return new DateRange(start, today, "æ¬å¨"); |
| | | } |
| | | if (text.contains("ä¸å¨")) { |
| | | LocalDate thisWeekStart = today.minusDays(today.getDayOfWeek().getValue() - 1L); |
| | | LocalDate start = thisWeekStart.minusWeeks(1); |
| | | LocalDate end = thisWeekStart.minusDays(1); |
| | | return new DateRange(start, end, "ä¸å¨"); |
| | | } |
| | | if (text.contains("æ¬æ")) { |
| | | return new DateRange(today.withDayOfMonth(1), today, "æ¬æ"); |
| | | } |
| | | if (text.contains("䏿")) { |
| | | YearMonth lastMonth = YearMonth.from(today).minusMonths(1); |
| | | return new DateRange(lastMonth.atDay(1), lastMonth.atEndOfMonth(), "䏿"); |
| | | } |
| | | if (text.contains("ä»å¹´") || text.contains("æ¬å¹´")) { |
| | | return new DateRange(today.withDayOfYear(1), today, "ä»å¹´"); |
| | | } |
| | | if (text.contains("å»å¹´")) { |
| | | LocalDate start = today.minusYears(1).withDayOfYear(1); |
| | | LocalDate end = today.minusYears(1).withMonth(12).withDayOfMonth(31); |
| | | return new DateRange(start, end, "å»å¹´"); |
| | | } |
| | | Matcher relativeMatcher = RELATIVE_PATTERN.matcher(text); |
| | | if (relativeMatcher.find()) { |
| | | int amount = Integer.parseInt(relativeMatcher.group(2)); |
| | | String unit = relativeMatcher.group(3); |
| | | LocalDate start = switch (unit) { |
| | | case "天" -> today.minusDays(Math.max(amount - 1L, 0)); |
| | | case "å¨" -> today.minusWeeks(Math.max(amount, 1)).plusDays(1); |
| | | case "个æ", "æ" -> today.minusMonths(Math.max(amount, 1)).plusDays(1); |
| | | case "å¹´" -> today.minusYears(Math.max(amount, 1)).plusDays(1); |
| | | default -> today.minusDays(29); |
| | | }; |
| | | return new DateRange(start, today, "è¿" + amount + unit); |
| | | } |
| | | Matcher dateMatcher = DATE_PATTERN.matcher(text); |
| | | if (dateMatcher.find()) { |
| | | LocalDate start = parseLocalDate(dateMatcher.group(1)); |
| | | LocalDate end = dateMatcher.find() ? parseLocalDate(dateMatcher.group(1)) : start; |
| | | if (start != null && end != null) { |
| | | if (start.isAfter(end)) { |
| | | LocalDate temp = start; |
| | | start = end; |
| | | end = temp; |
| | | } |
| | | return new DateRange(start, end, start + "è³" + end); |
| | | } |
| | | } |
| | | return new DateRange(today.minusDays(29), today, "è¿30天"); |
| | | } |
| | | |
| | | private LocalDate parseLocalDate(String text) { |
| | | if (!StringUtils.hasText(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return LocalDate.parse(text.trim(), DATE_FMT); |
| | | } catch (Exception ignored) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private Date toDate(LocalDate localDate) { |
| | | return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private Date toExclusiveEndDate(LocalDate localDate) { |
| | | return Date.from(localDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private LocalDate toLocalDate(Date date) { |
| | | if (date == null) { |
| | | return null; |
| | | } |
| | | return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | } |
| | | |
| | | private String formatDate(Date date) { |
| | | LocalDate localDate = toLocalDate(date); |
| | | return formatDate(localDate); |
| | | } |
| | | |
| | | private String formatDate(LocalDate date) { |
| | | return date == null ? "" : date.format(DATE_FMT); |
| | | } |
| | | |
| | | private String formatDateTime(LocalDateTime time) { |
| | | return time == null ? "" : time.toString().replace('T', ' '); |
| | | } |
| | | |
| | | private BigDecimal defaultDecimal(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private BigDecimal asBigDecimal(Object value) { |
| | | if (value == null) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | if (value instanceof BigDecimal decimal) { |
| | | return decimal; |
| | | } |
| | | if (value instanceof Number number) { |
| | | return new BigDecimal(String.valueOf(number)); |
| | | } |
| | | try { |
| | | return new BigDecimal(String.valueOf(value)); |
| | | } catch (Exception ignored) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | } |
| | | |
| | | private BigDecimal maxZero(BigDecimal value) { |
| | | return value == null || value.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private String toRate(long numerator, long denominator) { |
| | | if (denominator <= 0) { |
| | | return "0.00%"; |
| | | } |
| | | BigDecimal rate = new BigDecimal(numerator) |
| | | .multiply(ONE_HUNDRED) |
| | | .divide(new BigDecimal(denominator), 2, RoundingMode.HALF_UP); |
| | | return rate.toPlainString() + "%"; |
| | | } |
| | | |
| | | private String toPercent(BigDecimal decimal) { |
| | | if (decimal == null) { |
| | | return "0.00%"; |
| | | } |
| | | BigDecimal rate = decimal.multiply(ONE_HUNDRED).setScale(2, RoundingMode.HALF_UP); |
| | | return rate.toPlainString() + "%"; |
| | | } |
| | | |
| | | private String safe(Object value) { |
| | | return value == null ? "" : String.valueOf(value).replace('\n', ' ').replace('\r', ' ').trim(); |
| | | } |
| | | |
| | | private <T> List<T> defaultList(List<T> list) { |
| | | return list == null ? List.of() : list; |
| | | } |
| | | |
| | | private Map<String, Object> rangeSummary(DateRange range, int count, String keyword) { |
| | | Map<String, Object> summary = new LinkedHashMap<>(); |
| | | summary.put("timeRange", range.label()); |
| | | summary.put("startDate", range.start().toString()); |
| | | summary.put("endDate", range.end().toString()); |
| | | summary.put("count", count); |
| | | summary.put("keyword", safe(keyword)); |
| | | return summary; |
| | | } |
| | | |
| | | private Map<String, Object> buildAmountBarOption(BigDecimal contractAmount, |
| | | BigDecimal quotationAmount, |
| | | BigDecimal receivedAmount, |
| | | BigDecimal pendingAmount) { |
| | | List<String> xData = List.of("ååé¢", "æ¥ä»·é¢", "忬¾é¢", "å¾
忬¾"); |
| | | List<BigDecimal> yData = List.of(contractAmount, quotationAmount, receivedAmount, pendingAmount); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "éå®ç»è¥é颿¦è§", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "éé¢", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildShippingPieOption(long shippedCount, long pendingCount) { |
| | | List<Map<String, Object>> data = List.of( |
| | | Map.of("name", "å·²åè´§", "value", shippedCount), |
| | | Map.of("name", "æªåè´§", "value", pendingCount) |
| | | ); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "åè´§ç¶æåå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "item")); |
| | | option.put("series", List.of(Map.of("type", "pie", "radius", "60%", "data", data))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildCustomerTopBarOption(List<Map<String, Object>> topCustomers) { |
| | | List<String> xData = new ArrayList<>(); |
| | | List<BigDecimal> yData = new ArrayList<>(); |
| | | for (Map<String, Object> item : topCustomers) { |
| | | xData.add(String.valueOf(item.get("customerName"))); |
| | | yData.add((BigDecimal) item.get("contractAmount")); |
| | | } |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "客æ·ååé¢TOP5", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "ååé¢", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildContractTrendLineOption(List<String> labels, List<BigDecimal> values) { |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "ååé¢æåº¦è¶å¿", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", labels)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "ååé¢", "type", "line", "smooth", true, "data", values))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildRiskLevelPieOption(long highCount, long mediumCount, long lowCount) { |
| | | List<Map<String, Object>> data = List.of( |
| | | Map.of("name", "é«é£é©", "value", highCount), |
| | | Map.of("name", "ä¸é£é©", "value", mediumCount), |
| | | Map.of("name", "ä½é£é©", "value", lowCount) |
| | | ); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "客æ·é£é©ç级åå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "item")); |
| | | option.put("series", List.of(Map.of("name", "é£é©ç级", "type", "pie", "radius", "60%", "data", data))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildRiskScoreBarOption(List<CustomerRiskMetric> metrics) { |
| | | List<String> xData = metrics.stream().map(CustomerRiskMetric::getCustomerName).collect(Collectors.toList()); |
| | | List<Integer> yData = metrics.stream().map(CustomerRiskMetric::getRiskScore).collect(Collectors.toList()); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "客æ·é£é©åå¼", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value", "max", 100)); |
| | | option.put("series", List.of(Map.of("name", "é£é©åå¼", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildPendingAmountBarOption(List<CustomerRiskMetric> metrics) { |
| | | List<String> xData = metrics.stream().map(CustomerRiskMetric::getCustomerName).collect(Collectors.toList()); |
| | | List<BigDecimal> yData = metrics.stream().map(CustomerRiskMetric::getPendingAmount).collect(Collectors.toList()); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "客æ·å¾
忬¾æå", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "axis")); |
| | | option.put("xAxis", Map.of("type", "category", "data", xData)); |
| | | option.put("yAxis", Map.of("type", "value")); |
| | | option.put("series", List.of(Map.of("name", "å¾
忬¾", "type", "bar", "data", yData))); |
| | | return option; |
| | | } |
| | | |
| | | private Map<String, Object> buildPriorityPieOption(long high, long medium, long low) { |
| | | List<Map<String, Object>> data = List.of( |
| | | Map.of("name", "é«ä¼å
级", "value", high), |
| | | Map.of("name", "ä¸ä¼å
级", "value", medium), |
| | | Map.of("name", "ä½ä¼å
级", "value", low) |
| | | ); |
| | | Map<String, Object> option = new LinkedHashMap<>(); |
| | | option.put("title", Map.of("text", "çç¥ä¼å
级åå¸", "left", "center")); |
| | | option.put("tooltip", Map.of("trigger", "item")); |
| | | option.put("series", List.of(Map.of("name", "ä¼å
级", "type", "pie", "radius", "60%", "data", data))); |
| | | return option; |
| | | } |
| | | |
| | | private String jsonResponse(boolean success, |
| | | String type, |
| | | String description, |
| | | Map<String, Object> summary, |
| | | Map<String, Object> data, |
| | | Map<String, Object> charts) { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("success", success); |
| | | result.put("type", type); |
| | | result.put("description", description); |
| | | result.put("summary", summary == null ? Map.of() : summary); |
| | | result.put("data", data == null ? Map.of() : data); |
| | | result.put("charts", charts == null ? Map.of() : charts); |
| | | return JSON.toJSONString(result); |
| | | } |
| | | |
| | | private record DateRange(LocalDate start, LocalDate end, String label) { |
| | | } |
| | | |
| | | private record TrendData(List<String> labels, List<BigDecimal> values) { |
| | | private List<Map<String, Object>> toItemList() { |
| | | List<Map<String, Object>> items = new LinkedList<>(); |
| | | for (int i = 0; i < labels.size(); i++) { |
| | | Map<String, Object> item = new LinkedHashMap<>(); |
| | | item.put("month", labels.get(i)); |
| | | item.put("amount", values.get(i)); |
| | | items.add(item); |
| | | } |
| | | return items; |
| | | } |
| | | } |
| | | |
| | | private static class CustomerRiskMetric { |
| | | private final String customerName; |
| | | private final List<Long> ledgerIds = new ArrayList<>(); |
| | | private final Map<Long, LocalDate> deliveryDateByLedgerId = new HashMap<>(); |
| | | private BigDecimal contractAmount = BigDecimal.ZERO; |
| | | private BigDecimal receivedAmount = BigDecimal.ZERO; |
| | | private BigDecimal pendingAmount = BigDecimal.ZERO; |
| | | private BigDecimal pendingRate = BigDecimal.ZERO; |
| | | private BigDecimal quoteAmount = BigDecimal.ZERO; |
| | | private BigDecimal topSingleOrderAmount = BigDecimal.ZERO; |
| | | private int orderCount; |
| | | private int quoteCount; |
| | | private LocalDate lastOrderDate; |
| | | private long daysSinceLastOrder; |
| | | private long overdueDeliveryCount; |
| | | private int riskScore; |
| | | private String riskLevel = "low"; |
| | | private List<String> riskReasons = new ArrayList<>(); |
| | | |
| | | private CustomerRiskMetric(String customerName) { |
| | | this.customerName = customerName; |
| | | } |
| | | |
| | | private String getCustomerName() { |
| | | return customerName; |
| | | } |
| | | |
| | | private List<Long> getLedgerIds() { |
| | | return ledgerIds; |
| | | } |
| | | |
| | | private Map<Long, LocalDate> getDeliveryDateByLedgerId() { |
| | | return deliveryDateByLedgerId; |
| | | } |
| | | |
| | | private BigDecimal getContractAmount() { |
| | | return contractAmount; |
| | | } |
| | | |
| | | private void setContractAmount(BigDecimal contractAmount) { |
| | | this.contractAmount = contractAmount; |
| | | } |
| | | |
| | | private BigDecimal getReceivedAmount() { |
| | | return receivedAmount; |
| | | } |
| | | |
| | | private void setReceivedAmount(BigDecimal receivedAmount) { |
| | | this.receivedAmount = receivedAmount; |
| | | } |
| | | |
| | | private BigDecimal getPendingAmount() { |
| | | return pendingAmount; |
| | | } |
| | | |
| | | private void setPendingAmount(BigDecimal pendingAmount) { |
| | | this.pendingAmount = pendingAmount; |
| | | } |
| | | |
| | | private BigDecimal getPendingRate() { |
| | | return pendingRate; |
| | | } |
| | | |
| | | private void setPendingRate(BigDecimal pendingRate) { |
| | | this.pendingRate = pendingRate; |
| | | } |
| | | |
| | | private BigDecimal getQuoteAmount() { |
| | | return quoteAmount; |
| | | } |
| | | |
| | | private void setQuoteAmount(BigDecimal quoteAmount) { |
| | | this.quoteAmount = quoteAmount; |
| | | } |
| | | |
| | | private BigDecimal getTopSingleOrderAmount() { |
| | | return topSingleOrderAmount; |
| | | } |
| | | |
| | | private void setTopSingleOrderAmount(BigDecimal topSingleOrderAmount) { |
| | | this.topSingleOrderAmount = topSingleOrderAmount; |
| | | } |
| | | |
| | | private int getOrderCount() { |
| | | return orderCount; |
| | | } |
| | | |
| | | private void setOrderCount(int orderCount) { |
| | | this.orderCount = orderCount; |
| | | } |
| | | |
| | | private int getQuoteCount() { |
| | | return quoteCount; |
| | | } |
| | | |
| | | private void setQuoteCount(int quoteCount) { |
| | | this.quoteCount = quoteCount; |
| | | } |
| | | |
| | | private LocalDate getLastOrderDate() { |
| | | return lastOrderDate; |
| | | } |
| | | |
| | | private void setLastOrderDate(LocalDate lastOrderDate) { |
| | | this.lastOrderDate = lastOrderDate; |
| | | } |
| | | |
| | | private long getDaysSinceLastOrder() { |
| | | return daysSinceLastOrder; |
| | | } |
| | | |
| | | private void setDaysSinceLastOrder(long daysSinceLastOrder) { |
| | | this.daysSinceLastOrder = daysSinceLastOrder; |
| | | } |
| | | |
| | | private long getOverdueDeliveryCount() { |
| | | return overdueDeliveryCount; |
| | | } |
| | | |
| | | private void setOverdueDeliveryCount(long overdueDeliveryCount) { |
| | | this.overdueDeliveryCount = overdueDeliveryCount; |
| | | } |
| | | |
| | | private int getRiskScore() { |
| | | return riskScore; |
| | | } |
| | | |
| | | private void setRiskScore(int riskScore) { |
| | | this.riskScore = riskScore; |
| | | } |
| | | |
| | | private String getRiskLevel() { |
| | | return riskLevel; |
| | | } |
| | | |
| | | private void setRiskLevel(String riskLevel) { |
| | | this.riskLevel = riskLevel; |
| | | } |
| | | |
| | | private List<String> getRiskReasons() { |
| | | return riskReasons; |
| | | } |
| | | |
| | | private void setRiskReasons(List<String> riskReasons) { |
| | | this.riskReasons = riskReasons; |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @Schema(description = "åºå·®å¼å§æ¶é´") |
| | | private LocalDateTime startDateTime; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @Schema(description = "åºå·®ç»ææ¶é´") |
| | | private LocalDateTime endDateTime; |
| | | |
| | | private BigDecimal price; |
| | | |
| | | private String location; |
| | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @Schema(description = "åºå·®å¼å§æ¶é´") |
| | | private LocalDateTime startDateTime; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @Schema(description = "åºå·®ç»ææ¶é´") |
| | | private LocalDateTime endDateTime; |
| | | |
| | | private BigDecimal price; |
| | | |
| | | private String location; |
| | |
| | | */ |
| | | private BigDecimal maintenancePrice; |
| | | |
| | | private List<StorageBlobDTO> storageBlobDTOList; |
| | | private List<StorageBlobDTO> storageBlobDTOS; |
| | | } |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | |
| | | @Excel(name = "åºå·®å¼å§æ¶é´", dateFormat = "yyyy-MM-dd HH:mm", width = 30) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @Schema(description = "åºå·®å¼å§æ¶é´") |
| | | private LocalDateTime startDateTime; |
| | | |
| | | @Excel(name = "åºå·®ç»ææ¶é´", dateFormat = "yyyy-MM-dd HH:mm", width = 30) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm") |
| | | @Schema(description = "åºå·®ç»ææ¶é´") |
| | | private LocalDateTime endDateTime; |
| | | |
| | | private BigDecimal price; |
| | | |
| | | private String location; |
| | |
| | | if (shippingInfo != null) { |
| | | if (status.equals(2)) { |
| | | shippingInfo.setStatus("å®¡æ ¸éè¿"); |
| | | shippingInfo.setShippingDate(new Date()); |
| | | //æ´æ¹åºåºå®¡æ ¸ç¶æï¼å¾
ç¡®è®¤æ¹æå¾
å®¡æ ¸ï¼ |
| | | stockUtils.shipmentStatus(StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), shippingInfo.getId()); |
| | | } else if (status.equals(3)) { |
| | | //å é¤åæ¬ï¼å¾
确认ï¼çåºåºå®¡æ ¸ç¶æ |
| | | stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode()); |
| | | shippingInfo.setStatus("å®¡æ ¸æç»"); |
| | | } else if (status.equals(1)) { |
| | | shippingInfo.setStatus("å®¡æ ¸ä¸"); |
| | |
| | | approveProcess.setPrice(approveProcessVO.getPrice()); |
| | | approveProcess.setStartDate(approveProcessVO.getStartDate()); |
| | | approveProcess.setEndDate(approveProcessVO.getEndDate()); |
| | | approveProcess.setStartDateTime(approveProcessVO.getStartDateTime()); |
| | | approveProcess.setEndDateTime(approveProcessVO.getEndDateTime()); |
| | | approveProcess.setApproveStatus(0); |
| | | approveProcess.setApproveDelete(0); |
| | | approveProcess.setApproveType(approveProcessVO.getApproveType()); |
| | |
| | | .collect(Collectors.joining(",")); |
| | | approveNodeService.initApproveNodes(nodeIdStr, no, approveProcessVO.getApproveDeptId()); |
| | | // éä»¶ç»å® |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVE_PROCESS, approveProcess.getId(), approveProcessVO.getStorageBlobDTOList()); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVE_PROCESS, approveProcess.getId(), approveProcessVO.getStorageBlobDTOS()); |
| | | /*æ¶æ¯éç¥*/ |
| | | Long id = nodeIds.getFirst(); |
| | | if (approveProcess.getApproveType() == 8) { |
| | |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.production.bean.dto.ProductStructureDto; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.List; |
| | | |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @Data |
| | | public class ProductModelDto extends ProductModel { |
| | | private List<ProductStructureDto> productStructureList; |
| | |
| | | SALES_QUOTATION("sales_quotation"), |
| | | SALES_LEDGER_PRODUCT("sales_ledger_product"), |
| | | PURCHASE_LEDGER_FILE("purchase_ledger_file"), |
| | | RECEIPT_PAYMENT("receipt_payment"), |
| | | PAYMENT_SHIPPING("payment_shipping"), |
| | | INVOICE_REGISTRATION_PRODUCT("invoice_registration_product"), |
| | | LOSS("loss"), |
| | | INVOICE_REGISTRATION("invoice_registration"), |
| | | INVOICE_LEDGER_FILE("invoice_ledger_file"), |
| | | INVOICE_LEDGER("invoice_ledger"), |
| | | COMMON_FILE("common_file"), |
| | |
| | | QUALITY_INSPECT_PARAM("quality_inspect_param"), |
| | | QUALITY_INSPECT("quality_inspect"), |
| | | // Purchase |
| | | TICKET_REGISTRATION("ticket_registration"), |
| | | PURCHASE_RETURN_ORDER_PRODUCTS("purchase_return_order_products"), |
| | | PURCHASE_RETURN_ORDERS("purchase_return_orders"), |
| | | SALES_LEDGER_PRODUCT_TEMPLATE("sales_ledger_product_template"), |
| | | PURCHASE_LEDGER("purchase_ledger"), |
| | | PURCHASE_LEDGER_TEMPLATE("purchase_ledger_template"), |
| | | PRODUCT_RECORD("product_record"), |
| | | PAYMENT_REGISTRATION("payment_registration"), |
| | | INVOICE_PURCHASE("invoice_purchase"), |
| | | // Project Management |
| | | SHIPPING_ADDRESS("shipping_address"), |
| | | ROLES("roles"), |
| | |
| | | AFTER_SALES_SERVICE_FILE("after_sales_service_file"), |
| | | AFTER_SALES_NEAR_EXPIRY("after_sales_near_expiry"), |
| | | // Account |
| | | ACCOUNT_INCOME("account_income"), |
| | | BORROW_INFO("borrow_info"), |
| | | SALES_REFUND_AMOUNT_ORDER("sales_refund_amount_order"), |
| | | SALES_RECEIPT_RETURN("sales_receipt_return"), |
| | | ACCOUNT_EXPENSE("account_expense"), |
| | | ACCOUNT_FILE("account_file"); |
| | | FIN_VOUCHER("fin_voucher"), |
| | | ACCOUNT_INVOICE_APPLICATION("account_invoice_application"), |
| | | ACCOUNT_PURCHASE_INVOICE("account_purchase_invoice"); |
| | | |
| | | private final String type; |
| | | RecordTypeEnum(String type) { this.type = type; } |
| | |
| | | import com.ruoyi.basic.dto.CustomerDto; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.vo.CustomerVo; |
| | | import com.ruoyi.sales.vo.CustomerTransactionsDetailsVo; |
| | | import com.ruoyi.sales.vo.CustomerTransactionsVo; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | |
| | | /** |
| | | * å®¢æ·æ¡£æ¡Mapperæ¥å£ |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | * @date 2025-05-07 |
| | | */ |
| | |
| | | { |
| | | /** |
| | | * æ¥è¯¢å®¢æ·æ¡£æ¡ |
| | | * |
| | | * |
| | | * @param id å®¢æ·æ¡£æ¡ä¸»é® |
| | | * @return å®¢æ·æ¡£æ¡ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ¥è¯¢å®¢æ·æ¡£æ¡å表 |
| | | * |
| | | * |
| | | * @param customer å®¢æ·æ¡£æ¡ |
| | | * @return å®¢æ·æ¡£æ¡éå |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ°å¢å®¢æ·æ¡£æ¡ |
| | | * |
| | | * |
| | | * @param customer å®¢æ·æ¡£æ¡ |
| | | * @return ç»æ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * ä¿®æ¹å®¢æ·æ¡£æ¡ |
| | | * |
| | | * |
| | | * @param customer å®¢æ·æ¡£æ¡ |
| | | * @return ç»æ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * å é¤å®¢æ·æ¡£æ¡ |
| | | * |
| | | * |
| | | * @param id å®¢æ·æ¡£æ¡ä¸»é® |
| | | * @return ç»æ |
| | | */ |
| | |
| | | |
| | | /** |
| | | * æ¹éå é¤å®¢æ·æ¡£æ¡ |
| | | * |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ä¸»é®éå |
| | | * @return ç»æ |
| | | */ |
| | |
| | | IPage<CustomerVo> listPage(Page<CustomerDto> page, @Param("c") CustomerDto customer, @Param("loginUserId") Long loginUserId); |
| | | |
| | | List<CustomerVo> list(@Param("c") CustomerDto customer, @Param("loginUserId") Long loginUserId); |
| | | } |
| | | |
| | | IPage<CustomerTransactionsVo> customewTransactions(Page page, @Param("customerName") String customerName); |
| | | |
| | | IPage<CustomerTransactionsDetailsVo> customewTransactionsDetails(Page page, @Param("customerId") Long customerId); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.vo.ProductModelVo; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementPageDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementPageDto; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.excel.SupplierManageExcelDto; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.purchase.vo.SupplierTransactionsDetailsVo; |
| | | import com.ruoyi.purchase.vo.SupplierTransactionsVo; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | IPage<SupplierManage> supplierListPage(Page page, @Param("supplierManageDto") SupplierManageDto supplierManageDto); |
| | | |
| | | List<SupplierManageExcelDto> supplierExportList(@Param("supplierManageDto") SupplierManageDto supplierManageDto); |
| | | |
| | | IPage<SupplierTransactionsVo> supplierTransactions(Page page, @Param("supplierName") String supplierName); |
| | | |
| | | IPage<SupplierTransactionsDetailsVo> supplierTransactionsDetails(Page page, @Param("supplierId") Long supplierId); |
| | | } |
| | |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | |
| | | /** |
| | | * çäº§çæº |
| | | */ |
| | | @Excel(name = "çäº§çæº") |
| | | private String speculativeTradingName; |
| | | |
| | | @Schema(description = "ç§æ·ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.basic.vo.CustomerVo; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.sales.vo.CustomerTransactionsDetailsVo; |
| | | import com.ruoyi.sales.vo.CustomerTransactionsVo; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | |
| | | void together(CustomerDto customerDto); |
| | | |
| | | Boolean back(Long id); |
| | | |
| | | /** |
| | | * æ¥è¯¢å®¢æ·å¾æ¥å表 |
| | | * @param page |
| | | * @param customerName |
| | | * @return |
| | | */ |
| | | IPage<CustomerTransactionsVo> customewTransactions(Page page, String customerName); |
| | | |
| | | /** |
| | | * æ¥è¯¢å®¢æ·å¾æ¥æç»å表 |
| | | * @param page |
| | | * @param customerId |
| | | * @return |
| | | */ |
| | | IPage<CustomerTransactionsDetailsVo> customewTransactionsDetails(Page page, Long customerId); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.basic.pojo.SupplierManage; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.purchase.vo.SupplierTransactionsDetailsVo; |
| | | import com.ruoyi.purchase.vo.SupplierTransactionsVo; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | public interface ISupplierService extends IService<SupplierManage> { |
| | |
| | | void supplierExport(HttpServletResponse response, SupplierManageDto supplierManageDto); |
| | | |
| | | Boolean importData(MultipartFile file); |
| | | |
| | | /** |
| | | * ä¾åºå徿¥ |
| | | * @param page |
| | | * @param supplierName |
| | | * @return |
| | | */ |
| | | IPage<SupplierTransactionsVo> supplierTransactions(Page page, String supplierName); |
| | | |
| | | /** |
| | | * ä¾åºå徿¥è¯¦æ
|
| | | * @param page |
| | | * @param supplierId |
| | | * @return |
| | | */ |
| | | IPage<SupplierTransactionsDetailsVo> supplierTransactionsDetails(Page page, Long supplierId); |
| | | } |
| | |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.vo.CustomerTransactionsDetailsVo; |
| | | import com.ruoyi.sales.vo.CustomerTransactionsVo; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | return this.updateById(customer); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<CustomerTransactionsVo> customewTransactions(Page page, String customerName) { |
| | | return customerMapper.customewTransactions(page, customerName); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<CustomerTransactionsDetailsVo> customewTransactionsDetails(Page page, Long customerId) { |
| | | return customerMapper.customewTransactionsDetails(page, customerId); |
| | | } |
| | | |
| | | /** |
| | | * ä¸å线å½å转驼峰å½å |
| | | */ |
| | |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.sales.dto.LossProductModelDto; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.technology.mapper.TechnologyBomMapper; |
| | | import com.ruoyi.technology.pojo.TechnologyBom; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | private final ProductMapper productMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final TechnologyBomMapper technologyBomMapper; |
| | | private ProductModelMapper productModelMapper; |
| | | |
| | | @Override |
| | | public int addOrEditProductModel(ProductModelDto productModelDto) { |
| | | String model = StringUtils.trim(productModelDto.getModel()); |
| | | String productCode = StringUtils.trim(productModelDto.getProductCode()); |
| | | productModelDto.setModel(model); |
| | | productModelDto.setProductCode(productCode); |
| | | checkModelAndProductCodeUnique(model, productCode, productModelDto.getId()); |
| | | |
| | | if (productModelDto.getId() == null) { |
| | | ProductModel productModel = new ProductModel(); |
| | |
| | | return productModelMapper.insert(productModel); |
| | | } else { |
| | | return productModelMapper.updateById(productModelDto); |
| | | } |
| | | } |
| | | |
| | | private void checkModelAndProductCodeUnique(String model, String productCode, Long currentId) { |
| | | if (StringUtils.isEmpty(model) || StringUtils.isEmpty(productCode)) { |
| | | return; |
| | | } |
| | | LambdaQueryWrapper<ProductModel> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductModel::getModel, model) |
| | | .eq(ProductModel::getProductCode, productCode) |
| | | .ne(currentId != null, ProductModel::getId, currentId) |
| | | .last("limit 1"); |
| | | ProductModel duplicateProductModel = productModelMapper.selectOne(queryWrapper); |
| | | if (duplicateProductModel != null) { |
| | | throw new ServiceException("对åºçåå·" + model + "ç产åç¼ç " + productCode + "å·²ç»åå¨"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | throw new RuntimeException("å·²ç»åå¨è¯¥äº§åçéå®å°è´¦åéè´å°è´¦"); |
| | | } |
| | | |
| | | // æ¯å¦åå¨BOM |
| | | List<TechnologyBom> technologyBoms = technologyBomMapper.selectList(new QueryWrapper<TechnologyBom>() |
| | | .lambda().in(TechnologyBom::getProductModelId, ids)); |
| | | if (CollectionUtils.isNotEmpty(technologyBoms)) { |
| | | throw new RuntimeException("å·²ç»åå¨è¯¥äº§åçBOMæ°æ®"); |
| | | } |
| | | |
| | | return productModelMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductService; |
| | | import com.ruoyi.basic.vo.ProductModelVo; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | if (ObjectUtils.isEmpty(productDto.getParentId())) { |
| | | throw new IllegalArgumentException("è¯·éæ©ç¶èç¹"); |
| | | } |
| | | String productName = StringUtils.trim(productDto.getProductName()); |
| | | if (StringUtils.isEmpty(productName)) { |
| | | throw new IllegalArgumentException("产ååç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | productDto.setProductName(productName); |
| | | checkProductNameUnique(productDto.getParentId(), productName, productDto.getId()); |
| | | if (productDto.getId() == null) { |
| | | // æ°å¢äº§åé»è¾ |
| | | if (productDto.getParentId() == null) { |
| | | // è¥æªæå®ç¶èç¹ï¼é»è®¤ä¸ºæ ¹èç¹ï¼parentId 设为 nullï¼ |
| | | productDto.setParentId(null); |
| | | } else { |
| | | // æ£æ¥ç¶èç¹æ¯å¦åå¨ï¼å¯éï¼æ ¹æ®ä¸å¡éæ±ï¼ |
| | | Product parent = productMapper.selectById(productDto.getParentId()); |
| | | if (parent == null) { |
| | | throw new IllegalArgumentException("ç¶èç¹ä¸åå¨ï¼æ æ³æ·»å å产å"); |
| | | } |
| | | // æ£æ¥ç¶èç¹æ¯å¦åå¨ï¼å¯éï¼æ ¹æ®ä¸å¡éæ±ï¼ |
| | | Product parent = productMapper.selectById(productDto.getParentId()); |
| | | if (parent == null) { |
| | | throw new IllegalArgumentException("ç¶èç¹ä¸åå¨ï¼æ æ³æ·»å å产å"); |
| | | } |
| | | return productMapper.insert(productDto); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | private void checkProductNameUnique(Long parentId, String productName, Long currentId) { |
| | | LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Product::getParentId, parentId) |
| | | .eq(Product::getProductName, productName) |
| | | .ne(currentId != null, Product::getId, currentId) |
| | | .last("limit 1"); |
| | | Product duplicateProduct = productMapper.selectOne(queryWrapper); |
| | | if (duplicateProduct != null) { |
| | | throw new IllegalArgumentException("对åºç" + productName + "å·²ç»åå¨"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int delProductByIds(Long[] ids) { |
| | | // 1. å é¤å表 product_model ä¸å
³èçæ°æ® |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.purchase.vo.SupplierTransactionsDetailsVo; |
| | | import com.ruoyi.purchase.vo.SupplierTransactionsVo; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<SupplierTransactionsVo> supplierTransactions(Page page, String supplierName) { |
| | | return supplierMapper.supplierTransactions(page,supplierName); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<SupplierTransactionsDetailsVo> supplierTransactionsDetails(Page page, Long supplierId) { |
| | | return supplierMapper.supplierTransactionsDetails(page,supplierId); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.approve.pojo.KnowledgeBase; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.collaborativeApproval.dto.SealApplicationManagementDTO; |
| | | import com.ruoyi.collaborativeApproval.pojo.SealApplicationManagement; |
| | | import com.ruoyi.collaborativeApproval.service.SealApplicationManagementService; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | |
| | | public class SealApplicationManagementController { |
| | | private SealApplicationManagementService sealApplicationManagementService; |
| | | private ISysNoticeService sysNoticeService; |
| | | private FileUtil fileUtil; |
| | | |
| | | @GetMapping("/getList") |
| | | @Operation(summary = "å页æ¥è¯¢") |
| | |
| | | |
| | | @PostMapping("/add") |
| | | @Operation(summary = "æ°å¢") |
| | | public AjaxResult add(@RequestBody SealApplicationManagement sealApplicationManagement){ |
| | | public AjaxResult add(@RequestBody SealApplicationManagementDTO sealApplicationManagement){ |
| | | sealApplicationManagementService.save(sealApplicationManagement); |
| | | // 5. ä¿åéå®å°è´¦éä»¶ |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, |
| | | RecordTypeEnum.SEAL_APPLICATION_MANAGEMENT, |
| | | sealApplicationManagement.getId(), |
| | | sealApplicationManagement.getStorageBlobDTOs()); |
| | | //æ¶æ¯éç¥ |
| | | sysNoticeService.simpleNoticeByUser("ç¨å°å®¡æ¹", |
| | | "ç³è¯·ç¼å·ï¼"+sealApplicationManagement.getApplicationNum()+"\t" |
| | |
| | | |
| | | @PostMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹") |
| | | public AjaxResult update(@RequestBody SealApplicationManagement sealApplicationManagement){ |
| | | public AjaxResult update(@RequestBody SealApplicationManagementDTO sealApplicationManagement){ |
| | | // 5. ä¿åéå®å°è´¦éä»¶ |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, |
| | | RecordTypeEnum.SEAL_APPLICATION_MANAGEMENT, |
| | | sealApplicationManagement.getId(), |
| | | sealApplicationManagement.getStorageBlobDTOs()); |
| | | return AjaxResult.success(sealApplicationManagementService.updateById(sealApplicationManagement)); |
| | | } |
| | | |
| | |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | throw new RuntimeException("è¯·ä¼ å
¥è¦å é¤çID"); |
| | | } |
| | | fileUtil.deleteStorageAttachmentsByApplicationAndRecordTypeAndRecordIds(ApplicationTypeEnum.FILE, |
| | | RecordTypeEnum.SEAL_APPLICATION_MANAGEMENT, |
| | | ids); |
| | | return AjaxResult.success(sealApplicationManagementService.removeBatchByIds(ids)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.collaborativeApproval.dto; |
| | | |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.dto.StorageBlobVO; |
| | | import com.ruoyi.collaborativeApproval.pojo.SealApplicationManagement; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class SealApplicationManagementDTO extends SealApplicationManagement { |
| | |
| | | |
| | | //审æ¹äºº |
| | | private String approveUserName; |
| | | |
| | | private List<StorageBlobDTO> storageBlobDTOs; |
| | | private List<StorageBlobVO> storageBlobVOList; |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.collaborativeApproval.dto.SealApplicationManagementDTO; |
| | | import com.ruoyi.collaborativeApproval.mapper.SealApplicationManagementMapper; |
| | | import com.ruoyi.collaborativeApproval.pojo.SealApplicationManagement; |
| | |
| | | @RequiredArgsConstructor |
| | | public class SealApplicationManagementServiceImpl extends ServiceImpl<SealApplicationManagementMapper, SealApplicationManagement> implements SealApplicationManagementService { |
| | | private final SealApplicationManagementMapper sealApplicationManagementMapper; |
| | | private final FileUtil fileUtil; |
| | | |
| | | @Override |
| | | public IPage<SealApplicationManagementDTO> listPage(Page page, SealApplicationManagement sealApplicationManagement) { |
| | | return sealApplicationManagementMapper.listPage(page, sealApplicationManagement); |
| | | IPage<SealApplicationManagementDTO> sealApplicationManagementDTOIPage = sealApplicationManagementMapper.listPage(page, sealApplicationManagement); |
| | | sealApplicationManagementDTOIPage.getRecords().forEach(item -> { |
| | | item.setStorageBlobVOList(fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(RecordTypeEnum.SEAL_APPLICATION_MANAGEMENT, item.getId())); |
| | | }); |
| | | return sealApplicationManagementDTOIPage; |
| | | } |
| | | } |
| | |
| | | private DeviceMaintenanceMapper deviceMaintenanceMapper; |
| | | |
| | | |
| | | |
| | | @Operation(summary = "设å¤å°è´¦å表") |
| | | @GetMapping("/page") |
| | | public AjaxResult page(Page page , DeviceLedgerDto deviceLedger) { |
| | | return AjaxResult.success(deviceLedgerService.queryPage(page,deviceLedger)); |
| | | public AjaxResult page(Page page, DeviceLedgerDto deviceLedger) { |
| | | return AjaxResult.success(deviceLedgerService.queryPage(page, deviceLedger)); |
| | | } |
| | | |
| | | @PostMapping() |
| | | @Operation(summary = "æ·»å 设å¤å°è´¦") |
| | | public AjaxResult add(@RequestBody DeviceLedger deviceLedger) { |
| | | |
| | | return deviceLedgerService.saveDeviceLedger(deviceLedger); |
| | | public AjaxResult add(@RequestBody DeviceLedgerDto deviceLedgerDto) { |
| | | return deviceLedgerService.saveDeviceLedger(deviceLedgerDto); |
| | | } |
| | | |
| | | @Operation(summary = "æ ¹æ®idæ¥è¯¢è®¾å¤å°è´¦") |
| | | @GetMapping("/{id}") |
| | | public AjaxResult detail(@PathVariable Long id) { |
| | | return AjaxResult.success(deviceLedgerService.getById(id)); |
| | | DeviceLedgerDto deviceLedgerDto = deviceLedgerService.getDeviceLedgerDetail(id); |
| | | return AjaxResult.success(deviceLedgerDto); |
| | | } |
| | | |
| | | @PutMapping () |
| | | @PutMapping() |
| | | @Operation(summary = "ä¿®æ¹è®¾å¤å°è´¦") |
| | | public AjaxResult update(@RequestBody DeviceLedger deviceLedger) { |
| | | return deviceLedgerService.updateDeviceLedger(deviceLedger); |
| | | public AjaxResult update(@RequestBody DeviceLedgerDto deviceLedgerDto) { |
| | | return deviceLedgerService.updateDeviceLedger(deviceLedgerDto); |
| | | } |
| | | |
| | | @DeleteMapping("/{ids}") |
| | |
| | | @PostMapping("export") |
| | | @Operation(summary = "导åºè®¾å¤å°è´¦") |
| | | public void export(HttpServletResponse response, Long[] ids) { |
| | | deviceLedgerService.export(response, ids); |
| | | deviceLedgerService.export(response, ids); |
| | | } |
| | | |
| | | @Operation(summary = "ä¸è½½æ¨¡æ¿") |
| | |
| | | |
| | | @GetMapping("getDeviceLedger") |
| | | @Operation(summary = "è·å设å¤å°è´¦") |
| | | public AjaxResult getDeviceLedger( ) { |
| | | public AjaxResult getDeviceLedger() { |
| | | return AjaxResult.success(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda() |
| | | .select(DeviceLedger::getId, DeviceLedger::getDeviceName,DeviceLedger::getDeviceModel))); |
| | | .select(DeviceLedger::getId, DeviceLedger::getDeviceName, DeviceLedger::getDeviceModel))); |
| | | } |
| | | |
| | | @GetMapping("scanDevice") |
| | |
| | | public AjaxResult scanDevice(Long id) { |
| | | List<DeviceMaintenance> list = deviceMaintenanceMapper.list1(id); |
| | | DeviceLedger deviceLedger = deviceLedgerMapper.selectById1(id); |
| | | if (list.size()>0){ |
| | | deviceLedger.setUpdateTime(list.get(0).getMaintenanceActuallyTime());//æåç»´æ¤æ¶é´ |
| | | if (!list.isEmpty()) { |
| | | deviceLedger.setUpdateTime(list.getFirst().getMaintenanceActuallyTime());//æåç»´æ¤æ¶é´ |
| | | } |
| | | deviceLedger.setCreateTime(deviceLedger.getUpdateTime().plusMonths(1));//䏿¬¡ç»´æ¤æ¶é´ |
| | | return AjaxResult.success(deviceLedger); |
| | |
| | | return deviceRepairService.updateDeviceRepair(deviceRepairDto); |
| | | } |
| | | |
| | | @PostMapping ("repair") |
| | | @PostMapping ("/repair") |
| | | @Operation(summary = "设å¤ç»´ä¿®") |
| | | public AjaxResult repair( @RequestBody DeviceRepairDto deviceRepairDto) { |
| | | return deviceRepairService.updateDeviceRepair(deviceRepairDto); |
| | | return deviceRepairService.confirmRepair(deviceRepairDto); |
| | | } |
| | | |
| | | @PostMapping ("/acceptance") |
| | | @Operation(summary = "è®¾å¤æ¥ä¿®éªæ¶å®¡æ¹") |
| | | public AjaxResult acceptance(@RequestBody DeviceRepairDto deviceRepairDto) { |
| | | return deviceRepairService.approveRepairAcceptance(deviceRepairDto); |
| | | } |
| | | |
| | | @DeleteMapping("/{ids}") |
| | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.dto.StorageBlobVO; |
| | | |
| | | /** |
| | | * 设å¤å°è´¦å®ä½ç±» |
| | |
| | | private String supplierName; |
| | | |
| | | /** |
| | | * 设å¤éä»¶(ç¨äºæ¥æ¶) |
| | | */ |
| | | @TableField(exist = false) |
| | | @Schema(description = "设å¤éä»¶æ¥æ¶å表") |
| | | private List<StorageBlobDTO> storageBlobDTOs; |
| | | |
| | | /** |
| | | * 设å¤éä»¶(ç¨äºè¿å) |
| | | */ |
| | | @TableField(exist = false) |
| | | @Schema(description = "设å¤éä»¶å±ç¤ºå表") |
| | | private List<StorageBlobVO> storageBlobVOs; |
| | | |
| | | /** |
| | | * åä½ |
| | | */ |
| | | private String unit; |
| | |
| | | @Excel(name = "ç»´ä¿®ç»æ") |
| | | private String maintenanceResult; |
| | | |
| | | @Schema(description = "éªæ¶äºº") |
| | | @Excel(name = "éªæ¶äºº") |
| | | private String acceptanceName; |
| | | |
| | | @Schema(description = "éªæ¶æ¶é´") |
| | | @Excel(name = "éªæ¶æ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime acceptanceTime; |
| | | |
| | | @Schema(description = "éªæ¶å¤æ³¨") |
| | | @Excel(name = "éªæ¶å¤æ³¨") |
| | | private String acceptanceRemark; |
| | | |
| | | @Schema(description = "ç¶æ") |
| | | @Excel(name = "ç¶æ") |
| | | private String statusStr; |
| | |
| | | @Schema(description = "ç»´ä¿®ç»æ") |
| | | private String maintenanceResult; |
| | | |
| | | @Schema(description = "éªæ¶äºº") |
| | | private String acceptanceName; |
| | | |
| | | @Schema(description = "éªæ¶æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime acceptanceTime; |
| | | |
| | | @Schema(description = "éªæ¶å¤æ³¨") |
| | | private String acceptanceRemark; |
| | | |
| | | @Schema(description = "ç¶æ 0 å¾
ç»´ä¿® 1å®ç» 2 失败") |
| | | // 0:å¾
ç»´ä¿® 1:å®ç» 2:失败 3:å¾
éªæ¶ |
| | | private Integer status; |
| | | |
| | | @Schema(description = "å建æ¶é´") |
| | |
| | | @Schema(description = "设å¤id") |
| | | private Long taskId; |
| | | |
| | | @Schema(description = "ä¿å
»äºº") |
| | | @Excel(name = "ä¿å
»äºº") |
| | | private String maintenancePerson; |
| | | |
| | | @Schema(description = "颿¬¡") |
| | | @Excel(name = "颿¬¡") |
| | | private String frequencyType; |
| | |
| | | public interface IDeviceLedgerService extends IService<DeviceLedger> { |
| | | IPage<DeviceLedgerDto> queryPage(Page page, DeviceLedgerDto deviceLedger); |
| | | |
| | | AjaxResult saveDeviceLedger(DeviceLedger deviceLedger); |
| | | AjaxResult saveDeviceLedger(DeviceLedgerDto deviceLedgerDto); |
| | | |
| | | AjaxResult updateDeviceLedger(DeviceLedger deviceLedger); |
| | | AjaxResult updateDeviceLedger(DeviceLedgerDto deviceLedgerDto); |
| | | |
| | | DeviceLedgerDto getDeviceLedgerDetail(Long id); |
| | | |
| | | void export(HttpServletResponse response, Long[] ids); |
| | | |
| | |
| | | |
| | | AjaxResult updateDeviceRepair(DeviceRepairDto deviceRepairDto); |
| | | |
| | | AjaxResult confirmRepair(DeviceRepairDto deviceRepairDto); |
| | | |
| | | AjaxResult approveRepairAcceptance(DeviceRepairDto deviceRepairDto); |
| | | |
| | | void export(HttpServletResponse response, Long[] ids); |
| | | |
| | | DeviceRepairVo detailById(Long id); |
| | |
| | | import com.ruoyi.device.execl.DeviceLedgerExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.basic.dto.StorageAttachmentDTO; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.service.StorageAttachmentService; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | |
| | | |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final StorageAttachmentService storageAttachmentService; |
| | | |
| | | @Override |
| | | public IPage<DeviceLedgerDto> queryPage(Page page, DeviceLedgerDto deviceLedger) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult saveDeviceLedger(DeviceLedger deviceLedger) { |
| | | public AjaxResult saveDeviceLedger(DeviceLedgerDto deviceLedgerDto) { |
| | | LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedger.getDeviceName()); |
| | | deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedgerDto.getDeviceName()); |
| | | if (this.count(deviceLedgerLambdaQueryWrapper) > 0) { |
| | | return AjaxResult.error("设å¤åç§°å·²åå¨"); |
| | | } |
| | | DeviceLedger deviceLedger = new DeviceLedger(); |
| | | BeanUtils.copyProperties(deviceLedgerDto, deviceLedger); |
| | | boolean save = this.save(deviceLedger); |
| | | if (save){ |
| | | if (deviceLedgerDto.getStorageBlobDTOs() != null) { |
| | | StorageAttachmentDTO attachmentDTO = new StorageAttachmentDTO(); |
| | | attachmentDTO.setApplication("image"); |
| | | attachmentDTO.setRecordType(RecordTypeEnum.DEVICE_LEDGER.getType()); |
| | | attachmentDTO.setRecordId(deviceLedger.getId()); |
| | | attachmentDTO.setStorageBlobDTOs(deviceLedgerDto.getStorageBlobDTOs()); |
| | | storageAttachmentService.saveStorageAttachment(attachmentDTO); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult updateDeviceLedger(DeviceLedger deviceLedger) { |
| | | public AjaxResult updateDeviceLedger(DeviceLedgerDto deviceLedgerDto) { |
| | | DeviceLedger deviceLedger = new DeviceLedger(); |
| | | BeanUtils.copyProperties(deviceLedgerDto, deviceLedger); |
| | | if (this.updateById(deviceLedger)) { |
| | | if (deviceLedgerDto.getStorageBlobDTOs() != null) { |
| | | StorageAttachmentDTO attachmentDTO = new StorageAttachmentDTO(); |
| | | attachmentDTO.setApplication("image"); |
| | | attachmentDTO.setRecordType(RecordTypeEnum.DEVICE_LEDGER.getType()); |
| | | attachmentDTO.setRecordId(deviceLedger.getId()); |
| | | attachmentDTO.setStorageBlobDTOs(deviceLedgerDto.getStorageBlobDTOs()); |
| | | storageAttachmentService.saveStorageAttachment(attachmentDTO); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |
| | | public DeviceLedgerDto getDeviceLedgerDetail(Long id) { |
| | | DeviceLedger deviceLedger = this.getById(id); |
| | | if (deviceLedger != null) { |
| | | DeviceLedgerDto deviceLedgerDto = new DeviceLedgerDto(); |
| | | BeanUtils.copyProperties(deviceLedger, deviceLedgerDto); |
| | | StorageAttachmentDTO dto = new StorageAttachmentDTO(); |
| | | dto.setRecordType(RecordTypeEnum.DEVICE_LEDGER.getType()); |
| | | dto.setRecordId(id); |
| | | dto.setApplication("image"); |
| | | deviceLedgerDto.setStorageBlobVOs(storageAttachmentService.list(dto)); |
| | | return deviceLedgerDto; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | util.exportExcel(response, deviceLedgerExeclDtos, "设å¤å°è´¦å¯¼åº"); |
| | | }else { |
| | | ArrayList<Long> arrayList = new ArrayList<>(); |
| | | Arrays.stream(ids).map(id -> { |
| | | return arrayList.add( id); |
| | | }); |
| | | Arrays.stream(ids).map(arrayList::add); |
| | | List<DeviceLedger> supplierManageList = deviceLedgerMapper.selectBatchIds(arrayList); |
| | | ArrayList<DeviceLedgerExeclDto> deviceLedgerExeclDtos = new ArrayList<>(); |
| | | supplierManageList.stream().forEach(deviceLedger -> { |
| | |
| | | deviceLedger.setTaxIncludingPriceTotal(c.getTaxIncludingPriceUnit()); |
| | | deviceLedger.setNumber(BigDecimal.ONE); |
| | | deviceLedger.setPlanRuntimeTime(DateUtils.toLocalDate(c.getPlanRuntimeTime())); |
| | | deviceLedger.setUnTaxIncludingPriceTotal(deviceLedger.getTaxIncludingPriceTotal().divide(BigDecimal.ONE.add(c.getTaxRate()),2, RoundingMode.HALF_UP)); |
| | | // 计ç®ä¸å«ç¨æ»ä»·ï¼å¤çç©ºå¼æ
åµ |
| | | if (deviceLedger.getTaxIncludingPriceTotal() != null && c.getTaxRate() != null) { |
| | | deviceLedger.setUnTaxIncludingPriceTotal(deviceLedger.getTaxIncludingPriceTotal().divide(BigDecimal.ONE.add(c.getTaxRate()), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | deviceLedgerMapper.insert(deviceLedger); |
| | | }); |
| | | |
| | |
| | | private final SparePartsRequisitionRecordService sparePartsRequisitionRecordService; |
| | | private final FileUtil fileUtil; |
| | | |
| | | private static final int STATUS_PENDING_REPAIR = 0; |
| | | private static final int STATUS_COMPLETED = 1; |
| | | private static final int STATUS_FAILED = 2; |
| | | private static final int STATUS_PENDING_ACCEPTANCE = 3; |
| | | |
| | | @Override |
| | | public IPage<DeviceRepairVo> queryPage(Page page, DeviceRepairDto deviceRepairDto) { |
| | | IPage<DeviceRepairVo> pageDto = deviceRepairMapper.queryPage(page, deviceRepairDto); |
| | |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceRepairDto.getDeviceLedgerId()); |
| | | deviceRepairDto.setDeviceName(byId.getDeviceName()); |
| | | deviceRepairDto.setDeviceModel(byId.getDeviceModel()); |
| | | if (deviceRepairDto.getStatus() == null) { |
| | | deviceRepairDto.setStatus(STATUS_PENDING_REPAIR); |
| | | } |
| | | boolean save = this.save(deviceRepairDto); |
| | | if (save) { |
| | | // å¤çå¾çä¸ä¼ |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult updateDeviceRepair(DeviceRepairDto deviceRepairDto) { |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId()); |
| | | if (oldDeviceRepair == null) { |
| | | return AjaxResult.error("æ¥ä¿®è®°å½ä¸åå¨"); |
| | | } |
| | | if (deviceRepairDto.getStatus() != null |
| | | && deviceRepairDto.getStatus() == STATUS_COMPLETED |
| | | && (oldDeviceRepair.getStatus() == null |
| | | || oldDeviceRepair.getStatus() != STATUS_COMPLETED)) { |
| | | return AjaxResult.error("请å
æäº¤éªæ¶å®¡æ¹ï¼éªæ¶éè¿åæå¯å®ç»"); |
| | | } |
| | | // å¤çå¤ä»¶ä½¿ç¨æ
åµ |
| | | if (CollectionUtils.isNotEmpty(deviceRepairDto.getSparePartsUseList())) { |
| | | List<Long> sparePartIds = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult confirmRepair(DeviceRepairDto deviceRepairDto) { |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId()); |
| | | if (oldDeviceRepair == null) { |
| | | return AjaxResult.error("æ¥ä¿®è®°å½ä¸åå¨"); |
| | | } |
| | | if (oldDeviceRepair.getStatus() != null && oldDeviceRepair.getStatus() == STATUS_COMPLETED) { |
| | | return AjaxResult.error("该æ¥ä¿®å·²å®ç»ï¼ä¸è½éå¤ç¡®è®¤ç»´ä¿®"); |
| | | } |
| | | if (oldDeviceRepair.getStatus() != null && oldDeviceRepair.getStatus() == STATUS_PENDING_ACCEPTANCE) { |
| | | return AjaxResult.error("该æ¥ä¿®å·²æäº¤éªæ¶å®¡æ¹"); |
| | | } |
| | | deviceRepairDto.setStatus(STATUS_PENDING_ACCEPTANCE); |
| | | return updateDeviceRepair(deviceRepairDto); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult approveRepairAcceptance(DeviceRepairDto deviceRepairDto) { |
| | | if (deviceRepairDto.getId() == null) { |
| | | return AjaxResult.error("æ¥ä¿®è®°å½idä¸è½ä¸ºç©º"); |
| | | } |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId()); |
| | | if (oldDeviceRepair == null) { |
| | | return AjaxResult.error("æ¥ä¿®è®°å½ä¸åå¨"); |
| | | } |
| | | if (oldDeviceRepair.getStatus() == null || oldDeviceRepair.getStatus() != STATUS_PENDING_ACCEPTANCE) { |
| | | return AjaxResult.error("该æ¥ä¿®æªè¿å
¥å¾
éªæ¶ç¶æï¼ä¸è½å®¡æ¹"); |
| | | } |
| | | if (StringUtils.isBlank(deviceRepairDto.getAcceptanceName())) { |
| | | return AjaxResult.error("éªæ¶äººä¸è½ä¸ºç©º"); |
| | | } |
| | | if (deviceRepairDto.getAcceptanceTime() == null) { |
| | | return AjaxResult.error("éªæ¶æ¶é´ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (StringUtils.isBlank(deviceRepairDto.getAcceptanceRemark())) { |
| | | return AjaxResult.error("éªæ¶å¤æ³¨ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | DeviceRepair update = new DeviceRepair(); |
| | | update.setId(deviceRepairDto.getId()); |
| | | update.setAcceptanceName(deviceRepairDto.getAcceptanceName()); |
| | | update.setAcceptanceTime(deviceRepairDto.getAcceptanceTime()); |
| | | update.setAcceptanceRemark(deviceRepairDto.getAcceptanceRemark()); |
| | | update.setStatus(STATUS_COMPLETED); |
| | | if (this.updateById(update)) { |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error("éªæ¶å®¡æ¹å¤±è´¥"); |
| | | } |
| | | |
| | | @Override |
| | | public void export(HttpServletResponse response, Long[] ids) { |
| | | if (ids == null || ids.length == 0) { |
| | | List<DeviceRepair> supplierManageList = this.list(); |
| | |
| | | supplierManageList.stream().forEach(deviceRepair -> { |
| | | DeviceRepairExeclDto deviceRepairExeclDto = new DeviceRepairExeclDto(); |
| | | BeanUtils.copyProperties(deviceRepair,deviceRepairExeclDto); |
| | | deviceRepairExeclDto.setStatusStr(deviceRepair.getStatus() == 0 ? "å¾
ç»´ä¿®" : deviceRepair.getStatus() == 1 ? "å®ç»" : "失败"); |
| | | |
| | | deviceRepairExeclDto.setStatusStr(resolveStatusText(deviceRepair.getStatus())); |
| | | deviceLedgerExeclDtos.add(deviceRepairExeclDto); |
| | | }); |
| | | ExcelUtil<DeviceRepairExeclDto> util = new ExcelUtil<DeviceRepairExeclDto>(DeviceRepairExeclDto.class); |
| | | util.exportExcel(response, deviceLedgerExeclDtos, "è®¾å¤æ¥ä¿®å¯¼åº"); |
| | | }else { |
| | | ArrayList<Long> arrayList = new ArrayList<>(); |
| | | Arrays.stream(ids).map(id -> { |
| | | return arrayList.add( id); |
| | | }); |
| | | ArrayList<Long> arrayList = new ArrayList<>(Arrays.asList(ids)); |
| | | List<DeviceRepair> supplierManageList = deviceRepairMapper.selectBatchIds(arrayList); |
| | | ArrayList<DeviceRepairExeclDto> deviceLedgerExeclDtos = new ArrayList<>(); |
| | | supplierManageList.stream().forEach(deviceRepair -> { |
| | | DeviceRepairExeclDto deviceRepairExeclDto = new DeviceRepairExeclDto(); |
| | | BeanUtils.copyProperties(deviceRepair,deviceRepairExeclDto); |
| | | deviceRepairExeclDto.setStatusStr(deviceRepair.getStatus() == 0 ? "å¾
ç»´ä¿®" : deviceRepair.getStatus() == 1 ? "å®ç»" : "失败"); |
| | | |
| | | deviceRepairExeclDto.setStatusStr(resolveStatusText(deviceRepair.getStatus())); |
| | | deviceLedgerExeclDtos.add(deviceRepairExeclDto); |
| | | }); |
| | | ExcelUtil<DeviceRepairExeclDto> util = new ExcelUtil<DeviceRepairExeclDto>(DeviceRepairExeclDto.class); |
| | |
| | | |
| | | } |
| | | |
| | | private String resolveStatusText(Integer status) { |
| | | if (status == null) { |
| | | return ""; |
| | | } |
| | | if (status == STATUS_PENDING_REPAIR) { |
| | | return "å¾
ç»´ä¿®"; |
| | | } |
| | | if (status == STATUS_COMPLETED) { |
| | | return "å®ç»"; |
| | | } |
| | | if (status == STATUS_FAILED) { |
| | | return "失败"; |
| | | } |
| | | if (status == STATUS_PENDING_ACCEPTANCE) { |
| | | return "å¾
éªæ¶"; |
| | | } |
| | | return "æªç¥"; |
| | | } |
| | | |
| | | @Override |
| | | public DeviceRepairVo detailById(Long id) { |
| | | DeviceRepairVo vo = deviceRepairMapper.detailById(id); |
| | |
| | | inspectionTask.setMaintenanceTaskId(timingTask.getId()); |
| | | inspectionTask.setDeviceLedgerId(timingTask.getTaskId()); |
| | | inspectionTask.setMaintenancePlanTime(LocalDateTime.now()); |
| | | inspectionTask.setMaintenanceActuallyName(timingTask.getMaintenancePerson()); |
| | | inspectionTask.setFrequencyType(timingTask.getFrequencyType()); |
| | | inspectionTask.setFrequencyDetail(timingTask.getFrequencyDetail()); |
| | | inspectionTask.setTenantId(timingTask.getTenantId()); |
| | |
| | | public void setUser(SysUser user) |
| | | { |
| | | this.user = user; |
| | | this.aiEnabled = user == null ? null : user.getAiEnabled(); |
| | | if (user != null && user.getAiEnabled() != null) |
| | | { |
| | | this.aiEnabled = user.getAiEnabled(); |
| | | } |
| | | } |
| | |
|
| | | @Override
|
| | |
| | | package com.ruoyi.home.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.dto.MapDto; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.home.annotation.DefaultType; |
| | | import com.ruoyi.home.dto.*; |
| | | import com.ruoyi.home.service.HomeService; |
| | | import com.ruoyi.production.mapper.ProductionOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductOutputMapper; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.format.DateTimeParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | public class HomeController extends BaseController { |
| | | |
| | | private final HomeService homeService; |
| | | private final ProductionOrderMapper productionOrderMapper; |
| | | private final ProductionProductOutputMapper productionProductOutputMapper; |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | private final DeviceRepairMapper deviceRepairMapper; |
| | | |
| | | private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | private static final Integer ORDER_STATUS_WAIT = 1; |
| | | private static final Integer ORDER_STATUS_RUNNING = 2; |
| | | private static final Integer ORDER_STATUS_COMPLETED = 3; |
| | | private static final Integer ORDER_STATUS_PAUSED = 4; |
| | | |
| | | /********************************************************åºç¡ç±»*****************************************************/ |
| | | @GetMapping("/todos") |
| | | @Log(title = "å¾
åäºé¡¹", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "å¾
åäºé¡¹") |
| | | public AjaxResult todos(ApproveProcess req) throws ParseException { |
| | | public R todos() throws ParseException { |
| | | List<ApproveProcess> approveProcessList = homeService.todos(); |
| | | return AjaxResult.success(approveProcessList); |
| | | return R.ok(approveProcessList); |
| | | } |
| | | |
| | | @GetMapping("/approveAndDeviceTodos") |
| | | @Operation(summary = "审æ¹ååï¼è®¾å¤æ¥ä¿®å¾
åäºé¡¹") |
| | | public AjaxResult approveAndDeviceTodos(){ |
| | | public R approveAndDeviceTodos(){ |
| | | Map<String, Object> map = homeService.approveAndDeviceTodos(); |
| | | return AjaxResult.success(map); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | @GetMapping("/noticesCount") |
| | | @Operation(summary = "æªè¿æçå
¬åæ°é") |
| | | public AjaxResult noticesCount(){ |
| | | public R noticesCount(){ |
| | | Long count = homeService.noticesCount(); |
| | | return AjaxResult.success(count); |
| | | return R.ok(count); |
| | | } |
| | | |
| | | @GetMapping("/deptStaffDistribution") |
| | | @Operation(summary = "åé¨é¨äººååå¸") |
| | | public AjaxResult deptStaffDistribution() { |
| | | public R deptStaffDistribution() { |
| | | DeptStaffDistributionDto dto = homeService.deptStaffDistribution(); |
| | | return AjaxResult.success(dto); |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | @GetMapping("/summaryStatistics") |
| | | @Operation(summary = "åå·¥-客æ·-ä¾åºåæ»æ°") |
| | | public AjaxResult summaryStatistics() { |
| | | public R summaryStatistics() { |
| | | HomeSummaryDto homeSummaryDto = homeService.summaryStatistics(); |
| | | return AjaxResult.success(homeSummaryDto); |
| | | return R.ok(homeSummaryDto); |
| | | } |
| | | |
| | | /********************************************************è¥ééè´ç±»**************************************************/ |
| | | @GetMapping("/supplierPurchaseRanking") |
| | | @Operation(summary = "ä¾åºåéè´æå") |
| | | public AjaxResult supplierPurchaseRanking(@DefaultType Integer type) { |
| | | public R supplierPurchaseRanking(@DefaultType Integer type) { |
| | | List<SupplierPurchaseRankingDto> list = homeService.supplierPurchaseRanking(type); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/customerRevenueAnalysis") |
| | | @Operation(summary = "客æ·è¥æ¶è´¡ç®æ°å¼åæ") |
| | | public AjaxResult customerRevenueAnalysis(Long customerId, @DefaultType Integer type) { |
| | | public R customerRevenueAnalysis(Long customerId, @DefaultType Integer type) { |
| | | CustomerRevenueAnalysisDto dto = homeService.customerRevenueAnalysis(customerId, type); |
| | | return AjaxResult.success(dto); |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | @GetMapping("/customerContributionRanking") |
| | | @Operation(summary = "客æ·éé¢è´¡ç®æå") |
| | | public AjaxResult customerContributionRanking(@DefaultType Integer type) { |
| | | public R customerContributionRanking(@DefaultType Integer type) { |
| | | List<CustomerContributionRankingDto> list = homeService.customerContributionRanking(type); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/productSalesAnalysis") |
| | | @Operation(summary = "å产åéå®éé¢åæ") |
| | | public AjaxResult productSalesAnalysis() { |
| | | public R productSalesAnalysis() { |
| | | List<MapDto> list = homeService.productSalesAnalysis(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/rawMaterialPurchaseAmountRatio") |
| | | @Operation(summary = "åææéè´éé¢å æ¯") |
| | | public AjaxResult rawMaterialPurchaseAmountRatio(){ |
| | | public R rawMaterialPurchaseAmountRatio(){ |
| | | List<MapDto> list = homeService.rawMaterialPurchaseAmountRatio(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/business") |
| | | @Log(title = "éå®-éè´-åºåæ°æ®", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "éå®-éè´-åºåæ°æ®") |
| | | public AjaxResult business(HomeBusinessDto req) { |
| | | public R business() { |
| | | HomeBusinessDto homeBusinessDto = homeService.business(); |
| | | return AjaxResult.success(homeBusinessDto); |
| | | return R.ok(homeBusinessDto); |
| | | } |
| | | |
| | | @GetMapping("/analysisCustomerContractAmounts") |
| | | @Log(title = "客æ·ååéé¢åæ", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "客æ·ååéé¢åæ") |
| | | public AjaxResult analysisCustomerContractAmounts(AnalysisCustomerContractAmountsDto req) { |
| | | public R analysisCustomerContractAmounts() { |
| | | AnalysisCustomerContractAmountsDto analysisCustomerContractAmounts = homeService.analysisCustomerContractAmounts(); |
| | | return AjaxResult.success(analysisCustomerContractAmounts); |
| | | return R.ok(analysisCustomerContractAmounts); |
| | | } |
| | | |
| | | /********************************************************ç产类*****************************************************/ |
| | | @GetMapping("/inputOutputAnalysis") |
| | | @Operation(summary = "æå
¥äº§åºåæ") |
| | | public AjaxResult inputOutputAnalysis(@DefaultType Integer type){ |
| | | public R inputOutputAnalysis(@DefaultType Integer type){ |
| | | List<InputOutputAnalysisDto> list = homeService.inputOutputAnalysis(type); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/processOutputAnalysis") |
| | | @Operation(summary = "å·¥åºäº§åºåæ") |
| | | public AjaxResult processOutputAnalysis(@DefaultType Integer type){ |
| | | public R processOutputAnalysis(@DefaultType Integer type){ |
| | | List<MapDto> list = homeService.processOutputAnalysis(type); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/workOrderEfficiencyAnalysis") |
| | | @Operation(summary = "å·¥åæ§è¡æçåæ") |
| | | public AjaxResult workOrderEfficiencyAnalysis(@DefaultType Integer type){ |
| | | public R workOrderEfficiencyAnalysis(@DefaultType Integer type){ |
| | | List<WorkOrderEfficiencyDto> list = homeService.workOrderEfficiencyAnalysis(type); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/productionAccountingAnalysis") |
| | | @Operation(summary = "çäº§æ ¸ç®åæ") |
| | | public AjaxResult productionAccountingAnalysis(@DefaultType Integer type){ |
| | | public R productionAccountingAnalysis(@DefaultType Integer type){ |
| | | List<ProductionAccountingDto> list = homeService.productionAccountingAnalysis(type); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/orderCount") |
| | | @Operation(summary = "è®¢åæ°") |
| | | public AjaxResult orderCount(){ |
| | | return AjaxResult.success(homeService.orderCount()); |
| | | public R orderCount(){ |
| | | return R.ok(homeService.orderCount()); |
| | | } |
| | | |
| | | @GetMapping("/progressStatistics") |
| | | @Operation(summary = "åç产订åç宿è¿åº¦ç»è®¡") |
| | | public AjaxResult progressStatistics(){ |
| | | public R progressStatistics(){ |
| | | ProductionProgressDto productionProgressDto = homeService.productionProgress(); |
| | | return AjaxResult.success(productionProgressDto); |
| | | return R.ok(productionProgressDto); |
| | | } |
| | | |
| | | @GetMapping("/workInProcessTurnover") |
| | | @Operation(summary = "å¨å¶åå¨è½¬æ
åµ") |
| | | public AjaxResult workInProcessTurnover(){ |
| | | public R workInProcessTurnover(){ |
| | | ProductionTurnoverDto productionTurnoverDto = homeService.workInProcessTurnover(); |
| | | return AjaxResult.success(productionTurnoverDto); |
| | | return R.ok(productionTurnoverDto); |
| | | } |
| | | |
| | | @GetMapping("/processDataProductionStatistics") |
| | | @Operation(summary = "å·¥åºæ°æ®ç产ç»è®¡æ°æ®") |
| | | public AjaxResult processDataProductionStatistics(@DefaultType Integer type,@RequestParam(required = false) List<Long> processIds) { |
| | | public R processDataProductionStatistics(@DefaultType Integer type,@RequestParam(required = false) List<Long> processIds) { |
| | | List<processDataProductionStatisticsDto> list = homeService.processDataProductionStatistics(type, processIds); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /********************************************************è´¨éç±»*****************************************************/ |
| | | @GetMapping("/productionOverview") |
| | | @Operation(summary = "Production Overview") |
| | | public R productionOverview() { |
| | | LocalDate today = LocalDate.now(); |
| | | Map<String, BigDecimal> totalStats = loadOutputStats(LocalDate.of(2000, 1, 1), today.plusDays(1)); |
| | | BigDecimal totalOutput = totalStats.get("quantity"); |
| | | BigDecimal totalScrap = totalStats.get("scrapQty"); |
| | | BigDecimal yieldRate = calcRate(totalOutput, totalOutput.add(totalScrap)); |
| | | |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("totalOutput", scale(totalOutput)); |
| | | result.put("totalScrap", scale(totalScrap)); |
| | | result.put("yieldRate", scale(yieldRate)); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @GetMapping("/productionRealtimeBoard") |
| | | @Operation(summary = "Production Realtime Board") |
| | | public R productionRealtimeBoard() { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate yesterday = today.minusDays(1); |
| | | |
| | | BigDecimal todayDeviceOee = calcDeviceOee(today); |
| | | BigDecimal yesterdayDeviceOee = calcDeviceOee(yesterday); |
| | | |
| | | BigDecimal todayOrderAchievementRate = calcOrderAchievementRate(today); |
| | | BigDecimal yesterdayOrderAchievementRate = calcOrderAchievementRate(yesterday); |
| | | |
| | | BigDecimal todayDefectRate = calcDefectRate(today); |
| | | BigDecimal yesterdayDefectRate = calcDefectRate(yesterday); |
| | | |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("deviceOee", buildRealtimeMetric(todayDeviceOee, todayDeviceOee.subtract(yesterdayDeviceOee))); |
| | | result.put("orderAchievementRate", buildRealtimeMetric(todayOrderAchievementRate, todayOrderAchievementRate.subtract(yesterdayOrderAchievementRate))); |
| | | result.put("defectRate", buildRealtimeMetric(todayDefectRate, todayDefectRate.subtract(yesterdayDefectRate))); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @GetMapping("/productionOrderProgress") |
| | | @Operation(summary = "Production Order Progress") |
| | | public R productionOrderProgress(@RequestParam(defaultValue = "all") String tab, |
| | | @RequestParam(required = false) String status, |
| | | @RequestParam(required = false) String bizDate, |
| | | @RequestParam(defaultValue = "1") Long pageNum, |
| | | @RequestParam(defaultValue = "10") Long pageSize) { |
| | | LocalDate queryDate = parseDateOrNull(bizDate); |
| | | if (!isBlank(bizDate) && queryDate == null) { |
| | | return R.fail("bizDateæ ¼å¼é误ï¼è¯·ä½¿ç¨yyyy-MM-dd"); |
| | | } |
| | | Integer statusFromParam = parseOrderStatus(status); |
| | | if (!isBlank(status) && statusFromParam == null && !"all".equalsIgnoreCase(status.trim())) { |
| | | return R.fail("statusåæ°ä¸åæ³ï¼å¯éå¼ï¼all/waiting/inProgress/completed/paused æ 1/2/3/4"); |
| | | } |
| | | Integer queryStatus = resolveOrderStatus(status, tab); |
| | | |
| | | long safePageNum = pageNum == null || pageNum < 1 ? 1 : pageNum; |
| | | long safePageSize = pageSize == null || pageSize < 1 ? 10 : Math.min(pageSize, 50); |
| | | long offset = (safePageNum - 1) * safePageSize; |
| | | LocalDateTime startTime = queryDate == null ? null : queryDate.atStartOfDay(); |
| | | LocalDateTime endTime = queryDate == null ? null : queryDate.plusDays(1).atStartOfDay(); |
| | | |
| | | List<Map<String, Object>> rawRows = productionOrderMapper.selectHomeOrderProgressPage(queryStatus, offset, safePageSize, startTime, endTime); |
| | | List<Map<String, Object>> records = new ArrayList<>(); |
| | | if (rawRows != null) { |
| | | for (Map<String, Object> rawRow : rawRows) { |
| | | records.add(buildOrderProgressRow(rawRow)); |
| | | } |
| | | } |
| | | |
| | | long waitingCount = 0L; |
| | | long inProgressCount = 0L; |
| | | long completedCount = 0L; |
| | | long pausedCount = 0L; |
| | | List<Map<String, Object>> statusCountRows = productionOrderMapper.countHomeOrderProgressByStatus(startTime, endTime); |
| | | if (statusCountRows != null) { |
| | | for (Map<String, Object> countRow : statusCountRows) { |
| | | Integer statusKey = toInteger(countRow.get("status")); |
| | | long cnt = toLong(countRow.get("cnt")); |
| | | if (Objects.equals(statusKey, ORDER_STATUS_WAIT)) { |
| | | waitingCount = cnt; |
| | | } else if (Objects.equals(statusKey, ORDER_STATUS_RUNNING)) { |
| | | inProgressCount = cnt; |
| | | } else if (Objects.equals(statusKey, ORDER_STATUS_COMPLETED)) { |
| | | completedCount = cnt; |
| | | } else if (Objects.equals(statusKey, ORDER_STATUS_PAUSED)) { |
| | | pausedCount = cnt; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("tab", mapOrderTab(queryStatus)); |
| | | result.put("status", mapOrderStatus(queryStatus)); |
| | | result.put("bizDate", queryDate == null ? null : queryDate.format(DATE_FORMATTER)); |
| | | result.put("total", toLong(productionOrderMapper.countHomeOrderProgress(queryStatus, startTime, endTime))); |
| | | result.put("pageNum", safePageNum); |
| | | result.put("pageSize", safePageSize); |
| | | result.put("waitingCount", waitingCount); |
| | | result.put("inProgressCount", inProgressCount); |
| | | result.put("completedCount", completedCount); |
| | | result.put("pausedCount", pausedCount); |
| | | result.put("records", records); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @GetMapping("/todayProductionPlan") |
| | | @Operation(summary = "Today Production Plan") |
| | | public R todayProductionPlan(@RequestParam(defaultValue = "4") Long limit, |
| | | @RequestParam(required = false) String planDate) { |
| | | LocalDate queryDate = parseDateOrNull(planDate); |
| | | if (!isBlank(planDate) && queryDate == null) { |
| | | return R.fail("planDateæ ¼å¼é误ï¼è¯·ä½¿ç¨yyyy-MM-dd"); |
| | | } |
| | | |
| | | long safeLimit = limit == null || limit < 1 ? 4 : Math.min(limit, 20); |
| | | LocalDateTime planStart = queryDate == null ? null : queryDate.atStartOfDay(); |
| | | LocalDateTime planEnd = queryDate == null ? null : queryDate.plusDays(1).atStartOfDay(); |
| | | List<Map<String, Object>> records = new ArrayList<>(); |
| | | List<Map<String, Object>> rawRows = productionOrderMapper.selectHomeTodayProductionPlan(safeLimit, planStart, planEnd); |
| | | if (rawRows != null) { |
| | | for (Map<String, Object> rawRow : rawRows) { |
| | | Map<String, Object> row = new LinkedHashMap<>(); |
| | | Integer rowStatus = toInteger(rawRow.get("status")); |
| | | row.put("orderNo", rawRow.get("orderNo")); |
| | | row.put("productName", rawRow.get("productName")); |
| | | row.put("plannedQuantity", scale(toBigDecimal(rawRow.get("plannedQuantity")))); |
| | | row.put("dueDate", rawRow.get("dueDate")); |
| | | row.put("status", rowStatus); |
| | | row.put("statusLabel", mapOrderStatusLabel(rowStatus)); |
| | | records.add(row); |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("planDate", queryDate == null ? null : queryDate.format(DATE_FORMATTER)); |
| | | result.put("total", toLong(productionOrderMapper.countHomeTodayProductionPlan(planStart, planEnd))); |
| | | result.put("records", records); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @GetMapping("/rawMaterialDetection") |
| | | @Operation(summary = "åæææ£æµ") |
| | | public AjaxResult rawMaterialDetection(@DefaultType Integer type){ |
| | | return AjaxResult.success(homeService.rawMaterialDetection(type)); |
| | | public R rawMaterialDetection(@DefaultType Integer type){ |
| | | return R.ok(homeService.rawMaterialDetection(type)); |
| | | } |
| | | |
| | | @GetMapping("/processDetection") |
| | | @Operation(summary = "è¿ç¨æ£æµ") |
| | | public AjaxResult processDetection(@DefaultType Integer type){ |
| | | return AjaxResult.success(homeService.processDetection(type)); |
| | | public R processDetection(@DefaultType Integer type){ |
| | | return R.ok(homeService.processDetection(type)); |
| | | } |
| | | |
| | | @GetMapping("/factoryDetection") |
| | | @Operation(summary = "æååºåæ£æµ") |
| | | public AjaxResult factoryDetection(@DefaultType Integer type){ |
| | | return AjaxResult.success(homeService.factoryDetection(type)); |
| | | public R factoryDetection(@DefaultType Integer type){ |
| | | return R.ok(homeService.factoryDetection(type)); |
| | | } |
| | | |
| | | @GetMapping("/qualityInspectionCount") |
| | | @Operation(summary = "è´¨éæ£éªæ°é") |
| | | public AjaxResult qualityInspectionCount(){ |
| | | public R qualityInspectionCount(){ |
| | | QualityInspectionCountDto qualityInspectionCountDto = homeService.qualityInspectionCount(); |
| | | return AjaxResult.success(qualityInspectionCountDto); |
| | | return R.ok(qualityInspectionCountDto); |
| | | } |
| | | |
| | | @GetMapping("/nonComplianceWarning") |
| | | @Operation(summary = "ä¸åæ ¼é¢è¦") |
| | | public AjaxResult nonComplianceWarning(){ |
| | | public R nonComplianceWarning(){ |
| | | NonComplianceWarningDto nonComplianceWarningDto = homeService.nonComplianceWarning(); |
| | | return AjaxResult.success(nonComplianceWarningDto); |
| | | return R.ok(nonComplianceWarningDto); |
| | | } |
| | | |
| | | @GetMapping("/completedInspectionCount") |
| | | @Operation(summary = "宿æ£éªæ°") |
| | | public AjaxResult completedInspectionCount(){ |
| | | public R completedInspectionCount(){ |
| | | List<CompletedInspectionCountDto> list = homeService.completedInspectionCount(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/unqualifiedProductRanking") |
| | | @Operation(summary = "ä¸åæ ¼äº§åæå") |
| | | public AjaxResult unqualifiedProductRanking(){ |
| | | public R unqualifiedProductRanking(){ |
| | | List<UnqualifiedProductRankDto> list = homeService.unqualifiedProductRanking(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/unqualifiedProductProcessingAnalysis") |
| | | @Operation(summary = "ä¸åæ ¼æ£åå¤çåæ") |
| | | public AjaxResult unqualifiedProductProcessingAnalysis(){ |
| | | public R unqualifiedProductProcessingAnalysis(){ |
| | | List<MapDto> list = homeService.unqualifiedProductProcessingAnalysis(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/qualityStatistics") |
| | | @Log(title = "è´¨éåæ", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "è´¨éåæ") |
| | | public AjaxResult qualityStatistics(QualityStatisticsDto req) { |
| | | public R qualityStatistics() { |
| | | QualityStatisticsDto qualityStatisticsDto = homeService.qualityStatistics(); |
| | | return AjaxResult.success(qualityStatisticsDto); |
| | | return R.ok(qualityStatisticsDto); |
| | | } |
| | | |
| | | @GetMapping("/qualityInspectionStatistics") |
| | | @Operation(summary = "è´¨éç»è®¡") |
| | | public AjaxResult qualityInspectionStatistics(@DefaultType Integer type) { |
| | | public R qualityInspectionStatistics(@DefaultType Integer type) { |
| | | QualityStatisticsDto dto = homeService.qualityInspectionStatistics(type); |
| | | return AjaxResult.success(dto); |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | /********************************************************è´¢å¡ç±»*****************************************************/ |
| | | @GetMapping("/incomeExpenseAnalysis") |
| | | @Operation(summary = "æ¯æ¶å¯¹æ¯åæ") |
| | | public AjaxResult incomeExpenseAnalysis(@DefaultType Integer type) { |
| | | public R incomeExpenseAnalysis(@DefaultType Integer type) { |
| | | List<Map<String, Object>> result = homeService.incomeExpenseAnalysis(type); |
| | | return AjaxResult.success(result); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @GetMapping("/profitTrendAnalysis") |
| | | @Operation(summary = "婿¶¦è¶å¿åæ") |
| | | public AjaxResult profitTrendAnalysis(){ |
| | | public R profitTrendAnalysis(){ |
| | | List<MapDto> list = homeService.profitTrendAnalysis(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/expenseCompositionAnalysis") |
| | | @Operation(summary = "ææåæ") |
| | | public AjaxResult expenseCompositionAnalysis(@DefaultType Integer type) { |
| | | public R expenseCompositionAnalysis(@DefaultType Integer type) { |
| | | List<MapDto> list = homeService.expenseCompositionAnalysis(type); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/monthlyIncome") |
| | | @Operation(summary = "æåº¦æ¶å
¥") |
| | | public AjaxResult monthlyIncome(){ |
| | | public R monthlyIncome(){ |
| | | MonthlyIncomeDto dto = homeService.monthlyIncome(); |
| | | return AjaxResult.success(dto); |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | @GetMapping("/monthlyExpenditure") |
| | | @Operation(summary = "æåº¦æ¯åº") |
| | | public AjaxResult monthlyExpenditure(){ |
| | | public R monthlyExpenditure(){ |
| | | MonthlyExpenditureDto dto = homeService.monthlyExpenditure(); |
| | | return AjaxResult.success(dto); |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | @GetMapping("/statisticsReceivablePayable") |
| | | @Log(title = "åºæ¶åºä»ç»è®¡", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "åºæ¶åºä»ç»è®¡") |
| | | public AjaxResult statisticsReceivablePayable(StatisticsReceivablePayableDto req, @DefaultType Integer type ) { |
| | | public R statisticsReceivablePayable(@DefaultType Integer type ) { |
| | | StatisticsReceivablePayableDto statisticsReceivablePayable = homeService.statisticsReceivablePayable(type); |
| | | return AjaxResult.success(statisticsReceivablePayable); |
| | | return R.ok(statisticsReceivablePayable); |
| | | } |
| | | |
| | | /********************************************************ä»å¨ç±»*****************************************************/ |
| | | |
| | | @GetMapping("/productCategoryDistribution") |
| | | @Operation(summary = "产å大类åå¸") |
| | | public AjaxResult productCategoryDistribution() { |
| | | public R productCategoryDistribution() { |
| | | ProductCategoryDistributionDto dto = homeService.productCategoryDistribution(); |
| | | return AjaxResult.success(dto); |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | @GetMapping("/salesPurchaseStorageProductCount") |
| | | @Operation(summary = "éå®-éè´-å¨åäº§åæ°") |
| | | public AjaxResult salesPurchaseStorageProductCount(){ |
| | | public R salesPurchaseStorageProductCount(){ |
| | | List<MapDto> list = homeService.salesPurchaseStorageProductCount(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @GetMapping("/productInOutAnalysis") |
| | | @Operation(summary = "产ååºå
¥åºåæ") |
| | | public AjaxResult productInOutAnalysis(@DefaultType Integer type){ |
| | | public R productInOutAnalysis(@DefaultType Integer type){ |
| | | List<Map<String, Object>> result = homeService.productInOutAnalysis(type); |
| | | return AjaxResult.success(result); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @GetMapping("/productTurnoverDays") |
| | | @Operation(summary = "产åå¨è½¬å¤©æ°") |
| | | public AjaxResult productTurnoverDays(){ |
| | | public R productTurnoverDays(){ |
| | | List<MapDto> list = homeService.productTurnoverDays(); |
| | | return AjaxResult.success(list); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | private Map<String, Object> buildOrderProgressRow(Map<String, Object> rawRow) { |
| | | Map<String, Object> row = new LinkedHashMap<>(); |
| | | Integer rowStatus = toInteger(rawRow.get("status")); |
| | | row.put("orderNo", rawRow.get("orderNo")); |
| | | row.put("productName", rawRow.get("productName")); |
| | | row.put("plannedQuantity", scale(toBigDecimal(rawRow.get("plannedQuantity")))); |
| | | row.put("completedQuantity", scale(toBigDecimal(rawRow.get("completedQuantity")))); |
| | | row.put("completionRate", scale(toBigDecimal(rawRow.get("completionRate")))); |
| | | row.put("dueDate", rawRow.get("dueDate")); |
| | | row.put("status", rowStatus); |
| | | row.put("statusLabel", mapOrderStatusLabel(rowStatus)); |
| | | return row; |
| | | } |
| | | |
| | | private Integer resolveOrderStatus(String status, String tab) { |
| | | if (!isBlank(status)) { |
| | | return parseOrderStatus(status); |
| | | } |
| | | return parseOrderStatus(tab); |
| | | } |
| | | |
| | | private Integer parseOrderStatus(String rawStatus) { |
| | | if (isBlank(rawStatus)) { |
| | | return null; |
| | | } |
| | | String normalized = rawStatus.trim().toLowerCase(); |
| | | if ("all".equals(normalized)) { |
| | | return null; |
| | | } |
| | | if ("1".equals(normalized) || "waiting".equals(normalized) || "wait".equals(normalized)) { |
| | | return ORDER_STATUS_WAIT; |
| | | } |
| | | if ("2".equals(normalized) || "inprogress".equals(normalized) || "running".equals(normalized)) { |
| | | return ORDER_STATUS_RUNNING; |
| | | } |
| | | if ("3".equals(normalized) || "completed".equals(normalized)) { |
| | | return ORDER_STATUS_COMPLETED; |
| | | } |
| | | if ("4".equals(normalized) || "paused".equals(normalized)) { |
| | | return ORDER_STATUS_PAUSED; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String mapOrderTab(Integer status) { |
| | | if (Objects.equals(status, ORDER_STATUS_RUNNING)) { |
| | | return "inProgress"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_COMPLETED)) { |
| | | return "completed"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_PAUSED)) { |
| | | return "paused"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_WAIT)) { |
| | | return "waiting"; |
| | | } |
| | | return "all"; |
| | | } |
| | | |
| | | private String mapOrderStatus(Integer status) { |
| | | if (Objects.equals(status, ORDER_STATUS_WAIT)) { |
| | | return "waiting"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_RUNNING)) { |
| | | return "inProgress"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_COMPLETED)) { |
| | | return "completed"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_PAUSED)) { |
| | | return "paused"; |
| | | } |
| | | return "all"; |
| | | } |
| | | |
| | | private String mapOrderStatusLabel(Integer status) { |
| | | if (Objects.equals(status, ORDER_STATUS_WAIT)) { |
| | | return "å¾
å¼å§"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_RUNNING)) { |
| | | return "è¿è¡ä¸"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_COMPLETED)) { |
| | | return "已宿"; |
| | | } |
| | | if (Objects.equals(status, ORDER_STATUS_PAUSED)) { |
| | | return "å·²æå"; |
| | | } |
| | | return "æªç¥"; |
| | | } |
| | | |
| | | private Map<String, BigDecimal> loadOutputStats(LocalDate startDate, LocalDate endDateExclusive) { |
| | | String start = startDate.atStartOfDay().format(DATE_TIME_FORMATTER); |
| | | String end = endDateExclusive.atStartOfDay().format(DATE_TIME_FORMATTER); |
| | | |
| | | BigDecimal quantity = BigDecimal.ZERO; |
| | | BigDecimal scrapQty = BigDecimal.ZERO; |
| | | List<Map<String, Object>> rows = productionProductOutputMapper.selectDailyOutputStats(start, end); |
| | | if (rows != null) { |
| | | for (Map<String, Object> row : rows) { |
| | | quantity = quantity.add(toBigDecimal(row.get("quantity"))); |
| | | scrapQty = scrapQty.add(toBigDecimal(row.get("scrapQty"))); |
| | | } |
| | | } |
| | | |
| | | Map<String, BigDecimal> stats = new LinkedHashMap<>(); |
| | | stats.put("quantity", quantity); |
| | | stats.put("scrapQty", scrapQty); |
| | | return stats; |
| | | } |
| | | |
| | | private BigDecimal calcDeviceOee(LocalDate day) { |
| | | long totalDeviceCount = deviceLedgerMapper.selectCount(new LambdaQueryWrapper<>()); |
| | | if (totalDeviceCount <= 0) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | |
| | | Date start = Date.from(day.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | Date end = Date.from(day.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | |
| | | List<DeviceRepair> repairList = deviceRepairMapper.selectList(new LambdaQueryWrapper<DeviceRepair>() |
| | | .select(DeviceRepair::getDeviceLedgerId) |
| | | .ge(DeviceRepair::getRepairTime, start) |
| | | .lt(DeviceRepair::getRepairTime, end) |
| | | .in(DeviceRepair::getStatus, 0, 3)); |
| | | |
| | | long repairingDeviceCount = repairList == null ? 0 : repairList.stream() |
| | | .map(DeviceRepair::getDeviceLedgerId) |
| | | .filter(Objects::nonNull) |
| | | .distinct() |
| | | .count(); |
| | | |
| | | long availableDeviceCount = Math.max(totalDeviceCount - repairingDeviceCount, 0); |
| | | return new BigDecimal(availableDeviceCount) |
| | | .multiply(new BigDecimal("100")) |
| | | .divide(new BigDecimal(totalDeviceCount), 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private BigDecimal calcOrderAchievementRate(LocalDate day) { |
| | | List<ProductionOrder> orderList = productionOrderMapper.selectList(new LambdaQueryWrapper<ProductionOrder>() |
| | | .select(ProductionOrder::getQuantity, ProductionOrder::getCompleteQuantity) |
| | | .ge(ProductionOrder::getCreateTime, day.atStartOfDay()) |
| | | .lt(ProductionOrder::getCreateTime, day.plusDays(1).atStartOfDay()) |
| | | .ne(ProductionOrder::getStatus, ORDER_STATUS_PAUSED)); |
| | | |
| | | BigDecimal totalQuantity = BigDecimal.ZERO; |
| | | BigDecimal totalCompleteQuantity = BigDecimal.ZERO; |
| | | if (orderList != null) { |
| | | for (ProductionOrder order : orderList) { |
| | | totalQuantity = totalQuantity.add(zeroIfNull(order.getQuantity())); |
| | | totalCompleteQuantity = totalCompleteQuantity.add(zeroIfNull(order.getCompleteQuantity())); |
| | | } |
| | | } |
| | | return calcRate(totalCompleteQuantity, totalQuantity); |
| | | } |
| | | |
| | | private BigDecimal calcDefectRate(LocalDate day) { |
| | | Map<String, BigDecimal> stats = loadOutputStats(day, day.plusDays(1)); |
| | | BigDecimal quantity = stats.get("quantity"); |
| | | BigDecimal scrapQty = stats.get("scrapQty"); |
| | | return calcRate(scrapQty, quantity.add(scrapQty)); |
| | | } |
| | | |
| | | private Map<String, Object> buildRealtimeMetric(BigDecimal value, BigDecimal change) { |
| | | Map<String, Object> metric = new LinkedHashMap<>(); |
| | | metric.put("value", scale(value)); |
| | | metric.put("compareYesterday", scale(change)); |
| | | return metric; |
| | | } |
| | | |
| | | private BigDecimal calcRate(BigDecimal numerator, BigDecimal denominator) { |
| | | if (denominator == null || denominator.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | return zeroIfNull(numerator) |
| | | .multiply(new BigDecimal("100")) |
| | | .divide(denominator, 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private BigDecimal toBigDecimal(Object value) { |
| | | if (value == null) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | if (value instanceof BigDecimal) { |
| | | return (BigDecimal) value; |
| | | } |
| | | if (value instanceof Number) { |
| | | return BigDecimal.valueOf(((Number) value).doubleValue()); |
| | | } |
| | | try { |
| | | return new BigDecimal(String.valueOf(value)); |
| | | } catch (Exception ex) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | } |
| | | |
| | | private Integer toInteger(Object value) { |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | if (value instanceof Integer) { |
| | | return (Integer) value; |
| | | } |
| | | if (value instanceof Number) { |
| | | return ((Number) value).intValue(); |
| | | } |
| | | try { |
| | | return Integer.valueOf(String.valueOf(value)); |
| | | } catch (Exception ex) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private long toLong(Object value) { |
| | | if (value == null) { |
| | | return 0L; |
| | | } |
| | | if (value instanceof Long) { |
| | | return (Long) value; |
| | | } |
| | | if (value instanceof Number) { |
| | | return ((Number) value).longValue(); |
| | | } |
| | | try { |
| | | return Long.parseLong(String.valueOf(value)); |
| | | } catch (Exception ex) { |
| | | return 0L; |
| | | } |
| | | } |
| | | |
| | | private LocalDate parseDateOrNull(String rawDate) { |
| | | if (isBlank(rawDate)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return LocalDate.parse(rawDate.trim(), DATE_FORMATTER); |
| | | } catch (DateTimeParseException ex) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private boolean isBlank(String value) { |
| | | return value == null || value.trim().isEmpty(); |
| | | } |
| | | |
| | | private BigDecimal zeroIfNull(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private BigDecimal scale(BigDecimal value) { |
| | | return zeroIfNull(value).setScale(2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | } |
| | |
| | | @Schema(description = "åºä»éé¢") |
| | | private BigDecimal payableMoney; |
| | | |
| | | @Schema(description = "颿¶éé¢") |
| | | @Schema(description = "æ¶æ¬¾éé¢") |
| | | private BigDecimal advanceMoney; |
| | | |
| | | @Schema(description = "é¢ä»éé¢") |
| | | @Schema(description = "仿¬¾éé¢") |
| | | private BigDecimal prepayMoney; |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.ruoyi.account.mapper.AccountExpenseMapper; |
| | | import com.ruoyi.account.mapper.AccountIncomeMapper; |
| | | import com.ruoyi.account.pojo.AccountExpense; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseInboundDto; |
| | | import com.ruoyi.account.bean.dto.purchase.PurchaseReturnDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesOutboundDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo; |
| | | import com.ruoyi.account.bean.vo.purchase.PurchaseReturnVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesOutboundVo; |
| | | import com.ruoyi.account.bean.vo.sales.SalesReturnVo; |
| | | import com.ruoyi.account.mapper.AccountStatementMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.approve.mapper.ApproveProcessMapper; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | |
| | | import com.ruoyi.home.dto.*; |
| | | import com.ruoyi.home.mapper.HomeMapper; |
| | | import com.ruoyi.home.service.HomeService; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper; |
| | | import com.ruoyi.production.bean.dto.ProductionProductOutputDto; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.purchase.mapper.PaymentRegistrationMapper; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PaymentRegistration; |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrdersMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityUnqualifiedMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.quality.pojo.QualityUnqualified; |
| | | import com.ruoyi.sales.mapper.ReceiptPaymentMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.ReceiptPayment; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockOutRecordMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | public class HomeServiceImpl implements HomeService { |
| | | |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | private final StockOutRecordMapper stockOutRecordMapper; |
| | | private final ReturnManagementMapper returnManagementMapper; |
| | | private final StockInRecordMapper stockInRecordMapper; |
| | | private final PurchaseReturnOrdersMapper purchaseReturnOrdersMapper; |
| | | |
| | | private final PurchaseLedgerMapper purchaseLedgerMapper; |
| | | |
| | |
| | | private final QualityInspectMapper qualityStatisticsMapper; |
| | | |
| | | private final ApproveProcessMapper approveProcessMapper; |
| | | |
| | | private final ReceiptPaymentMapper receiptPaymentMapper; |
| | | |
| | | private final PaymentRegistrationMapper paymentRegistrationMapper; |
| | | |
| | | private final SysDeptMapper sysDeptMapper; |
| | | |
| | |
| | | |
| | | private final ProductionOperationTaskMapper productionOperationTaskMapper; |
| | | |
| | | private final AccountExpenseMapper accountExpenseMapper; |
| | | |
| | | private final AccountIncomeMapper accountIncomeMapper; |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final AccountStatementMapper accountStatementMapper; |
| | | |
| | | private final ProductionAccountMapper productionAccountMapper; |
| | | |
| | |
| | | salesLedgers.stream().map(SalesLedger::getId).collect(Collectors.toList())); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper |
| | | .selectList(salesLedgerProductMapperLambdaQueryWrapper); |
| | | // æªå¼ç¥¨éé¢ |
| | | BigDecimal noInvoiceAmountTotal = salesLedgerProducts.stream().map(SalesLedgerProduct::getNoInvoiceAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | homeBusinessDto.setMonthSaleMoney(contractAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setMonthSaleHaveMoney(BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | } |
| | | // å建LambdaQueryWrapper |
| | | LambdaQueryWrapper<PurchaseLedger> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | // å¾
仿¬¾æ»éé¢ |
| | | BigDecimal unReceiptPaymentAmount = salesLedgerProductsCopy.stream() |
| | | .map(SalesLedgerProduct::getPendingTicketsTotal) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | homeBusinessDto.setMonthPurchaseMoney(receiveAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setMonthPurchaseHaveMoney(unReceiptPaymentAmount.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | homeBusinessDto.setMonthPurchaseHaveMoney(BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | } |
| | | // ç»è®¡åºå |
| | | BigDecimal stockQuantityTotal = stockInventoryMapper.selectTotal(); |
| | |
| | | queryWrapper.ge(QualityInspect::getCheckTime, monthStart.toString()) |
| | | .le(QualityInspect::getCheckTime, monthEnd.toString()); |
| | | List<QualityInspect> monthInspects = qualityStatisticsMapper.selectList(queryWrapper); |
| | | |
| | | // ç»è®¡æ»æ°éï¼åæ ¼æ°é + ä¸åæ ¼æ°éï¼ |
| | | BigDecimal reduce = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(0)) |
| | | .map(QualityInspect::getQuantity) |
| | | .map(inspect -> { |
| | | BigDecimal qualified = inspect.getQualifiedQuantity() != null ? inspect.getQualifiedQuantity() : BigDecimal.ZERO; |
| | | BigDecimal unqualified = inspect.getUnqualifiedQuantity() != null ? inspect.getUnqualifiedQuantity() : BigDecimal.ZERO; |
| | | return qualified.add(unqualified); |
| | | }) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | supplierNum = supplierNum.add(reduce); |
| | | |
| | | BigDecimal reduce1 = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(1)) |
| | | .map(QualityInspect::getQuantity) |
| | | .map(inspect -> { |
| | | BigDecimal qualified = inspect.getQualifiedQuantity() != null ? inspect.getQualifiedQuantity() : BigDecimal.ZERO; |
| | | BigDecimal unqualified = inspect.getUnqualifiedQuantity() != null ? inspect.getUnqualifiedQuantity() : BigDecimal.ZERO; |
| | | return qualified.add(unqualified); |
| | | }) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | processNum = processNum.add(reduce1); |
| | | |
| | | BigDecimal reduce2 = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(2)) |
| | | .map(QualityInspect::getQuantity) |
| | | .map(inspect -> { |
| | | BigDecimal qualified = inspect.getQualifiedQuantity() != null ? inspect.getQualifiedQuantity() : BigDecimal.ZERO; |
| | | BigDecimal unqualified = inspect.getUnqualifiedQuantity() != null ? inspect.getUnqualifiedQuantity() : BigDecimal.ZERO; |
| | | return qualified.add(unqualified); |
| | | }) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | factoryNum = factoryNum.add(reduce2); |
| | | |
| | |
| | | |
| | | // 1. ä¾åºåæ£éªï¼ç±»å0ï¼- åæ ¼æ°é |
| | | BigDecimal supplierQualified = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(0) |
| | | && "åæ ¼".equals(inspect.getCheckResult())) |
| | | .map(QualityInspect::getQuantity) |
| | | .filter(inspect -> inspect.getInspectType().equals(0)) |
| | | .map(inspect -> inspect.getQualifiedQuantity() != null ? inspect.getQualifiedQuantity() : BigDecimal.ZERO) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | item.setSupplierNum(supplierQualified); |
| | | |
| | | // 2. å·¥åºæ£éªï¼ç±»å1ï¼- åæ ¼æ°é |
| | | BigDecimal processQualified = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(1) |
| | | && "åæ ¼".equals(inspect.getCheckResult())) |
| | | .map(QualityInspect::getQuantity) |
| | | .filter(inspect -> inspect.getInspectType().equals(1)) |
| | | .map(inspect -> inspect.getQualifiedQuantity() != null ? inspect.getQualifiedQuantity() : BigDecimal.ZERO) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | item.setProcessNum(processQualified); |
| | | |
| | | // 3. 工忣éªï¼ç±»å2ï¼- åæ ¼æ°é |
| | | BigDecimal factoryQualified = monthInspects.stream() |
| | | .filter(inspect -> inspect.getInspectType().equals(2) |
| | | && "åæ ¼".equals(inspect.getCheckResult())) |
| | | .map(QualityInspect::getQuantity) |
| | | .filter(inspect -> inspect.getInspectType().equals(2)) |
| | | .map(inspect -> inspect.getQualifiedQuantity() != null ? inspect.getQualifiedQuantity() : BigDecimal.ZERO) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | item.setFactoryNum(factoryQualified); |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public StatisticsReceivablePayableDto statisticsReceivablePayable(Integer type) { |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDate startDate = null; |
| | | LocalDate endDate = null; |
| | | switch (type) { |
| | | case 1: |
| | | // è·åæ¬å¨å¨ä¸ |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | // è·åæ¬å¨å¨æ¥ |
| | | endDate = today.with(DayOfWeek.SUNDAY); |
| | | break; |
| | | case 2: |
| | | startDate = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | endDate = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | break; |
| | | case 3: |
| | | Month currentMonth = today.getMonth(); |
| | | Month firstMonthOfQuarter = currentMonth.firstMonthOfQuarter(); |
| | | Month lastMonthOfQuarter = Month.of(firstMonthOfQuarter.getValue() + 2); |
| | | StatisticsReceivablePayableDto dto = new StatisticsReceivablePayableDto(); |
| | | LocalDate[] range = resolveFinanceRange(type); |
| | | LocalDate startDate = range[0]; |
| | | LocalDate endDate = range[1]; |
| | | |
| | | startDate = today.withMonth(firstMonthOfQuarter.getValue()) |
| | | .with(TemporalAdjusters.firstDayOfMonth()); |
| | | endDate = today.withMonth(lastMonthOfQuarter.getValue()) |
| | | .with(TemporalAdjusters.lastDayOfMonth()); |
| | | break; |
| | | } |
| | | // åºæ¶ |
| | | List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(new LambdaQueryWrapper<SalesLedger>() |
| | | // .ge(SalesLedger::getEntryDate, startDate) |
| | | // .lt(SalesLedger::getEntryDate, endDate) |
| | | ); |
| | | // BigDecimal receivableMoney = |
| | | // salesLedgers.stream().map(SalesLedger::getContractAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal receivableMoney = sumAmount(salesLedgers, SalesLedger::getContractAmount); |
| | | // åºä» |
| | | List<PurchaseLedger> procurementRecords = purchaseLedgerMapper |
| | | .selectList(new LambdaQueryWrapper<PurchaseLedger>() |
| | | // .ge(PurchaseLedger::getEntryDate, startDate) |
| | | // .lt(PurchaseLedger::getEntryDate, endDate) |
| | | ); |
| | | // BigDecimal payableMoney = |
| | | // procurementRecords.stream().map(PurchaseLedger::getContractAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal payableMoney = sumAmount(procurementRecords, PurchaseLedger::getContractAmount); |
| | | // 颿¶ |
| | | List<ReceiptPayment> receiptPayments = receiptPaymentMapper.selectList(new LambdaQueryWrapper<ReceiptPayment>() |
| | | // .ge(ReceiptPayment::getReceiptPaymentDate, startDate) |
| | | // .lt(ReceiptPayment::getReceiptPaymentDate, endDate) |
| | | ); |
| | | // BigDecimal advanceMoney = |
| | | // receiptPayments.stream().map(ReceiptPayment::getReceiptPaymentAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal advanceMoney = sumAmount(receiptPayments, ReceiptPayment::getReceiptPaymentAmount); |
| | | // é¢ä» |
| | | List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper |
| | | .selectList(new LambdaQueryWrapper<PaymentRegistration>() |
| | | // .ge(PaymentRegistration::getPaymentDate, startDate) |
| | | // .lt(PaymentRegistration::getPaymentDate, endDate) |
| | | ); |
| | | // BigDecimal prepayMoney = |
| | | // paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, |
| | | // BigDecimal::add); |
| | | BigDecimal prepayMoney = sumAmount(paymentRegistrations, PaymentRegistration::getCurrentPaymentAmount); |
| | | StatisticsReceivablePayableDto statisticsReceivablePayableDto = new StatisticsReceivablePayableDto(); |
| | | statisticsReceivablePayableDto.setPayableMoney(payableMoney.subtract(prepayMoney)); |
| | | statisticsReceivablePayableDto.setReceivableMoney(receivableMoney.subtract(advanceMoney)); |
| | | statisticsReceivablePayableDto.setAdvanceMoney(advanceMoney); |
| | | statisticsReceivablePayableDto.setPrepayMoney(prepayMoney); |
| | | //éå®åºåº |
| | | BigDecimal receivableBase = sumSalesContractAmount(startDate, endDate); |
| | | //éå®éè´§ |
| | | BigDecimal salesReturnAmount = sumSalesReturnAmount(startDate, endDate); |
| | | //éè´å
¥åº |
| | | BigDecimal payableBase = sumPurchaseContractAmount(startDate, endDate); |
| | | //éè´éè´§ |
| | | BigDecimal purchaseReturnAmount = sumPurchaseReturnAmount(startDate, endDate); |
| | | //æ¶æ¬¾ |
| | | BigDecimal advanceMoney = sumCollectionAmount(startDate, endDate); |
| | | //仿¬¾ |
| | | BigDecimal prepayMoney = sumPaymentAmount(startDate, endDate); |
| | | |
| | | return statisticsReceivablePayableDto; |
| | | //åºæ¶éé¢=éå®åºåº-éå®éè´§ |
| | | dto.setReceivableMoney(scaleMoney(maxZero(receivableBase.subtract(salesReturnAmount)))); |
| | | //åºä»éé¢=éè´å
¥åº-éè´éè´§ |
| | | dto.setPayableMoney(scaleMoney(maxZero(payableBase.subtract(purchaseReturnAmount)))); |
| | | //æ¶æ¬¾éé¢=æ¶æ¬¾å |
| | | dto.setAdvanceMoney(scaleMoney(advanceMoney)); |
| | | //仿¬¾éé¢=仿¬¾å |
| | | dto.setPrepayMoney(scaleMoney(prepayMoney)); |
| | | return dto; |
| | | } |
| | | |
| | | public static <T> BigDecimal sumAmount(List<T> list, java.util.function.Function<T, BigDecimal> amountExtractor) { |
| | |
| | | String endStr = endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | |
| | | // 2. æ¥è¯¢æ°æ® |
| | | List<IncomeExpenseAnalysisDto> incomeList = accountIncomeMapper.selectIncomeStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> incomeList = accountSalesCollectionMapper.selectIncomeStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountPurchasePaymentMapper.selectPayment(startStr, endStr, dateFormat); |
| | | |
| | | // List<IncomeExpenseAnalysisDto> purchaseList = |
| | | // purchaseLedgerMapper.selectPurchaseStats(startStr, endStr, dateFormat); |
| | | |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr, |
| | | dateFormat); |
| | | |
| | | // 3. 转 Mapï¼èªå¨åå¹¶ï¼ |
| | | Map<String, BigDecimal> incomeMap = incomeList.stream() |
| | |
| | | IncomeExpenseAnalysisDto::getAmount, |
| | | BigDecimal::add)); |
| | | |
| | | // Map<String, BigDecimal> purchaseMap = purchaseList.stream() |
| | | // .collect(Collectors.toMap( |
| | | // IncomeExpenseAnalysisDto::getDateStr, |
| | | // IncomeExpenseAnalysisDto::getAmount, |
| | | // BigDecimal::add)); |
| | | |
| | | |
| | | Map<String, BigDecimal> expenseMap = expenseList.stream() |
| | | .collect(Collectors.toMap( |
| | |
| | | for (String dateStr : xAxis) { |
| | | Map<String, Object> item = new HashMap<>(); |
| | | item.put("date", dateStr); |
| | | |
| | | // æ¶å
¥ |
| | | BigDecimal income = incomeMap.getOrDefault(dateStr, BigDecimal.ZERO); |
| | | item.put("income", income.setScale(2, RoundingMode.HALF_UP)); |
| | | |
| | | // æ¯åº = éè´ + è´¢å¡æ¯åº |
| | | // BigDecimal purchase = purchaseMap.getOrDefault(dateStr, BigDecimal.ZERO); |
| | | // æ¯åº |
| | | BigDecimal expense = expenseMap.getOrDefault(dateStr, BigDecimal.ZERO); |
| | | // BigDecimal totalExpense = purchase.add(expense); |
| | | BigDecimal totalExpense = expense; |
| | | |
| | | item.put("expense", totalExpense.setScale(2, RoundingMode.HALF_UP)); |
| | | item.put("expense", expense.setScale(2, RoundingMode.HALF_UP)); |
| | | |
| | | result.add(item); |
| | | } |
| | |
| | | String startStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | String endStr = endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | |
| | | List<IncomeExpenseAnalysisDto> incomeList = accountIncomeMapper.selectIncomeStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountExpenseMapper.selectAccountExpenseStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> incomeList = accountSalesCollectionMapper.selectIncomeStats(startStr, endStr, dateFormat); |
| | | List<IncomeExpenseAnalysisDto> expenseList = accountPurchasePaymentMapper.selectPayment(startStr, endStr, dateFormat); |
| | | |
| | | Map<String, BigDecimal> incomeMap = incomeList.stream().collect(Collectors |
| | | .toMap(IncomeExpenseAnalysisDto::getDateStr, IncomeExpenseAnalysisDto::getAmount, BigDecimal::add)); |
| | |
| | | rawMaterialDto.setName("åææ"); |
| | | rawMaterialDto.setValue(rawMaterialAmount != null ? rawMaterialAmount.toString() : "0"); |
| | | result.add(rawMaterialDto); |
| | | |
| | | List<MapDto> expenseList = accountExpenseMapper.selectExpenseComposition(null, null); |
| | | if (expenseList != null) { |
| | | result.addAll(expenseList); |
| | | } |
| | | } |
| | | |
| | | BigDecimal total = BigDecimal.ZERO; |
| | |
| | | @Override |
| | | public MonthlyIncomeDto monthlyIncome() { |
| | | MonthlyIncomeDto dto = new MonthlyIncomeDto(); |
| | | LocalDate now = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(now); |
| | | LocalDateTime startOfMonth = currentMonth.atDay(1).atStartOfDay(); |
| | | LocalDateTime endOfMonth = currentMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | |
| | | LambdaQueryWrapper<SalesLedgerProduct> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(SalesLedgerProduct::getType, 1); |
| | | wrapper.ge(SalesLedgerProduct::getRegisterDate, startOfMonth); |
| | | wrapper.le(SalesLedgerProduct::getRegisterDate, endOfMonth); |
| | | |
| | | List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(wrapper); |
| | | |
| | | if (CollectionUtils.isEmpty(products)) { |
| | | return dto; |
| | | } |
| | | |
| | | BigDecimal collected = products.stream() |
| | | .map(SalesLedgerProduct::getInvoiceTotal) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | dto.setMonthlyIncome(collected); |
| | | |
| | | BigDecimal overdue = products.stream() |
| | | .map(SalesLedgerProduct::getPendingInvoiceTotal) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | dto.setOverdueNum(overdue); |
| | | |
| | | BigDecimal total = collected.add(overdue); |
| | | |
| | | if (total.compareTo(BigDecimal.ZERO) > 0) { |
| | | String collectionRate = collected.divide(total, 4, RoundingMode.HALF_UP) |
| | | .multiply(new BigDecimal("100")) |
| | | .setScale(2, RoundingMode.HALF_UP) |
| | | .toString(); |
| | | dto.setCollectionRate(collectionRate); |
| | | |
| | | String overdueRate = overdue.divide(total, 4, RoundingMode.HALF_UP) |
| | | .multiply(new BigDecimal("100")) |
| | | .setScale(2, RoundingMode.HALF_UP) |
| | | .toString(); |
| | | dto.setOverdueRate(overdueRate); |
| | | } |
| | | |
| | | LocalDate today = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(today); |
| | | LocalDate startDate = currentMonth.atDay(1); |
| | | LocalDate endDate = currentMonth.atEndOfMonth(); |
| | | //æ¶æ¬¾ |
| | | BigDecimal monthlyIncome = sumCollectionAmount(startDate, endDate); |
| | | //éå®åºåº |
| | | BigDecimal receivableBase = sumSalesContractAmount(startDate, endDate); |
| | | //éå®éè´§ |
| | | BigDecimal salesReturnAmount = sumSalesReturnAmount(startDate, endDate); |
| | | //忬¾ç=æ¶æ¬¾/(éå®åºåº-éå®éè´§)åºæ¶ |
| | | String collectionRate = toRateString(monthlyIncome, receivableBase.subtract(salesReturnAmount)); |
| | | //龿æ°=(éå®åºåºéé¢-éå®éè´§éé¢)åºæ¶éé¢-æ¶æ¬¾éé¢ |
| | | BigDecimal overdueAmount = receivableBase.subtract(salesReturnAmount).subtract(monthlyIncome); |
| | | //龿ç=龿æ°/åºæ¶éé¢ |
| | | String overdueRate = toRateString(overdueAmount, receivableBase); |
| | | dto.setMonthlyIncome(scaleMoney(monthlyIncome)); |
| | | dto.setCollectionRate(collectionRate); |
| | | dto.setOverdueNum(overdueAmount); |
| | | dto.setOverdueRate(overdueRate); |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | public MonthlyExpenditureDto monthlyExpenditure() { |
| | | |
| | | MonthlyExpenditureDto dto = new MonthlyExpenditureDto(); |
| | | LocalDate today = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(today); |
| | | LocalDate startDate = currentMonth.atDay(1); |
| | | LocalDate endDate = currentMonth.atEndOfMonth(); |
| | | //æ¯åº |
| | | BigDecimal monthlyExpenditure = sumPaymentAmount(startDate, endDate); |
| | | //éè´å
¥åº |
| | | BigDecimal payableBase = sumPurchaseContractAmount(startDate, endDate); |
| | | //éè´éè´§ |
| | | BigDecimal purchaseReturnAmount = sumPurchaseReturnAmount(startDate, endDate); |
| | | //仿¬¾ç=仿¬¾/(éè´å
¥åº-éè´éè´§)åºä» |
| | | String paymentRate = toRateString(monthlyExpenditure, payableBase.subtract(purchaseReturnAmount)); |
| | | //æ¶æ¬¾ |
| | | BigDecimal monthlyIncome = sumCollectionAmount(startDate, endDate); |
| | | //æ¯å©æ¶¦= æ¶æ¬¾-æ¯åº |
| | | BigDecimal grossProfit = monthlyIncome.subtract(monthlyExpenditure); |
| | | //婿¶¦ç=æ¯å©æ¶¦/æ¶æ¬¾ |
| | | String profitMarginRate = toRateString(grossProfit, monthlyIncome); |
| | | |
| | | // 彿æ¶é´èå´ |
| | | LocalDate now = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(now); |
| | | LocalDateTime startOfMonth = currentMonth.atDay(1).atStartOfDay(); |
| | | LocalDateTime endOfMonth = currentMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | |
| | | // éè´å°è´¦ï¼type = 2ï¼ |
| | | LambdaQueryWrapper<SalesLedgerProduct> purchaseWrapper = new LambdaQueryWrapper<>(); |
| | | purchaseWrapper.eq(SalesLedgerProduct::getType, 2); |
| | | purchaseWrapper.ge(SalesLedgerProduct::getRegisterDate, startOfMonth); |
| | | purchaseWrapper.le(SalesLedgerProduct::getRegisterDate, endOfMonth); |
| | | |
| | | List<SalesLedgerProduct> purchaseProducts = salesLedgerProductMapper.selectList(purchaseWrapper); |
| | | |
| | | BigDecimal rawMaterialCost = BigDecimal.ZERO; // åææææ¬ |
| | | BigDecimal paidAmount = BigDecimal.ZERO; // 已仿¬¾éé¢ |
| | | BigDecimal pendingAmount = BigDecimal.ZERO; // å¾
仿¬¾éé¢ |
| | | |
| | | if (!CollectionUtils.isEmpty(purchaseProducts)) { |
| | | for (SalesLedgerProduct p : purchaseProducts) { |
| | | |
| | | if (p.getTaxInclusiveTotalPrice() != null) { |
| | | rawMaterialCost = rawMaterialCost.add(p.getTaxInclusiveTotalPrice()); |
| | | } |
| | | |
| | | if (p.getTicketsTotal() != null) { |
| | | paidAmount = paidAmount.add(p.getTicketsTotal()); |
| | | } |
| | | |
| | | if (p.getPendingTicketsTotal() != null) { |
| | | pendingAmount = pendingAmount.add(p.getPendingTicketsTotal()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // å
¶ä»è´¹ç¨ |
| | | LambdaQueryWrapper<AccountExpense> expenseWrapper = new LambdaQueryWrapper<>(); |
| | | expenseWrapper.ge(AccountExpense::getExpenseDate, |
| | | java.sql.Date.valueOf(currentMonth.atDay(1))); |
| | | expenseWrapper.le(AccountExpense::getExpenseDate, |
| | | java.sql.Date.valueOf(currentMonth.atEndOfMonth())); |
| | | |
| | | List<AccountExpense> expenses = accountExpenseMapper.selectList(expenseWrapper); |
| | | |
| | | BigDecimal otherExpense = BigDecimal.ZERO; |
| | | if (!CollectionUtils.isEmpty(expenses)) { |
| | | for (AccountExpense e : expenses) { |
| | | if (e.getExpenseMoney() != null) { |
| | | otherExpense = otherExpense.add(e.getExpenseMoney()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æåº¦æ»æ¯åº |
| | | // BigDecimal monthlyExpenditure = rawMaterialCost.add(otherExpense); |
| | | BigDecimal monthlyExpenditure = otherExpense; |
| | | dto.setMonthlyExpenditure(monthlyExpenditure); |
| | | |
| | | // 已仿¬¾ ÷ï¼å·²ä»æ¬¾ + å¾
仿¬¾ï¼ |
| | | BigDecimal totalPayable = paidAmount.add(pendingAmount); |
| | | if (totalPayable.compareTo(BigDecimal.ZERO) > 0) { |
| | | String paymentRate = paidAmount |
| | | .divide(totalPayable, 4, RoundingMode.HALF_UP) |
| | | .multiply(BigDecimal.valueOf(100)) |
| | | .setScale(2, RoundingMode.HALF_UP) |
| | | .toString(); |
| | | dto.setPaymentRate(paymentRate); |
| | | } |
| | | |
| | | // å®å°è´¦ï¼type = 1ï¼ |
| | | LambdaQueryWrapper<SalesLedgerProduct> salesWrapper = new LambdaQueryWrapper<>(); |
| | | salesWrapper.eq(SalesLedgerProduct::getType, 1); |
| | | salesWrapper.ge(SalesLedgerProduct::getRegisterDate, startOfMonth); |
| | | salesWrapper.le(SalesLedgerProduct::getRegisterDate, endOfMonth); |
| | | |
| | | List<SalesLedgerProduct> salesProducts = salesLedgerProductMapper.selectList(salesWrapper); |
| | | |
| | | BigDecimal revenue = BigDecimal.ZERO; |
| | | if (!CollectionUtils.isEmpty(salesProducts)) { |
| | | for (SalesLedgerProduct s : salesProducts) { |
| | | if (s.getInvoiceAmount() != null) { |
| | | revenue = revenue.add(s.getInvoiceAmount()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æ¯å©æ¶¦ & 婿¶¦ç |
| | | if (revenue.compareTo(BigDecimal.ZERO) > 0) { |
| | | |
| | | // æ¯å©æ¶¦ = é宿¶å
¥ - åææææ¬ |
| | | BigDecimal grossProfit = revenue.subtract(rawMaterialCost); |
| | | dto.setGrossProfit(grossProfit); |
| | | |
| | | // 婿¶¦ç = (é宿¶å
¥ - æåº¦æ»æ¯åº) / é宿¶å
¥ |
| | | BigDecimal profit = revenue.subtract(monthlyExpenditure); |
| | | String profitMarginRate = profit |
| | | .divide(revenue, 4, RoundingMode.HALF_UP) |
| | | .multiply(BigDecimal.valueOf(100)) |
| | | .setScale(2, RoundingMode.HALF_UP) |
| | | .toString(); |
| | | |
| | | dto.setProfitMarginRate(profitMarginRate); |
| | | } |
| | | |
| | | dto.setMonthlyExpenditure(scaleMoney(monthlyExpenditure)); |
| | | dto.setPaymentRate(paymentRate); |
| | | dto.setGrossProfit(scaleMoney(grossProfit)); |
| | | dto.setProfitMarginRate(profitMarginRate); |
| | | return dto; |
| | | } |
| | | |
| | |
| | | BigDecimal unqualifiedCount = BigDecimal.ZERO; |
| | | |
| | | for (QualityInspect item : list) { |
| | | if ("åæ ¼".equals(item.getCheckResult())) { |
| | | qualifiedCount = qualifiedCount.add(item.getQuantity()); |
| | | } else { |
| | | unqualifiedCount = unqualifiedCount.add(item.getQuantity()); |
| | | } |
| | | qualifiedCount = qualifiedCount.add(item.getQualifiedQuantity() != null ? item.getQualifiedQuantity() : BigDecimal.ZERO); |
| | | unqualifiedCount = unqualifiedCount.add(item.getUnqualifiedQuantity() != null ? item.getUnqualifiedQuantity() : BigDecimal.ZERO); |
| | | } |
| | | |
| | | BigDecimal totalCount = qualifiedCount.add(unqualifiedCount); |
| | |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal quantity = item.getQuantity(); |
| | | BigDecimal qualifiedQty = item.getQualifiedQuantity() != null ? item.getQualifiedQuantity() : BigDecimal.ZERO; |
| | | BigDecimal unqualifiedQty = item.getUnqualifiedQuantity() != null ? item.getUnqualifiedQuantity() : BigDecimal.ZERO; |
| | | |
| | | if ("åæ ¼".equals(item.getCheckResult())) { |
| | | dto.setQualifiedCount(dto.getQualifiedCount().add(quantity)); |
| | | } else { |
| | | dto.setUnqualifiedCount(dto.getUnqualifiedCount().add(quantity)); |
| | | } |
| | | dto.setQualifiedCount(dto.getQualifiedCount().add(qualifiedQty)); |
| | | dto.setUnqualifiedCount(dto.getUnqualifiedCount().add(unqualifiedQty)); |
| | | } |
| | | |
| | | // 计ç®åæ ¼ç |
| | |
| | | BigDecimal unqualifiedCount = BigDecimal.ZERO; |
| | | |
| | | for (QualityInspect item : items) { |
| | | BigDecimal qty = item.getQuantity(); |
| | | totalCount = totalCount.add(qty); |
| | | BigDecimal qualifiedQty = item.getQualifiedQuantity() != null ? item.getQualifiedQuantity() : BigDecimal.ZERO; |
| | | BigDecimal unqualifiedQty = item.getUnqualifiedQuantity() != null ? item.getUnqualifiedQuantity() : BigDecimal.ZERO; |
| | | |
| | | if ("åæ ¼".equals(item.getCheckResult())) { |
| | | qualifiedCount = qualifiedCount.add(qty); |
| | | } else { |
| | | unqualifiedCount = unqualifiedCount.add(qty); |
| | | } |
| | | totalCount = totalCount.add(qualifiedQty.add(unqualifiedQty)); |
| | | qualifiedCount = qualifiedCount.add(qualifiedQty); |
| | | unqualifiedCount = unqualifiedCount.add(unqualifiedQty); |
| | | } |
| | | |
| | | if (totalCount.compareTo(BigDecimal.ZERO) == 0) { |
| | |
| | | dto.setProcessNum(sumQuantity(qualityInspectList, 1)); // è¿ç¨ |
| | | dto.setFactoryNum(sumQuantity(qualityInspectList, 2)); // åºå |
| | | |
| | | // å设 qualityInspectList æ¯ä¸ä¸ª List<QualityInspect> ç±»åçéå |
| | | Map<String, List<QualityInspect>> groupedByCheckResult = qualityInspectList.stream() |
| | | .collect(Collectors.groupingBy(QualityInspect::getCheckResult)); |
| | | List<QualityInspect> qualityInspects = groupedByCheckResult.get("ä¸åæ ¼"); |
| | | if (ObjectUtils.isNull(qualityInspects) || qualityInspects.size() == 0) { |
| | | return null; |
| | | // æ ¹æ® unqualifiedQuantity > 0 çéä¸åæ ¼è®°å½ |
| | | List<QualityInspect> qualityInspects = qualityInspectList.stream() |
| | | .filter(i -> i.getUnqualifiedQuantity() != null && i.getUnqualifiedQuantity().compareTo(BigDecimal.ZERO) > 0) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if (ObjectUtils.isEmpty(qualityInspects)) { |
| | | // å³ä½¿æ²¡æä¸åæ ¼è®°å½ï¼ä¹åºè¯¥è¿åç»è®¡æ°æ®ï¼åªæ¯å¾è¡¨é¡¹ä¸ºç©º |
| | | dto.setItem(new ArrayList<>()); |
| | | return dto; |
| | | } |
| | | |
| | | // 4. å¤çå¾è¡¨é¡¹ (Item) |
| | | List<QualityStatisticsItem> itemList = new ArrayList<>(); |
| | | |
| | |
| | | private BigDecimal sumQuantity(List<QualityInspect> list, Integer type) { |
| | | return list.stream() |
| | | .filter(i -> i.getInspectType().equals(type)) |
| | | .map(QualityInspect::getQuantity) |
| | | .filter(Objects::nonNull) |
| | | .map(i -> { |
| | | BigDecimal qualified = i.getQualifiedQuantity() != null ? i.getQualifiedQuantity() : BigDecimal.ZERO; |
| | | BigDecimal unqualified = i.getUnqualifiedQuantity() != null ? i.getUnqualifiedQuantity() : BigDecimal.ZERO; |
| | | return qualified.add(unqualified); |
| | | }) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | } |
| | | |
| | |
| | | QualityStatisticsItem item = new QualityStatisticsItem(); |
| | | item.setDate(dateLabel); |
| | | |
| | | item.setSupplierNum(list.stream().filter(i -> i.getInspectType() == 0).map(QualityInspect::getQuantity) |
| | | // ç»è®¡æ¯ç§æ£éªç±»åçä¸åæ ¼æ°é |
| | | item.setSupplierNum(list.stream() |
| | | .filter(i -> i.getInspectType() == 0) |
| | | .map(i -> i.getUnqualifiedQuantity() != null ? i.getUnqualifiedQuantity() : BigDecimal.ZERO) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | item.setProcessNum(list.stream().filter(i -> i.getInspectType() == 1).map(QualityInspect::getQuantity) |
| | | item.setProcessNum(list.stream() |
| | | .filter(i -> i.getInspectType() == 1) |
| | | .map(i -> i.getUnqualifiedQuantity() != null ? i.getUnqualifiedQuantity() : BigDecimal.ZERO) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | item.setFactoryNum(list.stream().filter(i -> i.getInspectType() == 2).map(QualityInspect::getQuantity) |
| | | item.setFactoryNum(list.stream() |
| | | .filter(i -> i.getInspectType() == 2) |
| | | .map(i -> i.getUnqualifiedQuantity() != null ? i.getUnqualifiedQuantity() : BigDecimal.ZERO) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | |
| | | return item; |
| | |
| | | return productionOperationTaskMapper.calculateProductionStatistics(startDateTime, endDateTime, userId, processIds); |
| | | } |
| | | |
| | | private LocalDate[] resolveFinanceRange(Integer type) { |
| | | LocalDate today = LocalDate.now(); |
| | | int safeType = type == null ? 1 : type; |
| | | LocalDate startDate; |
| | | LocalDate endDate; |
| | | switch (safeType) { |
| | | case 1: |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | endDate = today.with(DayOfWeek.SUNDAY); |
| | | break; |
| | | case 2: |
| | | startDate = today.with(TemporalAdjusters.firstDayOfMonth()); |
| | | endDate = today.with(TemporalAdjusters.lastDayOfMonth()); |
| | | break; |
| | | case 3: |
| | | Month firstMonthOfQuarter = today.getMonth().firstMonthOfQuarter(); |
| | | startDate = LocalDate.of(today.getYear(), firstMonthOfQuarter, 1); |
| | | endDate = startDate.plusMonths(2).with(TemporalAdjusters.lastDayOfMonth()); |
| | | break; |
| | | default: |
| | | startDate = today.with(DayOfWeek.MONDAY); |
| | | endDate = today.with(DayOfWeek.SUNDAY); |
| | | break; |
| | | } |
| | | return new LocalDate[]{startDate, endDate}; |
| | | } |
| | | |
| | | //è®¡ç®æ¥æå
çéå®åºåºéé¢ |
| | | private BigDecimal sumSalesContractAmount(LocalDate startDate, LocalDate endDate) { |
| | | SalesOutboundDto salesOutboundDto = new SalesOutboundDto(); |
| | | salesOutboundDto.setStartDate(startDate); |
| | | salesOutboundDto.setEndDate(endDate); |
| | | List<SalesOutboundVo> salesOutboundVos = stockOutRecordMapper.listPageAccountSales(new Page(1, -1), salesOutboundDto).getRecords(); |
| | | return sumAmount(salesOutboundVos, SalesOutboundVo::getOutboundAmount); |
| | | } |
| | | |
| | | //è®¡ç®æ¥æå
çéå®éè´§éé¢ |
| | | private BigDecimal sumSalesReturnAmount(LocalDate startDate, LocalDate endDate) { |
| | | SalesReturnDto salesReturnDto = new SalesReturnDto(); |
| | | salesReturnDto.setStartDate(startDate); |
| | | salesReturnDto.setEndDate(endDate); |
| | | List<SalesReturnVo> salesReturnVos = returnManagementMapper.listPageAccountSalesReturn(new Page(1, -1), salesReturnDto).getRecords(); |
| | | return sumAmount(salesReturnVos, SalesReturnVo::getRefundAmount); |
| | | } |
| | | |
| | | //è®¡ç®æ¥æå
çéè´å
¥åºéé¢ |
| | | private BigDecimal sumPurchaseContractAmount(LocalDate startDate, LocalDate endDate) { |
| | | PurchaseInboundDto purchaseInboundDto = new PurchaseInboundDto(); |
| | | purchaseInboundDto.setStartDate(startDate); |
| | | purchaseInboundDto.setEndDate(endDate); |
| | | List<PurchaseInboundVo> purchaseInboundVos = stockInRecordMapper.listPageAccountPurchase(new Page(1, -1), purchaseInboundDto).getRecords(); |
| | | return sumAmount(purchaseInboundVos, PurchaseInboundVo::getInboundAmount); |
| | | } |
| | | |
| | | //è®¡ç®æ¥æå
çéè´éè´§éé¢ |
| | | private BigDecimal sumPurchaseReturnAmount(LocalDate startDate, LocalDate endDate) { |
| | | PurchaseReturnDto purchaseReturnDto = new PurchaseReturnDto(); |
| | | purchaseReturnDto.setStartDate(startDate); |
| | | purchaseReturnDto.setEndDate(endDate); |
| | | List<PurchaseReturnVo> purchaseReturnVos = purchaseReturnOrdersMapper.listPageAccountPurchaseReturn(new Page(1, -1), purchaseReturnDto).getRecords(); |
| | | return sumAmount(purchaseReturnVos, PurchaseReturnVo::getTotalAmount); |
| | | } |
| | | |
| | | //è®¡ç®æ¥æå
çæ»æ¶æ¬¾éé¢ |
| | | private BigDecimal sumCollectionAmount(LocalDate startDate, LocalDate endDate) { |
| | | List<AccountSalesCollection> collections = defaultList(accountSalesCollectionMapper.selectList( |
| | | new LambdaQueryWrapper<AccountSalesCollection>() |
| | | .ge(AccountSalesCollection::getCollectionDate, startDate) |
| | | .le(AccountSalesCollection::getCollectionDate, endDate))); |
| | | return sumAmount(collections, AccountSalesCollection::getCollectionAmount); |
| | | } |
| | | |
| | | //è®¡ç®æ¥æå
çæ»ä»æ¬¾éé¢ |
| | | private BigDecimal sumPaymentAmount(LocalDate startDate, LocalDate endDate) { |
| | | List<AccountPurchasePayment> payments = defaultList(accountPurchasePaymentMapper.selectList( |
| | | new LambdaQueryWrapper<AccountPurchasePayment>() |
| | | .ge(AccountPurchasePayment::getPaymentDate, startDate) |
| | | .le(AccountPurchasePayment::getPaymentDate, endDate))); |
| | | return sumAmount(payments, AccountPurchasePayment::getPaymentAmount); |
| | | } |
| | | |
| | | private Date toDate(LocalDate localDate) { |
| | | return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private Date toExclusiveEndDate(LocalDate localDate) { |
| | | return Date.from(localDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | } |
| | | |
| | | private String toRateString(BigDecimal numerator, BigDecimal denominator) { |
| | | if (denominator == null || denominator.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return "0.00"; |
| | | } |
| | | return defaultDecimal(numerator) |
| | | .divide(denominator, 4, RoundingMode.HALF_UP) |
| | | .multiply(BigDecimal.valueOf(100)) |
| | | .setScale(2, RoundingMode.HALF_UP) |
| | | .toString(); |
| | | } |
| | | |
| | | private BigDecimal maxZero(BigDecimal value) { |
| | | if (value == null) { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | return value.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private BigDecimal scaleMoney(BigDecimal value) { |
| | | return defaultDecimal(value).setScale(2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private <T> List<T> defaultList(List<T> list) { |
| | | return list == null ? List.of() : list; |
| | | } |
| | | |
| | | private BigDecimal defaultDecimal(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | |
| | | @Excel(name = "å·¡æ£ä»»å¡åç§°") |
| | | private String taskName; |
| | | |
| | | @Schema(description = "å·¡æ£é¡¹ç®") |
| | | @Excel(name = "å·¡æ£é¡¹ç®") |
| | | private String inspectionProject; |
| | | |
| | | @Schema(description = "设å¤id") |
| | | private Integer taskId; |
| | | |
| | |
| | | @Excel(name = "夿³¨") |
| | | private String remarks; |
| | | |
| | | @Schema(description = "å·¡æ£ç»æ 0 å¼å¸¸ 1 æ£å¸¸") |
| | | private String inspectionResult; |
| | | |
| | | @Schema(description = "å¼å¸¸æè¿°") |
| | | private String abnormalDescription; |
| | | |
| | | @Schema(description = "å
³èç»´ä¿®åID") |
| | | private Long deviceRepairId; |
| | | |
| | | @Schema(description = "éªæ¶äººID") |
| | | private Long acceptanceUserId; |
| | | |
| | | @Schema(description = "éªæ¶äºº") |
| | | @Excel(name = "éªæ¶äºº") |
| | | private String acceptanceName; |
| | | |
| | | @Schema(description = "ä»»å¡ç»è®°äººID") |
| | | private Long registrantId; |
| | | |
| | |
| | | @Excel(name = "å·¡æ£ä»»å¡åç§°") |
| | | private String taskName; |
| | | |
| | | @Schema(description = "å·¡æ£é¡¹ç®") |
| | | @Excel(name = "å·¡æ£é¡¹ç®") |
| | | private String inspectionProject; |
| | | |
| | | @Schema(description = "设å¤id") |
| | | private Integer taskId; |
| | | |
| | |
| | | @Schema(description = "æ¯å¦æ¿æ´»") |
| | | private boolean isActive; |
| | | |
| | | @Schema(description = "æ¯å¦å¯ç¨ 0å¦ 1æ¯") |
| | | @Excel(name = "æ¯å¦å¯ç¨", readConverterExp = "0=å¦,1=æ¯") |
| | | private Integer isEnabled; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Excel(name = "夿³¨") |
| | | private String remarks; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.device.mapper.DeviceLedgerMapper; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | | import com.ruoyi.inspectiontask.dto.InspectionTaskDto; |
| | | import com.ruoyi.inspectiontask.mapper.InspectionTaskMapper; |
| | | import com.ruoyi.inspectiontask.pojo.InspectionTask; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | private final FileUtil fileUtil; |
| | | |
| | | private final DeviceRepairMapper deviceRepairMapper; |
| | | |
| | | private final DeviceLedgerMapper deviceLedgerMapper; |
| | | |
| | | private static final String INSPECTION_RESULT_ABNORMAL = "0"; |
| | | private static final String INSPECTION_RESULT_NORMAL = "1"; |
| | | private static final int REPAIR_STATUS_PENDING = 0; |
| | | |
| | | @Override |
| | | public IPage<InspectionTaskDto> selectInspectionTaskList(Page<InspectionTask> page, InspectionTaskDto inspectionTaskDto) { |
| | | LambdaQueryWrapper<InspectionTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | if (StringUtils.isNotBlank(inspectionTaskDto.getTaskName())) { |
| | | queryWrapper.like(InspectionTask::getTaskName, inspectionTaskDto.getTaskName()); |
| | | } |
| | | if (StringUtils.isNotBlank(inspectionTaskDto.getInspectionProject())) { |
| | | queryWrapper.like(InspectionTask::getInspectionProject, inspectionTaskDto.getInspectionProject()); |
| | | } |
| | | IPage<InspectionTask> entityPage = inspectionTaskMapper.selectPage(page, queryWrapper); |
| | | |
| | | // æ æ°æ®æåè¿å |
| | | if (CollectionUtils.isEmpty(entityPage.getRecords())) { |
| | | return new Page<>(entityPage.getCurrent(), entityPage.getSize(), entityPage.getTotal()); |
| | | } |
| | | // è·åidéå |
| | | List<Long> ids = entityPage.getRecords().stream().map(InspectionTask::getId).collect(Collectors.toList()); |
| | | //ç»è®°äººids |
| | | List<Long> registrantIds = entityPage.getRecords().stream().map(InspectionTask::getRegistrantId).collect(Collectors.toList()); |
| | | // æ¹éæ¥è¯¢ç»è®°äºº |
| | |
| | | } else { |
| | | sysUserMap = new HashMap<>(); |
| | | } |
| | | //å·¡æ£äººids |
| | | List<String> inspectorIds = entityPage.getRecords().stream().map(InspectionTask::getInspectorId).collect(Collectors.toList()); |
| | | |
| | | //è·åææä¸éå¤çç¨æ·ID |
| | | Set<Long> allUserIds = entityPage.getRecords().stream() |
| | | .map(InspectionTask::getInspectorId) // è·å"2,3"è¿æ ·çå符串 |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int addOrEditInspectionTask(InspectionTaskDto inspectionTaskDto) { |
| | | InspectionTask oldInspectionTask = null; |
| | | if (Objects.nonNull(inspectionTaskDto.getId())) { |
| | | oldInspectionTask = inspectionTaskMapper.selectById(inspectionTaskDto.getId()); |
| | | if (oldInspectionTask == null) { |
| | | throw new IllegalArgumentException("å·¡æ£ä»»å¡ä¸åå¨"); |
| | | } |
| | | } |
| | | validateInspectionInput(inspectionTaskDto, oldInspectionTask); |
| | | |
| | | InspectionTask inspectionTask = new InspectionTask(); |
| | | BeanUtils.copyProperties(inspectionTaskDto, inspectionTask); |
| | | inspectionTask.setRegistrantId(SecurityUtils.getLoginUser().getUserId()); |
| | | inspectionTask.setRegistrant(SecurityUtils.getLoginUser().getUsername()); |
| | | fillAcceptanceInfo(inspectionTask, oldInspectionTask); |
| | | int i; |
| | | if (Objects.isNull(inspectionTaskDto.getId())) { |
| | | i = inspectionTaskMapper.insert(inspectionTask); |
| | | } else { |
| | | i = inspectionTaskMapper.updateById(inspectionTask); |
| | | } |
| | | // ä¿åæä»¶ |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.INSPECTION_TASK, inspectionTask.getId(), inspectionTaskDto.getCommonFileListDTO()); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.AFTER_FILE, RecordTypeEnum.INSPECTION_TASK, inspectionTask.getId(), inspectionTaskDto.getCommonFileListAfterDTO()); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.BEFORE_FILE, RecordTypeEnum.INSPECTION_TASK, inspectionTask.getId(), inspectionTaskDto.getCommonFileListBeforeDTO()); |
| | | if (i <= 0) { |
| | | return i; |
| | | } |
| | | Long linkedRepairId = syncRepairOrderIfAbnormal(inspectionTask, oldInspectionTask); |
| | | if (linkedRepairId != null && !Objects.equals(linkedRepairId, inspectionTask.getDeviceRepairId())) { |
| | | InspectionTask relationUpdate = new InspectionTask(); |
| | | relationUpdate.setId(inspectionTask.getId()); |
| | | relationUpdate.setDeviceRepairId(linkedRepairId); |
| | | inspectionTaskMapper.updateById(relationUpdate); |
| | | inspectionTask.setDeviceRepairId(linkedRepairId); |
| | | } |
| | | // ä¿åæä»¶ï¼å段ä¸ä¼ åä¿çåå²ï¼ |
| | | saveInspectionAttachments(inspectionTask.getId(), inspectionTaskDto); |
| | | |
| | | return i; |
| | | } |
| | | |
| | | private void validateInspectionInput(InspectionTaskDto inspectionTaskDto, InspectionTask oldInspectionTask) { |
| | | String inspectionResult = inspectionTaskDto.getInspectionResult(); |
| | | if (StringUtils.isBlank(inspectionResult) && oldInspectionTask != null) { |
| | | inspectionResult = oldInspectionTask.getInspectionResult(); |
| | | } |
| | | if (StringUtils.isBlank(inspectionResult)) { |
| | | throw new IllegalArgumentException("è¯·éæ©å·¡æ£ç»æ"); |
| | | } |
| | | if (!INSPECTION_RESULT_ABNORMAL.equals(inspectionResult) && !INSPECTION_RESULT_NORMAL.equals(inspectionResult)) { |
| | | throw new IllegalArgumentException("å·¡æ£ç»æä»
æ¯æï¼0-å¼å¸¸ï¼1-æ£å¸¸"); |
| | | } |
| | | inspectionTaskDto.setInspectionResult(inspectionResult); |
| | | |
| | | if (!INSPECTION_RESULT_ABNORMAL.equals(inspectionResult)) { |
| | | return; |
| | | } |
| | | |
| | | String abnormalDescription = inspectionTaskDto.getAbnormalDescription(); |
| | | if (StringUtils.isBlank(abnormalDescription) && oldInspectionTask != null) { |
| | | abnormalDescription = oldInspectionTask.getAbnormalDescription(); |
| | | } |
| | | if (StringUtils.isBlank(abnormalDescription)) { |
| | | throw new IllegalArgumentException("å·¡æ£ç»æä¸ºå¼å¸¸æ¶ï¼å¼å¸¸æè¿°ä¸è½ä¸ºç©º"); |
| | | } |
| | | inspectionTaskDto.setAbnormalDescription(abnormalDescription); |
| | | |
| | | if (!hasAnyInspectionPhotoAfterSave(inspectionTaskDto, oldInspectionTask)) { |
| | | throw new IllegalArgumentException("å·¡æ£ç»æä¸ºå¼å¸¸æ¶ï¼å¿
é¡»ä¸ä¼ è³å°ä¸å¼ ç
§ç"); |
| | | } |
| | | } |
| | | |
| | | private boolean hasAnyInspectionPhotoAfterSave(InspectionTaskDto inspectionTaskDto, InspectionTask oldInspectionTask) { |
| | | Long recordId = oldInspectionTask == null ? null : oldInspectionTask.getId(); |
| | | return hasApplicationPhotoAfterSave(inspectionTaskDto.getCommonFileListDTO(), ApplicationTypeEnum.FILE, recordId) |
| | | || hasApplicationPhotoAfterSave(inspectionTaskDto.getCommonFileListAfterDTO(), ApplicationTypeEnum.AFTER_FILE, recordId) |
| | | || hasApplicationPhotoAfterSave(inspectionTaskDto.getCommonFileListBeforeDTO(), ApplicationTypeEnum.BEFORE_FILE, recordId); |
| | | } |
| | | |
| | | private boolean hasApplicationPhotoAfterSave(List<StorageBlobDTO> requestPhotos, ApplicationTypeEnum applicationType, Long recordId) { |
| | | if (requestPhotos != null) { |
| | | return !requestPhotos.isEmpty(); |
| | | } |
| | | if (recordId == null) { |
| | | return false; |
| | | } |
| | | return CollectionUtils.isNotEmpty(fileUtil.getStorageAttachmentsByApplicationAndRecordTypeAndRecordId(applicationType, RecordTypeEnum.INSPECTION_TASK, recordId)); |
| | | } |
| | | |
| | | private void fillAcceptanceInfo(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | Long acceptanceUserId = inspectionTask.getAcceptanceUserId(); |
| | | if (acceptanceUserId == null && oldInspectionTask != null) { |
| | | acceptanceUserId = oldInspectionTask.getAcceptanceUserId(); |
| | | } |
| | | if (acceptanceUserId != null) { |
| | | inspectionTask.setAcceptanceUserId(acceptanceUserId); |
| | | } |
| | | |
| | | String acceptanceName = inspectionTask.getAcceptanceName(); |
| | | if (StringUtils.isBlank(acceptanceName) && acceptanceUserId != null) { |
| | | SysUser acceptanceUser = sysUserMapper.selectUserById(acceptanceUserId); |
| | | if (acceptanceUser != null) { |
| | | acceptanceName = acceptanceUser.getNickName(); |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(acceptanceName) && oldInspectionTask != null) { |
| | | acceptanceName = oldInspectionTask.getAcceptanceName(); |
| | | } |
| | | inspectionTask.setAcceptanceName(acceptanceName); |
| | | } |
| | | |
| | | private Long syncRepairOrderIfAbnormal(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | if (!INSPECTION_RESULT_ABNORMAL.equals(inspectionTask.getInspectionResult())) { |
| | | return inspectionTask.getDeviceRepairId(); |
| | | } |
| | | Long linkedRepairId = inspectionTask.getDeviceRepairId(); |
| | | if (linkedRepairId == null && oldInspectionTask != null) { |
| | | linkedRepairId = oldInspectionTask.getDeviceRepairId(); |
| | | } |
| | | |
| | | if (linkedRepairId != null) { |
| | | DeviceRepair updateRepair = new DeviceRepair(); |
| | | updateRepair.setId(linkedRepairId); |
| | | updateRepair.setRemark(inspectionTask.getAbnormalDescription()); |
| | | deviceRepairMapper.updateById(updateRepair); |
| | | return linkedRepairId; |
| | | } |
| | | |
| | | DeviceRepair deviceRepair = buildDeviceRepair(inspectionTask, oldInspectionTask); |
| | | deviceRepairMapper.insert(deviceRepair); |
| | | return deviceRepair.getId(); |
| | | } |
| | | |
| | | private DeviceRepair buildDeviceRepair(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | DeviceRepair deviceRepair = new DeviceRepair(); |
| | | Long deviceLedgerId = resolveDeviceLedgerId(inspectionTask, oldInspectionTask); |
| | | DeviceLedger deviceLedger = resolveDeviceLedger(deviceLedgerId); |
| | | deviceRepair.setDeviceLedgerId(deviceLedgerId); |
| | | deviceRepair.setDeviceName(resolveDeviceName(inspectionTask, oldInspectionTask, deviceLedger)); |
| | | deviceRepair.setDeviceModel(deviceLedger == null ? null : deviceLedger.getDeviceModel()); |
| | | deviceRepair.setRepairName(resolveRepairReporter(inspectionTask, oldInspectionTask)); |
| | | deviceRepair.setRepairTime(new Date()); |
| | | deviceRepair.setRemark(inspectionTask.getAbnormalDescription()); |
| | | deviceRepair.setMachineryCategory(deviceLedger == null ? null : deviceLedger.getType()); |
| | | deviceRepair.setStatus(REPAIR_STATUS_PENDING); |
| | | return deviceRepair; |
| | | } |
| | | |
| | | private Long resolveDeviceLedgerId(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | Integer taskId = inspectionTask.getTaskId(); |
| | | if (taskId == null && oldInspectionTask != null) { |
| | | taskId = oldInspectionTask.getTaskId(); |
| | | } |
| | | if (taskId == null || taskId <= 0) { |
| | | return null; |
| | | } |
| | | return taskId.longValue(); |
| | | } |
| | | |
| | | private DeviceLedger resolveDeviceLedger(Long deviceLedgerId) { |
| | | if (deviceLedgerId == null) { |
| | | return null; |
| | | } |
| | | return deviceLedgerMapper.selectById(deviceLedgerId); |
| | | } |
| | | |
| | | private String resolveDeviceName(InspectionTask inspectionTask, InspectionTask oldInspectionTask, DeviceLedger deviceLedger) { |
| | | String taskName = inspectionTask.getTaskName(); |
| | | if (StringUtils.isBlank(taskName) && oldInspectionTask != null) { |
| | | taskName = oldInspectionTask.getTaskName(); |
| | | } |
| | | if (StringUtils.isNotBlank(taskName)) { |
| | | return taskName; |
| | | } |
| | | return deviceLedger == null ? null : deviceLedger.getDeviceName(); |
| | | } |
| | | |
| | | private String resolveRepairReporter(InspectionTask inspectionTask, InspectionTask oldInspectionTask) { |
| | | String reporter = inspectionTask.getInspector(); |
| | | if (StringUtils.isBlank(reporter) && oldInspectionTask != null) { |
| | | reporter = oldInspectionTask.getInspector(); |
| | | } |
| | | if (StringUtils.isNotBlank(reporter)) { |
| | | return reporter; |
| | | } |
| | | String inspectorNameByUserId = resolveInspectorNameByUserId(inspectionTask.getInspectorId()); |
| | | if (StringUtils.isBlank(inspectorNameByUserId) && oldInspectionTask != null) { |
| | | inspectorNameByUserId = resolveInspectorNameByUserId(oldInspectionTask.getInspectorId()); |
| | | } |
| | | if (StringUtils.isNotBlank(inspectorNameByUserId)) { |
| | | return inspectorNameByUserId; |
| | | } |
| | | try { |
| | | return SecurityUtils.getUsername(); |
| | | } catch (Exception ignored) { |
| | | return "system"; |
| | | } |
| | | } |
| | | |
| | | private String resolveInspectorNameByUserId(String inspectorIds) { |
| | | if (StringUtils.isBlank(inspectorIds)) { |
| | | return null; |
| | | } |
| | | String firstInspectorId = Arrays.stream(inspectorIds.split(",")) |
| | | .map(String::trim) |
| | | .filter(StringUtils::isNotBlank) |
| | | .findFirst() |
| | | .orElse(null); |
| | | if (!StringUtils.isNumeric(firstInspectorId)) { |
| | | return null; |
| | | } |
| | | SysUser sysUser = sysUserMapper.selectUserById(Long.parseLong(firstInspectorId)); |
| | | return sysUser == null ? null : sysUser.getNickName(); |
| | | } |
| | | |
| | | private void saveInspectionAttachments(Long inspectionTaskId, InspectionTaskDto inspectionTaskDto) { |
| | | saveAttachmentIfPresent(inspectionTaskId, ApplicationTypeEnum.FILE, inspectionTaskDto.getCommonFileListDTO()); |
| | | saveAttachmentIfPresent(inspectionTaskId, ApplicationTypeEnum.AFTER_FILE, inspectionTaskDto.getCommonFileListAfterDTO()); |
| | | saveAttachmentIfPresent(inspectionTaskId, ApplicationTypeEnum.BEFORE_FILE, inspectionTaskDto.getCommonFileListBeforeDTO()); |
| | | } |
| | | |
| | | private void saveAttachmentIfPresent(Long inspectionTaskId, ApplicationTypeEnum applicationTypeEnum, List<StorageBlobDTO> storageBlobDTOS) { |
| | | if (storageBlobDTOS == null) { |
| | | return; |
| | | } |
| | | fileUtil.saveStorageAttachment(applicationTypeEnum, RecordTypeEnum.INSPECTION_TASK, inspectionTaskId, storageBlobDTOS); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int delByIds(Long[] ids) { |
| | |
| | | import com.ruoyi.inspectiontask.mapper.InspectionTaskMapper; |
| | | import com.ruoyi.inspectiontask.pojo.InspectionTask; |
| | | import com.ruoyi.inspectiontask.pojo.TimingTask; |
| | | import lombok.RequiredArgsConstructor; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.quartz.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| | |
| | | TimingTask timingTask = tasks.isEmpty() ? null : tasks.get(0); |
| | | if (timingTask == null) { |
| | | throw new JobExecutionException("æ¾ä¸å°å®æ¶ä»»å¡: " + taskId); |
| | | } |
| | | if (timingTask.getIsEnabled() != null && timingTask.getIsEnabled() == 0) { |
| | | return; |
| | | } |
| | | |
| | | // if (!timingTask.isActive()) { |
| | |
| | | |
| | | // å¤å¶åºæ¬å±æ§ |
| | | inspectionTask.setTaskName(timingTask.getTaskName()); |
| | | inspectionTask.setInspectionProject(timingTask.getInspectionProject()); |
| | | inspectionTask.setTaskId(timingTask.getTaskId()); |
| | | inspectionTask.setInspectorId(timingTask.getInspectorIds()); |
| | | inspectionTask.setInspectionLocation(timingTask.getInspectionLocation()); |
| | | inspectionTask.setRemarks("èªå¨çæèªå®æ¶ä»»å¡ID: " + timingTask.getId()); |
| | | String remarks = "èªå¨çæèªå®æ¶ä»»å¡ID: " + timingTask.getId(); |
| | | if (StringUtils.isNotBlank(timingTask.getRemarks())) { |
| | | remarks = remarks + "ï¼" + timingTask.getRemarks(); |
| | | } |
| | | inspectionTask.setRemarks(remarks); |
| | | inspectionTask.setRegistrantId(timingTask.getRegistrantId()); |
| | | inspectionTask.setFrequencyType(timingTask.getFrequencyType()); |
| | | inspectionTask.setFrequencyDetail(timingTask.getFrequencyDetail()); |
| | |
| | | private final TimingTaskMapper timingTaskMapper; |
| | | private final TimingTaskScheduler timingTaskScheduler; |
| | | private final SysUserMapper sysUserMapper; |
| | | private static final int ENABLED = 1; |
| | | private static final int DISABLED = 0; |
| | | |
| | | |
| | | @Override |
| | |
| | | LambdaQueryWrapper<TimingTask> queryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.isNotBlank(timingTask.getTaskName())) { |
| | | queryWrapper.like(TimingTask::getTaskName, timingTask.getTaskName()); |
| | | } |
| | | if (StringUtils.isNotBlank(timingTask.getInspectionProject())) { |
| | | queryWrapper.like(TimingTask::getInspectionProject, timingTask.getInspectionProject()); |
| | | } |
| | | if (timingTask.getIsEnabled() != null) { |
| | | queryWrapper.eq(TimingTask::getIsEnabled, timingTask.getIsEnabled()); |
| | | } |
| | | IPage<TimingTask> taskPage = timingTaskMapper.selectPage(page, queryWrapper); |
| | | |
| | |
| | | @Override |
| | | @Transactional |
| | | public int addOrEditTimingTask(TimingTaskDto timingTaskDto) throws SchedulerException { |
| | | TimingTask oldTimingTask = null; |
| | | if (Objects.nonNull(timingTaskDto.getId())) { |
| | | oldTimingTask = timingTaskMapper.selectById(timingTaskDto.getId()); |
| | | if (oldTimingTask == null) { |
| | | throw new IllegalArgumentException("宿¶ä»»å¡ä¸åå¨"); |
| | | } |
| | | } |
| | | TimingTask timingTask = new TimingTask(); |
| | | BeanUtils.copyProperties(timingTaskDto, timingTask); |
| | | timingTask.setIsEnabled(resolveEnabledValue(timingTask.getIsEnabled(), oldTimingTask)); |
| | | timingTask.setActive(ENABLED == timingTask.getIsEnabled()); |
| | | // 1. è§£æå符串为 LocalDateï¼åªå
å«å¹´ææ¥ï¼ |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDate localDate = LocalDate.now(); |
| | |
| | | // 设置å建人信æ¯åé»è®¤å¼ |
| | | if (Objects.isNull(timingTaskDto.getId())) { |
| | | timingTask.setRegistrationDate(LocalDate.now()); |
| | | timingTask.setActive(true); |
| | | |
| | | // 计ç®é¦æ¬¡æ§è¡æ¶é´ |
| | | LocalDateTime firstExecutionTime = calculateFirstExecutionTime(timingTask); |
| | | timingTask.setNextExecutionTime(firstExecutionTime); |
| | | int result = timingTaskMapper.insert(timingTask); |
| | | if (result > 0) { |
| | | if (result > 0 && isEnabled(timingTask.getIsEnabled(), timingTask.isActive())) { |
| | | // æ°å¢æååæ·»å å°è°åº¦å¨ |
| | | timingTaskScheduler.scheduleTimingTask(timingTask); |
| | | } |
| | |
| | | |
| | | int result = timingTaskMapper.updateById(timingTask); |
| | | if (result > 0) { |
| | | // æ´æ°æååéæ°è°åº¦ä»»å¡ |
| | | timingTaskScheduler.rescheduleTimingTask(timingTask); |
| | | boolean oldEnabled = isEnabled(oldTimingTask == null ? null : oldTimingTask.getIsEnabled(), oldTimingTask != null && oldTimingTask.isActive()); |
| | | boolean newEnabled = isEnabled(timingTask.getIsEnabled(), timingTask.isActive()); |
| | | if (!newEnabled) { |
| | | timingTaskScheduler.unscheduleTimingTask(timingTask.getId()); |
| | | } else if (oldEnabled) { |
| | | // æ´æ°æååéæ°è°åº¦ä»»å¡ |
| | | timingTaskScheduler.rescheduleTimingTask(timingTask); |
| | | } else { |
| | | // ä»ç¦ç¨æ¹ä¸ºå¯ç¨æ¶éæ°å建è°åº¦ä»»å¡ |
| | | timingTaskScheduler.scheduleTimingTask(timingTask); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | |
| | | return days; |
| | | } |
| | | |
| | | private Integer resolveEnabledValue(Integer requestEnabled, TimingTask oldTimingTask) { |
| | | if (requestEnabled != null) { |
| | | return requestEnabled; |
| | | } |
| | | if (oldTimingTask != null) { |
| | | if (oldTimingTask.getIsEnabled() != null) { |
| | | return oldTimingTask.getIsEnabled(); |
| | | } |
| | | return oldTimingTask.isActive() ? ENABLED : DISABLED; |
| | | } |
| | | return ENABLED; |
| | | } |
| | | |
| | | private boolean isEnabled(Integer enabledValue, boolean activeFallback) { |
| | | if (enabledValue != null) { |
| | | return ENABLED == enabledValue; |
| | | } |
| | | return activeFallback; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/Details.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/InventoryInformationDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementAddDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementManagementUpdateDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDtoCopy.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementRecordOutAdd.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementRecordOutPageDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ProcurementUpdateDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| ÎļþÃû´Ó src/main/java/com/ruoyi/procurementrecord/dto/ReturnManagementDto.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.procurementrecord.dto; |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnManagement; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.procurementrecord.bean.dto; |
| | | |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | public class ReturnSaleProductDto extends ReturnSaleProduct { |
| | | |
| | | private String productName; |
| | | |
| | | private String model; |
| | | |
| | | private String unit; |
| | | |
| | | //æªéè´§æ°é |
| | | private BigDecimal unQuantity; |
| | | |
| | | //æ»éè´§æ°é |
| | | private BigDecimal totalReturnNum; |
| | | |
| | | // éè´§æ»ä»· |
| | | private BigDecimal price; |
| | | |
| | | // éè´§æ»ä»· |
| | | private BigDecimal taxInclusiveUnitPrice; |
| | | |
| | | @Schema(description = "åºåºåå·") |
| | | private String outboundBatches; |
| | | |
| | | @Schema(description = "æ¹æ¬¡å·") |
| | | private String batchNo; |
| | | |
| | | @Schema(description = "åè´§åºåºæ°é") |
| | | private BigDecimal stockOutNum; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.procurementrecord.bean.vo; |
| | | |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @Schema(name = "ShippingInfoVo", description = "è¥é管ç--åè´§ä¿¡æ¯") |
| | | public class ShippingInfoVo { |
| | | |
| | | private ShippingInfo shippingInfo; |
| | | |
| | | @Schema(description = "å货产åå表") |
| | | private List<ShippingProductVo> shippingProductVoList; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.procurementrecord.bean.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | @Schema(name = "ShippingProductVo", description = "è¥é管ç--åè´§åºåºäº§åå表") |
| | | public class ShippingProductVo { |
| | | @Schema(description = "åºåºåid") |
| | | private Long id; |
| | | |
| | | @Schema(description = "产åè§æ ¼id") |
| | | private Long productModelId; |
| | | |
| | | @Schema(description = "产å大类") |
| | | private String productCategory; |
| | | |
| | | @Schema(description = "è§æ ¼åå·") |
| | | private String specificationModel; |
| | | |
| | | @Schema(description = "åä½") |
| | | private String unit; |
| | | |
| | | @Schema(description = "åºåºåå·") |
| | | private String outboundBatches; |
| | | |
| | | @Schema(description = "åè´§åºåºæ°é") |
| | | private BigDecimal stockOutNum; |
| | | |
| | | @Schema(description = "æ¹æ¬¡å·") |
| | | private String batchNo; |
| | | |
| | | @Schema(description = "æªéè´§æ°") |
| | | private BigDecimal unQuantity; |
| | | |
| | | @Schema(description = "éè´§æ»æ°") |
| | | private BigDecimal totalReturnNum; |
| | | |
| | | @Schema(description = "å«ç¨åä»·") |
| | | private BigDecimal taxInclusiveUnitPrice; |
| | | } |
| | |
| | | package com.ruoyi.procurementrecord.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.dto.*; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementExceptionRecordMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementExceptionRecord; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.dto.*; |
| | | import com.ruoyi.procurementrecord.bean.dto.*; |
| | | import com.ruoyi.procurementrecord.mapper.CustomStorageMapper; |
| | | import com.ruoyi.procurementrecord.pojo.CustomStorage; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.ibatis.annotations.Delete; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutAdd; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementUpdateDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementRecordOutAdd; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementUpdateDto; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordOutService; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.ruoyi.account.service.AccountStatementDetailsService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.dto.ReturnManagementDto; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnManagementDto; |
| | | import com.ruoyi.procurementrecord.bean.vo.ShippingInfoVo; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnManagement; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import com.ruoyi.procurementrecord.service.ReturnManagementService; |
| | | import com.ruoyi.procurementrecord.service.ReturnSaleProductService; |
| | | import com.ruoyi.procurementrecord.service.impl.ReturnSaleProductServiceImpl; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | private ReturnManagementService returnManagementService; |
| | | private ReturnSaleProductService returnSaleProductService; |
| | | private final AccountStatementDetailsService accountStatementDetailsService; |
| | | |
| | | @GetMapping("/listPage") |
| | | @Operation(summary = "éå®éè´§-æ¥è¯¢") |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult del(@RequestBody List<Long> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) return error("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | //å¦æè¯¥éå®éè´§å·²ç»çæå¯¹è´¦ååæ æ³å é¤ |
| | | List<ReturnManagement> returnManagements = returnManagementService.listByIds(ids); |
| | | List<String> strings = returnManagements.stream().map(ReturnManagement::getReturnNo).toList(); |
| | | List<AccountStatementDetails> accountStatementDetails = accountStatementDetailsService.list(Wrappers.<AccountStatementDetails>lambdaQuery() |
| | | .in(AccountStatementDetails::getReceiptNumber, strings)); |
| | | if (CollectionUtils.isNotEmpty(accountStatementDetails)){ |
| | | throw new ServiceException("该éå®éè´§åå·²ç»çæå¯¹è´¦åï¼æ æ³å é¤"); |
| | | } |
| | | returnSaleProductService.remove(new QueryWrapper<ReturnSaleProduct>() |
| | | .lambda() |
| | | .in(ReturnSaleProduct::getReturnManagementId, ids)); |
| | |
| | | } |
| | | |
| | | @GetMapping("/getByShippingId") |
| | | @Operation(summary = "éå®éè´§-æ ¹æ®åºåºåæ¥è¯¢éå®è®¢å以å产åä¿¡æ¯") |
| | | @Operation(summary = "éå®éè´§-æ ¹æ®åè´§åæ¥è¯¢éå®è®¢å以ååºåºç产åä¿¡æ¯") |
| | | public AjaxResult getByShippingId(Long shippingId) { |
| | | SalesLedgerDto salesLedgerDto = returnManagementService.getReturnManagementDtoByShippingIdId(shippingId); |
| | | return success(salesLedgerDto); |
| | | ShippingInfoVo shippingInfoVo = returnManagementService.getReturnManagementDtoByShippingIdId(shippingId); |
| | | return success(shippingInfoVo); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementDto; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementPageDto; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementPageDtoCopy; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementPageDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementPageDtoCopy; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.bean.dto.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.SalesReturnVo; |
| | | import com.ruoyi.procurementrecord.dto.ReturnManagementDto; |
| | | import com.ruoyi.account.bean.dto.sales.SalesReturnDto; |
| | | import com.ruoyi.account.bean.vo.sales.SalesReturnVo; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnManagementDto; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnManagement; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | package com.ruoyi.procurementrecord.mapper; |
| | | |
| | | import com.ruoyi.procurementrecord.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | @Schema(description = "å建æ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | @Schema(description = "æ´æ°æ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @Schema(description = "åå»ºç¨æ·") |
| | |
| | | package com.ruoyi.procurementrecord.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Schema(description = "éè´§åid") |
| | | private Long returnManagementId; |
| | | |
| | | @Schema(description = "é货产åid") |
| | | private Long returnsalesLedgerProductId; |
| | | @Schema(description = "å
³èåºåºåid") |
| | | private Long stockOutRecordId; |
| | | |
| | | @Schema(description = "éè´§äº§åæ°é") |
| | | private BigDecimal num; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutAdd; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementUpdateDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementRecordOutAdd; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementUpdateDto; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.dto.*; |
| | | import com.ruoyi.procurementrecord.bean.dto.*; |
| | | import com.ruoyi.procurementrecord.pojo.CustomStorage; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.procurementrecord.dto.ReturnManagementDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnManagementDto; |
| | | import com.ruoyi.procurementrecord.bean.vo.ShippingInfoVo; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnManagement; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | |
| | | /** |
| | | * @author :yys |
| | |
| | | |
| | | boolean updateReturnManagementDto(ReturnManagementDto returnManagementDto); |
| | | |
| | | SalesLedgerDto getReturnManagementDtoByShippingIdId(Long shippingId); |
| | | ShippingInfoVo getReturnManagementDtoByShippingIdId(Long shippingId); |
| | | |
| | | boolean handle(Long returnManagementId); |
| | | |
| | |
| | | package com.ruoyi.procurementrecord.service; |
| | | |
| | | import com.ruoyi.procurementrecord.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutAdd; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementUpdateDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementRecordOutAdd; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementRecordOutPageDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ProcurementUpdateDto; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordOutService; |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.dto.*; |
| | | import com.ruoyi.procurementrecord.bean.dto.*; |
| | | import com.ruoyi.procurementrecord.mapper.CustomStorageMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.bean.dto.SalesRefundAmountOrderDto; |
| | | import com.ruoyi.account.mapper.AccountExpenseMapper; |
| | | import com.ruoyi.account.pojo.AccountExpense; |
| | | import com.ruoyi.account.service.SalesRefundAmountOrderService; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.procurementrecord.dto.ReturnManagementDto; |
| | | import com.ruoyi.procurementrecord.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnManagementDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.bean.vo.ShippingInfoVo; |
| | | import com.ruoyi.procurementrecord.bean.vo.ShippingProductVo; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnManagement; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import com.ruoyi.procurementrecord.service.ReturnManagementService; |
| | | import com.ruoyi.procurementrecord.service.ReturnSaleProductService; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.dto.SalesLedgerProductDto; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.ShippingInfoService; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | private final SalesRefundAmountOrderService salesRefundAmountOrderService; |
| | | private final StockUtils stockUtils; |
| | | private final AccountExpenseMapper accountExpenseMapper; |
| | | |
| | | @Override |
| | | public IPage<ReturnManagementDto> listPage(Page page, ReturnManagementDto returnManagement) { |
| | |
| | | |
| | | @Override |
| | | public boolean updateReturnManagementDto(ReturnManagementDto returnManagementDto) { |
| | | List<ReturnSaleProduct> returnSaleProducts = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(returnManagementDto.getReturnSaleProducts())) { |
| | | returnManagementDto.getReturnSaleProducts().stream().forEach(returnSaleProductDto -> { |
| | | ReturnSaleProduct returnSaleProduct = new ReturnSaleProduct(); |
| | | BeanUtils.copyProperties(returnSaleProductDto, returnSaleProduct); |
| | | returnSaleProducts.add(returnSaleProduct); |
| | | if (returnSaleProductDto.getId() == null){ |
| | | returnSaleProduct.setReturnManagementId(returnManagementDto.getId()); |
| | | returnSaleProduct.setStatus(0); |
| | | returnSaleProductService.save(returnSaleProduct); |
| | | }else returnSaleProductService.updateById(returnSaleProduct); |
| | | }); |
| | | } |
| | | returnSaleProductService.updateBatchById(returnSaleProducts); |
| | | return updateById(returnManagementDto); |
| | | } |
| | | |
| | | @Override |
| | | public SalesLedgerDto getReturnManagementDtoByShippingIdId(Long shippingId) { |
| | | public ShippingInfoVo getReturnManagementDtoByShippingIdId(Long shippingId) { |
| | | ShippingInfo byId = shippingInfoService.getById(shippingId); |
| | | SalesLedger salesLedger = salesLedgerMapper.selectById(byId.getSalesLedgerId()); |
| | | SalesLedgerDto salesLedgerDto = new SalesLedgerDto(); |
| | | BeanUtils.copyProperties(salesLedger, salesLedgerDto); |
| | | |
| | | List<SalesLedgerProductDto> salesLedgerProductDtos = shippingInfoService.getReturnManagementDtoById(byId.getId()); |
| | | salesLedgerDto.setProductDtoData(salesLedgerProductDtos); |
| | | return salesLedgerDto; |
| | | ShippingInfoVo shippingInfoVo = new ShippingInfoVo(); |
| | | shippingInfoVo.setShippingInfo(byId); |
| | | List<ShippingProductVo> shippingProductVos = shippingInfoService.getReturnManagementDtoById(byId.getId()); |
| | | shippingInfoVo.setShippingProductVoList(shippingProductVos); |
| | | return shippingInfoVo; |
| | | } |
| | | |
| | | @Override |
| | |
| | | ReturnManagement byId = this.getById(returnManagementId); |
| | | List<ReturnSaleProductDto> list = returnSaleProductService.listReturnSaleProduct(returnManagementId); |
| | | byId.setStatus(1); |
| | | byId.setSettler(SecurityUtils.getLoginUser().getNickName()); |
| | | updateById(byId); |
| | | SalesRefundAmountOrderDto salesRefundAmountOrder = new SalesRefundAmountOrderDto(); |
| | | salesRefundAmountOrder.setReturnManagementId(returnManagementId); |
| | |
| | | salesRefundAmountOrder.setRefundedAmount(new BigDecimal(0)); |
| | | // æ¯å¦æè´¨éé®é¢ |
| | | if (returnSaleProduct.getIsQuality() == 1) { |
| | | // æè´¨éé®é¢ï¼å
¥ä¸åæ ¼åº |
| | | stockUtils.addUnStock(returnSaleProduct.getProductModelId(),returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_UNSTOCK_IN.getCode(),returnSaleProduct.getId()); |
| | | // æè´¨éé®é¢ï¼å
¥ä¸åæ ¼åº(å¸¦æ¹æ¬¡) |
| | | stockUtils.addUnStockWithBatchNo(returnSaleProduct.getProductModelId(),returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_UNSTOCK_IN.getCode(),returnSaleProduct.getId(),returnSaleProduct.getBatchNo()); |
| | | }else{ |
| | | // æ è´¨éé®é¢ï¼å
¥åæ ¼åº |
| | | stockUtils.addStock(returnSaleProduct.getProductModelId(),returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_HE_IN.getCode(),returnSaleProduct.getId()); |
| | | // æ è´¨éé®é¢ï¼å
¥åæ ¼åº(å¸¦æ¹æ¬¡) |
| | | stockUtils.addStockWithBatchNo(returnSaleProduct.getProductModelId(),returnSaleProduct.getNum(), StockInQualifiedRecordTypeEnum.RETURN_HE_IN.getCode(),returnSaleProduct.getId(),returnSaleProduct.getBatchNo()); |
| | | } |
| | | } |
| | | salesRefundAmountOrder.setRefundAmount(bigDecimal); |
| | | salesRefundAmountOrder.setNotRefundedAmount(salesRefundAmountOrder.getRefundedAmount()); |
| | | // 忹鿬¾ |
| | | // salesRefundAmountOrderService.addSalesRefundAmountOrderDto(salesRefundAmountOrder); |
| | | // åè´¢å¡èå¨ï¼æ°å¢æ¯åº |
| | | AccountExpense accountExpense = new AccountExpense(); |
| | | accountExpense.setBusinessType(3); |
| | | accountExpense.setExpenseMoney(byId.getRefundAmount()); |
| | | accountExpense.setBusinessId(byId.getId()); |
| | | accountExpense.setExpenseDate(new Date()); |
| | | accountExpense.setExpenseMethod("3"); |
| | | accountExpense.setExpenseType("5"); |
| | | accountExpense.setExpenseDescribed("éå®éè´§éæ¬¾"); |
| | | accountExpense.setNote(byId.getReturnReason()); |
| | | accountExpense.setInputUser(SecurityUtils.getLoginUser().getNickName()); |
| | | accountExpense.setInputTime(new Date()); |
| | | accountExpenseMapper.insert(accountExpense); |
| | | return true; |
| | | } |
| | | |
| | |
| | | package com.ruoyi.procurementrecord.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.procurementrecord.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.bean.dto.ReturnSaleProductDto; |
| | | import com.ruoyi.procurementrecord.mapper.ReturnSaleProductMapper; |
| | | import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct; |
| | | import com.ruoyi.procurementrecord.service.ReturnSaleProductService; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.ruoyi.common.enums.ReviewStatusEnum; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | |
| | | private final StockInventoryService stockInventoryService; |
| | | private final StockInRecordService stockInRecordService; |
| | | private final StockOutRecordService stockOutRecordService; |
| | | private final StockInventoryMapper stockInventoryMapper; |
| | | |
| | | /** |
| | | * ä¸åæ ¼å
¥åº |
| | |
| | | stockUninventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockUninventoryDto.setQualitity(quantity); |
| | | stockUninventoryDto.setProductModelId(productModelId); |
| | | stockUninventoryService.addStockInRecordOnly(stockUninventoryDto); |
| | | } |
| | | |
| | | /** |
| | | * ä¸åæ ¼å
¥åºå¸¦æ¹æ¬¡å· |
| | | * |
| | | * @param productModelId |
| | | * @param quantity |
| | | * @param recordType |
| | | * @param recordId |
| | | */ |
| | | public void addUnStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setRecordId(recordId); |
| | | stockUninventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockUninventoryDto.setQualitity(quantity); |
| | | stockUninventoryDto.setProductModelId(productModelId); |
| | | stockUninventoryDto.setBatchNo(batchNo); |
| | | stockUninventoryService.addStockInRecordOnly(stockUninventoryDto); |
| | | } |
| | | |
| | |
| | | public void shipmentStatus(String recordType, Long recordId) { |
| | | LambdaQueryWrapper<StockOutRecord> queryWrapper = new LambdaQueryWrapper<StockOutRecord>().eq(StockOutRecord::getRecordType, recordType) |
| | | .eq(StockOutRecord::getRecordId, recordId); |
| | | StockOutRecord stockOutRecord = stockOutRecordService.getOne(queryWrapper); |
| | | stockOutRecord.setApprovalStatus(0); |
| | | stockOutRecordService.updateById(stockOutRecord); |
| | | stockOutRecordService.list(queryWrapper).stream().forEach(stockOutRecord -> { |
| | | stockOutRecord.setApprovalStatus(0); |
| | | stockOutRecordService.updateById(stockOutRecord); |
| | | }); |
| | | } |
| | | |
| | | //ä¸åæ ¼åºåå é¤ |
| | | public void deleteStockInRecord(Long recordId, String recordType) { |
| | | StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>() |
| | | .lambda().eq(StockInRecord::getRecordId, recordId) |
| | | .eq(StockInRecord::getRecordType, recordType)); |
| | | .eq(StockInRecord::getRecordType, recordType), false); |
| | | if (ObjectUtils.isNotEmpty(one)) { |
| | | stockInRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | //å°åºåå忥 |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(recordId); |
| | | stockInventoryDto.setRecordType(recordType); |
| | | stockInventoryDto.setQualitity(one.getStockInNum()); |
| | | stockInventoryMapper.updateSubtractStockInventory((stockInventoryDto)); |
| | | if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) { |
| | | stockInRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | } else { |
| | | stockInRecordService.removeById(one.getId()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | //å é¤åºåºè®°å½ |
| | | public void deleteStockOutRecord(Long recordId, String recordType) { |
| | | StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>() |
| | | .lambda().eq(StockOutRecord::getRecordId, recordId) |
| | | .eq(StockOutRecord::getRecordType, recordType)); |
| | | .eq(StockOutRecord::getRecordType, recordType), false); |
| | | if (ObjectUtils.isNotEmpty(one)) { |
| | | stockOutRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | //å°åºåå 忥 |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(recordId); |
| | | stockInventoryDto.setRecordType(recordType); |
| | | stockInventoryDto.setQualitity(one.getStockOutNum()); |
| | | stockInventoryMapper.updateAddStockInventory((stockInventoryDto)); |
| | | if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) { |
| | | stockOutRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | } else { |
| | | stockOutRecordService.removeById(one.getId()); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | @Schema(description = "æ¯å¦ç产") |
| | | private Integer isProduction; |
| | | } |
| | |
| | | @PostMapping("/updateRouteItem") |
| | | @Operation(summary = "ä¿®æ¹ç产订åçå·¥èºè·¯çº¿è¯¦æ
") |
| | | public R updateRouteItem(@RequestBody ProductionOrderRoutingOperation productionOrderRoutingOperation) { |
| | | return R.ok(productionOrderRoutingOperationService.updateById(productionOrderRoutingOperation)); |
| | | return R.ok(productionOrderRoutingOperationService.updateRouteItem(productionOrderRoutingOperation)); |
| | | } |
| | | |
| | | @DeleteMapping("/deleteRouteItem/{id}") |
| | |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | Integer countPending(@Param("startDate") String startDate, @Param("endDate") String endDate); |
| | | |
| | | List<Map<String, Object>> selectHomeOrderProgressPage(@Param("status") Integer status, |
| | | @Param("offset") Long offset, |
| | | @Param("size") Long size, |
| | | @Param("startTime") LocalDateTime startTime, |
| | | @Param("endTime") LocalDateTime endTime); |
| | | |
| | | Long countHomeOrderProgress(@Param("status") Integer status, |
| | | @Param("startTime") LocalDateTime startTime, |
| | | @Param("endTime") LocalDateTime endTime); |
| | | |
| | | List<Map<String, Object>> countHomeOrderProgressByStatus(@Param("startTime") LocalDateTime startTime, |
| | | @Param("endTime") LocalDateTime endTime); |
| | | |
| | | List<Map<String, Object>> selectHomeTodayProductionPlan(@Param("size") Long size, |
| | | @Param("planStart") LocalDateTime planStart, |
| | | @Param("planEnd") LocalDateTime planEnd); |
| | | |
| | | Long countHomeTodayProductionPlan(@Param("planStart") LocalDateTime planStart, |
| | | @Param("planEnd") LocalDateTime planEnd); |
| | | |
| | | } |
| | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @Schema(description = "éå®å°è´¦id") |
| | | private Long salesLedgerId; |
| | | |
| | | @Schema(description = "éå®äº§åè§æ ¼id") |
| | | private Long salesLedgerProductId; |
| | | |
| | | @Schema(description = "æ¥å·¥è¡¨id") |
| | | private Long productionProductMainId; |
| | | |
| | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¥å·¥id") |
| | | private Long productMainId; |
| | | |
| | | @Schema(description = "ç产æ¥å·¥ä¸»è¡¨id") |
| | | private Long productionProductMainId; |
| | | |
| | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¥å·¥id") |
| | | private Long productMainId; |
| | | |
| | | @Schema(description = "ç产æ¥å·¥ä¸»è¡¨id") |
| | | private Long productionProductMainId; |
| | | |
| | |
| | | |
| | | R addRouteItem(ProductionOrderRoutingOperation productionOrderRoutingOperation); |
| | | |
| | | R updateRouteItem(ProductionOrderRoutingOperation productionOrderRoutingOperation); |
| | | |
| | | R deleteRouteItem(Long id); |
| | | |
| | | int sortRouteItem(ProductionOrderRoutingOperation productionOrderRoutingOperation); |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.production.bean.dto.ProductionBomStructureDto; |
| | | import com.ruoyi.production.bean.vo.ProductionBomStructureVo; |
| | | import com.ruoyi.production.mapper.ProductionBomStructureMapper; |
| | | import com.ruoyi.production.mapper.ProductionOperationTaskMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderBomMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingOperationMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingOperationParamMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.ProductionBomStructure; |
| | | import com.ruoyi.production.pojo.ProductionOperationTask; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | | import com.ruoyi.production.pojo.ProductionOrderBom; |
| | | import com.ruoyi.production.pojo.ProductionOrderRouting; |
| | | import com.ruoyi.production.pojo.ProductionOrderRoutingOperation; |
| | | import com.ruoyi.production.pojo.ProductionOrderRoutingOperationParam; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.production.service.ProductionBomStructureService; |
| | | import com.ruoyi.production.util.TaskPlanQuantityUtil; |
| | | import com.ruoyi.technology.mapper.TechnologyOperationMapper; |
| | | import com.ruoyi.technology.mapper.TechnologyOperationParamMapper; |
| | | import com.ruoyi.technology.mapper.TechnologyParamMapper; |
| | | import com.ruoyi.technology.pojo.TechnologyOperation; |
| | | import com.ruoyi.technology.pojo.TechnologyOperationParam; |
| | | import com.ruoyi.technology.pojo.TechnologyParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequiredArgsConstructor() |
| | | public class ProductionBomStructureServiceImpl extends ServiceImpl<ProductionBomStructureMapper, ProductionBomStructure> implements ProductionBomStructureService { |
| | | |
| | | private final ProductionBomStructureMapper productionBomStructureMapper; |
| | | private final ProductionBomStructureMapper productionBomStructureMapper; |
| | | private final ProductionOrderBomMapper productionOrderBomMapper; |
| | | private final ProductionOrderMapper productionOrderMapper; |
| | | private final ProductionOrderRoutingMapper productionOrderRoutingMapper; |
| | | private final ProductionOrderRoutingOperationMapper productionOrderRoutingOperationMapper; |
| | | private final ProductionOrderRoutingOperationParamMapper productionOrderRoutingOperationParamMapper; |
| | | private final ProductionOperationTaskMapper productionOperationTaskMapper; |
| | | private final ProductionProductMainMapper productionProductMainMapper; |
| | | private final TechnologyOperationMapper technologyOperationMapper; |
| | | private final TechnologyOperationParamMapper technologyOperationParamMapper; |
| | | private final TechnologyParamMapper technologyParamMapper; |
| | | |
| | | /** |
| | | * æ ¹æ®BOMæ¥è¯¢å¹¶ç»è£
ç»ææ ã |
| | |
| | | if (!updateList.isEmpty()) { |
| | | this.updateBatchById(updateList); |
| | | } |
| | | syncDemandedQuantityAndTaskPlanQuantity(orderBomId, dto.getProductionOrderId()); |
| | | return true; |
| | | } |
| | | |
| | | private void syncDemandedQuantityAndTaskPlanQuantity(Long orderBomId, Long productionOrderId) { |
| | | if (orderBomId == null) { |
| | | return; |
| | | } |
| | | ProductionOrderBom orderBom = productionOrderBomMapper.selectById(orderBomId); |
| | | if (orderBom == null) { |
| | | return; |
| | | } |
| | | Long currentProductionOrderId = productionOrderId != null ? productionOrderId : orderBom.getProductionOrderId(); |
| | | if (currentProductionOrderId == null) { |
| | | return; |
| | | } |
| | | ProductionOrder productionOrder = productionOrderMapper.selectById(currentProductionOrderId); |
| | | if (productionOrder == null) { |
| | | return; |
| | | } |
| | | |
| | | BigDecimal orderQuantity = defaultDecimal(productionOrder.getQuantity()); |
| | | List<ProductionBomStructure> structureList = this.list( |
| | | Wrappers.<ProductionBomStructure>lambdaQuery() |
| | | .eq(ProductionBomStructure::getProductionOrderBomId, orderBomId) |
| | | .orderByAsc(ProductionBomStructure::getId)); |
| | | //忥鿱æ°é |
| | | syncStructureDemandedQuantity(structureList, orderQuantity); |
| | | Long rootProductModelId = orderBom.getProductModelId() != null ? orderBom.getProductModelId() : productionOrder.getProductModelId(); |
| | | //忥ç产工èºè·¯çº¿ |
| | | syncRoutingOperationsByBom(currentProductionOrderId, productionOrder, orderBom, structureList, rootProductModelId); |
| | | //忥工å |
| | | syncTaskPlanQuantity( |
| | | currentProductionOrderId, |
| | | structureList, |
| | | orderQuantity, |
| | | rootProductModelId); |
| | | } |
| | | |
| | | private void syncStructureDemandedQuantity(List<ProductionBomStructure> structureList, BigDecimal orderQuantity) { |
| | | if (structureList == null || structureList.isEmpty()) { |
| | | return; |
| | | } |
| | | List<ProductionBomStructure> updateList = new ArrayList<>(); |
| | | BigDecimal lastProcessDemandedQuantity = orderQuantity; |
| | | for (ProductionBomStructure structure : structureList) { |
| | | if (structure == null || structure.getId() == null) { |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal demandedQuantity = lastProcessDemandedQuantity.multiply(defaultDecimal(structure.getUnitQuantity())); |
| | | // if (compareDecimal(structure.getDemandedQuantity(), demandedQuantity) == 0) { |
| | | // continue; |
| | | // } |
| | | ProductionBomStructure update = new ProductionBomStructure(); |
| | | update.setId(structure.getId()); |
| | | update.setDemandedQuantity(demandedQuantity); |
| | | updateList.add(update); |
| | | structure.setDemandedQuantity(demandedQuantity); |
| | | lastProcessDemandedQuantity = demandedQuantity; |
| | | } |
| | | if (!updateList.isEmpty()) { |
| | | this.updateBatchById(updateList); |
| | | } |
| | | } |
| | | |
| | | private void syncTaskPlanQuantity(Long productionOrderId, |
| | | List<ProductionBomStructure> structureList, |
| | | BigDecimal orderQuantity, |
| | | Long rootProductModelId) { |
| | | List<ProductionOperationTask> taskList = productionOperationTaskMapper.selectList( |
| | | Wrappers.<ProductionOperationTask>lambdaQuery() |
| | | .eq(ProductionOperationTask::getProductionOrderId, productionOrderId) |
| | | .orderByAsc(ProductionOperationTask::getId)); |
| | | if (taskList == null || taskList.isEmpty()) { |
| | | return; |
| | | } |
| | | Set<Long> routingOperationIds = taskList.stream() |
| | | .map(ProductionOperationTask::getProductionOrderRoutingOperationId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | if (routingOperationIds.isEmpty()) { |
| | | return; |
| | | } |
| | | Map<Long, ProductionOrderRoutingOperation> routingOperationMap = productionOrderRoutingOperationMapper |
| | | .selectBatchIds(routingOperationIds) |
| | | .stream() |
| | | .filter(item -> item != null && item.getId() != null) |
| | | .collect(Collectors.toMap(ProductionOrderRoutingOperation::getId, item -> item, (left, right) -> left)); |
| | | // Keep task plan quantities aligned with the same order BOM snapshot demand used during snapshot creation. |
| | | Map<String, BigDecimal> demandedQuantityMap = TaskPlanQuantityUtil.buildOperationDemandedQuantityMap(structureList, rootProductModelId); |
| | | for (ProductionOperationTask task : taskList) { |
| | | if (task == null || task.getId() == null || task.getProductionOrderRoutingOperationId() == null) { |
| | | continue; |
| | | } |
| | | ProductionOrderRoutingOperation routingOperation = routingOperationMap.get(task.getProductionOrderRoutingOperationId()); |
| | | if (routingOperation == null) { |
| | | continue; |
| | | } |
| | | BigDecimal planQuantity = resolveTaskPlanQuantity( |
| | | routingOperation, |
| | | demandedQuantityMap, |
| | | orderQuantity, |
| | | rootProductModelId); |
| | | if (compareDecimal(task.getPlanQuantity(), planQuantity) == 0) { |
| | | continue; |
| | | } |
| | | ProductionOperationTask update = new ProductionOperationTask(); |
| | | update.setId(task.getId()); |
| | | update.setPlanQuantity(planQuantity); |
| | | productionOperationTaskMapper.updateById(update); |
| | | } |
| | | } |
| | | |
| | | private void syncRoutingOperationsByBom(Long productionOrderId, |
| | | ProductionOrder productionOrder, |
| | | ProductionOrderBom orderBom, |
| | | List<ProductionBomStructure> structureList, |
| | | Long rootProductModelId) { |
| | | ProductionOrderRouting orderRouting = getOrCreateOrderRoutingSnapshot(productionOrderId, productionOrder, orderBom, rootProductModelId); |
| | | List<ProductionOrderRoutingOperation> desiredOperationList = buildDesiredRoutingOperationList(structureList, rootProductModelId); |
| | | List<ProductionOrderRoutingOperation> existingOperationList = productionOrderRoutingOperationMapper.selectList( |
| | | Wrappers.<ProductionOrderRoutingOperation>lambdaQuery() |
| | | .eq(ProductionOrderRoutingOperation::getOrderRoutingId, orderRouting.getId()) |
| | | .eq(ProductionOrderRoutingOperation::getProductionOrderId, productionOrderId) |
| | | .orderByAsc(ProductionOrderRoutingOperation::getDragSort) |
| | | .orderByAsc(ProductionOrderRoutingOperation::getId)); |
| | | Map<String, Deque<ProductionOrderRoutingOperation>> existingBucketMap = buildExistingRoutingOperationBucketMap(existingOperationList); |
| | | List<ProductionOrderRoutingOperation> finalOperationList = new ArrayList<>(); |
| | | for (ProductionOrderRoutingOperation desiredOperation : desiredOperationList) { |
| | | String bucketKey = buildRoutingOperationBucketKey( |
| | | desiredOperation.getTechnologyOperationId(), |
| | | desiredOperation.getProductModelId()); |
| | | Deque<ProductionOrderRoutingOperation> matchedQueue = existingBucketMap.get(bucketKey); |
| | | ProductionOrderRoutingOperation matchedOperation = matchedQueue == null ? null : matchedQueue.pollFirst(); |
| | | if (matchedOperation == null) { |
| | | matchedOperation = insertRoutingOperationSnapshot(orderRouting.getId(), productionOrderId, desiredOperation); |
| | | } else { |
| | | updateRoutingOperationSnapshotIfNecessary(matchedOperation, orderRouting.getId(), productionOrderId, desiredOperation); |
| | | } |
| | | finalOperationList.add(matchedOperation); |
| | | } |
| | | for (Deque<ProductionOrderRoutingOperation> queue : existingBucketMap.values()) { |
| | | while (queue != null && !queue.isEmpty()) { |
| | | removeRoutingOperationSnapshot(queue.pollFirst()); |
| | | } |
| | | } |
| | | syncRoutingOperationTasks(productionOrderId, finalOperationList); |
| | | } |
| | | |
| | | private ProductionOrderRouting getOrCreateOrderRoutingSnapshot(Long productionOrderId, |
| | | ProductionOrder productionOrder, |
| | | ProductionOrderBom orderBom, |
| | | Long rootProductModelId) { |
| | | ProductionOrderRouting orderRouting = productionOrderRoutingMapper.selectOne( |
| | | Wrappers.<ProductionOrderRouting>lambdaQuery() |
| | | .eq(ProductionOrderRouting::getProductionOrderId, productionOrderId) |
| | | .orderByDesc(ProductionOrderRouting::getId) |
| | | .last("limit 1")); |
| | | if (orderRouting == null) { |
| | | orderRouting = new ProductionOrderRouting(); |
| | | orderRouting.setProductionOrderId(productionOrderId); |
| | | orderRouting.setProductModelId(rootProductModelId); |
| | | orderRouting.setTechnologyRoutingId(productionOrder == null ? null : productionOrder.getTechnologyRoutingId()); |
| | | orderRouting.setBomId(orderBom == null ? null : orderBom.getBomId()); |
| | | orderRouting.setOrderBomId(orderBom == null ? null : orderBom.getId()); |
| | | productionOrderRoutingMapper.insert(orderRouting); |
| | | return orderRouting; |
| | | } |
| | | ProductionOrderRouting update = new ProductionOrderRouting(); |
| | | update.setId(orderRouting.getId()); |
| | | boolean changed = false; |
| | | if (!Objects.equals(orderRouting.getProductModelId(), rootProductModelId)) { |
| | | update.setProductModelId(rootProductModelId); |
| | | orderRouting.setProductModelId(rootProductModelId); |
| | | changed = true; |
| | | } |
| | | Long technologyRoutingId = productionOrder == null ? null : productionOrder.getTechnologyRoutingId(); |
| | | if (!Objects.equals(orderRouting.getTechnologyRoutingId(), technologyRoutingId)) { |
| | | update.setTechnologyRoutingId(technologyRoutingId); |
| | | orderRouting.setTechnologyRoutingId(technologyRoutingId); |
| | | changed = true; |
| | | } |
| | | Long bomId = orderBom == null ? null : orderBom.getBomId(); |
| | | if (!Objects.equals(orderRouting.getBomId(), bomId)) { |
| | | update.setBomId(bomId); |
| | | orderRouting.setBomId(bomId); |
| | | changed = true; |
| | | } |
| | | Long orderBomId = orderBom == null ? null : orderBom.getId(); |
| | | if (!Objects.equals(orderRouting.getOrderBomId(), orderBomId)) { |
| | | update.setOrderBomId(orderBomId); |
| | | orderRouting.setOrderBomId(orderBomId); |
| | | changed = true; |
| | | } |
| | | if (changed) { |
| | | productionOrderRoutingMapper.updateById(update); |
| | | } |
| | | return orderRouting; |
| | | } |
| | | |
| | | private List<ProductionOrderRoutingOperation> buildDesiredRoutingOperationList(List<ProductionBomStructure> structureList, |
| | | Long rootProductModelId) { |
| | | if (structureList == null || structureList.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | Map<Long, ProductionBomStructure> structureById = structureList.stream() |
| | | .filter(item -> item != null && item.getId() != null) |
| | | .collect(Collectors.toMap(ProductionBomStructure::getId, item -> item, (left, right) -> left)); |
| | | |
| | | // æå»ºç¶-åæ å°å
³ç³» |
| | | Map<Long, List<ProductionBomStructure>> treeMap = buildParentChildMap(structureList); |
| | | |
| | | // 使ç¨ååºéåæå»ºæä½å表ï¼å
ååç¶ï¼ç¡®ä¿å·¥èºè·¯çº¿é¡ºåºæ£ç¡®ï¼ |
| | | // ä½¿ç¨æ·±åº¦ä½ä¸ºæåºä¾æ®çè¾
å©ç»æ |
| | | Map<String, ProductionBomStructure> operationMap = new LinkedHashMap<>(); |
| | | Map<String, Integer> depthMap = new HashMap<>(); |
| | | buildOperationListPostOrderWithDepth(null, treeMap, operationMap, depthMap, structureById, rootProductModelId, 1); |
| | | |
| | | // ææ·±åº¦æåºï¼æ·±åº¦å¤§çæåé¢ |
| | | List<Map.Entry<String, ProductionBomStructure>> sortedEntries = new ArrayList<>(operationMap.entrySet()); |
| | | sortedEntries.sort((a, b) -> { |
| | | int depthCompare = Integer.compare( |
| | | depthMap.getOrDefault(b.getKey(), 0), |
| | | depthMap.getOrDefault(a.getKey(), 0)); |
| | | if (depthCompare != 0) { |
| | | return depthCompare; |
| | | } |
| | | return 0; |
| | | }); |
| | | |
| | | List<ProductionOrderRoutingOperation> desiredOperationList = new ArrayList<>(); |
| | | int dragSort = 1; |
| | | for (Map.Entry<String, ProductionBomStructure> entry : sortedEntries) { |
| | | ProductionBomStructure bomStructure = entry.getValue(); |
| | | Long outputProductModelId = resolveOutputProductModelId(resolveOperationOutputNode(bomStructure, structureById), rootProductModelId); |
| | | TechnologyOperation technologyOperation = getTechnologyOperation(bomStructure.getTechnologyOperationId()); |
| | | ProductionOrderRoutingOperation routingOperation = new ProductionOrderRoutingOperation(); |
| | | routingOperation.setProductModelId(outputProductModelId); |
| | | routingOperation.setTechnologyOperationId(bomStructure.getTechnologyOperationId()); |
| | | routingOperation.setOperationName(technologyOperation == null ? null : technologyOperation.getName()); |
| | | routingOperation.setIsQuality(technologyOperation == null ? null : technologyOperation.getIsQuality()); |
| | | routingOperation.setIsProduction(technologyOperation == null ? null : technologyOperation.getIsProduction()); |
| | | routingOperation.setType(technologyOperation == null ? null : technologyOperation.getType()); |
| | | routingOperation.setDragSort(dragSort++); |
| | | desiredOperationList.add(routingOperation); |
| | | } |
| | | return desiredOperationList; |
| | | } |
| | | |
| | | private void buildOperationListPostOrderWithDepth(Long parentId, |
| | | Map<Long, List<ProductionBomStructure>> treeMap, |
| | | Map<String, ProductionBomStructure> operationMap, |
| | | Map<String, Integer> depthMap, |
| | | Map<Long, ProductionBomStructure> structureById, |
| | | Long rootProductModelId, |
| | | int currentDepth) { |
| | | List<ProductionBomStructure> children = treeMap.get(parentId); |
| | | if (children == null || children.isEmpty()) { |
| | | return; |
| | | } |
| | | for (ProductionBomStructure child : children) { |
| | | // å
éå½å¤çåèç¹ |
| | | buildOperationListPostOrderWithDepth(child.getId(), treeMap, operationMap, depthMap, structureById, rootProductModelId, currentDepth + 1); |
| | | |
| | | // åå¤çå½åèç¹ |
| | | if (child.getTechnologyOperationId() != null) { |
| | | Long outputProductModelId = resolveOutputProductModelId(resolveOperationOutputNode(child, structureById), rootProductModelId); |
| | | String key = buildBomOperationDedupKey(child, outputProductModelId); |
| | | // ä¿ç深度æå¤§çæä½ |
| | | Integer existingDepth = depthMap.get(key); |
| | | if (existingDepth == null || currentDepth > existingDepth) { |
| | | operationMap.put(key, child); |
| | | depthMap.put(key, currentDepth); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Map<Long, List<ProductionBomStructure>> buildParentChildMap(List<ProductionBomStructure> structureList) { |
| | | Map<Long, List<ProductionBomStructure>> treeMap = new LinkedHashMap<>(); |
| | | Map<Long, ProductionBomStructure> structureById = new HashMap<>(); |
| | | |
| | | // æå»ºç¶-åæ å°åIDæ å° |
| | | for (ProductionBomStructure structure : structureList) { |
| | | if (structure == null) continue; |
| | | Long parentId = structure.getParentId(); |
| | | treeMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(structure); |
| | | if (structure.getId() != null) { |
| | | structureById.put(structure.getId(), structure); |
| | | } |
| | | } |
| | | |
| | | // è®¡ç®æ¯ä¸ªèç¹ç深度ï¼ä»æ ¹èç¹å°å½åèç¹çè·ç¦»ï¼æ ¹èç¹æ·±åº¦ä¸º1ï¼ |
| | | Map<Long, Integer> depthMap = new HashMap<>(); |
| | | for (ProductionBomStructure structure : structureList) { |
| | | if (structure == null || structure.getId() == null) continue; |
| | | computeDepthFromRoot(structure.getId(), structureById, depthMap); |
| | | } |
| | | |
| | | // 对æ¯ä¸ªç¶èç¹ä¸çåèç¹ææ·±åº¦ååºæåºï¼ææ·±å±çä¼å
ï¼ |
| | | for (Map.Entry<Long, List<ProductionBomStructure>> entry : treeMap.entrySet()) { |
| | | List<ProductionBomStructure> children = entry.getValue(); |
| | | children.sort((a, b) -> { |
| | | // ä¼å
ææ·±åº¦æåºï¼æ·±åº¦å¤§çæåé¢ï¼ææ·±å±ä¼å
ï¼ |
| | | int depthCompare = Integer.compare( |
| | | depthMap.getOrDefault(b.getId(), 0), |
| | | depthMap.getOrDefault(a.getId(), 0)); |
| | | if (depthCompare != 0) { |
| | | return depthCompare; |
| | | } |
| | | // 深度ç¸åæ¶æIDæåºä¿è¯ç¨³å®æ§ |
| | | return Long.compare(a.getId(), b.getId()); |
| | | }); |
| | | } |
| | | |
| | | return treeMap; |
| | | } |
| | | |
| | | /** |
| | | * 计ç®èç¹æ·±åº¦ï¼ä»æ ¹èç¹å°å½åèç¹çè·ç¦»ï¼ |
| | | * æ ¹èç¹æ·±åº¦ä¸º1ï¼æ¯åä¸ä¸å±æ·±åº¦å 1 |
| | | */ |
| | | private int computeDepthFromRoot(Long nodeId, Map<Long, ProductionBomStructure> structureById, Map<Long, Integer> depthMap) { |
| | | if (depthMap.containsKey(nodeId)) { |
| | | return depthMap.get(nodeId); |
| | | } |
| | | |
| | | ProductionBomStructure structure = structureById.get(nodeId); |
| | | if (structure == null) { |
| | | depthMap.put(nodeId, 1); |
| | | return 1; |
| | | } |
| | | |
| | | Long parentId = structure.getParentId(); |
| | | if (parentId == null || parentId == 0L) { |
| | | // æ ¹èç¹æ·±åº¦ä¸º1 |
| | | depthMap.put(nodeId, 1); |
| | | return 1; |
| | | } |
| | | |
| | | // åèç¹æ·±åº¦ = ç¶èç¹æ·±åº¦ + 1 |
| | | int parentDepth = computeDepthFromRoot(parentId, structureById, depthMap); |
| | | int depth = parentDepth + 1; |
| | | depthMap.put(nodeId, depth); |
| | | return depth; |
| | | } |
| | | |
| | | private void buildOperationListPostOrder(Long parentId, |
| | | Map<Long, List<ProductionBomStructure>> treeMap, |
| | | Map<String, ProductionBomStructure> uniqueOperationMap, |
| | | Map<Long, ProductionBomStructure> structureById, |
| | | Long rootProductModelId) { |
| | | List<ProductionBomStructure> children = treeMap.get(parentId); |
| | | if (children == null || children.isEmpty()) { |
| | | return; |
| | | } |
| | | for (ProductionBomStructure child : children) { |
| | | // å
éå½å¤çåèç¹ |
| | | buildOperationListPostOrder(child.getId(), treeMap, uniqueOperationMap, structureById, rootProductModelId); |
| | | |
| | | // åå¤çå½åèç¹ |
| | | if (child.getTechnologyOperationId() != null) { |
| | | Long outputProductModelId = resolveOutputProductModelId(resolveOperationOutputNode(child, structureById), rootProductModelId); |
| | | String key = buildBomOperationDedupKey(child, outputProductModelId); |
| | | // å»éæ¶ä¿ç深度æå¤§çæä½ï¼ååºéåå
éå°æ·±å±èç¹ï¼æä»¥ç´æ¥è¦çå³å¯ï¼ |
| | | uniqueOperationMap.put(key, child); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Map<String, Deque<ProductionOrderRoutingOperation>> buildExistingRoutingOperationBucketMap(List<ProductionOrderRoutingOperation> existingOperationList) { |
| | | Map<String, Deque<ProductionOrderRoutingOperation>> existingBucketMap = new LinkedHashMap<>(); |
| | | if (existingOperationList == null || existingOperationList.isEmpty()) { |
| | | return existingBucketMap; |
| | | } |
| | | for (ProductionOrderRoutingOperation routingOperation : existingOperationList) { |
| | | String bucketKey = buildRoutingOperationBucketKey( |
| | | routingOperation.getTechnologyOperationId(), |
| | | routingOperation.getProductModelId()); |
| | | existingBucketMap.computeIfAbsent(bucketKey, key -> new ArrayDeque<>()).addLast(routingOperation); |
| | | } |
| | | return existingBucketMap; |
| | | } |
| | | |
| | | private ProductionOrderRoutingOperation insertRoutingOperationSnapshot(Long orderRoutingId, |
| | | Long productionOrderId, |
| | | ProductionOrderRoutingOperation desiredOperation) { |
| | | ProductionOrderRoutingOperation insert = new ProductionOrderRoutingOperation(); |
| | | insert.setOrderRoutingId(orderRoutingId); |
| | | insert.setProductionOrderId(productionOrderId); |
| | | insert.setProductModelId(desiredOperation.getProductModelId()); |
| | | insert.setTechnologyOperationId(desiredOperation.getTechnologyOperationId()); |
| | | insert.setOperationName(desiredOperation.getOperationName()); |
| | | insert.setIsQuality(desiredOperation.getIsQuality()); |
| | | insert.setIsProduction(desiredOperation.getIsProduction()); |
| | | insert.setType(desiredOperation.getType()); |
| | | insert.setDragSort(desiredOperation.getDragSort()); |
| | | productionOrderRoutingOperationMapper.insert(insert); |
| | | syncRoutingOperationParams(insert.getId(), productionOrderId, insert.getTechnologyOperationId()); |
| | | return insert; |
| | | } |
| | | |
| | | private void updateRoutingOperationSnapshotIfNecessary(ProductionOrderRoutingOperation currentOperation, |
| | | Long orderRoutingId, |
| | | Long productionOrderId, |
| | | ProductionOrderRoutingOperation desiredOperation) { |
| | | if (currentOperation == null || currentOperation.getId() == null) { |
| | | return; |
| | | } |
| | | ProductionOrderRoutingOperation update = new ProductionOrderRoutingOperation(); |
| | | update.setId(currentOperation.getId()); |
| | | boolean changed = false; |
| | | if (!Objects.equals(currentOperation.getOrderRoutingId(), orderRoutingId)) { |
| | | update.setOrderRoutingId(orderRoutingId); |
| | | currentOperation.setOrderRoutingId(orderRoutingId); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getProductionOrderId(), productionOrderId)) { |
| | | update.setProductionOrderId(productionOrderId); |
| | | currentOperation.setProductionOrderId(productionOrderId); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getProductModelId(), desiredOperation.getProductModelId())) { |
| | | update.setProductModelId(desiredOperation.getProductModelId()); |
| | | currentOperation.setProductModelId(desiredOperation.getProductModelId()); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getTechnologyOperationId(), desiredOperation.getTechnologyOperationId())) { |
| | | update.setTechnologyOperationId(desiredOperation.getTechnologyOperationId()); |
| | | currentOperation.setTechnologyOperationId(desiredOperation.getTechnologyOperationId()); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getOperationName(), desiredOperation.getOperationName())) { |
| | | update.setOperationName(desiredOperation.getOperationName()); |
| | | currentOperation.setOperationName(desiredOperation.getOperationName()); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getIsQuality(), desiredOperation.getIsQuality())) { |
| | | update.setIsQuality(desiredOperation.getIsQuality()); |
| | | currentOperation.setIsQuality(desiredOperation.getIsQuality()); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getIsProduction(), desiredOperation.getIsProduction())) { |
| | | update.setIsProduction(desiredOperation.getIsProduction()); |
| | | currentOperation.setIsProduction(desiredOperation.getIsProduction()); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getType(), desiredOperation.getType())) { |
| | | update.setType(desiredOperation.getType()); |
| | | currentOperation.setType(desiredOperation.getType()); |
| | | changed = true; |
| | | } |
| | | if (!Objects.equals(currentOperation.getDragSort(), desiredOperation.getDragSort())) { |
| | | update.setDragSort(desiredOperation.getDragSort()); |
| | | currentOperation.setDragSort(desiredOperation.getDragSort()); |
| | | changed = true; |
| | | } |
| | | if (changed) { |
| | | productionOrderRoutingOperationMapper.updateById(update); |
| | | } |
| | | } |
| | | |
| | | private void removeRoutingOperationSnapshot(ProductionOrderRoutingOperation routingOperation) { |
| | | if (routingOperation == null || routingOperation.getId() == null) { |
| | | return; |
| | | } |
| | | ProductionOperationTask task = productionOperationTaskMapper.selectOne( |
| | | Wrappers.<ProductionOperationTask>lambdaQuery() |
| | | .eq(ProductionOperationTask::getProductionOrderRoutingOperationId, routingOperation.getId()) |
| | | .last("limit 1")); |
| | | if (task != null) { |
| | | validateTaskCanRemove(task); |
| | | productionOperationTaskMapper.deleteById(task.getId()); |
| | | } |
| | | productionOrderRoutingOperationParamMapper.delete( |
| | | Wrappers.<ProductionOrderRoutingOperationParam>lambdaQuery() |
| | | .eq(ProductionOrderRoutingOperationParam::getProductionOrderRoutingOperationId, routingOperation.getId())); |
| | | productionOrderRoutingOperationMapper.deleteById(routingOperation.getId()); |
| | | } |
| | | |
| | | private void syncRoutingOperationTasks(Long productionOrderId, List<ProductionOrderRoutingOperation> routingOperationList) { |
| | | if (routingOperationList == null || routingOperationList.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Long> routingOperationIdList = routingOperationList.stream() |
| | | .map(ProductionOrderRoutingOperation::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | if (routingOperationIdList.isEmpty()) { |
| | | return; |
| | | } |
| | | Map<Long, ProductionOperationTask> taskByRoutingOperationId = productionOperationTaskMapper.selectList( |
| | | Wrappers.<ProductionOperationTask>lambdaQuery() |
| | | .in(ProductionOperationTask::getProductionOrderRoutingOperationId, routingOperationIdList) |
| | | .orderByAsc(ProductionOperationTask::getId)) |
| | | .stream() |
| | | .filter(item -> item != null && item.getProductionOrderRoutingOperationId() != null) |
| | | .collect(Collectors.toMap( |
| | | ProductionOperationTask::getProductionOrderRoutingOperationId, |
| | | item -> item, |
| | | (left, right) -> left, |
| | | LinkedHashMap::new)); |
| | | for (int i = 0; i < routingOperationList.size(); i++) { |
| | | ProductionOrderRoutingOperation routingOperation = routingOperationList.get(i); |
| | | if (routingOperation == null || routingOperation.getId() == null) { |
| | | continue; |
| | | } |
| | | boolean shouldHaveTask = i == routingOperationList.size() - 1 || Boolean.TRUE.equals(routingOperation.getIsProduction()); |
| | | ProductionOperationTask existingTask = taskByRoutingOperationId.get(routingOperation.getId()); |
| | | if (shouldHaveTask) { |
| | | if (existingTask == null) { |
| | | ProductionOperationTask task = new ProductionOperationTask(); |
| | | task.setProductionOrderId(productionOrderId); |
| | | task.setProductionOrderRoutingOperationId(routingOperation.getId()); |
| | | task.setPlanQuantity(BigDecimal.ZERO); |
| | | task.setCompleteQuantity(BigDecimal.ZERO); |
| | | task.setWorkOrderNo(generateNextTaskNo()); |
| | | task.setStatus(2); |
| | | productionOperationTaskMapper.insert(task); |
| | | } |
| | | continue; |
| | | } |
| | | if (existingTask != null) { |
| | | validateTaskCanRemove(existingTask); |
| | | productionOperationTaskMapper.deleteById(existingTask.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void validateTaskCanRemove(ProductionOperationTask task) { |
| | | if (task == null || task.getId() == null) { |
| | | return; |
| | | } |
| | | if (defaultDecimal(task.getCompleteQuantity()).compareTo(BigDecimal.ZERO) > 0) { |
| | | throw new ServiceException("å·¥åºå·²äº§çæ¥å·¥è®°å½ï¼æ æ³æ ¹æ® BOM åæ´å é¤å¯¹åºå·¥åºå¿«ç
§" + task.getWorkOrderNo()); |
| | | } |
| | | long reportCount = productionProductMainMapper.selectCount( |
| | | Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .eq(ProductionProductMain::getProductionOperationTaskId, task.getId())); |
| | | if (reportCount > 0) { |
| | | throw new ServiceException("å·¥åºå·²äº§çæ¥å·¥è®°å½ï¼æ æ³æ ¹æ® BOM åæ´å é¤å¯¹åºå·¥å"); |
| | | } |
| | | } |
| | | |
| | | private void syncRoutingOperationParams(Long routingOperationId, Long productionOrderId, Long technologyOperationId) { |
| | | if (routingOperationId == null || technologyOperationId == null) { |
| | | return; |
| | | } |
| | | List<TechnologyOperationParam> operationParamList = technologyOperationParamMapper.selectList( |
| | | Wrappers.<TechnologyOperationParam>lambdaQuery() |
| | | .eq(TechnologyOperationParam::getTechnologyOperationId, technologyOperationId) |
| | | .orderByAsc(TechnologyOperationParam::getId)); |
| | | for (TechnologyOperationParam operationParam : operationParamList) { |
| | | TechnologyParam technologyParam = technologyParamMapper.selectById(operationParam.getTechnologyParamId()); |
| | | if (technologyParam == null) { |
| | | continue; |
| | | } |
| | | ProductionOrderRoutingOperationParam snapshot = new ProductionOrderRoutingOperationParam(); |
| | | snapshot.setProductionOrderId(productionOrderId); |
| | | snapshot.setProductionOrderRoutingOperationId(routingOperationId); |
| | | snapshot.setTechnologyOperationId(operationParam.getTechnologyOperationId()); |
| | | snapshot.setTechnologyOperationParamId(operationParam.getId()); |
| | | snapshot.setParamId(technologyParam.getId()); |
| | | snapshot.setParamCode(technologyParam.getParamCode()); |
| | | snapshot.setParamName(technologyParam.getParamName()); |
| | | snapshot.setParamType(technologyParam.getParamType()); |
| | | snapshot.setParamFormat(technologyParam.getParamFormat()); |
| | | snapshot.setUnit(technologyParam.getUnit()); |
| | | snapshot.setIsRequired(technologyParam.getIsRequired()); |
| | | snapshot.setRemark(technologyParam.getRemark()); |
| | | snapshot.setStandardValue(operationParam.getStandardValue()); |
| | | productionOrderRoutingOperationParamMapper.insert(snapshot); |
| | | } |
| | | } |
| | | |
| | | private Map<String, BigDecimal> buildOperationDemandedQuantityMap(List<ProductionBomStructure> structureList, |
| | | Long rootProductModelId) { |
| | | if (structureList == null || structureList.isEmpty()) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | Map<Long, ProductionBomStructure> structureById = structureList.stream() |
| | | .filter(item -> item != null && item.getId() != null) |
| | | .collect(Collectors.toMap(ProductionBomStructure::getId, item -> item, (left, right) -> left)); |
| | | Map<String, BigDecimal> demandedQuantityMap = new HashMap<>(); |
| | | Set<String> mergedOutputNodeKeySet = new HashSet<>(); |
| | | for (ProductionBomStructure bomStructure : structureList) { |
| | | if (bomStructure == null || bomStructure.getTechnologyOperationId() == null) { |
| | | continue; |
| | | } |
| | | // Resolve the output node first, then read the output node demand for the task plan quantity. |
| | | ProductionBomStructure outputNode = resolveOperationOutputNode(bomStructure, structureById); |
| | | Long outputProductModelId = resolveOutputProductModelId(outputNode, rootProductModelId); |
| | | if (outputProductModelId == null) { |
| | | continue; |
| | | } |
| | | String mergedOutputNodeKey = buildOperationOutputNodeKey( |
| | | bomStructure.getTechnologyOperationId(), |
| | | outputNode == null ? null : outputNode.getId(), |
| | | outputProductModelId); |
| | | if (!mergedOutputNodeKeySet.add(mergedOutputNodeKey)) { |
| | | continue; |
| | | } |
| | | // Multiple input rows can point to the same output node, so only count that output demand once. |
| | | String key = buildOperationDemandedQuantityKey(bomStructure.getTechnologyOperationId(), outputProductModelId); |
| | | demandedQuantityMap.merge(key, defaultDecimal(outputNode == null ? null : outputNode.getDemandedQuantity()), BigDecimal::add); |
| | | } |
| | | return demandedQuantityMap; |
| | | } |
| | | |
| | | private BigDecimal resolveTaskPlanQuantity(ProductionOrderRoutingOperation routingOperation, |
| | | Map<String, BigDecimal> demandedQuantityMap, |
| | | BigDecimal orderQuantity, |
| | | Long rootProductModelId) { |
| | | if (routingOperation == null || demandedQuantityMap == null || demandedQuantityMap.isEmpty()) { |
| | | return orderQuantity; |
| | | } |
| | | Long outputProductModelId = routingOperation.getProductModelId() != null |
| | | ? routingOperation.getProductModelId() |
| | | : rootProductModelId; |
| | | String key = buildOperationDemandedQuantityKey( |
| | | routingOperation.getTechnologyOperationId(), |
| | | outputProductModelId); |
| | | BigDecimal planQuantity = demandedQuantityMap.get(key); |
| | | return planQuantity != null ? planQuantity : orderQuantity; |
| | | } |
| | | |
| | | private String buildOperationDemandedQuantityKey(Long operationId, Long outputProductModelId) { |
| | | return String.valueOf(operationId) + "#" + String.valueOf(outputProductModelId); |
| | | } |
| | | |
| | | private String buildRoutingOperationBucketKey(Long operationId, Long outputProductModelId) { |
| | | return String.valueOf(operationId) + "#" + String.valueOf(outputProductModelId); |
| | | } |
| | | |
| | | private String buildBomOperationDedupKey(ProductionBomStructure bomStructure, Long outputProductModelId) { |
| | | Long operationId = bomStructure == null ? null : bomStructure.getTechnologyOperationId(); |
| | | Long parentId = bomStructure == null ? null : bomStructure.getParentId(); |
| | | return operationId + "#" + outputProductModelId + "#" + parentId; |
| | | } |
| | | |
| | | private String buildOperationOutputNodeKey(Long operationId, Long outputNodeId, Long outputProductModelId) { |
| | | return String.valueOf(operationId) + "#" + String.valueOf(outputNodeId) + "#" + String.valueOf(outputProductModelId); |
| | | } |
| | | |
| | | private ProductionBomStructure resolveOperationOutputNode(ProductionBomStructure bomStructure, |
| | | Map<Long, ProductionBomStructure> structureById) { |
| | | if (bomStructure == null) { |
| | | return null; |
| | | } |
| | | // The root node is the first output node; other rows use their direct parent as the current operation output. |
| | | if (bomStructure.getParentId() == null) { |
| | | return bomStructure; |
| | | } |
| | | ProductionBomStructure parent = structureById.get(bomStructure.getParentId()); |
| | | return parent != null ? parent : bomStructure; |
| | | } |
| | | |
| | | private Long resolveOutputProductModelId(ProductionBomStructure outputNode, |
| | | Long rootProductModelId) { |
| | | if (outputNode == null) { |
| | | return rootProductModelId; |
| | | } |
| | | return outputNode.getProductModelId() != null ? outputNode.getProductModelId() : rootProductModelId; |
| | | } |
| | | |
| | | private TechnologyOperation getTechnologyOperation(Long technologyOperationId) { |
| | | if (technologyOperationId == null) { |
| | | return null; |
| | | } |
| | | return technologyOperationMapper.selectById(technologyOperationId); |
| | | } |
| | | |
| | | private String generateNextTaskNo() { |
| | | String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | ProductionOperationTask latestTask = productionOperationTaskMapper.selectOne( |
| | | Wrappers.<ProductionOperationTask>lambdaQuery() |
| | | .likeRight(ProductionOperationTask::getWorkOrderNo, "GD" + datePrefix) |
| | | .orderByDesc(ProductionOperationTask::getWorkOrderNo) |
| | | .last("limit 1")); |
| | | int sequenceNumber = 1; |
| | | if (latestTask != null && latestTask.getWorkOrderNo() != null && latestTask.getWorkOrderNo().startsWith("GD" + datePrefix)) { |
| | | try { |
| | | sequenceNumber = Integer.parseInt(latestTask.getWorkOrderNo().substring(("GD" + datePrefix).length())) + 1; |
| | | } catch (NumberFormatException ignored) { |
| | | sequenceNumber = 1; |
| | | } |
| | | } |
| | | return "GD" + String.format("%s%03d", datePrefix, sequenceNumber); |
| | | } |
| | | |
| | | private BigDecimal defaultDecimal(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | private int compareDecimal(BigDecimal left, BigDecimal right) { |
| | | return defaultDecimal(left).compareTo(defaultDecimal(right)); |
| | | } |
| | | |
| | | /** |
| | | * å°æ å½¢ç»ææå¹³æå表ï¼ä¾¿äºç»ä¸ä¿åã |
| | | */ |
| | |
| | | import com.ruoyi.production.bean.dto.ProductionOperationTaskDto; |
| | | import com.ruoyi.production.bean.vo.ProductionOperationTaskVo; |
| | | import com.ruoyi.production.mapper.ProductionOrderMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingOperationMapper; |
| | | import com.ruoyi.production.mapper.ProductionOperationTaskMapper; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | | import com.ruoyi.production.pojo.ProductionOperationTask; |
| | | import com.ruoyi.production.pojo.ProductionOrderRoutingOperation; |
| | | import com.ruoyi.production.service.ProductionOperationTaskService; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | |
| | | |
| | | private final SysUserMapper sysUserMapper; |
| | | private final ProductionOrderMapper productionOrderMapper; |
| | | private final ProductionOrderRoutingOperationMapper productionOrderRoutingOperationMapper; |
| | | |
| | | private final FileUtil fileUtil; |
| | | |
| | |
| | | // å页æ¥è¯¢ç产工åºä»»å¡ |
| | | Page<ProductionOperationTaskVo> voPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal()); |
| | | IPage<ProductionOperationTaskVo> result = baseMapper.pageProductionOperationTask(voPage, dto); |
| | | fillOperationTypes(result.getRecords()); |
| | | fillUserNames(result.getRecords()); |
| | | return result; |
| | | } |
| | |
| | | public List<ProductionOperationTaskVo> listProductionOperationTask(ProductionOperationTaskDto dto) { |
| | | // æ¥è¯¢å·¥åºä»»å¡å表 |
| | | List<ProductionOperationTaskVo> result = BeanUtil.copyToList(this.list(buildQueryWrapper(dto)), ProductionOperationTaskVo.class); |
| | | fillOperationTypes(result); |
| | | fillUserNames(result); |
| | | return result; |
| | | } |
| | |
| | | return null; |
| | | } |
| | | ProductionOperationTaskVo vo = BeanUtil.copyProperties(item, ProductionOperationTaskVo.class); |
| | | fillOperationTypes(Collections.singletonList(vo)); |
| | | if (item.getProductionOrderId() != null) { |
| | | ProductionOrder productionOrder = productionOrderMapper.selectById(item.getProductionOrderId()); |
| | | if (productionOrder != null) { |
| | |
| | | @Override |
| | | public List<ProductionOperationTaskVo> getOperation(ProductionOperationTaskDto dto) { |
| | | // æ¥è¯¢å·¥åºä»»å¡å表 |
| | | return baseMapper.getOperation(dto); |
| | | List<ProductionOperationTaskVo> result = baseMapper.getOperation(dto); |
| | | fillOperationTypes(result); |
| | | return result; |
| | | } |
| | | |
| | | private void fillOperationTypes(List<ProductionOperationTaskVo> voList) { |
| | | // åå¡«å·¥åºç±»åï¼0 è®¡æ¶ / 1 è®¡ä»¶ï¼ |
| | | if (voList == null || voList.isEmpty()) { |
| | | return; |
| | | } |
| | | Set<Long> operationIds = voList.stream() |
| | | .filter(Objects::nonNull) |
| | | .map(ProductionOperationTaskVo::getProductionOrderRoutingOperationId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toCollection(LinkedHashSet::new)); |
| | | if (operationIds.isEmpty()) { |
| | | return; |
| | | } |
| | | Map<Long, Integer> typeByOperationId = productionOrderRoutingOperationMapper |
| | | .selectBatchIds(new ArrayList<>(operationIds)) |
| | | .stream() |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap( |
| | | ProductionOrderRoutingOperation::getId, |
| | | ProductionOrderRoutingOperation::getType, |
| | | (left, right) -> left |
| | | )); |
| | | for (ProductionOperationTaskVo vo : voList) { |
| | | if (vo == null || vo.getType() != null || vo.getProductionOrderRoutingOperationId() == null) { |
| | | continue; |
| | | } |
| | | vo.setType(typeByOperationId.get(vo.getProductionOrderRoutingOperationId())); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.production.mapper.ProductionOperationTaskMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingOperationMapper; |
| | | import com.ruoyi.production.mapper.ProductionOrderRoutingOperationParamMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.ProductionOperationTask; |
| | | import com.ruoyi.production.pojo.ProductionOrderRoutingOperation; |
| | | import com.ruoyi.production.pojo.ProductionOrderRoutingOperationParam; |
| | | import com.ruoyi.production.pojo.ProductionProductMain; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.util.TaskPlanQuantityUtil; |
| | | import com.ruoyi.technology.mapper.*; |
| | | import com.ruoyi.production.pojo.*; |
| | | import com.ruoyi.production.service.ProductionOrderRoutingOperationService; |
| | | import com.ruoyi.production.service.ProductionProductMainService; |
| | | import com.ruoyi.technology.mapper.TechnologyOperationParamMapper; |
| | | import com.ruoyi.technology.mapper.TechnologyParamMapper; |
| | | import com.ruoyi.technology.pojo.TechnologyOperationParam; |
| | | import com.ruoyi.technology.pojo.TechnologyParam; |
| | | import com.ruoyi.technology.pojo.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | private final TechnologyOperationParamMapper technologyOperationParamMapper; |
| | | private final TechnologyParamMapper technologyParamMapper; |
| | | private final ProductionOrderRoutingOperationParamMapper productionOrderRoutingOperationParamMapper; |
| | | private final ProductionOrderMapper productionOrderMapper; |
| | | private final ProductionOrderRoutingMapper productionOrderRoutingMapper; |
| | | private final ProductionOrderBomMapper productionOrderBomMapper; |
| | | private final ProductionBomStructureMapper productionBomStructureMapper; |
| | | private final TechnologyRoutingOperationMapper technologyRoutingOperationMapper; |
| | | |
| | | @Override |
| | | public R addRouteItem(ProductionOrderRoutingOperation productionOrderRoutingOperation) { |
| | |
| | | productionOperationTaskMapper.insert(productionOperationTask); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R updateRouteItem(ProductionOrderRoutingOperation productionOrderRoutingOperation) { |
| | | Long operationId = productionOrderRoutingOperation.getId(); |
| | | |
| | | // æ´æ°å·¥èºè·¯çº¿å·¥åº |
| | | productionOrderRoutingOperationMapper.updateById(productionOrderRoutingOperation); |
| | | |
| | | // éæ°æ¥è¯¢å®æ´è®°å½ï¼å端å¯è½æ²¡æä¼ éææåæ®µï¼å¦ productionOrderIdï¼ |
| | | ProductionOrderRoutingOperation updatedOperation = productionOrderRoutingOperationMapper.selectById(operationId); |
| | | if (updatedOperation == null) { |
| | | throw new ServiceException("å·¥èºè·¯çº¿å·¥åºä¸åå¨"); |
| | | } |
| | | |
| | | // æ¥è¯¢æ¯å¦åå¨å·¥å |
| | | ProductionOperationTask productionOperationTask = productionOperationTaskMapper.selectOne( |
| | | new LambdaQueryWrapper<ProductionOperationTask>() |
| | | .eq(ProductionOperationTask::getProductionOrderRoutingOperationId, operationId) |
| | | .last("limit 1")); |
| | | |
| | | // æ ¹æ®æ¯å¦éè¦ç产è¿è¡å¤ç |
| | | Boolean isProduction = updatedOperation.getIsProduction(); |
| | | |
| | | if (Boolean.TRUE.equals(isProduction)) { |
| | | // éè¦çäº§ï¼æ£æ¥å·¥åæ¯å¦åå¨ï¼ä¸åå¨åçæ |
| | | if (productionOperationTask == null) { |
| | | ProductionOperationTask task = new ProductionOperationTask(); |
| | | task.setProductionOrderRoutingOperationId(updatedOperation.getId()); |
| | | task.setProductionOrderId(updatedOperation.getProductionOrderId()); |
| | | // è·åç产订å |
| | | ProductionOrder productionOrder = productionOrderMapper.selectById(updatedOperation.getProductionOrderId()); |
| | | if (productionOrder == null) { |
| | | throw new ServiceException("ç产订åä¸åå¨"); |
| | | } |
| | | |
| | | // è·å订åBOM |
| | | ProductionOrderBom orderBom = productionOrderBomMapper.selectOne( |
| | | Wrappers.<ProductionOrderBom>lambdaQuery() |
| | | .eq(ProductionOrderBom::getProductionOrderId, productionOrder.getId())); |
| | | |
| | | // ç¡®å®æ ¹äº§åè§æ ¼ID |
| | | Long rootProductModelId = orderBom != null && orderBom.getProductModelId() != null |
| | | ? orderBom.getProductModelId() |
| | | : productionOrder.getProductModelId(); |
| | | |
| | | // è·åBOMç»æå表 |
| | | List<ProductionBomStructure> orderBomStructureList = orderBom == null || orderBom.getId() == null |
| | | ? Collections.emptyList() |
| | | : productionBomStructureMapper.selectList( |
| | | Wrappers.<ProductionBomStructure>lambdaQuery() |
| | | .eq(ProductionBomStructure::getProductionOrderBomId, orderBom.getId()) |
| | | .orderByAsc(ProductionBomStructure::getId)); |
| | | |
| | | // æå»ºå·¥åºéæ±éæ å° |
| | | Map<String, BigDecimal> operationDemandedQuantityMap = |
| | | TaskPlanQuantityUtil.buildOperationDemandedQuantityMap(orderBomStructureList, rootProductModelId); |
| | | |
| | | // è·åå·¥èºè·¯çº¿å·¥åºï¼ç¨äºè®¡ç®è®¡åæ°éï¼ |
| | | TechnologyRoutingOperation sourceOperation = technologyRoutingOperationMapper.selectById( |
| | | updatedOperation.getTechnologyRoutingOperationId()); |
| | | // å°åæ¥çç§ææ¹æ³æ¿æ¢ä¸ºè°ç¨å·¥å
·ç±» |
| | | BigDecimal planQuantity = TaskPlanQuantityUtil.resolveTaskPlanQuantity( |
| | | sourceOperation, |
| | | operationDemandedQuantityMap, |
| | | productionOrder, |
| | | rootProductModelId); |
| | | task.setPlanQuantity(planQuantity); |
| | | task.setCompleteQuantity(BigDecimal.ZERO); |
| | | task.setWorkOrderNo(generateNextTaskNo()); |
| | | task.setStatus(2); |
| | | productionOperationTaskMapper.insert(task); |
| | | } |
| | | } else { |
| | | // ä¸éè¦çäº§ï¼æ£æ¥å·¥åæ¯å¦åå¨ |
| | | if (productionOperationTask != null) { |
| | | validateTaskCanRemove(productionOperationTask); |
| | | // æ²¡ææ¥å·¥ï¼åå é¤å·¥å |
| | | productionOperationTaskMapper.deleteById(productionOperationTask.getId()); |
| | | } |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | private void validateTaskCanRemove(ProductionOperationTask task) { |
| | | if (task == null || task.getId() == null) { |
| | | return; |
| | | } |
| | | if (defaultDecimal(task.getCompleteQuantity()).compareTo(BigDecimal.ZERO) > 0) { |
| | | throw new ServiceException("å·¥åºå·²äº§çæ¥å·¥è®°å½ï¼æ æ³æ ¹æ® BOM åæ´å é¤å¯¹åºå·¥åºå¿«ç
§"); |
| | | } |
| | | long reportCount = productionProductMainMapper.selectCount( |
| | | Wrappers.<ProductionProductMain>lambdaQuery() |
| | | .eq(ProductionProductMain::getProductionOperationTaskId, task.getId())); |
| | | if (reportCount > 0) { |
| | | throw new ServiceException("å·¥åºå·²äº§çæ¥å·¥è®°å½ï¼æ æ³æ ¹æ® BOM åæ´å é¤å¯¹åºå·¥å"); |
| | | } |
| | | } |
| | | |
| | | private BigDecimal defaultDecimal(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | private String generateNextTaskNo() { |
| | | // çæä¸ä¸ä¸ªç产工åå· |
| | | String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); |
| | | String prefix = "GD" + datePrefix; |
| | | ProductionOperationTask lastTask = productionOperationTaskMapper.selectOne( |
| | | Wrappers.<ProductionOperationTask>lambdaQuery() |
| | | .likeRight(ProductionOperationTask::getWorkOrderNo, prefix) |
| | | .orderByDesc(ProductionOperationTask::getWorkOrderNo) |
| | | .last("limit 1")); |
| | | int sequence = 1; |
| | | if (lastTask != null && lastTask.getWorkOrderNo() != null && lastTask.getWorkOrderNo().startsWith(prefix)) { |
| | | try { |
| | | sequence = Integer.parseInt(lastTask.getWorkOrderNo().substring(prefix.length())) + 1; |
| | | } catch (NumberFormatException ignored) { |
| | | sequence = 1; |
| | | } |
| | | } |
| | | return prefix + String.format("%03d", sequence); |
| | | } |
| | | } |
| | |
| | | .eq(TechnologyRoutingOperation::getTechnologyRoutingId, technologyRouting.getId()) |
| | | .orderByDesc(TechnologyRoutingOperation::getDragSort) |
| | | .orderByDesc(TechnologyRoutingOperation::getId)); |
| | | // Build task plan quantities from order BOM snapshot demand instead of recomputing from technology BOM units. |
| | | Long rootProductModelId = orderBom != null && orderBom.getProductModelId() != null |
| | | ? orderBom.getProductModelId() |
| | | : productionOrder.getProductModelId(); |
| | | List<ProductionBomStructure> orderBomStructureList = orderBom == null || orderBom.getId() == null |
| | | ? Collections.emptyList() |
| | | : productionBomStructureMapper.selectList( |
| | | Wrappers.<ProductionBomStructure>lambdaQuery() |
| | | .eq(ProductionBomStructure::getProductionOrderBomId, orderBom.getId()) |
| | | .orderByAsc(ProductionBomStructure::getId)); |
| | | Map<String, BigDecimal> operationDemandedQuantityMap = |
| | | buildOperationDemandedQuantityMap(orderBomStructureList, rootProductModelId); |
| | | Map<Long, String> operationNameMap = technologyOperationMapper.selectBatchIds( |
| | | // éåå¤çæ°æ®å¹¶ç»è£
ç»æ |
| | | routingOperations.stream() |
| | |
| | | ProductionOperationTask task = new ProductionOperationTask(); |
| | | task.setProductionOrderRoutingOperationId(targetOperation.getId()); |
| | | task.setProductionOrderId(productionOrder.getId()); |
| | | task.setPlanQuantity(defaultDecimal(productionOrder.getQuantity())); |
| | | task.setPlanQuantity(resolveTaskPlanQuantity( |
| | | sourceOperation, |
| | | operationDemandedQuantityMap, |
| | | productionOrder, |
| | | rootProductModelId)); |
| | | task.setCompleteQuantity(BigDecimal.ZERO); |
| | | task.setWorkOrderNo(generateNextTaskNo()); |
| | | task.setStatus(2); |
| | |
| | | return syncedParamCount; |
| | | } |
| | | |
| | | private Map<String, BigDecimal> buildOperationDemandedQuantityMap(List<ProductionBomStructure> bomStructures, |
| | | Long rootProductModelId) { |
| | | if (bomStructures == null || bomStructures.isEmpty()) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | Map<Long, ProductionBomStructure> structureById = bomStructures.stream() |
| | | .filter(item -> item != null && item.getId() != null) |
| | | .collect(Collectors.toMap(ProductionBomStructure::getId, item -> item, (left, right) -> left)); |
| | | Map<String, BigDecimal> demandedQuantityMap = new HashMap<>(); |
| | | Set<String> mergedOutputNodeKeySet = new HashSet<>(); |
| | | for (ProductionBomStructure bomStructure : bomStructures) { |
| | | if (bomStructure == null || bomStructure.getTechnologyOperationId() == null) { |
| | | continue; |
| | | } |
| | | // The BOM row points to the producing operation; task quantity should come from that operation's output node. |
| | | ProductionBomStructure outputNode = resolveOperationOutputNode(bomStructure, structureById); |
| | | Long outputProductModelId = resolveOutputProductModelId(outputNode, rootProductModelId); |
| | | if (outputProductModelId == null) { |
| | | continue; |
| | | } |
| | | String mergedOutputNodeKey = buildOperationOutputNodeKey( |
| | | bomStructure.getTechnologyOperationId(), |
| | | outputNode == null ? null : outputNode.getId(), |
| | | outputProductModelId); |
| | | if (!mergedOutputNodeKeySet.add(mergedOutputNodeKey)) { |
| | | continue; |
| | | } |
| | | // demandedQuantity is already the order-level required output quantity for the current output node. |
| | | BigDecimal demandedQuantity = defaultDecimal(outputNode == null ? null : outputNode.getDemandedQuantity()); |
| | | String key = buildOperationDemandedQuantityKey(bomStructure.getTechnologyOperationId(), outputProductModelId); |
| | | demandedQuantityMap.merge(key, demandedQuantity, BigDecimal::add); |
| | | } |
| | | return demandedQuantityMap; |
| | | } |
| | | |
| | | private BigDecimal resolveTaskPlanQuantity(TechnologyRoutingOperation sourceOperation, |
| | | Map<String, BigDecimal> operationDemandedQuantityMap, |
| | | ProductionOrder productionOrder, |
| | | Long rootProductModelId) { |
| | | if (sourceOperation == null || operationDemandedQuantityMap == null || operationDemandedQuantityMap.isEmpty()) { |
| | | return defaultDecimal(productionOrder == null ? null : productionOrder.getQuantity()); |
| | | } |
| | | Long outputProductModelId = sourceOperation.getProductModelId() != null |
| | | ? sourceOperation.getProductModelId() |
| | | : rootProductModelId; |
| | | String key = buildOperationDemandedQuantityKey(sourceOperation.getTechnologyOperationId(), outputProductModelId); |
| | | BigDecimal planQuantity = operationDemandedQuantityMap.get(key); |
| | | return planQuantity != null ? planQuantity : defaultDecimal(productionOrder == null ? null : productionOrder.getQuantity()); |
| | | } |
| | | |
| | | private String buildOperationDemandedQuantityKey(Long operationId, Long outputProductModelId) { |
| | | return String.valueOf(operationId) + "#" + String.valueOf(outputProductModelId); |
| | | } |
| | | |
| | | private String buildOperationOutputNodeKey(Long operationId, Long outputNodeId, Long outputProductModelId) { |
| | | return String.valueOf(operationId) + "#" + String.valueOf(outputNodeId) + "#" + String.valueOf(outputProductModelId); |
| | | } |
| | | |
| | | private ProductionBomStructure resolveOperationOutputNode(ProductionBomStructure bomStructure, |
| | | Map<Long, ProductionBomStructure> structureById) { |
| | | if (bomStructure == null) { |
| | | return null; |
| | | } |
| | | // The root node is the first output node; child rows use their direct parent as the current operation output. |
| | | if (bomStructure.getParentId() == null) { |
| | | return bomStructure; |
| | | } |
| | | ProductionBomStructure parent = structureById.get(bomStructure.getParentId()); |
| | | return parent != null ? parent : bomStructure; |
| | | } |
| | | |
| | | private Long resolveOutputProductModelId(ProductionBomStructure outputNode, |
| | | Long rootProductModelId) { |
| | | if (outputNode == null) { |
| | | return rootProductModelId; |
| | | } |
| | | return outputNode.getProductModelId() != null ? outputNode.getProductModelId() : rootProductModelId; |
| | | } |
| | | |
| | | private ProductionOrderBom syncProductionOrderBomSnapshot(ProductionOrder productionOrder, TechnologyRouting technologyRouting) { |
| | | // åæ¥è®¢åBOMå¿«ç
§ç»æ |
| | | if (technologyRouting.getBomId() == null) { |
| | |
| | | productionOrderBomMapper.insert(orderBom); |
| | | |
| | | Map<Long, Long> idMap = new HashMap<>(); |
| | | BigDecimal lastProcessDemandedQuantity = orderQuantity; |
| | | for (TechnologyBomStructure source : structureList) { |
| | | // åèç¹ parentId éè¦æ å°ææ°å¿«ç
§èç¹ idï¼æè½ä¿çåå§ BOM å±çº§ã |
| | | ProductionBomStructure target = new ProductionBomStructure(); |
| | |
| | | target.setProductModelId(source.getProductModelId()); |
| | | target.setTechnologyOperationId(source.getOperationId()); |
| | | target.setUnitQuantity(source.getUnitQuantity()); |
| | | target.setDemandedQuantity(source.getUnitQuantity().multiply(orderQuantity)); |
| | | target.setDemandedQuantity(lastProcessDemandedQuantity.multiply(source.getUnitQuantity())); |
| | | target.setUnit(source.getUnit()); |
| | | productionBomStructureMapper.insert(target); |
| | | idMap.put(source.getId(), target.getId()); |
| | | lastProcessDemandedQuantity = target.getDemandedQuantity(); |
| | | } |
| | | return orderBom; |
| | | } |
| | |
| | | if (reportOutput == null) { |
| | | continue; |
| | | } |
| | | Long reportMainId = reportOutput.getProductionProductMainId() != null |
| | | ? reportOutput.getProductionProductMainId() |
| | | : reportOutput.getProductMainId(); |
| | | if (reportMainId == null) { |
| | | if (reportOutput.getProductionProductMainId() == null) { |
| | | continue; |
| | | } |
| | | Long reportMainId = reportOutput.getProductionProductMainId(); |
| | | reportOutputMap.computeIfAbsent(reportMainId, k -> new ArrayList<>()).add(reportOutput); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.quality.mapper.*; |
| | | import com.ruoyi.quality.pojo.*; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.service.StockInventoryService; |
| | | import com.ruoyi.technology.mapper.TechnologyOperationMapper; |
| | |
| | | private final TechnologyRoutingOperationMapper technologyRoutingOperationMapper; |
| | | private final TechnologyOperationMapper technologyOperationMapper; |
| | | private final StockUtils stockUtils; |
| | | private final StockInRecordService stockInRecordService; |
| | | private final StockInventoryService stockInventoryService; |
| | | |
| | | @Override |
| | |
| | | // å½åå®ç°æå·¥åºæåç´æ¥ä½ä¸ºæå
¥ï¼åç»è¥æ¥å
¥é¢æè®°å½å¯å¨è¿éæ¿æ¢æ¥æºã |
| | | ProductionProductInput productionProductInput = new ProductionProductInput(); |
| | | productionProductInput.setProductionProductMainId(productionProductMain.getId()); |
| | | productionProductInput.setProductMainId(productionProductMain.getId()); |
| | | productionProductInput.setProductModelId(item.getProductModelId()); |
| | | productionProductInput.setInputQuantity(item.getUnitQuantity().multiply(defaultDecimal(dto.getQuantity()))); |
| | | productionProductInput.setQuantity(productionProductInput.getInputQuantity()); |
| | |
| | | |
| | | ProductionProductOutput productionProductOutput = new ProductionProductOutput(); |
| | | productionProductOutput.setProductionProductMainId(productionProductMain.getId()); |
| | | productionProductOutput.setProductMainId(productionProductMain.getId()); |
| | | productionProductOutput.setProductModelId(productModel.getId()); |
| | | productionProductOutput.setQuantity(defaultDecimal(dto.getQuantity())); |
| | | productionProductOutput.setScrapQty(defaultDecimal(dto.getScrapQty())); |
| | | productionProductOutputMapper.insert(productionProductOutput); |
| | | BigDecimal reportQty = defaultDecimal(productionProductOutput.getQuantity()); |
| | | BigDecimal scrapQty = defaultDecimal(productionProductOutput.getScrapQty()); |
| | | BigDecimal productQty = reportQty; |
| | | String qualifiedBatchNo = null; |
| | | |
| | | List<ProductionOrderRoutingOperation> routingOperationList = productionOrderRoutingOperationMapper.selectList( |
| | | Wrappers.<ProductionOrderRoutingOperation>lambdaQuery() |
| | |
| | | stockInventoryDto.setQualitity(productQty); |
| | | stockInventoryDto.setProductModelId(productModel.getId()); |
| | | stockInventoryService.addStockInRecordOnly(stockInventoryDto); |
| | | qualifiedBatchNo = resolveLatestStockInBatchNo( |
| | | productionProductMain.getId(), |
| | | StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), |
| | | productModel.getId(), |
| | | "0"); |
| | | } |
| | | |
| | | productionOperationTask.setCompleteQuantity(defaultDecimal(productionOperationTask.getCompleteQuantity()).add(productQty)); |
| | |
| | | productionAccount.setSchedulingUserId(user == null ? null : user.getUserId()); |
| | | productionAccount.setSchedulingUserName(user == null ? dto.getUserName() : user.getNickName()); |
| | | productionAccount.setFinishedNum(productQty); |
| | | productionAccount.setWorkHours(workHours); |
| | | productionAccount.setWorkHours(technologyOperation != null ? technologyOperation.getSalaryQuota() : null); |
| | | productionAccount.setTechnologyOperationName(technologyOperation == null ? null : technologyOperation.getName()); |
| | | productionAccount.setSchedulingDate(LocalDateTime.now()); |
| | | productionAccountMapper.insert(productionAccount); |
| | | } |
| | | if (scrapQty.compareTo(BigDecimal.ZERO) > 0) { |
| | | stockUtils.addUnStockWithBatchNo( |
| | | productModel.getId(), |
| | | scrapQty, |
| | | StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode(), |
| | | productionProductMain.getId(), |
| | | qualifiedBatchNo); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private String resolveLatestStockInBatchNo(Long recordId, |
| | | String recordType, |
| | | Long productModelId, |
| | | String stockType) { |
| | | if (recordId == null || productModelId == null) { |
| | | return null; |
| | | } |
| | | StockInRecord stockInRecord = stockInRecordService.getOne( |
| | | Wrappers.<StockInRecord>lambdaQuery() |
| | | .eq(StockInRecord::getRecordId, recordId) |
| | | .eq(StockInRecord::getRecordType, recordType) |
| | | .eq(StockInRecord::getProductModelId, productModelId) |
| | | .eq(StockInRecord::getType, stockType) |
| | | .orderByDesc(StockInRecord::getId) |
| | | .last("limit 1"), |
| | | false); |
| | | if (stockInRecord == null) { |
| | | throw new ServiceException("æªæ¾å°å¯¹åºçå
¥åºç³è¯·è®°å½"); |
| | | } |
| | | return stockInRecord.getBatchNo(); |
| | | } |
| | | |
| | | private void syncOperationParamInputValue(ProductionProductMainDto dto, |
| | | Long productionOrderRoutingOperationId, |
| | | Long productionProductMainId) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.util; |
| | | |
| | | import com.ruoyi.production.pojo.ProductionBomStructure; |
| | | import com.ruoyi.production.pojo.ProductionOrder; |
| | | import com.ruoyi.production.pojo.ProductionOrderRoutingOperation; |
| | | import com.ruoyi.technology.pojo.TechnologyRoutingOperation; |
| | | import lombok.experimental.UtilityClass; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * å·¥åè®¡åæ°é计ç®å·¥å
·ç±» |
| | | */ |
| | | @UtilityClass |
| | | public class TaskPlanQuantityUtil { |
| | | |
| | | /** |
| | | * 计ç®å·¥åè®¡åæ°éï¼ä½¿ç¨ TechnologyRoutingOperationï¼ |
| | | */ |
| | | public BigDecimal resolveTaskPlanQuantity(TechnologyRoutingOperation sourceOperation, |
| | | Map<String, BigDecimal> operationDemandedQuantityMap, |
| | | ProductionOrder productionOrder, |
| | | Long rootProductModelId) { |
| | | if (sourceOperation == null || operationDemandedQuantityMap == null || operationDemandedQuantityMap.isEmpty()) { |
| | | return defaultDecimal(productionOrder == null ? null : productionOrder.getQuantity()); |
| | | } |
| | | Long outputProductModelId = sourceOperation.getProductModelId() != null |
| | | ? sourceOperation.getProductModelId() |
| | | : rootProductModelId; |
| | | String key = buildOperationDemandedQuantityKey(sourceOperation.getTechnologyOperationId(), outputProductModelId); |
| | | BigDecimal planQuantity = operationDemandedQuantityMap.get(key); |
| | | return planQuantity != null ? planQuantity : defaultDecimal(productionOrder == null ? null : productionOrder.getQuantity()); |
| | | } |
| | | |
| | | /** |
| | | * 计ç®å·¥åè®¡åæ°éï¼ä½¿ç¨ ProductionOrderRoutingOperationï¼ |
| | | */ |
| | | public BigDecimal resolveTaskPlanQuantity(ProductionOrderRoutingOperation routingOperation, |
| | | Map<String, BigDecimal> demandedQuantityMap, |
| | | BigDecimal orderQuantity, |
| | | Long rootProductModelId) { |
| | | if (routingOperation == null || demandedQuantityMap == null || demandedQuantityMap.isEmpty()) { |
| | | return orderQuantity; |
| | | } |
| | | Long outputProductModelId = routingOperation.getProductModelId() != null |
| | | ? routingOperation.getProductModelId() |
| | | : rootProductModelId; |
| | | String key = buildOperationDemandedQuantityKey(routingOperation.getTechnologyOperationId(), outputProductModelId); |
| | | BigDecimal planQuantity = demandedQuantityMap.get(key); |
| | | return planQuantity != null ? planQuantity : orderQuantity; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå·¥åºéæ±éæ å°è¡¨ |
| | | */ |
| | | public Map<String, BigDecimal> buildOperationDemandedQuantityMap(List<ProductionBomStructure> bomStructures, Long rootProductModelId) { |
| | | if (bomStructures == null || bomStructures.isEmpty()) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | Map<Long, ProductionBomStructure> structureById = new HashMap<>(); |
| | | for (ProductionBomStructure item : bomStructures) { |
| | | if (item != null && item.getId() != null) { |
| | | structureById.put(item.getId(), item); |
| | | } |
| | | } |
| | | Map<String, BigDecimal> demandedQuantityMap = new HashMap<>(); |
| | | Set<String> mergedOutputNodeKeySet = new HashSet<>(); |
| | | for (ProductionBomStructure bomStructure : bomStructures) { |
| | | if (bomStructure == null || bomStructure.getTechnologyOperationId() == null) { |
| | | continue; |
| | | } |
| | | ProductionBomStructure outputNode = resolveOperationOutputNode(bomStructure, structureById); |
| | | Long outputProductModelId = resolveOutputProductModelId(outputNode, rootProductModelId); |
| | | if (outputProductModelId == null) { |
| | | continue; |
| | | } |
| | | String mergedOutputNodeKey = buildOperationOutputNodeKey(bomStructure.getTechnologyOperationId(), |
| | | outputNode == null ? null : outputNode.getId(), outputProductModelId); |
| | | if (!mergedOutputNodeKeySet.add(mergedOutputNodeKey)) { |
| | | continue; |
| | | } |
| | | BigDecimal demandedQuantity = defaultDecimal(outputNode == null ? null : outputNode.getDemandedQuantity()); |
| | | String key = buildOperationDemandedQuantityKey(bomStructure.getTechnologyOperationId(), outputProductModelId); |
| | | demandedQuantityMap.merge(key, demandedQuantity, BigDecimal::add); |
| | | } |
| | | return demandedQuantityMap; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºå·¥åºéæ±ékey |
| | | */ |
| | | public String buildOperationDemandedQuantityKey(Long operationId, Long outputProductModelId) { |
| | | return String.valueOf(operationId) + "#" + String.valueOf(outputProductModelId); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºè¾åºèç¹key |
| | | */ |
| | | public String buildOperationOutputNodeKey(Long operationId, Long outputNodeId, Long outputProductModelId) { |
| | | return String.valueOf(operationId) + "#" + String.valueOf(outputNodeId) + "#" + String.valueOf(outputProductModelId); |
| | | } |
| | | |
| | | /** |
| | | * è§£æå·¥åºè¾åºèç¹ |
| | | */ |
| | | public ProductionBomStructure resolveOperationOutputNode(ProductionBomStructure bomStructure, |
| | | Map<Long, ProductionBomStructure> structureById) { |
| | | if (bomStructure == null) { |
| | | return null; |
| | | } |
| | | if (bomStructure.getParentId() == null) { |
| | | return bomStructure; |
| | | } |
| | | ProductionBomStructure parent = structureById.get(bomStructure.getParentId()); |
| | | return parent != null ? parent : bomStructure; |
| | | } |
| | | |
| | | /** |
| | | * è§£æè¾åºäº§åè§æ ¼ID |
| | | */ |
| | | public Long resolveOutputProductModelId(ProductionBomStructure outputNode, Long rootProductModelId) { |
| | | if (outputNode == null) { |
| | | return rootProductModelId; |
| | | } |
| | | return outputNode.getProductModelId() != null ? outputNode.getProductModelId() : rootProductModelId; |
| | | } |
| | | |
| | | /** |
| | | * é»è®¤BigDecimalå¼ |
| | | */ |
| | | public BigDecimal defaultDecimal(BigDecimal value) { |
| | | return value == null ? BigDecimal.ZERO : value; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.project.common;
|
| | |
|
| | | import com.google.code.kaptcha.Producer;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.utils.sign.Base64;
|
| | | import com.ruoyi.common.utils.uuid.IdUtils;
|
| | | import com.ruoyi.framework.redis.RedisCache;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.system.service.ISysConfigService;
|
| | | import jakarta.annotation.Resource;
|
| | | import jakarta.servlet.http.HttpServletResponse;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.util.FastByteArrayOutputStream;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | |
|
| | | import javax.imageio.ImageIO;
|
| | | import java.awt.image.BufferedImage;
|
| | | import java.io.IOException;
|
| | | import java.util.concurrent.TimeUnit;
|
| | |
|
| | | /**
|
| | | * éªè¯ç æä½å¤ç
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequiredArgsConstructor
|
| | | public class CaptchaController
|
| | | {
|
| | | @Resource(name = "captchaProducer")
|
| | | private Producer captchaProducer;
|
| | |
|
| | | @Resource(name = "captchaProducerMath")
|
| | | private Producer captchaProducerMath;
|
| | |
|
| | | private final RedisCache redisCache;
|
| | | |
| | | // éªè¯ç ç±»å
|
| | | @Value("${ruoyi.captchaType}")
|
| | | private String captchaType;
|
| | | |
| | | private final ISysConfigService configService;
|
| | |
|
| | | /**
|
| | | * çæéªè¯ç
|
| | | */
|
| | | @GetMapping("/captchaImage")
|
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException
|
| | | {
|
| | | AjaxResult ajax = AjaxResult.success();
|
| | | boolean captchaEnabled = configService.selectCaptchaEnabled();
|
| | | ajax.put("captchaEnabled", captchaEnabled);
|
| | | if (!captchaEnabled)
|
| | | {
|
| | | return ajax;
|
| | | }
|
| | |
|
| | | // ä¿åéªè¯ç ä¿¡æ¯
|
| | | String uuid = IdUtils.simpleUUID();
|
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
| | |
|
| | | String capStr = null, code = null;
|
| | | BufferedImage image = null;
|
| | |
|
| | | // çæéªè¯ç
|
| | | if ("math".equals(captchaType))
|
| | | {
|
| | | String capText = captchaProducerMath.createText();
|
| | | capStr = capText.substring(0, capText.lastIndexOf("@"));
|
| | | code = capText.substring(capText.lastIndexOf("@") + 1);
|
| | | image = captchaProducerMath.createImage(capStr);
|
| | | }
|
| | | else if ("char".equals(captchaType))
|
| | | {
|
| | | capStr = code = captchaProducer.createText();
|
| | | image = captchaProducer.createImage(capStr);
|
| | | }
|
| | |
|
| | | redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
| | | // è½¬æ¢æµä¿¡æ¯ååº
|
| | | FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
| | | try
|
| | | {
|
| | | ImageIO.write(image, "jpg", os);
|
| | | }
|
| | | catch (IOException e)
|
| | | {
|
| | | return AjaxResult.error(e.getMessage());
|
| | | }
|
| | |
|
| | | ajax.put("uuid", uuid);
|
| | | ajax.put("img", Base64.encode(os.toByteArray()));
|
| | | return ajax;
|
| | | }
|
| | | }
|
| | | package com.ruoyi.project.common; |
| | | |
| | | import com.google.code.kaptcha.Producer; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.utils.sign.Base64; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.framework.redis.RedisCache; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.project.system.service.ISysConfigService; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.FastByteArrayOutputStream; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * éªè¯ç æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | public class CaptchaController |
| | | { |
| | | @Resource(name = "captchaProducer") |
| | | private Producer captchaProducer; |
| | | |
| | | @Resource(name = "captchaProducerMath") |
| | | private Producer captchaProducerMath; |
| | | |
| | | private final RedisCache redisCache; |
| | | |
| | | // éªè¯ç ç±»å |
| | | @Value("${ruoyi.captchaType}") |
| | | private String captchaType; |
| | | |
| | | private final ISysConfigService configService; |
| | | |
| | | /** |
| | | * çæéªè¯ç |
| | | */ |
| | | @GetMapping("/captchaImage") |
| | | public AjaxResult getCode(HttpServletResponse response) throws IOException |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | boolean captchaEnabled = configService.selectCaptchaEnabled(); |
| | | ajax.put("captchaEnabled", captchaEnabled); |
| | | if (!captchaEnabled) |
| | | { |
| | | return ajax; |
| | | } |
| | | |
| | | // ä¿åéªè¯ç ä¿¡æ¯ |
| | | String uuid = IdUtils.simpleUUID(); |
| | | String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid; |
| | | |
| | | String capStr = null, code = null; |
| | | BufferedImage image = null; |
| | | |
| | | // çæéªè¯ç |
| | | if ("math".equals(captchaType)) |
| | | { |
| | | String capText = captchaProducerMath.createText(); |
| | | capStr = capText.substring(0, capText.lastIndexOf("@")); |
| | | code = capText.substring(capText.lastIndexOf("@") + 1); |
| | | image = captchaProducerMath.createImage(capStr); |
| | | } |
| | | else if ("char".equals(captchaType)) |
| | | { |
| | | capStr = code = captchaProducer.createText(); |
| | | image = captchaProducer.createImage(capStr); |
| | | } |
| | | |
| | | redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES); |
| | | // è½¬æ¢æµä¿¡æ¯ååº |
| | | FastByteArrayOutputStream os = new FastByteArrayOutputStream(); |
| | | try |
| | | { |
| | | ImageIO.write(image, "jpg", os); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", Base64.encode(os.toByteArray())); |
| | | return ajax; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | |
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.project.monitor.domain.SysCache;
|
| | | import lombok.AllArgsConstructor;
|
| | | import org.springframework.data.redis.core.RedisCallback;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import java.util.*;
|
| | |
|
| | | /**
|
| | | * ç¼åçæ§
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/monitor/cache")
|
| | | @AllArgsConstructor
|
| | | public class CacheController
|
| | | {
|
| | | private RedisTemplate<String, String> redisTemplate;
|
| | |
|
| | | private final static List<SysCache> caches = new ArrayList<SysCache>();
|
| | | {
|
| | | caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "ç¨æ·ä¿¡æ¯"));
|
| | | caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "é
置信æ¯"));
|
| | | caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "æ°æ®åå
¸"));
|
| | | caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "éªè¯ç "));
|
| | | caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "é²éæäº¤"));
|
| | | caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "éæµå¤ç"));
|
| | | caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "å¯ç é误次æ°"));
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping()
|
| | | public AjaxResult getInfo() throws Exception
|
| | | {
|
| | | Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
|
| | | Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
|
| | | Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
|
| | |
|
| | | Map<String, Object> result = new HashMap<>(3);
|
| | | result.put("info", info);
|
| | | result.put("dbSize", dbSize);
|
| | |
|
| | | List<Map<String, String>> pieList = new ArrayList<>();
|
| | | commandStats.stringPropertyNames().forEach(key -> {
|
| | | Map<String, String> data = new HashMap<>(2);
|
| | | String property = commandStats.getProperty(key);
|
| | | data.put("name", StringUtils.removeStart(key, "cmdstat_"));
|
| | | data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
|
| | | pieList.add(data);
|
| | | });
|
| | | result.put("commandStats", pieList);
|
| | | return AjaxResult.success(result);
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping("/getNames")
|
| | | public AjaxResult cache()
|
| | | {
|
| | | return AjaxResult.success(caches);
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping("/getKeys/{cacheName}")
|
| | | public AjaxResult getCacheKeys(@PathVariable String cacheName)
|
| | | {
|
| | | Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
| | | return AjaxResult.success(new TreeSet<>(cacheKeys));
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @GetMapping("/getValue/{cacheName}/{cacheKey}")
|
| | | public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
|
| | | {
|
| | | String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
| | | SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
|
| | | return AjaxResult.success(sysCache);
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @DeleteMapping("/clearCacheName/{cacheName}")
|
| | | public AjaxResult clearCacheName(@PathVariable String cacheName)
|
| | | {
|
| | | Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
|
| | | redisTemplate.delete(cacheKeys);
|
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @DeleteMapping("/clearCacheKey/{cacheKey}")
|
| | | public AjaxResult clearCacheKey(@PathVariable String cacheKey)
|
| | | {
|
| | | redisTemplate.delete(cacheKey);
|
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
|
| | | @DeleteMapping("/clearCacheAll")
|
| | | public AjaxResult clearCacheAll()
|
| | | {
|
| | | Collection<String> cacheKeys = redisTemplate.keys("*");
|
| | | redisTemplate.delete(cacheKeys);
|
| | | return AjaxResult.success();
|
| | | }
|
| | | }
|
| | | package com.ruoyi.project.monitor.controller; |
| | | |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.project.monitor.domain.SysCache; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.data.redis.core.RedisCallback; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * ç¼åçæ§ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/cache") |
| | | @AllArgsConstructor |
| | | public class CacheController |
| | | { |
| | | private RedisTemplate<String, String> redisTemplate; |
| | | |
| | | private final static List<SysCache> caches = new ArrayList<SysCache>(); |
| | | { |
| | | caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "ç¨æ·ä¿¡æ¯")); |
| | | caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "é
置信æ¯")); |
| | | caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "æ°æ®åå
¸")); |
| | | caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "éªè¯ç ")); |
| | | caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "é²éæäº¤")); |
| | | caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "éæµå¤ç")); |
| | | caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "å¯ç é误次æ°")); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping() |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info()); |
| | | Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats")); |
| | | Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize()); |
| | | |
| | | Map<String, Object> result = new HashMap<>(3); |
| | | result.put("info", info); |
| | | result.put("dbSize", dbSize); |
| | | |
| | | List<Map<String, String>> pieList = new ArrayList<>(); |
| | | commandStats.stringPropertyNames().forEach(key -> { |
| | | Map<String, String> data = new HashMap<>(2); |
| | | String property = commandStats.getProperty(key); |
| | | data.put("name", StringUtils.removeStart(key, "cmdstat_")); |
| | | data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); |
| | | pieList.add(data); |
| | | }); |
| | | result.put("commandStats", pieList); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getNames") |
| | | public AjaxResult cache() |
| | | { |
| | | return AjaxResult.success(caches); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getKeys/{cacheName}") |
| | | public AjaxResult getCacheKeys(@PathVariable String cacheName) |
| | | { |
| | | Set<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | return AjaxResult.success(new TreeSet<>(cacheKeys)); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @GetMapping("/getValue/{cacheName}/{cacheKey}") |
| | | public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey) |
| | | { |
| | | String cacheValue = redisTemplate.opsForValue().get(cacheKey); |
| | | SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue); |
| | | return AjaxResult.success(sysCache); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheName/{cacheName}") |
| | | public AjaxResult clearCacheName(@PathVariable String cacheName) |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheKey/{cacheKey}") |
| | | public AjaxResult clearCacheKey(@PathVariable String cacheKey) |
| | | { |
| | | redisTemplate.delete(cacheKey); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") |
| | | @DeleteMapping("/clearCacheAll") |
| | | public AjaxResult clearCacheAll() |
| | | { |
| | | Collection<String> cacheKeys = redisTemplate.keys("*"); |
| | | redisTemplate.delete(cacheKeys); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | |
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.domain.Server;
|
| | |
|
| | | /**
|
| | | * æå¡å¨çæ§
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/monitor/server")
|
| | | public class ServerController
|
| | | {
|
| | | @PreAuthorize("@ss.hasPermi('monitor:server:list')")
|
| | | @GetMapping()
|
| | | public AjaxResult getInfo() throws Exception
|
| | | {
|
| | | Server server = new Server();
|
| | | server.copyTo();
|
| | | return AjaxResult.success(server);
|
| | | }
|
| | | }
|
| | | package com.ruoyi.project.monitor.controller; |
| | | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.Server; |
| | | |
| | | /** |
| | | * æå¡å¨çæ§ |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/server") |
| | | public class ServerController |
| | | { |
| | | @PreAuthorize("@ss.hasPermi('monitor:server:list')") |
| | | @GetMapping() |
| | | public AjaxResult getInfo() throws Exception |
| | | { |
| | | Server server = new Server(); |
| | | server.copyTo(); |
| | | return AjaxResult.success(server); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.project.monitor.controller;
|
| | |
|
| | | import java.util.List;
|
| | | import jakarta.servlet.http.HttpServletResponse;
|
| | | import lombok.AllArgsConstructor;
|
| | | import org.quartz.SchedulerException;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.security.access.prepost.PreAuthorize;
|
| | | import org.springframework.web.bind.annotation.DeleteMapping;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.PutMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.exception.job.TaskException;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.job.CronUtils;
|
| | | import com.ruoyi.common.utils.job.ScheduleUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.monitor.domain.SysJob;
|
| | | import com.ruoyi.project.monitor.service.ISysJobService;
|
| | |
|
| | | /**
|
| | | * è°åº¦ä»»å¡ä¿¡æ¯æä½å¤ç
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("/monitor/job")
|
| | | @AllArgsConstructor
|
| | | public class SysJobController extends BaseController
|
| | | {
|
| | | private ISysJobService jobService;
|
| | |
|
| | | /**
|
| | | * æ¥è¯¢å®æ¶ä»»å¡å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(SysJob sysJob)
|
| | | {
|
| | | startPage();
|
| | | List<SysJob> list = jobService.selectJobList(sysJob);
|
| | | return getDataTable(list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 导åºå®æ¶ä»»å¡å表
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.EXPORT)
|
| | | @PostMapping("/export")
|
| | | public void export(HttpServletResponse response, SysJob sysJob)
|
| | | {
|
| | | List<SysJob> list = jobService.selectJobList(sysJob);
|
| | | ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
|
| | | util.exportExcel(response, list, "宿¶ä»»å¡");
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·å宿¶ä»»å¡è¯¦ç»ä¿¡æ¯
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
| | | @GetMapping(value = "/{jobId}")
|
| | | public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
|
| | | {
|
| | | return success(jobService.selectJobById(jobId));
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ°å¢å®æ¶ä»»å¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.INSERT)
|
| | | @PostMapping
|
| | | public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException
|
| | | {
|
| | | if (!CronUtils.isValid(job.getCronExpression()))
|
| | | {
|
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®");
|
| | | }
|
| | | else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
| | | {
|
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi'è°ç¨");
|
| | | }
|
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS }))
|
| | | {
|
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'ldap(s)'è°ç¨");
|
| | | }
|
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
| | | {
|
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'http(s)'è°ç¨");
|
| | | }
|
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
| | | {
|
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串åå¨è¿è§");
|
| | | }
|
| | | else if (!ScheduleUtils.whiteList(job.getInvokeTarget()))
|
| | | {
|
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å¨ç½ååå
");
|
| | | }
|
| | | job.setCreateBy(getUsername());
|
| | | return toAjax(jobService.insertJob(job));
|
| | | }
|
| | |
|
| | | /**
|
| | | * ä¿®æ¹å®æ¶ä»»å¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException
|
| | | {
|
| | | if (!CronUtils.isValid(job.getCronExpression()))
|
| | | {
|
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®");
|
| | | }
|
| | | else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
| | | {
|
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi'è°ç¨");
|
| | | }
|
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS }))
|
| | | {
|
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'ldap(s)'è°ç¨");
|
| | | }
|
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
| | | {
|
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'http(s)'è°ç¨");
|
| | | }
|
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
| | | {
|
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串åå¨è¿è§");
|
| | | }
|
| | | else if (!ScheduleUtils.whiteList(job.getInvokeTarget()))
|
| | | {
|
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å¨ç½ååå
");
|
| | | }
|
| | | job.setUpdateBy(getUsername());
|
| | | return toAjax(jobService.updateJob(job));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡ç¶æä¿®æ¹
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/changeStatus")
|
| | | public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException
|
| | | {
|
| | | SysJob newJob = jobService.selectJobById(job.getJobId());
|
| | | newJob.setStatus(job.getStatus());
|
| | | return toAjax(jobService.changeStatus(newJob));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 宿¶ä»»å¡ç«å³æ§è¡ä¸æ¬¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/run")
|
| | | public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
|
| | | {
|
| | | boolean result = jobService.run(job);
|
| | | return result ? success() : error("ä»»å¡ä¸åå¨æå·²è¿æï¼");
|
| | | }
|
| | |
|
| | | /**
|
| | | * å é¤å®æ¶ä»»å¡
|
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{jobIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException
|
| | | {
|
| | | jobService.deleteJobByIds(jobIds);
|
| | | return success();
|
| | | }
|
| | | }
|
| | | package com.ruoyi.project.monitor.controller; |
| | | |
| | | import java.util.List; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.exception.job.TaskException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.job.CronUtils; |
| | | import com.ruoyi.common.utils.job.ScheduleUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.page.TableDataInfo; |
| | | import com.ruoyi.project.monitor.domain.SysJob; |
| | | import com.ruoyi.project.monitor.service.ISysJobService; |
| | | |
| | | /** |
| | | * è°åº¦ä»»å¡ä¿¡æ¯æä½å¤ç |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/monitor/job") |
| | | @AllArgsConstructor |
| | | public class SysJobController extends BaseController |
| | | { |
| | | private ISysJobService jobService; |
| | | |
| | | /** |
| | | * æ¥è¯¢å®æ¶ä»»å¡å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysJob sysJob) |
| | | { |
| | | startPage(); |
| | | List<SysJob> list = jobService.selectJobList(sysJob); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 导åºå®æ¶ä»»å¡å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:export')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysJob sysJob) |
| | | { |
| | | List<SysJob> list = jobService.selectJobList(sysJob); |
| | | ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class); |
| | | util.exportExcel(response, list, "宿¶ä»»å¡"); |
| | | } |
| | | |
| | | /** |
| | | * è·å宿¶ä»»å¡è¯¦ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:query')") |
| | | @GetMapping(value = "/{jobId}") |
| | | public AjaxResult getInfo(@PathVariable("jobId") Long jobId) |
| | | { |
| | | return success(jobService.selectJobById(jobId)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢å®æ¶ä»»å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:add')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®"); |
| | | } |
| | | else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) |
| | | { |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi'è°ç¨"); |
| | | } |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS })) |
| | | { |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'ldap(s)'è°ç¨"); |
| | | } |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) |
| | | { |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'http(s)'è°ç¨"); |
| | | } |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) |
| | | { |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串åå¨è¿è§"); |
| | | } |
| | | else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) |
| | | { |
| | | return error("æ°å¢ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å¨ç½ååå
"); |
| | | } |
| | | job.setCreateBy(getUsername()); |
| | | return toAjax(jobService.insertJob(job)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹å®æ¶ä»»å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:edit')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException |
| | | { |
| | | if (!CronUtils.isValid(job.getCronExpression())) |
| | | { |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼Cron表达å¼ä¸æ£ç¡®"); |
| | | } |
| | | else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) |
| | | { |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'rmi'è°ç¨"); |
| | | } |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS })) |
| | | { |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'ldap(s)'è°ç¨"); |
| | | } |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) |
| | | { |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å
许'http(s)'è°ç¨"); |
| | | } |
| | | else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR)) |
| | | { |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串åå¨è¿è§"); |
| | | } |
| | | else if (!ScheduleUtils.whiteList(job.getInvokeTarget())) |
| | | { |
| | | return error("ä¿®æ¹ä»»å¡'" + job.getJobName() + "'失败ï¼ç®æ å符串ä¸å¨ç½ååå
"); |
| | | } |
| | | job.setUpdateBy(getUsername()); |
| | | return toAjax(jobService.updateJob(job)); |
| | | } |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡ç¶æä¿®æ¹ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | SysJob newJob = jobService.selectJobById(job.getJobId()); |
| | | newJob.setStatus(job.getStatus()); |
| | | return toAjax(jobService.changeStatus(newJob)); |
| | | } |
| | | |
| | | /** |
| | | * 宿¶ä»»å¡ç«å³æ§è¡ä¸æ¬¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/run") |
| | | public AjaxResult run(@RequestBody SysJob job) throws SchedulerException |
| | | { |
| | | boolean result = jobService.run(job); |
| | | return result ? success() : error("ä»»å¡ä¸åå¨æå·²è¿æï¼"); |
| | | } |
| | | |
| | | /** |
| | | * å é¤å®æ¶ä»»å¡ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('monitor:job:remove')") |
| | | @Log(title = "宿¶ä»»å¡", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{jobIds}") |
| | | public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException |
| | | { |
| | | jobService.deleteJobByIds(jobIds); |
| | | return success(); |
| | | } |
| | | } |
| src/main/java/com/ruoyi/project/monitor/controller/SysJobLogController.java
src/main/java/com/ruoyi/project/monitor/controller/SysLogininforController.java
src/main/java/com/ruoyi/project/monitor/controller/SysOperlogController.java
src/main/java/com/ruoyi/project/monitor/controller/SysUserOnlineController.java
src/main/java/com/ruoyi/project/system/controller/SysConfigController.java
src/main/java/com/ruoyi/project/system/controller/SysDeptController.java
src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java
src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java
src/main/java/com/ruoyi/project/system/controller/SysLoginController.java
src/main/java/com/ruoyi/project/system/controller/SysMenuController.java
src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java
src/main/java/com/ruoyi/project/system/controller/SysPostController.java
src/main/java/com/ruoyi/project/system/controller/SysProfileController.java
src/main/java/com/ruoyi/project/system/controller/SysRegisterController.java
src/main/java/com/ruoyi/project/system/controller/SysRoleController.java
src/main/java/com/ruoyi/project/system/controller/SysUserController.java
src/main/java/com/ruoyi/project/system/service/ISysUserService.java
src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java
src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java
src/main/java/com/ruoyi/projectManagement/service/impl/PlanServiceImpl.java
src/main/java/com/ruoyi/projectManagement/service/impl/handle/InfoStageHandleService.java
src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java
src/main/java/com/ruoyi/purchase/controller/InvoicePurchaseController.java (已删除)
src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java (已删除)
src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
src/main/java/com/ruoyi/purchase/controller/PurchaseReturnOrdersController.java
src/main/java/com/ruoyi/purchase/controller/TicketRegistrationController.java (已删除)
src/main/java/com/ruoyi/purchase/dto/InvoicePurchaseDto.java (已删除)
src/main/java/com/ruoyi/purchase/dto/InvoicePurchaseReportDto.java (已删除)
src/main/java/com/ruoyi/purchase/dto/PaymentRegistrationDto.java (已删除)
src/main/java/com/ruoyi/purchase/dto/ProductRecordDto.java (已删除)
src/main/java/com/ruoyi/purchase/dto/PurchaseLedgerDto.java
src/main/java/com/ruoyi/purchase/dto/PurchaseReturnOrderProductsDto.java
src/main/java/com/ruoyi/purchase/dto/SimpleReturnOrderGroupDto.java
src/main/java/com/ruoyi/purchase/dto/TicketRegistrationDto.java (已删除)
src/main/java/com/ruoyi/purchase/dto/VatDto.java
src/main/java/com/ruoyi/purchase/mapper/InvoicePurchaseMapper.java (已删除)
src/main/java/com/ruoyi/purchase/mapper/PaymentRegistrationMapper.java (已删除)
src/main/java/com/ruoyi/purchase/mapper/ProductRecordMapper.java (已删除)
src/main/java/com/ruoyi/purchase/mapper/PurchaseLedgerMapper.java
src/main/java/com/ruoyi/purchase/mapper/PurchaseReturnOrdersMapper.java
src/main/java/com/ruoyi/purchase/mapper/TicketRegistrationMapper.java (已删除)
src/main/java/com/ruoyi/purchase/pojo/InvoicePurchase.java (已删除)
src/main/java/com/ruoyi/purchase/pojo/PaymentRegistration.java (已删除)
src/main/java/com/ruoyi/purchase/pojo/ProductRecord.java (已删除)
src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java
src/main/java/com/ruoyi/purchase/pojo/PurchaseReturnOrderProducts.java
src/main/java/com/ruoyi/purchase/pojo/SalesLedgerProductTemplate.java
src/main/java/com/ruoyi/purchase/pojo/TicketRegistration.java (已删除)
src/main/java/com/ruoyi/purchase/service/IInvoicePurchaseService.java (已删除)
src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java (已删除)
src/main/java/com/ruoyi/purchase/service/IProductRecordService.java (已删除)
src/main/java/com/ruoyi/purchase/service/IPurchaseLedgerService.java
src/main/java/com/ruoyi/purchase/service/ITicketRegistrationService.java (已删除)
src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java
src/main/java/com/ruoyi/purchase/service/PurchaseReturnOrdersService.java
src/main/java/com/ruoyi/purchase/service/impl/InvoicePurchaseServiceImpl.java (已删除)
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java (已删除)
src/main/java/com/ruoyi/purchase/service/impl/ProductRecordServiceImpl.java (已删除)
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java
src/main/java/com/ruoyi/purchase/service/impl/PurchaseReturnOrdersServiceImpl.java
src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java (已删除)
src/main/java/com/ruoyi/purchase/vo/PurchaseReportVo.java
src/main/java/com/ruoyi/purchase/vo/PurchaseReturnDetailsVo.java
src/main/java/com/ruoyi/purchase/vo/PurchaseReturnOrderProductsDetailVo.java
src/main/java/com/ruoyi/purchase/vo/PurchaseStockInProductVo.java
src/main/java/com/ruoyi/purchase/vo/SupplierTransactionsDetailsVo.java
src/main/java/com/ruoyi/purchase/vo/SupplierTransactionsVo.java
src/main/java/com/ruoyi/quality/controller/QualityInspectController.java
src/main/java/com/ruoyi/quality/controller/QualityInspectParamController.java
src/main/java/com/ruoyi/quality/controller/QualityReportController.java
src/main/java/com/ruoyi/quality/controller/QualityTestStandardBindingController.java
src/main/java/com/ruoyi/quality/controller/QualityTestStandardController.java
src/main/java/com/ruoyi/quality/controller/QualityTestStandardParamController.java
src/main/java/com/ruoyi/quality/controller/QualityUnqualifiedController.java
src/main/java/com/ruoyi/quality/pojo/QualityInspect.java
src/main/java/com/ruoyi/quality/pojo/QualityUnqualified.java
src/main/java/com/ruoyi/quality/service/impl/QualityInspectServiceImpl.java
src/main/java/com/ruoyi/quality/service/impl/QualityUnqualifiedServiceImpl.java
src/main/java/com/ruoyi/sales/controller/InvoiceLedgerController.java (已删除)
src/main/java/com/ruoyi/sales/controller/InvoiceRegistrationController.java (已删除)
src/main/java/com/ruoyi/sales/controller/MetricStatisticsController.java
src/main/java/com/ruoyi/sales/controller/ReceiptPaymentController.java (已删除)
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
src/main/java/com/ruoyi/sales/controller/SalesLedgerProductController.java
src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
src/main/java/com/ruoyi/sales/dto/InvoiceLedgerDto.java (已删除)
src/main/java/com/ruoyi/sales/dto/InvoiceRegistrationDto.java (已删除)
src/main/java/com/ruoyi/sales/dto/InvoiceRegistrationProductDto.java (已删除)
src/main/java/com/ruoyi/sales/dto/ReceiptPaymentDto.java (已删除)
src/main/java/com/ruoyi/sales/dto/ReceiptPaymentExeclDto.java (已删除)
src/main/java/com/ruoyi/sales/dto/ReceiptPaymentRecordDto.java (已删除)
src/main/java/com/ruoyi/sales/dto/SalesLedgerImportDto.java
src/main/java/com/ruoyi/sales/dto/SalesLedgerProductImportDto.java
src/main/java/com/ruoyi/sales/dto/ShippingInfoDto.java
src/main/java/com/ruoyi/sales/excel/InvoiceLedgerExcelDto.java
src/main/java/com/ruoyi/sales/excel/InvoiceRegisAndProductExcelDto.java (已删除)
src/main/java/com/ruoyi/sales/mapper/InvoiceLedgerFileMapper.java (已删除)
src/main/java/com/ruoyi/sales/mapper/InvoiceLedgerMapper.java (已删除)
src/main/java/com/ruoyi/sales/mapper/InvoiceRegistrationMapper.java (已删除)
src/main/java/com/ruoyi/sales/mapper/InvoiceRegistrationProductMapper.java (已删除)
src/main/java/com/ruoyi/sales/mapper/ReceiptPaymentMapper.java (已删除)
src/main/java/com/ruoyi/sales/mapper/SalesLedgerMapper.java
src/main/java/com/ruoyi/sales/mapper/SalesLedgerProductMapper.java
src/main/java/com/ruoyi/sales/mapper/ShippingInfoMapper.java
src/main/java/com/ruoyi/sales/pojo/InvoiceLedger.java (已删除)
src/main/java/com/ruoyi/sales/pojo/InvoiceLedgerFile.java (已删除)
src/main/java/com/ruoyi/sales/pojo/InvoiceRegistration.java (已删除)
src/main/java/com/ruoyi/sales/pojo/InvoiceRegistrationProduct.java (已删除)
src/main/java/com/ruoyi/sales/pojo/ReceiptPayment.java (已删除)
src/main/java/com/ruoyi/sales/pojo/SalesLedger.java
src/main/java/com/ruoyi/sales/pojo/SalesLedgerProduct.java
src/main/java/com/ruoyi/sales/pojo/SalesQuotationProduct.java
src/main/java/com/ruoyi/sales/service/ISalesLedgerProductService.java
src/main/java/com/ruoyi/sales/service/InvoiceLedgerService.java (已删除)
src/main/java/com/ruoyi/sales/service/InvoiceRegistrationService.java (已删除)
src/main/java/com/ruoyi/sales/service/ReceiptPaymentService.java (已删除)
src/main/java/com/ruoyi/sales/service/ShippingInfoService.java
src/main/java/com/ruoyi/sales/service/impl/InvoiceLedgerServiceImpl.java (已删除)
src/main/java/com/ruoyi/sales/service/impl/InvoiceRegistrationServiceImpl.java (已删除)
src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java (已删除)
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
src/main/java/com/ruoyi/sales/vo/CustomerTransactionsDetailsVo.java
src/main/java/com/ruoyi/sales/vo/CustomerTransactionsVo.java
src/main/java/com/ruoyi/staff/service/impl/StaffSalaryMainServiceImpl.java
src/main/java/com/ruoyi/stock/controller/StockInRecordController.java
src/main/java/com/ruoyi/stock/controller/StockInventoryController.java
src/main/java/com/ruoyi/stock/dto/StockInRecordDto.java
src/main/java/com/ruoyi/stock/dto/StockInventoryDto.java
src/main/java/com/ruoyi/stock/dto/StockOutRecordDto.java
src/main/java/com/ruoyi/stock/execl/StockInRecordExportData.java
src/main/java/com/ruoyi/stock/execl/StockInventoryExportData.java
src/main/java/com/ruoyi/stock/execl/StockOutRecordExportData.java
src/main/java/com/ruoyi/stock/execl/StockUnInventoryExportData.java
src/main/java/com/ruoyi/stock/mapper/StockInRecordMapper.java
src/main/java/com/ruoyi/stock/mapper/StockInventoryMapper.java
src/main/java/com/ruoyi/stock/mapper/StockOutRecordMapper.java
src/main/java/com/ruoyi/stock/service/StockInRecordService.java
src/main/java/com/ruoyi/stock/service/StockInventoryService.java
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
src/main/java/com/ruoyi/stock/service/impl/StockOutRecordServiceImpl.java
src/main/java/com/ruoyi/stock/service/impl/StockUninventoryServiceImpl.java
src/main/java/com/ruoyi/technology/service/impl/TechnologyRoutingServiceImpl.java
src/main/java/com/ruoyi/warehouse/controller/DocumentationFileController.java
src/main/java/com/ruoyi/warehouse/mapper/DocumentationFileMapper.java
src/main/java/com/ruoyi/warehouse/mapper/DocumentationMapper.java
src/main/java/com/ruoyi/warehouse/service/DocumentationFileService.java
src/main/resources/application-dev.yml
src/main/resources/approve-todo-agent-prompt.txt
src/main/resources/financial-agent-prompt.txt
src/main/resources/logback.xml
src/main/resources/manufacturing-agent-prompt.txt
src/main/resources/mapper/account/AccountExpenseMapper.xml (已删除)
src/main/resources/mapper/account/AccountFileMapper.xml (已删除)
src/main/resources/mapper/account/AccountIncomeMapper.xml (已删除)
src/main/resources/mapper/account/AccountStatementMapper.xml
src/main/resources/mapper/account/BorrowInfoMapper.xml (已删除)
src/main/resources/mapper/account/financial/AccountSubjectMapper.xml
src/main/resources/mapper/account/purchase/AccountPaymentApplicationMapper.xml
src/main/resources/mapper/account/purchase/AccountPurchaseInvoiceMapper.xml
src/main/resources/mapper/account/purchase/AccountPurchasePaymentMapper.xml
src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
src/main/resources/mapper/account/sales/AccountSalesInvoiceMapper.xml
src/main/resources/mapper/approve/ApproveProcessMapper.xml
src/main/resources/mapper/basic/CustomerMapper.xml
src/main/resources/mapper/basic/ProductModelMapper.xml
src/main/resources/mapper/basic/SupplierManageMapper.xml
src/main/resources/mapper/collaborativeApproval/SealApplicationManagementMapper.xml
src/main/resources/mapper/device/DeviceRepairMapper.xml
src/main/resources/mapper/measuringinstrumentledger/MeasuringInstrumentLedgerMapper.xml
src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml
src/main/resources/mapper/procurementrecord/ProcurementRecordOutMapper.xml
src/main/resources/mapper/procurementrecord/ReturnManagementMapper.xml
src/main/resources/mapper/procurementrecord/ReturnSaleProductMapper.xml
src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
src/main/resources/mapper/production/ProductionOrderMapper.xml
src/main/resources/mapper/purchase/InvoicePurchaseMapper.xml (已删除)
src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml (已删除)
src/main/resources/mapper/purchase/ProductRecordMapper.xml (已删除)
src/main/resources/mapper/purchase/PurchaseLedgerMapper.xml
src/main/resources/mapper/purchase/PurchaseReturnOrderProductsMapper.xml
src/main/resources/mapper/purchase/PurchaseReturnOrdersMapper.xml
src/main/resources/mapper/quality/QualityInspectMapper.xml
src/main/resources/mapper/quality/QualityUnqualifiedMapper.xml
src/main/resources/mapper/sales/InvoiceLedgerMapper.xml (已删除)
src/main/resources/mapper/sales/InvoiceRegistrationMapper.xml (已删除)
src/main/resources/mapper/sales/InvoiceRegistrationProductMapper.xml (已删除)
src/main/resources/mapper/sales/ReceiptPaymentMapper.xml (已删除)
src/main/resources/mapper/sales/SalesLedgerMapper.xml
src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
src/main/resources/mapper/sales/SalesQuotationMapper.xml
src/main/resources/mapper/sales/ShippingInfoMapper.xml
src/main/resources/mapper/stock/StockInRecordMapper.xml
src/main/resources/mapper/stock/StockInventoryMapper.xml
src/main/resources/mapper/stock/StockOutRecordMapper.xml
src/main/resources/purchase-agent-prompt.txt
src/main/resources/sales-agent-prompt.txt
src/main/resources/static/销售台账导入模板.xlsx |