From 43113d6b1670530dfb4348836fd491c79f36af0a Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期二, 10 三月 2026 10:31:20 +0800
Subject: [PATCH] Merge branch 'dev_New' into dev_宁夏_中盛建材

---
 src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java |   42 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java b/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
index e8d3982..068bcfb 100644
--- a/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
+++ b/src/main/java/com/ruoyi/staff/service/impl/SchemeApplicableStaffServiceImpl.java
@@ -4,6 +4,9 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.production.dto.UserAccountDto;
+import com.ruoyi.production.dto.UserProductionAccountingDto;
+import com.ruoyi.production.service.SalesLedgerProductionAccountingService;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.domain.SysUserDept;
@@ -58,6 +61,9 @@
 
     @Autowired
     private StaffOnJobMapper staffOnJobMapper;
+
+    @Autowired
+    private SalesLedgerProductionAccountingService salesLedgerProductionAccountingService;
 
 
     @Override
@@ -160,7 +166,7 @@
      * 閫氳繃鍛樺伐id璁$畻绀句繚鏂规
      * @param id
      */
-    public void calculateByEmployeeId(Integer id,Map<String, Object> map) {
+    public void calculateByEmployeeId(Integer id,Map<String, Object> map,String date) {
         // 1. 鍏ュ弬鏍¢獙
         if (id == null) {
             return; // 鎴栬繑鍥炵┖鍒楄〃锛屾牴鎹笟鍔¢渶姹傝皟鏁�
@@ -211,6 +217,20 @@
         // 涓◣閲戦锛堟棤绀句繚鐗堬級
         BigDecimal bigDecimal = TaxCalculator.calculateMonthlyTax(basicSalary, schemeAmount, gjj);
         map.put("salaryTax", bigDecimal);
+        // 璁℃椂宸ヨ祫 璁′欢宸ヨ祫
+        UserProductionAccountingDto userProductionAccountingDto = new UserProductionAccountingDto();
+        userProductionAccountingDto.setUserId(getUidByStaffId(staffId));
+        userProductionAccountingDto.setDate(date);
+        UserAccountDto byUserId = salesLedgerProductionAccountingService.getByUserId(userProductionAccountingDto);
+        if(byUserId != null){
+            map.put("pieceSalary", byUserId.getAccountBalance());
+            map.put("hourlySalary", byUserId.getAccount());
+            // 搴斿彂 瀹炲彂澧炲姞
+            grossSalary = grossSalary.add(byUserId.getAccountBalance()).add(byUserId.getAccount());
+            map.put("grossSalary", grossSalary);
+            netSalary = netSalary.add(byUserId.getAccountBalance()).add(byUserId.getAccount());
+            map.put("netSalary", netSalary);
+        }
         // 2. 鏌ヨ璇ヤ汉鍛樺搴旂殑绀句繚鏂规
         List<SchemeApplicableStaff> schemeList = schemeApplicableStaffMapper.selectSchemeByStaffId(staffId);
         if (CollectionUtils.isEmpty(schemeList)) {
@@ -244,6 +264,26 @@
     }
 
     /**
+     * 閫氳繃鍛樺伐Id鑾峰彇鐢ㄦ埛id
+     * @param staffId
+     * @return
+     */
+    public Long getUidByStaffId(Long staffId){
+        StaffOnJob staffOnJob = staffOnJobMapper.selectById(staffId);
+        if(staffOnJob == null){
+            return -1L; // 杩斿洖涓嶅瓨鍦↖d
+        }
+        SysUser sysUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>()
+                .eq(SysUser::getUserName, staffOnJob.getStaffNo())
+                .eq(SysUser::getDelFlag, "0")
+                .last("limit 1"));
+        if(sysUser == null){
+            return -1L; // 杩斿洖涓嶅瓨鍦↖d
+        }
+        return sysUser.getUserId();
+    }
+
+    /**
      * 璁$畻
      * @param type
      * @param bigDecimal

--
Gitblit v1.9.3