瀏覽代碼

工资社保公积金导入,查询员工日均值

lamphua 3 週之前
父節點
當前提交
8f4f11b1bc

+ 70
- 0
oa-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/oa/CmcWageController.java 查看文件

@@ -1,7 +1,12 @@
1 1
 package com.ruoyi.web.controller.oa;
2 2
 
3
+import java.math.BigDecimal;
4
+import java.math.RoundingMode;
5
+import java.text.SimpleDateFormat;
6
+import java.time.YearMonth;
3 7
 import java.util.List;
4 8
 import javax.servlet.http.HttpServletResponse;
9
+
5 10
 import org.springframework.beans.factory.annotation.Autowired;
6 11
 import org.springframework.web.bind.annotation.GetMapping;
7 12
 import org.springframework.web.bind.annotation.PostMapping;
@@ -19,6 +24,7 @@ import com.ruoyi.oa.domain.CmcWage;
19 24
 import com.ruoyi.oa.service.ICmcWageService;
20 25
 import com.ruoyi.common.utils.poi.ExcelUtil;
21 26
 import com.ruoyi.common.core.page.TableDataInfo;
27
+import org.springframework.web.multipart.MultipartFile;
22 28
 
23 29
 /**
24 30
  * 员工工资Controller
@@ -65,6 +71,51 @@ public class CmcWageController extends BaseController
65 71
         return success(cmcWageService.selectCmcWageByWageId(wageId));
66 72
     }
67 73
 
74
+    /**
75
+     * 获取员工社保公积金日均值
76
+     */
77
+    @GetMapping(value = "/userDayValue")
78
+    public AjaxResult getUserDayValue(CmcWage cmcWage)
79
+    {
80
+        String queryYear = new SimpleDateFormat("yyyy").format(cmcWage.getPayMonth());
81
+        cmcWage.setPayMonth(null);
82
+        List<CmcWage> cmcWageList = cmcWageService.selectCmcWageList(cmcWage);
83
+        BigDecimal houseFundTotal = new BigDecimal(0);
84
+        BigDecimal socialSecurityUnitTotal = new BigDecimal(0);
85
+        int month = 0;
86
+        int days = 0;
87
+        if (cmcWageList.size() > 0) {
88
+            // 2025年4月至12月,按月除实际天数
89
+            if (cmcWageList.size() < 9) {
90
+                for (CmcWage wage : cmcWageList) {
91
+                    String payMonth = new SimpleDateFormat("yyyy-MM").format(wage.getPayMonth());
92
+                    houseFundTotal = houseFundTotal.add(wage.getHouseFund());
93
+                    socialSecurityUnitTotal = socialSecurityUnitTotal.add(wage.getSocialSecurityUnit());
94
+                    month ++;
95
+                    days += YearMonth.of(2025, Integer.parseInt(payMonth.split("-")[1])).lengthOfMonth();
96
+                }
97
+            }
98
+            // 2026年起,取上年日均值
99
+            else {
100
+                for (CmcWage wage : cmcWageList) {
101
+                    String payMonth = new SimpleDateFormat("yyyy-MM").format(wage.getPayMonth());
102
+                    int lastYear = Integer.parseInt(queryYear) - 1;
103
+                    if (payMonth.split("-")[0].equals(String.valueOf(lastYear))) {
104
+                        houseFundTotal = houseFundTotal.add(wage.getHouseFund());
105
+                        socialSecurityUnitTotal = socialSecurityUnitTotal.add(wage.getSocialSecurityUnit());
106
+                        month ++;
107
+                        days += YearMonth.of(Integer.parseInt(payMonth.split("-")[0]), Integer.parseInt(payMonth.split("-")[1])).lengthOfMonth();
108
+                    }
109
+                }
110
+            }
111
+            if (month > 0) {
112
+                cmcWage.setHouseFund(houseFundTotal.divide(new BigDecimal(days), RoundingMode.CEILING));
113
+                cmcWage.setSocialSecurityUnit(socialSecurityUnitTotal.divide(new BigDecimal(days), RoundingMode.CEILING));
114
+            }
115
+        }
116
+        return success(cmcWage);
117
+    }
118
+
68 119
     /**
69 120
      * 新增员工工资
70 121
      */
@@ -75,6 +126,25 @@ public class CmcWageController extends BaseController
75 126
         return toAjax(cmcWageService.insertCmcWage(cmcWage));
76 127
     }
77 128
 
129
+    /**
130
+     * 上传工资excel文件
131
+     */
132
+    @PostMapping("/uploadSheet")
133
+    public AjaxResult uploadWageSheet(MultipartFile file) throws Exception {
134
+        if (file.isEmpty()) {
135
+            return AjaxResult.error("文件内容为空!");
136
+        }
137
+        else {
138
+            ExcelUtil<CmcWage> util = new ExcelUtil<CmcWage>(CmcWage.class);
139
+            List<CmcWage> cmcWageList = util.importExcel(file.getInputStream());
140
+            for (CmcWage cmcWage : cmcWageList) {
141
+                cmcWage.setUserId(cmcWage.getUserId() + 1);
142
+                cmcWageService.insertCmcWage(cmcWage);
143
+            }
144
+            return AjaxResult.success("上传成功");
145
+        }
146
+    }
147
+
78 148
     /**
79 149
      * 修改员工工资
80 150
      */

+ 19
- 2
oa-back/ruoyi-system/src/main/java/com/ruoyi/oa/domain/CmcWage.java 查看文件

@@ -3,6 +3,7 @@ package com.ruoyi.oa.domain;
3 3
 import java.math.BigDecimal;
4 4
 import java.util.Date;
5 5
 import com.fasterxml.jackson.annotation.JsonFormat;
6
+import com.ruoyi.common.core.domain.entity.SysUser;
6 7
 import org.apache.commons.lang3.builder.ToStringBuilder;
7 8
 import org.apache.commons.lang3.builder.ToStringStyle;
8 9
 import com.ruoyi.common.annotation.Excel;
@@ -21,10 +22,14 @@ public class CmcWage extends BaseEntity
21 22
     /** 工资id */
22 23
     private Integer wageId;
23 24
 
24
-    /** 员工id */
25
-    @Excel(name = "员工id")
25
+    /** 用户序号 */
26
+    @Excel(name = "用户序号")
26 27
     private Long userId;
27 28
 
29
+    /** 姓名 */
30
+    @Excel(name = "姓名")
31
+    private String nickName;
32
+
28 33
     /** 基础工资 */
29 34
     @Excel(name = "基础工资")
30 35
     private BigDecimal baseSalary;
@@ -114,6 +119,8 @@ public class CmcWage extends BaseEntity
114 119
     /** 绩效审批id */
115 120
     private String performanceId;
116 121
 
122
+    private SysUser user;
123
+
117 124
     public void setWageId(Integer wageId) 
118 125
     {
119 126
         this.wageId = wageId;
@@ -330,6 +337,16 @@ public class CmcWage extends BaseEntity
330 337
     {
331 338
         return performanceId;
332 339
     }
340
+    public void setUser(SysUser user)
341
+    {
342
+        this.user = user;
343
+        this.nickName = user == null ? "" : user.getNickName();
344
+    }
345
+
346
+    public SysUser getUser()
347
+    {
348
+        return user;
349
+    }
333 350
 
334 351
     @Override
335 352
     public String toString() {

+ 33
- 24
oa-back/ruoyi-system/src/main/resources/mapper/oa/CmcWageMapper.xml 查看文件

@@ -30,38 +30,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
30 30
         <result property="payMonth"    column="pay_month"    />
31 31
         <result property="remark"    column="remark"    />
32 32
         <result property="performanceId"    column="performance_id"    />
33
+        <association property="user"    javaType="SysUser"         resultMap="SysUserResult" />
34
+    </resultMap>
35
+
36
+    <resultMap type="SysUser" id="SysUserResult">
37
+        <result property="userId"    column="user_id"    />
38
+        <result property="nickName"    column="nick_name"    />
33 39
     </resultMap>
34 40
 
35 41
     <sql id="selectCmcWageVo">
36
-        select wage_id, user_id, base_salary, year_salary, post_salary, performance_salary, certificates_subsidy, festival_subsidy, post_stable_subsidy, high_temperature_subsidy, attendance_deduct, payable_wage, house_fund, endowment_insurance, unemployment_insurance, medical_insurance, property_fee, deduct_total, social_security_unit, individual_income_tax, paid_wage, pay_day, pay_month, remark, performance_id from cmc_wage
42
+        select w.wage_id, w.user_id, w.base_salary, w.year_salary, w.post_salary, w.performance_salary, w.certificates_subsidy, w.festival_subsidy, w.post_stable_subsidy,
43
+               w.high_temperature_subsidy, w.attendance_deduct, w.payable_wage, w.house_fund, w.endowment_insurance, w.unemployment_insurance, w.medical_insurance, w.property_fee,
44
+               w.deduct_total, w.social_security_unit, w.individual_income_tax, w.paid_wage, w.pay_day, w.pay_month, w.remark, w.performance_id, u.nick_name from cmc_wage as w
45
+        left join sys_user as u on u.user_id = w.user_id
37 46
     </sql>
38 47
 
39 48
     <select id="selectCmcWageList" parameterType="CmcWage" resultMap="CmcWageResult">
40 49
         <include refid="selectCmcWageVo"/>
41 50
         <where>  
42
-            <if test="userId != null "> and user_id = #{userId}</if>
43
-            <if test="baseSalary != null "> and base_salary = #{baseSalary}</if>
44
-            <if test="yearSalary != null "> and year_salary = #{yearSalary}</if>
45
-            <if test="postSalary != null "> and post_salary = #{postSalary}</if>
46
-            <if test="performanceSalary != null "> and performance_salary = #{performanceSalary}</if>
47
-            <if test="certificatesSubsidy != null "> and certificates_subsidy = #{certificatesSubsidy}</if>
48
-            <if test="festivalSubsidy != null "> and festival_subsidy = #{festivalSubsidy}</if>
49
-            <if test="postStableSubsidy != null "> and post_stable_subsidy = #{postStableSubsidy}</if>
50
-            <if test="highTemperatureSubsidy != null "> and high_temperature_subsidy = #{highTemperatureSubsidy}</if>
51
-            <if test="attendanceDeduct != null "> and attendance_deduct = #{attendanceDeduct}</if>
52
-            <if test="payableWage != null "> and payable_wage = #{payableWage}</if>
53
-            <if test="houseFund != null "> and house_fund = #{houseFund}</if>
54
-            <if test="endowmentInsurance != null "> and endowment_insurance = #{endowmentInsurance}</if>
55
-            <if test="unemploymentInsurance != null "> and unemployment_insurance = #{unemploymentInsurance}</if>
56
-            <if test="medicalInsurance != null "> and medical_insurance = #{medicalInsurance}</if>
57
-            <if test="propertyFee != null "> and property_fee = #{propertyFee}</if>
58
-            <if test="deductTotal != null "> and deduct_total = #{deductTotal}</if>
59
-            <if test="socialSecurityUnit != null "> and social_security_unit = #{socialSecurityUnit}</if>
60
-            <if test="individualIncomeTax != null "> and individual_income_tax = #{individualIncomeTax}</if>
61
-            <if test="paidWage != null "> and paid_wage = #{paidWage}</if>
62
-            <if test="payDay != null "> and pay_day = #{payDay}</if>
63
-            <if test="payMonth != null "> and pay_month = #{payMonth}</if>
64
-            <if test="performanceId != null and performanceId != ''"> and performance_id = #{performanceId}</if>
51
+            <if test="userId != null "> and w.user_id = #{userId}</if>
52
+            <if test="baseSalary != null "> and w.base_salary = #{baseSalary}</if>
53
+            <if test="yearSalary != null "> and w.year_salary = #{yearSalary}</if>
54
+            <if test="postSalary != null "> and w.post_salary = #{postSalary}</if>
55
+            <if test="performanceSalary != null "> and w.performance_salary = #{performanceSalary}</if>
56
+            <if test="certificatesSubsidy != null "> and w.certificates_subsidy = #{certificatesSubsidy}</if>
57
+            <if test="festivalSubsidy != null "> and w.festival_subsidy = #{festivalSubsidy}</if>
58
+            <if test="postStableSubsidy != null "> and w.post_stable_subsidy = #{postStableSubsidy}</if>
59
+            <if test="highTemperatureSubsidy != null "> and w.high_temperature_subsidy = #{highTemperatureSubsidy}</if>
60
+            <if test="attendanceDeduct != null "> and w.attendance_deduct = #{attendanceDeduct}</if>
61
+            <if test="payableWage != null "> and w.payable_wage = #{payableWage}</if>
62
+            <if test="houseFund != null "> and w.house_fund = #{houseFund}</if>
63
+            <if test="endowmentInsurance != null "> and w.endowment_insurance = #{endowmentInsurance}</if>
64
+            <if test="unemploymentInsurance != null "> and w.unemployment_insurance = #{unemploymentInsurance}</if>
65
+            <if test="medicalInsurance != null "> and w.medical_insurance = #{medicalInsurance}</if>
66
+            <if test="propertyFee != null "> and w.property_fee = #{propertyFee}</if>
67
+            <if test="deductTotal != null "> and w.deduct_total = #{deductTotal}</if>
68
+            <if test="socialSecurityUnit != null "> and w.social_security_unit = #{socialSecurityUnit}</if>
69
+            <if test="individualIncomeTax != null "> and w.individual_income_tax = #{individualIncomeTax}</if>
70
+            <if test="paidWage != null "> and w.paid_wage = #{paidWage}</if>
71
+            <if test="payDay != null "> and w.pay_day = #{payDay}</if>
72
+            <if test="payMonth != null "> and MONTH(w.pay_month) = MONTH(#{payMonth})</if>
73
+            <if test="performanceId != null and performanceId != ''"> and w.performance_id = #{performanceId}</if>
65 74
         </where>
66 75
     </select>
67 76
     

+ 1
- 1
oa-ui/src/views/oa/wage/index.vue 查看文件

@@ -51,7 +51,7 @@
51 51
 
52 52
     <el-table v-loading="loading" :data="wageList" @selection-change="handleSelectionChange">
53 53
       <el-table-column type="selection" width="55" align="center" />
54
-      <el-table-column label="姓名" align="center" prop="userId">
54
+      <el-table-column label="姓名" align="center" prop="user.nickName">
55 55
 
56 56
       </el-table-column>
57 57
       <!-- <el-table-column label="基础工资" align="center" prop="baseSalary" />

Loading…
取消
儲存