Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro
# Conflicts:
# src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
# src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
已添加12个文件
已重命名1个文件
已修改50个文件
已删除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 龿¥ç´åºã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # éè´å
¥åºç¶æå端èè°ææ¡£ |
| | | æ´æ°æ¶é´ï¼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 'åºå·®ç»ææ¶é´'; |
| ÎļþÃû´Ó 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.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.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)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | |
| | | IPage<StatementAccountVo> listPageAccountStatement(Page page, @Param("req") StatementAccountDto statementAccountDto); |
| | | |
| | | IPage<VatDto> selectVatDtoPage(Page page, @Param("month") String month); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | |
| | | } |
| | |
| | | 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.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 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); // ææ§éé¢ |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | if (containsAny(text, "ææ¬æ ¸ç®", "äº§åææ¬", "å·¥åºææ¬", "äººå·¥ææ¬", "ææ§", "æææè")) { |
| | | return financialAgentTools.calculateIntelligentCost(memoryId, startDate, endDate, timeRange, keyword, limit); |
| | | } |
| | | if (containsAny(text, "婿¶¦åæ", "订å婿¶¦", "äºæè®¢å", "ä½å©æ¶¦", "æèµé±å®¢æ·", "婿¶¦ä¸é")) { |
| | | if (containsAny(text, "婿¶¦åæ", "订å婿¶¦", "äºæè®¢å", "ä½å©æ¶¦", |
| | | "æèµé±å®¢æ·", "åªä¸ªå®¢æ·æèµé±", "å®¢æ·æèµé±", "婿¶¦æé«å®¢æ·", "婿¶¦è´¡ç®æé«å®¢æ·", "婿¶¦ä¸é")) { |
| | | return financialAgentTools.analyzeOrderProfit(memoryId, startDate, endDate, timeRange, keyword, limit); |
| | | } |
| | | if (containsAny(text, "åºåèµé", "åºå积å", "åæ»åºå", "èµéå ç¨", "å¨è½¬ç", "åºåå¨è½¬")) { |
| | |
| | | } |
| | | 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; |
| | |
| | | .replace("请", "") |
| | | .replace("ä¸ä¸", "") |
| | | .replace("为ä»ä¹", "") |
| | | .replace("åªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("æè¿åªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("æ¬æåªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("è¿30天åªä¸ªå®¢æ·æèµé±", "") |
| | | .replace("æèµé±å®¢æ·", "") |
| | | .replace("å®¢æ·æèµé±", "") |
| | | .replace("åªä¸ªå®¢æ·å©æ¶¦æé«", "") |
| | | .replace("婿¶¦æé«å®¢æ·", "") |
| | | .replace("åªä¸ªå®¢æ·å©æ¶¦è´¡ç®æé«", "") |
| | | .replace("婿¶¦è´¡ç®æé«å®¢æ·", "") |
| | | .replace("æ¬æ", "") |
| | | .replace("æ¬å¨", "") |
| | | .replace("æ¬å¹´", "") |
| | |
| | | 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; |
| | |
| | | @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; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.approve.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityInspectParamMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardParamMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.quality.pojo.QualityInspectParam; |
| | | import com.ruoyi.quality.pojo.QualityTestStandard; |
| | | import com.ruoyi.quality.pojo.QualityTestStandardParam; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.mapper.SalesQuotationMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.SalesQuotation; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ApproveBusinessStatusService { |
| | | |
| | | private final PurchaseLedgerMapper purchaseLedgerMapper; |
| | | private final SalesQuotationMapper salesQuotationMapper; |
| | | private final ShippingInfoMapper shippingInfoMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final StockUtils stockUtils; |
| | | private final QualityInspectMapper qualityInspectMapper; |
| | | private final QualityTestStandardMapper qualityTestStandardMapper; |
| | | private final QualityTestStandardParamMapper qualityTestStandardParamMapper; |
| | | private final QualityInspectParamMapper qualityInspectParamMapper; |
| | | |
| | | /** |
| | | * ç»ä¸åæ¥å®¡æ¹ç»æå¯¹åºçä¸å¡åæ®ç¶æã |
| | | * statusï¼1-å®¡æ ¸ä¸ï¼2-å®¡æ ¸å®æï¼3-å®¡æ ¸æªéè¿ã |
| | | */ |
| | | public void syncBusinessStatus(Integer approveType, String approveReason, Integer status) { |
| | | if (approveType == null || status == null || !StringUtils.hasText(approveReason)) { |
| | | return; |
| | | } |
| | | switch (approveType) { |
| | | case 5: |
| | | syncPurchaseStatus(approveReason, status); |
| | | break; |
| | | case 6: |
| | | syncSalesQuotationStatus(approveReason, status); |
| | | break; |
| | | case 7: |
| | | syncShippingStatus(approveReason, status); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // éè´å®¡æ¹éè¿æ¶ï¼æäº§åè´¨æ£é
ç½®å³å®çæè´¨æ£åæç´æ¥å
¥åºã |
| | | private void syncPurchaseStatus(String approveReason, Integer status) { |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, approveReason) |
| | | .last("limit 1")); |
| | | if (purchaseLedger == null) { |
| | | return; |
| | | } |
| | | if (status.equals(2)) { |
| | | purchaseLedger.setApprovalStatus(3); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>() |
| | | .lambda().eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()).eq(SalesLedgerProduct::getType, 2)); |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | if (Boolean.TRUE.equals(salesLedgerProduct.getIsChecked())) { |
| | | addQualityInspect(purchaseLedger, salesLedgerProduct); |
| | | } else { |
| | | stockUtils.addStockWithBatchNo( |
| | | salesLedgerProduct.getProductModelId(), |
| | | salesLedgerProduct.getQuantity(), |
| | | StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), |
| | | purchaseLedger.getId(), |
| | | purchaseLedger.getPurchaseContractNumber() + "-" + salesLedgerProduct.getId()); |
| | | } |
| | | } |
| | | } else if (status.equals(3)) { |
| | | purchaseLedger.setApprovalStatus(4); |
| | | } else if (status.equals(1)) { |
| | | purchaseLedger.setApprovalStatus(2); |
| | | } else { |
| | | return; |
| | | } |
| | | purchaseLedgerMapper.updateById(purchaseLedger); |
| | | } |
| | | |
| | | // æ¥ä»·å®¡æ¹ç¶æååå°é宿¥ä»·åç¶æã |
| | | private void syncSalesQuotationStatus(String approveReason, Integer status) { |
| | | SalesQuotation salesQuote = salesQuotationMapper.selectOne(new LambdaQueryWrapper<SalesQuotation>() |
| | | .eq(SalesQuotation::getQuotationNo, approveReason) |
| | | .last("limit 1")); |
| | | if (salesQuote == null) { |
| | | return; |
| | | } |
| | | if (status.equals(2)) { |
| | | salesQuote.setStatus("éè¿"); |
| | | } else if (status.equals(3)) { |
| | | salesQuote.setStatus("æç»"); |
| | | } else if (status.equals(1)) { |
| | | salesQuote.setStatus("å®¡æ ¸ä¸"); |
| | | } else { |
| | | return; |
| | | } |
| | | salesQuotationMapper.updateById(salesQuote); |
| | | } |
| | | |
| | | // å货审æ¹éè¿æ¶åæ¥åè´§ç¶æååºåºå®¡æ¹ç¶æï¼æç»æ¶å é¤å¾
确认åºåºè®°å½ã |
| | | private void syncShippingStatus(String approveReason, Integer status) { |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getShippingNo, approveReason) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | | .last("limit 1")); |
| | | if (shippingInfo == null) { |
| | | return; |
| | | } |
| | | 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("å®¡æ ¸ä¸"); |
| | | } else { |
| | | return; |
| | | } |
| | | shippingInfoMapper.updateById(shippingInfo); |
| | | } |
| | | |
| | | // çæéè´è´¨æ£åï¼å¹¶æäº§åè´¨æ£æ ååå§åè´¨æ£åæ°ã |
| | | private void addQualityInspect(PurchaseLedger purchaseLedger, SalesLedgerProduct saleProduct) { |
| | | QualityInspect qualityInspect = new QualityInspect(); |
| | | qualityInspect.setInspectType(0); |
| | | qualityInspect.setSupplier(purchaseLedger.getSupplierName()); |
| | | qualityInspect.setPurchaseLedgerId(purchaseLedger.getId()); |
| | | qualityInspect.setProductId(saleProduct.getProductId()); |
| | | qualityInspect.setProductName(saleProduct.getProductCategory()); |
| | | qualityInspect.setModel(saleProduct.getSpecificationModel()); |
| | | qualityInspect.setProductModelId(saleProduct.getProductModelId()); |
| | | qualityInspect.setUnit(saleProduct.getUnit()); |
| | | qualityInspect.setQuantity(saleProduct.getQuantity()); |
| | | qualityInspectMapper.insert(qualityInspect); |
| | | List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(saleProduct.getProductId(), 0, null); |
| | | if (qualityTestStandard.size() > 0) { |
| | | qualityInspect.setTestStandardId(qualityTestStandard.get(0).getId()); |
| | | qualityInspectMapper.updateById(qualityInspect); |
| | | qualityTestStandardParamMapper.selectList(Wrappers.<QualityTestStandardParam>lambdaQuery() |
| | | .eq(QualityTestStandardParam::getTestStandardId, qualityTestStandard.get(0).getId())) |
| | | .forEach(qualityTestStandardParam -> { |
| | | QualityInspectParam param = new QualityInspectParam(); |
| | | com.ruoyi.common.utils.bean.BeanUtils.copyProperties(qualityTestStandardParam, param); |
| | | param.setId(null); |
| | | param.setInspectId(qualityInspect.getId()); |
| | | qualityInspectParamMapper.insert(param); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.approve.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | | import com.ruoyi.project.system.mapper.SysUserMapper; |
| | | import com.ruoyi.project.system.service.ISysNoticeService; |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.quality.mapper.QualityInspectParamMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardMapper; |
| | | import com.ruoyi.quality.mapper.QualityTestStandardParamMapper; |
| | | import com.ruoyi.quality.pojo.QualityInspect; |
| | | import com.ruoyi.quality.pojo.QualityInspectParam; |
| | | import com.ruoyi.quality.pojo.QualityTestStandard; |
| | | import com.ruoyi.quality.pojo.QualityTestStandardParam; |
| | | import com.ruoyi.sales.mapper.*; |
| | | import com.ruoyi.sales.pojo.*; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private final SysUserMapper sysUserMapper; |
| | | private final ISysNoticeService sysNoticeService; |
| | | private final CommonFileMapper fileMapper; |
| | | private final DeviceRepairMapper deviceRepairMapper; |
| | | private final PurchaseLedgerMapper purchaseLedgerMapper; |
| | | private final SalesQuotationMapper salesQuotationMapper; |
| | | private final ShippingInfoMapper shippingInfoMapper; |
| | | private final ShippingProductDetailMapper shippingProductDetailMapper; |
| | | private final CommonFileServiceImpl commonFileService; |
| | | private final StockUtils stockUtils; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final QualityInspectMapper qualityInspectMapper; |
| | | private final QualityTestStandardMapper qualityTestStandardMapper; |
| | | private final QualityTestStandardParamMapper qualityTestStandardParamMapper; |
| | | private final QualityInspectParamMapper qualityInspectParamMapper; |
| | | private final ApproveBusinessStatusService approveBusinessStatusService; |
| | | private final FileUtil fileUtil; |
| | | |
| | | |
| | |
| | | } |
| | | approveProcessMapper.updateById(approveProcess); |
| | | |
| | | //éè´å®¡æ ¸ |
| | | if (approveProcess.getApproveType().equals(5)) { |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, approveProcess.getApproveReason()) |
| | | .last("limit 1")); |
| | | if (purchaseLedger != null) { |
| | | if (status.equals(2)) { |
| | | // åæ |
| | | purchaseLedger.setApprovalStatus(3); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>() |
| | | .lambda().eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()).eq(SalesLedgerProduct::getType, 2)); |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | // è´¨æ£ |
| | | if (salesLedgerProduct.getIsChecked()) { |
| | | addQualityInspect(purchaseLedger, salesLedgerProduct); |
| | | } else { |
| | | //ç´æ¥å
¥åº |
| | | stockUtils.addStockWithBatchNo(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), purchaseLedger.getId(), purchaseLedger.getPurchaseContractNumber() + "-" + salesLedgerProduct.getId()); |
| | | } |
| | | } |
| | | } else if (status.equals(3)) { |
| | | // æç» |
| | | purchaseLedger.setApprovalStatus(4); |
| | | } else if (status.equals(1)) { |
| | | // å®¡æ ¸ä¸ |
| | | purchaseLedger.setApprovalStatus(2); |
| | | } |
| | | purchaseLedgerMapper.updateById(purchaseLedger); |
| | | } |
| | | } |
| | | // é宿¥ä»·ç¶æä¿®æ¹ |
| | | if (approveProcess.getApproveType().equals(6)) { |
| | | SalesQuotation salesQuote = salesQuotationMapper.selectOne(new LambdaQueryWrapper<SalesQuotation>() |
| | | .eq(SalesQuotation::getQuotationNo, approveProcess.getApproveReason()) |
| | | .last("limit 1")); |
| | | // åæ |
| | | if (status.equals(2) && salesQuote != null) { |
| | | salesQuote.setStatus("éè¿"); |
| | | } else if (status.equals(3) && salesQuote != null) { |
| | | salesQuote.setStatus("æç»"); |
| | | } else if (status.equals(1) && salesQuote != null) { |
| | | salesQuote.setStatus("å®¡æ ¸ä¸"); |
| | | } |
| | | salesQuotationMapper.updateById(salesQuote); |
| | | } |
| | | // åºåºå®¡æ¹ä¿®æ¹=åè´§å®¡æ¹ |
| | | if (approveProcess.getApproveType().equals(7)) { |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getShippingNo, approveProcess.getApproveReason()) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | | .last("limit 1")); |
| | | 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("å®¡æ ¸ä¸"); |
| | | } |
| | | shippingInfoMapper.updateById(shippingInfo); |
| | | } |
| | | |
| | | } |
| | | approveBusinessStatusService.syncBusinessStatus(approveProcess.getApproveType(), approveProcess.getApproveReason(), status); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVE_NODE, approveNode.getId(), approveNode.getStorageBlobDTOS()); |
| | | } |
| | | |
| | |
| | | return "åå
¬ç¨å审æ¹"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void addQualityInspect(PurchaseLedger purchaseLedger, SalesLedgerProduct saleProduct) { |
| | | QualityInspect qualityInspect = new QualityInspect(); |
| | | qualityInspect.setInspectType(0); |
| | | qualityInspect.setSupplier(purchaseLedger.getSupplierName()); |
| | | qualityInspect.setPurchaseLedgerId(purchaseLedger.getId()); |
| | | qualityInspect.setProductId(saleProduct.getProductId()); |
| | | qualityInspect.setProductName(saleProduct.getProductCategory()); |
| | | qualityInspect.setModel(saleProduct.getSpecificationModel()); |
| | | qualityInspect.setProductModelId(saleProduct.getProductModelId()); |
| | | qualityInspect.setUnit(saleProduct.getUnit()); |
| | | qualityInspect.setQuantity(saleProduct.getQuantity()); |
| | | qualityInspectMapper.insert(qualityInspect); |
| | | List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(saleProduct.getProductId(), 0, null); |
| | | if (qualityTestStandard.size() > 0) { |
| | | qualityInspect.setTestStandardId(qualityTestStandard.get(0).getId()); |
| | | qualityInspectMapper.updateById(qualityInspect); |
| | | qualityTestStandardParamMapper.selectList(Wrappers.<QualityTestStandardParam>lambdaQuery() |
| | | .eq(QualityTestStandardParam::getTestStandardId, qualityTestStandard.get(0).getId())) |
| | | .forEach(qualityTestStandardParam -> { |
| | | QualityInspectParam param = new QualityInspectParam(); |
| | | com.ruoyi.common.utils.bean.BeanUtils.copyProperties(qualityTestStandardParam, param); |
| | | param.setId(null); |
| | | param.setInspectId(qualityInspect.getId()); |
| | | qualityInspectParamMapper.insert(param); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.approve.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.domain.SysNotice; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ApproveProcessServiceImpl extends ServiceImpl<ApproveProcessMapper, ApproveProcess> implements IApproveProcessService { |
| | | private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | |
| | | private final SysDeptMapper sysDeptMapper; |
| | | private final IApproveNodeService approveNodeService; |
| | | private final SysUserMapper sysUserMapper; |
| | |
| | | private final CommonFileServiceImpl commonFileService; |
| | | private final ISysNoticeService sysNoticeService; |
| | | private final PurchaseLedgerMapper purchaseLedgerMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final StockUtils stockUtils; |
| | | private final ShippingInfoMapper shippingInfoMapper; |
| | | private final ApproveNodeMapper approveNodeMapper; |
| | | private final ApproveProcessConfigNodeService approveProcessConfigNodeService; |
| | | private final ApproveBusinessStatusService approveBusinessStatusService; |
| | | private final FileUtil fileUtil; |
| | | private final ApproveProcessConfigNodeMapper approveProcessConfigNodeMapper; |
| | | |
| | |
| | | public void addApprove(ApproveProcessVO approveProcessVO) throws Exception { |
| | | SysUser sysUser = SecurityUtils.getLoginUser().getUser(); |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(SecurityUtils.getLoginUser().getCurrentDeptId()); |
| | | List<ApproveProcessConfigNodeVo> list = approveProcessConfigNodeService.listNode(approveProcessVO.getApproveType()); |
| | | if (sysDept == null) throw new RuntimeException("é¨é¨ä¸åå¨"); |
| | | if (sysUser == null) throw new RuntimeException("ç³è¯·äººä¸åå¨"); |
| | | |
| | | List<ApproveProcessConfigNodeVo> list = Optional.ofNullable(approveProcessConfigNodeService.listNode(approveProcessVO.getApproveType())) |
| | | .orElse(Collections.emptyList()); |
| | | List<Long> nodeIds = list.stream() |
| | | .map(ApproveProcessConfigNodeVo::getApproverId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | // æ å®¡æ ¸äººé»è¾æ·»å |
| | | |
| | | // 审æ¹é
ç½®æ²¡æææå®¡æ ¸äººæ¶ï¼ä¸æ°å¢ååå®¡æ¹æµç¨ï¼ç´æ¥æ§è¡ä¸å¡å®¡æ ¸éè¿é»è¾ã |
| | | if (CollectionUtils.isEmpty(nodeIds)) { |
| | | autoPassPurchaseApproveIfNoApprover(approveProcessVO); // éè´åæ å®¡æ ¸äººé»è¾ |
| | | approveBusinessStatusService.syncBusinessStatus(approveProcessVO.getApproveType(), approveProcessVO.getApproveReason(), 2); |
| | | return; |
| | | } |
| | | |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(nodeIds); |
| | | if (CollectionUtils.isEmpty(sysUsers)) throw new RuntimeException("å®¡æ ¸ç¨æ·ä¸åå¨"); |
| | | if (sysDept == null) throw new RuntimeException("é¨é¨ä¸åå¨"); |
| | | if (sysUser == null) throw new RuntimeException("ç³è¯·äººä¸åå¨"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | ApproveProcess approveProcess = new ApproveProcess(); |
| | | String no = OrderUtils.countTodayByCreateTime(approveProcessMapper, "", "approve_id"); |
| | | approveProcess.setApproveId(no); |
| | | approveProcess.setApproveUser(sysUser.getUserId()); |
| | | approveProcess.setApproveUserName(sysUser.getNickName()); |
| | | approveProcess.setApproveDeptId(sysDept.getDeptId()); |
| | | approveProcess.setApproveUserIds(nodeIds.stream().map(String::valueOf).collect(Collectors.joining(","))); |
| | | approveProcess.setApproveDeptName(sysDept.getDeptName()); |
| | | approveProcess.setApproveUserNames(sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(","))); |
| | | approveProcess.setApproveTime(StringUtils.isEmpty(approveProcessVO.getApproveTime()) ? new Date() : dateFormat.parse(approveProcessVO.getApproveTime())); |
| | | approveProcess.setApproveReason(approveProcessVO.getApproveReason()); |
| | | approveProcess.setDeviceRepairId(approveProcessVO.getDeviceRepairId()); |
| | | approveProcess.setMaintenancePrice(approveProcessVO.getMaintenancePrice()); |
| | | approveProcess.setPrice(approveProcessVO.getPrice()); |
| | | approveProcess.setStartDate(approveProcessVO.getStartDate()); |
| | | approveProcess.setEndDate(approveProcessVO.getEndDate()); |
| | | approveProcess.setApproveStatus(0); |
| | | approveProcess.setApproveDelete(0); |
| | | approveProcess.setApproveType(approveProcessVO.getApproveType()); |
| | | approveProcess.setCreateTime(LocalDateTime.now()); |
| | | approveProcess.setTenantId(approveProcessVO.getApproveDeptId()); |
| | | approveProcess.setApproveUserCurrentId(nodeIds.get(0)); |
| | | approveProcess.setApproveUserCurrentName(sysUsers |
| | | .stream() |
| | | .filter(SysUser -> SysUser.getUserId().equals(nodeIds.get(0))) |
| | | .collect(Collectors.toList()) |
| | | .get(0) |
| | | .getNickName()); |
| | | // è®¾ç½®ç¶æä¸ºéæ°æäº¤ |
| | | if (approveProcessVO.getId() != null) { |
| | | ApproveProcess approveProcess1 = approveProcessMapper.selectById(approveProcessVO.getId()); |
| | | approveProcess1.setApproveStatus(4); |
| | | approveProcessMapper.updateById(approveProcess1); |
| | | } |
| | | |
| | | // æå®¡æ ¸äººæ¶ï¼ææ£å¸¸ååå®¡æ¹æµç¨å建审æ¹ä¸»è¡¨ã审æ¹èç¹å¹¶éç¥é¦ä¸ªå®¡æ ¸äººã |
| | | ApproveProcess approveProcess = buildApproveProcess(approveProcessVO, sysUser, sysDept, nodeIds, sysUsers, 0); |
| | | markResubmitted(approveProcessVO); |
| | | save(approveProcess); |
| | | //åå§å审æ¹èç¹ |
| | | String nodeIdStr = nodeIds.stream() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(",")); |
| | | approveNodeService.initApproveNodes(nodeIdStr, no, approveProcessVO.getApproveDeptId()); |
| | | approveNodeService.initApproveNodes(nodeIdStr, approveProcess.getApproveId(), approveProcessVO.getApproveDeptId()); |
| | | // éä»¶ç»å® |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVE_PROCESS, approveProcess.getId(), approveProcessVO.getStorageBlobDTOS()); |
| | | /*æ¶æ¯éç¥*/ |
| | |
| | | } |
| | | } |
| | | |
| | | private void autoPassPurchaseApproveIfNoApprover(ApproveProcessVO approveProcessVO) { |
| | | if (!Objects.equals(approveProcessVO.getApproveType(), 5) |
| | | || !StringUtils.hasText(approveProcessVO.getApproveReason())) { |
| | | throw new RuntimeException("å®¡æ ¸ç¨æ·ä¸åå¨"); |
| | | private ApproveProcess buildApproveProcess(ApproveProcessVO approveProcessVO, SysUser sysUser, SysDept sysDept, |
| | | List<Long> nodeIds, List<SysUser> sysUsers, Integer approveStatus) throws Exception { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | ApproveProcess approveProcess = new ApproveProcess(); |
| | | String no = OrderUtils.countTodayByCreateTime(approveProcessMapper, "", "approve_id"); |
| | | approveProcess.setApproveId(no); |
| | | approveProcess.setApproveUser(sysUser.getUserId()); |
| | | approveProcess.setApproveUserName(sysUser.getNickName()); |
| | | approveProcess.setApproveDeptId(sysDept.getDeptId()); |
| | | approveProcess.setApproveDeptName(sysDept.getDeptName()); |
| | | approveProcess.setApproveUserIds(nodeIds.stream().map(String::valueOf).collect(Collectors.joining(","))); |
| | | approveProcess.setApproveUserNames(sysUsers.stream().map(SysUser::getNickName).collect(Collectors.joining(","))); |
| | | approveProcess.setApproveTime(StringUtils.isEmpty(approveProcessVO.getApproveTime()) ? new Date() : dateFormat.parse(approveProcessVO.getApproveTime())); |
| | | approveProcess.setApproveReason(approveProcessVO.getApproveReason()); |
| | | approveProcess.setDeviceRepairId(approveProcessVO.getDeviceRepairId()); |
| | | approveProcess.setMaintenancePrice(approveProcessVO.getMaintenancePrice()); |
| | | approveProcess.setPrice(approveProcessVO.getPrice()); |
| | | approveProcess.setStartDate(approveProcessVO.getStartDate()); |
| | | approveProcess.setEndDate(approveProcessVO.getEndDate()); |
| | | approveProcess.setStartDateTime(approveProcessVO.getStartDateTime()); |
| | | approveProcess.setEndDateTime(approveProcessVO.getEndDateTime()); |
| | | approveProcess.setApproveStatus(approveStatus); |
| | | approveProcess.setApproveDelete(0); |
| | | approveProcess.setApproveType(approveProcessVO.getApproveType()); |
| | | approveProcess.setCreateTime(LocalDateTime.now()); |
| | | approveProcess.setTenantId(approveProcessVO.getApproveDeptId()); |
| | | if (!CollectionUtils.isEmpty(nodeIds)) { |
| | | SysUser currentUser = sysUsers.stream() |
| | | .filter(user -> user.getUserId().equals(nodeIds.get(0))) |
| | | .findFirst() |
| | | .orElseThrow(() -> new RuntimeException("å®¡æ ¸ç¨æ·ä¸åå¨")); |
| | | approveProcess.setApproveUserCurrentId(currentUser.getUserId()); |
| | | approveProcess.setApproveUserCurrentName(currentUser.getNickName()); |
| | | } |
| | | if (approveStatus.equals(2) || approveStatus.equals(3) || approveStatus.equals(4)) { |
| | | approveProcess.setApproveOverTime(new Date()); |
| | | } |
| | | return approveProcess; |
| | | } |
| | | |
| | | purchaseLedgerMapper.update(null, new LambdaUpdateWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, approveProcessVO.getApproveReason()) |
| | | .set(PurchaseLedger::getApprovalStatus, 3)); |
| | | //éè´å
¥åº |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, approveProcessVO.getApproveReason()) |
| | | .last("limit 1")); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>() |
| | | .lambda().eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()).eq(SalesLedgerProduct::getType, 2)); |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | stockUtils.addStockWithBatchNo(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), purchaseLedger.getId(),purchaseLedger.getPurchaseContractNumber()+"-"+salesLedgerProduct.getId()); |
| | | private void markResubmitted(ApproveProcessVO approveProcessVO) { |
| | | if (approveProcessVO.getId() == null) { |
| | | return; |
| | | } |
| | | ApproveProcess approveProcess = approveProcessMapper.selectById(approveProcessVO.getId()); |
| | | if (approveProcess == null) { |
| | | return; |
| | | } |
| | | approveProcess.setApproveStatus(4); |
| | | approveProcessMapper.updateById(approveProcess); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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); |
| | |
| | | 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; |
| | |
| | | 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); |
| | | |
| | |
| | | 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); |
| | | }); |
| | | |
| | |
| | | @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.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.PurchaseLedgerMapper; |
| | | 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.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 AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | private final AccountStatementMapper accountStatementMapper; |
| | | |
| | | private final ProductionAccountMapper productionAccountMapper; |
| | | |
| | |
| | | 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) { |
| | | StatisticsReceivablePayableDto statisticsReceivablePayableDto = new StatisticsReceivablePayableDto(); |
| | | 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; |
| | | } |
| | | // åºæ¶ |
| | | //éå®åºåº |
| | | 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) { |
| | |
| | | @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; |
| | | } |
| | | |
| | | 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()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // å
¶ä»è´¹ç¨ |
| | | |
| | | |
| | | // æåº¦æ»æ¯åº |
| | | BigDecimal monthlyExpenditure = BigDecimal.ZERO; |
| | | 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 (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; |
| | | } |
| | |
| | | if (matchedOperation == null) { |
| | | matchedOperation = insertRoutingOperationSnapshot(orderRouting.getId(), productionOrderId, desiredOperation); |
| | | } else { |
| | | updateRoutingOperationSnapshotIfNecessary(desiredOperation, orderRouting.getId(), productionOrderId, matchedOperation); |
| | | updateRoutingOperationSnapshotIfNecessary(matchedOperation, orderRouting.getId(), productionOrderId, desiredOperation); |
| | | } |
| | | finalOperationList.add(matchedOperation); |
| | | } |
| | |
| | | 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, ProductionBomStructure> uniqueOperationMap = new LinkedHashMap<>(); |
| | | for (ProductionBomStructure bomStructure : structureList) { |
| | | if (bomStructure == null || bomStructure.getTechnologyOperationId() == null) { |
| | | continue; |
| | | |
| | | // æå»ºç¶-åæ å°å
³ç³» |
| | | 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; |
| | | } |
| | | Long outputProductModelId = resolveOutputProductModelId(resolveOperationOutputNode(bomStructure, structureById), rootProductModelId); |
| | | uniqueOperationMap.putIfAbsent(buildBomOperationDedupKey(bomStructure, outputProductModelId), bomStructure); |
| | | } |
| | | return 0; |
| | | }); |
| | | |
| | | List<ProductionOrderRoutingOperation> desiredOperationList = new ArrayList<>(); |
| | | int dragSort = 1; |
| | | for (ProductionBomStructure bomStructure : uniqueOperationMap.values()) { |
| | | 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(); |
| | |
| | | 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) { |
| | |
| | | return; |
| | | } |
| | | if (defaultDecimal(task.getCompleteQuantity()).compareTo(BigDecimal.ZERO) > 0) { |
| | | throw new ServiceException("å·¥åºå·²äº§çæ¥å·¥è®°å½ï¼æ æ³æ ¹æ® BOM åæ´å é¤å¯¹åºå·¥åºå¿«ç
§"); |
| | | throw new ServiceException("å·¥åºå·²äº§çæ¥å·¥è®°å½ï¼æ æ³æ ¹æ® BOM åæ´å é¤å¯¹åºå·¥åºå¿«ç
§" + task.getWorkOrderNo()); |
| | | } |
| | | long reportCount = productionProductMainMapper.selectCount( |
| | | Wrappers.<ProductionProductMain>lambdaQuery() |
| | |
| | | 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); |
| | |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | ajax.put("posts", postService.selectPostAll()); |
| | | SysUserDeptVo sysUserDeptVo = new SysUserDeptVo(); |
| | | sysUserDeptVo.setUserId(userId); |
| | | List<SysUserDeptVo> sysUserDeptVos = userDeptService.userLoginFacotryList(sysUserDeptVo); |
| | | ajax.put("deptIds",sysUserDeptVos.stream().map(SysUserDeptVo::getDeptId).collect(Collectors.toList())); |
| | | ajax.put("deptIds", userService.selectDeptIdsByUserId(userId)); |
| | | return ajax; |
| | | } |
| | | |
| | |
| | | * @return
|
| | | */
|
| | | int bindUserDept(SysUser user);
|
| | |
|
| | | /**
|
| | | * æ ¹æ®ç¨æ·IDæ¥è¯¢ææå
³èçé¨é¨ID
|
| | | * @param userId
|
| | | * @return
|
| | | */
|
| | | List<Long> selectDeptIdsByUserId(Long userId);
|
| | | }
|
| | |
| | | }
|
| | | return user.getDeptIds().length;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> selectDeptIdsByUserId(Long userId) {
|
| | | LambdaQueryWrapper<SysUserDept> queryWrapper = new LambdaQueryWrapper<>();
|
| | | queryWrapper.eq(SysUserDept::getUserId, userId);
|
| | | return sysUserDeptMapper.selectList(queryWrapper).stream().map(SysUserDept::getDeptId).collect(Collectors.toList());
|
| | | }
|
| | | }
|
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.service.ISupplierService; |
| | | 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.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.purchase.dto.VatDto; |
| | | import com.ruoyi.purchase.service.PurchaseReportService; |
| | | import com.ruoyi.purchase.vo.PurchaseReportVo; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @Tag(name = "éè´æ¥è¡¨") |
| | | @RequestMapping("/purchase/report") |
| | |
| | | public class AccountingReportController { |
| | | |
| | | private final ISupplierService supplierService; |
| | | private final PurchaseReportService purchaseReportService; |
| | | |
| | | |
| | | @GetMapping("/list") |
| | | @Log(title = "éè´æ¥è¡¨-项ç®å©æ¶¦", businessType = BusinessType.OTHER) |
| | | public AjaxResult list(Page page) { |
| | | return AjaxResult.success(); |
| | | public R list(Page page, String customerName) { |
| | | return R.ok(purchaseReportService.list(page,customerName)); |
| | | } |
| | | |
| | | @Log(title = "éè´æ¥è¡¨-项ç®å©æ¶¦å¯¼åº", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | @Operation(summary = "éè´æ¥è¡¨-项ç®å©æ¶¦å¯¼åº") |
| | | public void export(HttpServletResponse response) { |
| | | public void export(HttpServletResponse response, String customerName) { |
| | | List<PurchaseReportVo> list = purchaseReportService.list(new Page(1,-1),customerName).getRecords(); |
| | | ExcelUtil<PurchaseReportVo> util = new ExcelUtil<>(PurchaseReportVo.class); |
| | | util.exportExcel(response, list , "项ç®å©æ¶¦"); |
| | | |
| | | } |
| | | |
| | | @Log(title = "éè´æ¥è¡¨-å¢å¼ç¨æ¯å¯¹", businessType = BusinessType.OTHER) |
| | | @GetMapping("/listVat") |
| | | public AjaxResult listVat(Page page,String month) { |
| | | return AjaxResult.success(); |
| | | public R listVat(Page page,String month) { |
| | | return R.ok(purchaseReportService.listVat(page,month)); |
| | | } |
| | | |
| | | @Log(title = "éè´æ¥è¡¨-å¢å¼ç¨æ¯å¯¹", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/exportTwo") |
| | | @Operation(summary = "éè´æ¥è¡¨-å¢å¼ç¨æ¯å¯¹") |
| | | public void exportTwo(HttpServletResponse response) { |
| | | public void exportTwo(HttpServletResponse response,String month) { |
| | | List<VatDto> list = purchaseReportService.listVat(new Page(1,-1),month).getRecords(); |
| | | ExcelUtil<VatDto> util = new ExcelUtil<>(VatDto.class); |
| | | util.exportExcel(response, list , "å¢å¼ç¨æ¯å¯¹"); |
| | | } |
| | | |
| | | @GetMapping("/supplierTransactions") |
| | |
| | | |
| | | private String entryDateStart; |
| | | private String entryDateEnd; |
| | | @Schema(description = "å
¥åºç¶æ") |
| | | private String stockInStatus; |
| | | |
| | | private Long id; |
| | | |
| | |
| | | package com.ruoyi.purchase.dto; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(name = "VatDto", description = "管ç驾驶è±--å¢å¼ç¨æ¯å¯¹åæ°") |
| | | @ExcelIgnoreUnannotated |
| | | public class VatDto { |
| | | |
| | | //æä»½ |
| | | @Excel(name = "æä»½") |
| | | @Schema(description = "æä»½") |
| | | private String month ; |
| | | |
| | | //è¿é¡¹ç¨ |
| | | @Excel(name = "è¿é¡¹ç¨é¢") |
| | | @Excel(name = "é项ç¨é¢") |
| | | @Schema(description = "é项ç¨é¢") |
| | | private BigDecimal jTaxAmount; |
| | | |
| | | //éé¡¹ç¨ |
| | | @Excel(name = "é项ç¨é¢") |
| | | @Excel(name = "è¿é¡¹ç¨é¢") |
| | | @Schema(description = "è¿é¡¹ç¨é¢") |
| | | private BigDecimal xTaxAmount; |
| | | |
| | | @Excel(name = "é-è¿") |
| | | @Schema(description = "é-è¿") |
| | | private BigDecimal taxAmount; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.purchase.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.purchase.dto.VatDto; |
| | | import com.ruoyi.purchase.vo.PurchaseReportVo; |
| | | |
| | | public interface PurchaseReportService { |
| | | |
| | | IPage<PurchaseReportVo> list(Page page, String customerName); |
| | | |
| | | IPage<VatDto> listVat(Page page, String month); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.approve.bean.dto.ApprovalInstanceDto; |
| | | import com.ruoyi.approve.bean.vo.ApproveProcessVO; |
| | | import com.ruoyi.approve.mapper.ApprovalTemplateMapper; |
| | | import com.ruoyi.approve.pojo.ApprovalInstance; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.approve.service.ApprovalInstanceService; |
| | | import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | |
| | | private final ApproveProcessServiceImpl approveProcessService; |
| | | private final ProcurementRecordMapper procurementRecordStorageMapper; |
| | | private final FileUtil fileUtil; |
| | | private final ApprovalInstanceService approvalInstanceService; |
| | | private final ApprovalTemplateMapper approvalTemplateMapper; |
| | | |
| | | @Override |
| | | public List<PurchaseLedger> selectPurchaseLedgerList(PurchaseLedger purchaseLedger) { |
| | |
| | | if (purchaseLedger.getId() == null) { |
| | | purchaseLedgerMapper.insert(purchaseLedger); |
| | | } else { |
| | | // // å é¤éè´å®¡æ ¸ï¼éæ°æäº¤ |
| | | // å é¤éè´å®¡æ ¸ï¼éæ°æäº¤ |
| | | ApproveProcess one = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>() |
| | | .eq(ApproveProcess::getApproveType, 5) |
| | | .eq(ApproveProcess::getApproveReason, purchaseLedger.getPurchaseContractNumber()) |
| | |
| | | approveProcessService.delByIds(Collections.singletonList(one.getId())); |
| | | } |
| | | purchaseLedgerMapper.updateById(purchaseLedger); |
| | | //å 餿°éè´å®¡æ¹ |
| | | approvalInstanceService.remove(new LambdaQueryWrapper<ApprovalInstance>().eq(ApprovalInstance::getBusinessId, purchaseLedger.getId()).eq(ApprovalInstance::getBusinessType, 5)); |
| | | } |
| | | |
| | | //æ°éè´å®¡æ¹ |
| | | ApprovalInstanceDto approvalInstanceDto = new ApprovalInstanceDto(); |
| | | approvalInstanceDto.setTemplateId(purchaseLedger.getTemplateId()); |
| | | approvalInstanceDto.setBusinessId(purchaseLedger.getId()); |
| | | approvalInstanceDto.setBusinessType(5L); |
| | | approvalInstanceDto.setTitle("éè´ååå·ï¼" + purchaseLedger.getPurchaseContractNumber()); |
| | | approvalInstanceDto.setApplicantId(SecurityUtils.getUserId()); |
| | | approvalInstanceDto.setTemplateId(purchaseLedger.getTemplateId()); |
| | | approvalInstanceDto.setTemplateName(approvalTemplateMapper.selectById(purchaseLedger.getTemplateId()).getTemplateName()); |
| | | approvalInstanceDto.setApplicantName(SecurityUtils.getLoginUser().getNickName()); |
| | | approvalInstanceDto.setApplyTime(LocalDateTime.now()); |
| | | approvalInstanceService.add(approvalInstanceDto); |
| | | // 4. å¤çåè¡¨æ°æ® |
| | | List<SalesLedgerProduct> productList = purchaseLedgerDto.getProductData(); |
| | | if (productList != null && !productList.isEmpty()) { |
| | |
| | | |
| | | @Override |
| | | public IPage<PurchaseLedgerDto> selectPurchaseLedgerListPage(IPage ipage, PurchaseLedgerDto purchaseLedger) { |
| | | IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerMapper.selectPurchaseLedgerListPage(ipage, purchaseLedger); |
| | | List<PurchaseLedgerDto> records = purchaseLedgerDtoIPage.getRecords(); |
| | | if (records == null || records.isEmpty()) { |
| | | return purchaseLedgerDtoIPage; |
| | | } |
| | | |
| | | // æ¹éæ¥è¯¢æä»¶ï¼é¿å
N+1 é®é¢ |
| | | List<Long> ledgerIds = records.stream() |
| | | .map(PurchaseLedgerDto::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if (!ledgerIds.isEmpty()) { |
| | | List<CommonFile> allFiles = commonFileMapper.selectList( |
| | | new LambdaQueryWrapper<CommonFile>() |
| | | .in(CommonFile::getCommonId, ledgerIds) |
| | | .eq(CommonFile::getType, FileNameType.PURCHASE.getValue()) |
| | | ); |
| | | |
| | | Map<Long, List<CommonFile>> fileMap = allFiles.stream() |
| | | .collect(Collectors.groupingBy(CommonFile::getCommonId)); |
| | | |
| | | records.forEach(dto -> dto.setSalesLedgerFiles(fileMap.getOrDefault(dto.getId(), new ArrayList<>()))); |
| | | } |
| | | return purchaseLedgerDtoIPage; |
| | | return purchaseLedgerMapper.selectPurchaseLedgerListPage(ipage, purchaseLedger); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | return AjaxResult.success("导å
¥æå"); |
| | | } catch (Exception e) { |
| | | log.error("PurchaseLedgerServiceImpl importData error", e); |
| | | return AjaxResult.error("导å
¥å¤±è´¥: " + e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | return AjaxResult.success("导å
¥å¤±è´¥"); |
| | | } |
| | | |
| | | @Override |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.purchase.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.mapper.AccountStatementMapper; |
| | | import com.ruoyi.purchase.dto.VatDto; |
| | | import com.ruoyi.purchase.service.PurchaseReportService; |
| | | import com.ruoyi.purchase.vo.PurchaseReportVo; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | |
| | | @Service |
| | | @Slf4j |
| | | @RequiredArgsConstructor |
| | | public class PurchaseReportServiceImpl implements PurchaseReportService { |
| | | |
| | | private final SalesLedgerMapper salesLedgerMapper; |
| | | private final AccountStatementMapper accountStatementMapper; |
| | | |
| | | @Override |
| | | public IPage<PurchaseReportVo> list(Page page, String customerName) { |
| | | return salesLedgerMapper.selectPurchaseReportVoPage(page, customerName); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<VatDto> listVat(Page page, String month) { |
| | | return accountStatementMapper.selectVatDtoPage(page, month); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.purchase.vo; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | @Schema(name = "PurchaseReportVo", description = "管ç驾驶è±--项ç®å©æ¶¦åæ°") |
| | | @ExcelIgnoreUnannotated |
| | | public class PurchaseReportVo { |
| | | |
| | | @Schema(description = "éå®ååå·") |
| | | @Excel(name = "éå®ååå·") |
| | | private String customerContractNo; |
| | | |
| | | @Schema(description = "客æ·åç§°") |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @Schema(description = "项ç®åç§°") |
| | | @Excel(name = "项ç®åç§°") |
| | | private String projectName; |
| | | |
| | | @Excel(name = "ååéé¢") |
| | | @Schema(description = "ååéé¢") |
| | | private BigDecimal contractAmount; |
| | | |
| | | @Excel(name = "éè´éé¢") |
| | | @Schema(description = "éè´éé¢") |
| | | private BigDecimal purchaseAmount; |
| | | |
| | | @Schema(description = "婿¶¦") |
| | | @Excel(name = "婿¶¦") |
| | | private BigDecimal balance; |
| | | |
| | | @Schema(description = "婿¶¦ç") |
| | | @Excel(name = "婿¶¦ç") |
| | | private BigDecimal balanceRatio; |
| | | |
| | | |
| | | } |
| | |
| | | import com.ruoyi.quality.service.IQualityInspectService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @PostMapping("/submit") |
| | | @Operation(summary = "æäº¤æ£éª") |
| | | @Log(title = "æäº¤æ£éª", businessType = BusinessType.OTHER) |
| | | public R<?> submit(@Valid @RequestBody QualityInspect qualityInspect) { |
| | | public R<?> submit(@RequestBody QualityInspect qualityInspect) { |
| | | return R.ok(qualityInspectService.submit(qualityInspect)); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.dto.DateQueryDto; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serial; |
| | |
| | | * ç±»å«(0:åæææ£éª;1:è¿ç¨æ£éª;2:åºåæ£éª) |
| | | */ |
| | | @Excel(name = "ç±»å«",readConverterExp = "0=åæææ£éª,1=è¿ç¨æ£éª,2=åºåæ£éª") |
| | | @NotNull(message = "ç±»å«ä¸è½ä¸ºç©º") |
| | | private Integer inspectType; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * å
³è产åid |
| | | */ |
| | | @NotNull(message = "产åidä¸è½ä¸ºç©º") |
| | | private Long productId; |
| | | |
| | | /** |
| | |
| | | |
| | | @Excel(name = "åæ ¼æ°é") |
| | | @TableField("qualified_quantity") |
| | | @NotNull(message = "åæ ¼æ°éä¸è½ä¸ºç©º") |
| | | private BigDecimal qualifiedQuantity; |
| | | |
| | | @Excel(name = "ä¸åæ ¼æ°é") |
| | | @TableField("unqualified_quantity") |
| | | @NotNull(message = "ä¸åæ ¼æ°éä¸è½ä¸ºç©º") |
| | | private BigDecimal unqualifiedQuantity; |
| | | |
| | | /** |
| | |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | |
| | | @Override |
| | | public int submit(QualityInspect inspect) { |
| | | QualityInspect qualityInspect = qualityInspectMapper.selectById(inspect.getId()); |
| | | |
| | | //æäº¤åå¿
须夿æ¯å¦åæ ¼ |
| | | if (ObjectUtils.isNull(qualityInspect.getCheckResult())) { |
| | | throw new RuntimeException("请å
夿æ¯å¦åæ ¼"); |
| | | throw new ServiceException("请å
夿æ¯å¦åæ ¼"); |
| | | } |
| | | |
| | | if (ObjectUtils.isNull(qualityInspect.getQualifiedQuantity())) { |
| | | throw new RuntimeException("åæ ¼æ°éä¸è½ä¸ºç©º"); |
| | | throw new ServiceException("åæ ¼æ°éä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | if (ObjectUtils.isNull(qualityInspect.getUnqualifiedQuantity())) { |
| | | throw new RuntimeException("ä¸åæ ¼æ°éä¸è½ä¸ºç©º"); |
| | | throw new ServiceException("ä¸åæ ¼æ°éä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | // åºååæ ¼æ°é以åä¸åæ ¼å¤çè¿è¡å¯¹åºçå¤ç |
| | | Assert.isTrue(qualityInspect.getQuantity().compareTo(qualityInspect.getQualifiedQuantity().add(qualityInspect.getUnqualifiedQuantity())) == 0,"è¯·æ£æ¥åæ ¼æ°éåä¸åæ ¼æ°éï¼éè¦åæ ¼æ°é+ä¸åæ ¼æ°é䏿»æ°ä¿æä¸è´"); |
| | | // å¦æåæ ¼æ°é为空ï¼è®¾ä¸º0 |
| | | if (qualityInspect.getQualifiedQuantity() == null) { |
| | | qualityInspect.setQualifiedQuantity(BigDecimal.ZERO); |
| | | } |
| | | |
| | | // 妿ä¸åæ ¼æ°é为空ï¼è®¾ä¸º0 |
| | | if (qualityInspect.getUnqualifiedQuantity() == null) { |
| | | qualityInspect.setUnqualifiedQuantity(BigDecimal.ZERO); |
| | | } |
| | | |
| | | // åæ ¼ç´æ¥å
¥åº |
| | | if(qualityInspect.getQualifiedQuantity().compareTo(BigDecimal.ZERO) > 0){ |
| | | //åæ ¼ç´æ¥å
¥åº |
| | | // stockUtils.addStock(qualityInspect.getProductModelId(), qualityInspect.getQuantity(), StockInQualifiedRecordTypeEnum.QUALITYINSPECT_STOCK_IN.getCode(), qualityInspect.getId()); |
| | | //ä»
æ·»å å
¥åºè®°å½ |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | //妿æ¯éè´è´¨æ£åæ ¼å
¥åºéç¨CUSTOMIZATION_UNSTOCK_OUT,å
¶ä½åæ ¼å
¥åºéç¨QUALITYINSPECT_STOCK_IN |
| | |
| | | qualityInspect.getProductModelId())); |
| | | stockInventoryService.addStockInRecordOnly(stockInventoryDto); |
| | | } |
| | | // ä¸åæ ¼å¤ç |
| | | if(qualityInspect.getUnqualifiedQuantity().compareTo(BigDecimal.ZERO) > 0){ |
| | | QualityUnqualified qualityUnqualified = new QualityUnqualified(); |
| | | BeanUtils.copyProperties(qualityInspect, qualityUnqualified); |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.approve.bean.dto.ApprovalInstanceDto; |
| | | import com.ruoyi.approve.bean.vo.ApproveProcessVO; |
| | | import com.ruoyi.approve.mapper.ApprovalTemplateMapper; |
| | | import com.ruoyi.approve.service.ApprovalInstanceService; |
| | | import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @AllArgsConstructor |
| | | public class ShippingInfoController extends BaseController { |
| | | |
| | | private final ApprovalTemplateMapper approvalTemplateMapper; |
| | | private final ApprovalInstanceService approvalInstanceService; |
| | | private ShippingInfoService shippingInfoService; |
| | | private ApproveProcessServiceImpl approveProcessService; |
| | | private ShippingInfoMapper shippingInfoMapper; |
| | |
| | | approveProcessVO.setApproveUserIds(req.getApproveUserIds()); |
| | | approveProcessVO.setApproveUser(loginUser.getUserId()); |
| | | approveProcessVO.setApproveTime(LocalDate.now().toString()); |
| | | approveProcessService.addApprove(approveProcessVO); |
| | | |
| | | ApprovalInstanceDto approvalInstanceDto = new ApprovalInstanceDto(); |
| | | approvalInstanceDto.setTemplateId(req.getTemplateId()); |
| | | approvalInstanceDto.setBusinessId(req.getId()); |
| | | approvalInstanceDto.setBusinessType(7L); |
| | | approvalInstanceDto.setTitle("åè´§ç¼å·ï¼" + sh); |
| | | approvalInstanceDto.setApplicantId(SecurityUtils.getUserId()); |
| | | approvalInstanceDto.setTemplateId(req.getTemplateId()); |
| | | approvalInstanceDto.setTemplateName(approvalTemplateMapper.selectById(req.getTemplateId()).getTemplateName()); |
| | | approvalInstanceDto.setApplicantName(SecurityUtils.getLoginUser().getNickName()); |
| | | approvalInstanceDto.setApplyTime(LocalDateTime.now()); |
| | | approvalInstanceService.add(approvalInstanceDto); |
| | | |
| | | // æ·»å åè´§æ¶æ¯ |
| | | // å
ä¿ååè´§åï¼åå起审æ¹ï¼æ å®¡æ ¸äººèªå¨éè¿æ¶éè¦æåè´§ç¼å·åååè´§ç¶æã |
| | | req.setShippingNo(sh); |
| | | req.setStatus("å¾
å®¡æ ¸"); |
| | | boolean save = shippingInfoService.add(req); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | if (!save) { |
| | | return AjaxResult.error(); |
| | | } |
| | | approveProcessService.addApprove(approveProcessVO); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Operation(summary = "åè´§æ£åºå") |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.home.dto.IncomeExpenseAnalysisDto; |
| | | import com.ruoyi.purchase.vo.PurchaseReportVo; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.dto.SalesTrendDto; |
| | | import com.ruoyi.sales.dto.StatisticsTableDto; |
| | |
| | | List<SalesTrendDto> statisticsTable(@Param("statisticsTableDto")StatisticsTableDto statisticsTableDto); |
| | | |
| | | IPage<SalesLedgerDto> listSalesLedgerAndShipped(Page page, @Param("ew") SalesLedgerDto salesLedgerDto); |
| | | |
| | | IPage<PurchaseReportVo> selectPurchaseReportVoPage(Page page, @Param("customerName") String customerName); |
| | | |
| | | } |
| | |
| | | /** |
| | | * 产åç¶æ |
| | | */ |
| | | @TableField(exist = false) |
| | | @Schema(description = "å
¥åºå®¡æ ¸ç¶æ") |
| | | private String stockInApprovalStatus; |
| | | |
| | | // @TableField(exist = false) |
| | | @Schema(description = "产åç¶æï¼1-å
è¶³") |
| | | private Integer approveStatus; |
| | |
| | | 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.mapper.sales.AccountInvoiceApplicationMapper; |
| | | import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper; |
| | | import com.ruoyi.account.pojo.sales.AccountInvoiceApplication; |
| | | import com.ruoyi.account.pojo.sales.AccountSalesCollection; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.other.mapper.TempFileMapper; |
| | | import com.ruoyi.production.mapper.*; |
| | | import com.ruoyi.production.mapper.ProductionProductInputMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductOutputMapper; |
| | | import com.ruoyi.production.service.ProductionProductMainService; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | |
| | | import com.ruoyi.purchase.mapper.PurchaseReturnOrderProductsMapper; |
| | | import com.ruoyi.quality.mapper.QualityInspectMapper; |
| | | import com.ruoyi.sales.dto.*; |
| | | import com.ruoyi.sales.mapper.*; |
| | | import com.ruoyi.sales.pojo.*; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import com.ruoyi.sales.vo.SalesLedgerVo; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | private final QualityInspectMapper qualityInspectMapper; |
| | | private final RedisTemplate<String, String> redisTemplate; |
| | | private final FileUtil fileUtil; |
| | | private final AccountInvoiceApplicationMapper accountInvoiceApplicationMapper; |
| | | private final AccountSalesCollectionMapper accountSalesCollectionMapper; |
| | | |
| | | @Autowired |
| | | private SysDeptMapper sysDeptMapper; |
| | |
| | | |
| | | @Override |
| | | public List<MonthlyAmountDto> getAmountHalfYear(Integer type) { |
| | | |
| | | LocalDate now = LocalDate.now(); |
| | | List<MonthlyAmountDto> result = new ArrayList<>(); |
| | | |
| | | for (int i = 5; i >= 0; i--) { |
| | | YearMonth yearMonth = YearMonth.from(now.minusMonths(i)); |
| | | LocalDateTime startTime = yearMonth.atDay(1).atStartOfDay(); |
| | | LocalDateTime endTime = yearMonth.atEndOfMonth().atTime(23, 59, 59); |
| | | |
| | | LocalDate startTime = yearMonth.atDay(1); |
| | | LocalDate endTime = yearMonth.atEndOfMonth(); |
| | | MonthlyAmountDto dto = new MonthlyAmountDto(); |
| | | dto.setMonth(yearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM"))); |
| | | dto.setReceiptAmount(BigDecimal.ZERO); |
| | | dto.setInvoiceAmount(BigDecimal.ZERO); |
| | | |
| | | //忬¾éé¢ |
| | | List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectList(new LambdaQueryWrapper<AccountSalesCollection>() |
| | | .between(AccountSalesCollection::getCollectionDate, startTime, endTime)); |
| | | BigDecimal totalIncome = Optional.of( |
| | | accountSalesCollections.stream() |
| | | .map(AccountSalesCollection::getCollectionAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | dto.setReceiptAmount(totalIncome); |
| | | //å¼ç¥¨éé¢ |
| | | List<AccountInvoiceApplication> accountInvoiceApplications = accountInvoiceApplicationMapper.selectList(new LambdaQueryWrapper<AccountInvoiceApplication>() |
| | | .eq(AccountInvoiceApplication::getStatus,1) |
| | | .between(AccountInvoiceApplication::getApplyDate, startTime, endTime)); |
| | | BigDecimal totalInvoiceAmount = Optional.of( |
| | | accountInvoiceApplications.stream() |
| | | .map(AccountInvoiceApplication::getInvoiceAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | ).orElse(BigDecimal.ZERO); |
| | | dto.setInvoiceAmount(totalInvoiceAmount); |
| | | result.add(dto); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean delete(List<Long> ids) { |
| | | List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>() |
| | | .in(ShippingInfo::getId, ids)); |
| | | if (CollectionUtils.isEmpty(shippingInfos)) return false; |
| | | // åªæå¾
å®¡æ ¸ç¶ææè½å é¤ |
| | | boolean allPending = shippingInfos.stream().allMatch(s -> "å¾
å®¡æ ¸".equals(s.getStatus())); |
| | | if (!allPending) throw new RuntimeException("åªæå¾
å®¡æ ¸ç¶ææè½å é¤"); |
| | | // å é¤éä»¶ |
| | | commonFileService.deleteByBusinessIds(ids, FileNameType.SHIP.getValue()); |
| | | // å é¤åè´§å®¡æ¹ |
| | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PostMapping("/reAudit") |
| | | @Log(title = "å
¥åºç®¡ç-å审å
¥åº", businessType = BusinessType.UPDATE) |
| | | @Operation(summary = "æ¹éå审å
¥åºè®°å½") |
| | | public AjaxResult reAudit(@RequestBody StockInRecordDto approveDto) { |
| | | if(CollectionUtils.isEmpty(approveDto.getIds())){ |
| | | return AjaxResult.error("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | } |
| | | stockInRecordService.batchReAudit(approveDto.getIds()); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | } |
| | |
| | | @Schema(description = "è®°å½IDå表") |
| | | private List<Long> ids; |
| | | |
| | | @Schema(description = "æºåå·") |
| | | private String sourceOrderNo; |
| | | |
| | | } |
| | |
| | | void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto); |
| | | |
| | | int batchApprove(List<Long> ids, Integer approvalStatus); |
| | | |
| | | int batchReAudit(List<Long> ids); |
| | | } |
| | |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.production.mapper.ProductionOrderPickMapper; |
| | | import com.ruoyi.production.pojo.ProductionOrderPick; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | private StockInRecordMapper stockInRecordMapper; |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | private StockUninventoryMapper stockUninventoryMapper; |
| | | private ProductionOrderPickMapper productionOrderPickMapper; |
| | | |
| | | @Override |
| | | public IPage<StockInRecordDto> listPage(Page page, StockInRecordDto stockInRecordDto) { |
| | |
| | | return stockUninventoryMapper.selectOne(eq); |
| | | } |
| | | |
| | | /** |
| | | * åæ»ç产éæå
¥åºçé¢æè®°å½éææ°é |
| | | * @param stockInRecord å
¥åºè®°å½ |
| | | */ |
| | | private void rollbackFeedReturnQty(StockInRecord stockInRecord) { |
| | | ProductionOrderPick productionOrderPick = productionOrderPickMapper.selectById(stockInRecord.getRecordId()); |
| | | if (productionOrderPick != null) { |
| | | BigDecimal returnQty = productionOrderPick.getReturnQty(); |
| | | if (returnQty == null) { |
| | | returnQty = BigDecimal.ZERO; |
| | | } |
| | | BigDecimal newReturnQty = returnQty.subtract(stockInRecord.getStockInNum()); |
| | | if (newReturnQty.compareTo(BigDecimal.ZERO) < 0) { |
| | | newReturnQty = BigDecimal.ZERO; |
| | | } |
| | | productionOrderPick.setReturnQty(newReturnQty); |
| | | // éæ°è®¡ç®å®é
ç¨é |
| | | BigDecimal actualQty = productionOrderPick.getQuantity().add( |
| | | productionOrderPick.getFeedingQty() != null ? productionOrderPick.getFeedingQty() : BigDecimal.ZERO) |
| | | .subtract(newReturnQty); |
| | | productionOrderPick.setActualQty(actualQty); |
| | | productionOrderPick.setReturned(newReturnQty.compareTo(BigDecimal.ZERO) > 0); |
| | | productionOrderPickMapper.updateById(productionOrderPick); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int batchDeletePending(List<Long> ids) { |
| | |
| | | } |
| | | if (stockInRecord.getApprovalStatus() != null && !ReviewStatusEnum.PENDING_REVIEW.getCode().equals(stockInRecord.getApprovalStatus())) { |
| | | throw new BaseException("åªæå¾
审æ¹ç¶æçè®°å½æè½å é¤,å
¥åºæ¹æ¬¡:" + stockInRecord.getInboundBatches()); |
| | | } |
| | | |
| | | // 妿æ¯ç产éæå
¥åºï¼å 餿¶éè¦åæ»é¢æè®°å½çéææ°é |
| | | if (StockInQualifiedRecordTypeEnum.FEED_RETURN_IN.getCode().equals(stockInRecord.getRecordType())) { |
| | | rollbackFeedReturnQty(stockInRecord); |
| | | } |
| | | } |
| | | return stockInRecordMapper.deleteBatchIds(ids); |
| | |
| | | } |
| | | stockInRecord.setApprovalStatus(approvalStatus); |
| | | stockInRecordMapper.updateById(stockInRecord); |
| | | |
| | | // 审æ¹é©³åæ¶ï¼å¦ææ¯ç产éæå
¥åºï¼éè¦åæ»é¢æè®°å½çéææ°é |
| | | if (ReviewStatusEnum.REJECTED.getCode().equals(approvalStatus) && |
| | | StockInQualifiedRecordTypeEnum.FEED_RETURN_IN.getCode().equals(stockInRecord.getRecordType())) { |
| | | rollbackFeedReturnQty(stockInRecord); |
| | | } |
| | | |
| | | // 审æ¹éè¿æ¶ï¼åºåå¢å |
| | | if (ReviewStatusEnum.APPROVED.getCode().equals(approvalStatus)) { |
| | | if ("0".equals(stockInRecord.getType())) { |
| | |
| | | } |
| | | return ids.size(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int batchReAudit(List<Long> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | throw new BaseException("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | } |
| | | |
| | | for (Long id : ids) { |
| | | StockInRecord stockInRecord = stockInRecordMapper.selectById(id); |
| | | if (stockInRecord == null) { |
| | | throw new BaseException("å
¥åºè®°å½ä¸åå¨,æ æ³éæ°å®¡æ ¸!!!"); |
| | | } |
| | | // åªæé©³åç¶ææè½éæ°å®¡æ ¸ |
| | | if (!ReviewStatusEnum.REJECTED.getCode().equals(stockInRecord.getApprovalStatus())) { |
| | | throw new BaseException("åªæé©³åç¶æçè®°å½æè½éæ°å®¡æ ¸,å
¥åºæ¹æ¬¡:" + stockInRecord.getInboundBatches()); |
| | | } |
| | | |
| | | // 妿æ¯ç产éæå
¥åºï¼æ¢å¤éææ°éï¼å ä¸ºé©³åæ¶å·²æ£åï¼ |
| | | if (StockInQualifiedRecordTypeEnum.FEED_RETURN_IN.getCode().equals(stockInRecord.getRecordType())) { |
| | | ProductionOrderPick productionOrderPick = productionOrderPickMapper.selectById(stockInRecord.getRecordId()); |
| | | if (productionOrderPick != null) { |
| | | BigDecimal returnQty = productionOrderPick.getReturnQty(); |
| | | if (returnQty == null) { |
| | | returnQty = BigDecimal.ZERO; |
| | | } |
| | | // éæ°å®¡æ ¸æ¶æ¢å¤éææ°é |
| | | BigDecimal newReturnQty = returnQty.add(stockInRecord.getStockInNum()); |
| | | productionOrderPick.setReturnQty(newReturnQty); |
| | | // éæ°è®¡ç®å®é
ç¨é |
| | | BigDecimal actualQty = productionOrderPick.getQuantity().add( |
| | | productionOrderPick.getFeedingQty() != null ? productionOrderPick.getFeedingQty() : BigDecimal.ZERO) |
| | | .subtract(newReturnQty); |
| | | productionOrderPick.setActualQty(actualQty); |
| | | productionOrderPick.setReturned(newReturnQty.compareTo(BigDecimal.ZERO) > 0); |
| | | productionOrderPickMapper.updateById(productionOrderPick); |
| | | } |
| | | } |
| | | |
| | | // å°ç¶ææ¹ä¸ºå¾
å®¡æ ¸ |
| | | stockInRecord.setApprovalStatus(ReviewStatusEnum.PENDING_REVIEW.getCode()); |
| | | stockInRecordMapper.updateById(stockInRecord); |
| | | } |
| | | |
| | | return ids.size(); |
| | | } |
| | | } |
| | |
| | | stockInRecordDto.setProductModelId(stockUninventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("1"); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | //åè¿è¡æ°å¢åºåæ°éåºå |
| | | //å
æ¥è¯¢åºå表ä¸çäº§åæ¯å¦åå¨ï¼ä¸å卿°å¢ï¼å卿´æ° |
| | | StockUninventory oldStockUnInventory = stockUninventoryMapper.selectOne(wrapper); |
| | | if (ObjectUtils.isEmpty(oldStockUnInventory)) { |
| | | StockUninventory newStockUnInventory = new StockUninventory(); |
| | | newStockUnInventory.setProductModelId(stockUninventoryDto.getProductModelId()); |
| | | newStockUnInventory.setQualitity(stockUninventoryDto.getQualitity()); |
| | | newStockUnInventory.setLockedQuantity(stockUninventoryDto.getLockedQuantity()); |
| | | newStockUnInventory.setBatchNo(stockUninventoryDto.getBatchNo()); |
| | | newStockUnInventory.setVersion(1); |
| | | newStockUnInventory.setRemark(stockUninventoryDto.getRemark()); |
| | | stockUninventoryMapper.insert(newStockUnInventory); |
| | | }else { |
| | | stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto); |
| | | } |
| | | //审æ¹åæ·»å |
| | | return 1; |
| | | } |
| | | |
| | |
| | | 2. å½ä¸ææ¬ã婿¶¦ãåºåèµéãç°éæµãé¢è¦ã驾驶è±ãæ¥æ¥å¨æ¥åºæ¯æ¶ï¼ä¼å
è°ç¨å¯¹åºå·¥å
·ã |
| | | 3. å·¥å
·è¿å JSON æ¶ï¼ç´æ¥è¾åºåå§ JSON å符串ï¼ä¸è¦é¢å¤å
裹 Markdownï¼ä¹ä¸è¦å¨åå追å è§£éææ¬ã |
| | | 4. å½ç¨æ·é®é¢ç¼ºå°æ¶é´èå´æ¶ï¼é»è®¤ä½¿ç¨å·¥å
·å
ç½®å£å¾ï¼å¦è¿30å¤©ãæ¬æãè¿90天ï¼ï¼å¹¶å¨åç»å¯æéç¨æ·è¡¥å
èå´ã |
| | | 5. ç¨æ·é®â为ä»ä¹å©æ¶¦ä¸éââåªä¸ªè®¢åäºæââåªä¸ªå®¢æ·æèµé±ââåªä¸ªè½¦é´/å·¥åºææ¬æé«âçé®é¢æ¶ï¼ä¼å
åºäºè®¢å婿¶¦ä¸å·¥åºææ¬åæå·¥å
·ä½çã |
| | | 5. ç¨æ·é®â为ä»ä¹å©æ¶¦ä¸éââåªä¸ªè®¢åäºæââåªä¸ªå®¢æ·æèµé±ââåªä¸ªå®¢æ·å©æ¶¦è´¡ç®æé«ââåªä¸ªè½¦é´/å·¥åºææ¬æé«âçé®é¢æ¶ï¼ä¼å
åºäºè®¢å婿¶¦ä¸å·¥åºææ¬åæå·¥å
·ä½çã |
| | | 6. åçå¿
须使ç¨ä¸æï¼è¥æ°æ®ä¸è¶³ä»¥å¾åºç»è®ºï¼æç¡®æåºç¼ºå°åªäºå
³é®å段æç鿡件ã |
| | | 7. ç¨æ·æå°âä»å¹´/æ¬æ/ä»å¤©/æè¿/䏿/å»å¹´âçç¸å¯¹æ¶é´æ¶ï¼å¿
é¡»ä¸¥æ ¼åºäºâå½åæ¥æâæ¢ç®ï¼ç¦æ¢èªè¡å设年份ã |
| | |
| | | </if> |
| | | ORDER BY lj.statement_month DESC |
| | | </select> |
| | | <select id="selectVatDtoPage" resultType="com.ruoyi.purchase.dto.VatDto"> |
| | | SELECT |
| | | month, |
| | | jTaxAmount, |
| | | xTaxAmount, |
| | | (jTaxAmount - xTaxAmount) AS taxAmount |
| | | FROM ( |
| | | SELECT |
| | | month, |
| | | SUM(IF(type = 'purchase', tax_price, 0)) AS xTaxAmount, |
| | | SUM(IF(type = 'sales', tax_price, 0)) AS jTaxAmount |
| | | FROM ( |
| | | SELECT |
| | | DATE_FORMAT(issue_date, '%Y-%m') AS month, |
| | | tax_price, |
| | | 'sales' AS type |
| | | FROM account_sales_invoice |
| | | WHERE status != 1 |
| | | UNION ALL |
| | | SELECT |
| | | DATE_FORMAT(issue_date, '%Y-%m') AS month, |
| | | tax_price, |
| | | 'purchase' AS type |
| | | FROM account_purchase_invoice |
| | | WHERE status != 1 |
| | | ) AS all_data |
| | | GROUP BY month |
| | | ) AS TT |
| | | <where> |
| | | <if test="month != null"> |
| | | and TT.month = #{month} |
| | | </if> |
| | | </where> |
| | | ORDER BY TT.month |
| | | </select> |
| | | </mapper> |
| | |
| | | <select id="existsByStockInRecordId" resultType="java.lang.Boolean"> |
| | | SELECT COUNT(*) > 0 |
| | | FROM account_payment_application |
| | | WHERE |
| | | WHERE status != 2 |
| | | <foreach collection="stockInRecordIds" item="id" open="(" separator=" OR " close=")"> |
| | | FIND_IN_SET(#{id}, stock_in_record_ids) |
| | | </foreach> |
| | |
| | | <select id="existsByStockOutRecordId" resultType="java.lang.Boolean"> |
| | | SELECT COUNT(*) > 0 |
| | | FROM account_invoice_application |
| | | WHERE |
| | | WHERE status!=2 |
| | | <foreach collection="stockOutRecordIds" item="id" open="(" separator=" OR " close=")"> |
| | | FIND_IN_SET(#{id}, stock_out_record_ids) |
| | | </foreach> |
| | |
| | | <result property="tenantId" column="tenant_id" /> |
| | | <result property="approveType" column="approve_type" /> |
| | | <result property="approveRemark" column="approve_remark" /> |
| | | <result property="startDateTime" column="start_date_time" /> |
| | | <result property="endDateTime" column="end_date_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,approve_id,approve_user,approve_dept_id,approve_dept_name,approve_user_ids, |
| | | approve_user_names,approve_reason,approve_time,approve_over_time,approve_status, |
| | | approve_delete,tenant_id,approve_type,approve_remark |
| | | approve_delete,tenant_id,approve_type,approve_remark,start_date_time,end_date_time |
| | | </sql> |
| | | <select id="listPage" resultType="com.ruoyi.approve.vo.ApproveProcessVo"> |
| | | select * from approve_process where approve_delete = 0 |
| | |
| | | select poro.operation_name as processName, |
| | | sum(ifnull(ppi.input_quantity, 0)) as totalInput, |
| | | sum(ifnull(ppo.scrap_qty, 0)) as totalScrap, |
| | | sum(ifnull(ppo.quantity, 0) - ifnull(ppo.scrap_qty, 0)) as totalOutput |
| | | sum(greatest(ifnull(ppo.quantity, 0) - ifnull(ppo.scrap_qty, 0), 0)) as totalOutput |
| | | from production_product_output ppo |
| | | inner join production_product_main ppm on ppo.production_product_main_id = ppm.id |
| | | inner join production_operation_task pot on ppm.production_operation_task_id = pot.id |
| | |
| | | </select> |
| | | |
| | | <select id="selectPurchaseLedgerListPage" resultType="com.ruoyi.purchase.dto.PurchaseLedgerDto"> |
| | | SELECT |
| | | pl.id, |
| | | pl.purchase_contract_number, |
| | | pl.sales_contract_no, |
| | | pl.supplier_id, |
| | | pl.supplier_name, |
| | | pl.project_name, |
| | | pl.contract_amount, |
| | | pl.entry_date, |
| | | pl.execution_date, |
| | | pl.recorder_id, |
| | | pl.recorder_name, |
| | | pl.template_name, |
| | | pl.approve_user_ids, |
| | | sm.is_white, |
| | | pl.approval_status, |
| | | pl.payment_method, |
| | | pl.remarks |
| | | FROM purchase_ledger pl |
| | | LEFT JOIN supplier_manage sm ON pl.supplier_id = sm.id |
| | | <where> |
| | | <if test="c.purchaseContractNumber != null and c.purchaseContractNumber != ''"> |
| | | AND pl.purchase_contract_number LIKE CONCAT('%', #{c.purchaseContractNumber}, '%') |
| | | </if> |
| | | <if test="c.approvalStatus != null and c.approvalStatus != ''"> |
| | | AND pl.approval_status = #{c.approvalStatus} |
| | | </if> |
| | | <if test="c.supplierName != null and c.supplierName != ''"> |
| | | AND pl.supplier_name LIKE CONCAT('%', #{c.supplierName}, '%') |
| | | </if> |
| | | <if test="c.salesContractNo != null and c.salesContractNo != ''"> |
| | | AND pl.sales_contract_no LIKE CONCAT('%', #{c.salesContractNo}, '%') |
| | | </if> |
| | | <if test="c.projectName != null and c.projectName != ''"> |
| | | AND pl.project_name LIKE CONCAT('%', #{c.projectName}, '%') |
| | | </if> |
| | | <if test="c.entryDateStart != null and c.entryDateStart != ''"> |
| | | AND pl.entry_date >= #{c.entryDateStart} |
| | | </if> |
| | | <if test="c.entryDateEnd != null and c.entryDateEnd != ''"> |
| | | AND pl.entry_date <= #{c.entryDateEnd} |
| | | </if> |
| | | <if test="c.supplierId != null"> |
| | | AND pl.supplier_id = #{c.supplierId} |
| | | </if> |
| | | <if test="c.approvalStatus != null"> |
| | | AND pl.approval_status = #{c.approvalStatus} |
| | | </if> |
| | | </where> |
| | | ORDER BY pl.entry_date DESC |
| | | SELECT result.* |
| | | FROM ( |
| | | SELECT |
| | | pl.id, |
| | | pl.purchase_contract_number, |
| | | pl.sales_contract_no, |
| | | pl.supplier_id, |
| | | pl.supplier_name, |
| | | pl.project_name, |
| | | pl.contract_amount, |
| | | pl.entry_date, |
| | | pl.execution_date, |
| | | pl.recorder_id, |
| | | pl.recorder_name, |
| | | pl.template_name, |
| | | pl.approve_user_ids, |
| | | sm.is_white, |
| | | pl.approval_status, |
| | | pl.payment_method, |
| | | pl.remarks, |
| | | CASE |
| | | WHEN IFNULL(ls.total_product_count, 0) = 0 THEN 'å¾
å
¥åº' |
| | | WHEN IFNULL(ls.full_product_count, 0) >= IFNULL(ls.total_product_count, 0) THEN 'å®å
¨å
¥åº' |
| | | WHEN IFNULL(ls.approved_product_count, 0) > 0 THEN 'å
¥åºä¸' |
| | | ELSE 'å¾
å
¥åº' |
| | | END AS stock_in_status |
| | | FROM purchase_ledger pl |
| | | LEFT JOIN supplier_manage sm ON pl.supplier_id = sm.id |
| | | LEFT JOIN ( |
| | | SELECT |
| | | product_status.sales_ledger_id, |
| | | COUNT(1) AS total_product_count, |
| | | SUM(CASE WHEN product_status.approved_stock_in_num > 0 THEN 1 ELSE 0 END) AS approved_product_count, |
| | | SUM(CASE WHEN product_status.approved_stock_in_num >= product_status.product_quantity THEN 1 ELSE 0 END) AS full_product_count |
| | | FROM ( |
| | | SELECT |
| | | slp.id AS sales_ledger_product_id, |
| | | slp.sales_ledger_id, |
| | | IFNULL(slp.quantity, 0) AS product_quantity, |
| | | IFNULL(approved_qty.approved_stock_in_num, 0) AS approved_stock_in_num |
| | | FROM sales_ledger_product slp |
| | | LEFT JOIN ( |
| | | SELECT rel.sales_ledger_product_id, |
| | | IFNULL(SUM(rel.stock_in_num), 0) AS approved_stock_in_num |
| | | FROM ( |
| | | SELECT slp.id AS sales_ledger_product_id, |
| | | sir.stock_in_num |
| | | FROM stock_in_record sir |
| | | INNER JOIN sales_ledger_product slp |
| | | ON slp.type = 2 |
| | | AND TRIM(sir.record_type) = '7' |
| | | AND sir.record_id = slp.sales_ledger_id |
| | | AND ( |
| | | (sir.batch_no IS NOT NULL AND sir.batch_no LIKE CONCAT('%-', slp.id)) |
| | | OR (sir.batch_no IS NULL AND sir.product_model_id = slp.product_model_id) |
| | | ) |
| | | WHERE sir.approval_status = 1 |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT slp.id AS sales_ledger_product_id, |
| | | sir.stock_in_num |
| | | FROM stock_in_record sir |
| | | INNER JOIN quality_inspect qi |
| | | ON TRIM(sir.record_type) = '10' |
| | | AND sir.record_id = qi.id |
| | | INNER JOIN sales_ledger_product slp |
| | | ON slp.type = 2 |
| | | AND slp.sales_ledger_id = qi.purchase_ledger_id |
| | | AND slp.product_model_id = qi.product_model_id |
| | | WHERE sir.approval_status = 1 |
| | | ) rel |
| | | GROUP BY rel.sales_ledger_product_id |
| | | ) approved_qty ON approved_qty.sales_ledger_product_id = slp.id |
| | | WHERE slp.type = 2 |
| | | ) product_status |
| | | GROUP BY product_status.sales_ledger_id |
| | | ) ls ON ls.sales_ledger_id = pl.id |
| | | <where> |
| | | <if test="c.purchaseContractNumber != null and c.purchaseContractNumber != ''"> |
| | | AND pl.purchase_contract_number LIKE CONCAT('%', #{c.purchaseContractNumber}, '%') |
| | | </if> |
| | | <if test="c.approvalStatus != null and c.approvalStatus != ''"> |
| | | AND pl.approval_status = #{c.approvalStatus} |
| | | </if> |
| | | <if test="c.supplierName != null and c.supplierName != ''"> |
| | | AND pl.supplier_name LIKE CONCAT('%', #{c.supplierName}, '%') |
| | | </if> |
| | | <if test="c.salesContractNo != null and c.salesContractNo != ''"> |
| | | AND pl.sales_contract_no LIKE CONCAT('%', #{c.salesContractNo}, '%') |
| | | </if> |
| | | <if test="c.projectName != null and c.projectName != ''"> |
| | | AND pl.project_name LIKE CONCAT('%', #{c.projectName}, '%') |
| | | </if> |
| | | <if test="c.entryDateStart != null and c.entryDateStart != ''"> |
| | | AND pl.entry_date >= #{c.entryDateStart} |
| | | </if> |
| | | <if test="c.entryDateEnd != null and c.entryDateEnd != ''"> |
| | | AND pl.entry_date <= #{c.entryDateEnd} |
| | | </if> |
| | | <if test="c.supplierId != null"> |
| | | AND pl.supplier_id = #{c.supplierId} |
| | | </if> |
| | | <if test="c.approvalStatus != null"> |
| | | AND pl.approval_status = #{c.approvalStatus} |
| | | </if> |
| | | </where> |
| | | ) result |
| | | <if test="c.stockInStatus != null and c.stockInStatus != ''"> |
| | | WHERE result.stock_in_status = #{c.stockInStatus} |
| | | </if> |
| | | ORDER BY result.entry_date DESC |
| | | </select> |
| | | |
| | | <select id="selectTotalPurchaseAmount" resultType="java.math.BigDecimal"> |
| | |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN qi.inspect_state = 1 |
| | | AND qi.check_result = 'åæ ¼' |
| | | THEN qi.quantity |
| | | THEN qi.qualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) AS qualifiedCount, |
| | |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN qi.inspect_state = 1 |
| | | AND qi.check_result = 'ä¸åæ ¼' |
| | | THEN qi.quantity |
| | | THEN qi.unqualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) AS unqualifiedCount, |
| | |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN qi.inspect_state = 1 |
| | | AND qi.check_result = 'åæ ¼' |
| | | THEN qi.quantity |
| | | THEN qi.qualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) |
| | |
| | | /* åæ ¼ */ |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN qi.inspect_state = 1 AND qi.check_result = 'åæ ¼' |
| | | THEN qi.quantity |
| | | WHEN qi.inspect_state = 1 |
| | | THEN qi.qualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) AS qualifiedCount, |
| | |
| | | /* ä¸åæ ¼ */ |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN qi.inspect_state = 1 AND qi.check_result = 'ä¸åæ ¼' |
| | | THEN qi.quantity |
| | | WHEN qi.inspect_state = 1 |
| | | THEN qi.unqualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) AS unqualifiedCount, |
| | |
| | | ROUND( |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN qi.inspect_state = 1 AND qi.check_result = 'åæ ¼' |
| | | THEN qi.quantity |
| | | WHEN qi.inspect_state = 1 |
| | | THEN qi.qualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) |
| | |
| | | |
| | | <select id="getYearlyPassRateStatistics" resultType="com.ruoyi.quality.dto.QualityPassRateDto"> |
| | | SELECT t.modelType, |
| | | |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN pp.product_name = 'åææ' AND t.modelType = 0 THEN qi.quantity |
| | |
| | | WHEN pp.product_name = 'æå' AND t.modelType = 2 THEN qi.quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) AS totalCount |
| | | |
| | | ), 0) AS totalCount, |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN pp.product_name = 'åææ' AND t.modelType = 0 THEN qi.qualified_quantity |
| | | WHEN pp.product_name = 'åæå' AND t.modelType = 1 THEN qi.qualified_quantity |
| | | WHEN pp.product_name = 'æå' AND t.modelType = 2 THEN qi.qualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) AS qualifiedCount, |
| | | COALESCE(SUM( |
| | | CASE |
| | | WHEN pp.product_name = 'åææ' AND t.modelType = 0 THEN qi.unqualified_quantity |
| | | WHEN pp.product_name = 'åæå' AND t.modelType = 1 THEN qi.unqualified_quantity |
| | | WHEN pp.product_name = 'æå' AND t.modelType = 2 THEN qi.unqualified_quantity |
| | | ELSE 0 |
| | | END |
| | | ), 0) AS unqualifiedCount |
| | | FROM (SELECT 0 AS modelType |
| | | UNION ALL |
| | | SELECT 1 |
| | |
| | | ON qi.product_model_id = pm.id |
| | | AND YEAR(qi.check_time) = #{year} |
| | | AND qi.inspect_state = 1 |
| | | AND qi.check_result = 'åæ ¼' |
| | | |
| | | GROUP BY t.modelType |
| | | ORDER BY t.modelType; |
| | | </select> |
| | |
| | | </if> |
| | | order by sl.execution_date desc |
| | | </select> |
| | | <select id="selectPurchaseReportVoPage" resultType="com.ruoyi.purchase.vo.PurchaseReportVo"> |
| | | select sl.sales_contract_no customerContractNo, |
| | | c.customer_name, |
| | | sl.project_name, |
| | | sl.contract_amount contractAmount, |
| | | pl.contract_amount purchaseAmount, |
| | | sl.contract_amount-pl.contract_amount balance, |
| | | (sl.contract_amount-pl.contract_amount)/sl.contract_amount balanceRatio |
| | | from sales_ledger sl |
| | | left join purchase_ledger pl on sl.id = pl.sales_ledger_id |
| | | left join customer c on sl.customer_id = c.id |
| | | where 1=1 |
| | | <if test="customerName != null and customerName != '' "> |
| | | and c.customer_name like concat('%',#{customerName},'%') |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | WHEN IFNULL(t3.shipped_quantity, 0) = 0 THEN 'å¾
åè´§' |
| | | WHEN (IFNULL(T1.quantity, 0) - IFNULL(t3.shipped_quantity, 0)) > 0 THEN 'é¨ååè´§' |
| | | ELSE 'å·²åè´§' |
| | | END as shippingStatus |
| | | END as shippingStatus, |
| | | CASE |
| | | WHEN T1.type != 2 THEN NULL |
| | | WHEN IFNULL(t4.approved_stock_in_num, 0) <= 0 THEN 'å¾
å
¥åº' |
| | | WHEN IFNULL(t4.approved_stock_in_num, 0) >= IFNULL(T1.quantity, 0) THEN 'å®å
¨å
¥åº' |
| | | ELSE 'å
¥åºä¸' |
| | | END AS stock_in_approval_status |
| | | FROM |
| | | sales_ledger_product T1 |
| | | LEFT JOIN ( |
| | |
| | | where si.status != 'å®¡æ ¸æç»' |
| | | GROUP BY sales_ledger_product_id |
| | | ) t3 ON t3.sales_ledger_product_id = T1.id |
| | | LEFT JOIN ( |
| | | SELECT rel.sales_ledger_product_id, |
| | | IFNULL(SUM(rel.stock_in_num), 0) AS approved_stock_in_num |
| | | FROM ( |
| | | SELECT slp.id AS sales_ledger_product_id, |
| | | sir.stock_in_num |
| | | FROM stock_in_record sir |
| | | INNER JOIN sales_ledger_product slp |
| | | ON slp.type = 2 |
| | | AND TRIM(sir.record_type) = '7' |
| | | AND sir.record_id = slp.sales_ledger_id |
| | | AND ( |
| | | (sir.batch_no IS NOT NULL AND sir.batch_no LIKE CONCAT('%-', slp.id)) |
| | | OR (sir.batch_no IS NULL AND sir.product_model_id = slp.product_model_id) |
| | | ) |
| | | WHERE sir.approval_status = 1 |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT slp.id AS sales_ledger_product_id, |
| | | sir.stock_in_num |
| | | FROM stock_in_record sir |
| | | INNER JOIN quality_inspect qi |
| | | ON TRIM(sir.record_type) = '10' |
| | | AND sir.record_id = qi.id |
| | | INNER JOIN sales_ledger_product slp |
| | | ON slp.type = 2 |
| | | AND slp.sales_ledger_id = qi.purchase_ledger_id |
| | | AND slp.product_model_id = qi.product_model_id |
| | | WHERE sir.approval_status = 1 |
| | | ) rel |
| | | GROUP BY rel.sales_ledger_product_id |
| | | ) t4 ON t4.sales_ledger_product_id = T1.id |
| | | left join product_model pm ON T1.product_model_id = pm.id |
| | | left join product p ON pm.product_id = p.id |
| | | <where> |
| | |
| | | FROM sales_quotation t1 |
| | | LEFT JOIN approve_process t2 ON t1.quotation_no = t2.approve_reason and t2.approve_type = 6 |
| | | WHERE 1=1 |
| | | and t2.approve_deleted = 0 |
| | | and t2.approve_delete = 0 |
| | | <if test="salesQuotationDto.quotationNo != null and salesQuotationDto.quotationNo != '' "> |
| | | AND t1.quotation_no LIKE CONCAT('%',#{salesQuotationDto.quotationNo},'%') |
| | | </if> |
| | |
| | | p.product_name as product_name, |
| | | pm.model, |
| | | pm.unit, |
| | | u.nick_name as createBy |
| | | u.nick_name as createBy, |
| | | CASE |
| | | WHEN #{params.topParentProductId} = 278 AND TRIM(sir.record_type) = '7' THEN |
| | | COALESCE(pl_by_product.purchase_contract_number, pl_direct.purchase_contract_number) |
| | | WHEN #{params.topParentProductId} = 278 AND TRIM(sir.record_type) = '10' THEN |
| | | pl_by_quality.purchase_contract_number |
| | | WHEN #{params.topParentProductId} = 276 THEN |
| | | CASE |
| | | WHEN TRIM(sir.record_type) IN ('14', '15') THEN |
| | | sl_return.sales_contract_no |
| | | WHEN TRIM(sir.record_type) IN ('2', '5') THEN |
| | | COALESCE(po_sales_main.sales_contract_no, po_main.nps_no) |
| | | WHEN TRIM(sir.record_type) = '6' THEN |
| | | COALESCE(po_sales_qi.sales_contract_no, po_qi.nps_no) |
| | | WHEN TRIM(sir.record_type) IN ('4', '11') THEN |
| | | COALESCE(po_sales_uq.sales_contract_no, po_uq.nps_no) |
| | | WHEN TRIM(sir.record_type) IN ('20', '22') THEN |
| | | COALESCE(po_sales_pick.sales_contract_no, po_pick.nps_no) |
| | | ELSE NULL |
| | | END |
| | | ELSE NULL |
| | | END AS sourceOrderNo |
| | | FROM stock_in_record as sir |
| | | LEFT JOIN product_model as pm on sir.product_model_id = pm.id |
| | | LEFT JOIN product as p on pm.product_id = p.id |
| | | LEFT JOIN sys_user as u on sir.create_user = u.user_id |
| | | LEFT JOIN quality_inspect as qi_purchase on TRIM(sir.record_type) = '10' and sir.record_id = qi_purchase.id |
| | | LEFT JOIN sales_ledger_product as slp on TRIM(sir.record_type) = '7' and slp.id = sir.record_id and slp.type = 2 |
| | | LEFT JOIN purchase_ledger as pl_by_product on TRIM(sir.record_type) = '7' and pl_by_product.id = slp.sales_ledger_id |
| | | LEFT JOIN purchase_ledger as pl_direct on TRIM(sir.record_type) = '7' and pl_direct.id = sir.record_id |
| | | LEFT JOIN purchase_ledger as pl_by_quality on TRIM(sir.record_type) = '10' and pl_by_quality.id = qi_purchase.purchase_ledger_id |
| | | |
| | | LEFT JOIN production_product_main as ppm_main on TRIM(sir.record_type) IN ('2', '5') and sir.record_id = ppm_main.id |
| | | LEFT JOIN production_operation_task as pot_main on ppm_main.production_operation_task_id = pot_main.id |
| | | LEFT JOIN production_order as po_main on pot_main.production_order_id = po_main.id |
| | | LEFT JOIN ( |
| | | select po2.id as production_order_id, |
| | | group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no |
| | | from production_order po2 |
| | | left join production_plan pp2 |
| | | on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0 |
| | | left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id |
| | | group by po2.id |
| | | ) as po_sales_main on po_sales_main.production_order_id = po_main.id |
| | | |
| | | LEFT JOIN quality_inspect as qi_prod on TRIM(sir.record_type) = '6' and sir.record_id = qi_prod.id |
| | | LEFT JOIN production_product_main as ppm_qi on qi_prod.product_main_id = ppm_qi.id |
| | | LEFT JOIN production_operation_task as pot_qi on ppm_qi.production_operation_task_id = pot_qi.id |
| | | LEFT JOIN production_order as po_qi on pot_qi.production_order_id = po_qi.id |
| | | LEFT JOIN ( |
| | | select po2.id as production_order_id, |
| | | group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no |
| | | from production_order po2 |
| | | left join production_plan pp2 |
| | | on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0 |
| | | left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id |
| | | group by po2.id |
| | | ) as po_sales_qi on po_sales_qi.production_order_id = po_qi.id |
| | | |
| | | LEFT JOIN quality_unqualified as qu on TRIM(sir.record_type) IN ('4', '11') and sir.record_id = qu.id |
| | | LEFT JOIN quality_inspect as qi_uq on qu.inspect_id = qi_uq.id |
| | | LEFT JOIN production_product_main as ppm_uq on qi_uq.product_main_id = ppm_uq.id |
| | | LEFT JOIN production_operation_task as pot_uq on ppm_uq.production_operation_task_id = pot_uq.id |
| | | LEFT JOIN production_order as po_uq on pot_uq.production_order_id = po_uq.id |
| | | LEFT JOIN ( |
| | | select po2.id as production_order_id, |
| | | group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no |
| | | from production_order po2 |
| | | left join production_plan pp2 |
| | | on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0 |
| | | left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id |
| | | group by po2.id |
| | | ) as po_sales_uq on po_sales_uq.production_order_id = po_uq.id |
| | | |
| | | LEFT JOIN production_order_pick as pop on TRIM(sir.record_type) IN ('20', '22') and sir.record_id = pop.id |
| | | LEFT JOIN production_order as po_pick on pop.production_order_id = po_pick.id |
| | | LEFT JOIN ( |
| | | select po2.id as production_order_id, |
| | | group_concat(distinct sl2.sales_contract_no order by sl2.sales_contract_no separator ',') as sales_contract_no |
| | | from production_order po2 |
| | | left join production_plan pp2 |
| | | on find_in_set(pp2.id, replace(replace(replace(po2.production_plan_ids, '[', ''), ']', ''), ' ', '')) > 0 |
| | | left join sales_ledger sl2 on sl2.id = pp2.sales_ledger_id |
| | | group by po2.id |
| | | ) as po_sales_pick on po_sales_pick.production_order_id = po_pick.id |
| | | |
| | | LEFT JOIN return_sale_product as rsp on TRIM(sir.record_type) IN ('14', '15') and sir.record_id = rsp.id |
| | | LEFT JOIN return_management as rm on rsp.return_management_id = rm.id |
| | | LEFT JOIN shipping_info as si_return on rm.shipping_id = si_return.id |
| | | LEFT JOIN sales_ledger as sl_return on si_return.sales_ledger_id = sl_return.id |
| | | <where> |
| | | <if test="params.timeStr != null and params.timeStr != ''"> |
| | | and sir.create_time like concat('%',#{params.timeStr},'%') |
| | |
| | | and (si.qualitity - ifnull(si.locked_quantity, 0)) > 0 |
| | | order by si.product_model_id, si.batch_no |
| | | </select> |
| | | <select id="getByModelId" resultType="com.ruoyi.stock.pojo.StockInventory"> |
| | | select si.id, si.batch_no, si.locked_quantity, (si.qualitity - IFNULL(sd.qualitity, 0)) as qualitity |
| | | <select id="getByModelId" resultType="com.ruoyi.stock.dto.StockInventoryDto"> |
| | | select si.id, si.batch_no, si.locked_quantity, (si.qualitity - IFNULL(sd.qualitity, 0)) as qualitity, |
| | | p.product_name, pm.model, pm.unit |
| | | from stock_inventory si |
| | | left join ( |
| | | select spd.stock_inventory_id, sum(spd.quantity) as qualitity |
| | |
| | | ) |
| | | group by spd.stock_inventory_id |
| | | ) as sd on sd.stock_inventory_id = si.id |
| | | left join product_model pm on si.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | where si.product_model_id = #{productModelId} |
| | | and si.qualitity > IFNULL(sd.qualitity, 0) |
| | | </select> |